Commit graph

47 commits

Author SHA1 Message Date
phosit
582541ea80 Enable eslint rule 'no-useless-assignment'
Enable rule 'no-useless-assignment' [1] and fix violations.

[1] https://eslint.org/docs/latest/rules/no-useless-assignment
2025-08-01 11:26:40 +02:00
trompetin17
01d2481f55
Fix Structure Tree misplaced phase icons
Refs: #8188
2025-07-17 09:45:35 -05:00
trompetin17
b42a2b9adb
Apply correct use of TextSize APIs in GUI
Updates GUI code to apply the correct usage of `guiObject.getTextSize()`
and `guiObject.GetPreferedTextSize()`.

- `guiObject.getPreferedTextSize()` is now used when the goal is to compute the
  bounding box of a text string to dynamically resize or layout a GUI
  object accordingly. It simulates how the text would be rendered,
  accounting for markup and layout rules.

- `guiObject.getTextSize()` remains in use when text is being measured
  within a fixed-size GUI element (e.g., a button or label). It respects
  internal constraints like buffer zone and maxWidth, and is typically
  used to align other elements based on its visual appearance.

These changes ensure more accurate text sizing and consistent layout
behavior across GUI components.
2025-06-26 17:11:24 -05:00
Vantha
fd847c2a23
Refactor GUI object resizing JS code passages
It is possible to modify sizes by setting the properties directly.
(Without having to create a copy of it)
This allows to shorten those passages quite a bit without any functional change.
2025-06-17 12:57:37 -05:00
Dunedan
58a58bc25d
Improve layout of the civ and structree pages
This contains some small layout fixes and improvements for the
civilization overview and structure tree pages. Some of these fixes have
fix regressions introduced with 37065ebc71.
2025-05-17 18:54:12 +02:00
Ralph Sennhauser
93668e8447
Fix eslint rule 'prefer-const' in gui/reference
eslint --no-config-lookup --fix --rule '"prefer-const": 1' \
    binaries/data/mods/public/gui/reference

Ref: #7812
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-05-10 18:40:28 +02:00
Ralph Sennhauser
81c119bf39
Fix eslint rule 'semi'
eslint --no-config-lookup --fix --rule '"semi": 1'

Ref: #7812
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-05-03 14:13:14 +02:00
Ralph Sennhauser
ddba1ceabd
Fix eslint rule 'no-extra-semi'
eslint --no-config-lookup --fix --rule '"no-extra-semi": 1'

Ref: #7812
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-05-03 11:18:16 +02:00
Ralph Sennhauser
b6df170303
Fix eslint indent rule
eslint --no-config-lookup --fix --rule 'indent:  ["warn", "tab", { "outerIIFEBody": 0, }]'

Ref: #7812
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-05-03 09:39:58 +02:00
phosit
df5fee6103 Rename PushGuiPage to OpenChildPage
There is no `PopGuiPage` anymore. For symmetry there should also be no
`PushGuiPage`.
2025-03-09 10:39:20 +01:00
phosit
094a7c2268 Return a promise from most page-inits
Adopt the new interface by all pages which close themself. (Not thous
using `Engine.SwitchGuiPage`.)
2025-03-09 10:39:20 +01:00
Sanctorum Thomas
37065ebc71 Harmonized design between civinfo and structree 2025-02-16 09:10:16 +01:00
Dunedan
c7b6b5147f
Improve spacing in the structure tree window 2025-01-11 17:45:32 +01:00
Dunedan
33e9cd6126
Increase height of StoneButtons and TabButtons
This increases the height StoneButtons and TabButtons, so that a
double-spaced caption does fit on them without significant overflow.
Exempt from that are the StoneButtons resembling lists in the main menu
and the in-game menu, as changing their height didn't feel right and we
don't need double-spaced captions for them anyway, as they're wide
enough.

The height of StoneButtons got increased from 28px to 32px, while the
height of TabButtons got increased from 30px to 34px.
2025-01-03 16:33:51 +01:00
Vantha
33111dc816 Fix phase names not updating on the structure tree
Reload all cached phase data when switching civ.
Add missing query for the generic phase technologies to the phase idents.
2024-12-29 22:21:28 +01:00
Itms
62f67f5870
Match structree size with civ overview
Refs #7316
2024-12-21 14:36:19 +01:00
trompetin17
c843ee3c24
Scrollpanel: Structure Tree 2024-11-12 15:01:43 -05:00
abian
798cff1f6f Left-click the portrait to follow the entity
- Left-clicking the portrait of a unit will make the camera follow that
   unit (before: no action). A tooltip informs the player of this
   possibility.

 - Left-clicking the portrait of a structure will make the camera focus on
   that structure (before: no action). A tooltip informs the player of
   this possibility.

 - Double-clicking a hero/treasure icon will make the camera follow that
   hero/treasure (before: just focus on that hero/treasure).

 - Some minor related changes.

