62 Commits

Author SHA1 Message Date
Celtic Minstrel
62d9ebecc2 Revert "Used std::optional directly since we support C++17 now"
This reverts commit 4d54b2a7fd75696e9d7f745104f4c2e2ce5d0e6c.
2024-07-23 09:03:13 -04:00
Pentarctagon
971073055e
Refactor the preferences into a proper singleton. (#8930)
The current preferences handling is a mess:
* it's essentially a global config object that anything can modify in any way the caller wants, which is managed across multiple source files which have their own oddities and interdependencies.
* the general preferences has its own bit of SDL event handling and while I get the idea behind `events::sdl_handler` there's no reason to have SDL events handled in the preferences instead of just calling the relevant preferences setter for each event when it happens.
* the general preferences is where most of the preferences are handled and has its `base_manager` struct, which is part of the `manager` struct in the game preferences, which is then implicitly initialized as part of game_launcher's constructor.
* the editor preferences are the only preferences in a sub-namespace `preferences::editor` while all other preferences are just in the `preferences` namespace.
* the display, editor, and lobby preferences are all dependent on including the game preferences, the credentials are dependent on including the general preferences (but not the game preferences), the game preferences are dependent on including the general preferences, and the advanced preferences are entirely their own thing which is dependent on none of the other preference functionality and manages its own singleton.
* nothing checks whether the preferences file has actually been loaded before allowing values to be read from or written to the preferences config - if you attempt to get a value too early in wesnoth's initialization it will silently just give you whatever the default value for that preference happens to be.

With this there is instead a single access point (with exceptions handled via friend functions/classes), all predefined preferences are accessed via their own setter/getter, and all mainline preferences are defined in a single file (preference_list.hpp) so it's easily findable what preferences exist and where they're used. Having the list of all mainline preferences listed out also allows the lua preferences API to provide that full list rather than just the list of the preferences that have been set so far. Also it now checks for whether the location of the preferences file is known before attempting to load the preferences file and asserts if someone attempts to use the preferences too early.
2024-06-09 11:34:09 -05:00
shijie.chen
d88ddec6f1
Remove unnecessary header files (#8531)
Co-authored-by: shijie.chen <shijie.chen@goland.cn>
2024-03-12 00:07:48 -04:00
pentarctagon
970163813d 2024 copyright update 2024-01-20 22:22:23 -06:00
Pentarctagon
c44cc2742e Copyright update.. 2023-04-29 10:48:11 -05:00
Tommy
29c82e308a CVideo: Remove CVideo singleton, replacing with "video" interface
The only real change is that in stead of passing around CVideo
pointers and calling things via CVideo::get_singleton().foo()
one simply does not pass around pointers, and calls video::foo().
2022-07-24 22:06:33 +12:00
Pentarctagon
340023921d
2022 copyright update. 2022-03-06 19:07:13 -06:00
Pentarctagon
c4c292fa3b Replace all remaining usages if MAKE_ENUM. 2022-03-03 21:23:02 -06:00
Pentarctagon
57ce449af8
Re-add attribution to copyright notices.
These are mostly useless and outdated/wrong, but apparently it's probably illegal to remove them.
2021-07-27 20:21:38 -05:00
Pentarctagon
ba75e1af50
Copyright update.
This additionally:
* Makes all copyright notices identical aside from the starting year for Wesnoth-specific source files. Files not included: mariadbpp, lua, spirit po, xbrz, and bcrypt (crypt_blowfish).
* Removes all attribution from the files, since the vast majority of them are outdated or seemingly just outright incorrect. For example, I would guess that Dave is no longer the sole author of the majority of Wesnoth's current code.
2021-07-26 11:38:03 -05:00
Pentarctagon
8e2996661f
Prevents logging of duplicate deprecation messages and messages missing timestamps.
Fixes #5942
2021-07-24 18:51:42 -05:00
Charles Dang
4d54b2a7fd Used std::optional directly since we support C++17 now 2021-01-17 11:48:14 +11:00
Charles Dang
ef5296faf5 Game Config Manager: removed jump_to_editor ctor argument
This was taken from the value in game_launcher, which was set to true if commandline_options::editor was set.
This uses that value instead of passing in the flag manually, which is consistent with the other defines.

This also removes game_launcher::jump_to_editor since it's no longer needed.
2021-01-09 11:38:33 +11:00
Charles Dang
dbf9d355cf Moved advanced prefs manager out of game_launcher
It didn't really make much sense to keep it here. The manager singleton is now local to its implementation
and initialized in game_config_manager::init_game_config like the credits data.
2021-01-09 03:39:44 +11:00
Charles Dang
4a86e4e17b Game Launcher: used a scoped enum for reload_mode (formerly RELOAD_GAME_DATA) 2021-01-07 02:28:18 +11:00
Charles Dang
321b496362 Game Launcher: cleaned up jump_to_campaign_info 2021-01-07 01:58:55 +11:00
Charles Dang
4feb168fd1 Game Launcher: removed unused mark_completed_campaigns function 2021-01-06 06:22:05 +11:00
Charles Dang
876ae66480 Game Launcher: removed show_preferences
This doesn't rely on anything in game_launcher so no need to have it a member function.
2021-01-06 01:10:42 +11:00
Charles Dang
ca00ca27fb Game Launcher: used a scoped enum for mp_mode (renamed from mp_selection) 2021-01-06 00:01:45 +11:00
Charles Dang
1a1c629721 Game Launcher: made clear_loaded_game and start_wesnothd private
Also properly deleted the copy constructor and assignment operators.
2021-01-05 23:54:56 +11:00
Charles Dang
8b6def9678 Game Launcher: renamed is_loading to has_load_data for clarity 2021-01-05 23:47:26 +11:00
Charles Dang
fbe44a4db5 Game Launcher: used an optional for load_data
This also fixes an issue where the exception data was actually being copied instead of being moved
since the exception was being passed in as const reference.
2021-01-05 21:39:12 +11:00
Charles Dang
f86168ab26 Game Launcher: removed set_tutorial
Since 4282d0b112f78746c01ca15e918389a8cfd1f0c6 the tutorial no longer has a dedicated titlescreen button,
which was the only use of this.
2021-01-03 06:04:46 +11:00
Pentarctagon
4c2b725ec0 Change all doxygen comments to the same format. 2020-12-31 23:59:28 -06:00
Charles Dang
f3f6acf74b Game Launcher: removed CVideo getter 2020-12-19 11:15:19 +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
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
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
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
Steve Cotton
5dcd2d301d
Clean up some Cppcheck warnings by passing args as const refs (#4364) 2019-09-20 09:34:19 +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ý
96bbebb514 Fix building with Xcode 10 (#3460)
Resolves #3458.

(cherry-picked from commit 50301f84e33d828c39835bc47f04dd1107631960)
2018-10-07 03:24:17 +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
Gregory A Lundberg
b5f76eff79
Bump copyright to 2018 2018-01-19 00:02:20 -06:00
Charles Dang
2101353d36 Convert include guards to the shorter #pragma once
Turns out I mistook @celticminstrel's opinion that we should use include guards over pragma (737916e).
Since all major compilers support `#pragma once`, there's no reason not to use it.

For future mergability reasons, this excludes src/spirit_po and src/xBRZ. It also excludes src/boost-patched.
2017-05-09 19:41:37 +11:00
Celtic Minstrel
b6eedd3df6 Allow launching test scenarios from the titlescreen
Unit test scenarios are excluded. There is no button and no default hotkey.
2017-05-04 19:20:44 -04:00
Charles Dang
e4f03fe459 Moved all preferences source files into a single folder 2017-05-04 11:04:19 +11:00
Celtic Minstrel
b4dc11ce36 Belated 2017 copyright update 2017-03-19 10:05:38 -04:00
Celtic Minstrel
f815c2272a Pass strings by constref when possible
These instances were found by cppcheck.
Thanks matthiaskrgr for running it.
2017-03-16 17:07:04 -04:00
Charles Dang
e22c8967ee Cleaned up global.hpp includes 2016-12-17 15:21:04 +11:00
Chris Beck
202408f28e simplify font::manager object a bit, give better error messages for font initialization failure 2016-10-16 21:07:09 -04:00
Chris Beck
e3417bd954 split gui1 font interface into a font_config and sdl_ttf interface
move all of these into font folder
2016-10-15 05:52:23 -04:00
Charles Dang
e78777caa3 Replaced instances of util::scoped_ptr with std::unique_ptr 2016-09-15 16:27:58 +11:00
gfgtdf
dcd037e530 small load_game_exception refactor
* Moves load_game_exception to savegame.hpp and cleans some #includes
* Removes the load_game_exception statis members and replaces them with
a non-static load_game_metadata member.
* Adds loadgame::DIALOG_TYPE to remove the gui1 dependency.
* Fixes loading of replay saves.
* Adds soem mising override specifers in savegame.hpp
2016-09-10 20:33:18 +02:00
Celtic Minstrel
d0906ceac5 Refactor titlescreen loop so that it redraws properly behind other dialogs 2016-09-08 02:24:16 -04:00
Charles Dang
56e2a733e5 Merge pull request #674 from jyrkive/mute-in-background
Mute the music when the game loses focus
2016-07-30 16:49:21 +11:00
Charles Dang
05092ba2f6 Refactor most boost pointer related stuff to use their stdlib counterparts
This constitutes drop-in replacements for:

* boost::shared_ptr
* boost::scoped_ptr
* boost::weak_ptr
* boost::enable_shared_from_this
* boost::static_pointer_cast
* boost::dynamic_pointer_cast

This excludes boost::intrusive_ptr, except for stray includes. Refactoring that is more complicated.
2016-07-25 09:28:42 +11:00
Jyrki Vesterinen
bf510e7886 Pause the music when the game loses focus 2016-06-30 12:58:18 +03:00