Commit Graph

92 Commits

Author SHA1 Message Date
André Cheng 57f5d27427 Doc: Fix documentation of GetDefaultValueCallback 2024-04-25 20:07:54 +02:00
André Cheng ceb0053dd9 Codechange: Correct return type of GetDefaultValueCallback 2024-04-25 20:07:54 +02:00
André Cheng a4071b78d7 Codechange: Add callback to IntSettingDesc to support more default values 2024-04-25 20:07:54 +02:00
Patric Stout 8f22066b9a
Fix #12147: reset all saved settings to their default before loading a game (#12210) 2024-03-02 16:05:43 +01:00
frosch 17dfc1a49a Codechange: Replace SF_GUI_NEGATIVE_IS_SPECIAL with a settings value callback. 2024-01-28 14:44:24 +01:00
frosch 9e9a8ca7f6 Codechange: Add callbacks to IntSettingDesc to support dynamic strings for title, help and values. 2024-01-28 14:44:24 +01:00
frosch 022b9e92d2 Codechange: Move settings string formatting into IntSettingDesc members. 2024-01-28 14:44:24 +01:00
Patric Stout fd073a2810 Remove: replace custom span with std::span 2024-01-17 00:25:08 +01:00
Peter Nelson ab535c0a86
Codechange: Add base() method to StrongType to allow access to the base type without casting. (#11445)
This removes the ability to explicitly cast to the base type, but the requirement
to use .base() means the conversion is still explicit.
2023-11-06 20:29:35 +00:00
frosch b6c8f301be Codechange: Silence warnings about intentionally unused parameters. 2023-09-19 22:49:59 +02:00
Patric Stout 37e2f99c09
Change: store crash logs in JSON format (#11232) 2023-09-14 20:13:27 +02:00
Patric Stout 299570b2c1
Codechange: make TimerGameCalendar Date and Year types strongly typed (#10761) 2023-08-12 18:14:21 +00:00
Rubidium eaae0bb5e7 Codechange: automatic adding of _t to (u)int types, and WChar to char32_t
for i in `find src -type f|grep -v 3rdparty/fmt|grep -v 3rdparty/catch2|grep -v 3rdparty/opengl|grep -v stdafx.h`; do sed 's/uint16& /uint16 \&/g;s/int8\([ >*),;[]\)/int8_t\1/g;s/int16\([ >*),;[]\)/int16_t\1/g;s/int32\([ >*),;[]\)/int32_t\1/g;s/int64\([ >*),;[]\)/int64_t\1/g;s/ uint32(/ uint32_t(/g;s/_uint8_t/_uint8/;s/Uint8_t/Uint8/;s/ft_int64_t/ft_int64/g;s/uint64$/uint64_t/;s/WChar/char32_t/g;s/char32_t char32_t/char32_t WChar/' -i $i; done
2023-07-19 19:30:14 +02:00
Patric Stout ece50d5a1d Codechange: use BoolSettingDesc to parse settings in conversion code 2023-07-19 13:17:50 +02:00
Rubidium f4b0ac2bd4 Codechange: use std::string for formatting settings 2023-05-24 22:42:01 +02:00
Patric Stout 199e41c762
Codechange: use default dtor instead of empty (#10826) 2023-05-14 23:31:03 +02:00
Rubidium ed7685910d Codechange: pass large objects by reference instead of value
Especially when they get passed on directly to the next function or via a
constructor into an instance variable
2023-01-28 13:43:21 +01:00
Rubidium ede3f79475 Codechange: use the name string in SaveLoad for the name of the Setting as well 2021-07-09 22:53:30 +02:00
Rubidium 01139d3368 Codechange: access the name of a setting via an accessor function 2021-07-09 22:53:30 +02:00
Patric Stout 8f5d0ecde3
Codechange: split settings.ini over several files (#9421)
This reduced the load on compilers, as currently for example MacOS
doesn't like the huge settings-tables.

Additionally, nobody can find settings, as the list is massive and
unordered. By splitting it, it becomes a little bit more sensible.
2021-07-09 21:16:03 +02:00
Rubidium 7e7a4aad72 Codechange: split off the settings saveload code from the main settings handling logic 2021-07-06 21:32:47 +02:00
rubidium42 98e653dacc Fix #9386: compilers failing to compile with LTO by using variants instead of new + unique_ptr
With std::variant all memory can be figured out at compile time, so the compiler needs to keep track of fewer elements. It also saves out a unique_ptr and its memory management, over a slight impact for resolving a setting.
2021-06-26 20:28:34 +02:00
rubidium42 f35e6c1c7f Codechange: use C-style strings instread of std::string in the SettingDesc constructor
This as using std::string causes much more variables to be tracked, potentially causing problemes for certain compilers in certain situations
2021-06-26 20:28:34 +02:00
rubidium42 bf500c39c9 Codechange: make the name of SettingDesc a std::string 2021-06-13 10:26:58 +02:00
rubidium42 ca9c50607e Codechange: use StrStartsWith/StrEndsWith when finding settings 2021-06-13 10:26:58 +02:00
Patric Stout 648ee88a02 Codechange: merge guiflags and flags in settings .ini files
It was rather confusing which one was for what, especially as some
SaveLoad flags were settings-only. Clean up this mess a bit by
having only Setting flags.
2021-06-06 21:45:01 +02:00
Patric Stout feb2ddbefa
Codechange: rename SettingGuiFlag to SettingFlag (#9332)
It is a lovely organicly grown enum, where it started off with
GUI-only flags, and after that a few flags got added that can be
considered GUI-only (the GUI disables/enables based on them), to
only have flags added that has nothing to do with the GUI.

So be less confusing, and rename them to what they do.

Additionally, I took this opportunity to rename 0ISDISABLED to
reflect what it really does.
2021-06-03 21:18:29 +02:00
Patric Stout 0c96884700
Codechange: add a wrapper function to find all settings based on prefix (#9312) 2021-05-30 10:55:52 +02:00
Patric Stout d70fb74ac6
Codechange: use setting name instead of index for CmdChange(Company)Setting (#9306)
This is mostly done as there are now constraints on settings.ini you might not
expected. For example, conditional settings always have to come last, as otherwise
they would influence the index.
2021-05-29 23:27:01 +02:00
rubidium42 08308d808c Codechange: use separate pre and post callbacks for int settings 2021-05-29 10:07:30 +02:00
rubidium42 e2f5d9e561 Codechange: use separate pre and post callbacks for string settings 2021-05-29 10:07:30 +02:00
rubidium42 ea9715d970 Codechange: split Write_ValidateSetting to get separate functions for making ints valid and writing ints 2021-05-29 10:07:30 +02:00
rubidium42 208952f2ba Codechange: split Write_ValidateSetting to get separate functions for making strings valid and writing strings 2021-05-29 10:07:30 +02:00
rubidium42 8372c679e3 Codechange: add helper functions to read an int setting value 2021-05-27 18:49:43 +02:00
rubidium42 86c9ef8134 Codechange: remove SettingDescType in lieu of the actual classes 2021-05-27 18:49:43 +02:00
rubidium42 e666a962b1 Codechange: let OneOfMany and ManyOfMany be their own classes as well 2021-05-27 18:49:43 +02:00
rubidium42 860003458f Codechange: make BoolSettingDesc its own sub class 2021-05-27 18:49:43 +02:00
rubidium42 72ec81325b Cleanup: remove unneeded temporary variables and casts 2021-05-27 18:49:43 +02:00
rubidium42 0d6597a9e6 Codechange: move bits of SettingDesc down to the appropriate sub classes
And by doing so remove the hack where ints were put into pointers so "def" could either be an int or a string
2021-05-27 18:49:43 +02:00
rubidium42 f6723b53da Codechange: make parsing of IniItems overridable functions of SettingDesc 2021-05-27 18:49:43 +02:00
rubidium42 1f8ff0e4f9 Codechange: make Write_ValidateSetting a function of StringSettingDesc 2021-05-27 18:49:43 +02:00
rubidium42 be28c95b30 Codechange: make Write_ValidateSetting a function of IntSettingDesc 2021-05-27 18:49:43 +02:00
rubidium42 c3cd4a683d Codechange: make formatting of values into strings a method of SettingDesc 2021-05-27 18:49:43 +02:00
rubidium42 d8125fa46e Codechange: make sub classes of SettingDesc for the different types of settings 2021-05-27 18:49:43 +02:00
rubidium42 91b3d697c5 Codechange: make SettingDesc an instance in the setting table to allow for sub classes 2021-05-27 18:49:43 +02:00
rubidium42 3bb6ce8827 Codechange: use initializer_lists for the settings tables
Not using vectors as those require copying from the initializer list and that
makes unique_ptrs to the actual SettingDesc objects later impossible.
2021-05-27 18:49:43 +02:00
rubidium42 425d50372f Codechange: let SettingDesc extend SettingDescBase 2021-05-27 18:49:43 +02:00
rubidium42 ac99a38175 Cleanup: remove and/or fix some confusing comments
The comments for SettingDescType; it is a byte, so not 4 bytes and since it is not a flag there are about 250 other possibilities left instead of 9.
SettingGuiFlag is uint16 so has 2 bytes allocated.
SettingDescGlobVarList and related comments imply that global vars cannot be used elsewhere, but they are used for settings just fine. Even then the type is not used anywhere else but the definition of the table.
2021-05-27 18:49:43 +02:00
rubidium42 8ffb4122df Codechange: just pass the SettingDesc to SetSettingValue and remove distinction between (non)company 2021-05-27 18:49:43 +02:00
rubidium42 0f062b3882 Codechange: clean up C-string support from settings 2021-05-13 23:13:17 +02:00