Commit graph

89 commits

Author SHA1 Message Date
Jyrki Vesterinen
af418d86f4 WIP: texture atlas class
Currently only loading images and applying IPFs is implemented.

Most code here is copy-pasted from picture.cpp, I'm planning to eventually
remove that file.

Next task is implementing the actual sprite packing.
2018-10-10 15:03:19 +03:00
Jyrki Vesterinen
9f1e4564df WIP: thread pool class
For now it's missing ability to, you know, actually run tasks.
2018-09-27 21:30:51 +03:00
Jyrki Vesterinen
34b7903d25 Add a shader class 2018-09-27 20:04:53 +03:00
Jyrki Vesterinen
0992605c5d Add sprite, draw_op and vertex classes 2018-09-27 20:03:46 +03:00
Jyrki Vesterinen
73caa6da64 Add a texture class 2018-09-27 20:03:45 +03:00
Martin Hrubý
50301f84e3 Fix building with Xcode 10 (#3460)
Resolves #3458.
2018-08-16 15:06:00 +03:00
Charles Dang
458dd284b8 GUI2: removed 2010 experimental listbox
This was never finished, is not maintained, suffers from a lack of features the "old" listbox
class now has, and seems (according to the logs) to be have been superceded by the pane widget.
At the very least, the pane widget seems to be what mordante was working with in his early
prototype of a new addon manager, and not this 2010 list class.
2018-07-02 22:22:17 +11:00
Charles Dang
dd69107c9b 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.

As for why I've decided to stick with nearest-neighbor scaling for zoom, it happens to look
a lot better when done on the GPU than on the CPU for some reason (perhaps having to do with
the old rendering pipeline in which we were doing surface scaling), and it's better to have
a consistent scaling look as you zoom in, especially if we wanted to do animated zoom-ins.

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.
2018-06-25 16:37:27 +11:00
Charles Dang
15917733e0 GUI2: removed legacy DescriptionWML parser
It's no longer needed.
2018-06-24 04:15:58 +11:00
Pentarctagon
0a7ed44c08 Remove unused test file and images. 2018-06-20 18:46:01 +11:00
Charles Dang
e0beff6615 Rename gettext_boost.cpp to gettext.cpp
Since there isn't another version anymore.
2018-05-16 12:06:48 +11:00
Charles Dang
e0192b1b1f Renamed filesystem_boost.cpp to filesystem.cpp 2018-05-13 00:10:56 +11:00
pentarctagon
07e01cd9b8 Fix a header file being in a source list. 2018-04-25 18:45:10 -05:00
Jyrki Vesterinen
a02100a0f1 Implement saving MP chat message history (#1194, #2802) 2018-04-17 22:29:26 +03:00
Charles Dang
d384b96d97 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.
2018-04-14 14:16:18 +11:00
Charles Dang
f7d2924b27 Added initial implementation of a dynamic spritesheet generator
This isn't used anywhere yet. Right now it only takes a directory and generates one
sheet for all the images in that directory and its sub-directories. The sheets are
fully-functional textures, and a path -> rect mapping exists, but I haven't added anything
that uses it yet.

This will definitely need some improvements and changes to properly integrate with @jyrkive 's
OGL work.
2018-04-10 03:03:56 +11:00
Charles Dang
23e78abb20 Help: massive refactor and cleanup of the help backend
This basically splits all the stuff in help/help_impl.*pp into multiple files by their
function, and refactors the entire workflow into a proper object-oriented interface in
modern C++.

There are still a features missing (such as hidden section parsing in the manager) that
I'll get back to.

Few incidental changes and fixes:
* Terrain topics now sorted alphabetically.
* Help text now small
* Fixed wrong toggle button id in browser. This is what was making it impossible to expand
  any sections.

The GUI2 help browser is now back in working order, inasmuch as you can view all sections'
and topics' text (save units').
2018-04-03 11:51:57 +11:00
Charles Dang
c198be1fa8 Removed the SDL_TTF and GUI1 font rendering API and associated functions
This removes all functions related to:
* GUI1 font formatting
* GUI1 font rendering
* Manual text surface size calculations
* The font description interface. While it wasn't exclusive to the TTF rendering system,
  it was unused by Pango/Cairo rendering.

A huge chunk of the help browser code was commented out since we don't have font::line_width anymore.
Likewise, a hack was added to the GUI2 text box since we don't have have get_max_height anymore.

font::is_cjk_char was retained (as well as some related helpers) since they might be useful
later.

I'll leave it to someone else to update the CMake/Scons files to remove TTF as a build
dependency.
2018-03-26 14:08:45 +11:00
Charles Dang
34797ed1a2 Removed or commented out (for reference) all uses of the GUI1 button widget
And removed said widget.
2018-03-26 13:13:17 +11:00
Charles Dang
239fde451a Removed the old surface drawing queue implementation, except for the layer enum
Kept that since it's still used in some places and is good for reference.
Also removed display::get_screen_surface which was used in said impl.
2018-03-20 22:07:34 +11:00
Charles Dang
28d2be4bec Removed a whole bunch of GUI1 stuff
This almost completely removes GUI1, save for the button widget (will remove once I get
all the Theme handling sorted out) and the editor's own GUI1 widgets.

This includes the GUI1 textbox, scrollbar, scrollarea, and menu widgets, as well as the
dialog_frame and dialog_manager classes. I've also removed floating_textbox. It was only
kept around for reference (it's unused as of the inclusion of the GUI2 command console).

gui::in_dialog has been replaced by GUI2's is_in_dialog directly now that we have no more
GUI1 dialogs.

\o/
2018-03-20 21:07:59 +11:00
Charles Dang
5022a38608 Removed GUI1 Help interface code
Not needed anymore since we're moving to GUI2 for this dialog.
2018-03-20 19:21:33 +11:00
Charles Dang
075a9bac34 Get the GUI2 in-game UI at least appearing
I decided to go with a modular approach, where both in-game and editor UI dialogs inherit
from a single base class, a pointer of which is owned by the display class. That can be
used for common functionality that needs be shared by all in-game dialogs.

Right now the new UI is just static. It works with most stuff, but not key presses. Working
on that...
2018-03-20 04:47:42 +11:00
Charles Dang
d23d1ea338 Renamed drawing_buffer to drawing_queue
Also renamed drawing_queue::drawing_layer to just 'layer'.
2018-03-19 01:22:28 +11:00
Charles Dang
ed27b67f1e Port floating textbox/command console to GUI2
The old floating textbox was extremely entwined with the controller_base, play_controller, and menu_handler
classes. controller_base::have_keyboard_focus essentially controlled whether some events were executed based
on whether the floating textbox was open or not. Additionally, those events weren't even reached if a UI dialog
was open at all.

The new design features a singleton console class that can be called from anywhere, not just the game. I've also
decoupled the execution object from play_controller. The relevant functions in menu_handler are now passed to
the console as callbacks.

To work around map events such as clicking not being available if the console was open, I removed the exclusionary
is-in-dialog check from controller_base::handle_event and instead exit early out certain types of events using
controller_base::have_keyboard_focus. As mentioned in the accompanying comment, this isn't the best solution, but
it will do for now.

The new console also isn't fully feature-comparable with the old GUI1 one. The following are still missing:
* The checkbox, for use when sending messages.
* Tab completion.
* A crash occurs when existing the app if a game was exited with the console open.

I'm leaving the old floating_textbox code around for now for reference.
2018-03-19 01:22:18 +11:00
Charles Dang
8a82d43855 Some initial code (disabled for now) for setting up an OGL context
In the interests of getting this all done faster, I've decided to postpone work on the OGL implementation for now
and focus on the SDL_Renderer version. This contains some basic code (include-guarded) for setting up an OGL context
for the main SDL window.
2018-03-19 01:22:01 +11:00
Charles Dang
8dc661db40 Decoupled drawing buffer code from display class 2018-03-19 01:14:02 +11:00
Charles Dang
e30a2aa520 Added static prototype for GUI2 in-game theme 2018-03-19 01:14:00 +11:00
Charles Dang
56a793c086 Added SDL_Texture wrapper class and some utility functions 2018-03-19 01:13:47 +11:00
Alexander van Gessel
0ed7ff100a
Factor out base64 and crypt {en,de}coding
Base64 according to RFC4648.
Crypt64 is whatever crypt() does.

The two radix-64 encodings share less code than I would like,
because base64 is stream-oriented and therefore big-endian,
while crypt is little-endian.
2018-03-16 07:57:51 +01:00
Gregory A Lundberg
a3c46d3639 Upgrade to PHP 5.6.27 bcrypt
Valid through PHP 7.2.2, at least.

Switch to the PHP-specific version of crypt_blowfish. Eliminate libbcrypt as dead/redundant code.
2018-03-13 19:58:43 -05:00
Charles Dang
078f61c412 Removed unused GUI1 label widget 2018-03-07 06:17:20 +11:00
loonycyborg
1c8f520672 Implemented support for forum auth using bcrypt as per #1761
Newer versions of phpbb use bcrypt for password hashing requiring this
change. This is squash commit of bcrypt_auth branch.
2018-02-21 22:26:05 +03:00
Celtic Minstrel
3440546f2d Some fixes to the Lua deprecation API, and extend it to C++
* Some improvements to the messages
* Don't clobber existing metatables on deprecated subtables
* Fix Lua deprecation messages not even being logged
* Fix deprecation of Lua subtables
* Don't clobber the metatable when deprecating a subtable
2018-02-12 00:09:48 -05:00
kallaballa
024b2e7e9b Implement a surrender dialog
This records a surrender command in replays and quits the game.
2018-02-05 00:35:35 +01:00
Charles Dang
002b1a3c87 MP Staging/Join Game: unified player list handling and added player icons
Previously, MP Staging was using connect_engine::connected_users() to fill in the user list.
However, I noticed that the server was already sending the user list to all clients, including
the host, so I could unify the handling between Staging and Join Game by just using the server
data for both.

I've also added appropriate indicators for host, observer, and self in the list for both dialogs.
Additional host= and observer= status keys are sent by the server for that purpose.

I've also made the server dispatch the player list to the host when a game is created. This is
slightly redundant, since the host is the only player at that point, but it's easier than creating
a user config locally, or using connected_users(), not to mention easier to maintain.

The wesnothd::game::send_user_list function no longer exists early id `description_` is null.
No idea why it did that. It's not even used in the function. Anyway, it needed to be removed in
order for the above change to work.

Speaking of the host's copy of the player list, I haven't touched that. It's still needed for
managing things in the connect_engine. Might simplify things further in the future by delegating
more handling to the server, since it has a lot of the data needed already, but that's a different
project.
2017-12-14 11:12:49 +11:00
Charles Dang
6759f41b1e GUI2: cleaned up and restructured initialization process
This mostly has to do with moving various components into more logical locations instead of
all mushed together in gui/widgets/settings.*pp. To that end, the following changes have been
made:

* The gui2::init function has been moved to its own file in the gui/ toplevel.
* load_settings() has been merged into init().
* All functions and code relating to gui theme definitions have been moved to their own file.
* All code relating to widgets or window static init have been moved to their own file.
* window::update_screen_size has been moved out of the window class and into settings.cpp.
* The unimplemented free-stadnding version of load_widget_definitions has been removed.
* gui_definition::read and gui_defintion::load have been merged into the gui_definition ctor
  and greatly simplified.
* Some functions relating to builder_widgets have been renamed for clarity.
* add/remove_single_widget_defintion now access the current gui theme instead of the default.
  This looks like it was a mistake made in the original code.
* Since the static registry is now externally linked, the unit tests accessor for window types
  has been removed.
* Documentation has been updated. The wikidoc comment for gui_definition has been removed. It
  was rather out-of-date and needed to be reworked anyway.
* widget_builder_func_t's signature is now to take a config reference and not a copy, though
  REGISRER_WIDGET had already passed register_builder_widget a lambda that took a reference.
* Various other misc cleanups and improvements.
2017-12-11 14:49:58 +11:00
Gregory A Lundberg
b7881a0e6e Force linking all widgets
Ensure all GUI2 Widgets are linked into the Wesnoth executable even if there are no specific references to them.
2017-12-08 21:27:40 -06:00
Charles Dang
e08350cd17 Revert "rebase commit: implemented a surrender dialog that records a surrender command in replays and quits the game"
This reverts commit 4dda0ad9b2. This feature needs to be
considered further. Right now the design doesn't make sense.
2017-12-06 13:35:28 +11:00
kallaballa
4dda0ad9b2
rebase commit: implemented a surrender dialog that records a surrender command in replays and quits the game 2017-12-05 17:01:06 -06:00
Charles Dang
34e065e011 Tests: removed another empty file I missed in c93aebb1de
Its contents were also removed when SDL 1.2 was dropped.
2017-11-27 09:47:45 +11:00
Charles Dang
c93aebb1de Tests: removed empty files
These were emptied out when SDL 1.2 was removed (358bd1235f). I seem to recall
someone saying it might be worth keeping them around in case something needed to be put
back, but it's been a year and a half. Not much worth in keeping empty files.
2017-11-27 09:42:14 +11:00
Alexander van Gessel
669ba885ce Add make_unit_ptr functions in separate header, to avoid inclusion of unit.hpp 2017-11-19 17:50:47 +01:00
Charles Dang
378b9199ae Moved point wrapper out of GUI2 namespace
I'm not sure if it should become part of the sdl namespace, but for now I'm leaving it out.
2017-11-11 21:49:05 +11:00
Gregory A Lundberg
d091391899 Renamed the target and binary for the Boost unit tests from test to boost_unit_tests
This quells warnings from CMake about reserved target names, and reduces confusion about which `test` is intended: the wesnoth executable or the standard shell command.
2017-11-06 20:32:27 +02:00
Charles Dang
b1ad293ccd GUI2: removed unused MP Command Wrapper dialog
This was the equivalent of the Player Info dialog for the old GUI1 MP Lobby, and is now unused.
The new GUI2 lobby uses the aforementioned Player Info dialog. The functionality is basically
the same, though, except the send-private-message interface is more streamlined in the new lobby.
2017-10-29 16:56:16 +11:00
gfgtdf
e9c6dff56a Slider refactor
1) We now use a single function to set slider min/max value, this fixes #1641
   (sliders having a temporary invalid (min > max) state between set_min() and
   set_max() calls)
2) I split the sliders_base class from the scrollbar_base class to not
   accidently break the rather complicated scrollbar_base class while
   refactoring sliders.
