diff options
Diffstat (limited to 'main')
-rw-r--r-- | main/input_default.cpp | 343 | ||||
-rw-r--r-- | main/input_default.h | 83 | ||||
-rw-r--r-- | main/main.cpp | 222 |
3 files changed, 582 insertions, 66 deletions
diff --git a/main/input_default.cpp b/main/input_default.cpp new file mode 100644 index 0000000000..878d21c302 --- /dev/null +++ b/main/input_default.cpp @@ -0,0 +1,343 @@ +#include "input_default.h" +#include "servers/visual_server.h" +#include "os/os.h" +#include "input_map.h" + +void InputDefault::SpeedTrack::update(const Vector2& p_delta_p) { + + uint64_t tick = OS::get_singleton()->get_ticks_usec(); + uint32_t tdiff = tick-last_tick; + float delta_t = tdiff / 1000000.0; + last_tick=tick; + + + accum+=p_delta_p; + accum_t+=delta_t; + + if (accum_t>max_ref_frame*10) + accum_t=max_ref_frame*10; + + while( accum_t>=min_ref_frame ) { + + float slice_t = min_ref_frame / accum_t; + Vector2 slice = accum*slice_t; + accum=accum-slice; + accum_t-=min_ref_frame; + + speed=(slice/min_ref_frame).linear_interpolate(speed,min_ref_frame/max_ref_frame); + } + +} + +void InputDefault::SpeedTrack::reset() { + last_tick = OS::get_singleton()->get_ticks_usec(); + speed=Vector2(); + accum_t=0; +} + +InputDefault::SpeedTrack::SpeedTrack() { + + min_ref_frame=0.1; + max_ref_frame=0.3; + reset(); +} + +bool InputDefault::is_key_pressed(int p_scancode) { + + _THREAD_SAFE_METHOD_ + return keys_pressed.has(p_scancode); +} + +bool InputDefault::is_mouse_button_pressed(int p_button) { + + _THREAD_SAFE_METHOD_ + return (mouse_button_mask&(1<<p_button))!=0; +} + + +static int _combine_device(int p_value,int p_device) { + + return p_value|(p_device<<20); +} + +bool InputDefault::is_joy_button_pressed(int p_device, int p_button) { + + _THREAD_SAFE_METHOD_ + return joy_buttons_pressed.has(_combine_device(p_button,p_device)); +} + +bool InputDefault::is_action_pressed(const StringName& p_action) { + + if (custom_action_press.has(p_action)) + return true; //simpler + + const List<InputEvent> *alist = InputMap::get_singleton()->get_action_list(p_action); + if (!alist) + return NULL; + + + for (const List<InputEvent>::Element *E=alist->front();E;E=E->next()) { + + + int device=E->get().device; + + switch(E->get().type) { + + case InputEvent::KEY: { + + const InputEventKey &iek=E->get().key; + if ((keys_pressed.has(iek.scancode))) + return true; + } break; + case InputEvent::MOUSE_BUTTON: { + + const InputEventMouseButton &iemb=E->get().mouse_button; + if(mouse_button_mask&(1<<iemb.button_index)) + return true; + } break; + case InputEvent::JOYSTICK_BUTTON: { + + const InputEventJoystickButton &iejb=E->get().joy_button; + int c = _combine_device(iejb.button_index,device); + if (joy_buttons_pressed.has(c)) + return true; + } break; + } + } + + return false; +} + +float InputDefault::get_joy_axis(int p_device,int p_axis) { + + _THREAD_SAFE_METHOD_ + int c = _combine_device(p_axis,p_device); + if (joy_axis.has(c)) { + return joy_axis[c]; + } else { + return 0; + } +} + +String InputDefault::get_joy_name(int p_idx) { + + _THREAD_SAFE_METHOD_ + return joy_names[p_idx]; +}; + +void InputDefault::joy_connection_changed(int p_idx, bool p_connected, String p_name) { + + _THREAD_SAFE_METHOD_ + joy_names[p_idx] = p_connected ? p_name : ""; + + emit_signal("joy_connection_changed", p_idx, p_connected); +}; + +Vector3 InputDefault::get_accelerometer() { + + _THREAD_SAFE_METHOD_ + return accelerometer; +} + +void InputDefault::parse_input_event(const InputEvent& p_event) { + + _THREAD_SAFE_METHOD_ + switch(p_event.type) { + + case InputEvent::KEY: { + + if (p_event.key.echo) + break; + if (p_event.key.scancode==0) + break; + + // print_line(p_event); + + if (p_event.key.pressed) + keys_pressed.insert(p_event.key.scancode); + else + keys_pressed.erase(p_event.key.scancode); + } break; + case InputEvent::MOUSE_BUTTON: { + + if (p_event.mouse_button.doubleclick) + break; + + if (p_event.mouse_button.pressed) + mouse_button_mask|=(1<<p_event.mouse_button.button_index); + else + mouse_button_mask&=~(1<<p_event.mouse_button.button_index); + + if (main_loop && emulate_touch && p_event.mouse_button.button_index==1) { + InputEventScreenTouch touch_event; + touch_event.index=0; + touch_event.pressed=p_event.mouse_button.pressed; + touch_event.x=p_event.mouse_button.x; + touch_event.y=p_event.mouse_button.y; + InputEvent ev; + ev.type=InputEvent::SCREEN_TOUCH; + ev.screen_touch=touch_event; + main_loop->input_event(ev); + } + } break; + case InputEvent::MOUSE_MOTION: { + + if (main_loop && emulate_touch && p_event.mouse_motion.button_mask&1) { + InputEventScreenDrag drag_event; + drag_event.index=0; + drag_event.x=p_event.mouse_motion.x; + drag_event.y=p_event.mouse_motion.y; + drag_event.relative_x=p_event.mouse_motion.relative_x; + drag_event.relative_y=p_event.mouse_motion.relative_y; + drag_event.speed_x=p_event.mouse_motion.speed_x; + drag_event.speed_y=p_event.mouse_motion.speed_y; + + InputEvent ev; + ev.type=InputEvent::SCREEN_DRAG; + ev.screen_drag=drag_event; + + main_loop->input_event(ev); + } + + } break; + case InputEvent::JOYSTICK_BUTTON: { + + int c = _combine_device(p_event.joy_button.button_index,p_event.device); + + if (p_event.joy_button.pressed) + joy_buttons_pressed.insert(c); + else + joy_buttons_pressed.erase(c); + } break; + case InputEvent::JOYSTICK_MOTION: { + set_joy_axis(p_event.device, p_event.joy_motion.axis, p_event.joy_motion.axis_value); + } break; + + } + + if (main_loop) + main_loop->input_event(p_event); + +} + +void InputDefault::set_joy_axis(int p_device,int p_axis,float p_value) { + + _THREAD_SAFE_METHOD_ + int c = _combine_device(p_axis,p_device); + joy_axis[c]=p_value; +} + +void InputDefault::set_accelerometer(const Vector3& p_accel) { + + _THREAD_SAFE_METHOD_ + + accelerometer=p_accel; + +} + +void InputDefault::set_main_loop(MainLoop *p_main_loop) { + main_loop=p_main_loop; + +} + +void InputDefault::set_mouse_pos(const Point2& p_posf) { + + mouse_speed_track.update(p_posf-mouse_pos); + mouse_pos=p_posf; + if (custom_cursor.is_valid()) { + VisualServer::get_singleton()->cursor_set_pos(get_mouse_pos()); + } +} + +Point2 InputDefault::get_mouse_pos() const { + + return mouse_pos; +} +Point2 InputDefault::get_mouse_speed() const { + + return mouse_speed_track.speed; +} + +int InputDefault::get_mouse_button_mask() const { + + return OS::get_singleton()->get_mouse_button_state(); +} + +void InputDefault::warp_mouse_pos(const Vector2& p_to) { + + OS::get_singleton()->warp_mouse_pos(p_to); +} + + +void InputDefault::iteration(float p_step) { + + +} + +void InputDefault::action_press(const StringName& p_action) { + + if (custom_action_press.has(p_action)) { + + custom_action_press[p_action]++; + } else { + custom_action_press[p_action]=1; + } +} + +void InputDefault::action_release(const StringName& p_action){ + + ERR_FAIL_COND(!custom_action_press.has(p_action)); + custom_action_press[p_action]--; + if (custom_action_press[p_action]==0) { + custom_action_press.erase(p_action); + } +} + +void InputDefault::set_emulate_touch(bool p_emulate) { + + emulate_touch=p_emulate; +} + +bool InputDefault::is_emulating_touchscreen() const { + + return emulate_touch; +} + +void InputDefault::set_custom_mouse_cursor(const RES& p_cursor,const Vector2& p_hotspot) { + if (custom_cursor==p_cursor) + return; + + custom_cursor=p_cursor; + + if (p_cursor.is_null()) { + set_mouse_mode(MOUSE_MODE_VISIBLE); + VisualServer::get_singleton()->cursor_set_visible(false); + } else { + set_mouse_mode(MOUSE_MODE_HIDDEN); + VisualServer::get_singleton()->cursor_set_visible(true); + VisualServer::get_singleton()->cursor_set_texture(custom_cursor->get_rid(),p_hotspot); + VisualServer::get_singleton()->cursor_set_pos(get_mouse_pos()); + } +} + +void InputDefault::set_mouse_in_window(bool p_in_window) { + + if (custom_cursor.is_valid()) { + + if (p_in_window) { + set_mouse_mode(MOUSE_MODE_HIDDEN); + VisualServer::get_singleton()->cursor_set_visible(true); + } else { + set_mouse_mode(MOUSE_MODE_VISIBLE); + VisualServer::get_singleton()->cursor_set_visible(false); + } + + } +} + +InputDefault::InputDefault() { + + mouse_button_mask=0; + emulate_touch=false; + main_loop=NULL; +} diff --git a/main/input_default.h b/main/input_default.h new file mode 100644 index 0000000000..2ef4f727c6 --- /dev/null +++ b/main/input_default.h @@ -0,0 +1,83 @@ +#ifndef INPUT_DEFAULT_H +#define INPUT_DEFAULT_H + +#include "os/input.h" + +class InputDefault : public Input { + + OBJ_TYPE( InputDefault, Input ); + _THREAD_SAFE_CLASS_ + + int mouse_button_mask; + Set<int> keys_pressed; + Set<int> joy_buttons_pressed; + Map<int,float> joy_axis; + Map<StringName,int> custom_action_press; + Map<int, String> joy_names; + Vector3 accelerometer; + Vector2 mouse_pos; + MainLoop *main_loop; + + bool emulate_touch; + + struct SpeedTrack { + + uint64_t last_tick; + Vector2 speed; + Vector2 accum; + float accum_t; + float min_ref_frame; + float max_ref_frame; + + void update(const Vector2& p_delta_p); + void reset(); + SpeedTrack(); + }; + + SpeedTrack mouse_speed_track; + + RES custom_cursor; + +public: + + virtual bool is_key_pressed(int p_scancode); + virtual bool is_mouse_button_pressed(int p_button); + virtual bool is_joy_button_pressed(int p_device, int p_button); + virtual bool is_action_pressed(const StringName& p_action); + + virtual float get_joy_axis(int p_device,int p_axis); + String get_joy_name(int p_idx); + void joy_connection_changed(int p_idx, bool p_connected, String p_name); + + virtual Vector3 get_accelerometer(); + + virtual Point2 get_mouse_pos() const; + virtual Point2 get_mouse_speed() const; + virtual int get_mouse_button_mask() const; + + virtual void warp_mouse_pos(const Vector2& p_to); + + + void parse_input_event(const InputEvent& p_event); + void set_accelerometer(const Vector3& p_accel); + void set_joy_axis(int p_device,int p_axis,float p_value); + + void set_main_loop(MainLoop *main_loop); + void set_mouse_pos(const Point2& p_posf); + + void action_press(const StringName& p_action); + void action_release(const StringName& p_action); + + void iteration(float p_step); + + void set_emulate_touch(bool p_emulate); + virtual bool is_emulating_touchscreen() const; + + virtual void set_custom_mouse_cursor(const RES& p_cursor,const Vector2& p_hotspot=Vector2()); + virtual void set_mouse_in_window(bool p_in_window); + + InputDefault(); + +}; + +#endif // INPUT_DEFAULT_H diff --git a/main/main.cpp b/main/main.cpp index 4cf4f3c7cd..9cd190a0e8 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -75,7 +75,7 @@ #include "core/io/file_access_zip.h" #include "translation.h" #include "version.h" - +#include "main/input_default.h" #include "performance.h" static Globals *globals=NULL; @@ -94,11 +94,17 @@ static FileAccessNetworkClient *file_access_network_client=NULL; static TranslationServer *translation_server = NULL; static OS::VideoMode video_mode; +static bool init_maximized=false; +static bool init_fullscreen=false; +static bool init_use_custom_pos=false; +static bool debug_collisions=false; +static bool debug_navigation=false; +static Vector2 init_custom_pos; static int video_driver_idx=-1; static int audio_driver_idx=-1; static String locale; -static bool init_maximized=false; + static int init_screen=-1; static String unescape_cmdline(const String& p_str) { @@ -136,8 +142,10 @@ void Main::print_help(const char* p_binary) { } OS::get_singleton()->print(")\n"); - OS::get_singleton()->print("\t-r WIDTHxHEIGHT\t : Request Screen Resolution\n"); + OS::get_singleton()->print("\t-r WIDTHxHEIGHT\t : Request Window Resolution\n"); + OS::get_singleton()->print("\t-p XxY\t : Request Window Position\n"); OS::get_singleton()->print("\t-f\t\t : Request Fullscreen\n"); + OS::get_singleton()->print("\t-mx\t\t Request Maximized\n"); OS::get_singleton()->print("\t-vd DRIVER\t : Video Driver ("); for (int i=0;i<OS::get_singleton()->get_video_driver_count();i++) { @@ -287,6 +295,7 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas if (vm.find("x")==-1) { // invalid parameter format + OS::get_singleton()->print("Invalid -r argument: %s\n",vm.utf8().get_data()); goto error; @@ -297,6 +306,7 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas if (w==0 || h==0) { + OS::get_singleton()->print("Invalid -r resolution, x and y must be >0\n"); goto error; } @@ -307,11 +317,43 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas N=I->next()->next(); } else { + OS::get_singleton()->print("Invalid -p argument, needs resolution\n"); goto error; } - + } else if (I->get()=="-p") { // position + + if (I->next()) { + + String vm=I->next()->get(); + + if (vm.find("x")==-1) { // invalid parameter format + + OS::get_singleton()->print("Invalid -p argument: %s\n",vm.utf8().get_data()); + goto error; + + + } + + int x=vm.get_slice("x",0).to_int(); + int y=vm.get_slice("x",1).to_int(); + + init_custom_pos=Point2(x,y); + init_use_custom_pos=true; + + N=I->next()->next(); + } else { + OS::get_singleton()->print("Invalid -r argument, needs position\n"); + goto error; + + + } + + + } else if (I->get()=="-mx") { // video driver + + init_maximized=true; } else if (I->get()=="-vd") { // video driver if (I->next()) { @@ -319,6 +361,7 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas video_driver=I->next()->get(); N=I->next()->next(); } else { + OS::get_singleton()->print("Invalid -cd argument, needs driver name\n"); goto error; } @@ -329,6 +372,7 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas locale=I->next()->get(); N=I->next()->next(); } else { + OS::get_singleton()->print("Invalid -lang argument, needs language code\n"); goto error; } @@ -383,7 +427,8 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas } else if (I->get()=="-f") { // fullscreen - video_mode.fullscreen=true; + //video_mode.fullscreen=false; + init_fullscreen=true; } else if (I->get()=="-e" || I->get()=="-editor") { // fonud editor editor=true; @@ -406,7 +451,6 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas } else { game_path=I->next()->get(); //use game_path instead } - N=I->next()->next(); } else { goto error; @@ -472,6 +516,10 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas } else if (I->get()=="-debug" || I->get()=="-d") { debug_mode="local"; + } else if (I->get()=="-debugcol" || I->get()=="-dc") { + debug_collisions=true; + } else if (I->get()=="-debugnav" || I->get()=="-dn") { + debug_navigation=true; } else if (I->get()=="-editor_scene") { if (I->next()) { @@ -487,8 +535,10 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas debug_mode="remote"; debug_host=I->next()->get(); - if (debug_host.find(":")==-1) //wrong host + if (debug_host.find(":")==-1) { //wrong host + OS::get_singleton()->print("Invalid debug host string\n"); goto error; + } N=I->next()->next(); } else { goto error; @@ -518,7 +568,7 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas } - + GLOBAL_DEF("debug/max_remote_stdout_chars_per_second",2048); if (debug_mode == "remote") { ScriptDebuggerRemote *sdr = memnew( ScriptDebuggerRemote ); @@ -651,6 +701,7 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas GLOBAL_DEF("display/resizable",video_mode.resizable); GLOBAL_DEF("display/test_width",0); GLOBAL_DEF("display/test_height",0); + OS::get_singleton()->_pixel_snap=GLOBAL_DEF("display/use_2d_pixel_snap",false); if (rtm==-1) { rtm=GLOBAL_DEF("render/thread_model",OS::RENDER_THREAD_SAFE); if (rtm>=1) //hack for now @@ -732,6 +783,7 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas if (p_second_phase) return setup2(); + return OK; error: @@ -785,6 +837,14 @@ Error Main::setup2() { OS::get_singleton()->initialize(video_mode,video_driver_idx,audio_driver_idx); + if (init_use_custom_pos) { + OS::get_singleton()->set_window_position(init_custom_pos); + } + if (init_maximized) { + OS::get_singleton()->set_window_maximized(true); + } else if (init_fullscreen) { + OS::get_singleton()->set_window_fullscreen(true); + } register_core_singletons(); @@ -801,17 +861,29 @@ Error Main::setup2() { if (init_maximized) { OS::get_singleton()->set_window_maximized(true); } + MAIN_PRINT("Main: Load Remaps"); + + path_remap->load_remaps(); if (show_logo) { //boot logo! String boot_logo_path=GLOBAL_DEF("application/boot_splash",String()); bool boot_logo_scale=GLOBAL_DEF("application/boot_splash_fullsize",true); Globals::get_singleton()->set_custom_property_info("application/boot_splash",PropertyInfo(Variant::STRING,"application/boot_splash",PROPERTY_HINT_FILE,"*.png")); - + print_line("BOOT SPLASH: "+boot_logo_path); Image boot_logo; - if (boot_logo_path.strip_edges()!="" && FileAccess::exists(boot_logo_path)) { - boot_logo.load(boot_logo_path); + boot_logo_path = boot_logo_path.strip_edges(); + print_line("BOOT SPLASH IS : "+boot_logo_path); + + if (boot_logo_path!=String() /*&& FileAccess::exists(boot_logo_path)*/) { + Error err = boot_logo.load(boot_logo_path); + if (err!=OK) { + print_line("ËRROR LOADING BOOT LOGO SPLASH :"+boot_logo_path); + } else { + print_line("BOOT SPLASH OK!"); + + } } if (!boot_logo.empty()) { @@ -822,7 +894,7 @@ Error Main::setup2() { VisualServer::get_singleton()->set_boot_image(boot_logo, boot_bg,boot_logo_scale); #ifndef TOOLS_ENABLED //no tools, so free the boot logo (no longer needed) - Globals::get_singleton()->set("application/boot_logo",Image()); + // Globals::get_singleton()->set("application/boot_logo",Image()); #endif } else { @@ -847,15 +919,38 @@ Error Main::setup2() { GLOBAL_DEF("application/icon",String()); Globals::get_singleton()->set_custom_property_info("application/icon",PropertyInfo(Variant::STRING,"application/icon",PROPERTY_HINT_FILE,"*.png,*.webp")); - MAIN_PRINT("Main: Load Remaps"); + if (bool(GLOBAL_DEF("display/emulate_touchscreen",false))) { + if (!OS::get_singleton()->has_touchscreen_ui_hint() && Input::get_singleton()) { + //only if no touchscreen ui hint, set emulation + InputDefault *id = Input::get_singleton()->cast_to<InputDefault>(); + if (id) + id->set_emulate_touch(true); + } + } - path_remap->load_remaps(); + + + MAIN_PRINT("Main: Load Remaps"); MAIN_PRINT("Main: Load Scene Types"); register_scene_types(); register_server_types(); + GLOBAL_DEF("display/custom_mouse_cursor",String()); + GLOBAL_DEF("display/custom_mouse_cursor_hotspot",Vector2()); + Globals::get_singleton()->set_custom_property_info("display/custom_mouse_cursor",PropertyInfo(Variant::STRING,"display/custom_mouse_cursor",PROPERTY_HINT_FILE,"*.png,*.webp")); + + if (String(Globals::get_singleton()->get("display/custom_mouse_cursor"))!=String()) { + + print_line("use custom cursor"); + Ref<Texture> cursor=ResourceLoader::load(Globals::get_singleton()->get("display/custom_mouse_cursor")); + if (cursor.is_valid()) { + print_line("loaded ok"); + Vector2 hotspot = Globals::get_singleton()->get("display/custom_mouse_cursor_hotspot"); + Input::get_singleton()->set_custom_mouse_cursor(cursor,hotspot); + } + } #ifdef TOOLS_ENABLED EditorNode::register_editor_types(); ObjectTypeDB::register_type<PCKPacker>(); // todo: move somewhere else @@ -912,61 +1007,49 @@ bool Main::start() { bool export_debug=false; List<String> args = OS::get_singleton()->get_cmdline_args(); for (int i=0;i<args.size();i++) { - - - if (args[i]=="-doctool" && i <(args.size()-1)) { - - doc_tool=args[i+1]; + //parameters that have an argument to the right + if (i < (args.size()-1)) { + if (args[i]=="-doctool") { + doc_tool=args[i+1]; + } else if (args[i]=="-script" || args[i]=="-s") { + script=args[i+1]; + } else if (args[i]=="-level" || args[i]=="-l") { + OS::get_singleton()->_custom_level=args[i+1]; + } else if (args[i]=="-test") { + test=args[i+1]; + } else if (args[i]=="-optimize") { + optimize=args[i+1]; + } else if (args[i]=="-optimize_preset") { + optimize_preset=args[i+1]; + } else if (args[i]=="-export") { + editor=true; //needs editor + _export_platform=args[i+1]; + } else if (args[i]=="-export_debug") { + editor=true; //needs editor + _export_platform=args[i+1]; + export_debug=true; + } else if (args[i]=="-import") { + editor=true; //needs editor + _import=args[i+1]; + } else if (args[i]=="-import_script") { + editor=true; //needs editor + _import_script=args[i+1]; + } else if (args[i]=="-dumpstrings") { + editor=true; //needs editor + dumpstrings=args[i+1]; + } i++; - }else if (args[i]=="-nodocbase") { - + } + //parameters that do not have an argument to the right + if (args[i]=="-nodocbase") { doc_base=false; - } else if ((args[i]=="-script" || args[i]=="-s") && i <(args.size()-1)) { - - script=args[i+1]; - i++; - } else if ((args[i]=="-level" || args[i]=="-l") && i <(args.size()-1)) { - - OS::get_singleton()->_custom_level=args[i+1]; - i++; - } else if (args[i]=="-test" && i <(args.size()-1)) { - test=args[i+1]; - i++; - } else if (args[i]=="-optimize" && i <(args.size()-1)) { - optimize=args[i+1]; - i++; - } else if (args[i]=="-optimize_preset" && i <(args.size()-1)) { - optimize_preset=args[i+1]; - i++; - } else if (args[i]=="-export" && i <(args.size()-1)) { - editor=true; //needs editor - _export_platform=args[i+1]; - i++; - } else if (args[i]=="-export_debug" && i <(args.size()-1)) { - editor=true; //needs editor - _export_platform=args[i+1]; - export_debug=true; - i++; - } else if (args[i]=="-import" && i <(args.size()-1)) { - editor=true; //needs editor - _import=args[i+1]; - i++; - } else if (args[i]=="-import_script" && i <(args.size()-1)) { - editor=true; //needs editor - _import_script=args[i+1]; - i++; - } else if (args[i]=="-noquit" ) { + } else if (args[i]=="-noquit") { noquit=true; - } else if (args[i]=="-dumpstrings" && i <(args.size()-1)) { - editor=true; //needs editor - dumpstrings=args[i+1]; - i++; - } else if (args[i]=="-editor" || args[i]=="-e") { - editor=true; } else if (args[i]=="-convert_old") { convert_old=true; + } else if (args[i]=="-editor" || args[i]=="-e") { + editor=true; } else if (args[i].length() && args[i][0] != '-' && game_path == "") { - game_path=args[i]; } } @@ -1083,8 +1166,15 @@ bool Main::start() { SceneTree *sml = main_loop->cast_to<SceneTree>(); + if (debug_collisions) { + sml->set_debug_collisions_hint(true); + } + if (debug_navigation) { + sml->set_debug_navigation_hint(true); + } #ifdef TOOLS_ENABLED + EditorNode *editor_node=NULL; if (editor) { @@ -1454,9 +1544,9 @@ bool Main::iteration() { OS::get_singleton()->delay_usec( OS::get_singleton()->get_frame_delay()*1000 ); } - int taret_fps = OS::get_singleton()->get_target_fps(); - if (taret_fps>0) { - uint64_t time_step = 1000000L/taret_fps; + int target_fps = OS::get_singleton()->get_target_fps(); + if (target_fps>0) { + uint64_t time_step = 1000000L/target_fps; target_ticks += time_step; uint64_t current_ticks = OS::get_singleton()->get_ticks_usec(); if (current_ticks<target_ticks) OS::get_singleton()->delay_usec(target_ticks-current_ticks); |