diff --git a/.gitignore b/.gitignore index 3635d19d..548b3fbd 100644 --- a/.gitignore +++ b/.gitignore @@ -43,6 +43,8 @@ project.lock.json C7.ini log.txt *.csproj.old* +# testing save.json save file +C7/Text/save.json # Build results [Dd]ebug/ diff --git a/C7/Art/grid.png.import b/C7/Art/grid.png.import new file mode 100644 index 00000000..c967a101 --- /dev/null +++ b/C7/Art/grid.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://ddwhuw1mk34rf" +path="res://.godot/imported/grid.png-78ae50a518b22416c81002ab51b5507d.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Art/grid.png" +dest_files=["res://.godot/imported/grid.png-78ae50a518b22416c81002ab51b5507d.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=1 diff --git a/C7/Credits.tscn b/C7/Credits.tscn index 63cd3075..efbf3217 100644 --- a/C7/Credits.tscn +++ b/C7/Credits.tscn @@ -1,6 +1,6 @@ -[gd_scene load_steps=2 format=2] +[gd_scene load_steps=2 format=3 uid="uid://i4j8a5aipkok"] -[ext_resource path="res://Credits.cs" type="Script" id=1] +[ext_resource type="Script" path="res://Credits.cs" id="1"] [node name="Node2D" type="Node2D"] -script = ExtResource( 1 ) +script = ExtResource("1") diff --git a/C7/Game.cs b/C7/Game.cs index b9c90b26..00b13c5a 100644 --- a/C7/Game.cs +++ b/C7/Game.cs @@ -58,16 +58,18 @@ public override void _Ready() { GetTree().AutoAcceptQuit = false; Global = GetNode("/root/GlobalSingleton"); try { - var animSoundPlayer = new AudioStreamPlayer(); + AudioStreamPlayer animSoundPlayer = new(); AddChild(animSoundPlayer); civ3AnimData = new AnimationManager(animSoundPlayer); animTracker = new AnimationTracker(civ3AnimData); controller = CreateGame.createGame(Global.LoadGamePath, Global.DefaultBicPath); // Spawns engine thread + GetNode("CanvasLayer/Control/GameStatus").CurrentPlayer = controller; + Global.ResetLoadGamePath(); camera = GetNode("MapViewCamera"); - using (var gameDataAccess = new UIGameDataAccess()) { + using (UIGameDataAccess gameDataAccess = new()) { GameMap map = gameDataAccess.gameData.map; Util.setModPath(gameDataAccess.gameData.scenarioSearchPath); log.Debug("RelativeModPath ", map.RelativeModPath); @@ -417,6 +419,10 @@ private void processActions() { this.OnPlayerEndTurn(); } + if (Input.IsActionJustPressed(C7Action.SaveGame)) { + OnSaveGame("./Text/save.json"); + } + if (this.HasCurrentlySelectedUnit()) { // TODO: replace bool with an invalid TileDirection enum TileDirection dir = TileDirection.NORTH; @@ -472,10 +478,9 @@ private void processActions() { } if (Input.IsActionJustPressed(C7Action.UnitWait)) { - using (var gameDataAccess = new UIGameDataAccess()) { - UnitInteractions.waitUnit(gameDataAccess.gameData, CurrentlySelectedUnit.id); - GetNextAutoselectedUnit(gameDataAccess.gameData); - } + using UIGameDataAccess gameDataAccess = new(); + UnitInteractions.waitUnit(gameDataAccess.gameData, CurrentlySelectedUnit.id); + GetNextAutoselectedUnit(gameDataAccess.gameData); } if (Input.IsActionJustPressed(C7Action.UnitFortify)) { @@ -507,14 +512,12 @@ private void processActions() { } if (Input.IsActionJustPressed(C7Action.UnitBuildCity) && CurrentlySelectedUnit.canBuildCity()) { - using (var gameDataAccess = new UIGameDataAccess()) { - MapUnit currentUnit = gameDataAccess.gameData.GetUnit(CurrentlySelectedUnit.id); - log.Debug(currentUnit.Describe()); - if (currentUnit.canBuildCity()) { - PopupOverlay popupOverlay = GetNode(PopupOverlay.NodePath); - popupOverlay.ShowPopup(new BuildCityDialog(controller.GetNextCityName()), - PopupOverlay.PopupCategory.Advisor); - } + using UIGameDataAccess gameDataAccess = new(); + MapUnit currentUnit = gameDataAccess.gameData.GetUnit(CurrentlySelectedUnit.id); + log.Debug(currentUnit.Describe()); + if (currentUnit.canBuildCity()) { + PopupOverlay popupOverlay = GetNode(PopupOverlay.NodePath); + popupOverlay.ShowPopup(new BuildCityDialog(controller.GetNextCityName()), PopupOverlay.PopupCategory.Advisor); } } @@ -557,4 +560,9 @@ public override void _Notification(int what) { private void OnBuildCity(string name) { new MsgBuildCity(CurrentlySelectedUnit.id, name).send(); } + + private void OnSaveGame(string path) { + log.Debug($"Saving game to {path}"); + new MsgSaveGame(path).send(); + } } diff --git a/C7/GlobalSingleton.cs b/C7/GlobalSingleton.cs index 75be8165..ff5ebb10 100644 --- a/C7/GlobalSingleton.cs +++ b/C7/GlobalSingleton.cs @@ -2,9 +2,9 @@ using QueryCiv3; /**** - Need to pass values from one scene to another, particularly when loading - a game in main menu. This script is set to auto load in project settings. - See https://docs.godotengine.org/en/stable/getting_started/step_by_step/singletons_autoload.html + Need to pass values from one scene to another, particularly when loading + a game in main menu. This script is set to auto load in project settings. + See https://docs.godotengine.org/en/stable/getting_started/step_by_step/singletons_autoload.html ****/ public partial class GlobalSingleton : Node { // Will have main menu file picker set this and Game.cs pass it to C7Engine.createGame diff --git a/C7/MainMenu.cs b/C7/MainMenu.cs index 2b209c32..1a213724 100644 --- a/C7/MainMenu.cs +++ b/C7/MainMenu.cs @@ -30,11 +30,13 @@ public override void _Ready() // To pass data between scenes, putting path string in a global singleton and reading it later in createGame Global = GetNode("/root/GlobalSingleton"); Global.ResetLoadGamePath(); - LoadDialog = new Util.Civ3FileDialog(); - LoadDialog.RelPath = @"Conquests/Saves"; + LoadDialog = new Util.Civ3FileDialog { + RelPath = @"Conquests/Saves" + }; LoadDialog.Connect("file_selected",new Callable(this,nameof(_on_FileDialog_file_selected))); - LoadScenarioDialog = new Util.Civ3FileDialog(); - LoadScenarioDialog.RelPath = @"Conquests/Scenarios"; + LoadScenarioDialog = new Util.Civ3FileDialog { + RelPath = @"Conquests/Scenarios" + }; LoadScenarioDialog.Connect("file_selected",new Callable(this,nameof(_on_FileDialog_file_selected))); GetNode("CanvasLayer").AddChild(LoadDialog); SetCiv3Home = GetNode