6 Commits

Author SHA1 Message Date
  Ryan Reed 796b623f89 chore: Bump version 0.1.2 -> 0.2.0 3 weeks ago
  Ryan Reed 207932d643 Inventory and Quickslots Rework (#24) 3 weeks ago
  Ryan Reed 5ed31e57d7 chore: Bump version 0.1.1 -> 0.1.2 3 weeks ago
  Ryan Reed 5257fa7fe1 feat: Update default night/day colors and time of day 3 weeks ago
  Ryan Reed 73fe4fa6c7 fix: Autosaves not working if saves path does not exist 3 weeks ago
  Ryan Reed 6ca52a9233 fix: default item_texture value 3 weeks ago
30 changed files with 613 additions and 273 deletions
Split View
  1. +1
    -0
      addons/save_load_system/autoloads/save_game_manager.gd
  2. +1
    -0
      autoloads/db_items.gd
  3. +186
    -9
      autoloads/inventory_manager.gd
  4. +1
    -1
      project.godot
  5. +3
    -1
      resources/blocks/005_grass.tres
  6. +3
    -1
      resources/db_item_resource.gd
  7. +40
    -7
      resources/inventory/player_inventory_testing.tres
  8. +0
    -1
      resources/inventory_resource.gd
  9. +5
    -0
      resources/item_resource.gd
  10. +1
    -0
      resources/item_resource.gd.uid
  11. +14
    -0
      resources/items/007_torch.tres
  12. +1
    -1
      resources/world/sky_horizon_color_gradient.tres
  13. +1
    -1
      resources/world/sky_top_color_gradient.tres
  14. +23
    -0
      scenes/items/torch.tscn
  15. +28
    -8
      scenes/player/player.gd
  16. +1
    -1
      scenes/player/player.tscn
  17. +2
    -1
      scenes/player/ray_cast_look.gd
  18. +65
    -43
      scenes/ui/inventory/inventory.gd
  19. +8
    -5
      scenes/ui/inventory/inventory.tscn
  20. +30
    -4
      scenes/ui/inventory/item_rect.gd
  21. +18
    -10
      scenes/ui/inventory/item_rect.tscn
  22. +0
    -157
      scenes/ui/quick_slots.tscn
  23. +34
    -20
      scenes/ui/quickslots/quick_slots.gd
  24. +0
    -0
      scenes/ui/quickslots/quick_slots.gd.uid
  25. +63
    -0
      scenes/ui/quickslots/quick_slots.tscn
  26. +40
    -0
      scenes/ui/quickslots/quickslots_slot.gd
  27. +1
    -0
      scenes/ui/quickslots/quickslots_slot.gd.uid
  28. +36
    -0
      scenes/ui/quickslots/quickslots_slot.tscn
  29. +6
    -2
      scenes/ui/ui.tscn
  30. +1
    -0
      scenes/world/world.tscn

+ 1
- 0
addons/save_load_system/autoloads/save_game_manager.gd View File

@ -186,6 +186,7 @@ func _rotate_autosaves() -> void:
var saves_dir = DirAccess.open(_save_game_settings.save_game_data_path)
if saves_dir == null:
DirAccess.make_dir_absolute(_save_game_settings.save_game_data_path)
saves_dir = DirAccess.open(_save_game_settings.save_game_data_path)
var autosaves: Array[String] = []
for filename in saves_dir.get_files():


+ 1
- 0
autoloads/db_items.gd View File

@ -8,4 +8,5 @@ extends Node
"004": preload("res://resources/blocks/004_leaves.tres"),
"005": preload("res://resources/blocks/005_grass.tres"),
"006": preload("res://resources/blocks/006_glass.tres"),
"007": preload("res://resources/items/007_torch.tres"),
}

+ 186
- 9
autoloads/inventory_manager.gd View File

