Commit Graph

157 Commits

Author SHA1 Message Date
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
Charles Dang
99ee4a7703
Split text attribute handling into its own API (#9890) 2025-02-15 00:33:46 -05: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
Pentarctagon
d8abcff103
wesnothd: use lambdas instead of rs_base (#9747) 2025-01-15 21:14:00 -05:00
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
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
79798b9f2b remove unused cpp file 2024-12-15 05:24:12 +01:00
gfgtdf
f29f8fb368 move the carryover gold handling and dialog to lua
The idea is to make it easier for umc devs to implement
their own carryover / early finish bonus mechanics. Maybe
we can also make use of it in Worls Conquest.
2024-12-15 05:17:57 +01:00
gfgtdf
a7d3db9cf7 Fix source_lists order 2024-12-14 23:07:10 +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
Charles Dang
5e4728d69e Remove make_unit_ptr
Only used in one place anymore which already included unit.hpp anyway, so there's no benefit here.
2024-10-18 12:51:01 -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
1261d88b15
Removed a bunch of unused GUI1 stuff (#9375)
Don't need these now that the GUI2 help browser is merged.
2024-09-23 23:54:47 -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
Charles Dang
03e11a62e1 Removed GUI1 Help interface code
Not needed anymore since we're moving to GUI2 for this dialog.
2024-09-23 19:49:44 -04:00
Celtic Minstrel
d4278fa1be Lua API: Add __dir metamethod to units metatable
This implements a new system for registering attributes, adapted from the system for widget attributes.
2024-09-15 15:27:39 -04:00
Charles Dang
518e0d2050
Added spritsheet generator (#6665)
This takes a folder with images and writes an assembled spritesheet to disk along with a config file.
2024-08-08 11:29:08 -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
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
Subhraman Sarkar
03a46f1d7c
Combobox, Tab Container and Editability in Text Box (#8390)
* new combobox and tab container widgets
* ediability in text box via the editable key
2024-05-06 09:56:44 +05:30
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
gfgtdf
0d9dfb64d2 Remove src/playturn.cpp 2024-04-09 04:18:46 +02:00
Subhraman Sarkar
0b646dec8a New Unit Type Editor UI in Scenario Editor 2024-03-26 13:23:38 -05:00
Rafael Fillipe Silva
c7e643bffd add a test to cover the fix to find_key's infinite loop/crash
Adds a test with a schema example containing a super cycle and a .cfg file containing an unknown key to this schema. Previously, this would cause an infinite loop or crash. Now an exception for invalid key should be thrown.
2024-02-26 10:12:43 -06:00
Rafael Fillipe Silva
fd6cd7c2a2 add tests for super cycle detection on schema self validator
Add test for the already existing validation where a tag shouldn't set itself as its own super.

Add test for the new cycle detection when validating a schema.
2024-02-26 10:12:43 -06:00
Subhraman Sarkar
6c5a8e923d
Spinner and multiline textbox widgets (#8199) 2024-02-13 11:54:34 -06:00
Eugene
9f99a4ef7d
Simplify nearest neighbor rescale (#8240) 2024-01-20 16:50:14 -06:00
Subhraman Sarkar
f1f67ae5df
Add functionality to Time Schedule Editor (#8066)
selected schedule will write to utils/schedule.cfg on scenario save

HOTKEY_EDITOR_CUSTOM_TODS is disabled unless user loads scenario

custom_tod:Preview button and associated callback added.

editor:translatable attributes now written with leading underscore

editor:support for multiple custom time schedules
2023-12-14 17:12:07 -06:00
Steve Cotton
cc8dddea6e Support negative numbers in ranges
Adds support for using these in the weapons and ability filters:
* "-1", which was previously treated as an parse error (no number before the separator).
* "-3--1"
* "-infinity" as the lower number in the range, provided a different upper number is given.

This treats "-infinity" (with no other number), "-infinity--infinity",
"infinity" (with no other number) and "infinity-infinity" as errors. It seems
unlikely that someone would intend to use a filter that can't match any
reasonable number.

The range "-infinity-infinity" will be parsed successfully. I don't see a use
case for that, but nor do I see a reason to add extra C++ to reject it.
However, it's not added to the schema, as I think it's good for the schema to
give a warning when someone creates a filter which will accept every value
(including accepting the default, so "-infinity-infinity" accepts the unset
value too).

Includes new unit tests for the C++ and the Lua stringx.parse_range functions.
The next commit adds more WML tests, but is kept separate to credit the author.

This started as a change to move common filter functions from unit.cpp to
somewhere that they could be reused for other config-based filters. In the
process a missing feature was found and added, the move is still included in a
single Git commit because the move was required in order to make these
functions accessible to the Boost unit tests.

Two CodeBlocks project files additionally get src/utils/any.hpp added,
which was in one of them but missing from the other two. I noticed because
these are alphabetically at the start of the src/utils file list.

Thanks to @CelticMinstrel for the review comments and Xcode project updates.
2023-08-11 21:59:06 +02:00
Pentarctagon
10997c39a3
Start giving the editor add-on level functionality. (#7719)
The key word of course being "start". This PR changes the editor by default to work at the add-on level instead of in its own separate scenarios and maps directories. The goal is to make the editor more useful generally, but also specifically to make it much easier for players to distribute content they create using the editor:
* When they click the Editor button on the main menu, they will first be prompted to choose an add-on (or mainline), or to create a new add-on.
* When saved, if the scenario cfg is in the format previously generated by the editor, it will be converted to the new format and to use the [multiplayer] tag, the map_file attribute, and have the map data saved to a separate .map file.
* Relatedly, the editor now knows how to handle scenarios with the map_file attribute at all (which yes, does mean that currently wesnoth's editor doesn't know how to load its own mainline scenarios from their cfg).
* When opening the file chooser dialog, it now defaults to their selected add-on's directory.

If they choose to create a new add-on, then the editor creates for them:
* a basic but functional _main.cfg.
* an empty achievements.cfg (at this point mostly just so they might see it at some point and realize achievements exist, but ideally an achievements editor dialog could be created eventually).
* an empty _server.pbl file.
* a proper add-on directory structure containing the standard set of folders (maps/, scenarios/, units/, utils/, images/, etc).

Additionally, as an initial proof of concept for actually using this new add-on level functionality, a new Add-ons dropdown has been added to the editor's top bar, with a pbl editor option. This allows populating the blank _server.pbl file as well as editing an existing _server.pbl. There is also an option to change the add-on's ID, which will update the add-on's folder name and _main.cfg.

Misc other changes:
* The ability to add a recruit list to a side has been added back as a text box on the edit side dialog. While admittedly this doesn't allow players to select units from within the editor itself, it does set the actual side's recruit list (rather than a specific unit's extra_recruits), will show the user what the current recruit list for the side is (which the previously removed implementation didn't show anywhere), and correctly sets the faction as Custom so that the recruit list is used.
* When saving an old-style editor scenario, everything that can be triggered via [event] is either moved to a start event with a specific id attribute. Exceptions to this are [time], [side], and [side][village]. This is done so that the editor can know (for the most part) what things are actually its own to safely replace. As such, aside from the three previously mentioned tags plus the start event, any other WML added to a scenario by a UMC author is preserved rather than being overwritten - the editor no longer replaces the entire contents of the scenario file.
* The editor no longer writes out cfg files missing the top level scenario tag. If it doesn't find one or this is the first save of a new scenario it defaults to [multiplayer], but otherwise it will properly handle finding [test] or [scenario] as well.
* Requires that map files have the .map extension and scenario files have the .cfg extension. Also it assumes that .map files do actually only have map data in them and the .cfg files do actually have valid WML in them. I understand that this is not a limitation it had previously, but I don't think this is an unreasonable thing to require.
* Addresses part of #7667 by just not using regex for figuring out the map_data attribute value.

Additionally, it is not possible to change the currently selected add-on without going back to the main menu, clicking the editor button, and choosing a different add-on. This is intentional - I don't want to deal with having multiple add-ons open at the same time. If someone feels really strongly otherwise, then they can implement that themselves later.
2023-07-19 15:00:14 -05:00
Pentarctagon
f6be887a91
Let wesnothd and campaignd build without SDL. (#7621) 2023-05-12 19:30:38 -05:00
gfgtdf
01f28b12ae Refactor statistics
Previously statistics were stored in global variables, now
it is a part of saved_game. With this saved_game now finally
represent the contents of a safefile as it was intended to,
without needing to fill the statistics part in some global
variable. (See also #4672 )

In particular now no longer have to manually reset the
statistics as random parts of the code, it gets reset
along with the saved_game object. Also it is now in theroy
possible for multiple saved_game objects to exist.

Statistics was split in two objects, the statistics_record
which only contains the data, and statistics_t, which
provides methods to modify statistics during a game (to get
cleaner dependencies)

This fixes multiple related bugs with statistics in replays:
- #4133 (stats not bring reset when loading a replay)
- #4133 (duplicate entry for current scenario in replay)
- #4441 (wrong stats at the beginning of a replay)

And issues with statistics being lost for non-host players when
reloading a game in (online) mp (no ticket for that one found).
2023-05-04 21:25:55 +02:00
gfgtdf
d954d307bc move carryover message to new file
This will in particular make future refactors of that code easier.
2023-03-18 19:04:39 +01:00
Pentarctagon
9315079389 Add curl-based functionality to download files from a URL.
This is a complement to #7416 where it replaces opening the replay's download URL in a browser with directly downloading it into the player's save folder.
2023-03-15 14:49:16 -05:00
Pentarctagon
d1465a9eb9
Add basic achievements functionality. (#7237)
* Add basic achievements functionality.

This reads the mainline achievements.cfg and then all the achievements of each installed add-on.

This is intentionally handled separately from other WML loading so that:
a) All achievements and their status are able to be displayed on the main menu right after Wesnoth starts and regardless of which add-ons are active.
b) Add-ons can add additional achievements to other content, whether UMC or mainline. For example, a modification that adds more achievements for mainline campaigns.

Marking something as achieved is handled by the new [set_achieved] tag and whether an achievement has been completed can be checked via [has_achievement].

There is no attempt to prevent people from manually editing which achievements they've accomplished.

NOTE: These are *not* in any way related to Steam achievements!
2023-01-21 10:32:45 -06:00
Pentarctagon
0e85fac29c
Have /report show a dialog for entering information. (#6969)
Resolves #5056
2022-09-02 21:18:03 -05:00
Iris Morelle
532ec4e06f addon/client: Add modeless dialog for displaying add-on install progress
This implements an add-on extraction progress dialog that does not
actually run its own event loop, allowing the caller to take ownership
of it (display() static method) and update its state using a callback
function object. The object in question is passed into the add-ons
management API and used to update the dialog status each time an add-on
file is written to disk as part of the pack extraction process.

In order to avoid stalling the extraction process in UI code, the
callback is invoked for every single file, but the dialog's progress
update method places a time restriction on GUI2 API calls of 120
milliseconds -- this is a good throttle interval that allows add-ons to
be extracted in about the same amount of time as before while still
updating the progress bar smoothly enough for add-ons that take longer
than that.

(This is not the most trivial code to test, so it is suggested to add a
sleep/delay API call in unarchive_file() in src/addon/manager.cpp to
introduce artificial delays.)

One issue with this code, however, is that because modeless_dialog
doesn't execute its own event loop, the only way to get the dialog to be
updated is to force a draw event in ourselves via the new
gui2::dialogs::modeless_dialog::force_redraw() method. This is really a
side-effect of my design choice here to run the dialog in the middle of
a blocking operation instead of somewhere where events are being
processed normally. I'm not entirely sure if the draw events would be
pushed even in that case, however.

Closes #1101.
2022-08-06 15:11:41 -05:00
Pentarctagon
a6fedd1847 Fix wml_exception getting thrown. 2022-08-06 03:03:17 -05:00
Pentarctagon
b586e38e30 Move simple_wml unit test into the actual unit tests. 2022-07-30 00:07:46 -05:00
Tommy
3dbf212f8c Add a draw manager, to manage drawing to the screen
There is a new global interface draw_manager which handles drawing,
and a new abstract base class top_level_drawable (TLD) to indicate
that an object is something that has a place on the screen and should
be drawn.

Basic usage is fairly straightforward. Top-level objects (such as
windows) inherit from top_level_drawable. They must implement the
functions layout(), screen_location(), and expose().

layout() should ensure that screen location and animations are current.
screen_location() should return the current draw location on screen.
expose() should do the actual drawing.

The draw manager keeps track of what regions of the screen, if any,
need to be redrawn. Regions must be invalidated by calling
invalidate_region(rect). This can be done at any time other than during
expose(). It must not be called during expose().

The draw manager has one main callable function, sparkle(). This may
be renamed at some point. It manages calling the TLD functions on all
TLDs in the correct order. It also manages loop delay and vsync.

The standard game loop now becomes:
1. events::pump()
2. draw_manager::sparkle()
2022-07-13 13:34:01 +12:00
Pentarctagon
ebd7be37aa Remove unused source file. 2022-07-06 20:11:11 -05:00
Celtic Minstrel
3bd8d82d4a Patch up some missing bits in the GUI2 iterator system 2022-06-10 23:31:40 -04:00
Tommy
96bc7d6046 Consolidate drawing functions in new "draw" namespace.
Contains primitive drawing functions, such as fill, points, line, etc,
and also texture drawing functions blit, flipped, tiled.

This removes specialty drawing code from several places, most notably
CVideo and gui/core/canvas.

Functions to draw to the screen should now go in draw.cpp.
2022-05-31 21:17:33 +12:00
Tommy
581c6e6a93 video: Add functions for immediate rendering of surfaces and textures. 2022-05-08 11:08:57 +12:00
Charles Dang
0a265d1c51 Re-added SDL_Texture wrapper and render utils
These were from the last attempt at accelerated rendering. We might be getting somewhere this time...
2022-04-30 16:57:59 -04:00
Tommy
ab10d4d219 Fix remaining input issues with scaled display.
There is a new sdl::get_mouse_state() function that should be used in place
of SDL_GetMouseState() in every case. It returns coordinates relative to
the drawing surface.

With this, the pixel scale option seems to be working without issue.
2022-04-18 17:25:06 +12:00
Pentarctagon
5155a74f4f Make lua a submodule.
No changes required to the lua source anymore.
2022-03-09 15:01:37 -06:00
Pentarctagon
573901376a Un-rename lua source files to .c
Being .cpp isn't required to have them be compiled as C++.
2022-03-09 15:01:37 -06:00