Skip to content

Commit 535a92c

Browse files
committed
Use user:// and res:// paths for the static/generated saves
I think this should fix the issue of local files not being found on macs. I used this reference: https://docs.godotengine.org/en/latest/tutorials/io/data_paths.html
1 parent 4fa421e commit 535a92c

File tree

4 files changed

+8
-15
lines changed

4 files changed

+8
-15
lines changed

C7/Game.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public override void _Ready() {
106106
civ3AnimData = new AnimationManager(animSoundPlayer);
107107
animTracker = new AnimationTracker(civ3AnimData);
108108

109-
controller = CreateGame.createGame(Global.LoadGamePath, Global.DefaultBicPath, (scenarioSearchPath) => {
109+
controller = CreateGame.createGame(Global.LoadGamePath, GlobalSingleton.DefaultBicPath, (scenarioSearchPath) => {
110110
// WHen the game loading logic tries to load the PediaIcons file, set the
111111
// scenario search path and then use our Civ3MediaPath searching logic to
112112
// find the correct version of the file.

C7/GlobalSingleton.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ public partial class GlobalSingleton : Node {
1313
// and back to game
1414
public string LoadGamePath;
1515
// For now this needs to get passed to QueryCiv3 when importing.
16-
public string DefaultBicPath { get => Util.GetCiv3Path() + @"/Conquests/conquests.biq"; }
16+
public static string DefaultBicPath { get => Util.GetCiv3Path() + @"/Conquests/conquests.biq"; }
1717

1818
// This is the 'static map' used in lieu of terrain generation
19-
public string DefaultGamePath { get => @"./Text/c7-static-map-save.json"; }
19+
public static string DefaultGamePath { get => ProjectSettings.GlobalizePath(@"res://Text/c7-static-map-save.json"); }
2020

2121
// The file where a generated map is saved, until we get more advanced ways
2222
// to generate new games.
2323
// TODO: improve this.
24-
public string DefaultGeneratedGamePath { get => @"./Text/c7-autosave-turn-0.json"; }
24+
public static string DefaultGeneratedGamePath { get => ProjectSettings.GlobalizePath(@"user://generated-game.json"); }
2525

2626
public void ResetLoadGamePath() {
2727
LoadGamePath = DefaultGamePath;

C7/UIElements/NewGame/PlayerSetup.cs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -204,14 +204,7 @@ private void DisplaySelectedLeader() {
204204
}
205205

206206
private SaveGame GetSave() {
207-
if (!Engine.IsEditorHint()) {
208-
GlobalSingleton Global = GetNode<GlobalSingleton>("/root/GlobalSingleton");
209-
return SaveManager.LoadSave(Global.DefaultGamePath, Global.DefaultBicPath, (string unused) => { return unused; });
210-
} else {
211-
// Hardcoded fallback for the godot editor, which doesn't handle the
212-
// global.
213-
return SaveManager.LoadSave(@"./Text/c7-static-map-save.json", "", (string unused) => { return unused; });
214-
}
207+
return SaveManager.LoadSave(GlobalSingleton.DefaultGamePath, GlobalSingleton.DefaultBicPath, (string unused) => { return unused; });
215208
}
216209

217210
private void CreateGame() {
@@ -275,8 +268,8 @@ private void DoWorldGenerationAndstartGame(SaveGame save, GlobalSingleton Global
275268
save.GameDifficulty = difficulty;
276269

277270
log.Information("saving generated map");
278-
save.Save(Global.DefaultGeneratedGamePath);
279-
Global.LoadGamePath = Global.DefaultGeneratedGamePath;
271+
save.Save(GlobalSingleton.DefaultGeneratedGamePath);
272+
Global.LoadGamePath = GlobalSingleton.DefaultGeneratedGamePath;
280273

281274
log.Information("opening map");
282275
CallDeferred("StartGame");

C7/UIElements/NewGame/WorldSetup.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ private void ResetAgeGraphics() {
314314
private void CreateGame() {
315315
GlobalSingleton Global = GetNode<GlobalSingleton>("/root/GlobalSingleton");
316316
Global.ResetLoadGamePath();
317-
SaveGame save = SaveManager.LoadSave(Global.DefaultGamePath, Global.DefaultBicPath, (string unused) => { return unused; });
317+
SaveGame save = SaveManager.LoadSave(GlobalSingleton.DefaultGamePath, GlobalSingleton.DefaultBicPath, (string unused) => { return unused; });
318318

319319
Global.WorldCharacteristics = new WorldCharacteristics() {
320320
landform = landform,

0 commit comments

Comments
 (0)