The reason it’s svg is because I have a battlemap generator that use procedural generation to build a ship layout. It has hull definitions and rooms that contain objects and generates different layouts randomly and it expects the rooms to be in svg format.
These maps are then used in a web app which also expects the source to be svg.
However it’s all line art in black and white.
I now have nice objects to populate the rooms with as well as new walls and new hulls etc all done in color. Now I need an easy way to generate the maps for the rooms so that I can use them to generate much nicer looking maps and automate as much of the process as possible and tracking rooms as they get finished.
I decided to use Godot because it has a decent UI toolkit that is cross platform and intrinsic support for displaying images for creating a preview of the map.
Currently it works for my use case, but I was thinking if I can make it generic enough it might be useful to other people who need to combine svgs, like say you have to layout multiple plots and or graphs on a page.
Edit Update:
So I came up with something that works. I included the svg files as content in the C# project, and set them to be copied to the output folder. However when run in the editor or when debugging this content is directly in the same folder relative to the exe because the editor runs the project. When exported this content ends up in a folder starting with data, in this case the folder is called data_RoomMapper_linuxbsd_x86_64.
So I had to come up with a check to see if the project was in editor or exported:
var path = ProjectSettings.GlobalizePath("res://");
if (path == String.Empty)
{
path = OS.GetExecutablePath().GetBaseDir();
string searchPattern = "data*";
string[] matchingDirectories = Directory.GetDirectories(path, searchPattern, SearchOption.TopDirectoryOnly);
if (matchingDirectories.Any())
{
GD.Print("A folder starting with 'data' exists.");
// Optionally, get the first matching folder name
string firstFolderName = Path.GetFileName(matchingDirectories.First());
GD.Print($"First matching folder found: {firstFolderName}");
path = Path.Join(path, firstFolderName) + "/";
}
else
{
GD.Print("No folder starting with 'data' was found.");
}
}
GD.Print(path);
resourceBasePath = path;
Then I just access the files with FileAccess:
setPath();
string relativePath = "packs/S7d31msP/textures/objects/bridge/bridge_electronics.svg";
bool found = FileAccess.FileExists(resourceBasePath + relativePath);
if (found)
{
GD.Print("FOUND");
}
Everything is still duplicated but at least it I only have one set of svgs and they can all be maintained within the project.
Which leads me to a question, my code to find the data folder depends on the data folder to start with data, is this the case when exported for a different platform? Or even better is there a built in variable for getting this folder?
Thanks for all the help and suggestions they are appreciated.