1
0
forked from 0ad/0ad
Commit Graph

1124 Commits

Author SHA1 Message Date
6db0f91823 Sort GUI Object types, GUI Object bases and GUI Setting value types into three new folders.
Differential Revision: https://code.wildfiregames.com/D2345
Tested on: gcc 9.1.0
Comments By: Vladislav
This was SVN commit r23028.
2019-10-02 09:44:00 +00:00
32d6d07eda Rename CClientArea to CGUISize, GUIbase.h to CGUISize.h, avoid temporary instances and default value and error duplication.
The name is in accordance with its JS classname, member names and
setting names.

Differential Revision: https://code.wildfiregames.com/D2341
Tested on: clang 8.0.1, Jenkins/vs2015

This was SVN commit r23023.
2019-10-01 15:06:13 +00:00
07cc1ba34c Move GUIbase structs and enums to separate files.
Differential Revision: https://code.wildfiregames.com/D2340
Tested on: clang 8.0.1, Jenkins

This was SVN commit r23022.
2019-10-01 12:46:55 +00:00
8190293f8b Remove virtual inheritance from the codebase, refs 6b51d71c85, e21ebb37f5 e326ebae46.
Remove workaround in 3d07327837 / D2136, the pointer from IGUIObject to
IGUITextOwner that avoided the dynamic_cast.
Have the GUIObject implementing class take responsibility of calling the
virtual methods in the base classes.
Leaves the code in a clean state that can serve as an example for new
GUI object classes, such as D1346, refs #4683.

Differential Revision: https://code.wildfiregames.com/D2325
Comments By: Vladislav on IRC 2019-07-30, 2019-08-22, 2019-09-20-23
Tested on: clang 8.0.1, Jenkins

This was SVN commit r23020.
2019-09-30 14:08:14 +00:00
218399bf3d Rename JSInterface_GUITypes to JSInterface_GUISize, refs 8734efca94, 9be8a560a9.
Rename init to RegisterScriptClass.

Differential Revision: https://code.wildfiregames.com/D2339
Tested on: clang 8.0.1., Jenkins/vs2015

This was SVN commit r23018.
2019-09-30 08:19:56 +00:00
52b7fd5cd9 Remove redundant IGUITextOwner::AddText IGUIObject/this argument.
Differential Revision: https://code.wildfiregames.com/D2333
Tested on: clang 8.0.1., Jenkins/vs2015

This was SVN commit r23009.
2019-09-28 11:46:06 +00:00
b097f38a79 Remove little IGUIButtonBehavior::DrawButton duplication.
Differential Revision: https://code.wildfiregames.com/D2332
Tested on: clang 8.0.1., gcc 9.1.0, Jenkins/vs2015

This was SVN commit r23008.
2019-09-28 11:33:58 +00:00
813fc38420 Fix alphabetic sorting induced syntax error in previous, a33fd55e81/D2313, reported by go2die.
This was SVN commit r23006.
2019-09-27 14:08:00 +00:00
a33fd55e81 Change GUI Object Setting values to be members of the IGUIObject inheriting class, rename AddSetting to RegisterSetting.
Improves performance for Draw calls by 3-5% according to a shady
benchmark.
Improves memory layout, since the values are not on the heap anymore but
in the using class.
Reduces complexity of the implementation and increases type safety.
Allows specifying default values at setting value construction time,
refs D2242.
Inspired by Vladislav introducing members that cached GetSetting values
in c016a74309/D325, refs #4039, ee38f0db37/D763, refs 4225,
a1c4c23ce4/D474, D406, which were formerly proposed to be removed in
D2241.

Differential Revision: https://code.wildfiregames.com/D2313
Tested on: clang 8.0.1, gcc 9.1.0, Jenkins vs2015
Comments By: Vladislav
This was SVN commit r23005.
2019-09-27 12:49:59 +00:00
7790fd7d29 Removes duplication of Clamp function.
Reviewed By: wraitii
Commented By: Stan
Differential Revision: https://code.wildfiregames.com/D1763
This was SVN commit r23002.
2019-09-26 21:14:21 +00:00
b9d413852b Cleanup GUI includes, whitespace, map iterators, nullptr.
Remove TODO comment about m_Children deletion from e21ebb37f5, refs
e05f939fab / D2311.

Differential Revision: https://code.wildfiregames.com/D2321
Tested on: clang 8.0.1, Jenkins

This was SVN commit r22976.
2019-09-22 23:28:25 +00:00
e67f364887 Warn if the derived class and the base class have the same AddSetting call instead of silently ignoring it.
Enabled by f69261d37b (refs d412b2010b / D2314, 7bb0f2ea69 / D2318).
Helps structuring the GUI so that AddSetting and GetSetting are in the
same file, which defragments code and may allow for future optimizations
(setting values as class members for Draw calls), refs D2313.

Differential Revision: https://code.wildfiregames.com/D2320
Tested on: clang 8.0.1, Jenkins

This was SVN commit r22975.
2019-09-22 22:49:20 +00:00
7bb0f2ea69 Defragment IGUIButtonBehavior Settings.
Moves the AddSetting sound calls from CButton and CCheckbox to
IGUIButtonBehavior, since the latter is the only class to use them.
Moves ChooseColor from IGUIButtonBehavior to CButton, since that's the
only class to use it and the only class registering the dependent
Settings following b1422137e5 (refs d412b2010b / D2314)

Initialize m_PressedRight in the constructor to prevent undefined
behavior in possible future code following 0d204037b6, refs #1028.
Remove unused soundPath variable following 0e26503cc6 / D2209.

Differential Revision: https://code.wildfiregames.com/D2318
Tested on: clang 8.0.1, Jenkins

This was SVN commit r22969.
2019-09-22 14:53:27 +00:00
d1bcce55db Improve js glue code in D1839/61e3f1ec0d (hotkey state fix) and deal with rebase leftovers.
The code could be improved by using more modern code.

Reviewed By: elexis
Differential Revision: https://code.wildfiregames.com/D2295
This was SVN commit r22963.
2019-09-22 07:38:13 +00:00
f69261d37b Remove AddSetting<CStrW>("tooltip") and AddSetting<CStr>("tooltip_style") calls redundant with the ones in the IGUIObject base constructor.
If all redundant calls are removed, the code will be able to warn about
them.

Tested on: clang 8.0.1

This was SVN commit r22958.
2019-09-21 16:13:18 +00:00
d412b2010b Delete unused CCheckbox text setting remains following b1422137e5, refs 0f807c643a.
Differential Revision: https://code.wildfiregames.com/D2314
Tested on: clang 8.0.1., Jenkins

This was SVN commit r22952.
2019-09-21 03:11:18 +00:00
734d21464b Fix missing JSAutoRequest before JS_ReportError in various commits.
Differential Revision: https://code.wildfiregames.com/D2256
Tested on: clang 8.0.1, Jenkins

This was SVN commit r22949.
2019-09-20 19:18:07 +00:00
e05f939fab Delete empty IGUIObject::Destroy function and MEGA TODO from 5122b0f906, e21ebb37f5.
None of the GUI object types implemented in the past two decades owns
children, only the CGUI page.

Differential Revision: https://code.wildfiregames.com/D2311
Tested on: clang 8.0.1, Jenkins

This was SVN commit r22943.
2019-09-20 15:25:13 +00:00
1bc6d778bb Delete GUI.h umbrella include following 8d0cb1b954.
Differential Revision: https://code.wildfiregames.com/D2304
Tested on: clang 8.0.1., VS2015, Jenkins
Comments By: Vladislav, Angen, Stan
Tested by: Angen
This was SVN commit r22941.
2019-09-20 13:11:18 +00:00
a936cc618a Move CGUIDummyObject class used for empty GUI objects to a separate file, and put the according CGUI page base object on the stack.
Differential Revision: https://code.wildfiregames.com/D2206
Tested on: clang 8.0.1., Jenkins

This was SVN commit r22931.
2019-09-18 20:51:45 +00:00
f1de8eb4ba Removes usages of duplication of Clamp function in gui, ps and renderer. Refs D1763.
This was SVN commit r22926.
2019-09-18 14:44:31 +00:00
003d588d13 Happy savegame hack removal following e0ea53a8ee, refs #2030.
Simply pass the JS value to the Save functions instead of letting those
obtain the data later from the topmost GUI page.
The JS hack incidence appears to be unused since 4b1297b328.

Differential Revision: https://code.wildfiregames.com/D2302
Tested on: clang 8.0.1, Jenkins

This was SVN commit r22922.
2019-09-18 00:17:56 +00:00
41475093b0 Fix struc tree / civ info hotkeys following rebase error in adf448db4d / D2240 and don't trigger global hotkey handlers upon release following f192d4a2fa / D2260.
Differential Revision: https://code.wildfiregames.com/D2273
Tested on: clang 8.0.1., Jenkins
Tested by: Nescio
This was SVN commit r22920.
2019-09-17 22:42:50 +00:00
a3d8807833 Fix 61e3f1ec0d on Windows.
Patch By: Angen
Reviewed By: elexis
Differential Revision: https://code.wildfiregames.com/D2299
This was SVN commit r22917.
2019-09-17 19:27:38 +00:00
4d4bf579b2 Report and tolerate XML GUI object setting errors when parsing XML attribute strings as values for settings that don't exist on the GUI object.
Following e326ebae46, 80b1876b77, d6db5a466d, ... the XML errors were
silently ignored.
Following 1a49ccb294 it led to a crash (m_Setting access for an item
that does not exist).

Differential Revision: https://code.wildfiregames.com/D2297
Tested on: clang 8.0.1, Jenkins

This was SVN commit r22911.
2019-09-16 16:13:25 +00:00
61e3f1ec0d Fix hotkey events synching with hotkey state.
This is a semi-revert of 78bc56f33e and a correct fix for #3194.

The core issue is that the GUI handler must come behore the hotkey
handler, otherwise typing in boxes can set off hotkeys, and the hotkey
handler is repsonsible for updating the hotkey state.
Thus the GUI handler never has an up-to-date hotkey state, since that's
done later. 78bc56f33e fixed that by calling HotkeyInputHandler
manually, but that was still broken in some (unused) cases and was hacky
(indeed, it even looked hacky as noted by elexis).

The simplest fix is to split the 'hotkey creator' handler from the
'hotkey state change' handler, and run the 'hotkey state change handler'
before any other handler. Thus the gui handler remains in front of the
'hotkey creator' handler, but it has a correct hotkey state at any time.

Differential Revision: https://code.wildfiregames.com/D1839
This was SVN commit r22909.
2019-09-15 12:16:28 +00:00
a84e2e57df Use ScriptInterface::CreateObject for ToJSVal<CColor>, and for ToJSVal<Grid<u8> >, ToJSVal<Grid<u16> > used by the AIManager obtaining the pathfinder grid.
Make that function static, so that it can be used for these functions
without slowly having to obtain the ScriptInterface instance using
GetScriptInterfaceAndCBData just to get the JSContext again.
Remove few redundant conversions for CreateObject arguments.

Differential Revision: https://code.wildfiregames.com/D2128
Tested on: gcc 9.1.0, clang 8.0.1, Jenkins
Tedious performance testing in: D2128, D2127

This was SVN commit r22894.
2019-09-13 00:56:51 +00:00
de050ef7e2 Remove some unused Profiler.h and CLogger.h includes.
NativeWrapperDefns.h from 4e87fef3da, found in audit of 7c21a0cf8e.

Differential Revision: https://code.wildfiregames.com/D2268
Tested on: clang 8.0.1, Jenkins

