diff options
| author | Michael <[email protected]> | 2017-08-02 10:23:13 -0400 |
|---|---|---|
| committer | Michael <[email protected]> | 2017-08-02 10:23:13 -0400 |
| commit | 37cf129165916101ba665891d157c85ea9c37383 (patch) | |
| tree | bc184d6be19bdf1258faba51a1323bfeec676502 /ShiftOS.Frontend/Apps | |
| parent | 10d2c0bbaa2b5c933a37056c784d3de84fa82eaf (diff) | |
| download | shiftos_thereturn-37cf129165916101ba665891d157c85ea9c37383.tar.gz shiftos_thereturn-37cf129165916101ba665891d157c85ea9c37383.tar.bz2 shiftos_thereturn-37cf129165916101ba665891d157c85ea9c37383.zip | |
The first loot!
Diffstat (limited to 'ShiftOS.Frontend/Apps')
| -rw-r--r-- | ShiftOS.Frontend/Apps/FileSkimmer.cs | 6 | ||||
| -rw-r--r-- | ShiftOS.Frontend/Apps/Installer.cs | 131 |
2 files changed, 135 insertions, 2 deletions
diff --git a/ShiftOS.Frontend/Apps/FileSkimmer.cs b/ShiftOS.Frontend/Apps/FileSkimmer.cs index 58a9908..672446c 100644 --- a/ShiftOS.Frontend/Apps/FileSkimmer.cs +++ b/ShiftOS.Frontend/Apps/FileSkimmer.cs @@ -21,11 +21,12 @@ namespace ShiftOS.Frontend.Apps public void OnLoad() { - if(Hacking.CurrentHackable != null) + + if (Hacking.CurrentHackable != null) { if (Hacking.CurrentHackable.VectorsUnlocked.Contains(Objects.SystemType.FileServer)) { - if(Mounts.Count > 2) + if (Mounts.Count > 2) { Mounts.RemoveAt(2); } @@ -37,6 +38,7 @@ namespace ShiftOS.Frontend.Apps if(!FileExists("2:/" + loot.LootName)) { var bytes = Hacking.GetLootBytes(loot.PointTo); + WriteAllBytes($"2:/{loot.LootName}", bytes); } } } diff --git a/ShiftOS.Frontend/Apps/Installer.cs b/ShiftOS.Frontend/Apps/Installer.cs new file mode 100644 index 0000000..86045e1 --- /dev/null +++ b/ShiftOS.Frontend/Apps/Installer.cs @@ -0,0 +1,131 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ShiftOS.Engine; +using ShiftOS.Frontend.GUI; +using Newtonsoft.Json; +using static ShiftOS.Objects.ShiftFS.Utils; +using Microsoft.Xna.Framework; + +namespace ShiftOS.Frontend.Apps +{ + [DefaultTitle("Installer")] + [FileHandler("Setup file", ".stp", "")] + public class Installer : Control, IShiftOSWindow, IFileHandler + { + private SetupFile _setup = null; + private TextControl _header = null; + private TextControl _body = null; + private Button _cancel = null; + private Button _install = null; + + public Installer() + { + Width = 600; + Height = 400; + _header = new GUI.TextControl(); + _body = new GUI.TextControl(); + _cancel = new Button(); + _install = new Button(); + + _install.Text = "Install"; + _cancel.Text = "Close"; + + _install.AutoSize = true; + _cancel.AutoSize = true; + + AddControl(_header); + AddControl(_body); + AddControl(_install); + AddControl(_cancel); + + _install.Click += () => + { + Install(); + + }; + _cancel.Click += () => + { + AppearanceManager.Close(this); + }; + + } + + public void Install() + { + switch (_setup.SourceType) + { + case SetupSource.ShiftoriumUpgrade: + if (Shiftorium.UpgradeInstalled(_setup.Source)) + { + Engine.Infobox.Show("Upgrade installed.", "This upgrade has already been installed either through the Shiftorium or through another setup file."); + return; + } + Shiftorium.Buy(_setup.Source, 0); + Engine.Infobox.Show("Upgrade installed.", "The upgrade \"" + _setup.Source + "\" has been installed and is now ready to be used!"); + + break; + } + } + + + protected override void OnLayout(GameTime gameTime) + { + _header.X = 10; + _header.Y = 10; + _header.Font = SkinEngine.LoadedSkin.Header3Font; + _header.AutoSize = true; + + _body.X = 10; + _body.Y = _header.Y + _header.Height + 5; + _body.Width = Width - 20; + + _cancel.X = Width - _cancel.Width - 10; + _cancel.Y = Height - _cancel.Height - 10; + _body.Height = (_cancel.Y - _body.Y); + _install.Y = _cancel.Y; + _install.X = _cancel.X - _install.Width - 5; + } + + + public void OpenFile(string file) + { + _setup = JsonConvert.DeserializeObject<SetupFile>(ReadAllText(file)); + AppearanceManager.SetupDialog(this); + } + + public void OnLoad() + { + _header.Text = _setup.Name; + _body.Text = _setup.Description; + } + + public void OnSkinLoad() + { + } + + public bool OnUnload() + { + return true; + } + + public void OnUpgrade() + { + } + } + + public class SetupFile + { + public string Name { get; set; } + public string Description { get; set; } + public SetupSource SourceType { get; set; } + public string Source { get; set; } + } + + public enum SetupSource + { + ShiftoriumUpgrade + } +} |
