add edit panel
This commit is contained in:
parent
47234f1bc1
commit
89518f6aa5
|
@ -5,6 +5,7 @@ extends Control
|
|||
signal pressed()
|
||||
signal button_down()
|
||||
signal button_up()
|
||||
signal toggled()
|
||||
|
||||
export var text := ""
|
||||
export(Styles.CornerType) var corner_type = Styles.CornerType.SINGLE
|
||||
|
@ -35,7 +36,7 @@ func _ready():
|
|||
# Styles
|
||||
#
|
||||
var background_style := Styles.get_stylebox_flat(background.get_stylebox("panel", "panel"), "button_background", corner_type)
|
||||
background_style.set_bg_color(Color(1, 1, 1))
|
||||
background_style.set_bg_color(Color(0.73, 0.35, 0.13))
|
||||
background.set('custom_styles/panel', background_style)
|
||||
match corner_type:
|
||||
Styles.CornerType.SINGLE:
|
||||
|
@ -105,6 +106,7 @@ func _on_Button_toggled(button_pressed):
|
|||
button.rect_position.y -= depth - _toggled_depth
|
||||
|
||||
_toggled = button_pressed
|
||||
emit_signal("toggled", _toggled)
|
||||
|
||||
func _on_Button_pressed():
|
||||
emit_signal("pressed")
|
||||
|
|
|
@ -8,6 +8,7 @@ anchor_right = 1.0
|
|||
anchor_bottom = 1.0
|
||||
margin_right = -734.0
|
||||
margin_bottom = -464.0
|
||||
rect_min_size = Vector2( 200, 80 )
|
||||
theme = ExtResource( 1 )
|
||||
script = ExtResource( 2 )
|
||||
__meta__ = {
|
||||
|
|
|
@ -68,6 +68,7 @@ rect_min_size = Vector2( 0, 70 )
|
|||
text = "Hints"
|
||||
|
||||
[node name="NewGamePanel" parent="." instance=ExtResource( 3 )]
|
||||
rect_pivot_offset = Vector2( 4, 4 )
|
||||
[connection signal="state_changed" from="HSplitContainer/Taquin" to="." method="_on_Taquin_state_changed"]
|
||||
[connection signal="pressed" from="HSplitContainer/VBoxContainer/New Game" to="." method="_on_New_game_pressed"]
|
||||
[connection signal="button_down" from="HSplitContainer/VBoxContainer/Hints" to="HSplitContainer/Taquin" method="_on_Hints_button_down"]
|
||||
|
|
|
@ -4,25 +4,44 @@ extends PopupPanel
|
|||
|
||||
signal start_triggered(config)
|
||||
|
||||
const pref_path = "user://preferences.cfg"
|
||||
const pref_path := "user://preferences.cfg"
|
||||
|
||||
const easy_columns := 3
|
||||
const easy_rows := 3
|
||||
const easy_iterations := 4
|
||||
const normal_columns := 4
|
||||
const normal_rows := 4
|
||||
const normal_iterations := 10
|
||||
const hard_columns := 5
|
||||
const hard_rows := 5
|
||||
const hard_iterations := 30
|
||||
|
||||
export var window_scale_factor = 0.9 # how big the popup will be compared to screen
|
||||
|
||||
var preferences = ConfigFile.new()
|
||||
var fade_duration = 0.2
|
||||
var fade_scale_factor = 0.9
|
||||
var flip_duration = 0.4
|
||||
|
||||
onready var popup = $"."
|
||||
onready var panel = $Panel
|
||||
onready var edit_panel = $EditPanel
|
||||
onready var tween = $Tween
|
||||
onready var easy_button = $Panel/Difficulty/Easy
|
||||
onready var normal_button = $Panel/Difficulty/Normal
|
||||
onready var hard_button = $Panel/Difficulty/Hard
|
||||
onready var custom_button = $Panel/Difficulty/Custom
|
||||
onready var edit_button = $Panel/Edit
|
||||
onready var columns_spinbox = $EditPanel/VBoxContainer/Columns/SpinBox
|
||||
onready var rows_spinbox = $EditPanel/VBoxContainer/Rows/SpinBox
|
||||
onready var iterations_spinbox = $EditPanel/VBoxContainer/Iterations/SpinBox
|
||||
|
||||
func _init():
|
||||
var err = preferences.load(pref_path)
|
||||
|
||||
func _ready():
|
||||
rect_pivot_offset = rect_size / 2
|
||||
|
||||
assert(popup.theme != null)
|
||||
var popup_style : = popup.get_stylebox("panel", "PopupPanel") as StyleBoxFlat
|
||||
assert(popup_style != null)
|
||||
|
@ -34,26 +53,94 @@ func _ready():
|
|||
modified_panel_style.corner_radius_top_left = popup_style.corner_radius_top_left
|
||||
modified_panel_style.corner_radius_top_right = popup_style.corner_radius_top_right
|
||||
panel.set("custom_styles/panel", modified_panel_style)
|
||||
edit_panel.set("custom_styles/panel", modified_panel_style)
|
||||
panel.show()
|
||||
edit_panel.hide()
|
||||
edit_button.hide()
|
||||
|
||||
func fade_in():
|
||||
rect_pivot_offset = rect_size / 2
|
||||
tween.remove_all()
|
||||
tween.interpolate_property(self, "rect_scale", Vector2(fade_scale_factor, fade_scale_factor), Vector2.ONE, fade_duration, Tween.TRANS_LINEAR, Tween.EASE_IN)
|
||||
tween.interpolate_property(self, "modulate:a", 0.0, 1.0, fade_duration, Tween.TRANS_LINEAR, Tween.EASE_IN)
|
||||
tween.start()
|
||||
|
||||
func fade_out():
|
||||
rect_pivot_offset = rect_size / 2
|
||||
tween.remove_all()
|
||||
tween.interpolate_property(self, "rect_scale", Vector2(1.0, 1.0), Vector2(fade_scale_factor, fade_scale_factor), fade_duration, Tween.TRANS_LINEAR, Tween.EASE_IN)
|
||||
var scaled_center_position: Vector2 = (OS.window_size - (rect_size * fade_scale_factor)) / 2
|
||||
tween.interpolate_property(self, "rect_position", rect_position, scaled_center_position, fade_duration, Tween.TRANS_LINEAR, Tween.EASE_IN)
|
||||
tween.interpolate_property(self, "rect_scale", Vector2.ONE, Vector2(fade_scale_factor, fade_scale_factor), fade_duration, Tween.TRANS_LINEAR, Tween.EASE_IN)
|
||||
tween.interpolate_property(self, "modulate:a", 1.0, 0.0, fade_duration, Tween.TRANS_LINEAR, Tween.EASE_IN)
|
||||
tween.interpolate_callback(self, fade_duration, "hide")
|
||||
tween.start()
|
||||
|
||||
func flip_over():
|
||||
tween.remove_all()
|
||||
var mid_duration = flip_duration / 2.0
|
||||
tween.interpolate_property(self, "rect_scale:x", 1.0, 0.0, mid_duration)
|
||||
tween.interpolate_callback($Panel, mid_duration, "hide")
|
||||
tween.interpolate_callback($EditPanel, mid_duration, "show")
|
||||
tween.interpolate_property(self, "rect_scale:x", 0.0, 1.0, mid_duration, Tween.TRANS_LINEAR, Tween.EASE_IN, mid_duration)
|
||||
tween.start()
|
||||
|
||||
func flip_back():
|
||||
tween.remove_all()
|
||||
var mid_duration = flip_duration / 2.0
|
||||
tween.interpolate_property(self, "rect_scale:x", 1.0, 0.0, mid_duration)
|
||||
tween.interpolate_callback($Panel, mid_duration, "show")
|
||||
tween.interpolate_callback($EditPanel, mid_duration, "hide")
|
||||
tween.interpolate_property(self, "rect_scale:x", 0.0, 1.0, mid_duration, Tween.TRANS_LINEAR, Tween.EASE_IN, mid_duration)
|
||||
tween.start()
|
||||
|
||||
func _update_description():
|
||||
var columns := 0
|
||||
var rows := 0
|
||||
var iterations := 0
|
||||
if easy_button.pressed:
|
||||
columns = easy_columns
|
||||
rows = easy_rows
|
||||
iterations = easy_iterations
|
||||
if normal_button.pressed:
|
||||
columns = normal_columns
|
||||
rows = normal_rows
|
||||
iterations = normal_iterations
|
||||
if hard_button.pressed:
|
||||
columns = hard_columns
|
||||
rows = hard_rows
|
||||
iterations = hard_iterations
|
||||
if custom_button.pressed:
|
||||
columns = columns_spinbox.value as int
|
||||
rows = rows_spinbox.value as int
|
||||
iterations = iterations_spinbox.value as int
|
||||
|
||||
$Panel/Description.text = "Dimension: %d x %d\nIterations: %d" % [columns, rows, iterations]
|
||||
|
||||
#
|
||||
# Signals
|
||||
#
|
||||
func _on_Cancel_pressed():
|
||||
fade_out()
|
||||
|
||||
func _on_Start_pressed():
|
||||
if easy_button.pressed:
|
||||
preferences.set_value("game", "difficulty", "easy")
|
||||
preferences.set_value("game", "columns", easy_columns)
|
||||
preferences.set_value("game", "rows", easy_rows)
|
||||
preferences.set_value("game", "shuffle_iterations", easy_iterations)
|
||||
if normal_button.pressed:
|
||||
preferences.set_value("game", "difficulty", "normal")
|
||||
preferences.set_value("game", "columns", normal_columns)
|
||||
preferences.set_value("game", "rows", normal_rows)
|
||||
preferences.set_value("game", "shuffle_iterations", normal_iterations)
|
||||
if hard_button.pressed:
|
||||
preferences.set_value("game", "difficulty", "hard")
|
||||
preferences.set_value("game", "columns", hard_columns)
|
||||
preferences.set_value("game", "rows", hard_rows)
|
||||
preferences.set_value("game", "shuffle_iterations", hard_iterations)
|
||||
if custom_button.pressed:
|
||||
preferences.set_value("game", "difficulty", "custom")
|
||||
preferences.set_value("game", "columns", columns_spinbox.value)
|
||||
preferences.set_value("game", "rows", rows_spinbox.value)
|
||||
preferences.set_value("game", "shuffle_iterations", iterations_spinbox.value)
|
||||
|
||||
preferences.save(pref_path)
|
||||
|
||||
|
@ -65,13 +152,47 @@ func _on_NewGamePanel_about_to_show():
|
|||
easy_button.pressed = difficulty == "easy"
|
||||
normal_button.pressed = difficulty == "normal"
|
||||
hard_button.pressed = difficulty == "hard"
|
||||
custom_button.pressed = difficulty == "custom"
|
||||
|
||||
$Panel/Start.grab_focus()
|
||||
columns_spinbox.value = preferences.get_value("game", "custom_columns", normal_columns)
|
||||
rows_spinbox.value = preferences.get_value("game", "custom_rows", normal_rows)
|
||||
iterations_spinbox.value = preferences.get_value("game", "custom_shuffle_iterations", normal_iterations)
|
||||
|
||||
var size = OS.window_size * window_scale_factor
|
||||
tween.interpolate_property(self, "rect_scale", Vector2(fade_scale_factor, fade_scale_factor), Vector2(1.0, 1.0), fade_duration, Tween.TRANS_LINEAR, Tween.EASE_IN)
|
||||
var original_position: Vector2 = (OS.window_size - size) / 2
|
||||
var scaled_center_position: Vector2 = (OS.window_size - (size * fade_scale_factor)) / 2
|
||||
tween.interpolate_property(self, "rect_position", scaled_center_position, original_position, fade_duration, Tween.TRANS_LINEAR, Tween.EASE_IN)
|
||||
tween.interpolate_property(self, "modulate:a", 0.0, 1.0, fade_duration, Tween.TRANS_LINEAR, Tween.EASE_IN)
|
||||
tween.start()
|
||||
if custom_button.pressed:
|
||||
edit_button.show()
|
||||
|
||||
_update_description()
|
||||
|
||||
# $Panel/Start.grab_focus()
|
||||
fade_in()
|
||||
|
||||
func _on_Edit_pressed():
|
||||
flip_over()
|
||||
|
||||
func _on_Edit_Cancel_pressed():
|
||||
columns_spinbox.value = preferences.get_value("game", "custom_columns", normal_columns)
|
||||
rows_spinbox.value = preferences.get_value("game", "custom_rows", normal_rows)
|
||||
iterations_spinbox.value = preferences.get_value("game", "custom_shuffle_iterations", normal_iterations)
|
||||
flip_back()
|
||||
|
||||
func _on_Edit_Save_pressed():
|
||||
preferences.set_value("game", "custom_columns", columns_spinbox.value) as int
|
||||
preferences.set_value("game", "custom_rows", rows_spinbox.value) as int
|
||||
preferences.set_value("game", "custom_shuffle_iterations", iterations_spinbox.value) as int
|
||||
flip_back()
|
||||
|
||||
func _on_Custom_toggled(value: bool):
|
||||
if value:
|
||||
edit_button.show()
|
||||
_update_description()
|
||||
else:
|
||||
edit_button.hide()
|
||||
|
||||
func _on_Easy_pressed():
|
||||
_update_description()
|
||||
|
||||
func _on_Normal_pressed():
|
||||
_update_description()
|
||||
|
||||
func _on_Hard_pressed():
|
||||
_update_description()
|
||||
|
|
|
@ -13,8 +13,10 @@ corner_radius_bottom_right = 20
|
|||
corner_radius_bottom_left = 20
|
||||
|
||||
[node name="NewGamePanel" type="PopupPanel"]
|
||||
visible = true
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
rect_pivot_offset = Vector2( 512, 300 )
|
||||
theme = ExtResource( 1 )
|
||||
popup_exclusive = true
|
||||
script = ExtResource( 3 )
|
||||
|
@ -34,45 +36,6 @@ __meta__ = {
|
|||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="Panel"]
|
||||
visible = false
|
||||
anchor_left = 0.5
|
||||
anchor_right = 0.5
|
||||
margin_left = -304.0
|
||||
margin_top = 30.0
|
||||
margin_right = 304.0
|
||||
margin_bottom = 70.0
|
||||
rect_min_size = Vector2( 0, 70 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Easy" type="Button" parent="Panel/HBoxContainer"]
|
||||
margin_right = 200.0
|
||||
margin_bottom = 70.0
|
||||
rect_min_size = Vector2( 200, 70 )
|
||||
toggle_mode = true
|
||||
group = ExtResource( 2 )
|
||||
text = "Easy"
|
||||
|
||||
[node name="Normal" type="Button" parent="Panel/HBoxContainer"]
|
||||
margin_left = 208.0
|
||||
margin_right = 408.0
|
||||
margin_bottom = 70.0
|
||||
rect_min_size = Vector2( 200, 70 )
|
||||
toggle_mode = true
|
||||
group = ExtResource( 2 )
|
||||
text = "Normal"
|
||||
|
||||
[node name="Hard" type="Button" parent="Panel/HBoxContainer"]
|
||||
margin_left = 416.0
|
||||
margin_right = 616.0
|
||||
margin_bottom = 70.0
|
||||
rect_min_size = Vector2( 200, 70 )
|
||||
toggle_mode = true
|
||||
group = ExtResource( 2 )
|
||||
text = "Hard"
|
||||
|
||||
[node name="Difficulty" type="HBoxContainer" parent="Panel"]
|
||||
anchor_right = 1.0
|
||||
margin_top = 20.0
|
||||
|
@ -85,10 +48,9 @@ __meta__ = {
|
|||
[node name="Easy" parent="Panel/Difficulty" instance=ExtResource( 4 )]
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_left = 200.0
|
||||
margin_right = 400.0
|
||||
margin_left = 96.0
|
||||
margin_right = 296.0
|
||||
margin_bottom = 80.0
|
||||
rect_min_size = Vector2( 200, 80 )
|
||||
text = "Easy"
|
||||
corner_type = 1
|
||||
toggle_mode = true
|
||||
|
@ -97,10 +59,9 @@ group = ExtResource( 2 )
|
|||
[node name="Normal" parent="Panel/Difficulty" instance=ExtResource( 4 )]
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_left = 408.0
|
||||
margin_right = 608.0
|
||||
margin_left = 304.0
|
||||
margin_right = 504.0
|
||||
margin_bottom = 80.0
|
||||
rect_min_size = Vector2( 200, 80 )
|
||||
text = "Normal"
|
||||
corner_type = 2
|
||||
toggle_mode = true
|
||||
|
@ -109,11 +70,21 @@ group = ExtResource( 2 )
|
|||
[node name="Hard" parent="Panel/Difficulty" instance=ExtResource( 4 )]
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_left = 616.0
|
||||
margin_right = 816.0
|
||||
margin_left = 512.0
|
||||
margin_right = 712.0
|
||||
margin_bottom = 80.0
|
||||
rect_min_size = Vector2( 200, 80 )
|
||||
text = "Hard"
|
||||
corner_type = 2
|
||||
toggle_mode = true
|
||||
group = ExtResource( 2 )
|
||||
|
||||
[node name="Custom" parent="Panel/Difficulty" instance=ExtResource( 4 )]
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_left = 720.0
|
||||
margin_right = 920.0
|
||||
margin_bottom = 80.0
|
||||
text = "Custom"
|
||||
corner_type = 3
|
||||
toggle_mode = true
|
||||
group = ExtResource( 2 )
|
||||
|
@ -141,7 +112,161 @@ __meta__ = {
|
|||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Description" type="Label" parent="Panel"]
|
||||
margin_left = 95.676
|
||||
margin_top = 144.404
|
||||
margin_right = 135.676
|
||||
margin_bottom = 189.404
|
||||
text = "Dimension: 4x4
|
||||
Iterations: 5"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Edit" parent="Panel" instance=ExtResource( 4 )]
|
||||
visible = false
|
||||
margin_left = 651.0
|
||||
margin_top = 126.0
|
||||
margin_right = -148.0
|
||||
margin_bottom = -350.0
|
||||
text = "Edit"
|
||||
|
||||
[node name="EditPanel" type="Panel" parent="."]
|
||||
visible = false
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_left = 4.0
|
||||
margin_top = 4.0
|
||||
margin_right = -4.0
|
||||
margin_bottom = -4.0
|
||||
custom_styles/panel = SubResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Save" parent="EditPanel" instance=ExtResource( 4 )]
|
||||
anchor_left = 1.0
|
||||
anchor_top = 1.0
|
||||
margin_left = -235.0
|
||||
margin_top = -138.0
|
||||
margin_right = -20.0
|
||||
margin_bottom = -20.0
|
||||
text = "Save"
|
||||
|
||||
[node name="Cancel" type="Button" parent="EditPanel"]
|
||||
anchor_top = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_left = 20.0
|
||||
margin_top = -90.0
|
||||
margin_right = 220.0
|
||||
margin_bottom = -20.0
|
||||
rect_min_size = Vector2( 200, 70 )
|
||||
text = "Cancel"
|
||||
flat = true
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="EditPanel"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_bottom = -150.0
|
||||
alignment = 1
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Columns" type="HBoxContainer" parent="EditPanel/VBoxContainer"]
|
||||
margin_top = 115.0
|
||||
margin_right = 1016.0
|
||||
margin_bottom = 180.0
|
||||
alignment = 1
|
||||
|
||||
[node name="Label" type="Label" parent="EditPanel/VBoxContainer/Columns"]
|
||||
margin_left = 183.0
|
||||
margin_top = 10.0
|
||||
margin_right = 533.0
|
||||
margin_bottom = 55.0
|
||||
rect_min_size = Vector2( 350, 0 )
|
||||
text = "Columns"
|
||||
align = 2
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="SpinBox" type="SpinBox" parent="EditPanel/VBoxContainer/Columns"]
|
||||
margin_left = 541.0
|
||||
margin_right = 833.0
|
||||
margin_bottom = 65.0
|
||||
min_value = 2.0
|
||||
value = 4.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Rows" type="HBoxContainer" parent="EditPanel/VBoxContainer"]
|
||||
margin_top = 188.0
|
||||
margin_right = 1016.0
|
||||
margin_bottom = 253.0
|
||||
alignment = 1
|
||||
|
||||
[node name="Label" type="Label" parent="EditPanel/VBoxContainer/Rows"]
|
||||
margin_left = 183.0
|
||||
margin_top = 10.0
|
||||
margin_right = 533.0
|
||||
margin_bottom = 55.0
|
||||
rect_min_size = Vector2( 350, 0 )
|
||||
text = "Rows"
|
||||
align = 2
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="SpinBox" type="SpinBox" parent="EditPanel/VBoxContainer/Rows"]
|
||||
margin_left = 541.0
|
||||
margin_right = 833.0
|
||||
margin_bottom = 65.0
|
||||
min_value = 2.0
|
||||
value = 4.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Iterations" type="HBoxContainer" parent="EditPanel/VBoxContainer"]
|
||||
margin_top = 261.0
|
||||
margin_right = 1016.0
|
||||
margin_bottom = 326.0
|
||||
alignment = 1
|
||||
|
||||
[node name="Label" type="Label" parent="EditPanel/VBoxContainer/Iterations"]
|
||||
margin_left = 183.0
|
||||
margin_top = 10.0
|
||||
margin_right = 533.0
|
||||
margin_bottom = 55.0
|
||||
rect_min_size = Vector2( 350, 0 )
|
||||
text = "Shuffle iterations"
|
||||
align = 2
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="SpinBox" type="SpinBox" parent="EditPanel/VBoxContainer/Iterations"]
|
||||
margin_left = 541.0
|
||||
margin_right = 833.0
|
||||
margin_bottom = 65.0
|
||||
value = 10.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Tween" type="Tween" parent="."]
|
||||
[connection signal="about_to_show" from="." to="." method="_on_NewGamePanel_about_to_show"]
|
||||
[connection signal="pressed" from="Panel/Difficulty/Easy" to="." method="_on_Easy_pressed"]
|
||||
[connection signal="pressed" from="Panel/Difficulty/Normal" to="." method="_on_Normal_pressed"]
|
||||
[connection signal="pressed" from="Panel/Difficulty/Hard" to="." method="_on_Hard_pressed"]
|
||||
[connection signal="toggled" from="Panel/Difficulty/Custom" to="." method="_on_Custom_toggled"]
|
||||
[connection signal="pressed" from="Panel/Start" to="." method="_on_Start_pressed"]
|
||||
[connection signal="pressed" from="Panel/Cancel" to="." method="_on_Cancel_pressed"]
|
||||
[connection signal="pressed" from="Panel/Edit" to="." method="_on_Edit_pressed"]
|
||||
[connection signal="pressed" from="EditPanel/Save" to="." method="_on_Edit_Save_pressed"]
|
||||
[connection signal="pressed" from="EditPanel/Cancel" to="." method="_on_Edit_Cancel_pressed"]
|
||||
|
|
|
@ -21,7 +21,7 @@ float dist_thick = length(max(d_thick, 0.0)) + min(max(d_thick.x, d_thick.y), 0.
|
|||
is_thickness = rel_p.y > 0.0 && dist_thick > (0.5 - box_size);"
|
||||
|
||||
[sub_resource type="VisualShaderNodeColorConstant" id=2]
|
||||
constant = Color( 0.734375, 0.347832, 0.0657608, 1 )
|
||||
constant = Color( 0.733333, 0.34902, 0.0666667, 1 )
|
||||
|
||||
[sub_resource type="VisualShaderNodeSwitch" id=3]
|
||||
output_port_for_preview = 0
|
||||
|
@ -109,7 +109,7 @@ void fragment() {
|
|||
}
|
||||
|
||||
// Color:15
|
||||
vec3 n_out15p0 = vec3(0.734375, 0.347832, 0.065761);
|
||||
vec3 n_out15p0 = vec3(0.733333, 0.349020, 0.066667);
|
||||
float n_out15p1 = 1.000000;
|
||||
|
||||
// BooleanUniform:24
|
||||
|
|
|
@ -18,9 +18,9 @@ const _state_transitions = {
|
|||
}
|
||||
const Piece = preload("res://src/Piece.tscn")
|
||||
|
||||
export var rows: int = 4
|
||||
export var columns: int = 4
|
||||
export var difficulty: int = 10
|
||||
export var rows: int = NewGamePanel.normal_rows
|
||||
export var columns: int = NewGamePanel.normal_columns
|
||||
export var shuffle_iterations: int = NewGamePanel.normal_iterations
|
||||
export(State) var current_state = State.MAIN
|
||||
|
||||
var board_size := Vector2.ZERO
|
||||
|
@ -80,7 +80,7 @@ func _ready() -> void:
|
|||
|
||||
rng.randomize()
|
||||
|
||||
new_game("normal")
|
||||
new_game(NewGamePanel.normal_columns, NewGamePanel.normal_rows, NewGamePanel.normal_iterations)
|
||||
|
||||
func _input(event):
|
||||
if $AnimationPlayer.is_playing():
|
||||
|
@ -404,33 +404,17 @@ func init(pieces_order: Array, hidden_piece: int) -> void:
|
|||
pieces.append(pieces_row)
|
||||
assert(missing_piece != null)
|
||||
|
||||
func new_game(difficulty_mode: String) -> void:
|
||||
print_debug("difficulty mode: ", difficulty_mode)
|
||||
match difficulty_mode:
|
||||
"easy":
|
||||
rows = 3
|
||||
columns = 3
|
||||
difficulty = 4
|
||||
"normal":
|
||||
rows = 4
|
||||
columns = 4
|
||||
difficulty = 10
|
||||
"hard":
|
||||
rows = 5
|
||||
columns = 5
|
||||
difficulty = 30
|
||||
_:
|
||||
assert("Invalid value")
|
||||
rows = 4
|
||||
columns = 4
|
||||
difficulty = 10
|
||||
|
||||
func new_game(columns: int, rows: int, shuffle_iterations: int) -> void:
|
||||
self.columns = columns
|
||||
self.rows = rows
|
||||
self.shuffle_iterations = shuffle_iterations
|
||||
print_debug("%d x %d with %d shuffles" % [columns, rows, shuffle_iterations])
|
||||
var pieces_order: Array = []
|
||||
for order in range(1, rows * columns + 1):
|
||||
pieces_order.append(order)
|
||||
var hidden_piece = rows * columns # Last piece is hidden
|
||||
init(pieces_order, hidden_piece)
|
||||
shuffle(difficulty, 0.0)
|
||||
shuffle(shuffle_iterations, 0.0)
|
||||
|
||||
#
|
||||
# Hints
|
||||
|
@ -469,7 +453,11 @@ func _on_AnimationPlayer_animation_finished(anim_name):
|
|||
|
||||
func _on_NewGamePanel_start_triggered(preferences):
|
||||
var difficulty_mode = preferences.get_value("game", "difficulty", "normal")
|
||||
new_game(difficulty_mode)
|
||||
print_debug("difficulty mode: ", difficulty_mode)
|
||||
var columns = preferences.get_value("game", "columns", NewGamePanel.normal_columns)
|
||||
var rows = preferences.get_value("game", "rows", NewGamePanel.normal_rows)
|
||||
var shuffle_iterations = preferences.get_value("game", "shuffle_iterations", NewGamePanel.normal_iterations)
|
||||
new_game(columns, rows, shuffle_iterations)
|
||||
|
||||
|
||||
func _on_Hints_button_down():
|
||||
|
|
Loading…
Reference in a new issue