shift click items across inventories
This commit is contained in:
parent
c05f2c703b
commit
64d6e72407
15 changed files with 94 additions and 5 deletions
|
|
@ -9,6 +9,7 @@
|
|||
- [ ] crafting system (3x3 inventory with shaped recipies)
|
||||
- [x] loot system (provides random assortment of items from the ewaste bin)
|
||||
- [ ] selling things
|
||||
- [ ] shift click items to move to other inventory?
|
||||
|
||||
Submission day: Jan 19th 8AM
|
||||
|
||||
|
|
|
|||
5
crafting/craft_recipe.gd
Normal file
5
crafting/craft_recipe.gd
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
extends Resource
|
||||
class_name CraftRecipe
|
||||
|
||||
@export var ingredients : Array[ItemData] = [null,null,null,null,null,null,null,null,null]
|
||||
@export var output : ItemData
|
||||
1
crafting/craft_recipe.gd.uid
Normal file
1
crafting/craft_recipe.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://b4iu5xrdf0evs
|
||||
12
crafting/crafts/computer_craft.tres
Normal file
12
crafting/crafts/computer_craft.tres
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
[gd_resource type="Resource" script_class="CraftRecipe" load_steps=6 format=3 uid="uid://dp4hnei3ur6oe"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dccraom7a7e8d" path="res://inv_system/item_data.gd" id="1_ayiw2"]
|
||||
[ext_resource type="Script" uid="uid://b4iu5xrdf0evs" path="res://crafting/craft_recipe.gd" id="2_2p7jb"]
|
||||
[ext_resource type="Resource" uid="uid://88v5bcyrgpob" path="res://items/large_psu_item.tres" id="2_egxug"]
|
||||
[ext_resource type="Resource" uid="uid://bepkdyf7dn1y0" path="res://items/hdd_item.tres" id="3_ccdvw"]
|
||||
[ext_resource type="Resource" uid="uid://c2wbqelme8vy1" path="res://items/ram_item.tres" id="4_tkhhn"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("2_2p7jb")
|
||||
ingredients = Array[ExtResource("1_ayiw2")]([ExtResource("2_egxug"), ExtResource("4_tkhhn"), ExtResource("3_ccdvw"), null, null, null, null, null, null])
|
||||
metadata/_custom_type_script = "uid://b4iu5xrdf0evs"
|
||||
6
crafting/scavenge_recipe.gd
Normal file
6
crafting/scavenge_recipe.gd
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
extends Resource
|
||||
class_name ScavengeRecipe
|
||||
|
||||
@export var input : ItemData
|
||||
@export var rolls : int = 3
|
||||
@export var loot_pool : Dictionary[int, ItemData]
|
||||
1
crafting/scavenge_recipe.gd.uid
Normal file
1
crafting/scavenge_recipe.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://boqr1fowaqmt0
|
||||
|
|
@ -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,7 +27,12 @@ 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():
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
||||
|
|
|
|||
31
mouseTweaks.gd
Normal file
31
mouseTweaks.gd
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
extends Node
|
||||
|
||||
var hovered_slot : ItemSlot
|
||||
var player_inventory : Inventory
|
||||
var other_inventory : Inventory
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
if Input.is_action_just_pressed("quick_move") and hovered_slot:
|
||||
# figure out what the "other" inventory is and move it
|
||||
var current_inv : String = hovered_slot.type
|
||||
var target_inv : Inventory
|
||||
if current_inv != "Inventory":
|
||||
target_inv = player_inventory
|
||||
else:
|
||||
target_inv = other_inventory
|
||||
|
||||
var temp_item : ItemData = hovered_slot.item
|
||||
|
||||
|
||||
if target_inv.add_item(temp_item):
|
||||
# only runs if it was able to put the item in the target inv
|
||||
hovered_slot.item = null
|
||||
hovered_slot.update_ui()
|
||||
|
||||
pass
|
||||
1
mouseTweaks.gd.uid
Normal file
1
mouseTweaks.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://dvam042pcmjig
|
||||
|
|
@ -20,6 +20,7 @@ config/icon="res://icon.svg"
|
|||
Tooltip="*res://tooltip.tscn"
|
||||
PlayerInventory="*res://inv_system/player_inventory.tscn"
|
||||
Clock="*res://time_system/clock.tscn"
|
||||
MouseTweaks="*res://mouseTweaks.gd"
|
||||
|
||||
[display]
|
||||
|
||||
|
|
@ -33,6 +34,14 @@ movie_writer/ogv/keyframe_interval=128
|
|||
movie_writer/movie_file="C:/Users/tabby/Documents/Godot/Projects/RepurposedJam/video.avi"
|
||||
movie_writer/fps=30
|
||||
|
||||
[input]
|
||||
|
||||
quick_move={
|
||||
"deadzone": 0.2,
|
||||
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":true,"ctrl_pressed":false,"meta_pressed":false,"button_mask":1,"position":Vector2(218, 14),"global_position":Vector2(226, 57),"factor":1.0,"button_index":1,"canceled":false,"pressed":true,"double_click":false,"script":null)
|
||||
]
|
||||
}
|
||||
|
||||
[rendering]
|
||||
|
||||
renderer/rendering_method="gl_compatibility"
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
[sub_resource type="LabelSettings" id="LabelSettings_00tp4"]
|
||||
font_color = Color(1, 0, 0, 0.5764706)
|
||||
|
||||
[node name="Control" type="Control" node_paths=PackedStringArray("bin_inventory", "loot_button")]
|
||||
[node name="ewaste" type="Control" node_paths=PackedStringArray("bin_inventory", "loot_button")]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
|
|
@ -48,6 +48,7 @@ offset_right = 1066.0
|
|||
offset_bottom = 587.0
|
||||
script = ExtResource("1_6uqi0")
|
||||
inventory_name = "E-waste Recycling Bin"
|
||||
type = "Loot"
|
||||
grid = NodePath("MarginContainer/VBoxContainer/ScrollContainer/GridContainer")
|
||||
inv_label = NodePath("MarginContainer/VBoxContainer/Label")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue