Changed UI sprites to use sprite in resource

This commit is contained in:
MaddoScientisto 2025-02-16 17:36:33 +01:00
commit f2482e4e38
10 changed files with 47 additions and 13 deletions

View file

@ -1,6 +1,11 @@
[gd_resource type="Resource" script_class="LootItem" load_steps=2 format=3 uid="uid://cj5aa7btaw6q0"]
[gd_resource type="Resource" script_class="LootItem" load_steps=4 format=3 uid="uid://cj5aa7btaw6q0"]
[ext_resource type="Script" path="res://Scripts/Resources/LootItem.cs" id="1_k8cnp"]
[ext_resource type="Texture2D" uid="uid://bvybqletsvqgk" path="res://Sprites/Items/BlueKeycard_Small.png" id="1_sgsjd"]
[sub_resource type="AtlasTexture" id="AtlasTexture_ebbst"]
atlas = ExtResource("1_sgsjd")
region = Rect2(0, 0, 16, 16)
[resource]
script = ExtResource("1_k8cnp")
@ -12,3 +17,4 @@ Max = 1
PickupIfMaxed = false
ConsumeOnUse = false
UiType = 1
InventorySprite = SubResource("AtlasTexture_ebbst")

View file

@ -1,7 +1,8 @@
[gd_resource type="Resource" script_class="LootItem" load_steps=4 format=3 uid="uid://cfq121rs3bsu8"]
[gd_resource type="Resource" script_class="LootItem" load_steps=5 format=3 uid="uid://cfq121rs3bsu8"]
[ext_resource type="PackedScene" uid="uid://pemr2lrv3ylk" path="res://Scenes/HUD/Items/ying_yang_gun_huditem.tscn" id="1_i6xgq"]
[ext_resource type="Resource" uid="uid://ckppo2seg313h" path="res://Resources/Weapons/Cheat_Gun.tres" id="2_0na1t"]
[ext_resource type="Texture2D" uid="uid://61kfxc7k3do" path="res://Sprites/Items/Ying_Yang_Gun.png" id="2_5g5j1"]
[ext_resource type="Script" path="res://Scripts/Resources/LootItem.cs" id="3_i0e51"]
[resource]
@ -15,4 +16,5 @@ Max = 1
PickupIfMaxed = true
ConsumeOnUse = false
UiType = 1
InventorySprite = ExtResource("2_5g5j1")
HudItemScene = ExtResource("1_i6xgq")

View file

@ -1,7 +1,12 @@
[gd_resource type="Resource" script_class="LootItem" load_steps=2 format=3 uid="uid://cspcgkr0tane2"]
[gd_resource type="Resource" script_class="LootItem" load_steps=4 format=3 uid="uid://cspcgkr0tane2"]
[ext_resource type="Texture2D" uid="uid://bvkjnc3ggp7ba" path="res://Sprites/Items/GreenKeycard_Small.png" id="1_eyk8n"]
[ext_resource type="Script" path="res://Scripts/Resources/LootItem.cs" id="1_t0s5w"]
[sub_resource type="AtlasTexture" id="AtlasTexture_iasoh"]
atlas = ExtResource("1_eyk8n")
region = Rect2(0, 0, 16, 16)
[resource]
script = ExtResource("1_t0s5w")
ItemName = "Green Keycard"
@ -12,3 +17,4 @@ Max = 1
PickupIfMaxed = false
ConsumeOnUse = false
UiType = 1
InventorySprite = SubResource("AtlasTexture_iasoh")

View file

