120 Commits

Author SHA1 Message Date
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
Pentarctagon
c4c292fa3b Replace all remaining usages if MAKE_ENUM. 2022-03-03 21:23:02 -06:00
Charles Dang
cc5e67e373 Forgot to commit the source_lists change 2021-07-30 23:28:05 -04:00
Pentarctagon
e5b4a39242
Add a prompt to migrate data from previous versions of wesnoth.
Currently migrated, if existing:
* Add-ons (redownloaded if present on new add-ons server)
* Preferences file
* Credentials file
2021-07-15 20:16:17 -05:00
Pentarctagon
08bfe41b9e Move password hashing to server_base.
This is in preparation for adding the `forum_auth` option when uploading an add-on.
2021-06-01 13:47:48 -05:00
loonycyborg
f59f5a4091
Load system certificate store manually on Windows because boost.asio doesn't 2021-05-22 01:06:10 +03:00
Celtic Minstrel
a09f88c1c9 Start a Lua mathx module to hold round, shuffle, random, and a few other things 2021-05-08 17:20:47 -04:00
Pentarctagon
b95d72f9c1 Use cmake to create VS project files.
Due to an upstream change in vcpkg that breaks the simple integration previously available with `vcpkg integrate install`, building using that setup method is no longer possible. In order to work correctly, cmake must instead be used to generate the VS project files, since that is able to integrate with vcpkg, since vcpkg also uses cmake to build all the library dependencies.

An additional benefit of this is that it will no longer be necessary to separately update the VS project files since it will read the same source_lists files as cmake (on linux) and scons do.

This also enables running the WML unit tests on Windows with this in order to confirm that a valid wesnoth.exe is in fact being generated as well as fixes building the boost unit tests.

The warning level for both release and debug builds are now at level three, the remaining warnings have been fixed, and therefore strict builds have been enabled - any warning will now cause the build to fail, just like for the linux jobs.

Known issues:
* The boost unit tests don't actually run successfully - they fail on CI at least with an exit code on 201 - however I don't know if this is a real problem or just a problem with running headless on CI.
* The debug build doesn't quite work since the executables are built against the non-debug dlls but cmake copies over the debug dlls into the output directory. For now this can be worked around by copying the release dlls into the debug directory.
* The instructions in INSTALL.md are not very good since I don't use Windows and thus can't write anything more detailed. Ideally someone who uses Windows can add more detailed step by step instructions at some point.