3) We don't use floats in the slider code to make sure no rounding errors happen.
4) This fixes #1539 by removing slider::in_orthoginal (which made it impossible
   to pull a slider to its maximum/minimum) and intead clamping the mouse
   position in range.
5) This fixes #1656 and #1767 by refactoriung code (that bug happend mainly
   because the old code used variables that contained the position in 'steps'
   as pixel position and vice versa)
6) Sliders now 'snap' to the correct values just like the gui1 sliders did.
7) Slider positions are now poperly rounded to its neariest values
   instead of just beeing 'floored'
2017-10-29 01:13:48 +02:00
Gregory A Lundberg
f7bea59fe9 Finish switch to MT19937 for randomness
Coverity has been complaining about using rand() as an insecure function. As we're using it, this function is not insecure; but is also not a very good RNG. We're using MT19937 in a system-independant manner. But some uses of rand() were never converted. This converts them.

This closes the following Coverity issues:

CID 1356297
CID 1356299
CID 1356303
CID 1356304
CID 1356306
CID 1356312
CID 1356314
CID 1380163
CID 1380173
CID 1380179
CID 1380191
CID 1380198
CID 1380201
CID 1380210
CID 1380214
CID 1380215
CID 1380219
CID 1380230
CID 1380241
2017-10-26 09:28:24 +11:00
Charles Dang
f2593034a8 GUI2: moved MP Lobby and Player Info files into the multiplayer dialog subdir 2017-10-20 16:36:18 +11:00
Ignacio R. Morelle
28c5179636 campaignd: Add wrapper for atomic commits of crucial files
As the 2016-10-07~09 downtime incident shows, it is paramount to take
further steps in guaranteeing that the server can't corrupt its own data
files (especially the add-ons database) when receiving
inappropriately-timed signals.

This commit adds and deploys an ostream wrapper that requires callers to
explicitly commit the results to disk when finished writing to the
stream, so that only then the real destination file is overwritten with
the working copy (a temporary in the same dir). This way, there should
never be a situation in which the destination is left in an inconsistent
state due to a signal or exception.

The temporary receives a predictable name right now in the interest of
simplicity, since we are more or less in control of the target directory
anyway. We definitely don't want it to be an unlinked file since that
would make it impossible for admins to inspect and compare the temporary
against the original afterwards.

The code makes some assumptions about the nature of the return value of
filesystem::ostream_file() which will never be broken in this stable
branch, which is why one helper function is in campaignd land rather
than in the global filesystem API for now. This should probably be
rectified when forward-porting to master. Maybe.

Nothing of this will work reliably on Windows but we don't care. There's
only one machine in the world where we support running campaignd at this
time and it runs Linux.
2017-09-14 20:14:08 -03:00