From cef940108fe15752c3ef66f43f5169403fa2f71d Mon Sep 17 00:00:00 2001 From: Spartan322 Date: Sat, 3 Jun 2023 14:37:10 -0400 Subject: Reorganize the file structure of the files in `game/src` --- game/src/Autoload/Arguments/ArgumentOption.gd | 60 ----- game/src/Autoload/Arguments/ArgumentParser.gd | 267 --------------------- game/src/Autoload/Arguments/ArgumentParser.tscn | 32 --- game/src/Autoload/Events.gd | 45 ---- game/src/Autoload/Events/GameDebug.gd | 21 -- game/src/Autoload/Events/Localisation.gd | 30 --- game/src/Autoload/Events/Options.gd | 30 --- game/src/Autoload/Events/ShaderManager.gd | 48 ---- game/src/Autoload/GuiScale.gd | 62 ----- game/src/Autoload/Resolution.gd | 101 -------- game/src/Autoload/SaveManager.gd | 55 ----- game/src/Autoload/SoundManager.gd | 42 ---- game/src/CreditsMenu/CreditsMenu.gd | 200 --------------- game/src/CreditsMenu/CreditsMenu.tscn | 50 ---- game/src/CreditsMenu/GodotEngineButton.gd | 4 - game/src/CreditsMenu/GodotEngineButton.tscn | 20 -- game/src/CreditsMenu/logo_vertical_color_dark.svg | 1 - .../logo_vertical_color_dark.svg.import | 37 --- game/src/GIT_INFO.gd | 9 + game/src/Game/Autoload/Argument/ArgumentOption.gd | 60 +++++ game/src/Game/Autoload/Argument/ArgumentParser.gd | 267 +++++++++++++++++++++ .../src/Game/Autoload/Argument/ArgumentParser.tscn | 32 +++ game/src/Game/Autoload/Events.gd | 45 ++++ game/src/Game/Autoload/Events/GameDebug.gd | 21 ++ game/src/Game/Autoload/Events/Localisation.gd | 30 +++ game/src/Game/Autoload/Events/Options.gd | 30 +++ game/src/Game/Autoload/Events/ShaderManager.gd | 48 ++++ game/src/Game/Autoload/GuiScale.gd | 62 +++++ game/src/Game/Autoload/Resolution.gd | 101 ++++++++ game/src/Game/Autoload/SaveManager.gd | 55 +++++ game/src/Game/Autoload/SoundManager.gd | 42 ++++ game/src/Game/GameMenu.gd | 47 ++++ game/src/Game/GameMenu.tscn | 53 ++++ game/src/Game/GameSession/GameSession.gd | 16 ++ game/src/Game/GameSession/GameSession.tscn | 95 ++++++++ game/src/Game/GameSession/GameSessionMenu.gd | 80 ++++++ game/src/Game/GameSession/GameSessionMenu.tscn | 91 +++++++ game/src/Game/GameSession/GameSpeedPanel.gd | 37 +++ game/src/Game/GameSession/GameSpeedPanel.tscn | 38 +++ .../GameSession/MapControlPanel/MapControlPanel.gd | 57 +++++ .../MapControlPanel/MapControlPanel.tscn | 107 +++++++++ .../Game/GameSession/MapControlPanel/Minimap.gd | 105 ++++++++ .../GameSession/MapControlPanel/Minimap.gdshader | 18 ++ game/src/Game/GameSession/MapView.gd | 242 +++++++++++++++++++ game/src/Game/GameSession/MapView.tscn | 30 +++ .../GameSession/ProvinceIndexSampler.gdshaderinc | 18 ++ .../ProvinceOverviewPanel/ProvinceOverviewPanel.gd | 122 ++++++++++ .../ProvinceOverviewPanel.tscn | 86 +++++++ game/src/Game/GameSession/TerrainMap.gdshader | 50 ++++ game/src/Game/GameStart.tscn | 52 ++++ game/src/Game/LocaleButton.gd | 80 ++++++ game/src/Game/LocaleButton.tscn | 12 + game/src/Game/Menu/CreditsMenu/CreditsMenu.gd | 200 +++++++++++++++ game/src/Game/Menu/CreditsMenu/CreditsMenu.tscn | 50 ++++ .../src/Game/Menu/CreditsMenu/GodotEngineButton.gd | 4 + .../Game/Menu/CreditsMenu/GodotEngineButton.tscn | 20 ++ .../Menu/CreditsMenu/logo_vertical_color_dark.svg | 1 + .../logo_vertical_color_dark.svg.import | 37 +++ game/src/Game/Menu/LobbyMenu/LobbyMenu.gd | 165 +++++++++++++ game/src/Game/Menu/LobbyMenu/LobbyMenu.tscn | 138 +++++++++++ game/src/Game/Menu/LobbyMenu/LobbyPanelButton.gd | 102 ++++++++ game/src/Game/Menu/LobbyMenu/LobbyPanelButton.tscn | 31 +++ game/src/Game/Menu/MainMenu/MainMenu.gd | 50 ++++ game/src/Game/Menu/MainMenu/MainMenu.tscn | 150 ++++++++++++ game/src/Game/Menu/MainMenu/ReleaseInfoBox.gd | 41 ++++ game/src/Game/Menu/MainMenu/ReleaseInfoBox.tscn | 38 +++ .../Menu/OptionMenu/AutosaveIntervalSelector.gd | 2 + game/src/Game/Menu/OptionMenu/ControlsTab.tscn | 14 ++ game/src/Game/Menu/OptionMenu/GeneralTab.gd | 9 + game/src/Game/Menu/OptionMenu/GeneralTab.tscn | 81 +++++++ game/src/Game/Menu/OptionMenu/GuiScaleSelector.gd | 64 +++++ .../Game/Menu/OptionMenu/MonitorDisplaySelector.gd | 18 ++ game/src/Game/Menu/OptionMenu/OptionsMenu.gd | 68 ++++++ game/src/Game/Menu/OptionMenu/OptionsMenu.tscn | 52 ++++ game/src/Game/Menu/OptionMenu/OtherTab.tscn | 18 ++ .../Game/Menu/OptionMenu/QualityPresetSelector.gd | 4 + .../Game/Menu/OptionMenu/RefreshRateSelector.gd | 5 + .../Game/Menu/OptionMenu/ResolutionRevertDialog.gd | 35 +++ .../src/Game/Menu/OptionMenu/ResolutionSelector.gd | 91 +++++++ .../src/Game/Menu/OptionMenu/ScreenModeSelector.gd | 48 ++++ .../Menu/OptionMenu/SettingNodes/SettingHSlider.gd | 41 ++++ .../OptionMenu/SettingNodes/SettingOptionButton.gd | 77 ++++++ .../OptionMenu/SettingNodes/SettingRevertButton.gd | 27 +++ game/src/Game/Menu/OptionMenu/SoundTab.gd | 4 + game/src/Game/Menu/OptionMenu/SoundTab.tscn | 34 +++ game/src/Game/Menu/OptionMenu/VideoTab.gd | 9 + game/src/Game/Menu/OptionMenu/VideoTab.tscn | 181 ++++++++++++++ game/src/Game/Menu/OptionMenu/VolumeGrid.gd | 70 ++++++ game/src/Game/Menu/OptionMenu/VolumeGrid.tscn | 8 + game/src/Game/Menu/SaveLoadMenu/SaveLoadMenu.gd | 123 ++++++++++ game/src/Game/Menu/SaveLoadMenu/SaveLoadMenu.tscn | 109 +++++++++ game/src/Game/Menu/SaveLoadMenu/SavePanelButton.gd | 41 ++++ .../Game/Menu/SaveLoadMenu/SavePanelButton.tscn | 58 +++++ game/src/Game/Menu/SaveLoadMenu/SaveResource.gd | 59 +++++ game/src/Game/MusicConductor/MusicConductor.gd | 77 ++++++ game/src/Game/MusicConductor/MusicConductor.tscn | 13 + game/src/Game/MusicConductor/MusicPlayer.gd | 73 ++++++ game/src/Game/MusicConductor/MusicPlayer.tscn | 63 +++++ game/src/Game/MusicConductor/SongInfo.gd | 11 + game/src/Game/SplashContainer.gd | 30 +++ game/src/Game/Theme/StyleBoxCombinedTexture.gd | 47 ++++ game/src/Game/Theme/StyleBoxWithSound.gd | 34 +++ game/src/Game/Theme/TextureSetting.gd | 123 ++++++++++ game/src/GameMenu.gd | 47 ---- game/src/GameMenu.tscn | 53 ---- game/src/GameSession/GameSession.gd | 16 -- game/src/GameSession/GameSession.tscn | 95 -------- game/src/GameSession/GameSessionMenu.gd | 80 ------ game/src/GameSession/GameSessionMenu.tscn | 91 ------- game/src/GameSession/GameSpeedPanel.gd | 37 --- game/src/GameSession/GameSpeedPanel.tscn | 38 --- .../GameSession/MapControlPanel/MapControlPanel.gd | 57 ----- .../MapControlPanel/MapControlPanel.tscn | 107 --------- game/src/GameSession/MapControlPanel/Minimap.gd | 105 -------- .../GameSession/MapControlPanel/Minimap.gdshader | 18 -- game/src/GameSession/MapView.gd | 242 ------------------- game/src/GameSession/MapView.tscn | 30 --- .../GameSession/ProvinceIndexSampler.gdshaderinc | 18 -- .../ProvinceOverviewPanel/ProvinceOverviewPanel.gd | 122 ---------- .../ProvinceOverviewPanel.tscn | 86 ------- game/src/GameSession/TerrainMap.gdshader | 50 ---- game/src/GameStart.tscn | 52 ---- game/src/LobbyMenu/LobbyMenu.gd | 165 ------------- game/src/LobbyMenu/LobbyMenu.tscn | 138 ----------- game/src/LobbyMenu/LobbyPanelButton.gd | 102 -------- game/src/LobbyMenu/LobbyPanelButton.tscn | 31 --- game/src/LocaleButton.gd | 80 ------ game/src/LocaleButton.tscn | 12 - game/src/MainMenu/MainMenu.gd | 50 ---- game/src/MainMenu/MainMenu.tscn | 150 ------------ game/src/MainMenu/ReleaseInfoBox.gd | 41 ---- game/src/MainMenu/ReleaseInfoBox.tscn | 38 --- game/src/MusicConductor/MusicConductor.gd | 77 ------ game/src/MusicConductor/MusicConductor.tscn | 13 - game/src/MusicConductor/MusicPlayer.gd | 73 ------ game/src/MusicConductor/MusicPlayer.tscn | 63 ----- game/src/MusicConductor/SongInfo.gd | 11 - game/src/OptionMenu/AutosaveIntervalSelector.gd | 2 - game/src/OptionMenu/ControlsTab.tscn | 14 -- game/src/OptionMenu/GeneralTab.gd | 9 - game/src/OptionMenu/GeneralTab.tscn | 81 ------- game/src/OptionMenu/GuiScaleSelector.gd | 64 ----- game/src/OptionMenu/MonitorDisplaySelector.gd | 18 -- game/src/OptionMenu/OptionsMenu.gd | 68 ------ game/src/OptionMenu/OptionsMenu.tscn | 52 ---- game/src/OptionMenu/OtherTab.tscn | 18 -- game/src/OptionMenu/QualityPresetSelector.gd | 4 - game/src/OptionMenu/RefreshRateSelector.gd | 5 - game/src/OptionMenu/ResolutionRevertDialog.gd | 35 --- game/src/OptionMenu/ResolutionSelector.gd | 91 ------- game/src/OptionMenu/ScreenModeSelector.gd | 48 ---- game/src/OptionMenu/SettingNodes/SettingHSlider.gd | 41 ---- .../OptionMenu/SettingNodes/SettingOptionButton.gd | 77 ------ .../OptionMenu/SettingNodes/SettingRevertButton.gd | 27 --- game/src/OptionMenu/SoundTab.gd | 4 - game/src/OptionMenu/SoundTab.tscn | 34 --- game/src/OptionMenu/VideoTab.gd | 9 - game/src/OptionMenu/VideoTab.tscn | 181 -------------- game/src/OptionMenu/VolumeGrid.gd | 70 ------ game/src/OptionMenu/VolumeGrid.tscn | 8 - game/src/SaveLoadMenu/SaveLoadMenu.gd | 123 ---------- game/src/SaveLoadMenu/SaveLoadMenu.tscn | 109 --------- game/src/SaveLoadMenu/SavePanelButton.gd | 41 ---- game/src/SaveLoadMenu/SavePanelButton.tscn | 58 ----- game/src/SaveLoadMenu/SaveResource.gd | 59 ----- game/src/SplashContainer.gd | 30 --- game/src/Utility/GIT_INFO.gd | 9 - game/src/Utility/StyleBoxCombinedTexture.gd | 47 ---- game/src/Utility/StyleBoxWithSound.gd | 34 --- game/src/Utility/TextureSetting.gd | 123 ---------- 170 files changed, 5086 insertions(+), 5086 deletions(-) delete mode 100644 game/src/Autoload/Arguments/ArgumentOption.gd delete mode 100644 game/src/Autoload/Arguments/ArgumentParser.gd delete mode 100644 game/src/Autoload/Arguments/ArgumentParser.tscn delete mode 100644 game/src/Autoload/Events.gd delete mode 100644 game/src/Autoload/Events/GameDebug.gd delete mode 100644 game/src/Autoload/Events/Localisation.gd delete mode 100644 game/src/Autoload/Events/Options.gd delete mode 100644 game/src/Autoload/Events/ShaderManager.gd delete mode 100644 game/src/Autoload/GuiScale.gd delete mode 100644 game/src/Autoload/Resolution.gd delete mode 100644 game/src/Autoload/SaveManager.gd delete mode 100644 game/src/Autoload/SoundManager.gd delete mode 100644 game/src/CreditsMenu/CreditsMenu.gd delete mode 100644 game/src/CreditsMenu/CreditsMenu.tscn delete mode 100644 game/src/CreditsMenu/GodotEngineButton.gd delete mode 100644 game/src/CreditsMenu/GodotEngineButton.tscn delete mode 100644 game/src/CreditsMenu/logo_vertical_color_dark.svg delete mode 100644 game/src/CreditsMenu/logo_vertical_color_dark.svg.import create mode 100644 game/src/GIT_INFO.gd create mode 100644 game/src/Game/Autoload/Argument/ArgumentOption.gd create mode 100644 game/src/Game/Autoload/Argument/ArgumentParser.gd create mode 100644 game/src/Game/Autoload/Argument/ArgumentParser.tscn create mode 100644 game/src/Game/Autoload/Events.gd create mode 100644 game/src/Game/Autoload/Events/GameDebug.gd create mode 100644 game/src/Game/Autoload/Events/Localisation.gd create mode 100644 game/src/Game/Autoload/Events/Options.gd create mode 100644 game/src/Game/Autoload/Events/ShaderManager.gd create mode 100644 game/src/Game/Autoload/GuiScale.gd create mode 100644 game/src/Game/Autoload/Resolution.gd create mode 100644 game/src/Game/Autoload/SaveManager.gd create mode 100644 game/src/Game/Autoload/SoundManager.gd create mode 100644 game/src/Game/GameMenu.gd create mode 100644 game/src/Game/GameMenu.tscn create mode 100644 game/src/Game/GameSession/GameSession.gd create mode 100644 game/src/Game/GameSession/GameSession.tscn create mode 100644 game/src/Game/GameSession/GameSessionMenu.gd create mode 100644 game/src/Game/GameSession/GameSessionMenu.tscn create mode 100644 game/src/Game/GameSession/GameSpeedPanel.gd create mode 100644 game/src/Game/GameSession/GameSpeedPanel.tscn create mode 100644 game/src/Game/GameSession/MapControlPanel/MapControlPanel.gd create mode 100644 game/src/Game/GameSession/MapControlPanel/MapControlPanel.tscn create mode 100644 game/src/Game/GameSession/MapControlPanel/Minimap.gd create mode 100644 game/src/Game/GameSession/MapControlPanel/Minimap.gdshader create mode 100644 game/src/Game/GameSession/MapView.gd create mode 100644 game/src/Game/GameSession/MapView.tscn create mode 100644 game/src/Game/GameSession/ProvinceIndexSampler.gdshaderinc create mode 100644 game/src/Game/GameSession/ProvinceOverviewPanel/ProvinceOverviewPanel.gd create mode 100644 game/src/Game/GameSession/ProvinceOverviewPanel/ProvinceOverviewPanel.tscn create mode 100644 game/src/Game/GameSession/TerrainMap.gdshader create mode 100644 game/src/Game/GameStart.tscn create mode 100644 game/src/Game/LocaleButton.gd create mode 100644 game/src/Game/LocaleButton.tscn create mode 100644 game/src/Game/Menu/CreditsMenu/CreditsMenu.gd create mode 100644 game/src/Game/Menu/CreditsMenu/CreditsMenu.tscn create mode 100644 game/src/Game/Menu/CreditsMenu/GodotEngineButton.gd create mode 100644 game/src/Game/Menu/CreditsMenu/GodotEngineButton.tscn create mode 100644 game/src/Game/Menu/CreditsMenu/logo_vertical_color_dark.svg create mode 100644 game/src/Game/Menu/CreditsMenu/logo_vertical_color_dark.svg.import create mode 100644 game/src/Game/Menu/LobbyMenu/LobbyMenu.gd create mode 100644 game/src/Game/Menu/LobbyMenu/LobbyMenu.tscn create mode 100644 game/src/Game/Menu/LobbyMenu/LobbyPanelButton.gd create mode 100644 game/src/Game/Menu/LobbyMenu/LobbyPanelButton.tscn create mode 100644 game/src/Game/Menu/MainMenu/MainMenu.gd create mode 100644 game/src/Game/Menu/MainMenu/MainMenu.tscn create mode 100644 game/src/Game/Menu/MainMenu/ReleaseInfoBox.gd create mode 100644 game/src/Game/Menu/MainMenu/ReleaseInfoBox.tscn create mode 100644 game/src/Game/Menu/OptionMenu/AutosaveIntervalSelector.gd create mode 100644 game/src/Game/Menu/OptionMenu/ControlsTab.tscn create mode 100644 game/src/Game/Menu/OptionMenu/GeneralTab.gd create mode 100644 game/src/Game/Menu/OptionMenu/GeneralTab.tscn create mode 100644 game/src/Game/Menu/OptionMenu/GuiScaleSelector.gd create mode 100644 game/src/Game/Menu/OptionMenu/MonitorDisplaySelector.gd create mode 100644 game/src/Game/Menu/OptionMenu/OptionsMenu.gd create mode 100644 game/src/Game/Menu/OptionMenu/OptionsMenu.tscn create mode 100644 game/src/Game/Menu/OptionMenu/OtherTab.tscn create mode 100644 game/src/Game/Menu/OptionMenu/QualityPresetSelector.gd create mode 100644 game/src/Game/Menu/OptionMenu/RefreshRateSelector.gd create mode 100644 game/src/Game/Menu/OptionMenu/ResolutionRevertDialog.gd create mode 100644 game/src/Game/Menu/OptionMenu/ResolutionSelector.gd create mode 100644 game/src/Game/Menu/OptionMenu/ScreenModeSelector.gd create mode 100644 game/src/Game/Menu/OptionMenu/SettingNodes/SettingHSlider.gd create mode 100644 game/src/Game/Menu/OptionMenu/SettingNodes/SettingOptionButton.gd create mode 100644 game/src/Game/Menu/OptionMenu/SettingNodes/SettingRevertButton.gd create mode 100644 game/src/Game/Menu/OptionMenu/SoundTab.gd create mode 100644 game/src/Game/Menu/OptionMenu/SoundTab.tscn create mode 100644 game/src/Game/Menu/OptionMenu/VideoTab.gd create mode 100644 game/src/Game/Menu/OptionMenu/VideoTab.tscn create mode 100644 game/src/Game/Menu/OptionMenu/VolumeGrid.gd create mode 100644 game/src/Game/Menu/OptionMenu/VolumeGrid.tscn create mode 100644 game/src/Game/Menu/SaveLoadMenu/SaveLoadMenu.gd create mode 100644 game/src/Game/Menu/SaveLoadMenu/SaveLoadMenu.tscn create mode 100644 game/src/Game/Menu/SaveLoadMenu/SavePanelButton.gd create mode 100644 game/src/Game/Menu/SaveLoadMenu/SavePanelButton.tscn create mode 100644 game/src/Game/Menu/SaveLoadMenu/SaveResource.gd create mode 100644 game/src/Game/MusicConductor/MusicConductor.gd create mode 100644 game/src/Game/MusicConductor/MusicConductor.tscn create mode 100644 game/src/Game/MusicConductor/MusicPlayer.gd create mode 100644 game/src/Game/MusicConductor/MusicPlayer.tscn create mode 100644 game/src/Game/MusicConductor/SongInfo.gd create mode 100644 game/src/Game/SplashContainer.gd create mode 100644 game/src/Game/Theme/StyleBoxCombinedTexture.gd create mode 100644 game/src/Game/Theme/StyleBoxWithSound.gd create mode 100644 game/src/Game/Theme/TextureSetting.gd delete mode 100644 game/src/GameMenu.gd delete mode 100644 game/src/GameMenu.tscn delete mode 100644 game/src/GameSession/GameSession.gd delete mode 100644 game/src/GameSession/GameSession.tscn delete mode 100644 game/src/GameSession/GameSessionMenu.gd delete mode 100644 game/src/GameSession/GameSessionMenu.tscn delete mode 100644 game/src/GameSession/GameSpeedPanel.gd delete mode 100644 game/src/GameSession/GameSpeedPanel.tscn delete mode 100644 game/src/GameSession/MapControlPanel/MapControlPanel.gd delete mode 100644 game/src/GameSession/MapControlPanel/MapControlPanel.tscn delete mode 100644 game/src/GameSession/MapControlPanel/Minimap.gd delete mode 100644 game/src/GameSession/MapControlPanel/Minimap.gdshader delete mode 100644 game/src/GameSession/MapView.gd delete mode 100644 game/src/GameSession/MapView.tscn delete mode 100644 game/src/GameSession/ProvinceIndexSampler.gdshaderinc delete mode 100644 game/src/GameSession/ProvinceOverviewPanel/ProvinceOverviewPanel.gd delete mode 100644 game/src/GameSession/ProvinceOverviewPanel/ProvinceOverviewPanel.tscn delete mode 100644 game/src/GameSession/TerrainMap.gdshader delete mode 100644 game/src/GameStart.tscn delete mode 100644 game/src/LobbyMenu/LobbyMenu.gd delete mode 100644 game/src/LobbyMenu/LobbyMenu.tscn delete mode 100644 game/src/LobbyMenu/LobbyPanelButton.gd delete mode 100644 game/src/LobbyMenu/LobbyPanelButton.tscn delete mode 100644 game/src/LocaleButton.gd delete mode 100644 game/src/LocaleButton.tscn delete mode 100644 game/src/MainMenu/MainMenu.gd delete mode 100644 game/src/MainMenu/MainMenu.tscn delete mode 100644 game/src/MainMenu/ReleaseInfoBox.gd delete mode 100644 game/src/MainMenu/ReleaseInfoBox.tscn delete mode 100644 game/src/MusicConductor/MusicConductor.gd delete mode 100644 game/src/MusicConductor/MusicConductor.tscn delete mode 100644 game/src/MusicConductor/MusicPlayer.gd delete mode 100644 game/src/MusicConductor/MusicPlayer.tscn delete mode 100644 game/src/MusicConductor/SongInfo.gd delete mode 100644 game/src/OptionMenu/AutosaveIntervalSelector.gd delete mode 100644 game/src/OptionMenu/ControlsTab.tscn delete mode 100644 game/src/OptionMenu/GeneralTab.gd delete mode 100644 game/src/OptionMenu/GeneralTab.tscn delete mode 100644 game/src/OptionMenu/GuiScaleSelector.gd delete mode 100644 game/src/OptionMenu/MonitorDisplaySelector.gd delete mode 100644 game/src/OptionMenu/OptionsMenu.gd delete mode 100644 game/src/OptionMenu/OptionsMenu.tscn delete mode 100644 game/src/OptionMenu/OtherTab.tscn delete mode 100644 game/src/OptionMenu/QualityPresetSelector.gd delete mode 100644 game/src/OptionMenu/RefreshRateSelector.gd delete mode 100644 game/src/OptionMenu/ResolutionRevertDialog.gd delete mode 100644 game/src/OptionMenu/ResolutionSelector.gd delete mode 100644 game/src/OptionMenu/ScreenModeSelector.gd delete mode 100644 game/src/OptionMenu/SettingNodes/SettingHSlider.gd delete mode 100644 game/src/OptionMenu/SettingNodes/SettingOptionButton.gd delete mode 100644 game/src/OptionMenu/SettingNodes/SettingRevertButton.gd delete mode 100644 game/src/OptionMenu/SoundTab.gd delete mode 100644 game/src/OptionMenu/SoundTab.tscn delete mode 100644 game/src/OptionMenu/VideoTab.gd delete mode 100644 game/src/OptionMenu/VideoTab.tscn delete mode 100644 game/src/OptionMenu/VolumeGrid.gd delete mode 100644 game/src/OptionMenu/VolumeGrid.tscn delete mode 100644 game/src/SaveLoadMenu/SaveLoadMenu.gd delete mode 100644 game/src/SaveLoadMenu/SaveLoadMenu.tscn delete mode 100644 game/src/SaveLoadMenu/SavePanelButton.gd delete mode 100644 game/src/SaveLoadMenu/SavePanelButton.tscn delete mode 100644 game/src/SaveLoadMenu/SaveResource.gd delete mode 100644 game/src/SplashContainer.gd delete mode 100644 game/src/Utility/GIT_INFO.gd delete mode 100644 game/src/Utility/StyleBoxCombinedTexture.gd delete mode 100644 game/src/Utility/StyleBoxWithSound.gd delete mode 100644 game/src/Utility/TextureSetting.gd (limited to 'game') diff --git a/game/src/Autoload/Arguments/ArgumentOption.gd b/game/src/Autoload/Arguments/ArgumentOption.gd deleted file mode 100644 index f14cef0..0000000 --- a/game/src/Autoload/Arguments/ArgumentOption.gd +++ /dev/null @@ -1,60 +0,0 @@ -@tool -class_name ArgumentOption -extends Resource - -@export var name : StringName -@export var aliases : Array[StringName] = [] -@export var type : Variant.Type : - get: return type - set(v): - type = v - match v: - TYPE_BOOL: default_value = false - TYPE_INT: default_value = 0 - TYPE_FLOAT: default_value = 0.0 - TYPE_STRING: default_value = "" - TYPE_STRING_NAME: default_value = &"" - TYPE_COLOR: default_value = Color() - _: default_value = null - notify_property_list_changed() -var default_value -@export var description : String - -func _init(_name = "", _type = TYPE_NIL, _description = "", default = null): - name = _name - type = _type - if default != null and typeof(default) == type: - default_value = default - description = _description - -func add_alias(alias : StringName) -> ArgumentOption: - aliases.append(alias) - return self - -func get_type_string() -> StringName: - match type: - TYPE_NIL: return "null" - TYPE_BOOL: return "boolean" - TYPE_INT: return "integer" - TYPE_FLOAT: return "float" - TYPE_STRING, TYPE_STRING_NAME: return "string" - TYPE_COLOR: return "color" - return "" - -func _get(property): - if property == "default_value": return default_value - -func _set(property, value): - if property == "default_value": - default_value = value - return true - -func _get_property_list(): - var properties := [] - - properties.append({ - "name": "default_value", - "type": type - }) - - return properties diff --git a/game/src/Autoload/Arguments/ArgumentParser.gd b/game/src/Autoload/Arguments/ArgumentParser.gd deleted file mode 100644 index ce89dd8..0000000 --- a/game/src/Autoload/Arguments/ArgumentParser.gd +++ /dev/null @@ -1,267 +0,0 @@ -@tool -extends Node - -const argument_setting_path := &"openvic/data/arguments" - -@export var option_array : Array[ArgumentOption] = [ - ArgumentOption.new( - "help", - TYPE_BOOL, - "Displays help and quits.", - false - ).add_alias(&"h") -] - -const color_name_array : PackedStringArray =[ - "aliceblue", "antiquewhite", "aqua", "aquamarine", - "azure", "beige", "bisque", "black", "blanchedalmond", - "blue", "blueviolet", "brown", "burlywood", "cadetblue", - "chartreuse", "chocolate", "coral", "cornflower", "cornsilk", - "crimson", "cyan", "darkblue", "darkcyan", "darkgoldenrod", - "darkgray", "darkgreen", "darkkhaki", "darkmagenta", "darkolivegreen", - "darkorange", "darkorchid", "darkred", "darksalmon", "darkseagreen", - "darkslateblue", "darkslategray", "darkturquoise", "darkviolet", - "deeppink", "deepskyblue", "dimgray", "dodgerblue", "firebrick", - "floralwhite", "forestgreen", "fuchsia", "gainsboro", "ghostwhite", - "gold", "goldenrod", "gray", "green", "greenyellow", "honeydew", - "hotpink", "indianred", "indigo", "ivory", "khaki", "lavender", - "lavenderblush", "lawngreen", "lemonchiffon", "lightblue", "lightcoral", - "lightcyan", "lightgoldenrod", "lightgray", "lightgreen", "lightpink", - "lightsalmon", "lightseagreen", "lightskyblue", "lightslategray", - "lightsteelblue", "lightyellow", "lime", "limegreen", "linen", "magenta", - "maroon", "mediumaquamarine", "mediumblue", "mediumorchid", - "mediumpurple", "mediumseagreen", "mediumslateblue", "mediumspringgreen", - "mediumturquoise", "mediumvioletred", "midnightblue", "mintcream", - "mistyrose", "moccasin", "navajowhite", "navyblue", "oldlace", "olive", - "olivedrab", "orange", "orangered", "orchid", "palegoldenrod", - "palegreen", "paleturquoise", "palevioletred", "papayawhip", - "peachpuff", "peru", "pink", "plum", "powderblue", "purple", - "rebeccapurple", "red", "rosybrown", "royalblue", "saddlebrown", - "salmon", "sandybrown", "seagreen", "seashell", "sienna", "silver", - "skyblue", "slateblue", "slategray", "snow", "springgreen", "steelblue", - "tan", "teal", "thistle", "tomato", "transparent", "turquoise", "violet", - "webgray", "webgreen", "webmaroon", "webpurple", "wheat", "white", - "whitesmoke", "yellow", "yellowgreen" -] - -func _parse_value(arg_name : StringName, value_string : String, type : Variant.Type) -> Variant: - match type: - TYPE_NIL: return null - TYPE_BOOL: - value_string = value_string.to_lower() - if value_string == "true" or value_string == "t" or value_string == "yes" or value_string == "y": - return true - if value_string == "false" or value_string == "f" or value_string == "no" or value_string == "n": - return false - push_error("'%s' must be a valid boolean, '%s' is an invalid value." % [arg_name, value_string]) - return null - TYPE_INT: - if value_string.is_valid_int(): - return value_string.to_int() - push_error("'%s' must be a valid integer, '%s' is an invalid value." % [arg_name, value_string]) - return null - TYPE_FLOAT: - if value_string.is_valid_float(): - return value_string.to_float() - push_error("'%s' must be a valid float, '%s' is an invalid value." % [arg_name, value_string]) - return null - TYPE_STRING, TYPE_STRING_NAME: - return value_string - TYPE_COLOR: - if Color.html_is_valid(value_string) or value_string.to_lower() in color_name_array: - return Color.from_string(value_string, Color()) - push_error("'%s' must be an html Color or Color name, '%s' is an invalid value." % [arg_name, value_string]) - return null - # Unsupported types - TYPE_VECTOR2, \ - TYPE_VECTOR2I, \ - TYPE_VECTOR3, \ - TYPE_VECTOR3I, \ - TYPE_VECTOR4, \ - TYPE_VECTOR4I, \ - TYPE_RECT2, \ - TYPE_RECT2I: - push_warning("Value type '%s' may not be supported." % type) - var data_array = value_string.lstrip("(").rstrip(")").split(",", false) - for index in range(data_array.size()): - data_array[index] = " " + data_array[index].strip_edges() - match type: - TYPE_VECTOR2: - if data_array.size() != 2: - push_error("'%s' value must be a Vector2, '%s' is an invalid value." % [arg_name, value_string]) - return null - return str_to_var("Vector2(%s )" % ",".join(data_array)) - TYPE_VECTOR2I: - if data_array.size() != 2: - push_error("'%s' value must be a Vector2i, '%s' is an invalid value." % [arg_name, value_string]) - return null - return str_to_var("Vector2i(%s )" % ",".join(data_array)) - TYPE_VECTOR3: - if data_array.size() != 2: - push_error("'%s' value must be a Vector3, '%s' is an invalid value." % [arg_name, value_string]) - return null - return str_to_var("Vector3(%s )" % ",".join(data_array)) - TYPE_VECTOR3I: - if data_array.size() != 2: - push_error("'%s' value must be a Vector3i, '%s' is an invalid value." % [arg_name, value_string]) - return null - return str_to_var("Vector3i(%s )" % ",".join(data_array)) - TYPE_VECTOR4: - if data_array.size() != 2: - push_error("'%s' value must be a Vector4, '%s' is an invalid value." % [arg_name, value_string]) - return null - return str_to_var("Vector4(%s )" % ",".join(data_array)) - TYPE_VECTOR4I: - if data_array.size() != 2: - push_error("'%s' value must be a Vector4i, '%s' is an invalid value." % [arg_name, value_string]) - return null - return str_to_var("Vector4i(%s )" % ",".join(data_array)) - TYPE_RECT2: - if data_array.size() != 2: - push_error("'%s' value must be a Rect2, '%s' is an invalid value." % [arg_name, value_string]) - return null - return str_to_var("Rect2(%s )" % ",".join(data_array)) - TYPE_RECT2I: - if data_array.size() != 2: - push_error("'%s' value must be a Rect2i, '%s' is an invalid value." % [arg_name, value_string]) - return null - return str_to_var("Rect2i(%s )" % ",".join(data_array)) - _: - push_error("'%s' value of type '%s' requested but could not be parsed." % [arg_name, type]) - return null - - return null - -# Missing types -# TYPE_TRANSFORM2D = 11 -# TYPE_VECTOR4 = 12 -# TYPE_VECTOR4I = 13 -# TYPE_PLANE = 14 -# TYPE_QUATERNION = 15 -# TYPE_AABB = 16 -# TYPE_BASIS = 17 -# TYPE_TRANSFORM3D = 18 -# TYPE_PROJECTION = 19 -# TYPE_NODE_PATH = 22 -# TYPE_RID = 23 -# TYPE_OBJECT = 24 -# TYPE_CALLABLE = 25 -# TYPE_SIGNAL = 26 -# TYPE_DICTIONARY = 27 -# TYPE_ARRAY = 28 -# TYPE_PACKED_BYTE_ARRAY = 29 -# TYPE_PACKED_INT32_ARRAY = 30 -# TYPE_PACKED_INT64_ARRAY = 31 -# TYPE_PACKED_FLOAT32_ARRAY = 32 -# TYPE_PACKED_FLOAT64_ARRAY = 33 -# TYPE_PACKED_STRING_ARRAY = 34 -# TYPE_PACKED_VECTOR2_ARRAY = 35 -# TYPE_PACKED_VECTOR3_ARRAY = 36 -# TYPE_PACKED_COLOR_ARRAY = 37 - -func _parse_argument_list(dictionary : Dictionary, arg_list : PackedStringArray) -> Dictionary: - var current_key : String = "" - var current_option : ArgumentOption = null - for arg in arg_list: - if current_option != null and not arg.begins_with("-"): - var result = _parse_value(current_key, arg, current_option.type) - if result != null: - dictionary[current_option.name] = result - current_option = null - continue - - if current_option != null: - push_warning("Valid argument '%s' was not set as a value, skipping." % current_key) - - if arg.begins_with("-"): - current_option = null - arg = arg.substr(1) - var key := &"" - var value := &"" - - # Support for Unix shorthand of multiple boolean arguments - # eg: "-abc" means a == true, b == true, c == true - if arg.length() > 1 and arg[0] != "-" and arg[1] != "=": - for c in arg: - for o in option_array: - if o.aliases.any(func(v): return c == v): - dictionary[o.name] = true - continue - - # Support for = key/value split - # eg: "-v=5" and "--value=5" means v == 5 and value == 5 - var first_equal := arg.find("=") - if first_equal > -1: - key = arg.substr(0, first_equal - 1) - value = arg.substr(first_equal + 1) - else: - key = arg - - # Removes - for full name arguments - if key.begins_with("-"): - key = key.substr(1) - - for o in option_array: - if key == o.name or o.aliases.any(func(v): return key == v): - current_option = o - break - - if current_option == null: - push_warning("Invalid argument '%s' found, skipping." % key) - continue - - current_key = key - if first_equal > -1: - var arg_result = _parse_value(key, value, current_option.type) - if arg_result != null: - dictionary[current_option.name] = arg_result - current_option = null - - return dictionary - -func _print_help(): - var project_name : StringName = ProjectSettings.get_setting_with_override(&"application/config/name") - var project_version : String = _GIT_INFO_.tag - var project_hash : String = _GIT_INFO_.short_hash - var project_website : String = "https://openvic.com" - var project_description : String = ProjectSettings.get_setting_with_override(&"application/config/description") - print_rich( -""" -%s - %s - %s - %s -%s - -%s - -Options: -""" - % [ - project_name, - project_version, - project_hash, - project_website, - project_description, - "usage: %s [options]" % OS.get_executable_path().get_file() - ] - ) - for option in option_array: - print_rich(" --%s%s%s" % [ - (option.name + (",-%s" % (",-".join(option.aliases)) if option.aliases.size() > 0 else "")).rpad(45), - ("Type: %s - Default Value: %s" % [option.get_type_string(), option.default_value]).rpad(45), - option.description - ]) -func _ready(): - if Engine.is_editor_hint(): return - - var argument_dictionary : Dictionary = {} - if ProjectSettings.has_setting(argument_setting_path): - argument_dictionary = ProjectSettings.get_setting_with_override(argument_setting_path) - for option in option_array: - argument_dictionary[option.name] = option.default_value - - _parse_argument_list(argument_dictionary, OS.get_cmdline_args()) - _parse_argument_list(argument_dictionary, OS.get_cmdline_user_args()) - - ProjectSettings.set_setting(argument_setting_path, argument_dictionary) - if argument_dictionary[&"help"]: - _print_help() - get_tree().quit() diff --git a/game/src/Autoload/Arguments/ArgumentParser.tscn b/game/src/Autoload/Arguments/ArgumentParser.tscn deleted file mode 100644 index 8fda8f1..0000000 --- a/game/src/Autoload/Arguments/ArgumentParser.tscn +++ /dev/null @@ -1,32 +0,0 @@ -[gd_scene load_steps=6 format=3 uid="uid://dayjmgc34tqo6"] - -[ext_resource type="Script" path="res://src/Autoload/Arguments/ArgumentParser.gd" id="1_pc7xr"] -[ext_resource type="Script" path="res://src/Autoload/Arguments/ArgumentOption.gd" id="2_4hguj"] - -[sub_resource type="Resource" id="Resource_tq3y4"] -script = ExtResource("2_4hguj") -name = &"help" -aliases = Array[StringName]([&"h"]) -type = 1 -description = "Displays help and quits." -default_value = false - -[sub_resource type="Resource" id="Resource_j1to4"] -script = ExtResource("2_4hguj") -name = &"game-debug" -aliases = Array[StringName]([&"d", &"-debug", &"-debug-mode"]) -type = 1 -description = "Start in debug mode." -default_value = false - -[sub_resource type="Resource" id="Resource_tiax1"] -script = ExtResource("2_4hguj") -name = &"compatibility-mode" -aliases = Array[StringName]([&"-compat"]) -type = 4 -description = "Load Victoria 2 assets from this path." -default_value = "" - -[node name="ArgumentParser" type="Node"] -script = ExtResource("1_pc7xr") -option_array = Array[ExtResource("2_4hguj")]([SubResource("Resource_tq3y4"), SubResource("Resource_j1to4"), SubResource("Resource_tiax1")]) diff --git a/game/src/Autoload/Events.gd b/game/src/Autoload/Events.gd deleted file mode 100644 index 4387cc7..0000000 --- a/game/src/Autoload/Events.gd +++ /dev/null @@ -1,45 +0,0 @@ -extends Node - -var GameDebug = preload("Events/GameDebug.gd").new() -var Options = preload("Events/Options.gd").new() -var Localisation = preload("Events/Localisation.gd").new() -var ShaderManager = preload("Events/ShaderManager.gd").new() - -var _define_filepaths_dict : Dictionary = { - GameSingleton.get_province_identifier_file_key(): "res://common/map/provinces.json", - GameSingleton.get_water_province_file_key(): "res://common/map/water.json", - GameSingleton.get_region_file_key(): "res://common/map/regions.json", - GameSingleton.get_terrain_variant_file_key(): "res://common/map/terrain.json", - GameSingleton.get_terrain_texture_dir_key(): "res://art/terrain/", - GameSingleton.get_province_image_file_key(): "res://common/map/provinces.png", - GameSingleton.get_terrain_image_file_key(): "res://common/map/terrain.png", - GameSingleton.get_goods_file_key(): "res://common/goods.json", - GameSingleton.get_good_icons_dir_key(): "res://art/economy/goods" -} - -# REQUIREMENTS -# * FS-333, FS-334, FS-335, FS-341 -func _ready(): - GameSingleton.setup_logger() - - # Set this to your Vic2 install dir or a mod's dir to enable compatibility mode - # (this won't work for mods which rely on vanilla map assets, copy missing assets - # into the mod's dir for a temporary fix) - # Usage: OpenVic --compatibility-mode - - var compatibility_mode_path : String - if ProjectSettings.has_setting(ArgumentParser.argument_setting_path): - var arg_dictionary : Dictionary = ProjectSettings.get_setting(ArgumentParser.argument_setting_path) - compatibility_mode_path = arg_dictionary.get(&"compatibility-mode", compatibility_mode_path) - - var start := Time.get_ticks_usec() - - if compatibility_mode_path: - if GameSingleton.load_defines_compatibility_mode(compatibility_mode_path) != OK: - push_error("Errors loading game defines!") - else: - if GameSingleton.load_defines(_define_filepaths_dict) != OK: - push_error("Errors loading game defines!") - - var end := Time.get_ticks_usec() - print("Loading took ", float(end - start) / 1000000, " seconds") diff --git a/game/src/Autoload/Events/GameDebug.gd b/game/src/Autoload/Events/GameDebug.gd deleted file mode 100644 index df7a23a..0000000 --- a/game/src/Autoload/Events/GameDebug.gd +++ /dev/null @@ -1,21 +0,0 @@ -extends RefCounted - -# REQUIREMENTS: -# * SS-56 -func _init(): - for engine_args in OS.get_cmdline_args(): - match(engine_args): - "--game-debug": - set_debug_mode(true) - - for engine_args in OS.get_cmdline_user_args(): - match(engine_args): - "--game-debug", "-d", "--debug", "--debug-mode": - set_debug_mode(true) - -func set_debug_mode(value : bool) -> void: - ProjectSettings.set_setting("openvic/debug/enabled", value) - print("Set debug mode to: ", value) - -func is_debug_mode() -> bool: - return ProjectSettings.get_setting("openvic/debug/enabled", false) diff --git a/game/src/Autoload/Events/Localisation.gd b/game/src/Autoload/Events/Localisation.gd deleted file mode 100644 index eda7e51..0000000 --- a/game/src/Autoload/Events/Localisation.gd +++ /dev/null @@ -1,30 +0,0 @@ -extends RefCounted - -# REQUIREMENTS -# * SS-59, SS-60, SS-61 -func get_default_locale() -> String: - var locales := TranslationServer.get_loaded_locales() - var default_locale := OS.get_locale() - if default_locale in locales: - return default_locale - var default_language := OS.get_locale_language() - for locale in locales: - if locale.begins_with(default_language): - return default_language - return ProjectSettings.get_setting("internationalization/locale/fallback", "en_GB") - -func load_localisation(dir_path : String) -> void: - if LoadLocalisation.load_localisation_dir(dir_path) == OK: - print("loaded locales: ", TranslationServer.get_loaded_locales()) - else: - push_error("Failed to load localisation directory: ", dir_path) - -# REQUIREMENTS -# * SS-57 -# * FS-17 -func _init(): - var localisation_dir_path : String = ProjectSettings.get_setting("internationalization/locale/localisation_path", "") - if localisation_dir_path.is_empty(): - push_error("Missing localisation_path setting!") - else: - load_localisation(localisation_dir_path) diff --git a/game/src/Autoload/Events/Options.gd b/game/src/Autoload/Events/Options.gd deleted file mode 100644 index fbeccef..0000000 --- a/game/src/Autoload/Events/Options.gd +++ /dev/null @@ -1,30 +0,0 @@ -extends RefCounted - -signal save_settings(save_file: ConfigFile) -signal load_settings(load_file: ConfigFile) -signal reset_settings() - -func load_settings_from_file() -> void: - load_settings.emit(_settings_file) - -# REQUIREMENTS -# * SS-11 -func save_settings_to_file() -> void: - save_settings.emit(_settings_file) - _settings_file.save(_settings_file_path) - -func try_reset_settings() -> void: - reset_settings.emit() - -const settings_file_path_setting : String = "openvic/settings/settings_file_path" -const settings_file_path_default : String = "user://settings.cfg" - -var _settings_file_path : String = ProjectSettings.get_setting(settings_file_path_setting, settings_file_path_default) -var _settings_file := ConfigFile.new() - -# REQUIREMENTS -# * SS-9 -# * UIFUN-7 -func _init(): - if FileAccess.file_exists(_settings_file_path): - _settings_file.load(_settings_file_path) diff --git a/game/src/Autoload/Events/ShaderManager.gd b/game/src/Autoload/Events/ShaderManager.gd deleted file mode 100644 index a503c52..0000000 --- a/game/src/Autoload/Events/ShaderManager.gd +++ /dev/null @@ -1,48 +0,0 @@ -extends RefCounted - -const param_province_shape_tex : StringName = &"province_shape_tex" -const param_province_shape_subdivisions : StringName = &"province_shape_subdivisions" -const param_province_colour_tex : StringName = &"province_colour_tex" -const param_hover_index : StringName = &"hover_index" -const param_selected_index : StringName = &"selected_index" -const param_terrain_tex : StringName = &"terrain_tex" -const param_terrain_tile_factor : StringName = &"terrain_tile_factor" - -func set_up_shader(material : Material, add_cosmetic_textures : bool) -> Error: - # Shader Material - if material == null: - push_error("material is null!") - return FAILED - if not material is ShaderMaterial: - push_error("Invalid map mesh material class: ", material.get_class()) - return FAILED - var shader_material : ShaderMaterial = material - - # Province shape texture - var province_shape_texture := GameSingleton.get_province_shape_texture() - if province_shape_texture == null: - push_error("Failed to get province shape texture!") - return FAILED - shader_material.set_shader_parameter(param_province_shape_tex, province_shape_texture) - var subdivisions := GameSingleton.get_province_shape_image_subdivisions() - if subdivisions.x < 1 or subdivisions.y < 1: - push_error("Invalid province shape image subdivision: ", subdivisions.x, "x", subdivisions.y) - return FAILED - shader_material.set_shader_parameter(param_province_shape_subdivisions, Vector2(subdivisions)) - - if add_cosmetic_textures: - # Province colour texture - var map_province_colour_texture := GameSingleton.get_province_colour_texture() - if map_province_colour_texture == null: - push_error("Failed to get province colour image!") - return FAILED - shader_material.set_shader_parameter(param_province_colour_tex, map_province_colour_texture) - - # Terrain texture - var terrain_texture := GameSingleton.get_terrain_texture() - if terrain_texture == null: - push_error("Failed to get terrain texture!") - return FAILED - shader_material.set_shader_parameter(param_terrain_tex, terrain_texture) - - return OK diff --git a/game/src/Autoload/GuiScale.gd b/game/src/Autoload/GuiScale.gd deleted file mode 100644 index afd73df..0000000 --- a/game/src/Autoload/GuiScale.gd +++ /dev/null @@ -1,62 +0,0 @@ -extends Node - -const error_guiscale : float = -1.0 - -@export -var minimum_guiscale : float = 0.1 - -const _starting_guiscales : Dictionary = { - float(0.5) : &"0.5x", - float(0.75): &"0.75x", - float(1) : &"1x", - float(1.5) : &"1.5x", - float(2) : &"2x", -} - -var _guiscales: Dictionary - -#Similar to Resolution.gd, but we don't bother checking for strings from files -#and we have floats instead of vector2 integers - -func _ready(): - assert(minimum_guiscale > 0, "Minimum gui scale must be positive") - for guiscale_value in _starting_guiscales: - add_guiscale(guiscale_value, _starting_guiscales[guiscale_value]) - assert(not _guiscales.is_empty(), "No valid starting gui scales!") - -func has_guiscale(guiscale_value : float) -> bool: - return guiscale_value in _guiscales - -func add_guiscale(guiscale_value: float, guiscale_name: StringName=&"") -> bool: - if has_guiscale(guiscale_value): return true - var scale_dict := { value = guiscale_value } - if not guiscale_name.is_empty(): - scale_dict.display_name = guiscale_name - else: - scale_dict.display_name = StringName("%sx" % guiscale_value) - if guiscale_value < minimum_guiscale: - push_error("GUI scale %s is smaller than the minimum %s" % [scale_dict.display_name, minimum_guiscale]) - return false - _guiscales[guiscale_value] = scale_dict - return true - -#returns floats -func get_guiscale_value_list() -> Array: - var list := _guiscales.keys() - list.sort_custom(func(a, b): return a > b) - return list - -func get_guiscale_display_name(guiscale_value : float) -> StringName: - return _guiscales.get(guiscale_value, {display_name = &"unknown gui scale"}).display_name - -func get_current_guiscale() -> float: - return get_tree().root.content_scale_factor - -func set_guiscale(guiscale:float) -> void: - print("New GUI scale: %f" % guiscale) - if not has_guiscale(guiscale): - push_warning("Setting GUI Scale to non-standard value %sx" % [guiscale]) - get_tree().root.content_scale_factor = guiscale - -func reset_guiscale() -> void: - set_guiscale(get_current_guiscale()) diff --git a/game/src/Autoload/Resolution.gd b/game/src/Autoload/Resolution.gd deleted file mode 100644 index c973ba9..0000000 --- a/game/src/Autoload/Resolution.gd +++ /dev/null @@ -1,101 +0,0 @@ -extends Node - -signal resolution_added(value : Vector2i, name : StringName, display_name : StringName) -signal resolution_changed(value : Vector2i) -signal window_mode_changed(value : Window.Mode) - -const error_resolution : Vector2i = Vector2i(-1,-1) - -@export -var minimum_resolution : Vector2i = Vector2i(1,1) - -const _starting_resolutions : Dictionary = { - Vector2i(3840,2160): &"4K", - Vector2i(2560,1080): &"UW1080p", - Vector2i(1920,1080): &"1080p", - Vector2i(1366,768) : &"", - Vector2i(1536,864) : &"", - Vector2i(1280,720) : &"720p", - Vector2i(1440,900) : &"", - Vector2i(1600,900) : &"", - Vector2i(1024,600) : &"", - Vector2i(800,600) : &"" -} - -var _resolutions : Dictionary - -const _regex_pattern : String = "(\\d+)\\s*[xX,]\\s*(\\d+)" -var _regex : RegEx - -func _ready(): - assert(minimum_resolution.x > 0 and minimum_resolution.y > 0, "Minimum resolution must be positive!") - for resolution_value in _starting_resolutions: - add_resolution(resolution_value, _starting_resolutions[resolution_value]) - assert(not _resolutions.is_empty(), "No valid starting resolutions!") - - _regex = RegEx.new() - var err := _regex.compile(_regex_pattern) - assert(err == OK, "Resolution RegEx failed to compile!") - - -func has_resolution(resolution_value : Vector2i) -> bool: - return resolution_value in _resolutions - -func add_resolution(resolution_value : Vector2i, resolution_name : StringName = &"") -> bool: - if has_resolution(resolution_value): return true - var res_dict := { value = resolution_value, name = &"" } - var display_name := "%sx%s" % [resolution_value.x, resolution_value.y] - if not resolution_name.is_empty(): - res_dict.name = resolution_name - display_name = "%s (%s)" % [display_name, resolution_name] - res_dict.display_name = StringName(display_name) - if resolution_value.x < minimum_resolution.x or resolution_value.y < minimum_resolution.y: - push_error("Resolution %s is smaller than minimum (%sx%s)" % [res_dict.display_name, minimum_resolution.x, minimum_resolution.y]) - return false - resolution_added.emit(resolution_value, resolution_name, display_name) - _resolutions[resolution_value] = res_dict - return true - -func get_resolution_value_list() -> Array: - var list := _resolutions.keys() - list.sort_custom(func(a, b): return a > b) - return list - -func get_resolution_name(resolution_value : Vector2i) -> StringName: - return _resolutions.get(resolution_value, { name = &"unknown resolution" }).name - -func get_resolution_display_name(resolution_value : Vector2i) -> StringName: - return _resolutions.get(resolution_value, { display_name = &"unknown resolution" }).display_name - -func get_resolution_value_from_string(resolution_string : String) -> Vector2i: - if not resolution_string.is_empty(): - for resolution in _resolutions.values(): - if resolution_string == resolution.name or resolution_string == resolution.display_name: - return resolution.value - var result := _regex.search(resolution_string) - if result: return Vector2i(result.get_string(1).to_int(), result.get_string(2).to_int()) - return error_resolution - -func get_current_resolution() -> Vector2i: - var window := get_viewport().get_window() - match window.mode: - Window.MODE_EXCLUSIVE_FULLSCREEN, Window.MODE_FULLSCREEN: - return window.content_scale_size - _: - return window.size - -func set_resolution(resolution : Vector2i) -> void: - if not has_resolution(resolution): - push_warning("Setting resolution to non-standard value %sx%s" % [resolution.x, resolution.y]) - var window := get_viewport().get_window() - if get_current_resolution() != resolution: - resolution_changed.emit(resolution) - match window.mode: - Window.MODE_EXCLUSIVE_FULLSCREEN, Window.MODE_FULLSCREEN: - window.content_scale_size = resolution - _: - window.size = resolution - window.content_scale_size = Vector2i(0,0) - -func reset_resolution() -> void: - set_resolution(get_current_resolution()) diff --git a/game/src/Autoload/SaveManager.gd b/game/src/Autoload/SaveManager.gd deleted file mode 100644 index fb7806b..0000000 --- a/game/src/Autoload/SaveManager.gd +++ /dev/null @@ -1,55 +0,0 @@ -extends Node - -# Requirements -# * FS-28 -const save_directory_setting := &"openvic/data/saves_directory" - -var current_save : SaveResource -var current_session_tag : StringName - -var _save_dictionary : Dictionary = {} -var _dirty_save : SaveResource - -func _ready(): - var saves_dir_path : String = ProjectSettings.get_setting_with_override(save_directory_setting) - assert(saves_dir_path != null, "'%s' setting could not be found." % save_directory_setting) - - DirAccess.make_dir_recursive_absolute(saves_dir_path) - var saves_dir := DirAccess.open(saves_dir_path) - for file in saves_dir.get_files(): - var save := SaveResource.new() - save.load_save(saves_dir_path.path_join(file)) - add_or_replace_save(save, true) - -func get_save_file_name(save_name : StringName, session_tag : StringName = current_session_tag) -> StringName: - return ("%s - %s" % [save_name, session_tag]).validate_filename() - -func make_new_save(save_name : String, session_tag : StringName = current_session_tag) -> SaveResource: - var file_name := get_save_file_name(save_name, session_tag) + ".tres" - var new_save := SaveResource.new() - new_save.set_file_path(save_name, ProjectSettings.get_setting_with_override(save_directory_setting).path_join(file_name)) - print(new_save.file_path) - new_save.session_tag = session_tag - return new_save - -func has_save(save_name : StringName, session_tag : StringName = current_session_tag) -> bool: - return _save_dictionary.has(get_save_file_name(save_name, session_tag)) - -func add_or_replace_save(save : SaveResource, ignore_dirty : bool = false) -> void: - var binded_func := _on_save_deleted_or_moved.bind(save) - save.deleted.connect(binded_func) - save.trash_moved.connect(binded_func) - _save_dictionary[get_save_file_name(save.save_name, save.session_tag)] = save - if not ignore_dirty: - _dirty_save = save - -func delete_save(save : SaveResource) -> void: - save.delete() - -func flush_save() -> void: - if _dirty_save == null: return - _dirty_save.flush_save() - _dirty_save = null - -func _on_save_deleted_or_moved(save : SaveResource) -> void: - _save_dictionary.erase(get_save_file_name(save.save_name, save.session_tag)) diff --git a/game/src/Autoload/SoundManager.gd b/game/src/Autoload/SoundManager.gd deleted file mode 100644 index c58ce1a..0000000 --- a/game/src/Autoload/SoundManager.gd +++ /dev/null @@ -1,42 +0,0 @@ -extends Node - -# REQUIREMENTS: -# * SS-68 - -const _audio_directory_path : StringName = &"res://audio/sfx/" - -var _loaded_sound : Dictionary = {} - -var _bus_to_stream_player : Dictionary = {} - -# REQUIREMENTS: -# * SND-10 -func _ready(): - var dir = DirAccess.open(_audio_directory_path) - for fname in dir.get_files(): - match fname.get_extension(): - "ogg", "wav", "mp3": - _loaded_sound[fname.get_basename()] = load(_audio_directory_path.path_join(fname)) # SND-10 - -func play_stream(sound : AudioStream, bus_type : String) -> void: - var player : AudioStreamPlayer = _bus_to_stream_player.get(bus_type) - if player == null: - player = AudioStreamPlayer.new() - player.bus = bus_type - player.stream = AudioStreamPolyphonic.new() - _bus_to_stream_player[bus_type] = player - add_child(player) - player.play() - var poly_playback : AudioStreamPlaybackPolyphonic = player.get_stream_playback() - poly_playback.play_stream(sound) - -func play(sound : String, bus_type : String) -> void: - play_stream(_loaded_sound[sound], bus_type) - -# REQUIREMENTS: -# * SND-7 -func play_effect_stream(sound : AudioStream) -> void: - play_stream(sound, "SFX") - -func play_effect(sound : String) -> void: - play(sound, "SFX") diff --git a/game/src/CreditsMenu/CreditsMenu.gd b/game/src/CreditsMenu/CreditsMenu.gd deleted file mode 100644 index 0db4d7d..0000000 --- a/game/src/CreditsMenu/CreditsMenu.gd +++ /dev/null @@ -1,200 +0,0 @@ -extends Control - -signal back_button_pressed - -############### -# Credits CSV format -# The project title row is the only requirement within the csv file, however -# it can be on any row, so long as it exists. -# ---------------------- -# title,project-title -# role-name,person-name -# role-name,person-name -# role-name,person-name -# ... -############### - -@export_file("*.csv") -var core_credits_path : String - -@export -var godot_engine_scene : PackedScene - -@export_group("Label Variants", "label_variants_") -@export -var label_variants_project : StringName - -@export -var label_variants_role : StringName - -@export -var label_variants_person : StringName - -@export -var credits_list: VBoxContainer - -const title_key : String = "TITLE" - -# REQUIREMENTS: -# * 1.5 Credits Menu -# * SS-17 - -# REQUIREMENTS -# * FS-4 -func _load_credit_file(path : String) -> Dictionary: - var roles := {} - var core_credits = FileAccess.open(path, FileAccess.READ) - if core_credits == null: - push_error("Failed to open credits file %s (error code %d)" % [path, FileAccess.get_open_error()]) - return roles - - while not core_credits.eof_reached(): - var line := core_credits.get_csv_line() - var role := line[0].strip_edges().to_upper() - - # If the line does not have an identifiable role or is empty then skip it - if role.is_empty() or line.size() < 2: - if not (role.is_empty() and line.size() < 2): - push_warning("Incorrectly formatted credit line %s in %s" % [line, path]) - continue - - var person := line[1].strip_edges() - - if person.is_empty(): - push_warning("Incorrectly formatted credit line %s in %s" % [line, path]) - continue - if line.size() > 2: - push_warning("Extra entries ignored in credit line %s in %s" % [line, path]) - - if role not in roles: - roles[role] = [person] - else: - if person in roles[role]: - push_warning("Duplicate person %s for role %s in %s" % [person, role, path]) - else: - roles[role].push_back(person) - if title_key in roles: - if roles[title_key].size() > 1: - push_warning("More than one %s: %s in %s" % [title_key, roles[title_key], path]) - roles[title_key] = [roles[title_key][0]] - else: - push_warning("Credits file %s missing %s" % [path, title_key]) - for role_list in roles.values(): - role_list.sort_custom(func(a : String, b : String) -> bool: return a.naturalnocasecmp_to(b) < 0) - return roles - -func _add_label(node : Node, text : String, type_variation : StringName) -> void: - var label := Label.new() - label.name = 'Label' + text - label.text = text - label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER - label.theme_type_variation = type_variation - node.add_child(label) - -# REQUIREMENTS: -# * UI-34, UI-35 -func _add_project_credits(project : Dictionary) -> void: - var project_credits_list = VBoxContainer.new() - project_credits_list.name = 'Credits' - if title_key in project: - var title : String = project[title_key][0] - project_credits_list.name += title - _add_label(project_credits_list, title, label_variants_project) - project_credits_list.add_child(HSeparator.new()) - - for role in project: - if role == title_key: - continue - - var role_parent = VBoxContainer.new() - - for person in project[role]: - _add_label(role_parent, person, label_variants_person) - - _add_label(project_credits_list, role, label_variants_role) - project_credits_list.add_child(role_parent) - project_credits_list.add_child(HSeparator.new()) - - credits_list.add_child(project_credits_list) - -func _add_godot_credits() -> void: - var godot_credits_list = VBoxContainer.new() - godot_credits_list.name = 'CreditsGodot' - var godot_engine = godot_engine_scene.instantiate() - godot_credits_list.add_child(godot_engine) - godot_credits_list.add_child(HSeparator.new()) - - var author_dict := Engine.get_author_info() - _add_label(godot_credits_list, "Contributors", label_variants_role) - - for role in author_dict: - var role_parent = VBoxContainer.new() - - for person in author_dict[role]: - _add_label(role_parent, person, label_variants_person) - - _add_label(godot_credits_list, role.replace("_", " ").capitalize(), label_variants_role) - godot_credits_list.add_child(role_parent) - godot_credits_list.add_child(HSeparator.new()) - - var donor_dict := Engine.get_donor_info() - _add_label(godot_credits_list, "Donors", label_variants_role) - - for role in donor_dict: - if donor_dict[role].size() == 0 or donor_dict[role][0].begins_with("None"): continue - var role_parent = VBoxContainer.new() - - for person in donor_dict[role]: - _add_label(role_parent, person, label_variants_person) - - _add_label(godot_credits_list, role.replace("_", " ").capitalize(), label_variants_role) - godot_credits_list.add_child(role_parent) - godot_credits_list.add_child(HSeparator.new()) - - credits_list.add_child(godot_credits_list) - -func _add_link_button(node : Node, text : String, url: String, type_variation : StringName) -> void: - var button := LinkButton.new() - button.name = 'LinkButton' + text - button.text = text - button.uri = url - button.size_flags_horizontal = SIZE_SHRINK_CENTER - button.theme_type_variation = type_variation - node.add_child(button) - -func _add_licenses() -> void: - var license_list = VBoxContainer.new() - license_list.name = 'Licenses' - _add_label(license_list, "Third-Party Licenses", label_variants_project) - license_list.add_child(HSeparator.new()) - - var license_info := { - "OpenVic": ["GPLv3", "https://github.com/OpenVicProject/OpenVic/blob/main/LICENSE.md"], - "Godot": ["MIT", "https://github.com/godotengine/godot/blob/master/LICENSE.txt"], - "FreeType": ["FreeType License", "https://gitlab.freedesktop.org/freetype/freetype/-/blob/master/docs/FTL.TXT"], - "ENet": ["MIT", "http://enet.bespin.org/License.html"], - "mbed TLS": ["APLv2", "https://github.com/Mbed-TLS/mbedtls/blob/development/LICENSE"] - } - # Add additional licenses required for attribution here - # These licenses should also either be displayed or exported alongside this project - - for project in license_info: - _add_label(license_list, project, label_variants_role) - _add_link_button(license_list, license_info[project][0], license_info[project][1], label_variants_person) - license_list.add_child(HSeparator.new()) - - credits_list.add_child(license_list) - - -# REQUIREMENTS: -# * SS-17 -func _ready(): - _add_project_credits(_load_credit_file(core_credits_path)) - _add_godot_credits() - _add_licenses() - -# REQUIREMENTS: -# * UI-38 -# * UIFUN-37 -func _on_back_button_pressed() -> void: - back_button_pressed.emit() diff --git a/game/src/CreditsMenu/CreditsMenu.tscn b/game/src/CreditsMenu/CreditsMenu.tscn deleted file mode 100644 index 2d10d2e..0000000 --- a/game/src/CreditsMenu/CreditsMenu.tscn +++ /dev/null @@ -1,50 +0,0 @@ -[gd_scene load_steps=4 format=3 uid="uid://c8knthxkwj1uj"] - -[ext_resource type="Theme" uid="uid://stfxt4hpsify" path="res://theme/credits_menu.tres" id="1_7y4l8"] -[ext_resource type="Script" path="res://src/CreditsMenu/CreditsMenu.gd" id="1_csd7i"] -[ext_resource type="PackedScene" uid="uid://ddjbee5gj6bkv" path="res://src/CreditsMenu/GodotEngineButton.tscn" id="3_fl02a"] - -[node name="CreditsMenu" type="Control" node_paths=PackedStringArray("credits_list")] -editor_description = "UI-34" -layout_mode = 3 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 -theme = ExtResource("1_7y4l8") -script = ExtResource("1_csd7i") -core_credits_path = "res://common/credits.csv" -godot_engine_scene = ExtResource("3_fl02a") -label_variants_project = &"ProjectLabel" -label_variants_role = &"RoleLabel" -label_variants_person = &"PersonLabel" -credits_list = NodePath("Scroll/CreditsList") - -[node name="ControlMargin" type="MarginContainer" parent="."] -layout_mode = 2 -anchor_right = 1.0 -anchor_bottom = 0.071 -offset_bottom = -0.120003 -theme_type_variation = &"BackButtonsMargin" - -[node name="BackButton" type="Button" parent="ControlMargin"] -editor_description = "UI-38" -layout_mode = 2 -text = "CREDITS_BACK" - -[node name="Scroll" type="ScrollContainer" parent="."] -editor_description = "UI-35" -layout_mode = 2 -anchor_top = 0.071 -anchor_right = 1.0 -anchor_bottom = 1.0 -offset_top = -0.120003 -offset_bottom = -6.0 - -[node name="CreditsList" type="VBoxContainer" parent="Scroll"] -layout_mode = 2 -size_flags_horizontal = 3 -size_flags_vertical = 3 - -[connection signal="pressed" from="ControlMargin/BackButton" to="." method="_on_back_button_pressed"] diff --git a/game/src/CreditsMenu/GodotEngineButton.gd b/game/src/CreditsMenu/GodotEngineButton.gd deleted file mode 100644 index ca3a958..0000000 --- a/game/src/CreditsMenu/GodotEngineButton.gd +++ /dev/null @@ -1,4 +0,0 @@ -extends Button - -func _on_pressed(): - OS.shell_open("https://godotengine.org") diff --git a/game/src/CreditsMenu/GodotEngineButton.tscn b/game/src/CreditsMenu/GodotEngineButton.tscn deleted file mode 100644 index 8b0c46b..0000000 --- a/game/src/CreditsMenu/GodotEngineButton.tscn +++ /dev/null @@ -1,20 +0,0 @@ -[gd_scene load_steps=3 format=3 uid="uid://ddjbee5gj6bkv"] - -[ext_resource type="Texture2D" uid="uid://rh7l4xuh4ali" path="res://src/CreditsMenu/logo_vertical_color_dark.svg" id="1_b0brk"] -[ext_resource type="Script" path="res://src/CreditsMenu/GodotEngineButton.gd" id="3_gi8fv"] - -[node name="GodotEngineButton" type="Button"] -custom_minimum_size = Vector2(0, 200) -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 -size_flags_vertical = 3 -icon = ExtResource("1_b0brk") -flat = true -icon_alignment = 1 -expand_icon = true -script = ExtResource("3_gi8fv") - -[connection signal="pressed" from="." to="." method="_on_pressed"] diff --git a/game/src/CreditsMenu/logo_vertical_color_dark.svg b/game/src/CreditsMenu/logo_vertical_color_dark.svg deleted file mode 100644 index 00e50cd..0000000 --- a/game/src/CreditsMenu/logo_vertical_color_dark.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/game/src/CreditsMenu/logo_vertical_color_dark.svg.import b/game/src/CreditsMenu/logo_vertical_color_dark.svg.import deleted file mode 100644 index a4fb09a..0000000 --- a/game/src/CreditsMenu/logo_vertical_color_dark.svg.import +++ /dev/null @@ -1,37 +0,0 @@ -[remap] - -importer="texture" -type="CompressedTexture2D" -uid="uid://rh7l4xuh4ali" -path="res://.godot/imported/logo_vertical_color_dark.svg-1167b3ce62f0747c0e76b17bdbb9f218.ctex" -metadata={ -"vram_texture": false -} - -[deps] - -source_file="res://src/CreditsMenu/logo_vertical_color_dark.svg" -dest_files=["res://.godot/imported/logo_vertical_color_dark.svg-1167b3ce62f0747c0e76b17bdbb9f218.ctex"] - -[params] - -compress/mode=0 -compress/high_quality=false -compress/lossy_quality=0.7 -compress/hdr_compression=1 -compress/normal_map=0 -compress/channel_pack=0 -mipmaps/generate=false -mipmaps/limit=-1 -roughness/mode=0 -roughness/src_normal="" -process/fix_alpha_border=true -process/premult_alpha=false -process/normal_map_invert_y=false -process/hdr_as_srgb=false -process/hdr_clamp_exposure=false -process/size_limit=0 -detect_3d/compress_to=0 -svg/scale=1.0 -editor/scale_with_editor_scale=false -editor/convert_colors_with_editor_theme=false diff --git a/game/src/GIT_INFO.gd b/game/src/GIT_INFO.gd new file mode 100644 index 0000000..eddb7a1 --- /dev/null +++ b/game/src/GIT_INFO.gd @@ -0,0 +1,9 @@ +### IMPORTANT: IF LOCATION IS CHANGED, PLEASE UPDATE IN addon/openvic-plugin/ReleaseExportEditorPlugin +class_name _GIT_INFO_ +extends RefCounted + + +const commit_hash : StringName = &"0000000000000000000000000000000000000000" +const short_hash : StringName = &"0000000" +const tag : StringName = &"" +const release_name : StringName = &"" diff --git a/game/src/Game/Autoload/Argument/ArgumentOption.gd b/game/src/Game/Autoload/Argument/ArgumentOption.gd new file mode 100644 index 0000000..f14cef0 --- /dev/null +++ b/game/src/Game/Autoload/Argument/ArgumentOption.gd @@ -0,0 +1,60 @@ +@tool +class_name ArgumentOption +extends Resource + +@export var name : StringName +@export var aliases : Array[StringName] = [] +@export var type : Variant.Type : + get: return type + set(v): + type = v + match v: + TYPE_BOOL: default_value = false + TYPE_INT: default_value = 0 + TYPE_FLOAT: default_value = 0.0 + TYPE_STRING: default_value = "" + TYPE_STRING_NAME: default_value = &"" + TYPE_COLOR: default_value = Color() + _: default_value = null + notify_property_list_changed() +var default_value +@export var description : String + +func _init(_name = "", _type = TYPE_NIL, _description = "", default = null): + name = _name + type = _type + if default != null and typeof(default) == type: + default_value = default + description = _description + +func add_alias(alias : StringName) -> ArgumentOption: + aliases.append(alias) + return self + +func get_type_string() -> StringName: + match type: + TYPE_NIL: return "null" + TYPE_BOOL: return "boolean" + TYPE_INT: return "integer" + TYPE_FLOAT: return "float" + TYPE_STRING, TYPE_STRING_NAME: return "string" + TYPE_COLOR: return "color" + return "" + +func _get(property): + if property == "default_value": return default_value + +func _set(property, value): + if property == "default_value": + default_value = value + return true + +func _get_property_list(): + var properties := [] + + properties.append({ + "name": "default_value", + "type": type + }) + + return properties diff --git a/game/src/Game/Autoload/Argument/ArgumentParser.gd b/game/src/Game/Autoload/Argument/ArgumentParser.gd new file mode 100644 index 0000000..ce89dd8 --- /dev/null +++ b/game/src/Game/Autoload/Argument/ArgumentParser.gd @@ -0,0 +1,267 @@ +@tool +extends Node + +const argument_setting_path := &"openvic/data/arguments" + +@export var option_array : Array[ArgumentOption] = [ + ArgumentOption.new( + "help", + TYPE_BOOL, + "Displays help and quits.", + false + ).add_alias(&"h") +] + +const color_name_array : PackedStringArray =[ + "aliceblue", "antiquewhite", "aqua", "aquamarine", + "azure", "beige", "bisque", "black", "blanchedalmond", + "blue", "blueviolet", "brown", "burlywood", "cadetblue", + "chartreuse", "chocolate", "coral", "cornflower", "cornsilk", + "crimson", "cyan", "darkblue", "darkcyan", "darkgoldenrod", + "darkgray", "darkgreen", "darkkhaki", "darkmagenta", "darkolivegreen", + "darkorange", "darkorchid", "darkred", "darksalmon", "darkseagreen", + "darkslateblue", "darkslategray", "darkturquoise", "darkviolet", + "deeppink", "deepskyblue", "dimgray", "dodgerblue", "firebrick", + "floralwhite", "forestgreen", "fuchsia", "gainsboro", "ghostwhite", + "gold", "goldenrod", "gray", "green", "greenyellow", "honeydew", + "hotpink", "indianred", "indigo", "ivory", "khaki", "lavender", + "lavenderblush", "lawngreen", "lemonchiffon", "lightblue", "lightcoral", + "lightcyan", "lightgoldenrod", "lightgray", "lightgreen", "lightpink", + "lightsalmon", "lightseagreen", "lightskyblue", "lightslategray", + "lightsteelblue", "lightyellow", "lime", "limegreen", "linen", "magenta", + "maroon", "mediumaquamarine", "mediumblue", "mediumorchid", + "mediumpurple", "mediumseagreen", "mediumslateblue", "mediumspringgreen", + "mediumturquoise", "mediumvioletred", "midnightblue", "mintcream", + "mistyrose", "moccasin", "navajowhite", "navyblue", "oldlace", "olive", + "olivedrab", "orange", "orangered", "orchid", "palegoldenrod", + "palegreen", "paleturquoise", "palevioletred", "papayawhip", + "peachpuff", "peru", "pink", "plum", "powderblue", "purple", + "rebeccapurple", "red", "rosybrown", "royalblue", "saddlebrown", + "salmon", "sandybrown", "seagreen", "seashell", "sienna", "silver", + "skyblue", "slateblue", "slategray", "snow", "springgreen", "steelblue", + "tan", "teal", "thistle", "tomato", "transparent", "turquoise", "violet", + "webgray", "webgreen", "webmaroon", "webpurple", "wheat", "white", + "whitesmoke", "yellow", "yellowgreen" +] + +func _parse_value(arg_name : StringName, value_string : String, type : Variant.Type) -> Variant: + match type: + TYPE_NIL: return null + TYPE_BOOL: + value_string = value_string.to_lower() + if value_string == "true" or value_string == "t" or value_string == "yes" or value_string == "y": + return true + if value_string == "false" or value_string == "f" or value_string == "no" or value_string == "n": + return false + push_error("'%s' must be a valid boolean, '%s' is an invalid value." % [arg_name, value_string]) + return null + TYPE_INT: + if value_string.is_valid_int(): + return value_string.to_int() + push_error("'%s' must be a valid integer, '%s' is an invalid value." % [arg_name, value_string]) + return null + TYPE_FLOAT: + if value_string.is_valid_float(): + return value_string.to_float() + push_error("'%s' must be a valid float, '%s' is an invalid value." % [arg_name, value_string]) + return null + TYPE_STRING, TYPE_STRING_NAME: + return value_string + TYPE_COLOR: + if Color.html_is_valid(value_string) or value_string.to_lower() in color_name_array: + return Color.from_string(value_string, Color()) + push_error("'%s' must be an html Color or Color name, '%s' is an invalid value." % [arg_name, value_string]) + return null + # Unsupported types + TYPE_VECTOR2, \ + TYPE_VECTOR2I, \ + TYPE_VECTOR3, \ + TYPE_VECTOR3I, \ + TYPE_VECTOR4, \ + TYPE_VECTOR4I, \ + TYPE_RECT2, \ + TYPE_RECT2I: + push_warning("Value type '%s' may not be supported." % type) + var data_array = value_string.lstrip("(").rstrip(")").split(",", false) + for index in range(data_array.size()): + data_array[index] = " " + data_array[index].strip_edges() + match type: + TYPE_VECTOR2: + if data_array.size() != 2: + push_error("'%s' value must be a Vector2, '%s' is an invalid value." % [arg_name, value_string]) + return null + return str_to_var("Vector2(%s )" % ",".join(data_array)) + TYPE_VECTOR2I: + if data_array.size() != 2: + push_error("'%s' value must be a Vector2i, '%s' is an invalid value." % [arg_name, value_string]) + return null + return str_to_var("Vector2i(%s )" % ",".join(data_array)) + TYPE_VECTOR3: + if data_array.size() != 2: + push_error("'%s' value must be a Vector3, '%s' is an invalid value." % [arg_name, value_string]) + return null + return str_to_var("Vector3(%s )" % ",".join(data_array)) + TYPE_VECTOR3I: + if data_array.size() != 2: + push_error("'%s' value must be a Vector3i, '%s' is an invalid value." % [arg_name, value_string]) + return null + return str_to_var("Vector3i(%s )" % ",".join(data_array)) + TYPE_VECTOR4: + if data_array.size() != 2: + push_error("'%s' value must be a Vector4, '%s' is an invalid value." % [arg_name, value_string]) + return null + return str_to_var("Vector4(%s )" % ",".join(data_array)) + TYPE_VECTOR4I: + if data_array.size() != 2: + push_error("'%s' value must be a Vector4i, '%s' is an invalid value." % [arg_name, value_string]) + return null + return str_to_var("Vector4i(%s )" % ",".join(data_array)) + TYPE_RECT2: + if data_array.size() != 2: + push_error("'%s' value must be a Rect2, '%s' is an invalid value." % [arg_name, value_string]) + return null + return str_to_var("Rect2(%s )" % ",".join(data_array)) + TYPE_RECT2I: + if data_array.size() != 2: + push_error("'%s' value must be a Rect2i, '%s' is an invalid value." % [arg_name, value_string]) + return null + return str_to_var("Rect2i(%s )" % ",".join(data_array)) + _: + push_error("'%s' value of type '%s' requested but could not be parsed." % [arg_name, type]) + return null + + return null + +# Missing types +# TYPE_TRANSFORM2D = 11 +# TYPE_VECTOR4 = 12 +# TYPE_VECTOR4I = 13 +# TYPE_PLANE = 14 +# TYPE_QUATERNION = 15 +# TYPE_AABB = 16 +# TYPE_BASIS = 17 +# TYPE_TRANSFORM3D = 18 +# TYPE_PROJECTION = 19 +# TYPE_NODE_PATH = 22 +# TYPE_RID = 23 +# TYPE_OBJECT = 24 +# TYPE_CALLABLE = 25 +# TYPE_SIGNAL = 26 +# TYPE_DICTIONARY = 27 +# TYPE_ARRAY = 28 +# TYPE_PACKED_BYTE_ARRAY = 29 +# TYPE_PACKED_INT32_ARRAY = 30 +# TYPE_PACKED_INT64_ARRAY = 31 +# TYPE_PACKED_FLOAT32_ARRAY = 32 +# TYPE_PACKED_FLOAT64_ARRAY = 33 +# TYPE_PACKED_STRING_ARRAY = 34 +# TYPE_PACKED_VECTOR2_ARRAY = 35 +# TYPE_PACKED_VECTOR3_ARRAY = 36 +# TYPE_PACKED_COLOR_ARRAY = 37 + +func _parse_argument_list(dictionary : Dictionary, arg_list : PackedStringArray) -> Dictionary: + var current_key : String = "" + var current_option : ArgumentOption = null + for arg in arg_list: + if current_option != null and not arg.begins_with("-"): + var result = _parse_value(current_key, arg, current_option.type) + if result != null: + dictionary[current_option.name] = result + current_option = null + continue + + if current_option != null: + push_warning("Valid argument '%s' was not set as a value, skipping." % current_key) + + if arg.begins_with("-"): + current_option = null + arg = arg.substr(1) + var key := &"" + var value := &"" + + # Support for Unix shorthand of multiple boolean arguments + # eg: "-abc" means a == true, b == true, c == true + if arg.length() > 1 and arg[0] != "-" and arg[1] != "=": + for c in arg: + for o in option_array: + if o.aliases.any(func(v): return c == v): + dictionary[o.name] = true + continue + + # Support for = key/value split + # eg: "-v=5" and "--value=5" means v == 5 and value == 5 + var first_equal := arg.find("=") + if first_equal > -1: + key = arg.substr(0, first_equal - 1) + value = arg.substr(first_equal + 1) + else: + key = arg + + # Removes - for full name arguments + if key.begins_with("-"): + key = key.substr(1) + + for o in option_array: + if key == o.name or o.aliases.any(func(v): return key == v): + current_option = o + break + + if current_option == null: + push_warning("Invalid argument '%s' found, skipping." % key) + continue + + current_key = key + if first_equal > -1: + var arg_result = _parse_value(key, value, current_option.type) + if arg_result != null: + dictionary[current_option.name] = arg_result + current_option = null + + return dictionary + +func _print_help(): + var project_name : StringName = ProjectSettings.get_setting_with_override(&"application/config/name") + var project_version : String = _GIT_INFO_.tag + var project_hash : String = _GIT_INFO_.short_hash + var project_website : String = "https://openvic.com" + var project_description : String = ProjectSettings.get_setting_with_override(&"application/config/description") + print_rich( +""" +%s - %s - %s - %s +%s + +%s + +Options: +""" + % [ + project_name, + project_version, + project_hash, + project_website, + project_description, + "usage: %s [options]" % OS.get_executable_path().get_file() + ] + ) + for option in option_array: + print_rich(" --%s%s%s" % [ + (option.name + (",-%s" % (",-".join(option.aliases)) if option.aliases.size() > 0 else "")).rpad(45), + ("Type: %s - Default Value: %s" % [option.get_type_string(), option.default_value]).rpad(45), + option.description + ]) +func _ready(): + if Engine.is_editor_hint(): return + + var argument_dictionary : Dictionary = {} + if ProjectSettings.has_setting(argument_setting_path): + argument_dictionary = ProjectSettings.get_setting_with_override(argument_setting_path) + for option in option_array: + argument_dictionary[option.name] = option.default_value + + _parse_argument_list(argument_dictionary, OS.get_cmdline_args()) + _parse_argument_list(argument_dictionary, OS.get_cmdline_user_args()) + + ProjectSettings.set_setting(argument_setting_path, argument_dictionary) + if argument_dictionary[&"help"]: + _print_help() + get_tree().quit() diff --git a/game/src/Game/Autoload/Argument/ArgumentParser.tscn b/game/src/Game/Autoload/Argument/ArgumentParser.tscn new file mode 100644 index 0000000..8fda8f1 --- /dev/null +++ b/game/src/Game/Autoload/Argument/ArgumentParser.tscn @@ -0,0 +1,32 @@ +[gd_scene load_steps=6 format=3 uid="uid://dayjmgc34tqo6"] + +[ext_resource type="Script" path="res://src/Autoload/Arguments/ArgumentParser.gd" id="1_pc7xr"] +[ext_resource type="Script" path="res://src/Autoload/Arguments/ArgumentOption.gd" id="2_4hguj"] + +[sub_resource type="Resource" id="Resource_tq3y4"] +script = ExtResource("2_4hguj") +name = &"help" +aliases = Array[StringName]([&"h"]) +type = 1 +description = "Displays help and quits." +default_value = false + +[sub_resource type="Resource" id="Resource_j1to4"] +script = ExtResource("2_4hguj") +name = &"game-debug" +aliases = Array[StringName]([&"d", &"-debug", &"-debug-mode"]) +type = 1 +description = "Start in debug mode." +default_value = false + +[sub_resource type="Resource" id="Resource_tiax1"] +script = ExtResource("2_4hguj") +name = &"compatibility-mode" +aliases = Array[StringName]([&"-compat"]) +type = 4 +description = "Load Victoria 2 assets from this path." +default_value = "" + +[node name="ArgumentParser" type="Node"] +script = ExtResource("1_pc7xr") +option_array = Array[ExtResource("2_4hguj")]([SubResource("Resource_tq3y4"), SubResource("Resource_j1to4"), SubResource("Resource_tiax1")]) diff --git a/game/src/Game/Autoload/Events.gd b/game/src/Game/Autoload/Events.gd new file mode 100644 index 0000000..4387cc7 --- /dev/null +++ b/game/src/Game/Autoload/Events.gd @@ -0,0 +1,45 @@ +extends Node + +var GameDebug = preload("Events/GameDebug.gd").new() +var Options = preload("Events/Options.gd").new() +var Localisation = preload("Events/Localisation.gd").new() +var ShaderManager = preload("Events/ShaderManager.gd").new() + +var _define_filepaths_dict : Dictionary = { + GameSingleton.get_province_identifier_file_key(): "res://common/map/provinces.json", + GameSingleton.get_water_province_file_key(): "res://common/map/water.json", + GameSingleton.get_region_file_key(): "res://common/map/regions.json", + GameSingleton.get_terrain_variant_file_key(): "res://common/map/terrain.json", + GameSingleton.get_terrain_texture_dir_key(): "res://art/terrain/", + GameSingleton.get_province_image_file_key(): "res://common/map/provinces.png", + GameSingleton.get_terrain_image_file_key(): "res://common/map/terrain.png", + GameSingleton.get_goods_file_key(): "res://common/goods.json", + GameSingleton.get_good_icons_dir_key(): "res://art/economy/goods" +} + +# REQUIREMENTS +# * FS-333, FS-334, FS-335, FS-341 +func _ready(): + GameSingleton.setup_logger() + + # Set this to your Vic2 install dir or a mod's dir to enable compatibility mode + # (this won't work for mods which rely on vanilla map assets, copy missing assets + # into the mod's dir for a temporary fix) + # Usage: OpenVic --compatibility-mode + + var compatibility_mode_path : String + if ProjectSettings.has_setting(ArgumentParser.argument_setting_path): + var arg_dictionary : Dictionary = ProjectSettings.get_setting(ArgumentParser.argument_setting_path) + compatibility_mode_path = arg_dictionary.get(&"compatibility-mode", compatibility_mode_path) + + var start := Time.get_ticks_usec() + + if compatibility_mode_path: + if GameSingleton.load_defines_compatibility_mode(compatibility_mode_path) != OK: + push_error("Errors loading game defines!") + else: + if GameSingleton.load_defines(_define_filepaths_dict) != OK: + push_error("Errors loading game defines!") + + var end := Time.get_ticks_usec() + print("Loading took ", float(end - start) / 1000000, " seconds") diff --git a/game/src/Game/Autoload/Events/GameDebug.gd b/game/src/Game/Autoload/Events/GameDebug.gd new file mode 100644 index 0000000..df7a23a --- /dev/null +++ b/game/src/Game/Autoload/Events/GameDebug.gd @@ -0,0 +1,21 @@ +extends RefCounted + +# REQUIREMENTS: +# * SS-56 +func _init(): + for engine_args in OS.get_cmdline_args(): + match(engine_args): + "--game-debug": + set_debug_mode(true) + + for engine_args in OS.get_cmdline_user_args(): + match(engine_args): + "--game-debug", "-d", "--debug", "--debug-mode": + set_debug_mode(true) + +func set_debug_mode(value : bool) -> void: + ProjectSettings.set_setting("openvic/debug/enabled", value) + print("Set debug mode to: ", value) + +func is_debug_mode() -> bool: + return ProjectSettings.get_setting("openvic/debug/enabled", false) diff --git a/game/src/Game/Autoload/Events/Localisation.gd b/game/src/Game/Autoload/Events/Localisation.gd new file mode 100644 index 0000000..eda7e51 --- /dev/null +++ b/game/src/Game/Autoload/Events/Localisation.gd @@ -0,0 +1,30 @@ +extends RefCounted + +# REQUIREMENTS +# * SS-59, SS-60, SS-61 +func get_default_locale() -> String: + var locales := TranslationServer.get_loaded_locales() + var default_locale := OS.get_locale() + if default_locale in locales: + return default_locale + var default_language := OS.get_locale_language() + for locale in locales: + if locale.begins_with(default_language): + return default_language + return ProjectSettings.get_setting("internationalization/locale/fallback", "en_GB") + +func load_localisation(dir_path : String) -> void: + if LoadLocalisation.load_localisation_dir(dir_path) == OK: + print("loaded locales: ", TranslationServer.get_loaded_locales()) + else: + push_error("Failed to load localisation directory: ", dir_path) + +# REQUIREMENTS +# * SS-57 +# * FS-17 +func _init(): + var localisation_dir_path : String = ProjectSettings.get_setting("internationalization/locale/localisation_path", "") + if localisation_dir_path.is_empty(): + push_error("Missing localisation_path setting!") + else: + load_localisation(localisation_dir_path) diff --git a/game/src/Game/Autoload/Events/Options.gd b/game/src/Game/Autoload/Events/Options.gd new file mode 100644 index 0000000..fbeccef --- /dev/null +++ b/game/src/Game/Autoload/Events/Options.gd @@ -0,0 +1,30 @@ +extends RefCounted + +signal save_settings(save_file: ConfigFile) +signal load_settings(load_file: ConfigFile) +signal reset_settings() + +func load_settings_from_file() -> void: + load_settings.emit(_settings_file) + +# REQUIREMENTS +# * SS-11 +func save_settings_to_file() -> void: + save_settings.emit(_settings_file) + _settings_file.save(_settings_file_path) + +func try_reset_settings() -> void: + reset_settings.emit() + +const settings_file_path_setting : String = "openvic/settings/settings_file_path" +const settings_file_path_default : String = "user://settings.cfg" + +var _settings_file_path : String = ProjectSettings.get_setting(settings_file_path_setting, settings_file_path_default) +var _settings_file := ConfigFile.new() + +# REQUIREMENTS +# * SS-9 +# * UIFUN-7 +func _init(): + if FileAccess.file_exists(_settings_file_path): + _settings_file.load(_settings_file_path) diff --git a/game/src/Game/Autoload/Events/ShaderManager.gd b/game/src/Game/Autoload/Events/ShaderManager.gd new file mode 100644 index 0000000..a503c52 --- /dev/null +++ b/game/src/Game/Autoload/Events/ShaderManager.gd @@ -0,0 +1,48 @@ +extends RefCounted + +const param_province_shape_tex : StringName = &"province_shape_tex" +const param_province_shape_subdivisions : StringName = &"province_shape_subdivisions" +const param_province_colour_tex : StringName = &"province_colour_tex" +const param_hover_index : StringName = &"hover_index" +const param_selected_index : StringName = &"selected_index" +const param_terrain_tex : StringName = &"terrain_tex" +const param_terrain_tile_factor : StringName = &"terrain_tile_factor" + +func set_up_shader(material : Material, add_cosmetic_textures : bool) -> Error: + # Shader Material + if material == null: + push_error("material is null!") + return FAILED + if not material is ShaderMaterial: + push_error("Invalid map mesh material class: ", material.get_class()) + return FAILED + var shader_material : ShaderMaterial = material + + # Province shape texture + var province_shape_texture := GameSingleton.get_province_shape_texture() + if province_shape_texture == null: + push_error("Failed to get province shape texture!") + return FAILED + shader_material.set_shader_parameter(param_province_shape_tex, province_shape_texture) + var subdivisions := GameSingleton.get_province_shape_image_subdivisions() + if subdivisions.x < 1 or subdivisions.y < 1: + push_error("Invalid province shape image subdivision: ", subdivisions.x, "x", subdivisions.y) + return FAILED + shader_material.set_shader_parameter(param_province_shape_subdivisions, Vector2(subdivisions)) + + if add_cosmetic_textures: + # Province colour texture + var map_province_colour_texture := GameSingleton.get_province_colour_texture() + if map_province_colour_texture == null: + push_error("Failed to get province colour image!") + return FAILED + shader_material.set_shader_parameter(param_province_colour_tex, map_province_colour_texture) + + # Terrain texture + var terrain_texture := GameSingleton.get_terrain_texture() + if terrain_texture == null: + push_error("Failed to get terrain texture!") + return FAILED + shader_material.set_shader_parameter(param_terrain_tex, terrain_texture) + + return OK diff --git a/game/src/Game/Autoload/GuiScale.gd b/game/src/Game/Autoload/GuiScale.gd new file mode 100644 index 0000000..afd73df --- /dev/null +++ b/game/src/Game/Autoload/GuiScale.gd @@ -0,0 +1,62 @@ +extends Node + +const error_guiscale : float = -1.0 + +@export +var minimum_guiscale : float = 0.1 + +const _starting_guiscales : Dictionary = { + float(0.5) : &"0.5x", + float(0.75): &"0.75x", + float(1) : &"1x", + float(1.5) : &"1.5x", + float(2) : &"2x", +} + +var _guiscales: Dictionary + +#Similar to Resolution.gd, but we don't bother checking for strings from files +#and we have floats instead of vector2 integers + +func _ready(): + assert(minimum_guiscale > 0, "Minimum gui scale must be positive") + for guiscale_value in _starting_guiscales: + add_guiscale(guiscale_value, _starting_guiscales[guiscale_value]) + assert(not _guiscales.is_empty(), "No valid starting gui scales!") + +func has_guiscale(guiscale_value : float) -> bool: + return guiscale_value in _guiscales + +func add_guiscale(guiscale_value: float, guiscale_name: StringName=&"") -> bool: + if has_guiscale(guiscale_value): return true + var scale_dict := { value = guiscale_value } + if not guiscale_name.is_empty(): + scale_dict.display_name = guiscale_name + else: + scale_dict.display_name = StringName("%sx" % guiscale_value) + if guiscale_value < minimum_guiscale: + push_error("GUI scale %s is smaller than the minimum %s" % [scale_dict.display_name, minimum_guiscale]) + return false + _guiscales[guiscale_value] = scale_dict + return true + +#returns floats +func get_guiscale_value_list() -> Array: + var list := _guiscales.keys() + list.sort_custom(func(a, b): return a > b) + return list + +func get_guiscale_display_name(guiscale_value : float) -> StringName: + return _guiscales.get(guiscale_value, {display_name = &"unknown gui scale"}).display_name + +func get_current_guiscale() -> float: + return get_tree().root.content_scale_factor + +func set_guiscale(guiscale:float) -> void: + print("New GUI scale: %f" % guiscale) + if not has_guiscale(guiscale): + push_warning("Setting GUI Scale to non-standard value %sx" % [guiscale]) + get_tree().root.content_scale_factor = guiscale + +func reset_guiscale() -> void: + set_guiscale(get_current_guiscale()) diff --git a/game/src/Game/Autoload/Resolution.gd b/game/src/Game/Autoload/Resolution.gd new file mode 100644 index 0000000..c973ba9 --- /dev/null +++ b/game/src/Game/Autoload/Resolution.gd @@ -0,0 +1,101 @@ +extends Node + +signal resolution_added(value : Vector2i, name : StringName, display_name : StringName) +signal resolution_changed(value : Vector2i) +signal window_mode_changed(value : Window.Mode) + +const error_resolution : Vector2i = Vector2i(-1,-1) + +@export +var minimum_resolution : Vector2i = Vector2i(1,1) + +const _starting_resolutions : Dictionary = { + Vector2i(3840,2160): &"4K", + Vector2i(2560,1080): &"UW1080p", + Vector2i(1920,1080): &"1080p", + Vector2i(1366,768) : &"", + Vector2i(1536,864) : &"", + Vector2i(1280,720) : &"720p", + Vector2i(1440,900) : &"", + Vector2i(1600,900) : &"", + Vector2i(1024,600) : &"", + Vector2i(800,600) : &"" +} + +var _resolutions : Dictionary + +const _regex_pattern : String = "(\\d+)\\s*[xX,]\\s*(\\d+)" +var _regex : RegEx + +func _ready(): + assert(minimum_resolution.x > 0 and minimum_resolution.y > 0, "Minimum resolution must be positive!") + for resolution_value in _starting_resolutions: + add_resolution(resolution_value, _starting_resolutions[resolution_value]) + assert(not _resolutions.is_empty(), "No valid starting resolutions!") + + _regex = RegEx.new() + var err := _regex.compile(_regex_pattern) + assert(err == OK, "Resolution RegEx failed to compile!") + + +func has_resolution(resolution_value : Vector2i) -> bool: + return resolution_value in _resolutions + +func add_resolution(resolution_value : Vector2i, resolution_name : StringName = &"") -> bool: + if has_resolution(resolution_value): return true + var res_dict := { value = resolution_value, name = &"" } + var display_name := "%sx%s" % [resolution_value.x, resolution_value.y] + if not resolution_name.is_empty(): + res_dict.name = resolution_name + display_name = "%s (%s)" % [display_name, resolution_name] + res_dict.display_name = StringName(display_name) + if resolution_value.x < minimum_resolution.x or resolution_value.y < minimum_resolution.y: + push_error("Resolution %s is smaller than minimum (%sx%s)" % [res_dict.display_name, minimum_resolution.x, minimum_resolution.y]) + return false + resolution_added.emit(resolution_value, resolution_name, display_name) + _resolutions[resolution_value] = res_dict + return true + +func get_resolution_value_list() -> Array: + var list := _resolutions.keys() + list.sort_custom(func(a, b): return a > b) + return list + +func get_resolution_name(resolution_value : Vector2i) -> StringName: + return _resolutions.get(resolution_value, { name = &"unknown resolution" }).name + +func get_resolution_display_name(resolution_value : Vector2i) -> StringName: + return _resolutions.get(resolution_value, { display_name = &"unknown resolution" }).display_name + +func get_resolution_value_from_string(resolution_string : String) -> Vector2i: + if not resolution_string.is_empty(): + for resolution in _resolutions.values(): + if resolution_string == resolution.name or resolution_string == resolution.display_name: + return resolution.value + var result := _regex.search(resolution_string) + if result: return Vector2i(result.get_string(1).to_int(), result.get_string(2).to_int()) + return error_resolution + +func get_current_resolution() -> Vector2i: + var window := get_viewport().get_window() + match window.mode: + Window.MODE_EXCLUSIVE_FULLSCREEN, Window.MODE_FULLSCREEN: + return window.content_scale_size + _: + return window.size + +func set_resolution(resolution : Vector2i) -> void: + if not has_resolution(resolution): + push_warning("Setting resolution to non-standard value %sx%s" % [resolution.x, resolution.y]) + var window := get_viewport().get_window() + if get_current_resolution() != resolution: + resolution_changed.emit(resolution) + match window.mode: + Window.MODE_EXCLUSIVE_FULLSCREEN, Window.MODE_FULLSCREEN: + window.content_scale_size = resolution + _: + window.size = resolution + window.content_scale_size = Vector2i(0,0) + +func reset_resolution() -> void: + set_resolution(get_current_resolution()) diff --git a/game/src/Game/Autoload/SaveManager.gd b/game/src/Game/Autoload/SaveManager.gd new file mode 100644 index 0000000..fb7806b --- /dev/null +++ b/game/src/Game/Autoload/SaveManager.gd @@ -0,0 +1,55 @@ +extends Node + +# Requirements +# * FS-28 +const save_directory_setting := &"openvic/data/saves_directory" + +var current_save : SaveResource +var current_session_tag : StringName + +var _save_dictionary : Dictionary = {} +var _dirty_save : SaveResource + +func _ready(): + var saves_dir_path : String = ProjectSettings.get_setting_with_override(save_directory_setting) + assert(saves_dir_path != null, "'%s' setting could not be found." % save_directory_setting) + + DirAccess.make_dir_recursive_absolute(saves_dir_path) + var saves_dir := DirAccess.open(saves_dir_path) + for file in saves_dir.get_files(): + var save := SaveResource.new() + save.load_save(saves_dir_path.path_join(file)) + add_or_replace_save(save, true) + +func get_save_file_name(save_name : StringName, session_tag : StringName = current_session_tag) -> StringName: + return ("%s - %s" % [save_name, session_tag]).validate_filename() + +func make_new_save(save_name : String, session_tag : StringName = current_session_tag) -> SaveResource: + var file_name := get_save_file_name(save_name, session_tag) + ".tres" + var new_save := SaveResource.new() + new_save.set_file_path(save_name, ProjectSettings.get_setting_with_override(save_directory_setting).path_join(file_name)) + print(new_save.file_path) + new_save.session_tag = session_tag + return new_save + +func has_save(save_name : StringName, session_tag : StringName = current_session_tag) -> bool: + return _save_dictionary.has(get_save_file_name(save_name, session_tag)) + +func add_or_replace_save(save : SaveResource, ignore_dirty : bool = false) -> void: + var binded_func := _on_save_deleted_or_moved.bind(save) + save.deleted.connect(binded_func) + save.trash_moved.connect(binded_func) + _save_dictionary[get_save_file_name(save.save_name, save.session_tag)] = save + if not ignore_dirty: + _dirty_save = save + +func delete_save(save : SaveResource) -> void: + save.delete() + +func flush_save() -> void: + if _dirty_save == null: return + _dirty_save.flush_save() + _dirty_save = null + +func _on_save_deleted_or_moved(save : SaveResource) -> void: + _save_dictionary.erase(get_save_file_name(save.save_name, save.session_tag)) diff --git a/game/src/Game/Autoload/SoundManager.gd b/game/src/Game/Autoload/SoundManager.gd new file mode 100644 index 0000000..c58ce1a --- /dev/null +++ b/game/src/Game/Autoload/SoundManager.gd @@ -0,0 +1,42 @@ +extends Node + +# REQUIREMENTS: +# * SS-68 + +const _audio_directory_path : StringName = &"res://audio/sfx/" + +var _loaded_sound : Dictionary = {} + +var _bus_to_stream_player : Dictionary = {} + +# REQUIREMENTS: +# * SND-10 +func _ready(): + var dir = DirAccess.open(_audio_directory_path) + for fname in dir.get_files(): + match fname.get_extension(): + "ogg", "wav", "mp3": + _loaded_sound[fname.get_basename()] = load(_audio_directory_path.path_join(fname)) # SND-10 + +func play_stream(sound : AudioStream, bus_type : String) -> void: + var player : AudioStreamPlayer = _bus_to_stream_player.get(bus_type) + if player == null: + player = AudioStreamPlayer.new() + player.bus = bus_type + player.stream = AudioStreamPolyphonic.new() + _bus_to_stream_player[bus_type] = player + add_child(player) + player.play() + var poly_playback : AudioStreamPlaybackPolyphonic = player.get_stream_playback() + poly_playback.play_stream(sound) + +func play(sound : String, bus_type : String) -> void: + play_stream(_loaded_sound[sound], bus_type) + +# REQUIREMENTS: +# * SND-7 +func play_effect_stream(sound : AudioStream) -> void: + play_stream(sound, "SFX") + +func play_effect(sound : String) -> void: + play(sound, "SFX") diff --git a/game/src/Game/GameMenu.gd b/game/src/Game/GameMenu.gd new file mode 100644 index 0000000..4b589f9 --- /dev/null +++ b/game/src/Game/GameMenu.gd @@ -0,0 +1,47 @@ +extends Control + +@export var _main_menu : Control +@export var _options_menu : Control +@export var _lobby_menu : Control +@export var _credits_menu : Control + +# REQUIREMENTS +# * SS-10 +func _ready(): + Events.Options.load_settings_from_file() + +func _on_main_menu_new_game_button_pressed(): + _lobby_menu.show() + _main_menu.hide() + +# REQUIREMENTS +# * SS-6 +# * UIFUN-5 +func _on_main_menu_options_button_pressed(): + _options_menu.show() + _main_menu.hide() + + +func _on_options_menu_back_button_pressed(): + _main_menu.show() + _options_menu.hide() + + +func _on_lobby_menu_back_button_pressed(): + _main_menu.show() + _lobby_menu.hide() + + +func _on_credits_back_button_pressed(): + _credits_menu.hide() + _main_menu.show() + + +func _on_main_menu_credits_button_pressed(): + _credits_menu.show() + _main_menu.hide() + + + +func _on_splash_container_splash_end(): + show() diff --git a/game/src/Game/GameMenu.tscn b/game/src/Game/GameMenu.tscn new file mode 100644 index 0000000..224ae2e --- /dev/null +++ b/game/src/Game/GameMenu.tscn @@ -0,0 +1,53 @@ +[gd_scene load_steps=7 format=3 uid="uid://o4u142w4qkln"] + +[ext_resource type="Script" path="res://src/GameMenu.gd" id="1_cafwe"] +[ext_resource type="PackedScene" uid="uid://bp5n3mlu45ygw" path="res://src/MainMenu/MainMenu.tscn" id="2_2jbkh"] +[ext_resource type="PackedScene" uid="uid://cnbfxjy1m6wja" path="res://src/OptionMenu/OptionsMenu.tscn" id="3_111lv"] +[ext_resource type="PackedScene" uid="uid://c8knthxkwj1uj" path="res://src/CreditsMenu/CreditsMenu.tscn" id="4_n0hoo"] +[ext_resource type="PackedScene" uid="uid://do60kx0d3nrh4" path="res://src/LobbyMenu/LobbyMenu.tscn" id="4_nofk1"] +[ext_resource type="PackedScene" uid="uid://cvl76duuym1wq" path="res://src/MusicConductor/MusicPlayer.tscn" id="6_lts1m"] + +[node name="GameMenu" type="Control" node_paths=PackedStringArray("_main_menu", "_options_menu", "_lobby_menu", "_credits_menu")] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_cafwe") +_main_menu = NodePath("MainMenu") +_options_menu = NodePath("OptionsMenu") +_lobby_menu = NodePath("LobbyMenu") +_credits_menu = NodePath("CreditsMenu") + +[node name="MainMenu" parent="." instance=ExtResource("2_2jbkh")] +layout_mode = 1 +metadata/_edit_vertical_guides_ = [251.0, 269.0, 504.0, 523.0, 15.0, 759.0, 777.0] + +[node name="OptionsMenu" parent="." instance=ExtResource("3_111lv")] +visible = false +layout_mode = 1 + +[node name="LobbyMenu" parent="." instance=ExtResource("4_nofk1")] +visible = false +layout_mode = 1 + +[node name="CreditsMenu" parent="." instance=ExtResource("4_n0hoo")] +visible = false +layout_mode = 1 + +[node name="MusicPlayer" parent="." instance=ExtResource("6_lts1m")] +layout_mode = 1 +anchors_preset = 1 +anchor_left = 1.0 +anchor_right = 1.0 +offset_left = -184.0 +offset_right = -34.0 +grow_horizontal = 0 + +[connection signal="credits_button_pressed" from="MainMenu" to="." method="_on_main_menu_credits_button_pressed"] +[connection signal="new_game_button_pressed" from="MainMenu" to="." method="_on_main_menu_new_game_button_pressed"] +[connection signal="options_button_pressed" from="MainMenu" to="." method="_on_main_menu_options_button_pressed"] +[connection signal="back_button_pressed" from="OptionsMenu" to="." method="_on_options_menu_back_button_pressed"] +[connection signal="back_button_pressed" from="LobbyMenu" to="." method="_on_lobby_menu_back_button_pressed"] +[connection signal="back_button_pressed" from="CreditsMenu" to="." method="_on_credits_back_button_pressed"] diff --git a/game/src/Game/GameSession/GameSession.gd b/game/src/Game/GameSession/GameSession.gd new file mode 100644 index 0000000..5bb1c2f --- /dev/null +++ b/game/src/Game/GameSession/GameSession.gd @@ -0,0 +1,16 @@ +extends Control + +@export var _game_session_menu : Control + +func _ready(): + Events.Options.load_settings_from_file() + if GameSingleton.setup_game() != OK: + push_error("Failed to setup game") + +func _process(delta : float): + GameSingleton.try_tick() + +# REQUIREMENTS: +# * SS-42 +func _on_game_session_menu_button_pressed() -> void: + _game_session_menu.visible = !_game_session_menu.visible diff --git a/game/src/Game/GameSession/GameSession.tscn b/game/src/Game/GameSession/GameSession.tscn new file mode 100644 index 0000000..188ccde --- /dev/null +++ b/game/src/Game/GameSession/GameSession.tscn @@ -0,0 +1,95 @@ +[gd_scene load_steps=10 format=3 uid="uid://bgnupcshe1m7r"] + +[ext_resource type="Script" path="res://src/GameSession/GameSession.gd" id="1_eklvp"] +[ext_resource type="PackedScene" uid="uid://cvl76duuym1wq" path="res://src/MusicConductor/MusicPlayer.tscn" id="2_kt6aa"] +[ext_resource type="PackedScene" uid="uid://g524p8lr574w" path="res://src/GameSession/MapControlPanel/MapControlPanel.tscn" id="3_afh6d"] +[ext_resource type="PackedScene" uid="uid://dvdynl6eir40o" path="res://src/GameSession/GameSessionMenu.tscn" id="3_bvmqh"] +[ext_resource type="PackedScene" uid="uid://dkehmdnuxih2r" path="res://src/GameSession/MapView.tscn" id="4_xkg5j"] +[ext_resource type="PackedScene" uid="uid://byq323jbel48u" path="res://src/GameSession/ProvinceOverviewPanel/ProvinceOverviewPanel.tscn" id="5_osjnn"] +[ext_resource type="PackedScene" uid="uid://cnbfxjy1m6wja" path="res://src/OptionMenu/OptionsMenu.tscn" id="6_p5mnx"] +[ext_resource type="PackedScene" uid="uid://dd8k3p7r3huwc" path="res://src/GameSession/GameSpeedPanel.tscn" id="7_myy4q"] +[ext_resource type="PackedScene" uid="uid://d3g6wbvwflmyk" path="res://src/SaveLoadMenu/SaveLoadMenu.tscn" id="8_4g7ko"] + +[node name="GameSession" type="Control" node_paths=PackedStringArray("_game_session_menu")] +editor_description = "SS-102, UI-546" +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +mouse_filter = 2 +script = ExtResource("1_eklvp") +_game_session_menu = NodePath("GameSessionMenu") + +[node name="MapView" parent="." instance=ExtResource("4_xkg5j")] + +[node name="MapControlPanel" parent="." instance=ExtResource("3_afh6d")] +layout_mode = 1 +anchors_preset = 3 +anchor_left = 1.0 +anchor_top = 1.0 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 0 +grow_vertical = 0 + +[node name="ProvinceOverviewPanel" parent="." instance=ExtResource("5_osjnn")] +layout_mode = 1 + +[node name="GameSpeedPanel" parent="." instance=ExtResource("7_myy4q")] +layout_mode = 0 +offset_right = 302.0 +offset_bottom = 31.0 + +[node name="GameSessionMenu" parent="." instance=ExtResource("3_bvmqh")] +visible = false +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -159.0 +offset_top = -165.0 +offset_right = 159.0 +offset_bottom = 165.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="OptionsMenu" parent="." instance=ExtResource("6_p5mnx")] +visible = false +layout_mode = 1 + +[node name="SaveLoadMenu" parent="." instance=ExtResource("8_4g7ko")] +visible = false +layout_mode = 1 +anchors_preset = -1 +anchor_left = 0.5 +anchor_right = 0.5 +offset_left = -640.0 +offset_right = 640.0 + +[node name="MusicPlayer" parent="." instance=ExtResource("2_kt6aa")] +layout_mode = 1 +anchors_preset = 1 +anchor_left = 1.0 +anchor_right = 1.0 +offset_left = -150.0 +offset_right = 0.0 +grow_horizontal = 0 + +[connection signal="map_view_camera_changed" from="MapView" to="MapControlPanel" method="_on_map_view_camera_changed"] +[connection signal="game_session_menu_button_pressed" from="MapControlPanel" to="." method="_on_game_session_menu_button_pressed"] +[connection signal="minimap_clicked" from="MapControlPanel" to="MapView" method="_on_minimap_clicked"] +[connection signal="mouse_entered" from="MapControlPanel" to="MapView" method="_on_mouse_exited_viewport"] +[connection signal="mouse_exited" from="MapControlPanel" to="MapView" method="_on_mouse_entered_viewport"] +[connection signal="zoom_in_button_pressed" from="MapControlPanel" to="MapView" method="zoom_in"] +[connection signal="zoom_out_button_pressed" from="MapControlPanel" to="MapView" method="zoom_out"] +[connection signal="mouse_entered" from="ProvinceOverviewPanel" to="MapView" method="_on_mouse_exited_viewport"] +[connection signal="mouse_exited" from="ProvinceOverviewPanel" to="MapView" method="_on_mouse_entered_viewport"] +[connection signal="load_button_pressed" from="GameSessionMenu" to="SaveLoadMenu" method="show_for_load"] +[connection signal="options_button_pressed" from="GameSessionMenu" to="OptionsMenu" method="show"] +[connection signal="save_button_pressed" from="GameSessionMenu" to="SaveLoadMenu" method="show_for_save"] +[connection signal="back_button_pressed" from="OptionsMenu" to="MapView" method="enable_processing"] +[connection signal="back_button_pressed" from="OptionsMenu" to="OptionsMenu" method="hide"] diff --git a/game/src/Game/GameSession/GameSessionMenu.gd b/game/src/Game/GameSession/GameSessionMenu.gd new file mode 100644 index 0000000..23ef2ef --- /dev/null +++ b/game/src/Game/GameSession/GameSessionMenu.gd @@ -0,0 +1,80 @@ +extends PanelContainer + +@export var _main_menu_scene : PackedScene + +@export var _main_menu_dialog : AcceptDialog +@export var _quit_dialog : AcceptDialog + +var _main_menu_save_button : Button +var _main_menu_save_separator : Control +var _quit_save_button : Button +var _quit_save_separator : Control + +signal save_button_pressed +signal load_button_pressed +signal options_button_pressed + +func _ready() -> void: + _main_menu_save_button = _main_menu_dialog.add_button("DIALOG_SAVE_AND_RESIGN", true, &"save_and_main_menu") + _quit_save_button = _quit_dialog.add_button("DIALOG_SAVE_AND_QUIT", true, &"save_and_quit") + + # Neccessary to center the save buttons and preserve the reference to the separator elements + var dialog_hbox : HBoxContainer = _main_menu_dialog.get_child(2, true) + var index := _main_menu_save_button.get_index(true) + dialog_hbox.move_child(_main_menu_save_button, _main_menu_dialog.get_ok_button().get_index(true)) + dialog_hbox.move_child(_main_menu_dialog.get_ok_button(), index) + _main_menu_save_separator = dialog_hbox.get_child(_main_menu_save_button.get_index(true) - 1) + + dialog_hbox = _quit_dialog.get_child(2, true) + index = _quit_save_button.get_index(true) + dialog_hbox.move_child(_quit_save_button, _quit_dialog.get_ok_button().get_index(true)) + dialog_hbox.move_child(_quit_dialog.get_ok_button(), index) + _quit_save_separator = dialog_hbox.get_child(_quit_save_button.get_index(true) - 1) + +func hide_save_dialog_button() -> void: + _main_menu_save_button.hide() + _main_menu_save_separator.hide() + _quit_save_button.hide() + _quit_save_separator.hide() + +func show_save_dialog_button() -> void: + _main_menu_save_button.show() + _main_menu_save_separator.show() + _quit_save_button.show() + _quit_save_separator.show() + +# REQUIREMENTS: +# * SS-47 +# * UIFUN-69 +func _on_main_menu_confirmed() -> void: + SaveManager.current_session_tag = "" + SaveManager.current_save = null + get_tree().change_scene_to_packed(_main_menu_scene) + +# REQUIREMENTS: +# * SS-48 +# * UIFUN-70 +func _on_quit_confirmed() -> void: + get_tree().quit() + +# REQUIREMENTS: +# * SS-7, SS-46 +# * UIFUN-11 +func _on_options_button_pressed() -> void: + options_button_pressed.emit() + +func _on_main_menu_dialog_custom_action(action) -> void: + match action: + &"save_and_main_menu": + _on_main_menu_confirmed() + +func _on_quit_dialog_custom_action(action : StringName) -> void: + match action: + &"save_and_quit": + _on_quit_confirmed() + +func _on_save_button_pressed(): + save_button_pressed.emit() + +func _on_load_button_pressed(): + load_button_pressed.emit() diff --git a/game/src/Game/GameSession/GameSessionMenu.tscn b/game/src/Game/GameSession/GameSessionMenu.tscn new file mode 100644 index 0000000..025ef3b --- /dev/null +++ b/game/src/Game/GameSession/GameSessionMenu.tscn @@ -0,0 +1,91 @@ +[gd_scene load_steps=4 format=3 uid="uid://dvdynl6eir40o"] + +[ext_resource type="Theme" uid="uid://cqrfmjt5yeti7" path="res://theme/game_session_menu.tres" id="1_2onog"] +[ext_resource type="Script" path="res://src/GameSession/GameSessionMenu.gd" id="1_usq6o"] +[ext_resource type="PackedScene" uid="uid://o4u142w4qkln" path="res://src/GameMenu.tscn" id="2_xi6a4"] + +[node name="GameSessionMenu" type="PanelContainer" node_paths=PackedStringArray("_main_menu_dialog", "_quit_dialog")] +process_mode = 3 +editor_description = "UI-68" +theme = ExtResource("1_2onog") +theme_type_variation = &"SessionPanel" +script = ExtResource("1_usq6o") +_main_menu_scene = ExtResource("2_xi6a4") +_main_menu_dialog = NodePath("MainMenuDialog") +_quit_dialog = NodePath("QuitDialog") + +[node name="ButtonListMargin" type="MarginContainer" parent="."] +layout_mode = 2 +theme_override_constants/margin_left = 10 +theme_override_constants/margin_top = 10 +theme_override_constants/margin_right = 10 +theme_override_constants/margin_bottom = 10 + +[node name="ButtonList" type="VBoxContainer" parent="ButtonListMargin"] +layout_mode = 2 + +[node name="SaveButton" type="Button" parent="ButtonListMargin/ButtonList"] +editor_description = "UI-69" +layout_mode = 2 +theme_type_variation = &"SessionButton" +text = "GAMESESSIONMENU_SAVE" + +[node name="LoadButton" type="Button" parent="ButtonListMargin/ButtonList"] +editor_description = "UI-70" +layout_mode = 2 +theme_type_variation = &"SessionButton" +text = "GAMESESSIONMENU_LOAD" + +[node name="OptionsButton" type="Button" parent="ButtonListMargin/ButtonList"] +editor_description = "UI-10" +layout_mode = 2 +theme_type_variation = &"SessionButton" +text = "GAMESESSIONMENU_OPTIONS" + +[node name="MainMenuButton" type="Button" parent="ButtonListMargin/ButtonList"] +editor_description = "UI-71" +layout_mode = 2 +theme_type_variation = &"SessionButton" +text = "GAMESESSIONMENU_MAINMENU" + +[node name="QuitButton" type="Button" parent="ButtonListMargin/ButtonList"] +editor_description = "UI-72" +layout_mode = 2 +theme_type_variation = &"SessionButton" +text = "GAMESESSIONMENU_QUIT" + +[node name="CloseSeparator" type="HSeparator" parent="ButtonListMargin/ButtonList"] +layout_mode = 2 +theme_type_variation = &"SessionSeparator" + +[node name="CloseButton" type="Button" parent="ButtonListMargin/ButtonList"] +editor_description = "SS-64, UI-80, UIFUN-79" +layout_mode = 2 +theme_type_variation = &"SessionButton" +text = "GAMESESSIONMENU_CLOSE" + +[node name="MainMenuDialog" type="ConfirmationDialog" parent="."] +disable_3d = true +title = "GAMESESSIONMENU_MAINMENU_DIALOG_TITLE" +size = Vector2i(384, 100) +ok_button_text = "DIALOG_OK" +dialog_text = "GAMESESSIONMENU_MAINMENU_DIALOG_TEXT" +cancel_button_text = "DIALOG_CANCEL" + +[node name="QuitDialog" type="ConfirmationDialog" parent="."] +disable_3d = true +title = "GAMESESSIONMENU_QUIT_DIALOG_TITLE" +ok_button_text = "DIALOG_OK" +dialog_text = "GAMESESSIONMENU_QUIT_DIALOG_TEXT" +cancel_button_text = "DIALOG_CANCEL" + +[connection signal="pressed" from="ButtonListMargin/ButtonList/SaveButton" to="." method="_on_save_button_pressed"] +[connection signal="pressed" from="ButtonListMargin/ButtonList/LoadButton" to="." method="_on_load_button_pressed"] +[connection signal="pressed" from="ButtonListMargin/ButtonList/OptionsButton" to="." method="_on_options_button_pressed"] +[connection signal="pressed" from="ButtonListMargin/ButtonList/MainMenuButton" to="MainMenuDialog" method="popup_centered"] +[connection signal="pressed" from="ButtonListMargin/ButtonList/QuitButton" to="QuitDialog" method="popup_centered"] +[connection signal="pressed" from="ButtonListMargin/ButtonList/CloseButton" to="." method="hide"] +[connection signal="confirmed" from="MainMenuDialog" to="." method="_on_main_menu_confirmed"] +[connection signal="custom_action" from="MainMenuDialog" to="." method="_on_main_menu_dialog_custom_action"] +[connection signal="confirmed" from="QuitDialog" to="." method="_on_quit_confirmed"] +[connection signal="custom_action" from="QuitDialog" to="." method="_on_quit_dialog_custom_action"] diff --git a/game/src/Game/GameSession/GameSpeedPanel.gd b/game/src/Game/GameSession/GameSpeedPanel.gd new file mode 100644 index 0000000..80708b1 --- /dev/null +++ b/game/src/Game/GameSession/GameSpeedPanel.gd @@ -0,0 +1,37 @@ +extends PanelContainer + +#UI-74 UI-75 UI-76 UI-77 + +@export var _longform_date_button : Button +@export var _play_pause_display_button : Button +@export var _decrease_speed_button : Button +@export var _increase_speed_button : Button + +func _ready(): + 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() + + _longform_date_button.text = GameSingleton.get_longform_date() + + +func _on_decrease_speed_button_pressed(): + GameSingleton.decrease_speed() + _update_buttons() + +func _on_increase_speed_button_pressed(): + GameSingleton.increase_speed() + _update_buttons() + +func _on_play_pause_display_button_pressed(): + GameSingleton.toggle_paused() + _update_buttons() + +func _on_longform_date_label_pressed(): + GameSingleton.toggle_paused() + _update_buttons() diff --git a/game/src/Game/GameSession/GameSpeedPanel.tscn b/game/src/Game/GameSession/GameSpeedPanel.tscn new file mode 100644 index 0000000..8a37565 --- /dev/null +++ b/game/src/Game/GameSession/GameSpeedPanel.tscn @@ -0,0 +1,38 @@ +[gd_scene load_steps=2 format=3 uid="uid://dd8k3p7r3huwc"] + +[ext_resource type="Script" path="res://src/GameSession/GameSpeedPanel.gd" id="1_pfs8t"] + +[node name="GameSpeedPanel" type="PanelContainer" node_paths=PackedStringArray("_longform_date_button", "_play_pause_display_button", "_decrease_speed_button", "_increase_speed_button")] +script = ExtResource("1_pfs8t") +_longform_date_button = NodePath("ButtonList/LongformDateButton") +_play_pause_display_button = NodePath("ButtonList/PlayPauseDisplayButton") +_decrease_speed_button = NodePath("ButtonList/DecreaseSpeedButton") +_increase_speed_button = NodePath("ButtonList/IncreaseSpeedButton") + +[node name="ButtonList" type="HBoxContainer" parent="."] +layout_mode = 2 + +[node name="LongformDateButton" type="Button" parent="ButtonList"] +custom_minimum_size = Vector2(200, 0) +layout_mode = 2 +text = "LONGFORM DATE" + +[node name="PlayPauseDisplayButton" type="Button" parent="ButtonList"] +custom_minimum_size = Vector2(30, 0) +layout_mode = 2 +text = "⏸ " + +[node name="DecreaseSpeedButton" type="Button" parent="ButtonList"] +custom_minimum_size = Vector2(30, 0) +layout_mode = 2 +text = "-" + +[node name="IncreaseSpeedButton" type="Button" parent="ButtonList"] +custom_minimum_size = Vector2(30, 0) +layout_mode = 2 +text = "+" + +[connection signal="pressed" from="ButtonList/LongformDateButton" to="." method="_on_longform_date_label_pressed"] +[connection signal="pressed" from="ButtonList/PlayPauseDisplayButton" to="." method="_on_play_pause_display_button_pressed"] +[connection signal="pressed" from="ButtonList/DecreaseSpeedButton" to="." method="_on_decrease_speed_button_pressed"] +[connection signal="pressed" from="ButtonList/IncreaseSpeedButton" to="." method="_on_increase_speed_button_pressed"] diff --git a/game/src/Game/GameSession/MapControlPanel/MapControlPanel.gd b/game/src/Game/GameSession/MapControlPanel/MapControlPanel.gd new file mode 100644 index 0000000..0cef057 --- /dev/null +++ b/game/src/Game/GameSession/MapControlPanel/MapControlPanel.gd @@ -0,0 +1,57 @@ +extends PanelContainer + +signal game_session_menu_button_pressed +signal map_view_camera_changed(near_left : Vector2, far_left : Vector2, far_right : Vector2, near_right : Vector2) +signal minimap_clicked(pos_clicked : Vector2) +signal zoom_in_button_pressed +signal zoom_out_button_pressed + +@export var _mapmodes_grid : GridContainer + +var _mapmode_button_group : ButtonGroup + +# REQUIREMENTS: +# * UI-550, UI-552, UI-554, UI-561 +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 + button.mouse_filter = MOUSE_FILTER_PASS + _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 GameSingleton.get_mapmode_count(): + _add_mapmode_button(GameSingleton.get_mapmode_identifier(index)) + +# REQUIREMENTS: +# * UIFUN-10 +func _on_game_session_menu_button_pressed() -> void: + game_session_menu_button_pressed.emit() + +# REQUIREMENTS: +# * SS-76 +# * UIFUN-129, UIFUN-131, UIFUN-133 +func _mapmode_pressed(button : BaseButton) -> void: + GameSingleton.set_mapmode(button.tooltip_text) + +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) + +# REQUIREMENTS: +# * UIFUN-269 +func _on_zoom_in_button_pressed() -> void: + zoom_in_button_pressed.emit() + +# REQUIREMENTS: +# * UIFUN-270 +func _on_zoom_out_button_pressed() -> void: + zoom_out_button_pressed.emit() diff --git a/game/src/Game/GameSession/MapControlPanel/MapControlPanel.tscn b/game/src/Game/GameSession/MapControlPanel/MapControlPanel.tscn new file mode 100644 index 0000000..bd4a010 --- /dev/null +++ b/game/src/Game/GameSession/MapControlPanel/MapControlPanel.tscn @@ -0,0 +1,107 @@ +[gd_scene load_steps=7 format=3 uid="uid://g524p8lr574w"] + +[ext_resource type="Script" path="res://src/GameSession/MapControlPanel/MapControlPanel.gd" id="1_ign64"] +[ext_resource type="Shader" path="res://src/GameSession/MapControlPanel/Minimap.gdshader" id="2_rinsg"] +[ext_resource type="Script" path="res://src/GameSession/MapControlPanel/Minimap.gd" id="3_s4dml"] + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_bhuqb"] +shader = ExtResource("2_rinsg") +shader_parameter/province_shape_subdivisions = null +shader_parameter/selected_index = null + +[sub_resource type="InputEventAction" id="InputEventAction_5nck3"] +action = &"ui_cancel" + +[sub_resource type="Shortcut" id="Shortcut_fc1tk"] +events = [SubResource("InputEventAction_5nck3")] + +[node name="MapControlPanel" type="PanelContainer" node_paths=PackedStringArray("_mapmodes_grid")] +editor_description = "SS-103, UI-548" +mouse_filter = 1 +script = ExtResource("1_ign64") +_mapmodes_grid = NodePath("MapPanelMargin/MapPanelList/MapDisplayList/MapmodesGrid") + +[node name="MapPanelMargin" type="MarginContainer" parent="."] +layout_mode = 2 +theme_override_constants/margin_left = 5 +theme_override_constants/margin_top = 5 +theme_override_constants/margin_right = 5 +theme_override_constants/margin_bottom = 5 + +[node name="MapPanelList" type="HBoxContainer" parent="MapPanelMargin"] +layout_mode = 2 +theme_override_constants/separation = 6 +alignment = 1 + +[node name="MapDisplayList" type="VBoxContainer" parent="MapPanelMargin/MapPanelList"] +layout_mode = 2 +alignment = 1 + +[node name="MapmodesGrid" type="GridContainer" parent="MapPanelMargin/MapPanelList/MapDisplayList"] +editor_description = "UI-750" +layout_mode = 2 +columns = 11 + +[node name="Minimap" type="PanelContainer" parent="MapPanelMargin/MapPanelList/MapDisplayList"] +editor_description = "UI-549" +layout_mode = 2 +size_flags_horizontal = 4 +size_flags_vertical = 4 +mouse_filter = 1 + +[node name="MinimapTexture" type="ColorRect" parent="MapPanelMargin/MapPanelList/MapDisplayList/Minimap"] +editor_description = "UI-751, FS-338" +material = SubResource("ShaderMaterial_bhuqb") +layout_mode = 2 +color = Color(0.921569, 0.835294, 0.701961, 1) + +[node name="ViewportQuad" type="Control" parent="MapPanelMargin/MapPanelList/MapDisplayList/Minimap" node_paths=PackedStringArray("_minimap_texture")] +layout_mode = 2 +mouse_filter = 1 +script = ExtResource("3_s4dml") +_minimap_texture = NodePath("../MinimapTexture") + +[node name="AuxiliaryPanel" type="VBoxContainer" parent="MapPanelMargin/MapPanelList"] +editor_description = "UI-761" +layout_mode = 2 + +[node name="GameSessionMenuButton" type="Button" parent="MapPanelMargin/MapPanelList/AuxiliaryPanel"] +editor_description = "UI-9" +layout_mode = 2 +mouse_filter = 1 +shortcut = SubResource("Shortcut_fc1tk") +text = "ESC" + +[node name="LedgerButton" type="Button" parent="MapPanelMargin/MapPanelList/AuxiliaryPanel"] +editor_description = "UI-860" +layout_mode = 2 +mouse_filter = 1 +text = "L" + +[node name="FindButton" type="Button" parent="MapPanelMargin/MapPanelList/AuxiliaryPanel"] +editor_description = "UI-861" +layout_mode = 2 +mouse_filter = 1 +text = "F" + +[node name="ZoomButtonsContainer" type="HBoxContainer" parent="MapPanelMargin/MapPanelList/AuxiliaryPanel"] +layout_mode = 2 +alignment = 1 + +[node name="ZoomInButton" type="Button" parent="MapPanelMargin/MapPanelList/AuxiliaryPanel/ZoomButtonsContainer"] +editor_description = "UI-862" +layout_mode = 2 +mouse_filter = 1 +text = "+" + +[node name="ZoomOutButton" type="Button" parent="MapPanelMargin/MapPanelList/AuxiliaryPanel/ZoomButtonsContainer"] +editor_description = "UI-863" +layout_mode = 2 +mouse_filter = 1 +text = "-" + +[connection signal="map_view_camera_changed" from="." to="MapPanelMargin/MapPanelList/MapDisplayList/Minimap/ViewportQuad" method="_on_map_view_camera_changed"] +[connection signal="minimap_clicked" from="MapPanelMargin/MapPanelList/MapDisplayList/Minimap/ViewportQuad" to="." method="_on_minimap_clicked"] +[connection signal="pressed" from="MapPanelMargin/MapPanelList/AuxiliaryPanel/GameSessionMenuButton" to="." method="_on_game_session_menu_button_pressed"] +[connection signal="pressed" from="MapPanelMargin/MapPanelList/AuxiliaryPanel/ZoomButtonsContainer/ZoomInButton" to="." method="_on_zoom_in_button_pressed"] +[connection signal="pressed" from="MapPanelMargin/MapPanelList/AuxiliaryPanel/ZoomButtonsContainer/ZoomOutButton" to="." method="_on_zoom_out_button_pressed"] diff --git a/game/src/Game/GameSession/MapControlPanel/Minimap.gd b/game/src/Game/GameSession/MapControlPanel/Minimap.gd new file mode 100644 index 0000000..1f9b75e --- /dev/null +++ b/game/src/Game/GameSession/MapControlPanel/Minimap.gd @@ -0,0 +1,105 @@ +extends Control + +signal minimap_clicked(pos_clicked : Vector2) + +const _action_click : StringName = &"map_click" + +@export var _minimap_texture : Control +var _minimap_shader : ShaderMaterial + +var _viewport_points : PackedVector2Array + +func _ready(): + _minimap_texture.custom_minimum_size = Vector2(GameSingleton.get_aspect_ratio(), 1.0) * 150 + var minimap_material := _minimap_texture.get_material() + if Events.ShaderManager.set_up_shader(minimap_material, false) != OK: + push_error("Failed to set up minimap shader") + else: + _minimap_shader = minimap_material + GameSingleton.province_selected.connect(_on_province_selected) + +func _on_province_selected(index : int) -> void: + if _minimap_shader != null: + _minimap_shader.set_shader_parameter(Events.ShaderManager.param_selected_index, index) + +# REQUIREMENTS +# * SS-80 +# * UI-752 +func _draw() -> void: + if _viewport_points.size() > 1: + draw_multiline(_viewport_points, Color.WHITE, -1) + +# REQUIREMENTS +# * SS-81 +# * UIFUN-127 +func _unhandled_input(event : InputEvent): + if event is InputEventMouse and Input.is_action_pressed(_action_click): + var pos_clicked := get_local_mouse_position() / size - Vector2(0.5, 0.5) + if abs(pos_clicked.x) < 0.5 and abs(pos_clicked.y) < 0.5: + minimap_clicked.emit(pos_clicked) + +# Returns the point on the line going through p and q with the specific x coord +func _intersect_x(p : Vector2, q : Vector2, x : float) -> Vector2: + if p.x == q.x: + return Vector2(x, 0.5 * (p.y + q.y)) + var t := (x - q.x) / (p.x - q.x) + return q + t * (p - q) + +# Returns the point on the line going through p and q with the specific y coord +func _intersect_y(p : Vector2, q : Vector2, y : float) -> Vector2: + if p.y == q.y: + return Vector2(0.5 * (p.x + q.x), y) + var t := (y - q.y) / (p.y - q.y) + return q + t * (p - q) + +const _one_x := Vector2(1, 0) + +func _add_line_looped_over_x(left : Vector2, right : Vector2) -> void: + if left.x < 0: + if right.x < 0: + _viewport_points.push_back(left + _one_x) + _viewport_points.push_back(right + _one_x) + else: + var mid_point := _intersect_x(left, right, 0) + _viewport_points.push_back(mid_point) + _viewport_points.push_back(right) + mid_point.x = 1 + _viewport_points.push_back(left + _one_x) + _viewport_points.push_back(mid_point) + elif right.x > 1: + if left.x > 1: + _viewport_points.push_back(left - _one_x) + _viewport_points.push_back(right - _one_x) + else: + var mid_point := _intersect_x(left, right, 1) + _viewport_points.push_back(left) + _viewport_points.push_back(mid_point) + mid_point.x = 0 + _viewport_points.push_back(mid_point) + _viewport_points.push_back(right - _one_x) + else: + _viewport_points.push_back(left) + _viewport_points.push_back(right) + +# This can break if the viewport is rotated too far! +func _on_map_view_camera_changed(near_left : Vector2, far_left : Vector2, far_right : Vector2, near_right : Vector2) -> void: + # Bound far y coords + if far_left.y < 0: + far_left = _intersect_y(near_left, far_left, 0) + if far_right.y < 0: + far_right = _intersect_y(near_right, far_right, 0) + # Bound near y coords + if near_left.y > 1: + near_left = _intersect_y(near_left, far_left, 1) + if near_right.y > 1: + near_right = _intersect_y(near_right, far_right, 1) + + _viewport_points.clear() + _add_line_looped_over_x(near_left, near_right) + _add_line_looped_over_x(far_left, far_right) + _add_line_looped_over_x(far_left, near_left) + _add_line_looped_over_x(near_right, far_right) + + for i in _viewport_points.size(): + _viewport_points[i] *= size + queue_redraw() diff --git a/game/src/Game/GameSession/MapControlPanel/Minimap.gdshader b/game/src/Game/GameSession/MapControlPanel/Minimap.gdshader new file mode 100644 index 0000000..608abe2 --- /dev/null +++ b/game/src/Game/GameSession/MapControlPanel/Minimap.gdshader @@ -0,0 +1,18 @@ +shader_type canvas_item; + +#include "res://src/GameSession/ProvinceIndexSampler.gdshaderinc" + +// Index of the currently selected province +uniform uint selected_index; + +const vec3 land_colour = vec3(0.5); +const vec3 selected_colour = vec3(1.0, 1.0, 0.0); + +void fragment() { + uvec3 data = read_uvec3(UV); + uint index = uvec2_to_uint(data.rg); + float is_land = float(data.b != 0u); + float is_selected = float(index == selected_index); + COLOR.rgb = mix(COLOR.rgb, land_colour, is_land); + COLOR.rgb = mix(COLOR.rgb, selected_colour, is_selected); +} diff --git a/game/src/Game/GameSession/MapView.gd b/game/src/Game/GameSession/MapView.gd new file mode 100644 index 0000000..ced8bb7 --- /dev/null +++ b/game/src/Game/GameSession/MapView.gd @@ -0,0 +1,242 @@ +extends Node3D + +signal map_view_camera_changed(near_left : Vector2, far_left : Vector2, far_right : Vector2, near_right : Vector2) + +const _action_north : StringName = &"map_north" +const _action_east : StringName = &"map_east" +const _action_south : StringName = &"map_south" +const _action_west : StringName = &"map_west" +const _action_zoom_in : StringName = &"map_zoom_in" +const _action_zoom_out : StringName = &"map_zoom_out" +const _action_drag : StringName = &"map_drag" +const _action_click : StringName = &"map_click" + +@export var _camera : Camera3D + +@export var _cardinal_move_speed : float = 1.0 +@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 + +var _mouse_over_viewport : bool = true + +@export var _zoom_target_min : float = 0.05 +@export var _zoom_target_max : float = 5.0 +@export var _zoom_target_step : float = 0.1 +@export var _zoom_epsilon : float = _zoom_target_step * 0.1 +@export var _zoom_speed : float = 5.0 +@export var _zoom_target : float = 1.0: + get: return _zoom_target + set(v): _zoom_target = clamp(v, _zoom_target_min, _zoom_target_max) + +@export var _map_mesh_instance : MeshInstance3D +var _map_mesh : MapMesh +var _map_shader_material : ShaderMaterial +var _map_mesh_corner : Vector2 +var _map_mesh_dims : Vector2 + +var _mouse_pos_viewport : Vector2 = Vector2(0.5, 0.5) +var _mouse_pos_map : Vector2 = Vector2(0.5, 0.5) +var _viewport_dims : Vector2 = Vector2(1, 1) + +# ??? Strange Godot/GDExtension Bug ??? +# Upon first opening a clone of this repo with the Godot Editor, +# 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. +# This was an absolute pain to track down. --- hop311 +func _ready(): + if _camera == null: + push_error("MapView's _camera variable hasn't been set!") + return + _zoom_target = _camera.position.y + if _map_mesh_instance == null: + push_error("MapView's _map_mesh variable hasn't been set!") + return + + # Shader Material + var map_material := _map_mesh_instance.get_active_material(0) + if Events.ShaderManager.set_up_shader(map_material, true) != OK: + push_error("Failed to set up map shader") + return + _map_shader_material = map_material + + if not _map_mesh_instance.mesh is MapMesh: + push_error("Invalid map mesh class: ", _map_mesh_instance.mesh.get_class(), "(expected MapMesh)") + return + _map_mesh = _map_mesh_instance.mesh + + # Set map mesh size and get bounds + const pixels_per_terrain_tile : float = 32.0 + _map_shader_material.set_shader_parameter(Events.ShaderManager.param_terrain_tile_factor, + float(GameSingleton.get_height()) / pixels_per_terrain_tile) + var map_mesh_aabb := _map_mesh.get_core_aabb() * _map_mesh_instance.transform + _map_mesh_corner = Vector2( + min(map_mesh_aabb.position.x, map_mesh_aabb.end.x), + min(map_mesh_aabb.position.z, map_mesh_aabb.end.z) + ) + _map_mesh_dims = abs(Vector2( + map_mesh_aabb.position.x - map_mesh_aabb.end.x, + map_mesh_aabb.position.z - map_mesh_aabb.end.z + )) + + GameSingleton.province_selected.connect(_on_province_selected) + +func _notification(what : int): + match what: + NOTIFICATION_WM_MOUSE_ENTER: # Mouse inside window + _on_mouse_entered_viewport() + NOTIFICATION_WM_MOUSE_EXIT: # Mouse out of window + _on_mouse_exited_viewport() + +func _world_to_map_coords(pos : Vector3) -> Vector2: + return (Vector2(pos.x, pos.z) - _map_mesh_corner) / _map_mesh_dims + +func _viewport_to_map_coords(pos_viewport : Vector2) -> Vector2: + var ray_origin := _camera.project_ray_origin(pos_viewport) + var ray_normal := _camera.project_ray_normal(pos_viewport) + # Plane with normal (0,1,0) facing upwards, at a distance 0 from the origin + var intersection = Plane(0, 1, 0, 0).intersects_ray(ray_origin, ray_normal) + if typeof(intersection) == TYPE_VECTOR3: + return _world_to_map_coords(intersection as Vector3) + else: + # Normals parallel to the xz-plane could cause null intersections, + # but the camera's orientation should prevent such normals + push_error("Invalid intersection: ", intersection) + return Vector2(0.5, 0.5) + +func zoom_in() -> void: + _zoom_target -= _zoom_target_step + +func zoom_out() -> void: + _zoom_target += _zoom_target_step + +func _on_province_selected(index : int) -> void: + _map_shader_material.set_shader_parameter(Events.ShaderManager.param_selected_index, index) + +# REQUIREMENTS +# * SS-31 +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): + GameSingleton.set_selected_province(GameSingleton.get_province_index_from_uv_coords(_mouse_pos_map)) + else: + print("Clicked outside the map!") + elif event.is_action_pressed(_action_drag): + if _drag_active: + push_warning("Drag being activated while already active!") + _drag_active = true + _drag_anchor = _mouse_pos_map + elif event.is_action_released(_action_drag): + if not _drag_active: + push_warning("Drag being deactivated while already not active!") + _drag_active = false + elif event.is_action_pressed(_action_zoom_in, true): + zoom_in() + elif event.is_action_pressed(_action_zoom_out, true): + zoom_out() + +func _physics_process(delta : float): + _mouse_pos_viewport = get_viewport().get_mouse_position() + _viewport_dims = Vector2(Resolution.get_current_resolution()) + # Process movement + _movement_process(delta) + # Keep within map bounds + _clamp_over_map() + # Process zooming + _zoom_process(delta) + # Orient based on height + _update_orientation() + # Update viewport on minimap + _update_minimap_viewport() + # Calculate where the mouse lies on the map + _update_mouse_map_position() + +# REQUIREMENTS +# * UIFUN-124 +func _movement_process(delta : float) -> void: + var direction : Vector2 + if _drag_active: + direction = (_drag_anchor - _mouse_pos_map) * _map_mesh_dims + else: + direction = _edge_scrolling_vector() + _cardinal_movement_vector() + # Scale movement speed with height + direction *= _camera.position.y * delta + _camera.position += Vector3(direction.x, 0, direction.y) + +# REQUIREMENTS +# * UIFUN-125 +func _edge_scrolling_vector() -> Vector2: + if not _mouse_over_viewport: + return Vector2() + var mouse_vector := _mouse_pos_viewport * GuiScale.get_current_guiscale() / _viewport_dims - Vector2(0.5, 0.5) + if abs(mouse_vector.x) < 0.5 - _edge_move_threshold and abs(mouse_vector.y) < 0.5 - _edge_move_threshold: + mouse_vector *= 0 + return mouse_vector * _edge_move_speed + +# REQUIREMENTS +# * SS-75 +func _cardinal_movement_vector() -> Vector2: + var move := Vector2( + float(Input.is_action_pressed(_action_east)) - float(Input.is_action_pressed(_action_west)), + float(Input.is_action_pressed(_action_south)) - float(Input.is_action_pressed(_action_north)) + ) + return move * _cardinal_move_speed + +func _clamp_over_map() -> void: + _camera.position.x = _map_mesh_corner.x + fposmod(_camera.position.x - _map_mesh_corner.x, _map_mesh_dims.x) + _camera.position.z = clamp(_camera.position.z, _map_mesh_corner.y, _map_mesh_corner.y + _map_mesh_dims.y) + +# REQUIREMENTS +# * SS-74 +# * UIFUN-123 +func _zoom_process(delta : float) -> void: + var height := _camera.position.y + var zoom := _zoom_target - height + height += zoom * _zoom_speed * delta + var new_zoom := _zoom_target - height + # Set to target if height is within _zoom_epsilon of it or has overshot past it + if abs(new_zoom) < _zoom_epsilon or sign(zoom) != sign(new_zoom): + height = _zoom_target + _camera.position.y = height + +func _update_orientation() -> void: + var dir := Vector3(0, -1, -exp(-_camera.position.y - 1)) + _camera.look_at(_camera.position + dir) + +func _update_minimap_viewport() -> void: + var near_left := _viewport_to_map_coords(Vector2(0, _viewport_dims.y)) + var far_left := _viewport_to_map_coords(Vector2(0, 0)) + var far_right := _viewport_to_map_coords(Vector2(_viewport_dims.x, 0)) + var near_right := _viewport_to_map_coords(_viewport_dims) + map_view_camera_changed.emit(near_left, far_left, far_right, near_right) + +func _update_mouse_map_position() -> void: + _mouse_pos_map = _viewport_to_map_coords(_mouse_pos_viewport) + var hover_index := GameSingleton.get_province_index_from_uv_coords(_mouse_pos_map) + if _mouse_over_viewport: + _map_shader_material.set_shader_parameter(Events.ShaderManager.param_hover_index, hover_index) + +func _on_mouse_entered_viewport(): + _mouse_over_viewport = true + +func _on_mouse_exited_viewport(): + _mouse_over_viewport = false + _map_shader_material.set_shader_parameter(Events.ShaderManager.param_hover_index, 0) + +func _on_minimap_clicked(pos_clicked : Vector2): + pos_clicked *= _map_mesh_dims + _camera.position.x = pos_clicked.x + _camera.position.z = pos_clicked.y + _clamp_over_map() + +func enable_processing() -> void: + set_process_unhandled_input(true) + set_physics_process(true) + +func disable_processing() -> void: + set_process_unhandled_input(false) + set_physics_process(false) diff --git a/game/src/Game/GameSession/MapView.tscn b/game/src/Game/GameSession/MapView.tscn new file mode 100644 index 0000000..fa6ffcd --- /dev/null +++ b/game/src/Game/GameSession/MapView.tscn @@ -0,0 +1,30 @@ +[gd_scene load_steps=5 format=3 uid="uid://dkehmdnuxih2r"] + +[ext_resource type="Script" path="res://src/GameSession/MapView.gd" id="1_exccw"] +[ext_resource type="Shader" path="res://src/GameSession/TerrainMap.gdshader" id="1_upocn"] + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_tayeg"] +render_priority = 0 +shader = ExtResource("1_upocn") +shader_parameter/province_shape_subdivisions = null +shader_parameter/hover_index = null +shader_parameter/selected_index = null +shader_parameter/terrain_tile_factor = null + +[sub_resource type="MapMesh" id="MapMesh_3gtsd"] + +[node name="MapView" type="Node3D" node_paths=PackedStringArray("_camera", "_map_mesh_instance")] +editor_description = "SS-73" +script = ExtResource("1_exccw") +_camera = NodePath("MapCamera") +_map_mesh_instance = NodePath("MapMeshInstance") + +[node name="MapCamera" type="Camera3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 0.707107, 0.707107, 0, -0.707107, 0.707107, 0.25, 1.5, -2.75) +near = 0.01 + +[node name="MapMeshInstance" type="MeshInstance3D" parent="."] +editor_description = "FS-343" +transform = Transform3D(10, 0, 0, 0, 10, 0, 0, 0, 10, 0, 0, 0) +material_override = SubResource("ShaderMaterial_tayeg") +mesh = SubResource("MapMesh_3gtsd") diff --git a/game/src/Game/GameSession/ProvinceIndexSampler.gdshaderinc b/game/src/Game/GameSession/ProvinceIndexSampler.gdshaderinc new file mode 100644 index 0000000..65f73d8 --- /dev/null +++ b/game/src/Game/GameSession/ProvinceIndexSampler.gdshaderinc @@ -0,0 +1,18 @@ + +// Province shape texture +uniform sampler2DArray province_shape_tex : repeat_enable, filter_nearest; +// Province shape subdivisions +uniform vec2 province_shape_subdivisions; + +uvec3 vec3_to_uvec3(vec3 v) { + return uvec3(v * 255.0); +} +uvec3 read_uvec3(vec2 uv) { + uv *= province_shape_subdivisions; + vec2 subdivision_coords = mod(floor(uv), province_shape_subdivisions); + float idx = subdivision_coords.x + subdivision_coords.y * province_shape_subdivisions.x; + return vec3_to_uvec3(texture(province_shape_tex, vec3(uv, idx)).rgb); +} +uint uvec2_to_uint(uvec2 v) { + return (v.y << 8u) | v.x; +} diff --git a/game/src/Game/GameSession/ProvinceOverviewPanel/ProvinceOverviewPanel.gd b/game/src/Game/GameSession/ProvinceOverviewPanel/ProvinceOverviewPanel.gd new file mode 100644 index 0000000..67060bf --- /dev/null +++ b/game/src/Game/GameSession/ProvinceOverviewPanel/ProvinceOverviewPanel.gd @@ -0,0 +1,122 @@ +extends PanelContainer + +@export var _province_name_label : Label +@export var _region_name_label : Label +@export var _life_rating_bar : ProgressBar +@export var _rgo_icon_texture_rect : TextureRect +@export var _rgo_name_label : Label +@export var _buildings_container : Container + +const _missing_suffix : String = "_MISSING" + +var _selected_index : int: + get: return _selected_index + set(v): + _selected_index = v + update_info() +var _province_info : Dictionary + +func _ready(): + GameSingleton.province_selected.connect(_on_province_selected) + 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); + +# Each building row contains: +# level - Level Label +# name - Name Label +# button - Expansion Button +# progress_bar - Expansion ProgressBar +var _building_rows : Array[Dictionary] + +# REQUIREMENTS: +# * UI-183, UI-185, UI-186, UI-765, UI-187, UI-188, UI-189 +# * UI-191, UI-193, UI-194, UI-766, UI-195, UI-196, UI-197 +# * UI-199, UI-201, UI-202, UI-767, UI-203, UI-204, UI-205 +func _add_building_row() -> void: + var row : Dictionary + + row.level = Label.new() + row.level.text = "X" + _buildings_container.add_child(row.level) + + row.name = Label.new() + row.name.text = GameSingleton.get_building_info_building_key() + _missing_suffix + _buildings_container.add_child(row.name) + + row.button = Button.new() + row.button.text = "EXPAND_PROVINCE_BUILDING" + row.button.size_flags_horizontal = Control.SIZE_EXPAND_FILL + row.button.mouse_filter = Control.MOUSE_FILTER_PASS + row.button.pressed.connect(func(): _expand_building(row.name.text)) + _buildings_container.add_child(row.button) + + row.progress_bar = ProgressBar.new() + row.progress_bar.max_value = 1 + row.progress_bar.size_flags_horizontal = Control.SIZE_EXPAND_FILL + row.progress_bar.mouse_filter = Control.MOUSE_FILTER_PASS + _buildings_container.add_child(row.progress_bar) + + _building_rows.append(row) + _set_building_row(_building_rows.size() - 1, {}) + +func _set_building_row(index : int, building : Dictionary) -> void: + if index < 0 or index > _building_rows.size(): + push_error("Invalid building row index: ", index, " (max ", _building_rows.size(), ")") + return + if index == _building_rows.size(): _add_building_row() + var row := _building_rows[index] + if building.is_empty(): + row.level.visible = false + row.name.visible = false + row.progress_bar.visible = false + row.button.visible = false + return + row.level.text = str(building.get(GameSingleton.get_building_info_level_key(), 0)) + row.level.visible = true + row.name.text = building.get(GameSingleton.get_building_info_building_key(), + GameSingleton.get_building_info_building_key() + _missing_suffix) + row.name.visible = true + + var expansion_state : int = building.get(GameSingleton.get_building_info_expansion_state_key(), + CANNOT_EXPAND) + var show_progress_bar := expansion_state == PREPARING or expansion_state == EXPANDING + row.progress_bar.value = building.get(GameSingleton.get_building_info_expansion_progress_key(), 0) + row.progress_bar.visible = show_progress_bar + row.button.disabled = expansion_state != CAN_EXPAND + row.button.visible = not show_progress_bar + +func update_info() -> void: + _province_info = GameSingleton.get_province_info_from_index(_selected_index) + if _province_info: + _province_name_label.text = _province_info.get(GameSingleton.get_province_info_province_key(), + GameSingleton.get_province_info_province_key() + _missing_suffix) + _region_name_label.text = _province_info.get(GameSingleton.get_province_info_region_key(), + GameSingleton.get_province_info_region_key() + _missing_suffix) + + _life_rating_bar.value = _province_info.get(GameSingleton.get_province_info_life_rating_key(), 0) + _life_rating_bar.tooltip_text = tr("LIFE_RATING_TOOLTIP").format({ "life_rating": _life_rating_bar.value }) + + _rgo_name_label.text = _province_info.get(GameSingleton.get_province_info_rgo_key(), + GameSingleton.get_province_info_rgo_key() + _missing_suffix) + _rgo_icon_texture_rect.texture = GameSingleton.get_good_icon_texture(_rgo_name_label.text) + + var buildings : Array = _province_info.get(GameSingleton.get_province_info_buildings_key(), []) + for i in max(buildings.size(), _building_rows.size()): + _set_building_row(i, buildings[i] if i < buildings.size() else {}) + + show() + else: + hide() + mouse_exited.emit() + +func _on_province_selected(index : int) -> void: + _selected_index = index + +func _on_close_button_pressed() -> void: + GameSingleton.set_selected_province(0) diff --git a/game/src/Game/GameSession/ProvinceOverviewPanel/ProvinceOverviewPanel.tscn b/game/src/Game/GameSession/ProvinceOverviewPanel/ProvinceOverviewPanel.tscn new file mode 100644 index 0000000..a233db0 --- /dev/null +++ b/game/src/Game/GameSession/ProvinceOverviewPanel/ProvinceOverviewPanel.tscn @@ -0,0 +1,86 @@ +[gd_scene load_steps=2 format=3 uid="uid://byq323jbel48u"] + +[ext_resource type="Script" path="res://src/GameSession/ProvinceOverviewPanel/ProvinceOverviewPanel.gd" id="1_3n8k5"] + +[node name="ProvinceOverviewPanel" type="PanelContainer" node_paths=PackedStringArray("_province_name_label", "_region_name_label", "_life_rating_bar", "_rgo_icon_texture_rect", "_rgo_name_label", "_buildings_container")] +editor_description = "UI-56" +anchors_preset = 2 +anchor_top = 1.0 +anchor_bottom = 1.0 +offset_top = -300.0 +offset_right = 200.0 +grow_vertical = 0 +mouse_filter = 1 +script = ExtResource("1_3n8k5") +_province_name_label = NodePath("PanelList/TopBarList/NameList/ProvinceName") +_region_name_label = NodePath("PanelList/TopBarList/NameList/RegionName") +_life_rating_bar = NodePath("PanelList/TopBarList/NameList/LifeRatingBar") +_rgo_icon_texture_rect = NodePath("PanelList/InteractList/RGOInfo/RGOIcon") +_rgo_name_label = NodePath("PanelList/InteractList/RGOInfo/RGOName") +_buildings_container = NodePath("PanelList/InteractList/BuildingsContainer") + +[node name="PanelList" type="VBoxContainer" parent="."] +layout_mode = 2 + +[node name="TopBarList" type="HBoxContainer" parent="PanelList"] +layout_mode = 2 + +[node name="NameList" type="VBoxContainer" parent="PanelList/TopBarList"] +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_vertical = 0 + +[node name="ProvinceName" type="Label" parent="PanelList/TopBarList/NameList"] +editor_description = "UI-57" +layout_mode = 2 +text = "province_MISSING" +vertical_alignment = 1 + +[node name="RegionName" type="Label" parent="PanelList/TopBarList/NameList"] +editor_description = "UI-58" +layout_mode = 2 +text = "region_MISSING" +vertical_alignment = 1 + +[node name="LifeRatingBar" type="ProgressBar" parent="PanelList/TopBarList/NameList"] +editor_description = "UI-62" +layout_mode = 2 +mouse_filter = 1 + +[node name="CloseButton" type="Button" parent="PanelList/TopBarList"] +custom_minimum_size = Vector2(30, 30) +layout_mode = 2 +size_flags_vertical = 0 +mouse_filter = 1 +text = "X" + +[node name="InteractList" type="VBoxContainer" parent="PanelList"] +layout_mode = 2 +size_flags_vertical = 3 + +[node name="HSeparator" type="HSeparator" parent="PanelList/InteractList"] +layout_mode = 2 +mouse_filter = 1 + +[node name="RGOInfo" type="HBoxContainer" parent="PanelList/InteractList"] +editor_description = "UI-112" +layout_mode = 2 + +[node name="RGOIcon" type="TextureRect" parent="PanelList/InteractList/RGOInfo"] +editor_description = "UI-100" +layout_mode = 2 + +[node name="RGOName" type="Label" parent="PanelList/InteractList/RGOInfo"] +layout_mode = 2 +text = "rgo_MISSING" +vertical_alignment = 1 + +[node name="HSeparator2" type="HSeparator" parent="PanelList/InteractList"] +layout_mode = 2 +mouse_filter = 1 + +[node name="BuildingsContainer" type="GridContainer" parent="PanelList/InteractList"] +layout_mode = 2 +columns = 3 + +[connection signal="pressed" from="PanelList/TopBarList/CloseButton" to="." method="_on_close_button_pressed"] diff --git a/game/src/Game/GameSession/TerrainMap.gdshader b/game/src/Game/GameSession/TerrainMap.gdshader new file mode 100644 index 0000000..88e7019 --- /dev/null +++ b/game/src/Game/GameSession/TerrainMap.gdshader @@ -0,0 +1,50 @@ +shader_type spatial; + +render_mode unshaded; + +#include "res://src/GameSession/ProvinceIndexSampler.gdshaderinc" + +// Province colour texture +uniform sampler2D province_colour_tex: source_color, repeat_enable, filter_nearest; +// Index of the mouse over the map mesh +uniform uint hover_index; +// Index of the currently selected province +uniform uint selected_index; +// Cosmetic terrain textures +uniform sampler2DArray terrain_tex: source_color, repeat_enable, filter_linear; +// The number of times the terrain textures should tile vertically +uniform float terrain_tile_factor; + +const vec3 highlight_colour = vec3(1.0); + +vec3 get_terrain_colour(vec2 uv, vec2 corner, vec2 half_pixel_size, vec2 terrain_uv) { + uvec3 province_data = read_uvec3(fma(corner, half_pixel_size, uv)); + vec4 province_colour = texelFetch(province_colour_tex, ivec2(province_data.rg), 0); + vec3 terrain_colour = texture(terrain_tex, vec3(terrain_uv, float(province_data.b))).rgb; + vec3 mixed_colour = mix(terrain_colour, province_colour.rgb, province_colour.a); + uint index = uvec2_to_uint(province_data.rg); + float mix_val = 0.1 * (float(index == hover_index) + float(index == selected_index)); + return mix(mixed_colour, highlight_colour, mix_val); +} + +vec3 mix_terrain_colour(vec2 uv) { + vec2 map_size = vec2(textureSize(province_shape_tex, 0).xy) * province_shape_subdivisions; + vec2 pixel_offset = fract(fma(uv, map_size, vec2(0.5))); + vec2 half_pixel_size = 0.49 / map_size; + + vec2 terrain_uv = uv; + terrain_uv.x *= map_size.x / map_size.y; + terrain_uv *= terrain_tile_factor; + + return mix( + mix(get_terrain_colour(uv, vec2(-1, -1), half_pixel_size, terrain_uv), + get_terrain_colour(uv, vec2(+1, -1), half_pixel_size, terrain_uv), pixel_offset.x), + mix(get_terrain_colour(uv, vec2(-1, +1), half_pixel_size, terrain_uv), + get_terrain_colour(uv, vec2(+1, +1), half_pixel_size, terrain_uv), pixel_offset.x), + pixel_offset.y); +} + +void fragment() { + vec3 terrain_colour = mix_terrain_colour(UV); + ALBEDO = terrain_colour; +} diff --git a/game/src/Game/GameStart.tscn b/game/src/Game/GameStart.tscn new file mode 100644 index 0000000..2046bb5 --- /dev/null +++ b/game/src/Game/GameStart.tscn @@ -0,0 +1,52 @@ +[gd_scene load_steps=6 format=3 uid="uid://1udsn4mggep2"] + +[ext_resource type="PackedScene" uid="uid://o4u142w4qkln" path="res://src/GameMenu.tscn" id="1_wlojq"] +[ext_resource type="Script" path="res://src/SplashContainer.gd" id="2_xmcgv"] +[ext_resource type="Texture2D" uid="uid://deef5hufq0j61" path="res://splash_assets/splash_end.png" id="3_qfv12"] +[ext_resource type="Texture2D" uid="uid://cgdnixsyh7bja" path="res://splash_assets/splash_image.png" id="4_5b6yq"] +[ext_resource type="VideoStream" path="res://splash_assets/splash_startup.ogv" id="5_8euyy"] + +[node name="GameStartup" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="GameMenu" parent="." instance=ExtResource("1_wlojq")] +visible = false +layout_mode = 1 + +[node name="SplashContainer" type="AspectRatioContainer" parent="." node_paths=PackedStringArray("_splash_finish", "_splash_image", "_splash_video")] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +ratio = 1.7778 +stretch_mode = 3 +script = ExtResource("2_xmcgv") +_splash_finish = NodePath("SplashFinish") +_splash_image = NodePath("SplashImage") +_splash_video = NodePath("SplashVideo") + +[node name="SplashFinish" type="TextureRect" parent="SplashContainer"] +layout_mode = 2 +texture = ExtResource("3_qfv12") +expand_mode = 1 + +[node name="SplashImage" type="TextureRect" parent="SplashContainer"] +layout_mode = 2 +texture = ExtResource("4_5b6yq") +expand_mode = 1 + +[node name="SplashVideo" type="VideoStreamPlayer" parent="SplashContainer"] +layout_mode = 2 +stream = ExtResource("5_8euyy") +autoplay = true +expand = true + +[connection signal="splash_end" from="SplashContainer" to="GameMenu" method="_on_splash_container_splash_end"] +[connection signal="finished" from="SplashContainer/SplashVideo" to="SplashContainer" method="_on_splash_startup_finished"] diff --git a/game/src/Game/LocaleButton.gd b/game/src/Game/LocaleButton.gd new file mode 100644 index 0000000..2b717a4 --- /dev/null +++ b/game/src/Game/LocaleButton.gd @@ -0,0 +1,80 @@ +extends OptionButton + +const section_name : String = "localisation" +const setting_name : String = "locale" + +var _default_locale_index : int + +func _ready(): + var locales_country_rename : Dictionary = ProjectSettings.get_setting("internationalization/locale/country_short_name", {}) + + var locales_list = TranslationServer.get_loaded_locales() + var default_locale := Events.Localisation.get_default_locale() + if default_locale not in locales_list: + locales_list.push_back(default_locale) + + for locale in locales_list: + # locale_name consists of a compulsory language name and optional script + # and country names, in the format: "[ (script)][, country]" + var locale_name := TranslationServer.get_locale_name(locale) + var comma_idx := locale_name.find(", ") + if comma_idx != -1: + var locale_country_name := locale_name.substr(comma_idx + 2) + locale_country_name = locales_country_rename.get(locale_country_name, "") + if not locale_country_name.is_empty(): + locale_name = locale_name.left(comma_idx + 2) + locale_country_name + + add_item(locale_name) + set_item_metadata(item_count - 1, locale) + + if locale == default_locale: + _default_locale_index = item_count - 1 + + Events.Options.load_settings.connect(load_setting) + Events.Options.save_settings.connect(save_setting) + +func _notification(what : int): + match what: + NOTIFICATION_TRANSLATION_CHANGED: + _select_locale_by_string(TranslationServer.get_locale()) + +func _valid_index(index : int) -> bool: + return 0 <= index and index < item_count + +func load_setting(file : ConfigFile) -> void: + if file == null: return + var load_value = file.get_value(section_name, setting_name, Events.Localisation.get_default_locale()) + match typeof(load_value): + TYPE_STRING, TYPE_STRING_NAME: + if _select_locale_by_string(load_value as String): + item_selected.emit(selected) + return + push_error("Setting value '%s' invalid for setting [%s] %s" % [load_value, section_name, setting_name]) + reset_setting() + +func _select_locale_by_string(locale : String) -> bool: + for idx in item_count: + if get_item_metadata(idx) == locale: + selected = idx + return true + selected = _default_locale_index + return false + +# REQUIREMENTS: +# * UIFUN-74 +func save_setting(file : ConfigFile) -> void: + if file == null: return + file.set_value(section_name, setting_name, get_item_metadata(selected)) + +func reset_setting() -> void: + _select_locale_by_string(TranslationServer.get_locale()) + +# REQUIREMENTS: +# * SS-58 +func _on_item_selected(index : int) -> void: + if _valid_index(index): + TranslationServer.set_locale(get_item_metadata(index)) + Events.Options.save_settings_to_file.call_deferred() + else: + push_error("Invalid LocaleButton index: %d" % index) + reset_setting() diff --git a/game/src/Game/LocaleButton.tscn b/game/src/Game/LocaleButton.tscn new file mode 100644 index 0000000..55f1c29 --- /dev/null +++ b/game/src/Game/LocaleButton.tscn @@ -0,0 +1,12 @@ +[gd_scene load_steps=2 format=3 uid="uid://b7oncobnacxmt"] + +[ext_resource type="Script" path="res://src/LocaleButton.gd" id="1_ganev"] + +[node name="LocaleButton" type="OptionButton"] +custom_minimum_size = Vector2(150, 0) +alignment = 2 +text_overrun_behavior = 2 +fit_to_longest_item = false +script = ExtResource("1_ganev") + +[connection signal="item_selected" from="." to="." method="_on_item_selected"] diff --git a/game/src/Game/Menu/CreditsMenu/CreditsMenu.gd b/game/src/Game/Menu/CreditsMenu/CreditsMenu.gd new file mode 100644 index 0000000..0db4d7d --- /dev/null +++ b/game/src/Game/Menu/CreditsMenu/CreditsMenu.gd @@ -0,0 +1,200 @@ +extends Control + +signal back_button_pressed + +############### +# Credits CSV format +# The project title row is the only requirement within the csv file, however +# it can be on any row, so long as it exists. +# ---------------------- +# title,project-title +# role-name,person-name +# role-name,person-name +# role-name,person-name +# ... +############### + +@export_file("*.csv") +var core_credits_path : String + +@export +var godot_engine_scene : PackedScene + +@export_group("Label Variants", "label_variants_") +@export +var label_variants_project : StringName + +@export +var label_variants_role : StringName + +@export +var label_variants_person : StringName + +@export +var credits_list: VBoxContainer + +const title_key : String = "TITLE" + +# REQUIREMENTS: +# * 1.5 Credits Menu +# * SS-17 + +# REQUIREMENTS +# * FS-4 +func _load_credit_file(path : String) -> Dictionary: + var roles := {} + var core_credits = FileAccess.open(path, FileAccess.READ) + if core_credits == null: + push_error("Failed to open credits file %s (error code %d)" % [path, FileAccess.get_open_error()]) + return roles + + while not core_credits.eof_reached(): + var line := core_credits.get_csv_line() + var role := line[0].strip_edges().to_upper() + + # If the line does not have an identifiable role or is empty then skip it + if role.is_empty() or line.size() < 2: + if not (role.is_empty() and line.size() < 2): + push_warning("Incorrectly formatted credit line %s in %s" % [line, path]) + continue + + var person := line[1].strip_edges() + + if person.is_empty(): + push_warning("Incorrectly formatted credit line %s in %s" % [line, path]) + continue + if line.size() > 2: + push_warning("Extra entries ignored in credit line %s in %s" % [line, path]) + + if role not in roles: + roles[role] = [person] + else: + if person in roles[role]: + push_warning("Duplicate person %s for role %s in %s" % [person, role, path]) + else: + roles[role].push_back(person) + if title_key in roles: + if roles[title_key].size() > 1: + push_warning("More than one %s: %s in %s" % [title_key, roles[title_key], path]) + roles[title_key] = [roles[title_key][0]] + else: + push_warning("Credits file %s missing %s" % [path, title_key]) + for role_list in roles.values(): + role_list.sort_custom(func(a : String, b : String) -> bool: return a.naturalnocasecmp_to(b) < 0) + return roles + +func _add_label(node : Node, text : String, type_variation : StringName) -> void: + var label := Label.new() + label.name = 'Label' + text + label.text = text + label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER + label.theme_type_variation = type_variation + node.add_child(label) + +# REQUIREMENTS: +# * UI-34, UI-35 +func _add_project_credits(project : Dictionary) -> void: + var project_credits_list = VBoxContainer.new() + project_credits_list.name = 'Credits' + if title_key in project: + var title : String = project[title_key][0] + project_credits_list.name += title + _add_label(project_credits_list, title, label_variants_project) + project_credits_list.add_child(HSeparator.new()) + + for role in project: + if role == title_key: + continue + + var role_parent = VBoxContainer.new() + + for person in project[role]: + _add_label(role_parent, person, label_variants_person) + + _add_label(project_credits_list, role, label_variants_role) + project_credits_list.add_child(role_parent) + project_credits_list.add_child(HSeparator.new()) + + credits_list.add_child(project_credits_list) + +func _add_godot_credits() -> void: + var godot_credits_list = VBoxContainer.new() + godot_credits_list.name = 'CreditsGodot' + var godot_engine = godot_engine_scene.instantiate() + godot_credits_list.add_child(godot_engine) + godot_credits_list.add_child(HSeparator.new()) + + var author_dict := Engine.get_author_info() + _add_label(godot_credits_list, "Contributors", label_variants_role) + + for role in author_dict: + var role_parent = VBoxContainer.new() + + for person in author_dict[role]: + _add_label(role_parent, person, label_variants_person) + + _add_label(godot_credits_list, role.replace("_", " ").capitalize(), label_variants_role) + godot_credits_list.add_child(role_parent) + godot_credits_list.add_child(HSeparator.new()) + + var donor_dict := Engine.get_donor_info() + _add_label(godot_credits_list, "Donors", label_variants_role) + + for role in donor_dict: + if donor_dict[role].size() == 0 or donor_dict[role][0].begins_with("None"): continue + var role_parent = VBoxContainer.new() + + for person in donor_dict[role]: + _add_label(role_parent, person, label_variants_person) + + _add_label(godot_credits_list, role.replace("_", " ").capitalize(), label_variants_role) + godot_credits_list.add_child(role_parent) + godot_credits_list.add_child(HSeparator.new()) + + credits_list.add_child(godot_credits_list) + +func _add_link_button(node : Node, text : String, url: String, type_variation : StringName) -> void: + var button := LinkButton.new() + button.name = 'LinkButton' + text + button.text = text + button.uri = url + button.size_flags_horizontal = SIZE_SHRINK_CENTER + button.theme_type_variation = type_variation + node.add_child(button) + +func _add_licenses() -> void: + var license_list = VBoxContainer.new() + license_list.name = 'Licenses' + _add_label(license_list, "Third-Party Licenses", label_variants_project) + license_list.add_child(HSeparator.new()) + + var license_info := { + "OpenVic": ["GPLv3", "https://github.com/OpenVicProject/OpenVic/blob/main/LICENSE.md"], + "Godot": ["MIT", "https://github.com/godotengine/godot/blob/master/LICENSE.txt"], + "FreeType": ["FreeType License", "https://gitlab.freedesktop.org/freetype/freetype/-/blob/master/docs/FTL.TXT"], + "ENet": ["MIT", "http://enet.bespin.org/License.html"], + "mbed TLS": ["APLv2", "https://github.com/Mbed-TLS/mbedtls/blob/development/LICENSE"] + } + # Add additional licenses required for attribution here + # These licenses should also either be displayed or exported alongside this project + + for project in license_info: + _add_label(license_list, project, label_variants_role) + _add_link_button(license_list, license_info[project][0], license_info[project][1], label_variants_person) + license_list.add_child(HSeparator.new()) + + credits_list.add_child(license_list) + + +# REQUIREMENTS: +# * SS-17 +func _ready(): + _add_project_credits(_load_credit_file(core_credits_path)) + _add_godot_credits() + _add_licenses() + +# REQUIREMENTS: +# * UI-38 +# * UIFUN-37 +func _on_back_button_pressed() -> void: + back_button_pressed.emit() diff --git a/game/src/Game/Menu/CreditsMenu/CreditsMenu.tscn b/game/src/Game/Menu/CreditsMenu/CreditsMenu.tscn new file mode 100644 index 0000000..2d10d2e --- /dev/null +++ b/game/src/Game/Menu/CreditsMenu/CreditsMenu.tscn @@ -0,0 +1,50 @@ +[gd_scene load_steps=4 format=3 uid="uid://c8knthxkwj1uj"] + +[ext_resource type="Theme" uid="uid://stfxt4hpsify" path="res://theme/credits_menu.tres" id="1_7y4l8"] +[ext_resource type="Script" path="res://src/CreditsMenu/CreditsMenu.gd" id="1_csd7i"] +[ext_resource type="PackedScene" uid="uid://ddjbee5gj6bkv" path="res://src/CreditsMenu/GodotEngineButton.tscn" id="3_fl02a"] + +[node name="CreditsMenu" type="Control" node_paths=PackedStringArray("credits_list")] +editor_description = "UI-34" +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme = ExtResource("1_7y4l8") +script = ExtResource("1_csd7i") +core_credits_path = "res://common/credits.csv" +godot_engine_scene = ExtResource("3_fl02a") +label_variants_project = &"ProjectLabel" +label_variants_role = &"RoleLabel" +label_variants_person = &"PersonLabel" +credits_list = NodePath("Scroll/CreditsList") + +[node name="ControlMargin" type="MarginContainer" parent="."] +layout_mode = 2 +anchor_right = 1.0 +anchor_bottom = 0.071 +offset_bottom = -0.120003 +theme_type_variation = &"BackButtonsMargin" + +[node name="BackButton" type="Button" parent="ControlMargin"] +editor_description = "UI-38" +layout_mode = 2 +text = "CREDITS_BACK" + +[node name="Scroll" type="ScrollContainer" parent="."] +editor_description = "UI-35" +layout_mode = 2 +anchor_top = 0.071 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_top = -0.120003 +offset_bottom = -6.0 + +[node name="CreditsList" type="VBoxContainer" parent="Scroll"] +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_vertical = 3 + +[connection signal="pressed" from="ControlMargin/BackButton" to="." method="_on_back_button_pressed"] diff --git a/game/src/Game/Menu/CreditsMenu/GodotEngineButton.gd b/game/src/Game/Menu/CreditsMenu/GodotEngineButton.gd new file mode 100644 index 0000000..ca3a958 --- /dev/null +++ b/game/src/Game/Menu/CreditsMenu/GodotEngineButton.gd @@ -0,0 +1,4 @@ +extends Button + +func _on_pressed(): + OS.shell_open("https://godotengine.org") diff --git a/game/src/Game/Menu/CreditsMenu/GodotEngineButton.tscn b/game/src/Game/Menu/CreditsMenu/GodotEngineButton.tscn new file mode 100644 index 0000000..8b0c46b --- /dev/null +++ b/game/src/Game/Menu/CreditsMenu/GodotEngineButton.tscn @@ -0,0 +1,20 @@ +[gd_scene load_steps=3 format=3 uid="uid://ddjbee5gj6bkv"] + +[ext_resource type="Texture2D" uid="uid://rh7l4xuh4ali" path="res://src/CreditsMenu/logo_vertical_color_dark.svg" id="1_b0brk"] +[ext_resource type="Script" path="res://src/CreditsMenu/GodotEngineButton.gd" id="3_gi8fv"] + +[node name="GodotEngineButton" type="Button"] +custom_minimum_size = Vector2(0, 200) +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +size_flags_vertical = 3 +icon = ExtResource("1_b0brk") +flat = true +icon_alignment = 1 +expand_icon = true +script = ExtResource("3_gi8fv") + +[connection signal="pressed" from="." to="." method="_on_pressed"] diff --git a/game/src/Game/Menu/CreditsMenu/logo_vertical_color_dark.svg b/game/src/Game/Menu/CreditsMenu/logo_vertical_color_dark.svg new file mode 100644 index 0000000..00e50cd --- /dev/null +++ b/game/src/Game/Menu/CreditsMenu/logo_vertical_color_dark.svg @@ -0,0 +1 @@ + diff --git a/game/src/Game/Menu/CreditsMenu/logo_vertical_color_dark.svg.import b/game/src/Game/Menu/CreditsMenu/logo_vertical_color_dark.svg.import new file mode 100644 index 0000000..a4fb09a --- /dev/null +++ b/game/src/Game/Menu/CreditsMenu/logo_vertical_color_dark.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://rh7l4xuh4ali" +path="res://.godot/imported/logo_vertical_color_dark.svg-1167b3ce62f0747c0e76b17bdbb9f218.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://src/CreditsMenu/logo_vertical_color_dark.svg" +dest_files=["res://.godot/imported/logo_vertical_color_dark.svg-1167b3ce62f0747c0e76b17bdbb9f218.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=0 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/game/src/Game/Menu/LobbyMenu/LobbyMenu.gd b/game/src/Game/Menu/LobbyMenu/LobbyMenu.gd new file mode 100644 index 0000000..db4f2ce --- /dev/null +++ b/game/src/Game/Menu/LobbyMenu/LobbyMenu.gd @@ -0,0 +1,165 @@ +extends HBoxContainer + +# REQUIREMENTS: +# * 1.4 Game Lobby Menu +# * SS-12 + +signal back_button_pressed +signal save_game_selected(save : SaveResource) +signal start_date_selected(index : int) + +@export var lobby_panel_button : PackedScene +@export var save_scene : PackedScene + +@export_group("Nodes") +@export var game_select_start_date : BoxContainer +@export var game_select_save_tab : TabBar +@export var game_select_save_list : BoxContainer +@export var start_button : BaseButton +@export var session_tag_line_edit : LineEdit +@export var session_tag_dialog : ConfirmationDialog +@export var delete_dialog : ConfirmationDialog + +func filter_for_tag(tag : StringName) -> void: + for child in game_select_save_list.get_children(): + if tag == &"": + child.show() + else: + if tag == child.resource.session_tag: + child.show() + else: + child.hide() + +func _build_date_list() -> void: + var start_date := lobby_panel_button.instantiate() + start_date.set_text(&"1836") + start_date.pressed.connect(_on_start_date_panel_button_pressed.bind(start_date)) + game_select_start_date.add_child(start_date) + start_date = lobby_panel_button.instantiate() + start_date.set_text(&"1863") + start_date.pressed.connect(_on_start_date_panel_button_pressed.bind(start_date)) + game_select_start_date.add_child(start_date) + +var _id_to_tag : Array[StringName] = [] + +# Requirements +# * FS-8 +func _build_save_list() -> void: + game_select_save_tab.add_tab("GAMELOBBY_SELECT_ALL") + for save_name in SaveManager._save_dictionary: + var save : SaveResource = SaveManager._save_dictionary[save_name] + var save_node := _create_save_node(save) + game_select_save_list.add_child(save_node) + if not _id_to_tag.has(save.session_tag): + _id_to_tag.append(save.session_tag) + game_select_save_tab.add_tab(save.session_tag) + +func _create_save_node(resource : SaveResource) -> Control: + var save_node = save_scene.instantiate() + save_node.resource = resource + save_node.pressed.connect(_on_save_node_pressed.bind(save_node)) + save_node.request_to_delete.connect(_on_save_node_delete_requested.bind(save_node)) + return save_node + +func _queue_clear_lists() -> void: + var full_list = game_select_start_date.get_children() + full_list.append_array(game_select_save_list.get_children()) + for child in full_list: + child.queue_free() + game_select_save_tab.clear_tabs() + _id_to_tag.clear() + +# REQUIREMENTS: +# * SS-16 +# * UIFUN-40 +func _on_back_button_button_down(): + print("Returning to Main Menu.") + SaveManager.current_session_tag = "" + SaveManager.current_save = null + back_button_pressed.emit() + +# REQUIREMENTS: +# * SS-21 +func _on_start_button_pressed(): + print("Starting new game.") + if SaveManager.current_session_tag == "": + # TODO: Get country tag as well + var datetime := Time.get_datetime_dict_from_system() + SaveManager.current_session_tag = "%s/%s/%s-%s:%s:%s" % [ + datetime["day"], + datetime["month"], + datetime["year"], + datetime["hour"], + datetime["minute"], + datetime["second"] + ] + if SaveManager.current_save == null and SaveManager.current_session_tag in _id_to_tag: + session_tag_dialog.dialog_text = tr("GAMELOBBY_SESSIONTAG_DIALOG_TEXT").format({ "session_tag": SaveManager.current_session_tag }) + session_tag_dialog.title = tr("GAMELOBBY_SESSIONTAG_DIALOG_TITLE").format({ "session_tag": SaveManager.current_session_tag }) + session_tag_dialog.popup_centered() + else: + _on_session_tag_dialog_confirmed() + +# REQUIREMENTS: +# * SS-19 +func _on_game_select_list_item_selected(index): + print("Selected save game: ", index) + save_game_selected.emit(index) + +# If the date is double-clicked, start the game! +func _on_game_select_list_item_activated(index): + _on_game_select_list_item_selected(index) + _on_start_button_pressed() + +func _on_session_tag_edit_text_submitted(new_text): + SaveManager.current_session_tag = new_text + _on_start_button_pressed() + +func _on_session_tag_dialog_confirmed(): + get_tree().change_scene_to_file("res://src/GameSession/GameSession.tscn") + +var _requested_node_to_delete : Control +func _on_save_node_delete_requested(node : Control) -> void: + _requested_node_to_delete = node + delete_dialog.dialog_text = tr("GAMELOBBY_DELETE_DIALOG_TEXT").format({ "file_name": _requested_node_to_delete.resource.save_name }) + delete_dialog.title = tr("GAMELOBBY_DELETE_DIALOG_TITLE").format({ "file_name": _requested_node_to_delete.resource.save_name }) + delete_dialog.popup_centered() + +var _start_date_index := -1 +func _on_start_date_panel_button_pressed(node : Control) -> void: + if node is LobbyPanelButton and node.get_index(true) == _start_date_index: + _on_start_button_pressed() + return + _start_date_index = node.get_index(true) + start_button.disabled = false + start_date_selected.emit(_start_date_index) + +func _on_save_node_pressed(node : Control) -> void: + if SaveManager.current_save != null and SaveManager.current_save == node.resource: + SaveManager.current_session_tag = SaveManager.current_save.session_tag + _on_start_button_pressed() + return + SaveManager.current_save = node.resource + if SaveManager.current_save != null: + session_tag_line_edit.text = SaveManager.current_save.session_tag + else: + session_tag_line_edit.text = "" + start_button.disabled = false + save_game_selected.emit(SaveManager.current_save) + +func _on_game_select_save_tab_tab_changed(tab) -> void: + if tab == 0: + filter_for_tag(&"") + else: + filter_for_tag(_id_to_tag[tab - 1]) + +func _on_delete_dialog_confirmed(): + _requested_node_to_delete.resource.delete() + _requested_node_to_delete.queue_free() + +func _on_visibility_changed(): + if visible: + _build_date_list() + _build_save_list() + else: + _queue_clear_lists() diff --git a/game/src/Game/Menu/LobbyMenu/LobbyMenu.tscn b/game/src/Game/Menu/LobbyMenu/LobbyMenu.tscn new file mode 100644 index 0000000..3b5796e --- /dev/null +++ b/game/src/Game/Menu/LobbyMenu/LobbyMenu.tscn @@ -0,0 +1,138 @@ +[gd_scene load_steps=4 format=3 uid="uid://do60kx0d3nrh4"] + +[ext_resource type="Script" path="res://src/LobbyMenu/LobbyMenu.gd" id="1_cvwum"] +[ext_resource type="PackedScene" uid="uid://k71f5gibwmtc" path="res://src/LobbyMenu/LobbyPanelButton.tscn" id="2_exh17"] +[ext_resource type="PackedScene" uid="uid://d2s7roinx2or7" path="res://src/SaveLoadMenu/SavePanelButton.tscn" id="3_4otj7"] + +[node name="LobbyMenu" type="HBoxContainer" node_paths=PackedStringArray("game_select_start_date", "game_select_save_tab", "game_select_save_list", "start_button", "session_tag_line_edit", "session_tag_dialog", "delete_dialog")] +editor_description = "UI-36" +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_cvwum") +lobby_panel_button = ExtResource("2_exh17") +save_scene = ExtResource("3_4otj7") +game_select_start_date = NodePath("GameSelectPanel/VBoxContainer/GameSelectScroll/GameSelectList/GameSelectStartDate") +game_select_save_tab = NodePath("GameSelectPanel/VBoxContainer/GameSelectScroll/GameSelectList/GameSelectSaveTab") +game_select_save_list = NodePath("GameSelectPanel/VBoxContainer/GameSelectScroll/GameSelectList/GameSelectSaveList") +start_button = NodePath("GameStartPanel/VBoxContainer/StartButton") +session_tag_line_edit = NodePath("GameStartPanel/VBoxContainer/SessionTagEdit") +session_tag_dialog = NodePath("SessionTagDialog") +delete_dialog = NodePath("DeleteDialog") + +[node name="GameSelectPanel" type="PanelContainer" parent="."] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="VBoxContainer" type="VBoxContainer" parent="GameSelectPanel"] +layout_mode = 2 + +[node name="GameSelectScroll" type="ScrollContainer" parent="GameSelectPanel/VBoxContainer"] +editor_description = "UI-39" +layout_mode = 2 +size_flags_vertical = 3 +horizontal_scroll_mode = 0 + +[node name="GameSelectList" type="VBoxContainer" parent="GameSelectPanel/VBoxContainer/GameSelectScroll"] +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_vertical = 3 + +[node name="GameSelectStartDate" type="VBoxContainer" parent="GameSelectPanel/VBoxContainer/GameSelectScroll/GameSelectList"] +layout_mode = 2 + +[node name="GameSelectSaveTab" type="TabBar" parent="GameSelectPanel/VBoxContainer/GameSelectScroll/GameSelectList"] +layout_mode = 2 +tab_count = 1 +tab_0/title = "GAMELOBBY_SELECT_ALL" + +[node name="GameSelectSaveList" type="VBoxContainer" parent="GameSelectPanel/VBoxContainer/GameSelectScroll/GameSelectList"] +layout_mode = 2 +size_flags_vertical = 3 + +[node name="GameSelectList" type="ItemList" parent="GameSelectPanel/VBoxContainer"] +visible = false +layout_mode = 2 +size_flags_vertical = 3 +item_count = 2 +item_0/text = "1836" +item_1/text = "1863" + +[node name="Spacer" type="Control" parent="GameSelectPanel/VBoxContainer"] +custom_minimum_size = Vector2(0, 150) +layout_mode = 2 +size_flags_vertical = 3 + +[node name="BackButton" type="Button" parent="GameSelectPanel/VBoxContainer"] +editor_description = "UI-37" +layout_mode = 2 +text = "GAMELOBBY_BACK" + +[node name="Spacer2" type="Control" parent="GameSelectPanel/VBoxContainer"] +custom_minimum_size = Vector2(0, 33) +layout_mode = 2 + +[node name="Spacer" type="Control" parent="."] +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_stretch_ratio = 2.75 +mouse_filter = 2 + +[node name="GameStartPanel" type="PanelContainer" parent="."] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="VBoxContainer" type="VBoxContainer" parent="GameStartPanel"] +layout_mode = 2 + +[node name="Spacer" type="Control" parent="GameStartPanel/VBoxContainer"] +custom_minimum_size = Vector2(0, 50) +layout_mode = 2 + +[node name="SelectedCountryNameLabel" type="Label" parent="GameStartPanel/VBoxContainer"] +layout_mode = 2 +text = "France" +horizontal_alignment = 1 + +[node name="Spacer2" type="Control" parent="GameStartPanel/VBoxContainer"] +custom_minimum_size = Vector2(0, 150) +layout_mode = 2 +size_flags_vertical = 3 + +[node name="SessionTagEdit" type="LineEdit" parent="GameStartPanel/VBoxContainer"] +layout_mode = 2 +placeholder_text = "GAMELOBBY_SESSION_TAG" + +[node name="StartButton" type="Button" parent="GameStartPanel/VBoxContainer"] +editor_description = "UI-43" +layout_mode = 2 +disabled = true +text = "GAMELOBBY_START" + +[node name="Spacer3" type="Control" parent="GameStartPanel/VBoxContainer"] +custom_minimum_size = Vector2(0, 33) +layout_mode = 2 + +[node name="SessionTagDialog" type="ConfirmationDialog" parent="."] +disable_3d = true +title = "GAMELOBBY_SESSIONTAG_DIALOG_TITLE" +ok_button_text = "DIALOG_OK" +dialog_text = "GAMELOBBY_SESSIONTAG_DIALOG_TEXT" +cancel_button_text = "DIALOG_CANCEL" + +[node name="DeleteDialog" type="ConfirmationDialog" parent="."] +disable_3d = true +title = "GAMELOBBY_DELETE_DIALOG_TITLE" +ok_button_text = "DIALOG_OK" +dialog_text = "GAMELOBBY_DELETE_DIALOG_TEXT" +cancel_button_text = "DIALOG_CANCEL" + +[connection signal="visibility_changed" from="." to="." method="_on_visibility_changed"] +[connection signal="tab_changed" from="GameSelectPanel/VBoxContainer/GameSelectScroll/GameSelectList/GameSelectSaveTab" to="." method="_on_game_select_save_tab_tab_changed"] +[connection signal="button_down" from="GameSelectPanel/VBoxContainer/BackButton" to="." method="_on_back_button_button_down"] +[connection signal="text_submitted" from="GameStartPanel/VBoxContainer/SessionTagEdit" to="." method="_on_session_tag_edit_text_submitted"] +[connection signal="pressed" from="GameStartPanel/VBoxContainer/StartButton" to="." method="_on_start_button_pressed"] +[connection signal="confirmed" from="SessionTagDialog" to="." method="_on_session_tag_dialog_confirmed"] +[connection signal="confirmed" from="DeleteDialog" to="." method="_on_delete_dialog_confirmed"] diff --git a/game/src/Game/Menu/LobbyMenu/LobbyPanelButton.gd b/game/src/Game/Menu/LobbyMenu/LobbyPanelButton.gd new file mode 100644 index 0000000..5f3ea46 --- /dev/null +++ b/game/src/Game/Menu/LobbyMenu/LobbyPanelButton.gd @@ -0,0 +1,102 @@ +@tool +class_name LobbyPanelButton +extends Container + +signal button_down +signal button_up +signal pressed +signal toggled(button_pressed : bool) + +var is_start_date : bool: + get = _is_start_date + +func _is_start_date() -> bool: + return true + +@export_group("Nodes") +@export var background_button : BaseButton +@export var name_label : Label + +var text : StringName: + get = get_text, + set = set_text + +func get_text() -> StringName: + return name_label.text + +func set_text(value : StringName) -> void: + name_label.text = value + +func _get_minimum_size() -> Vector2: + var result := Vector2() + for child in get_children(): + child = child as Control + if child == null or not child.visible: + continue + if child.top_level: + continue + + var minsize : Vector2 = child.get_combined_minimum_size() + result.x = max(result.x, minsize.x) + result.y = max(result.y, minsize.y) + + var draw_style := _get_draw_mode_style() + if draw_style != null: + result += draw_style.get_minimum_size() + + return result + +func _get_draw_mode_name(support_rtl : bool = true) -> StringName: + var rtl := support_rtl and background_button != null and background_button.is_layout_rtl() + match background_button.get_draw_mode() if background_button != null else BaseButton.DrawMode.DRAW_NORMAL: + BaseButton.DrawMode.DRAW_NORMAL: + if rtl: return &"normal_mirrored" + return &"normal" + BaseButton.DrawMode.DRAW_PRESSED: + if rtl: return &"pressed_mirrored" + return &"pressed" + BaseButton.DrawMode.DRAW_HOVER: + if rtl: return &"hover_mirrored" + return &"hover" + BaseButton.DrawMode.DRAW_DISABLED: + if rtl: return &"disabled_mirrored" + return &"disabled" + BaseButton.DrawMode.DRAW_HOVER_PRESSED: + if rtl: return &"hover_pressed_mirrored" + return &"hover_pressed" + return &"" + +func _get_draw_mode_style() -> StyleBox: + if background_button == null: return null + var result := background_button.get_theme_stylebox(_get_draw_mode_name()) + if result == null: + return background_button.get_theme_stylebox(_get_draw_mode_name(false)) + return result + +func _notification(what) -> void: + if what == NOTIFICATION_SORT_CHILDREN: + var _size := size + var offset := Vector2() + var style := _get_draw_mode_style() + if style != null: + _size -= style.get_minimum_size() + offset += style.get_offset() + + for child in get_children(): + child = child as Control + if child == null or not child.is_visible_in_tree() or child.top_level: + continue + + fit_child_in_rect(child, Rect2(offset, _size)) + +func _on_background_button_button_down(): + button_down.emit() + +func _on_background_button_button_up(): + button_up.emit() + +func _on_background_button_pressed(): + pressed.emit() + +func _on_background_button_toggled(button_pressed : bool): + toggled.emit(button_pressed) diff --git a/game/src/Game/Menu/LobbyMenu/LobbyPanelButton.tscn b/game/src/Game/Menu/LobbyMenu/LobbyPanelButton.tscn new file mode 100644 index 0000000..f409a2e --- /dev/null +++ b/game/src/Game/Menu/LobbyMenu/LobbyPanelButton.tscn @@ -0,0 +1,31 @@ +[gd_scene load_steps=2 format=3 uid="uid://k71f5gibwmtc"] + +[ext_resource type="Script" path="res://src/LobbyMenu/LobbyPanelButton.gd" id="1_327u2"] + +[node name="LobbyPanelButton" type="Container" node_paths=PackedStringArray("background_button", "name_label")] +editor_description = "UI-41" +offset_right = 113.0 +offset_bottom = 48.0 +script = ExtResource("1_327u2") +background_button = NodePath("BackgroundButton") +name_label = NodePath("SaveList/NameLabel") + +[node name="BackgroundButton" type="Button" parent="."] +layout_mode = 2 +theme_type_variation = &"ButtonContainer" + +[node name="SaveList" type="HBoxContainer" parent="."] +layout_mode = 2 +size_flags_horizontal = 0 +mouse_filter = 2 + +[node name="NameLabel" type="Label" parent="SaveList"] +layout_mode = 2 +size_flags_vertical = 1 +text = "PLACEHOLDER" +vertical_alignment = 1 + +[connection signal="button_down" from="BackgroundButton" to="." method="_on_background_button_button_down"] +[connection signal="button_up" from="BackgroundButton" to="." method="_on_background_button_button_up"] +[connection signal="pressed" from="BackgroundButton" to="." method="_on_background_button_pressed"] +[connection signal="toggled" from="BackgroundButton" to="." method="_on_background_button_toggled"] diff --git a/game/src/Game/Menu/MainMenu/MainMenu.gd b/game/src/Game/Menu/MainMenu/MainMenu.gd new file mode 100644 index 0000000..9d0edc6 --- /dev/null +++ b/game/src/Game/Menu/MainMenu/MainMenu.gd @@ -0,0 +1,50 @@ +extends Control + +signal options_button_pressed +signal new_game_button_pressed +signal credits_button_pressed + +@export +var _new_game_button : BaseButton + +# REQUIREMENTS: +# * SS-3 +func _ready(): + _on_new_game_button_visibility_changed() + +# REQUIREMENTS: +# * SS-14 +# * UIFUN-32 +func _on_new_game_button_pressed(): + print("Start a new game!") + new_game_button_pressed.emit() + + +func _on_continue_button_pressed(): + print("Continue last game!") + + +func _on_multi_player_button_pressed(): + print("Have fun with friends!") + + +func _on_options_button_pressed(): + print("Check out some options!") + options_button_pressed.emit() + +# REQUIREMENTS +# * UI-32 +# * UIFUN-36 +func _on_credits_button_pressed(): + credits_button_pressed.emit() + +# REQUIREMENTS +# * SS-4 +# * UIFUN-3 +func _on_exit_button_pressed(): + print("See you later!") + get_tree().quit() + +func _on_new_game_button_visibility_changed(): + if visible: + _new_game_button.grab_focus.call_deferred() diff --git a/game/src/Game/Menu/MainMenu/MainMenu.tscn b/game/src/Game/Menu/MainMenu/MainMenu.tscn new file mode 100644 index 0000000..0618fe8 --- /dev/null +++ b/game/src/Game/Menu/MainMenu/MainMenu.tscn @@ -0,0 +1,150 @@ +[gd_scene load_steps=6 format=3 uid="uid://bp5n3mlu45ygw"] + +[ext_resource type="Theme" uid="uid://qoi3oec48jp0" path="res://theme/main_menu.tres" id="1_1yri4"] +[ext_resource type="Script" path="res://src/MainMenu/MainMenu.gd" id="2_nm1fq"] +[ext_resource type="Texture2D" uid="uid://dxys0wg0f0ic5" path="res://theme/assets/OpenVicFINALREALTRANS.png" id="3_58ess"] +[ext_resource type="PackedScene" uid="uid://b7oncobnacxmt" path="res://src/LocaleButton.tscn" id="3_amonp"] +[ext_resource type="PackedScene" uid="uid://cen7wkmn6og66" path="res://src/MainMenu/ReleaseInfoBox.tscn" id="3_km0er"] + +[node name="MainMenu" type="Control" node_paths=PackedStringArray("_new_game_button")] +editor_description = "UI-13" +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme = ExtResource("1_1yri4") +script = ExtResource("2_nm1fq") +_new_game_button = NodePath("MenuPanel/MenuList/ButtonListMargin/ButtonList/NewGameButton") + +[node name="MenuPanel" type="PanelContainer" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_type_variation = &"BackgroundPanel" + +[node name="MenuList" type="VBoxContainer" parent="MenuPanel"] +layout_mode = 2 + +[node name="TitleIcon" type="TextureRect" parent="MenuPanel/MenuList"] +layout_mode = 2 +size_flags_vertical = 3 +size_flags_stretch_ratio = 1.75 +texture = ExtResource("3_58ess") +expand_mode = 1 +stretch_mode = 5 + +[node name="ButtonListMargin" type="MarginContainer" parent="MenuPanel/MenuList"] +layout_mode = 2 +theme_override_constants/margin_left = 15 +theme_override_constants/margin_right = 12 + +[node name="ButtonList" type="HBoxContainer" parent="MenuPanel/MenuList/ButtonListMargin"] +custom_minimum_size = Vector2(500, 0) +layout_mode = 2 +theme_type_variation = &"HBox_MainMenu_ButtonList" +theme_override_constants/separation = 18 +alignment = 1 + +[node name="NewGameButton" type="Button" parent="MenuPanel/MenuList/ButtonListMargin/ButtonList"] +editor_description = "UI-26" +layout_mode = 2 +size_flags_horizontal = 3 +focus_neighbor_left = NodePath("../ExitButton") +focus_neighbor_top = NodePath("../ExitButton") +focus_neighbor_right = NodePath("../ContinueButton") +focus_next = NodePath("../ContinueButton") +focus_previous = NodePath("../ExitButton") +theme_type_variation = &"TitleButton" +text = "MAINMENU_NEW_GAME" +clip_text = true + +[node name="ContinueButton" type="Button" parent="MenuPanel/MenuList/ButtonListMargin/ButtonList"] +layout_mode = 2 +size_flags_horizontal = 3 +focus_neighbor_left = NodePath("../NewGameButton") +focus_neighbor_right = NodePath("../MultiplayerButton") +focus_next = NodePath("../MultiplayerButton") +focus_previous = NodePath("../NewGameButton") +theme_type_variation = &"TitleButton" +disabled = true +text = "MAINMENU_CONTINUE" +clip_text = true + +[node name="MultiplayerButton" type="Button" parent="MenuPanel/MenuList/ButtonListMargin/ButtonList"] +editor_description = "UI-27" +layout_mode = 2 +size_flags_horizontal = 3 +focus_neighbor_left = NodePath("../ContinueButton") +focus_neighbor_right = NodePath("../OptionsButton") +focus_next = NodePath("../OptionsButton") +focus_previous = NodePath("../ContinueButton") +theme_type_variation = &"TitleButton" +text = "MAINMENU_MULTIPLAYER" +clip_text = true + +[node name="OptionsButton" type="Button" parent="MenuPanel/MenuList/ButtonListMargin/ButtonList"] +editor_description = "UI-5" +layout_mode = 2 +size_flags_horizontal = 3 +focus_neighbor_left = NodePath("../MultiplayerButton") +focus_neighbor_right = NodePath("../CreditsButton") +focus_next = NodePath("../CreditsButton") +focus_previous = NodePath("../MultiplayerButton") +theme_type_variation = &"TitleButton" +text = "MAINMENU_OPTIONS" +clip_text = true + +[node name="CreditsButton" type="Button" parent="MenuPanel/MenuList/ButtonListMargin/ButtonList"] +editor_description = "UI-32" +layout_mode = 2 +size_flags_horizontal = 3 +focus_neighbor_left = NodePath("../OptionsButton") +focus_neighbor_right = NodePath("../ExitButton") +focus_next = NodePath("../ExitButton") +focus_previous = NodePath("../OptionsButton") +theme_type_variation = &"TitleButton" +text = "MAINMENU_CREDITS" +clip_text = true + +[node name="ExitButton" type="Button" parent="MenuPanel/MenuList/ButtonListMargin/ButtonList"] +editor_description = "UI-3" +layout_mode = 2 +size_flags_horizontal = 3 +focus_neighbor_left = NodePath("../OptionsButton") +focus_neighbor_right = NodePath("../NewGameButton") +focus_next = NodePath("../NewGameButton") +focus_previous = NodePath("../OptionsButton") +theme_type_variation = &"TitleButton" +text = "MAINMENU_EXIT" +clip_text = true + +[node name="BottomSpace" type="Control" parent="MenuPanel/MenuList"] +layout_mode = 2 +size_flags_vertical = 3 +size_flags_stretch_ratio = 0.35 + +[node name="BottomMargin" type="MarginContainer" parent="MenuPanel/MenuList"] +layout_mode = 2 +theme_type_variation = &"BottomMargin" + +[node name="ReleaseInfoBox" parent="MenuPanel/MenuList/BottomMargin" instance=ExtResource("3_km0er")] +layout_mode = 2 + +[node name="LocaleButton" parent="MenuPanel/MenuList/BottomMargin" instance=ExtResource("3_amonp")] +layout_mode = 2 +size_flags_horizontal = 8 +alignment = 0 +text_overrun_behavior = 4 + +[connection signal="pressed" from="MenuPanel/MenuList/ButtonListMargin/ButtonList/NewGameButton" to="." method="_on_new_game_button_pressed"] +[connection signal="visibility_changed" from="MenuPanel/MenuList/ButtonListMargin/ButtonList/NewGameButton" to="." method="_on_new_game_button_visibility_changed"] +[connection signal="pressed" from="MenuPanel/MenuList/ButtonListMargin/ButtonList/ContinueButton" to="." method="_on_continue_button_pressed"] +[connection signal="pressed" from="MenuPanel/MenuList/ButtonListMargin/ButtonList/MultiplayerButton" to="." method="_on_multi_player_button_pressed"] +[connection signal="pressed" from="MenuPanel/MenuList/ButtonListMargin/ButtonList/OptionsButton" to="." method="_on_options_button_pressed"] +[connection signal="pressed" from="MenuPanel/MenuList/ButtonListMargin/ButtonList/CreditsButton" to="." method="_on_credits_button_pressed"] +[connection signal="pressed" from="MenuPanel/MenuList/ButtonListMargin/ButtonList/ExitButton" to="." method="_on_exit_button_pressed"] diff --git a/game/src/Game/Menu/MainMenu/ReleaseInfoBox.gd b/game/src/Game/Menu/MainMenu/ReleaseInfoBox.gd new file mode 100644 index 0000000..e363162 --- /dev/null +++ b/game/src/Game/Menu/MainMenu/ReleaseInfoBox.gd @@ -0,0 +1,41 @@ +extends HBoxContainer + +@export +var _version_label : Button + +@export +var _commit_label : Button + +@export +var _checksum_label : Button + +var _checksum : String = "????" + +# REQUIREMENTS: +# * UIFUN-97 +func _ready(): + _version_label.text = _GIT_INFO_.release_name + _version_label.tooltip_text = _GIT_INFO_.tag + _commit_label.text = _GIT_INFO_.short_hash + _commit_label.tooltip_text = _GIT_INFO_.commit_hash + # UI-111 + _checksum = Checksum.get_checksum_text() + _update_checksum_label_text() + +func _notification(what : int): + match what: + NOTIFICATION_TRANSLATION_CHANGED: + _update_checksum_label_text() + +func _update_checksum_label_text() -> void: + _checksum_label.tooltip_text = tr("MAINMENU_CHECKSUM").format({ "checksum": _checksum }) + _checksum_label.text = "(%s)" % _checksum.substr(0, 4) + +func _on_version_label_pressed(): + DisplayServer.clipboard_set(_GIT_INFO_.tag) + +func _on_commit_label_pressed(): + DisplayServer.clipboard_set(_GIT_INFO_.commit_hash) + +func _on_checksum_label_pressed(): + DisplayServer.clipboard_set(_checksum) diff --git a/game/src/Game/Menu/MainMenu/ReleaseInfoBox.tscn b/game/src/Game/Menu/MainMenu/ReleaseInfoBox.tscn new file mode 100644 index 0000000..821982b --- /dev/null +++ b/game/src/Game/Menu/MainMenu/ReleaseInfoBox.tscn @@ -0,0 +1,38 @@ +[gd_scene load_steps=2 format=3 uid="uid://cen7wkmn6og66"] + +[ext_resource type="Script" path="res://src/MainMenu/ReleaseInfoBox.gd" id="1_y2djw"] + +[node name="ReleaseInfoBox" type="HBoxContainer" node_paths=PackedStringArray("_version_label", "_commit_label", "_checksum_label")] +editor_description = "UI-31" +script = ExtResource("1_y2djw") +_version_label = NodePath("VersionLabel") +_commit_label = NodePath("CommitLabel") +_checksum_label = NodePath("ChecksumLabel") + +[node name="VersionLabel" type="Button" parent="."] +layout_mode = 2 +tooltip_text = "VERSION_MISSING" +theme_type_variation = &"VersionLabel" +text = "VERSION_MISSING" +flat = true +alignment = 0 + +[node name="CommitLabel" type="Button" parent="."] +layout_mode = 2 +theme_type_variation = &"CommitLabel" +text = "????????" +flat = true +alignment = 0 + +[node name="ChecksumLabel" type="Button" parent="."] +editor_description = "UI-111" +layout_mode = 2 +tooltip_text = "CHECKSUM_MISSING" +theme_type_variation = &"ChecksumLabel" +text = "(????)" +flat = true +alignment = 0 + +[connection signal="pressed" from="VersionLabel" to="." method="_on_version_label_pressed"] +[connection signal="pressed" from="CommitLabel" to="." method="_on_commit_label_pressed"] +[connection signal="pressed" from="ChecksumLabel" to="." method="_on_checksum_label_pressed"] diff --git a/game/src/Game/Menu/OptionMenu/AutosaveIntervalSelector.gd b/game/src/Game/Menu/OptionMenu/AutosaveIntervalSelector.gd new file mode 100644 index 0000000..2c55862 --- /dev/null +++ b/game/src/Game/Menu/OptionMenu/AutosaveIntervalSelector.gd @@ -0,0 +1,2 @@ +extends SettingOptionButton + diff --git a/game/src/Game/Menu/OptionMenu/ControlsTab.tscn b/game/src/Game/Menu/OptionMenu/ControlsTab.tscn new file mode 100644 index 0000000..b84dc85 --- /dev/null +++ b/game/src/Game/Menu/OptionMenu/ControlsTab.tscn @@ -0,0 +1,14 @@ +[gd_scene load_steps=2 format=3 uid="uid://cdwymd51i4b2f"] + +[ext_resource type="PackedScene" uid="uid://by4gggse2nsdx" path="res://addons/keychain/ShortcutEdit.tscn" id="1_fv8sh"] + +[node name="Controls" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="ShortcutEdit" parent="." instance=ExtResource("1_fv8sh")] +layout_mode = 1 diff --git a/game/src/Game/Menu/OptionMenu/GeneralTab.gd b/game/src/Game/Menu/OptionMenu/GeneralTab.gd new file mode 100644 index 0000000..3d98678 --- /dev/null +++ b/game/src/Game/Menu/OptionMenu/GeneralTab.gd @@ -0,0 +1,9 @@ +extends HBoxContainer + +@export var initial_focus: Control + +func _notification(what : int) -> void: + match(what): + NOTIFICATION_VISIBILITY_CHANGED: + if visible and is_inside_tree(): + initial_focus.grab_focus() diff --git a/game/src/Game/Menu/OptionMenu/GeneralTab.tscn b/game/src/Game/Menu/OptionMenu/GeneralTab.tscn new file mode 100644 index 0000000..4e9ff6a --- /dev/null +++ b/game/src/Game/Menu/OptionMenu/GeneralTab.tscn @@ -0,0 +1,81 @@ +[gd_scene load_steps=5 format=3 uid="uid://duwjal7sd7p6w"] + +[ext_resource type="Script" path="res://src/OptionMenu/GeneralTab.gd" id="1_gbutn"] +[ext_resource type="PackedScene" uid="uid://b7oncobnacxmt" path="res://src/LocaleButton.tscn" id="2_5cfd7"] +[ext_resource type="Script" path="res://src/OptionMenu/SettingNodes/SettingOptionButton.gd" id="2_msx2u"] +[ext_resource type="Script" path="res://src/OptionMenu/AutosaveIntervalSelector.gd" id="2_t06tb"] + +[node name="GeneralTab" type="HBoxContainer" node_paths=PackedStringArray("initial_focus")] +editor_description = "UI-48, UIFUN-45" +alignment = 1 +script = ExtResource("1_gbutn") +initial_focus = NodePath("VBoxContainer/GridContainer/SavegameFormatSelector") + +[node name="VBoxContainer" type="VBoxContainer" parent="."] +layout_mode = 2 + +[node name="Control" type="Control" parent="VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 3 +size_flags_stretch_ratio = 0.1 + +[node name="GridContainer" type="GridContainer" parent="VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 3 +columns = 2 + +[node name="SavegameFormatLabel" type="Label" parent="VBoxContainer/GridContainer"] +layout_mode = 2 +text = "OPTIONS_GENERAL_SAVEFORMAT" + +[node name="SavegameFormatSelector" type="OptionButton" parent="VBoxContainer/GridContainer"] +editor_description = "UI-50" +layout_mode = 2 +focus_neighbor_bottom = NodePath("../AutosaveIntervalSelector") +item_count = 2 +selected = 0 +popup/item_0/text = "OPTIONS_GENERAL_BINARY" +popup/item_0/id = 0 +popup/item_1/text = "OPTIONS_GENERAL_TEXT" +popup/item_1/id = 1 +script = ExtResource("2_msx2u") +section_name = "general" +setting_name = "savegame_format" +default_selected = 0 + +[node name="AutosaveIntervalLabel" type="Label" parent="VBoxContainer/GridContainer"] +layout_mode = 2 +text = "OPTIONS_GENERAL_AUTOSAVE" + +[node name="AutosaveIntervalSelector" type="OptionButton" parent="VBoxContainer/GridContainer"] +editor_description = "UI-15, UIFUN-19" +layout_mode = 2 +focus_neighbor_top = NodePath("../SavegameFormatSelector") +focus_neighbor_bottom = NodePath("../LocaleButton") +item_count = 5 +selected = 0 +popup/item_0/text = "OPTIONS_GENERAL_AUTOSAVE_MONTHLY" +popup/item_0/id = 0 +popup/item_1/text = "OPTIONS_GENERAL_AUTOSAVE_BIMONTHLY" +popup/item_1/id = 1 +popup/item_2/text = "OPTIONS_GENERAL_AUTOSAVE_YEARLY" +popup/item_2/id = 2 +popup/item_3/text = "OPTIONS_GENERAL_AUTOSAVE_BIYEARLY" +popup/item_3/id = 3 +popup/item_4/text = "OPTIONS_GENERAL_AUTOSAVE_NEVER" +popup/item_4/id = 4 +script = ExtResource("2_t06tb") +section_name = "general" +setting_name = "autosave_interval" +default_selected = 0 + +[node name="LocaleLabel" type="Label" parent="VBoxContainer/GridContainer"] +layout_mode = 2 +text = "OPTIONS_GENERAL_LANGUAGE" + +[node name="LocaleButton" parent="VBoxContainer/GridContainer" instance=ExtResource("2_5cfd7")] +editor_description = "UI-79" +layout_mode = 2 +focus_neighbor_top = NodePath("../AutosaveIntervalSelector") +alignment = 0 +text_overrun_behavior = 4 diff --git a/game/src/Game/Menu/OptionMenu/GuiScaleSelector.gd b/game/src/Game/Menu/OptionMenu/GuiScaleSelector.gd new file mode 100644 index 0000000..4dd86e1 --- /dev/null +++ b/game/src/Game/Menu/OptionMenu/GuiScaleSelector.gd @@ -0,0 +1,64 @@ +extends SettingOptionButton + +# REQUIREMENTS +# * UIFUN-24 +# * UIFUN-31 + +@export +var default_value : float = GuiScale.error_guiscale + +func _find_guiscale_index_by_value(value : float) -> int: + for item_index in item_count: + if get_item_metadata(item_index) == value: + return item_index + return -1 + +func _sync_guiscales(to_select : float = GuiScale.get_current_guiscale()) -> void: + clear() + default_selected = -1 + selected = -1 + for guiscale_value in GuiScale.get_guiscale_value_list(): + add_item(GuiScale.get_guiscale_display_name(guiscale_value)) + set_item_metadata(item_count - 1, guiscale_value) + + if guiscale_value == default_value: + default_selected = item_count - 1 + + if guiscale_value == to_select: + selected = item_count - 1 + + if default_selected == -1: + default_selected = item_count - 1 + + if selected == -1: + selected = default_selected + +func _setup_button(): + if default_value <= 0: + default_value = ProjectSettings.get_setting("display/window/stretch/scale") + GuiScale.add_guiscale(default_value, &"default") + _sync_guiscales() + +func _get_value_for_file(select_value : int): + if _valid_index(select_value): + return get_item_metadata(select_value) + else: + return null + +func _set_value_from_file(load_value): + if typeof(load_value) == TYPE_FLOAT: + var target_guiscale : float = load_value + selected = _find_guiscale_index_by_value(target_guiscale) + if selected != -1: return + if GuiScale.add_guiscale(target_guiscale): + _sync_guiscales(target_guiscale) + return + push_error("Setting value '%s' invalid for setting [%s] %s" % [load_value, section_name, setting_name]) + selected = default_selected + +func _on_option_selected(index : int, by_user : bool): + if _valid_index(index): + GuiScale.set_guiscale(get_item_metadata(index)) + else: + push_error("Invalid GuiScaleSelector index: %d" % index) + reset_setting(not by_user) diff --git a/game/src/Game/Menu/OptionMenu/MonitorDisplaySelector.gd b/game/src/Game/Menu/OptionMenu/MonitorDisplaySelector.gd new file mode 100644 index 0000000..7de033a --- /dev/null +++ b/game/src/Game/Menu/OptionMenu/MonitorDisplaySelector.gd @@ -0,0 +1,18 @@ +extends SettingOptionButton + +func _setup_button() -> void: + clear() + for screen_index in DisplayServer.get_screen_count(): + add_item("Monitor %d" % (screen_index + 1)) + default_selected = get_viewport().get_window().current_screen + +func _on_option_selected(index : int, by_user : bool) -> void: + if _valid_index(index): + var window := get_viewport().get_window() + var mode := window.mode + window.mode = Window.MODE_WINDOWED + get_viewport().get_window().set_current_screen(index) + window.mode = mode + else: + push_error("Invalid MonitorDisplaySelector index: %d" % index) + reset_setting(not by_user) diff --git a/game/src/Game/Menu/OptionMenu/OptionsMenu.gd b/game/src/Game/Menu/OptionMenu/OptionsMenu.gd new file mode 100644 index 0000000..5f6a088 --- /dev/null +++ b/game/src/Game/Menu/OptionMenu/OptionsMenu.gd @@ -0,0 +1,68 @@ +extends Control + +# REQUIREMENTS +# * SS-13 + +signal back_button_pressed + +func _ready(): + # Prepare options menu before loading user settings + var tab_bar : TabBar = $Margin/Tab.get_child(0, true) + + # This ends up easier to manage then trying to manually recreate the TabContainer's behavior + # These buttons can be accessed regardless of the tab + var button_list := HBoxContainer.new() + button_list.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT) + button_list.alignment = BoxContainer.ALIGNMENT_END + tab_bar.add_child(button_list) + + # REQUIREMENTS + # * UI-12 + # * UIFUN-14 + var reset_button := Button.new() + reset_button.text = "OPTIONS_RESET" + reset_button.pressed.connect(Events.Options.try_reset_settings) + button_list.add_child(reset_button) + + # REQUIREMENTS + # * UI-11 + # * UIFUN-17 + var back_button := Button.new() + back_button.text = "OPTIONS_BACK" + back_button.pressed.connect(_on_back_button_pressed) + button_list.add_child(back_button) + get_viewport().get_window().close_requested.connect(_on_window_close_requested) + _save_overrides.call_deferred() + Events.Options.save_settings.connect(func(_f): self._save_overrides.call_deferred()) + +func _notification(what): + match what: + NOTIFICATION_CRASH: + _on_window_close_requested() + +func _input(event): + if self.is_visible_in_tree(): + if event.is_action_pressed("ui_cancel"): + _on_back_button_pressed() + +func _on_back_button_pressed(): + Events.Options.save_settings_to_file() + back_button_pressed.emit() + +func _on_window_close_requested() -> void: + if visible: + Events.Options.save_settings_to_file() + +func _save_overrides() -> void: + var override_path : String = ProjectSettings.get_setting("application/config/project_settings_override", "") + if override_path.is_empty(): + override_path = ProjectSettings.get_setting(Events.Options.settings_file_path_setting, Events.Options.settings_file_path_default) + var file := ConfigFile.new() + var err_ret := file.load(override_path) + if err_ret != OK: push_error("Failed to load overrides from %s" % override_path) + file.set_value("display", "window/size/mode", get_viewport().get_window().mode) + var resolution : Vector2i = Resolution.get_current_resolution() + file.set_value("display", "window/size/viewport_width", resolution.x) + file.set_value("display", "window/size/viewport_height", resolution.y) + err_ret = file.save(override_path) + if err_ret != OK: push_error("Failed to save overrides to %s" % override_path) diff --git a/game/src/Game/Menu/OptionMenu/OptionsMenu.tscn b/game/src/Game/Menu/OptionMenu/OptionsMenu.tscn new file mode 100644 index 0000000..3156e33 --- /dev/null +++ b/game/src/Game/Menu/OptionMenu/OptionsMenu.tscn @@ -0,0 +1,52 @@ +[gd_scene load_steps=8 format=3 uid="uid://cnbfxjy1m6wja"] + +[ext_resource type="Theme" uid="uid://fbxssqcg1s0m" path="res://theme/options_menu.tres" id="1_0up1d"] +[ext_resource type="Script" path="res://src/OptionMenu/OptionsMenu.gd" id="1_tlein"] +[ext_resource type="PackedScene" uid="uid://bq3awxxjn1tuw" path="res://src/OptionMenu/VideoTab.tscn" id="2_ji8xr"] +[ext_resource type="PackedScene" uid="uid://cbtgwpx2wxi33" path="res://src/OptionMenu/SoundTab.tscn" id="3_4w35t"] +[ext_resource type="PackedScene" uid="uid://duwjal7sd7p6w" path="res://src/OptionMenu/GeneralTab.tscn" id="3_6gvf6"] +[ext_resource type="PackedScene" uid="uid://bq7ibhm0txl5p" path="res://addons/keychain/ShortcutEdit.tscn" id="4_vdhjp"] +[ext_resource type="PackedScene" uid="uid://dp2grvybtecqu" path="res://src/OptionMenu/OtherTab.tscn" id="5_ahefp"] + +[node name="OptionsMenu" type="PanelContainer"] +editor_description = "UI-25" +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme = ExtResource("1_0up1d") +theme_type_variation = &"BackgroundPanel" +script = ExtResource("1_tlein") + +[node name="Margin" type="MarginContainer" parent="."] +layout_mode = 2 +theme_type_variation = &"TabMargin" + +[node name="Tab" type="TabContainer" parent="Margin"] +editor_description = "UI-45" +layout_mode = 2 +tab_alignment = 1 +use_hidden_tabs_for_min_size = true + +[node name="General" parent="Margin/Tab" instance=ExtResource("3_6gvf6")] +layout_mode = 2 + +[node name="Video" parent="Margin/Tab" instance=ExtResource("2_ji8xr")] +editor_description = "UI-46, UIFUN-43" +visible = false +layout_mode = 2 + +[node name="Sound" parent="Margin/Tab" instance=ExtResource("3_4w35t")] +editor_description = "UI-47, UIFUN-44" +visible = false +layout_mode = 2 + +[node name="Controls" parent="Margin/Tab" instance=ExtResource("4_vdhjp")] +editor_description = "SS-27, UI-49, UIFUN-46" +visible = false +layout_mode = 2 +alignment = 1 + +[node name="Other" parent="Margin/Tab" instance=ExtResource("5_ahefp")] +layout_mode = 2 diff --git a/game/src/Game/Menu/OptionMenu/OtherTab.tscn b/game/src/Game/Menu/OptionMenu/OtherTab.tscn new file mode 100644 index 0000000..0ffc92d --- /dev/null +++ b/game/src/Game/Menu/OptionMenu/OtherTab.tscn @@ -0,0 +1,18 @@ +[gd_scene format=3 uid="uid://dp2grvybtecqu"] + +[node name="Other" type="Control"] +visible = false +layout_mode = 3 +anchors_preset = 0 + +[node name="HBoxContainer" type="HBoxContainer" parent="."] +layout_mode = 0 +offset_right = 40.0 +offset_bottom = 40.0 + +[node name="Label" type="Label" parent="HBoxContainer"] +layout_mode = 2 +text = "Spinbox Example :)" + +[node name="SpinBox" type="SpinBox" parent="HBoxContainer"] +layout_mode = 2 diff --git a/game/src/Game/Menu/OptionMenu/QualityPresetSelector.gd b/game/src/Game/Menu/OptionMenu/QualityPresetSelector.gd new file mode 100644 index 0000000..57ba4ab --- /dev/null +++ b/game/src/Game/Menu/OptionMenu/QualityPresetSelector.gd @@ -0,0 +1,4 @@ +extends SettingOptionButton + +func _setup_button(): + pass diff --git a/game/src/Game/Menu/OptionMenu/RefreshRateSelector.gd b/game/src/Game/Menu/OptionMenu/RefreshRateSelector.gd new file mode 100644 index 0000000..31b115b --- /dev/null +++ b/game/src/Game/Menu/OptionMenu/RefreshRateSelector.gd @@ -0,0 +1,5 @@ +extends SettingOptionButton + + +func _setup_button(): + pass diff --git a/game/src/Game/Menu/OptionMenu/ResolutionRevertDialog.gd b/game/src/Game/Menu/OptionMenu/ResolutionRevertDialog.gd new file mode 100644 index 0000000..4d2b8f2 --- /dev/null +++ b/game/src/Game/Menu/OptionMenu/ResolutionRevertDialog.gd @@ -0,0 +1,35 @@ +extends ConfirmationDialog +class_name ResolutionRevertDialog + +signal dialog_accepted(button : SettingRevertButton) +signal dialog_reverted(button : SettingRevertButton) + +@export_group("Nodes") +@export var timer : Timer + +var _revert_node : SettingRevertButton = null + +func show_dialog(button : SettingRevertButton, time : float = 0) -> void: + timer.start(time) + popup_centered(Vector2(1,1)) + _revert_node = button + +func _notification(what): + if what == NOTIFICATION_VISIBILITY_CHANGED: + set_process(visible) + if not visible: _revert_node = null + +func _process(_delta) -> void: + dialog_text = tr("OPTIONS_VIDEO_RESOLUTION_DIALOG_TEXT").format({ "time": int(timer.time_left) }) + +func _on_canceled_or_close_requested() -> void: + timer.stop() + dialog_reverted.emit(_revert_node) + +func _on_confirmed() -> void: + timer.stop() + dialog_accepted.emit(_revert_node) + +func _on_resolution_revert_timer_timeout() -> void: + dialog_reverted.emit(_revert_node) + hide() diff --git a/game/src/Game/Menu/OptionMenu/ResolutionSelector.gd b/game/src/Game/Menu/OptionMenu/ResolutionSelector.gd new file mode 100644 index 0000000..ebdf718 --- /dev/null +++ b/game/src/Game/Menu/OptionMenu/ResolutionSelector.gd @@ -0,0 +1,91 @@ +extends SettingRevertButton + +# REQUIREMENTS +# * UIFUN-21 +# * UIFUN-28 +# * UIFUN-301 +# * UIFUN-302 + +@export var default_value : Vector2i = Resolution.error_resolution + +func _find_resolution_index_by_value(value : Vector2i) -> int: + for item_index in item_count: + if get_item_metadata(item_index) == value: + return item_index + return -1 + +func _sync_resolutions( + value : Vector2i = Resolution.error_resolution, + _resolution_name = null, + _resolution_display_name = null +) -> void: + clear() + default_selected = -1 + selected = -1 + var resolution_list := Resolution.get_resolution_value_list() + if value != Resolution.error_resolution: + resolution_list.append(value) + for resolution_value in resolution_list: + var display_name := "%sx%s" % [resolution_value.x, resolution_value.y] + var resolution_name := Resolution.get_resolution_name(resolution_value) + if resolution_name == &"Default": + display_name = "Default (%s)" % resolution_name + if not resolution_name.is_empty(): + display_name = "%s (%s)" % [display_name, resolution_name + (", Default" if resolution_value == default_value else "")] + add_item(display_name) + set_item_metadata(item_count - 1, resolution_value) + + if resolution_value == default_value: + default_selected = item_count - 1 + + if resolution_value == Resolution.get_current_resolution(): + selected = item_count - 1 + + if default_selected == -1: + default_selected = item_count - 1 + + if selected == -1: + selected = default_selected + +func _setup_button() -> void: + Resolution.resolution_added.connect(_sync_resolutions) + if default_value.x <= 0: + default_value.x = ProjectSettings.get_setting("display/window/size/viewport_width") + if default_value.y <= 0: + default_value.y = ProjectSettings.get_setting("display/window/size/viewport_height") + if not Resolution.has_resolution(default_value): + Resolution.add_resolution(default_value, &"Default") + else: + _sync_resolutions() + +func _get_value_for_file(select_value : int) -> Variant: + if _valid_index(select_value): + return get_item_metadata(select_value) + else: + return null + +func _set_value_from_file(load_value) -> void: + var target_resolution := Resolution.error_resolution + match typeof(load_value): + TYPE_VECTOR2I: target_resolution = load_value + TYPE_STRING, TYPE_STRING_NAME: target_resolution = Resolution.get_resolution_value_from_string(load_value) + if target_resolution != Resolution.error_resolution: + selected = _find_resolution_index_by_value(target_resolution) + if selected != -1: return + if Resolution.add_resolution(target_resolution): + Resolution.set_resolution(target_resolution) + return + push_error("Setting value '%s' invalid for setting [%s] %s" % [load_value, section_name, setting_name]) + selected = default_selected + +func _on_option_selected(index : int, by_user : bool) -> void: + if _valid_index(index): + if by_user: + print("Start Revert Countdown!") + revert_dialog.show_dialog.call_deferred(self) + previous_index = _find_resolution_index_by_value(Resolution.get_current_resolution()) + + Resolution.set_resolution(get_item_metadata(index)) + else: + push_error("Invalid ResolutionSelector index: %d" % index) + reset_setting(not by_user) diff --git a/game/src/Game/Menu/OptionMenu/ScreenModeSelector.gd b/game/src/Game/Menu/OptionMenu/ScreenModeSelector.gd new file mode 100644 index 0000000..af95901 --- /dev/null +++ b/game/src/Game/Menu/OptionMenu/ScreenModeSelector.gd @@ -0,0 +1,48 @@ +extends SettingRevertButton + +# REQUIREMENTS +# * UIFUN-42 + +enum ScreenMode { Unknown = -1, Fullscreen, Borderless, Windowed } + +func get_screen_mode_from_window_mode(window_mode : int) -> ScreenMode: + match window_mode: + Window.MODE_EXCLUSIVE_FULLSCREEN: + return ScreenMode.Fullscreen + Window.MODE_FULLSCREEN: + return ScreenMode.Borderless + Window.MODE_WINDOWED: + return ScreenMode.Windowed + _: + return ScreenMode.Unknown + +func get_window_mode_from_screen_mode(screen_mode : int) -> Window.Mode: + match screen_mode: + ScreenMode.Fullscreen: + return Window.MODE_EXCLUSIVE_FULLSCREEN + ScreenMode.Borderless: + return Window.MODE_FULLSCREEN + ScreenMode.Windowed: + return Window.MODE_WINDOWED + _: + return Window.MODE_EXCLUSIVE_FULLSCREEN + +func _setup_button(): + default_selected = get_screen_mode_from_window_mode(get_viewport().get_window().mode) + selected = default_selected + +func _on_option_selected(index : int, by_user : bool) -> void: + if _valid_index(index): + if by_user: + print("Start Revert Countdown!") + revert_dialog.show_dialog.call_deferred(self) + previous_index = get_screen_mode_from_window_mode(get_viewport().get_window().mode) + + var current_resolution := Resolution.get_current_resolution() + var window_mode := get_window_mode_from_screen_mode(index) + Resolution.window_mode_changed.emit(window_mode) + get_viewport().get_window().mode = window_mode + Resolution.set_resolution(current_resolution) + else: + push_error("Invalid ScreenModeSelector index: %d" % index) + reset_setting(not by_user) diff --git a/game/src/Game/Menu/OptionMenu/SettingNodes/SettingHSlider.gd b/game/src/Game/Menu/OptionMenu/SettingNodes/SettingHSlider.gd new file mode 100644 index 0000000..6fa30ed --- /dev/null +++ b/game/src/Game/Menu/OptionMenu/SettingNodes/SettingHSlider.gd @@ -0,0 +1,41 @@ +extends HSlider +class_name SettingHSlider + +@export +var section_name : String = "setting" + +@export +var setting_name : String = "setting_hslider" + +@export +var default_value : float = 0 + +func _ready(): + Events.Options.load_settings.connect(load_setting) + Events.Options.save_settings.connect(save_setting) + Events.Options.reset_settings.connect(reset_setting) + +func load_setting(file : ConfigFile): + if file == null: return + var load_value = file.get_value(section_name, setting_name, default_value) + match typeof(load_value): + TYPE_FLOAT, TYPE_INT: + if value == load_value: value_changed.emit(value) + value = load_value + return + TYPE_STRING, TYPE_STRING_NAME: + var load_string := load_value as String + if load_string.is_valid_float(): + load_value = load_string.to_float() + if value == load_value: value_changed.emit(value) + value = load_value + return + push_error("Setting value '%s' invalid for setting [%s] \"%s\"" % [load_value, section_name, setting_name]) + value = default_value + +func save_setting(file : ConfigFile): + if file == null: return + file.set_value(section_name, setting_name, value) + +func reset_setting(): + value = default_value diff --git a/game/src/Game/Menu/OptionMenu/SettingNodes/SettingOptionButton.gd b/game/src/Game/Menu/OptionMenu/SettingNodes/SettingOptionButton.gd new file mode 100644 index 0000000..c5a805e --- /dev/null +++ b/game/src/Game/Menu/OptionMenu/SettingNodes/SettingOptionButton.gd @@ -0,0 +1,77 @@ +extends OptionButton +class_name SettingOptionButton + +signal option_selected(index : int, by_user : bool) + +@export +var section_name : String = "setting" + +@export +var setting_name : String = "setting_optionbutton" + +@export +var default_selected : int = -1: + get: return default_selected + set(v): + if v < 0 or item_count == 0: + default_selected = -1 + return + default_selected = v % item_count + +func _valid_index(index : int) -> bool: + return 0 <= index and index < item_count + +func _get_value_for_file(select_value : int): + if _valid_index(select_value): + return select_value + else: + return null + +func _set_value_from_file(load_value) -> void: + match typeof(load_value): + TYPE_INT: + if _valid_index(load_value): + selected = load_value + return + TYPE_STRING, TYPE_STRING_NAME: + var load_string := load_value as String + if load_string.is_valid_int(): + var load_int := load_string.to_int() + if _valid_index(load_int): + selected = load_int + return + for item_index in item_count: + if load_string == get_item_text(item_index): + selected = item_index + return + push_error("Setting value '%s' invalid for setting [%s] \"%s\"" % [load_value, section_name, setting_name]) + selected = default_selected + +func _setup_button() -> void: + pass + +func _ready(): + Events.Options.load_settings.connect(load_setting) + Events.Options.save_settings.connect(save_setting) + Events.Options.reset_settings.connect(reset_setting) + item_selected.connect(func(index : int): option_selected.emit(index, true)) + _setup_button() + if not _valid_index(default_selected) or selected == -1: + var msg := "Failed to generate %s %s options." % [setting_name, section_name] + push_error(msg) + OS.alert(msg, "%s Options Error" % section_name) + get_tree().quit() + +func load_setting(file : ConfigFile) -> void: + if file == null: return + _set_value_from_file(file.get_value(section_name, setting_name, _get_value_for_file(default_selected))) + option_selected.emit(selected, false) + +func save_setting(file : ConfigFile) -> void: + if file == null: return + file.set_value(section_name, setting_name, _get_value_for_file(selected)) + +func reset_setting(no_emit : bool = false) -> void: + selected = default_selected + if not no_emit: + option_selected.emit(selected, false) diff --git a/game/src/Game/Menu/OptionMenu/SettingNodes/SettingRevertButton.gd b/game/src/Game/Menu/OptionMenu/SettingNodes/SettingRevertButton.gd new file mode 100644 index 0000000..945d35b --- /dev/null +++ b/game/src/Game/Menu/OptionMenu/SettingNodes/SettingRevertButton.gd @@ -0,0 +1,27 @@ +extends SettingOptionButton +class_name SettingRevertButton + +@export_group("Nodes") +@export var revert_dialog : ResolutionRevertDialog + +var previous_index : int = -1 + +func _ready(): + super() + if revert_dialog != null: + revert_dialog.visibility_changed.connect(_on_revert_dialog_visibility_changed) + revert_dialog.dialog_accepted.connect(_on_accepted) + revert_dialog.dialog_reverted.connect(_on_reverted) + +func _on_revert_dialog_visibility_changed() -> void: + disabled = revert_dialog.visible + if not revert_dialog.visible: + previous_index = -1 + +func _on_reverted(button : SettingRevertButton) -> void: + if button != self: return + selected = previous_index + option_selected.emit(selected, false) + +func _on_accepted(button : SettingRevertButton) -> void: + if button != self: return diff --git a/game/src/Game/Menu/OptionMenu/SoundTab.gd b/game/src/Game/Menu/OptionMenu/SoundTab.gd new file mode 100644 index 0000000..c707605 --- /dev/null +++ b/game/src/Game/Menu/OptionMenu/SoundTab.gd @@ -0,0 +1,4 @@ +extends HBoxContainer + +func _on_ear_exploder_toggled(button_pressed): + print("KABOOM!!!" if button_pressed else "DEFUSED!!!") diff --git a/game/src/Game/Menu/OptionMenu/SoundTab.tscn b/game/src/Game/Menu/OptionMenu/SoundTab.tscn new file mode 100644 index 0000000..10d7f10 --- /dev/null +++ b/game/src/Game/Menu/OptionMenu/SoundTab.tscn @@ -0,0 +1,34 @@ +[gd_scene load_steps=3 format=3 uid="uid://cbtgwpx2wxi33"] + +[ext_resource type="Script" path="res://src/OptionMenu/SoundTab.gd" id="1_a7k0s"] +[ext_resource type="PackedScene" uid="uid://dy4si8comamnv" path="res://src/OptionMenu/VolumeGrid.tscn" id="1_okpft"] + +[node name="Sound" type="HBoxContainer"] +alignment = 1 +script = ExtResource("1_a7k0s") + +[node name="VBoxContainer" type="VBoxContainer" parent="."] +layout_mode = 2 + +[node name="Control" type="Control" parent="VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 3 +size_flags_stretch_ratio = 0.1 + +[node name="VolumeGrid" parent="VBoxContainer" instance=ExtResource("1_okpft")] +layout_mode = 2 + +[node name="ButtonGrid" type="GridContainer" parent="VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 2 +columns = 2 + +[node name="Spacer" type="Control" parent="VBoxContainer/ButtonGrid"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="EarExploder" type="CheckButton" parent="VBoxContainer/ButtonGrid"] +layout_mode = 2 +text = "Explode Eardrums on Startup?" + +[connection signal="toggled" from="VBoxContainer/ButtonGrid/EarExploder" to="." method="_on_ear_exploder_toggled"] diff --git a/game/src/Game/Menu/OptionMenu/VideoTab.gd b/game/src/Game/Menu/OptionMenu/VideoTab.gd new file mode 100644 index 0000000..3d98678 --- /dev/null +++ b/game/src/Game/Menu/OptionMenu/VideoTab.gd @@ -0,0 +1,9 @@ +extends HBoxContainer + +@export var initial_focus: Control + +func _notification(what : int) -> void: + match(what): + NOTIFICATION_VISIBILITY_CHANGED: + if visible and is_inside_tree(): + initial_focus.grab_focus() diff --git a/game/src/Game/Menu/OptionMenu/VideoTab.tscn b/game/src/Game/Menu/OptionMenu/VideoTab.tscn new file mode 100644 index 0000000..244f481 --- /dev/null +++ b/game/src/Game/Menu/OptionMenu/VideoTab.tscn @@ -0,0 +1,181 @@ +[gd_scene load_steps=9 format=3 uid="uid://bq3awxxjn1tuw"] + +[ext_resource type="Script" path="res://src/OptionMenu/ResolutionSelector.gd" id="1_i8nro"] +[ext_resource type="Script" path="res://src/OptionMenu/VideoTab.gd" id="1_jvv62"] +[ext_resource type="Script" path="res://src/OptionMenu/ScreenModeSelector.gd" id="2_wa7vw"] +[ext_resource type="Script" path="res://src/OptionMenu/GuiScaleSelector.gd" id="3_pgc5d"] +[ext_resource type="Script" path="res://src/OptionMenu/MonitorDisplaySelector.gd" id="3_y6lyb"] +[ext_resource type="Script" path="res://src/OptionMenu/RefreshRateSelector.gd" id="4_381mg"] +[ext_resource type="Script" path="res://src/OptionMenu/QualityPresetSelector.gd" id="5_srg4v"] +[ext_resource type="Script" path="res://src/OptionMenu/ResolutionRevertDialog.gd" id="8_802cr"] + +[node name="Video" type="HBoxContainer" node_paths=PackedStringArray("initial_focus")] +editor_description = "UI-46" +alignment = 1 +script = ExtResource("1_jvv62") +initial_focus = NodePath("VideoSettingList/VideoSettingGrid/ResolutionSelector") + +[node name="VideoSettingList" type="VBoxContainer" parent="."] +layout_mode = 2 + +[node name="Control" type="Control" parent="VideoSettingList"] +layout_mode = 2 +size_flags_vertical = 3 +size_flags_stretch_ratio = 0.1 + +[node name="VideoSettingGrid" type="GridContainer" parent="VideoSettingList"] +layout_mode = 2 +size_flags_vertical = 3 +columns = 2 + +[node name="ResolutionLabel" type="Label" parent="VideoSettingList/VideoSettingGrid"] +layout_mode = 2 +text = "OPTIONS_VIDEO_RESOLUTION" + +[node name="ResolutionSelector" type="OptionButton" parent="VideoSettingList/VideoSettingGrid" node_paths=PackedStringArray("revert_dialog")] +editor_description = "UI-19" +layout_mode = 2 +focus_neighbor_bottom = NodePath("../ScreenModeSelector") +item_count = 1 +selected = 0 +popup/item_0/text = "MISSING" +popup/item_0/id = 0 +script = ExtResource("1_i8nro") +revert_dialog = NodePath("../../../ResolutionRevertDialog") +section_name = "video" +setting_name = "resolution" + +[node name="GuiScaleLabel" type="Label" parent="VideoSettingList/VideoSettingGrid"] +layout_mode = 2 +text = "OPTIONS_VIDEO_GUI_SCALE" + +[node name="GuiScaleSelector" type="OptionButton" parent="VideoSettingList/VideoSettingGrid"] +editor_description = "UI-23" +layout_mode = 2 +focus_neighbor_bottom = NodePath("../ScreenModeSelector") +item_count = 1 +selected = 0 +popup/item_0/text = "MISSING" +popup/item_0/id = 0 +script = ExtResource("3_pgc5d") +section_name = "video" +setting_name = "gui_scale" + +[node name="ScreenModeLabel" type="Label" parent="VideoSettingList/VideoSettingGrid"] +editor_description = "UI-44" +layout_mode = 2 +text = "OPTIONS_VIDEO_SCREEN_MODE" + +[node name="ScreenModeSelector" type="OptionButton" parent="VideoSettingList/VideoSettingGrid" node_paths=PackedStringArray("revert_dialog")] +layout_mode = 2 +focus_neighbor_top = NodePath("../ResolutionSelector") +focus_neighbor_bottom = NodePath("../MonitorDisplaySelector") +item_count = 3 +selected = 0 +popup/item_0/text = "OPTIONS_VIDEO_FULLSCREEN" +popup/item_0/id = 0 +popup/item_1/text = "OPTIONS_VIDEO_BORDERLESS" +popup/item_1/id = 1 +popup/item_2/text = "OPTIONS_VIDEO_WINDOWED" +popup/item_2/id = 2 +script = ExtResource("2_wa7vw") +revert_dialog = NodePath("../../../ResolutionRevertDialog") +section_name = "video" +setting_name = "mode_selected" + +[node name="MonitorSelectionLabel" type="Label" parent="VideoSettingList/VideoSettingGrid"] +layout_mode = 2 +text = "OPTIONS_VIDEO_MONITOR_SELECTION" + +[node name="MonitorDisplaySelector" type="OptionButton" parent="VideoSettingList/VideoSettingGrid"] +layout_mode = 2 +focus_neighbor_top = NodePath("../ScreenModeSelector") +focus_neighbor_bottom = NodePath("../RefreshRateSelector") +item_count = 1 +selected = 0 +popup/item_0/text = "MISSING" +popup/item_0/id = 0 +script = ExtResource("3_y6lyb") +section_name = "video" +setting_name = "current_screen" + +[node name="RefreshRateLabel" type="Label" parent="VideoSettingList/VideoSettingGrid"] +layout_mode = 2 +text = "OPTIONS_VIDEO_REFRESH_RATE" + +[node name="RefreshRateSelector" type="OptionButton" parent="VideoSettingList/VideoSettingGrid"] +editor_description = "UI-18, UIFUN-20" +layout_mode = 2 +tooltip_text = "OPTIONS_VIDEO_REFRESH_RATE_TOOLTIP" +focus_neighbor_top = NodePath("../MonitorDisplaySelector") +focus_neighbor_bottom = NodePath("../QualityPresetSelector") +item_count = 8 +selected = 0 +popup/item_0/text = "VSYNC" +popup/item_0/id = 0 +popup/item_1/text = "30hz" +popup/item_1/id = 1 +popup/item_2/text = "60hz" +popup/item_2/id = 2 +popup/item_3/text = "90hz" +popup/item_3/id = 3 +popup/item_4/text = "120hz" +popup/item_4/id = 4 +popup/item_5/text = "144hz" +popup/item_5/id = 5 +popup/item_6/text = "365hz" +popup/item_6/id = 6 +popup/item_7/text = "Unlimited" +popup/item_7/id = 7 +script = ExtResource("4_381mg") +section_name = "video" +setting_name = "refresh_rate" +default_selected = 0 + +[node name="QualityPresetLabel" type="Label" parent="VideoSettingList/VideoSettingGrid"] +layout_mode = 2 +text = "OPTIONS_VIDEO_QUALITY" + +[node name="QualityPresetSelector" type="OptionButton" parent="VideoSettingList/VideoSettingGrid"] +editor_description = "UI-21, UIFUN-22" +layout_mode = 2 +focus_neighbor_top = NodePath("../RefreshRateSelector") +item_count = 5 +selected = 1 +popup/item_0/text = "Low" +popup/item_0/id = 0 +popup/item_1/text = "Medium" +popup/item_1/id = 1 +popup/item_2/text = "High" +popup/item_2/id = 2 +popup/item_3/text = "Ultra" +popup/item_3/id = 3 +popup/item_4/text = "Custom" +popup/item_4/id = 4 +script = ExtResource("5_srg4v") +section_name = "video" +setting_name = "quality_preset" +default_selected = 1 + +[node name="ResolutionRevertDialog" type="ConfirmationDialog" parent="." node_paths=PackedStringArray("timer")] +editor_description = "UI-873" +disable_3d = true +title = "OPTIONS_VIDEO_RESOLUTION_DIALOG_TITLE" +size = Vector2i(730, 100) +ok_button_text = "DIALOG_OK" +cancel_button_text = "DIALOG_CANCEL" +script = ExtResource("8_802cr") +timer = NodePath("ResolutionRevertTimer") + +[node name="ResolutionRevertTimer" type="Timer" parent="ResolutionRevertDialog"] +wait_time = 5.0 +one_shot = true + +[connection signal="option_selected" from="VideoSettingList/VideoSettingGrid/ResolutionSelector" to="VideoSettingList/VideoSettingGrid/ResolutionSelector" method="_on_option_selected"] +[connection signal="option_selected" from="VideoSettingList/VideoSettingGrid/GuiScaleSelector" to="VideoSettingList/VideoSettingGrid/GuiScaleSelector" method="_on_option_selected"] +[connection signal="option_selected" from="VideoSettingList/VideoSettingGrid/ScreenModeSelector" to="VideoSettingList/VideoSettingGrid/ScreenModeSelector" method="_on_option_selected"] +[connection signal="option_selected" from="VideoSettingList/VideoSettingGrid/MonitorDisplaySelector" to="VideoSettingList/VideoSettingGrid/MonitorDisplaySelector" method="_on_option_selected"] +[connection signal="canceled" from="ResolutionRevertDialog" to="ResolutionRevertDialog" method="_on_canceled_or_close_requested"] +[connection signal="close_requested" from="ResolutionRevertDialog" to="ResolutionRevertDialog" method="_on_canceled_or_close_requested"] +[connection signal="confirmed" from="ResolutionRevertDialog" to="ResolutionRevertDialog" method="_on_confirmed"] +[connection signal="timeout" from="ResolutionRevertDialog/ResolutionRevertTimer" to="ResolutionRevertDialog" method="_on_resolution_revert_timer_timeout"] diff --git a/game/src/Game/Menu/OptionMenu/VolumeGrid.gd b/game/src/Game/Menu/OptionMenu/VolumeGrid.gd new file mode 100644 index 0000000..46613b4 --- /dev/null +++ b/game/src/Game/Menu/OptionMenu/VolumeGrid.gd @@ -0,0 +1,70 @@ +extends GridContainer + +const RATIO_FOR_LINEAR : float = 100 + +var _slider_dictionary : Dictionary + +var initial_focus : Control + +func get_db_as_volume_value(db : float) -> float: + # db_to_linear produces a float between 0 and 1 from a db value + return db_to_linear(db) * RATIO_FOR_LINEAR + +func get_volume_value_as_db(value : float) -> float: + # linear_to_db consumes a float between 0 and 1 to produce the db value + return linear_to_db(value / RATIO_FOR_LINEAR) + +func add_volume_row(bus_name : String, bus_index : int) -> HSlider: + var volume_label := Label.new() + if bus_name == "Master": + volume_label.text = "MASTER_BUS" + else: + volume_label.text = bus_name + add_child(volume_label) + + var volume_slider := SettingHSlider.new() + volume_slider.section_name = "audio" + volume_slider.setting_name = volume_label.text + volume_slider.custom_minimum_size = Vector2(290, 0) + volume_slider.size_flags_vertical = Control.SIZE_FILL + volume_slider.min_value = 0 + volume_slider.default_value = 100 + volume_slider.max_value = 120 # 120 so volume can be boosted somewhat + volume_slider.value_changed.connect(_on_slider_value_changed.bind(bus_index)) + add_child(volume_slider) + + _slider_dictionary[volume_label.text] = volume_slider + if not initial_focus: initial_focus = volume_slider + return volume_slider + +# REQUIREMENTS +# * UI-22 +func _ready(): + for bus_index in AudioServer.bus_count: + add_volume_row(AudioServer.get_bus_name(bus_index), bus_index) + +func _notification(what : int) -> void: + match(what): + NOTIFICATION_VISIBILITY_CHANGED: + if visible and is_inside_tree() and initial_focus: initial_focus.grab_focus() + +# REQUIREMENTS +# * UIFUN-30 +func _on_slider_value_changed(value : float, bus_index : int) -> void: + AudioServer.set_bus_volume_db(bus_index, get_volume_value_as_db(value)) + + +func _on_options_menu_load_settings(load_file : ConfigFile): + for volume_slider in _slider_dictionary.values(): + volume_slider.load_setting(load_file) + +# REQUIREMENTS +# * UIFUN-23 +func _on_options_menu_save_settings(save_file : ConfigFile): + for volume_slider in _slider_dictionary.values(): + volume_slider.save_setting(save_file) + + +func _on_options_menu_reset_settings(): + for volume_slider in _slider_dictionary.values(): + volume_slider.reset_setting() diff --git a/game/src/Game/Menu/OptionMenu/VolumeGrid.tscn b/game/src/Game/Menu/OptionMenu/VolumeGrid.tscn new file mode 100644 index 0000000..6d4de3c --- /dev/null +++ b/game/src/Game/Menu/OptionMenu/VolumeGrid.tscn @@ -0,0 +1,8 @@ +[gd_scene load_steps=2 format=3 uid="uid://dy4si8comamnv"] + +[ext_resource type="Script" path="res://src/OptionMenu/VolumeGrid.gd" id="1_wb64h"] + +[node name="VolumeGrid" type="GridContainer"] +size_flags_vertical = 0 +columns = 2 +script = ExtResource("1_wb64h") diff --git a/game/src/Game/Menu/SaveLoadMenu/SaveLoadMenu.gd b/game/src/Game/Menu/SaveLoadMenu/SaveLoadMenu.gd new file mode 100644 index 0000000..bff0bb5 --- /dev/null +++ b/game/src/Game/Menu/SaveLoadMenu/SaveLoadMenu.gd @@ -0,0 +1,123 @@ +extends Control + +@export var _save_scene : PackedScene + +@export_group("Nodes") +@export var _label : Label +@export var _scroll_list : BoxContainer +@export var _save_line_edit : LineEdit +@export var _save_load_button : Button +@export var _tag_selection_tab : TabBar +@export var _delete_dialog : ConfirmationDialog +@export var _overwrite_dialog : ConfirmationDialog + +var is_save_menu : bool = true +var _id_to_tag : Array[StringName] = [] + +func filter_for_tag(tag : StringName) -> void: + for child in _scroll_list.get_children(): + if tag == &"": + child.show() + else: + if tag == child.resource.session_tag: + child.show() + else: + child.hide() + +# Requirements +# * UIFUN-78 +func show_for_load() -> void: + _label.text = "SAVELOADMENU_LOAD_TITLE" + _save_load_button.text = "SAVELOADMENU_LOAD_BUTTON" + _save_line_edit.editable = false + is_save_menu = false + show() + +# Requirements +# * UIFUN-77 +func show_for_save() -> void: + _label.text = "SAVELOADMENU_SAVE_TITLE" + _save_load_button.text = "SAVELOADMENU_SAVE_BUTTON" + _save_line_edit.editable = true + is_save_menu = true + show() + +func _build_save_list() -> void: + _tag_selection_tab.add_tab("SAVELOADMENU_TABSELECTIONTABBAR_ALL") + for save_name in SaveManager._save_dictionary: + var save : SaveResource = SaveManager._save_dictionary[save_name] + var save_node := _create_save_node(save) + _scroll_list.add_child(save_node) + if not _id_to_tag.has(save.session_tag): + _id_to_tag.append(save.session_tag) + _tag_selection_tab.add_tab(save.session_tag) + +func _create_save_node(resource : SaveResource) -> Control: + var save_node = _save_scene.instantiate() + save_node.resource = resource + save_node.pressed.connect(_on_save_node_pressed.bind(save_node)) + save_node.request_to_delete.connect(_on_save_node_delete_requested.bind(save_node)) + return save_node + +func _queue_clear_scroll_list() -> void: + for child in _scroll_list.get_children(): + child.queue_free() + _tag_selection_tab.clear_tabs() + _id_to_tag.clear() + +# REQUIREMENTS: +# * UIFUN-84 +# * UIFUN-89 +func _on_close_button_pressed() -> void: + hide() + +func _on_delete_dialog_confirmed() -> void: + _requested_node_to_delete.resource.delete() + _requested_node_to_delete.queue_free() + +# REQUIREMENTS: +# * UIFUN-83 +func _on_overwrite_dialog_confirmed() -> void: + SaveManager.add_or_replace_save(SaveManager.make_new_save(_submitted_text)) + _on_close_button_pressed() + +var _submitted_text : String = "" +func _on_save_line_edit_text_submitted(new_text) -> void: + _submitted_text = new_text + if SaveManager.has_save(new_text): + _overwrite_dialog.dialog_text = tr("SAVELOADMENU_OVERWRITE_DIALOG_TEXT").format({ "file_name": _submitted_text }) + _overwrite_dialog.title = tr("SAVELOADMENU_OVERWRITE_DIALOG_TITLE").format({ "file_name": _submitted_text }) + _overwrite_dialog.popup_centered() + return + _on_overwrite_dialog_confirmed() + +func _on_save_load_button_pressed() -> void: + if is_save_menu: + _save_line_edit.text_submitted.emit(_save_line_edit.text) + +var _requested_node_to_delete : Control +func _on_save_node_delete_requested(node : Control) -> void: + _requested_node_to_delete = node + _delete_dialog.dialog_text = tr("SAVELOADMENU_DELETE_DIALOG_TEXT").format({ "file_name": _requested_node_to_delete.resource.save_name }) + _delete_dialog.title = tr("SAVELOADMENU_DELETE_DIALOG_TITLE").format({ "file_name": _requested_node_to_delete.resource.save_name }) + _delete_dialog.popup_centered() + +# REQUIREMENTS: +# * UIFUN-81 +# * UIFUN-86 +func _on_save_node_pressed(node : Control) -> void: + if is_save_menu: + _save_line_edit.text = node.resource.save_name + +func _on_tag_selection_tab_bar_tab_changed(tab) -> void: + if tab == 0: + filter_for_tag(&"") + else: + filter_for_tag(_id_to_tag[tab - 1]) + +func _on_visibility_changed() -> void: + if visible: + _build_save_list() + else: + _queue_clear_scroll_list() + SaveManager.flush_save() diff --git a/game/src/Game/Menu/SaveLoadMenu/SaveLoadMenu.tscn b/game/src/Game/Menu/SaveLoadMenu/SaveLoadMenu.tscn new file mode 100644 index 0000000..e9f068e --- /dev/null +++ b/game/src/Game/Menu/SaveLoadMenu/SaveLoadMenu.tscn @@ -0,0 +1,109 @@ +[gd_scene load_steps=5 format=3 uid="uid://d3g6wbvwflmyk"] + +[ext_resource type="Script" path="res://src/SaveLoadMenu/SaveLoadMenu.gd" id="1_3jkds"] +[ext_resource type="PackedScene" uid="uid://d2s7roinx2or7" path="res://src/SaveLoadMenu/SavePanelButton.tscn" id="2_fc6r3"] + +[sub_resource type="InputEventAction" id="InputEventAction_8vo2t"] +action = &"ui_accept" +pressed = true + +[sub_resource type="Shortcut" id="Shortcut_o1f2l"] +events = [SubResource("InputEventAction_8vo2t")] + +[node name="SaveLoadMenu" type="MarginContainer" node_paths=PackedStringArray("_label", "_scroll_list", "_save_line_edit", "_save_load_button", "_tag_selection_tab", "_delete_dialog", "_overwrite_dialog")] +editor_description = "UI-82, UI-89" +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_constants/margin_left = 250 +theme_override_constants/margin_top = 100 +theme_override_constants/margin_right = 250 +theme_override_constants/margin_bottom = 100 +script = ExtResource("1_3jkds") +_save_scene = ExtResource("2_fc6r3") +_label = NodePath("SaveLoadPanel/SaveLoadList/TitleBarList/SaveLoadLabel") +_scroll_list = NodePath("SaveLoadPanel/SaveLoadList/SaveLoadScroll/SaveLoadScrollList") +_save_line_edit = NodePath("SaveLoadPanel/SaveLoadList/SaveLineEdit") +_save_load_button = NodePath("SaveLoadPanel/SaveLoadList/SaveLoadButton") +_tag_selection_tab = NodePath("SaveLoadPanel/SaveLoadList/TagSelectionList/TagSelectionTabBar") +_delete_dialog = NodePath("DeleteDialog") +_overwrite_dialog = NodePath("OverwriteDialog") + +[node name="SaveLoadPanel" type="PanelContainer" parent="."] +layout_mode = 2 + +[node name="SaveLoadList" type="VBoxContainer" parent="SaveLoadPanel"] +layout_mode = 2 + +[node name="TitleBarList" type="HBoxContainer" parent="SaveLoadPanel/SaveLoadList"] +layout_mode = 2 +alignment = 2 + +[node name="SaveLoadLabel" type="Label" parent="SaveLoadPanel/SaveLoadList/TitleBarList"] +layout_mode = 2 +size_flags_horizontal = 6 +text = "SAVELOADMENU_SAVE_TITLE" + +[node name="CloseButton" type="Button" parent="SaveLoadPanel/SaveLoadList/TitleBarList"] +editor_description = "UI-87, UI-94" +layout_mode = 2 +text = "X" + +[node name="TagSelectionList" type="HBoxContainer" parent="SaveLoadPanel/SaveLoadList"] +layout_mode = 2 + +[node name="TagSelectionLabel" type="Label" parent="SaveLoadPanel/SaveLoadList/TagSelectionList"] +layout_mode = 2 +text = "SAVELOADMENU_SESSION" + +[node name="TagSelectionTabBar" type="TabBar" parent="SaveLoadPanel/SaveLoadList/TagSelectionList"] +layout_mode = 2 +size_flags_horizontal = 3 +tab_count = 1 +tab_0/title = "SAVELOADMENU_TABSELECTIONTABBAR_ALL" + +[node name="SaveLoadScroll" type="ScrollContainer" parent="SaveLoadPanel/SaveLoadList"] +editor_description = "UI-83, UI-90" +layout_mode = 2 +size_flags_vertical = 3 + +[node name="SaveLoadScrollList" type="VBoxContainer" parent="SaveLoadPanel/SaveLoadList/SaveLoadScroll"] +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_vertical = 3 + +[node name="SaveLineEdit" type="LineEdit" parent="SaveLoadPanel/SaveLoadList"] +editor_description = "UI-85, UI-92" +layout_mode = 2 + +[node name="SaveLoadButton" type="Button" parent="SaveLoadPanel/SaveLoadList"] +editor_description = "UIFUN-82, UIFUN-87" +layout_mode = 2 +size_flags_horizontal = 4 +shortcut = SubResource("Shortcut_o1f2l") +shortcut_feedback = false +text = "SAVELOADMENU_SAVE_BUTTON" + +[node name="DeleteDialog" type="ConfirmationDialog" parent="."] +disable_3d = true +title = "SAVELOADMENU_DELETE_DIALOG_TITLE" +ok_button_text = "DIALOG_OK" +dialog_text = "SAVELOADMENU_DELETE_DIALOG_TEXT" +cancel_button_text = "DIALOG_CANCEL" + +[node name="OverwriteDialog" type="ConfirmationDialog" parent="."] +disable_3d = true +title = "SAVELOADMENU_OVERWRITE_DIALOG_TITLE" +ok_button_text = "DIALOG_OK" +dialog_text = "SAVELOADMENU_OVERWRITE_DIALOG_TEXT" +cancel_button_text = "DIALOG_CANCEL" + +[connection signal="visibility_changed" from="." to="." method="_on_visibility_changed"] +[connection signal="pressed" from="SaveLoadPanel/SaveLoadList/TitleBarList/CloseButton" to="." method="_on_close_button_pressed"] +[connection signal="tab_changed" from="SaveLoadPanel/SaveLoadList/TagSelectionList/TagSelectionTabBar" to="." method="_on_tag_selection_tab_bar_tab_changed"] +[connection signal="text_submitted" from="SaveLoadPanel/SaveLoadList/SaveLineEdit" to="." method="_on_save_line_edit_text_submitted"] +[connection signal="pressed" from="SaveLoadPanel/SaveLoadList/SaveLoadButton" to="." method="_on_save_load_button_pressed"] +[connection signal="confirmed" from="DeleteDialog" to="." method="_on_delete_dialog_confirmed"] +[connection signal="confirmed" from="OverwriteDialog" to="." method="_on_overwrite_dialog_confirmed"] diff --git a/game/src/Game/Menu/SaveLoadMenu/SavePanelButton.gd b/game/src/Game/Menu/SaveLoadMenu/SavePanelButton.gd new file mode 100644 index 0000000..5fe4917 --- /dev/null +++ b/game/src/Game/Menu/SaveLoadMenu/SavePanelButton.gd @@ -0,0 +1,41 @@ +@tool +extends LobbyPanelButton + +signal request_to_delete + +@export_group("Nodes") +@export var country_flag : TextureRect +@export var date_label : Label +@export var delete_button : BaseButton + +var resource : SaveResource: + get: + return resource + set(value): + if resource != null: + resource.changed.disconnect(_resource_changed) + resource = value + if resource != null: + resource.changed.connect(_resource_changed) + _resource_changed() + +func get_text() -> StringName: + return resource.save_name + +func set_text(value : StringName) -> void: + if resource != null: + resource.save_name = value + +func _ready(): + _resource_changed() + +func _is_start_date() -> bool: + return false + +func _resource_changed() -> void: + if resource == null: return + name_label.text = resource.save_name + date_label.text = Time.get_datetime_string_from_unix_time(resource.get_save_file_time(), true) + +func _on_delete_button_pressed() -> void: + request_to_delete.emit() diff --git a/game/src/Game/Menu/SaveLoadMenu/SavePanelButton.tscn b/game/src/Game/Menu/SaveLoadMenu/SavePanelButton.tscn new file mode 100644 index 0000000..d2d0a41 --- /dev/null +++ b/game/src/Game/Menu/SaveLoadMenu/SavePanelButton.tscn @@ -0,0 +1,58 @@ +[gd_scene load_steps=2 format=3 uid="uid://d2s7roinx2or7"] + +[ext_resource type="Script" path="res://src/SaveLoadMenu/SavePanelButton.gd" id="1_rtuo6"] + +[node name="SavePanelButton" type="Container" node_paths=PackedStringArray("country_flag", "date_label", "delete_button", "background_button", "name_label")] +editor_description = "SS-18, UI-40, UI-84, UI-86, UI-91, UI-93" +offset_right = 276.0 +offset_bottom = 48.0 +script = ExtResource("1_rtuo6") +country_flag = NodePath("SaveList/CountryFlag") +date_label = NodePath("SaveList/DateLabel") +delete_button = NodePath("SaveList/DeleteButton") +background_button = NodePath("BackgroundButton") +name_label = NodePath("SaveList/NameLabel") + +[node name="BackgroundButton" type="Button" parent="."] +layout_mode = 2 +theme_type_variation = &"ButtonContainer" + +[node name="SaveList" type="HBoxContainer" parent="."] +layout_mode = 2 +mouse_filter = 2 + +[node name="CountryFlag" type="TextureRect" parent="SaveList"] +layout_mode = 2 +size_flags_horizontal = 0 +size_flags_vertical = 4 +mouse_filter = 2 + +[node name="NameLabel" type="Label" parent="SaveList"] +layout_mode = 2 +size_flags_horizontal = 0 +size_flags_vertical = 1 +text = "PLACEHOLDER" +vertical_alignment = 1 + +[node name="DateLabel" type="Label" parent="SaveList"] +layout_mode = 2 +size_flags_horizontal = 0 +size_flags_vertical = 1 +text = "00.00.0000" +vertical_alignment = 1 + +[node name="Separator" type="Control" parent="SaveList"] +layout_mode = 2 +size_flags_horizontal = 3 +mouse_filter = 2 + +[node name="DeleteButton" type="Button" parent="SaveList"] +layout_mode = 2 +size_flags_horizontal = 8 +text = "x" + +[connection signal="button_down" from="BackgroundButton" to="." method="_on_background_button_button_down"] +[connection signal="button_up" from="BackgroundButton" to="." method="_on_background_button_button_up"] +[connection signal="pressed" from="BackgroundButton" to="." method="_on_background_button_pressed"] +[connection signal="toggled" from="BackgroundButton" to="." method="_on_background_button_toggled"] +[connection signal="pressed" from="SaveList/DeleteButton" to="." method="_on_delete_button_pressed"] diff --git a/game/src/Game/Menu/SaveLoadMenu/SaveResource.gd b/game/src/Game/Menu/SaveLoadMenu/SaveResource.gd new file mode 100644 index 0000000..5e7faa6 --- /dev/null +++ b/game/src/Game/Menu/SaveLoadMenu/SaveResource.gd @@ -0,0 +1,59 @@ +extends Resource +class_name SaveResource + +signal file_flushed(path : String) +signal file_loaded +signal file_moved_to_trash +signal file_deleted +signal trash_moved +signal deleted + +var save_name : StringName: + get: return save_name + set(v): + save_name = v + file.set_value("Save", "name", save_name) + emit_changed() +var session_tag : StringName: + get: return session_tag + set(v): + session_tag = v + file.set_value("Save", "session_tag", v) + emit_changed() +var file_path : String: + get: return file_path + set(v): + file_path = v + emit_changed() +var file : ConfigFile = ConfigFile.new() + +func set_file_path(name : StringName, path : String): + file_path = path + save_name = name + +func flush_save() -> Error: + file_flushed.emit(file_path) + var result := file.save(file_path) + file.clear() + return result + +func load_save(path : String = file_path) -> Error: + file_loaded.emit() + var result := file.load(path) + session_tag = file.get_value("Save", "session_tag", session_tag) + if path != file_path: + set_file_path(file.get_value("Save", "name", save_name), path) + return result + +func get_save_file_time() -> int: + return FileAccess.get_modified_time(file_path) + +func move_to_trash() -> Error: + trash_moved.emit() + file_moved_to_trash.emit() + return OS.move_to_trash(file_path) + +func delete() -> Error: + deleted.emit() + file_deleted.emit() + return DirAccess.remove_absolute(file_path) diff --git a/game/src/Game/MusicConductor/MusicConductor.gd b/game/src/Game/MusicConductor/MusicConductor.gd new file mode 100644 index 0000000..98dd0eb --- /dev/null +++ b/game/src/Game/MusicConductor/MusicConductor.gd @@ -0,0 +1,77 @@ +extends Node + +# REQUIREMENTS +# * SS-67 +@export_dir var music_directory : String +@export var first_song_name : String + +var _selected_track = 0 +var _available_songs : Array[SongInfo] = [] +var _auto_play_next_song : bool = true + +## True if music player should be visible. +## Used to keep keep consistency between scene changes +var is_music_player_visible : bool = true + +func get_all_song_names() -> Array[String]: + var songNames : Array[String] = [] + for si in _available_songs: + songNames.append(si.song_name) + return songNames + +func get_current_song_index() -> int: + return _selected_track + +func get_current_song_name() -> String: + return _available_songs[_selected_track].song_name + +func scrub_song_by_percentage(percentage: float) -> void: + var percentInSeconds : float = (percentage / 100.0) * $AudioStreamPlayer.stream.get_length() + $AudioStreamPlayer.play(percentInSeconds) + +func get_current_song_progress_percentage() -> float: + return 100 * ($AudioStreamPlayer.get_playback_position() / $AudioStreamPlayer.stream.get_length()) + +func is_paused() -> bool: + return $AudioStreamPlayer.stream_paused + +func toggle_play_pause() -> void: + $AudioStreamPlayer.stream_paused = !$AudioStreamPlayer.stream_paused + +func start_current_song() -> void: + $AudioStreamPlayer.stream = _available_songs[_selected_track].song_stream + $AudioStreamPlayer.play() + +# REQUIREMENTS +# * SS-70 +func start_song_by_index(id: int) -> void: + _selected_track = id + start_current_song() + +# REQUIREMENTS +# * SS-69 +func select_next_song() -> void: + _selected_track = (_selected_track + 1) % len(_available_songs) + start_current_song() + +func select_previous_song() -> void: + _selected_track = (len(_available_songs) - 1) if (_selected_track == 0) else (_selected_track - 1) + start_current_song() + +# REQUIREMENTS +# * SND-2 +func _ready(): + var dir = DirAccess.open(music_directory) + for fname in dir.get_files(): + if fname.ends_with(".import"): + fname = fname.get_basename() + if fname.get_basename() == first_song_name: + _selected_track = _available_songs.size() + _available_songs.append(SongInfo.new(music_directory, fname)) + start_current_song() + + +func _on_audio_stream_player_finished(): + if _auto_play_next_song: + select_next_song() + start_current_song() diff --git a/game/src/Game/MusicConductor/MusicConductor.tscn b/game/src/Game/MusicConductor/MusicConductor.tscn new file mode 100644 index 0000000..182de99 --- /dev/null +++ b/game/src/Game/MusicConductor/MusicConductor.tscn @@ -0,0 +1,13 @@ +[gd_scene load_steps=2 format=3 uid="uid://b1h31mnn8n2nu"] + +[ext_resource type="Script" path="res://src/MusicConductor/MusicConductor.gd" id="1_56t1b"] + +[node name="MusicConductor" type="Node"] +script = ExtResource("1_56t1b") +music_directory = "res://audio/music" +first_song_name = "The_Crown" + +[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."] +bus = &"MUSIC_BUS" + +[connection signal="finished" from="AudioStreamPlayer" to="." method="_on_audio_stream_player_finished"] diff --git a/game/src/Game/MusicConductor/MusicPlayer.gd b/game/src/Game/MusicConductor/MusicPlayer.gd new file mode 100644 index 0000000..47be158 --- /dev/null +++ b/game/src/Game/MusicConductor/MusicPlayer.gd @@ -0,0 +1,73 @@ +extends Control + +@export var _song_selector_button : OptionButton +@export var _progress_slider : HSlider +@export var _previous_song_button : Button +@export var _play_pause_button : Button +@export var _next_song_button : Button +@export var _visbility_button : Button + +var _is_user_dragging_progress_slider : bool = false + +func _ready(): + for songName in MusicConductor.get_all_song_names(): + _song_selector_button.add_item(songName, _song_selector_button.item_count) + _update_song_name_visual() + _update_play_pause_button() + _set_music_player_visible(MusicConductor.is_music_player_visible) + + +func _process(_delta): + if !_is_user_dragging_progress_slider: + _progress_slider.value = MusicConductor.get_current_song_progress_percentage() + +func _update_song_name_visual(): + _song_selector_button.selected = MusicConductor.get_current_song_index() + +func _update_play_pause_button(): + _play_pause_button.text = "◼" if MusicConductor.is_paused() else "▶" + +func _on_play_pause_button_pressed(): + MusicConductor.toggle_play_pause() + _update_play_pause_button() + +func _on_next_song_button_pressed(): + MusicConductor.select_next_song() + _update_song_name_visual() + _update_play_pause_button() + +func _on_previous_song_button_pressed(): + MusicConductor.select_previous_song() + _update_song_name_visual() + _update_play_pause_button() + +# REQUIREMENTS +# * UIFUN-92 +func _on_option_button_item_selected(index): + MusicConductor.start_song_by_index(index) + _update_song_name_visual() + _update_play_pause_button() + + +func _on_progress_slider_drag_started(): + _is_user_dragging_progress_slider = true + + +func _on_progress_slider_drag_ended(_value_changed): + MusicConductor.scrub_song_by_percentage(_progress_slider.value) + _is_user_dragging_progress_slider = false + _update_play_pause_button() + +func _set_music_player_visible(is_player_visible : bool) -> void: + MusicConductor.is_music_player_visible = is_player_visible + _visbility_button.text = "⬆️" if is_player_visible else "⬇" + _song_selector_button.visible = is_player_visible + _progress_slider.visible = is_player_visible + _previous_song_button.visible = is_player_visible + _play_pause_button.visible = is_player_visible + _next_song_button.visible = is_player_visible + +# REQUIREMENTS +# * UIFUN-91 +func _on_music_ui_visibility_button_pressed(): + _set_music_player_visible(not MusicConductor.is_music_player_visible) diff --git a/game/src/Game/MusicConductor/MusicPlayer.tscn b/game/src/Game/MusicConductor/MusicPlayer.tscn new file mode 100644 index 0000000..80ad641 --- /dev/null +++ b/game/src/Game/MusicConductor/MusicPlayer.tscn @@ -0,0 +1,63 @@ +[gd_scene load_steps=2 format=3 uid="uid://cvl76duuym1wq"] + +[ext_resource type="Script" path="res://src/MusicConductor/MusicPlayer.gd" id="1_gcm4m"] + +[node name="MusicPlayer" type="BoxContainer" node_paths=PackedStringArray("_song_selector_button", "_progress_slider", "_previous_song_button", "_play_pause_button", "_next_song_button", "_visbility_button")] +editor_description = "UI-104" +offset_right = 150.0 +offset_bottom = 110.0 +mouse_filter = 2 +vertical = true +script = ExtResource("1_gcm4m") +_song_selector_button = NodePath("SongSelectorButton") +_progress_slider = NodePath("ProgressSlider") +_previous_song_button = NodePath("ButtonList/PreviousSongButton") +_play_pause_button = NodePath("ButtonList/PlayPauseButton") +_next_song_button = NodePath("ButtonList/NextSongButton") +_visbility_button = NodePath("MusicUIVisibilityButton") + +[node name="SongSelectorButton" type="OptionButton" parent="."] +editor_description = "UI-107" +custom_minimum_size = Vector2(150, 0) +layout_mode = 2 +alignment = 1 +text_overrun_behavior = 3 +fit_to_longest_item = false + +[node name="ProgressSlider" type="HSlider" parent="."] +custom_minimum_size = Vector2(150, 0) +layout_mode = 2 +size_flags_vertical = 1 + +[node name="ButtonList" type="HBoxContainer" parent="."] +layout_mode = 2 +size_flags_horizontal = 4 +mouse_filter = 2 + +[node name="PreviousSongButton" type="Button" parent="ButtonList"] +layout_mode = 2 +text = "<" + +[node name="PlayPauseButton" type="Button" parent="ButtonList"] +custom_minimum_size = Vector2(30, 0) +layout_mode = 2 +text = "▶" + +[node name="NextSongButton" type="Button" parent="ButtonList"] +layout_mode = 2 +text = ">" + +[node name="MusicUIVisibilityButton" type="Button" parent="."] +editor_description = "UI-106" +layout_mode = 2 +size_flags_horizontal = 4 +toggle_mode = true +text = "⬆" + +[connection signal="item_selected" from="SongSelectorButton" to="." method="_on_option_button_item_selected"] +[connection signal="drag_ended" from="ProgressSlider" to="." method="_on_progress_slider_drag_ended"] +[connection signal="drag_started" from="ProgressSlider" to="." method="_on_progress_slider_drag_started"] +[connection signal="pressed" from="ButtonList/PreviousSongButton" to="." method="_on_previous_song_button_pressed"] +[connection signal="pressed" from="ButtonList/PlayPauseButton" to="." method="_on_play_pause_button_pressed"] +[connection signal="pressed" from="ButtonList/NextSongButton" to="." method="_on_next_song_button_pressed"] +[connection signal="pressed" from="MusicUIVisibilityButton" to="." method="_on_music_ui_visibility_button_pressed"] diff --git a/game/src/Game/MusicConductor/SongInfo.gd b/game/src/Game/MusicConductor/SongInfo.gd new file mode 100644 index 0000000..1ee9adc --- /dev/null +++ b/game/src/Game/MusicConductor/SongInfo.gd @@ -0,0 +1,11 @@ +extends Resource +class_name SongInfo + +var song_path : String = "" +var song_name : String = "" +var song_stream : Resource + +func _init(dirname:String, fname:String): + song_path = dirname.path_join(fname) + song_name = fname.get_basename().replace("_", " ") + song_stream = load(song_path) diff --git a/game/src/Game/SplashContainer.gd b/game/src/Game/SplashContainer.gd new file mode 100644 index 0000000..524d314 --- /dev/null +++ b/game/src/Game/SplashContainer.gd @@ -0,0 +1,30 @@ +extends Control + +signal splash_end + +@export var _splash_finish : TextureRect +@export var _splash_image : TextureRect +@export var _splash_video : VideoStreamPlayer + +func _process(_delta): + var stream_texture := _splash_video.get_video_texture() + if stream_texture != null and not stream_texture.get_image().is_invisible(): + _splash_image.hide() + _splash_finish.show() + set_process(false) + +func _input(event): + if (event is InputEventKey\ + or event is InputEventMouse\ + or event is InputEventScreenTouch\ + or event is InputEventJoypadButton) and event.is_pressed(): + _splash_finish.hide() + _on_splash_startup_finished() + accept_event() + +func _on_splash_startup_finished(): + set_process_input(false) + splash_end.emit() + var tween := create_tween() + tween.tween_property(self, "modulate:a", 0, 0.5) + tween.tween_callback(self.queue_free) diff --git a/game/src/Game/Theme/StyleBoxCombinedTexture.gd b/game/src/Game/Theme/StyleBoxCombinedTexture.gd new file mode 100644 index 0000000..db54da4 --- /dev/null +++ b/game/src/Game/Theme/StyleBoxCombinedTexture.gd @@ -0,0 +1,47 @@ +@tool +extends StyleBox +class_name StyleBoxCombinedTexture + +@export +var texture_settings : Array[TextureSetting] = []: + get: return texture_settings.duplicate() + set(v): + texture_settings = v + for setting in texture_settings: + setting.changed.connect(emit_changed) + emit_changed() + +func _get_draw_rect(rect : Rect2) -> Rect2: + var combined_rect : Rect2 = Rect2() + for setting in texture_settings: + if combined_rect.position.x > setting.expand_margin_left: + combined_rect.position.x = setting.expand_margin_left + if combined_rect.position.y > setting.expand_margin_top: + combined_rect.position.y = setting.expand_margin_top + if combined_rect.end.x < setting.expand_margin_right: + combined_rect.end.x = setting.expand_margin_right + if combined_rect.end.y < setting.expand_margin_bottom: + combined_rect.end.y = setting.expand_margin_bottom + return rect.grow_individual(combined_rect.position.x, combined_rect.position.y, combined_rect.end.x, combined_rect.end.y) + +func _draw(to_canvas_item : RID, rect : Rect2) -> void: + for setting in texture_settings: + if setting == null or setting.texture == null: + continue + var inner_rect : Rect2 = rect + inner_rect.position.x -= setting.expand_margin_left + inner_rect.position.y -= setting.expand_margin_top + inner_rect.size.x += setting.expand_margin_left + setting.expand_margin_right + inner_rect.size.y += setting.expand_margin_top + setting.expand_margin_bottom + RenderingServer.canvas_item_add_nine_patch( + to_canvas_item, + inner_rect, + setting.region_rect, + setting.texture.get_rid(), + Vector2(setting.texture_margin_left, setting.texture_margin_top), + Vector2(setting.texture_margin_right, setting.texture_margin_bottom), + setting.axis_stretch_horizontal, + setting.axis_stretch_vertical, + setting.draw_center, + setting.modulate_color + ) diff --git a/game/src/Game/Theme/StyleBoxWithSound.gd b/game/src/Game/Theme/StyleBoxWithSound.gd new file mode 100644 index 0000000..8c29b34 --- /dev/null +++ b/game/src/Game/Theme/StyleBoxWithSound.gd @@ -0,0 +1,34 @@ +## WARNING: This will not work with togglable UI elements, a special implementation is needed for them. +@tool +extends StyleBox +class_name StyleBoxWithSound + +@export +var style_box : StyleBox: + get: return style_box + set(v): + style_box = v + emit_changed() + +@export +var sound : AudioStream: + get: return sound + set(v): + sound = v + emit_changed() + +func _get_draw_rect(rect : Rect2) -> Rect2: + if style_box == null: return Rect2() + return style_box._get_draw_rect(rect) + +func _draw(to_canvas_item : RID, rect : Rect2) -> void: + # This is a hack + # Works fine for simple non-normal style cases + # Normal styles being drawn immediately tho will trigger sound on startup + # This would require further work to be applicable for release sounds + # Is there any other reason aside from release sounds (might be useful for toggles?) + # This should be fast enough to not cause draw issues + if sound != null: + SoundManager.play_effect_stream(sound) + if style_box != null: + style_box.draw(to_canvas_item, rect) diff --git a/game/src/Game/Theme/TextureSetting.gd b/game/src/Game/Theme/TextureSetting.gd new file mode 100644 index 0000000..da9b185 --- /dev/null +++ b/game/src/Game/Theme/TextureSetting.gd @@ -0,0 +1,123 @@ +extends Resource +class_name TextureSetting + +@export +var texture : Texture2D: + get: return texture + set(v): + texture = v + emit_changed() +@export +var draw_center : bool = true: + get: return draw_center + set(v): + draw_center = v + emit_changed() + +@export_group("Texture Margins", "texture_margin_") +@export +var texture_margin_left : float = 0: + get: return texture_margin_left + set(v): + texture_margin_left = v + emit_changed() +@export +var texture_margin_top : float = 0: + get: return texture_margin_top + set(v): + texture_margin_top = v + emit_changed() +@export +var texture_margin_right : float = 0: + get: return texture_margin_right + set(v): + texture_margin_right = v + emit_changed() +@export +var texture_margin_bottom : float = 0: + get: return texture_margin_bottom + set(v): + texture_margin_bottom = v + emit_changed() + +@export_group("Expand Margins", "expand_margin_") +@export +var expand_margin_left : float = 0: + get: return expand_margin_left + set(v): + expand_margin_left = v + emit_changed() +@export +var expand_margin_top : float = 0: + get: return expand_margin_top + set(v): + expand_margin_top = v + emit_changed() +@export +var expand_margin_right : float = 0: + get: return expand_margin_right + set(v): + expand_margin_right = v + emit_changed() +@export +var expand_margin_bottom : float = 0: + get: return expand_margin_bottom + set(v): + expand_margin_bottom = v + emit_changed() + +@export_group("Axis Stretch", "axis_stretch_") +@export +var axis_stretch_horizontal : RenderingServer.NinePatchAxisMode = RenderingServer.NINE_PATCH_STRETCH: + get: return axis_stretch_horizontal + set(v): + axis_stretch_horizontal = v + emit_changed() +@export +var axis_stretch_vertical : RenderingServer.NinePatchAxisMode = RenderingServer.NINE_PATCH_STRETCH: + get: return axis_stretch_vertical + set(v): + axis_stretch_vertical = v + emit_changed() + +@export_group("Sub-Region", "region_") +@export +var region_rect : Rect2 = Rect2(0, 0, 0, 0): + get: return region_rect + set(v): + region_rect = v + emit_changed() + +@export_group("Modulate", "modulate_") +@export +var modulate_color : Color = Color(1, 1, 1, 1): + get: return modulate_color + set(v): + modulate_color = v + emit_changed() + +@export_group("Content Margins", "content_margin_") +@export +var content_margin_left : float = -1: + get: return content_margin_left + set(v): + content_margin_left = v + emit_changed() +@export +var content_margin_top : float = -1: + get: return content_margin_top + set(v): + content_margin_top = v + emit_changed() +@export +var content_margin_right : float = -1: + get: return content_margin_right + set(v): + content_margin_right = v + emit_changed() +@export +var content_margin_bottom : float = -1: + get: return content_margin_bottom + set(v): + content_margin_bottom = v + emit_changed() diff --git a/game/src/GameMenu.gd b/game/src/GameMenu.gd deleted file mode 100644 index 4b589f9..0000000 --- a/game/src/GameMenu.gd +++ /dev/null @@ -1,47 +0,0 @@ -extends Control - -@export var _main_menu : Control -@export var _options_menu : Control -@export var _lobby_menu : Control -@export var _credits_menu : Control - -# REQUIREMENTS -# * SS-10 -func _ready(): - Events.Options.load_settings_from_file() - -func _on_main_menu_new_game_button_pressed(): - _lobby_menu.show() - _main_menu.hide() - -# REQUIREMENTS -# * SS-6 -# * UIFUN-5 -func _on_main_menu_options_button_pressed(): - _options_menu.show() - _main_menu.hide() - - -func _on_options_menu_back_button_pressed(): - _main_menu.show() - _options_menu.hide() - - -func _on_lobby_menu_back_button_pressed(): - _main_menu.show() - _lobby_menu.hide() - - -func _on_credits_back_button_pressed(): - _credits_menu.hide() - _main_menu.show() - - -func _on_main_menu_credits_button_pressed(): - _credits_menu.show() - _main_menu.hide() - - - -func _on_splash_container_splash_end(): - show() diff --git a/game/src/GameMenu.tscn b/game/src/GameMenu.tscn deleted file mode 100644 index 224ae2e..0000000 --- a/game/src/GameMenu.tscn +++ /dev/null @@ -1,53 +0,0 @@ -[gd_scene load_steps=7 format=3 uid="uid://o4u142w4qkln"] - -[ext_resource type="Script" path="res://src/GameMenu.gd" id="1_cafwe"] -[ext_resource type="PackedScene" uid="uid://bp5n3mlu45ygw" path="res://src/MainMenu/MainMenu.tscn" id="2_2jbkh"] -[ext_resource type="PackedScene" uid="uid://cnbfxjy1m6wja" path="res://src/OptionMenu/OptionsMenu.tscn" id="3_111lv"] -[ext_resource type="PackedScene" uid="uid://c8knthxkwj1uj" path="res://src/CreditsMenu/CreditsMenu.tscn" id="4_n0hoo"] -[ext_resource type="PackedScene" uid="uid://do60kx0d3nrh4" path="res://src/LobbyMenu/LobbyMenu.tscn" id="4_nofk1"] -[ext_resource type="PackedScene" uid="uid://cvl76duuym1wq" path="res://src/MusicConductor/MusicPlayer.tscn" id="6_lts1m"] - -[node name="GameMenu" type="Control" node_paths=PackedStringArray("_main_menu", "_options_menu", "_lobby_menu", "_credits_menu")] -layout_mode = 3 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 -script = ExtResource("1_cafwe") -_main_menu = NodePath("MainMenu") -_options_menu = NodePath("OptionsMenu") -_lobby_menu = NodePath("LobbyMenu") -_credits_menu = NodePath("CreditsMenu") - -[node name="MainMenu" parent="." instance=ExtResource("2_2jbkh")] -layout_mode = 1 -metadata/_edit_vertical_guides_ = [251.0, 269.0, 504.0, 523.0, 15.0, 759.0, 777.0] - -[node name="OptionsMenu" parent="." instance=ExtResource("3_111lv")] -visible = false -layout_mode = 1 - -[node name="LobbyMenu" parent="." instance=ExtResource("4_nofk1")] -visible = false -layout_mode = 1 - -[node name="CreditsMenu" parent="." instance=ExtResource("4_n0hoo")] -visible = false -layout_mode = 1 - -[node name="MusicPlayer" parent="." instance=ExtResource("6_lts1m")] -layout_mode = 1 -anchors_preset = 1 -anchor_left = 1.0 -anchor_right = 1.0 -offset_left = -184.0 -offset_right = -34.0 -grow_horizontal = 0 - -[connection signal="credits_button_pressed" from="MainMenu" to="." method="_on_main_menu_credits_button_pressed"] -[connection signal="new_game_button_pressed" from="MainMenu" to="." method="_on_main_menu_new_game_button_pressed"] -[connection signal="options_button_pressed" from="MainMenu" to="." method="_on_main_menu_options_button_pressed"] -[connection signal="back_button_pressed" from="OptionsMenu" to="." method="_on_options_menu_back_button_pressed"] -[connection signal="back_button_pressed" from="LobbyMenu" to="." method="_on_lobby_menu_back_button_pressed"] -[connection signal="back_button_pressed" from="CreditsMenu" to="." method="_on_credits_back_button_pressed"] diff --git a/game/src/GameSession/GameSession.gd b/game/src/GameSession/GameSession.gd deleted file mode 100644 index 5bb1c2f..0000000 --- a/game/src/GameSession/GameSession.gd +++ /dev/null @@ -1,16 +0,0 @@ -extends Control - -@export var _game_session_menu : Control - -func _ready(): - Events.Options.load_settings_from_file() - if GameSingleton.setup_game() != OK: - push_error("Failed to setup game") - -func _process(delta : float): - GameSingleton.try_tick() - -# REQUIREMENTS: -# * SS-42 -func _on_game_session_menu_button_pressed() -> void: - _game_session_menu.visible = !_game_session_menu.visible diff --git a/game/src/GameSession/GameSession.tscn b/game/src/GameSession/GameSession.tscn deleted file mode 100644 index 188ccde..0000000 --- a/game/src/GameSession/GameSession.tscn +++ /dev/null @@ -1,95 +0,0 @@ -[gd_scene load_steps=10 format=3 uid="uid://bgnupcshe1m7r"] - -[ext_resource type="Script" path="res://src/GameSession/GameSession.gd" id="1_eklvp"] -[ext_resource type="PackedScene" uid="uid://cvl76duuym1wq" path="res://src/MusicConductor/MusicPlayer.tscn" id="2_kt6aa"] -[ext_resource type="PackedScene" uid="uid://g524p8lr574w" path="res://src/GameSession/MapControlPanel/MapControlPanel.tscn" id="3_afh6d"] -[ext_resource type="PackedScene" uid="uid://dvdynl6eir40o" path="res://src/GameSession/GameSessionMenu.tscn" id="3_bvmqh"] -[ext_resource type="PackedScene" uid="uid://dkehmdnuxih2r" path="res://src/GameSession/MapView.tscn" id="4_xkg5j"] -[ext_resource type="PackedScene" uid="uid://byq323jbel48u" path="res://src/GameSession/ProvinceOverviewPanel/ProvinceOverviewPanel.tscn" id="5_osjnn"] -[ext_resource type="PackedScene" uid="uid://cnbfxjy1m6wja" path="res://src/OptionMenu/OptionsMenu.tscn" id="6_p5mnx"] -[ext_resource type="PackedScene" uid="uid://dd8k3p7r3huwc" path="res://src/GameSession/GameSpeedPanel.tscn" id="7_myy4q"] -[ext_resource type="PackedScene" uid="uid://d3g6wbvwflmyk" path="res://src/SaveLoadMenu/SaveLoadMenu.tscn" id="8_4g7ko"] - -[node name="GameSession" type="Control" node_paths=PackedStringArray("_game_session_menu")] -editor_description = "SS-102, UI-546" -layout_mode = 3 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 -mouse_filter = 2 -script = ExtResource("1_eklvp") -_game_session_menu = NodePath("GameSessionMenu") - -[node name="MapView" parent="." instance=ExtResource("4_xkg5j")] - -[node name="MapControlPanel" parent="." instance=ExtResource("3_afh6d")] -layout_mode = 1 -anchors_preset = 3 -anchor_left = 1.0 -anchor_top = 1.0 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 0 -grow_vertical = 0 - -[node name="ProvinceOverviewPanel" parent="." instance=ExtResource("5_osjnn")] -layout_mode = 1 - -[node name="GameSpeedPanel" parent="." instance=ExtResource("7_myy4q")] -layout_mode = 0 -offset_right = 302.0 -offset_bottom = 31.0 - -[node name="GameSessionMenu" parent="." instance=ExtResource("3_bvmqh")] -visible = false -layout_mode = 1 -anchors_preset = 8 -anchor_left = 0.5 -anchor_top = 0.5 -anchor_right = 0.5 -anchor_bottom = 0.5 -offset_left = -159.0 -offset_top = -165.0 -offset_right = 159.0 -offset_bottom = 165.0 -grow_horizontal = 2 -grow_vertical = 2 - -[node name="OptionsMenu" parent="." instance=ExtResource("6_p5mnx")] -visible = false -layout_mode = 1 - -[node name="SaveLoadMenu" parent="." instance=ExtResource("8_4g7ko")] -visible = false -layout_mode = 1 -anchors_preset = -1 -anchor_left = 0.5 -anchor_right = 0.5 -offset_left = -640.0 -offset_right = 640.0 - -[node name="MusicPlayer" parent="." instance=ExtResource("2_kt6aa")] -layout_mode = 1 -anchors_preset = 1 -anchor_left = 1.0 -anchor_right = 1.0 -offset_left = -150.0 -offset_right = 0.0 -grow_horizontal = 0 - -[connection signal="map_view_camera_changed" from="MapView" to="MapControlPanel" method="_on_map_view_camera_changed"] -[connection signal="game_session_menu_button_pressed" from="MapControlPanel" to="." method="_on_game_session_menu_button_pressed"] -[connection signal="minimap_clicked" from="MapControlPanel" to="MapView" method="_on_minimap_clicked"] -[connection signal="mouse_entered" from="MapControlPanel" to="MapView" method="_on_mouse_exited_viewport"] -[connection signal="mouse_exited" from="MapControlPanel" to="MapView" method="_on_mouse_entered_viewport"] -[connection signal="zoom_in_button_pressed" from="MapControlPanel" to="MapView" method="zoom_in"] -[connection signal="zoom_out_button_pressed" from="MapControlPanel" to="MapView" method="zoom_out"] -[connection signal="mouse_entered" from="ProvinceOverviewPanel" to="MapView" method="_on_mouse_exited_viewport"] -[connection signal="mouse_exited" from="ProvinceOverviewPanel" to="MapView" method="_on_mouse_entered_viewport"] -[connection signal="load_button_pressed" from="GameSessionMenu" to="SaveLoadMenu" method="show_for_load"] -[connection signal="options_button_pressed" from="GameSessionMenu" to="OptionsMenu" method="show"] -[connection signal="save_button_pressed" from="GameSessionMenu" to="SaveLoadMenu" method="show_for_save"] -[connection signal="back_button_pressed" from="OptionsMenu" to="MapView" method="enable_processing"] -[connection signal="back_button_pressed" from="OptionsMenu" to="OptionsMenu" method="hide"] diff --git a/game/src/GameSession/GameSessionMenu.gd b/game/src/GameSession/GameSessionMenu.gd deleted file mode 100644 index 23ef2ef..0000000 --- a/game/src/GameSession/GameSessionMenu.gd +++ /dev/null @@ -1,80 +0,0 @@ -extends PanelContainer - -@export var _main_menu_scene : PackedScene - -@export var _main_menu_dialog : AcceptDialog -@export var _quit_dialog : AcceptDialog - -var _main_menu_save_button : Button -var _main_menu_save_separator : Control -var _quit_save_button : Button -var _quit_save_separator : Control - -signal save_button_pressed -signal load_button_pressed -signal options_button_pressed - -func _ready() -> void: - _main_menu_save_button = _main_menu_dialog.add_button("DIALOG_SAVE_AND_RESIGN", true, &"save_and_main_menu") - _quit_save_button = _quit_dialog.add_button("DIALOG_SAVE_AND_QUIT", true, &"save_and_quit") - - # Neccessary to center the save buttons and preserve the reference to the separator elements - var dialog_hbox : HBoxContainer = _main_menu_dialog.get_child(2, true) - var index := _main_menu_save_button.get_index(true) - dialog_hbox.move_child(_main_menu_save_button, _main_menu_dialog.get_ok_button().get_index(true)) - dialog_hbox.move_child(_main_menu_dialog.get_ok_button(), index) - _main_menu_save_separator = dialog_hbox.get_child(_main_menu_save_button.get_index(true) - 1) - - dialog_hbox = _quit_dialog.get_child(2, true) - index = _quit_save_button.get_index(true) - dialog_hbox.move_child(_quit_save_button, _quit_dialog.get_ok_button().get_index(true)) - dialog_hbox.move_child(_quit_dialog.get_ok_button(), index) - _quit_save_separator = dialog_hbox.get_child(_quit_save_button.get_index(true) - 1) - -func hide_save_dialog_button() -> void: - _main_menu_save_button.hide() - _main_menu_save_separator.hide() - _quit_save_button.hide() - _quit_save_separator.hide() - -func show_save_dialog_button() -> void: - _main_menu_save_button.show() - _main_menu_save_separator.show() - _quit_save_button.show() - _quit_save_separator.show() - -# REQUIREMENTS: -# * SS-47 -# * UIFUN-69 -func _on_main_menu_confirmed() -> void: - SaveManager.current_session_tag = "" - SaveManager.current_save = null - get_tree().change_scene_to_packed(_main_menu_scene) - -# REQUIREMENTS: -# * SS-48 -# * UIFUN-70 -func _on_quit_confirmed() -> void: - get_tree().quit() - -# REQUIREMENTS: -# * SS-7, SS-46 -# * UIFUN-11 -func _on_options_button_pressed() -> void: - options_button_pressed.emit() - -func _on_main_menu_dialog_custom_action(action) -> void: - match action: - &"save_and_main_menu": - _on_main_menu_confirmed() - -func _on_quit_dialog_custom_action(action : StringName) -> void: - match action: - &"save_and_quit": - _on_quit_confirmed() - -func _on_save_button_pressed(): - save_button_pressed.emit() - -func _on_load_button_pressed(): - load_button_pressed.emit() diff --git a/game/src/GameSession/GameSessionMenu.tscn b/game/src/GameSession/GameSessionMenu.tscn deleted file mode 100644 index 025ef3b..0000000 --- a/game/src/GameSession/GameSessionMenu.tscn +++ /dev/null @@ -1,91 +0,0 @@ -[gd_scene load_steps=4 format=3 uid="uid://dvdynl6eir40o"] - -[ext_resource type="Theme" uid="uid://cqrfmjt5yeti7" path="res://theme/game_session_menu.tres" id="1_2onog"] -[ext_resource type="Script" path="res://src/GameSession/GameSessionMenu.gd" id="1_usq6o"] -[ext_resource type="PackedScene" uid="uid://o4u142w4qkln" path="res://src/GameMenu.tscn" id="2_xi6a4"] - -[node name="GameSessionMenu" type="PanelContainer" node_paths=PackedStringArray("_main_menu_dialog", "_quit_dialog")] -process_mode = 3 -editor_description = "UI-68" -theme = ExtResource("1_2onog") -theme_type_variation = &"SessionPanel" -script = ExtResource("1_usq6o") -_main_menu_scene = ExtResource("2_xi6a4") -_main_menu_dialog = NodePath("MainMenuDialog") -_quit_dialog = NodePath("QuitDialog") - -[node name="ButtonListMargin" type="MarginContainer" parent="."] -layout_mode = 2 -theme_override_constants/margin_left = 10 -theme_override_constants/margin_top = 10 -theme_override_constants/margin_right = 10 -theme_override_constants/margin_bottom = 10 - -[node name="ButtonList" type="VBoxContainer" parent="ButtonListMargin"] -layout_mode = 2 - -[node name="SaveButton" type="Button" parent="ButtonListMargin/ButtonList"] -editor_description = "UI-69" -layout_mode = 2 -theme_type_variation = &"SessionButton" -text = "GAMESESSIONMENU_SAVE" - -[node name="LoadButton" type="Button" parent="ButtonListMargin/ButtonList"] -editor_description = "UI-70" -layout_mode = 2 -theme_type_variation = &"SessionButton" -text = "GAMESESSIONMENU_LOAD" - -[node name="OptionsButton" type="Button" parent="ButtonListMargin/ButtonList"] -editor_description = "UI-10" -layout_mode = 2 -theme_type_variation = &"SessionButton" -text = "GAMESESSIONMENU_OPTIONS" - -[node name="MainMenuButton" type="Button" parent="ButtonListMargin/ButtonList"] -editor_description = "UI-71" -layout_mode = 2 -theme_type_variation = &"SessionButton" -text = "GAMESESSIONMENU_MAINMENU" - -[node name="QuitButton" type="Button" parent="ButtonListMargin/ButtonList"] -editor_description = "UI-72" -layout_mode = 2 -theme_type_variation = &"SessionButton" -text = "GAMESESSIONMENU_QUIT" - -[node name="CloseSeparator" type="HSeparator" parent="ButtonListMargin/ButtonList"] -layout_mode = 2 -theme_type_variation = &"SessionSeparator" - -[node name="CloseButton" type="Button" parent="ButtonListMargin/ButtonList"] -editor_description = "SS-64, UI-80, UIFUN-79" -layout_mode = 2 -theme_type_variation = &"SessionButton" -text = "GAMESESSIONMENU_CLOSE" - -[node name="MainMenuDialog" type="ConfirmationDialog" parent="."] -disable_3d = true -title = "GAMESESSIONMENU_MAINMENU_DIALOG_TITLE" -size = Vector2i(384, 100) -ok_button_text = "DIALOG_OK" -dialog_text = "GAMESESSIONMENU_MAINMENU_DIALOG_TEXT" -cancel_button_text = "DIALOG_CANCEL" - -[node name="QuitDialog" type="ConfirmationDialog" parent="."] -disable_3d = true -title = "GAMESESSIONMENU_QUIT_DIALOG_TITLE" -ok_button_text = "DIALOG_OK" -dialog_text = "GAMESESSIONMENU_QUIT_DIALOG_TEXT" -cancel_button_text = "DIALOG_CANCEL" - -[connection signal="pressed" from="ButtonListMargin/ButtonList/SaveButton" to="." method="_on_save_button_pressed"] -[connection signal="pressed" from="ButtonListMargin/ButtonList/LoadButton" to="." method="_on_load_button_pressed"] -[connection signal="pressed" from="ButtonListMargin/ButtonList/OptionsButton" to="." method="_on_options_button_pressed"] -[connection signal="pressed" from="ButtonListMargin/ButtonList/MainMenuButton" to="MainMenuDialog" method="popup_centered"] -[connection signal="pressed" from="ButtonListMargin/ButtonList/QuitButton" to="QuitDialog" method="popup_centered"] -[connection signal="pressed" from="ButtonListMargin/ButtonList/CloseButton" to="." method="hide"] -[connection signal="confirmed" from="MainMenuDialog" to="." method="_on_main_menu_confirmed"] -[connection signal="custom_action" from="MainMenuDialog" to="." method="_on_main_menu_dialog_custom_action"] -[connection signal="confirmed" from="QuitDialog" to="." method="_on_quit_confirmed"] -[connection signal="custom_action" from="QuitDialog" to="." method="_on_quit_dialog_custom_action"] diff --git a/game/src/GameSession/GameSpeedPanel.gd b/game/src/GameSession/GameSpeedPanel.gd deleted file mode 100644 index 80708b1..0000000 --- a/game/src/GameSession/GameSpeedPanel.gd +++ /dev/null @@ -1,37 +0,0 @@ -extends PanelContainer - -#UI-74 UI-75 UI-76 UI-77 - -@export var _longform_date_button : Button -@export var _play_pause_display_button : Button -@export var _decrease_speed_button : Button -@export var _increase_speed_button : Button - -func _ready(): - 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() - - _longform_date_button.text = GameSingleton.get_longform_date() - - -func _on_decrease_speed_button_pressed(): - GameSingleton.decrease_speed() - _update_buttons() - -func _on_increase_speed_button_pressed(): - GameSingleton.increase_speed() - _update_buttons() - -func _on_play_pause_display_button_pressed(): - GameSingleton.toggle_paused() - _update_buttons() - -func _on_longform_date_label_pressed(): - GameSingleton.toggle_paused() - _update_buttons() diff --git a/game/src/GameSession/GameSpeedPanel.tscn b/game/src/GameSession/GameSpeedPanel.tscn deleted file mode 100644 index 8a37565..0000000 --- a/game/src/GameSession/GameSpeedPanel.tscn +++ /dev/null @@ -1,38 +0,0 @@ -[gd_scene load_steps=2 format=3 uid="uid://dd8k3p7r3huwc"] - -[ext_resource type="Script" path="res://src/GameSession/GameSpeedPanel.gd" id="1_pfs8t"] - -[node name="GameSpeedPanel" type="PanelContainer" node_paths=PackedStringArray("_longform_date_button", "_play_pause_display_button", "_decrease_speed_button", "_increase_speed_button")] -script = ExtResource("1_pfs8t") -_longform_date_button = NodePath("ButtonList/LongformDateButton") -_play_pause_display_button = NodePath("ButtonList/PlayPauseDisplayButton") -_decrease_speed_button = NodePath("ButtonList/DecreaseSpeedButton") -_increase_speed_button = NodePath("ButtonList/IncreaseSpeedButton") - -[node name="ButtonList" type="HBoxContainer" parent="."] -layout_mode = 2 - -[node name="LongformDateButton" type="Button" parent="ButtonList"] -custom_minimum_size = Vector2(200, 0) -layout_mode = 2 -text = "LONGFORM DATE" - -[node name="PlayPauseDisplayButton" type="Button" parent="ButtonList"] -custom_minimum_size = Vector2(30, 0) -layout_mode = 2 -text = "⏸ " - -[node name="DecreaseSpeedButton" type="Button" parent="ButtonList"] -custom_minimum_size = Vector2(30, 0) -layout_mode = 2 -text = "-" - -[node name="IncreaseSpeedButton" type="Button" parent="ButtonList"] -custom_minimum_size = Vector2(30, 0) -layout_mode = 2 -text = "+" - -[connection signal="pressed" from="ButtonList/LongformDateButton" to="." method="_on_longform_date_label_pressed"] -[connection signal="pressed" from="ButtonList/PlayPauseDisplayButton" to="." method="_on_play_pause_display_button_pressed"] -[connection signal="pressed" from="ButtonList/DecreaseSpeedButton" to="." method="_on_decrease_speed_button_pressed"] -[connection signal="pressed" from="ButtonList/IncreaseSpeedButton" to="." method="_on_increase_speed_button_pressed"] diff --git a/game/src/GameSession/MapControlPanel/MapControlPanel.gd b/game/src/GameSession/MapControlPanel/MapControlPanel.gd deleted file mode 100644 index 0cef057..0000000 --- a/game/src/GameSession/MapControlPanel/MapControlPanel.gd +++ /dev/null @@ -1,57 +0,0 @@ -extends PanelContainer - -signal game_session_menu_button_pressed -signal map_view_camera_changed(near_left : Vector2, far_left : Vector2, far_right : Vector2, near_right : Vector2) -signal minimap_clicked(pos_clicked : Vector2) -signal zoom_in_button_pressed -signal zoom_out_button_pressed - -@export var _mapmodes_grid : GridContainer - -var _mapmode_button_group : ButtonGroup - -# REQUIREMENTS: -# * UI-550, UI-552, UI-554, UI-561 -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 - button.mouse_filter = MOUSE_FILTER_PASS - _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 GameSingleton.get_mapmode_count(): - _add_mapmode_button(GameSingleton.get_mapmode_identifier(index)) - -# REQUIREMENTS: -# * UIFUN-10 -func _on_game_session_menu_button_pressed() -> void: - game_session_menu_button_pressed.emit() - -# REQUIREMENTS: -# * SS-76 -# * UIFUN-129, UIFUN-131, UIFUN-133 -func _mapmode_pressed(button : BaseButton) -> void: - GameSingleton.set_mapmode(button.tooltip_text) - -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) - -# REQUIREMENTS: -# * UIFUN-269 -func _on_zoom_in_button_pressed() -> void: - zoom_in_button_pressed.emit() - -# REQUIREMENTS: -# * UIFUN-270 -func _on_zoom_out_button_pressed() -> void: - zoom_out_button_pressed.emit() diff --git a/game/src/GameSession/MapControlPanel/MapControlPanel.tscn b/game/src/GameSession/MapControlPanel/MapControlPanel.tscn deleted file mode 100644 index bd4a010..0000000 --- a/game/src/GameSession/MapControlPanel/MapControlPanel.tscn +++ /dev/null @@ -1,107 +0,0 @@ -[gd_scene load_steps=7 format=3 uid="uid://g524p8lr574w"] - -[ext_resource type="Script" path="res://src/GameSession/MapControlPanel/MapControlPanel.gd" id="1_ign64"] -[ext_resource type="Shader" path="res://src/GameSession/MapControlPanel/Minimap.gdshader" id="2_rinsg"] -[ext_resource type="Script" path="res://src/GameSession/MapControlPanel/Minimap.gd" id="3_s4dml"] - -[sub_resource type="ShaderMaterial" id="ShaderMaterial_bhuqb"] -shader = ExtResource("2_rinsg") -shader_parameter/province_shape_subdivisions = null -shader_parameter/selected_index = null - -[sub_resource type="InputEventAction" id="InputEventAction_5nck3"] -action = &"ui_cancel" - -[sub_resource type="Shortcut" id="Shortcut_fc1tk"] -events = [SubResource("InputEventAction_5nck3")] - -[node name="MapControlPanel" type="PanelContainer" node_paths=PackedStringArray("_mapmodes_grid")] -editor_description = "SS-103, UI-548" -mouse_filter = 1 -script = ExtResource("1_ign64") -_mapmodes_grid = NodePath("MapPanelMargin/MapPanelList/MapDisplayList/MapmodesGrid") - -[node name="MapPanelMargin" type="MarginContainer" parent="."] -layout_mode = 2 -theme_override_constants/margin_left = 5 -theme_override_constants/margin_top = 5 -theme_override_constants/margin_right = 5 -theme_override_constants/margin_bottom = 5 - -[node name="MapPanelList" type="HBoxContainer" parent="MapPanelMargin"] -layout_mode = 2 -theme_override_constants/separation = 6 -alignment = 1 - -[node name="MapDisplayList" type="VBoxContainer" parent="MapPanelMargin/MapPanelList"] -layout_mode = 2 -alignment = 1 - -[node name="MapmodesGrid" type="GridContainer" parent="MapPanelMargin/MapPanelList/MapDisplayList"] -editor_description = "UI-750" -layout_mode = 2 -columns = 11 - -[node name="Minimap" type="PanelContainer" parent="MapPanelMargin/MapPanelList/MapDisplayList"] -editor_description = "UI-549" -layout_mode = 2 -size_flags_horizontal = 4 -size_flags_vertical = 4 -mouse_filter = 1 - -[node name="MinimapTexture" type="ColorRect" parent="MapPanelMargin/MapPanelList/MapDisplayList/Minimap"] -editor_description = "UI-751, FS-338" -material = SubResource("ShaderMaterial_bhuqb") -layout_mode = 2 -color = Color(0.921569, 0.835294, 0.701961, 1) - -[node name="ViewportQuad" type="Control" parent="MapPanelMargin/MapPanelList/MapDisplayList/Minimap" node_paths=PackedStringArray("_minimap_texture")] -layout_mode = 2 -mouse_filter = 1 -script = ExtResource("3_s4dml") -_minimap_texture = NodePath("../MinimapTexture") - -[node name="AuxiliaryPanel" type="VBoxContainer" parent="MapPanelMargin/MapPanelList"] -editor_description = "UI-761" -layout_mode = 2 - -[node name="GameSessionMenuButton" type="Button" parent="MapPanelMargin/MapPanelList/AuxiliaryPanel"] -editor_description = "UI-9" -layout_mode = 2 -mouse_filter = 1 -shortcut = SubResource("Shortcut_fc1tk") -text = "ESC" - -[node name="LedgerButton" type="Button" parent="MapPanelMargin/MapPanelList/AuxiliaryPanel"] -editor_description = "UI-860" -layout_mode = 2 -mouse_filter = 1 -text = "L" - -[node name="FindButton" type="Button" parent="MapPanelMargin/MapPanelList/AuxiliaryPanel"] -editor_description = "UI-861" -layout_mode = 2 -mouse_filter = 1 -text = "F" - -[node name="ZoomButtonsContainer" type="HBoxContainer" parent="MapPanelMargin/MapPanelList/AuxiliaryPanel"] -layout_mode = 2 -alignment = 1 - -[node name="ZoomInButton" type="Button" parent="MapPanelMargin/MapPanelList/AuxiliaryPanel/ZoomButtonsContainer"] -editor_description = "UI-862" -layout_mode = 2 -mouse_filter = 1 -text = "+" - -[node name="ZoomOutButton" type="Button" parent="MapPanelMargin/MapPanelList/AuxiliaryPanel/ZoomButtonsContainer"] -editor_description = "UI-863" -layout_mode = 2 -mouse_filter = 1 -text = "-" - -[connection signal="map_view_camera_changed" from="." to="MapPanelMargin/MapPanelList/MapDisplayList/Minimap/ViewportQuad" method="_on_map_view_camera_changed"] -[connection signal="minimap_clicked" from="MapPanelMargin/MapPanelList/MapDisplayList/Minimap/ViewportQuad" to="." method="_on_minimap_clicked"] -[connection signal="pressed" from="MapPanelMargin/MapPanelList/AuxiliaryPanel/GameSessionMenuButton" to="." method="_on_game_session_menu_button_pressed"] -[connection signal="pressed" from="MapPanelMargin/MapPanelList/AuxiliaryPanel/ZoomButtonsContainer/ZoomInButton" to="." method="_on_zoom_in_button_pressed"] -[connection signal="pressed" from="MapPanelMargin/MapPanelList/AuxiliaryPanel/ZoomButtonsContainer/ZoomOutButton" to="." method="_on_zoom_out_button_pressed"] diff --git a/game/src/GameSession/MapControlPanel/Minimap.gd b/game/src/GameSession/MapControlPanel/Minimap.gd deleted file mode 100644 index 1f9b75e..0000000 --- a/game/src/GameSession/MapControlPanel/Minimap.gd +++ /dev/null @@ -1,105 +0,0 @@ -extends Control - -signal minimap_clicked(pos_clicked : Vector2) - -const _action_click : StringName = &"map_click" - -@export var _minimap_texture : Control -var _minimap_shader : ShaderMaterial - -var _viewport_points : PackedVector2Array - -func _ready(): - _minimap_texture.custom_minimum_size = Vector2(GameSingleton.get_aspect_ratio(), 1.0) * 150 - var minimap_material := _minimap_texture.get_material() - if Events.ShaderManager.set_up_shader(minimap_material, false) != OK: - push_error("Failed to set up minimap shader") - else: - _minimap_shader = minimap_material - GameSingleton.province_selected.connect(_on_province_selected) - -func _on_province_selected(index : int) -> void: - if _minimap_shader != null: - _minimap_shader.set_shader_parameter(Events.ShaderManager.param_selected_index, index) - -# REQUIREMENTS -# * SS-80 -# * UI-752 -func _draw() -> void: - if _viewport_points.size() > 1: - draw_multiline(_viewport_points, Color.WHITE, -1) - -# REQUIREMENTS -# * SS-81 -# * UIFUN-127 -func _unhandled_input(event : InputEvent): - if event is InputEventMouse and Input.is_action_pressed(_action_click): - var pos_clicked := get_local_mouse_position() / size - Vector2(0.5, 0.5) - if abs(pos_clicked.x) < 0.5 and abs(pos_clicked.y) < 0.5: - minimap_clicked.emit(pos_clicked) - -# Returns the point on the line going through p and q with the specific x coord -func _intersect_x(p : Vector2, q : Vector2, x : float) -> Vector2: - if p.x == q.x: - return Vector2(x, 0.5 * (p.y + q.y)) - var t := (x - q.x) / (p.x - q.x) - return q + t * (p - q) - -# Returns the point on the line going through p and q with the specific y coord -func _intersect_y(p : Vector2, q : Vector2, y : float) -> Vector2: - if p.y == q.y: - return Vector2(0.5 * (p.x + q.x), y) - var t := (y - q.y) / (p.y - q.y) - return q + t * (p - q) - -const _one_x := Vector2(1, 0) - -func _add_line_looped_over_x(left : Vector2, right : Vector2) -> void: - if left.x < 0: - if right.x < 0: - _viewport_points.push_back(left + _one_x) - _viewport_points.push_back(right + _one_x) - else: - var mid_point := _intersect_x(left, right, 0) - _viewport_points.push_back(mid_point) - _viewport_points.push_back(right) - mid_point.x = 1 - _viewport_points.push_back(left + _one_x) - _viewport_points.push_back(mid_point) - elif right.x > 1: - if left.x > 1: - _viewport_points.push_back(left - _one_x) - _viewport_points.push_back(right - _one_x) - else: - var mid_point := _intersect_x(left, right, 1) - _viewport_points.push_back(left) - _viewport_points.push_back(mid_point) - mid_point.x = 0 - _viewport_points.push_back(mid_point) - _viewport_points.push_back(right - _one_x) - else: - _viewport_points.push_back(left) - _viewport_points.push_back(right) - -# This can break if the viewport is rotated too far! -func _on_map_view_camera_changed(near_left : Vector2, far_left : Vector2, far_right : Vector2, near_right : Vector2) -> void: - # Bound far y coords - if far_left.y < 0: - far_left = _intersect_y(near_left, far_left, 0) - if far_right.y < 0: - far_right = _intersect_y(near_right, far_right, 0) - # Bound near y coords - if near_left.y > 1: - near_left = _intersect_y(near_left, far_left, 1) - if near_right.y > 1: - near_right = _intersect_y(near_right, far_right, 1) - - _viewport_points.clear() - _add_line_looped_over_x(near_left, near_right) - _add_line_looped_over_x(far_left, far_right) - _add_line_looped_over_x(far_left, near_left) - _add_line_looped_over_x(near_right, far_right) - - for i in _viewport_points.size(): - _viewport_points[i] *= size - queue_redraw() diff --git a/game/src/GameSession/MapControlPanel/Minimap.gdshader b/game/src/GameSession/MapControlPanel/Minimap.gdshader deleted file mode 100644 index 608abe2..0000000 --- a/game/src/GameSession/MapControlPanel/Minimap.gdshader +++ /dev/null @@ -1,18 +0,0 @@ -shader_type canvas_item; - -#include "res://src/GameSession/ProvinceIndexSampler.gdshaderinc" - -// Index of the currently selected province -uniform uint selected_index; - -const vec3 land_colour = vec3(0.5); -const vec3 selected_colour = vec3(1.0, 1.0, 0.0); - -void fragment() { - uvec3 data = read_uvec3(UV); - uint index = uvec2_to_uint(data.rg); - float is_land = float(data.b != 0u); - float is_selected = float(index == selected_index); - COLOR.rgb = mix(COLOR.rgb, land_colour, is_land); - COLOR.rgb = mix(COLOR.rgb, selected_colour, is_selected); -} diff --git a/game/src/GameSession/MapView.gd b/game/src/GameSession/MapView.gd deleted file mode 100644 index ced8bb7..0000000 --- a/game/src/GameSession/MapView.gd +++ /dev/null @@ -1,242 +0,0 @@ -extends Node3D - -signal map_view_camera_changed(near_left : Vector2, far_left : Vector2, far_right : Vector2, near_right : Vector2) - -const _action_north : StringName = &"map_north" -const _action_east : StringName = &"map_east" -const _action_south : StringName = &"map_south" -const _action_west : StringName = &"map_west" -const _action_zoom_in : StringName = &"map_zoom_in" -const _action_zoom_out : StringName = &"map_zoom_out" -const _action_drag : StringName = &"map_drag" -const _action_click : StringName = &"map_click" - -@export var _camera : Camera3D - -@export var _cardinal_move_speed : float = 1.0 -@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 - -var _mouse_over_viewport : bool = true - -@export var _zoom_target_min : float = 0.05 -@export var _zoom_target_max : float = 5.0 -@export var _zoom_target_step : float = 0.1 -@export var _zoom_epsilon : float = _zoom_target_step * 0.1 -@export var _zoom_speed : float = 5.0 -@export var _zoom_target : float = 1.0: - get: return _zoom_target - set(v): _zoom_target = clamp(v, _zoom_target_min, _zoom_target_max) - -@export var _map_mesh_instance : MeshInstance3D -var _map_mesh : MapMesh -var _map_shader_material : ShaderMaterial -var _map_mesh_corner : Vector2 -var _map_mesh_dims : Vector2 - -var _mouse_pos_viewport : Vector2 = Vector2(0.5, 0.5) -var _mouse_pos_map : Vector2 = Vector2(0.5, 0.5) -var _viewport_dims : Vector2 = Vector2(1, 1) - -# ??? Strange Godot/GDExtension Bug ??? -# Upon first opening a clone of this repo with the Godot Editor, -# 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. -# This was an absolute pain to track down. --- hop311 -func _ready(): - if _camera == null: - push_error("MapView's _camera variable hasn't been set!") - return - _zoom_target = _camera.position.y - if _map_mesh_instance == null: - push_error("MapView's _map_mesh variable hasn't been set!") - return - - # Shader Material - var map_material := _map_mesh_instance.get_active_material(0) - if Events.ShaderManager.set_up_shader(map_material, true) != OK: - push_error("Failed to set up map shader") - return - _map_shader_material = map_material - - if not _map_mesh_instance.mesh is MapMesh: - push_error("Invalid map mesh class: ", _map_mesh_instance.mesh.get_class(), "(expected MapMesh)") - return - _map_mesh = _map_mesh_instance.mesh - - # Set map mesh size and get bounds - const pixels_per_terrain_tile : float = 32.0 - _map_shader_material.set_shader_parameter(Events.ShaderManager.param_terrain_tile_factor, - float(GameSingleton.get_height()) / pixels_per_terrain_tile) - var map_mesh_aabb := _map_mesh.get_core_aabb() * _map_mesh_instance.transform - _map_mesh_corner = Vector2( - min(map_mesh_aabb.position.x, map_mesh_aabb.end.x), - min(map_mesh_aabb.position.z, map_mesh_aabb.end.z) - ) - _map_mesh_dims = abs(Vector2( - map_mesh_aabb.position.x - map_mesh_aabb.end.x, - map_mesh_aabb.position.z - map_mesh_aabb.end.z - )) - - GameSingleton.province_selected.connect(_on_province_selected) - -func _notification(what : int): - match what: - NOTIFICATION_WM_MOUSE_ENTER: # Mouse inside window - _on_mouse_entered_viewport() - NOTIFICATION_WM_MOUSE_EXIT: # Mouse out of window - _on_mouse_exited_viewport() - -func _world_to_map_coords(pos : Vector3) -> Vector2: - return (Vector2(pos.x, pos.z) - _map_mesh_corner) / _map_mesh_dims - -func _viewport_to_map_coords(pos_viewport : Vector2) -> Vector2: - var ray_origin := _camera.project_ray_origin(pos_viewport) - var ray_normal := _camera.project_ray_normal(pos_viewport) - # Plane with normal (0,1,0) facing upwards, at a distance 0 from the origin - var intersection = Plane(0, 1, 0, 0).intersects_ray(ray_origin, ray_normal) - if typeof(intersection) == TYPE_VECTOR3: - return _world_to_map_coords(intersection as Vector3) - else: - # Normals parallel to the xz-plane could cause null intersections, - # but the camera's orientation should prevent such normals - push_error("Invalid intersection: ", intersection) - return Vector2(0.5, 0.5) - -func zoom_in() -> void: - _zoom_target -= _zoom_target_step - -func zoom_out() -> void: - _zoom_target += _zoom_target_step - -func _on_province_selected(index : int) -> void: - _map_shader_material.set_shader_parameter(Events.ShaderManager.param_selected_index, index) - -# REQUIREMENTS -# * SS-31 -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): - GameSingleton.set_selected_province(GameSingleton.get_province_index_from_uv_coords(_mouse_pos_map)) - else: - print("Clicked outside the map!") - elif event.is_action_pressed(_action_drag): - if _drag_active: - push_warning("Drag being activated while already active!") - _drag_active = true - _drag_anchor = _mouse_pos_map - elif event.is_action_released(_action_drag): - if not _drag_active: - push_warning("Drag being deactivated while already not active!") - _drag_active = false - elif event.is_action_pressed(_action_zoom_in, true): - zoom_in() - elif event.is_action_pressed(_action_zoom_out, true): - zoom_out() - -func _physics_process(delta : float): - _mouse_pos_viewport = get_viewport().get_mouse_position() - _viewport_dims = Vector2(Resolution.get_current_resolution()) - # Process movement - _movement_process(delta) - # Keep within map bounds - _clamp_over_map() - # Process zooming - _zoom_process(delta) - # Orient based on height - _update_orientation() - # Update viewport on minimap - _update_minimap_viewport() - # Calculate where the mouse lies on the map - _update_mouse_map_position() - -# REQUIREMENTS -# * UIFUN-124 -func _movement_process(delta : float) -> void: - var direction : Vector2 - if _drag_active: - direction = (_drag_anchor - _mouse_pos_map) * _map_mesh_dims - else: - direction = _edge_scrolling_vector() + _cardinal_movement_vector() - # Scale movement speed with height - direction *= _camera.position.y * delta - _camera.position += Vector3(direction.x, 0, direction.y) - -# REQUIREMENTS -# * UIFUN-125 -func _edge_scrolling_vector() -> Vector2: - if not _mouse_over_viewport: - return Vector2() - var mouse_vector := _mouse_pos_viewport * GuiScale.get_current_guiscale() / _viewport_dims - Vector2(0.5, 0.5) - if abs(mouse_vector.x) < 0.5 - _edge_move_threshold and abs(mouse_vector.y) < 0.5 - _edge_move_threshold: - mouse_vector *= 0 - return mouse_vector * _edge_move_speed - -# REQUIREMENTS -# * SS-75 -func _cardinal_movement_vector() -> Vector2: - var move := Vector2( - float(Input.is_action_pressed(_action_east)) - float(Input.is_action_pressed(_action_west)), - float(Input.is_action_pressed(_action_south)) - float(Input.is_action_pressed(_action_north)) - ) - return move * _cardinal_move_speed - -func _clamp_over_map() -> void: - _camera.position.x = _map_mesh_corner.x + fposmod(_camera.position.x - _map_mesh_corner.x, _map_mesh_dims.x) - _camera.position.z = clamp(_camera.position.z, _map_mesh_corner.y, _map_mesh_corner.y + _map_mesh_dims.y) - -# REQUIREMENTS -# * SS-74 -# * UIFUN-123 -func _zoom_process(delta : float) -> void: - var height := _camera.position.y - var zoom := _zoom_target - height - height += zoom * _zoom_speed * delta - var new_zoom := _zoom_target - height - # Set to target if height is within _zoom_epsilon of it or has overshot past it - if abs(new_zoom) < _zoom_epsilon or sign(zoom) != sign(new_zoom): - height = _zoom_target - _camera.position.y = height - -func _update_orientation() -> void: - var dir := Vector3(0, -1, -exp(-_camera.position.y - 1)) - _camera.look_at(_camera.position + dir) - -func _update_minimap_viewport() -> void: - var near_left := _viewport_to_map_coords(Vector2(0, _viewport_dims.y)) - var far_left := _viewport_to_map_coords(Vector2(0, 0)) - var far_right := _viewport_to_map_coords(Vector2(_viewport_dims.x, 0)) - var near_right := _viewport_to_map_coords(_viewport_dims) - map_view_camera_changed.emit(near_left, far_left, far_right, near_right) - -func _update_mouse_map_position() -> void: - _mouse_pos_map = _viewport_to_map_coords(_mouse_pos_viewport) - var hover_index := GameSingleton.get_province_index_from_uv_coords(_mouse_pos_map) - if _mouse_over_viewport: - _map_shader_material.set_shader_parameter(Events.ShaderManager.param_hover_index, hover_index) - -func _on_mouse_entered_viewport(): - _mouse_over_viewport = true - -func _on_mouse_exited_viewport(): - _mouse_over_viewport = false - _map_shader_material.set_shader_parameter(Events.ShaderManager.param_hover_index, 0) - -func _on_minimap_clicked(pos_clicked : Vector2): - pos_clicked *= _map_mesh_dims - _camera.position.x = pos_clicked.x - _camera.position.z = pos_clicked.y - _clamp_over_map() - -func enable_processing() -> void: - set_process_unhandled_input(true) - set_physics_process(true) - -func disable_processing() -> void: - set_process_unhandled_input(false) - set_physics_process(false) diff --git a/game/src/GameSession/MapView.tscn b/game/src/GameSession/MapView.tscn deleted file mode 100644 index fa6ffcd..0000000 --- a/game/src/GameSession/MapView.tscn +++ /dev/null @@ -1,30 +0,0 @@ -[gd_scene load_steps=5 format=3 uid="uid://dkehmdnuxih2r"] - -[ext_resource type="Script" path="res://src/GameSession/MapView.gd" id="1_exccw"] -[ext_resource type="Shader" path="res://src/GameSession/TerrainMap.gdshader" id="1_upocn"] - -[sub_resource type="ShaderMaterial" id="ShaderMaterial_tayeg"] -render_priority = 0 -shader = ExtResource("1_upocn") -shader_parameter/province_shape_subdivisions = null -shader_parameter/hover_index = null -shader_parameter/selected_index = null -shader_parameter/terrain_tile_factor = null - -[sub_resource type="MapMesh" id="MapMesh_3gtsd"] - -[node name="MapView" type="Node3D" node_paths=PackedStringArray("_camera", "_map_mesh_instance")] -editor_description = "SS-73" -script = ExtResource("1_exccw") -_camera = NodePath("MapCamera") -_map_mesh_instance = NodePath("MapMeshInstance") - -[node name="MapCamera" type="Camera3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 0.707107, 0.707107, 0, -0.707107, 0.707107, 0.25, 1.5, -2.75) -near = 0.01 - -[node name="MapMeshInstance" type="MeshInstance3D" parent="."] -editor_description = "FS-343" -transform = Transform3D(10, 0, 0, 0, 10, 0, 0, 0, 10, 0, 0, 0) -material_override = SubResource("ShaderMaterial_tayeg") -mesh = SubResource("MapMesh_3gtsd") diff --git a/game/src/GameSession/ProvinceIndexSampler.gdshaderinc b/game/src/GameSession/ProvinceIndexSampler.gdshaderinc deleted file mode 100644 index 65f73d8..0000000 --- a/game/src/GameSession/ProvinceIndexSampler.gdshaderinc +++ /dev/null @@ -1,18 +0,0 @@ - -// Province shape texture -uniform sampler2DArray province_shape_tex : repeat_enable, filter_nearest; -// Province shape subdivisions -uniform vec2 province_shape_subdivisions; - -uvec3 vec3_to_uvec3(vec3 v) { - return uvec3(v * 255.0); -} -uvec3 read_uvec3(vec2 uv) { - uv *= province_shape_subdivisions; - vec2 subdivision_coords = mod(floor(uv), province_shape_subdivisions); - float idx = subdivision_coords.x + subdivision_coords.y * province_shape_subdivisions.x; - return vec3_to_uvec3(texture(province_shape_tex, vec3(uv, idx)).rgb); -} -uint uvec2_to_uint(uvec2 v) { - return (v.y << 8u) | v.x; -} diff --git a/game/src/GameSession/ProvinceOverviewPanel/ProvinceOverviewPanel.gd b/game/src/GameSession/ProvinceOverviewPanel/ProvinceOverviewPanel.gd deleted file mode 100644 index 67060bf..0000000 --- a/game/src/GameSession/ProvinceOverviewPanel/ProvinceOverviewPanel.gd +++ /dev/null @@ -1,122 +0,0 @@ -extends PanelContainer - -@export var _province_name_label : Label -@export var _region_name_label : Label -@export var _life_rating_bar : ProgressBar -@export var _rgo_icon_texture_rect : TextureRect -@export var _rgo_name_label : Label -@export var _buildings_container : Container - -const _missing_suffix : String = "_MISSING" - -var _selected_index : int: - get: return _selected_index - set(v): - _selected_index = v - update_info() -var _province_info : Dictionary - -func _ready(): - GameSingleton.province_selected.connect(_on_province_selected) - 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); - -# Each building row contains: -# level - Level Label -# name - Name Label -# button - Expansion Button -# progress_bar - Expansion ProgressBar -var _building_rows : Array[Dictionary] - -# REQUIREMENTS: -# * UI-183, UI-185, UI-186, UI-765, UI-187, UI-188, UI-189 -# * UI-191, UI-193, UI-194, UI-766, UI-195, UI-196, UI-197 -# * UI-199, UI-201, UI-202, UI-767, UI-203, UI-204, UI-205 -func _add_building_row() -> void: - var row : Dictionary - - row.level = Label.new() - row.level.text = "X" - _buildings_container.add_child(row.level) - - row.name = Label.new() - row.name.text = GameSingleton.get_building_info_building_key() + _missing_suffix - _buildings_container.add_child(row.name) - - row.button = Button.new() - row.button.text = "EXPAND_PROVINCE_BUILDING" - row.button.size_flags_horizontal = Control.SIZE_EXPAND_FILL - row.button.mouse_filter = Control.MOUSE_FILTER_PASS - row.button.pressed.connect(func(): _expand_building(row.name.text)) - _buildings_container.add_child(row.button) - - row.progress_bar = ProgressBar.new() - row.progress_bar.max_value = 1 - row.progress_bar.size_flags_horizontal = Control.SIZE_EXPAND_FILL - row.progress_bar.mouse_filter = Control.MOUSE_FILTER_PASS - _buildings_container.add_child(row.progress_bar) - - _building_rows.append(row) - _set_building_row(_building_rows.size() - 1, {}) - -func _set_building_row(index : int, building : Dictionary) -> void: - if index < 0 or index > _building_rows.size(): - push_error("Invalid building row index: ", index, " (max ", _building_rows.size(), ")") - return - if index == _building_rows.size(): _add_building_row() - var row := _building_rows[index] - if building.is_empty(): - row.level.visible = false - row.name.visible = false - row.progress_bar.visible = false - row.button.visible = false - return - row.level.text = str(building.get(GameSingleton.get_building_info_level_key(), 0)) - row.level.visible = true - row.name.text = building.get(GameSingleton.get_building_info_building_key(), - GameSingleton.get_building_info_building_key() + _missing_suffix) - row.name.visible = true - - var expansion_state : int = building.get(GameSingleton.get_building_info_expansion_state_key(), - CANNOT_EXPAND) - var show_progress_bar := expansion_state == PREPARING or expansion_state == EXPANDING - row.progress_bar.value = building.get(GameSingleton.get_building_info_expansion_progress_key(), 0) - row.progress_bar.visible = show_progress_bar - row.button.disabled = expansion_state != CAN_EXPAND - row.button.visible = not show_progress_bar - -func update_info() -> void: - _province_info = GameSingleton.get_province_info_from_index(_selected_index) - if _province_info: - _province_name_label.text = _province_info.get(GameSingleton.get_province_info_province_key(), - GameSingleton.get_province_info_province_key() + _missing_suffix) - _region_name_label.text = _province_info.get(GameSingleton.get_province_info_region_key(), - GameSingleton.get_province_info_region_key() + _missing_suffix) - - _life_rating_bar.value = _province_info.get(GameSingleton.get_province_info_life_rating_key(), 0) - _life_rating_bar.tooltip_text = tr("LIFE_RATING_TOOLTIP").format({ "life_rating": _life_rating_bar.value }) - - _rgo_name_label.text = _province_info.get(GameSingleton.get_province_info_rgo_key(), - GameSingleton.get_province_info_rgo_key() + _missing_suffix) - _rgo_icon_texture_rect.texture = GameSingleton.get_good_icon_texture(_rgo_name_label.text) - - var buildings : Array = _province_info.get(GameSingleton.get_province_info_buildings_key(), []) - for i in max(buildings.size(), _building_rows.size()): - _set_building_row(i, buildings[i] if i < buildings.size() else {}) - - show() - else: - hide() - mouse_exited.emit() - -func _on_province_selected(index : int) -> void: - _selected_index = index - -func _on_close_button_pressed() -> void: - GameSingleton.set_selected_province(0) diff --git a/game/src/GameSession/ProvinceOverviewPanel/ProvinceOverviewPanel.tscn b/game/src/GameSession/ProvinceOverviewPanel/ProvinceOverviewPanel.tscn deleted file mode 100644 index a233db0..0000000 --- a/game/src/GameSession/ProvinceOverviewPanel/ProvinceOverviewPanel.tscn +++ /dev/null @@ -1,86 +0,0 @@ -[gd_scene load_steps=2 format=3 uid="uid://byq323jbel48u"] - -[ext_resource type="Script" path="res://src/GameSession/ProvinceOverviewPanel/ProvinceOverviewPanel.gd" id="1_3n8k5"] - -[node name="ProvinceOverviewPanel" type="PanelContainer" node_paths=PackedStringArray("_province_name_label", "_region_name_label", "_life_rating_bar", "_rgo_icon_texture_rect", "_rgo_name_label", "_buildings_container")] -editor_description = "UI-56" -anchors_preset = 2 -anchor_top = 1.0 -anchor_bottom = 1.0 -offset_top = -300.0 -offset_right = 200.0 -grow_vertical = 0 -mouse_filter = 1 -script = ExtResource("1_3n8k5") -_province_name_label = NodePath("PanelList/TopBarList/NameList/ProvinceName") -_region_name_label = NodePath("PanelList/TopBarList/NameList/RegionName") -_life_rating_bar = NodePath("PanelList/TopBarList/NameList/LifeRatingBar") -_rgo_icon_texture_rect = NodePath("PanelList/InteractList/RGOInfo/RGOIcon") -_rgo_name_label = NodePath("PanelList/InteractList/RGOInfo/RGOName") -_buildings_container = NodePath("PanelList/InteractList/BuildingsContainer") - -[node name="PanelList" type="VBoxContainer" parent="."] -layout_mode = 2 - -[node name="TopBarList" type="HBoxContainer" parent="PanelList"] -layout_mode = 2 - -[node name="NameList" type="VBoxContainer" parent="PanelList/TopBarList"] -layout_mode = 2 -size_flags_horizontal = 3 -size_flags_vertical = 0 - -[node name="ProvinceName" type="Label" parent="PanelList/TopBarList/NameList"] -editor_description = "UI-57" -layout_mode = 2 -text = "province_MISSING" -vertical_alignment = 1 - -[node name="RegionName" type="Label" parent="PanelList/TopBarList/NameList"] -editor_description = "UI-58" -layout_mode = 2 -text = "region_MISSING" -vertical_alignment = 1 - -[node name="LifeRatingBar" type="ProgressBar" parent="PanelList/TopBarList/NameList"] -editor_description = "UI-62" -layout_mode = 2 -mouse_filter = 1 - -[node name="CloseButton" type="Button" parent="PanelList/TopBarList"] -custom_minimum_size = Vector2(30, 30) -layout_mode = 2 -size_flags_vertical = 0 -mouse_filter = 1 -text = "X" - -[node name="InteractList" type="VBoxContainer" parent="PanelList"] -layout_mode = 2 -size_flags_vertical = 3 - -[node name="HSeparator" type="HSeparator" parent="PanelList/InteractList"] -layout_mode = 2 -mouse_filter = 1 - -[node name="RGOInfo" type="HBoxContainer" parent="PanelList/InteractList"] -editor_description = "UI-112" -layout_mode = 2 - -[node name="RGOIcon" type="TextureRect" parent="PanelList/InteractList/RGOInfo"] -editor_description = "UI-100" -layout_mode = 2 - -[node name="RGOName" type="Label" parent="PanelList/InteractList/RGOInfo"] -layout_mode = 2 -text = "rgo_MISSING" -vertical_alignment = 1 - -[node name="HSeparator2" type="HSeparator" parent="PanelList/InteractList"] -layout_mode = 2 -mouse_filter = 1 - -[node name="BuildingsContainer" type="GridContainer" parent="PanelList/InteractList"] -layout_mode = 2 -columns = 3 - -[connection signal="pressed" from="PanelList/TopBarList/CloseButton" to="." method="_on_close_button_pressed"] diff --git a/game/src/GameSession/TerrainMap.gdshader b/game/src/GameSession/TerrainMap.gdshader deleted file mode 100644 index 88e7019..0000000 --- a/game/src/GameSession/TerrainMap.gdshader +++ /dev/null @@ -1,50 +0,0 @@ -shader_type spatial; - -render_mode unshaded; - -#include "res://src/GameSession/ProvinceIndexSampler.gdshaderinc" - -// Province colour texture -uniform sampler2D province_colour_tex: source_color, repeat_enable, filter_nearest; -// Index of the mouse over the map mesh -uniform uint hover_index; -// Index of the currently selected province -uniform uint selected_index; -// Cosmetic terrain textures -uniform sampler2DArray terrain_tex: source_color, repeat_enable, filter_linear; -// The number of times the terrain textures should tile vertically -uniform float terrain_tile_factor; - -const vec3 highlight_colour = vec3(1.0); - -vec3 get_terrain_colour(vec2 uv, vec2 corner, vec2 half_pixel_size, vec2 terrain_uv) { - uvec3 province_data = read_uvec3(fma(corner, half_pixel_size, uv)); - vec4 province_colour = texelFetch(province_colour_tex, ivec2(province_data.rg), 0); - vec3 terrain_colour = texture(terrain_tex, vec3(terrain_uv, float(province_data.b))).rgb; - vec3 mixed_colour = mix(terrain_colour, province_colour.rgb, province_colour.a); - uint index = uvec2_to_uint(province_data.rg); - float mix_val = 0.1 * (float(index == hover_index) + float(index == selected_index)); - return mix(mixed_colour, highlight_colour, mix_val); -} - -vec3 mix_terrain_colour(vec2 uv) { - vec2 map_size = vec2(textureSize(province_shape_tex, 0).xy) * province_shape_subdivisions; - vec2 pixel_offset = fract(fma(uv, map_size, vec2(0.5))); - vec2 half_pixel_size = 0.49 / map_size; - - vec2 terrain_uv = uv; - terrain_uv.x *= map_size.x / map_size.y; - terrain_uv *= terrain_tile_factor; - - return mix( - mix(get_terrain_colour(uv, vec2(-1, -1), half_pixel_size, terrain_uv), - get_terrain_colour(uv, vec2(+1, -1), half_pixel_size, terrain_uv), pixel_offset.x), - mix(get_terrain_colour(uv, vec2(-1, +1), half_pixel_size, terrain_uv), - get_terrain_colour(uv, vec2(+1, +1), half_pixel_size, terrain_uv), pixel_offset.x), - pixel_offset.y); -} - -void fragment() { - vec3 terrain_colour = mix_terrain_colour(UV); - ALBEDO = terrain_colour; -} diff --git a/game/src/GameStart.tscn b/game/src/GameStart.tscn deleted file mode 100644 index 2046bb5..0000000 --- a/game/src/GameStart.tscn +++ /dev/null @@ -1,52 +0,0 @@ -[gd_scene load_steps=6 format=3 uid="uid://1udsn4mggep2"] - -[ext_resource type="PackedScene" uid="uid://o4u142w4qkln" path="res://src/GameMenu.tscn" id="1_wlojq"] -[ext_resource type="Script" path="res://src/SplashContainer.gd" id="2_xmcgv"] -[ext_resource type="Texture2D" uid="uid://deef5hufq0j61" path="res://splash_assets/splash_end.png" id="3_qfv12"] -[ext_resource type="Texture2D" uid="uid://cgdnixsyh7bja" path="res://splash_assets/splash_image.png" id="4_5b6yq"] -[ext_resource type="VideoStream" path="res://splash_assets/splash_startup.ogv" id="5_8euyy"] - -[node name="GameStartup" type="Control"] -layout_mode = 3 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 - -[node name="GameMenu" parent="." instance=ExtResource("1_wlojq")] -visible = false -layout_mode = 1 - -[node name="SplashContainer" type="AspectRatioContainer" parent="." node_paths=PackedStringArray("_splash_finish", "_splash_image", "_splash_video")] -layout_mode = 1 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 -ratio = 1.7778 -stretch_mode = 3 -script = ExtResource("2_xmcgv") -_splash_finish = NodePath("SplashFinish") -_splash_image = NodePath("SplashImage") -_splash_video = NodePath("SplashVideo") - -[node name="SplashFinish" type="TextureRect" parent="SplashContainer"] -layout_mode = 2 -texture = ExtResource("3_qfv12") -expand_mode = 1 - -[node name="SplashImage" type="TextureRect" parent="SplashContainer"] -layout_mode = 2 -texture = ExtResource("4_5b6yq") -expand_mode = 1 - -[node name="SplashVideo" type="VideoStreamPlayer" parent="SplashContainer"] -layout_mode = 2 -stream = ExtResource("5_8euyy") -autoplay = true -expand = true - -[connection signal="splash_end" from="SplashContainer" to="GameMenu" method="_on_splash_container_splash_end"] -[connection signal="finished" from="SplashContainer/SplashVideo" to="SplashContainer" method="_on_splash_startup_finished"] diff --git a/game/src/LobbyMenu/LobbyMenu.gd b/game/src/LobbyMenu/LobbyMenu.gd deleted file mode 100644 index db4f2ce..0000000 --- a/game/src/LobbyMenu/LobbyMenu.gd +++ /dev/null @@ -1,165 +0,0 @@ -extends HBoxContainer - -# REQUIREMENTS: -# * 1.4 Game Lobby Menu -# * SS-12 - -signal back_button_pressed -signal save_game_selected(save : SaveResource) -signal start_date_selected(index : int) - -@export var lobby_panel_button : PackedScene -@export var save_scene : PackedScene - -@export_group("Nodes") -@export var game_select_start_date : BoxContainer -@export var game_select_save_tab : TabBar -@export var game_select_save_list : BoxContainer -@export var start_button : BaseButton -@export var session_tag_line_edit : LineEdit -@export var session_tag_dialog : ConfirmationDialog -@export var delete_dialog : ConfirmationDialog - -func filter_for_tag(tag : StringName) -> void: - for child in game_select_save_list.get_children(): - if tag == &"": - child.show() - else: - if tag == child.resource.session_tag: - child.show() - else: - child.hide() - -func _build_date_list() -> void: - var start_date := lobby_panel_button.instantiate() - start_date.set_text(&"1836") - start_date.pressed.connect(_on_start_date_panel_button_pressed.bind(start_date)) - game_select_start_date.add_child(start_date) - start_date = lobby_panel_button.instantiate() - start_date.set_text(&"1863") - start_date.pressed.connect(_on_start_date_panel_button_pressed.bind(start_date)) - game_select_start_date.add_child(start_date) - -var _id_to_tag : Array[StringName] = [] - -# Requirements -# * FS-8 -func _build_save_list() -> void: - game_select_save_tab.add_tab("GAMELOBBY_SELECT_ALL") - for save_name in SaveManager._save_dictionary: - var save : SaveResource = SaveManager._save_dictionary[save_name] - var save_node := _create_save_node(save) - game_select_save_list.add_child(save_node) - if not _id_to_tag.has(save.session_tag): - _id_to_tag.append(save.session_tag) - game_select_save_tab.add_tab(save.session_tag) - -func _create_save_node(resource : SaveResource) -> Control: - var save_node = save_scene.instantiate() - save_node.resource = resource - save_node.pressed.connect(_on_save_node_pressed.bind(save_node)) - save_node.request_to_delete.connect(_on_save_node_delete_requested.bind(save_node)) - return save_node - -func _queue_clear_lists() -> void: - var full_list = game_select_start_date.get_children() - full_list.append_array(game_select_save_list.get_children()) - for child in full_list: - child.queue_free() - game_select_save_tab.clear_tabs() - _id_to_tag.clear() - -# REQUIREMENTS: -# * SS-16 -# * UIFUN-40 -func _on_back_button_button_down(): - print("Returning to Main Menu.") - SaveManager.current_session_tag = "" - SaveManager.current_save = null - back_button_pressed.emit() - -# REQUIREMENTS: -# * SS-21 -func _on_start_button_pressed(): - print("Starting new game.") - if SaveManager.current_session_tag == "": - # TODO: Get country tag as well - var datetime := Time.get_datetime_dict_from_system() - SaveManager.current_session_tag = "%s/%s/%s-%s:%s:%s" % [ - datetime["day"], - datetime["month"], - datetime["year"], - datetime["hour"], - datetime["minute"], - datetime["second"] - ] - if SaveManager.current_save == null and SaveManager.current_session_tag in _id_to_tag: - session_tag_dialog.dialog_text = tr("GAMELOBBY_SESSIONTAG_DIALOG_TEXT").format({ "session_tag": SaveManager.current_session_tag }) - session_tag_dialog.title = tr("GAMELOBBY_SESSIONTAG_DIALOG_TITLE").format({ "session_tag": SaveManager.current_session_tag }) - session_tag_dialog.popup_centered() - else: - _on_session_tag_dialog_confirmed() - -# REQUIREMENTS: -# * SS-19 -func _on_game_select_list_item_selected(index): - print("Selected save game: ", index) - save_game_selected.emit(index) - -# If the date is double-clicked, start the game! -func _on_game_select_list_item_activated(index): - _on_game_select_list_item_selected(index) - _on_start_button_pressed() - -func _on_session_tag_edit_text_submitted(new_text): - SaveManager.current_session_tag = new_text - _on_start_button_pressed() - -func _on_session_tag_dialog_confirmed(): - get_tree().change_scene_to_file("res://src/GameSession/GameSession.tscn") - -var _requested_node_to_delete : Control -func _on_save_node_delete_requested(node : Control) -> void: - _requested_node_to_delete = node - delete_dialog.dialog_text = tr("GAMELOBBY_DELETE_DIALOG_TEXT").format({ "file_name": _requested_node_to_delete.resource.save_name }) - delete_dialog.title = tr("GAMELOBBY_DELETE_DIALOG_TITLE").format({ "file_name": _requested_node_to_delete.resource.save_name }) - delete_dialog.popup_centered() - -var _start_date_index := -1 -func _on_start_date_panel_button_pressed(node : Control) -> void: - if node is LobbyPanelButton and node.get_index(true) == _start_date_index: - _on_start_button_pressed() - return - _start_date_index = node.get_index(true) - start_button.disabled = false - start_date_selected.emit(_start_date_index) - -func _on_save_node_pressed(node : Control) -> void: - if SaveManager.current_save != null and SaveManager.current_save == node.resource: - SaveManager.current_session_tag = SaveManager.current_save.session_tag - _on_start_button_pressed() - return - SaveManager.current_save = node.resource - if SaveManager.current_save != null: - session_tag_line_edit.text = SaveManager.current_save.session_tag - else: - session_tag_line_edit.text = "" - start_button.disabled = false - save_game_selected.emit(SaveManager.current_save) - -func _on_game_select_save_tab_tab_changed(tab) -> void: - if tab == 0: - filter_for_tag(&"") - else: - filter_for_tag(_id_to_tag[tab - 1]) - -func _on_delete_dialog_confirmed(): - _requested_node_to_delete.resource.delete() - _requested_node_to_delete.queue_free() - -func _on_visibility_changed(): - if visible: - _build_date_list() - _build_save_list() - else: - _queue_clear_lists() diff --git a/game/src/LobbyMenu/LobbyMenu.tscn b/game/src/LobbyMenu/LobbyMenu.tscn deleted file mode 100644 index 3b5796e..0000000 --- a/game/src/LobbyMenu/LobbyMenu.tscn +++ /dev/null @@ -1,138 +0,0 @@ -[gd_scene load_steps=4 format=3 uid="uid://do60kx0d3nrh4"] - -[ext_resource type="Script" path="res://src/LobbyMenu/LobbyMenu.gd" id="1_cvwum"] -[ext_resource type="PackedScene" uid="uid://k71f5gibwmtc" path="res://src/LobbyMenu/LobbyPanelButton.tscn" id="2_exh17"] -[ext_resource type="PackedScene" uid="uid://d2s7roinx2or7" path="res://src/SaveLoadMenu/SavePanelButton.tscn" id="3_4otj7"] - -[node name="LobbyMenu" type="HBoxContainer" node_paths=PackedStringArray("game_select_start_date", "game_select_save_tab", "game_select_save_list", "start_button", "session_tag_line_edit", "session_tag_dialog", "delete_dialog")] -editor_description = "UI-36" -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 -script = ExtResource("1_cvwum") -lobby_panel_button = ExtResource("2_exh17") -save_scene = ExtResource("3_4otj7") -game_select_start_date = NodePath("GameSelectPanel/VBoxContainer/GameSelectScroll/GameSelectList/GameSelectStartDate") -game_select_save_tab = NodePath("GameSelectPanel/VBoxContainer/GameSelectScroll/GameSelectList/GameSelectSaveTab") -game_select_save_list = NodePath("GameSelectPanel/VBoxContainer/GameSelectScroll/GameSelectList/GameSelectSaveList") -start_button = NodePath("GameStartPanel/VBoxContainer/StartButton") -session_tag_line_edit = NodePath("GameStartPanel/VBoxContainer/SessionTagEdit") -session_tag_dialog = NodePath("SessionTagDialog") -delete_dialog = NodePath("DeleteDialog") - -[node name="GameSelectPanel" type="PanelContainer" parent="."] -layout_mode = 2 -size_flags_horizontal = 3 - -[node name="VBoxContainer" type="VBoxContainer" parent="GameSelectPanel"] -layout_mode = 2 - -[node name="GameSelectScroll" type="ScrollContainer" parent="GameSelectPanel/VBoxContainer"] -editor_description = "UI-39" -layout_mode = 2 -size_flags_vertical = 3 -horizontal_scroll_mode = 0 - -[node name="GameSelectList" type="VBoxContainer" parent="GameSelectPanel/VBoxContainer/GameSelectScroll"] -layout_mode = 2 -size_flags_horizontal = 3 -size_flags_vertical = 3 - -[node name="GameSelectStartDate" type="VBoxContainer" parent="GameSelectPanel/VBoxContainer/GameSelectScroll/GameSelectList"] -layout_mode = 2 - -[node name="GameSelectSaveTab" type="TabBar" parent="GameSelectPanel/VBoxContainer/GameSelectScroll/GameSelectList"] -layout_mode = 2 -tab_count = 1 -tab_0/title = "GAMELOBBY_SELECT_ALL" - -[node name="GameSelectSaveList" type="VBoxContainer" parent="GameSelectPanel/VBoxContainer/GameSelectScroll/GameSelectList"] -layout_mode = 2 -size_flags_vertical = 3 - -[node name="GameSelectList" type="ItemList" parent="GameSelectPanel/VBoxContainer"] -visible = false -layout_mode = 2 -size_flags_vertical = 3 -item_count = 2 -item_0/text = "1836" -item_1/text = "1863" - -[node name="Spacer" type="Control" parent="GameSelectPanel/VBoxContainer"] -custom_minimum_size = Vector2(0, 150) -layout_mode = 2 -size_flags_vertical = 3 - -[node name="BackButton" type="Button" parent="GameSelectPanel/VBoxContainer"] -editor_description = "UI-37" -layout_mode = 2 -text = "GAMELOBBY_BACK" - -[node name="Spacer2" type="Control" parent="GameSelectPanel/VBoxContainer"] -custom_minimum_size = Vector2(0, 33) -layout_mode = 2 - -[node name="Spacer" type="Control" parent="."] -layout_mode = 2 -size_flags_horizontal = 3 -size_flags_stretch_ratio = 2.75 -mouse_filter = 2 - -[node name="GameStartPanel" type="PanelContainer" parent="."] -layout_mode = 2 -size_flags_horizontal = 3 - -[node name="VBoxContainer" type="VBoxContainer" parent="GameStartPanel"] -layout_mode = 2 - -[node name="Spacer" type="Control" parent="GameStartPanel/VBoxContainer"] -custom_minimum_size = Vector2(0, 50) -layout_mode = 2 - -[node name="SelectedCountryNameLabel" type="Label" parent="GameStartPanel/VBoxContainer"] -layout_mode = 2 -text = "France" -horizontal_alignment = 1 - -[node name="Spacer2" type="Control" parent="GameStartPanel/VBoxContainer"] -custom_minimum_size = Vector2(0, 150) -layout_mode = 2 -size_flags_vertical = 3 - -[node name="SessionTagEdit" type="LineEdit" parent="GameStartPanel/VBoxContainer"] -layout_mode = 2 -placeholder_text = "GAMELOBBY_SESSION_TAG" - -[node name="StartButton" type="Button" parent="GameStartPanel/VBoxContainer"] -editor_description = "UI-43" -layout_mode = 2 -disabled = true -text = "GAMELOBBY_START" - -[node name="Spacer3" type="Control" parent="GameStartPanel/VBoxContainer"] -custom_minimum_size = Vector2(0, 33) -layout_mode = 2 - -[node name="SessionTagDialog" type="ConfirmationDialog" parent="."] -disable_3d = true -title = "GAMELOBBY_SESSIONTAG_DIALOG_TITLE" -ok_button_text = "DIALOG_OK" -dialog_text = "GAMELOBBY_SESSIONTAG_DIALOG_TEXT" -cancel_button_text = "DIALOG_CANCEL" - -[node name="DeleteDialog" type="ConfirmationDialog" parent="."] -disable_3d = true -title = "GAMELOBBY_DELETE_DIALOG_TITLE" -ok_button_text = "DIALOG_OK" -dialog_text = "GAMELOBBY_DELETE_DIALOG_TEXT" -cancel_button_text = "DIALOG_CANCEL" - -[connection signal="visibility_changed" from="." to="." method="_on_visibility_changed"] -[connection signal="tab_changed" from="GameSelectPanel/VBoxContainer/GameSelectScroll/GameSelectList/GameSelectSaveTab" to="." method="_on_game_select_save_tab_tab_changed"] -[connection signal="button_down" from="GameSelectPanel/VBoxContainer/BackButton" to="." method="_on_back_button_button_down"] -[connection signal="text_submitted" from="GameStartPanel/VBoxContainer/SessionTagEdit" to="." method="_on_session_tag_edit_text_submitted"] -[connection signal="pressed" from="GameStartPanel/VBoxContainer/StartButton" to="." method="_on_start_button_pressed"] -[connection signal="confirmed" from="SessionTagDialog" to="." method="_on_session_tag_dialog_confirmed"] -[connection signal="confirmed" from="DeleteDialog" to="." method="_on_delete_dialog_confirmed"] diff --git a/game/src/LobbyMenu/LobbyPanelButton.gd b/game/src/LobbyMenu/LobbyPanelButton.gd deleted file mode 100644 index 5f3ea46..0000000 --- a/game/src/LobbyMenu/LobbyPanelButton.gd +++ /dev/null @@ -1,102 +0,0 @@ -@tool -class_name LobbyPanelButton -extends Container - -signal button_down -signal button_up -signal pressed -signal toggled(button_pressed : bool) - -var is_start_date : bool: - get = _is_start_date - -func _is_start_date() -> bool: - return true - -@export_group("Nodes") -@export var background_button : BaseButton -@export var name_label : Label - -var text : StringName: - get = get_text, - set = set_text - -func get_text() -> StringName: - return name_label.text - -func set_text(value : StringName) -> void: - name_label.text = value - -func _get_minimum_size() -> Vector2: - var result := Vector2() - for child in get_children(): - child = child as Control - if child == null or not child.visible: - continue - if child.top_level: - continue - - var minsize : Vector2 = child.get_combined_minimum_size() - result.x = max(result.x, minsize.x) - result.y = max(result.y, minsize.y) - - var draw_style := _get_draw_mode_style() - if draw_style != null: - result += draw_style.get_minimum_size() - - return result - -func _get_draw_mode_name(support_rtl : bool = true) -> StringName: - var rtl := support_rtl and background_button != null and background_button.is_layout_rtl() - match background_button.get_draw_mode() if background_button != null else BaseButton.DrawMode.DRAW_NORMAL: - BaseButton.DrawMode.DRAW_NORMAL: - if rtl: return &"normal_mirrored" - return &"normal" - BaseButton.DrawMode.DRAW_PRESSED: - if rtl: return &"pressed_mirrored" - return &"pressed" - BaseButton.DrawMode.DRAW_HOVER: - if rtl: return &"hover_mirrored" - return &"hover" - BaseButton.DrawMode.DRAW_DISABLED: - if rtl: return &"disabled_mirrored" - return &"disabled" - BaseButton.DrawMode.DRAW_HOVER_PRESSED: - if rtl: return &"hover_pressed_mirrored" - return &"hover_pressed" - return &"" - -func _get_draw_mode_style() -> StyleBox: - if background_button == null: return null - var result := background_button.get_theme_stylebox(_get_draw_mode_name()) - if result == null: - return background_button.get_theme_stylebox(_get_draw_mode_name(false)) - return result - -func _notification(what) -> void: - if what == NOTIFICATION_SORT_CHILDREN: - var _size := size - var offset := Vector2() - var style := _get_draw_mode_style() - if style != null: - _size -= style.get_minimum_size() - offset += style.get_offset() - - for child in get_children(): - child = child as Control - if child == null or not child.is_visible_in_tree() or child.top_level: - continue - - fit_child_in_rect(child, Rect2(offset, _size)) - -func _on_background_button_button_down(): - button_down.emit() - -func _on_background_button_button_up(): - button_up.emit() - -func _on_background_button_pressed(): - pressed.emit() - -func _on_background_button_toggled(button_pressed : bool): - toggled.emit(button_pressed) diff --git a/game/src/LobbyMenu/LobbyPanelButton.tscn b/game/src/LobbyMenu/LobbyPanelButton.tscn deleted file mode 100644 index f409a2e..0000000 --- a/game/src/LobbyMenu/LobbyPanelButton.tscn +++ /dev/null @@ -1,31 +0,0 @@ -[gd_scene load_steps=2 format=3 uid="uid://k71f5gibwmtc"] - -[ext_resource type="Script" path="res://src/LobbyMenu/LobbyPanelButton.gd" id="1_327u2"] - -[node name="LobbyPanelButton" type="Container" node_paths=PackedStringArray("background_button", "name_label")] -editor_description = "UI-41" -offset_right = 113.0 -offset_bottom = 48.0 -script = ExtResource("1_327u2") -background_button = NodePath("BackgroundButton") -name_label = NodePath("SaveList/NameLabel") - -[node name="BackgroundButton" type="Button" parent="."] -layout_mode = 2 -theme_type_variation = &"ButtonContainer" - -[node name="SaveList" type="HBoxContainer" parent="."] -layout_mode = 2 -size_flags_horizontal = 0 -mouse_filter = 2 - -[node name="NameLabel" type="Label" parent="SaveList"] -layout_mode = 2 -size_flags_vertical = 1 -text = "PLACEHOLDER" -vertical_alignment = 1 - -[connection signal="button_down" from="BackgroundButton" to="." method="_on_background_button_button_down"] -[connection signal="button_up" from="BackgroundButton" to="." method="_on_background_button_button_up"] -[connection signal="pressed" from="BackgroundButton" to="." method="_on_background_button_pressed"] -[connection signal="toggled" from="BackgroundButton" to="." method="_on_background_button_toggled"] diff --git a/game/src/LocaleButton.gd b/game/src/LocaleButton.gd deleted file mode 100644 index 2b717a4..0000000 --- a/game/src/LocaleButton.gd +++ /dev/null @@ -1,80 +0,0 @@ -extends OptionButton - -const section_name : String = "localisation" -const setting_name : String = "locale" - -var _default_locale_index : int - -func _ready(): - var locales_country_rename : Dictionary = ProjectSettings.get_setting("internationalization/locale/country_short_name", {}) - - var locales_list = TranslationServer.get_loaded_locales() - var default_locale := Events.Localisation.get_default_locale() - if default_locale not in locales_list: - locales_list.push_back(default_locale) - - for locale in locales_list: - # locale_name consists of a compulsory language name and optional script - # and country names, in the format: "[ (script)][, country]" - var locale_name := TranslationServer.get_locale_name(locale) - var comma_idx := locale_name.find(", ") - if comma_idx != -1: - var locale_country_name := locale_name.substr(comma_idx + 2) - locale_country_name = locales_country_rename.get(locale_country_name, "") - if not locale_country_name.is_empty(): - locale_name = locale_name.left(comma_idx + 2) + locale_country_name - - add_item(locale_name) - set_item_metadata(item_count - 1, locale) - - if locale == default_locale: - _default_locale_index = item_count - 1 - - Events.Options.load_settings.connect(load_setting) - Events.Options.save_settings.connect(save_setting) - -func _notification(what : int): - match what: - NOTIFICATION_TRANSLATION_CHANGED: - _select_locale_by_string(TranslationServer.get_locale()) - -func _valid_index(index : int) -> bool: - return 0 <= index and index < item_count - -func load_setting(file : ConfigFile) -> void: - if file == null: return - var load_value = file.get_value(section_name, setting_name, Events.Localisation.get_default_locale()) - match typeof(load_value): - TYPE_STRING, TYPE_STRING_NAME: - if _select_locale_by_string(load_value as String): - item_selected.emit(selected) - return - push_error("Setting value '%s' invalid for setting [%s] %s" % [load_value, section_name, setting_name]) - reset_setting() - -func _select_locale_by_string(locale : String) -> bool: - for idx in item_count: - if get_item_metadata(idx) == locale: - selected = idx - return true - selected = _default_locale_index - return false - -# REQUIREMENTS: -# * UIFUN-74 -func save_setting(file : ConfigFile) -> void: - if file == null: return - file.set_value(section_name, setting_name, get_item_metadata(selected)) - -func reset_setting() -> void: - _select_locale_by_string(TranslationServer.get_locale()) - -# REQUIREMENTS: -# * SS-58 -func _on_item_selected(index : int) -> void: - if _valid_index(index): - TranslationServer.set_locale(get_item_metadata(index)) - Events.Options.save_settings_to_file.call_deferred() - else: - push_error("Invalid LocaleButton index: %d" % index) - reset_setting() diff --git a/game/src/LocaleButton.tscn b/game/src/LocaleButton.tscn deleted file mode 100644 index 55f1c29..0000000 --- a/game/src/LocaleButton.tscn +++ /dev/null @@ -1,12 +0,0 @@ -[gd_scene load_steps=2 format=3 uid="uid://b7oncobnacxmt"] - -[ext_resource type="Script" path="res://src/LocaleButton.gd" id="1_ganev"] - -[node name="LocaleButton" type="OptionButton"] -custom_minimum_size = Vector2(150, 0) -alignment = 2 -text_overrun_behavior = 2 -fit_to_longest_item = false -script = ExtResource("1_ganev") - -[connection signal="item_selected" from="." to="." method="_on_item_selected"] diff --git a/game/src/MainMenu/MainMenu.gd b/game/src/MainMenu/MainMenu.gd deleted file mode 100644 index 9d0edc6..0000000 --- a/game/src/MainMenu/MainMenu.gd +++ /dev/null @@ -1,50 +0,0 @@ -extends Control - -signal options_button_pressed -signal new_game_button_pressed -signal credits_button_pressed - -@export -var _new_game_button : BaseButton - -# REQUIREMENTS: -# * SS-3 -func _ready(): - _on_new_game_button_visibility_changed() - -# REQUIREMENTS: -# * SS-14 -# * UIFUN-32 -func _on_new_game_button_pressed(): - print("Start a new game!") - new_game_button_pressed.emit() - - -func _on_continue_button_pressed(): - print("Continue last game!") - - -func _on_multi_player_button_pressed(): - print("Have fun with friends!") - - -func _on_options_button_pressed(): - print("Check out some options!") - options_button_pressed.emit() - -# REQUIREMENTS -# * UI-32 -# * UIFUN-36 -func _on_credits_button_pressed(): - credits_button_pressed.emit() - -# REQUIREMENTS -# * SS-4 -# * UIFUN-3 -func _on_exit_button_pressed(): - print("See you later!") - get_tree().quit() - -func _on_new_game_button_visibility_changed(): - if visible: - _new_game_button.grab_focus.call_deferred() diff --git a/game/src/MainMenu/MainMenu.tscn b/game/src/MainMenu/MainMenu.tscn deleted file mode 100644 index 0618fe8..0000000 --- a/game/src/MainMenu/MainMenu.tscn +++ /dev/null @@ -1,150 +0,0 @@ -[gd_scene load_steps=6 format=3 uid="uid://bp5n3mlu45ygw"] - -[ext_resource type="Theme" uid="uid://qoi3oec48jp0" path="res://theme/main_menu.tres" id="1_1yri4"] -[ext_resource type="Script" path="res://src/MainMenu/MainMenu.gd" id="2_nm1fq"] -[ext_resource type="Texture2D" uid="uid://dxys0wg0f0ic5" path="res://theme/assets/OpenVicFINALREALTRANS.png" id="3_58ess"] -[ext_resource type="PackedScene" uid="uid://b7oncobnacxmt" path="res://src/LocaleButton.tscn" id="3_amonp"] -[ext_resource type="PackedScene" uid="uid://cen7wkmn6og66" path="res://src/MainMenu/ReleaseInfoBox.tscn" id="3_km0er"] - -[node name="MainMenu" type="Control" node_paths=PackedStringArray("_new_game_button")] -editor_description = "UI-13" -layout_mode = 3 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 -theme = ExtResource("1_1yri4") -script = ExtResource("2_nm1fq") -_new_game_button = NodePath("MenuPanel/MenuList/ButtonListMargin/ButtonList/NewGameButton") - -[node name="MenuPanel" type="PanelContainer" parent="."] -layout_mode = 1 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 -theme_type_variation = &"BackgroundPanel" - -[node name="MenuList" type="VBoxContainer" parent="MenuPanel"] -layout_mode = 2 - -[node name="TitleIcon" type="TextureRect" parent="MenuPanel/MenuList"] -layout_mode = 2 -size_flags_vertical = 3 -size_flags_stretch_ratio = 1.75 -texture = ExtResource("3_58ess") -expand_mode = 1 -stretch_mode = 5 - -[node name="ButtonListMargin" type="MarginContainer" parent="MenuPanel/MenuList"] -layout_mode = 2 -theme_override_constants/margin_left = 15 -theme_override_constants/margin_right = 12 - -[node name="ButtonList" type="HBoxContainer" parent="MenuPanel/MenuList/ButtonListMargin"] -custom_minimum_size = Vector2(500, 0) -layout_mode = 2 -theme_type_variation = &"HBox_MainMenu_ButtonList" -theme_override_constants/separation = 18 -alignment = 1 - -[node name="NewGameButton" type="Button" parent="MenuPanel/MenuList/ButtonListMargin/ButtonList"] -editor_description = "UI-26" -layout_mode = 2 -size_flags_horizontal = 3 -focus_neighbor_left = NodePath("../ExitButton") -focus_neighbor_top = NodePath("../ExitButton") -focus_neighbor_right = NodePath("../ContinueButton") -focus_next = NodePath("../ContinueButton") -focus_previous = NodePath("../ExitButton") -theme_type_variation = &"TitleButton" -text = "MAINMENU_NEW_GAME" -clip_text = true - -[node name="ContinueButton" type="Button" parent="MenuPanel/MenuList/ButtonListMargin/ButtonList"] -layout_mode = 2 -size_flags_horizontal = 3 -focus_neighbor_left = NodePath("../NewGameButton") -focus_neighbor_right = NodePath("../MultiplayerButton") -focus_next = NodePath("../MultiplayerButton") -focus_previous = NodePath("../NewGameButton") -theme_type_variation = &"TitleButton" -disabled = true -text = "MAINMENU_CONTINUE" -clip_text = true - -[node name="MultiplayerButton" type="Button" parent="MenuPanel/MenuList/ButtonListMargin/ButtonList"] -editor_description = "UI-27" -layout_mode = 2 -size_flags_horizontal = 3 -focus_neighbor_left = NodePath("../ContinueButton") -focus_neighbor_right = NodePath("../OptionsButton") -focus_next = NodePath("../OptionsButton") -focus_previous = NodePath("../ContinueButton") -theme_type_variation = &"TitleButton" -text = "MAINMENU_MULTIPLAYER" -clip_text = true - -[node name="OptionsButton" type="Button" parent="MenuPanel/MenuList/ButtonListMargin/ButtonList"] -editor_description = "UI-5" -layout_mode = 2 -size_flags_horizontal = 3 -focus_neighbor_left = NodePath("../MultiplayerButton") -focus_neighbor_right = NodePath("../CreditsButton") -focus_next = NodePath("../CreditsButton") -focus_previous = NodePath("../MultiplayerButton") -theme_type_variation = &"TitleButton" -text = "MAINMENU_OPTIONS" -clip_text = true - -[node name="CreditsButton" type="Button" parent="MenuPanel/MenuList/ButtonListMargin/ButtonList"] -editor_description = "UI-32" -layout_mode = 2 -size_flags_horizontal = 3 -focus_neighbor_left = NodePath("../OptionsButton") -focus_neighbor_right = NodePath("../ExitButton") -focus_next = NodePath("../ExitButton") -focus_previous = NodePath("../OptionsButton") -theme_type_variation = &"TitleButton" -text = "MAINMENU_CREDITS" -clip_text = true - -[node name="ExitButton" type="Button" parent="MenuPanel/MenuList/ButtonListMargin/ButtonList"] -editor_description = "UI-3" -layout_mode = 2 -size_flags_horizontal = 3 -focus_neighbor_left = NodePath("../OptionsButton") -focus_neighbor_right = NodePath("../NewGameButton") -focus_next = NodePath("../NewGameButton") -focus_previous = NodePath("../OptionsButton") -theme_type_variation = &"TitleButton" -text = "MAINMENU_EXIT" -clip_text = true - -[node name="BottomSpace" type="Control" parent="MenuPanel/MenuList"] -layout_mode = 2 -size_flags_vertical = 3 -size_flags_stretch_ratio = 0.35 - -[node name="BottomMargin" type="MarginContainer" parent="MenuPanel/MenuList"] -layout_mode = 2 -theme_type_variation = &"BottomMargin" - -[node name="ReleaseInfoBox" parent="MenuPanel/MenuList/BottomMargin" instance=ExtResource("3_km0er")] -layout_mode = 2 - -[node name="LocaleButton" parent="MenuPanel/MenuList/BottomMargin" instance=ExtResource("3_amonp")] -layout_mode = 2 -size_flags_horizontal = 8 -alignment = 0 -text_overrun_behavior = 4 - -[connection signal="pressed" from="MenuPanel/MenuList/ButtonListMargin/ButtonList/NewGameButton" to="." method="_on_new_game_button_pressed"] -[connection signal="visibility_changed" from="MenuPanel/MenuList/ButtonListMargin/ButtonList/NewGameButton" to="." method="_on_new_game_button_visibility_changed"] -[connection signal="pressed" from="MenuPanel/MenuList/ButtonListMargin/ButtonList/ContinueButton" to="." method="_on_continue_button_pressed"] -[connection signal="pressed" from="MenuPanel/MenuList/ButtonListMargin/ButtonList/MultiplayerButton" to="." method="_on_multi_player_button_pressed"] -[connection signal="pressed" from="MenuPanel/MenuList/ButtonListMargin/ButtonList/OptionsButton" to="." method="_on_options_button_pressed"] -[connection signal="pressed" from="MenuPanel/MenuList/ButtonListMargin/ButtonList/CreditsButton" to="." method="_on_credits_button_pressed"] -[connection signal="pressed" from="MenuPanel/MenuList/ButtonListMargin/ButtonList/ExitButton" to="." method="_on_exit_button_pressed"] diff --git a/game/src/MainMenu/ReleaseInfoBox.gd b/game/src/MainMenu/ReleaseInfoBox.gd deleted file mode 100644 index e363162..0000000 --- a/game/src/MainMenu/ReleaseInfoBox.gd +++ /dev/null @@ -1,41 +0,0 @@ -extends HBoxContainer - -@export -var _version_label : Button - -@export -var _commit_label : Button - -@export -var _checksum_label : Button - -var _checksum : String = "????" - -# REQUIREMENTS: -# * UIFUN-97 -func _ready(): - _version_label.text = _GIT_INFO_.release_name - _version_label.tooltip_text = _GIT_INFO_.tag - _commit_label.text = _GIT_INFO_.short_hash - _commit_label.tooltip_text = _GIT_INFO_.commit_hash - # UI-111 - _checksum = Checksum.get_checksum_text() - _update_checksum_label_text() - -func _notification(what : int): - match what: - NOTIFICATION_TRANSLATION_CHANGED: - _update_checksum_label_text() - -func _update_checksum_label_text() -> void: - _checksum_label.tooltip_text = tr("MAINMENU_CHECKSUM").format({ "checksum": _checksum }) - _checksum_label.text = "(%s)" % _checksum.substr(0, 4) - -func _on_version_label_pressed(): - DisplayServer.clipboard_set(_GIT_INFO_.tag) - -func _on_commit_label_pressed(): - DisplayServer.clipboard_set(_GIT_INFO_.commit_hash) - -func _on_checksum_label_pressed(): - DisplayServer.clipboard_set(_checksum) diff --git a/game/src/MainMenu/ReleaseInfoBox.tscn b/game/src/MainMenu/ReleaseInfoBox.tscn deleted file mode 100644 index 821982b..0000000 --- a/game/src/MainMenu/ReleaseInfoBox.tscn +++ /dev/null @@ -1,38 +0,0 @@ -[gd_scene load_steps=2 format=3 uid="uid://cen7wkmn6og66"] - -[ext_resource type="Script" path="res://src/MainMenu/ReleaseInfoBox.gd" id="1_y2djw"] - -[node name="ReleaseInfoBox" type="HBoxContainer" node_paths=PackedStringArray("_version_label", "_commit_label", "_checksum_label")] -editor_description = "UI-31" -script = ExtResource("1_y2djw") -_version_label = NodePath("VersionLabel") -_commit_label = NodePath("CommitLabel") -_checksum_label = NodePath("ChecksumLabel") - -[node name="VersionLabel" type="Button" parent="."] -layout_mode = 2 -tooltip_text = "VERSION_MISSING" -theme_type_variation = &"VersionLabel" -text = "VERSION_MISSING" -flat = true -alignment = 0 - -[node name="CommitLabel" type="Button" parent="."] -layout_mode = 2 -theme_type_variation = &"CommitLabel" -text = "????????" -flat = true -alignment = 0 - -[node name="ChecksumLabel" type="Button" parent="."] -editor_description = "UI-111" -layout_mode = 2 -tooltip_text = "CHECKSUM_MISSING" -theme_type_variation = &"ChecksumLabel" -text = "(????)" -flat = true -alignment = 0 - -[connection signal="pressed" from="VersionLabel" to="." method="_on_version_label_pressed"] -[connection signal="pressed" from="CommitLabel" to="." method="_on_commit_label_pressed"] -[connection signal="pressed" from="ChecksumLabel" to="." method="_on_checksum_label_pressed"] diff --git a/game/src/MusicConductor/MusicConductor.gd b/game/src/MusicConductor/MusicConductor.gd deleted file mode 100644 index 98dd0eb..0000000 --- a/game/src/MusicConductor/MusicConductor.gd +++ /dev/null @@ -1,77 +0,0 @@ -extends Node - -# REQUIREMENTS -# * SS-67 -@export_dir var music_directory : String -@export var first_song_name : String - -var _selected_track = 0 -var _available_songs : Array[SongInfo] = [] -var _auto_play_next_song : bool = true - -## True if music player should be visible. -## Used to keep keep consistency between scene changes -var is_music_player_visible : bool = true - -func get_all_song_names() -> Array[String]: - var songNames : Array[String] = [] - for si in _available_songs: - songNames.append(si.song_name) - return songNames - -func get_current_song_index() -> int: - return _selected_track - -func get_current_song_name() -> String: - return _available_songs[_selected_track].song_name - -func scrub_song_by_percentage(percentage: float) -> void: - var percentInSeconds : float = (percentage / 100.0) * $AudioStreamPlayer.stream.get_length() - $AudioStreamPlayer.play(percentInSeconds) - -func get_current_song_progress_percentage() -> float: - return 100 * ($AudioStreamPlayer.get_playback_position() / $AudioStreamPlayer.stream.get_length()) - -func is_paused() -> bool: - return $AudioStreamPlayer.stream_paused - -func toggle_play_pause() -> void: - $AudioStreamPlayer.stream_paused = !$AudioStreamPlayer.stream_paused - -func start_current_song() -> void: - $AudioStreamPlayer.stream = _available_songs[_selected_track].song_stream - $AudioStreamPlayer.play() - -# REQUIREMENTS -# * SS-70 -func start_song_by_index(id: int) -> void: - _selected_track = id - start_current_song() - -# REQUIREMENTS -# * SS-69 -func select_next_song() -> void: - _selected_track = (_selected_track + 1) % len(_available_songs) - start_current_song() - -func select_previous_song() -> void: - _selected_track = (len(_available_songs) - 1) if (_selected_track == 0) else (_selected_track - 1) - start_current_song() - -# REQUIREMENTS -# * SND-2 -func _ready(): - var dir = DirAccess.open(music_directory) - for fname in dir.get_files(): - if fname.ends_with(".import"): - fname = fname.get_basename() - if fname.get_basename() == first_song_name: - _selected_track = _available_songs.size() - _available_songs.append(SongInfo.new(music_directory, fname)) - start_current_song() - - -func _on_audio_stream_player_finished(): - if _auto_play_next_song: - select_next_song() - start_current_song() diff --git a/game/src/MusicConductor/MusicConductor.tscn b/game/src/MusicConductor/MusicConductor.tscn deleted file mode 100644 index 182de99..0000000 --- a/game/src/MusicConductor/MusicConductor.tscn +++ /dev/null @@ -1,13 +0,0 @@ -[gd_scene load_steps=2 format=3 uid="uid://b1h31mnn8n2nu"] - -[ext_resource type="Script" path="res://src/MusicConductor/MusicConductor.gd" id="1_56t1b"] - -[node name="MusicConductor" type="Node"] -script = ExtResource("1_56t1b") -music_directory = "res://audio/music" -first_song_name = "The_Crown" - -[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."] -bus = &"MUSIC_BUS" - -[connection signal="finished" from="AudioStreamPlayer" to="." method="_on_audio_stream_player_finished"] diff --git a/game/src/MusicConductor/MusicPlayer.gd b/game/src/MusicConductor/MusicPlayer.gd deleted file mode 100644 index 47be158..0000000 --- a/game/src/MusicConductor/MusicPlayer.gd +++ /dev/null @@ -1,73 +0,0 @@ -extends Control - -@export var _song_selector_button : OptionButton -@export var _progress_slider : HSlider -@export var _previous_song_button : Button -@export var _play_pause_button : Button -@export var _next_song_button : Button -@export var _visbility_button : Button - -var _is_user_dragging_progress_slider : bool = false - -func _ready(): - for songName in MusicConductor.get_all_song_names(): - _song_selector_button.add_item(songName, _song_selector_button.item_count) - _update_song_name_visual() - _update_play_pause_button() - _set_music_player_visible(MusicConductor.is_music_player_visible) - - -func _process(_delta): - if !_is_user_dragging_progress_slider: - _progress_slider.value = MusicConductor.get_current_song_progress_percentage() - -func _update_song_name_visual(): - _song_selector_button.selected = MusicConductor.get_current_song_index() - -func _update_play_pause_button(): - _play_pause_button.text = "◼" if MusicConductor.is_paused() else "▶" - -func _on_play_pause_button_pressed(): - MusicConductor.toggle_play_pause() - _update_play_pause_button() - -func _on_next_song_button_pressed(): - MusicConductor.select_next_song() - _update_song_name_visual() - _update_play_pause_button() - -func _on_previous_song_button_pressed(): - MusicConductor.select_previous_song() - _update_song_name_visual() - _update_play_pause_button() - -# REQUIREMENTS -# * UIFUN-92 -func _on_option_button_item_selected(index): - MusicConductor.start_song_by_index(index) - _update_song_name_visual() - _update_play_pause_button() - - -func _on_progress_slider_drag_started(): - _is_user_dragging_progress_slider = true - - -func _on_progress_slider_drag_ended(_value_changed): - MusicConductor.scrub_song_by_percentage(_progress_slider.value) - _is_user_dragging_progress_slider = false - _update_play_pause_button() - -func _set_music_player_visible(is_player_visible : bool) -> void: - MusicConductor.is_music_player_visible = is_player_visible - _visbility_button.text = "⬆️" if is_player_visible else "⬇" - _song_selector_button.visible = is_player_visible - _progress_slider.visible = is_player_visible - _previous_song_button.visible = is_player_visible - _play_pause_button.visible = is_player_visible - _next_song_button.visible = is_player_visible - -# REQUIREMENTS -# * UIFUN-91 -func _on_music_ui_visibility_button_pressed(): - _set_music_player_visible(not MusicConductor.is_music_player_visible) diff --git a/game/src/MusicConductor/MusicPlayer.tscn b/game/src/MusicConductor/MusicPlayer.tscn deleted file mode 100644 index 80ad641..0000000 --- a/game/src/MusicConductor/MusicPlayer.tscn +++ /dev/null @@ -1,63 +0,0 @@ -[gd_scene load_steps=2 format=3 uid="uid://cvl76duuym1wq"] - -[ext_resource type="Script" path="res://src/MusicConductor/MusicPlayer.gd" id="1_gcm4m"] - -[node name="MusicPlayer" type="BoxContainer" node_paths=PackedStringArray("_song_selector_button", "_progress_slider", "_previous_song_button", "_play_pause_button", "_next_song_button", "_visbility_button")] -editor_description = "UI-104" -offset_right = 150.0 -offset_bottom = 110.0 -mouse_filter = 2 -vertical = true -script = ExtResource("1_gcm4m") -_song_selector_button = NodePath("SongSelectorButton") -_progress_slider = NodePath("ProgressSlider") -_previous_song_button = NodePath("ButtonList/PreviousSongButton") -_play_pause_button = NodePath("ButtonList/PlayPauseButton") -_next_song_button = NodePath("ButtonList/NextSongButton") -_visbility_button = NodePath("MusicUIVisibilityButton") - -[node name="SongSelectorButton" type="OptionButton" parent="."] -editor_description = "UI-107" -custom_minimum_size = Vector2(150, 0) -layout_mode = 2 -alignment = 1 -text_overrun_behavior = 3 -fit_to_longest_item = false - -[node name="ProgressSlider" type="HSlider" parent="."] -custom_minimum_size = Vector2(150, 0) -layout_mode = 2 -size_flags_vertical = 1 - -[node name="ButtonList" type="HBoxContainer" parent="."] -layout_mode = 2 -size_flags_horizontal = 4 -mouse_filter = 2 - -[node name="PreviousSongButton" type="Button" parent="ButtonList"] -layout_mode = 2 -text = "<" - -[node name="PlayPauseButton" type="Button" parent="ButtonList"] -custom_minimum_size = Vector2(30, 0) -layout_mode = 2 -text = "▶" - -[node name="NextSongButton" type="Button" parent="ButtonList"] -layout_mode = 2 -text = ">" - -[node name="MusicUIVisibilityButton" type="Button" parent="."] -editor_description = "UI-106" -layout_mode = 2 -size_flags_horizontal = 4 -toggle_mode = true -text = "⬆" - -[connection signal="item_selected" from="SongSelectorButton" to="." method="_on_option_button_item_selected"] -[connection signal="drag_ended" from="ProgressSlider" to="." method="_on_progress_slider_drag_ended"] -[connection signal="drag_started" from="ProgressSlider" to="." method="_on_progress_slider_drag_started"] -[connection signal="pressed" from="ButtonList/PreviousSongButton" to="." method="_on_previous_song_button_pressed"] -[connection signal="pressed" from="ButtonList/PlayPauseButton" to="." method="_on_play_pause_button_pressed"] -[connection signal="pressed" from="ButtonList/NextSongButton" to="." method="_on_next_song_button_pressed"] -[connection signal="pressed" from="MusicUIVisibilityButton" to="." method="_on_music_ui_visibility_button_pressed"] diff --git a/game/src/MusicConductor/SongInfo.gd b/game/src/MusicConductor/SongInfo.gd deleted file mode 100644 index 1ee9adc..0000000 --- a/game/src/MusicConductor/SongInfo.gd +++ /dev/null @@ -1,11 +0,0 @@ -extends Resource -class_name SongInfo - -var song_path : String = "" -var song_name : String = "" -var song_stream : Resource - -func _init(dirname:String, fname:String): - song_path = dirname.path_join(fname) - song_name = fname.get_basename().replace("_", " ") - song_stream = load(song_path) diff --git a/game/src/OptionMenu/AutosaveIntervalSelector.gd b/game/src/OptionMenu/AutosaveIntervalSelector.gd deleted file mode 100644 index 2c55862..0000000 --- a/game/src/OptionMenu/AutosaveIntervalSelector.gd +++ /dev/null @@ -1,2 +0,0 @@ -extends SettingOptionButton - diff --git a/game/src/OptionMenu/ControlsTab.tscn b/game/src/OptionMenu/ControlsTab.tscn deleted file mode 100644 index b84dc85..0000000 --- a/game/src/OptionMenu/ControlsTab.tscn +++ /dev/null @@ -1,14 +0,0 @@ -[gd_scene load_steps=2 format=3 uid="uid://cdwymd51i4b2f"] - -[ext_resource type="PackedScene" uid="uid://by4gggse2nsdx" path="res://addons/keychain/ShortcutEdit.tscn" id="1_fv8sh"] - -[node name="Controls" type="Control"] -layout_mode = 3 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 - -[node name="ShortcutEdit" parent="." instance=ExtResource("1_fv8sh")] -layout_mode = 1 diff --git a/game/src/OptionMenu/GeneralTab.gd b/game/src/OptionMenu/GeneralTab.gd deleted file mode 100644 index 3d98678..0000000 --- a/game/src/OptionMenu/GeneralTab.gd +++ /dev/null @@ -1,9 +0,0 @@ -extends HBoxContainer - -@export var initial_focus: Control - -func _notification(what : int) -> void: - match(what): - NOTIFICATION_VISIBILITY_CHANGED: - if visible and is_inside_tree(): - initial_focus.grab_focus() diff --git a/game/src/OptionMenu/GeneralTab.tscn b/game/src/OptionMenu/GeneralTab.tscn deleted file mode 100644 index 4e9ff6a..0000000 --- a/game/src/OptionMenu/GeneralTab.tscn +++ /dev/null @@ -1,81 +0,0 @@ -[gd_scene load_steps=5 format=3 uid="uid://duwjal7sd7p6w"] - -[ext_resource type="Script" path="res://src/OptionMenu/GeneralTab.gd" id="1_gbutn"] -[ext_resource type="PackedScene" uid="uid://b7oncobnacxmt" path="res://src/LocaleButton.tscn" id="2_5cfd7"] -[ext_resource type="Script" path="res://src/OptionMenu/SettingNodes/SettingOptionButton.gd" id="2_msx2u"] -[ext_resource type="Script" path="res://src/OptionMenu/AutosaveIntervalSelector.gd" id="2_t06tb"] - -[node name="GeneralTab" type="HBoxContainer" node_paths=PackedStringArray("initial_focus")] -editor_description = "UI-48, UIFUN-45" -alignment = 1 -script = ExtResource("1_gbutn") -initial_focus = NodePath("VBoxContainer/GridContainer/SavegameFormatSelector") - -[node name="VBoxContainer" type="VBoxContainer" parent="."] -layout_mode = 2 - -[node name="Control" type="Control" parent="VBoxContainer"] -layout_mode = 2 -size_flags_vertical = 3 -size_flags_stretch_ratio = 0.1 - -[node name="GridContainer" type="GridContainer" parent="VBoxContainer"] -layout_mode = 2 -size_flags_vertical = 3 -columns = 2 - -[node name="SavegameFormatLabel" type="Label" parent="VBoxContainer/GridContainer"] -layout_mode = 2 -text = "OPTIONS_GENERAL_SAVEFORMAT" - -[node name="SavegameFormatSelector" type="OptionButton" parent="VBoxContainer/GridContainer"] -editor_description = "UI-50" -layout_mode = 2 -focus_neighbor_bottom = NodePath("../AutosaveIntervalSelector") -item_count = 2 -selected = 0 -popup/item_0/text = "OPTIONS_GENERAL_BINARY" -popup/item_0/id = 0 -popup/item_1/text = "OPTIONS_GENERAL_TEXT" -popup/item_1/id = 1 -script = ExtResource("2_msx2u") -section_name = "general" -setting_name = "savegame_format" -default_selected = 0 - -[node name="AutosaveIntervalLabel" type="Label" parent="VBoxContainer/GridContainer"] -layout_mode = 2 -text = "OPTIONS_GENERAL_AUTOSAVE" - -[node name="AutosaveIntervalSelector" type="OptionButton" parent="VBoxContainer/GridContainer"] -editor_description = "UI-15, UIFUN-19" -layout_mode = 2 -focus_neighbor_top = NodePath("../SavegameFormatSelector") -focus_neighbor_bottom = NodePath("../LocaleButton") -item_count = 5 -selected = 0 -popup/item_0/text = "OPTIONS_GENERAL_AUTOSAVE_MONTHLY" -popup/item_0/id = 0 -popup/item_1/text = "OPTIONS_GENERAL_AUTOSAVE_BIMONTHLY" -popup/item_1/id = 1 -popup/item_2/text = "OPTIONS_GENERAL_AUTOSAVE_YEARLY" -popup/item_2/id = 2 -popup/item_3/text = "OPTIONS_GENERAL_AUTOSAVE_BIYEARLY" -popup/item_3/id = 3 -popup/item_4/text = "OPTIONS_GENERAL_AUTOSAVE_NEVER" -popup/item_4/id = 4 -script = ExtResource("2_t06tb") -section_name = "general" -setting_name = "autosave_interval" -default_selected = 0 - -[node name="LocaleLabel" type="Label" parent="VBoxContainer/GridContainer"] -layout_mode = 2 -text = "OPTIONS_GENERAL_LANGUAGE" - -[node name="LocaleButton" parent="VBoxContainer/GridContainer" instance=ExtResource("2_5cfd7")] -editor_description = "UI-79" -layout_mode = 2 -focus_neighbor_top = NodePath("../AutosaveIntervalSelector") -alignment = 0 -text_overrun_behavior = 4 diff --git a/game/src/OptionMenu/GuiScaleSelector.gd b/game/src/OptionMenu/GuiScaleSelector.gd deleted file mode 100644 index 4dd86e1..0000000 --- a/game/src/OptionMenu/GuiScaleSelector.gd +++ /dev/null @@ -1,64 +0,0 @@ -extends SettingOptionButton - -# REQUIREMENTS -# * UIFUN-24 -# * UIFUN-31 - -@export -var default_value : float = GuiScale.error_guiscale - -func _find_guiscale_index_by_value(value : float) -> int: - for item_index in item_count: - if get_item_metadata(item_index) == value: - return item_index - return -1 - -func _sync_guiscales(to_select : float = GuiScale.get_current_guiscale()) -> void: - clear() - default_selected = -1 - selected = -1 - for guiscale_value in GuiScale.get_guiscale_value_list(): - add_item(GuiScale.get_guiscale_display_name(guiscale_value)) - set_item_metadata(item_count - 1, guiscale_value) - - if guiscale_value == default_value: - default_selected = item_count - 1 - - if guiscale_value == to_select: - selected = item_count - 1 - - if default_selected == -1: - default_selected = item_count - 1 - - if selected == -1: - selected = default_selected - -func _setup_button(): - if default_value <= 0: - default_value = ProjectSettings.get_setting("display/window/stretch/scale") - GuiScale.add_guiscale(default_value, &"default") - _sync_guiscales() - -func _get_value_for_file(select_value : int): - if _valid_index(select_value): - return get_item_metadata(select_value) - else: - return null - -func _set_value_from_file(load_value): - if typeof(load_value) == TYPE_FLOAT: - var target_guiscale : float = load_value - selected = _find_guiscale_index_by_value(target_guiscale) - if selected != -1: return - if GuiScale.add_guiscale(target_guiscale): - _sync_guiscales(target_guiscale) - return - push_error("Setting value '%s' invalid for setting [%s] %s" % [load_value, section_name, setting_name]) - selected = default_selected - -func _on_option_selected(index : int, by_user : bool): - if _valid_index(index): - GuiScale.set_guiscale(get_item_metadata(index)) - else: - push_error("Invalid GuiScaleSelector index: %d" % index) - reset_setting(not by_user) diff --git a/game/src/OptionMenu/MonitorDisplaySelector.gd b/game/src/OptionMenu/MonitorDisplaySelector.gd deleted file mode 100644 index 7de033a..0000000 --- a/game/src/OptionMenu/MonitorDisplaySelector.gd +++ /dev/null @@ -1,18 +0,0 @@ -extends SettingOptionButton - -func _setup_button() -> void: - clear() - for screen_index in DisplayServer.get_screen_count(): - add_item("Monitor %d" % (screen_index + 1)) - default_selected = get_viewport().get_window().current_screen - -func _on_option_selected(index : int, by_user : bool) -> void: - if _valid_index(index): - var window := get_viewport().get_window() - var mode := window.mode - window.mode = Window.MODE_WINDOWED - get_viewport().get_window().set_current_screen(index) - window.mode = mode - else: - push_error("Invalid MonitorDisplaySelector index: %d" % index) - reset_setting(not by_user) diff --git a/game/src/OptionMenu/OptionsMenu.gd b/game/src/OptionMenu/OptionsMenu.gd deleted file mode 100644 index 5f6a088..0000000 --- a/game/src/OptionMenu/OptionsMenu.gd +++ /dev/null @@ -1,68 +0,0 @@ -extends Control - -# REQUIREMENTS -# * SS-13 - -signal back_button_pressed - -func _ready(): - # Prepare options menu before loading user settings - var tab_bar : TabBar = $Margin/Tab.get_child(0, true) - - # This ends up easier to manage then trying to manually recreate the TabContainer's behavior - # These buttons can be accessed regardless of the tab - var button_list := HBoxContainer.new() - button_list.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT) - button_list.alignment = BoxContainer.ALIGNMENT_END - tab_bar.add_child(button_list) - - # REQUIREMENTS - # * UI-12 - # * UIFUN-14 - var reset_button := Button.new() - reset_button.text = "OPTIONS_RESET" - reset_button.pressed.connect(Events.Options.try_reset_settings) - button_list.add_child(reset_button) - - # REQUIREMENTS - # * UI-11 - # * UIFUN-17 - var back_button := Button.new() - back_button.text = "OPTIONS_BACK" - back_button.pressed.connect(_on_back_button_pressed) - button_list.add_child(back_button) - get_viewport().get_window().close_requested.connect(_on_window_close_requested) - _save_overrides.call_deferred() - Events.Options.save_settings.connect(func(_f): self._save_overrides.call_deferred()) - -func _notification(what): - match what: - NOTIFICATION_CRASH: - _on_window_close_requested() - -func _input(event): - if self.is_visible_in_tree(): - if event.is_action_pressed("ui_cancel"): - _on_back_button_pressed() - -func _on_back_button_pressed(): - Events.Options.save_settings_to_file() - back_button_pressed.emit() - -func _on_window_close_requested() -> void: - if visible: - Events.Options.save_settings_to_file() - -func _save_overrides() -> void: - var override_path : String = ProjectSettings.get_setting("application/config/project_settings_override", "") - if override_path.is_empty(): - override_path = ProjectSettings.get_setting(Events.Options.settings_file_path_setting, Events.Options.settings_file_path_default) - var file := ConfigFile.new() - var err_ret := file.load(override_path) - if err_ret != OK: push_error("Failed to load overrides from %s" % override_path) - file.set_value("display", "window/size/mode", get_viewport().get_window().mode) - var resolution : Vector2i = Resolution.get_current_resolution() - file.set_value("display", "window/size/viewport_width", resolution.x) - file.set_value("display", "window/size/viewport_height", resolution.y) - err_ret = file.save(override_path) - if err_ret != OK: push_error("Failed to save overrides to %s" % override_path) diff --git a/game/src/OptionMenu/OptionsMenu.tscn b/game/src/OptionMenu/OptionsMenu.tscn deleted file mode 100644 index 3156e33..0000000 --- a/game/src/OptionMenu/OptionsMenu.tscn +++ /dev/null @@ -1,52 +0,0 @@ -[gd_scene load_steps=8 format=3 uid="uid://cnbfxjy1m6wja"] - -[ext_resource type="Theme" uid="uid://fbxssqcg1s0m" path="res://theme/options_menu.tres" id="1_0up1d"] -[ext_resource type="Script" path="res://src/OptionMenu/OptionsMenu.gd" id="1_tlein"] -[ext_resource type="PackedScene" uid="uid://bq3awxxjn1tuw" path="res://src/OptionMenu/VideoTab.tscn" id="2_ji8xr"] -[ext_resource type="PackedScene" uid="uid://cbtgwpx2wxi33" path="res://src/OptionMenu/SoundTab.tscn" id="3_4w35t"] -[ext_resource type="PackedScene" uid="uid://duwjal7sd7p6w" path="res://src/OptionMenu/GeneralTab.tscn" id="3_6gvf6"] -[ext_resource type="PackedScene" uid="uid://bq7ibhm0txl5p" path="res://addons/keychain/ShortcutEdit.tscn" id="4_vdhjp"] -[ext_resource type="PackedScene" uid="uid://dp2grvybtecqu" path="res://src/OptionMenu/OtherTab.tscn" id="5_ahefp"] - -[node name="OptionsMenu" type="PanelContainer"] -editor_description = "UI-25" -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 -theme = ExtResource("1_0up1d") -theme_type_variation = &"BackgroundPanel" -script = ExtResource("1_tlein") - -[node name="Margin" type="MarginContainer" parent="."] -layout_mode = 2 -theme_type_variation = &"TabMargin" - -[node name="Tab" type="TabContainer" parent="Margin"] -editor_description = "UI-45" -layout_mode = 2 -tab_alignment = 1 -use_hidden_tabs_for_min_size = true - -[node name="General" parent="Margin/Tab" instance=ExtResource("3_6gvf6")] -layout_mode = 2 - -[node name="Video" parent="Margin/Tab" instance=ExtResource("2_ji8xr")] -editor_description = "UI-46, UIFUN-43" -visible = false -layout_mode = 2 - -[node name="Sound" parent="Margin/Tab" instance=ExtResource("3_4w35t")] -editor_description = "UI-47, UIFUN-44" -visible = false -layout_mode = 2 - -[node name="Controls" parent="Margin/Tab" instance=ExtResource("4_vdhjp")] -editor_description = "SS-27, UI-49, UIFUN-46" -visible = false -layout_mode = 2 -alignment = 1 - -[node name="Other" parent="Margin/Tab" instance=ExtResource("5_ahefp")] -layout_mode = 2 diff --git a/game/src/OptionMenu/OtherTab.tscn b/game/src/OptionMenu/OtherTab.tscn deleted file mode 100644 index 0ffc92d..0000000 --- a/game/src/OptionMenu/OtherTab.tscn +++ /dev/null @@ -1,18 +0,0 @@ -[gd_scene format=3 uid="uid://dp2grvybtecqu"] - -[node name="Other" type="Control"] -visible = false -layout_mode = 3 -anchors_preset = 0 - -[node name="HBoxContainer" type="HBoxContainer" parent="."] -layout_mode = 0 -offset_right = 40.0 -offset_bottom = 40.0 - -[node name="Label" type="Label" parent="HBoxContainer"] -layout_mode = 2 -text = "Spinbox Example :)" - -[node name="SpinBox" type="SpinBox" parent="HBoxContainer"] -layout_mode = 2 diff --git a/game/src/OptionMenu/QualityPresetSelector.gd b/game/src/OptionMenu/QualityPresetSelector.gd deleted file mode 100644 index 57ba4ab..0000000 --- a/game/src/OptionMenu/QualityPresetSelector.gd +++ /dev/null @@ -1,4 +0,0 @@ -extends SettingOptionButton - -func _setup_button(): - pass diff --git a/game/src/OptionMenu/RefreshRateSelector.gd b/game/src/OptionMenu/RefreshRateSelector.gd deleted file mode 100644 index 31b115b..0000000 --- a/game/src/OptionMenu/RefreshRateSelector.gd +++ /dev/null @@ -1,5 +0,0 @@ -extends SettingOptionButton - - -func _setup_button(): - pass diff --git a/game/src/OptionMenu/ResolutionRevertDialog.gd b/game/src/OptionMenu/ResolutionRevertDialog.gd deleted file mode 100644 index 4d2b8f2..0000000 --- a/game/src/OptionMenu/ResolutionRevertDialog.gd +++ /dev/null @@ -1,35 +0,0 @@ -extends ConfirmationDialog -class_name ResolutionRevertDialog - -signal dialog_accepted(button : SettingRevertButton) -signal dialog_reverted(button : SettingRevertButton) - -@export_group("Nodes") -@export var timer : Timer - -var _revert_node : SettingRevertButton = null - -func show_dialog(button : SettingRevertButton, time : float = 0) -> void: - timer.start(time) - popup_centered(Vector2(1,1)) - _revert_node = button - -func _notification(what): - if what == NOTIFICATION_VISIBILITY_CHANGED: - set_process(visible) - if not visible: _revert_node = null - -func _process(_delta) -> void: - dialog_text = tr("OPTIONS_VIDEO_RESOLUTION_DIALOG_TEXT").format({ "time": int(timer.time_left) }) - -func _on_canceled_or_close_requested() -> void: - timer.stop() - dialog_reverted.emit(_revert_node) - -func _on_confirmed() -> void: - timer.stop() - dialog_accepted.emit(_revert_node) - -func _on_resolution_revert_timer_timeout() -> void: - dialog_reverted.emit(_revert_node) - hide() diff --git a/game/src/OptionMenu/ResolutionSelector.gd b/game/src/OptionMenu/ResolutionSelector.gd deleted file mode 100644 index ebdf718..0000000 --- a/game/src/OptionMenu/ResolutionSelector.gd +++ /dev/null @@ -1,91 +0,0 @@ -extends SettingRevertButton - -# REQUIREMENTS -# * UIFUN-21 -# * UIFUN-28 -# * UIFUN-301 -# * UIFUN-302 - -@export var default_value : Vector2i = Resolution.error_resolution - -func _find_resolution_index_by_value(value : Vector2i) -> int: - for item_index in item_count: - if get_item_metadata(item_index) == value: - return item_index - return -1 - -func _sync_resolutions( - value : Vector2i = Resolution.error_resolution, - _resolution_name = null, - _resolution_display_name = null -) -> void: - clear() - default_selected = -1 - selected = -1 - var resolution_list := Resolution.get_resolution_value_list() - if value != Resolution.error_resolution: - resolution_list.append(value) - for resolution_value in resolution_list: - var display_name := "%sx%s" % [resolution_value.x, resolution_value.y] - var resolution_name := Resolution.get_resolution_name(resolution_value) - if resolution_name == &"Default": - display_name = "Default (%s)" % resolution_name - if not resolution_name.is_empty(): - display_name = "%s (%s)" % [display_name, resolution_name + (", Default" if resolution_value == default_value else "")] - add_item(display_name) - set_item_metadata(item_count - 1, resolution_value) - - if resolution_value == default_value: - default_selected = item_count - 1 - - if resolution_value == Resolution.get_current_resolution(): - selected = item_count - 1 - - if default_selected == -1: - default_selected = item_count - 1 - - if selected == -1: - selected = default_selected - -func _setup_button() -> void: - Resolution.resolution_added.connect(_sync_resolutions) - if default_value.x <= 0: - default_value.x = ProjectSettings.get_setting("display/window/size/viewport_width") - if default_value.y <= 0: - default_value.y = ProjectSettings.get_setting("display/window/size/viewport_height") - if not Resolution.has_resolution(default_value): - Resolution.add_resolution(default_value, &"Default") - else: - _sync_resolutions() - -func _get_value_for_file(select_value : int) -> Variant: - if _valid_index(select_value): - return get_item_metadata(select_value) - else: - return null - -func _set_value_from_file(load_value) -> void: - var target_resolution := Resolution.error_resolution - match typeof(load_value): - TYPE_VECTOR2I: target_resolution = load_value - TYPE_STRING, TYPE_STRING_NAME: target_resolution = Resolution.get_resolution_value_from_string(load_value) - if target_resolution != Resolution.error_resolution: - selected = _find_resolution_index_by_value(target_resolution) - if selected != -1: return - if Resolution.add_resolution(target_resolution): - Resolution.set_resolution(target_resolution) - return - push_error("Setting value '%s' invalid for setting [%s] %s" % [load_value, section_name, setting_name]) - selected = default_selected - -func _on_option_selected(index : int, by_user : bool) -> void: - if _valid_index(index): - if by_user: - print("Start Revert Countdown!") - revert_dialog.show_dialog.call_deferred(self) - previous_index = _find_resolution_index_by_value(Resolution.get_current_resolution()) - - Resolution.set_resolution(get_item_metadata(index)) - else: - push_error("Invalid ResolutionSelector index: %d" % index) - reset_setting(not by_user) diff --git a/game/src/OptionMenu/ScreenModeSelector.gd b/game/src/OptionMenu/ScreenModeSelector.gd deleted file mode 100644 index af95901..0000000 --- a/game/src/OptionMenu/ScreenModeSelector.gd +++ /dev/null @@ -1,48 +0,0 @@ -extends SettingRevertButton - -# REQUIREMENTS -# * UIFUN-42 - -enum ScreenMode { Unknown = -1, Fullscreen, Borderless, Windowed } - -func get_screen_mode_from_window_mode(window_mode : int) -> ScreenMode: - match window_mode: - Window.MODE_EXCLUSIVE_FULLSCREEN: - return ScreenMode.Fullscreen - Window.MODE_FULLSCREEN: - return ScreenMode.Borderless - Window.MODE_WINDOWED: - return ScreenMode.Windowed - _: - return ScreenMode.Unknown - -func get_window_mode_from_screen_mode(screen_mode : int) -> Window.Mode: - match screen_mode: - ScreenMode.Fullscreen: - return Window.MODE_EXCLUSIVE_FULLSCREEN - ScreenMode.Borderless: - return Window.MODE_FULLSCREEN - ScreenMode.Windowed: - return Window.MODE_WINDOWED - _: - return Window.MODE_EXCLUSIVE_FULLSCREEN - -func _setup_button(): - default_selected = get_screen_mode_from_window_mode(get_viewport().get_window().mode) - selected = default_selected - -func _on_option_selected(index : int, by_user : bool) -> void: - if _valid_index(index): - if by_user: - print("Start Revert Countdown!") - revert_dialog.show_dialog.call_deferred(self) - previous_index = get_screen_mode_from_window_mode(get_viewport().get_window().mode) - - var current_resolution := Resolution.get_current_resolution() - var window_mode := get_window_mode_from_screen_mode(index) - Resolution.window_mode_changed.emit(window_mode) - get_viewport().get_window().mode = window_mode - Resolution.set_resolution(current_resolution) - else: - push_error("Invalid ScreenModeSelector index: %d" % index) - reset_setting(not by_user) diff --git a/game/src/OptionMenu/SettingNodes/SettingHSlider.gd b/game/src/OptionMenu/SettingNodes/SettingHSlider.gd deleted file mode 100644 index 6fa30ed..0000000 --- a/game/src/OptionMenu/SettingNodes/SettingHSlider.gd +++ /dev/null @@ -1,41 +0,0 @@ -extends HSlider -class_name SettingHSlider - -@export -var section_name : String = "setting" - -@export -var setting_name : String = "setting_hslider" - -@export -var default_value : float = 0 - -func _ready(): - Events.Options.load_settings.connect(load_setting) - Events.Options.save_settings.connect(save_setting) - Events.Options.reset_settings.connect(reset_setting) - -func load_setting(file : ConfigFile): - if file == null: return - var load_value = file.get_value(section_name, setting_name, default_value) - match typeof(load_value): - TYPE_FLOAT, TYPE_INT: - if value == load_value: value_changed.emit(value) - value = load_value - return - TYPE_STRING, TYPE_STRING_NAME: - var load_string := load_value as String - if load_string.is_valid_float(): - load_value = load_string.to_float() - if value == load_value: value_changed.emit(value) - value = load_value - return - push_error("Setting value '%s' invalid for setting [%s] \"%s\"" % [load_value, section_name, setting_name]) - value = default_value - -func save_setting(file : ConfigFile): - if file == null: return - file.set_value(section_name, setting_name, value) - -func reset_setting(): - value = default_value diff --git a/game/src/OptionMenu/SettingNodes/SettingOptionButton.gd b/game/src/OptionMenu/SettingNodes/SettingOptionButton.gd deleted file mode 100644 index c5a805e..0000000 --- a/game/src/OptionMenu/SettingNodes/SettingOptionButton.gd +++ /dev/null @@ -1,77 +0,0 @@ -extends OptionButton -class_name SettingOptionButton - -signal option_selected(index : int, by_user : bool) - -@export -var section_name : String = "setting" - -@export -var setting_name : String = "setting_optionbutton" - -@export -var default_selected : int = -1: - get: return default_selected - set(v): - if v < 0 or item_count == 0: - default_selected = -1 - return - default_selected = v % item_count - -func _valid_index(index : int) -> bool: - return 0 <= index and index < item_count - -func _get_value_for_file(select_value : int): - if _valid_index(select_value): - return select_value - else: - return null - -func _set_value_from_file(load_value) -> void: - match typeof(load_value): - TYPE_INT: - if _valid_index(load_value): - selected = load_value - return - TYPE_STRING, TYPE_STRING_NAME: - var load_string := load_value as String - if load_string.is_valid_int(): - var load_int := load_string.to_int() - if _valid_index(load_int): - selected = load_int - return - for item_index in item_count: - if load_string == get_item_text(item_index): - selected = item_index - return - push_error("Setting value '%s' invalid for setting [%s] \"%s\"" % [load_value, section_name, setting_name]) - selected = default_selected - -func _setup_button() -> void: - pass - -func _ready(): - Events.Options.load_settings.connect(load_setting) - Events.Options.save_settings.connect(save_setting) - Events.Options.reset_settings.connect(reset_setting) - item_selected.connect(func(index : int): option_selected.emit(index, true)) - _setup_button() - if not _valid_index(default_selected) or selected == -1: - var msg := "Failed to generate %s %s options." % [setting_name, section_name] - push_error(msg) - OS.alert(msg, "%s Options Error" % section_name) - get_tree().quit() - -func load_setting(file : ConfigFile) -> void: - if file == null: return - _set_value_from_file(file.get_value(section_name, setting_name, _get_value_for_file(default_selected))) - option_selected.emit(selected, false) - -func save_setting(file : ConfigFile) -> void: - if file == null: return - file.set_value(section_name, setting_name, _get_value_for_file(selected)) - -func reset_setting(no_emit : bool = false) -> void: - selected = default_selected - if not no_emit: - option_selected.emit(selected, false) diff --git a/game/src/OptionMenu/SettingNodes/SettingRevertButton.gd b/game/src/OptionMenu/SettingNodes/SettingRevertButton.gd deleted file mode 100644 index 945d35b..0000000 --- a/game/src/OptionMenu/SettingNodes/SettingRevertButton.gd +++ /dev/null @@ -1,27 +0,0 @@ -extends SettingOptionButton -class_name SettingRevertButton - -@export_group("Nodes") -@export var revert_dialog : ResolutionRevertDialog - -var previous_index : int = -1 - -func _ready(): - super() - if revert_dialog != null: - revert_dialog.visibility_changed.connect(_on_revert_dialog_visibility_changed) - revert_dialog.dialog_accepted.connect(_on_accepted) - revert_dialog.dialog_reverted.connect(_on_reverted) - -func _on_revert_dialog_visibility_changed() -> void: - disabled = revert_dialog.visible - if not revert_dialog.visible: - previous_index = -1 - -func _on_reverted(button : SettingRevertButton) -> void: - if button != self: return - selected = previous_index - option_selected.emit(selected, false) - -func _on_accepted(button : SettingRevertButton) -> void: - if button != self: return diff --git a/game/src/OptionMenu/SoundTab.gd b/game/src/OptionMenu/SoundTab.gd deleted file mode 100644 index c707605..0000000 --- a/game/src/OptionMenu/SoundTab.gd +++ /dev/null @@ -1,4 +0,0 @@ -extends HBoxContainer - -func _on_ear_exploder_toggled(button_pressed): - print("KABOOM!!!" if button_pressed else "DEFUSED!!!") diff --git a/game/src/OptionMenu/SoundTab.tscn b/game/src/OptionMenu/SoundTab.tscn deleted file mode 100644 index 10d7f10..0000000 --- a/game/src/OptionMenu/SoundTab.tscn +++ /dev/null @@ -1,34 +0,0 @@ -[gd_scene load_steps=3 format=3 uid="uid://cbtgwpx2wxi33"] - -[ext_resource type="Script" path="res://src/OptionMenu/SoundTab.gd" id="1_a7k0s"] -[ext_resource type="PackedScene" uid="uid://dy4si8comamnv" path="res://src/OptionMenu/VolumeGrid.tscn" id="1_okpft"] - -[node name="Sound" type="HBoxContainer"] -alignment = 1 -script = ExtResource("1_a7k0s") - -[node name="VBoxContainer" type="VBoxContainer" parent="."] -layout_mode = 2 - -[node name="Control" type="Control" parent="VBoxContainer"] -layout_mode = 2 -size_flags_vertical = 3 -size_flags_stretch_ratio = 0.1 - -[node name="VolumeGrid" parent="VBoxContainer" instance=ExtResource("1_okpft")] -layout_mode = 2 - -[node name="ButtonGrid" type="GridContainer" parent="VBoxContainer"] -layout_mode = 2 -size_flags_vertical = 2 -columns = 2 - -[node name="Spacer" type="Control" parent="VBoxContainer/ButtonGrid"] -layout_mode = 2 -size_flags_horizontal = 3 - -[node name="EarExploder" type="CheckButton" parent="VBoxContainer/ButtonGrid"] -layout_mode = 2 -text = "Explode Eardrums on Startup?" - -[connection signal="toggled" from="VBoxContainer/ButtonGrid/EarExploder" to="." method="_on_ear_exploder_toggled"] diff --git a/game/src/OptionMenu/VideoTab.gd b/game/src/OptionMenu/VideoTab.gd deleted file mode 100644 index 3d98678..0000000 --- a/game/src/OptionMenu/VideoTab.gd +++ /dev/null @@ -1,9 +0,0 @@ -extends HBoxContainer - -@export var initial_focus: Control - -func _notification(what : int) -> void: - match(what): - NOTIFICATION_VISIBILITY_CHANGED: - if visible and is_inside_tree(): - initial_focus.grab_focus() diff --git a/game/src/OptionMenu/VideoTab.tscn b/game/src/OptionMenu/VideoTab.tscn deleted file mode 100644 index 244f481..0000000 --- a/game/src/OptionMenu/VideoTab.tscn +++ /dev/null @@ -1,181 +0,0 @@ -[gd_scene load_steps=9 format=3 uid="uid://bq3awxxjn1tuw"] - -[ext_resource type="Script" path="res://src/OptionMenu/ResolutionSelector.gd" id="1_i8nro"] -[ext_resource type="Script" path="res://src/OptionMenu/VideoTab.gd" id="1_jvv62"] -[ext_resource type="Script" path="res://src/OptionMenu/ScreenModeSelector.gd" id="2_wa7vw"] -[ext_resource type="Script" path="res://src/OptionMenu/GuiScaleSelector.gd" id="3_pgc5d"] -[ext_resource type="Script" path="res://src/OptionMenu/MonitorDisplaySelector.gd" id="3_y6lyb"] -[ext_resource type="Script" path="res://src/OptionMenu/RefreshRateSelector.gd" id="4_381mg"] -[ext_resource type="Script" path="res://src/OptionMenu/QualityPresetSelector.gd" id="5_srg4v"] -[ext_resource type="Script" path="res://src/OptionMenu/ResolutionRevertDialog.gd" id="8_802cr"] - -[node name="Video" type="HBoxContainer" node_paths=PackedStringArray("initial_focus")] -editor_description = "UI-46" -alignment = 1 -script = ExtResource("1_jvv62") -initial_focus = NodePath("VideoSettingList/VideoSettingGrid/ResolutionSelector") - -[node name="VideoSettingList" type="VBoxContainer" parent="."] -layout_mode = 2 - -[node name="Control" type="Control" parent="VideoSettingList"] -layout_mode = 2 -size_flags_vertical = 3 -size_flags_stretch_ratio = 0.1 - -[node name="VideoSettingGrid" type="GridContainer" parent="VideoSettingList"] -layout_mode = 2 -size_flags_vertical = 3 -columns = 2 - -[node name="ResolutionLabel" type="Label" parent="VideoSettingList/VideoSettingGrid"] -layout_mode = 2 -text = "OPTIONS_VIDEO_RESOLUTION" - -[node name="ResolutionSelector" type="OptionButton" parent="VideoSettingList/VideoSettingGrid" node_paths=PackedStringArray("revert_dialog")] -editor_description = "UI-19" -layout_mode = 2 -focus_neighbor_bottom = NodePath("../ScreenModeSelector") -item_count = 1 -selected = 0 -popup/item_0/text = "MISSING" -popup/item_0/id = 0 -script = ExtResource("1_i8nro") -revert_dialog = NodePath("../../../ResolutionRevertDialog") -section_name = "video" -setting_name = "resolution" - -[node name="GuiScaleLabel" type="Label" parent="VideoSettingList/VideoSettingGrid"] -layout_mode = 2 -text = "OPTIONS_VIDEO_GUI_SCALE" - -[node name="GuiScaleSelector" type="OptionButton" parent="VideoSettingList/VideoSettingGrid"] -editor_description = "UI-23" -layout_mode = 2 -focus_neighbor_bottom = NodePath("../ScreenModeSelector") -item_count = 1 -selected = 0 -popup/item_0/text = "MISSING" -popup/item_0/id = 0 -script = ExtResource("3_pgc5d") -section_name = "video" -setting_name = "gui_scale" - -[node name="ScreenModeLabel" type="Label" parent="VideoSettingList/VideoSettingGrid"] -editor_description = "UI-44" -layout_mode = 2 -text = "OPTIONS_VIDEO_SCREEN_MODE" - -[node name="ScreenModeSelector" type="OptionButton" parent="VideoSettingList/VideoSettingGrid" node_paths=PackedStringArray("revert_dialog")] -layout_mode = 2 -focus_neighbor_top = NodePath("../ResolutionSelector") -focus_neighbor_bottom = NodePath("../MonitorDisplaySelector") -item_count = 3 -selected = 0 -popup/item_0/text = "OPTIONS_VIDEO_FULLSCREEN" -popup/item_0/id = 0 -popup/item_1/text = "OPTIONS_VIDEO_BORDERLESS" -popup/item_1/id = 1 -popup/item_2/text = "OPTIONS_VIDEO_WINDOWED" -popup/item_2/id = 2 -script = ExtResource("2_wa7vw") -revert_dialog = NodePath("../../../ResolutionRevertDialog") -section_name = "video" -setting_name = "mode_selected" - -[node name="MonitorSelectionLabel" type="Label" parent="VideoSettingList/VideoSettingGrid"] -layout_mode = 2 -text = "OPTIONS_VIDEO_MONITOR_SELECTION" - -[node name="MonitorDisplaySelector" type="OptionButton" parent="VideoSettingList/VideoSettingGrid"] -layout_mode = 2 -focus_neighbor_top = NodePath("../ScreenModeSelector") -focus_neighbor_bottom = NodePath("../RefreshRateSelector") -item_count = 1 -selected = 0 -popup/item_0/text = "MISSING" -popup/item_0/id = 0 -script = ExtResource("3_y6lyb") -section_name = "video" -setting_name = "current_screen" - -[node name="RefreshRateLabel" type="Label" parent="VideoSettingList/VideoSettingGrid"] -layout_mode = 2 -text = "OPTIONS_VIDEO_REFRESH_RATE" - -[node name="RefreshRateSelector" type="OptionButton" parent="VideoSettingList/VideoSettingGrid"] -editor_description = "UI-18, UIFUN-20" -layout_mode = 2 -tooltip_text = "OPTIONS_VIDEO_REFRESH_RATE_TOOLTIP" -focus_neighbor_top = NodePath("../MonitorDisplaySelector") -focus_neighbor_bottom = NodePath("../QualityPresetSelector") -item_count = 8 -selected = 0 -popup/item_0/text = "VSYNC" -popup/item_0/id = 0 -popup/item_1/text = "30hz" -popup/item_1/id = 1 -popup/item_2/text = "60hz" -popup/item_2/id = 2 -popup/item_3/text = "90hz" -popup/item_3/id = 3 -popup/item_4/text = "120hz" -popup/item_4/id = 4 -popup/item_5/text = "144hz" -popup/item_5/id = 5 -popup/item_6/text = "365hz" -popup/item_6/id = 6 -popup/item_7/text = "Unlimited" -popup/item_7/id = 7 -script = ExtResource("4_381mg") -section_name = "video" -setting_name = "refresh_rate" -default_selected = 0 - -[node name="QualityPresetLabel" type="Label" parent="VideoSettingList/VideoSettingGrid"] -layout_mode = 2 -text = "OPTIONS_VIDEO_QUALITY" - -[node name="QualityPresetSelector" type="OptionButton" parent="VideoSettingList/VideoSettingGrid"] -editor_description = "UI-21, UIFUN-22" -layout_mode = 2 -focus_neighbor_top = NodePath("../RefreshRateSelector") -item_count = 5 -selected = 1 -popup/item_0/text = "Low" -popup/item_0/id = 0 -popup/item_1/text = "Medium" -popup/item_1/id = 1 -popup/item_2/text = "High" -popup/item_2/id = 2 -popup/item_3/text = "Ultra" -popup/item_3/id = 3 -popup/item_4/text = "Custom" -popup/item_4/id = 4 -script = ExtResource("5_srg4v") -section_name = "video" -setting_name = "quality_preset" -default_selected = 1 - -[node name="ResolutionRevertDialog" type="ConfirmationDialog" parent="." node_paths=PackedStringArray("timer")] -editor_description = "UI-873" -disable_3d = true -title = "OPTIONS_VIDEO_RESOLUTION_DIALOG_TITLE" -size = Vector2i(730, 100) -ok_button_text = "DIALOG_OK" -cancel_button_text = "DIALOG_CANCEL" -script = ExtResource("8_802cr") -timer = NodePath("ResolutionRevertTimer") - -[node name="ResolutionRevertTimer" type="Timer" parent="ResolutionRevertDialog"] -wait_time = 5.0 -one_shot = true - -[connection signal="option_selected" from="VideoSettingList/VideoSettingGrid/ResolutionSelector" to="VideoSettingList/VideoSettingGrid/ResolutionSelector" method="_on_option_selected"] -[connection signal="option_selected" from="VideoSettingList/VideoSettingGrid/GuiScaleSelector" to="VideoSettingList/VideoSettingGrid/GuiScaleSelector" method="_on_option_selected"] -[connection signal="option_selected" from="VideoSettingList/VideoSettingGrid/ScreenModeSelector" to="VideoSettingList/VideoSettingGrid/ScreenModeSelector" method="_on_option_selected"] -[connection signal="option_selected" from="VideoSettingList/VideoSettingGrid/MonitorDisplaySelector" to="VideoSettingList/VideoSettingGrid/MonitorDisplaySelector" method="_on_option_selected"] -[connection signal="canceled" from="ResolutionRevertDialog" to="ResolutionRevertDialog" method="_on_canceled_or_close_requested"] -[connection signal="close_requested" from="ResolutionRevertDialog" to="ResolutionRevertDialog" method="_on_canceled_or_close_requested"] -[connection signal="confirmed" from="ResolutionRevertDialog" to="ResolutionRevertDialog" method="_on_confirmed"] -[connection signal="timeout" from="ResolutionRevertDialog/ResolutionRevertTimer" to="ResolutionRevertDialog" method="_on_resolution_revert_timer_timeout"] diff --git a/game/src/OptionMenu/VolumeGrid.gd b/game/src/OptionMenu/VolumeGrid.gd deleted file mode 100644 index 46613b4..0000000 --- a/game/src/OptionMenu/VolumeGrid.gd +++ /dev/null @@ -1,70 +0,0 @@ -extends GridContainer - -const RATIO_FOR_LINEAR : float = 100 - -var _slider_dictionary : Dictionary - -var initial_focus : Control - -func get_db_as_volume_value(db : float) -> float: - # db_to_linear produces a float between 0 and 1 from a db value - return db_to_linear(db) * RATIO_FOR_LINEAR - -func get_volume_value_as_db(value : float) -> float: - # linear_to_db consumes a float between 0 and 1 to produce the db value - return linear_to_db(value / RATIO_FOR_LINEAR) - -func add_volume_row(bus_name : String, bus_index : int) -> HSlider: - var volume_label := Label.new() - if bus_name == "Master": - volume_label.text = "MASTER_BUS" - else: - volume_label.text = bus_name - add_child(volume_label) - - var volume_slider := SettingHSlider.new() - volume_slider.section_name = "audio" - volume_slider.setting_name = volume_label.text - volume_slider.custom_minimum_size = Vector2(290, 0) - volume_slider.size_flags_vertical = Control.SIZE_FILL - volume_slider.min_value = 0 - volume_slider.default_value = 100 - volume_slider.max_value = 120 # 120 so volume can be boosted somewhat - volume_slider.value_changed.connect(_on_slider_value_changed.bind(bus_index)) - add_child(volume_slider) - - _slider_dictionary[volume_label.text] = volume_slider - if not initial_focus: initial_focus = volume_slider - return volume_slider - -# REQUIREMENTS -# * UI-22 -func _ready(): - for bus_index in AudioServer.bus_count: - add_volume_row(AudioServer.get_bus_name(bus_index), bus_index) - -func _notification(what : int) -> void: - match(what): - NOTIFICATION_VISIBILITY_CHANGED: - if visible and is_inside_tree() and initial_focus: initial_focus.grab_focus() - -# REQUIREMENTS -# * UIFUN-30 -func _on_slider_value_changed(value : float, bus_index : int) -> void: - AudioServer.set_bus_volume_db(bus_index, get_volume_value_as_db(value)) - - -func _on_options_menu_load_settings(load_file : ConfigFile): - for volume_slider in _slider_dictionary.values(): - volume_slider.load_setting(load_file) - -# REQUIREMENTS -# * UIFUN-23 -func _on_options_menu_save_settings(save_file : ConfigFile): - for volume_slider in _slider_dictionary.values(): - volume_slider.save_setting(save_file) - - -func _on_options_menu_reset_settings(): - for volume_slider in _slider_dictionary.values(): - volume_slider.reset_setting() diff --git a/game/src/OptionMenu/VolumeGrid.tscn b/game/src/OptionMenu/VolumeGrid.tscn deleted file mode 100644 index 6d4de3c..0000000 --- a/game/src/OptionMenu/VolumeGrid.tscn +++ /dev/null @@ -1,8 +0,0 @@ -[gd_scene load_steps=2 format=3 uid="uid://dy4si8comamnv"] - -[ext_resource type="Script" path="res://src/OptionMenu/VolumeGrid.gd" id="1_wb64h"] - -[node name="VolumeGrid" type="GridContainer"] -size_flags_vertical = 0 -columns = 2 -script = ExtResource("1_wb64h") diff --git a/game/src/SaveLoadMenu/SaveLoadMenu.gd b/game/src/SaveLoadMenu/SaveLoadMenu.gd deleted file mode 100644 index bff0bb5..0000000 --- a/game/src/SaveLoadMenu/SaveLoadMenu.gd +++ /dev/null @@ -1,123 +0,0 @@ -extends Control - -@export var _save_scene : PackedScene - -@export_group("Nodes") -@export var _label : Label -@export var _scroll_list : BoxContainer -@export var _save_line_edit : LineEdit -@export var _save_load_button : Button -@export var _tag_selection_tab : TabBar -@export var _delete_dialog : ConfirmationDialog -@export var _overwrite_dialog : ConfirmationDialog - -var is_save_menu : bool = true -var _id_to_tag : Array[StringName] = [] - -func filter_for_tag(tag : StringName) -> void: - for child in _scroll_list.get_children(): - if tag == &"": - child.show() - else: - if tag == child.resource.session_tag: - child.show() - else: - child.hide() - -# Requirements -# * UIFUN-78 -func show_for_load() -> void: - _label.text = "SAVELOADMENU_LOAD_TITLE" - _save_load_button.text = "SAVELOADMENU_LOAD_BUTTON" - _save_line_edit.editable = false - is_save_menu = false - show() - -# Requirements -# * UIFUN-77 -func show_for_save() -> void: - _label.text = "SAVELOADMENU_SAVE_TITLE" - _save_load_button.text = "SAVELOADMENU_SAVE_BUTTON" - _save_line_edit.editable = true - is_save_menu = true - show() - -func _build_save_list() -> void: - _tag_selection_tab.add_tab("SAVELOADMENU_TABSELECTIONTABBAR_ALL") - for save_name in SaveManager._save_dictionary: - var save : SaveResource = SaveManager._save_dictionary[save_name] - var save_node := _create_save_node(save) - _scroll_list.add_child(save_node) - if not _id_to_tag.has(save.session_tag): - _id_to_tag.append(save.session_tag) - _tag_selection_tab.add_tab(save.session_tag) - -func _create_save_node(resource : SaveResource) -> Control: - var save_node = _save_scene.instantiate() - save_node.resource = resource - save_node.pressed.connect(_on_save_node_pressed.bind(save_node)) - save_node.request_to_delete.connect(_on_save_node_delete_requested.bind(save_node)) - return save_node - -func _queue_clear_scroll_list() -> void: - for child in _scroll_list.get_children(): - child.queue_free() - _tag_selection_tab.clear_tabs() - _id_to_tag.clear() - -# REQUIREMENTS: -# * UIFUN-84 -# * UIFUN-89 -func _on_close_button_pressed() -> void: - hide() - -func _on_delete_dialog_confirmed() -> void: - _requested_node_to_delete.resource.delete() - _requested_node_to_delete.queue_free() - -# REQUIREMENTS: -# * UIFUN-83 -func _on_overwrite_dialog_confirmed() -> void: - SaveManager.add_or_replace_save(SaveManager.make_new_save(_submitted_text)) - _on_close_button_pressed() - -var _submitted_text : String = "" -func _on_save_line_edit_text_submitted(new_text) -> void: - _submitted_text = new_text - if SaveManager.has_save(new_text): - _overwrite_dialog.dialog_text = tr("SAVELOADMENU_OVERWRITE_DIALOG_TEXT").format({ "file_name": _submitted_text }) - _overwrite_dialog.title = tr("SAVELOADMENU_OVERWRITE_DIALOG_TITLE").format({ "file_name": _submitted_text }) - _overwrite_dialog.popup_centered() - return - _on_overwrite_dialog_confirmed() - -func _on_save_load_button_pressed() -> void: - if is_save_menu: - _save_line_edit.text_submitted.emit(_save_line_edit.text) - -var _requested_node_to_delete : Control -func _on_save_node_delete_requested(node : Control) -> void: - _requested_node_to_delete = node - _delete_dialog.dialog_text = tr("SAVELOADMENU_DELETE_DIALOG_TEXT").format({ "file_name": _requested_node_to_delete.resource.save_name }) - _delete_dialog.title = tr("SAVELOADMENU_DELETE_DIALOG_TITLE").format({ "file_name": _requested_node_to_delete.resource.save_name }) - _delete_dialog.popup_centered() - -# REQUIREMENTS: -# * UIFUN-81 -# * UIFUN-86 -func _on_save_node_pressed(node : Control) -> void: - if is_save_menu: - _save_line_edit.text = node.resource.save_name - -func _on_tag_selection_tab_bar_tab_changed(tab) -> void: - if tab == 0: - filter_for_tag(&"") - else: - filter_for_tag(_id_to_tag[tab - 1]) - -func _on_visibility_changed() -> void: - if visible: - _build_save_list() - else: - _queue_clear_scroll_list() - SaveManager.flush_save() diff --git a/game/src/SaveLoadMenu/SaveLoadMenu.tscn b/game/src/SaveLoadMenu/SaveLoadMenu.tscn deleted file mode 100644 index e9f068e..0000000 --- a/game/src/SaveLoadMenu/SaveLoadMenu.tscn +++ /dev/null @@ -1,109 +0,0 @@ -[gd_scene load_steps=5 format=3 uid="uid://d3g6wbvwflmyk"] - -[ext_resource type="Script" path="res://src/SaveLoadMenu/SaveLoadMenu.gd" id="1_3jkds"] -[ext_resource type="PackedScene" uid="uid://d2s7roinx2or7" path="res://src/SaveLoadMenu/SavePanelButton.tscn" id="2_fc6r3"] - -[sub_resource type="InputEventAction" id="InputEventAction_8vo2t"] -action = &"ui_accept" -pressed = true - -[sub_resource type="Shortcut" id="Shortcut_o1f2l"] -events = [SubResource("InputEventAction_8vo2t")] - -[node name="SaveLoadMenu" type="MarginContainer" node_paths=PackedStringArray("_label", "_scroll_list", "_save_line_edit", "_save_load_button", "_tag_selection_tab", "_delete_dialog", "_overwrite_dialog")] -editor_description = "UI-82, UI-89" -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 -theme_override_constants/margin_left = 250 -theme_override_constants/margin_top = 100 -theme_override_constants/margin_right = 250 -theme_override_constants/margin_bottom = 100 -script = ExtResource("1_3jkds") -_save_scene = ExtResource("2_fc6r3") -_label = NodePath("SaveLoadPanel/SaveLoadList/TitleBarList/SaveLoadLabel") -_scroll_list = NodePath("SaveLoadPanel/SaveLoadList/SaveLoadScroll/SaveLoadScrollList") -_save_line_edit = NodePath("SaveLoadPanel/SaveLoadList/SaveLineEdit") -_save_load_button = NodePath("SaveLoadPanel/SaveLoadList/SaveLoadButton") -_tag_selection_tab = NodePath("SaveLoadPanel/SaveLoadList/TagSelectionList/TagSelectionTabBar") -_delete_dialog = NodePath("DeleteDialog") -_overwrite_dialog = NodePath("OverwriteDialog") - -[node name="SaveLoadPanel" type="PanelContainer" parent="."] -layout_mode = 2 - -[node name="SaveLoadList" type="VBoxContainer" parent="SaveLoadPanel"] -layout_mode = 2 - -[node name="TitleBarList" type="HBoxContainer" parent="SaveLoadPanel/SaveLoadList"] -layout_mode = 2 -alignment = 2 - -[node name="SaveLoadLabel" type="Label" parent="SaveLoadPanel/SaveLoadList/TitleBarList"] -layout_mode = 2 -size_flags_horizontal = 6 -text = "SAVELOADMENU_SAVE_TITLE" - -[node name="CloseButton" type="Button" parent="SaveLoadPanel/SaveLoadList/TitleBarList"] -editor_description = "UI-87, UI-94" -layout_mode = 2 -text = "X" - -[node name="TagSelectionList" type="HBoxContainer" parent="SaveLoadPanel/SaveLoadList"] -layout_mode = 2 - -[node name="TagSelectionLabel" type="Label" parent="SaveLoadPanel/SaveLoadList/TagSelectionList"] -layout_mode = 2 -text = "SAVELOADMENU_SESSION" - -[node name="TagSelectionTabBar" type="TabBar" parent="SaveLoadPanel/SaveLoadList/TagSelectionList"] -layout_mode = 2 -size_flags_horizontal = 3 -tab_count = 1 -tab_0/title = "SAVELOADMENU_TABSELECTIONTABBAR_ALL" - -[node name="SaveLoadScroll" type="ScrollContainer" parent="SaveLoadPanel/SaveLoadList"] -editor_description = "UI-83, UI-90" -layout_mode = 2 -size_flags_vertical = 3 - -[node name="SaveLoadScrollList" type="VBoxContainer" parent="SaveLoadPanel/SaveLoadList/SaveLoadScroll"] -layout_mode = 2 -size_flags_horizontal = 3 -size_flags_vertical = 3 - -[node name="SaveLineEdit" type="LineEdit" parent="SaveLoadPanel/SaveLoadList"] -editor_description = "UI-85, UI-92" -layout_mode = 2 - -[node name="SaveLoadButton" type="Button" parent="SaveLoadPanel/SaveLoadList"] -editor_description = "UIFUN-82, UIFUN-87" -layout_mode = 2 -size_flags_horizontal = 4 -shortcut = SubResource("Shortcut_o1f2l") -shortcut_feedback = false -text = "SAVELOADMENU_SAVE_BUTTON" - -[node name="DeleteDialog" type="ConfirmationDialog" parent="."] -disable_3d = true -title = "SAVELOADMENU_DELETE_DIALOG_TITLE" -ok_button_text = "DIALOG_OK" -dialog_text = "SAVELOADMENU_DELETE_DIALOG_TEXT" -cancel_button_text = "DIALOG_CANCEL" - -[node name="OverwriteDialog" type="ConfirmationDialog" parent="."] -disable_3d = true -title = "SAVELOADMENU_OVERWRITE_DIALOG_TITLE" -ok_button_text = "DIALOG_OK" -dialog_text = "SAVELOADMENU_OVERWRITE_DIALOG_TEXT" -cancel_button_text = "DIALOG_CANCEL" - -[connection signal="visibility_changed" from="." to="." method="_on_visibility_changed"] -[connection signal="pressed" from="SaveLoadPanel/SaveLoadList/TitleBarList/CloseButton" to="." method="_on_close_button_pressed"] -[connection signal="tab_changed" from="SaveLoadPanel/SaveLoadList/TagSelectionList/TagSelectionTabBar" to="." method="_on_tag_selection_tab_bar_tab_changed"] -[connection signal="text_submitted" from="SaveLoadPanel/SaveLoadList/SaveLineEdit" to="." method="_on_save_line_edit_text_submitted"] -[connection signal="pressed" from="SaveLoadPanel/SaveLoadList/SaveLoadButton" to="." method="_on_save_load_button_pressed"] -[connection signal="confirmed" from="DeleteDialog" to="." method="_on_delete_dialog_confirmed"] -[connection signal="confirmed" from="OverwriteDialog" to="." method="_on_overwrite_dialog_confirmed"] diff --git a/game/src/SaveLoadMenu/SavePanelButton.gd b/game/src/SaveLoadMenu/SavePanelButton.gd deleted file mode 100644 index 5fe4917..0000000 --- a/game/src/SaveLoadMenu/SavePanelButton.gd +++ /dev/null @@ -1,41 +0,0 @@ -@tool -extends LobbyPanelButton - -signal request_to_delete - -@export_group("Nodes") -@export var country_flag : TextureRect -@export var date_label : Label -@export var delete_button : BaseButton - -var resource : SaveResource: - get: - return resource - set(value): - if resource != null: - resource.changed.disconnect(_resource_changed) - resource = value - if resource != null: - resource.changed.connect(_resource_changed) - _resource_changed() - -func get_text() -> StringName: - return resource.save_name - -func set_text(value : StringName) -> void: - if resource != null: - resource.save_name = value - -func _ready(): - _resource_changed() - -func _is_start_date() -> bool: - return false - -func _resource_changed() -> void: - if resource == null: return - name_label.text = resource.save_name - date_label.text = Time.get_datetime_string_from_unix_time(resource.get_save_file_time(), true) - -func _on_delete_button_pressed() -> void: - request_to_delete.emit() diff --git a/game/src/SaveLoadMenu/SavePanelButton.tscn b/game/src/SaveLoadMenu/SavePanelButton.tscn deleted file mode 100644 index d2d0a41..0000000 --- a/game/src/SaveLoadMenu/SavePanelButton.tscn +++ /dev/null @@ -1,58 +0,0 @@ -[gd_scene load_steps=2 format=3 uid="uid://d2s7roinx2or7"] - -[ext_resource type="Script" path="res://src/SaveLoadMenu/SavePanelButton.gd" id="1_rtuo6"] - -[node name="SavePanelButton" type="Container" node_paths=PackedStringArray("country_flag", "date_label", "delete_button", "background_button", "name_label")] -editor_description = "SS-18, UI-40, UI-84, UI-86, UI-91, UI-93" -offset_right = 276.0 -offset_bottom = 48.0 -script = ExtResource("1_rtuo6") -country_flag = NodePath("SaveList/CountryFlag") -date_label = NodePath("SaveList/DateLabel") -delete_button = NodePath("SaveList/DeleteButton") -background_button = NodePath("BackgroundButton") -name_label = NodePath("SaveList/NameLabel") - -[node name="BackgroundButton" type="Button" parent="."] -layout_mode = 2 -theme_type_variation = &"ButtonContainer" - -[node name="SaveList" type="HBoxContainer" parent="."] -layout_mode = 2 -mouse_filter = 2 - -[node name="CountryFlag" type="TextureRect" parent="SaveList"] -layout_mode = 2 -size_flags_horizontal = 0 -size_flags_vertical = 4 -mouse_filter = 2 - -[node name="NameLabel" type="Label" parent="SaveList"] -layout_mode = 2 -size_flags_horizontal = 0 -size_flags_vertical = 1 -text = "PLACEHOLDER" -vertical_alignment = 1 - -[node name="DateLabel" type="Label" parent="SaveList"] -layout_mode = 2 -size_flags_horizontal = 0 -size_flags_vertical = 1 -text = "00.00.0000" -vertical_alignment = 1 - -[node name="Separator" type="Control" parent="SaveList"] -layout_mode = 2 -size_flags_horizontal = 3 -mouse_filter = 2 - -[node name="DeleteButton" type="Button" parent="SaveList"] -layout_mode = 2 -size_flags_horizontal = 8 -text = "x" - -[connection signal="button_down" from="BackgroundButton" to="." method="_on_background_button_button_down"] -[connection signal="button_up" from="BackgroundButton" to="." method="_on_background_button_button_up"] -[connection signal="pressed" from="BackgroundButton" to="." method="_on_background_button_pressed"] -[connection signal="toggled" from="BackgroundButton" to="." method="_on_background_button_toggled"] -[connection signal="pressed" from="SaveList/DeleteButton" to="." method="_on_delete_button_pressed"] diff --git a/game/src/SaveLoadMenu/SaveResource.gd b/game/src/SaveLoadMenu/SaveResource.gd deleted file mode 100644 index 5e7faa6..0000000 --- a/game/src/SaveLoadMenu/SaveResource.gd +++ /dev/null @@ -1,59 +0,0 @@ -extends Resource -class_name SaveResource - -signal file_flushed(path : String) -signal file_loaded -signal file_moved_to_trash -signal file_deleted -signal trash_moved -signal deleted - -var save_name : StringName: - get: return save_name - set(v): - save_name = v - file.set_value("Save", "name", save_name) - emit_changed() -var session_tag : StringName: - get: return session_tag - set(v): - session_tag = v - file.set_value("Save", "session_tag", v) - emit_changed() -var file_path : String: - get: return file_path - set(v): - file_path = v - emit_changed() -var file : ConfigFile = ConfigFile.new() - -func set_file_path(name : StringName, path : String): - file_path = path - save_name = name - -func flush_save() -> Error: - file_flushed.emit(file_path) - var result := file.save(file_path) - file.clear() - return result - -func load_save(path : String = file_path) -> Error: - file_loaded.emit() - var result := file.load(path) - session_tag = file.get_value("Save", "session_tag", session_tag) - if path != file_path: - set_file_path(file.get_value("Save", "name", save_name), path) - return result - -func get_save_file_time() -> int: - return FileAccess.get_modified_time(file_path) - -func move_to_trash() -> Error: - trash_moved.emit() - file_moved_to_trash.emit() - return OS.move_to_trash(file_path) - -func delete() -> Error: - deleted.emit() - file_deleted.emit() - return DirAccess.remove_absolute(file_path) diff --git a/game/src/SplashContainer.gd b/game/src/SplashContainer.gd deleted file mode 100644 index 524d314..0000000 --- a/game/src/SplashContainer.gd +++ /dev/null @@ -1,30 +0,0 @@ -extends Control - -signal splash_end - -@export var _splash_finish : TextureRect -@export var _splash_image : TextureRect -@export var _splash_video : VideoStreamPlayer - -func _process(_delta): - var stream_texture := _splash_video.get_video_texture() - if stream_texture != null and not stream_texture.get_image().is_invisible(): - _splash_image.hide() - _splash_finish.show() - set_process(false) - -func _input(event): - if (event is InputEventKey\ - or event is InputEventMouse\ - or event is InputEventScreenTouch\ - or event is InputEventJoypadButton) and event.is_pressed(): - _splash_finish.hide() - _on_splash_startup_finished() - accept_event() - -func _on_splash_startup_finished(): - set_process_input(false) - splash_end.emit() - var tween := create_tween() - tween.tween_property(self, "modulate:a", 0, 0.5) - tween.tween_callback(self.queue_free) diff --git a/game/src/Utility/GIT_INFO.gd b/game/src/Utility/GIT_INFO.gd deleted file mode 100644 index eddb7a1..0000000 --- a/game/src/Utility/GIT_INFO.gd +++ /dev/null @@ -1,9 +0,0 @@ -### IMPORTANT: IF LOCATION IS CHANGED, PLEASE UPDATE IN addon/openvic-plugin/ReleaseExportEditorPlugin -class_name _GIT_INFO_ -extends RefCounted - - -const commit_hash : StringName = &"0000000000000000000000000000000000000000" -const short_hash : StringName = &"0000000" -const tag : StringName = &"" -const release_name : StringName = &"" diff --git a/game/src/Utility/StyleBoxCombinedTexture.gd b/game/src/Utility/StyleBoxCombinedTexture.gd deleted file mode 100644 index db54da4..0000000 --- a/game/src/Utility/StyleBoxCombinedTexture.gd +++ /dev/null @@ -1,47 +0,0 @@ -@tool -extends StyleBox -class_name StyleBoxCombinedTexture - -@export -var texture_settings : Array[TextureSetting] = []: - get: return texture_settings.duplicate() - set(v): - texture_settings = v - for setting in texture_settings: - setting.changed.connect(emit_changed) - emit_changed() - -func _get_draw_rect(rect : Rect2) -> Rect2: - var combined_rect : Rect2 = Rect2() - for setting in texture_settings: - if combined_rect.position.x > setting.expand_margin_left: - combined_rect.position.x = setting.expand_margin_left - if combined_rect.position.y > setting.expand_margin_top: - combined_rect.position.y = setting.expand_margin_top - if combined_rect.end.x < setting.expand_margin_right: - combined_rect.end.x = setting.expand_margin_right - if combined_rect.end.y < setting.expand_margin_bottom: - combined_rect.end.y = setting.expand_margin_bottom - return rect.grow_individual(combined_rect.position.x, combined_rect.position.y, combined_rect.end.x, combined_rect.end.y) - -func _draw(to_canvas_item : RID, rect : Rect2) -> void: - for setting in texture_settings: - if setting == null or setting.texture == null: - continue - var inner_rect : Rect2 = rect - inner_rect.position.x -= setting.expand_margin_left - inner_rect.position.y -= setting.expand_margin_top - inner_rect.size.x += setting.expand_margin_left + setting.expand_margin_right - inner_rect.size.y += setting.expand_margin_top + setting.expand_margin_bottom - RenderingServer.canvas_item_add_nine_patch( - to_canvas_item, - inner_rect, - setting.region_rect, - setting.texture.get_rid(), - Vector2(setting.texture_margin_left, setting.texture_margin_top), - Vector2(setting.texture_margin_right, setting.texture_margin_bottom), - setting.axis_stretch_horizontal, - setting.axis_stretch_vertical, - setting.draw_center, - setting.modulate_color - ) diff --git a/game/src/Utility/StyleBoxWithSound.gd b/game/src/Utility/StyleBoxWithSound.gd deleted file mode 100644 index 8c29b34..0000000 --- a/game/src/Utility/StyleBoxWithSound.gd +++ /dev/null @@ -1,34 +0,0 @@ -## WARNING: This will not work with togglable UI elements, a special implementation is needed for them. -@tool -extends StyleBox -class_name StyleBoxWithSound - -@export -var style_box : StyleBox: - get: return style_box - set(v): - style_box = v - emit_changed() - -@export -var sound : AudioStream: - get: return sound - set(v): - sound = v - emit_changed() - -func _get_draw_rect(rect : Rect2) -> Rect2: - if style_box == null: return Rect2() - return style_box._get_draw_rect(rect) - -func _draw(to_canvas_item : RID, rect : Rect2) -> void: - # This is a hack - # Works fine for simple non-normal style cases - # Normal styles being drawn immediately tho will trigger sound on startup - # This would require further work to be applicable for release sounds - # Is there any other reason aside from release sounds (might be useful for toggles?) - # This should be fast enough to not cause draw issues - if sound != null: - SoundManager.play_effect_stream(sound) - if style_box != null: - style_box.draw(to_canvas_item, rect) diff --git a/game/src/Utility/TextureSetting.gd b/game/src/Utility/TextureSetting.gd deleted file mode 100644 index da9b185..0000000 --- a/game/src/Utility/TextureSetting.gd +++ /dev/null @@ -1,123 +0,0 @@ -extends Resource -class_name TextureSetting - -@export -var texture : Texture2D: - get: return texture - set(v): - texture = v - emit_changed() -@export -var draw_center : bool = true: - get: return draw_center - set(v): - draw_center = v - emit_changed() - -@export_group("Texture Margins", "texture_margin_") -@export -var texture_margin_left : float = 0: - get: return texture_margin_left - set(v): - texture_margin_left = v - emit_changed() -@export -var texture_margin_top : float = 0: - get: return texture_margin_top - set(v): - texture_margin_top = v - emit_changed() -@export -var texture_margin_right : float = 0: - get: return texture_margin_right - set(v): - texture_margin_right = v - emit_changed() -@export -var texture_margin_bottom : float = 0: - get: return texture_margin_bottom - set(v): - texture_margin_bottom = v - emit_changed() - -@export_group("Expand Margins", "expand_margin_") -@export -var expand_margin_left : float = 0: - get: return expand_margin_left - set(v): - expand_margin_left = v - emit_changed() -@export -var expand_margin_top : float = 0: - get: return expand_margin_top - set(v): - expand_margin_top = v - emit_changed() -@export -var expand_margin_right : float = 0: - get: return expand_margin_right - set(v): - expand_margin_right = v - emit_changed() -@export -var expand_margin_bottom : float = 0: - get: return expand_margin_bottom - set(v): - expand_margin_bottom = v - emit_changed() - -@export_group("Axis Stretch", "axis_stretch_") -@export -var axis_stretch_horizontal : RenderingServer.NinePatchAxisMode = RenderingServer.NINE_PATCH_STRETCH: - get: return axis_stretch_horizontal - set(v): - axis_stretch_horizontal = v - emit_changed() -@export -var axis_stretch_vertical : RenderingServer.NinePatchAxisMode = RenderingServer.NINE_PATCH_STRETCH: - get: return axis_stretch_vertical - set(v): - axis_stretch_vertical = v - emit_changed() - -@export_group("Sub-Region", "region_") -@export -var region_rect : Rect2 = Rect2(0, 0, 0, 0): - get: return region_rect - set(v): - region_rect = v - emit_changed() - -@export_group("Modulate", "modulate_") -@export -var modulate_color : Color = Color(1, 1, 1, 1): - get: return modulate_color - set(v): - modulate_color = v - emit_changed() - -@export_group("Content Margins", "content_margin_") -@export -var content_margin_left : float = -1: - get: return content_margin_left - set(v): - content_margin_left = v - emit_changed() -@export -var content_margin_top : float = -1: - get: return content_margin_top - set(v): - content_margin_top = v - emit_changed() -@export -var content_margin_right : float = -1: - get: return content_margin_right - set(v): - content_margin_right = v - emit_changed() -@export -var content_margin_bottom : float = -1: - get: return content_margin_bottom - set(v): - content_margin_bottom = v - emit_changed() -- cgit v1.2.3-56-ga3b1 From b98166b28c47cccff731d30959b8250fb27ff408 Mon Sep 17 00:00:00 2001 From: Spartan322 Date: Sat, 3 Jun 2023 15:03:52 -0400 Subject: Update file contents according to reorganization --- .../addons/openvic-plugin/ReleaseExportEditorPlugin.gd | 2 +- game/project.godot | 16 ++++++++-------- game/src/Game/Autoload/Argument/ArgumentParser.tscn | 4 ++-- game/src/Game/GameMenu.tscn | 12 ++++++------ game/src/Game/GameSession/GameSession.tscn | 18 +++++++++--------- game/src/Game/GameSession/GameSessionMenu.tscn | 4 ++-- game/src/Game/GameSession/GameSpeedPanel.tscn | 2 +- .../GameSession/MapControlPanel/MapControlPanel.tscn | 6 +++--- .../Game/GameSession/MapControlPanel/Minimap.gdshader | 2 +- game/src/Game/GameSession/MapView.tscn | 4 ++-- .../ProvinceOverviewPanel/ProvinceOverviewPanel.tscn | 2 +- game/src/Game/GameSession/TerrainMap.gdshader | 2 +- game/src/Game/GameStart.tscn | 6 +++--- game/src/Game/LocaleButton.tscn | 2 +- game/src/Game/Menu/CreditsMenu/CreditsMenu.tscn | 4 ++-- game/src/Game/Menu/CreditsMenu/GodotEngineButton.tscn | 4 ++-- .../CreditsMenu/logo_vertical_color_dark.svg.import | 6 +++--- game/src/Game/Menu/LobbyMenu/LobbyMenu.gd | 2 +- game/src/Game/Menu/LobbyMenu/LobbyMenu.tscn | 6 +++--- game/src/Game/Menu/LobbyMenu/LobbyPanelButton.tscn | 2 +- game/src/Game/Menu/MainMenu/MainMenu.tscn | 6 +++--- game/src/Game/Menu/MainMenu/ReleaseInfoBox.tscn | 2 +- game/src/Game/Menu/OptionMenu/GeneralTab.tscn | 8 ++++---- game/src/Game/Menu/OptionMenu/OptionsMenu.tscn | 10 +++++----- game/src/Game/Menu/OptionMenu/SoundTab.tscn | 4 ++-- game/src/Game/Menu/OptionMenu/VideoTab.tscn | 16 ++++++++-------- game/src/Game/Menu/OptionMenu/VolumeGrid.tscn | 2 +- game/src/Game/Menu/SaveLoadMenu/SaveLoadMenu.tscn | 4 ++-- game/src/Game/Menu/SaveLoadMenu/SavePanelButton.tscn | 2 +- game/src/Game/MusicConductor/MusicConductor.tscn | 2 +- game/src/Game/MusicConductor/MusicPlayer.tscn | 2 +- game/theme/game_session_menu.tres | 2 +- game/theme/main_menu.tres | 6 +++--- game/theme/options_menu.tres | 4 ++-- 34 files changed, 88 insertions(+), 88 deletions(-) (limited to 'game') diff --git a/game/addons/openvic-plugin/ReleaseExportEditorPlugin.gd b/game/addons/openvic-plugin/ReleaseExportEditorPlugin.gd index ac6c5bc..5deb761 100644 --- a/game/addons/openvic-plugin/ReleaseExportEditorPlugin.gd +++ b/game/addons/openvic-plugin/ReleaseExportEditorPlugin.gd @@ -9,7 +9,7 @@ func _get_name(): return "OpenVic-ReleaseExportEditorPlugin" func _export_file(path: String, type: String, features: PackedStringArray) -> void: - if path != "res://src/Utility/GIT_INFO.gd": return + if path != "res://src/GIT_INFO.gd": return var GitInfoScript : String = "" _get_commit_long() _get_commit_short() diff --git a/game/project.godot b/game/project.godot index 3bb2438..253a54b 100644 --- a/game/project.godot +++ b/game/project.godot @@ -12,7 +12,7 @@ config_version=5 config/name="OpenVic" config/description="A faithful recreation of Victoria 2: Heart of Darkness with a focus on enhancing performance, multiplayer stability, and modability for modern machines." -run/main_scene="res://src/GameStart.tscn" +run/main_scene="res://src/Game/GameStart.tscn" config/features=PackedStringArray("4.0", "Forward Plus") boot_splash/bg_color=Color(0.380392, 0.145098, 0.14902, 1) boot_splash/image="res://splash_assets/splash_image.png" @@ -21,14 +21,14 @@ config/project_settings_override.template="user://settings.cfg" [autoload] -ArgumentParser="*res://src/Autoload/Arguments/ArgumentParser.tscn" -Events="*res://src/Autoload/Events.gd" -Resolution="*res://src/Autoload/Resolution.gd" -SoundManager="*res://src/Autoload/SoundManager.gd" -MusicConductor="*res://src/MusicConductor/MusicConductor.tscn" +ArgumentParser="*res://src/Game/Autoload/Argument/ArgumentParser.tscn" +Events="*res://src/Game/Autoload/Events.gd" +Resolution="*res://src/Game/Autoload/Resolution.gd" +SoundManager="*res://src/Game/Autoload/SoundManager.gd" +MusicConductor="*res://src/Game/MusicConductor/MusicConductor.tscn" Keychain="*res://addons/keychain/Keychain.gd" -GuiScale="*res://src/Autoload/GuiScale.gd" -SaveManager="*res://src/Autoload/SaveManager.gd" +GuiScale="*res://src/Game/Autoload/GuiScale.gd" +SaveManager="*res://src/Game/Autoload/SaveManager.gd" [display] diff --git a/game/src/Game/Autoload/Argument/ArgumentParser.tscn b/game/src/Game/Autoload/Argument/ArgumentParser.tscn index 8fda8f1..09e5e6c 100644 --- a/game/src/Game/Autoload/Argument/ArgumentParser.tscn +++ b/game/src/Game/Autoload/Argument/ArgumentParser.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=6 format=3 uid="uid://dayjmgc34tqo6"] -[ext_resource type="Script" path="res://src/Autoload/Arguments/ArgumentParser.gd" id="1_pc7xr"] -[ext_resource type="Script" path="res://src/Autoload/Arguments/ArgumentOption.gd" id="2_4hguj"] +[ext_resource type="Script" path="res://src/Game/Autoload/Argument/ArgumentParser.gd" id="1_pc7xr"] +[ext_resource type="Script" path="res://src/Game/Autoload/Argument/ArgumentOption.gd" id="2_4hguj"] [sub_resource type="Resource" id="Resource_tq3y4"] script = ExtResource("2_4hguj") diff --git a/game/src/Game/GameMenu.tscn b/game/src/Game/GameMenu.tscn index 224ae2e..73287a5 100644 --- a/game/src/Game/GameMenu.tscn +++ b/game/src/Game/GameMenu.tscn @@ -1,11 +1,11 @@ [gd_scene load_steps=7 format=3 uid="uid://o4u142w4qkln"] -[ext_resource type="Script" path="res://src/GameMenu.gd" id="1_cafwe"] -[ext_resource type="PackedScene" uid="uid://bp5n3mlu45ygw" path="res://src/MainMenu/MainMenu.tscn" id="2_2jbkh"] -[ext_resource type="PackedScene" uid="uid://cnbfxjy1m6wja" path="res://src/OptionMenu/OptionsMenu.tscn" id="3_111lv"] -[ext_resource type="PackedScene" uid="uid://c8knthxkwj1uj" path="res://src/CreditsMenu/CreditsMenu.tscn" id="4_n0hoo"] -[ext_resource type="PackedScene" uid="uid://do60kx0d3nrh4" path="res://src/LobbyMenu/LobbyMenu.tscn" id="4_nofk1"] -[ext_resource type="PackedScene" uid="uid://cvl76duuym1wq" path="res://src/MusicConductor/MusicPlayer.tscn" id="6_lts1m"] +[ext_resource type="Script" path="res://src/Game/GameMenu.gd" id="1_cafwe"] +[ext_resource type="PackedScene" uid="uid://bp5n3mlu45ygw" path="res://src/Game/Menu/MainMenu/MainMenu.tscn" id="2_2jbkh"] +[ext_resource type="PackedScene" uid="uid://cnbfxjy1m6wja" path="res://src/Game/Menu/OptionMenu/OptionsMenu.tscn" id="3_111lv"] +[ext_resource type="PackedScene" uid="uid://c8knthxkwj1uj" path="res://src/Game/Menu/CreditsMenu/CreditsMenu.tscn" id="4_n0hoo"] +[ext_resource type="PackedScene" uid="uid://do60kx0d3nrh4" path="res://src/Game/Menu/LobbyMenu/LobbyMenu.tscn" id="4_nofk1"] +[ext_resource type="PackedScene" uid="uid://cvl76duuym1wq" path="res://src/Game/MusicConductor/MusicPlayer.tscn" id="6_lts1m"] [node name="GameMenu" type="Control" node_paths=PackedStringArray("_main_menu", "_options_menu", "_lobby_menu", "_credits_menu")] layout_mode = 3 diff --git a/game/src/Game/GameSession/GameSession.tscn b/game/src/Game/GameSession/GameSession.tscn index 188ccde..c9f4095 100644 --- a/game/src/Game/GameSession/GameSession.tscn +++ b/game/src/Game/GameSession/GameSession.tscn @@ -1,14 +1,14 @@ [gd_scene load_steps=10 format=3 uid="uid://bgnupcshe1m7r"] -[ext_resource type="Script" path="res://src/GameSession/GameSession.gd" id="1_eklvp"] -[ext_resource type="PackedScene" uid="uid://cvl76duuym1wq" path="res://src/MusicConductor/MusicPlayer.tscn" id="2_kt6aa"] -[ext_resource type="PackedScene" uid="uid://g524p8lr574w" path="res://src/GameSession/MapControlPanel/MapControlPanel.tscn" id="3_afh6d"] -[ext_resource type="PackedScene" uid="uid://dvdynl6eir40o" path="res://src/GameSession/GameSessionMenu.tscn" id="3_bvmqh"] -[ext_resource type="PackedScene" uid="uid://dkehmdnuxih2r" path="res://src/GameSession/MapView.tscn" id="4_xkg5j"] -[ext_resource type="PackedScene" uid="uid://byq323jbel48u" path="res://src/GameSession/ProvinceOverviewPanel/ProvinceOverviewPanel.tscn" id="5_osjnn"] -[ext_resource type="PackedScene" uid="uid://cnbfxjy1m6wja" path="res://src/OptionMenu/OptionsMenu.tscn" id="6_p5mnx"] -[ext_resource type="PackedScene" uid="uid://dd8k3p7r3huwc" path="res://src/GameSession/GameSpeedPanel.tscn" id="7_myy4q"] -[ext_resource type="PackedScene" uid="uid://d3g6wbvwflmyk" path="res://src/SaveLoadMenu/SaveLoadMenu.tscn" id="8_4g7ko"] +[ext_resource type="Script" path="res://src/Game/GameSession/GameSession.gd" id="1_eklvp"] +[ext_resource type="PackedScene" uid="uid://cvl76duuym1wq" path="res://src/Game/MusicConductor/MusicPlayer.tscn" id="2_kt6aa"] +[ext_resource type="PackedScene" uid="uid://g524p8lr574w" path="res://src/Game/GameSession/MapControlPanel/MapControlPanel.tscn" id="3_afh6d"] +[ext_resource type="PackedScene" uid="uid://dvdynl6eir40o" path="res://src/Game/GameSession/GameSessionMenu.tscn" id="3_bvmqh"] +[ext_resource type="PackedScene" uid="uid://dkehmdnuxih2r" path="res://src/Game/GameSession/MapView.tscn" id="4_xkg5j"] +[ext_resource type="PackedScene" uid="uid://byq323jbel48u" path="res://src/Game/GameSession/ProvinceOverviewPanel/ProvinceOverviewPanel.tscn" id="5_osjnn"] +[ext_resource type="PackedScene" uid="uid://cnbfxjy1m6wja" path="res://src/Game/Menu/OptionMenu/OptionsMenu.tscn" id="6_p5mnx"] +[ext_resource type="PackedScene" uid="uid://dd8k3p7r3huwc" path="res://src/Game/GameSession/GameSpeedPanel.tscn" id="7_myy4q"] +[ext_resource type="PackedScene" uid="uid://d3g6wbvwflmyk" path="res://src/Game/Menu/SaveLoadMenu/SaveLoadMenu.tscn" id="8_4g7ko"] [node name="GameSession" type="Control" node_paths=PackedStringArray("_game_session_menu")] editor_description = "SS-102, UI-546" diff --git a/game/src/Game/GameSession/GameSessionMenu.tscn b/game/src/Game/GameSession/GameSessionMenu.tscn index 025ef3b..196a5d8 100644 --- a/game/src/Game/GameSession/GameSessionMenu.tscn +++ b/game/src/Game/GameSession/GameSessionMenu.tscn @@ -1,8 +1,8 @@ [gd_scene load_steps=4 format=3 uid="uid://dvdynl6eir40o"] [ext_resource type="Theme" uid="uid://cqrfmjt5yeti7" path="res://theme/game_session_menu.tres" id="1_2onog"] -[ext_resource type="Script" path="res://src/GameSession/GameSessionMenu.gd" id="1_usq6o"] -[ext_resource type="PackedScene" uid="uid://o4u142w4qkln" path="res://src/GameMenu.tscn" id="2_xi6a4"] +[ext_resource type="Script" path="res://src/Game/GameSession/GameSessionMenu.gd" id="1_usq6o"] +[ext_resource type="PackedScene" uid="uid://o4u142w4qkln" path="res://src/Game/GameMenu.tscn" id="2_xi6a4"] [node name="GameSessionMenu" type="PanelContainer" node_paths=PackedStringArray("_main_menu_dialog", "_quit_dialog")] process_mode = 3 diff --git a/game/src/Game/GameSession/GameSpeedPanel.tscn b/game/src/Game/GameSession/GameSpeedPanel.tscn index 8a37565..fab988e 100644 --- a/game/src/Game/GameSession/GameSpeedPanel.tscn +++ b/game/src/Game/GameSession/GameSpeedPanel.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=2 format=3 uid="uid://dd8k3p7r3huwc"] -[ext_resource type="Script" path="res://src/GameSession/GameSpeedPanel.gd" id="1_pfs8t"] +[ext_resource type="Script" path="res://src/Game/GameSession/GameSpeedPanel.gd" id="1_pfs8t"] [node name="GameSpeedPanel" type="PanelContainer" node_paths=PackedStringArray("_longform_date_button", "_play_pause_display_button", "_decrease_speed_button", "_increase_speed_button")] script = ExtResource("1_pfs8t") diff --git a/game/src/Game/GameSession/MapControlPanel/MapControlPanel.tscn b/game/src/Game/GameSession/MapControlPanel/MapControlPanel.tscn index bd4a010..a00f110 100644 --- a/game/src/Game/GameSession/MapControlPanel/MapControlPanel.tscn +++ b/game/src/Game/GameSession/MapControlPanel/MapControlPanel.tscn @@ -1,8 +1,8 @@ [gd_scene load_steps=7 format=3 uid="uid://g524p8lr574w"] -[ext_resource type="Script" path="res://src/GameSession/MapControlPanel/MapControlPanel.gd" id="1_ign64"] -[ext_resource type="Shader" path="res://src/GameSession/MapControlPanel/Minimap.gdshader" id="2_rinsg"] -[ext_resource type="Script" path="res://src/GameSession/MapControlPanel/Minimap.gd" id="3_s4dml"] +[ext_resource type="Script" path="res://src/Game/GameSession/MapControlPanel/MapControlPanel.gd" id="1_ign64"] +[ext_resource type="Shader" path="res://src/Game/GameSession/MapControlPanel/Minimap.gdshader" id="2_rinsg"] +[ext_resource type="Script" path="res://src/Game/GameSession/MapControlPanel/Minimap.gd" id="3_s4dml"] [sub_resource type="ShaderMaterial" id="ShaderMaterial_bhuqb"] shader = ExtResource("2_rinsg") diff --git a/game/src/Game/GameSession/MapControlPanel/Minimap.gdshader b/game/src/Game/GameSession/MapControlPanel/Minimap.gdshader index 608abe2..271b809 100644 --- a/game/src/Game/GameSession/MapControlPanel/Minimap.gdshader +++ b/game/src/Game/GameSession/MapControlPanel/Minimap.gdshader @@ -1,6 +1,6 @@ shader_type canvas_item; -#include "res://src/GameSession/ProvinceIndexSampler.gdshaderinc" +#include "res://src/Game/GameSession/ProvinceIndexSampler.gdshaderinc" // Index of the currently selected province uniform uint selected_index; diff --git a/game/src/Game/GameSession/MapView.tscn b/game/src/Game/GameSession/MapView.tscn index fa6ffcd..fb4ac07 100644 --- a/game/src/Game/GameSession/MapView.tscn +++ b/game/src/Game/GameSession/MapView.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=5 format=3 uid="uid://dkehmdnuxih2r"] -[ext_resource type="Script" path="res://src/GameSession/MapView.gd" id="1_exccw"] -[ext_resource type="Shader" path="res://src/GameSession/TerrainMap.gdshader" id="1_upocn"] +[ext_resource type="Script" path="res://src/Game/GameSession/MapView.gd" id="1_exccw"] +[ext_resource type="Shader" path="res://src/Game/GameSession/TerrainMap.gdshader" id="1_upocn"] [sub_resource type="ShaderMaterial" id="ShaderMaterial_tayeg"] render_priority = 0 diff --git a/game/src/Game/GameSession/ProvinceOverviewPanel/ProvinceOverviewPanel.tscn b/game/src/Game/GameSession/ProvinceOverviewPanel/ProvinceOverviewPanel.tscn index a233db0..f8c1e65 100644 --- a/game/src/Game/GameSession/ProvinceOverviewPanel/ProvinceOverviewPanel.tscn +++ b/game/src/Game/GameSession/ProvinceOverviewPanel/ProvinceOverviewPanel.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=2 format=3 uid="uid://byq323jbel48u"] -[ext_resource type="Script" path="res://src/GameSession/ProvinceOverviewPanel/ProvinceOverviewPanel.gd" id="1_3n8k5"] +[ext_resource type="Script" path="res://src/Game/GameSession/ProvinceOverviewPanel/ProvinceOverviewPanel.gd" id="1_3n8k5"] [node name="ProvinceOverviewPanel" type="PanelContainer" node_paths=PackedStringArray("_province_name_label", "_region_name_label", "_life_rating_bar", "_rgo_icon_texture_rect", "_rgo_name_label", "_buildings_container")] editor_description = "UI-56" diff --git a/game/src/Game/GameSession/TerrainMap.gdshader b/game/src/Game/GameSession/TerrainMap.gdshader index 88e7019..852ccc3 100644 --- a/game/src/Game/GameSession/TerrainMap.gdshader +++ b/game/src/Game/GameSession/TerrainMap.gdshader @@ -2,7 +2,7 @@ shader_type spatial; render_mode unshaded; -#include "res://src/GameSession/ProvinceIndexSampler.gdshaderinc" +#include "res://src/Game/GameSession/ProvinceIndexSampler.gdshaderinc" // Province colour texture uniform sampler2D province_colour_tex: source_color, repeat_enable, filter_nearest; diff --git a/game/src/Game/GameStart.tscn b/game/src/Game/GameStart.tscn index 2046bb5..dd683e8 100644 --- a/game/src/Game/GameStart.tscn +++ b/game/src/Game/GameStart.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=6 format=3 uid="uid://1udsn4mggep2"] -[ext_resource type="PackedScene" uid="uid://o4u142w4qkln" path="res://src/GameMenu.tscn" id="1_wlojq"] -[ext_resource type="Script" path="res://src/SplashContainer.gd" id="2_xmcgv"] +[ext_resource type="PackedScene" uid="uid://o4u142w4qkln" path="res://src/Game/GameMenu.tscn" id="1_vadki"] +[ext_resource type="Script" path="res://src/Game/SplashContainer.gd" id="2_xmcgv"] [ext_resource type="Texture2D" uid="uid://deef5hufq0j61" path="res://splash_assets/splash_end.png" id="3_qfv12"] [ext_resource type="Texture2D" uid="uid://cgdnixsyh7bja" path="res://splash_assets/splash_image.png" id="4_5b6yq"] [ext_resource type="VideoStream" path="res://splash_assets/splash_startup.ogv" id="5_8euyy"] @@ -14,7 +14,7 @@ anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 -[node name="GameMenu" parent="." instance=ExtResource("1_wlojq")] +[node name="GameMenu" parent="." instance=ExtResource("1_vadki")] visible = false layout_mode = 1 diff --git a/game/src/Game/LocaleButton.tscn b/game/src/Game/LocaleButton.tscn index 55f1c29..c4b58f8 100644 --- a/game/src/Game/LocaleButton.tscn +++ b/game/src/Game/LocaleButton.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=2 format=3 uid="uid://b7oncobnacxmt"] -[ext_resource type="Script" path="res://src/LocaleButton.gd" id="1_ganev"] +[ext_resource type="Script" path="res://src/Game/LocaleButton.gd" id="1_ganev"] [node name="LocaleButton" type="OptionButton"] custom_minimum_size = Vector2(150, 0) diff --git a/game/src/Game/Menu/CreditsMenu/CreditsMenu.tscn b/game/src/Game/Menu/CreditsMenu/CreditsMenu.tscn index 2d10d2e..df9d0b2 100644 --- a/game/src/Game/Menu/CreditsMenu/CreditsMenu.tscn +++ b/game/src/Game/Menu/CreditsMenu/CreditsMenu.tscn @@ -1,8 +1,8 @@ [gd_scene load_steps=4 format=3 uid="uid://c8knthxkwj1uj"] [ext_resource type="Theme" uid="uid://stfxt4hpsify" path="res://theme/credits_menu.tres" id="1_7y4l8"] -[ext_resource type="Script" path="res://src/CreditsMenu/CreditsMenu.gd" id="1_csd7i"] -[ext_resource type="PackedScene" uid="uid://ddjbee5gj6bkv" path="res://src/CreditsMenu/GodotEngineButton.tscn" id="3_fl02a"] +[ext_resource type="Script" path="res://src/Game/Menu/CreditsMenu/CreditsMenu.gd" id="1_csd7i"] +[ext_resource type="PackedScene" uid="uid://ddjbee5gj6bkv" path="res://src/Game/Menu/CreditsMenu/GodotEngineButton.tscn" id="3_fl02a"] [node name="CreditsMenu" type="Control" node_paths=PackedStringArray("credits_list")] editor_description = "UI-34" diff --git a/game/src/Game/Menu/CreditsMenu/GodotEngineButton.tscn b/game/src/Game/Menu/CreditsMenu/GodotEngineButton.tscn index 8b0c46b..c613553 100644 --- a/game/src/Game/Menu/CreditsMenu/GodotEngineButton.tscn +++ b/game/src/Game/Menu/CreditsMenu/GodotEngineButton.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=3 format=3 uid="uid://ddjbee5gj6bkv"] -[ext_resource type="Texture2D" uid="uid://rh7l4xuh4ali" path="res://src/CreditsMenu/logo_vertical_color_dark.svg" id="1_b0brk"] -[ext_resource type="Script" path="res://src/CreditsMenu/GodotEngineButton.gd" id="3_gi8fv"] +[ext_resource type="Texture2D" uid="uid://rh7l4xuh4ali" path="res://src/Game/Menu/CreditsMenu/logo_vertical_color_dark.svg" id="1_b0brk"] +[ext_resource type="Script" path="res://src/Game/Menu/CreditsMenu/GodotEngineButton.gd" id="3_gi8fv"] [node name="GodotEngineButton" type="Button"] custom_minimum_size = Vector2(0, 200) diff --git a/game/src/Game/Menu/CreditsMenu/logo_vertical_color_dark.svg.import b/game/src/Game/Menu/CreditsMenu/logo_vertical_color_dark.svg.import index a4fb09a..10681d4 100644 --- a/game/src/Game/Menu/CreditsMenu/logo_vertical_color_dark.svg.import +++ b/game/src/Game/Menu/CreditsMenu/logo_vertical_color_dark.svg.import @@ -3,15 +3,15 @@ importer="texture" type="CompressedTexture2D" uid="uid://rh7l4xuh4ali" -path="res://.godot/imported/logo_vertical_color_dark.svg-1167b3ce62f0747c0e76b17bdbb9f218.ctex" +path="res://.godot/imported/logo_vertical_color_dark.svg-c63a0d0871169a4a2f8b57a5b904d732.ctex" metadata={ "vram_texture": false } [deps] -source_file="res://src/CreditsMenu/logo_vertical_color_dark.svg" -dest_files=["res://.godot/imported/logo_vertical_color_dark.svg-1167b3ce62f0747c0e76b17bdbb9f218.ctex"] +source_file="res://src/Game/Menu/CreditsMenu/logo_vertical_color_dark.svg" +dest_files=["res://.godot/imported/logo_vertical_color_dark.svg-c63a0d0871169a4a2f8b57a5b904d732.ctex"] [params] diff --git a/game/src/Game/Menu/LobbyMenu/LobbyMenu.gd b/game/src/Game/Menu/LobbyMenu/LobbyMenu.gd index db4f2ce..3c857fe 100644 --- a/game/src/Game/Menu/LobbyMenu/LobbyMenu.gd +++ b/game/src/Game/Menu/LobbyMenu/LobbyMenu.gd @@ -116,7 +116,7 @@ func _on_session_tag_edit_text_submitted(new_text): _on_start_button_pressed() func _on_session_tag_dialog_confirmed(): - get_tree().change_scene_to_file("res://src/GameSession/GameSession.tscn") + get_tree().change_scene_to_file("res://src/Game/GameSession/GameSession.tscn") var _requested_node_to_delete : Control func _on_save_node_delete_requested(node : Control) -> void: diff --git a/game/src/Game/Menu/LobbyMenu/LobbyMenu.tscn b/game/src/Game/Menu/LobbyMenu/LobbyMenu.tscn index 3b5796e..081beda 100644 --- a/game/src/Game/Menu/LobbyMenu/LobbyMenu.tscn +++ b/game/src/Game/Menu/LobbyMenu/LobbyMenu.tscn @@ -1,8 +1,8 @@ [gd_scene load_steps=4 format=3 uid="uid://do60kx0d3nrh4"] -[ext_resource type="Script" path="res://src/LobbyMenu/LobbyMenu.gd" id="1_cvwum"] -[ext_resource type="PackedScene" uid="uid://k71f5gibwmtc" path="res://src/LobbyMenu/LobbyPanelButton.tscn" id="2_exh17"] -[ext_resource type="PackedScene" uid="uid://d2s7roinx2or7" path="res://src/SaveLoadMenu/SavePanelButton.tscn" id="3_4otj7"] +[ext_resource type="Script" path="res://src/Game/Menu/LobbyMenu/LobbyMenu.gd" id="1_cvwum"] +[ext_resource type="PackedScene" uid="uid://k71f5gibwmtc" path="res://src/Game/Menu/LobbyMenu/LobbyPanelButton.tscn" id="2_exh17"] +[ext_resource type="PackedScene" uid="uid://d2s7roinx2or7" path="res://src/Game/Menu/SaveLoadMenu/SavePanelButton.tscn" id="3_4otj7"] [node name="LobbyMenu" type="HBoxContainer" node_paths=PackedStringArray("game_select_start_date", "game_select_save_tab", "game_select_save_list", "start_button", "session_tag_line_edit", "session_tag_dialog", "delete_dialog")] editor_description = "UI-36" diff --git a/game/src/Game/Menu/LobbyMenu/LobbyPanelButton.tscn b/game/src/Game/Menu/LobbyMenu/LobbyPanelButton.tscn index f409a2e..f27ddac 100644 --- a/game/src/Game/Menu/LobbyMenu/LobbyPanelButton.tscn +++ b/game/src/Game/Menu/LobbyMenu/LobbyPanelButton.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=2 format=3 uid="uid://k71f5gibwmtc"] -[ext_resource type="Script" path="res://src/LobbyMenu/LobbyPanelButton.gd" id="1_327u2"] +[ext_resource type="Script" path="res://src/Game/Menu/LobbyMenu/LobbyPanelButton.gd" id="1_327u2"] [node name="LobbyPanelButton" type="Container" node_paths=PackedStringArray("background_button", "name_label")] editor_description = "UI-41" diff --git a/game/src/Game/Menu/MainMenu/MainMenu.tscn b/game/src/Game/Menu/MainMenu/MainMenu.tscn index 0618fe8..71d020a 100644 --- a/game/src/Game/Menu/MainMenu/MainMenu.tscn +++ b/game/src/Game/Menu/MainMenu/MainMenu.tscn @@ -1,10 +1,10 @@ [gd_scene load_steps=6 format=3 uid="uid://bp5n3mlu45ygw"] [ext_resource type="Theme" uid="uid://qoi3oec48jp0" path="res://theme/main_menu.tres" id="1_1yri4"] -[ext_resource type="Script" path="res://src/MainMenu/MainMenu.gd" id="2_nm1fq"] +[ext_resource type="Script" path="res://src/Game/Menu/MainMenu/MainMenu.gd" id="2_nm1fq"] [ext_resource type="Texture2D" uid="uid://dxys0wg0f0ic5" path="res://theme/assets/OpenVicFINALREALTRANS.png" id="3_58ess"] -[ext_resource type="PackedScene" uid="uid://b7oncobnacxmt" path="res://src/LocaleButton.tscn" id="3_amonp"] -[ext_resource type="PackedScene" uid="uid://cen7wkmn6og66" path="res://src/MainMenu/ReleaseInfoBox.tscn" id="3_km0er"] +[ext_resource type="PackedScene" uid="uid://b7oncobnacxmt" path="res://src/Game/LocaleButton.tscn" id="3_amonp"] +[ext_resource type="PackedScene" uid="uid://cen7wkmn6og66" path="res://src/Game/Menu/MainMenu/ReleaseInfoBox.tscn" id="3_km0er"] [node name="MainMenu" type="Control" node_paths=PackedStringArray("_new_game_button")] editor_description = "UI-13" diff --git a/game/src/Game/Menu/MainMenu/ReleaseInfoBox.tscn b/game/src/Game/Menu/MainMenu/ReleaseInfoBox.tscn index 821982b..a10232e 100644 --- a/game/src/Game/Menu/MainMenu/ReleaseInfoBox.tscn +++ b/game/src/Game/Menu/MainMenu/ReleaseInfoBox.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=2 format=3 uid="uid://cen7wkmn6og66"] -[ext_resource type="Script" path="res://src/MainMenu/ReleaseInfoBox.gd" id="1_y2djw"] +[ext_resource type="Script" path="res://src/Game/Menu/MainMenu/ReleaseInfoBox.gd" id="1_y2djw"] [node name="ReleaseInfoBox" type="HBoxContainer" node_paths=PackedStringArray("_version_label", "_commit_label", "_checksum_label")] editor_description = "UI-31" diff --git a/game/src/Game/Menu/OptionMenu/GeneralTab.tscn b/game/src/Game/Menu/OptionMenu/GeneralTab.tscn index 4e9ff6a..1c49326 100644 --- a/game/src/Game/Menu/OptionMenu/GeneralTab.tscn +++ b/game/src/Game/Menu/OptionMenu/GeneralTab.tscn @@ -1,9 +1,9 @@ [gd_scene load_steps=5 format=3 uid="uid://duwjal7sd7p6w"] -[ext_resource type="Script" path="res://src/OptionMenu/GeneralTab.gd" id="1_gbutn"] -[ext_resource type="PackedScene" uid="uid://b7oncobnacxmt" path="res://src/LocaleButton.tscn" id="2_5cfd7"] -[ext_resource type="Script" path="res://src/OptionMenu/SettingNodes/SettingOptionButton.gd" id="2_msx2u"] -[ext_resource type="Script" path="res://src/OptionMenu/AutosaveIntervalSelector.gd" id="2_t06tb"] +[ext_resource type="Script" path="res://src/Game/Menu/OptionMenu/GeneralTab.gd" id="1_gbutn"] +[ext_resource type="PackedScene" uid="uid://b7oncobnacxmt" path="res://src/Game/LocaleButton.tscn" id="2_5cfd7"] +[ext_resource type="Script" path="res://src/Game/Menu/OptionMenu/SettingNodes/SettingOptionButton.gd" id="2_msx2u"] +[ext_resource type="Script" path="res://src/Game/Menu/OptionMenu/AutosaveIntervalSelector.gd" id="2_t06tb"] [node name="GeneralTab" type="HBoxContainer" node_paths=PackedStringArray("initial_focus")] editor_description = "UI-48, UIFUN-45" diff --git a/game/src/Game/Menu/OptionMenu/OptionsMenu.tscn b/game/src/Game/Menu/OptionMenu/OptionsMenu.tscn index 3156e33..017629a 100644 --- a/game/src/Game/Menu/OptionMenu/OptionsMenu.tscn +++ b/game/src/Game/Menu/OptionMenu/OptionsMenu.tscn @@ -1,12 +1,12 @@ [gd_scene load_steps=8 format=3 uid="uid://cnbfxjy1m6wja"] [ext_resource type="Theme" uid="uid://fbxssqcg1s0m" path="res://theme/options_menu.tres" id="1_0up1d"] -[ext_resource type="Script" path="res://src/OptionMenu/OptionsMenu.gd" id="1_tlein"] -[ext_resource type="PackedScene" uid="uid://bq3awxxjn1tuw" path="res://src/OptionMenu/VideoTab.tscn" id="2_ji8xr"] -[ext_resource type="PackedScene" uid="uid://cbtgwpx2wxi33" path="res://src/OptionMenu/SoundTab.tscn" id="3_4w35t"] -[ext_resource type="PackedScene" uid="uid://duwjal7sd7p6w" path="res://src/OptionMenu/GeneralTab.tscn" id="3_6gvf6"] +[ext_resource type="Script" path="res://src/Game/Menu/OptionMenu/OptionsMenu.gd" id="1_tlein"] +[ext_resource type="PackedScene" uid="uid://bq3awxxjn1tuw" path="res://src/Game/Menu/OptionMenu/VideoTab.tscn" id="2_ji8xr"] +[ext_resource type="PackedScene" uid="uid://cbtgwpx2wxi33" path="res://src/Game/Menu/OptionMenu/SoundTab.tscn" id="3_4w35t"] +[ext_resource type="PackedScene" uid="uid://duwjal7sd7p6w" path="res://src/Game/Menu/OptionMenu/GeneralTab.tscn" id="3_6gvf6"] [ext_resource type="PackedScene" uid="uid://bq7ibhm0txl5p" path="res://addons/keychain/ShortcutEdit.tscn" id="4_vdhjp"] -[ext_resource type="PackedScene" uid="uid://dp2grvybtecqu" path="res://src/OptionMenu/OtherTab.tscn" id="5_ahefp"] +[ext_resource type="PackedScene" uid="uid://dp2grvybtecqu" path="res://src/Game/Menu/OptionMenu/OtherTab.tscn" id="5_ahefp"] [node name="OptionsMenu" type="PanelContainer"] editor_description = "UI-25" diff --git a/game/src/Game/Menu/OptionMenu/SoundTab.tscn b/game/src/Game/Menu/OptionMenu/SoundTab.tscn index 10d7f10..4bb6948 100644 --- a/game/src/Game/Menu/OptionMenu/SoundTab.tscn +++ b/game/src/Game/Menu/OptionMenu/SoundTab.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=3 format=3 uid="uid://cbtgwpx2wxi33"] -[ext_resource type="Script" path="res://src/OptionMenu/SoundTab.gd" id="1_a7k0s"] -[ext_resource type="PackedScene" uid="uid://dy4si8comamnv" path="res://src/OptionMenu/VolumeGrid.tscn" id="1_okpft"] +[ext_resource type="Script" path="res://src/Game/Menu/OptionMenu/SoundTab.gd" id="1_a7k0s"] +[ext_resource type="PackedScene" uid="uid://dy4si8comamnv" path="res://src/Game/Menu/OptionMenu/VolumeGrid.tscn" id="1_okpft"] [node name="Sound" type="HBoxContainer"] alignment = 1 diff --git a/game/src/Game/Menu/OptionMenu/VideoTab.tscn b/game/src/Game/Menu/OptionMenu/VideoTab.tscn index 244f481..4f5151c 100644 --- a/game/src/Game/Menu/OptionMenu/VideoTab.tscn +++ b/game/src/Game/Menu/OptionMenu/VideoTab.tscn @@ -1,13 +1,13 @@ [gd_scene load_steps=9 format=3 uid="uid://bq3awxxjn1tuw"] -[ext_resource type="Script" path="res://src/OptionMenu/ResolutionSelector.gd" id="1_i8nro"] -[ext_resource type="Script" path="res://src/OptionMenu/VideoTab.gd" id="1_jvv62"] -[ext_resource type="Script" path="res://src/OptionMenu/ScreenModeSelector.gd" id="2_wa7vw"] -[ext_resource type="Script" path="res://src/OptionMenu/GuiScaleSelector.gd" id="3_pgc5d"] -[ext_resource type="Script" path="res://src/OptionMenu/MonitorDisplaySelector.gd" id="3_y6lyb"] -[ext_resource type="Script" path="res://src/OptionMenu/RefreshRateSelector.gd" id="4_381mg"] -[ext_resource type="Script" path="res://src/OptionMenu/QualityPresetSelector.gd" id="5_srg4v"] -[ext_resource type="Script" path="res://src/OptionMenu/ResolutionRevertDialog.gd" id="8_802cr"] +[ext_resource type="Script" path="res://src/Game/Menu/OptionMenu/ResolutionSelector.gd" id="1_i8nro"] +[ext_resource type="Script" path="res://src/Game/Menu/OptionMenu/VideoTab.gd" id="1_jvv62"] +[ext_resource type="Script" path="res://src/Game/Menu/OptionMenu/ScreenModeSelector.gd" id="2_wa7vw"] +[ext_resource type="Script" path="res://src/Game/Menu/OptionMenu/GuiScaleSelector.gd" id="3_pgc5d"] +[ext_resource type="Script" path="res://src/Game/Menu/OptionMenu/MonitorDisplaySelector.gd" id="3_y6lyb"] +[ext_resource type="Script" path="res://src/Game/Menu/OptionMenu/RefreshRateSelector.gd" id="4_381mg"] +[ext_resource type="Script" path="res://src/Game/Menu/OptionMenu/QualityPresetSelector.gd" id="5_srg4v"] +[ext_resource type="Script" path="res://src/Game/Menu/OptionMenu/ResolutionRevertDialog.gd" id="8_802cr"] [node name="Video" type="HBoxContainer" node_paths=PackedStringArray("initial_focus")] editor_description = "UI-46" diff --git a/game/src/Game/Menu/OptionMenu/VolumeGrid.tscn b/game/src/Game/Menu/OptionMenu/VolumeGrid.tscn index 6d4de3c..5dd3c1e 100644 --- a/game/src/Game/Menu/OptionMenu/VolumeGrid.tscn +++ b/game/src/Game/Menu/OptionMenu/VolumeGrid.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=2 format=3 uid="uid://dy4si8comamnv"] -[ext_resource type="Script" path="res://src/OptionMenu/VolumeGrid.gd" id="1_wb64h"] +[ext_resource type="Script" path="res://src/Game/Menu/OptionMenu/VolumeGrid.gd" id="1_wb64h"] [node name="VolumeGrid" type="GridContainer"] size_flags_vertical = 0 diff --git a/game/src/Game/Menu/SaveLoadMenu/SaveLoadMenu.tscn b/game/src/Game/Menu/SaveLoadMenu/SaveLoadMenu.tscn index e9f068e..adc9bdc 100644 --- a/game/src/Game/Menu/SaveLoadMenu/SaveLoadMenu.tscn +++ b/game/src/Game/Menu/SaveLoadMenu/SaveLoadMenu.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=5 format=3 uid="uid://d3g6wbvwflmyk"] -[ext_resource type="Script" path="res://src/SaveLoadMenu/SaveLoadMenu.gd" id="1_3jkds"] -[ext_resource type="PackedScene" uid="uid://d2s7roinx2or7" path="res://src/SaveLoadMenu/SavePanelButton.tscn" id="2_fc6r3"] +[ext_resource type="Script" path="res://src/Game/Menu/SaveLoadMenu/SaveLoadMenu.gd" id="1_3jkds"] +[ext_resource type="PackedScene" uid="uid://d2s7roinx2or7" path="res://src/Game/Menu/SaveLoadMenu/SavePanelButton.tscn" id="2_fc6r3"] [sub_resource type="InputEventAction" id="InputEventAction_8vo2t"] action = &"ui_accept" diff --git a/game/src/Game/Menu/SaveLoadMenu/SavePanelButton.tscn b/game/src/Game/Menu/SaveLoadMenu/SavePanelButton.tscn index d2d0a41..94dc8a3 100644 --- a/game/src/Game/Menu/SaveLoadMenu/SavePanelButton.tscn +++ b/game/src/Game/Menu/SaveLoadMenu/SavePanelButton.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=2 format=3 uid="uid://d2s7roinx2or7"] -[ext_resource type="Script" path="res://src/SaveLoadMenu/SavePanelButton.gd" id="1_rtuo6"] +[ext_resource type="Script" path="res://src/Game/Menu/SaveLoadMenu/SavePanelButton.gd" id="1_rtuo6"] [node name="SavePanelButton" type="Container" node_paths=PackedStringArray("country_flag", "date_label", "delete_button", "background_button", "name_label")] editor_description = "SS-18, UI-40, UI-84, UI-86, UI-91, UI-93" diff --git a/game/src/Game/MusicConductor/MusicConductor.tscn b/game/src/Game/MusicConductor/MusicConductor.tscn index 182de99..3c288be 100644 --- a/game/src/Game/MusicConductor/MusicConductor.tscn +++ b/game/src/Game/MusicConductor/MusicConductor.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=2 format=3 uid="uid://b1h31mnn8n2nu"] -[ext_resource type="Script" path="res://src/MusicConductor/MusicConductor.gd" id="1_56t1b"] +[ext_resource type="Script" path="res://src/Game/MusicConductor/MusicConductor.gd" id="1_56t1b"] [node name="MusicConductor" type="Node"] script = ExtResource("1_56t1b") diff --git a/game/src/Game/MusicConductor/MusicPlayer.tscn b/game/src/Game/MusicConductor/MusicPlayer.tscn index 80ad641..8d47ba0 100644 --- a/game/src/Game/MusicConductor/MusicPlayer.tscn +++ b/game/src/Game/MusicConductor/MusicPlayer.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=2 format=3 uid="uid://cvl76duuym1wq"] -[ext_resource type="Script" path="res://src/MusicConductor/MusicPlayer.gd" id="1_gcm4m"] +[ext_resource type="Script" path="res://src/Game/MusicConductor/MusicPlayer.gd" id="1_gcm4m"] [node name="MusicPlayer" type="BoxContainer" node_paths=PackedStringArray("_song_selector_button", "_progress_slider", "_previous_song_button", "_play_pause_button", "_next_song_button", "_visbility_button")] editor_description = "UI-104" diff --git a/game/theme/game_session_menu.tres b/game/theme/game_session_menu.tres index 0cab476..68847d4 100644 --- a/game/theme/game_session_menu.tres +++ b/game/theme/game_session_menu.tres @@ -1,7 +1,7 @@ [gd_resource type="Theme" load_steps=11 format=3 uid="uid://cqrfmjt5yeti7"] [ext_resource type="StyleBox" uid="uid://blwilunhmyvpq" path="res://theme/assets/main_menu_button_normal.tres" id="1_7med2"] -[ext_resource type="Script" path="res://src/Utility/StyleBoxWithSound.gd" id="2_oj3dv"] +[ext_resource type="Script" path="res://src/Game/Theme/StyleBoxWithSound.gd" id="2_oj3dv"] [ext_resource type="AudioStream" uid="uid://bsldcs3l8s7ug" path="res://addons/kenney_ui_audio/click3.wav" id="3_j823n"] [ext_resource type="Texture2D" uid="uid://c0p34i3d3b0pw" path="res://theme/assets/main_menu_button.png" id="4_lno5s"] diff --git a/game/theme/main_menu.tres b/game/theme/main_menu.tres index 0518cd8..e25da4d 100644 --- a/game/theme/main_menu.tres +++ b/game/theme/main_menu.tres @@ -1,12 +1,12 @@ [gd_resource type="Theme" load_steps=32 format=3 uid="uid://qoi3oec48jp0"] -[ext_resource type="Script" path="res://src/Utility/StyleBoxCombinedTexture.gd" id="1_axke7"] -[ext_resource type="Script" path="res://src/Utility/TextureSetting.gd" id="2_7bwl2"] +[ext_resource type="Script" path="res://src/Game/Theme/StyleBoxCombinedTexture.gd" id="1_axke7"] +[ext_resource type="Script" path="res://src/Game/Theme/TextureSetting.gd" id="2_7bwl2"] [ext_resource type="Texture2D" uid="uid://dapuqgpjs56bs" path="res://theme/assets/main_menu_background.png" id="3_cpatd"] [ext_resource type="Texture2D" uid="uid://q25s41oavuxw" path="res://theme/assets/main_menu_border_paper.png" id="4_sl60o"] [ext_resource type="Texture2D" uid="uid://c0p34i3d3b0pw" path="res://theme/assets/main_menu_button.png" id="5_xj7ql"] [ext_resource type="StyleBox" uid="uid://blwilunhmyvpq" path="res://theme/assets/main_menu_button_normal.tres" id="6_dx0aj"] -[ext_resource type="Script" path="res://src/Utility/StyleBoxWithSound.gd" id="7_qo00e"] +[ext_resource type="Script" path="res://src/Game/Theme/StyleBoxWithSound.gd" id="7_qo00e"] [ext_resource type="AudioStream" uid="uid://bsldcs3l8s7ug" path="res://addons/kenney_ui_audio/click3.wav" id="8_etuft"] [sub_resource type="Resource" id="Resource_hxpog"] diff --git a/game/theme/options_menu.tres b/game/theme/options_menu.tres index 04bcb96..58c12ab 100644 --- a/game/theme/options_menu.tres +++ b/game/theme/options_menu.tres @@ -1,7 +1,7 @@ [gd_resource type="Theme" load_steps=8 format=3 uid="uid://fbxssqcg1s0m"] -[ext_resource type="Script" path="res://src/Utility/StyleBoxCombinedTexture.gd" id="1_6eqg5"] -[ext_resource type="Script" path="res://src/Utility/TextureSetting.gd" id="2_d0e1t"] +[ext_resource type="Script" path="res://src/Game/Theme/StyleBoxCombinedTexture.gd" id="1_6eqg5"] +[ext_resource type="Script" path="res://src/Game/Theme/TextureSetting.gd" id="2_d0e1t"] [ext_resource type="Texture2D" uid="uid://dapuqgpjs56bs" path="res://theme/assets/main_menu_background.png" id="3_t863y"] [ext_resource type="Texture2D" uid="uid://q25s41oavuxw" path="res://theme/assets/main_menu_border_paper.png" id="4_ljte1"] -- cgit v1.2.3-56-ga3b1