Skip to content

Commit 1770dc4

Browse files
committed
fix zoom step factor division by zero
1 parent 5fcf557 commit 1770dc4

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

addons/nklbdev.enchanced_tilemap_editor/palette/_list_and_content_subpalette.gd

+10-4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ var _settings: Common.Settings = Common.get_static(Common.Statics.SETTINGS)
3232

3333
func _init(title: String, icon_name: String).(title, icon_name) -> void:
3434
EDSCALE = Common.get_static(Common.Statics.EDITOR_SCALE)
35+
var zoom_step_factor: float = _settings.palette_zoom_step_factor
36+
if zoom_step_factor == 0:
37+
zoom_step_factor = 1.25 # default value
3538
var tb = TreeBuilder.tree(self)
3639

3740
tb.node(self).with_children([
@@ -69,7 +72,7 @@ func _init(title: String, icon_name: String).(title, icon_name) -> void:
6972
hint_tooltip = "Zoom Out",
7073
focus_mode = FOCUS_NONE,
7174
shortcut = Common.create_shortcut(KEY_MASK_CMD | KEY_MINUS),
72-
}).connected("pressed", "__zoom_content", [_settings.palette_zoom_step_factor]),
75+
}).connected("pressed", "__zoom_content", [zoom_step_factor]),
7376
tb.node(ToolButton.new(), "__zoom_reset_button").with_props({
7477
hint_tooltip = "Zoom Reset",
7578
focus_mode = FOCUS_NONE,
@@ -82,7 +85,7 @@ func _init(title: String, icon_name: String).(title, icon_name) -> void:
8285
hint_tooltip = "Zoom In",
8386
focus_mode = FOCUS_NONE,
8487
shortcut = Common.create_shortcut(KEY_MASK_CMD | KEY_PLUS),
85-
}).connected("pressed", "__zoom_content", [1 / _settings.palette_zoom_step_factor]),
88+
}).connected("pressed", "__zoom_content", [1 / zoom_step_factor]),
8689
]),
8790
tb.node(ToolButton.new(), "__center_view_button").with_props({
8891
icon = Common.get_icon("center_view"),
@@ -216,6 +219,9 @@ func __set_content_zoom(zoom: float, origin: Vector2 = __get_content_panel_cente
216219
var __warping: bool
217220
var __content_dragging_button: int
218221
func __on_content_panel_gui_input(event: InputEvent) -> void:
222+
var zoom_step_factor: float = _settings.palette_zoom_step_factor
223+
if zoom_step_factor == 0:
224+
zoom_step_factor = 1.25 # default value
219225
if _content == null:
220226
return
221227
if event is InputEventMouse:
@@ -233,10 +239,10 @@ func __on_content_panel_gui_input(event: InputEvent) -> void:
233239
else:
234240
match event.button_index:
235241
BUTTON_WHEEL_UP:
236-
__zoom_content(_settings.palette_zoom_step_factor, event.position)
242+
__zoom_content(zoom_step_factor, event.position)
237243
return
238244
BUTTON_WHEEL_DOWN:
239-
__zoom_content(1 / _settings.palette_zoom_step_factor, event.position)
245+
__zoom_content(1 / zoom_step_factor, event.position)
240246
return
241247

242248
elif event is InputEventMouseMotion:

0 commit comments

Comments
 (0)