@ -1,20 +1,197 @@
extends Node
signal item_dropped(item: DBItemResource)
signal item_picked_up(item: DBItemResource)
#region Inventory Specific
signal add_to_inventory(item_id: String, amount: int)
signal clear_inventory ## Remove all items in inventory
signal item_added(item_id: String, amount: int)
signal item_removed(item_id: String, amount: int)
signal inventory_closed
signal inventory_opened
signal inventory_slot_updated(slot_index: int)
signal remove_from_inventory(item_id: String, amount: int)
signal remove_from_quickslot(amount: int)
signal remove_from_slot(slot_index: int, amount: int)
#endregion
#region Quickslots
signal next_quick_slot
signal previous_quick_slot
signal quick_slot_selected(slot_index: int)
signal select_quick_slot(slot_index: int)
signal quick_slot_item_changed(item_id: String)
signal item_picked_up(item: DBItemResource)
signal item_dropped(item: DBItemResource)
signal inventory_opened
signal inventory_closed
#endregion
var quick_slot_item_id: String = "001"
var max_inventory_items: int = 40 # 4 rows of 10
var quick_slot_count: int = 10
var selected_quick_slot: int = 0
var inventory: Array[DBItemResource] = [] ## To ensure inventory is automatically sorted, "empty" inventory cells will be replaced with null to keep positions
var _inventory_cache: Dictionary[String, Dictionary] = {} ## Used for caching certain information
func _ready() -> void:
self.quick_slot_item_changed.connect(_on_quick_slot_item_changed)
self.item_picked_up.connect(_on_item_picked_up)
self.item_dropped.connect(_on_item_dropped)
self.add_to_inventory.connect(_on_add_to_inventory)
self.clear_inventory.connect(_on_clear_inventory)
self.quick_slot_selected.connect(_on_quick_slot_selected)
self.remove_from_inventory.connect(_on_remove_from_inventory)
self.remove_from_quickslot.connect(_on_remove_from_quickslot)
self.remove_from_slot.connect(_on_remove_from_slot)
func available_space(item_id: String) -> int:
var full_stacks: int = floor(_inventory_cache[item_id].total / DBItems.data[item_id].max_stack_size)
var space_in_stacks: int = (
DBItems.data[item_id].max_stack_size - abs(
_inventory_cache[item_id].total - (DBItems.data[item_id].max_stack_size * full_stacks)
)
)
# This is a bit of a hack because I'm a math/logic noob
if space_in_stacks == DBItems.data[item_id].max_stack_size:
space_in_stacks = 0
var open_stack_amount: int = (max_inventory_items - inventory.size()) * DBItems.data[item_id].max_stack_size
return open_stack_amount + space_in_stacks
func get_inventory_item(item_slot: int = selected_quick_slot) -> DBItemResource:
if item_slot >= inventory.size() or item_slot < 0:
return null
return inventory.get(item_slot)
func get_quick_slot_item_id(item_slot: int = selected_quick_slot) -> String:
return inventory[item_slot].id
func _find_stacks_by_id(item_resource: DBItemResource, item_id: String) -> bool:
return item_resource != null and item_resource.id == item_id
## Find the stack where at least one item can be added
func _find_stacks_with_space(item_resource: DBItemResource, item_id: String) -> bool:
return (
item_resource == null or (
item_resource.id == item_id and
item_resource.amount < item_resource.max_stack_size
)
)
## Removes an amount of items from a specific slot
## If the amount exceeds the amount of the slot, will NOT remove from other stacks
func _remove_from_slot(slot_index: int, amount: int) -> void:
if slot_index >= max_inventory_items:
printerr("Slot Index ", slot_index, " out of inventory range")
return
inventory[slot_index].amount -= amount
if inventory[slot_index].amount <= 0:
inventory[slot_index] = null
inventory_slot_updated.emit(slot_index)
func _update_cache_total(item_id: String, amount: int) -> void:
if not _inventory_cache.get(item_id):
_inventory_cache[item_id] = {"total": 0}
_inventory_cache[item_id].total += amount
func _on_add_to_inventory(item_id: String, amount: int = 1) -> void:
if not DBItems.data.get(item_id):
printerr("Cannot add item, ", item_id, ", to inventory. Could not find item within DBItems.data.")
return
if amount < 1:
printerr("Cannot add item, ", item_id, ", to inventory. Amount to add cannot be less then 1.")
return
var item_resource: DBItemResource = DBItems.data[item_id]
# This logic seems overly complicated and is a mess.
# Should look into fixing/simplifying this in the future
var amount_remaining: int = amount
while amount_remaining > 0:
var first_stack_index: int = inventory.find_custom(_find_stacks_with_space.bind(item_id))
var stack_resource: DBItemResource
if first_stack_index == -1 and inventory.size() < max_inventory_items: # No existing stack and empty slots available
stack_resource = item_resource.duplicate()
inventory.append(stack_resource)
if amount_remaining <= stack_resource.max_stack_size:
_update_cache_total(item_id, amount_remaining)
inventory[-1].amount += amount_remaining
amount_remaining = 0
else:
_update_cache_total(item_id, stack_resource.max_stack_size)
inventory[-1].amount = stack_resource.max_stack_size
amount_remaining -= stack_resource.max_stack_size
inventory_slot_updated.emit(inventory.size() - 1)
elif first_stack_index > -1:
if inventory[first_stack_index] == null: # Empty slot
inventory[first_stack_index] = item_resource.duplicate()
stack_resource = inventory[first_stack_index]
var current_amount: int = stack_resource.amount
var total_amount: int = current_amount + amount_remaining
if total_amount < stack_resource.max_stack_size: # Stack not full and has space
_update_cache_total(item_id, amount_remaining)
inventory[first_stack_index].amount = total_amount
amount_remaining = 0
else:
_update_cache_total(item_id, stack_resource.max_stack_size - current_amount)
inventory[first_stack_index].amount = stack_resource.max_stack_size
amount_remaining -= stack_resource.max_stack_size
inventory_slot_updated.emit(first_stack_index)
item_added.emit(item_id, amount - amount_remaining)
func _on_remove_from_inventory(item_id: String, amount: int = 1) -> void:
var amount_remaining: int = amount
while amount_remaining > 0:
var last_stack_index: int = inventory.rfind_custom(_find_stacks_by_id.bind(item_id))
if last_stack_index > -1:
var stack_resource: DBItemResource = inventory[last_stack_index]
var current_stack_amount: int = stack_resource.amount
var total_amount: int = current_stack_amount - amount_remaining
if total_amount > 0: # Stack will not be empty after removing
_update_cache_total(item_id, -amount_remaining)
inventory[last_stack_index].amount -= amount_remaining
amount_remaining = 0
else:
var to_remove: int = stack_resource.max_stack_size - current_stack_amount
_update_cache_total(item_id, -amount_remaining)
inventory[last_stack_index] = null
amount_remaining -= to_remove
inventory_slot_updated.emit(last_stack_index)
else: # Received more to remove than we have stacks for
amount_remaining = 0
item_removed.emit(item_id, amount - amount_remaining)
func _on_clear_inventory() -> void:
inventory.clear()
_inventory_cache.clear()
func _on_item_dropped(item: DBItemResource) -> void:
_on_remove_from_inventory(item.id, 1)
func _on_item_picked_up(item: DBItemResource) -> void:
_on_add_to_inventory(item.id, 1)
func _on_quick_slot_selected(slot_index: int) -> void:
selected_quick_slot = slot_index
func _on_remove_from_slot(slot_index: int, amount: int) -> void:
_remove_from_slot(slot_index, amount)
func _on_quick_slot_item_changed(item_id: String) -> void:
quick_slot_item_id = item_id
func _on_remove_from_quickslot(amount: int) -> void:
_remove_from_slot(selected_quick_slot, amount)

+ 1
- 1
project.godot View File

@ -11,7 +11,7 @@ config_version=5
[application]
config/name="Skyblock"
config/version="0.1.1"
config/version="0.2.0"
run/main_scene="uid://cgx0nawwjjj7g"
config/features=PackedStringArray("4.4", "Forward Plus")
config/icon="uid://f6hee5t26uqt"


+ 3
- 1
resources/blocks/005_grass.tres View File

@ -9,6 +9,8 @@ material_texture = ExtResource("1_n4fyn")
id = "005"
name = "Grass"
amount = 0
max_stack_size = 999
max_number_stacks = 0
description = "Block of grass and dirt"
item_texture = "uid://li36txj7oweq"
item_texture = "uid://bgo4mb3atmbot"
metadata/_custom_type_script = "uid://dwrmy4mx0mw18"

+ 3
- 1
resources/db_item_resource.gd View File

@ -5,5 +5,7 @@ extends Resource
@export var id: String = "000"
@export var name: String = "Item Name"
@export var amount: int = 0
@export var max_stack_size: int = 999
@export var max_number_stacks: int = 0 ## 0 for unlimited stacks
@export var description: String = "Item Description"
@export_file var item_texture: String = "res://assets/icon.svg"
@export_file var item_texture: String = "res://assets/godot-icon.svg"

+ 40
- 7
resources/inventory/player_inventory_testing.tres View File

