-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNethackWrapper.cs
More file actions
108 lines (84 loc) · 2.83 KB
/
Copy pathNethackWrapper.cs
File metadata and controls
108 lines (84 loc) · 2.83 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
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection.Metadata.Ecma335;
using System.Security.Cryptography.X509Certificates;
using System.Text;
namespace MONKEYTOOLS;
public class NethackWrapper
{
public static void Run(string[] args)
{
LaunchNethack();
}
static void LaunchNethack()
{
//Little hacky but grab root or exe location when built
static string GetNetHackDir()
{
#if DEBUG
return Path.GetFullPath(
Path.Combine(AppContext.BaseDirectory, "..", "..", "..", "Nethack")
);
#else
return Path.Combine(AppContext.BaseDirectory, "Nethack")
#endif
}
string cmdexe = Path.Combine(GetNetHackDir(), "Nethack.exe");
string guiexe = Path.Combine(GetNetHackDir(), "NetHackW.exe");
string sysconf = Path.Combine(GetNetHackDir(), "sysconf.txt");
if (!File.Exists(cmdexe))
{
Console.WriteLine("🚬🐒 No Nethack CMD Exists RIP");
return;
}
if (!File.Exists(guiexe))
{
Console.WriteLine("🚬🐒 No Nethack GUi Exists RIP");
return;
}
if (!File.Exists(sysconf))
{
File.WriteAllText(sysconf, "portable_device_paths = 1");
Console.WriteLine("🐒 Wrote sysconf for ya");
}
if (File.Exists(sysconf))
{
File.ReadAllText(sysconf).Contains("portable_device_paths = 1");
Console.WriteLine("🐒 sysconf smells correct");
}
string content = File.ReadAllText(sysconf);
if (!content.Contains("portable_device_paths = 1"))
{
File.AppendAllText(sysconf, "portable_device_paths");
Console.WriteLine("🐒 Fixed sysconf");
}
Console.WriteLine("🚬🐒Nethack Loaded, sorry about your productivity dude");
Console.WriteLine("1) Nethack CMD line");
Console.WriteLine("2) Netack GUI");
Console.WriteLine("type 'exit' to quit");
Console.Write(">");
string input = Console.ReadLine() ?? "";
if (string.IsNullOrWhiteSpace(input))
{
if (input.ToLower() == "exit") ;
}
else if (input.ToLower() == "1")
Process.Start(new ProcessStartInfo
{
FileName = cmdexe,
WorkingDirectory = GetNetHackDir(),
//Arguments = "--cmd",
UseShellExecute = true
});
else if (input.ToLower() == "2");
Process.Start(new ProcessStartInfo
{
FileName = guiexe,
WorkingDirectory = GetNetHackDir(),
//Arguments = "--gui",
UseShellExecute = true
});
}
}