Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editor Scroll Speed small tweaks #1611

Merged
merged 3 commits into from
Jan 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 24 additions & 5 deletions src/editor/editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<EditorToolboxWidget>(*this);
auto layers_widget = std::make_unique<EditorLayersWidget>(*this);
Expand Down Expand Up @@ -386,19 +387,19 @@ Editor::update_keyboard(const Controller& controller)
}

if (controller.hold(Control::LEFT)) {
scroll({-32.0f, 0.0f});
scroll({ -m_scroll_speed, 0.0f });
}

if (controller.hold(Control::RIGHT)) {
scroll({32.0f, 0.0f});
scroll({ m_scroll_speed, 0.0f });
}

if (controller.hold(Control::UP)) {
scroll({0.0f, -32.0f});
scroll({ 0.0f, -m_scroll_speed });
}

if (controller.hold(Control::DOWN)) {
scroll({0.0f, 32.0f});
scroll({ 0.0f, m_scroll_speed });
}
}

Expand Down Expand Up @@ -669,6 +670,24 @@ Editor::event(const SDL_Event& ev)
redo();
}

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;
}
}



if (ev.type == SDL_KEYDOWN && ev.key.keysym.sym == SDLK_F6) {
Compositor::s_render_lighting = !Compositor::s_render_lighting;
return;
Expand Down
2 changes: 2 additions & 0 deletions src/editor/editor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down