add base logic 1

This commit is contained in:
pietru 2024-04-08 23:18:04 +02:00
parent eca5e49c91
commit 4e31b9e8e4
3 changed files with 271 additions and 35 deletions

65
main.gd Normal file
View file

@ -0,0 +1,65 @@
extends Control
var games := []
func _ready():
%Games.visible=false
%GameTab.visible=false
%Profiles.visible=false
register_games()
%Games.item_activated.connect(on_item_activated.bind("games"))
%Profiles.item_activated.connect(on_item_activated.bind("profiles"))
%ProfileAdd.pressed.connect(_add_new_profile)
if games.size()==1:
select_game(games[0])
%GameClose.visible=false
elif games.size()>1:
load_games()
%GameClose.pressed.connect(_return_to_list)
func register_games():
games.push_back({"name":"dummy","image":"res://icon.svg"})
games.push_back({"name":"dummy2","image":"res://icon.svg"})
func select_game(game_data:Dictionary):
var game_name :String= game_data.get("name") if game_data.has("name") else "UNKNOWN"
var game_image :Texture= load(game_data.get("image")) if game_data.has("name") else load("res://icon.svg")
%GameName.text=game_name
%GameIcon.texture=game_image
%Games.visible=false
%GameTab.visible=true
%Profiles.visible=true
func load_games():
var list :ItemList=%Games
list.clear()
var i:=0
for dt in games:
var game_name :String= dt.get("name") if dt.has("name") else "UNKNOWN"
var game_image :Texture= load(dt.get("image")) if dt.has("name") else load("res://icon.svg")
list.add_item(game_name,game_image)
list.set_item_metadata(i,dt)
i+=1
%Games.visible=true
func on_item_activated(id:int,type:String):
if type=="games":
var data :Dictionary=%Games.get_item_metadata(id)
select_game(data)
elif type=="profiles":
var data :Dictionary=%Profiles.get_item_metadata(id)
func _return_to_list():
load_games()
%Games.visible=true
%GameTab.visible=false
%Profiles.visible=false
func _add_new_profile():
pass

240
main.tscn
View file

