It's Cow Game! Version 2.04!
This commit is contained in:
commit
a9e1ed9ddd
3148 changed files with 95332 additions and 0 deletions
137
UI/MenuBar/Inventory/InventoryMenu.gd
Normal file
137
UI/MenuBar/Inventory/InventoryMenu.gd
Normal file
|
|
@ -0,0 +1,137 @@
|
|||
extends PanelContainer
|
||||
|
||||
var groundItemScene = preload("res://Objects/GroundItems/GroundItem.tscn")
|
||||
|
||||
var inventoryDisplayer
|
||||
var keyInventoryDisplayer
|
||||
|
||||
var currentInv = "normal"
|
||||
|
||||
var clickMenu
|
||||
var itemSelected
|
||||
|
||||
var shortcuts = [KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, KEY_8, KEY_9]
|
||||
|
||||
func _ready():
|
||||
inventoryDisplayer = %InventoryItems
|
||||
keyInventoryDisplayer = %KeyInventoryItems
|
||||
clickMenu = %ClickMenu
|
||||
|
||||
inventoryDisplayer.displayScene = load("res://UI/MenuBar/Inventory/ItemInventoryDisplay.tscn")
|
||||
keyInventoryDisplayer.displayScene = load("res://UI/MenuBar/Inventory/ItemInventoryDisplay.tscn")
|
||||
update_inventory()
|
||||
inventoryDisplayer.itemClicked.connect(item_clicked)
|
||||
keyInventoryDisplayer.itemClicked.connect(item_clicked)
|
||||
|
||||
InventoryManager.playerInventoryUpdated.connect(update_inventory)
|
||||
|
||||
func _process(delta):
|
||||
if clickMenu.visible:
|
||||
for i in range(clickMenu.item_count):
|
||||
var currentID = clickMenu.get_item_id(i)
|
||||
if currentID < shortcuts.size() and Input.is_action_just_pressed(str(i+1)):
|
||||
_on_click_menu_id_pressed(currentID)
|
||||
break
|
||||
|
||||
func update_inventory():
|
||||
var inventory = InventoryManager.get_inventory()
|
||||
inventoryDisplayer.inventory = inventory
|
||||
inventoryDisplayer.update_display()
|
||||
|
||||
var keyInventory = InventoryManager.get_inventory("keyItems")
|
||||
keyInventoryDisplayer.inventory = keyInventory
|
||||
keyInventoryDisplayer.update_display()
|
||||
|
||||
func item_clicked(item):
|
||||
clear_click_menu()
|
||||
itemSelected = item
|
||||
|
||||
clickMenu.size.x = 0
|
||||
clickMenu.size.y = 0
|
||||
|
||||
clickMenu.add_item("Behold", 0)
|
||||
if currentInv != "keyItems":
|
||||
clickMenu.add_item("Drop", 1)
|
||||
if Item.types.Juice in item.itemTypes:
|
||||
clickMenu.add_item("Drink", 2)
|
||||
elif item.get_edibility() >= 50:
|
||||
clickMenu.add_item("Eat", 3)
|
||||
if Item.types.Toy in item.itemTypes:
|
||||
clickMenu.add_item("Play", 4)
|
||||
|
||||
clickMenu.show()
|
||||
|
||||
var WindowSize = Vector2(880,620)
|
||||
var MenuSize = clickMenu.size
|
||||
var PopUpPos = get_viewport().get_mouse_position()
|
||||
if MenuSize.x + PopUpPos.x > WindowSize.x: PopUpPos.x -= MenuSize.x
|
||||
if MenuSize.y + PopUpPos.y > WindowSize.y: PopUpPos.y -= MenuSize.y
|
||||
clickMenu.position = PopUpPos
|
||||
|
||||
func clear_click_menu():
|
||||
clickMenu.clear()
|
||||
|
||||
func _on_click_menu_id_pressed(id):
|
||||
if !InventoryManager.check_if_in_inventory(itemSelected, 1, currentInv):
|
||||
return
|
||||
|
||||
if id == 0:
|
||||
behold_item(itemSelected)
|
||||
examine_item(itemSelected)
|
||||
elif id == 1:
|
||||
drop_item(itemSelected)
|
||||
elif id == 2:
|
||||
drink_item(itemSelected)
|
||||
elif id == 3:
|
||||
eat_item(itemSelected)
|
||||
elif id == 4:
|
||||
play_with_item(itemSelected)
|
||||
|
||||
func behold_item(item):
|
||||
GameVariables.player.behold_item(item)
|
||||
|
||||
func drop_item(item):
|
||||
var newGroundItem = groundItemScene.instantiate()
|
||||
newGroundItem.set_item(item.duplicate())
|
||||
newGroundItem.global_position = GameVariables.player.global_position
|
||||
|
||||
if GameVariables.player.swimmingZones.size() > 0:
|
||||
newGroundItem.assume_water_start(GameVariables.player.swimmingZones[0])
|
||||
|
||||
if GameVariables.player.currentInteractingItem != null and GameVariables.player.currentInteractingItem.equals(item):
|
||||
GameVariables.player.change_state("Idle")
|
||||
|
||||
InventoryManager.remove_item_from_inventory(item)
|
||||
LocationManager.currentLocation.add_child(newGroundItem)
|
||||
|
||||
func examine_item(item):
|
||||
MessageManager.addMessage(item.get_description(), null, "System", Color.MIDNIGHT_BLUE,
|
||||
true, false)
|
||||
|
||||
func drink_item(item):
|
||||
GameVariables.player.drink_juice(item)
|
||||
|
||||
func eat_item(item):
|
||||
GameVariables.player.eat_item(item)
|
||||
|
||||
func play_with_item(item):
|
||||
GameVariables.player.play_item(item)
|
||||
if Item.types.Trumpet in item.itemTypes:
|
||||
var trumpetMenu = preload("res://UI/Trumpet/TrumpetMenu.tscn").instantiate()
|
||||
add_child(trumpetMenu)
|
||||
trumpetMenu.popup_centered()
|
||||
trumpetMenu.position.y -= 200
|
||||
|
||||
func _on_inventory_chooser_tab_changed(tab):
|
||||
if tab == 0:
|
||||
currentInv = "normal"
|
||||
else:
|
||||
currentInv = "keyItems"
|
||||
tab += 1
|
||||
|
||||
var inventories = %InventoryHolder.get_children()
|
||||
for i in inventories.size():
|
||||
if i == tab or i == inventories.size() - 1 or i == 0:
|
||||
inventories[i].visible = true
|
||||
else:
|
||||
inventories[i].visible = false
|
||||
76
UI/MenuBar/Inventory/ItemInventoryDisplay.gd
Normal file
76
UI/MenuBar/Inventory/ItemInventoryDisplay.gd
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
extends PanelContainer
|
||||
|
||||
signal itemClicked
|
||||
signal buttonPressed
|
||||
signal fiveButtonPressed
|
||||
signal allButtonPressed
|
||||
|
||||
var itemSpriteDisplay:TextureRect
|
||||
var itemNameDisplay:Label
|
||||
var itemQuantityDisplay:Label
|
||||
|
||||
var quantityDisplayed = 0
|
||||
|
||||
func _ready():
|
||||
itemSpriteDisplay = get_node("MarginContainer/ItemInventoryDisplay/ItemSprite")
|
||||
itemNameDisplay = get_node("MarginContainer/ItemInventoryDisplay/HSplitContainer/ItemName")
|
||||
itemQuantityDisplay = get_node("MarginContainer/ItemInventoryDisplay/HSplitContainer/Quantity")
|
||||
|
||||
func set_sprite(sprite):
|
||||
itemSpriteDisplay.texture = sprite
|
||||
|
||||
func set_item_name(itemName):
|
||||
itemNameDisplay.text = itemName
|
||||
|
||||
func set_quantity(quantity:int):
|
||||
itemQuantityDisplay.text = "x" + str(quantity)
|
||||
quantityDisplayed = quantity
|
||||
|
||||
func hide_quantity():
|
||||
itemQuantityDisplay.visible = false
|
||||
|
||||
func show_positives():
|
||||
var plusButton = $MarginContainer/ItemInventoryDisplay/HSplitContainer/Buttons/PlusButton
|
||||
if plusButton != null:
|
||||
plusButton.visible = true
|
||||
|
||||
func hide_positives():
|
||||
var plusButton = $MarginContainer/ItemInventoryDisplay/HSplitContainer/Buttons/PlusButton
|
||||
if plusButton != null:
|
||||
plusButton.visible = false
|
||||
|
||||
func show_negatives():
|
||||
var minusButton = $MarginContainer/ItemInventoryDisplay/HSplitContainer/Buttons/MinusButton
|
||||
if minusButton != null:
|
||||
minusButton.visible = true
|
||||
|
||||
func hide_negatives():
|
||||
var minusButton = $MarginContainer/ItemInventoryDisplay/HSplitContainer/Buttons/MinusButton
|
||||
if minusButton != null:
|
||||
minusButton.visible = false
|
||||
|
||||
func show_five_button():
|
||||
var fiveButton = get_node("MarginContainer/ItemInventoryDisplay/HSplitContainer/Buttons/5Button")
|
||||
if fiveButton != null:
|
||||
fiveButton.visible = true
|
||||
|
||||
func show_all_button():
|
||||
var allButton = get_node("MarginContainer/ItemInventoryDisplay/HSplitContainer/Buttons/AllButton")
|
||||
if allButton != null:
|
||||
allButton.visible = true
|
||||
|
||||
func _on_plus_button_pressed():
|
||||
buttonPressed.emit()
|
||||
|
||||
func _on_minus_button_pressed():
|
||||
buttonPressed.emit()
|
||||
|
||||
func _on_gui_input(event):
|
||||
if event is InputEventMouseButton and event.pressed and event.button_index == MOUSE_BUTTON_LEFT:
|
||||
itemClicked.emit()
|
||||
|
||||
func _on_5_button_pressed():
|
||||
fiveButtonPressed.emit()
|
||||
|
||||
func _on_all_button_pressed():
|
||||
allButtonPressed.emit()
|
||||
47
UI/MenuBar/Inventory/ItemInventoryDisplay.tscn
Normal file
47
UI/MenuBar/Inventory/ItemInventoryDisplay.tscn
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://c3bb0ljgv77r2"]
|
||||
|
||||
[ext_resource type="Script" path="res://UI/MenuBar/Inventory/ItemInventoryDisplay.gd" id="1_2pu85"]
|
||||
[ext_resource type="Texture2D" uid="uid://ct5a5b2148uia" path="res://Items/Foods/Fruits/Sprites/Orange.png" id="2_sxoyk"]
|
||||
|
||||
[sub_resource type="Theme" id="Theme_tw8r0"]
|
||||
|
||||
[node name="ItemInventoryDisplay" type="PanelContainer"]
|
||||
offset_right = 229.0
|
||||
offset_bottom = 26.0
|
||||
script = ExtResource("1_2pu85")
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="."]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 3
|
||||
theme_override_constants/margin_top = 2
|
||||
theme_override_constants/margin_right = 5
|
||||
theme_override_constants/margin_bottom = 2
|
||||
|
||||
[node name="ItemInventoryDisplay" type="HSplitContainer" parent="MarginContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="ItemSprite" type="TextureRect" parent="MarginContainer/ItemInventoryDisplay"]
|
||||
layout_mode = 2
|
||||
theme = SubResource("Theme_tw8r0")
|
||||
texture = ExtResource("2_sxoyk")
|
||||
expand_mode = 2
|
||||
|
||||
[node name="HSplitContainer" type="HSplitContainer" parent="MarginContainer/ItemInventoryDisplay"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
dragger_visibility = 2
|
||||
|
||||
[node name="ItemName" type="Label" parent="MarginContainer/ItemInventoryDisplay/HSplitContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Orange"
|
||||
vertical_alignment = 1
|
||||
text_overrun_behavior = 4
|
||||
|
||||
[node name="Quantity" type="Label" parent="MarginContainer/ItemInventoryDisplay/HSplitContainer"]
|
||||
layout_mode = 2
|
||||
text = "Qt. 10"
|
||||
horizontal_alignment = 2
|
||||
vertical_alignment = 1
|
||||
|
||||
[connection signal="gui_input" from="." to="." method="_on_gui_input"]
|
||||
10
UI/MenuBar/Inventory/item_inventory_display_clickable.tscn
Normal file
10
UI/MenuBar/Inventory/item_inventory_display_clickable.tscn
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://tqulfnxq65nt"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://c3bb0ljgv77r2" path="res://UI/MenuBar/Inventory/ItemInventoryDisplay.tscn" id="1_r3jxp"]
|
||||
[ext_resource type="Script" path="res://ItemInventoryDisplayClickable.gd" id="2_sxs8q"]
|
||||
|
||||
[node name="ItemInventoryDisplay" instance=ExtResource("1_r3jxp")]
|
||||
script = ExtResource("2_sxs8q")
|
||||
|
||||
[node name="PopupMenu" type="PopupMenu" parent="." index="1"]
|
||||
visible = true
|
||||
Loading…
Add table
Add a link
Reference in a new issue