Set Ruby's ARGV based on the command line

This commit is contained in:
Roza 2021-06-22 09:38:23 -04:00
parent 0770751e20
commit 7a9d60cdbc
4 changed files with 131 additions and 105 deletions

View file

@ -1077,6 +1077,13 @@ static void mriBindingExecute() {
#endif #endif
#endif #endif
VALUE rbArgv = rb_get_argv();
for (const auto &str : conf.launchArgs)
rb_ary_push(rbArgv, rb_utf8_str_new_cstr(str.c_str()));
// Duplicates get pushed for some reason
rb_funcall(rbArgv, rb_intern("uniq!"), 0);
VALUE lpaths = rb_gv_get(":"); VALUE lpaths = rb_gv_get(":");
if (!conf.rubyLoadpaths.empty()) { if (!conf.rubyLoadpaths.empty()) {
/* Setup custom load paths */ /* Setup custom load paths */

View file

@ -323,5 +323,17 @@
// is a tiny bit less intrusive. // is a tiny bit less intrusive.
// //
// "execName": "Game" // "execName": "Game"
// You can define alternate terminology for the different
// inputs recognized by RPG Maker. A, B, C, X, Y, Z, L, and R
// can all be set using this dictionary, and will be displayed
// on the F1 menu. This is only a cosmetic effect, so it will
// have no effect on the game's scripts.
//
// "bindingNames": {
// "c": "Confirm",
// "b": "Cancel",
// "x": ...
// }
} }

View file

@ -236,6 +236,11 @@ try { exp } catch (...) {}
editor.debug = true; editor.debug = true;
else if (!strcmp(argv[1], "btest")) else if (!strcmp(argv[1], "btest"))
editor.battleTest = true; editor.battleTest = true;
for (int i = 1; i < argc; i++) {
const char *arg = argv[i];
launchArgs.push_back(argv[i]);
}
} }
if (mkxp_fs::fileExists(CONF_FILE)) { if (mkxp_fs::fileExists(CONF_FILE)) {

View file

@ -1,23 +1,23 @@
/* /*
** config.h ** config.h
** **
** This file is part of mkxp. ** This file is part of mkxp.
** **
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com> ** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
** **
** mkxp is free software: you can redistribute it and/or modify ** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by ** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 2 of the License, or ** the Free Software Foundation, either version 2 of the License, or
** (at your option) any later version. ** (at your option) any later version.
** **
** mkxp is distributed in the hope that it will be useful, ** mkxp is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. ** GNU General Public License for more details.
** **
** You should have received a copy of the GNU General Public License ** You should have received a copy of the GNU General Public License
** along with mkxp. If not, see <http://www.gnu.org/licenses/>. ** along with mkxp. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef CONFIG_H #ifndef CONFIG_H
#define CONFIG_H #define CONFIG_H
@ -27,85 +27,87 @@
#include <vector> #include <vector>
struct Config { struct Config {
int rgssVersion; int rgssVersion;
bool debugMode;
bool printFPS;
bool winResizable;
bool fullscreen;
bool fixedAspectRatio;
bool smoothScaling;
bool vsync;
int defScreenW;
int defScreenH;
std::string windowTitle;
int fixedFramerate;
bool frameSkip;
bool syncToRefreshrate;
bool solidFonts;
bool subImageFix;
bool enableBlitting;
int maxTextureSize;
std::string gameFolder;
bool anyAltToggleFS;
bool enableReset;
bool allowSymlinks;
bool pathCache;
std::string dataPathOrg;
std::string dataPathApp;
std::string iconPath;
std::string execName;
std::string titleLanguage;
struct {
std::string soundFont;
bool chorus;
bool reverb;
} midi;
struct {
int sourceCount;
} SE;
bool useScriptNames;
std::string customScript;
std::vector<std::string> preloadScripts;
std::vector<std::string> rtps;
std::vector<std::string> fontSubs;
std::vector<std::string> rubyLoadpaths;
/* Editor flags */
struct {
bool debug;
bool battleTest;
} editor;
/* Game INI contents */
struct {
std::string scripts;
std::string title;
} game;
// JIT Options bool debugMode;
struct { bool printFPS;
bool enabled;
int verboseLevel;
int maxCache;
int minCalls;
} jit;
// Keybinding action name mappings bool winResizable;
bool fullscreen;
bool fixedAspectRatio;
bool smoothScaling;
bool vsync;
int defScreenW;
int defScreenH;
std::string windowTitle;
int fixedFramerate;
bool frameSkip;
bool syncToRefreshrate;
bool solidFonts;
bool subImageFix;
bool enableBlitting;
int maxTextureSize;
std::string gameFolder;
bool anyAltToggleFS;
bool enableReset;
bool allowSymlinks;
bool pathCache;
std::string dataPathOrg;
std::string dataPathApp;
std::string iconPath;
std::string execName;
std::string titleLanguage;
struct {
std::string soundFont;
bool chorus;
bool reverb;
} midi;
struct {
int sourceCount;
} SE;
bool useScriptNames;
std::string customScript;
std::vector<std::string> launchArgs;
std::vector<std::string> preloadScripts;
std::vector<std::string> rtps;
std::vector<std::string> fontSubs;
std::vector<std::string> rubyLoadpaths;
/* Editor flags */
struct {
bool debug;
bool battleTest;
} editor;
/* Game INI contents */
struct {
std::string scripts;
std::string title;
} game;
// JIT Options
struct {
bool enabled;
int verboseLevel;
int maxCache;
int minCalls;
} jit;
// Keybinding action name mappings
struct { struct {
std::string a; std::string a;
std::string b; std::string b;
@ -118,15 +120,15 @@ struct Config {
std::string l; std::string l;
std::string r; std::string r;
} kbActionNames; } kbActionNames;
/* Internal */ /* Internal */
std::string customDataPath; std::string customDataPath;
std::string commonDataPath; std::string commonDataPath;
Config(); Config();
void read(int argc, char *argv[]); void read(int argc, char *argv[]);
void readGameINI(); void readGameINI();
}; };
#endif // CONFIG_H #endif // CONFIG_H