diff --git a/source/WindowsFormsApplication1/API.cs b/source/WindowsFormsApplication1/API.cs index b99f98f..fcf03a1 100644 --- a/source/WindowsFormsApplication1/API.cs +++ b/source/WindowsFormsApplication1/API.cs @@ -16,6 +16,16 @@ using System.ComponentModel; namespace ShiftOS { + public static class Consts + { + public const string Version = "0.1.2"; + } + + public class Settings + { + public int MusicVolume { get; set; } + } + public class PanelButton { /// @@ -71,6 +81,12 @@ namespace ShiftOS public class API { + + /// + /// Settings file. + /// + public static Settings LoadedSettings = null; + /// /// Whether or not dev commands like '05tray' are available. /// Typically, this is set to true if the release is classified as @@ -83,7 +99,7 @@ namespace ShiftOS /// to test new features or to bring in lots of codepoints. This is why /// Developer mode should ALWAYS be off in non-dev releases, to prevent cheating. /// - public static bool DeveloperMode = false; + public static bool DeveloperMode = true; /// /// If this is true, only certain applications will open and only @@ -99,6 +115,22 @@ namespace ShiftOS public static bool InfoboxesPlaySounds = true; + public static void SkinControl(Control c) + { + if(c is Button) + { + var b = c as Button; + b.FlatStyle = FlatStyle.Flat; + } + if(c is Panel || c is FlowLayoutPanel) + { + foreach(Control child in c.Controls) + { + SkinControl(child); + } + } + } + public static List RunningModProcesses = new List(); public static Dictionary CommandAliases = new Dictionary(); public static Terminal LoggerTerminal = null; @@ -830,16 +862,17 @@ namespace ShiftOS /// public static void ShutDownShiftOS() { + File.WriteAllText(Paths.SystemDir + "settings.json", JsonConvert.SerializeObject(LoadedSettings)); + Audio.running = false; if (!LimitedMode) { - //dispose audio clients - Audio.DisposeAll(); //Disconnect from server. try { - foreach (string ip in Package_Grabber.clients.Keys) + foreach (var ip in Package_Grabber.clients) { - Package_Grabber.Disconnect(ip); + if (ip.Value.IsConnected) + ip.Value.Disconnect(); } } catch @@ -1012,12 +1045,14 @@ namespace ShiftOS { formToCreate.Controls.Remove(ctrl); ctrl.Show(); + SkinControl(ctrl); } - catch (Exception ex) + catch { API.CurrentSession.Invoke(new Action(() => { ctrl.Show(); + SkinControl(ctrl); })); } } @@ -1197,7 +1232,8 @@ namespace ShiftOS /// I don't know. public static bool CloseProgram(string command) { - try { + try + { List PanelButtonsToKill = new List(); bool closed = false; foreach (Form app in OpenPrograms) @@ -1236,7 +1272,8 @@ namespace ShiftOS PanelButtons.Remove(pbtn); } return closed; - } catch(Exception ex) + } + catch { return false; } @@ -1608,7 +1645,7 @@ namespace ShiftOS return "success"; } } - catch (Exception ex) + catch { API.LogException("User didn't guess a valid knowledge input guess.", false); return "not_valid"; @@ -1672,6 +1709,17 @@ namespace ShiftOS bool succeeded = true; switch (cmd) { + + case "settings": + API.CreateForm(new GameSettings(), "Settings", API.GetIcon("Settings")); + break; + case "credits": + var c = new CreditScroller(); + c.FormBorderStyle = FormBorderStyle.None; + c.Show(); + c.WindowState = FormWindowState.Maximized; + c.TopMost = true; + break; case "netbrowse": if(Upgrades["networkbrowser"]) { @@ -1909,6 +1957,7 @@ namespace ShiftOS public static Color[] graymemory = new Color[16]; public static Color[] yellowmemory = new Color[16]; public static Color[] pinkmemory = new Color[16]; + internal static Dictionary> LuaShifterRegistry = null; #endregion } diff --git a/source/WindowsFormsApplication1/AlternateDesktop.cs b/source/WindowsFormsApplication1/AlternateDesktop.cs index f3c7b73..690977f 100644 --- a/source/WindowsFormsApplication1/AlternateDesktop.cs +++ b/source/WindowsFormsApplication1/AlternateDesktop.cs @@ -116,7 +116,7 @@ namespace ShiftOS PanelButton pbtn = (PanelButton)s.Tag; API.ToggleMinimized(pbtn.FormToManage); } - catch (Exception ex) + catch { } diff --git a/source/WindowsFormsApplication1/Appscape.cs b/source/WindowsFormsApplication1/Appscape.cs index a482a04..92171d9 100644 --- a/source/WindowsFormsApplication1/Appscape.cs +++ b/source/WindowsFormsApplication1/Appscape.cs @@ -236,7 +236,7 @@ namespace ShiftOS pbappscreenshot.Show(); pbappscreenshot.Load(pkg.ScreenshotPath); } - catch(Exception ex) + catch { pbappscreenshot.Hide(); } @@ -266,7 +266,7 @@ namespace ShiftOS pbappicon.Show(); pbappicon.Load("http://playshiftos.ml/appscape/packages/" + pkg.PkgIconPath); } - catch(Exception ex) + catch { pbappicon.Hide(); } @@ -490,8 +490,6 @@ namespace ShiftOS return new KeyValuePair(dev, clt); } - private Dictionary LocalDevList = null; - /// /// Adds a new developer key to the specified client's listing. /// @@ -670,7 +668,7 @@ namespace ShiftOS { pkg.Cost = Convert.ToDecimal(Convert.ToDecimal(txtprice.Text).ToString("#.#####")); } - catch (Exception ex) + catch { ContinueUpload = false; API.CreateInfoboxSession("Error", "You have entered an incorrect price value.", infobox.InfoboxMode.Info); @@ -871,7 +869,7 @@ namespace ShiftOS }; _IP = ip_address; } - catch(Exception ex) + catch { throw new ArgumentException("IP address not found in client list."); } diff --git a/source/WindowsFormsApplication1/AppscapeUploader.cs b/source/WindowsFormsApplication1/AppscapeUploader.cs index 3c2465c..5cc8560 100644 --- a/source/WindowsFormsApplication1/AppscapeUploader.cs +++ b/source/WindowsFormsApplication1/AppscapeUploader.cs @@ -31,8 +31,6 @@ namespace ShiftOS private AppscapeModder MyProfile = null; private AppscapeClient Repo = null; - private string result = "cancelled"; - private void btncancel_Click(object sender, EventArgs e) { this.Close(); @@ -52,7 +50,7 @@ namespace ShiftOS { pkg.Cost = Convert.ToDecimal(Convert.ToDecimal(txtprice.Text).ToString("#.#####")); } - catch(Exception ex) + catch { ContinueUpload = false; API.CreateInfoboxSession("Error", "You have entered an incorrect price value.", infobox.InfoboxMode.Info); @@ -112,7 +110,6 @@ namespace ShiftOS - result = "finished"; this.Close(); } } @@ -136,7 +133,7 @@ namespace ShiftOS RecursiveControlSetup(c); } } - catch(Exception ex) { + catch { } } @@ -325,7 +322,7 @@ namespace ShiftOS ZipFile.CreateFromDirectory(dir, API.GetFSResult()); API.CreateInfoboxSession("Success", "The SAA file has been created successfully.", infobox.InfoboxMode.Info); } - catch(Exception ex) + catch { API.CreateInfoboxSession("Error", "Could not create the SAA file.", infobox.InfoboxMode.Info); } diff --git a/source/WindowsFormsApplication1/Artpad.cs b/source/WindowsFormsApplication1/Artpad.cs index 1ba144d..c393ae0 100644 --- a/source/WindowsFormsApplication1/Artpad.cs +++ b/source/WindowsFormsApplication1/Artpad.cs @@ -229,7 +229,7 @@ namespace ShiftOS canvasbitmap.SetPixel(Convert.ToInt32(txtpixelsetterxcoordinate.Text), Convert.ToInt32(txtpixelsetterycoordinate.Text), drawingcolour); picdrawingdisplay.Invalidate(); } - catch (Exception ex) + catch { API.CreateInfoboxSession("ArtPad - Placement Error!", "You have specified invalid coordinates for the pixel setter." + Environment.NewLine + Environment.NewLine + "Remember that the top left pixel has the coordinates 0, 0", infobox.InfoboxMode.Info); } @@ -344,7 +344,7 @@ namespace ShiftOS e.Graphics.DrawImage(canvasbitmap, 0, 0); e.Graphics.DrawImage(previewcanvasbitmap, 0, 0); } - catch (System.OutOfMemoryException ex) + catch { } @@ -1075,7 +1075,7 @@ namespace ShiftOS } } } - catch(Exception ex) + catch { } @@ -1295,7 +1295,7 @@ namespace ShiftOS graphicsbitmap = Graphics.FromImage(canvasbitmap); picdrawingdisplay.Invalidate(); } - catch (Exception ex) + catch { API.CreateInfoboxSession("ArtPad - Undo Error!" ,"There doesn't appear to be any more actions to undo." + Environment.NewLine + Environment.NewLine + "One more step back would undo the creation of the canvas. If this is your goal just click new.", infobox.InfoboxMode.Info); @@ -1312,7 +1312,7 @@ namespace ShiftOS graphicsbitmap = Graphics.FromImage(canvasbitmap); picdrawingdisplay.Invalidate(); } - catch (Exception ex) + catch { API.CreateInfoboxSession("ArtPad - Redo Error!" , "There doesn't appear to be any more actions to redo." + Environment.NewLine + Environment.NewLine + "If you have drawn on the canvas recently all future history would have been wiped!", infobox.InfoboxMode.Info); diff --git a/source/WindowsFormsApplication1/AudioResourceClient.cs b/source/WindowsFormsApplication1/AudioResourceClient.cs index ec51b18..717d43a 100644 --- a/source/WindowsFormsApplication1/AudioResourceClient.cs +++ b/source/WindowsFormsApplication1/AudioResourceClient.cs @@ -1,7 +1,4 @@ -// WARNING: This thing likes leaking memory. - - -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -10,241 +7,202 @@ using System.IO; using NAudio; using NAudio.Wave; using System.Threading; +using Newtonsoft.Json; +using AxWMPLib; +using System.Windows.Forms; +using WMPLib; namespace ShiftOS { + public class AudioData + { + public string StartURL { get; set; } + public Dictionary> Files { get; set; } + public Dictionary> Visualizers = null; + } + public class Audio { - public static List Clients = null; - internal static bool Enabled = false; - - public static void DisposeAll() + public static string Name { - if(Clients != null) + get { - foreach(var client in Clients) + string res = null; + try { - client.Dispose(); + if (_wmp != null) + { + if (_wmp.currentMedia != null) + { + res = _wmp.currentMedia.name; + } + + } + } + catch + { + + } + return res; + } + } + + private static AudioData _ad = null; + public static WindowsMediaPlayer _wmp = null; + public static bool running = true; + + public static int CurrentPosition + { + get + { + try + { + if (_wmp != null) + { + return (int)_wmp.controls.currentPosition; + } + else + { + return 0; + } + } + catch + { + return 0; } } } + + public static int CurrentPositionMS + { + get + { + try + { + if (_wmp != null) + { + return (int)(_wmp.controls.currentPosition * 100); + } + else + { + return 0; + } + } + catch + { + return 0; + } + } + } + + + public static void LoadAudioData() + { + var t = new Thread(new ThreadStart(() => + { + _wmp = new WindowsMediaPlayer(); + _wmp.settings.autoStart = true; + _wmp.settings.volume = API.LoadedSettings.MusicVolume; + })); + t.Start(); + _ad = JsonConvert.DeserializeObject(Properties.Resources.MusicData); + } + + public static void Play(string list) + { + _forceStop = false; + var lst = _ad.Files[list]; + var rnd = new Random(); + int i = rnd.Next(0, lst.Count); + _wmp.URL = _ad.StartURL + list + "/" + _ad.Files[list][i] + ".mp3"; + _wmp.PlayStateChange += (o) => + { + if (o == (int)WMPPlayState.wmppsMediaEnded) + { + var t = new System.Windows.Forms.Timer(); + t.Interval = 1000; + t.Tick += (object s, EventArgs a) => + { + t.Stop(); + Stopped?.Invoke(_wmp, new EventArgs()); + }; + t.Start(); + } + }; + + } + + public static event EventHandler Stopped; + + public static bool _forceStop = false; + + public static void Mute() + { + _wmp.settings.volume = 0; + } + + public static void VolumeUp() + { + if(_wmp.settings.volume < 90) + { + _wmp.settings.volume += 10; + } + } + + public static void VolumeDown() + { + if(_wmp.settings.volume > 0) + { + _wmp.settings.volume -= 10; + } + } + + public static void Pause() + { + _wmp.controls.pause(); + } + + public static void Unpause() + { + _wmp.controls.play(); + } + + public static void ForceStop() + { + new Thread(new ThreadStart(() => + { + _forceStop = true; + _wmp.controls.stop(); + })).Start(); + } + + internal static Visualizer GetVisualizer() + { + Visualizer v = null; + foreach(var vis in _ad.Visualizers[Name]) + { + if (vis.startTime <= CurrentPosition && vis.endTime >= CurrentPosition) + v = vis; + } + return v; + } } - public class AudioResourceClient + public class Visualizer { - - - public AudioResourceClient(string folder) - { - if (Audio.Enabled) - { - if (Audio.Clients == null) - { - Audio.Clients = new List(); - } - Audio.Clients.Add(this); - string real = folder.Replace(";", OSInfo.DirectorySeparator); - real_path = "resources" + OSInfo.DirectorySeparator + real; - soundPlayer = new WaveOut(); - var t = new Thread(new ThreadStart(new Action(() => - { - while (disposed == false) - { - switch (soundPlayer.PlaybackState) - { - case PlaybackState.Stopped: - if (fireEvents) - { - if (currentStream != null) - currentStream.Dispose(); - currentStream = null; - currentProvider = null; - var h = SongFinished; - if (h != null) - { - API.CurrentSession.Invoke(new Action(() => - { - h(this, new EventArgs()); - })); - } - - } - - break; - } - } - }))); - t.Start(); - } - } - - public string CurrentSong - { - get { return currentSong; } - } - - private string real_path = null; - private WaveOut soundPlayer = null; - private bool disposed = false; - private bool playing = false; - private bool loopActive = false; - private string currentSong = ""; - protected Thread soundThread; - private Stream currentStream = null; - private IWaveProvider currentProvider = null; - private bool fireEvents = false; - - public event EventHandler SongFinished; - - public void Play(byte[] songbytes) - { - if (Audio.Enabled) - { - var t = new Thread(new ThreadStart(new Action(() => - { - try - { - if (disposed == false) - { - if (currentProvider != null) - { - currentProvider = null; - } - if (currentStream != null) - { - currentStream.Dispose(); - currentStream = null; - } - Stream s = new MemoryStream(songbytes); - IWaveProvider provider = new RawSourceWaveStream(s, new WaveFormat()); - soundPlayer.Init(provider); - soundPlayer.Play(); - fireEvents = true; - currentStream = s; - currentProvider = provider; - } - } - catch - { - - } - }))); - soundThread = t; - t.Start(); - } - } - - public void PlayMP3(byte[] songbytes) - { - if (Audio.Enabled) - { - var t = new Thread(new ThreadStart(new Action(() => - { - if (currentProvider != null) - { - currentProvider = null; - } - if (currentStream != null) - { - currentStream.Dispose(); - currentStream = null; - } - Stream s = new MemoryStream(songbytes); - IWaveProvider provider = new Mp3FileReader(s); - soundPlayer.Init(provider); - soundPlayer.Play(); - currentStream = s; - currentProvider = provider; - }))); - soundThread = t; - t.Start(); - } - } - - - public void Play(string file) - { - if (Audio.Enabled) - { - if (File.Exists(real_path + OSInfo.DirectorySeparator + file + ".wav")) - { - currentSong = file; - Play(File.ReadAllBytes(real_path + OSInfo.DirectorySeparator + file + ".wav")); - } - else if (File.Exists(real_path + OSInfo.DirectorySeparator + file + ".mp3")) - { - currentSong = file; - PlayMP3(File.ReadAllBytes(real_path + OSInfo.DirectorySeparator + file + ".mp3")); - } - } - } - - public void Stop() - { - if (Audio.Enabled) - { - var t = new Thread(new ThreadStart(new Action(() => - { - fireEvents = false; - soundPlayer.Stop(); - if (currentProvider != null) - { - currentProvider = null; - } - if (currentStream != null) - { - currentStream.Dispose(); - currentStream = null; - } - }))); - t.Start(); - } - } - - public void Pause() - { - if (Audio.Enabled) - { - if (soundPlayer.PlaybackState == PlaybackState.Playing) - { - soundPlayer.Pause(); - } - else if (soundPlayer.PlaybackState == PlaybackState.Paused) - { - soundPlayer.Resume(); - } - } - } - - public void PlayRandom() - { - if (Audio.Enabled) - { - int r = new Random().Next(0, Directory.GetFiles(real_path).Length); - var files = Directory.GetFiles(real_path); - FileInfo finf = new FileInfo(files[r]); - string name = finf.Name.Replace(finf.Extension, ""); - Play(name); - - } - } - - public void Dispose() - { - if (Audio.Enabled) - { - if (currentProvider != null) - { - currentProvider = null; - } - if (currentStream != null) - { - currentStream.Dispose(); - currentStream = null; - } - soundPlayer.Dispose(); - disposed = true; - } - } + public int startTime { get; set; } + public int endTime { get; set; } + public VisualizerType type { get; set; } + public bool R { get; set; } + public bool G { get; set; } + public bool B { get; set; } } + + public enum VisualizerType + { + Pulse, + BuildUp, + CalmDown + } + } diff --git a/source/WindowsFormsApplication1/BitnoteConverter.cs b/source/WindowsFormsApplication1/BitnoteConverter.cs index 3059114..d28b970 100644 --- a/source/WindowsFormsApplication1/BitnoteConverter.cs +++ b/source/WindowsFormsApplication1/BitnoteConverter.cs @@ -37,7 +37,7 @@ namespace ShiftOS lbstatus.Text = "> " + decstr + " BTN"; BitnotesToAdd = Convert.ToDecimal(decstr); } - catch(Exception ex) + catch { BitnotesToAdd = 0; } diff --git a/source/WindowsFormsApplication1/BitnoteWallet.cs b/source/WindowsFormsApplication1/BitnoteWallet.cs index e3c6a2a..6d5cb9f 100644 --- a/source/WindowsFormsApplication1/BitnoteWallet.cs +++ b/source/WindowsFormsApplication1/BitnoteWallet.cs @@ -76,7 +76,7 @@ namespace ShiftOS }; t.RunWorkerAsync(); } - catch(Exception ex) + catch { SyncBitnotes(new List()); API.CreateInfoboxSession("Error", "You cannot sync your Bitnotes as the connection to the server has failed.", infobox.InfoboxMode.Info); @@ -211,7 +211,7 @@ namespace ShiftOS }; _IP = IP; } - catch (Exception ex) + catch { throw new ArgumentException("IP address not found in client list."); } diff --git a/source/WindowsFormsApplication1/Computer.Designer.cs b/source/WindowsFormsApplication1/Computer.Designer.cs index 622cd09..4157592 100644 --- a/source/WindowsFormsApplication1/Computer.Designer.cs +++ b/source/WindowsFormsApplication1/Computer.Designer.cs @@ -13,6 +13,10 @@ /// true if managed resources should be disposed; otherwise, false. protected override void Dispose(bool disposing) { + if(this.HealthTimer != null) + { + this.HealthTimer.Stop(); + } if (disposing && (components != null)) { components.Dispose(); diff --git a/source/WindowsFormsApplication1/Computer.cs b/source/WindowsFormsApplication1/Computer.cs index 3b546b7..8f849d3 100644 --- a/source/WindowsFormsApplication1/Computer.cs +++ b/source/WindowsFormsApplication1/Computer.cs @@ -45,8 +45,7 @@ namespace ShiftOS } } - private SystemType _Type = SystemType.Core; - + public SystemType Type { get; set; @@ -112,8 +111,6 @@ namespace ShiftOS return AttackType.Core; case SystemType.Turret: return AttackType.Virus; - case SystemType.FTPServer: - return AttackType.Backdoor; default: return AttackType.None; } @@ -284,30 +281,31 @@ namespace ShiftOS { case SystemType.Core: return 100; - break; default: switch (Grade) { case 1: return 10; - break; case 2: return 20; - break; case 3: return 40; - break; case 4: return 80; - break; default: return 10; - break; } - break; } } + public Timer HealthTimer = null; + + public bool AlreadyEnslaved = false; + public bool Enslaved = false; + + public event EventHandler EnslavedModule; + + public event EventHandler MassDDoS; private void Computer_Load(object sender, EventArgs e) @@ -341,7 +339,7 @@ namespace ShiftOS (this.Parent.Height - this.Height) / 2 ); } - catch (Exception ex) + catch { } @@ -360,6 +358,26 @@ namespace ShiftOS } this.Size = new Size(32, 32); break; + case SystemType.ModuleStealer: + var rnd = new Random(); + int num = rnd.Next(0, 2500 / Grade); + if(num == 25) + { + StolenModule?.Invoke(this, new EventArgs()); + } + break; + case SystemType.Enslaver: + if (AlreadyEnslaved == false) + { + var ernd = new Random(); + int num2 = ernd.Next(0, 2500 / Grade); + if (num2 == 25) + { + AlreadyEnslaved = true; + EnslavedModule?.Invoke(this, new EventArgs()); + } + } + break; case SystemType.ServerStack: var r2 = new Random(); int i2 = r2.Next(0, GetChance()); @@ -419,8 +437,11 @@ namespace ShiftOS } }; t.Start(); + HealthTimer = t; } + public event EventHandler StolenModule; + public event EventHandler OnDestruction; public void ThrowDestroyed() @@ -446,16 +467,16 @@ namespace ShiftOS public enum SystemType { - Core, - Antivirus, - DedicatedDDoS, - Turret, - FTPServer, - Firewall, - ServerStack, - Enslaver, - DamageLogger, - RepairModule, + Core = 0, + Antivirus = 1, + DedicatedDDoS = 2, + Turret = 3, + FTPServer = 4, + Firewall = 5, + ServerStack = 6, + Enslaver = 7, + RepairModule = 9, + ModuleStealer = 8, } public enum AttackType { diff --git a/source/WindowsFormsApplication1/ConnectionManager.Designer.cs b/source/WindowsFormsApplication1/ConnectionManager.Designer.cs new file mode 100644 index 0000000..89abcca --- /dev/null +++ b/source/WindowsFormsApplication1/ConnectionManager.Designer.cs @@ -0,0 +1,129 @@ +namespace ShiftOS +{ + partial class ConnectionManager + { + /// + /// 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 Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.panel1 = new System.Windows.Forms.Panel(); + this.lbconnections = new System.Windows.Forms.ListBox(); + this.flbuttons = new System.Windows.Forms.FlowLayoutPanel(); + this.btnadd = new System.Windows.Forms.Button(); + this.btnconnect = new System.Windows.Forms.Button(); + this.btndisconnect = new System.Windows.Forms.Button(); + this.panel1.SuspendLayout(); + this.flbuttons.SuspendLayout(); + this.SuspendLayout(); + // + // panel1 + // + this.panel1.Controls.Add(this.flbuttons); + this.panel1.Controls.Add(this.lbconnections); + this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel1.Location = new System.Drawing.Point(0, 0); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(684, 531); + this.panel1.TabIndex = 0; + // + // lbconnections + // + this.lbconnections.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.lbconnections.FormattingEnabled = true; + this.lbconnections.Location = new System.Drawing.Point(13, 13); + this.lbconnections.Name = "lbconnections"; + this.lbconnections.Size = new System.Drawing.Size(659, 472); + this.lbconnections.TabIndex = 0; + this.lbconnections.SelectedIndexChanged += new System.EventHandler(this.lbconnections_SelectedIndexChanged); + // + // flbuttons + // + this.flbuttons.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.flbuttons.Controls.Add(this.btnadd); + this.flbuttons.Controls.Add(this.btnconnect); + this.flbuttons.Controls.Add(this.btndisconnect); + this.flbuttons.Location = new System.Drawing.Point(13, 489); + this.flbuttons.Name = "flbuttons"; + this.flbuttons.Size = new System.Drawing.Size(659, 30); + this.flbuttons.TabIndex = 1; + // + // btnadd + // + this.btnadd.Location = new System.Drawing.Point(3, 3); + this.btnadd.Name = "btnadd"; + this.btnadd.Size = new System.Drawing.Size(75, 23); + this.btnadd.TabIndex = 0; + this.btnadd.Text = "Add"; + this.btnadd.UseVisualStyleBackColor = true; + this.btnadd.Click += new System.EventHandler(this.btnadd_Click); + // + // btnconnect + // + this.btnconnect.Location = new System.Drawing.Point(84, 3); + this.btnconnect.Name = "btnconnect"; + this.btnconnect.Size = new System.Drawing.Size(75, 23); + this.btnconnect.TabIndex = 1; + this.btnconnect.Text = "Connect"; + this.btnconnect.UseVisualStyleBackColor = true; + this.btnconnect.Click += new System.EventHandler(this.btnconnect_Click); + // + // btndisconnect + // + this.btndisconnect.Location = new System.Drawing.Point(165, 3); + this.btndisconnect.Name = "btndisconnect"; + this.btndisconnect.Size = new System.Drawing.Size(75, 23); + this.btndisconnect.TabIndex = 2; + this.btndisconnect.Text = "Disconnect"; + this.btndisconnect.UseVisualStyleBackColor = true; + this.btndisconnect.Click += new System.EventHandler(this.btndisconnect_Click); + // + // ConnectionManager + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(684, 531); + this.Controls.Add(this.panel1); + this.Name = "ConnectionManager"; + this.Text = "ConnectionManager"; + this.Load += new System.EventHandler(this.ConnectionManager_Load); + this.panel1.ResumeLayout(false); + this.flbuttons.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.FlowLayoutPanel flbuttons; + private System.Windows.Forms.Button btnadd; + private System.Windows.Forms.Button btnconnect; + private System.Windows.Forms.Button btndisconnect; + private System.Windows.Forms.ListBox lbconnections; + } +} \ No newline at end of file diff --git a/source/WindowsFormsApplication1/ConnectionManager.cs b/source/WindowsFormsApplication1/ConnectionManager.cs new file mode 100644 index 0000000..eaf2a24 --- /dev/null +++ b/source/WindowsFormsApplication1/ConnectionManager.cs @@ -0,0 +1,91 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace ShiftOS +{ + public partial class ConnectionManager : Form + { + public ConnectionManager() + { + InitializeComponent(); + } + + string selectednet = null; + + private void lbconnections_SelectedIndexChanged(object sender, EventArgs e) + { + try + { + selectednet = lbconnections.SelectedItem.ToString(); + SetupUI(); + } + catch + { + selectednet = null; + SetupUI(); + } + } + + public void SetupUI() + { + if(selectednet != null) + { + btnconnect.Visible = !Package_Grabber.clients[selectednet].IsConnected; + btndisconnect.Visible = Package_Grabber.clients[selectednet].IsConnected; + } + else + { + btnconnect.Hide(); + btndisconnect.Hide(); + } + } + + private void ConnectionManager_Load(object sender, EventArgs e) + { + SetupUI(); + var t = new Timer(); + t.Interval = 500; + t.Tick += (object s, EventArgs a) => + { + lbconnections.Items.Clear(); + foreach(var itm in Package_Grabber.clients) + { + lbconnections.Items.Add(itm.Key); + } + }; + t.Start(); + } + + private void btndisconnect_Click(object sender, EventArgs e) + { + Package_Grabber.Disconnect(selectednet); + SetupUI(); + } + + private void btnconnect_Click(object sender, EventArgs e) + { + Package_Grabber.ConnectToServer(selectednet, 7429); + SetupUI(); + } + + private void btnadd_Click(object sender, EventArgs e) + { + API.CreateInfoboxSession("Add connection", "Please type the IP Address or hostname of the server.", infobox.InfoboxMode.TextEntry); + API.InfoboxSession.FormClosing += (o, a) => + { + var res = API.GetInfoboxResult(); + if(res != "Cancelled") + { + Package_Grabber.ConnectToServer(res, 7429); + } + }; + } + } +} diff --git a/source/WindowsFormsApplication1/ConnectionManager.resx b/source/WindowsFormsApplication1/ConnectionManager.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/source/WindowsFormsApplication1/ConnectionManager.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + \ No newline at end of file diff --git a/source/WindowsFormsApplication1/CreditScroller.Designer.cs b/source/WindowsFormsApplication1/CreditScroller.Designer.cs new file mode 100644 index 0000000..f453b50 --- /dev/null +++ b/source/WindowsFormsApplication1/CreditScroller.Designer.cs @@ -0,0 +1,263 @@ +namespace ShiftOS +{ + partial class CreditScroller + { + /// + /// 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 Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.panel1 = new System.Windows.Forms.Panel(); + this.pnlscroll = new System.Windows.Forms.Panel(); + this.btnclose = new System.Windows.Forms.Button(); + this.lbcreditstext = new System.Windows.Forms.Label(); + this.lbgametitle = new System.Windows.Forms.Label(); + this.tmrredraw = new System.Windows.Forms.Timer(this.components); + this.pgcontents = new System.Windows.Forms.Panel(); + this.lblcountdown = new System.Windows.Forms.Label(); + this.ball = new System.Windows.Forms.Panel(); + this.paddleHuman = new System.Windows.Forms.PictureBox(); + this.paddleComputer = new System.Windows.Forms.Panel(); + this.lbllevelandtime = new System.Windows.Forms.Label(); + this.lblstatsY = new System.Windows.Forms.Label(); + this.lblstatsX = new System.Windows.Forms.Label(); + this.pongGameTimer = new System.Windows.Forms.Timer(this.components); + this.counter = new System.Windows.Forms.Timer(this.components); + this.tmrcountdown = new System.Windows.Forms.Timer(this.components); + this.panel1.SuspendLayout(); + this.pnlscroll.SuspendLayout(); + this.pgcontents.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.paddleHuman)).BeginInit(); + this.SuspendLayout(); + // + // panel1 + // + this.panel1.Controls.Add(this.pnlscroll); + this.panel1.Controls.Add(this.lbgametitle); + this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel1.Location = new System.Drawing.Point(0, 0); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(916, 528); + this.panel1.TabIndex = 0; + // + // pnlscroll + // + this.pnlscroll.Controls.Add(this.btnclose); + this.pnlscroll.Controls.Add(this.lbcreditstext); + this.pnlscroll.Controls.Add(this.pgcontents); + this.pnlscroll.Dock = System.Windows.Forms.DockStyle.Fill; + this.pnlscroll.Location = new System.Drawing.Point(0, 66); + this.pnlscroll.Name = "pnlscroll"; + this.pnlscroll.Size = new System.Drawing.Size(916, 462); + this.pnlscroll.TabIndex = 1; + // + // btnclose + // + this.btnclose.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnclose.AutoSize = true; + this.btnclose.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.btnclose.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnclose.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F); + this.btnclose.Location = new System.Drawing.Point(843, 418); + this.btnclose.Name = "btnclose"; + this.btnclose.Size = new System.Drawing.Size(61, 32); + this.btnclose.TabIndex = 1; + this.btnclose.Text = "Close"; + this.btnclose.UseVisualStyleBackColor = true; + this.btnclose.Click += new System.EventHandler(this.btnclose_Click); + // + // lbcreditstext + // + this.lbcreditstext.AutoSize = true; + this.lbcreditstext.BackColor = System.Drawing.Color.Transparent; + this.lbcreditstext.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F); + this.lbcreditstext.Location = new System.Drawing.Point(0, 138); + this.lbcreditstext.MaximumSize = new System.Drawing.Size(916, 0); + this.lbcreditstext.Name = "lbcreditstext"; + this.lbcreditstext.Size = new System.Drawing.Size(0, 25); + this.lbcreditstext.TabIndex = 0; + this.lbcreditstext.TextAlign = System.Drawing.ContentAlignment.TopCenter; + // + // lbgametitle + // + this.lbgametitle.Dock = System.Windows.Forms.DockStyle.Top; + this.lbgametitle.Font = new System.Drawing.Font("Microsoft Sans Serif", 25F); + this.lbgametitle.Location = new System.Drawing.Point(0, 0); + this.lbgametitle.Name = "lbgametitle"; + this.lbgametitle.Size = new System.Drawing.Size(916, 66); + this.lbgametitle.TabIndex = 0; + this.lbgametitle.Text = "ShiftOS Credits"; + this.lbgametitle.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // tmrredraw + // + this.tmrredraw.Enabled = true; + this.tmrredraw.Tick += new System.EventHandler(this.tmrredraw_Tick); + // + // pgcontents + // + this.pgcontents.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.pgcontents.BackColor = System.Drawing.Color.Black; + this.pgcontents.Controls.Add(this.lblcountdown); + this.pgcontents.Controls.Add(this.ball); + this.pgcontents.Controls.Add(this.paddleHuman); + this.pgcontents.Controls.Add(this.paddleComputer); + this.pgcontents.Controls.Add(this.lbllevelandtime); + this.pgcontents.Controls.Add(this.lblstatsY); + this.pgcontents.Controls.Add(this.lblstatsX); + this.pgcontents.ForeColor = System.Drawing.Color.Gray; + this.pgcontents.Location = new System.Drawing.Point(0, 0); + this.pgcontents.Name = "pgcontents"; + this.pgcontents.Size = new System.Drawing.Size(700, 400); + this.pgcontents.TabIndex = 21; + // + // lblcountdown + // + this.lblcountdown.Font = new System.Drawing.Font("Microsoft Sans Serif", 24F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lblcountdown.Location = new System.Drawing.Point(187, 152); + this.lblcountdown.Name = "lblcountdown"; + this.lblcountdown.Size = new System.Drawing.Size(315, 49); + this.lblcountdown.TabIndex = 7; + this.lblcountdown.Text = "3"; + this.lblcountdown.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.lblcountdown.Visible = false; + // + // ball + // + this.ball.BackColor = System.Drawing.Color.Gray; + this.ball.Location = new System.Drawing.Point(300, 152); + this.ball.Name = "ball"; + this.ball.Size = new System.Drawing.Size(20, 20); + this.ball.TabIndex = 2; + // + // paddleHuman + // + this.paddleHuman.BackColor = System.Drawing.Color.Gray; + this.paddleHuman.Location = new System.Drawing.Point(10, 134); + this.paddleHuman.Name = "paddleHuman"; + this.paddleHuman.Size = new System.Drawing.Size(20, 100); + this.paddleHuman.TabIndex = 3; + this.paddleHuman.TabStop = false; + // + // paddleComputer + // + this.paddleComputer.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Right))); + this.paddleComputer.BackColor = System.Drawing.Color.Gray; + this.paddleComputer.Location = new System.Drawing.Point(666, 134); + this.paddleComputer.MaximumSize = new System.Drawing.Size(20, 100); + this.paddleComputer.Name = "paddleComputer"; + this.paddleComputer.Size = new System.Drawing.Size(20, 100); + this.paddleComputer.TabIndex = 1; + // + // lbllevelandtime + // + this.lbllevelandtime.Dock = System.Windows.Forms.DockStyle.Top; + this.lbllevelandtime.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lbllevelandtime.Location = new System.Drawing.Point(0, 0); + this.lbllevelandtime.Name = "lbllevelandtime"; + this.lbllevelandtime.Size = new System.Drawing.Size(700, 22); + this.lbllevelandtime.TabIndex = 4; + this.lbllevelandtime.Text = "Level: 1"; + this.lbllevelandtime.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // lblstatsY + // + this.lblstatsY.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.lblstatsY.Font = new System.Drawing.Font("Georgia", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lblstatsY.Location = new System.Drawing.Point(542, 356); + this.lblstatsY.Name = "lblstatsY"; + this.lblstatsY.Size = new System.Drawing.Size(144, 35); + this.lblstatsY.TabIndex = 11; + this.lblstatsY.Text = "Yspeed:"; + this.lblstatsY.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // lblstatsX + // + this.lblstatsX.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.lblstatsX.Font = new System.Drawing.Font("Georgia", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lblstatsX.Location = new System.Drawing.Point(3, 356); + this.lblstatsX.Name = "lblstatsX"; + this.lblstatsX.Size = new System.Drawing.Size(144, 35); + this.lblstatsX.TabIndex = 5; + this.lblstatsX.Text = "Xspeed: "; + this.lblstatsX.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // pongGameTimer + // + this.pongGameTimer.Interval = 30; + this.pongGameTimer.Tick += new System.EventHandler(this.pongGameTimer_Tick); + // + // counter + // + this.counter.Interval = 1000; + this.counter.Tick += new System.EventHandler(this.counter_Tick); + // + // tmrcountdown + // + this.tmrcountdown.Interval = 1000; + this.tmrcountdown.Tick += new System.EventHandler(this.tmrcountdown_Tick); + // + // CreditScroller + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.Color.Black; + this.ClientSize = new System.Drawing.Size(916, 528); + this.Controls.Add(this.panel1); + this.ForeColor = System.Drawing.Color.White; + this.Name = "CreditScroller"; + this.Text = "CreditScroller"; + this.Load += new System.EventHandler(this.CreditScroller_Load); + this.panel1.ResumeLayout(false); + this.pnlscroll.ResumeLayout(false); + this.pnlscroll.PerformLayout(); + this.pgcontents.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.paddleHuman)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.Panel pnlscroll; + private System.Windows.Forms.Label lbcreditstext; + private System.Windows.Forms.Label lbgametitle; + private System.Windows.Forms.Timer tmrredraw; + private System.Windows.Forms.Button btnclose; + internal System.Windows.Forms.Panel pgcontents; + internal System.Windows.Forms.Label lblcountdown; + internal System.Windows.Forms.Panel ball; + internal System.Windows.Forms.PictureBox paddleHuman; + internal System.Windows.Forms.Panel paddleComputer; + internal System.Windows.Forms.Label lbllevelandtime; + internal System.Windows.Forms.Label lblstatsY; + internal System.Windows.Forms.Label lblstatsX; + internal System.Windows.Forms.Timer pongGameTimer; + internal System.Windows.Forms.Timer counter; + internal System.Windows.Forms.Timer tmrcountdown; + } +} \ No newline at end of file diff --git a/source/WindowsFormsApplication1/CreditScroller.cs b/source/WindowsFormsApplication1/CreditScroller.cs new file mode 100644 index 0000000..ff0a206 --- /dev/null +++ b/source/WindowsFormsApplication1/CreditScroller.cs @@ -0,0 +1,273 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace ShiftOS +{ + public partial class CreditScroller : Form + { + public CreditScroller() + { + InitializeComponent(); + } + + #region pong visualizer variables + + + bool pongVisible = false; + Random rand = new Random(); + int xVel = 7; + int yVel = 8; + int computerspeed = 8; + int level = 1; + int secondsleft = 60; + int casualposition; + double xveldec = 3.0; + double yveldec = 3.0; + double incrementx = 0.4; + double incrementy = 0.2; + int levelxspeed = 3; + int levelyspeed = 3; + int beatairewardtotal; + int beataireward = 1; + int[] levelrewards = new int[50]; + int countdown = 3; + + #endregion + + int offset = 0; + + private void tmrredraw_Tick(object sender, EventArgs e) + { + pgcontents.Visible = pongVisible; + lbcreditstext.Top = pnlscroll.Height - offset; + if(pongVisible) + lbcreditstext.Left = (pnlscroll.Width - lbcreditstext.Width); + else + lbcreditstext.Left = (pnlscroll.Width - lbcreditstext.Width) / 2; + offset += 1; + } + + private void CreditScroller_Load(object sender, EventArgs e) + { + Audio.Play("hackerbattle_ambient"); + tmrredraw.Interval = 50; + lbcreditstext.Text = Properties.Resources.Credits.Replace("#VER#", Consts.Version); + tmrredraw.Start(); + newgame(); + } + + private void btnclose_Click(object sender, EventArgs e) + { + this.Close(); + } + + private void pongGameTimer_Tick(object sender, EventArgs e) + { + //Move player according to ball + if(ball.Left < 250 + xVel / 10 && xVel < 0) + { + if(ball.Top > paddleHuman.Top + 50) + { + paddleHuman.Top += computerspeed * 2 + ((int)yveldec / 2); + } + else if(ball.Top < paddleHuman.Top + 50) + { + paddleHuman.Top -= computerspeed * 2 + ((int)yveldec / 2); + } + } + + //Set the computer player to move according to the ball's position. + if (ball.Location.X > 500 - xVel * 10 && xVel > 0) + { + if (ball.Location.Y > paddleComputer.Location.Y + 50) + { + paddleComputer.Location = new Point(paddleComputer.Location.X, paddleComputer.Location.Y + computerspeed * 2 + ((int)yveldec / 2)); + } + if (ball.Location.Y < paddleComputer.Location.Y + 50) + { + paddleComputer.Location = new Point(paddleComputer.Location.X, paddleComputer.Location.Y - computerspeed * 2 + ((int)yveldec / 2)); + } + casualposition = rand.Next(-150, 201); + } + + //Set Xvel and Yvel speeds from decimal + if (xVel > 0) + xVel = (int)Math.Round(xveldec); + if (xVel < 0) + xVel = (int)-Math.Round(xveldec); + if (yVel > 0) + yVel = (int)Math.Round(yveldec); + if (yVel < 0) + yVel = (int)-Math.Round(yveldec); + + // Move the game ball. + ball.Location = new Point(ball.Location.X + xVel, ball.Location.Y + yVel); + + // Check for top wall. + if (ball.Location.Y < 0) + { + ball.Location = new Point(ball.Location.X, 0); + yVel = -yVel; + } + + // Check for bottom wall. + if (ball.Location.Y > pgcontents.Height - ball.Height) + { + ball.Location = new Point(ball.Location.X, pgcontents.Height - ball.Size.Height); + yVel = -yVel; + } + + // Check for player paddle. + if (ball.Bounds.IntersectsWith(paddleHuman.Bounds)) + { + ball.Location = new Point(paddleHuman.Location.X + ball.Size.Width, ball.Location.Y); + //randomly increase x or y speed of ball + switch (rand.Next(1, 3)) + { + case 1: + xveldec = xveldec + incrementx; + break; + case 2: + if (yveldec > 0) + yveldec = yveldec + incrementy; + if (yveldec < 0) + yveldec = yveldec - incrementy; + break; + } + xVel = -xVel; + } + + // Check for computer paddle. + if (ball.Bounds.IntersectsWith(paddleComputer.Bounds)) + { + ball.Location = new Point(paddleComputer.Location.X - paddleComputer.Size.Width + 1, ball.Location.Y); + xveldec = xveldec + incrementx; + xVel = -xVel; + } + + // Check for left wall. + if (ball.Location.X < -100) + { + ball.Location = new Point(pgcontents.Size.Width / 2 + 200, pgcontents.Size.Height / 2); + paddleComputer.Location = new Point(paddleComputer.Location.X, ball.Location.Y); + paddleHuman.Location = new Point(paddleHuman.Location.X, ball.Location.Y); + + if (xVel > 0) + xVel = -xVel; + pongGameTimer.Stop(); + tmrcountdown.Start(); + counter.Stop(); + } + + // Check for right wall. + if (ball.Location.X > pgcontents.Width - ball.Size.Width - paddleComputer.Width + 100) + { + ball.Location = new Point(pgcontents.Size.Width / 2 + 200, pgcontents.Size.Height / 2); + paddleComputer.Location = new Point(paddleComputer.Location.X, ball.Location.Y); + paddleHuman.Location = new Point(paddleHuman.Location.X, ball.Location.Y); + + if (xVel > 0) + xVel = -xVel; + beatairewardtotal = beatairewardtotal + beataireward; + tmrcountdown.Start(); + pongGameTimer.Stop(); + counter.Stop(); + } + + //lblstats.Text = "Xspeed: " & Math.Abs(xVel) & " Yspeed: " & Math.Abs(yVel) & " Human Location: " & paddleHuman.Location.ToString & " Computer Location: " & paddleComputer.Location.ToString & Environment.NewLine & " Ball Location: " & ball.Location.ToString & " Xdec: " & xveldec & " Ydec: " & yveldec & " Xinc: " & incrementx & " Yinc: " & incrementy + lblstatsX.Text = "Xspeed: " + xveldec; + lblstatsY.Text = "Yspeed: " + yveldec; + + lbllevelandtime.Text = "Level: " + level; + + if (xVel > 20 || xVel < -20) + { + paddleHuman.Width = Math.Abs(xVel); + paddleComputer.Width = Math.Abs(xVel); + } + else + { + paddleHuman.Width = 20; + paddleComputer.Width = 20; + } + + computerspeed = Math.Abs(yVel); + + // pgcontents.Refresh() + // pgcontents.CreateGraphics.FillRectangle(Brushes.Black, ball.Location.X, ball.Location.Y, ball.Width, ball.Height) + + } + + private void counter_Tick(object sender, EventArgs e) + { + secondsleft = secondsleft - 1; + if (secondsleft == -1) + { + secondsleft = 60; + level = level + 1; + + + } + + } + + private void tmrcountdown_Tick(object sender, EventArgs e) + { + switch (countdown) + { + case 0: + countdown = 3; + lblcountdown.Hide(); + pongGameTimer.Start(); + counter.Start(); + tmrcountdown.Stop(); + break; + case 1: + lblcountdown.Text = "1"; + countdown = countdown - 1; + break; + case 2: + lblcountdown.Text = "2"; + countdown = countdown - 1; + break; + case 3: + lblcountdown.Text = "3"; + countdown = countdown - 1; + lblcountdown.Show(); + break; + } + } + + private void newgame() + { + level = 1; + beataireward = 2; + beatairewardtotal = 0; + secondsleft = 60; + //reset stats text + lblstatsX.Text = "Xspeed: "; + lblstatsY.Text = "Yspeed: "; + + levelxspeed = 3; + levelyspeed = 3; + + incrementx = 0.4; + incrementy = 0.2; + + xveldec = levelxspeed; + yveldec = levelyspeed; + + tmrcountdown.Start(); + if (xVel < 0) + xVel = Math.Abs(xVel); + lbllevelandtime.Text = "Level: " + level + " - " + secondsleft + " Seconds Left"; + } + } +} diff --git a/source/WindowsFormsApplication1/CreditScroller.resx b/source/WindowsFormsApplication1/CreditScroller.resx new file mode 100644 index 0000000..42cc80f --- /dev/null +++ b/source/WindowsFormsApplication1/CreditScroller.resx @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + 130, 17 + + + 283, 18 + + + 376, 18 + + \ No newline at end of file diff --git a/source/WindowsFormsApplication1/File Skimmer.cs b/source/WindowsFormsApplication1/File Skimmer.cs index 883ff95..4ee8531 100644 --- a/source/WindowsFormsApplication1/File Skimmer.cs +++ b/source/WindowsFormsApplication1/File Skimmer.cs @@ -177,10 +177,11 @@ namespace ShiftOS { if (lbcurrentfolder.Text != "/") { - if (lbcurrentfolder.Text == MountPoint.Replace("\\", "/")) + if (MountPoint != null && lbcurrentfolder.Text == MountPoint.Replace("\\", "/")) { CurrentFolder = Paths.SaveRoot; ListFiles(); + } else { @@ -402,24 +403,18 @@ namespace ShiftOS case ".docx": case ".txt": return "doc"; - break; case ".exe": case ".saa": return "application"; - break; case ".stp": case ".pkg": case ".mod": return "package"; - break; case ".skn": case ".spk": return "skin"; - break; default: return "none"; - break; - } } @@ -454,7 +449,7 @@ namespace ShiftOS Directory.CreateDirectory(fullname); } } - catch (Exception ex) + catch { API.CreateInfoboxSession("Error", "File Skimmer could not create the directory.", infobox.InfoboxMode.Info); } @@ -598,7 +593,7 @@ namespace ShiftOS txtfilename.Text = itm.Text; } } - catch(Exception ex) + catch { } diff --git a/source/WindowsFormsApplication1/FinalMission/ChooseYourApproach.cs b/source/WindowsFormsApplication1/FinalMission/ChooseYourApproach.cs index 78a8508..c757699 100644 --- a/source/WindowsFormsApplication1/FinalMission/ChooseYourApproach.cs +++ b/source/WindowsFormsApplication1/FinalMission/ChooseYourApproach.cs @@ -17,22 +17,19 @@ namespace ShiftOS.FinalMission { public partial class ChooseYourApproach : Form { - bool Playing = false; - private AudioResourceClient audioClient = null; - + public ChooseYourApproach() { - audioClient = new AudioResourceClient("EndGame;RossBugden"); - InitializeComponent(); - //Music thread. - audioClient.Play("Rapture"); - audioClient.SongFinished += (object s, EventArgs a) => + Audio.Play("endgame"); + Audio.Stopped += (o, a) => { - if (musicEnabled) + if (this != null) { - audioClient.Play("Rapture"); + Audio.Play("endgame"); } }; + InitializeComponent(); + //Music thread. } private void lbdesc_Click(object sender, EventArgs e) @@ -128,9 +125,7 @@ namespace ShiftOS.FinalMission private void onClose(object sender, FormClosingEventArgs e) { - audioClient.Stop(); - audioClient.Dispose(); - audioClient = null; + Audio.ForceStop(); } bool musicEnabled = true; @@ -139,11 +134,11 @@ namespace ShiftOS.FinalMission { if (musicEnabled) { - audioClient.Stop(); + Audio.ForceStop(); } else { - audioClient.Play("Rapture"); + Audio.Play("hackerbattle_ambient"); } musicEnabled = !musicEnabled; } diff --git a/source/WindowsFormsApplication1/GameSettings.Designer.cs b/source/WindowsFormsApplication1/GameSettings.Designer.cs new file mode 100644 index 0000000..809fbb0 --- /dev/null +++ b/source/WindowsFormsApplication1/GameSettings.Designer.cs @@ -0,0 +1,130 @@ +namespace ShiftOS +{ + partial class GameSettings + { + /// + /// 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 Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.panel1 = new System.Windows.Forms.Panel(); + this.label1 = new System.Windows.Forms.Label(); + this.lbgame = new System.Windows.Forms.Label(); + this.pgsound = new ShiftOS.ProgressBarEX(); + this.label2 = new System.Windows.Forms.Label(); + this.panel1.SuspendLayout(); + this.SuspendLayout(); + // + // panel1 + // + this.panel1.Controls.Add(this.label2); + this.panel1.Controls.Add(this.pgsound); + this.panel1.Controls.Add(this.lbgame); + this.panel1.Controls.Add(this.label1); + this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel1.Location = new System.Drawing.Point(0, 0); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(665, 432); + this.panel1.TabIndex = 0; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(0, 0); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(35, 13); + this.label1.TabIndex = 0; + this.label1.Text = "label1"; + // + // lbgame + // + this.lbgame.Dock = System.Windows.Forms.DockStyle.Top; + this.lbgame.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F); + this.lbgame.Location = new System.Drawing.Point(0, 0); + this.lbgame.Name = "lbgame"; + this.lbgame.Size = new System.Drawing.Size(665, 23); + this.lbgame.TabIndex = 1; + this.lbgame.Text = "ShiftOS settings"; + this.lbgame.TextAlign = System.Drawing.ContentAlignment.TopCenter; + // + // pgsound + // + this.pgsound.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.pgsound.BackColor = System.Drawing.Color.White; + this.pgsound.BlockSeparation = 3; + this.pgsound.BlockWidth = 5; + this.pgsound.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.pgsound.Color = System.Drawing.Color.Black; + this.pgsound.ForeColor = System.Drawing.Color.Gray; + this.pgsound.Label = "Music Volume:"; + this.pgsound.Location = new System.Drawing.Point(13, 67); + this.pgsound.MaxValue = 100; + this.pgsound.MinValue = 0; + this.pgsound.Name = "pgsound"; + this.pgsound.Orientation = ShiftOS.ProgressBarEX.ProgressBarOrientation.Horizontal; + this.pgsound.ShowLabel = true; + this.pgsound.ShowValue = true; + this.pgsound.Size = new System.Drawing.Size(640, 32); + this.pgsound.Step = 10; + this.pgsound.Style = ShiftOS.ProgressBarEX.ProgressBarExStyle.Continuous; + this.pgsound.TabIndex = 2; + this.pgsound.Value = 0; + this.pgsound.MouseDown += new System.Windows.Forms.MouseEventHandler(this.set_music_volume); + this.pgsound.MouseLeave += new System.EventHandler(this.pgsound_MouseLeave); + this.pgsound.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pgsound_MouseMove); + // + // label2 + // + this.label2.Dock = System.Windows.Forms.DockStyle.Top; + this.label2.Location = new System.Drawing.Point(0, 23); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(665, 13); + this.label2.TabIndex = 3; + this.label2.Text = "* Click and drag to set any percentage values!"; + this.label2.TextAlign = System.Drawing.ContentAlignment.TopCenter; + // + // GameSettings + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(665, 432); + this.Controls.Add(this.panel1); + this.Name = "GameSettings"; + this.Text = "GameSettings"; + this.panel1.ResumeLayout(false); + this.panel1.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Panel panel1; + private ProgressBarEX pgsound; + private System.Windows.Forms.Label lbgame; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + } +} \ No newline at end of file diff --git a/source/WindowsFormsApplication1/GameSettings.cs b/source/WindowsFormsApplication1/GameSettings.cs new file mode 100644 index 0000000..0d3bdc0 --- /dev/null +++ b/source/WindowsFormsApplication1/GameSettings.cs @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace ShiftOS +{ + public partial class GameSettings : Form + { + public GameSettings() + { + InitializeComponent(); + SetupUI(); + } + + public void SetupUI() + { + pgsound.MaxValue = 100; + pgsound.Value = Audio._wmp.settings.volume; + } + + bool moving = false; + + private void set_music_volume(object sender, MouseEventArgs e) + { + Audio._wmp.settings.volume = MathEx.LinearInterpolate(0, pgsound.Width, e.X, 0, 100); + moving = true; + SetupUI(); + } + + private void pgsound_MouseLeave(object sender, EventArgs e) + { + moving = false; + } + + private void pgsound_MouseMove(object sender, MouseEventArgs e) + { + if (moving == true) + { + Audio._wmp.settings.volume = MathEx.LinearInterpolate(0, pgsound.Width, e.X, 0, 100); + SetupUI(); + } + } + } +} diff --git a/source/WindowsFormsApplication1/GameSettings.resx b/source/WindowsFormsApplication1/GameSettings.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/source/WindowsFormsApplication1/GameSettings.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + \ No newline at end of file diff --git a/source/WindowsFormsApplication1/HackUI.Designer.cs b/source/WindowsFormsApplication1/HackUI.Designer.cs index 9b58537..6db5640 100644 --- a/source/WindowsFormsApplication1/HackUI.Designer.cs +++ b/source/WindowsFormsApplication1/HackUI.Designer.cs @@ -68,11 +68,23 @@ this.btntogglemusic = new System.Windows.Forms.Button(); this.lbsong = new System.Windows.Forms.Label(); this.panel2 = new System.Windows.Forms.Panel(); + this.pgpong = new System.Windows.Forms.Panel(); + this.lblcountdown = new System.Windows.Forms.Label(); + this.ball = new System.Windows.Forms.Panel(); + this.paddleHuman = new System.Windows.Forms.PictureBox(); + this.paddleComputer = new System.Windows.Forms.Panel(); + this.lbllevelandtime = new System.Windows.Forms.Label(); + this.lblstatsY = new System.Windows.Forms.Label(); + this.lblstatsX = new System.Windows.Forms.Label(); this.pnltutorial = new System.Windows.Forms.Panel(); this.lbtutorial = new System.Windows.Forms.Label(); this.tmrplayerhealthdetect = new System.Windows.Forms.Timer(this.components); this.tmrenemyhealthdetect = new System.Windows.Forms.Timer(this.components); this.tmrredraw = new System.Windows.Forms.Timer(this.components); + this.tmrvisualizer = new System.Windows.Forms.Timer(this.components); + this.pongGameTimer = new System.Windows.Forms.Timer(this.components); + this.counter = new System.Windows.Forms.Timer(this.components); + this.tmrcountdown = new System.Windows.Forms.Timer(this.components); this.tbui.SuspendLayout(); this.pnlenemy.SuspendLayout(); this.pnlyou.SuspendLayout(); @@ -81,6 +93,8 @@ this.pnlpcinfo.SuspendLayout(); this.flcontrols.SuspendLayout(); this.panel2.SuspendLayout(); + this.pgpong.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.paddleHuman)).BeginInit(); this.pnltutorial.SuspendLayout(); this.SuspendLayout(); // @@ -146,7 +160,6 @@ this.txtyourconsole.Name = "txtyourconsole"; this.txtyourconsole.Size = new System.Drawing.Size(662, 348); this.txtyourconsole.TabIndex = 3; - this.txtyourconsole.Text = "PLAYER CONSOLE"; // // pnlyou // @@ -192,7 +205,6 @@ this.txtenemyconsole.Name = "txtenemyconsole"; this.txtenemyconsole.Size = new System.Drawing.Size(662, 347); this.txtenemyconsole.TabIndex = 2; - this.txtenemyconsole.Text = "ENEMY CONSOLE"; // // btnnext // @@ -513,13 +525,14 @@ // this.lbsong.Location = new System.Drawing.Point(336, 0); this.lbsong.Name = "lbsong"; - this.lbsong.Size = new System.Drawing.Size(127, 26); + this.lbsong.Size = new System.Drawing.Size(414, 26); this.lbsong.TabIndex = 3; this.lbsong.Text = "Codepoints:"; this.lbsong.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // panel2 // + this.panel2.Controls.Add(this.pgpong); this.panel2.Controls.Add(this.pnltutorial); this.panel2.Controls.Add(this.pnlbuy); this.panel2.Controls.Add(this.pnlpcinfo); @@ -532,6 +545,96 @@ this.panel2.Size = new System.Drawing.Size(1339, 741); this.panel2.TabIndex = 1; // + // pgpong + // + this.pgpong.BackColor = System.Drawing.Color.Black; + this.pgpong.Controls.Add(this.lblcountdown); + this.pgpong.Controls.Add(this.ball); + this.pgpong.Controls.Add(this.paddleHuman); + this.pgpong.Controls.Add(this.paddleComputer); + this.pgpong.Controls.Add(this.lbllevelandtime); + this.pgpong.Controls.Add(this.lblstatsY); + this.pgpong.Controls.Add(this.lblstatsX); + this.pgpong.ForeColor = System.Drawing.Color.White; + this.pgpong.Location = new System.Drawing.Point(0, 0); + this.pgpong.Name = "pgpong"; + this.pgpong.Size = new System.Drawing.Size(700, 400); + this.pgpong.TabIndex = 22; + this.pgpong.Visible = false; + this.pgpong.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pongMain_MouseMove); + // + // lblcountdown + // + this.lblcountdown.Font = new System.Drawing.Font("Microsoft Sans Serif", 24F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lblcountdown.Location = new System.Drawing.Point(187, 152); + this.lblcountdown.Name = "lblcountdown"; + this.lblcountdown.Size = new System.Drawing.Size(315, 49); + this.lblcountdown.TabIndex = 7; + this.lblcountdown.Text = "3"; + this.lblcountdown.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.lblcountdown.Visible = false; + // + // ball + // + this.ball.BackColor = System.Drawing.Color.Gray; + this.ball.Location = new System.Drawing.Point(300, 152); + this.ball.Name = "ball"; + this.ball.Size = new System.Drawing.Size(20, 20); + this.ball.TabIndex = 2; + // + // paddleHuman + // + this.paddleHuman.BackColor = System.Drawing.Color.Gray; + this.paddleHuman.Location = new System.Drawing.Point(10, 134); + this.paddleHuman.Name = "paddleHuman"; + this.paddleHuman.Size = new System.Drawing.Size(20, 100); + this.paddleHuman.TabIndex = 3; + this.paddleHuman.TabStop = false; + // + // paddleComputer + // + this.paddleComputer.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Right))); + this.paddleComputer.BackColor = System.Drawing.Color.Gray; + this.paddleComputer.Location = new System.Drawing.Point(666, 134); + this.paddleComputer.MaximumSize = new System.Drawing.Size(20, 100); + this.paddleComputer.Name = "paddleComputer"; + this.paddleComputer.Size = new System.Drawing.Size(20, 100); + this.paddleComputer.TabIndex = 1; + // + // lbllevelandtime + // + this.lbllevelandtime.Dock = System.Windows.Forms.DockStyle.Top; + this.lbllevelandtime.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lbllevelandtime.Location = new System.Drawing.Point(0, 0); + this.lbllevelandtime.Name = "lbllevelandtime"; + this.lbllevelandtime.Size = new System.Drawing.Size(700, 22); + this.lbllevelandtime.TabIndex = 4; + this.lbllevelandtime.Text = "Level: 1"; + this.lbllevelandtime.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // lblstatsY + // + this.lblstatsY.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.lblstatsY.Font = new System.Drawing.Font("Georgia", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lblstatsY.Location = new System.Drawing.Point(542, 356); + this.lblstatsY.Name = "lblstatsY"; + this.lblstatsY.Size = new System.Drawing.Size(144, 35); + this.lblstatsY.TabIndex = 11; + this.lblstatsY.Text = "Yspeed:"; + this.lblstatsY.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // lblstatsX + // + this.lblstatsX.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.lblstatsX.Font = new System.Drawing.Font("Georgia", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lblstatsX.Location = new System.Drawing.Point(3, 356); + this.lblstatsX.Name = "lblstatsX"; + this.lblstatsX.Size = new System.Drawing.Size(144, 35); + this.lblstatsX.TabIndex = 5; + this.lblstatsX.Text = "Xspeed: "; + this.lblstatsX.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // // pnltutorial // this.pnltutorial.Controls.Add(this.btnnext); @@ -565,6 +668,25 @@ // this.tmrredraw.Tick += new System.EventHandler(this.tmrredraw_Tick); // + // tmrvisualizer + // + this.tmrvisualizer.Tick += new System.EventHandler(this.tmrvisualizer_Tick); + // + // pongGameTimer + // + this.pongGameTimer.Interval = 30; + this.pongGameTimer.Tick += new System.EventHandler(this.pongGameTimer_Tick); + // + // counter + // + this.counter.Interval = 1000; + this.counter.Tick += new System.EventHandler(this.counter_Tick); + // + // tmrcountdown + // + this.tmrcountdown.Interval = 1000; + this.tmrcountdown.Tick += new System.EventHandler(this.tmrcountdown_Tick); + // // HackUI // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 11F); @@ -594,6 +716,8 @@ this.flcontrols.ResumeLayout(false); this.flcontrols.PerformLayout(); this.panel2.ResumeLayout(false); + this.pgpong.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.paddleHuman)).EndInit(); this.pnltutorial.ResumeLayout(false); this.pnltutorial.PerformLayout(); this.ResumeLayout(false); @@ -645,5 +769,17 @@ private System.Windows.Forms.Label lbsong; private System.Windows.Forms.Panel pnltutorial; private System.Windows.Forms.Label lbtutorial; + private System.Windows.Forms.Timer tmrvisualizer; + internal System.Windows.Forms.Panel pgpong; + internal System.Windows.Forms.Label lblcountdown; + internal System.Windows.Forms.Panel ball; + internal System.Windows.Forms.PictureBox paddleHuman; + internal System.Windows.Forms.Panel paddleComputer; + internal System.Windows.Forms.Label lbllevelandtime; + internal System.Windows.Forms.Label lblstatsY; + internal System.Windows.Forms.Label lblstatsX; + internal System.Windows.Forms.Timer pongGameTimer; + internal System.Windows.Forms.Timer counter; + internal System.Windows.Forms.Timer tmrcountdown; } } \ No newline at end of file diff --git a/source/WindowsFormsApplication1/HackUI.cs b/source/WindowsFormsApplication1/HackUI.cs index 09841d6..ee36b8f 100644 --- a/source/WindowsFormsApplication1/HackUI.cs +++ b/source/WindowsFormsApplication1/HackUI.cs @@ -5,6 +5,7 @@ using System.Data; using System.Drawing; using System.Linq; using System.Text; +using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; @@ -15,6 +16,7 @@ namespace ShiftOS public HackUI() { InitializeComponent(); + this.TopMost = false; ThisEnemyHacker = new EnemyHacker("Test Dummy", "A test hacker", "A test hacker", 1, 1, "easy"); } @@ -104,11 +106,16 @@ namespace ShiftOS { if (pc.Disabled == false) { - if (pc.Enemies != null) + var elist = new List(); + if (pc.Enslaved) + elist = AllPlayerComputers; + else + elist = pc.Enemies; + if (elist != null) { - foreach (var enemy in pc.Enemies) + foreach (var enemy in elist) { - if (AllEnemyComputers.Contains(enemy)) + if (enemy != null && enemy.HP > 0) { chance = rnd.Next(1, 15); if (chance == 7) @@ -150,7 +157,7 @@ namespace ShiftOS } if (ThisPlayerPC.HP <= 0) { - API.CreateInfoboxSession("System compromised.", "The enemy hacker has overthrown your defenses and compromised your system. You will need to wait an hour before you can start another hack battle.", infobox.InfoboxMode.Info); + API.CreateInfoboxSession("System compromised.", "The enemy hacker has overthrown your defenses and compromised your system. You will need to wait until your core heals before beginning another battle.", infobox.InfoboxMode.Info); Hacking.Failure = true; Hacking.FailDate = DateTime.Now; UserRequestedClose = false; @@ -162,16 +169,35 @@ namespace ShiftOS private void this_Closing(object sender, FormClosingEventArgs e) { + var t = new Thread(new ThreadStart(() => + { + int prev_volume = Audio._wmp.settings.volume; + while(Audio._wmp.settings.volume > 0) + { + Thread.Sleep(100); + Audio._wmp.settings.volume -= 1; + } + Audio.ForceStop(); + Audio._wmp.settings.volume = prev_volume; + })); + t.Start(); if (UserRequestedClose == false) { - arc.Dispose(); - Computer[] pcs = { }; + this.TopMost = false; + Computer[] pcs = new Computer[AllPlayerComputers.Count]; AllPlayerComputers.CopyTo(pcs); - foreach(var pc in pcs) + foreach (var pc in pcs) { - pc.Dispose(); + pc?.Dispose(); + } + Computer[] epcs = new Computer[AllEnemyComputers.Count]; + AllEnemyComputers.CopyTo(epcs); + foreach (var epc in epcs) + { + epc?.Dispose(); } tmrplayerhealthdetect.Stop(); + tmrenemyhealthdetect.Stop(); Hacking.RepairTimer.Start(); //Now the player can repair. } else @@ -182,6 +208,8 @@ namespace ShiftOS public Computer SelectedPlayerComputer = null; + public Computer module_to_steal = null; + public void AddModule(Computer newModule) { pnlyou.Controls.Add(newModule); @@ -190,6 +218,49 @@ namespace ShiftOS TotalPlayerHP += newModule.HP; AllPlayerComputers.Add(newModule); newModule.Show(); + newModule.StolenModule += (o, a) => + { + var t = new Thread(new ThreadStart(() => + { + var rnd = new Random(); + var lst = new List(); + if (newModule.Enslaved) + lst = AllPlayerComputers; + else + lst = AllEnemyComputers; + WriteLine($"[{newModule.Hostname}] Starting network hack..."); + Thread.Sleep(5000); + + var pc = lst[rnd.Next(0, lst.Count)]; + this.Invoke(new Action(() => + { + if (pc.Type != SystemType.Core) + { + module_to_steal = pc; + + pgpong.Left = (this.Width - pgpong.Width) / 2; + pgpong.Top = (this.Height - pgpong.Height) / 2; + + pgpong.Show(); + newgame(); + } + })); + })); + t.Start(); + }; + newModule.EnslavedModule += (o, e) => + { + if(!newModule.Enslaved) + { + var pc = AllEnemyComputers[rand.Next(0, AllEnemyComputers.Count)]; + if(!pc.Enslaved) + { + WriteLine($"[{newModule.Hostname}] Successfully enslaved {pc.Hostname}"); + pc.Enslaved = true; + } + + } + }; newModule.OnDestruction += (object s, EventArgs a) => { if (this.SelectedPlayerComputer == newModule) @@ -268,7 +339,10 @@ namespace ShiftOS { newModule.MassDDoS += (object s, EventArgs a) => { - WormToEnemy(); + if (newModule.Enslaved) + WormToPlayer(); + else + WormToEnemy(); }; } } @@ -289,6 +363,15 @@ namespace ShiftOS public void ShowPCInfo(string hostname) { + Computer c = null; + foreach (var pc in AllPlayerComputers) + { + if (pc.Hostname == hostname) + { + c = pc; + } + } + Module mod = null; foreach (var m in GetMyNet()) { @@ -302,7 +385,7 @@ namespace ShiftOS pnlpcinfo.Left = 7; pnlpcinfo.Show(); lbmoduletitle.Text = "Module Info - " + hostname; - lbpcinfo.Text = $"Hostname: {hostname}{Environment.NewLine}Type: {mod.Type.ToString()}"; + lbpcinfo.Text = $"Hostname: {hostname}{Environment.NewLine}Type: {mod.Type.ToString()}{Environment.NewLine}{Environment.NewLine}"; if (mod.Type == SystemType.Core) { lbpcinfo.Text += Environment.NewLine + "This represents your main system. If this module is destroyed, you will automatically lose the battle. Protect it at all costs."; @@ -322,37 +405,37 @@ namespace ShiftOS } btnpoweroff.Show(); } - } - Computer c = null; - foreach (var pc in AllPlayerComputers) - { - if (pc.Hostname == hostname) - { - c = pc; - } + } if (c != null) { - lbtargets.Text = "Targets: "; - if (c.Enemies != null) + if (c.Enslaved) { - if (c.Enemies.Count > 0) + lbtargets.Text = "*** WARNING ***: This module has been ENSLAVED! Consider a redeploy."; + } + else + { + lbtargets.Text = "Targets: "; + if (c.Enemies != null) { - foreach (var pc in c.Enemies) + if (c.Enemies.Count > 0) { - lbtargets.Text += " " + pc.Hostname + ","; + foreach (var pc in c.Enemies) + { + lbtargets.Text += " " + pc.Hostname + ","; + } + } + else + { + lbtargets.Text += " - Click on an enemy module to target it."; } } else { lbtargets.Text += " - Click on an enemy module to target it."; } + lbtargets.Text += Environment.NewLine + "Some modules will not fire at their targets."; } - else - { - lbtargets.Text += " - Click on an enemy module to target it."; - } - lbtargets.Text += Environment.NewLine + "Some modules will not fire at their targets."; } } @@ -514,7 +597,7 @@ namespace ShiftOS { SystemType type = FutureModules[cmbmodules.Text]; } - catch (Exception ex) + catch { cont = false; API.CreateInfoboxSession("Error", "Please select a module type.", infobox.InfoboxMode.Info); @@ -680,7 +763,7 @@ namespace ShiftOS } SetupModuleInfo(); } - catch (Exception ex) + catch { txtgrade.Text = "1"; SetupModuleInfo(); @@ -982,18 +1065,24 @@ namespace ShiftOS private void HackUI_Load(object sender, EventArgs e) { + this.TopMost = false; + Audio.Stopped += (o, a) => + { + if (this != null) + { + Audio.Play("hackerbattle_ambient"); + } + }; + Audio.Play("hackerbattle_ambient"); + Hacking.RepairTimer.Stop(); //Don't want the player to be able to repair dead modules during a battle! this.TopMost = true; - arc = new AudioResourceClient("HackerBattle"); - arc.SongFinished += (object s, EventArgs a) => - { - arc.PlayRandom(); - }; - arc.PlayRandom(); this.WindowState = FormWindowState.Maximized; //this.TopMost = true; LoadPlayerScreen(); LoadEnemyScreen(); + tmrvisualizer.Interval = 10; + tmrvisualizer.Start(); } #region ENEMY @@ -1056,6 +1145,49 @@ namespace ShiftOS int hp = newModule.HP; TotalEnemyHP += (decimal)newModule.HP; newModule.Show(); + + newModule.StolenModule += (o, a) => + { + var t = new Thread(new ThreadStart(() => + { + var lst = new List(); + if (!newModule.Enslaved) + lst = AllPlayerComputers; + else + lst = AllEnemyComputers; + WriteLine_Enemy($"[{newModule.Hostname}] Starting network hack..."); + Thread.Sleep(5000); + + var pc = lst[rnd.Next(0, lst.Count)]; + this.Invoke(new Action(() => + { + if (pc.Type != SystemType.Core) + { + module_to_steal = pc; + + pgpong.Left = (this.Width - pgpong.Width) / 2; + pgpong.Top = (this.Height - pgpong.Height) / 2; + + pgpong.Show(); + newgame(); + } + })); + })); + t.Start(); + }; + newModule.EnslavedModule += (o, e) => + { + if (!newModule.Enslaved) + { + var pc = AllPlayerComputers[rand.Next(0, AllPlayerComputers.Count)]; + if (!pc.Enslaved) + { + WriteLine_Enemy($"[{newModule.Hostname}] Successfully enslaved {pc.Hostname}"); + pc.Enslaved = true; + } + + } + }; newModule.OnDestruction += (object s, EventArgs a) => { if (this.SelectedEnemyComputer == newModule) @@ -1134,7 +1266,10 @@ namespace ShiftOS { newModule.MassDDoS += (object s, EventArgs a) => { - WormToPlayer(); + if (newModule.Enslaved) + WormToEnemy(); + else + WormToPlayer(); }; } } @@ -1142,7 +1277,7 @@ namespace ShiftOS public void Enemy_Firewall_Deflect(Computer fwall) { //Safeguard... also apparently I can't spell... because this used to be 'Safegaurd'... - if (fwall.Type == SystemType.Firewall) + if (fwall.Enslaved == false && fwall.Type == SystemType.Firewall) { var r = fwall.GetAreaOfEffect(); foreach (var pc in AllEnemyComputers) @@ -1218,13 +1353,10 @@ namespace ShiftOS private void tmrenemyhealthdetect_Tick(object sender, EventArgs e) { - lbsong.Visible = Audio.Enabled; - btntogglemusic.Visible = Audio.Enabled; + lbsong.Visible = true; + btntogglemusic.Visible = true; - if(arc != null) - { - lbsong.Text = $"Ross Bugden - {arc.CurrentSong}"; - } + lbsong.Text = Audio.Name + " @ " + Audio.CurrentPosition; decimal health = 0; lbcodepoints.Text = $"Codepoints: {API.Codepoints}"; @@ -1234,7 +1366,12 @@ namespace ShiftOS { if (pc.Disabled == false) { - foreach (var enemy in AllPlayerComputers) + var elist = new List(); + if (pc.Enslaved) + elist = AllEnemyComputers; + else + elist = AllPlayerComputers; + foreach (var enemy in elist) { chance = rnd.Next(1, 20); if (chance == 10) @@ -1282,7 +1419,7 @@ namespace ShiftOS string message = "You have successfully beaten the enemy hacker."; if (ThisEnemyHacker.IsLeader == false) { - switch(rnd.Next(0, 5)) + switch(rnd.Next(0, 6)) { case 1: API.AddCodepoints(1000); @@ -1305,6 +1442,15 @@ namespace ShiftOS var name = ThisEnemyHacker.Name; Hacking.AddCharacter(new Character(name, desc, skill, speed, 0)); break; + case 5: + var cats = SaveSystem.ShiftoriumRegistry.GetCategories(false); + string cat = cats[rnd.Next(0, cats.Count - 1)]; + if (API.Upgrades[cat] == false) + { + API.Upgrades[cat] = true; + message = $"You have beaten the enemy, and as a result, the {cat.ToUpper()} Shiftorium category has been unlocked."; + } + break; default: message = "You have successfully beaten the enemy hacker."; break; @@ -1344,42 +1490,432 @@ namespace ShiftOS public void WriteLine_Enemy(string text) { - if(txtenemyconsole.Text.Length == 0) + try { - txtenemyconsole.Text = text + Environment.NewLine; + if (txtenemyconsole.Text.Length == 0) + { + txtenemyconsole.Text = text + Environment.NewLine; + } + else + { + txtenemyconsole.Text += text + Environment.NewLine; + } + txtenemyconsole.Select(txtenemyconsole.TextLength, 0); + txtenemyconsole.ScrollToCaret(); } - else + catch { - txtenemyconsole.Text += text + Environment.NewLine; + this.Invoke(new Action(() => { WriteLine_Enemy(text); })); } - txtenemyconsole.Select(txtenemyconsole.TextLength, 0); - txtenemyconsole.ScrollToCaret(); } public void WriteLine(string text) { - if (txtyourconsole.Text.Length == 0) + try { - txtyourconsole.Text = text + Environment.NewLine; + if (txtyourconsole.Text.Length == 0) + { + txtyourconsole.Text = text + Environment.NewLine; + } + else + { + txtyourconsole.Text += text + Environment.NewLine; + } + txtyourconsole.Select(txtyourconsole.TextLength, 0); + txtyourconsole.ScrollToCaret(); } - else + catch { - txtyourconsole.Text += text + Environment.NewLine; + this.Invoke(new Action(() => { WriteLine(text); })); } - txtyourconsole.Select(txtyourconsole.TextLength, 0); - txtyourconsole.ScrollToCaret(); } #endregion - AudioResourceClient arc = null; - bool musicenabled = true; + bool playing = true; private void button2_Click(object sender, EventArgs e) { - arc.Pause(); + if (playing == true) + { + Audio.ForceStop(); + } + else + { + Audio.Play("hackerbattle_ambient"); + } + playing = !playing; } - + Panel winningPlayfield = null; + + int bgcol = 0; + int pulse = 0; + Panel losingPlayfield = null; + private void tmrvisualizer_Tick(object sender, EventArgs e) + { + int enemy_hp = 0; + int player_hp = 0; + foreach(var p in AllPlayerComputers) + { + player_hp += p.HP; + } + foreach (var p in AllEnemyComputers) + { + enemy_hp += p.HP; + } + + if (player_hp >= enemy_hp) + { + winningPlayfield = pnlyou; + losingPlayfield = pnlenemy; + } + else + { + winningPlayfield = pnlenemy; + losingPlayfield = pnlyou; + } + + losingPlayfield.BackColor = Color.Black; + + + try + { + var visualizer = Audio.GetVisualizer(); + switch(visualizer.type) + { + case VisualizerType.Pulse: + tmrvisualizer.Interval = 1; + if(pulse == 0) + { + if(bgcol < 255) + { + bgcol += 10; + } + else + { + pulse = 1; + } + } + else + { + if(bgcol > 0) + { + bgcol -= 10; + } + else + { + pulse = 0; + } + } + break; + case VisualizerType.CalmDown: + bgcol = 255 - MathEx.LinearInterpolate(visualizer.startTime * 100, visualizer.endTime * 100, Audio.CurrentPositionMS, 0, 255); + break; + case VisualizerType.BuildUp: + bgcol = MathEx.LinearInterpolate(visualizer.startTime, visualizer.endTime, Audio.CurrentPosition, 0, 255); + break; + } + Color c = new Color(); + int r = 0; + int g = 0; + int b = 0; + if (visualizer.R) + r = bgcol; + if (visualizer.G) + g = bgcol; + if (visualizer.B) + b = bgcol; + c = Color.FromArgb(r, g, b); + if(playing) + winningPlayfield.BackColor = c; + } + catch + { + + } + } + + private void pongMain_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) + { + paddleHuman.Location = new Point(paddleHuman.Location.X, (MousePosition.Y - pgpong.Location.Y) - (paddleHuman.Height / 2)); + } + + + private void pongGameTimer_Tick(object sender, EventArgs e) + { + //Set the computer player to move according to the ball's position. + if (ball.Location.X > 500 - xVel * 10 && xVel > 0) + { + if (ball.Location.Y > paddleComputer.Location.Y + 50) + { + paddleComputer.Location = new Point(paddleComputer.Location.X, paddleComputer.Location.Y + computerspeed * 2 + ((int)yveldec / 2)); + } + if (ball.Location.Y < paddleComputer.Location.Y + 50) + { + paddleComputer.Location = new Point(paddleComputer.Location.X, paddleComputer.Location.Y - computerspeed * 2 + ((int)yveldec / 2)); + } + casualposition = rand.Next(-150, 201); + } + + //Set Xvel and Yvel speeds from decimal + if (xVel > 0) + xVel = (int)Math.Round(xveldec); + if (xVel < 0) + xVel = (int)-Math.Round(xveldec); + if (yVel > 0) + yVel = (int)Math.Round(yveldec); + if (yVel < 0) + yVel = (int)-Math.Round(yveldec); + + // Move the game ball. + ball.Location = new Point(ball.Location.X + xVel, ball.Location.Y + yVel); + + // Check for top wall. + if (ball.Location.Y < 0) + { + ball.Location = new Point(ball.Location.X, 0); + yVel = -yVel; + } + + // Check for bottom wall. + if (ball.Location.Y > pgpong.Height - ball.Height) + { + ball.Location = new Point(ball.Location.X, pgpong.Height - ball.Size.Height); + yVel = -yVel; + } + + // Check for player paddle. + if (ball.Bounds.IntersectsWith(paddleHuman.Bounds)) + { + ball.Location = new Point(paddleHuman.Location.X + ball.Size.Width, ball.Location.Y); + //randomly increase x or y speed of ball + switch (rand.Next(1, 3)) + { + case 1: + xveldec = xveldec + incrementx; + break; + case 2: + if (yveldec > 0) + yveldec = yveldec + incrementy; + if (yveldec < 0) + yveldec = yveldec - incrementy; + break; + } + xVel = -xVel; + } + + // Check for computer paddle. + if (ball.Bounds.IntersectsWith(paddleComputer.Bounds)) + { + ball.Location = new Point(paddleComputer.Location.X - paddleComputer.Size.Width + 1, ball.Location.Y); + xveldec = xveldec + incrementx; + xVel = -xVel; + } + + // Check for left wall. + if (ball.Location.X < -100) + { + var m = module_to_steal; + if (m.Enemy) + AllEnemyComputers.Remove(m); + + var lst = new List(); + if (!m.Enemy) + lst = MyNetwork; + else + lst = ThisEnemyHacker.Network; + + string hn = m.Hostname; + + Module mod = null; + foreach(var pc in lst) + { + if(pc.Hostname == hn) + { + mod = pc; + } + } + + if (!AllPlayerComputers.Contains(m)) + AddModule(mod.Deploy()); + + if(!Hacking.MyNetwork.Contains(mod)) + { + Hacking.MyNetwork.Add(mod); + } + + if(module_to_steal.Parent != pnlyou) + { + module_to_steal.Parent.Controls.Remove(module_to_steal); + module_to_steal.Dispose(); + } + tmrcountdown.Stop(); + pongGameTimer.Stop(); + counter.Stop(); + pgpong.Hide(); + } + + // Check for right wall. + if (ball.Location.X > pgpong.Width - ball.Size.Width - paddleComputer.Width + 100) + { + var m = module_to_steal; + if (!m.Enemy) + AllPlayerComputers.Remove(m); + + var lst = new List(); + if (!m.Enemy) + lst = MyNetwork; + else + lst = ThisEnemyHacker.Network; + + string hn = m.Hostname; + + Module mod = null; + foreach (var pc in lst) + { + if (pc.Hostname == hn) + { + mod = pc; + } + } + + if (!AllEnemyComputers.Contains(m)) + AddEnemyModule(mod.Deploy()); + + if (!ThisEnemyHacker.Network.Contains(mod)) + { + ThisEnemyHacker.Network.Add(mod); + } + + if (module_to_steal.Parent != pnlenemy) + { + module_to_steal.Parent.Controls.Remove(module_to_steal); + module_to_steal.Dispose(); + } + tmrcountdown.Stop(); + pongGameTimer.Stop(); + counter.Stop(); + pgpong.Hide(); + } + + //lblstats.Text = "Xspeed: " & Math.Abs(xVel) & " Yspeed: " & Math.Abs(yVel) & " Human Location: " & paddleHuman.Location.ToString & " Computer Location: " & paddleComputer.Location.ToString & Environment.NewLine & " Ball Location: " & ball.Location.ToString & " Xdec: " & xveldec & " Ydec: " & yveldec & " Xinc: " & incrementx & " Yinc: " & incrementy + lblstatsX.Text = "Xspeed: " + xveldec; + lblstatsY.Text = "Yspeed: " + yveldec; + + lbllevelandtime.Text = "Level: " + level; + + if (xVel > 20 || xVel < -20) + { + paddleHuman.Width = Math.Abs(xVel); + paddleComputer.Width = Math.Abs(xVel); + } + else + { + paddleHuman.Width = 20; + paddleComputer.Width = 20; + } + + computerspeed = Math.Abs(yVel); + + // pgcontents.Refresh() + // pgcontents.CreateGraphics.FillRectangle(Brushes.Black, ball.Location.X, ball.Location.Y, ball.Width, ball.Height) + + } + + #region pong visualizer variables + + Random rand = new Random(); + int xVel = 7; + int yVel = 8; + int computerspeed = 8; + int level = 1; + int secondsleft = 60; + int casualposition; + double xveldec = 3.0; + double yveldec = 3.0; + double incrementx = 0.4; + double incrementy = 0.2; + int levelxspeed = 3; + int levelyspeed = 3; + int[] levelrewards = new int[50]; + int countdown = 3; + + #endregion + + private void counter_Tick(object sender, EventArgs e) + { + secondsleft = secondsleft - 1; + if (secondsleft == -1) + { + secondsleft = 60; + level = level + 1; + } + } + + private void tmrcountdown_Tick(object sender, EventArgs e) + { + switch (countdown) + { + case 0: + countdown = 3; + lblcountdown.Hide(); + pongGameTimer.Start(); + counter.Start(); + tmrcountdown.Stop(); + break; + case 1: + lblcountdown.Text = "1"; + countdown = countdown - 1; + break; + case 2: + lblcountdown.Text = "2"; + countdown = countdown - 1; + break; + case 3: + lblcountdown.Text = "3"; + countdown = countdown - 1; + lblcountdown.Show(); + break; + } + + } + + private void newgame() + { + level = 1; + secondsleft = 60; + //reset stats text + lblstatsX.Text = "Xspeed: "; + lblstatsY.Text = "Yspeed: "; + + levelxspeed = 3; + levelyspeed = 3; + + incrementx = 0.4; + incrementy = 0.2; + + xveldec = levelxspeed; + yveldec = levelyspeed; + + tmrcountdown.Start(); + if (xVel < 0) + xVel = Math.Abs(xVel); + lbllevelandtime.Text = "Level: " + level + " - " + secondsleft + " Seconds Left"; + } + } +} + +namespace System +{ + public class MathEx + { + public static int LinearInterpolate(int input_start, int input_end, int input, int output_start, int output_end) + { + int input_range = input_end - input_start; + int output_range = output_end - output_start; + + return (input - input_start) * output_range / input_range + output_start; + } } } diff --git a/source/WindowsFormsApplication1/HackUI.resx b/source/WindowsFormsApplication1/HackUI.resx index 7ec36cf..9def72b 100644 --- a/source/WindowsFormsApplication1/HackUI.resx +++ b/source/WindowsFormsApplication1/HackUI.resx @@ -162,4 +162,16 @@ If you would like to buy a new module, click 'Buy new module'. 191, 17 + + 238, 42 + + + 358, 42 + + + 501, 42 + + + 594, 42 + \ No newline at end of file diff --git a/source/WindowsFormsApplication1/Hacking.cs b/source/WindowsFormsApplication1/Hacking.cs index ba54532..7b18852 100644 --- a/source/WindowsFormsApplication1/Hacking.cs +++ b/source/WindowsFormsApplication1/Hacking.cs @@ -139,7 +139,7 @@ namespace ShiftOS f.Font = new Font(OSInfo.GetMonospaceFont(), 9); var l = new Label(); int p = 0; - int speed = 100000 / h.Speed; //If a hacker has a speed of one, it will take 100,000 milliseconds to move 1% in the hack progress. Divide it by a thousand, you get 10,000 seconds. + int speed = 10000 / h.Speed; //If a hacker has a speed of one, it will take 10,000 milliseconds to move 1% in the hack progress. Divide it by a thousand, you get 1,000 seconds. var t = new Timer(); t.Interval = speed; f.FormBorderStyle = FormBorderStyle.None; @@ -169,7 +169,7 @@ namespace ShiftOS { l.Text = $"Progress: {p}%"; int fail = new Random().Next(0, h.Skill * h.Speed); - if (fail == h.Skill / 2) + if (fail == 1) { l.Text = "Hack failed."; } @@ -201,6 +201,8 @@ namespace ShiftOS { var lst = new List(); lst.Add(new FutureModule("Antivirus", 15, "This module will heal any other module within it's area of effect to 10 HP. Higher grades can improve it's area of effect.", SystemType.Antivirus)); + lst.Add(new FutureModule("Enslaver", 75, "The Enslaver is a scary module for an opposing network. At any time, the Enslaver can take over any module on the enemy network and turn it against them.", SystemType.Enslaver)); + lst.Add(new FutureModule("Module Thief", 100, "The Module Thief can hack into the enemy's network and attempt to steal one of their modules and bring them into your network temporarily though. Be careful though, it might not work all the time!", SystemType.ModuleStealer)); lst.Add(new FutureModule("Dedicated DDoS module", 10, "This module will attempt to disable the enemy network by sending a DDoS attack allowing you to take a breather.", SystemType.DedicatedDDoS)); lst.Add(new FutureModule("Turret", 5, "It's not super-effective, but the Turret will blast through any Grade 1 defenses pretty quickly. The higher the grade, the higher the strength.", SystemType.Turret)); lst.Add(new FutureModule("Firewall", 20, "Will decrease the amount of damage taken by any module within it's area of effect. The higher the grade, the bigger the area of effect and more protection it offers.", SystemType.Firewall)); @@ -228,7 +230,7 @@ namespace ShiftOS f.Font = new Font(OSInfo.GetMonospaceFont(), 9); var l = new Label(); int p = 0; - int speed = 100000 / h.Speed; //If a hacker has a speed of one, it will take 100,000 milliseconds to move 1% in the hack progress. Divide it by a thousand, you get 10,000 seconds. + int speed = 10000 / h.Speed; //If a hacker has a speed of one, it will take 10,000 milliseconds to move 1% in the hack progress. Divide it by a thousand, you get 1,000 seconds. var t = new Timer(); t.Interval = speed; f.FormBorderStyle = FormBorderStyle.None; @@ -257,8 +259,8 @@ namespace ShiftOS if (p <= 100) { l.Text = $"Progress: {p}%"; - int fail = new Random().Next(0, h.Skill + h.Speed); - if (fail == h.Skill / 2) + int fail = new Random().Next(0, h.Skill * h.Speed); + if (fail == 1) { l.Text = "Hack failed."; } @@ -342,7 +344,7 @@ namespace ShiftOS break; } } - catch(Exception ex) + catch { t.Stop(); var tr = new Terminal(); @@ -553,6 +555,15 @@ namespace ShiftOS /// public static void SaveCharacters() { + if (MyNetwork == null) + { + MyNetwork = new List(); + var c = new Module(SystemType.Core, 1, "localhost"); + c.HP = 100; //bugfix: core not appearing during battle on new save + c.X = 0; + c.Y = 0; + MyNetwork.Add(c); + } File.WriteAllText(Paths.SystemDir + "_hackers.json", API.Encryption.Encrypt(JsonConvert.SerializeObject(Characters))); File.WriteAllText(Paths.SystemDir + "_hacktools.json", API.Encryption.Encrypt(JsonConvert.SerializeObject(Tools))); File.WriteAllText(Paths.Drivers + "Network.dri", API.Encryption.Encrypt(JsonConvert.SerializeObject(MyNetwork))); diff --git a/source/WindowsFormsApplication1/Hacking_Enemy.cs b/source/WindowsFormsApplication1/Hacking_Enemy.cs index 8cec39f..3f6ab63 100644 --- a/source/WindowsFormsApplication1/Hacking_Enemy.cs +++ b/source/WindowsFormsApplication1/Hacking_Enemy.cs @@ -285,7 +285,7 @@ namespace ShiftOS } } } - catch(Exception ex) + catch { } diff --git a/source/WindowsFormsApplication1/Hacking_YourHealth.cs b/source/WindowsFormsApplication1/Hacking_YourHealth.cs index 6166e93..b6689fc 100644 --- a/source/WindowsFormsApplication1/Hacking_YourHealth.cs +++ b/source/WindowsFormsApplication1/Hacking_YourHealth.cs @@ -488,7 +488,7 @@ namespace ShiftOS { SystemType type = FutureModules[cmbmodules.Text]; } - catch (Exception ex) + catch { cont = false; API.CreateInfoboxSession("Error", "Please select a module type.", infobox.InfoboxMode.Info); @@ -654,7 +654,7 @@ namespace ShiftOS } SetupModuleInfo(); } - catch(Exception ex) + catch { txtgrade.Text = "1"; SetupModuleInfo(); diff --git a/source/WindowsFormsApplication1/IconManager.cs b/source/WindowsFormsApplication1/IconManager.cs index 0f5002e..2ffa24a 100644 --- a/source/WindowsFormsApplication1/IconManager.cs +++ b/source/WindowsFormsApplication1/IconManager.cs @@ -48,7 +48,7 @@ namespace ShiftOS IconControl ic = (IconControl)ctrl; Skinning.Utilities.IconRegistry[ic.IconName] = ic.LargeImage; } - catch(Exception ex) + catch { IconControl ic = (IconControl)ctrl; Skinning.Utilities.IconRegistry.Add(ic.IconName, ic.LargeImage); @@ -105,7 +105,7 @@ namespace ShiftOS API.IconRegistry[finf.Name] = Image.FromStream(stream); } } - catch (Exception ex) + catch { API.IconRegistry.Add(finf.Name, Image.FromFile(finf.FullName)); } diff --git a/source/WindowsFormsApplication1/KnowledgeInput.cs b/source/WindowsFormsApplication1/KnowledgeInput.cs index fdb9f81..a494a93 100644 --- a/source/WindowsFormsApplication1/KnowledgeInput.cs +++ b/source/WindowsFormsApplication1/KnowledgeInput.cs @@ -31,7 +31,6 @@ namespace ShiftOS bool levelup; int rewardbase; - string[] savecontent; int totalguessed; int level; @@ -314,8 +313,6 @@ namespace ShiftOS } } - int chance = 101; - // ERROR: Handles clauses are not supported in C# // ERROR: Handles clauses are not supported in C# private void me_closing() diff --git a/source/WindowsFormsApplication1/Lua_Interp.cs b/source/WindowsFormsApplication1/Lua_Interp.cs index 80841de..ab87fa7 100644 --- a/source/WindowsFormsApplication1/Lua_Interp.cs +++ b/source/WindowsFormsApplication1/Lua_Interp.cs @@ -111,6 +111,90 @@ namespace ShiftOS /// public void RegisterCore() { + //Shifter Extension API + mod.shifter_add_category = new Action((name) => + { + bool add = true; + if(API.LuaShifterRegistry == null) + { + API.LuaShifterRegistry = new Dictionary>(); + } + foreach(var kv in API.LuaShifterRegistry) + { + if (kv.Key == name) + add = false; + } + if(add == true) + { + API.LuaShifterRegistry.Add(name, new Dictionary()); + } + else + { + Errors.Add($"shifter_add_category(\"{name}\"): Error: Category already exists!"); + } + }); + mod.shifter_remove_category = new Action((name) => + { + if(API.LuaShifterRegistry.ContainsKey(name)) + { + API.LuaShifterRegistry.Remove(name); + } + else + { + Errors.Add($"shifter_remove_category(\"{name}\"): No such category."); + } + }); + mod.shifter_add_value = new Action((cat, name, in_value) => + { + if(API.LuaShifterRegistry.ContainsKey(cat)) + { + var lst = API.LuaShifterRegistry[cat]; + if(!lst.ContainsKey(name)) + { + lst.Add(name, in_value); + } + else + { + Errors.Add($"shifter_add_value(\"{cat}\", \"{name}\", in_value): Category was found, but it already contained a value with the specified name."); + } + } + else + { + Errors.Add($"shifter_add_value(\"{cat}\", \"{name}\", in_value): Category not found."); + } + }); + mod.shifter_get_value = new Func((cat, name) => + { + if (API.LuaShifterRegistry.ContainsKey(cat)) + { + var lst = API.LuaShifterRegistry[cat]; + if (lst.ContainsKey(name)) + { + return lst[name]; + } + else + { + Errors.Add($"shifter_add_value(\"{cat}\", \"{name}\", in_value): Category was found, but it already contained a value with the specified name."); + return null; + } + } + else + { + Errors.Add($"shifter_add_value(\"{cat}\", \"{name}\", in_value): Category not found."); + return null; + } + }); + + + //APIs. + mod.load_api = new Action((name) => + { + if(File.Exists(Paths.APIs + name + ".lua")) + { + mod(File.ReadAllText(Paths.APIs + name + ".lua")); + } + }); + //Functions with Return Values mod.get_app_launcher_items = new Func>(() => { @@ -159,7 +243,7 @@ namespace ShiftOS { return Color.FromArgb(r, g, b); } - catch(Exception ex) + catch { Errors.Add("Invalid color values. Values must be a minimum of 0 and a maximum of 255."); return new Color(); @@ -497,7 +581,7 @@ namespace ShiftOS i = it; } } - catch(Exception ex) + catch { } @@ -959,7 +1043,6 @@ namespace ShiftOS return ctrl; } - private bool Beeping = false; /// /// Broken, piece of dump beep function. diff --git a/source/WindowsFormsApplication1/Package_Grabber.cs b/source/WindowsFormsApplication1/Package_Grabber.cs index 3ea29d0..b6bbc61 100644 --- a/source/WindowsFormsApplication1/Package_Grabber.cs +++ b/source/WindowsFormsApplication1/Package_Grabber.cs @@ -98,7 +98,7 @@ namespace ShiftOS client.Connect(address, port); clients.Add(client.RemoteHost, client); } - catch (Exception ex) + catch { } } @@ -191,7 +191,7 @@ namespace ShiftOS wc.DownloadFile("http://playshiftos.ml/shiftnet/packages/" + pkgname + ".pkg", downloadpath + pkgname + ".pkg"); LastPackage_DownloadPath = downloadpath + pkgname + ".pkg"; } - catch (WebException wex) + catch { result = false; } @@ -248,7 +248,7 @@ namespace ShiftOS ZipFile.ExtractToDirectory(localpath, packagedir); return packagedir; } - catch (Exception ex) + catch { return "fail"; } diff --git a/source/WindowsFormsApplication1/Paths.cs b/source/WindowsFormsApplication1/Paths.cs index e85c73f..32e8c3a 100644 --- a/source/WindowsFormsApplication1/Paths.cs +++ b/source/WindowsFormsApplication1/Paths.cs @@ -23,6 +23,7 @@ namespace ShiftOS public static string Videos; public static string SystemDir; public static string AutoStart; + public static string APIs; public static string SkinDir; public static string LoadedSkin; public static string Icons; @@ -77,6 +78,7 @@ namespace ShiftOS Bitnote = Drivers + "BNWallet.dri"; Icons = LoadedSkin + "Icons\\"; WidgetFiles = SystemDir + "Widgets\\"; + APIs = SystemDir + "APIs\\"; break; default: SaveRoot = OSInfo.homePath () + "/.local/lib/.shiftos"; @@ -104,6 +106,7 @@ namespace ShiftOS Bitnote = Drivers + "BNWallet.dri"; Icons = LoadedSkin + "Icons/"; WidgetFiles = SystemDir + "Widgets/"; + APIs = SystemDir + "APIs/"; break; } diff --git a/source/WindowsFormsApplication1/Program.cs b/source/WindowsFormsApplication1/Program.cs index 2b9bd47..555ed9c 100644 --- a/source/WindowsFormsApplication1/Program.cs +++ b/source/WindowsFormsApplication1/Program.cs @@ -8,6 +8,7 @@ using System.Net; using System.IO.Compression; using System.ComponentModel; using System.Threading; +using Newtonsoft.Json; namespace ShiftOS { @@ -19,6 +20,7 @@ namespace ShiftOS [STAThread] static void Main(string[] args) { + Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //Extract all dependencies before starting the engine. @@ -44,7 +46,7 @@ namespace ShiftOS } } } - catch(Exception ex) + catch { Console.WriteLine("[ServerThread/WARNING] Couldn't retrieve startup pool. Not connecting to any servers."); } @@ -52,6 +54,17 @@ namespace ShiftOS poolThread.Start(); //Start the Windows Forms backend Paths.RegisterPaths(); //Sets ShiftOS path variables based on the current OS. + if (File.Exists(Paths.SystemDir + "settings.json")) + { + API.LoadedSettings = JsonConvert.DeserializeObject(File.ReadAllText(Paths.SystemDir + "settings.json")); + } + else + { + API.LoadedSettings = new Settings(); + API.LoadedSettings.MusicVolume = 50; + File.WriteAllText(Paths.SystemDir + "settings.json", JsonConvert.SerializeObject(API.LoadedSettings)); + } + Audio.LoadAudioData(); SaveSystem.Utilities.CheckForOlderSaves(); //Backs up C:\ShiftOS on Windows systems if it exists and doesn't contain a _engineInfo.txt file telling ShiftOS what engine created it. //If there isn't a save folder at the directory specified by ShiftOS.Paths.SaveRoot, create a new save. //If not, load that save. @@ -111,7 +124,7 @@ namespace ShiftOS } } } - catch(Exception ex) + catch { } @@ -140,7 +153,6 @@ namespace ShiftOS { Directory.Delete(temppath, true); } - bool firstfile = false; ZipFile.ExtractToDirectory(zippath, temppath); foreach (string f in Directory.GetFiles(temppath)) { @@ -164,7 +176,7 @@ namespace ShiftOS w.Dispose(); GC.Collect(); } - catch (Exception ex) + catch { MessageBox.Show("Sorry to break the immersion, but we're currently downloading ShiftOS dependencies that'll make the game run MUCH better, such as the Lua engine and Gecko web renderer. Give us a moment. ShiftOS will continue to run while this happens but some things won't work right until we're finished."); wc.DownloadFileAsync(new Uri("http://playshiftos.ml/shiftos/dependencies/ShiftOS_Dependencies.zip"), zippath); diff --git a/source/WindowsFormsApplication1/ProgressBarEX.cs b/source/WindowsFormsApplication1/ProgressBarEX.cs index e474a87..0e64aad 100644 --- a/source/WindowsFormsApplication1/ProgressBarEX.cs +++ b/source/WindowsFormsApplication1/ProgressBarEX.cs @@ -17,7 +17,37 @@ namespace ShiftOS InitializeComponent(); } -#region " Properties " + #region " Properties " + + private string _label = "Progress:"; + private bool show_label = false; + + public string Label + { + get + { + return _label; + } + set + { + _label = value; + this.Invalidate(); + } + } + + public bool ShowLabel + { + get + { + return show_label; + } + set + { + show_label = value; + this.Invalidate(); + } + } + private int _Value = 0; public int Value @@ -295,6 +325,9 @@ namespace ShiftOS private void DoPaintValue(Graphics g) { string valStr = GetRelativeValue().ToString() + "%"; + if (show_label) + valStr = _label + " " + valStr; + StringFormat sf = new StringFormat(); sf.Alignment = StringAlignment.Center; SizeF s = g.MeasureString(valStr, this.Font); diff --git a/source/WindowsFormsApplication1/Properties/Resources.Designer.cs b/source/WindowsFormsApplication1/Properties/Resources.Designer.cs index 71beb06..2c80870 100644 --- a/source/WindowsFormsApplication1/Properties/Resources.Designer.cs +++ b/source/WindowsFormsApplication1/Properties/Resources.Designer.cs @@ -318,7 +318,7 @@ namespace ShiftOS.Properties { /// internal static System.Drawing.Bitmap BeginButton_Image { get { - object obj = ResourceManager.GetObject("BeginButton.Image", resourceCulture); + object obj = ResourceManager.GetObject("BeginButton_Image", resourceCulture); return ((System.Drawing.Bitmap)(obj)); } } @@ -462,6 +462,52 @@ namespace ShiftOS.Properties { } } + /// + /// Looks up a localized string similar to ShiftOS #VER# + /// + /// + /// + ///A game by Michael VanOverbeek + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// == External Libraries / Dependencies == + /// + /// JSON.NET - Version 8.0.2 + /// By James Newton-King + /// http://www.newtonsoft.com/json + /// + /// + /// DynamicLua 1.1.1 + /// By Niklas Rother + /// http://www.github.com/nrother/dynamiclua + /// + /// + /// GeckoFX .NET wrapper for Gecko and xulrunner - 1.0.5 + /// By EmaGht + /// + /// + /// and various other amazing .NET libraries + /// + /// + /// + /// + ///== Music == + /// + ///All music in ShiftOS is provided by Free Songs to Use, whose YouTube channel ca [rest of string was truncated]";. + /// + internal static string Credits { + get { + return ResourceManager.GetString("Credits", resourceCulture); + } + } + /// /// Looks up a localized string similar to private void tmrfirstrun_Tick(object sender, EventArgs e) /// { @@ -1103,7 +1149,21 @@ namespace ShiftOS.Properties { /// /// Looks up a localized string similar to { - ///"BufferOverflow":{"IsLeader":false,"Name":"BufferOverflow","FriendDesc":"BufferOverflow is a question-and-answer site with millions of Shifters willing to share their knowledge.","Description":"BufferOverflow is a question-and-answer site with millions of Shifters willing to share their knowledge.","FriendSpeed":0,"FriendSkill":0,"Difficulty":"easy","Network":[{"Hostname":"bufferoverflow","ModuleType":0,"Type":0,"HP":100,"Grade":1,"X":0,"Y":0},{"Hostname":"main_av","ModuleType":0,"Type":1,"HP":0,"Grade": [rest of string was truncated]";. + ///"StartURL":"http://michael.playshiftos.ml/shiftos/soundtrack/", + ///"Files":{"endgame":["Tom Vanko & Mark Vank - Origin"], "hackerbattle_ambient":["HardMix - Evolution", "Lastep - NeveS", "Timmo Hendriks - That Happen", "Eric Rodriguez - Lion", "Mark Vank & Miza - Dark Generation"]}, + ///"Visualizers":{ + /// "Mark Vank & Miza - Dark Generation":[{"R":false, "G":true, "B":false, "type":"Pulse", "startTime":0, "endTime":30}, + /// {"R":false, "G":true, "B":false, "type":"BuildUp", "startTime":30, "endTime" [rest of string was truncated]";. + /// + internal static string MusicData { + get { + return ResourceManager.GetString("MusicData", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to { + ///"BufferOverflow":{"IsLeader":false,"Name":"BufferOverflow","FriendDesc":"BufferOverflow is a question-and-answer site with millions of Shifters willing to share their knowledge.","Description":"BufferOverflow is a question-and-answer site with millions of Shifters willing to share their knowledge.","FriendSpeed":65,"FriendSkill":50,"Difficulty":"easy","Network":[{"Hostname":"bufferoverflow","ModuleType":0,"Type":0,"HP":100,"Grade":1,"X":0,"Y":0},{"Hostname":"main_av","ModuleType":0,"Type":1,"HP":0,"Grade [rest of string was truncated]";. /// internal static string NetBrowser_Enemies { get { @@ -1166,7 +1226,7 @@ namespace ShiftOS.Properties { /// internal static System.Drawing.Bitmap object_large_Image { get { - object obj = ResourceManager.GetObject("object_large.Image", resourceCulture); + object obj = ResourceManager.GetObject("object_large_Image", resourceCulture); return ((System.Drawing.Bitmap)(obj)); } } @@ -1176,7 +1236,7 @@ namespace ShiftOS.Properties { /// internal static System.Drawing.Bitmap object_mid_Image { get { - object obj = ResourceManager.GetObject("object_mid.Image", resourceCulture); + object obj = ResourceManager.GetObject("object_mid_Image", resourceCulture); return ((System.Drawing.Bitmap)(obj)); } } @@ -1186,7 +1246,7 @@ namespace ShiftOS.Properties { /// internal static System.Drawing.Bitmap object_mid2_Image { get { - object obj = ResourceManager.GetObject("object_mid2.Image", resourceCulture); + object obj = ResourceManager.GetObject("object_mid2_Image", resourceCulture); return ((System.Drawing.Bitmap)(obj)); } } @@ -1196,7 +1256,7 @@ namespace ShiftOS.Properties { /// internal static System.Drawing.Bitmap object_small_Image { get { - object obj = ResourceManager.GetObject("object_small.Image", resourceCulture); + object obj = ResourceManager.GetObject("object_small_Image", resourceCulture); return ((System.Drawing.Bitmap)(obj)); } } @@ -1206,7 +1266,7 @@ namespace ShiftOS.Properties { /// internal static System.Drawing.Bitmap object_small2_Image { get { - object obj = ResourceManager.GetObject("object_small2.Image", resourceCulture); + object obj = ResourceManager.GetObject("object_small2_Image", resourceCulture); return ((System.Drawing.Bitmap)(obj)); } } @@ -1236,7 +1296,7 @@ namespace ShiftOS.Properties { /// internal static System.Drawing.Bitmap PicBonus_Image { get { - object obj = ResourceManager.GetObject("PicBonus.Image", resourceCulture); + object obj = ResourceManager.GetObject("PicBonus_Image", resourceCulture); return ((System.Drawing.Bitmap)(obj)); } } @@ -1266,7 +1326,7 @@ namespace ShiftOS.Properties { /// internal static System.Drawing.Bitmap player_Image { get { - object obj = ResourceManager.GetObject("player.Image", resourceCulture); + object obj = ResourceManager.GetObject("player_Image", resourceCulture); return ((System.Drawing.Bitmap)(obj)); } } @@ -1286,7 +1346,7 @@ namespace ShiftOS.Properties { /// internal static System.Drawing.Bitmap QuitButton_Image { get { - object obj = ResourceManager.GetObject("QuitButton.Image", resourceCulture); + object obj = ResourceManager.GetObject("QuitButton_Image", resourceCulture); return ((System.Drawing.Bitmap)(obj)); } } diff --git a/source/WindowsFormsApplication1/Properties/Resources.resx b/source/WindowsFormsApplication1/Properties/Resources.resx index d2f0adf..e8fecc6 100644 --- a/source/WindowsFormsApplication1/Properties/Resources.resx +++ b/source/WindowsFormsApplication1/Properties/Resources.resx @@ -220,7 +220,7 @@ ..\Resources\upgradeshiftpanelclock.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - + ..\Resources\BeginButton.Image.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -310,7 +310,7 @@ ..\Resources\deletefile.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - + ..\Resources\QuitButton.Image.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -412,7 +412,7 @@ ..\Resources\upgradegreencustom.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - + ..\Resources\player.Image.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -610,7 +610,7 @@ ..\Resources\iconDownloader.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - + ..\Resources\object_mid2.Image.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -622,7 +622,7 @@ ..\Resources\upgradeartpadpaintbrushtool.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - + ..\Resources\object_small2.Image.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -655,7 +655,7 @@ ..\Resources\upgradeartpadpixellimit4096.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - + ..\Resources\object_large.Image.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -778,7 +778,7 @@ ..\Resources\upgradeartpadpixelplacermovementmode.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - + ..\Resources\object_small.Image.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -868,7 +868,7 @@ ..\Resources\upgrademinutesssincemidnight.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - + ..\Resources\object_mid.Image.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -1009,7 +1009,7 @@ ..\Resources\upgradepinkshades.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - + ..\Resources\PicBonus.Image.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -1063,4 +1063,10 @@ ..\Resources\AustinWalkerCompletionStory.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252 + + ..\Resources\MusicData.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252 + + + ..\Resources\Credits.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252 + \ No newline at end of file diff --git a/source/WindowsFormsApplication1/QuickChat.cs b/source/WindowsFormsApplication1/QuickChat.cs index d650914..9cac42e 100644 --- a/source/WindowsFormsApplication1/QuickChat.cs +++ b/source/WindowsFormsApplication1/QuickChat.cs @@ -52,7 +52,7 @@ namespace ShiftOS this.Close(); } } - catch(Exception ex) + catch { } @@ -72,7 +72,7 @@ namespace ShiftOS } } } - catch(Exception ex) + catch { } diff --git a/source/WindowsFormsApplication1/Resources/Credits.txt b/source/WindowsFormsApplication1/Resources/Credits.txt new file mode 100644 index 0000000..9961fa3 --- /dev/null +++ b/source/WindowsFormsApplication1/Resources/Credits.txt @@ -0,0 +1,121 @@ +ShiftOS #VER# + + + +A game by Michael VanOverbeek + + + + + + + + + + == External Libraries / Dependencies == + + JSON.NET - Version 8.0.2 + By James Newton-King + http://www.newtonsoft.com/json + + + DynamicLua 1.1.1 + By Niklas Rother + http://www.github.com/nrother/dynamiclua + + + GeckoFX .NET wrapper for Gecko and xulrunner - 1.0.5 + By EmaGht + + + and various other amazing .NET libraries + + + + +== Music == + +All music in ShiftOS is provided by Free Songs to Use, whose YouTube channel can be found at https://www.youtube.com/channel/UCPSX-g40Ti1c5C7sbGNtGzA + +TRACKLIST: + +Lastep - NeveS +Timmo Hendriks - That Happen +Tom Vanko / Mark Vank - Origin +HardMix - Evolution +Eric Rodriguez - Lion +Mark Vank & Miza - Dark Generation + +SUPPORT THESE BRILLIANT ARTISTS! + +• Support Miza: +https://soundcloud.com/miza-official1 +https://soundcloud.com/miza-official1 +https://www.facebook.com/miza.official.page + +Support Lastep: +https://www.youtube.com/channel/UCQoGdkBRqzjx12htDBhiCxQ +https://soundcloud.com/lastepmusic +https://twitter.com/LastepMusic + +Support Tom Vanko: +https://soundcloud.com/tomvanko +https://www.facebook.com/tomvankomusic +https://twitter.com/tomvankomusic + +Support Timmo Hendriks: +https://soundcloud.com/dj-timmo +https://www.facebook.com/TimmoHendriksofficial +https://twitter.com/Timmo_Hendriks +https://www.instagram.com/timmohendriks/ +https://www.youtube.com/c/TimmoHendriks +Snapchat: Timmo_Hendriks + +Support Mark Vank: +https://soundcloud.com/markvank +https://www.youtube.com/channel/UCb4ch0_TAKSDvq89NUIElLA +https://twitter.com/MarkVank_ +https://www.facebook.com/HardMixOfficial + +Support HardMix: +https://soundcloud.com/hardmix-ap3x +http://www.instagram.com/mebn2 +http://www.youtube.com/VoltiDubstep + +Support Eric Rodriguez: +https://soundcloud.com/ericrodriguezofficial +https://instagram.com/ericrodriguezmusic/ +https://www.youtube.com/user/ericrodriguezmusic + +Go check out Free Songs To Use (and thank them for this brilliant music) +Facebook: https://www.facebook.com/FreeSongsToUse +Twitter: https://twitter.com/FreeSongsToUse +Soundcloud: https://soundcloud.com/FreeSongsToUse +Instagram: https://www.instagram.com/freesongstouse_official + + +== More of Michael's things == + +Enjoyed ShiftOS? Want to see more games and projects from Michael? Why not visit his website at http://michael.playshiftos.ml? + + + + + == Special Thanks == + +On behalf of the ShiftOS development team, we would love to thank the following amazing people and groups: + + - Microsoft BizSpark, Azure, and MSDN + - Philip Adams, a.k.a OSFirstTimer + - All the amazing people on the ShiftOS Forums + +Without your help, ShiftOS just wouldn't be what it is today. It probably wouldn't exist if it weren't for OSFirstTimer, and without BizSpark and Azure hosting our website and servers, you wouldn't be able to hear the amazing music you hear right now. That, and without the amazing people at the ShiftOS community bringing us new ideas, suggestions, bug reports, and being generally nice people, the project wouldn't get as far as it has. + + + + + + + + +And finally, we want to thank you, #USER#, for giving our game a try. We hope you enjoyed and continue to enjoy it! \ No newline at end of file diff --git a/source/WindowsFormsApplication1/Resources/MusicData.txt b/source/WindowsFormsApplication1/Resources/MusicData.txt new file mode 100644 index 0000000..b17ac5a --- /dev/null +++ b/source/WindowsFormsApplication1/Resources/MusicData.txt @@ -0,0 +1,45 @@ +{ +"StartURL":"http://michael.playshiftos.ml/shiftos/soundtrack/", +"Files":{"endgame":["Tom Vanko & Mark Vank - Origin"], "hackerbattle_ambient":["HardMix - Evolution", "Lastep - NeveS", "Timmo Hendriks - That Happen", "Mark Vank & Miza - Dark Generation"]}, +"Visualizers":{ + "Mark Vank & Miza - Dark Generation":[{"R":false, "G":true, "B":false, "type":"Pulse", "startTime":0, "endTime":30}, + {"R":false, "G":true, "B":false, "type":"BuildUp", "startTime":30, "endTime":60}, + {"R":false, "G":true, "B":true, "type":"BuildUp", "startTime":60, "endTime":75}, + {"R":true, "G":false, "B":false, "type":"Pulse", "startTime":75, "endTime":105}, + {"R":false, "G":true, "B":false, "type":"Pulse", "startTime":106, "endTime":135}, + {"R":false, "G":true, "B":true, "type":"BuildUp", "startTime":135, "endTime":150}, + {"R":true, "G":true, "B":false, "type":"Pulse", "startTime":150, "endTime":175}, + {"R":true, "G":true, "B":false, "type":"CalmDown", "startTime":175, "endTime":212} + ], + "HardMix - Evolution": [{"R":false, "G":false, "B":true, "type":"Pulse", "startTime":0, "endTime":15}, + {"R":false, "G":true, "B":true, "type":"Pulse", "startTime":15, "endTime":30}, + {"R":true, "G":false, "B":true, "type":"BuildUp", "startTime":30, "endTime":83}, + {"R":true, "G":false, "B":false, "type":"BuildUp", "startTime":83, "endTime":97}, + {"R":true, "G":false, "B":false, "type":"Pulse", "startTime":97, "endTime":130}, + {"R":true, "G":false, "B":true, "type":"BuildUp", "startTime":130, "endTime":175}, + {"R":true, "G":false, "B":false, "type":"BuildUp", "startTime":175, "endTime":190}, + {"R":true, "G":false, "B":false, "type":"Pulse", "startTime":190, "endTime":220}, + {"R":false, "G":false, "B":true, "type":"CalmDown", "startTime":220, "endTime":252} + ], + "Lastep - NeveS": [{"R":true, "G":true, "B":true, "type":"Pulse", "startTime":0, "endTime":47}, + {"R":true, "G":true, "B":false, "type":"BuildUp", "startTime":47, "endTime":78}, + {"R":true, "G":true, "B":false, "type":"Pulse", "startTime":78, "endTime":110}, + {"R":true, "G":false, "B":false, "type":"Pulse", "startTime":110, "endTime":157}, + {"R":true, "G":true, "B":false, "type":"BuildUp", "startTime":157, "endTime":190}, + {"R":true, "G":true, "B":false, "type":"Pulse", "startTime":190, "endTime":220} + ], + "Timmo Hendriks - That Happen": [{"R":false, "G":false, "B":true, "type":"Pulse", "startTime":0, "endTime":30}, + {"R":false, "G":true, "B":true, "type":"Pulse", "startTime":30, "endTime":60}, + {"R":true, "G":true, "B":false, "type":"Pulse", "startTime":60, "endTime":90}, + {"R":true, "G":false, "B":true, "type":"Pulse", "startTime":90, "endTime":120}, + {"R":true, "G":true, "B":false, "type":"Pulse", "startTime":120, "endTime":135}, + {"R":true, "G":false, "B":false, "type":"BuildUp", "startTime":135, "endTime":165}, + {"R":true, "B":false, "G":false, "type":"Pulse", "startTime":165, "endTime":195}, + {"R":false, "G":false, "B":true, "type":"BuildUp", "startTime":195, "endTime":240}, + {"R":false, "G":false, "B":true, "type":"Pulse", "startTime":240, "endTime":255}, + {"R":true, "G":false, "B":false, "type":"BuildUp", "startTime":255, "endTime":285}, + {"R":true, "G":true, "B":false, "type":"Pulse", "startTime":285, "endTime":330}, + {"R":true, "G":true, "B":false, "type":"CalmDown", "startTime":330, "endTime":377} + ] + } +} \ No newline at end of file diff --git a/source/WindowsFormsApplication1/Resources/NetBrowser_Enemies.txt b/source/WindowsFormsApplication1/Resources/NetBrowser_Enemies.txt index 950d6b7..bc8d7f9 100644 --- a/source/WindowsFormsApplication1/Resources/NetBrowser_Enemies.txt +++ b/source/WindowsFormsApplication1/Resources/NetBrowser_Enemies.txt @@ -1,6 +1,8 @@ { -"BufferOverflow":{"IsLeader":false,"Name":"BufferOverflow","FriendDesc":"BufferOverflow is a question-and-answer site with millions of Shifters willing to share their knowledge.","Description":"BufferOverflow is a question-and-answer site with millions of Shifters willing to share their knowledge.","FriendSpeed":0,"FriendSkill":0,"Difficulty":"easy","Network":[{"Hostname":"bufferoverflow","ModuleType":0,"Type":0,"HP":100,"Grade":1,"X":0,"Y":0},{"Hostname":"main_av","ModuleType":0,"Type":1,"HP":0,"Grade":4,"X":371,"Y":148},{"Hostname":"defense1","ModuleType":0,"Type":3,"HP":0,"Grade":4,"X":252,"Y":121},{"Hostname":"defense2","ModuleType":0,"Type":3,"HP":0,"Grade":4,"X":251,"Y":163}]}, +"BufferOverflow":{"IsLeader":false,"Name":"BufferOverflow","FriendDesc":"BufferOverflow is a question-and-answer site with millions of Shifters willing to share their knowledge.","Description":"BufferOverflow is a question-and-answer site with millions of Shifters willing to share their knowledge.","FriendSpeed":65,"FriendSkill":50,"Difficulty":"easy","Network":[{"Hostname":"bufferoverflow","ModuleType":0,"Type":0,"HP":100,"Grade":1,"X":0,"Y":0},{"Hostname":"main_av","ModuleType":0,"Type":1,"HP":0,"Grade":4,"X":371,"Y":148},{"Hostname":"defense1","ModuleType":0,"Type":3,"HP":0,"Grade":4,"X":252,"Y":121},{"Hostname":"defense2","ModuleType":0,"Type":3,"HP":0,"Grade":4,"X":251,"Y":163}]}, "Exodus Software":{"IsLeader":false,"Name":"Exodus Software","FriendDesc":"Known for their ShiftOS desktop environment \"Exodus Desktop Environment\", Exodus Software is well-known among the ShiftOS user-base. Now they're trying to dig their hands into hacker battles.","Description":"Known for their ShiftOS desktop environment \"Exodus Desktop Environment\", Exodus Software is well-known among the ShiftOS user-base. Now they're trying to dig their hands into hacker battles.","FriendSpeed":75,"FriendSkill":45,"Difficulty":"easy","Network":[{"Hostname":"exodus_software","ModuleType":0,"Type":0,"HP":100,"Grade":1,"X":0,"Y":0},{"Hostname":"exds_turret1","ModuleType":0,"Type":3,"HP":0,"Grade":4,"X":500,"Y":215},{"Hostname":"exds_antimalware","ModuleType":0,"Type":1,"HP":0,"Grade":1,"X":500,"Y":259},{"Hostname":"exds_antimalware2","ModuleType":0,"Type":1,"HP":0,"Grade":1,"X":498,"Y":162},{"Hostname":"exds_repairman","ModuleType":0,"Type":9,"HP":0,"Grade":2,"X":351,"Y":210}]}, -"Orange Inc.":{"IsLeader":false,"Name":"Orange Inc.","FriendDesc":"Orange is a computer industry giant. Let's see how they can compete in a Hacker Battle.","Description":"Orange is a computer industry giant. Let's see how they can compete in a Hacker Battle.","FriendSpeed":100,"FriendSkill":2001,"Difficulty":"hard","Network":[{"Hostname":"orange_inc.","ModuleType":0,"Type":0,"HP":100,"Grade":1,"X":0,"Y":0},{"Hostname":"blood_orange","ModuleType":0,"Type":6,"HP":0,"Grade":4,"X":484,"Y":203},{"Hostname":"yummy","ModuleType":0,"Type":2,"HP":0,"Grade":3,"X":497,"Y":150},{"Hostname":"juicy","ModuleType":0,"Type":5,"HP":0,"Grade":4,"X":356,"Y":212},{"Hostname":"sweet","ModuleType":0,"Type":9,"HP":0,"Grade":2,"X":316,"Y":212},{"Hostname":"orange","ModuleType":0,"Type":2,"HP":0,"Grade":3,"X":490,"Y":270}]}, -"UltraDOS Foundation":{"IsLeader":false,"Name":"UltraDOS Foundation","FriendDesc":"UltraDOS Foundation is a group of competent programmers responsible for the ShiftOS-based UltraDOS operating system.","Description":"UltraDOS Foundation is a group of competent programmers responsible for the ShiftOS-based UltraDOS operating system.","FriendSpeed":65,"FriendSkill":75,"Difficulty":"medium","Network":[{"Hostname":"ultrados_foundation","ModuleType":0,"Type":0,"HP":100,"Grade":1,"X":0,"Y":0},{"Hostname":"ud_trt1","ModuleType":0,"Type":3,"HP":0,"Grade":2,"X":361,"Y":171},{"Hostname":"ud_trt2","ModuleType":0,"Type":3,"HP":0,"Grade":2,"X":358,"Y":220},{"Hostname":"ud_repairer","ModuleType":0,"Type":9,"HP":0,"Grade":4,"X":494,"Y":215}]} +"Orange Inc.":{"IsLeader":false,"Name":"Orange Inc.","FriendDesc":"Orange is a computer industry giant. Let's see how they can compete in a Hacker Battle.","Description":"Orange is a computer industry giant, creators of the Tangerine Operating System, and various portable devices like the TangerineBook, OrangePad, and OrangePhone.","FriendSpeed":100,"FriendSkill":200,"Difficulty":"hard","Network":[{"Hostname":"orange_inc.","ModuleType":0,"Type":0,"HP":100,"Grade":1,"X":0,"Y":0},{"Hostname":"blood_orange","ModuleType":0,"Type":6,"HP":0,"Grade":4,"X":484,"Y":203},{"Hostname":"yummy","ModuleType":0,"Type":2,"HP":0,"Grade":3,"X":497,"Y":150},{"Hostname":"juicy","ModuleType":0,"Type":5,"HP":0,"Grade":4,"X":356,"Y":212},{"Hostname":"sweet","ModuleType":0,"Type":9,"HP":0,"Grade":2,"X":316,"Y":212},{"Hostname":"orange","ModuleType":0,"Type":2,"HP":0,"Grade":3,"X":490,"Y":270}]}, +"UltraDOS Foundation":{"IsLeader":false,"Name":"UltraDOS Foundation","FriendDesc":"UltraDOS Foundation is a group of competent programmers responsible for the ShiftOS-based UltraDOS operating system.","Description":"UltraDOS Foundation is a group of competent programmers responsible for the ShiftOS-based UltraDOS operating system.","FriendSpeed":65,"FriendSkill":75,"Difficulty":"medium","Network":[{"Hostname":"ultrados_foundation","ModuleType":0,"Type":0,"HP":100,"Grade":1,"X":0,"Y":0},{"Hostname":"ud_trt1","ModuleType":0,"Type":3,"HP":0,"Grade":2,"X":361,"Y":171},{"Hostname":"ud_trt2","ModuleType":0,"Type":3,"HP":0,"Grade":2,"X":358,"Y":220},{"Hostname":"ud_repairer","ModuleType":0,"Type":9,"HP":0,"Grade":4,"X":494,"Y":215}]}, +"LadouceurNet":{"IsLeader":false,"Name":"LadouceurNet","FriendDesc":"The LadouceurNet - the Shiftnet that never happened.","Description":"The LadouceurNet - the Shiftnet that never happened.","FriendSpeed":140,"FriendSkill":125,"Difficulty":"medium","Network":[{"Hostname":"ladouceurnet","ModuleType":0,"Type":0,"HP":100,"Grade":1,"X":0,"Y":0},{"Hostname":"mod4","ModuleType":0,"Type":3,"HP":0,"Grade":4,"X":479,"Y":127},{"Hostname":"mod5","ModuleType":0,"Type":3,"HP":0,"Grade":4,"X":382,"Y":131},{"Hostname":"mod5_1","ModuleType":0,"Type":1,"HP":0,"Grade":2,"X":482,"Y":302},{"Hostname":"mod5_2","ModuleType":0,"Type":9,"HP":0,"Grade":4,"X":359,"Y":304},{"Hostname":"mod8","ModuleType":0,"Type":5,"HP":0,"Grade":4,"X":403,"Y":336},{"Hostname":"mod1","ModuleType":0,"Type":3,"HP":0,"Grade":4,"X":444,"Y":335}]}, +"GimmeX":{"IsLeader":false,"Name":"GimmeX","FriendDesc":"The data stealer","Description":"The data stealer","FriendSpeed":10,"FriendSkill":15,"Difficulty":"medium","Network":[{"Hostname":"gimmex","ModuleType":0,"Type":0,"HP":100,"Grade":1,"X":0,"Y":0},{"Hostname":"Repairman","ModuleType":0,"Type":9,"HP":0,"Grade":1,"X":442,"Y":145},{"Hostname":"Stealer","ModuleType":0,"Type":8,"HP":0,"Grade":4,"X":371,"Y":121},{"Hostname":"Attacker","ModuleType":0,"Type":3,"HP":0,"Grade":1,"X":359,"Y":218},{"Hostname":"Defense","ModuleType":0,"Type":5,"HP":0,"Grade":4,"X":494,"Y":227},{"Hostname":"IGiveBreaks","ModuleType":0,"Type":6,"HP":0,"Grade":1,"X":522,"Y":156}]} } \ No newline at end of file diff --git a/source/WindowsFormsApplication1/SaveSystem.cs b/source/WindowsFormsApplication1/SaveSystem.cs index a86ee52..aab5ab2 100644 --- a/source/WindowsFormsApplication1/SaveSystem.cs +++ b/source/WindowsFormsApplication1/SaveSystem.cs @@ -186,6 +186,32 @@ namespace SaveSystem public static List DefaultUpgrades = new List(); + public static List GetCategories(bool showBought) + { + List cats = new List(); + foreach(var upg in DefaultUpgrades) + { + if(upg.id.Contains("dummy")) + { + if(!cats.Contains(upg.Category.ToLower())) + { + if(API.Upgrades[upg.Category.ToLower()]) + { + if(showBought == true) + { + cats.Add(upg.Category.ToLower()); + } + } + else + { + cats.Add(upg.Category.ToLower()); + } + + } + } + } + return cats; //Meow! No. I don't mean the animal. I mean "Categories". + } /// /// Adds upgrade info (such as CP, description, etc) to the registry. Add your Shiftorium upgrades here. @@ -460,13 +486,14 @@ namespace SaveSystem try { ShiftoriumUpgrades[kv.Key] = kv.Value; - } catch(Exception ex) + } catch { Console.WriteLine("[Shiftorium/Registry] [ERROR] Upgrade {0} from disk doesn't seem to be found in the 'Default Upgrades' dictionary. This may be caused by a bug.", kv.Key); } } } - catch (Exception ex) + catch + { string shiftoriumjson = JsonConvert.SerializeObject(ShiftoriumUpgrades); if (API.DeveloperMode == true) @@ -505,10 +532,10 @@ namespace Shiftorium /// Whether the upgrade could be bought. public static bool Buy(Upgrade upgradeToBuy) { - if(API.Codepoints >= upgradeToBuy.Cost) + if(API.Codepoints >= upgradeToBuy.Cost / API.CurrentSave.PriceDivider) { SaveSystem.ShiftoriumRegistry.ShiftoriumUpgrades[upgradeToBuy.id] = true; - SaveSystem.Utilities.LoadedSave.codepoints -= upgradeToBuy.Cost; + SaveSystem.Utilities.LoadedSave.codepoints -= upgradeToBuy.Cost / API.CurrentSave.PriceDivider; SaveSystem.Utilities.saveGame(); API.UpdateWindows(); API.Log("[Shiftorium] Upgrade \"" + upgradeToBuy.id + "\" bought successfully, game saved."); @@ -561,7 +588,7 @@ namespace Shiftorium } - catch (Exception ex) + catch { if (upgrade.id.Contains("dummy")) { diff --git a/source/WindowsFormsApplication1/ShiftOS.csproj b/source/WindowsFormsApplication1/ShiftOS.csproj index 0f86628..7572db9 100644 --- a/source/WindowsFormsApplication1/ShiftOS.csproj +++ b/source/WindowsFormsApplication1/ShiftOS.csproj @@ -146,6 +146,18 @@ Connection.cs + + Form + + + ConnectionManager.cs + + + Form + + + CreditScroller.cs + UserControl @@ -189,6 +201,12 @@ QuestViewer.cs + + Form + + + GameSettings.cs + Form @@ -346,6 +364,30 @@ Shifter.cs + + UserControl + + + ShifterColorInput.cs + + + UserControl + + + ShifterGraphicInput.cs + + + UserControl + + + ShifterIntInput.cs + + + UserControl + + + ShifterTextInput.cs + Form @@ -416,6 +458,12 @@ Connection.cs + + ConnectionManager.cs + + + CreditScroller.cs + DesktopIcon.cs @@ -437,6 +485,9 @@ QuestViewer.cs + + GameSettings.cs + Graphic_Picker.cs @@ -511,6 +562,18 @@ Shifter.cs + + ShifterColorInput.cs + + + ShifterGraphicInput.cs + + + ShifterIntInput.cs + + + ShifterTextInput.cs + Shiftnet.cs @@ -559,6 +622,8 @@ + + @@ -959,7 +1024,25 @@ - + + + {6BF52A50-394A-11D3-B153-00C04F79FAA6} + 1 + 0 + 0 + aximp + False + + + {6BF52A50-394A-11D3-B153-00C04F79FAA6} + 1 + 0 + 0 + tlbimp + False + True + + diff --git a/source/WindowsFormsApplication1/ShiftOSDesktop.cs b/source/WindowsFormsApplication1/ShiftOSDesktop.cs index bc0b9ed..9a6818e 100644 --- a/source/WindowsFormsApplication1/ShiftOSDesktop.cs +++ b/source/WindowsFormsApplication1/ShiftOSDesktop.cs @@ -385,7 +385,7 @@ namespace ShiftOS ctrl.Width = w.Width; Skinning.Utilities.saveskin(); } - catch(Exception ex) + catch { AddNotification("Invalid width", "You have entered an invalid width."); } @@ -397,7 +397,7 @@ namespace ShiftOS l.mod.widget(ctrl); } - catch(Exception ex) + catch { API.CreateInfoboxSession("Widget Error", $"An error has occurred creating this \"{w.Name}\". It'll stay, but it may not function as intended.", infobox.InfoboxMode.Info); } @@ -666,7 +666,7 @@ namespace ShiftOS NewAL = new ApplauncherItem(TEMP_AL.Name, Image.FromFile(Paths.Applications + TEMP_AL.AppDirectory + "\\" + TEMP_AL.Icon), lua, true); imgshiftnetapps.Images.Add(file, NewAL.Icon); } - catch (Exception ex) + catch { NewAL = new ApplauncherItem(TEMP_AL.Name, null, lua, true); } @@ -894,7 +894,7 @@ namespace ShiftOS ctrl.Parent.Controls.Remove(ctrl); newPanel.Controls.Add(ctrl); } - catch(Exception ex) + catch { newPanel.Controls.Add(ctrl); } @@ -996,7 +996,7 @@ namespace ShiftOS API.ToggleMinimized(frm); } } - catch (Exception ex) + catch { } diff --git a/source/WindowsFormsApplication1/Shifter.Designer.cs b/source/WindowsFormsApplication1/Shifter.Designer.cs index 1d16831..d49294e 100644 --- a/source/WindowsFormsApplication1/Shifter.Designer.cs +++ b/source/WindowsFormsApplication1/Shifter.Designer.cs @@ -34,6 +34,7 @@ namespace ShiftOS this.Label1 = new System.Windows.Forms.Label(); this.btnapply = new System.Windows.Forms.Button(); this.catholder = new System.Windows.Forms.Panel(); + this.btnmore = new System.Windows.Forms.Button(); this.btnreset = new System.Windows.Forms.Button(); this.btnwindowcomposition = new System.Windows.Forms.Button(); this.btndesktopicons = new System.Windows.Forms.Button(); @@ -46,6 +47,16 @@ namespace ShiftOS this.Label64 = new System.Windows.Forms.Label(); this.Label63 = new System.Windows.Forms.Label(); this.pnldesktopoptions = new System.Windows.Forms.Panel(); + this.pnldesktoppaneloptions = new System.Windows.Forms.Panel(); + this.btnpanelbuttons = new System.Windows.Forms.Button(); + this.lbwarning = new System.Windows.Forms.Label(); + this.combodesktoppanelposition = new System.Windows.Forms.ComboBox(); + this.lbposition = new System.Windows.Forms.Label(); + this.Label47 = new System.Windows.Forms.Label(); + this.txtdesktoppanelheight = new System.Windows.Forms.NumericUpDown(); + this.lbheight = new System.Windows.Forms.Label(); + this.pnldesktoppanelcolour = new System.Windows.Forms.Panel(); + this.lbpanelcolor = new System.Windows.Forms.Label(); this.pnlapplauncheroptions = new System.Windows.Forms.Panel(); this.pnlalhover = new System.Windows.Forms.Panel(); this.label119 = new System.Windows.Forms.Label(); @@ -108,16 +119,6 @@ namespace ShiftOS this.Label91 = new System.Windows.Forms.Label(); this.pnlpanelbuttoncolour = new System.Windows.Forms.Panel(); this.Label95 = new System.Windows.Forms.Label(); - this.pnldesktoppaneloptions = new System.Windows.Forms.Panel(); - this.btnpanelbuttons = new System.Windows.Forms.Button(); - this.lbwarning = new System.Windows.Forms.Label(); - this.combodesktoppanelposition = new System.Windows.Forms.ComboBox(); - this.lbposition = new System.Windows.Forms.Label(); - this.Label47 = new System.Windows.Forms.Label(); - this.txtdesktoppanelheight = new System.Windows.Forms.NumericUpDown(); - this.lbheight = new System.Windows.Forms.Label(); - this.pnldesktoppanelcolour = new System.Windows.Forms.Panel(); - this.lbpanelcolor = new System.Windows.Forms.Label(); this.pnldesktopbackgroundoptions = new System.Windows.Forms.Panel(); this.pnldesktopcolour = new System.Windows.Forms.Panel(); this.Label45 = new System.Windows.Forms.Label(); @@ -437,14 +438,17 @@ namespace ShiftOS this.label74 = new System.Windows.Forms.Label(); this.tmrfix = new System.Windows.Forms.Timer(this.components); this.tmrdelay = new System.Windows.Forms.Timer(this.components); + this.pnlluaoptions = new System.Windows.Forms.Panel(); + this.flmorebuttons = new System.Windows.Forms.FlowLayoutPanel(); + this.pnlluafield = new System.Windows.Forms.Panel(); this.catholder.SuspendLayout(); this.pnlshifterintro.SuspendLayout(); this.pnldesktopoptions.SuspendLayout(); + this.pnldesktoppaneloptions.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.txtdesktoppanelheight)).BeginInit(); this.pnlapplauncheroptions.SuspendLayout(); this.pnldesktopintro.SuspendLayout(); this.pnlpanelbuttonsoptions.SuspendLayout(); - this.pnldesktoppaneloptions.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.txtdesktoppanelheight)).BeginInit(); this.pnldesktopbackgroundoptions.SuspendLayout(); this.pnlpanelclockoptions.SuspendLayout(); this.pnldesktoppreview.SuspendLayout(); @@ -487,6 +491,7 @@ namespace ShiftOS this.pnlbasic.SuspendLayout(); this.pnlmenusintro.SuspendLayout(); this.pnlmenucategories.SuspendLayout(); + this.pnlluaoptions.SuspendLayout(); this.SuspendLayout(); // // clocktick @@ -532,6 +537,7 @@ namespace ShiftOS this.catholder.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left))); this.catholder.BackColor = System.Drawing.Color.White; + this.catholder.Controls.Add(this.btnmore); this.catholder.Controls.Add(this.btnreset); this.catholder.Controls.Add(this.btnwindowcomposition); this.catholder.Controls.Add(this.btndesktopicons); @@ -543,6 +549,21 @@ namespace ShiftOS this.catholder.Size = new System.Drawing.Size(119, 271); this.catholder.TabIndex = 5; // + // btnmore + // + this.btnmore.BackColor = System.Drawing.Color.White; + this.btnmore.Dock = System.Windows.Forms.DockStyle.Top; + this.btnmore.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnmore.Font = new System.Drawing.Font("Cambria", 12F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic))), System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnmore.Location = new System.Drawing.Point(0, 174); + this.btnmore.Name = "btnmore"; + this.btnmore.Size = new System.Drawing.Size(119, 29); + this.btnmore.TabIndex = 11; + this.btnmore.TabStop = false; + this.btnmore.Text = "More"; + this.btnmore.UseVisualStyleBackColor = false; + this.btnmore.Click += new System.EventHandler(this.btnmore_Click); + // // btnreset // this.btnreset.BackColor = System.Drawing.Color.White; @@ -699,8 +720,8 @@ namespace ShiftOS | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.pnldesktopoptions.BackColor = System.Drawing.Color.White; - this.pnldesktopoptions.Controls.Add(this.pnldesktoppaneloptions); this.pnldesktopoptions.Controls.Add(this.pnlapplauncheroptions); + this.pnldesktopoptions.Controls.Add(this.pnldesktoppaneloptions); this.pnldesktopoptions.Controls.Add(this.pnldesktopintro); this.pnldesktopoptions.Controls.Add(this.pnlpanelbuttonsoptions); this.pnldesktopoptions.Controls.Add(this.pnldesktopbackgroundoptions); @@ -713,6 +734,120 @@ namespace ShiftOS this.pnldesktopoptions.TabIndex = 16; this.pnldesktopoptions.Visible = false; // + // pnldesktoppaneloptions + // + this.pnldesktoppaneloptions.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.pnldesktoppaneloptions.Controls.Add(this.btnpanelbuttons); + this.pnldesktoppaneloptions.Controls.Add(this.lbwarning); + this.pnldesktoppaneloptions.Controls.Add(this.combodesktoppanelposition); + this.pnldesktoppaneloptions.Controls.Add(this.lbposition); + this.pnldesktoppaneloptions.Controls.Add(this.Label47); + this.pnldesktoppaneloptions.Controls.Add(this.txtdesktoppanelheight); + this.pnldesktoppaneloptions.Controls.Add(this.lbheight); + this.pnldesktoppaneloptions.Controls.Add(this.pnldesktoppanelcolour); + this.pnldesktoppaneloptions.Controls.Add(this.lbpanelcolor); + this.pnldesktoppaneloptions.Location = new System.Drawing.Point(135, 159); + this.pnldesktoppaneloptions.Name = "pnldesktoppaneloptions"; + this.pnldesktoppaneloptions.Size = new System.Drawing.Size(317, 140); + this.pnldesktoppaneloptions.TabIndex = 9; + this.pnldesktoppaneloptions.Visible = false; + // + // btnpanelbuttons + // + this.btnpanelbuttons.BackColor = System.Drawing.Color.White; + this.btnpanelbuttons.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnpanelbuttons.Font = new System.Drawing.Font("Cambria", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnpanelbuttons.Location = new System.Drawing.Point(193, 101); + this.btnpanelbuttons.Name = "btnpanelbuttons"; + this.btnpanelbuttons.Size = new System.Drawing.Size(119, 29); + this.btnpanelbuttons.TabIndex = 8; + this.btnpanelbuttons.Text = "Panel Buttons >"; + this.btnpanelbuttons.UseVisualStyleBackColor = false; + this.btnpanelbuttons.Click += new System.EventHandler(this.btnpanelbuttons_Click); + // + // lbwarning + // + this.lbwarning.Location = new System.Drawing.Point(3, 52); + this.lbwarning.Name = "lbwarning"; + this.lbwarning.Size = new System.Drawing.Size(290, 42); + this.lbwarning.TabIndex = 8; + this.lbwarning.Text = "Warning: If you set the panel position to the bottom you must hide your windows t" + + "askbar and restart ShiftOS on your host operating system to prevent a visual bug" + + "."; + // + // combodesktoppanelposition + // + this.combodesktoppanelposition.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.combodesktoppanelposition.FormattingEnabled = true; + this.combodesktoppanelposition.Items.AddRange(new object[] { + "Top", + "Bottom"}); + this.combodesktoppanelposition.Location = new System.Drawing.Point(103, 28); + this.combodesktoppanelposition.Name = "combodesktoppanelposition"; + this.combodesktoppanelposition.Size = new System.Drawing.Size(59, 24); + this.combodesktoppanelposition.TabIndex = 7; + this.combodesktoppanelposition.SelectedIndexChanged += new System.EventHandler(this.combodesktoppanelposition_SelectedIndexChanged); + // + // lbposition + // + this.lbposition.AutoSize = true; + this.lbposition.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lbposition.Location = new System.Drawing.Point(3, 31); + this.lbposition.Name = "lbposition"; + this.lbposition.Size = new System.Drawing.Size(97, 16); + this.lbposition.TabIndex = 6; + this.lbposition.Text = "Panel Position:"; + // + // Label47 + // + this.Label47.AutoSize = true; + this.Label47.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.Label47.Location = new System.Drawing.Point(226, 8); + this.Label47.Name = "Label47"; + this.Label47.Size = new System.Drawing.Size(22, 16); + this.Label47.TabIndex = 5; + this.Label47.Text = "px"; + // + // txtdesktoppanelheight + // + this.txtdesktoppanelheight.BackColor = System.Drawing.Color.White; + this.txtdesktoppanelheight.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.txtdesktoppanelheight.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.txtdesktoppanelheight.ForeColor = System.Drawing.Color.Black; + this.txtdesktoppanelheight.Location = new System.Drawing.Point(189, 5); + this.txtdesktoppanelheight.Name = "txtdesktoppanelheight"; + this.txtdesktoppanelheight.Size = new System.Drawing.Size(37, 22); + this.txtdesktoppanelheight.TabIndex = 4; + this.txtdesktoppanelheight.ValueChanged += new System.EventHandler(this.txtdesktoppanelheight_ValueChanged); + // + // lbheight + // + this.lbheight.AutoSize = true; + this.lbheight.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lbheight.Location = new System.Drawing.Point(138, 7); + this.lbheight.Name = "lbheight"; + this.lbheight.Size = new System.Drawing.Size(50, 16); + this.lbheight.TabIndex = 2; + this.lbheight.Text = "Height:"; + // + // pnldesktoppanelcolour + // + this.pnldesktoppanelcolour.Location = new System.Drawing.Point(92, 5); + this.pnldesktoppanelcolour.Name = "pnldesktoppanelcolour"; + this.pnldesktoppanelcolour.Size = new System.Drawing.Size(41, 20); + this.pnldesktoppanelcolour.TabIndex = 1; + this.pnldesktoppanelcolour.MouseDown += new System.Windows.Forms.MouseEventHandler(this.ChangeDesktopPanelColor); + // + // lbpanelcolor + // + this.lbpanelcolor.AutoSize = true; + this.lbpanelcolor.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lbpanelcolor.Location = new System.Drawing.Point(3, 7); + this.lbpanelcolor.Name = "lbpanelcolor"; + this.lbpanelcolor.Size = new System.Drawing.Size(88, 16); + this.lbpanelcolor.TabIndex = 0; + this.lbpanelcolor.Text = "Panel Colour:"; + // // pnlapplauncheroptions // this.pnlapplauncheroptions.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); @@ -1426,120 +1561,6 @@ namespace ShiftOS this.Label95.TabIndex = 0; this.Label95.Text = "Button Colour:"; // - // pnldesktoppaneloptions - // - this.pnldesktoppaneloptions.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.pnldesktoppaneloptions.Controls.Add(this.btnpanelbuttons); - this.pnldesktoppaneloptions.Controls.Add(this.lbwarning); - this.pnldesktoppaneloptions.Controls.Add(this.combodesktoppanelposition); - this.pnldesktoppaneloptions.Controls.Add(this.lbposition); - this.pnldesktoppaneloptions.Controls.Add(this.Label47); - this.pnldesktoppaneloptions.Controls.Add(this.txtdesktoppanelheight); - this.pnldesktoppaneloptions.Controls.Add(this.lbheight); - this.pnldesktoppaneloptions.Controls.Add(this.pnldesktoppanelcolour); - this.pnldesktoppaneloptions.Controls.Add(this.lbpanelcolor); - this.pnldesktoppaneloptions.Location = new System.Drawing.Point(135, 159); - this.pnldesktoppaneloptions.Name = "pnldesktoppaneloptions"; - this.pnldesktoppaneloptions.Size = new System.Drawing.Size(317, 140); - this.pnldesktoppaneloptions.TabIndex = 9; - this.pnldesktoppaneloptions.Visible = false; - // - // btnpanelbuttons - // - this.btnpanelbuttons.BackColor = System.Drawing.Color.White; - this.btnpanelbuttons.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btnpanelbuttons.Font = new System.Drawing.Font("Cambria", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btnpanelbuttons.Location = new System.Drawing.Point(193, 101); - this.btnpanelbuttons.Name = "btnpanelbuttons"; - this.btnpanelbuttons.Size = new System.Drawing.Size(119, 29); - this.btnpanelbuttons.TabIndex = 8; - this.btnpanelbuttons.Text = "Panel Buttons >"; - this.btnpanelbuttons.UseVisualStyleBackColor = false; - this.btnpanelbuttons.Click += new System.EventHandler(this.btnpanelbuttons_Click); - // - // lbwarning - // - this.lbwarning.Location = new System.Drawing.Point(3, 52); - this.lbwarning.Name = "lbwarning"; - this.lbwarning.Size = new System.Drawing.Size(290, 42); - this.lbwarning.TabIndex = 8; - this.lbwarning.Text = "Warning: If you set the panel position to the bottom you must hide your windows t" + - "askbar and restart ShiftOS on your host operating system to prevent a visual bug" + - "."; - // - // combodesktoppanelposition - // - this.combodesktoppanelposition.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.combodesktoppanelposition.FormattingEnabled = true; - this.combodesktoppanelposition.Items.AddRange(new object[] { - "Top", - "Bottom"}); - this.combodesktoppanelposition.Location = new System.Drawing.Point(103, 28); - this.combodesktoppanelposition.Name = "combodesktoppanelposition"; - this.combodesktoppanelposition.Size = new System.Drawing.Size(59, 24); - this.combodesktoppanelposition.TabIndex = 7; - this.combodesktoppanelposition.SelectedIndexChanged += new System.EventHandler(this.combodesktoppanelposition_SelectedIndexChanged); - // - // lbposition - // - this.lbposition.AutoSize = true; - this.lbposition.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lbposition.Location = new System.Drawing.Point(3, 31); - this.lbposition.Name = "lbposition"; - this.lbposition.Size = new System.Drawing.Size(97, 16); - this.lbposition.TabIndex = 6; - this.lbposition.Text = "Panel Position:"; - // - // Label47 - // - this.Label47.AutoSize = true; - this.Label47.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Label47.Location = new System.Drawing.Point(226, 8); - this.Label47.Name = "Label47"; - this.Label47.Size = new System.Drawing.Size(22, 16); - this.Label47.TabIndex = 5; - this.Label47.Text = "px"; - // - // txtdesktoppanelheight - // - this.txtdesktoppanelheight.BackColor = System.Drawing.Color.White; - this.txtdesktoppanelheight.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.txtdesktoppanelheight.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.txtdesktoppanelheight.ForeColor = System.Drawing.Color.Black; - this.txtdesktoppanelheight.Location = new System.Drawing.Point(189, 5); - this.txtdesktoppanelheight.Name = "txtdesktoppanelheight"; - this.txtdesktoppanelheight.Size = new System.Drawing.Size(37, 22); - this.txtdesktoppanelheight.TabIndex = 4; - this.txtdesktoppanelheight.ValueChanged += new System.EventHandler(this.txtdesktoppanelheight_ValueChanged); - // - // lbheight - // - this.lbheight.AutoSize = true; - this.lbheight.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lbheight.Location = new System.Drawing.Point(138, 7); - this.lbheight.Name = "lbheight"; - this.lbheight.Size = new System.Drawing.Size(50, 16); - this.lbheight.TabIndex = 2; - this.lbheight.Text = "Height:"; - // - // pnldesktoppanelcolour - // - this.pnldesktoppanelcolour.Location = new System.Drawing.Point(92, 5); - this.pnldesktoppanelcolour.Name = "pnldesktoppanelcolour"; - this.pnldesktoppanelcolour.Size = new System.Drawing.Size(41, 20); - this.pnldesktoppanelcolour.TabIndex = 1; - this.pnldesktoppanelcolour.MouseDown += new System.Windows.Forms.MouseEventHandler(this.ChangeDesktopPanelColor); - // - // lbpanelcolor - // - this.lbpanelcolor.AutoSize = true; - this.lbpanelcolor.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lbpanelcolor.Location = new System.Drawing.Point(3, 7); - this.lbpanelcolor.Name = "lbpanelcolor"; - this.lbpanelcolor.Size = new System.Drawing.Size(88, 16); - this.lbpanelcolor.TabIndex = 0; - this.lbpanelcolor.Text = "Panel Colour:"; - // // pnldesktopbackgroundoptions // this.pnldesktopbackgroundoptions.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); @@ -3511,6 +3532,7 @@ namespace ShiftOS // this.pgcontents.BackColor = System.Drawing.Color.White; this.pgcontents.Controls.Add(this.pnldesktopoptions); + this.pgcontents.Controls.Add(this.pnlluaoptions); this.pgcontents.Controls.Add(this.pnldesktopcomposition); this.pgcontents.Controls.Add(this.pnlreset); this.pgcontents.Controls.Add(this.pnlwindowsoptions); @@ -5054,6 +5076,38 @@ namespace ShiftOS // this.tmrfix.Interval = 5000; // + // pnlluaoptions + // + this.pnlluaoptions.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.pnlluaoptions.BackColor = System.Drawing.Color.White; + this.pnlluaoptions.Controls.Add(this.pnlluafield); + this.pnlluaoptions.Controls.Add(this.flmorebuttons); + this.pnlluaoptions.Location = new System.Drawing.Point(139, 9); + this.pnlluaoptions.Name = "pnlluaoptions"; + this.pnlluaoptions.Size = new System.Drawing.Size(457, 306); + this.pnlluaoptions.TabIndex = 21; + this.pnlluaoptions.Visible = false; + // + // flmorebuttons + // + this.flmorebuttons.AutoSize = true; + this.flmorebuttons.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.flmorebuttons.Dock = System.Windows.Forms.DockStyle.Top; + this.flmorebuttons.Location = new System.Drawing.Point(0, 0); + this.flmorebuttons.Name = "flmorebuttons"; + this.flmorebuttons.Size = new System.Drawing.Size(457, 0); + this.flmorebuttons.TabIndex = 0; + // + // pnlluafield + // + this.pnlluafield.Dock = System.Windows.Forms.DockStyle.Fill; + this.pnlluafield.Location = new System.Drawing.Point(0, 0); + this.pnlluafield.Name = "pnlluafield"; + this.pnlluafield.Size = new System.Drawing.Size(457, 306); + this.pnlluafield.TabIndex = 1; + // // Shifter // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -5069,15 +5123,15 @@ namespace ShiftOS this.pnlshifterintro.ResumeLayout(false); this.pnlshifterintro.PerformLayout(); this.pnldesktopoptions.ResumeLayout(false); + this.pnldesktoppaneloptions.ResumeLayout(false); + this.pnldesktoppaneloptions.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.txtdesktoppanelheight)).EndInit(); this.pnlapplauncheroptions.ResumeLayout(false); this.pnlapplauncheroptions.PerformLayout(); this.pnldesktopintro.ResumeLayout(false); this.pnldesktopintro.PerformLayout(); this.pnlpanelbuttonsoptions.ResumeLayout(false); this.pnlpanelbuttonsoptions.PerformLayout(); - this.pnldesktoppaneloptions.ResumeLayout(false); - this.pnldesktoppaneloptions.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.txtdesktoppanelheight)).EndInit(); this.pnldesktopbackgroundoptions.ResumeLayout(false); this.pnldesktopbackgroundoptions.PerformLayout(); this.pnlpanelclockoptions.ResumeLayout(false); @@ -5143,6 +5197,8 @@ namespace ShiftOS this.pnlbasic.PerformLayout(); this.pnlmenusintro.ResumeLayout(false); this.pnlmenucategories.ResumeLayout(false); + this.pnlluaoptions.ResumeLayout(false); + this.pnlluaoptions.PerformLayout(); this.ResumeLayout(false); } @@ -5556,5 +5612,9 @@ namespace ShiftOS private Label label150; private TextBox txtwinfadespeed; private Label label151; + private Button btnmore; + private Panel pnlluaoptions; + private FlowLayoutPanel flmorebuttons; + private Panel pnlluafield; } } \ No newline at end of file diff --git a/source/WindowsFormsApplication1/Shifter.cs b/source/WindowsFormsApplication1/Shifter.cs index 25e4dd2..3aad889 100644 --- a/source/WindowsFormsApplication1/Shifter.cs +++ b/source/WindowsFormsApplication1/Shifter.cs @@ -581,7 +581,7 @@ namespace ShiftOS SetPreviewSkin(false); AddCP(1); } - catch (Exception ex) + catch { txtdesktoppanelheight.Text = CustomizingSkin.desktoppanelheight.ToString(); } @@ -800,7 +800,7 @@ namespace ShiftOS SetPreviewSkin(false); AddCP(1); } - catch(Exception ex) + catch { txtappbuttontextsize.Text = CustomizingSkin.applicationbuttontextsize.ToString(); } @@ -828,7 +828,7 @@ namespace ShiftOS SetPreviewSkin(false); AddCP(1); } - catch (Exception ex) + catch { txtapplicationsbuttonheight.Text = CustomizingSkin.applicationbuttonheight.ToString(); } @@ -842,7 +842,7 @@ namespace ShiftOS SetPreviewSkin(false); AddCP(1); } - catch (Exception ex) + catch { txtapplauncherwidth.Text = CustomizingSkin.applaunchermenuholderwidth.ToString(); } @@ -1005,8 +1005,7 @@ namespace ShiftOS CustomizingSkin.panelbuttonwidth = Convert.ToInt16(txtpanelbuttonwidth.Text); AddCP(1); } - catch(Exception ex) - { + catch{ txtpanelbuttonwidth.Text = CustomizingSkin.panelbuttonwidth.ToString(); } SetPreviewSkin(false); @@ -1019,7 +1018,7 @@ namespace ShiftOS CustomizingSkin.panelbuttoninitialgap = Convert.ToInt16(txtpanelbuttoninitalgap.Text); AddCP(1); } - catch (Exception ex) + catch { txtpanelbuttoninitalgap.Text = CustomizingSkin.panelbuttoninitialgap.ToString(); } @@ -1033,7 +1032,7 @@ namespace ShiftOS CustomizingSkin.panelbuttonheight = Convert.ToInt16(txtpanelbuttonheight.Text); AddCP(1); } - catch (Exception ex) + catch { txtpanelbuttonheight.Text = CustomizingSkin.panelbuttonheight.ToString(); } @@ -1047,7 +1046,7 @@ namespace ShiftOS CustomizingSkin.panelbuttongap = Convert.ToInt16(txtpanelbuttongap.Text); AddCP(1); } - catch (Exception ex) + catch { txtpanelbuttongap.Text = CustomizingSkin.panelbuttongap.ToString(); } @@ -1121,7 +1120,7 @@ namespace ShiftOS CustomizingSkin.panelbuttoniconsize = Convert.ToInt16(txtpanelbuttoniconsize.Text); AddCP(1); } - catch (Exception ex) + catch { txtpanelbuttoniconsize.Text = CustomizingSkin.panelbuttoniconsize.ToString(); } @@ -1135,7 +1134,7 @@ namespace ShiftOS CustomizingSkin.panelbuttoniconside = Convert.ToInt16(txtpanelbuttoniconside.Text); AddCP(1); } - catch (Exception ex) + catch { txtpanelbuttoniconside.Text = CustomizingSkin.panelbuttoniconside.ToString(); } @@ -1149,7 +1148,7 @@ namespace ShiftOS CustomizingSkin.panelbuttonicontop = Convert.ToInt16(txtpanelbuttonicontop.Text); AddCP(1); } - catch (Exception ex) + catch { txtpanelbuttonicontop.Text = CustomizingSkin.panelbuttonicontop.ToString(); } @@ -1163,7 +1162,7 @@ namespace ShiftOS CustomizingSkin.panelbuttontextside = Convert.ToInt16(txtpanelbuttontextside.Text); AddCP(1); } - catch (Exception ex) + catch { txtpanelbuttontextside.Text = CustomizingSkin.panelbuttontextside.ToString(); } @@ -1177,7 +1176,7 @@ namespace ShiftOS CustomizingSkin.panelbuttontexttop = Convert.ToInt16(txtpanelbuttontexttop.Text); AddCP(1); } - catch (Exception ex) + catch { txtpanelbuttontexttop.Text = CustomizingSkin.panelbuttontexttop.ToString(); } @@ -1191,7 +1190,7 @@ namespace ShiftOS CustomizingSkin.panelbuttontextsize = Convert.ToInt16(txtpaneltextbuttonsize.Text); AddCP(1); } - catch (Exception ex) + catch { txtpaneltextbuttonsize.Text = CustomizingSkin.panelbuttontextsize.ToString(); } @@ -1205,7 +1204,7 @@ namespace ShiftOS CustomizingSkin.panelbuttonfromtop = Convert.ToInt16(txtpanelbuttontop.Text); AddCP(1); } - catch (Exception ex) + catch { txtpanelbuttontop.Text = CustomizingSkin.panelbuttonfromtop.ToString(); } @@ -1297,7 +1296,7 @@ namespace ShiftOS CustomizingSkin.panelclocktextsize = Convert.ToInt16(txtclocktextsize.Text); AddCP(1); } - catch (Exception ex) + catch { txtclocktextsize.Text = CustomizingSkin.panelclocktextsize.ToString(); } @@ -1311,7 +1310,7 @@ namespace ShiftOS CustomizingSkin.panelclocktexttop = Convert.ToInt16(txtclocktextfromtop.Text); AddCP(1); } - catch (Exception ex) + catch { txtclocktextfromtop.Text = CustomizingSkin.panelclocktexttop.ToString(); //Funny story: I accidentally assigned 'panelcocktexttop' to that property. xD - Michael VanOverbeek } @@ -1358,7 +1357,7 @@ namespace ShiftOS CustomizingSkin.titletextfromtop = Convert.ToInt16(txttitletexttop.Text); AddCP(1); } - catch(Exception ex) + catch { txttitletexttop.Text = CustomizingSkin.titletextfromtop.ToString(); } @@ -1372,7 +1371,7 @@ namespace ShiftOS CustomizingSkin.titletextfromside = Convert.ToInt16(txttitletextside.Text); AddCP(1); } - catch (Exception ex) + catch { txttitletextside.Text = CustomizingSkin.titletextfromside.ToString(); } @@ -1407,7 +1406,7 @@ namespace ShiftOS CustomizingSkin.titletextfontsize = Convert.ToInt16(txttitletextsize.Text); AddCP(1); } - catch (Exception ex) + catch { txttitletextsize.Text = CustomizingSkin.titletextfontsize.ToString(); } @@ -1746,7 +1745,7 @@ namespace ShiftOS CustomizingSkin.borderwidth = Convert.ToInt16(txtbordersize.Text); AddCP(1); } - catch(Exception ex) + catch { txtbordersize.Text = CustomizingSkin.borderwidth.ToString(); } @@ -1836,7 +1835,7 @@ namespace ShiftOS CustomizingSkin.titlebarheight = Convert.ToInt16(txttitlebarheight.Text); AddCP(1); } - catch(Exception ex) + catch { txttitlebarheight.Text = CustomizingSkin.titlebarheight.ToString(); } @@ -1850,7 +1849,7 @@ namespace ShiftOS CustomizingSkin.titlebarcornerwidth = Convert.ToInt16(txttitlebarcornerwidth.Text); AddCP(1); } - catch (Exception ex) + catch { txttitlebarcornerwidth.Text = CustomizingSkin.titlebarcornerwidth.ToString(); } @@ -1926,7 +1925,7 @@ namespace ShiftOS CustomizingSkin.titleiconfromside = Convert.ToInt16(txticonfromside.Text); AddCP(1); } - catch (Exception ex) + catch { txticonfromside.Text = CustomizingSkin.titleiconfromside.ToString(); } @@ -1940,7 +1939,7 @@ namespace ShiftOS CustomizingSkin.titleiconfromtop = Convert.ToInt16(txticonfromtop.Text); AddCP(1); } - catch (Exception ex) + catch { txticonfromtop.Text = CustomizingSkin.titleiconfromtop.ToString(); } @@ -2064,7 +2063,7 @@ namespace ShiftOS CustomizingSkin.minbtnsize.Height = Convert.ToInt16(txtminimizebuttonheight.Text); AddCP(1); } - catch(Exception ex) + catch { txtminimizebuttonheight.Text = CustomizingSkin.minbtnsize.Height.ToString(); } @@ -2078,7 +2077,7 @@ namespace ShiftOS CustomizingSkin.minbtnsize.Width = Convert.ToInt16(txtminimizebuttonwidth.Text); AddCP(1); } - catch (Exception ex) + catch { txtminimizebuttonwidth.Text = CustomizingSkin.minbtnsize.Width.ToString(); } @@ -2092,7 +2091,7 @@ namespace ShiftOS CustomizingSkin.minbtnfromtop = Convert.ToInt16(txtminimizebuttontop.Text); AddCP(1); } - catch(Exception ex) + catch { txtminimizebuttontop.Text = CustomizingSkin.minbtnfromtop.ToString(); } @@ -2106,7 +2105,7 @@ namespace ShiftOS CustomizingSkin.minbtnfromside = Convert.ToInt16(txtminimizebuttonside.Text); AddCP(1); } - catch (Exception ex) + catch { txtminimizebuttonside.Text = CustomizingSkin.minbtnfromside.ToString(); } @@ -2155,7 +2154,7 @@ namespace ShiftOS CustomizingSkin.rollbtnsize.Height = Convert.ToInt16(txtrollupbuttonheight.Text); AddCP(1); } - catch (Exception ex) + catch { txtrollupbuttonheight.Text = CustomizingSkin.rollbtnsize.Height.ToString(); } @@ -2169,7 +2168,7 @@ namespace ShiftOS CustomizingSkin.rollbtnsize.Width = Convert.ToInt16(txtrollupbuttonwidth.Text); AddCP(1); } - catch (Exception ex) + catch { txtrollupbuttonwidth.Text = CustomizingSkin.rollbtnsize.Width.ToString(); } @@ -2183,7 +2182,7 @@ namespace ShiftOS CustomizingSkin.rollbtnfromtop = Convert.ToInt16(txtrollupbuttontop.Text); AddCP(1); } - catch (Exception ex) + catch { txtrollupbuttontop.Text = CustomizingSkin.rollbtnfromtop.ToString(); } @@ -2197,7 +2196,7 @@ namespace ShiftOS CustomizingSkin.rollbtnfromside = Convert.ToInt16(txtrollupbuttonside.Text); AddCP(1); } - catch (Exception ex) + catch { txtrollupbuttonside.Text = CustomizingSkin.rollbtnfromside.ToString(); } @@ -2246,7 +2245,7 @@ namespace ShiftOS CustomizingSkin.closebtnsize.Height = Convert.ToInt16(txtclosebuttonheight.Text); AddCP(1); } - catch (Exception ex) + catch { txtclosebuttonheight.Text = CustomizingSkin.closebtnsize.Height.ToString(); } @@ -2260,7 +2259,7 @@ namespace ShiftOS CustomizingSkin.closebtnsize.Width = Convert.ToInt16(txtclosebuttonwidth.Text); AddCP(1); } - catch (Exception ex) + catch { txtclosebuttonwidth.Text = CustomizingSkin.closebtnsize.Width.ToString(); } @@ -2274,7 +2273,7 @@ namespace ShiftOS CustomizingSkin.closebtnfromtop = Convert.ToInt16(txtclosebuttonfromtop.Text); AddCP(1); } - catch (Exception ex) + catch { txtclosebuttonfromtop.Text = CustomizingSkin.closebtnfromtop.ToString(); } @@ -2288,7 +2287,7 @@ namespace ShiftOS CustomizingSkin.closebtnfromside = Convert.ToInt16(txtclosebuttonfromside.Text); AddCP(1); } - catch (Exception ex) + catch { txtclosebuttonfromside.Text = CustomizingSkin.closebtnfromside.ToString(); } @@ -2899,7 +2898,7 @@ namespace ShiftOS CustomizingSkin.DragFadeInterval = Convert.ToInt32(txtfadespeed.Text); AddCP(1); } - catch(Exception ex) + catch { txtfadespeed.Text = CustomizingSkin.DragFadeInterval.ToString(); } @@ -2912,7 +2911,7 @@ namespace ShiftOS CustomizingSkin.DragFadeSpeed = Convert.ToDouble(txtdragfadedec.Text); AddCP(1); } - catch (Exception ex) + catch { txtdragfadedec.Text = CustomizingSkin.DragFadeSpeed.ToString(); } @@ -2932,7 +2931,7 @@ namespace ShiftOS CustomizingSkin.DragFadeLevel = Convert.ToDouble(txtdragopacitydec.Text); AddCP(1); } - catch (Exception ex) + catch { txtdragopacitydec.Text = CustomizingSkin.DragFadeLevel.ToString(); } @@ -2945,7 +2944,7 @@ namespace ShiftOS CustomizingSkin.ShakeMaxOffset = Convert.ToInt32(txtshakemax.Text); AddCP(1); } - catch (Exception ex) + catch { txtshakemax.Text = CustomizingSkin.ShakeMaxOffset.ToString(); } @@ -2958,7 +2957,7 @@ namespace ShiftOS CustomizingSkin.ShakeMinOffset = Convert.ToInt32(txtshakeminoffset.Text); AddCP(1); } - catch (Exception ex) + catch { txtshakeminoffset.Text = CustomizingSkin.ShakeMinOffset.ToString(); } @@ -2971,7 +2970,7 @@ namespace ShiftOS CustomizingSkin.WindowFadeTime = Convert.ToInt32(txtwinfadespeed.Text); AddCP(1); } - catch (Exception ex) + catch { txtwinfadespeed.Text = CustomizingSkin.WindowFadeTime.ToString(); } @@ -2984,10 +2983,111 @@ namespace ShiftOS CustomizingSkin.WindowFadeSpeed = Convert.ToDecimal(txtwinfadedec.Text); AddCP(1); } - catch (Exception ex) + catch { txtwinfadedec.Text = CustomizingSkin.WindowFadeSpeed.ToString(); } } + + private void btnmore_Click(object sender, EventArgs e) + { + pnlluaoptions.Show(); + pnlluaoptions.BringToFront(); + SetupLuaUI(); + + } + + public void SetupLuaUI() + { + pnlluafield.Controls.Clear(); + flmorebuttons.Controls.Clear(); + if (API.LuaShifterRegistry == null) + { + var l = new Label(); + l.Dock = DockStyle.Fill; + l.TextAlign = ContentAlignment.MiddleCenter; + l.Font = new Font("Microsoft Sans Serif", 12); + l.Text = @"Nothing to show here. + +There are no options to show here yet. + +You can add options in the Lua interpreter using the shifter_add_category(string name), shifter_add_value(string category, string name, value), and shifter_remove_category(string name) methods. Applications may also add their own values."; + pnlluafield.Controls.Add(l); + l.Show(); + } + else + { + foreach (var kv in API.LuaShifterRegistry) + { + var b = new Button(); + b.Text = kv.Key; + b.FlatStyle = FlatStyle.Flat; + b.AutoSize = true; + b.AutoSizeMode = AutoSizeMode.GrowAndShrink; + flmorebuttons.Controls.Add(b); + b.Show(); + b.Click += (object s, EventArgs a) => + { + SetupLuaForm(kv.Value); + }; + } + } + } + + public void SetupLuaForm(Dictionary d) + { + pnlluafield.Controls.Clear(); + foreach(var kv in d) + { + IShifterSetting l = new ShifterTextInput(); + if (kv.Value is string) + l = new ShifterTextInput(); + if (kv.Value is Image) + l = new ShifterGraphicInput(); + if (kv.Value is Color) + l = new ShifterColorInput(); + if (kv.Value is int || kv.Value is float || kv.Value is double || kv.Value is decimal) + l = new ShifterIntInput(); + if(l is ShifterIntInput) + { + var i = l as ShifterIntInput; + if (kv.Value is int) + i.NoDecimal = true; + else + i.NoDecimal = false; + } + if (pnlluafield.Controls.Count > 0) + { + var ctrl = pnlluafield.Controls[pnlluafield.Controls.Count - 1]; + l.Location = new Point(ctrl.Left + ctrl.Width + 5, ctrl.Top); + if(l.Left + l.Width > pnlluafield.Width) + { + l.Left = 2; + l.Top = ctrl.Top + ctrl.Height + 2; + } + } + else + { + l.Location = new Point(2, 2); + } + + pnlluafield.Controls.Add(l); + l.Show(); + l.Font = new Font("Microsoft Sans Serif", 9); + l.Text = kv.Key; + l.Value = kv.Value; + l.OnValueChange += (hello, its_me) => + { + foreach(var dict in API.LuaShifterRegistry) + { + if(API.LuaShifterRegistry[dict.Key] == d) + { + API.LuaShifterRegistry[dict.Key][kv.Key] = l.Value; + } + } + }; + + } + } } } diff --git a/source/WindowsFormsApplication1/Shifter.resx b/source/WindowsFormsApplication1/Shifter.resx index dbf1220..2b9e8c1 100644 --- a/source/WindowsFormsApplication1/Shifter.resx +++ b/source/WindowsFormsApplication1/Shifter.resx @@ -137,6 +137,9 @@ Simply click the buttons on the right to choose a category, and then from there, 508, 17 + + 508, 17 + Have you made a nice skin and want a clean slate to make another? Do you want to reverse back to regular ShiftOS? Well, fear not, the 'Reset' button is here. Just click it, and ShiftOS will wok it's magic. diff --git a/source/WindowsFormsApplication1/ShifterColorInput.Designer.cs b/source/WindowsFormsApplication1/ShifterColorInput.Designer.cs new file mode 100644 index 0000000..47cf0a1 --- /dev/null +++ b/source/WindowsFormsApplication1/ShifterColorInput.Designer.cs @@ -0,0 +1,77 @@ +namespace ShiftOS +{ + partial class ShifterColorInput + { + /// + /// 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.pnlmainbuttoncolour = new System.Windows.Forms.Panel(); + this.lblabel = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // pnlmainbuttoncolour + // + this.pnlmainbuttoncolour.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Right))); + this.pnlmainbuttoncolour.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.pnlmainbuttoncolour.Location = new System.Drawing.Point(128, 3); + this.pnlmainbuttoncolour.MaximumSize = new System.Drawing.Size(41, 20); + this.pnlmainbuttoncolour.Name = "pnlmainbuttoncolour"; + this.pnlmainbuttoncolour.Size = new System.Drawing.Size(41, 20); + this.pnlmainbuttoncolour.TabIndex = 3; + // + // lblabel + // + this.lblabel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.lblabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lblabel.Location = new System.Drawing.Point(3, 6); + this.lblabel.Name = "lblabel"; + this.lblabel.Size = new System.Drawing.Size(122, 19); + this.lblabel.TabIndex = 2; + this.lblabel.Text = "Main Button Colour:"; + this.lblabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // ShifterColorInput + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.pnlmainbuttoncolour); + this.Controls.Add(this.lblabel); + this.Name = "ShifterColorInput"; + this.Size = new System.Drawing.Size(173, 28); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Panel pnlmainbuttoncolour; + private System.Windows.Forms.Label lblabel; + + } +} diff --git a/source/WindowsFormsApplication1/ShifterColorInput.cs b/source/WindowsFormsApplication1/ShifterColorInput.cs new file mode 100644 index 0000000..11bedf0 --- /dev/null +++ b/source/WindowsFormsApplication1/ShifterColorInput.cs @@ -0,0 +1,47 @@ +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; + +namespace ShiftOS +{ + public partial class ShifterColorInput : IShifterSetting + { + public ShifterColorInput() + { + InitializeComponent(); + pnlmainbuttoncolour.Click += (o, e) => + { + API.CreateColorPickerSession(Text, pnlmainbuttoncolour.BackColor); + API.ColorPickerSession.FormClosing += (s, a) => + { + var res = API.GetLastColorFromSession(); + pnlmainbuttoncolour.BackColor = res; + InvokeEvent(o, e); + }; + }; + } + + public override string Text + { + get { return lblabel.Text; } + set { lblabel.Text = value; } + } + + public override object Value + { + get { return pnlmainbuttoncolour.BackColor; } + set + { + pnlmainbuttoncolour.BackColor = (Color)value; + } + } + + + } +} diff --git a/source/WindowsFormsApplication1/ShifterColorInput.resx b/source/WindowsFormsApplication1/ShifterColorInput.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/source/WindowsFormsApplication1/ShifterColorInput.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + \ No newline at end of file diff --git a/source/WindowsFormsApplication1/ShifterGraphicInput.Designer.cs b/source/WindowsFormsApplication1/ShifterGraphicInput.Designer.cs new file mode 100644 index 0000000..b09416f --- /dev/null +++ b/source/WindowsFormsApplication1/ShifterGraphicInput.Designer.cs @@ -0,0 +1,76 @@ +namespace ShiftOS +{ + partial class ShifterGraphicInput + { + /// + /// 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.pnlmainbuttoncolour = new System.Windows.Forms.Panel(); + this.lblabel = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // pnlmainbuttoncolour + // + this.pnlmainbuttoncolour.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Right))); + this.pnlmainbuttoncolour.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.pnlmainbuttoncolour.Location = new System.Drawing.Point(129, 3); + this.pnlmainbuttoncolour.MaximumSize = new System.Drawing.Size(41, 20); + this.pnlmainbuttoncolour.Name = "pnlmainbuttoncolour"; + this.pnlmainbuttoncolour.Size = new System.Drawing.Size(41, 20); + this.pnlmainbuttoncolour.TabIndex = 3; + // + // lblabel + // + this.lblabel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.lblabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lblabel.Location = new System.Drawing.Point(3, 6); + this.lblabel.Name = "lblabel"; + this.lblabel.Size = new System.Drawing.Size(123, 18); + this.lblabel.TabIndex = 2; + this.lblabel.Text = "Main Button Colour:"; + this.lblabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // ShifterGraphicInput + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.pnlmainbuttoncolour); + this.Controls.Add(this.lblabel); + this.Name = "ShifterGraphicInput"; + this.Size = new System.Drawing.Size(174, 27); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Panel pnlmainbuttoncolour; + private System.Windows.Forms.Label lblabel; + } +} diff --git a/source/WindowsFormsApplication1/ShifterGraphicInput.cs b/source/WindowsFormsApplication1/ShifterGraphicInput.cs new file mode 100644 index 0000000..8e15e07 --- /dev/null +++ b/source/WindowsFormsApplication1/ShifterGraphicInput.cs @@ -0,0 +1,49 @@ +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; + +namespace ShiftOS +{ + public partial class ShifterGraphicInput : IShifterSetting + { + public ShifterGraphicInput() + { + InitializeComponent(); + pnlmainbuttoncolour.Click += (o, e) => + { + API.CreateGraphicPickerSession(Text, false); + API.GraphicPickerSession.FormClosing += (s, a) => + { + var res = API.GetGraphicPickerResult(); + if(res != "fail") + { + pnlmainbuttoncolour.BackgroundImage = API.GraphicPickerSession.IdleImage; + InvokeEvent(o, e); + } + }; + }; + } + + public override string Text + { + get { return lblabel.Text; } + set { lblabel.Text = value; } + } + + public override object Value + { + get { return pnlmainbuttoncolour.BackgroundImage; } + set + { + pnlmainbuttoncolour.BackgroundImage = (Image)value; + } + } + + } +} diff --git a/source/WindowsFormsApplication1/ShifterGraphicInput.resx b/source/WindowsFormsApplication1/ShifterGraphicInput.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/source/WindowsFormsApplication1/ShifterGraphicInput.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + \ No newline at end of file diff --git a/source/WindowsFormsApplication1/ShifterIntInput.Designer.cs b/source/WindowsFormsApplication1/ShifterIntInput.Designer.cs new file mode 100644 index 0000000..130db0c --- /dev/null +++ b/source/WindowsFormsApplication1/ShifterIntInput.Designer.cs @@ -0,0 +1,83 @@ +namespace ShiftOS +{ + partial class ShifterIntInput + { + /// + /// 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.txttext = new System.Windows.Forms.TextBox(); + this.Label51 = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // txttext + // + this.txttext.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Right))); + this.txttext.BackColor = System.Drawing.Color.White; + this.txttext.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.txttext.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.txttext.ForeColor = System.Drawing.Color.Black; + this.txttext.Location = new System.Drawing.Point(174, 3); + this.txttext.MinimumSize = new System.Drawing.Size(5, 2); + this.txttext.Name = "txttext"; + this.txttext.Size = new System.Drawing.Size(36, 22); + this.txttext.TabIndex = 32; + this.txttext.TextChanged += new System.EventHandler(this.txttext_TextChanged); + // + // Label51 + // + this.Label51.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.Label51.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.Label51.Location = new System.Drawing.Point(0, 0); + this.Label51.Name = "Label51"; + this.Label51.Size = new System.Drawing.Size(168, 29); + this.Label51.TabIndex = 31; + this.Label51.Text = "Label:"; + this.Label51.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // ShifterIntInput + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.Controls.Add(this.txttext); + this.Controls.Add(this.Label51); + this.Name = "ShifterIntInput"; + this.Size = new System.Drawing.Size(213, 29); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TextBox txttext; + private System.Windows.Forms.Label Label51; + + } +} diff --git a/source/WindowsFormsApplication1/ShifterIntInput.cs b/source/WindowsFormsApplication1/ShifterIntInput.cs new file mode 100644 index 0000000..782d265 --- /dev/null +++ b/source/WindowsFormsApplication1/ShifterIntInput.cs @@ -0,0 +1,62 @@ +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; + +namespace ShiftOS +{ + public partial class ShifterIntInput : IShifterSetting + { + public ShifterIntInput() + { + InitializeComponent(); + } + + public bool NoDecimal + { + get; + set; + } + + public override string Text + { + get { return Label51.Text; } + set { Label51.Text = value; } + } + + public override object Value + { + get { + if (NoDecimal) + return Convert.ToInt32(txttext.Text); + else + return Convert.ToDecimal(txttext.Text); + } + set + { + txttext.Text = value.ToString(); + } + } + + private void txttext_TextChanged(object sender, EventArgs e) + { + try + { + if (NoDecimal) + Value = Convert.ToInt32(txttext.Text); + else + Value = Convert.ToDecimal(txttext.Text); + InvokeEvent(sender, e); + } + catch + { + txttext.Text = Value.ToString(); + } + } + } +} diff --git a/source/WindowsFormsApplication1/ShifterIntInput.resx b/source/WindowsFormsApplication1/ShifterIntInput.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/source/WindowsFormsApplication1/ShifterIntInput.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + \ No newline at end of file diff --git a/source/WindowsFormsApplication1/ShifterTextInput.Designer.cs b/source/WindowsFormsApplication1/ShifterTextInput.Designer.cs new file mode 100644 index 0000000..9da62c6 --- /dev/null +++ b/source/WindowsFormsApplication1/ShifterTextInput.Designer.cs @@ -0,0 +1,78 @@ +namespace ShiftOS +{ + partial class ShifterTextInput + { + /// + /// 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.txttext = new System.Windows.Forms.TextBox(); + this.Label51 = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // txttext + // + this.txttext.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.txttext.BackColor = System.Drawing.Color.White; + this.txttext.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.txttext.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.txttext.ForeColor = System.Drawing.Color.Black; + this.txttext.Location = new System.Drawing.Point(106, 7); + this.txttext.MinimumSize = new System.Drawing.Size(5, 2); + this.txttext.Name = "txttext"; + this.txttext.Size = new System.Drawing.Size(116, 22); + this.txttext.TabIndex = 32; + // + // Label51 + // + this.Label51.Dock = System.Windows.Forms.DockStyle.Left; + this.Label51.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.Label51.Location = new System.Drawing.Point(0, 0); + this.Label51.Name = "Label51"; + this.Label51.Size = new System.Drawing.Size(100, 29); + this.Label51.TabIndex = 31; + this.Label51.Text = "Label:"; + this.Label51.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // ShifterTextInput + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.Controls.Add(this.txttext); + this.Controls.Add(this.Label51); + this.Name = "ShifterTextInput"; + this.Size = new System.Drawing.Size(222, 29); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TextBox txttext; + private System.Windows.Forms.Label Label51; + } +} diff --git a/source/WindowsFormsApplication1/ShifterTextInput.cs b/source/WindowsFormsApplication1/ShifterTextInput.cs new file mode 100644 index 0000000..6e59649 --- /dev/null +++ b/source/WindowsFormsApplication1/ShifterTextInput.cs @@ -0,0 +1,65 @@ +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; + +namespace ShiftOS +{ + public partial class ShifterTextInput : IShifterSetting + { + public ShifterTextInput() + { + InitializeComponent(); + txttext.TextChanged += (o, e) => + { + Value = txttext.Text; + InvokeEvent(o, e); + }; + } + + public override string Text + { + get + { + return Label51.Text; + } + set + { + Label51.Text = value; + } + } + + public override object Value + { + get + { + return txttext.Text; + } + set + { + txttext.Text = value as string; + } + } + + + + } + + public class IShifterSetting : UserControl + { + public virtual string Text { get; set; } + public virtual object Value { get; set; } + public event EventHandler OnValueChange; + + public void InvokeEvent(object s, EventArgs a) + { + OnValueChange?.Invoke(s, a); + } + } + +} diff --git a/source/WindowsFormsApplication1/ShifterTextInput.resx b/source/WindowsFormsApplication1/ShifterTextInput.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/source/WindowsFormsApplication1/ShifterTextInput.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + \ No newline at end of file diff --git a/source/WindowsFormsApplication1/Shiftnet.cs b/source/WindowsFormsApplication1/Shiftnet.cs index cd334a9..cbcab1b 100644 --- a/source/WindowsFormsApplication1/Shiftnet.cs +++ b/source/WindowsFormsApplication1/Shiftnet.cs @@ -87,7 +87,7 @@ namespace ShiftOS return HtmlTemplate.Replace("#BODY#", "That page was not found."); } } - catch (WebException ex) + catch { LastUrl = "shiftnet://not_found"; return HtmlTemplate.Replace("#BODY#", "That page was not found."); diff --git a/source/WindowsFormsApplication1/ShiftnetDecryptor.cs b/source/WindowsFormsApplication1/ShiftnetDecryptor.cs index c31a6dc..dbf086e 100644 --- a/source/WindowsFormsApplication1/ShiftnetDecryptor.cs +++ b/source/WindowsFormsApplication1/ShiftnetDecryptor.cs @@ -46,7 +46,7 @@ namespace ShiftOS RecursiveControlSetup(c); } } - catch (Exception ex) + catch { } @@ -87,7 +87,7 @@ namespace ShiftOS { encrypted_contents = new WebClient().DownloadString(currentaddress); } - catch(Exception ex) + catch { WriteLine(" *** ERROR: Remote file could not be accessed."); tmrdecrypt.Stop(); diff --git a/source/WindowsFormsApplication1/Shiftorium.cs b/source/WindowsFormsApplication1/Shiftorium.cs index 9c281e9..ce9dbfc 100644 --- a/source/WindowsFormsApplication1/Shiftorium.cs +++ b/source/WindowsFormsApplication1/Shiftorium.cs @@ -77,7 +77,7 @@ namespace Shiftorium btnhack.Hide(); } } - catch(Exception ex) + catch { lbcategory.Text = "No upgrades!"; } @@ -132,12 +132,12 @@ namespace Shiftorium lbupgradename.Text = upgrade.Name.Replace($" - {upgrade.Cost} CP", ""); lbudescription.Text = upgrade.Description; btnbuy.Show(); - lbprice.Text = upgrade.Cost.ToString() + " CP"; + lbprice.Text = (upgrade.Cost / API.CurrentSave.PriceDivider).ToString() + " CP"; picpreview.Image = upgrade.Preview; selectedUpgrade = upgrade; } } - } catch(Exception ex) + } catch { //do nothing. } diff --git a/source/WindowsFormsApplication1/Terminal.cs b/source/WindowsFormsApplication1/Terminal.cs index 4b4a3b8..944b333 100644 --- a/source/WindowsFormsApplication1/Terminal.cs +++ b/source/WindowsFormsApplication1/Terminal.cs @@ -19,9 +19,12 @@ namespace ShiftOS { public partial class Terminal : Form { + string current_dir = ""; + public Terminal() { InitializeComponent(); + current_dir = Paths.SaveRoot; } public Terminal(bool modlog) @@ -29,6 +32,7 @@ namespace ShiftOS ModLogger = modlog; InitializeComponent(); API.LoggerTerminal = this; + current_dir = Paths.SaveRoot; } public void StartOtherPlayerStory() @@ -110,7 +114,7 @@ namespace ShiftOS tmrshutdown.Tick += new EventHandler(tmrshutdown_Tick); if (Hacking == false) { - WriteLine(SaveSystem.Utilities.LoadedSave.username + "@" + SaveSystem.Utilities.LoadedSave.osname + " $> "); + WriteLine(prefix); } txtterm.Select(txtterm.TextLength, 0); if (API.Upgrades["terminalscrollbar"] == true) @@ -186,10 +190,12 @@ namespace ShiftOS int firstrun; public bool sendinputtomod = false; + string prefix = $"{API.Username}@{API.OSName} $> "; + private void ReadCommand() { command = txtterm.Lines[txtterm.Lines.Length - 1]; - command = command.Replace(SaveSystem.Utilities.LoadedSave.username + "@" + SaveSystem.Utilities.LoadedSave.osname + " $> ", ""); + command = command.Replace(prefix, ""); command = command.ToLower(); } @@ -393,20 +399,12 @@ namespace ShiftOS if (command == "clear") { - txtterm.Text = txtterm.Text + SaveSystem.Utilities.LoadedSave.username + "@" + SaveSystem.Utilities.LoadedSave.osname + " $> "; + txtterm.Text = txtterm.Text + prefix; txtterm.Select(txtterm.Text.Length, 0); } - else if (command == "lua") - { - if (Lua_API.UseLuaAPI == false) - { - txtterm.Text = txtterm.Text + Environment.NewLine + SaveSystem.Utilities.LoadedSave.username + "@" + SaveSystem.Utilities.LoadedSave.osname + " $> "; - txtterm.Select(txtterm.Text.Length, 0); - } - } else { - txtterm.Text = txtterm.Text + Environment.NewLine + SaveSystem.Utilities.LoadedSave.username + "@" + SaveSystem.Utilities.LoadedSave.osname + " $> "; + txtterm.Text = txtterm.Text + Environment.NewLine + prefix; txtterm.Select(txtterm.Text.Length, 0); } trackpos = 0; @@ -585,6 +583,11 @@ Password: z7fjsd3"); t.Start(); } + public void SetPrefix(string _prefix) + { + prefix = _prefix; + } + internal void StartBridgeToMidGame() { var t2 = new System.Windows.Forms.Timer(); @@ -787,7 +790,7 @@ Password: z7fjsd3"); WriteLine($"Description: {h.Description}"); WriteLine(Environment.NewLine + "LEFT: Previous Attack, RIGHT: Next Attack, ENTER: Confirm"); } - catch (Exception ex) + catch { WriteLine("There are no entries to display in this list."); } @@ -1234,7 +1237,6 @@ Password: z7fjsd3"); { System.Windows.Forms.Timer tmrstory = new System.Windows.Forms.Timer(); tmrstory.Interval = 10000; - int i = 0; WriteLine("IP connecting as 'Maureen Fenn'..."); API.PlaySound(Properties.Resources.dial_up_modem_02); var t = new Thread(new ThreadStart(new Action(() => @@ -1368,12 +1370,69 @@ Password: z7fjsd3"); private bool LuaMode = false; + public string GetPath(string path) + { + return path.Replace(Paths.SaveRoot, "").Replace(OSInfo.DirectorySeparator, "/"); + } + + public string GetParent(string path) + { + var d = new DirectoryInfo(path); + return d.Parent.FullName; + } + public void DoCommand() { API.LastRanCommand = command; string[] args = command.ToLower().Split(' '); switch (args[0]) { + case "ls": + case "dir": + if(API.Upgrades["fileskimmer"]) + { + foreach(var d in Directory.GetDirectories(current_dir)) + { + WriteLine($"[DIR] {new DirectoryInfo(d).Name}"); + } + foreach (var d in Directory.GetFiles(current_dir)) + { + WriteLine($"{new FileInfo(d).Name}"); + } + } + else + { + wrongcommand(); + } + break; + case "cd": + if (API.Upgrades["fileskimmer"]) + { + if (args[1] == "..") + { + if (GetPath(current_dir) != "/") + { + current_dir = GetParent(current_dir); + SetPrefix($"{API.Username}@{API.OSName} in {GetPath(current_dir)} $> "); + } + else + { + WriteLine("cd: Can't go up past the root."); + } + } + else + { + string newdir = current_dir + OSInfo.DirectorySeparator; + foreach (var dir in Directory.GetDirectories(current_dir)) + { + if (new DirectoryInfo(dir).Name.ToLower() == args[1]) + newdir = dir; + } + current_dir = newdir; + SetPrefix($"{API.Username}@{API.OSName} in {GetPath(current_dir)} $> "); + } + } + break; case "upg": if(API.DeveloperMode) { @@ -1467,6 +1526,9 @@ Password: z7fjsd3"); WriteLine($"Hostname: {client.Key}, Port: {client.Value.RemotePort}, Online: {client.Value.IsConnected}"); } break; + case "gui": + API.CreateForm(new ConnectionManager(), "Connections", API.GetIcon("Connections")); + break; case "drop": foreach(var client in Package_Grabber.clients) { @@ -1497,7 +1559,7 @@ Password: z7fjsd3"); break; } } - catch(Exception ex) + catch { WriteLine("connections: Missing arguments."); } @@ -1526,7 +1588,7 @@ Password: z7fjsd3"); break; } } - catch(Exception ex) + catch { WriteLine("Missing arguments."); } @@ -1548,29 +1610,11 @@ Password: z7fjsd3"); WriteLine($"make: *** No rule to make target \"{realpath}\". Stop."); } } - catch(Exception ex) + catch { WriteLine("make: Invalid arguments."); } break; - case "toggle_music": - if (API.DeveloperMode) - { - if (Audio.Enabled == false) - { - WriteLine(@"Music enabled. - -Warning: The music player code in ShiftOS has a memory leak issue and is quite CPU-intensive. If your CPU fan starts to spin up while listening to a song, that's why. - -Warning: Music is not embedded within the game. You must download the external resources directory at http://playshiftos.ml/shiftos/resources.zip to have applications play their music."); - } - Audio.Enabled = !Audio.Enabled; - } - else - { - wrongcommand(); - } - break; case "linux": if(API.DeveloperMode) { @@ -1613,7 +1657,7 @@ Warning: Music is not embedded within the game. You must download the external r WriteLine("Lua script file not found."); } } - catch (Exception ex) + catch { this.LuaMode = true; this.Interpreter = new LuaInterpreter(); @@ -1946,7 +1990,7 @@ HIJACKER is a utility that allows you to hijack any system and install ShiftOS o break; } } - catch(Exception ex) + catch { WriteLine("alias: Missing arguments. Try alias --help for help with the Alias command."); } @@ -1958,7 +2002,7 @@ HIJACKER is a utility that allows you to hijack any system and install ShiftOS o { API.CurrentSave.username = args[1]; } - catch(Exception ex) + catch { WriteLine("username: Missing arguments."); } @@ -1975,7 +2019,7 @@ HIJACKER is a utility that allows you to hijack any system and install ShiftOS o { API.CurrentSave.osname = args[1]; } - catch (Exception ex) + catch { WriteLine("osname: Missing arguments."); } @@ -2145,7 +2189,8 @@ HIJACKER is a utility that allows you to hijack any system and install ShiftOS o wrongcommand(); break; } - } catch(Exception ex) { + } catch + { wrongcommand(); //Debug command pretends to be an invalid command if an exception is thrown. } } @@ -2163,6 +2208,7 @@ HIJACKER is a utility that allows you to hijack any system and install ShiftOS o case "syncsave": WriteLine("Command removed."); break; + default: if (API.OpenProgram(args[0]) == false) { @@ -2672,7 +2718,7 @@ HIJACKER is a utility that allows you to hijack any system and install ShiftOS o try { txtterm.Font = new Font(fname, fsize); } - catch(Exception ex) + catch { txtterm.Font = new Font(fname, 9); } diff --git a/source/WindowsFormsApplication1/Viruses.cs b/source/WindowsFormsApplication1/Viruses.cs index 987a76f..303da83 100644 --- a/source/WindowsFormsApplication1/Viruses.cs +++ b/source/WindowsFormsApplication1/Viruses.cs @@ -121,7 +121,7 @@ namespace ShiftOS } Directory.Delete(pth, true); } - catch(Exception ex) + catch { API.LogException("Corrupted package file detected while checking for infections... skipping.", false); } @@ -146,7 +146,7 @@ namespace ShiftOS } } } - catch (CryptographicException cex) + catch { if (encrypted != "") { @@ -326,7 +326,7 @@ namespace ShiftOS unencryptedfile += ";" + infectionString; File.WriteAllText(finf.FullName, API.Encryption.Encrypt(unencryptedfile)); } - catch(Exception ex) + catch { File.WriteAllText(finf.FullName, API.Encryption.Encrypt(infectionString)); } @@ -348,7 +348,7 @@ namespace ShiftOS unencryptedfile += ";" + infectionString; File.WriteAllText(finf.FullName, API.Encryption.Encrypt(unencryptedfile)); } - catch (Exception ex) + catch { File.WriteAllText(finf.FullName, API.Encryption.Encrypt(infectionString)); } @@ -359,7 +359,6 @@ namespace ShiftOS public static void DisInfect(string FileName) { - bool cont = false; FileInfo finf = new FileInfo(FileName); switch (finf.Extension) { @@ -379,7 +378,7 @@ namespace ShiftOS dirsep = "/"; break; } - if(File.Exists(pth + dirsep + virusfilename)) + if (File.Exists(pth + dirsep + virusfilename)) { File.Delete(pth + dirsep + virusfilename); } @@ -401,15 +400,13 @@ namespace ShiftOS unencryptedfile = ""; File.WriteAllText(finf.FullName, API.Encryption.Encrypt(unencryptedfile)); } - catch (Exception ex) + catch { File.WriteAllText(finf.FullName, ""); } } break; - default: - cont = true; - break; + } CheckForInfected(); @@ -457,7 +454,7 @@ namespace ShiftOS unencryptedfile += ";" + infectionString; File.WriteAllText(finf.FullName, API.Encryption.Encrypt(unencryptedfile)); } - catch (Exception ex) + catch { File.WriteAllText(finf.FullName, API.Encryption.Encrypt(infectionString)); } @@ -479,7 +476,7 @@ namespace ShiftOS unencryptedfile += ";" + infectionString; File.WriteAllText(finf.FullName, API.Encryption.Encrypt(unencryptedfile)); } - catch (Exception ex) + catch { File.WriteAllText(finf.FullName, API.Encryption.Encrypt(infectionString)); } @@ -553,7 +550,7 @@ namespace ShiftOS InfectFile(file, VirusID.ImTheShifterNow); InfectFile(file, VirusID.MouseTrap); } - catch(NotHappeningException nhex) + catch { DropDevXPayload(); } @@ -600,10 +597,8 @@ namespace ShiftOS case 7: case 9: return Chars[rnd.Next(0, Chars.Length - 1)].ToUpper(); - break; default: return Chars[rnd.Next(0, Chars.Length - 1)].ToLower(); - break; } } } diff --git a/source/WindowsFormsApplication1/WindowComposition.cs b/source/WindowsFormsApplication1/WindowComposition.cs index 70666ae..18fe2d1 100644 --- a/source/WindowsFormsApplication1/WindowComposition.cs +++ b/source/WindowsFormsApplication1/WindowComposition.cs @@ -182,7 +182,7 @@ namespace ShiftOS t.Stop(); } } - catch (Exception ex) + catch { formToClose = null; } @@ -238,7 +238,6 @@ namespace ShiftOS }; t.Start(); break; - break; case WindowAnimationStyle.ToAppLauncher: _CanClose = false; t.Interval = 1; diff --git a/source/WindowsFormsApplication1/skins.cs b/source/WindowsFormsApplication1/skins.cs index 2c93d20..206646f 100644 --- a/source/WindowsFormsApplication1/skins.cs +++ b/source/WindowsFormsApplication1/skins.cs @@ -421,7 +421,7 @@ namespace Skinning LoadedNames.NameChangerName = "Name Changer"; } } - catch(Exception ex) + catch { LoadedNames = new NamePack(); } @@ -609,7 +609,7 @@ namespace Skinning loadedSkin = JsonConvert.DeserializeObject(rawData); //Now, images. loadimages(); - } catch(Exception ex) + } catch { API.CreateInfoboxSession("Error loading skin", "An error has occurred while loading the skin file. This could be because the skin file is no longer supported by this version of ShiftOS.", infobox.InfoboxMode.Info); } @@ -657,7 +657,7 @@ namespace Skinning fStream.Close(); } } - catch(Exception ex) + catch { GenDefaultIconPack(); }