2021-02-02 15:48:17 +00:00
|
|
|
extends BaseTool
|
2020-07-09 12:22:17 +00:00
|
|
|
|
|
|
|
|
2021-11-03 00:23:26 +00:00
|
|
|
var _relative : Vector2
|
|
|
|
var _prev_zoom_mode := 0
|
2020-07-09 12:22:17 +00:00
|
|
|
var _zoom_mode := 0
|
|
|
|
|
|
|
|
|
2021-11-03 00:23:26 +00:00
|
|
|
func _input(event: InputEvent) -> void:
|
|
|
|
if event is InputEventMouseMotion:
|
|
|
|
_relative = event.relative
|
|
|
|
|
|
|
|
if event.is_action_pressed("ctrl"):
|
|
|
|
_prev_zoom_mode = $ModeOptions.selected
|
|
|
|
if event.is_action("ctrl"):
|
|
|
|
$ModeOptions.selected = _prev_zoom_mode ^ 1
|
|
|
|
_zoom_mode = $ModeOptions.selected
|
|
|
|
if event.is_action_released("ctrl"):
|
|
|
|
$ModeOptions.selected = _prev_zoom_mode
|
|
|
|
_zoom_mode = $ModeOptions.selected
|
|
|
|
|
|
|
|
|
2021-02-02 15:48:17 +00:00
|
|
|
func _on_ModeOptions_item_selected(id : int) -> void:
|
2020-07-09 12:22:17 +00:00
|
|
|
_zoom_mode = id
|
|
|
|
update_config()
|
|
|
|
save_config()
|
|
|
|
|
|
|
|
|
2021-02-02 15:48:17 +00:00
|
|
|
func _on_FitToFrame_pressed() -> void:
|
2020-07-09 12:22:17 +00:00
|
|
|
Global.camera.fit_to_frame(Global.current_project.size)
|
|
|
|
|
|
|
|
|
2021-02-02 15:48:17 +00:00
|
|
|
func _on_100_pressed() -> void:
|
2020-08-17 19:30:58 +00:00
|
|
|
Global.camera.zoom_100()
|
2020-07-09 12:22:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
func get_config() -> Dictionary:
|
|
|
|
return {
|
|
|
|
"zoom_mode" : _zoom_mode,
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func set_config(config : Dictionary) -> void:
|
|
|
|
_zoom_mode = config.get("zoom_mode", _zoom_mode)
|
|
|
|
|
|
|
|
|
|
|
|
func update_config() -> void:
|
|
|
|
$ModeOptions.selected = _zoom_mode
|
|
|
|
|
|
|
|
|
|
|
|
func draw_start(_position : Vector2) -> void:
|
2021-02-01 19:07:09 +00:00
|
|
|
var mouse_pos := get_global_mouse_position()
|
|
|
|
var viewport_rect := Rect2(Global.main_viewport.rect_global_position, Global.main_viewport.rect_size)
|
|
|
|
var viewport_rect_2 := Rect2(Global.second_viewport.rect_global_position, Global.second_viewport.rect_size)
|
|
|
|
|
|
|
|
if viewport_rect.has_point(mouse_pos):
|
|
|
|
Global.camera.zoom_camera(_zoom_mode * 2 - 1)
|
|
|
|
elif viewport_rect_2.has_point(mouse_pos):
|
|
|
|
Global.camera2.zoom_camera(_zoom_mode * 2 - 1)
|
2020-07-09 12:22:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
func draw_move(_position : Vector2) -> void:
|
2021-11-03 00:23:26 +00:00
|
|
|
Global.camera.zoom_camera(-_relative.x / 3)
|
2020-07-09 12:22:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
func draw_end(_position : Vector2) -> void:
|
|
|
|
pass
|