39 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
  Ryan Reed 89d9f46fc2 Bumping to version 0.1.1 4 weeks ago
  Ryan Reed 37849199ce Merge pull request 'Replacing Fullscreen with Window Mode' (#23) from window-mode into master 4 weeks ago
  Ryan Reed 23b303822f Replacing Fullscreen with Window Mode 4 weeks ago
  Ryan Reed eef494d646 Add LifetimeTimer to DroppedBlocks 4 weeks ago
  Ryan Reed d3c013f35c Updating is_valid_placement_target() logic 4 weeks ago
  Ryan Reed 5495d8892e Tweak is_valid_placement() 1 month ago
  Ryan Reed 25e06c7bf1 Minor cleanup 1 month ago
  Ryan Reed 5d8540003e Merge pull request 'Fix: Placing block where player is occupying' (#22) from fix-player-block-placement into master 1 month ago
  Ryan Reed 0bd79ee992 Disallow placing blocks where player is located 1 month ago
  Ryan Reed d3a651816a Updating wood texture to reduce tiling seams 1 month ago
  Ryan Reed 1688e445c5 Moving PREFABs out of Globals and removing Globals autoload 1 month ago
  Ryan Reed 13a90dfe13 Removing old variables 1 month ago
  Ryan Reed 795707db8b Updating version 1 month ago
  Ryan Reed 5c93f41598 Merge pull request 'Pause Menu Redesign' (#21) from pause-menu-redesign into master 1 month ago
  Ryan Reed 1015d89c0b Set visible on menus 1 month ago
  Ryan Reed c0d04507f2 Updating offsets 1 month ago
  Ryan Reed 13ffe080cf Correcting save menu open and hidden after creating a new save 1 month ago
  Ryan Reed 1cb2d08b7d Removing old SaveLoadUI scene and references to ui_node 1 month ago
  Ryan Reed e40c044ad3 Migrating menus into Inherited scenes 1 month ago
  Ryan Reed 5874f7730d Updating default animation 1 month ago
  Ryan Reed 65068a82e4 Updating save menu theme and node names 1 month ago
  Ryan Reed ad0c781dee Moving to a common theme for all menus 1 month ago
  Ryan Reed 67a34d6611 Comments and formatting 1 month ago
  Ryan Reed db15ad68ef Minor offset change 1 month ago
  Ryan Reed 2aba84aa0f Fix hiding UI when saving game and backing out to MainMenu from submenus 1 month ago
  Ryan Reed 8fe40d0c8b Fix hiding UI when saving game for screenshot 1 month ago
  Ryan Reed 82c199be69 Moving MainMenu, SettingsMenu, and SavesMenu into separate scenes 1 month ago
  Ryan Reed 4f91aa12ea Setting default values 1 month ago
  Ryan Reed 069a95fc8b Fixing autosaves setting and saving 1 month ago
  Ryan Reed d9bdcc87c3 Removing old menu scenes and renaming new menu 1 month ago
  Ryan Reed a00fe83a03 Initial work on the redesign 1 month ago
  Ryan Reed c22f21fb9c Replacing various error signals with a single error signal 1 month ago
  Ryan Reed bbb3411065 Adding setting for enabling/disabling autosaves 1 month ago
73 changed files with 1501 additions and 919 deletions
Split View
  1. +22
    -8
      addons/save_load_system/autoloads/save_game_manager.gd
  2. BIN
      assets/textures/wood-block.png
  3. BIN
      assets/textures/wood.png
  4. +1
    -0
      autoloads/db_items.gd
  5. +13
    -10
      autoloads/game_settings_manager.gd
  6. +0
    -9
      autoloads/globals.gd
  7. +0
    -1
      autoloads/globals.gd.uid
  8. +186
    -9
      autoloads/inventory_manager.gd
  9. +3
    -1
      autoloads/signal_manager.gd
  10. +1
    -2
      project.godot
  11. +3
    -1
      resources/blocks/005_grass.tres
  12. +3
    -1
      resources/db_item_resource.gd
  13. +1
    -0
      resources/game_settings/game_options_settings_resource.gd
  14. +4
    -0
      resources/game_settings/game_options_settings_resource.tres
  15. +3
    -2
      resources/game_settings/graphics_settings_resource.gd
  16. +40
    -7
      resources/inventory/player_inventory_testing.tres
  17. +0
    -1
      resources/inventory_resource.gd
  18. +5
    -0
      resources/item_resource.gd
  19. +1
    -0
      resources/item_resource.gd.uid
  20. +14
    -0
      resources/items/007_torch.tres
  21. +2
    -0
      resources/pause_menu_theme.tres
  22. +1
    -1
      resources/world/sky_horizon_color_gradient.tres
  23. +1
    -1
      resources/world/sky_top_color_gradient.tres
  24. +1
    -0
      scenes/blocks/block.gd
  25. +11
    -0
      scenes/blocks/dropped_block.gd
  26. +6
    -1
      scenes/blocks/dropped_block.tscn
  27. +23
    -0
      scenes/items/torch.tscn
  28. +40
    -10
      scenes/player/player.gd
  29. +3
    -2
      scenes/player/player.tscn
  30. +28
    -4
      scenes/player/ray_cast_look.gd
  31. +65
    -43
      scenes/ui/inventory/inventory.gd
  32. +8
    -5
      scenes/ui/inventory/inventory.tscn
  33. +30
    -4
      scenes/ui/inventory/item_rect.gd
  34. +18
    -10
      scenes/ui/inventory/item_rect.tscn
  35. +0
    -32
      scenes/ui/menus/pause_menu.gd
  36. +0
    -1
      scenes/ui/menus/pause_menu.gd.uid
  37. +0
    -75
      scenes/ui/menus/pause_menu.tscn
  38. +0
    -1
      scenes/ui/menus/saves_manager/save_load_ui.gd.uid
  39. +0
    -133
      scenes/ui/menus/saves_manager/save_load_ui.tscn
  40. +0
    -1
      scenes/ui/menus/settings_menu.gd.uid
  41. +0
    -266
      scenes/ui/menus/settings_menu.tscn
  42. +33
    -0
      scenes/ui/pause_menu/base_menu.gd
  43. +1
    -0
      scenes/ui/pause_menu/base_menu.gd.uid
  44. +152
    -0
      scenes/ui/pause_menu/base_menu.tscn
  45. +16
    -0
      scenes/ui/pause_menu/main_menu.gd
  46. +1
    -0
      scenes/ui/pause_menu/main_menu.gd.uid
  47. +36
    -0
      scenes/ui/pause_menu/main_menu.tscn
  48. +87
    -0
      scenes/ui/pause_menu/pause_menu.gd
  49. +1
    -0
      scenes/ui/pause_menu/pause_menu.gd.uid
  50. +37
    -0
      scenes/ui/pause_menu/pause_menu.tscn
  51. +0
    -0
      scenes/ui/pause_menu/saves_manager/save_file.gd
  52. +0
    -0
      scenes/ui/pause_menu/saves_manager/save_file.gd.uid
  53. +1
    -1
      scenes/ui/pause_menu/saves_manager/save_file.tscn
  54. +1
    -8
      scenes/ui/pause_menu/saves_manager/save_files_list.gd
  55. +0
    -0
      scenes/ui/pause_menu/saves_manager/save_files_list.gd.uid
  56. +2
    -2
      scenes/ui/pause_menu/saves_manager/save_files_list.tscn
  57. +18
    -14
      scenes/ui/pause_menu/saves_menu.gd
  58. +1
    -0
      scenes/ui/pause_menu/saves_menu.gd.uid
  59. +97
    -0
      scenes/ui/pause_menu/saves_menu.tscn
  60. +26
    -11
      scenes/ui/pause_menu/settings_menu.gd
  61. +1
    -0
      scenes/ui/pause_menu/settings_menu.gd.uid
  62. +240
    -0
      scenes/ui/pause_menu/settings_menu.tscn
  63. +0
    -157
      scenes/ui/quick_slots.tscn
  64. +34
    -20
      scenes/ui/quickslots/quick_slots.gd
  65. +0
    -0
      scenes/ui/quickslots/quick_slots.gd.uid
  66. +63
    -0
      scenes/ui/quickslots/quick_slots.tscn
  67. +40
    -0
      scenes/ui/quickslots/quickslots_slot.gd
  68. +1
    -0
      scenes/ui/quickslots/quickslots_slot.gd.uid
  69. +36
    -0
      scenes/ui/quickslots/quickslots_slot.tscn
  70. +29
    -49
      scenes/ui/ui.gd
  71. +7
    -13
      scenes/ui/ui.tscn
  72. +2
    -2
      scenes/world/world.gd
  73. +1
    -0
      scenes/world/world.tscn

+ 22
- 8
addons/save_load_system/autoloads/save_game_manager.gd View File

@ -14,12 +14,12 @@ signal autosave_start ## Autosave has started
signal create_autosave
signal create_save(save_name: String)
signal delete_save(filename: String)
signal delete_error(error_message: String)
signal disable_autosaves
signal enable_autosaves
signal error(error_message: String)
signal load_complete
signal load_error(error_message: String)
signal load_save(filename: String) ## Loads the save into memory. Does NOT apply the load as this allows for other actions (such as resetting the levle/world).[br]Don't forget to run `apply_save` after loading
signal save_complete
signal save_error(error_message: String)
signal start_autosave
signal stop_autosave
@ -28,6 +28,7 @@ signal quick_load
signal toggle_save_icon_generation(toggled: bool) ## Enable/Disable the generation of a screenshot during save for the save icon.
var _autosaves_enabled: bool = true
var _autosave_timer: Timer = Timer.new()
var _enable_save_icon_generation: bool = true
var _loaded_save_resource: SaveGameDataResource = SaveGameDataResource.new()
@ -39,6 +40,8 @@ func _ready() -> void:
apply_save.connect(_on_apply_save)
create_save.connect(_on_save_game_as_resource)
delete_save.connect(_on_delete_save)
disable_autosaves.connect(_on_disable_autosaves)
enable_autosaves.connect(_on_enable_autosaves)
load_save.connect(_on_load_game_save)
quick_load.connect(_on_quick_load)
quick_save.connect(_on_quick_save)
@ -157,12 +160,12 @@ func _load_game_resource(resource_filename: String) -> void:
var save_game_file_path: String = _save_game_settings.save_game_data_path + resource_filename
if !FileAccess.file_exists(save_game_file_path):
load_error.emit("Failed to load save. File does not exist: %s" % save_game_file_path)
error.emit("Failed to load save. File does not exist: %s" % save_game_file_path)
return
_loaded_save_resource = ResourceLoader.load(save_game_file_path)
if _loaded_save_resource == null:
load_error.emit("Failed to load save. Unknown format? %s" % save_game_file_path)
error.emit("Failed to load save. Unknown format? %s" % save_game_file_path)
return
load_complete.emit()
@ -171,7 +174,7 @@ func _load_game_resource(resource_filename: String) -> void:
func _load_save_settings() -> bool:
var _save_level_data_component: SaveLevelDataComponent = get_tree().get_first_node_in_group("save_level_data_component")
if _save_level_data_component == null:
push_error("Could not find SaveLevelDataComponent node in level")
error.emit("Failed to Save Settings. Could not find SaveLevelDataComponent node in tree")
return false
_save_game_settings = _save_level_data_component.settings
@ -183,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():
@ -218,7 +222,7 @@ func _save_game_as_resource(save_name, resource_filename: String) -> void:
var result: int = ResourceSaver.save(_save_resource, save_game_file_path)
if result != OK:
save_error.emit("Failed to save game (" , result, "): " + save_game_file_path)
error.emit("Failed to save game (" , result, "): " + save_game_file_path)
return
_take_save_screenshot(save_game_file_path)
@ -250,18 +254,26 @@ func _on_apply_save() -> void:
apply_complete.emit()
func _on_autosave_timer_timeout() -> void:
if not _autosaves_enabled: return
_create_autosave()
## Delete both the save file and the related screenshot
func _on_delete_save(filename: String) -> void:
if filename.length() < 1:
delete_error.emit("Empty filename provided")
error.emit("Failed to delete save. Empty filename provided.")
return
var save_file_path: String = _save_game_settings.save_game_data_path + filename
DirAccess.remove_absolute(save_file_path)
DirAccess.remove_absolute(save_file_path.replace(".tres", ".png")) # Delete icon
func _on_disable_autosaves() -> void:
_autosaves_enabled = false
stop_autosave.emit()
func _on_enable_autosaves() -> void:
_autosaves_enabled = true
func _on_load_game_save(resource_filename: String) -> void:
_load_game_resource(resource_filename)
@ -286,6 +298,8 @@ func _on_save_game_as_resource(save_name: String) -> void:
save_complete.emit()
func _on_start_autosave() -> void:
if not _autosaves_enabled: return
if _save_game_settings == null:
_load_save_settings()
_autosave_timer.start(_save_game_settings.autosave_duration)


BIN
assets/textures/wood-block.png View File

Before After
Width: 48  |  Height: 32  |  Size: 685 B Width: 48  |  Height: 32  |  Size: 679 B

BIN
assets/textures/wood.png View File

Before After
Width: 16  |  Height: 16  |  Size: 700 B Width: 16  |  Height: 16  |  Size: 238 B

+ 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"),
}

+ 13
- 10
autoloads/game_settings_manager.gd View File

@ -2,6 +2,7 @@ extends Node
#region Game Options Signals
signal game_options_autosaves_changed(autosaves_enabled: bool)
signal game_options_block_highlight_changed(block_highlight_enabled: bool)
signal game_options_held_block_ui_changed(held_block_enabled: bool)
signal game_options_quickslots_ui_changed(quickslots_enabled: bool)
@ -11,10 +12,10 @@ signal game_options_waila_changed(waila_enabled: bool)
#region Graphics Settings Signals
signal apply_graphics_settings
signal graphics_fov_changed(fov: int)
signal graphics_resolution_changed(resolution: Vector2i, id: int)
signal graphics_fullscreen_changed(fullscreen_enabled: bool)
signal graphics_vsync_changed(vsync_enabled: bool)
signal graphics_fov_changed(fov: int)
signal graphics_window_mode_changed(mode_id: int)
#endregion
signal load_game_settings
@ -34,6 +35,7 @@ var settings: GameSettingsResource = GameSettingsResource.new()
func _init() -> void:
game_options_autosaves_changed.connect(_on_game_options_autosaves_changed)
game_options_block_highlight_changed.connect(_on_game_options_block_highlight_changed)
game_options_held_block_ui_changed.connect(_on_game_options_held_block_ui_changed)
game_options_quickslots_ui_changed.connect(_on_game_options_quickslots_ui_changed)
@ -41,8 +43,8 @@ func _init() -> void:
game_options_waila_changed.connect(_on_game_options_waila_changed)
graphics_fov_changed.connect(_on_graphics_fov_changed)
graphics_fullscreen_changed.connect(_on_graphics_fullscreen_changed)
graphics_resolution_changed.connect(_on_graphics_resolution_changed)
graphics_window_mode_changed.connect(_on_graphics_window_mode_changed)
graphics_vsync_changed.connect(_on_graphics_vsync_changed)
apply_graphics_settings.connect(_on_apply_graphics_settings)
@ -51,6 +53,10 @@ func _init() -> void:
#region Game Option Settings
func _on_game_options_autosaves_changed(autosaves_enabled: bool) -> void:
settings.game_options.enable_autosaves = autosaves_enabled
save_settings()
func _on_game_options_block_highlight_changed(highlight_enabled: bool) -> void:
settings.game_options.enable_block_highlight = highlight_enabled
save_settings()
@ -74,10 +80,7 @@ func _on_game_options_waila_changed(waila_enabled: bool) -> void:
#region Graphics Settings
func _on_apply_graphics_settings() -> void:
if settings.graphics.fullscreen:
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
else:
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)
DisplayServer.window_set_mode(settings.graphics.window_mode)
get_window().size = settings.graphics.resolution
@ -91,15 +94,15 @@ func _on_apply_graphics_settings() -> void:
func _on_graphics_fov_changed(fov: int) -> void:
settings.graphics.fov = fov
func _on_graphics_fullscreen_changed(fullscreen_enabled: bool) -> void:
settings.graphics.fullscreen = fullscreen_enabled
func _on_graphics_resolution_changed(resolution: Vector2i, id: int) -> void:
settings.graphics.resolution = resolution
settings.graphics.resolution_id = id
func _on_graphics_vsync_changed(vsync_enabled: bool) -> void:
settings.graphics.vsync = vsync_enabled
func _on_graphics_window_mode_changed(id: int) -> void:
settings.graphics.window_mode = id as DisplayServer.WindowMode
#endregion


+ 0
- 9
autoloads/globals.gd View File

@ -1,9 +0,0 @@
extends Node
const BLOCK_PREFAB: PackedScene = preload("res://scenes/blocks/block.tscn")
const DROPPED_BLOCK_PREFAB: PackedScene = preload("res://scenes/blocks/dropped_block.tscn")
# TODO: Move the following into the GameSettingsManager
var enable_waila: bool = true ## Enable `What Am I Looking At` UI
var enable_block_highlight: bool = true

+ 0
- 1
autoloads/globals.gd.uid View File

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

+ 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)