@ -1,4 +1,92 @@
[gd_scene format=3 uid="uid://cefaf32sglsey"] [gd_scene load_steps=5 format=3 uid="uid://cefaf32sglsey"]
[ext_resource type="Script" path="res://main.gd" id="1_ksdsl"]
[sub_resource type="Animation" id="Animation_m3lq2"]
resource_name = "switch_profile_view"
length = 0.15
step = 0.05
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Panel/HBoxContainer/ProfilePanel:visible")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.05, 0.15),
"transitions": PackedFloat32Array(1, 1, 1),
"update": 1,
"values": [false, true, true]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("Panel/HBoxContainer/ProfilePanel:size_flags_stretch_ratio")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0.05, 0.15),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [0.0, 1.0]
}
tracks/2/type = "value"
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/path = NodePath("Panel/HBoxContainer/ProfilePanel:modulate")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/keys = {
"times": PackedFloat32Array(0, 0.05, 0.15),
"transitions": PackedFloat32Array(1, 1, 1),
"update": 0,
"values": [Color(1, 1, 1, 0), Color(1, 1, 1, 0), Color(1, 1, 1, 1)]
}
[sub_resource type="Animation" id="Animation_ise3b"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Panel/HBoxContainer/ProfilePanel:visible")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [false]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("Panel/HBoxContainer/ProfilePanel:size_flags_stretch_ratio")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [0.0]
}
tracks/2/type = "value"
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/path = NodePath("Panel/HBoxContainer/ProfilePanel:modulate")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Color(1, 1, 1, 0)]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_s7q63"]
_data = {
"RESET": SubResource("Animation_ise3b"),
"switch_profile_view": SubResource("Animation_m3lq2")
}
[node name="Main" type="Control"] [node name="Main" type="Control"]
layout_mode = 3 layout_mode = 3
@ -7,6 +95,12 @@ anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
grow_horizontal = 2 grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
script = ExtResource("1_ksdsl")
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
libraries = {
"": SubResource("AnimationLibrary_s7q63")
}
[node name="Panel" type="Panel" parent="."] [node name="Panel" type="Panel" parent="."]
layout_mode = 1 layout_mode = 1
@ -24,60 +118,136 @@ anchor_bottom = 1.0
grow_horizontal = 2 grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
[node name="Cont" type="VBoxContainer" parent="Panel/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
[node name="HBoxContainer" type="HBoxContainer" parent="Panel/HBoxContainer/Cont"]
layout_mode = 2
size_flags_vertical = 3
[node name="Games" type="ItemList" parent="Panel/HBoxContainer/Cont"]
layout_mode = 2
size_flags_vertical = 3
size_flags_stretch_ratio = 4.0
[node name="Profiles" type="ItemList" parent="Panel/HBoxContainer/Cont"]
layout_mode = 2
size_flags_vertical = 3
size_flags_stretch_ratio = 4.0
[node name="VSeparator" type="VSeparator" parent="Panel/HBoxContainer"] [node name="VSeparator" type="VSeparator" parent="Panel/HBoxContainer"]
self_modulate = Color(1, 1, 1, 0) self_modulate = Color(1, 1, 1, 0)
layout_mode = 2 layout_mode = 2
[node name="Cont2" type="VBoxContainer" parent="Panel/HBoxContainer"] [node name="Cont" type="VBoxContainer" parent="Panel/HBoxContainer"]
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
[node name="HBoxContainer" type="HBoxContainer" parent="Panel/HBoxContainer/Cont2"] [node name="HSeparator" type="HSeparator" parent="Panel/HBoxContainer/Cont"]
self_modulate = Color(1, 1, 1, 0)
layout_mode = 2
[node name="GameTab" type="HBoxContainer" parent="Panel/HBoxContainer/Cont"]
unique_name_in_owner = true
layout_mode = 2 layout_mode = 2
size_flags_vertical = 3 size_flags_vertical = 3
[node name="Label" type="Label" parent="Panel/HBoxContainer/Cont2/HBoxContainer"] [node name="GameIcon" type="TextureRect" parent="Panel/HBoxContainer/Cont/GameTab"]
unique_name_in_owner = true
custom_minimum_size = Vector2(64, 0)
layout_mode = 2 layout_mode = 2
text = "lorem Ipsum" expand_mode = 3
stretch_mode = 4
[node name="HBoxContainer2" type="HBoxContainer" parent="Panel/HBoxContainer/Cont2"] [node name="GameName" type="Label" parent="Panel/HBoxContainer/Cont/GameTab"]
unique_name_in_owner = true
layout_mode = 2
text = "Selected Game Name"
[node name="VSeparator" type="VSeparator" parent="Panel/HBoxContainer/Cont/GameTab"]
self_modulate = Color(1, 1, 1, 0)
custom_minimum_size = Vector2(64, 0)
layout_mode = 2
[node name="VBoxContainer" type="VBoxContainer" parent="Panel/HBoxContainer/Cont/GameTab"]
layout_mode = 2
alignment = 1
[node name="ProfileAdd" type="Button" parent="Panel/HBoxContainer/Cont/GameTab/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
text = "Add profile"
[node name="VSeparator2" type="VSeparator" parent="Panel/HBoxContainer/Cont/GameTab"]
self_modulate = Color(1, 1, 1, 0)
custom_minimum_size = Vector2(16, 0)
layout_mode = 2
[node name="VBoxContainer2" type="VBoxContainer" parent="Panel/HBoxContainer/Cont/GameTab"]
layout_mode = 2
alignment = 1
[node name="GameClose" type="Button" parent="Panel/HBoxContainer/Cont/GameTab/VBoxContainer2"]
unique_name_in_owner = true
layout_mode = 2
text = "Return"
[node name="Games" type="ItemList" parent="Panel/HBoxContainer/Cont"]
unique_name_in_owner = true
layout_mode = 2 layout_mode = 2
size_flags_vertical = 3 size_flags_vertical = 3
size_flags_stretch_ratio = 4.0
auto_height = true
max_columns = 8
same_column_width = true
icon_mode = 0
[node name="Label" type="Label" parent="Panel/HBoxContainer/Cont2/HBoxContainer2"] [node name="Profiles" type="ItemList" parent="Panel/HBoxContainer/Cont"]
layout_mode = 2 unique_name_in_owner = true
text = "lorem Ipsum"
[node name="HBoxContainer3" type="HBoxContainer" parent="Panel/HBoxContainer/Cont2"]
layout_mode = 2 layout_mode = 2
size_flags_vertical = 3 size_flags_vertical = 3
size_flags_stretch_ratio = 4.0
auto_height = true
max_columns = 8
same_column_width = true
icon_mode = 0
[node name="Label" type="Label" parent="Panel/HBoxContainer/Cont2/HBoxContainer3"] [node name="HSeparator3" type="HSeparator" parent="Panel/HBoxContainer/Cont"]
self_modulate = Color(1, 1, 1, 0)
layout_mode = 2 layout_mode = 2
text = "lorem Ipsum"
[node name="HBoxContainer4" type="HBoxContainer" parent="Panel/HBoxContainer/Cont2"] [node name="VSeparator2" type="VSeparator" parent="Panel/HBoxContainer"]
self_modulate = Color(1, 1, 1, 0)
layout_mode = 2 layout_mode = 2
size_flags_vertical = 3
[node name="Label" type="Label" parent="Panel/HBoxContainer/Cont2/HBoxContainer4"] [node name="ProfilePanel" type="VBoxContainer" parent="Panel/HBoxContainer"]
unique_name_in_owner = true
visible = false
modulate = Color(1, 1, 1, 0)
layout_mode = 2 layout_mode = 2
text = "lorem Ipsum" size_flags_horizontal = 3
size_flags_stretch_ratio = 0.0
[node name="ProfileIcon" type="TextureRect" parent="Panel/HBoxContainer/ProfilePanel"]
unique_name_in_owner = true
custom_minimum_size = Vector2(96, 96)
layout_mode = 2
expand_mode = 3
stretch_mode = 4
[node name="ProfileName" type="Label" parent="Panel/HBoxContainer/ProfilePanel"]
unique_name_in_owner = true
layout_mode = 2
text = "Profile Name"
[node name="ProfileDesc" type="Label" parent="Panel/HBoxContainer/ProfilePanel"]
unique_name_in_owner = true
layout_mode = 2
text = "Profile Desc"
[node name="ProfileOptions" type="HBoxContainer" parent="Panel/HBoxContainer/ProfilePanel"]
custom_minimum_size = Vector2(0, 32)
layout_mode = 2
[node name="ProfileLaunch" type="Button" parent="Panel/HBoxContainer/ProfilePanel/ProfileOptions"]
unique_name_in_owner = true
layout_mode = 2
text = "Launch"
[node name="ProfileEdit" type="Button" parent="Panel/HBoxContainer/ProfilePanel/ProfileOptions"]
unique_name_in_owner = true
layout_mode = 2
text = "Edit"
[node name="ProfileDelete" type="Button" parent="Panel/HBoxContainer/ProfilePanel/ProfileOptions"]
unique_name_in_owner = true
layout_mode = 2
text = "Delete"
[node name="ProfileOpenFolder" type="Button" parent="Panel/HBoxContainer/ProfilePanel/ProfileOptions"]
unique_name_in_owner = true
layout_mode = 2
text = "Open Folder"

View file

@ -11,5 +11,6 @@ config_version=5
[application] [application]
config/name="AppLauncher" config/name="AppLauncher"
run/main_scene="res://main.tscn"
config/features=PackedStringArray("4.2", "Forward Plus") config/features=PackedStringArray("4.2", "Forward Plus")
config/icon="res://icon.svg" config/icon="res://icon.svg"