aboutsummaryrefslogtreecommitdiff
path: root/game/src/GameSession/MapControlPanel.gd
blob: cfd102c4db45b7d05d1094df61253e6507bc6e5e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
extends PanelContainer

signal game_session_menu_button_pressed
signal mapmode_changed

@export var _mapmodes_grid : GridContainer
var _mapmode_button_group : ButtonGroup

func _add_mapmode_button(identifier : String) -> void:
   var button := Button.new()
   button.text = identifier
   button.tooltip_text = identifier
   button.toggle_mode = true
   button.button_group = _mapmode_button_group
   _mapmodes_grid.add_child(button)
   if _mapmode_button_group.get_pressed_button() == null:
      button.button_pressed = true

func _ready():
   _mapmode_button_group = ButtonGroup.new()
   _mapmode_button_group.pressed.connect(_mapmode_pressed)
   for index in MapSingleton.get_mapmode_count():
      _add_mapmode_button(MapSingleton.get_mapmode_identifier(index))

# REQUIREMENTS:
# * UIFUN-10
func _on_game_session_menu_button_pressed() -> void:
   game_session_menu_button_pressed.emit()

func _mapmode_pressed(button : BaseButton) -> void:
   MapSingleton.set_mapmode(button.tooltip_text)
   mapmode_changed.emit()