diff --git a/binding-mri/binding-mri.cpp b/binding-mri/binding-mri.cpp index 57e6db1..1bb8f96 100644 --- a/binding-mri/binding-mri.cpp +++ b/binding-mri/binding-mri.cpp @@ -149,7 +149,16 @@ static void mriBindingInit() _rb_define_module_function(mod, "raw_key_states", mkxpRawKeyStates); _rb_define_module_function(mod, "mouse_in_window", mkxpMouseInWindow); + /* Load global constants */ 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 diff --git a/binding-mruby/binding-mruby.cpp b/binding-mruby/binding-mruby.cpp index 867d2d6..a713d73 100644 --- a/binding-mruby/binding-mruby.cpp +++ b/binding-mruby/binding-mruby.cpp @@ -114,8 +114,17 @@ static void mrbBindingInit(mrb_state *mrb) /* Load RPG module */ mrb_load_irep(mrb, mrbModuleRPG); + /* Load global constants */ 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); } diff --git a/src/config.cpp b/src/config.cpp index fdc0033..e98e781 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -189,6 +189,27 @@ void Config::read(int argc, char *argv[]) // Not gonna take your shit boost #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)) po::options_description podesc; diff --git a/src/config.h b/src/config.h index 5060e60..ba2b88c 100644 --- a/src/config.h +++ b/src/config.h @@ -94,6 +94,12 @@ struct Config std::vector rubyLoadpaths; + /* Editor flags */ + struct { + bool debug; + bool battleTest; + } editor; + /* Game INI contents */ struct { std::string scripts;