+ 3
- 1
autoloads/signal_manager.gd View File

@ -2,8 +2,10 @@
extends Node
#signal pause_game
signal pause_game
signal resume_game
signal hide_ui
signal show_ui
signal open_pause_menu
signal close_pause_menu


+ 1
- 2
project.godot View File

@ -11,14 +11,13 @@ config_version=5
[application]
config/name="Skyblock"
config/version="0.0.1"
config/version="0.2.0"
run/main_scene="uid://cgx0nawwjjj7g"
config/features=PackedStringArray("4.4", "Forward Plus")
config/icon="uid://f6hee5t26uqt"
[autoload]
Globals="*res://autoloads/globals.gd"
EntityManager="*res://autoloads/entity_manager.gd"
InventoryManager="*res://autoloads/inventory_manager.gd"
DBItems="*res://autoloads/db_items.gd"


+ 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"

+ 1
- 0
resources/game_settings/game_options_settings_resource.gd View File

@ -7,3 +7,4 @@ extends Resource
@export var enable_quickslots_ui: bool = true
@export var enable_held_block: bool = true
@export var enable_save_screenshots: bool = true ## Take a screenshot during save to use as the save icon
@export var enable_autosaves: bool = true

+ 4
- 0
resources/game_settings/game_options_settings_resource.tres View File

@ -6,4 +6,8 @@
script = ExtResource("1_wnf6r")
enable_waila = true
enable_block_highlight = true
enable_quickslots_ui = true
enable_held_block = true
enable_save_screenshots = true
enable_autosaves = true
metadata/_custom_type_script = "uid://7yv740somgqf"

+ 3
- 2
resources/game_settings/graphics_settings_resource.gd View File

@ -3,8 +3,9 @@
class_name GraphicsSettingsResource
extends Resource
@export var fov: int = 75
@export var resolution: Vector2i = Vector2i(1280, 720) ## Width, Height
@export var resolution_id: int = 0 ## The ID of the item in the OptionsButton list element
@export var fullscreen: bool = false
@export var vsync: bool = false
@export var fov: int = 75
@export var window_mode: DisplayServer.WindowMode = DisplayServer.WINDOW_MODE_WINDOWED

+ 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"

+ 2
- 0
resources/pause_menu_theme.tres View File

@ -4,3 +4,5 @@
Button/colors/font_color = Color(0.839216, 0.933333, 1, 1)
Button/constants/outline_size = 2
Button/font_sizes/font_size = 20
MenuTitle/base_type = &"Label"
MenuTitle/font_sizes/font_size = 40

+ 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)

+ 1
- 0
scenes/blocks/block.gd View File

@ -1,6 +1,7 @@
class_name Block
extends StaticBody3D
const PREFAB: PackedScene = preload("res://scenes/blocks/block.tscn")
@export var block_mesh: BlockMesh
@export var collision_shape: CollisionShape3D


+ 11
- 0
scenes/blocks/dropped_block.gd View File

@ -2,11 +2,15 @@ class_name DroppedBlock
extends RigidBody3D
const PREFAB: PackedScene = preload("res://scenes/blocks/dropped_block.tscn")
## The amount of time to wait before PickupArea is set to monitorable[br]
## This is to ensure that the item isn't picked up immediately after throwing
@export var pickup_timeout: int = 1
@export var lifetime_in_seconds: int = 10 ## Lifetime before despawning
@export var animation_player: AnimationPlayer
@export var block_mesh: BlockMesh
@export var lifetime_timer: Timer
@export var pickup_area: Area3D
var id: String
@ -14,6 +18,8 @@ var impulse: Vector3 = Vector3.ZERO
func _ready() -> void:
lifetime_timer.timeout.connect(_on_lifetime_timeout)
## AnimationPlayer handles modifying BlockMesh scale, position, and rotation
## The scale is NOT applied to any other node, including RigidBody and CollisionShape
animation_player.play("start_animation")
@ -38,6 +44,8 @@ func initialize(block_id: String, start_position: Vector3, drop_direction: Vecto
impulse = drop_direction * drop_impulse
apply_central_impulse(impulse)
lifetime_timer.start(lifetime_in_seconds)
func set_id(block_id: String) -> void:
id = block_id
if id in DBItems.data:
@ -46,6 +54,9 @@ func set_id(block_id: String) -> void:
printerr("Unknown Block ID: ", id)
func _on_lifetime_timeout() -> void:
call_deferred("queue_free")
func _on_pickup_area_body_entered(body: Node3D) -> void:
if not body is Player: return


+ 6
- 1
scenes/blocks/dropped_block.tscn View File

@ -96,11 +96,12 @@ _data = {
[sub_resource type="SphereShape3D" id="SphereShape3D_5kft2"]
[node name="DroppedBlock" type="RigidBody3D" node_paths=PackedStringArray("animation_player", "block_mesh", "pickup_area")]
[node name="DroppedBlock" type="RigidBody3D" node_paths=PackedStringArray("animation_player", "block_mesh", "lifetime_timer", "pickup_area")]
collision_layer = 4
script = ExtResource("1_y8usf")
animation_player = NodePath("AnimationPlayer")
block_mesh = NodePath("BlockMesh")
lifetime_timer = NodePath("LifetimeTimer")
pickup_area = NodePath("PickupArea")
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
@ -129,4 +130,8 @@ shape = SubResource("SphereShape3D_5kft2")
[node name="SaveDataComponent" parent="." instance=ExtResource("3_ix4xk")]
save_data_resource = ExtResource("4_8xfh1")
[node name="LifetimeTimer" type="Timer" parent="."]
wait_time = 10.0
one_shot = true
[connection signal="body_entered" from="PickupArea" to="." method="_on_pickup_area_body_entered"]

+ 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")

+ 40
- 10
scenes/player/player.gd View File

@ -25,6 +25,7 @@ extends CharacterBody3D
@onready var collision_shape_crouching: CollisionShape3D = $CollisionShapeCrouching
@onready var ray_cast_crouch: RayCast3D = $RayCastCrouch
var current_height: float = 0.0
var current_jump_count: int = 0
var current_speed: float = walk_speed
var direction: Vector3 = Vector3.ZERO
@ -36,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()
@ -55,11 +58,15 @@ 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)
_update_held_block_mesh(InventoryManager.quick_slot_item_id)
SignalManager.hide_ui.connect(_on_hide_ui)
SignalManager.show_ui.connect(_on_show_ui)
func _apply_gravity(delta: float) -> void:
@ -72,8 +79,8 @@ func _handle_crouching(delta: float) -> void:
collision_shape_crouching.disabled = !is_crouching
collision_shape_standing.disabled = is_crouching
var height: float = crouch_height if is_crouching else standing_height
head.position.y = lerp(head.position.y, height, camera_acceleration * delta)
current_height = crouch_height if is_crouching else standing_height
head.position.y = lerp(head.position.y, current_height, camera_acceleration * delta)
func _handle_jumping() -> void:
if is_on_floor():
@ -130,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:
@ -142,11 +154,29 @@ 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
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
func _on_show_ui() -> void:
block_mesh.visible = true and GameSettingsManager.settings.game_options.enable_held_block

+ 3
- 2
scenes/player/player.tscn View File

@ -35,12 +35,13 @@ 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 name="RayCastLook" type="RayCast3D" parent="Head" node_paths=PackedStringArray("player")]
target_position = Vector3(0, 0, -10)
debug_shape_custom_color = Color(0.753415, 4.77457e-05, 0.578804, 1)
script = ExtResource("2_dovo2")
player = NodePath("../..")
[node name="RayCastCrouch" type="RayCast3D" parent="."]
editor_description = "Y should be just slightly higher than the height of the standing collision shape"


