summaryrefslogtreecommitdiff
path: root/addons/escoria-wizard/item_creator.gd
diff options
context:
space:
mode:
authorradiohotline <radoihotline@disroot.rg>2026-08-25 16:33:56 +0300
committerradiohotline <radoihotline@disroot.rg>2026-08-25 16:33:56 +0300
commita89e744ed0e8c759caf041a580112365bbfe4303 (patch)
treedd61e320904176995727e86a857d00c90d4933ba /addons/escoria-wizard/item_creator.gd
parent6d53d8cac78250dc888aa49d5f9d4175c6652feb (diff)
escoria updateHEADmain
Diffstat (limited to 'addons/escoria-wizard/item_creator.gd')
-rw-r--r--addons/escoria-wizard/item_creator.gd45
1 files changed, 28 insertions, 17 deletions
diff --git a/addons/escoria-wizard/item_creator.gd b/addons/escoria-wizard/item_creator.gd
index 6a279b8..93b08ce 100644
--- a/addons/escoria-wizard/item_creator.gd
+++ b/addons/escoria-wizard/item_creator.gd
@@ -1,3 +1,6 @@
+# gdlint:disable=function-name
+# gdlint:disable=no-else-return
+# TODO: Fix this file's legacy lint violations and remove the gdlint disables above.
@tool
extends MarginContainer
@@ -36,27 +39,29 @@ var preview_size:Vector2
# Called when the node enters the scene tree for the first time.
+
func _ready() -> void:
# Capture the size of the window before we update its contents so we have
# the absolute size before it gets scaled contents applied to it
- preview_size = get_node(PREVIEW_NODE).size
+ preview_size = get_node(PREVIEW_NODE).get_size()
inventory_mode = not get_node(BACKGROUND_OBJ_NODE).pressed
+
+ var action_option: OptionButton = get_node(ACTION_NODE)
+ action_option.clear()
+ for option_list in ["", "look", "pick up", "open", "close", "use", "push", "pull", "talk"]:
+ action_option.add_item(option_list)
+
item_creator_reset()
+
func item_creator_reset() -> void:
get_node(ITEM_NAME_NODE).text = "replace_me"
get_node(GLOBAL_ID_NODE).text = ""
get_node(IMAGE_PATH_NODE).text = ""
get_node(INTERACTIVE_NODE).button_pressed = true
-
- if get_node(ACTION_NODE).get_item_count() > 0:
- get_node(ACTION_NODE).clear()
-
- for option_list in ["look", "pick up", "open", "close", "use", "push", "pull", "talk"]:
- get_node(ACTION_NODE).add_item(option_list)
-
get_node(ACTION_NODE).selected = 0
+
image_size = Vector2.ZERO
image_has_been_loaded = false
main_menu_requested = false
@@ -91,9 +96,10 @@ func resize_image() -> void:
# Calculate the scale to make the preview as big as possible in the preview window depending on
# the height to width ratio of the frame
image_size = image_stream_texture.get_size()
+
var preview_scale = Vector2.ONE
- preview_scale.x = preview_size.x / image_size.x
- preview_scale.y = preview_size.y / image_size.y
+ preview_scale.x = clampf(preview_size.x / image_size.x, 0, 1)
+ preview_scale.y = clampf(preview_size.y / image_size.y, 0, 1)
if preview_scale.y > preview_scale.x:
get_node(PREVIEW_NODE).scale = Vector2(preview_scale.x, preview_scale.x)
@@ -110,12 +116,17 @@ func load_button_pressed() -> void:
func LoadObjectFileDialog_file_selected(path: String) -> void:
- image_stream_texture = load(path)
-
- get_node(PREVIEW_NODE).texture = image_stream_texture
+ var loaded_texture := load(path) as CompressedTexture2D
+ if loaded_texture == null:
+ get_node(ERROR_WINDOW_NODE).dialog_text = "Failed to load image: %s" % path
+ get_node(ERROR_WINDOW_NODE).popup_centered()
+ return
+ image_stream_texture = loaded_texture
resize_image()
+ get_node(PREVIEW_NODE).texture = image_stream_texture
+
get_node(IMAGE_SIZE_NODE).text = "(%s, %s)" % [image_size.x, image_size.y]
get_node(IMAGE_PATH_NODE).text = path
@@ -155,17 +166,17 @@ func _on_CreateButton_pressed() -> void:
var item = ESCItem.new()
item.name = get_node(ITEM_NAME_NODE).text
item.global_id = get_node(GLOBAL_ID_NODE).text
- item.is_interactive = get_node(INTERACTIVE_NODE).pressed
+ item.is_interactive = get_node(INTERACTIVE_NODE).button_pressed
item.tooltip_name = get_node(ITEM_NAME_NODE).text
var selected_index = get_node(ACTION_NODE).selected
item.default_action = get_node(ACTION_NODE).get_item_text(selected_index)
- # Make the item by default it's usable straight out of the inventory
+ # Make the item use a second target object by default when used from inventory.
if inventory_mode == true:
- var new_pool_array: PackedStringArray = item.combine_when_selected_action_is_in
+ var new_pool_array: PackedStringArray = item.actions_requiring_target_object
new_pool_array.append("use")
- item.combine_when_selected_action_is_in = new_pool_array
+ item.actions_requiring_target_object = new_pool_array
# Add Dialog Position to the background item
var interact_position = ESCLocation.new()