-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
executable file
·145 lines (122 loc) · 4.59 KB
/
Copy pathProgram.cs
File metadata and controls
executable file
·145 lines (122 loc) · 4.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
using IsometricMapViewer;
using System;
// Check for command-line export mode
if (args.Length > 0 && args[0] == "--export")
{
if (args.Length < 2)
{
Console.WriteLine("Usage: dotnet run -- --export <mapname> [output-path]");
Console.WriteLine("Example: dotnet run -- --export arefarm /home/leduardo/maps");
return;
}
string mapName = args[1];
string outputPath = args.Length > 2 ? args[2] : "/home/leduardo/exported-maps";
ExportMapCLI(mapName, outputPath);
return;
}
// HelbreathAtlasPacker export mode:
// dotnet run -- --atlas <format> <mapname> [output-root]
// formats: package | rpg | godot | tiled | map-shot | master | olympia | all
if (args.Length > 0 && args[0] == "--atlas")
{
if (args.Length < 3)
{
Console.WriteLine("Usage: dotnet run -- --atlas <format> <mapname> [output-root]");
Console.WriteLine("Formats: package | rpg | godot | tiled | map-shot | master | olympia | all");
return;
}
string format = args[1];
string mapName = args[2];
string outputRoot = args.Length > 3 ? args[3] : "resources/exported";
RunAtlasExport(format, mapName, outputRoot);
return;
}
// Headless smoke test: load every PAK-backed sprite (no visible window).
if (args.Length > 0 && args[0] == "--verify-sprites")
{
Raylib_cs.Raylib.SetConfigFlags(Raylib_cs.ConfigFlags.HiddenWindow);
Raylib_cs.Raylib.InitWindow(320, 240, "verify-sprites");
var loader = new IsometricMapViewer.Loaders.SpriteLoader();
loader.LoadSprites();
int total = 0, ground = 0, objects = 0, empty = 0;
foreach (var sprite in loader.GetAllSprites())
{
total++;
if (sprite.Texture.Id == 0) empty++;
else if ((sprite.Index >= 50 && sprite.Index <= 69) ||
(sprite.Index >= 100 && sprite.Index <= 145) ||
(sprite.Index >= 200 && sprite.Index <= 248)) objects++;
else if (sprite.Index < 150 || sprite.Index > 195) ground++;
}
Console.WriteLine($"sprites={total} ground={ground} objects={objects} no-texture={empty}");
loader.Dispose();
Raylib_cs.Raylib.CloseWindow();
return;
}
// GUI mode
var app = new ExporterApp();
app.Run();
static void RunAtlasExport(string format, string mapName, string outputRoot)
{
var exporter = new AtlasPackerExporter(
ResourcePaths.Paks,
ResourcePaths.Maps,
outputRoot);
try
{
string result = format.ToLowerInvariant() switch
{
"package" => exporter.ExportPackage(mapName),
"rpg" => exporter.ExportRpg(mapName),
"godot" => exporter.ExportGodot(mapName),
"tiled" => exporter.ExportTiled(mapName),
"map-shot" or "mapshot" => exporter.ExportMapShot(mapName),
"master" => exporter.ExportMasterTiles(),
"olympia" => exporter.ExportOlympia(mapName),
"all" => RunAtlasExportAll(exporter, mapName),
_ => throw new ArgumentException($"Unknown format '{format}'")
};
Console.WriteLine($"✓ {format} export complete: {result}");
}
catch (Exception ex)
{
Console.WriteLine($"Export failed: {ex.Message}");
Console.WriteLine(ex.StackTrace);
}
}
static string RunAtlasExportAll(AtlasPackerExporter exporter, string mapName)
{
exporter.ExportAll(mapName);
return System.IO.Path.Combine(exporter.OutputRoot, mapName);
}
static void ExportMapCLI(string mapName, string outputPath)
{
Console.WriteLine($"Exporting map '{mapName}' for BudgetDungeon...");
try
{
var mapPath = System.IO.Path.Combine(ResourcePaths.Maps, $"{mapName}.amd");
if (!System.IO.File.Exists(mapPath))
{
Console.WriteLine($"Error: Map file not found: {mapPath}");
return;
}
var map = new Map();
if (!map.Load(mapPath))
{
Console.WriteLine($"Error: Failed to load map: {mapPath}");
return;
}
Console.WriteLine($"✓ Loaded map: {map.Width}x{map.Height} tiles");
var exporter = new BudgetDungeonExporter(null, map);
var mapFolder = System.IO.Path.Combine(outputPath, mapName);
System.IO.Directory.CreateDirectory(mapFolder);
var jsonPath = System.IO.Path.Combine(mapFolder, $"{mapName}.json");
exporter.ExportJsonOnly(jsonPath, mapName);
Console.WriteLine($"✓ Exported map data to: {jsonPath}");
}
catch (Exception ex)
{
Console.WriteLine($"Error during export: {ex.Message}");
Console.WriteLine($"Stack trace: {ex.StackTrace}");
}
}