diff --git a/include/platform/wxwidgets/platform.hpp b/include/platform/wxwidgets/platform.hpp index c0096d8c..f6597425 100644 --- a/include/platform/wxwidgets/platform.hpp +++ b/include/platform/wxwidgets/platform.hpp @@ -32,6 +32,7 @@ void wxeditor_axes_display(wxWindow* parent); void wxeditor_authors_display(wxWindow* parent); void wxeditor_settings_display(wxWindow* parent); void wxeditor_hotkeys_display(wxWindow* parent); +void wxeditor_paths_display(wxWindow* parent); std::string wxeditor_keyselect(wxWindow* parent, bool clearable); void wxeditor_screen_display(wxWindow* parent, double& horiz, double& vert, int& flags); diff --git a/include/platform/wxwidgets/window_mainwindow.hpp b/include/platform/wxwidgets/window_mainwindow.hpp index 4af0d690..d6e5548a 100644 --- a/include/platform/wxwidgets/window_mainwindow.hpp +++ b/include/platform/wxwidgets/window_mainwindow.hpp @@ -35,7 +35,7 @@ public: void menu_entry(int id, wxString name); void menu_entry_check(int id, wxString name); void menu_start_sub(wxString name); - void menu_end_sub(wxString name); + void menu_end_sub(); bool menu_ischecked(int id); void menu_check(int id, bool newstate); void menu_separator(); diff --git a/manual.lyx b/manual.lyx index 5980ca95..451d6afb 100644 --- a/manual.lyx +++ b/manual.lyx @@ -2748,6 +2748,19 @@ L[] Can be used anywhere. \end_layout +\begin_layout Subsubsection +gui.rainbow(number step, number steps[, number color]) +\end_layout + +\begin_layout Standard +Perform hue rotation of color (default bright red), by steps. + The number of steps per full rotation is given by absolute value of . +\end_layout + +\begin_layout Standard +If is negative, the rotation will be counterclockwise. +\end_layout + \begin_layout Subsection table input \end_layout diff --git a/manual.txt b/manual.txt index 8ae6a130..a545e69e 100644 --- a/manual.txt +++ b/manual.txt @@ -1354,6 +1354,14 @@ The default alpha is 256. Set status field “L[]” to in status area. Can be used anywhere. +8.3.26 gui.rainbow(number step, number steps[, number color]) + +Perform hue rotation of color (default bright red), by + steps. The number of steps per full rotation is given by +absolute value of . + +If is negative, the rotation will be counterclockwise. + 8.4 table input Input handling. Only available in on_input callback. @@ -1746,7 +1754,7 @@ Called if savestate goes wrong. 8.10.12 Callback: on_post_save(string name, boolean is_savestate) Called on successful savaestate. is_savestate gives if this was a -savestate or a movie. +savestate or a 8.10.13 Callback: on_quit() @@ -2629,7 +2637,7 @@ set-axis joystick0axis19 disabled • Remove calls to runtosave() that aren't supposed to be there -• Lua function: movie.read_rtc() +• Lua function: read_rtc() • Ignore src/fonts/font.cpp @@ -2850,7 +2858,7 @@ set-axis joystick0axis19 disabled • Wxwidgets: 128 -> 1024 Autohold slots (in case more are needed). -• Don't append trailing '-' to prefix when saving movie. +• Don't append trailing '-' to prefix when saving • Fix ROM/savestate handling (don't let user mismatch ROM and savestates). diff --git a/src/core/mainloop.cpp b/src/core/mainloop.cpp index 6551fced..4d7a5e08 100644 --- a/src/core/mainloop.cpp +++ b/src/core/mainloop.cpp @@ -95,8 +95,11 @@ public: void set(const std::string& value) throw(std::bad_alloc, std::runtime_error) { + if(value != "") { _firmwarepath = value; default_firmware = false; + } else + blank(); } std::string get() throw(std::bad_alloc) diff --git a/src/lua/gui-core.cpp b/src/lua/gui-core.cpp index 1a2bca50..d8f0b277 100644 --- a/src/lua/gui-core.cpp +++ b/src/lua/gui-core.cpp @@ -1,5 +1,6 @@ #include "lua/internal.hpp" #include "core/window.hpp" +#include "library/minmax.hpp" namespace { @@ -73,4 +74,61 @@ namespace return 1; }); + + //0: m + //1: M + //2: m + phue + //3: M - phue + uint8_t hsl2rgb_flags[] = {24, 52, 6, 13, 33, 19}; + + uint32_t shifthue(uint32_t color, double shift) + { + int16_t R = (color >> 16) & 0xFF; + int16_t G = (color >> 8) & 0xFF; + int16_t B = color & 0xFF; + int16_t m = min(R, min(G, B)); + int16_t M = max(R, max(G, B)); + int16_t S = M - m; + if(!S) + return color; //Grey. + int16_t hue; + if(R == M) + hue = G - B + 6 * S; + else if(G == M) + hue = B - R + 2 * S; + else + hue = R - G + 4 * S; + int16_t ohue = hue % (6 * S); + hue = (hue + static_cast(shift * S)) % (6 * S); + uint32_t V[4]; + V[0] = m; + V[1] = M; + V[2] = m + hue % S; + V[3] = M - hue % S; + uint8_t flag = hsl2rgb_flags[hue / S]; + return (V[(flag >> 4) & 3] << 16) | (V[(flag >> 2) & 3] << 8) | (V[flag & 3]); + } + + function_ptr_luafun gui_rainbow("gui.rainbow", [](lua_State* LS, const std::string& fname) -> int { + int64_t basecolor = 0x00FF0000; + uint64_t step = get_numeric_argument(LS, 1, fname.c_str()); + int32_t steps = get_numeric_argument(LS, 2, fname.c_str()); + get_numeric_argument(LS, 3, basecolor, fname.c_str()); + if(!steps) { + lua_pushstring(LS, "Expected nonzero steps for gui.rainbow"); + lua_error(LS); + } + if(basecolor < 0) { + //Special: Any rotation of transparent is transparent. + lua_pushnumber(LS, -1); + return 1; + } + uint32_t asteps = std::abs(steps); + if(steps < 0) + step = asteps - step % asteps; //Reverse order. + double hueshift = 6.0 * (step % asteps) / asteps; + basecolor = shifthue(basecolor & 0xFFFFFF, hueshift) | (basecolor & 0xFF000000); + lua_pushnumber(LS, basecolor); + return 1; + }); } diff --git a/src/platform/portaudio/sound.cpp b/src/platform/portaudio/sound.cpp index 10024df1..45673928 100644 --- a/src/platform/portaudio/sound.cpp +++ b/src/platform/portaudio/sound.cpp @@ -59,7 +59,7 @@ namespace int audiocb(const void *input, void *output, unsigned long frame_count, const PaStreamCallbackTimeInfo* time_info, PaStreamCallbackFlags flags, void* user) { - static uint16_t lprev, rprev; + static uint16_t lprev = 32768, rprev = 32768; int16_t* _output = reinterpret_cast(output); for(unsigned long i = 0; i < frame_count; i++) { uint16_t l, r; diff --git a/src/platform/wxwidgets/dumpmenu.cpp b/src/platform/wxwidgets/dumpmenu.cpp index 3056f6eb..a78a63b4 100644 --- a/src/platform/wxwidgets/dumpmenu.cpp +++ b/src/platform/wxwidgets/dumpmenu.cpp @@ -146,12 +146,12 @@ void dumper_menu::update(const std::map& new_dumpers) if(!i.second.active) { if(i.second.modes.empty()) { menustructure[i.first].start_items[id] = Append(id, towxstring("Dump " + - i.second.name)); + i.second.name + "...")); menustructure[i.first].start_wxids[id++] = ""; } for(auto j : i.second.modes) { menustructure[i.first].start_items[id] = Append(id, towxstring("Dump " + - i.second.name + " (" + j.second + ")")); + i.second.name + " (" + j.second + ")...")); menustructure[i.first].start_wxids[id++] = j.first; } } else { diff --git a/src/platform/wxwidgets/editor-paths.cpp b/src/platform/wxwidgets/editor-paths.cpp new file mode 100644 index 00000000..9ecf88a8 --- /dev/null +++ b/src/platform/wxwidgets/editor-paths.cpp @@ -0,0 +1,112 @@ +#include "platform/wxwidgets/platform.hpp" +#include "core/settings.hpp" +#include "library/string.hpp" + +#include +#include +#include +#include +#include +#include + +#include +#include + +#define FIRMWAREPATH "firmwarepath" +#define ROMPATH "rompath" +#define MOVIEPATH "moviepath" + +class wxeditor_paths : public wxDialog +{ +public: + wxeditor_paths(wxWindow* parent); + ~wxeditor_paths(); + bool ShouldPreventAppExit() const; + void on_cancel(wxCommandEvent& e); + void on_ok(wxCommandEvent& e); +private: + wxButton* okbutton; + wxButton* cancel; + wxTextCtrl* rompath; + wxTextCtrl* moviepath; + wxTextCtrl* firmwarepath; +}; + +wxeditor_paths::wxeditor_paths(wxWindow* parent) + : wxDialog(parent, wxID_ANY, wxT("lsnes: Paths"), wxDefaultPosition, wxSize(-1, -1)) +{ + std::string cur_rompath, cur_moviepath, cur_firmwarepath; + runemufn([&cur_firmwarepath, &cur_moviepath, &cur_rompath]() { + cur_firmwarepath = setting::get(FIRMWAREPATH); + cur_rompath = setting::get(ROMPATH); + cur_moviepath = setting::get(MOVIEPATH); + }); + + Centre(); + wxFlexGridSizer* top_s = new wxFlexGridSizer(2, 1, 0, 0); + SetSizer(top_s); + + wxFlexGridSizer* t_s = new wxFlexGridSizer(3, 2, 0, 0); + t_s->Add(new wxStaticText(this, wxID_ANY, wxT("ROMs:")), 0, wxGROW); + t_s->Add(rompath = new wxTextCtrl(this, wxID_ANY, towxstring(cur_rompath), wxDefaultPosition, wxSize(400, -1)), + 1, wxGROW); + t_s->Add(new wxStaticText(this, wxID_ANY, wxT("Movies:")), 0, wxGROW); + t_s->Add(moviepath = new wxTextCtrl(this, wxID_ANY, towxstring(cur_moviepath), wxDefaultPosition, + wxSize(400, -1)), 1, wxGROW); + t_s->Add(new wxStaticText(this, wxID_ANY, wxT("Firmware:")), 0, wxGROW); + t_s->Add(firmwarepath = new wxTextCtrl(this, wxID_ANY, towxstring(cur_firmwarepath), wxDefaultPosition, + wxSize(400, -1)), 1, wxGROW); + top_s->Add(t_s); + + wxBoxSizer* pbutton_s = new wxBoxSizer(wxHORIZONTAL); + pbutton_s->AddStretchSpacer(); + pbutton_s->Add(okbutton = new wxButton(this, wxID_OK, wxT("OK")), 0, wxGROW); + pbutton_s->Add(cancel = new wxButton(this, wxID_CANCEL, wxT("Cancel")), 0, wxGROW); + okbutton->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(wxeditor_paths::on_ok), NULL, this); + cancel->Connect(wxEVT_COMMAND_BUTTON_CLICKED, + wxCommandEventHandler(wxeditor_paths::on_cancel), NULL, this); + top_s->Add(pbutton_s, 0, wxGROW); + + t_s->SetSizeHints(this); + top_s->SetSizeHints(this); + Fit(); +} + +wxeditor_paths::~wxeditor_paths() +{ +} + +bool wxeditor_paths::ShouldPreventAppExit() const +{ + return false; +} + +void wxeditor_paths::on_cancel(wxCommandEvent& e) +{ + EndModal(wxID_CANCEL); +} + +void wxeditor_paths::on_ok(wxCommandEvent& e) +{ + std::string cur_rompath = tostdstring(rompath->GetValue()); + std::string cur_moviepath = tostdstring(moviepath->GetValue()); + std::string cur_firmwarepath = tostdstring(firmwarepath->GetValue()); + runemufn([cur_firmwarepath, cur_moviepath, cur_rompath]() { + setting::set(ROMPATH, cur_rompath); + setting::set(MOVIEPATH, cur_moviepath); + setting::set(FIRMWAREPATH, cur_firmwarepath); + }); + EndModal(wxID_OK); +} + +void wxeditor_paths_display(wxWindow* parent) +{ + modal_pause_holder hld; + wxDialog* editor; + try { + editor = new wxeditor_paths(parent); + editor->ShowModal(); + } catch(...) { + } + editor->Destroy(); +} diff --git a/src/platform/wxwidgets/mainwindow.cpp b/src/platform/wxwidgets/mainwindow.cpp index 6f747d26..8210818f 100644 --- a/src/platform/wxwidgets/mainwindow.cpp +++ b/src/platform/wxwidgets/mainwindow.cpp @@ -82,7 +82,20 @@ enum wxID_SHOW_STATUS, wxID_SET_SPEED, wxID_SET_VOLUME, - wxID_SET_SCREEN + wxID_SET_SCREEN, + wxID_SET_PATHS, + wxID_SPEED_5, + wxID_SPEED_10, + wxID_SPEED_17, + wxID_SPEED_20, + wxID_SPEED_25, + wxID_SPEED_33, + wxID_SPEED_50, + wxID_SPEED_100, + wxID_SPEED_150, + wxID_SPEED_200, + wxID_SPEED_300, + wxID_SPEED_TURBO }; @@ -198,6 +211,15 @@ namespace return ret; } + void set_speed(double target) + { + std::string v = (stringfmt() << target).str(); + if(target < 0) + runemufn([]() { setting::set("targetfps", "infinite"); }); + else + runemufn([v]() { setting::set("targetfps", v); }); + } + class controller_autohold_menu : public wxMenu { public: @@ -426,6 +448,52 @@ namespace { runuifun([ahmenu]() { ahmenu->reconfigure(); }); } + + + class movie_path_setting : public setting + { + public: + movie_path_setting() : setting("moviepath") { _moviepath = "."; default_movie = true; } + void blank() throw(std::bad_alloc, std::runtime_error) + { + _moviepath = "."; + default_movie = true; + } + + bool is_set() throw() + { + return !default_movie; + } + + void set(const std::string& value) throw(std::bad_alloc, std::runtime_error) + { + if(value != "") { + _moviepath = value; + default_movie = false; + } else + blank(); + } + + std::string get() throw(std::bad_alloc) + { + return _moviepath; + } + + operator std::string() throw(std::bad_alloc) + { + return _moviepath; + } + private: + std::string _moviepath; + bool default_movie; + } moviepath_setting; + + std::string movie_path() + { + std::string x; + runemufn([&x]() { x = setting::get("moviepath"); }); + return x; + } } void boot_emulator(loaded_rom& rom, moviefile& movie) @@ -506,7 +574,7 @@ void wxwin_mainwindow::menu_start_sub(wxString name) old->AppendSubMenu(current_menu, name); } -void wxwin_mainwindow::menu_end_sub(wxString name) +void wxwin_mainwindow::menu_end_sub() { current_menu = upper.top(); upper.pop(); @@ -617,75 +685,90 @@ wxwin_mainwindow::wxwin_mainwindow() SetMenuBar(menubar); //TOP-level accels: ACFOS. - //System menu: (ACFOS)EMNPQRU + //System menu: (ACOS)ELNPQTV menu_start(wxT("&System")); - menu_entry(wxID_FRAMEADVANCE, wxT("Fra&me advance")); - menu_entry(wxID_SUBFRAMEADVANCE, wxT("S&ubframe advance")); - menu_entry(wxID_NEXTPOLL, wxT("&Next poll")); - menu_entry(wxID_PAUSE, wxT("&Pause/Unpause")); - menu_separator(); - menu_entry(wxID_ERESET, wxT("&Reset")); - menu_separator(); - menu_entry(wxID_EDIT_AUTHORS, wxT("&Edit game name && authors")); - menu_separator(); - menu_entry(wxID_EXIT, wxT("&Quit")); - menu_separator(); - menu_entry(wxID_ABOUT, wxT("About")); - //File menu: (ACFOS)DEILMNPRTUVW - menu_start(wxT("&File")); menu_entry_check(wxID_READONLY_MODE, wxT("Reado&nly mode")); menu_check(wxID_READONLY_MODE, is_readonly_mode()); + menu_entry(wxID_EDIT_AUTHORS, wxT("Edit game name && authors...")); + menu_start_sub(wxT("Spee&d")); + menu_entry(wxID_SPEED_5, wxT("1/20x")); + menu_entry(wxID_SPEED_10, wxT("1/10x")); + menu_entry(wxID_SPEED_17, wxT("1/6x")); + menu_entry(wxID_SPEED_20, wxT("1/5x")); + menu_entry(wxID_SPEED_25, wxT("1/4x")); + menu_entry(wxID_SPEED_33, wxT("1/3x")); + menu_entry(wxID_SPEED_50, wxT("1/2x")); + menu_entry(wxID_SPEED_100, wxT("1x")); + menu_entry(wxID_SPEED_150, wxT("1.5x")); + menu_entry(wxID_SPEED_200, wxT("2x")); + menu_entry(wxID_SPEED_300, wxT("3x")); + menu_entry(wxID_SPEED_TURBO, wxT("Turbo")); + menu_entry(wxID_SET_SPEED, wxT("Set...")); + menu_end_sub(); menu_separator(); - menu_entry(wxID_SAVE_STATE, wxT("Save stat&e")); - menu_entry(wxID_SAVE_MOVIE, wxT("Sa&ve movie")); - menu_separator(); - menu_entry(wxID_LOAD_STATE, wxT("&Load state")); - menu_entry(wxID_LOAD_STATE_RO, wxT("Loa&d state (readonly)")); - menu_entry(wxID_LOAD_STATE_RW, wxT("Load s&tate (read-write)")); - menu_entry(wxID_LOAD_STATE_P, wxT("Load state (&preserve)")); - menu_entry(wxID_LOAD_MOVIE, wxT("Load &movie")); - menu_entry(wxID_REWIND_MOVIE, wxT("Re&wind movie")); - menu_separator(); - menu_entry(wxID_CANCEL_SAVES, wxT("Cancel pend&ing saves")); - menu_separator(); - menu_entry(wxID_SAVE_SCREENSHOT, wxT("Save sc&reenshot")); - menu_separator(); - menu_special_sub(wxT("D&ump video"), reinterpret_cast(dmenu = new dumper_menu(this, - wxID_DUMP_FIRST, wxID_DUMP_LAST))); + menu_start_sub(wxT("&Load")); + menu_entry(wxID_LOAD_STATE, wxT("&Load state...")); + menu_entry(wxID_LOAD_STATE_RO, wxT("Loa&d state (readonly)...")); + menu_entry(wxID_LOAD_STATE_RW, wxT("Load s&tate (read-write)...")); + menu_entry(wxID_LOAD_STATE_P, wxT("Load state (&preserve input)...")); + menu_entry(wxID_LOAD_MOVIE, wxT("Load &movie...")); + menu_entry(wxID_REWIND_MOVIE, wxT("Re&wind movie...")); if(load_library_supported) { menu_separator(); menu_entry(wxID_LOAD_LIBRARY, towxstring(std::string("Load ") + library_is_called)); } - //Autohold menu: (ACFOS) + menu_end_sub(); + menu_start_sub(wxT("Sa&ve")); + menu_entry(wxID_SAVE_STATE, wxT("Save stat&e...")); + menu_entry(wxID_SAVE_MOVIE, wxT("Sa&ve movie...")); + menu_entry(wxID_SAVE_SCREENSHOT, wxT("Save sc&reenshot...")); + menu_entry(wxID_CANCEL_SAVES, wxT("Cancel pend&ing saves...")); + menu_end_sub(); + menu_separator(); + menu_entry(wxID_PAUSE, wxT("&Pause/Unpause")); + menu_entry(wxID_FRAMEADVANCE, wxT("S&tep frame")); + menu_entry(wxID_SUBFRAMEADVANCE, wxT("St&ep subframe")); + menu_entry(wxID_NEXTPOLL, wxT("Step poll")); + menu_separator(); + menu_entry(wxID_ERESET, wxT("&Reset")); + menu_separator(); + menu_entry_check(wxID_SHOW_STATUS, wxT("Show/Hide status panel")); + menu_separator(); + menu_special_sub(wxT("D&ump video"), reinterpret_cast(dmenu = new dumper_menu(this, + wxID_DUMP_FIRST, wxID_DUMP_LAST))); + menu_separator(); + menu_entry(wxID_EXIT, wxT("&Quit")); + menu_separator(); + menu_entry(wxID_ABOUT, wxT("About...")); + //Autohold menu: (ACOS) menu_special(wxT("&Autohold"), reinterpret_cast(ahmenu = new autohold_menu(this))); blistener->set_autohold_menu(reinterpret_cast(ahmenu)); - //Scripting menu: (ACFOS)ERU + //Scripting menu: (ACOS)ERU menu_start(wxT("S&cripting")); - menu_entry(wxID_RUN_SCRIPT, wxT("&Run script")); + menu_entry(wxID_RUN_SCRIPT, wxT("&Run script...")); if(lua_supported) { menu_separator(); - menu_entry(wxID_EVAL_LUA, wxT("&Evaluate Lua statement")); - menu_entry(wxID_RUN_LUA, wxT("R&un Lua script")); + menu_entry(wxID_EVAL_LUA, wxT("&Evaluate Lua statement...")); + menu_entry(wxID_RUN_LUA, wxT("R&un Lua script...")); } menu_separator(); - menu_entry(wxID_EDIT_MEMORYWATCH, wxT("Edit memory watch")); + menu_entry(wxID_EDIT_MEMORYWATCH, wxT("Edit memory watch...")); menu_separator(); - menu_entry(wxID_LOAD_MEMORYWATCH, wxT("Load memory watch")); - menu_entry(wxID_SAVE_MEMORYWATCH, wxT("Save memory watch")); + menu_entry(wxID_LOAD_MEMORYWATCH, wxT("Load memory watch...")); + menu_entry(wxID_SAVE_MEMORYWATCH, wxT("Save memory watch...")); menu_separator(); - menu_entry(wxID_MEMORY_SEARCH, wxT("Memory Search")); + menu_entry(wxID_MEMORY_SEARCH, wxT("Memory Search...")); //Settings menu: (ACFOS) menu_start(wxT("Settings")); - menu_entry(wxID_EDIT_AXES, wxT("Configure axes")); - menu_entry(wxID_EDIT_SETTINGS, wxT("Configure settings")); - menu_entry(wxID_EDIT_HOTKEYS, wxT("Configure hotkeys")); - menu_entry(wxID_EDIT_KEYBINDINGS, wxT("Configure keybindings")); - menu_entry(wxID_EDIT_ALIAS, wxT("Configure aliases")); - menu_entry(wxID_EDIT_JUKEBOX, wxT("Configure jukebox")); + menu_entry(wxID_EDIT_AXES, wxT("Configure axes...")); + menu_entry(wxID_EDIT_SETTINGS, wxT("Configure settings...")); + menu_entry(wxID_EDIT_KEYBINDINGS, wxT("Configure keybindings...")); + menu_entry(wxID_EDIT_ALIAS, wxT("Configure aliases...")); + menu_entry(wxID_EDIT_JUKEBOX, wxT("Configure jukebox...")); menu_separator(); - menu_entry_check(wxID_SHOW_STATUS, wxT("Show status panel")); - menu_entry(wxID_SET_SPEED, wxT("Set speed")); - menu_entry(wxID_SET_SCREEN, wxT("Set screen scaling")); + menu_entry(wxID_SET_SCREEN, wxT("Set screen scaling...")); + menu_entry(wxID_SET_PATHS, wxT("Set paths...")); + menu_entry(wxID_EDIT_HOTKEYS, wxT("Configure hotkeys...")); menu_check(wxID_SHOW_STATUS, true); if(platform::sound_initialized()) { //Sound menu: (ACFOS)EHU @@ -794,31 +877,31 @@ void wxwin_mainwindow::handle_menu_click_cancelable(wxCommandEvent& e) platform::queue("cancel-saves"); return; case wxID_LOAD_MOVIE: - platform::queue("load-movie " + pick_file(this, "Load Movie", ".")); + platform::queue("load-movie " + pick_file(this, "Load Movie", movie_path())); return; case wxID_LOAD_STATE: - platform::queue("load " + pick_file(this, "Load State", ".")); + platform::queue("load " + pick_file(this, "Load State", movie_path())); return; case wxID_LOAD_STATE_RO: - platform::queue("load-readonly " + pick_file(this, "Load State (Read-Only)", ".")); + platform::queue("load-readonly " + pick_file(this, "Load State (Read-Only)", movie_path())); return; case wxID_LOAD_STATE_RW: - platform::queue("load-state " + pick_file(this, "Load State (Read-Write)", ".")); + platform::queue("load-state " + pick_file(this, "Load State (Read-Write)", movie_path())); return; case wxID_LOAD_STATE_P: - platform::queue("load-preserve " + pick_file(this, "Load State (Preserve)", ".")); + platform::queue("load-preserve " + pick_file(this, "Load State (Preserve)", movie_path())); return; case wxID_REWIND_MOVIE: platform::queue("rewind-movie"); return; case wxID_SAVE_MOVIE: - platform::queue("save-movie " + pick_file(this, "Save Movie", ".")); + platform::queue("save-movie " + pick_file(this, "Save Movie", movie_path())); return; case wxID_SAVE_STATE: - platform::queue("save-state " + pick_file(this, "Save State", ".")); + platform::queue("save-state " + pick_file(this, "Save State", movie_path())); return; case wxID_SAVE_SCREENSHOT: - platform::queue("take-screenshot " + pick_file(this, "Save State", ".")); + platform::queue("take-screenshot " + pick_file(this, "Save Screenshot", movie_path())); return; case wxID_RUN_SCRIPT: platform::queue("run-script " + pick_file_member(this, "Select Script", ".")); @@ -1054,5 +1137,44 @@ void wxwin_mainwindow::handle_menu_click_cancelable(wxCommandEvent& e) case wxID_SET_SCREEN: wxeditor_screen_display(this, horizontal_multiplier, vertical_multiplier, libswscale_flags); return; + case wxID_SET_PATHS: + wxeditor_paths_display(this); + return; + case wxID_SPEED_5: + set_speed(5); + break; + case wxID_SPEED_10: + set_speed(10); + break; + case wxID_SPEED_17: + set_speed(16.66666666666); + break; + case wxID_SPEED_20: + set_speed(20); + break; + case wxID_SPEED_25: + set_speed(25); + break; + case wxID_SPEED_33: + set_speed(33.3333333333333); + break; + case wxID_SPEED_50: + set_speed(50); + break; + case wxID_SPEED_100: + set_speed(100); + break; + case wxID_SPEED_150: + set_speed(150); + break; + case wxID_SPEED_200: + set_speed(200); + break; + case wxID_SPEED_300: + set_speed(300); + break; + case wxID_SPEED_TURBO: + set_speed(-1); + break; }; } diff --git a/src/platform/wxwidgets/romselect.cpp b/src/platform/wxwidgets/romselect.cpp index 0c99aaaa..91819522 100644 --- a/src/platform/wxwidgets/romselect.cpp +++ b/src/platform/wxwidgets/romselect.cpp @@ -3,6 +3,7 @@ #include "core/moviedata.hpp" #include "core/framerate.hpp" +#include "core/settings.hpp" #include "library/zip.hpp" #include "interface/core.hpp" @@ -245,6 +246,50 @@ namespace private: wxTextCtrl* ctrl; }; + + class rom_path_setting : public setting + { + public: + rom_path_setting() : setting("rompath") { _rompath = "."; default_rom = true; } + void blank() throw(std::bad_alloc, std::runtime_error) + { + _rompath = "."; + default_rom = true; + } + + bool is_set() throw() + { + return !default_rom; + } + + void set(const std::string& value) throw(std::bad_alloc, std::runtime_error) + { + if(value != "") { + _rompath = value; + default_rom = false; + } else + blank(); + } + + std::string get() throw(std::bad_alloc) + { + return _rompath; + } + + operator std::string() throw(std::bad_alloc) + { + return _rompath; + } + private: + std::string _rompath; + bool default_rom; + } rompath_setting; + + std::string rom_path() + { + //This is pre-boot, so read directly. + return setting::get("rompath"); + } } @@ -286,7 +331,7 @@ wxwin_romselect::wxwin_romselect() romgrid->Add(rom_label[i] = new wxStaticText(this, wxID_ANY, wxT("")), 0, wxGROW); romgrid->Add(rom_name[i] = new wxTextCtrl(this, wxID_ANY, wxT(""), wxDefaultPosition, wxSize(500, -1)), 1, wxGROW); - romgrid->Add(rom_change[i] = new wxButton(this, ROM_SELECTS_BASE + i, wxT("...")), 0, wxGROW); + romgrid->Add(rom_change[i] = new wxButton(this, ROM_SELECTS_BASE + i, wxT("Pick")), 0, wxGROW); rom_name[i]->Connect(wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler(wxwin_romselect::on_filename_change), NULL, this); rom_change[i]->Connect(wxEVT_COMMAND_BUTTON_CLICKED, @@ -353,7 +398,7 @@ void wxwin_romselect::on_ask_rom_filename(wxCommandEvent& e) { try { std::string fname = pick_file_member(this, "Choose " + tostdstring( - rom_label[e.GetId() - ROM_SELECTS_BASE]->GetLabel()), "."); + rom_label[e.GetId() - ROM_SELECTS_BASE]->GetLabel()), rom_path()); wxTextCtrl* textbox = rom_name[e.GetId() - ROM_SELECTS_BASE]; if(textbox) textbox->SetValue(towxstring(fname)); @@ -471,7 +516,7 @@ wxwin_patch::wxwin_patch(loaded_rom& rom) patchsel->Add(new wxStaticText(this, wxID_ANY, wxT("File:")), 0, wxGROW); patchsel->Add(patchfile = new wxTextCtrl(this, wxID_ANY, wxT(""), wxDefaultPosition, wxSize(500, -1)), 1, wxGROW); - patchsel->Add(choosefile = new wxButton(this, wxID_ANY, wxT("...")), 0, wxGROW); + patchsel->Add(choosefile = new wxButton(this, wxID_ANY, wxT("Pick")), 0, wxGROW); patchfile->Connect(wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler(wxwin_patch::on_patchfile_change), NULL, this); choosefile->Connect(wxEVT_COMMAND_BUTTON_CLICKED, @@ -517,7 +562,7 @@ wxwin_patch::wxwin_patch(loaded_rom& rom) void wxwin_patch::on_ask_patchfile(wxCommandEvent& e) { try { - std::string fname = pick_file_member(this, "Choose patch file", "."); + std::string fname = pick_file_member(this, "Choose patch file", rom_path()); patchfile->SetValue(towxstring(fname)); on_patchfile_change(e); } catch(canceled_exception& e) { @@ -649,7 +694,9 @@ wxwin_project::wxwin_project(loaded_rom& rom) wxFlexGridSizer* fileblock = new wxFlexGridSizer(1, 2, 0, 0); fileblock->Add(savefile = new wxTextCtrl(this, wxID_ANY, wxT(""), wxDefaultPosition, wxSize(500, -1)), 1, wxGROW); - fileblock->Add(ask_savefile = new wxButton(this, ASK_FILENAME_BUTTON, wxT("...")), 0, wxGROW); + savefile->SetDropTarget(new textboxloadfilename(savefile)); + + fileblock->Add(ask_savefile = new wxButton(this, ASK_FILENAME_BUTTON, wxT("Pick")), 0, wxGROW); savefile->Connect(wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler(wxwin_project::on_filename_change), NULL, this); ask_savefile->Connect(wxEVT_COMMAND_BUTTON_CLICKED, @@ -681,7 +728,8 @@ wxwin_project::wxwin_project(loaded_rom& rom) wxFlexGridSizer* fileblock2 = new wxFlexGridSizer(1, 2, 0, 0); fileblock2->Add(sram_files[i] = new wxTextCtrl(this, wxID_ANY, wxT(""), wxDefaultPosition, wxSize(500, -1)), 1, wxGROW); - fileblock2->Add(sram_choosers[i] = new wxButton(this, ASK_SRAMS_BASE + idx, wxT("...")), 0, wxGROW); + sram_files[i]->SetDropTarget(new textboxloadfilename(sram_files[i])); + fileblock2->Add(sram_choosers[i] = new wxButton(this, ASK_SRAMS_BASE + idx, wxT("Pick")), 0, wxGROW); sram_files[i]->Connect(wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler(wxwin_project::on_filename_change), NULL, this); sram_choosers[i]->Connect(wxEVT_COMMAND_BUTTON_CLICKED,