Commit Graph

25856 Commits

Author SHA1 Message Date
Ralph Sennhauser df06b6895e Don't mix static and dynamic events
Commit 309ed5ef28 used dynamic events
which prevents some other menu items from working properly. So don't mix
static and dynamic events for top window.

Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2026-07-25 14:05:38 +02:00
phosit a80446eb59 Use the profiler to profile map generation
Instead of writing the duration to the console it uses
`Engine.ProfileStart` and `Engine.ProfileStop` to profile map
generation.

Refs: #5263
2026-07-25 10:47:49 +02:00
phosit 4122f0bfb3 Use atomic instead of COMPILER_FENCE for Profiler2 2026-07-24 17:22:44 +02:00
Ralph Sennhauser aae1bbbab2 Use new WX object macro
Added in 2010.

Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2026-07-24 16:51:58 +02:00
Ralph Sennhauser 8523fa5ab4 Fix Atlas build on macOS Tahoe
Bump wxWidgets, the upstream fix was backported to 3.2.9 with commit
a6fc33b416e2ebc804d80a1ac66021935c434573

Fixes: #8594
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2026-07-24 13:14:34 +02:00
phosit 8b1e78ae1e Use JS classes for the AI
Fixes: #6285
2026-07-23 15:15:59 +02:00
phosit 09671b49a2 Use JS classes for QueuePlan
Classes derifed from `QueuePlan` used manual inherintance.

Refs: #6285
2026-07-23 15:12:50 +02:00
phosit 327e70ea82 Use JS classes for Template and Entity
`Template` and `Entity` used a costum form of inheritance.

Refs: #6285
2026-07-23 15:12:50 +02:00
phosit f9de339f85 Use JS classes for Terain-Analysis and InfoMap
`TerrainAnalysis` and `Accessibility` used a costum form of inheritance.

Refs: #6285
2026-07-23 15:12:50 +02:00
phosit ea1026a1cc Define the terrain states in a dedicated file 2026-07-23 15:12:49 +02:00
Vantha 2520c45220 Only call Engine.EndGame right before closing
Since #7786, the GUI tick completed normally after calling
`closePageCallback` instead of being cancelled like previously. Since
`Engine.EndGame` deletes the internal `g_Game` pointer, every Engine call
after it that tried to access `g_Game` caused a segfault.
This patch solves it by moving `Engine.EndGame` to the very end, right
before closing the session page.
In order to follow the convention that only functions directly closing
the page are called `closePageCallback`, that function is in turn
renamed to `closeSession`. Additionally, this allows only resolving
the promise with a bool (`showSummary`) and then only calling
`getNextPageOpenRequest` at the end of `init` for reasons of simplicity.
2026-07-22 23:51:49 +02:00
Vantha 801d21671e Correct hotkey names in Economy Walkthrough
The queue hotkey is called "session.queue", not "selection.queue"

Fixes #8939
2026-07-22 23:51:49 +02:00
Vantha 931c132b1b Fix brief text misalignment in GUI text objects
The issue was introduced by 8a2a450686.
It affected GUI text objects (CText) with `scrollbar` set to true; when
their caption was long enough for a scrollbar to be visible and then the
size changed (got bigger) so that no scrollbar was needed anymore, then
for a single frame the text was completely misaligned. This happened
because in `CText::Draw` the scrollbar wasn't updated yet, so the newly
added `GetScrollBar(0).IsVisible()` check still returned true, even
though it wouldn't end up being rendered anyway -- it was updated in
`IGUITextOwner::DrawText` eventually.

