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.
The storyscreen would trigger a full redraw-cycle partially through
displaying bigmap. Due to the implementation of the storyscreen, this
would cause it to have the background overdrawn and never updated. The
fix implemented here is to remove layered-drawing functionality from
the storyscreen and trigger a full redraw manually at the end of the
story screen functionality.
This introduces a subclass of events::sdl_handler that keeps track of
all instantiated classes. When a new instance is created it's pushed
onto a list of all tracked instances. When an instance is destroyed,
all known instances are sent a resize event (under SDL2) to mark them
as dirty. After that there's a DRAW_ALL event pushed onto the event
queue to cause a redraw. There's currently no logic in place to ensure
that there's only one DRAW_ALL event in the event queue at any given
time, but it should be harmless as long as no components are marked as
dirty.
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.
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.
General changes in this commit:
* Split window initialization out of setMode and into its own function
* Remove local flags for window state and instead get them directly from the
window itself.
* Improve handling of distinct window change cases in setMode.
* Refactored and cleaned up several functions.
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.
This removes the usage of the display::get_singleton() in the event
handling code since it may cause incorrect behaviour (crash) when the
singleton has been incorrectly set to null.
This also removes SDL_PumpEvents() from grid.cpp the rendering code
should not be directly interacting with the event handling and it's
causing instabilities.
SDL2 uses shared memory to communicate with the graphics system when
using a software renderer. A resize event will cause SDL2 to
invalidate the SDL_surface that relies on shared memory and any
subsequent calls to will be SDL_GetWindowSurface will cause the shared
memory do be unmapped as the old surface is released. This is
problematic when it occurs during a rendering cycle, because the
software rendered may also invoke SDL_GetWindowSurface, making any
references to that surface that the game contains become stale. This
will in turn cause a segmentation fault during blitting.
This change makes sure that only references are used to the video
surface instead of a copy. This will help to avoid stale values after
a resize event has occured where it will cause a crash due to a stale
pointer.
Separated the dialog code from the resolution gathering code. This makes
it easier to port the code to SDL2.
This also changes the sorting of the resolutions, first width then
height instead of based on the area. Before a part of the list looked
like:
1280 x 720
1152 x 864
1280 x 960
1440 x 900
1282 x 1024
These now look like:
1152 x 864
1280 x 720
1280 x 960
1280 x 1024
1440 x 900
The new sorting makes more sense to me.