This was SVN commit r22863.
2019-09-07 13:35:45 +00:00
f192d4a2fa Support assigning functions to hotkeys from the JS GUI without involving a GUI object.
Allows developers and modders to register and unregister hotkeys without
having to specify, change or overwrite XML files.
Also allows implementing the main menu GUI page with only GUI objects
for one submenu, refs #5387 / D2240.

Differential Revision: https://code.wildfiregames.com/D2260
Idea by nani in D2257.

This was SVN commit r22851.
2019-09-05 10:42:16 +00:00
d5c1fd09a4 Add ToJSVal<CRect> to make the conversion reusable, remove unused PSERROR_Scripting_ConversionFailed and dead catch.
Avoids the CRect copy or stops relying on optimization to avoid the
copy.
Split from D2142.

Differential Revision: https://code.wildfiregames.com/D2259
Tested on: gcc 9.1.0, Jenkins

This was SVN commit r22847.
2019-09-04 16:15:37 +00:00
c25ab670e6 Don't crash if a JS GUI author calls Engine.PopGuiPage too often.
Differential Revision: https://code.wildfiregames.com/D2255
Tested On: clang 8.0.1, Jenkins
Comments By: Stan
This was SVN commit r22846.
2019-09-04 15:45:48 +00:00
33af6da5e1 Implement JS support for GUI object "hotkey" setting missing from 6d8b9e33ef, refs #567, #2604, 9e499cdec5.
Allows JS GUI to assign hotkeys to GUI objects from JS instead of XML.

Differential Revision: https://code.wildfiregames.com/D2257
Comments By: nani
Tested By: nani, Jenkins
Tested on: clang, VS2015

This was SVN commit r22845.
2019-09-04 15:29:36 +00:00
9c6039e4fe Solemnly delete class GUI and rename GUIUtil.h to CGUISetting.h.
Finishes GUIutil rewrite and fixes #5575.

Differential Revision: https://code.wildfiregames.com/D2233
Test on: clang 8.0.1, Jenkins

This was SVN commit r22801.
2019-08-29 09:07:29 +00:00
1a49ccb294 Move static GUI<>::SetSetting operating on IGUIObject to a member IGUIObject::SetSetting.
Remove PSERROR codes from SetSetting (let std::map throw an out_of_range
if a caller wants to Set a setting that doesn't exist without having
checked with SettingExists, equal to GetSetting from 92b6cdfeab).
That also simplifies std::function SetSettingWrap construct from
0a7d0ecdde to void IGUIObject::SettingChanged.
Don't trigger debug_warn or exceptions in GUITooltip::ShowTooltip if the
XML author specified wrong tooltip input, and dodge another
dynamic_cast.

Rename existing IGUIObject::SetSetting to
IGUIObject::SetSettingFromString and comment that it is purposed for
parsing XML files.
Remove SetSetting default value, so that authors are made aware
explicitly of the need to decide the function broadcasting a message,
refs d87057b1c0, 719f2d7967, ...
Change const bool& SkipMessage to const bool SendMessage, so that a
positive value relates to a positive action.
Clean AddSettings whitespace and integer types.

Differential Revision: https://code.wildfiregames.com/D2231
Tested on: gcc 9.1.0, clang 8.0.1, Jenkins
Comments By: Philip on IRC on 2010-07-24 on GUIUtil being ugly, in case
that one counts

This was SVN commit r22796.
2019-08-28 11:21:11 +00:00
be963ec9b7 Delete 27 invalid style settings and add LOGWARNING to inform future authors.
Unify the two IGUIObject::LoadStyle functions and remove CGUI argument
that is always identical to the member.

Differential Revision: https://code.wildfiregames.com/D2232
Tested on: gcc 9.1.0., clang 8.0.1, Jenkins

This was SVN commit r22792.
2019-08-27 16:03:24 +00:00
0a6b650189 Delete SGUIMessage GUIM_SETTINGS_UPDATED broadcasts redundant with the broadcast initiated from SetSetting from e21ebb37f5.
659a9ea57a introduced the call rightfully in ShowTooltip since
CTooltip::SetupText() depends on the just changed _mousepos setting.
But then 0382cdd9b1 moved that _mousepos SetSetting call, resulting in
the message becoming redundant; and it inserted the second redundant
message in HideTooltip.

These were the only redundant SGUIMessage HandleMessage calls.

This was SVN commit r22790.
2019-08-26 23:39:16 +00:00
92b6cdfeab Move static GUI<>::GetSetting operating on IGUIObject member to a IGUIObject member function, grouping it with SettingExists and AddSetting.
Differential Revision: https://code.wildfiregames.com/D2230
Tested on: gcc 9.1.0, Jenkins

This was SVN commit r22789.
2019-08-26 12:25:07 +00:00
4919a6185e Remove unused GUIUtil functions, unused GUI includes and some tails in GUIUtil.
HasSetting from 3dfa23cd25 is actually redundant with
IGUIObject::SettingExists.
GetSettingPointer from 8f4f8e240f is superseded by GetSetting reference
following 3dfa23cd25 and 040624acff.
Deregister copying SetSetting variants for CStr and CStrW following copy
removal in 040624acff.
The default template <typename T=int> from c2a71e41bf can be removed
following FallBackSprite/FallBackColor removal in 9985fcf5bd and
RecurseObject unification in d4d5187c9d.
Delete all unused GUI includes, refs D1478.
Remove GUIUtil friend class following something.

Differential Revision: https://code.wildfiregames.com/D2225
Tested on: gcc 9.1.0, Jenkins

This was SVN commit r22779.
2019-08-25 08:57:36 +00:00
b197df5ee6 Fix valgrind conditional jump depending on uninitialised value warning in CGUIManager::HandleEvent from 7c2e9027c2.
The warning seems to be a false positive and happens with clang but not
gcc.

Differential Revision: https://code.wildfiregames.com/D2223
Reviewed By: Vladislav
This was SVN commit r22777.
2019-08-24 22:25:26 +00:00
040624acff Replace copy-assigning GUI<T>::GetSetting from c2a71e41bf with the reference returning GetSetting from 3dfa23cd25.
Avoids one or two dozen unoptimizable string copies and two CPos copies,
mostly in SetupText.

The reference return allows to mark values as const where the previous
one prevented that.
This also reveals unused variables where the previous code hid them.

Thus use unused variable "buffer_zone" in the otherwise unused (since
b1422137e5, refs 0f807c643a) CCheckBox::SetupText() from b5f6d19332 and
use the unused variable "scrollbar" in CInput GUIM_MOUSE_PRESS_LEFT from
4113aa0a36.

Refs unintentionally copied DrawCall cache due to GetSetting copying in
c19f3608a5, fixed in 8f4f8e240f.

Differential Revision: https://code.wildfiregames.com/D2215
This was SVN commit r22765.
2019-08-23 14:43:10 +00:00
e02afa279c Remove hardcoded C++ fallback font from 70d84beab2 and according TODO from 924b0bf1b4 that was fixed in 6af0d7cfd3 by having the default style specify the default font.
Use references instead of copies for obtaining the font in SetupText().

Differential Revision: https://code.wildfiregames.com/D2214
This was SVN commit r22761.
2019-08-23 03:28:04 +00:00
8609041ddf Fix missing actual boolean check in the commit removing the odd way to check for a boolean in 77b81d8761.
Reported By: Vladislav
Reviewed By: Vladislav
This was SVN commit r22758.
2019-08-23 00:42:00 +00:00
f4990cf967 Mark some GUI functions as const, including the boolean ones from d4d5187c9d.
Rename MouseOver to IsMouseOver.

Reported By: Vladislav
This was SVN commit r22757.
2019-08-22 23:51:10 +00:00
0e26503cc6 Introduce IGUIObject::PlaySound to unify 19 copies of the UI sound play following 9565c60a14, refs #948.
Stops copying the CStrW each time a sound is played by using the
reference GetSetting variant.

Differential Revision: https://code.wildfiregames.com/D2209
This was SVN commit r22756.
2019-08-22 22:34:12 +00:00
d4d5187c9d Use variadic template for RecurseObject from c2a71e41bf and move it from GUIutil to IGUIObject.
Unifies the four copies of the function while making it more versatile.
Supersede the hardcoded GUIRR enum and CheckIfRestricted function with a
flexible member function pointer.
Replace the custom IGUIObject iterator with a casually iterable
GetChildren getter, so that it is more obvious what it iterates on.
Implement TODO from e21ebb37f5, i.e. RecurseObject not iterating over
the base object.

Differential Revision: https://code.wildfiregames.com/D2204
Tested on: gcc 9.1.0, clang 8.0.1, VS2015

This was SVN commit r22744.
2019-08-21 13:22:25 +00:00
e1014aad3b Use CGUI& instead of CGUI* so that the 50+ users stop wondering whether or not that is null and can't even be mistaken to add redundant null checks preemptively.
Remove the remaining of such checks after d3e56f0f57 removed 21 of them
already.
2c47fbd66a initialized the pointer at construction time rather than at
random conditional events later.

Differential Revision: https://code.wildfiregames.com/D2205
Comments By: Vladislav, wraitii
Tested on: gcc 9.1.0, clang 8.0.1

This was SVN commit r22741.
2019-08-21 10:12:33 +00:00
e82d0867b2 Erase unused variable following 77b81d8761, clean two stray includes from c19f3608a5.
Confess a wrong word in a comment in c9c82d9daf and a typo in a comment
in 9985fcf5bd.

Differential Revision: https://code.wildfiregames.com/D2203
This was SVN commit r22720.
2019-08-20 10:51:29 +00:00
8b6eee672b Move GUI string parsing specializations to a separate file and remove __ParseString proxy.
Differential Revision: https://code.wildfiregames.com/D2194
This was SVN commit r22696.
2019-08-19 19:43:13 +00:00
77b81d8761 Remove IsBoolTrue helper function from c399dc277e.
This property is defined as a boolean for every IGUIObject.
If GUIObjects were empowered to make up their own hidden property, then
they should also be empowered to use custom boolean hidden properties
that don't trigger ResetStates.

This was SVN commit r22695.
2019-08-19 18:36:35 +00:00
d403d750f0 Stop copying color every draw call for every GUI object using colors.
Avoid color copies for rendering Draw calls in
GUIRenderer::UpdateDrawCallCache, CButton::Draw, CChart::DrawAxes,
CDropDown::Draw, CList::DrawList, COList::DrawList, refs #1984,
8f4f8e240f, 3028551b91, a905fbbc98.
Avoid color copies during XML loading in CGUI::Xeromyces_ReadImage,
CGUI::Xeromyces_ReadEffects, COList::HandleAdditionalChildren.
Add CGUI::HasPreDefinedColor and mark m_PreDefinedColors,
CGUI::GetPreDefinedColor, IGUIButtonBehavior::ChooseColor() as const for
consistency with the other "databases", refs 3028551b91.
Mark CGUIColor as NONCOPYABLE to add compiler errors if there is an
unexplicit copy, refs 3028551b91.
Explicit ugly copy in CGUI::Xeromyces_ReadColor and
CGUIColor::ParseString.
Deregister copying <CGUIColor>GetSetting functions, refs 8f4f8e240f.
Uses the const ref GetSetting from 3dfa23cd25.

This was SVN commit r22694.
2019-08-19 12:53:58 +00:00
3dfa23cd25 Use a new GetSetting returning a reference instead of GetSettingPointer when the setting is known to exist.
Differential Revision: https://code.wildfiregames.com/D2192
This was SVN commit r22693.
2019-08-19 10:32:29 +00:00
9985fcf5bd Move GUI<>::FallBackSprite and GUI<>::FallBackColor to CGUIColor::operator|| and CGUISpriteInstance::operator||.
Leaves only setting management in GUIutil.h.

