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
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(":");
if (!conf.rubyLoadpaths.empty()) {
/* Setup custom load paths */

View file

@ -323,5 +323,17 @@
// is a tiny bit less intrusive.
//
// "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;
else if (!strcmp(argv[1], "btest"))
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)) {

View file

@ -1,23 +1,23 @@
/*
** config.h
**
** This file is part of mkxp.
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 2 of the License, or
** (at your option) any later version.
**
** mkxp is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with mkxp. If not, see <http://www.gnu.org/licenses/>.
*/
** config.h
**
** This file is part of mkxp.
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 2 of the License, or
** (at your option) any later version.
**
** mkxp is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with mkxp. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CONFIG_H
#define CONFIG_H
@ -27,85 +27,87 @@
#include <vector>
struct Config {
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;
int rgssVersion;
// JIT Options
struct {
bool enabled;
int verboseLevel;
int maxCache;
int minCalls;
} jit;
bool debugMode;
bool printFPS;
// 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 {
std::string a;
std::string b;
@ -118,15 +120,15 @@ struct Config {
std::string l;
std::string r;
} kbActionNames;
/* Internal */
std::string customDataPath;
std::string commonDataPath;
Config();
void read(int argc, char *argv[]);
void readGameINI();
/* Internal */
std::string customDataPath;
std::string commonDataPath;
Config();
void read(int argc, char *argv[]);
void readGameINI();
};
#endif // CONFIG_H