Since C++11 a C typedef'ed union can be forward declared, so the wrapper
is no longer needed.
While at it switch signatures to refs and convert C style casts.
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
This shifts the responsibility of updating the actual size more towards
IGUIObject, and enables only ever doing it when the value is actually
needed. This allows us to remove the delay of size changed
notifications, since the value is now already recalculated as
infrequently as possible anyways.
All of that ensures that the actual size (returned by GetActualSize) is
always up-to-date e.g. when reading it from the parent, which was
previously broken.
Fixes#8200
GetGUIObjectByName was previously made stricter, logging an
error if it doesn't find the target object.
This commit deals with the resulting error-causing (invalid) calls,
by deleting them if they're unnecessary or converting them to the new
TryGetGUIObjectByName (which doesn't log any errors).
It previously failed silently and just returned undefined which would often
only cause errors later on. Printing an error as soon as that happens helps
with debugging, by directly catching typos, for example.
For cases where the queried object may not exist, a new Engine function
called TryGetGUIObjectByName is introduced. It doesn't log any errors
and behaves exactly as GetGUIObjectByName used to.
Make include-what-you-use happy with most of the files in source/gui and
fix what needs to be fixed after including missing compile flags.
Ref: #8086
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
Previously, modifying individual CGUISize properties (left, top, right,
bottom) via JavaScript had no effect unless the entire size object was
copied, modified, and reassigned—resulting in verbose and error-prone
code.
This update introduces proper JavaScript property accessors, enabling
direct reading and writing of CGUISize members. The result is a more
intuitive and scriptable API.
Key Changes:
- Implemented JavaScript get/set accessors for each CGUISize property,
directly interacting with the native object.
- Retained support for string assignments to CGUISize
- Maintained the GUISize JS object for backward compatibility, also
marked as deprecated.
- Improved CGUISimpleSetting<CGUISize> to allow partial updates via
direct property access.
- allow assigning size from object with pixel and percent values
You can now assign size using an object with properties like:
size = {
left: number, right: number, top: number, bottom: number,
rleft: number, rright: number, rtop: number, rbottom: number
}
- One or more properties can be specified, the missing properties with
fill as zero.
- Assignment triggers an immediate update event.
Delayed Setting Notifications:
- Introduced a mechanism for delayed setting notifications, currently
only used in CGUISimpleSetting<CGUISize>, to avoid redundant
recalculations.
- Ensured that getComputedSize triggers any pending delayed
notifications before returning the size.
This change significantly enhances the developer experience and brings
the behavior in line with typical expectations for direct property
manipulation in JavaScript.
This PR introduces a new ScrollPanel component with the following
capabilities:
- Scroll Orientation Support: Allows scrolling in horizontal, vertical,
or both directions, providing flexibility for different use cases.
- Partial Object Rendering: Supports partial rendering of objects that
are only partially visible within the scroll boundaries, improving
visual accuracy and performance.
- Boundary-Constrained Mouse Interaction: Handles mouse events strictly
within the panel's visible boundaries, preventing interaction with
objects outside the scrollable area.
- Minimum Internal Size (min_width, min_height): Introduces support for
virtual space management, allowing the panel to maintain a minimum
internal size independent of its actual on-screen dimensions. Even
when the panel is resized, this ensures that the content respects a
defined virtual space (with min_width and min_height), effectively
simulating a larger internal canvas. This is particularly useful for
large content or scenarios where a more extensive scrollable area is
required than the current visible panel.
`std::shared_ptr` is intrusive. When a function expects a
`std::shared_ptr` the caller has to use it too and can't store the
element on the stack for example.
Comments by: @vladislavbelov
Differential Revision: https://code.wildfiregames.com/D5221
This was SVN commit r28131.
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.
Users sometimes ended up with bad (wrong version) XMB files in the user
mod. This resulted in A25 loading a black screen.
There is a combination of unfortunate code paths that lead to this. The
core issue is that:
- cdd75deafb changed the XMB loading code that if there is an error in
Init from a cached XMB, it reports an error. This error happens to be
silent, because the GUI expects CXeromyces to do its own error reporting
(a pretty poor decision, all in all, but whatever). This explained why
the black screen showed no errors.
- The code flow attemps to load an 'archive' XMB first, then only a
loose cache. _But_ if the XMB that fails to load is an archive (which
generally never happens except when using incompatible mods, which is
generally less easy in A25 since we added code to stop that), then the
game will try to recreate the XMB as an 'archived' path, not a 'loose
cache' path as it would usually do.
- Because the 'archived' path already exists in the VFS, the game will
attempt to overwrite that. It so happens that in non-dev copies, this
writes to the user mod.
- Because the user-mod is always loaded, this was unexpected for users.
Fixing this is rather simple: the game should never attempt to write
'archive' XMBs in that function. Added explicit barrier, which shouldn't
matter performance-wise but fixes the issue by writing in the proper
place, and also properly recovering in case of read failure.
I will note that the game will still try to load the archived file, and
recreate it every time, but I don't think that's a particularly big
deal, in general having engine-incompatible mods in the future should be
harder because of A25 changes there.
(NB: users that have used both A24 and A25 should perhaps still be
advised to check their user mod folder, otherwise they'll end up
recreating those files forever).
Reported by: dave_k
Fixes#6320
Differential Revision: https://code.wildfiregames.com/D4275
This was SVN commit r26272.
Use dropdown with values. Implement confirmation box with countdown to
revert scale change because buttons can get unable to click.
Differential revision: D3037
Comments by: @vladislavbelov, @Stan, @wraitii, @pieq, @sera
Tested by: @Langbart
This was SVN commit r25966.
The structTree, in case of errors, could have enough items to draw to
trigger an OOM failure in the Arena allocator.
This fixes that by hiding elements by default and some c++ memory
optimisation (mostly, this should make all platforms take the same
memory footprint for VisibleObject).
Discussed with vladislavbelov and s0600204
Differential Revision: https://code.wildfiregames.com/D4114
This was SVN commit r25746.
Completes work starting in D2313 / a33fd55e81:
- Make C++ mistakes where values can be changed without messages being
sent easier to notice / harder to do.
- Make the IGUISetting interface more flexible, allowing custom settings
implementing their own logic. This is used to clean up hotkey code
introduced in 33af6da5e1.
Side effects:
- FromJSVal_Vector clears the vector being passed in. I have some vague
memory of not doing that in D24 / 2bae30c454 as an optimisation, but it
seems more like a footgun to me.
- Most usage of SetSettingFromString is replaced by direct method calls,
as we can generally cast to the proper GUI object type. Where we can't,
it is kept as a poor's man virtual dispatch.
- It moves a few member variables elsewhere, e.g. TextOwner now gets its
own member variable settings.
Differential Revision: https://code.wildfiregames.com/D3892
This was SVN commit r25392.
- 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.
XMB format is bumped to 4, invalidating all cached files. The
differences are:
- element/attribute names are stored after the elements themselves, and
not before. This allows writing XMB data in one pass instead of two.
- names themselves becomes offsets (instead of arbitrary integers),
making getting the string from the int name much more efficient.
XMBFile is renamed to XMBData to clarify that it does not, in fact,
refer to a file on disk.
XMBData::GetElementString is also changed to return a const char*, thus
not creating an std::string. A string_view version is added where
convenient.
The XML->XMB and JS->XMB conversion functions and the corresponding
storage are moved to `ps/XMB`, since that format doesn't particularly
relate to XML. CXeromyces becomes lighter and more focused as a result.
The XML->XMB conversion also benefits from the above streamlining.
Note that in a few cases, string_view gets printed to CLogger via
data(), which is generally not legal, but we know that the strings are
null-terminated here. Our libfmt (version 4) doesn't support
string_view, that would be v5.
Differential Revision: https://code.wildfiregames.com/D3909
This was SVN commit r25375.