Differential Revision: https://code.wildfiregames.com/D2185
This was SVN commit r22689.
2019-08-18 15:17:49 +00:00
c9c82d9daf Use shared_ptr to avoid copying and deleting SGUIImageEffects, 2.5x faster in a benchmark, refs ba0ebd6644.
Differential Revision: https://code.wildfiregames.com/D2184
Refs 3028551b91/D2163
Tested on: gcc 9, Jenkins

This was SVN commit r22682.
2019-08-17 11:52:57 +00:00
ba56191dc2 Move CGUI::GenerateText to CGUIText constructor, CGUI::DrawText to CGUIText::Draw, SGenerateTextImage from CGUI to CGUIText.
Makes GUI text construction 30x faster for empty strings, otherwise less
than 1% faster.
Split the constructor into smaller helper functions to reduce nesting
and improve readability.
Change m_GeneratedTexts from pointer to reference, so that one doesn't
have to keep track to delete it correctly in several places, without
having to resort to copy or move assignments but constructing in place.
Mark CGUIText as NONCOPYABLE and MOVABLE which is already implicitly the
case due to the CGUISpriteInstance members, refs 0a7d0ecdde/D2133,
D2163/3028551b91.

Differential Revision: https://code.wildfiregames.com/D2168
Prepared by the GUIText.h file split in 838889ab12 / D2167.
Comments By: Vladislav
Tested on: gcc 9, clang 8, VS2015, Jenkins
Inlining tested using: clang -Rpass=inline and gcc -Winline

This was SVN commit r22679.
2019-08-17 01:32:11 +00:00
86c151ebaa PushGuiPage support for passing a function instead of a function name.
Allows coding the GUI without global functions which break
prototype-oriented coding, refs #5322, fixing the concern in 4b1297b328.

Supports stacked message boxes and removes the according workaround.
Change structree / civinfo switch-dialog code from 760a47335d to perform
the callback for page that actually registered the callback.
Ensure the parent that the callbackhandler is always called if the page
is closed.
Merge PopGuiPage and PopGuiPageCB following that choice, incidentally
leaving cleaner code.

Differential Revision: https://code.wildfiregames.com/D1684
Comments by: Yves, Vladislav, wraitii, leper
This was SVN commit r22676.
2019-08-16 18:46:04 +00:00
6ad90aa1b8 Delete wrongful proxy CGUIManager::GetPreDefinedColor from f0d9806b3f.
It is wrong because the predefined colors should be loaded from the GUI
page that requests to have the color parsed, which may be different from
the topmost page.
Similar to FindObjectByName removed in f9b529f2fb.

Achieve this by implementing the CGUISetting<CGUIColor>::FromJSVal
specialization, moved from ScriptInterface::FromJSVal<CGUIColor>,
instead of adding a CGUI pointer to CGUIColor.
Mark ScriptInterface::FromJSVal<GUIColor> and inherited
CColor::ParseString explicitly as deleted, so that people get a compile
error if they forget to check for predefined colors when parsing a
color.

Refs #5387, D1746 > D1684 > this > f9b529f2fb, 9be8a560a9, 415939b59b,
2c47fbd66a, 85a622b13a.

Differential Revision: https://code.wildfiregames.com/D2108
Tested on: clang 8, VS2015

This was SVN commit r22663.
2019-08-13 18:00:41 +00:00
02d23d1ff0 Remove useless proxy GUI<int>::ParseColor, refs 31f0e62c83, 2c14d94559.
Tested on: clang 8.

This was SVN commit r22662.
2019-08-13 15:42:14 +00:00
64e80471d0 Replace JS_THIS_OBJECT and JS::CallReceiver in preparation for SpiderMonkey 49 and 61.
Differential Revision: https://code.wildfiregames.com/D2173
Refs #4893, D1699, D2142, D844, 7c2e9027c2, ...
Refs https://bugzilla.mozilla.org/show_bug.cgi?id=1270977
Refs https://bugzilla.mozilla.org/show_bug.cgi?id=1255800
Tested on: clang 8, VS2015, Jenkins

This was SVN commit r22661.
2019-08-13 14:11:43 +00:00
838889ab12 Split CGUIString.h from GUIText.h, so that one may have the SGUIText implementation in a separate cpp file.
Differential Revision: https://code.wildfiregames.com/D2167
Reviewed By: Vladislav
Tested on: gcc 9.0.1, VS2015, Jenkins

This was SVN commit r22643.
2019-08-10 19:16:52 +00:00
d3e56f0f57 Unfriend the 20 IGUIObject classes from CGUI.
Improves separation of concerns and makes the code less error prone,
since the IGUIObject classes can't break CGUI private members without
CGUIs help anymore.

This is achieved by making CGUI GetFocusedObject, UpdateObjects public,
by introducing public CGUI GetBaseObject, GetMousePos, GetMouseButtons,
HasStyle, GetStyle getters,
and by removing the pointless IGUIObject GetMousePos proxy.

Delete GetGUI() checks that are either always or never true following
2c47fbd66a.
Use const references instead of copies for some mouse positions.

Differential Revision: https://code.wildfiregames.com/D2166
This was SVN commit r22641.
2019-08-10 12:51:27 +00:00
a905fbbc98 Use NONCOPYABLE for most GUI classes and structs to have the compiler indicate unintended copies, refs 3028551b91 / D2163.
That is CChartData, CGUIList, CGUISeries, COListColumn, GUITooltip,
SGUIMessage, SSpriteCall, STextCall, SFeedback, IGUISetting,
CGUISetting, GUI, IGUIObject, IGUIScrollBar.
Drop copying GetSetting and SetSetting template functions for CGUIList,
CGUISeries, CClientArea, CGUIString.
Stop copying COListColumn.
Drop copying GUI<CClientArea>::GetSetting call in
IGUIObject::UpdateCachedSize() and four copying
GUI<CGUIString>::GetSetting calls in SetupText() functions.
Delete unused GUIRenderer IGLState class from 849f50a500 obsolete since
1f5b8f1c9a.

Differential Revision: https://code.wildfiregames.com/D2164
This was SVN commit r22638.
2019-08-10 00:04:17 +00:00
3028551b91 MOVABLE idiom, const CGUI struct maps, in place move construction instead of copying temporaries during CGUI XML loading and GenerateText.
Introduce MOVABLE idiom indicating that a class can use move semantics.
Make values of CGUI struct maps holding XML data const to ensure at the
root that the data is not modified.
Use NONCOPYABLE and MOVABLE for SGUIIcon and SGUIStyle to enforce the
non-copy policy on the compiler level (until someone changes the GUI
design to make modifications needed).

As indicated by that:
  Replace copy operations by in place move operations for these CGUI
struct maps in the CGUI Xeromyces XML loading functions.
  Replace copy operations by const references for CSize and SGUIIcon in
CGUIString::GenerateTextCall and CGUI::GenerateText.
  This avoids copying of non primitive members, such as the strings and
containers of strings.

Further related cleanup to be kept separated for auditability.

Differential Revision: https://code.wildfiregames.com/D2163
Few comments on IRC by: wraitii, Itms
Tested on: gcc 9, Jenkins, partially VS2015

Refs #1984,
  NONCOPYABLE CGUISpriteInstances: 0a7d0ecdde, 8f4f8e240f, c19f3608a5
  NONCOPYABLE Image, Sprite: fb8032043b
  NONCOPYABLE GUI page: 94c57085e9
  NONCOPYABLE GUIManager: 7c2e9027c2
  NONCOPYABLE macro: 16ccae10cd

This was SVN commit r22637.
2019-08-09 17:25:55 +00:00
f804226b89 Fix failure of the CGUIColor constructor author to call the base constructor following f236c07a56, refs 415939b59b.
Tested on: gcc 9, VS2015

This was SVN commit r22636.
2019-08-09 14:54:14 +00:00
9325992232 Revert use of the isRunOnce flag after removal in 64b477625d of compile'n go, refs #4893.
This breaked a SM assertion, which was only caught in debug mode. It
could have led to subtle bugs during the compilation of JS scripts.
Still set the flag to its default value, because SM devs wanted to
change the default in the future.

This was SVN commit r22629.
2019-08-08 09:05:42 +00:00
64b477625d Upgrade SpiderMonkey to version 45.0.2, refs #4893.
- Various build changes, in particular NSPR is not needed on Unix
anymore
- Add js/Initialization.h to source/scriptinterface/ScriptEngine.h
- Use nullptr instead of JS::NullPtr(), see
https://bugzilla.mozilla.org/show_bug.cgi?id=1164602
- Remove `JS::RuntimeOptionsRef.varObjFix`, see
https://bugzilla.mozilla.org/show_bug.cgi?id=1171177
- Remove uses of `AutoIdArray`, see
https://bugzilla.mozilla.org/show_bug.cgi?id=1191529
- `JS_InternUCStringN` has been renamed, see
https://bugzilla.mozilla.org/show_bug.cgi?id=1178581
- `JS::Evaluate` now takes scope chains explicitly, see
https://bugzilla.mozilla.org/show_bug.cgi?id=1097987
- Array functions (such as `JS_IsArrayObject`) are fallible and output
to params, see https://bugzilla.mozilla.org/show_bug.cgi?id=f3d35d8
- Remove `JSCLASS_CACHED_PROTO_WIDTH` workaround in our code, see
https://bugzilla.mozilla.org/show_bug.cgi?id=1236373
- Remove compile'n go (`setCompileAndGo`) and replace it by
`setIsRunOnce` which will become the default in the future, see
https://bugzilla.mozilla.org/show_bug.cgi?id=679939
- Mark shared memory in direct access operations
(`JS_GetUint16ArrayData` and `JS_GetUint8ArrayData`), see
https://bugzilla.mozilla.org/show_bug.cgi?id=1176214
- Use new `JS::ObjectOpResult`, see
https://bugzilla.mozilla.org/show_bug.cgi?id=1113369

Thanks to wraitii, elexis, Krinkle and historic_bruno for contributions
and comments, and to gentz, madpilot, s0600204 and Stan for testing and
indirect contributions.

Differential Revision: https://code.wildfiregames.com/D1510
This was SVN commit r22627.
2019-08-07 22:37:43 +00:00
f236c07a56 Call CGUIColor base constructor without C++17 using declaration following 415939b59b.
This removes the trigger for an unidentified VS2015 bug revealed by the
IGUIObject::AddSetting / CGUISetting constructor in 85a622b13a
(unset GUIObject color settings didn't hold the color assigned in the
inherited default constructor, so hovered button text appeared black
instead of white on Windows).
The code in the two commits seems correct, but VS2015 doesn't seem to
implement it correctly (and claims to support C++17) while clang and gcc
behave as intended.
Fix whitespace.

Reported By: gameboy, Angen
Refs
https://wildfiregames.com/forum/index.php?/topic/26694-strange-font-color/

This was SVN commit r22617.
2019-08-05 20:45:15 +00:00
5c4d124d2a Refactor renderer options.
This moves the renderer options into their own class to:@
  - allow one to only include the rendering options, not the whole
renderer header, when one wants access to rendering options.
  - centralise rendering changes and their side-effects.
  - clean up code.

Tested by: historic_bruno, Freagarach
Commented by: historic_bruno
Differential Revision: https://code.wildfiregames.com/D1929
This was SVN commit r22610.
2019-08-04 08:28:30 +00:00
da4e601d8f Move GetDefaultGuiMatrix to a separate file.
The function was located in the wrong file, because it is not logically
related to IGUIObject settings.
The separate file allows the various users to include it without
including the GUIRenderer.

