mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-18 17:19:50 +00:00
Added shortcuts (#673)
* add limit change with brush * Delete Draw.gd * Delete BaseTool.gd * Added all shortcuts * formatting * Removed 1 shortcut from "Fullscreen" * Assigned shortcuts to special behaviours * formatting * Added configurable shortcuts to special behaviour * formatting * Added special behaviour shortcuts and some code im provements * a minor fix
This commit is contained in:
parent
7b721ca66d
commit
16a2abf9b4
|
@ -310,7 +310,6 @@ right_shading_tool={
|
|||
toggle_fullscreen={
|
||||
"deadzone": 0.5,
|
||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777254,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":true,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777221,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
left_colorpicker_tool={
|
||||
|
|
|
@ -95,7 +95,7 @@ var tools := {
|
|||
"""Hold %s to snap the angle of the line
|
||||
Hold %s to center the shape on the click origin
|
||||
Hold %s to displace the shape's origin""",
|
||||
["Shift", "Ctrl", "Alt"]
|
||||
["Shift", "configurable_ctrl", "configurable_alt"]
|
||||
),
|
||||
"RectangleTool":
|
||||
Tool.new(
|
||||
|
@ -106,7 +106,7 @@ Hold %s to displace the shape's origin""",
|
|||
"""Hold %s to create a 1:1 shape
|
||||
Hold %s to center the shape on the click origin
|
||||
Hold %s to displace the shape's origin""",
|
||||
["Shift", "Ctrl", "Alt"]
|
||||
["configurable_shift", "configurable_ctrl", "configurable_alt"]
|
||||
),
|
||||
"EllipseTool":
|
||||
Tool.new(
|
||||
|
@ -117,7 +117,7 @@ Hold %s to displace the shape's origin""",
|
|||
"""Hold %s to create a 1:1 shape
|
||||
Hold %s to center the shape on the click origin
|
||||
Hold %s to displace the shape's origin""",
|
||||
["Shift", "Ctrl", "Alt"]
|
||||
["configurable_shift", "configurable_ctrl", "configurable_alt"]
|
||||
),
|
||||
}
|
||||
|
||||
|
@ -138,6 +138,7 @@ class Tool:
|
|||
var shortcut := ""
|
||||
var extra_hint := ""
|
||||
var extra_shortcuts := [] # Array of String(s)
|
||||
var extra_shortcuts_order := [] # Array to keep shift, ctrl, alt in order
|
||||
var button_node: BaseButton
|
||||
|
||||
func _init(
|
||||
|
@ -154,6 +155,7 @@ class Tool:
|
|||
scene = _scene
|
||||
extra_hint = _extra_hint
|
||||
extra_shortcuts = _extra_shortucts
|
||||
extra_shortcuts_order = _extra_shortucts.duplicate()
|
||||
icon = load("res://assets/graphics/tools/%s.png" % name.to_lower())
|
||||
cursor_icon = load("res://assets/graphics/tools/cursors/%s.png" % name.to_lower())
|
||||
|
||||
|
@ -177,7 +179,24 @@ class Tool:
|
|||
if !extra_hint.empty():
|
||||
hint += "\n\n" + extra_hint
|
||||
|
||||
# Some tools have shift,ctrl,alt "HARD CODED" in them using (InputEventWithModifiers)
|
||||
# But Others only use the regular is_action_pressed() function
|
||||
# their Shift, Ctrl, Alt are listed Below
|
||||
var code_shift = InputMap.get_action_list("shift")[0].get_scancode_with_modifiers()
|
||||
var code_ctrl = InputMap.get_action_list("ctrl")[0].get_scancode_with_modifiers()
|
||||
var code_alt = InputMap.get_action_list("alt")[0].get_scancode_with_modifiers()
|
||||
var configurable_shift: String = OS.get_scancode_string(code_shift)
|
||||
var configurable_ctrl: String = OS.get_scancode_string(code_ctrl)
|
||||
var configurable_alt: String = OS.get_scancode_string(code_alt)
|
||||
for shortcut_idx in extra_shortcuts.size():
|
||||
if extra_shortcuts_order[shortcut_idx] == "configurable_shift":
|
||||
extra_shortcuts[shortcut_idx] = configurable_shift
|
||||
if extra_shortcuts_order[shortcut_idx] == "configurable_ctrl":
|
||||
extra_shortcuts[shortcut_idx] = configurable_ctrl
|
||||
if extra_shortcuts_order[shortcut_idx] == "configurable_alt":
|
||||
extra_shortcuts[shortcut_idx] = configurable_alt
|
||||
shortcuts.append_array(extra_shortcuts)
|
||||
|
||||
if shortcuts.empty():
|
||||
hint = tr(hint)
|
||||
else:
|
||||
|
|
|
@ -114,12 +114,104 @@ func toggle_shortcut_buttons(enabled: bool) -> void:
|
|||
|
||||
|
||||
func set_action_shortcut(action: String, oldinput: InputEventKey, newinput: InputEventKey) -> void:
|
||||
# Only updates the InputMap
|
||||
InputMap.action_erase_event(action, oldinput)
|
||||
InputMap.action_add_event(action, newinput)
|
||||
var color_switch: BaseButton = Global.control.find_node("ColorSwitch")
|
||||
update_ui_shortcuts(action)
|
||||
|
||||
|
||||
func update_ui_shortcuts(action: String):
|
||||
# Updates UI elements according to InputMap (Tool shortcuts are updated from a seperate function)
|
||||
# Set shortcut to switch colors button
|
||||
if action == "switch_colors":
|
||||
color_switch.shortcut.shortcut = InputMap.get_action_list("switch_colors")[0]
|
||||
update_ui_shortcut("ColorSwitch", action)
|
||||
# Set timeline shortcuts
|
||||
if action == "go_to_first_frame":
|
||||
update_ui_shortcut("FirstFrame", action)
|
||||
if action == "go_to_previous_frame":
|
||||
update_ui_shortcut("PreviousFrame", action)
|
||||
if action == "play_backwards":
|
||||
update_ui_shortcut("PlayBackwards", action)
|
||||
if action == "play_forward":
|
||||
update_ui_shortcut("PlayForward", action)
|
||||
if action == "go_to_next_frame":
|
||||
update_ui_shortcut("NextFrame", action)
|
||||
if action == "go_to_last_frame":
|
||||
update_ui_shortcut("LastFrame", action)
|
||||
# Set shortcuts for Menu Options
|
||||
var top_menu: Panel = Global.control.find_node("TopMenuContainer")
|
||||
var file_menu: PopupMenu = top_menu.file_menu_button.get_popup()
|
||||
var edit_menu: PopupMenu = top_menu.edit_menu_button.get_popup()
|
||||
var select_menu: PopupMenu = top_menu.select_menu_button.get_popup()
|
||||
var view_menu: PopupMenu = top_menu.view_menu_button.get_popup()
|
||||
var window_menu: PopupMenu = top_menu.window_menu_button.get_popup()
|
||||
var help_menu: PopupMenu = top_menu.help_menu_button.get_popup()
|
||||
if action == "new_file":
|
||||
update_menu_option(file_menu, "New...", action)
|
||||
if action == "open_file":
|
||||
update_menu_option(file_menu, "Open...", action)
|
||||
if action == "save_file":
|
||||
update_menu_option(file_menu, "Save...", action)
|
||||
if action == "save_file_as":
|
||||
update_menu_option(file_menu, "Save as...", action)
|
||||
if action == "export_file":
|
||||
update_menu_option(file_menu, "Export...", action)
|
||||
if action == "export_file_as":
|
||||
update_menu_option(file_menu, "Export as...", action)
|
||||
if action == "quit":
|
||||
update_menu_option(file_menu, "Quit", action)
|
||||
if action == "undo":
|
||||
update_menu_option(edit_menu, "Undo", action)
|
||||
if action == "redo":
|
||||
update_menu_option(edit_menu, "Redo", action)
|
||||
if action == "copy":
|
||||
update_menu_option(edit_menu, "Copy", action)
|
||||
if action == "cut":
|
||||
update_menu_option(edit_menu, "Cut", action)
|
||||
if action == "paste":
|
||||
update_menu_option(edit_menu, "Paste", action)
|
||||
if action == "delete":
|
||||
update_menu_option(edit_menu, "Delete", action)
|
||||
if action == "new_brush":
|
||||
update_menu_option(edit_menu, "New Brush", action)
|
||||
if action == "select_all":
|
||||
update_menu_option(select_menu, "All", action)
|
||||
if action == "clear_selection":
|
||||
update_menu_option(select_menu, "Clear", action)
|
||||
if action == "invert_selection":
|
||||
update_menu_option(select_menu, "Invert", action)
|
||||
if action == "mirror_view":
|
||||
update_menu_option(view_menu, "Mirror View", action)
|
||||
if action == "show_grid":
|
||||
update_menu_option(view_menu, "Show Grid", action)
|
||||
if action == "show_pixel_grid":
|
||||
update_menu_option(view_menu, "Show Pixel Grid", action)
|
||||
if action == "show_rulers":
|
||||
update_menu_option(view_menu, "Show Rulers", action)
|
||||
if action == "show_guides":
|
||||
update_menu_option(view_menu, "Show Guides", action)
|
||||
if action == "edit_mode":
|
||||
for child in window_menu.get_children():
|
||||
if child.name == "panels_submenu":
|
||||
update_menu_option(child, "Moveable Panels", action)
|
||||
if action == "zen_mode":
|
||||
update_menu_option(window_menu, "Zen Mode", action)
|
||||
if action == "toggle_fullscreen":
|
||||
update_menu_option(window_menu, "Fullscreen Mode", action)
|
||||
if action == "open_docs":
|
||||
update_menu_option(help_menu, "Online Docs", action)
|
||||
|
||||
|
||||
func update_ui_shortcut(name: String, action: String):
|
||||
var ui_button: BaseButton = Global.control.find_node(name)
|
||||
ui_button.shortcut.shortcut = InputMap.get_action_list(action)[0]
|
||||
|
||||
|
||||
func update_menu_option(menu: PopupMenu, name: String, action: String):
|
||||
for idx in menu.get_item_count():
|
||||
if menu.get_item_text(idx) == name:
|
||||
var accel: int = InputMap.get_action_list(action)[0].get_scancode_with_modifiers()
|
||||
menu.set_item_accelerator(idx, accel)
|
||||
|
||||
|
||||
func _on_Shortcut_button_pressed(button: Button) -> void:
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -97,7 +97,8 @@ func draw_move(position: Vector2) -> void:
|
|||
_original_pos += position - _offset
|
||||
var d = _line_angle_constraint(_original_pos, position)
|
||||
_dest = d.position
|
||||
if Tools.control:
|
||||
# Didn't use (Tools.control) to make more consistent with shape tools
|
||||
if Input.is_action_pressed("ctrl"):
|
||||
_start = _original_pos - (_dest - _original_pos)
|
||||
else:
|
||||
_start = _original_pos
|
||||
|
|
Loading…
Reference in a new issue