From 9e8ba1f68c402adb6a6316824a75d1b93adf784b Mon Sep 17 00:00:00 2001 From: Ilari Liusvaara Date: Thu, 3 Nov 2011 23:07:21 +0200 Subject: [PATCH] More backporting changes to core from wxwidgets work --- generic/lua.cpp | 4 +++- generic/lua.hpp | 1 + generic/mainloop.cpp | 3 +++ generic/moviedata.cpp | 2 ++ generic/window.cpp | 13 +++++++++++-- generic/window.hpp | 8 ++++++++ 6 files changed, 28 insertions(+), 3 deletions(-) diff --git a/generic/lua.cpp b/generic/lua.cpp index b9d9673c..f99a8e26 100644 --- a/generic/lua.cpp +++ b/generic/lua.cpp @@ -20,6 +20,7 @@ void lua_callback_quit() throw() {} void init_lua() throw() {} bool lua_requests_repaint = false; bool lua_requests_subframe_paint = false; +bool lua_supported = false; #else #include "lua-int.hpp" @@ -431,4 +432,5 @@ void init_lua() throw() bool lua_requests_repaint = false; bool lua_requests_subframe_paint = false; -#endif \ No newline at end of file +bool lua_supported = true; +#endif diff --git a/generic/lua.hpp b/generic/lua.hpp index de0282cc..664174f5 100644 --- a/generic/lua.hpp +++ b/generic/lua.hpp @@ -81,6 +81,7 @@ void lua_callback_post_save(const std::string& name, bool is_state) throw(); void lua_callback_snoop_input(uint32_t port, uint32_t controller, uint32_t index, short value) throw(); void lua_callback_quit() throw(); +extern bool lua_supported; extern bool lua_requests_repaint; extern bool lua_requests_subframe_paint; diff --git a/generic/mainloop.cpp b/generic/mainloop.cpp index e60abac9..cf51d403 100644 --- a/generic/mainloop.cpp +++ b/generic/mainloop.cpp @@ -604,6 +604,7 @@ namespace "Syntax: set-rwmode\nSwitches to read/write mode\n", []() throw(std::bad_alloc, std::runtime_error) { movb.get_movie().readonly_mode(false); + window_callback::do_mode_change(false); lua_callback_do_readwrite(); update_movie_state(); window::notify_screen_update(); @@ -613,6 +614,7 @@ namespace "Syntax: set-romode\nSwitches to read-only mode\n", []() throw(std::bad_alloc, std::runtime_error) { movb.get_movie().readonly_mode(true); + window_callback::do_mode_change(true); update_movie_state(); window::notify_screen_update(); }); @@ -622,6 +624,7 @@ namespace []() throw(std::bad_alloc, std::runtime_error) { bool c = movb.get_movie().readonly_mode(); movb.get_movie().readonly_mode(!c); + window_callback::do_mode_change(!c); if(c) lua_callback_do_readwrite(); update_movie_state(); diff --git a/generic/moviedata.cpp b/generic/moviedata.cpp index e46d84c9..c6c8df35 100644 --- a/generic/moviedata.cpp +++ b/generic/moviedata.cpp @@ -12,6 +12,7 @@ #include "rrdata.hpp" #include "settings.hpp" #include "controller.hpp" +#include "window.hpp" struct moviefile our_movie; struct loaded_rom* our_rom; @@ -263,6 +264,7 @@ void do_load_state(struct moviefile& _movie, int lmode) movb.get_movie().readonly_mode(false); if(lmode == LOAD_STATE_CURRENT && !current_mode) movb.get_movie().readonly_mode(false); + window_callback::do_mode_change(movb.get_movie().readonly_mode()); messages << "ROM Type "; switch(our_rom->rtype) { case ROMTYPE_SNES: diff --git a/generic/window.cpp b/generic/window.cpp index 0d2c8b61..1f734afb 100644 --- a/generic/window.cpp +++ b/generic/window.cpp @@ -291,6 +291,10 @@ void window_callback::on_sound_unmute(bool unmute) throw() { } +void window_callback::on_mode_change(bool readonly) throw() +{ +} + void window_callback::on_sound_change(const std::string& dev) throw() { } @@ -317,7 +321,12 @@ void window_callback::do_sound_unmute(bool unmute) throw() void window_callback::do_sound_change(const std::string& dev) throw() { - std::cerr << "do_sound_change(" << dev << ")" << std::endl; for(auto i : wcbs()) i->on_sound_change(dev); -} \ No newline at end of file +} + +void window_callback::do_mode_change(bool readonly) throw() +{ + for(auto i : wcbs()) + i->on_mode_change(readonly); +} diff --git a/generic/window.hpp b/generic/window.hpp index 97191460..d592d30c 100644 --- a/generic/window.hpp +++ b/generic/window.hpp @@ -45,6 +45,10 @@ public: * Called when sound device gets (possibly) changed. */ virtual void on_sound_change(const std::string& dev) throw(); +/** + * Called when mode gets (possibly) changed. + */ + virtual void on_mode_change(bool readonly) throw(); /** * Do try to close the window. */ @@ -61,6 +65,10 @@ public: * Do on_sound_change */ static void do_sound_change(const std::string& dev) throw(); +/** + * Do on_mode_change + */ + static void do_mode_change(bool readonly) throw(); private: window_callback(window_callback&); window_callback& operator=(window_callback&);