Inventory now interactive
This commit is contained in:
parent
0a1ea67500
commit
8c9cc7e31d
36
MiscCodes/Inventory.gd
Normal file
36
MiscCodes/Inventory.gd
Normal file
@ -0,0 +1,36 @@
|
||||
extends Node2D
|
||||
|
||||
# Many thanks to Arkeve! https://github.com/arkeve
|
||||
|
||||
const SlotClass = preload("res://MiscCodes/Slot.gd")
|
||||
onready var inventory_slots = $GridContainer
|
||||
var holding_item = null
|
||||
|
||||
func _ready():
|
||||
for inv_slot in inventory_slots.get_children():
|
||||
inv_slot.connect("gui_input", self, "slot_gui_input", [inv_slot])
|
||||
|
||||
func slot_gui_input(event: InputEvent, slot: SlotClass):
|
||||
if event is InputEventMouseButton:
|
||||
if event.button_index == BUTTON_LEFT && event.pressed:
|
||||
if holding_item != null:
|
||||
if !slot.item: # Place holding item to slot
|
||||
slot.putIntoSlot(holding_item)
|
||||
holding_item = null
|
||||
else: # Swap holding item with item in slot
|
||||
var temp_item = slot.item
|
||||
slot.pickFromSlot()
|
||||
temp_item.global_position = event.global_position
|
||||
slot.putIntoSlot(holding_item)
|
||||
holding_item = temp_item
|
||||
elif slot.item:
|
||||
holding_item = slot.item
|
||||
slot.pickFromSlot()
|
||||
holding_item.global_position = get_global_mouse_position()
|
||||
|
||||
func _input(event):
|
||||
if holding_item:
|
||||
holding_item.global_position = get_global_mouse_position()
|
||||
|
||||
func _on_TouchScreenButton_pressed():
|
||||
get_tree().change_scene("res://river_intersection_home2.tscn")
|
@ -1,7 +1,7 @@
|
||||
extends Node2D
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
# Many thanks to Arkeve! https://github.com/arkeve
|
||||
|
||||
func _ready():
|
||||
if randi() % 3 == 0:
|
||||
$TextureRect.texture = load("res://pictures/inventory_iconpictures/miscellaneous/magic_formulae.png")
|
||||
|
@ -1,5 +1,7 @@
|
||||
extends Panel
|
||||
|
||||
#Many thanks to Arkeve! https://github.com/arkeve
|
||||
|
||||
#var default_tex = preload("res://item_slot_default_background.png")
|
||||
#var empty_tex = preload("res://item_slot_empty_background.png")
|
||||
|
||||
|
@ -1,19 +1,17 @@
|
||||
[gd_scene load_steps=5 format=2]
|
||||
[gd_scene load_steps=7 format=2]
|
||||
|
||||
[ext_resource path="res://pictures/gui/backgrounds/inventory/inventory_background.png" type="Texture" id=1]
|
||||
[ext_resource path="res://pictures/gui/backgrounds/inventory/item_slot.png" type="Texture" id=2]
|
||||
[ext_resource path="res://MiscCodes/Slot.gd" type="Script" id=3]
|
||||
[ext_resource path="res://MiscCodes/Inventory.gd" type="Script" id=4]
|
||||
[ext_resource path="res://pictures/gui/buttons/no_button.png" type="Texture" id=5]
|
||||
|
||||
[sub_resource type="StyleBoxTexture" id=1]
|
||||
texture = ExtResource( 2 )
|
||||
region_rect = Rect2( 0, 0, 72, 72 )
|
||||
|
||||
[node name="Inventory" type="Control"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
[node name="Inventory" type="Node2D"]
|
||||
script = ExtResource( 4 )
|
||||
|
||||
[node name="Background" type="TextureRect" parent="."]
|
||||
margin_right = 1234.0
|
||||
@ -28,7 +26,7 @@ __meta__ = {
|
||||
margin_left = 30.0
|
||||
margin_right = 1228.0
|
||||
margin_bottom = 656.0
|
||||
columns = 9
|
||||
columns = 8
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
@ -97,209 +95,183 @@ custom_styles/panel = SubResource( 1 )
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="Slot9" type="Panel" parent="GridContainer"]
|
||||
margin_left = 1056.0
|
||||
margin_right = 1184.0
|
||||
margin_bottom = 128.0
|
||||
margin_top = 132.0
|
||||
margin_right = 128.0
|
||||
margin_bottom = 260.0
|
||||
rect_min_size = Vector2( 128, 128 )
|
||||
custom_styles/panel = SubResource( 1 )
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="Slot10" type="Panel" parent="GridContainer"]
|
||||
margin_left = 132.0
|
||||
margin_top = 132.0
|
||||
margin_right = 128.0
|
||||
margin_right = 260.0
|
||||
margin_bottom = 260.0
|
||||
rect_min_size = Vector2( 128, 128 )
|
||||
custom_styles/panel = SubResource( 1 )
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="Slot11" type="Panel" parent="GridContainer"]
|
||||
margin_left = 132.0
|
||||
margin_left = 264.0
|
||||
margin_top = 132.0
|
||||
margin_right = 260.0
|
||||
margin_right = 392.0
|
||||
margin_bottom = 260.0
|
||||
rect_min_size = Vector2( 128, 128 )
|
||||
custom_styles/panel = SubResource( 1 )
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="Slot12" type="Panel" parent="GridContainer"]
|
||||
margin_left = 264.0
|
||||
margin_left = 396.0
|
||||
margin_top = 132.0
|
||||
margin_right = 392.0
|
||||
margin_right = 524.0
|
||||
margin_bottom = 260.0
|
||||
rect_min_size = Vector2( 128, 128 )
|
||||
custom_styles/panel = SubResource( 1 )
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="Slot13" type="Panel" parent="GridContainer"]
|
||||
margin_left = 396.0
|
||||
margin_left = 528.0
|
||||
margin_top = 132.0
|
||||
margin_right = 524.0
|
||||
margin_right = 656.0
|
||||
margin_bottom = 260.0
|
||||
rect_min_size = Vector2( 128, 128 )
|
||||
custom_styles/panel = SubResource( 1 )
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="Slot14" type="Panel" parent="GridContainer"]
|
||||
margin_left = 528.0
|
||||
margin_left = 660.0
|
||||
margin_top = 132.0
|
||||
margin_right = 656.0
|
||||
margin_right = 788.0
|
||||
margin_bottom = 260.0
|
||||
rect_min_size = Vector2( 128, 128 )
|
||||
custom_styles/panel = SubResource( 1 )
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="Slot15" type="Panel" parent="GridContainer"]
|
||||
margin_left = 660.0
|
||||
margin_left = 792.0
|
||||
margin_top = 132.0
|
||||
margin_right = 788.0
|
||||
margin_right = 920.0
|
||||
margin_bottom = 260.0
|
||||
rect_min_size = Vector2( 128, 128 )
|
||||
custom_styles/panel = SubResource( 1 )
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="Slot16" type="Panel" parent="GridContainer"]
|
||||
margin_left = 792.0
|
||||
margin_left = 924.0
|
||||
margin_top = 132.0
|
||||
margin_right = 920.0
|
||||
margin_right = 1052.0
|
||||
margin_bottom = 260.0
|
||||
rect_min_size = Vector2( 128, 128 )
|
||||
custom_styles/panel = SubResource( 1 )
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="Slot17" type="Panel" parent="GridContainer"]
|
||||
margin_left = 924.0
|
||||
margin_top = 132.0
|
||||
margin_right = 1052.0
|
||||
margin_bottom = 260.0
|
||||
margin_top = 264.0
|
||||
margin_right = 128.0
|
||||
margin_bottom = 392.0
|
||||
rect_min_size = Vector2( 128, 128 )
|
||||
custom_styles/panel = SubResource( 1 )
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="Slot18" type="Panel" parent="GridContainer"]
|
||||
margin_left = 1056.0
|
||||
margin_top = 132.0
|
||||
margin_right = 1184.0
|
||||
margin_bottom = 260.0
|
||||
margin_left = 132.0
|
||||
margin_top = 264.0
|
||||
margin_right = 260.0
|
||||
margin_bottom = 392.0
|
||||
rect_min_size = Vector2( 128, 128 )
|
||||
custom_styles/panel = SubResource( 1 )
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="Slot19" type="Panel" parent="GridContainer"]
|
||||
margin_left = 264.0
|
||||
margin_top = 264.0
|
||||
margin_right = 128.0
|
||||
margin_right = 392.0
|
||||
margin_bottom = 392.0
|
||||
rect_min_size = Vector2( 128, 128 )
|
||||
custom_styles/panel = SubResource( 1 )
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="Slot20" type="Panel" parent="GridContainer"]
|
||||
margin_left = 132.0
|
||||
margin_left = 396.0
|
||||
margin_top = 264.0
|
||||
margin_right = 260.0
|
||||
margin_right = 524.0
|
||||
margin_bottom = 392.0
|
||||
rect_min_size = Vector2( 128, 128 )
|
||||
custom_styles/panel = SubResource( 1 )
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="Slot21" type="Panel" parent="GridContainer"]
|
||||
margin_left = 264.0
|
||||
margin_left = 528.0
|
||||
margin_top = 264.0
|
||||
margin_right = 392.0
|
||||
margin_right = 656.0
|
||||
margin_bottom = 392.0
|
||||
rect_min_size = Vector2( 128, 128 )
|
||||
custom_styles/panel = SubResource( 1 )
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="Slot22" type="Panel" parent="GridContainer"]
|
||||
margin_left = 396.0
|
||||
margin_left = 660.0
|
||||
margin_top = 264.0
|
||||
margin_right = 524.0
|
||||
margin_right = 788.0
|
||||
margin_bottom = 392.0
|
||||
rect_min_size = Vector2( 128, 128 )
|
||||
custom_styles/panel = SubResource( 1 )
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="Slot23" type="Panel" parent="GridContainer"]
|
||||
margin_left = 528.0
|
||||
margin_left = 792.0
|
||||
margin_top = 264.0
|
||||
margin_right = 656.0
|
||||
margin_right = 920.0
|
||||
margin_bottom = 392.0
|
||||
rect_min_size = Vector2( 128, 128 )
|
||||
custom_styles/panel = SubResource( 1 )
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="Slot24" type="Panel" parent="GridContainer"]
|
||||
margin_left = 660.0
|
||||
margin_left = 924.0
|
||||
margin_top = 264.0
|
||||
margin_right = 788.0
|
||||
margin_right = 1052.0
|
||||
margin_bottom = 392.0
|
||||
rect_min_size = Vector2( 128, 128 )
|
||||
custom_styles/panel = SubResource( 1 )
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="Slot25" type="Panel" parent="GridContainer"]
|
||||
margin_left = 792.0
|
||||
margin_top = 264.0
|
||||
margin_right = 920.0
|
||||
margin_bottom = 392.0
|
||||
margin_top = 396.0
|
||||
margin_right = 128.0
|
||||
margin_bottom = 524.0
|
||||
rect_min_size = Vector2( 128, 128 )
|
||||
custom_styles/panel = SubResource( 1 )
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="Slot26" type="Panel" parent="GridContainer"]
|
||||
margin_left = 924.0
|
||||
margin_top = 264.0
|
||||
margin_right = 1052.0
|
||||
margin_bottom = 392.0
|
||||
margin_left = 132.0
|
||||
margin_top = 396.0
|
||||
margin_right = 260.0
|
||||
margin_bottom = 524.0
|
||||
rect_min_size = Vector2( 128, 128 )
|
||||
custom_styles/panel = SubResource( 1 )
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="Slot27" type="Panel" parent="GridContainer"]
|
||||
margin_left = 1056.0
|
||||
margin_top = 264.0
|
||||
margin_right = 1184.0
|
||||
margin_bottom = 392.0
|
||||
margin_left = 264.0
|
||||
margin_top = 396.0
|
||||
margin_right = 392.0
|
||||
margin_bottom = 524.0
|
||||
rect_min_size = Vector2( 128, 128 )
|
||||
custom_styles/panel = SubResource( 1 )
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="Slot28" type="Panel" parent="GridContainer"]
|
||||
margin_left = 396.0
|
||||
margin_top = 396.0
|
||||
margin_right = 128.0
|
||||
margin_right = 524.0
|
||||
margin_bottom = 524.0
|
||||
rect_min_size = Vector2( 128, 128 )
|
||||
custom_styles/panel = SubResource( 1 )
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="Slot29" type="Panel" parent="GridContainer"]
|
||||
margin_left = 132.0
|
||||
margin_top = 396.0
|
||||
margin_right = 260.0
|
||||
margin_bottom = 524.0
|
||||
rect_min_size = Vector2( 128, 128 )
|
||||
custom_styles/panel = SubResource( 1 )
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="Slot30" type="Panel" parent="GridContainer"]
|
||||
margin_left = 264.0
|
||||
margin_top = 396.0
|
||||
margin_right = 392.0
|
||||
margin_bottom = 524.0
|
||||
rect_min_size = Vector2( 128, 128 )
|
||||
custom_styles/panel = SubResource( 1 )
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="Slot31" type="Panel" parent="GridContainer"]
|
||||
margin_left = 396.0
|
||||
margin_top = 396.0
|
||||
margin_right = 524.0
|
||||
margin_bottom = 524.0
|
||||
rect_min_size = Vector2( 128, 128 )
|
||||
custom_styles/panel = SubResource( 1 )
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="Slot32" type="Panel" parent="GridContainer"]
|
||||
margin_left = 528.0
|
||||
margin_top = 396.0
|
||||
margin_right = 656.0
|
||||
@ -308,7 +280,7 @@ rect_min_size = Vector2( 128, 128 )
|
||||
custom_styles/panel = SubResource( 1 )
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="Slot33" type="Panel" parent="GridContainer"]
|
||||
[node name="Slot30" type="Panel" parent="GridContainer"]
|
||||
margin_left = 660.0
|
||||
margin_top = 396.0
|
||||
margin_right = 788.0
|
||||
@ -317,7 +289,7 @@ rect_min_size = Vector2( 128, 128 )
|
||||
custom_styles/panel = SubResource( 1 )
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="Slot34" type="Panel" parent="GridContainer"]
|
||||
[node name="Slot31" type="Panel" parent="GridContainer"]
|
||||
margin_left = 792.0
|
||||
margin_top = 396.0
|
||||
margin_right = 920.0
|
||||
@ -326,7 +298,7 @@ rect_min_size = Vector2( 128, 128 )
|
||||
custom_styles/panel = SubResource( 1 )
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="Slot35" type="Panel" parent="GridContainer"]
|
||||
[node name="Slot32" type="Panel" parent="GridContainer"]
|
||||
margin_left = 924.0
|
||||
margin_top = 396.0
|
||||
margin_right = 1052.0
|
||||
@ -335,16 +307,7 @@ rect_min_size = Vector2( 128, 128 )
|
||||
custom_styles/panel = SubResource( 1 )
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="Slot36" type="Panel" parent="GridContainer"]
|
||||
margin_left = 1056.0
|
||||
margin_top = 396.0
|
||||
margin_right = 1184.0
|
||||
margin_bottom = 524.0
|
||||
rect_min_size = Vector2( 128, 128 )
|
||||
custom_styles/panel = SubResource( 1 )
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="Slot37" type="Panel" parent="GridContainer"]
|
||||
[node name="Slot33" type="Panel" parent="GridContainer"]
|
||||
margin_top = 528.0
|
||||
margin_right = 128.0
|
||||
margin_bottom = 656.0
|
||||
@ -352,7 +315,7 @@ rect_min_size = Vector2( 128, 128 )
|
||||
custom_styles/panel = SubResource( 1 )
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="Slot38" type="Panel" parent="GridContainer"]
|
||||
[node name="Slot34" type="Panel" parent="GridContainer"]
|
||||
margin_left = 132.0
|
||||
margin_top = 528.0
|
||||
margin_right = 260.0
|
||||
@ -361,7 +324,7 @@ rect_min_size = Vector2( 128, 128 )
|
||||
custom_styles/panel = SubResource( 1 )
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="Slot39" type="Panel" parent="GridContainer"]
|
||||
[node name="Slot35" type="Panel" parent="GridContainer"]
|
||||
margin_left = 264.0
|
||||
margin_top = 528.0
|
||||
margin_right = 392.0
|
||||
@ -370,7 +333,7 @@ rect_min_size = Vector2( 128, 128 )
|
||||
custom_styles/panel = SubResource( 1 )
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="Slot40" type="Panel" parent="GridContainer"]
|
||||
[node name="Slot36" type="Panel" parent="GridContainer"]
|
||||
margin_left = 396.0
|
||||
margin_top = 528.0
|
||||
margin_right = 524.0
|
||||
@ -379,7 +342,7 @@ rect_min_size = Vector2( 128, 128 )
|
||||
custom_styles/panel = SubResource( 1 )
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="Slot41" type="Panel" parent="GridContainer"]
|
||||
[node name="Slot37" type="Panel" parent="GridContainer"]
|
||||
margin_left = 528.0
|
||||
margin_top = 528.0
|
||||
margin_right = 656.0
|
||||
@ -388,7 +351,7 @@ rect_min_size = Vector2( 128, 128 )
|
||||
custom_styles/panel = SubResource( 1 )
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="Slot42" type="Panel" parent="GridContainer"]
|
||||
[node name="Slot38" type="Panel" parent="GridContainer"]
|
||||
margin_left = 660.0
|
||||
margin_top = 528.0
|
||||
margin_right = 788.0
|
||||
@ -397,7 +360,7 @@ rect_min_size = Vector2( 128, 128 )
|
||||
custom_styles/panel = SubResource( 1 )
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="Slot43" type="Panel" parent="GridContainer"]
|
||||
[node name="Slot39" type="Panel" parent="GridContainer"]
|
||||
margin_left = 792.0
|
||||
margin_top = 528.0
|
||||
margin_right = 920.0
|
||||
@ -406,7 +369,7 @@ rect_min_size = Vector2( 128, 128 )
|
||||
custom_styles/panel = SubResource( 1 )
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="Slot44" type="Panel" parent="GridContainer"]
|
||||
[node name="Slot40" type="Panel" parent="GridContainer"]
|
||||
margin_left = 924.0
|
||||
margin_top = 528.0
|
||||
margin_right = 1052.0
|
||||
@ -415,11 +378,8 @@ rect_min_size = Vector2( 128, 128 )
|
||||
custom_styles/panel = SubResource( 1 )
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="Slot45" type="Panel" parent="GridContainer"]
|
||||
margin_left = 1056.0
|
||||
margin_top = 528.0
|
||||
margin_right = 1184.0
|
||||
margin_bottom = 656.0
|
||||
rect_min_size = Vector2( 128, 128 )
|
||||
custom_styles/panel = SubResource( 1 )
|
||||
script = ExtResource( 3 )
|
||||
[node name="TouchScreenButton" type="TouchScreenButton" parent="."]
|
||||
position = Vector2( 1106.07, 1.52588e-05 )
|
||||
scale = Vector2( 4, 4 )
|
||||
normal = ExtResource( 5 )
|
||||
[connection signal="pressed" from="TouchScreenButton" to="." method="_on_TouchScreenButton_pressed"]
|
||||
|
@ -69,3 +69,4 @@ func CameraToPlayer():
|
||||
if lockedPlayerCamera == false:
|
||||
MoveCamera(player.position.x, player.position.y)
|
||||
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
extends TileMap
|
||||
|
||||
|
||||
|
||||
onready var player = get_node("/root/Map1/Player")
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
@ -19,5 +21,6 @@ func _unhandled_input(event):
|
||||
if(pl_tile != -1):
|
||||
set_cellv(pl_pos_tile, -1)
|
||||
|
||||
|
||||
func _on_Inventory_pressed():
|
||||
get_tree().change_scene("res://MiscScenes/Inventory.tscn")
|
||||
|
@ -167,6 +167,7 @@ shape = SubResource( 2 )
|
||||
action = "map_interaction"
|
||||
|
||||
[node name="Tween" type="Tween" parent="."]
|
||||
[connection signal="pressed" from="Camera2D/Interactive/GameButtons/Inventory" to="background" method="_on_Inventory_pressed"]
|
||||
[connection signal="pressed" from="Camera2D/MoveDown" to="Player" method="_on_TouchScreenButton_pressed"]
|
||||
[connection signal="pressed" from="Camera2D/MoveRight" to="Player" method="_on_TouchScreenButton_pressed"]
|
||||
[connection signal="pressed" from="Camera2D/MoveUp" to="Player" method="_on_TouchScreenButton_pressed"]
|
||||
|
Loading…
Reference in New Issue
Block a user