From 931e01337f3781aecbf24f9de59e437b68578202 Mon Sep 17 00:00:00 2001 From: Jarrod Doyle Date: Tue, 17 Sep 2024 17:43:37 +0100 Subject: [PATCH] Add asset browser to main scene with hotkey --- project/code/TMV/UI/AssetBrowser.cs | 28 +++++++++++++++++++ .../scenes/asset_browser/asset_browser.tscn | 12 ++++---- project/scenes/main.tscn | 6 +++- 3 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 project/code/TMV/UI/AssetBrowser.cs diff --git a/project/code/TMV/UI/AssetBrowser.cs b/project/code/TMV/UI/AssetBrowser.cs new file mode 100644 index 0000000..6a37f30 --- /dev/null +++ b/project/code/TMV/UI/AssetBrowser.cs @@ -0,0 +1,28 @@ +using Godot; + +namespace KeepersCompound.TMV.UI; + +public partial class AssetBrowser : Control +{ + // Called when the node enters the scene tree for the first time. + public override void _Ready() + { + } + + // Called every frame. 'delta' is the elapsed time since the previous frame. + public override void _Process(double delta) + { + } + + public override void _ShortcutInput(InputEvent input) + { + if (input is InputEventKey keyEvent && keyEvent.Pressed) + { + if (keyEvent.Keycode == Key.Space) + { + Visible = !Visible; + GetViewport().SetInputAsHandled(); + } + } + } +} diff --git a/project/scenes/asset_browser/asset_browser.tscn b/project/scenes/asset_browser/asset_browser.tscn index fc62f91..9c88948 100644 --- a/project/scenes/asset_browser/asset_browser.tscn +++ b/project/scenes/asset_browser/asset_browser.tscn @@ -1,6 +1,7 @@ -[gd_scene load_steps=8 format=3 uid="uid://byknmqac1a5vn"] +[gd_scene load_steps=9 format=3 uid="uid://byknmqac1a5vn"] [ext_resource type="Texture2D" uid="uid://b208ufsau5jhb" path="res://project/jorge.png" id="1_1vlw2"] +[ext_resource type="Script" path="res://project/code/TMV/UI/AssetBrowser.cs" id="1_5rr8c"] [ext_resource type="Script" path="res://project/code/TMV/UI/TextureBrowser.cs" id="1_72xft"] [ext_resource type="Texture2D" uid="uid://beb4tj06ivjae" path="res://project/assets/icons/Search.svg" id="1_ityvd"] [ext_resource type="Texture2D" uid="uid://dx8paqeom7dtb" path="res://project/assets/icons/Sort.svg" id="3_0k1fm"] @@ -9,6 +10,7 @@ [ext_resource type="Texture2D" uid="uid://bfswg75r148mr" path="res://project/assets/icons/ActionCopy.svg" id="7_2pq2g"] [node name="AssetBrowser" type="Control"] +visible = false layout_mode = 3 anchors_preset = 15 anchor_right = 1.0 @@ -17,12 +19,12 @@ grow_horizontal = 2 grow_vertical = 2 size_flags_horizontal = 3 size_flags_vertical = 3 +script = ExtResource("1_5rr8c") [node name="TabContainer" type="TabContainer" parent="."] -layout_mode = 1 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 +layout_mode = 2 +offset_right = 1152.0 +offset_bottom = 648.0 grow_horizontal = 2 grow_vertical = 2 current_tab = 0 diff --git a/project/scenes/main.tscn b/project/scenes/main.tscn index e13afad..796da0b 100644 --- a/project/scenes/main.tscn +++ b/project/scenes/main.tscn @@ -1,8 +1,9 @@ -[gd_scene load_steps=6 format=3 uid="uid://boxi211q3kx6c"] +[gd_scene load_steps=7 format=3 uid="uid://boxi211q3kx6c"] [ext_resource type="Script" path="res://project/code/TMV/Mission.cs" id="1_3gnqe"] [ext_resource type="Script" path="res://project/code/camera.gd" id="2_w5otl"] [ext_resource type="PackedScene" uid="uid://bfxdpxkcgwlkx" path="res://project/scenes/ui/resource_selector.tscn" id="3_kdn7u"] +[ext_resource type="PackedScene" uid="uid://byknmqac1a5vn" path="res://project/scenes/asset_browser/asset_browser.tscn" id="3_noiti"] [ext_resource type="PackedScene" uid="uid://0h2w7w84vbea" path="res://project/scenes/ui/lightmap_layer_toggler.tscn" id="4_naip8"] [sub_resource type="Environment" id="Environment_cckyk"] @@ -26,6 +27,9 @@ unique_name_in_owner = true [node name="LightmapToggler" parent="UI" instance=ExtResource("4_naip8")] unique_name_in_owner = true +visible = false + +[node name="AssetBrowser" parent="UI" instance=ExtResource("3_noiti")] [node name="WorldEnvironment" type="WorldEnvironment" parent="."] environment = SubResource("Environment_cckyk")