diff options
Diffstat (limited to 'core/globals.cpp')
-rw-r--r-- | core/globals.cpp | 56 |
1 files changed, 43 insertions, 13 deletions
diff --git a/core/globals.cpp b/core/globals.cpp index aee708d0cd..5f52420735 100644 --- a/core/globals.cpp +++ b/core/globals.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -132,8 +132,12 @@ bool Globals::_set(const StringName& p_name, const Variant& p_value) { if (props.has(p_name)) { if (!props[p_name].overrided) props[p_name].variant=p_value; + + if (props[p_name].order>=NO_ORDER_BASE && registering_order) { + props[p_name].order=last_order++; + } } else { - props[p_name]=VariantContainer(p_value,last_order++); + props[p_name]=VariantContainer(p_value,last_order++ + (registering_order?0:NO_ORDER_BASE)); } } @@ -300,6 +304,7 @@ Error Globals::setup(const String& p_path,const String & p_main_pack) { return OK; } + if (OS::get_singleton()->get_resource_dir()!="") { //OS will call Globals->get_resource_path which will be empty if not overriden! //if the OS would rather use somewhere else, then it will not be empty. @@ -309,7 +314,7 @@ Error Globals::setup(const String& p_path,const String & p_main_pack) { print_line("has res dir: "+resource_path); if (!_load_resource_pack("res://data.pck")) - _load_resource_pack("res://data.pcz"); + _load_resource_pack("res://data.zip"); // make sure this is load from the resource path print_line("exists engine cfg? "+itos(FileAccess::exists("/engine.cfg"))); if (_load_settings("res://engine.cfg")==OK || _load_settings_binary("res://engine.cfb")==OK) { @@ -340,7 +345,7 @@ Error Globals::setup(const String& p_path,const String & p_main_pack) { //try to load settings in ascending through dirs shape! //tries to open pack, but only first time - if (first_time && (_load_resource_pack(current_dir+"/"+exec_name+".pck") || _load_resource_pack(current_dir+"/"+exec_name+".pcz") )) { + if (first_time && (_load_resource_pack(current_dir+"/"+exec_name+".pck") || _load_resource_pack(current_dir+"/"+exec_name+".zip") )) { if (_load_settings("res://engine.cfg")==OK || _load_settings_binary("res://engine.cfb")==OK) { _load_settings("res://override.cfg"); @@ -349,7 +354,7 @@ Error Globals::setup(const String& p_path,const String & p_main_pack) { } break; - } else if (first_time && (_load_resource_pack(current_dir+"/data.pck") || _load_resource_pack(current_dir+"/data.pcz") )) { + } else if (first_time && (_load_resource_pack(current_dir+"/data.pck") || _load_resource_pack(current_dir+"/data.zip") )) { if (_load_settings("res://engine.cfg")==OK || _load_settings_binary("res://engine.cfb")==OK) { _load_settings("res://override.cfg"); @@ -633,7 +638,9 @@ static Variant _decode_variant(const String& p_string) { InputEvent ie; ie.type=InputEvent::JOYSTICK_MOTION; ie.device=params[0].to_int(); - ie.joy_motion.axis=params[1].to_int(); + int axis = params[1].to_int();; + ie.joy_motion.axis=axis>>1; + ie.joy_motion.axis_value=axis&1?1:-1; return ie; } @@ -741,6 +748,10 @@ static Variant _decode_variant(const String& p_string) { return Variant(); } +void Globals::set_registering_order(bool p_enable) { + + registering_order=p_enable; +} Error Globals::_load_settings_binary(const String p_path) { @@ -760,6 +771,8 @@ Error Globals::_load_settings_binary(const String p_path) { ERR_FAIL_V(ERR_FILE_CORRUPT;) } + set_registering_order(false); + uint32_t count=f->get_32(); for(int i=0;i<count;i++) { @@ -784,6 +797,9 @@ Error Globals::_load_settings_binary(const String p_path) { set_persisting(key,true); } + set_registering_order(true); + + return OK; } Error Globals::_load_settings(const String p_path) { @@ -802,6 +818,8 @@ Error Globals::_load_settings(const String p_path) { String section; String subpath; + set_registering_order(false); + int line_count = 0; while(!f->eof_reached()) { @@ -877,6 +895,7 @@ Error Globals::_load_settings(const String p_path) { memdelete(f); + set_registering_order(true); return OK; } @@ -1012,7 +1031,7 @@ static String _encode_variant(const Variant& p_variant) { } break; case InputEvent::JOYSTICK_MOTION: { - return "jaxis("+itos(ev.device)+", "+itos(ev.joy_motion.axis)+")"; + return "jaxis("+itos(ev.device)+", "+itos(ev.joy_motion.axis * 2 + (ev.joy_motion.axis_value<0?0:1))+")"; } break; default: { @@ -1374,11 +1393,11 @@ void Globals::_bind_methods() { ObjectTypeDB::bind_method(_MD("localize_path","path"),&Globals::localize_path); ObjectTypeDB::bind_method(_MD("globalize_path","path"),&Globals::globalize_path); ObjectTypeDB::bind_method(_MD("save"),&Globals::save); - ObjectTypeDB::bind_method(_MD("has_singleton"),&Globals::has_singleton); - ObjectTypeDB::bind_method(_MD("get_singleton"),&Globals::get_singleton_object); - ObjectTypeDB::bind_method(_MD("load_resource_pack"),&Globals::_load_resource_pack); + ObjectTypeDB::bind_method(_MD("has_singleton","name"),&Globals::has_singleton); + ObjectTypeDB::bind_method(_MD("get_singleton","name"),&Globals::get_singleton_object); + ObjectTypeDB::bind_method(_MD("load_resource_pack","pack"),&Globals::_load_resource_pack); - ObjectTypeDB::bind_method(_MD("save_custom"),&Globals::_save_custom_bnd); + ObjectTypeDB::bind_method(_MD("save_custom","file"),&Globals::_save_custom_bnd); } @@ -1388,7 +1407,7 @@ Globals::Globals() { singleton=this; last_order=0; disable_platform_override=false; - + registering_order=true; Array va; @@ -1400,7 +1419,7 @@ Globals::Globals() { set("application/name","" ); set("application/main_scene",""); - custom_prop_info["application/main_scene"]=PropertyInfo(Variant::STRING,"application/main_scene",PROPERTY_HINT_FILE,"scn,res,xscn,xml"); + custom_prop_info["application/main_scene"]=PropertyInfo(Variant::STRING,"application/main_scene",PROPERTY_HINT_FILE,"scn,res,xscn,xml,tscn"); set("application/disable_stdout",false); set("application/use_shared_user_dir",true); @@ -1414,6 +1433,7 @@ Globals::Globals() { joyb.joy_button.button_index=JOY_BUTTON_0; va.push_back(joyb); set("input/ui_accept",va); + input_presets.push_back("input/ui_accept"); va=Array(); key.key.scancode=KEY_SPACE; @@ -1421,6 +1441,7 @@ Globals::Globals() { joyb.joy_button.button_index=JOY_BUTTON_3; va.push_back(joyb); set("input/ui_select",va); + input_presets.push_back("input/ui_select"); va=Array(); key.key.scancode=KEY_ESCAPE; @@ -1428,17 +1449,20 @@ Globals::Globals() { joyb.joy_button.button_index=JOY_BUTTON_1; va.push_back(joyb); set("input/ui_cancel",va); + input_presets.push_back("input/ui_cancel"); va=Array(); key.key.scancode=KEY_TAB; va.push_back(key); set("input/ui_focus_next",va); + input_presets.push_back("input/ui_focus_next"); va=Array(); key.key.scancode=KEY_TAB; key.key.mod.shift=true; va.push_back(key); set("input/ui_focus_prev",va); + input_presets.push_back("input/ui_focus_prev"); key.key.mod.shift=false; va=Array(); @@ -1447,6 +1471,7 @@ Globals::Globals() { joyb.joy_button.button_index=JOY_DPAD_LEFT; va.push_back(joyb); set("input/ui_left",va); + input_presets.push_back("input/ui_left"); va=Array(); key.key.scancode=KEY_RIGHT; @@ -1454,6 +1479,7 @@ Globals::Globals() { joyb.joy_button.button_index=JOY_DPAD_RIGHT; va.push_back(joyb); set("input/ui_right",va); + input_presets.push_back("input/ui_right"); va=Array(); key.key.scancode=KEY_UP; @@ -1461,6 +1487,7 @@ Globals::Globals() { joyb.joy_button.button_index=JOY_DPAD_UP; va.push_back(joyb); set("input/ui_up",va); + input_presets.push_back("input/ui_up"); va=Array(); key.key.scancode=KEY_DOWN; @@ -1468,17 +1495,20 @@ Globals::Globals() { joyb.joy_button.button_index=JOY_DPAD_DOWN; va.push_back(joyb); set("input/ui_down",va); + input_presets.push_back("input/ui_down"); va=Array(); key.key.scancode=KEY_PAGEUP; va.push_back(key); set("input/ui_page_up",va); + input_presets.push_back("input/ui_page_up"); va=Array(); key.key.scancode=KEY_PAGEDOWN; va.push_back(key); set("input/ui_page_down",va); + input_presets.push_back("input/ui_page_down"); // set("display/orientation", "landscape"); |