Lua app launcher items

This commit is contained in:
Michael 2017-02-02 14:31:39 -05:00
parent 3a41ba45e7
commit 44c1e66dd0
4 changed files with 32 additions and 2 deletions

View file

@ -12,7 +12,7 @@ using ShiftOS.Objects.ShiftFS;
namespace ShiftOS.Modding.VirtualMachine
{
[Launcher("ShiftOS Virtual Machine", false)]
[Launcher("ShiftOS Virtual Machine", false, null, "Programming")]
public partial class Form1 : UserControl, IShiftOSWindow
{
private byte[] memory = null; //program binary

View file

@ -263,7 +263,16 @@ namespace ShiftOS.WinForms
item.Text = kv.DisplayData.Name;
item.Click += (o, a) =>
{
Engine.AppearanceManager.SetupWindow(Activator.CreateInstance(kv.LaunchType) as IShiftOSWindow);
if (kv is LuaLauncherItem)
{
var interpreter = new Engine.Scripting.LuaInterpreter();
interpreter.ExecuteFile((kv as LuaLauncherItem).LaunchPath);
}
else
{
Engine.AppearanceManager.SetupWindow(Activator.CreateInstance(kv.LaunchType) as IShiftOSWindow);
}
};
if (sortedItems.ContainsKey(kv.DisplayData.Category))
{

View file

@ -30,6 +30,7 @@ using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Newtonsoft.Json;
using ShiftOS.Objects.ShiftFS;
namespace ShiftOS.Engine
{
@ -84,6 +85,15 @@ namespace ShiftOS.Engine
}
}
}
foreach(var file in Utils.GetFiles(Paths.GetPath("applauncher")))
{
if (file.EndsWith(".al"))
{
var item = JsonConvert.DeserializeObject<LuaLauncherItem>(Utils.ReadAllText(file));
win.Add(item);
}
}
return win;
}
@ -95,4 +105,14 @@ namespace ShiftOS.Engine
public Type LaunchType { get; internal set; }
}
public class LuaLauncherItem : LauncherItem
{
public LuaLauncherItem(string file)
{
LaunchPath = file;
}
public string LaunchPath { get; private set; }
}
}

View file

@ -56,6 +56,7 @@ namespace ShiftOS.Engine
AddPath("local", "deutsch.local");
AddPath("local", "verbose.local");
AddPath("system", "data");
AddPath("system", "applauncher");
AddPath("data", "save.json");
AddPath("data", "user.dat");
AddPath("data", "skin");