diff --git a/main.gd b/main.gd index 0816bcb..4161bb3 100644 --- a/main.gd +++ b/main.gd @@ -19,6 +19,9 @@ func _ready() -> void: advance_level() func _process(delta: float) -> void: + $UndoButton.disabled = not hist.has_undo() + $RedoButton.disabled = not hist.has_redo() + $RestartButton.disabled = not hist.has_undo() if $TopLeft.is_on_screen() and $BottomRight.is_on_screen(): return camera.position.y += 10*delta @@ -33,20 +36,29 @@ func _input(event: InputEvent) -> void: elif event.is_action_pressed("r", true, true): step(Vector2i.RIGHT) elif event.is_action_pressed("undo", true, true): - if hist.undo(): - sound.stream = sounds_undo - sound.play() + undo() elif event.is_action_pressed("redo", true, true): - if hist.redo(): - sound.stream = sounds_redo - sound.play() + redo() elif event.is_action_pressed("restart", true, true): restart() +func undo(): + if hist.undo(): + sound.stream = sounds_undo + sound.play() + +func redo(): + if hist.redo(): + sound.stream = sounds_redo + sound.play() + # TODO: make restart undoable? func restart(): while hist.has_undo(): hist.undo() + # i think it's unintuitive to be able to redo from restart + # scratch that i like that, don't clear the history + # you can like replay your steps up to a point func step(move: Vector2i): var pos := player.lpos diff --git a/main.tscn b/main.tscn index 6d00b1d..a61d153 100644 --- a/main.tscn +++ b/main.tscn @@ -1,7 +1,10 @@ -[gd_scene load_steps=6 format=3 uid="uid://lrk2whqxl0w0"] +[gd_scene load_steps=9 format=3 uid="uid://lrk2whqxl0w0"] [ext_resource type="Script" uid="uid://c707s0tgd88pg" path="res://main.gd" id="1_ig7tw"] [ext_resource type="Script" uid="uid://c8ywa33v3jq7t" path="res://board.gd" id="2_0xm2m"] +[ext_resource type="Texture2D" uid="uid://bl73lsxse1roj" path="res://undo.png" id="3_lquwl"] +[ext_resource type="Texture2D" uid="uid://cs7ofsoatkhpk" path="res://redo.png" id="4_7mycd"] +[ext_resource type="Texture2D" uid="uid://dkl0lf6wlidup" path="res://restart.png" id="5_272bh"] [sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_ig7tw"] ground_bottom_color = Color(0.270778, 0.538085, 0.397052, 1) @@ -36,3 +39,34 @@ aabb = AABB(0, 0, 0, 2, 2, 2) [node name="Board" type="Node3D" parent="."] script = ExtResource("2_0xm2m") metadata/_custom_type_script = "uid://c8ywa33v3jq7t" + +[node name="UndoButton" type="Button" parent="."] +offset_left = -5.0 +offset_top = 1.0 +offset_right = 101.0 +offset_bottom = 115.0 +icon = ExtResource("3_lquwl") +flat = true +expand_icon = true + +[node name="RedoButton" type="Button" parent="."] +offset_left = 108.0 +offset_top = 3.0 +offset_right = 226.0 +offset_bottom = 113.0 +icon = ExtResource("4_7mycd") +flat = true +expand_icon = true + +[node name="RestartButton" type="Button" parent="."] +offset_left = 245.0 +offset_top = 4.0 +offset_right = 369.0 +offset_bottom = 116.0 +icon = ExtResource("5_272bh") +flat = true +expand_icon = true + +[connection signal="pressed" from="UndoButton" to="." method="undo"] +[connection signal="pressed" from="RedoButton" to="." method="redo"] +[connection signal="pressed" from="RestartButton" to="." method="restart"] diff --git a/redo.png b/redo.png new file mode 100644 index 0000000..abb9246 Binary files /dev/null and b/redo.png differ diff --git a/redo.png.import b/redo.png.import new file mode 100644 index 0000000..5e0571b --- /dev/null +++ b/redo.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cs7ofsoatkhpk" +path="res://.godot/imported/redo.png-ee35da30d5564f6349e0e057a85ac757.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://redo.png" +dest_files=["res://.godot/imported/redo.png-ee35da30d5564f6349e0e057a85ac757.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/restart.png b/restart.png new file mode 100644 index 0000000..8c40f73 Binary files /dev/null and b/restart.png differ diff --git a/restart.png.import b/restart.png.import new file mode 100644 index 0000000..6a8d4b4 --- /dev/null +++ b/restart.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dkl0lf6wlidup" +path="res://.godot/imported/restart.png-26b7c787948cb57c7b611be1d72180b7.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://restart.png" +dest_files=["res://.godot/imported/restart.png-26b7c787948cb57c7b611be1d72180b7.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/undo.png b/undo.png new file mode 100644 index 0000000..42e3a98 Binary files /dev/null and b/undo.png differ diff --git a/undo.png.import b/undo.png.import new file mode 100644 index 0000000..5f1d43d --- /dev/null +++ b/undo.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bl73lsxse1roj" +path="res://.godot/imported/undo.png-84d838c088789c9f3b743b68335cbb34.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://undo.png" +dest_files=["res://.godot/imported/undo.png-84d838c088789c9f3b743b68335cbb34.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1