Commit graph

592 commits

Author SHA1 Message Date
Andreas Löf
64b90042c4 Fix bug #24762: Recreate buttons GUI buttons on a full redraw
This re-creates the main display-gui() buttons on a full redraw to take
into account that the theme expects them to be out of sync. As a
consequence I have also been forced to refactor how said buttons are
managed and introduced a new method to join the same event context
as another component.
2016-07-09 21:54:48 +12:00
Charles Dang
0ca4e6c943 Convert uses of boost functional to standard library variants
This commit converts the following function calls:

* boost::bind                          -> std::bind
* boost::function and boost::functionN -> std::function
* boost::ref and boost::cref           -> std::ref and std::cref
* boost::bad_function_call             -> std::bad_function_call

In the process, it was discovered that std::bind has trouble with overloaded
functions. There were two such cases in the code:

* gui2::twindow had an ancient unused overload to draw(). The overload was removed.
* gui2::trepeating_button was binding tdispatcher::fire. This case was converted
  to a lambda.
2016-04-04 02:20:52 +11:00
Celtic Minstrel
3ac7f8d970 NULL -> nullptr
A few cases of NULL were missed, since changing them led to errors
(Mainly instances where it was passed to a boost::function)
2016-03-31 00:42:38 -04:00
Andreas Löf
358bd1235f Remove SDL1.2 code
This removes all legacy SDL1.2 code. It was done by invoking:
coan source --replace --no-transients -D"SDL_VERSION_ATLEAST(X, Y, Z)"=1 <file>
on each file.
2016-03-13 11:34:34 +13:00
ln-zookeeper
d9326e13bf Added an "Animate water" toggle to display preferences 2016-03-02 13:42:11 +02:00
Andreas Löf
12d1fd006f Resize action buttons dynamically on the main display
This adds the necessary bells and whistles to resize the GUI1 buttons
used in the main game display. It is rather painful as it involves
re-setting most of the attributes that affect the size.

These changes also adds two new draw-methods to the display class and
gets rid of the default parameters. This is to avoid warnings from
clang since the draw() method comes from a superclass to display now.

The GUI1 button's set_image has been updated to treat the image path
in the same way as it is treated in the constructor. This should not
be a problem since the method is not called from anywhere but the
display class, and that call is added in this commit.
2016-02-24 20:45:50 +13:00
Andreas Löf
b8f18919dd Merge remote-tracking branch 'origin/master' into guifixes
Conflicts:
	src/events.cpp
	src/hotkey/command_executor.hpp
	src/video.cpp

Resolved manually.
2016-02-21 23:00:14 +13:00
Andreas Löf
ea649ec0a2 Fix event-context related assertion failure at exit
This fixes an assertion failure at exit which was caused by the event
contexts being cleaned up before the dummy display. There is no need
for the dummy display implementation to ever receive events so the
functionality has been extended for it to not join an event context,
resolving the assertion failure.
2016-02-13 11:57:01 +13:00
Charles Dang
d131f1d58c Removed the option to turn off Local ToD lighting. It is now always on. 2016-02-06 20:19:41 +11:00
Andreas Löf
a02a8da7ea Continued improvements to layered rendering
This makes the display class be aware of the layered rendering events (DRAW_ALL) and make it mark itself as dirty on certain window events. It also makes sure that the layers are redrawn in the correct order. GUI2 is now appearing to handle events properly, but GUI1 is still having issues with dialogs. And there's an assertion failure on program exit.
2016-02-02 23:23:16 +13:00
gfgtdf
08236f8953 added name= attribute to [item]
name= has no effect but can be used to delete the item. I also changed
[item] to automatically create an id (in case no id was given) and
return that (only usable if called from lua).

I used the id= field from overlay class for this, it was previously only
used by the editor. Not sure if it is a good idea to reuse the id field.
2016-01-31 02:25:46 +01:00
gfgtdf
cf49294c9a add a comment 2016-01-16 20:50:04 +01:00
Charles Dang
4afd415143 Decoupled delay() from display class and moved it to a static CVideo function 2016-01-12 10:55:55 +11:00
Andreas Löf
ac242376e9 Add a dynamic layout functionality to the game display
This adds dynamic layout functionality, which is invoked on a full
redraw and upon element creation. It also makes sure that there's no
attempt to do a surface restore on negative widhts or heights as
introduced support for in SDL2. Finally, there's a workaround for text
being clipped by 1-2 pixels in GUI1 buttons.
2016-01-10 18:54:06 +13:00
Chris Beck
ba51524f6e update copyright to year 2016
using this shell script:

find src -type f -print0 | xargs -0 sed -i "s|Copyright (C) \([[:digit:]]*\)\([ ]*\)-\([ ]*\)2015|Copyright (C) \1\2-\32016|g"
2016-01-02 23:59:31 -05:00
Andreas Löf
2c1f3ef540 Merge branch 'master' into sdl2 2015-12-19 12:03:12 +13:00
gfgtdf
7f13156c28 Revert "Rename team_name/user_team_name to team_id/team_name (old syntax still valid)"
And related commits.

This reverts commit 545253ec2b.
This reverts commit 1215f65eb8.
This reverts commit 11664f4024.
This reverts commit e948df3424.
This reverts commit 3781e7839f.

This commits were reverted to exclude them from wesnoth 1.13.2 release because:
1) We are still unsure about the best name oftthese attributes
2) This breaks multiple campaigns, including LoW and the tutorial.
Feel free to revert this revert after 1.13.2 when thse issues can be solved..
2015-12-10 21:29:52 +01:00
Andreas Löf
1890e948e4 Merge branch 'master' into sdl2 2015-10-26 18:57:32 +13:00
Charles Dang
3781e7839f Rename team_name/user_team_name to team_id/team_name (old syntax still valid) 2015-10-26 00:44:28 +11:00
Andreas Löf
da98c62d4f Bug #23908 - Don't hold copies of the window surface
Change more copies of the window surface to be references
instead. This will make sure they do not contain a stale version that
has a pointer that points to freed memory.
2015-10-14 23:00:43 +13:00
Andreas Löf
54d9965950 Fix compile warning in clang
Clang is warning that the field is unused when SDL2 is enabled. This
fixes the warning by removing the field when the game is compiled with
SDL2.
2015-09-25 02:02:48 +12:00
gfgtdf
ec8bf1e1f7 move reset_gamestate function (reset_replay) to play_controller 2015-09-09 17:46:10 +02:00
Ignacio R. Morelle
a62914e9f2 display: Return error status from display::screenshot() instead of file size
This makes it so errors in image::save_image() are printed to stderr
using our log facilities before returning, and also propagates the
function's result to screenshot()'s callers instead of a computed
screenshot size that doesn't hold true for PNG images.

