1
0
forked from 0ad/0ad
Commit Graph

1124 Commits

Author SHA1 Message Date
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
96410ee9a4 Fix heightmap rectangle. Take the water plain height as the base plane, instead of a hardcoded value.
This was SVN commit r16482.
2015-04-01 14:17:18 +00:00
b1c4e29ac8 Fixes inconsistencies in spelling of colour/color by preferring "color" (only wxWidgets remains with some API that requires "colour"), fixes #1029.
NOTE: requires update-workspaces and may require correction of some
modded actors/scenarios

This was SVN commit r16438.
2015-03-15 23:59:48 +00:00
caf89fa04e Rename ps/Overlay(.h|.cpp) to ps/Shapes(.h|.cpp), fixes a TODO located in graphics/Overlay.h.
The file name did not match the content.

Also little cleanup of some unnecessary includes.

This was SVN commit r16431.
2015-03-15 18:06:32 +00:00
bb9de80dd4 Convert CConsole to take UTF-8 strings.
This avoids vswprintf failures when printing non-ASCII char* strings
from CLogger into the console.

Also convert ScriptInterface::ToString to return UTF-8, to avoid some
utf8_from_wstring calls.

Also remove some unused and redundant CConsole functions.

This was SVN commit r16333.
2015-02-14 01:49:34 +00:00
e06a7b37d8 Convert debug_printf to take UTF-8 strings instead of wchar_t.
This fixes the problem where passing a non-ASCII string to
debug_printf(L"%hs", s) caused vswprintf_s to fail on Linux (because it
doesn't know what encoding the char* is meant to have). Now debug
messages will remain as UTF-8 until they reach the OS.

Fixes #3021.

This was SVN commit r16332.
2015-02-14 01:45:13 +00:00
53b335f5ae Improve auto-completition of nick names and add it to the in-game chat. Patch by trompetin17. Refs #1767.
This was SVN commit r16261.
2015-02-02 23:44:06 +00:00
df2e077870 Trailing spaces cleanup, based on patch by trompetin17, refs #1767.
This was SVN commit r16244.
2015-01-29 16:10:03 +00:00
0ef6c7555e Optimise VBO updates.
Some drivers (at least the Intel drivers on Windows) are slow at
incrementally updating a VBO with hundreds of calls to glBufferSubData
every frame. Performance is significantly better if you use
glBufferData(NULL) to tell it to discard all the previous contents, and
then re-upload all the data at once.

Update CVertexBuffer so that GL_DYNAMIC_DRAW/GL_STREAM_DRAW buffers are
handled with the new mechanism. This requires the caller to hold onto
the backing store so it can be re-uploaded when necessary, and needs a
bit more signalling to indicate exactly what needs uploading.

I see an improvement from roughly 60 to 75 fps on Intel HD Graphics
3000, Windows, 1024x768, Siwa Oasis.

This was SVN commit r16241.
2015-01-28 00:48:00 +00:00
59503b9ae9 Add basic support for GUI scaling factor, to help with high-res displays (e.g. 4K monitors and 1080p tablets).
Use the config setting "gui.scale = 0.5" to make the GUI bigger.

This was SVN commit r16223.
2015-01-24 20:06:37 +00:00
c02a7e1a7b SpiderMonkey 31 upgrade
This upgrade also introduces exact stack rooting (see to the wiki:
JSRootingGuide) and fixes problems with moving GC. This allows us to
enable generational garbage collection (GGC).
Measurements a few months ago have shown a performance improvement of a
non-visual replay of around 13.5%. This probably varies quite a bit, but
it should be somewhere between 5-20%. Memory usage has also been
improved. Check the forum thread for details.

Thanks to everyone from the team who helped with this directly or
indirectly (review, finding and fixing issues, the required C++11
upgrade, the new autobuilder etc.)! Also thanks to the SpiderMonkey
developers who helped on the #jsapi channel or elsewhere!

Fixes #2462, #2415, #2428, #2684, #1374
Refs #2973, #2669

This was SVN commit r16214.
2015-01-24 14:46:52 +00:00
568c415d0a Convert wchar_t*/wstring arguments to UTF-8 strings in CLogger messages.
This was SVN commit r16188.
2015-01-22 20:37:38 +00:00
e02d7ad949 Automatically replace %hs/%ls with %s in CLogger format strings.
Everything is char* now, so we don't need to mess around with different
string types.

Done with:

  ag -ls 'LOG(MESSAGE|MESSAGERENDER|WARNING|ERROR)' source | xargs perl
-pi -e'1 while
s/(LOG(MESSAGE|MESSAGERENDER|WARNING|ERROR).*)%[hl]s/$1%s/g'

This was SVN commit r16187.
2015-01-22 20:36:24 +00:00
38a8e2e0d6 Automatically convert most path.string().c_str() to path.string8()
Done with:

  ag -l 'LOG.*string\(\).c_str\(\)' source | xargs perl -pi -e'1 while
s/(LOG.*string)\(\)\.c_str\(\)/${1}8()/g'

This was SVN commit r16186.
2015-01-22 20:35:17 +00:00
49e2ecea63 Automatically convert all CLogger format strings from wchar_t* to char*.
Done with:

  ag -ls 'LOG(MESSAGE|MESSAGERENDER|WARNING|ERROR)' source | xargs sed
-i 's/LOG\(MESSAGE\|MESSAGERENDER\|WARNING\|ERROR\)(L/LOG\1(/g'

This was SVN commit r16183.
2015-01-22 20:31:30 +00:00
755ec45a14 Use correct format specifiers. Patch by bog_dan_ro.
This was SVN commit r16148.
2015-01-13 18:37:50 +00:00
851d3d964a Fixes MSVC build warnings about unhanded cases in switch statement (C4062) and missing parameter in macro (C4003)
This was SVN commit r16141.
2015-01-11 21:37:53 +00:00
8e30410109 Improve PickEntitiesAtPoint
First, do a ray intersection test with the bounding-sphere for all
entities on the map and then check the more detailed selection shape for
the remaining candidates. Do checks that require component lookups after
the ray intersection tests because these are relatively expensive.
The old method for figuring out which entities are below the mouse
cursor was incorrect because it does a 2D check to filter out the first
candidates which can lead to incorrect results with lower camera angles
and high buildings or buildings with a large footprint. Such problems
were avoided with quite a large radius for this 2D test and resulted in
a large number of candiate entities after this first test (200-500).
Also rename PickEntitiesAtPoint to PickEntityAtPoint and make it return
only one (the closest) match.

I've tested performance with the tracelogger by starting a map and then
moving the mouse in circles for one minute. The results were relatively
stable. I've compared the total time percentage of input.js:836, which
spends nearly all of the time in PickEntityAtPoint.
Ardennes Forest - Normal size:       Original: 41.46%    Patched: 31.6%
Ardennes Forest - Giant size:        Original: 40.59%    Patched: 51.55%

As we see, it's faster on normal map sizes but slower on giant maps with
a lot of entities.
This approach can be further improved with some kind of spatial
subdivision for the culling (like an octree), which would help the unit
renderer too. This way it should be possible to make it faster (and
still correct) on all map sizes and with a large total numbers of
entities.

This was SVN commit r16098.
2015-01-01 23:05:26 +00:00
2c20936ce3 Save map settings. Patch by @aBothe. Fixes #2963.
This was SVN commit r16089.
2014-12-31 00:21:24 +00:00
d68a057153 Fix warning.
This was SVN commit r16077.
2014-12-28 16:45:06 +00:00
4c12440868 Give access to the templates to the GUI. This will be useful for eventually displaying factions specificities in main menus.
This was SVN commit r16075.
2014-12-28 16:21:07 +00:00
add113a2a1 Remove duplicated layers of unescaping which required multiple escapes in some places.
This was SVN commit r16043.
2014-12-13 01:08:29 +00:00
622614de02 Allow nesting repeat tags in the GUI.
This was SVN commit r16034.
2014-12-10 20:10:02 +00:00
c385a88c88 Remove unused overload of GetSavedGameData
This was SVN commit r16001.
2014-11-22 19:46:24 +00:00
9407dbe45e Remove useless parameter from CFG_GET_VALUE.
This was SVN commit r15984.
2014-11-17 23:29:49 +00:00
df4c07238d Change GUI tag parsing to use a FSM instead of using CParser. Refs #2589.
Parameters now have to be quoted with ".
Supports " in parameters by escaping them with \.
Tag start characters can be included in normal text by escaping them
with \.
Better error handling and a error messages to help with fixing
invalid/malformed strings.

This was SVN commit r15969.
2014-11-16 02:10:28 +00:00
d15e2f0cf6 Check for availability of XmppClient.
Move Lobby script function registration to the lobby JS interface.

This was SVN commit r15968.
2014-11-16 02:10:24 +00:00
c813a11427 Split ScriptRuntime and ScriptInterface code to separate files.
The runtime is becoming more and more important in the JSAPI. As a
result, we also have more functionality on the runtime level and having
the whole ScriptRuntime class hidden in ScriptInterface.cpp doesn't make
sense anymore. ScriptInterface.cpp also has become quite a large file
and pulling out the runtime part makes it a bit smaller.

Refs #2462

This was SVN commit r15961.
2014-11-13 11:19:28 +00:00
6e788fb15e Clean up JSON parsing code. Refs #1374.
Fix Engine.ReadJSONFile() which did throw a JS exception that was not
caught. Discovered by s0600204.
Expose Engine.ReadJSONFile() to the gui scripts.

This was SVN commit r15959.
2014-11-13 01:26:22 +00:00
e108b162b6 Add hotloading for translation files. Fixes #2915.
This was SVN commit r15947.
2014-11-09 16:58:14 +00:00
8b9847e007 Replace CScriptValRooted with JS::Heap<T> and custom tracer for CNetClient
Refs #2462

This was SVN commit r15946.
2014-11-09 15:16:00 +00:00
ff50b0b74c Fixes incorrect input handling in dropdowns and lists, they were manually handling all events, but should only handle certain key presses. Fixes #2885.
Fixes bug where lists/dropdowns could select an invalid index.

This was SVN commit r15909.
2014-10-27 04:37:06 +00:00
b4997dc7c6 Fixes minimap GLES compatibility by making point size a uniform and passing into the shaders
This was SVN commit r15901.
2014-10-26 04:37:26 +00:00
18ab827886 Change L10n code to use ps/Singleton, so that we can recreate it.
This allows for adding locales in mods.

This was SVN commit r15874.
2014-10-15 16:04:37 +00:00
9c4eb0295a Fixes some bugs related to IME text input in SDL2, including a possible crash, refs #2041. Behavior seems reasonably consistent now on Windows and OS X
This was SVN commit r15830.
2014-10-03 23:33:41 +00:00
3b49576fa6 Tunes GC scheduling a bit to reduce memory usage.
The main problem was that GC was only called from the simulation before
this patch. This means when you were waiting in the multiplayer lobby or
just had the GUI open, it only called GC when getting close to the JS
runtime size limit (I assume). Another problem was the Net Server
runtime which didn't GC either. Here the runtime size limit is 16 MB
though, so it's not too terrible. These issues have both been addressed
and GC has been given a bit more time per incremental slice to make sure
it gets done in time. It's still far from perfect, but there are too
many changes in SpiderMonkey related to GC, so I don't want to spend too
much time on this yet.

Refs #2808

This was SVN commit r15787.
2014-09-22 20:13:04 +00:00
5593f573f4 Cleans up handling of SDL2 text input events, no behavior change expected.
Implements SDL2 text editing handler for input fields, this is for IME
support, so users entering CJK text can see what they're composing
before committing it. Should have no effect on SDL1 or normal text
input.

This was SVN commit r15785.
2014-09-22 19:00:20 +00:00
6b2677a3fd Adds profiles to the multiplayer lobby. Fixes #2504.
This was SVN commit r15768.
2014-09-20 15:35:26 +00:00
d62e3729d5 Improves SDL2 support, includes patch by yashi and fabio, refs #2041:
* Adds SDL color cursor implementation
* Adds config option for choosing preferred display in multimonitor
setup
* Uses text input API to better handle CJK input
* Fixes various hotkey and input bugs

SDL 1.2 is still the default and recommended, to test experimental SDL2
support, pass the --sdl2 flag to update-workspaces

This was SVN commit r15767.
2014-09-20 12:12:35 +00:00
881ad4090b Fixes weird unconventional use of logical not operator that also triggered a warning in clang
This was SVN commit r15717.
2014-09-08 00:19:35 +00:00
64bfa089af Add mod selection mod.
Includes some contributions by rada and sanderd17.

This was SVN commit r15677.
2014-08-25 16:02:54 +00:00
8ce8e6ba9a Exact stack rooting for IGUIObject.
Refs #2415
Refs #2462

This was SVN commit r15623.
2014-08-08 13:41:47 +00:00
c662a4e9e9 Fixes #2713
This was SVN commit r15615.
2014-08-05 19:03:10 +00:00
e41f010f91 Fixes crash when loading maps in Atlas.
The ScriptInterface pointer can be NULL there, so using it without
checking is not safe.
This fixes the problem by continuing with the exact stack rooting
changes, which makes the temporary solution unnecessary.

Fixes #2707
Refs #2415

This was SVN commit r15611.
2014-08-04 20:14:17 +00:00
efb889b79a Exact stack rooting for WriteStructuredClone and functions that use it.
Refs #2415

This was SVN commit r15607.
2014-08-03 19:32:39 +00:00
a2bd44b23a Exact stack rooting for JSON related ScriptInterface functions.
Refs #2415
Refs #2462

This was SVN commit r15603.
2014-08-02 22:21:50 +00:00
608c27fe10 Exact stack rooting for structured cloning functions.
Refs #2415
Refs #2462

This was SVN commit r15597.
2014-08-01 20:55:16 +00:00
5c07a25ddc More exact stack rooting (CallFunction object).
Changes CallFunction and CallFunctionVoid to use a HandleValue as object
parameter. Also changes some JS serialization/deserialization functions
to only support the JSAPI rooted types (drop support for CScriptVal and
CScriptValRooted there). Some other functions got changed too because
they were closely related.

Refs #2415
Refs #2462

This was SVN commit r15592.
2014-07-31 19:18:40 +00:00
2ae74221c7 Fixes saving/loading problems introduced in 28bdd8540f.
* CGameLoader created a new JS::Value when assigning to m_Metadata.
This means it didn't actually update metadata in SavedGames::Load. The
new approach solves this problem and should work well if
CScriptValRooted gets replaced in the future.
 * The cloning in ScriptFunctions.cpp was required. Removing it caused
compartment mismatches.
 * Now CGameLoader loads the metadata unconditinally because we didn't
actually use the option to not load load it.

Ref #2415

This was SVN commit r15589.
2014-07-31 14:44:51 +00:00
28bdd8540f Quite a lot of stack rooting related changes.
Changes GetProperty, SetProperty and HasProperty and a few other
functions to take handles. The conversions to CScriptVal or
CScriptValRooted at some places should be removed in the future. I've
done that to avoid an even larger patch.

Refs #2415
Refs #2462

This was SVN commit r15568.
2014-07-26 22:33:16 +00:00
31f9ca9ebf Implements CallFunction with JS::MutableHandle<T> return type.
Changes the CallFunction implementation to use macros because otherwise
we'd have to write twice as many functions manually.
Adapts GetSavedGameData to use the new function template. Additional
callers will be changed in future commits.

Refs #2415
Refs #2462

This was SVN commit r15541.
2014-07-20 15:08:28 +00:00
52f4cda439 Changes ToJSVal to take JS::MutableHandleValue instead of JS::Value&.
JS::MutableHandleValue is similar to JS::HandleValue, but the whole
JS::Value it points to can be replaced.
This change is needed for support of exact stack rooting and moving GC.
Contains a few other trivial API adjustments and style improvements too.

Refs #2462
Refs #2415

This was SVN commit r15534.
2014-07-14 19:52:35 +00:00
17634d7507 Move the minimap to only use the shader pipeline. Should make it OpenGL ES compatible (untested).
This was SVN commit r15533.
2014-07-14 17:15:22 +00:00
1b5ab8142e Makes custom JS objects compatible with SpiderMonkey ESR31.
In v24 you called JS_InitClass and passed in a definition of JSNative
functions. Later you could call JS_NewObject with this class and the
object would get a prototype with the specified JSNative functions.
In ESR31 you now have to explicitly store the prototype object returned
by JS_InitClass and pass it as prototype argument to JS_NewObject to
achieve the same.
This change modifies our existing ScriptInterface implementation for
custom object types a bit and uses it at places where the JSAPI was used
directly before.

Refs #2462

This was SVN commit r15524.
2014-07-13 15:31:48 +00:00
db9c20e0a9 Changes FromJSVal to take a JS::HandleValue instead of JS::Value.
JS::HandleValue is basically a wrapper around a JS::Value that is safe
for exact stack rooting and moving GC.
I've tried to keep this changeset rather small and isolated and
therefore create additional JS::Rooted<T> values at some places where
the function should eventually directly take a JS::Handle<T>.
The functions "CallFunction" and "CallFunctionVoid" put their arguments
inside a JS::AutoValueVector because this will be passed directly to
"CallFunction_" with ESR31.

Refs #2462
Refs #2415

This was SVN commit r15517.
2014-07-12 19:08:39 +00:00
cfa59fc4e1 Changes our JSNative functions to use JS::CallReceiver/JS::CallArgs.
This is the new way for working with arguments in JSNative functions.
JS_THIS_VALUE, JS_ARGV, JS_SET_RVAL and direct access to vp or argc are
deprecated and will probably be removed in future versions of
SpiderMonkey.
CallArgs also takes care of proper rooting and you can get the values as
Handles or MutableHandles. The interface changes a little bit for ESR
31, but commiting this now still makes it easier and the changes shout
be straigtforward (search and replace more or less).

Refs #2462
Refs #2415

This was SVN commit r15516.
2014-07-12 16:55:09 +00:00
8b493c2739 Revert obsolete workaround for structured clones.
Reverts 8195e767ef because that workaround isn't needed anymore with
SpiderMonkey 24 (and 31).

Refs #2241
Refs #1886

This was SVN commit r15495.
2014-07-05 11:35:00 +00:00
ffd6e10edf Make CGUIManager register a callback function for hotloading instead of specifically calling it.
This was SVN commit r15482.
2014-07-02 23:44:39 +00:00
c793da5368 Don't allow changeing disabled dropdowns using the scrollwheel. Also corrects some things in b9a4af4cc6.
This was SVN commit r15406.
2014-06-21 00:25:12 +00:00
02fd235bbd Make hotkeys and top panel fully moddable by splitting up the xml file. Allow entire directories to be loaded via an 'include' to provide extra moddability (modders don't have to edit any files, they can just add new ones).
This was SVN commit r15380.
2014-06-17 13:03:55 +00:00
b469983c58 Fix for 89f5e7b260. Refs #2622
This was SVN commit r15353.
2014-06-14 16:12:41 +00:00
89f5e7b260 Improve gui moddability by allowing to load an entire directory of scripts at once, and being able to split up big gui XML files. Fixes #2622
This was SVN commit r15330.
2014-06-11 17:14:35 +00:00
fd8ffb506b Remove commented out code and add licence headers to COList.cpp/.h.
This was SVN commit r15300.
2014-06-05 14:33:44 +00:00
2c14d94559 Replace usage of CParser for CColor.
Switches format to use integers only.
Adds logging if the string is invalid.
Refs #2589.

This was SVN commit r15278.
2014-06-04 00:58:05 +00:00
5ce12c2263 Start phasing out the use of CParser in the GUI. Makes GUI parsing generally faster and stricter while adding better tests and debug information.
This was SVN commit r15213.
2014-05-25 03:16:52 +00:00
f15160412a Enlarge the ideographic ranges in the word boundaries, fixes Japanese rendering a bit
This was SVN commit r15138.
2014-05-09 12:13:42 +00:00
62f5476dec Add support for adding translation context to XML elements. Patch by Gallaecio.
Add translation context to some lobby headers.

This was SVN commit r15078.
2014-04-30 22:33:08 +00:00
2ad7187f92 Move XMPP polling to the mainloop. Should reduce lobby disconnects. Fixes #2491
This was SVN commit r15018.
2014-04-27 05:37:34 +00:00
d1d7afe46c Implements ready status into gamesetup. Fixes #2447.
This was SVN commit r15006.
2014-04-26 18:34:34 +00:00
dc0deb5f52 Fixed bad fix in bc1ed335e2
Note: l777 had given me the right fix (%s), I fixed it wrong for no good
reason…

This was SVN commit r14989.
2014-04-25 02:56:08 +00:00
bc1ed335e2 Fix GCC warning on “source/gui/scripting/ScriptFunctions.cpp”
Reported by JoshuaJB at Github: https://github.com/leper/0ad/issues/27
Fix provided by l777 (who I believe to be leper but I don’t really know)
on IRC.

This was SVN commit r14985.
2014-04-25 00:38:30 +00:00
510ad15e6c Adds missing libs, fixes some svn properties and a build-problem on Windows.
In 1b3261b8f4 empty text files were committed instead of the libs.
The text files had svn:eol-style properties set and the mime-type was
text.
This removes the eol-style properties, changes the mime type and addes
the content of the files.

This was SVN commit r14959.
2014-04-20 23:47:52 +00:00
e05c8263c5 Internationalization of the public mod (JavaScript and GUI XML side)
It includes a marvelous language selection menu developed by Yves.

It also includes the introduction of a sprintf implementation for
JavaScript, as well as
translation helper functions that use JavaScript-side translation
caching.

This patch includes code by Yves, sanderd17, leper and Gallaecio.

Ref #67

This was SVN commit r14954.
2014-04-20 20:51:48 +00:00
d6db5a466d Internationalization of the C++ side
Provides the logic to detect the system language, load translations, and
use
loaded translations both in the C++ and the JavaScript side.

This patch includes code by Yves, sanderd17, leper, historic_bruno and
Gallaecio. It’s worth noting that Yves and historic_bruno were also the
main
contributors behind the changes in 1b3261b8f4 as well.

This was SVN commit r14953.
2014-04-20 20:03:57 +00:00
9e2d0b9506 Fix #2404. Rating auto-configure TODO (eg 2v2 games do not automatically show as being unrated). See #2276.
This was SVN commit r14934.
2014-04-16 06:03:49 +00:00
180aa5c60d Makes the moderator prefix visible in the chatbox.
This was SVN commit r14922.
2014-04-12 23:40:36 +00:00
833c2bac7a save/restore camera position and orientation in saved games, fixes #2354
This was SVN commit r14905.
2014-04-06 16:27:57 +00:00
e9e05f4efc Second (main) commit for the SpiderMonkey upgrade.
This commit contains all the required changes to our source files and
build scripts (hopefully).
A next commit will remove the old stuff of SpiderMonkey 1.8.5.

Spcial thanks to:
 - H4writer who helped a lot mainly with the performance issues we
had/have, but also with other problems or questions.
 - Leper for the review.
 - Historic_bruno for implementing the build scripts on Mac OS X and
testing on the Mac.
 - The people from the #jsapi channel and from
mozilla.dev.tech.js-engine who answered a lot of questions and helped
solving problems.
 - All the other people who helped

Refs #1886
Fixes #2442
Fixes #2416

This was SVN commit r14877.
2014-03-28 20:26:32 +00:00
cde72788a2 * Add support for fallback fonts in the font builder.
* Replace DejaVu with Biolinium for the existign sans-styles.
* Add additional sans-styles using Biolinum.
* Update the GUI style definitions to use the sans-styles instead of
serif styles.
(Wait with updating custom defined fonts in strings, as it will cause a
mess with the internationalisation that's about to be included)
* Add fonts from the quite complete FreeFont family as fallback fonts.
* Render all glyphs supported by the different fonts to support as many
scripts as possible.
* Fixes #2457.
(Now hope I included all needed files)

This was SVN commit r14853.
2014-03-17 10:13:49 +00:00
fb65288463 Fix hover effect not regenerating after mousedown events, minor GUI code cleanup, and fix #2414
This was SVN commit r14819.
2014-03-07 22:43:57 +00:00
8f30e722ab Some inconsequential style adjustments.
This was SVN commit r14809.
2014-03-06 02:24:06 +00:00
02024370d8 Fix a warning in Visual Studio 2010 related to some of my recent changes.
This was SVN commit r14805.
2014-03-05 01:06:13 +00:00
e182b4ddd2 Fix a valgrind warning about uninitilized variables in the scrollbar code and some comment/style fixes.
This was SVN commit r14764.
2014-02-19 21:59:07 +00:00
72d306873f Correctly handle the keypad enter in CInput.cpp and make the return key case catch SDLK_RETURN instead of '/r' for consistancy and readability.
This was SVN commit r14730.
2014-02-03 21:46:27 +00:00
39fef5c299 Add the ability to display chat messages when joining the lobby and quickly mostly update the options window to the new UI style.
This was SVN commit r14679.
2014-01-26 05:39:55 +00:00
041c6ab1b3 More lobby cleanup.
This was SVN commit r14677.
2014-01-26 04:25:35 +00:00
b46a6de335 Allow using the XMPP room subject to display lobby information to user, make the lobby GUI code more readable, and cleanup the modern styles.
This was SVN commit r14656.
2014-01-24 18:20:15 +00:00
dd274113bc Fix #2403
This was SVN commit r14655.
2014-01-24 18:15:42 +00:00
e5e634f768 Displays ratings in the userlist. Fixes #2371.
This was SVN commit r14650.
2014-01-23 23:13:13 +00:00
41d3366f6a check version and mods before loading a file, fixes #2361 and #2385.
This was SVN commit r14630.
2014-01-21 22:49:42 +00:00
377c780ddd Fixes the problem that functions in globalscripts aren't available from GUI scripts anymore since 4b1297b328.
Refs #2241

This was SVN commit r14592.
2014-01-17 18:21:27 +00:00
c094e72ede Fixes scoping for icons in GUI text, instead of using only the top page on the stack, which caused errors when dialog boxes popped up over text containing icons
This was SVN commit r14591.
2014-01-17 02:54:57 +00:00
8195e767ef Fixes an occasional crash when hotloading GUI files.
Refs #2241

This was SVN commit r14573.
2014-01-11 20:53:01 +00:00
8226d75715 Make PickEntitiesAtPoint faster yielding 1-3% overall performance improvement. Fixes #2358. Also removes some trailing whitespace.
This was SVN commit r14532.
2014-01-07 04:05:10 +00:00
6ca6a5f779 The patch in 4b65f77438 seems to have fixed the crash, but the initData value doesn't match the JSContext's compartment, so it's theoretically wrong.
This should fix it correctly.

#Refs 2241

This was SVN commit r14508.
2014-01-04 21:49:36 +00:00
4b65f77438 Fixes an occasional crash introduced in #2241 (hopefully).
Refs #2241

This was SVN commit r14507.
2014-01-04 21:36:12 +00:00
4b1297b328 Removes g_ScriptingHost and implements global to compartment 1 to 1 relation.
Each GUI Page gets its own compartment and all ScriptInterfaces in the
same thread should now use the same JS Runtime.
This is required for the SpiderMonkey upgrade.
Check the ticket for details.

Closes #2241
Refs #1886
Refs #1966

This was SVN commit r14496.
2014-01-04 10:14:53 +00:00
fb8032043b Use pointers instead of copying sprites in the GUI. Fixes #1984. Patch by jP_wanN.
This was SVN commit r14493.
2014-01-03 20:19:43 +00:00
b1422137e5 Cleanup GUI Checkbox C++ code by removing broken, non-obvious internal text rendering.
This was SVN commit r14476.
2014-01-02 03:28:15 +00:00
67570be8fa Make GUI button-based objects to behave more expectedly when doubleclicked, also some style tweaks.
This was SVN commit r14468.
2014-01-01 06:05:41 +00:00
1e522f9b2c Fix bug with rating in lobby bot, remove superfluous GUI typedef, and change the lobby chat autocompletion to use tab.
This was SVN commit r14467.
2014-01-01 00:23:18 +00:00