These got lost in the migration to Meson; they used to be called
with atexit, but this caused more problems than it should have.
Anyway, it's fine to call these only when we're exiting normally,
since otherwise we have bigger problems than not quitting SDL.
Also:
recreate the window when enabling resizable window, same workaround I applied to my mod for jacob1/The-Powder-Toy#24
recreate the window when toggling fullscreen, to work around some bugs where the window is sized incorrectly or the mouse position doesn't match where the cursor is
Don't capture mouse cursor when this is a debug build
don't recreate window every scale / fullscreen change
better renderer handling, input scaling no longer needed even if window resizing is enabled
load/save window position (replaces old windows code to do this)
calculate initial mouse position on startup because sdl no longer does this for us
mouse movement captured outside the window when mouse is down
fullscreen now focuses the window (there is a bug where you have to click once to get mouse input, though)
add linux icon, will need to be redone properly because it's offcentered with a black border (mask isn't present)
allow typing ~ into the console + some other fixes
Still currently in process, there are some issues:
Windows version doesn't work, mac version might not work, opengl might not work
Icon doesn't work (on Linux at least)
Lua will need some changes, there are some sdl 1.2 hacks in there
When entering fullscreen, the window loses focus
When holding down mouse out of bounds, mouse move events stop being sent
When letting go of mouse out of bounds, mouseup event doesn't take into account double scale mode
Clicking on startup without moving mouse will draw at 0,0 for a frame
Renderer probably won't compile because USE_SDL doesn't entirely work
... and maybe others
Some nice things were done though:
no more blit2, sdl can do the scaling itself
3d effect removed, no reason to support this joke any longer
No need to support copy/paste ourselves, sdl does it now
text handling done much better now, separate events for key presses and text input
when a new window is shown, all events ignored until next tick (ignore textinput event if window shown from key press event like console)
Apparently C++11 is more strict regarding default argument and return
value conversions. Also return brace-initializer construction has had
little support.
Window scale can now be anything between 1 and 10 (suggest something other than 10 for maximum scale?). This required a number of subtle changes:
* made blit2 (PowderToySDL.cpp) handle scale modes correctly (it really only handled scale:2 correctly before)
* replaced `bool scale` with `int scale` everywhere in the options view/model/controller
* replaced the _large screen_ checkbox with a _window scale_ textbox in the options view
The new scale is only checked and applied when the options view is closed. There's no reason to not apply it live, I just chose not to.
This commit does *not* make TPT able to figure out an optimal scale mode at first run. It still suggests using scale:2 if it makes sense though.
I had doubts about using a second loop in blit2 but it doesn't seem to be an issue. If there's a more optimal way of going about what blit2 does, I haven't figured it out.
(Sublime seems to have eaten a few trailing spaces, hence there are a few seemingly identical pairs of lines in the diff.)
I've left some of the less important items, like SearchView.cpp "'then' statement is equivalent to the 'else' statement", and RequestBroker::Request::~Request, because I don't feel like spending a few days entirely rewriting those files at the moment (which is what I'd end up doing if I started fixing minor problems and refactoring...)
GameSave::readOPS - not changed. At some point we may have to move to a larger type for element IDs (probably two or four bytes), but PT_NUM isn't likely to be raised to the maximum value of that type immediately, so this check will be needed then. There should be an elements[partsData[i]].Enabled check in there too, but it might be a bit difficult - I'm not sure how to access a Simulation object from GameSave::readOPS...
Notes on changes:
Graphics::textsize, Element_FRZW::Element_FRZW - typos
Button::Draw - the extra case was originally used to invert the icon (draw it in black instead of in white) when the button was clicked. However, the icon colour is now automatically set depending on the background colour. (Note similar conditions "if(Enabled) { if(isButtonDown || (isTogglable && toggle)) " near the start of the function - same logic but in a different place, setting icon colour indirectly).
Simulation::transform_save - unused redundant function, everything uses GameSave::Transform which does much the same thing.
PreviewView::NotifySaveChanged - should be height==YRES/2, it's checking whether the preview image is the correct size, and resizing it if it isn't.
Element_FWRK::update - no idea why that line was there, even though it was my commit that originally added it...