@ -1,4 +1,4 @@
[gd_resource type="Resource" script_class="InventoryResource" load_steps=12 format=3 uid="uid://blfp6tiir282o"]
[gd_resource type="Resource" script_class="InventoryResource" load_steps=16 format=3 uid="uid://blfp6tiir282o"]
[ext_resource type="Script" uid="uid://becun6dj78v8d" path="res://resources/inventory_resource.gd" id="1_4v6mg"]
[ext_resource type="Script" uid="uid://bdx4q355l5ugl" path="res://resources/db_item_resource.gd" id="1_gg8jx"]
@ -6,14 +6,18 @@
[ext_resource type="Script" uid="uid://dwrmy4mx0mw18" path="res://resources/block_resource.gd" id="3_vgvac"]
[ext_resource type="Material" uid="uid://cx7m27qa4ds4s" path="res://assets/materials/stone.tres" id="4_7yuhn"]
[ext_resource type="Material" uid="uid://jearv8lmwhec" path="res://assets/materials/wood.tres" id="5_p27bu"]
[ext_resource type="Material" uid="uid://b4wrf3quiaa1b" path="res://assets/materials/grass.tres" id="7_vgvac"]
[ext_resource type="Material" uid="uid://d15n1p3spu3jg" path="res://assets/materials/leaves.tres" id="7_xd1nd"]
[ext_resource type="Material" uid="uid://b2w5ybx51vuwf" path="res://assets/materials/glass.tres" id="8_7yuhn"]
[sub_resource type="Resource" id="Resource_jaam2"]
script = ExtResource("3_vgvac")
material_texture = ExtResource("2_8w148")
id = "001"
name = "Dirt"
amount = 100
amount = 999
max_stack_size = 999
max_number_stacks = 0
description = "Block of dirt"
item_texture = "uid://li36txj7oweq"
metadata/_custom_type_script = "uid://dwrmy4mx0mw18"
@ -23,7 +27,9 @@ script = ExtResource("3_vgvac")
material_texture = ExtResource("4_7yuhn")
id = "002"
name = "Stone"
amount = 100
amount = 999
max_stack_size = 999
max_number_stacks = 0
description = "Block of stone"
item_texture = "uid://ct1iawpfkdf5l"
metadata/_custom_type_script = "uid://dwrmy4mx0mw18"
@ -33,7 +39,9 @@ script = ExtResource("3_vgvac")
material_texture = ExtResource("5_p27bu")
id = "003"
name = "Wood"
amount = 100
amount = 999
max_stack_size = 999
max_number_stacks = 0
description = "Wood log"
item_texture = "uid://0mw651622h01"
metadata/_custom_type_script = "uid://dwrmy4mx0mw18"
@ -43,13 +51,38 @@ script = ExtResource("3_vgvac")
material_texture = ExtResource("7_xd1nd")
id = "004"
name = "Leaves"
amount = 100
amount = 999
max_stack_size = 999
max_number_stacks = 0
description = "Tree leaves"
item_texture = "uid://goygbpyqhych"
metadata/_custom_type_script = "uid://dwrmy4mx0mw18"
[sub_resource type="Resource" id="Resource_viap3"]
script = ExtResource("3_vgvac")
material_texture = ExtResource("7_vgvac")
id = "005"
name = "Grass"
amount = 999
max_stack_size = 999
max_number_stacks = 0
description = "Block of grass and dirt"
item_texture = "uid://li36txj7oweq"
metadata/_custom_type_script = "uid://dwrmy4mx0mw18"
[sub_resource type="Resource" id="Resource_wqat2"]
script = ExtResource("3_vgvac")
material_texture = ExtResource("8_7yuhn")
id = "006"
name = "Glass"
amount = 999
max_stack_size = 999
max_number_stacks = 0
description = "Glass block"
item_texture = "uid://cpllegyqnfnrh"
metadata/_custom_type_script = "uid://dwrmy4mx0mw18"
[resource]
script = ExtResource("1_4v6mg")
inventory = Array[ExtResource("1_gg8jx")]([SubResource("Resource_jaam2"), SubResource("Resource_4kby3"), SubResource("Resource_byct5"), SubResource("Resource_qycqj")])
max_stack_size = 999
inventory = Array[ExtResource("1_gg8jx")]([SubResource("Resource_jaam2"), SubResource("Resource_4kby3"), SubResource("Resource_byct5"), SubResource("Resource_qycqj"), SubResource("Resource_viap3"), SubResource("Resource_wqat2")])
metadata/_custom_type_script = "uid://becun6dj78v8d"

+ 0
- 1
resources/inventory_resource.gd View File

@ -3,4 +3,3 @@ extends Resource
@export var inventory: Array[DBItemResource] = []
@export var max_stack_size: int = 999

+ 5
- 0
resources/item_resource.gd View File

@ -0,0 +1,5 @@
class_name ItemResource
extends DBItemResource
@export var resource_scene: PackedScene = null

+ 1
- 0
resources/item_resource.gd.uid View File

@ -0,0 +1 @@
uid://m32ytcig5ha5

+ 14
- 0
resources/items/007_torch.tres View File

@ -0,0 +1,14 @@
[gd_resource type="Resource" script_class="ItemResource" load_steps=3 format=3 uid="uid://dqkdgxdjb8sk5"]
[ext_resource type="PackedScene" uid="uid://ccky0w7brcf1l" path="res://scenes/items/torch.tscn" id="1_7h82o"]
[ext_resource type="Script" uid="uid://m32ytcig5ha5" path="res://resources/item_resource.gd" id="2_e6rfx"]
[resource]
script = ExtResource("2_e6rfx")
resource_scene = ExtResource("1_7h82o")
id = "007"
name = "Torch"
amount = 1
description = "A torch to light the way"
item_texture = "uid://dknv7amroftm8"
metadata/_custom_type_script = "uid://m32ytcig5ha5"

+ 1
- 1
resources/world/sky_horizon_color_gradient.tres View File

@ -2,4 +2,4 @@
[resource]
offsets = PackedFloat32Array(0.1, 0.25, 0.4, 0.6, 0.75, 0.9)
colors = PackedColorArray(0.317647, 0.333333, 0.65098, 1, 0.87451, 0.521569, 0.407843, 1, 0.584314, 0.980392, 0.980392, 1, 0.584314, 0.980392, 0.980392, 1, 0.87451, 0.521569, 0.407843, 1, 0.317647, 0.333333, 0.65098, 1)
colors = PackedColorArray(0.317647, 0.333333, 0.65098, 1, 0.87451, 0.521569, 0.407843, 1, 0.243137, 0.584314, 0.85098, 1, 0.243137, 0.584314, 0.85098, 1, 0.87451, 0.521569, 0.407843, 1, 0.317647, 0.333333, 0.65098, 1)

+ 1
- 1
resources/world/sky_top_color_gradient.tres View File

