diff options
Diffstat (limited to 'main')
-rw-r--r-- | main/SCsub | 2 | ||||
-rw-r--r-- | main/input_default.cpp | 36 | ||||
-rw-r--r-- | main/input_default.h | 6 | ||||
-rw-r--r-- | main/main.cpp | 10 | ||||
-rw-r--r-- | main/tests/test_gui.cpp | 4 |
5 files changed, 38 insertions, 20 deletions
diff --git a/main/SCsub b/main/SCsub index 9eddc4f5b6..e2bf03234f 100644 --- a/main/SCsub +++ b/main/SCsub @@ -121,7 +121,7 @@ def make_default_controller_mappings(target, source, env): g.write("\t\"{}\",\n".format(mapping)) g.write("#endif\n") - g.write("};\n") + g.write("\tNULL\n};\n") g.close() env.main_sources = [] diff --git a/main/input_default.cpp b/main/input_default.cpp index c3bc83b2de..3c40be5082 100644 --- a/main/input_default.cpp +++ b/main/input_default.cpp @@ -127,6 +127,14 @@ bool InputDefault::is_action_just_released(const StringName &p_action) const { } } +float InputDefault::get_action_strength(const StringName &p_action) const { + const Map<StringName, Action>::Element *E = action_state.find(p_action); + if (!E) + return 0.0f; + + return E->get().strength; +} + float InputDefault::get_joy_axis(int p_device, int p_axis) const { _THREAD_SAFE_METHOD_ @@ -330,16 +338,18 @@ void InputDefault::parse_input_event(const Ref<InputEvent> &p_event) { } } - if (!p_event->is_echo()) { - for (const Map<StringName, InputMap::Action>::Element *E = InputMap::get_singleton()->get_action_map().front(); E; E = E->next()) { + for (const Map<StringName, InputMap::Action>::Element *E = InputMap::get_singleton()->get_action_map().front(); E; E = E->next()) { + if (InputMap::get_singleton()->event_is_action(p_event, E->key())) { - if (InputMap::get_singleton()->event_is_action(p_event, E->key()) && is_action_pressed(E->key()) != p_event->is_pressed()) { + // Save the action's state + if (!p_event->is_echo() && is_action_pressed(E->key()) != p_event->is_action_pressed(E->key())) { Action action; action.physics_frame = Engine::get_singleton()->get_physics_frames(); action.idle_frame = Engine::get_singleton()->get_idle_frames(); - action.pressed = p_event->is_pressed(); + action.pressed = p_event->is_action_pressed(E->key()); action_state[E->key()] = action; } + action_state[E->key()].strength = p_event->get_action_strength(E->key()); } } @@ -413,10 +423,6 @@ void InputDefault::set_mouse_position(const Point2 &p_posf) { mouse_speed_track.update(p_posf - mouse_pos); mouse_pos = p_posf; - if (custom_cursor.is_valid()) { - //removed, please insist that we implement hardware cursors - // VisualServer::get_singleton()->cursor_set_pos(get_mouse_position()); - } } Point2 InputDefault::get_mouse_position() const { @@ -499,15 +505,19 @@ bool InputDefault::is_emulating_touchscreen() const { return emulate_touch; } +Input::CursorShape InputDefault::get_default_cursor_shape() { + return default_shape; +} + +void InputDefault::set_default_cursor_shape(CursorShape p_shape) { + default_shape = p_shape; + OS::get_singleton()->set_cursor_shape((OS::CursorShape)p_shape); +} + void InputDefault::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) { if (Engine::get_singleton()->is_editor_hint()) return; - if (custom_cursor == p_cursor) - return; - - custom_cursor = p_cursor; - OS::get_singleton()->set_custom_mouse_cursor(p_cursor, (OS::CursorShape)p_shape, p_hotspot); } diff --git a/main/input_default.h b/main/input_default.h index 0479fdc0ff..6dd88cd31e 100644 --- a/main/input_default.h +++ b/main/input_default.h @@ -55,6 +55,7 @@ class InputDefault : public Input { uint64_t physics_frame; uint64_t idle_frame; bool pressed; + float strength; }; Map<StringName, Action> action_state; @@ -115,7 +116,7 @@ class InputDefault : public Input { SpeedTrack mouse_speed_track; Map<int, Joypad> joy_names; int fallback_mapping; - RES custom_cursor; + CursorShape default_shape = CURSOR_ARROW; public: enum HatMask { @@ -182,6 +183,7 @@ public: virtual bool is_action_pressed(const StringName &p_action) const; virtual bool is_action_just_pressed(const StringName &p_action) const; virtual bool is_action_just_released(const StringName &p_action) const; + virtual float get_action_strength(const StringName &p_action) const; virtual float get_joy_axis(int p_device, int p_axis) const; String get_joy_name(int p_idx); @@ -226,6 +228,8 @@ public: void set_emulate_touch(bool p_emulate); virtual bool is_emulating_touchscreen() const; + virtual CursorShape get_default_cursor_shape(); + virtual void set_default_cursor_shape(CursorShape p_shape); virtual void set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape = Input::CURSOR_ARROW, const Vector2 &p_hotspot = Vector2()); virtual void set_mouse_in_window(bool p_in_window); diff --git a/main/main.cpp b/main/main.cpp index a59ca3da3b..3542133719 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -1312,7 +1312,7 @@ bool Main::start() { DocData docsrc; Map<String, String> doc_data_classes; Set<String> checked_paths; - print_line("Loading docs.."); + print_line("Loading docs..."); for (int i = 0; i < _doc_data_class_path_count; i++) { String path = doc_tool.plus_file(_doc_data_class_paths[i].path); @@ -1330,14 +1330,14 @@ bool Main::start() { checked_paths.insert(index_path); print_line("Loading docs from: " + index_path); - print_line("Merging docs.."); + print_line("Merging docs..."); doc.merge_from(docsrc); for (Set<String>::Element *E = checked_paths.front(); E; E = E->next()) { print_line("Erasing old docs at: " + E->get()); DocData::erase_classes(E->get()); } - print_line("Generating new docs.."); + print_line("Generating new docs..."); doc.save_classes(index_path, doc_data_classes); return false; @@ -1512,7 +1512,7 @@ bool Main::start() { bool snap_controls = GLOBAL_DEF("gui/common/snap_controls_to_pixels", true); sml->get_root()->set_snap_controls_to_pixels(snap_controls); - bool font_oversampling = GLOBAL_DEF("rendering/quality/dynamic_fonts/use_oversampling", false); + bool font_oversampling = GLOBAL_DEF("rendering/quality/dynamic_fonts/use_oversampling", true); sml->set_use_font_oversampling(font_oversampling); } else { @@ -1525,7 +1525,7 @@ bool Main::start() { sml->set_auto_accept_quit(GLOBAL_DEF("application/config/auto_accept_quit", true)); sml->set_quit_on_go_back(GLOBAL_DEF("application/config/quit_on_go_back", true)); GLOBAL_DEF("gui/common/snap_controls_to_pixels", true); - GLOBAL_DEF("rendering/quality/dynamic_fonts/use_oversampling", false); + GLOBAL_DEF("rendering/quality/dynamic_fonts/use_oversampling", true); } String local_game_path; diff --git a/main/tests/test_gui.cpp b/main/tests/test_gui.cpp index b7b6c21692..305b749717 100644 --- a/main/tests/test_gui.cpp +++ b/main/tests/test_gui.cpp @@ -185,6 +185,10 @@ public: popup->add_item("Popup"); popup->add_check_item("Check Popup"); popup->set_item_checked(4, true); + popup->add_separator(); + popup->add_radio_check_item("Option A"); + popup->set_item_checked(6, true); + popup->add_radio_check_item("Option B"); OptionButton *options = memnew(OptionButton); |