@ -1,7 +1,8 @@
[gd_resource type="Resource" script_class="LootItem" load_steps=4 format=3 uid="uid://dau0s8ob7qnpc"]
[gd_resource type="Resource" script_class="LootItem" load_steps=5 format=3 uid="uid://dau0s8ob7qnpc"]
[ext_resource type="PackedScene" uid="uid://bqb3gbnrkqewt" path="res://Scenes/HUD/Items/ice_shotgun_huditem.tscn" id="1_13ven"]
[ext_resource type="Resource" uid="uid://cyntngidhcbkc" path="res://Resources/Weapons/Ice_Shotgun_Weapon.tres" id="2_3le6e"]
[ext_resource type="Texture2D" uid="uid://b46usr10jhmev" path="res://Sprites/Items/Ice_Shotgun.png" id="2_4ibag"]
[ext_resource type="Script" path="res://Scripts/Resources/LootItem.cs" id="3_cjfxs"]
[resource]
@ -15,4 +16,5 @@ Max = 1
PickupIfMaxed = false
ConsumeOnUse = false
UiType = 1
InventorySprite = ExtResource("2_4ibag")
HudItemScene = ExtResource("1_13ven")

View file

@ -1,7 +1,8 @@
[gd_resource type="Resource" script_class="LootItem" load_steps=4 format=3 uid="uid://cs3ihltcn2166"]
[gd_resource type="Resource" script_class="LootItem" load_steps=5 format=3 uid="uid://cs3ihltcn2166"]
[ext_resource type="Resource" uid="uid://b8apu0l5fm4k" path="res://Resources/Weapons/IcicleGun.tres" id="1_itajb"]
[ext_resource type="PackedScene" uid="uid://cicthr1v5v4s2" path="res://Scenes/HUD/Items/icicle_gun.tscn" id="1_lfbsh"]
[ext_resource type="Texture2D" uid="uid://duwiasewxvcb5" path="res://Sprites/Items/Icicle_Gun.png" id="2_eaoas"]
[ext_resource type="Script" path="res://Scripts/Resources/LootItem.cs" id="2_hy2hk"]
[resource]
@ -15,4 +16,5 @@ Max = 1
PickupIfMaxed = false
ConsumeOnUse = false
UiType = 1
InventorySprite = ExtResource("2_eaoas")
HudItemScene = ExtResource("1_lfbsh")

View file

@ -3,5 +3,7 @@
[ext_resource type="Texture2D" uid="uid://duwiasewxvcb5" path="res://Sprites/Items/Icicle_Gun.png" id="1_ebd3h"]
[node name="IcicleGun" type="TextureRect"]
offset_right = 16.0
offset_bottom = 16.0
texture = ExtResource("1_ebd3h")
stretch_mode = 2

View file

@ -92,7 +92,12 @@ public partial class Hud : CanvasLayer
var hbox = new HBoxContainer();
_itemsContainer.AddChild(hbox);
var instance = item.HudItemScene.Instantiate<TextureRect>();
var instance = new TextureRect();
instance.Texture = item.InventorySprite;
instance.StretchMode = TextureRect.StretchModeEnum.Keep;
// change transform size?
//var instance = item.HudItemScene.Instantiate<TextureRect>();
//_in.CallDeferred("add_child", instance);
hbox.AddChild(instance);

View file

@ -348,11 +348,11 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
EmitSignal(nameof(InteractableAreaEntered), interactable);
if (_selector == null) return;
//_selector.Position = interactable.Position;
_selector.SelectedInteractable = interactable;
//_selector.AddInteractable(interactable);
//_selector.Visible = true;
//_lastInteractable = interactable;
_selector.AddInteractable(interactable);
//_selector.SelectedInteractable = interactable;
}
}

View file

@ -15,7 +15,7 @@ public partial class LootItem : Resource
[Export] public bool ConsumeOnUse;
[Export] public UiItemType UiType;
[Export] public AtlasTexture InventorySprite;
[Export] public Texture2D InventorySprite;
[Export] public SpriteFrames WorldSprite;
[Export] public PackedScene HudItemScene;

View file

@ -47,7 +47,15 @@ public partial class Selector : Node2D
if (Input.IsActionJustPressed("scan"))
{
SelectNext();
}
if (SelectedInteractable != null) {
this.Visible = true;
this.GlobalPosition = SelectedInteractable.GlobalPosition;
}
else
{
this.Visible = false;
}
}
@ -107,6 +115,7 @@ public partial class Selector : Node2D
public void UpdatePosition()
{
return;
if (SelectedInteractable != null)
{
this.Position = SelectedInteractable.Position;