Additionally, a couple of existing error messages have been reworded and
are now emitted through the log facilities instead of being sent
directly to stderr.
2015-04-10 00:49:40 -03:00
Chris Beck
2d0a543922 fix zoom slider focus issue (add a separate class for zoom_slider)
When the slider widget was added to ThemeWML, some work was not
done apparently to make it play nicely with regards to focus and
key events with the other theme wml widgets, causing it to retain
focus for keyboard events indefinitely. At the time this was
resolved by disabling these events, but this cripples the many
other sliders in the game. In this commit we introduce a subclass
zoom_slider which has this functionality disabled, and use that
for zoom sliders, so that we can get the desired functionality
back for the other sliders. See parent of this commit for more
info.
2015-03-05 13:52:33 -05:00
Ignacio R. Morelle
57ae45387a New Year copyright update 2015-01-01 19:07:35 -03:00
Chris Beck
0fce6e7c68 add tod_manager, lua kernel to filter context
this allows to remove the resources:: links from the filter
implementations
2014-12-23 01:34:24 -05:00
Chris Beck
0459f8a574 make "reports" not a singleton object
This is necessary to make game_events not a singleton.
2014-12-13 01:28:57 -05:00
Chris Beck
5a8485d225 fixup a warning (c++11 unused variable) 2014-11-04 12:45:25 -05:00
Boldizsár Lipka
685acdf4a9 Better SDL_gpu implementation for display::render_image. 2014-08-11 23:01:55 +02:00
Boldizsár Lipka
5f63af2049 Only redraw invalidated parts of the panel.
Fixes flickering buttons.
2014-07-22 18:53:35 +02:00
Boldizsár Lipka
740d1978b7 Don't recreate buttons for every draw. 2014-07-21 09:31:14 +02:00
Boldizsár Lipka
73b4f25fd9 SDL_gpu implementation for reports. 2014-07-17 21:47:06 +02:00
Boldizsár Lipka
1a7873e5aa Move sdl/texture.?pp to sdl/image.?pp. 2014-07-17 21:47:04 +02:00
Boldizsár Lipka
7d3535645f Rename ttexture to timage. 2014-07-17 21:47:04 +02:00
Boldizsár Lipka
0acb2e1529 Initial SDL_gpu support in the game display. 2014-07-17 21:47:04 +02:00
Chris Beck
d86b59f08a add filter_context class, use in unit_filter
The filter context is, game_board + tod manager.
game_display can (and now does) implement this interface,
also game_state. This permits both animations and engine
components to use it.
2014-07-03 10:27:01 -04:00
Chris Beck
32dc07478f revert and fixup boost/function.hpp external include guards 2014-06-29 11:40:53 -04:00
Chris Beck
ae39fe4e8a Revert "put include guards on boost/function"
This reverts commit 8f0fe88635.
2014-06-29 11:07:25 -04:00
Chris Beck
33ae8d7398 move bar drawing code from display to unit_drawer
That's the only place it is used.
2014-06-27 17:53:48 -04:00
Chris Beck
b0e407ac66 move halo::manager from play_controller to display
Also this removes the need to have it in the editor.
2014-06-27 10:36:15 -04:00
Chris Beck
8f0fe88635 put include guards on boost/function
According to clang boost/function.hpp does not have include guards,
and from inspecting clang diagnostics we include it many times
in several compilation units. This commit adds an external include
guard to all of our includes of this header, it was made using

find . -type f -exec sed -i 's/^#include <boost\/function\.hpp>$/\n#ifndef I

and inspecting the results.
2014-06-19 13:58:58 -04:00
Chris Beck
1cc51deb87 remove unit.hpp include from game_display.hpp 2014-06-17 13:17:14 -04:00
Chris Beck
4ff77b84c8 redraw_unit takes display & as an argument 2014-06-16 23:31:36 -04:00
Chris Beck
0be1d731d5 add drawable unit class
drawable unit inherits from unit, and implements the draw function,
used only by the display. when the display wants to use the function,
it casts a unit pointer to a drawable_unit, and draws it. this
improves encapsulation.
2014-06-16 22:10:31 -04:00
Chris Beck
06f02b52c5 add fake_unit_manager, split off from game_display object
This commit adds two classes -- fake_unit, and fake_unit_manager,
both split off from code contained in game_display. The display
object is reconfigured to hold a pointer to the manager and
display the units it contains. The rest of the code is configured
to add fake units to the manager, not the display.

This improves encapsulation and helps to reduce the game_display
class.
2014-06-16 17:31:38 -04:00
Chris Beck
13155c4f41 separate fake units list from real units list
This is a first step before brnaching off to fake units manager
2014-06-16 15:19:24 -04:00
Chris Beck
e32de173ea remove unit.hpp include from team.hpp 2014-06-15 14:57:47 -04:00
Chris Beck
926effb41a fixup segfaults in replay viewer
After this commit e4eb0a3ede the
replay viewer would segfault during prestart events. However, it
turns out that nothing in the replay viewer, or in that commit,
was directly causing the segault. Instead, the display object
was holding dangling pointers for no reason, when it could have.
been simply computing the correct value (very cheaply). We clean
up the code in the display objects to fix the segfault.
2014-06-14 22:05:07 -04:00
Chris Beck
89c22a8279 add virtual fcns to display, remove refs to game_display in reports
This commit adds virtual functions covering "observers",
"displayed_unit_hex", and "playing_side", in display:: object.
This allows to avoid dynamic casts in the reports.cpp file, and
to eliminate a header. It avoids the possibility of segfault when
using the editor if the reports context isn't set up correctly.
2014-06-12 20:37:18 -04:00
Chris Beck
f4754496d3 remove unnecessary (duplicated) accessors 2014-06-12 19:33:15 -04:00