Skip to content

Commit

Permalink
Merge pull request #87 from crystal-bit/fix-debug-shortcuts
Browse files Browse the repository at this point in the history
fix: debug shortcuts.
  • Loading branch information
davcri committed Oct 9, 2023
2 parents 8078132 + 281face commit 8bc4e80
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
6 changes: 6 additions & 0 deletions addons/ggt-debug-shortcuts/autoload/debug_shortcuts.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
extends Node


func _ready():
if OS.is_debug_build() == false:
queue_free()
4 changes: 3 additions & 1 deletion addons/ggt-debug-shortcuts/autoload/debug_shortcuts.tscn
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[gd_scene load_steps=5 format=3 uid="uid://dwudswealbjw5"]
[gd_scene load_steps=6 format=3 uid="uid://dwudswealbjw5"]

[ext_resource type="Script" path="res://addons/ggt-debug-shortcuts/autoload/debug_shortcuts.gd" id="1_h8jbq"]
[ext_resource type="PackedScene" uid="uid://b5hm57d3waa77" path="res://addons/ggt-debug-shortcuts/shortcuts/pause_game.tscn" id="2_in6k6"]
[ext_resource type="PackedScene" uid="uid://gulo6hdwe6ug" path="res://addons/ggt-debug-shortcuts/shortcuts/quit_game.tscn" id="2_pto5j"]
[ext_resource type="PackedScene" uid="uid://ctsbjmhftjw2e" path="res://addons/ggt-debug-shortcuts/shortcuts/toggle_fullscreen.tscn" id="3_o3see"]
Expand All @@ -8,6 +9,7 @@
[node name="DebugShortcuts" type="Node"]
process_mode = 3
editor_description = "Node automatically removed on release builds."
script = ExtResource("1_h8jbq")

[node name="PauseGame" parent="." instance=ExtResource("2_in6k6")]

Expand Down
10 changes: 3 additions & 7 deletions addons/ggt-debug-shortcuts/ggt-debug-shortcuts.gd
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@ const default_debug_shortcuts = {


func _enter_tree():
if OS.is_debug_build():
register_input_mappings(func(): save_project_settings())
register_input_mappings(func(): save_project_settings())


func _enable_plugin():
if OS.is_debug_build():
add_autoload_singleton("DebugShortcuts", "res://addons/ggt-debug-shortcuts/autoload/debug_shortcuts.tscn")
register_input_mappings(func(): save_project_settings())
add_autoload_singleton("DebugShortcuts", "res://addons/ggt-debug-shortcuts/autoload/debug_shortcuts.tscn")
register_input_mappings(func(): save_project_settings())


func _exit_tree():
Expand Down Expand Up @@ -52,14 +50,12 @@ func register_input_mappings(on_project_settings_changed: Callable):
for k in default_debug_shortcuts:
var v = default_debug_shortcuts[k]
if ProjectSettings.has_setting(k):
# push_warning("{0} shortcut already set in ProjectSettings, skipping...".format([k]))
pass # leave user configured action
else:
dirty = true
ProjectSettings.set_setting(k, create_input_action(v)) # set default value
if dirty:
if on_project_settings_changed is Callable:
print("saving projsettings")
on_project_settings_changed.call()


Expand Down
2 changes: 1 addition & 1 deletion addons/ggt-debug-shortcuts/shortcuts/restart_scene.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ func _unhandled_input(event):
if event is InputEventKey:
if event.is_action_pressed(\"debug_restart_game\"):
var ggt_game_autoload = get_node_or_null(\"/root/Game\")
# if \"ggt-core\" addon is enabled
if ggt_game_autoload:
ggt_game_autoload.restart_scene()
else:
get_tree().reload_current_scene()
print(\"/root/Game not found \")
"
[node name="RestartCurrentScene" type="Node"]
Expand Down

0 comments on commit 8bc4e80

Please sign in to comment.