[wip] rework edit panel

master
Fabien Freling 2020-06-04 18:39:27 +02:00
parent 5f84111cdd
commit c8bd0412f3
3 changed files with 135 additions and 112 deletions

View File

@ -44,5 +44,19 @@ Button/styles/focus = SubResource( 1 )
Button/styles/hover = SubResource( 2 )
Button/styles/normal = SubResource( 3 )
Button/styles/pressed = SubResource( 4 )
LineEdit/colors/clear_button_color = Color( 0.88, 0.88, 0.88, 1 )
LineEdit/colors/clear_button_color_pressed = Color( 1, 1, 1, 1 )
LineEdit/colors/cursor_color = Color( 0.94, 0.94, 0.94, 1 )
LineEdit/colors/font_color = Color( 0.88, 0.88, 0.88, 1 )
LineEdit/colors/font_color_selected = Color( 0, 0, 0, 1 )
LineEdit/colors/font_color_uneditable = Color( 0.88, 0.88, 0.88, 0.5 )
LineEdit/colors/selection_color = Color( 0.49, 0.49, 0.49, 1 )
LineEdit/constants/minimum_spaces = 8
LineEdit/fonts/font = null
LineEdit/icons/clear = null
LineEdit/styles/focus = null
LineEdit/styles/normal = null
LineEdit/styles/read_only = null
Panel/styles/panel = SubResource( 5 )
PopupPanel/styles/panel = SubResource( 6 )
SpinBox/icons/updown = null

View File

@ -61,7 +61,7 @@ func _ready():
edit_panel.hide()
edit_button.hide()
var button_max_width: int = $EditPanel/VBoxContainer.rect_size.x / 4
var button_max_width: int = $EditPanel/VBoxContainer.rect_size.x / 3.5
var button_width := min(200, button_max_width)
print_debug("button max width = ", button_max_width)
easy_button.rect_min_size.x = button_width
@ -94,6 +94,7 @@ func flip_over():
tween.start()
func flip_back():
_update_description()
tween.remove_all()
var mid_duration = flip_duration / 2.0
tween.interpolate_property(self, "rect_scale:x", 1.0, 0.0, mid_duration)
@ -210,18 +211,12 @@ func _on_Edit_Cancel_pressed():
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
print_debug(columns_spinbox.value)
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()
@ -230,3 +225,7 @@ func _on_Normal_pressed():
func _on_Hard_pressed():
_update_description()
func _on_Custom_pressed():
_update_description()
flip_over()

View File

@ -187,19 +187,112 @@ margin_left = 4.0
margin_top = 4.0
margin_right = -4.0
margin_bottom = -4.0
rect_clip_content = true
custom_styles/panel = SubResource( 4 )
__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="VBoxContainer" type="VBoxContainer" parent="EditPanel"]
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 15.0
margin_top = 15.0
margin_right = -15.0
margin_bottom = -15.0
alignment = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Columns" type="HBoxContainer" parent="EditPanel/VBoxContainer"]
margin_top = 175.0
margin_right = 986.0
margin_bottom = 240.0
alignment = 1
[node name="Label" type="Label" parent="EditPanel/VBoxContainer/Columns"]
modulate = Color( 0.733333, 0.34902, 0.0666667, 1 )
margin_left = 258.0
margin_top = 10.0
margin_right = 428.0
margin_bottom = 55.0
text = "Columns"
align = 2
__meta__ = {
"_edit_use_anchors_": false
}
[node name="SpinBox" type="SpinBox" parent="EditPanel/VBoxContainer/Columns"]
margin_left = 436.0
margin_right = 728.0
margin_bottom = 65.0
min_value = 2.0
max_value = 12.0
value = 4.0
rounded = true
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Rows" type="HBoxContainer" parent="EditPanel/VBoxContainer"]
margin_top = 248.0
margin_right = 986.0
margin_bottom = 313.0
size_flags_horizontal = 3
alignment = 1
[node name="Label" type="Label" parent="EditPanel/VBoxContainer/Rows"]
modulate = Color( 0.733333, 0.34902, 0.0666667, 1 )
margin_left = 290.0
margin_top = 10.0
margin_right = 395.0
margin_bottom = 55.0
text = "Rows"
align = 2
__meta__ = {
"_edit_use_anchors_": false
}
[node name="SpinBox" type="SpinBox" parent="EditPanel/VBoxContainer/Rows"]
margin_left = 403.0
margin_right = 695.0
margin_bottom = 65.0
min_value = 2.0
max_value = 12.0
value = 4.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Iterations" type="HBoxContainer" parent="EditPanel/VBoxContainer"]
margin_top = 321.0
margin_right = 986.0
margin_bottom = 386.0
size_flags_horizontal = 3
alignment = 1
[node name="Label" type="Label" parent="EditPanel/VBoxContainer/Iterations"]
modulate = Color( 0.733333, 0.34902, 0.0666667, 1 )
margin_left = 177.0
margin_top = 10.0
margin_right = 509.0
margin_bottom = 55.0
text = "Shuffle iterations"
align = 2
__meta__ = {
"_edit_use_anchors_": false
}
[node name="SpinBox" type="SpinBox" parent="EditPanel/VBoxContainer/Iterations"]
margin_left = 517.0
margin_right = 809.0
margin_bottom = 65.0
max_value = 999.0
value = 10.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Cancel" type="Button" parent="EditPanel"]
anchor_top = 1.0
@ -215,106 +308,23 @@ __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="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="Tween" type="Tween" parent="."]
[connection signal="about_to_show" from="." to="." method="_on_NewGamePanel_about_to_show"]
[connection signal="pressed" from="Panel/VBoxContainer/Difficulty/Easy" to="." method="_on_Easy_pressed"]
[connection signal="pressed" from="Panel/VBoxContainer/Difficulty/Normal" to="." method="_on_Normal_pressed"]
[connection signal="pressed" from="Panel/VBoxContainer/Difficulty/Hard" to="." method="_on_Hard_pressed"]
[connection signal="toggled" from="Panel/VBoxContainer/HBoxContainer/Custom" to="." method="_on_Custom_toggled"]
[connection signal="pressed" from="Panel/VBoxContainer/HBoxContainer/Custom" to="." method="_on_Custom_pressed"]
[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"]
[connection signal="pressed" from="EditPanel/Save" to="." method="_on_Edit_Save_pressed"]