+ 28
- 4
scenes/player/ray_cast_look.gd View File

@ -1,6 +1,9 @@
extends RayCast3D
@export var player: Player
func _process(_delta: float) -> void:
if is_colliding():
var collider: Object = get_collider()
@ -9,10 +12,13 @@ func _process(_delta: float) -> void:
if Input.is_action_just_pressed("right_click_interact"):
(collider as Block).destroy_block()
if Input.is_action_just_pressed("left_click_interact"):
EntityManager.create_block.emit(
InventoryManager.quick_slot_item_id,
collider.position + get_collision_normal()
)
var block_pos: Vector3i = Vector3i(collider.position + get_collision_normal())
if !is_valid_placement_target(block_pos):
return
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
@ -25,6 +31,24 @@ func _process(_delta: float) -> void:
release_target()
func is_valid_placement_target(block_pos: Vector3i) -> bool:
var collision_shape_radius: float = player.collision_shape_standing.shape.radius
var collision_size_adjustments: Vector3 = Vector3(collision_shape_radius, 0, collision_shape_radius)
var player_position_min: Vector3 = player.global_position - collision_size_adjustments
var player_position_max: Vector3 = player.global_position + collision_size_adjustments
player_position_max.y += player.current_height
var _is_overlapping_player: bool = (
block_pos.x >= player_position_min.x and block_pos.x <= player_position_max.x and
block_pos.y >= player_position_min.y and block_pos.y <= player_position_max.y and
block_pos.z >= player_position_min.z and block_pos.z <= player_position_max.z
)
return !_is_overlapping_player
func hook_block(target_block: Block) -> void:
target_block.hook()
Waila.ref.set_target(target_block)


+ 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
- 32
scenes/ui/menus/pause_menu.gd View File

@ -1,32 +0,0 @@
class_name PauseMenu
extends Panel
@export var save_load_ui: SaveLoadUI
func _unhandled_input(event: InputEvent) -> void:
if event.is_action_pressed("ui_cancel") and self.visible:
hide_menu()
elif event.is_action_pressed("ui_cancel") and !self.visible:
show_menu()
func hide_menu() -> void:
SignalManager.close_pause_menu.emit()
func show_menu() -> void:
SignalManager.open_pause_menu.emit()
# Signals
func _on_exit_game_button_pressed() -> void:
get_tree().quit()
func _on_resume_button_pressed() -> void:
hide_menu()
func _on_settings_button_pressed() -> void:
SignalManager.open_settings_menu.emit()
func _on_saves_button_pressed() -> void:
save_load_ui.open_save_list.emit()

+ 0
- 1
scenes/ui/menus/pause_menu.gd.uid View File

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

+ 0
- 75
scenes/ui/menus/pause_menu.tscn View File

@ -1,75 +0,0 @@
[gd_scene load_steps=3 format=3 uid="uid://bopvfwcgnnawg"]
[ext_resource type="Theme" uid="uid://b5q8b0l6qp1dt" path="res://resources/pause_menu_theme.tres" id="1_6tw0m"]
[ext_resource type="Script" uid="uid://d3ysjgxxmyqpw" path="res://scenes/ui/menus/pause_menu.gd" id="2_0lmf7"]
[node name="PauseMenu" type="Panel"]
process_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme = ExtResource("1_6tw0m")
script = ExtResource("2_0lmf7")
[node name="Background" type="ColorRect" parent="."]
custom_minimum_size = Vector2(400, 0)
layout_mode = 1
anchors_preset = 13
anchor_left = 0.5
anchor_right = 0.5
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
color = Color(0.192157, 0.239216, 0.352941, 1)
[node name="MarginContainer" type="MarginContainer" parent="Background"]
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 = 10
theme_override_constants/margin_top = 10
theme_override_constants/margin_right = 10
theme_override_constants/margin_bottom = 10
[node name="MenuContainer" type="VBoxContainer" parent="Background/MarginContainer"]
layout_mode = 2
size_flags_horizontal = 4
theme_override_constants/separation = 20
[node name="Title" type="Label" parent="Background/MarginContainer/MenuContainer"]
layout_mode = 2
theme_override_font_sizes/font_size = 40
text = "Paused"
horizontal_alignment = 1
vertical_alignment = 1
[node name="ButtonsContainer" type="VBoxContainer" parent="Background/MarginContainer/MenuContainer"]
layout_mode = 2
size_flags_vertical = 6
theme_override_constants/separation = 20
[node name="ResumeButton" type="Button" parent="Background/MarginContainer/MenuContainer/ButtonsContainer"]
layout_mode = 2
text = "Resume"
[node name="SavesButton" type="Button" parent="Background/MarginContainer/MenuContainer/ButtonsContainer"]
layout_mode = 2
text = "Saves"
[node name="SettingsButton" type="Button" parent="Background/MarginContainer/MenuContainer/ButtonsContainer"]
layout_mode = 2
text = "Settings"
[node name="ExitGameButton" type="Button" parent="Background/MarginContainer/MenuContainer/ButtonsContainer"]
layout_mode = 2
text = "Exit Game"
[connection signal="pressed" from="Background/MarginContainer/MenuContainer/ButtonsContainer/ResumeButton" to="." method="_on_resume_button_pressed"]
[connection signal="pressed" from="Background/MarginContainer/MenuContainer/ButtonsContainer/SavesButton" to="." method="_on_saves_button_pressed"]
[connection signal="pressed" from="Background/MarginContainer/MenuContainer/ButtonsContainer/SettingsButton" to="." method="_on_settings_button_pressed"]
[connection signal="pressed" from="Background/MarginContainer/MenuContainer/ButtonsContainer/ExitGameButton" to="." method="_on_exit_game_button_pressed"]

+ 0
- 1
scenes/ui/menus/saves_manager/save_load_ui.gd.uid View File

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

+ 0
- 133
scenes/ui/menus/saves_manager/save_load_ui.tscn View File

@ -1,133 +0,0 @@
[gd_scene load_steps=7 format=3 uid="uid://dauchkhmnyk7n"]
[ext_resource type="Script" uid="uid://b6831eygibii7" path="res://scenes/ui/menus/saves_manager/save_load_ui.gd" id="1_lo08d"]
[ext_resource type="PackedScene" uid="uid://cyxieflejsggu" path="res://scenes/ui/menus/saves_manager/save_files_list.tscn" id="1_tqtxm"]
[ext_resource type="PackedScene" uid="uid://bb7poutsn4ex2" path="res://scenes/ui/menus/saves_manager/save_file.tscn" id="2_6uxbh"]
[ext_resource type="Texture2D" uid="uid://ja8bc1h5x85o" path="res://assets/ui/save-normal.png" id="3_lo08d"]
[ext_resource type="Texture2D" uid="uid://crqgyft4gfilt" path="res://assets/ui/save-pressed.png" id="4_md7la"]
[ext_resource type="Texture2D" uid="uid://o3l0j53mgkan" path="res://assets/ui/save-hover.png" id="5_hmxxn"]
[node name="SaveLoadUI" type="Control" node_paths=PackedStringArray("show_save_ui_button", "new_save_ui", "save_name_input", "create_save_button", "create_save_cancel_button")]
process_mode = 3
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
size_flags_horizontal = 6
size_flags_vertical = 4
script = ExtResource("1_lo08d")
show_save_ui_button = NodePath("Panel/MarginContainer/VBoxContainer/BottomRow/SaveButton")
new_save_ui = NodePath("Panel/NewSaveUI")
save_name_input = NodePath("Panel/NewSaveUI/MarginContainer/VBoxContainer/SaveNameInput")
create_save_button = NodePath("Panel/NewSaveUI/MarginContainer/VBoxContainer/SaveButton")
create_save_cancel_button = NodePath("Panel/NewSaveUI/MarginContainer/VBoxContainer/CancelButton")
[node name="Panel" type="Panel" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="MarginContainer" type="MarginContainer" parent="Panel"]
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 = 20
theme_override_constants/margin_top = 20
theme_override_constants/margin_right = 20
theme_override_constants/margin_bottom = 20
[node name="VBoxContainer" type="VBoxContainer" parent="Panel/MarginContainer"]
layout_mode = 2
[node name="Label" type="Label" parent="Panel/MarginContainer/VBoxContainer"]
layout_mode = 2
theme_override_font_sizes/font_size = 40
text = "Save/Load Game"
horizontal_alignment = 1
[node name="ScrollContainer" type="ScrollContainer" parent="Panel/MarginContainer/VBoxContainer"]
custom_minimum_size = Vector2(0, 500)
layout_mode = 2
horizontal_scroll_mode = 0
[node name="SaveFilesList" parent="Panel/MarginContainer/VBoxContainer/ScrollContainer" node_paths=PackedStringArray("save_load_ui") instance=ExtResource("1_tqtxm")]
layout_mode = 2
size_flags_horizontal = 6
save_load_ui = NodePath("../../../../..")
[node name="SaveFilePanel" parent="Panel/MarginContainer/VBoxContainer/ScrollContainer/SaveFilesList" instance=ExtResource("2_6uxbh")]
layout_mode = 2
[node name="BottomRow" type="HBoxContainer" parent="Panel/MarginContainer/VBoxContainer"]
layout_mode = 2
alignment = 1
[node name="SaveButton" type="TextureButton" parent="Panel/MarginContainer/VBoxContainer/BottomRow"]
clip_contents = true
custom_minimum_size = Vector2(32, 32)
layout_mode = 2
tooltip_text = "New Save"
texture_normal = ExtResource("3_lo08d")
texture_pressed = ExtResource("4_md7la")
texture_hover = ExtResource("5_hmxxn")
ignore_texture_size = true
stretch_mode = 5
[node name="NewSaveUI" type="Panel" parent="Panel"]
visible = false
custom_minimum_size = Vector2(450, 100)
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="MarginContainer" type="MarginContainer" parent="Panel/NewSaveUI"]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -205.0
offset_top = -29.5
offset_right = 205.0
offset_bottom = 29.5
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/margin_left = 5
theme_override_constants/margin_top = 5
theme_override_constants/margin_right = 5
theme_override_constants/margin_bottom = 5
[node name="VBoxContainer" type="VBoxContainer" parent="Panel/NewSaveUI/MarginContainer"]
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 4
[node name="SaveNameLabel" type="Label" parent="Panel/NewSaveUI/MarginContainer/VBoxContainer"]
layout_mode = 2
theme_override_font_sizes/font_size = 20
text = "Create New Save"
[node name="SaveNameInput" type="LineEdit" parent="Panel/NewSaveUI/MarginContainer/VBoxContainer"]
custom_minimum_size = Vector2(400, 0)
layout_mode = 2
placeholder_text = "New Save File Name"
[node name="SaveButton" type="Button" parent="Panel/NewSaveUI/MarginContainer/VBoxContainer"]
layout_mode = 2
text = "Create Save"
[node name="CancelButton" type="Button" parent="Panel/NewSaveUI/MarginContainer/VBoxContainer"]
layout_mode = 2
text = "Cancel"

