1
1
forked from 0ad/0ad
Commit Graph

139 Commits

Author SHA1 Message Date
bb
157c6af18e Make the space in 0 A.D. non-breaking throughout the codebase.
Avoid cases of filenames
Update years in terms and other legal(ish) documents
Don't update years in license headers, since change is not meaningful

Will add linter rule in seperate commit

Happy recompiling everyone!

Original Patch By: Nescio
Comment By: Gallaecio
Differential Revision: D2620
This was SVN commit r27786.
2023-07-27 20:54:46 +00:00
bb
fefde41317 Allied chat opens with t bug (on linux)
Comments By: vladislav, elexis
Solution Proposed By: elexis
fixes #5194
refs #3870

Differential Revision: D1386
This was SVN commit r26530.
2022-03-03 11:36:08 +00:00
8a63adc40d Uses CDeviceCommandContext as an input parameter for CCanvas2D.
This was SVN commit r26480.
2022-02-25 08:14:11 +00:00
4ffc005a7f Removes raw pointers management from sprites owned by CGUI.
This was SVN commit r25695.
2021-06-06 00:32:49 +00:00
57dde8d082 Provides Canvas2D for sprite rendering.
Differential Revision: https://code.wildfiregames.com/D4029
This was SVN commit r25591.
2021-05-29 19:47:36 +00:00
b17e8f3043 Removes global g_xres and g_yres dependency from GUI objects.
Differential Revision: https://code.wildfiregames.com/D4014
This was SVN commit r25577.
2021-05-26 18:52:22 +00:00
babfd913fb Adds std namespace to shared_ptr usages in gui and sound.
This was SVN commit r25526.
2021-05-22 19:23:03 +00:00
0728c58a4d Removes unnecessary z-level from GUI sprite rendering.
Tested By: Imarok
Differential Revision: https://code.wildfiregames.com/D4003
This was SVN commit r25524.
2021-05-22 18:06:18 +00:00
5ff4fa19c0 Removes unused and outdated includes, replaces some includes by forward declarations.
This was SVN commit r25444.
2021-05-15 17:27:01 +00:00
2e08fd38ea GUI cleanup: XML & child handling.
- We only need an XMBFile, not a CXeromyces to parse GUI
objects/scripts/... This makes the interface more consistent with other
usage, notably ParamNode.
- Rename IGUIObject::AddChild to RegisterChild and flesh out the
interface a little.

Differential Revision: https://code.wildfiregames.com/D3908
This was SVN commit r25378.
2021-05-04 15:17:50 +00:00
34b1920e7b Split ScriptRequest in its own header.
We often only need to include ScriptRequest.h and not the full
ScriptInterface.h

Differential Revision: https://code.wildfiregames.com/D3920
This was SVN commit r25366.
2021-05-03 16:07:26 +00:00
742b636f70 Moves CRect from ps to maths to related geometric primitives.
This was SVN commit r25165.
2021-03-30 21:14:36 +00:00
969112b9c8 Replaces CPos by more a consistent CVector2D, reduces geometry code duplication.
Tested By: Freagarach, Langbart
Differential Revision: https://code.wildfiregames.com/D3759
This was SVN commit r25152.
2021-03-28 21:55:13 +00:00
db84c2a9b2 Moves CSize into a separate file and renames it to CSize2D according to other geometric entities.
This was SVN commit r25143.
2021-03-27 16:08:06 +00:00
734b672569 Removes unused and limited cell sprite functionality.
Tested By: Freagarach
Differential Revision: https://code.wildfiregames.com/D3749
This was SVN commit r25140.
2021-03-27 11:38:34 +00:00
2e4639e6dc Removes unused containers included in headers.
This was SVN commit r25004.
2021-03-03 23:01:08 +00:00
3872ee43b5 Fix 768c84aa46 style, add tests.
Patch by: @bb
Small fixes by: @Stan
Reviewed by: @vladislavbelov
Differential Revision: https://code.wildfiregames.com/D3103
This was SVN commit r24665.
2021-01-17 15:44:14 +00:00
1b67a079fb Reduce duplication in JSI GUI objects implementation.
- Store the functions in an unordered_map. A no-container implementation
is doable but likely not worth the added code complexity, maybe with
C++20
- Move more things into the _impl.h
- Clear out the un-necessary friends declaration in the specific types
by moving the functions to the public interface, which makes sense.
- Fix a memory leak (JS::PersistentRootedObject weren't deleted).

This doesn't change what one needs to do to add a new type, but it does
reduce the actual code that's necessary, and makes it less error prone.

Differential Revision: https://code.wildfiregames.com/D3214
This was SVN commit r24384.
2020-12-13 15:06:18 +00:00
369c2e8801 Further header & precompiled cleanup, fix no-PCH builds.
GUIObjectBase is made a IGUIObject* to avoid including those headers
un-necessarily. Subsequent diffs ought to clean up the various of
pointers for that with a similar type with reference semantics.

Also:
- Add standard C and C++ headers (mostly cstring for memcpy, string and
vector) where needed.
- Swap out some includes for forward declarations
- Clean up un-necessary boost includes in precompiled and other headers.
- Clean up precompiled headers, including fewer things.
- Move ACPI to the windows-specific folder as it's included there only
and mostly specific to that platform.

Thanks Stan for the testing.

Differential Revision: https://code.wildfiregames.com/D3129
This was SVN commit r24352.
2020-12-09 14:39:14 +00:00
4928508dcd Properly set and get GUI objects' style attribute in JS
This fixes tab buttons not playing sounds when pressed.

Original patch by: Stan
Amended patch reviewed by: Stan

Differential Revision: https://code.wildfiregames.com/D3109
This was SVN commit r24270.
2020-11-27 02:30:42 +00:00
d07f271d60 [SM60 2/2] Update to Spidermonkey 60 APIs
Two noteworthy changes:
- Proxies are update to the SM60 API, having an explicit reserved slot
and a private slot, in which the 'proxy data' and the C++ object are
stored. This fixes a debug assertion failure of SM52 (See bugs 1237504
and 1339411)
- The GC callback behaviour has changed slightly, and we should now only
look for GC_SLICE_BEGIN and GC_SLICE_END calls (Bug 1364547)

Other updates are minor:
- Bug 1339036: JSTYPE_VOID beomes JSTYPE_UNDEFINED
- Bug 1308236 - avoid ambiguous comparison by changing NULL to nullptr
- Bug 1421358, GC::reason::REFRESH_FRAME was removed. API is indicated
in jsapi.h so use that.
- Compartment behaviours update
- ClassOps changes (Bug 1389510 removed the getter/setter - 7c04ea0211 -
and bug 1370608 added one more before that so net minus one)
- Minor tests touchups again.

Tested by: SubitaNeo, Stan
Thanks to bellaz89 for the Shared Array fix

Closes #5859

Differential Revision: https://code.wildfiregames.com/D3116
This was SVN commit r24243.
2020-11-24 15:47:03 +00:00
7c04ea0211 Make JS GUI Objects Proxy objects.
The JS-side counterparts of C++ objects are now Proxy objects, in
anticipation of SM60 changes that remove the get/set hooks entirely.
This makes semantic sense too as they are essentially phantom wrappers
around the C++ objects, with no proper JS representation.

By using different proxy handlers for different GUI object types, we can
further fix issues encountered in D2136 by defining the relevant
functions only on objects that should have them.

The main complexity with proxy handlers is that Spidermonkey assumes in
several places that they are static and data-less, so they cannot be
used directly to hold data. This diff works around that issue by storing
per-script-interface data in the CGui directly.

Further API changes in SM60 make this slightly cleaner.

Comments by: Itms
Refs #5859

Differential Revision: https://code.wildfiregames.com/D2768
This was SVN commit r24229.
2020-11-21 17:49:06 +00:00
935af751b9 Fix building without precompiled headers.
Broken in several recent diffs.
This also fixes (very) old missing standard headers.

Differential Revision: https://code.wildfiregames.com/D3110
This was SVN commit r24200.
2020-11-18 11:35:36 +00:00
bb
768c84aa46 Optimize the GUI event broadcast
Patch By: nani
Differential Revision: D2638
This was SVN commit r24185.
2020-11-14 21:54:17 +00:00
aa15066c69 Rename ScriptRuntime to ScriptContext
SM52 essentially replaces JSRuntime with JSContext (though JSContext
itself was replaced with JSCompartment).
To prepare for this migration, rename all Runtime-related things to
Context.

Part of the SM52 migration, stage: SM45 compatible.

Patch by: Itms
Refs #4893

Differential Revision: https://code.wildfiregames.com/D3091
This was SVN commit r24181.
2020-11-14 10:57:50 +00:00
aae417bd29 Explicitly make ScriptInterface a Compartment wrapper.
ScriptInterface is now a wrapper around a JSCompartment, and thus always
has a well-defined global.

The error reporter is moved to ScriptRuntime in anticipation of that
handling JSContext in a later diff.

Part of the SM52 migration, stage: SM45 compatible.

Patch by: Itms
Tested By: Freagarach
Refs #4893

Differential Revision: https://code.wildfiregames.com/D3090
This was SVN commit r24180.
2020-11-14 08:46:32 +00:00
bb
5cfce692e7 Implement keyDown event
Change HotkeyPress event to be non-repeating (HotkeyDown to replace the
repeating case)
Fix shiftlag
Make toggle hotkeys only respond to the first SDL event.

Many iterations of review by: elexis
Test done by: Imarok
Comments By: vladislav, Stan
Reviewed By: wraitii
Fixes: #5055
Differential Revision: https://code.wildfiregames.com/D1398
This was SVN commit r23701.
2020-05-26 21:47:03 +00:00
ff7ab2fa8f Revert 0916ffbbb1
Summary: Having a mouse event and a hotkey for the same hardware key
turned out to be bad. If the mouse is above a gui element that handles
the middle mouse event and the middle mouse is released, this event will
be consumed by the gui handler of this gui element. Therefore the hotkey
handler does not know that the key was released. If we change that
behaviour typing in input fields would trigger hotkeys. So this seems
unsolvable without adding special handling for the middle mouse case,
which would be ugly.


Fixes: #5695

Differential Revision: https://code.wildfiregames.com/D2700
This was SVN commit r23589.
2020-04-19 12:29:40 +00:00
b4da3388ec Should have waited for the bears
refs D1752
refs 0916ffbbb1

This was SVN commit r23507.
2020-02-17 19:23:42 +00:00
0916ffbbb1 Add GUI events for middle mouse click
Summary: Add gui events for middle mouse click

Differential Revision: https://code.wildfiregames.com/D1752
This was SVN commit r23505.
2020-02-17 18:16:58 +00:00
eafd44cfc5 Remove counterproductive lowercasing of GUI ScriptEvent names, refs #127.
a8f48ff7e0 introduced XeroXMB lowercasing of element and attribute names
as a feature.
cf9d8b9797, 4d390f501c, dda6268466 added bugfixes and TODOs because of
that.
f76d0ffdc6, 44fe226dd2 removed the XeroXMB lowercase feature.
This patch removes the lowercasing GUI bugfixes that don't fix any bug
anymore while increasing code complexity and lowering performance
(string copies).

Do not send mouse coordinates objects for events that do not relate to
the mouse.

Store event names in static const members to:
(1) improve performance, ensuring that the CStr is not reconstructed
every call,
(2) obtain compile errors when misspelling event names,
(3) allow reuse of the strings in inherited and friend classes.

Differential Revision: https://code.wildfiregames.com/D2445
Comments by Matei, Philip on 2006-03-11-QuakeNet-#wfg-Meeting-0126.log
and 2006-06-24-QuakeNet-#wfg-Meeting-0139.log

This was SVN commit r23403.
2020-01-15 16:00:37 +00:00
5d2c20beb0 Replace boost::unordered_map, boost::unordered_set with std::unordered_map, std::unordered_set to establish consistency.
Replace boost::hash_combine with a lib/hash.h hash_combine performing
the same statement.
Replace inconspicuous global boost hash_value specializations with
std::hash specializations.
No performance difference was observed in three simple MeshManager
measurements.

Remove unused TAG_MASK and h_tag in h_mgr.cpp following 0748c5a75e.
Replace typedef with using keyword and sort header includes.

Differential Revision: https://code.wildfiregames.com/D2441
Tested on: clang  9.0.0, gcc 9.2.0, Jenkins/vs2015, Jenkins/gcc6

This was SVN commit r23191.
2019-11-25 14:30:25 +00:00
52f282a7e1 Move CGUI constructor to the top of its file following 5cc814759f.
Move object type definitions to own file, since CGUI doesn't use the
GUIObject types otherwise and for similarity with GUISettingTypes,
making it slightly easier to maintain and read.

Differential Revision: https://code.wildfiregames.com/D2439
Tested on: clang 9.0.0, Jenkins/vs2015, Jenkins/gcc6

This was SVN commit r23184.
2019-11-24 10:26:48 +00:00
197ab42bd2 Remove catch of critical PSERROR_Scripting exceptions in the GUI that is obsolete for the intended case and wrong for the unintended case.
The catch had been introduced in 953fb41c82, seemingly to catch the case
PSERROR_Scripting_LoadFile_OpenFailed from 1e40ed1543 which was removed
in 4b1297b328, refs D2363.
The LoadGlobalScript and LoadGlobalScriptFile functions don't throw
these errors unless that JS code calls broken C++ code throwing that.
In that case catching the error and continuing like nothing happened
leads to subsequent segfaults and similarly severe errors caused by C++,
not XML.

Differential Revision: https://code.wildfiregames.com/D2366
Tested on: clang 9.0.0, gcc 9.2.0, Jenkins/vs2015
Accepted By: nani
This was SVN commit r23068.
2019-10-11 19:30:28 +00:00
a01e68a4ea Don't leak all GUI objects on name ambiguity following 5cc814759f and remove ERROR_GROUP GUI.
Delete CGUI::UpdateObjects and don't recreate the entire object
hierarchy by recursing through the existing one each time when inserting
one GUI Object.
Change CGUI::AddObject to only insert the one relevant pointer into the
map hierarchy, return success value and delete the child upon failed
insertion in the caller instead of leaking it.
Defer GUIM_LOAD and UpdateCachedSize recursion until all XML files
linked in the page XML file were loaded.
Delete related ERROR_TYPE NameAmbiguity, ObjectNeedsName, and unrelated
JSOpenFailed and in consistency with the rest, do the LOGERROR in the
scope where the error occurs.
Delete ERROR_TYPE InvalidSetting from 90f6641c1d unused following
85a622b13a, 1a49ccb294, ERROR_TYPE OperationNeedsGUIObject from
90f6641c1d unused following d3e56f0f57, see also e1014aad3b, refs #128.

This was SVN commit r23067.
2019-10-11 16:20:50 +00:00
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
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
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
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
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
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
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
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
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
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
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