Skip to content

Commit 33a0ba1

Browse files
committed
Fix some hardcoded asset paths
1 parent 3e298d1 commit 33a0ba1

File tree

3 files changed

+58
-3
lines changed

3 files changed

+58
-3
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using Common;
2+
using System;
3+
using static System.Compiler;
4+
5+
namespace Nanoforge.Misc.Generators
6+
{
7+
public class WorkspaceGenerator : Generator
8+
{
9+
public override System.String Name => "New workspace info";
10+
11+
public override void InitUI()
12+
{
13+
AddEdit("Name", "Class name", "");
14+
}
15+
16+
public override void Generate(String outFileName, String outText, ref Flags generateFlags)
17+
{
18+
generateFlags |= .AllowRegenerate; //This class should always regenerate so it has up to date workspace paths
19+
20+
//Output file
21+
var name = mParams["Name"];
22+
if (name.EndsWith(".bf", .OrdinalIgnoreCase))
23+
name.RemoveFromEnd(3);
24+
outFileName.Append(name);
25+
26+
//Set file contents
27+
outText.AppendF(
28+
$"""
29+
using System;
30+
31+
namespace {Namespace}
32+
{{
33+
public static class {name}
34+
{{
35+
public static StringView Directory = @"{this.WorkspaceDir}";
36+
public static StringView Name = @"{this.WorkspaceName}";
37+
}}
38+
}}
39+
""");
40+
}
41+
}
42+
}

src/Program.bf

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,10 @@ namespace Nanoforge
1313
{
1414
public static void Main(String[] args)
1515
{
16-
//TODO: Fix needing to manually set this. Should auto set using build system
1716
#if DEBUG
18-
StringView assetsBasePath = "C:/Users/lukem/source/repos/Nanoforge/assets/";
17+
StringView assetsBasePath = scope $@"{Workspace.Directory}\assets\";
1918
#else
20-
StringView assetsBasePath = "./assets/";
19+
StringView assetsBasePath = @".\assets\";
2120
#endif
2221

2322
//Initialize utility for determining origin string of hashes used in game files

src/Workspace.bf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Generator=Nanoforge:Nanoforge.Misc.Generators.WorkspaceGenerator
2+
// Name=Workspace
3+
// GenHash=507BD6D2A1411B5EF920C5DD8F3E3005
4+
5+
using System;
6+
7+
namespace Nanoforge
8+
{
9+
public static class Workspace
10+
{
11+
public static StringView Directory = @"C:\Users\lukem\source\repos\Nanoforge";
12+
public static StringView Name = @"Nanoforge";
13+
}
14+
}

0 commit comments

Comments
 (0)