This happened to the tutorial info panel in the starting economy
walkthrough, for example. Note: in that case the scrollbar wasn't ever
drawn, but it was temporarily set visible within a frame by the JS
object resizing logic.
2026-07-22 23:51:49 +02:00
Vantha 6ed963b94c Don't check all scrollbars' visibility in CText
The CText class is designed to only work with one scrollbar, so the
any_of was pointless.
2026-07-22 23:51:49 +02:00
Vantha a784659158 Two adjustments to the Introductory Tutorial
This patch splits the steps that said "Wait for X and then do Y" into
two different steps "Wait for X" and "Do Y".
2026-07-22 23:51:49 +02:00
Vantha 52b40aaa4f Add a tutorial panel for explaining the GUI
This patch adds a new type of tutorial steps called "GUI explanation",
with a corresponding GUI panel. The purpose of it is to explain what a
certain GUI element does. To make use of it the trigger script has to
specify the target GUI object's name as well as the side on which to
place the explanation panel relative to the target itself. The panel
then highlights the target object by fading everything else out with
black and also uses an arrow to point to it. Whilever the target GUI
object is hidden, the panel hides the background fade too and shows a
warning message.
Unlike for the other steps, the TutorialManager does not hide the
previously active panel when showing a GUI explanation, but instead
only disables it, since it could contain relevant information and the
GUI explanation panel is visibly placed "above" all other panels (in the
Z axis).
2026-07-22 23:51:49 +02:00
Vantha 27fbf02ff4 Improve the ending of tutorials
This patch introduces two functions `CompleteTutorial` and
`FailTutorial` for the tutorial steps to call. They can pass a
message to it to be shown on the victory/defeat screen.
`CompleteTutorial` is also called automatically when all steps are
finished, which resolves #8583 and prevents it from happening in the
future.
`FailTutorial` isn't used anywhere at the moment, but it'll be useful
for the future.

Fixes #8583
2026-07-22 23:51:49 +02:00
Vantha f1a9c503b8 Support custom hint & button captions in the tutorial
This patch allows steps to override the default hint caption and button
caption set by the PanelControlSection class. This allows them to better
communicate what the player is supposed to do, e.g. don't show "Follow
the instructions" if the player is only supposed to wait.
2026-07-22 23:51:49 +02:00
Vantha f39e71cca0 Move calls in playersFinished to handlers
This patch fixes the TODO comment in playersFinished and moves
all of the calls to handlers. The only reason for adding back the
function `handlePlayersFinished` is to prevent duplication in the "won"
and "defeated" message handlers. In the future, code to execute when
players finish in the future should exclusively be added by registering
new handlers, not by adding it to that function.
2026-07-22 23:51:49 +02:00
Vantha 6456bccebe Replace old GetState and SetState calls
966727b52e made the player state an enum and introduced more descriptive
functions to achieve the same thing, but it seems they were forgotten to
be replaced in a few places, which this patch fixes.
2026-07-22 23:51:49 +02:00
Vantha 0cc025f675 Indicate if a tutorial step is already done
If a new tutorial step has already been completed by the player it isn't
skipped, but instead shown with the continue button, so that the player
can manually switch to the next one. However, it wasn't well
communicated to the player that this was the case and why the continue
button was shown at the same time as the instruction. This patch adds a
hint "You have already done this." to explain the this to the player.
2026-07-22 23:51:49 +02:00
Vantha 05d434830f Add hotloading support to the tutorial UI 2026-07-22 23:51:49 +02:00
Vantha 2522c305dd Allow defining tutorial steps more compactly
This allows the trigger scripts to combine consecutive tutorial steps
that only differ in the `panelData.text` property into a single one that
instead defines a `panelData.texts` array.
2026-07-22 23:51:49 +02:00
Vantha 7e77065c56 Add an info panel to the tutorial
This patch adds a new tutorial step type and corresponding tutorial
panel labelled "info". It is intended to display steps whose purpose it
is to explain something to the player and give tips -- rather than
just giving instructions and telling the player what to do, like the
instruction panel does.
Also, it can show several related steps at once. To do that, the first
step has to set the 'appendable' flag to true and can also define a
title; then the succeeding steps can then set the 'appendToPrevious'
flag to true in order to do exactly that.
Note: 'info'-type tutorial steps are still supposed to be able to define
triggers, switch to the next step on their own and hide the continue
button on the info panel, to teach the topic interactively, e.g.
"Select a unit by left-clicking on it."

