Autosave settings immediately after closing settings
[lsnes.git] / include / platform / wxwidgets / platform.hpp
bloba9380d46252e1c1a6572247c6589b20d245eaa76
1 #ifndef _plat_wxwidgets__platform__hpp__included__
2 #define _plat_wxwidgets__platform__hpp__included__
4 #include "core/moviefile.hpp"
5 #include "core/window.hpp"
7 #include <cstdlib>
8 #include <cstdint>
9 #include <cstddef>
11 #include <wx/string.h>
13 class wxwin_mainwindow;
14 class wxwin_messages;
15 class wxwin_status;
16 class wxWindow;
17 class wxKeyEvent;
19 //Scaling
20 extern double video_scale_factor;
21 extern int scaling_flags;
22 extern bool arcorrect_enabled;
23 extern bool hflip_enabled;
24 extern bool vflip_enabled;
25 extern bool rotate_enabled;
26 extern int wx_escape_count;
28 wxString towxstring(const std::string& str) throw(std::bad_alloc);
29 std::string tostdstring(const wxString& str) throw(std::bad_alloc);
30 wxString towxstring(const std::u32string& str) throw(std::bad_alloc);
31 std::u32string tou32string(const wxString& str) throw(std::bad_alloc);
32 void bring_app_foreground();
33 std::string pick_archive_member(wxWindow* parent, const std::string& filename) throw(std::bad_alloc);
34 void boot_emulator(loaded_rom& rom, moviefile& movie, bool fscreen);
35 void handle_wx_keyboard(wxKeyEvent& e, bool polarity);
36 std::string map_keycode_to_key(int kcode);
37 void initialize_wx_keyboard();
38 void deinitialize_wx_keyboard();
39 void signal_program_exit();
40 void signal_resize_needed();
41 void _runuifun_async(void (*fn)(void*), void* arg);
42 void show_projectwindow(wxWindow* modwin);
43 void signal_core_change();
44 void do_save_configuration();
46 std::vector<interface_action_paramval> prompt_action_params(wxWindow* parent, const std::string& label,
47 const std::list<interface_action_param>& params);
50 //Editor dialogs.
51 void wxeditor_authors_display(wxWindow* parent);
52 void wxeditor_hotkeys_display(wxWindow* parent);
53 void wxeditor_memorywatches_display(wxWindow* parent);
54 void wxeditor_subtitles_display(wxWindow* parent);
55 std::string wxeditor_keyselect(wxWindow* parent, bool clearable);
56 void show_wxeditor_voicesub(wxWindow* parent);
57 void open_rom_select_window();
58 void open_new_project_window(wxWindow* parent);
59 void show_conflictwindow(wxWindow* parent);
60 void open_vumeter_window(wxWindow* parent);
61 void wxeditor_movie_display(wxWindow* parent);
62 void wxeditor_movie_update();
63 void wxeditor_autohold_display(wxWindow* parent);
64 void wxeditor_tasinput_display(wxWindow* parent);
65 void wxeditor_macro_display(wxWindow* parent);
66 void wxeditor_hexedit_display(wxWindow* parent);
67 void wxeditor_multitrack_display(wxWindow* parent);
68 bool wxeditor_plugin_manager_display(wxWindow* parent);
69 void wxeditor_tracelog_display(wxWindow* parent, int cpuid, const std::string& cpuname);
70 void wxeditor_disassembler_display(wxWindow* parent);
71 void wxeditor_plugin_manager_notify_fail(const std::string& libname);
73 //Auxillary windows.
74 void wxwindow_memorysearch_display();
75 void wxwindow_memorysearch_update();
76 void wxeditor_hexeditor_update();
77 class memory_search;
78 memory_search* wxwindow_memorysearch_active();
79 bool wxeditor_hexeditor_available();
80 bool wxeditor_hexeditor_jumpto(uint64_t addr);
81 void wxwindow_tasinput_update();
83 template<typename T>
84 void functor_call_helper2(void* args)
86 (*reinterpret_cast<T*>(args))();
87 delete reinterpret_cast<T*>(args);
90 template<typename T>
91 void runuifun(T fn)
93 _runuifun_async(functor_call_helper2<T>, new T(fn));
96 //Thrown by various dialog functions if canceled.
97 class canceled_exception : public std::runtime_error
99 public:
100 canceled_exception();
103 //Prompt for stuff. These all can throw canceled_exception.
104 std::string pick_file_member(wxWindow* parent, const std::string& title, const std::string& startdir);
105 std::string pick_among(wxWindow* parent, const std::string& title, const std::string& prompt,
106 const std::vector<std::string>& choices, unsigned defaultchoice = 0);
107 std::string pick_text(wxWindow* parent, const std::string& title, const std::string& prompt,
108 const std::string& dflt = "", bool multiline = false);
109 //Show message box with OK button.
110 void show_message_ok(wxWindow* parent, const std::string& title, const std::string& text, int icon);
113 //Some important windows (if open).
114 extern wxwin_messages* msg_window;
115 extern wxwin_mainwindow* main_window;
116 extern std::string our_rom_name;
117 extern bool wxwidgets_exiting;
119 //Some important settings.
120 extern std::map<std::string, std::string> core_selections;
122 template<typename T> void runemufn_async(T fn)
124 platform::queue(functor_call_helper2<T>, new T(fn), false);
127 #endif