update to godot v4
This commit is contained in:
parent
95c7976f14
commit
67e71181f6
35 changed files with 795 additions and 494 deletions
|
|
@ -1,4 +1,4 @@
|
|||
tool
|
||||
@tool
|
||||
class_name NewGamePanel
|
||||
extends PopupPanel
|
||||
|
||||
|
|
@ -19,36 +19,36 @@ const hard_iterations := 30
|
|||
|
||||
const Utils = preload("res://src/Utils.gd")
|
||||
|
||||
export var window_scale_factor = 0.9 # how big the popup will be compared to screen
|
||||
export var default_artwork_texture: Texture
|
||||
@export var window_scale_factor = 0.9 # how big the popup will be compared to screen
|
||||
@export var default_artwork_texture: Texture2D
|
||||
|
||||
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 popup = $"."
|
||||
@onready var panel = $Panel
|
||||
@onready var edit_panel = $EditPanel
|
||||
@onready var tween = $Tween
|
||||
|
||||
onready var difficulty_container = $Panel/VBoxContainer/Difficulty
|
||||
onready var easy_button = $Panel/VBoxContainer/Difficulty/Easy
|
||||
onready var normal_button = $Panel/VBoxContainer/Difficulty/Normal
|
||||
onready var hard_button = $Panel/VBoxContainer/Difficulty/Hard
|
||||
onready var custom_button = $Panel/VBoxContainer/HBoxContainer/Custom
|
||||
@onready var difficulty_container = $Panel/VBoxContainer/Difficulty
|
||||
@onready var easy_button = $Panel/VBoxContainer/Difficulty/Easy
|
||||
@onready var normal_button = $Panel/VBoxContainer/Difficulty/Normal
|
||||
@onready var hard_button = $Panel/VBoxContainer/Difficulty/Hard
|
||||
@onready var custom_button = $Panel/VBoxContainer/HBoxContainer/Custom
|
||||
|
||||
onready var preview = $Panel/VBoxContainer/ArtworkSource/Preview
|
||||
@onready var preview = $Panel/VBoxContainer/ArtworkSource/Preview
|
||||
|
||||
onready var columns_spinbox = $EditPanel/VBoxContainer/Columns/SpinBox
|
||||
onready var rows_spinbox = $EditPanel/VBoxContainer/Rows/SpinBox
|
||||
onready var iterations_spinbox = $EditPanel/VBoxContainer/Iterations/SpinBox
|
||||
@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
|
||||
pivot_offset = size / 2
|
||||
|
||||
assert(popup.theme != null)
|
||||
var popup_style : = popup.get_stylebox("panel", "PopupPanel") as StyleBoxFlat
|
||||
|
|
@ -60,29 +60,29 @@ func _ready():
|
|||
modified_panel_style.corner_radius_bottom_right = popup_style.corner_radius_bottom_right
|
||||
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.set("theme_override_styles/panel", modified_panel_style)
|
||||
edit_panel.set("theme_override_styles/panel", modified_panel_style)
|
||||
panel.show()
|
||||
edit_panel.hide()
|
||||
edit_panel.hide()
|
||||
|
||||
var button_max_width: int = $EditPanel/VBoxContainer.rect_size.x / 3.5
|
||||
var button_max_width: int = $EditPanel/VBoxContainer.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
|
||||
normal_button.rect_min_size.x = button_width
|
||||
hard_button.rect_min_size.x = button_width
|
||||
custom_button.rect_min_size.x = button_width
|
||||
easy_button.custom_minimum_size.x = button_width
|
||||
normal_button.custom_minimum_size.x = button_width
|
||||
hard_button.custom_minimum_size.x = button_width
|
||||
custom_button.custom_minimum_size.x = button_width
|
||||
|
||||
func fade_in():
|
||||
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, "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():
|
||||
tween.remove_all()
|
||||
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, "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()
|
||||
|
|
@ -90,20 +90,20 @@ func fade_out():
|
|||
func flip_over(new_panel: Panel) -> void:
|
||||
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_property(self, "scale:x", 1.0, 0.0, mid_duration)
|
||||
tween.interpolate_callback($Panel, mid_duration, "hide")
|
||||
tween.interpolate_callback(new_panel, 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.interpolate_property(self, "scale:x", 0.0, 1.0, mid_duration, Tween.TRANS_LINEAR, Tween.EASE_IN, mid_duration)
|
||||
tween.start()
|
||||
|
||||
func flip_back(previous_panel: Panel) -> void:
|
||||
_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)
|
||||
tween.interpolate_property(self, "scale:x", 1.0, 0.0, mid_duration)
|
||||
tween.interpolate_callback($Panel, mid_duration, "show")
|
||||
tween.interpolate_callback(previous_panel, 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.interpolate_property(self, "scale:x", 0.0, 1.0, mid_duration, Tween.TRANS_LINEAR, Tween.EASE_IN, mid_duration)
|
||||
tween.start()
|
||||
|
||||
func _update_description():
|
||||
|
|
@ -131,7 +131,7 @@ func _update_description():
|
|||
# $Panel/Description.text = "Dimension: %d x %d\nIterations: %d" % [columns, rows, iterations]
|
||||
desc.clear()
|
||||
|
||||
desc.push_align(RichTextLabel.ALIGN_CENTER)
|
||||
desc.push_align(RichTextLabel.ALIGNMENT_CENTER)
|
||||
desc.add_text("Board: ")
|
||||
|
||||
desc.push_bold()
|
||||
|
|
@ -152,7 +152,7 @@ func _update_description():
|
|||
desc.add_text("%d" % [iterations])
|
||||
desc.pop()
|
||||
|
||||
func _set_artwork(tex: Texture) -> void:
|
||||
func _set_artwork(tex: Texture2D) -> void:
|
||||
preview.texture = tex
|
||||
|
||||
var file = File.new()
|
||||
|
|
@ -196,10 +196,10 @@ func _on_Start_pressed():
|
|||
|
||||
func _on_NewGamePanel_about_to_show():
|
||||
var difficulty = preferences.get_value("game", "difficulty", "normal")
|
||||
easy_button.pressed = difficulty == "easy"
|
||||
normal_button.pressed = difficulty == "normal"
|
||||
hard_button.pressed = difficulty == "hard"
|
||||
custom_button.pressed = difficulty == "custom"
|
||||
easy_button.button_pressed = difficulty == "easy"
|
||||
normal_button.button_pressed = difficulty == "normal"
|
||||
hard_button.button_pressed = difficulty == "hard"
|
||||
custom_button.button_pressed = difficulty == "custom"
|
||||
|
||||
columns_spinbox.value = preferences.get_value("game", "custom_columns", normal_columns)
|
||||
rows_spinbox.value = preferences.get_value("game", "custom_rows", normal_rows)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue