31 lines
897 B
GDScript
31 lines
897 B
GDScript
extends HFlowContainer
|
|
|
|
var button_prefix="btn_map_"
|
|
var disabled_mod_color=Color(0.3,0.3,0.3,1.0)
|
|
|
|
signal map_changed
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready() -> void:
|
|
for btn in get_children():
|
|
btn.pressed.connect(_on_btn_map.bind(btn))
|
|
|
|
if len(Gamestate.getSelectedMap())<=0: #no map selected (ie on startup)
|
|
get_children()[0].emit_signal("pressed") #preselect first map in list
|
|
else:
|
|
for c in get_children():
|
|
if c.name==button_prefix+Gamestate.getSelectedMap():
|
|
c.emit_signal("pressed")
|
|
break
|
|
|
|
|
|
|
|
func _on_btn_map(btn):
|
|
map_changed.emit()
|
|
for b in get_children():
|
|
b.self_modulate=disabled_mod_color #show all others disabled
|
|
btn.self_modulate=Color(1,1,1,1) #show selected enabled
|
|
var btn_name=btn.name
|
|
var mapname=btn_name.erase(0,len(button_prefix))
|
|
print("Selected Map="+str(mapname))
|
|
Gamestate.setSelectedMap(mapname)
|