shift click items across inventories
This commit is contained in:
parent
c05f2c703b
commit
64d6e72407
15 changed files with 94 additions and 5 deletions
|
|
@ -1,6 +1,7 @@
|
|||
extends Inventory
|
||||
|
||||
@export var action_button : Button
|
||||
@export var craft_recipes : Array[CraftRecipe]
|
||||
#@export var no_style : StyleBox
|
||||
@export var assemble_style : StyleBox
|
||||
@export var assemble_style_hover : StyleBox
|
||||
|
|
@ -26,9 +27,14 @@ func _process(delta: float) -> void:
|
|||
func _notification(what: int) -> void:
|
||||
super(what)
|
||||
if what == Node.NOTIFICATION_DRAG_END:
|
||||
# check against recipies!
|
||||
check_recipes()
|
||||
pass
|
||||
|
||||
func check_recipes():
|
||||
print("checking now")
|
||||
# write checking logic
|
||||
pass
|
||||
|
||||
func style_assemble():
|
||||
action_button.add_theme_stylebox_override("normal",assemble_style)
|
||||
action_button.add_theme_stylebox_override("hover",assemble_style_hover)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
[gd_scene load_steps=7 format=3 uid="uid://f06ym5ujhdsc"]
|
||||
[gd_scene load_steps=9 format=3 uid="uid://f06ym5ujhdsc"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://br4fgimf7nygr" path="res://inv_system/crafting_panel.gd" id="1_441s3"]
|
||||
[ext_resource type="PackedScene" uid="uid://dgqs20xf7l8c" path="res://inv_system/item_slot.tscn" id="2_h0v0h"]
|
||||
[ext_resource type="Script" uid="uid://b4iu5xrdf0evs" path="res://crafting/craft_recipe.gd" id="2_ytbts"]
|
||||
[ext_resource type="Resource" uid="uid://dp4hnei3ur6oe" path="res://crafting/crafts/computer_craft.tres" id="3_4h4i0"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_h0v0h"]
|
||||
content_margin_left = 0.0
|
||||
|
|
@ -82,6 +84,7 @@ offset_right = 962.0
|
|||
offset_bottom = 382.0
|
||||
script = ExtResource("1_441s3")
|
||||
action_button = NodePath("MarginContainer/VBoxContainer/ActionButton")
|
||||
craft_recipes = Array[ExtResource("2_ytbts")]([ExtResource("3_4h4i0")])
|
||||
assemble_style = SubResource("StyleBoxFlat_h0v0h")
|
||||
assemble_style_hover = SubResource("StyleBoxFlat_441s3")
|
||||
assemble_style_pressed = SubResource("StyleBoxFlat_h0v0h")
|
||||
|
|
@ -89,6 +92,7 @@ scavenge_style = SubResource("StyleBoxFlat_ytbts")
|
|||
scavenge_style_hover = SubResource("StyleBoxFlat_4h4i0")
|
||||
scavenge_style_pressed = SubResource("StyleBoxFlat_ytbts")
|
||||
inventory_name = "Workbench"
|
||||
type = "Crafting"
|
||||
grid = NodePath("MarginContainer/VBoxContainer/ScrollContainer/GridContainer")
|
||||
inv_label = NodePath("MarginContainer/VBoxContainer/Label")
|
||||
|
||||
|
|
|
|||
|
|
@ -3,14 +3,22 @@ class_name Inventory
|
|||
|
||||
@export var inventory_name : String = "Inventory"
|
||||
@export var slots : Array[ItemSlot]
|
||||
@export var type: String
|
||||
@export_group("Node References")
|
||||
@export var grid : GridContainer
|
||||
@export var inv_label : Label
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
slots.assign(grid.get_children())
|
||||
inv_label.text = inventory_name
|
||||
for slot in slots:
|
||||
slot.type = type
|
||||
if type == "Inventory":
|
||||
MouseTweaks.player_inventory = self
|
||||
else:
|
||||
MouseTweaks.other_inventory = self
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
|
|
@ -38,5 +46,3 @@ func add_item(item : ItemData) -> bool:
|
|||
return true # item placed successfully
|
||||
return false # theres no space to add the item
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ class_name ItemSlot
|
|||
@export var icon : TextureRect
|
||||
@export var item: ItemData
|
||||
@export var label : Label
|
||||
var type : String
|
||||
|
||||
func _ready() -> void:
|
||||
update_ui()
|
||||
|
|
@ -19,6 +20,7 @@ func update_ui():
|
|||
label.text = item.value
|
||||
|
||||
|
||||
|
||||
func _get_drag_data(at_position: Vector2) -> Variant:
|
||||
if not item:
|
||||
return
|
||||
|
|
@ -51,9 +53,11 @@ func _on_mouse_entered() -> void:
|
|||
#print("im real?")
|
||||
if item:
|
||||
Tooltip.show_tip(item.item_name)
|
||||
MouseTweaks.hovered_slot = self
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
func _on_mouse_exited() -> void:
|
||||
Tooltip.hide_tip()
|
||||
MouseTweaks.hovered_slot = null
|
||||
pass # Replace with function body.
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ offset_right = 419.0
|
|||
offset_bottom = 561.0
|
||||
script = ExtResource("2_hk4hx")
|
||||
inventory_name = "Your Inventory"
|
||||
type = "Inventory"
|
||||
grid = NodePath("MarginContainer/VBoxContainer/ScrollContainer/GridContainer")
|
||||
inv_label = NodePath("MarginContainer/VBoxContainer/Label")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue