Commit 14edd5eb authored by Julia Santos's avatar Julia Santos

Started adding inventory UI, still glitchy for now but it works

parent 09691a69
......@@ -9,6 +9,7 @@ onready var moxie = get_parent().get_node("Moxie")
onready var left = get_parent().get_node("UI/Left") # left arrow
onready var right = get_parent().get_node("UI/Right") # right arrow
onready var inventory = get_parent().get_node("UI/Inventory")
onready var inventoryUI = get_parent().get_node("UI/Inventory UI")
onready var deselect = get_parent().get_node("UI/Inventory control")
onready var energy = get_parent().get_node("UI/Energy bar")
onready var dialogue = get_parent().get_node("UI/Dialogue Box/RichTextLabel")
......@@ -327,7 +328,7 @@ func _balcony_to_neighbor(): # moving from neighbor's balcony to their living ro
# ----------------- Zooming in and out of specific views -----------------
func zoom_in(): # for close up perspectives without some UI
moxie.hide()
inventory.hide()
inventoryUI.hide()
left.hide()
right.hide()
deselect.hide()
......@@ -335,7 +336,7 @@ func zoom_in(): # for close up perspectives without some UI
func zoom_out(): # for returning from close up perspectives
moxie.show()
inventory.show()
inventoryUI.show()
if !lockedNotepad:
#get_parent().get_node("UI/Movement Handler").check_arrows() # show arrows depending on situation
movementHandle.enableMovement()
......@@ -370,7 +371,7 @@ func _return_fridge(): # returning from fridge view
func _open_cabinet(): # looking inside kitchen cabinet
zoom_in()
inventory.show()
inventoryUI.show()
kitchen.hide()
insideCabinet.show()
......@@ -382,7 +383,7 @@ func _close_cabinet(): # leaving kitchen cabinet
func _in_desk(): # looking at desk
if !lockedNotepad: # only if notepad has been retrieved
zoom_in()
inventory.show()
inventoryUI.show()
desk.show()
bedroom.hide()
......
......@@ -95,10 +95,12 @@ func pickup(): # when it's picked up
inventory.unselect_all()
func objInteraction(selected): # when an object is used on it
print("Using " + inventory.get_item_text(selected) + " on " + self.name )
var flavor = control.interaction(inventory.get_item_text(selected), self.get_name())
if typeof(flavor) != 0: #checks if there's coded flavor text for this interaction
dialogueBox.text = flavor
else:
dialogueBox.text = "No flavor text found" #can replace this later!
if inventory.get_name() == "Words":
inventory.unselect_all()
dialogueBox.playText()
inventory.unselect_all() #unselect item
extends ItemList
onready var UI = get_parent().get_node("Inventory UI")
# Called when the node enters the scene tree for the first time.
......@@ -23,3 +23,16 @@ func remove_item_name(toRemove):
var index = hasItem(toRemove)
if index != -1:
remove_item(index)
func remove_item(idx):
.remove_item(idx)
UI.updateUI()
print("Removing item")
func add_item(text, icon=null, selectable=true):
.add_item(text, icon)
UI.updateUI()
print("Adding item")
func updateUI():
UI.updateUI()
[gd_scene load_steps=50 format=2]
[gd_scene load_steps=55 format=2]
[ext_resource path="res://Main rooms/Test room 1.tscn" type="PackedScene" id=1]
[ext_resource path="res://assets/Thesis Clickables/moxie1.png" type="Texture" id=2]
......@@ -39,6 +39,8 @@
[ext_resource path="res://assets/Fonts/Be Vietnam.tres" type="DynamicFont" id=37]
[ext_resource path="res://assets/Thesis Clickables/Polygon 1.png" type="Texture" id=38]
[ext_resource path="res://assets/Thesis Clickables/Deselect button.tres" type="StyleBox" id=39]
[ext_resource path="res://assets/Thesis Clickables/inventory disabled.tres" type="StyleBox" id=40]
[ext_resource path="res://Scripts/Inventory UI.gd" type="Script" id=41]
[sub_resource type="Animation" id=1]
resource_name = "Notepad open"
......@@ -72,20 +74,29 @@ corner_radius_bottom_right = 36
corner_radius_bottom_left = 36
[sub_resource type="StyleBoxFlat" id=6]
bg_color = Color( 0.521569, 0.494118, 0.572549, 0.231373 )
[sub_resource type="StyleBoxFlat" id=7]
bg_color = Color( 0.521569, 0.494118, 0.572549, 0.231373 )
[sub_resource type="StyleBoxFlat" id=8]
bg_color = Color( 0.0313726, 0.0313726, 0.0313726, 0.145098 )
[sub_resource type="StyleBoxFlat" id=9]
bg_color = Color( 0.168627, 0.156863, 0.219608, 0.937255 )
corner_radius_top_left = 36
corner_radius_top_right = 36
corner_radius_bottom_right = 36
corner_radius_bottom_left = 36
[sub_resource type="StyleBoxFlat" id=7]
[sub_resource type="StyleBoxFlat" id=10]
bg_color = Color( 0.662745, 0.639216, 0.72549, 1 )
corner_radius_top_left = 500
corner_radius_top_right = 500
corner_radius_bottom_right = 500
corner_radius_bottom_left = 500
[sub_resource type="Animation" id=8]
[sub_resource type="Animation" id=11]
tracks/0/type = "value"
tracks/0/path = NodePath("RichTextLabel:percent_visible")
tracks/0/interp = 1
......@@ -99,7 +110,7 @@ tracks/0/keys = {
"values": [ 0.0 ]
}
[sub_resource type="StyleBoxFlat" id=9]
[sub_resource type="StyleBoxFlat" id=12]
bg_color = Color( 0.52549, 0.905882, 0.462745, 0.858824 )
border_width_left = 5
border_width_top = 5
......@@ -111,7 +122,7 @@ corner_radius_top_right = 36
corner_radius_bottom_right = 36
corner_radius_bottom_left = 36
[sub_resource type="StyleBoxFlat" id=10]
[sub_resource type="StyleBoxFlat" id=13]
bg_color = Color( 0.168627, 0.156863, 0.219608, 0.937255 )
corner_radius_top_left = 36
corner_radius_top_right = 36
......@@ -125,7 +136,7 @@ script = ExtResource( 4 )
items = [ NodePath("Pants"), NodePath("Shirt"), NodePath("Sando"), NodePath("Towel"), NodePath("Laundry basket"), NodePath("Laptop"), NodePath("Cellphone"), NodePath("Bathroom door"), NodePath("Terrarium") ]
[node name="BG" parent="Bedroom" index="1"]
position = Vector2( 192.923, 293.932 )
position = Vector2( 193.188, 294.197 )
[node name="Desk" parent="." instance=ExtResource( 26 )]
visible = false
......@@ -332,13 +343,119 @@ position = Vector2( 150.967, 149.796 )
scale = Vector2( 0.629082, 0.629082 )
polygon = PoolVector2Array( 143, -298.8, 143, -291.4, 145.7, -283, 162.7, -301, 204, -301, 204, -294.5, 262, -241, 262, 287, 255.3, 287, 234.7, 302, -261, 302, -261, 291, -262, 221.9, -262, -269, -260.6, -269, -201.7, -302, -178.8, -302, -153.1, -278, -134.5, -302, -106.5, -302, -81.2, -279, -72.3, -279, -61.3, -302, -54.2, -302, -19, -302, -19, -301.2, 4, -279, 6, -279, 18.5, -302, 57, -302, 57, -300.9, 78.3, -284.5, 95.1, -302, 135, -302 )
[node name="Inventory UI" type="Control" parent="UI"]
margin_left = -197.0
margin_top = 115.0
margin_right = -157.0
margin_bottom = 155.0
script = ExtResource( 41 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Panel" type="Panel" parent="UI/Inventory UI"]
margin_left = 1.0
margin_top = -2.0
margin_right = 607.0
margin_bottom = 90.0
custom_styles/panel = SubResource( 5 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="1" type="Button" parent="UI/Inventory UI"]
margin_left = 50.1849
margin_top = 8.07666
margin_right = 120.185
margin_bottom = 78.0767
hint_tooltip = "This is an item"
mouse_filter = 1
custom_styles/hover = SubResource( 6 )
custom_styles/pressed = SubResource( 7 )
custom_styles/disabled = ExtResource( 40 )
custom_styles/normal = SubResource( 8 )
toggle_mode = true
expand_icon = true
__meta__ = {
"_edit_use_anchors_": false
}
[node name="2" type="Button" parent="UI/Inventory UI"]
margin_left = 150.185
margin_top = 8.077
margin_right = 220.185
margin_bottom = 78.077
hint_tooltip = "This is an item"
mouse_filter = 1
custom_styles/hover = SubResource( 6 )
custom_styles/pressed = SubResource( 7 )
custom_styles/disabled = ExtResource( 40 )
custom_styles/normal = SubResource( 8 )
toggle_mode = true
expand_icon = true
__meta__ = {
"_edit_use_anchors_": false
}
[node name="3" type="Button" parent="UI/Inventory UI"]
margin_left = 250.185
margin_top = 8.077
margin_right = 320.185
margin_bottom = 78.077
hint_tooltip = "This is an item"
mouse_filter = 1
custom_styles/hover = SubResource( 6 )
custom_styles/pressed = SubResource( 7 )
custom_styles/disabled = ExtResource( 40 )
custom_styles/normal = SubResource( 8 )
toggle_mode = true
expand_icon = true
__meta__ = {
"_edit_use_anchors_": false
}
[node name="4" type="Button" parent="UI/Inventory UI"]
margin_left = 350.185
margin_top = 8.077
margin_right = 420.185
margin_bottom = 78.077
hint_tooltip = "This is an item"
mouse_filter = 1
custom_styles/hover = SubResource( 6 )
custom_styles/pressed = SubResource( 7 )
custom_styles/disabled = ExtResource( 40 )
custom_styles/normal = SubResource( 8 )
toggle_mode = true
expand_icon = true
__meta__ = {
"_edit_use_anchors_": false
}
[node name="5" type="Button" parent="UI/Inventory UI"]
margin_left = 450.185
margin_top = 8.077
margin_right = 520.185
margin_bottom = 78.077
hint_tooltip = "This is an item"
mouse_filter = 1
custom_styles/hover = SubResource( 6 )
custom_styles/pressed = SubResource( 7 )
custom_styles/disabled = ExtResource( 40 )
custom_styles/normal = SubResource( 8 )
toggle_mode = true
expand_icon = true
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Inventory" type="ItemList" parent="UI"]
visible = false
margin_left = -197.0
margin_top = 115.0
margin_right = 409.0
margin_bottom = 196.0
margin_bottom = 203.0
rect_pivot_offset = Vector2( 5, 0 )
custom_styles/bg = SubResource( 5 )
custom_styles/bg = SubResource( 9 )
custom_constants/hseparation = 10
max_columns = 8
same_column_width = true
......@@ -354,7 +471,7 @@ margin_left = 334.0
margin_top = 98.0
margin_right = 429.0
margin_bottom = 146.0
custom_styles/panel = SubResource( 6 )
custom_styles/panel = SubResource( 5 )
__meta__ = {
"_edit_group_": true,
"_edit_use_anchors_": false
......@@ -365,6 +482,7 @@ margin_left = 65.2903
margin_top = 11.3307
margin_right = 84.2903
margin_bottom = 38.3307
hint_tooltip = "Previous page"
texture_normal = ExtResource( 38 )
__meta__ = {
"_edit_use_anchors_": false
......@@ -376,6 +494,7 @@ margin_top = 38.3624
margin_right = 47.9565
margin_bottom = 65.3624
rect_rotation = 180.0
hint_tooltip = "Next page"
texture_normal = ExtResource( 38 )
__meta__ = {
"_edit_use_anchors_": false
......@@ -386,7 +505,8 @@ margin_left = 39.5535
margin_top = 16.442
margin_right = 56.5535
margin_bottom = 33.442
custom_styles/hover = SubResource( 7 )
hint_tooltip = "Deselect"
custom_styles/hover = SubResource( 10 )
custom_styles/pressed = ExtResource( 39 )
custom_styles/normal = ExtResource( 39 )
script = ExtResource( 5 )
......@@ -436,14 +556,14 @@ margin_left = 241.743
margin_top = -369.036
margin_right = 782.743
margin_bottom = -277.036
custom_styles/panel = SubResource( 6 )
custom_styles/panel = SubResource( 5 )
__meta__ = {
"_edit_group_": true,
"_edit_use_anchors_": false
}
[node name="Text Animator" type="AnimationPlayer" parent="UI/Dialogue Box"]
anims/Dialogue = SubResource( 8 )
anims/Dialogue = SubResource( 11 )
[node name="RichTextLabel" type="RichTextLabel" parent="UI/Dialogue Box"]
margin_left = 27.0
......@@ -465,8 +585,8 @@ margin_left = -197.0
margin_top = -368.0
margin_right = 233.0
margin_bottom = -319.0
custom_styles/fg = SubResource( 9 )
custom_styles/bg = SubResource( 10 )
custom_styles/fg = SubResource( 12 )
custom_styles/bg = SubResource( 13 )
value = 50.0
percent_visible = false
__meta__ = {
......@@ -488,6 +608,13 @@ visible = false
[node name="3" parent="Cutscenes" instance=ExtResource( 33 )]
visible = false
[connection signal="toggled" from="UI/Inventory UI/1" to="UI/Inventory UI" method="_on_1_toggled"]
[connection signal="toggled" from="UI/Inventory UI/2" to="UI/Inventory UI" method="_on_2_toggled"]
[connection signal="toggled" from="UI/Inventory UI/3" to="UI/Inventory UI" method="_on_3_toggled"]
[connection signal="toggled" from="UI/Inventory UI/4" to="UI/Inventory UI" method="_on_4_toggled"]
[connection signal="toggled" from="UI/Inventory UI/5" to="UI/Inventory UI" method="_on_5_toggled"]
[connection signal="pressed" from="UI/Inventory control/Inventory right" to="UI/Inventory UI" method="_on_Inventory_right_pressed"]
[connection signal="pressed" from="UI/Inventory control/Inventory left" to="UI/Inventory UI" method="_on_Inventory_left_pressed"]
[connection signal="pressed" from="UI/Inventory control/Deselect" to="UI/Inventory" method="_on_Button_pressed"]
[editable path="Bedroom"]
......
......@@ -19,4 +19,5 @@ func pickup():
dialogueBox.playText()
queue_free()
inventory.unselect_all()
inventory.updateUI()
emit_signal("retrieved")
extends Control
onready var inventory = get_parent().get_node("Inventory")
onready var firstIndex = 0
onready var items = [get_node("1"), get_node("2"), get_node("3"), get_node("4"), get_node("5")]
# Called when the node enters the scene tree for the first time.
func _ready():
updateUI()
func updateUI():
var i = 0
while i < 5:
if i < inventory.get_item_count():
items[i].set_disabled(false)
items[i].set_button_icon(inventory.get_item_icon(firstIndex + i))
items[i].set_tooltip(inventory.get_item_text(firstIndex+i))
else:
items[i].set_button_icon(null)
items[i].set_tooltip("")
items[i].set_disabled(true)
if inventory.get_selected_items().size() == 0:
items[i].set_pressed(false)
i = i + 1
#set icon
#set tooltip
#set index?
print("Updated inventory UI")
func disableRest(num):
var j = 0
while j < 5:
if j != num:
items[j].set_disabled(true)
j = j + 1
func enableRest():
updateUI()
func _on_1_toggled(button_pressed):
if button_pressed:
inventory.select(firstIndex)
disableRest(0)
else:
enableRest()
inventory.unselect_all()
print(inventory.get_selected_items())
func _on_2_toggled(button_pressed):
if button_pressed: # has to be at least two items
inventory.select(firstIndex + 1)
disableRest(1)
else:
enableRest()
inventory.unselect_all()
print(inventory.get_selected_items())
func _on_3_toggled(button_pressed):
if button_pressed:
inventory.select(firstIndex + 2)
disableRest(2)
else:
enableRest()
inventory.unselect_all()
print(inventory.get_selected_items())
func _on_4_toggled(button_pressed):
if button_pressed:
inventory.select(firstIndex + 3)
disableRest(3)
else:
enableRest()
inventory.unselect_all()
print(inventory.get_selected_items())
func _on_5_toggled(button_pressed):
if button_pressed:
inventory.select(firstIndex + 4)
disableRest(4)
else:
enableRest()
inventory.unselect_all()
print(inventory.get_selected_items())
func _on_Inventory_right_pressed():
if (inventory.get_item_count() > firstIndex + 4):
firstIndex = firstIndex + 5
updateUI()
func _on_Inventory_left_pressed():
if firstIndex != 0:
firstIndex = firstIndex - 5
updateUI()
......@@ -3,5 +3,5 @@
[ext_resource path="res://assets/Fonts/BeVietnamPro-Medium.ttf" type="DynamicFontData" id=1]
[resource]
size = 14
size = 12
font_data = ExtResource( 1 )
[gd_resource type="StyleBoxFlat" format=2]
[resource]
bg_color = Color( 0.286275, 0.262745, 0.32549, 0.231373 )
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment