diff --git a/ShiftOS.WinForms/Applications/ExperienceShifter.Designer.cs b/ShiftOS.WinForms/Applications/ExperienceShifter.Designer.cs deleted file mode 100644 index 02cb01b..0000000 --- a/ShiftOS.WinForms/Applications/ExperienceShifter.Designer.cs +++ /dev/null @@ -1,217 +0,0 @@ -namespace ShiftOS.WinForms.Applications -{ - partial class ExperienceShifter - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Component Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.menuStrip1 = new System.Windows.Forms.MenuStrip(); - this.desktopToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.appLauncherToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.pnldesktop = new System.Windows.Forms.Panel(); - this.lbdesktops = new System.Windows.Forms.ListBox(); - this.gpdesktopsettings = new System.Windows.Forms.GroupBox(); - this.label2 = new System.Windows.Forms.Label(); - this.pnlapplauncher = new System.Windows.Forms.Panel(); - this.lblaunchers = new System.Windows.Forms.ListBox(); - this.gpalsettings = new System.Windows.Forms.GroupBox(); - this.label1 = new System.Windows.Forms.Label(); - this.menuStrip2 = new System.Windows.Forms.MenuStrip(); - this.addToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.menuStrip1.SuspendLayout(); - this.pnldesktop.SuspendLayout(); - this.pnlapplauncher.SuspendLayout(); - this.menuStrip2.SuspendLayout(); - this.SuspendLayout(); - // - // menuStrip1 - // - this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.desktopToolStripMenuItem, - this.appLauncherToolStripMenuItem}); - this.menuStrip1.Location = new System.Drawing.Point(0, 0); - this.menuStrip1.Name = "menuStrip1"; - this.menuStrip1.Size = new System.Drawing.Size(582, 24); - this.menuStrip1.TabIndex = 0; - this.menuStrip1.Text = "menuStrip1"; - // - // desktopToolStripMenuItem - // - this.desktopToolStripMenuItem.Name = "desktopToolStripMenuItem"; - this.desktopToolStripMenuItem.Size = new System.Drawing.Size(62, 20); - this.desktopToolStripMenuItem.Text = "Desktop"; - this.desktopToolStripMenuItem.Click += new System.EventHandler(this.desktopToolStripMenuItem_Click); - // - // appLauncherToolStripMenuItem - // - this.appLauncherToolStripMenuItem.Name = "appLauncherToolStripMenuItem"; - this.appLauncherToolStripMenuItem.Size = new System.Drawing.Size(93, 20); - this.appLauncherToolStripMenuItem.Text = "App Launcher"; - this.appLauncherToolStripMenuItem.Click += new System.EventHandler(this.appLauncherToolStripMenuItem_Click); - // - // pnldesktop - // - this.pnldesktop.Controls.Add(this.menuStrip2); - this.pnldesktop.Controls.Add(this.lbdesktops); - this.pnldesktop.Controls.Add(this.gpdesktopsettings); - this.pnldesktop.Controls.Add(this.label2); - this.pnldesktop.Dock = System.Windows.Forms.DockStyle.Fill; - this.pnldesktop.Location = new System.Drawing.Point(0, 24); - this.pnldesktop.Name = "pnldesktop"; - this.pnldesktop.Size = new System.Drawing.Size(582, 407); - this.pnldesktop.TabIndex = 1; - // - // lbdesktops - // - this.lbdesktops.Dock = System.Windows.Forms.DockStyle.Fill; - this.lbdesktops.FormattingEnabled = true; - this.lbdesktops.Location = new System.Drawing.Point(0, 23); - this.lbdesktops.Name = "lbdesktops"; - this.lbdesktops.Size = new System.Drawing.Size(582, 239); - this.lbdesktops.TabIndex = 0; - this.lbdesktops.SelectedIndexChanged += new System.EventHandler(this.lbdesktops_SelectedIndexChanged); - // - // gpdesktopsettings - // - this.gpdesktopsettings.Dock = System.Windows.Forms.DockStyle.Bottom; - this.gpdesktopsettings.Location = new System.Drawing.Point(0, 262); - this.gpdesktopsettings.Name = "gpdesktopsettings"; - this.gpdesktopsettings.Size = new System.Drawing.Size(582, 145); - this.gpdesktopsettings.TabIndex = 2; - this.gpdesktopsettings.TabStop = false; - this.gpdesktopsettings.Text = "Settings for this environment"; - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Dock = System.Windows.Forms.DockStyle.Top; - this.label2.Location = new System.Drawing.Point(0, 0); - this.label2.Name = "label2"; - this.label2.Padding = new System.Windows.Forms.Padding(5); - this.label2.Size = new System.Drawing.Size(57, 23); - this.label2.TabIndex = 1; - this.label2.Tag = "header2"; - this.label2.Text = "Desktop"; - // - // pnlapplauncher - // - this.pnlapplauncher.Controls.Add(this.lblaunchers); - this.pnlapplauncher.Controls.Add(this.gpalsettings); - this.pnlapplauncher.Controls.Add(this.label1); - this.pnlapplauncher.Dock = System.Windows.Forms.DockStyle.Fill; - this.pnlapplauncher.Location = new System.Drawing.Point(0, 24); - this.pnlapplauncher.Name = "pnlapplauncher"; - this.pnlapplauncher.Size = new System.Drawing.Size(582, 407); - this.pnlapplauncher.TabIndex = 0; - // - // lblaunchers - // - this.lblaunchers.Dock = System.Windows.Forms.DockStyle.Fill; - this.lblaunchers.FormattingEnabled = true; - this.lblaunchers.Location = new System.Drawing.Point(0, 23); - this.lblaunchers.Name = "lblaunchers"; - this.lblaunchers.Size = new System.Drawing.Size(582, 239); - this.lblaunchers.TabIndex = 4; - // - // gpalsettings - // - this.gpalsettings.Dock = System.Windows.Forms.DockStyle.Bottom; - this.gpalsettings.Location = new System.Drawing.Point(0, 262); - this.gpalsettings.Name = "gpalsettings"; - this.gpalsettings.Size = new System.Drawing.Size(582, 145); - this.gpalsettings.TabIndex = 3; - this.gpalsettings.TabStop = false; - this.gpalsettings.Text = "Settings for this environment"; - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Dock = System.Windows.Forms.DockStyle.Top; - this.label1.Location = new System.Drawing.Point(0, 0); - this.label1.Name = "label1"; - this.label1.Padding = new System.Windows.Forms.Padding(5); - this.label1.Size = new System.Drawing.Size(84, 23); - this.label1.TabIndex = 0; - this.label1.Tag = "header2"; - this.label1.Text = "App Launcher"; - // - // menuStrip2 - // - this.menuStrip2.Dock = System.Windows.Forms.DockStyle.Bottom; - this.menuStrip2.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.addToolStripMenuItem}); - this.menuStrip2.Location = new System.Drawing.Point(0, 238); - this.menuStrip2.Name = "menuStrip2"; - this.menuStrip2.Size = new System.Drawing.Size(582, 24); - this.menuStrip2.TabIndex = 0; - this.menuStrip2.Text = "menuStrip2"; - // - // addToolStripMenuItem - // - this.addToolStripMenuItem.Name = "addToolStripMenuItem"; - this.addToolStripMenuItem.Size = new System.Drawing.Size(41, 20); - this.addToolStripMenuItem.Text = "Add"; - this.addToolStripMenuItem.Click += new System.EventHandler(this.addToolStripMenuItem_Click); - // - // ExperienceShifter - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Controls.Add(this.pnldesktop); - this.Controls.Add(this.pnlapplauncher); - this.Controls.Add(this.menuStrip1); - this.Name = "ExperienceShifter"; - this.Size = new System.Drawing.Size(582, 431); - this.menuStrip1.ResumeLayout(false); - this.menuStrip1.PerformLayout(); - this.pnldesktop.ResumeLayout(false); - this.pnldesktop.PerformLayout(); - this.pnlapplauncher.ResumeLayout(false); - this.pnlapplauncher.PerformLayout(); - this.menuStrip2.ResumeLayout(false); - this.menuStrip2.PerformLayout(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.MenuStrip menuStrip1; - private System.Windows.Forms.ToolStripMenuItem desktopToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem appLauncherToolStripMenuItem; - private System.Windows.Forms.Panel pnldesktop; - private System.Windows.Forms.Label label2; - private System.Windows.Forms.Panel pnlapplauncher; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.GroupBox gpdesktopsettings; - private System.Windows.Forms.ListBox lbdesktops; - private System.Windows.Forms.ListBox lblaunchers; - private System.Windows.Forms.GroupBox gpalsettings; - private System.Windows.Forms.MenuStrip menuStrip2; - private System.Windows.Forms.ToolStripMenuItem addToolStripMenuItem; - } -} diff --git a/ShiftOS.WinForms/Applications/ExperienceShifter.cs b/ShiftOS.WinForms/Applications/ExperienceShifter.cs deleted file mode 100644 index 281b723..0000000 --- a/ShiftOS.WinForms/Applications/ExperienceShifter.cs +++ /dev/null @@ -1,136 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Drawing; -using System.Data; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; - -using ShiftOS.Engine; -using ShiftOS.Objects.ShiftFS; -using Newtonsoft.Json; - -namespace ShiftOS.WinForms.Applications -{ - [Launcher("Experience Shifter", false, "", "Customization")] - [DefaultTitle("Experience Shifter")] - [DefaultIcon("iconShifter")] - public partial class ExperienceShifter : UserControl, IShiftOSWindow - { - public ExperienceShifter() - { - InitializeComponent(); - } - - private string currentUI = "desktop"; - - public void SetupUI() - { - switch (currentUI) - { - case "desktop": - pnldesktop.BringToFront(); - PopulateDesktops(); - break; - case "applauncher": - pnlapplauncher.BringToFront(); - PopulateLaunchers(); - break; - } - } - - public void PopulateDesktops() - { - lbdesktops.Items.Clear(); - foreach(var desk in GetAllDesktops()) - { - lbdesktops.Items.Add(desk.DesktopName); - } - } - - public List GetAllDesktops() - { - List dekstops = new List(); - dekstops.Add(new WinformsDesktop()); - if (!Utils.FileExists(Paths.GetPath("conf.sft"))) - Utils.WriteAllText(Paths.GetPath("conf.sft"), JsonConvert.SerializeObject(new ShiftOSConfigFile(), Formatting.Indented)); - - foreach(var script in JsonConvert.DeserializeObject(Utils.ReadAllText(Paths.GetPath("conf.sft"))).Desktops) - { - if(Utils.FileExists(script)) - dekstops.Add(new LuaDesktop(script)); - } - return dekstops; - } - - public void PopulateLaunchers() - { - lblaunchers.Items.Clear(); - lbdesktops.Items.Add("ShiftOS App Launcher"); - } - - public void OnLoad() - { - SetupUI(); - } - - public void OnSkinLoad() - { - } - - public bool OnUnload() - { - return true; - } - - public void OnUpgrade() - { - } - - private void desktopToolStripMenuItem_Click(object sender, EventArgs e) - { - currentUI = "desktop"; - SetupUI(); - } - - private void appLauncherToolStripMenuItem_Click(object sender, EventArgs e) - { - currentUI = "applauncher"; - SetupUI(); - } - - private void addToolStripMenuItem_Click(object sender, EventArgs e) - { - FileSkimmerBackend.GetFile(new[] { ".lua" }, FileOpenerStyle.Open, new Action((script) => - { - ShiftOSConfigFile conf = new WinForms.ShiftOSConfigFile(); - if (Utils.FileExists(Paths.GetPath("conf.sft"))) - { - conf = JsonConvert.DeserializeObject(Utils.ReadAllText(Paths.GetPath("conf.sft"))); - } - conf.Desktops.Add(script); - Utils.WriteAllText(Paths.GetPath("conf.sft"), JsonConvert.SerializeObject(conf, Formatting.Indented)); - })); - } - - private void lbdesktops_SelectedIndexChanged(object sender, EventArgs e) - { - foreach(var desk in GetAllDesktops()) - { - try - { - if(desk.DesktopName == lbdesktops.SelectedItem.ToString()) - { - Desktop.Init(desk, true); - } - } - catch - { - - } - } - } - } -} diff --git a/ShiftOS.WinForms/Applications/ExperienceShifter.resx b/ShiftOS.WinForms/Applications/ExperienceShifter.resx deleted file mode 100644 index 2d404e0..0000000 --- a/ShiftOS.WinForms/Applications/ExperienceShifter.resx +++ /dev/null @@ -1,126 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - - - 132, 17 - - \ No newline at end of file diff --git a/ShiftOS.WinForms/ShiftOS.WinForms.csproj b/ShiftOS.WinForms/ShiftOS.WinForms.csproj index d2260cf..5f85330 100644 --- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj +++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj @@ -94,12 +94,6 @@ Downloader.cs - - UserControl - - - ExperienceShifter.cs - UserControl @@ -265,9 +259,6 @@ Downloader.cs - - ExperienceShifter.cs - FileDialog.cs diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs index ab04bc8..83de1fb 100644 --- a/ShiftOS.WinForms/WinformsDesktop.cs +++ b/ShiftOS.WinForms/WinformsDesktop.cs @@ -36,6 +36,7 @@ using static ShiftOS.Engine.SkinEngine; using ShiftOS.WinForms.Tools; using ShiftOS.WinForms.Applications; using Newtonsoft.Json; +using ShiftOS.Engine.Scripting; /// /// Winforms desktop. @@ -122,7 +123,6 @@ namespace ShiftOS.WinForms time.Start(); this.DoubleBuffered = true; - } /// @@ -131,6 +131,7 @@ namespace ShiftOS.WinForms /// The panel buttons. public void PopulatePanelButtons() { + panelbuttonholder.Controls.Clear(); if (Shiftorium.IsInitiated == true) { @@ -200,6 +201,8 @@ namespace ShiftOS.WinForms } } } + + LuaInterpreter.RaiseEvent("on_panelbutton_populate", this); } /// @@ -273,6 +276,8 @@ namespace ShiftOS.WinForms } } + LuaInterpreter.RaiseEvent("on_desktop_skin", this); + PopulatePanelButtons(); } @@ -370,6 +375,8 @@ namespace ShiftOS.WinForms } } + + LuaInterpreter.RaiseEvent("on_al_populate", items); } @@ -385,13 +392,21 @@ namespace ShiftOS.WinForms SaveSystem.Begin(); SetupDesktop(); + + SaveSystem.GameReady += () => + { + this.Invoke(new Action(() => + { + LuaInterpreter.RaiseEvent("on_desktop_load", this); + })); + }; } - /// - /// Shows the window. - /// - /// The window. - /// Border. + /// + /// Shows the window. + /// + /// The window. + /// Border. public void ShowWindow(IWindowBorder border) { var brdr = border as Form; @@ -495,4 +510,13 @@ namespace ShiftOS.WinForms return this.Size; } } + + [ShiftOS.Engine.Scripting.Exposed("desktop")] + public class DesktopFunctions + { + public dynamic getWindow() + { + return Desktop.CurrentDesktop; + } + } } diff --git a/ShiftOS_TheReturn/Desktop.cs b/ShiftOS_TheReturn/Desktop.cs index 86d2099..256ab09 100644 --- a/ShiftOS_TheReturn/Desktop.cs +++ b/ShiftOS_TheReturn/Desktop.cs @@ -100,6 +100,14 @@ namespace ShiftOS.Engine } } + public static IDesktop CurrentDesktop + { + get + { + return _desktop; + } + } + public static void Init(IDesktop desk, bool show = false) { IDesktop deskToClose = null; diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index 90504bb..ec3c3b3 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -172,6 +172,10 @@ namespace ShiftOS.Engine TerminalBackend.InStory = false; TerminalBackend.PrefixEnabled = true; Shiftorium.LogOrphanedUpgrades = true; + Desktop.InvokeOnWorkerThread(new Action(() => + { + ShiftOS.Engine.Scripting.LuaInterpreter.RunSft(Paths.GetPath("kernel.sft")); + })); Desktop.InvokeOnWorkerThread(new Action(() => Desktop.PopulateAppLauncher())); if (CurrentSave.StoryPosition == 1) { diff --git a/ShiftOS_TheReturn/Scripting.cs b/ShiftOS_TheReturn/Scripting.cs index 7215fbf..eca94fc 100644 --- a/ShiftOS_TheReturn/Scripting.cs +++ b/ShiftOS_TheReturn/Scripting.cs @@ -43,6 +43,24 @@ namespace ShiftOS.Engine.Scripting public dynamic Lua = new DynamicLua.DynamicLua(); public bool Running = true; + public static void RunSft(string sft) + { + if (Utils.FileExists(sft)) + { + try + { + string b64 = Utils.ReadAllText(sft); + byte[] bytes = Convert.FromBase64String(b64); + string lua = Encoding.UTF8.GetString(bytes); + new LuaInterpreter().Execute(lua); + } + catch + { + Infobox.Show("Invalid binary.", "This file is not a valid ShiftOS binary executable."); + } + } + } + public LuaInterpreter() { Lua(@"function totable(clrlist)