This repository has been archived by the owner on Jan 4, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 98
/
LuaService.Disks.cs
50 lines (39 loc) · 1.86 KB
/
LuaService.Disks.cs
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
using System;
using System.IO;
using MoonSharp.Interpreter;
using PixelVision8.Workspace;
namespace PixelVision8.Runner
{
public partial class LuaService
{
[RegisterLuaService]
public void RegisterDisks(Script luaScript)
{
// if (runner.mode == RunnerMode.Loading)
// {
luaScript.Globals["DiskPaths"] = new Func<WorkspacePath[]>(() => runner.workspaceServicePlus.Disks);
luaScript.Globals["SharedLibPaths"] = new Func<WorkspacePath[]>(() => runner.workspaceServicePlus.SharedLibDirectories().ToArray());
luaScript.Globals["EjectDisk"] = new Action<string>(runner.EjectDisk);
luaScript.Globals["RebuildWorkspace"] = new Action(runner.workspaceServicePlus.RebuildWorkspace);
luaScript.Globals["MountDisk"] = new Action<WorkspacePath>(path =>
{
var segments = path.GetDirectorySegments();
var systemPath = Path.PathSeparator.ToString();
if (segments[0] == "Disk")
{
}
else if (segments[0] == "Workspace")
{
// TODO the workspace could have a different name so we should check the bios
systemPath = Path.Combine(runner.documentsPath, segments[0]);
}
for (var i = 1; i < segments.Length; i++) systemPath = Path.Combine(systemPath, segments[i]);
systemPath = Path.Combine(systemPath,
path.IsDirectory ? Path.PathSeparator.ToString() : path.EntityName);
// Console.WriteLine("Mount Disk From " + systemPath);
runner.MountDisk(systemPath);
});
// }
}
}
}