@ -2,4 +2,4 @@
[resource]
offsets = PackedFloat32Array(0.1, 0.4, 0.6, 0.9)
colors = PackedColorArray(0.317647, 0.333333, 0.65098, 1, 0.583728, 0.979416, 0.978736, 1, 0.584314, 0.980392, 0.980392, 1, 0.317647, 0.333333, 0.65098, 1)
colors = PackedColorArray(0.317647, 0.333333, 0.65098, 1, 0.243137, 0.584314, 0.85098, 1, 0.243137, 0.584314, 0.85098, 1, 0.317647, 0.333333, 0.65098, 1)

+ 23
- 0
scenes/items/torch.tscn View File

@ -0,0 +1,23 @@
[gd_scene load_steps=4 format=3 uid="uid://ccky0w7brcf1l"]
[sub_resource type="BoxMesh" id="BoxMesh_ctvck"]
size = Vector3(0.1, 0.1, 0.1)
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_ctvck"]
emission_enabled = true
emission = Color(0.846334, 0.776792, 0.275847, 1)
emission_energy_multiplier = 8.23
[sub_resource type="BoxMesh" id="BoxMesh_vkm4o"]
size = Vector3(0.1, 0.4, 0.1)
[node name="Torch" type="Node3D"]
[node name="Head" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.449571, 0)
mesh = SubResource("BoxMesh_ctvck")
surface_material_override/0 = SubResource("StandardMaterial3D_ctvck")
[node name="Base" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.19988, 0)
mesh = SubResource("BoxMesh_vkm4o")

+ 28
- 8
scenes/player/player.gd View File

@ -37,7 +37,9 @@ func _input(event: InputEvent) -> void:
if event is InputEventMouseMotion:
_handle_mouse_movement(event.relative)
elif event.is_action_pressed("throw_item"): # TODO: Move to state?
EntityManager.drop_block.emit(InventoryManager.quick_slot_item_id, head.global_position, -head.global_basis.z, throw_velocity)
if InventoryManager.get_inventory_item() != null:
EntityManager.drop_block.emit(InventoryManager.get_quick_slot_item_id(), head.global_position, -head.global_basis.z, throw_velocity)
InventoryManager.remove_from_quickslot.emit(1)
func _physics_process(delta: float) -> void:
is_crouching = Input.is_action_pressed("crouch") or ray_cast_crouch.is_colliding()
@ -56,14 +58,16 @@ func _physics_process(delta: float) -> void:
func _ready() -> void:
GameSettingsManager.graphics_fov_changed.connect(_on_graphics_fov_changed)
GameSettingsManager.game_options_held_block_ui_changed.connect(_on_game_options_held_block_ui_changed)
InventoryManager.quick_slot_item_changed.connect(_on_quick_slot_item_changed)
InventoryManager.quick_slot_selected.connect(_on_quick_slot_selected)
InventoryManager.add_to_inventory.connect(_on_add_to_inventory)
InventoryManager.remove_from_inventory.connect(_on_remove_from_inventory)
InventoryManager.item_picked_up.connect(_on_item_picked_up)
InventoryManager.inventory_slot_updated.connect(_on_inventory_slot_updated)
SignalManager.resume_game.connect(_on_resume_game)
SignalManager.open_pause_menu.connect(_on_open_pause_menu)
SignalManager.hide_ui.connect(_on_hide_ui)
SignalManager.show_ui.connect(_on_show_ui)
_update_held_block_mesh(InventoryManager.quick_slot_item_id)
func _apply_gravity(delta: float) -> void:
if is_on_floor(): return
@ -133,10 +137,15 @@ func _set_is_sprinting() -> void:
else:
is_sprinting = Input.is_action_pressed("run")
func _update_held_block_mesh(item_id: String) -> void:
func _update_held_block_mesh() -> void:
var current_item: DBItemResource = InventoryManager.get_inventory_item()
if current_item == null:
block_mesh.visible = false
return
block_mesh.visible = GameSettingsManager.settings.game_options.enable_held_block
if GameSettingsManager.settings.game_options.enable_held_block:
block_mesh.apply_material(DBItems.data[item_id].material_texture)
block_mesh.apply_material(current_item.material_texture)
func _on_game_options_held_block_ui_changed(toggled: bool) -> void:
@ -145,8 +154,8 @@ func _on_game_options_held_block_ui_changed(toggled: bool) -> void:
func _on_graphics_fov_changed(fov: int) -> void:
camera.fov = fov
func _on_quick_slot_item_changed(item_id: String) -> void:
_update_held_block_mesh(item_id)
func _on_quick_slot_selected(_slot_index: int) -> void:
_update_held_block_mesh()
func _on_open_pause_menu() -> void:
block_mesh.visible = false
@ -154,6 +163,17 @@ func _on_open_pause_menu() -> void:
func _on_resume_game() -> void:
block_mesh.visible = GameSettingsManager.settings.game_options.enable_held_block
func _on_add_to_inventory(_item_id: String, _amount: int) -> void:
_update_held_block_mesh()
func _on_inventory_slot_updated(_slot_index: int) -> void:
_update_held_block_mesh()
func _on_item_picked_up(_item: DBItemResource) -> void:
_update_held_block_mesh()
func _on_remove_from_inventory(_item_id: String, _amount: int) -> void:
_update_held_block_mesh()
func _on_hide_ui() -> void:
block_mesh.visible = false


+ 1
- 1
scenes/player/player.tscn View File

@ -35,7 +35,7 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.8, 0)
[node name="Camera3D" type="Camera3D" parent="Head"]
[node name="BlockMesh" parent="Head/Camera3D" instance=ExtResource("2_p47bc")]
transform = Transform3D(1, 0, 0, 0, 0.965926, -0.258819, 0, 0.258819, 0.965926, 0, -0.680035, -1.7196)
transform = Transform3D(1, 0, 0, 0, 0.965926, -0.258819, 0, 0.258819, 0.965926, 1.15474, -0.680035, -1.35803)
[node name="RayCastLook" type="RayCast3D" parent="Head" node_paths=PackedStringArray("player")]
target_position = Vector3(0, 0, -10)


+ 2
- 1
scenes/player/ray_cast_look.gd View File

@ -17,7 +17,8 @@ func _process(_delta: float) -> void:
if !is_valid_placement_target(block_pos):
return
EntityManager.create_block.emit(InventoryManager.quick_slot_item_id, block_pos)
EntityManager.create_block.emit(InventoryManager.get_quick_slot_item_id(), block_pos)
InventoryManager.remove_from_quickslot.emit(1)
if Waila.ref.get_target() == collider:
return


+ 65
- 43
scenes/ui/inventory/inventory.gd View File

