Set debug variables from argv #191
					 5 changed files with 46 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -147,7 +147,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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -88,6 +88,12 @@ struct Config
 | 
			
		|||
 | 
			
		||||
	std::vector<std::string> rubyLoadpaths;
 | 
			
		||||
 | 
			
		||||
	/* Editor flags */
 | 
			
		||||
	struct {
 | 
			
		||||
		bool debug;
 | 
			
		||||
		bool battleTest;
 | 
			
		||||
	} editor;
 | 
			
		||||
 | 
			
		||||
	/* Game INI contents */
 | 
			
		||||
	struct {
 | 
			
		||||
		std::string scripts;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -508,7 +508,7 @@ findFontsFolderCB(void *data, const char *, const char *fname)
 | 
			
		|||
	char buffer[512];
 | 
			
		||||
	const char *s = fname;
 | 
			
		||||
 | 
			
		||||
	while (s && i < sizeof(buffer))
 | 
			
		||||
	while (*s && i < sizeof(buffer))
 | 
			
		||||
		buffer[i++] = tolower(*s++);
 | 
			
		||||
| 
					
	
 Looks like a commit from master sneaked in Looks like a commit from master sneaked in 
			
			
		 | 
			||||
 | 
			
		||||
	buffer[i] = '\0';
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	
Might want to set
TESThere too according torgssVerlike you did in MRI, just for consistency.