191 Commits

Author SHA1 Message Date
Charles Dang
f3f6acf74b Game Launcher: removed CVideo getter 2020-12-19 11:15:19 +11:00
Charles Dang
1ba2b7e823 SP: cleaned up code a bit 2020-12-19 10:33:32 +11:00
Charles Dang
add1fd9fa3 Removed second argument from game_launcher ctor
This seems to be a relic from the time when the editor was a separate executable
2020-12-18 13:40:36 +11:00
Charles Dang
1507bec710 Game Launcher: code formatting 2020-12-18 07:53:00 +11:00
Charles Dang
3ae339bf31 GUI2/Preferences Dialog: removed now-unused game config ctor argument 2020-12-14 06:03:59 +11:00
Charles Dang
ccd006cccd Refactored handling of advanced preferences
Instead of having the preferences dialog make a copy of all advanced preference config objects (and sorting them)
every time you invoke it, this adds a new advanced_manager class instantiated once in game_launcher (not sure if
that's the best place for it, though) that parses and handles the options. Allows me to greatly clean up the
preferences dialog code.
2020-12-14 05:56:52 +11:00
Charles Dang
99188ee077 Removed game_config parameter from start_local_game_commandline 2020-12-11 20:10:12 +11:00
Charles Dang
52f447dc52 MP: cleaned up mp workflow code 2020-10-10 16:57:43 +11:00
Charles Dang
c3e578ba80 Repurposed Outro dialog for campaign-specific credits 2020-10-04 23:21:33 +11:00
Charles Dang
791021f25e GUI2/Outro: pass in game_classification reference 2020-10-04 20:02:17 +11:00
gfgtdf
5b5a60d0c4 fix 'unable to find scenario id' error
get_scenario_id() cannot be queried from state_ if
state was not set before
2020-08-26 16:00:29 +02:00
gfgtdf
5759404121 disable unused addons during a game
Now, during an active game, (that is: not during
campaign selection for example) the engine hides
all toplevel tags from addons that are not
involved in the current game. 'involved' here
means providing one of the [campaign], [scenario],
[era], [multiplayer], [modification] or [resource]
tags that are active in the current game.

Fixes #4832
2020-06-29 15:16:05 +02:00
gfgtdf
0efd35acbc move active_mods and mp_era to game_classification
in particular because active_mod is no longer mp specific, but
also for technical reasons
2020-06-29 15:16:05 +02:00
Pentarctagon
c394353d48 Append the timestamp to the save/replay file name.
Also fixes the unit tests to be able to find the replay since hard-coding the expected replay name will no longer work.

Fixes #4730
2020-05-27 13:08:54 -05:00
Pentarctagon
9a0b95f9a0 Separate unit test results from scenario victory/defeat.
This adds an additional `test_result` attribute to [endlevel], intended for use with the automated unit tests. This allows for the unit tests to differentiate a pass/fail result separately from scenario victory or defeat, which allows for more accurately determining the outcome of a test as well as addresses the potential, for example, for a scenario to be expect to pass because of the {SUCCEED} macro but instead passes because the scenario ended as a victory through some other method.

Additional unit tests which were the original motivation for this change are also added as part of this.  They test, as much as possible, that events are executed at all, and are then also executed in the expected order.
2020-04-07 16:45:34 -05:00
Steve Cotton
7359fddecb
Separate unit test statuses for WML exceptions and strict warnings (#4599)
This is part of working out whether a subset of the "fail" tests could be run
in one Wesnoth instance. To run a test that returns TEST_FAIL_BROKE_STRICT with
any other test would require a mechanism to reset lg::broke_strict()'s flag.

All tests that fail with an {ASSERT} will also set the lg::broke_strict() flag,
the tests with the new status are only those that would pass without the strict
flag.

In the SUF tests, change a test from fail-on-success to breaks-strict, rename
the formula tests and add some comments. The rename is because "fai" is
"Formula AI", an obsolete name for WFL.
2019-12-22 19:11:48 +01:00
Steve Cotton
63bb076b97
Support running multiple expected-to-pass unit tests (#4582)
This allows batching all of the tests that are expected to return status zero,
which is currently 161 tests, and running the batch with a single instance of
Wesnoth.  It doesn't include the changes to the run_wml_tests script to use
this new feature.

Timing on my PC:
* 4 seconds to run a single test on a debug build
* 90 seconds to run the whole batch of 161 on a debug build
* 1.2 seconds to run a single test on a release build
* 31.2 seconds to run the whole batch of 161 on a release build
2019-11-22 23:14:53 +01:00
Iris Morelle
f136bb9ef3 gui2/mp_connect: Overhaul dialog adding a more powerful server list
There has been functionality to manage custom servers in the player's
preferences file since as far back as commit
5fb0b2a91123474d147c9de4918fc11a1b4c15ac in June 2007, but there's never
been a user interface for it.

This commit removes the current server list dialog attached to the MP
Connect dialog and replaces it with the same functionality embedded into
the latter, as well as the ability to edit the server list in the
player's preferences file. There's some code movement in a few other
places since the previous function in the preferences namespace doesn't
suit the new code (it always returned a combined list of game and
player-defined servers).

There's some disabled code referencing a situation where the listbox
with the list of servers allows the code (and the player) to clear the
selection. It's disabled because there are some UX issues with it noted
in the code comments associated to it.

Fixes #4564.
2019-11-17 18:05:29 -03:00
Steve Cotton
1f323ab04e Fix the add_completed_campaign() call for the tutorial
When completing the tutorial, the preferences file's [completed_campaigns]
recorded that "" had been completed at difficulty NORMAL. This is an old
bug, unrelated to the other tutorial changes that I'm making, but would
cause problems if we want to change the UI based on whether the tutorial
has already been completed.
2019-11-04 16:36:37 +11:00
Steve Cotton
b66bdb8a16 Add other versions of Wesnoth to the Load Game dialog
If a save directory from another version is found, a drop-down list of
directories is added below the filter box in the Load Game dialog.

Refactor save_index_class to allow instances for other directories.

Design idea: all new saves go in to the main save directory. Games can be
loaded from other directories, but those directories are treated as read-only.
When building an index for other directories, the index is kept in memory and
not written to disk - this results in some noticeable lag in the UI when
opening the other versions' directories, but not the usual save dir.
2019-11-03 12:11:51 +01:00
Charles Dang
e643d2dce7 Removed joystick code
This was never fully implemented and has been essentially abandoned. If we want to
add this again, we should look to adding full game controller support (Steam controller,
for example), though I don't know how suited this game is for controller support. As for
as I can tell, the only working part was ever map scrolling.

Includes a sqrt -> std::sqrt conversion I forgot in this file awhile back.
2019-10-19 18:21:14 +11:00
Charles Dang
2470984af3 Prepend 'SDL2/' to all SDL includes
This was needed to get the build working with vcpkg's version of SDL, where all the SDL files are
in their own SDL folder. However, our cmake config also has a note saying it was a deliberate choice
to move our SDL files *out* of their SDL2 folder due to certain distros (FreeBSD is mentioned) not
putting the files in said folder in the first place.
2019-07-22 15:35:55 +11:00
gfgtdf
eba882b957 implement [lua]name=, fixes #3381 2018-10-22 01:34:21 +02:00
josteph
d443df9be1 Commandline: Add --campaign-skip-story option
Fixes #3472

(cherry-picked from commit f7be872da24474a47894becd7c6d5f013c495a2f)
2018-10-07 03:25:19 +00:00
Martin Hrubý (hrubymar10)
674fda85b7 Migrate links to https if available - Fwd c18537edc0678f40a209797d72dfaba3e5e88545
(cherry-picked from commit bc4d22dc72e79c3d6a3364ac896e473afd298246)
2018-10-07 03:23:36 +00:00
Charles Dang
071ca23a12 Language Selection: declared an execute function
(cherry-picked from commit c0b09315d1a67be30aaf82d09d06f594d0d5d2ed)
2018-10-07 03:23:30 +00:00
Charles Dang
f46e217454 Stop passing a milion game_config refs around during game initializaton
There are only 3 places where it's actually really needed. Used the game_config_manager
singleton to retrieve a reference in those cases.

(cherry-picked from commit 4eee386664b66e801bd4498e8730c017af03f0aa)
2018-10-07 03:22:55 +00:00
Celtic Minstrel
6177d4ae0a Add a command-line option to show incomplete translations in the language list
(cherry-picked from commit fc74e782b7e5afc9a842f231655d48e42d63f4e6)
2018-10-07 03:21:24 +00:00
Charles Dang
d9fb6c0bf5 Catch all exceptions (where possible) as const references
A few catch blocks modify something in their exceptions, so those are kept non-const.

(cherry-picked from commit 2bf4d68c87b69256266b7745a9e3453693794e35)
2018-10-07 03:20:58 +00:00
Iris Morelle
bd8176dc42 mp: Improve display of wesnothd client errors in general
Besides replacing the "End of file" error when getting disconnected from
the server under unexpected circumstances (e.g. because the server died)
with a translatable and more intuitive message, this also makes it so
other network error messages ("Connection refused", "Host not found",
etcetera) are displayed in the UI in a slightly clearer fashion, and in
an error dialog that must be dismissed with a click on a button, instead
of a transient message that can be easily missed due to an accidental
misclick.

Closes #3005.

(cherry-picked from commit c503c2ce35bc7d70fddc71daff70e31389615cf0)
2018-10-07 03:20:18 +00:00
Jyrki Vesterinen
e20e840700 Error message when trying to save a screenshot in an unsupported format
(cherry-picked from commit 93f956ed4cb8b182c7e150ef15f99f837044cf69)
2018-10-07 03:20:07 +00:00
Charles Dang
45f871067f Use std::size_t everywhere instead of plain size_t
Excludes:
* spirit_po/
* xBRZ/

(cherry-picked from commit fc2a58f6935176b70a035d3e1c03080f79687f94)
2018-10-07 03:17:59 +00:00
Celtic Minstrel
3bececed7c Sanitize the build info report to blank out the user's name
This report is intended for submission in bug reports,
so it makes sense to avoid the user's name for privacy concerns.
2018-03-12 12:20:52 +11:00
Charles Dang
26e8c148b1 GUI2: split default return value enum into its own file
This avoid having to include gui/widgets/window.hpp every time you just want to
check a dialog's return value.
2018-03-12 12:03:48 +11:00
Sofartin
733b76241d Fix for DEBUG_WINDOW_LAYOUT_GRAPHS macro
With big help from @jyrkive and @Vultraz
2018-03-11 11:51:13 -04:00
Celtic Minstrel
dc0d6474e8 Boost deprecation logdomain severity when debug mode is enabled 2018-03-04 21:21:33 -05:00
Jyrki Vesterinen
3984ae5b5e Fail WML unit test if the replay produces a warning or an error 2018-02-21 22:32:17 +02:00
Jyrki Vesterinen
5b89aaf780 Reset AI manager singleton pointer when exiting the game (fixes #2523) 2018-02-20 19:50:30 +02:00
Charles Dang
2dc4352845 Rebuild image cache when reloading changed game config (fixes #2424)
The above issue was caused by the fact that image::flush_cache() wasn't called after
reload_changed_game_config() when the addons manager was exited. Using F5 at the tilescreen
caused the image to appear since that callback *did* include image::flush_cache();

reload_changed_game_config() was called in 5 places, 2 of which were followed by flush_cache.
I figured it's safest to just include the latter in the former, since the other three usecases
(multiplayer installed addons before joining a game, a new core was selected, and the addons
manager was exited) all seem like places where flushing the image cache would be appropriate.
2018-02-06 05:32:24 +11:00
Gregory A Lundberg
b5f76eff79
Bump copyright to 2018 2018-01-19 00:02:20 -06:00
Gregory A Lundberg
d9f9d83a6b
Stop hanging when banned
When a banned or connection-limited client attempts to log in, it hangs.

This is because the client does not understand that the server did not finish the handshake. This moves the check to a point just after the handshake has completed (when the server would normally ask for a version number). The client never checked for errors, so added a check.
2018-01-03 19:53:11 -06:00
Charles Dang
a21697fef3 Cleaned up various areas of code related to setting window resolution
* Added a point ctor that takes an SDL_Point.
* Added a toggle_fullscreen function to CVideo.
* Change all management of resolution data to use point instead of std::pair<int, int>. This
  shortens the code considerably.
* Cleaned up preferences_dialog::set_resolution_list
* Made CVideo::set_resolution return a bool indicating whether resolution was changed.
* Swapped which of the two set_resolution overloads contains the main implementation.
* Moved the events::raise_resize_event() call when setting resolution to the CVideo function
  where it should have always been (instead of the prefs dialog callback). This is a pretty
  essential component and having it localized in one place meant any other area of the code
  that might have called set_resolution wouldn't have it.
2017-11-27 05:53:23 +11:00
Charles Dang
5481a7985f Cleaned up SP initialization function parameters
As of f4584b6b722a9 the game_config isn't needed in SP initialization anymore, and
enter_connect_mode can be made to return void.
2017-11-24 23:34:53 +11:00
Charles Dang
f4584b6b72 MP Game Settings: removed show_connect member
Early in the 1.13 development cycle there used to be an option to show the mp_connect screen
(now mp_staging) before starting an SP campaign. That was scrapped and the only code that used
it (in the SP initialization process) commented it out. Since we're not going to restore it,
might as well remove this flag.

Also removes the one instance remaining of a "show_configure" flag. Pretty sure this might have
also been a relic from the same time as show_connect, but it looks like it was since removed.
SP now has a dedicated screen for configuring active modifications in SP, which was the only
reason to show the configure dialog anyway (plus the mp create and configure screens were combined
later in 1.13 anyway).
2017-11-24 23:16:33 +11:00
Charles Dang
c67f5c352a Cleaned up more unnecessary CVideo function arguments and class members
* Dropped unused CVideo class member references.
* Replaced the lone usecase of the CVideo member in loadgame with the singleton and removed said member.
* Removed CVideo references from a bunch of addon management functions.
* Cleaned up a *lot* of now-unnecessary forward CVideo declarations.
2017-11-21 03:07:23 +11:00
Charles Dang
9dd497db4a Cleaned up the mess of CVideo references passed around the game initialization process
Essentially, we had CVideo arguments being passed down this chain:
- game_launcher
- free-standing MP initialization functions
- campaign_controller
- playsingle_controller/playmp_controller
- play_controller
- game_display
- display

And likewise down through
- game_launcher
- editor_controller
- editor_display
- display

With only a minimal number of actual calls along the way. :| There were maybe... two remaining?

This removes the CVideo arguments and class members from both chains (except of course, game_launcher.
That's where the "real" CVideo object lives).

The display class now initializes its CVideo reference from the singleton, which is also used in the
very few other places it's needed. I also replaced a check for a null video ptr in show_tooltip()
with a faked() check (see src/tooltips.cpp). That seems to make more sense, since CVideo is never
null now.
2017-11-21 02:30:19 +11:00
Charles Dang
b46a64b8ad Dropped CVideo parameter from loading screen and prefs display functions (missed in f2b31ba)
I had left the former alone in the above commit since I thought it might be worth keeping for the
faked() call, but that's not really a great reason.

As for the latter, I didn't realize the CVideo argument wasn't really even needed. I didn't even
need to replace it with a get_singleton() call since the resolution list is updated by set_resolution_list
before it's used.
2017-11-21 01:32:57 +11:00
Charles Dang
464cf07a8b Fix Travis GCC warnings for f2b31ba082e1
This also removes a bunch of unnecessary CVideo arguments from various savegame functions that
emerged as I cleaned up the unused parameters. savegame::save_game did take a CVideo pointer
that did look like it was intended to be a sort of do-show-dialog flag, but since that parameter
was never passed as null, I removed it.
2017-11-20 22:29:49 +11:00
Charles Dang
f2b31ba082 Massive cleanup of GUI2 display/show and execute functions implementations and related CVideo arguments
This a two part commit. First:
----------------------------------------------------------------------------------------------------
Added and deployed two new helper macros for the standard implementations of the static execute
and display functions. I also made use of a variadic template in order greatly simplify code
maintenance. Now, even if the dialog's ctor parameters change, no one has to worry about updating
the associated execute/display functions (though of course, this only applies if the helper macros
are used). \o/

I did not deploy the macro in cases where there were multiple overloads or the functions did more
than just show their dialogs. I might add an additional __VA_ARGS_ parameter to the macros later.
Do note for the end_credits dialog I moved the default empty-string parameter from the display
function to the ctor.

Second:
----------------------------------------------------------------------------------------------------
Another change is that modal_dialog::show and modeless_dialog::show no longer take CVideo arguments.
Since the video argument couldn't be included in the parameter pack (maintaining the argument would
have meant making it the first one, which would be just as much work), and using CVideo::get_singleton
in the macros would require adding video.hpp includes in a whole bunch of files, I simply removed the
argument. I had been intending to do this for a while anyway.

This therefor also removes the CVideo argument from:
* All dialog display/execute functions.
* modal_dialog::show
* modal_dialog::build_window
* modeless_dialog::show
* modeless_dialog::build_window
* wml_exception::show
* gui2::show_message
* gui2::show_error_message
* gui2::show_transient_message
* gui2::show_transient_error_message
* gui2::show_wml_message
* gui2::build
* gui2:🪟:window
* gui2::dialogs::tip::show
* Various GUI2-related Lua functions. The video_dispatch helper was also removed.
* Any functions that took a CVideo argument for the sole purpose of passing it to one of the above.

Ya know, all these damn CVideo arguments didn't actually do anything, besides an occasional check to
CVideo::faked. At the end of the pipeline, they just got assigned to the video_ member of gui2::window.
Huge code bloat for nothing.
2017-11-20 19:24:41 +11:00
Jyrki Vesterinen
a324534a6a Fix Wesnoth prompting for MP server even in local games
Regression from commit 9019074182753475b3b6788a35af0322d67ef08f.
2017-11-07 19:09:03 +02:00