diff options
| author | Michael <[email protected]> | 2017-02-18 10:37:11 -0500 |
|---|---|---|
| committer | Michael <[email protected]> | 2017-02-18 10:37:11 -0500 |
| commit | 9b8d5861a954610713ae66a53d2ac067991d9b68 (patch) | |
| tree | e550f758e52ec8ca12357d91c9fa13907e70c4f3 /ShiftOS_TheReturn | |
| parent | 30823a0778614d0f9fd6f82b5d9eb03aab41280d (diff) | |
| download | shiftos_thereturn-9b8d5861a954610713ae66a53d2ac067991d9b68.tar.gz shiftos_thereturn-9b8d5861a954610713ae66a53d2ac067991d9b68.tar.bz2 shiftos_thereturn-9b8d5861a954610713ae66a53d2ac067991d9b68.zip | |
WHOA LUA STUFF :dancer:
Diffstat (limited to 'ShiftOS_TheReturn')
| -rw-r--r-- | ShiftOS_TheReturn/AudioManager.cs | 6 | ||||
| -rw-r--r-- | ShiftOS_TheReturn/Desktop.cs | 35 | ||||
| -rw-r--r-- | ShiftOS_TheReturn/Infobox.cs | 6 | ||||
| -rw-r--r-- | ShiftOS_TheReturn/Paths.cs | 3 | ||||
| -rw-r--r-- | ShiftOS_TheReturn/Scripting.cs | 32 |
5 files changed, 56 insertions, 26 deletions
diff --git a/ShiftOS_TheReturn/AudioManager.cs b/ShiftOS_TheReturn/AudioManager.cs index 1ea4575..db3ddc9 100644 --- a/ShiftOS_TheReturn/AudioManager.cs +++ b/ShiftOS_TheReturn/AudioManager.cs @@ -1,4 +1,6 @@ -using System; +#define NOSOUND + +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -18,6 +20,7 @@ namespace ShiftOS.Engine public static void Init(IAudioProvider _p) { +#if !NOSOUND _provider = _p; AppearanceManager.OnExit += () => { @@ -59,6 +62,7 @@ namespace ShiftOS.Engine }); t.IsBackground = true; t.Start(); +#endif } public static void SetVolume(float volume) diff --git a/ShiftOS_TheReturn/Desktop.cs b/ShiftOS_TheReturn/Desktop.cs index d30e3c3..86d2099 100644 --- a/ShiftOS_TheReturn/Desktop.cs +++ b/ShiftOS_TheReturn/Desktop.cs @@ -85,45 +85,30 @@ namespace ShiftOS.Engine void RestoreWindow(IWindowBorder brdr); void InvokeOnWorkerThread(Action act); Size GetSize(); + + void Show(); + void Close(); } public static class Desktop { private static IDesktop _desktop = null; - public static IDesktop[] GetAllDesktops() - { - List<IDesktop> desktops = new List<IDesktop>(); - foreach(var exe in System.IO.Directory.GetFiles(Environment.CurrentDirectory)) - { - if(exe.EndsWith(".exe") || exe.EndsWith(".dll")) - { - try - { - var asm = Assembly.LoadFile(exe); - foreach(var type in asm.GetTypes()) - { - if (type.GetInterfaces().Contains(typeof(IDesktop))) - { - desktops.Add(Activator.CreateInstance(type) as IDesktop); - } - } - } - catch { } - } - } - return desktops.ToArray(); - } - public static Size Size { get { return _desktop.GetSize(); } } - public static void Init(IDesktop desk) + public static void Init(IDesktop desk, bool show = false) { + IDesktop deskToClose = null; + if (_desktop != null) + deskToClose = _desktop; _desktop = desk; + if (show == true) + _desktop.Show(); + deskToClose?.Close(); } public static void MinimizeWindow(IWindowBorder brdr) diff --git a/ShiftOS_TheReturn/Infobox.cs b/ShiftOS_TheReturn/Infobox.cs index 8854b88..3e8fa30 100644 --- a/ShiftOS_TheReturn/Infobox.cs +++ b/ShiftOS_TheReturn/Infobox.cs @@ -57,16 +57,22 @@ namespace ShiftOS.Engine /// <param name="message">Infobox message</param> public static void Show(string title, string message) { + title = Localization.Parse(title); + message = Localization.Parse(message); _infobox.Open(title, message); } public static void PromptText(string title, string message, Action<string> callback) { + title = Localization.Parse(title); + message = Localization.Parse(message); _infobox.PromptText(title, message, callback); } public static void PromptYesNo(string title, string message, Action<bool> callback) { + title = Localization.Parse(title); + message = Localization.Parse(message); _infobox.PromptYesNo(title, message, callback); } diff --git a/ShiftOS_TheReturn/Paths.cs b/ShiftOS_TheReturn/Paths.cs index aeca13d..7408bef 100644 --- a/ShiftOS_TheReturn/Paths.cs +++ b/ShiftOS_TheReturn/Paths.cs @@ -60,6 +60,9 @@ namespace ShiftOS.Engine AddPath("data", "save.json"); AddPath("data", "user.dat"); AddPath("data", "skin"); + AddPath("system", "programs"); + AddPath("system", "kernel.sft"); + AddPath("system", "conf.sft"); AddPath("skin", "current"); AddPath("current", "skin.json"); AddPath("current", "images"); diff --git a/ShiftOS_TheReturn/Scripting.cs b/ShiftOS_TheReturn/Scripting.cs index e699939..c934fc6 100644 --- a/ShiftOS_TheReturn/Scripting.cs +++ b/ShiftOS_TheReturn/Scripting.cs @@ -45,6 +45,15 @@ namespace ShiftOS.Engine.Scripting public LuaInterpreter() { + Lua(@"function totable(clrlist) + local t = {} + local it = clrlist:GetEnumerator() + while it:MoveNext() do + t[#t+1] = it.Current + end + return t +end"); + SetupAPIs(); Application.ApplicationExit += (o, a) => { @@ -55,6 +64,14 @@ namespace ShiftOS.Engine.Scripting public void SetupAPIs() { + Lua.registerEvent = new Action<string, Action<object>>((eventName, callback) => + { + LuaEvent += (e, s) => + { + if(e == eventName) + callback?.Invoke(s); + }; + }); //This temporary proxy() method will be used by the API prober. Lua.proxy = new Func<string, dynamic>((objName) => { @@ -166,6 +183,21 @@ namespace ShiftOS.Engine.Scripting {e.Message}"); } } + + /// <summary> + /// Occurs when a Lua event is fired by C#. + /// </summary> + private static event Action<string, object> LuaEvent; + + /// <summary> + /// Raises a Lua event with the specified name and caller object. + /// </summary> + /// <param name="eventName">The name of the event. Scripts use this to check what type of event occurred.</param> + /// <param name="caller">The caller of the event. Scripts can use this to check if they should handle this event.</param> + public static void RaiseEvent(string eventName, object caller) + { + LuaEvent?.Invoke(eventName, caller); + } } [Exposed("net")] |
