Config: Set debug editor's debug variables into ruby

This commit is contained in:
ReinUsesLisp 2018-02-22 04:37:47 -03:00 committed by Jonas Kulla
parent 9f44ee5068
commit b5e5a26d8b
4 changed files with 45 additions and 0 deletions

View File

@ -147,7 +147,16 @@ static void mriBindingInit()
_rb_define_module_function(mod, "raw_key_states", mkxpRawKeyStates); _rb_define_module_function(mod, "raw_key_states", mkxpRawKeyStates);
_rb_define_module_function(mod, "mouse_in_window", mkxpMouseInWindow); _rb_define_module_function(mod, "mouse_in_window", mkxpMouseInWindow);
/* Load global constants */
rb_gv_set("MKXP", Qtrue); rb_gv_set("MKXP", Qtrue);
VALUE debug = rb_bool_new(shState->config().editor.debug);
if (rgssVer == 1)
rb_gv_set("DEBUG", debug);
else if (rgssVer >= 2)
rb_gv_set("TEST", debug);
rb_gv_set("BTEST", rb_bool_new(shState->config().editor.battleTest));
} }
static void static void

View File

@ -114,8 +114,17 @@ static void mrbBindingInit(mrb_state *mrb)
/* Load RPG module */ /* Load RPG module */
mrb_load_irep(mrb, mrbModuleRPG); mrb_load_irep(mrb, mrbModuleRPG);
/* Load global constants */
mrb_define_global_const(mrb, "MKXP", mrb_true_value()); mrb_define_global_const(mrb, "MKXP", mrb_true_value());
mrb_value debug = rb_bool_new(shState->config().editor.debug);
if (rgssVer == 1)
mrb_define_global_const(mrb, "DEBUG", debug);
else if (rgssVer >= 2)
mrb_define_global_const(mrb, "TEST", debug);
mrb_define_global_const(mrb, "BTEST", mrb_bool_value(shState->config().editor.battleTest));
mrb_gc_arena_restore(mrb, arena); mrb_gc_arena_restore(mrb, arena);
} }

View File

@ -189,6 +189,27 @@ void Config::read(int argc, char *argv[])
// Not gonna take your shit boost // Not gonna take your shit boost
#define GUARD_ALL( exp ) try { exp } catch(...) {} #define GUARD_ALL( exp ) try { exp } catch(...) {}
editor.debug = false;
editor.battleTest = false;
/* Read arguments sent from the editor */
if (argc > 1)
{
std::string argv1 = argv[1];
/* RGSS1 uses "debug", 2 and 3 use "test" */
if (argv1 == "debug" || argv1 == "test")
editor.debug = true;
else if (argv1 == "btest")
editor.battleTest = true;
/* Fix offset */
if (editor.debug || editor.battleTest)
{
argc--;
argv++;
}
}
#define PO_DESC(key, type, def) (#key, po::value< type >()->default_value(def)) #define PO_DESC(key, type, def) (#key, po::value< type >()->default_value(def))
po::options_description podesc; po::options_description podesc;

View File

@ -88,6 +88,12 @@ struct Config
std::vector<std::string> rubyLoadpaths; std::vector<std::string> rubyLoadpaths;
/* Editor flags */
struct {
bool debug;
bool battleTest;
} editor;
/* Game INI contents */ /* Game INI contents */
struct { struct {
std::string scripts; std::string scripts;