aboutsummaryrefslogtreecommitdiff
path: root/game/src/GameSession/MapControlPanel.gd
diff options
context:
space:
mode:
author George L. Albany <Megacake1234@gmail.com>2023-04-14 18:31:58 +0200
committer GitHub <noreply@github.com>2023-04-14 18:31:58 +0200
commit436b038c1806e326ff6458f1692e9009d3a54346 (patch)
treeb5a33a733398b511eb0aa7781860c8accbadd2a0 /game/src/GameSession/MapControlPanel.gd
parent1f04a7827ae377372cb491ff0257a47d0d4c2967 (diff)
parent7241811bd8c9493b7b6c6480e8d63a5fb7f38e4e (diff)
Merge pull request #84 from OpenVic2Project/terrain-map
Diffstat (limited to 'game/src/GameSession/MapControlPanel.gd')
-rw-r--r--game/src/GameSession/MapControlPanel.gd40
1 files changed, 39 insertions, 1 deletions
diff --git a/game/src/GameSession/MapControlPanel.gd b/game/src/GameSession/MapControlPanel.gd
index ad56536..693890f 100644
--- a/game/src/GameSession/MapControlPanel.gd
+++ b/game/src/GameSession/MapControlPanel.gd
@@ -1,8 +1,46 @@
extends PanelContainer
signal game_session_menu_button_pressed
+signal mapmode_changed
+signal map_view_camera_changed(near_left : Vector2, far_left : Vector2, far_right : Vector2, near_right : Vector2)
+signal minimap_clicked(pos_clicked : Vector2)
+
+@export var _mapmodes_grid : GridContainer
+
+var _mapmode_button_group : ButtonGroup
+
+# REQUIREMENTS:
+# * UI-550, UI-554
+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():
+func _on_game_session_menu_button_pressed() -> void:
game_session_menu_button_pressed.emit()
+
+# REQUIREMENTS:
+# * SS-76
+# * UIFUN-129, UIFUN-133
+func _mapmode_pressed(button : BaseButton) -> void:
+ MapSingleton.set_mapmode(button.tooltip_text)
+ mapmode_changed.emit()
+
+func _on_map_view_camera_changed(near_left : Vector2, far_left : Vector2, far_right : Vector2, near_right : Vector2) -> void:
+ map_view_camera_changed.emit(near_left, far_left, far_right, near_right)
+
+func _on_minimap_clicked(pos_clicked : Vector2) -> void:
+ minimap_clicked.emit(pos_clicked)