@ -2,9 +2,11 @@ class_name Inventory
extends Control
@export var inventory_resource: InventoryResource
@export var item_rect_scene: PackedScene
@export var grid_container: GridContainer
@export var inventory_resource: InventoryResource ## A starting inventory to initialize the inventory with
@export var item_rect_scene: PackedScene ## The scene to use for each individual item stack in the inventory
@export var grid_container: GridContainer ## Container for inventory items
@export var highlight_theme: Resource ## The theme to apply on mouse_enter of the InventoryItemRect
func _input(event: InputEvent) -> void:
@ -12,58 +14,78 @@ func _input(event: InputEvent) -> void:
toggle_inventory()
func _ready() -> void:
InventoryManager.item_picked_up.connect(add_item)
InventoryManager.item_dropped.connect(subtract_item)
for item_resource: DBItemResource in inventory_resource.inventory:
add_item(item_resource)
update_inventory_with_resource()
refresh_inventory_grid()
InventoryManager.item_added.connect(_on_item_added) # Should be added after update_inventory_with_resource()
InventoryManager.item_removed.connect(_on_item_removed) # Should be added after update_inventory_with_resource()
InventoryManager.clear_inventory.connect(_on_clear_inventory)
func add_item(item_resource: DBItemResource, amount: int = 1) -> void:
var item_rect: InventoryItemRect = find_item_rect(item_resource)
if item_rect != null:
if item_rect.item_resource.amount + item_resource.amount >= inventory_resource.max_stack_size:
item_rect.on_stack_full(true)
return
item_rect.item_resource.amount += item_resource.amount
item_rect.update_rect()
else:
item_rect = item_rect_scene.instantiate()
grid_container.add_child(item_rect)
item_rect.item_resource = item_resource
item_rect.update_rect()
func find_item_rect(item_resource: DBItemResource) -> InventoryItemRect:
func create_item_cell(item_resource: DBItemResource) -> void:
var item_rect: InventoryItemRect = item_rect_scene.instantiate()
grid_container.add_child(item_rect)
item_rect.init(item_resource, highlight_theme)
func find_item_cell(item_resource: DBItemResource) -> InventoryItemRect:
var rect: InventoryItemRect = null
for container: InventoryItemRect in grid_container.get_children():
if container.item_resource.id == item_resource.id:
rect = container
for item_rect: InventoryItemRect in grid_container.get_children():
if item_rect.item_resource == null: continue
if item_rect.item_resource.id == item_resource.id:
rect = item_rect
break
return rect
func subtract_item(item_resource: DBItemResource) -> void:
var item_rect: InventoryItemRect = find_item_rect(item_resource)
func refresh_inventory_grid() -> void:
for item: InventoryItemRect in grid_container.get_children():
item.queue_free()
if item_rect != null:
if item_rect.item_resource.amount >= inventory_resource.max_stack_size:
item_rect.on_stack_full(false)
item_rect.item_resource.amount -= item_resource.amount
item_rect.update_rect()
for item: DBItemResource in InventoryManager.inventory:
create_item_cell(item)
if item_rect.item_resource.amount < 1: # Empty stack
item_rect.queue_free()
else:
push_error("Attempting to subtract amount (" + str(item_resource.amount) + " from nonexistent inventory item (" + str(item_resource.name) + ")")
var empty_cells: int = InventoryManager.max_inventory_items - InventoryManager.inventory.size()
for _i: int in range(empty_cells):
create_item_cell(null)
func toggle_inventory() -> void:
visible = not visible
if visible:
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
InventoryManager.inventory_opened.emit()
get_tree().paused = true
_close_inventory()
else:
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
InventoryManager.inventory_closed.emit()
get_tree().paused = false
_open_inventory()
## Add any items from the existing inventory resource
func update_inventory_with_resource() -> void:
if inventory_resource == null:
return
InventoryManager.clear_inventory.emit()
for item_resource: DBItemResource in inventory_resource.inventory:
InventoryManager.add_to_inventory.emit(item_resource.id, item_resource.amount)
func _close_inventory() -> void:
visible = false
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
InventoryManager.inventory_closed.emit()
func _open_inventory() -> void:
refresh_inventory_grid()
visible = true
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
InventoryManager.inventory_opened.emit()
func _on_clear_inventory() -> void:
for item: InventoryItemRect in grid_container.get_children():
item.queue_free()
for _i: int in range(InventoryManager.max_inventory_items):
create_item_cell(null)
func _on_item_added(_item_id: String, _amount: int) -> void:
refresh_inventory_grid()
func _on_item_removed(_item_id: String, _amount: int) -> void:
refresh_inventory_grid()

+ 8
- 5
scenes/ui/inventory/inventory.tscn View File

@ -1,8 +1,9 @@
[gd_scene load_steps=4 format=3 uid="uid://dcr25y1lw4wjp"]
[gd_scene load_steps=5 format=3 uid="uid://dcr25y1lw4wjp"]
[ext_resource type="Script" uid="uid://dybecq130mxhn" path="res://scenes/ui/inventory/inventory.gd" id="1_s6ek7"]
[ext_resource type="Resource" uid="uid://cnpw7y1csu774" path="res://resources/inventory/player_inventory_empty.tres" id="2_avmd0"]
[ext_resource type="Resource" uid="uid://blfp6tiir282o" path="res://resources/inventory/player_inventory_testing.tres" id="2_pefhr"]
[ext_resource type="PackedScene" uid="uid://boueuk2hnfvg" path="res://scenes/ui/inventory/item_rect.tscn" id="3_xeaml"]
[ext_resource type="StyleBox" uid="uid://dlaswvta2mvim" path="res://resources/inventory/quickslot-panel-highlight-stylebox.tres" id="4_8ndef"]
[node name="Inventory" type="Control" node_paths=PackedStringArray("grid_container")]
process_mode = 3
@ -20,9 +21,10 @@ offset_bottom = 200.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_s6ek7")
inventory_resource = ExtResource("2_avmd0")
inventory_resource = ExtResource("2_pefhr")
item_rect_scene = ExtResource("3_xeaml")
grid_container = NodePath("Background/MarginContainer/VBoxContainer/GridContainer")
highlight_theme = ExtResource("4_8ndef")
[node name="Background" type="Panel" parent="."]
layout_mode = 1
@ -54,7 +56,8 @@ text = "Inventory"
[node name="GridContainer" type="GridContainer" parent="Background/MarginContainer/VBoxContainer"]
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 3
theme_override_constants/h_separation = 20
theme_override_constants/v_separation = 20
theme_override_constants/h_separation = 5
theme_override_constants/v_separation = 5
columns = 10

+ 30
- 4
scenes/ui/inventory/item_rect.gd View File