Fixes #6879
2024-09-18 06:46:51 +02:00
phosit
660fdfac44 Use pageLoop for structree and civinfo
Deduplicate code in four places.

Comments by: @elexis
Differential Revision: https://code.wildfiregames.com/D5261
This was SVN commit r28085.
2024-05-10 13:16:52 +00:00
Freagarach
eae5840b0e Fix structure tree/civinfo with empty civ history.
Since the history string is optional, don't fail without it.

Based on a patch by: @Silier
Fixes #6651

This was SVN commit r27427.
2023-01-12 10:34:53 +00:00
s0600204
06672206d4 (Re)display phase idents in Structure Tree
They were all set to hidden-by-default as part of b7ff371d00, only there
wasn't anything to tell them to unhide when we actually want them. This
commit
fixes that.


Differential Revision: https://code.wildfiregames.com/D4114
This was SVN commit r25750.
2021-06-08 23:20:39 +00:00
wraitii
b7ff371d00 Prevent OOM crash in Reference Tree on error
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.
2021-06-08 14:57:59 +00:00
Freagarach
ebc2ec5498 Give option to switch between specific and/or generic entity names.
As requested on the forums (e.g.
https://wildfiregames.com/forum/index.php?/topic/25202-transliteration-of-ancient-greek-into-english/&tab=comments#comment-378174).

Differential revision: D2126
Closes: #3397

This was SVN commit r25116.
2021-03-25 06:58:47 +00:00
Angen
1432343eeb Fix upgrades not being sorted by phase in structuretree
Currenlty there is regression in structuretree from b2842e8021, when
upgrade for sentry tower is not in the correct phase row.
Thix is fixing that.
Probably typo in condition.

Differential Revision: D3252
Reviewed by: bb
This was SVN commit r24461.
2020-12-27 15:47:30 +00:00
bb
3ff65b451f Fix jsDocs object => Object
This was SVN commit r23991.
2020-08-24 11:01:25 +00:00
s0600204
a4bc787ddc Don't have the Structure Tree fill up the entire screen
For those lucky enough to have screens with a high enough resolution to
display
a chosen civilisation's tree in its entirety, the Structure Tree page
now
determines the minimum space necessary to do so, and sizes itself
accordingly.
(e.g. The page no longer scales to fill the entire screen.)

For those on lower resolution screens, the page now takes up slightly
less space
vertically.

This was SVN commit r23813.
2020-07-11 02:50:32 +00:00
s0600204
b2842e8021 Rewrite Structure Tree and Template Viewer to use OOP principles
Commenters: elexis, Stan, Angen
Refs.: #5387
Differential Revision: https://code.wildfiregames.com/D2734
This was SVN commit r23808.
2020-07-07 19:11:36 +00:00
s0600204
40f77d0f0f Rename civinfo page from "History" to "Civilization Overview"
Patch by: Nescio
Accepted by: s0600204
Differential Revision: https://code.wildfiregames.com/D2722
This was SVN commit r23671.
2020-05-15 21:27:35 +00:00
Gallaecio
9b9410c923 [gui] building → structure
This patch corrects occurrences of “building” into “structure”.
Whilst “constructing a building” is proper English, it is important to
refer to one and the same thing with a single term, to avoid potential
misunderstandings (see
https://trac.wildfiregames.com/wiki/EnglishStyleGuide ), thence
“building a structure”, because the unit action is “build” and the
entity is a “structure” (see `simulation/templates/`).

Patch By: Nescio
Reviewed By: Gallaecio
Differential Revision: https://code.wildfiregames.com/D2429
This was SVN commit r23366.
2020-01-11 10:58:43 +00:00
elexis
702cdbf0c7 Remove GUI object setting values z="0", size="0 0 100% 100%", hidden="false" in XML page specifications that are redundant with the default style values.
Remove question by brian in single_details_area.xml from b66d1716e7
which is answered by "because the style set it".
Delete BuildNameText style, because it specifies ghost="true" in both
style and sole object using the style.
Don't touch progressbar and structree styles, because there is more to
clean.

Differential Revision: https://code.wildfiregames.com/D2292
This was SVN commit r22957.
2019-09-21 15:54:25 +00:00
elexis
be963ec9b7 Delete 27 invalid style settings and add LOGWARNING to inform future authors.
Unify the two IGUIObject::LoadStyle functions and remove CGUI argument
that is always identical to the member.

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

This was SVN commit r22792.
2019-08-27 16:03:24 +00:00
elexis
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
elexis
e370c509a6 Small closePage() cleanup for D1684.
Rename close() to closePage() for structree / template viewer / civ info
for global consistency.
Remove a splashscreen proxy and move splashscreen closing from XML to
closePage() in JS.

This was SVN commit r22669.
2019-08-15 13:29:11 +00:00
Itms
e84e712801 Enlarge some GUI elements in order to display correctly the majority of strings for the bundled languages.
This was SVN commit r21804.
2018-04-29 14:34:10 +00:00
elexis
db07c11216 Maximize civ selection dropdown size in the gamesetup, i.e increase the size by 3 more civs.
Further increasing the size for mods was neglected in d6c028923e / D527
and
Delenda Est had a copy of gamesetup.xml to extend the size already.

This was SVN commit r21353.
2018-02-24 12:19:47 +00:00
s0600204
760a47335d Add buttons for changing between, and hotkeys for opening, the civinfo and structree
Patch by: fpre
Reviewed By: s0600204
Fixes: #4970
Differential Revision: https://code.wildfiregames.com/D846
This was SVN commit r21339.
2018-02-23 20:54:28 +00:00
s0600204
c8fda40b02 Implement an in-game Template Details Viewer
Right-click on icons of units, structures, technologies, flora, fauna,
etc. and view additional details.


Reviewed By: elexis
Fixes: #3212
Differential Revision: https://code.wildfiregames.com/D297
This was SVN commit r21310.
2018-02-21 21:39:00 +00:00
s0600204
9501292661 Merge the structree's loadUnit and loadStructure functions
The resultant function should be able to handle any (selectable) entity
template.

This was SVN commit r21174.
2018-02-11 04:09:28 +00:00
elexis
c53adeaaa6 Unify structree production queue loading duplication.
Differential Revision: https://code.wildfiregames.com/D1192
Reviewed By: s0600204
This was SVN commit r21022.
2018-01-26 22:18:35 +00:00
s0600204
f6b5488a24 Move unravelPhases function from structree to globalscripts for use in AI init.
Reviewed By: mimo
Differential Revision: https://code.wildfiregames.com/D1183
This was SVN commit r20750.
2018-01-02 06:38:09 +00:00
s0600204
00b05fd9f7 Use phase techs to determine phase order in structure tree.
(Instead of non-phase techs which is what it was using up to now.)


Reviewed/accepted by: mimo
Changes agreed (but not tested/formally proven) by: elexis

Differential Revision: https://code.wildfiregames.com/D1181
This was SVN commit r20749.
2018-01-02 06:23:33 +00:00
elexis
9950e06d4c Include entire directories in GUI pages instead of a subset of the files contained, where possible.
This allows mods to add new JS files without introducing a hardly
maintainable copy of the XML file.

Differential Revision: https://code.wildfiregames.com/D619
Proofread By: bb
This was SVN commit r20535.
2017-11-27 16:29:23 +00:00
elexis
89055ef858 Delete GetCivData from MapGeneratorWorker.cpp which is redundant with the ReadJSONFile from 871ed04521.
Unify civ file loading from gui/common/functions_civinfo.js and
rmgen/library.js in globalscripts/Templates.js.
Delete the two forgotton headers in 4275a8a33c.

Refs #4868, #4804, D900.
Differential Revision: https://code.wildfiregames.com/D1062
Discussed with: leper

This was SVN commit r20528.
2017-11-26 13:30:57 +00:00
elexis
3c73b329f2 JS cleanup.
Mark global consts as variable if mods can legitimately modify them.
Keep global objects const if mods should insert their modifications at a
different place, refs D829.
Mark the few consts inside function scope as let or var for consistency.
Don't touch the AI, simulation test and rmgen folder.
Change some var to let.
Remove an unused variable in the mainmenu and summary screen.
Inline few variables.

This was SVN commit r20047.
2017-08-26 20:10:39 +00:00
elexis
b5ea27904d JS GUI cleanup.
Mark g_CivData as const and don't use optional arguments at loadCivData.
Translate the infinity symbol in the summary screen.

Refs D829
Reviewed By: s0600204
This was SVN commit r20043.
2017-08-26 18:53:37 +00:00
elexis
c4cef0d289 Don't write two helper variables to g_CivInfo in the structure tree,
so that the object has the same content throughout the entire GUI and
can be marked read-only.

Refs D829
Reviewed by: s0600204
This was SVN commit r20042.
2017-08-26 17:57:11 +00:00
s0600204
cdf6109713 Relocate and Rearrange the structree codebase
Makes it possible to reuse the more generic parts of the `structree`
codebase in other pages without including `structree`-specific logic.
This sets the stage for further reference/encyclopedia-type pages.

Reviewed By: fatherbushido, elexis
Differential Revision: https://code.wildfiregames.com/D295
This was SVN commit r19940.
2017-07-31 12:49:00 +00:00