Kill experience shifter.

Now all we need is a Lua->SFT compiler (not that hard) and then we can
generate 0:/system/kernel.sft and have whatever's in there run at
startup.
This commit is contained in:
Michael 2017-02-19 13:47:51 -05:00
parent b5a9b4caf2
commit 762bd11cdf
8 changed files with 60 additions and 494 deletions

View file

@ -1,217 +0,0 @@
namespace ShiftOS.WinForms.Applications
{
partial class ExperienceShifter
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
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;
}
}

View file

@ -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<IDesktop> GetAllDesktops()
{
List<IDesktop> dekstops = new List<IDesktop>();
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<ShiftOSConfigFile>(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<string>((script) =>
{
ShiftOSConfigFile conf = new WinForms.ShiftOSConfigFile();
if (Utils.FileExists(Paths.GetPath("conf.sft")))
{
conf = JsonConvert.DeserializeObject<ShiftOSConfigFile>(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
{
}
}
}
}
}

View file

@ -1,126 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="menuStrip2.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>132, 17</value>
</metadata>
</root>

View file

@ -94,12 +94,6 @@
<Compile Include="Applications\Downloader.Designer.cs">
<DependentUpon>Downloader.cs</DependentUpon>
</Compile>
<Compile Include="Applications\ExperienceShifter.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Applications\ExperienceShifter.Designer.cs">
<DependentUpon>ExperienceShifter.cs</DependentUpon>
</Compile>
<Compile Include="Applications\FileDialog.cs">
<SubType>UserControl</SubType>
</Compile>
@ -265,9 +259,6 @@
<EmbeddedResource Include="Applications\Downloader.resx">
<DependentUpon>Downloader.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Applications\ExperienceShifter.resx">
<DependentUpon>ExperienceShifter.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Applications\FileDialog.resx">
<DependentUpon>FileDialog.cs</DependentUpon>
</EmbeddedResource>

View file

@ -36,6 +36,7 @@ using static ShiftOS.Engine.SkinEngine;
using ShiftOS.WinForms.Tools;
using ShiftOS.WinForms.Applications;
using Newtonsoft.Json;
using ShiftOS.Engine.Scripting;
/// <summary>
/// Winforms desktop.
@ -122,7 +123,6 @@ namespace ShiftOS.WinForms
time.Start();
this.DoubleBuffered = true;
}
/// <summary>
@ -131,6 +131,7 @@ namespace ShiftOS.WinForms
/// <returns>The panel buttons.</returns>
public void PopulatePanelButtons()
{
panelbuttonholder.Controls.Clear();
if (Shiftorium.IsInitiated == true)
{
@ -200,6 +201,8 @@ namespace ShiftOS.WinForms
}
}
}
LuaInterpreter.RaiseEvent("on_panelbutton_populate", this);
}
/// <summary>
@ -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);
}));
};
}
/// <summary>
/// Shows the window.
/// </summary>
/// <returns>The window.</returns>
/// <param name="border">Border.</param>
/// <summary>
/// Shows the window.
/// </summary>
/// <returns>The window.</returns>
/// <param name="border">Border.</param>
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;
}
}
}

View file

@ -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;

View file

@ -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)
{

View file

@ -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)