b451f83174
Captures the pre-Godot-port state of the codebase. This is the rollback anchor for the Godot port (M0 of theriapolis-rpg-implementation-plan-godot-port.md). All Phase 0 through Phase 6.5 work is included; Phase 7 is in flight. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
38 lines
1.4 KiB
C#
38 lines
1.4 KiB
C#
using Theriapolis.Game;
|
|
|
|
// Resolve content directories relative to the executable.
|
|
// Distribution: Data/ and Gfx/ sit next to the exe (absolute path)
|
|
// Development: walk up from the exe to find Content/Data and Content/Gfx
|
|
string dataDir = ResolveContentDir("Data");
|
|
string gfxDir = ResolveContentDir("Gfx");
|
|
|
|
static string ResolveContentDir(string subdir)
|
|
{
|
|
// 1. "<subdir>" next to the executable — distribution layout
|
|
string local = Path.Combine(AppContext.BaseDirectory, subdir);
|
|
if (Directory.Exists(local)) return local;
|
|
|
|
// 2. Walk up from the exe to find Content/<subdir> — development layout.
|
|
// Trim the trailing separator first: on Windows AppContext.BaseDirectory ends
|
|
// with '\', and GetDirectoryName on a trailing-slash path strips the slash
|
|
// without ascending, wasting one iteration.
|
|
string? dir = AppContext.BaseDirectory.TrimEnd(
|
|
Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
|
|
for (int i = 0; i < 6; i++)
|
|
{
|
|
if (dir is null) break;
|
|
string candidate = Path.Combine(dir, "Content", subdir);
|
|
if (Directory.Exists(candidate)) return candidate;
|
|
dir = Path.GetDirectoryName(dir);
|
|
}
|
|
|
|
return local; // missing-file errors will surface from the consumer with the bad path
|
|
}
|
|
|
|
using var game = new Game1
|
|
{
|
|
ContentDataDirectory = dataDir,
|
|
ContentGfxDirectory = gfxDir,
|
|
};
|
|
game.Run();
|