116 Commits

Author SHA1 Message Date
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
Iris Morelle
dce011919c Add -Wno-shorten-64-to-32 to compiler flags in Xcode
This is necessary with Xcode 15.3 to avoid about 750 warnings across
all of the codebase regarding "Implicit conversion loses integer
precision", most of which apply in cases where theoretical limits are
involved because of conversions from unsigned 64-bit integers (usually
size_t) to signed 32-bit (int).

Ideally we want to address these warnings, but given how many of them
there are all over the place this is not something that can reasonably
be done in such short notice before Wesnoth 1.18.0 is released, and in
the meantime they make the compiler output with Xcode unnecessarily
noisy and completely bury any relevant warnings from actual code
changes. In the meantime, this is best for productivity until we can
get to a place where we can fix all of them and force using
-Wshorten-64-to-32 for all platforms in CI.
2024-03-13 23:04:29 -03: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
Rafael Fillipe Silva
dafb78cdf1 implement super cycle detection for the schema self validator
The super tag dependency forms a directed graph. Boost Graph's depth first search implementation was used with a back edge detector to find the cycles.

This is a preparation for enumerating all keys that a tag can use, including the keys from the super tags. If cycles aren't handled, it is impossible to validate mandatory keys without entering an infinite loop.
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
Martin Hrubý (hrubymar10)
9125f7dab0
Fix Xcode builds 2023-12-19 17:04:46 +01:00
Martin Hrubý (hrubymar10)
be04167fff
Fix Xcode build on newest macOS versions 2023-12-17 19:24:58 +01:00
Martin Hrubý (hrubymar10)
23f3a7fe9c
Switch Xcode builds to the new MCS 2023-12-17 19:24:58 +01: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
Gunter Labes
2e191db2e7
Ignore implicit conversion warnings 2023-11-04 22:48:45 +01: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
Iris Morelle
948f3555e1
campaignd: Fix link-time options for Xcode build
This copies the same runpath search paths already used for wesnothd
to enable campaignd to run at all.
2023-05-23 17:46:51 -04: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
6fe2627048 Fixup, complete, and enable the lobby's game history viewer.
At some point in the future I'd like to come back and add some search parameters - right now it shows the game history of the currently selected player in the lobby, but ideally it would instead have options for player name, era, scenario, etc.
2023-03-11 10:55:55 -06:00
Celtic Minstrel
6722f04510 Xcode: Pass --no-log-to-file in the scheme
[ci skip]
2023-01-25 19:41:55 -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
Pentarctagon
72a1c801c0 Log exception type when doing catch(...). 2022-08-25 22:22:22 -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
Celtic Minstrel
9edb9cdc16 Update Xcode project 2022-07-30 00:07:46 -05:00
Martin Hrubý (hrubymar10)
698f93f68e
Update Xcode project for new MCS 2022-07-17 19:58:45 +02:00
Gunter Labes
c4635b1058 Update Xcode project 2022-07-13 13:34:01 +12:00
Celtic Minstrel
a1eb63b359 Xcode: Disable header maps
This makes the Xcode build's way of locating headers be similar to other compilers.
The header maps feature means you can include any header in the project just by the filename,
but none of the other supported build systems allow this, requiring a full path relative
to the src directory.

By disabling header maps, Xcode will give an error if you miss the file path
(unless including a file in the same directory).
2022-07-07 22:05:33 -04:00
Celtic Minstrel
e39f91682a Xcode: Remove the DYLD environment variables from the unit test scheme
It runs without them so there's no point in them being there.
2022-07-02 09:55:14 -04:00
Celtic Minstrel
b22f57ea08 Xcode: Sadly the internal output console doesn't support colour 2022-07-02 09:55:10 -04:00
Celtic Minstrel
d3124af4a5 Xcode: Add additional command line parameters in the unit tests to match those passed in the CI 2022-07-01 23:08:38 -04:00
Celtic Minstrel
c2593ff79c Xcode: Set correct working directory for unit tests 2022-07-01 22:36:49 -04:00
Celtic Minstrel
8ba57c4290 Allow specifying where the unit test output file is
The default location probably makes sense on Linux or Windows, but it is nonsensical on Mac and breaks the game's build when the tests are run.
2022-07-01 21:50:11 -04:00
mattsc
1f9f7a076c Boost unit tests: fix Xcode warnings 2022-07-01 15:30:28 -07:00
Celtic Minstrel
8cb19eafbf Xcode: Add a sample command-line argument to the unit test scheme 2022-07-01 15:54:17 -04:00
Celtic Minstrel
3d20ea27d2 Xcode: Copy additional libraries so the unit tests can run 2022-07-01 15:42:21 -04:00
Celtic Minstrel
eddd762615 Xcode: Add additional rpath entries to wesnothd
This should allow it to run in different configurations:
- When clicking "run" in Xcode, it's adjacent to the Wesnoth applicaiton
- If you wanted a standalone install of wesnothd you'd now only need to copy over the Frameworks directory.

All of this assumes that wesnothd will run at all, which works with a debug build but probably not in the actual release.
2022-07-01 15:39:26 -04:00
Celtic Minstrel
864666f1dc Xcode: Set unit tests runpath correctly 2022-07-01 15:36:08 -04:00
Celtic Minstrel
bcdecb1185 Xcode: Update unit tests working directory 2022-07-01 15:35:37 -04:00
Celtic Minstrel
b14061d619 Xcode: Fix link errors in unit tests 2022-07-01 15:12:33 -04:00
Celtic Minstrel
348834b03a Xcode: fixup log option in the scheme 2022-07-01 13:57:41 -04:00
Celtic Minstrel
12b52ea179 Xcode: Add a bunch of useful command-line options to the scheme, but defaulted to off.
The motivation for this is that Xcode is (for some reason) incapable of automatically reloading a scheme that has changed on disk, and overwrites it the moment you try to edit it with whatever it has in memory.

With this change, the information lost when it does that will be much less; in many cases, just a checkbox to toggle back on.
2022-07-01 13:56:46 -04:00
mattsc
1945c6a255 Xcode project: use same warning flags for debug and release builds 2022-06-23 07:00:42 -07:00
mattsc
e776d8c8d9 Xcode: enable strict builds 2022-06-23 07:00:41 -07:00
mattsc
6786b26b2a Fix Xcode warnings 2022-06-23 07:00:35 -07:00
mattsc
c5c0217aa0 Enable LTO for Xcode Release and SignedRelease builds 2022-06-18 08:05:05 -07:00
Martin Hrubý (hrubymar10)
335a8739f9 Add new SignedRelease build configuration to Xcode project 2022-06-17 14:27:14 -04:00
Martin Hrubý (hrubymar10)
4832912cca
Fix Xcode project DEBUG scheme builds 2022-06-14 10:05:09 +02:00