@ -4,16 +4,42 @@ extends Panel
@export var amount_label: Label
@export var item_resource: DBItemResource
@export var item_texture: TextureRect
@export var item_texture: TextureButton
var highlight_theme: Resource
func init(_item_resource: DBItemResource, _highlight_theme: Resource) -> void:
item_texture.mouse_entered.connect(_on_mouse_entered)
item_texture.mouse_exited.connect(_on_mouse_exited)
highlight_theme = _highlight_theme
item_resource = _item_resource
update_rect()
func clear_rect() -> void:
item_texture.texture_normal = null
amount_label.text = ""
item_texture.tooltip_text = ""
func update_rect() -> void:
item_texture.texture = load(item_resource.item_texture)
amount_label.text = "x" + str(item_resource.amount)
tooltip_text = item_resource.name + "\n" + item_resource.description
if not item_resource:
clear_rect()
else:
item_texture.texture_normal = load(item_resource.item_texture)
amount_label.text = "x" + str(item_resource.amount)
item_texture.tooltip_text = item_resource.name + "\n" + item_resource.description
func on_stack_full(is_full: bool) -> void:
if is_full:
amount_label.add_theme_color_override("font_color", Color(1, 0, 0))
else:
amount_label.add_theme_color_override("font_color", Color(1, 1, 1))
func _on_mouse_entered() -> void:
set("theme_override_styles/panel", highlight_theme)
func _on_mouse_exited() -> void:
set("theme_override_styles/panel", null)

+ 18
- 10
scenes/ui/inventory/item_rect.tscn View File

@ -1,6 +1,5 @@
[gd_scene load_steps=4 format=3 uid="uid://boueuk2hnfvg"]
[gd_scene load_steps=3 format=3 uid="uid://boueuk2hnfvg"]
[ext_resource type="Texture2D" uid="uid://dknv7amroftm8" path="res://assets/godot-icon.svg" id="1_o0kom"]
[ext_resource type="Script" uid="uid://cknl6i0jce5jr" path="res://scenes/ui/inventory/item_rect.gd" id="1_oderi"]
[sub_resource type="LabelSettings" id="LabelSettings_oderi"]
@ -8,21 +7,30 @@ outline_size = 3
outline_color = Color(0, 0, 0, 1)
[node name="ItemRect" type="Panel" node_paths=PackedStringArray("amount_label", "item_texture")]
custom_minimum_size = Vector2(64, 64)
custom_minimum_size = Vector2(72, 72)
offset_right = 64.0
offset_bottom = 64.0
script = ExtResource("1_oderi")
amount_label = NodePath("AmountLabel")
item_texture = NodePath("ItemTexture")
item_texture = NodePath("TextureButton")
metadata/_edit_use_anchors_ = true
[node name="ItemTexture" type="TextureRect" parent="."]
[node name="TextureButton" type="TextureButton" parent="."]
texture_filter = 1
layout_mode = 0
offset_right = 64.0
offset_bottom = 64.0
texture = ExtResource("1_o0kom")
expand_mode = 1
custom_minimum_size = Vector2(64, 64)
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -32.0
offset_top = -32.0
offset_right = 32.0
offset_bottom = 32.0
grow_horizontal = 2
grow_vertical = 2
ignore_texture_size = true
stretch_mode = 4
[node name="AmountLabel" type="Label" parent="."]


+ 0
- 157
scenes/ui/quick_slots.tscn View File

