From c3e2455fce8b1fa9779f9b1d178c5a60f2af98ba Mon Sep 17 00:00:00 2001 From: Raoul1808 Date: Sat, 19 Dec 2020 15:19:57 +0100 Subject: [PATCH 1/3] Added 3x scroll speed in editor when holding down action --- src/editor/editor.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/editor/editor.cpp b/src/editor/editor.cpp index 9e310b07a02..a6b3c1e4195 100644 --- a/src/editor/editor.cpp +++ b/src/editor/editor.cpp @@ -385,20 +385,26 @@ Editor::update_keyboard(const Controller& controller) return; } + float scroll_velocity = 32.0f; + + if (controller.hold(Control::ACTION)) { + scroll_velocity = 96.0f; + } + if (controller.hold(Control::LEFT)) { - scroll({-32.0f, 0.0f}); + scroll({ -scroll_velocity, 0.0f }); } if (controller.hold(Control::RIGHT)) { - scroll({32.0f, 0.0f}); + scroll({ scroll_velocity, 0.0f }); } if (controller.hold(Control::UP)) { - scroll({0.0f, -32.0f}); + scroll({ 0.0f, -scroll_velocity }); } if (controller.hold(Control::DOWN)) { - scroll({0.0f, 32.0f}); + scroll({ 0.0f, scroll_velocity }); } } From 8095b81118560c1e3b848062f7a30c6386530ef2 Mon Sep 17 00:00:00 2001 From: Raoul1808 Date: Sun, 20 Dec 2020 16:30:02 +0100 Subject: [PATCH 2/3] Further improved scrolling velocity changes CTRL to go 0.5x speed SHIFT to go 3x speed --- src/editor/editor.cpp | 31 ++++++++++++++++++++----------- src/editor/editor.hpp | 2 ++ 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/editor/editor.cpp b/src/editor/editor.cpp index a6b3c1e4195..d7c4a05caa7 100644 --- a/src/editor/editor.cpp +++ b/src/editor/editor.cpp @@ -104,7 +104,8 @@ Editor::Editor() : m_undo_manager(new UndoManager), m_ignore_sector_change(false), m_level_first_loaded(false), - m_time_since_last_save(0.f) + m_time_since_last_save(0.f), + m_scroll_speed(32.0f) { auto toolbox_widget = std::make_unique(*this); auto layers_widget = std::make_unique(*this); @@ -385,26 +386,20 @@ Editor::update_keyboard(const Controller& controller) return; } - float scroll_velocity = 32.0f; - - if (controller.hold(Control::ACTION)) { - scroll_velocity = 96.0f; - } - if (controller.hold(Control::LEFT)) { - scroll({ -scroll_velocity, 0.0f }); + scroll({ -m_scroll_speed, 0.0f }); } if (controller.hold(Control::RIGHT)) { - scroll({ scroll_velocity, 0.0f }); + scroll({ m_scroll_speed, 0.0f }); } if (controller.hold(Control::UP)) { - scroll({ 0.0f, -scroll_velocity }); + scroll({ 0.0f, -m_scroll_speed }); } if (controller.hold(Control::DOWN)) { - scroll({ 0.0f, scroll_velocity }); + scroll({ 0.0f, m_scroll_speed }); } } @@ -675,6 +670,20 @@ Editor::event(const SDL_Event& ev) redo(); } + if (ev.type == SDL_KEYDOWN && + ev.key.keysym.mod & KMOD_SHIFT) { + m_scroll_speed = 96.0f; + } + else if (ev.type == SDL_KEYDOWN && + ev.key.keysym.mod & KMOD_CTRL) { + m_scroll_speed = 16.0f; + } + else { + m_scroll_speed = 32.0f; + } + + + if (ev.type == SDL_KEYDOWN && ev.key.keysym.sym == SDLK_F6) { Compositor::s_render_lighting = !Compositor::s_render_lighting; return; diff --git a/src/editor/editor.hpp b/src/editor/editor.hpp index 4e5277b8c5b..5439935bf16 100644 --- a/src/editor/editor.hpp +++ b/src/editor/editor.hpp @@ -200,6 +200,8 @@ class Editor final : public Screen, float m_time_since_last_save; + float m_scroll_speed; + private: Editor(const Editor&) = delete; Editor& operator=(const Editor&) = delete; From c8b2ab469c050bc07012fdae14790dc6a91f602e Mon Sep 17 00:00:00 2001 From: Raoul1808 Date: Wed, 23 Dec 2020 09:22:07 +0100 Subject: [PATCH 3/3] Cleaned up additions --- src/editor/editor.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/editor/editor.cpp b/src/editor/editor.cpp index d7c4a05caa7..7e3e06bc074 100644 --- a/src/editor/editor.cpp +++ b/src/editor/editor.cpp @@ -670,16 +670,20 @@ Editor::event(const SDL_Event& ev) redo(); } - if (ev.type == SDL_KEYDOWN && - ev.key.keysym.mod & KMOD_SHIFT) { - m_scroll_speed = 96.0f; - } - else if (ev.type == SDL_KEYDOWN && - ev.key.keysym.mod & KMOD_CTRL) { - m_scroll_speed = 16.0f; - } - else { - m_scroll_speed = 32.0f; + if (ev.type == SDL_KEYDOWN) + { + if (ev.key.keysym.mod & KMOD_SHIFT) + { + m_scroll_speed = 96.0f; + } + else if (ev.key.keysym.mod & KMOD_CTRL) + { + m_scroll_speed = 16.0f; + } + else + { + m_scroll_speed = 32.0f; + } }