Nav panel logic and ControlPanelButton logic
This commit is contained in:
parent
926cc98c4b
commit
52c32de8f2
3
sessionzero/.vscode/settings.json
vendored
Normal file
3
sessionzero/.vscode/settings.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"godotTools.editorPath.godot4": "/home/chris/Godot/Godot_v4.4.1-stable_mono_linux_x86_64/Godot_v4.4.1-stable_mono_linux.x86_64"
|
||||
}
|
@ -13,7 +13,7 @@ config_version=5
|
||||
config/name="SessionZero"
|
||||
config/tags=PackedStringArray("c#")
|
||||
run/main_scene="uid://djj22j6g14exe"
|
||||
config/features=PackedStringArray("4.4", "GL Compatibility")
|
||||
config/features=PackedStringArray("4.4", "C#", "GL Compatibility")
|
||||
boot_splash/bg_color=Color(0.101961, 0.12549, 0.180392, 1)
|
||||
boot_splash/image="uid://qnpvlqg85kx4"
|
||||
config/icon="res://resources/images/icon.svg"
|
||||
|
@ -1,5 +1,6 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://dik0j12wsrebk"]
|
||||
[gd_scene load_steps=4 format=3 uid="uid://dik0j12wsrebk"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://2fms2mdp2fcr" path="res://src/scripts/scenes/controls/ControlPanelButton.cs" id="1_7ouv3"]
|
||||
[ext_resource type="Texture2D" uid="uid://led2qy4im1ir" path="res://resources/icons/outline/user/address-book.svg" id="1_ceptd"]
|
||||
[ext_resource type="Material" uid="uid://ct6poiml5fc2h" path="res://resources/shaders/InverShaderMaterial.tres" id="1_ubvdb"]
|
||||
|
||||
@ -8,6 +9,7 @@ custom_minimum_size = Vector2(250, 150)
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 4
|
||||
theme_type_variation = &"ControlPanelButton"
|
||||
script = ExtResource("1_7ouv3")
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||
layout_mode = 1
|
||||
|
@ -1,14 +1,17 @@
|
||||
[gd_scene load_steps=5 format=3 uid="uid://djj22j6g14exe"]
|
||||
[gd_scene load_steps=8 format=3 uid="uid://djj22j6g14exe"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://rbad8dldyf3k" path="res://src/scripts/scenes/main/MainUILogic.cs" id="1_jqcri"]
|
||||
[ext_resource type="Theme" uid="uid://cy6doom358pb0" path="res://resources/themes/main_theme.tres" id="1_w8y14"]
|
||||
[ext_resource type="Texture2D" uid="uid://b1uk5lvcgwwng" path="res://resources/images/logo_800x800_transparent.png" id="2_gvps3"]
|
||||
[ext_resource type="Material" uid="uid://ct6poiml5fc2h" path="res://resources/shaders/InverShaderMaterial.tres" id="2_jqcri"]
|
||||
[ext_resource type="Texture2D" uid="uid://byj6qsopdu0d3" path="res://resources/icons/outline/general/bars.svg" id="2_ljdvm"]
|
||||
[ext_resource type="PackedScene" uid="uid://uw5lhfr2gtir" path="res://src/scenes/controls/library_grid_container.tscn" id="5_708wv"]
|
||||
[ext_resource type="PackedScene" uid="uid://dik0j12wsrebk" path="res://src/scenes/controls/control_panel_button.tscn" id="6_8fhmd"]
|
||||
|
||||
[node name="MainUICanvas" type="CanvasLayer"]
|
||||
follow_viewport_enabled = true
|
||||
|
||||
[node name="MainUI" type="Control" parent="."]
|
||||
[node name="MainUI" type="Control" parent="." node_paths=PackedStringArray("HamburgerButton", "SideNavPanel", "MainContentContainer")]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
@ -17,6 +20,11 @@ grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
script = ExtResource("1_jqcri")
|
||||
HamburgerButton = NodePath("BackgroundPanel/VBoxContainer/TopNavPanel/HBoxContainer/MarginContainer/HamburgerIcon")
|
||||
SideNavPanel = NodePath("BackgroundPanel/VBoxContainer/MainGridContainer/SideNavPanel")
|
||||
MainContentContainer = NodePath("BackgroundPanel/VBoxContainer/MainGridContainer/MainContentMarginContainer")
|
||||
_navPanelExpandedSize = 100
|
||||
|
||||
[node name="BackgroundPanel" type="Panel" parent="MainUI"]
|
||||
layout_mode = 1
|
||||
@ -73,7 +81,7 @@ size_flags_vertical = 3
|
||||
columns = 2
|
||||
|
||||
[node name="SideNavPanel" type="Panel" parent="MainUI/BackgroundPanel/VBoxContainer/MainGridContainer"]
|
||||
custom_minimum_size = Vector2(60, 0)
|
||||
custom_minimum_size = Vector2(100, 0)
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
theme_type_variation = &"SideNavigationPanel"
|
||||
@ -94,9 +102,12 @@ theme_override_constants/margin_right = 10
|
||||
theme_override_constants/margin_bottom = 10
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="MainUI/BackgroundPanel/VBoxContainer/MainGridContainer/SideNavPanel/VBoxContainer/MarginContainer"]
|
||||
custom_minimum_size = Vector2(40, 40)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 4
|
||||
texture = ExtResource("2_gvps3")
|
||||
expand_mode = 5
|
||||
expand_mode = 1
|
||||
stretch_mode = 4
|
||||
|
||||
[node name="NavButtonsVBox" type="VBoxContainer" parent="MainUI/BackgroundPanel/VBoxContainer/MainGridContainer/SideNavPanel/VBoxContainer"]
|
||||
@ -111,3 +122,9 @@ theme_override_constants/margin_left = 50
|
||||
theme_override_constants/margin_top = 50
|
||||
theme_override_constants/margin_right = 50
|
||||
theme_override_constants/margin_bottom = 50
|
||||
|
||||
[node name="LibraryGridContainer" parent="MainUI/BackgroundPanel/VBoxContainer/MainGridContainer/MainContentMarginContainer" instance=ExtResource("5_708wv")]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="ControlPanelButton" parent="MainUI/BackgroundPanel/VBoxContainer/MainGridContainer/MainContentMarginContainer/LibraryGridContainer" instance=ExtResource("6_8fhmd")]
|
||||
layout_mode = 2
|
||||
|
@ -0,0 +1,20 @@
|
||||
using Godot;
|
||||
using System;
|
||||
|
||||
public partial class ControlPanelButton : Panel
|
||||
{
|
||||
|
||||
public Action Pressed;
|
||||
|
||||
public override void _GuiInput(InputEvent @event)
|
||||
{
|
||||
if (@event is not InputEventMouseButton eventMouseButton) return;
|
||||
|
||||
if (eventMouseButton.ButtonIndex == MouseButton.Left && eventMouseButton.Pressed)
|
||||
{
|
||||
AcceptEvent();
|
||||
Pressed?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1 @@
|
||||
uid://2fms2mdp2fcr
|
@ -3,5 +3,55 @@ using System;
|
||||
|
||||
public partial class MainUILogic : Control
|
||||
{
|
||||
[ExportGroup("Node Exports")]
|
||||
[Export] public TextureButton HamburgerButton;
|
||||
[Export] public Panel SideNavPanel;
|
||||
[Export] public MarginContainer MainContentContainer;
|
||||
|
||||
[ExportGroup("Behaviour")]
|
||||
[Export] private int _navPanelExpandedSize = 60;
|
||||
|
||||
private bool _sideNavToggled = true;
|
||||
private Tween _sideNavTween;
|
||||
private VBoxContainer _sideNavVBox;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_sideNavVBox = SideNavPanel.GetNode<VBoxContainer>("VBoxContainer");
|
||||
|
||||
SetupButtonConnections();
|
||||
|
||||
var cpbTest = GetNode<ControlPanelButton>("BackgroundPanel/VBoxContainer/MainGridContainer/MainContentMarginContainer/LibraryGridContainer/ControlPanelButton");
|
||||
|
||||
cpbTest.Pressed += () => { GD.Print("AYYYYYY"); };
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void SetupButtonConnections()
|
||||
{
|
||||
HamburgerButton.Pressed += () => {ToggleSideNav();};
|
||||
}
|
||||
|
||||
|
||||
private void ToggleSideNav()
|
||||
{
|
||||
_sideNavTween?.Kill();
|
||||
_sideNavTween = CreateTween();
|
||||
|
||||
float targetSize = _sideNavToggled ? 0 : _navPanelExpandedSize;
|
||||
float targetAlpha = _sideNavToggled ? 0.0f : 1.0f;
|
||||
|
||||
_sideNavTween.SetParallel(true);
|
||||
|
||||
_sideNavTween.TweenProperty(SideNavPanel, "custom_minimum_size:x", targetSize, 0.3f)
|
||||
.SetEase(Tween.EaseType.InOut)
|
||||
.SetTrans(Tween.TransitionType.Cubic);
|
||||
|
||||
_sideNavTween.TweenProperty(_sideNavVBox, "modulate:a", targetAlpha, 0.2f);
|
||||
|
||||
_sideNavToggled = !_sideNavToggled;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user