Fixes #5741
2021-05-07 00:02:02 -05:00
Pentarctagon
6b97a76109 Add a prompt to allow entering an add-on's password at upload time.
This is an alternative to needing to store the plaintext password in the _server.pbl.
2021-04-04 01:28:23 -05:00
Iris Morelle
055eb13e67 Move font::is_cjk_char() to help browser implementation 2021-03-13 13:51:47 -03:00
Iris Morelle
2dfdc0061d Remove SDL_ttf wrapper API
This removes the build-time dependencies on SDL_ttf and FriBidi,
alongside the SDL_ttf wrappers, the SDL_ttf text surface class, the
SDL_ttf render cache, and the SDL_ttf (de)initialization code.
2021-03-13 13:51:47 -03:00
Iris Morelle
8cd739cef1 font/sdl_ttf_compat: Initial Pango-based font rendering API for GUI1
This adds a minimal wrapper around pango_text intended for use in GUI1,
in particular for the help browser. Functionality is very incomplete
right now but for the time being we can render text, determine line
dimensions, and ellipsize text, which is almost the bare minimum needed
for porting the Help system (it's still missing a word wrapping
implementation).
2021-03-13 13:51:47 -03:00
Pentarctagon
b974423e2e Add optional fuh to campaignd. 2021-03-12 16:12:09 -06:00
Charles Dang
561cc33dc4
Upgrade to Lua 5.4.2 (#5535)
The change to static_cast for the definition of  LUAL_BUFFERSIZE replaces the fix previously used (d0100758f855ec0d8f30dff41e8a8b6ff2d45fda) for Lua 5.3. 5.4 removes the static alternative for LUAL_BUFFERSIZE. A better solution would probably be to disable the old-style-cast warning for luaconf.h, but I can't figure out how to do that so using static_cast is the easiest solution. Do note that change will have to be applied each Lua update like the aforementioned commit.
2021-02-14 02:07:12 +11:00
Charles Dang
e3f8b68796 Added basic dialog definitions for the Match History viewer 2021-01-17 11:48:21 +11:00
Pentarctagon
5ee08c80fb Add support for asynchronously querying a player's game history for display on the client. 2021-01-16 12:48:07 -06:00
Steve Cotton
4205de91e5 Remove the editor's unused set_starting_position dialog
6424d79f489129791fedb23e267565922dba3751 changed to using an editor palette instead.
2020-12-30 15:01:47 +01: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
Iris Morelle
8c3918197c gui/addon_manager: Add dedicated license prompt dialog
This allows using full markup for the license text and making it
independently scrollable without messing up the dialog. It also enables
URL parsing in it.
2020-12-10 00:15:17 -03:00
CrawlCycle
a6f36becb9 Test parsing of WML define and undef macros by the preprocessor & parser
This commit adds tools to test parsing of WML macros by the preprocessor
and parser. The commit also adds two tests of the #define and #undef
WML macro as examples.

The tests consist of three steps:

1. Define one WML string containing macros and one WML string
   that lacks macros in each test. The two WML strings should be
   equivalent after preprocessing.

2. Transform each WML string into a syntax tree (represented by config
   objects) with the preprocessor and parser of Wesnoth.

3. Check if the two config objects are equal. Since the two WML strings
   are equivalent, the two configs object should be equivalent if the
   preprocessor and parsers are both correct.

The output of the preprocessor is in an undocumented format. Therefore,
this commit does not test the preprocessor as an isolated unit.
2020-11-28 14:52:48 -05:00
Iris Morelle
227738cb6f campaignd: Command line processing w/ Boost.program_options
This also adds a few utility switches which people are probably already
familiarized with from the game proper. Most notably this means I don't
need to alter and recompile campaignd any time I want different logging
settings.

There's some functionality commented out in this commit while I figure
out how to wire it into the campaignd server class.
2020-11-09 21:22:00 -03:00
Iris Morelle
145c986a5c Move argv repackaging logic out of wesnoth.cpp
This includes all the Win32-specific code dealing with the retrieval of
the UTF-16 version of the command line and subsequent parsing into an
array of UTF-8 strings.

The latter code is unchanged except for the function names and one local
variable originally named `is_excaped` instead of `is_escaped`.

(Note to self: ask gfgtdf if he was aware of the existence of
CommandLineToArgvW() back when he wrote the Win32 command line retrieval
logic.)
2020-11-09 21:22:00 -03:00
Iris Morelle
cfa0342829 campaignd: Move auth functionality out of server.cpp 2020-11-01 16:11:20 -03:00
Steve Cotton
934cae6093 Refactoring the orb-coloring code, adding new units/orb_status.hpp
Instead of creating lots of image::locators and calling a family of
similarly-named preferences functions, this refactor encapsulates that logic
and uses an enum.

The new orb_status files still need adding to the MacOS build.

An assert has been added to `unit_drawer`'s constructor. There are two callers
- the `display` class guards it with an explicit check before constructing
unit_drawer. The `game_display` class doesn't have an explicit check, but it's
clear that other code in that class assumes the teams are already valid (and
would crash if they weren't).
2020-10-17 14:11:10 +02:00
Steve Cotton
a2b98687b7
Update the VC16 project files for Lua Widgets (#5125)
In source_lists/wesnoth, put the new files in alphabetical order.

This (as expected) fails to build on MacOS, just like the previous build.

It also fails to build with Clang on Linux, just like the previous build. That's
caused by src/scripting/push_check.hpp:89's unused parameter 'L', and is
also just like the previous build.
2020-09-04 05:44:15 +02:00
gfgtdf
90a5930f21 new lua gui2 widget userdata
lua now has a widget userdata that can be used
to set/get widgets properties as one would
expect, a lot of the set/get_dialog_xy function
were converted into modifiable properties of
the widget userdata. This in particular allows
us to get rid of the strange 'path to widget'
type of arguments of gui2 functions.

It currently generates lot of compiler wanrings,
I will fix this in a later commit.

One of the main advantage is that it makes it
much easier to add new api, previously a lot
of functions where overused, probably because
that was just easier than creatign a new
function. For example set_dialog_value returned
multiple value of listbox objects. (the
compatibility path doesn't support this
particular feature yet but i don't think it is
important, it probably wasn't even used at all,
since it also wasn't documented).

This also adds some new features, like an 'add_item'
function to add an item to a listbox, a 'type'
property of widgets to query the type of a
widget and a 'item_count' property to count the
number of children in an item.

Im still not 100% sure about the
property /function names, in particular:

1) i might rename 'items' to 'elements' or
   'children' in some functions. Not sure yet
2) I might rename the 'value' property to
   'value_compat' to make clear that its only
   supposed to be used by the
   backwards_compat.lua code.

A next step in improving this api might be
to introduce a (reusable!) 'window' userdata
so that the implementaion of wesnoth.show_dialog
would become:
```
function wesnoth.show_dialog(wml, preshow, postshow)
  local dialog = gui.create_dialog(wml)
  preshow(dialog)
  local res = dialog:show()
  postshow(dialog)
  return res
end
```

However this is currently not really possble
since the pure existance of a gui2::window
object blocks the gui1 code (the main game view)
from receiving events. So we clearly cannot luas
gc take ownership of gui2::window objects.
2020-09-03 22:08:53 +02:00
Pentarctagon
46f74f0ebb Move campaignd and wesnothd files into more descriptive locations.
Also fix a few cases of not specifying the full path to header files.
2020-08-06 12:16:18 -05:00
Pentarctagon
113a4e0913 Use mariadbpp rather than the mysql C connector.
Reasoning being:
* The result_set and other APIs are nicer to use.
* We use mariadb on our server rather than mysql, so this would minimize the chance of any incompatibilities.
* The mysql C++ connector 1.1 isn't compatible with with c++17 (https://stackoverflow.com/q/47284705).
2020-07-30 13:17:22 -05:00
Pentarctagon
f996803cf6 A separate button for info/announcements.
Rather than having everything in the MOTD, this adds a separate button that will popup a window which will have most of this information in two tabs:
* General server information, such as a link to the CoC.
* Announcements, such as tournaments and new versions being released.

The information on this new window will be stored in the new `server_config` database table.
The MOTD will then just be a short greeting instead of the several lines that are shown currently.

Additionally, now the motd will only be displayed in the lobby chat the first time the user logs on.
2020-07-30 13:17:22 -05:00
gfgtdf
93aa2ca409 deploy new game_config_view object
the game_config_view object offers const
access to the game_config object, furthermore
it allows the game_config config object to be
replaced by a vector of config objects which
is what we will do later.
2020-06-29 15:16:05 +02:00
gfgtdf
f9790bcb5d add wesnoth.colors
see #3706

the main usecase to be able to show messages and
dialog labels in the color of a specific team.
2020-03-16 00:29:57 +01:00
Celtic Minstrel
1323e75ee2 Split out the main core modules of Wesnoth (wml, gui, stringx) into separate C++ source files
And load them with lua_requiref because we can.
2019-12-09 21:54:28 -05:00
Charles Dang
15bf3bb256 Removed scaling algorithm customization
We're going to be using NN scaling for the map, and that's already handled automatically
by SDL (and in the future, OGL). We don't need these settings for surface SCALED_TO_ZOOM
and SCALED_TO_HEX scaling. In any case, if we want to scale a surface to zoom or hex, it
will almost certainly be for map rendering (such scaling methods don't make sense in the
UI, for example), so just defaulting to NN is simplest.

This change drops the option to use Linear or xBRZ scaling for map zooming. This was already
the practical case due to me converting map rendering to use textures. NN was used for all
zoom levels, and it's fast and looks good.
2019-11-05 22:55:05 +11: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
Celtic Minstrel
7c07cc71c0 Remove support for legacy menu markup 2019-09-18 22:48:53 -04:00
Pentarctagon
77fc455b0b Remove sample_user_handler.
While I understand the reason it's here, it's been over a decade, no other user handlers have been added, and there's no indication any others will be added. Therefore, it doesn't seem like there's much of a reason to keep this code around.
2019-08-22 10:41:51 +02:00
Iris Morelle
37cca84684 Add utils::format_timespan() for formatting time lengths for user display 2019-03-01 02:29:20 -03:00
loonycyborg
34e2ef12c7 Add support for ipv6 addresses to addon client and multiplayer client
ipv6 address must be specifid surrounded by [], like [ipv6_address]:port,
since otherwise impossible to disambiguate colons separating ipv6 quads
from the colon delimiting port
2019-01-04 17:45:39 +03:00