+ 0
- 1
scenes/ui/menus/settings_menu.gd.uid View File

@ -1 +0,0 @@
uid://37ftrpj14msn

+ 0
- 266
scenes/ui/menus/settings_menu.tscn View File

@ -1,266 +0,0 @@
[gd_scene load_steps=4 format=3 uid="uid://4bdgwwx27m71"]
[ext_resource type="Script" uid="uid://37ftrpj14msn" path="res://scenes/ui/menus/settings_menu.gd" id="1_qwcqe"]
[ext_resource type="Theme" uid="uid://b5q8b0l6qp1dt" path="res://resources/pause_menu_theme.tres" id="2_mhswj"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_80b2v"]
content_margin_left = 10.0
content_margin_top = 10.0
content_margin_right = 10.0
content_margin_bottom = 10.0
bg_color = Color(0, 0, 0, 0.27451)
corner_radius_top_left = 2
corner_radius_top_right = 2
corner_radius_bottom_right = 2
corner_radius_bottom_left = 2
[node name="SettingsMenu" type="Panel" node_paths=PackedStringArray("block_highlight_input", "held_block_ui_input", "quick_slots_ui_input", "screenshot_icon_input", "waila_input", "resolution_input", "fullscreen_input", "vsync_input", "fov_slider", "fov_value_label")]
process_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_qwcqe")
block_highlight_input = NodePath("Background/MarginContainer/VBoxContainer/TabContainer/Game/BlockHighlight/CheckButton")
held_block_ui_input = NodePath("Background/MarginContainer/VBoxContainer/TabContainer/Game/HeldBlockUI/CheckButton")
quick_slots_ui_input = NodePath("Background/MarginContainer/VBoxContainer/TabContainer/Game/QuickslotsUI/CheckButton")
screenshot_icon_input = NodePath("Background/MarginContainer/VBoxContainer/TabContainer/Game/ScreenshotIcon/CheckButton")
waila_input = NodePath("Background/MarginContainer/VBoxContainer/TabContainer/Game/Waila/CheckButton")
resolution_input = NodePath("Background/MarginContainer/VBoxContainer/TabContainer/Graphics/Resolution/OptionButton")
fullscreen_input = NodePath("Background/MarginContainer/VBoxContainer/TabContainer/Graphics/Fullscreen/CheckBox")
vsync_input = NodePath("Background/MarginContainer/VBoxContainer/TabContainer/Graphics/VSync/CheckBox")
fov_slider = NodePath("Background/MarginContainer/VBoxContainer/TabContainer/Graphics/FOV/HSlider")
fov_value_label = NodePath("Background/MarginContainer/VBoxContainer/TabContainer/Graphics/FOV/Value")
metadata/_edit_vertical_guides_ = [349.0]
[node name="Background" type="ColorRect" parent="."]
custom_minimum_size = Vector2(400, 0)
layout_mode = 1
anchors_preset = 13
anchor_left = 0.5
anchor_right = 0.5
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
color = Color(0.192157, 0.239216, 0.352941, 1)
[node name="MarginContainer" type="MarginContainer" parent="Background"]
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 = 10
theme_override_constants/margin_top = 10
theme_override_constants/margin_right = 10
theme_override_constants/margin_bottom = 10
[node name="VBoxContainer" type="VBoxContainer" parent="Background/MarginContainer"]
layout_mode = 2
size_flags_horizontal = 4
theme_override_constants/separation = 20
[node name="Title" type="Label" parent="Background/MarginContainer/VBoxContainer"]
layout_mode = 2
theme_override_font_sizes/font_size = 40
text = "Settings"
horizontal_alignment = 1
[node name="TabContainer" type="TabContainer" parent="Background/MarginContainer/VBoxContainer"]
layout_mode = 2
theme_override_constants/side_margin = 0
theme_override_styles/panel = SubResource("StyleBoxFlat_80b2v")
current_tab = 0
clip_tabs = false
[node name="Game" type="VBoxContainer" parent="Background/MarginContainer/VBoxContainer/TabContainer"]
layout_mode = 2
metadata/_tab_index = 0
[node name="BlockHighlight" type="HBoxContainer" parent="Background/MarginContainer/VBoxContainer/TabContainer/Game"]
layout_mode = 2
[node name="Label" type="Label" parent="Background/MarginContainer/VBoxContainer/TabContainer/Game/BlockHighlight"]
layout_mode = 2
size_flags_horizontal = 3
text = "Enable Block Highlighting"
[node name="CheckButton" type="CheckButton" parent="Background/MarginContainer/VBoxContainer/TabContainer/Game/BlockHighlight"]
layout_mode = 2
button_pressed = true
[node name="Waila" type="HBoxContainer" parent="Background/MarginContainer/VBoxContainer/TabContainer/Game"]
layout_mode = 2
[node name="Label" type="Label" parent="Background/MarginContainer/VBoxContainer/TabContainer/Game/Waila"]
layout_mode = 2
size_flags_horizontal = 3
text = "Enable Waila"
[node name="CheckButton" type="CheckButton" parent="Background/MarginContainer/VBoxContainer/TabContainer/Game/Waila"]
layout_mode = 2
button_pressed = true
[node name="QuickslotsUI" type="HBoxContainer" parent="Background/MarginContainer/VBoxContainer/TabContainer/Game"]
layout_mode = 2
[node name="Label" type="Label" parent="Background/MarginContainer/VBoxContainer/TabContainer/Game/QuickslotsUI"]
layout_mode = 2
size_flags_horizontal = 3
text = "Enable Quickslots UI"
[node name="CheckButton" type="CheckButton" parent="Background/MarginContainer/VBoxContainer/TabContainer/Game/QuickslotsUI"]
layout_mode = 2
button_pressed = true
[node name="HeldBlockUI" type="HBoxContainer" parent="Background/MarginContainer/VBoxContainer/TabContainer/Game"]
layout_mode = 2
[node name="Label" type="Label" parent="Background/MarginContainer/VBoxContainer/TabContainer/Game/HeldBlockUI"]
layout_mode = 2
size_flags_horizontal = 3
text = "Enable Player Held Block"
[node name="CheckButton" type="CheckButton" parent="Background/MarginContainer/VBoxContainer/TabContainer/Game/HeldBlockUI"]
layout_mode = 2
button_pressed = true
[node name="ScreenshotIcon" type="HBoxContainer" parent="Background/MarginContainer/VBoxContainer/TabContainer/Game"]
layout_mode = 2
[node name="Label" type="Label" parent="Background/MarginContainer/VBoxContainer/TabContainer/Game/ScreenshotIcon"]
layout_mode = 2
size_flags_horizontal = 3
tooltip_text = "Enable/Disable the taking of a screenshot to utilize as the save icon."
mouse_filter = 1
text = "Enable Save Screenshot"
[node name="CheckButton" type="CheckButton" parent="Background/MarginContainer/VBoxContainer/TabContainer/Game/ScreenshotIcon"]
layout_mode = 2
tooltip_text = "Enable/Disable the taking of a screenshot to utilize as the save icon."
button_pressed = true
[node name="Graphics" type="VBoxContainer" parent="Background/MarginContainer/VBoxContainer/TabContainer"]
visible = false
layout_mode = 2
metadata/_tab_index = 1
[node name="Resolution" type="HBoxContainer" parent="Background/MarginContainer/VBoxContainer/TabContainer/Graphics"]
layout_mode = 2
[node name="Label" type="Label" parent="Background/MarginContainer/VBoxContainer/TabContainer/Graphics/Resolution"]
layout_mode = 2
size_flags_horizontal = 3
text = "Resolution"
[node name="OptionButton" type="OptionButton" parent="Background/MarginContainer/VBoxContainer/TabContainer/Graphics/Resolution"]
layout_mode = 2
selected = 0
item_count = 6
popup/item_0/text = "1280x720"
popup/item_0/id = 0
popup/item_1/text = "1280x800"
popup/item_1/id = 4
popup/item_2/text = "1920x1080"
popup/item_2/id = 1
popup/item_3/text = "2560x1440"
popup/item_3/id = 2
popup/item_4/text = "3440x1440"
popup/item_4/id = 3
popup/item_5/text = "3840 x 2160"
popup/item_5/id = 5
[node name="Fullscreen" type="HBoxContainer" parent="Background/MarginContainer/VBoxContainer/TabContainer/Graphics"]
layout_mode = 2
[node name="Label" type="Label" parent="Background/MarginContainer/VBoxContainer/TabContainer/Graphics/Fullscreen"]
layout_mode = 2
size_flags_horizontal = 3
text = "Fullscreen"
[node name="CheckBox" type="CheckBox" parent="Background/MarginContainer/VBoxContainer/TabContainer/Graphics/Fullscreen"]
layout_mode = 2
[node name="VSync" type="HBoxContainer" parent="Background/MarginContainer/VBoxContainer/TabContainer/Graphics"]
layout_mode = 2
[node name="Label" type="Label" parent="Background/MarginContainer/VBoxContainer/TabContainer/Graphics/VSync"]
layout_mode = 2
size_flags_horizontal = 3
text = "VSync"
[node name="CheckBox" type="CheckBox" parent="Background/MarginContainer/VBoxContainer/TabContainer/Graphics/VSync"]
layout_mode = 2
[node name="FOV" type="HBoxContainer" parent="Background/MarginContainer/VBoxContainer/TabContainer/Graphics"]
layout_mode = 2
[node name="Label" type="Label" parent="Background/MarginContainer/VBoxContainer/TabContainer/Graphics/FOV"]
layout_mode = 2
size_flags_horizontal = 3
text = "FOV"
[node name="HSlider" type="HSlider" parent="Background/MarginContainer/VBoxContainer/TabContainer/Graphics/FOV"]
layout_mode = 2
size_flags_horizontal = 3
min_value = 60.0
max_value = 120.0
value = 75.0
rounded = true
ticks_on_borders = true
[node name="Value" type="Label" parent="Background/MarginContainer/VBoxContainer/TabContainer/Graphics/FOV"]
layout_mode = 2
text = "75"
[node name="HSeparator" type="HSeparator" parent="Background/MarginContainer/VBoxContainer/TabContainer/Graphics"]
layout_mode = 2
theme_override_constants/separation = 20
[node name="CenterContainer" type="CenterContainer" parent="Background/MarginContainer/VBoxContainer/TabContainer/Graphics"]
layout_mode = 2
[node name="ApplyButton" type="Button" parent="Background/MarginContainer/VBoxContainer/TabContainer/Graphics/CenterContainer"]
layout_mode = 2
text = "Apply/Save"
[node name="Audio" type="VBoxContainer" parent="Background/MarginContainer/VBoxContainer/TabContainer"]
visible = false
layout_mode = 2
metadata/_tab_index = 2
[node name="Inputs" type="VBoxContainer" parent="Background/MarginContainer/VBoxContainer/TabContainer"]
visible = false
layout_mode = 2
metadata/_tab_index = 3
[node name="BottomRow" type="MarginContainer" parent="Background"]
layout_mode = 1
anchors_preset = 7
anchor_left = 0.5
anchor_top = 1.0
anchor_right = 0.5
anchor_bottom = 1.0
offset_left = -82.5
offset_top = -46.0
offset_right = 82.5
grow_horizontal = 2
grow_vertical = 0
theme_override_constants/margin_bottom = 10
[node name="CloseButton" type="Button" parent="Background/BottomRow"]
custom_minimum_size = Vector2(141, 36)
layout_mode = 2
theme = ExtResource("2_mhswj")
text = "Close Settings"
[connection signal="toggled" from="Background/MarginContainer/VBoxContainer/TabContainer/Game/BlockHighlight/CheckButton" to="." method="_on_block_highlighting_toggled"]
[connection signal="toggled" from="Background/MarginContainer/VBoxContainer/TabContainer/Game/Waila/CheckButton" to="." method="_on_enable_waila_toggled"]
[connection signal="toggled" from="Background/MarginContainer/VBoxContainer/TabContainer/Game/QuickslotsUI/CheckButton" to="." method="_on_quickslots_ui_toggled"]
[connection signal="toggled" from="Background/MarginContainer/VBoxContainer/TabContainer/Game/HeldBlockUI/CheckButton" to="." method="_on_held_block_ui_toggled"]
[connection signal="toggled" from="Background/MarginContainer/VBoxContainer/TabContainer/Game/ScreenshotIcon/CheckButton" to="." method="_on_screenshot_icon_button_toggled"]
[connection signal="value_changed" from="Background/MarginContainer/VBoxContainer/TabContainer/Graphics/FOV/HSlider" to="." method="_on_fov_slider_changed"]
[connection signal="pressed" from="Background/MarginContainer/VBoxContainer/TabContainer/Graphics/CenterContainer/ApplyButton" to="." method="_on_graphics_apply_button_pressed"]
[connection signal="pressed" from="Background/BottomRow/CloseButton" to="." method="_on_close_button_pressed"]

+ 33
- 0
scenes/ui/pause_menu/base_menu.gd View File

@ -0,0 +1,33 @@
class_name BaseMenu
extends ColorRect
@export var animation_player: AnimationPlayer
var pause_menu: PauseMenu
func init() -> void:
reset_menu()
update_animation_tracks()
func close_menu() -> void:
animation_player.play("hide")
func open_menu() -> void:
animation_player.play("show")
func reset_menu() -> void:
animation_player.play("RESET")
## Update the animation tracks to account for the varying sizes of the menu container[br]
## Requires:[br]
## Track 1 - Must be for the content_container[br]
## First Property - Must be position[br]
## Second Property - Visibility
func update_animation_tracks() -> void:
var hide_animation: Animation = animation_player.get_animation("hide")
var show_animation: Animation = animation_player.get_animation("show")
hide_animation.track_set_key_value(0, 1, Vector2(-size.x, hide_animation.track_get_key_value(0, 1).y))
show_animation.track_set_key_value(0, 0, Vector2(-size.x, show_animation.track_get_key_value(0, 0).y))

+ 1
- 0
scenes/ui/pause_menu/base_menu.gd.uid View File

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

+ 152
- 0
scenes/ui/pause_menu/base_menu.tscn View File

@ -0,0 +1,152 @@
[gd_scene load_steps=7 format=3 uid="uid://4itp2hjp14n2"]
[ext_resource type="Theme" uid="uid://b5q8b0l6qp1dt" path="res://resources/pause_menu_theme.tres" id="1_3sxei"]
[ext_resource type="Script" uid="uid://c71f7fatmvsra" path="res://scenes/ui/pause_menu/base_menu.gd" id="2_3sxei"]
[sub_resource type="Animation" id="Animation_vx2qe"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath(".:position")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector2(-400, 0)]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath(".:visible")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [false]
}
[sub_resource type="Animation" id="Animation_q12vw"]
resource_name = "hide"
length = 0.2
step = 0.05
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath(".:position")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.2),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [Vector2(0, 0), Vector2(-400, 0)]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath(".:visible")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0, 0.2),
"transitions": PackedFloat32Array(1, 1),
"update": 1,
"values": [true, false]
}
[sub_resource type="Animation" id="Animation_3mo8w"]
resource_name = "show"
length = 0.2
step = 0.05
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath(".:position")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.2),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [Vector2(-400, 0), Vector2(0, 0)]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath(".:visible")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [true]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_q12vw"]
_data = {
&"RESET": SubResource("Animation_vx2qe"),
&"hide": SubResource("Animation_q12vw"),
&"show": SubResource("Animation_3mo8w")
}
[node name="BaseMenu" type="ColorRect" node_paths=PackedStringArray("animation_player")]
custom_minimum_size = Vector2(400, 0)
anchors_preset = 9
anchor_bottom = 1.0
offset_left = -400.0
grow_vertical = 2
theme = ExtResource("1_3sxei")
color = Color(0.133333, 0.133333, 0.133333, 0.784314)
script = ExtResource("2_3sxei")
animation_player = NodePath("AnimationPlayer")
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
reset_on_save = false
libraries = {
&"": SubResource("AnimationLibrary_q12vw")
}
autoplay = "show"
[node name="MainContent" 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 = 10
theme_override_constants/margin_top = 10
theme_override_constants/margin_right = 10
theme_override_constants/margin_bottom = 10
[node name="MenuContainer" type="VBoxContainer" parent="MainContent"]
layout_mode = 2
size_flags_horizontal = 4
theme_override_constants/separation = 20
[node name="Title" type="Label" parent="MainContent/MenuContainer"]
layout_mode = 2
theme_type_variation = &"MenuTitle"
text = "Menu Title"
horizontal_alignment = 1
vertical_alignment = 1
[node name="BottomRow" type="MarginContainer" parent="."]
layout_mode = 1
anchors_preset = 7
anchor_left = 0.5
anchor_top = 1.0
anchor_right = 0.5
anchor_bottom = 1.0
offset_left = -82.5
offset_top = -46.0
offset_right = 82.5
grow_horizontal = 2
grow_vertical = 0
theme_override_constants/margin_bottom = 10

+ 16
- 0
scenes/ui/pause_menu/main_menu.gd View File

@ -0,0 +1,16 @@
class_name PauseMenuMain
extends BaseMenu
# Signals
func _on_exit_game_button_pressed() -> void:
get_tree().quit()
func _on_resume_button_pressed() -> void:
close_menu()
func _on_saves_button_pressed() -> void:
pause_menu.open_menu.emit("SavesMenu")
func _on_settings_button_pressed() -> void:
pause_menu.open_menu.emit("SettingsMenu")

+ 1
- 0
scenes/ui/pause_menu/main_menu.gd.uid View File

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

+ 36
- 0
scenes/ui/pause_menu/main_menu.tscn View File

@ -0,0 +1,36 @@
[gd_scene load_steps=3 format=3 uid="uid://xy8pdtxcepqf"]
[ext_resource type="PackedScene" uid="uid://4itp2hjp14n2" path="res://scenes/ui/pause_menu/base_menu.tscn" id="1_6fgdx"]
[ext_resource type="Script" uid="uid://bwvwpiwhp52e" path="res://scenes/ui/pause_menu/main_menu.gd" id="2_4i143"]
[node name="MainMenu" instance=ExtResource("1_6fgdx")]
script = ExtResource("2_4i143")
[node name="Title" parent="MainContent/MenuContainer" index="0"]
text = "Paused"
[node name="ButtonsContainer" type="VBoxContainer" parent="MainContent/MenuContainer" index="1"]
layout_mode = 2
size_flags_vertical = 6
theme_override_constants/separation = 20
[node name="ResumeButton" type="Button" parent="MainContent/MenuContainer/ButtonsContainer" index="0"]
layout_mode = 2
text = "Resume"
[node name="SavesButton" type="Button" parent="MainContent/MenuContainer/ButtonsContainer" index="1"]
layout_mode = 2
text = "Saves"
[node name="SettingsButton" type="Button" parent="MainContent/MenuContainer/ButtonsContainer" index="2"]
layout_mode = 2
text = "Settings"
[node name="ExitGameButton" type="Button" parent="MainContent/MenuContainer/ButtonsContainer" index="3"]
layout_mode = 2
text = "Exit Game"
[connection signal="pressed" from="MainContent/MenuContainer/ButtonsContainer/ResumeButton" to="." method="_on_resume_button_pressed"]
[connection signal="pressed" from="MainContent/MenuContainer/ButtonsContainer/SavesButton" to="." method="_on_saves_button_pressed"]
[connection signal="pressed" from="MainContent/MenuContainer/ButtonsContainer/SettingsButton" to="." method="_on_settings_button_pressed"]
[connection signal="pressed" from="MainContent/MenuContainer/ButtonsContainer/ExitGameButton" to="." method="_on_exit_game_button_pressed"]

+ 87
- 0
scenes/ui/pause_menu/pause_menu.gd View File

@ -0,0 +1,87 @@
## Handle changing changing menus and running the show/hide animations for each menu.
## Each menu should extend BaseMenu
class_name PauseMenu
extends Panel
signal open_menu(menu_name: String)
@onready var menu_mapping: Dictionary[String, BaseMenu] = {
"MainMenu": $MainMenu,
"SettingsMenu": $SettingsMenu,
"SavesMenu": $SavesMenu,
}
var _active_menu: String = "MainMenu"
var _next_menu: String = ""
func _ready() -> void:
open_menu.connect(_on_change_menu)
for menu: BaseMenu in get_children():
menu.animation_player.animation_finished.connect(_on_animation_finished)
menu.pause_menu = self
menu.init()
SaveGameManager.create_save.connect(_on_create_save)
SaveGameManager.load_save.connect(_on_load_save)
func _unhandled_input(event: InputEvent) -> void:
if event.is_action_pressed("ui_cancel") and !visible:
_open_pause_menu()
elif event.is_action_pressed("ui_cancel") and visible and _active_menu == "MainMenu":
menu_mapping["MainMenu"].animation_player.play("hide")
elif event.is_action_pressed("ui_cancel"): ## Always back out to the MainMenu - Future, maybe add _previous_menu to allow backing out to any menu
open_menu.emit("MainMenu")
## Start the `hide` animation for the current menu.
## The `show` animation will play after the `hide` has completed, from `_on_animation_finished()`.
func _change_menu(menu_name: String) -> void:
visible = true
_next_menu = menu_name
if _next_menu == "":
menu_mapping["MainMenu"].animation_player.play("hide")
else:
menu_mapping[_active_menu].animation_player.play("hide")
func _close_pause_menu() -> void:
visible = false
_next_menu = ""
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
SignalManager.resume_game.emit()
## Run the `show` animation for the next menu
## If there is no next menu, close the pause menu
func _handle_next_menu() -> void:
if _next_menu == "":
_active_menu = "MainMenu"
_close_pause_menu()
else:
_active_menu = _next_menu
_next_menu = ""
menu_mapping[_active_menu].animation_player.play("show")
func _open_pause_menu() -> void:
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
SignalManager.pause_game.emit()
menu_mapping["MainMenu"].animation_player.play("show")
## When the hide animation finished, start show `show` animation for the next menu
func _on_animation_finished(animation_name: String) -> void:
if animation_name == "hide":
_handle_next_menu()
func _on_change_menu(menu_name: String) -> void:
_change_menu(menu_name)
func _on_create_save(_save: String) -> void:
menu_mapping["SavesMenu"].reset_menu()
_close_pause_menu()
func _on_load_save(_save: String) -> void:
menu_mapping["SavesMenu"].reset_menu()
_close_pause_menu()

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

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

+ 37
- 0
scenes/ui/pause_menu/pause_menu.tscn View File

@ -0,0 +1,37 @@
[gd_scene load_steps=6 format=3 uid="uid://by0gd600mbcr5"]
[ext_resource type="Script" uid="uid://domfn2obgmavw" path="res://scenes/ui/pause_menu/pause_menu.gd" id="1_ugqbi"]
[ext_resource type="PackedScene" uid="uid://xy8pdtxcepqf" path="res://scenes/ui/pause_menu/main_menu.tscn" id="2_rv5mv"]
[ext_resource type="PackedScene" uid="uid://uwlutbmfp8dv" path="res://scenes/ui/pause_menu/settings_menu.tscn" id="3_rv5mv"]
[ext_resource type="PackedScene" uid="uid://dq83yv2um7sci" path="res://scenes/ui/pause_menu/saves_menu.tscn" id="4_rv5mv"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_4xojl"]
bg_color = Color(0.176419, 0.176419, 0.176419, 0.462745)
[node name="PauseMenu" type="Panel"]
process_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_styles/panel = SubResource("StyleBoxFlat_4xojl")
script = ExtResource("1_ugqbi")
[node name="MainMenu" parent="." instance=ExtResource("2_rv5mv")]
visible = false
layout_mode = 1
offset_left = 0.0
offset_right = 400.0
[node name="SettingsMenu" parent="." instance=ExtResource("3_rv5mv")]
visible = false
layout_mode = 1
offset_left = 0.0
offset_right = 400.0
[node name="SavesMenu" parent="." instance=ExtResource("4_rv5mv")]
visible = false
layout_mode = 1
offset_left = 0.0
offset_right = 450.0

scenes/ui/menus/saves_manager/save_file.gd → scenes/ui/pause_menu/saves_manager/save_file.gd View File


scenes/ui/menus/saves_manager/save_file.gd.uid → scenes/ui/pause_menu/saves_manager/save_file.gd.uid View File


scenes/ui/menus/saves_manager/save_file.tscn → scenes/ui/pause_menu/saves_manager/save_file.tscn View File

@ -2,7 +2,7 @@
[ext_resource type="StyleBox" uid="uid://biousyggn7iua" path="res://resources/save_file_panel_theme.tres" id="1_cqw77"]
[ext_resource type="Texture2D" uid="uid://cmq51cgasug81" path="res://assets/ui/folder-open-normal.png" id="1_k6haa"]
[ext_resource type="Script" uid="uid://dcfdyua5gwpw4" path="res://scenes/ui/menus/saves_manager/save_file.gd" id="2_5g2eu"]
[ext_resource type="Script" uid="uid://dcfdyua5gwpw4" path="res://scenes/ui/pause_menu/saves_manager/save_file.gd" id="2_5g2eu"]
[ext_resource type="Texture2D" uid="uid://blyryo60jydgi" path="res://assets/ui/folder-open-pressed.png" id="2_714lu"]
[ext_resource type="StyleBox" uid="uid://bwm315lqbbb87" path="res://resources/save_file_highlight_panel_theme.tres" id="3_om23c"]
[ext_resource type="Texture2D" uid="uid://by4w5ll3le7g6" path="res://assets/ui/folder-open-hover.png" id="3_ubfnn"]

scenes/ui/menus/saves_manager/save_files_list.gd → scenes/ui/pause_menu/saves_manager/save_files_list.gd View File

@ -1,12 +1,8 @@
class_name SaveFilesListUI
extends VBoxContainer
@export var save_file_scene: PackedScene
@export var save_load_ui: SaveLoadUI
func _ready() -> void:
save_load_ui.open_save_list.connect(_on_open_save_list) # TODO: Reconsider this setup
## Clear the SaveFilesList node of all saves and load most recent saves
@ -24,6 +20,3 @@ func refresh_saves_list() -> void:
func _clear_save_files_list() -> void:
for _panel: SaveFilePanel in get_children():
_panel.queue_free()
func _on_open_save_list() -> void:
refresh_saves_list()

scenes/ui/menus/saves_manager/save_files_list.gd.uid → scenes/ui/pause_menu/saves_manager/save_files_list.gd.uid View File


scenes/ui/menus/saves_manager/save_files_list.tscn → scenes/ui/pause_menu/saves_manager/save_files_list.tscn View File

@ -1,7 +1,7 @@
[gd_scene load_steps=3 format=3 uid="uid://cyxieflejsggu"]
[ext_resource type="Script" uid="uid://cqabj86bq8whn" path="res://scenes/ui/menus/saves_manager/save_files_list.gd" id="1_sh1p7"]
[ext_resource type="PackedScene" uid="uid://bb7poutsn4ex2" path="res://scenes/ui/menus/saves_manager/save_file.tscn" id="2_kb5u8"]
[ext_resource type="Script" uid="uid://cqabj86bq8whn" path="res://scenes/ui/pause_menu/saves_manager/save_files_list.gd" id="1_sh1p7"]
[ext_resource type="PackedScene" uid="uid://bb7poutsn4ex2" path="res://scenes/ui/pause_menu/saves_manager/save_file.tscn" id="2_kb5u8"]
[node name="SaveFilesList" type="VBoxContainer"]
clip_contents = true

scenes/ui/menus/saves_manager/save_load_ui.gd → scenes/ui/pause_menu/saves_menu.gd View File

@ -1,6 +1,5 @@
class_name SaveLoadUI
extends Control
class_name PauseMenuSaves
extends BaseMenu
signal close_save_list
signal open_save_list
@ -12,15 +11,16 @@ signal open_save_list
@export var create_save_button: BaseButton
@export var create_save_cancel_button: BaseButton
@export var ui_node: CanvasLayer ## The UI to Show/Hide when taking screenshot (e.g. save icon generation)
@export var save_files_list_ui: SaveFilesListUI
func _ready() -> void:
show_save_ui_button.pressed.connect(_on_show_save_ui_button_pressed)
func init() -> void:
super.init()
create_save_button.pressed.connect(_on_create_save_button_pressed)
create_save_cancel_button.pressed.connect(_on_create_save_cancel_button_pressed)
new_save_ui.hide()
show_save_ui_button.pressed.connect(_on_show_save_ui_button_pressed)
pause_menu.open_menu.connect(_on_open_menu)
func _on_create_save_button_pressed() -> void:
@ -28,18 +28,22 @@ func _on_create_save_button_pressed() -> void:
if save_name.strip_edges() == "":
save_name = Time.get_datetime_string_from_system(false, true)
if ui_node != null:
ui_node.visible = false
await get_tree().create_timer(.150).timeout # A hack to allow time for UI to hide before taking screenshot
SaveGameManager.create_save.emit(save_name)
if ui_node != null:
ui_node.visible = true
new_save_ui.hide()
SignalManager.hide_ui.emit()
await get_tree().create_timer(.150).timeout # A hack to allow time for UI to hide before taking screenshot
SaveGameManager.create_save.emit(save_name)
pause_menu.open_menu.emit("")
SignalManager.resume_game.emit()
func _on_create_save_cancel_button_pressed() -> void:
new_save_ui.hide()
func _on_open_menu(menu_name: String) -> void:
if menu_name == name:
save_files_list_ui.refresh_saves_list()
func _on_show_save_ui_button_pressed() -> void:
save_name_input.text = Time.get_datetime_string_from_system(false, true)
new_save_ui.show()

+ 1
- 0
scenes/ui/pause_menu/saves_menu.gd.uid View File

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

+ 97
- 0
scenes/ui/pause_menu/saves_menu.tscn View File

@ -0,0 +1,97 @@
[gd_scene load_steps=8 format=3 uid="uid://dq83yv2um7sci"]
[ext_resource type="PackedScene" uid="uid://4itp2hjp14n2" path="res://scenes/ui/pause_menu/base_menu.tscn" id="1_i4hg7"]
[ext_resource type="Script" uid="uid://di8dm3fdxfwo1" path="res://scenes/ui/pause_menu/saves_menu.gd" id="2_q3hp2"]
[ext_resource type="PackedScene" uid="uid://cyxieflejsggu" path="res://scenes/ui/pause_menu/saves_manager/save_files_list.tscn" id="3_0ok72"]
[ext_resource type="Texture2D" uid="uid://ja8bc1h5x85o" path="res://assets/ui/save-normal.png" id="3_urnjr"]
[ext_resource type="Texture2D" uid="uid://crqgyft4gfilt" path="res://assets/ui/save-pressed.png" id="4_31dcc"]
[ext_resource type="PackedScene" uid="uid://bb7poutsn4ex2" path="res://scenes/ui/pause_menu/saves_manager/save_file.tscn" id="4_v5wg2"]
[ext_resource type="Texture2D" uid="uid://o3l0j53mgkan" path="res://assets/ui/save-hover.png" id="5_0ok72"]
[node name="SavesMenu" node_paths=PackedStringArray("show_save_ui_button", "new_save_ui", "save_name_input", "create_save_button", "create_save_cancel_button", "save_files_list_ui") instance=ExtResource("1_i4hg7")]
custom_minimum_size = Vector2(450, 0)
offset_left = -450.0
script = ExtResource("2_q3hp2")
show_save_ui_button = NodePath("BottomRow/SaveButton")
new_save_ui = NodePath("NewSaveUI")
save_name_input = NodePath("NewSaveUI/MarginContainer/VBoxContainer/SaveNameInput")
create_save_button = NodePath("NewSaveUI/MarginContainer/VBoxContainer/SaveButton")
create_save_cancel_button = NodePath("NewSaveUI/MarginContainer/VBoxContainer/CancelButton")
save_files_list_ui = NodePath("MainContent/MenuContainer/ScrollContainer/SaveFilesList")
[node name="Title" parent="MainContent/MenuContainer" index="0"]
text = "Save/Load Game"
[node name="ScrollContainer" type="ScrollContainer" parent="MainContent/MenuContainer" index="1"]
custom_minimum_size = Vector2(0, 500)
layout_mode = 2
horizontal_scroll_mode = 0
[node name="SaveFilesList" parent="MainContent/MenuContainer/ScrollContainer" index="0" instance=ExtResource("3_0ok72")]
layout_mode = 2
size_flags_horizontal = 6
[node name="SaveFilePanel" parent="MainContent/MenuContainer/ScrollContainer/SaveFilesList" index="0" instance=ExtResource("4_v5wg2")]
layout_mode = 2
[node name="SaveButton" type="TextureButton" parent="BottomRow" index="0"]
clip_contents = true
custom_minimum_size = Vector2(32, 32)
layout_mode = 2
tooltip_text = "New Save"
texture_normal = ExtResource("3_urnjr")
texture_pressed = ExtResource("4_31dcc")
texture_hover = ExtResource("5_0ok72")
ignore_texture_size = true
stretch_mode = 5
[node name="NewSaveUI" type="Panel" parent="." index="3"]
visible = false
custom_minimum_size = Vector2(450, 100)
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="MarginContainer" type="MarginContainer" parent="NewSaveUI" index="0"]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -205.0
offset_top = -29.5
offset_right = 205.0
offset_bottom = 29.5
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/margin_left = 5
theme_override_constants/margin_top = 5
theme_override_constants/margin_right = 5
theme_override_constants/margin_bottom = 5
[node name="VBoxContainer" type="VBoxContainer" parent="NewSaveUI/MarginContainer" index="0"]
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 4
[node name="SaveNameLabel" type="Label" parent="NewSaveUI/MarginContainer/VBoxContainer" index="0"]
layout_mode = 2
theme_override_font_sizes/font_size = 20
text = "Create New Save"
[node name="SaveNameInput" type="LineEdit" parent="NewSaveUI/MarginContainer/VBoxContainer" index="1"]
custom_minimum_size = Vector2(400, 0)
layout_mode = 2
placeholder_text = "New Save File Name"
[node name="SaveButton" type="Button" parent="NewSaveUI/MarginContainer/VBoxContainer" index="2"]
layout_mode = 2
text = "Create Save"
[node name="CancelButton" type="Button" parent="NewSaveUI/MarginContainer/VBoxContainer" index="3"]
layout_mode = 2
text = "Cancel"

scenes/ui/menus/settings_menu.gd → scenes/ui/pause_menu/settings_menu.gd View File

@ -1,8 +1,9 @@
class_name SettingsMenu
extends Panel
class_name PauseMenuSettings
extends BaseMenu
@export_group("Game Option Nodes")
@export var autosaves_input: CheckButton
@export var block_highlight_input: CheckButton
@export var held_block_ui_input: CheckButton
@export var quick_slots_ui_input: CheckButton
@ -10,20 +11,23 @@ extends Panel
@export var waila_input: CheckButton
@export_group("Graphics Settings Nodes")
@export var resolution_input: OptionButton
@export var fullscreen_input: CheckBox
@export var vsync_input: CheckBox
@export var fov_slider: HSlider
@export var fov_value_label: Label
@export var resolution_input: OptionButton
@export var vsync_input: CheckBox
@export var window_mode_input: OptionButton
func _ready() -> void:
func init() -> void:
super.init()
apply_default_values()
## Sets the default values of all the inputs
func apply_default_values() -> void:
#region Game Options
autosaves_input.button_pressed = GameSettingsManager.settings.game_options.enable_autosaves
block_highlight_input.set_pressed_no_signal(GameSettingsManager.settings.game_options.enable_block_highlight)
held_block_ui_input.set_pressed_no_signal(GameSettingsManager.settings.game_options.enable_held_block)
quick_slots_ui_input.set_pressed_no_signal(GameSettingsManager.settings.game_options.enable_quickslots_ui)
@ -34,14 +38,17 @@ func apply_default_values() -> void:
#region Graphics Settings
# Changing the FOV value should trigger the value_changed signal which should update the camera and label automatically
fov_slider.value = GameSettingsManager.settings.graphics.fov
fullscreen_input.set_pressed_no_signal(GameSettingsManager.settings.graphics.fullscreen)
vsync_input.set_pressed_no_signal(GameSettingsManager.settings.graphics.vsync)
var current_mode_index: int = window_mode_input.get_item_index(GameSettingsManager.settings.graphics.window_mode)
window_mode_input.select(current_mode_index)
var current_resolution_index: int = resolution_input.get_item_index(GameSettingsManager.settings.graphics.resolution_id)
resolution_input.select(current_resolution_index)
#endregion
#region Game Settings
func _on_block_highlighting_toggled(toggled_on: bool) -> void:
GameSettingsManager.game_options_block_highlight_changed.emit(toggled_on)
@ -58,6 +65,13 @@ func _on_enable_waila_toggled(toggled_on: bool) -> void:
func _on_screenshot_icon_button_toggled(toggled_on: bool) -> void:
GameSettingsManager.game_options_screenshot_saves_changed.emit(toggled_on)
SaveGameManager.toggle_save_icon_generation.emit(toggled_on)
func _on_autosaves_button_toggled(toggled_on: bool) -> void:
GameSettingsManager.game_options_autosaves_changed.emit(toggled_on)
if toggled_on:
SaveGameManager.enable_autosaves.emit()
else:
SaveGameManager.disable_autosaves.emit()
#endregion
#region Graphics Settings
@ -67,10 +81,11 @@ func _on_fov_slider_changed(value: float) -> void:
func _on_graphics_apply_button_pressed() -> void:
var values: Array = resolution_input.text.split_floats("x")
var id: int = resolution_input.get_selected_id()
var resolution_id: int = resolution_input.get_selected_id()
var window_mode_id: int = window_mode_input.get_selected_id()
GameSettingsManager.graphics_resolution_changed.emit(Vector2i(values[0], values[1]), id)
GameSettingsManager.graphics_fullscreen_changed.emit(fullscreen_input.button_pressed)
GameSettingsManager.graphics_resolution_changed.emit(Vector2i(values[0], values[1]), resolution_id)
GameSettingsManager.graphics_window_mode_changed.emit(window_mode_id)
GameSettingsManager.graphics_vsync_changed.emit(vsync_input.button_pressed)
GameSettingsManager.apply_graphics_settings.emit()
#endregion
@ -83,4 +98,4 @@ func _on_graphics_apply_button_pressed() -> void:
func _on_close_button_pressed() -> void:
SignalManager.resume_game.emit()
pause_menu.open_menu.emit("MainMenu")

+ 1
- 0
scenes/ui/pause_menu/settings_menu.gd.uid View File

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

+ 240
- 0
scenes/ui/pause_menu/settings_menu.tscn View File

@ -0,0 +1,240 @@
[gd_scene load_steps=4 format=3 uid="uid://uwlutbmfp8dv"]
[ext_resource type="Script" uid="uid://ccei1q7fb022x" path="res://scenes/ui/pause_menu/settings_menu.gd" id="1_govsn"]
[ext_resource type="PackedScene" uid="uid://4itp2hjp14n2" path="res://scenes/ui/pause_menu/base_menu.tscn" id="1_oec81"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_830fb"]
content_margin_left = 10.0
content_margin_top = 10.0
content_margin_right = 10.0
content_margin_bottom = 10.0
bg_color = Color(0, 0, 0, 0.27451)
corner_radius_top_left = 2
corner_radius_top_right = 2
corner_radius_bottom_right = 2
corner_radius_bottom_left = 2
[node name="SettingsMenu" node_paths=PackedStringArray("autosaves_input", "block_highlight_input", "held_block_ui_input", "quick_slots_ui_input", "screenshot_icon_input", "waila_input", "fov_slider", "fov_value_label", "resolution_input", "vsync_input", "window_mode_input") instance=ExtResource("1_oec81")]
visible = false
script = ExtResource("1_govsn")
autosaves_input = NodePath("MainContent/MenuContainer/TabContainer/Game/Autosaves/CheckButton")
block_highlight_input = NodePath("MainContent/MenuContainer/TabContainer/Game/BlockHighlight/CheckButton")
held_block_ui_input = NodePath("MainContent/MenuContainer/TabContainer/Game/HeldBlockUI/CheckButton")
quick_slots_ui_input = NodePath("MainContent/MenuContainer/TabContainer/Game/QuickslotsUI/CheckButton")
screenshot_icon_input = NodePath("MainContent/MenuContainer/TabContainer/Game/ScreenshotIcon/CheckButton")
waila_input = NodePath("MainContent/MenuContainer/TabContainer/Game/Waila/CheckButton")
fov_slider = NodePath("MainContent/MenuContainer/TabContainer/Graphics/FOV/HSlider")
fov_value_label = NodePath("MainContent/MenuContainer/TabContainer/Graphics/FOV/Value")
resolution_input = NodePath("MainContent/MenuContainer/TabContainer/Graphics/Resolution/OptionButton")
vsync_input = NodePath("MainContent/MenuContainer/TabContainer/Graphics/VSync/CheckBox")
window_mode_input = NodePath("MainContent/MenuContainer/TabContainer/Graphics/WindowMode/OptionButton")
[node name="Title" parent="MainContent/MenuContainer" index="0"]
text = "Settings"
[node name="TabContainer" type="TabContainer" parent="MainContent/MenuContainer" index="1"]
layout_mode = 2
theme_override_constants/side_margin = 0
theme_override_styles/panel = SubResource("StyleBoxFlat_830fb")
current_tab = 0
clip_tabs = false
[node name="Game" type="VBoxContainer" parent="MainContent/MenuContainer/TabContainer" index="1"]
layout_mode = 2
metadata/_tab_index = 0
[node name="BlockHighlight" type="HBoxContainer" parent="MainContent/MenuContainer/TabContainer/Game" index="0"]
layout_mode = 2
[node name="Label" type="Label" parent="MainContent/MenuContainer/TabContainer/Game/BlockHighlight" index="0"]
layout_mode = 2
size_flags_horizontal = 3
text = "Enable Block Highlighting"
[node name="CheckButton" type="CheckButton" parent="MainContent/MenuContainer/TabContainer/Game/BlockHighlight" index="1"]
layout_mode = 2
button_pressed = true
[node name="Waila" type="HBoxContainer" parent="MainContent/MenuContainer/TabContainer/Game" index="1"]
layout_mode = 2
[node name="Label" type="Label" parent="MainContent/MenuContainer/TabContainer/Game/Waila" index="0"]
layout_mode = 2
size_flags_horizontal = 3
text = "Enable Waila"
[node name="CheckButton" type="CheckButton" parent="MainContent/MenuContainer/TabContainer/Game/Waila" index="1"]
layout_mode = 2
button_pressed = true
[node name="QuickslotsUI" type="HBoxContainer" parent="MainContent/MenuContainer/TabContainer/Game" index="2"]
layout_mode = 2
[node name="Label" type="Label" parent="MainContent/MenuContainer/TabContainer/Game/QuickslotsUI" index="0"]
layout_mode = 2
size_flags_horizontal = 3
text = "Enable Quickslots UI"
[node name="CheckButton" type="CheckButton" parent="MainContent/MenuContainer/TabContainer/Game/QuickslotsUI" index="1"]
layout_mode = 2
button_pressed = true
[node name="HeldBlockUI" type="HBoxContainer" parent="MainContent/MenuContainer/TabContainer/Game" index="3"]
layout_mode = 2
[node name="Label" type="Label" parent="MainContent/MenuContainer/TabContainer/Game/HeldBlockUI" index="0"]
layout_mode = 2
size_flags_horizontal = 3
text = "Enable Player Held Block"
[node name="CheckButton" type="CheckButton" parent="MainContent/MenuContainer/TabContainer/Game/HeldBlockUI" index="1"]
layout_mode = 2
button_pressed = true
[node name="ScreenshotIcon" type="HBoxContainer" parent="MainContent/MenuContainer/TabContainer/Game" index="4"]
layout_mode = 2
[node name="Label" type="Label" parent="MainContent/MenuContainer/TabContainer/Game/ScreenshotIcon" index="0"]
layout_mode = 2
size_flags_horizontal = 3
tooltip_text = "Enable/Disable the taking of a screenshot to utilize as the save icon."
mouse_filter = 1
text = "Enable Save Screenshot"
[node name="CheckButton" type="CheckButton" parent="MainContent/MenuContainer/TabContainer/Game/ScreenshotIcon" index="1"]
layout_mode = 2
tooltip_text = "Enable/Disable the taking of a screenshot to utilize as the save icon."
button_pressed = true
[node name="Autosaves" type="HBoxContainer" parent="MainContent/MenuContainer/TabContainer/Game" index="5"]
layout_mode = 2
[node name="Label" type="Label" parent="MainContent/MenuContainer/TabContainer/Game/Autosaves" index="0"]
layout_mode = 2
size_flags_horizontal = 3
tooltip_text = "Enable/Disable the taking of a screenshot to utilize as the save icon."
mouse_filter = 1
text = "Enable Autosaves"
[node name="CheckButton" type="CheckButton" parent="MainContent/MenuContainer/TabContainer/Game/Autosaves" index="1"]
layout_mode = 2
tooltip_text = "Enable/Disable the taking of a screenshot to utilize as the save icon."
button_pressed = true
[node name="Graphics" type="VBoxContainer" parent="MainContent/MenuContainer/TabContainer" index="2"]
visible = false
layout_mode = 2
metadata/_tab_index = 1
[node name="Resolution" type="HBoxContainer" parent="MainContent/MenuContainer/TabContainer/Graphics" index="0"]
layout_mode = 2
[node name="Label" type="Label" parent="MainContent/MenuContainer/TabContainer/Graphics/Resolution" index="0"]
layout_mode = 2
size_flags_horizontal = 3
text = "Resolution"
[node name="OptionButton" type="OptionButton" parent="MainContent/MenuContainer/TabContainer/Graphics/Resolution" index="1"]
layout_mode = 2
selected = 0
item_count = 6
popup/item_0/text = "1280x720"
popup/item_0/id = 0
popup/item_1/text = "1280x800"
popup/item_1/id = 4
popup/item_2/text = "1920x1080"
popup/item_2/id = 1
popup/item_3/text = "2560x1440"
popup/item_3/id = 2
popup/item_4/text = "3440x1440"
popup/item_4/id = 3
popup/item_5/text = "3840 x 2160"
popup/item_5/id = 5
[node name="WindowMode" type="HBoxContainer" parent="MainContent/MenuContainer/TabContainer/Graphics" index="1"]
layout_mode = 2
[node name="Label" type="Label" parent="MainContent/MenuContainer/TabContainer/Graphics/WindowMode" index="0"]
layout_mode = 2
size_flags_horizontal = 3
text = "Display Mode"
[node name="OptionButton" type="OptionButton" parent="MainContent/MenuContainer/TabContainer/Graphics/WindowMode" index="1"]
layout_mode = 2
item_count = 4
popup/item_0/text = "Window"
popup/item_0/id = 0
popup/item_1/text = "Maximized"
popup/item_1/id = 2
popup/item_2/text = "Fullscreen"
popup/item_2/id = 3
popup/item_3/text = "Exclusive Fullscreen"
popup/item_3/id = 4
[node name="VSync" type="HBoxContainer" parent="MainContent/MenuContainer/TabContainer/Graphics" index="2"]
layout_mode = 2
[node name="Label" type="Label" parent="MainContent/MenuContainer/TabContainer/Graphics/VSync" index="0"]
layout_mode = 2
size_flags_horizontal = 3
text = "VSync"
[node name="CheckBox" type="CheckBox" parent="MainContent/MenuContainer/TabContainer/Graphics/VSync" index="1"]
layout_mode = 2
[node name="FOV" type="HBoxContainer" parent="MainContent/MenuContainer/TabContainer/Graphics" index="3"]
layout_mode = 2
[node name="Label" type="Label" parent="MainContent/MenuContainer/TabContainer/Graphics/FOV" index="0"]
layout_mode = 2
size_flags_horizontal = 3
text = "FOV"
[node name="HSlider" type="HSlider" parent="MainContent/MenuContainer/TabContainer/Graphics/FOV" index="1"]
layout_mode = 2
size_flags_horizontal = 3
min_value = 60.0
max_value = 120.0
value = 75.0
rounded = true
ticks_on_borders = true
[node name="Value" type="Label" parent="MainContent/MenuContainer/TabContainer/Graphics/FOV" index="2"]
layout_mode = 2
text = "75"
[node name="HSeparator" type="HSeparator" parent="MainContent/MenuContainer/TabContainer/Graphics" index="4"]
layout_mode = 2
theme_override_constants/separation = 20
[node name="CenterContainer" type="CenterContainer" parent="MainContent/MenuContainer/TabContainer/Graphics" index="5"]
layout_mode = 2
[node name="ApplyButton" type="Button" parent="MainContent/MenuContainer/TabContainer/Graphics/CenterContainer" index="0"]
layout_mode = 2
text = "Apply/Save"
[node name="Audio" type="VBoxContainer" parent="MainContent/MenuContainer/TabContainer" index="3"]
visible = false
layout_mode = 2
metadata/_tab_index = 2
[node name="Inputs" type="VBoxContainer" parent="MainContent/MenuContainer/TabContainer" index="4"]
visible = false
layout_mode = 2
metadata/_tab_index = 3
[node name="CloseButton" type="Button" parent="BottomRow" index="0"]
custom_minimum_size = Vector2(141, 36)
layout_mode = 2
text = "Close Settings"
[connection signal="toggled" from="MainContent/MenuContainer/TabContainer/Game/BlockHighlight/CheckButton" to="." method="_on_block_highlighting_toggled"]
[connection signal="toggled" from="MainContent/MenuContainer/TabContainer/Game/Waila/CheckButton" to="." method="_on_enable_waila_toggled"]
[connection signal="toggled" from="MainContent/MenuContainer/TabContainer/Game/QuickslotsUI/CheckButton" to="." method="_on_quickslots_ui_toggled"]
[connection signal="toggled" from="MainContent/MenuContainer/TabContainer/Game/HeldBlockUI/CheckButton" to="." method="_on_held_block_ui_toggled"]
[connection signal="toggled" from="MainContent/MenuContainer/TabContainer/Game/ScreenshotIcon/CheckButton" to="." method="_on_screenshot_icon_button_toggled"]
[connection signal="toggled" from="MainContent/MenuContainer/TabContainer/Game/Autosaves/CheckButton" to="." method="_on_autosaves_button_toggled"]
[connection signal="value_changed" from="MainContent/MenuContainer/TabContainer/Graphics/FOV/HSlider" to="." method="_on_fov_slider_changed"]
[connection signal="pressed" from="MainContent/MenuContainer/TabContainer/Graphics/CenterContainer/ApplyButton" to="." method="_on_graphics_apply_button_pressed"]
[connection signal="pressed" from="BottomRow/CloseButton" to="." method="_on_close_button_pressed"]

+ 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")

+ 29
- 49
scenes/ui/ui.gd View File

@ -5,82 +5,62 @@ extends CanvasLayer
@onready var crosshair: CenterContainer = $Crosshair
@onready var quick_slots: MarginContainer = $QuickSlots
@onready var pause_menu: PauseMenu = $PauseMenu
@onready var save_load_ui: SaveLoadUI = $SaveLoadUI
@onready var settings_menu: SettingsMenu = $SettingsMenu
@onready var waila: Waila = $Waila
func _ready() -> void:
SignalManager.close_pause_menu.connect(_on_close_pause_menu)
SignalManager.open_pause_menu.connect(_on_open_pause_menu)
SignalManager.close_settings_menu.connect(_on_close_settings_menu)
SignalManager.open_settings_menu.connect(_on_open_settings_menu)
SignalManager.resume_game.connect(_on_resume_game)
save_load_ui.close_save_list.connect(_on_close_save_list_ui)
save_load_ui.open_save_list.connect(_on_open_save_list_ui)
SaveGameManager.load_complete.connect(_on_load_complete)
SignalManager.pause_game.connect(_on_pause_game)
SignalManager.resume_game.connect(_on_resume_game)
SignalManager.hide_ui.connect(_on_hide_ui)
SignalManager.show_ui.connect(_on_show_ui)
_on_resume_game()
resume_game()
func hide_menus() -> void:
pause_menu.visible = false
settings_menu.visible = false
save_load_ui.visible = false
func show_menus() -> void:
pause_menu.visible = true
func hide_ui_elements() -> void:
crosshair.visible = false
quick_slots.visible = false
waila.visible = false
func show_ui_elements() -> void:
crosshair.visible = true
quick_slots.visible = true and GameSettingsManager.settings.game_options.enable_quickslots_ui
waila.visible = true and GameSettingsManager.settings.game_options.enable_waila
func _on_close_pause_menu() -> void:
SignalManager.resume_game.emit()
func _on_close_save_list_ui() -> void:
SignalManager.open_settings_menu.emit()
func _on_close_settings_menu() -> void:
SignalManager.resume_game.emit()
func _on_load_complete() -> void:
_on_resume_game()
func _on_open_pause_menu() -> void:
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
hide_ui_elements()
hide_menus()
pause_menu.visible = true
func pause_game() -> void:
show_menus()
get_tree().paused = true
func _on_open_save_list_ui() -> void:
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
hide_ui_elements()
func resume_game() -> void:
hide_menus()
save_load_ui.visible = true
show_ui_elements()
get_tree().paused = true
get_tree().paused = false
func _on_open_settings_menu() -> void:
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
hide_ui_elements()
hide_menus()
settings_menu.visible = true
func _on_load_complete() -> void:
resume_game()
get_tree().paused = true
func _on_pause_game() -> void:
pause_game()
func _on_resume_game() -> void:
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
resume_game()
func _on_hide_ui() -> void:
hide_menus()
crosshair.visible = true
quick_slots.visible = true and GameSettingsManager.settings.game_options.enable_quickslots_ui
waila.visible = true
hide_ui_elements()
get_tree().paused = false
func _on_show_ui() -> void:
show_ui_elements()

+ 7
- 13
scenes/ui/ui.tscn View File

@ -1,12 +1,11 @@
[gd_scene load_steps=8 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://bopvfwcgnnawg" path="res://scenes/ui/menus/pause_menu.tscn" id="6_7vp6q"]
[ext_resource type="PackedScene" uid="uid://4bdgwwx27m71" path="res://scenes/ui/menus/settings_menu.tscn" id="7_7vp6q"]
[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"]
[ext_resource type="PackedScene" uid="uid://dauchkhmnyk7n" path="res://scenes/ui/menus/saves_manager/save_load_ui.tscn" id="8_jcn1r"]
[node name="UI" type="CanvasLayer"]
script = ExtResource("1_aac20")
@ -32,16 +31,11 @@ mouse_filter = 2
[node name="QuickSlots" parent="." instance=ExtResource("4_g5kmx")]
[node name="PauseMenu" parent="." node_paths=PackedStringArray("save_load_ui") instance=ExtResource("6_7vp6q")]
visible = false
save_load_ui = NodePath("../SaveLoadUI")
[node name="SettingsMenu" parent="." instance=ExtResource("7_7vp6q")]
[node name="AutosaveNotification" parent="." instance=ExtResource("7_jcn1r")]
visible = false
[node name="SaveLoadUI" parent="." node_paths=PackedStringArray("ui_node") instance=ExtResource("8_jcn1r")]
[node name="PauseMenu" parent="." instance=ExtResource("5_0dwhk")]
visible = false
ui_node = NodePath("..")
[node name="AutosaveNotification" parent="." instance=ExtResource("7_jcn1r")]
[node name="Inventory" parent="." instance=ExtResource("6_pfayw")]
visible = false

+ 2
- 2
scenes/world/world.gd View File

@ -64,14 +64,14 @@ func spawn_player(player_position: Transform3D) -> void:
func _create_block(id: String, block_position: Vector3) -> void:
var block: Block = Globals.BLOCK_PREFAB.instantiate()
var block: Block = Block.PREFAB.instantiate()
block.position = block_position
block.set_id(id)
blocks_container.add_child(block)
func _create_dropped_block(id: String, start_position: Vector3, direction: Vector3 = Vector3.ZERO, velocity: float = 0.0) -> void:
var block: DroppedBlock = Globals.DROPPED_BLOCK_PREFAB.instantiate()
var block: DroppedBlock = DroppedBlock.PREFAB.instantiate()
dropped_items_container.add_child(block)
block.initialize(id, start_position, direction, velocity)


+ 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