File tree Expand file tree Collapse file tree 3 files changed +58
-3
lines changed Expand file tree Collapse file tree 3 files changed +58
-3
lines changed Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change @@ -13,11 +13,10 @@ namespace Nanoforge
13
13
{
14
14
public static void Main ( String [ ] args )
15
15
{
16
- //TODO: Fix needing to manually set this. Should auto set using build system
17
16
#if DEBUG
18
- StringView assetsBasePath = "C:/Users/lukem/source/repos/Nanoforge/ assets/ ";
17
+ StringView assetsBasePath = scope $ @"{Workspace.Directory}\ assets\ ";
19
18
#else
20
- StringView assetsBasePath = "./ assets/ ";
19
+ StringView assetsBasePath = @".\ assets\ ";
21
20
#endif
22
21
23
22
//Initialize utility for determining origin string of hashes used in game files
Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments