It's Cow Game! Version 2.04!
This commit is contained in:
commit
a9e1ed9ddd
3148 changed files with 95332 additions and 0 deletions
43
UI/AshBarrel/AshBarrelContents.gd
Normal file
43
UI/AshBarrel/AshBarrelContents.gd
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
extends ScrollContainer
|
||||
|
||||
var displayScene = preload("res://UI/AshBarrel/AshQuantityDisplay.tscn")
|
||||
|
||||
func add_ash(ashName):
|
||||
var itemFound = false
|
||||
|
||||
var displays = %AshQuantityDisplays.get_children()
|
||||
for display in displays:
|
||||
var currentAshName = display.ashName
|
||||
if currentAshName == ashName:
|
||||
display.set_ash_count(display.ashCount + 1)
|
||||
itemFound = true
|
||||
break
|
||||
|
||||
if !itemFound:
|
||||
var newDisplay = displayScene.instantiate()
|
||||
%AshQuantityDisplays.add_child(newDisplay)
|
||||
newDisplay.visible = true
|
||||
newDisplay.set_ash_name(ashName)
|
||||
newDisplay.set_ash_count(1)
|
||||
|
||||
func display_barrel_inventory():
|
||||
var config = SaveManager.get_save_config()
|
||||
var ashNames = config.get_section_keys("AshBarrel")
|
||||
|
||||
var displays = %AshQuantityDisplays.get_children()
|
||||
for display in displays:
|
||||
display.visible = false
|
||||
|
||||
for i in range(ashNames.size()):
|
||||
var currentAshName = ashNames[i]
|
||||
var currentAshCount = SaveManager.get_value_from_section("AshBarrel", currentAshName, 0)
|
||||
if i >= displays.size():
|
||||
var newDisplay = displayScene.instantiate()
|
||||
%AshQuantityDisplays.add_child(newDisplay)
|
||||
displays.append(newDisplay)
|
||||
|
||||
var currentDisplay = displays[i]
|
||||
currentDisplay.visible = true
|
||||
|
||||
currentDisplay.set_ash_name(currentAshName)
|
||||
currentDisplay.set_ash_count(currentAshCount)
|
||||
23
UI/AshBarrel/AshBarrelContents.tscn
Normal file
23
UI/AshBarrel/AshBarrelContents.tscn
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://clpkuwmqfa7vp"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://cwkj1o1dlonhk" path="res://UI/AshBarrel/AshQuantityDisplay.tscn" id="1_rlw8v"]
|
||||
[ext_resource type="Script" path="res://UI/AshBarrel/AshBarrelContents.gd" id="1_sfqre"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_ys683"]
|
||||
|
||||
[node name="AshBarrelContents" type="ScrollContainer"]
|
||||
offset_right = 400.0
|
||||
offset_bottom = 300.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_ys683")
|
||||
script = ExtResource("1_sfqre")
|
||||
|
||||
[node name="AshQuantityDisplays" type="VBoxContainer" parent="."]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_constants/separation = 0
|
||||
|
||||
[node name="AshQuantityDisplay" parent="AshQuantityDisplays" instance=ExtResource("1_rlw8v")]
|
||||
layout_mode = 2
|
||||
130
UI/AshBarrel/AshBarrelWindow.gd
Normal file
130
UI/AshBarrel/AshBarrelWindow.gd
Normal file
|
|
@ -0,0 +1,130 @@
|
|||
extends Window
|
||||
|
||||
@onready var inventoryDisplayer = %InventoryDisplayer
|
||||
|
||||
func _ready():
|
||||
inventoryDisplayer.buttonPressed.connect(add_ash)
|
||||
|
||||
func opened():
|
||||
get_tree().paused = true
|
||||
initialize_inventory()
|
||||
initialize_barrel_contents()
|
||||
update_barrel_display()
|
||||
|
||||
%CheckButton.button_pressed = SaveManager.get_save_value("PreventAshDuplicates", false)
|
||||
|
||||
func update_display(ashCount:int = -1):
|
||||
update_inventory()
|
||||
update_barrel_display(ashCount)
|
||||
|
||||
func initialize_barrel_contents():
|
||||
%AshBarrelContents.display_barrel_inventory()
|
||||
|
||||
func add_to_barrel_display(ashName):
|
||||
%AshBarrelContents.add_ash(ashName)
|
||||
|
||||
func update_barrel_display(ashCount:int = -1):
|
||||
if ashCount == -1:
|
||||
ashCount = get_ash_count()
|
||||
|
||||
var ashLevel = ashCount
|
||||
if ashLevel > 0:
|
||||
%AshBottom.visible = true
|
||||
%AshBottom.self_modulate = get_ash_color()
|
||||
else:
|
||||
%AshBottom.visible = false
|
||||
|
||||
if ashLevel > 100:
|
||||
ashLevel = 100
|
||||
|
||||
%AshProgress.value = ashLevel
|
||||
|
||||
var newStyleBox = %AshProgress.get("theme_override_styles/fill")
|
||||
newStyleBox.bg_color = get_ash_color()
|
||||
|
||||
get_parent().update_ash()
|
||||
|
||||
func get_ash_color():
|
||||
var ashColor = SaveManager.get_save_value("AshBarrelColor", "#FFFFFF")
|
||||
return Color.html(ashColor)
|
||||
|
||||
func get_ash_count():
|
||||
var ashCount = 0
|
||||
|
||||
var config = SaveManager.get_save_config()
|
||||
var ashNames = config.get_section_keys("AshBarrel")
|
||||
|
||||
for i in range(ashNames.size()):
|
||||
var currentAshName = ashNames[i]
|
||||
var currentAshCount = SaveManager.get_value_from_section("AshBarrel", currentAshName, 0)
|
||||
ashCount += currentAshCount
|
||||
|
||||
return ashCount
|
||||
|
||||
func add_ash(item:Item):
|
||||
var itemName = item.get_name()
|
||||
var timesAdded = SaveManager.get_value_from_section("AshBarrel", itemName, 0)
|
||||
|
||||
if SaveManager.get_save_value("PreventAshDuplicates", false) and timesAdded > 0:
|
||||
return
|
||||
|
||||
timesAdded += 1
|
||||
SaveManager.save_to_section("AshBarrel", itemName, timesAdded)
|
||||
|
||||
var ashColor:Color = SpriteGeneration.get_average_color(item.get_sprite().get_image())
|
||||
var totalAsh = get_ash_count()
|
||||
if totalAsh == 1:
|
||||
SaveManager.set_save_value("AshBarrelColor", ashColor.to_html())
|
||||
else:
|
||||
var oldRatio = (totalAsh-1)/float(totalAsh)
|
||||
var newRatio = 1 - oldRatio
|
||||
|
||||
if newRatio < 0.1:
|
||||
newRatio = 0.1
|
||||
|
||||
var oldAshColor = get_ash_color()
|
||||
var newAverageColor = oldAshColor.lerp(ashColor, newRatio)
|
||||
|
||||
SaveManager.set_save_value("AshBarrelColor", newAverageColor.to_html())
|
||||
|
||||
InventoryManager.remove_item_from_inventory(item)
|
||||
|
||||
if totalAsh >= 100:
|
||||
AchievementManager.complete_achievement("Community Service")
|
||||
|
||||
var config = SaveManager.get_save_config()
|
||||
var ashNames = config.get_section_keys("AshBarrel")
|
||||
if ashNames.size() >= 200:
|
||||
AchievementManager.complete_achievement("Arson Scientist")
|
||||
|
||||
update_display(totalAsh)
|
||||
add_to_barrel_display(itemName)
|
||||
|
||||
func initialize_inventory():
|
||||
update_inventory()
|
||||
inventoryDisplayer.set_title("Ash Items")
|
||||
|
||||
func update_inventory():
|
||||
var playerInventory = InventoryManager.get_inventory()
|
||||
inventoryDisplayer.inventory = filter_inventory(playerInventory)
|
||||
inventoryDisplayer.update_display()
|
||||
|
||||
func filter_inventory(inventory):
|
||||
var filteredInv:Inventory = Inventory.new()
|
||||
|
||||
var i = inventory.items.size() - 1
|
||||
while i >= 0:
|
||||
var currentItem = inventory.items[i]
|
||||
if Item.types.Ash in currentItem.itemTypes:
|
||||
filteredInv.add_item(currentItem.duplicate(), inventory.quantities[i])
|
||||
i -= 1
|
||||
|
||||
return filteredInv
|
||||
|
||||
func _on_leave_button_pressed():
|
||||
get_tree().paused = false
|
||||
get_parent().update_ash()
|
||||
hide()
|
||||
|
||||
func _on_check_button_toggled(toggled_on):
|
||||
SaveManager.set_save_value("PreventAshDuplicates", toggled_on)
|
||||
152
UI/AshBarrel/AshBarrelWindow.tscn
Normal file
152
UI/AshBarrel/AshBarrelWindow.tscn
Normal file
|
|
@ -0,0 +1,152 @@
|
|||
[gd_scene load_steps=9 format=3 uid="uid://rggivntaylnr"]
|
||||
|
||||
[ext_resource type="Script" path="res://UI/AshBarrel/AshBarrelWindow.gd" id="1_dx65t"]
|
||||
[ext_resource type="PackedScene" uid="uid://c3ku75p4ep3c7" path="res://UI/Inventory/InventoryDisplayer.tscn" id="2_teuni"]
|
||||
[ext_resource type="Texture2D" uid="uid://bfsfwarreymej" path="res://Objects/Museum/AshBarrel/AshBarrel.png" id="3_lg4rj"]
|
||||
[ext_resource type="PackedScene" uid="uid://clpkuwmqfa7vp" path="res://UI/AshBarrel/AshBarrelContents.tscn" id="3_xickp"]
|
||||
[ext_resource type="Texture2D" uid="uid://6qkrfsj54byn" path="res://Objects/Museum/AshBarrel/AshBottom.png" id="4_n8vro"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_gwc7g"]
|
||||
bg_color = Color(0.87451, 0.882353, 0.886275, 1)
|
||||
border_width_left = 4
|
||||
border_width_top = 4
|
||||
border_width_right = 4
|
||||
border_width_bottom = 4
|
||||
border_color = Color(0, 0, 0, 1)
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_evst0"]
|
||||
bg_color = Color(0.6, 0.6, 0.6, 0)
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_hiy88"]
|
||||
bg_color = Color(0.819608, 0, 0.34902, 1)
|
||||
border_color = Color(0, 0.235294, 0.909804, 1)
|
||||
|
||||
[node name="AshBarrelWindow" type="Window"]
|
||||
process_mode = 3
|
||||
size = Vector2i(600, 500)
|
||||
borderless = true
|
||||
script = ExtResource("1_dx65t")
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="."]
|
||||
custom_minimum_size = Vector2(600, 500)
|
||||
offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_gwc7g")
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 13
|
||||
|
||||
[node name="Label" type="Label" parent="PanelContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 0
|
||||
theme_override_colors/font_color = Color(0.65098, 0.647059, 0.627451, 1)
|
||||
theme_override_colors/font_outline_color = Color(0, 0, 0, 1)
|
||||
theme_override_constants/outline_size = 16
|
||||
theme_override_font_sizes/font_size = 32
|
||||
text = "Ash Barrel"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 2
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="PanelContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
theme_override_constants/margin_left = 14
|
||||
theme_override_constants/margin_right = 14
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="PanelContainer/VBoxContainer/MarginContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
theme_override_constants/separation = 14
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer/VBoxContainer/MarginContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="InventoryDisplayer" parent="PanelContainer/VBoxContainer/MarginContainer/HBoxContainer/VBoxContainer" instance=ExtResource("2_teuni")]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
|
||||
[node name="CheckButton" type="CheckButton" parent="PanelContainer/VBoxContainer/MarginContainer/HBoxContainer/VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
theme_override_colors/font_color = Color(0, 0, 0, 1)
|
||||
theme_override_colors/font_pressed_color = Color(0, 0, 0, 1)
|
||||
theme_override_colors/font_hover_color = Color(0, 0, 0, 1)
|
||||
theme_override_colors/font_hover_pressed_color = Color(0, 0, 0, 1)
|
||||
theme_override_colors/font_focus_color = Color(0, 0, 0, 1)
|
||||
theme_override_colors/font_disabled_color = Color(0, 0, 0, 1)
|
||||
theme_override_colors/font_outline_color = Color(0, 0, 0, 1)
|
||||
text = "Prevent Adding Duplicates"
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="PanelContainer/VBoxContainer/MarginContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
mouse_filter = 2
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer/VBoxContainer/MarginContainer/HBoxContainer/PanelContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label" type="Label" parent="PanelContainer/VBoxContainer/MarginContainer/HBoxContainer/PanelContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_colors/font_color = Color(0, 0, 0, 1)
|
||||
theme_override_font_sizes/font_size = 21
|
||||
text = "Barrel Contents"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 2
|
||||
|
||||
[node name="AshBarrelContents" parent="PanelContainer/VBoxContainer/MarginContainer/HBoxContainer/PanelContainer/VBoxContainer" instance=ExtResource("3_xickp")]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Node2D" type="Node2D" parent="PanelContainer/VBoxContainer/MarginContainer/HBoxContainer/PanelContainer/VBoxContainer"]
|
||||
position = Vector2(30, 50)
|
||||
|
||||
[node name="AshProgress" type="ProgressBar" parent="PanelContainer/VBoxContainer/MarginContainer/HBoxContainer/PanelContainer/VBoxContainer/Node2D"]
|
||||
unique_name_in_owner = true
|
||||
offset_top = 160.0
|
||||
offset_right = 210.0
|
||||
offset_bottom = 300.0
|
||||
theme_override_styles/background = SubResource("StyleBoxFlat_evst0")
|
||||
theme_override_styles/fill = SubResource("StyleBoxFlat_hiy88")
|
||||
value = 80.0
|
||||
fill_mode = 3
|
||||
show_percentage = false
|
||||
|
||||
[node name="AshBottom" type="Sprite2D" parent="PanelContainer/VBoxContainer/MarginContainer/HBoxContainer/PanelContainer/VBoxContainer/Node2D"]
|
||||
unique_name_in_owner = true
|
||||
position = Vector2(105, 227)
|
||||
scale = Vector2(0.8, 0.8)
|
||||
texture = ExtResource("4_n8vro")
|
||||
|
||||
[node name="BarrelSprite2" type="Sprite2D" parent="PanelContainer/VBoxContainer/MarginContainer/HBoxContainer/PanelContainer/VBoxContainer"]
|
||||
clip_children = 2
|
||||
position = Vector2(137, 277)
|
||||
scale = Vector2(0.8, 0.8)
|
||||
texture = ExtResource("3_lg4rj")
|
||||
|
||||
[node name="Control" type="Control" parent="PanelContainer/VBoxContainer/MarginContainer/HBoxContainer/PanelContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
size_flags_stretch_ratio = 1.75
|
||||
|
||||
[node name="MarginContainer2" type="MarginContainer" parent="PanelContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 47
|
||||
theme_override_constants/margin_right = 42
|
||||
theme_override_constants/margin_bottom = 10
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="PanelContainer/VBoxContainer/MarginContainer2"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_constants/margin_left = 40
|
||||
theme_override_constants/margin_right = 40
|
||||
|
||||
[node name="LeaveButton" type="Button" parent="PanelContainer/VBoxContainer/MarginContainer2/MarginContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Leave"
|
||||
|
||||
[connection signal="toggled" from="PanelContainer/VBoxContainer/MarginContainer/HBoxContainer/VBoxContainer/CheckButton" to="." method="_on_check_button_toggled"]
|
||||
[connection signal="pressed" from="PanelContainer/VBoxContainer/MarginContainer2/MarginContainer/LeaveButton" to="." method="_on_leave_button_pressed"]
|
||||
12
UI/AshBarrel/AshQuantityDisplay.gd
Normal file
12
UI/AshBarrel/AshQuantityDisplay.gd
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
extends PanelContainer
|
||||
|
||||
var ashName = ""
|
||||
var ashCount = 0
|
||||
|
||||
func set_ash_name(newAshName):
|
||||
%AshName.text = newAshName
|
||||
ashName = newAshName
|
||||
|
||||
func set_ash_count(amount):
|
||||
%AshCount.text = "x" + str(amount)
|
||||
ashCount = amount
|
||||
29
UI/AshBarrel/AshQuantityDisplay.tscn
Normal file
29
UI/AshBarrel/AshQuantityDisplay.tscn
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://cwkj1o1dlonhk"]
|
||||
|
||||
[ext_resource type="Script" path="res://UI/AshBarrel/AshQuantityDisplay.gd" id="1_2bb87"]
|
||||
|
||||
[node name="AshQuantityDisplay" type="PanelContainer"]
|
||||
size_flags_horizontal = 3
|
||||
script = ExtResource("1_2bb87")
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="."]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 10
|
||||
theme_override_constants/margin_right = 10
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="AshName" type="Label" parent="MarginContainer/HBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Caramel Ash"
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="AshCount" type="Label" parent="MarginContainer/HBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "x1333"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
Loading…
Add table
Add a link
Reference in a new issue