mirror of
https://github.com/Relintai/MemR.git
synced 2024-11-12 10:25:05 +01:00
Initial menu and settings setup.
This commit is contained in:
parent
95127e0c71
commit
0e02e5588d
29
game/Main.gd
Normal file
29
game/Main.gd
Normal file
@ -0,0 +1,29 @@
|
||||
extends Control
|
||||
|
||||
var _menu : Control
|
||||
var _settings : Control
|
||||
var _sort : Control
|
||||
|
||||
func hide_all() -> void:
|
||||
_menu.hide()
|
||||
_settings.hide()
|
||||
_sort.hide()
|
||||
|
||||
func _on_Sort_pressed() -> void:
|
||||
hide_all()
|
||||
_sort.show()
|
||||
|
||||
func _on_Settings_pressed() -> void:
|
||||
hide_all()
|
||||
_settings.show()
|
||||
|
||||
func _notification(what: int) -> void:
|
||||
if what == NOTIFICATION_READY:
|
||||
_menu = get_node("Menu")
|
||||
_settings = get_node("Settings")
|
||||
_sort = get_node("Sort")
|
||||
|
||||
|
||||
func _on_Settings_back() -> void:
|
||||
hide_all()
|
||||
_menu.show()
|
@ -1,5 +1,58 @@
|
||||
[gd_scene format=2]
|
||||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[node name="Main" type="Control"]
|
||||
[ext_resource path="res://menu/Menu.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://Main.gd" type="Script" id=2]
|
||||
[ext_resource path="res://settings/Settings.tscn" type="PackedScene" id=3]
|
||||
[ext_resource path="res://sort/Sort.tscn" type="PackedScene" id=4]
|
||||
|
||||
[node name="Main" type="PanelContainer"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="Menu" parent="." instance=ExtResource( 1 )]
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_left = 7.0
|
||||
margin_top = 7.0
|
||||
margin_right = 1017.0
|
||||
margin_bottom = 593.0
|
||||
|
||||
[node name="VBoxContainer" parent="Menu" index="0"]
|
||||
margin_right = 1010.0
|
||||
margin_bottom = 586.0
|
||||
|
||||
[node name="Sort" parent="Menu/VBoxContainer" index="0"]
|
||||
margin_top = 239.0
|
||||
margin_right = 1010.0
|
||||
margin_bottom = 259.0
|
||||
|
||||
[node name="Settings" parent="Menu/VBoxContainer" index="1"]
|
||||
margin_top = 283.0
|
||||
margin_right = 1010.0
|
||||
margin_bottom = 303.0
|
||||
|
||||
[node name="Exit" parent="Menu/VBoxContainer" index="2"]
|
||||
margin_top = 327.0
|
||||
margin_right = 1010.0
|
||||
margin_bottom = 347.0
|
||||
|
||||
[node name="Settings" parent="." instance=ExtResource( 3 )]
|
||||
visible = false
|
||||
margin_left = 7.0
|
||||
margin_top = 7.0
|
||||
margin_right = 1017.0
|
||||
margin_bottom = 593.0
|
||||
|
||||
[node name="Sort" parent="." instance=ExtResource( 4 )]
|
||||
visible = false
|
||||
margin_left = 7.0
|
||||
margin_top = 7.0
|
||||
margin_right = 1017.0
|
||||
margin_bottom = 593.0
|
||||
|
||||
[connection signal="pressed" from="Menu/VBoxContainer/Sort" to="." method="_on_Sort_pressed"]
|
||||
[connection signal="pressed" from="Menu/VBoxContainer/Settings" to="." method="_on_Settings_pressed"]
|
||||
[connection signal="back" from="Settings" to="." method="_on_Settings_back"]
|
||||
|
||||
[editable path="Menu"]
|
||||
|
4
game/menu/Exit.gd
Normal file
4
game/menu/Exit.gd
Normal file
@ -0,0 +1,4 @@
|
||||
extends Button
|
||||
|
||||
func _pressed() -> void:
|
||||
get_tree().quit()
|
32
game/menu/Menu.tscn
Normal file
32
game/menu/Menu.tscn
Normal file
@ -0,0 +1,32 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://menu/Exit.gd" type="Script" id=1]
|
||||
|
||||
[node name="Menu" type="MarginContainer"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 600.0
|
||||
custom_constants/separation = 24
|
||||
alignment = 1
|
||||
|
||||
[node name="Sort" type="Button" parent="VBoxContainer"]
|
||||
margin_top = 246.0
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 266.0
|
||||
text = "Sort"
|
||||
|
||||
[node name="Settings" type="Button" parent="VBoxContainer"]
|
||||
margin_top = 290.0
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 310.0
|
||||
text = "Settings"
|
||||
|
||||
[node name="Exit" type="Button" parent="VBoxContainer"]
|
||||
margin_top = 334.0
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 354.0
|
||||
text = "Exit"
|
||||
script = ExtResource( 1 )
|
@ -13,6 +13,14 @@ config_version=4
|
||||
config/name="MemR"
|
||||
run/main_scene="res://Main.tscn"
|
||||
config/icon="res://icon.png"
|
||||
config/sort_folder=""
|
||||
config/target_folder=""
|
||||
|
||||
[display]
|
||||
|
||||
window/handheld/orientation="sensor"
|
||||
window/stretch/mode="2d"
|
||||
window/stretch/aspect="expand"
|
||||
|
||||
[physics]
|
||||
|
||||
|
55
game/settings/Settings.gd
Normal file
55
game/settings/Settings.gd
Normal file
@ -0,0 +1,55 @@
|
||||
extends MarginContainer
|
||||
|
||||
var settings_file : String = "user://settings.cfg"
|
||||
|
||||
signal back
|
||||
|
||||
var _sort_folder_line_edit : LineEdit
|
||||
var _target_folder_line_edit : LineEdit
|
||||
|
||||
func load_settings() -> void:
|
||||
var config_file : ConfigFile = ConfigFile.new()
|
||||
|
||||
var error : int = config_file.load(settings_file)
|
||||
|
||||
if error != OK:
|
||||
# print("Failed to load the settings file! Error code %s" % error)
|
||||
return
|
||||
|
||||
var sort_folder : String = config_file.get_value("default", "sort_folder", "")
|
||||
var target_folder : String = config_file.get_value("default", "target_folder", "")
|
||||
|
||||
ProjectSettings.set("application/config/sort_folder", sort_folder)
|
||||
ProjectSettings.set("application/config/target_folder", target_folder)
|
||||
|
||||
_sort_folder_line_edit.text = sort_folder
|
||||
_target_folder_line_edit.text = target_folder
|
||||
|
||||
|
||||
func save_settings() -> void:
|
||||
var config_file : ConfigFile = ConfigFile.new()
|
||||
|
||||
var sort_folder : String = _sort_folder_line_edit.text
|
||||
var target_folder : String = _target_folder_line_edit.text
|
||||
|
||||
config_file.set_value("default", "sort_folder", sort_folder)
|
||||
config_file.set_value("default", "target_folder", target_folder)
|
||||
|
||||
ProjectSettings.set("application/config/sort_folder", sort_folder)
|
||||
ProjectSettings.set("application/config/target_folder", target_folder)
|
||||
|
||||
var error : int = config_file.save(settings_file)
|
||||
|
||||
if error != OK:
|
||||
# print("Failed to load the settings file! Error code %s" % error)
|
||||
return
|
||||
|
||||
func _on_Button_pressed() -> void:
|
||||
save_settings()
|
||||
emit_signal("back")
|
||||
|
||||
func _notification(what: int) -> void:
|
||||
if what == NOTIFICATION_READY:
|
||||
_sort_folder_line_edit = get_node("VBoxContainer/SortFolder") as LineEdit
|
||||
_target_folder_line_edit = get_node("VBoxContainer/TargetFolder") as LineEdit
|
||||
load_settings()
|
43
game/settings/Settings.tscn
Normal file
43
game/settings/Settings.tscn
Normal file
@ -0,0 +1,43 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://settings/Settings.gd" type="Script" id=1]
|
||||
|
||||
[node name="Settings" type="MarginContainer"]
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 600.0
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 600.0
|
||||
alignment = 1
|
||||
|
||||
[node name="Label" type="Label" parent="VBoxContainer"]
|
||||
margin_top = 244.0
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 258.0
|
||||
text = "Sort folder"
|
||||
|
||||
[node name="SortFolder" type="LineEdit" parent="VBoxContainer"]
|
||||
margin_top = 262.0
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 286.0
|
||||
|
||||
[node name="Label2" type="Label" parent="VBoxContainer"]
|
||||
margin_top = 290.0
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 304.0
|
||||
text = "Target folder"
|
||||
|
||||
[node name="TargetFolder" type="LineEdit" parent="VBoxContainer"]
|
||||
margin_top = 308.0
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 332.0
|
||||
|
||||
[node name="BackButton" type="Button" parent="VBoxContainer"]
|
||||
margin_top = 336.0
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 356.0
|
||||
text = "<- Back"
|
||||
|
||||
[connection signal="pressed" from="VBoxContainer/BackButton" to="." method="_on_Button_pressed"]
|
5
game/sort/Sort.tscn
Normal file
5
game/sort/Sort.tscn
Normal file
@ -0,0 +1,5 @@
|
||||
[gd_scene format=2]
|
||||
|
||||
[node name="Sort" type="MarginContainer"]
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 600.0
|
Loading…
Reference in New Issue
Block a user