In order to prevent code duplication between `InfoPanel` and
`InstructionPanel` a generic superclass `TutorialPanel` is introduced,
which manages the text, hint, and button objects.
2026-07-22 23:51:49 +02:00
Vantha 6dd8139b43 Only show the last instruction in the tutorial
The idea is to add different types of panels to the tutorial in the
future. And the only texts that players might read multiple times are
tips or explanations, which the plan is to display on an entirely
separate panel anyway.
2026-07-22 23:51:49 +02:00
Vantha c2c8f5bdf2 Remove pointless trainingDone from tutorial
In `Init` it was always overwritten to false, so `IsDone` always returned
false anyway.
2026-07-22 23:51:49 +02:00
Vantha 1f7d384c29 Fix player command handling in the tutorial
Move the code that checks whether a player command is a "continue
tutorial" into a separate method, so that it never overrides the player
command action of the active tutorial step. This could previously
happen if a step had the showContinueButton flag was set to true (and
a OnPlayerCommand method defined).
2026-07-22 23:51:49 +02:00
Vantha 2f27dcc97d Rename index to stepIndex in Tutorial.js
Makes it more clear what it is an index of.
2026-07-22 23:51:49 +02:00
Vantha 6e6864fd7c Improve internal naming of tutorial triggers
Make the naming consistent with e.g. the Triggers Demo map
Remove the "On" at the start, since it's otherwise used for message
handlers, and replace "Trigger" at the end with "Action", since that
more accurately describes what it is.
2026-07-22 23:51:49 +02:00
Vantha 702e3f1113 Revise tutorial step handling
- Remove the delay functionality from the tutorial. It was unused and
  that for a reason. Switching to the next step after a fixed amount of
  time is never wanted. It was only used to force-show the ready button
  in one case, but a designated bool communicates the purpose better.
- Rename the "ready" button to "continue" as it fits better.
- Rename "leave" to "isLast" as it's more descriptive.
- Rename the "warning" object of the instruction panel to "hint" as it's
  not always display warnings, and move its captions to the class
  prototype like the coding conventions state.
- Simplify the logic in NextStep a bit to make it more readable.
2026-07-22 23:51:49 +02:00
Vantha f3b71a1fbf Remove unused this.fullText from the tutorial 2026-07-22 23:51:49 +02:00
Vantha e02a2e0b31 Add support for different types of tutorial steps
This patch doesn't add any new functionality and keeps the introductory
tutorial and economy walkthrough as they are. Instead, it rearranges some
code to enable easily adding different types of tutorial steps in the
future. The idea is for each type to be displayed on a different panel
and for the TutorialManager to switch back and forth between them, and
to handle and translate the received messages from the simulation and
pass them along to the active panel. Currently, there are only
"instruction"-type steps, which are handled by the InstructionPanel in
the GUI. But new ones can be added in the future, like information boxes
or bigger objectives.
2026-07-22 23:51:49 +02:00
Vantha ab4a9d6def Rename tutorial "goals" to "steps"
While it's currently the case everywhere, tutorial "steps" don't
necessarily have to be goals, they could be stuff like tips or info too
in general, if different types of "steps" are added in the future.
2026-07-22 23:51:49 +02:00
Vantha dd396f19b6 Separate handling of tutorial goals and warnings
This is more explicit and makes the code cleaner.
2026-07-22 23:51:49 +02:00
Vantha ca8a0a5611 Move "TutorialPanel" style to session styles
It's not used anywhere else besides there, so that where it belongs.
2026-07-22 23:51:49 +02:00
Vantha 663f5c5ff6 Create designated tutorial class in the GUI
This keeps messags.js shorter, prevents unnecessary GetGUIObjectByName
calls and, most importantly, makes it a lot more extensible for the
future.
2026-07-22 23:51:49 +02:00
Vantha 0e6e0280fc Prevent segfault in CMiniMap::Tick
Oversight in 01476b9836
For example, it could cause a segfault when rendering a frame after
EndGame was called therefore g_Game already deleted.
2026-07-22 23:51:49 +02:00
Ralph Sennhauser adfe6b0c36 Convert wxString using ToStdWstring
Avoid using c-style cast to convert wxString to std::wstring.

Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2026-07-22 16:49:41 +02:00
Ralph Sennhauser eae57d9aab Fix clang-tidy modernize-avoid-bind check
And enable the check in the config.

Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2026-07-21 17:15:07 +02:00
Ralph Sennhauser 91a4b834a8 Add clang-tidy linting script
Add groups we might be interested in and disable failing checks.

Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2026-07-21 17:15:07 +02:00
phosit 9598c6c2e1 Only clone this.position when it's an object
Refs: #8951
2026-07-19 13:01:04 +02:00
phosit e6f75f2c33 Fix displaying errors of map generation scripts
Displaying the error lead to a freeze.

Introduced in d842a134f9.
2026-07-19 11:17:35 +02:00
Ralph Sennhauser 6244d25f90 Don't generate SDL events on Atlas shutdown
WX may still generate mouse events after calling CVideoMode::Shutdown(),
so don't create SDL events triggering assertions.

Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2026-07-19 08:59:06 +02:00
Ralph Sennhauser 63629195ba Wait for work to be finished before shutting down
Stopping the timers isn't sufficient, also wait for in-flight work to be
finished first.

Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2026-07-19 08:59:06 +02:00
Ralph Sennhauser 2fae39df3b Use new WX event macros
Were added in 2010.

Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2026-07-18 13:32:23 +02:00
Ralph Sennhauser f1181bada0 Don't install SDL default signal handler for Atlas
If we catch the signal we'd have to communicate that we terminated by
signal, which might depend on shell. There is also the issue of various
dialogs blocking regular quit which we don't want, so that would need
extra work as well.

As such just let the SIGINT/SIGTERM do there default action and forgo
cleanup and let the OS handle it.

Fixes: #198
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2026-07-18 11:50:31 +02:00
Ralph Sennhauser 309ed5ef28 Add fullscreen support to Atlas
Add a fullscreen toggle to the View menu and with a global hotkey,
reusing the default one from the main game.

Unlike the current implementation this one doesn't need the game canvas
to be focused and also works on GTK.

Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2026-07-18 11:33:17 +02:00
Ralph Sennhauser 3c8b7dfa7a Fix Enter key behaviour on Windows
Commit fe192fe58f made it possible for
events to properly propagate to the top window. As on Windows Enter is
also used for navigation, i.e. used to trigger the dialogs default action,
which in our case seems to be quit.

Tell the wxSpinCtrl to fire wxEVT_TEXT_ENTER instead and handle it.

The wxCommandEvent wxEVT_TEXT_ENTER doesn't carry the value, so need to
use dynamic event binding (which is preferred way anyway).

Also show the numPlayerSpinner as a spinner instead of a text field to
match visuals to actual behaviour.

Fixes: #9026
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2026-07-18 11:24:36 +02:00
Ralph Sennhauser 32b9713781 Modernize Brush in Atlas
Use dynamic event bindings allowing to bind all events in all sort of
ways. Addionally no need for subclassing wx widgets.

Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2026-07-18 11:24:36 +02:00
Vladislav Belov 7ee476928b Fixes missing window preview on Alt+Tab
There was a crash on Alt+Tab in fullscreen for some specific driver:

https://code.wildfiregames.com/D1212

It was related only to post processing so it's time to try to enable
rendering again (but with provided option to disable it). Also without
rendering we might have some bugs in other components. See:

https://github.com/libsdl-org/SDL/issues/5033#issuecomment-981819661

The issue is reported here (first one):

https://wildfiregames.com/forum/topic/129061-two-vulkan-issues-in-a27-and-unrelated-choppiness-caused-by-control-groups/
2026-07-14 19:54:00 +02:00