149 Commits

Author SHA1 Message Date
Charles Dang
1fa6a2d4b2 Convert uses of abs to std::abs 2016-11-07 11:30:21 +11:00
Jyrki Vesterinen
af733360a8 Fix a bunch of MSVC2015 compiler warnings about hiding declarations
This commit still doesn't fix all of them. I decided to leave alone
cases where variables with the same name are assigned in multiple
conditions of the same if...else if...else statement, and cases where a
scope logging macro is used multiple times in the same scope. In any
case, this commit greatly reduces the warning count on MSVC2015 and makes
new warnings much easier to spot.
2016-10-06 00:11:56 +03:00
Celtic Minstrel
a8aa38277e Revert accidentally-committed code in c5ce248f54695316d4603c18b7e5e485b2564d24. 2016-09-29 14:40:46 -04:00
Celtic Minstrel
c5ce248f54 Update credits listing
This adds a large number of people gleaned from the logs with:
	git log --merges --since=Jan.1.2015

If any of the people added in this commit wish to change how they
are referenced, they are of course free to contact us.
2016-09-29 11:21:05 -04:00
Jyrki Vesterinen
61a22556ce Fix multiplayer tests getting stuck in Travis CI 2016-08-20 11:45:39 +03:00
Jyrki Vesterinen
b15c9be4d5 Fix delay before drawing menu content 2016-08-17 20:18:51 +03:00
Jyrki Vesterinen
927b8aa7d5 Fixed crash caused by failing to remove an event handler
If code attempted to remove an event handler from an event context whose
all handlers were in the staging area (especially if that context was
freshly created and events::pump() hadn't been called since creating it),
the handler wasn't removed. This resulted in the handler remaining in the
context, but believing that it wasn't there. If the handler was later
destroyed, the event system still retained a pointer to it and attempted to
call handle_event() on it. Depending on the compiler, it could cause a
"pure virtual function call" error message.
2016-08-14 11:47:15 +03:00
Jyrki Vesterinen
f621d7fa46 Add new event handlers to a staging area
This reverts the semantical change in commit 61ccf2f that event handlers
registered as a result of an event received that event.

Compared with commit 3d8c29bc, this is a lower-level way to fix the ;
character appearing in the command console. This commit has potential to
fix more code that assumes that an event handler can't receive an event
that caused the handler to be registered in the first place. On the other
hand, it is no longer possible for event handlers to receive such events
even if developers want that.
2016-08-13 18:39:13 +03:00
Andreas Löf
15ff7e7d1a Fix bug #24553: Prevent the display (and others) from drawing over the storyscreen.
This also adds a call to stop flips during a full redraw as a consequence of a window event.
2016-07-30 00:20:53 +12:00
Andreas Löf
abc64e62c8 Fix crash by reintroduce splice.
This fixes a crash that would be caused by memory incorrectly being freed
when removed from a list. Relying on splice stops that from happening.

This also fixes an exit condition when deleting handlers as depth could
sometimes not be decremented.

Finally, checks are made to made sure that an sdl_handler is either
exclusively in the global context or a different context, ensuring
that they cannot be in both.
2016-07-29 00:20:05 +12:00
Jyrki Vesterinen
8a296386e3 Fix undefined behavior on destroying an event context
The destructor of the context class accidentally incremented the iterator
twice per iteration. If the number of event handlers was odd, the
destructor ended up incrementing the end iterator, which is UB.

I rewrote the whole destructor. It's unnecessary to manually remove event
handlers from the list because the list will do it automatically when it's
destroyed.
2016-07-22 21:05:08 +03:00
Andreas
5e7d558228 Merge pull request #696 from wesnoth/Vultraz-event_handling_fixes
Refactored event contexts to use lists instead of vectors
2016-07-18 23:50:21 +12:00
Andreas Löf
9550c3636b Ensure that focus handling stays the same as before the fix 2016-07-17 22:52:09 +12:00
Andreas Löf
501eb60743 Fix crash in context destructor
This fixes a crash that was seen when the context destructor was calling
either leave or leave_global while iterating over the list. The current iterator
handle would be invalidated and further calls to it would return invalid values.
2016-07-17 22:06:52 +12:00
Andreas Löf
516daccbba Move the global event context onto the general event queue.
This moves the global event context onto the general event queue
and creates it through RAII instead.
2016-07-17 20:33:09 +12:00
Andreas Löf
6964aa2ba7 Change const_iterator to iterator in an attempt to appease travis. 2016-07-17 16:01:31 +12:00
Andreas Löf
75632003ef Add a destructor to the context class.
This adds a destructor to the context class to ensure that any joined
event_handlers leave the context before it is deallocated.
It also changes the preferences to explicitly leave the global event
context as it is destroyed instead of when the event handler is
destroyed during _exit().
Also replace std::list.splice with push_back and erase(iterator) in
an attempt to avoid compile errors on older versions of gcc.
2016-07-17 15:15:18 +12:00
Andreas Löf
aa58d83b45 Use RAII instead of lock->unlock directly. 2016-07-16 11:25:01 +12:00
Andreas Löf
d55e884280 Hacky fix for the flickering when a screen is fully redrawn.
The fix supresses the call to flip() while a full redrawn
is performed. The flip calls are instead deferred to
then next draw-cycle.
2016-07-15 23:29:45 +12:00
Charles Dang
a399a00717 Use emplace_back when adding new event_contexts member
Thanks to celticminstrel for the suggestion.
2016-07-15 06:23:17 +11:00
Andreas Löf
90b6b58aa4 Fix crashes in the focus cycling code.
This ensures that the focus_handler is correctly initialised and
that cycle_focus() iterates over the current handlers correctly.
2016-07-14 23:19:49 +12:00
Charles Dang
61ccf2fc16 WIP: some refactoring of event handling w/ celticminstrel 2016-07-14 14:48:09 +11:00
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
Celtic Minstrel
1afa45a53e Fix crash if Lua initialization routines put up a dialog during the loading screen 2016-04-05 22:56:58 -04:00
Celtic Minstrel
e805a38735 Fix preferences not recentering on resolution switch 2016-03-21 12:50:06 -04:00
Charles Dang
37d9b102b7 Include SDL files as system headers
This excludes inclusions in SDL_GPU files.
2016-03-20 15:07:16 +11:00
Charles Dang
9c33f77de2 Cleaned up inclusions of display.hpp 2016-03-19 22:30:21 +11:00
Charles Dang
4435b25523 Remove calls to empty update_whole_screen() function
The function's contents were SDL1.2 only, and it now does nothing in
SDL2.
2016-03-13 22:17:36 +11: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
Ignacio R. Morelle
3159f738e8 Add member variable to initializer list (bug #24498) 2016-03-06 05:56:31 -03:00
Andreas Löf
6978296137 Move stray curly bracket to right place 2016-02-28 23:17:00 +13:00
Andreas Löf
c0f7fb6be2 Merge remote-tracking branch 'origin/master' into guifixes 2016-02-24 22:03:28 +13:00
Andreas Löf
d00e207202 Make storyscreen respect draw-all events
The storyscreen now marks itself as dirty on a draw-all event and
redraws itself. There's also some code cleanup in here.
2016-02-24 15:34:25 +13:00
Charles Dang
7d0a02ec7d Bunch of refactoring of editor quit handling 2016-02-24 12:28:38 +11: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
b73cc895ae Fix GUI1 layering and redraws.
These changes ensure that GUI1 elements are properly respecting the
draw layering and are redrawed on the appropriate window events. It
has been tested with both one and multiple overlapping dialogs.
2016-02-03 22:25:12 +13: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
8efc1da970 cleanup some includes 2016-01-16 20:50:09 +01:00
Charles Dang
1304ac0954 Removed unused static resize_comparer function 2016-01-14 07:51:39 +11:00
Celtic Minstrel
d98b74d3ad Fix some missing prototype warnings 2016-01-13 12:30:54 -05:00
gfgtdf
93091519bd make CVideo a singleton
half of CVideo's member variables were already static members (in anon
namespaces) so it was never possibel to have more than one of this
class. Making this class a singelton allows us to move all these
variables into the CVideo class.
2016-01-12 00:17:26 +01:00
Andreas Löf
5f5a334fba Make window events a separate handler for sdl_events
This adds a new function to sdl_handler, handle_window_event that is called for all window events. It is propogated to all event contexts instead of just the current one.
events::raise_draw_all_event (and a volatile variant) are added, that also sends draw events to all event contexts in reverse order so that the draw-stack can be redrawn bottom-up.
2016-01-11 18:59:33 +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
9e356c40f4 Removed two printouts to stdout I inadvertently introduced 2016-01-02 22:51:56 +13:00
Andreas Löf
4b2fabfd7e Ask the window for it's state when trying to decide what the state is 2016-01-02 10:41:16 +13:00
Charles Dang
a6f35e5186 Move prefs window event handling to global event context 2016-01-01 20:24:25 +11:00
Charles Dang
02b992821a Reimplement preference flag event handling in member function hook 2016-01-01 18:30:43 +11:00
Charles Dang
c425bd8b15 Save new resolution on window resize 2016-01-01 18:29:55 +11:00
Andreas Löf
544b61534c Fix bug #24209 and add a global event scope
This adds a global event scope that an sdl_handler can register to in
order to receive all current events, regardless of the current
scope. Care should be taken to not be registerd in a local event
context and the global context at the same time as it will lead to the
event handler potentially being invoked twice.

This also adds the workaround needed for #24209 in the new event
handler in the video class.
2016-01-01 17:56:59 +13:00
Andreas Löf
2f65f0ad1a Trigger a full redraw oncertain window events.
This is an attempt to fix #24212 and similar bugs by always triggering
full redraws when the window is exposes, restrored, etc.
2015-12-31 11:10:48 +13:00