Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 7 additions & 16 deletions C7/Game.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,7 @@ public override async void _Ready() {
}

private async Task LoadGame() {
// Ensure we clear out our image caches, as scenarios and games will
// use the same filenames but have different content for them.
Util.ClearCaches();

CreateGameParams options = new(GamePaths.LuaRulesDir, GamePaths.DefaultBicPath)
CreateGameParams options = new(GamePaths.DefaultBicPath)
{
GetPediaIconsPath = (scenarioSearchPath) => {
// When the game loading logic tries to load the PediaIcons file, set the
Expand All @@ -133,11 +129,14 @@ private async Task LoadGame() {
Util.setModPath(scenarioSearchPath);
log.Debug("RelativeModPath ", scenarioSearchPath);
return Util.Civ3MediaPath("Text/PediaIcons.txt");
}
},
GameModeLoader = (config) => {
Global.ActivateGameMode(config);
return Global.GameMode.behaviors;
},
};

if (Global.SaveGame != null) {
controller = await CreateGame.createGame(Global.SaveGame, options);
controller = await CreateGame.createGame(Global.SaveGame, options.GameModeLoader);
} else if (Global.LoadGamePath != null) {
controller = await CreateGame.createGame(Global.LoadGamePath, options);
} else {
Expand Down Expand Up @@ -597,9 +596,6 @@ private void HandleKeyboardInput(InputEventKey eventKeyDown) {
if (eventKeyDown.Keycode == Godot.Key.O && eventKeyDown.ShiftPressed && eventKeyDown.IsCommandOrControlPressed() && eventKeyDown.AltPressed) {
ToggleObserverMode();
}
if (eventKeyDown.Keycode == Godot.Key.T && eventKeyDown.ShiftPressed && eventKeyDown.IsCommandOrControlPressed() && eventKeyDown.AltPressed) {
ToggleC7Graphics();
}
if (eventKeyDown.Keycode == Godot.Key.F1) {
EmitSignal(SignalName.ShowSpecificAdvisor, "F1");
}
Expand Down Expand Up @@ -687,11 +683,6 @@ private void ToggleGridCoordinates() {
});
}

private void ToggleC7Graphics() {
Global.ToggleModernGraphics();
InitializeMapView();
}

private void HandleMagnifyGesture(InputEventMagnifyGesture magnifyGesture) {
double newScale = mapView.cameraZoom * magnifyGesture.Factor;

Expand Down
15 changes: 4 additions & 11 deletions C7/GamePaths.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,13 @@ public static string BaseDir {
}
}

// This is the 'static map' used in lieu of terrain generation
public static GameModeConfig GameMode {
public static GameMode.Config GameMode {
get => C7Engine.C7Settings.UseStandaloneMode() ? standalone : basic;
}

public static GameModeConfig basic = new("base-ruleset.json");
public static GameModeConfig standalone = new("base-ruleset.json", ["standalone.lua"]);

public static string LuaRulesDir => Path.Combine(BaseDir, "Lua/rules/");
public static string TextureConfigsDir => Path.Combine(BaseDir, "Lua/texture_configs/");
public static string GameModesDir => Path.Combine(BaseDir, "Lua/game_modes/");

public const string ModernGraphicsConfig = "c7.lua";
public const string ClassicGraphicsConfig = "civ3.lua";
public static string GameModesDir => Path.Combine(BaseDir, "Lua");
public static GameMode.Config basic = new("civ3");
public static GameMode.Config standalone = new("civ3", ["standalone"]);

// For now this needs to get passed to QueryCiv3 when importing.
public static string DefaultBicPath { get => Util.GetCiv3Path() + "/Conquests/conquests.biq"; }
Expand Down
44 changes: 33 additions & 11 deletions C7/GlobalSingleton.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
using Godot;
using C7Engine;
using C7GameData.Save;
using C7Engine.Lua;

/****
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 {
public GameMode GameMode;

// Will have main menu file picker set this and Game.cs pass it to C7Engine.createGame
// which then should blank it again to prevent reloading same if going back to main menu
// and back to game
Expand All @@ -16,27 +19,46 @@ public partial class GlobalSingleton : Node {
// Generated game data used when starting a new game
public SaveGame SaveGame;

public bool ModernGraphicsActive { get; private set; }
// The characteristics of the world to generate. This exists in the singleton
// to allow the world setup screen to pass the information to the player
// setup screen, which is what actually kicks off the world generation.
public WorldCharacteristics WorldCharacteristics;

public GlobalSingleton() {
if (C7Settings.UseStandaloneMode()) {
ToggleModernGraphics();
ActivateGameMode(GamePaths.standalone);
} else {
ActivateGameMode(GamePaths.basic);
}
}

// The characteristics of the world to generate. This exists in the singleton
// to allow the world setup screen to pass the information to the player
// setup screen, which is what actually kicks off the world generation.
public WorldCharacteristics WorldCharacteristics;

public void ResetLoadGameFields() {
LoadGamePath = null;
SaveGame = null;
}

public void ToggleModernGraphics() {
string newConfig = ModernGraphicsActive ? GamePaths.ClassicGraphicsConfig : GamePaths.ModernGraphicsConfig;
TextureLoader.SetConfig(GamePaths.TextureConfigsDir, newConfig);
ModernGraphicsActive = !ModernGraphicsActive;
public void ActivateGameMode(GameMode.Config config) {
// Ensure we clear out our image caches, as scenarios and games will
// use the same filenames but have different content for them.
Util.ClearCaches();

GameMode = GameMode.Load(GamePaths.GameModesDir, config);

var (script, textureConfig) = GameMode.textures;
TextureLoader.SetConfig(script, textureConfig);

if (config.addonPaths.Contains("standalone")) {
C7Settings.SetValue("locations", "useStandaloneMode", "true");
} else {
C7Settings.SetValue("locations", "useStandaloneMode", "false");
}

C7Settings.SaveSettings();
}

public void ToggleStandaloneMode() {
GameMode.Config newConfig = C7Settings.UseStandaloneMode() ? GamePaths.basic : GamePaths.standalone;

ActivateGameMode(newConfig);
}
}
12 changes: 12 additions & 0 deletions C7/Lua/civ3/behaviors.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
return {
buildings = require "behaviors.buildings",

--[[
terraforms module provides rules for worker actions (e.g., clearing forest or mining),
while terrain_improvements describes improvements placed on a map (e.g., mine, irrigation, railroad)
--]]
terraforms = require "behaviors.terraforms",
terrain_improvements = require "behaviors.terrain_improvements",
inflows = require "behaviors.inflows",
gameplay = require "behaviors.gameplay",
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
32 changes: 16 additions & 16 deletions C7/Lua/texture_configs/civ3.lua → C7/Lua/civ3/textures.lua
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ textures.ui = {
},
}

textures.terrain = require "civ3.terrain"
textures.terrain = require "textures.terrain"

textures.resources = require "civ3.resources"
textures.resources = require "textures.resources"

textures.credits = {
background = CREDITS .. "credits_background.pcx",
Expand Down Expand Up @@ -336,8 +336,8 @@ textures.palace = {
background = PALACE .. "bkgr.pcx",
}

textures.world_setup = require "civ3.world_setup"
textures.player_setup = require "civ3.player_setup"
textures.world_setup = require "textures.world_setup"
textures.player_setup = require "textures.player_setup"

textures.diplomacy = {
deal = "Art/Diplomacy/counter.pcx",
Expand Down Expand Up @@ -448,17 +448,17 @@ textures.animations = {
},
}

textures.popheads = require "civ3.popheads"
textures.cities = require "civ3.cities"
textures.advisor_heads = require "civ3.advisor_heads"
textures.ui.unit_control = require "civ3.unit_control"
textures.terrain_improvements = require "civ3.terrain_improvements"
textures.civ_colors = require "civ3.civ_colors"
textures.unit_icons = require "civ3.unit_icons"
textures.building_icons = require "civ3.building_icons"
textures.tech_icons = require "civ3.tech_icons"
textures.tech_boxes = require "civ3.tech_boxes"
textures.leader_heads = require "civ3.leader_heads"
textures.borders = require "civ3.borders"
textures.popheads = require "textures.popheads"
textures.cities = require "textures.cities"
textures.advisor_heads = require "textures.advisor_heads"
textures.ui.unit_control = require "textures.unit_control"
textures.terrain_improvements = require "textures.terrain_improvements"
textures.civ_colors = require "textures.civ_colors"
textures.unit_icons = require "textures.unit_icons"
textures.building_icons = require "textures.building_icons"
textures.tech_icons = require "textures.tech_icons"
textures.tech_boxes = require "textures.tech_boxes"
textures.leader_heads = require "textures.leader_heads"
textures.borders = require "textures.borders"

return textures
File renamed without changes.
12 changes: 0 additions & 12 deletions C7/Lua/rules/civ3.lua

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ local unit_replacement_art_map = {
--[[
This function defines the standalone addon to the base ruleset.

This function takes the initial save data from `base-ruleset.json` and
This function takes the initial save data from `civ3/ruleset.json` and
removes the units for which we don't have graphics replacements.

On the C# side, this function is called as part of addon loading logic
Expand Down
Loading