aboutsummaryrefslogtreecommitdiff
path: root/game
diff options
context:
space:
mode:
Diffstat (limited to 'game')
-rw-r--r--game/localisation/en_GB/menus.csv9
-rw-r--r--game/localisation/en_GB/provinces.csv374
-rw-r--r--game/localisation/en_GB/regions.csv12
-rw-r--r--game/src/Autoload/Events.gd9
-rw-r--r--game/src/GameSession/GameSession.gd5
-rw-r--r--game/src/GameSession/GameSessionMenu.gd1
-rw-r--r--game/src/GameSession/GameSpeedPanel.gd29
-rw-r--r--game/src/GameSession/MapControlPanel.gd6
-rw-r--r--game/src/GameSession/MapView.gd21
-rw-r--r--game/src/GameSession/ProvinceOverviewPanel.gd82
-rw-r--r--game/src/GameSession/ProvinceOverviewPanel.tscn14
11 files changed, 320 insertions, 242 deletions
diff --git a/game/localisation/en_GB/menus.csv b/game/localisation/en_GB/menus.csv
index 33e5c42..c637a39 100644
--- a/game/localisation/en_GB/menus.csv
+++ b/game/localisation/en_GB/menus.csv
@@ -63,3 +63,12 @@ GAMESESSIONMENU_QUIT_DIALOG_TEXT,Are you sure you want to quit and return to des
DIALOG_OK,OK
DIALOG_CANCEL,Cancel
+
+,, Province Overview Panel
+province_MISSING,No Province
+region_MISSING,No Region
+building_MISSING,No Building
+building_fort,Fort
+building_naval_base,Naval Base
+building_railroad,Railroad
+EXPAND_PROVINCE_BUILDING,Expand
diff --git a/game/localisation/en_GB/provinces.csv b/game/localisation/en_GB/provinces.csv
index 814b4f9..8f1679d 100644
--- a/game/localisation/en_GB/provinces.csv
+++ b/game/localisation/en_GB/provinces.csv
@@ -1,51 +1,51 @@
,, Europe
-prov_britain_NAME,Britain
-prov_ireland_NAME,Ireland
-prov_iceland_NAME,Iceland
-prov_corsica_NAME,Corsica
-prov_sardinia_NAME,Sardinia
-prov_sicily_NAME,Sicily
-prov_malta_NAME,Malta
-prov_cyprus_NAME,Cyprus
-prov_greenland_NAME,Greenland
-prov_baleares_NAME,Balearic Islands
-prov_gotland_NAME,Gotland
-prov_crete_NAME,Crete
-prov_jan_mayen_NAME,Jan Mayen
-prov_faroes_NAME,Faroe Islands
-prov_mann_NAME,Isle of Mann
-prov_shetlands_NAME,Shetlands
-prov_orkney_NAME,Orkney
-prov_channel_islands_NAME,Channel Islands
-prov_madiera_NAME,Madiera
-prov_canarias_NAME,Canarias
-prov_sjaeland_NAME,Sjaeland
-prov_bornholm_NAME,Bornholm
-prov_bear_island_NAME,Bear Island
-prov_pantelleria_NAME,Pantelleria
-prov_iberia_NAME,Iberia
-prov_scandinavia_NAME,Scandinavia
-prov_jutland_NAME,Jutland
-prov_fyn_NAME,Fyn
-prov_hiiumaa_NAME,Hiiumaa
-prov_saaremaa_NAME,Saaremaa
-prov_italy_NAME,Italy
-prov_elba_NAME,Elba
-prov_france_NAME,France
-prov_netherlands_NAME,Netherlands
-prov_belgium_NAME,Belgium
-prov_luxembourg_NAME,Luxembourg
-prov_switzerland_NAME,Switzerland
-prov_balkans_NAME,Balkans
-prov_crimea_NAME,Crimea
-prov_germany_NAME,Germany
-prov_poland_NAME,Poland
-prov_baltics_NAME,Baltics
-prov_finland_NAME,Finland
-prov_aland_NAME,Åland
-prov_ukraine_NAME,Ukraine
-prov_russia_NAME,Russia
+prov_britain,Britain
+prov_ireland,Ireland
+prov_iceland,Iceland
+prov_corsica,Corsica
+prov_sardinia,Sardinia
+prov_sicily,Sicily
+prov_malta,Malta
+prov_cyprus,Cyprus
+prov_greenland,Greenland
+prov_baleares,Balearic Islands
+prov_gotland,Gotland
+prov_crete,Crete
+prov_jan_mayen,Jan Mayen
+prov_faroes,Faroe Islands
+prov_mann,Isle of Mann
+prov_shetlands,Shetlands
+prov_orkney,Orkney
+prov_channel_islands,Channel Islands
+prov_madiera,Madiera
+prov_canarias,Canarias
+prov_sjaeland,Sjaeland
+prov_bornholm,Bornholm
+prov_bear_island,Bear Island
+prov_pantelleria,Pantelleria
+prov_iberia,Iberia
+prov_scandinavia,Scandinavia
+prov_jutland,Jutland
+prov_fyn,Fyn
+prov_hiiumaa,Hiiumaa
+prov_saaremaa,Saaremaa
+prov_italy,Italy
+prov_elba,Elba
+prov_france,France
+prov_netherlands,Netherlands
+prov_belgium,Belgium
+prov_luxembourg,Luxembourg
+prov_switzerland,Switzerland
+prov_balkans,Balkans
+prov_crimea,Crimea
+prov_germany,Germany
+prov_poland,Poland
+prov_baltics,Baltics
+prov_finland,Finland
+prov_aland,Åland
+prov_ukraine,Ukraine
+prov_russia,Russia
,, North America
prov_north_america_NAME,North America
@@ -92,154 +92,154 @@ prov_yellowknife_NAME,Yellowknife
prov_iqaluit_NAME,Iqaluit
,, South America
-prov_south_america_NAME,South America
-prov_galapagos_NAME,Galapagos
-prov_falklands_NAME,Falklands
-prov_south_georgia_NAME,South Georgia
+prov_south_america,South America
+prov_galapagos,Galapagos
+prov_falklands,Falklands
+prov_south_georgia,South Georgia
,, Africa
-prov_africa_NAME,Africa
-prov_madagascar_NAME,Madagascar
-prov_socotra_NAME,Socotra
-prov_mauritius_NAME,Mauritius
-prov_reunion_NAME,Réunion
-prov_comoros_NAME,Comoros
-prov_sao_tome_NAME,Sao Tome
-prov_fernando_po_NAME,Fernando Po
-prov_cape_verde_NAME,Cape Verde
-prov_ascension_NAME,Ascension
-prov_st_helena_NAME,St Helena
-prov_tristan_da_cunha_NAME,Tristan da Cunha
-prov_seychelles_NAME,Seychelles
-prov_prince_edward_islands_NAME,Prince Edward Islands
-prov_kerguelen_islands_NAME,Kerguelen Islands
-prov_heard_island_NAME,Heard Island
-prov_egypt_NAME,Egypt
-prov_morocco_NAME,Morocco
+prov_africa,Africa
+prov_madagascar,Madagascar
+prov_socotra,Socotra
+prov_mauritius,Mauritius
+prov_reunion,Réunion
+prov_comoros,Comoros
+prov_sao_tome,Sao Tome
+prov_fernando_po,Fernando Po
+prov_cape_verde,Cape Verde
+prov_ascension,Ascension
+prov_st_helena,St Helena
+prov_tristan_da_cunha,Tristan da Cunha
+prov_seychelles,Seychelles
+prov_prince_edward_islands,Prince Edward Islands
+prov_kerguelen_islands,Kerguelen Islands
+prov_heard_island,Heard Island
+prov_egypt,Egypt
+prov_morocco,Morocco
,, Asia
-prov_middle_east_NAME,Middle East
-prov_ceylon_NAME,Ceylon
-prov_formosa_NAME,Formosa
-prov_sakhalin_NAME,Sakhalin
-prov_maldives_NAME,Maldives
-prov_hainan_NAME,Hainan
-prov_hokkaido_NAME,Hokkaido
-prov_diego_garcia_NAME,Diego Garcia
-prov_philippines_NAME,Philippines
-prov_india_NAME,India
-prov_andamans_NAME,Andaman Islands
-prov_nicobar_islands_NAME,Nicobar Islands
-prov_indochina_NAME,Indochina
-prov_korea_NAME,Korea
-prov_okinawa_NAME,Okinawa
-prov_yaeyama_NAME,Yaeyama
-prov_kyushu_NAME,Kyushu
-prov_shikoku_NAME,Shikoku
-prov_japan_NAME,Japan
-prov_kurils_NAME,Kuril Islands
-prov_manchuria_NAME,Manchuria
-prov_china_NAME,China
-prov_central_asia_NAME,Central Asia
-prov_siberia_NAME,Siberia
-prov_iran_NAME,Iran
-prov_anatolia_NAME,Anatolia
+prov_middle_east,Middle East
+prov_ceylon,Ceylon
+prov_formosa,Formosa
+prov_sakhalin,Sakhalin
+prov_maldives,Maldives
+prov_hainan,Hainan
+prov_hokkaido,Hokkaido
+prov_diego_garcia,Diego Garcia
+prov_philippines,Philippines
+prov_india,India
+prov_andamans,Andaman Islands
+prov_nicobar_islands,Nicobar Islands
+prov_indochina,Indochina
+prov_korea,Korea
+prov_okinawa,Okinawa
+prov_yaeyama,Yaeyama
+prov_kyushu,Kyushu
+prov_shikoku,Shikoku
+prov_japan,Japan
+prov_kurils,Kuril Islands
+prov_manchuria,Manchuria
+prov_china,China
+prov_central_asia,Central Asia
+prov_siberia,Siberia
+prov_iran,Iran
+prov_anatolia,Anatolia
,, Oceania
-prov_oceania_NAME,Oceania
-prov_indonesia_NAME,Indonesia
-prov_north_island_NAME,North Island
-prov_south_island_NAME,South Island
-prov_tasmania_NAME,Tasmania
-prov_australia_NAME,Australia
-prov_hawaii_NAME,Hawaii
+prov_oceania,Oceania
+prov_indonesia,Indonesia
+prov_north_island,North Island
+prov_south_island,South Island
+prov_tasmania,Tasmania
+prov_australia,Australia
+prov_hawaii,Hawaii
,, Lakes
-prov_aral_sea_NAME,Aral Sea
-prov_caspian_sea_NAME,Caspian Sea
-prov_lake_ladoga_NAME,Lake Ladoga
-prov_lake_ontario_NAME,Lake Ontario
-prov_lake_erie_NAME,Lake Erie
-prov_lake_huron_NAME,Lake Huron
-prov_lake_michigan_NAME,Lake Michigan
-prov_lake_superior_NAME,Lake Superior
-prov_lake_baikal_NAME,Lake Baikal
-prov_lake_woods_NAME,Lake of the Woods
-prov_lake_manitoba_NAME,Lake Manitoba
-prov_reindeer_lake_NAME,Reindeer Lake
-prov_lake_ronge_NAME,Lac la Ronge
-prov_lake_athabasca_NAME,Lake Athabasca
-prov_great_slave_lake_NAME,Great Slave Lake
-prov_great_bear_lake_NAME,Great Bear Lake
+prov_aral_sea,Aral Sea
+prov_caspian_sea,Caspian Sea
+prov_lake_ladoga,Lake Ladoga
+prov_lake_ontario,Lake Ontario
+prov_lake_erie,Lake Erie
+prov_lake_huron,Lake Huron
+prov_lake_michigan,Lake Michigan
+prov_lake_superior,Lake Superior
+prov_lake_baikal,Lake Baikal
+prov_lake_woods,Lake of the Woods
+prov_lake_manitoba,Lake Manitoba
+prov_reindeer_lake,Reindeer Lake
+prov_lake_ronge,Lac la Ronge
+prov_lake_athabasca,Lake Athabasca
+prov_great_slave_lake,Great Slave Lake
+prov_great_bear_lake,Great Bear Lake
,, Seas and Oceans
-prov_azov_sea_NAME,Sea of Azov
-prov_black_sea_NAME,Black Sea
-prov_marmara_sea_NAME,Sea of Marmara
-prov_agean_sea_NAME,Agean Sea
-prov_ionian_sea_NAME,Ionian Sea
-prov_adriatic_sea_NAME,Adriatic Sea
-prov_tyrrhenian_sea_NAME,Tyrrhenian Sea
-prov_east_mediterranean_NAME,East Mediterranean Sea
-prov_central_mediterranean_NAME,Central Mediterranean Sea
-prov_west_mediterranean_NAME,West Mediterranean Sea
-prov_ligurian_sea_NAME,Ligurian Sea
-prov_balearic_sea_NAME,Balearic Sea
-prov_alboran_sea_NAME,Alboran Sea
-prov_gulf_bothnia_NAME,Gulf of Bothnia
-prov_gulf_finland_NAME,Gulf of Finland
-prov_gulf_riga_NAME,Gulf of Riga
-prov_baltic_sea_NAME,Baltic Sea
-prov_danish_straits_NAME,Danish Straits
-prov_english_channel_NAME,English Channel
-prov_irish_sea_NAME,Irish Sea
-prov_biscay_bay_NAME,Bay of Biscay
-prov_north_sea_NAME,North Sea
-prov_red_sea_NAME,Red Sea
-prov_arabian_sea_NAME,Arabian Sea
-prov_persian_gulf_NAME,Persian Gulf
-prov_andaman_sea_NAME,Andaman Sea
-prov_bay_bengal_NAME,Bay of Bengal
-prov_okhotsk_sea_NAME,Sea of Okhotsk
-prov_japan_sea_NAME,Sea of Japan
-prov_east_china_sea_NAME,East China Sea
-prov_south_china_sea_NAME,South China Sea
-prov_philippine_sea_NAME,Philippine Sea
-prov_celebes_sea_NAME,Celebes Sea
-prov_java_sea_NAME,Java Sea
-prov_banda_sea_NAME,Banda Sea
-prov_arafura_sea_NAME,Arafura Sea
-prov_gulf_mexico_NAME,Gulf of Mexico
-prov_caribbean_sea_NAME,Caribbean Sea
-prov_mozambique_channel_NAME,Mozambique Channel
-prov_zanj_sea_NAME,Sea of Zanj
-prov_kara_sea_NAME,Kara Sea
-prov_barents_sea_NAME,Barents Sea
-prov_norwegian_sea_NAME,Norwegian Sea
-prov_greenland_sea_NAME,Greenland Sea
-prov_labrador_sea_NAME,Labrador Sea
-prov_hudson_bay_NAME,Hudson Bay
-prov_gulf_st_lawrence_NAME,Gulf of St Lawrence
-prov_gulf_alaska_NAME,Gulf of Alaska
-prov_gulf_california_NAME,Gulf of California
-prov_east_siberian_sea_NAME,East Siberian Sea
-prov_sargasso_sea_NAME,Sargasso Sea
-prov_gulf_guinea_NAME,Gulf of Guinea
-prov_celtic_sea_NAME,Celtic Sea
-prov_argentine_sea_NAME,Argentine Sea
-prov_chilean_sea_NAME,Chilean Sea
-prov_north_atlantic_NAME,North Atlantic Ocean
-prov_central_atlantic_NAME,Central Atlantic Ocean
-prov_south_atlantic_NAME,South Atlantic Ocean
-prov_indian_ocean_NAME,Indian Ocean
-prov_great_australian_bight_NAME,Great Australian Bight
-prov_tasman_sea_NAME,Tasman Sea
-prov_coral_sea_NAME,Coral Sea
-prov_melanesia_NAME,Melanesia
-prov_micronesia_NAME,Micronesia
-prov_polynesia_NAME,Polynesia
-prov_north_pacific_NAME,North Pacific Ocean
-prov_south_pacific_NAME,South Pacific Ocean
-prov_bering_sea_NAME,Bering Sea
-prov_chukchi_sea_NAME,Chukchi Sea
-prov_beaufort_sea_NAME,Beaufort Sea
+prov_azov_sea,Sea of Azov
+prov_black_sea,Black Sea
+prov_marmara_sea,Sea of Marmara
+prov_agean_sea,Agean Sea
+prov_ionian_sea,Ionian Sea
+prov_adriatic_sea,Adriatic Sea
+prov_tyrrhenian_sea,Tyrrhenian Sea
+prov_east_mediterranean,East Mediterranean Sea
+prov_central_mediterranean,Central Mediterranean Sea
+prov_west_mediterranean,West Mediterranean Sea
+prov_ligurian_sea,Ligurian Sea
+prov_balearic_sea,Balearic Sea
+prov_alboran_sea,Alboran Sea
+prov_gulf_bothnia,Gulf of Bothnia
+prov_gulf_finland,Gulf of Finland
+prov_gulf_riga,Gulf of Riga
+prov_baltic_sea,Baltic Sea
+prov_danish_straits,Danish Straits
+prov_english_channel,English Channel
+prov_irish_sea,Irish Sea
+prov_biscay_bay,Bay of Biscay
+prov_north_sea,North Sea
+prov_red_sea,Red Sea
+prov_arabian_sea,Arabian Sea
+prov_persian_gulf,Persian Gulf
+prov_andaman_sea,Andaman Sea
+prov_bay_bengal,Bay of Bengal
+prov_okhotsk_sea,Sea of Okhotsk
+prov_japan_sea,Sea of Japan
+prov_east_china_sea,East China Sea
+prov_south_china_sea,South China Sea
+prov_philippine_sea,Philippine Sea
+prov_celebes_sea,Celebes Sea
+prov_java_sea,Java Sea
+prov_banda_sea,Banda Sea
+prov_arafura_sea,Arafura Sea
+prov_gulf_mexico,Gulf of Mexico
+prov_caribbean_sea,Caribbean Sea
+prov_mozambique_channel,Mozambique Channel
+prov_zanj_sea,Sea of Zanj
+prov_kara_sea,Kara Sea
+prov_barents_sea,Barents Sea
+prov_norwegian_sea,Norwegian Sea
+prov_greenland_sea,Greenland Sea
+prov_labrador_sea,Labrador Sea
+prov_hudson_bay,Hudson Bay
+prov_gulf_st_lawrence,Gulf of St Lawrence
+prov_gulf_alaska,Gulf of Alaska
+prov_gulf_california,Gulf of California
+prov_east_siberian_sea,East Siberian Sea
+prov_sargasso_sea,Sargasso Sea
+prov_gulf_guinea,Gulf of Guinea
+prov_celtic_sea,Celtic Sea
+prov_argentine_sea,Argentine Sea
+prov_chilean_sea,Chilean Sea
+prov_north_atlantic,North Atlantic Ocean
+prov_central_atlantic,Central Atlantic Ocean
+prov_south_atlantic,South Atlantic Ocean
+prov_indian_ocean,Indian Ocean
+prov_great_australian_bight,Great Australian Bight
+prov_tasman_sea,Tasman Sea
+prov_coral_sea,Coral Sea
+prov_melanesia,Melanesia
+prov_micronesia,Micronesia
+prov_polynesia,Polynesia
+prov_north_pacific,North Pacific Ocean
+prov_south_pacific,South Pacific Ocean
+prov_bering_sea,Bering Sea
+prov_chukchi_sea,Chukchi Sea
+prov_beaufort_sea,Beaufort Sea
diff --git a/game/localisation/en_GB/regions.csv b/game/localisation/en_GB/regions.csv
index 8fe8943..258cce6 100644
--- a/game/localisation/en_GB/regions.csv
+++ b/game/localisation/en_GB/regions.csv
@@ -1,8 +1,8 @@
,, Regions
-region_europe_NAME,Europe
-region_north_america_NAME,North America
-region_south_america_NAME,South America
-region_africa_NAME,Africa
-region_asia_NAME,Asia
-region_oceania_NAME,Oceania
+region_europe,Europe
+region_north_america,North America
+region_south_america,South America
+region_africa,Africa
+region_asia,Asia
+region_oceania,Oceania
diff --git a/game/src/Autoload/Events.gd b/game/src/Autoload/Events.gd
index dbd3f9f..0ee2eff 100644
--- a/game/src/Autoload/Events.gd
+++ b/game/src/Autoload/Events.gd
@@ -11,11 +11,12 @@ const _province_shape_file : String = "res://common/map/provinces.png"
# REQUIREMENTS
# * FS-333, FS-334, FS-335, FS-341
func _ready():
- if MapSingleton.load_province_identifier_file(_province_identifier_file) != OK:
+ if GameSingleton.load_province_identifier_file(_province_identifier_file) != OK:
push_error("Failed to load province identifiers")
- if MapSingleton.load_water_province_file(_water_province_file) != OK:
+ if GameSingleton.load_water_province_file(_water_province_file) != OK:
push_error("Failed to load water provinces")
- if MapSingleton.load_region_file(_region_file) != OK:
+ if GameSingleton.load_region_file(_region_file) != OK:
push_error("Failed to load regions")
- if MapSingleton.load_province_shape_file(_province_shape_file) != OK:
+ if GameSingleton.load_province_shape_file(_province_shape_file) != OK:
push_error("Failed to load province shapes")
+ GameSingleton.finished_loading_data()
diff --git a/game/src/GameSession/GameSession.gd b/game/src/GameSession/GameSession.gd
index fe83a8a..2761815 100644
--- a/game/src/GameSession/GameSession.gd
+++ b/game/src/GameSession/GameSession.gd
@@ -5,7 +5,10 @@ extends Control
func _ready():
Events.Options.load_settings_from_file()
+func _process(delta : float):
+ GameSingleton.try_tick()
+
# REQUIREMENTS:
# * SS-42
-func _on_game_session_menu_button_pressed():
+func _on_game_session_menu_button_pressed() -> void:
_game_session_menu.visible = !_game_session_menu.visible
diff --git a/game/src/GameSession/GameSessionMenu.gd b/game/src/GameSession/GameSessionMenu.gd
index 8a76c0f..7d785ca 100644
--- a/game/src/GameSession/GameSessionMenu.gd
+++ b/game/src/GameSession/GameSessionMenu.gd
@@ -8,6 +8,7 @@ signal options_button_pressed
# * SS-47
# * UIFUN-69
func _on_main_menu_confirmed() -> void:
+ # TODO - reset map when going back to main menu
get_tree().change_scene_to_packed(_main_menu_scene)
# REQUIREMENTS:
diff --git a/game/src/GameSession/GameSpeedPanel.gd b/game/src/GameSession/GameSpeedPanel.gd
index 8dc35d7..c203032 100644
--- a/game/src/GameSession/GameSpeedPanel.gd
+++ b/game/src/GameSession/GameSpeedPanel.gd
@@ -7,27 +7,32 @@ extends PanelContainer
@export var _decrease_speed_button : Button
@export var _increase_speed_button : Button
-var is_game_paused : bool = true
-
# Called when the node enters the scene tree for the first time.
func _ready():
- _update_playpause_button()
+ GameSingleton.state_updated.connect(_update_buttons)
+ _update_buttons()
+
+func _update_buttons():
+ _play_pause_display_button.text = "⏸️" if GameSingleton.is_paused() else "▶"
+
+ _increase_speed_button.disabled = not GameSingleton.can_increase_speed()
+ _decrease_speed_button.disabled = not GameSingleton.can_decrease_speed()
-func _update_playpause_button():
- _play_pause_display_button.text = "⏸️" if is_game_paused else "▶"
- print("Game is paused" if is_game_paused else "Game is advancing")
+ _longform_date_button.text = GameSingleton.get_longform_date()
func _on_decrease_speed_button_pressed():
- print("Decrease speed")
+ GameSingleton.decrease_speed()
+ _update_buttons()
func _on_increase_speed_button_pressed():
- print("Increase speed")
+ GameSingleton.increase_speed()
+ _update_buttons()
func _on_play_pause_display_button_pressed():
- is_game_paused = !is_game_paused
- _update_playpause_button()
+ GameSingleton.toggle_paused()
+ _update_buttons()
func _on_longform_date_label_pressed():
- is_game_paused = !is_game_paused
- _update_playpause_button()
+ GameSingleton.toggle_paused()
+ _update_buttons()
diff --git a/game/src/GameSession/MapControlPanel.gd b/game/src/GameSession/MapControlPanel.gd
index d5810c5..73d7e06 100644
--- a/game/src/GameSession/MapControlPanel.gd
+++ b/game/src/GameSession/MapControlPanel.gd
@@ -27,8 +27,8 @@ func _add_mapmode_button(identifier : String) -> void:
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))
+ for index in GameSingleton.get_mapmode_count():
+ _add_mapmode_button(GameSingleton.get_mapmode_identifier(index))
# REQUIREMENTS:
# * UIFUN-10
@@ -39,7 +39,7 @@ func _on_game_session_menu_button_pressed() -> void:
# * SS-76
# * UIFUN-129, UIFUN-133
func _mapmode_pressed(button : BaseButton) -> void:
- MapSingleton.set_mapmode(button.tooltip_text)
+ GameSingleton.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:
diff --git a/game/src/GameSession/MapView.gd b/game/src/GameSession/MapView.gd
index ae49e82..ac060e1 100644
--- a/game/src/GameSession/MapView.gd
+++ b/game/src/GameSession/MapView.gd
@@ -1,6 +1,6 @@
extends Node3D
-signal province_selected(identifier : String)
+signal province_selected(index : int)
signal map_view_camera_changed(near_left : Vector2, far_left : Vector2, far_right : Vector2, near_right : Vector2)
const _action_north : StringName = &"map_north"
@@ -21,7 +21,7 @@ const _shader_param_terrain_tile_factor : StringName = &"terrain_tile_factor"
@export var _camera : Camera3D
@export var _cardinal_move_speed : float = 1.0
-@export var _edge_move_threshold: float = 0.02
+@export var _edge_move_threshold: float = 0.01
@export var _edge_move_speed: float = 2.5
var _drag_anchor : Vector2
var _drag_active : bool = false
@@ -53,7 +53,7 @@ var _viewport_dims : Vector2 = Vector2(1, 1)
# ??? Strange Godot/GDExtension Bug ???
# Upon first opening a clone of this repo with the Godot Editor,
-# if MapSingleton.get_province_index_image is called before MapMesh
+# if GameSingleton.get_province_index_image is called before MapMesh
# is referenced in the script below, then the editor will crash due
# to a failed HashMap lookup. I'm not sure if this is a bug in the
# editor, GDExtension, my own extension, or a combination of them.
@@ -78,7 +78,7 @@ func _ready():
_map_shader_material = map_material
# Province index texture
- _map_province_index_image = MapSingleton.get_province_index_image()
+ _map_province_index_image = GameSingleton.get_province_index_image()
if _map_province_index_image == null:
push_error("Failed to get province index image!")
return
@@ -86,7 +86,7 @@ func _ready():
_map_shader_material.set_shader_parameter(_shader_param_province_index, province_index_texture)
# Province colour texture
- _map_province_colour_image = MapSingleton.get_province_colour_image()
+ _map_province_colour_image = GameSingleton.get_province_colour_image()
if _map_province_colour_image == null:
push_error("Failed to get province colour image!")
return
@@ -99,7 +99,7 @@ func _ready():
_map_mesh = _map_mesh_instance.mesh
# Set map mesh size and get bounds
- _map_image_size = Vector2(Vector2i(MapSingleton.get_width(), MapSingleton.get_height()))
+ _map_image_size = Vector2(Vector2i(GameSingleton.get_width(), GameSingleton.get_height()))
_map_mesh.aspect_ratio = _map_image_size.x / _map_image_size.y
_map_shader_material.set_shader_parameter(_shader_param_terrain_tile_factor, _map_image_size.y / 64.0)
var map_mesh_aabb := _map_mesh.get_core_aabb() * _map_mesh_instance.transform
@@ -120,7 +120,7 @@ func _notification(what : int):
_on_mouse_exited_viewport()
func _update_colour_texture() -> void:
- MapSingleton.update_colour_image()
+ GameSingleton.update_colour_image()
_map_province_colour_texture.update(_map_province_colour_image)
func _world_to_map_coords(pos : Vector3) -> Vector2:
@@ -151,10 +151,9 @@ func _unhandled_input(event : InputEvent):
if _mouse_over_viewport and event.is_action_pressed(_action_click):
# Check if the mouse is outside of bounds
if _map_mesh.is_valid_uv_coord(_mouse_pos_map):
- var selected_index := MapSingleton.get_province_index_from_uv_coords(_mouse_pos_map)
+ var selected_index := GameSingleton.get_province_index_from_uv_coords(_mouse_pos_map)
_map_shader_material.set_shader_parameter(_shader_param_selected_index, selected_index)
- var province_identifier := MapSingleton.get_province_identifier_from_uv_coords(_mouse_pos_map)
- province_selected.emit(province_identifier)
+ province_selected.emit(selected_index)
else:
print("Clicked outside the map!")
elif event.is_action_pressed(_action_drag):
@@ -248,7 +247,7 @@ func _update_minimap_viewport() -> void:
func _update_mouse_map_position() -> void:
_mouse_pos_map = _viewport_to_map_coords(_mouse_pos_viewport)
- var hover_index := MapSingleton.get_province_index_from_uv_coords(_mouse_pos_map)
+ var hover_index := GameSingleton.get_province_index_from_uv_coords(_mouse_pos_map)
if _mouse_over_viewport:
_map_shader_material.set_shader_parameter(_shader_param_hover_index, hover_index)
diff --git a/game/src/GameSession/ProvinceOverviewPanel.gd b/game/src/GameSession/ProvinceOverviewPanel.gd
index 4615df9..832f21c 100644
--- a/game/src/GameSession/ProvinceOverviewPanel.gd
+++ b/game/src/GameSession/ProvinceOverviewPanel.gd
@@ -2,32 +2,84 @@ extends Panel
@export var _province_name_label : Label
@export var _region_name_label : Label
+@export var _buildings_container : Container
-var _province_identifier: String = "":
- get: return _province_identifier
+const _missing_suffix : String = "_MISSING"
+
+var _selected_index : int:
+ get: return _selected_index
set(v):
- _province_identifier = v
+ _selected_index = v
update_info()
-
-const _name_suffix : String = "_NAME"
+var _province_info : Dictionary
func _ready():
+ GameSingleton.state_updated.connect(update_info)
update_info()
+enum { CANNOT_EXPAND, CAN_EXPAND, PREPARING, EXPANDING }
+
+func _expand_building(building_identifier : String) -> void:
+ if GameSingleton.expand_building(_selected_index, building_identifier) != OK:
+ push_error("Failed to expand ", building_identifier, " in province #", _selected_index);
+
+func _add_building(building : Dictionary) -> void:
+ const _building_key : StringName = &"building"
+ const _level_key : StringName = &"level"
+ const _expansion_state_key : StringName = &"expansion_state"
+ const _start_key : StringName = &"start"
+ const _end_key : StringName = &"end"
+ const _expansion_progress_key : StringName = &"expansion_progress"
+
+ const _expand_province_building : String = "EXPAND_PROVINCE_BUILDING"
+
+ var level_label := Label.new()
+ level_label.text = str(building.get(_level_key, 0))
+ _buildings_container.add_child(level_label)
+
+ var building_label := Label.new()
+ building_label.text = building.get(_building_key, _building_key + _missing_suffix)
+ _buildings_container.add_child(building_label)
+
+ var expansion_state : int = building.get(_expansion_state_key, CANNOT_EXPAND)
+ if expansion_state == PREPARING or expansion_state == EXPANDING:
+ var progress_bar := ProgressBar.new()
+ progress_bar.max_value = 1
+ progress_bar.value = building.get(_expansion_progress_key, 0)
+ progress_bar.size_flags_horizontal = Control.SIZE_EXPAND_FILL
+ _buildings_container.add_child(progress_bar)
+ else:
+ var expand_button := Button.new()
+ expand_button.text = _expand_province_building
+ expand_button.size_flags_horizontal = Control.SIZE_EXPAND_FILL
+ expand_button.disabled = expansion_state != CAN_EXPAND
+ expand_button.pressed.connect(func(): _expand_building(building_label.text))
+ _buildings_container.add_child(expand_button)
+
func update_info() -> void:
- if _province_identifier:
- _province_name_label.text = _province_identifier + _name_suffix
- var region_identifier := MapSingleton.get_region_identifier_from_province_identifier(_province_identifier)
- if region_identifier:
- _region_name_label.text = region_identifier + _name_suffix
- else:
- _region_name_label.text = "NO REGION"
+ const _province_key : StringName = &"province"
+ const _region_key : StringName = &"region"
+ const _life_rating_key : StringName = &"life_rating"
+ const _buildings_key : StringName = &"buildings"
+
+ _province_info = GameSingleton.get_province_info_from_index(_selected_index)
+ if _province_info:
+ _province_name_label.text = _province_info.get(_province_key, _province_key + _missing_suffix)
+ _region_name_label.text = _province_info.get(_region_key, _region_key + _missing_suffix)
+
+ for child in _buildings_container.get_children():
+ _buildings_container.remove_child(child)
+ child.queue_free()
+ var buildings : Array = _province_info.get(_buildings_key, [])
+ for building in buildings:
+ _add_building(building)
+
show()
else:
hide()
-func _on_province_selected(identifier : String) -> void:
- _province_identifier = identifier
+func _on_province_selected(index : int) -> void:
+ _selected_index = index
func _on_close_button_pressed() -> void:
- _province_identifier = ""
+ _selected_index = 0
diff --git a/game/src/GameSession/ProvinceOverviewPanel.tscn b/game/src/GameSession/ProvinceOverviewPanel.tscn
index 7d21edc..dacdc4b 100644
--- a/game/src/GameSession/ProvinceOverviewPanel.tscn
+++ b/game/src/GameSession/ProvinceOverviewPanel.tscn
@@ -2,7 +2,7 @@
[ext_resource type="Script" path="res://src/GameSession/ProvinceOverviewPanel.gd" id="1_3n8k5"]
-[node name="ProvinceOverviewPanel" type="Panel" node_paths=PackedStringArray("_province_name_label", "_region_name_label")]
+[node name="ProvinceOverviewPanel" type="Panel" node_paths=PackedStringArray("_province_name_label", "_region_name_label", "_buildings_container")]
editor_description = "UI-56"
anchors_preset = 2
anchor_top = 1.0
@@ -13,6 +13,7 @@ grow_vertical = 0
script = ExtResource("1_3n8k5")
_province_name_label = NodePath("VBoxContainer/ProvinceName")
_region_name_label = NodePath("VBoxContainer/RegionName")
+_buildings_container = NodePath("VBoxContainer/BuildingsContainer")
[node name="VBoxContainer" type="VBoxContainer" parent="."]
layout_mode = 1
@@ -27,15 +28,22 @@ offset_bottom = -5.0
[node name="ProvinceName" type="Label" parent="VBoxContainer"]
editor_description = "UI-57"
layout_mode = 2
-text = "PROVINCE_NAME"
+text = "province_MISSING"
vertical_alignment = 1
[node name="RegionName" type="Label" parent="VBoxContainer"]
editor_description = "UI-58"
layout_mode = 2
-text = "REGION_NAME"
+text = "region_MISSING"
vertical_alignment = 1
+[node name="HSeparator" type="HSeparator" parent="VBoxContainer"]
+layout_mode = 2
+
+[node name="BuildingsContainer" type="GridContainer" parent="VBoxContainer"]
+layout_mode = 2
+columns = 3
+
[node name="CloseButton" type="Button" parent="."]
custom_minimum_size = Vector2(30, 30)
layout_mode = 1