mirror of
https://github.com/Theaninova/mhlib.git
synced 2025-12-12 20:46:20 +00:00
122 lines
3.8 KiB
Plaintext
122 lines
3.8 KiB
Plaintext
[gd_scene load_steps=5 format=3 uid="uid://dleusk0maomll"]
|
|
|
|
[ext_resource type="Theme" uid="uid://ks2uyxqg6u4k" path="res://mhjnr/theme.tres" id="1_o0c21"]
|
|
[ext_resource type="Texture2D" uid="uid://dkeuhlg0ki67o" path="res://remakes/minimize.svg" id="3_qkgqr"]
|
|
[ext_resource type="Texture2D" uid="uid://24kg870sjulo" path="res://remakes/close.svg" id="4_a24a2"]
|
|
|
|
[sub_resource type="GDScript" id="GDScript_oemh7"]
|
|
script/source = "extends MarginContainer
|
|
|
|
const Profile = preload(\"res://mhjnr/profile/player_profile.gd\")
|
|
|
|
@export var entry: String = \"main\"
|
|
@export var window_size: Vector2i = Vector2i(800, 600)
|
|
|
|
var menu: Node
|
|
var profile: Profile
|
|
@onready var translations: Translation = load(\"datafile://data/text.csv\")
|
|
|
|
func _ready() -> void:
|
|
DisplayServer.window_set_flag(DisplayServer.WINDOW_FLAG_BORDERLESS, true)
|
|
DisplayServer.window_set_flag(DisplayServer.WINDOW_FLAG_RESIZE_DISABLED, true)
|
|
DisplayServer.window_set_size(window_size)
|
|
DisplayServer.window_set_position(
|
|
(DisplayServer.screen_get_size(0) - window_size) / 2, 0
|
|
)
|
|
set_menu(entry)
|
|
|
|
func set_menu(name: String) -> void:
|
|
if menu != null:
|
|
menu.queue_free()
|
|
menu = load(\"datafile://data/menu/screens/%s.xml\" % name).instantiate()
|
|
add_child(menu)
|
|
move_child(menu, 0)
|
|
connect_actions()
|
|
translate()
|
|
|
|
func connect_actions() -> void:
|
|
for button in menu.find_children(\"*\", \"Button\"):
|
|
if not button.has_meta(\"action\"):
|
|
continue
|
|
var action = button.get_meta(\"action\")
|
|
var callable = Callable(self, \"_on_action_%s\" % action.name)
|
|
button.z_index = 1
|
|
button.connect(\"pressed\", callable.bindv(action.args))
|
|
|
|
func translate() -> void:
|
|
for node in menu.find_children(\"*\"):
|
|
if \"text\" in node and not translations.get_message(node.text).is_empty():
|
|
node.text = translations.get_message(node.text)
|
|
|
|
|
|
func _on_minimize_pressed() -> void:
|
|
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_MINIMIZED)
|
|
|
|
func _on_close_pressed() -> void:
|
|
get_tree().quit()
|
|
|
|
func _on_action_CheckStartGame() -> void:
|
|
var level = profile.current_level
|
|
if level == 0:
|
|
set_menu(\"screen_set1\")
|
|
else:
|
|
set_menu(\"screen_set2\")
|
|
|
|
func _on_action_SelectProfile(id: String) -> void:
|
|
profile = load(\"user://profile_%02d.tres\" % (id.to_int() + 1))
|
|
if profile == null:
|
|
set_menu(\"profile_create\")
|
|
else:
|
|
set_menu(\"main\")
|
|
|
|
func _on_action_ProfileCreated() -> void:
|
|
profile = Profile.new()
|
|
profile.name = menu.find_child(\"profile1\").text
|
|
ResourceSaver.save(profile, \"user://profile_01.tres\")
|
|
set_menu(\"main\")
|
|
|
|
func _on_action_SetMenu(name: String) -> void:
|
|
set_menu(name)
|
|
|
|
func _on_action_DisplayEndscreen() -> void:
|
|
get_tree().quit()
|
|
|
|
func _on_action_StartGame() -> void:
|
|
DisplayServer.window_set_flag(DisplayServer.WINDOW_FLAG_RESIZE_DISABLED, false)
|
|
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
|
|
get_tree().change_scene_to_file(\"res://mhjnr/level.tscn\")
|
|
|
|
"
|
|
|
|
[node name="Root" type="MarginContainer"]
|
|
anchors_preset = 15
|
|
anchor_right = 1.0
|
|
anchor_bottom = 1.0
|
|
grow_horizontal = 2
|
|
grow_vertical = 2
|
|
theme = ExtResource("1_o0c21")
|
|
script = SubResource("GDScript_oemh7")
|
|
entry = "profile_start_select"
|
|
|
|
[node name="Titlebar" type="HBoxContainer" parent="."]
|
|
layout_mode = 2
|
|
size_flags_horizontal = 8
|
|
size_flags_vertical = 0
|
|
|
|
[node name="Minimize" type="Button" parent="Titlebar"]
|
|
layout_mode = 2
|
|
focus_mode = 1
|
|
theme_override_colors/icon_hover_color = Color(0.403922, 0.403922, 0.403922, 1)
|
|
icon = ExtResource("3_qkgqr")
|
|
flat = true
|
|
|
|
[node name="Close" type="Button" parent="Titlebar"]
|
|
layout_mode = 2
|
|
focus_mode = 1
|
|
theme_override_colors/icon_hover_color = Color(0.780392, 0.435294, 0.360784, 1)
|
|
icon = ExtResource("4_a24a2")
|
|
flat = true
|
|
|
|
[connection signal="pressed" from="Titlebar/Minimize" to="." method="_on_minimize_pressed"]
|
|
[connection signal="pressed" from="Titlebar/Close" to="." method="_on_close_pressed"]
|