This was SVN commit r22605.
2019-08-04 03:52:00 +00:00
85a622b13a Implement IGUIObject settings as a template class and IGUIObject::AddSetting as a template function.
This means the type information is available for all methods operating
with the setting type, which is easier for the authors, allows for
compile-time checks and optimizations.
Remove the enum that was used to indirectly obtain the setting type at
runtime.
Revises SGUISetting and enum from e326ebae46 (5122b0f906),
std::function from 82f1d2718b.

Differential Revision: https://code.wildfiregames.com/D2145
Tested on: gcc, clang, VS2015, Jenkins

This was SVN commit r22604.
2019-08-04 02:20:08 +00:00
5a1da77ce4 Use IGUIObject::GetSettingPointer and SetSetting instead of accessing the member m_pSetting directly following fd91563f42.
Revise 53b335f5ae in CInput::UpdateBufferPositionSetting to use the
SkipMessage argument from 4113aa0a36 to prevent the infinite loop
instead of hijacking the pointer.

This was SVN commit r22603.
2019-08-04 00:02:56 +00:00
cd82b62e25 Fix JSInterface_IGUITextOwner build on VS2015 following 3d07327837 (which works on gcc, clang and Jenkins), reported by minohaka.
Retract IGUIObject override keyword from that commit, because clang
recommends to use it for either every or no overriding class member
(which then should be done consistently for all classes inheriting
IGUIObject, refs D2144).

This was SVN commit r22602.
2019-08-03 17:52:56 +00:00
3d07327837 Introduce a JSInterface_IGUITextOwner to encapsulate JSI_IGUIObject::getTextSize from 9c5062147a / D844.
JSI_IGUIObject should not contain functions that work only for some GUI
Object types, refs #5442.

Deduplicate the shuffled copy of CText::SetupText.

Avoid the 80 times slower dynamic_cast mandated by the virtual class
inheritance by adding an ugly overridable pointer to the base class
pointing at this derived classes, as bargained with Vladislav and
proposed by wraitii in D1781 id=8426.
This may be improved by refactoring the IGUIObject and JSInterface
classes to use templates and / or eliminating its virtual inheritance.

Implement and use FromJSVal / ToJSVal CSize specialization.
Remove the JS::CallArgsFromVp call.

Differential Revision: https://code.wildfiregames.com/D2136
Comments By: wraitii, Vladislav
This was SVN commit r22596.
2019-08-02 16:55:15 +00:00
df489f2500 Add virtual CreateJSObject to IGUIObject, split from GetJSObject, so that inheriting classes can extend the JS object upon construction, refs #5442, D2136.
Remove the comment from 53bcba3368 that allures the reader to believe
there is a memory leak which is not and has not been the case, refs
D1700.
Remove the useless JSAutoRequest from GetJSObject if the object was
constructed already (performance improvement), following cx assignment
in 4b1297b328, following JSAutoRequest addition in e9e05f4efc (that also
had removed other useles JSAutoRequest calls but not this one).
Don't change JS::PersistentRooted to JS::Heap until SpiderMonkey is
updated, refs D1700.
Provide access to GUI, ScriptHandlers and JSObject for inheriting
classes.

This was SVN commit r22593.
2019-08-02 12:18:30 +00:00
52f2bfae2b Add virtual base initialization missing in 2c47fbd66a.
Reported by Jenkins, but not gcc, clang, VS2015.
Take the opportunity following 2c47fbd66a to make the CGUI pointer held
by IGUIObject constant (the address, not the value).

Differential Revision: https://code.wildfiregames.com/D2139
This was SVN commit r22589.
2019-08-01 23:55:10 +00:00
69ac0b9656 Move CGUIManager::LoadPage to CGUIManager::SGUIPage::LoadPage, because it only operates only on that struct.
Refs D1684 (patch also made an appearance in D2108)

This was SVN commit r22588.
2019-08-01 20:48:05 +00:00
2c47fbd66a Pass the GUI page pointer CGUI* to the IGUIObject and derived classes upon construction, instead of on stray cases.
Call JS_AddExtraGCRootsTracer and JS_RemoveExtraGCRootsTracer depending
on JS::Heap use instead of on CGUI page link setup.
GUIObjects should be able to access the GUI page independent of the
scripting (for example to obtain PredefinedColors, refs D2108).

Refs: D2108, c02a7e1a7b
Comments By: wraitii
This was SVN commit r22587.
2019-08-01 20:20:24 +00:00
82f1d2718b Remove both copies of the 15-fold copies of the JSI_IGUIObject::getProperty and setProperty setting case handlers following the FromJSVal / ToJSVal template specializations implemented in
* JSI_GUIColor in 9be8a560a9
* bool in eec179a9a8
* CGUISeries and CGUIList in 26ae9d430a
* primitives in 636c719110
* EAlign and EVAlign in 0834d07462
* ClientArea in b9f3c8557b
* CColor in 415939b59b
* CGUISpriteInstance 0a7d0ecdde
* CPos in d6b93b3be6

The removed JS_ReportError calls were redundant.

This was SVN commit r22574.
2019-07-29 14:46:29 +00:00
d6b93b3be6 Add missing CPos FromJSVal, ToJSVal following 659a9ea57a.
This was SVN commit r22573.
2019-07-29 11:56:11 +00:00
0a7d0ecdde CGUISpriteInstance non-copyable and FromJSVal / ToJSVal.
Make CGUISpriteInstance non-copyable to further harden Philips
protection from 8f4f8e240f against unintentional copies of its DrawCall
cache such as in c19f3608a5.
Remove its copy constructor from 849f50a500, make it movable, and until
it becomes otherwise necessary, force move assignment when sprites are
assigned.
Improves the fixes of the compiler warnings about deprecated implicit
copy constructors in 8a32b0b3d4 by avoiding the copies instead of
copying explicitly.
Add ToJSVal, FromJSVal for CGUISprinteInstance to make
JSI_IGUIObject::getProperty and setProperty more consistent.
Rename Sprite operator= to SetName to reduce ambiguity.
Pass CRect by reference in CGUISpriteInstance::Draw.

Differential Revision: https://code.wildfiregames.com/D2133
Comments By: wraitii
This was SVN commit r22570.
2019-07-28 22:40:58 +00:00
ad4de3d3be Delete CInternalCGUIAccessorBase class from c2a71e41bf.
Delete GetSetting/SetSetting variants that operate on a GUI page other
than the one that the setting is defined in; introduced in c2a71e41bf,
obsolete since f0d9806b3f.

Delete CInternalCGUIAccessorBase::GetObjectPointer as these variants
were the only caller for that.
Delete CInternalCGUIAccessorBase::HandleMessage from a08cbd2f74 as it's
an unnecessary proxy.
Delete CInternalCGUIAccessorBase::QueryResetting from 953f72a91c by
making ResetStates public, equal to UpdateCachedSize from 90bbd48a14
(public required for VS2015 but not gcc 9).
Move ResetStates to implementation file.

Tested on: gcc 9, VS2015

This was SVN commit r22563.
2019-07-28 02:39:52 +00:00
6b052bab08 Fix 415939b59b - clang-specific error at compilation time
JS_ReportError was passed a CStr, which it doesn't support.

Reviewed By: elexis
Differential Revision: https://code.wildfiregames.com/D2131
This was SVN commit r22561.
2019-07-27 15:12:59 +00:00
415939b59b Introduce CGUIColor type inheriting Color type and switch the GUI to exclusively use that.
The type differs from the Color type, because contrary to Color, it can
be created from a color predefined in the GUI page (such as "yellow").
Move this predefined color check to the new class instead of hardcoding
it in FromJSVal / ToJSVal, GUIUtil, JSInterface_IGUIObject and to
straighten the latter.

Delete fov_wedge_color from Minimap, unused since introduction in
5275dc862b.

This was SVN commit r22558.
2019-07-26 18:57:28 +00:00
b9f3c8557b Move CClientArea ToJSVal / FromJSVal conversion from JSI_IGUIObject (since that should be agnostic of the conversion) to CClientArea (since that defines the properties).
This was SVN commit r22557.
2019-07-26 14:47:27 +00:00
0834d07462 Make JS changed horizontal / vertical actually take effect, finishing 156ff7cf56, refs f4b410ff82.
Move EAlign and EVAlign JS<->C++ conversions to FromJSVal and ToJSVal
for consistency.

Remove alternative / british spelling "centre".
Use i32 instead of int since at least and at most 32 bits are intended
there, refs 1e07787e76.

This was SVN commit r22556.
2019-07-26 13:45:14 +00:00
636c719110 Use FromJSVal ToJSVal for primitive types to remove the duplicate logic and make JSInterface_IGUIObject case handling more equal.
Remove broken uint overflow check from 3698c134b5 and just use the
native JS uint32 conversion.

This was SVN commit r22540.
2019-07-24 02:58:50 +00:00
26ae9d430a CGUISeries and CGUIList specializations for ToJSVal / FromJSVal to make the JSI_IGUIObject case handling agnostic of implementation specifics, refs 4d367109c3, 977a5c7ca2, 2bae30c454.
This was SVN commit r22539.
2019-07-24 01:40:30 +00:00
eec179a9a8 Use FromJSVal and ToJSVal for GUI boolean conversions.
Consistently warn instead of using implicit conversion when not passing
a boolean, for consistency and callers being more cautious with passed
values.

This was SVN commit r22538.
2019-07-23 21:46:32 +00:00
62f83eb673 Use ToJSVal for JS_NewStringCopyZ to improve encapsulation and consistency and remove a snprintf call.
This was SVN commit r22536.
2019-07-23 15:17:35 +00:00
cbcd1bbde0 There is nothing to see here following 9be8a560a9.
This was SVN commit r22535.
2019-07-23 14:50:09 +00:00
9be8a560a9 Delete JSClass JSI_GUIColor / GUIColor from af9c336b43, refs #5387, D1699.
* JSI_GUIColor::construct and JSI_IGUIObject::setProperty hunk are
duplicates of FromJSVal, getProperty of ToJSVal, following 7c2e9027c2.
* The constructor, it's fallback magenta and toString have never been
used by JS.
* A JS color class providing some methods (such as found in color.js,
refs #5387, and the unused toString redundant with rgbToGuiColor, see
also eee8217b45) is more inviting to changes and maintenance if defined
in JS and can still be instantiated in C++, like the Vector2D (see also
65b02395b3).
* PredefinedColors (such as "red" or "green") can be obtained from the
prototype without defining the class in C++.
* Minimize ugliness by removing macrosity, refs 8ceb41212d.

Rename alpha to a in guiToRgbColor from eee8217b45 for consistency with
the C++ conversions (opaqueness had been skipped in the only callers of
this JS function yet).
Delete unused GUISTDTYPE Mouse in header forgotton in 8734efca94.

This was SVN commit r22534.
2019-07-23 14:22:27 +00:00
8734efca94 Delete JSI_GUIMouse from af9c336b43 obsoleted by 64bd264fc0.
Excerpt of D1699.

This was SVN commit r22531.
2019-07-23 01:36:13 +00:00
227957cd99 Delete unused broken JSI_IGUIObject::construct.
The constructor is invalid, because one cannot create or obtain and pass
an IGUIObject C++ class instance pointer via JS, only triggering a crash
when doing something with it.
If there was a use case, the GUIObject should be created with a
GUIObject type specific constructor.
Remove obsolete getProperty comments.

