undo/redo/restart buttons/indicators
This commit is contained in:
parent
c29bce724f
commit
082100ec2f
8 changed files with 155 additions and 7 deletions
18
main.gd
18
main.gd
|
|
@ -19,6 +19,9 @@ func _ready() -> void:
|
||||||
advance_level()
|
advance_level()
|
||||||
|
|
||||||
func _process(delta: float) -> void:
|
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():
|
if $TopLeft.is_on_screen() and $BottomRight.is_on_screen():
|
||||||
return
|
return
|
||||||
camera.position.y += 10*delta
|
camera.position.y += 10*delta
|
||||||
|
|
@ -33,20 +36,29 @@ func _input(event: InputEvent) -> void:
|
||||||
elif event.is_action_pressed("r", true, true):
|
elif event.is_action_pressed("r", true, true):
|
||||||
step(Vector2i.RIGHT)
|
step(Vector2i.RIGHT)
|
||||||
elif event.is_action_pressed("undo", true, true):
|
elif event.is_action_pressed("undo", true, true):
|
||||||
|
undo()
|
||||||
|
elif event.is_action_pressed("redo", true, true):
|
||||||
|
redo()
|
||||||
|
elif event.is_action_pressed("restart", true, true):
|
||||||
|
restart()
|
||||||
|
|
||||||
|
func undo():
|
||||||
if hist.undo():
|
if hist.undo():
|
||||||
sound.stream = sounds_undo
|
sound.stream = sounds_undo
|
||||||
sound.play()
|
sound.play()
|
||||||
elif event.is_action_pressed("redo", true, true):
|
|
||||||
|
func redo():
|
||||||
if hist.redo():
|
if hist.redo():
|
||||||
sound.stream = sounds_redo
|
sound.stream = sounds_redo
|
||||||
sound.play()
|
sound.play()
|
||||||
elif event.is_action_pressed("restart", true, true):
|
|
||||||
restart()
|
|
||||||
|
|
||||||
# TODO: make restart undoable?
|
# TODO: make restart undoable?
|
||||||
func restart():
|
func restart():
|
||||||
while hist.has_undo():
|
while hist.has_undo():
|
||||||
hist.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):
|
func step(move: Vector2i):
|
||||||
var pos := player.lpos
|
var pos := player.lpos
|
||||||
|
|
|
||||||
36
main.tscn
36
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://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="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"]
|
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_ig7tw"]
|
||||||
ground_bottom_color = Color(0.270778, 0.538085, 0.397052, 1)
|
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="."]
|
[node name="Board" type="Node3D" parent="."]
|
||||||
script = ExtResource("2_0xm2m")
|
script = ExtResource("2_0xm2m")
|
||||||
metadata/_custom_type_script = "uid://c8ywa33v3jq7t"
|
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"]
|
||||||
|
|
|
||||||
BIN
redo.png
Normal file
BIN
redo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
34
redo.png.import
Normal file
34
redo.png.import
Normal file
|
|
@ -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
|
||||||
BIN
restart.png
Normal file
BIN
restart.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 25 KiB |
34
restart.png.import
Normal file
34
restart.png.import
Normal file
|
|
@ -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
|
||||||
BIN
undo.png
Normal file
BIN
undo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
34
undo.png.import
Normal file
34
undo.png.import
Normal file
|
|
@ -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
|
||||||
Loading…
Reference in a new issue