Move generator panel ui inside generator
This commit is contained in:
@@ -34,7 +34,8 @@ const HUGE_COST_EXPONENT: int = 1000000
|
||||
## Extra multiplier applied to automatic production output.
|
||||
@export var run_multiplier: float = 1.0
|
||||
|
||||
|
||||
## Reference to generator UI
|
||||
@onready var info_generator_container: GeneratorPanel = $GeneratorPanel
|
||||
|
||||
## True while the pointer is inside the generator Area2D.
|
||||
var _mouse_entered: bool = false
|
||||
@@ -85,14 +86,13 @@ var _generator_id: StringName = &""
|
||||
## Prevents duplicate state registration in GameState.
|
||||
var _is_registered: bool = false
|
||||
|
||||
|
||||
## Resolves and registers this generator state before gameplay updates.
|
||||
func _ready() -> void:
|
||||
assert(currency != null, "Currency cannot be null")
|
||||
assert(data != null, "Data cannot be null")
|
||||
|
||||
_generator_id = _resolve_generator_id()
|
||||
_ensure_registered()
|
||||
#_ensure_registered()
|
||||
cycle_progress_seconds = 0.0
|
||||
|
||||
GameState.currency_changed.connect(_on_currency_changed)
|
||||
@@ -559,10 +559,13 @@ func _default_available_state() -> bool:
|
||||
## Area2D callback: pointer entered generator interaction region.
|
||||
func _on_area_2d_mouse_entered() -> void:
|
||||
_mouse_entered = true
|
||||
info_generator_container.visible = true
|
||||
|
||||
## Area2D callback: pointer exited generator interaction region.
|
||||
func _on_area_2d_mouse_exited() -> void:
|
||||
_mouse_entered = false
|
||||
info_generator_container.visible = false
|
||||
|
||||
|
||||
func _on_generated_state_changed(generator_id: StringName, _state: Dictionary) -> void:
|
||||
if generator_id == _generator_id:
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
[ext_resource type="Resource" uid="uid://brqaojindcxa5" path="res://idles/currencies/magic.tres" id="2_5tmvy"]
|
||||
[ext_resource type="Resource" uid="uid://co0mcc2kvcpo5" path="res://idles/generators/primary_generator.tres" id="3_wx13b"]
|
||||
[ext_resource type="Texture2D" uid="uid://bgtt3wu43tajh" path="res://icon.svg" id="4_ruf1h"]
|
||||
[ext_resource type="PackedScene" uid="uid://ckos7f22pnmyh" path="res://generator_container.tscn" id="5_bb14m"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_y5m1q"]
|
||||
size = Vector2(128, 128)
|
||||
@@ -21,5 +22,12 @@ texture = ExtResource("4_ruf1h")
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D" unique_id=1572620025]
|
||||
shape = SubResource("RectangleShape2D_y5m1q")
|
||||
|
||||
[node name="GeneratorPanel" parent="." unique_id=1129190041 node_paths=PackedStringArray("_generator") instance=ExtResource("5_bb14m")]
|
||||
offset_left = 64.0
|
||||
offset_top = -64.0
|
||||
offset_right = 505.0
|
||||
offset_bottom = 201.5
|
||||
_generator = NodePath("..")
|
||||
|
||||
[connection signal="mouse_entered" from="Area2D" to="." method="_on_area_2d_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="Area2D" to="." method="_on_area_2d_mouse_exited"]
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
[ext_resource type="Resource" uid="uid://04pmc034qupd" path="res://idles/generators/secondary_generator.tres" id="3_4ly0e"]
|
||||
[ext_resource type="PackedScene" uid="uid://btkxru2gdjsgc" path="res://currency_tile.tscn" id="4_6ri4a"]
|
||||
[ext_resource type="Resource" uid="uid://brqaojindcxa5" path="res://idles/currencies/magic.tres" id="5_dl3gy"]
|
||||
[ext_resource type="PackedScene" uid="uid://ckos7f22pnmyh" path="res://generator_container.tscn" id="6_miduw"]
|
||||
[ext_resource type="PackedScene" uid="uid://dirvi76rkoowf" path="res://core/generator-unlock-goals/goals_debug_ui.tscn" id="7_7i63j"]
|
||||
[ext_resource type="Script" uid="uid://1sykgtg24a7g" path="res://core/generator-unlock-goals/generator_unlock_system.gd" id="8_bhig6"]
|
||||
[ext_resource type="Resource" uid="uid://mnuihnwb70ba" path="res://idles/goals/generator_unlock_knowledge.tres" id="9_l765j"]
|
||||
@@ -14,7 +13,8 @@
|
||||
[node name="GeneratorMuseum" type="Node2D" unique_id=1219373683]
|
||||
|
||||
[node name="MagicGenerator" parent="." unique_id=967969064 instance=ExtResource("1_6pne4")]
|
||||
position = Vector2(580, 114)
|
||||
position = Vector2(569, 328)
|
||||
grants_click_while_hovering = true
|
||||
|
||||
[node name="KnowledgeGenerator" parent="." unique_id=2139088546 instance=ExtResource("1_6pne4")]
|
||||
visible = false
|
||||
@@ -41,23 +41,6 @@ offset_right = 160.0
|
||||
offset_bottom = 59.0
|
||||
currency = ExtResource("2_8qilt")
|
||||
|
||||
[node name="MagicGeneratorContainer" parent="UI" unique_id=1129190041 node_paths=PackedStringArray("_generator") instance=ExtResource("6_miduw")]
|
||||
layout_mode = 1
|
||||
offset_left = -19.0
|
||||
offset_top = 50.5
|
||||
offset_right = 422.0
|
||||
offset_bottom = 316.0
|
||||
_generator = NodePath("../../MagicGenerator")
|
||||
|
||||
[node name="KnowledgeGeneratorContainer" parent="UI" unique_id=1999544736 node_paths=PackedStringArray("_generator") instance=ExtResource("6_miduw")]
|
||||
visible = false
|
||||
layout_mode = 1
|
||||
offset_left = -16.0
|
||||
offset_top = 352.0
|
||||
offset_right = 417.0
|
||||
offset_bottom = 626.0
|
||||
_generator = NodePath("../../KnowledgeGenerator")
|
||||
|
||||
[node name="GoalsDebugUI" parent="UI" unique_id=4710697 instance=ExtResource("7_7i63j")]
|
||||
layout_mode = 1
|
||||
offset_left = 846.0
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
extends VBoxContainer
|
||||
class_name GeneratorPanel
|
||||
extends Container
|
||||
|
||||
const GENERATOR_BUFF_TILE_SCENE: PackedScene = preload("res://generator_buff_tile.tscn")
|
||||
|
||||
@@ -12,22 +13,25 @@ class BuffRow extends RefCounted:
|
||||
|
||||
@export var _generator: CurrencyGenerator
|
||||
|
||||
@onready var _buy_button: Button = $HBoxContainerGenerators/BuyOneButton
|
||||
@onready var _buy_max_button: Button = $HBoxContainerGenerators/BuyMaxButton
|
||||
@onready var _name_label: Label = $Label
|
||||
@onready var _owned_value: Label = $GeneratorStatsGrid/OwnedValue
|
||||
@onready var _next_cost_value: Label = $GeneratorStatsGrid/NextCostValue
|
||||
@onready var _production_value: Label = $GeneratorStatsGrid/ProductionValue
|
||||
@onready var _buffs_section: VBoxContainer = $BuffsSection
|
||||
@onready var _buffs_list: VBoxContainer = $BuffsSection/BuffsList
|
||||
@onready var _buy_button: Button = $VBoxContainer/HBoxContainerGenerators/BuyOneButton
|
||||
@onready var _buy_max_button: Button = $VBoxContainer/HBoxContainerGenerators/BuyMaxButton
|
||||
@onready var _name_label: Label = $VBoxContainer/Label
|
||||
@onready var _owned_value: Label = $VBoxContainer/GeneratorStatsGrid/OwnedValue
|
||||
@onready var _next_cost_value: Label = $VBoxContainer/GeneratorStatsGrid/NextCostValue
|
||||
@onready var _production_value: Label = $VBoxContainer/GeneratorStatsGrid/ProductionValue
|
||||
@onready var _buffs_section: VBoxContainer = $VBoxContainer/BuffsSection
|
||||
@onready var _buffs_list: VBoxContainer = $VBoxContainer/BuffsSection/BuffsList
|
||||
|
||||
var _buff_rows: Array[BuffRow] = []
|
||||
var _generator_id: StringName = &""
|
||||
|
||||
func _ready() -> void:
|
||||
if _generator == null:
|
||||
push_warning("GeneratorContainer '%s' has no generator assigned." % String(name))
|
||||
return
|
||||
|
||||
_generator_id = _generator.get_generator_id()
|
||||
|
||||
_generator.purchase_completed.connect(_on_generator_updated)
|
||||
_generator.production_tick.connect(_on_generator_updated)
|
||||
_generator.purchase_failed.connect(_on_generator_updated)
|
||||
@@ -62,18 +66,18 @@ func _on_generator_updated(_a = null, _b = null, _c = null, _d = null) -> void:
|
||||
_refresh_generator_ui()
|
||||
|
||||
func _on_generator_state_changed(generator_id: StringName, _state: Dictionary) -> void:
|
||||
if generator_id == _generator.get_generator_id():
|
||||
if generator_id == _generator_id:
|
||||
visible = true
|
||||
_refresh_generator_ui()
|
||||
|
||||
func _on_generator_buff_level_changed(generator_id: StringName, _buff_id: StringName, _new_level: int) -> void:
|
||||
if generator_id != _generator.get_generator_id():
|
||||
if generator_id != _generator_id:
|
||||
return
|
||||
|
||||
_refresh_generator_ui()
|
||||
|
||||
func _on_generator_buff_unlocked_changed(generator_id: StringName, _buff_id: StringName, _unlocked: bool) -> void:
|
||||
if generator_id != _generator.get_generator_id():
|
||||
if generator_id != _generator_id:
|
||||
return
|
||||
|
||||
_refresh_generator_ui()
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
[ext_resource type="Script" uid="uid://es14nqk6vrrk" path="res://generator_container.gd" id="1_8wouw"]
|
||||
|
||||
[node name="GeneratorContainer" type="VBoxContainer" unique_id=1129190041]
|
||||
[node name="GeneratorContainer" type="MarginContainer" unique_id=1253142977]
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
@@ -11,65 +11,71 @@ anchor_bottom = 0.5
|
||||
offset_left = -132.0
|
||||
offset_top = -82.5
|
||||
offset_right = 132.0
|
||||
offset_bottom = 82.5
|
||||
offset_bottom = 87.5
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_constants/margin_left = 20
|
||||
script = ExtResource("1_8wouw")
|
||||
|
||||
[node name="Label" type="Label" parent="." unique_id=1867673612]
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="." unique_id=1139263929]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label" type="Label" parent="VBoxContainer" unique_id=1867673612]
|
||||
layout_mode = 2
|
||||
text = "Generator"
|
||||
|
||||
[node name="HBoxContainerGenerators" type="HBoxContainer" parent="." unique_id=2033456807]
|
||||
[node name="HBoxContainerGenerators" type="HBoxContainer" parent="VBoxContainer" unique_id=2033456807]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 8
|
||||
|
||||
[node name="BuyOneButton" type="Button" parent="HBoxContainerGenerators" unique_id=1171095139]
|
||||
[node name="BuyOneButton" type="Button" parent="VBoxContainer/HBoxContainerGenerators" unique_id=1171095139]
|
||||
layout_mode = 2
|
||||
text = "Buy x1"
|
||||
|
||||
[node name="BuyMaxButton" type="Button" parent="HBoxContainerGenerators" unique_id=871628534]
|
||||
[node name="BuyMaxButton" type="Button" parent="VBoxContainer/HBoxContainerGenerators" unique_id=871628534]
|
||||
layout_mode = 2
|
||||
text = "Buy Max"
|
||||
|
||||
[node name="GeneratorStatsGrid" type="GridContainer" parent="." unique_id=745078076]
|
||||
[node name="GeneratorStatsGrid" type="GridContainer" parent="VBoxContainer" unique_id=745078076]
|
||||
layout_mode = 2
|
||||
columns = 2
|
||||
|
||||
[node name="OwnedTitle" type="Label" parent="GeneratorStatsGrid" unique_id=891417119]
|
||||
[node name="OwnedTitle" type="Label" parent="VBoxContainer/GeneratorStatsGrid" unique_id=891417119]
|
||||
layout_mode = 2
|
||||
text = "Owned"
|
||||
|
||||
[node name="OwnedValue" type="Label" parent="GeneratorStatsGrid" unique_id=549086894]
|
||||
[node name="OwnedValue" type="Label" parent="VBoxContainer/GeneratorStatsGrid" unique_id=549086894]
|
||||
layout_mode = 2
|
||||
text = "0"
|
||||
|
||||
[node name="NextCostTitle" type="Label" parent="GeneratorStatsGrid" unique_id=303459589]
|
||||
[node name="NextCostTitle" type="Label" parent="VBoxContainer/GeneratorStatsGrid" unique_id=303459589]
|
||||
layout_mode = 2
|
||||
text = "Next Cost"
|
||||
|
||||
[node name="NextCostValue" type="Label" parent="GeneratorStatsGrid" unique_id=50480604]
|
||||
[node name="NextCostValue" type="Label" parent="VBoxContainer/GeneratorStatsGrid" unique_id=50480604]
|
||||
layout_mode = 2
|
||||
text = "0"
|
||||
|
||||
[node name="ProductionTitle" type="Label" parent="GeneratorStatsGrid" unique_id=2139535774]
|
||||
[node name="ProductionTitle" type="Label" parent="VBoxContainer/GeneratorStatsGrid" unique_id=2139535774]
|
||||
layout_mode = 2
|
||||
text = "Production / sec"
|
||||
|
||||
[node name="ProductionValue" type="Label" parent="GeneratorStatsGrid" unique_id=938669936]
|
||||
[node name="ProductionValue" type="Label" parent="VBoxContainer/GeneratorStatsGrid" unique_id=938669936]
|
||||
layout_mode = 2
|
||||
text = "0"
|
||||
|
||||
[node name="BuffsSection" type="VBoxContainer" parent="."]
|
||||
[node name="BuffsSection" type="VBoxContainer" parent="VBoxContainer" unique_id=640102105]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="BuffsTitle" type="Label" parent="BuffsSection"]
|
||||
[node name="BuffsTitle" type="Label" parent="VBoxContainer/BuffsSection" unique_id=1169271241]
|
||||
layout_mode = 2
|
||||
text = "Buffs"
|
||||
|
||||
[node name="BuffsList" type="VBoxContainer" parent="BuffsSection"]
|
||||
[node name="BuffsList" type="VBoxContainer" parent="VBoxContainer/BuffsSection" unique_id=1221547661]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 4
|
||||
|
||||
[connection signal="pressed" from="HBoxContainerGenerators/BuyOneButton" to="." method="_on_buy_pressed"]
|
||||
[connection signal="pressed" from="HBoxContainerGenerators/BuyMaxButton" to="." method="_on_buy_max_pressed"]
|
||||
[connection signal="mouse_entered" from="." to="." method="_on_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="." to="." method="_on_mouse_exited"]
|
||||
[connection signal="pressed" from="VBoxContainer/HBoxContainerGenerators/BuyOneButton" to="." method="_on_buy_pressed"]
|
||||
[connection signal="pressed" from="VBoxContainer/HBoxContainerGenerators/BuyMaxButton" to="." method="_on_buy_max_pressed"]
|
||||
|
||||
@@ -20,6 +20,11 @@ config/icon="res://icon.svg"
|
||||
CurrencyDatabase="*res://core/currency_database.gd"
|
||||
GameState="*uid://d2j7tvlgxr2jp"
|
||||
|
||||
[display]
|
||||
|
||||
window/size/viewport_width=1920
|
||||
window/size/viewport_height=1080
|
||||
|
||||
[input]
|
||||
|
||||
click={
|
||||
|
||||
Reference in New Issue
Block a user