mirror of
https://github.com/Relintai/material-maker.git
synced 2024-11-13 06:27:18 +01:00
Merge pull request #21 from jackaperkins/keys
Make key shortcuts work on mac, move some keys to new View menu, fix backspace on mac
This commit is contained in:
commit
b325d68f96
@ -22,9 +22,7 @@ func _ready():
|
||||
func _gui_input(event):
|
||||
if event is InputEventKey and event.pressed:
|
||||
var scancode_with_modifiers = event.get_scancode_with_modifiers()
|
||||
if scancode_with_modifiers == KEY_C:
|
||||
center_view()
|
||||
elif scancode_with_modifiers == KEY_DELETE:
|
||||
if scancode_with_modifiers == KEY_DELETE || scancode_with_modifiers == KEY_BACKSPACE:
|
||||
remove_selection()
|
||||
|
||||
# Misc. useful functions
|
||||
|
@ -26,6 +26,8 @@ const MENU = [
|
||||
{ menu="Edit", command="edit_cut", shortcut="Control+X", description="Cut" },
|
||||
{ menu="Edit", command="edit_copy", shortcut="Control+C", description="Copy" },
|
||||
{ menu="Edit", command="edit_paste", shortcut="Control+V", description="Paste" },
|
||||
{ menu="View", command="view_center", shortcut="C", description="Center view" },
|
||||
{ menu="View", command="view_reset_zoom", shortcut="Control+0", description="Reset zoom" },
|
||||
{ menu="Tools", submenu="create", description="Create" },
|
||||
{ menu="Tools", command="create_subgraph", shortcut="Control+G", description="Create group" },
|
||||
{ menu="Tools", command="make_selected_nodes_editable", shortcut="Control+F", description="Make selected nodes editable" },
|
||||
@ -40,8 +42,13 @@ const MENU = [
|
||||
|
||||
signal quit
|
||||
|
||||
var is_mac = false
|
||||
|
||||
func _ready():
|
||||
# Upscale everything if the display requires it (crude hiDPI support).
|
||||
if OS.get_name() == "OSX":
|
||||
is_mac = true
|
||||
|
||||
# Upscale everything if the display requires it (crude hiDPI support).
|
||||
# This prevents UI elements from being too small on hiDPI displays.
|
||||
if OS.get_screen_dpi() >= 192 and OS.get_screen_size().x >= 2048:
|
||||
get_tree().set_screen_stretch(SceneTree.STRETCH_MODE_DISABLED, SceneTree.STRETCH_ASPECT_IGNORE, Vector2(), 2)
|
||||
@ -89,7 +96,7 @@ func create_menu(menu, menu_name):
|
||||
if s == "Alt":
|
||||
shortcut |= KEY_MASK_ALT
|
||||
elif s == "Control":
|
||||
shortcut |= KEY_MASK_CTRL
|
||||
shortcut |= KEY_MASK_CMD if is_mac else KEY_MASK_CTRL
|
||||
elif s == "Shift":
|
||||
shortcut |= KEY_MASK_SHIFT
|
||||
else:
|
||||
@ -237,7 +244,6 @@ func quit():
|
||||
else:
|
||||
get_tree().quit()
|
||||
|
||||
|
||||
func edit_cut():
|
||||
var graph_edit : MMGraphEdit = get_current_graph_edit()
|
||||
if graph_edit != null:
|
||||
@ -263,6 +269,15 @@ func edit_paste():
|
||||
func edit_paste_is_disabled():
|
||||
var data = parse_json(OS.clipboard)
|
||||
return data == null
|
||||
|
||||
func view_center():
|
||||
var graph_edit : MMGraphEdit = get_current_graph_edit()
|
||||
graph_edit.center_view()
|
||||
|
||||
func view_reset_zoom():
|
||||
var graph_edit : MMGraphEdit = get_current_graph_edit()
|
||||
graph_edit.zoom = 1
|
||||
|
||||
|
||||
func get_selected_nodes():
|
||||
var graph_edit : MMGraphEdit = get_current_graph_edit()
|
||||
|
@ -41,25 +41,32 @@ margin_bottom = 20.0
|
||||
margin_right = 35.0
|
||||
margin_bottom = 20.0
|
||||
text = "File"
|
||||
items = [ "New material", null, 0, false, false, 0, 0, null, "", false, "Load material", null, 0, false, false, 1, 268435535, null, "", false, "", null, 0, false, false, -1, 0, null, "", true, "Save material", null, 0, false, false, 4, 268435539, null, "", false, "Save material as...", null, 0, false, false, 5, 301989971, null, "", false, "Save all materials...", null, 0, false, false, 6, 0, null, "", false, "", null, 0, false, false, -1, 0, null, "", true, "Export material", null, 0, false, false, 8, 268435525, null, "", false, "", null, 0, false, false, -1, 0, null, "", true, "Close material", null, 0, false, false, 10, 0, null, "", false, "Quit", null, 0, false, false, 11, 268435537, null, "", false ]
|
||||
items = [ "New material", null, 0, false, false, 0, 0, null, "", false, "Load material", null, 0, false, false, 1, 134217807, null, "", false, "", null, 0, false, false, -1, 0, null, "", true, "Save material", null, 0, false, false, 4, 134217811, null, "", false, "Save material as...", null, 0, false, false, 5, 167772243, null, "", false, "Save all materials...", null, 0, false, false, 6, 0, null, "", false, "", null, 0, false, false, -1, 0, null, "", true, "Export material", null, 0, false, false, 8, 134217797, null, "", false, "", null, 0, false, false, -1, 0, null, "", true, "Close material", null, 0, false, false, 10, 0, null, "", false, "Quit", null, 0, false, false, 11, 134217809, null, "", false ]
|
||||
|
||||
[node name="Edit" type="MenuButton" parent="VBoxContainer/Menu"]
|
||||
margin_left = 39.0
|
||||
margin_right = 75.0
|
||||
margin_bottom = 20.0
|
||||
text = "Edit"
|
||||
items = [ "Cut", null, 0, false, false, 12, 268435544, null, "", false, "Copy", null, 0, false, false, 13, 268435523, null, "", false, "Paste", null, 0, false, false, 14, 268435542, null, "", false ]
|
||||
items = [ "Cut", null, 0, false, false, 12, 134217816, null, "", false, "Copy", null, 0, false, false, 13, 134217795, null, "", false, "Paste", null, 0, false, false, 14, 134217814, null, "", false ]
|
||||
|
||||
[node name="View" type="MenuButton" parent="VBoxContainer/Menu"]
|
||||
margin_left = 79.0
|
||||
margin_right = 121.0
|
||||
margin_bottom = 20.0
|
||||
text = "View"
|
||||
items = [ "Cut", null, 0, false, false, 12, 134217816, null, "", false, "Copy", null, 0, false, false, 13, 134217795, null, "", false, "Paste", null, 0, false, false, 14, 134217814, null, "", false ]
|
||||
|
||||
[node name="Tools" type="MenuButton" parent="VBoxContainer/Menu"]
|
||||
margin_left = 79.0
|
||||
margin_right = 125.0
|
||||
margin_left = 125.0
|
||||
margin_right = 171.0
|
||||
margin_bottom = 20.0
|
||||
text = "Tools"
|
||||
items = [ "Create", null, 0, false, false, -1, 0, null, "PopupMenu", false, "Create group", null, 0, false, false, 16, 268435527, null, "", false, "Make selected nodes editable", null, 0, false, false, 17, 268435526, null, "", false, "", null, 0, false, false, -1, 0, null, "", true, "Add selected node to user library", null, 0, false, false, 19, 0, null, "", false, "Save user library", null, 0, false, false, 20, 0, null, "", false ]
|
||||
items = [ "Create", null, 0, false, false, -1, 0, null, "PopupMenu", false, "Create group", null, 0, false, false, 16, 134217799, null, "", false, "Make selected nodes editable", null, 0, false, false, 17, 134217798, null, "", false, "", null, 0, false, false, -1, 0, null, "", true, "Add selected node to user library", null, 0, false, false, 19, 0, null, "", false, "Save user library", null, 0, false, false, 20, 0, null, "", false ]
|
||||
|
||||
[node name="Help" type="MenuButton" parent="VBoxContainer/Menu"]
|
||||
margin_left = 129.0
|
||||
margin_right = 171.0
|
||||
margin_left = 175.0
|
||||
margin_right = 217.0
|
||||
margin_bottom = 20.0
|
||||
text = "Help"
|
||||
items = [ "User manual", null, 0, false, false, 21, 0, null, "", false, "Report a bug", null, 0, false, false, 22, 0, null, "", false, "", null, 0, false, false, -1, 0, null, "", true, "About", null, 0, false, false, 24, 0, null, "", false ]
|
||||
|
Loading…
Reference in New Issue
Block a user