From D1699, refs #5369 and wraitiis equivalent:
Differential Revision: https://code.wildfiregames.com/D1933
This was SVN commit r22530.
2019-07-23 01:24:49 +00:00
b4626359f5 Provide ScriptInterface CreateObject and CreateArray functions to replace Eval calls following 7c2e9027c2, 1c0536bf08 and later.
Differential Revision: https://code.wildfiregames.com/D2080
Previous version reviewed By: Krinkle
Comments By: historic_bruno, wraitii
This was SVN commit r22528.
2019-07-22 19:35:14 +00:00
41ee485e68 Remove unused GUIManager SGUIPage members from 7c2e9027c2 and 4b1297b328.
This was SVN commit r22520.
2019-07-21 01:29:08 +00:00
feb88a337a Pass arbitrary arguments to GUI events / SendEventToAll and remove loading screen progess workaround, refs D1716, 6d792365aa, bd3bd084c0, 4b1297b328, db5d4bb5f1.
Differential Revision: https://code.wildfiregames.com/D1754
Reviewed By: Itms
Comments By: leper
This was SVN commit r22515.
2019-07-19 21:15:04 +00:00
8a32b0b3d4 Fix some gcc 8 and gcc 9 compiler warnings that were thrown 4500 times.
Refs #5294
Differential Revision: https://code.wildfiregames.com/D2055
Reviewed By: Vladislav
This was SVN commit r22443.
2019-07-09 00:18:48 +00:00
621bb1367a [CChart] Add a percentage format and round displayed integers
Reviewed by: bb
Approved by: Vladislav
Differential Revision: https://code.wildfiregames.com/D1878
This was SVN commit r22282.
2019-05-13 21:23:26 +00:00
f9b529f2fb Remove workaround in GetGUIObjectByName
f0d9806b3f added a problem: Engine.GetGuiObjectByName is unaware of the
caller GUI page.
So GUI pages in the background that still run the onTick and other event
code tried to look on the topmost GUI page, rather than their own GUI
page.
9674c3c0fe added a workaround that has to be copied to any place that
can call JS code.
If developers don't know about the reason for this workaround and add a
new place that can call JS code (#5369), they won't be able to implement
anything.

This removes this workaround by passing the pointer to the correct GUI
page as callback data.

Patch By: elexis
Reviewed By: wraitii
Refs #5369

Trac Tickets: #5369

Differential Revision: https://code.wildfiregames.com/D1701
This was SVN commit r22200.
2019-04-20 15:49:42 +00:00
bb
94716b9987 Remove an unused variable
The variable was introduced in 492e49da38 without being used, neither
did it become used in a later commit. To me it seems that it is a
left-over from a copy paste, as the ".left" functions do use the
variable.
Notice 74c420f658 did cleanup around these lines, but did not remove
this variable

Patch By: Angen
Differential Revision: https://code.wildfiregames.com/D1813
This was SVN commit r22166.
2019-04-06 22:04:13 +00:00
359df88f1a [CSlider] On click move the slider-button to the mouse position
Reviewed By: vladislavbelov
Refs: #2593
Differential Revision: https://code.wildfiregames.com/D1622
This was SVN commit r22164.
2019-04-06 18:47:22 +00:00
9c5062147a Add a GetTextSize() method to GUI objects
Usage:
  let size = Engine.GetGUIObjectByName({gui_object_name}).GetTextSize()

Returns a JS object containing the height and width of the primary text
field within
the object, taking into account new lines, text wrapping, and font
changes.

Unless the object doesn't contain text, in which case the method will
return undefined.

Commented on by: vladislavbelov
Additional code by: elexis
Reviewed By: wraitii
Differential Revision: https://code.wildfiregames.com/D844
This was SVN commit r22134.
2019-03-18 22:15:40 +00:00
ac1a56e0cc Fix cell text wrapping inside COList.
Patch By: gentz
Tested By: vladislavbelov
Commented By: elexis
Differential Revision: https://code.wildfiregames.com/D1717
This was SVN commit r22066.
2019-01-24 20:00:31 +00:00
db5d4bb5f1 SpiderMonkey-related changes in preparation for the upgrade to SpiderMonkey 45, refs #4893.
- Remove JSVAL_ZERO and JSVAL_NULL
https://bugzilla.mozilla.org/show_bug.cgi?id=1177825
- Remove *_TO_JSVAL https://bugzilla.mozilla.org/show_bug.cgi?id=1177892
- Drop support for parent object in the deserializer
https://bugzilla.mozilla.org/show_bug.cgi?id=1136345,
https://bugzilla.mozilla.org/show_bug.cgi?id=805052
- Correctly use boolean values in JS::RuntimeOptionsRef
- Use JS_FN instead of JS_FS: in future versions, JS_FS is not public
because it isn't supposed to be used in JSAPI code
- Allow to select flags for global objects, and correctly mark progress
bars in the loading screen as not readonly+permanent
- Remove empty JSI_props in IGUIObject

Reviewed By: wraitii, elexis
Differential Revision: https://code.wildfiregames.com/D1716
This was SVN commit r22052.
2019-01-13 16:37:41 +00:00
651cf8b364 Split CColor from Shapes.
Reviewed By: wraitii
Tested By: Stan
Differential Revision: https://code.wildfiregames.com/D1515
This was SVN commit r22051.
2019-01-13 15:38:41 +00:00
e76b7d1e02 Remove obsolete DisplayMessageBox function from 00e18e4ea8, unused since 835609df20.
C++ should not hardcode JS implementation details or strings.
SendEventToAll or CallFunctionVoid are more common and versatile
alternatives.

This was SVN commit r21935.
2018-11-29 12:33:45 +00:00
9e712fa0c5 Move UserReporter C++/JS functions from JSInterface_Debug.cpp to JSInterface_UserReport.cpp, refs #4772.
This way it stands out more as a separate feature that can be more
easily exchanged, extended, maintained or conditionally removed from the
build and leaves more transparent includes, refs #5257.

Add missing string includes following 7c2e9027c2 and d6cb9c845b.
Remove unused Profile include following 38d6f81d71 and d6cb9c845b.
Remove unused CLogger include, add missing debug include following
d6cb9c845b.
Remove unused CConsole include following 9f0484e5ce / D1073.
Remove unused ProfilerViewer include following 2af94c5898.

This was SVN commit r21866.
2018-08-22 12:48:27 +00:00
4c73614955 In preparation of renaming and grouping main.cpp shutdown variables:
Declare the g_GameRestarted hack from 12f0720f31 in main.cpp, because it
is main.cpp and Game.cpp who provide it's value.
Move the comment so that the connotation becomes clear when reading
main.cpp.

Remove the extern declaration introduced to the Renderer in fb035d08e3
that became obsolete with ed7c66eb82.

This was SVN commit r21816.
2018-05-08 09:24:16 +00:00
13e1702777 Add missing ScriptInterface includes to
JSInterface_L10n.cpp from d6db5a466d,
JSInterface_Renderer.cpp and JSInterface_GUITypes.cpp from 4b1297b328,
JSInterface_VisualReplay.cpp from b830233498,
JSInterface_Game.cpp from 5f8be8e0c6,
JSInterface_Simulation.cpp from 921c5515a6,
JSInterface_Debug.cpp from d6cb9c845b,
JSInterface_Main.cpp from 486aec18d4, refs #4772,
JSInterface_Mod.cpp where it was incorrectly removed in af03c72f76.

Refs D1470.
Sort includes alphabetically, add recent Coding Convention macro
comments.

This was SVN commit r21789.
2018-04-27 16:48:44 +00:00
86fcf0de8c Move ModIo JS interface functions to a separate namespace, refs 833c9f108c.
Differential Revision: https://code.wildfiregames.com/D1466
Reviewed By: Itms
This was SVN commit r21778.
2018-04-24 13:12:08 +00:00
afd69a58b3 Stop new-line characters making lines longer than they should be.
Reviewed By: Imarok
Fixes: #3351
Differential Revision: https://code.wildfiregames.com/D1299
This was SVN commit r21546.
2018-03-13 23:06:21 +00:00
a1c4c23ce4 Adds axes to the CChart and the summary screen.
Comments By: elexis, Imarok
Reviewed By: s0600204
Trac Tickets: #4892
Differential Revision: https://code.wildfiregames.com/D474
This was SVN commit r21429.
2018-03-04 12:42:35 +00:00
bb
3698c134b5 Make sure dropdowns fit in the screen by allowing the list to be above when there is not enough space
Reviewed By: Vladislav
Differential Revision: D1061
fixes #4857

This was SVN commit r21379.
2018-02-25 22:26:31 +00:00
e497672a9c Bump copyright header year numbers.
This was SVN commit r21305.
2018-02-21 18:44:52 +00:00
72fa750a0c Fix margin/padding issue in tooltips
Reviewed By: bb
Refs: D836, d01cb88ac4
Differential Revision: https://code.wildfiregames.com/D1298
This was SVN commit r21215.
2018-02-15 18:16:45 +00:00
d01cb88ac4 Calculate and return correct width in CGUI::GenerateText
Reviewed By: bb
Differential Revision: https://code.wildfiregames.com/D836
This was SVN commit r21142.
2018-02-07 20:47:10 +00:00
751edb43fc Fix wrong type in 8aaff7fc62 / D1232.
Differential Revision: https://code.wildfiregames.com/D1266
Patch By: Angen
This was SVN commit r21047.
2018-01-28 17:37:55 +00:00
8aaff7fc62 Implement an auto-scroll setting for GUI lists.
Patch By: fpre / ffffffff
Fixes #4987, refs #4254

This allows the replay menu and lobby to focus the selected element if,
but only if it is expected by the user.
Replaces 3f5648767d which scrolled the selected player into view every
single time a new playerlist was received by the lobby server.

This was SVN commit r20958.
2018-01-22 04:45:27 +00:00
b982e7f510 Fix build on armhf with gcc 7.
The abs caused a compiler error in that environment, because wchar_t is
unsigned on armhf, subtracting signed from unsigned results in unsigned
and std::abs does not define an unsigned variant.

Differential Revision: https://code.wildfiregames.com/D1122
Patch By: Peter Michael Green
Uploaded By: Ludovic
This was SVN commit r20869.
2018-01-14 21:18:37 +00:00
0cfe9ab153 Expose the same ReadJSONFile function to simulation, GUI and rmgen.
This way globalscripts/ can use the same code in all contexts, all paths
are absolute and only one function name is needed.
Remove ReadCivJSONFile which is redundant with this function as well.
Restrict read access of rmgen/ to rmgen/ and simulation/, refs
4275a8a33c, 89055ef858.

Refs #4868
Differential Revision: https://code.wildfiregames.com/D1085
Reviewed By: wraitii
Partial agreement with leper

This was SVN commit r20576.
2017-12-03 23:02:27 +00:00
2877ae1c38 Fix oversight in 16afbf32c8 noticed by Geramoto
Reviewed by: bb
Refs: #4722
Differential Revision: https://code.wildfiregames.com/D1072
This was SVN commit r20544.
2017-11-27 19:51:21 +00:00
4275a8a33c Unify two rmgen and GUI JSON file loading script functions, refs #4868.
Revert the introduction of the exact copies of FileExists ReadJSONFile
functions in MapGenerator.cpp introduced by 871ed04521.
Include JSInterface_VFS.cpp from MapGenerator.cpp to remove that code
while gaining the other missing VFS file loading functions in rmgen/.
Split RegisterScriptFunctions of JSInterface_VFS.cpp from eb4e66aab3
into RegisterReadOnlyScriptFunctions and RegisterWriteScriptFunctions to
prevent unintentional write access.

This was SVN commit r20507.
2017-11-24 17:19:16 +00:00
bb
e6dff349bd Fix scrollbare edgy-case and off by 1's in dropdown
Reviewed By: Imarok
Comments By: elexis
Differential Revision: https://code.wildfiregames.com/D1030
This was SVN commit r20500.
2017-11-21 20:07:23 +00:00
7b93690c76 Fix few typos found with the Debian lintian tool.
Differential Revision: https://code.wildfiregames.com/D973
Differential Revision: https://code.wildfiregames.com/D974
Differential Revision: https://code.wildfiregames.com/D975
Patch By: LudovicRousseau
Reviewed By: Dunedan, bb
This was SVN commit r20369.
2017-10-28 22:34:57 +00:00
486aec18d4 Move Main ScriptFunctions to a new JS Interface, refs #4772.
This was SVN commit r20172.
2017-09-12 03:11:33 +00:00
d6cb9c845b Move Debugging ScriptFunctions to a new JS Interface, refs #4772.
This was SVN commit r20171.
2017-09-12 02:25:28 +00:00
921c5515a6 Move Simulation GUI ScriptFunctions to a new JS Interface, refs #4772.
This was SVN commit r20170.
2017-09-12 01:53:46 +00:00
5f8be8e0c6 Move Game ScriptFunctions to a new JS Interface, refs #4772.
This was SVN commit r20169.
2017-09-12 01:38:46 +00:00
fa54a8cd65 Move GUI Manager ScriptFunctions to a new JS Interface, refs #4772.
This was SVN commit r20168.
2017-09-12 00:54:49 +00:00
21f69ef574 Move networking ScriptFunctions to a new JS Interface, refs #4772.
This was SVN commit r20167.
2017-09-12 00:29:10 +00:00
0e3a6d811c Move SavedGame ScriptFunctions to a new JS Interface, refs #4772.
This was SVN commit r20166.
2017-09-11 23:22:28 +00:00
f1cc54cc18 Move GameView ScriptFunctions to its JS Interface, refs #4772.
Use early returns as initialization checks.

This was SVN commit r20165.
2017-09-11 23:03:27 +00:00
4d931b57e9 Move ReadJSONFile and WriteJSONFile GUI ScriptFunctions that only handle VFS paths to the VFS JS Interface.
This was SVN commit r20164.
2017-09-11 22:21:34 +00:00
e69a0fb9db Remove unused clumsy JS GUI ScriptFunctions debug timer from ed7b4b5fca.
GetMicroseconds from 7a91d330d3 provides microsecond precise timing.

Refs #4772.

This was SVN commit r20163.
2017-09-11 22:08:54 +00:00
eb4e66aab3 Move VFS GUI script function registration to its interface file.
This was SVN commit r20133.
2017-09-08 04:01:26 +00:00
5c01b50ca4 Add FALLTHROUGH, which in the best case is just [[fallthrough]].
Note that this does not fix the warnings in AtlasObjectXML, someone
interested
in fixing those should check whether using ICU would be a nicer
solution.

Reviewed By: echotangoecho
Differential Revision: https://code.wildfiregames.com/D740
This was SVN commit r20095.
2017-09-01 20:04:53 +00:00
7a157faf3c Allow the GUI to subscribe to text edit events to redeem three workarounds in the options page.
Differential Revision: https://code.wildfiregames.com/D860
Refs #2451, #3511, 5c61f68600 (registerChanges), 7fa2962c45
(onMouseLeave), e909567004 (onPress)
Reviewed By: Vladislav
This was SVN commit r20091.
2017-09-01 12:06:18 +00:00
2cb6139761 Fix typo in f8d53d8f7b / D786 and some whitespace in CInput.cpp
This was SVN commit r20088.
2017-09-01 01:51:48 +00:00
a5c60619e2 Input GUI object cleanup.
Remove redundant if-statement following 5593f573f4 as reported by
Vladislav.
Use switch-statement in ManuallyHandleEvent.

This was SVN commit r20078.
2017-08-30 12:01:17 +00:00
ee38f0db37 Implement readonly Input GUI objects and use it in the file location indicator in the replay menu,
so that the user can copy the file path.

Fixes #4225
Refs D763
Patch By: Vladislav
This was SVN commit r20075.
2017-08-29 23:53:23 +00:00
23118ba847 Split the Input GUI object key processing into two methods (methods changing the text and methods not changing it).
Patch By: Vladislav
Refs #4225, D763

Also use SDL_Keycode instead of int, remove an outdated history lookup
comment and some other unneeded comments.

This was SVN commit r20074.
2017-08-29 23:29:29 +00:00
1b44946078 Replace deprecated jsval with JS::Value.
Remove unused SGUIBaseSettings and GUI comment.
Fix indentation of a macro, refs D794.

Differential Revision: https://code.wildfiregames.com/D838
Review by: leper.
Itms came up with the same patch for the SpiderMonkey 45 update
independently.

This was SVN commit r20062.
2017-08-28 10:27:36 +00:00
9defd11440 Pass ScriptInterface as a const ref where possible.
Reviewed By: elexis
Differential Revision: https://code.wildfiregames.com/D739
This was SVN commit r20028.
2017-08-24 00:32:42 +00:00
3fca871fd6 Take gui.scale into account when repositioning tooltips
Patch by: joskar
Differential Revision: https://code.wildfiregames.com/D749
This was SVN commit r19928.
2017-07-29 18:30:59 +00:00
6f7a5fb773 Allow the JS GUI to subscribe to the window resized event and use it to conditionally update the observer panel (refs D689).
Differential Revision: https://code.wildfiregames.com/D694
Tested By: temple
Proofread By: Vladislav
This was SVN commit r19846.
2017-06-30 00:04:29 +00:00
5e6b502eab Fix dropdown list height after resizing the window (in case there is an item that used wordwrapping before but not after the resize or vice versa).
Differential Revision: https://code.wildfiregames.com/D692
Tested By: temple
Proofread by: Vladislav
Refs #3571

This was SVN commit r19845.
2017-06-29 23:39:12 +00:00
ca2390d70e JS lobby cleanup, fixes and lobby bot performance improvements:
Do not send a wasteful rating request if the same player is selected
again when someone joined the lobby, when changing the sorting order or
when clicking on the same user again
by moving the player-selection change test from updatePlayerList to
onPlayerListSelection.

That test should have been done here in 8f4daa9dd0 already and fixes
#3840 well enough.

This change also fixes an unintentional behavior of the code, where the
game the currently selected player is playing in would be selected if
someone else joined the lobby, even if a different game was selected
manually.
Furthermore it allows simplification of the code of 655ce95468 by
removing selectGameFromPlayername which did almost the same as
selectGameFromPlayername.

To still select the game the current player is playing in if the
selected player didn't change, subscribe to the (new) event that is
called when clicking on an item.

Differential Revision: https://code.wildfiregames.com/D688
Reviewed By: ffffffff (fpre)
This was SVN commit r19841.
2017-06-29 02:58:04 +00:00
e7ab22286e Fix the replay menu for people with non-latin characters in their username.
Use OsPath instead of CStr and CStrW where possible,
wstring_from_utf8(OsPath.string8()) to pass printable strings to the
JSAPI,
OsString when opening a filestream and
off_t instead of int for filesizes.

Fixes #4320
Differential Revision: https://code.wildfiregames.com/D518
Reviewed By: Imarok
Tested By: Imarok on Windows, wraitii on OSX
Special thanks to Philip for advice and the lib/path.h fix in
47cc447322.

This was SVN commit r19824.
2017-06-25 14:54:00 +00:00
b94a54b18a Use direct gui.scale instead of reciprocal gui.scale
Patch by Dariost.

Differential Revision: https://code.wildfiregames.com/D328
This was SVN commit r19774.
2017-06-14 17:13:44 +00:00
74512ef01c Remove emptyinit.xml workaround file for atlas introduced in abaea508ac that silenced an engine warning stating that the GUI page doesn't provide a JS init function.
Still throw that error if the function exists but could not be called
with JS_CallFunction.

Differential Revision: https://code.wildfiregames.com/D620
This was SVN commit r19769.
2017-06-13 02:50:41 +00:00
61261d14fc STUN + XMPP ICE implementation.
Allows lobby players to host games without having to configure their
router.

Differential Revision: https://code.wildfiregames.com/D364
Fixes #2305
Patch By: fcxSanya.
StunClient based on code by SuperTuxKart, relicensed with approval of
the according authors hilnius, hiker, Auria, deveee, Flakebi, leper,
konstin and KroArtem.
Added rfc5245 (ejabberd) support, a GUI option, refactoring and segfault
fixes by myself.

Tested By: user1, Sandarac, Sestroretsk1714, Vladislav, Grugnas,
javiergodas
Partially Reviewed By: leper, Philip, echotangoecho
This was SVN commit r19703.
2017-06-01 06:33:52 +00:00
3d53614bce Add a script to lint the translations with Dennis.
Two of our printf calls are not compatible with python-format and will
be ignored until Dennis supports the corresponding formats. Also removed
meaningless enclosing characters that were wrongly considered HTML.

Reviewed By: leper
Differential Revision: https://code.wildfiregames.com/D214
This was SVN commit r19669.
2017-05-27 12:26:26 +00:00
7a91d330d3 Add GetMicroseconds function to allow microsecond precise timing in the JS GUI.
Differential Revision: https://code.wildfiregames.com/D190
Reviewed By: Vladislav, echotangoecho
This was SVN commit r19603.
2017-05-17 22:10:09 +00:00
2599d0374e Get the index of the hovered element in GUI lists and use it to display item-specific tooltips in the gamesetup for the victory condition, maptype and starting resources.
Differential Revision: https://code.wildfiregames.com/D316
Fixes #3699
Patch By: Vladislav
This was SVN commit r19588.
2017-05-15 21:49:10 +00:00
62195c28f2 Fix out of range access in CInput, patch by vladislavbelov. Fixes #4570.
Some invalid cursor positions were not checked, resulting in a crash in
Debug mode. This was revealed by e1e4ef0370, refs #4401.

Reviewed By: echotangoecho, Itms
Differential Revision: https://code.wildfiregames.com/D484
This was SVN commit r19579.
2017-05-14 19:02:03 +00:00
8bf732453e Ignore color and font tags when typing something in a Dropdown gui element to select an item.
Differential Revision: https://code.wildfiregames.com/D462
Refs D435
Reviewed By: Vladislav
This was SVN commit r19545.
2017-05-09 13:29:19 +00:00
09e974e1cb Bump year number of files changed this year in the license headers.
This was SVN commit r19503.
2017-05-01 14:28:22 +00:00
c016a74309 Add sliders to the GUI. Use them for the sound/music volume controls.
Patch by vladislavbelov, based on a patch by dpiquet.

Fixes #4039.
Differential Revision: https://code.wildfiregames.com/D325
This was SVN commit r19479.
2017-04-30 16:51:18 +00:00
8f36ca47a1 Replace input.js doubleclick hack and ease doubleclicking on moving units.
Differential Revision: https://code.wildfiregames.com/D326
Patch By: causative
Refs #4414

This was SVN commit r19444.
2017-04-22 01:24:03 +00:00
b856ec5ea4 Update the Minimap texture if the waterheight has changed.
Differential Revision: https://code.wildfiregames.com/D344
Patch By: Sandarac
Reviewed By: Vladislav
Refs https://code.wildfiregames.com/D229

This was SVN commit r19420.
2017-04-16 22:13:32 +00:00
16afbf32c8 Fix CChart scaling edgecases (constant value and infinity)
Reviewed by: vladislavbelov
Differential Revision: https://code.wildfiregames.com/D167
This was SVN commit r19408.
2017-04-11 12:27:21 +00:00
dbd56403b9 Allow hiding of list columns via XML or JS.
Differential Revision: https://code.wildfiregames.com/D228
Reviewed By: Vladislav
This was SVN commit r19353.
2017-03-28 00:25:17 +00:00
27f37ccd21 Cleanup the rest of the mess introduced with the NonGaiaEntities functions in 8c7b6dceaa.
Add a test for the GetNonGaiaEntities function of the RangeManager
broken by that commit that was fixed by f3e4e619bc.
Don't call one script function from another, but directly call into the
Selection helper like the others.
Don't make a loop around that RangeManager function for all players but
call the function once for all players.
The pointless virtual keywords were removed by 8827db201a.

Differential Revision: https://code.wildfiregames.com/D166
Reviewed By: leper
This was SVN commit r19344.
2017-03-25 02:42:51 +00:00
208b5b6dd8 Use a minimum height of at least one space character of the current font size when drawing list rows.
Use the maximum height of all cells of the current row.
Lobby games with empty servernames are not rendered weirdly anymore.

Patch By: Vladislav
Fixes #4402

This was SVN commit r19306.
2017-03-17 01:10:49 +00:00
a0a0895a12 Pass some strings and a vector as const refs.
Reviewed By: Imarok
Differential Revision: https://code.wildfiregames.com/D160
This was SVN commit r19240.
2017-02-24 17:02:10 +00:00
e1e4ef0370 Add UpdateAutoScroll calls to some events where they were missing. For example when deleting, cutting, pasting, autocompleting or doubleclicking text. Patch by Vladislav, fixes #4401.
This was SVN commit r19234.
2017-02-22 15:28:09 +00:00
6ae2db53db Employ some variadic macros to make some of the C++ -> JS function calling code nicer.
Template-ize CallFunctionVoid.
Changes CallFunction parameter order to make template parameter
deduction with
variadic parameters work nicely.

Reviewed By: Itms, wraitii, Yves
Differential Revision: https://code.wildfiregames.com/D77
This was SVN commit r19183.
2017-01-28 23:37:15 +00:00
4f01db4831 Split TurnManager classes into individual files per class. Patch by echotangoecho, fixes #4095.
Remove the "Net" prefix from the non-networked classes.
Use variadic macros and mark the client turnmanager as NONCOPYABLE.

Differential Revision: D16
Reviewed By: leper
This was SVN commit r19165.
2017-01-24 02:04:50 +00:00
2bae30c454 Fix [19027] by using generic code for conversions and fixing a few other issues. Refs #3403. Reviewed by leper.
Also fix some of the warnings that jenkins showed.

Differential Revision: https://code.wildfiregames.com/D24
This was SVN commit r19115.
2017-01-06 11:14:03 +00:00
3c8fc4f263 Return "local" from GetPlayerGUID to avoid duplicate checks and allow AIs to send private messages to the single player. Refs #4431.
Reviewed By: mimo
Differential Revision: https://code.wildfiregames.com/D38
This was SVN commit r19112.
2017-01-05 10:22:39 +00:00
507ecff2ed Scroll to the top when switching between tabs in the credits. Patch by vladislavbelov
This was SVN commit r19036.
2016-12-11 21:15:50 +00:00
78bc56f33e Display the updated batch size immediately when using the batch-train/barter hotkey, instead of waiting for the next turn. Patch by elexis. Fixes #3194
This was SVN commit r19028.
2016-12-07 19:18:57 +00:00
977a5c7ca2 Add C++ GUI code for drawing charts. Patch by vladislavbelov. JS will come later. Refs #3403
This was SVN commit r19027.
2016-12-07 19:03:54 +00:00
fe77783145 Change color of disabled labels and dropdowns, patch by vladislavbelov, fixes #4350
This was SVN commit r19020.
2016-12-05 17:21:51 +00:00
b18f74da44 Remove trailing whitespace and whitespace in empty lines of source/ except source/third_party/.
This was SVN commit r18987.
2016-11-23 11:18:37 +00:00
aa7e2fce49 Don't subtract the scrollbar size from GUI dropdowns when there is no scrollbar. Patch by Imarok, reviewed by mimo, refs #3571.
Remove unused button_width.

This was SVN commit r18984.
2016-11-22 13:05:56 +00:00
3f5648767d Scroll to the selected element after the selection changes. Fixes #4254, refs #3742.
This was SVN commit r18935.
2016-11-14 15:28:49 +00:00
34ce0f865d Reset the cursor when opening new GUI pages. Patch by danger89, refs #539.
Remove duplicate cursor image and duplicate hardcoded default paths.

This was SVN commit r18933.
2016-11-14 13:23:07 +00:00
caef42084d Add missing JSAutoRequest calls. (hopefully all of them have been spotted now)
Patch by echotangoecho, refs #4053

This was SVN commit r18730.
2016-09-18 09:34:45 +00:00
c2078bd0c6 Supress an error warning that isn't valid for unsortable ordered lists and hide sorting sprites if sorting is disabled. Based on patch by Imarok, refs #3905.
This was SVN commit r18694.
2016-09-03 22:22:11 +00:00
0cc23c1964 SpiderMonkey 38 upgrade: 33/35
Remove a workaround. Note that this removal is incomplete. Based on
patch by leper.

This was SVN commit r18687.
2016-09-02 16:53:22 +00:00
2aa75a05d4 SpiderMonkey 38 upgrade: 18/35
Renamed JS_Compile{,UC}Function to JS::CompileFunction. Patch by leper.
Addresses https://bugzilla.mozilla.org/show_bug.cgi?id=1089026

This was SVN commit r18672.
2016-09-02 16:34:02 +00:00
8d15411abf SpiderMonkey 38 upgrade: 13/35
Update JS_NewObject to JS_NewPlainObject, with new parameters. Patch by
leper.
Addresses https://bugzilla.mozilla.org/show_bug.cgi?id=1136906 and
https://bugzilla.mozilla.org/show_bug.cgi?id=1125356

This was SVN commit r18667.
2016-09-02 16:28:17 +00:00
c99ae7ca1c SpiderMonkey 38 upgrade: 12/35
Major update to the JSClass stubs. Based on patch by leper.
https://bugzilla.mozilla.org/show_bug.cgi?id=1103152

This was SVN commit r18666.
2016-09-02 16:26:54 +00:00
b01300c222 SpiderMonkey 38 upgrade: 11/35
Renamed JS_CallHeapFooTracer to JS_CallFooTracer. Patch by leper.
Addresses https://bugzilla.mozilla.org/show_bug.cgi?id=1052388

This was SVN commit r18665.
2016-09-02 16:25:42 +00:00
c7c3ef9f92 SpiderMonkey 38 upgrade: 09/35
Use .toFoo() instead of JSVAL_TO_FOO. Patch by leper.
Addresses https://bugzilla.mozilla.org/show_bug.cgi?id=952650

This was SVN commit r18663.
2016-09-02 16:23:44 +00:00
8f1b37b216 Major ordered list GUI cleanup. Patch by Imarok, fixes #3905.
Remove m_SelectedDef, m_SelectedColumnOrder and m_HeadingHeight. Use
GetSetting and SetSetting instead. Thus
implement selecting a column / column order sprite from JS correctly.
Since the actual list sorting is done in JS, only the column header
sprites were inaccurate.

Remove "selected_def" since that is redundant with "selected_column".
Merge "selected_column" with "default_column" (and
"selected_column_order" with "default_column_order") since
all properties provided in XML pages are defaults and to remove the
copying on init.

Rename "def" to "column" and "ObjectDef" to "COListColumn".
Replace 30px header height hardcoded in the C++ with an option set by
the style.
Remove the unneeded requirement to specify a "list_name".
Thus rename "list_name" to "list_month" in the replay menu.
Remove unneeded "list_" prefix and substr(5) in column checks.
Use ranged loops.
Fix typo "Avalible".
Add an error message if the GUI style doesn't specify the selected
column order.

This was SVN commit r18652.
2016-08-31 19:29:48 +00:00
4e87fef3da The old debug API has been removed in SpiderMonkey 38, so remove profiler1 script profiling.
Patch by leper, refs #3708

See also https://bugzilla.mozilla.org/show_bug.cgi?id=1069694

This was SVN commit r18580.
2016-08-02 16:58:30 +00:00
72ca6c5f80 Style cleanup by leper, preparing the SpiderMonkey update. Refs #3708
This was SVN commit r18579.
2016-08-02 16:12:11 +00:00
4c0f12bce3 Fix autostart replays following a23884d79a by grabbing g_GameAttributes from the simulation instead of the GUI. Patch by Imarok, refs #3143.
Don't remove attribs from the init attributes as that is still used by
the loading screen to show the mapname.

This was SVN commit r18510.
2016-07-12 01:49:48 +00:00
a23884d79a Cache gameAttributes in the session. Patch by Imarok, refs #3143, #3263.
This was SVN commit r18452.
2016-06-29 01:45:20 +00:00
0f807c643a GUI cleanup.
Point out missing functionality and unused properties in the
implementation of checkboxes.
Don't specify a useless font tag for checkboxes in the templates.

This was SVN commit r18419.
2016-06-21 14:38:06 +00:00
7c21a0cf8e Header cleanup: profile.h is no longer unnecessarily included in scriptinterface.h but rather in the required .cpp files
This was SVN commit r18417.
2016-06-21 10:33:11 +00:00
84d5fb2d34 Tooltip GUI engine cleanup.
Merge some if statements.
Fix whitespace.
Remove unneeded comments and braces.
Remove one duplicated statement out of an if-statement.

This was SVN commit r18381.
2016-06-15 15:40:05 +00:00
a296909f91 GUI engine cleanup.
Merge a check.
Remove unneeded comments and braces.
Some whitespace fixes.

This was SVN commit r18379.
2016-06-14 15:06:39 +00:00
62061557db Host on arbitrary UDP ports. Patch in cooperation with Imarok, fixes #3575.
This was SVN commit r18372.
2016-06-13 16:56:14 +00:00
c94cd66a57 Savegame cleanup.
Remove the player assignments altogether (506350d6fa) as the C++ part
already saves the playerID.
Grab the playerID directly from the game instead of passing it around
needlessly.

This was SVN commit r18357.
2016-06-10 19:04:57 +00:00
70e6be5196 GUI engine cleanup.
Remove unneeded parenthesis and few whitespace changes.

This was SVN commit r18341.
2016-06-07 15:57:33 +00:00
a7b310f3bd GUI engine cleanup.
Fix typos, remove unneeded comments.

This was SVN commit r18339.
2016-06-07 12:02:33 +00:00
248a48d88a Major network cleanup. Patch by Imarok.
Access the server from the client only, not from the GUI (except for
autostarted games).
Thereby lay the foundation for clients to setup the game (refs #3806)
and dedicated hosting (refs #3556).
Doesn't transfer nor remove the SetTurnLength showcase from 0ebe3486b6.

This was SVN commit r18322.
2016-06-04 12:08:30 +00:00
8b30273a50 GUI engine improvement + gamesetup cleanup.
Grab the list of children of a GUI object directly instead of hardcoding
the names.

This was SVN commit r18296.
2016-06-02 22:49:28 +00:00
00ea7763f7 GUIInterface / observermode cleanup as recommended by leper, fixes #3999.
Default to the viewed player in the GUIInterface to avoid passing that
separately in some places, refs #3168.
Thus GetEntityState will be called for the viewed player instead of
observer playerID, therefore
fixes a fog-of-war selection relict when changing the perspective, refs
#3850.
Also remove some unused player arguments.

This was SVN commit r18283.
2016-06-02 00:09:21 +00:00
9cc98aaf47 Take new observermode into account in some missing places, refs #3850, #3168.
This was SVN commit r18223.
2016-05-23 15:26:47 +00:00
ec1696ded3 Send a network message to update the GUI if another player pauses a multiplayer game. Patch by echotangoecho, fixes #1950.
Pause animations then and on disconnect.
Don't unpause unintentionally when closing a message box in
singleplayer.

This was SVN commit r18204.
2016-05-19 22:10:38 +00:00
856dc1c999 Network cleanup.
Send the "client has rejoined" message after the synchronization
finished instead of right after the loading screen.
Patch by echotangoecho, refs #1949, #1950.

This was SVN commit r18203.
2016-05-19 21:03:46 +00:00
6f744aef88 Simulation context cleanup, refs #3991, #3168.
Save the viewed player in the CGame class.
Add the const keyword back to the SimContext to help find mistakes at
compiletime.

This was SVN commit r18201.
2016-05-19 19:42:07 +00:00
9eccf5cd07 Use an actual playername instead of "You" in singleplayer, fixes #3979.
Differentiate between SP and MP name and allow editing it in the
settings.
Defaults to the OS username.
Makes sharing singleplayer replays more effective.
Also fixes a troublesome colorization of "You" in a translated sentence,
refs #3501.

This was SVN commit r18180.
2016-05-15 17:13:35 +00:00
1a3fb29ff3 Network cleanup, fixes #3953.
Don't compare for "127.0.0.1" to identify the host, but check for a new
boolean flag that is set by the client, refs #2854.
Remove an unneeded IP address conversion from u32 to string, refs #3241.

This was SVN commit r18140.
2016-05-08 11:46:19 +00:00
f905ee2c7e Don't use the ternary operator as some people find that unreadable.
This was SVN commit r18035.
2016-04-15 06:11:38 +00:00
a57bfc829e Add a button to the summary screen to replay the game that was just played (or replayed). Patch by Imarok, fixes #3437.
This was SVN commit r18031.
2016-04-14 14:45:03 +00:00
5ac76ecf89 Some style fixes reported by leper.
This was SVN commit r18016.
2016-04-10 16:57:12 +00:00
f8b20d181d Add chat-addressee dropdown, refs #1767.
Add observer-only chat and allow private messages from observer to
observer.
Prevent defeated players from using the team-chat, fixes #3441.

This was SVN commit r17771.
2016-02-18 01:09:56 +00:00
3244d91add Don't render a selection box instead of crashing due to ENSURE when elements are removed from a dropdownlist
(while the list is rendered and the last element being selected).

This was SVN commit r17751.
2016-02-12 16:38:25 +00:00
a2f7d4d82a Show fog of war in observermode, fixes #3168.
This was SVN commit r17735.
2016-02-06 12:56:41 +00:00
22f5b00fce Implement network-warnings, fixes #3264.
Shows a notification if the local client or other players connections
timeout or have bad latency.

This was SVN commit r17730.
2016-02-04 17:14:46 +00:00
1a66f510d0 Use const T& for parameters of some types in script-exposed native functions
Using references matches the C++ coding style better and should improve
performance a bit in theory. It avoids 2 copies of T in case of the
functions registered with RegisterFunction (mainy used in the GUI). It
should also avoid one or two copies in case of
DEFINE_INTERFACE_METHOD_X, which is used in the simulation, but I
haven't bothered to count it there exactly.
It is now predefined which types have to be passed by const reference
and which are passed by value. Note that references can't be used as
out-parameters (to return multiple values to JS). This hasn't worked
before either and probably never will.

This was SVN commit r17696.
2016-01-23 15:17:56 +00:00
a59833102f Specify the default column sorting order in XML instead of JS.
Ref #2405, #3473.

This was SVN commit r17670.
2016-01-18 19:23:14 +00:00
7c40c67efa Fix a bug in b8fce56821 which prevented the replaylist from being sorted correclty on init, refs #2405, #3473.
The default column argument is given in XML and applied in
COList::SetupText() but it hasn't been stored, preventing JS from
knowing the selected column.

This was SVN commit r17665.
2016-01-18 14:45:13 +00:00
fb92761c92 Use explicit types instead of auto.
This was SVN commit r17642.
2016-01-13 00:42:55 +00:00
27fab6bf1e Constify Spatial.h a bit.
While there don't check for null when delete-ing since that is a no-op,
use the proper type instead of auto, always swap when removing a single
element (instead of comparing .size() to 1), and clean up includes.

foobar

This was SVN commit r17641.
2016-01-13 00:20:22 +00:00
8c7b6dceaa Show status-bars of all players to observers, fixes #3215.
This was SVN commit r17623.
2016-01-10 16:47:57 +00:00
8859f33b38 Rename PickFriendlyEntitiesOnScreen to PickPlayerEntitiesOnScreen.
Rename PickFriendlyEntitiesInRect to PickPlayerEntitiesInRect.
Rename PickSimilarFriendlyEntities to PickSimilarPlayerEntities.
Add comment.
Refs #3215.

This was SVN commit r17622.
2016-01-10 14:47:09 +00:00
9a2d0f803e Remove disabled by default SDL1 support.
Refs #2041.

This was SVN commit r17470.
2015-12-14 10:52:21 +00:00
909b8d4369 Allow multiple special sprites, to facilitate cases where we want to add an overlay to a sprite.
"color" can make use of the sprite's alpha texture, and the "add_color"
effect will now take the original image's alpha into account.
Remove the no longer needed "unaffordableMask" images on a variety of
panels.

Somewhat based on a patch by BoeseRaupe. Fixes #2421 and #3688.

This was SVN commit r17456.
2015-12-13 16:03:17 +00:00
9819b23529 I should not commit half-finished debug code.
This was SVN commit r17276.
2015-11-16 18:48:05 +00:00
70164a02c4 Handle double-clicks on list elements better. Patch by elexis.
Fixes #3574

This was SVN commit r17274.
2015-11-16 18:23:21 +00:00
6b8dc7684a Return in case we do not have any available JS timer slots instead of accessing OOB memory.
This was SVN commit r17263.
2015-11-15 01:09:35 +00:00
32da740f14 Allow kicking/banning players from gamesetup and session. Patch by elexis. Fixes #3241.
This was SVN commit r17217.
2015-11-11 02:05:23 +00:00
108633affd Fix #3415. Removes 'ghost' scrollbar bounding to enable extreme-right hover and selection in dropdowns. Patch by elexis.
This was SVN commit r17149.
2015-10-31 05:40:43 +00:00
d64b95b28c An awesome Visual Replay menu, made by elexis. Fixes #3258.
This was SVN commit r17054.
2015-09-21 17:00:21 +00:00
9816e7c92d Rename some variables to point out that they are only used in visual replay. Add script function IsVisualReplay. Refs #9 #3355, patch by elexis
This was SVN commit r17017.
2015-09-13 19:03:33 +00:00
7d6553099f Fix wrong offset when clicking too close to the header of sortable lists. Also added some code comments.
Patch by elexis, fixes #3391

This was SVN commit r16976.
2015-09-02 17:55:02 +00:00
74c420f658 GUI code cleanup. Fixes #3354.
Lots of code style fixes:
 * type [*&]varname -> type[*&] varname
 * else
   if (...)
   ->
   else if (...)
 * Spaces around some ops.
 * i++ -> ++i.
 * switch-case style fixes.
 * Indentation fixes.
 * Removing some commented out code.
 * include header sorting
 * Changed multiple pointer var declarations to be one per line.
 * Removed strange spaces in some places.
 * Changed some include header guards to be consistent with the rest of
the codebase.
 * Use UNUSED() instead of UNUSED2().

Some small code fixes:
 * Using .find() instead of .count() == 0.
 * !.empty() instead of .size() == 0.
 * Range-based for loops.
 * Making some member functions const by small changes.
   * Adds GetScrollBarPos(idx) const for this.
 * Using early returns/continues in some places.
 * Uses size_t for some loops in CList and COList.
 * Removes unused heading element (not attribute) from COList.
 * Use ENSURE in one case where some custom code did something similar.
 * Made some parameters const ptrs/refs.
 * Change removal loop in GUItext.cpp to erase-unique.
 * Made some static things const.
 * Allow iterating over children of IGUIObject with range-based for
loops by
   exposing begin() and end() (rename from ChildrenIt{Begin,End}()) and
use it.

Comments:
 * Comment COList.
 * Update a few comments.
 * Remove useless or duplicated comments.

This was SVN commit r16931.
2015-08-21 17:08:41 +00:00
ec96c737ee Actually use vpObj instead of obj, and use it in all cases. Refs #3354.
This was SVN commit r16909.
2015-08-02 14:40:51 +00:00
47336b770f Add clipping to OList cells. Patch by elexis. Fixes #3353.
This was SVN commit r16895.
2015-07-30 01:33:48 +00:00
c5eb9b7bb7 Range-based for for VfsPath loops.
This was SVN commit r16893.
2015-07-29 23:44:12 +00:00
04982b0bf5 Fix compiler warning
This was SVN commit r16849.
2015-07-12 16:49:26 +00:00
edf6e909b2 ...aaaaand I forgot this guy.
This was SVN commit r16846.
2015-07-12 08:11:30 +00:00
0d32afd688 Improve the style of GUI string text call functions.
This was SVN commit r16845.
2015-07-12 08:09:55 +00:00
0682190def Don't postpone rendering of icons when they are at the end of a GUI string.
Fixes #2502

This was SVN commit r16844.
2015-07-12 07:38:04 +00:00
1793a96c14 Actually remove the unused expression.
This was SVN commit r16805.
2015-06-21 20:44:31 +00:00
5a0b9b0e70 Fix some issues found by static analysis (clang-analyzer and cppcheck).
This was SVN commit r16801.
2015-06-21 18:46:31 +00:00
b8fce56821 Implement sortable columns for the gui, and use them in the lobby. Patch by Vladislav. Fixes #2405.
This was SVN commit r16781.
2015-06-17 09:10:50 +00:00
fd3d697edf Make it easier to add different backgrounds
This was SVN commit r16747.
2015-06-11 09:08:46 +00:00
a18fbd12ec XML validation. Based on patch by historic_bruno. Refs #245.
This was SVN commit r16733.
2015-06-07 21:56:52 +00:00
f71be3c764 Use iterators for XMBAttributeList and XMBElementList. Fixes #3269.
This was SVN commit r16704.
2015-06-01 00:29:35 +00:00
d3da00dc99 Fix some issues found by static analysis.
Actually abort in case of recursive includes again. Refs #2622.

This was SVN commit r16703.
2015-06-01 00:29:23 +00:00
7a70c475df Improve rejoin messages. Patch by elexis. Fixes #1949.
This was SVN commit r16614.
2015-05-03 02:06:17 +00:00
535d612e06 Small fixes.
This was SVN commit r16552.
2015-04-20 14:51:06 +00:00
120ff2c60c Fix the structure tree a second time, this should also work on Windows.
This was SVN commit r16542.
2015-04-15 09:10:05 +00:00
a980d8fdfc Fix structure tree by allowing undefined templates in the productionqueue
This was SVN commit r16537.
2015-04-14 18:45:02 +00:00