@ -1,157 +0,0 @@
[gd_scene load_steps=9 format=3 uid="uid://cbiygbgpfk220"]
[ext_resource type="Script" uid="uid://bcq6vexsmyeol" path="res://scenes/ui/quick_slots.gd" id="1_cqw2g"]
[ext_resource type="Texture2D" uid="uid://li36txj7oweq" path="res://assets/textures/dirt.png" id="2_kotkb"]
[ext_resource type="StyleBox" uid="uid://dlaswvta2mvim" path="res://resources/inventory/quickslot-panel-highlight-stylebox.tres" id="2_ps55n"]
[ext_resource type="Texture2D" uid="uid://ct1iawpfkdf5l" path="res://assets/textures/stone.png" id="3_cqw2g"]
[ext_resource type="Texture2D" uid="uid://bgo4mb3atmbot" path="res://assets/textures/grass.png" id="3_yyyxx"]
[ext_resource type="Texture2D" uid="uid://0mw651622h01" path="res://assets/textures/wood.png" id="4_yyyxx"]
[ext_resource type="Texture2D" uid="uid://goygbpyqhych" path="res://assets/textures/leaves.png" id="5_ps55n"]
[ext_resource type="Texture2D" uid="uid://cpllegyqnfnrh" path="res://assets/textures/glass.png" id="8_bup65"]
[node name="QuickSlots" type="MarginContainer"]
anchors_preset = 4
anchor_top = 0.5
anchor_bottom = 0.5
offset_top = -220.0
offset_right = 80.0
offset_bottom = 220.0
grow_vertical = 2
size_flags_horizontal = 0
theme_override_constants/margin_left = 8
theme_override_constants/margin_top = 8
theme_override_constants/margin_right = 8
theme_override_constants/margin_bottom = 8
script = ExtResource("1_cqw2g")
highlight_theme = ExtResource("2_ps55n")
[node name="GridContainer" type="GridContainer" parent="."]
layout_mode = 2
theme_override_constants/h_separation = 8
theme_override_constants/v_separation = 8
[node name="Slot0" type="Panel" parent="GridContainer"]
custom_minimum_size = Vector2(64, 64)
layout_mode = 2
[node name="MarginContainer" type="MarginContainer" parent="GridContainer/Slot0"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/margin_left = 4
theme_override_constants/margin_top = 4
theme_override_constants/margin_right = 4
theme_override_constants/margin_bottom = 4
[node name="TextureRect" type="TextureRect" parent="GridContainer/Slot0/MarginContainer"]
texture_filter = 1
layout_mode = 2
texture = ExtResource("2_kotkb")
[node name="Slot1" type="Panel" parent="GridContainer"]
custom_minimum_size = Vector2(64, 64)
layout_mode = 2
[node name="MarginContainer" type="MarginContainer" parent="GridContainer/Slot1"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/margin_left = 4
theme_override_constants/margin_top = 4
theme_override_constants/margin_right = 4
theme_override_constants/margin_bottom = 4
[node name="TextureRect" type="TextureRect" parent="GridContainer/Slot1/MarginContainer"]
texture_filter = 1
layout_mode = 2
texture = ExtResource("3_yyyxx")
[node name="Slot3" type="Panel" parent="GridContainer"]
custom_minimum_size = Vector2(64, 64)
layout_mode = 2
[node name="MarginContainer" type="MarginContainer" parent="GridContainer/Slot3"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/margin_left = 4
theme_override_constants/margin_top = 4
theme_override_constants/margin_right = 4
theme_override_constants/margin_bottom = 4
[node name="TextureRect" type="TextureRect" parent="GridContainer/Slot3/MarginContainer"]
texture_filter = 1
layout_mode = 2
texture = ExtResource("3_cqw2g")
[node name="Slot4" type="Panel" parent="GridContainer"]
custom_minimum_size = Vector2(64, 64)
layout_mode = 2
[node name="MarginContainer" type="MarginContainer" parent="GridContainer/Slot4"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/margin_left = 4
theme_override_constants/margin_top = 4
theme_override_constants/margin_right = 4
theme_override_constants/margin_bottom = 4
[node name="TextureRect" type="TextureRect" parent="GridContainer/Slot4/MarginContainer"]
texture_filter = 1
layout_mode = 2
texture = ExtResource("4_yyyxx")
[node name="Slot5" type="Panel" parent="GridContainer"]
custom_minimum_size = Vector2(64, 64)
layout_mode = 2
[node name="MarginContainer" type="MarginContainer" parent="GridContainer/Slot5"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/margin_left = 4
theme_override_constants/margin_top = 4
theme_override_constants/margin_right = 4
theme_override_constants/margin_bottom = 4
[node name="TextureRect" type="TextureRect" parent="GridContainer/Slot5/MarginContainer"]
texture_filter = 1
layout_mode = 2
texture = ExtResource("5_ps55n")
[node name="Slot6" type="Panel" parent="GridContainer"]
custom_minimum_size = Vector2(64, 64)
layout_mode = 2
[node name="MarginContainer" type="MarginContainer" parent="GridContainer/Slot6"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/margin_left = 4
theme_override_constants/margin_top = 4
theme_override_constants/margin_right = 4
theme_override_constants/margin_bottom = 4
[node name="TextureRect" type="TextureRect" parent="GridContainer/Slot6/MarginContainer"]
texture_filter = 1
layout_mode = 2
texture = ExtResource("8_bup65")

scenes/ui/quick_slots.gd → scenes/ui/quickslots/quick_slots.gd View File

@ -3,28 +3,33 @@ extends Node
@export var highlight_theme: Resource
@export var slots_container: GridContainer
@export var quickslots_slot: PackedScene
@onready var slots_container: GridContainer = $GridContainer
var _items: Array[String] = ["001", "005", "002", "003", "004", "006"]
var _previous_selected_item: int = 0
var _selected_item: int = 0 :
set(new_item_index):
if new_item_index < 0:
new_item_index = _items.size() - 1
elif new_item_index >= _items.size():
new_item_index = InventoryManager.quick_slot_count - 1
elif new_item_index >= InventoryManager.quick_slot_count:
new_item_index = 0
_previous_selected_item = _selected_item
_selected_item = new_item_index
func _init() -> void:
InventoryManager.next_quick_slot.connect(select_next_item)
InventoryManager.previous_quick_slot.connect(select_previous_item)
InventoryManager.select_quick_slot.connect(select_quick_slot)
func _ready() -> void:
var current_slot: Panel = slots_container.get_child(_selected_item)
current_slot.set("theme_override_styles/panel", highlight_theme)
remove_slots()
generate_quick_slots()
# This doesn't quite work on ready as, for some reason, it will select
# Slot0 (one of the slots BEFORE remove_slots()) instead of the first slot
# create in generate_quick_slots()
select_quick_slot(0)
func _unhandled_input(event: InputEvent) -> void:
if event.is_action_pressed("quickslot1"):
@ -53,26 +58,35 @@ func _unhandled_input(event: InputEvent) -> void:
select_previous_item()
func get_quickslot_index() -> int:
return _selected_item
func clear_slots() -> void:
for slot: QuickSlotsSlot in slots_container.get_children():
slot.clear()
func get_selected_item() -> String:
return _items[_selected_item]
func generate_quick_slots() -> void:
for slot_index: int in range(InventoryManager.quick_slot_count):
var slot: QuickSlotsSlot = quickslots_slot.instantiate()
slots_container.add_child(slot)
slot.init(slot_index)
func select_quick_slot(slot_index: int) -> void:
_selected_item = slot_index
update_highlighted_slot()
InventoryManager.quick_slot_item_changed.emit(get_selected_item())
func remove_slots() -> void:
for slot: QuickSlotsSlot in slots_container.get_children():
slot.queue_free()
func select_previous_item() -> void:
func select_next_item() -> void:
select_quick_slot(_selected_item + 1)
func select_next_item() -> void:
func select_previous_item() -> void:
select_quick_slot(_selected_item - 1)
func select_quick_slot(slot_index: int) -> void:
_selected_item = slot_index
InventoryManager.quick_slot_selected.emit(_selected_item)
update_highlighted_slot()
func update_highlighted_slot() -> void:
var previous_slot: Panel = slots_container.get_child(_previous_selected_item)
var current_slot: Panel = slots_container.get_child(_selected_item)
if _previous_selected_item != _selected_item:
var previous_slot: Panel = slots_container.get_child(_previous_selected_item)
previous_slot.set("theme_override_styles/panel", null)
previous_slot.set("theme_override_styles/panel", null)
var current_slot: Panel = slots_container.get_child(_selected_item)
current_slot.set("theme_override_styles/panel", highlight_theme)

scenes/ui/quick_slots.gd.uid → scenes/ui/quickslots/quick_slots.gd.uid View File


+ 63
- 0
scenes/ui/quickslots/quick_slots.tscn View File

@ -0,0 +1,63 @@
[gd_scene load_steps=4 format=3 uid="uid://cbiygbgpfk220"]
[ext_resource type="Script" uid="uid://bcq6vexsmyeol" path="res://scenes/ui/quickslots/quick_slots.gd" id="1_cqw2g"]
[ext_resource type="StyleBox" uid="uid://dlaswvta2mvim" path="res://resources/inventory/quickslot-panel-highlight-stylebox.tres" id="2_ps55n"]
[ext_resource type="PackedScene" uid="uid://c40k8ey6e54v1" path="res://scenes/ui/quickslots/quickslots_slot.tscn" id="3_bup65"]
[node name="QuickSlots" type="MarginContainer" node_paths=PackedStringArray("slots_container")]
anchors_preset = 7
anchor_left = 0.5
anchor_top = 1.0
anchor_right = 0.5
anchor_bottom = 1.0
offset_left = -364.0
offset_top = -80.0
offset_right = 364.0
grow_horizontal = 2
grow_vertical = 0
theme_override_constants/margin_left = 8
theme_override_constants/margin_top = 8
theme_override_constants/margin_right = 8
theme_override_constants/margin_bottom = 8
script = ExtResource("1_cqw2g")
highlight_theme = ExtResource("2_ps55n")
slots_container = NodePath("SlotsContainer")
quickslots_slot = ExtResource("3_bup65")
[node name="SlotsContainer" type="GridContainer" parent="."]
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 4
theme_override_constants/h_separation = 8
theme_override_constants/v_separation = 8
columns = 10
[node name="Slot0" parent="SlotsContainer" instance=ExtResource("3_bup65")]
layout_mode = 2
[node name="Slot1" parent="SlotsContainer" instance=ExtResource("3_bup65")]
layout_mode = 2
[node name="Slot2" parent="SlotsContainer" instance=ExtResource("3_bup65")]
layout_mode = 2
[node name="Slot3" parent="SlotsContainer" instance=ExtResource("3_bup65")]
layout_mode = 2
[node name="Slot4" parent="SlotsContainer" instance=ExtResource("3_bup65")]
layout_mode = 2
[node name="Slot5" parent="SlotsContainer" instance=ExtResource("3_bup65")]
layout_mode = 2
[node name="Slot6" parent="SlotsContainer" instance=ExtResource("3_bup65")]
layout_mode = 2
[node name="Slot7" parent="SlotsContainer" instance=ExtResource("3_bup65")]
layout_mode = 2
[node name="Slot8" parent="SlotsContainer" instance=ExtResource("3_bup65")]
layout_mode = 2
[node name="Slot9" parent="SlotsContainer" instance=ExtResource("3_bup65")]
layout_mode = 2

+ 40
- 0
scenes/ui/quickslots/quickslots_slot.gd View File

@ -0,0 +1,40 @@
class_name QuickSlotsSlot
extends Panel
@export var amount_label: Label
@export var slot_texture: TextureRect
var slot_index: int = 0
func _ready() -> void:
InventoryManager.inventory_slot_updated.connect(_on_inventory_slot_updated)
func init(_slot_index: int) -> void:
slot_index = _slot_index
refresh()
func clear() -> void:
slot_texture.texture = null
amount_label.text = ""
slot_texture.tooltip_text = ""
func refresh() -> void:
if InventoryManager.inventory.size() < 1:
return clear()
elif not InventoryManager.inventory.get(slot_index):
return clear()
elif InventoryManager.inventory[slot_index] == null:
return clear()
slot_texture.texture = load(InventoryManager.inventory[slot_index].item_texture)
amount_label.text = "x" + str(InventoryManager.inventory[slot_index].amount)
slot_texture.tooltip_text = InventoryManager.inventory[slot_index].name + "\n" + InventoryManager.inventory[slot_index].description
func _on_inventory_slot_updated(_slot_index: int) -> void:
if _slot_index != slot_index: return
refresh()

+ 1
- 0
scenes/ui/quickslots/quickslots_slot.gd.uid View File

@ -0,0 +1 @@
uid://cq3yb4beq5f4s

+ 36
- 0
scenes/ui/quickslots/quickslots_slot.tscn View File

@ -0,0 +1,36 @@
[gd_scene load_steps=3 format=3 uid="uid://c40k8ey6e54v1"]
[ext_resource type="Script" uid="uid://cq3yb4beq5f4s" path="res://scenes/ui/quickslots/quickslots_slot.gd" id="1_l6jhe"]
[sub_resource type="LabelSettings" id="LabelSettings_7oxdy"]
outline_size = 3
outline_color = Color(0, 0, 0, 1)
[node name="Slot" type="Panel" node_paths=PackedStringArray("amount_label", "slot_texture")]
custom_minimum_size = Vector2(64, 64)
script = ExtResource("1_l6jhe")
amount_label = NodePath("MarginContainer/AmountLabel")
slot_texture = NodePath("MarginContainer/TextureRect")
[node name="MarginContainer" type="MarginContainer" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/margin_left = 4
theme_override_constants/margin_top = 4
theme_override_constants/margin_right = 4
theme_override_constants/margin_bottom = 4
[node name="TextureRect" type="TextureRect" parent="MarginContainer"]
texture_filter = 1
layout_mode = 2
expand_mode = 2
[node name="AmountLabel" type="Label" parent="MarginContainer"]
layout_mode = 2
size_flags_horizontal = 8
size_flags_vertical = 8
label_settings = SubResource("LabelSettings_7oxdy")

+ 6
- 2
scenes/ui/ui.tscn View File

@ -1,9 +1,10 @@
[gd_scene load_steps=6 format=3 uid="uid://c7fj7wla8bd70"]
[gd_scene load_steps=7 format=3 uid="uid://c7fj7wla8bd70"]
[ext_resource type="Script" uid="uid://bslimr2y4lnvq" path="res://scenes/ui/ui.gd" id="1_aac20"]
[ext_resource type="PackedScene" uid="uid://dvogu3djluqsn" path="res://scenes/ui/waila.tscn" id="1_u7n8c"]
[ext_resource type="PackedScene" uid="uid://cbiygbgpfk220" path="res://scenes/ui/quick_slots.tscn" id="4_g5kmx"]
[ext_resource type="PackedScene" uid="uid://cbiygbgpfk220" path="res://scenes/ui/quickslots/quick_slots.tscn" id="4_g5kmx"]
[ext_resource type="PackedScene" uid="uid://by0gd600mbcr5" path="res://scenes/ui/pause_menu/pause_menu.tscn" id="5_0dwhk"]
[ext_resource type="PackedScene" uid="uid://dcr25y1lw4wjp" path="res://scenes/ui/inventory/inventory.tscn" id="6_pfayw"]
[ext_resource type="PackedScene" uid="uid://rfknvv8b0d4i" path="res://scenes/ui/autosave_notification.tscn" id="7_jcn1r"]
[node name="UI" type="CanvasLayer"]
@ -35,3 +36,6 @@ visible = false
[node name="PauseMenu" parent="." instance=ExtResource("5_0dwhk")]
visible = false
[node name="Inventory" parent="." instance=ExtResource("6_pfayw")]
visible = false

+ 1
- 0
scenes/world/world.tscn View File

@ -13,6 +13,7 @@ player_scene = ExtResource("2_sl2e5")
spawn_position = NodePath("SpawnPosition")
[node name="DayNightCycleComponent" parent="." instance=ExtResource("3_6m72w")]
start_time = 0.4
[node name="BlocksContainer" type="Node3D" parent="."]


Loading…
Cancel
Save