45 lines
1.6 KiB
GDScript
45 lines
1.6 KiB
GDScript
extends GridContainer
|
|
|
|
func _ready():
|
|
load_boss_buttons()
|
|
|
|
func load_boss_buttons():
|
|
if "bosses" in BossDatabase.boss_data:
|
|
for boss in BossDatabase.boss_data["bosses"]:
|
|
var button = create_boss_button(boss)
|
|
add_child(button)
|
|
else:
|
|
print("No bosses found in boss data.")
|
|
|
|
|
|
func create_boss_button(boss: Dictionary) -> TextureButton:
|
|
var button = TextureButton.new()
|
|
#Loads the texture specified in the memberData sheet
|
|
if boss.has("texturePath"):
|
|
button.texture_normal = load(boss["texturePath"])
|
|
else:
|
|
button.texture_normal = preload("res://Images/Members/Soldier.png") # Use a default texture if none is specified
|
|
button.connect("pressed", Callable(self, "_on_button_pressed").bind(button, boss))
|
|
button.connect("mouse_entered", Callable(self, "_on_button_hovered").bind(button, boss))
|
|
button.connect("mouse_exited", Callable(self, "_on_button_exited").bind(button))
|
|
return button
|
|
|
|
|
|
func _on_button_hovered(button: TextureButton, boss: Dictionary):
|
|
#current_member = member
|
|
#The backslash \ allows you to continue to the next line while concatenating the string
|
|
var tooltip_text = "" + str(boss["name"]) + "\n" + "" + str(boss["description"]) + "\n" + "Total Health: " + str(boss["totalHealth"]) + "\n" + \
|
|
"Minimum DPS Required: " + str(boss["minDPS"])
|
|
button.tooltip_text = tooltip_text
|
|
|
|
# Function called when the mouse exits the button
|
|
func _on_button_exited(button: TextureButton):
|
|
button.tooltip_text = ""
|
|
|
|
|
|
func _on_button_pressed(button: TextureButton, boss: Dictionary):
|
|
#var character_manager = get_node("/root/Root/UI/CharacterRoll")
|
|
#character_manager.roll_character()
|
|
|
|
$CharacterRoll.roll_character()
|