Hide and show shop menu
parent
83754105e8
commit
627598b753
32
UI/Base.tscn
32
UI/Base.tscn
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=18 format=3 uid="uid://c271rdjhd1gfo"]
|
||||
[gd_scene load_steps=14 format=3 uid="uid://c271rdjhd1gfo"]
|
||||
|
||||
[ext_resource type="Script" path="res://UI/UIController.cs" id="2_b4b6l"]
|
||||
[ext_resource type="PackedScene" uid="uid://bxo553hblp6nf" path="res://UI/HealthBar.tscn" id="3_j1j6h"]
|
||||
|
@ -11,18 +11,8 @@
|
|||
[ext_resource type="PackedScene" uid="uid://2afbrf8asy2a" path="res://UI/PostProcessing/Vignette.tscn" id="9_p1ubd"]
|
||||
[ext_resource type="PackedScene" uid="uid://b1wsryv4bn0cn" path="res://UI/PostProcessing/StunEffect.tscn" id="10_646ma"]
|
||||
[ext_resource type="Shader" path="res://Shaders/Grayscale.gdshader" id="11_w4gn1"]
|
||||
[ext_resource type="Theme" uid="uid://cksjbu3vrup5" path="res://UI/Themes/supalidl.tres" id="11_wtdum"]
|
||||
[ext_resource type="Texture2D" uid="uid://bw052v8ikfget" path="res://icon.svg" id="12_tyv35"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_a504f"]
|
||||
bg_color = Color(0.906763, 0, 0.280984, 1)
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_gheod"]
|
||||
bg_color = Color(1, 0.315507, 0.447521, 1)
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_1nm23"]
|
||||
bg_color = Color(0.951511, 0.387714, 0.416256, 1)
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_kbd61"]
|
||||
shader = ExtResource("11_w4gn1")
|
||||
shader_parameter/grayscale_intensity = 0.0
|
||||
|
@ -30,15 +20,6 @@ shader_parameter/grayscale_intensity = 0.0
|
|||
[node name="BaseUI" type="CanvasLayer"]
|
||||
process_mode = 3
|
||||
|
||||
[node name="Button" type="Button" parent="."]
|
||||
offset_left = 536.0
|
||||
offset_right = 592.0
|
||||
offset_bottom = 31.0
|
||||
theme_override_styles/focus = SubResource("StyleBoxFlat_a504f")
|
||||
theme_override_styles/hover = SubResource("StyleBoxFlat_gheod")
|
||||
theme_override_styles/normal = SubResource("StyleBoxFlat_1nm23")
|
||||
text = "sdfsdf"
|
||||
|
||||
[node name="PostProcessing" type="CanvasLayer" parent="."]
|
||||
|
||||
[node name="Vignette" parent="PostProcessing" instance=ExtResource("9_p1ubd")]
|
||||
|
@ -139,7 +120,9 @@ grow_horizontal = 0
|
|||
grow_vertical = 2
|
||||
alignment = 2
|
||||
|
||||
[node name="Panel" parent="SubViewportContainer/UIViewport/MainUILayer/Main/BoxContainer" node_paths=PackedStringArray("_inventoryGrid") instance=ExtResource("8_ep3ae")]
|
||||
[node name="ShopMenu" parent="SubViewportContainer/UIViewport/MainUILayer/Main/BoxContainer" node_paths=PackedStringArray("_inventoryGrid") instance=ExtResource("8_ep3ae")]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
_inventoryGrid = NodePath("PanelContainer/VBoxContainer/ScrollContainer/InventoryGrid")
|
||||
|
||||
|
@ -158,13 +141,6 @@ alignment = 1
|
|||
visible = false
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Button" type="Button" parent="SubViewportContainer/UIViewport/MainUILayer/Main/Bottom"]
|
||||
layout_mode = 2
|
||||
theme = ExtResource("11_wtdum")
|
||||
theme_type_variation = &"InventorySlotButton"
|
||||
theme_override_styles/hover = SubResource("StyleBoxFlat_gheod")
|
||||
text = "sdfsdfa"
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="SubViewportContainer/UIViewport/MainUILayer/Main"]
|
||||
visible = false
|
||||
layout_mode = 0
|
||||
|
|
|
@ -12,7 +12,6 @@ public partial class ShopMenu : Control, IModal
|
|||
get => _source;
|
||||
set
|
||||
{
|
||||
GD.Print("Set ShopMenu source");
|
||||
_source = value;
|
||||
_inventoryGrid.Source = value;
|
||||
}
|
||||
|
@ -23,24 +22,31 @@ public partial class ShopMenu : Control, IModal
|
|||
|
||||
private InventorySlot _selected;
|
||||
|
||||
public void ShowModal()
|
||||
{
|
||||
Show();
|
||||
var animPlayer = GetNode<AnimationPlayer>("%AnimationPlayer");
|
||||
animPlayer.Play("open");
|
||||
}
|
||||
|
||||
public void HideModal()
|
||||
{
|
||||
Hide();
|
||||
_source = null;
|
||||
}
|
||||
|
||||
public async void Close()
|
||||
{
|
||||
var animPlayer = GetNode<AnimationPlayer>("%AnimationPlayer");
|
||||
animPlayer.Play("close");
|
||||
await ToSignal(animPlayer, AnimationPlayer.SignalName.AnimationFinished);
|
||||
HideModal();
|
||||
}
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
Events.EventBus.Instance.EnterShop += (string path) =>
|
||||
{
|
||||
var shop = ResourceLoader.Load<Items.Shop>(path);
|
||||
GD.Print("Loaded shop");
|
||||
Source = shop;
|
||||
};
|
||||
|
||||
_inventoryGrid.SlotFocused += (InventorySlot slot) =>
|
||||
{
|
||||
GD.Print("SlotFocused " + slot.Name);
|
||||
if (slot.Item is not null)
|
||||
{
|
||||
SetTooltipItem(slot);
|
||||
|
@ -59,10 +65,11 @@ public partial class ShopMenu : Control, IModal
|
|||
GetNode<Button>("%BuyButton").GrabFocus();
|
||||
};
|
||||
|
||||
GetNode<Button>("%BuyButton").GuiInput += (Godot.InputEvent @event) =>
|
||||
GetNode<Button>("%BuyButton").GuiInput += (InputEvent @event) =>
|
||||
{
|
||||
if (@event.IsAction("ui_cancel"))
|
||||
if (@event.IsActionPressed("ui_cancel"))
|
||||
{
|
||||
GetViewport().SetInputAsHandled();
|
||||
_selected?.GrabFocus();
|
||||
}
|
||||
};
|
||||
|
@ -81,4 +88,13 @@ public partial class ShopMenu : Control, IModal
|
|||
GetNode<Button>("%BuyButton").Disabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
public override void _UnhandledInput(InputEvent @event)
|
||||
{
|
||||
if (@event.IsActionPressed("ui_cancel"))
|
||||
{
|
||||
GetViewport().SetInputAsHandled();
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
[gd_scene load_steps=9 format=3 uid="uid://cyggkyqosjk36"]
|
||||
[gd_scene load_steps=15 format=3 uid="uid://cyggkyqosjk36"]
|
||||
|
||||
[ext_resource type="StyleBox" uid="uid://bqhotx2ogucye" path="res://UI/Themes/Panel.tres" id="1_2ffty"]
|
||||
[ext_resource type="Script" path="res://UI/Inventory/ShopMenu.cs" id="1_8c1y7"]
|
||||
[ext_resource type="Shader" path="res://Shaders/WipeXY.gdshader" id="2_jqery"]
|
||||
[ext_resource type="FontFile" uid="uid://cgwa8bjiyv534" path="res://Assets/Fonts/alagard.ttf" id="3_aj4jx"]
|
||||
[ext_resource type="PackedScene" uid="uid://bsheehtfcdwhh" path="res://UI/Inventory/ItemTooltip.tscn" id="4_n61n7"]
|
||||
[ext_resource type="PackedScene" uid="uid://chmokkxsy5vas" path="res://UI/Inventory/InventoryGrid.tscn" id="4_sl632"]
|
||||
|
@ -21,6 +22,138 @@ corner_radius_top_right = 16
|
|||
corner_radius_bottom_right = 16
|
||||
corner_radius_bottom_left = 16
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_2hdh3"]
|
||||
shader = ExtResource("2_jqery")
|
||||
shader_parameter/x_amount = 1.0
|
||||
shader_parameter/y_amount = 0.5
|
||||
|
||||
[sub_resource type="Animation" id="Animation_yj24f"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath(".:modulate")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Color(1, 1, 1, 1)]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("PanelContainer:material:shader_parameter/y_amount")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [0.5]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/path = NodePath("PanelContainer:material:shader_parameter/x_amount")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [1.0]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_tm2as"]
|
||||
resource_name = "close"
|
||||
length = 0.5
|
||||
step = 0.05
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath(".:modulate")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.4),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [Color(1, 1, 1, 1), Color(1, 1, 1, 0)]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("PanelContainer:material:shader_parameter/y_amount")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0, 0.1),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [0.5, 1.0]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/path = NodePath("PanelContainer:material:shader_parameter/x_amount")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/keys = {
|
||||
"times": PackedFloat32Array(0.05, 0.15),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [1.0, 0.5]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_fgj27"]
|
||||
resource_name = "open"
|
||||
length = 0.5
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath(".:modulate")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.3),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [Color(1, 1, 1, 0), Color(1, 1, 1, 1)]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("PanelContainer:material:shader_parameter/y_amount")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0, 0.5),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [1.0, 0.5]
|
||||
}
|
||||
tracks/2/type = "value"
|
||||
tracks/2/imported = false
|
||||
tracks/2/enabled = true
|
||||
tracks/2/path = NodePath("PanelContainer:material:shader_parameter/x_amount")
|
||||
tracks/2/interp = 1
|
||||
tracks/2/loop_wrap = true
|
||||
tracks/2/keys = {
|
||||
"times": PackedFloat32Array(0, 0.3),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [0.5, 1.0]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_0glcp"]
|
||||
_data = {
|
||||
"RESET": SubResource("Animation_yj24f"),
|
||||
"close": SubResource("Animation_tm2as"),
|
||||
"open": SubResource("Animation_fgj27")
|
||||
}
|
||||
|
||||
[node name="Panel" type="PanelContainer" node_paths=PackedStringArray("_inventoryGrid")]
|
||||
anchors_preset = 6
|
||||
anchor_left = 1.0
|
||||
|
@ -37,6 +170,7 @@ script = ExtResource("1_8c1y7")
|
|||
_inventoryGrid = NodePath("PanelContainer/VBoxContainer/ScrollContainer/InventoryGrid")
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="."]
|
||||
material = SubResource("ShaderMaterial_2hdh3")
|
||||
layout_mode = 2
|
||||
theme_override_styles/panel = ExtResource("1_2ffty")
|
||||
|
||||
|
@ -75,3 +209,9 @@ layout_mode = 2
|
|||
size_flags_horizontal = 3
|
||||
theme = ExtResource("7_rvp1r")
|
||||
text = "Buy"
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
unique_name_in_owner = true
|
||||
libraries = {
|
||||
"": SubResource("AnimationLibrary_0glcp")
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using Godot;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SupaLidlGame.UI;
|
||||
|
||||
|
@ -9,4 +10,17 @@ public partial class UIController : Control
|
|||
|
||||
[Export]
|
||||
public BossBar BossBar { get; set; }
|
||||
|
||||
private Stack<IModal> _modals;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
Events.EventBus.Instance.EnterShop += (string path) =>
|
||||
{
|
||||
var shop = ResourceLoader.Load<Items.Shop>(path);
|
||||
var shopMenu = GetNode<Inventory.ShopMenu>("%ShopMenu");
|
||||
shopMenu.Source = shop;
|
||||
shopMenu.ShowModal();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue