Add GUI cmd line option for config file. (#724)

This adds the command-line option `-c` or `--config` to specify a custom
configuration file.

Co-authored-by: Fabrice de Gans-Riberi <steelskin+github@gmail.com>
This commit is contained in:
Fabrice de Gans-Riberi 2020-08-28 15:26:07 -07:00 committed by GitHub
parent a305f550e1
commit 4074158061
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 124 additions and 99 deletions

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-08-17 17:30+0000\n" "POT-Creation-Date: 2020-08-27 19:38-0700\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -21,47 +21,51 @@ msgstr ""
msgid "visualboyadvance-m" msgid "visualboyadvance-m"
msgstr "" msgstr ""
#: wxvbam.cpp:440 #: wxvbam.cpp:443
msgid "Could not create main window" msgid "Could not create main window"
msgstr "" msgstr ""
#: wxvbam.cpp:511 #: wxvbam.cpp:514
msgid "Save built-in XRC file and exit" msgid "Save built-in XRC file and exit"
msgstr "" msgstr ""
#: wxvbam.cpp:514 #: wxvbam.cpp:517
msgid "Save built-in vba-over.ini and exit" msgid "Save built-in vba-over.ini and exit"
msgstr "" msgstr ""
#: wxvbam.cpp:517 #: wxvbam.cpp:520
msgid "Print configuration path and exit" msgid "Print configuration path and exit"
msgstr "" msgstr ""
#: wxvbam.cpp:520 #: wxvbam.cpp:523
msgid "Start in full-screen mode" msgid "Start in full-screen mode"
msgstr "" msgstr ""
#: wxvbam.cpp:524 #: wxvbam.cpp:526
msgid "Set a configuration file"
msgstr ""
#: wxvbam.cpp:530
msgid "Delete shared link state first, if it exists" msgid "Delete shared link state first, if it exists"
msgstr "" msgstr ""
#: wxvbam.cpp:531 #: wxvbam.cpp:537
msgid "List all settable options and exit" msgid "List all settable options and exit"
msgstr "" msgstr ""
#: wxvbam.cpp:534 #: wxvbam.cpp:540
msgid "ROM file" msgid "ROM file"
msgstr "" msgstr ""
#: wxvbam.cpp:536 #: wxvbam.cpp:542
msgid "<config>=<value>" msgid "<config>=<value>"
msgstr "" msgstr ""
#: wxvbam.cpp:567 #: wxvbam.cpp:573
msgid "Configuration/build error: can't find built-in xrc" msgid "Configuration/build error: can't find built-in xrc"
msgstr "" msgstr ""
#: wxvbam.cpp:575 #: wxvbam.cpp:581
#, c-format #, c-format
msgid "" msgid ""
"Wrote built-in configuration to %s.\n" "Wrote built-in configuration to %s.\n"
@ -70,11 +74,11 @@ msgid ""
"built-in:" "built-in:"
msgstr "" msgstr ""
#: wxvbam.cpp:590 #: wxvbam.cpp:596
msgid "Configuration is read from, in order:" msgid "Configuration is read from, in order:"
msgstr "" msgstr ""
#: wxvbam.cpp:604 #: wxvbam.cpp:610
#, c-format #, c-format
msgid "" msgid ""
"Wrote built-in override file to %s\n" "Wrote built-in override file to %s\n"
@ -82,13 +86,13 @@ msgid ""
"from search path:" "from search path:"
msgstr "" msgstr ""
#: wxvbam.cpp:610 #: wxvbam.cpp:616
msgid "" msgid ""
"\n" "\n"
"\tbuilt-in" "\tbuilt-in"
msgstr "" msgstr ""
#: wxvbam.cpp:621 #: wxvbam.cpp:627
msgid "" msgid ""
"Options set from the command line are saved if any configuration changes are " "Options set from the command line are saved if any configuration changes are "
"made in the user interface.\n" "made in the user interface.\n"
@ -97,13 +101,17 @@ msgid ""
"\n" "\n"
msgstr "" msgstr ""
#: wxvbam.cpp:642 #: wxvbam.cpp:648
msgid "" msgid ""
"The commands available for the Keyboard/* option are:\n" "The commands available for the Keyboard/* option are:\n"
"\n" "\n"
msgstr "" msgstr ""
#: wxvbam.cpp:676 #: wxvbam.cpp:660
msgid "Configuration file not found."
msgstr ""
#: wxvbam.cpp:693
msgid "Bad configuration option or multiple ROM files given:\n" msgid "Bad configuration option or multiple ROM files given:\n"
msgstr "" msgstr ""
@ -155,7 +163,7 @@ msgstr ""
msgid "VBA cheat lists (*.clt)|*.clt|CHT cheat lists (*.cht)|*.cht" msgid "VBA cheat lists (*.clt)|*.clt|CHT cheat lists (*.cht)|*.cht"
msgstr "" msgstr ""
#: guiinit.cpp:256 panel.cpp:427 #: guiinit.cpp:256 panel.cpp:436
msgid "Loaded cheats" msgid "Loaded cheats"
msgstr "" msgstr ""
@ -611,7 +619,7 @@ msgstr ""
msgid "Confirm import" msgid "Confirm import"
msgstr "" msgstr ""
#: cmdevents.cpp:907 panel.cpp:370 #: cmdevents.cpp:907 panel.cpp:379
#, c-format #, c-format
msgid "Loaded battery %s" msgid "Loaded battery %s"
msgstr "" msgstr ""
@ -694,7 +702,7 @@ msgstr ""
msgid "Wrote battery %s" msgid "Wrote battery %s"
msgstr "" msgstr ""
#: cmdevents.cpp:1100 panel.cpp:677 #: cmdevents.cpp:1100 panel.cpp:686
#, c-format #, c-format
msgid "Error writing battery %s" msgid "Error writing battery %s"
msgstr "" msgstr ""
@ -800,22 +808,22 @@ msgstr ""
msgid "Using interframe blending #%d" msgid "Using interframe blending #%d"
msgstr "" msgstr ""
#: cmdevents.cpp:2690 panel.cpp:183 panel.cpp:286 #: cmdevents.cpp:2690 panel.cpp:192 panel.cpp:295
msgid "Could not initialize the sound driver!" msgid "Could not initialize the sound driver!"
msgstr "" msgstr ""
#: cmdevents.cpp:2780 #: cmdevents.cpp:2794
msgid "Nintendo GameBoy (+Color+Advance) emulator." msgid "Nintendo GameBoy (+Color+Advance) emulator."
msgstr "" msgstr ""
#: cmdevents.cpp:2781 #: cmdevents.cpp:2795
msgid "" msgid ""
"Copyright (C) 1999-2003 Forgotten\n" "Copyright (C) 1999-2003 Forgotten\n"
"Copyright (C) 2004-2006 VBA development team\n" "Copyright (C) 2004-2006 VBA development team\n"
"Copyright (C) 2007-2017 VBA-M development team" "Copyright (C) 2007-2017 VBA-M development team"
msgstr "" msgstr ""
#: cmdevents.cpp:2782 #: cmdevents.cpp:2796
msgid "" msgid ""
"This program is free software: you can redistribute it and/or modify\n" "This program is free software: you can redistribute it and/or modify\n"
"it under the terms of the GNU General Public License as published by\n" "it under the terms of the GNU General Public License as published by\n"
@ -831,11 +839,11 @@ msgid ""
"along with this program. If not, see http://www.gnu.org/licenses ." "along with this program. If not, see http://www.gnu.org/licenses ."
msgstr "" msgstr ""
#: cmdevents.cpp:3087 #: cmdevents.cpp:3101
msgid "LAN link is already active. Disable link mode to disconnect." msgid "LAN link is already active. Disable link mode to disconnect."
msgstr "" msgstr ""
#: cmdevents.cpp:3093 #: cmdevents.cpp:3107
msgid "Network is not supported in local mode." msgid "Network is not supported in local mode."
msgstr "" msgstr ""
@ -939,155 +947,155 @@ msgstr ""
msgid "Error setting up server socket (%d)" msgid "Error setting up server socket (%d)"
msgstr "" msgstr ""
#: panel.cpp:97 #: panel.cpp:106
#, c-format #, c-format
msgid "%s is not a valid ROM file" msgid "%s is not a valid ROM file"
msgstr "" msgstr ""
#: panel.cpp:98 panel.cpp:159 panel.cpp:224 #: panel.cpp:107 panel.cpp:168 panel.cpp:233
msgid "Problem loading file" msgid "Problem loading file"
msgstr "" msgstr ""
#: panel.cpp:158 #: panel.cpp:167
#, c-format #, c-format
msgid "Unable to load Game Boy ROM %s" msgid "Unable to load Game Boy ROM %s"
msgstr "" msgstr ""
#: panel.cpp:200 panel.cpp:300 #: panel.cpp:209 panel.cpp:309
#, c-format #, c-format
msgid "Could not load BIOS %s" msgid "Could not load BIOS %s"
msgstr "" msgstr ""
#: panel.cpp:223 #: panel.cpp:232
#, c-format #, c-format
msgid "Unable to load Game Boy Advance ROM %s" msgid "Unable to load Game Boy Advance ROM %s"
msgstr "" msgstr ""
#: panel.cpp:459 #: panel.cpp:468
msgid " player " msgid " player "
msgstr "" msgstr ""
#: panel.cpp:625 #: panel.cpp:634
#, c-format #, c-format
msgid "Loaded state %s" msgid "Loaded state %s"
msgstr "" msgstr ""
#: panel.cpp:625 #: panel.cpp:634
#, c-format #, c-format
msgid "Error loading state %s" msgid "Error loading state %s"
msgstr "" msgstr ""
#: panel.cpp:649 #: panel.cpp:658
#, c-format #, c-format
msgid "Saved state %s" msgid "Saved state %s"
msgstr "" msgstr ""
#: panel.cpp:649 #: panel.cpp:658
#, c-format #, c-format
msgid "Error saving state %s" msgid "Error saving state %s"
msgstr "" msgstr ""
#: panel.cpp:853 #: panel.cpp:862
#, c-format #, c-format
msgid "Fullscreen mode %dx%d-%d@%d not supported; looking for another" msgid "Fullscreen mode %dx%d-%d@%d not supported; looking for another"
msgstr "" msgstr ""
#: panel.cpp:891 #: panel.cpp:900
#, c-format #, c-format
msgid "Fullscreen mode %dx%d-%d@%d not supported" msgid "Fullscreen mode %dx%d-%d@%d not supported"
msgstr "" msgstr ""
#: panel.cpp:896 #: panel.cpp:905
#, c-format #, c-format
msgid "Valid mode: %dx%d-%d@%d" msgid "Valid mode: %dx%d-%d@%d"
msgstr "" msgstr ""
#: panel.cpp:904 #: panel.cpp:913
#, c-format #, c-format
msgid "Chose mode %dx%d-%d@%d" msgid "Chose mode %dx%d-%d@%d"
msgstr "" msgstr ""
#: panel.cpp:908 #: panel.cpp:917
#, c-format #, c-format
msgid "Failed to change mode to %dx%d-%d@%d" msgid "Failed to change mode to %dx%d-%d@%d"
msgstr "" msgstr ""
#: panel.cpp:992 #: panel.cpp:1001
msgid "Not a valid GBA cartridge" msgid "Not a valid GBA cartridge"
msgstr "" msgstr ""
#: panel.cpp:1152 #: panel.cpp:1161
msgid "No memory for rewinding" msgid "No memory for rewinding"
msgstr "" msgstr ""
#: panel.cpp:1162 #: panel.cpp:1171
msgid "Error writing rewind state" msgid "Error writing rewind state"
msgstr "" msgstr ""
#: panel.cpp:2271 #: panel.cpp:2272
msgid "Failed to set glXSwapIntervalEXT" msgid "Failed to set glXSwapIntervalEXT"
msgstr "" msgstr ""
#: panel.cpp:2280 #: panel.cpp:2281
msgid "Failed to set glXSwapIntervalSGI" msgid "Failed to set glXSwapIntervalSGI"
msgstr "" msgstr ""
#: panel.cpp:2289 #: panel.cpp:2290
msgid "Failed to set glXSwapIntervalMESA" msgid "Failed to set glXSwapIntervalMESA"
msgstr "" msgstr ""
#: panel.cpp:2295 #: panel.cpp:2296
msgid "No support for wglGetExtensionsStringEXT" msgid "No support for wglGetExtensionsStringEXT"
msgstr "" msgstr ""
#: panel.cpp:2298 #: panel.cpp:2299
msgid "No support for WGL_EXT_swap_control" msgid "No support for WGL_EXT_swap_control"
msgstr "" msgstr ""
#: panel.cpp:2307 #: panel.cpp:2308
msgid "Failed to set wglSwapIntervalEXT" msgid "Failed to set wglSwapIntervalEXT"
msgstr "" msgstr ""
#: panel.cpp:2313 #: panel.cpp:2314
msgid "No VSYNC available on this platform" msgid "No VSYNC available on this platform"
msgstr "" msgstr ""
#: panel.cpp:2409 #: panel.cpp:2410
msgid "memory allocation error" msgid "memory allocation error"
msgstr "" msgstr ""
#: panel.cpp:2412 #: panel.cpp:2413
msgid "error initializing codec" msgid "error initializing codec"
msgstr "" msgstr ""
#: panel.cpp:2415 #: panel.cpp:2416
msgid "error writing to output file" msgid "error writing to output file"
msgstr "" msgstr ""
#: panel.cpp:2418 #: panel.cpp:2419
msgid "can't guess output format from file name" msgid "can't guess output format from file name"
msgstr "" msgstr ""
#: panel.cpp:2423 #: panel.cpp:2424
msgid "programming error; aborting!" msgid "programming error; aborting!"
msgstr "" msgstr ""
#: panel.cpp:2435 panel.cpp:2464 #: panel.cpp:2436 panel.cpp:2465
#, c-format #, c-format
msgid "Unable to begin recording to %s (%s)" msgid "Unable to begin recording to %s (%s)"
msgstr "" msgstr ""
#: panel.cpp:2492 #: panel.cpp:2493
#, c-format #, c-format
msgid "Error in audio/video recording (%s); aborting" msgid "Error in audio/video recording (%s); aborting"
msgstr "" msgstr ""
#: panel.cpp:2498 #: panel.cpp:2499
#, c-format #, c-format
msgid "Error in audio recording (%s); aborting" msgid "Error in audio recording (%s); aborting"
msgstr "" msgstr ""
#: panel.cpp:2508 #: panel.cpp:2509
#, c-format #, c-format
msgid "Error in video recording (%s); aborting" msgid "Error in video recording (%s); aborting"
msgstr "" msgstr ""

View File

@ -276,21 +276,23 @@ bool wxvbamApp::OnInit()
} }
wxSetWorkingDirectory(cwd); wxSetWorkingDirectory(cwd);
// set up config file
// this needs to be in a subdir to support other config as well if (!cfg) {
// but subdir flag behaves differently 2.8 vs. 2.9. Oh well. // set up config file
// NOTE: this does not support XDG (freedesktop.org) paths // this needs to be in a subdir to support other config as well
// but subdir flag behaves differently 2.8 vs. 2.9. Oh well.
// NOTE: this does not support XDG (freedesktop.org) paths
wxString confname(wxT("vbam.ini")); wxString confname(wxT("vbam.ini"));
wxFileName vbamconf(GetConfigurationPath(), confname); wxFileName vbamconf(GetConfigurationPath(), confname);
// /MIGRATION // /MIGRATION
// migrate from 'vbam.{cfg,conf}' to 'vbam.ini' to manage a single config // migrate from 'vbam.{cfg,conf}' to 'vbam.ini' to manage a single config
// file for all platforms. // file for all platforms.
wxString oldConf(GetConfigurationPath() + wxT(FILE_SEP) + wxT("vbam.conf")); wxString oldConf(GetConfigurationPath() + wxT(FILE_SEP) + wxT("vbam.conf"));
wxString newConf(GetConfigurationPath() + wxT(FILE_SEP) + wxT("vbam.ini")); wxString newConf(GetConfigurationPath() + wxT(FILE_SEP) + wxT("vbam.ini"));
if (!wxFileExists(newConf) && wxFileExists(oldConf)) if (!wxFileExists(newConf) && wxFileExists(oldConf))
wxRenameFile(oldConf, newConf, false); wxRenameFile(oldConf, newConf, false);
// /END_MIGRATION // /END_MIGRATION
cfg = new wxFileConfig(wxT("vbam"), wxEmptyString, cfg = new wxFileConfig(wxT("vbam"), wxEmptyString,
vbamconf.GetFullPath(), vbamconf.GetFullPath(),
@ -307,9 +309,9 @@ bool wxvbamApp::OnInit()
if (fc) { if (fc) {
wxFileName s(wxFileConfig::GetLocalFileName(GetAppName())); wxFileName s(wxFileConfig::GetLocalFileName(GetAppName()));
// at least up to 2.8.12, GetLocalFileName returns the dir if // at least up to 2.8.12, GetLocalFileName returns the dir if
// SUBDIR is specified instead of actual file name // SUBDIR is specified instead of actual file name
// and SUBDIR only affects UNIX // and SUBDIR only affects UNIX
#if defined(__UNIX__) && !wxCHECK_VERSION(2, 9, 0) #if defined(__UNIX__) && !wxCHECK_VERSION(2, 9, 0)
s.AppendDir(s.GetFullName()); s.AppendDir(s.GetFullName());
#endif #endif
@ -319,6 +321,7 @@ bool wxvbamApp::OnInit()
s = wxFileName::DirName(GetConfigurationPath()); s = wxFileName::DirName(GetConfigurationPath());
s.Mkdir(0777, wxPATH_MKDIR_FULL); s.Mkdir(0777, wxPATH_MKDIR_FULL);
} }
}
load_opts(); load_opts();
@ -519,6 +522,9 @@ void wxvbamApp::OnInitCmdLine(wxCmdLineParser& cl)
{ wxCMD_LINE_SWITCH, t("f"), t("fullscreen"), { wxCMD_LINE_SWITCH, t("f"), t("fullscreen"),
N_("Start in full-screen mode"), N_("Start in full-screen mode"),
wxCMD_LINE_VAL_NONE, 0 }, wxCMD_LINE_VAL_NONE, 0 },
{ wxCMD_LINE_OPTION, t("c"), t("config"),
N_("Set a configuration file"),
wxCMD_LINE_VAL_STRING, 0 },
#if !defined(NO_LINK) && !defined(__WXMSW__) #if !defined(NO_LINK) && !defined(__WXMSW__)
{ wxCMD_LINE_SWITCH, t("s"), t("delete-shared-state"), { wxCMD_LINE_SWITCH, t("s"), t("delete-shared-state"),
N_("Delete shared link state first, if it exists"), N_("Delete shared link state first, if it exists"),
@ -648,6 +654,17 @@ bool wxvbamApp::OnCmdLineParsed(wxCmdLineParser& cl)
return true; return true;
} }
if (cl.Found(wxT("c"), &s)) {
wxFileName vbamconf(s);
if (!vbamconf.FileExists()) {
wxLogError(_("Configuration file not found."));
return false;
}
cfg = new wxFileConfig(wxT("vbam"), wxEmptyString,
vbamconf.GetFullPath(),
wxEmptyString, wxCONFIG_USE_LOCAL_FILE);
}
#if !defined(NO_LINK) && !defined(__WXMSW__) #if !defined(NO_LINK) && !defined(__WXMSW__)
if (cl.Found(wxT("s"))) { if (cl.Found(wxT("s"))) {

View File

@ -104,7 +104,7 @@ public:
} }
// the main configuration // the main configuration
wxFileConfig* cfg; wxFileConfig* cfg = nullptr;
// vba-over.ini // vba-over.ini
wxFileConfig* overrides = nullptr; wxFileConfig* overrides = nullptr;