diff --git a/src/common/ConfigManager.cpp b/src/common/ConfigManager.cpp index 2ef6cc9a..f860fdf0 100644 --- a/src/common/ConfigManager.cpp +++ b/src/common/ConfigManager.cpp @@ -109,8 +109,10 @@ enum named_opts OPT_SYNCHRONIZE, OPT_THREAD_PRIORITY, OPT_VIDEO_OPTION, + OPT_WINDOW_HEIGHT, OPT_WINDOW_POSITION_X, OPT_WINDOW_POSITION_Y, + OPT_WINDOW_WIDTH, OPT_SPEEDUP_THROTTLE, OPT_SPEEDUP_FRAME_SKIP }; @@ -239,8 +241,10 @@ int useBiosFileGBC; int videoOption; int vsync; int wasPaused = 0; +uint32_t windowHeight; int windowPositionX; int windowPositionY; +uint32_t windowWidth; int winFlashSize; int winGbBorderOn; int winGbPrinterEnabled; @@ -394,8 +398,10 @@ struct option argOptions[] = { { "video-option", required_argument, 0, OPT_VIDEO_OPTION }, { "vsync", no_argument, &vsync, 1 }, { "win-gb-printer-enabled", no_argument, &winGbPrinterEnabled, 1 }, + { "window-height", required_argument, 0, OPT_WINDOW_HEIGHT }, { "window-position-x", required_argument, 0, OPT_WINDOW_POSITION_X }, { "window-position-y", required_argument, 0, OPT_WINDOW_POSITION_Y }, + { "window-width", required_argument, 0, OPT_WINDOW_WIDTH }, { NULL, no_argument, NULL, 0 } @@ -547,8 +553,10 @@ void LoadConfig() useBiosFileGBC = ReadPref("useBiosGBC", 0); videoOption = ReadPref("video", 2); // VIDEO_3X = 2 vsync = ReadPref("vsync", false); - windowPositionX = ReadPref("windowX", 0); - windowPositionY = ReadPref("windowY", 0); + windowHeight = ReadPref("windowHeight", 0); + windowPositionX = ReadPref("windowX", -1); + windowPositionY = ReadPref("windowY", -1); + windowWidth = ReadPref("windowWidth", 0); winFlashSize = ReadPref("flashSize", 0x10000); winGbBorderOn = ReadPref("borderOn", 0); winGbPrinterEnabled = ReadPref("gbPrinter", 0); @@ -1333,6 +1341,20 @@ int ReadOpts(int argc, char ** argv) } break; + case OPT_WINDOW_HEIGHT: + // --window-height + if (optarg) { + windowHeight = atoi(optarg); + } + break; + + case OPT_WINDOW_WIDTH: + // --window-width + if (optarg) { + windowWidth = atoi(optarg); + } + break; + case OPT_DOTCODE_FILE_NAME_LOAD: // --dotcode-file-name-load loadDotCodeFile = optarg; diff --git a/src/common/ConfigManager.h b/src/common/ConfigManager.h index 77ac8c7b..7983fe87 100644 --- a/src/common/ConfigManager.h +++ b/src/common/ConfigManager.h @@ -132,8 +132,10 @@ extern int useBiosFileGBC; extern int videoOption; extern int vsync; extern int wasPaused; +extern uint32_t windowHeight; extern int windowPositionX; extern int windowPositionY; +extern uint32_t windowWidth; extern int winFlashSize; extern int winGbBorderOn; extern int winGbPrinterEnabled; diff --git a/src/wx/opts.cpp b/src/wx/opts.cpp index 48c561d7..5ea9d72f 100644 --- a/src/wx/opts.cpp +++ b/src/wx/opts.cpp @@ -239,7 +239,6 @@ opt_desc opts[] = { INTOPT("preferences/fsFrequency", "", wxTRANSLATE("Fullscreen mode frequency (0 = any)"), fsFrequency, 0, 999), INTOPT("preferences/fsHeight", "", wxTRANSLATE("Fullscreen mode height (0 = desktop)"), fsHeight, 0, 99999), INTOPT("preferences/fsWidth", "", wxTRANSLATE("Fullscreen mode width (0 = desktop)"), fsWidth, 0, 99999), - INTOPT("preferences/fullScreen", "Fullscreen", wxTRANSLATE("Enter fullscreen mode at startup"), fullScreen, 0, 1), INTOPT("preferences/gbPaletteOption", "", wxTRANSLATE("The palette to use"), gbPaletteOption, 0, 2), INTOPT("preferences/gbPrinter", "Printer", wxTRANSLATE("Enable printer emulation"), winGbPrinterEnabled, 0, 1), INTOPT("preferences/gdbBreakOnLoad", "DebugGDBBreakOnLoad", wxTRANSLATE("Break into GDB after loading the game."), gdbBreakOnLoad, 0, 1), @@ -264,8 +263,14 @@ opt_desc opts[] = { INTOPT("preferences/useBiosGBC", "BootRomGBC", wxTRANSLATE("Use the specified BIOS file for GBC"), useBiosFileGBC, 0, 1), INTOPT("preferences/vsync", "VSync", wxTRANSLATE("Wait for vertical sync"), vsync, 0, 1), -/// Sound + /// Geometry + INTOPT("geometry/fullScreen", "Fullscreen", wxTRANSLATE("Enter fullscreen mode at startup"), fullScreen, 0, 1), + UINTOPT("geometry/windowHeight", "Height", wxTRANSLATE("Window height at startup"), windowHeight, 0, 99999), + UINTOPT("geometry/windowWidth", "Width", wxTRANSLATE("Window width at startup"), windowWidth, 0, 99999), + INTOPT("geometry/windowX", "X", wxTRANSLATE("Window axis X position at startup"), windowPositionX, -1, 99999), + INTOPT("geometry/windowY", "Y", wxTRANSLATE("Window axis Y position at startup"), windowPositionY, -1, 99999), + /// Sound ENUMOPT("Sound/AudioAPI", "", wxTRANSLATE("Sound API; if unsupported, default API will be used"), gopts.audio_api, wxTRANSLATE("sdl|openal|directsound|xaudio2|faudio")), STROPT("Sound/AudioDevice", "", wxTRANSLATE("Device ID of chosen audio device for chosen driver"), gopts.audio_dev), INTOPT("Sound/Buffers", "", wxTRANSLATE("Number of sound buffers"), gopts.audio_buffers, 2, 10), diff --git a/src/wx/wxvbam.cpp b/src/wx/wxvbam.cpp index 9d2deaf2..a72d6590 100644 --- a/src/wx/wxvbam.cpp +++ b/src/wx/wxvbam.cpp @@ -398,6 +398,11 @@ bool wxvbamApp::OnInit() } // create the main window + int x = windowPositionX; + int y = windowPositionX; + int width = windowWidth; + int height = windowHeight; + int isFullscreen = fullScreen; frame = wxDynamicCast(xr->LoadFrame(NULL, wxT("MainFrame")), MainFrame); if (!frame) { @@ -409,6 +414,11 @@ bool wxvbamApp::OnInit() if (!frame->BindControls()) return false; + if (x >= 0 && y >= 0 && width > 0 && height > 0) + frame->SetSize(x, y, width, height); + + if (isFullscreen && wxGetApp().pending_load != wxEmptyString) + frame->ShowFullScreen(isFullscreen); frame->Show(true); return true; } @@ -633,6 +643,9 @@ EVT_ACTIVATE(MainFrame::OnActivate) // requires DragAcceptFiles(true); even then may not do anything EVT_DROP_FILES(MainFrame::OnDropFile) +// for window geometry +EVT_MOVE(MainFrame::OnMove) +EVT_SIZE(MainFrame::OnSize) // pause game if menu pops up // // This is a feature most people don't like, and it causes problems with @@ -688,6 +701,39 @@ void MainFrame::OnMenu(wxContextMenuEvent& event) } } +void MainFrame::OnMove(wxMoveEvent& event) +{ + wxRect pos = GetRect(); + int x = pos.GetX(), y = pos.GetY(); + if (x >= 0 && y >= 0 && !IsFullScreen()) + { + windowPositionX = x; + windowPositionY = y; + update_opts(); + } +} + +void MainFrame::OnSize(wxSizeEvent& event) +{ + wxFrame::OnSize(event); + wxRect pos = GetRect(); + int height = pos.GetHeight(), width = pos.GetWidth(); + int x = pos.GetX(), y = pos.GetY(); + bool isFullscreen = IsFullScreen(); + if (height > 0 && width > 0 && !isFullscreen) + { + windowHeight = height; + windowWidth = width; + } + if (x >= 0 && y >= 0 && !isFullscreen) + { + windowPositionX = x; + windowPositionY = y; + } + fullScreen = isFullscreen; + update_opts(); +} + wxString MainFrame::GetGamePath(wxString path) { wxString game_path = path; diff --git a/src/wx/wxvbam.h b/src/wx/wxvbam.h index 7c92b918..9213410e 100644 --- a/src/wx/wxvbam.h +++ b/src/wx/wxvbam.h @@ -356,6 +356,9 @@ private: void OnDropFile(wxDropFilesEvent&); // pop up menu in fullscreen mode void OnMenu(wxContextMenuEvent&); + // window geometry + void OnMove(wxMoveEvent& event); + void OnSize(wxSizeEvent& event); // Load a named wxDialog from the XRC file wxDialog* LoadXRCDialog(const char* name); // Load a named wxDialog from the XRC file