946 Commits

Author SHA1 Message Date
pentarctagon
d674e9f462 automatic copyright update 2025-02-17 12:59:51 -06:00
pentarctagon
47417814a6 Remove configure_engine
it's mostly a wrapper around things which are already available via create_engine
2025-02-15 11:04:37 -06:00
ForestDragon
93509c8499
Implement Reachmap Color and Opacity Options (#9877)
Co-authored-by: Descacharrado <Luis_koopa@hotmail.com>
Co-authored-by: Gunter Labes <soliton@wesnoth.org>
Co-authored-by: Charles Dang <exodia339@gmail.com>
2025-02-14 23:39:49 -05:00
Subhraman Sarkar
adc95a06cd tests: call set_main_thread 2025-01-31 07:35:10 +05:30
Celtic Minstrel
ef66ad5aae Make enable_lua_ptr movable and non-copyable 2025-01-15 09:46:42 -05:00
Pentarctagon
f61b7b77ec
Add additional functionality for the in-game add-ons manager (#9693)
When started with the command line argument --addon-info, the Info button is shown on the add-ons manager which then allows:
* querying the downloads by version of the currently selected add-on
* querying the count of total add-ons uploaded vs the count of add-ons using forum_auth
* deleting an add-on (requires being a member of the Site Administrators or Forum Administrators forum groups)
* hiding an add-on (requires being a member of the Site Administrators or Forum Administrators forum groups)
2025-01-14 09:35:46 -06:00
Charles Dang
b9d67848ae Markup: doc cleanup, take arguments by string_view when possible 2025-01-04 09:31:32 -05:00
Subhraman Sarkar
bab3dd6e35 unified units dialog with configurable options
instead of having multiple dialogs with similar UI, we use only one dialog to which multiple configurations and data can be set.
2024-12-29 22:00:00 +05:30
gfgtdf
392b8dc9fb
Use [leader] in the c++ code (#9660)
Added code to convert all  `[side]type=` to `[side][leader]` when the `[scenario]` is read, and the rest of the engine code to only work with [leader], this should fix all possible problems with `[leader]` and also simplify the code a bit

Fixes #7985
Fixes #3742
2024-12-26 20:22:09 +01:00
gfgtdf
5801b5bcdb
use to/from_chars in attribute_value and lexical_cast (#8790)
This makes attribute_value and lexical_cast use the "new" to/from_chars api.

Its main advantages are:
- It's guaranteed to be locale independent, hopefully fixing all cases of #3945 and similar
- It fixes some cases config serialization, in particular the test
```
	cfg["x"] = "9.87654321";
	BOOST_CHECK_EQUAL(cfg["x"], 9.87654321);
```
- Previously the lexical_cast implementation used exception
  handling for invalid formats (catching std::invalid_argument)
  which made noise during debugging (and is also slower if it
  is not optimized out).
- It's faster

So far afaik the only compiler which has a complete and proper to/from_chars implementation is msvc, gccs implementation of from_chars sometimes uses strtod under the hood and clang simply hasn't implemented from_chars for floating point numbers yet at all (actually the upcomig clang 20 will have it). Luckily for us, there is now also boost::charconv that can be used. So this raises to minimum build requirement to have at least one of:

- msvc 2019 update 5
- gcc 11
- clang 14 (i have added a fallback implementation of from_chars for this case, that doesn't support all of its features, and is probably certainly not as fast as the boost version, but supports the features that we use from it)
- boost 1.85
 
Since in particular the gcc implementation isn't that good (at least it on gcc11), boost charconv is the preferred implementation that is used if available.

This also removes a strange overload for
pointers to integers in lexical_cast while changing lexical_cast to use the new api.
2024-12-08 22:28:10 +01:00
JJ Marr
fe5296aefd Make every possible param a const reference
This is important for performance. If a parameter doesn't have to be
modified, it should be a constant reference to the original.
2024-12-01 23:19:53 -05:00
JJ Marr
3b8ceb00f0 Replace NULL with nullptr in the codebase 2024-11-30 13:24:45 +01:00
Charles Dang
2c216eec72
Refactor utils::format_timespan to use chrono types (#9610)
This also adjusts the periods for years and months. Previously, we were using values of 30 days for a month and 12 months for year. Now, we use the chrono values of a month as 1/12 of a year and a year as 365.2425 days.
2024-11-28 22:07:52 -05:00
Charles Dang
c5cb0f104f Remove --no-delay option
This wasn't consistently honored and only affected unit animations.
2024-11-12 00:19:44 -05:00
Charles Dang
c815e1d23a Map Location: reimplement rotate_right as rotate_direction
Since rotate_right_around_center rotates a location, this makes it clear we're getting a rotated direction instead. Also made it constexpr
2024-10-10 22:57:23 -04:00
Charles Dang
f04e19934f Map Location: rename default_dirs and get_opposite_dir
all_directions better reflects the purpose of the former. Also made it return a value,
since the only places that used it immediately assigned it to a local variable.
2024-10-10 22:57:23 -04:00
Charles Dang
f4fda31707 Map Location: convert direction to a scoped enum 2024-10-10 22:57:23 -04:00
Subhraman Sarkar
c2757a1d35 markup refactor: replace hardcoded markup strings
Examples:
formatter() << "<b>" << "Hello" << "</b>" becomes just markup::bold("Hello")
formatter() << font::span_color(color) << text << "</span>" becomes formatter() << markup::span_color(color, text)
also adds markup.cpp/markup.hpp to XCode and CodeBlocks source files and removes text_formatting.cpp/hpp from projectfiles.
2024-10-10 01:31:14 -04:00
Charles Dang
56cc3aee0f
Config: remove implicit conversion to int and bool (#9444)
Resolves #9009, closes #9384. Besides the issues that came from having both int and bool conversions (even with bool marked explicit), it doesn't make sense to use int for all numeric assignments. I didn't test whether it would be an issue in practice, but it seems better to let callers be explicit about what type they want for numeric values than risking overflow or wrapping for very large values.
2024-10-09 01:36:10 -04:00
Wedge009
558650bd14 Typography update for source code (in addition to .cfg data files previously reviewed). 2024-10-06 09:13:10 +11:00
pentarctagon
d4e7f5bc43 remove unsigned_matches_if_present 2024-09-29 23:19:39 -05:00
Celtic Minstrel
65124f30d7 Help markup: Add a unit test for unknown character entities 2024-09-23 19:49:44 -04:00
Celtic Minstrel
5f47ea6643 Help markup: add more unit tests and fix a small parser issue 2024-09-23 19:49:44 -04:00
Celtic Minstrel
2e3c401f45 Help markup parser: Fix some issues with auto-closed tags 2024-09-23 19:49:44 -04:00
Celtic Minstrel
d910171b3d Rewrite the help markup parser.
It is now roughly a superset of Pango and supports the following new features
* XML character entities, including decimal and hex entities, common named entities (apos, quot, lt, gt, amp), and even unrecognized named entities
* Nesting tags within each other (new-style only)
* Attributes without a value
2024-09-23 19:49:44 -04:00
pentarctagon
08d3f3be88 Revert "Add utils::span wrapper (#9318)"
This reverts commit 686eb30d41cf3975a3900fb11a80630fce6369e3.
2024-09-08 10:25:36 -05:00
Charles Dang
686eb30d41
Add utils::span wrapper (#9318) 2024-09-08 02:38:24 -04:00
Gunter Labes
6293a503e0
Merge pull request #9133 2024-08-24 06:41:03 +02:00
Nils Kneuper
e1c14ac2a7 applied "update_copyrights" script 2024-08-23 14:50:50 +02:00
Gunter Labes
d46dbef39b
Warn about external paths 2024-08-20 09:14:47 +02:00
Gunter Labes
5da4160d87
Correct confusing handling of ./ paths
Warn about unresolvable paths instead of returning a bogus path or nothing.
2024-08-20 09:14:47 +02:00
Charles Dang
0a9d351fe2 Replace filesystem::ends_with with boost::algorithm::ends_with
The former had nothing to do with fs functionality at all.
2024-08-01 00:03:13 -04:00
Charles Dang
fa905a6165 Added some heterogeneous comparison config tests 2024-07-30 22:48:40 -04:00
Charles Dang
1ba0168eb3 Removed serialization test that relies on deleted ostream operators
These were removed in C++20. See https://en.cppreference.com/w/cpp/io/basic_ostream/operator_ltlt2
and https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1423r3.html#option7
2024-07-30 21:03:43 -04:00
Subhraman Sarkar
64caa4acda
Allow quick reload of gui2 themes (#9117)
* New "Apply" button in preferences dialog that is used to quickly apply the GUI2 theme, no restart needed.
* gui initialization reorganized a bit. gui2::init() now responsible for reading themes from file only. Actual theme switching and activation done by gui2::switch_theme(). preferences dependency removed from gui and moved to caller of gui2::init(). gui2 tests updated accordingly.
2024-07-30 07:59:54 +05:30
Gunter Labes
1f6c935fe1
Declare locally used function static 2024-07-28 22:10:09 +02:00
Charles Dang
e45b46107e
FS: use optional<string> to represent non-existent paths (#9107) 2024-07-18 09:58:55 -04:00
pentarctagon
4f40c9deb5 Move assert into filesystem::get_user_data_path()
As discussed previously in https://github.com/wesnoth/wesnoth/pull/9016#discussion_r1650036348
2024-07-17 17:50:03 -05:00
pentarctagon
f0991ec9c1 remove use of the config directory
the credentials and lan config files will now use the userdata folder
2024-07-08 17:42:20 -05:00
Subhraman Sarkar
103b80ff01
Editor enhancements (#8903)
Map/Scenario Editor

* Rename Load Map to Load Map/Scenario (since it can load both), Edit Scenario to Edit Scenario Settings, Save Map to just Save.
* Rearrange menu order
* Add icon for the preferences menu item (used the preexisting settings.png icon)
* Open folder correctly at Add-on's scenario directory instead of editor/scenarios. (#8910)
* Show Save Scenario As only for Scenarios
* Use the settings.png icon for Preferences menu item
* Add functionality to "Loyal" checkbox (Unit tool -> Place unit -> Right click menu) (#8445)
* Show warning when maps are saved in scenarios folder or vice versa (#8911)
* Unit List moved to Units menu from File menu to reduce some pressure from the latter.
* Status Table menu item disabled since it does nothing. (Should be reenabled once the functionality has been added.)
* Improve reload functionality in Editor (F5). Reload happens directly from memory and no temp files are needed. Also, the undo/redo stacks will be preserved. (#9024)

Time Schedule Editor

* Browse buttons now set wesnoth style paths instead of just pasting the absolute path returned by the file dialog
* Change text boxes from inactive to uneditable.
* Code generation improvements
* Add copyright notice to tod_new_schedule
* Confirmation messages
* Preview buttons for image and sound files and new icons for the preview button (2 sets : preview image and preview sound)

Unit Type Editor
 * Confirmation messages
 * New icons for the preview button (2 sets : preview image and preview sound)

Add-on menu
 * Two new menu entries for (1) opening the Add-on selection dialog, (2) opening the folder corresponding to the Add-on
The open add-on folder option shows a GUI2 file dialog at the add-on's folder which can be used to open any file. If it is a loadable map/scenario it will be opened in the editor, otherwise the OS's default application for that file will be opened.

File Dialog
 * Redesigned with new icons
 * New Open External button that opens selected file/folder in the platform's default application (independently of what pressing Open would do). This could be used to quickly open a folder or preview the file before actually selecting it.
 * Extension checking and filename validation. (See #8911)
2024-06-29 21:56:54 +05:30
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
Subhraman Sarkar
43f5644e36
Rich Text Label widget for Help Browser GUI2 port (#8655)
A rich text label widget that can show text marked up with help markup.
Also includes the GUI Test Window, accessible in the title screen after launching wesnoth using --clock option. It can be used as dialog template/example or as a place to test GUI2 code.
2024-06-06 16:33:37 +05:30
Subhraman Sarkar
92d66554dd
UI : About dialog (#8803)
* Redesigned the version dialog to serve as a general purpose About dialog.

* Credits button removed from title screen

* Moved community dialog contents to about dialog as new tab

Co-Authored-By: Pentarctagon

* Bugfixes to the tab_container widget

* Success indication mechanism on copy buttons
2024-05-21 09:43:32 +05:30
Pentarctagon
b3f6f80010
Add a button to the build info dialog to rerun the migrator. (#8791)
Add-ons: checks for any that exist in the chosen other version but not in the current version.
Preferences: adds attributes that don't exist from the chosen other version's preferences that aren't in the current version's preferences. for attributes that exist in both, use the attributes from the file that was modified most recently.
Credentials: move if the credentials file doesn't exist.

Fixes #7936
2024-04-27 00:45:41 -05:00
pentarctagon
39987cd1ca Add a Community button to the title screen.
This opens a dialog with links to the forums, discord, etc, plus a donate button that links to Wesnoth's SPI page.
2024-04-15 16:50:42 -05:00
grz0
4b027073c0
Remove gzip/bzip2 (de)compression commandline options (#8718)
* Remove handling of --gzip --gunzip --bzip2 --bunzip2 command line options

* Remove --gzip --gunzip --bzip2 --bunzip2 options from manpages

* Remove --gzip --gunzip tests for commandline_options class
2024-04-10 15:45:01 +02:00
Subhraman Sarkar
0b646dec8a New Unit Type Editor UI in Scenario Editor 2024-03-26 13:23:38 -05:00
Rafael Fillipe Silva
96ebe8a693 add tests for link cycle validation
Signed-off-by: Rafael Fillipe Silva <rfsc.mori@gmail.com>
2024-02-26 10:12:43 -06:00
Rafael Fillipe Silva
c925737f54 format changes related super mandatory keys validation with clang-format 2024-02-26 10:12:43 -06:00
Rafael Fillipe Silva
0f78777dee add tests for mandatory key validations considering super tags 2024-02-26 10:12:43 -06:00