Skip to content

Commit 202fb4d

Browse files
committed
Restore crappy zoom code + ignore cursor zoom on keyboard zoom
1 parent 873f8be commit 202fb4d

File tree

3 files changed

+19
-13
lines changed

3 files changed

+19
-13
lines changed

src/editor/editor.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ Editor::Editor() :
139139
m_ctrl_pressed(false),
140140
m_shift_pressed(false),
141141
m_alt_pressed(false),
142+
m_key_zoomed(false),
142143
m_sector(),
143144
m_levelloaded(false),
144145
m_leveltested(false),
@@ -642,12 +643,13 @@ Editor::update(float dt_sec, const Controller& controller)
642643
camera.set_scale(m_new_scale);
643644

644645
// When zooming in, focus on the position of the mouse.
645-
// if (zooming_in)
646-
// camera.move((m_mouse_pos - Vector(static_cast<float>(SCREEN_WIDTH - 128),
647-
// static_cast<float>(SCREEN_HEIGHT - 32)) / 2.f) / CAMERA_ZOOM_FOCUS_PROGRESSION);
646+
if (zooming_in && !m_key_zoomed)
647+
camera.move((m_mouse_pos - Vector(static_cast<float>(SCREEN_WIDTH - 128),
648+
static_cast<float>(SCREEN_HEIGHT - 32)) / 2.f) / CAMERA_ZOOM_FOCUS_PROGRESSION);
648649

649650
keep_camera_in_bounds();
650651
}
652+
m_key_zoomed = false;
651653
m_new_scale = 0.f;
652654
}
653655

@@ -1365,10 +1367,12 @@ Editor::event(const SDL_Event& ev)
13651367
case SDLK_PLUS: // Zoom in
13661368
case SDLK_EQUALS:
13671369
case SDLK_KP_PLUS:
1370+
m_key_zoomed = true;
13681371
m_new_scale = m_sector->get_camera().get_current_scale() + CAMERA_ZOOM_SENSITIVITY;
13691372
break;
13701373
case SDLK_MINUS: // Zoom out
13711374
case SDLK_KP_MINUS:
1375+
m_key_zoomed = true;
13721376
m_new_scale = m_sector->get_camera().get_current_scale() - CAMERA_ZOOM_SENSITIVITY;
13731377
break;
13741378
case SDLK_d: // Reset zoom

src/editor/editor.hpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class Editor final : public Screen,
9797
inline TileSet* get_tileset() const { return m_tileset; }
9898
inline TileSelection* get_tiles() const { return m_toolbox_widget->get_tilebox().get_tiles(); }
9999
inline std::string get_tileselect_object() const { return m_toolbox_widget->get_tilebox().get_object(); }
100-
100+
101101
void toggle_tile_object_mode();
102102

103103
inline EditorTilebox::InputType get_tileselect_input_type() const { return m_toolbox_widget->get_tilebox().get_input_type(); }
@@ -108,7 +108,7 @@ class Editor final : public Screen,
108108
inline int get_tileselect_move_mode() const { return m_toolbox_widget->get_tileselect_move_mode(); }
109109

110110
inline const std::string& get_levelfile() const { return m_levelfile; }
111-
111+
112112
void level_from_nothing();
113113

114114
void set_level(std::unique_ptr<Level> level, bool reset = true);
@@ -119,7 +119,7 @@ class Editor final : public Screen,
119119
}
120120

121121
std::string get_level_directory() const;
122-
122+
123123
inline bool is_temp_level() const { return m_temp_level; }
124124

125125
void open_level_directory();
@@ -149,7 +149,7 @@ class Editor final : public Screen,
149149
void esc_press();
150150
void delete_markers();
151151
void sort_layers();
152-
152+
153153
inline void disable_testing() { m_testing_disabled = true; }
154154

155155
void select_tilegroup(int id);
@@ -239,11 +239,12 @@ class Editor final : public Screen,
239239
bool m_ctrl_pressed;
240240
bool m_shift_pressed;
241241
bool m_alt_pressed;
242-
242+
bool m_key_zoomed;
243+
243244
ScriptManager m_script_manager;
244-
245+
245246
exit_cb_t m_on_exit_cb;
246-
247+
247248
bool m_tilebox_something_selected;
248249

249250
private:
@@ -277,14 +278,14 @@ class Editor final : public Screen,
277278

278279
float m_scroll_speed;
279280
float m_new_scale;
280-
281+
281282
float m_widgets_width;
282283
float m_widgets_width_offset;
283284

284285
Vector m_mouse_pos;
285286

286287
bool m_layers_widget_needs_refresh;
287-
288+
288289
SpritePtr m_shadow;
289290

290291
private:

src/object/camera.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,8 @@ Camera::scroll_to(const Vector& goal, float scrolltime)
290290
{
291291
m_translation.x = goal.x;
292292
m_translation.y = goal.y;
293-
m_mode = Mode::MANUAL;
293+
if (m_mode != Mode::FREE)
294+
m_mode = Mode::MANUAL;
294295
return;
295296
}
296297

0 commit comments

Comments
 (0)