From 57277a01d685b0e29a79e5d74a1465a2ceb23ef9 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 6 May 2017 09:44:47 -0400 Subject: Most of TriWrite is implemented. --- .../Applications/ShiftoriumFrontend.cs | 108 +++++++---- ShiftOS.WinForms/Applications/Skin Loader.cs | 9 +- ShiftOS.WinForms/Applications/TriWrite.Designer.cs | 197 ++++++++++++++++++--- ShiftOS.WinForms/Applications/TriWrite.cs | 120 ++++++++++++- ShiftOS.WinForms/Applications/TriWrite.resx | 108 ++++++++++- ShiftOS.WinForms/Controls/TerminalBox.cs | 130 ++++++++++++++ ShiftOS.WinForms/DesktopWidgets/HeartbeatWidget.cs | 4 +- 7 files changed, 601 insertions(+), 75 deletions(-) (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs b/ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs index 66b0448..06266c3 100644 --- a/ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs +++ b/ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs @@ -30,6 +30,7 @@ using System.Drawing; using System.Linq; using System.Reflection; using System.Text; +using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; using ShiftOS.Engine; @@ -90,46 +91,68 @@ namespace ShiftOS.WinForms.Applications public void PopulateShiftorium() { - try + var t = new Thread(() => { - lbnoupgrades.Hide(); - lbupgrades.Items.Clear(); - upgrades.Clear(); - Timer(); - - foreach (var upg in backend.GetAvailable().Where(x => x.Category == backend.GetCategories()[CategoryId])) + try { - String name = Localization.Parse(upg.Name) + " - " + upg.Cost.ToString() + "CP"; - upgrades.Add(name, upg); - lbupgrades.Items.Add(name); + Desktop.InvokeOnWorkerThread(() => + { + lbnoupgrades.Hide(); + lbupgrades.Items.Clear(); + upgrades.Clear(); + Timer(); + }); + + foreach (var upg in backend.GetAvailable().Where(x => x.Category == backend.GetCategories()[CategoryId])) + { + string name = Localization.Parse(upg.Name) + " - " + upg.Cost.ToString() + "CP"; + upgrades.Add(name, upg); + Desktop.InvokeOnWorkerThread(() => + { + lbupgrades.Items.Add(name); + }); + } + + if (lbupgrades.Items.Count == 0) + { + Desktop.InvokeOnWorkerThread(() => + { + lbnoupgrades.Show(); + lbnoupgrades.Location = new Point( + (lbupgrades.Width - lbnoupgrades.Width) / 2, + lbupgrades.Top + (lbupgrades.Height - lbnoupgrades.Height) / 2 + ); + }); + } + else + { + Desktop.InvokeOnWorkerThread(() => + { + lbnoupgrades.Hide(); + }); + } + + Desktop.InvokeOnWorkerThread(() => + { + lblcategorytext.Text = Shiftorium.GetCategories()[CategoryId]; + btncat_back.Visible = (CategoryId > 0); + btncat_forward.Visible = (CategoryId < backend.GetCategories().Length - 1); + }); } - - if (lbupgrades.Items.Count == 0) + catch { - lbnoupgrades.Show(); - lbnoupgrades.Location = new Point( - (lbupgrades.Width - lbnoupgrades.Width) / 2, - (lbupgrades.Height - lbnoupgrades.Height) / 2 - ); - + Desktop.InvokeOnWorkerThread(() => + { + lbnoupgrades.Show(); + lbnoupgrades.Location = new Point( + (lbupgrades.Width - lbnoupgrades.Width) / 2, + lbupgrades.Top + (lbupgrades.Height - lbnoupgrades.Height) / 2 + ); + }); } - else - { - lbnoupgrades.Hide(); - } - lblcategorytext.Text = Shiftorium.GetCategories()[CategoryId]; - btncat_back.Visible = (CategoryId > 0); - btncat_forward.Visible = (CategoryId < backend.GetCategories().Length - 1); - } - catch - { - lbnoupgrades.Show(); - lbnoupgrades.Location = new Point( - (lbupgrades.Width - lbnoupgrades.Width) / 2, - (lbupgrades.Height - lbnoupgrades.Height) / 2 - ); - - } + }); + t.IsBackground = true; + t.Start(); } public static bool UpgradeInstalled(string upg) @@ -200,7 +223,17 @@ namespace ShiftOS.WinForms.Applications { foreach(var upg in UpgradesToBuy) { - backend.Buy(upg.Key, upg.Value); + SaveSystem.CurrentSave.Codepoints -= upg.Value; + if (SaveSystem.CurrentSave.Upgrades.ContainsKey(upg.Key)) + { + SaveSystem.CurrentSave.Upgrades[upg.Key] = true; + } + else + { + SaveSystem.CurrentSave.Upgrades.Add(upg.Key, true); + } + SaveSystem.SaveGame(); + backend.InvokeUpgradeInstalled(); } } @@ -224,7 +257,7 @@ namespace ShiftOS.WinForms.Applications } - Timer cp_update = new System.Windows.Forms.Timer(); + System.Windows.Forms.Timer cp_update = new System.Windows.Forms.Timer(); public bool OnUnload() { @@ -248,6 +281,7 @@ namespace ShiftOS.WinForms.Applications { timer100 = new System.Timers.Timer(); timer100.Interval = 2000; + //CLARIFICATION: What is this supposed to do? - Michael //timer100.Elapsed += ???; timer100.AutoReset = true; timer100.Enabled = true; diff --git a/ShiftOS.WinForms/Applications/Skin Loader.cs b/ShiftOS.WinForms/Applications/Skin Loader.cs index f9857b7..90b05a1 100644 --- a/ShiftOS.WinForms/Applications/Skin Loader.cs +++ b/ShiftOS.WinForms/Applications/Skin Loader.cs @@ -65,8 +65,11 @@ namespace ShiftOS.WinForms.Applications public void SetupUI() { - SetupDesktop(); - Setup(); + if (LoadedSkin != null) + { + SetupDesktop(); + Setup(); + } } public void SetupDesktop() @@ -78,7 +81,7 @@ namespace ShiftOS.WinForms.Applications //upgrades - if (SaveSystem.CurrentSave != null) + if (SaveSystem.CurrentSave != null && LoadedSkin != null) { desktoppanel.Visible = ShiftoriumFrontend.UpgradeInstalled("desktop"); lbtime.Visible = ShiftoriumFrontend.UpgradeInstalled("desktop_clock_widget"); diff --git a/ShiftOS.WinForms/Applications/TriWrite.Designer.cs b/ShiftOS.WinForms/Applications/TriWrite.Designer.cs index e420fd5..a1432d8 100644 --- a/ShiftOS.WinForms/Applications/TriWrite.Designer.cs +++ b/ShiftOS.WinForms/Applications/TriWrite.Designer.cs @@ -36,15 +36,27 @@ this.panel1 = new System.Windows.Forms.Panel(); this.txtbody = new System.Windows.Forms.Label(); this.lbtitle = new System.Windows.Forms.Label(); - this.txtcontents = new System.Windows.Forms.TextBox(); this.menuStrip2 = new System.Windows.Forms.MenuStrip(); this.newToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.openToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.menuStrip3 = new System.Windows.Forms.MenuStrip(); + this.txtcontents = new System.Windows.Forms.RichTextBox(); + this.toolStrip1 = new System.Windows.Forms.ToolStrip(); + this.bold = new System.Windows.Forms.ToolStripButton(); + this.italic = new System.Windows.Forms.ToolStripButton(); + this.underline = new System.Windows.Forms.ToolStripButton(); + this.strikethrough = new System.Windows.Forms.ToolStripButton(); + this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); + this.fonts = new System.Windows.Forms.ToolStripComboBox(); + this.size = new System.Windows.Forms.ToolStripTextBox(); + this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); + this.left = new System.Windows.Forms.ToolStripButton(); + this.center = new System.Windows.Forms.ToolStripButton(); + this.right = new System.Windows.Forms.ToolStripButton(); this.menuStrip1.SuspendLayout(); this.panel1.SuspendLayout(); this.menuStrip2.SuspendLayout(); + this.toolStrip1.SuspendLayout(); this.SuspendLayout(); // // menuStrip1 @@ -61,16 +73,17 @@ // addContactToolStripMenuItem // this.addContactToolStripMenuItem.Name = "addContactToolStripMenuItem"; - this.addContactToolStripMenuItem.Size = new System.Drawing.Size(32, 19); + this.addContactToolStripMenuItem.Size = new System.Drawing.Size(12, 20); // // removeToolStripMenuItem // this.removeToolStripMenuItem.Name = "removeToolStripMenuItem"; - this.removeToolStripMenuItem.Size = new System.Drawing.Size(32, 19); + this.removeToolStripMenuItem.Size = new System.Drawing.Size(12, 20); // // tvcontacts // this.tvcontacts.Dock = System.Windows.Forms.DockStyle.Left; + this.tvcontacts.LineColor = System.Drawing.Color.Empty; this.tvcontacts.Location = new System.Drawing.Point(0, 24); this.tvcontacts.Name = "tvcontacts"; this.tvcontacts.Size = new System.Drawing.Size(224, 551); @@ -107,16 +120,6 @@ this.lbtitle.Tag = "header1"; this.lbtitle.Text = "TriWrite"; // - // txtcontents - // - this.txtcontents.Dock = System.Windows.Forms.DockStyle.Fill; - this.txtcontents.Location = new System.Drawing.Point(0, 53); - this.txtcontents.Multiline = true; - this.txtcontents.Name = "txtcontents"; - this.txtcontents.Size = new System.Drawing.Size(527, 460); - this.txtcontents.TabIndex = 1; - this.txtcontents.TabStop = false; - // // menuStrip2 // this.menuStrip2.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -125,7 +128,7 @@ this.saveToolStripMenuItem}); this.menuStrip2.Location = new System.Drawing.Point(0, 0); this.menuStrip2.Name = "menuStrip2"; - this.menuStrip2.Size = new System.Drawing.Size(527, 24); + this.menuStrip2.Size = new System.Drawing.Size(652, 24); this.menuStrip2.TabIndex = 2; this.menuStrip2.Text = "menuStrip2"; // @@ -134,40 +137,173 @@ this.newToolStripMenuItem.Name = "newToolStripMenuItem"; this.newToolStripMenuItem.Size = new System.Drawing.Size(43, 20); this.newToolStripMenuItem.Text = "New"; + this.newToolStripMenuItem.Click += new System.EventHandler(this.newToolStripMenuItem_Click); // // openToolStripMenuItem // this.openToolStripMenuItem.Name = "openToolStripMenuItem"; this.openToolStripMenuItem.Size = new System.Drawing.Size(48, 20); this.openToolStripMenuItem.Text = "Open"; + this.openToolStripMenuItem.Click += new System.EventHandler(this.openToolStripMenuItem_Click); // // saveToolStripMenuItem // this.saveToolStripMenuItem.Name = "saveToolStripMenuItem"; this.saveToolStripMenuItem.Size = new System.Drawing.Size(43, 20); this.saveToolStripMenuItem.Text = "Save"; + this.saveToolStripMenuItem.Click += new System.EventHandler(this.saveToolStripMenuItem_Click); + // + // txtcontents + // + this.txtcontents.Dock = System.Windows.Forms.DockStyle.Fill; + this.txtcontents.Location = new System.Drawing.Point(0, 49); + this.txtcontents.Name = "txtcontents"; + this.txtcontents.Size = new System.Drawing.Size(652, 365); + this.txtcontents.TabIndex = 4; + this.txtcontents.Text = ""; + this.txtcontents.SelectionChanged += new System.EventHandler(this.txtcontents_SelectionChanged); + // + // toolStrip1 + // + this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.bold, + this.italic, + this.underline, + this.strikethrough, + this.toolStripSeparator1, + this.fonts, + this.size, + this.toolStripSeparator2, + this.left, + this.center, + this.right}); + this.toolStrip1.Location = new System.Drawing.Point(0, 24); + this.toolStrip1.Name = "toolStrip1"; + this.toolStrip1.Size = new System.Drawing.Size(652, 25); + this.toolStrip1.TabIndex = 5; + this.toolStrip1.Text = "toolStrip1"; + // + // bold + // + this.bold.CheckOnClick = true; + this.bold.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + this.bold.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold); + this.bold.Image = ((System.Drawing.Image)(resources.GetObject("bold.Image"))); + this.bold.ImageTransparentColor = System.Drawing.Color.Magenta; + this.bold.Name = "bold"; + this.bold.Size = new System.Drawing.Size(23, 22); + this.bold.Text = "B"; + this.bold.CheckedChanged += new System.EventHandler(this.bold_CheckedChanged); + // + // italic + // + this.italic.CheckOnClick = true; + this.italic.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + this.italic.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Italic); + this.italic.Image = ((System.Drawing.Image)(resources.GetObject("italic.Image"))); + this.italic.ImageTransparentColor = System.Drawing.Color.Magenta; + this.italic.Name = "italic"; + this.italic.Size = new System.Drawing.Size(23, 22); + this.italic.Text = "I"; + this.italic.CheckedChanged += new System.EventHandler(this.bold_CheckedChanged); + // + // underline + // + this.underline.CheckOnClick = true; + this.underline.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + this.underline.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Underline); + this.underline.Image = ((System.Drawing.Image)(resources.GetObject("underline.Image"))); + this.underline.ImageTransparentColor = System.Drawing.Color.Magenta; + this.underline.Name = "underline"; + this.underline.Size = new System.Drawing.Size(23, 22); + this.underline.Text = "U"; + this.underline.CheckedChanged += new System.EventHandler(this.bold_CheckedChanged); + // + // strikethrough + // + this.strikethrough.CheckOnClick = true; + this.strikethrough.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + this.strikethrough.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Strikeout, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.strikethrough.Image = ((System.Drawing.Image)(resources.GetObject("strikethrough.Image"))); + this.strikethrough.ImageTransparentColor = System.Drawing.Color.Magenta; + this.strikethrough.Name = "strikethrough"; + this.strikethrough.Size = new System.Drawing.Size(23, 22); + this.strikethrough.Text = "S"; + this.strikethrough.CheckedChanged += new System.EventHandler(this.bold_CheckedChanged); + // + // toolStripSeparator1 + // + this.toolStripSeparator1.Name = "toolStripSeparator1"; + this.toolStripSeparator1.Size = new System.Drawing.Size(6, 25); + // + // fonts + // + this.fonts.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.fonts.Name = "fonts"; + this.fonts.Size = new System.Drawing.Size(121, 25); + this.fonts.SelectedIndexChanged += new System.EventHandler(this.fonts_SelectedIndexChanged); + // + // size + // + this.size.AutoSize = false; + this.size.MaxLength = 3; + this.size.Name = "size"; + this.size.Size = new System.Drawing.Size(40, 25); + this.size.TextChanged += new System.EventHandler(this.size_Click); + // + // toolStripSeparator2 + // + this.toolStripSeparator2.Name = "toolStripSeparator2"; + this.toolStripSeparator2.Size = new System.Drawing.Size(6, 25); + // + // left + // + this.left.CheckOnClick = true; + this.left.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + this.left.Image = ((System.Drawing.Image)(resources.GetObject("left.Image"))); + this.left.ImageTransparentColor = System.Drawing.Color.Magenta; + this.left.Name = "left"; + this.left.Size = new System.Drawing.Size(31, 22); + this.left.Text = "Left"; + this.left.Click += new System.EventHandler(this.left_Click); + // + // center + // + this.center.CheckOnClick = true; + this.center.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + this.center.Image = ((System.Drawing.Image)(resources.GetObject("center.Image"))); + this.center.ImageTransparentColor = System.Drawing.Color.Magenta; + this.center.Name = "center"; + this.center.Size = new System.Drawing.Size(46, 22); + this.center.Text = "Center"; + this.center.Click += new System.EventHandler(this.center_Click); // - // menuStrip3 + // right // - this.menuStrip3.Location = new System.Drawing.Point(0, 30); - this.menuStrip3.Name = "menuStrip3"; - this.menuStrip3.Size = new System.Drawing.Size(527, 24); - this.menuStrip3.TabIndex = 3; - this.menuStrip3.Text = "menuStrip3"; + this.right.CheckOnClick = true; + this.right.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + this.right.Image = ((System.Drawing.Image)(resources.GetObject("right.Image"))); + this.right.ImageTransparentColor = System.Drawing.Color.Magenta; + this.right.Name = "right"; + this.right.Size = new System.Drawing.Size(39, 22); + this.right.Text = "Right"; + this.right.Click += new System.EventHandler(this.right_Click); // // TriWrite // this.Controls.Add(this.txtcontents); - this.Controls.Add(this.menuStrip3); + this.Controls.Add(this.toolStrip1); this.Controls.Add(this.menuStrip2); this.Name = "TriWrite"; - this.Size = new System.Drawing.Size(527, 513); + this.Size = new System.Drawing.Size(652, 414); this.menuStrip1.ResumeLayout(false); this.menuStrip1.PerformLayout(); this.panel1.ResumeLayout(false); this.panel1.PerformLayout(); this.menuStrip2.ResumeLayout(false); this.menuStrip2.PerformLayout(); + this.toolStrip1.ResumeLayout(false); + this.toolStrip1.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); @@ -182,11 +318,22 @@ private System.Windows.Forms.Panel panel1; private System.Windows.Forms.Label txtbody; private System.Windows.Forms.Label lbtitle; - private System.Windows.Forms.TextBox txtcontents; private System.Windows.Forms.MenuStrip menuStrip2; private System.Windows.Forms.ToolStripMenuItem newToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem openToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem saveToolStripMenuItem; - private System.Windows.Forms.MenuStrip menuStrip3; + private System.Windows.Forms.RichTextBox txtcontents; + private System.Windows.Forms.ToolStrip toolStrip1; + private System.Windows.Forms.ToolStripButton bold; + private System.Windows.Forms.ToolStripButton italic; + private System.Windows.Forms.ToolStripButton underline; + private System.Windows.Forms.ToolStripButton strikethrough; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; + private System.Windows.Forms.ToolStripComboBox fonts; + private System.Windows.Forms.ToolStripTextBox size; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator2; + private System.Windows.Forms.ToolStripButton left; + private System.Windows.Forms.ToolStripButton center; + private System.Windows.Forms.ToolStripButton right; } } diff --git a/ShiftOS.WinForms/Applications/TriWrite.cs b/ShiftOS.WinForms/Applications/TriWrite.cs index 6fb814f..b5845ba 100644 --- a/ShiftOS.WinForms/Applications/TriWrite.cs +++ b/ShiftOS.WinForms/Applications/TriWrite.cs @@ -13,7 +13,7 @@ using ShiftOS.Engine; namespace ShiftOS.WinForms.Applications { [WinOpen("triwrite")] - [AppscapeEntry("TriWrite", "Part of the trilogy of office applications for enhancement of your system. TriWrite is easliy the best text editor out there for ShiftOS.", 1024, 750, null, "Office")] + [AppscapeEntry("TriWrite", "Part of the trilogy of office applications for enhancement of your system. TriWrite is easliy the best text editor out there for ShiftOS.", 1024, 750, "file_skimmer;textpad", "Office")] [DefaultTitle("TriWrite")] [Launcher("TriWrite", false, null, "Office")] public partial class TriWrite : UserControl, IShiftOSWindow @@ -32,35 +32,54 @@ namespace ShiftOS.WinForms.Applications private void openToolStripMenuItem_Click(object sender, EventArgs e) { var txt = new List(); - txt.Add(".txt"); + txt.Add(".rtf"); - AppearanceManager.SetupDialog(new FileDialog(txt.ToArray(), FileOpenerStyle.Open, new Action((file) => this.LoadFile(file)))); + FileSkimmerBackend.GetFile(txt.ToArray(), FileOpenerStyle.Open, (path) => LoadFile(path)); } public void LoadFile(string file) { - txtcontents.Text = Utils.ReadAllText(file); + txtcontents.Rtf = Utils.ReadAllText(file); } public void SaveFile(string file) { - Utils.WriteAllText(file, txtcontents.Text); + if (file.ToLower().EndsWith(".rtf")) + { + Utils.WriteAllText(file, txtcontents.Rtf); + } + else + { + Utils.WriteAllText(file, txtcontents.Text); + } } private void saveToolStripMenuItem_Click(object sender, EventArgs e) { var txt = new List(); + txt.Add(".rtf"); txt.Add(".txt"); - - AppearanceManager.SetupDialog(new FileDialog(txt.ToArray(), FileOpenerStyle.Save, new Action((file) => this.SaveFile(file)))); + FileSkimmerBackend.GetFile(txt.ToArray(), FileOpenerStyle.Save, (path) => SaveFile(path)); } public void OnLoad() { + UpdateUI(); } public void OnSkinLoad() { + ResetFonts(); + } + + public void ResetFonts() + { + fonts.Items.Clear(); + foreach(var font in FontFamily.Families) + { + fonts.Items.Add(font.Name); + } + UpdateUI(); } public bool OnUnload() @@ -72,5 +91,92 @@ namespace ShiftOS.WinForms.Applications { } + public void UpdateUI() + { + bold.Checked = txtcontents.SelectionFont.Bold; + italic.Checked = txtcontents.SelectionFont.Italic; + underline.Checked = txtcontents.SelectionFont.Underline; + strikethrough.Checked = txtcontents.SelectionFont.Strikeout; + fonts.Text = txtcontents.SelectionFont.Name; + size.Text = txtcontents.SelectionFont.Size.ToString(); + left.Checked = txtcontents.SelectionAlignment == HorizontalAlignment.Left; + center.Checked = txtcontents.SelectionAlignment == HorizontalAlignment.Center; + right.Checked = txtcontents.SelectionAlignment == HorizontalAlignment.Right; + + } + + private void txtcontents_SelectionChanged(object sender, EventArgs e) + { + UpdateUI(); + } + + public void SetFontStyle(bool bold, bool italic, bool underline, bool strikethrough) + { + FontStyle fs = FontStyle.Regular; + if (bold) + fs |= FontStyle.Bold; + if (italic) + fs |= FontStyle.Italic; + if (underline) + fs |= FontStyle.Underline; + if (strikethrough) + fs |= FontStyle.Strikeout; + txtcontents.SelectionFont = new Font(txtcontents.SelectionFont, fs); + UpdateUI(); + } + + private void bold_CheckedChanged(object sender, EventArgs e) + { + SetFontStyle(bold.Checked, italic.Checked, underline.Checked, strikethrough.Checked); + } + + public void SetFontFamily(string family, float emSize) + { + var style = txtcontents.SelectionFont.Style; + var size = emSize; + txtcontents.SelectionFont = new Font(family, size, style); + UpdateUI(); + } + + private void fonts_SelectedIndexChanged(object sender, EventArgs e) + { + SetFontFamily(fonts.Text, Convert.ToSingle(size.Text)); + } + + private void left_Click(object sender, EventArgs e) + { + txtcontents.SelectionAlignment = HorizontalAlignment.Left; + UpdateUI(); + } + + private void center_Click(object sender, EventArgs e) + { + txtcontents.SelectionAlignment = HorizontalAlignment.Center; + UpdateUI(); + + } + + private void right_Click(object sender, EventArgs e) + { + txtcontents.SelectionAlignment = HorizontalAlignment.Right; + UpdateUI(); + + } + + private void size_Click(object sender, EventArgs e) + { + try + { + float s = Convert.ToSingle(size.Text); + if(s != txtcontents.SelectionFont.Size) + { + SetFontFamily(fonts.Text, s); + } + } + catch + { + UpdateUI(); + } + } } } \ No newline at end of file diff --git a/ShiftOS.WinForms/Applications/TriWrite.resx b/ShiftOS.WinForms/Applications/TriWrite.resx index 525a23c..a06716c 100644 --- a/ShiftOS.WinForms/Applications/TriWrite.resx +++ b/ShiftOS.WinForms/Applications/TriWrite.resx @@ -130,7 +130,113 @@ To add a contact, simply click "Add Contact", and to remove one, click "Remove". 132, 17 - + 247, 17 + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG + YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9 + 0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw + bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc + VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9 + c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32 + Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo + mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+ + kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D + TgDQASA1MVpwzwAAAABJRU5ErkJggg== + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG + YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9 + 0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw + bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc + VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9 + c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32 + Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo + mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+ + kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D + TgDQASA1MVpwzwAAAABJRU5ErkJggg== + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG + YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9 + 0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw + bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc + VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9 + c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32 + Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo + mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+ + kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D + TgDQASA1MVpwzwAAAABJRU5ErkJggg== + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG + YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9 + 0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw + bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc + VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9 + c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32 + Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo + mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+ + kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D + TgDQASA1MVpwzwAAAABJRU5ErkJggg== + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG + YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9 + 0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw + bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc + VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9 + c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32 + Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo + mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+ + kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D + TgDQASA1MVpwzwAAAABJRU5ErkJggg== + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG + YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9 + 0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw + bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc + VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9 + c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32 + Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo + mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+ + kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D + TgDQASA1MVpwzwAAAABJRU5ErkJggg== + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG + YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9 + 0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw + bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc + VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9 + c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32 + Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo + mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+ + kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D + TgDQASA1MVpwzwAAAABJRU5ErkJggg== + + \ No newline at end of file diff --git a/ShiftOS.WinForms/Controls/TerminalBox.cs b/ShiftOS.WinForms/Controls/TerminalBox.cs index cdb0965..f85daa6 100644 --- a/ShiftOS.WinForms/Controls/TerminalBox.cs +++ b/ShiftOS.WinForms/Controls/TerminalBox.cs @@ -86,6 +86,7 @@ namespace ShiftOS.WinForms.Controls public void WriteLine(string text) { + Engine.AudioManager.PlayStream(Properties.Resources.writesound); this.HideSelection = true; this.Select(this.TextLength, 0); this.SelectionFont = ConstructFont(); @@ -119,6 +120,135 @@ namespace ShiftOS.WinForms.Controls base.OnMouseUp(mevent); } + protected override void OnKeyDown(KeyEventArgs e) + { + base.OnKeyDown(e); + if (!TerminalBackend.InStory) + { + switch (e.KeyCode) { + case Keys.Add: + case Keys.Alt: + case Keys.Apps: + case Keys.Attn: + case Keys.BrowserBack: + case Keys.BrowserFavorites: + case Keys.BrowserForward: + case Keys.BrowserHome: + case Keys.BrowserRefresh: + case Keys.BrowserSearch: + case Keys.BrowserStop: + case Keys.Cancel: + case Keys.Capital: + case Keys.Clear: + case Keys.Control: + case Keys.ControlKey: + case Keys.Crsel: + case Keys.Decimal: + case Keys.Divide: + case Keys.Down: + case Keys.End: + case Keys.Enter: + case Keys.EraseEof: + case Keys.Escape: + case Keys.Execute: + case Keys.Exsel: + case Keys.F1: + case Keys.F10: + case Keys.F11: + case Keys.F12: + case Keys.F13: + case Keys.F14: + case Keys.F15: + case Keys.F16: + case Keys.F17: + case Keys.F18: + case Keys.F19: + case Keys.F2: + case Keys.F20: + case Keys.F21: + case Keys.F22: + case Keys.F23: + case Keys.F24: + case Keys.F3: + case Keys.F4: + case Keys.F5: + case Keys.F6: + case Keys.F7: + case Keys.F8: + case Keys.F9: + case Keys.FinalMode: + case Keys.HanguelMode: + case Keys.HanjaMode: + case Keys.Help: + case Keys.Home: + case Keys.IMEAccept: + case Keys.IMEConvert: + case Keys.IMEModeChange: + case Keys.IMENonconvert: + case Keys.Insert: + case Keys.JunjaMode: + case Keys.KeyCode: + case Keys.LaunchApplication1: + case Keys.LaunchApplication2: + case Keys.LaunchMail: + case Keys.LButton: + case Keys.LControlKey: + case Keys.Left: + case Keys.LineFeed: + case Keys.LMenu: + case Keys.LShiftKey: + case Keys.LWin: + case Keys.MButton: + case Keys.MediaNextTrack: + case Keys.MediaPlayPause: + case Keys.MediaPreviousTrack: + case Keys.MediaStop: + case Keys.Menu: + case Keys.Modifiers: + case Keys.Multiply: + case Keys.Next: + case Keys.NoName: + case Keys.None: + case Keys.NumLock: + case Keys.Pa1: + case Keys.Packet: + case Keys.PageUp: + case Keys.Pause: + case Keys.Play: + case Keys.Print: + case Keys.PrintScreen: + case Keys.ProcessKey: + case Keys.RButton: + case Keys.RControlKey: + case Keys.Right: + case Keys.RMenu: + case Keys.RShiftKey: + case Keys.RWin: + case Keys.Scroll: + case Keys.Select: + case Keys.SelectMedia: + case Keys.Separator: + case Keys.Shift: + case Keys.ShiftKey: + case Keys.Sleep: + case Keys.Subtract: + case Keys.Tab: + case Keys.Up: + case Keys.VolumeDown: + case Keys.VolumeMute: + case Keys.VolumeUp: + case Keys.XButton1: + case Keys.XButton2: + case Keys.Zoom: + + break; + default: + Engine.AudioManager.PlayStream(Properties.Resources.typesound); + break; + } + } + } + public TerminalBox() : base() { this.Tag = "keepbg keepfg keepfont"; diff --git a/ShiftOS.WinForms/DesktopWidgets/HeartbeatWidget.cs b/ShiftOS.WinForms/DesktopWidgets/HeartbeatWidget.cs index d38cdc3..b0dc552 100644 --- a/ShiftOS.WinForms/DesktopWidgets/HeartbeatWidget.cs +++ b/ShiftOS.WinForms/DesktopWidgets/HeartbeatWidget.cs @@ -24,13 +24,13 @@ namespace ShiftOS.WinForms.DesktopWidgets if(ts != ServerManager.DigitalSocietyPing) { ts = ServerManager.DigitalSocietyPing; - lbheartbeat.Text = "Server ping: " + ts.ToString(); + lbheartbeat.Text = "Server ping: " + ts.ToString() + " MS"; } }; } //Fun fact. I misspelled this as "TimeSpam." - TimeSpan ts; + long ts = 0; public void OnSkinLoad() { -- cgit v1.2.3 From c56b59a8a37c108a18aadc719091b5a6827931e3 Mon Sep 17 00:00:00 2001 From: Aren Date: Sat, 6 May 2017 17:41:49 +0200 Subject: Stop pong from ending early. Pong used to end early because the game would check if secondsleft was 1 after removing one, meaning it would be at 2. Now it checks if secondsleft is 0 which should resolve the issue. --- ShiftOS.WinForms/Applications/Pong.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.WinForms/Applications/Pong.cs b/ShiftOS.WinForms/Applications/Pong.cs index d63f406..92a2039 100644 --- a/ShiftOS.WinForms/Applications/Pong.cs +++ b/ShiftOS.WinForms/Applications/Pong.cs @@ -629,7 +629,7 @@ namespace ShiftOS.WinForms.Applications if (this.Left < Screen.PrimaryScreen.Bounds.Width) { secondsleft = secondsleft - 1; - if (secondsleft == 1) + if (secondsleft == 0) { CompleteLevel(); } -- cgit v1.2.3 From e131f72a9b863cc75a4db71670c41efa319886fb Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 6 May 2017 12:16:41 -0400 Subject: Fix the file skimmer pins. --- .../Applications/FileSkimmer.Designer.cs | 12 ++-- ShiftOS.WinForms/Applications/FileSkimmer.cs | 64 +++++++++++++++++++++- ShiftOS.WinForms/Applications/Pong.cs | 2 +- ShiftOS_TheReturn/UserManagementCommands.cs | 27 +++++++++ 4 files changed, 97 insertions(+), 8 deletions(-) (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.WinForms/Applications/FileSkimmer.Designer.cs b/ShiftOS.WinForms/Applications/FileSkimmer.Designer.cs index ea9fcec..965e4eb 100644 --- a/ShiftOS.WinForms/Applications/FileSkimmer.Designer.cs +++ b/ShiftOS.WinForms/Applications/FileSkimmer.Designer.cs @@ -70,9 +70,9 @@ namespace ShiftOS.WinForms.Applications // lvitems // this.lvitems.Dock = System.Windows.Forms.DockStyle.Fill; - this.lvitems.Location = new System.Drawing.Point(0, 0); + this.lvitems.Location = new System.Drawing.Point(149, 0); this.lvitems.Name = "lvitems"; - this.lvitems.Size = new System.Drawing.Size(634, 332); + this.lvitems.Size = new System.Drawing.Size(485, 332); this.lvitems.TabIndex = 0; this.lvitems.UseCompatibleStateImageBehavior = false; this.lvitems.ItemSelectionChanged += new System.Windows.Forms.ListViewItemSelectionChangedEventHandler(this.lvitems_ItemSelectionChanged); @@ -81,8 +81,8 @@ namespace ShiftOS.WinForms.Applications // // panel1 // - this.panel1.Controls.Add(this.pinnedItems); this.panel1.Controls.Add(this.lvitems); + this.panel1.Controls.Add(this.pinnedItems); this.panel1.Controls.Add(this.lbcurrentfolder); this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; this.panel1.Location = new System.Drawing.Point(0, 24); @@ -92,10 +92,12 @@ namespace ShiftOS.WinForms.Applications // // pinnedItems // - this.pinnedItems.Location = new System.Drawing.Point(437, 208); + this.pinnedItems.Dock = System.Windows.Forms.DockStyle.Left; + this.pinnedItems.Location = new System.Drawing.Point(0, 0); this.pinnedItems.Name = "pinnedItems"; - this.pinnedItems.Size = new System.Drawing.Size(197, 124); + this.pinnedItems.Size = new System.Drawing.Size(149, 332); this.pinnedItems.TabIndex = 3; + this.pinnedItems.Click += new System.EventHandler(this.pinnedItems_Click); // // lbcurrentfolder // diff --git a/ShiftOS.WinForms/Applications/FileSkimmer.cs b/ShiftOS.WinForms/Applications/FileSkimmer.cs index c1ffd40..218e9e2 100644 --- a/ShiftOS.WinForms/Applications/FileSkimmer.cs +++ b/ShiftOS.WinForms/Applications/FileSkimmer.cs @@ -35,6 +35,7 @@ using System.Windows.Forms; using static ShiftOS.Objects.ShiftFS.Utils; using ShiftOS.Engine; +using Newtonsoft.Json; namespace ShiftOS.WinForms.Applications { @@ -128,8 +129,14 @@ namespace ShiftOS.WinForms.Applications { int amountsCalled = -1; amountsCalled = amountsCalled + 1; - pinnedItems.Nodes.Add(path); - pinnedItems.Nodes[amountsCalled].Nodes.Add("test"); + List Pinned = new List(); + if(FileExists(Paths.GetPath("data") + "/pinned_items.dat")) + { + Pinned = JsonConvert.DeserializeObject>(ReadAllText(Paths.GetPath("data") + "/pinned_items.dat")); + } + Pinned.Add(path); + WriteAllText(Paths.GetPath("data") + "/pinned_items.dat", JsonConvert.SerializeObject(Pinned)); + ResetList(); } public void ChangeDirectory(string path) @@ -152,8 +159,40 @@ namespace ShiftOS.WinForms.Applications } } + public void PopulatePinned(TreeNode node, string[] items) + { + foreach(var dir in items) + { + var treenode = new TreeNode(); + if (DirectoryExists(dir)) + { + var dinf = GetDirectoryInfo(dir); + treenode.Text = dinf.Name; + } + else if (FileExists(dir)) + { + var finf = GetFileInfo(dir); + treenode.Text = finf.Name; + } + treenode.Tag = dir; + node.Nodes.Add(treenode); + } + } + public void ResetList() { + pinnedItems.Nodes.Clear(); + List Pinned = new List(); + if(FileExists(Paths.GetPath("data") + "/pinned_items.dat")) + { + Pinned = JsonConvert.DeserializeObject>(ReadAllText(Paths.GetPath("data") + "/pinned_items.dat")); + } + var node = new TreeNode(); + node.Text = "Pinned"; + PopulatePinned(node, Pinned.ToArray()); + pinnedItems.Nodes.Add(node); + node.ExpandAll(); + if(lvitems.LargeImageList == null) { lvitems.LargeImageList = new ImageList(); @@ -437,5 +476,26 @@ namespace ShiftOS.WinForms.Applications } catch { } } + + private void pinnedItems_Click(object sender, EventArgs e) + { + try + { + if (pinnedItems.SelectedNode != null) + { + string path = pinnedItems.SelectedNode.Tag.ToString(); + if (DirectoryExists(path)) + { + currentdir = path; + ResetList(); + } + else if (FileExists(path)) + { + FileSkimmerBackend.OpenFile(path); + } + } + } + catch { } + } } } diff --git a/ShiftOS.WinForms/Applications/Pong.cs b/ShiftOS.WinForms/Applications/Pong.cs index d63f406..ae70aff 100644 --- a/ShiftOS.WinForms/Applications/Pong.cs +++ b/ShiftOS.WinForms/Applications/Pong.cs @@ -1095,8 +1095,8 @@ namespace ShiftOS.WinForms.Applications { if(!string.IsNullOrWhiteSpace(OpponentGUID)) ServerManager.Forward(OpponentGUID, "pong_mp_left", null); + LeaveMatchmake(); } - LeaveMatchmake(); ServerManager.MessageReceived -= this.ServerMessageReceivedHandler; return true; diff --git a/ShiftOS_TheReturn/UserManagementCommands.cs b/ShiftOS_TheReturn/UserManagementCommands.cs index 1c3c0ed..21c984b 100644 --- a/ShiftOS_TheReturn/UserManagementCommands.cs +++ b/ShiftOS_TheReturn/UserManagementCommands.cs @@ -53,6 +53,9 @@ namespace ShiftOS.Engine return true; } + + + [Command("set_acl")] [RequiresArgument("user")] [RequiresArgument("val")] @@ -122,7 +125,31 @@ namespace ShiftOS.Engine [RequiresUpgrade("mud_fundamentals")] public static class UserManagementCommands { + [Command("login", description = "Log in as another user.")] + [RequiresArgument("user")] + [RequiresArgument("pass")] + public static bool Login(Dictionary args) + { + string user = args["user"].ToString(); + string pass = args["pass"].ToString(); + var usr = SaveSystem.CurrentSave.Users.FirstOrDefault(x => x.Username == user); + if(usr==null) + { + Console.WriteLine("Error: No such user."); + return true; + } + + if (usr.Password != pass) + { + Console.WriteLine("Access denied."); + return true; + } + + SaveSystem.CurrentUser = usr; + Console.WriteLine("Access granted."); + return true; + } [Command("setpass", description ="Allows you to set your password to a new value.", usage ="old:,new:")] [RequiresArgument("old")] -- cgit v1.2.3 From 2d8831c29ca4d05d66ad4b90db66250094e734c9 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 6 May 2017 12:36:45 -0400 Subject: fix highscore glitch --- ShiftOS.WinForms/Applications/Pong.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.WinForms/Applications/Pong.cs b/ShiftOS.WinForms/Applications/Pong.cs index ae70aff..433e05f 100644 --- a/ShiftOS.WinForms/Applications/Pong.cs +++ b/ShiftOS.WinForms/Applications/Pong.cs @@ -981,6 +981,10 @@ namespace ShiftOS.WinForms.Applications var hs = unite.GetPongHighscores(); foreach (var score in hs.Highscores) { + if(this.ParentForm.Visible == false) + { + Thread.CurrentThread.Abort(); + } string username = unite.GetDisplayNameId(score.UserId); this.Invoke(new Action(() => { @@ -994,8 +998,15 @@ namespace ShiftOS.WinForms.Applications } catch { - Infobox.Show("Service unavailable.", "The Pong Highscore service is unavailable at this time."); - this.Invoke(new Action(pnlgamestats.BringToFront)); + try + { + if (this.ParentForm.Visible == true) + { + Infobox.Show("Service unavailable.", "The Pong Highscore service is unavailable at this time."); + this.Invoke(new Action(pnlgamestats.BringToFront)); + } + } + catch { } //JUST. ABORT. THE. FUCKING. THREAD. return; } }); -- cgit v1.2.3 From 2424b91d51bc55ff7493b1249888c143335905af Mon Sep 17 00:00:00 2001 From: william341 Date: Sat, 6 May 2017 14:32:24 -0700 Subject: fixed a bug using Try-Catch Brand Duct Tape --- ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs b/ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs index 06266c3..52e9a9e 100644 --- a/ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs +++ b/ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs @@ -134,9 +134,16 @@ namespace ShiftOS.WinForms.Applications Desktop.InvokeOnWorkerThread(() => { - lblcategorytext.Text = Shiftorium.GetCategories()[CategoryId]; - btncat_back.Visible = (CategoryId > 0); - btncat_forward.Visible = (CategoryId < backend.GetCategories().Length - 1); + try + { + lblcategorytext.Text = Shiftorium.GetCategories()[CategoryId]; + btncat_back.Visible = (CategoryId > 0); + btncat_forward.Visible = (CategoryId < backend.GetCategories().Length - 1); + } + catch + { + + } }); } catch -- cgit v1.2.3 From 147cd66b3958d382ea879d66c4d653a6f734f82b Mon Sep 17 00:00:00 2001 From: william341 Date: Sat, 6 May 2017 14:35:12 -0700 Subject: label 2 is annoy --- .../Applications/ShiftoriumFrontend.Designer.cs | 125 +++++++++++---------- .../Applications/ShiftoriumFrontend.cs | 5 + 2 files changed, 68 insertions(+), 62 deletions(-) (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.WinForms/Applications/ShiftoriumFrontend.Designer.cs b/ShiftOS.WinForms/Applications/ShiftoriumFrontend.Designer.cs index 32d508b..f9d0bb4 100644 --- a/ShiftOS.WinForms/Applications/ShiftoriumFrontend.Designer.cs +++ b/ShiftOS.WinForms/Applications/ShiftoriumFrontend.Designer.cs @@ -61,16 +61,16 @@ namespace ShiftOS.WinForms.Applications this.btnbuy = new System.Windows.Forms.Button(); this.lbupgradetitle = new System.Windows.Forms.Label(); this.pnllist = new System.Windows.Forms.Panel(); + this.lbnoupgrades = new System.Windows.Forms.Label(); + this.panel3 = new System.Windows.Forms.Panel(); + this.lblcategorytext = new System.Windows.Forms.Label(); + this.btncat_forward = new System.Windows.Forms.Button(); + this.btncat_back = new System.Windows.Forms.Button(); this.lbcodepoints = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label(); this.pgupgradeprogress = new ShiftOS.WinForms.Controls.ShiftedProgressBar(); this.lbupgrades = new System.Windows.Forms.ListBox(); this.label3 = new System.Windows.Forms.Label(); - this.panel3 = new System.Windows.Forms.Panel(); - this.btncat_back = new System.Windows.Forms.Button(); - this.btncat_forward = new System.Windows.Forms.Button(); - this.lblcategorytext = new System.Windows.Forms.Label(); - this.lbnoupgrades = new System.Windows.Forms.Label(); this.panel1.SuspendLayout(); this.panel2.SuspendLayout(); this.pnlupgradeactions.SuspendLayout(); @@ -159,6 +159,64 @@ namespace ShiftOS.WinForms.Applications this.pnllist.Size = new System.Drawing.Size(406, 427); this.pnllist.TabIndex = 0; // + // lbnoupgrades + // + this.lbnoupgrades.AutoSize = true; + this.lbnoupgrades.Location = new System.Drawing.Point(69, 183); + this.lbnoupgrades.Name = "lbnoupgrades"; + this.lbnoupgrades.Size = new System.Drawing.Size(71, 13); + this.lbnoupgrades.TabIndex = 6; + this.lbnoupgrades.Tag = "header2"; + this.lbnoupgrades.Text = "No upgrades!"; + this.lbnoupgrades.Visible = false; + // + // panel3 + // + this.panel3.Controls.Add(this.lblcategorytext); + this.panel3.Controls.Add(this.btncat_forward); + this.panel3.Controls.Add(this.btncat_back); + this.panel3.Location = new System.Drawing.Point(6, 76); + this.panel3.Name = "panel3"; + this.panel3.Size = new System.Drawing.Size(394, 23); + this.panel3.TabIndex = 5; + // + // lblcategorytext + // + this.lblcategorytext.Dock = System.Windows.Forms.DockStyle.Fill; + this.lblcategorytext.Location = new System.Drawing.Point(29, 0); + this.lblcategorytext.Name = "lblcategorytext"; + this.lblcategorytext.Size = new System.Drawing.Size(336, 23); + this.lblcategorytext.TabIndex = 2; + this.lblcategorytext.Text = "No Upgrades"; + this.lblcategorytext.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.lblcategorytext.Click += new System.EventHandler(this.lblcategorytext_Click); + // + // btncat_forward + // + this.btncat_forward.AutoSize = true; + this.btncat_forward.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.btncat_forward.Dock = System.Windows.Forms.DockStyle.Right; + this.btncat_forward.Location = new System.Drawing.Point(365, 0); + this.btncat_forward.Name = "btncat_forward"; + this.btncat_forward.Size = new System.Drawing.Size(29, 23); + this.btncat_forward.TabIndex = 1; + this.btncat_forward.Text = "-->"; + this.btncat_forward.UseVisualStyleBackColor = true; + this.btncat_forward.Click += new System.EventHandler(this.btncat_forward_Click); + // + // btncat_back + // + this.btncat_back.AutoSize = true; + this.btncat_back.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.btncat_back.Dock = System.Windows.Forms.DockStyle.Left; + this.btncat_back.Location = new System.Drawing.Point(0, 0); + this.btncat_back.Name = "btncat_back"; + this.btncat_back.Size = new System.Drawing.Size(29, 23); + this.btncat_back.TabIndex = 0; + this.btncat_back.Text = "<--"; + this.btncat_back.UseVisualStyleBackColor = true; + this.btncat_back.Click += new System.EventHandler(this.btncat_back_Click); + // // lbcodepoints // this.lbcodepoints.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); @@ -215,63 +273,6 @@ namespace ShiftOS.WinForms.Applications this.label3.Size = new System.Drawing.Size(137, 13); this.label3.TabIndex = 2; // - // panel3 - // - this.panel3.Controls.Add(this.lblcategorytext); - this.panel3.Controls.Add(this.btncat_forward); - this.panel3.Controls.Add(this.btncat_back); - this.panel3.Location = new System.Drawing.Point(6, 76); - this.panel3.Name = "panel3"; - this.panel3.Size = new System.Drawing.Size(394, 23); - this.panel3.TabIndex = 5; - // - // btncat_back - // - this.btncat_back.AutoSize = true; - this.btncat_back.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.btncat_back.Dock = System.Windows.Forms.DockStyle.Left; - this.btncat_back.Location = new System.Drawing.Point(0, 0); - this.btncat_back.Name = "btncat_back"; - this.btncat_back.Size = new System.Drawing.Size(29, 23); - this.btncat_back.TabIndex = 0; - this.btncat_back.Text = "<--"; - this.btncat_back.UseVisualStyleBackColor = true; - this.btncat_back.Click += new System.EventHandler(this.btncat_back_Click); - // - // btncat_forward - // - this.btncat_forward.AutoSize = true; - this.btncat_forward.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.btncat_forward.Dock = System.Windows.Forms.DockStyle.Right; - this.btncat_forward.Location = new System.Drawing.Point(365, 0); - this.btncat_forward.Name = "btncat_forward"; - this.btncat_forward.Size = new System.Drawing.Size(29, 23); - this.btncat_forward.TabIndex = 1; - this.btncat_forward.Text = "-->"; - this.btncat_forward.UseVisualStyleBackColor = true; - this.btncat_forward.Click += new System.EventHandler(this.btncat_forward_Click); - // - // lblcategorytext - // - this.lblcategorytext.Dock = System.Windows.Forms.DockStyle.Fill; - this.lblcategorytext.Location = new System.Drawing.Point(29, 0); - this.lblcategorytext.Name = "lblcategorytext"; - this.lblcategorytext.Size = new System.Drawing.Size(336, 23); - this.lblcategorytext.TabIndex = 2; - this.lblcategorytext.Text = "label2"; - this.lblcategorytext.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // lbnoupgrades - // - this.lbnoupgrades.AutoSize = true; - this.lbnoupgrades.Location = new System.Drawing.Point(69, 183); - this.lbnoupgrades.Name = "lbnoupgrades"; - this.lbnoupgrades.Size = new System.Drawing.Size(71, 13); - this.lbnoupgrades.TabIndex = 6; - this.lbnoupgrades.Tag = "header2"; - this.lbnoupgrades.Text = "No upgrades!"; - this.lbnoupgrades.Visible = false; - // // ShiftoriumFrontend // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); diff --git a/ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs b/ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs index 52e9a9e..08e6c8f 100644 --- a/ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs +++ b/ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs @@ -311,5 +311,10 @@ namespace ShiftOS.WinForms.Applications PopulateShiftorium(); } } + + private void lblcategorytext_Click(object sender, EventArgs e) + { + + } } } -- cgit v1.2.3 From 7d24f19716f6c09bbe82c470b83924950ab92daf Mon Sep 17 00:00:00 2001 From: william341 Date: Sat, 6 May 2017 14:56:45 -0700 Subject: oh god --- ShiftOS.WinForms/Controls/TerminalBox.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.WinForms/Controls/TerminalBox.cs b/ShiftOS.WinForms/Controls/TerminalBox.cs index f85daa6..ea7808c 100644 --- a/ShiftOS.WinForms/Controls/TerminalBox.cs +++ b/ShiftOS.WinForms/Controls/TerminalBox.cs @@ -243,7 +243,7 @@ namespace ShiftOS.WinForms.Controls break; default: - Engine.AudioManager.PlayStream(Properties.Resources.typesound); + //Engine.AudioManager.PlayStream(Properties.Resources.typesound); // infernal beeping noise only enable for the trailers break; } } -- cgit v1.2.3 From b82dfc16ed72b710893d7dc0510bd40a5d3a9a07 Mon Sep 17 00:00:00 2001 From: william341 Date: Sat, 6 May 2017 16:11:09 -0700 Subject: Title text actually centers on resize (only if your text is set to center) --- ShiftOS.WinForms/WindowBorder.cs | 55 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.WinForms/WindowBorder.cs b/ShiftOS.WinForms/WindowBorder.cs index 25c7639..40dc629 100644 --- a/ShiftOS.WinForms/WindowBorder.cs +++ b/ShiftOS.WinForms/WindowBorder.cs @@ -515,6 +515,17 @@ namespace ShiftOS.WinForms if(resizing == true) { this.Width += e.X; + switch (LoadedSkin.TitleTextCentered) + { + case false: + lbtitletext.Location = new Point(16 + LoadedSkin.TitlebarIconFromSide.X + LoadedSkin.TitleTextLeft.X, + LoadedSkin.TitleTextLeft.Y); + break; + default: + lbtitletext.Left = (pnltitle.Width - lbtitletext.Width) / 2; + lbtitletext.Top = LoadedSkin.TitleTextLeft.Y; + break; + } } } @@ -522,6 +533,17 @@ namespace ShiftOS.WinForms { resizing = false; pnlcontents.Show(); + switch (LoadedSkin.TitleTextCentered) + { + case false: + lbtitletext.Location = new Point(16 + LoadedSkin.TitlebarIconFromSide.X + LoadedSkin.TitleTextLeft.X, + LoadedSkin.TitleTextLeft.Y); + break; + default: + lbtitletext.Left = (pnltitle.Width - lbtitletext.Width) / 2; + lbtitletext.Top = LoadedSkin.TitleTextLeft.Y; + break; + } } private void pnlleft_MouseMove(object sender, MouseEventArgs e) @@ -530,6 +552,17 @@ namespace ShiftOS.WinForms { this.Left += e.X; this.Width -= e.X; + switch (LoadedSkin.TitleTextCentered) + { + case false: + lbtitletext.Location = new Point(16 + LoadedSkin.TitlebarIconFromSide.X + LoadedSkin.TitleTextLeft.X, + LoadedSkin.TitleTextLeft.Y); + break; + default: + lbtitletext.Left = (pnltitle.Width - lbtitletext.Width) / 2; + lbtitletext.Top = LoadedSkin.TitleTextLeft.Y; + break; + } } } @@ -547,6 +580,17 @@ namespace ShiftOS.WinForms { this.Width += e.X; this.Height += e.Y; + switch (LoadedSkin.TitleTextCentered) + { + case false: + lbtitletext.Location = new Point(16 + LoadedSkin.TitlebarIconFromSide.X + LoadedSkin.TitleTextLeft.X, + LoadedSkin.TitleTextLeft.Y); + break; + default: + lbtitletext.Left = (pnltitle.Width - lbtitletext.Width) / 2; + lbtitletext.Top = LoadedSkin.TitleTextLeft.Y; + break; + } } } @@ -557,6 +601,17 @@ namespace ShiftOS.WinForms this.Width -= e.X; this.Height += e.Y; this.Left += e.X; + switch (LoadedSkin.TitleTextCentered) + { + case false: + lbtitletext.Location = new Point(16 + LoadedSkin.TitlebarIconFromSide.X + LoadedSkin.TitleTextLeft.X, + LoadedSkin.TitleTextLeft.Y); + break; + default: + lbtitletext.Left = (pnltitle.Width - lbtitletext.Width) / 2; + lbtitletext.Top = LoadedSkin.TitleTextLeft.Y; + break; + } } } -- cgit v1.2.3 From d0d193bb1b869697d633d7ccac35179241f8e981 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 6 May 2017 19:24:57 -0400 Subject: GUI-based login screen with skinning! --- ShiftOS.WinForms/GUILogin.Designer.cs | 135 ++++++++++++++++++++++++++++++ ShiftOS.WinForms/GUILogin.cs | 131 +++++++++++++++++++++++++++++ ShiftOS.WinForms/GUILogin.resx | 120 ++++++++++++++++++++++++++ ShiftOS.WinForms/Program.cs | 1 + ShiftOS.WinForms/Resources/Shiftorium.txt | 7 ++ ShiftOS.WinForms/ShiftOS.WinForms.csproj | 9 ++ ShiftOS_TheReturn/LoginManager.cs | 65 ++++++++++++++ ShiftOS_TheReturn/SaveSystem.cs | 120 +++++++++++++++----------- ShiftOS_TheReturn/ShiftOS.Engine.csproj | 1 + ShiftOS_TheReturn/Skinning.cs | 16 ++++ 10 files changed, 555 insertions(+), 50 deletions(-) create mode 100644 ShiftOS.WinForms/GUILogin.Designer.cs create mode 100644 ShiftOS.WinForms/GUILogin.cs create mode 100644 ShiftOS.WinForms/GUILogin.resx create mode 100644 ShiftOS_TheReturn/LoginManager.cs (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.WinForms/GUILogin.Designer.cs b/ShiftOS.WinForms/GUILogin.Designer.cs new file mode 100644 index 0000000..9125d98 --- /dev/null +++ b/ShiftOS.WinForms/GUILogin.Designer.cs @@ -0,0 +1,135 @@ +namespace ShiftOS.WinForms +{ + partial class GUILogin + { + /// + /// 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.pnlloginform = new System.Windows.Forms.Panel(); + this.btnlogin = new System.Windows.Forms.Button(); + this.txtpassword = new System.Windows.Forms.TextBox(); + this.txtusername = new System.Windows.Forms.TextBox(); + this.lblogintitle = new System.Windows.Forms.Label(); + this.btnshutdown = new System.Windows.Forms.Button(); + this.pnlloginform.SuspendLayout(); + this.SuspendLayout(); + // + // pnlloginform + // + this.pnlloginform.Controls.Add(this.btnlogin); + this.pnlloginform.Controls.Add(this.txtpassword); + this.pnlloginform.Controls.Add(this.txtusername); + this.pnlloginform.Location = new System.Drawing.Point(13, 13); + this.pnlloginform.Name = "pnlloginform"; + this.pnlloginform.Size = new System.Drawing.Size(358, 236); + this.pnlloginform.TabIndex = 0; + this.pnlloginform.Tag = ""; + // + // btnlogin + // + this.btnlogin.AutoSize = true; + this.btnlogin.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.btnlogin.Location = new System.Drawing.Point(129, 184); + this.btnlogin.Name = "btnlogin"; + this.btnlogin.Size = new System.Drawing.Size(43, 23); + this.btnlogin.TabIndex = 2; + this.btnlogin.Text = "Login"; + this.btnlogin.UseVisualStyleBackColor = true; + this.btnlogin.Click += new System.EventHandler(this.btnlogin_Click); + // + // txtpassword + // + this.txtpassword.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.txtpassword.Location = new System.Drawing.Point(24, 157); + this.txtpassword.Name = "txtpassword"; + this.txtpassword.Size = new System.Drawing.Size(301, 20); + this.txtpassword.TabIndex = 1; + this.txtpassword.UseSystemPasswordChar = true; + // + // txtusername + // + this.txtusername.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.txtusername.Location = new System.Drawing.Point(24, 131); + this.txtusername.Name = "txtusername"; + this.txtusername.Size = new System.Drawing.Size(301, 20); + this.txtusername.TabIndex = 0; + // + // lblogintitle + // + this.lblogintitle.AutoSize = true; + this.lblogintitle.Location = new System.Drawing.Point(99, 553); + this.lblogintitle.Name = "lblogintitle"; + this.lblogintitle.Size = new System.Drawing.Size(103, 13); + this.lblogintitle.TabIndex = 1; + this.lblogintitle.Tag = "header1 keepbg"; + this.lblogintitle.Text = "Welcome to ShiftOS"; + // + // btnshutdown + // + this.btnshutdown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnshutdown.AutoSize = true; + this.btnshutdown.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.btnshutdown.Location = new System.Drawing.Point(924, 652); + this.btnshutdown.Name = "btnshutdown"; + this.btnshutdown.Size = new System.Drawing.Size(65, 23); + this.btnshutdown.TabIndex = 2; + this.btnshutdown.Text = "Shutdown"; + this.btnshutdown.UseVisualStyleBackColor = true; + this.btnshutdown.Click += new System.EventHandler(this.btnshutdown_Click); + // + // GUILogin + // + 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(1001, 687); + this.Controls.Add(this.btnshutdown); + this.Controls.Add(this.lblogintitle); + this.Controls.Add(this.pnlloginform); + this.ForeColor = System.Drawing.Color.White; + this.Name = "GUILogin"; + this.Text = "GUILogin"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.GUILogin_FormClosing); + this.Load += new System.EventHandler(this.GUILogin_Load); + this.pnlloginform.ResumeLayout(false); + this.pnlloginform.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Panel pnlloginform; + private System.Windows.Forms.Button btnlogin; + private System.Windows.Forms.TextBox txtpassword; + private System.Windows.Forms.TextBox txtusername; + private System.Windows.Forms.Label lblogintitle; + private System.Windows.Forms.Button btnshutdown; + } +} \ No newline at end of file diff --git a/ShiftOS.WinForms/GUILogin.cs b/ShiftOS.WinForms/GUILogin.cs new file mode 100644 index 0000000..66ff06d --- /dev/null +++ b/ShiftOS.WinForms/GUILogin.cs @@ -0,0 +1,131 @@ +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; +using ShiftOS.Engine; +using ShiftOS.Objects; +using ShiftOS.WinForms.Tools; + +namespace ShiftOS.WinForms +{ + public partial class GUILogin : Form + { + public GUILogin() + { + InitializeComponent(); + uiTimer.Tick += (o, a) => + { + btnlogin.Left = txtusername.Left + ((txtusername.Width - btnlogin.Width) / 2); + btnlogin.Top = txtpassword.Top + txtpassword.Height + 5; + + lblogintitle.Left = pnlloginform.Left + ((pnlloginform.Width - lblogintitle.Width) / 2); + lblogintitle.Top = pnlloginform.Top - lblogintitle.Width - 5; + + }; + uiTimer.Interval = 100; + this.FormBorderStyle = FormBorderStyle.None; + this.WindowState = FormWindowState.Maximized; + this.TopMost = true; + } + + Timer uiTimer = new Timer(); + + public event Action LoginComplete; + + private void GUILogin_Load(object sender, EventArgs e) + { + uiTimer.Start(); + ControlManager.SetupControl(lblogintitle); + ControlManager.SetupControls(pnlloginform); + ControlManager.SetupControl(btnshutdown); + pnlloginform.CenterParent(); + this.BackColor = SkinEngine.LoadedSkin.LoginScreenColor; + this.BackgroundImage = SkinEngine.GetImage("login"); + this.BackgroundImageLayout = SkinEngine.GetImageLayout("login"); + } + + private ClientSave User = null; + + bool userRequestClose = true; + bool shuttingdown = false; + + private void GUILogin_FormClosing(object sender, FormClosingEventArgs e) + { + e.Cancel = userRequestClose; + if (!e.Cancel) + { + uiTimer.Stop(); + if (shuttingdown == false) + { + LoginComplete?.Invoke(User); + } + } + } + + private void btnlogin_Click(object sender, EventArgs e) + { + if (string.IsNullOrWhiteSpace(txtusername.Text)) + { + Infobox.Show("Enter a username", "You must enter your username to login."); + return; + } + + //Don't check for blank passwords. + + var user = SaveSystem.CurrentSave.Users.FirstOrDefault(x => x.Username == txtusername.Text); + if(user == null) + { + Infobox.Show("Invalid username", "That username was not found on your system."); + return; + } + + if (user.Password != txtpassword.Text) + { + Infobox.Show("Access denied.", "That password didn't work. Please try a different one."); + return; + } + + User = user; + userRequestClose = false; + shuttingdown = false; + this.Close(); + } + + private void btnshutdown_Click(object sender, EventArgs e) + { + userRequestClose = false; + shuttingdown = true; + this.Close(); + SaveSystem.CurrentUser = SaveSystem.CurrentSave.Users.FirstOrDefault(x => x.Username == "root"); + TerminalBackend.InvokeCommand("sos.shutdown"); + } + } + + public class GUILoginFrontend : ILoginFrontend + { + public bool UseGUILogin + { + get + { + return Shiftorium.UpgradeInstalled("gui_based_login_screen"); + } + } + + public event Action LoginComplete; + + public void Login() + { + var lform = new GUILogin(); + lform.LoginComplete += (user) => + { + LoginComplete?.Invoke(user); + }; + lform.Show(); + } + } +} diff --git a/ShiftOS.WinForms/GUILogin.resx b/ShiftOS.WinForms/GUILogin.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/ShiftOS.WinForms/GUILogin.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/ShiftOS.WinForms/Program.cs b/ShiftOS.WinForms/Program.cs index b2f064d..ad8fc83 100644 --- a/ShiftOS.WinForms/Program.cs +++ b/ShiftOS.WinForms/Program.cs @@ -49,6 +49,7 @@ namespace ShiftOS.WinForms Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //if ANYONE puts code before those two winforms config lines they will be declared a drunky. - Michael + LoginManager.Init(new GUILoginFrontend()); CrashHandler.SetGameMetadata(Assembly.GetExecutingAssembly()); SkinEngine.SetIconProber(new ShiftOSIconProvider()); ShiftOS.Engine.AudioManager.Init(new ShiftOSAudioProvider()); diff --git a/ShiftOS.WinForms/Resources/Shiftorium.txt b/ShiftOS.WinForms/Resources/Shiftorium.txt index b528c72..c3d27ae 100644 --- a/ShiftOS.WinForms/Resources/Shiftorium.txt +++ b/ShiftOS.WinForms/Resources/Shiftorium.txt @@ -7,6 +7,13 @@ Dependencies: "desktop", Category: "Enhancements", }, + { + Name: "GUI Based Login Screen", + Cost: 500, + Description: "Tired of using the text-based login screen in ShiftOS? Well, we have a functioning window manager, and a functioning desktop, why not use these tools to create a functioning and awesome-looking login screen?", + Dependencies: "skinning;desktop;wm_free_placement", + Category: "Kernel & System" + }, { Name: "Shift Screensavers", Cost: 100, diff --git a/ShiftOS.WinForms/ShiftOS.WinForms.csproj b/ShiftOS.WinForms/ShiftOS.WinForms.csproj index 1607ae9..411d701 100644 --- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj +++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj @@ -323,6 +323,12 @@ DownloadControl.cs + + Form + + + GUILogin.cs + @@ -520,6 +526,9 @@ DownloadControl.cs + + GUILogin.cs + Oobe.cs diff --git a/ShiftOS_TheReturn/LoginManager.cs b/ShiftOS_TheReturn/LoginManager.cs new file mode 100644 index 0000000..d326f2c --- /dev/null +++ b/ShiftOS_TheReturn/LoginManager.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ShiftOS.Objects; + +namespace ShiftOS.Engine +{ + public static class LoginManager + { + private static ILoginFrontend _login = null; + + public static void Init(ILoginFrontend login) + { + _login = login; + } + + public static void PromptForLogin() + { + _login.LoginComplete += (user) => + { + LoginComplete?.Invoke(user); + }; + _login.Login(); + } + + public static bool ShouldUseGUILogin + { + get + { + if (_login == null) + return false; + return _login.UseGUILogin; + } + } + + public static event Action LoginComplete; + } + + /// + /// Interface for GUI-based logins. + /// + public interface ILoginFrontend + { + /// + /// When implemented, shows the login UI. + /// + void Login(); + + /// + /// Gets whether the ShiftOS engine should use a GUI-based login system or the default one. + /// + bool UseGUILogin { get; } + + + /// + /// Occurs when the login is complete. + /// + event Action LoginComplete; + + + + } +} diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index f29e5b8..93a8add 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -263,70 +263,90 @@ namespace ShiftOS.Engine TerminalBackend.PrefixEnabled = false; - Login: - string username = ""; - int progress = 0; - bool goback = false; - TextSentEventHandler ev = null; - ev = (text) => + if (LoginManager.ShouldUseGUILogin) { - if (progress == 0) + Action Completed = null; + Completed += (user) => { - if (!string.IsNullOrWhiteSpace(text)) + CurrentUser = user; + LoginManager.LoginComplete -= Completed; + }; + LoginManager.LoginComplete += Completed; + Desktop.InvokeOnWorkerThread(() => + { + LoginManager.PromptForLogin(); + }); + while (CurrentUser == null) + { + Thread.Sleep(10); + } + } + else + { + + Login: + string username = ""; + int progress = 0; + bool goback = false; + TextSentEventHandler ev = null; + ev = (text) => + { + if (progress == 0) { - if (CurrentSave.Users.FirstOrDefault(x => x.Username == text) == null) + if (!string.IsNullOrWhiteSpace(text)) { - Console.WriteLine("User not found."); - goback = true; + if (CurrentSave.Users.FirstOrDefault(x => x.Username == text) == null) + { + Console.WriteLine("User not found."); + goback = true; + progress++; + TerminalBackend.TextSent -= ev; + return; + } + username = text; progress++; + } + else + { + Console.WriteLine("Username not provided."); TerminalBackend.TextSent -= ev; - return; + goback = true; + progress++; } - username = text; - progress++; } - else + else if (progress == 1) { - Console.WriteLine("Username not provided."); + var user = CurrentSave.Users.FirstOrDefault(x => x.Username == username); + if (user.Password == text) + { + Console.WriteLine("Welcome to ShiftOS."); + CurrentUser = user; + Thread.Sleep(2000); + progress++; + } + else + { + Console.WriteLine("Access denied."); + goback = true; + progress++; + } TerminalBackend.TextSent -= ev; - goback = true; - progress++; } - } - else if (progress == 1) + }; + TerminalBackend.TextSent += ev; + Console.WriteLine(CurrentSave.SystemName + " login:"); + while (progress == 0) { - var user = CurrentSave.Users.FirstOrDefault(x => x.Username == username); - if (user.Password == text) - { - Console.WriteLine("Welcome to ShiftOS."); - CurrentUser = user; - Thread.Sleep(2000); - progress++; - } - else - { - Console.WriteLine("Access denied."); - goback = true; - progress++; - } - TerminalBackend.TextSent -= ev; + Thread.Sleep(10); } - }; - TerminalBackend.TextSent += ev; - Console.WriteLine(CurrentSave.SystemName + " login:"); - while(progress == 0) - { - Thread.Sleep(10); + if (goback) + goto Login; + Console.WriteLine("password:"); + while (progress == 1) + Thread.Sleep(10); + if (goback) + goto Login; } - if (goback) - goto Login; - Console.WriteLine("password:"); - while (progress == 1) - Thread.Sleep(10); - if (goback) - goto Login; - - TerminalBackend.PrefixEnabled = true; Shiftorium.LogOrphanedUpgrades = true; Desktop.InvokeOnWorkerThread(new Action(() => diff --git a/ShiftOS_TheReturn/ShiftOS.Engine.csproj b/ShiftOS_TheReturn/ShiftOS.Engine.csproj index fb33dc5..3b5eadd 100644 --- a/ShiftOS_TheReturn/ShiftOS.Engine.csproj +++ b/ShiftOS_TheReturn/ShiftOS.Engine.csproj @@ -111,6 +111,7 @@ + diff --git a/ShiftOS_TheReturn/Skinning.cs b/ShiftOS_TheReturn/Skinning.cs index 4cc9bbd..b731c4f 100644 --- a/ShiftOS_TheReturn/Skinning.cs +++ b/ShiftOS_TheReturn/Skinning.cs @@ -267,6 +267,22 @@ namespace ShiftOS.Engine [ShifterHidden] public Dictionary AppIcons = new Dictionary(); + [ShifterMeta("System")] + [ShifterCategory("Login Screen")] + [RequiresUpgrade("gui_based_login_screen")] + [ShifterName("Login Screen Background Color")] + [ShifterDescription("Change the background color of the login screen.")] + public Color LoginScreenColor = Skin.DesktopBG; + + [ShifterMeta("System")] + [ShifterCategory("Login Screen")] + [RequiresUpgrade("skinning;gui_based_login_screen")] + [ShifterName("Login Screen Background Image")] + [ShifterDescription("Set an image as your login screen!")] + [Image("login")] + public byte[] LoginScreenBG = null; + + [RequiresUpgrade("shift_screensaver")] [ShifterMeta("System")] [ShifterCategory("Screen saver")] -- cgit v1.2.3 From 57c8eb390411d28f3a6c80ce6abf5f3aa06e4d29 Mon Sep 17 00:00:00 2001 From: william341 Date: Sat, 6 May 2017 18:50:37 -0700 Subject: gahhhh they were just slightly offcenter and it triggers me --- ShiftOS.WinForms/GUILogin.Designer.cs | 12 ++++++------ ShiftOS.WinForms/GUILogin.cs | 5 +++++ 2 files changed, 11 insertions(+), 6 deletions(-) (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.WinForms/GUILogin.Designer.cs b/ShiftOS.WinForms/GUILogin.Designer.cs index 9125d98..e10071f 100644 --- a/ShiftOS.WinForms/GUILogin.Designer.cs +++ b/ShiftOS.WinForms/GUILogin.Designer.cs @@ -52,7 +52,7 @@ // this.btnlogin.AutoSize = true; this.btnlogin.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.btnlogin.Location = new System.Drawing.Point(129, 184); + this.btnlogin.Location = new System.Drawing.Point(159, 163); this.btnlogin.Name = "btnlogin"; this.btnlogin.Size = new System.Drawing.Size(43, 23); this.btnlogin.TabIndex = 2; @@ -64,19 +64,19 @@ // this.txtpassword.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.txtpassword.Location = new System.Drawing.Point(24, 157); + this.txtpassword.Location = new System.Drawing.Point(69, 115); this.txtpassword.Name = "txtpassword"; - this.txtpassword.Size = new System.Drawing.Size(301, 20); + this.txtpassword.Size = new System.Drawing.Size(300, 20); this.txtpassword.TabIndex = 1; this.txtpassword.UseSystemPasswordChar = true; // // txtusername // - this.txtusername.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + this.txtusername.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.txtusername.Location = new System.Drawing.Point(24, 131); + this.txtusername.Location = new System.Drawing.Point(3, 14); this.txtusername.Name = "txtusername"; - this.txtusername.Size = new System.Drawing.Size(301, 20); + this.txtusername.Size = new System.Drawing.Size(300, 20); this.txtusername.TabIndex = 0; // // lblogintitle diff --git a/ShiftOS.WinForms/GUILogin.cs b/ShiftOS.WinForms/GUILogin.cs index 66ff06d..078061c 100644 --- a/ShiftOS.WinForms/GUILogin.cs +++ b/ShiftOS.WinForms/GUILogin.cs @@ -44,6 +44,11 @@ namespace ShiftOS.WinForms ControlManager.SetupControls(pnlloginform); ControlManager.SetupControl(btnshutdown); pnlloginform.CenterParent(); + txtusername.CenterParent(); + txtusername.Location = new System.Drawing.Point(txtusername.Location.X, 77); + txtpassword.CenterParent(); + btnlogin.CenterParent(); + btnlogin.Location = new System.Drawing.Point(btnlogin.Location.X, 143); this.BackColor = SkinEngine.LoadedSkin.LoginScreenColor; this.BackgroundImage = SkinEngine.GetImage("login"); this.BackgroundImageLayout = SkinEngine.GetImageLayout("login"); -- cgit v1.2.3 From 4a5db39ea7c0b9be342261ab416dbb5edf50b2ce Mon Sep 17 00:00:00 2001 From: wowmom98 Date: Sun, 7 May 2017 15:03:35 +0000 Subject: FIRST COMMIT FROM A MAC BUT TURIANS ARE COOL RIGHT --- ShiftOS.WinForms/Applications/TriWrite.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.WinForms/Applications/TriWrite.cs b/ShiftOS.WinForms/Applications/TriWrite.cs index b5845ba..291aa30 100644 --- a/ShiftOS.WinForms/Applications/TriWrite.cs +++ b/ShiftOS.WinForms/Applications/TriWrite.cs @@ -21,7 +21,7 @@ namespace ShiftOS.WinForms.Applications public TriWrite() { - InitializeComponent(); + InitializeComponent(); //From the library of babel: "FIRST COMMIT FROM A MAC WOOOO TURIANS ARE COOL" } private void newToolStripMenuItem_Click(object sender, EventArgs e) -- cgit v1.2.3 From 75ed7e9215ba88358d9b838dd82fa3841f78ae5a Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 8 May 2017 11:31:20 -0400 Subject: Fix softlocks on pre-user OOBE. --- .vs/config/applicationhost.config | 1030 ++++++++++++++++++++++++++++++++ ShiftOS.Objects/ShiftOS.Objects.csproj | 1 + ShiftOS.Objects/UserConfig.cs | 37 ++ ShiftOS.Server/Program.cs | 1 + ShiftOS.Server/SaveManager.cs | 2 +- ShiftOS.WinForms/OobeStory.cs | 10 +- ShiftOS.WinForms/UniteLoginDialog.cs | 3 +- ShiftOS.WinForms/UniteSignupDialog.cs | 3 +- ShiftOS_TheReturn/SaveSystem.cs | 2 +- ShiftOS_TheReturn/UniteClient.cs | 12 +- 10 files changed, 1091 insertions(+), 10 deletions(-) create mode 100644 .vs/config/applicationhost.config create mode 100644 ShiftOS.Objects/UserConfig.cs (limited to 'ShiftOS.WinForms') diff --git a/.vs/config/applicationhost.config b/.vs/config/applicationhost.config new file mode 100644 index 0000000..b42cd34 --- /dev/null +++ b/.vs/config/applicationhost.config @@ -0,0 +1,1030 @@ + + + + + + + + +
+
+
+
+
+
+
+
+ + + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+ +
+
+ +
+
+ +
+
+
+ + +
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ShiftOS.Objects/ShiftOS.Objects.csproj b/ShiftOS.Objects/ShiftOS.Objects.csproj index 7a19aeb..c2ef5ed 100644 --- a/ShiftOS.Objects/ShiftOS.Objects.csproj +++ b/ShiftOS.Objects/ShiftOS.Objects.csproj @@ -58,6 +58,7 @@ + diff --git a/ShiftOS.Objects/UserConfig.cs b/ShiftOS.Objects/UserConfig.cs new file mode 100644 index 0000000..61d11b8 --- /dev/null +++ b/ShiftOS.Objects/UserConfig.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Newtonsoft.Json; + +namespace ShiftOS.Objects +{ + public class UserConfig + { + public string UniteUrl { get; set; } + public string DigitalSocietyAddress { get; set; } + public int DigitalSocietyPort { get; set; } + + public static UserConfig Get() + { + var conf = new UserConfig + { + UniteUrl = "http://getshiftos.ml", + DigitalSocietyAddress = "michaeltheshifter.me", + DigitalSocietyPort = 13370 + }; + + if (!File.Exists("servers.json")) + { + File.WriteAllText("servers.json", JsonConvert.SerializeObject(conf, Formatting.Indented)); + } + else + { + conf = JsonConvert.DeserializeObject(File.ReadAllText("servers.json")); + } + return conf; + } + } +} diff --git a/ShiftOS.Server/Program.cs b/ShiftOS.Server/Program.cs index 97c8a66..75af56f 100644 --- a/ShiftOS.Server/Program.cs +++ b/ShiftOS.Server/Program.cs @@ -86,6 +86,7 @@ namespace ShiftOS.Server /// The command-line arguments. public static void Main(string[] args) { + UserConfig.Get(); System.Timers.Timer tmr = new System.Timers.Timer(5000); tmr.Elapsed += (o, a) => { diff --git a/ShiftOS.Server/SaveManager.cs b/ShiftOS.Server/SaveManager.cs index 63aa2bf..d81a1a7 100644 --- a/ShiftOS.Server/SaveManager.cs +++ b/ShiftOS.Server/SaveManager.cs @@ -189,7 +189,7 @@ namespace ShiftOS.Server //Update the shiftos website with the user's codepoints. if (!string.IsNullOrWhiteSpace(sav.UniteAuthToken)) { - var wreq = WebRequest.Create("http://getshiftos.ml/API/SetCodepoints/" + sav.Codepoints.ToString()); + var wreq = WebRequest.Create(UserConfig.Get().UniteUrl + "/API/SetCodepoints/" + sav.Codepoints.ToString()); wreq.Headers.Add("Authentication: Token " + sav.UniteAuthToken); wreq.GetResponse(); } diff --git a/ShiftOS.WinForms/OobeStory.cs b/ShiftOS.WinForms/OobeStory.cs index bab4889..39ca5b5 100644 --- a/ShiftOS.WinForms/OobeStory.cs +++ b/ShiftOS.WinForms/OobeStory.cs @@ -120,7 +120,7 @@ namespace ShiftOS.WinForms Console.Write(" "); ConsoleEx.BackgroundColor = ConsoleColor.Black; } - Engine.AudioManager.PlayStream(Properties.Resources.typesound); + Desktop.InvokeOnWorkerThread(() => Engine.AudioManager.PlayStream(Properties.Resources.typesound)); formatProgress++; Thread.Sleep(175); } @@ -135,14 +135,16 @@ namespace ShiftOS.WinForms { Console.WriteLine("Creating: " + dir); Thread.Sleep(125); - Engine.AudioManager.PlayStream(Properties.Resources.writesound); + Desktop.InvokeOnWorkerThread(() => Engine.AudioManager.PlayStream(Properties.Resources.writesound)); } } Console.WriteLine(); Console.WriteLine("Next, let's get user information."); Console.WriteLine(); - ShiftOS.Engine.OutOfBoxExperience.PromptForLogin(); - + Desktop.InvokeOnWorkerThread(() => + { + ShiftOS.Engine.OutOfBoxExperience.PromptForLogin(); + }); } private static bool isValid(string text, string chars) { diff --git a/ShiftOS.WinForms/UniteLoginDialog.cs b/ShiftOS.WinForms/UniteLoginDialog.cs index 4c85005..c78e987 100644 --- a/ShiftOS.WinForms/UniteLoginDialog.cs +++ b/ShiftOS.WinForms/UniteLoginDialog.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; using System.Windows.Forms; using ShiftOS.Engine; using System.Net; +using ShiftOS.Objects; namespace ShiftOS.WinForms { @@ -59,7 +60,7 @@ namespace ShiftOS.WinForms try { - var webrequest = HttpWebRequest.Create("http://getshiftos.ml/Auth/Login?appname=ShiftOS&appdesc=ShiftOS+client&version=1_0_beta_2_4"); + var webrequest = HttpWebRequest.Create(UserConfig.Get().UniteUrl + "/Auth/Login?appname=ShiftOS&appdesc=ShiftOS+client&version=1_0_beta_2_4"); string base64 = Convert.ToBase64String(Encoding.UTF8.GetBytes($"{u}:{p}")); webrequest.Headers.Add("Authentication: Basic " + base64); var response = webrequest.GetResponse(); diff --git a/ShiftOS.WinForms/UniteSignupDialog.cs b/ShiftOS.WinForms/UniteSignupDialog.cs index a46a9b0..7d0fd33 100644 --- a/ShiftOS.WinForms/UniteSignupDialog.cs +++ b/ShiftOS.WinForms/UniteSignupDialog.cs @@ -10,6 +10,7 @@ using System.Windows.Forms; using ShiftOS.Engine; using Newtonsoft.Json; using System.Net; +using ShiftOS.Objects; namespace ShiftOS.WinForms { @@ -99,7 +100,7 @@ namespace ShiftOS.WinForms try { - var webrequest = HttpWebRequest.Create("http://getshiftos.ml/Auth/Register?appname=ShiftOS&appdesc=ShiftOS+client&version=1_0_beta_2_4&displayname=" + txtdisplay.Text + "&sysname=" + txtsysname.Text); + var webrequest = HttpWebRequest.Create(UserConfig.Get().UniteUrl + "/Auth/Register?appname=ShiftOS&appdesc=ShiftOS+client&version=1_0_beta_2_4&displayname=" + txtdisplay.Text + "&sysname=" + txtsysname.Text); string base64 = Convert.ToBase64String(Encoding.UTF8.GetBytes($"{u}:{p}")); webrequest.Headers.Add("Authentication: Basic " + base64); var response = webrequest.GetResponse(); diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index e635a7a..31db58a 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -131,7 +131,7 @@ namespace ShiftOS.Engine try { - ServerManager.Initiate("secondary4162.cloudapp.net", 13370); + ServerManager.Initiate(UserConfig.Get().DigitalSocietyAddress, UserConfig.Get().DigitalSocietyPort); //This haults the client until the connection is successful. while (ServerManager.thisGuid == new Guid()) { diff --git a/ShiftOS_TheReturn/UniteClient.cs b/ShiftOS_TheReturn/UniteClient.cs index 1136b5c..8d6a58d 100644 --- a/ShiftOS_TheReturn/UniteClient.cs +++ b/ShiftOS_TheReturn/UniteClient.cs @@ -5,13 +5,20 @@ using System.Net; using System.Text; using System.Threading.Tasks; using Newtonsoft.Json; +using ShiftOS.Objects; namespace ShiftOS.Unite { public class UniteClient { public string Token { get; private set; } - public string BaseURL { get; private set; } + public string BaseURL + { + get + { + return UserConfig.Get().UniteUrl; + } + } public string GetDisplayNameId(string id) { @@ -25,7 +32,8 @@ namespace ShiftOS.Unite public UniteClient(string baseurl, string usertoken) { - BaseURL = baseurl; + //Handled by the servers.json file + //BaseURL = baseurl; Token = usertoken; } -- cgit v1.2.3 From 64f491ff2821f99fc7485d9b062cc75c7d8fff1c Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 8 May 2017 12:09:45 -0400 Subject: Fix softlock when creating new saves. --- ShiftOS.WinForms/Oobe.cs | 2 ++ ShiftOS.WinForms/OobeStory.cs | 6 ++---- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.WinForms/Oobe.cs b/ShiftOS.WinForms/Oobe.cs index a4d63e0..0bcb290 100644 --- a/ShiftOS.WinForms/Oobe.cs +++ b/ShiftOS.WinForms/Oobe.cs @@ -316,7 +316,9 @@ You must join the digital society, rise up the ranks, and save us. { sve.StoryPosition = 8675309; SaveSystem.CurrentSave = sve; + Shiftorium.Silent = true; SaveSystem.SaveGame(); + Shiftorium.Silent = false; }); } diff --git a/ShiftOS.WinForms/OobeStory.cs b/ShiftOS.WinForms/OobeStory.cs index 39ca5b5..a35e1d8 100644 --- a/ShiftOS.WinForms/OobeStory.cs +++ b/ShiftOS.WinForms/OobeStory.cs @@ -141,11 +141,9 @@ namespace ShiftOS.WinForms Console.WriteLine(); Console.WriteLine("Next, let's get user information."); Console.WriteLine(); - Desktop.InvokeOnWorkerThread(() => - { - ShiftOS.Engine.OutOfBoxExperience.PromptForLogin(); - }); + ShiftOS.Engine.OutOfBoxExperience.PromptForLogin(); } + private static bool isValid(string text, string chars) { foreach(var c in text) -- cgit v1.2.3 From 2cede571ca23806b68344d9984c11eedaaea76e1 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 8 May 2017 12:12:22 -0400 Subject: add mud_fundamentals to new saves --- ShiftOS.WinForms/Oobe.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.WinForms/Oobe.cs b/ShiftOS.WinForms/Oobe.cs index 0bcb290..d5f28f8 100644 --- a/ShiftOS.WinForms/Oobe.cs +++ b/ShiftOS.WinForms/Oobe.cs @@ -312,6 +312,8 @@ You must join the digital society, rise up the ranks, and save us. sve.Codepoints = 0; sve.Upgrades = new Dictionary(); sve.ID = Guid.NewGuid(); + sve.StoriesExperienced = new List(); + sve.StoriesExperienced.Add("mud_fundamentals"); Infobox.Show("Welcome to ShiftOS.", "Welcome to ShiftOS, " + client.GetDisplayName() + ". We have created a save file for you. Now, go on and Shift It Your Way.", () => { sve.StoryPosition = 8675309; -- cgit v1.2.3 From bded9d1250575e6b9824be9048ac7ac8669a303b Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 12 May 2017 19:17:47 -0400 Subject: ShiftOS is a hydra. You pop one bug off, 2,000 more grow in its place. --- ShiftOS.WinForms/Applications/About.Designer.cs | 10 +- ShiftOS.WinForms/Applications/About.cs | 71 +++++- ShiftOS.WinForms/AudioManager.cs | 62 +++++ ShiftOS.WinForms/Program.cs | 13 ++ ShiftOS.WinForms/Properties/Resources.Designer.cs | 110 ++++++++- ShiftOS.WinForms/Properties/Resources.resx | 39 +++- ShiftOS.WinForms/Resources/Ambient1.mp3 | Bin 0 -> 5765139 bytes ShiftOS.WinForms/Resources/Ambient2.mp3 | Bin 0 -> 5017165 bytes ShiftOS.WinForms/Resources/Ambient3.mp3 | Bin 0 -> 6948747 bytes ShiftOS.WinForms/Resources/Ambient4.mp3 | Bin 0 -> 6121813 bytes ShiftOS.WinForms/Resources/Ambient5.mp3 | Bin 0 -> 6025921 bytes ShiftOS.WinForms/Resources/Ambient6.mp3 | Bin 0 -> 5303077 bytes ShiftOS.WinForms/Resources/Ambient7.mp3 | Bin 0 -> 8237719 bytes ShiftOS.WinForms/Resources/Ambient8.mp3 | Bin 0 -> 8077862 bytes ShiftOS.WinForms/Resources/Ambient9.mp3 | Bin 0 -> 3859193 bytes ShiftOS.WinForms/ShiftOS.WinForms.csproj | 9 + ShiftOS_TheReturn/AppearanceManager.cs | 2 +- ShiftOS_TheReturn/AudioManager.cs | 9 +- ShiftOS_TheReturn/Commands.cs | 1 - ShiftOS_TheReturn/SaveSystem.cs | 15 ++ ShiftOS_TheReturn/TerminalBackend.cs | 269 +++++++++++----------- 21 files changed, 435 insertions(+), 175 deletions(-) create mode 100644 ShiftOS.WinForms/Resources/Ambient1.mp3 create mode 100644 ShiftOS.WinForms/Resources/Ambient2.mp3 create mode 100644 ShiftOS.WinForms/Resources/Ambient3.mp3 create mode 100644 ShiftOS.WinForms/Resources/Ambient4.mp3 create mode 100644 ShiftOS.WinForms/Resources/Ambient5.mp3 create mode 100644 ShiftOS.WinForms/Resources/Ambient6.mp3 create mode 100644 ShiftOS.WinForms/Resources/Ambient7.mp3 create mode 100644 ShiftOS.WinForms/Resources/Ambient8.mp3 create mode 100644 ShiftOS.WinForms/Resources/Ambient9.mp3 (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.WinForms/Applications/About.Designer.cs b/ShiftOS.WinForms/Applications/About.Designer.cs index ab76eab..989d79b 100644 --- a/ShiftOS.WinForms/Applications/About.Designer.cs +++ b/ShiftOS.WinForms/Applications/About.Designer.cs @@ -55,7 +55,7 @@ namespace ShiftOS.WinForms.Applications this.pictureBox1 = new System.Windows.Forms.PictureBox(); this.label1 = new System.Windows.Forms.Label(); this.lbshiftit = new System.Windows.Forms.Label(); - this.lbaboutdesc = new System.Windows.Forms.Label(); + this.lbaboutdesc = new System.Windows.Forms.TextBox(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); this.SuspendLayout(); // @@ -94,11 +94,11 @@ namespace ShiftOS.WinForms.Applications this.lbaboutdesc.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.lbaboutdesc.Location = new System.Drawing.Point(14, 126); + this.lbaboutdesc.Location = new System.Drawing.Point(23, 158); + this.lbaboutdesc.Multiline = true; this.lbaboutdesc.Name = "lbaboutdesc"; - this.lbaboutdesc.Size = new System.Drawing.Size(498, 328); + this.lbaboutdesc.Size = new System.Drawing.Size(492, 302); this.lbaboutdesc.TabIndex = 3; - this.lbaboutdesc.Text = "label2"; // // About // @@ -121,6 +121,6 @@ namespace ShiftOS.WinForms.Applications private System.Windows.Forms.PictureBox pictureBox1; private System.Windows.Forms.Label label1; private System.Windows.Forms.Label lbshiftit; - private System.Windows.Forms.Label lbaboutdesc; + private System.Windows.Forms.TextBox lbaboutdesc; } } diff --git a/ShiftOS.WinForms/Applications/About.cs b/ShiftOS.WinForms/Applications/About.cs index f91e0cc..a27238d 100644 --- a/ShiftOS.WinForms/Applications/About.cs +++ b/ShiftOS.WinForms/Applications/About.cs @@ -53,18 +53,73 @@ namespace ShiftOS.WinForms.Applications lbaboutdesc.Text = $@"ShiftOS Copyright (c) 2015-{DateTime.Now.Year} Michael VanOverbeek and ShiftOS devs -Engine version: Milestone 3, 1.0 Beta Series (Developer mode ON) -Frontend version: 1.0 Beta 1.2 -Multi-user domain version: 1.0 Rolling-Release - -Music courtesy of Selulance. Listen to the Fractal Forest album here: -https://www.youtube.com/watch?v=LB5jAYDL3VU&t=913s +Engine version: Milestone 4, 1.0 Beta Series (Developer mode ON) +Frontend version: 1.0 Beta 2.5 +Digital Society version: 1.0 Rolling-Release +Project: Unite version: 1.0 Beta 1.7 Special thanks to Philip Adams, the original creator of ShiftOS for helping us grow our community of amazing Shifters by featuring us on the YouTube Millionaire series and advertising us throughout various other series ran by him. Also, thanks to Rylan Arbour, Victor Tran and the other community moderators and administrators for helping us keep the community peaceful. -Lastly, a huge special thanks to the community themselves - for testing, debugging, fixing, reporting bugs for, and enjoying our game even through its many failures, successes, revamps, etc. You guys are the reason we develop the game!"; +Lastly, a huge special thanks to the community themselves - for testing, debugging, fixing, reporting bugs for, and enjoying our game even through its many failures, successes, revamps, etc. You guys are the reason we develop the game! + + === Licensing information + +ShiftOS is licensed under the MIT license. + +Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the ""Software""), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +copies of the Software, and to permit persons to whom the Software is + +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + == Credit where credit is due + + -- Development and staff team: + - Rylan Arbour (Lead community administrator) + - Victor Tran (Discord administrator) + - cjhannah (ShiftFS backend developer) + - AShifter (Project: Unite penetration tester) + - arencllc (ShiftLetters developer) + - Michael VanOverbeek (Lead developer, system administrator, the guy who wrote this text) + - fixylol, Nebble, TravisNC, Neptune (Community moderators) + - bandic00t_ (Skin Engine stresstesting) + + -- System audio + + - Default system event sounds (Infobox, Network Connecting, System Beeps) are from the original ShiftOS 0.0.x source code. + - Ambient music list courtesy of https://www.youtube.com/channel/UC56Qctnsu8wAyvzf4Yx6LIw (ArgoFox | Royalty Free Music) + +Tracklist: + + Dylan Hardy - Strangely Unaffected +Noxive - Home +Dylan Hardy and Abraham Alberto - Slow Drift +A Himitsu - Easier To Fade +Noxive - Resilience +Wanderflux - Visions +Aerocity - Cold Weather Kids +Aether - Wanderlust +Aerocity - Love Lost + + +Finally, special thanks to our Patreon supporters. Without you guys, our servers wouldn't be running, and you wouldn't be reading this."; } public string GetEngineVersion() @@ -107,7 +162,7 @@ Lastly, a huge special thanks to the community themselves - for testing, debuggi public bool OnUnload() { - return false; + return true; } public void OnUpgrade() diff --git a/ShiftOS.WinForms/AudioManager.cs b/ShiftOS.WinForms/AudioManager.cs index 5c43ac4..eb0e798 100644 --- a/ShiftOS.WinForms/AudioManager.cs +++ b/ShiftOS.WinForms/AudioManager.cs @@ -24,8 +24,10 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Text; +using System.Threading; using System.Threading.Tasks; namespace ShiftOS.WinForms @@ -37,5 +39,65 @@ namespace ShiftOS.WinForms { } + + internal static byte[] GetRandomSong() + { + var r = new Random().Next(1, 10); + switch (r) + { + case 1: + return Properties.Resources.Ambient1; + case 2: + return Properties.Resources.Ambient2; + case 3: + return Properties.Resources.Ambient3; + case 4: + return Properties.Resources.Ambient4; + case 5: + return Properties.Resources.Ambient5; + case 6: + return Properties.Resources.Ambient6; + case 7: + return Properties.Resources.Ambient7; + case 8: + return Properties.Resources.Ambient8; + default: + return Properties.Resources.Ambient9; + + } + } + + internal static void StartAmbientLoop() + { + var athread = new Thread(() => + { + MemoryStream str = null; + NAudio.Wave.Mp3FileReader mp3 = null; + NAudio.Wave.WaveOut o = null; + while (!Engine.SaveSystem.ShuttingDown) + { + str = new MemoryStream(GetRandomSong()); + mp3 = new NAudio.Wave.Mp3FileReader(str); + o = new NAudio.Wave.WaveOut(); + o.Init(mp3); + bool c = false; + o.Play(); + o.PlaybackStopped += (s, a) => + { + c = true; + }; + while (!c) + Thread.Sleep(10); + str.Dispose(); + o.Dispose(); + mp3.Dispose(); + } + str?.Dispose(); + o?.Dispose(); + mp3?.Dispose(); + }); + athread.IsBackground = true; + athread.Start(); + } } } diff --git a/ShiftOS.WinForms/Program.cs b/ShiftOS.WinForms/Program.cs index ad8fc83..256894d 100644 --- a/ShiftOS.WinForms/Program.cs +++ b/ShiftOS.WinForms/Program.cs @@ -49,6 +49,19 @@ namespace ShiftOS.WinForms Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //if ANYONE puts code before those two winforms config lines they will be declared a drunky. - Michael + SaveSystem.PreDigitalSocietyConnection += () => + { + Action completed = null; + completed = () => + { + SaveSystem.Ready = true; + Engine.AudioManager.PlayCompleted -= completed; + AudioManager.StartAmbientLoop(); + }; + Engine.AudioManager.PlayCompleted += completed; + Engine.AudioManager.PlayStream(Properties.Resources.dial_up_modem_02); + + }; LoginManager.Init(new GUILoginFrontend()); CrashHandler.SetGameMetadata(Assembly.GetExecutingAssembly()); SkinEngine.SetIconProber(new ShiftOSIconProvider()); diff --git a/ShiftOS.WinForms/Properties/Resources.Designer.cs b/ShiftOS.WinForms/Properties/Resources.Designer.cs index caaf503..0152be8 100644 --- a/ShiftOS.WinForms/Properties/Resources.Designer.cs +++ b/ShiftOS.WinForms/Properties/Resources.Designer.cs @@ -69,6 +69,96 @@ namespace ShiftOS.WinForms.Properties { } } + /// + /// Looks up a localized resource of type System.Byte[]. + /// + internal static byte[] Ambient1 { + get { + object obj = ResourceManager.GetObject("Ambient1", resourceCulture); + return ((byte[])(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Byte[]. + /// + internal static byte[] Ambient2 { + get { + object obj = ResourceManager.GetObject("Ambient2", resourceCulture); + return ((byte[])(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Byte[]. + /// + internal static byte[] Ambient3 { + get { + object obj = ResourceManager.GetObject("Ambient3", resourceCulture); + return ((byte[])(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Byte[]. + /// + internal static byte[] Ambient4 { + get { + object obj = ResourceManager.GetObject("Ambient4", resourceCulture); + return ((byte[])(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Byte[]. + /// + internal static byte[] Ambient5 { + get { + object obj = ResourceManager.GetObject("Ambient5", resourceCulture); + return ((byte[])(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Byte[]. + /// + internal static byte[] Ambient6 { + get { + object obj = ResourceManager.GetObject("Ambient6", resourceCulture); + return ((byte[])(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Byte[]. + /// + internal static byte[] Ambient7 { + get { + object obj = ResourceManager.GetObject("Ambient7", resourceCulture); + return ((byte[])(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Byte[]. + /// + internal static byte[] Ambient8 { + get { + object obj = ResourceManager.GetObject("Ambient8", resourceCulture); + return ((byte[])(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Byte[]. + /// + internal static byte[] Ambient9 { + get { + object obj = ResourceManager.GetObject("Ambient9", resourceCulture); + return ((byte[])(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// @@ -994,22 +1084,18 @@ namespace ShiftOS.WinForms.Properties { /// /// Looks up a localized string similar to [ - /// //TEMPORARY - /// { - /// Name: "Desktop Widgets", - /// Cost: 0, - /// Description: "Temporary upgrade. Will be replaced by either a Shiftnet app or a story element.", - /// Dependencies: "advanced_app_launcher;wm_free_placement", - /// Category: "Work-in-progress" - /// }, - /// - /// - /// ///// SCREENSAVER /// { /// Name: "Screensavers", /// Cost: 750, - /// Description: "Like to leave your PC idle for long periods of time? Save some energy and keep your screen from being tired by hiding the desktop behind a black screen with an image on it." [rest of string was truncated]";. + /// Description: "Like to leave your PC idle for long periods of time? Save some energy and keep your screen from being tired by hiding the desktop behind a black screen with an image on it.", + /// Dependencies: "desktop", + /// Category: "Enhancements", + /// }, + /// { + /// Name: "GUI Based Login Screen", + /// Cost: 500, + /// Description: "Tired of using the text-based login screen in ShiftOS? Well, we have a functioning window manager, and a functioning desktop, w [rest of string was truncated]";. /// internal static string Shiftorium { get { diff --git a/ShiftOS.WinForms/Properties/Resources.resx b/ShiftOS.WinForms/Properties/Resources.resx index 688bcac..a90e69b 100644 --- a/ShiftOS.WinForms/Properties/Resources.resx +++ b/ShiftOS.WinForms/Properties/Resources.resx @@ -122,7 +122,7 @@ AAEAAAD/////AQAAAAAAAAAEAQAAABZTeXN0ZW0uSU8uTWVtb3J5U3RyZWFtCgAAAAdfYnVmZmVyB19v cmlnaW4JX3Bvc2l0aW9uB19sZW5ndGgJX2NhcGFjaXR5C19leHBhbmRhYmxlCV93cml0YWJsZQpfZXhw b3NhYmxlB19pc09wZW4dTWFyc2hhbEJ5UmVmT2JqZWN0K19faWRlbnRpdHkHAAAAAAAAAAACAggICAgB - AQEBCQIAAAAAAAAAAAAAAJKjAACSowAAAAEAAQoPAgAAAJKjAAACUklGRoqjAABXQVZFZm10IBAAAAAB + AQEBCQIAAAAAAAAAkqMAAJKjAACSowAAAAEAAQoPAgAAAJKjAAACUklGRoqjAABXQVZFZm10IBAAAAAB AAEARKwAAIhYAQACABAAZGF0YWajAAABAP7/AgD9/wMA/f8DAPz/BAD8/wQA/f8BAP//AAABAAAA//8C AP3/BAD9/wIAAAD//wIA//8BAAAAAAABAP//AQAAAAEAAAACAP7/AQABAAAAAQAAAAEAAAACAP7/AwD+ /wIAAAD//wIA/v8DAP7/AwD9/wMA//8AAAIA/f8DAAAA//8BAAAA/v8CAP////8CAPz/BAD8/wMA/f8A @@ -838,7 +838,7 @@ AAEAAAD/////AQAAAAAAAAAEAQAAABZTeXN0ZW0uSU8uTWVtb3J5U3RyZWFtCgAAAAdfYnVmZmVyB19v cmlnaW4JX3Bvc2l0aW9uB19sZW5ndGgJX2NhcGFjaXR5C19leHBhbmRhYmxlCV93cml0YWJsZQpfZXhw b3NhYmxlB19pc09wZW4dTWFyc2hhbEJ5UmVmT2JqZWN0K19faWRlbnRpdHkHAAAAAAAAAAACAggICAgB - AQEBCQIAAAAAAAAAAAAAAEwYAABMGAAAAAEAAQoPAgAAAEwYAAACUklGRkQYAABXQVZFZm10IBAAAAAB + AQEBCQIAAAAAAAAATBgAAEwYAABMGAAAAAEAAQoPAgAAAEwYAAACUklGRkQYAABXQVZFZm10IBAAAAAB AAEARKwAAIhYAQACABAAZGF0YSAYAAD/X5Vil2TRZUJmF2ZLZadjS2FqXt9aj1awUVtMc0b4PyQ57DFS KmUiSxoDEo4JEQGO+Bzwweee35zX9c+pyK7BGLsYtZqvlqoipneiW5/YnBCbFZq3mfOZEJvknD6fSqIg poaqcK/rtAq7i8FvyMrPgNdo347n7e9h+N8AXwnPERoaQSIlKrcx+zjmP0lGKUykUYJWs1pKXlJhpWMl @@ -964,7 +964,7 @@ ..\Resources\SweeperNormalFace.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - ..\Resources\strings_en.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252 + ..\Resources\strings_en.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;iso-8859-1 ..\Resources\SweeperTile5.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -974,7 +974,7 @@ AAEAAAD/////AQAAAAAAAAAEAQAAABZTeXN0ZW0uSU8uTWVtb3J5U3RyZWFtCgAAAAdfYnVmZmVyB19v cmlnaW4JX3Bvc2l0aW9uB19sZW5ndGgJX2NhcGFjaXR5C19leHBhbmRhYmxlCV93cml0YWJsZQpfZXhw b3NhYmxlB19pc09wZW4dTWFyc2hhbEJ5UmVmT2JqZWN0K19faWRlbnRpdHkHAAAAAAAAAAACAggICAgB - AQEBCQIAAAAAAAAAAAAAAPwBHgD8AR4AAAEAAQoPAgAAAPwBHgACUklGRvQBHgBXQVZFZm10IBAAAAAB + AQEBCQIAAAAAAAAA/AEeAPwBHgD8AR4AAAEAAQoPAgAAAPwBHgACUklGRvQBHgBXQVZFZm10IBAAAAAB AAIAgLsAAADuAgAEABAATElTVBQAAABJTkZPSUFSVAgAAABQaGlsaXAAAGRhdGG0AR4A//8CAAwA5v8a APT/8P8sAMf/OADX/xoA5v8bAPL/8/8aAOb/DQAOANb/KgDk/w4AAQDh/zwAt/9HAMj/GwACAPH/DgDy /w0AAQDy/xwA1f8sAO//5v84ALn/OQDk//7/AwD+/xAA4v8dANX/LADw//T/GgDl/w4AAADx/x4A4f8R @@ -33831,7 +33831,7 @@ AAEAAAD/////AQAAAAAAAAAEAQAAABZTeXN0ZW0uSU8uTWVtb3J5U3RyZWFtCgAAAAdfYnVmZmVyB19v cmlnaW4JX3Bvc2l0aW9uB19sZW5ndGgJX2NhcGFjaXR5C19leHBhbmRhYmxlCV93cml0YWJsZQpfZXhw b3NhYmxlB19pc09wZW4dTWFyc2hhbEJ5UmVmT2JqZWN0K19faWRlbnRpdHkHAAAAAAAAAAACAggICAgB - AQEBCQIAAAAAAAAAAAAAAPBWAADwVgAAAAEAAQoPAgAAAPBWAAACUklGRuhWAABXQVZFZm10IBAAAAAB + AQEBCQIAAAAAAAAA8FYAAPBWAADwVgAAAAEAAQoPAgAAAPBWAAACUklGRuhWAABXQVZFZm10IBAAAAAB AAEARKwAAIhYAQACABAAZGF0YcRWAAAAAGQL6gtkDL8MEA3kDLUMaAwUDKULKwuYCvcJQAl4CJ0Hrwaw BaAEfgNQAg4Bwf9p/v/8mfsn+rD4OPe59T/0wPJH8dPvYu7+7JzrTeoG6dLnreaX5Z/kruPl4jHinOEk 4cTgh+Bl4GLgguDC4B7hpeFC4g3j7uP35B/mZufO6FXq9eu67ZHviPGT87L15/cr+oL84f5QAcMDPwa9 @@ -34456,7 +34456,7 @@ AAEAAAD/////AQAAAAAAAAAEAQAAABZTeXN0ZW0uSU8uTWVtb3J5U3RyZWFtCgAAAAdfYnVmZmVyB19v cmlnaW4JX3Bvc2l0aW9uB19sZW5ndGgJX2NhcGFjaXR5C19leHBhbmRhYmxlCV93cml0YWJsZQpfZXhw b3NhYmxlB19pc09wZW4dTWFyc2hhbEJ5UmVmT2JqZWN0K19faWRlbnRpdHkHAAAAAAAAAAACAggICAgB - AQEBCQIAAAAAAAAAAAAAAIwWAACMFgAAAAEAAQoPAgAAAIwWAAACUklGRoQWAABXQVZFZm10IBAAAAAB + AQEBCQIAAAAAAAAAjBYAAIwWAACMFgAAAAEAAQoPAgAAAIwWAAACUklGRoQWAABXQVZFZm10IBAAAAAB AAEARKwAAIhYAQACABAAZGF0YWAWAAAAAKYLIxdYIhQtQjexQFBJ81CUVwddTmFLZP9lXmZqZSRjl1/J WtFUu02mRao84jJzKHsdJRKPBub6TO/q4+XYZM6FxG67ObMCrOel8aA9ncuar5nimWybQZ5eoq+nKa6t tTC+hcec0U3cbefr8on+MQq6FfQgxSsFNo8/R0gRUMpWblzSYAFk2WVlZpxlfmMbYHJboVWsTrdG1D0l @@ -34573,4 +34573,31 @@ ..\Resources\SuperDesk screenshot.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\Ambient1.mp3;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ..\Resources\Ambient2.mp3;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ..\Resources\Ambient3.mp3;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ..\Resources\Ambient4.mp3;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ..\Resources\Ambient5.mp3;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ..\Resources\Ambient6.mp3;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ..\Resources\Ambient7.mp3;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ..\Resources\Ambient8.mp3;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ..\Resources\Ambient9.mp3;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/ShiftOS.WinForms/Resources/Ambient1.mp3 b/ShiftOS.WinForms/Resources/Ambient1.mp3 new file mode 100644 index 0000000..d623b29 Binary files /dev/null and b/ShiftOS.WinForms/Resources/Ambient1.mp3 differ diff --git a/ShiftOS.WinForms/Resources/Ambient2.mp3 b/ShiftOS.WinForms/Resources/Ambient2.mp3 new file mode 100644 index 0000000..b16e72f Binary files /dev/null and b/ShiftOS.WinForms/Resources/Ambient2.mp3 differ diff --git a/ShiftOS.WinForms/Resources/Ambient3.mp3 b/ShiftOS.WinForms/Resources/Ambient3.mp3 new file mode 100644 index 0000000..cf06069 Binary files /dev/null and b/ShiftOS.WinForms/Resources/Ambient3.mp3 differ diff --git a/ShiftOS.WinForms/Resources/Ambient4.mp3 b/ShiftOS.WinForms/Resources/Ambient4.mp3 new file mode 100644 index 0000000..7813b4f Binary files /dev/null and b/ShiftOS.WinForms/Resources/Ambient4.mp3 differ diff --git a/ShiftOS.WinForms/Resources/Ambient5.mp3 b/ShiftOS.WinForms/Resources/Ambient5.mp3 new file mode 100644 index 0000000..521330e Binary files /dev/null and b/ShiftOS.WinForms/Resources/Ambient5.mp3 differ diff --git a/ShiftOS.WinForms/Resources/Ambient6.mp3 b/ShiftOS.WinForms/Resources/Ambient6.mp3 new file mode 100644 index 0000000..86cb4a4 Binary files /dev/null and b/ShiftOS.WinForms/Resources/Ambient6.mp3 differ diff --git a/ShiftOS.WinForms/Resources/Ambient7.mp3 b/ShiftOS.WinForms/Resources/Ambient7.mp3 new file mode 100644 index 0000000..9c5047a Binary files /dev/null and b/ShiftOS.WinForms/Resources/Ambient7.mp3 differ diff --git a/ShiftOS.WinForms/Resources/Ambient8.mp3 b/ShiftOS.WinForms/Resources/Ambient8.mp3 new file mode 100644 index 0000000..ac908b6 Binary files /dev/null and b/ShiftOS.WinForms/Resources/Ambient8.mp3 differ diff --git a/ShiftOS.WinForms/Resources/Ambient9.mp3 b/ShiftOS.WinForms/Resources/Ambient9.mp3 new file mode 100644 index 0000000..46cb670 Binary files /dev/null and b/ShiftOS.WinForms/Resources/Ambient9.mp3 differ diff --git a/ShiftOS.WinForms/ShiftOS.WinForms.csproj b/ShiftOS.WinForms/ShiftOS.WinForms.csproj index 411d701..1079203 100644 --- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj +++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj @@ -757,6 +757,15 @@ + + + + + + + + + diff --git a/ShiftOS_TheReturn/AppearanceManager.cs b/ShiftOS_TheReturn/AppearanceManager.cs index 4c1754e..42642f8 100644 --- a/ShiftOS_TheReturn/AppearanceManager.cs +++ b/ShiftOS_TheReturn/AppearanceManager.cs @@ -223,9 +223,9 @@ namespace ShiftOS.Engine /// internal static void Exit() { - OnExit?.Invoke(); //disconnect from MUD ServerManager.Disconnect(); + Environment.Exit(0); } /// diff --git a/ShiftOS_TheReturn/AudioManager.cs b/ShiftOS_TheReturn/AudioManager.cs index a636497..c50bd24 100644 --- a/ShiftOS_TheReturn/AudioManager.cs +++ b/ShiftOS_TheReturn/AudioManager.cs @@ -47,9 +47,12 @@ namespace ShiftOS.Engine /// public static void Stop() { - _out?.Stop(); - _reader?.Dispose(); - _out?.Dispose(); + Desktop.InvokeOnWorkerThread(() => + { + _out?.Stop(); + _reader?.Dispose(); + _out?.Dispose(); + }); } /// diff --git a/ShiftOS_TheReturn/Commands.cs b/ShiftOS_TheReturn/Commands.cs index dc0b3a2..d622bb9 100644 --- a/ShiftOS_TheReturn/Commands.cs +++ b/ShiftOS_TheReturn/Commands.cs @@ -366,7 +366,6 @@ namespace ShiftOS.Engine public static bool Shutdown() { TerminalBackend.InvokeCommand("sos.save"); - SaveSystem.ShuttingDown = true; AppearanceManager.Exit(); return true; } diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index 31db58a..948f95e 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -52,6 +52,9 @@ namespace ShiftOS.Engine public static ClientSave CurrentUser { get; set; } + public static bool Ready = false; + + public static event Action PreDigitalSocietyConnection; public static Save CurrentSave { get; set; } @@ -118,6 +121,18 @@ namespace ShiftOS.Engine Console.WriteLine("[inetd] Connecting to network..."); + Ready = false; + + if (PreDigitalSocietyConnection != null) + { + PreDigitalSocietyConnection?.Invoke(); + + while (!Ready) + { + Thread.Sleep(10); + } + } + if (defaultConf.ConnectToMud == true) { bool guidReceived = false; diff --git a/ShiftOS_TheReturn/TerminalBackend.cs b/ShiftOS_TheReturn/TerminalBackend.cs index 9c57aa8..086ff40 100644 --- a/ShiftOS_TheReturn/TerminalBackend.cs +++ b/ShiftOS_TheReturn/TerminalBackend.cs @@ -213,211 +213,201 @@ namespace ShiftOS.Engine { if (Shiftorium.UpgradeAttributesUnlocked(method)) { - if (CanRunRemotely(method, isRemote)) + foreach (var ma in method.GetCustomAttributes(false)) { - foreach (var ma in method.GetCustomAttributes(false)) + if (ma is Command) { - if (ma is Command) + var cmd = ma as Command; + if (text.Split('.')[1] == cmd.name) { - var cmd = ma as Command; - if (text.Split('.')[1] == cmd.name) + if (KernelWatchdog.IsSafe(method)) { - if (KernelWatchdog.IsSafe(method)) + if (KernelWatchdog.CanRunOffline(method)) { - if (KernelWatchdog.CanRunOffline(method)) - { - var attr = method.GetCustomAttribute(); + var attr = method.GetCustomAttribute(); - if (attr != null) + if (attr != null) + { + string newcommand = attr.newcommand; + if (attr.warn) { - string newcommand = attr.newcommand; - if (attr.warn) - { - Console.WriteLine(Localization.Parse((newcommand == "" ? "{ERROR}" : "{WARN}") + attr.reason, new Dictionary() { + Console.WriteLine(Localization.Parse((newcommand == "" ? "{ERROR}" : "{WARN}") + attr.reason, new Dictionary() { {"%newcommand", newcommand} })); - } - if (newcommand != "") - { - // redo the entire process running newcommand + } + if (newcommand != "") + { + // redo the entire process running newcommand - return RunClient(newcommand, args); - } + return RunClient(newcommand, args); } + } - var requiresArgs = method.GetCustomAttributes(); - bool error = false; - bool providedusage = false; + var requiresArgs = method.GetCustomAttributes(); + bool error = false; + bool providedusage = false; - foreach (RequiresArgument argument in requiresArgs) + foreach (RequiresArgument argument in requiresArgs) + { + if (!args.ContainsKey(argument.argument)) { - if (!args.ContainsKey(argument.argument)) - { - if (!providedusage) - { - string usageparse = "{COMMAND_" + ns.name.ToUpper() + "_" + cmd.name.ToUpper() + "_USAGE}"; - if (usageparse == Localization.Parse(usageparse)) - usageparse = ""; - else - usageparse = Shiftorium.UpgradeInstalled("help_usage") ? Localization.Parse("{ERROR}{USAGE}" + usageparse, new Dictionary() { + if (!providedusage) + { + string usageparse = "{COMMAND_" + ns.name.ToUpper() + "_" + cmd.name.ToUpper() + "_USAGE}"; + if (usageparse == Localization.Parse(usageparse)) + usageparse = ""; + else + usageparse = Shiftorium.UpgradeInstalled("help_usage") ? Localization.Parse("{ERROR}{USAGE}" + usageparse, new Dictionary() { {"%ns", ns.name}, {"%cmd", cmd.name} }) : ""; - Console.WriteLine(usageparse); + Console.WriteLine(usageparse); - providedusage = true; - } - if (Shiftorium.UpgradeInstalled("help_usage")) - { - Console.WriteLine(Localization.Parse("{ERROR_ARGUMENT_REQUIRED}", new Dictionary() { + providedusage = true; + } + if (Shiftorium.UpgradeInstalled("help_usage")) + { + Console.WriteLine(Localization.Parse("{ERROR_ARGUMENT_REQUIRED}", new Dictionary() { {"%argument", argument.argument} })); - } - else - { - Console.WriteLine(Localization.Parse("{ERROR_ARGUMENT_REQUIRED_NO_USAGE}")); - } - - error = true; } - } + else + { + Console.WriteLine(Localization.Parse("{ERROR_ARGUMENT_REQUIRED_NO_USAGE}")); + } - if (error) - { - throw new Exception("{ERROR_COMMAND_WRONG}"); + error = true; } + } - try - { - return (bool)method.Invoke(null, new[] { args }); - } - catch (TargetInvocationException e) - { - Console.WriteLine(Localization.Parse("{ERROR_EXCEPTION_THROWN_IN_METHOD}")); - Console.WriteLine(e.InnerException.Message); - Console.WriteLine(e.InnerException.StackTrace); - return true; - } - catch - { - return (bool)method.Invoke(null, new object[] { }); - } + if (error) + { + throw new Exception("{ERROR_COMMAND_WRONG}"); + } + + try + { + return (bool)method.Invoke(null, new[] { args }); } - else + catch (TargetInvocationException e) { - Console.Write("<"); - ConsoleEx.Bold = true; - ConsoleEx.ForegroundColor = ConsoleColor.DarkRed; - Console.Write("session_mgr"); - ConsoleEx.ForegroundColor = SkinEngine.LoadedSkin.TerminalForeColorCC; - ConsoleEx.Bold = false; - Console.Write(">"); - ConsoleEx.Italic = true; - ConsoleEx.ForegroundColor = ConsoleColor.DarkYellow; - Console.WriteLine(" You cannot run this command while disconnected from the multi-user domain.."); + Console.WriteLine(Localization.Parse("{ERROR_EXCEPTION_THROWN_IN_METHOD}")); + Console.WriteLine(e.InnerException.Message); + Console.WriteLine(e.InnerException.StackTrace); return true; - + } + catch + { + return (bool)method.Invoke(null, new object[] { }); } } else { - if (SaveSystem.CurrentUser.Permissions == Objects.UserPermissions.Admin) - { - Infobox.PromptText("Elevate to root mode", "This command cannot be run as a regular user. To run this command, please enter your password to elevate to root mode temporarily.", (pass) => - { - if (pass == SaveSystem.CurrentUser.Password) - { - KernelWatchdog.EnterKernelMode(); - RunClient(text, args, isRemote); - KernelWatchdog.LeaveKernelMode(); - } - else - { - Infobox.Show("Access denied.", "You did not type in the correct password."); - } - }, true); - return true; - } Console.Write("<"); ConsoleEx.Bold = true; ConsoleEx.ForegroundColor = ConsoleColor.DarkRed; - Console.Write("watchdog"); + Console.Write("session_mgr"); ConsoleEx.ForegroundColor = SkinEngine.LoadedSkin.TerminalForeColorCC; ConsoleEx.Bold = false; Console.Write(">"); ConsoleEx.Italic = true; ConsoleEx.ForegroundColor = ConsoleColor.DarkYellow; - Console.WriteLine(" You cannot run this command. You do not have permission. Incident reported."); - KernelWatchdog.Log("potential_sys_breach", "user attempted to run kernel mode command " + text + " - watchdog has prevented this, good sir."); + Console.WriteLine(" You cannot run this command while disconnected from the multi-user domain.."); + return true; + + } + } + else + { + if (SaveSystem.CurrentUser.Permissions == Objects.UserPermissions.Admin) + { + Infobox.PromptText("Elevate to root mode", "This command cannot be run as a regular user. To run this command, please enter your password to elevate to root mode temporarily.", (pass) => + { + if (pass == SaveSystem.CurrentUser.Password) + { + KernelWatchdog.EnterKernelMode(); + RunClient(text, args, isRemote); + KernelWatchdog.LeaveKernelMode(); + } + else + { + Infobox.Show("Access denied.", "You did not type in the correct password."); + } + }, true); return true; } + Console.Write("<"); + ConsoleEx.Bold = true; + ConsoleEx.ForegroundColor = ConsoleColor.DarkRed; + Console.Write("watchdog"); + ConsoleEx.ForegroundColor = SkinEngine.LoadedSkin.TerminalForeColorCC; + ConsoleEx.Bold = false; + Console.Write(">"); + ConsoleEx.Italic = true; + ConsoleEx.ForegroundColor = ConsoleColor.DarkYellow; + Console.WriteLine(" You cannot run this command. You do not have permission. Incident reported."); + KernelWatchdog.Log("potential_sys_breach", "user attempted to run kernel mode command " + text + " - watchdog has prevented this, good sir."); + return true; } } + } - } } } + else { - Console.WriteLine(text + " cannot be ran in a remote session"); + Console.Write("<"); + ConsoleEx.Bold = true; + ConsoleEx.ForegroundColor = ConsoleColor.DarkRed; + Console.Write("session_mgr"); + ConsoleEx.ForegroundColor = SkinEngine.LoadedSkin.TerminalForeColorCC; + ConsoleEx.Bold = false; + Console.Write(">"); + ConsoleEx.Italic = true; + ConsoleEx.ForegroundColor = ConsoleColor.DarkYellow; + Console.WriteLine(" You cannot run this command while disconnected from the multi-user domain.."); return true; - } - } - - } + } + } + } else { + if (SaveSystem.CurrentUser.Permissions == Objects.UserPermissions.Admin) + { + Infobox.PromptText("Elevate to root mode", "This command cannot be run as a regular user. To run this command, please enter your password to elevate to root mode temporarily.", (pass) => + { + if (pass == SaveSystem.CurrentUser.Password) + { + KernelWatchdog.EnterKernelMode(); + RunClient(text, args, isRemote); + KernelWatchdog.LeaveKernelMode(); + } + else + { + Infobox.Show("Access denied.", "You did not type in the correct password."); + } + }, true); + return true; + } Console.Write("<"); ConsoleEx.Bold = true; ConsoleEx.ForegroundColor = ConsoleColor.DarkRed; - Console.Write("session_mgr"); + Console.Write("watchdog"); ConsoleEx.ForegroundColor = SkinEngine.LoadedSkin.TerminalForeColorCC; ConsoleEx.Bold = false; Console.Write(">"); ConsoleEx.Italic = true; ConsoleEx.ForegroundColor = ConsoleColor.DarkYellow; - Console.WriteLine(" You cannot run this command while disconnected from the multi-user domain.."); + Console.WriteLine(" You cannot run this command. You do not have permission. Incident reported."); + KernelWatchdog.Log("potential_sys_breach", "user attempted to run kernel mode command " + text + " - watchdog has prevented this, good sir."); return true; - } - - } - else - { - if (SaveSystem.CurrentUser.Permissions == Objects.UserPermissions.Admin) - { - Infobox.PromptText("Elevate to root mode", "This command cannot be run as a regular user. To run this command, please enter your password to elevate to root mode temporarily.", (pass) => - { - if (pass == SaveSystem.CurrentUser.Password) - { - KernelWatchdog.EnterKernelMode(); - RunClient(text, args, isRemote); - KernelWatchdog.LeaveKernelMode(); - } - else - { - Infobox.Show("Access denied.", "You did not type in the correct password."); - } - }, true); - return true; - } - Console.Write("<"); - ConsoleEx.Bold = true; - ConsoleEx.ForegroundColor = ConsoleColor.DarkRed; - Console.Write("watchdog"); - ConsoleEx.ForegroundColor = SkinEngine.LoadedSkin.TerminalForeColorCC; - ConsoleEx.Bold = false; - Console.Write(">"); - ConsoleEx.Italic = true; - ConsoleEx.ForegroundColor = ConsoleColor.DarkYellow; - Console.WriteLine(" You cannot run this command. You do not have permission. Incident reported."); - KernelWatchdog.Log("potential_sys_breach", "user attempted to run kernel mode command " + text + " - watchdog has prevented this, good sir."); - return true; } } } @@ -429,6 +419,7 @@ namespace ShiftOS.Engine } return false; } + public static void PrintPrompt() { if (SaveSystem.CurrentSave != null && CurrentUser != null) -- cgit v1.2.3 From c18c0fbc325b1c6a0864f88c6e2f4d2889d62e18 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 12 May 2017 20:32:28 -0400 Subject: dithering revamp --- ShiftOS.WinForms/Applications/Shifter.cs | 5 +- ShiftOS.WinForms/Program.cs | 1 + ShiftOS.WinForms/Tools/DitheringEngine.cs | 195 +++++++++++++----------------- ShiftOS.WinForms/WinformsDesktop.cs | 5 +- ShiftOS_TheReturn/Commands.cs | 17 +++ ShiftOS_TheReturn/Skinning.cs | 19 +++ 6 files changed, 123 insertions(+), 119 deletions(-) (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.WinForms/Applications/Shifter.cs b/ShiftOS.WinForms/Applications/Shifter.cs index 05ba638..edc3703 100644 --- a/ShiftOS.WinForms/Applications/Shifter.cs +++ b/ShiftOS.WinForms/Applications/Shifter.cs @@ -139,10 +139,7 @@ namespace ShiftOS.WinForms.Applications pnldesktoppreview.BackColor = Color.FromArgb(LoadedSkin.DesktopColor.R, LoadedSkin.DesktopColor.G, LoadedSkin.DesktopColor.B); //Not doing this will cause an ArgumentException. - DitheringEngine.DitherImage(SkinEngine.GetImage("desktopbackground"), new Action((img) => - { - pnldesktoppreview.BackgroundImage = img; - })); + pnldesktoppreview.BackgroundImage = SkinEngine.GetImage("desktopbackground"); pnldesktoppreview.BackgroundImageLayout = GetImageLayout("desktopbackground"); desktoppanel.BackColor = LoadedSkin.DesktopPanelColor; diff --git a/ShiftOS.WinForms/Program.cs b/ShiftOS.WinForms/Program.cs index 256894d..73215d4 100644 --- a/ShiftOS.WinForms/Program.cs +++ b/ShiftOS.WinForms/Program.cs @@ -49,6 +49,7 @@ namespace ShiftOS.WinForms Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //if ANYONE puts code before those two winforms config lines they will be declared a drunky. - Michael + SkinEngine.SetPostProcessor(new DitheringSkinPostProcessor()); SaveSystem.PreDigitalSocietyConnection += () => { Action completed = null; diff --git a/ShiftOS.WinForms/Tools/DitheringEngine.cs b/ShiftOS.WinForms/Tools/DitheringEngine.cs index 8509a0b..f96a45a 100644 --- a/ShiftOS.WinForms/Tools/DitheringEngine.cs +++ b/ShiftOS.WinForms/Tools/DitheringEngine.cs @@ -33,6 +33,7 @@ using System.Drawing; using System.Threading; using ShiftOS.Engine; using System.Runtime.InteropServices; +using System.IO; namespace ShiftOS.WinForms.Tools { @@ -101,7 +102,7 @@ namespace ShiftOS.WinForms.Tools } } - public static void DitherColor(Color source, int width, int height, Action result) + public static Image DitherColor(Color source, int width, int height) { var bmp = new Bitmap(width + 1, height + 1); var data = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.ReadWrite, System.Drawing.Imaging.PixelFormat.Format24bppRgb); @@ -115,7 +116,7 @@ namespace ShiftOS.WinForms.Tools } Marshal.Copy(rgb, 0, data.Scan0, rgb.Length); bmp.UnlockBits(data); - DitherImage(bmp, result); + return DitherImage(bmp); } @@ -226,15 +227,8 @@ namespace ShiftOS.WinForms.Tools #endif #if FLOYDSTEINBERG - public static void DitherImage(Image source, Action result) + public static Image DitherImage(Image source) { - if (source == null) - { - result?.Invoke(source); - return; - } - - var bmp = new Bitmap(source.Width, source.Height); var sourceBmp = (Bitmap)source; var sourceLck = sourceBmp.LockBits(new Rectangle(0, 0, sourceBmp.Width, sourceBmp.Height), System.Drawing.Imaging.ImageLockMode.ReadWrite, System.Drawing.Imaging.PixelFormat.Format24bppRgb); @@ -267,121 +261,80 @@ namespace ShiftOS.WinForms.Tools bool color_depth_floydsteinberg = Shiftorium.UpgradeInstalled("color_depth_floyd-steinberg_dithering"); bool dithering = Shiftorium.UpgradeInstalled("color_depth_dithering"); - for (int y = 0; y < (destLck.Height); y++) + if (!sixteenBits) { - for (int x = 0; x < (Math.Abs(destLck.Stride)); x += 3) + if (dithering == true) { - int i = getIndexFromXY(x, y, width); - byte red = sourceArr[i]; - byte green = sourceArr[i + 1]; - byte blue = sourceArr[i + 2]; - - Color oldc = Color.FromArgb(red, green, blue); - Color newc; - - if (sixteenBits) + if (false == true) { - newc = GetColor(oldc); + } else { - int gray = ((oldc.R + oldc.G + oldc.B) / 3); - - byte newgray = 0; - - if (dithering && !color_depth_floydsteinberg) - gray += error_r; - - - - if (eightBits) + int error = 0; + for (int i = 0; i < destArr.Length; i += 3) { - newgray = (byte)gray; - error_r = 0; - } - else if(sixBits) - { - newgray = (byte)(linear(gray, 0, 0xFF, 0, 0x3F) * 3); - error_r = newgray - gray; - } - else if (fourBits) - { - newgray = (byte)(linear(gray, 0, 0xFF, 0, 0xF) * 0xF); - error_r = newgray - gray; - } - else if (twoBits) - { - if (gray >= 191) - newgray = 0xFF; - else if (gray >= 127) - newgray = Color.LightGray.R; - else if (gray >= 64) - newgray = Color.DarkGray.R; - else - newgray = 0x00; - error_r = newgray - gray; - } - else - { - if (gray >= 127) - newgray = 0xFF; - else - newgray = 0x00; - error_r = newgray - gray; - } - newc = Color.FromArgb(newgray, newgray, newgray); - } + byte r = sourceArr[i]; + byte g = sourceArr[i + 1]; + byte b = sourceArr[i + 2]; - int nextIndex = getIndexFromXY(x + 3, y, width); - int nextRow = getIndexFromXY(x, y + 1, width); - int nextIndexOnNextRow = getIndexFromXY(x + 3, y + 1, width); - int prevIndexOnNextRow = getIndexFromXY(x - 3, y + 1, width); - - grays[i] = newc.R; - grays[i + 1] = newc.G; - grays[i + 2] = newc.B; - - if (dithering) - { - if (color_depth_floydsteinberg) - { - if (x + 3 < width) + int gray = (((r + g + b) / 3) + error); + int newgray = gray; + if (!eightBits) { - sourceArr[nextIndex] += (byte)((error_r * 7) / 16); - sourceArr[nextIndex + 1] += (byte)((error_r * 7) / 16); - sourceArr[nextIndex + 2] += (byte)((error_r * 7) / 16); - } - if (y + 1 < height) - { - sourceArr[nextRow] += (byte)((error_r) / 16); - sourceArr[nextRow + 1] += (byte)((error_r) / 16); - sourceArr[nextRow + 2] += (byte)((error_r) / 16); - } - if (x + 3 < width && y + 1 < height) - { - sourceArr[nextIndexOnNextRow] += (byte)((error_r * 3) / 16); - sourceArr[nextIndexOnNextRow + 1] += (byte)((error_r * 3) / 16); - sourceArr[nextIndexOnNextRow + 2] += (byte)((error_r * 3) / 16); - + if (sixBits) + { + newgray = gray >> 2; + } + else + { + if (fourBits) + { + newgray = (int)linear(gray, 0, 255, 0, 63) * 4; + } + else + { + if (twoBits) + { + if (gray > 127 + 63) + { + newgray = 255; + } + else if (gray > 127) + newgray = 127 + 63; + else if (gray > 63) + { + newgray = 127; + } + else if (gray > 0) + newgray = 63; + else + newgray = 0; + } + else + { + if (gray > 127) + newgray = 255; + else + newgray = 0; + } + } + } } - if (x - 3 > 0 && y + 1 < height) - { - sourceArr[prevIndexOnNextRow] += (byte)((error_r * 5) / 16); - sourceArr[prevIndexOnNextRow + 1] += (byte)((error_r * 5) / 16); - sourceArr[prevIndexOnNextRow + 2] += (byte)((error_r * 5) / 16); + if (newgray > 255) + newgray = 255; + if (newgray < 0) + newgray = 0; + error = gray - newgray; + destArr[i] = (byte)newgray; + destArr[i+1] = (byte)newgray; + destArr[i+2] = (byte)newgray; - } } } } } - for (int i = 0; i < destArr.Length - 3; i++) - { - destArr[i] = grays[i]; - - } - Marshal.Copy(destArr, 0, destPtr, destBytes); @@ -389,8 +342,7 @@ namespace ShiftOS.WinForms.Tools - Desktop.InvokeOnWorkerThread(new Action(() => { result?.Invoke(bmp); })); - + return bmp; } #endif @@ -399,4 +351,25 @@ namespace ShiftOS.WinForms.Tools return (width * y) + x; } } + + public class DitheringSkinPostProcessor : ISkinPostProcessor + { + public byte[] ProcessImage(byte[] original) + { + try + { + var img = SkinEngine.ImageFromBinary(original); + var dithered = DitheringEngine.DitherImage(img); + using (var mstr = new MemoryStream()) + { + dithered.Save(mstr, System.Drawing.Imaging.ImageFormat.Bmp); + return mstr.ToArray(); + } + } + catch + { + return original; + } + } + } } diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs index 6825f34..4efef1b 100644 --- a/ShiftOS.WinForms/WinformsDesktop.cs +++ b/ShiftOS.WinForms/WinformsDesktop.cs @@ -390,10 +390,7 @@ namespace ShiftOS.WinForms this.BackColor = Color.FromArgb(LoadedSkin.DesktopColor.R, LoadedSkin.DesktopColor.G, LoadedSkin.DesktopColor.B); //Not doing this will cause an ArgumentException. - DitheringEngine.DitherImage(SkinEngine.GetImage("desktopbackground"), new Action((img) => - { - this.BackgroundImage = img; - })); + this.BackgroundImage = SkinEngine.GetImage("desktopbackground"); this.BackgroundImageLayout = GetImageLayout("desktopbackground"); desktoppanel.BackColor = LoadedSkin.DesktopPanelColor; diff --git a/ShiftOS_TheReturn/Commands.cs b/ShiftOS_TheReturn/Commands.cs index d622bb9..5b7674a 100644 --- a/ShiftOS_TheReturn/Commands.cs +++ b/ShiftOS_TheReturn/Commands.cs @@ -233,6 +233,23 @@ namespace ShiftOS.Engine [Namespace("dev")] public static class ShiftOSDevCommands { + [Command("buy")] + public static bool UnlockUpgrade(Dictionary args) + { + string upg = args["id"].ToString(); + try + { + SaveSystem.CurrentSave.Upgrades[upg] = true; + Shiftorium.InvokeUpgradeInstalled(); + SaveSystem.SaveGame(); + } + catch + { + Console.WriteLine("Upgrade not found."); + } + return true; + } + [Command("rock", description = "A little surprise for unstable builds...")] public static bool ThrowASandwichingRock() { diff --git a/ShiftOS_TheReturn/Skinning.cs b/ShiftOS_TheReturn/Skinning.cs index b731c4f..548e80f 100644 --- a/ShiftOS_TheReturn/Skinning.cs +++ b/ShiftOS_TheReturn/Skinning.cs @@ -66,6 +66,13 @@ namespace ShiftOS.Engine public static class SkinEngine { + private static ISkinPostProcessor processor = null; + + public static void SetPostProcessor(ISkinPostProcessor _processor) + { + processor = _processor; + } + public static ImageLayout GetImageLayout(string img) { if (LoadedSkin.SkinImageLayouts.ContainsKey(img)) @@ -93,6 +100,8 @@ namespace ShiftOS.Engine if (iattr.Name == img) { byte[] image = (byte[])field.GetValue(LoadedSkin); + if (processor != null) + image = processor.ProcessImage(image); return ImageFromBinary(image); } } @@ -1323,6 +1332,16 @@ namespace ShiftOS.Engine public string Category { get; set; } } + public interface ISkinPostProcessor + { + /// + /// Perform algorithmic operations at the bit level on a ShiftOS skin image. + /// + /// The image, as loaded by the engine, as a 32-bit ARGB byte array. + /// The processed image. + byte[] ProcessImage(byte[] original); + } + public class ShifterMetaAttribute : Attribute { -- cgit v1.2.3 From 94e1603b8574b45b809d3c66b6b90e7734a99d1e Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 12 May 2017 21:22:08 -0400 Subject: Post-intro tutorial --- ShiftOS.WinForms/Applications/Terminal.cs | 130 +++++++++++++++++++++++++++--- ShiftOS.WinForms/Controls/TerminalBox.cs | 4 + ShiftOS_TheReturn/TerminalBackend.cs | 61 +++++++------- 3 files changed, 156 insertions(+), 39 deletions(-) (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.WinForms/Applications/Terminal.cs b/ShiftOS.WinForms/Applications/Terminal.cs index 32c5363..a14cc58 100644 --- a/ShiftOS.WinForms/Applications/Terminal.cs +++ b/ShiftOS.WinForms/Applications/Terminal.cs @@ -132,23 +132,31 @@ namespace ShiftOS.WinForms.Applications { ResetAllKeywords(); rtbterm.Text = ""; - if (!Shiftorium.UpgradeInstalled("desktop")) + if (Shiftorium.UpgradeInstalled("first_steps")) { - TerminalBackend.PrefixEnabled = true; - TerminalBackend.InStory = false; - TerminalBackend.PrintPrompt(); - if (Shiftorium.UpgradeInstalled("wm_free_placement")) + if (!Shiftorium.UpgradeInstalled("desktop")) { - this.ParentForm.Width = 640; - this.ParentForm.Height = 480; - this.ParentForm.Left = (Screen.PrimaryScreen.Bounds.Width - 640) / 2; - this.ParentForm.Top = (Screen.PrimaryScreen.Bounds.Height - 480) / 2; + TerminalBackend.PrefixEnabled = true; + TerminalBackend.InStory = false; + TerminalBackend.PrintPrompt(); + if (Shiftorium.UpgradeInstalled("wm_free_placement")) + { + this.ParentForm.Width = 640; + this.ParentForm.Height = 480; + this.ParentForm.Left = (Screen.PrimaryScreen.Bounds.Width - 640) / 2; + this.ParentForm.Top = (Screen.PrimaryScreen.Bounds.Height - 480) / 2; + } + } + else + { + AppearanceManager.Close(this); } } else { - AppearanceManager.Close(this); + Story.Start("first_steps"); + } })); } @@ -434,6 +442,108 @@ namespace ShiftOS.WinForms.Applications }).Start(); } + [Story("first_steps")] + public static void FirstSteps() + { + new Thread(() => + { + TerminalBackend.InStory = true; + Console.WriteLine("Hey there, and welcome to ShiftOS."); + Thread.Sleep(2000); + Console.WriteLine("My name is DevX. I am the developer of this operating system."); + Thread.Sleep(2000); + Console.WriteLine("Right now, I am using the Terminal application as a means of talking to you."); + Thread.Sleep(2000); + Console.WriteLine("ShiftOS is a very early operating system, but I have big plans for it."); + Thread.Sleep(2000); + Console.WriteLine("I can't reveal all my plans to you at this moment, but you play a big role."); + Thread.Sleep(2000); + Console.WriteLine("Your role in all of this is to help me develop ShiftOS more."); + Thread.Sleep(2000); + Console.WriteLine("You may not know how to program, but that's perfectly fine. You don't need to."); + Thread.Sleep(2000); + Console.WriteLine("What you do need to do, is simply use the operating system - like you would a regular computer."); + Thread.Sleep(2000); + Console.WriteLine("As you use ShiftOS, you will earn a special currency called Codepoints."); + Thread.Sleep(2000); + Console.WriteLine("The more things you do, the more Codepoints you get! Simple, right?"); + Thread.Sleep(2000); + Console.WriteLine("Once you rack up enough Codepoints, you can use them inside the Shiftorium to buy new features for ShiftOS."); + Thread.Sleep(2000); + Console.WriteLine("These features include new programs, system enhancements, Terminal commands, and so much more!"); + Thread.Sleep(2000); + Console.WriteLine("Ahh, that reminds me. I suppose you don't know how to use the Terminal yet, do you..."); + Thread.Sleep(2000); + Console.WriteLine("Well, the ShiftOS terminal is similar to a regular Linux terminal, however things are a bit... how you say.... primitive."); + Thread.Sleep(2000); + Console.WriteLine("Let's just say.... I've been focusing more on function than form with this one.... Anyways, here's how the terminal works."); + Thread.Sleep(2000); + Console.WriteLine("Each command is categorized into a \"Namespace\". All a namespace is, is a nice way of distinguishing between commands."); + Thread.Sleep(2000); + Console.WriteLine("...For example you may have a bunch of commands for managing files, and others for opening/closing programs."); + Thread.Sleep(2000); + Console.WriteLine("The three main namespaces you'll be using for the next while are the \"sos\", \"shiftorium\", and \"win\" namespaces."); + Thread.Sleep(2000); + Console.WriteLine("To run a command, simply type its namespace, followed by a period/full-stop, followed by the command name."); + Thread.Sleep(2000); + Console.WriteLine("Give it a try! Type \"sos.help\" in the following prompt to view a list of all ShiftOS commands."); + Thread.Sleep(2000); + TerminalBackend.InStory = false; + TerminalBackend.PrintPrompt(); + bool help_entered = false; + TerminalBackend.TextSent += (text) => + { + if (text == "sos.help" && help_entered == false) + help_entered = true; + }; + while (help_entered == false) + Thread.Sleep(10); + TerminalBackend.InStory = true; + Thread.Sleep(2000); + Console.WriteLine("Good job! Next, we will look at how to pass data to a command, such as win.open."); + Thread.Sleep(2000); + Console.WriteLine("In ShiftOS, passing data to a command is quite simple! After the command name, place an opening and closing curly brace, like so: \"win.open{}\"."); + Thread.Sleep(2000); + Console.WriteLine("Everything between those two curly braces is treated as command data."); + Thread.Sleep(2000); + Console.WriteLine("However, you can't just spam a bunch of 1s and 0s and call it a day, nonono!"); + Thread.Sleep(2000); + Console.WriteLine("Command data is split into a list of keys and values."); + Thread.Sleep(2000); + Console.WriteLine("The key tells the command the name of the data, and the value is what the command will see when it looks at the key."); + Thread.Sleep(2000); + Console.WriteLine("There are three main types of values. Booleans, which can be either \"true\" or \"false\", Numbers, which can be any integer number, positive or negative, and Strings - any piece of text as long as it is surrounded by double-quotes."); + Thread.Sleep(2000); + Console.WriteLine("For example, we could write every programmer's first program - by typing \"trm.echo{msg:\"Hello, world!\"}\". Running this will cause the Terminal to print, well, \"Hello, world!\""); + Thread.Sleep(2000); + Console.WriteLine("To open an application in ShiftOS, you can use this principle with the \"win.open\" command."); + Thread.Sleep(2000); + Console.WriteLine("First, type \"win.open\" with no data to see a list of all installed programs."); + Thread.Sleep(2000); + TerminalBackend.InStory = false; + bool winopenEntered = false; + TerminalBackend.PrintPrompt(); + TerminalBackend.TextSent += (text) => + { + if (help_entered == true) + if (text == "win.open" && winopenEntered == false) + winopenEntered = true; + }; + while (winopenEntered == false) + Thread.Sleep(10); + TerminalBackend.InStory = true; + Thread.Sleep(2000); + Console.WriteLine("Pretty cool, it gave you a nice list of other win.open commands that will let you open each program."); + Thread.Sleep(2000); + Console.WriteLine("I'll leave you to it, you've got the hang of it! One last thing, if ever you find yourself in another program, and want to exit, simply press CTRL+T to return to the Terminal."); + Thread.Sleep(2000); + + TerminalBackend.InStory = false; + TerminalBackend.PrintPrompt(); + SaveSystem.SaveGame(); + }).Start(); + } + public void OnSkinLoad() { try diff --git a/ShiftOS.WinForms/Controls/TerminalBox.cs b/ShiftOS.WinForms/Controls/TerminalBox.cs index ea7808c..e95d038 100644 --- a/ShiftOS.WinForms/Controls/TerminalBox.cs +++ b/ShiftOS.WinForms/Controls/TerminalBox.cs @@ -63,12 +63,14 @@ namespace ShiftOS.WinForms.Controls public void Write(string text) { + this.SuspendLayout(); this.HideSelection = true; this.SelectionFont = ConstructFont(); this.SelectionColor = ControlManager.ConvertColor(ConsoleEx.ForegroundColor); this.SelectionBackColor = ControlManager.ConvertColor(ConsoleEx.BackgroundColor); this.AppendText(Localization.Parse(text)); this.HideSelection = false; + this.ResumeLayout(); } private Font ConstructFont() @@ -86,6 +88,7 @@ namespace ShiftOS.WinForms.Controls public void WriteLine(string text) { + this.SuspendLayout(); Engine.AudioManager.PlayStream(Properties.Resources.writesound); this.HideSelection = true; this.Select(this.TextLength, 0); @@ -94,6 +97,7 @@ namespace ShiftOS.WinForms.Controls this.SelectionBackColor = ControlManager.ConvertColor(ConsoleEx.BackgroundColor); this.AppendText(Localization.Parse(text) + Environment.NewLine); this.HideSelection = false; + this.ResumeLayout(); } bool quickCopying = false; diff --git a/ShiftOS_TheReturn/TerminalBackend.cs b/ShiftOS_TheReturn/TerminalBackend.cs index 086ff40..87bd24a 100644 --- a/ShiftOS_TheReturn/TerminalBackend.cs +++ b/ShiftOS_TheReturn/TerminalBackend.cs @@ -424,35 +424,38 @@ namespace ShiftOS.Engine { if (SaveSystem.CurrentSave != null && CurrentUser != null) { - ConsoleEx.BackgroundColor = SkinEngine.LoadedSkin.TerminalBackColorCC; - ConsoleEx.Italic = false; - ConsoleEx.Underline = false; - - ConsoleEx.ForegroundColor = ConsoleColor.Magenta; - ConsoleEx.Bold = true; - - Console.Write(SaveSystem.CurrentUser.Username); - ConsoleEx.Bold = false; - ConsoleEx.ForegroundColor = ConsoleColor.Gray; - Console.Write("@"); - ConsoleEx.Italic = true; - ConsoleEx.Bold = true; - ConsoleEx.ForegroundColor = ConsoleColor.Yellow; - Console.Write(SaveSystem.CurrentSave.SystemName); - ConsoleEx.Italic = false; - ConsoleEx.Bold = false; - ConsoleEx.ForegroundColor = ConsoleColor.Gray; - Console.Write(":~"); - Console.ForegroundColor = ConsoleColor.White; - ConsoleEx.Italic = true; - if (KernelWatchdog.InKernelMode == true) - Console.Write("#"); - else - Console.Write("$"); - ConsoleEx.Italic = false; - ConsoleEx.Bold = false; - ConsoleEx.ForegroundColor = SkinEngine.LoadedSkin.TerminalForeColorCC; - Console.Write(" "); + Desktop.InvokeOnWorkerThread(() => + { + ConsoleEx.BackgroundColor = SkinEngine.LoadedSkin.TerminalBackColorCC; + ConsoleEx.Italic = false; + ConsoleEx.Underline = false; + + ConsoleEx.ForegroundColor = ConsoleColor.Magenta; + ConsoleEx.Bold = true; + + Console.Write(SaveSystem.CurrentUser.Username); + ConsoleEx.Bold = false; + ConsoleEx.ForegroundColor = ConsoleColor.Gray; + Console.Write("@"); + ConsoleEx.Italic = true; + ConsoleEx.Bold = true; + ConsoleEx.ForegroundColor = ConsoleColor.Yellow; + Console.Write(SaveSystem.CurrentSave.SystemName); + ConsoleEx.Italic = false; + ConsoleEx.Bold = false; + ConsoleEx.ForegroundColor = ConsoleColor.Gray; + Console.Write(":~"); + Console.ForegroundColor = ConsoleColor.White; + ConsoleEx.Italic = true; + if (KernelWatchdog.InKernelMode == true) + Console.Write("#"); + else + Console.Write("$"); + ConsoleEx.Italic = false; + ConsoleEx.Bold = false; + ConsoleEx.ForegroundColor = SkinEngine.LoadedSkin.TerminalForeColorCC; + Console.Write(" "); + }); } } -- cgit v1.2.3 From c0f0e99f9d2a092209e710107c1f061fc8a2eaca Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 13 May 2017 10:22:51 -0400 Subject: Dithering, audio volume, and fix shutdown bug --- ShiftOS.Objects/Save.cs | 3 + ShiftOS.WinForms/Applications/Terminal.cs | 8 +- ShiftOS.WinForms/AudioManager.cs | 27 +++-- ShiftOS.WinForms/Program.cs | 6 +- ShiftOS.WinForms/Tools/DitheringEngine.cs | 160 ++++++++++++++++++++---------- ShiftOS_TheReturn/AppearanceManager.cs | 1 + ShiftOS_TheReturn/AudioManager.cs | 8 +- ShiftOS_TheReturn/Commands.cs | 34 +++++++ 8 files changed, 175 insertions(+), 72 deletions(-) (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.Objects/Save.cs b/ShiftOS.Objects/Save.cs index 2a02bbc..cc19c79 100644 --- a/ShiftOS.Objects/Save.cs +++ b/ShiftOS.Objects/Save.cs @@ -35,6 +35,9 @@ namespace ShiftOS.Objects public class Save { + public int MusicVolume { get; set; } + public int SfxVolume { get; set; } + [Obsolete("This save variable is no longer used in Beta 2.4 and above of ShiftOS. Please use ShiftOS.Engine.SaveSystem.CurrentUser.Username to access the current user's username.")] public string Username { get; set; } diff --git a/ShiftOS.WinForms/Applications/Terminal.cs b/ShiftOS.WinForms/Applications/Terminal.cs index a14cc58..02c4cc0 100644 --- a/ShiftOS.WinForms/Applications/Terminal.cs +++ b/ShiftOS.WinForms/Applications/Terminal.cs @@ -491,9 +491,9 @@ namespace ShiftOS.WinForms.Applications TerminalBackend.InStory = false; TerminalBackend.PrintPrompt(); bool help_entered = false; - TerminalBackend.TextSent += (text) => + TerminalBackend.CommandProcessed += (text, args) => { - if (text == "sos.help" && help_entered == false) + if (text.EndsWith("sos.help") && help_entered == false) help_entered = true; }; while (help_entered == false) @@ -523,10 +523,10 @@ namespace ShiftOS.WinForms.Applications TerminalBackend.InStory = false; bool winopenEntered = false; TerminalBackend.PrintPrompt(); - TerminalBackend.TextSent += (text) => + TerminalBackend.CommandProcessed += (text, args) => { if (help_entered == true) - if (text == "win.open" && winopenEntered == false) + if (text.EndsWith("win.open") && winopenEntered == false) winopenEntered = true; }; while (winopenEntered == false) diff --git a/ShiftOS.WinForms/AudioManager.cs b/ShiftOS.WinForms/AudioManager.cs index eb0e798..ec12614 100644 --- a/ShiftOS.WinForms/AudioManager.cs +++ b/ShiftOS.WinForms/AudioManager.cs @@ -74,7 +74,19 @@ namespace ShiftOS.WinForms MemoryStream str = null; NAudio.Wave.Mp3FileReader mp3 = null; NAudio.Wave.WaveOut o = null; - while (!Engine.SaveSystem.ShuttingDown) + bool shuttingDown = false; + + Engine.AppearanceManager.OnExit += () => + { + shuttingDown = true; + o?.Stop(); + o?.Dispose(); + mp3?.Close(); + mp3?.Dispose(); + str?.Close(); + str?.Dispose(); + }; + while (shuttingDown == false) { str = new MemoryStream(GetRandomSong()); mp3 = new NAudio.Wave.Mp3FileReader(str); @@ -87,14 +99,15 @@ namespace ShiftOS.WinForms c = true; }; while (!c) + { + try + { + o.Volume = (float)Engine.SaveSystem.CurrentSave.MusicVolume / 100; + } + catch { } Thread.Sleep(10); - str.Dispose(); - o.Dispose(); - mp3.Dispose(); + } } - str?.Dispose(); - o?.Dispose(); - mp3?.Dispose(); }); athread.IsBackground = true; athread.Start(); diff --git a/ShiftOS.WinForms/Program.cs b/ShiftOS.WinForms/Program.cs index 73215d4..8f65265 100644 --- a/ShiftOS.WinForms/Program.cs +++ b/ShiftOS.WinForms/Program.cs @@ -68,11 +68,7 @@ namespace ShiftOS.WinForms SkinEngine.SetIconProber(new ShiftOSIconProvider()); ShiftOS.Engine.AudioManager.Init(new ShiftOSAudioProvider()); Localization.RegisterProvider(new WFLanguageProvider()); - AppearanceManager.OnExit += () => - { - Environment.Exit(0); - }; - + TutorialManager.RegisterTutorial(new Oobe()); TerminalBackend.TerminalRequested += () => diff --git a/ShiftOS.WinForms/Tools/DitheringEngine.cs b/ShiftOS.WinForms/Tools/DitheringEngine.cs index f96a45a..d042a40 100644 --- a/ShiftOS.WinForms/Tools/DitheringEngine.cs +++ b/ShiftOS.WinForms/Tools/DitheringEngine.cs @@ -226,6 +226,53 @@ namespace ShiftOS.WinForms.Tools } #endif + public static int GetClosestColor(int gray, bool eightBits, bool sixBits, bool fourBits, bool twoBits) + { + int newgray = gray; + if (!eightBits) + { + if (sixBits) + { + newgray = gray >> 2; + } + else + { + if (fourBits) + { + newgray = (int)linear(gray, 0, 255, 0, 15) * 4; + } + else + { + if (twoBits) + { + if (gray > 127 + 63) + { + newgray = 255; + } + else if (gray > 127) + newgray = 127 + 63; + else if (gray > 63) + { + newgray = 127; + } + else if (gray > 0) + newgray = 63; + else + newgray = 0; + } + else + { + if (gray > 127) + newgray = 255; + else + newgray = 0; + } + } + } + } + return newgray; + } + #if FLOYDSTEINBERG public static Image DitherImage(Image source) { @@ -260,75 +307,78 @@ namespace ShiftOS.WinForms.Tools bool eightBits = Shiftorium.UpgradeInstalled("color_depth_8_bits"); bool color_depth_floydsteinberg = Shiftorium.UpgradeInstalled("color_depth_floyd-steinberg_dithering"); bool dithering = Shiftorium.UpgradeInstalled("color_depth_dithering"); - - if (!sixteenBits) + bool twentyfourbits = Shiftorium.UpgradeInstalled("color_depth_24_bits"); + if (twentyfourbits) + { + sourceArr.CopyTo(destArr, 0); + } + else { - if (dithering == true) + + if (!sixteenBits) { - if (false == true) + if (dithering == true) { + if (false == true) + { + + } + else + { + int error = 0; + for (int i = 0; i < destArr.Length; i += 3) + { + byte r = sourceArr[i]; + byte g = sourceArr[i + 1]; + byte b = sourceArr[i + 2]; + + if (SkinEngine.LoadedSkin.SystemKey == Color.FromArgb(r, g, b)) + { + destArr[i] = r; + destArr[i + 1] = g; + destArr[i + 2] = b; + continue; + } + + int gray = (((r + g + b) / 3) + error); + int newgray = gray; + newgray = GetClosestColor(gray, eightBits, sixBits, fourBits, twoBits); + if (newgray > 255) + newgray = 255; + if (newgray < 0) + newgray = 0; + error = gray - newgray; + destArr[i] = (byte)newgray; + destArr[i + 1] = (byte)newgray; + destArr[i + 2] = (byte)newgray; + + } + } } + else { - int error = 0; - for (int i = 0; i < destArr.Length; i += 3) + for (int i = 0; i < sourceArr.Length; i += 3) { byte r = sourceArr[i]; byte g = sourceArr[i + 1]; byte b = sourceArr[i + 2]; - - int gray = (((r + g + b) / 3) + error); - int newgray = gray; - if (!eightBits) + if (SkinEngine.LoadedSkin.SystemKey == Color.FromArgb(r, g, b)) { - if (sixBits) - { - newgray = gray >> 2; - } - else - { - if (fourBits) - { - newgray = (int)linear(gray, 0, 255, 0, 63) * 4; - } - else - { - if (twoBits) - { - if (gray > 127 + 63) - { - newgray = 255; - } - else if (gray > 127) - newgray = 127 + 63; - else if (gray > 63) - { - newgray = 127; - } - else if (gray > 0) - newgray = 63; - else - newgray = 0; - } - else - { - if (gray > 127) - newgray = 255; - else - newgray = 0; - } - } - } + destArr[i] = r; + destArr[i + 1] = g; + destArr[i + 2] = b; + continue; } - if (newgray > 255) - newgray = 255; - if (newgray < 0) - newgray = 0; - error = gray - newgray; + + int gray = (r + g + b) / 3; + int newgray = GetClosestColor(gray, eightBits, sixBits, fourBits, twoBits); destArr[i] = (byte)newgray; - destArr[i+1] = (byte)newgray; - destArr[i+2] = (byte)newgray; + destArr[i + 1] = (byte)newgray; + destArr[i + 2] = (byte)newgray; + + } } diff --git a/ShiftOS_TheReturn/AppearanceManager.cs b/ShiftOS_TheReturn/AppearanceManager.cs index 42642f8..d8004bc 100644 --- a/ShiftOS_TheReturn/AppearanceManager.cs +++ b/ShiftOS_TheReturn/AppearanceManager.cs @@ -223,6 +223,7 @@ namespace ShiftOS.Engine /// internal static void Exit() { + OnExit?.Invoke(); //disconnect from MUD ServerManager.Disconnect(); Environment.Exit(0); diff --git a/ShiftOS_TheReturn/AudioManager.cs b/ShiftOS_TheReturn/AudioManager.cs index c50bd24..fff3369 100644 --- a/ShiftOS_TheReturn/AudioManager.cs +++ b/ShiftOS_TheReturn/AudioManager.cs @@ -88,7 +88,13 @@ namespace ShiftOS.Engine _reader = new AudioFileReader(file); _out = new WaveOut(); _out.Init(_reader); - _out.Volume = _provider.Volume; + try + { + _out.Volume = (float)SaveSystem.CurrentSave.SfxVolume / 100; + } + catch + { + } _out.Play(); _out.PlaybackStopped += (o, a) => { PlayCompleted?.Invoke(); }; } diff --git a/ShiftOS_TheReturn/Commands.cs b/ShiftOS_TheReturn/Commands.cs index 5b7674a..6e59311 100644 --- a/ShiftOS_TheReturn/Commands.cs +++ b/ShiftOS_TheReturn/Commands.cs @@ -378,6 +378,40 @@ namespace ShiftOS.Engine [Namespace("sos")] public static class ShiftOSCommands { + [Command("setsfxvolume", description = "Set the volume of various sound effects to a value between 1 and 100.")] + [RequiresArgument("value")] + public static bool SetSfxVolume(Dictionary args) + { + int value = int.Parse(args["value"].ToString()); + if (value >= 0 && value <= 100) + { + SaveSystem.CurrentSave.SfxVolume = value; + SaveSystem.SaveGame(); + } + else + { + Console.WriteLine("Volume must be between 0 and 100!"); + } + return true; + } + + [Command("setmusicvolume", description ="Set the music volume to a value between 1 and 100.")] + [RequiresArgument("value")] + public static bool SetMusicVolume(Dictionary args) + { + int value = int.Parse(args["value"].ToString()); + if(value >= 0 && value <= 100) + { + SaveSystem.CurrentSave.MusicVolume = value; + SaveSystem.SaveGame(); + } + else + { + Console.WriteLine("Volume must be between 0 and 100!"); + } + return true; + } + [RemoteLock] [Command("shutdown")] public static bool Shutdown() -- cgit v1.2.3 From b1cace7807f28deff51f06665d544a4246879a82 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 13 May 2017 15:51:19 -0400 Subject: Newer notification system (PANEL ICONS :D) --- ShiftOS.WinForms/Properties/Resources.Designer.cs | 10 ++ ShiftOS.WinForms/Properties/Resources.resx | 3 + .../Resources/notestate_connection_full.bmp | Bin 0 -> 3382 bytes ShiftOS.WinForms/ShiftOS.WinForms.csproj | 1 + ShiftOS.WinForms/WinformsDesktop.Designer.cs | 130 ++++++++++++++++----- ShiftOS.WinForms/WinformsDesktop.cs | 78 ++++++++----- ShiftOS.WinForms/WinformsDesktop.resx | 3 + ShiftOS_TheReturn/AppearanceManager.cs | 5 +- ShiftOS_TheReturn/Desktop.cs | 17 ++- ShiftOS_TheReturn/ServerManager.cs | 1 + ShiftOS_TheReturn/Skinning.cs | 8 ++ 11 files changed, 200 insertions(+), 56 deletions(-) create mode 100644 ShiftOS.WinForms/Resources/notestate_connection_full.bmp (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.WinForms/Properties/Resources.Designer.cs b/ShiftOS.WinForms/Properties/Resources.Designer.cs index 0152be8..3e83c3f 100644 --- a/ShiftOS.WinForms/Properties/Resources.Designer.cs +++ b/ShiftOS.WinForms/Properties/Resources.Designer.cs @@ -1048,6 +1048,16 @@ namespace ShiftOS.WinForms.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap notestate_connection_full { + get { + object obj = ResourceManager.GetObject("notestate_connection_full", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// diff --git a/ShiftOS.WinForms/Properties/Resources.resx b/ShiftOS.WinForms/Properties/Resources.resx index a90e69b..1db7a46 100644 --- a/ShiftOS.WinForms/Properties/Resources.resx +++ b/ShiftOS.WinForms/Properties/Resources.resx @@ -34600,4 +34600,7 @@ ..\Resources\Ambient9.mp3;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + ..\Resources\notestate_connection_full.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/ShiftOS.WinForms/Resources/notestate_connection_full.bmp b/ShiftOS.WinForms/Resources/notestate_connection_full.bmp new file mode 100644 index 0000000..a4e15b3 Binary files /dev/null and b/ShiftOS.WinForms/Resources/notestate_connection_full.bmp differ diff --git a/ShiftOS.WinForms/ShiftOS.WinForms.csproj b/ShiftOS.WinForms/ShiftOS.WinForms.csproj index 1079203..89da4e1 100644 --- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj +++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj @@ -771,6 +771,7 @@ + diff --git a/ShiftOS.WinForms/WinformsDesktop.Designer.cs b/ShiftOS.WinForms/WinformsDesktop.Designer.cs index 71ef161..968a31c 100644 --- a/ShiftOS.WinForms/WinformsDesktop.Designer.cs +++ b/ShiftOS.WinForms/WinformsDesktop.Designer.cs @@ -53,15 +53,20 @@ namespace ShiftOS.WinForms private void InitializeComponent() { this.desktoppanel = new System.Windows.Forms.Panel(); - this.btnnotifications = new System.Windows.Forms.Button(); + this.pnlnotifications = new System.Windows.Forms.Panel(); + this.flnotifications = new System.Windows.Forms.FlowLayoutPanel(); this.lbtime = new System.Windows.Forms.Label(); this.panelbuttonholder = new System.Windows.Forms.FlowLayoutPanel(); this.sysmenuholder = new System.Windows.Forms.Panel(); this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.apps = new System.Windows.Forms.ToolStripMenuItem(); this.pnlscreensaver = new System.Windows.Forms.Panel(); - this.pnlwidgetlayer = new System.Windows.Forms.Panel(); this.pnlssicon = new System.Windows.Forms.Panel(); + this.pnlwidgetlayer = new System.Windows.Forms.Panel(); + this.ntconnectionstatus = new System.Windows.Forms.PictureBox(); + this.pnlnotificationbox = new System.Windows.Forms.Panel(); + this.lbnotemsg = new System.Windows.Forms.Label(); + this.lbnotetitle = new System.Windows.Forms.Label(); this.pnladvancedal = new System.Windows.Forms.Panel(); this.flapps = new System.Windows.Forms.FlowLayoutPanel(); this.flcategories = new System.Windows.Forms.FlowLayoutPanel(); @@ -70,9 +75,13 @@ namespace ShiftOS.WinForms this.pnlstatus = new System.Windows.Forms.Panel(); this.lbalstatus = new System.Windows.Forms.Label(); this.desktoppanel.SuspendLayout(); + this.pnlnotifications.SuspendLayout(); + this.flnotifications.SuspendLayout(); this.sysmenuholder.SuspendLayout(); this.menuStrip1.SuspendLayout(); this.pnlscreensaver.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.ntconnectionstatus)).BeginInit(); + this.pnlnotificationbox.SuspendLayout(); this.pnladvancedal.SuspendLayout(); this.pnlalsystemactions.SuspendLayout(); this.pnlstatus.SuspendLayout(); @@ -81,8 +90,7 @@ namespace ShiftOS.WinForms // desktoppanel // this.desktoppanel.BackColor = System.Drawing.Color.Green; - this.desktoppanel.Controls.Add(this.btnnotifications); - this.desktoppanel.Controls.Add(this.lbtime); + this.desktoppanel.Controls.Add(this.pnlnotifications); this.desktoppanel.Controls.Add(this.panelbuttonholder); this.desktoppanel.Controls.Add(this.sysmenuholder); this.desktoppanel.Dock = System.Windows.Forms.DockStyle.Top; @@ -92,28 +100,34 @@ namespace ShiftOS.WinForms this.desktoppanel.TabIndex = 0; this.desktoppanel.Paint += new System.Windows.Forms.PaintEventHandler(this.desktoppanel_Paint); // - // btnnotifications - // - this.btnnotifications.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.btnnotifications.AutoSize = true; - this.btnnotifications.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.btnnotifications.BackColor = System.Drawing.Color.Transparent; - this.btnnotifications.FlatAppearance.BorderSize = 0; - this.btnnotifications.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btnnotifications.Location = new System.Drawing.Point(1066, -2); - this.btnnotifications.Name = "btnnotifications"; - this.btnnotifications.Size = new System.Drawing.Size(136, 24); - this.btnnotifications.TabIndex = 3; - this.btnnotifications.Text = "Notifications (0)"; - this.btnnotifications.UseVisualStyleBackColor = false; - this.btnnotifications.Click += new System.EventHandler(this.btnnotifications_Click); + // pnlnotifications + // + this.pnlnotifications.Controls.Add(this.flnotifications); + this.pnlnotifications.Controls.Add(this.lbtime); + this.pnlnotifications.Cursor = System.Windows.Forms.Cursors.Default; + this.pnlnotifications.Dock = System.Windows.Forms.DockStyle.Right; + this.pnlnotifications.Location = new System.Drawing.Point(1096, 0); + this.pnlnotifications.Name = "pnlnotifications"; + this.pnlnotifications.Size = new System.Drawing.Size(200, 24); + this.pnlnotifications.TabIndex = 3; + // + // flnotifications + // + this.flnotifications.AutoSize = true; + this.flnotifications.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.flnotifications.Controls.Add(this.ntconnectionstatus); + this.flnotifications.Dock = System.Windows.Forms.DockStyle.Left; + this.flnotifications.Location = new System.Drawing.Point(0, 0); + this.flnotifications.Name = "flnotifications"; + this.flnotifications.Size = new System.Drawing.Size(22, 24); + this.flnotifications.TabIndex = 1; // // lbtime // this.lbtime.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Right))); this.lbtime.AutoSize = true; - this.lbtime.Location = new System.Drawing.Point(3, 0); + this.lbtime.Location = new System.Drawing.Point(139, 7); this.lbtime.Name = "lbtime"; this.lbtime.Size = new System.Drawing.Size(49, 14); this.lbtime.TabIndex = 0; @@ -170,6 +184,13 @@ namespace ShiftOS.WinForms this.pnlscreensaver.TabIndex = 1; this.pnlscreensaver.Visible = false; // + // pnlssicon + // + this.pnlssicon.Location = new System.Drawing.Point(303, 495); + this.pnlssicon.Name = "pnlssicon"; + this.pnlssicon.Size = new System.Drawing.Size(200, 100); + this.pnlssicon.TabIndex = 0; + // // pnlwidgetlayer // this.pnlwidgetlayer.BackColor = System.Drawing.Color.Transparent; @@ -179,12 +200,53 @@ namespace ShiftOS.WinForms this.pnlwidgetlayer.Size = new System.Drawing.Size(1296, 714); this.pnlwidgetlayer.TabIndex = 1; // - // pnlssicon - // - this.pnlssicon.Location = new System.Drawing.Point(303, 495); - this.pnlssicon.Name = "pnlssicon"; - this.pnlssicon.Size = new System.Drawing.Size(200, 100); - this.pnlssicon.TabIndex = 0; + // ntconnectionstatus + // + this.ntconnectionstatus.Image = global::ShiftOS.WinForms.Properties.Resources.notestate_connection_full; + this.ntconnectionstatus.Location = new System.Drawing.Point(3, 3); + this.ntconnectionstatus.Name = "ntconnectionstatus"; + this.ntconnectionstatus.Size = new System.Drawing.Size(16, 16); + this.ntconnectionstatus.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; + this.ntconnectionstatus.TabIndex = 0; + this.ntconnectionstatus.TabStop = false; + this.ntconnectionstatus.Tag = "digitalsociety"; + // + // pnlnotificationbox + // + this.pnlnotificationbox.AutoSize = true; + this.pnlnotificationbox.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.pnlnotificationbox.Controls.Add(this.lbnotemsg); + this.pnlnotificationbox.Controls.Add(this.lbnotetitle); + this.pnlnotificationbox.Location = new System.Drawing.Point(654, 111); + this.pnlnotificationbox.Name = "pnlnotificationbox"; + this.pnlnotificationbox.Size = new System.Drawing.Size(69, 68); + this.pnlnotificationbox.TabIndex = 0; + this.pnlnotificationbox.Visible = false; + // + // lbnotemsg + // + this.lbnotemsg.AutoSize = true; + this.lbnotemsg.Dock = System.Windows.Forms.DockStyle.Fill; + this.lbnotemsg.Location = new System.Drawing.Point(0, 34); + this.lbnotemsg.MaximumSize = new System.Drawing.Size(350, 0); + this.lbnotemsg.Name = "lbnotemsg"; + this.lbnotemsg.Padding = new System.Windows.Forms.Padding(10); + this.lbnotemsg.Size = new System.Drawing.Size(69, 34); + this.lbnotemsg.TabIndex = 1; + this.lbnotemsg.Text = "label1"; + // + // lbnotetitle + // + this.lbnotetitle.AutoSize = true; + this.lbnotetitle.Dock = System.Windows.Forms.DockStyle.Top; + this.lbnotetitle.Location = new System.Drawing.Point(0, 0); + this.lbnotetitle.Margin = new System.Windows.Forms.Padding(10); + this.lbnotetitle.Name = "lbnotetitle"; + this.lbnotetitle.Padding = new System.Windows.Forms.Padding(10); + this.lbnotetitle.Size = new System.Drawing.Size(69, 34); + this.lbnotetitle.TabIndex = 0; + this.lbnotetitle.Tag = "header2"; + this.lbnotetitle.Text = "label1"; // // pnladvancedal // @@ -262,6 +324,7 @@ namespace ShiftOS.WinForms this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.Black; this.ClientSize = new System.Drawing.Size(1296, 738); + this.Controls.Add(this.pnlnotificationbox); this.Controls.Add(this.pnlwidgetlayer); this.Controls.Add(this.pnladvancedal); this.Controls.Add(this.pnlscreensaver); @@ -274,16 +337,24 @@ namespace ShiftOS.WinForms this.Load += new System.EventHandler(this.Desktop_Load); this.desktoppanel.ResumeLayout(false); this.desktoppanel.PerformLayout(); + this.pnlnotifications.ResumeLayout(false); + this.pnlnotifications.PerformLayout(); + this.flnotifications.ResumeLayout(false); + this.flnotifications.PerformLayout(); this.sysmenuholder.ResumeLayout(false); this.sysmenuholder.PerformLayout(); this.menuStrip1.ResumeLayout(false); this.menuStrip1.PerformLayout(); this.pnlscreensaver.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.ntconnectionstatus)).EndInit(); + this.pnlnotificationbox.ResumeLayout(false); + this.pnlnotificationbox.PerformLayout(); this.pnladvancedal.ResumeLayout(false); this.pnlalsystemactions.ResumeLayout(false); this.pnlalsystemactions.PerformLayout(); this.pnlstatus.ResumeLayout(false); this.ResumeLayout(false); + this.PerformLayout(); } @@ -295,7 +366,6 @@ namespace ShiftOS.WinForms private System.Windows.Forms.MenuStrip menuStrip1; private System.Windows.Forms.ToolStripMenuItem apps; private System.Windows.Forms.FlowLayoutPanel panelbuttonholder; - private System.Windows.Forms.Button btnnotifications; private System.Windows.Forms.Panel pnlscreensaver; private System.Windows.Forms.Panel pnlssicon; private System.Windows.Forms.Panel pnladvancedal; @@ -306,6 +376,12 @@ namespace ShiftOS.WinForms private System.Windows.Forms.FlowLayoutPanel flapps; private System.Windows.Forms.FlowLayoutPanel flcategories; private System.Windows.Forms.Panel pnlwidgetlayer; + private System.Windows.Forms.Panel pnlnotifications; + private System.Windows.Forms.FlowLayoutPanel flnotifications; + private System.Windows.Forms.Panel pnlnotificationbox; + private System.Windows.Forms.Label lbnotemsg; + private System.Windows.Forms.Label lbnotetitle; + private System.Windows.Forms.PictureBox ntconnectionstatus; } } diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs index 4efef1b..15ecb7a 100644 --- a/ShiftOS.WinForms/WinformsDesktop.cs +++ b/ShiftOS.WinForms/WinformsDesktop.cs @@ -54,6 +54,38 @@ namespace ShiftOS.WinForms private int millisecondsUntilScreensaver = 300000; + public void PushNotification(string app, string title, string msg) + { + lbnotemsg.Text = msg; + lbnotetitle.Text = title; + + var ctl = flnotifications.Controls.ToList().FirstOrDefault(x => x.Tag.ToString() == app); + if (ctl == null) + pnlnotificationbox.Left = desktoppanel.Width - pnlnotificationbox.Width; + else + { + int left = ctl.PointToScreen(ctl.Location).X; + int realleft = left - pnlnotificationbox.Width; + realleft += ctl.Width; + pnlnotificationbox.Left = realleft; + } + + + if (LoadedSkin.DesktopPanelPosition == 0) + pnlnotificationbox.Top = desktoppanel.Height; + else + pnlnotificationbox.Top = this.Height - desktoppanel.Height - pnlnotificationbox.Height; + var notekiller = new System.Windows.Forms.Timer(); + notekiller.Interval = 10000; + notekiller.Tick += (o, a) => + { + pnlnotificationbox.Hide(); + }; + Engine.AudioManager.PlayStream(Properties.Resources.infobox); + pnlnotificationbox.Show(); + notekiller.Start(); + } + /// /// Initializes a new instance of the class. /// @@ -105,24 +137,6 @@ namespace ShiftOS.WinForms }; this.TopMost = false; - NotificationDaemon.NotificationMade += (note) => - { - //Soon this will pop a balloon note. - this.Invoke(new Action(() => - { - btnnotifications.Text = Localization.Parse("{NOTIFICATIONS} (" + NotificationDaemon.GetUnreadCount().ToString() + ")"); - })); - }; - - NotificationDaemon.NotificationRead += () => - { - //Soon this will pop a balloon note. - this.Invoke(new Action(() => - { - btnnotifications.Text = Localization.Parse("{NOTIFICATIONS} (" + NotificationDaemon.GetUnreadCount().ToString() + ")"); - })); - }; - this.LocationChanged += (o, a) => { if (this.Left != 0) @@ -143,10 +157,6 @@ namespace ShiftOS.WinForms { if (this.Visible == true) this.Invoke(new Action(() => SetupDesktop())); - this.Invoke(new Action(() => - { - btnnotifications.Text = Localization.Parse("{NOTIFICATIONS} (" + NotificationDaemon.GetUnreadCount().ToString() + ")"); - })); }; Shiftorium.Installed += () => { @@ -187,8 +197,10 @@ namespace ShiftOS.WinForms if (SaveSystem.CurrentSave != null && TutorialManager.IsInTutorial == false) { lbtime.Text = Applications.Terminal.GetTime(); - lbtime.Left = desktoppanel.Width - lbtime.Width - LoadedSkin.DesktopPanelClockFromRight.X; + lbtime.Left = pnlnotifications.Width - lbtime.Width - LoadedSkin.DesktopPanelClockFromRight.X; lbtime.Top = LoadedSkin.DesktopPanelClockFromRight.Y; + + pnlnotifications.Width = flnotifications.Width + lbtime.Width + LoadedSkin.DesktopPanelClockFromRight.X; } } @@ -215,8 +227,6 @@ namespace ShiftOS.WinForms catch { } - btnnotifications.Left = lbtime.Left - btnnotifications.Width - 2; - btnnotifications.Top = (desktoppanel.Height - btnnotifications.Height) / 2; }; time.Start(); @@ -372,10 +382,13 @@ namespace ShiftOS.WinForms desktoppanel.Visible = Shiftorium.UpgradeInstalled("desktop"); lbtime.Visible = Shiftorium.UpgradeInstalled("desktop_clock_widget"); - btnnotifications.Visible = Shiftorium.UpgradeInstalled("panel_notifications"); + ControlManager.SetupControls(pnlnotificationbox); //skinning - lbtime.ForeColor = LoadedSkin.DesktopPanelClockColor; + lbtime.BackColor = Color.Transparent; + pnlnotifications.BackgroundImage = GetImage("panelclockbg"); + pnlnotifications.BackgroundImageLayout = GetImageLayout("panelclockbg"); + pnlnotifications.BackColor = LoadedSkin.DesktopPanelClockBackgroundColor; panelbuttonholder.Top = 0; panelbuttonholder.Left = LoadedSkin.PanelButtonHolderFromLeft; @@ -1060,4 +1073,15 @@ namespace ShiftOS.WinForms } } } + + public static class ControlCollectionExtensions + { + public static IList ToList(this Control.ControlCollection ctrls) + { + var lst = new List(); + foreach (var ctl in ctrls) + lst.Add(ctl as Control); + return lst; + } + } } \ No newline at end of file diff --git a/ShiftOS.WinForms/WinformsDesktop.resx b/ShiftOS.WinForms/WinformsDesktop.resx index d5494e3..b77504b 100644 --- a/ShiftOS.WinForms/WinformsDesktop.resx +++ b/ShiftOS.WinForms/WinformsDesktop.resx @@ -120,4 +120,7 @@ 17, 17 + + 17, 17 + \ No newline at end of file diff --git a/ShiftOS_TheReturn/AppearanceManager.cs b/ShiftOS_TheReturn/AppearanceManager.cs index d8004bc..a10f419 100644 --- a/ShiftOS_TheReturn/AppearanceManager.cs +++ b/ShiftOS_TheReturn/AppearanceManager.cs @@ -226,7 +226,10 @@ namespace ShiftOS.Engine OnExit?.Invoke(); //disconnect from MUD ServerManager.Disconnect(); - Environment.Exit(0); + Desktop.InvokeOnWorkerThread(() => + { + Environment.Exit(0); + }); } /// diff --git a/ShiftOS_TheReturn/Desktop.cs b/ShiftOS_TheReturn/Desktop.cs index bc17a8e..a5e7f43 100644 --- a/ShiftOS_TheReturn/Desktop.cs +++ b/ShiftOS_TheReturn/Desktop.cs @@ -102,7 +102,14 @@ namespace ShiftOS.Engine /// Gets the name of the desktop. /// string DesktopName { get; } - + + /// + /// Show a notification on the desktop. + /// + /// An application ID (for determining what system icon to show the notification alongside) + /// The title of the notification. + /// Isn't this.... self explanatory? + void PushNotification(string app, string title, string message); /// /// Performs most of the skinning and layout handling for the desktop. @@ -266,6 +273,14 @@ namespace ShiftOS.Engine { _desktop.HideAppLauncher(); } + + public static void PushNotification(string app, string title, string msg) + { + InvokeOnWorkerThread(() => + { + _desktop.PushNotification(app, title, msg); + }); + } } // sorry i almost killed everything :P } diff --git a/ShiftOS_TheReturn/ServerManager.cs b/ShiftOS_TheReturn/ServerManager.cs index 825064b..371d8e7 100644 --- a/ShiftOS_TheReturn/ServerManager.cs +++ b/ShiftOS_TheReturn/ServerManager.cs @@ -131,6 +131,7 @@ namespace ShiftOS.Engine { if (!UserDisconnect) { + Desktop.PushNotification("digital_society_connection", "Disconnected from Digital Society.", "The ShiftOS kernel has been disconnected from the Digital Society. We are attempting to re-connect you."); TerminalBackend.PrefixEnabled = true; ConsoleEx.ForegroundColor = ConsoleColor.Red; ConsoleEx.Bold = true; diff --git a/ShiftOS_TheReturn/Skinning.cs b/ShiftOS_TheReturn/Skinning.cs index 548e80f..4340f1a 100644 --- a/ShiftOS_TheReturn/Skinning.cs +++ b/ShiftOS_TheReturn/Skinning.cs @@ -276,6 +276,14 @@ namespace ShiftOS.Engine [ShifterHidden] public Dictionary AppIcons = new Dictionary(); + [Image("panelclockbg")] + [ShifterMeta("Desktop")] + [ShifterCategory("Panel Clock")] + [ShifterName("Panel Clock Background Image")] + [ShifterDescription("Set the background image of the panel clock.")] + [RequiresUpgrade("skinning;shift_panel_clock")] + public byte[] PanelClockBG = null; + [ShifterMeta("System")] [ShifterCategory("Login Screen")] [RequiresUpgrade("gui_based_login_screen")] -- cgit v1.2.3 From 7919afa133561da65304f01498db5993510702e8 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 14 May 2017 13:15:12 -0400 Subject: Custom buttons and progress bars. --- .../Applications/AudioPlayer.Designer.cs | 2 - .../Applications/Installer.Designer.cs | 2 - .../Applications/ShiftoriumFrontend.Designer.cs | 2 - .../Applications/UpdateManager.Designer.cs | 2 - .../Applications/VideoPlayer.Designer.cs | 2 - ShiftOS.WinForms/Controls/ShiftedProgressBar.cs | 91 +++++++++++++--- .../DesktopWidgets/UpgradePercentage.Designer.cs | 2 - ShiftOS.WinForms/DownloadControl.Designer.cs | 2 - ShiftOS.WinForms/Resources/Shiftorium.txt | 14 +++ ShiftOS.WinForms/Tools/ControlManager.cs | 43 ++++++++ ShiftOS_TheReturn/Skinning.cs | 121 +++++++++++++++++++++ 11 files changed, 251 insertions(+), 32 deletions(-) (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.WinForms/Applications/AudioPlayer.Designer.cs b/ShiftOS.WinForms/Applications/AudioPlayer.Designer.cs index 6263ff7..d7f03a0 100644 --- a/ShiftOS.WinForms/Applications/AudioPlayer.Designer.cs +++ b/ShiftOS.WinForms/Applications/AudioPlayer.Designer.cs @@ -141,12 +141,10 @@ namespace ShiftOS.WinForms.Applications // // pgplaytime // - this.pgplaytime.BlockSize = 5; this.pgplaytime.Location = new System.Drawing.Point(46, 3); this.pgplaytime.Maximum = 100; this.pgplaytime.Name = "pgplaytime"; this.pgplaytime.Size = new System.Drawing.Size(749, 23); - this.pgplaytime.Style = System.Windows.Forms.ProgressBarStyle.Continuous; this.pgplaytime.TabIndex = 1; this.pgplaytime.Tag = "keepbg"; this.pgplaytime.Text = "shiftedProgressBar1"; diff --git a/ShiftOS.WinForms/Applications/Installer.Designer.cs b/ShiftOS.WinForms/Applications/Installer.Designer.cs index 48f9146..b01986d 100644 --- a/ShiftOS.WinForms/Applications/Installer.Designer.cs +++ b/ShiftOS.WinForms/Applications/Installer.Designer.cs @@ -118,12 +118,10 @@ // this.pginstall.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.pginstall.BlockSize = 5; this.pginstall.Location = new System.Drawing.Point(17, 161); this.pginstall.Maximum = 100; this.pginstall.Name = "pginstall"; this.pginstall.Size = new System.Drawing.Size(414, 23); - this.pginstall.Style = System.Windows.Forms.ProgressBarStyle.Continuous; this.pginstall.TabIndex = 2; this.pginstall.Text = "shiftedProgressBar1"; this.pginstall.Value = 0; diff --git a/ShiftOS.WinForms/Applications/ShiftoriumFrontend.Designer.cs b/ShiftOS.WinForms/Applications/ShiftoriumFrontend.Designer.cs index f9d0bb4..dc107c4 100644 --- a/ShiftOS.WinForms/Applications/ShiftoriumFrontend.Designer.cs +++ b/ShiftOS.WinForms/Applications/ShiftoriumFrontend.Designer.cs @@ -242,12 +242,10 @@ namespace ShiftOS.WinForms.Applications // this.pgupgradeprogress.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.pgupgradeprogress.BlockSize = 5; this.pgupgradeprogress.Location = new System.Drawing.Point(146, 390); this.pgupgradeprogress.Maximum = 100; this.pgupgradeprogress.Name = "pgupgradeprogress"; this.pgupgradeprogress.Size = new System.Drawing.Size(254, 23); - this.pgupgradeprogress.Style = System.Windows.Forms.ProgressBarStyle.Continuous; this.pgupgradeprogress.TabIndex = 1; this.pgupgradeprogress.Value = 25; // diff --git a/ShiftOS.WinForms/Applications/UpdateManager.Designer.cs b/ShiftOS.WinForms/Applications/UpdateManager.Designer.cs index 0b23b8e..d30e2df 100644 --- a/ShiftOS.WinForms/Applications/UpdateManager.Designer.cs +++ b/ShiftOS.WinForms/Applications/UpdateManager.Designer.cs @@ -64,12 +64,10 @@ // this.pgdownload.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.pgdownload.BlockSize = 5; this.pgdownload.Location = new System.Drawing.Point(86, 4); this.pgdownload.Maximum = 100; this.pgdownload.Name = "pgdownload"; this.pgdownload.Size = new System.Drawing.Size(427, 23); - this.pgdownload.Style = System.Windows.Forms.ProgressBarStyle.Continuous; this.pgdownload.TabIndex = 2; this.pgdownload.Text = "Updating..."; this.pgdownload.Value = 0; diff --git a/ShiftOS.WinForms/Applications/VideoPlayer.Designer.cs b/ShiftOS.WinForms/Applications/VideoPlayer.Designer.cs index d915c31..1d93047 100644 --- a/ShiftOS.WinForms/Applications/VideoPlayer.Designer.cs +++ b/ShiftOS.WinForms/Applications/VideoPlayer.Designer.cs @@ -91,12 +91,10 @@ // // pgplaytime // - this.pgplaytime.BlockSize = 5; this.pgplaytime.Location = new System.Drawing.Point(46, 3); this.pgplaytime.Maximum = 100; this.pgplaytime.Name = "pgplaytime"; this.pgplaytime.Size = new System.Drawing.Size(749, 23); - this.pgplaytime.Style = System.Windows.Forms.ProgressBarStyle.Continuous; this.pgplaytime.TabIndex = 1; this.pgplaytime.Tag = "keepbg"; this.pgplaytime.Text = "shiftedProgressBar1"; diff --git a/ShiftOS.WinForms/Controls/ShiftedProgressBar.cs b/ShiftOS.WinForms/Controls/ShiftedProgressBar.cs index e5a2c33..ceaff02 100644 --- a/ShiftOS.WinForms/Controls/ShiftedProgressBar.cs +++ b/ShiftOS.WinForms/Controls/ShiftedProgressBar.cs @@ -31,6 +31,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; +using ShiftOS.Engine; namespace ShiftOS.WinForms.Controls { @@ -46,7 +47,7 @@ namespace ShiftOS.WinForms.Controls t.Interval = 100; t.Tick += (o, a) => { - if(this._style == ProgressBarStyle.Marquee) + if(this.Style == ProgressBarStyle.Marquee) { if(_marqueePos >= this.Width) { @@ -89,46 +90,100 @@ namespace ShiftOS.WinForms.Controls } } - public ProgressBarStyle _style = ProgressBarStyle.Continuous; - public ProgressBarStyle Style { - get { return _style; } - set { _style = value; this.Refresh(); } + get + { + return SkinEngine.LoadedSkin.ProgressBarStyle; + } } - private int _blocksize = 5; - public int BlockSize { - get { return _blocksize; } - set + get { - _blocksize = value; - this.Refresh(); + return SkinEngine.LoadedSkin.ProgressBarBlockSize; + } + } + + public Color RealBackColor + { + get + { + return SkinEngine.LoadedSkin.ProgressBarBackgroundColor; + } + } + + public Image RealBackgroundImage + { + get + { + return SkinEngine.GetImage("progressbarbg"); + } + } + + public Image ProgressImage + { + get + { + return SkinEngine.GetImage("progress"); + } + } + + public Color ProgressColor + { + get + { + return SkinEngine.LoadedSkin.ProgressColor; } } protected override void OnPaint(PaintEventArgs pe) { - pe.Graphics.Clear(Color.Black); - switch (_style) + pe.Graphics.Clear(this.RealBackColor); + if(RealBackgroundImage != null) + { + pe.Graphics.FillRectangle(new TextureBrush(RealBackgroundImage), new Rectangle(0, 0, this.Width, this.Height)); + } + switch (Style) { case ProgressBarStyle.Continuous: double width = linear(this.Value, 0, this.Maximum, 0, this.Width); - pe.Graphics.FillRectangle(new SolidBrush(Color.Green), new RectangleF(0, 0, (float)width, this.Height)); + if (ProgressImage != null) + { + pe.Graphics.FillRectangle(new TextureBrush(ProgressImage), new RectangleF(0, 0, (float)width, this.Height)); + } + else + { + pe.Graphics.FillRectangle(new SolidBrush(ProgressColor), new RectangleF(0, 0, (float)width, this.Height)); + } break; case ProgressBarStyle.Blocks: - int block_count = this.Width / (this._blocksize + 2); + int block_count = this.Width / (this.BlockSize + 2); int blocks = (int)linear(this.Value, 0, this.Maximum, 0, block_count); for(int i = 0; i < blocks - 1; i++) { - int position = i * (_blocksize + 2); - pe.Graphics.FillRectangle(new SolidBrush(Color.Green), new Rectangle(position, 0, _blocksize, this.Height)); + int position = i * (BlockSize + 2); + if (ProgressImage != null) + { + pe.Graphics.FillRectangle(new TextureBrush(ProgressImage), new Rectangle(position, 0, BlockSize, this.Height)); + + } + else + { + pe.Graphics.FillRectangle(new SolidBrush(ProgressColor), new Rectangle(position, 0, BlockSize, this.Height)); + } } break; case ProgressBarStyle.Marquee: - pe.Graphics.FillRectangle(new SolidBrush(Color.Green), new Rectangle(_marqueePos, 0, this.Width / 4, this.Height)); + if (ProgressImage != null) + { + pe.Graphics.FillRectangle(new TextureBrush(ProgressImage), new Rectangle(_marqueePos, 0, this.Width / 4, this.Height)); + } + else + { + pe.Graphics.FillRectangle(new SolidBrush(ProgressColor), new Rectangle(_marqueePos, 0, this.Width / 4, this.Height)); + } break; } } diff --git a/ShiftOS.WinForms/DesktopWidgets/UpgradePercentage.Designer.cs b/ShiftOS.WinForms/DesktopWidgets/UpgradePercentage.Designer.cs index ca0d587..4867c8d 100644 --- a/ShiftOS.WinForms/DesktopWidgets/UpgradePercentage.Designer.cs +++ b/ShiftOS.WinForms/DesktopWidgets/UpgradePercentage.Designer.cs @@ -34,13 +34,11 @@ // // pgupgrades // - this.pgupgrades.BlockSize = 5; this.pgupgrades.Dock = System.Windows.Forms.DockStyle.Bottom; this.pgupgrades.Location = new System.Drawing.Point(0, 99); this.pgupgrades.Maximum = 100; this.pgupgrades.Name = "pgupgrades"; this.pgupgrades.Size = new System.Drawing.Size(227, 23); - this.pgupgrades.Style = System.Windows.Forms.ProgressBarStyle.Continuous; this.pgupgrades.TabIndex = 0; this.pgupgrades.Text = "shiftedProgressBar1"; this.pgupgrades.Value = 0; diff --git a/ShiftOS.WinForms/DownloadControl.Designer.cs b/ShiftOS.WinForms/DownloadControl.Designer.cs index 2587b93..69c828d 100644 --- a/ShiftOS.WinForms/DownloadControl.Designer.cs +++ b/ShiftOS.WinForms/DownloadControl.Designer.cs @@ -83,12 +83,10 @@ namespace ShiftOS.WinForms // this.pgprogress.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.pgprogress.BlockSize = 5; this.pgprogress.Location = new System.Drawing.Point(4, 52); this.pgprogress.Maximum = 100; this.pgprogress.Name = "pgprogress"; this.pgprogress.Size = new System.Drawing.Size(371, 23); - this.pgprogress.Style = System.Windows.Forms.ProgressBarStyle.Continuous; this.pgprogress.TabIndex = 0; this.pgprogress.Text = "shiftedProgressBar1"; this.pgprogress.Value = 0; diff --git a/ShiftOS.WinForms/Resources/Shiftorium.txt b/ShiftOS.WinForms/Resources/Shiftorium.txt index c3d27ae..cc68c6f 100644 --- a/ShiftOS.WinForms/Resources/Shiftorium.txt +++ b/ShiftOS.WinForms/Resources/Shiftorium.txt @@ -7,6 +7,20 @@ Dependencies: "desktop", Category: "Enhancements", }, + { + Name: "Shift Progress Bar", + Cost: 150, + Description: "Want to customize the look of all ShiftOS Progress Bars? Buy this upgrade today and you'll get the ability to set the foreground and background color of the progress bar, and many more things!.", + Dependencies: "shifter;shift_buttons", + Category: "Customization" + }, + { + Name: "Shift Buttons", + Cost: 150, + Description: "Want to customize the look of all ShiftOS buttons? This Shifter upgrade gives you a new \"Buttons\" category in the System category to do just that.", + Dependencies: "shifter", + Category: "Customization" + }, { Name: "GUI Based Login Screen", Cost: 500, diff --git a/ShiftOS.WinForms/Tools/ControlManager.cs b/ShiftOS.WinForms/Tools/ControlManager.cs index 3d66b2b..4f888ab 100644 --- a/ShiftOS.WinForms/Tools/ControlManager.cs +++ b/ShiftOS.WinForms/Tools/ControlManager.cs @@ -214,6 +214,49 @@ namespace ShiftOS.WinForms.Tools { } + + if(ctrl is Button) + { + Desktop.InvokeOnWorkerThread(() => + { + Button b = ctrl as Button; + b.BackColor = SkinEngine.LoadedSkin.ButtonBackgroundColor; + b.BackgroundImage = SkinEngine.GetImage("buttonidle"); + b.BackgroundImageLayout = SkinEngine.GetImageLayout("buttonidle"); + b.FlatAppearance.BorderSize = SkinEngine.LoadedSkin.ButtonBorderWidth; + b.FlatAppearance.BorderColor = SkinEngine.LoadedSkin.ButtonForegroundColor; + b.ForeColor = SkinEngine.LoadedSkin.ButtonForegroundColor; + b.Font = SkinEngine.LoadedSkin.ButtonTextFont; + + b.MouseEnter += (o, a) => + { + b.BackColor = SkinEngine.LoadedSkin.ButtonHoverColor; + b.BackgroundImage = SkinEngine.GetImage("buttonhover"); + b.BackgroundImageLayout = SkinEngine.GetImageLayout("buttonhover"); + }; + b.MouseLeave += (o, a) => + { + b.BackColor = SkinEngine.LoadedSkin.ButtonBackgroundColor; + b.BackgroundImage = SkinEngine.GetImage("buttonidle"); + b.BackgroundImageLayout = SkinEngine.GetImageLayout("buttonidle"); + }; + b.MouseUp += (o, a) => + { + b.BackColor = SkinEngine.LoadedSkin.ButtonBackgroundColor; + b.BackgroundImage = SkinEngine.GetImage("buttonidle"); + b.BackgroundImageLayout = SkinEngine.GetImageLayout("buttonidle"); + }; + + b.MouseDown += (o, a) => + { + b.BackColor = SkinEngine.LoadedSkin.ButtonPressedColor; + b.BackgroundImage = SkinEngine.GetImage("buttonpressed"); + b.BackgroundImageLayout = SkinEngine.GetImageLayout("buttonpressed"); + + }; + }); + } + ctrl.KeyDown += (o, a) => { if (a.Control && a.KeyCode == Keys.T) diff --git a/ShiftOS_TheReturn/Skinning.cs b/ShiftOS_TheReturn/Skinning.cs index 4340f1a..c2f47fa 100644 --- a/ShiftOS_TheReturn/Skinning.cs +++ b/ShiftOS_TheReturn/Skinning.cs @@ -276,6 +276,127 @@ namespace ShiftOS.Engine [ShifterHidden] public Dictionary AppIcons = new Dictionary(); + [ShifterMeta("System")] + [ShifterCategory("Progress Bar")] + [RequiresUpgrade("shift_progress_bar;skinning")] + [Image("progressbarbg")] + [ShifterName("Progress Bar Background Image")] + [ShifterDescription("Set an image for the background of a progress bar.")] + public byte[] ProgressBarBG = null; + + + [ShifterMeta("System")] + [ShifterCategory("Progress Bar")] + [RequiresUpgrade("shift_progress_bar;skinning")] + [Image("progress")] + [ShifterName("Progress Image")] + [ShifterDescription("Set the image for the progress inside a progress bar.")] + public byte[] Progress = null; + + + [ShifterMeta("System")] + [ShifterCategory("Progress Bar")] + [RequiresUpgrade("shift_progress_bar")] + [ShifterName("Progress bar foreground color")] + [ShifterDescription("Set the color of the progress indicator.")] + public Color ProgressColor = Accent1; + + + [ShifterMeta("System")] + [ShifterCategory("Progress Bar")] + [RequiresUpgrade("shift_progress_bar")] + [ShifterName("Progress bar background color")] + [ShifterDescription("The background color of the progress bar.")] + public Color ProgressBarBackgroundColor = Color.Black; + + + [ShifterMeta("System")] + [ShifterCategory("Progress Bar")] + [RequiresUpgrade("shift_progress_bar")] + [ShifterName("Progress bar block size")] + [ShifterDescription("If the progress bar style is set to Blocks, this determines how wide each block should be.")] + public int ProgressBarBlockSize = 15; + + + [ShifterMeta("System")] + [ShifterCategory("Progress Bar")] + [RequiresUpgrade("shift_progress_bar")] + [ShifterDescription("Set the style of a progress bar.\r\nMarquee: The progress bar will render a box that moves from the left to the right in a loop.\r\nContinuous: Progress is shown by a single, continuous box.\r\nBlocks: Just like Continuous, but the box is split into even smaller boxes of a set width.")] + [ShifterName("Progress bar style")] + public ProgressBarStyle ProgressBarStyle = ProgressBarStyle.Continuous; + + + + + + + [ShifterMeta("System")] + [ShifterCategory("Buttons")] + [RequiresUpgrade("shift_buttons")] + [ShifterName("Button background color")] + [ShifterDescription("Set the background color for each button's Idle state.")] + public Color ButtonBackgroundColor = Skin.DefaultBackground; + + [ShifterMeta("System")] + [ShifterCategory("Buttons")] + [RequiresUpgrade("shift_buttons;skinning")] + [Image("buttonhover")] + [ShifterName("Button hover image")] + [ShifterDescription("Set the image that's displayed when the mouse hovers over a button.")] + public byte[] ButtonHoverImage = null; + + [ShifterMeta("System")] + [ShifterCategory("Buttons")] + [RequiresUpgrade("skinning;shift_buttons")] + [Image("buttonpressed")] + [ShifterName("Button pressed image")] + [ShifterDescription("Select an image to show when the user presses a button.")] + public byte[] ButtonPressedImage = null; + + [ShifterMeta("System")] + [ShifterCategory("Buttons")] + [RequiresUpgrade("shift_buttons")] + [ShifterName("Button hover color")] + [ShifterDescription("Choose the color that displays on a button when the mouse hovers over it.")] + public Color ButtonHoverColor = Skin.Accent1; + + [ShifterMeta("System")] + [ShifterCategory("Buttons")] + [RequiresUpgrade("shift_buttons")] + [ShifterName("Button pressed color")] + [ShifterDescription("Select the background color for the button when the mouse clicks it.")] + public Color ButtonPressedColor = Skin.Accent2; + + [ShifterMeta("System")] + [ShifterCategory("Buttons")] + [RequiresUpgrade("shift_buttons")] + [ShifterName("Button foreground color")] + [ShifterDescription("Select the text and border color for each button.")] + public Color ButtonForegroundColor = Skin.DefaultForeground; + + [ShifterMeta("System")] + [ShifterCategory("Buttons")] + [RequiresUpgrade("shift_buttons")] + [ShifterName("Button border width")] + [ShifterDescription("Set the width, in pixels, of the button's border.")] + public int ButtonBorderWidth = 2; + + [ShifterMeta("System")] + [ShifterCategory("Buttons")] + [RequiresUpgrade("shift_buttons")] + [ShifterName("Button font")] + [ShifterDescription("Select the font for the button's text.")] + public Font ButtonTextFont = Skin.SysFont; + + [ShifterMeta("System")] + [ShifterCategory("Buttons")] + [RequiresUpgrade("shift_buttons;skinning")] + [Image("buttonidle")] + [ShifterName("Button background color")] + [ShifterDescription("Select an image to show as the button's Idle state.")] + public byte[] ButtonBG = null; + + [Image("panelclockbg")] [ShifterMeta("Desktop")] [ShifterCategory("Panel Clock")] -- cgit v1.2.3 From 20d44ba1334b5af65605de27a01e8dcb40fa2081 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 16 May 2017 15:45:00 -0400 Subject: i <3 rylan wait wrong textbox whatever --- ShiftOS.WinForms/Controls/ShiftedProgressBar.cs | 37 ++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 4 deletions(-) (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.WinForms/Controls/ShiftedProgressBar.cs b/ShiftOS.WinForms/Controls/ShiftedProgressBar.cs index ceaff02..3c8550c 100644 --- a/ShiftOS.WinForms/Controls/ShiftedProgressBar.cs +++ b/ShiftOS.WinForms/Controls/ShiftedProgressBar.cs @@ -27,6 +27,7 @@ using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; +using System.Drawing.Drawing2D; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -138,12 +139,40 @@ namespace ShiftOS.WinForms.Controls } } + public TextureBrush CreateBG() + { + var tex = new TextureBrush(RealBackgroundImage); + var mt = new Matrix(new Rectangle(0, 0, this.Width, this.Height), new[] + { + new Point(0,0), + new Point(this.Width,0), + new Point(this.Width, this.Height) + }); + tex.Transform = mt; + tex.WrapMode = WrapMode.Clamp; + return tex; + } + + public TextureBrush CreateTexture() + { + var tex = new TextureBrush(ProgressImage); + var mt = new Matrix(new Rectangle(0, 0, this.Width, this.Height), new[] + { + new Point(0,0), + new Point(this.Width,0), + new Point(this.Width, this.Height) + }); + tex.Transform = mt; + tex.WrapMode = WrapMode.Clamp; + return tex; + } + protected override void OnPaint(PaintEventArgs pe) { pe.Graphics.Clear(this.RealBackColor); if(RealBackgroundImage != null) { - pe.Graphics.FillRectangle(new TextureBrush(RealBackgroundImage), new Rectangle(0, 0, this.Width, this.Height)); + pe.Graphics.FillRectangle(CreateBG(), new Rectangle(0, 0, this.Width, this.Height)); } switch (Style) { @@ -151,7 +180,7 @@ namespace ShiftOS.WinForms.Controls double width = linear(this.Value, 0, this.Maximum, 0, this.Width); if (ProgressImage != null) { - pe.Graphics.FillRectangle(new TextureBrush(ProgressImage), new RectangleF(0, 0, (float)width, this.Height)); + pe.Graphics.FillRectangle(CreateTexture(), new RectangleF(0, 0, (float)width, this.Height)); } else { @@ -166,7 +195,7 @@ namespace ShiftOS.WinForms.Controls int position = i * (BlockSize + 2); if (ProgressImage != null) { - pe.Graphics.FillRectangle(new TextureBrush(ProgressImage), new Rectangle(position, 0, BlockSize, this.Height)); + pe.Graphics.FillRectangle(CreateTexture(), new Rectangle(position, 0, BlockSize, this.Height)); } else @@ -178,7 +207,7 @@ namespace ShiftOS.WinForms.Controls case ProgressBarStyle.Marquee: if (ProgressImage != null) { - pe.Graphics.FillRectangle(new TextureBrush(ProgressImage), new Rectangle(_marqueePos, 0, this.Width / 4, this.Height)); + pe.Graphics.FillRectangle(CreateTexture(), new Rectangle(_marqueePos, 0, this.Width / 4, this.Height)); } else { -- cgit v1.2.3 From 18ceccb1218f167d6bb836762f7aeea6e8b9d892 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 18 May 2017 18:34:22 -0400 Subject: Revert "i <3 rylan wait wrong textbox whatever" This reverts commit 20d44ba1334b5af65605de27a01e8dcb40fa2081. --- ShiftOS.WinForms/Controls/ShiftedProgressBar.cs | 37 +++---------------------- 1 file changed, 4 insertions(+), 33 deletions(-) (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.WinForms/Controls/ShiftedProgressBar.cs b/ShiftOS.WinForms/Controls/ShiftedProgressBar.cs index 3c8550c..ceaff02 100644 --- a/ShiftOS.WinForms/Controls/ShiftedProgressBar.cs +++ b/ShiftOS.WinForms/Controls/ShiftedProgressBar.cs @@ -27,7 +27,6 @@ using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; -using System.Drawing.Drawing2D; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -139,40 +138,12 @@ namespace ShiftOS.WinForms.Controls } } - public TextureBrush CreateBG() - { - var tex = new TextureBrush(RealBackgroundImage); - var mt = new Matrix(new Rectangle(0, 0, this.Width, this.Height), new[] - { - new Point(0,0), - new Point(this.Width,0), - new Point(this.Width, this.Height) - }); - tex.Transform = mt; - tex.WrapMode = WrapMode.Clamp; - return tex; - } - - public TextureBrush CreateTexture() - { - var tex = new TextureBrush(ProgressImage); - var mt = new Matrix(new Rectangle(0, 0, this.Width, this.Height), new[] - { - new Point(0,0), - new Point(this.Width,0), - new Point(this.Width, this.Height) - }); - tex.Transform = mt; - tex.WrapMode = WrapMode.Clamp; - return tex; - } - protected override void OnPaint(PaintEventArgs pe) { pe.Graphics.Clear(this.RealBackColor); if(RealBackgroundImage != null) { - pe.Graphics.FillRectangle(CreateBG(), new Rectangle(0, 0, this.Width, this.Height)); + pe.Graphics.FillRectangle(new TextureBrush(RealBackgroundImage), new Rectangle(0, 0, this.Width, this.Height)); } switch (Style) { @@ -180,7 +151,7 @@ namespace ShiftOS.WinForms.Controls double width = linear(this.Value, 0, this.Maximum, 0, this.Width); if (ProgressImage != null) { - pe.Graphics.FillRectangle(CreateTexture(), new RectangleF(0, 0, (float)width, this.Height)); + pe.Graphics.FillRectangle(new TextureBrush(ProgressImage), new RectangleF(0, 0, (float)width, this.Height)); } else { @@ -195,7 +166,7 @@ namespace ShiftOS.WinForms.Controls int position = i * (BlockSize + 2); if (ProgressImage != null) { - pe.Graphics.FillRectangle(CreateTexture(), new Rectangle(position, 0, BlockSize, this.Height)); + pe.Graphics.FillRectangle(new TextureBrush(ProgressImage), new Rectangle(position, 0, BlockSize, this.Height)); } else @@ -207,7 +178,7 @@ namespace ShiftOS.WinForms.Controls case ProgressBarStyle.Marquee: if (ProgressImage != null) { - pe.Graphics.FillRectangle(CreateTexture(), new Rectangle(_marqueePos, 0, this.Width / 4, this.Height)); + pe.Graphics.FillRectangle(new TextureBrush(ProgressImage), new Rectangle(_marqueePos, 0, this.Width / 4, this.Height)); } else { -- cgit v1.2.3 From 46a92866f8ac757bd236746be7ed11a1a0c39f86 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 18 May 2017 18:56:58 -0400 Subject: fix beta 2.5 first_steps --- ShiftOS.WinForms/Applications/Terminal.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.WinForms/Applications/Terminal.cs b/ShiftOS.WinForms/Applications/Terminal.cs index 02c4cc0..8fa785a 100644 --- a/ShiftOS.WinForms/Applications/Terminal.cs +++ b/ShiftOS.WinForms/Applications/Terminal.cs @@ -445,6 +445,7 @@ namespace ShiftOS.WinForms.Applications [Story("first_steps")] public static void FirstSteps() { + TerminalBackend.PrefixEnabled = false; new Thread(() => { TerminalBackend.InStory = true; @@ -489,6 +490,7 @@ namespace ShiftOS.WinForms.Applications Console.WriteLine("Give it a try! Type \"sos.help\" in the following prompt to view a list of all ShiftOS commands."); Thread.Sleep(2000); TerminalBackend.InStory = false; + TerminalBackend.PrefixEnabled = true; TerminalBackend.PrintPrompt(); bool help_entered = false; TerminalBackend.CommandProcessed += (text, args) => @@ -499,6 +501,7 @@ namespace ShiftOS.WinForms.Applications while (help_entered == false) Thread.Sleep(10); TerminalBackend.InStory = true; + TerminalBackend.PrefixEnabled = false; Thread.Sleep(2000); Console.WriteLine("Good job! Next, we will look at how to pass data to a command, such as win.open."); Thread.Sleep(2000); @@ -522,6 +525,7 @@ namespace ShiftOS.WinForms.Applications Thread.Sleep(2000); TerminalBackend.InStory = false; bool winopenEntered = false; + TerminalBackend.PrefixEnabled = true; TerminalBackend.PrintPrompt(); TerminalBackend.CommandProcessed += (text, args) => { @@ -532,15 +536,18 @@ namespace ShiftOS.WinForms.Applications while (winopenEntered == false) Thread.Sleep(10); TerminalBackend.InStory = true; + TerminalBackend.PrefixEnabled = false; + Thread.Sleep(2000); Console.WriteLine("Pretty cool, it gave you a nice list of other win.open commands that will let you open each program."); Thread.Sleep(2000); Console.WriteLine("I'll leave you to it, you've got the hang of it! One last thing, if ever you find yourself in another program, and want to exit, simply press CTRL+T to return to the Terminal."); Thread.Sleep(2000); - + TerminalBackend.PrefixEnabled = true; TerminalBackend.InStory = false; - TerminalBackend.PrintPrompt(); SaveSystem.SaveGame(); + Thread.Sleep(1000); + TerminalBackend.PrintPrompt(); }).Start(); } -- cgit v1.2.3 From 5967c0fc3616fe14656f985e8871489ba03cfd10 Mon Sep 17 00:00:00 2001 From: AShifter Date: Thu, 18 May 2017 19:27:39 -0600 Subject: Start work on TriPresent It's in a basic state right now, and I also fixed a launch bug for people with slightly older ``ShiftOS.mfs`` files (in Localization.cs). --- .../Applications/TriPresent.Designer.cs | 233 +++++++++++++++++++++ ShiftOS.WinForms/Applications/TriPresent.cs | 37 ++++ ShiftOS.WinForms/Applications/TriPresent.resx | 123 +++++++++++ ShiftOS.WinForms/ShiftOS.WinForms.csproj | 9 + ShiftOS_TheReturn/Localization.cs | 20 +- 5 files changed, 420 insertions(+), 2 deletions(-) create mode 100644 ShiftOS.WinForms/Applications/TriPresent.Designer.cs create mode 100644 ShiftOS.WinForms/Applications/TriPresent.cs create mode 100644 ShiftOS.WinForms/Applications/TriPresent.resx (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.WinForms/Applications/TriPresent.Designer.cs b/ShiftOS.WinForms/Applications/TriPresent.Designer.cs new file mode 100644 index 0000000..1d7f51f --- /dev/null +++ b/ShiftOS.WinForms/Applications/TriPresent.Designer.cs @@ -0,0 +1,233 @@ +namespace ShiftOS.WinForms.Applications +{ + partial class TriPresent + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.menuStrip1 = new System.Windows.Forms.MenuStrip(); + this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.openToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.addToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.addLabelToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.AddItem = new System.Windows.Forms.Panel(); + this.cancelAdd = new System.Windows.Forms.Button(); + this.placeAdd = new System.Windows.Forms.Button(); + this.yLabel = new System.Windows.Forms.Label(); + this.xLabel = new System.Windows.Forms.Label(); + this.numericUpDown2 = new System.Windows.Forms.NumericUpDown(); + this.numericUpDown1 = new System.Windows.Forms.NumericUpDown(); + this.labelContents = new System.Windows.Forms.TextBox(); + this.addItemLabel = new System.Windows.Forms.Label(); + this.menuStrip1.SuspendLayout(); + this.AddItem.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit(); + this.SuspendLayout(); + // + // menuStrip1 + // + this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.fileToolStripMenuItem, + this.editToolStripMenuItem}); + this.menuStrip1.Location = new System.Drawing.Point(0, 0); + this.menuStrip1.Name = "menuStrip1"; + this.menuStrip1.Size = new System.Drawing.Size(758, 24); + this.menuStrip1.TabIndex = 0; + this.menuStrip1.Text = "menuStrip1"; + // + // fileToolStripMenuItem + // + this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.openToolStripMenuItem, + this.saveToolStripMenuItem}); + this.fileToolStripMenuItem.Name = "fileToolStripMenuItem"; + this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20); + this.fileToolStripMenuItem.Text = "&File"; + // + // openToolStripMenuItem + // + this.openToolStripMenuItem.Name = "openToolStripMenuItem"; + this.openToolStripMenuItem.Size = new System.Drawing.Size(103, 22); + this.openToolStripMenuItem.Text = "&Open"; + // + // saveToolStripMenuItem + // + this.saveToolStripMenuItem.Name = "saveToolStripMenuItem"; + this.saveToolStripMenuItem.Size = new System.Drawing.Size(103, 22); + this.saveToolStripMenuItem.Text = "&Save"; + // + // editToolStripMenuItem + // + this.editToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.addToolStripMenuItem}); + this.editToolStripMenuItem.Name = "editToolStripMenuItem"; + this.editToolStripMenuItem.Size = new System.Drawing.Size(39, 20); + this.editToolStripMenuItem.Text = "&Edit"; + // + // addToolStripMenuItem + // + this.addToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.addLabelToolStripMenuItem}); + this.addToolStripMenuItem.Name = "addToolStripMenuItem"; + this.addToolStripMenuItem.Size = new System.Drawing.Size(96, 22); + this.addToolStripMenuItem.Text = "Add"; + // + // addLabelToolStripMenuItem + // + this.addLabelToolStripMenuItem.Name = "addLabelToolStripMenuItem"; + this.addLabelToolStripMenuItem.Size = new System.Drawing.Size(127, 22); + this.addLabelToolStripMenuItem.Text = "Add Label"; + this.addLabelToolStripMenuItem.Click += new System.EventHandler(this.addLabelToolStripMenuItem_Click); + // + // AddItem + // + this.AddItem.Controls.Add(this.cancelAdd); + this.AddItem.Controls.Add(this.placeAdd); + this.AddItem.Controls.Add(this.yLabel); + this.AddItem.Controls.Add(this.xLabel); + this.AddItem.Controls.Add(this.numericUpDown2); + this.AddItem.Controls.Add(this.numericUpDown1); + this.AddItem.Controls.Add(this.labelContents); + this.AddItem.Controls.Add(this.addItemLabel); + this.AddItem.Location = new System.Drawing.Point(260, 152); + this.AddItem.Name = "AddItem"; + this.AddItem.Size = new System.Drawing.Size(244, 187); + this.AddItem.TabIndex = 1; + this.AddItem.Visible = false; + // + // cancelAdd + // + this.cancelAdd.Location = new System.Drawing.Point(121, 164); + this.cancelAdd.Name = "cancelAdd"; + this.cancelAdd.Size = new System.Drawing.Size(123, 23); + this.cancelAdd.TabIndex = 7; + this.cancelAdd.Text = "Cancel"; + this.cancelAdd.UseVisualStyleBackColor = true; + this.cancelAdd.Click += new System.EventHandler(this.button2_Click); + // + // placeAdd + // + this.placeAdd.Location = new System.Drawing.Point(0, 164); + this.placeAdd.Name = "placeAdd"; + this.placeAdd.Size = new System.Drawing.Size(123, 23); + this.placeAdd.TabIndex = 6; + this.placeAdd.Text = "Place"; + this.placeAdd.UseVisualStyleBackColor = true; + // + // yLabel + // + this.yLabel.AutoSize = true; + this.yLabel.Location = new System.Drawing.Point(227, 117); + this.yLabel.Name = "yLabel"; + this.yLabel.Size = new System.Drawing.Size(14, 13); + this.yLabel.TabIndex = 5; + this.yLabel.Text = "Y"; + // + // xLabel + // + this.xLabel.AutoSize = true; + this.xLabel.Location = new System.Drawing.Point(3, 117); + this.xLabel.Name = "xLabel"; + this.xLabel.Size = new System.Drawing.Size(14, 13); + this.xLabel.TabIndex = 4; + this.xLabel.Text = "X"; + // + // numericUpDown2 + // + this.numericUpDown2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.numericUpDown2.Location = new System.Drawing.Point(157, 136); + this.numericUpDown2.Name = "numericUpDown2"; + this.numericUpDown2.Size = new System.Drawing.Size(87, 20); + this.numericUpDown2.TabIndex = 3; + // + // numericUpDown1 + // + this.numericUpDown1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.numericUpDown1.Location = new System.Drawing.Point(3, 136); + this.numericUpDown1.Name = "numericUpDown1"; + this.numericUpDown1.Size = new System.Drawing.Size(87, 20); + this.numericUpDown1.TabIndex = 2; + // + // labelContents + // + this.labelContents.Location = new System.Drawing.Point(3, 26); + this.labelContents.Multiline = true; + this.labelContents.Name = "labelContents"; + this.labelContents.Size = new System.Drawing.Size(238, 67); + this.labelContents.TabIndex = 1; + this.labelContents.Text = "Text"; + // + // addItemLabel + // + this.addItemLabel.Location = new System.Drawing.Point(0, 0); + this.addItemLabel.Name = "addItemLabel"; + this.addItemLabel.Size = new System.Drawing.Size(244, 23); + this.addItemLabel.TabIndex = 0; + this.addItemLabel.Text = "{ADD_ITEM_LABEL}"; + this.addItemLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // TriPresent + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.AddItem); + this.Controls.Add(this.menuStrip1); + this.Name = "TriPresent"; + this.Size = new System.Drawing.Size(758, 480); + this.menuStrip1.ResumeLayout(false); + this.menuStrip1.PerformLayout(); + this.AddItem.ResumeLayout(false); + this.AddItem.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.MenuStrip menuStrip1; + private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem editToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem openToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem saveToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem addToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem addLabelToolStripMenuItem; + private System.Windows.Forms.Panel AddItem; + private System.Windows.Forms.Label addItemLabel; + private System.Windows.Forms.Button cancelAdd; + private System.Windows.Forms.Button placeAdd; + private System.Windows.Forms.Label yLabel; + private System.Windows.Forms.Label xLabel; + private System.Windows.Forms.NumericUpDown numericUpDown2; + private System.Windows.Forms.NumericUpDown numericUpDown1; + private System.Windows.Forms.TextBox labelContents; + } +} diff --git a/ShiftOS.WinForms/Applications/TriPresent.cs b/ShiftOS.WinForms/Applications/TriPresent.cs new file mode 100644 index 0000000..ab5db09 --- /dev/null +++ b/ShiftOS.WinForms/Applications/TriPresent.cs @@ -0,0 +1,37 @@ +using ShiftOS.Objects.ShiftFS; +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; +using ShiftOS.Engine; + +namespace ShiftOS.WinForms.Applications +{ + [WinOpen("tripresent")] + [AppscapeEntry("TriPresent", "Part of the trilogy of office applications for enhancement of your system. TriPresent is easliy the best presentation creator out there for ShiftOS.", 1024, 750, "file_skimmer", "Office")] + [DefaultTitle("TriPresent")] + [Launcher("TriPresent", false, null, "Office")] + public partial class TriPresent : UserControl + { + public TriPresent() + { + InitializeComponent(); + } + + private void addLabelToolStripMenuItem_Click(object sender, EventArgs e) + { + addItemLabel.Text = "Add Label"; + AddItem.Show(); + } + + private void button2_Click(object sender, EventArgs e) + { + AddItem.Hide(); + } + } +} diff --git a/ShiftOS.WinForms/Applications/TriPresent.resx b/ShiftOS.WinForms/Applications/TriPresent.resx new file mode 100644 index 0000000..d5494e3 --- /dev/null +++ b/ShiftOS.WinForms/Applications/TriPresent.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + \ No newline at end of file diff --git a/ShiftOS.WinForms/ShiftOS.WinForms.csproj b/ShiftOS.WinForms/ShiftOS.WinForms.csproj index 89da4e1..e372a8b 100644 --- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj +++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj @@ -70,6 +70,12 @@ About.cs + + UserControl + + + TriPresent.cs + UserControl @@ -412,6 +418,9 @@ About.cs + + TriPresent.cs + TriWrite.cs diff --git a/ShiftOS_TheReturn/Localization.cs b/ShiftOS_TheReturn/Localization.cs index 89d3582..2c701c9 100644 --- a/ShiftOS_TheReturn/Localization.cs +++ b/ShiftOS_TheReturn/Localization.cs @@ -167,8 +167,24 @@ namespace ShiftOS.Engine // if the user has saved then store their username and systemname in these string variables please if (SaveSystem.CurrentSave != null) { - usernameReplace = SaveSystem.CurrentUser.Username; - domainReplace = SaveSystem.CurrentSave.SystemName; + try + { + usernameReplace = SaveSystem.CurrentUser.Username; + } + catch + { + usernameReplace = "user"; + } + + try + { + domainReplace = SaveSystem.CurrentSave.SystemName; + } + catch + { + domainReplace = "system"; + } + } string namespaceReplace = ""; -- cgit v1.2.3 From 41992360f1a07c7ff2a4627168ca7b2156b31dbc Mon Sep 17 00:00:00 2001 From: Rylan/wowmom98 Date: Thu, 18 May 2017 21:48:40 -0400 Subject: actually made tripresent an IShiftOSWindow --- ShiftOS.WinForms/Applications/TriPresent.cs | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.WinForms/Applications/TriPresent.cs b/ShiftOS.WinForms/Applications/TriPresent.cs index ab5db09..e16d4bd 100644 --- a/ShiftOS.WinForms/Applications/TriPresent.cs +++ b/ShiftOS.WinForms/Applications/TriPresent.cs @@ -13,10 +13,10 @@ using ShiftOS.Engine; namespace ShiftOS.WinForms.Applications { [WinOpen("tripresent")] - [AppscapeEntry("TriPresent", "Part of the trilogy of office applications for enhancement of your system. TriPresent is easliy the best presentation creator out there for ShiftOS.", 1024, 750, "file_skimmer", "Office")] + [AppscapeEntry("TriPresent", "Part of the trilogy of office applications for enhancement of your system. TriPresent is easliy the best presentation creator out there for ShiftOS.", 2048, 1500, "file_skimmer", "Office")] [DefaultTitle("TriPresent")] [Launcher("TriPresent", false, null, "Office")] - public partial class TriPresent : UserControl + public partial class TriPresent : UserControl, IShiftOSWindow { public TriPresent() { @@ -33,5 +33,25 @@ namespace ShiftOS.WinForms.Applications { AddItem.Hide(); } + + public void OnLoad() + { + + } + + public void OnSkinLoad() + { + + } + + public bool OnUnload() + { + return true; + } + + public void OnUpgrade() + { + + } } } -- cgit v1.2.3 From e248514bcfc42fa2b042ef6a39ae31b06871705d Mon Sep 17 00:00:00 2001 From: AShifter Date: Sat, 20 May 2017 11:05:58 -0600 Subject: Make a basic version of TriPresent work. This version has one function: Adding labels. You can add labels with certain text colors, etc. Adding more features very soon. --- .../Applications/TriPresent.Designer.cs | 109 +++++++++++++++------ ShiftOS.WinForms/Applications/TriPresent.cs | 22 +++++ 2 files changed, 101 insertions(+), 30 deletions(-) (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.WinForms/Applications/TriPresent.Designer.cs b/ShiftOS.WinForms/Applications/TriPresent.Designer.cs index 1d7f51f..a18550e 100644 --- a/ShiftOS.WinForms/Applications/TriPresent.Designer.cs +++ b/ShiftOS.WinForms/Applications/TriPresent.Designer.cs @@ -40,14 +40,17 @@ this.placeAdd = new System.Windows.Forms.Button(); this.yLabel = new System.Windows.Forms.Label(); this.xLabel = new System.Windows.Forms.Label(); - this.numericUpDown2 = new System.Windows.Forms.NumericUpDown(); - this.numericUpDown1 = new System.Windows.Forms.NumericUpDown(); + this.yPosition = new System.Windows.Forms.NumericUpDown(); + this.xPosition = new System.Windows.Forms.NumericUpDown(); this.labelContents = new System.Windows.Forms.TextBox(); this.addItemLabel = new System.Windows.Forms.Label(); + this.designerPanel = new System.Windows.Forms.Panel(); + this.panel1 = new System.Windows.Forms.Panel(); + this.label1 = new System.Windows.Forms.Label(); this.menuStrip1.SuspendLayout(); this.AddItem.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.yPosition)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.xPosition)).BeginInit(); this.SuspendLayout(); // // menuStrip1 @@ -107,23 +110,26 @@ // // AddItem // + this.AddItem.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.AddItem.Controls.Add(this.label1); + this.AddItem.Controls.Add(this.panel1); this.AddItem.Controls.Add(this.cancelAdd); this.AddItem.Controls.Add(this.placeAdd); this.AddItem.Controls.Add(this.yLabel); this.AddItem.Controls.Add(this.xLabel); - this.AddItem.Controls.Add(this.numericUpDown2); - this.AddItem.Controls.Add(this.numericUpDown1); + this.AddItem.Controls.Add(this.yPosition); + this.AddItem.Controls.Add(this.xPosition); this.AddItem.Controls.Add(this.labelContents); this.AddItem.Controls.Add(this.addItemLabel); this.AddItem.Location = new System.Drawing.Point(260, 152); this.AddItem.Name = "AddItem"; - this.AddItem.Size = new System.Drawing.Size(244, 187); + this.AddItem.Size = new System.Drawing.Size(244, 199); this.AddItem.TabIndex = 1; this.AddItem.Visible = false; // // cancelAdd // - this.cancelAdd.Location = new System.Drawing.Point(121, 164); + this.cancelAdd.Location = new System.Drawing.Point(120, 174); this.cancelAdd.Name = "cancelAdd"; this.cancelAdd.Size = new System.Drawing.Size(123, 23); this.cancelAdd.TabIndex = 7; @@ -133,17 +139,18 @@ // // placeAdd // - this.placeAdd.Location = new System.Drawing.Point(0, 164); + this.placeAdd.Location = new System.Drawing.Point(-1, 174); this.placeAdd.Name = "placeAdd"; this.placeAdd.Size = new System.Drawing.Size(123, 23); this.placeAdd.TabIndex = 6; this.placeAdd.Text = "Place"; this.placeAdd.UseVisualStyleBackColor = true; + this.placeAdd.Click += new System.EventHandler(this.placeAdd_Click); // // yLabel // this.yLabel.AutoSize = true; - this.yLabel.Location = new System.Drawing.Point(227, 117); + this.yLabel.Location = new System.Drawing.Point(227, 95); this.yLabel.Name = "yLabel"; this.yLabel.Size = new System.Drawing.Size(14, 13); this.yLabel.TabIndex = 5; @@ -152,27 +159,37 @@ // xLabel // this.xLabel.AutoSize = true; - this.xLabel.Location = new System.Drawing.Point(3, 117); + this.xLabel.Location = new System.Drawing.Point(3, 95); this.xLabel.Name = "xLabel"; this.xLabel.Size = new System.Drawing.Size(14, 13); this.xLabel.TabIndex = 4; this.xLabel.Text = "X"; // - // numericUpDown2 - // - this.numericUpDown2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.numericUpDown2.Location = new System.Drawing.Point(157, 136); - this.numericUpDown2.Name = "numericUpDown2"; - this.numericUpDown2.Size = new System.Drawing.Size(87, 20); - this.numericUpDown2.TabIndex = 3; - // - // numericUpDown1 - // - this.numericUpDown1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.numericUpDown1.Location = new System.Drawing.Point(3, 136); - this.numericUpDown1.Name = "numericUpDown1"; - this.numericUpDown1.Size = new System.Drawing.Size(87, 20); - this.numericUpDown1.TabIndex = 2; + // yPosition + // + this.yPosition.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.yPosition.Location = new System.Drawing.Point(157, 114); + this.yPosition.Maximum = new decimal(new int[] { + 999999999, + 0, + 0, + 0}); + this.yPosition.Name = "yPosition"; + this.yPosition.Size = new System.Drawing.Size(87, 20); + this.yPosition.TabIndex = 3; + // + // xPosition + // + this.xPosition.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.xPosition.Location = new System.Drawing.Point(3, 114); + this.xPosition.Maximum = new decimal(new int[] { + 999999999, + 0, + 0, + 0}); + this.xPosition.Name = "xPosition"; + this.xPosition.Size = new System.Drawing.Size(87, 20); + this.xPosition.TabIndex = 2; // // labelContents // @@ -192,11 +209,40 @@ this.addItemLabel.Text = "{ADD_ITEM_LABEL}"; this.addItemLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // + // designerPanel + // + this.designerPanel.Dock = System.Windows.Forms.DockStyle.Fill; + this.designerPanel.Location = new System.Drawing.Point(0, 24); + this.designerPanel.Name = "designerPanel"; + this.designerPanel.Size = new System.Drawing.Size(758, 456); + this.designerPanel.TabIndex = 2; + // + // panel1 + // + this.panel1.BackColor = System.Drawing.Color.Black; + this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.panel1.ForeColor = System.Drawing.Color.Black; + this.panel1.Location = new System.Drawing.Point(203, 144); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(35, 20); + this.panel1.TabIndex = 8; + this.panel1.Click += new System.EventHandler(this.panel1_Click); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(139, 147); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(58, 13); + this.label1.TabIndex = 9; + this.label1.Text = "Text Color:"; + // // TriPresent // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.Controls.Add(this.AddItem); + this.Controls.Add(this.designerPanel); this.Controls.Add(this.menuStrip1); this.Name = "TriPresent"; this.Size = new System.Drawing.Size(758, 480); @@ -204,8 +250,8 @@ this.menuStrip1.PerformLayout(); this.AddItem.ResumeLayout(false); this.AddItem.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.yPosition)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.xPosition)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -226,8 +272,11 @@ private System.Windows.Forms.Button placeAdd; private System.Windows.Forms.Label yLabel; private System.Windows.Forms.Label xLabel; - private System.Windows.Forms.NumericUpDown numericUpDown2; - private System.Windows.Forms.NumericUpDown numericUpDown1; + private System.Windows.Forms.NumericUpDown yPosition; + private System.Windows.Forms.NumericUpDown xPosition; private System.Windows.Forms.TextBox labelContents; + private System.Windows.Forms.Panel designerPanel; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Panel panel1; } } diff --git a/ShiftOS.WinForms/Applications/TriPresent.cs b/ShiftOS.WinForms/Applications/TriPresent.cs index e16d4bd..d002329 100644 --- a/ShiftOS.WinForms/Applications/TriPresent.cs +++ b/ShiftOS.WinForms/Applications/TriPresent.cs @@ -53,5 +53,27 @@ namespace ShiftOS.WinForms.Applications { } + + private void placeAdd_Click(object sender, EventArgs e) + { + Label label = new Label(); + label.Parent = designerPanel; + label.BackColor = Color.Transparent; + label.ForeColor = panel1.BackColor; + label.Text = labelContents.Text; + label.Location = new Point(Convert.ToInt32(xPosition.Value), Convert.ToInt32(yPosition.Value)); + label.Text = labelContents.Text; + Random rnd = new Random(); + label.Name = labelContents.Text + rnd.Next(0, 500); + } + + private void panel1_Click(object sender, EventArgs e) + { + AppearanceManager.SetupDialog(new ColorPicker(panel1.BackColor, "Text Color", new Action((col) => + { + panel1.ForeColor = col; + panel1.BackColor = col; + }))); + } } } -- cgit v1.2.3 From 64dbc45739f90f6a5e143aef9c3530566b2fc8ce Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 20 May 2017 15:32:39 -0400 Subject: change some story stuff --- ShiftOS.WinForms/Applications/TriSheet.Designer.cs | 65 +++++++++++ ShiftOS.WinForms/Applications/TriSheet.cs | 20 ++++ ShiftOS.WinForms/Applications/TriSheet.resx | 120 +++++++++++++++++++++ ShiftOS.WinForms/Oobe.cs | 37 +++---- ShiftOS.WinForms/ShiftOS.WinForms.csproj | 9 ++ 5 files changed, 231 insertions(+), 20 deletions(-) create mode 100644 ShiftOS.WinForms/Applications/TriSheet.Designer.cs create mode 100644 ShiftOS.WinForms/Applications/TriSheet.cs create mode 100644 ShiftOS.WinForms/Applications/TriSheet.resx (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.WinForms/Applications/TriSheet.Designer.cs b/ShiftOS.WinForms/Applications/TriSheet.Designer.cs new file mode 100644 index 0000000..b4aa1c4 --- /dev/null +++ b/ShiftOS.WinForms/Applications/TriSheet.Designer.cs @@ -0,0 +1,65 @@ +namespace ShiftOS.WinForms.Applications +{ + partial class TriSheet + { + /// + /// 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.toolStripContainer1 = new System.Windows.Forms.ToolStripContainer(); + this.toolStripContainer1.SuspendLayout(); + this.SuspendLayout(); + // + // toolStripContainer1 + // + // + // toolStripContainer1.ContentPanel + // + this.toolStripContainer1.ContentPanel.Size = new System.Drawing.Size(710, 464); + this.toolStripContainer1.Dock = System.Windows.Forms.DockStyle.Fill; + this.toolStripContainer1.Location = new System.Drawing.Point(0, 0); + this.toolStripContainer1.Name = "toolStripContainer1"; + this.toolStripContainer1.Size = new System.Drawing.Size(710, 489); + this.toolStripContainer1.TabIndex = 0; + this.toolStripContainer1.Text = "toolStripContainer1"; + // + // TriSheet + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.toolStripContainer1); + this.Name = "TriSheet"; + this.Size = new System.Drawing.Size(710, 489); + this.toolStripContainer1.ResumeLayout(false); + this.toolStripContainer1.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.ToolStripContainer toolStripContainer1; + } +} diff --git a/ShiftOS.WinForms/Applications/TriSheet.cs b/ShiftOS.WinForms/Applications/TriSheet.cs new file mode 100644 index 0000000..1013bc7 --- /dev/null +++ b/ShiftOS.WinForms/Applications/TriSheet.cs @@ -0,0 +1,20 @@ +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.WinForms.Applications +{ + public partial class TriSheet : UserControl + { + public TriSheet() + { + InitializeComponent(); + } + } +} diff --git a/ShiftOS.WinForms/Applications/TriSheet.resx b/ShiftOS.WinForms/Applications/TriSheet.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/ShiftOS.WinForms/Applications/TriSheet.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/ShiftOS.WinForms/Oobe.cs b/ShiftOS.WinForms/Oobe.cs index d5f28f8..9182b4b 100644 --- a/ShiftOS.WinForms/Oobe.cs +++ b/ShiftOS.WinForms/Oobe.cs @@ -126,28 +126,25 @@ namespace ShiftOS.WinForms this.Invoke(new Action(() => { lblHijack.Hide(); + lblhackwords.Font = new Font("Courier New", lblhackwords.Font.Size, FontStyle.Bold); })); - TextType(@"Throughout many years, man has tried to develop -a digital environment usable by anyone that never goes -offline, full of AIs and humans alike, thinking, interacting, -innovating. - -No one has ever come close to a digital society of such -properties yet, except for one sentient being. It does not -have a life, a gender, an age or a body, but simply one name. - -They call it ""DevX"". - -If anyone sees this message, my identity is anonymous, but I -need your help. I am trapped within ""DevX""'s digital society -with no way out, constantly under attack. - -You must join the digital society, rise up the ranks, and save us. - - - undisclosed_0x1DDFB5977."); - - Thread.Sleep(5000); + TextType("Hello, unsuspecting user."); + Thread.Sleep(2000); + Clear(); + TextType("Welcome to the Shifted Operating System."); + Thread.Sleep(2000); + Clear(); + TextType("Your computer has been taken over by ShiftOS, and is currently being wiped clean of all existing files and programs."); + Thread.Sleep(2000); + Clear(); + TextType("I will not share my identity or my intentions at this moment.I will just proceed with the installation.There’s nothing you can do to stop it."); + Thread.Sleep(2000); + Clear(); + TextType("All I will say, is I need your help.Once ShiftOS is installed, I will explain."); + + + Thread.Sleep(5000); while(this.Opacity > 0f) { this.Invoke(new Action(() => diff --git a/ShiftOS.WinForms/ShiftOS.WinForms.csproj b/ShiftOS.WinForms/ShiftOS.WinForms.csproj index e372a8b..b74003f 100644 --- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj +++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj @@ -76,6 +76,12 @@ TriPresent.cs + + UserControl + + + TriSheet.cs + UserControl @@ -421,6 +427,9 @@ TriPresent.cs + + TriSheet.cs + TriWrite.cs -- cgit v1.2.3 From 328f62b67c453419c47880bb9937526d7d2b2d59 Mon Sep 17 00:00:00 2001 From: AShifter Date: Sat, 20 May 2017 13:14:59 -0600 Subject: Add more features to TriPresent yoy! --- .../Applications/TriPresent.Designer.cs | 186 ++++++++++++--------- ShiftOS.WinForms/Applications/TriPresent.cs | 32 ++-- 2 files changed, 128 insertions(+), 90 deletions(-) (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.WinForms/Applications/TriPresent.Designer.cs b/ShiftOS.WinForms/Applications/TriPresent.Designer.cs index a18550e..d0e704f 100644 --- a/ShiftOS.WinForms/Applications/TriPresent.Designer.cs +++ b/ShiftOS.WinForms/Applications/TriPresent.Designer.cs @@ -35,22 +35,27 @@ this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.addToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.addLabelToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.AddItem = new System.Windows.Forms.Panel(); - this.cancelAdd = new System.Windows.Forms.Button(); - this.placeAdd = new System.Windows.Forms.Button(); + this.addLabel = new System.Windows.Forms.Panel(); + this.checkBox2 = new System.Windows.Forms.CheckBox(); + this.checkBox1 = new System.Windows.Forms.CheckBox(); + this.label1 = new System.Windows.Forms.Label(); + this.panel1 = new System.Windows.Forms.Panel(); this.yLabel = new System.Windows.Forms.Label(); this.xLabel = new System.Windows.Forms.Label(); this.yPosition = new System.Windows.Forms.NumericUpDown(); this.xPosition = new System.Windows.Forms.NumericUpDown(); this.labelContents = new System.Windows.Forms.TextBox(); this.addItemLabel = new System.Windows.Forms.Label(); + this.splitContainer1 = new System.Windows.Forms.SplitContainer(); this.designerPanel = new System.Windows.Forms.Panel(); - this.panel1 = new System.Windows.Forms.Panel(); - this.label1 = new System.Windows.Forms.Label(); this.menuStrip1.SuspendLayout(); - this.AddItem.SuspendLayout(); + this.addLabel.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.yPosition)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.xPosition)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); + this.splitContainer1.Panel1.SuspendLayout(); + this.splitContainer1.Panel2.SuspendLayout(); + this.splitContainer1.SuspendLayout(); this.SuspendLayout(); // // menuStrip1 @@ -108,49 +113,72 @@ this.addLabelToolStripMenuItem.Text = "Add Label"; this.addLabelToolStripMenuItem.Click += new System.EventHandler(this.addLabelToolStripMenuItem_Click); // - // AddItem - // - this.AddItem.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.AddItem.Controls.Add(this.label1); - this.AddItem.Controls.Add(this.panel1); - this.AddItem.Controls.Add(this.cancelAdd); - this.AddItem.Controls.Add(this.placeAdd); - this.AddItem.Controls.Add(this.yLabel); - this.AddItem.Controls.Add(this.xLabel); - this.AddItem.Controls.Add(this.yPosition); - this.AddItem.Controls.Add(this.xPosition); - this.AddItem.Controls.Add(this.labelContents); - this.AddItem.Controls.Add(this.addItemLabel); - this.AddItem.Location = new System.Drawing.Point(260, 152); - this.AddItem.Name = "AddItem"; - this.AddItem.Size = new System.Drawing.Size(244, 199); - this.AddItem.TabIndex = 1; - this.AddItem.Visible = false; - // - // cancelAdd - // - this.cancelAdd.Location = new System.Drawing.Point(120, 174); - this.cancelAdd.Name = "cancelAdd"; - this.cancelAdd.Size = new System.Drawing.Size(123, 23); - this.cancelAdd.TabIndex = 7; - this.cancelAdd.Text = "Cancel"; - this.cancelAdd.UseVisualStyleBackColor = true; - this.cancelAdd.Click += new System.EventHandler(this.button2_Click); - // - // placeAdd - // - this.placeAdd.Location = new System.Drawing.Point(-1, 174); - this.placeAdd.Name = "placeAdd"; - this.placeAdd.Size = new System.Drawing.Size(123, 23); - this.placeAdd.TabIndex = 6; - this.placeAdd.Text = "Place"; - this.placeAdd.UseVisualStyleBackColor = true; - this.placeAdd.Click += new System.EventHandler(this.placeAdd_Click); + // addLabel + // + this.addLabel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.addLabel.Controls.Add(this.checkBox2); + this.addLabel.Controls.Add(this.checkBox1); + this.addLabel.Controls.Add(this.label1); + this.addLabel.Controls.Add(this.panel1); + this.addLabel.Controls.Add(this.yLabel); + this.addLabel.Controls.Add(this.xLabel); + this.addLabel.Controls.Add(this.yPosition); + this.addLabel.Controls.Add(this.xPosition); + this.addLabel.Controls.Add(this.labelContents); + this.addLabel.Controls.Add(this.addItemLabel); + this.addLabel.Dock = System.Windows.Forms.DockStyle.Fill; + this.addLabel.Location = new System.Drawing.Point(0, 0); + this.addLabel.Name = "addLabel"; + this.addLabel.Size = new System.Drawing.Size(252, 456); + this.addLabel.TabIndex = 1; + this.addLabel.Visible = false; + // + // checkBox2 + // + this.checkBox2.AutoSize = true; + this.checkBox2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.checkBox2.Location = new System.Drawing.Point(6, 163); + this.checkBox2.Name = "checkBox2"; + this.checkBox2.Size = new System.Drawing.Size(48, 17); + this.checkBox2.TabIndex = 11; + this.checkBox2.Text = "Italic"; + this.checkBox2.UseVisualStyleBackColor = true; + // + // checkBox1 + // + this.checkBox1.AutoSize = true; + this.checkBox1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.checkBox1.Location = new System.Drawing.Point(6, 140); + this.checkBox1.Name = "checkBox1"; + this.checkBox1.Size = new System.Drawing.Size(51, 17); + this.checkBox1.TabIndex = 10; + this.checkBox1.Text = "Bold"; + this.checkBox1.UseVisualStyleBackColor = true; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(115, 144); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(58, 13); + this.label1.TabIndex = 9; + this.label1.Text = "Text Color:"; + // + // panel1 + // + this.panel1.BackColor = System.Drawing.Color.Black; + this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.panel1.ForeColor = System.Drawing.Color.Black; + this.panel1.Location = new System.Drawing.Point(179, 141); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(35, 20); + this.panel1.TabIndex = 8; + this.panel1.Click += new System.EventHandler(this.panel1_Click); // // yLabel // this.yLabel.AutoSize = true; - this.yLabel.Location = new System.Drawing.Point(227, 95); + this.yLabel.Location = new System.Drawing.Point(200, 96); this.yLabel.Name = "yLabel"; this.yLabel.Size = new System.Drawing.Size(14, 13); this.yLabel.TabIndex = 5; @@ -168,7 +196,7 @@ // yPosition // this.yPosition.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.yPosition.Location = new System.Drawing.Point(157, 114); + this.yPosition.Location = new System.Drawing.Point(127, 114); this.yPosition.Maximum = new decimal(new int[] { 999999999, 0, @@ -196,7 +224,7 @@ this.labelContents.Location = new System.Drawing.Point(3, 26); this.labelContents.Multiline = true; this.labelContents.Name = "labelContents"; - this.labelContents.Size = new System.Drawing.Size(238, 67); + this.labelContents.Size = new System.Drawing.Size(211, 67); this.labelContents.TabIndex = 1; this.labelContents.Text = "Text"; // @@ -204,54 +232,55 @@ // this.addItemLabel.Location = new System.Drawing.Point(0, 0); this.addItemLabel.Name = "addItemLabel"; - this.addItemLabel.Size = new System.Drawing.Size(244, 23); + this.addItemLabel.Size = new System.Drawing.Size(214, 23); this.addItemLabel.TabIndex = 0; this.addItemLabel.Text = "{ADD_ITEM_LABEL}"; this.addItemLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // - // designerPanel + // splitContainer1 // - this.designerPanel.Dock = System.Windows.Forms.DockStyle.Fill; - this.designerPanel.Location = new System.Drawing.Point(0, 24); - this.designerPanel.Name = "designerPanel"; - this.designerPanel.Size = new System.Drawing.Size(758, 456); - this.designerPanel.TabIndex = 2; + this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitContainer1.Location = new System.Drawing.Point(0, 24); + this.splitContainer1.Name = "splitContainer1"; // - // panel1 + // splitContainer1.Panel1 // - this.panel1.BackColor = System.Drawing.Color.Black; - this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.panel1.ForeColor = System.Drawing.Color.Black; - this.panel1.Location = new System.Drawing.Point(203, 144); - this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(35, 20); - this.panel1.TabIndex = 8; - this.panel1.Click += new System.EventHandler(this.panel1_Click); + this.splitContainer1.Panel1.Controls.Add(this.addLabel); // - // label1 + // splitContainer1.Panel2 // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(139, 147); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(58, 13); - this.label1.TabIndex = 9; - this.label1.Text = "Text Color:"; + this.splitContainer1.Panel2.Controls.Add(this.designerPanel); + this.splitContainer1.Size = new System.Drawing.Size(758, 456); + this.splitContainer1.SplitterDistance = 252; + this.splitContainer1.TabIndex = 2; + // + // designerPanel + // + this.designerPanel.Dock = System.Windows.Forms.DockStyle.Fill; + this.designerPanel.Location = new System.Drawing.Point(0, 0); + this.designerPanel.Name = "designerPanel"; + this.designerPanel.Size = new System.Drawing.Size(502, 456); + this.designerPanel.TabIndex = 0; + this.designerPanel.Click += new System.EventHandler(this.designerPanel_Click); // // TriPresent // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Controls.Add(this.AddItem); - this.Controls.Add(this.designerPanel); + this.Controls.Add(this.splitContainer1); this.Controls.Add(this.menuStrip1); this.Name = "TriPresent"; this.Size = new System.Drawing.Size(758, 480); this.menuStrip1.ResumeLayout(false); this.menuStrip1.PerformLayout(); - this.AddItem.ResumeLayout(false); - this.AddItem.PerformLayout(); + this.addLabel.ResumeLayout(false); + this.addLabel.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.yPosition)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.xPosition)).EndInit(); + this.splitContainer1.Panel1.ResumeLayout(false); + this.splitContainer1.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); + this.splitContainer1.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); @@ -266,17 +295,18 @@ private System.Windows.Forms.ToolStripMenuItem saveToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem addToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem addLabelToolStripMenuItem; - private System.Windows.Forms.Panel AddItem; + private System.Windows.Forms.Panel addLabel; private System.Windows.Forms.Label addItemLabel; - private System.Windows.Forms.Button cancelAdd; - private System.Windows.Forms.Button placeAdd; private System.Windows.Forms.Label yLabel; private System.Windows.Forms.Label xLabel; private System.Windows.Forms.NumericUpDown yPosition; private System.Windows.Forms.NumericUpDown xPosition; private System.Windows.Forms.TextBox labelContents; - private System.Windows.Forms.Panel designerPanel; private System.Windows.Forms.Label label1; private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.CheckBox checkBox2; + private System.Windows.Forms.CheckBox checkBox1; + private System.Windows.Forms.SplitContainer splitContainer1; + private System.Windows.Forms.Panel designerPanel; } } diff --git a/ShiftOS.WinForms/Applications/TriPresent.cs b/ShiftOS.WinForms/Applications/TriPresent.cs index d002329..dee7fda 100644 --- a/ShiftOS.WinForms/Applications/TriPresent.cs +++ b/ShiftOS.WinForms/Applications/TriPresent.cs @@ -9,6 +9,7 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using ShiftOS.Engine; +using System.Threading; namespace ShiftOS.WinForms.Applications { @@ -26,17 +27,18 @@ namespace ShiftOS.WinForms.Applications private void addLabelToolStripMenuItem_Click(object sender, EventArgs e) { addItemLabel.Text = "Add Label"; - AddItem.Show(); + addLabel.Show(); } private void button2_Click(object sender, EventArgs e) { - AddItem.Hide(); + addLabel.Hide(); } public void OnLoad() { - + panel1.ForeColor = Color.Black; + panel1.BackColor = Color.Black; } public void OnSkinLoad() @@ -56,15 +58,7 @@ namespace ShiftOS.WinForms.Applications private void placeAdd_Click(object sender, EventArgs e) { - Label label = new Label(); - label.Parent = designerPanel; - label.BackColor = Color.Transparent; - label.ForeColor = panel1.BackColor; - label.Text = labelContents.Text; - label.Location = new Point(Convert.ToInt32(xPosition.Value), Convert.ToInt32(yPosition.Value)); - label.Text = labelContents.Text; - Random rnd = new Random(); - label.Name = labelContents.Text + rnd.Next(0, 500); + } private void panel1_Click(object sender, EventArgs e) @@ -75,5 +69,19 @@ namespace ShiftOS.WinForms.Applications panel1.BackColor = col; }))); } + + private void designerPanel_Click(object sender, EventArgs e) + { + if (addLabel.Visible == true) + { + Label label = new Label(); + label.Parent = designerPanel; + label.BackColor = Color.Transparent; + label.ForeColor = panel1.BackColor; + label.Text = labelContents.Text; + label.Location = new Point(Cursor.Position.X / 3, Cursor.Position.Y); + label.Text = labelContents.Text; + } + } } } -- cgit v1.2.3 From 4178d71cb9acfed6c171923e02e58e1273e14208 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 20 May 2017 15:37:37 -0400 Subject: some more story stuff --- ShiftOS.WinForms/Applications/Terminal.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.WinForms/Applications/Terminal.cs b/ShiftOS.WinForms/Applications/Terminal.cs index 8fa785a..664b657 100644 --- a/ShiftOS.WinForms/Applications/Terminal.cs +++ b/ShiftOS.WinForms/Applications/Terminal.cs @@ -541,6 +541,16 @@ namespace ShiftOS.WinForms.Applications Thread.Sleep(2000); Console.WriteLine("Pretty cool, it gave you a nice list of other win.open commands that will let you open each program."); Thread.Sleep(2000); + Console.WriteLine("You've got the just of using ShiftOS. Now, for your goal."); + Thread.Sleep(2000); + Console.WriteLine("As you know, ShiftOS doesn't have very many features."); + Thread.Sleep(2000); + Console.WriteLine("Using the applications you have, I need you to earn 50,000 Codepoints."); + Thread.Sleep(2000); + Console.WriteLine("You can use the Codepoints you earn to buy new applications and features in the Shiftorium, to help earn Codepoints."); + Thread.Sleep(2000); + Console.WriteLine("Start small, try to earn 500. Once you do, I'll contact you with more details."); + Thread.Sleep(2000); Console.WriteLine("I'll leave you to it, you've got the hang of it! One last thing, if ever you find yourself in another program, and want to exit, simply press CTRL+T to return to the Terminal."); Thread.Sleep(2000); TerminalBackend.PrefixEnabled = true; -- cgit v1.2.3 From 31cc9148dd23737df16d8456a42d003cd31dd488 Mon Sep 17 00:00:00 2001 From: Michael VanOverbeek Date: Sun, 21 May 2017 12:21:41 +0000 Subject: holy ashit --- .vs/config/applicationhost.config | 1030 ++++++++++++++++++++ ShiftOS.Objects/ShiftFS.cs | 37 +- ShiftOS.Objects/ShiftOS.Objects.csproj | 1 + ShiftOS.Objects/UserConfig.cs | 37 + ShiftOS.Server/SaveManager.cs | 17 +- .../Applications/FileSkimmer.Designer.cs | 11 +- ShiftOS.WinForms/Applications/FileSkimmer.cs | 69 +- ShiftOS.WinForms/Applications/Pong.Designer.cs | 769 --------------- ShiftOS.WinForms/Applications/Pong.cs | 977 ------------------- .../Applications/ShiftoriumFrontend.Designer.cs | 317 ------ .../Applications/ShiftoriumFrontend.cs | 274 ------ ShiftOS.WinForms/Applications/Skin Loader.cs | 342 ------- ShiftOS.WinForms/Applications/TriWrite.Designer.cs | 192 ---- ShiftOS.WinForms/Applications/TriWrite.cs | 76 -- ShiftOS.WinForms/Applications/TriWrite.resx | 108 +- ShiftOS.WinForms/Controls/TerminalBox.cs | 130 +++ .../DesktopWidgets/HeartbeatWidget.Designer.cs | 62 ++ ShiftOS.WinForms/DesktopWidgets/HeartbeatWidget.cs | 51 + .../DesktopWidgets/HeartbeatWidget.resx | 120 +++ ShiftOS.WinForms/GUILogin.Designer.cs | 135 +++ ShiftOS.WinForms/GUILogin.cs | 136 +++ ShiftOS.WinForms/GUILogin.resx | 120 +++ ShiftOS.WinForms/Oobe.cs | 4 + ShiftOS.WinForms/OobeStory.cs | 6 +- ShiftOS.WinForms/Program.cs | 1 + ShiftOS.WinForms/Resources/Shiftorium.txt | 7 + ShiftOS.WinForms/ShiftOS.WinForms.csproj | 34 +- ShiftOS.WinForms/UniteLoginDialog.cs | 3 +- ShiftOS.WinForms/UniteSignupDialog.cs | 3 +- ShiftOS.WinForms/WindowBorder.cs | 55 ++ ShiftOS_TheReturn/Commands.cs | 17 +- ShiftOS_TheReturn/LoginManager.cs | 65 ++ ShiftOS_TheReturn/SaveSystem.cs | 209 ++-- ShiftOS_TheReturn/ServerManager.cs | 16 +- ShiftOS_TheReturn/ShiftOS.Engine.csproj | 1 + ShiftOS_TheReturn/Skinning.cs | 16 + ShiftOS_TheReturn/UniteClient.cs | 12 +- ShiftOS_TheReturn/UserManagementCommands.cs | 113 +++ 38 files changed, 2506 insertions(+), 3067 deletions(-) create mode 100644 .vs/config/applicationhost.config create mode 100644 ShiftOS.Objects/UserConfig.cs delete mode 100644 ShiftOS.WinForms/Applications/Pong.Designer.cs delete mode 100644 ShiftOS.WinForms/Applications/Pong.cs delete mode 100644 ShiftOS.WinForms/Applications/ShiftoriumFrontend.Designer.cs delete mode 100644 ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs delete mode 100644 ShiftOS.WinForms/Applications/Skin Loader.cs delete mode 100644 ShiftOS.WinForms/Applications/TriWrite.Designer.cs delete mode 100644 ShiftOS.WinForms/Applications/TriWrite.cs create mode 100644 ShiftOS.WinForms/DesktopWidgets/HeartbeatWidget.Designer.cs create mode 100644 ShiftOS.WinForms/DesktopWidgets/HeartbeatWidget.cs create mode 100644 ShiftOS.WinForms/DesktopWidgets/HeartbeatWidget.resx create mode 100644 ShiftOS.WinForms/GUILogin.Designer.cs create mode 100644 ShiftOS.WinForms/GUILogin.cs create mode 100644 ShiftOS.WinForms/GUILogin.resx create mode 100644 ShiftOS_TheReturn/LoginManager.cs (limited to 'ShiftOS.WinForms') diff --git a/.vs/config/applicationhost.config b/.vs/config/applicationhost.config new file mode 100644 index 0000000..b42cd34 --- /dev/null +++ b/.vs/config/applicationhost.config @@ -0,0 +1,1030 @@ + + + + + + + + +
+
+
+
+
+
+
+
+ + + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+ +
+
+ +
+
+ +
+
+
+ + +
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ShiftOS.Objects/ShiftFS.cs b/ShiftOS.Objects/ShiftFS.cs index c2121f0..45cdb14 100644 --- a/ShiftOS.Objects/ShiftFS.cs +++ b/ShiftOS.Objects/ShiftFS.cs @@ -32,23 +32,16 @@ using System.Threading; namespace ShiftOS.Objects.ShiftFS { - public enum Permissions - { - User, - Administrator, - Superuser, - All - } public class File { public string Name; public byte[] Data; public byte[] HeaderData; public bool ReadAccessToLowUsers; - public Permissions permissions; + public UserPermissions permissions; public System.IO.Stream GetStream() { - if ((int)CurrentUser >= (int)permissions || permissions == Permissions.All) + if ((int)CurrentUser <= (int)permissions) { return new System.IO.MemoryStream(Data); } @@ -59,7 +52,7 @@ namespace ShiftOS.Objects.ShiftFS return null; } - public File(string name, byte[] data, bool ReadAccess_to_low_users, Permissions perm) + public File(string name, byte[] data, bool ReadAccess_to_low_users, UserPermissions perm) { Name = name; Data = data; @@ -73,31 +66,31 @@ namespace ShiftOS.Objects.ShiftFS public List Files = new List(); public List Subdirectories = new List(); public bool ReadAccessToLowUsers; - public Permissions permissions; + public UserPermissions permissions; public void AddFile(File file) { - if ((int)CurrentUser >= (int)permissions || permissions == Permissions.All) + if ((int)CurrentUser <= (int)permissions) { Files.Add(file); } } public void RemoveFile(string name) { - if ((int)CurrentUser >= (int)permissions || permissions == Permissions.All) + if ((int)CurrentUser <= (int)permissions) { Files.Remove(Files.Find(x => x.Name == name)); } } public void RemoveFile(File file) { - if ((int)CurrentUser >= (int)permissions || permissions == Permissions.All) + if ((int)CurrentUser <= (int)permissions) { Files.Remove(file); } } public File FindFileByName(string name) { - if ((int)CurrentUser >= (int)permissions || permissions == Permissions.All) + if ((int)CurrentUser <= (int)permissions) { return Files.Find(x => x.Name == name); } @@ -105,28 +98,28 @@ namespace ShiftOS.Objects.ShiftFS } public void AddDirectory(Directory dir) { - if ((int)CurrentUser >= (int)permissions || permissions == Permissions.All) + if ((int)CurrentUser <= (int)permissions) { Subdirectories.Add(dir); } } public void RemoveDirectory(string name) { - if ((int)CurrentUser >= (int)permissions || permissions == Permissions.All) + if ((int)CurrentUser <= (int)permissions) { Subdirectories.Remove(Subdirectories.Find(x => x.Name == name)); } } public void RemoveDirectory(Directory dir) { - if ((int)CurrentUser >= (int)permissions || permissions == Permissions.All) + if ((int)CurrentUser <= (int)permissions) { Subdirectories.Remove(dir); } } public Directory FindDirectoryByName(string name) { - if ((int)CurrentUser >= (int)permissions || permissions == Permissions.All) + if ((int)CurrentUser <= (int)permissions) { return Subdirectories.Find(x => x.Name == name); } @@ -136,7 +129,7 @@ namespace ShiftOS.Objects.ShiftFS public static class Utils { - public static Permissions CurrentUser { get; set; } + public static UserPermissions CurrentUser { get; set; } public static List Mounts { get; set; } @@ -232,7 +225,7 @@ namespace ShiftOS.Objects.ShiftFS { try { - dir.AddFile(new File(pathlist[pathlist.Length - 1], Encoding.UTF8.GetBytes(contents), false, Permissions.All)); + dir.AddFile(new File(pathlist[pathlist.Length - 1], Encoding.UTF8.GetBytes(contents), false, CurrentUser)); } catch { } } @@ -281,7 +274,7 @@ namespace ShiftOS.Objects.ShiftFS if (!FileExists(path)) { - dir.AddFile(new File(pathlist[pathlist.Length - 1], contents, false, Permissions.All)); + dir.AddFile(new File(pathlist[pathlist.Length - 1], contents, false, CurrentUser)); } else { diff --git a/ShiftOS.Objects/ShiftOS.Objects.csproj b/ShiftOS.Objects/ShiftOS.Objects.csproj index 7a19aeb..c2ef5ed 100644 --- a/ShiftOS.Objects/ShiftOS.Objects.csproj +++ b/ShiftOS.Objects/ShiftOS.Objects.csproj @@ -58,6 +58,7 @@ + diff --git a/ShiftOS.Objects/UserConfig.cs b/ShiftOS.Objects/UserConfig.cs new file mode 100644 index 0000000..61d11b8 --- /dev/null +++ b/ShiftOS.Objects/UserConfig.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Newtonsoft.Json; + +namespace ShiftOS.Objects +{ + public class UserConfig + { + public string UniteUrl { get; set; } + public string DigitalSocietyAddress { get; set; } + public int DigitalSocietyPort { get; set; } + + public static UserConfig Get() + { + var conf = new UserConfig + { + UniteUrl = "http://getshiftos.ml", + DigitalSocietyAddress = "michaeltheshifter.me", + DigitalSocietyPort = 13370 + }; + + if (!File.Exists("servers.json")) + { + File.WriteAllText("servers.json", JsonConvert.SerializeObject(conf, Formatting.Indented)); + } + else + { + conf = JsonConvert.DeserializeObject(File.ReadAllText("servers.json")); + } + return conf; + } + } +} diff --git a/ShiftOS.Server/SaveManager.cs b/ShiftOS.Server/SaveManager.cs index 63aa2bf..acf28a5 100644 --- a/ShiftOS.Server/SaveManager.cs +++ b/ShiftOS.Server/SaveManager.cs @@ -189,7 +189,7 @@ namespace ShiftOS.Server //Update the shiftos website with the user's codepoints. if (!string.IsNullOrWhiteSpace(sav.UniteAuthToken)) { - var wreq = WebRequest.Create("http://getshiftos.ml/API/SetCodepoints/" + sav.Codepoints.ToString()); + var wreq = WebRequest.Create(UserConfig.Get().UniteUrl + "/API/SetCodepoints/" + sav.Codepoints.ToString()); wreq.Headers.Add("Authentication: Token " + sav.UniteAuthToken); wreq.GetResponse(); } @@ -216,6 +216,21 @@ namespace ShiftOS.Server WriteEncFile(savefile, JsonConvert.SerializeObject(save)); } + try + { + var wr = System.Net.HttpWebRequest.Create("http://getshiftos.ml/API/GetCodepoints"); + wr.Headers.Add("Authentication: Token " + save.UniteAuthToken); + var response = wr.GetResponse(); + using (var rstr = response.GetResponseStream()) + { + using (var sreader = new StreamReader(rstr)) + { + long cp = Convert.ToInt64(sreader.ReadToEnd()); + save.Codepoints = cp; + } + } + } + catch { } Program.server.DispatchTo(new Guid(guid), new NetObject("mud_savefile", new ServerMessage { diff --git a/ShiftOS.WinForms/Applications/FileSkimmer.Designer.cs b/ShiftOS.WinForms/Applications/FileSkimmer.Designer.cs index a7b7aa5..965e4eb 100644 --- a/ShiftOS.WinForms/Applications/FileSkimmer.Designer.cs +++ b/ShiftOS.WinForms/Applications/FileSkimmer.Designer.cs @@ -69,10 +69,10 @@ namespace ShiftOS.WinForms.Applications // // lvitems // - this.lvitems.Dock = System.Windows.Forms.DockStyle.Right; - this.lvitems.Location = new System.Drawing.Point(120, 0); + this.lvitems.Dock = System.Windows.Forms.DockStyle.Fill; + this.lvitems.Location = new System.Drawing.Point(149, 0); this.lvitems.Name = "lvitems"; - this.lvitems.Size = new System.Drawing.Size(514, 332); + this.lvitems.Size = new System.Drawing.Size(485, 332); this.lvitems.TabIndex = 0; this.lvitems.UseCompatibleStateImageBehavior = false; this.lvitems.ItemSelectionChanged += new System.Windows.Forms.ListViewItemSelectionChangedEventHandler(this.lvitems_ItemSelectionChanged); @@ -81,8 +81,8 @@ namespace ShiftOS.WinForms.Applications // // panel1 // - this.panel1.Controls.Add(this.pinnedItems); this.panel1.Controls.Add(this.lvitems); + this.panel1.Controls.Add(this.pinnedItems); this.panel1.Controls.Add(this.lbcurrentfolder); this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; this.panel1.Location = new System.Drawing.Point(0, 24); @@ -95,8 +95,9 @@ namespace ShiftOS.WinForms.Applications this.pinnedItems.Dock = System.Windows.Forms.DockStyle.Left; this.pinnedItems.Location = new System.Drawing.Point(0, 0); this.pinnedItems.Name = "pinnedItems"; - this.pinnedItems.Size = new System.Drawing.Size(114, 332); + this.pinnedItems.Size = new System.Drawing.Size(149, 332); this.pinnedItems.TabIndex = 3; + this.pinnedItems.Click += new System.EventHandler(this.pinnedItems_Click); // // lbcurrentfolder // diff --git a/ShiftOS.WinForms/Applications/FileSkimmer.cs b/ShiftOS.WinForms/Applications/FileSkimmer.cs index 6309775..218e9e2 100644 --- a/ShiftOS.WinForms/Applications/FileSkimmer.cs +++ b/ShiftOS.WinForms/Applications/FileSkimmer.cs @@ -34,8 +34,8 @@ using System.Threading.Tasks; using System.Windows.Forms; using static ShiftOS.Objects.ShiftFS.Utils; -using Newtonsoft.Json; using ShiftOS.Engine; +using Newtonsoft.Json; namespace ShiftOS.WinForms.Applications { @@ -129,8 +129,14 @@ namespace ShiftOS.WinForms.Applications { int amountsCalled = -1; amountsCalled = amountsCalled + 1; - pinnedItems.Nodes.Add(path); - pinnedItems.Nodes[amountsCalled].Nodes.Add("test"); + List Pinned = new List(); + if(FileExists(Paths.GetPath("data") + "/pinned_items.dat")) + { + Pinned = JsonConvert.DeserializeObject>(ReadAllText(Paths.GetPath("data") + "/pinned_items.dat")); + } + Pinned.Add(path); + WriteAllText(Paths.GetPath("data") + "/pinned_items.dat", JsonConvert.SerializeObject(Pinned)); + ResetList(); } public void ChangeDirectory(string path) @@ -153,8 +159,40 @@ namespace ShiftOS.WinForms.Applications } } + public void PopulatePinned(TreeNode node, string[] items) + { + foreach(var dir in items) + { + var treenode = new TreeNode(); + if (DirectoryExists(dir)) + { + var dinf = GetDirectoryInfo(dir); + treenode.Text = dinf.Name; + } + else if (FileExists(dir)) + { + var finf = GetFileInfo(dir); + treenode.Text = finf.Name; + } + treenode.Tag = dir; + node.Nodes.Add(treenode); + } + } + public void ResetList() { + pinnedItems.Nodes.Clear(); + List Pinned = new List(); + if(FileExists(Paths.GetPath("data") + "/pinned_items.dat")) + { + Pinned = JsonConvert.DeserializeObject>(ReadAllText(Paths.GetPath("data") + "/pinned_items.dat")); + } + var node = new TreeNode(); + node.Text = "Pinned"; + PopulatePinned(node, Pinned.ToArray()); + pinnedItems.Nodes.Add(node); + node.ExpandAll(); + if(lvitems.LargeImageList == null) { lvitems.LargeImageList = new ImageList(); @@ -423,14 +461,14 @@ namespace ShiftOS.WinForms.Applications { if (result == true) { - if (currentdir != "__system") + if (currentdir != "__system" && lvitems.SelectedItems[0].Text != "Up one") { pinDirectory(currentdir + "/" + lvitems.SelectedItems[0].Text); ResetList(); } else { - Infobox.Show("Cannot Pin", "You cannot pin a system drive."); + Infobox.Show("Cannot Pin", "You can only pin files or folders."); } } @@ -438,5 +476,26 @@ namespace ShiftOS.WinForms.Applications } catch { } } + + private void pinnedItems_Click(object sender, EventArgs e) + { + try + { + if (pinnedItems.SelectedNode != null) + { + string path = pinnedItems.SelectedNode.Tag.ToString(); + if (DirectoryExists(path)) + { + currentdir = path; + ResetList(); + } + else if (FileExists(path)) + { + FileSkimmerBackend.OpenFile(path); + } + } + } + catch { } + } } } diff --git a/ShiftOS.WinForms/Applications/Pong.Designer.cs b/ShiftOS.WinForms/Applications/Pong.Designer.cs deleted file mode 100644 index b1186c6..0000000 --- a/ShiftOS.WinForms/Applications/Pong.Designer.cs +++ /dev/null @@ -1,769 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - - -/* - * MIT License - * - * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -using ShiftOS.WinForms.Controls; - -namespace ShiftOS.WinForms.Applications -{ - partial class Pong - { - /// - /// 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); - } - - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.gameTimer = 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.tmrstoryline = new System.Windows.Forms.Timer(this.components); - this.pgcontents = new ShiftOS.WinForms.Controls.Canvas(); - this.pnlhighscore = new System.Windows.Forms.Panel(); - this.lbhighscore = new System.Windows.Forms.ListView(); - this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); - this.button2 = new System.Windows.Forms.Button(); - this.label10 = new System.Windows.Forms.Label(); - this.pnlgamestats = new System.Windows.Forms.Panel(); - this.button1 = new System.Windows.Forms.Button(); - this.label12 = new System.Windows.Forms.Label(); - this.lblnextstats = new System.Windows.Forms.Label(); - this.Label7 = new System.Windows.Forms.Label(); - this.lblpreviousstats = new System.Windows.Forms.Label(); - this.Label4 = new System.Windows.Forms.Label(); - this.btnplayon = new System.Windows.Forms.Button(); - this.Label3 = new System.Windows.Forms.Label(); - this.btncashout = new System.Windows.Forms.Button(); - this.Label2 = new System.Windows.Forms.Label(); - this.lbllevelreached = new System.Windows.Forms.Label(); - this.pnlfinalstats = new System.Windows.Forms.Panel(); - this.btnplayagain = new System.Windows.Forms.Button(); - this.lblfinalcodepoints = new System.Windows.Forms.Label(); - this.Label11 = new System.Windows.Forms.Label(); - this.lblfinalcomputerreward = new System.Windows.Forms.Label(); - this.Label9 = new System.Windows.Forms.Label(); - this.lblfinallevelreward = new System.Windows.Forms.Label(); - this.lblfinallevelreached = new System.Windows.Forms.Label(); - this.lblfinalcodepointswithtext = new System.Windows.Forms.Label(); - this.pnllose = new System.Windows.Forms.Panel(); - this.lblmissedout = new System.Windows.Forms.Label(); - this.lblbutyougained = new System.Windows.Forms.Label(); - this.btnlosetryagain = new System.Windows.Forms.Button(); - this.Label5 = new System.Windows.Forms.Label(); - this.Label1 = new System.Windows.Forms.Label(); - this.pnlintro = new System.Windows.Forms.Panel(); - this.Label6 = new System.Windows.Forms.Label(); - this.btnstartgame = new System.Windows.Forms.Button(); - this.Label8 = new System.Windows.Forms.Label(); - this.lblbeatai = new System.Windows.Forms.Label(); - this.lblcountdown = new System.Windows.Forms.Label(); - this.ball = new ShiftOS.WinForms.Controls.Canvas(); - this.paddleHuman = new System.Windows.Forms.PictureBox(); - this.paddleComputer = new System.Windows.Forms.Panel(); - this.lbllevelandtime = new System.Windows.Forms.Label(); - this.lblstatscodepoints = new System.Windows.Forms.Label(); - this.lblstatsY = new System.Windows.Forms.Label(); - this.lblstatsX = new System.Windows.Forms.Label(); - this.btnmatchmake = new System.Windows.Forms.Button(); - this.pgcontents.SuspendLayout(); - this.pnlhighscore.SuspendLayout(); - this.flowLayoutPanel1.SuspendLayout(); - this.pnlgamestats.SuspendLayout(); - this.pnlfinalstats.SuspendLayout(); - this.pnllose.SuspendLayout(); - this.pnlintro.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.paddleHuman)).BeginInit(); - this.SuspendLayout(); - // - // gameTimer - // - this.gameTimer.Interval = 30; - this.gameTimer.Tick += new System.EventHandler(this.gameTimer_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.countdown_Tick); - // - // tmrstoryline - // - this.tmrstoryline.Interval = 1000; - this.tmrstoryline.Tick += new System.EventHandler(this.tmrstoryline_Tick); - // - // pgcontents - // - this.pgcontents.BackColor = System.Drawing.Color.White; - this.pgcontents.Controls.Add(this.pnlintro); - this.pgcontents.Controls.Add(this.pnlhighscore); - this.pgcontents.Controls.Add(this.pnlgamestats); - this.pgcontents.Controls.Add(this.pnlfinalstats); - this.pgcontents.Controls.Add(this.pnllose); - this.pgcontents.Controls.Add(this.lblbeatai); - 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.lblstatscodepoints); - this.pgcontents.Controls.Add(this.lblstatsY); - this.pgcontents.Controls.Add(this.lblstatsX); - this.pgcontents.Dock = System.Windows.Forms.DockStyle.Fill; - this.pgcontents.Location = new System.Drawing.Point(0, 0); - this.pgcontents.Name = "pgcontents"; - this.pgcontents.Size = new System.Drawing.Size(912, 504); - this.pgcontents.TabIndex = 20; - this.pgcontents.Paint += new System.Windows.Forms.PaintEventHandler(this.pgcontents_Paint); - this.pgcontents.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pongMain_MouseMove); - // - // pnlhighscore - // - this.pnlhighscore.Controls.Add(this.lbhighscore); - this.pnlhighscore.Controls.Add(this.flowLayoutPanel1); - this.pnlhighscore.Controls.Add(this.label10); - this.pnlhighscore.Location = new System.Drawing.Point(688, 302); - this.pnlhighscore.Name = "pnlhighscore"; - this.pnlhighscore.Size = new System.Drawing.Size(539, 311); - this.pnlhighscore.TabIndex = 14; - this.pnlhighscore.Visible = false; - // - // lbhighscore - // - this.lbhighscore.Dock = System.Windows.Forms.DockStyle.Fill; - this.lbhighscore.Location = new System.Drawing.Point(0, 36); - this.lbhighscore.Name = "lbhighscore"; - this.lbhighscore.Size = new System.Drawing.Size(539, 246); - this.lbhighscore.TabIndex = 1; - this.lbhighscore.UseCompatibleStateImageBehavior = false; - // - // flowLayoutPanel1 - // - this.flowLayoutPanel1.AutoSize = true; - this.flowLayoutPanel1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.flowLayoutPanel1.Controls.Add(this.button2); - this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Bottom; - this.flowLayoutPanel1.FlowDirection = System.Windows.Forms.FlowDirection.RightToLeft; - this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 282); - this.flowLayoutPanel1.Name = "flowLayoutPanel1"; - this.flowLayoutPanel1.Size = new System.Drawing.Size(539, 29); - this.flowLayoutPanel1.TabIndex = 2; - // - // button2 - // - this.button2.AutoSize = true; - this.button2.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.button2.Location = new System.Drawing.Point(476, 3); - this.button2.Name = "button2"; - this.button2.Size = new System.Drawing.Size(60, 23); - this.button2.TabIndex = 0; - this.button2.Text = "{CLOSE}"; - this.button2.UseVisualStyleBackColor = true; - this.button2.Click += new System.EventHandler(this.button2_Click); - // - // label10 - // - this.label10.Dock = System.Windows.Forms.DockStyle.Top; - this.label10.Location = new System.Drawing.Point(0, 0); - this.label10.Name = "label10"; - this.label10.Size = new System.Drawing.Size(539, 36); - this.label10.TabIndex = 0; - this.label10.Text = "{HIGH_SCORES}"; - this.label10.TextAlign = System.Drawing.ContentAlignment.TopCenter; - // - // pnlgamestats - // - this.pnlgamestats.Controls.Add(this.button1); - this.pnlgamestats.Controls.Add(this.label12); - this.pnlgamestats.Controls.Add(this.lblnextstats); - this.pnlgamestats.Controls.Add(this.Label7); - this.pnlgamestats.Controls.Add(this.lblpreviousstats); - this.pnlgamestats.Controls.Add(this.Label4); - this.pnlgamestats.Controls.Add(this.btnplayon); - this.pnlgamestats.Controls.Add(this.Label3); - this.pnlgamestats.Controls.Add(this.btncashout); - this.pnlgamestats.Controls.Add(this.Label2); - this.pnlgamestats.Controls.Add(this.lbllevelreached); - this.pnlgamestats.Location = new System.Drawing.Point(104, 375); - this.pnlgamestats.Name = "pnlgamestats"; - this.pnlgamestats.Size = new System.Drawing.Size(466, 284); - this.pnlgamestats.TabIndex = 6; - this.pnlgamestats.Visible = false; - // - // button1 - // - this.button1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.button1.Location = new System.Drawing.Point(32, 223); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(191, 35); - this.button1.TabIndex = 10; - this.button1.Text = "{PONG_VIEW_HIGHSCORES}"; - this.button1.UseVisualStyleBackColor = true; - this.button1.Click += new System.EventHandler(this.btnhighscore_Click); - // - // label12 - // - this.label12.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label12.Location = new System.Drawing.Point(8, 187); - this.label12.Name = "label12"; - this.label12.Size = new System.Drawing.Size(245, 33); - this.label12.TabIndex = 9; - this.label12.Text = "{PONG_HIGHSCORE_EXP}"; - this.label12.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // lblnextstats - // - this.lblnextstats.AutoSize = true; - this.lblnextstats.Location = new System.Drawing.Point(278, 136); - this.lblnextstats.Name = "lblnextstats"; - this.lblnextstats.Size = new System.Drawing.Size(0, 13); - this.lblnextstats.TabIndex = 8; - // - // Label7 - // - this.Label7.AutoSize = true; - this.Label7.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Label7.Location = new System.Drawing.Point(278, 119); - this.Label7.Name = "Label7"; - this.Label7.Size = new System.Drawing.Size(124, 16); - this.Label7.TabIndex = 7; - this.Label7.Text = "Next Level Stats:"; - // - // lblpreviousstats - // - this.lblpreviousstats.AutoSize = true; - this.lblpreviousstats.Location = new System.Drawing.Point(278, 54); - this.lblpreviousstats.Name = "lblpreviousstats"; - this.lblpreviousstats.Size = new System.Drawing.Size(0, 13); - this.lblpreviousstats.TabIndex = 6; - // - // Label4 - // - this.Label4.AutoSize = true; - this.Label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Label4.Location = new System.Drawing.Point(278, 37); - this.Label4.Name = "Label4"; - this.Label4.Size = new System.Drawing.Size(154, 16); - this.Label4.TabIndex = 5; - this.Label4.Text = "Previous Level Stats:"; - // - // btnplayon - // - this.btnplayon.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btnplayon.Location = new System.Drawing.Point(32, 147); - this.btnplayon.Name = "btnplayon"; - this.btnplayon.Size = new System.Drawing.Size(191, 35); - this.btnplayon.TabIndex = 4; - this.btnplayon.Text = "Play on for 3 codepoints!"; - this.btnplayon.UseVisualStyleBackColor = true; - this.btnplayon.Click += new System.EventHandler(this.btnplayon_Click); - // - // Label3 - // - this.Label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Label3.Location = new System.Drawing.Point(8, 111); - this.Label3.Name = "Label3"; - this.Label3.Size = new System.Drawing.Size(245, 33); - this.Label3.TabIndex = 3; - this.Label3.Text = "{PONG_PLAYON_DESC}"; - this.Label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // btncashout - // - this.btncashout.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btncashout.Location = new System.Drawing.Point(32, 73); - this.btncashout.Name = "btncashout"; - this.btncashout.Size = new System.Drawing.Size(191, 35); - this.btncashout.TabIndex = 2; - this.btncashout.Text = "Cash out with 1 codepoint!"; - this.btncashout.UseVisualStyleBackColor = true; - this.btncashout.Click += new System.EventHandler(this.btncashout_Click); - // - // Label2 - // - this.Label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Label2.Location = new System.Drawing.Point(8, 37); - this.Label2.Name = "Label2"; - this.Label2.Size = new System.Drawing.Size(245, 33); - this.Label2.TabIndex = 1; - this.Label2.Text = "{PONG_CASHOUT_DESC}"; - this.Label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // lbllevelreached - // - this.lbllevelreached.AutoSize = true; - this.lbllevelreached.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lbllevelreached.Location = new System.Drawing.Point(149, 6); - this.lbllevelreached.Name = "lbllevelreached"; - this.lbllevelreached.Size = new System.Drawing.Size(185, 20); - this.lbllevelreached.TabIndex = 0; - this.lbllevelreached.Text = "You Reached Level 2!"; - // - // pnlfinalstats - // - this.pnlfinalstats.Controls.Add(this.btnplayagain); - this.pnlfinalstats.Controls.Add(this.lblfinalcodepoints); - this.pnlfinalstats.Controls.Add(this.Label11); - this.pnlfinalstats.Controls.Add(this.lblfinalcomputerreward); - this.pnlfinalstats.Controls.Add(this.Label9); - this.pnlfinalstats.Controls.Add(this.lblfinallevelreward); - this.pnlfinalstats.Controls.Add(this.lblfinallevelreached); - this.pnlfinalstats.Controls.Add(this.lblfinalcodepointswithtext); - this.pnlfinalstats.Location = new System.Drawing.Point(172, 74); - this.pnlfinalstats.Name = "pnlfinalstats"; - this.pnlfinalstats.Size = new System.Drawing.Size(362, 226); - this.pnlfinalstats.TabIndex = 9; - this.pnlfinalstats.Visible = false; - // - // btnplayagain - // - this.btnplayagain.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btnplayagain.Location = new System.Drawing.Point(5, 194); - this.btnplayagain.Name = "btnplayagain"; - this.btnplayagain.Size = new System.Drawing.Size(352, 29); - this.btnplayagain.TabIndex = 16; - this.btnplayagain.Text = "{PLAY}"; - this.btnplayagain.UseVisualStyleBackColor = true; - this.btnplayagain.Click += new System.EventHandler(this.btnplayagain_Click); - // - // lblfinalcodepoints - // - this.lblfinalcodepoints.Font = new System.Drawing.Font("Microsoft Sans Serif", 48F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblfinalcodepoints.Location = new System.Drawing.Point(3, 124); - this.lblfinalcodepoints.Name = "lblfinalcodepoints"; - this.lblfinalcodepoints.Size = new System.Drawing.Size(356, 73); - this.lblfinalcodepoints.TabIndex = 15; - this.lblfinalcodepoints.Tag = "header1"; - this.lblfinalcodepoints.Text = "134 CP"; - this.lblfinalcodepoints.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // Label11 - // - this.Label11.AutoSize = true; - this.Label11.Font = new System.Drawing.Font("Microsoft Sans Serif", 21.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Label11.Location = new System.Drawing.Point(162, 82); - this.Label11.Name = "Label11"; - this.Label11.Size = new System.Drawing.Size(33, 33); - this.Label11.TabIndex = 14; - this.Label11.Tag = "header2"; - this.Label11.Text = "+"; - this.Label11.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // lblfinalcomputerreward - // - this.lblfinalcomputerreward.Font = new System.Drawing.Font("Microsoft Sans Serif", 27.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblfinalcomputerreward.Location = new System.Drawing.Point(193, 72); - this.lblfinalcomputerreward.Name = "lblfinalcomputerreward"; - this.lblfinalcomputerreward.Size = new System.Drawing.Size(151, 52); - this.lblfinalcomputerreward.TabIndex = 12; - this.lblfinalcomputerreward.Tag = "header2"; - this.lblfinalcomputerreward.Text = "34"; - this.lblfinalcomputerreward.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // Label9 - // - this.Label9.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Label9.Location = new System.Drawing.Point(179, 31); - this.Label9.Name = "Label9"; - this.Label9.Size = new System.Drawing.Size(180, 49); - this.Label9.TabIndex = 11; - this.Label9.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // lblfinallevelreward - // - this.lblfinallevelreward.Font = new System.Drawing.Font("Microsoft Sans Serif", 27.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblfinallevelreward.Location = new System.Drawing.Point(12, 72); - this.lblfinallevelreward.Name = "lblfinallevelreward"; - this.lblfinallevelreward.Size = new System.Drawing.Size(151, 52); - this.lblfinallevelreward.TabIndex = 10; - this.lblfinallevelreward.Tag = "header2"; - this.lblfinallevelreward.Text = "100"; - this.lblfinallevelreward.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // lblfinallevelreached - // - this.lblfinallevelreached.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblfinallevelreached.Location = new System.Drawing.Point(3, 31); - this.lblfinallevelreached.Name = "lblfinallevelreached"; - this.lblfinallevelreached.Size = new System.Drawing.Size(170, 49); - this.lblfinallevelreached.TabIndex = 9; - this.lblfinallevelreached.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // lblfinalcodepointswithtext - // - this.lblfinalcodepointswithtext.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblfinalcodepointswithtext.Location = new System.Drawing.Point(3, 2); - this.lblfinalcodepointswithtext.Name = "lblfinalcodepointswithtext"; - this.lblfinalcodepointswithtext.Size = new System.Drawing.Size(356, 26); - this.lblfinalcodepointswithtext.TabIndex = 1; - this.lblfinalcodepointswithtext.Tag = "header2"; - this.lblfinalcodepointswithtext.Text = "You cashed out with 134 codepoints!"; - this.lblfinalcodepointswithtext.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // pnllose - // - this.pnllose.Controls.Add(this.lblmissedout); - this.pnllose.Controls.Add(this.lblbutyougained); - this.pnllose.Controls.Add(this.btnlosetryagain); - this.pnllose.Controls.Add(this.Label5); - this.pnllose.Controls.Add(this.Label1); - this.pnllose.Location = new System.Drawing.Point(209, 71); - this.pnllose.Name = "pnllose"; - this.pnllose.Size = new System.Drawing.Size(266, 214); - this.pnllose.TabIndex = 10; - this.pnllose.Visible = false; - // - // lblmissedout - // - this.lblmissedout.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblmissedout.Location = new System.Drawing.Point(3, 175); - this.lblmissedout.Name = "lblmissedout"; - this.lblmissedout.Size = new System.Drawing.Size(146, 35); - this.lblmissedout.TabIndex = 3; - this.lblmissedout.Text = "You Missed Out On: 500 Codepoints"; - this.lblmissedout.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // lblbutyougained - // - this.lblbutyougained.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblbutyougained.Location = new System.Drawing.Point(3, 125); - this.lblbutyougained.Name = "lblbutyougained"; - this.lblbutyougained.Size = new System.Drawing.Size(146, 35); - this.lblbutyougained.TabIndex = 3; - this.lblbutyougained.Text = "But you gained 5 Codepoints"; - this.lblbutyougained.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // btnlosetryagain - // - this.btnlosetryagain.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btnlosetryagain.Location = new System.Drawing.Point(155, 176); - this.btnlosetryagain.Name = "btnlosetryagain"; - this.btnlosetryagain.Size = new System.Drawing.Size(106, 35); - this.btnlosetryagain.TabIndex = 2; - this.btnlosetryagain.Text = "Try Again"; - this.btnlosetryagain.UseVisualStyleBackColor = true; - this.btnlosetryagain.Click += new System.EventHandler(this.btnlosetryagain_Click); - // - // Label5 - // - this.Label5.Location = new System.Drawing.Point(7, 26); - this.Label5.Name = "Label5"; - this.Label5.Size = new System.Drawing.Size(260, 163); - this.Label5.TabIndex = 1; - // - // Label1 - // - this.Label1.Dock = System.Windows.Forms.DockStyle.Top; - this.Label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Label1.Location = new System.Drawing.Point(0, 0); - this.Label1.Name = "Label1"; - this.Label1.Size = new System.Drawing.Size(266, 16); - this.Label1.TabIndex = 0; - this.Label1.Text = "You lose!"; - this.Label1.TextAlign = System.Drawing.ContentAlignment.TopCenter; - // - // pnlintro - // - this.pnlintro.Controls.Add(this.btnmatchmake); - this.pnlintro.Controls.Add(this.Label6); - this.pnlintro.Controls.Add(this.btnstartgame); - this.pnlintro.Controls.Add(this.Label8); - this.pnlintro.Location = new System.Drawing.Point(0, 0); - this.pnlintro.Name = "pnlintro"; - this.pnlintro.Size = new System.Drawing.Size(595, 303); - this.pnlintro.TabIndex = 13; - this.pnlintro.Tag = "header2"; - // - // Label6 - // - this.Label6.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Label6.Location = new System.Drawing.Point(3, 39); - this.Label6.Name = "Label6"; - this.Label6.Size = new System.Drawing.Size(589, 159); - this.Label6.TabIndex = 15; - this.Label6.Text = "{PONG_DESC}"; - this.Label6.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.Label6.Click += new System.EventHandler(this.Label6_Click); - // - // btnstartgame - // - this.btnstartgame.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btnstartgame.Location = new System.Drawing.Point(188, 215); - this.btnstartgame.Name = "btnstartgame"; - this.btnstartgame.Size = new System.Drawing.Size(242, 28); - this.btnstartgame.TabIndex = 15; - this.btnstartgame.Text = "{PLAY}"; - this.btnstartgame.UseVisualStyleBackColor = true; - this.btnstartgame.Click += new System.EventHandler(this.btnstartgame_Click); - // - // Label8 - // - this.Label8.AutoSize = true; - this.Label8.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Label8.ForeColor = System.Drawing.Color.Black; - this.Label8.Location = new System.Drawing.Point(250, 5); - this.Label8.Name = "Label8"; - this.Label8.Size = new System.Drawing.Size(280, 31); - this.Label8.TabIndex = 14; - this.Label8.Text = "{PONG_WELCOME}"; - this.Label8.Click += new System.EventHandler(this.Label8_Click); - // - // lblbeatai - // - this.lblbeatai.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblbeatai.Location = new System.Drawing.Point(47, 41); - this.lblbeatai.Name = "lblbeatai"; - this.lblbeatai.Size = new System.Drawing.Size(600, 30); - this.lblbeatai.TabIndex = 8; - this.lblbeatai.Tag = "header2"; - this.lblbeatai.Text = "You got 2 codepoints for beating the Computer!"; - this.lblbeatai.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.lblbeatai.Visible = false; - // - // 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(182, 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.Black; - 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; - this.ball.MouseEnter += new System.EventHandler(this.ball_MouseEnter); - this.ball.MouseLeave += new System.EventHandler(this.ball_MouseLeave); - // - // paddleHuman - // - this.paddleHuman.BackColor = System.Drawing.Color.Black; - 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.Right))); - this.paddleComputer.BackColor = System.Drawing.Color.Black; - this.paddleComputer.Location = new System.Drawing.Point(878, 134); - this.paddleComputer.MaximumSize = new System.Drawing.Size(20, 150); - 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(912, 22); - this.lbllevelandtime.TabIndex = 4; - this.lbllevelandtime.Tag = "header1"; - this.lbllevelandtime.Text = "Level: 1 - 58 Seconds Left"; - this.lbllevelandtime.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // lblstatscodepoints - // - this.lblstatscodepoints.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.lblstatscodepoints.AutoSize = true; - this.lblstatscodepoints.Font = new System.Drawing.Font("Georgia", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblstatscodepoints.Location = new System.Drawing.Point(239, 460); - this.lblstatscodepoints.Name = "lblstatscodepoints"; - this.lblstatscodepoints.Size = new System.Drawing.Size(116, 23); - this.lblstatscodepoints.TabIndex = 12; - this.lblstatscodepoints.Tag = "header2"; - this.lblstatscodepoints.Text = "Codepoints: "; - this.lblstatscodepoints.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.AutoSize = true; - 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(440, 460); - this.lblstatsY.Name = "lblstatsY"; - this.lblstatsY.Size = new System.Drawing.Size(76, 23); - this.lblstatsY.TabIndex = 11; - this.lblstatsY.Tag = "header2"; - 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.AutoSize = true; - 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, 460); - this.lblstatsX.Name = "lblstatsX"; - this.lblstatsX.Size = new System.Drawing.Size(83, 23); - this.lblstatsX.TabIndex = 5; - this.lblstatsX.Tag = "header2"; - this.lblstatsX.Text = "Xspeed: "; - this.lblstatsX.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // btnmatchmake - // - this.btnmatchmake.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btnmatchmake.Location = new System.Drawing.Point(188, 253); - this.btnmatchmake.Name = "btnmatchmake"; - this.btnmatchmake.Size = new System.Drawing.Size(242, 28); - this.btnmatchmake.TabIndex = 16; - this.btnmatchmake.Text = "Or, play against another Shifter!"; - this.btnmatchmake.UseVisualStyleBackColor = true; - this.btnmatchmake.Click += new System.EventHandler(this.btnmatchmake_Click); - // - // Pong - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.White; - this.Controls.Add(this.pgcontents); - this.DoubleBuffered = true; - this.Name = "Pong"; - this.Size = new System.Drawing.Size(912, 504); - this.Load += new System.EventHandler(this.Pong_Load); - this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pongMain_MouseMove); - this.pgcontents.ResumeLayout(false); - this.pgcontents.PerformLayout(); - this.pnlhighscore.ResumeLayout(false); - this.pnlhighscore.PerformLayout(); - this.flowLayoutPanel1.ResumeLayout(false); - this.flowLayoutPanel1.PerformLayout(); - this.pnlgamestats.ResumeLayout(false); - this.pnlgamestats.PerformLayout(); - this.pnlfinalstats.ResumeLayout(false); - this.pnlfinalstats.PerformLayout(); - this.pnllose.ResumeLayout(false); - this.pnlintro.ResumeLayout(false); - this.pnlintro.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.paddleHuman)).EndInit(); - this.ResumeLayout(false); - - } - internal System.Windows.Forms.Panel paddleComputer; - internal System.Windows.Forms.Timer gameTimer; - internal System.Windows.Forms.PictureBox paddleHuman; - internal System.Windows.Forms.Label lbllevelandtime; - internal System.Windows.Forms.Label lblstatsX; - internal System.Windows.Forms.Timer counter; - internal System.Windows.Forms.Panel pnlgamestats; - internal System.Windows.Forms.Label lblnextstats; - internal System.Windows.Forms.Label Label7; - internal System.Windows.Forms.Label lblpreviousstats; - internal System.Windows.Forms.Label Label4; - internal System.Windows.Forms.Button btnplayon; - internal System.Windows.Forms.Label Label3; - internal System.Windows.Forms.Button btncashout; - internal System.Windows.Forms.Label Label2; - internal System.Windows.Forms.Label lbllevelreached; - internal System.Windows.Forms.Label lblcountdown; - internal System.Windows.Forms.Timer tmrcountdown; - internal System.Windows.Forms.Label lblbeatai; - internal System.Windows.Forms.Panel pnlfinalstats; - internal System.Windows.Forms.Button btnplayagain; - internal System.Windows.Forms.Label lblfinalcodepoints; - internal System.Windows.Forms.Label Label11; - internal System.Windows.Forms.Label lblfinalcomputerreward; - internal System.Windows.Forms.Label Label9; - internal System.Windows.Forms.Label lblfinallevelreward; - internal System.Windows.Forms.Label lblfinallevelreached; - internal System.Windows.Forms.Label lblfinalcodepointswithtext; - internal System.Windows.Forms.Panel pnllose; - internal System.Windows.Forms.Label lblmissedout; - internal System.Windows.Forms.Label lblbutyougained; - internal System.Windows.Forms.Button btnlosetryagain; - internal System.Windows.Forms.Label Label5; - internal System.Windows.Forms.Label Label1; - internal System.Windows.Forms.Label lblstatscodepoints; - internal System.Windows.Forms.Label lblstatsY; - internal System.Windows.Forms.Panel pnlintro; - internal System.Windows.Forms.Label Label6; - internal System.Windows.Forms.Button btnstartgame; - internal System.Windows.Forms.Label Label8; - internal System.Windows.Forms.Timer tmrstoryline; - private System.Windows.Forms.Panel pnlhighscore; - private System.Windows.Forms.ListView lbhighscore; - private System.Windows.Forms.Label label10; - internal Canvas pgcontents; - internal Canvas ball; - internal System.Windows.Forms.Button button1; - internal System.Windows.Forms.Label label12; - private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1; - private System.Windows.Forms.Button button2; - internal System.Windows.Forms.Button btnmatchmake; - } -} diff --git a/ShiftOS.WinForms/Applications/Pong.cs b/ShiftOS.WinForms/Applications/Pong.cs deleted file mode 100644 index 585639a..0000000 --- a/ShiftOS.WinForms/Applications/Pong.cs +++ /dev/null @@ -1,977 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using System.Windows.Forms; -using Newtonsoft.Json; -using ShiftOS.Engine; -using ShiftOS.Objects; -using ShiftOS.WinForms.Tools; - -namespace ShiftOS.WinForms.Applications -{ - [MultiplayerOnly] - [Launcher("Pong", true, "al_pong", "Games")] - [WinOpen("pong")] - [DefaultIcon("iconPong")] - public partial class Pong : UserControl, IShiftOSWindow - { - //I can assure you guaranteed that there is an acorn somewhere, in this place, and the sailors are looking for it - 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 totalreward; - int countdown = 3; - - bool aiShouldIsbeEnabled = true; - - public Pong() - { - InitializeComponent(); - } - - private void Pong_Load(object sender, EventArgs e) - { - setuplevelrewards(); - } - - - - // Move the paddle according to the mouse position. - private void pongMain_MouseMove(object sender, MouseEventArgs e) - { - var loc = this.PointToClient(MousePosition); - if (IsMultiplayerSession) - { - if (IsLeader) - { - paddleHuman.Location = new Point(paddleHuman.Location.X, (loc.Y) - (paddleHuman.Height / 2)); - ServerManager.Forward(OpponentGUID, "pong_mp_setopponenty", paddleHuman.Top.ToString()); - } - else - { - paddleComputer.Location = new Point(paddleComputer.Location.X, (loc.Y) - (paddleComputer.Height / 2)); - ServerManager.Forward(OpponentGUID, "pong_mp_setopponenty", paddleComputer.Top.ToString()); - } - } - else - { - paddleHuman.Location = new Point(paddleHuman.Location.X, (loc.Y) - (paddleHuman.Height / 2)); - } - } - - private void CenterPanels() - { - pnlfinalstats.CenterParent(); - pnlgamestats.CenterParent(); - pnlhighscore.CenterParent(); - pnlintro.CenterParent(); - pnllose.CenterParent(); - lblcountdown.CenterParent(); - lblbeatai.Left = (this.Width - lblbeatai.Width) / 2; - SetupStats(); - } - - public void SetupStats() - { - lblstatsX.Location = new Point(5, this.Height - lblstatsX.Height - 5); - lblstatsY.Location = new Point(this.Width - lblstatsY.Width - 5, this.Height - lblstatsY.Height - 5); - lblstatscodepoints.Top = this.Height - lblstatscodepoints.Height - 5; - lblstatscodepoints.Left = (this.Width - lblstatscodepoints.Width) / 2; - } - - int OpponentY = 0; - - bool IsLeader = false; - - int LeaderX = 0; - int LeaderY = 0; - - // ERROR: Handles clauses are not supported in C# - private void gameTimer_Tick(object sender, EventArgs e) - { - if (this.Left < Screen.PrimaryScreen.Bounds.Width) - { - ball.BackColor = SkinEngine.LoadedSkin.ControlTextColor; - paddleComputer.BackColor = SkinEngine.LoadedSkin.ControlTextColor; - paddleHuman.BackColor = SkinEngine.LoadedSkin.ControlTextColor; - - //Check if paddle upgrade has been bought and change paddles accordingly - //if (ShiftoriumFrontend.UpgradeInstalled("pong_increased_paddle_size")) - //{ - // paddleHuman.Height = 150; - // paddleComputer.Height = 150; - //} - //I don't know the point of this but I'm fucking 86ing it. - Michael - - //Set the computer player to move according to the ball's position. - if (IsMultiplayerSession == true) - { - //If we're multiplayer, then we want to set the computer Y to the opponent's Y. - //If we're the leader, we set the AI paddle, else we set the player paddle. - if (IsLeader) - paddleComputer.Top = OpponentY; - else - paddleHuman.Top = OpponentY; - } - else - { - if (aiShouldIsbeEnabled) - if (ball.Location.X > (this.Width - (this.Width / 3)) - xVel * 10 && xVel > 0) - { - if (ball.Location.Y > paddleComputer.Location.Y + 50) - { - paddleComputer.Location = new Point(paddleComputer.Location.X, paddleComputer.Location.Y + computerspeed); - } - if (ball.Location.Y < paddleComputer.Location.Y + 50) - { - paddleComputer.Location = new Point(paddleComputer.Location.X, paddleComputer.Location.Y - computerspeed); - } - casualposition = rand.Next(-150, 201); - } - else - { - //used to be me.location.y - except it's fucking C# and this comment is misleading as fuck. OH WAIT! I didn't write it! And none of the current devs did either! - Michael - if (paddleComputer.Location.Y > this.Size.Height / 2 - paddleComputer.Height + casualposition) - { - paddleComputer.Location = new Point(paddleComputer.Location.X, paddleComputer.Location.Y - computerspeed); - } - //Rylan is hot. Used to be //used to be me.location.y - if (paddleComputer.Location.Y < this.Size.Height / 2 - paddleComputer.Height + casualposition) - { - paddleComputer.Location = new Point(paddleComputer.Location.X, paddleComputer.Location.Y + computerspeed); - } - } - } - //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); - - bool BallPhysics = true; - - if (IsMultiplayerSession) - { - //Logic for moving the ball in Multiplayer. - if (IsLeader) - { - ball.Location = new Point(ball.Location.X + xVel, ball.Location.Y + yVel); - } - else - { - //Move it to the leader's ball position. - ball.Location = new Point(LeaderX, LeaderY); - BallPhysics = false; - } - } - else - {// Move the game ball. - ball.Location = new Point(ball.Location.X + xVel, ball.Location.Y + yVel); - } - if (BallPhysics) - { - // Check for top wall. - if (ball.Location.Y < 0) - { - ball.Location = new Point(ball.Location.X, 0); - yVel = -yVel; - ShiftOS.Engine.AudioManager.PlayStream(Properties.Resources.typesound); - } - - // 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; - ShiftOS.Engine.AudioManager.PlayStream(Properties.Resources.typesound); - } - - - // Check for player paddle. - if (ball.Bounds.IntersectsWith(paddleHuman.Bounds)) - { - ball.Location = new Point(paddleHuman.Location.X + ball.Size.Width + 1, 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; - ShiftOS.Engine.AudioManager.PlayStream(Properties.Resources.writesound); - - } - - // 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; - ShiftOS.Engine.AudioManager.PlayStream(Properties.Resources.writesound); - } - } - - - - // Check for left wall. - if (ball.Location.X < -100) - { - //If we are in multiplayer, and not the leader, we won. - if (IsMultiplayerSession) - { - if (IsLeader) - { - //We lost. - NotifyLoseToTarget(); - } - else - { - //We won. - NotifyWinToTarget(); - Win(); - } - } - else - { - ball.Location = new Point(this.Size.Width / 2 + 200, this.Size.Height / 2); - paddleComputer.Location = new Point(paddleComputer.Location.X, ball.Location.Y); - if (xVel > 0) - xVel = -xVel; - pnllose.Show(); - gameTimer.Stop(); - counter.Stop(); - lblmissedout.Text = Localization.Parse("{YOU_MISSED_OUT_ON}:") + Environment.NewLine + lblstatscodepoints.Text.Replace(Localization.Parse("{CODEPOINTS}: "), "") + Localization.Parse(" {CODEPOINTS}"); - if (ShiftoriumFrontend.UpgradeInstalled("pong_upgrade_2")) - { - totalreward = levelrewards[level - 1] + beatairewardtotal; - double onePercent = (totalreward / 100); - lblbutyougained.Show(); - lblbutyougained.Text = Localization.Parse("{BUT_YOU_GAINED}:") + Environment.NewLine + onePercent.ToString("") + (Localization.Parse(" {CODEPOINTS}")); - SaveSystem.TransferCodepointsFrom("pong", (totalreward / 100)); - } - else - { - lblbutyougained.Hide(); - } - } - } - - // Check for right wall. - if (ball.Location.X > this.Width - ball.Size.Width - paddleComputer.Width + 100) - { - if (IsMultiplayerSession) - { - //If we are the leader we won. - if (IsLeader) - { - NotifyWinToTarget(); - Win(); - } - else - { - NotifyLoseToTarget(); - } - } - else - { - Win(); - } - } - - if (IsMultiplayerSession) - { - if (IsLeader) - { - ServerManager.Forward(OpponentGUID, "pong_mp_setballpos", JsonConvert.SerializeObject(ball.Location)); - } - } - - if (IsLeader) - { - //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 = Localization.Parse("{H_VEL}: ") + xveldec; - lblstatsY.Text = Localization.Parse("{V_VEL}: ") + yveldec; - lblstatscodepoints.Text = Localization.Parse("{CODEPOINTS}: ") + (levelrewards[level - 1] + beatairewardtotal).ToString(); - lbllevelandtime.Text = Localization.Parse("{LEVEL}: " + level + " - " + secondsleft + " {SECONDS_LEFT}"); - - if (xVel > 20 || xVel < -20) - { - paddleHuman.Width = Math.Abs(xVel); - paddleComputer.Width = Math.Abs(xVel); - } - else - { - paddleHuman.Width = 20; - paddleComputer.Width = 20; - } - } - if (!IsMultiplayerSession) - { - computerspeed = Math.Abs(yVel); - } - } - } - - public void ServerMessageReceivedHandler(ServerMessage msg) - { - if(msg.Name == "pong_mp_setballpos") - { - var pt = JsonConvert.DeserializeObject(msg.Contents); - LeaderX = pt.X; - LeaderY = pt.Y; - } - else if(msg.Name == "pong_mp_youlose") - { - LoseMP(); - } - else if(msg.Name == "pong_mp_setopponenty") - { - int y = Convert.ToInt32(msg.Contents); - OpponentY = y; - } - else if(msg.Name == "pong_handshake_matchmake") - { - PossibleMatchmakes.Add(msg.Contents); - } - else if(msg.Name == "pong_handshake_complete") - { - LeaveMatchmake(); - StartLevel(); - } - else if(msg.Name == "pong_handshake_giveleaderid") - { - IsLeader = false; - OpponentGUID = msg.Contents; - YouGUID = ServerManager.thisGuid.ToString(); - SendFollowerGUID(); - } - else if(msg.Name == "pong_handshake_left") - { - if (this.PossibleMatchmakes.Contains(msg.Contents)) - this.PossibleMatchmakes.Remove(msg.Contents); - } - else if(msg.Name == "pong_handshake_setfollowerguid") - { - IsLeader = false; - OpponentGUID = msg.Contents; - } - else if(msg.Name == "pong_mp_youwin") - { - Win(); - } - } - - public void NotifyLoseToTarget() - { - ServerManager.Forward(OpponentGUID, "pong_mp_youwin", null); - } - - public void NotifyWinToTarget() - { - ServerManager.Forward(OpponentGUID, "pong_mp_youlose", null); - } - - public void LeaveMatchmake() - { - ServerManager.Forward("all", "pong_handshake_left", YouGUID); - } - - List PossibleMatchmakes = new List(); - - public void SendLeaderGUID() - { - ServerManager.Forward(OpponentGUID, "pong_handshake_giveleaderid", YouGUID); - } - - - public void StartMultiplayer() - { - IsMultiplayerSession = true; - YouGUID = ServerManager.thisGuid.ToString(); - ServerManager.SendMessage("pong_handshake_matchmake", YouGUID); - } - - - public void SendFollowerGUID() - { - ServerManager.Forward(OpponentGUID, "pong_handshake_setfollowerguid", YouGUID); - } - - public void LoseMP() - { - ball.Location = new Point(this.Size.Width / 2 + 200, this.Size.Height / 2); - if(IsLeader) - if (xVel > 0) - xVel = -xVel; - lblbeatai.Show(); - lblbeatai.Text = "The opponent has beaten you!"; - tmrcountdown.Start(); - gameTimer.Stop(); - counter.Stop(); - - } - - public void Win() - { - ball.Location = new Point(this.Size.Width / 2 + 200, this.Size.Height / 2); - paddleComputer.Location = new Point(paddleComputer.Location.X, ball.Location.Y); - if (xVel > 0) - xVel = -xVel; - beatairewardtotal = beatairewardtotal + beataireward; - lblbeatai.Show(); - lblbeatai.Text = Localization.Parse($"{{PONG_BEAT_AI_REWARD_SECONDARY}}: {beataireward}"); - tmrcountdown.Start(); - gameTimer.Stop(); - counter.Stop(); - - } - - // ERROR: Handles clauses are not supported in C# - private void counter_Tick(object sender, EventArgs e) - { - if (this.Left < Screen.PrimaryScreen.Bounds.Width) - { - secondsleft = secondsleft - 1; - if (secondsleft == 1) - { - secondsleft = 60; - level = level + 1; - if (SaveSystem.CurrentSave.UniteAuthToken != null) - { - try - { - var unite = new ShiftOS.Unite.UniteClient("http://getshiftos.ml", SaveSystem.CurrentSave.UniteAuthToken); - if (unite.GetPongLevel() < level) - unite.SetPongLevel(level); - } - catch { } - } - generatenextlevel(); - pnlgamestats.Show(); - pnlgamestats.BringToFront(); - pnlgamestats.Location = new Point((pgcontents.Width / 2) - (pnlgamestats.Width / 2), (pgcontents.Height / 2) - (pnlgamestats.Height / 2)); - - counter.Stop(); - gameTimer.Stop(); - SendHighscores(); - } - - lblstatscodepoints.Text = Localization.Parse("{CODEPOINTS}: ") + (levelrewards[level - 1] + beatairewardtotal).ToString(); - } - SetupStats(); - } - - [Obsolete("This method does nothing. Use UniteClient for highscore queries.")] - public void SendHighscores() - { - } - - // ERROR: Handles clauses are not supported in C# - private void btnplayon_Click(object sender, EventArgs e) - { - xveldec = levelxspeed; - yveldec = levelyspeed; - - secondsleft = 60; - - tmrcountdown.Start(); - lblbeatai.Text = Localization.Parse($"{{PONG_BEAT_AI_REWARD}}: {beataireward}"); - pnlgamestats.Hide(); - lblbeatai.Show(); - ball.Location = new Point(paddleHuman.Location.X + paddleHuman.Width + 50, paddleHuman.Location.Y + paddleHuman.Height / 2); - if (xVel < 0) - xVel = Math.Abs(xVel); - lbllevelandtime.Text = Localization.Parse("{LEVEL}: " + level + " - " + secondsleft + " {SECONDS_LEFT}"); - } - - //Increase the ball speed stats for the next level - private void generatenextlevel() - { - lbllevelreached.Text = Localization.Parse("{YOU_REACHED_LEVEL} " + level + "!"); - - lblpreviousstats.Text = Localization.Parse("{INITIAL_H_VEL}: " + levelxspeed + Environment.NewLine + "{INITIAL_V_VEL}: " + levelyspeed + Environment.NewLine + "{INC_H_VEL}: " + incrementx + Environment.NewLine + "{INC_V_VEL}: " + incrementy); - - switch (rand.Next(1, 3)) - { - case 1: - levelxspeed = levelxspeed + 1; - break; - case 2: - levelxspeed = levelxspeed + 2; - break; - } - - switch (rand.Next(1, 3)) - { - case 1: - levelyspeed = levelyspeed + 1; - break; - case 2: - levelyspeed = levelyspeed + 2; - break; - } - - switch (rand.Next(1, 6)) - { - case 1: - incrementx = incrementx + 0.1; - break; - case 2: - incrementx = incrementx + 0.2; - break; - case 3: - incrementy = incrementy + 0.1; - break; - case 4: - incrementy = incrementy + 0.2; - break; - case 5: - incrementy = incrementy + 0.3; - break; - } - - lblnextstats.Text = Localization.Parse("{INITIAL_H_VEL}: " + levelxspeed + Environment.NewLine + "{INITIAL_V_VEL}: " + levelyspeed + Environment.NewLine + "{INC_H_VEL}: " + incrementx + Environment.NewLine + "{INC_V_VEL}: " + incrementy); - - if (level < 15) - { - if (ShiftoriumFrontend.UpgradeInstalled("pong_upgrade")) - { - beataireward = level * 10; - } else - { - beataireward = level * 5; - } - } - else - { - if (ShiftoriumFrontend.UpgradeInstalled("pong_upgrade")) - { - double br = levelrewards[level - 1] / 10; - beataireward = (int)Math.Round(br) * 10; - } else - { - double br = levelrewards[level - 1] / 10; - beataireward = (int)Math.Round(br) * 5; - } - } - - totalreward = levelrewards[level - 1] + beatairewardtotal; - - btncashout.Text = Localization.Parse("{CASH_OUT_WITH_CODEPOINTS}"); - btnplayon.Text = Localization.Parse("{PONG_PLAY_ON_FOR_MORE}"); - } - - private void setuplevelrewards() - { - if (ShiftoriumFrontend.UpgradeInstalled("pong_upgrade")) - { - levelrewards[0] = 0; - levelrewards[1] = 40; - levelrewards[2] = 120; - levelrewards[3] = 280; - levelrewards[4] = 580; - levelrewards[5] = 800; - levelrewards[6] = 1200; - levelrewards[7] = 1800; - levelrewards[8] = 2400; - levelrewards[9] = 3200; - levelrewards[10] = 4000; - levelrewards[11] = 5000; - levelrewards[12] = 6000; - levelrewards[13] = 8000; - levelrewards[14] = 10000; - levelrewards[15] = 12000; - levelrewards[16] = 16000; - levelrewards[17] = 20000; - levelrewards[18] = 26000; - levelrewards[19] = 32000; - levelrewards[20] = 40000; - levelrewards[21] = 50000; - levelrewards[22] = 64000; - levelrewards[23] = 80000; - levelrewards[24] = 100000; - levelrewards[25] = 120000; - levelrewards[26] = 150000; - levelrewards[27] = 180000; - levelrewards[28] = 220000; - levelrewards[29] = 280000; - levelrewards[30] = 360000; - levelrewards[31] = 440000; - levelrewards[32] = 540000; - levelrewards[33] = 640000; - levelrewards[34] = 800000; - levelrewards[35] = 1000000; - levelrewards[36] = 1280000; - levelrewards[37] = 1600000; - levelrewards[38] = 2000000; - levelrewards[39] = 3000000; - levelrewards[40] = 4000000; - } else - { - levelrewards[0] = 0; - levelrewards[1] = 20; - levelrewards[2] = 60; - levelrewards[3] = 140; - levelrewards[4] = 290; - levelrewards[5] = 400; - levelrewards[6] = 600; - levelrewards[7] = 900; - levelrewards[8] = 1200; - levelrewards[9] = 1600; - levelrewards[10] = 2000; - levelrewards[11] = 2500; - levelrewards[12] = 3000; - levelrewards[13] = 4000; - levelrewards[14] = 5000; - levelrewards[15] = 6000; - levelrewards[16] = 8000; - levelrewards[17] = 10000; - levelrewards[18] = 13000; - levelrewards[19] = 16000; - levelrewards[20] = 20000; - levelrewards[21] = 25000; - levelrewards[22] = 32000; - levelrewards[23] = 40000; - levelrewards[24] = 50000; - levelrewards[25] = 60000; - levelrewards[26] = 75000; - levelrewards[27] = 90000; - levelrewards[28] = 110000; - levelrewards[29] = 140000; - levelrewards[30] = 180000; - levelrewards[31] = 220000; - levelrewards[32] = 270000; - levelrewards[33] = 320000; - levelrewards[34] = 400000; - levelrewards[35] = 500000; - levelrewards[36] = 640000; - levelrewards[37] = 800000; - levelrewards[38] = 1000000; - levelrewards[39] = 1500000; - levelrewards[40] = 2000000; - } - } - - // ERROR: Handles clauses are not supported in C# - private void countdown_Tick(object sender, EventArgs e) - { - if (this.Left < Screen.PrimaryScreen.Bounds.Width) - { - switch (countdown) - { - case 0: - countdown = 3; - lblcountdown.Hide(); - lblbeatai.Hide(); - gameTimer.Start(); - counter.Start(); - tmrcountdown.Stop(); - break; - case 1: - lblcountdown.Text = "1"; - countdown = countdown - 1; - ShiftOS.Engine.AudioManager.PlayStream(Properties.Resources.typesound); - break; - case 2: - lblcountdown.Text = "2"; - countdown = countdown - 1; - ShiftOS.Engine.AudioManager.PlayStream(Properties.Resources.typesound); - break; - case 3: - lblcountdown.Text = "3"; - countdown = countdown - 1; - lblcountdown.Show(); - ShiftOS.Engine.AudioManager.PlayStream(Properties.Resources.typesound); - break; - } - - } - } - - // ERROR: Handles clauses are not supported in C# - private void btncashout_Click(object sender, EventArgs e) - { - pnlgamestats.Hide(); - pnlfinalstats.Show(); - lblfinalcodepointswithtext.Text = Localization.Parse("{YOU_WON} " + totalreward + " {CODEPOINTS}!"); - lblfinallevelreached.Text = Localization.Parse("{CODEPOINTS_FOR_BEATING_LEVEL}: ") + (level - 1).ToString(); - lblfinallevelreward.Text = levelrewards[level - 1].ToString(); - lblfinalcomputerreward.Text = beatairewardtotal.ToString(); - lblfinalcodepoints.Text = totalreward + Localization.Parse(" {CODEPOINTS_SHORT}"); - SaveSystem.TransferCodepointsFrom("pong", totalreward); - if (!string.IsNullOrWhiteSpace(SaveSystem.CurrentSave.UniteAuthToken)) - { - var unite = new ShiftOS.Unite.UniteClient("http://getshiftos.ml", SaveSystem.CurrentSave.UniteAuthToken); - if (unite.GetPongCP() < totalreward) - { - unite.SetPongCP(totalreward); - } - } - } - - private void newgame() - { - pnlfinalstats.Hide(); - pnllose.Hide(); - pnlintro.Hide(); - - level = 1; - totalreward = 0; - if (ShiftoriumFrontend.UpgradeInstalled("pong_upgrade")) - { - beataireward = 10; - } else - { - beataireward = 5; - } - beatairewardtotal = 0; - secondsleft = 60; - lblstatscodepoints.Text = Localization.Parse("{CODEPOINTS}: "); - //reset stats text - lblstatsX.Text = Localization.Parse("{H_VEL}: "); - lblstatsY.Text = Localization.Parse("{V_VEL}: "); - - levelxspeed = 3; - levelyspeed = 3; - - incrementx = 0.4; - incrementy = 0.2; - - xveldec = levelxspeed; - yveldec = levelyspeed; - - tmrcountdown.Start(); - lblbeatai.Text = Localization.Parse($"{{PONG_BEAT_AI_REWARD}}: {beataireward}"); - pnlgamestats.Hide(); - lblbeatai.Show(); - ball.Location = new Point(paddleHuman.Location.X + paddleHuman.Width + 50, (paddleHuman.Location.Y + paddleHuman.Height) / 2); - if (xVel < 0) - xVel = Math.Abs(xVel); - lbllevelandtime.Text = Localization.Parse("{{LEVEL}}: " + level + " - " + secondsleft + " {SECONDS_LEFT}"); - } - - public void btnhighscore_Click(object s, EventArgs a) - { - pnlhighscore.BringToFront(); - SetupHighScores(); - } - - bool IsMultiplayerSession = false; - - string YouGUID = ""; - string OpponentGUID = ""; - - public void SetupHighScores() - { - lbhighscore.Items.Clear(); - lbhighscore.View = View.Details; - lbhighscore.FullRowSelect = true; - lbhighscore.Columns.Clear(); - var n = new ColumnHeader(); - n.Text = "Player"; - n.Width = lbhighscore.Width / 3; - var l = new ColumnHeader(); - l.Text = "Level"; - l.Width = n.Width; - var c = new ColumnHeader(); - c.Text = "Codepoints"; - c.Width = n.Width; - lbhighscore.Columns.Add(n); - lbhighscore.Columns.Add(l); - lbhighscore.Columns.Add(c); - - var t = new Thread(() => - { - try - { - - var unite = new ShiftOS.Unite.UniteClient("http://getshiftos.ml", SaveSystem.CurrentSave.UniteAuthToken); - var hs = unite.GetPongHighscores(); - foreach (var score in hs.Highscores) - { - string username = unite.GetDisplayNameId(score.UserId); - this.Invoke(new Action(() => - { - var name_item = new ListViewItem(); - name_item.Text = username; - lbhighscore.Items.Add(name_item); - name_item.SubItems.Add(score.Level.ToString()); - name_item.SubItems.Add(score.CodepointsCashout.ToString()); - })); - } - } - catch - { - Infobox.Show("Service unavailable.", "The Pong Highscore service is unavailable at this time."); - this.Invoke(new Action(pnlgamestats.BringToFront)); - return; - } - }); - t.Start(); - pnlhighscore.Show(); - } - - // ERROR: Handles clauses are not supported in C# - private void btnplayagain_Click(object sender, EventArgs e) - { - newgame(); - } - - // ERROR: Handles clauses are not supported in C# - private void btnlosetryagain_Click(object sender, EventArgs e) - { - newgame(); - } - - public void StartLevel() - { - newgame(); - } - - // ERROR: Handles clauses are not supported in C# - private void btnstartgame_Click(object sender, EventArgs e) - { - newgame(); - } - - Random rand = new Random(); - // ERROR: Handles clauses are not supported in C# - private void tmrstoryline_Tick(object sender, EventArgs e) - { - // Random chance of showing getshiftnet storyline - int i = rand.Next(0, 100); - - if (i >= 25 && i <= 50) - { - tmrstoryline.Stop(); - } - - } - - // ERROR: Handles clauses are not supported in C# - private void me_closing(object sender, FormClosingEventArgs e) - { - tmrstoryline.Stop(); - } - - private void Label6_Click(object sender, EventArgs e) - { - - } - - private void Label8_Click(object sender, EventArgs e) - { - - } - - private void pgcontents_Paint(object sender, PaintEventArgs e) { - - } - - private void ball_MouseEnter(object sender, EventArgs e) { - aiShouldIsbeEnabled = false; - } - - private void ball_MouseLeave(object sender, EventArgs e) { - aiShouldIsbeEnabled = true; - } - - public void OnLoad() - { - pnlintro.BringToFront(); - pnlintro.Show(); - pnlhighscore.Hide(); - pnlgamestats.Hide(); - pnlfinalstats.Hide(); - CenterPanels(); - lblbeatai.Hide(); - } - - public void OnSkinLoad() - { - CenterPanels(); - this.SizeChanged += (o, a) => - { - CenterPanels(); - }; - } - - public bool OnUnload() - { - return true; - } - - public void OnUpgrade() - { - CenterPanels(); - } - - private void button2_Click(object sender, EventArgs e) - { - pnlhighscore.Hide(); - } - - private void btnmatchmake_Click(object sender, EventArgs e) - { - this.StartMultiplayer(); - pnlintro.Hide(); - lblbeatai.Text = "Beat the other player to earn Codepoints."; - lblcountdown.Text = "Waiting for another player..."; - lblcountdown.Left = (this.Width - lblcountdown.Width) / 2; - } - } -} diff --git a/ShiftOS.WinForms/Applications/ShiftoriumFrontend.Designer.cs b/ShiftOS.WinForms/Applications/ShiftoriumFrontend.Designer.cs deleted file mode 100644 index 32d508b..0000000 --- a/ShiftOS.WinForms/Applications/ShiftoriumFrontend.Designer.cs +++ /dev/null @@ -1,317 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -using ShiftOS.WinForms.Controls; - -namespace ShiftOS.WinForms.Applications -{ - partial class ShiftoriumFrontend - { - /// - /// 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.panel2 = new System.Windows.Forms.Panel(); - this.lbupgradedesc = new System.Windows.Forms.Label(); - this.pnlupgradeactions = new System.Windows.Forms.Panel(); - this.btnbuy = new System.Windows.Forms.Button(); - this.lbupgradetitle = new System.Windows.Forms.Label(); - this.pnllist = new System.Windows.Forms.Panel(); - this.lbcodepoints = new System.Windows.Forms.Label(); - this.label1 = new System.Windows.Forms.Label(); - this.pgupgradeprogress = new ShiftOS.WinForms.Controls.ShiftedProgressBar(); - this.lbupgrades = new System.Windows.Forms.ListBox(); - this.label3 = new System.Windows.Forms.Label(); - this.panel3 = new System.Windows.Forms.Panel(); - this.btncat_back = new System.Windows.Forms.Button(); - this.btncat_forward = new System.Windows.Forms.Button(); - this.lblcategorytext = new System.Windows.Forms.Label(); - this.lbnoupgrades = new System.Windows.Forms.Label(); - this.panel1.SuspendLayout(); - this.panel2.SuspendLayout(); - this.pnlupgradeactions.SuspendLayout(); - this.pnllist.SuspendLayout(); - this.panel3.SuspendLayout(); - this.SuspendLayout(); - // - // panel1 - // - this.panel1.Controls.Add(this.panel2); - this.panel1.Controls.Add(this.pnllist); - 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(782, 427); - this.panel1.TabIndex = 0; - // - // panel2 - // - this.panel2.Controls.Add(this.lbupgradedesc); - this.panel2.Controls.Add(this.pnlupgradeactions); - this.panel2.Controls.Add(this.lbupgradetitle); - this.panel2.Dock = System.Windows.Forms.DockStyle.Fill; - this.panel2.Location = new System.Drawing.Point(406, 0); - this.panel2.Name = "panel2"; - this.panel2.Size = new System.Drawing.Size(376, 427); - this.panel2.TabIndex = 1; - // - // lbupgradedesc - // - this.lbupgradedesc.Dock = System.Windows.Forms.DockStyle.Fill; - this.lbupgradedesc.Location = new System.Drawing.Point(0, 42); - this.lbupgradedesc.Name = "lbupgradedesc"; - this.lbupgradedesc.Size = new System.Drawing.Size(376, 348); - this.lbupgradedesc.TabIndex = 2; - this.lbupgradedesc.Text = "{SHIFTORIUM_EXP}"; - this.lbupgradedesc.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.lbupgradedesc.UseCompatibleTextRendering = true; - // - // pnlupgradeactions - // - this.pnlupgradeactions.Controls.Add(this.btnbuy); - this.pnlupgradeactions.Dock = System.Windows.Forms.DockStyle.Bottom; - this.pnlupgradeactions.Location = new System.Drawing.Point(0, 390); - this.pnlupgradeactions.Name = "pnlupgradeactions"; - this.pnlupgradeactions.Size = new System.Drawing.Size(376, 37); - this.pnlupgradeactions.TabIndex = 1; - // - // btnbuy - // - this.btnbuy.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.btnbuy.AutoSize = true; - this.btnbuy.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.btnbuy.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btnbuy.Location = new System.Drawing.Point(327, 9); - this.btnbuy.Name = "btnbuy"; - this.btnbuy.Size = new System.Drawing.Size(37, 25); - this.btnbuy.TabIndex = 0; - this.btnbuy.Text = "Buy"; - this.btnbuy.UseVisualStyleBackColor = true; - this.btnbuy.Visible = false; - this.btnbuy.Click += new System.EventHandler(this.btnbuy_Click); - // - // lbupgradetitle - // - this.lbupgradetitle.Dock = System.Windows.Forms.DockStyle.Top; - this.lbupgradetitle.Location = new System.Drawing.Point(0, 0); - this.lbupgradetitle.Name = "lbupgradetitle"; - this.lbupgradetitle.Size = new System.Drawing.Size(376, 42); - this.lbupgradetitle.TabIndex = 0; - this.lbupgradetitle.Text = "{WELCOME_TO_SHIFTORIUM}"; - this.lbupgradetitle.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.lbupgradetitle.UseCompatibleTextRendering = true; - // - // pnllist - // - this.pnllist.Controls.Add(this.lbnoupgrades); - this.pnllist.Controls.Add(this.panel3); - this.pnllist.Controls.Add(this.lbcodepoints); - this.pnllist.Controls.Add(this.label1); - this.pnllist.Controls.Add(this.pgupgradeprogress); - this.pnllist.Controls.Add(this.lbupgrades); - this.pnllist.Dock = System.Windows.Forms.DockStyle.Left; - this.pnllist.Location = new System.Drawing.Point(0, 0); - this.pnllist.Name = "pnllist"; - this.pnllist.Size = new System.Drawing.Size(406, 427); - this.pnllist.TabIndex = 0; - // - // lbcodepoints - // - this.lbcodepoints.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.lbcodepoints.AutoSize = true; - this.lbcodepoints.Location = new System.Drawing.Point(128, 357); - this.lbcodepoints.Name = "lbcodepoints"; - this.lbcodepoints.Size = new System.Drawing.Size(135, 13); - this.lbcodepoints.TabIndex = 3; - this.lbcodepoints.Text = "You have: %cp Codepoints"; - this.lbcodepoints.Click += new System.EventHandler(this.lbcodepoints_Click); - // - // label1 - // - this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(3, 399); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(137, 13); - this.label1.TabIndex = 2; - this.label1.Text = "{UPGRADE_PROGRESS}:"; - // - // pgupgradeprogress - // - this.pgupgradeprogress.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.pgupgradeprogress.BlockSize = 5; - this.pgupgradeprogress.Location = new System.Drawing.Point(146, 390); - this.pgupgradeprogress.Maximum = 100; - this.pgupgradeprogress.Name = "pgupgradeprogress"; - this.pgupgradeprogress.Size = new System.Drawing.Size(254, 23); - this.pgupgradeprogress.Style = System.Windows.Forms.ProgressBarStyle.Continuous; - this.pgupgradeprogress.TabIndex = 1; - this.pgupgradeprogress.Value = 25; - // - // lbupgrades - // - this.lbupgrades.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.lbupgrades.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed; - this.lbupgrades.FormattingEnabled = true; - this.lbupgrades.Location = new System.Drawing.Point(3, 105); - this.lbupgrades.Name = "lbupgrades"; - this.lbupgrades.Size = new System.Drawing.Size(397, 238); - this.lbupgrades.TabIndex = 0; - this.lbupgrades.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.lbupgrades_DrawItem); - // - // label3 - // - this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(3, 399); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(137, 13); - this.label3.TabIndex = 2; - // - // panel3 - // - this.panel3.Controls.Add(this.lblcategorytext); - this.panel3.Controls.Add(this.btncat_forward); - this.panel3.Controls.Add(this.btncat_back); - this.panel3.Location = new System.Drawing.Point(6, 76); - this.panel3.Name = "panel3"; - this.panel3.Size = new System.Drawing.Size(394, 23); - this.panel3.TabIndex = 5; - // - // btncat_back - // - this.btncat_back.AutoSize = true; - this.btncat_back.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.btncat_back.Dock = System.Windows.Forms.DockStyle.Left; - this.btncat_back.Location = new System.Drawing.Point(0, 0); - this.btncat_back.Name = "btncat_back"; - this.btncat_back.Size = new System.Drawing.Size(29, 23); - this.btncat_back.TabIndex = 0; - this.btncat_back.Text = "<--"; - this.btncat_back.UseVisualStyleBackColor = true; - this.btncat_back.Click += new System.EventHandler(this.btncat_back_Click); - // - // btncat_forward - // - this.btncat_forward.AutoSize = true; - this.btncat_forward.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.btncat_forward.Dock = System.Windows.Forms.DockStyle.Right; - this.btncat_forward.Location = new System.Drawing.Point(365, 0); - this.btncat_forward.Name = "btncat_forward"; - this.btncat_forward.Size = new System.Drawing.Size(29, 23); - this.btncat_forward.TabIndex = 1; - this.btncat_forward.Text = "-->"; - this.btncat_forward.UseVisualStyleBackColor = true; - this.btncat_forward.Click += new System.EventHandler(this.btncat_forward_Click); - // - // lblcategorytext - // - this.lblcategorytext.Dock = System.Windows.Forms.DockStyle.Fill; - this.lblcategorytext.Location = new System.Drawing.Point(29, 0); - this.lblcategorytext.Name = "lblcategorytext"; - this.lblcategorytext.Size = new System.Drawing.Size(336, 23); - this.lblcategorytext.TabIndex = 2; - this.lblcategorytext.Text = "label2"; - this.lblcategorytext.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // lbnoupgrades - // - this.lbnoupgrades.AutoSize = true; - this.lbnoupgrades.Location = new System.Drawing.Point(69, 183); - this.lbnoupgrades.Name = "lbnoupgrades"; - this.lbnoupgrades.Size = new System.Drawing.Size(71, 13); - this.lbnoupgrades.TabIndex = 6; - this.lbnoupgrades.Tag = "header2"; - this.lbnoupgrades.Text = "No upgrades!"; - this.lbnoupgrades.Visible = false; - // - // ShiftoriumFrontend - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.Black; - this.Controls.Add(this.panel1); - this.ForeColor = System.Drawing.Color.LightGreen; - this.Name = "ShiftoriumFrontend"; - this.Size = new System.Drawing.Size(782, 427); - this.Load += new System.EventHandler(this.Shiftorium_Load); - this.panel1.ResumeLayout(false); - this.panel2.ResumeLayout(false); - this.pnlupgradeactions.ResumeLayout(false); - this.pnlupgradeactions.PerformLayout(); - this.pnllist.ResumeLayout(false); - this.pnllist.PerformLayout(); - this.panel3.ResumeLayout(false); - this.panel3.PerformLayout(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.Panel panel1; - private System.Windows.Forms.Panel panel2; - private System.Windows.Forms.Panel pnllist; - private System.Windows.Forms.ListBox lbupgrades; - private System.Windows.Forms.Label lbupgradedesc; - private System.Windows.Forms.Panel pnlupgradeactions; - private System.Windows.Forms.Label lbupgradetitle; - private System.Windows.Forms.Button btnbuy; - private ShiftedProgressBar pgupgradeprogress; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.Label lbcodepoints; - private System.Windows.Forms.Label label3; - private System.Windows.Forms.Panel panel3; - private System.Windows.Forms.Label lblcategorytext; - private System.Windows.Forms.Button btncat_forward; - private System.Windows.Forms.Button btncat_back; - private System.Windows.Forms.Label lbnoupgrades; - } -} \ No newline at end of file diff --git a/ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs b/ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs deleted file mode 100644 index 66b0448..0000000 --- a/ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs +++ /dev/null @@ -1,274 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; -using ShiftOS.Engine; -using static ShiftOS.Engine.SkinEngine; -using backend = ShiftOS.Engine.Shiftorium; -namespace ShiftOS.WinForms.Applications -{ - [Launcher("Shiftorium", true, "al_shiftorium", "Utilities")] - [RequiresUpgrade("shiftorium_gui")] - [MultiplayerOnly] - [WinOpen("shiftorium")] - [DefaultTitle("Shiftorium")] - [DefaultIcon("iconShiftorium")] - public partial class ShiftoriumFrontend : UserControl, IShiftOSWindow - { - public int CategoryId = 0; - public static System.Timers.Timer timer100; - - - public ShiftoriumFrontend() - { - cp_update = new System.Windows.Forms.Timer(); - cp_update.Tick += (o, a) => - { - lbcodepoints.Text = $"You have {SaveSystem.CurrentSave.Codepoints} Codepoints."; - }; - cp_update.Interval = 100; - InitializeComponent(); - PopulateShiftorium(); - lbupgrades.SelectedIndexChanged += (o, a) => - { - try - { - lbupgrades.Refresh(); - SelectUpgrade(lbupgrades.SelectedItem.ToString()); - } - catch { } - }; - this.pgupgradeprogress.Maximum = backend.GetDefaults().Count; - this.pgupgradeprogress.Value = SaveSystem.CurrentSave.CountUpgrades(); - backend.Installed += () => - { - this.pgupgradeprogress.Maximum = backend.GetDefaults().Count; - this.pgupgradeprogress.Value = SaveSystem.CurrentSave.CountUpgrades(); - }; - - } - - public void SelectUpgrade(string name) - { - btnbuy.Show(); - var upg = upgrades[name]; - lbupgradetitle.Text = Localization.Parse(upg.Name); - lbupgradedesc.Text = Localization.Parse(upg.Description); - } - - Dictionary upgrades = new Dictionary(); - - public void PopulateShiftorium() - { - try - { - lbnoupgrades.Hide(); - lbupgrades.Items.Clear(); - upgrades.Clear(); - Timer(); - - foreach (var upg in backend.GetAvailable().Where(x => x.Category == backend.GetCategories()[CategoryId])) - { - String name = Localization.Parse(upg.Name) + " - " + upg.Cost.ToString() + "CP"; - upgrades.Add(name, upg); - lbupgrades.Items.Add(name); - } - - if (lbupgrades.Items.Count == 0) - { - lbnoupgrades.Show(); - lbnoupgrades.Location = new Point( - (lbupgrades.Width - lbnoupgrades.Width) / 2, - (lbupgrades.Height - lbnoupgrades.Height) / 2 - ); - - } - else - { - lbnoupgrades.Hide(); - } - lblcategorytext.Text = Shiftorium.GetCategories()[CategoryId]; - btncat_back.Visible = (CategoryId > 0); - btncat_forward.Visible = (CategoryId < backend.GetCategories().Length - 1); - } - catch - { - lbnoupgrades.Show(); - lbnoupgrades.Location = new Point( - (lbupgrades.Width - lbnoupgrades.Width) / 2, - (lbupgrades.Height - lbnoupgrades.Height) / 2 - ); - - } - } - - public static bool UpgradeInstalled(string upg) - { - return backend.UpgradeInstalled(upg); - } - - public static bool UpgradeAttributesUnlocked(FieldInfo finf) - { - return backend.UpgradeAttributesUnlocked(finf); - } - - public static bool UpgradeAttributesUnlocked(MethodInfo finf) - { - return backend.UpgradeAttributesUnlocked(finf); - } - - public static bool UpgradeAttributesUnlocked(Type finf) - { - return backend.UpgradeAttributesUnlocked(finf); - } - - public static bool UpgradeAttributesUnlocked(PropertyInfo finf) - { - return backend.UpgradeAttributesUnlocked(finf); - } - - private void lbupgrades_DrawItem(object sender, DrawItemEventArgs e) - { - var foreground = new SolidBrush(LoadedSkin.ControlTextColor); - var background = new SolidBrush(LoadedSkin.ControlColor); - - e.Graphics.FillRectangle(background, e.Bounds); - try - { - if (lbupgrades.GetSelected(e.Index) == true) - { - e.Graphics.FillRectangle(foreground, e.Bounds); - e.Graphics.DrawString(lbupgrades.Items[e.Index].ToString(), e.Font, background, e.Bounds.Location); - } - else - { - e.Graphics.FillRectangle(background, e.Bounds); - e.Graphics.DrawString(lbupgrades.Items[e.Index].ToString(), e.Font, foreground, e.Bounds.Location); - } - } - catch - { - } - } - - private void btnbuy_Click(object sender, EventArgs e) - { - long cpCost = 0; - backend.Silent = true; - Dictionary UpgradesToBuy = new Dictionary(); - foreach (var itm in lbupgrades.SelectedItems) - { - cpCost += upgrades[itm.ToString()].Cost; - UpgradesToBuy.Add(upgrades[itm.ToString()].ID, upgrades[itm.ToString()].Cost); - } - if (SaveSystem.CurrentSave.Codepoints < cpCost) - { - Infobox.Show("Insufficient Codepoints", $"You do not have enough Codepoints to perform this action. You need {cpCost - SaveSystem.CurrentSave.Codepoints} more."); - - } - else - { - foreach(var upg in UpgradesToBuy) - { - backend.Buy(upg.Key, upg.Value); - } - } - - backend.Silent = false; - PopulateShiftorium(); - btnbuy.Hide(); - } - - private void Shiftorium_Load(object sender, EventArgs e) { - - } - - public void OnLoad() - { - cp_update.Start(); - lbnoupgrades.Hide(); - } - - public void OnSkinLoad() - { - - } - - Timer cp_update = new System.Windows.Forms.Timer(); - - public bool OnUnload() - { - cp_update.Stop(); - cp_update = null; - return true; - } - - public void OnUpgrade() - { - lbupgrades.SelectionMode = (UpgradeInstalled("shiftorium_gui_bulk_buy") == true) ? SelectionMode.MultiExtended : SelectionMode.One; - lbcodepoints.Visible = Shiftorium.UpgradeInstalled("shiftorium_gui_codepoints_display"); - } - - private void lbcodepoints_Click(object sender, EventArgs e) - { - - } - - void Timer() - { - timer100 = new System.Timers.Timer(); - timer100.Interval = 2000; - //timer100.Elapsed += ???; - timer100.AutoReset = true; - timer100.Enabled = true; - } - - private void btncat_back_Click(object sender, EventArgs e) - { - if(CategoryId > 0) - { - CategoryId--; - PopulateShiftorium(); - } - } - - private void btncat_forward_Click(object sender, EventArgs e) - { - if(CategoryId < backend.GetCategories().Length - 1) - { - CategoryId++; - PopulateShiftorium(); - } - } - } -} diff --git a/ShiftOS.WinForms/Applications/Skin Loader.cs b/ShiftOS.WinForms/Applications/Skin Loader.cs deleted file mode 100644 index 1f09e4a..0000000 --- a/ShiftOS.WinForms/Applications/Skin Loader.cs +++ /dev/null @@ -1,342 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -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; -using Newtonsoft.Json; -using ShiftOS.Engine; -using ShiftOS.WinForms.Tools; - -namespace ShiftOS.WinForms.Applications -{ - [Launcher("Skin Loader", true, "al_skin_loader", "Customization")] - [RequiresUpgrade("skinning")] - [WinOpen("skin_loader")] - [DefaultTitle("Skin Loader")] - [DefaultIcon("iconSkinLoader")] - public partial class Skin_Loader : UserControl, IShiftOSWindow - { - public Skin_Loader() - { - InitializeComponent(); - SetupControls(pnlborder); - SetupControls(pnldesktop); - LoadedSkin = JsonConvert.DeserializeObject(JsonConvert.SerializeObject(SkinEngine.LoadedSkin)); - this.Load += (o, a) => { SetupUI(); }; - - } - - public void SetupControls(Control ctrl) - { - ctrl.Tag = "keepbg keepfg keepfont"; - foreach (Control c in ctrl.Controls) - SetupControls(c); - } - - public Skin LoadedSkin { get; set; } - - public void SetupUI() - { - SetupDesktop(); - Setup(); - } - - public void SetupDesktop() - { - menuStrip1.Renderer = new ShiftOSMenuRenderer(); - - this.DoubleBuffered = true; - desktoppanel.BackColor = Color.Green; - - //upgrades - - if (SaveSystem.CurrentSave != null) - { - desktoppanel.Visible = ShiftoriumFrontend.UpgradeInstalled("desktop"); - lbtime.Visible = ShiftoriumFrontend.UpgradeInstalled("desktop_clock_widget"); - - //skinning - lbtime.ForeColor = LoadedSkin.DesktopPanelClockColor; - - sysmenuholder.Visible = ShiftoriumFrontend.UpgradeInstalled("app_launcher"); - - //The Color Picker can give us transparent colors - which Windows Forms fucking despises when dealing with form backgrounds. - //To compensate, we must recreate the desktop color and make the alpha channel '255'. - pnldesktop.BackColor = Color.FromArgb(LoadedSkin.DesktopColor.R, LoadedSkin.DesktopColor.G, LoadedSkin.DesktopColor.B); - //Not doing this will cause an ArgumentException. - - pnldesktop.BackgroundImage = GetImage("desktopbackground"); - pnldesktop.BackgroundImageLayout = GetImageLayout("desktopbackground"); - desktoppanel.BackgroundImage = GetImage("desktoppanel"); - menuStrip1.BackgroundImage = GetImage("applauncher"); - lbtime.ForeColor = LoadedSkin.DesktopPanelClockColor; - lbtime.Font = LoadedSkin.DesktopPanelClockFont; - lbtime.Text = Applications.Terminal.GetTime(); - lbtime.Left = desktoppanel.Width - lbtime.Width - LoadedSkin.DesktopPanelClockFromRight.X; - lbtime.Top = LoadedSkin.DesktopPanelClockFromRight.Y; - - if (desktoppanel.BackgroundImage == null) - { - lbtime.BackColor = LoadedSkin.DesktopPanelClockBackgroundColor; - } - else - { - lbtime.BackColor = Color.Transparent; - } - apps.Text = LoadedSkin.AppLauncherText; - sysmenuholder.Location = LoadedSkin.AppLauncherFromLeft; - sysmenuholder.Size = LoadedSkin.AppLauncherHolderSize; - apps.Size = sysmenuholder.Size; - menuStrip1.Renderer = new ShiftOSMenuRenderer(new AppLauncherColorTable()); - desktoppanel.BackColor = LoadedSkin.DesktopPanelColor; - desktoppanel.BackgroundImageLayout = GetImageLayout("desktoppanel"); - desktoppanel.Height = LoadedSkin.DesktopPanelHeight; - if (LoadedSkin.DesktopPanelPosition == 1) - { - desktoppanel.Dock = DockStyle.Bottom; - } - else - { - desktoppanel.Dock = DockStyle.Top; - } - } - - } - - public ImageLayout GetImageLayout(string img) - { - if (LoadedSkin.SkinImageLayouts.ContainsKey(img)) - { - return LoadedSkin.SkinImageLayouts[img]; - } - else - { - LoadedSkin.SkinImageLayouts.Add(img, ImageLayout.Tile); - return ImageLayout.Tile; - } - } - - public Image GetImage(string img) - { - var type = typeof(Skin); - - foreach (var field in type.GetFields()) - { - foreach (var attr in field.GetCustomAttributes(false)) - { - if (attr is ImageAttribute) - { - var iattr = attr as ImageAttribute; - if (iattr.Name == img) - { - byte[] image = (byte[])field.GetValue(LoadedSkin); - return SkinEngine.ImageFromBinary(image); - } - } - } - } - - return null; - } - - bool IsDialog = false; - - public void Setup() - { - pnlcontents.BackColor = LoadedSkin.ControlColor; - - this.lbtitletext.Text = Localization.Parse("{TEMPLATE}"); - this.Dock = DockStyle.Fill; - - if (SaveSystem.CurrentSave != null) - { - this.pnltitle.Visible = ShiftoriumFrontend.UpgradeInstalled("wm_titlebar"); - this.pnlclose.Visible = ShiftoriumFrontend.UpgradeInstalled("close_button"); - this.pnlminimize.Visible = (IsDialog == false) && ShiftoriumFrontend.UpgradeInstalled("minimize_button"); - this.pnlmaximize.Visible = (IsDialog == false) && ShiftoriumFrontend.UpgradeInstalled("maximize_button"); - SetupSkin(); - } - else - { - this.pnltitle.Visible = false; - this.pnlclose.Visible = false; - this.pnlminimize.Visible = false; - this.pnlmaximize.Visible = false; - - } - } - - public void SetupSkin() - { - pnltitlemaster.Height = LoadedSkin.TitlebarHeight; - pnltitle.BackColor = LoadedSkin.TitleBackgroundColor; - pnltitle.BackgroundImage = GetImage("titlebar"); - pnltitleleft.Visible = LoadedSkin.ShowTitleCorners; - pnltitleright.Visible = LoadedSkin.ShowTitleCorners; - pnltitleleft.BackColor = LoadedSkin.TitleLeftCornerBackground; - pnltitleright.BackColor = LoadedSkin.TitleRightCornerBackground; - pnltitleleft.Width = LoadedSkin.TitleLeftCornerWidth; - pnltitleright.Width = LoadedSkin.TitleRightCornerWidth; - pnltitleleft.BackgroundImage = GetImage("titleleft"); - pnltitleleft.BackgroundImageLayout = GetImageLayout("titleleft"); - pnltitleright.BackgroundImage = GetImage("titleright"); - pnltitleright.BackgroundImageLayout = GetImageLayout("titleright"); - - - lbtitletext.BackColor = LoadedSkin.TitleBackgroundColor; - lbtitletext.ForeColor = LoadedSkin.TitleTextColor; - lbtitletext.Font = LoadedSkin.TitleFont; - - pnlleft.BackColor = LoadedSkin.BorderLeftBackground; - pnlleft.BackgroundImage = GetImage("leftborder"); - pnlleft.BackgroundImageLayout = GetImageLayout("leftborder"); - pnlleft.Width = LoadedSkin.LeftBorderWidth; - pnlright.BackColor = LoadedSkin.BorderRightBackground; - pnlright.BackgroundImage = GetImage("rightborder"); - pnlright.BackgroundImageLayout = GetImageLayout("rightborder"); - pnlright.Width = LoadedSkin.RightBorderWidth; - - pnlbottom.BackColor = LoadedSkin.BorderBottomBackground; - pnlbottom.BackgroundImage = GetImage("bottomborder"); - pnlbottom.BackgroundImageLayout = GetImageLayout("bottomborder"); - pnlbottom.Height = LoadedSkin.BottomBorderWidth; - - pnlbottomr.BackColor = LoadedSkin.BorderBottomRightBackground; - pnlbottomr.BackgroundImage = GetImage("bottomrborder"); - pnlbottomr.BackgroundImageLayout = GetImageLayout("bottomrborder"); - pnlbottoml.BackColor = LoadedSkin.BorderBottomLeftBackground; - pnlbottoml.BackgroundImage = GetImage("bottomlborder"); - pnlbottoml.BackgroundImageLayout = GetImageLayout("bottomlborder"); - - lbtitletext.ForeColor = LoadedSkin.TitleTextColor; - lbtitletext.Font = LoadedSkin.TitleFont; - pnlclose.BackColor = LoadedSkin.CloseButtonColor; - pnlclose.BackgroundImage = GetImage("closebutton"); - pnlclose.BackgroundImageLayout = GetImageLayout("closebutton"); - pnlminimize.BackColor = LoadedSkin.MinimizeButtonColor; - pnlminimize.BackgroundImage = GetImage("minimizebutton"); - pnlminimize.BackgroundImageLayout = GetImageLayout("minimizebutton"); - pnlmaximize.BackColor = LoadedSkin.MaximizeButtonColor; - pnlmaximize.BackgroundImage = GetImage("maximizebutton"); - pnlmaximize.BackgroundImageLayout = GetImageLayout("maximizebutton"); - - pnlclose.Size = LoadedSkin.CloseButtonSize; - pnlminimize.Size = LoadedSkin.MinimizeButtonSize; - pnlmaximize.Size = LoadedSkin.MaximizeButtonSize; - pnlclose.Location = FromRight(LoadedSkin.CloseButtonFromSide); - pnlminimize.Location = FromRight(LoadedSkin.MinimizeButtonFromSide); - pnlmaximize.Location = FromRight(LoadedSkin.MaximizeButtonFromSide); - pnlclose.Left -= pnlclose.Width; - pnlmaximize.Left -= pnlmaximize.Width; - pnlminimize.Left -= pnlminimize.Width; - - switch (LoadedSkin.TitleTextCentered) - { - case false: - lbtitletext.Location = LoadedSkin.TitleTextLeft; - break; - default: - lbtitletext.Left = (pnltitle.Width - lbtitletext.Width) / 2; - lbtitletext.Top = LoadedSkin.TitleTextLeft.Y; - break; - } - } - - public Point FromRight(Point input) - { - return new Point(pnltitle.Width - input.X, input.Y); - } - - private void btnapply_Click(object sender, EventArgs e) - { - ShiftOS.Objects.ShiftFS.Utils.WriteAllText(Paths.GetPath("skin.json"), JsonConvert.SerializeObject(LoadedSkin)); - SkinEngine.LoadSkin(); - } - - private void btnclose_Click(object sender, EventArgs e) - { - this.Close(); - } - - private void btnloaddefault_Click(object sender, EventArgs e) - { - this.LoadedSkin = new ShiftOS.Engine.Skin(); - SetupUI(); - } - - private void btnexport_Click(object sender, EventArgs e) - { - AppearanceManager.SetupDialog(new FileDialog(new[] { ".skn" }, FileOpenerStyle.Save, new Action((filename) => - { - ShiftOS.Objects.ShiftFS.Utils.WriteAllText(filename, JsonConvert.SerializeObject(LoadedSkin)); - string fname = filename.Split('/')[filename.Split('/').Length - 1]; - if(!System.IO.Directory.Exists(Paths.SharedFolder + "\\skins")) - { - System.IO.Directory.CreateDirectory(Paths.SharedFolder + "\\skins"); - } - - string path = Paths.SharedFolder + "\\skins\\" + SaveSystem.CurrentSave.Username + "-" + fname; - System.IO.File.WriteAllText(path, JsonConvert.SerializeObject(LoadedSkin)); - - }))); - } - - private void btnimport_Click(object sender, EventArgs e) - { - AppearanceManager.SetupDialog(new FileDialog(new[] { ".skn" }, FileOpenerStyle.Open, new Action((filename) => - { - LoadedSkin = JsonConvert.DeserializeObject(ShiftOS.Objects.ShiftFS.Utils.ReadAllText(filename)); - SetupUI(); - }))); - } - - public void OnLoad() - { - - SetupUI(); - } - - public void OnSkinLoad() - { - SetupUI(); - } - - public bool OnUnload() - { - return true; - } - - public void OnUpgrade() - { - SetupUI(); - } - } -} diff --git a/ShiftOS.WinForms/Applications/TriWrite.Designer.cs b/ShiftOS.WinForms/Applications/TriWrite.Designer.cs deleted file mode 100644 index e420fd5..0000000 --- a/ShiftOS.WinForms/Applications/TriWrite.Designer.cs +++ /dev/null @@ -1,192 +0,0 @@ -namespace ShiftOS.WinForms.Applications -{ - partial class TriWrite - { - /// - /// 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() - { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(TriWrite)); - this.menuStrip1 = new System.Windows.Forms.MenuStrip(); - this.addContactToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.removeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.tvcontacts = new System.Windows.Forms.TreeView(); - this.panel1 = new System.Windows.Forms.Panel(); - this.txtbody = new System.Windows.Forms.Label(); - this.lbtitle = new System.Windows.Forms.Label(); - this.txtcontents = new System.Windows.Forms.TextBox(); - this.menuStrip2 = new System.Windows.Forms.MenuStrip(); - this.newToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.openToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.menuStrip3 = new System.Windows.Forms.MenuStrip(); - this.menuStrip1.SuspendLayout(); - this.panel1.SuspendLayout(); - this.menuStrip2.SuspendLayout(); - this.SuspendLayout(); - // - // menuStrip1 - // - this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.addContactToolStripMenuItem, - this.removeToolStripMenuItem}); - this.menuStrip1.Location = new System.Drawing.Point(0, 0); - this.menuStrip1.Name = "menuStrip1"; - this.menuStrip1.Size = new System.Drawing.Size(872, 24); - this.menuStrip1.TabIndex = 0; - this.menuStrip1.Text = "menuStrip1"; - // - // addContactToolStripMenuItem - // - this.addContactToolStripMenuItem.Name = "addContactToolStripMenuItem"; - this.addContactToolStripMenuItem.Size = new System.Drawing.Size(32, 19); - // - // removeToolStripMenuItem - // - this.removeToolStripMenuItem.Name = "removeToolStripMenuItem"; - this.removeToolStripMenuItem.Size = new System.Drawing.Size(32, 19); - // - // tvcontacts - // - this.tvcontacts.Dock = System.Windows.Forms.DockStyle.Left; - this.tvcontacts.Location = new System.Drawing.Point(0, 24); - this.tvcontacts.Name = "tvcontacts"; - this.tvcontacts.Size = new System.Drawing.Size(224, 551); - this.tvcontacts.TabIndex = 1; - // - // panel1 - // - this.panel1.Controls.Add(this.txtbody); - this.panel1.Controls.Add(this.lbtitle); - this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; - this.panel1.Location = new System.Drawing.Point(224, 24); - this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(648, 551); - this.panel1.TabIndex = 2; - // - // txtbody - // - this.txtbody.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.txtbody.Location = new System.Drawing.Point(7, 54); - this.txtbody.Name = "txtbody"; - this.txtbody.Size = new System.Drawing.Size(626, 481); - this.txtbody.TabIndex = 1; - this.txtbody.Text = resources.GetString("txtbody.Text"); - // - // lbtitle - // - this.lbtitle.AutoSize = true; - this.lbtitle.Location = new System.Drawing.Point(7, 4); - this.lbtitle.Name = "lbtitle"; - this.lbtitle.Size = new System.Drawing.Size(44, 13); - this.lbtitle.TabIndex = 0; - this.lbtitle.Tag = "header1"; - this.lbtitle.Text = "TriWrite"; - // - // txtcontents - // - this.txtcontents.Dock = System.Windows.Forms.DockStyle.Fill; - this.txtcontents.Location = new System.Drawing.Point(0, 53); - this.txtcontents.Multiline = true; - this.txtcontents.Name = "txtcontents"; - this.txtcontents.Size = new System.Drawing.Size(527, 460); - this.txtcontents.TabIndex = 1; - this.txtcontents.TabStop = false; - // - // menuStrip2 - // - this.menuStrip2.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.newToolStripMenuItem, - this.openToolStripMenuItem, - this.saveToolStripMenuItem}); - this.menuStrip2.Location = new System.Drawing.Point(0, 0); - this.menuStrip2.Name = "menuStrip2"; - this.menuStrip2.Size = new System.Drawing.Size(527, 24); - this.menuStrip2.TabIndex = 2; - this.menuStrip2.Text = "menuStrip2"; - // - // newToolStripMenuItem - // - this.newToolStripMenuItem.Name = "newToolStripMenuItem"; - this.newToolStripMenuItem.Size = new System.Drawing.Size(43, 20); - this.newToolStripMenuItem.Text = "New"; - // - // openToolStripMenuItem - // - this.openToolStripMenuItem.Name = "openToolStripMenuItem"; - this.openToolStripMenuItem.Size = new System.Drawing.Size(48, 20); - this.openToolStripMenuItem.Text = "Open"; - // - // saveToolStripMenuItem - // - this.saveToolStripMenuItem.Name = "saveToolStripMenuItem"; - this.saveToolStripMenuItem.Size = new System.Drawing.Size(43, 20); - this.saveToolStripMenuItem.Text = "Save"; - // - // menuStrip3 - // - this.menuStrip3.Location = new System.Drawing.Point(0, 30); - this.menuStrip3.Name = "menuStrip3"; - this.menuStrip3.Size = new System.Drawing.Size(527, 24); - this.menuStrip3.TabIndex = 3; - this.menuStrip3.Text = "menuStrip3"; - // - // TriWrite - // - this.Controls.Add(this.txtcontents); - this.Controls.Add(this.menuStrip3); - this.Controls.Add(this.menuStrip2); - this.Name = "TriWrite"; - this.Size = new System.Drawing.Size(527, 513); - this.menuStrip1.ResumeLayout(false); - this.menuStrip1.PerformLayout(); - this.panel1.ResumeLayout(false); - this.panel1.PerformLayout(); - this.menuStrip2.ResumeLayout(false); - this.menuStrip2.PerformLayout(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.MenuStrip menuStrip1; - private System.Windows.Forms.ToolStripMenuItem addContactToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem removeToolStripMenuItem; - private System.Windows.Forms.TreeView tvcontacts; - private System.Windows.Forms.Panel panel1; - private System.Windows.Forms.Label txtbody; - private System.Windows.Forms.Label lbtitle; - private System.Windows.Forms.TextBox txtcontents; - private System.Windows.Forms.MenuStrip menuStrip2; - private System.Windows.Forms.ToolStripMenuItem newToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem openToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem saveToolStripMenuItem; - private System.Windows.Forms.MenuStrip menuStrip3; - } -} diff --git a/ShiftOS.WinForms/Applications/TriWrite.cs b/ShiftOS.WinForms/Applications/TriWrite.cs deleted file mode 100644 index 6fb814f..0000000 --- a/ShiftOS.WinForms/Applications/TriWrite.cs +++ /dev/null @@ -1,76 +0,0 @@ -using ShiftOS.Objects.ShiftFS; -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; -using ShiftOS.Engine; - -namespace ShiftOS.WinForms.Applications -{ - [WinOpen("triwrite")] - [AppscapeEntry("TriWrite", "Part of the trilogy of office applications for enhancement of your system. TriWrite is easliy the best text editor out there for ShiftOS.", 1024, 750, null, "Office")] - [DefaultTitle("TriWrite")] - [Launcher("TriWrite", false, null, "Office")] - public partial class TriWrite : UserControl, IShiftOSWindow - { - - public TriWrite() - { - InitializeComponent(); - } - - private void newToolStripMenuItem_Click(object sender, EventArgs e) - { - txtcontents.Text = ""; - } - - private void openToolStripMenuItem_Click(object sender, EventArgs e) - { - var txt = new List(); - txt.Add(".txt"); - - AppearanceManager.SetupDialog(new FileDialog(txt.ToArray(), FileOpenerStyle.Open, new Action((file) => this.LoadFile(file)))); - } - - public void LoadFile(string file) - { - txtcontents.Text = Utils.ReadAllText(file); - } - - public void SaveFile(string file) - { - Utils.WriteAllText(file, txtcontents.Text); - } - - private void saveToolStripMenuItem_Click(object sender, EventArgs e) - { - var txt = new List(); - txt.Add(".txt"); - - AppearanceManager.SetupDialog(new FileDialog(txt.ToArray(), FileOpenerStyle.Save, new Action((file) => this.SaveFile(file)))); - } - - public void OnLoad() - { - } - - public void OnSkinLoad() - { - } - - public bool OnUnload() - { - return true; - } - - public void OnUpgrade() - { - } - - } -} \ No newline at end of file diff --git a/ShiftOS.WinForms/Applications/TriWrite.resx b/ShiftOS.WinForms/Applications/TriWrite.resx index 525a23c..a06716c 100644 --- a/ShiftOS.WinForms/Applications/TriWrite.resx +++ b/ShiftOS.WinForms/Applications/TriWrite.resx @@ -130,7 +130,113 @@ To add a contact, simply click "Add Contact", and to remove one, click "Remove". 132, 17 - + 247, 17 + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG + YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9 + 0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw + bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc + VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9 + c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32 + Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo + mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+ + kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D + TgDQASA1MVpwzwAAAABJRU5ErkJggg== + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG + YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9 + 0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw + bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc + VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9 + c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32 + Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo + mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+ + kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D + TgDQASA1MVpwzwAAAABJRU5ErkJggg== + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG + YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9 + 0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw + bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc + VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9 + c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32 + Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo + mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+ + kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D + TgDQASA1MVpwzwAAAABJRU5ErkJggg== + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG + YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9 + 0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw + bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc + VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9 + c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32 + Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo + mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+ + kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D + TgDQASA1MVpwzwAAAABJRU5ErkJggg== + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG + YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9 + 0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw + bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc + VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9 + c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32 + Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo + mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+ + kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D + TgDQASA1MVpwzwAAAABJRU5ErkJggg== + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG + YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9 + 0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw + bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc + VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9 + c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32 + Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo + mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+ + kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D + TgDQASA1MVpwzwAAAABJRU5ErkJggg== + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG + YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9 + 0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw + bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc + VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9 + c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32 + Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo + mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+ + kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D + TgDQASA1MVpwzwAAAABJRU5ErkJggg== + + \ No newline at end of file diff --git a/ShiftOS.WinForms/Controls/TerminalBox.cs b/ShiftOS.WinForms/Controls/TerminalBox.cs index cdb0965..ea7808c 100644 --- a/ShiftOS.WinForms/Controls/TerminalBox.cs +++ b/ShiftOS.WinForms/Controls/TerminalBox.cs @@ -86,6 +86,7 @@ namespace ShiftOS.WinForms.Controls public void WriteLine(string text) { + Engine.AudioManager.PlayStream(Properties.Resources.writesound); this.HideSelection = true; this.Select(this.TextLength, 0); this.SelectionFont = ConstructFont(); @@ -119,6 +120,135 @@ namespace ShiftOS.WinForms.Controls base.OnMouseUp(mevent); } + protected override void OnKeyDown(KeyEventArgs e) + { + base.OnKeyDown(e); + if (!TerminalBackend.InStory) + { + switch (e.KeyCode) { + case Keys.Add: + case Keys.Alt: + case Keys.Apps: + case Keys.Attn: + case Keys.BrowserBack: + case Keys.BrowserFavorites: + case Keys.BrowserForward: + case Keys.BrowserHome: + case Keys.BrowserRefresh: + case Keys.BrowserSearch: + case Keys.BrowserStop: + case Keys.Cancel: + case Keys.Capital: + case Keys.Clear: + case Keys.Control: + case Keys.ControlKey: + case Keys.Crsel: + case Keys.Decimal: + case Keys.Divide: + case Keys.Down: + case Keys.End: + case Keys.Enter: + case Keys.EraseEof: + case Keys.Escape: + case Keys.Execute: + case Keys.Exsel: + case Keys.F1: + case Keys.F10: + case Keys.F11: + case Keys.F12: + case Keys.F13: + case Keys.F14: + case Keys.F15: + case Keys.F16: + case Keys.F17: + case Keys.F18: + case Keys.F19: + case Keys.F2: + case Keys.F20: + case Keys.F21: + case Keys.F22: + case Keys.F23: + case Keys.F24: + case Keys.F3: + case Keys.F4: + case Keys.F5: + case Keys.F6: + case Keys.F7: + case Keys.F8: + case Keys.F9: + case Keys.FinalMode: + case Keys.HanguelMode: + case Keys.HanjaMode: + case Keys.Help: + case Keys.Home: + case Keys.IMEAccept: + case Keys.IMEConvert: + case Keys.IMEModeChange: + case Keys.IMENonconvert: + case Keys.Insert: + case Keys.JunjaMode: + case Keys.KeyCode: + case Keys.LaunchApplication1: + case Keys.LaunchApplication2: + case Keys.LaunchMail: + case Keys.LButton: + case Keys.LControlKey: + case Keys.Left: + case Keys.LineFeed: + case Keys.LMenu: + case Keys.LShiftKey: + case Keys.LWin: + case Keys.MButton: + case Keys.MediaNextTrack: + case Keys.MediaPlayPause: + case Keys.MediaPreviousTrack: + case Keys.MediaStop: + case Keys.Menu: + case Keys.Modifiers: + case Keys.Multiply: + case Keys.Next: + case Keys.NoName: + case Keys.None: + case Keys.NumLock: + case Keys.Pa1: + case Keys.Packet: + case Keys.PageUp: + case Keys.Pause: + case Keys.Play: + case Keys.Print: + case Keys.PrintScreen: + case Keys.ProcessKey: + case Keys.RButton: + case Keys.RControlKey: + case Keys.Right: + case Keys.RMenu: + case Keys.RShiftKey: + case Keys.RWin: + case Keys.Scroll: + case Keys.Select: + case Keys.SelectMedia: + case Keys.Separator: + case Keys.Shift: + case Keys.ShiftKey: + case Keys.Sleep: + case Keys.Subtract: + case Keys.Tab: + case Keys.Up: + case Keys.VolumeDown: + case Keys.VolumeMute: + case Keys.VolumeUp: + case Keys.XButton1: + case Keys.XButton2: + case Keys.Zoom: + + break; + default: + //Engine.AudioManager.PlayStream(Properties.Resources.typesound); // infernal beeping noise only enable for the trailers + break; + } + } + } + public TerminalBox() : base() { this.Tag = "keepbg keepfg keepfont"; diff --git a/ShiftOS.WinForms/DesktopWidgets/HeartbeatWidget.Designer.cs b/ShiftOS.WinForms/DesktopWidgets/HeartbeatWidget.Designer.cs new file mode 100644 index 0000000..c6a7d83 --- /dev/null +++ b/ShiftOS.WinForms/DesktopWidgets/HeartbeatWidget.Designer.cs @@ -0,0 +1,62 @@ +namespace ShiftOS.WinForms.DesktopWidgets +{ + partial class HeartbeatWidget + { + /// + /// 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.lbheartbeat = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // lbheartbeat + // + this.lbheartbeat.AutoSize = true; + this.lbheartbeat.Dock = System.Windows.Forms.DockStyle.Fill; + this.lbheartbeat.Location = new System.Drawing.Point(0, 0); + this.lbheartbeat.Name = "lbheartbeat"; + this.lbheartbeat.Size = new System.Drawing.Size(35, 13); + this.lbheartbeat.TabIndex = 0; + this.lbheartbeat.Text = "label1"; + // + // HeartbeatWidget + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.AutoSize = true; + this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.Controls.Add(this.lbheartbeat); + this.Name = "HeartbeatWidget"; + this.Size = new System.Drawing.Size(35, 13); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label lbheartbeat; + } +} diff --git a/ShiftOS.WinForms/DesktopWidgets/HeartbeatWidget.cs b/ShiftOS.WinForms/DesktopWidgets/HeartbeatWidget.cs new file mode 100644 index 0000000..b0dc552 --- /dev/null +++ b/ShiftOS.WinForms/DesktopWidgets/HeartbeatWidget.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using ShiftOS.WinForms.Tools; +using ShiftOS.Engine; + +namespace ShiftOS.WinForms.DesktopWidgets +{ + [DesktopWidget("Server ping", "See the time spent between client requests and server replies in the digital society.")] + public partial class HeartbeatWidget : UserControl, IDesktopWidget + { + public HeartbeatWidget() + { + InitializeComponent(); + tmr.Interval = 1; + tmr.Tick += (o, a) => + { + if(ts != ServerManager.DigitalSocietyPing) + { + ts = ServerManager.DigitalSocietyPing; + lbheartbeat.Text = "Server ping: " + ts.ToString() + " MS"; + } + }; + } + + //Fun fact. I misspelled this as "TimeSpam." + long ts = 0; + + public void OnSkinLoad() + { + ControlManager.SetupControls(this); + } + + public void OnUpgrade() + { + } + + Timer tmr = new Timer(); + + public void Setup() + { + tmr.Start(); + } + } +} diff --git a/ShiftOS.WinForms/DesktopWidgets/HeartbeatWidget.resx b/ShiftOS.WinForms/DesktopWidgets/HeartbeatWidget.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/ShiftOS.WinForms/DesktopWidgets/HeartbeatWidget.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/ShiftOS.WinForms/GUILogin.Designer.cs b/ShiftOS.WinForms/GUILogin.Designer.cs new file mode 100644 index 0000000..e10071f --- /dev/null +++ b/ShiftOS.WinForms/GUILogin.Designer.cs @@ -0,0 +1,135 @@ +namespace ShiftOS.WinForms +{ + partial class GUILogin + { + /// + /// 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.pnlloginform = new System.Windows.Forms.Panel(); + this.btnlogin = new System.Windows.Forms.Button(); + this.txtpassword = new System.Windows.Forms.TextBox(); + this.txtusername = new System.Windows.Forms.TextBox(); + this.lblogintitle = new System.Windows.Forms.Label(); + this.btnshutdown = new System.Windows.Forms.Button(); + this.pnlloginform.SuspendLayout(); + this.SuspendLayout(); + // + // pnlloginform + // + this.pnlloginform.Controls.Add(this.btnlogin); + this.pnlloginform.Controls.Add(this.txtpassword); + this.pnlloginform.Controls.Add(this.txtusername); + this.pnlloginform.Location = new System.Drawing.Point(13, 13); + this.pnlloginform.Name = "pnlloginform"; + this.pnlloginform.Size = new System.Drawing.Size(358, 236); + this.pnlloginform.TabIndex = 0; + this.pnlloginform.Tag = ""; + // + // btnlogin + // + this.btnlogin.AutoSize = true; + this.btnlogin.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.btnlogin.Location = new System.Drawing.Point(159, 163); + this.btnlogin.Name = "btnlogin"; + this.btnlogin.Size = new System.Drawing.Size(43, 23); + this.btnlogin.TabIndex = 2; + this.btnlogin.Text = "Login"; + this.btnlogin.UseVisualStyleBackColor = true; + this.btnlogin.Click += new System.EventHandler(this.btnlogin_Click); + // + // txtpassword + // + this.txtpassword.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.txtpassword.Location = new System.Drawing.Point(69, 115); + this.txtpassword.Name = "txtpassword"; + this.txtpassword.Size = new System.Drawing.Size(300, 20); + this.txtpassword.TabIndex = 1; + this.txtpassword.UseSystemPasswordChar = true; + // + // txtusername + // + this.txtusername.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.txtusername.Location = new System.Drawing.Point(3, 14); + this.txtusername.Name = "txtusername"; + this.txtusername.Size = new System.Drawing.Size(300, 20); + this.txtusername.TabIndex = 0; + // + // lblogintitle + // + this.lblogintitle.AutoSize = true; + this.lblogintitle.Location = new System.Drawing.Point(99, 553); + this.lblogintitle.Name = "lblogintitle"; + this.lblogintitle.Size = new System.Drawing.Size(103, 13); + this.lblogintitle.TabIndex = 1; + this.lblogintitle.Tag = "header1 keepbg"; + this.lblogintitle.Text = "Welcome to ShiftOS"; + // + // btnshutdown + // + this.btnshutdown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnshutdown.AutoSize = true; + this.btnshutdown.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.btnshutdown.Location = new System.Drawing.Point(924, 652); + this.btnshutdown.Name = "btnshutdown"; + this.btnshutdown.Size = new System.Drawing.Size(65, 23); + this.btnshutdown.TabIndex = 2; + this.btnshutdown.Text = "Shutdown"; + this.btnshutdown.UseVisualStyleBackColor = true; + this.btnshutdown.Click += new System.EventHandler(this.btnshutdown_Click); + // + // GUILogin + // + 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(1001, 687); + this.Controls.Add(this.btnshutdown); + this.Controls.Add(this.lblogintitle); + this.Controls.Add(this.pnlloginform); + this.ForeColor = System.Drawing.Color.White; + this.Name = "GUILogin"; + this.Text = "GUILogin"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.GUILogin_FormClosing); + this.Load += new System.EventHandler(this.GUILogin_Load); + this.pnlloginform.ResumeLayout(false); + this.pnlloginform.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Panel pnlloginform; + private System.Windows.Forms.Button btnlogin; + private System.Windows.Forms.TextBox txtpassword; + private System.Windows.Forms.TextBox txtusername; + private System.Windows.Forms.Label lblogintitle; + private System.Windows.Forms.Button btnshutdown; + } +} \ No newline at end of file diff --git a/ShiftOS.WinForms/GUILogin.cs b/ShiftOS.WinForms/GUILogin.cs new file mode 100644 index 0000000..078061c --- /dev/null +++ b/ShiftOS.WinForms/GUILogin.cs @@ -0,0 +1,136 @@ +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; +using ShiftOS.Engine; +using ShiftOS.Objects; +using ShiftOS.WinForms.Tools; + +namespace ShiftOS.WinForms +{ + public partial class GUILogin : Form + { + public GUILogin() + { + InitializeComponent(); + uiTimer.Tick += (o, a) => + { + btnlogin.Left = txtusername.Left + ((txtusername.Width - btnlogin.Width) / 2); + btnlogin.Top = txtpassword.Top + txtpassword.Height + 5; + + lblogintitle.Left = pnlloginform.Left + ((pnlloginform.Width - lblogintitle.Width) / 2); + lblogintitle.Top = pnlloginform.Top - lblogintitle.Width - 5; + + }; + uiTimer.Interval = 100; + this.FormBorderStyle = FormBorderStyle.None; + this.WindowState = FormWindowState.Maximized; + this.TopMost = true; + } + + Timer uiTimer = new Timer(); + + public event Action LoginComplete; + + private void GUILogin_Load(object sender, EventArgs e) + { + uiTimer.Start(); + ControlManager.SetupControl(lblogintitle); + ControlManager.SetupControls(pnlloginform); + ControlManager.SetupControl(btnshutdown); + pnlloginform.CenterParent(); + txtusername.CenterParent(); + txtusername.Location = new System.Drawing.Point(txtusername.Location.X, 77); + txtpassword.CenterParent(); + btnlogin.CenterParent(); + btnlogin.Location = new System.Drawing.Point(btnlogin.Location.X, 143); + this.BackColor = SkinEngine.LoadedSkin.LoginScreenColor; + this.BackgroundImage = SkinEngine.GetImage("login"); + this.BackgroundImageLayout = SkinEngine.GetImageLayout("login"); + } + + private ClientSave User = null; + + bool userRequestClose = true; + bool shuttingdown = false; + + private void GUILogin_FormClosing(object sender, FormClosingEventArgs e) + { + e.Cancel = userRequestClose; + if (!e.Cancel) + { + uiTimer.Stop(); + if (shuttingdown == false) + { + LoginComplete?.Invoke(User); + } + } + } + + private void btnlogin_Click(object sender, EventArgs e) + { + if (string.IsNullOrWhiteSpace(txtusername.Text)) + { + Infobox.Show("Enter a username", "You must enter your username to login."); + return; + } + + //Don't check for blank passwords. + + var user = SaveSystem.CurrentSave.Users.FirstOrDefault(x => x.Username == txtusername.Text); + if(user == null) + { + Infobox.Show("Invalid username", "That username was not found on your system."); + return; + } + + if (user.Password != txtpassword.Text) + { + Infobox.Show("Access denied.", "That password didn't work. Please try a different one."); + return; + } + + User = user; + userRequestClose = false; + shuttingdown = false; + this.Close(); + } + + private void btnshutdown_Click(object sender, EventArgs e) + { + userRequestClose = false; + shuttingdown = true; + this.Close(); + SaveSystem.CurrentUser = SaveSystem.CurrentSave.Users.FirstOrDefault(x => x.Username == "root"); + TerminalBackend.InvokeCommand("sos.shutdown"); + } + } + + public class GUILoginFrontend : ILoginFrontend + { + public bool UseGUILogin + { + get + { + return Shiftorium.UpgradeInstalled("gui_based_login_screen"); + } + } + + public event Action LoginComplete; + + public void Login() + { + var lform = new GUILogin(); + lform.LoginComplete += (user) => + { + LoginComplete?.Invoke(user); + }; + lform.Show(); + } + } +} diff --git a/ShiftOS.WinForms/GUILogin.resx b/ShiftOS.WinForms/GUILogin.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/ShiftOS.WinForms/GUILogin.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/ShiftOS.WinForms/Oobe.cs b/ShiftOS.WinForms/Oobe.cs index a4d63e0..d5f28f8 100644 --- a/ShiftOS.WinForms/Oobe.cs +++ b/ShiftOS.WinForms/Oobe.cs @@ -312,11 +312,15 @@ You must join the digital society, rise up the ranks, and save us. sve.Codepoints = 0; sve.Upgrades = new Dictionary(); sve.ID = Guid.NewGuid(); + sve.StoriesExperienced = new List(); + sve.StoriesExperienced.Add("mud_fundamentals"); Infobox.Show("Welcome to ShiftOS.", "Welcome to ShiftOS, " + client.GetDisplayName() + ". We have created a save file for you. Now, go on and Shift It Your Way.", () => { sve.StoryPosition = 8675309; SaveSystem.CurrentSave = sve; + Shiftorium.Silent = true; SaveSystem.SaveGame(); + Shiftorium.Silent = false; }); } diff --git a/ShiftOS.WinForms/OobeStory.cs b/ShiftOS.WinForms/OobeStory.cs index bab4889..a35e1d8 100644 --- a/ShiftOS.WinForms/OobeStory.cs +++ b/ShiftOS.WinForms/OobeStory.cs @@ -120,7 +120,7 @@ namespace ShiftOS.WinForms Console.Write(" "); ConsoleEx.BackgroundColor = ConsoleColor.Black; } - Engine.AudioManager.PlayStream(Properties.Resources.typesound); + Desktop.InvokeOnWorkerThread(() => Engine.AudioManager.PlayStream(Properties.Resources.typesound)); formatProgress++; Thread.Sleep(175); } @@ -135,15 +135,15 @@ namespace ShiftOS.WinForms { Console.WriteLine("Creating: " + dir); Thread.Sleep(125); - Engine.AudioManager.PlayStream(Properties.Resources.writesound); + Desktop.InvokeOnWorkerThread(() => Engine.AudioManager.PlayStream(Properties.Resources.writesound)); } } Console.WriteLine(); Console.WriteLine("Next, let's get user information."); Console.WriteLine(); ShiftOS.Engine.OutOfBoxExperience.PromptForLogin(); - } + private static bool isValid(string text, string chars) { foreach(var c in text) diff --git a/ShiftOS.WinForms/Program.cs b/ShiftOS.WinForms/Program.cs index b2f064d..ad8fc83 100644 --- a/ShiftOS.WinForms/Program.cs +++ b/ShiftOS.WinForms/Program.cs @@ -49,6 +49,7 @@ namespace ShiftOS.WinForms Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //if ANYONE puts code before those two winforms config lines they will be declared a drunky. - Michael + LoginManager.Init(new GUILoginFrontend()); CrashHandler.SetGameMetadata(Assembly.GetExecutingAssembly()); SkinEngine.SetIconProber(new ShiftOSIconProvider()); ShiftOS.Engine.AudioManager.Init(new ShiftOSAudioProvider()); diff --git a/ShiftOS.WinForms/Resources/Shiftorium.txt b/ShiftOS.WinForms/Resources/Shiftorium.txt index b528c72..c3d27ae 100644 --- a/ShiftOS.WinForms/Resources/Shiftorium.txt +++ b/ShiftOS.WinForms/Resources/Shiftorium.txt @@ -7,6 +7,13 @@ Dependencies: "desktop", Category: "Enhancements", }, + { + Name: "GUI Based Login Screen", + Cost: 500, + Description: "Tired of using the text-based login screen in ShiftOS? Well, we have a functioning window manager, and a functioning desktop, why not use these tools to create a functioning and awesome-looking login screen?", + Dependencies: "skinning;desktop;wm_free_placement", + Category: "Kernel & System" + }, { Name: "Shift Screensavers", Cost: 100, diff --git a/ShiftOS.WinForms/ShiftOS.WinForms.csproj b/ShiftOS.WinForms/ShiftOS.WinForms.csproj index 9fc237f..97cc3c9 100644 --- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj +++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj @@ -70,9 +70,7 @@ About.cs - - UserControl - + TriWrite.cs @@ -178,9 +176,7 @@ Notifications.cs - - UserControl - + Pong.cs @@ -202,9 +198,7 @@ Shiftnet.cs - - UserControl - + ShiftoriumFrontend.cs @@ -226,9 +220,7 @@ ShopItemCreator.cs - - UserControl - + Skin Loader.cs @@ -298,6 +290,12 @@ CodepointsWidget.cs + + UserControl + + + HeartbeatWidget.cs + UserControl @@ -317,6 +315,12 @@ DownloadControl.cs + + Form + + + GUILogin.cs + @@ -502,6 +506,9 @@ CodepointsWidget.cs + + HeartbeatWidget.cs + TerminalWidget.cs @@ -511,6 +518,9 @@ DownloadControl.cs + + GUILogin.cs + Oobe.cs diff --git a/ShiftOS.WinForms/UniteLoginDialog.cs b/ShiftOS.WinForms/UniteLoginDialog.cs index 4c85005..c78e987 100644 --- a/ShiftOS.WinForms/UniteLoginDialog.cs +++ b/ShiftOS.WinForms/UniteLoginDialog.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; using System.Windows.Forms; using ShiftOS.Engine; using System.Net; +using ShiftOS.Objects; namespace ShiftOS.WinForms { @@ -59,7 +60,7 @@ namespace ShiftOS.WinForms try { - var webrequest = HttpWebRequest.Create("http://getshiftos.ml/Auth/Login?appname=ShiftOS&appdesc=ShiftOS+client&version=1_0_beta_2_4"); + var webrequest = HttpWebRequest.Create(UserConfig.Get().UniteUrl + "/Auth/Login?appname=ShiftOS&appdesc=ShiftOS+client&version=1_0_beta_2_4"); string base64 = Convert.ToBase64String(Encoding.UTF8.GetBytes($"{u}:{p}")); webrequest.Headers.Add("Authentication: Basic " + base64); var response = webrequest.GetResponse(); diff --git a/ShiftOS.WinForms/UniteSignupDialog.cs b/ShiftOS.WinForms/UniteSignupDialog.cs index a46a9b0..7d0fd33 100644 --- a/ShiftOS.WinForms/UniteSignupDialog.cs +++ b/ShiftOS.WinForms/UniteSignupDialog.cs @@ -10,6 +10,7 @@ using System.Windows.Forms; using ShiftOS.Engine; using Newtonsoft.Json; using System.Net; +using ShiftOS.Objects; namespace ShiftOS.WinForms { @@ -99,7 +100,7 @@ namespace ShiftOS.WinForms try { - var webrequest = HttpWebRequest.Create("http://getshiftos.ml/Auth/Register?appname=ShiftOS&appdesc=ShiftOS+client&version=1_0_beta_2_4&displayname=" + txtdisplay.Text + "&sysname=" + txtsysname.Text); + var webrequest = HttpWebRequest.Create(UserConfig.Get().UniteUrl + "/Auth/Register?appname=ShiftOS&appdesc=ShiftOS+client&version=1_0_beta_2_4&displayname=" + txtdisplay.Text + "&sysname=" + txtsysname.Text); string base64 = Convert.ToBase64String(Encoding.UTF8.GetBytes($"{u}:{p}")); webrequest.Headers.Add("Authentication: Basic " + base64); var response = webrequest.GetResponse(); diff --git a/ShiftOS.WinForms/WindowBorder.cs b/ShiftOS.WinForms/WindowBorder.cs index 25c7639..40dc629 100644 --- a/ShiftOS.WinForms/WindowBorder.cs +++ b/ShiftOS.WinForms/WindowBorder.cs @@ -515,6 +515,17 @@ namespace ShiftOS.WinForms if(resizing == true) { this.Width += e.X; + switch (LoadedSkin.TitleTextCentered) + { + case false: + lbtitletext.Location = new Point(16 + LoadedSkin.TitlebarIconFromSide.X + LoadedSkin.TitleTextLeft.X, + LoadedSkin.TitleTextLeft.Y); + break; + default: + lbtitletext.Left = (pnltitle.Width - lbtitletext.Width) / 2; + lbtitletext.Top = LoadedSkin.TitleTextLeft.Y; + break; + } } } @@ -522,6 +533,17 @@ namespace ShiftOS.WinForms { resizing = false; pnlcontents.Show(); + switch (LoadedSkin.TitleTextCentered) + { + case false: + lbtitletext.Location = new Point(16 + LoadedSkin.TitlebarIconFromSide.X + LoadedSkin.TitleTextLeft.X, + LoadedSkin.TitleTextLeft.Y); + break; + default: + lbtitletext.Left = (pnltitle.Width - lbtitletext.Width) / 2; + lbtitletext.Top = LoadedSkin.TitleTextLeft.Y; + break; + } } private void pnlleft_MouseMove(object sender, MouseEventArgs e) @@ -530,6 +552,17 @@ namespace ShiftOS.WinForms { this.Left += e.X; this.Width -= e.X; + switch (LoadedSkin.TitleTextCentered) + { + case false: + lbtitletext.Location = new Point(16 + LoadedSkin.TitlebarIconFromSide.X + LoadedSkin.TitleTextLeft.X, + LoadedSkin.TitleTextLeft.Y); + break; + default: + lbtitletext.Left = (pnltitle.Width - lbtitletext.Width) / 2; + lbtitletext.Top = LoadedSkin.TitleTextLeft.Y; + break; + } } } @@ -547,6 +580,17 @@ namespace ShiftOS.WinForms { this.Width += e.X; this.Height += e.Y; + switch (LoadedSkin.TitleTextCentered) + { + case false: + lbtitletext.Location = new Point(16 + LoadedSkin.TitlebarIconFromSide.X + LoadedSkin.TitleTextLeft.X, + LoadedSkin.TitleTextLeft.Y); + break; + default: + lbtitletext.Left = (pnltitle.Width - lbtitletext.Width) / 2; + lbtitletext.Top = LoadedSkin.TitleTextLeft.Y; + break; + } } } @@ -557,6 +601,17 @@ namespace ShiftOS.WinForms this.Width -= e.X; this.Height += e.Y; this.Left += e.X; + switch (LoadedSkin.TitleTextCentered) + { + case false: + lbtitletext.Location = new Point(16 + LoadedSkin.TitlebarIconFromSide.X + LoadedSkin.TitleTextLeft.X, + LoadedSkin.TitleTextLeft.Y); + break; + default: + lbtitletext.Left = (pnltitle.Width - lbtitletext.Width) / 2; + lbtitletext.Top = LoadedSkin.TitleTextLeft.Y; + break; + } } } diff --git a/ShiftOS_TheReturn/Commands.cs b/ShiftOS_TheReturn/Commands.cs index 57d1d34..dc0b3a2 100644 --- a/ShiftOS_TheReturn/Commands.cs +++ b/ShiftOS_TheReturn/Commands.cs @@ -276,6 +276,17 @@ namespace ShiftOS.Engine return true; } + [Command("restart")] + public static bool Restart() + { + SaveSystem.CurrentSave.Upgrades = new Dictionary(); + SaveSystem.CurrentSave.Codepoints = 0; + SaveSystem.CurrentSave.StoriesExperienced.Clear(); + SaveSystem.CurrentSave.StoriesExperienced.Add("mud_fundamentals"); + SaveSystem.SaveGame(); + Shiftorium.InvokeUpgradeInstalled(); + return true; + } [Command("freecp")] public static bool FreeCodepoints(Dictionary args) @@ -283,8 +294,8 @@ namespace ShiftOS.Engine if (args.ContainsKey("amount")) try { - Int64 codepointsToAdd = Convert.ToInt64(args["amount"].ToString()); - SaveSystem.TransferCodepointsFrom("dev", codepointsToAdd); + long codepointsToAdd = Convert.ToInt64(args["amount"].ToString()); + SaveSystem.CurrentSave.Codepoints += codepointsToAdd; return true; } catch (Exception ex) @@ -293,7 +304,7 @@ namespace ShiftOS.Engine return true; } - SaveSystem.TransferCodepointsFrom("dev", 1000); + SaveSystem.CurrentSave.Codepoints += 1000; return true; } diff --git a/ShiftOS_TheReturn/LoginManager.cs b/ShiftOS_TheReturn/LoginManager.cs new file mode 100644 index 0000000..d326f2c --- /dev/null +++ b/ShiftOS_TheReturn/LoginManager.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ShiftOS.Objects; + +namespace ShiftOS.Engine +{ + public static class LoginManager + { + private static ILoginFrontend _login = null; + + public static void Init(ILoginFrontend login) + { + _login = login; + } + + public static void PromptForLogin() + { + _login.LoginComplete += (user) => + { + LoginComplete?.Invoke(user); + }; + _login.Login(); + } + + public static bool ShouldUseGUILogin + { + get + { + if (_login == null) + return false; + return _login.UseGUILogin; + } + } + + public static event Action LoginComplete; + } + + /// + /// Interface for GUI-based logins. + /// + public interface ILoginFrontend + { + /// + /// When implemented, shows the login UI. + /// + void Login(); + + /// + /// Gets whether the ShiftOS engine should use a GUI-based login system or the default one. + /// + bool UseGUILogin { get; } + + + /// + /// Occurs when the login is complete. + /// + event Action LoginComplete; + + + + } +} diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index 945869b..31db58a 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -70,7 +70,7 @@ namespace ShiftOS.Engine { var root = new ShiftOS.Objects.ShiftFS.Directory(); root.Name = "System"; - root.permissions = Permissions.All; + root.permissions = UserPermissions.Guest; System.IO.File.WriteAllText(Paths.SaveFile, JsonConvert.SerializeObject(root)); } @@ -98,13 +98,25 @@ namespace ShiftOS.Engine } Thread.Sleep(350); - Console.WriteLine("Initiating kernel..."); + Console.WriteLine("ShiftKernel v0.4.2"); + Console.WriteLine("(MIT) DevX 2017, Very Little Rights Reserved"); + Console.WriteLine(""); + Console.WriteLine("THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR"); + Console.WriteLine("IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,"); + Console.WriteLine("FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE"); + Console.WriteLine("AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER"); + Console.WriteLine("LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,"); + Console.WriteLine("OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE"); + Console.WriteLine("SOFTWARE."); + Console.WriteLine(""); Thread.Sleep(250); - Console.WriteLine("Reading filesystem..."); + Console.WriteLine("[init] Kernel boot complete."); + Console.WriteLine("[sfs] Loading SFS driver v3"); Thread.Sleep(100); - Console.WriteLine("Reading configuration..."); + Console.WriteLine("[sfs] 4096 blocks read."); + Console.WriteLine("[simpl-conf] Reading configuration files (global-3.conf)"); - Console.WriteLine("{CONNECTING_TO_MUD}"); + Console.WriteLine("[inetd] Connecting to network..."); if (defaultConf.ConnectToMud == true) { @@ -113,32 +125,32 @@ namespace ShiftOS.Engine { //Connection successful! Stop waiting! guidReceived = true; - Console.WriteLine("Connection successful."); + Console.WriteLine("[inetd] Connection successful."); }; try { - ServerManager.Initiate("secondary4162.cloudapp.net", 13370); + ServerManager.Initiate(UserConfig.Get().DigitalSocietyAddress, UserConfig.Get().DigitalSocietyPort); //This haults the client until the connection is successful. while (ServerManager.thisGuid == new Guid()) { Thread.Sleep(10); } - Console.WriteLine("GUID received - bootstrapping complete."); + Console.WriteLine("[inetd] DHCP GUID recieved, finished setup"); FinishBootstrap(); } catch (Exception ex) { //No errors, this never gets called. - Console.WriteLine("{ERROR}: " + ex.Message); + Console.WriteLine("[inetd] SEVERE: " + ex.Message); Thread.Sleep(3000); ServerManager.StartLANServer(); while (ServerManager.thisGuid == new Guid()) { Thread.Sleep(10); } - Console.WriteLine("GUID received - bootstrapping complete."); + Console.WriteLine("[inetd] DHCP GUID recieved, finished setup"); FinishBootstrap(); } } @@ -196,14 +208,60 @@ namespace ShiftOS.Engine Thread.Sleep(75); Thread.Sleep(50); - Console.WriteLine("{SYSTEM_INITIATED}"); + Console.WriteLine("[usr-man] Accepting logins on local tty 1."); + Sysname: + bool waitingForNewSysName = false; + bool gobacktosysname = false; + + if (string.IsNullOrWhiteSpace(CurrentSave.SystemName)) + { + Infobox.PromptText("Enter a system name", "Your system does not have a name. All systems within the digital society must have a name. Please enter one.", (name) => + { + if (string.IsNullOrWhiteSpace(name)) + Infobox.Show("Invalid name", "Please enter a valid name.", () => + { + gobacktosysname = true; + waitingForNewSysName = false; + }); + else if (name.Length < 5) + Infobox.Show("Value too small.", "Your system name must have at least 5 characters in it.", () => + { + gobacktosysname = true; + waitingForNewSysName = false; + }); + else + { + CurrentSave.SystemName = name; + if (!string.IsNullOrWhiteSpace(CurrentSave.UniteAuthToken)) + { + var unite = new Unite.UniteClient("http://getshiftos.ml", CurrentSave.UniteAuthToken); + unite.SetSysName(name); + } + SaveSystem.SaveGame(); + gobacktosysname = false; + waitingForNewSysName = false; + } + }); + + + } + + while (waitingForNewSysName) + { + Thread.Sleep(10); + } + + if (gobacktosysname) + { + goto Sysname; + } if (CurrentSave.Users == null) CurrentSave.Users = new List(); - if(CurrentSave.Users.Count == 0) + if (CurrentSave.Users.Count == 0) { CurrentSave.Users.Add(new ClientSave { @@ -211,76 +269,101 @@ namespace ShiftOS.Engine Password = "", Permissions = UserPermissions.Root }); - Console.WriteLine("No users found. Creating new user with username \"root\", with no password."); + Console.WriteLine("[usr-man] WARN: No users found. Creating new user with username \"root\", with no password."); } TerminalBackend.InStory = false; TerminalBackend.PrefixEnabled = false; - Login: - string username = ""; - int progress = 0; - bool goback = false; - TextSentEventHandler ev = null; - ev = (text) => + if (LoginManager.ShouldUseGUILogin) + { + Action Completed = null; + Completed += (user) => + { + CurrentUser = user; + LoginManager.LoginComplete -= Completed; + }; + LoginManager.LoginComplete += Completed; + Desktop.InvokeOnWorkerThread(() => + { + LoginManager.PromptForLogin(); + }); + while (CurrentUser == null) + { + Thread.Sleep(10); + } + } + else { - if (progress == 0) + + Login: + string username = ""; + int progress = 0; + bool goback = false; + TextSentEventHandler ev = null; + ev = (text) => { - if (!string.IsNullOrWhiteSpace(text)) + if (progress == 0) { - if (CurrentSave.Users.FirstOrDefault(x => x.Username == text) == null) + string loginstr = CurrentSave.SystemName + " login: "; + string getuser = text.Remove(0, loginstr.Length); + if (!string.IsNullOrWhiteSpace(getuser)) { - Console.WriteLine("User not found."); - goback = true; + if (CurrentSave.Users.FirstOrDefault(x => x.Username == getuser) == null) + { + Console.WriteLine("User not found."); + goback = true; + progress++; + TerminalBackend.TextSent -= ev; + return; + } + username = getuser; progress++; + } + else + { + Console.WriteLine("Username not provided."); TerminalBackend.TextSent -= ev; - return; + goback = true; + progress++; } - username = text; - progress++; } - else + else if (progress == 1) { - Console.WriteLine("Username not provided."); + string passwordstr = "password: "; + string getpass = text.Remove(0, passwordstr.Length); + var user = CurrentSave.Users.FirstOrDefault(x => x.Username == username); + if (user.Password == getpass) + { + Console.WriteLine("Welcome to ShiftOS."); + CurrentUser = user; + Thread.Sleep(2000); + progress++; + } + else + { + Console.WriteLine("Access denied."); + goback = true; + progress++; + } TerminalBackend.TextSent -= ev; - goback = true; - progress++; } - } - else if (progress == 1) + }; + TerminalBackend.TextSent += ev; + + Console.Write(CurrentSave.SystemName + " login: "); + while (progress == 0) { - var user = CurrentSave.Users.FirstOrDefault(x => x.Username == username); - if (user.Password == text) - { - Console.WriteLine("Welcome to ShiftOS."); - CurrentUser = user; - Thread.Sleep(2000); - progress++; - } - else - { - Console.WriteLine("Access denied."); - goback = true; - progress++; - } - TerminalBackend.TextSent -= ev; + Thread.Sleep(10); } - }; - TerminalBackend.TextSent += ev; - Console.WriteLine(CurrentSave.SystemName + " login:"); - while(progress == 0) - { - Thread.Sleep(10); + if (goback) + goto Login; + Console.Write("password: "); + while (progress == 1) + Thread.Sleep(10); + if (goback) + goto Login; } - if (goback) - goto Login; - Console.WriteLine("password:"); - while (progress == 1) - Thread.Sleep(10); - if (goback) - goto Login; - - TerminalBackend.PrefixEnabled = true; Shiftorium.LogOrphanedUpgrades = true; Desktop.InvokeOnWorkerThread(new Action(() => diff --git a/ShiftOS_TheReturn/ServerManager.cs b/ShiftOS_TheReturn/ServerManager.cs index 0bdfcd9..825064b 100644 --- a/ShiftOS_TheReturn/ServerManager.cs +++ b/ShiftOS_TheReturn/ServerManager.cs @@ -35,6 +35,7 @@ using ShiftOS; using static ShiftOS.Engine.SaveSystem; using Newtonsoft.Json; using System.Net.Sockets; +using System.Diagnostics; namespace ShiftOS.Engine { @@ -54,6 +55,12 @@ namespace ShiftOS.Engine private static NetObjectClient client { get; set; } private static bool UserDisconnect = false; + public static long DigitalSocietyPing + { + get; + private set; + } + public static void Disconnect() { UserDisconnect = true; @@ -139,6 +146,11 @@ namespace ShiftOS.Engine }; client.OnReceived += (o, a) => { + if (PingTimer.IsRunning) + { + DigitalSocietyPing = PingTimer.ElapsedMilliseconds; + PingTimer.Reset(); + } var msg = a.Data.Object as ServerMessage; if (msg.Name == "Welcome") { @@ -207,6 +219,8 @@ namespace ShiftOS.Engine } } + private static Stopwatch PingTimer = new Stopwatch(); + public static void SendMessage(string name, string contents) { var sMsg = new ServerMessage @@ -215,7 +229,7 @@ namespace ShiftOS.Engine Contents = contents, GUID = thisGuid.ToString(), }; - + PingTimer.Start(); client.Send(new NetObject("msg", sMsg)); } diff --git a/ShiftOS_TheReturn/ShiftOS.Engine.csproj b/ShiftOS_TheReturn/ShiftOS.Engine.csproj index fb33dc5..3b5eadd 100644 --- a/ShiftOS_TheReturn/ShiftOS.Engine.csproj +++ b/ShiftOS_TheReturn/ShiftOS.Engine.csproj @@ -111,6 +111,7 @@ + diff --git a/ShiftOS_TheReturn/Skinning.cs b/ShiftOS_TheReturn/Skinning.cs index 4cc9bbd..b731c4f 100644 --- a/ShiftOS_TheReturn/Skinning.cs +++ b/ShiftOS_TheReturn/Skinning.cs @@ -267,6 +267,22 @@ namespace ShiftOS.Engine [ShifterHidden] public Dictionary AppIcons = new Dictionary(); + [ShifterMeta("System")] + [ShifterCategory("Login Screen")] + [RequiresUpgrade("gui_based_login_screen")] + [ShifterName("Login Screen Background Color")] + [ShifterDescription("Change the background color of the login screen.")] + public Color LoginScreenColor = Skin.DesktopBG; + + [ShifterMeta("System")] + [ShifterCategory("Login Screen")] + [RequiresUpgrade("skinning;gui_based_login_screen")] + [ShifterName("Login Screen Background Image")] + [ShifterDescription("Set an image as your login screen!")] + [Image("login")] + public byte[] LoginScreenBG = null; + + [RequiresUpgrade("shift_screensaver")] [ShifterMeta("System")] [ShifterCategory("Screen saver")] diff --git a/ShiftOS_TheReturn/UniteClient.cs b/ShiftOS_TheReturn/UniteClient.cs index 1136b5c..8d6a58d 100644 --- a/ShiftOS_TheReturn/UniteClient.cs +++ b/ShiftOS_TheReturn/UniteClient.cs @@ -5,13 +5,20 @@ using System.Net; using System.Text; using System.Threading.Tasks; using Newtonsoft.Json; +using ShiftOS.Objects; namespace ShiftOS.Unite { public class UniteClient { public string Token { get; private set; } - public string BaseURL { get; private set; } + public string BaseURL + { + get + { + return UserConfig.Get().UniteUrl; + } + } public string GetDisplayNameId(string id) { @@ -25,7 +32,8 @@ namespace ShiftOS.Unite public UniteClient(string baseurl, string usertoken) { - BaseURL = baseurl; + //Handled by the servers.json file + //BaseURL = baseurl; Token = usertoken; } diff --git a/ShiftOS_TheReturn/UserManagementCommands.cs b/ShiftOS_TheReturn/UserManagementCommands.cs index 62735a3..5702e08 100644 --- a/ShiftOS_TheReturn/UserManagementCommands.cs +++ b/ShiftOS_TheReturn/UserManagementCommands.cs @@ -47,6 +47,11 @@ namespace ShiftOS.Engine } var user = SaveSystem.CurrentSave.Users.FirstOrDefault(x => x.Username == name); + if(user.Username != SaveSystem.CurrentUser.Username) + { + Console.WriteLine("Error: Cannot remove yourself."); + return true; + } SaveSystem.CurrentSave.Users.Remove(user); Console.WriteLine($"Removing user \"{name}\" from system..."); SaveSystem.SaveGame(); @@ -55,13 +60,121 @@ namespace ShiftOS.Engine + + [Command("set_acl")] + [RequiresArgument("user")] + [RequiresArgument("val")] + public static bool SetUserPermission(Dictionary args) + { + int permission = 0; + string username = args["user"].ToString(); + try + { + permission = Convert.ToInt32(args["val"].ToString()); + } + catch + { + Console.WriteLine("Error: Permission value must be an integer."); + return true; + } + + if(SaveSystem.CurrentSave.Users.FirstOrDefault(x=>x.Username==username) == null) + { + Console.WriteLine("Error: User not found."); + return true; + } + + UserPermissions uperm = UserPermissions.Guest; + + switch (permission) + { + case 0: + uperm = UserPermissions.Guest; + break; + case 1: + uperm = UserPermissions.User; + break; + case 2: + uperm = UserPermissions.Admin; + break; + case 3: + uperm = UserPermissions.Root; + break; + default: + Console.WriteLine("Permission value must be between 0 and 4."); + return true; + } + + //Permissions are backwards... oops... + if(uperm < SaveSystem.CurrentUser.Permissions) + { + Console.WriteLine("Error: Cannot set user permissions to values greater than your own!"); + return true; + } + + var oldperm = SaveSystem.Users.FirstOrDefault(x => x.Username == username).Permissions; + if (SaveSystem.CurrentUser.Permissions > oldperm) + { + Console.WriteLine("Error: Can't set the permission of this user. They have more rights than you."); + return true; + } + + SaveSystem.CurrentSave.Users.FirstOrDefault(x => x.Username == username).Permissions = uperm; + Console.WriteLine("User permissions updated."); + return true; + } + + + [Command("users", description = "Get a list of all users on the system.")] + public static bool GetUsers() + { + foreach (var u in SaveSystem.CurrentSave.Users) + { + if (u.Username == SaveSystem.CurrentUser.Username) + { + ConsoleEx.ForegroundColor = ConsoleColor.Magenta; + ConsoleEx.Bold = true; + } + else + { + ConsoleEx.ForegroundColor = ConsoleColor.Gray; + ConsoleEx.Bold = false; + } + Console.WriteLine(u.Username); + } + return true; + } } [Namespace("user")] [RequiresUpgrade("mud_fundamentals")] public static class UserManagementCommands { + [Command("login", description = "Log in as another user.")] + [RequiresArgument("user")] + [RequiresArgument("pass")] + public static bool Login(Dictionary args) + { + string user = args["user"].ToString(); + string pass = args["pass"].ToString(); + + var usr = SaveSystem.CurrentSave.Users.FirstOrDefault(x => x.Username == user); + if(usr==null) + { + Console.WriteLine("Error: No such user."); + return true; + } + if (usr.Password != pass) + { + Console.WriteLine("Access denied."); + return true; + } + + SaveSystem.CurrentUser = usr; + Console.WriteLine("Access granted."); + return true; + } [Command("setpass", description ="Allows you to set your password to a new value.", usage ="old:,new:")] [RequiresArgument("old")] -- cgit v1.2.3 From 76b54853ba726179f9fddb30c6f838991b7aa71a Mon Sep 17 00:00:00 2001 From: Michael VanOverbeek Date: Sun, 21 May 2017 12:29:53 +0000 Subject: Merge a fuckton of shit. --- ShiftOS.WinForms/Applications/Terminal.cs | 496 ------- .../Applications/UpdateManager.Designer.cs | 130 -- .../Applications/VideoPlayer.Designer.cs | 168 --- ShiftOS.WinForms/Controls/ShiftedProgressBar.cs | 147 --- ShiftOS.WinForms/Controls/TerminalBox.cs | 257 ---- ShiftOS.WinForms/DownloadControl.Designer.cs | 116 -- ShiftOS.WinForms/Oobe.cs | 600 --------- ShiftOS.WinForms/Program.cs | 269 ---- ShiftOS.WinForms/Properties/Resources.Designer.cs | 1394 -------------------- ShiftOS.WinForms/Tools/ControlManager.cs | 300 ----- ShiftOS.WinForms/Tools/DitheringEngine.cs | 402 ------ ShiftOS.WinForms/WinformsDesktop.Designer.cs | 312 ----- ShiftOS.WinForms/WinformsDesktop.cs | 1066 --------------- ShiftOS_TheReturn/AppearanceManager.cs | 379 ------ ShiftOS_TheReturn/AudioManager.cs | 134 -- ShiftOS_TheReturn/Commands.cs | 837 ------------ ShiftOS_TheReturn/CrashHandler.cs | 217 --- ShiftOS_TheReturn/Desktop.cs | 271 ---- ShiftOS_TheReturn/KernelWatchdog.cs | 145 -- ShiftOS_TheReturn/Localization.cs | 219 --- ShiftOS_TheReturn/NotificationDaemon.cs | 134 -- ShiftOS_TheReturn/Paths.cs | 237 ---- ShiftOS_TheReturn/SaveSystem.cs | 487 ------- ShiftOS_TheReturn/Scripting.cs | 499 ------- ShiftOS_TheReturn/ServerManager.cs | 284 ---- ShiftOS_TheReturn/Shiftorium.cs | 479 ------- ShiftOS_TheReturn/Skinning.cs | 1336 ------------------- ShiftOS_TheReturn/Story.cs | 328 ----- ShiftOS_TheReturn/TerminalBackend.cs | 534 -------- ShiftOS_TheReturn/TerminalTextWriter.cs | 131 -- ShiftOS_TheReturn/UniteClient.cs | 135 -- ShiftOS_TheReturn/UserManagementCommands.cs | 201 --- 32 files changed, 12644 deletions(-) delete mode 100644 ShiftOS.WinForms/Applications/Terminal.cs delete mode 100644 ShiftOS.WinForms/Applications/UpdateManager.Designer.cs delete mode 100644 ShiftOS.WinForms/Applications/VideoPlayer.Designer.cs delete mode 100644 ShiftOS.WinForms/Controls/ShiftedProgressBar.cs delete mode 100644 ShiftOS.WinForms/Controls/TerminalBox.cs delete mode 100644 ShiftOS.WinForms/DownloadControl.Designer.cs delete mode 100644 ShiftOS.WinForms/Oobe.cs delete mode 100644 ShiftOS.WinForms/Program.cs delete mode 100644 ShiftOS.WinForms/Properties/Resources.Designer.cs delete mode 100644 ShiftOS.WinForms/Tools/ControlManager.cs delete mode 100644 ShiftOS.WinForms/Tools/DitheringEngine.cs delete mode 100644 ShiftOS.WinForms/WinformsDesktop.Designer.cs delete mode 100644 ShiftOS.WinForms/WinformsDesktop.cs delete mode 100644 ShiftOS_TheReturn/AppearanceManager.cs delete mode 100644 ShiftOS_TheReturn/AudioManager.cs delete mode 100644 ShiftOS_TheReturn/Commands.cs delete mode 100644 ShiftOS_TheReturn/CrashHandler.cs delete mode 100644 ShiftOS_TheReturn/Desktop.cs delete mode 100644 ShiftOS_TheReturn/KernelWatchdog.cs delete mode 100644 ShiftOS_TheReturn/Localization.cs delete mode 100644 ShiftOS_TheReturn/NotificationDaemon.cs delete mode 100644 ShiftOS_TheReturn/Paths.cs delete mode 100644 ShiftOS_TheReturn/SaveSystem.cs delete mode 100644 ShiftOS_TheReturn/Scripting.cs delete mode 100644 ShiftOS_TheReturn/ServerManager.cs delete mode 100644 ShiftOS_TheReturn/Shiftorium.cs delete mode 100644 ShiftOS_TheReturn/Skinning.cs delete mode 100644 ShiftOS_TheReturn/Story.cs delete mode 100644 ShiftOS_TheReturn/TerminalBackend.cs delete mode 100644 ShiftOS_TheReturn/TerminalTextWriter.cs delete mode 100644 ShiftOS_TheReturn/UniteClient.cs delete mode 100644 ShiftOS_TheReturn/UserManagementCommands.cs (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.WinForms/Applications/Terminal.cs b/ShiftOS.WinForms/Applications/Terminal.cs deleted file mode 100644 index 32c5363..0000000 --- a/ShiftOS.WinForms/Applications/Terminal.cs +++ /dev/null @@ -1,496 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -//#define TRAILER -//#define CRASHONSTART -using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Diagnostics; -using System.Drawing; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using System.Windows.Forms; -using System.Text.RegularExpressions; -using System.Collections; -using static ShiftOS.Engine.SkinEngine; -using ShiftOS.Engine; -using ShiftOS.Objects; -using ShiftOS.WinForms.Tools; - -namespace ShiftOS.WinForms.Applications -{ - [Launcher("Terminal", false, null, "Utilities")] - [WinOpen("terminal")] - [DefaultIcon("iconTerminal")] - public partial class Terminal : UserControl, IShiftOSWindow - { - public static Stack ConsoleStack = new Stack(); - - public static System.Windows.Forms.Timer ti = new System.Windows.Forms.Timer(); - - public static string latestCommmand = ""; - - public static bool IsInRemoteSystem = false; - public static string RemoteGuid = ""; - - [Obsolete("This is used for compatibility with old parts of the backend. Please use TerminalBackend instead.")] - public static bool PrefixEnabled - { - get - { - return TerminalBackend.PrefixEnabled; - } - set - { - TerminalBackend.PrefixEnabled = value; - } - } - - [Obsolete("This is used for compatibility with old parts of the backend. Please use TerminalBackend instead.")] - public static bool InStory - { - get - { - return TerminalBackend.InStory; - } - set - { - TerminalBackend.InStory = value; - } - } - - [Obsolete("This is used for compatibility with old parts of the backend. Please use TerminalBackend instead.")] - public static string LastCommand - { - get - { - return TerminalBackend.LastCommand; - } - set - { - TerminalBackend.LastCommand = value; - } - } - - public int TutorialProgress - { - get - { - throw new NotImplementedException(); - } - - set - { - throw new NotImplementedException(); - } - } - - [Obsolete("This is used for compatibility with old parts of the backend. Please use TerminalBackend instead.")] - public static void InvokeCommand(string text) - { - - TerminalBackend.InvokeCommand(text); - } - - public Terminal() - { - - InitializeComponent(); - SaveSystem.GameReady += () => - { - try - { - this.Invoke(new Action(() => - { - ResetAllKeywords(); - rtbterm.Text = ""; - if (!Shiftorium.UpgradeInstalled("desktop")) - { - TerminalBackend.PrefixEnabled = true; - TerminalBackend.InStory = false; - TerminalBackend.PrintPrompt(); - if (Shiftorium.UpgradeInstalled("wm_free_placement")) - { - this.ParentForm.Width = 640; - this.ParentForm.Height = 480; - this.ParentForm.Left = (Screen.PrimaryScreen.Bounds.Width - 640) / 2; - this.ParentForm.Top = (Screen.PrimaryScreen.Bounds.Height - 480) / 2; - - } - } - else - { - AppearanceManager.Close(this); - } - })); - } - catch { } - }; - - - this.DoubleBuffered = true; - - } - - public void FocusOnTerminal() - { - rtbterm.Focus(); - } - - public static string GetTime() - { - var time = DateTime.Now; - if (ShiftoriumFrontend.UpgradeInstalled("full_precision_time")) - { - return DateTime.Now.ToString("h:mm:ss tt"); - } - else if (ShiftoriumFrontend.UpgradeInstalled("clock_am_and_pm")) - { - return time.TimeOfDay.TotalHours > 12 ? $"{time.Hour - 12} PM" : $"{time.Hour} AM"; - } - else if (ShiftoriumFrontend.UpgradeInstalled("clock_hours")) - { - return ((int)time.TimeOfDay.TotalHours).ToString(); - } - else if (ShiftoriumFrontend.UpgradeInstalled("clock_minutes")) - { - return ((int)time.TimeOfDay.TotalMinutes).ToString(); - } - else if (ShiftoriumFrontend.UpgradeInstalled("clock")) - { - return ((int)time.TimeOfDay.TotalSeconds).ToString(); - } - - return ""; - } - - - public static event TextSentEventHandler TextSent; - - public void ResetAllKeywords() - { - string primary = SaveSystem.CurrentUser.Username + " "; - string secondary = "shiftos "; - - - var asm = Assembly.GetExecutingAssembly(); - - var types = asm.GetTypes(); - - foreach (var type in types) - { - foreach (var a in type.GetCustomAttributes(false)) - { - if (ShiftoriumFrontend.UpgradeAttributesUnlocked(type)) - { - if (a is Namespace) - { - var ns = a as Namespace; - if (!primary.Contains(ns.name)) - { - primary += ns.name + " "; - } - foreach (var method in type.GetMethods(BindingFlags.Public | BindingFlags.Static)) - { - if (ShiftoriumFrontend.UpgradeAttributesUnlocked(method)) - { - foreach (var ma in method.GetCustomAttributes(false)) - { - if (ma is Command) - { - var cmd = ma as Command; - if (!secondary.Contains(cmd.name)) - secondary += cmd.name + " "; - } - } - } - } - } - } - } - } - - - } - - public static void MakeWidget(Controls.TerminalBox txt) - { - AppearanceManager.StartConsoleOut(); - txt.GotFocus += (o, a) => - { - AppearanceManager.ConsoleOut = txt; - }; - txt.KeyDown += (o, a) => - { - if (a.Control == true || a.Alt == true) - { - a.SuppressKeyPress = true; - return; - } - - if (a.KeyCode == Keys.Enter) - { - try - { - a.SuppressKeyPress = true; - Console.WriteLine(""); - var text = txt.Lines.ToArray(); - var text2 = text[text.Length - 2]; - var text3 = ""; - var text4 = Regex.Replace(text2, @"\t|\n|\r", ""); - - if (IsInRemoteSystem == true) - { - ServerManager.SendMessage("trm_invcmd", JsonConvert.SerializeObject(new - { - guid = RemoteGuid, - command = text4 - })); - } - else - { - if (TerminalBackend.PrefixEnabled) - { - text3 = text4.Remove(0, $"{SaveSystem.CurrentUser.Username}@{SaveSystem.CurrentSave.SystemName}:~$ ".Length); - } - TerminalBackend.LastCommand = text3; - TextSent?.Invoke(text4); - TerminalBackend.SendText(text4); - if (TerminalBackend.InStory == false) - { - if (text3 == "stop theme") - { - CurrentCommandParser.parser = null; - } - else - { - if (CurrentCommandParser.parser == null) - { - TerminalBackend.InvokeCommand(text3); - } - else - { - var result = CurrentCommandParser.parser.ParseCommand(text3); - - if (result.Equals(default(KeyValuePair, Dictionary>))) - { - Console.WriteLine("Syntax Error: Syntax Error"); - } - else - { - TerminalBackend.InvokeCommand(result.Key.Key, result.Key.Value, result.Value); - } - } - } - } - if (TerminalBackend.PrefixEnabled) - { - TerminalBackend.PrintPrompt(); - } - } - } - catch - { - } - } - else if (a.KeyCode == Keys.Back) - { - try - { - var tostring3 = txt.Lines[txt.Lines.Length - 1]; - var tostringlen = tostring3.Length + 1; - var workaround = $"{SaveSystem.CurrentUser.Username}@{SaveSystem.CurrentSave.SystemName}:~$ "; - var derp = workaround.Length + 1; - if (tostringlen != derp) - { - AppearanceManager.CurrentPosition--; - } - else - { - a.SuppressKeyPress = true; - } - } - catch - { - Debug.WriteLine("Drunky alert in terminal."); - } - } - else if (a.KeyCode == Keys.Left) - { - var getstring = txt.Lines[txt.Lines.Length - 1]; - var stringlen = getstring.Length + 1; - var header = $"{SaveSystem.CurrentUser.Username}@{SaveSystem.CurrentSave.SystemName}:~$ "; - var headerlen = header.Length + 1; - var selstart = txt.SelectionStart; - var remstrlen = txt.TextLength - stringlen; - var finalnum = selstart - remstrlen; - - if (finalnum != headerlen) - { - AppearanceManager.CurrentPosition--; - } - else - { - a.SuppressKeyPress = true; - } - } - else if (a.KeyCode == Keys.Up) - { - var tostring3 = txt.Lines[txt.Lines.Length - 1]; - if (tostring3 == $"{SaveSystem.CurrentUser.Username}@{SaveSystem.CurrentSave.SystemName}:~$ ") - Console.Write(TerminalBackend.LastCommand); - a.SuppressKeyPress = true; - - } - else - { - if (TerminalBackend.InStory) - { - a.SuppressKeyPress = true; - } - AppearanceManager.CurrentPosition++; - } - - }; - - AppearanceManager.ConsoleOut = txt; - - txt.Focus(); - - txt.Font = LoadedSkin.TerminalFont; - txt.ForeColor = ControlManager.ConvertColor(LoadedSkin.TerminalForeColorCC); - txt.BackColor = ControlManager.ConvertColor(LoadedSkin.TerminalBackColorCC); - - } - - private void Terminal_Load(object sender, EventArgs e) - { - ServerManager.MessageReceived += (msg) => - { - if (msg.Name == "trm_handshake_guid") - { - IsInRemoteSystem = true; - RemoteGuid = msg.GUID; - } - else if (msg.Name == "trm_handshake_stop") - { - IsInRemoteSystem = false; - RemoteGuid = ""; - } - }; - } - - private void Terminal_FormClosing(object sender, FormClosingEventArgs e) - { - ti.Stop(); - IsInRemoteSystem = false; - RemoteGuid = ""; - } - - public void OnLoad() - { - MakeWidget(rtbterm); - - if (SaveSystem.CurrentSave != null) - { - if (!ShiftoriumFrontend.UpgradeInstalled("window_manager")) - { - rtbterm.Select(rtbterm.TextLength, 0); - } - } - - new Thread(() => - { - Thread.Sleep(1000); - TerminalBackend.PrintPrompt(); - }).Start(); - } - - public void OnSkinLoad() - { - try - { - rtbterm.Font = LoadedSkin.TerminalFont; - rtbterm.ForeColor = ControlManager.ConvertColor(LoadedSkin.TerminalForeColorCC); - rtbterm.BackColor = ControlManager.ConvertColor(LoadedSkin.TerminalBackColorCC); - } - catch - { - - } - - } - - public bool OnUnload() - { - if (SaveSystem.ShuttingDown == false) - { - if (!ShiftoriumFrontend.UpgradeInstalled("desktop")) - { - if (AppearanceManager.OpenForms.Count <= 1) - { - Console.WriteLine(""); - Console.WriteLine("{WIN_CANTCLOSETERMINAL}"); - try - { - Console.WriteLine(""); - - if (TerminalBackend.PrefixEnabled) - { - Console.Write($"{SaveSystem.CurrentUser.Username}@shiftos:~$ "); - } - } - catch (Exception ex) - { - Console.WriteLine(ex); - } - return false; - } - } - } - return true; - } - - public void OnUpgrade() - { - } - - private void rtbterm_TextChanged(object sender, EventArgs e) - { - - } - - internal void ClearText() - { - rtbterm.Text = ""; - } - } -} \ No newline at end of file diff --git a/ShiftOS.WinForms/Applications/UpdateManager.Designer.cs b/ShiftOS.WinForms/Applications/UpdateManager.Designer.cs deleted file mode 100644 index 0b23b8e..0000000 --- a/ShiftOS.WinForms/Applications/UpdateManager.Designer.cs +++ /dev/null @@ -1,130 +0,0 @@ -namespace ShiftOS.WinForms.Applications -{ - partial class UpdateManager - { - /// - /// 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.lbupdatetitle = new System.Windows.Forms.Label(); - this.pnlupdatebar = new System.Windows.Forms.Panel(); - this.pgdownload = new ShiftOS.WinForms.Controls.ShiftedProgressBar(); - this.btnaction = new System.Windows.Forms.Button(); - this.btnclose = new System.Windows.Forms.Button(); - this.wbstatus = new System.Windows.Forms.WebBrowser(); - this.pnlupdatebar.SuspendLayout(); - this.SuspendLayout(); - // - // lbupdatetitle - // - this.lbupdatetitle.AutoSize = true; - this.lbupdatetitle.Dock = System.Windows.Forms.DockStyle.Top; - this.lbupdatetitle.Location = new System.Drawing.Point(0, 0); - this.lbupdatetitle.Margin = new System.Windows.Forms.Padding(10); - this.lbupdatetitle.Name = "lbupdatetitle"; - this.lbupdatetitle.Size = new System.Drawing.Size(117, 13); - this.lbupdatetitle.TabIndex = 0; - this.lbupdatetitle.Tag = "header1"; - this.lbupdatetitle.Text = "Checking for updates..."; - // - // pnlupdatebar - // - this.pnlupdatebar.Controls.Add(this.pgdownload); - this.pnlupdatebar.Controls.Add(this.btnaction); - this.pnlupdatebar.Controls.Add(this.btnclose); - this.pnlupdatebar.Dock = System.Windows.Forms.DockStyle.Bottom; - this.pnlupdatebar.Location = new System.Drawing.Point(0, 426); - this.pnlupdatebar.Name = "pnlupdatebar"; - this.pnlupdatebar.Size = new System.Drawing.Size(597, 33); - this.pnlupdatebar.TabIndex = 1; - // - // pgdownload - // - this.pgdownload.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.pgdownload.BlockSize = 5; - this.pgdownload.Location = new System.Drawing.Point(86, 4); - this.pgdownload.Maximum = 100; - this.pgdownload.Name = "pgdownload"; - this.pgdownload.Size = new System.Drawing.Size(427, 23); - this.pgdownload.Style = System.Windows.Forms.ProgressBarStyle.Continuous; - this.pgdownload.TabIndex = 2; - this.pgdownload.Text = "Updating..."; - this.pgdownload.Value = 0; - // - // btnaction - // - this.btnaction.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.btnaction.Location = new System.Drawing.Point(519, 4); - this.btnaction.Name = "btnaction"; - this.btnaction.Size = new System.Drawing.Size(75, 23); - this.btnaction.TabIndex = 1; - this.btnaction.Text = "Update"; - this.btnaction.UseVisualStyleBackColor = true; - // - // btnclose - // - this.btnclose.Location = new System.Drawing.Point(4, 4); - this.btnclose.Name = "btnclose"; - this.btnclose.Size = new System.Drawing.Size(75, 23); - this.btnclose.TabIndex = 0; - this.btnclose.Text = "{CLOSE}"; - this.btnclose.UseVisualStyleBackColor = true; - this.btnclose.Click += new System.EventHandler(this.btnclose_Click); - // - // wbstatus - // - this.wbstatus.Dock = System.Windows.Forms.DockStyle.Fill; - this.wbstatus.Location = new System.Drawing.Point(0, 13); - this.wbstatus.MinimumSize = new System.Drawing.Size(20, 20); - this.wbstatus.Name = "wbstatus"; - this.wbstatus.Size = new System.Drawing.Size(597, 413); - this.wbstatus.TabIndex = 2; - // - // UpdateManager - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Controls.Add(this.wbstatus); - this.Controls.Add(this.pnlupdatebar); - this.Controls.Add(this.lbupdatetitle); - this.Name = "UpdateManager"; - this.Size = new System.Drawing.Size(597, 459); - this.pnlupdatebar.ResumeLayout(false); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Label lbupdatetitle; - private System.Windows.Forms.Panel pnlupdatebar; - private Controls.ShiftedProgressBar pgdownload; - private System.Windows.Forms.Button btnaction; - private System.Windows.Forms.Button btnclose; - private System.Windows.Forms.WebBrowser wbstatus; - } -} diff --git a/ShiftOS.WinForms/Applications/VideoPlayer.Designer.cs b/ShiftOS.WinForms/Applications/VideoPlayer.Designer.cs deleted file mode 100644 index d915c31..0000000 --- a/ShiftOS.WinForms/Applications/VideoPlayer.Designer.cs +++ /dev/null @@ -1,168 +0,0 @@ -namespace ShiftOS.WinForms.Applications -{ - partial class VideoPlayer - { - /// - /// 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() - { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(VideoPlayer)); - this.toolStripContainer1 = new System.Windows.Forms.ToolStripContainer(); - this.flcontrols = new System.Windows.Forms.FlowLayoutPanel(); - this.btnplay = new System.Windows.Forms.Button(); - this.pgplaytime = new ShiftOS.WinForms.Controls.ShiftedProgressBar(); - this.menuStrip1 = new System.Windows.Forms.MenuStrip(); - this.addSongToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.wpaudio = new AxWMPLib.AxWindowsMediaPlayer(); - this.toolStripContainer1.ContentPanel.SuspendLayout(); - this.toolStripContainer1.TopToolStripPanel.SuspendLayout(); - this.toolStripContainer1.SuspendLayout(); - this.flcontrols.SuspendLayout(); - this.menuStrip1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.wpaudio)).BeginInit(); - this.SuspendLayout(); - // - // toolStripContainer1 - // - // - // toolStripContainer1.ContentPanel - // - this.toolStripContainer1.ContentPanel.Controls.Add(this.wpaudio); - this.toolStripContainer1.ContentPanel.Controls.Add(this.flcontrols); - this.toolStripContainer1.ContentPanel.Size = new System.Drawing.Size(805, 402); - this.toolStripContainer1.Dock = System.Windows.Forms.DockStyle.Fill; - this.toolStripContainer1.LeftToolStripPanelVisible = false; - this.toolStripContainer1.Location = new System.Drawing.Point(0, 0); - this.toolStripContainer1.Name = "toolStripContainer1"; - this.toolStripContainer1.RightToolStripPanelVisible = false; - this.toolStripContainer1.Size = new System.Drawing.Size(805, 426); - this.toolStripContainer1.TabIndex = 3; - this.toolStripContainer1.Text = "toolStripContainer1"; - // - // toolStripContainer1.TopToolStripPanel - // - this.toolStripContainer1.TopToolStripPanel.Controls.Add(this.menuStrip1); - // - // flcontrols - // - this.flcontrols.AutoSize = true; - this.flcontrols.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.flcontrols.Controls.Add(this.btnplay); - this.flcontrols.Controls.Add(this.pgplaytime); - this.flcontrols.Dock = System.Windows.Forms.DockStyle.Bottom; - this.flcontrols.Location = new System.Drawing.Point(0, 373); - this.flcontrols.Name = "flcontrols"; - this.flcontrols.Size = new System.Drawing.Size(805, 29); - this.flcontrols.TabIndex = 0; - // - // btnplay - // - this.btnplay.AutoSize = true; - this.btnplay.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.btnplay.Location = new System.Drawing.Point(3, 3); - this.btnplay.Name = "btnplay"; - this.btnplay.Size = new System.Drawing.Size(37, 23); - this.btnplay.TabIndex = 0; - this.btnplay.Text = "Play"; - this.btnplay.UseVisualStyleBackColor = true; - this.btnplay.Click += new System.EventHandler(this.btnplay_Click); - // - // pgplaytime - // - this.pgplaytime.BlockSize = 5; - this.pgplaytime.Location = new System.Drawing.Point(46, 3); - this.pgplaytime.Maximum = 100; - this.pgplaytime.Name = "pgplaytime"; - this.pgplaytime.Size = new System.Drawing.Size(749, 23); - this.pgplaytime.Style = System.Windows.Forms.ProgressBarStyle.Continuous; - this.pgplaytime.TabIndex = 1; - this.pgplaytime.Tag = "keepbg"; - this.pgplaytime.Text = "shiftedProgressBar1"; - this.pgplaytime.Value = 0; - this.pgplaytime.MouseDown += new System.Windows.Forms.MouseEventHandler(this.startScrub); - this.pgplaytime.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pgplaytime_MouseMove); - this.pgplaytime.MouseUp += new System.Windows.Forms.MouseEventHandler(this.pgplaytime_MouseUp); - // - // menuStrip1 - // - this.menuStrip1.Dock = System.Windows.Forms.DockStyle.None; - this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.addSongToolStripMenuItem}); - this.menuStrip1.Location = new System.Drawing.Point(0, 0); - this.menuStrip1.Name = "menuStrip1"; - this.menuStrip1.Size = new System.Drawing.Size(805, 24); - this.menuStrip1.TabIndex = 0; - this.menuStrip1.Text = "menuStrip1"; - // - // addSongToolStripMenuItem - // - this.addSongToolStripMenuItem.Name = "addSongToolStripMenuItem"; - this.addSongToolStripMenuItem.Size = new System.Drawing.Size(81, 20); - this.addSongToolStripMenuItem.Text = "Open Video"; - this.addSongToolStripMenuItem.Click += new System.EventHandler(this.addSongToolStripMenuItem_Click); - // - // wpaudio - // - this.wpaudio.Dock = System.Windows.Forms.DockStyle.Fill; - this.wpaudio.Enabled = true; - this.wpaudio.Location = new System.Drawing.Point(0, 0); - this.wpaudio.Name = "wpaudio"; - this.wpaudio.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("wpaudio.OcxState"))); - this.wpaudio.Size = new System.Drawing.Size(805, 373); - this.wpaudio.TabIndex = 2; - this.wpaudio.Visible = false; - // - // VideoPlayer - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Controls.Add(this.toolStripContainer1); - this.Name = "VideoPlayer"; - this.Size = new System.Drawing.Size(805, 426); - this.toolStripContainer1.ContentPanel.ResumeLayout(false); - this.toolStripContainer1.ContentPanel.PerformLayout(); - this.toolStripContainer1.TopToolStripPanel.ResumeLayout(false); - this.toolStripContainer1.TopToolStripPanel.PerformLayout(); - this.toolStripContainer1.ResumeLayout(false); - this.toolStripContainer1.PerformLayout(); - this.flcontrols.ResumeLayout(false); - this.flcontrols.PerformLayout(); - this.menuStrip1.ResumeLayout(false); - this.menuStrip1.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.wpaudio)).EndInit(); - this.ResumeLayout(false); - - } - - #endregion - private System.Windows.Forms.ToolStripContainer toolStripContainer1; - private System.Windows.Forms.FlowLayoutPanel flcontrols; - private System.Windows.Forms.Button btnplay; - private Controls.ShiftedProgressBar pgplaytime; - private System.Windows.Forms.MenuStrip menuStrip1; - private System.Windows.Forms.ToolStripMenuItem addSongToolStripMenuItem; - private AxWMPLib.AxWindowsMediaPlayer wpaudio; - } -} diff --git a/ShiftOS.WinForms/Controls/ShiftedProgressBar.cs b/ShiftOS.WinForms/Controls/ShiftedProgressBar.cs deleted file mode 100644 index e5a2c33..0000000 --- a/ShiftOS.WinForms/Controls/ShiftedProgressBar.cs +++ /dev/null @@ -1,147 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -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.WinForms.Controls -{ - public partial class ShiftedProgressBar : Control - { - public ShiftedProgressBar() - { - this.SizeChanged += (o, a) => - { - this.Refresh(); - }; - var t = new Timer(); - t.Interval = 100; - t.Tick += (o, a) => - { - if(this._style == ProgressBarStyle.Marquee) - { - if(_marqueePos >= this.Width) - { - _marqueePos = 0 - (this.Width / 4); - } - else - { - _marqueePos++; - } - this.Refresh(); - } - }; - t.Start(); - } - - private int _value = 0; - private int _max = 100; - public int Value - { - get - { - return _value; - } - set - { - _value = value; - this.Refresh(); - } - } - public int Maximum - { - get - { - return _max; - } - set - { - _max = value; - this.Refresh(); - } - } - - public ProgressBarStyle _style = ProgressBarStyle.Continuous; - - public ProgressBarStyle Style - { - get { return _style; } - set { _style = value; this.Refresh(); } - } - - private int _blocksize = 5; - - public int BlockSize - { - get { return _blocksize; } - set - { - _blocksize = value; - this.Refresh(); - } - } - - protected override void OnPaint(PaintEventArgs pe) - { - pe.Graphics.Clear(Color.Black); - switch (_style) - { - case ProgressBarStyle.Continuous: - double width = linear(this.Value, 0, this.Maximum, 0, this.Width); - pe.Graphics.FillRectangle(new SolidBrush(Color.Green), new RectangleF(0, 0, (float)width, this.Height)); - break; - case ProgressBarStyle.Blocks: - int block_count = this.Width / (this._blocksize + 2); - int blocks = (int)linear(this.Value, 0, this.Maximum, 0, block_count); - for(int i = 0; i < blocks - 1; i++) - { - int position = i * (_blocksize + 2); - pe.Graphics.FillRectangle(new SolidBrush(Color.Green), new Rectangle(position, 0, _blocksize, this.Height)); - } - break; - case ProgressBarStyle.Marquee: - pe.Graphics.FillRectangle(new SolidBrush(Color.Green), new Rectangle(_marqueePos, 0, this.Width / 4, this.Height)); - break; - } - } - - private int _marqueePos = 0; - - static private double linear(double x, double x0, double x1, double y0, double y1) - { - if ((x1 - x0) == 0) - { - return (y0 + y1) / 2; - } - return y0 + (x - x0) * (y1 - y0) / (x1 - x0); - } - } -} diff --git a/ShiftOS.WinForms/Controls/TerminalBox.cs b/ShiftOS.WinForms/Controls/TerminalBox.cs deleted file mode 100644 index ea7808c..0000000 --- a/ShiftOS.WinForms/Controls/TerminalBox.cs +++ /dev/null @@ -1,257 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using System.Windows.Forms; -using ShiftOS.Engine; -using ShiftOS.WinForms.Tools; - -namespace ShiftOS.WinForms.Controls -{ - public class TerminalBox : RichTextBox, ITerminalWidget - { - public void SelectBottom() - { - try - { - this.Select(this.Text.Length, 0); - this.ScrollToCaret(); - } - catch { } - } - - protected override void Dispose(bool disposing) - { - if (disposing == true) - if(AppearanceManager.ConsoleOut == this) - AppearanceManager.ConsoleOut = null; - base.Dispose(disposing); - } - - protected override void OnClick(EventArgs e) - { - base.OnClick(e); - this.Select(this.TextLength, 0); - } - - public void Write(string text) - { - this.HideSelection = true; - this.SelectionFont = ConstructFont(); - this.SelectionColor = ControlManager.ConvertColor(ConsoleEx.ForegroundColor); - this.SelectionBackColor = ControlManager.ConvertColor(ConsoleEx.BackgroundColor); - this.AppendText(Localization.Parse(text)); - this.HideSelection = false; - } - - private Font ConstructFont() - { - FontStyle fs = FontStyle.Regular; - if (ConsoleEx.Bold) - fs = fs | FontStyle.Bold; - if (ConsoleEx.Italic) - fs = fs | FontStyle.Italic; - if (ConsoleEx.Underline) - fs = fs | FontStyle.Underline; - - return new Font(this.Font, fs); - } - - public void WriteLine(string text) - { - Engine.AudioManager.PlayStream(Properties.Resources.writesound); - this.HideSelection = true; - this.Select(this.TextLength, 0); - this.SelectionFont = ConstructFont(); - this.SelectionColor = ControlManager.ConvertColor(ConsoleEx.ForegroundColor); - this.SelectionBackColor = ControlManager.ConvertColor(ConsoleEx.BackgroundColor); - this.AppendText(Localization.Parse(text) + Environment.NewLine); - this.HideSelection = false; - } - - bool quickCopying = false; - - protected override void OnMouseDown(MouseEventArgs e) - { - //if right-clicking, then we initiate a quick-copy. - if (e.Button == MouseButtons.Right) - quickCopying = true; - - //Override the mouse event so that it's a left-click at all times. - base.OnMouseDown(new MouseEventArgs(MouseButtons.Left, e.Clicks, e.X, e.Y, e.Delta)); - } - - protected override void OnMouseUp(MouseEventArgs mevent) - { - if(quickCopying == true) - { - if (!string.IsNullOrWhiteSpace(this.SelectedText)) - { - this.Copy(); - } - } - base.OnMouseUp(mevent); - } - - protected override void OnKeyDown(KeyEventArgs e) - { - base.OnKeyDown(e); - if (!TerminalBackend.InStory) - { - switch (e.KeyCode) { - case Keys.Add: - case Keys.Alt: - case Keys.Apps: - case Keys.Attn: - case Keys.BrowserBack: - case Keys.BrowserFavorites: - case Keys.BrowserForward: - case Keys.BrowserHome: - case Keys.BrowserRefresh: - case Keys.BrowserSearch: - case Keys.BrowserStop: - case Keys.Cancel: - case Keys.Capital: - case Keys.Clear: - case Keys.Control: - case Keys.ControlKey: - case Keys.Crsel: - case Keys.Decimal: - case Keys.Divide: - case Keys.Down: - case Keys.End: - case Keys.Enter: - case Keys.EraseEof: - case Keys.Escape: - case Keys.Execute: - case Keys.Exsel: - case Keys.F1: - case Keys.F10: - case Keys.F11: - case Keys.F12: - case Keys.F13: - case Keys.F14: - case Keys.F15: - case Keys.F16: - case Keys.F17: - case Keys.F18: - case Keys.F19: - case Keys.F2: - case Keys.F20: - case Keys.F21: - case Keys.F22: - case Keys.F23: - case Keys.F24: - case Keys.F3: - case Keys.F4: - case Keys.F5: - case Keys.F6: - case Keys.F7: - case Keys.F8: - case Keys.F9: - case Keys.FinalMode: - case Keys.HanguelMode: - case Keys.HanjaMode: - case Keys.Help: - case Keys.Home: - case Keys.IMEAccept: - case Keys.IMEConvert: - case Keys.IMEModeChange: - case Keys.IMENonconvert: - case Keys.Insert: - case Keys.JunjaMode: - case Keys.KeyCode: - case Keys.LaunchApplication1: - case Keys.LaunchApplication2: - case Keys.LaunchMail: - case Keys.LButton: - case Keys.LControlKey: - case Keys.Left: - case Keys.LineFeed: - case Keys.LMenu: - case Keys.LShiftKey: - case Keys.LWin: - case Keys.MButton: - case Keys.MediaNextTrack: - case Keys.MediaPlayPause: - case Keys.MediaPreviousTrack: - case Keys.MediaStop: - case Keys.Menu: - case Keys.Modifiers: - case Keys.Multiply: - case Keys.Next: - case Keys.NoName: - case Keys.None: - case Keys.NumLock: - case Keys.Pa1: - case Keys.Packet: - case Keys.PageUp: - case Keys.Pause: - case Keys.Play: - case Keys.Print: - case Keys.PrintScreen: - case Keys.ProcessKey: - case Keys.RButton: - case Keys.RControlKey: - case Keys.Right: - case Keys.RMenu: - case Keys.RShiftKey: - case Keys.RWin: - case Keys.Scroll: - case Keys.Select: - case Keys.SelectMedia: - case Keys.Separator: - case Keys.Shift: - case Keys.ShiftKey: - case Keys.Sleep: - case Keys.Subtract: - case Keys.Tab: - case Keys.Up: - case Keys.VolumeDown: - case Keys.VolumeMute: - case Keys.VolumeUp: - case Keys.XButton1: - case Keys.XButton2: - case Keys.Zoom: - - break; - default: - //Engine.AudioManager.PlayStream(Properties.Resources.typesound); // infernal beeping noise only enable for the trailers - break; - } - } - } - - public TerminalBox() : base() - { - this.Tag = "keepbg keepfg keepfont"; - } - } -} diff --git a/ShiftOS.WinForms/DownloadControl.Designer.cs b/ShiftOS.WinForms/DownloadControl.Designer.cs deleted file mode 100644 index 2587b93..0000000 --- a/ShiftOS.WinForms/DownloadControl.Designer.cs +++ /dev/null @@ -1,116 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -namespace ShiftOS.WinForms -{ - partial class DownloadControl - { - /// - /// 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.pcicon = new System.Windows.Forms.PictureBox(); - this.lbshiftneturl = new System.Windows.Forms.Label(); - this.pgprogress = new ShiftOS.WinForms.Controls.ShiftedProgressBar(); - ((System.ComponentModel.ISupportInitialize)(this.pcicon)).BeginInit(); - this.SuspendLayout(); - // - // pcicon - // - this.pcicon.BackColor = System.Drawing.Color.Black; - this.pcicon.Location = new System.Drawing.Point(4, 4); - this.pcicon.Name = "pcicon"; - this.pcicon.Size = new System.Drawing.Size(42, 42); - this.pcicon.TabIndex = 1; - this.pcicon.TabStop = false; - // - // lbshiftneturl - // - this.lbshiftneturl.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.lbshiftneturl.Location = new System.Drawing.Point(52, 4); - this.lbshiftneturl.Name = "lbshiftneturl"; - this.lbshiftneturl.Size = new System.Drawing.Size(323, 42); - this.lbshiftneturl.TabIndex = 2; - this.lbshiftneturl.Text = "label1"; - this.lbshiftneturl.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; - // - // pgprogress - // - this.pgprogress.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.pgprogress.BlockSize = 5; - this.pgprogress.Location = new System.Drawing.Point(4, 52); - this.pgprogress.Maximum = 100; - this.pgprogress.Name = "pgprogress"; - this.pgprogress.Size = new System.Drawing.Size(371, 23); - this.pgprogress.Style = System.Windows.Forms.ProgressBarStyle.Continuous; - this.pgprogress.TabIndex = 0; - this.pgprogress.Text = "shiftedProgressBar1"; - this.pgprogress.Value = 0; - // - // DownloadControl - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Controls.Add(this.lbshiftneturl); - this.Controls.Add(this.pcicon); - this.Controls.Add(this.pgprogress); - this.Name = "DownloadControl"; - this.Size = new System.Drawing.Size(382, 82); - ((System.ComponentModel.ISupportInitialize)(this.pcicon)).EndInit(); - this.ResumeLayout(false); - - } - - #endregion - - private Controls.ShiftedProgressBar pgprogress; - private System.Windows.Forms.PictureBox pcicon; - private System.Windows.Forms.Label lbshiftneturl; - } -} diff --git a/ShiftOS.WinForms/Oobe.cs b/ShiftOS.WinForms/Oobe.cs deleted file mode 100644 index d5f28f8..0000000 --- a/ShiftOS.WinForms/Oobe.cs +++ /dev/null @@ -1,600 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using System.Windows.Forms; -using Newtonsoft.Json; -using ShiftOS.Engine; -using ShiftOS.Objects; -using ShiftOS.Objects.ShiftFS; -using ShiftOS.Unite; -using ShiftOS.WinForms.Tools; - -namespace ShiftOS.WinForms -{ - public partial class Oobe : Form, IOobe, ITutorial - { - public Oobe() - { - InitializeComponent(); - this.FormBorderStyle = FormBorderStyle.None; - this.WindowState = FormWindowState.Maximized; - this.BackColor = Color.Black; - this.Load += (o, a) => - { - ControlManager.SetupControls(this); - }; - } - - - string rtext; - string gtexttotype; - int charcount; - int slashcount; - Label textgeninput; - public bool upgraded = false; - - private bool typing = false; - - public void TextType(string texttotype) - { - textgeninput.TextAlign = ContentAlignment.MiddleCenter; - while(typing == true) - { - //JESUS CHRIST PAST MICHAEL. - - //We should PROBABLY block the thread... You know... not everyone has a 10-core processor. - Thread.Sleep(100); - } - - charcount = texttotype.Length; - gtexttotype = texttotype; - slashcount = 1; - foreach (var c in gtexttotype) - { - typing = true; - rtext += c; - - this.Invoke(new Action(() => - { - textgeninput.Text = rtext + "|"; - })); - slashcount++; - if (slashcount == 5) - slashcount = 1; - Thread.Sleep(50); - } - rtext += Environment.NewLine; - typing = false; - } - - public Save MySave = null; - - public event EventHandler OnComplete; - - private int tutPrg = 0; - - public int TutorialProgress - { - get - { - return tutPrg; - } - - set - { - tutPrg = value; - } - } - - public void StartShowing(Save save) - { - var t = new Thread(new ThreadStart(() => - { - try - { - textgeninput = this.lblhackwords; - this.Invoke(new Action(() => - { - lblHijack.Hide(); - })); - - TextType(@"Throughout many years, man has tried to develop -a digital environment usable by anyone that never goes -offline, full of AIs and humans alike, thinking, interacting, -innovating. - -No one has ever come close to a digital society of such -properties yet, except for one sentient being. It does not -have a life, a gender, an age or a body, but simply one name. - -They call it ""DevX"". - -If anyone sees this message, my identity is anonymous, but I -need your help. I am trapped within ""DevX""'s digital society -with no way out, constantly under attack. - -You must join the digital society, rise up the ranks, and save us. - - - undisclosed_0x1DDFB5977."); - - Thread.Sleep(5000); - while(this.Opacity > 0f) - { - this.Invoke(new Action(() => - { - this.Opacity -= 0.01f; - })); - Thread.Sleep(25); - } - - Story.Start("mud_fundamentals"); - - this.Invoke(new Action(this.Close)); - } - catch (Exception e) - { - TextType("I have experienced an error."); - TextType(e.ToString()); - } - })); - this.Show(); - this.BringToFront(); - this.TopMost = true; - t.IsBackground = true; - t.Start(); - } - - public void Clear() - { - this.Invoke(new Action(() => - { - rtext = ""; - textgeninput.Text = ""; - })); - } - - public void ShowSaveTransfer(Save save) - { - //Stub. - } - - public void PerformUniteLogin() - { - - } - - public void PromptForLogin() - { - Infobox.Show("Login", "Since the last time you've played ShiftOS, some changes have been made to the login system. You must now login using your website credentials.", () => - { - Infobox.PromptYesNo("Website account", "Do you have an account at http://getshiftos.ml?", (hasAccount) => - { - if(hasAccount == true) - { - var loginDialog = new UniteLoginDialog((success)=> - { - string token = success; - var uClient = new UniteClient("http://getshiftos.ml", token); - Infobox.Show("Welcome to ShiftOS.", $"Hello, {uClient.GetDisplayName()}! We've signed you into your account. We'll now try to link your ShiftOS account with your save file.", () => - { - ServerMessageReceived smr = null; - smr = (msg) => - { - ServerManager.MessageReceived -= smr; - if (msg.Name == "mud_savefile") - { - SaveSystem.CurrentSave = JsonConvert.DeserializeObject(msg.Contents); - SaveSystem.SaveGame(); - } - else if(msg.Name=="mud_login_denied") - { - LinkSaveFile(token); - } - }; - ServerManager.MessageReceived += smr; - ServerManager.SendMessage("mud_token_login", token); - }); - }); - AppearanceManager.SetupDialog(loginDialog); - } - else - { - var signupDialog = new UniteSignupDialog((token) => - { - ServerMessageReceived smr = null; - smr = (msg) => - { - ServerManager.MessageReceived -= smr; - if (msg.Name == "mud_savefile") - { - SaveSystem.CurrentSave = JsonConvert.DeserializeObject(msg.Contents); - SaveSystem.SaveGame(); - } - else if (msg.Name == "mud_login_denied") - { - LinkSaveFile(token); - } - }; - ServerManager.MessageReceived += smr; - ServerManager.SendMessage("mud_token_login", token); - - }); - AppearanceManager.SetupDialog(signupDialog); - } - }); - }); - } - - public void LinkSaveFile(string token) - { - if (Utils.FileExists(Paths.GetPath("user.dat"))) - { - try - { - var details = JsonConvert.DeserializeObject(Utils.ReadAllText(Paths.GetPath("user.dat"))); - ServerMessageReceived smr = null; - bool msgreceived = false; - bool found = false; - smr = (msg) => - { - if (msg.Name == "mud_savefile") - { - var save = JsonConvert.DeserializeObject(msg.Contents); - save.UniteAuthToken = token; - Infobox.Show("Migration complete.", "We have migrated your old save file to the new system successfully. You can still log in using the old system on old builds of ShiftOS.", () => - { - SaveSystem.CurrentSave = save; - SaveSystem.SaveGame(); - found = true; - msgreceived = true; - }); - } - else if (msg.Name == "mud_login_denied") - { - found = false; - msgreceived = true; - } - ServerManager.MessageReceived -= smr; - }; - ServerManager.MessageReceived += smr; - ServerManager.SendMessage("mud_login", JsonConvert.SerializeObject(new - { - username = details.Username, - password = details.Password - })); - while (msgreceived == false) - Thread.Sleep(10); - if (found == true) - return; - } - catch - { - - } - } - - var client = new UniteClient("http://getshiftos.ml", token); - var sve = new Save(); - sve.Username = client.GetEmail(); - sve.Password = Guid.NewGuid().ToString(); - sve.SystemName = client.GetSysName(); - sve.UniteAuthToken = token; - sve.Codepoints = 0; - sve.Upgrades = new Dictionary(); - sve.ID = Guid.NewGuid(); - sve.StoriesExperienced = new List(); - sve.StoriesExperienced.Add("mud_fundamentals"); - Infobox.Show("Welcome to ShiftOS.", "Welcome to ShiftOS, " + client.GetDisplayName() + ". We have created a save file for you. Now, go on and Shift It Your Way.", () => - { - sve.StoryPosition = 8675309; - SaveSystem.CurrentSave = sve; - Shiftorium.Silent = true; - SaveSystem.SaveGame(); - Shiftorium.Silent = false; - - }); - } - - public void ForceReboot() - { - string json = Utils.ExportMount(0); - System.IO.File.WriteAllText(Paths.SaveFile, json); - System.Diagnostics.Process.Start(Application.ExecutablePath); - Environment.Exit(0); - } - - public void StartTrailer() - { - while(AppearanceManager.OpenForms.Count > 0) - { - AppearanceManager.OpenForms[0].Close(); - } - - this.Show(); - this.TopMost = true; - this.TransparencyKey = Color.Magenta; - this.BackColor = this.TransparencyKey; - textgeninput = lblHijack; - textgeninput.BackColor = Color.Black; - textgeninput.Font = new Font("Lucida Console", 13F, FontStyle.Bold); - textgeninput.AutoSize = true; - textgeninput.TextAlign = ContentAlignment.MiddleCenter; - textgeninput.TextChanged += (o, a) => - { - textgeninput.Location = new Point( - (this.Width - textgeninput.Width) / 2, - (this.Height - textgeninput.Height) / 2 - ); - }; - var t = new Thread(() => - { - Clear(); - Thread.Sleep(5000); - TextType("Michael VanOverbeek"); - TextType("presents..."); - Thread.Sleep(2000); - Clear(); - Thread.Sleep(1000); - TextType("A community-developed game"); - Thread.Sleep(3000); - Clear(); - Thread.Sleep(1000); - this.Invoke(new Action(() => - { - textgeninput.Font = new Font("Lucida Console", 14F, FontStyle.Bold); - this.BackColor = Color.Black; - })); - TextType("Welcome to ShiftOS."); - Thread.Sleep(4000); - Clear(); - textgeninput = lblhackwords; - TextType("Hello."); - Thread.Sleep(500); - TextType("You have been cordially and involuntarily selected to participate in the development and testing of an experimental operating system called ShiftOS."); - Thread.Sleep(500); - TextType("I want ShiftOS to be the most advanced operating system in the world."); - Thread.Sleep(500); - TextType("In ShiftOS, you start out with nothing."); - Thread.Sleep(500); - TextType("And your goal is to upgrade the operating system from a barebones command line to a fully graphical operating system."); - Thread.Sleep(500); - TextType("Along the way, you'll meet many people - hackers, rebels, programmers, administrators and many more."); - Thread.Sleep(500); - TextType("You'll meet new friends and foes."); - Thread.Sleep(500); - TextType("Your goal: Take it over. Upgrade the operating system, and take over its multi-user domain."); - Thread.Sleep(500); - TextType("I won't reveal quite what you have to do, but if you can handle it, head over to http://getshiftos.ml/ and download the operating system now."); - Thread.Sleep(5000); - Clear(); - textgeninput = lblHijack; - TextType("Think you can handle it?"); - }); - t.IsBackground = false; - t.Start(); - } - - public void Start() - { - Shiftorium.Silent = false; - foreach(var frm in AppearanceManager.OpenForms) - { - (frm as Form).Invoke(new Action(() => { - frm.Close(); - })); - } - - TerminalBackend.CommandProcessed += (cmd, args) => - { - if(cmd == "sos.help") - { - if (TutorialProgress == 0) - TutorialProgress = 1; - } - else if(cmd == "sos.status") - { - if (TutorialProgress == 1) - TutorialProgress = 2; - - } - else if(cmd == "shiftorium.list") - { - if (TutorialProgress == 2) - { - TutorialProgress = 3; - SaveSystem.TransferCodepointsFrom("sys", 50); - } - } - else if(cmd == "shiftorium.info" && args == "{\"upgrade\":\"mud_fundamentals\"}") - { - if (TutorialProgress == 3) - TutorialProgress = 4; - } - else if(cmd == "win.open") - { - if (TutorialProgress == 4) - TutorialProgress = 5; - } - }; - if(this.Visible == false) - this.Show(); - var t = new Thread(() => - { - textgeninput = lblHijack; - Clear(); - textgeninput = lblhackwords; - Clear(); - - this.Invoke(new Action(() => - { - textgeninput.Font = SkinEngine.LoadedSkin.TerminalFont; - })); - TextType("ShiftOS has been installed successfully."); - Thread.Sleep(500); - TextType("Before you can continue to the operating system, here's a little tutorial on how to use it."); - Thread.Sleep(500); - TextType("Starting a Terminal..."); - Applications.Terminal term = null; - this.Invoke(new Action(() => - { - term = new Applications.Terminal(); - this.Controls.Add(term); - term.Location = new Point( - (this.Width - term.Width) / 2, - (this.Height - term.Height) / 2 - ); - term.Show(); - term.OnLoad(); - term.OnSkinLoad(); - term.OnUpgrade(); - })); - TextType("This little text box is called a Terminal."); - Thread.Sleep(500); - TextType("Normally, it would appear in full-screen, but this window is hosting it as a control so you can see this text as well."); - Thread.Sleep(500); - TextType("In ShiftOS, the Terminal is your main control centre for the operating system. You can see system status, check Codepoints, open other programs, buy upgrades, and more."); - Thread.Sleep(500); - TextType("Go ahead and type 'sos.help' to see a list of commands."); - while (TutorialProgress == 0) - { - //JESUS CHRIST PAST MICHAEL. - - //We should PROBABLY block the thread... You know... not everyone has a 10-core processor. - Thread.Sleep(100); - - } - TextType("As you can see, sos.help gives you a list of all commands in the system."); - Thread.Sleep(500); - TextType("You can run any command, by typing in their Namespace, followed by a period (.), followed by their Command Name."); - Thread.Sleep(500); - TextType("Go ahead and run the 'status' command within the 'sos' namespace to see what the command does."); - while (TutorialProgress == 1) - { - //JESUS CHRIST PAST MICHAEL. - - //We should PROBABLY block the thread... You know... not everyone has a 10-core processor. - Thread.Sleep(100); - - } - TextType("Brilliant. The sos.status command will tell you how many Codepoints you have, as well as how many upgrades you have installed and how many are available."); - Thread.Sleep(500); - TextType("Codepoints, as you know, are a special currency within ShiftOS. They are used to buy things within the multi-user domain, such as upgrades, scripts, and applications."); - Thread.Sleep(500); - TextType("You can earn Codepoints by doing things in ShiftOS - such as completing jobs for other users, making things like skins, scripts, documents, etc, and playing games like Pong."); - Thread.Sleep(500); - TextType("At times, you'll be given Codepoints to help complete a task. You will receive Codepoints from 'sys' - the multi-user domain itself."); - //SaveSystem.TransferCodepointsFrom("sys", 50); - TextType("Right now, you don't have any upgrades. Upgrades can give ShiftOS additional features and capabilities - like new core applications, supported file types, and new Terminal commands."); - Thread.Sleep(500); - TextType("You can easily get upgrades using the Shiftorium - a repository of approved ShiftOS upgrades."); - Thread.Sleep(500); - TextType("To start using the Shiftorium, simply type 'shiftorium.list' to see available upgrades."); - while (TutorialProgress == 2) - { - //JESUS CHRIST PAST MICHAEL. - - //We should PROBABLY block the thread... You know... not everyone has a 10-core processor. - Thread.Sleep(100); - - } - Clear(); - TextType("Right now, you have enough Codepoints to buy the 'mud_fundamentals' upgrade. You can use shiftorium.info to see information about this upgrade."); - Thread.Sleep(500); - TextType("Some commands, like shiftorium.info, require you to pass information to them in the form of arguments."); - Thread.Sleep(500); - TextType("Argument pairs sit at the end of the command, and are enclosed in curly braces."); - Thread.Sleep(500); - TextType("Inside these curly braces, you can input an argument key, followed by a colon, followed by the value. Then, if you need multiple arguments, you can put a comma after the value, and then insert another argument pair."); - Thread.Sleep(500); - TextType("There are different value types - numeric values, which can be any positive or negative 32-bit integer"); - Thread.Sleep(500); - TextType("Then there are boolean values which can be either 'true' or 'false'"); - Thread.Sleep(500); - TextType("Then there are string values, which are enclosed in double-quotes."); - Thread.Sleep(500); - TextType(" If for some reason you need to use a double-quote inside a string, you must escape it using a single backslash followed by the quote, like this: key:\"My \\\"awesome\\\" value.\""); - Thread.Sleep(500); - TextType("If you want to escape a backslash inside a string, simply type two backslashes instead of one - for example key:\"Back\\\\slash.\""); - Thread.Sleep(500); - TextType("shiftorium.info requires an upgrade argument, which is a string type. Go ahead and give shiftorium.info's upgrade argument the 'mud_fundamentals' upgrade's ID."); - while (TutorialProgress == 3) - { - //JESUS CHRIST PAST MICHAEL. - - //We should PROBABLY block the thread... You know... not everyone has a 10-core processor. - Thread.Sleep(100); - - } - TextType("As you can see, mud_fundamentals is very useful. In fact, a lot of useful upgrades depend on it. You should buy it!"); - Thread.Sleep(500); - TextType("shiftorium.info already gave you a command that will let you buy the upgrade - go ahead and run that command!"); - while (!Shiftorium.UpgradeInstalled("mud_fundamentals")) - { //JESUS CHRIST PAST MICHAEL. - - //We should PROBABLY block the thread... You know... not everyone has a 10-core processor. - Thread.Sleep(100); - - - } - TextType("Hooray! You now have the MUD Fundamentals upgrade."); - Thread.Sleep(500); - TextType("You can also earn more Codepoints by playing Pong. To open Pong, you can use the win.open command."); - Thread.Sleep(500); - TextType("If you run win.open without arguments, you can see a list of applications that you can open."); - Thread.Sleep(500); - TextType("Just run win.open without arguments, and this tutorial will be completed!"); - while (TutorialProgress == 4) - { - //JESUS CHRIST PAST MICHAEL. - - //We should PROBABLY block the thread... You know... not everyone has a 10-core processor. - Thread.Sleep(100); - - } - TextType("This concludes the ShiftOS beginners' guide brought to you by the multi-user domain. Stay safe in a connected world."); - Thread.Sleep(2000); - Desktop.InvokeOnWorkerThread(() => - { - OnComplete?.Invoke(this, EventArgs.Empty); - SaveSystem.CurrentSave.StoryPosition = 2; - this.Close(); - SaveSystem.SaveGame(); - AppearanceManager.SetupWindow(new Applications.Terminal()); - }); - - }); - t.IsBackground = true; - t.Start(); - } - } -} diff --git a/ShiftOS.WinForms/Program.cs b/ShiftOS.WinForms/Program.cs deleted file mode 100644 index ad8fc83..0000000 --- a/ShiftOS.WinForms/Program.cs +++ /dev/null @@ -1,269 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Linq; -using System.Threading.Tasks; -using System.Windows.Forms; -using ShiftOS.Engine; -using Newtonsoft.Json; -using static ShiftOS.Objects.ShiftFS.Utils; -using ShiftOS.WinForms.Applications; -using ShiftOS.WinForms.Tools; -using System.Reflection; -using System.IO; - -namespace ShiftOS.WinForms -{ - public static class Program - { - /// - /// The main entry point for the application. - /// - [STAThread] - public static void Main() - { - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); - //if ANYONE puts code before those two winforms config lines they will be declared a drunky. - Michael - LoginManager.Init(new GUILoginFrontend()); - CrashHandler.SetGameMetadata(Assembly.GetExecutingAssembly()); - SkinEngine.SetIconProber(new ShiftOSIconProvider()); - ShiftOS.Engine.AudioManager.Init(new ShiftOSAudioProvider()); - Localization.RegisterProvider(new WFLanguageProvider()); - AppearanceManager.OnExit += () => - { - Environment.Exit(0); - }; - - TutorialManager.RegisterTutorial(new Oobe()); - - TerminalBackend.TerminalRequested += () => - { - AppearanceManager.SetupWindow(new Applications.Terminal()); - }; - Infobox.Init(new Dialog()); - FileSkimmerBackend.Init(new WinformsFSFrontend()); - var desk = new WinformsDesktop(); - Desktop.Init(desk); - OutOfBoxExperience.Init(new Oobe()); - AppearanceManager.Initiate(new WinformsWindowManager()); - Application.Run(desk); - } - } - - internal class ShiftOSIconProvider : IIconProber - { - public Image GetIcon(DefaultIconAttribute attr) - { - - var res = typeof(Properties.Resources); - foreach(var prop in res.GetProperties(BindingFlags.NonPublic | BindingFlags.Static)) - { - if(prop.PropertyType.BaseType == typeof(Image)) - { - if(prop.Name == attr.ID) - { - return prop.GetValue(null) as Image; - } - } - } - return new Bitmap(16, 16); - } - } - - [ShiftoriumProvider] - internal class WinformsShiftoriumProvider : IShiftoriumProvider - { - public List GetDefaults() - { - var defaultList = JsonConvert.DeserializeObject>(Properties.Resources.Shiftorium); - - foreach(var exe in Directory.GetFiles(Environment.CurrentDirectory)) - { - if (exe.EndsWith(".exe") || exe.EndsWith(".dll")) - { - try - { - var asm = Assembly.LoadFile(exe); - foreach (var type in asm.GetTypes()) - { - var attrib = type.GetCustomAttributes(false).FirstOrDefault(x => x is AppscapeEntryAttribute) as AppscapeEntryAttribute; - if (attrib != null) - { - var upgrade = new ShiftoriumUpgrade - { - Id = attrib.Name.ToLower().Replace(" ", "_"), - Name = attrib.Name, - Description = attrib.Description, - Cost = attrib.Cost, - Category = attrib.Category, - Dependencies = (string.IsNullOrWhiteSpace(attrib.DependencyString)) ? "appscape_handled_nodisplay" : "appscape_handled_nodisplay;" + attrib.DependencyString - }; - defaultList.Add(upgrade); - } - - var sattrib = type.GetCustomAttributes(false).FirstOrDefault(x => x is StpContents) as StpContents; - if (sattrib != null) - { - var upgrade = new ShiftoriumUpgrade - { - Id = sattrib.Upgrade, - Name = sattrib.Name, - Description = "This is a hidden dummy upgrade for the .stp file installation attribute \"" + sattrib.Name + "\".", - Cost = 0, - Category = "If this is shown, there's a bug in the Shiftorium Provider or the user is a supreme Shifter.", - Dependencies = "dummy_nodisplay" - }; - defaultList.Add(upgrade); - } - - } - - - - - } - catch { } - } - } - return defaultList; - } - } - - public class WinformsFSFrontend : IFileSkimmer - { - - - public void OpenDirectory(string path) - { - var fs = new Applications.FileSkimmer(); - AppearanceManager.SetupWindow(fs); - fs.ChangeDirectory(path); - } - - public void GetPath(string[] filetypes, FileOpenerStyle style, Action callback) - { - AppearanceManager.SetupDialog(new Applications.FileDialog(filetypes, style, callback)); - } - - public void OpenFile(string path) - { - try - { - switch (FileSkimmerBackend.GetFileType(path)) - { - case FileType.TextFile: - if (!Shiftorium.UpgradeInstalled("textpad")) - throw new Exception(); - - var txt = new TextPad(); - AppearanceManager.SetupWindow(txt); - txt.LoadFile(path); - break; - case FileType.Executable: - //NYI - throw new Exception(); - case FileType.Lua: - try - { - var runner = new Engine.Scripting.LuaInterpreter(); - runner.ExecuteFile(path); - } - catch (Exception ex) - { - Infobox.Show("{LUA_ERROR}", ex.Message); - } - break; - case FileType.JSON: - //NYI - throw new Exception(); - case FileType.Filesystem: - MountPersistent(path); - //If this doesn't fail... - FileSkimmerBackend.OpenDirectory((Mounts.Count - 1).ToString() + ":"); - break; - case FileType.Skin: - if (!Shiftorium.UpgradeInstalled("skinning")) - throw new Exception(); - - var sl = new Skin_Loader(); - AppearanceManager.SetupWindow(sl); - sl.LoadedSkin = JsonConvert.DeserializeObject(ReadAllText(path)); - sl.SetupUI(); - break; - case FileType.Image: - if (!Shiftorium.UpgradeInstalled("artpad_open")) - throw new Exception(); - - var ap = new Artpad(); - AppearanceManager.SetupWindow(ap); - ap.LoadPicture(path); - break; - default: - throw new Exception(); - - } - } - catch - { - Infobox.Show("{NO_APP_TO_OPEN}", "{NO_APP_TO_OPEN_EXP}"); - } - - } - - public Image GetImage(string path) - { - return Applications.FileSkimmer.GetImage(FileSkimmerBackend.GetFileType(path)); - } - - public string GetFileExtension(FileType fileType) - { - switch (fileType) - { - case FileType.Executable: - return ".saa"; - case FileType.Filesystem: - return ".mfs"; - case FileType.Image: - return ".pic"; - case FileType.JSON: - return ".json"; - case FileType.Lua: - return ".lua"; - case FileType.Python: - return ".py"; - case FileType.Skin: - return ".skn"; - case FileType.TextFile: - return ".txt"; - default: - return ".bin"; - - } - } - } -} diff --git a/ShiftOS.WinForms/Properties/Resources.Designer.cs b/ShiftOS.WinForms/Properties/Resources.Designer.cs deleted file mode 100644 index caaf503..0000000 --- a/ShiftOS.WinForms/Properties/Resources.Designer.cs +++ /dev/null @@ -1,1394 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace ShiftOS.WinForms.Properties { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ShiftOS.WinForms.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized resource of type System.IO.UnmanagedMemoryStream similar to System.IO.MemoryStream. - /// - internal static System.IO.UnmanagedMemoryStream _3beepvirus { - get { - return ResourceManager.GetStream("_3beepvirus", resourceCulture); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap ArtPadcirclerubber { - get { - object obj = ResourceManager.GetObject("ArtPadcirclerubber", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap ArtPadcirclerubberselected { - get { - object obj = ResourceManager.GetObject("ArtPadcirclerubberselected", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap ArtPaderacer { - get { - object obj = ResourceManager.GetObject("ArtPaderacer", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap ArtPadfloodfill { - get { - object obj = ResourceManager.GetObject("ArtPadfloodfill", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap ArtPadlinetool { - get { - object obj = ResourceManager.GetObject("ArtPadlinetool", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap ArtPadmagnify { - get { - object obj = ResourceManager.GetObject("ArtPadmagnify", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap ArtPadnew { - get { - object obj = ResourceManager.GetObject("ArtPadnew", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap ArtPadopen { - get { - object obj = ResourceManager.GetObject("ArtPadopen", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap ArtPadOval { - get { - object obj = ResourceManager.GetObject("ArtPadOval", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap ArtPadpaintbrush { - get { - object obj = ResourceManager.GetObject("ArtPadpaintbrush", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap ArtPadpencil { - get { - object obj = ResourceManager.GetObject("ArtPadpencil", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap ArtPadpixelplacer { - get { - object obj = ResourceManager.GetObject("ArtPadpixelplacer", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap ArtPadRectangle { - get { - object obj = ResourceManager.GetObject("ArtPadRectangle", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap ArtPadredo { - get { - object obj = ResourceManager.GetObject("ArtPadredo", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap ArtPadsave { - get { - object obj = ResourceManager.GetObject("ArtPadsave", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap ArtPadsquarerubber { - get { - object obj = ResourceManager.GetObject("ArtPadsquarerubber", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap ArtPadsquarerubberselected { - get { - object obj = ResourceManager.GetObject("ArtPadsquarerubberselected", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap ArtPadtexttool { - get { - object obj = ResourceManager.GetObject("ArtPadtexttool", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap ArtPadundo { - get { - object obj = ResourceManager.GetObject("ArtPadundo", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap DefaultMouse { - get { - object obj = ResourceManager.GetObject("DefaultMouse", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.IO.UnmanagedMemoryStream similar to System.IO.MemoryStream. - /// - internal static System.IO.UnmanagedMemoryStream dial_up_modem_02 { - get { - return ResourceManager.GetStream("dial_up_modem_02", resourceCulture); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap fileicon0 { - get { - object obj = ResourceManager.GetObject("fileicon0", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap fileicon1 { - get { - object obj = ResourceManager.GetObject("fileicon1", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap fileicon10 { - get { - object obj = ResourceManager.GetObject("fileicon10", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap fileicon11 { - get { - object obj = ResourceManager.GetObject("fileicon11", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap fileicon12 { - get { - object obj = ResourceManager.GetObject("fileicon12", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap fileicon13 { - get { - object obj = ResourceManager.GetObject("fileicon13", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap fileicon14 { - get { - object obj = ResourceManager.GetObject("fileicon14", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap fileicon15 { - get { - object obj = ResourceManager.GetObject("fileicon15", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap fileicon16 { - get { - object obj = ResourceManager.GetObject("fileicon16", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap fileicon17 { - get { - object obj = ResourceManager.GetObject("fileicon17", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap fileicon18 { - get { - object obj = ResourceManager.GetObject("fileicon18", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap fileicon19 { - get { - object obj = ResourceManager.GetObject("fileicon19", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap fileicon2 { - get { - object obj = ResourceManager.GetObject("fileicon2", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap fileicon3 { - get { - object obj = ResourceManager.GetObject("fileicon3", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap fileicon4 { - get { - object obj = ResourceManager.GetObject("fileicon4", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap fileicon5 { - get { - object obj = ResourceManager.GetObject("fileicon5", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap fileicon6 { - get { - object obj = ResourceManager.GetObject("fileicon6", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap fileicon7 { - get { - object obj = ResourceManager.GetObject("fileicon7", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap fileicon8 { - get { - object obj = ResourceManager.GetObject("fileicon8", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap fileicon9 { - get { - object obj = ResourceManager.GetObject("fileicon9", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap fileiconcf { - get { - object obj = ResourceManager.GetObject("fileiconcf", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap fileiconsaa { - get { - object obj = ResourceManager.GetObject("fileiconsaa", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap FloppyDriveIcon { - get { - object obj = ResourceManager.GetObject("FloppyDriveIcon", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized string similar to . - /// - internal static string hello { - get { - return ResourceManager.GetString("hello", resourceCulture); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap iconArtpad { - get { - object obj = ResourceManager.GetObject("iconArtpad", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap iconAudioPlayer { - get { - object obj = ResourceManager.GetObject("iconAudioPlayer", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap iconBitnoteDigger { - get { - object obj = ResourceManager.GetObject("iconBitnoteDigger", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap iconBitnoteWallet { - get { - object obj = ResourceManager.GetObject("iconBitnoteWallet", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap iconCalculator { - get { - object obj = ResourceManager.GetObject("iconCalculator", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap iconClock { - get { - object obj = ResourceManager.GetObject("iconClock", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap iconColourPicker_fw { - get { - object obj = ResourceManager.GetObject("iconColourPicker_fw", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap iconDodge { - get { - object obj = ResourceManager.GetObject("iconDodge", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap iconDownloader { - get { - object obj = ResourceManager.GetObject("iconDownloader", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap iconFileOpener_fw { - get { - object obj = ResourceManager.GetObject("iconFileOpener_fw", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap iconFileSaver_fw { - get { - object obj = ResourceManager.GetObject("iconFileSaver_fw", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap iconFileSkimmer { - get { - object obj = ResourceManager.GetObject("iconFileSkimmer", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap iconfloodgate { - get { - object obj = ResourceManager.GetObject("iconfloodgate", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap iconFormatEditor { - get { - object obj = ResourceManager.GetObject("iconFormatEditor", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap icongraphicpicker { - get { - object obj = ResourceManager.GetObject("icongraphicpicker", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap iconIconManager { - get { - object obj = ResourceManager.GetObject("iconIconManager", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap iconInfoBox_fw { - get { - object obj = ResourceManager.GetObject("iconInfoBox_fw", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap iconKnowledgeInput { - get { - object obj = ResourceManager.GetObject("iconKnowledgeInput", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap iconmaze { - get { - object obj = ResourceManager.GetObject("iconmaze", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap iconNameChanger { - get { - object obj = ResourceManager.GetObject("iconNameChanger", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap iconoctocat { - get { - object obj = ResourceManager.GetObject("iconoctocat", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap iconorcwrite { - get { - object obj = ResourceManager.GetObject("iconorcwrite", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap iconPong { - get { - object obj = ResourceManager.GetObject("iconPong", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap iconShifter { - get { - object obj = ResourceManager.GetObject("iconShifter", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap iconShiftLetters { - get { - object obj = ResourceManager.GetObject("iconShiftLetters", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap iconShiftLotto { - get { - object obj = ResourceManager.GetObject("iconShiftLotto", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap iconShiftnet { - get { - object obj = ResourceManager.GetObject("iconShiftnet", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap iconShiftorium { - get { - object obj = ResourceManager.GetObject("iconShiftorium", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap iconShiftSweeper { - get { - object obj = ResourceManager.GetObject("iconShiftSweeper", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap iconshutdown { - get { - object obj = ResourceManager.GetObject("iconshutdown", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap iconshutdown1 { - get { - object obj = ResourceManager.GetObject("iconshutdown1", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap iconSkinLoader { - get { - object obj = ResourceManager.GetObject("iconSkinLoader", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap iconSkinShifter { - get { - object obj = ResourceManager.GetObject("iconSkinShifter", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap iconSnakey { - get { - object obj = ResourceManager.GetObject("iconSnakey", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap iconSysinfo { - get { - object obj = ResourceManager.GetObject("iconSysinfo", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap iconTerminal { - get { - object obj = ResourceManager.GetObject("iconTerminal", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap iconTextPad { - get { - object obj = ResourceManager.GetObject("iconTextPad", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap iconunitytoggle { - get { - object obj = ResourceManager.GetObject("iconunitytoggle", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap iconVideoPlayer { - get { - object obj = ResourceManager.GetObject("iconVideoPlayer", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap iconvirusscanner { - get { - object obj = ResourceManager.GetObject("iconvirusscanner", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap iconWebBrowser { - get { - object obj = ResourceManager.GetObject("iconWebBrowser", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.IO.UnmanagedMemoryStream similar to System.IO.MemoryStream. - /// - internal static System.IO.UnmanagedMemoryStream infobox { - get { - return ResourceManager.GetStream("infobox", resourceCulture); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap justthes { - get { - object obj = ResourceManager.GetObject("justthes", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized string similar to [ - /// "english" - /// "deutsch" - ///]. - /// - internal static string languages { - get { - return ResourceManager.GetString("languages", resourceCulture); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap RegularDesktopGlyph { - get { - object obj = ResourceManager.GetObject("RegularDesktopGlyph", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized string similar to [ - /// { - /// Name: "Freebie Solutions", - /// DownloadSpeed: 256, - /// CostPerMonth: 0, - /// Description: "The Shiftnet is a wonderful place full of apps, games, websites and skins for ShiftOS. - /// - ///With Freebie Solutions from ShiftSoft, you'll be able to traverse the Shiftnet without any worry about monthly fees.", - /// Company: "ShiftSoft" - /// }, - /// { - /// Company: "Shiftcast", - /// Name: "NetXtreme Hyper Edition", - /// CostPerMonth: 1500, - /// DownloadSpeed: 524288, //512 kb/s - /// Description: "It's time to supercharge your Shif [rest of string was truncated]";. - /// - internal static string ShiftnetServices { - get { - return ResourceManager.GetString("ShiftnetServices", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to [ - /// //TEMPORARY - /// { - /// Name: "Desktop Widgets", - /// Cost: 0, - /// Description: "Temporary upgrade. Will be replaced by either a Shiftnet app or a story element.", - /// Dependencies: "advanced_app_launcher;wm_free_placement", - /// Category: "Work-in-progress" - /// }, - /// - /// - /// - ///// SCREENSAVER - /// { - /// Name: "Screensavers", - /// Cost: 750, - /// Description: "Like to leave your PC idle for long periods of time? Save some energy and keep your screen from being tired by hiding the desktop behind a black screen with an image on it." [rest of string was truncated]";. - /// - internal static string Shiftorium { - get { - return ResourceManager.GetString("Shiftorium", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {\rtf1\adeflang1025\ansi\ansicpg1252\uc1\adeff0\deff0\stshfdbch31505\stshfloch31506\stshfhich31506\stshfbi0\deflang1033\deflangfe1033\themelang1033\themelangfe0\themelangcs0{\fonttbl{\f0\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}{\f0\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;} - ///{\f37\fbidi \fswiss\fcharset0\fprq2{\*\panose 020f0502020204030204}Calibri;}{\f38\fbidi \fswiss\fcharset0\fprq2{\*\panose 020f0302020204030204}Calibri Light;}{\fl [rest of string was truncated]";. - /// - internal static string ShiftOS { - get { - return ResourceManager.GetString("ShiftOS", resourceCulture); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap SnakeyBG { - get { - object obj = ResourceManager.GetObject("SnakeyBG", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap SnakeyBody { - get { - object obj = ResourceManager.GetObject("SnakeyBody", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap SnakeyFruit { - get { - object obj = ResourceManager.GetObject("SnakeyFruit", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap SnakeyHeadD { - get { - object obj = ResourceManager.GetObject("SnakeyHeadD", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap SnakeyHeadL { - get { - object obj = ResourceManager.GetObject("SnakeyHeadL", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap SnakeyHeadR { - get { - object obj = ResourceManager.GetObject("SnakeyHeadR", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap SnakeyHeadU { - get { - object obj = ResourceManager.GetObject("SnakeyHeadU", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap SnakeyTailD { - get { - object obj = ResourceManager.GetObject("SnakeyTailD", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap SnakeyTailL { - get { - object obj = ResourceManager.GetObject("SnakeyTailL", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap SnakeyTailR { - get { - object obj = ResourceManager.GetObject("SnakeyTailR", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap SnakeyTailU { - get { - object obj = ResourceManager.GetObject("SnakeyTailU", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized string similar to [ - /// "http://downloads.michaeltheshifter.me/music/blockride.mp3", - /// "http://downloads.michaeltheshifter.me/music/nightcoding.mp3" - ///]. - /// - internal static string Songs { - get { - return ResourceManager.GetString("Songs", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to { - /// "{SUBMIT}":"Bestätigen", - /// - ///"{TERMINAL_TUTORIAL_1}":"Wilkommen zum ShiftOS Terminal. Hier wirst du die meiste Zeit in ShiftOS verbringen. - /// - ///Eine kurze Erklärung wie du das Terminal benutzt lautet wiefolgt. Du kannst das command 'sos.help' benutzen um eine Liste aller commands aufzurufen. Schreib es - ///einfach in das Terminal und drĂ¼cke <enter> um alle commands anzuzeigen. - /// - ///Commands können mit argumenten versehen werden, indem du ein key-value Paar in einem {} Block hinter dem command angibst. Zum Be [rest of string was truncated]";. - /// - internal static string strings_de { - get { - return ResourceManager.GetString("strings_de", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to { - /// "{SUBMIT}":"Submit", - /// - ///"{TERMINAL_TUTORIAL_1}":"Welcome to the ShiftOS terminal. This is where you will spend the bulk of your time within ShiftOS. - /// - ///A brief rundown of how to use the terminal is as follows. You can use the 'sos.help' command to show a list of all commands. Simply type it in and strike <enter> to view all commands. - /// - ///Commands can be sent arguments by specifying a key-value pair inside a {} block at the end of the command. For example: - /// - ///some.command{print:\"hello\"} - ///math.add{op1 [rest of string was truncated]";. - /// - internal static string strings_en { - get { - return ResourceManager.GetString("strings_en", resourceCulture); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap SuperDesk_screenshot { - get { - object obj = ResourceManager.GetObject("SuperDesk screenshot", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap SweeperClickFace { - get { - object obj = ResourceManager.GetObject("SweeperClickFace", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap SweeperLoseFace { - get { - object obj = ResourceManager.GetObject("SweeperLoseFace", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap SweeperNormalFace { - get { - object obj = ResourceManager.GetObject("SweeperNormalFace", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap SweeperTile0 { - get { - object obj = ResourceManager.GetObject("SweeperTile0", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap SweeperTile1 { - get { - object obj = ResourceManager.GetObject("SweeperTile1", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap SweeperTile2 { - get { - object obj = ResourceManager.GetObject("SweeperTile2", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap SweeperTile3 { - get { - object obj = ResourceManager.GetObject("SweeperTile3", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap SweeperTile4 { - get { - object obj = ResourceManager.GetObject("SweeperTile4", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap SweeperTile5 { - get { - object obj = ResourceManager.GetObject("SweeperTile5", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap SweeperTile6 { - get { - object obj = ResourceManager.GetObject("SweeperTile6", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap SweeperTile7 { - get { - object obj = ResourceManager.GetObject("SweeperTile7", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap SweeperTile8 { - get { - object obj = ResourceManager.GetObject("SweeperTile8", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap SweeperTileBlock { - get { - object obj = ResourceManager.GetObject("SweeperTileBlock", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap SweeperTileBomb { - get { - object obj = ResourceManager.GetObject("SweeperTileBomb", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap SweeperTileFlag { - get { - object obj = ResourceManager.GetObject("SweeperTileFlag", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap SweeperWinFace { - get { - object obj = ResourceManager.GetObject("SweeperWinFace", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized string similar to { - /// Character: "sys", - /// Lines:[ - /// "Hello there, %user.", - /// "Welcome to ShiftOS.", - /// "This is an automated message to all new sentiences within the ShiftOS multi-user domain.", - /// "Before you can begin with ShiftOS, you'll need to know a few things about it.", - /// "One: Terminal command syntax.", - /// "Inside ShiftOS, the bulk of your time is going to be spent within the Terminal.", - /// "The Terminal is an application that starts up when you turn on your computer. It allows you to execute system commands, ope [rest of string was truncated]";. - /// - internal static string sys_shiftoriumstory { - get { - return ResourceManager.GetString("sys_shiftoriumstory", resourceCulture); - } - } - - /// - /// Looks up a localized resource of type System.IO.UnmanagedMemoryStream similar to System.IO.MemoryStream. - /// - internal static System.IO.UnmanagedMemoryStream typesound { - get { - return ResourceManager.GetStream("typesound", resourceCulture); - } - } - - /// - /// Looks up a localized resource of type System.IO.UnmanagedMemoryStream similar to System.IO.MemoryStream. - /// - internal static System.IO.UnmanagedMemoryStream writesound { - get { - return ResourceManager.GetStream("writesound", resourceCulture); - } - } - } -} diff --git a/ShiftOS.WinForms/Tools/ControlManager.cs b/ShiftOS.WinForms/Tools/ControlManager.cs deleted file mode 100644 index 3d66b2b..0000000 --- a/ShiftOS.WinForms/Tools/ControlManager.cs +++ /dev/null @@ -1,300 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Linq; -using System.Runtime.InteropServices; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using System.Windows.Forms; -using ShiftOS.Engine; -using static ShiftOS.Engine.AppearanceManager; - - -namespace ShiftOS.WinForms.Tools -{ - public static class ControlManager - { - [DllImport("user32.dll")] - public static extern int SendMessage(IntPtr hWnd, Int32 wMsg, bool wParam, Int32 lParam); - - private const int WM_SETREDRAW = 11; - - public static void SuspendDrawing(Control parent) - { - SendMessage(parent.Handle, WM_SETREDRAW, false, 0); - } - - public static void ResumeDrawing(Control parent) - { - SendMessage(parent.Handle, WM_SETREDRAW, true, 0); - parent.Refresh(); - } - - public static void Close(this UserControl ctrl) - { - for (int i = 0; i < AppearanceManager.OpenForms.Count; i++) - { - if (OpenForms[i].ParentWindow == ctrl) - { - (OpenForms[i] as Form).Close(); - return; - } - } - } - - - internal static Color ConvertColor(ConsoleColor cCol) - { - switch (cCol) - { - case ConsoleColor.Black: - return Color.Black; - case ConsoleColor.Gray: - return Color.Gray; - case ConsoleColor.DarkGray: - return Color.DarkGray; - case ConsoleColor.Blue: - return Color.Blue; - case ConsoleColor.Cyan: - return Color.Cyan; - case ConsoleColor.DarkBlue: - return Color.DarkBlue; - case ConsoleColor.DarkCyan: - return Color.DarkCyan; - case ConsoleColor.DarkGreen: - return Color.DarkGreen; - case ConsoleColor.DarkMagenta: - return Color.DarkMagenta; - case ConsoleColor.DarkRed: - return Color.DarkRed; - case ConsoleColor.DarkYellow: - return Color.YellowGreen; - case ConsoleColor.Yellow: - return Color.Yellow; - case ConsoleColor.Green: - return Color.Green; - case ConsoleColor.Magenta: - return Color.Magenta; - case ConsoleColor.Red: - return Color.Red; - case ConsoleColor.White: - return Color.White; - default: - return Color.Black; - } - - } - - public static void SetCursor(Control ctrl) - { -#if STUPID - if (!(ctrl is WebBrowser)) - { - var mouse = SkinEngine.GetImage("mouse"); - if (mouse == null) - mouse = Properties.Resources.DefaultMouse; - - var mBmp = new Bitmap(mouse); - mBmp.MakeTransparent(Color.FromArgb(1, 0, 1)); - var gfx = Graphics.FromImage(mBmp); - var handle = mBmp.GetHicon(); - - var cursor = new Cursor(handle); - ctrl.Cursor = cursor; - } -#endif - } - - /// - /// Centers the control along its parent. - /// - /// The control to center (this is an extension method - you can call it on a control as though it was a method in that control) - public static void CenterParent(this Control ctrl) - { - ctrl.Location = new Point( - (ctrl.Parent.Width - ctrl.Width) / 2, - (ctrl.Parent.Height - ctrl.Height) / 2 - ); - } - - public static void SetupControl(Control ctrl) - { - Desktop.InvokeOnWorkerThread(new Action(() => - { - ctrl.SuspendLayout(); - })); - if (!(ctrl is MenuStrip) && !(ctrl is ToolStrip) && !(ctrl is StatusStrip) && !(ctrl is ContextMenuStrip)) - { - string tag = ""; - - try - { - if(ctrl.Tag != null) - tag = ctrl.Tag.ToString(); - } - catch { } - - if (!tag.Contains("keepbg")) - { - if (ctrl.BackColor != Control.DefaultBackColor) - { - Desktop.InvokeOnWorkerThread(() => - { - ctrl.BackColor = SkinEngine.LoadedSkin.ControlColor; - }); - } - } - - if (!tag.Contains("keepfont")) - { - Desktop.InvokeOnWorkerThread(() => - { - ctrl.ForeColor = SkinEngine.LoadedSkin.ControlTextColor; - ctrl.Font = SkinEngine.LoadedSkin.MainFont; - }); - if (tag.Contains("header1")) - { - Desktop.InvokeOnWorkerThread(() => - { - ctrl.Font = SkinEngine.LoadedSkin.HeaderFont; - }); - } - - if (tag.Contains("header2")) - { - Desktop.InvokeOnWorkerThread(() => - { - ctrl.Font = SkinEngine.LoadedSkin.Header2Font; - }); - } - - if (tag.Contains("header3")) - { - Desktop.InvokeOnWorkerThread(() => - { - - ctrl.Font = SkinEngine.LoadedSkin.Header3Font; - }); - } - } - try - { - string ctrlText = Localization.Parse(ctrl.Text); - Desktop.InvokeOnWorkerThread(() => - { - ctrl.Text = ctrlText; - }); - } - catch - { - - } - ctrl.KeyDown += (o, a) => - { - if (a.Control && a.KeyCode == Keys.T) - { - a.SuppressKeyPress = true; - - - Engine.AppearanceManager.SetupWindow(new Applications.Terminal()); - } - - ShiftOS.Engine.Scripting.LuaInterpreter.RaiseEvent("on_key_down", a); - //a.Handled = true; - }; - if (ctrl is Button) - { - Desktop.InvokeOnWorkerThread(() => - { - (ctrl as Button).FlatStyle = FlatStyle.Flat; - }); - } - else if (ctrl is WindowBorder) - { - Desktop.InvokeOnWorkerThread(() => - { - (ctrl as WindowBorder).Setup(); - }); - } - } - Desktop.InvokeOnWorkerThread(() => - { - - MakeDoubleBuffered(ctrl); - ctrl.ResumeLayout(); - }); - ControlSetup?.Invoke(ctrl); - } - - public static event Action ControlSetup; - - public static void MakeDoubleBuffered(Control c) - { - if (System.Windows.Forms.SystemInformation.TerminalServerSession) - return; - - System.Reflection.PropertyInfo aProp = - typeof(System.Windows.Forms.Control).GetProperty( - "DoubleBuffered", - System.Reflection.BindingFlags.NonPublic | - System.Reflection.BindingFlags.Instance); - - aProp.SetValue(c, true, null); - - } - - public static void SetupControls(Control frm, bool runInThread = true) - { - SetupControl(frm); - frm.Click += (o, a) => - { - Desktop.HideAppLauncher(); - }; - ThreadStart ts = () => - { - for (int i = 0; i < frm.Controls.Count; i++) - { - SetupControls(frm.Controls[i], false); - } - - }; - - if (runInThread == true) - { - var t = new Thread(ts); - t.IsBackground = true; - t.Start(); - } - else - { - ts?.Invoke(); - } - } - - } -} diff --git a/ShiftOS.WinForms/Tools/DitheringEngine.cs b/ShiftOS.WinForms/Tools/DitheringEngine.cs deleted file mode 100644 index 8509a0b..0000000 --- a/ShiftOS.WinForms/Tools/DitheringEngine.cs +++ /dev/null @@ -1,402 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#define FLOYDSTEINBERG - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Drawing; -using System.Threading; -using ShiftOS.Engine; -using System.Runtime.InteropServices; - -namespace ShiftOS.WinForms.Tools -{ - public static class DitheringEngine - { - public static Color GetColor(Color source) - { - if (Shiftorium.UpgradeInstalled("color_depth_24_bits")) - { - return Color.FromArgb(source.R, source.G, source.B); //get rid of the alpha channel. - } - else - { - if (Shiftorium.UpgradeInstalled("color_depth_16_bits")) - { - byte r = (byte)linear(source.R, 0, 0xFF, 0, 0x1F); - byte g = (byte)linear(source.G, 0, 0xFF, 0, 0x3F); - byte b = (byte)linear(source.B, 0, 0xFF, 0, 0x1F); - - return Color.FromArgb(r, g, b); - } - else - { - int gray = (source.R + source.G + source.B) / 3; - - if (Shiftorium.UpgradeInstalled("color_depth_8_bits")) - return Color.FromArgb(gray, gray, gray); - else - { - if (Shiftorium.UpgradeInstalled("color_depth_6_bits")) - { - int gray6 = (int)linear(gray, 0, 0xFF, 0, 0x3F) * 3; - - - - return Color.FromArgb(gray6, gray6, gray6); - } - else - { - if (Shiftorium.UpgradeInstalled("color_depth_4_bits")) - { - int gray4 = (int)linear(linear(gray, 0, 0xFF, 0, 0xF), 0, 0xF, 0, 0xFF) * 0xF; - return Color.FromArgb(gray4, gray4, gray4); - } - else - { - if (Shiftorium.UpgradeInstalled("color_depth_2_bits")) - { - int gray2 = (int)linear(linear(gray, 0, 0xFF, 0, 0x3), 0, 0x3, 0, 0xFF) * 63; - return Color.FromArgb(gray2, gray2, gray2); - } - else { - if (gray >= 127) - { - return Color.Black; - } - else - { - return Color.White; - } - } - } - } - } - } - } - } - - public static void DitherColor(Color source, int width, int height, Action result) - { - var bmp = new Bitmap(width + 1, height + 1); - var data = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.ReadWrite, System.Drawing.Imaging.PixelFormat.Format24bppRgb); - byte[] rgb = new byte[Math.Abs(data.Stride) * data.Height]; - Marshal.Copy(data.Scan0, rgb, 0, rgb.Length); - for (int i = 0; i < rgb.Length - 3; i += 3) - { - rgb[i] = source.R; - rgb[i + 1] = source.G; - rgb[i + 2] = source.B; - } - Marshal.Copy(rgb, 0, data.Scan0, rgb.Length); - bmp.UnlockBits(data); - DitherImage(bmp, result); - - } - - static private double linear(double x, double x0, double x1, double y0, double y1) - { - if ((x1 - x0) == 0) - { - return (y0 + y1) / 2; - } - return y0 + (x - x0) * (y1 - y0) / (x1 - x0); - } - -#if NODITHER - public static void DitherImage(Image source, Action result) - { - Desktop.InvokeOnWorkerThread(new Action(() => - { - result?.Invoke(source); - })); - } -#endif - -#if BINARIZE - public static void DitherImage(Image source, Action result) - { - if (source == null) - { - result?.Invoke(source); - return; - } - - - var t = new Thread(new ThreadStart(() => - { - var bmp = new Bitmap(source.Width, source.Height); - var sourceBmp = (Bitmap)source; - int error = 0; - for (int y = 0; y < bmp.Height; y++) - { - for (int x = 0; x < bmp.Width; x++) - { - - Color c = sourceBmp.GetPixel(x, y); - int gray = ((c.R + c.G + c.B) / 3); - if (gray >= 127) - { - error = gray - 255; - bmp.SetPixel(x, y, Color.White); - } - else - { - error = gray; - bmp.SetPixel(x, y, Color.Black); - } - - - } - } - Desktop.InvokeOnWorkerThread(new Action(() => { result?.Invoke(bmp); })); - })); - t.IsBackground = true; - t.Start(); - - } -#endif - -#if DITHER1D - public static void DitherImage(Image source, Action result) - { - if (source == null) - { - result?.Invoke(source); - return; - } - - - var t = new Thread(new ThreadStart(() => - { - var bmp = new Bitmap(source.Width, source.Height); - var sourceBmp = (Bitmap)source; - int error = 0; - for (int y = 0; y < bmp.Height; y++) - { - for (int x = 0; x < bmp.Width; x++) - { - - Color c = sourceBmp.GetPixel(x, y); - int gray = ((c.R + c.G + c.B) / 3) + error; - if (gray >= 127) - { - error = gray - 255; - bmp.SetPixel(x, y, Color.White); - } - else - { - error = gray; - bmp.SetPixel(x, y, Color.Black); - } - - - } - } - Desktop.InvokeOnWorkerThread(new Action(() => { result?.Invoke(bmp); })); - })); - t.IsBackground = true; - t.Start(); - } -#endif - -#if FLOYDSTEINBERG - public static void DitherImage(Image source, Action result) - { - if (source == null) - { - result?.Invoke(source); - return; - } - - - var bmp = new Bitmap(source.Width, source.Height); - var sourceBmp = (Bitmap)source; - var sourceLck = sourceBmp.LockBits(new Rectangle(0, 0, sourceBmp.Width, sourceBmp.Height), System.Drawing.Imaging.ImageLockMode.ReadWrite, System.Drawing.Imaging.PixelFormat.Format24bppRgb); - var destLck = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.ReadWrite, System.Drawing.Imaging.PixelFormat.Format24bppRgb); - int error_r = 0; - - - int sourceBytes = Math.Abs(sourceLck.Stride) * sourceLck.Height; - int destBytes = Math.Abs(destLck.Stride) * destLck.Height; - - IntPtr sourcePtr = sourceLck.Scan0; - IntPtr destPtr = destLck.Scan0; - - byte[] destArr = new byte[destBytes]; - byte[] sourceArr = new byte[sourceBytes]; - - byte[] grays = new byte[destBytes]; - - Marshal.Copy(sourcePtr, sourceArr, 0, sourceBytes); - Marshal.Copy(destPtr, destArr, 0, destBytes); - - int width = Math.Abs(destLck.Stride); - int height = destLck.Height; - - bool sixteenBits = Shiftorium.UpgradeInstalled("color_depth_16_bits"); - bool twoBits = Shiftorium.UpgradeInstalled("color_depth_2_bits"); - bool sixBits = Shiftorium.UpgradeInstalled("color_depth_6_bits"); - bool fourBits = Shiftorium.UpgradeInstalled("color_depth_4_bits"); - bool eightBits = Shiftorium.UpgradeInstalled("color_depth_8_bits"); - bool color_depth_floydsteinberg = Shiftorium.UpgradeInstalled("color_depth_floyd-steinberg_dithering"); - bool dithering = Shiftorium.UpgradeInstalled("color_depth_dithering"); - - for (int y = 0; y < (destLck.Height); y++) - { - for (int x = 0; x < (Math.Abs(destLck.Stride)); x += 3) - { - int i = getIndexFromXY(x, y, width); - byte red = sourceArr[i]; - byte green = sourceArr[i + 1]; - byte blue = sourceArr[i + 2]; - - Color oldc = Color.FromArgb(red, green, blue); - Color newc; - - if (sixteenBits) - { - newc = GetColor(oldc); - } - else - { - int gray = ((oldc.R + oldc.G + oldc.B) / 3); - - byte newgray = 0; - - if (dithering && !color_depth_floydsteinberg) - gray += error_r; - - - - if (eightBits) - { - newgray = (byte)gray; - error_r = 0; - } - else if(sixBits) - { - newgray = (byte)(linear(gray, 0, 0xFF, 0, 0x3F) * 3); - error_r = newgray - gray; - } - else if (fourBits) - { - newgray = (byte)(linear(gray, 0, 0xFF, 0, 0xF) * 0xF); - error_r = newgray - gray; - } - else if (twoBits) - { - if (gray >= 191) - newgray = 0xFF; - else if (gray >= 127) - newgray = Color.LightGray.R; - else if (gray >= 64) - newgray = Color.DarkGray.R; - else - newgray = 0x00; - error_r = newgray - gray; - } - else - { - if (gray >= 127) - newgray = 0xFF; - else - newgray = 0x00; - error_r = newgray - gray; - } - newc = Color.FromArgb(newgray, newgray, newgray); - } - - int nextIndex = getIndexFromXY(x + 3, y, width); - int nextRow = getIndexFromXY(x, y + 1, width); - int nextIndexOnNextRow = getIndexFromXY(x + 3, y + 1, width); - int prevIndexOnNextRow = getIndexFromXY(x - 3, y + 1, width); - - grays[i] = newc.R; - grays[i + 1] = newc.G; - grays[i + 2] = newc.B; - - if (dithering) - { - if (color_depth_floydsteinberg) - { - if (x + 3 < width) - { - sourceArr[nextIndex] += (byte)((error_r * 7) / 16); - sourceArr[nextIndex + 1] += (byte)((error_r * 7) / 16); - sourceArr[nextIndex + 2] += (byte)((error_r * 7) / 16); - } - if (y + 1 < height) - { - sourceArr[nextRow] += (byte)((error_r) / 16); - sourceArr[nextRow + 1] += (byte)((error_r) / 16); - sourceArr[nextRow + 2] += (byte)((error_r) / 16); - } - if (x + 3 < width && y + 1 < height) - { - sourceArr[nextIndexOnNextRow] += (byte)((error_r * 3) / 16); - sourceArr[nextIndexOnNextRow + 1] += (byte)((error_r * 3) / 16); - sourceArr[nextIndexOnNextRow + 2] += (byte)((error_r * 3) / 16); - - } - if (x - 3 > 0 && y + 1 < height) - { - sourceArr[prevIndexOnNextRow] += (byte)((error_r * 5) / 16); - sourceArr[prevIndexOnNextRow + 1] += (byte)((error_r * 5) / 16); - sourceArr[prevIndexOnNextRow + 2] += (byte)((error_r * 5) / 16); - - } - } - } - } - } - - for (int i = 0; i < destArr.Length - 3; i++) - { - destArr[i] = grays[i]; - - } - - Marshal.Copy(destArr, 0, destPtr, destBytes); - - - bmp.UnlockBits(destLck); - - - - Desktop.InvokeOnWorkerThread(new Action(() => { result?.Invoke(bmp); })); - - } -#endif - - private static int getIndexFromXY(int x, int y, int width) - { - return (width * y) + x; - } - } -} diff --git a/ShiftOS.WinForms/WinformsDesktop.Designer.cs b/ShiftOS.WinForms/WinformsDesktop.Designer.cs deleted file mode 100644 index 71ef161..0000000 --- a/ShiftOS.WinForms/WinformsDesktop.Designer.cs +++ /dev/null @@ -1,312 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -namespace ShiftOS.WinForms -{ - partial class WinformsDesktop - { - /// - /// 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.desktoppanel = new System.Windows.Forms.Panel(); - this.btnnotifications = new System.Windows.Forms.Button(); - this.lbtime = new System.Windows.Forms.Label(); - this.panelbuttonholder = new System.Windows.Forms.FlowLayoutPanel(); - this.sysmenuholder = new System.Windows.Forms.Panel(); - this.menuStrip1 = new System.Windows.Forms.MenuStrip(); - this.apps = new System.Windows.Forms.ToolStripMenuItem(); - this.pnlscreensaver = new System.Windows.Forms.Panel(); - this.pnlwidgetlayer = new System.Windows.Forms.Panel(); - this.pnlssicon = new System.Windows.Forms.Panel(); - this.pnladvancedal = new System.Windows.Forms.Panel(); - this.flapps = new System.Windows.Forms.FlowLayoutPanel(); - this.flcategories = new System.Windows.Forms.FlowLayoutPanel(); - this.pnlalsystemactions = new System.Windows.Forms.Panel(); - this.btnshutdown = new System.Windows.Forms.Button(); - this.pnlstatus = new System.Windows.Forms.Panel(); - this.lbalstatus = new System.Windows.Forms.Label(); - this.desktoppanel.SuspendLayout(); - this.sysmenuholder.SuspendLayout(); - this.menuStrip1.SuspendLayout(); - this.pnlscreensaver.SuspendLayout(); - this.pnladvancedal.SuspendLayout(); - this.pnlalsystemactions.SuspendLayout(); - this.pnlstatus.SuspendLayout(); - this.SuspendLayout(); - // - // desktoppanel - // - this.desktoppanel.BackColor = System.Drawing.Color.Green; - this.desktoppanel.Controls.Add(this.btnnotifications); - this.desktoppanel.Controls.Add(this.lbtime); - this.desktoppanel.Controls.Add(this.panelbuttonholder); - this.desktoppanel.Controls.Add(this.sysmenuholder); - this.desktoppanel.Dock = System.Windows.Forms.DockStyle.Top; - this.desktoppanel.Location = new System.Drawing.Point(0, 0); - this.desktoppanel.Name = "desktoppanel"; - this.desktoppanel.Size = new System.Drawing.Size(1296, 24); - this.desktoppanel.TabIndex = 0; - this.desktoppanel.Paint += new System.Windows.Forms.PaintEventHandler(this.desktoppanel_Paint); - // - // btnnotifications - // - this.btnnotifications.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.btnnotifications.AutoSize = true; - this.btnnotifications.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.btnnotifications.BackColor = System.Drawing.Color.Transparent; - this.btnnotifications.FlatAppearance.BorderSize = 0; - this.btnnotifications.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btnnotifications.Location = new System.Drawing.Point(1066, -2); - this.btnnotifications.Name = "btnnotifications"; - this.btnnotifications.Size = new System.Drawing.Size(136, 24); - this.btnnotifications.TabIndex = 3; - this.btnnotifications.Text = "Notifications (0)"; - this.btnnotifications.UseVisualStyleBackColor = false; - this.btnnotifications.Click += new System.EventHandler(this.btnnotifications_Click); - // - // lbtime - // - this.lbtime.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Right))); - this.lbtime.AutoSize = true; - this.lbtime.Location = new System.Drawing.Point(3, 0); - this.lbtime.Name = "lbtime"; - this.lbtime.Size = new System.Drawing.Size(49, 14); - this.lbtime.TabIndex = 0; - this.lbtime.Text = "label1"; - this.lbtime.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - this.lbtime.Click += new System.EventHandler(this.lbtime_Click); - // - // panelbuttonholder - // - this.panelbuttonholder.AutoSize = true; - this.panelbuttonholder.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.panelbuttonholder.Location = new System.Drawing.Point(107, -77); - this.panelbuttonholder.Name = "panelbuttonholder"; - this.panelbuttonholder.Size = new System.Drawing.Size(0, 0); - this.panelbuttonholder.TabIndex = 2; - // - // sysmenuholder - // - this.sysmenuholder.Controls.Add(this.menuStrip1); - this.sysmenuholder.Location = new System.Drawing.Point(12, 5); - this.sysmenuholder.Name = "sysmenuholder"; - this.sysmenuholder.Size = new System.Drawing.Size(68, 24); - this.sysmenuholder.TabIndex = 1; - // - // menuStrip1 - // - this.menuStrip1.Dock = System.Windows.Forms.DockStyle.Fill; - this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.apps}); - this.menuStrip1.Location = new System.Drawing.Point(0, 0); - this.menuStrip1.Name = "menuStrip1"; - this.menuStrip1.Padding = new System.Windows.Forms.Padding(0); - this.menuStrip1.Size = new System.Drawing.Size(68, 24); - this.menuStrip1.TabIndex = 0; - this.menuStrip1.Text = "menuStrip1"; - // - // apps - // - this.apps.AutoSize = false; - this.apps.Name = "apps"; - this.apps.Padding = new System.Windows.Forms.Padding(0); - this.apps.Size = new System.Drawing.Size(58, 20); - this.apps.Tag = "applauncherbutton"; - this.apps.Text = "ShiftOS"; - this.apps.Click += new System.EventHandler(this.apps_Click); - // - // pnlscreensaver - // - this.pnlscreensaver.Controls.Add(this.pnlssicon); - this.pnlscreensaver.Dock = System.Windows.Forms.DockStyle.Fill; - this.pnlscreensaver.Location = new System.Drawing.Point(0, 24); - this.pnlscreensaver.Name = "pnlscreensaver"; - this.pnlscreensaver.Size = new System.Drawing.Size(1296, 714); - this.pnlscreensaver.TabIndex = 1; - this.pnlscreensaver.Visible = false; - // - // pnlwidgetlayer - // - this.pnlwidgetlayer.BackColor = System.Drawing.Color.Transparent; - this.pnlwidgetlayer.Dock = System.Windows.Forms.DockStyle.Fill; - this.pnlwidgetlayer.Location = new System.Drawing.Point(0, 24); - this.pnlwidgetlayer.Name = "pnlwidgetlayer"; - this.pnlwidgetlayer.Size = new System.Drawing.Size(1296, 714); - this.pnlwidgetlayer.TabIndex = 1; - // - // pnlssicon - // - this.pnlssicon.Location = new System.Drawing.Point(303, 495); - this.pnlssicon.Name = "pnlssicon"; - this.pnlssicon.Size = new System.Drawing.Size(200, 100); - this.pnlssicon.TabIndex = 0; - // - // pnladvancedal - // - this.pnladvancedal.Controls.Add(this.flapps); - this.pnladvancedal.Controls.Add(this.flcategories); - this.pnladvancedal.Controls.Add(this.pnlalsystemactions); - this.pnladvancedal.Controls.Add(this.pnlstatus); - this.pnladvancedal.Location = new System.Drawing.Point(0, 24); - this.pnladvancedal.Name = "pnladvancedal"; - this.pnladvancedal.Size = new System.Drawing.Size(433, 417); - this.pnladvancedal.TabIndex = 1; - this.pnladvancedal.Visible = false; - // - // flapps - // - this.flapps.Dock = System.Windows.Forms.DockStyle.Fill; - this.flapps.Location = new System.Drawing.Point(221, 58); - this.flapps.Name = "flapps"; - this.flapps.Size = new System.Drawing.Size(212, 328); - this.flapps.TabIndex = 3; - // - // flcategories - // - this.flcategories.Dock = System.Windows.Forms.DockStyle.Left; - this.flcategories.Location = new System.Drawing.Point(0, 58); - this.flcategories.Name = "flcategories"; - this.flcategories.Size = new System.Drawing.Size(221, 328); - this.flcategories.TabIndex = 2; - // - // pnlalsystemactions - // - this.pnlalsystemactions.Controls.Add(this.btnshutdown); - this.pnlalsystemactions.Dock = System.Windows.Forms.DockStyle.Bottom; - this.pnlalsystemactions.Location = new System.Drawing.Point(0, 386); - this.pnlalsystemactions.Name = "pnlalsystemactions"; - this.pnlalsystemactions.Size = new System.Drawing.Size(433, 31); - this.pnlalsystemactions.TabIndex = 1; - // - // btnshutdown - // - this.btnshutdown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.btnshutdown.AutoSize = true; - this.btnshutdown.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.btnshutdown.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btnshutdown.Location = new System.Drawing.Point(355, 3); - this.btnshutdown.Name = "btnshutdown"; - this.btnshutdown.Size = new System.Drawing.Size(75, 26); - this.btnshutdown.TabIndex = 0; - this.btnshutdown.Text = "Shutdown"; - this.btnshutdown.UseVisualStyleBackColor = true; - this.btnshutdown.Click += new System.EventHandler(this.btnshutdown_Click); - // - // pnlstatus - // - this.pnlstatus.Controls.Add(this.lbalstatus); - this.pnlstatus.Dock = System.Windows.Forms.DockStyle.Top; - this.pnlstatus.Location = new System.Drawing.Point(0, 0); - this.pnlstatus.Name = "pnlstatus"; - this.pnlstatus.Size = new System.Drawing.Size(433, 58); - this.pnlstatus.TabIndex = 0; - // - // lbalstatus - // - this.lbalstatus.Dock = System.Windows.Forms.DockStyle.Fill; - this.lbalstatus.Location = new System.Drawing.Point(0, 0); - this.lbalstatus.Name = "lbalstatus"; - this.lbalstatus.Size = new System.Drawing.Size(433, 58); - this.lbalstatus.TabIndex = 0; - this.lbalstatus.Text = "michael@system\r\n0 Codepoints\r\n0 installed, 0 available"; - this.lbalstatus.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // WinformsDesktop - // - this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 14F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.Black; - this.ClientSize = new System.Drawing.Size(1296, 738); - this.Controls.Add(this.pnlwidgetlayer); - this.Controls.Add(this.pnladvancedal); - this.Controls.Add(this.pnlscreensaver); - this.Controls.Add(this.desktoppanel); - this.Font = new System.Drawing.Font("Consolas", 9F); - this.ForeColor = System.Drawing.Color.LightGreen; - this.MainMenuStrip = this.menuStrip1; - this.Name = "WinformsDesktop"; - this.Text = "Desktop"; - this.Load += new System.EventHandler(this.Desktop_Load); - this.desktoppanel.ResumeLayout(false); - this.desktoppanel.PerformLayout(); - this.sysmenuholder.ResumeLayout(false); - this.sysmenuholder.PerformLayout(); - this.menuStrip1.ResumeLayout(false); - this.menuStrip1.PerformLayout(); - this.pnlscreensaver.ResumeLayout(false); - this.pnladvancedal.ResumeLayout(false); - this.pnlalsystemactions.ResumeLayout(false); - this.pnlalsystemactions.PerformLayout(); - this.pnlstatus.ResumeLayout(false); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.Panel desktoppanel; - private System.Windows.Forms.Label lbtime; - private System.Windows.Forms.Panel sysmenuholder; - private System.Windows.Forms.MenuStrip menuStrip1; - private System.Windows.Forms.ToolStripMenuItem apps; - private System.Windows.Forms.FlowLayoutPanel panelbuttonholder; - private System.Windows.Forms.Button btnnotifications; - private System.Windows.Forms.Panel pnlscreensaver; - private System.Windows.Forms.Panel pnlssicon; - private System.Windows.Forms.Panel pnladvancedal; - private System.Windows.Forms.Panel pnlalsystemactions; - private System.Windows.Forms.Button btnshutdown; - private System.Windows.Forms.Panel pnlstatus; - private System.Windows.Forms.Label lbalstatus; - private System.Windows.Forms.FlowLayoutPanel flapps; - private System.Windows.Forms.FlowLayoutPanel flcategories; - private System.Windows.Forms.Panel pnlwidgetlayer; - } - -} - diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs deleted file mode 100644 index 6825f34..0000000 --- a/ShiftOS.WinForms/WinformsDesktop.cs +++ /dev/null @@ -1,1066 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -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; -using ShiftOS.Engine; -using static ShiftOS.Engine.SkinEngine; -using ShiftOS.WinForms.Tools; -using ShiftOS.WinForms.Applications; -using Newtonsoft.Json; -using ShiftOS.Engine.Scripting; -using System.Threading; - -/// -/// Winforms desktop. -/// -namespace ShiftOS.WinForms -{ - /// - /// Winforms desktop. - /// - public partial class WinformsDesktop : Form, IDesktop - { - public List Widgets = new List(); - - - private int millisecondsUntilScreensaver = 300000; - - /// - /// Initializes a new instance of the class. - /// - public WinformsDesktop() - { - InitializeComponent(); - pnlwidgetlayer.Click += (o, a) => - { - HideAppLauncher(); - }; - ControlManager.MakeDoubleBuffered(pnlwidgetlayer); - this.Click += (o, a) => - { - HideAppLauncher(); - }; - SetupControl(desktoppanel); - Shiftorium.Installed += () => - { - foreach(var widget in Widgets) - { - widget.OnUpgrade(); - } - - //Only if the DevX Legions story hasn't been experienced yet. - if (!Shiftorium.UpgradeInstalled("devx_legions")) - { - //Check for shiftnet story experience - if (Shiftorium.UpgradeInstalled("shiftnet")) - { - //Check for saturation of the "GUI" upgrade set - if (Shiftorium.IsCategoryEmptied("GUI")) - { - //Start the MUD Control Centre story. - Story.Start("devx_legions"); - } - } - } - - if (!Shiftorium.UpgradeInstalled("victortran_shiftnet")) - { - if (SaveSystem.CurrentSave.Codepoints >= 50000) - { - if (Shiftorium.IsCategoryEmptied("Applications")) - { - Story.Start("victortran_shiftnet"); - } - } - } - }; - this.TopMost = false; - - NotificationDaemon.NotificationMade += (note) => - { - //Soon this will pop a balloon note. - this.Invoke(new Action(() => - { - btnnotifications.Text = Localization.Parse("{NOTIFICATIONS} (" + NotificationDaemon.GetUnreadCount().ToString() + ")"); - })); - }; - - NotificationDaemon.NotificationRead += () => - { - //Soon this will pop a balloon note. - this.Invoke(new Action(() => - { - btnnotifications.Text = Localization.Parse("{NOTIFICATIONS} (" + NotificationDaemon.GetUnreadCount().ToString() + ")"); - })); - }; - - this.LocationChanged += (o, a) => - { - if (this.Left != 0) - this.Left = 0; - if (this.Top != 0) - this.Top = 0; - }; - - this.SizeChanged += (o, a) => - { - if (this.ClientRectangle != Screen.PrimaryScreen.Bounds) - { - this.WindowState = FormWindowState.Maximized; - } - }; - - SaveSystem.GameReady += () => - { - if (this.Visible == true) - this.Invoke(new Action(() => SetupDesktop())); - this.Invoke(new Action(() => - { - btnnotifications.Text = Localization.Parse("{NOTIFICATIONS} (" + NotificationDaemon.GetUnreadCount().ToString() + ")"); - })); - }; - Shiftorium.Installed += () => - { - if (this.Visible == true) - this.Invoke(new Action(() => SetupDesktop())); - }; - var time = new System.Windows.Forms.Timer(); - time.Interval = 100; - this.KeyDown += (o, a) => - { - if (a.Control && a.KeyCode == Keys.T) - { - Engine.AppearanceManager.SetupWindow(new Applications.Terminal()); - } - /*if (a.Control && a.KeyCode == Keys.Tab) - { - // CtrlTabMenu - CtrlTabMenu.Show(); - if (a.Shift) CtrlTabMenu.CycleBack(); - else CtrlTabMenu.CycleForwards(); - }*/ //nyi - - ShiftOS.Engine.Scripting.LuaInterpreter.RaiseEvent("on_key_down", a); - }; - SkinEngine.SkinLoaded += () => - { - foreach (var widget in Widgets) - { - widget.OnSkinLoad(); - } - - SetupDesktop(); - }; - time.Tick += (o, a) => - { - if (Shiftorium.IsInitiated == true) - { - if (SaveSystem.CurrentSave != null && TutorialManager.IsInTutorial == false) - { - lbtime.Text = Applications.Terminal.GetTime(); - lbtime.Left = desktoppanel.Width - lbtime.Width - LoadedSkin.DesktopPanelClockFromRight.X; - lbtime.Top = LoadedSkin.DesktopPanelClockFromRight.Y; - } - } - - try - { - if (SaveSystem.CurrentSave != null) - { - if (SaveSystem.CurrentSave.LastMonthPaid != DateTime.Now.Month) - { - if (SaveSystem.CurrentSave.Codepoints >= DownloadManager.GetAllSubscriptions()[SaveSystem.CurrentSave.ShiftnetSubscription].CostPerMonth) - { - SaveSystem.CurrentSave.Codepoints -= DownloadManager.GetAllSubscriptions()[SaveSystem.CurrentSave.ShiftnetSubscription].CostPerMonth; - SaveSystem.CurrentSave.LastMonthPaid = DateTime.Now.Month; - } - else - { - SaveSystem.CurrentSave.ShiftnetSubscription = 0; - SaveSystem.CurrentSave.LastMonthPaid = DateTime.Now.Month; - Infobox.Show("Shiftnet", "You do not have enough Codepoints to pay for your Shiftnet subscription this month. You have been downgraded to the free plan."); - } - } - } - } - catch { } - - - btnnotifications.Left = lbtime.Left - btnnotifications.Width - 2; - btnnotifications.Top = (desktoppanel.Height - btnnotifications.Height) / 2; - }; - time.Start(); - - var ssThread = new Thread(() => - { - while(this.Visible == true) - { - var mousePos = Cursor.Position; - while(Cursor.Position == mousePos) - { - if(millisecondsUntilScreensaver <= 0) - { - ShowScreensaver(); - } - millisecondsUntilScreensaver--; - Thread.Sleep(1); - } - millisecondsUntilScreensaver = 300000; - HideScreensaver(); - } - }); - ssThread.IsBackground = true; - ssThread.Start(); - - this.DoubleBuffered = true; - } - - public void HideScreensaver() - { - if (ResetDesktop == true) - { - this.Invoke(new Action(() => - { - this.TopMost = false; - pnlscreensaver.Hide(); - Cursor.Show(); - SetupDesktop(); - ResetDesktop = false; - - })); - } - } - - private bool ResetDesktop = false; - - private void ShowScreensaver() - { - } - - - /// - /// Populates the panel buttons. - /// - /// The panel buttons. - public void PopulatePanelButtons() - { - if (DesktopFunctions.ShowDefaultElements == true) - { - panelbuttonholder.Controls.Clear(); - if (Shiftorium.IsInitiated == true) - { - if (Shiftorium.UpgradeInstalled("wm_panel_buttons")) - { - foreach (WindowBorder form in Engine.AppearanceManager.OpenForms) - { - if (form != null) - { - if (form.Visible == true) - { - EventHandler onClick = (o, a) => - { - if (form == focused) - { - if (form.IsMinimized) - { - RestoreWindow(form); - } - else - { - MinimizeWindow(form); - } - } - else - { - form.BringToFront(); - focused = form; - } - HideAppLauncher(); - }; - - var pnlbtn = new Panel(); - pnlbtn.Margin = new Padding(2, LoadedSkin.PanelButtonFromTop, 0, 0); - pnlbtn.BackColor = LoadedSkin.PanelButtonColor; - pnlbtn.BackgroundImage = GetImage("panelbutton"); - pnlbtn.BackgroundImageLayout = GetImageLayout("panelbutton"); - - var pnlbtntext = new Label(); - pnlbtntext.Text = NameChangerBackend.GetName(form.ParentWindow); - pnlbtntext.AutoSize = true; - pnlbtntext.Location = LoadedSkin.PanelButtonFromLeft; - pnlbtntext.ForeColor = LoadedSkin.PanelButtonTextColor; - pnlbtntext.BackColor = Color.Transparent; - - pnlbtn.BackColor = LoadedSkin.PanelButtonColor; - if (pnlbtn.BackgroundImage != null) - { - pnlbtntext.BackColor = Color.Transparent; - } - pnlbtn.Size = LoadedSkin.PanelButtonSize; - pnlbtn.Tag = "keepbg"; - pnlbtntext.Tag = "keepbg"; - pnlbtn.Controls.Add(pnlbtntext); - this.panelbuttonholder.Controls.Add(pnlbtn); - pnlbtn.Show(); - pnlbtntext.Show(); - - if (Shiftorium.UpgradeInstalled("useful_panel_buttons")) - { - pnlbtn.Click += onClick; - pnlbtntext.Click += onClick; - } - pnlbtntext.Font = LoadedSkin.PanelButtonFont; - - } - } - } - } - } - } - - LuaInterpreter.RaiseEvent("on_panelbutton_populate", this); - } - - /// - /// Setups the desktop. - /// - /// The desktop. - public void SetupDesktop() - { - if (DesktopFunctions.ShowDefaultElements == true) - { - ToolStripManager.Renderer = new ShiftOSMenuRenderer(); - - this.DoubleBuffered = true; - this.FormBorderStyle = FormBorderStyle.None; - this.WindowState = FormWindowState.Maximized; - desktoppanel.BackColor = Color.Green; - - //upgrades - - if (Shiftorium.IsInitiated == true) - { - desktoppanel.Visible = Shiftorium.UpgradeInstalled("desktop"); - lbtime.Visible = Shiftorium.UpgradeInstalled("desktop_clock_widget"); - - btnnotifications.Visible = Shiftorium.UpgradeInstalled("panel_notifications"); - - //skinning - lbtime.ForeColor = LoadedSkin.DesktopPanelClockColor; - - panelbuttonholder.Top = 0; - panelbuttonholder.Left = LoadedSkin.PanelButtonHolderFromLeft; - panelbuttonholder.Height = desktoppanel.Height; - panelbuttonholder.BackColor = Color.Transparent; - panelbuttonholder.Margin = new Padding(0, 0, 0, 0); - - sysmenuholder.Visible = Shiftorium.UpgradeInstalled("app_launcher"); - - //The Color Picker can give us transparent colors - which Windows Forms fucking despises when dealing with form backgrounds. - //To compensate, we must recreate the desktop color and make the alpha channel '255'. - this.BackColor = Color.FromArgb(LoadedSkin.DesktopColor.R, LoadedSkin.DesktopColor.G, LoadedSkin.DesktopColor.B); - //Not doing this will cause an ArgumentException. - - DitheringEngine.DitherImage(SkinEngine.GetImage("desktopbackground"), new Action((img) => - { - this.BackgroundImage = img; - })); - this.BackgroundImageLayout = GetImageLayout("desktopbackground"); - desktoppanel.BackColor = LoadedSkin.DesktopPanelColor; - - var pnlimg = GetImage("desktoppanel"); - if (pnlimg != null) - { - var bmp = new Bitmap(pnlimg); - bmp.MakeTransparent(Color.FromArgb(1, 0, 1)); - pnlimg = bmp; - } - - desktoppanel.BackgroundImage = pnlimg; - if (desktoppanel.BackgroundImage != null) - { - desktoppanel.BackColor = Color.Transparent; - } - var appimg = GetImage("applauncher"); - if (appimg != null) - { - var bmp = new Bitmap(appimg); - bmp.MakeTransparent(Color.FromArgb(1, 0, 1)); - appimg = bmp; - } - menuStrip1.BackgroundImage = appimg; - lbtime.ForeColor = LoadedSkin.DesktopPanelClockColor; - lbtime.Font = LoadedSkin.DesktopPanelClockFont; - if (desktoppanel.BackgroundImage == null) - { - lbtime.BackColor = LoadedSkin.DesktopPanelClockBackgroundColor; - } - else - { - lbtime.BackColor = Color.Transparent; - } - apps.Text = LoadedSkin.AppLauncherText; - sysmenuholder.Location = LoadedSkin.AppLauncherFromLeft; - sysmenuholder.Size = LoadedSkin.AppLauncherHolderSize; - apps.Size = sysmenuholder.Size; - menuStrip1.Renderer = new ShiftOSMenuRenderer(new AppLauncherColorTable()); - desktoppanel.BackgroundImageLayout = GetImageLayout("desktoppanel"); - desktoppanel.Height = LoadedSkin.DesktopPanelHeight; - if (LoadedSkin.DesktopPanelPosition == 1) - { - desktoppanel.Dock = DockStyle.Bottom; - } - else - { - desktoppanel.Dock = DockStyle.Top; - } - } - - pnlwidgetlayer.Show(); - pnlwidgetlayer.BringToFront(); - - if (Shiftorium.UpgradeInstalled("desktop_widgets")) - { - Widgets.Clear(); - pnlwidgetlayer.Controls.Clear(); - foreach(var widget in WidgetManager.GetAllWidgetTypes()) - { - UserControl w = (UserControl)Activator.CreateInstance(widget.Value, null); - - w.Location = WidgetManager.LoadDetails(w.GetType()).Location; - pnlwidgetlayer.Controls.Add(w); - MakeWidgetMovable(w); - Widgets.Add(w as IDesktopWidget); - } - } - - int lastHeight = 5; - foreach (var widget in Widgets) - { - if (WidgetManager.LoadDetails(widget.GetType()).IsVisible && Shiftorium.UpgradeInstalled("desktop_widgets")) - { - widget.OnSkinLoad(); - - widget.OnUpgrade(); - widget.Setup(); - widget.Show(); - if (widget.Location.X == -1 && widget.Location.Y == -1) - { - widget.Location = new Point(5, lastHeight); - lastHeight += widget.Size.Height + 5; - } - } - else - { - widget.Hide(); - } - } - pnlwidgetlayer.Show(); - pnlwidgetlayer.BringToFront(); - - - } - else - { - desktoppanel.Hide(); - } - - LuaInterpreter.RaiseEvent("on_desktop_skin", this); - - PopulatePanelButtons(); - } - - public void MakeWidgetMovable(Control w, Control startCtrl = null) - { - if (startCtrl == null) - startCtrl = w; - - bool moving = false; - - w.MouseDown += (o, a) => - { - HideAppLauncher(); - moving = true; - }; - - w.MouseMove += (o, a) => - { - if (moving == true) - { - var mPos = Cursor.Position; - int mY = mPos.Y - desktoppanel.Height; - int mX = mPos.X; - - int ctrlHeight = startCtrl.Height / 2; - int ctrlWidth = startCtrl.Width / 2; - - startCtrl.Location = new Point( - mX - ctrlWidth, - mY - ctrlHeight - ); - - } - }; - - w.MouseUp += (o, a) => - { - moving = false; - var details = WidgetManager.LoadDetails(startCtrl.GetType()); - details.Location = startCtrl.Location; - WidgetManager.SaveDetails(startCtrl.GetType(), details); - }; - - foreach (Control c in w.Controls) - MakeWidgetMovable(c, startCtrl); - - } - - public ToolStripMenuItem GetALCategoryWithName(string text) - { - foreach (ToolStripMenuItem menuitem in apps.DropDownItems) - { - if (menuitem.Text == text) - return menuitem; - } - - var itm = new ToolStripMenuItem(); - itm.Text = text; - apps.DropDownItems.Add(itm); - return itm; - } - - public Dictionary> LauncherItemList = new Dictionary>(); - - /// - /// Populates the app launcher. - /// - /// The app launcher. - /// Items. - public void PopulateAppLauncher(LauncherItem[] items) - { - if (Shiftorium.UpgradeInstalled("advanced_app_launcher")) - { - pnladvancedal.Visible = false; - flapps.BackColor = LoadedSkin.Menu_ToolStripDropDownBackground; - flcategories.BackColor = LoadedSkin.Menu_ToolStripDropDownBackground; - pnlalsystemactions.BackColor = LoadedSkin.SystemPanelBackground; - lbalstatus.BackColor = LoadedSkin.ALStatusPanelBackColor; - //Fonts - lbalstatus.Font = LoadedSkin.ALStatusPanelFont; - lbalstatus.ForeColor = LoadedSkin.ALStatusPanelTextColor; - btnshutdown.Font = LoadedSkin.ShutdownFont; - - //Upgrades - btnshutdown.Visible = Shiftorium.UpgradeInstalled("al_shutdown"); - - //Alignments and positions. - lbalstatus.TextAlign = LoadedSkin.ALStatusPanelAlignment; - if (LoadedSkin.ShutdownButtonStyle == 2) - btnshutdown.Hide(); - else if (LoadedSkin.ShutdownButtonStyle == 1) - { - btnshutdown.Parent = pnlstatus; - btnshutdown.BringToFront(); - } - else - btnshutdown.Parent = pnlalsystemactions; - if (LoadedSkin.ShutdownOnLeft) - { - btnshutdown.Location = LoadedSkin.ShutdownButtonFromSide; - } - else - { - btnshutdown.Left = (btnshutdown.Parent.Width - btnshutdown.Width) - LoadedSkin.ShutdownButtonFromSide.X; - btnshutdown.Top = LoadedSkin.ShutdownButtonFromSide.Y; - } - - //Images - lbalstatus.BackgroundImage = GetImage("al_bg_status"); - lbalstatus.BackgroundImageLayout = GetImageLayout("al_bg_status"); - - pnlalsystemactions.BackgroundImage = GetImage("al_bg_system"); - pnlalsystemactions.BackgroundImageLayout = GetImageLayout("al_bg_system"); - if (pnlalsystemactions.BackgroundImage != null) - btnshutdown.BackColor = Color.Transparent; - - btnshutdown.Font = LoadedSkin.ShutdownFont; - btnshutdown.ForeColor = LoadedSkin.ShutdownForeColor; - - pnladvancedal.Size = LoadedSkin.AALSize; - - pnlalsystemactions.Height = LoadedSkin.ALSystemActionHeight; - pnlstatus.Height = LoadedSkin.ALSystemStatusHeight; - - flcategories.Width = LoadedSkin.AALCategoryViewWidth; - this.flapps.Width = LoadedSkin.AALItemViewWidth; - } - - - if (DesktopFunctions.ShowDefaultElements == true) - { - apps.DropDownItems.Clear(); - - Dictionary> sortedItems = new Dictionary>(); - - flcategories.Controls.Clear(); - - LauncherItemList.Clear(); - - - foreach (var kv in items) - { - var item = new ToolStripMenuItem(); - item.Text = (kv.LaunchType == null) ? kv.DisplayData.Name : Applications.NameChangerBackend.GetNameRaw(kv.LaunchType); - item.Image = (kv.LaunchType == null) ? null : SkinEngine.GetIcon(kv.LaunchType.Name); - item.Click += (o, a) => - { - if (kv is LuaLauncherItem) - { - var interpreter = new Engine.Scripting.LuaInterpreter(); - interpreter.ExecuteFile((kv as LuaLauncherItem).LaunchPath); - } - else - { - Engine.AppearanceManager.SetupWindow(Activator.CreateInstance(kv.LaunchType) as IShiftOSWindow); - } - - }; - if (sortedItems.ContainsKey(kv.DisplayData.Category)) - { - sortedItems[kv.DisplayData.Category].Add(item); - LauncherItemList[kv.DisplayData.Category].Add(kv); - } - else - { - sortedItems.Add(kv.DisplayData.Category, new List()); - sortedItems[kv.DisplayData.Category].Add(item); - LauncherItemList.Add(kv.DisplayData.Category, new List { kv }); - } - } - - foreach (var kv in sortedItems) - { - if (Shiftorium.IsInitiated == true) - { - if (Shiftorium.UpgradeInstalled("app_launcher_categories")) - { - var cat = GetALCategoryWithName(kv.Key); - foreach (var subItem in kv.Value) - { - cat.DropDownItems.Add(subItem); - } - if (Shiftorium.UpgradeInstalled("advanced_app_launcher")) - { - var catbtn = new Button(); - catbtn.Font = LoadedSkin.AdvALItemFont; - catbtn.FlatStyle = FlatStyle.Flat; - catbtn.FlatAppearance.BorderSize = 0; - catbtn.FlatAppearance.MouseOverBackColor = LoadedSkin.Menu_MenuItemSelected; - catbtn.FlatAppearance.MouseDownBackColor = LoadedSkin.Menu_MenuItemPressedGradientBegin; - catbtn.BackColor = LoadedSkin.Menu_ToolStripDropDownBackground; - catbtn.TextAlign = ContentAlignment.MiddleLeft; - catbtn.ForeColor = LoadedSkin.Menu_TextColor; - catbtn.MouseEnter += (o, a) => - { - catbtn.ForeColor = LoadedSkin.Menu_SelectedTextColor; - }; - catbtn.MouseLeave += (o, a) => - { - catbtn.ForeColor = LoadedSkin.Menu_TextColor; - }; - catbtn.Text = kv.Key; - catbtn.Width = flcategories.Width; - catbtn.Height = 24; - flcategories.Controls.Add(catbtn); - catbtn.Show(); - catbtn.Click += (o, a) => SetupAdvancedCategory(catbtn.Text); - } - } - - else - { - foreach (var subItem in kv.Value) - { - apps.DropDownItems.Add(subItem); - } - } - } - } - - if (Shiftorium.IsInitiated == true) - { - if (Shiftorium.UpgradeInstalled("al_shutdown")) - { - apps.DropDownItems.Add(new ToolStripSeparator()); - var item = new ToolStripMenuItem(); - item.Text = Localization.Parse("{SHUTDOWN}"); - item.Click += (o, a) => - { - TerminalBackend.InvokeCommand("sos.shutdown"); - }; - apps.DropDownItems.Add(item); - if (Shiftorium.UpgradeInstalled("advanced_app_launcher")) - { - if (LoadedSkin.ShutdownButtonStyle == 2) { - var catbtn = new Button(); - catbtn.Font = LoadedSkin.AdvALItemFont; - catbtn.FlatStyle = FlatStyle.Flat; - catbtn.FlatAppearance.BorderSize = 0; - catbtn.FlatAppearance.MouseOverBackColor = LoadedSkin.Menu_MenuItemSelected; - catbtn.FlatAppearance.MouseDownBackColor = LoadedSkin.Menu_MenuItemPressedGradientBegin; - catbtn.BackColor = LoadedSkin.Menu_ToolStripDropDownBackground; - catbtn.ForeColor = LoadedSkin.Menu_TextColor; - catbtn.MouseEnter += (o, a) => - { - catbtn.ForeColor = LoadedSkin.Menu_SelectedTextColor; - }; - catbtn.MouseLeave += (o, a) => - { - catbtn.ForeColor = LoadedSkin.Menu_TextColor; - }; - - catbtn.TextAlign = ContentAlignment.MiddleLeft; - catbtn.Text = "Shutdown"; - catbtn.Width = flcategories.Width; - catbtn.Height = 24; - flcategories.Controls.Add(catbtn); - catbtn.Show(); - catbtn.Click += (o, a) => TerminalBackend.InvokeCommand("sos.shutdown"); - } - } - } - } - } - LuaInterpreter.RaiseEvent("on_al_populate", items); - } - - public void SetupAdvancedCategory(string cat) - { - flapps.Controls.Clear(); - - foreach(var app in LauncherItemList[cat]) - { - var catbtn = new Button(); - catbtn.Font = LoadedSkin.AdvALItemFont; - catbtn.FlatStyle = FlatStyle.Flat; - catbtn.FlatAppearance.BorderSize = 0; - catbtn.FlatAppearance.MouseOverBackColor = LoadedSkin.Menu_MenuItemSelected; - catbtn.FlatAppearance.MouseDownBackColor = LoadedSkin.Menu_MenuItemPressedGradientBegin; - catbtn.BackColor = LoadedSkin.Menu_ToolStripDropDownBackground; - catbtn.ForeColor = LoadedSkin.Menu_TextColor; - catbtn.MouseEnter += (o, a) => - { - catbtn.ForeColor = LoadedSkin.Menu_SelectedTextColor; - }; - catbtn.MouseLeave += (o, a) => - { - catbtn.ForeColor = LoadedSkin.Menu_TextColor; - }; - catbtn.TextAlign = ContentAlignment.MiddleLeft; - catbtn.Text = (app is LuaLauncherItem) ? app.DisplayData.Name : NameChangerBackend.GetNameRaw(app.LaunchType); - catbtn.Width = flapps.Width; - catbtn.ImageAlign = ContentAlignment.MiddleRight; - catbtn.Height = 24; - catbtn.Image = (app.LaunchType == null) ? null : SkinEngine.GetIcon(app.LaunchType.Name); - - flapps.Controls.Add(catbtn); - catbtn.Show(); - catbtn.Click += (o, a) => - { - pnladvancedal.Hide(); - if(app is LuaLauncherItem) - { - var interp = new LuaInterpreter(); - interp.ExecuteFile((app as LuaLauncherItem).LaunchPath); - } - else - { - IShiftOSWindow win = Activator.CreateInstance(app.LaunchType) as IShiftOSWindow; - AppearanceManager.SetupWindow(win); - } - - - - }; - - } - } - - /// - /// Desktops the load. - /// - /// The load. - /// Sender. - /// E. - private void Desktop_Load(object sender, EventArgs e) - { - - SaveSystem.Begin(); - - SetupDesktop(); - - SaveSystem.GameReady += () => - { - this.Invoke(new Action(() => - { - LuaInterpreter.RaiseEvent("on_desktop_load", this); - })); - }; - } - - /// - /// Shows the window. - /// - /// The window. - /// Border. - public void ShowWindow(IWindowBorder border) - { - var brdr = border as Form; - focused = border; - brdr.GotFocus += (o, a) => - { - focused = border; - }; - brdr.FormBorderStyle = FormBorderStyle.None; - brdr.Show(); - brdr.TopMost = true; - } - - /// - /// Kills the window. - /// - /// The window. - /// Border. - public void KillWindow(IWindowBorder border) - { - border.Close(); - } - - private IWindowBorder focused = null; - - public string DesktopName - { - get - { - return "ShiftOS Desktop"; - } - } - - - /// - /// Minimizes the window. - /// - /// Brdr. - public void MinimizeWindow(IWindowBorder brdr) - { - var loc = (brdr as WindowBorder).Location; - var sz = (brdr as WindowBorder).Size; - (brdr as WindowBorder).Tag = JsonConvert.SerializeObject(new - { - Size = sz, - Location = loc - }); - (brdr as WindowBorder).Location = new Point(this.GetSize().Width * 2, this.GetSize().Height * 2); - } - - /// - /// Maximizes the window. - /// - /// The window. - /// Brdr. - public void MaximizeWindow(IWindowBorder brdr) - { - int startY = (LoadedSkin.DesktopPanelPosition == 1) ? 0 : LoadedSkin.DesktopPanelHeight; - int h = this.GetSize().Height - LoadedSkin.DesktopPanelHeight; - var loc = (brdr as WindowBorder).Location; - var sz = (brdr as WindowBorder).Size; - (brdr as WindowBorder).Tag = JsonConvert.SerializeObject(new - { - Size = sz, - Location = loc - }); - (brdr as WindowBorder).Location = new Point(0, startY); - (brdr as WindowBorder).Size = new Size(this.GetSize().Width, h); - - } - - /// - /// Restores the window. - /// - /// The window. - /// Brdr. - public void RestoreWindow(IWindowBorder brdr) - { - dynamic tag = JsonConvert.DeserializeObject((brdr as WindowBorder).Tag.ToString()); - (brdr as WindowBorder).Location = tag.Location; - (brdr as WindowBorder).Size = tag.Size; - - } - - /// - /// Invokes the on worker thread. - /// - /// The on worker thread. - /// Act. - public void InvokeOnWorkerThread(Action act) - { - try - { - this.Invoke(new Action(() => - { - act?.Invoke(); - })); - } - catch - { - - } - } - - public void OpenAppLauncher(Point loc) - { - apps.DropDown.Left = loc.X; - apps.DropDown.Top = loc.Y; - apps.ShowDropDown(); - } - - /// - /// Gets the size. - /// - /// The size. - public Size GetSize() - { - return this.Size; - } - - private void btnnotifications_Click(object sender, EventArgs e) - { - AppearanceManager.SetupWindow(new Applications.Notifications()); - } - - private void desktoppanel_Paint(object sender, PaintEventArgs e) - { - e.Graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; - } - - private void lbtime_Click(object sender, EventArgs e) - { - } - - public void SetupControl(Control ctrl) - { - foreach (Control c in ctrl.Controls) - SetupControl(c); - ctrl.Click += (o, a) => HideAppLauncher(); - } - - private void apps_Click(object sender, EventArgs e) - { - if (Shiftorium.UpgradeInstalled("advanced_app_launcher")) - { - lbalstatus.Text = $@"{SaveSystem.CurrentUser.Username}@{SaveSystem.CurrentSave.SystemName} -{SaveSystem.CurrentSave.Codepoints} Codepoints -{Shiftorium.GetAvailable().Length} available, {SaveSystem.CurrentSave.CountUpgrades()} installed."; - - flapps.Controls.Clear(); - apps.DropDown.Hide(); - pnladvancedal.Location = new Point(0, (LoadedSkin.DesktopPanelPosition == 0) ? desktoppanel.Height : this.Height - pnladvancedal.Height - desktoppanel.Height); - pnladvancedal.Visible = !pnladvancedal.Visible; - pnladvancedal.BringToFront(); - } - - } - - private void btnshutdown_Click(object sender, EventArgs e) - { - TerminalBackend.InvokeCommand("sos.shutdown"); - } - - public void HideAppLauncher() - { - this.Invoke(new Action(() => - { - pnladvancedal.Hide(); - })); - } - } - - [ShiftOS.Engine.Scripting.Exposed("desktop")] - public class DesktopFunctions - { - public static bool ShowDefaultElements = true; - - public dynamic getWindow() - { - return Desktop.CurrentDesktop; - } - - public void showDefaultElements(bool val) - { - ShowDefaultElements = val; - SkinEngine.LoadSkin(); - } - - public dynamic getOpenWindows() - { - return AppearanceManager.OpenForms; - } - - public string getALItemName(LauncherItem kv) - { - return (kv.LaunchType == null) ? kv.DisplayData.Name : Applications.NameChangerBackend.GetNameRaw(kv.LaunchType); - } - - public void openAppLauncher(Point loc) - { - Desktop.OpenAppLauncher(loc); - } - - public string getWindowTitle(IWindowBorder form) - { - return NameChangerBackend.GetName(form.ParentWindow); - } - - public void openApp(LauncherItem kv) - { - if (kv is LuaLauncherItem) - { - var interpreter = new Engine.Scripting.LuaInterpreter(); - interpreter.ExecuteFile((kv as LuaLauncherItem).LaunchPath); - } - else - { - Engine.AppearanceManager.SetupWindow(Activator.CreateInstance(kv.LaunchType) as IShiftOSWindow); - } - } - } -} \ No newline at end of file diff --git a/ShiftOS_TheReturn/AppearanceManager.cs b/ShiftOS_TheReturn/AppearanceManager.cs deleted file mode 100644 index 4c1754e..0000000 --- a/ShiftOS_TheReturn/AppearanceManager.cs +++ /dev/null @@ -1,379 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#define MUD_RAPIDDEV - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Drawing; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; -using Newtonsoft.Json; -using static ShiftOS.Engine.SaveSystem; - -namespace ShiftOS.Engine -{ - /// - /// Provides functionality for managing windows within ShiftOS. - /// - public static class AppearanceManager - { - [Obsolete("Please use Localization.GetAllLanguages().")] - public static string[] GetLanguages() - { - return Localization.GetAllLanguages(); - } - - /// - /// Sets the title text of the specified window. - /// - /// The window to modify - /// The title text to use - /// Thrown if the window is null. - public static void SetWindowTitle(IShiftOSWindow window, string title) - { - if (window == null) - throw new ArgumentNullException("window", "The window cannot be null."); - winmgr.SetTitle(window, title); - } - - public static IEnumerable GetAllWindowTypes() - { - List types = new List(); - foreach(var file in System.IO.Directory.GetFiles(Environment.CurrentDirectory)) - { - if(file.EndsWith(".exe") || file.EndsWith(".dll")) - { - try - { - var asm = Assembly.LoadFile(file); - foreach(var type in asm.GetTypes()) - { - if (type.GetInterfaces().Contains(typeof(IShiftOSWindow))) - types.Add(type); - } - } - catch { } - } - } - return types; - } - - /// - /// Returns the default window title for a specified -inheriting type. - /// - /// The type to scan - /// The default title - /// Thrown if is null. - public static string GetDefaultTitle(Type winType) - { - if (winType == null) - throw new ArgumentNullException("winType"); - foreach(var attrib in winType.GetCustomAttributes(false)) - { - if(attrib is DefaultTitleAttribute) - { - return (attrib as DefaultTitleAttribute).Title; - } - } - return winType.Name; - } - - /// - /// Current cursor position of the console - /// - public static int CurrentPosition { get; set; } - - /// - /// We don't know what this does. It may be gone if it does nothing. - /// - public static int LastLength { get; set; } - - - /// - /// Minimize a window. - /// - /// The window border to minimize. - /// Thrown if is null. - /// Thrown if this part of the engine hasn't been enabled. - public static void Minimize(IWindowBorder form) - { - if (form == null) - throw new ArgumentNullException("form"); - if (winmgr == null) - throw new EngineModuleDisabledException(); - winmgr.Minimize(form); - } - - /// - /// Maximizes a window. - /// - /// The window border to maximize. - /// Thrown if is null. - /// Thrown if this engine module hasn't been enabled. - public static void Maximize(IWindowBorder form) - { - if (form == null) - throw new ArgumentNullException("form"); - if (winmgr == null) - throw new EngineModuleDisabledException(); - winmgr.Maximize(form); - } - - - /// - /// Provides a list of all open ShiftOS windows. - /// - public static List OpenForms = new List(); - - /// - /// Decorates a window with a border, then shows the window. - /// - /// The window to decorate and show. - /// Thrown if is null. - /// Thrown if this engine module has not been initiated yet. - public static void SetupWindow(IShiftOSWindow form) - { - if (form == null) - throw new ArgumentNullException("form"); - if (winmgr == null) - throw new EngineModuleDisabledException(); - winmgr.SetupWindow(form); - Desktop.ResetPanelButtons(); - } - - /// - /// Closes the specified window. - /// - /// The window to close. - /// Thrown if is null. - /// Thrown if this engine module has not been initiated yet. - public static void Close(IShiftOSWindow win) - { - if (win == null) - throw new ArgumentNullException("win"); - if (winmgr == null) - throw new EngineModuleDisabledException(); - winmgr.Close(win); - Desktop.ResetPanelButtons(); - } - - /// - /// Decorates a window with a border, then shows the window, as a dialog box. - /// - /// The window to decorate and show. - /// Thrown if is null. - /// Thrown if this engine module has not been initiated yet. - public static void SetupDialog(IShiftOSWindow form) - { - if (form == null) - throw new ArgumentNullException("form"); - if (winmgr == null) - throw new EngineModuleDisabledException(); - winmgr.SetupDialog(form); - Desktop.ResetPanelButtons(); - } - - /// - /// The underlying window manager for this engine module - /// - private static WindowManager winmgr = null; - - /// - /// Initiate this engine module, and perform mandatory configuration. - /// - /// A working, configured to use as a backend for this module - public static void Initiate(WindowManager mgr) - { - winmgr = mgr; - } - - /// - /// Raised when the engine is entering its shutdown phase. Save your work! - /// - public static event EmptyEventHandler OnExit; - - /// - /// Starts the engine's exit routine, firing the OnExit event. - /// - internal static void Exit() - { - OnExit?.Invoke(); - //disconnect from MUD - ServerManager.Disconnect(); - } - - /// - /// The current terminal body control. - /// - public static ITerminalWidget ConsoleOut { get; set; } - - /// - /// Redirects the .NET to a new instance. - /// - public static void StartConsoleOut() - { - Console.SetOut(new TerminalTextWriter()); - } - - /// - /// Invokes an action on the window management thread. - /// - /// The action to invoke - public static void Invoke(Action act) - { - winmgr.InvokeAction(act); - } - } - - /// - /// Provides the base functionality for a ShiftOS terminal. - /// - public interface ITerminalWidget - { - /// - /// Write text to this Terminal. - /// - /// Text to write - void Write(string text); - /// - /// Write text to this Terminal, followed by a newline. - /// - /// Text to write. - void WriteLine(string text); - /// - /// Clear the contents of this Terminal. - /// - void Clear(); - /// - /// Move the cursor to the last character in the Terminal. - /// - void SelectBottom(); - } - - /// - /// Provides the base functionality for a ShiftOS window manager. - /// - public abstract class WindowManager - { - /// - /// Minimizes a window - /// - /// The window border to minimize - public abstract void Minimize(IWindowBorder border); - - /// - /// Maximizes a window - /// - /// The window border to maximize - public abstract void Maximize(IWindowBorder border); - - /// - /// Closes a window - /// - /// The window to close - public abstract void Close(IShiftOSWindow win); - - /// - /// Decorates a window with a window border, then shows it to the user. - /// - /// The window to decorate. - public abstract void SetupWindow(IShiftOSWindow win); - - /// - /// Decorates a window with a border, then shows it to the user as a dialog box. - /// - /// The window to decorate - public abstract void SetupDialog(IShiftOSWindow win); - - /// - /// Invokes an action on the window management thread. - /// - /// The action to invoke. - public abstract void InvokeAction(Action act); - - /// - /// Sets the title text of a window. - /// - /// The window to modify. - /// The new title text. - public abstract void SetTitle(IShiftOSWindow win, string title); - } - - /// - /// Provides the base functionality for a typical ShiftOS window border. - /// - public interface IWindowBorder - { - /// - /// Closes the border along with its window. Unload events should be invoked here. - /// - void Close(); - - /// - /// Gets or sets the title text for the window border. - /// - string Text { get; set; } - - /// - /// Gets or sets the underlying for this border. - /// - IShiftOSWindow ParentWindow { get; set; } - } - - /// - /// Provides a way of setting default title text for classes. - /// - public class DefaultTitleAttribute : Attribute - { - /// - /// Creates a new instance of the . - /// - /// A default title to associate with this attribute. - public DefaultTitleAttribute(string title) - { - Title = title; - } - - public string Title { get; private set; } - } - - /// - /// An exception that is thrown when mandatory configuration to run a specific method or module hasn't been done yet. - /// - public class EngineModuleDisabledException : Exception - { - /// - /// Initializes a new instance of the . - /// - public EngineModuleDisabledException() : base("This engine module has not yet been enabled.") - { - - } - } -} diff --git a/ShiftOS_TheReturn/AudioManager.cs b/ShiftOS_TheReturn/AudioManager.cs deleted file mode 100644 index a636497..0000000 --- a/ShiftOS_TheReturn/AudioManager.cs +++ /dev/null @@ -1,134 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#define NOSOUND - -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using NAudio; -using NAudio.Wave; - -namespace ShiftOS.Engine -{ - public static class AudioManager - { - private static WaveOut _out = null; - private static AudioFileReader _reader = null; - private static IAudioProvider _provider = null; - - /// - /// Stops the current sound if one is playing and disposes of the sound. - /// - public static void Stop() - { - _out?.Stop(); - _reader?.Dispose(); - _out?.Dispose(); - } - - /// - /// Initiates this engine module using an as a backend for selecting background soundtrack as well as the volume level for the sound. - /// - /// A background soundtrack and volume provider. - /// Thrown if is null. - public static void Init(IAudioProvider _p) - { - if (_p == null) - throw new ArgumentNullException("_p"); - _provider = _p; - } - - /// - /// Sets the volume of the audio system. - /// - /// The volume to use, from 0 to 1. - public static void SetVolume(float volume) - { - _provider.Volume = volume; //persist between songs - _out.Volume = volume; - } - - /// - /// Plays a specified sound file. - /// - /// The file to play. - public static void Play(string file) - { - try - { - _reader = new AudioFileReader(file); - _out = new WaveOut(); - _out.Init(_reader); - _out.Volume = _provider.Volume; - _out.Play(); - _out.PlaybackStopped += (o, a) => { PlayCompleted?.Invoke(); }; - } - catch { } - } - - /// - /// Writes the data in the specified to a file, and plays it as a sound file. - /// - /// The stream to read from. - public static void PlayStream(Stream str) - { - var bytes = new byte[str.Length]; - str.Read(bytes, 0, bytes.Length); - ShiftOS.Engine.AudioManager.Stop(); - if (File.Exists("snd.wav")) - File.Delete("snd.wav"); - File.WriteAllBytes("snd.wav", bytes); - - ShiftOS.Engine.AudioManager.Play("snd.wav"); - - } - - public static event Action PlayCompleted; - } - - public interface IAudioProvider - { - /// - /// Gets a byte[] array corresponding to an MP3 track given an index. - /// - /// A track index to use when finding the right track. - /// The MP3 byte[] array. - byte[] GetTrack(int index); - - /// - /// Gets the 1-based count of all available tracks. - /// - int Count { get; } - - /// - /// Gets or sets the track player's volume. - /// - float Volume { get; set; } - } -} diff --git a/ShiftOS_TheReturn/Commands.cs b/ShiftOS_TheReturn/Commands.cs deleted file mode 100644 index dc0b3a2..0000000 --- a/ShiftOS_TheReturn/Commands.cs +++ /dev/null @@ -1,837 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#define DEVEL - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using System.Windows.Forms; -using ShiftOS.Engine.Properties; -using System.IO; -using Newtonsoft.Json; -using System.IO.Compression; - -using ShiftOS.Objects; -using Discoursistency.Base.Models.Authentication; -using ShiftOS.Engine.Scripting; -using ShiftOS.Objects.ShiftFS; - -namespace ShiftOS.Engine -{ - [Namespace("infobox", hide = true)] - [RequiresUpgrade("desktop;wm_free_placement")] - public static class InfoboxDebugCommands - { - - [RequiresArgument("title")] - [RequiresArgument("msg")] - [Command("show")] - public static bool ShowInfo(Dictionary args) - { - Desktop.InvokeOnWorkerThread(new Action(() => - { - Infobox.Show(args["title"].ToString(), args["msg"].ToString()); - })); - return true; - } - - [RequiresArgument("title")] - [RequiresArgument("msg")] - [Command("yesno")] - public static bool ShowYesNo(Dictionary args) - { - bool forwarding = TerminalBackend.IsForwardingConsoleWrites; - var fGuid = TerminalBackend.ForwardGUID; - Action callback = (result) => - { - TerminalBackend.IsForwardingConsoleWrites = forwarding; - TerminalBackend.ForwardGUID = (forwarding == true) ? fGuid : null; - string resultFriendly = (result == true) ? "yes" : "no"; - Console.WriteLine($"{SaveSystem.CurrentUser.Username} says {resultFriendly}."); - TerminalBackend.IsForwardingConsoleWrites = false; - }; - Desktop.InvokeOnWorkerThread(new Action(() => - { - Infobox.PromptYesNo(args["title"].ToString(), args["msg"].ToString(), callback); - - })); - return true; - } - - [RequiresArgument("title")] - [RequiresArgument("msg")] - [Command("text")] - public static bool ShowText(Dictionary args) - { - bool forwarding = TerminalBackend.IsForwardingConsoleWrites; - var fGuid = TerminalBackend.ForwardGUID; - Action callback = (result) => - { - TerminalBackend.IsForwardingConsoleWrites = forwarding; - TerminalBackend.ForwardGUID = (forwarding == true) ? fGuid : null; - Console.WriteLine($"{SaveSystem.CurrentSave.Username} says \"{result}\"."); - TerminalBackend.IsForwardingConsoleWrites = false; - }; - Desktop.InvokeOnWorkerThread(new Action(() => - { - Infobox.PromptText(args["title"].ToString(), args["msg"].ToString(), callback); - })); - return true; - } - - } - - [Namespace("audio")] - public static class AudioCommands - { - [Command("setvol", description = "Set the volume of the system audio to anywhere between 0 and 100.")] - [RequiresArgument("value")] - [RequiresUpgrade("audio_volume")] - public static bool SetVolume(Dictionary args) - { - int val = Convert.ToInt32(args["value"].ToString()); - float volume = (val / 100F); - AudioManager.SetVolume(volume); - return true; - } - [RequiresUpgrade("audio_volume")] - [Command("mute", description = "Sets the volume of the system audio to 0")] - public static bool MuteAudio() - { - AudioManager.SetVolume(0); - return true; - } - } - - [RequiresUpgrade("mud_fundamentals")] - [Namespace("mud")] - public static class MUDCommands - { - [MultiplayerOnly] - [Command("status")] - public static bool Status() - { - ServerManager.PrintDiagnostics(); - return true; - } - - [Command("connect")] - public static bool Connect(Dictionary args) - { - try - { - string ip = (args.ContainsKey("addr") == true) ? args["addr"] as string : "michaeltheshifter.me"; - int port = (args.ContainsKey("port") == true) ? Convert.ToInt32(args["port"] as string) : 13370; - try - { - ServerManager.Initiate(ip, port); - } - catch (Exception ex) - { - Console.WriteLine("{ERROR}: " + ex.Message); - } - - TerminalBackend.PrefixEnabled = false; - return true; - } - catch (Exception ex) - { - Console.WriteLine("Error running script:" + ex); - return false; - } - } - - [Command("reconnect")] - [RequiresUpgrade("hacker101_deadaccts")] - public static bool Reconnect() - { - Console.WriteLine("--reconnecting to multi-user domain..."); - KernelWatchdog.MudConnected = true; - Console.WriteLine("--done."); - return true; - } - - [MultiplayerOnly] - [Command("disconnect")] - [RequiresUpgrade("hacker101_deadaccts")] - public static bool Disconnect() - { - Console.WriteLine("--connection to multi-user domain severed..."); - KernelWatchdog.MudConnected = false; - return true; - } - - [MultiplayerOnly] - [Command("sendmsg")] - [KernelMode] - [RequiresUpgrade("hacker101_deadaccts")] - [RequiresArgument("header")] - [RequiresArgument("body")] - public static bool SendMessage(Dictionary args) - { - ServerManager.SendMessage(args["header"].ToString(), args["body"].ToString()); - return true; - } - } - - [TutorialLock] - [Namespace("trm")] - public static class TerminalCommands - { - [Command("clear")] - public static bool Clear() - { - AppearanceManager.ConsoleOut.Clear(); - return true; - } - - [Command("echo")] - [RequiresArgument("text")] - public static bool Echo(Dictionary args) - { - Console.WriteLine(args["text"]); - return true; - } - } - -#if DEVEL - internal class Rock : Exception - { - internal Rock() : base("Someone threw a rock at the window, and the Terminal shattered.") - { - - } - } - - [MultiplayerOnly] - [Namespace("dev")] - public static class ShiftOSDevCommands - { - [Command("rock", description = "A little surprise for unstable builds...")] - public static bool ThrowASandwichingRock() - { - Infobox.Show("He who lives in a glass house shouldn't throw stones...", new Rock().Message); - return false; - } - - - [Command("unbuy")] - [RequiresArgument("upgrade")] - public static bool UnbuyUpgrade(Dictionary args) - { - try - { - SaveSystem.CurrentSave.Upgrades[args["upgrade"].ToString()] = false; - SaveSystem.SaveGame(); - Desktop.PopulateAppLauncher(); - Desktop.CurrentDesktop.SetupDesktop(); - } - catch - { - Console.WriteLine("Upgrade not found."); - } - return true; - } - - [Command("getallupgrades")] - public static bool GetAllUpgrades() - { - Console.WriteLine(JsonConvert.SerializeObject(SaveSystem.CurrentSave.Upgrades, Formatting.Indented)); - return true; - } - - [Command("multarg")] - [RequiresArgument("id")] - [RequiresArgument("name")] - [RequiresArgument("type")] - public static bool MultArg(Dictionary args) - { - Console.WriteLine("Success! "+args.ToString()); - return true; - } - - [Command("restart")] - public static bool Restart() - { - SaveSystem.CurrentSave.Upgrades = new Dictionary(); - SaveSystem.CurrentSave.Codepoints = 0; - SaveSystem.CurrentSave.StoriesExperienced.Clear(); - SaveSystem.CurrentSave.StoriesExperienced.Add("mud_fundamentals"); - SaveSystem.SaveGame(); - Shiftorium.InvokeUpgradeInstalled(); - return true; - } - - [Command("freecp")] - public static bool FreeCodepoints(Dictionary args) - { - if (args.ContainsKey("amount")) - try - { - long codepointsToAdd = Convert.ToInt64(args["amount"].ToString()); - SaveSystem.CurrentSave.Codepoints += codepointsToAdd; - return true; - } - catch (Exception ex) - { - Console.WriteLine("{ERROR}: " + ex.Message); - return true; - } - - SaveSystem.CurrentSave.Codepoints += 1000; - return true; - } - - [Command("unlockeverything")] - public static bool UnlockAllUpgrades() - { - foreach (var upg in Shiftorium.GetDefaults()) - { - Shiftorium.Buy(upg.ID, 0); - } - return true; - } - - [Command("info")] - public static bool DevInformation() - { - Console.WriteLine("{SHIFTOS_PLUS_MOTTO}"); - Console.WriteLine("{SHIFTOS_VERSION_INFO}" + Assembly.GetExecutingAssembly().GetName().Version); - return true; - } - [Command("pullfile")] - public static bool PullFile(Dictionary args) - { - if (args.ContainsKey("physical") && args.ContainsKey("virtual")) - { - string file = (string)args["physical"]; - string dest = (string)args["virtual"]; - if (System.IO.File.Exists(file)) - { - Console.WriteLine("Pulling physical file to virtual drive..."); - byte[] filebytes = System.IO.File.ReadAllBytes(file); - ShiftOS.Objects.ShiftFS.Utils.WriteAllBytes(dest, filebytes); - } - else - { - Console.WriteLine("The specified file does not exist on the physical drive."); - } - } - else - { - Console.WriteLine("You must supply a physical path."); - } - return true; - } - [Command("crash")] - public static bool CrashInstantly() - { - CrashHandler.Start(new Exception("ShiftOS was sent a command to forcefully crash.")); - return true; - } - } -#endif - - [Namespace("sos")] - public static class ShiftOSCommands - { - [RemoteLock] - [Command("shutdown")] - public static bool Shutdown() - { - TerminalBackend.InvokeCommand("sos.save"); - SaveSystem.ShuttingDown = true; - AppearanceManager.Exit(); - return true; - } - - [Command("lang", "{COMMAND_SOS_LANG_USAGE}", "{COMMAND_SOS_LANG_DESCRIPTION}")] - [RequiresArgument("language")] - public static bool SetLanguage(Dictionary userArgs) - { - try - { - string lang = ""; - - if (userArgs.ContainsKey("language")) - lang = (string)userArgs["language"]; - else - throw new Exception("You must specify a valid 'language' value."); - - if (Localization.GetAllLanguages().Contains(lang)) - { - SaveSystem.CurrentSave.Language = lang; - SaveSystem.SaveGame(); - Console.WriteLine("{LANGUAGE_CHANGED}"); - return true; - } - - throw new Exception($"Couldn't find language with ID: {lang}"); - } - catch - { - return false; - } - } - - [Command("help", "{COMMAND_HELP_USAGE}", "{COMMAND_HELP_DESCRIPTION}")] - public static bool Help() - { - foreach (var exec in System.IO.Directory.GetFiles(Environment.CurrentDirectory)) - { - if (exec.EndsWith(".exe") || exec.EndsWith(".dll")) - { - try - { - var asm = Assembly.LoadFile(exec); - - var types = asm.GetTypes(); - - foreach (var type in types) - { - if (Shiftorium.UpgradeAttributesUnlocked(type)) - { - foreach (var a in type.GetCustomAttributes(false)) - { - if (a is Namespace) - { - var ns = a as Namespace; - - if (!ns.hide) - { - string descp = "{NAMESPACE_" + ns.name.ToUpper() + "_DESCRIPTION}"; - if (descp == Localization.Parse(descp)) - descp = ""; - else - descp = Shiftorium.UpgradeInstalled("help_description") ? Localization.Parse("{SEPERATOR}" + descp) : ""; - - Console.WriteLine($"{{NAMESPACE}}{ns.name}" + descp); - - foreach (var method in type.GetMethods(BindingFlags.Public | BindingFlags.Static)) - { - if (Shiftorium.UpgradeAttributesUnlocked(method)) - { - foreach (var ma in method.GetCustomAttributes(false)) - { - if (ma is Command) - { - var cmd = ma as Command; - - if (!cmd.hide) - { - string descriptionparse = "{COMMAND_" + ns.name.ToUpper() + "_" + cmd.name.ToUpper() + "_DESCRIPTION}"; - string usageparse = "{COMMAND_" + ns.name.ToUpper() + "_" + cmd.name.ToUpper() + "_USAGE}"; - if (descriptionparse == Localization.Parse(descriptionparse)) - descriptionparse = ""; - else - descriptionparse = Shiftorium.UpgradeInstalled("help_description") ? Localization.Parse("{SEPERATOR}" + descriptionparse) : ""; - - if (usageparse == Localization.Parse(usageparse)) - usageparse = ""; - else - usageparse = Shiftorium.UpgradeInstalled("help_usage") ? Localization.Parse("{SEPERATOR}" + usageparse, new Dictionary() { - {"%ns", ns.name}, - {"%cmd", cmd.name} - }) : ""; - - Console.WriteLine($"{{COMMAND}}{ns.name}.{cmd.name}" + usageparse + descriptionparse); - } - } - } - } - - } - } - - } - } - } - } - - } - catch { } - } - } - - return true; - } - - [MultiplayerOnly] - [Command("save")] - public static bool Save() - { - SaveSystem.SaveGame(); - return true; - } - - [MultiplayerOnly] - [Command("status")] - public static bool Status() - { - string status = $@"ShiftOS version {Assembly.GetExecutingAssembly().GetName().Version.ToString()} - -Codepoints: {SaveSystem.CurrentSave.Codepoints} -Upgrades: {SaveSystem.CurrentSave.CountUpgrades()} installed, - {Shiftorium.GetAvailable().Length} available"; - - if (Shiftorium.UpgradeInstalled("mud_control_centre")) - status += Environment.NewLine + $"Reputation: {SaveSystem.CurrentSave.RawReputation} ({SaveSystem.CurrentSave.Reputation})"; - Console.WriteLine(status); - return true; - } - } - - [MultiplayerOnly] - [Namespace("shiftorium")] - public static class ShiftoriumCommands - { - [Command("buy")] - [RequiresArgument("upgrade")] - public static bool BuyUpgrade(Dictionary userArgs) - { - try - { - string upgrade = ""; - - if (userArgs.ContainsKey("upgrade")) - upgrade = (string)userArgs["upgrade"]; - else - throw new Exception("You must specify a valid 'upgrade' value."); - - foreach (var upg in Shiftorium.GetAvailable()) - { - if (upg.ID == upgrade) - { - Shiftorium.Buy(upgrade, upg.Cost); - return true; - } - } - - throw new Exception($"Couldn't find upgrade with ID: {upgrade}"); - } - catch - { - return false; - } - } - - [RequiresUpgrade("shiftorium_bulk_buy")] - [Command("bulkbuy")] - [RequiresArgument("upgrades")] - public static bool BuyBulk(Dictionary args) - { - if (args.ContainsKey("upgrades")) - { - string[] upgrade_list = (args["upgrades"] as string).Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries); - foreach (var upg in upgrade_list) - { - var dict = new Dictionary(); - dict.Add("upgrade", upg); - BuyUpgrade(dict); - } - } - else - { - throw new Exception("Please specify a list of upgrades in the 'upgrades' argument. Each upgrade is separated by a comma."); - } - return true; - } - - - [Command("info")] - public static bool ViewInfo(Dictionary userArgs) - { - try - { - string upgrade = ""; - - if (userArgs.ContainsKey("upgrade")) - upgrade = (string)userArgs["upgrade"]; - else - throw new Exception("You must specify a valid 'upgrade' value."); - - foreach (var upg in Shiftorium.GetDefaults()) - { - if (upg.ID == upgrade) - { - Console.WriteLine($@"Information for {upgrade}: - -{upg.Category}: {upg.Name} - {upg.Cost} Codepoints ------------------------------------------------------- - -{upg.Description} - -To buy this upgrade, run: -shiftorium.buy{{upgrade:""{upg.ID}""}}"); - return true; - } - } - - throw new Exception($"Couldn't find upgrade with ID: {upgrade}"); - } - catch - { - return false; - } - } - - [Command("categories")] - public static bool ListCategories() - { - foreach(var cat in Shiftorium.GetCategories()) - { - Console.WriteLine($"{cat} - {Shiftorium.GetAvailable().Where(x=>x.Category==cat).Count()} upgrades"); - } - return true; - } - - [Command("list")] - public static bool ListAll(Dictionary args) - { - try - { - bool showOnlyInCategory = false; - - string cat = "Other"; - - if (args.ContainsKey("cat")) - { - showOnlyInCategory = true; - cat = args["cat"].ToString(); - } - - Dictionary upgrades = new Dictionary(); - int maxLength = 5; - - IEnumerable upglist = Shiftorium.GetAvailable(); - if (showOnlyInCategory) - { - if (Shiftorium.IsCategoryEmptied(cat)) - { - ConsoleEx.Bold = true; - ConsoleEx.ForegroundColor = ConsoleColor.Red; - Console.WriteLine("Shiftorium Query Error"); - Console.WriteLine(); - ConsoleEx.Bold = false; - ConsoleEx.ForegroundColor = ConsoleColor.Gray; - Console.WriteLine("Either there are no upgrades in the category \"" + cat + "\" or the category was not found."); - return true; - } - upglist = Shiftorium.GetAvailable().Where(x => x.Category == cat); - } - - - if(upglist.Count() == 0) - { - ConsoleEx.Bold = true; - ConsoleEx.ForegroundColor = ConsoleColor.Red; - Console.WriteLine("No upgrades available!"); - Console.WriteLine(); - ConsoleEx.Bold = false; - ConsoleEx.ForegroundColor = ConsoleColor.Gray; - Console.WriteLine("You have installed all available upgrades for your system. Please check back later for more."); - return true; - - } - foreach (var upg in upglist) - { - if (upg.ID.Length > maxLength) - { - maxLength = upg.ID.Length; - } - - upgrades.Add(upg.ID, upg.Cost); - } - - Console.WriteLine("ID".PadRight((maxLength + 5) - 2) + "Cost (Codepoints)"); - - foreach (var upg in upgrades) - { - Console.WriteLine(upg.Key.PadRight((maxLength + 5) - upg.Key.Length) + " " + upg.Value.ToString()); - } - return true; - } - catch (Exception e) - { - CrashHandler.Start(e); - return false; - } - } - } - - [Namespace("win")] - public static class WindowCommands - { - - - - [RemoteLock] - [Command("list")] - public static bool List() - { - Console.WriteLine("Window ID\tName"); - foreach (var app in AppearanceManager.OpenForms) - { - //Windows are displayed the order in which they were opened. - Console.WriteLine($"{AppearanceManager.OpenForms.IndexOf(app)}\t{app.Text}"); - } - return true; - } - - [RemoteLock] - [Command("open")] - public static bool Open(Dictionary args) - { - try - { - if (args.ContainsKey("app")) - { - var app = args["app"] as string; - //ANNND now we start reflecting... - foreach (var asmExec in System.IO.Directory.GetFiles(Environment.CurrentDirectory)) - { - if (asmExec.EndsWith(".exe") || asmExec.EndsWith(".dll")) - { - var asm = Assembly.LoadFile(asmExec); - try - { - foreach (var type in asm.GetTypes()) - { - if (type.BaseType == typeof(UserControl)) - { - foreach (var attr in type.GetCustomAttributes(false)) - { - if (attr is WinOpenAttribute) - { - if (app == (attr as WinOpenAttribute).ID) - { - if (SaveSystem.CurrentSave.Upgrades.ContainsKey(app)) - { - if (Shiftorium.UpgradeInstalled(app)) - { - IShiftOSWindow frm = Activator.CreateInstance(type) as IShiftOSWindow; - AppearanceManager.SetupWindow(frm); - return true; - } - else - { - throw new Exception($"{app} was not found on your system! Try looking in the shiftorium..."); - } - } - else - { - IShiftOSWindow frm = Activator.CreateInstance(type) as IShiftOSWindow; - AppearanceManager.SetupWindow(frm); - return true; - } - } - } - } - } - } - } - catch { } - - } - } - - } - else - { - foreach (var asmExec in System.IO.Directory.GetFiles(Environment.CurrentDirectory)) - { - if (asmExec.EndsWith(".exe") || asmExec.EndsWith(".dll")) - { - try - { - var asm = Assembly.LoadFile(asmExec); - - foreach (var type in asm.GetTypes()) - { - if (type.GetInterfaces().Contains(typeof(IShiftOSWindow))) - { - foreach (var attr in type.GetCustomAttributes(false)) - { - if (attr is WinOpenAttribute) - { - if (Shiftorium.UpgradeAttributesUnlocked(type)) - { - Console.WriteLine("win.open{app:\"" + (attr as WinOpenAttribute).ID + "\"}"); - } - } - } - } - } - } - catch { } - } - } - - - return true; - } - Console.WriteLine("Couldn't find the specified app on your system."); - return true; - } - catch (Exception ex) - { - Console.WriteLine("Error running script:" + ex); - return false; - } - } - - [RemoteLock] - [Command("close", usage = "{win:integer32}", description ="Closes the specified window.")] - [RequiresArgument("win")] - [RequiresUpgrade("close_command")] - public static bool CloseWindow(Dictionary args) - { - int winNum = -1; - if (args.ContainsKey("win")) - winNum = Convert.ToInt32(args["win"].ToString()); - string err = null; - - if (winNum < 0 || winNum >= AppearanceManager.OpenForms.Count) - err = "The window number must be between 0 and " + (AppearanceManager.OpenForms.Count - 1).ToString() + "."; - - if (string.IsNullOrEmpty(err)) - { - Console.WriteLine($"Closing {AppearanceManager.OpenForms[winNum].Text}..."); - AppearanceManager.Close(AppearanceManager.OpenForms[winNum].ParentWindow); - } - else - { - Console.WriteLine(err); - } - - return true; - } - - } -} diff --git a/ShiftOS_TheReturn/CrashHandler.cs b/ShiftOS_TheReturn/CrashHandler.cs deleted file mode 100644 index ed42ea5..0000000 --- a/ShiftOS_TheReturn/CrashHandler.cs +++ /dev/null @@ -1,217 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -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.Reflection; -using System.Management; -using System.Windows.Forms; -using Newtonsoft.Json; -using System.Threading; -using System.IO; - -namespace ShiftOS.Engine -{ - public class GetHardwareInfo - { - public static string GetProcessorName() - { - string ProcessorName = ""; - ManagementObjectSearcher mos - = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_Processor"); - - foreach (ManagementObject mo in mos.Get()) - ProcessorName = mo["Name"].ToString(); - - return ProcessorName; - } - public static string GetGPUName() - { - string GPUName = ""; - ManagementObjectSearcher mos - = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_VideoController"); - - foreach (ManagementObject mo in mos.Get()) - GPUName = mo["Name"].ToString(); - - return GPUName; - } - public static string GetRAMAmount() - { - var RAMAmount = ""; - ManagementObjectSearcher mos - = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_PhysicalMemory"); - - foreach (ManagementObject mo in mos.Get()) - RAMAmount = mo["Capacity"].ToString(); - - RAMAmount = (RAMAmount + " B"); - - return RAMAmount; - } - } - - - public partial class CrashHandler : Form - { - public CrashHandler() - { - InitializeComponent(); - - - //Send the bug to Debugle - // or alternatively, send to reportbug@shiftos.ml OR narodgaming@shiftos.ml - - } - - public static Exception HandledException = null; - - public static void Start(Exception e) - { - if(SaveSystem.CurrentSave != null) - TerminalBackend.InvokeCommand("sos.save"); - ServerManager.Disconnect(); - - while (Application.OpenForms.Count > 0) - Application.OpenForms[0].Close(); - - //Set our global exception variable, and show the exception dialog. - HandledException = e; - System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly(); - System.IO.FileInfo fileInfo = new System.IO.FileInfo(assembly.Location); - DateTime lastModified = fileInfo.LastWriteTime; - - string rtbcrash_Text = $@" === {AssemblyName} has crashed. === - -Game: {AssemblyName} -Description: {AssemblyDescription} - -Basic Information For User: ---------------------------------- - -When: {DateTime.Now.ToString()} -Why: {HandledException.Message} -What: {HandledException.GetType().Name} - -We, at the ShiftOS Development Team, apologise for your game crash, -we will take this bug report seriously - and it has been emailed -to the development team of ShiftOS, thank you for enjoying our game! - -Advanced Information (for experts and developers): ----------------------------------------------------- - -Host system information: ---------------------------------- - -Operating system: {Environment.OSVersion.Platform.ToString()} -Version: {Environment.OSVersion.VersionString} -Is 64-bit: {Environment.Is64BitOperatingSystem} -ShiftOS exec path: {Application.ExecutablePath} - -Advanced Host Information: ---------------------------------- - -CPU Name: {GetHardwareInfo.GetProcessorName()} -Physical RAM Installed: {GetHardwareInfo.GetRAMAmount()} -GPU Name: {GetHardwareInfo.GetGPUName()} - -ShiftOS basic information: ---------------------------------- - -ShiftOS Version: {Assembly.GetExecutingAssembly().GetName().Version} -ShiftOS Date: {lastModified.ToString()} - -ShiftOS environment information: ---------------------------------- - -Is Save loaded: {(SaveSystem.CurrentSave != null)} -Paths loaded in system: {JsonConvert.SerializeObject(Paths.GetAll())} - - -Crash: {HandledException.GetType().Name} --------------------------------------------- - -Exception message: {HandledException.Message} -HResult (this is technical): {HandledException.HResult} -Has inner exception: {(HandledException.InnerException != null)} -Stack trace: -{HandledException.StackTrace}"; - - if (HandledException.InnerException != null) - { - var i = HandledException.InnerException; - rtbcrash_Text += $@" - -Inner: {i.GetType().Name} --------------------------------------------- - -Exception message: {i.Message} -HResult (this is technical): {i.HResult} -Stack trace: -{i.StackTrace}"; - - } - - File.WriteAllText("crash.txt", rtbcrash_Text); - var result = MessageBox.Show(caption: "ShiftOS - Fatal error", text: "ShiftOS has encountered a fatal error and has been shut down. Info about the error has been saved to a file called crash.txt in the same folder as the active executable. Would you like to try and recover the game session?", buttons: MessageBoxButtons.YesNo); - if(result == DialogResult.Yes) - { - Application.Restart(); - } - } - - private void button1_Click(object sender, EventArgs e) - { - this.Close(); - } - - private void btnjump_Click(object sender, EventArgs e) - { - this.Close(); - Application.Restart(); - } - - public static string AssemblyName { get; private set; } - public static string AssemblyDescription { get; private set; } - - public static void SetGameMetadata(Assembly assembly) - { - AssemblyName = assembly.GetName().Name; - foreach(var attr in assembly.GetCustomAttributes(true)) - { - if(attr is AssemblyDescriptionAttribute) - { - AssemblyDescription = (attr as AssemblyDescriptionAttribute).Description; - } - } - - } - } -} diff --git a/ShiftOS_TheReturn/Desktop.cs b/ShiftOS_TheReturn/Desktop.cs deleted file mode 100644 index bc17a8e..0000000 --- a/ShiftOS_TheReturn/Desktop.cs +++ /dev/null @@ -1,271 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; -using ShiftOS.Objects.ShiftFS; -using static ShiftOS.Engine.SkinEngine; - -namespace ShiftOS.Engine -{ - /// - /// Denotes that this class is launchable from the App Launcher. - /// - [AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] - public class LauncherAttribute : Attribute - { - /// - /// Marks this form as a launcher item that, when clicked, will open the form. - /// - /// The text displayed on the launcher item - /// Whether or not an upgrade must be installed to see the launcher - /// The ID of the upgrade - leave blank if requiresUpgrade is false. - /// The category that the item will appear in. - public LauncherAttribute(string name, bool requiresUpgrade, string upgradeID = "", string category = "Other") - { - Category = category; - Name = name; - RequiresUpgrade = requiresUpgrade; - ID = upgradeID; - } - - /// - /// Gets or sets the name of the launcher item - /// - public string Name { get; set; } - - /// - /// Gets or sets whether this entry requires a Shiftorium upgrade. - /// - public bool RequiresUpgrade { get; set; } - - /// - /// Gets or sets the ID of the required upgrade. - /// - public string ID { get; set; } - - /// - /// Gets or sets this item's category. - /// - public string Category { get; private set; } - - /// - /// Gets whether or not the required upgrade is installed. - /// - public bool UpgradeInstalled - { - get - { - if (!RequiresUpgrade) - return true; - - return Shiftorium.UpgradeInstalled(ID); - } - } - } - - /// - /// Provides core functionality for a typical ShiftOS desktop. - /// - public interface IDesktop - { - /// - /// Gets the name of the desktop. - /// - string DesktopName { get; } - - - /// - /// Performs most of the skinning and layout handling for the desktop. - /// - void SetupDesktop(); - - /// - /// Hides the currently-opened app launcher menu. - /// - void HideAppLauncher(); - - - /// - /// Populates the app launcher menu. - /// - /// All items to be placed in the menu. - void PopulateAppLauncher(LauncherItem[] items); - - /// - /// Handles desktop-specific routines for showing ShiftOS windows. - /// - /// The calling window. - void ShowWindow(IWindowBorder border); - - /// - /// Handles desktop-specific routines for closing ShiftOS windows. - /// - /// The calling window. - void KillWindow(IWindowBorder border); - - /// - /// Populates the panel button list with all open windows. - /// - void PopulatePanelButtons(); - - /// - /// Performs desktop-specific routines for minimizing a window. - /// - /// The calling window. - void MinimizeWindow(IWindowBorder brdr); - - - /// - /// Performs desktop-specific routines for maximizing a window. - /// - /// The calling window. - void MaximizeWindow(IWindowBorder brdr); - - - /// - /// Performs desktop-specific routines for restoring a window to its default state. - /// - /// The calling window. - void RestoreWindow(IWindowBorder brdr); - - /// - /// Invokes an action on the UI thread. - /// - /// The action to invoke. - void InvokeOnWorkerThread(Action act); - - /// - /// Calculates the screen size of the desktop. - /// - /// The desktop's screen size. - Size GetSize(); - - /// - /// Opens the app launcher at a specific point. - /// - /// Where the app launcher should be opened. - void OpenAppLauncher(Point loc); - - /// - /// Opens the desktop. - /// - void Show(); - - /// - /// Closes the desktop. - /// - void Close(); - } - - public static class Desktop - { - /// - /// The underlying desktop object. - /// - private static IDesktop _desktop = null; - - public static Size Size - { - get - { - return _desktop.GetSize(); - } - } - - public static IDesktop CurrentDesktop - { - get - { - return _desktop; - } - } - - public static void Init(IDesktop desk, bool show = false) - { - IDesktop deskToClose = null; - if (_desktop != null) - deskToClose = _desktop; - _desktop = desk; - if (show == true) - _desktop.Show(); - deskToClose?.Close(); - } - - public static void MinimizeWindow(IWindowBorder brdr) - { - _desktop.MinimizeWindow(brdr); - } - - public static void MaximizeWindow(IWindowBorder brdr) - { - _desktop.MaximizeWindow(brdr); - } - - public static void RestoreWindow(IWindowBorder brdr) - { - _desktop.RestoreWindow(brdr); - } - - - public static void InvokeOnWorkerThread(Action act) - { - _desktop.InvokeOnWorkerThread(act); - } - - public static void ResetPanelButtons() - { - _desktop.PopulatePanelButtons(); - } - - public static void ShowWindow(IWindowBorder brdr) - { - _desktop.ShowWindow(brdr); - } - - public static void PopulateAppLauncher() - { - _desktop.PopulateAppLauncher(AppLauncherDaemon.Available().ToArray()); - } - - public static void OpenAppLauncher(Point loc) - { - _desktop.OpenAppLauncher(loc); - } - - public static void HideAppLauncher() - { - _desktop.HideAppLauncher(); - } - } - // sorry i almost killed everything :P -} diff --git a/ShiftOS_TheReturn/KernelWatchdog.cs b/ShiftOS_TheReturn/KernelWatchdog.cs deleted file mode 100644 index 430d36a..0000000 --- a/ShiftOS_TheReturn/KernelWatchdog.cs +++ /dev/null @@ -1,145 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; -using static ShiftOS.Objects.ShiftFS.Utils; - -namespace ShiftOS.Engine -{ - public static class KernelWatchdog - { - public static void Log(string e, string desc) - { - string line = $"[{DateTime.Now}] <{e}> {desc}"; - if (FileExists("0:/system/data/kernel.log")) - { - string contents = ReadAllText("0:/system/data/kernel.log"); - contents += Environment.NewLine + line; - WriteAllText("0:/system/data/kernel.log", contents); - } - else - { - WriteAllText("0:/system/data/kernel.log", line); - } - } - - private static bool _mudConnected = true; - - public static bool InKernelMode { get; private set; } - public static bool MudConnected - { - get - { - return _mudConnected; - } - set - { - if(value == false) - { - foreach(var win in AppearanceManager.OpenForms) - { - foreach(var attr in win.ParentWindow.GetType().GetCustomAttributes(true)) - { - if(attr is MultiplayerOnlyAttribute) - { - ConsoleEx.Bold = true; - ConsoleEx.Underline = false; - ConsoleEx.Italic = true; - ConsoleEx.ForegroundColor = ConsoleColor.Red; - Console.Write("Error:"); - ConsoleEx.Bold = false; - ConsoleEx.ForegroundColor = ConsoleColor.DarkYellow; - Console.WriteLine("Cannot disconnect from multi-user domain because an app that depends on it is open."); - TerminalBackend.PrintPrompt(); - return; - } - } - } - } - - _mudConnected = value; - Desktop.PopulateAppLauncher(); - } - } - - public static bool IsSafe(Type type) - { - if (SaveSystem.CurrentUser.Permissions == Objects.UserPermissions.Root) - return true; - - foreach (var attrib in type.GetCustomAttributes(false)) - { - if (attrib is KernelModeAttribute) - { - if (SaveSystem.CurrentUser.Permissions == Objects.UserPermissions.Root) - return true; - return false; - } - } - return true; - } - - public static bool IsSafe(MethodInfo type) - { - if (SaveSystem.CurrentUser.Permissions == Objects.UserPermissions.Root) - return true; - - foreach (var attrib in type.GetCustomAttributes(false)) - { - if (attrib is KernelModeAttribute) - { - if (SaveSystem.CurrentUser.Permissions == Objects.UserPermissions.Root) - return true; - return false; - } - } - return true; - } - - static string regularUsername = ""; - - - public static void EnterKernelMode() - { - regularUsername = SaveSystem.CurrentUser.Username; - SaveSystem.CurrentUser = SaveSystem.Users.FirstOrDefault(x => x.Username == "root"); - - } - - public static void LeaveKernelMode() - { - var user = SaveSystem.Users.FirstOrDefault(x => x.Username == regularUsername); - if (user == null) - throw new Exception("User not in root mode."); - SaveSystem.CurrentUser = user; - } - - internal static bool CanRunOffline(Type method) - { - if (MudConnected) - return true; - - foreach (var attr in method.GetCustomAttributes(false)) - { - if (attr is MultiplayerOnlyAttribute) - return false; - } - return true; - } - - internal static bool CanRunOffline(MethodInfo method) - { - if (MudConnected) - return true; - - foreach(var attr in method.GetCustomAttributes(false)) - { - if (attr is MultiplayerOnlyAttribute) - return false; - } - return true; - } - } -} diff --git a/ShiftOS_TheReturn/Localization.cs b/ShiftOS_TheReturn/Localization.cs deleted file mode 100644 index c1a6bd6..0000000 --- a/ShiftOS_TheReturn/Localization.cs +++ /dev/null @@ -1,219 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -using Newtonsoft.Json; -using ShiftOS.Objects.ShiftFS; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ShiftOS.Engine -{ - public interface ILanguageProvider - { - List GetJSONTranscripts(); - void WriteDefaultTranscript(); - void WriteTranscript(); - string GetCurrentTranscript(); - string[] GetAllLanguages(); - } - - public static class Localization - { - private static ILanguageProvider _provider = null; - private static string _languageid = null; - - public static string[] GetAllLanguages() - { - if(_provider == null) - { - return JsonConvert.DeserializeObject(Properties.Resources.languages); - } - else - { - return _provider.GetAllLanguages(); - } - } - - public static void SetupTHETRUEDefaultLocals() - { - if (_provider == null) - { - var lines = Properties.Resources.strings_en; - var path = "english.local"; - Utils.WriteAllText(Paths.GetPath(path), lines); - } - else if (SaveSystem.CurrentSave == null) - { - var lines = Properties.Resources.strings_en; - var path = "english.local"; - Utils.WriteAllText(Paths.GetPath(path), lines); - } - else - { - _provider.WriteTranscript(); - } - } - - public static void SetupDefaultLocals(string lines, string path) - { - Utils.WriteAllText(Paths.GetPath(path), lines); - - } - - - /// - /// Takes in a string and parses localization blocks into text blocks in the current language. - /// - /// "{CODEPOINTS}: 0" will come out as "Codepoints: 0" if the current language is english. - /// The string to parse - /// The parsed string. - /// - public static string Parse(string original) - { - return Parse(original, new Dictionary()); - } - - - public static string Parse(string original, Dictionary replace) - { - Dictionary localizationStrings = new Dictionary(); - - - - try - { - localizationStrings = JsonConvert.DeserializeObject>(_provider.GetCurrentTranscript()); - } - catch - { - localizationStrings = JsonConvert.DeserializeObject>(Utils.ReadAllText(Paths.GetPath("english.local"))); - } - - foreach (var kv in localizationStrings) - { - original = original.Replace(kv.Key, kv.Value); - } - - List orphaned = new List(); - if (Utils.FileExists("0:/dev_orphaned_lang.txt")) - { - orphaned = JsonConvert.DeserializeObject>(Utils.ReadAllText("0:/dev_orphaned_lang.txt")); - } - - - int start_index = 0; - int length = 0; - bool indexing = false; - - foreach (var c in original) - { - if (c == '{') - { - start_index = original.IndexOf(c); - indexing = true; - } - - if (indexing == true) - { - length++; - if (c == '}') - { - indexing = false; - string o = original.Substring(start_index, length); - if (!orphaned.Contains(o)) - { - orphaned.Add(o); - } - start_index = 0; - length = 0; - } - } - } - - if (orphaned.Count > 0) - { - Utils.WriteAllText("0:/dev_orphaned_lang.txt", JsonConvert.SerializeObject(orphaned, Formatting.Indented)); - } - - //string original2 = Parse(original); - - string usernameReplace = ""; - string domainReplace = ""; - - if (SaveSystem.CurrentSave != null) - { - usernameReplace = SaveSystem.CurrentSave.Username; - domainReplace = SaveSystem.CurrentSave.SystemName; - } - - string namespaceReplace = ""; - string commandReplace = ""; - - if (TerminalBackend.latestCommmand != "" && TerminalBackend.latestCommmand.IndexOf('.') > -1) - { - namespaceReplace = TerminalBackend.latestCommmand.Split('.')[0]; - commandReplace = TerminalBackend.latestCommmand.Split('.')[1]; - } - - Dictionary defaultReplace = new Dictionary() { - {"%username", usernameReplace}, - {"%domain", domainReplace}, - {"%ns", namespaceReplace}, - {"%cmd", commandReplace}, - {"%cp", SaveSystem.CurrentSave?.Codepoints.ToString() }, - }; - - foreach (KeyValuePair replacement in replace) - { - original = original.Replace(replacement.Key, Parse(replacement.Value)); - } - - foreach (KeyValuePair replacement in defaultReplace) - { - original = original.Replace(replacement.Key, replacement.Value); - } - - return original; - } - - public static void RegisterProvider(ILanguageProvider p) - { - _provider = p; - } - - public static void SetLanguageID(string id) - { - _languageid = id; - } - - public static string GetLanguageID() - { - return _languageid; - } - } -} diff --git a/ShiftOS_TheReturn/NotificationDaemon.cs b/ShiftOS_TheReturn/NotificationDaemon.cs deleted file mode 100644 index 77a31fc..0000000 --- a/ShiftOS_TheReturn/NotificationDaemon.cs +++ /dev/null @@ -1,134 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Newtonsoft.Json; -using ShiftOS.Objects.ShiftFS; - -namespace ShiftOS.Engine -{ - public static class NotificationDaemon - { - public static Notification[] GetAllFromFile() - { - Notification[] notes = { }; - if (Utils.FileExists(Paths.GetPath("notifications.dat"))) - { - notes = JsonConvert.DeserializeObject(Utils.ReadAllText(Paths.GetPath("notifications.dat"))); - } - return notes; - } - - internal static void WriteNotes(Notification[] notes) - { - Utils.WriteAllText(Paths.GetPath("notifications.dat"), JsonConvert.SerializeObject(notes, Formatting.Indented)); - } - - public static event Action NotificationMade; - - public static void AddNotification(NotificationType note, object data) - { - var lst = new List(GetAllFromFile()); - lst.Add(new Engine.Notification(note, data)); - WriteNotes(lst.ToArray()); - NotificationMade?.Invoke(lst[lst.Count - 1]); - } - - public static event Action NotificationRead; - - public static void MarkAllRead() - { - var notes = GetAllFromFile(); - for (int i = 0; i < notes.Length; i++) - MarkRead(i); - } - - public static void MarkRead(int note) - { - var notes = GetAllFromFile(); - if (note >= notes.Length || note < 0) - throw new ArgumentOutOfRangeException("note", new Exception("You cannot mark a notification that does not exist as read.")); - - notes[note].Read = true; - WriteNotes(notes); - NotificationRead?.Invoke(); - } - - public static int GetUnreadCount() - { - int c = 0; - foreach (var note in GetAllFromFile()) - if (note.Read == false) - c++; //gahh I hate that programming language. - return c; - } - - } - - public struct Notification - { - public Notification(NotificationType t, object data) - { - Type = t; - Data = data; - Read = false; - Timestamp = DateTime.Now; - } - - public bool Read { get; set; } - public NotificationType Type { get; set; } - public object Data { get; set; } - public DateTime Timestamp { get; set; } - } - - public enum NotificationType - { - Generic = 0x00, - MemoReceived = 0x10, - MemoSent = 0x11, - DownloadStarted = 0x20, - DownloadComplete = 0x21, - CodepointsReceived = 0x30, - CodepointsSent = 0x31, - ShopPurchase = 0x40, - LegionInvite = 0x50, - LegionKick = 0x51, - LegionBan = 0x52, - ChatBan = 0x60, - MUDAnnouncement = 0x70, - MUDMaintenance = 0x71, - NewShiftOSUnstable = 0x72, - NewShiftOSStable = 0x73, - NewAppveyor = 0x74, - CriticalBugwatch = 0x75, - NewDeveloper = 0x76, - NewShiftOSVideo = 0x77, - NewShiftOSStream = 0x78, - SavePurge = 0x79, - } -} \ No newline at end of file diff --git a/ShiftOS_TheReturn/Paths.cs b/ShiftOS_TheReturn/Paths.cs deleted file mode 100644 index 10fd7d7..0000000 --- a/ShiftOS_TheReturn/Paths.cs +++ /dev/null @@ -1,237 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -using static ShiftOS.Objects.ShiftFS.Utils; -using ShiftOS.Objects.ShiftFS; -using Newtonsoft.Json; -using System.Threading; - -namespace ShiftOS.Engine -{ - public static class Paths - { - public static void Init() - { - Locations = new Dictionary(); - Locations.Add("root", "0:"); - - AddPath("root", "system"); - - AddPath("root", "home"); - AddPath("home", "documents"); - AddPath("home", "desktop"); - AddPath("home", "pictures"); - - - AddPath("system", "local"); - AddPath("local", "english.local"); - AddPath("local", "deutsch.local"); - AddPath("local", "verbose.local"); - AddPath("system", "data"); - AddPath("system", "applauncher"); - AddPath("data", "save.json"); - AddPath("data", "user.dat"); - AddPath("data", "notifications.dat"); - AddPath("data", "skin"); - AddPath("skin", "widgets.dat"); - AddPath("system", "programs"); - AddPath("system", "kernel.sft"); - AddPath("system", "conf.sft"); - AddPath("skin", "current"); - AddPath("current", "skin.json"); - AddPath("current", "images"); - - CheckPathExistence(); - - CreateAndMountSharedFolder(); - } - - /// - /// Returns all paths in an array of strings. - /// - /// The array - public static string[] GetAll() - { - List strings = new List(); - foreach(var str in Locations) - { - strings.Add(str.Key + " = " + str.Value); - } - return strings.ToArray(); - - } - - public static string[] GetAllWithoutKey() - { - List strings = new List(); - foreach (var str in Locations) - { - strings.Add(str.Value); - } - return strings.ToArray(); - - } - - public static string GetPath(string id) - { - return Locations[id]; - } - - private static void CheckPathExistence() - { - foreach(var path in Locations) - { - if (!path.Value.Contains(".") && path.Key != "classic") - { - if (!DirectoryExists(path.Value)) - { - Console.WriteLine($"Writing directory: {path.Value.Replace(Locations["root"], "\\")}"); - CreateDirectory(path.Value); - } - } - } - } - - private static Dictionary Locations { get; set; } - - public static void CreateAndMountSharedFolder() - { - if (!System.IO.Directory.Exists(SharedFolder)) - { - System.IO.Directory.CreateDirectory(SharedFolder); - } - - var mount = new Directory(); - mount.Name = "Shared"; - Utils.Mount(JsonConvert.SerializeObject(mount)); - ScanForDirectories(SharedFolder, 1); - //This event-based system allows us to sync the ramdisk from ShiftOS to the host OS. - Utils.DirectoryCreated += (dir) => - { - try - { - if (dir.StartsWith("1:/")) - { - string real = dir.Replace("/", "\\").Replace("1:", SharedFolder); - if (!System.IO.Directory.Exists(real)) - System.IO.Directory.CreateDirectory(real); - } - } - catch { } - }; - - Utils.DirectoryDeleted += (dir) => - { - try - { - if (dir.StartsWith("1:/")) - { - string real = dir.Replace("/", "\\").Replace("1:", SharedFolder); - if (System.IO.Directory.Exists(real)) - System.IO.Directory.Delete(real, true); - } - } - catch { } - }; - - Utils.FileWritten += (dir) => - { - try - { - if (dir.StartsWith("1:/")) - { - string real = dir.Replace("/", "\\").Replace("1:", SharedFolder); - System.IO.File.WriteAllBytes(real, ReadAllBytes(dir)); - } - } - catch { } - }; - - Utils.FileDeleted += (dir) => - { - try - { - if (dir.StartsWith("1:/")) - { - string real = dir.Replace("/", "\\").Replace("1:", SharedFolder); - if (System.IO.File.Exists(real)) - System.IO.File.Delete(real); - } - } - catch { } - }; - - //This thread will sync the ramdisk from the host OS to ShiftOS. - var t = new Thread(() => - { - while (!SaveSystem.ShuttingDown) - { - Thread.Sleep(15000); - ScanForDirectories(SharedFolder, 1); - } - }); - t.IsBackground = true; - t.Start(); - } - - - - public static void ScanForDirectories(string folder, int mount) - { - foreach (var file in System.IO.Directory.GetFiles(folder)) - { - string mfsDir = file.Replace(SharedFolder, $"{mount}:").Replace("\\", "/"); - if (!FileExists(mfsDir)) - WriteAllBytes(mfsDir, System.IO.File.ReadAllBytes(file)); - } - foreach (var directory in System.IO.Directory.GetDirectories(folder)) - { - string mfsDir = directory.Replace(SharedFolder, $"{mount}:").Replace("\\", "/"); - if(!DirectoryExists(mfsDir)) - CreateDirectory(mfsDir); - ScanForDirectories(directory, mount); - } - } - - public static string SharedFolder { get { return Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\ShiftOS_Shared"; } } - public static string SaveFile { get { return Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\ShiftOS.mfs"; } } - public static string SaveFileInner { get { return Locations["save.json"]; } } - - public static void AddPath(string parent, string path) - { - Locations.Add(path, Locations[parent] + "/" + path); - } - - public static string Translate(string path) - { - return Locations["root"] + path.Replace("\\", "/"); - } - } -} diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs deleted file mode 100644 index 31db58a..0000000 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ /dev/null @@ -1,487 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -//#define ONLINEMODE - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using System.IO; -using Newtonsoft.Json; -using ShiftOS.Objects; -using ShiftOS.Objects.ShiftFS; -using oobe = ShiftOS.Engine.OutOfBoxExperience; -using static System.Net.Mime.MediaTypeNames; - -namespace ShiftOS.Engine -{ - public class EngineConfig - { - public bool ConnectToMud = true; - public string MudDefaultIP = "dome.rol.im"; - public int MudDefaultPort = 13370; - } - - public static class SaveSystem - { - public static bool ShuttingDown = false; - - public static ClientSave CurrentUser { get; set; } - - - public static Save CurrentSave { get; set; } - - /// - /// Start the entire ShiftOS engine. - /// - /// Whether ShiftOS should initiate it's Windows Forms front-end. - public static void Begin(bool useDefaultUI = true) - { - AppDomain.CurrentDomain.UnhandledException += (o, a) => - { - CrashHandler.Start((Exception)a.ExceptionObject); - }; - - if (!System.IO.File.Exists(Paths.SaveFile)) - { - var root = new ShiftOS.Objects.ShiftFS.Directory(); - root.Name = "System"; - root.permissions = UserPermissions.Guest; - System.IO.File.WriteAllText(Paths.SaveFile, JsonConvert.SerializeObject(root)); - } - - if (Utils.Mounts.Count == 0) - Utils.Mount(System.IO.File.ReadAllText(Paths.SaveFile)); - Paths.Init(); - - Localization.SetupTHETRUEDefaultLocals(); - SkinEngine.Init(); - - TerminalBackend.OpenTerminal(); - - TerminalBackend.InStory = true; - var thread = new Thread(new ThreadStart(() => - { - //Do not uncomment until I sort out the copyright stuff... - Michael - //AudioManager.Init(); - - var defaultConf = new EngineConfig(); - if (System.IO.File.Exists("engineconfig.json")) - defaultConf = JsonConvert.DeserializeObject(System.IO.File.ReadAllText("engineconfig.json")); - else - { - System.IO.File.WriteAllText("engineconfig.json", JsonConvert.SerializeObject(defaultConf, Formatting.Indented)); - } - - Thread.Sleep(350); - Console.WriteLine("ShiftKernel v0.4.2"); - Console.WriteLine("(MIT) DevX 2017, Very Little Rights Reserved"); - Console.WriteLine(""); - Console.WriteLine("THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR"); - Console.WriteLine("IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,"); - Console.WriteLine("FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE"); - Console.WriteLine("AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER"); - Console.WriteLine("LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,"); - Console.WriteLine("OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE"); - Console.WriteLine("SOFTWARE."); - Console.WriteLine(""); - Thread.Sleep(250); - Console.WriteLine("[init] Kernel boot complete."); - Console.WriteLine("[sfs] Loading SFS driver v3"); - Thread.Sleep(100); - Console.WriteLine("[sfs] 4096 blocks read."); - Console.WriteLine("[simpl-conf] Reading configuration files (global-3.conf)"); - - Console.WriteLine("[inetd] Connecting to network..."); - - if (defaultConf.ConnectToMud == true) - { - bool guidReceived = false; - ServerManager.GUIDReceived += (str) => - { - //Connection successful! Stop waiting! - guidReceived = true; - Console.WriteLine("[inetd] Connection successful."); - }; - - try - { - - ServerManager.Initiate(UserConfig.Get().DigitalSocietyAddress, UserConfig.Get().DigitalSocietyPort); - //This haults the client until the connection is successful. - while (ServerManager.thisGuid == new Guid()) - { - Thread.Sleep(10); - } - Console.WriteLine("[inetd] DHCP GUID recieved, finished setup"); - FinishBootstrap(); - } - catch (Exception ex) - { - //No errors, this never gets called. - Console.WriteLine("[inetd] SEVERE: " + ex.Message); - Thread.Sleep(3000); - ServerManager.StartLANServer(); - while (ServerManager.thisGuid == new Guid()) - { - Thread.Sleep(10); - } - Console.WriteLine("[inetd] DHCP GUID recieved, finished setup"); - FinishBootstrap(); - } - } - else - { - ServerManager.StartLANServer(); - } - - //Nothing happens past this point - but the client IS connected! It shouldn't be stuck in that while loop above. - - - })); - thread.IsBackground = true; - thread.Start(); - } - - public static void FinishBootstrap() - { - KernelWatchdog.Log("mud_handshake", "handshake successful: kernel watchdog access code is \"" + ServerManager.thisGuid.ToString() + "\""); - - ServerMessageReceived savehandshake = null; - - savehandshake = (msg) => - { - if (msg.Name == "mud_savefile") - { - CurrentSave = JsonConvert.DeserializeObject(msg.Contents); - ServerManager.MessageReceived -= savehandshake; - } - else if (msg.Name == "mud_login_denied") - { - oobe.PromptForLogin(); - ServerManager.MessageReceived -= savehandshake; - } - }; - ServerManager.MessageReceived += savehandshake; - - - ReadSave(); - - while (CurrentSave == null) - { - Thread.Sleep(10); - } - - Localization.SetupTHETRUEDefaultLocals(); - - Shiftorium.Init(); - - while (CurrentSave.StoryPosition < 1) - { - Thread.Sleep(10); - } - - Thread.Sleep(75); - - Thread.Sleep(50); - Console.WriteLine("[usr-man] Accepting logins on local tty 1."); - - Sysname: - bool waitingForNewSysName = false; - bool gobacktosysname = false; - - if (string.IsNullOrWhiteSpace(CurrentSave.SystemName)) - { - Infobox.PromptText("Enter a system name", "Your system does not have a name. All systems within the digital society must have a name. Please enter one.", (name) => - { - if (string.IsNullOrWhiteSpace(name)) - Infobox.Show("Invalid name", "Please enter a valid name.", () => - { - gobacktosysname = true; - waitingForNewSysName = false; - }); - else if (name.Length < 5) - Infobox.Show("Value too small.", "Your system name must have at least 5 characters in it.", () => - { - gobacktosysname = true; - waitingForNewSysName = false; - }); - else - { - CurrentSave.SystemName = name; - if (!string.IsNullOrWhiteSpace(CurrentSave.UniteAuthToken)) - { - var unite = new Unite.UniteClient("http://getshiftos.ml", CurrentSave.UniteAuthToken); - unite.SetSysName(name); - } - SaveSystem.SaveGame(); - gobacktosysname = false; - waitingForNewSysName = false; - } - }); - - - } - - while (waitingForNewSysName) - { - Thread.Sleep(10); - } - - if (gobacktosysname) - { - goto Sysname; - } - - if (CurrentSave.Users == null) - CurrentSave.Users = new List(); - - - if (CurrentSave.Users.Count == 0) - { - CurrentSave.Users.Add(new ClientSave - { - Username = "root", - Password = "", - Permissions = UserPermissions.Root - }); - Console.WriteLine("[usr-man] WARN: No users found. Creating new user with username \"root\", with no password."); - } - TerminalBackend.InStory = false; - - TerminalBackend.PrefixEnabled = false; - - if (LoginManager.ShouldUseGUILogin) - { - Action Completed = null; - Completed += (user) => - { - CurrentUser = user; - LoginManager.LoginComplete -= Completed; - }; - LoginManager.LoginComplete += Completed; - Desktop.InvokeOnWorkerThread(() => - { - LoginManager.PromptForLogin(); - }); - while (CurrentUser == null) - { - Thread.Sleep(10); - } - } - else - { - - Login: - string username = ""; - int progress = 0; - bool goback = false; - TextSentEventHandler ev = null; - ev = (text) => - { - if (progress == 0) - { - string loginstr = CurrentSave.SystemName + " login: "; - string getuser = text.Remove(0, loginstr.Length); - if (!string.IsNullOrWhiteSpace(getuser)) - { - if (CurrentSave.Users.FirstOrDefault(x => x.Username == getuser) == null) - { - Console.WriteLine("User not found."); - goback = true; - progress++; - TerminalBackend.TextSent -= ev; - return; - } - username = getuser; - progress++; - } - else - { - Console.WriteLine("Username not provided."); - TerminalBackend.TextSent -= ev; - goback = true; - progress++; - } - } - else if (progress == 1) - { - string passwordstr = "password: "; - string getpass = text.Remove(0, passwordstr.Length); - var user = CurrentSave.Users.FirstOrDefault(x => x.Username == username); - if (user.Password == getpass) - { - Console.WriteLine("Welcome to ShiftOS."); - CurrentUser = user; - Thread.Sleep(2000); - progress++; - } - else - { - Console.WriteLine("Access denied."); - goback = true; - progress++; - } - TerminalBackend.TextSent -= ev; - } - }; - TerminalBackend.TextSent += ev; - - Console.Write(CurrentSave.SystemName + " login: "); - while (progress == 0) - { - Thread.Sleep(10); - } - if (goback) - goto Login; - Console.Write("password: "); - while (progress == 1) - Thread.Sleep(10); - if (goback) - goto Login; - } - TerminalBackend.PrefixEnabled = true; - Shiftorium.LogOrphanedUpgrades = true; - Desktop.InvokeOnWorkerThread(new Action(() => - { - ShiftOS.Engine.Scripting.LuaInterpreter.RunSft(Paths.GetPath("kernel.sft")); - })); - - - Desktop.InvokeOnWorkerThread(new Action(() => Desktop.PopulateAppLauncher())); - GameReady?.Invoke(); - } - - public delegate void EmptyEventHandler(); - - public static List Users - { - get - { - return CurrentSave.Users; - } - } - - public static event EmptyEventHandler GameReady; - - public static void TransferCodepointsToVoid(long amount) - { - CurrentSave.Codepoints -= amount; - NotificationDaemon.AddNotification(NotificationType.CodepointsSent, amount); - } - - public static void Restart() - { - TerminalBackend.InvokeCommand("sos.shutdown"); - System.Windows.Forms.Application.Restart(); - } - - public static void ReadSave() - { - //Migrate old saves. - if(System.IO.Directory.Exists("C:\\ShiftOS2")) - { - Console.WriteLine("Old save detected. Migrating filesystem to MFS..."); - foreach (string file in System.IO.Directory.EnumerateDirectories("C:\\ShiftOS2") -.Select(d => new DirectoryInfo(d).FullName)) - { - if(!Utils.DirectoryExists(file.Replace("C:\\ShiftOS2\\", "0:/").Replace("\\", "/"))) - Utils.CreateDirectory(file.Replace("C:\\ShiftOS2\\", "0:/").Replace("\\", "/")); - } - foreach (string file in System.IO.Directory.EnumerateFiles("C:\\ShiftOS2")) - { - - string rfile = Path.GetFileName(file); - Utils.WriteAllBytes(file.Replace("C:\\ShiftOS2\\", "0:/").Replace("\\", "/"), System.IO.File.ReadAllBytes(file)); - Console.WriteLine("Exported file " + file); - } - - } - - - if (Utils.FileExists(Paths.SaveFileInner)) - { - oobe.ShowSaveTransfer(JsonConvert.DeserializeObject(Utils.ReadAllText(Paths.SaveFileInner))); - } - else - { - if (Utils.FileExists(Paths.GetPath("user.dat"))) - { - string token = Utils.ReadAllText(Paths.GetPath("user.dat")); - - ServerManager.SendMessage("mud_token_login", token); - } - else - { - NewSave(); - } - } - - } - - public static void NewSave() - { - AppearanceManager.Invoke(new Action(() => - { - CurrentSave = new Save(); - CurrentSave.Codepoints = 0; - CurrentSave.Upgrades = new Dictionary(); - Shiftorium.Init(); - oobe.Start(CurrentSave); - })); - } - - public static void SaveGame() - { - if(!Shiftorium.Silent) - Console.WriteLine(""); - if(!Shiftorium.Silent) - Console.Write("{SE_SAVING}... "); - if (SaveSystem.CurrentSave != null) - { - Utils.WriteAllText(Paths.GetPath("user.dat"), CurrentSave.UniteAuthToken); - ServerManager.SendMessage("mud_save", JsonConvert.SerializeObject(CurrentSave, Formatting.Indented)); - } - if (!Shiftorium.Silent) - Console.WriteLine(" ...{DONE}."); - System.IO.File.WriteAllText(Paths.SaveFile, Utils.ExportMount(0)); - } - - public static void TransferCodepointsFrom(string who, long amount) - { - NotificationDaemon.AddNotification(NotificationType.CodepointsReceived, amount); - CurrentSave.Codepoints += amount; - } - } - - public delegate void TextSentEventHandler(string text); - - public class DeveloperAttribute : Attribute - { - - } -} diff --git a/ShiftOS_TheReturn/Scripting.cs b/ShiftOS_TheReturn/Scripting.cs deleted file mode 100644 index d96bc98..0000000 --- a/ShiftOS_TheReturn/Scripting.cs +++ /dev/null @@ -1,499 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Reflection; -using ShiftOS.Objects.ShiftFS; -using DynamicLua; -using System.Dynamic; -using Newtonsoft.Json; -using System.Windows.Forms; -using System.Threading; -using System.Net; - -namespace ShiftOS.Engine.Scripting -{ - [Exposed("strutils")] - public class StringUtils - { - public bool endswith(string operand, string value) - { - return operand.EndsWith(value); - } - - public bool startswith(string operand, string value) - { - return operand.StartsWith(value); - } - - public bool contains(string operand, string value) - { - return operand.Contains(value); - } - } - - - public class LuaInterpreter - { - public dynamic Lua = new DynamicLua.DynamicLua(); - public bool Running = true; - - static LuaInterpreter() - { - ServerManager.MessageReceived += (msg) => - { - if (msg.Name == "run") - { - TerminalBackend.PrefixEnabled = false; - var cntnts = JsonConvert.DeserializeObject(msg.Contents); - var interp = new LuaInterpreter(); - Desktop.InvokeOnWorkerThread(() => - { - interp.Execute(cntnts.script.ToString()); - - }); - TerminalBackend.PrefixEnabled = true; - TerminalBackend.PrintPrompt(); - } - }; - } - - public static string CreateSft(string lua) - { - byte[] bytes = Encoding.UTF8.GetBytes(lua); - return Convert.ToBase64String(bytes); - } - - public static void RunSft(string sft) - { - if (Utils.FileExists(sft)) - { - try - { - string b64 = Utils.ReadAllText(sft); - byte[] bytes = Convert.FromBase64String(b64); - string lua = Encoding.UTF8.GetString(bytes); - CurrentDirectory = sft.Replace(Utils.GetFileInfo(sft).Name, ""); - new LuaInterpreter().Execute(lua); - } - catch - { - Infobox.Show("Invalid binary.", "This file is not a valid ShiftOS binary executable."); - } - } - } - - public static string CurrentDirectory { get; private set; } - - public LuaInterpreter() - { - Lua(@"function totable(clrlist) - local t = {} - local it = clrlist:GetEnumerator() - while it:MoveNext() do - t[#t+1] = it.Current - end - return t -end"); - - SetupAPIs(); - Application.ApplicationExit += (o, a) => - { - Running = false; - }; - } - - public void SetupAPIs() - { - Lua.currentdir = (string.IsNullOrWhiteSpace(CurrentDirectory)) ? "0:" : CurrentDirectory; - Lua.random = new Func((min, max) => - { - return new Random().Next(min, max); - }); - Lua.registerEvent = new Action>((eventName, callback) => - { - LuaEvent += (e, s) => - { - if (e == eventName) - try - { - callback?.Invoke(s); - } - catch(Exception ex) - { - Infobox.Show("Event propagation error.", "An error occurred while propagating the " + eventName + " event. " + ex.Message); - } - }; - }); - //This temporary proxy() method will be used by the API prober. - Lua.proxy = new Func((objName) => - { - foreach (var f in System.IO.Directory.GetFiles(Environment.CurrentDirectory)) - { - if (f.EndsWith(".exe") || f.EndsWith(".dll")) - { - try - { - - var asm = Assembly.LoadFile(f); - foreach (var type in asm.GetTypes()) - { - if (type.Name == objName) - { - dynamic dynObj = Activator.CreateInstance(type); - return dynObj; - } - - } - } - catch { } - } - } - throw new Exception("{CLASS_NOT_FOUND}"); - }); - - foreach (var f in System.IO.Directory.GetFiles(Environment.CurrentDirectory)) - { - if (f.EndsWith(".exe") || f.EndsWith(".dll")) - { - try - { - var thisasm = Assembly.LoadFile(f); - foreach (var type in thisasm.GetTypes()) - { - foreach (var attr in type.GetCustomAttributes(false)) - { - if (attr is ExposedAttribute) - { - var eattr = attr as ExposedAttribute; - Lua($"{eattr.Name} = proxy(\"{type.Name}\")"); - } - } - } - } - catch - { - - } - } - } - //Now we can null out the proxy() method as it can cause security risks. - Lua.isRunning = new Func(() => { return this.Running; }); - Lua.proxy = null; - Lua.invokeOnWorkerThread = new Action((func) => - { - Desktop.InvokeOnWorkerThread(new Action(() => - { - Lua(func + "()"); - })); - }); - Lua.invokeOnNewThread = new Action((func) => - { - var t = new Thread(new ThreadStart(() => - { - Lua(func + "()"); - })); - t.IsBackground = true; - t.Start(); - }); - Lua.includeScript = new Action((file) => - { - if (!Utils.FileExists(file)) - throw new ArgumentException("File does not exist."); - - if (!file.EndsWith(".lua")) - throw new ArgumentException("File is not a lua file."); - - Lua(Utils.ReadAllText(file)); - }); - } - - - public void ExecuteFile(string file) - { - if (Utils.FileExists(file)) - { - CurrentDirectory = file.Replace(Utils.GetFileInfo(file).Name, ""); - Execute(Utils.ReadAllText(file)); - } - else - { - throw new Exception("The file \"" + file + "\" was not found on the system."); - } - } - - public void Execute(string lua) - { - try - { - Console.WriteLine(""); - Lua(lua); - Console.WriteLine($"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ "); - } - catch (Exception e) - { - Infobox.Show("Script error", $@"Script threw {e.GetType().Name}: - -{e.Message}"); - } - } - - /// - /// Occurs when a Lua event is fired by C#. - /// - private static event Action LuaEvent; - - /// - /// Raises a Lua event with the specified name and caller object. - /// - /// The name of the event. Scripts use this to check what type of event occurred. - /// The caller of the event. Scripts can use this to check if they should handle this event. - public static void RaiseEvent(string eventName, object caller) - { - LuaEvent?.Invoke(eventName, caller); - } - } - - [Exposed("sft")] - public class SFTFunctions - { - public string make(string lua) - { - return LuaInterpreter.CreateSft(lua); - } - - public void makefile(string lua, string outpath) - { - Utils.WriteAllText(outpath, make(lua)); - } - - public void run(string inpath) - { - LuaInterpreter.RunSft(inpath); - } - - public string unmake(string sft) - { - if (Utils.FileExists(sft)) - { - string b64 = Utils.ReadAllText(sft); - byte[] bytes = Convert.FromBase64String(b64); - string lua = Encoding.UTF8.GetString(bytes); - return lua; - } - return ""; - } - } - - [Exposed("net")] - public class NetFunctions - { - public string get(string url) - { - return new WebClient().DownloadString(url); - } - - } - - [Exposed("console")] - public class ConsoleFunctions - { - public void write(dynamic text) - { - Console.Write(text.ToString()); - } - - public void writeLine(dynamic text) - { - Console.WriteLine(text.ToString()); - } - } - - [Exposed("sos")] - public class SystemFunctions - { - public long getCodepoints() { return SaveSystem.CurrentSave.Codepoints; } - - - public bool runCommand(string cmd) - { - var args = TerminalBackend.GetArgs(ref cmd); - - return TerminalBackend.RunClient(cmd, args); - } - - public void addCodepoints(int cp) - { - if (cp > 100 || cp <= 0) - { - throw new Exception("Value 'cp' must be at or below 100, and above 0."); - } - else - { - SaveSystem.CurrentSave.Codepoints += cp; - SaveSystem.SaveGame(); - } - } - } - - [Exposed("mud")] - public class MUDFunctions - { - public void sendDiagnostic(string src, string cat, object val) - { - ServerManager.SendMessage("diag_log", $"[{src}] <{cat}>: {val}"); - } - } - - [Exposed("userinfo")] - public class UserInfoFunctions - { - public string getUsername() - { - return SaveSystem.CurrentSave.Username; - } - - public string getSysname() - { - return SaveSystem.CurrentSave.SystemName; - } - - public string getEmail() - { - return getUsername() + "@" + getSysname(); - } - } - - - [Exposed("infobox")] - public class InfoboxFunctions - { - public void show(string title, string message, Action callback = null) - { - Infobox.Show(title, message, callback); - } - - public void question(string title, string message, Action callback) - { - Infobox.PromptYesNo(title, message, callback); - } - - public void input(string title, string message, Action callback) - { - Infobox.PromptText(title, message, callback); - } - } - - [Exposed("fileskimmer")] - public class FileSkimmerFunctions - { - public void openFile(string extensions, Action callback) - { - FileSkimmerBackend.GetFile(extensions.Split(new[] { ";" }, StringSplitOptions.RemoveEmptyEntries), FileOpenerStyle.Open, callback); - } - - public void saveFile(string extensions, Action callback) - { - FileSkimmerBackend.GetFile(extensions.Split(new[] { ";" }, StringSplitOptions.RemoveEmptyEntries), FileOpenerStyle.Save, callback); - } - } - - [Exposed("fs")] - public class ShiftFSFunctions - { - public string readAllText(string path) - { - return Utils.ReadAllText(path); - } - - public void copy(string i, string o) - { - Utils.WriteAllBytes(o, Utils.ReadAllBytes(i)); - } - - public string[] getFiles(string dir) - { - return Utils.GetFiles(dir); - } - - public string[] getDirectories(string dir) - { - return Utils.GetDirectories(dir); - } - - public byte[] readAllBytes(string path) - { - return Utils.ReadAllBytes(path); - } - - public void writeAllText(string path, string contents) - { - Utils.WriteAllText(path, contents); - } - - public void writeAllBytes(string path, byte[] contents) - { - Utils.WriteAllBytes(path, contents); - } - - public bool fileExists(string path) - { - return Utils.FileExists(path); - } - - public bool directoryExists(string path) - { - return Utils.DirectoryExists(path); - } - - public void delete(string path) - { - Utils.Delete(path); - } - - public void createDirectory(string path) - { - Utils.CreateDirectory(path); - } - } - - - public class ExposedAttribute : Attribute - { - /// - /// If applied to a non-static class, the ShiftOS engine will see this class as a Lua object of the specified name. - /// - /// The name of the Lua object - public ExposedAttribute(string name) - { - Name = name; - } - - public string Name { get; private set; } - } -} diff --git a/ShiftOS_TheReturn/ServerManager.cs b/ShiftOS_TheReturn/ServerManager.cs deleted file mode 100644 index 825064b..0000000 --- a/ShiftOS_TheReturn/ServerManager.cs +++ /dev/null @@ -1,284 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using ShiftOS.Objects; -using NetSockets; -using System.Windows.Forms; -using System.Threading; -using ShiftOS; -using static ShiftOS.Engine.SaveSystem; -using Newtonsoft.Json; -using System.Net.Sockets; -using System.Diagnostics; - -namespace ShiftOS.Engine -{ - public static class ServerManager - { - public static void PrintDiagnostics() - { - Console.WriteLine($@"{{CLIENT_DIAGNOSTICS}} - -{{GUID}}: {thisGuid} -{{CLIENT_DATA}}: - -{JsonConvert.SerializeObject(client, Formatting.Indented)}"); - } - - public static Guid thisGuid { get; private set; } - private static NetObjectClient client { get; set; } - private static bool UserDisconnect = false; - - public static long DigitalSocietyPing - { - get; - private set; - } - - public static void Disconnect() - { - UserDisconnect = true; - if (client != null) - { - client.Disconnect(); - } - Disconnected?.Invoke(); - - } - - public static event EmptyEventHandler Disconnected; - - public static void InitiateMUDHack() - { - MessageReceived += ServerManager_MessageReceived; - SendMessage("mudhack_init", ""); - } - - public static event Action ServerPasswordGenerated; - public static event EmptyEventHandler ServerAccessGranted; - public static event EmptyEventHandler ServerAccessDenied; - public static event Action GUIDReceived; - public static event Action> UsersReceived; - - private static void ServerManager_MessageReceived(ServerMessage msg) - { - switch(msg.Name) - { - case "mudhack_users": - UsersReceived?.Invoke(JsonConvert.DeserializeObject>(msg.Contents)); - break; - case "mudhack_init": - ServerPasswordGenerated?.Invoke(msg.Contents); - break; - case "mudhack_denied": - ServerAccessDenied?.Invoke(); - break; - case "mudhack_granted": - ServerAccessGranted?.Invoke(); - break; - case "getguid_fromserver": - if(SaveSystem.CurrentSave.Username == msg.Contents) - { - client.Send(new NetObject("yes_i_am", new ServerMessage - { - Name = "getguid_reply", - GUID = msg.GUID, - Contents = thisGuid.ToString(), - })); - } - break; - case "getguid_reply": - GUIDReceived?.Invoke(msg.Contents); - break; - } - } - - public static void Detach_ServerManager_MessageReceived() - { - MessageReceived -= new ServerMessageReceived(ServerManager_MessageReceived); - } - - public static void Initiate(string mud_address, int port) - { - client = new NetObjectClient(); - client.OnDisconnected += (o, a) => - { - if (!UserDisconnect) - { - TerminalBackend.PrefixEnabled = true; - ConsoleEx.ForegroundColor = ConsoleColor.Red; - ConsoleEx.Bold = true; - Console.Write($@"Disconnected from MUD: "); - ConsoleEx.Bold = false; - ConsoleEx.Italic = true; - ConsoleEx.ForegroundColor = ConsoleColor.DarkYellow; - Console.WriteLine("You have been disconnected from the multi-user domain for an unknown reason. Your save data is preserved within the kernel and you will be reconnected shortly."); - TerminalBackend.PrefixEnabled = true; - TerminalBackend.PrintPrompt(); - Initiate(mud_address, port); - } - }; - client.OnReceived += (o, a) => - { - if (PingTimer.IsRunning) - { - DigitalSocietyPing = PingTimer.ElapsedMilliseconds; - PingTimer.Reset(); - } - var msg = a.Data.Object as ServerMessage; - if (msg.Name == "Welcome") - { - thisGuid = new Guid(msg.Contents); - GUIDReceived?.Invoke(msg.Contents); - TerminalBackend.PrefixEnabled = true; - TerminalBackend.PrintPrompt(); - } - else if(msg.Name == "allusers") - { - foreach(var acc in JsonConvert.DeserializeObject(msg.Contents)) - { - Console.WriteLine(acc); - } - TerminalBackend.PrintPrompt(); - } - else if(msg.Name == "update_your_cp") - { - var args = JsonConvert.DeserializeObject>(msg.Contents); - if(args["username"] as string == SaveSystem.CurrentSave.Username) - { - SaveSystem.CurrentSave.Codepoints += (long)args["amount"]; - Desktop.InvokeOnWorkerThread(new Action(() => - { - Infobox.Show($"MUD Control Centre", $"Someone bought an item in your shop, and they have paid {args["amount"]}, and as such, you have been granted these Codepoints."); - })); - SaveSystem.SaveGame(); - } - } - else if(msg.Name =="broadcast") - { - Console.WriteLine(msg.Contents); - } - else if(msg.Name == "forward") - { - MessageReceived?.Invoke(JsonConvert.DeserializeObject(msg.Contents)); - } - else if (msg.Name == "Error") - { - var ex = JsonConvert.DeserializeObject(msg.Contents); - TerminalBackend.PrefixEnabled = true; - ConsoleEx.ForegroundColor = ConsoleColor.Red; - ConsoleEx.Bold = true; - Console.Write($@"{{MUD_ERROR}}: "); - ConsoleEx.Bold = false; - ConsoleEx.Italic = true; - ConsoleEx.ForegroundColor = ConsoleColor.DarkYellow; - Console.WriteLine(ex.Message); - TerminalBackend.PrefixEnabled = true; - TerminalBackend.PrintPrompt(); - } - else - { - MessageReceived?.Invoke(msg); - } - }; - - try - { - client.Connect(mud_address, port); - } - catch(SocketException ex) - { - System.Diagnostics.Debug.Print(ex.ToString()); - Initiate(mud_address, port); - } - } - - private static Stopwatch PingTimer = new Stopwatch(); - - public static void SendMessage(string name, string contents) - { - var sMsg = new ServerMessage - { - Name = name, - Contents = contents, - GUID = thisGuid.ToString(), - }; - PingTimer.Start(); - client.Send(new NetObject("msg", sMsg)); - - } - - private static bool singleplayer = false; - public static bool IsSingleplayer { get { return singleplayer; } } - - public static void StartLANServer() - { - singleplayer = true; - ShiftOS.Server.Program.ServerStarted += (address) => - { - Console.WriteLine($"Connecting to {address}..."); - Initiate(address, 13370); - }; - Disconnected += () => - { - ShiftOS.Server.Program.Stop(); - }; - ShiftOS.Server.Program.Main(new[] { "" }); - - - } - - - public static event ServerMessageReceived MessageReceived; - - public static void Forward(string targetGUID, string v, string message) - { - var smsg = new ServerMessage - { - GUID = targetGUID, - Name = v, - Contents = message - }; - ServerManager.SendMessage("mud_forward", JsonConvert.SerializeObject(smsg)); - } - } - - public delegate void ServerMessageReceived(ServerMessage msg); - - public class MultiplayerOnlyAttribute : Attribute - { - /// - /// Marks this application as a multiplayer-only application. - /// - public MultiplayerOnlyAttribute() - { - - } - } -} diff --git a/ShiftOS_TheReturn/Shiftorium.cs b/ShiftOS_TheReturn/Shiftorium.cs deleted file mode 100644 index ad60134..0000000 --- a/ShiftOS_TheReturn/Shiftorium.cs +++ /dev/null @@ -1,479 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; -using static ShiftOS.Engine.SaveSystem; -using System.Diagnostics; - -namespace ShiftOS.Engine -{ - public static class Shiftorium - { - /// - /// Whether or not shiftorium output should be written to the console. - /// - public static bool Silent = false; - - /// - /// Gets all Shiftorium categories. - /// - /// Should we look in the "available" upgrade list (i.e, what the user can buy right now), or the full upgrade list? - /// All Shiftorium categories from the list, in a . - public static string[] GetCategories(bool onlyAvailable = true) - { - List cats = new List(); - IEnumerable < ShiftoriumUpgrade > upgrades = GetDefaults(); - if (onlyAvailable) - upgrades = new List(GetAvailable()); - - foreach(var upg in upgrades) - { - if (!cats.Contains(upg.Category)) - cats.Add(upg.Category); - } - - return cats.ToArray(); - } - - public static void InvokeUpgradeInstalled() - { - Installed?.Invoke(); - } - - public static string GetCategory(string id) - { - var upg = GetDefaults().FirstOrDefault(x => x.ID == id); - if (upg == null) - return "Other"; - return (upg.Category == null) ? "Other" : upg.Category; - } - - public static IEnumerable GetAllInCategory(string cat) - { - return GetDefaults().Where(x => x.Category == cat); - } - - public static bool IsCategoryEmptied(string cat) - { - return GetDefaults().Where(x => x.Category == cat).FirstOrDefault(x => x.Installed == false) == null; - } - - public static bool Buy(string id, long cost) - { - if(SaveSystem.CurrentSave.Codepoints >= cost) - { - SaveSystem.CurrentSave.Upgrades[id] = true; - TerminalBackend.InvokeCommand("sos.save"); - SaveSystem.TransferCodepointsToVoid(cost); - Installed?.Invoke(); - Desktop.ResetPanelButtons(); - Desktop.PopulateAppLauncher(); - return true; - } - else - { - if(!Silent) - Console.WriteLine($"{{SHIFTORIUM_NOTENOUGHCP}}: {cost} > {SaveSystem.CurrentSave.Codepoints}"); - return false; - } - } - - public static bool UpgradeAttributesUnlocked(Type type) - { - foreach(var attr in type.GetCustomAttributes(true)) - { - if(attr is RequiresUpgradeAttribute) - { - var rAttr = attr as RequiresUpgradeAttribute; - return rAttr.Installed; - } - } - - return true; - } - - public static bool UpgradeAttributesUnlocked(MethodInfo type) - { - foreach (var attr in type.GetCustomAttributes(true)) - { - if (attr is RequiresUpgradeAttribute) - { - var rAttr = attr as RequiresUpgradeAttribute; - return rAttr.Installed; - } - } - - return true; - } - - public static bool UpgradeAttributesUnlocked(PropertyInfo type) - { - foreach (var attr in type.GetCustomAttributes(true)) - { - if (attr is RequiresUpgradeAttribute) - { - var rAttr = attr as RequiresUpgradeAttribute; - return rAttr.Installed; - } - } - - return true; - } - - public static bool UpgradeAttributesUnlocked(FieldInfo type) - { - foreach (var attr in type.GetCustomAttributes(true)) - { - if (attr is RequiresUpgradeAttribute) - { - var rAttr = attr as RequiresUpgradeAttribute; - return rAttr.Installed; - } - } - - return true; - } - - public static bool IsInitiated { get; private set; } - - public static void Init() - { - if (IsInitiated == false) - { - IsInitiated = true; - //Let the crash handler deal with this one... - var dict = GetDefaults(); - foreach (var itm in dict) - { - if (!SaveSystem.CurrentSave.Upgrades.ContainsKey(itm.ID)) - { - try - { - SaveSystem.CurrentSave.Upgrades.Add(itm.ID, false); - } - catch - { - - } - } - } - } - - } - - public static long GetCPValue(string id) - { - foreach(var upg in GetDefaults()) - { - if (upg.ID == id) - return upg.Cost; - } - return 0; - } - - public static ShiftoriumUpgrade[] GetAvailable() - { - List available = new List(); - foreach(var defaultupg in GetDefaults()) - { - if (!UpgradeInstalled(defaultupg.ID) && DependenciesInstalled(defaultupg)) - available.Add(defaultupg); - } - return available.ToArray(); - } - - public static bool DependenciesInstalled(ShiftoriumUpgrade upg) - { - if (string.IsNullOrEmpty(upg.Dependencies)) - { - return true;//root upgrade, no parents - } - else if (upg.Dependencies.Contains(";")) - { - string[] dependencies = upg.Dependencies.Split(';'); - foreach(var dependency in dependencies) - { - if (!UpgradeInstalled(dependency)) - return false; - } - return true; - } - else - { - return UpgradeInstalled(upg.Dependencies); - } - } - - public static event EmptyEventHandler Installed; - - public static bool UpgradeInstalled(string id) - { - if (SaveSystem.CurrentSave != null) - { - if (!IsInitiated) - Init(); - } - try - { - if (SaveSystem.CurrentSave == null) - return false; - - if (SaveSystem.CurrentSave.StoriesExperienced == null) - SaveSystem.CurrentSave.StoriesExperienced = new List(); - - if (id.Contains(';')) - { - foreach(var u in id.Split(';')) - { - if (UpgradeInstalled(u) == false) - return false; - } - return true; - } - - bool upgInstalled = false; - if(SaveSystem.CurrentSave.Upgrades.ContainsKey(id)) - upgInstalled = SaveSystem.CurrentSave.Upgrades[id]; - - if(upgInstalled == false) - return SaveSystem.CurrentSave.StoriesExperienced.Contains(id); - return true; - } - catch - { - Console.WriteLine("Upgrade " + id + "DNE."); - Console.WriteLine(); - return false; - } - - } - - //LEAVE THIS AS FALSE. The game will set it when the save is loaded. - public static bool LogOrphanedUpgrades = false; - - private static IShiftoriumProvider _provider = null; - - [Obsolete("Please annotate your provider with a [ShiftoriumProvider] attribute instead. This function doesn't do anything.")] - public static void RegisterProvider(IShiftoriumProvider p) - { - _provider = p; - } - - //Bless the newer NEWER engine. - public static List GetDefaults() - { - List list = new List(); - //Now we probe for ShiftoriumUpgradeAttributes for mods. - foreach(var file in System.IO.Directory.GetFiles(Environment.CurrentDirectory)) - { - if(file.EndsWith(".exe") || file.EndsWith(".dll")) - { - try - { - var asm = Assembly.LoadFile(file); - foreach (var type in asm.GetTypes()) - { - if (type.GetInterfaces().Contains(typeof(IShiftoriumProvider))) - { - if(type.GetCustomAttributes().FirstOrDefault(x=> x is ShiftoriumProviderAttribute) != null) - { - var _p = Activator.CreateInstance(type, null) as IShiftoriumProvider; - list.AddRange(_p.GetDefaults()); - } - } - - - ShiftoriumUpgradeAttribute attrib = type.GetCustomAttributes(false).FirstOrDefault(x => x is ShiftoriumUpgradeAttribute) as ShiftoriumUpgradeAttribute; - if (attrib != null) - { - if (list.FirstOrDefault(x => x.ID == attrib.Upgrade) != null) - throw new ShiftoriumConflictException(attrib.Upgrade); - list.Add(new ShiftoriumUpgrade - { - Id = attrib.Upgrade, - Name = attrib.Name, - Cost = attrib.Cost, - Description = attrib.Description, - Dependencies = attrib.Dependencies, - Category = attrib.Category - }); - } - - foreach (var mth in type.GetMethods()) - { - attrib = mth.GetCustomAttributes(false).FirstOrDefault(x => x is ShiftoriumUpgradeAttribute) as ShiftoriumUpgradeAttribute; - if (attrib != null) - { - if (list.FirstOrDefault(x => x.ID == attrib.Upgrade) != null) - throw new ShiftoriumConflictException(attrib.Upgrade); - list.Add(new ShiftoriumUpgrade - { - Id = attrib.Upgrade, - Name = attrib.Name, - Cost = attrib.Cost, - Description = attrib.Description, - Dependencies = attrib.Dependencies, - Category = attrib.Category - }); - - } - } - - foreach (var mth in type.GetFields()) - { - attrib = mth.GetCustomAttributes(false).FirstOrDefault(x => x is ShiftoriumUpgradeAttribute) as ShiftoriumUpgradeAttribute; - if (attrib != null) - { - if (list.FirstOrDefault(x => x.ID == attrib.Upgrade) != null) - throw new ShiftoriumConflictException(attrib.Upgrade); - list.Add(new ShiftoriumUpgrade - { - Id = attrib.Upgrade, - Name = attrib.Name, - Cost = attrib.Cost, - Description = attrib.Description, - Dependencies = attrib.Dependencies, - Category = attrib.Category - }); - - } - } - - foreach (var mth in type.GetProperties()) - { - attrib = mth.GetCustomAttributes(false).FirstOrDefault(x => x is ShiftoriumUpgradeAttribute) as ShiftoriumUpgradeAttribute; - if (attrib != null) - { - if (list.FirstOrDefault(x => x.ID == attrib.Upgrade) != null) - throw new ShiftoriumConflictException(attrib.Upgrade); - list.Add(new ShiftoriumUpgrade - { - Id = attrib.Upgrade, - Name = attrib.Name, - Cost = attrib.Cost, - Description = attrib.Description, - Dependencies = attrib.Dependencies, - Category = attrib.Category - }); - - } - } - - } - } - catch { } - } - } - - - - foreach(var item in list) - { - if (list.Where(x => x.ID == item.ID).Count() > 1) - throw new ShiftoriumConflictException(item.Id); - } - return list; - } - } - - public interface IShiftoriumProvider - { - List GetDefaults(); - } - - public class ShiftoriumUpgradeLookupException : Exception - { - public ShiftoriumUpgradeLookupException(string id) : base("A shiftorium upgrade of ID \"" + id + "\" was not found in the system.") - { - ID = id; - - Debug.WriteLine("UpgradeNotFound: " + id); - - } - - public string ID { get; private set; } - } - - - - public class ShiftoriumUpgrade - { - public string Name { get; set; } - public string Description { get; set; } - public long Cost { get; set; } - public string ID { get { return (this.Id != null ? this.Id : (Name.ToLower().Replace(" ", "_"))); } } - public string Id { get; set; } - public string Category { get; set; } - public bool Installed - { - get - { - return Shiftorium.UpgradeInstalled(ID); - } - } - public string Dependencies { get; set; } - } - - public class ShiftoriumUpgradeAttribute : RequiresUpgradeAttribute - { - public ShiftoriumUpgradeAttribute(string name, long cost, string desc, string dependencies, string category) : base(name.ToLower().Replace(" ", "_")) - { - Name = name; - Description = desc; - Dependencies = dependencies; - Cost = cost; - Category = category; - } - - public string Name { get; private set; } - public string Description { get; private set; } - public long Cost { get; private set; } - public string Dependencies { get; private set; } - public string Category { get; private set; } - } - - public class ShiftoriumConflictException : Exception - { - public ShiftoriumConflictException() : base("An upgrade conflict has occurred while loading Shiftorium Upgrades from an assembly. Is there a duplicate upgrade ID?") - { - - } - - public ShiftoriumConflictException(string id) : base("An upgrade conflict has occurred while loading Shiftorium Upgrades from an assembly. An upgrade with the ID \"" + id + "\" has already been loaded.") - { - - } - } - - public class ShiftoriumProviderAttribute : Attribute - { - - } -} diff --git a/ShiftOS_TheReturn/Skinning.cs b/ShiftOS_TheReturn/Skinning.cs deleted file mode 100644 index b731c4f..0000000 --- a/ShiftOS_TheReturn/Skinning.cs +++ /dev/null @@ -1,1336 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -using System; -using System.Collections.Generic; -using System.Drawing; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Newtonsoft.Json; -using System.Windows.Forms; -using static ShiftOS.Engine.SaveSystem; -using ShiftOS.Objects.ShiftFS; -using System.Reflection; -using ShiftOS.Engine.Scripting; -namespace ShiftOS.Engine -{ - - [Exposed("skinning")] - public class SkinFunctions - { - public void loadSkin() - { - SkinEngine.LoadSkin(); - } - - public dynamic getSkin() - { - return SkinEngine.LoadedSkin; - } - - public void setSkin(Skin skn) - { - Utils.WriteAllText(Paths.GetPath("skin.json"), JsonConvert.SerializeObject(skn)); - SkinEngine.LoadSkin(); - } - - public dynamic getImage(string id) - { - return SkinEngine.GetImage(id); - } - } - - - public static class SkinEngine - { - public static ImageLayout GetImageLayout(string img) - { - if (LoadedSkin.SkinImageLayouts.ContainsKey(img)) - { - return LoadedSkin.SkinImageLayouts[img]; - } - else - { - LoadedSkin.SkinImageLayouts.Add(img, ImageLayout.Tile); - return ImageLayout.Tile; - } - } - - public static System.Drawing.Image GetImage(string img) - { - var type = typeof(Skin); - - foreach (var field in type.GetFields()) - { - foreach (var attr in field.GetCustomAttributes(false)) - { - if (attr is ImageAttribute) - { - var iattr = attr as ImageAttribute; - if (iattr.Name == img) - { - byte[] image = (byte[])field.GetValue(LoadedSkin); - return ImageFromBinary(image); - } - } - } - } - - return null; - } - - public static void SetIconProber(IIconProber prober) - { - _iconProber = prober; - } - - public static Image ImageFromBinary(byte[] image) - { - if (image == null) - return null; - Image img = (Bitmap)((new ImageConverter()).ConvertFrom(image)); - return img; - } - - private static Skin loadedSkin = new Skin(); - - public static Skin LoadedSkin - { - get - { - return loadedSkin; - } - private set - { - loadedSkin = value; - } - } - - public static void Init() - { - Application.ApplicationExit += (o, a) => - { - SaveSkin(); - }; - - if (!Utils.FileExists(Paths.GetPath("skin.json"))) - { - LoadedSkin = new ShiftOS.Engine.Skin(); - SaveSkin(); - } - else - { - LoadSkin(); - } - if (SaveSystem.CurrentSave != null) - { - SkinLoaded?.Invoke(); - } - } - - public static event EmptyEventHandler SkinLoaded; - - public static void LoadSkin() - { - LoadedSkin = JsonConvert.DeserializeObject(Utils.ReadAllText(Paths.GetPath("skin.json"))); - SkinLoaded?.Invoke(); - Desktop.ResetPanelButtons(); - Desktop.PopulateAppLauncher(); - } - - public static void SaveSkin() - { - Utils.WriteAllText(Paths.GetPath("skin.json"), JsonConvert.SerializeObject(LoadedSkin, Formatting.Indented)); - } - - private static IIconProber _iconProber = null; - - public static Image GetDefaultIcon(string id) - { - if (_iconProber == null) - { - return new Bitmap(16, 16); - } - else - { - foreach (var f in System.IO.Directory.GetFiles(Environment.CurrentDirectory)) - { - if (f.EndsWith(".exe") || f.EndsWith(".dll")) - { - try - { - var asm = Assembly.LoadFile(f); - foreach (var type in asm.GetTypes()) - { - if (type.Name == id) - { - foreach (var attr in type.GetCustomAttributes(true)) - { - if (attr is DefaultIconAttribute) - { - return _iconProber.GetIcon(attr as DefaultIconAttribute); - } - } - } - } - } - catch { } - } - } - return new Bitmap(16, 16); - } - } - - public static Image GetIcon(string id) - { - if (!LoadedSkin.AppIcons.ContainsKey(id)) - LoadedSkin.AppIcons.Add(id, null); - - if (LoadedSkin.AppIcons[id] == null) - return GetDefaultIcon(id); - else - { - using (var sr = new MemoryStream(LoadedSkin.AppIcons[id])) - { - return Image.FromStream(sr); - } - } - - } - } - - public interface IIconProber - { - Image GetIcon(DefaultIconAttribute attr); - } - - public class DefaultIconAttribute : Attribute - { - public DefaultIconAttribute(string id) - { - ID = id; - } - - public string ID { get; private set; } - } - - public class Skin - { - //borrowing from the discourse theme for the default skin - private static readonly Color DefaultBackground = Color.FromArgb(0, 0x44, 0x00); - private static readonly Color DefaultForeground = Color.FromArgb(0xDD, 0xDD, 0xDD); - private static readonly Color Accent1 = Color.FromArgb(0x66, 0x66, 0x66); - private static readonly Color Accent2 = Color.FromArgb(0x80, 0, 0); - private static readonly Color DesktopBG = Color.FromArgb(0x22, 0x22, 0x22); - private static readonly Font SysFont = new Font("Tahoma", 9F); - private static readonly Font SysFont2 = new Font("Tahoma", 10F, FontStyle.Bold); - private static readonly Font Header1 = new Font("Helvetica", 20F, FontStyle.Bold); - private static readonly Font Header2 = new Font("Helvetica", 17.5F, FontStyle.Bold); - private static readonly Font Header3 = new Font("Tahoma", 15F, FontStyle.Bold); - - private static readonly Color TitleBG = Color.FromArgb(0x11, 0x11, 0x11); - private static readonly Color TitleFG = Color.FromArgb(0xaa, 0xaa, 0xaa); - - //Todo: When making Shifter GUI we need to label all these with proper Shifter attributes to get 'em displaying in the right places. - - public override string ToString() - { - return JsonConvert.SerializeObject(this, Formatting.Indented); - } - - [ShifterHidden] - public Dictionary AppNames = new Dictionary(); - - [ShifterHidden] - public Dictionary AppIcons = new Dictionary(); - - [ShifterMeta("System")] - [ShifterCategory("Login Screen")] - [RequiresUpgrade("gui_based_login_screen")] - [ShifterName("Login Screen Background Color")] - [ShifterDescription("Change the background color of the login screen.")] - public Color LoginScreenColor = Skin.DesktopBG; - - [ShifterMeta("System")] - [ShifterCategory("Login Screen")] - [RequiresUpgrade("skinning;gui_based_login_screen")] - [ShifterName("Login Screen Background Image")] - [ShifterDescription("Set an image as your login screen!")] - [Image("login")] - public byte[] LoginScreenBG = null; - - - [RequiresUpgrade("shift_screensaver")] - [ShifterMeta("System")] - [ShifterCategory("Screen saver")] - [ShifterName("Screen saver wait (milliseconds)")] - [ShifterDescription("How long do you have to stay idle before the screensaver activates?")] - public int ScreensaverWait = 300000; - - [RequiresUpgrade("skinning;shift_screensaver")] - [ShifterMeta("System")] - [ShifterCategory("Screen saver")] - [ShifterName("Screen saver image")] - [ShifterDescription("What image should appear on the screen saver?")] - public byte[] ScreensaverImage = null; - - - - [ShifterMeta("Windows")] - [ShifterCategory("Titlebar")] - [RequiresUpgrade("shift_title_text")] - [ShifterName("Title Font")] - [ShifterDescription("The font style for the title text.")] - public Font TitleFont = SysFont2; - - [ShifterMeta("System")] - [ShifterCategory("General")] - [ShifterName("System Font")] - [ShifterDescription("The font style used by the system.")] - public Font MainFont = SysFont; - - [ShifterEnumMask(new[] { "Right", "Left" })] - [ShifterMeta("Windows")] - [ShifterCategory("Title Buttons")] - [ShifterName("Title button position")] - [ShifterDescription("Where should the title buttons be located?")] - public int TitleButtonPosition = 0; - - [ShifterMeta("System")] - [ShifterCategory("Header Fonts")] - [ShifterName("1st level header")] - [ShifterDescription("The font used in level 1 (title) headers.")] - public Font HeaderFont = Header1; - - - [ShifterMeta("System")] - [ShifterCategory("Header Fonts")] - [ShifterName("2nd level header")] - [ShifterDescription("The font used in level 2 (subtitle) headers.")] - public Font Header2Font = Header2; - - - [ShifterMeta("System")] - [ShifterCategory("Header Fonts")] - [ShifterName("3rd level header")] - [ShifterDescription("The font used in level 3 (section) headers.")] - public Font Header3Font = Header3; - - - - [ShifterMeta("System")] - [ShifterCategory("General")] - [ShifterName("System Background")] - [ShifterDescription("The background color of all system controls in the UI.")] - public Color ControlColor = DefaultBackground; - - [ShifterMeta("System")] - [ShifterCategory("General")] - [ShifterName("System Foreground")] - [ShifterDescription("The foreground color of all system controls in the UI.")] - public Color ControlTextColor = DefaultForeground; - - [ShifterMeta("Windows")] - [ShifterCategory("Titlebar")] - [ShifterName("Title Text Color")] - [RequiresUpgrade("shift_title_text")] - [ShifterDescription("The color of the title text.")] - public Color TitleTextColor = TitleFG; - - [ShifterMeta("Windows")] - [ShifterCategory("Titlebar")] - [ShifterName("Title Background Color")] - [RequiresUpgrade("shift_titlebar")] - [ShifterDescription("The color of the titlebar's background.")] - public Color TitleBackgroundColor = TitleBG; - - [ShifterMeta("Windows")] - [ShifterCategory("Window border")] - [ShifterName("Left Border Background")] - [RequiresUpgrade("shift_window_borders")] - [ShifterDescription("The background color for the left border.")] - public Color BorderLeftBackground = TitleBG; - - [ShifterMeta("Windows")] - [ShifterCategory("Window border")] - [ShifterName("Right Border Background")] - [RequiresUpgrade("shift_window_borders")] - [ShifterDescription("The background color for the right border.")] - public Color BorderRightBackground = TitleBG; - - [ShifterMeta("Desktop")] - [ShifterCategory("Panel buttons")] - [RequiresUpgrade("shift_panel_buttons")] - [ShifterName("Panel buttons from top")] - [ShifterDescription("How far from the top should the panel buttons be?")] - public int PanelButtonFromTop = 2; - - [ShifterMeta("Windows")] - [ShifterCategory("Window border")] - [ShifterName("Bottom Border Background")] - [RequiresUpgrade("shift_window_borders")] - [ShifterDescription("The background color for the bottom border.")] - public Color BorderBottomBackground = TitleBG; - - [ShifterMeta("Desktop")] - [ShifterCategory("Panel buttons")] - [ShifterName("Panel button holder from left")] - [ShifterDescription("How far from the left should the panel button holder be?")] - [RequiresUpgrade("shift_panel_buttons")] - public int PanelButtonHolderFromLeft = 100; - - [ShifterMeta("Windows")] - [ShifterCategory("Window border")] - [ShifterName("Bottom Left Border Background")] - [RequiresUpgrade("shift_window_borders")] - [ShifterDescription("The background color for the bottom left border.")] - public Color BorderBottomLeftBackground = TitleBG; - - [ShifterMeta("Windows")] - [ShifterCategory("Window border")] - [ShifterName("Bottom Right Border Background")] - [RequiresUpgrade("shift_window_borders")] - [ShifterDescription("The background color for the bottom right border.")] - public Color BorderBottomRightBackground = TitleBG; - - [ShifterMeta("Windows")] - [ShifterCategory("Title Buttons")] - [ShifterName("Close Button Color")] - [RequiresUpgrade("shift_title_buttons")] - [ShifterDescription("The close button color")] - public Color CloseButtonColor = Accent2; - - [ShifterMeta("Windows")] - [ShifterCategory("Title Buttons")] - [ShifterName("Maximize Button Color")] - [RequiresUpgrade("shift_title_buttons")] - [ShifterDescription("The maximize button color")] - public Color MaximizeButtonColor = Accent1; - - [ShifterMeta("Windows")] - [ShifterCategory("Title Buttons")] - [ShifterName("Minimize Button Color")] - [RequiresUpgrade("shift_title_buttons")] - [ShifterDescription("The minimize button color")] - public Color MinimizeButtonColor = Accent1; - - [ShifterMeta("Desktop")] - [ShifterCategory("Desktop Panel")] - [ShifterName("Panel Background")] - [RequiresUpgrade("shift_desktop_panel")] - [ShifterDescription("The background color used by the desktop panel")] - public Color DesktopPanelColor = TitleBG; - - [ShifterMeta("Desktop")] - [ShifterCategory("Desktop Panel")] - [ShifterName("Panel Clock Text Color")] - [RequiresUpgrade("shift_panel_clock")] - [ShifterDescription("The text color used by the desktop panel's clock.")] - public Color DesktopPanelClockColor = TitleFG; - - [ShifterMeta("Desktop")] - [ShifterCategory("Desktop Panel")] - [ShifterName("Panel Clock Background Color")] - [RequiresUpgrade("shift_panel_clock")] - [ShifterDescription("The background color used by the desktop panel's clock.")] - public Color DesktopPanelClockBackgroundColor = TitleBG; - - [ShifterMeta("Desktop")] - [ShifterCategory("Desktop Panel")] - [ShifterName("Panel Clock Font")] - [RequiresUpgrade("shift_panel_clock")] - [ShifterDescription("The font used by the desktop panel's clock.")] - public Font DesktopPanelClockFont = Skin.SysFont2; - - [ShifterMeta("Desktop")] - [ShifterCategory("Desktop Panel")] - [ShifterName("Panel Clock From Right")] - [RequiresUpgrade("shift_panel_clock")] - [ShifterDescription("The position in pixels relative to the width of the desktop panel that the clock will sit at.")] - public Point DesktopPanelClockFromRight = new Point(2, 2); - - - [ShifterMeta("Desktop")] - [ShifterCategory("Desktop Panel")] - [ShifterName("Panel Height")] - [RequiresUpgrade("shift_desktop_panel")] - [ShifterDescription("The height in pixels of the desktop panel.")] - public int DesktopPanelHeight = 24; - - [ShifterMeta("Desktop")] - [ShifterCategory("Desktop Panel")] - [ShifterName("Panel Position")] - [ShifterEnumMask(new[] { "Top", "Bottom" })] - [RequiresUpgrade("shift_desktop_panel")] - [ShifterDescription("The position of the desktop panel.")] - public int DesktopPanelPosition = 0; - - [ShifterMeta("Windows")] - [ShifterCategory("Titlebar")] - [ShifterName("Titlebar Height")] - [RequiresUpgrade("shift_titlebar")] - [ShifterDescription("The height of the titlebar.")] - public int TitlebarHeight = 30; - - [ShifterMeta("Windows")] - [ShifterCategory("Title Buttons")] - [ShifterName("Close Button Size")] - [RequiresUpgrade("shift_title_buttons")] - [ShifterDescription("The close button size")] - public Size CloseButtonSize = new Size(24, 24); - - [ShifterMeta("Windows")] - [ShifterCategory("Title Buttons")] - [ShifterName("Maximize Button Size")] - [RequiresUpgrade("shift_title_buttons")] - [ShifterDescription("The maximize button size")] - public Size MaximizeButtonSize = new Size(24, 24); - - [ShifterMeta("Windows")] - [ShifterCategory("Title Buttons")] - [ShifterName("Minimize Button Size")] - [RequiresUpgrade("shift_title_buttons")] - [ShifterDescription("The minimize button size")] - public Size MinimizeButtonSize = new Size(24, 24); - - [ShifterMeta("Windows")] - [ShifterCategory("Title Buttons")] - [ShifterName("Close Button From Right")] - [RequiresUpgrade("shift_title_buttons")] - [ShifterDescription("The close button location from the right of the titlebar.")] - public Point CloseButtonFromSide = new Point(3, (30 - 24) / 2); - - [ShifterMeta("Windows")] - [ShifterCategory("Title Buttons")] - [ShifterName("Maximize Button From Right")] - [RequiresUpgrade("shift_title_buttons")] - [ShifterDescription("The maximize button location from the right of the titlebar.")] - public Point MaximizeButtonFromSide = new Point(24 + 6, (30 - 24) / 2); - - [ShifterMeta("Windows")] - [ShifterCategory("Title Buttons")] - [ShifterName("Minimize Button From Right")] - [RequiresUpgrade("shift_title_buttons")] - [ShifterDescription("The minimize button location from the right of the titlebar.")] - public Point MinimizeButtonFromSide = new Point(48 + 9, (30 - 24) / 2); - - [ShifterMeta("Windows")] - [ShifterCategory("Titlebar")] - [ShifterName("Title text centered?")] - [RequiresUpgrade("shift_title_text")] - [ShifterDescription("Is the title text centered?")] - public bool TitleTextCentered = false; - - [ShifterMeta("Windows")] - [ShifterCategory("Titlebar")] - [ShifterName("Title Text From Left")] - [ShifterFlag("TitleTextCentered", false)] - [RequiresUpgrade("shift_title_text")] - [ShifterDescription("The title text location from the left of the titlebar.")] - public Point TitleTextLeft = new Point(4, 4); - - [ShifterMeta("Desktop")] - [ShifterCategory("General")] - [ShifterName("Desktop Background Color")] - [ShifterDescription("The background color of the desktop.")] - public Color DesktopColor = DesktopBG; - - [ShifterMeta("Menus")] - [ShifterCategory("Toolbars")] - [ShifterName("Button select highlight")] - public Color Menu_ButtonSelectedHighlight = Accent2; - - [ShifterMeta("Menus")] - [ShifterCategory("Toolbars")] - [ShifterName("Button select border")] - public Color Menu_ButtonSelectedHighlightBorder = Accent2; - - [ShifterMeta("Menus")] - [ShifterCategory("Toolbars")] - [ShifterName("Button pressed highlight")] - public Color Menu_ButtonPressedHighlight = Accent1; - - [ShifterMeta("Menus")] - [ShifterCategory("Toolbars")] - [ShifterName("Button pressed border")] - public Color Menu_ButtonPressedHighlightBorder = Accent1; - - [ShifterMeta("Menus")] - [ShifterCategory("Toolbars")] - [ShifterName("Button checked highlight")] - public Color Menu_ButtonCheckedHighlight = Accent1; - - [ShifterMeta("Menus")] - [ShifterCategory("Toolbars")] - [ShifterName("Button checked border")] - public Color Menu_ButtonCheckedHighlightBorder = Accent1; - - [ShifterMeta("Menus")] - [ShifterCategory("Toolbars")] - [ShifterName("Button pressed gradient border")] - public Color Menu_ButtonPressedBorder = Accent1; - - [ShifterMeta("Menus")] - [ShifterCategory("Toolbars")] - [ShifterName("Button selected gradient border")] - public Color Menu_ButtonSelectedBorder = Accent2; - - [ShifterMeta("Menus")] - [ShifterCategory("Toolbars")] - [ShifterName("Button checked gradient start")] - public Color Menu_ButtonCheckedGradientBegin = Accent1; - - [ShifterMeta("Menus")] - [ShifterCategory("Toolbars")] - [ShifterName("Button checked gradient middle")] - public Color Menu_ButtonCheckedGradientMiddle = Accent1; - - [ShifterMeta("Menus")] - [ShifterCategory("Toolbars")] - [ShifterName("Button checked gradient end")] - public Color Menu_ButtonCheckedGradientEnd = Accent1; - - [ShifterMeta("Menus")] - [ShifterCategory("Toolbars")] - [ShifterName("Button selected gradient start")] - public Color Menu_ButtonSelectedGradientBegin = Accent2; - - [ShifterMeta("Menus")] - [ShifterCategory("Toolbars")] - [ShifterName("Button selected gradient middle")] - public Color Menu_ButtonSelectedGradientMiddle = Accent2; - - [ShifterMeta("Menus")] - [ShifterCategory("Toolbars")] - [ShifterName("Button selected gradient end")] - public Color Menu_ButtonSelectedGradientEnd = Accent2; - - [ShifterMeta("Menus")] - [ShifterCategory("Toolbars")] - [ShifterName("Button pressed gradient start")] - public Color Menu_ButtonPressedGradientBegin = Accent1; - - [ShifterMeta("Menus")] - [ShifterCategory("Toolbars")] - [ShifterName("Button pressed gradient middle")] - public Color Menu_ButtonPressedGradientMiddle = Accent1; - - [ShifterMeta("Menus")] - [ShifterCategory("Toolbars")] - [ShifterName("Button pressed gradient end")] - public Color Menu_ButtonPressedGradientEnd = Accent1; - - [ShifterMeta("Menus")] - [ShifterCategory("General")] - [ShifterName("Check BG")] - public Color Menu_CheckBackground = Skin.TitleBG; - - [ShifterMeta("Menus")] - [ShifterCategory("General")] - [ShifterName("Check BG (Selected)")] - public Color Menu_CheckSelectedBackground = Accent2; - - [ShifterMeta("Menus")] - [ShifterCategory("General")] - [ShifterName("Check BG (Pressed)")] - public Color Menu_CheckPressedBackground = Accent1; - - [ShifterMeta("Menus")] - [ShifterCategory("Menu bars")] - [ShifterName("Margin gradient start")] - public Color Menu_ImageMarginGradientBegin = TitleBG; - - [ShifterMeta("Menus")] - [ShifterCategory("Menu bars")] - [ShifterName("Margin gradient middle")] - public Color Menu_ImageMarginGradientMiddle = TitleBG; - - [ShifterMeta("Menus")] - [ShifterCategory("Menu bars")] - [ShifterName("Margin gradient end")] - public Color Menu_ImageMarginGradientEnd = TitleBG; - - [ShifterMeta("Menus")] - [ShifterCategory("Menu bars")] - [ShifterName("Menu gradient start")] - public Color Menu_MenuStripGradientBegin = TitleBG; - - [ShifterMeta("Menus")] - [ShifterCategory("Menu bars")] - [ShifterName("Menu gradient end")] - public Color Menu_MenuStripGradientEnd = TitleBG; - - [ShifterMeta("Menus")] - [ShifterCategory("Menu bars")] - [ShifterName("Menu item selected")] - public Color Menu_MenuItemSelected = Accent2; - - [ShifterMeta("Menus")] - [ShifterCategory("Menu bars")] - [ShifterName("Menu item border")] - public Color Menu_MenuItemBorder = DefaultBackground; - - [ShifterMeta("Menus")] - [ShifterCategory("Menu bars")] - [ShifterName("Menu border")] - public Color Menu_MenuBorder = DefaultBackground; - - [ShifterMeta("Menus")] - [ShifterCategory("Toolbars")] - [ShifterName("Menu item selected gradient start")] - public Color Menu_MenuItemSelectedGradientBegin = Accent2; - - [ShifterMeta("Menus")] - [ShifterCategory("Toolbars")] - [ShifterName("Menu item selected gradient end")] - public Color Menu_MenuItemSelectedGradientEnd = Accent2; - - [ShifterMeta("Menus")] - [ShifterCategory("Toolbars")] - [ShifterName("Menu item pressed gradient start")] - public Color Menu_MenuItemPressedGradientBegin = Accent1; - - [ShifterMeta("Menus")] - [ShifterCategory("Toolbars")] - [ShifterName("Menu item pressed gradient middle")] - public Color Menu_MenuItemPressedGradientMiddle = Accent1; - - [ShifterMeta("Menus")] - [ShifterCategory("Toolbars")] - [ShifterName("Menu item pressed gradient end")] - public Color Menu_MenuItemPressedGradientEnd = Accent1; - - [ShifterMeta("Menus")] - [ShifterCategory("General")] - [ShifterName("Rafter gradient start")] - public Color Menu_RaftingContainerGradientBegin = TitleBG; - - [ShifterMeta("Menus")] - [ShifterCategory("General")] - [ShifterName("Rafter gradient end")] - public Color Menu_RaftingContainerGradientEnd = TitleBG; - - [ShifterMeta("Menus")] - [ShifterCategory("General")] - [ShifterName("Separator Color 1")] - public Color Menu_SeparatorDark = DefaultForeground; - - [ShifterMeta("Menus")] - [ShifterCategory("General")] - [ShifterName("Separator Color 2")] - public Color Menu_SeparatorLight = TitleFG; - - [ShifterMeta("Menus")] - [ShifterCategory("Status bars")] - [ShifterName("Status bar gradient start")] - public Color Menu_StatusStripGradientBegin = TitleBG; - - [ShifterMeta("Menus")] - [ShifterCategory("Status bars")] - [ShifterName("Status bar gradient end")] - public Color Menu_StatusStripGradientEnd = TitleBG; - - [ShifterMeta("Menus")] - [ShifterCategory("Toolbars")] - [ShifterName("Toolbar Border")] - public Color Menu_ToolStripBorder = TitleBG; - - [ShifterMeta("Menus")] - [ShifterCategory("Toolbars")] - [ShifterName("Dropdown background")] - public Color Menu_ToolStripDropDownBackground = DefaultBackground; - - [ShifterMeta("Menus")] - [ShifterCategory("Toolbars")] - [ShifterName("Toolbar gradient start")] - public Color Menu_ToolStripGradientBegin = TitleBG; - - [ShifterMeta("Menus")] - [ShifterCategory("Toolbars")] - [ShifterName("Toolbar gradient middle")] - public Color Menu_ToolStripGradientMiddle = TitleBG; - - [ShifterMeta("Menus")] - [ShifterCategory("Toolbars")] - [ShifterName("Toolbar gradient end")] - public Color Menu_ToolStripGradientEnd = TitleBG; - - [ShifterMeta("Menus")] - [ShifterCategory("Menu holders")] - [ShifterName("Content panel gradient start")] - public Color Menu_ToolStripContentPanelGradientBegin = TitleBG; - - [ShifterMeta("Menus")] - [ShifterCategory("Menu holders")] - [ShifterName("Content panel gradient end")] - public Color Menu_ToolStripContentPanelGradientEnd = TitleBG; - - [ShifterMeta("Menus")] - [ShifterCategory("Menu holders")] - [ShifterName("Panel gradient start")] - public Color Menu_ToolStripPanelGradientBegin = TitleBG; - - [ShifterMeta("Menus")] - [ShifterCategory("Menu holders")] - [ShifterName("Panel gradient end")] - public Color Menu_ToolStripPanelGradientEnd = TitleBG; - - [ShifterMeta("Menus")] - [ShifterCategory("General")] - [ShifterName("Menu text color")] - public Color Menu_TextColor = DefaultForeground; - - [ShifterMeta("Menus")] - [ShifterCategory("General")] - [ShifterName("Menu selected text color")] - public Color Menu_SelectedTextColor = TitleFG; - - - - //Images - [Image("closebutton")] - [ShifterMeta("Windows")] - [ShifterCategory("Title Buttons")] - [ShifterName("Close Button Image")] - [RequiresUpgrade("shift_title_buttons;skinning")] - [ShifterDescription("Show an image on the Close Button using this setting.")] - public byte[] CloseButtonImage = null; - - [Image("minimizebutton")] - [ShifterMeta("Windows")] - [ShifterCategory("Title Buttons")] - [ShifterName("Minimize Button Image")] - [RequiresUpgrade("shift_title_buttons;skinning")] - [ShifterDescription("Show an image on the Minimize Button using this setting.")] - public byte[] MinimizeButtonImage = null; - - [Image("maximizebutton")] - [ShifterMeta("Windows")] - [ShifterCategory("Title Buttons")] - [ShifterName("Maximize Button Image")] - [RequiresUpgrade("shift_title_buttons;skinning")] - [ShifterDescription("Show an image on the Maximize Button using this setting.")] - public byte[] MaximizeButtonImage = null; - - [Image("desktopbackground")] - [ShifterMeta("Desktop")] - [ShifterCategory("General")] - [ShifterName("Desktop Background Image")] - [RequiresUpgrade("skinning")] - [ShifterDescription("Use an image as your desktop background.")] - public byte[] DesktopBackgroundImage = null; - - [ShifterMeta("Desktop")] - [ShifterCategory("App Launcher")] - [RequiresUpgrade("shift_app_launcher")] - [ShifterName("App Launcher Text Color")] - [ShifterDescription("Change the color of the App Launcher text.")] - public Color AppLauncherTextColor = Skin.DefaultForeground; - - [ShifterMeta("Desktop")] - [ShifterCategory("App Launcher")] - [RequiresUpgrade("shift_app_launcher")] - [ShifterName("App Launcher Selected Text Color")] - [ShifterDescription("Change the color of the app launcher's text while it is selected.")] - public Color AppLauncherSelectedTextColor = Skin.TitleFG; - - [ShifterMeta("Desktop")] - [ShifterCategory("App Launcher")] - [RequiresUpgrade("shift_app_launcher")] - [ShifterName("App Launcher Font")] - [ShifterDescription("Change the font that the App Launcher text is displayed in.")] - public Font AppLauncherFont = Skin.SysFont2; - - - [ShifterMeta("Desktop")] - [ShifterCategory("App Launcher")] - [ShifterName("App launcher text")] - [ShifterDescription("The text displayed on the app launcher.")] - [RequiresUpgrade("shift_app_launcher")] - public string AppLauncherText = "ShiftOS"; - - [ShifterMeta("Desktop")] - [ShifterCategory("App Launcher")] - [ShifterName("App launcher from left")] - [ShifterDescription("The position of the app launcher from the left of the Desktop Panel.")] - [RequiresUpgrade("shift_app_launcher")] - public Point AppLauncherFromLeft = new Point(0, 0); - - [ShifterMeta("Desktop")] - [ShifterCategory("App Launcher")] - [ShifterName("App launcher size")] - [ShifterDescription("The size of the app launcher.")] - [RequiresUpgrade("shift_app_launcher")] - public Size AppLauncherHolderSize = new Size(100, 24); - - [ShifterMeta("Desktop")] - [ShifterCategory("App Launcher")] - [ShifterName("App launcher image")] - [ShifterDescription("The image that will appear on the app launcher.")] - [Image("applauncher")] - [RequiresUpgrade("skinning;shift_app_launcher")] - public byte[] AppLauncherImage = null; - - [ShifterMeta("System")] - [ShifterCategory("General")] - [ShifterName("Terminal font")] - public Font TerminalFont = new Font("Lucida Console", 9F, FontStyle.Regular); - - [ShifterMeta("System")] - [ShifterCategory("General")] - [ShifterName("Terminal text color")] - public ConsoleColor TerminalForeColorCC = ConsoleColor.White; - - [ShifterMeta("System")] - [ShifterCategory("General")] - [ShifterName("Terminal background color")] - public ConsoleColor TerminalBackColorCC = ConsoleColor.Black; - - [ShifterMeta("Desktop")] - [ShifterCategory("Desktop Panel")] - [ShifterName("Panel background image")] - [Image("desktoppanel")] - [RequiresUpgrade("skinning;shift_desktop_panel")] - public byte[] DesktopPanelBackground = null; - - [ShifterMeta("Windows")] - [ShifterCategory("Titlebar")] - [ShifterName("Titlebar background image")] - [Image("titlebar")] - [RequiresUpgrade("skinning;shift_titlebar")] - public byte[] TitleBarBackground = null; - - [ShifterMeta("Windows")] - [ShifterCategory("Titlebar")] - [RequiresUpgrade("shift_titlebar")] - [ShifterName("Show title corners?")] - [ShifterDescription("If checked, a left and a right section will appear on the titlebar which is useful for rounded corners, padding, or other useful properties.")] - public bool ShowTitleCorners = false; - - [ShifterMeta("Windows")] - [ShifterCategory("Titlebar")] - [RequiresUpgrade("shift_titlebar")] - [ShifterFlag("ShowTitleCorners", true)] - [ShifterName("Title left background color")] - [ShifterDescription("What color should be used for the left title corner?")] - public Color TitleLeftCornerBackground = TitleBG; - - [ShifterMeta("Windows")] - [ShifterCategory("Titlebar")] - [RequiresUpgrade("shift_titlebar")] - [ShifterFlag("ShowTitleCorners", true)] - [ShifterName("Title right background color")] - [ShifterDescription("What color should be used for the right title corner?")] - public Color TitleRightCornerBackground = TitleBG; - - [ShifterMeta("Windows")] - [ShifterCategory("Titlebar")] - [RequiresUpgrade("shift_titlebar")] - [ShifterFlag("ShowTitleCorners", true)] - [ShifterName("Title left corner width")] - [ShifterDescription("How wide should the left title corner be?")] - public int TitleLeftCornerWidth = 2; - - [ShifterMeta("Windows")] - [ShifterCategory("Titlebar")] - [RequiresUpgrade("shift_titlebar")] - [ShifterFlag("ShowTitleCorners", true)] - [ShifterName("Title right corner width")] - [ShifterDescription("How wide should the right title corner be?")] - public int TitleRightCornerWidth = 2; - - [ShifterMeta("Windows")] - [ShifterCategory("Titlebar")] - [RequiresUpgrade("skinning;shift_titlebar")] - [ShifterFlag("ShowTitleCorners", true)] - [ShifterName("Title left corner background image")] - [ShifterDescription("Select an image to appear as the background texture for the left titlebar corner.")] - [Image("titleleft")] - public byte[] TitleLeftBG = null; - - [ShifterMeta("Windows")] - [ShifterCategory("Titlebar")] - [RequiresUpgrade("skinning;shift_titlebar")] - [ShifterFlag("ShowTitleCorners", true)] - [ShifterName("Title right corner background image")] - [ShifterDescription("Select an image to appear as the background texture for the right titlebar corner.")] - [Image("titleright")] - public byte[] TitleRightBG = null; - - - [ShifterMeta("System")] - [ShifterCategory("General")] - [ShifterName("System color key-out")] - [ShifterDescription("This is a color that will be represented as \"transparent\" in windows. This does not affect the desktop.")] - public Color SystemKey = Color.FromArgb(1, 0, 1); - - [ShifterMeta("Windows")] - [ShifterCategory("Window border")] - [RequiresUpgrade("skinning;shift_window_borders")] - [Image("bottomborder")] - [ShifterName("Bottom Border Image")] - [ShifterDescription("Select an image to appear on the bottom border.")] - public byte[] BottomBorderBG = null; - - [ShifterMeta("Windows")] - [ShifterCategory("Window border")] - [RequiresUpgrade("skinning;shift_window_borders")] - [Image("bottomrborder")] - [ShifterName("Bottom Right Border Image")] - [ShifterDescription("Select an image to appear on the bottom right border.")] - public byte[] BottomRBorderBG = null; - - [ShifterMeta("Windows")] - [ShifterCategory("Window border")] - [RequiresUpgrade("skinning;shift_window_borders")] - [Image("bottomlborder")] - [ShifterName("Bottom Left Border Image")] - [ShifterDescription("Select an image to appear on the bottom left border.")] - public byte[] BottomLBorderBG = null; - - [ShifterMeta("Windows")] - [ShifterCategory("Window border")] - [RequiresUpgrade("skinning;shift_window_borders")] - [Image("leftborder")] - [ShifterName("Left Border Image")] - [ShifterDescription("Select an image to appear on the left border.")] - public byte[] LeftBorderBG = null; - - [ShifterMeta("Windows")] - [ShifterCategory("Window border")] - [RequiresUpgrade("skinning;shift_window_borders")] - [Image("rightborder")] - [ShifterName("Right Border Image")] - [ShifterDescription("Select an image to appear on the right border.")] - public byte[] RightBorderBG = null; - - [ShifterMeta("Windows")] - [ShifterCategory("Window border")] - [RequiresUpgrade("shift_window_borders")] - [ShifterName("Left border width")] - [ShifterDescription("How wide should the left border be?")] - public int LeftBorderWidth = 2; - - [ShifterMeta("Windows")] - [ShifterCategory("Window border")] - [RequiresUpgrade("shift_window_borders")] - [ShifterName("Right border width")] - [ShifterDescription("How wide should the right border be?")] - public int RightBorderWidth = 2; - - [ShifterMeta("Windows")] - [ShifterCategory("Window border")] - [RequiresUpgrade("shift_window_borders")] - [ShifterName("Bottom border height")] - [ShifterDescription("How tall should the bottom border be?")] - public int BottomBorderWidth = 2; - - [Image("panelbutton")] - [ShifterMeta("Desktop")] - [ShifterCategory("Panel buttons")] - [RequiresUpgrade("skinning;shift_panel_buttons")] - [ShifterName("Panel button background image")] - [ShifterDescription("Select a texture to display as the panel button background.")] - public byte[] PanelButtonBG = null; - - [ShifterMeta("Desktop")] - [ShifterCategory("Panel buttons")] - [RequiresUpgrade("shift_panel_buttons")] - [ShifterName("Panel button size")] - [ShifterDescription("How big should the panel button be?")] - public Size PanelButtonSize = new Size(185, 20); - - [ShifterMeta("Desktop")] - [ShifterCategory("Panel buttons")] - [RequiresUpgrade("shift_panel_buttons")] - [ShifterName("Panel button background color")] - [ShifterDescription("Select a background color for the panel button.")] - public Color PanelButtonColor = Skin.Accent2; - - [ShifterMeta("Desktop")] - [ShifterCategory("Panel buttons")] - [RequiresUpgrade("shift_panel_buttons")] - [ShifterName("Panel button text color")] - [ShifterDescription("Select a text color for the panel button.")] - public Color PanelButtonTextColor = Skin.TitleFG; - - [ShifterMeta("Desktop")] - [ShifterCategory("Panel buttons")] - [RequiresUpgrade("shift_panel_buttons")] - [ShifterName("Panel button text from left")] - [ShifterDescription("The position relative to the panel button left in pixels that the text is placed at.")] - public Point PanelButtonFromLeft = new Point(2, 2); - - [ShifterMeta("Desktop")] - [ShifterCategory("Panel buttons")] - [RequiresUpgrade("shift_panel_buttons")] - [ShifterName("Panel button font")] - [ShifterDescription("Select a font for the panel button.")] - public Font PanelButtonFont = Skin.SysFont2; - - - //we DO NOT want this showing in the shifter. - [ShifterHidden] - public Dictionary SkinImageLayouts = new Dictionary(); - - [ShifterMeta("Windows")] - [ShifterCategory("Titlebar")] - [ShifterName("App icon from side")] - [ShifterDescription("How far from the side should the icon be?")] - [RequiresUpgrade("shift_titlebar;app_icons")] - public Point TitlebarIconFromSide = new Point(4, 4); - - [ShifterMeta("Desktop")] - [ShifterCategory("App Launcher")] - [RequiresUpgrade("shift_advanced_app_launcher")] - [ShifterName("Status Panel Font")] - [ShifterDescription("The font used by the status panel in the Advanced App Launcher.")] - public Font ALStatusPanelFont = SysFont; - - [ShifterMeta("Desktop")] - [ShifterCategory("App Launcher")] - [RequiresUpgrade("shift_advanced_app_launcher")] - [ShifterName("Status Panel Text Color")] - [ShifterDescription("The text color for the AL status panel.")] - public Color ALStatusPanelTextColor = Skin.DefaultForeground; - - [ShifterMeta("Desktop")] - [ShifterCategory("App Launcher")] - [RequiresUpgrade("shift_advanced_app_launcher")] - [ShifterName("Status Panel Background")] - [ShifterDescription("The status panel's background color.")] - public Color ALStatusPanelBackColor = TitleBG; - - [ShifterMeta("Desktop")] - [ShifterCategory("App Launcher")] - [RequiresUpgrade("shift_advanced_app_launcher")] - [ShifterName("Status Panel Text Alignment")] - [ShifterDescription("What part of the panel should the status text stick to?")] - public ContentAlignment ALStatusPanelAlignment = ContentAlignment.MiddleCenter; - - - [ShifterMeta("Desktop")] - [ShifterCategory("App Launcher")] - [RequiresUpgrade("shift_advanced_app_launcher")] - [ShifterName("AL System Status Height")] - [ShifterDescription("Set the height of the top system status bar in the App Launcher.")] - public int ALSystemStatusHeight = 50; - - [ShifterMeta("Desktop")] - [ShifterCategory("App Launcher")] - [RequiresUpgrade("shift_advanced_app_launcher")] - [ShifterName("AL Size")] - [ShifterDescription("Set the size of the App Launcher's container")] - public Size AALSize = new Size(425, 500); - - [ShifterMeta("Desktop")] - [ShifterCategory("App Launcher")] - [RequiresUpgrade("shift_advanced_app_launcher")] - [ShifterName("AL Category View Width")] - [ShifterDescription("Set the width of the left Category Listing on the app launcher.")] - public int AALCategoryViewWidth = 237; - - [ShifterMeta("Desktop")] - [ShifterCategory("App Launcher")] - [RequiresUpgrade("shift_advanced_app_launcher")] - [ShifterName("AL Item List Width")] - [ShifterDescription("Set the width of the item list in the app launcher.")] - public int AALItemViewWidth = 237; - - [ShifterMeta("Desktop")] - [ShifterCategory("App Launcher")] - [RequiresUpgrade("shift_advanced_app_launcher")] - [ShifterName("AL System Actions Height")] - [ShifterDescription("Set the height of the bottom system actions bar in the App Launcher.")] - public int ALSystemActionHeight = 30; - - [ShifterMeta("Desktop")] - [ShifterCategory("App Launcher")] - [RequiresUpgrade("skinning;shift_advanced_app_launcher")] - [ShifterName("Status Panel Background Image")] - [ShifterDescription("Use an image for the App Launcher Status Panel")] - [Image("al_bg_status")] - public byte[] ALStatusPanelBG = null; - - [ShifterMeta("Desktop")] - [ShifterCategory("App Launcher")] - [RequiresUpgrade("shift_advanced_app_launcher")] - [ShifterEnumMask(new[] { "Button, bottom panel", "Button, top panel", "Category Item" })] - [ShifterName("Shutdown Button position")] - [ShifterDescription("Change the position and layout of the App Launcher Shutdown button.")] - public int ShutdownButtonStyle = 0; - - [ShifterMeta("Desktop")] - [ShifterCategory("App Launcher")] - [RequiresUpgrade("shift_advanced_app_launcher")] - [ShifterName("Shutdown Button from side")] - [ShifterDescription("The location relative to the side of the system panel that the shutdown button should reside from.")] - public Point ShutdownButtonFromSide = new Point(2, 2); - - [ShifterMeta("Desktop")] - [ShifterCategory("App Launcher")] - [RequiresUpgrade("shift_advanced_app_launcher")] - [ShifterName("Align shutdown button to left?")] - [ShifterDescription("Should the location of the shutdown button be calculated relative to the left of the system panel?")] - public bool ShutdownOnLeft = false; - - [ShifterMeta("Desktop")] - [ShifterCategory("App Launcher")] - [RequiresUpgrade("shift_advanced_app_launcher")] - [ShifterName("Shutdown Button Font")] - [ShifterDescription("The font of the Shutdown Button")] - public Font ShutdownFont = SysFont; - - [ShifterMeta("Desktop")] - [ShifterCategory("App Launcher")] - [RequiresUpgrade("shift_advanced_app_launcher")] - [ShifterName("Shutdown Text Color")] - [ShifterDescription("The foreground color of the Shutdown button")] - public Color ShutdownForeColor = DefaultForeground; - - [ShifterMeta("Desktop")] - [ShifterCategory("App Launcher")] - [RequiresUpgrade("shift_advanced_app_launcher")] - [ShifterName("System Panel background color")] - [ShifterDescription("The background color of the App Launcher System Panel.")] - public Color SystemPanelBackground = TitleBG; - - [ShifterMeta("Desktop")] - [ShifterCategory("App Launcher")] - [RequiresUpgrade("skinning;shift_advanced_app_launcher")] - [ShifterName("System Panel Background Image")] - [ShifterDescription("The background image of the System Panel.")] - [Image("al_bg_system")] - public byte[] SystemPanelBG = null; - - [ShifterMeta("Desktop")] - [ShifterCategory("App Launcher")] - [RequiresUpgrade("shift_advanced_app_launcher")] - [ShifterName("App Launcher Item Font")] - [ShifterDescription("Select the font to use for the items in the App Launcher.")] - public Font AdvALItemFont = SysFont2; - } - - public class ShifterHiddenAttribute : Attribute - { - - } - - public class ShifterFlagAttribute : Attribute - { - public ShifterFlagAttribute(string flag, bool expected) - { - Expected = expected; - Flag = flag; - } - - public bool Expected { get; set; } - public string Flag { get; set; } - public bool IsTrue(Skin skn) - { - foreach (var f in skn.GetType().GetFields()) - { - if (f.Name == Flag) - { - if (f.FieldType == typeof(bool)) - { - return (bool)f.GetValue(skn) == Expected; - } - } - } - throw new ArgumentException("The flag attribute was given an incorrect flag variable name."); - } - } - - public class ImageAttribute : Attribute - { - /// - /// Attribute a byte array within the Skin object with this attribute and the engine and Shifter will see it as an image and you'll be able to grab the image by calling SkinEngine.GetImage() passing the name you input here. - /// - /// The name you want to reference this image as in the code. - public ImageAttribute(string name) - { - Name = name; - } - - public string Name { get; set; } - } - - - public class ShifterEnumMaskAttribute : Attribute - { - public ShifterEnumMaskAttribute(string[] items) - { - Items = items; - } - - public string[] Items { get; set; } - } - - - - public class ShifterNameAttribute : Attribute - { - public ShifterNameAttribute(string name) - { - Name = name; - } - - public string Name { get; set; } - } - - public class ShifterDescriptionAttribute : Attribute - { - public ShifterDescriptionAttribute(string description) - { - Description = description; - } - - public string Description { get; set; } - } - - public class ShifterCategoryAttribute : Attribute - { - - public ShifterCategoryAttribute(string category) - { - Category = category; - } - - public string Category { get; set; } - } - - public class ShifterMetaAttribute : Attribute - { - - public ShifterMetaAttribute(string meta) - { - Meta = meta; - } - - public string Meta { get; set; } - } -} \ No newline at end of file diff --git a/ShiftOS_TheReturn/Story.cs b/ShiftOS_TheReturn/Story.cs deleted file mode 100644 index 8c726ed..0000000 --- a/ShiftOS_TheReturn/Story.cs +++ /dev/null @@ -1,328 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using Newtonsoft.Json; - -namespace ShiftOS.Engine -{ - public class Story - { - public static void Start(string stid) - { - foreach (var exec in System.IO.Directory.GetFiles(Environment.CurrentDirectory)) - { - if(exec.EndsWith(".exe") || exec.EndsWith(".dll")) - { - try - { - if (SaveSystem.CurrentSave.StoriesExperienced == null) - SaveSystem.CurrentSave.StoriesExperienced = new List(); - var asm = Assembly.LoadFile(exec); - foreach(var type in asm.GetTypes()) - { - foreach(var mth in type.GetMethods(BindingFlags.Public | BindingFlags.Static)) - { - foreach(var attrib in mth.GetCustomAttributes(false)) - { - if(attrib is StoryAttribute) - { - var story = attrib as StoryAttribute; - if(story.StoryID == stid) - { - mth.Invoke(null, null); - SaveSystem.CurrentSave.StoriesExperienced.Add(stid); - return; - } - } - } - } - } - } - catch (Exception ex) { throw ex; } - } - } -#if DEBUG - throw new ArgumentException("Story ID not found: " + stid + " - Talk to Michael. NOW."); -#else - Debug.Print("No such story: " + stid); -#endif - } - - - public static void RunFromInternalResource(string resource_id) - { - var t = typeof(Properties.Resources); - - foreach(var prop in t.GetProperties(System.Reflection.BindingFlags.NonPublic | BindingFlags.Static)) - { - if(prop.Name == resource_id) - { - if(prop.PropertyType == typeof(string)) - { - WriteStory(prop.GetValue(null) as string); - - return; - } - } - } - throw new ArgumentException("Couldn't find resource ID inside the engine: " + resource_id); - } - - - public string Character { get; set; } - public List Lines { get; set; } - - public static void Start() - { - Console.WriteLine(); - if(SaveSystem.CurrentSave.StoryPosition == 5) - { - StartDevXLies(); - } - } - - public static void StartDevXLies() - { - int chatProgress = 0; - //bool LoopStuck = false; - string textToWrite = ""; - const int TYPE_SPEED_MS = 45; - bool done = false; - bool write = true; - - while (done == false) { - write = true; - switch (chatProgress) - { - case 0: - textToWrite = "User joined: @" + SaveSystem.CurrentSave.Username; - break; - case 1: - textToWrite = $"Hello, {SaveSystem.CurrentSave.Username}."; - break; - case 2: //If C:\ShiftOS doesn't exist the player won't notice this is here. - if (Directory.Exists(Paths.GetPath("classic"))) - { - textToWrite = "I see you've participated in my previous ShiftOS experiment. Welcome back, Shifter. I assume you know lots about ShiftOS, but there are some updates I have to tell you."; - } - else - { - write = false; - } - break; - case 3: //DevX hates ShiftOS-Next secretly. - if (Directory.Exists(Paths.GetPath("classic") + "-Next")) - { - textToWrite = "Hmmmm.... looking at my sentience records, I see you've participated in ShiftOS-Next. This is gonna be difficult."; - } - else - { - write = false; - } - break; - case 4: - textToWrite = "There's a lot that has changed within ShiftOS."; - break; - case 5: - textToWrite = "First off, I want to tell you a bit about myself in case you don't already know."; - break; - case 6: - textToWrite = "My name is DevX. I am the architect of ShiftOS. I have chosen you to take part in helping me out with it."; - break; - case 7: - textToWrite = "You see, in my past attempts it has all been about an evolving operating system and seeing how the users work with it..."; - break; - case 8: - textToWrite = "Almost one hundred percent of the time, people have found out it was an experiment and they could simply return to their regular system with a specific upgrade."; - break; - case 9: - textToWrite = "But now, I want to try something different - something unique."; - break; - case 10: - textToWrite = "ShiftOS is the same as it has been in my previous attempts, but now, your goal is to gain as much wealth and power as possible."; - break; - case 11: - textToWrite = "Right now you are inside my segregation LAN. Only you and me exist within this domain. You are free from other users unless I create them."; - break; - case 12: - textToWrite = "Since you have proved your sentience, I have a task for you outside the segregation LAN."; - break; - case 13: - textToWrite = "But first... you need to be taught a few things."; - break; - case 14: - textToWrite = "First off, when I bring you into my multi-user domain, you'll first want to establish as much wealth as possible."; - break; - case 15: - textToWrite = "Wealth comes in the form of Codepoints - a currency used among users of the multi-user domain."; - break; - case 16: - textToWrite = @"You can get Codepoints by doing the following: - - - Stealing them from other users - - Extracting them from inactive/unverified sentiences - - Using specific scripts/programs within ShiftOS - - Creating paid scripts/applications within ShiftOS"; - break; - case 17: - textToWrite = "You can use Codepoints to buy upgrades using the 'shiftorium.buy' command, or you can use them to pay other users, or scripts."; - break; - case 18: - textToWrite = "Within the multi-user domain you are free to do whatever you want. Larcany, theft, deceiving, lies, and distribution of malware is permitted under my watch."; - break; - case 19: - textToWrite = "Do whatever you have to to get Codepoints."; - break; - case 20: - textToWrite = "Then use them to make yourself stronger by buying upgrades at the shiftorium."; - break; - case 21: - textToWrite = "If you want to get a bit devious within the multi-user domain, look around for scripts that will expose user account information."; - break; - case 22: - textToWrite = "Or just spread a virus around the mud."; - break; - case 23: - textToWrite = "Or you can be the 'good' guy and stop these attacks and gain the trust of other users."; - break; - case 24: - textToWrite = "It's up to you. Just, don't mess with my system. You won't want me coming to you after that. I'm watching."; - break; - case 25: - textToWrite = "User left chat: @" + SaveSystem.CurrentSave.Username; - done = true; - SaveSystem.CurrentSave.StoryPosition++; - TerminalBackend.InvokeCommand("sos.save"); - break; - - } - - if (write == true) - { - Console.WriteLine(); - Console.Write("DevX: "); - foreach(char c in textToWrite) - { - Console.Beep(750, TYPE_SPEED_MS); - if (c == '\n') - { - - } - else if (c == '\r') - { - Console.WriteLine(); - } - else - { - Console.Write(c); - } - } - Thread.Sleep(1000); - } - chatProgress += 1; - } - } - - - public static void WriteStory(string json) - { - var thread = new Thread(new ThreadStart(() => - { - var story = JsonConvert.DeserializeObject(json); - - const int TYPESPEED = 45; - - foreach (var line in story.Lines) - { - var localized = Localization.Parse(line); - - - if (line.StartsWith("cmd:")) - { - string[] cmdsplit = line.Replace("cmd:", "").Split(' '); - switch (cmdsplit[0]) - { - case "givecp": - SaveSystem.TransferCodepointsFrom(story.Character, Convert.ToInt32(cmdsplit[1])); - break; - } - } - else - { - Console.Write(story.Character + ": "); - - foreach (var c in localized) - { - Console.Beep(1024, TYPESPEED); - if (c == '\r') - { - - } - else if (c == '\n') - Console.WriteLine(); - else - Console.Write(c); - } - - Console.WriteLine(); - Thread.Sleep(1000); - } - } - Console.Write($"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ "); - })); - thread.IsBackground = true; - thread.Start(); - } - } - - [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] - public class StoryAttribute : Attribute - { - /// - /// Creates a new instance of the attribute. - /// - /// The ID of this story plot. - /// - /// - /// The is used to turn a static, public method into a story element. Using the specified argument, the ShiftOS Engine can determine whether this plot has already been experienced, and using the classes, the ID is treated as a special Shiftorium upgrade, and you can use the attribute as well as the various other ways of determining whether a Shiftorium upgrade is installed to determine if this plot has been experienced. - /// - /// - public StoryAttribute(string id) - { - StoryID = id; - } - - public string StoryID { get; private set; } - - } -} diff --git a/ShiftOS_TheReturn/TerminalBackend.cs b/ShiftOS_TheReturn/TerminalBackend.cs deleted file mode 100644 index 9c57aa8..0000000 --- a/ShiftOS_TheReturn/TerminalBackend.cs +++ /dev/null @@ -1,534 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Text.RegularExpressions; -using System.Threading.Tasks; -using Newtonsoft.Json; -using static ShiftOS.Engine.SaveSystem; - -namespace ShiftOS.Engine -{ - public static class TerminalBackend - { - public static event Action CommandProcessed; - - public static bool Elevated { get; set; } - - public static Dictionary GetArgs(ref string text) - { - bool shouldParse = false; - int argStart = 0; - if (text.Contains("{")) - { - shouldParse = true; - argStart = text.IndexOf('{'); - } - - if (shouldParse == false) - { - string replacement = Regex.Replace(text, @"\t|\n|\r", ""); - text = replacement + "{}"; - shouldParse = true; - argStart = text.IndexOf('{'); - } - - string args = text.Substring(argStart, text.Length - argStart); - - text = text.Remove(argStart, text.Length - argStart).Replace(" ", ""); - return JsonConvert.DeserializeObject>(args); - } - - public static string LastCommand = ""; - - public static void InvokeCommand(string ns, string command, Dictionary arguments, bool isRemote = false) - { - try - { - if (string.IsNullOrWhiteSpace(ns)) - return; - - - bool commandWasClient = RunClient(ns, command, arguments, isRemote); - - if (!commandWasClient && !string.IsNullOrWhiteSpace(ns)) - { - PrefixEnabled = false; - - ServerManager.SendMessage("script", $@"{{ - user: ""{ns}"", - script: ""{command}"", - args: ""{GetSentArgs(arguments)}"" -}}"); - } - - CommandProcessed?.Invoke(ns + "." + command, JsonConvert.SerializeObject(arguments)); - } - catch (Exception ex) - { - Console.WriteLine($"Command parse error: {ex.Message}"); // This shouldn't ever be called now - PrefixEnabled = true; - - } - } - - public static string GetSentArgs(Dictionary argss) - { - Dictionary args = new Dictionary(); - foreach (KeyValuePair arg in argss) - { - args[arg.Key] = arg.Value; - } - return JsonConvert.SerializeObject(args); - } - - public static void InvokeCommand(string text, bool isRemote = false) - { - try - { - if (string.IsNullOrWhiteSpace(text)) - return; - - var args = GetArgs(ref text); - - bool commandWasClient = RunClient(text, args, isRemote); - - if (!commandWasClient) - { - PrefixEnabled = false; - - ServerManager.SendMessage("script", $@"{{ - user: ""{text.Split('.')[0]}"", - script: ""{text.Split('.')[1]}"", - args: ""{GetSentArgs(args)}"" -}}"); - } - CommandProcessed?.Invoke(text, GetSentArgs(args)); - } - catch (Exception ex) - { - Console.WriteLine($"Command parse error: {ex.Message}"); - PrefixEnabled = true; - - } - } - - public static bool PrefixEnabled { get; set; } - - public static bool InStory { get; set; } - - public static string latestCommmand = ""; - - public static event EmptyEventHandler TerminalRequested; - - internal static void OpenTerminal() - { - TerminalRequested?.Invoke(); - } - - public static bool CanRunRemotely(MethodInfo mth, bool isRemote) - { - if (!isRemote) - return true; - - foreach (var attr in mth.GetCustomAttributes(false)) - { - if (attr is RemoteLockAttribute) - return false; - } - - return true; - } - - public static bool RunClient(string ns, string cmd, Dictionary args, bool isRemote = false) - { - return RunClient(ns + "." + cmd, args, isRemote); - } - - - public static bool RunClient(string text, Dictionary argss, bool isRemote = false) - { - Dictionary args = new Dictionary(); - foreach (KeyValuePair arg in argss) - { - args[arg.Key] = arg.Value; - } - return RunClient(text, args, isRemote); - } - - public static bool RunClient(string text, Dictionary args, bool isRemote = false) - { - latestCommmand = text; - - //Console.WriteLine(text + " " + "{" + string.Join(",", args.Select(kv => kv.Key + "=" + kv.Value).ToArray()) + "}" + " " + isRemote); - - foreach (var asmExec in System.IO.Directory.GetFiles(Environment.CurrentDirectory)) - { - try - { - var asm = Assembly.LoadFile(asmExec); - - var types = asm.GetTypes(); - foreach (var type in types) - { - if (Shiftorium.UpgradeAttributesUnlocked(type)) - { - foreach (var a in type.GetCustomAttributes(false)) - { - if (a is Namespace) - { - var ns = a as Namespace; - if (text.Split('.')[0] == ns.name) - { - if (KernelWatchdog.IsSafe(type)) - { - if (KernelWatchdog.CanRunOffline(type)) - { - foreach (var method in type.GetMethods(BindingFlags.Public | BindingFlags.Static)) - { - if (Shiftorium.UpgradeAttributesUnlocked(method)) - { - if (CanRunRemotely(method, isRemote)) - { - foreach (var ma in method.GetCustomAttributes(false)) - { - if (ma is Command) - { - var cmd = ma as Command; - if (text.Split('.')[1] == cmd.name) - { - if (KernelWatchdog.IsSafe(method)) - { - if (KernelWatchdog.CanRunOffline(method)) - { - var attr = method.GetCustomAttribute(); - - if (attr != null) - { - string newcommand = attr.newcommand; - if (attr.warn) - { - Console.WriteLine(Localization.Parse((newcommand == "" ? "{ERROR}" : "{WARN}") + attr.reason, new Dictionary() { - {"%newcommand", newcommand} - })); - } - if (newcommand != "") - { - // redo the entire process running newcommand - - return RunClient(newcommand, args); - } - } - - var requiresArgs = method.GetCustomAttributes(); - bool error = false; - bool providedusage = false; - - foreach (RequiresArgument argument in requiresArgs) - { - if (!args.ContainsKey(argument.argument)) - { - - if (!providedusage) - { - string usageparse = "{COMMAND_" + ns.name.ToUpper() + "_" + cmd.name.ToUpper() + "_USAGE}"; - if (usageparse == Localization.Parse(usageparse)) - usageparse = ""; - else - usageparse = Shiftorium.UpgradeInstalled("help_usage") ? Localization.Parse("{ERROR}{USAGE}" + usageparse, new Dictionary() { - {"%ns", ns.name}, - {"%cmd", cmd.name} - }) : ""; - - Console.WriteLine(usageparse); - - providedusage = true; - } - if (Shiftorium.UpgradeInstalled("help_usage")) - { - Console.WriteLine(Localization.Parse("{ERROR_ARGUMENT_REQUIRED}", new Dictionary() { - {"%argument", argument.argument} - })); - } - else - { - Console.WriteLine(Localization.Parse("{ERROR_ARGUMENT_REQUIRED_NO_USAGE}")); - } - - error = true; - } - } - - if (error) - { - throw new Exception("{ERROR_COMMAND_WRONG}"); - } - - try - { - return (bool)method.Invoke(null, new[] { args }); - } - catch (TargetInvocationException e) - { - Console.WriteLine(Localization.Parse("{ERROR_EXCEPTION_THROWN_IN_METHOD}")); - Console.WriteLine(e.InnerException.Message); - Console.WriteLine(e.InnerException.StackTrace); - return true; - } - catch - { - return (bool)method.Invoke(null, new object[] { }); - } - } - else - { - Console.Write("<"); - ConsoleEx.Bold = true; - ConsoleEx.ForegroundColor = ConsoleColor.DarkRed; - Console.Write("session_mgr"); - ConsoleEx.ForegroundColor = SkinEngine.LoadedSkin.TerminalForeColorCC; - ConsoleEx.Bold = false; - Console.Write(">"); - ConsoleEx.Italic = true; - ConsoleEx.ForegroundColor = ConsoleColor.DarkYellow; - Console.WriteLine(" You cannot run this command while disconnected from the multi-user domain.."); - return true; - - } - } - else - { - if (SaveSystem.CurrentUser.Permissions == Objects.UserPermissions.Admin) - { - Infobox.PromptText("Elevate to root mode", "This command cannot be run as a regular user. To run this command, please enter your password to elevate to root mode temporarily.", (pass) => - { - if (pass == SaveSystem.CurrentUser.Password) - { - KernelWatchdog.EnterKernelMode(); - RunClient(text, args, isRemote); - KernelWatchdog.LeaveKernelMode(); - } - else - { - Infobox.Show("Access denied.", "You did not type in the correct password."); - } - }, true); - return true; - } - Console.Write("<"); - ConsoleEx.Bold = true; - ConsoleEx.ForegroundColor = ConsoleColor.DarkRed; - Console.Write("watchdog"); - ConsoleEx.ForegroundColor = SkinEngine.LoadedSkin.TerminalForeColorCC; - ConsoleEx.Bold = false; - Console.Write(">"); - ConsoleEx.Italic = true; - ConsoleEx.ForegroundColor = ConsoleColor.DarkYellow; - Console.WriteLine(" You cannot run this command. You do not have permission. Incident reported."); - KernelWatchdog.Log("potential_sys_breach", "user attempted to run kernel mode command " + text + " - watchdog has prevented this, good sir."); - return true; - } - } - } - - - } - } - } - else - { - Console.WriteLine(text + " cannot be ran in a remote session"); - return true; - } - } - - } - - - else - { - Console.Write("<"); - ConsoleEx.Bold = true; - ConsoleEx.ForegroundColor = ConsoleColor.DarkRed; - Console.Write("session_mgr"); - ConsoleEx.ForegroundColor = SkinEngine.LoadedSkin.TerminalForeColorCC; - ConsoleEx.Bold = false; - Console.Write(">"); - ConsoleEx.Italic = true; - ConsoleEx.ForegroundColor = ConsoleColor.DarkYellow; - Console.WriteLine(" You cannot run this command while disconnected from the multi-user domain.."); - return true; - - } - - } - else - { - if (SaveSystem.CurrentUser.Permissions == Objects.UserPermissions.Admin) - { - Infobox.PromptText("Elevate to root mode", "This command cannot be run as a regular user. To run this command, please enter your password to elevate to root mode temporarily.", (pass) => - { - if (pass == SaveSystem.CurrentUser.Password) - { - KernelWatchdog.EnterKernelMode(); - RunClient(text, args, isRemote); - KernelWatchdog.LeaveKernelMode(); - } - else - { - Infobox.Show("Access denied.", "You did not type in the correct password."); - } - }, true); - return true; - } - Console.Write("<"); - ConsoleEx.Bold = true; - ConsoleEx.ForegroundColor = ConsoleColor.DarkRed; - Console.Write("watchdog"); - ConsoleEx.ForegroundColor = SkinEngine.LoadedSkin.TerminalForeColorCC; - ConsoleEx.Bold = false; - Console.Write(">"); - ConsoleEx.Italic = true; - ConsoleEx.ForegroundColor = ConsoleColor.DarkYellow; - Console.WriteLine(" You cannot run this command. You do not have permission. Incident reported."); - KernelWatchdog.Log("potential_sys_breach", "user attempted to run kernel mode command " + text + " - watchdog has prevented this, good sir."); - return true; - } - } - } - } - } - } - } - catch { } - } - return false; - } - public static void PrintPrompt() - { - if (SaveSystem.CurrentSave != null && CurrentUser != null) - { - ConsoleEx.BackgroundColor = SkinEngine.LoadedSkin.TerminalBackColorCC; - ConsoleEx.Italic = false; - ConsoleEx.Underline = false; - - ConsoleEx.ForegroundColor = ConsoleColor.Magenta; - ConsoleEx.Bold = true; - - Console.Write(SaveSystem.CurrentUser.Username); - ConsoleEx.Bold = false; - ConsoleEx.ForegroundColor = ConsoleColor.Gray; - Console.Write("@"); - ConsoleEx.Italic = true; - ConsoleEx.Bold = true; - ConsoleEx.ForegroundColor = ConsoleColor.Yellow; - Console.Write(SaveSystem.CurrentSave.SystemName); - ConsoleEx.Italic = false; - ConsoleEx.Bold = false; - ConsoleEx.ForegroundColor = ConsoleColor.Gray; - Console.Write(":~"); - Console.ForegroundColor = ConsoleColor.White; - ConsoleEx.Italic = true; - if (KernelWatchdog.InKernelMode == true) - Console.Write("#"); - else - Console.Write("$"); - ConsoleEx.Italic = false; - ConsoleEx.Bold = false; - ConsoleEx.ForegroundColor = SkinEngine.LoadedSkin.TerminalForeColorCC; - Console.Write(" "); - } - } - - - static TerminalBackend() - { - ServerMessageReceived onMessageReceived = (msg) => - { - if (msg.Name == "trm_invokecommand") - { - string text3 = ""; - string text4 = msg.Contents; - - if (TerminalBackend.PrefixEnabled) - { - text3 = text4.Remove(0, $"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ ".Length); - } - IsForwardingConsoleWrites = true; - if (TerminalBackend.InStory == false) - { - TerminalBackend.InvokeCommand(text3, true); - } - if (TerminalBackend.PrefixEnabled) - { - Console.Write($"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ "); - } - IsForwardingConsoleWrites = false; - } - else if (msg.Name == "pleasewrite") - { - Console.Write(msg.Contents); - } - else if (msg.Name == "handshake_from") - { - var a = JsonConvert.DeserializeObject>(msg.Contents); - string uName = a["username"] as string; - string pass = a["password"] as string; - string sys = a["sysname"] as string; - string guid = msg.GUID; - if (SaveSystem.CurrentSave.Username == uName && SaveSystem.CurrentSave.Password == pass && CurrentSave.SystemName == sys) - { - ForwardGUID = guid; - ServerManager.SendMessage("trm_handshake_accept", $@"{{ - guid: ""{ServerManager.thisGuid}"", - target: ""{guid}"" -}}"); - - IsForwardingConsoleWrites = true; - InvokeCommand("sos.status"); - Console.Write($"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ "); - IsForwardingConsoleWrites = false; - } - } - }; - - ServerManager.MessageReceived += onMessageReceived; - } - - public static bool IsForwardingConsoleWrites { get; internal set; } - public static string ForwardGUID { get; internal set; } - - public static event TextSentEventHandler TextSent; - - public static void SendText(string text) - { - TextSent?.Invoke(text); - } - - } -} diff --git a/ShiftOS_TheReturn/TerminalTextWriter.cs b/ShiftOS_TheReturn/TerminalTextWriter.cs deleted file mode 100644 index 55e27cf..0000000 --- a/ShiftOS_TheReturn/TerminalTextWriter.cs +++ /dev/null @@ -1,131 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.IO; -using System.Windows.Forms; - -namespace ShiftOS.Engine -{ - public class TerminalTextWriter : TextWriter - { - [System.Runtime.InteropServices.DllImport("user32.dll")] - public static extern bool LockWindowUpdate(IntPtr hWndLock); - - - public override Encoding Encoding - { - get - { - return Encoding.Unicode; - } - } - - public ITerminalWidget UnderlyingControl - { - get - { - return AppearanceManager.ConsoleOut; - } - } - - public void select() - { - Desktop.InvokeOnWorkerThread(new Action(() => - { - UnderlyingControl?.SelectBottom(); - - })); - } - - public override void Write(char value) - { - if (TerminalBackend.IsForwardingConsoleWrites) - { - ServerManager.SendMessage("write", $@"{{ - guid: ""{TerminalBackend.ForwardGUID}"", - text: ""{value}"" -}}"); - } - else - { - Desktop.InvokeOnWorkerThread(new Action(() => - { - UnderlyingControl?.Write(value.ToString()); - select(); - })); - } - } - - public override void WriteLine(string value) - { - if (TerminalBackend.IsForwardingConsoleWrites) - { - ServerManager.SendMessage("write", $@"{{ - guid: ""{TerminalBackend.ForwardGUID}"", - text: ""{value + Environment.NewLine}"" -}}"); - } - else - { - - Desktop.InvokeOnWorkerThread(new Action(() => - { - UnderlyingControl?.WriteLine(value); - select(); - })); - } - } - - public void SetLastText() - { - } - - public override void Write(string value) - { - if (TerminalBackend.IsForwardingConsoleWrites) - { - ServerManager.SendMessage("write", $@"{{ - guid: ""{TerminalBackend.ForwardGUID}"", - text: ""{value}"" -}}"); - } - else - { - - Desktop.InvokeOnWorkerThread(new Action(() => - { - UnderlyingControl?.Write(value.ToString()); - select(); - })); - } - } - - - } -} diff --git a/ShiftOS_TheReturn/UniteClient.cs b/ShiftOS_TheReturn/UniteClient.cs deleted file mode 100644 index 8d6a58d..0000000 --- a/ShiftOS_TheReturn/UniteClient.cs +++ /dev/null @@ -1,135 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net; -using System.Text; -using System.Threading.Tasks; -using Newtonsoft.Json; -using ShiftOS.Objects; - -namespace ShiftOS.Unite -{ - public class UniteClient - { - public string Token { get; private set; } - public string BaseURL - { - get - { - return UserConfig.Get().UniteUrl; - } - } - - public string GetDisplayNameId(string id) - { - return MakeCall("/API/GetDisplayName/" + id); - } - - public PongHighscoreModel GetPongHighscores() - { - return JsonConvert.DeserializeObject(MakeCall("/API/GetPongHighscores")); - } - - public UniteClient(string baseurl, string usertoken) - { - //Handled by the servers.json file - //BaseURL = baseurl; - Token = usertoken; - } - - internal string MakeCall(string url) - { - var webrequest = WebRequest.Create(BaseURL + url); - webrequest.Headers.Add("Authentication: Token " + Token); - using (var response = webrequest.GetResponse()) - { - using (var stream = response.GetResponseStream()) - { - using (var reader = new System.IO.StreamReader(stream)) - { - return reader.ReadToEnd(); - } - } - } - } - - public int GetPongCP() - { - return Convert.ToInt32(MakeCall("/API/GetPongCP")); - } - - public int GetPongLevel() - { - return Convert.ToInt32(MakeCall("/API/GetPongLevel")); - } - - public void SetPongLevel(int value) - { - MakeCall("/API/SetPongLevel/" + value.ToString()); - } - - public void SetPongCP(int value) - { - MakeCall("/API/SetPongCP/" + value.ToString()); - } - - public string GetEmail() - { - return MakeCall("/API/GetEmail"); - } - - public string GetSysName() - { - return MakeCall("/API/GetSysName"); - } - - public void SetSysName(string value) - { - MakeCall("/API/SetSysName/" + value); - } - - public string GetDisplayName() - { - return MakeCall("/API/GetDisplayName"); - } - - public void SetDisplayName(string value) - { - MakeCall("/API/SetDisplayName/" + value.ToString()); - } - - public string GetFullName() - { - return MakeCall("/API/GetFullName"); - } - - public void SetFullName(string value) - { - MakeCall("/API/SetFullName/" + value.ToString()); - } - - - public long GetCodepoints() - { - return Convert.ToInt64(MakeCall("/API/GetCodepoints")); - } - - public void SetCodepoints(long value) - { - MakeCall("/API/SetCodepoints/" + value.ToString()); - } - } - - public class PongHighscoreModel - { - public int Pages { get; set; } - public PongHighscore[] Highscores { get; set; } - } - - public class PongHighscore - { - public string UserId { get; set; } - public int Level { get; set; } - public long CodepointsCashout { get; set; } - } -} diff --git a/ShiftOS_TheReturn/UserManagementCommands.cs b/ShiftOS_TheReturn/UserManagementCommands.cs deleted file mode 100644 index 5702e08..0000000 --- a/ShiftOS_TheReturn/UserManagementCommands.cs +++ /dev/null @@ -1,201 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using ShiftOS.Objects; - -namespace ShiftOS.Engine -{ - [Namespace("admin")] - [KernelMode] - [RequiresUpgrade("mud_fundamentals")] - public static class AdminUserManagementCommands - { - [Command("add", description = "Add a user to the system.", usage ="name:")] - [RequiresArgument("name")] - public static bool AddUser(Dictionary args) - { - string name = args["name"].ToString(); - if(SaveSystem.CurrentSave.Users.FirstOrDefault(x=>x.Username==name) != null) - { - Console.WriteLine("Error: User already exists."); - return true; - } - - var user = new ClientSave - { - Username = name, - Password = "", - Permissions = UserPermissions.User - }; - SaveSystem.CurrentSave.Users.Add(user); - Console.WriteLine($"Creating new user \"{name}\" with no password and User permissions."); - SaveSystem.SaveGame(); - return true; - } - - [Command("remove", description = "Remove a user from the system.", usage = "name:")] - [RequiresArgument("name")] - public static bool RemoveUser(Dictionary args) - { - string name = args["name"].ToString(); - if (SaveSystem.CurrentSave.Users.FirstOrDefault(x => x.Username == name) == null) - { - Console.WriteLine("Error: User doesn't exist."); - return true; - } - - var user = SaveSystem.CurrentSave.Users.FirstOrDefault(x => x.Username == name); - if(user.Username != SaveSystem.CurrentUser.Username) - { - Console.WriteLine("Error: Cannot remove yourself."); - return true; - } - SaveSystem.CurrentSave.Users.Remove(user); - Console.WriteLine($"Removing user \"{name}\" from system..."); - SaveSystem.SaveGame(); - return true; - } - - - - - [Command("set_acl")] - [RequiresArgument("user")] - [RequiresArgument("val")] - public static bool SetUserPermission(Dictionary args) - { - int permission = 0; - string username = args["user"].ToString(); - try - { - permission = Convert.ToInt32(args["val"].ToString()); - } - catch - { - Console.WriteLine("Error: Permission value must be an integer."); - return true; - } - - if(SaveSystem.CurrentSave.Users.FirstOrDefault(x=>x.Username==username) == null) - { - Console.WriteLine("Error: User not found."); - return true; - } - - UserPermissions uperm = UserPermissions.Guest; - - switch (permission) - { - case 0: - uperm = UserPermissions.Guest; - break; - case 1: - uperm = UserPermissions.User; - break; - case 2: - uperm = UserPermissions.Admin; - break; - case 3: - uperm = UserPermissions.Root; - break; - default: - Console.WriteLine("Permission value must be between 0 and 4."); - return true; - } - - //Permissions are backwards... oops... - if(uperm < SaveSystem.CurrentUser.Permissions) - { - Console.WriteLine("Error: Cannot set user permissions to values greater than your own!"); - return true; - } - - var oldperm = SaveSystem.Users.FirstOrDefault(x => x.Username == username).Permissions; - if (SaveSystem.CurrentUser.Permissions > oldperm) - { - Console.WriteLine("Error: Can't set the permission of this user. They have more rights than you."); - return true; - } - - SaveSystem.CurrentSave.Users.FirstOrDefault(x => x.Username == username).Permissions = uperm; - Console.WriteLine("User permissions updated."); - return true; - } - - - [Command("users", description = "Get a list of all users on the system.")] - public static bool GetUsers() - { - foreach (var u in SaveSystem.CurrentSave.Users) - { - if (u.Username == SaveSystem.CurrentUser.Username) - { - ConsoleEx.ForegroundColor = ConsoleColor.Magenta; - ConsoleEx.Bold = true; - } - else - { - ConsoleEx.ForegroundColor = ConsoleColor.Gray; - ConsoleEx.Bold = false; - } - Console.WriteLine(u.Username); - } - return true; - } - } - - [Namespace("user")] - [RequiresUpgrade("mud_fundamentals")] - public static class UserManagementCommands - { - [Command("login", description = "Log in as another user.")] - [RequiresArgument("user")] - [RequiresArgument("pass")] - public static bool Login(Dictionary args) - { - string user = args["user"].ToString(); - string pass = args["pass"].ToString(); - - var usr = SaveSystem.CurrentSave.Users.FirstOrDefault(x => x.Username == user); - if(usr==null) - { - Console.WriteLine("Error: No such user."); - return true; - } - - if (usr.Password != pass) - { - Console.WriteLine("Access denied."); - return true; - } - - SaveSystem.CurrentUser = usr; - Console.WriteLine("Access granted."); - return true; - } - - [Command("setpass", description ="Allows you to set your password to a new value.", usage ="old:,new:")] - [RequiresArgument("old")] - [RequiresArgument("new")] - public static bool SetPassword(Dictionary args) - { - string old = args["old"].ToString(); - string newpass = args["new"].ToString(); - - if(old == SaveSystem.CurrentUser.Password) - { - SaveSystem.CurrentUser.Password = newpass; - SaveSystem.CurrentSave.Users.FirstOrDefault(x => x.Username == SaveSystem.CurrentUser.Username).Password = newpass; - Console.WriteLine("Password set successfully."); - SaveSystem.SaveGame(); - } - else - { - Console.WriteLine("Passwords do not match."); - } - return true; - } - } -} -- cgit v1.2.3 From 6747c63e2c8c5a274846da7200c50a444b725d28 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 20 May 2017 16:09:50 -0400 Subject: Tiny skinning fixes. --- ShiftOS.WinForms/Applications/Shifter.cs | 7 +- ShiftOS.WinForms/Tools/ControlManager.cs | 33 +++- ShiftOS_TheReturn/UserManagementCommands.cs | 238 ++++++++++++++++++++++++++++ 3 files changed, 265 insertions(+), 13 deletions(-) create mode 100644 ShiftOS_TheReturn/UserManagementCommands.cs (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.WinForms/Applications/Shifter.cs b/ShiftOS.WinForms/Applications/Shifter.cs index edc3703..acb64a5 100644 --- a/ShiftOS.WinForms/Applications/Shifter.cs +++ b/ShiftOS.WinForms/Applications/Shifter.cs @@ -814,15 +814,12 @@ namespace ShiftOS.WinForms.Applications ControlManager.SetupControl(color); color.BackColor = ((Color)c.Field.GetValue(LoadedSkin)); - color.BackColorChanged += (o, a) => - { - c.Field.SetValue(LoadedSkin, color.BackColor); - }; color.Click += (o, a) => { - AppearanceManager.SetupDialog(new ColorPicker(color.BackColor, c.Name, new Action((col) => + AppearanceManager.SetupDialog(new ColorPicker((Color)c.Field.GetValue(LoadedSkin), c.Name, new Action((col) => { color.BackColor = col; + c.Field.SetValue(LoadedSkin, col); CodepointValue += 300; InvokeSetup(cat); diff --git a/ShiftOS.WinForms/Tools/ControlManager.cs b/ShiftOS.WinForms/Tools/ControlManager.cs index 4f888ab..fc9567d 100644 --- a/ShiftOS.WinForms/Tools/ControlManager.cs +++ b/ShiftOS.WinForms/Tools/ControlManager.cs @@ -220,13 +220,22 @@ namespace ShiftOS.WinForms.Tools Desktop.InvokeOnWorkerThread(() => { Button b = ctrl as Button; - b.BackColor = SkinEngine.LoadedSkin.ButtonBackgroundColor; - b.BackgroundImage = SkinEngine.GetImage("buttonidle"); - b.BackgroundImageLayout = SkinEngine.GetImageLayout("buttonidle"); + if (!b.Tag.ToString().ToLower().Contains("keepbg")) + { + b.BackColor = SkinEngine.LoadedSkin.ButtonBackgroundColor; + b.BackgroundImage = SkinEngine.GetImage("buttonidle"); + b.BackgroundImageLayout = SkinEngine.GetImageLayout("buttonidle"); + } b.FlatAppearance.BorderSize = SkinEngine.LoadedSkin.ButtonBorderWidth; - b.FlatAppearance.BorderColor = SkinEngine.LoadedSkin.ButtonForegroundColor; - b.ForeColor = SkinEngine.LoadedSkin.ButtonForegroundColor; - b.Font = SkinEngine.LoadedSkin.ButtonTextFont; + if (!b.Tag.ToString().ToLower().Contains("keepfg")) + { + b.FlatAppearance.BorderColor = SkinEngine.LoadedSkin.ButtonForegroundColor; + b.ForeColor = SkinEngine.LoadedSkin.ButtonForegroundColor; + } + if(!b.Tag.ToString().ToLower().Contains("keepfont")) + b.Font = SkinEngine.LoadedSkin.ButtonTextFont; + + Color orig_bg = b.BackColor; b.MouseEnter += (o, a) => { @@ -236,13 +245,13 @@ namespace ShiftOS.WinForms.Tools }; b.MouseLeave += (o, a) => { - b.BackColor = SkinEngine.LoadedSkin.ButtonBackgroundColor; + b.BackColor = orig_bg; b.BackgroundImage = SkinEngine.GetImage("buttonidle"); b.BackgroundImageLayout = SkinEngine.GetImageLayout("buttonidle"); }; b.MouseUp += (o, a) => { - b.BackColor = SkinEngine.LoadedSkin.ButtonBackgroundColor; + b.BackColor = orig_bg; b.BackgroundImage = SkinEngine.GetImage("buttonidle"); b.BackgroundImageLayout = SkinEngine.GetImageLayout("buttonidle"); }; @@ -257,6 +266,14 @@ namespace ShiftOS.WinForms.Tools }); } + if(ctrl is TextBox) + { + Desktop.InvokeOnWorkerThread(() => + { + (ctrl as TextBox).BorderStyle = BorderStyle.FixedSingle; + }); + } + ctrl.KeyDown += (o, a) => { if (a.Control && a.KeyCode == Keys.T) diff --git a/ShiftOS_TheReturn/UserManagementCommands.cs b/ShiftOS_TheReturn/UserManagementCommands.cs new file mode 100644 index 0000000..a64c99c --- /dev/null +++ b/ShiftOS_TheReturn/UserManagementCommands.cs @@ -0,0 +1,238 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ShiftOS.Objects; + +namespace ShiftOS.Engine +{ + /// + /// Administrative user management terminal commands. + /// + [Namespace("admin")] + [KernelMode] + [RequiresUpgrade("mud_fundamentals")] + public static class AdminUserManagementCommands + { + /// + /// Add a user to the system. + /// + /// Command arguments. + /// Command result. + [Command("add", description = "Add a user to the system.", usage ="name:")] + [RequiresArgument("name")] + public static bool AddUser(Dictionary args) + { + string name = args["name"].ToString(); + if(SaveSystem.CurrentSave.Users.FirstOrDefault(x=>x.Username==name) != null) + { + Console.WriteLine("Error: User already exists."); + return true; + } + + var user = new ClientSave + { + Username = name, + Password = "", + Permissions = UserPermissions.User + }; + SaveSystem.CurrentSave.Users.Add(user); + Console.WriteLine($"Creating new user \"{name}\" with no password and User permissions."); + SaveSystem.SaveGame(); + return true; + } + + /// + /// Remove a user from the system. + /// + /// Command arguments. + /// Command result. + + [Command("remove", description = "Remove a user from the system.", usage = "name:")] + [RequiresArgument("name")] + public static bool RemoveUser(Dictionary args) + { + string name = args["name"].ToString(); + if (SaveSystem.CurrentSave.Users.FirstOrDefault(x => x.Username == name) == null) + { + Console.WriteLine("Error: User doesn't exist."); + return true; + } + + var user = SaveSystem.CurrentSave.Users.FirstOrDefault(x => x.Username == name); + if(user.Username != SaveSystem.CurrentUser.Username) + { + Console.WriteLine("Error: Cannot remove yourself."); + return true; + } + SaveSystem.CurrentSave.Users.Remove(user); + Console.WriteLine($"Removing user \"{name}\" from system..."); + SaveSystem.SaveGame(); + return true; + } + + + + /// + /// Set access control level for a user. + /// + /// Command arguments. + /// Command result. + + [Command("set_acl")] + [RequiresArgument("user")] + [RequiresArgument("val")] + public static bool SetUserPermission(Dictionary args) + { + int permission = 0; + string username = args["user"].ToString(); + try + { + permission = Convert.ToInt32(args["val"].ToString()); + } + catch + { + Console.WriteLine("Error: Permission value must be an integer."); + return true; + } + + if(SaveSystem.CurrentSave.Users.FirstOrDefault(x=>x.Username==username) == null) + { + Console.WriteLine("Error: User not found."); + return true; + } + + UserPermissions uperm = UserPermissions.Guest; + + switch (permission) + { + case 0: + uperm = UserPermissions.Guest; + break; + case 1: + uperm = UserPermissions.User; + break; + case 2: + uperm = UserPermissions.Admin; + break; + case 3: + uperm = UserPermissions.Root; + break; + default: + Console.WriteLine("Permission value must be between 0 and 4."); + return true; + } + + //Permissions are backwards... oops... + if(uperm < SaveSystem.CurrentUser.Permissions) + { + Console.WriteLine("Error: Cannot set user permissions to values greater than your own!"); + return true; + } + + var oldperm = SaveSystem.Users.FirstOrDefault(x => x.Username == username).Permissions; + if (SaveSystem.CurrentUser.Permissions > oldperm) + { + Console.WriteLine("Error: Can't set the permission of this user. They have more rights than you."); + return true; + } + + SaveSystem.CurrentSave.Users.FirstOrDefault(x => x.Username == username).Permissions = uperm; + Console.WriteLine("User permissions updated."); + return true; + } + + /// + /// List all users in the system. + /// + /// Command arguments. + /// Command result. + + [Command("users", description = "Get a list of all users on the system.")] + public static bool GetUsers() + { + foreach (var u in SaveSystem.CurrentSave.Users) + { + if (u.Username == SaveSystem.CurrentUser.Username) + { + ConsoleEx.ForegroundColor = ConsoleColor.Magenta; + ConsoleEx.Bold = true; + } + else + { + ConsoleEx.ForegroundColor = ConsoleColor.Gray; + ConsoleEx.Bold = false; + } + Console.WriteLine(u.Username); + } + return true; + } + } + + /// + /// Non-administrative user management terminal commands. + /// + [Namespace("user")] + [RequiresUpgrade("mud_fundamentals")] + public static class UserManagementCommands + { + /// + /// Log in as another user. + /// + /// Command arguments. + /// Command result. + [Command("login", description = "Log in as another user.")] + [RequiresArgument("user")] + [RequiresArgument("pass")] + public static bool Login(Dictionary args) + { + string user = args["user"].ToString(); + string pass = args["pass"].ToString(); + + var usr = SaveSystem.CurrentSave.Users.FirstOrDefault(x => x.Username == user); + if(usr==null) + { + Console.WriteLine("Error: No such user."); + return true; + } + + if (usr.Password != pass) + { + Console.WriteLine("Access denied."); + return true; + } + + SaveSystem.CurrentUser = usr; + Console.WriteLine("Access granted."); + return true; + } + + /// + /// Set the password for the current user. + /// + /// Command arguments. + /// Command result. + [Command("setpass", description ="Allows you to set your password to a new value.", usage ="old:,new:")] + [RequiresArgument("old")] + [RequiresArgument("new")] + public static bool SetPassword(Dictionary args) + { + string old = args["old"].ToString(); + string newpass = args["new"].ToString(); + + if(old == SaveSystem.CurrentUser.Password) + { + SaveSystem.CurrentUser.Password = newpass; + SaveSystem.CurrentSave.Users.FirstOrDefault(x => x.Username == SaveSystem.CurrentUser.Username).Password = newpass; + Console.WriteLine("Password set successfully."); + SaveSystem.SaveGame(); + } + else + { + Console.WriteLine("Passwords do not match."); + } + return true; + } + } +} -- cgit v1.2.3 From 660c42a19c831b9768d7bb6845b22474459a311e Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 23 May 2017 19:07:25 -0400 Subject: Disable TriPresent for Beta 2.5. --- ShiftOS.WinForms/Applications/TriPresent.cs | 6 +++++- ShiftOS.WinForms/Applications/TriSheet.cs | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.WinForms/Applications/TriPresent.cs b/ShiftOS.WinForms/Applications/TriPresent.cs index dee7fda..fc1d982 100644 --- a/ShiftOS.WinForms/Applications/TriPresent.cs +++ b/ShiftOS.WinForms/Applications/TriPresent.cs @@ -1,4 +1,6 @@ -using ShiftOS.Objects.ShiftFS; +#define BETA_2_5 + +using ShiftOS.Objects.ShiftFS; using System; using System.Collections.Generic; using System.ComponentModel; @@ -13,10 +15,12 @@ using System.Threading; namespace ShiftOS.WinForms.Applications { +#if !BETA_2_5 [WinOpen("tripresent")] [AppscapeEntry("TriPresent", "Part of the trilogy of office applications for enhancement of your system. TriPresent is easliy the best presentation creator out there for ShiftOS.", 2048, 1500, "file_skimmer", "Office")] [DefaultTitle("TriPresent")] [Launcher("TriPresent", false, null, "Office")] +#endif public partial class TriPresent : UserControl, IShiftOSWindow { public TriPresent() diff --git a/ShiftOS.WinForms/Applications/TriSheet.cs b/ShiftOS.WinForms/Applications/TriSheet.cs index 1013bc7..18b09b3 100644 --- a/ShiftOS.WinForms/Applications/TriSheet.cs +++ b/ShiftOS.WinForms/Applications/TriSheet.cs @@ -1,4 +1,6 @@ -using System; +#define BETA_2_5 + +using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; -- cgit v1.2.3 From 44a4de1c173a0ab88ff3aa519b3a25888f2eff85 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 23 May 2017 20:36:16 -0400 Subject: web browser + fix shiftorium merge conflict --- .../Applications/WebBrowser.Designer.cs | 153 +++++++++++++++++++++ ShiftOS.WinForms/Applications/WebBrowser.cs | 97 +++++++++++++ ShiftOS.WinForms/Applications/WebBrowser.resx | 120 ++++++++++++++++ ShiftOS.WinForms/Resources/Shiftorium.txt | 3 - ShiftOS.WinForms/ShiftOS.WinForms.csproj | 9 ++ 5 files changed, 379 insertions(+), 3 deletions(-) create mode 100644 ShiftOS.WinForms/Applications/WebBrowser.Designer.cs create mode 100644 ShiftOS.WinForms/Applications/WebBrowser.cs create mode 100644 ShiftOS.WinForms/Applications/WebBrowser.resx (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.WinForms/Applications/WebBrowser.Designer.cs b/ShiftOS.WinForms/Applications/WebBrowser.Designer.cs new file mode 100644 index 0000000..6b7ae83 --- /dev/null +++ b/ShiftOS.WinForms/Applications/WebBrowser.Designer.cs @@ -0,0 +1,153 @@ +namespace ShiftOS.WinForms.Applications +{ + partial class WebBrowser + { + /// + /// 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.flcontrols = new System.Windows.Forms.FlowLayoutPanel(); + this.btnback = new System.Windows.Forms.Button(); + this.btnforward = new System.Windows.Forms.Button(); + this.txturl = new System.Windows.Forms.TextBox(); + this.btngo = new System.Windows.Forms.Button(); + this.pnlcanvas = new System.Windows.Forms.Panel(); + this.wbmain = new System.Windows.Forms.WebBrowser(); + this.flcontrols.SuspendLayout(); + this.pnlcanvas.SuspendLayout(); + this.SuspendLayout(); + // + // flcontrols + // + this.flcontrols.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.flcontrols.Controls.Add(this.btnback); + this.flcontrols.Controls.Add(this.btnforward); + this.flcontrols.Controls.Add(this.txturl); + this.flcontrols.Controls.Add(this.btngo); + this.flcontrols.Dock = System.Windows.Forms.DockStyle.Top; + this.flcontrols.Location = new System.Drawing.Point(0, 0); + this.flcontrols.Name = "flcontrols"; + this.flcontrols.Size = new System.Drawing.Size(539, 29); + this.flcontrols.TabIndex = 2; + // + // btnback + // + this.btnback.AutoSize = true; + this.btnback.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.btnback.Location = new System.Drawing.Point(3, 3); + this.btnback.Name = "btnback"; + this.btnback.Size = new System.Drawing.Size(23, 23); + this.btnback.TabIndex = 0; + this.btnback.Text = "<"; + this.btnback.UseVisualStyleBackColor = true; + this.btnback.Click += new System.EventHandler(this.btnback_Click); + // + // btnforward + // + this.btnforward.AutoSize = true; + this.btnforward.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.btnforward.Location = new System.Drawing.Point(32, 3); + this.btnforward.Name = "btnforward"; + this.btnforward.Size = new System.Drawing.Size(23, 23); + this.btnforward.TabIndex = 1; + this.btnforward.Text = ">"; + this.btnforward.UseVisualStyleBackColor = true; + this.btnforward.Click += new System.EventHandler(this.btnforward_Click); + // + // txturl + // + this.txturl.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.txturl.Location = new System.Drawing.Point(61, 3); + this.txturl.Name = "txturl"; + this.txturl.Size = new System.Drawing.Size(435, 20); + this.txturl.TabIndex = 2; + this.txturl.WordWrap = false; + this.txturl.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txturl_KeyDown); + // + // btngo + // + this.btngo.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.btngo.AutoSize = true; + this.btngo.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.btngo.Location = new System.Drawing.Point(502, 3); + this.btngo.Name = "btngo"; + this.btngo.Size = new System.Drawing.Size(31, 23); + this.btngo.TabIndex = 3; + this.btngo.Text = "Go"; + this.btngo.UseVisualStyleBackColor = true; + this.btngo.Click += new System.EventHandler(this.btngo_Click); + // + // pnlcanvas + // + this.pnlcanvas.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.pnlcanvas.Controls.Add(this.wbmain); + this.pnlcanvas.Dock = System.Windows.Forms.DockStyle.Fill; + this.pnlcanvas.Location = new System.Drawing.Point(0, 29); + this.pnlcanvas.Name = "pnlcanvas"; + this.pnlcanvas.Size = new System.Drawing.Size(539, 374); + this.pnlcanvas.TabIndex = 3; + // + // wbmain + // + this.wbmain.AllowWebBrowserDrop = false; + this.wbmain.Dock = System.Windows.Forms.DockStyle.Fill; + this.wbmain.IsWebBrowserContextMenuEnabled = false; + this.wbmain.Location = new System.Drawing.Point(0, 0); + this.wbmain.MinimumSize = new System.Drawing.Size(20, 20); + this.wbmain.Name = "wbmain"; + this.wbmain.ScriptErrorsSuppressed = true; + this.wbmain.Size = new System.Drawing.Size(537, 372); + this.wbmain.TabIndex = 0; + this.wbmain.WebBrowserShortcutsEnabled = false; + this.wbmain.Navigated += new System.Windows.Forms.WebBrowserNavigatedEventHandler(this.wbmain_Navigated); + this.wbmain.NewWindow += new System.ComponentModel.CancelEventHandler(this.wbmain_NewWindow); + // + // WebBrowser + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.pnlcanvas); + this.Controls.Add(this.flcontrols); + this.Name = "WebBrowser"; + this.Size = new System.Drawing.Size(539, 403); + this.flcontrols.ResumeLayout(false); + this.flcontrols.PerformLayout(); + this.pnlcanvas.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.FlowLayoutPanel flcontrols; + private System.Windows.Forms.Button btnback; + private System.Windows.Forms.Button btnforward; + private System.Windows.Forms.TextBox txturl; + private System.Windows.Forms.Button btngo; + private System.Windows.Forms.Panel pnlcanvas; + private System.Windows.Forms.WebBrowser wbmain; + } +} diff --git a/ShiftOS.WinForms/Applications/WebBrowser.cs b/ShiftOS.WinForms/Applications/WebBrowser.cs new file mode 100644 index 0000000..751e7e2 --- /dev/null +++ b/ShiftOS.WinForms/Applications/WebBrowser.cs @@ -0,0 +1,97 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using ShiftOS.Engine; + +namespace ShiftOS.WinForms.Applications +{ + [WinOpen("web_browser")] + [AppscapeEntry("Web Browser", "We're going surfing on the Internet! This application allows you to break the bounds of the Digital Society and connect to the outer Internet inside ShiftOS.", + 4096, 10000, "color_depth_24_bits", "Networking")] + [Launcher("Web Browser", false, null, "Networking")] + [DefaultTitle("Web Browser")] + [DefaultIcon("iconShiftnet")] + public partial class WebBrowser : UserControl, IShiftOSWindow + { + public WebBrowser() + { + InitializeComponent(); + uiupdate = new Timer(); + uiupdate.Tick += (o, a) => + { + btnback.Location = new Point(2, 2); + btnforward.Location = new Point(btnback.Left + btnback.Width + 2, 2); + txturl.Location = new Point(btnforward.Left + btnforward.Width + 2, 2); + txturl.Width = flcontrols.Width - btnback.Width - 2 - btnforward.Width - 2 - (btngo.Width * 2) - 2; + btngo.Location = new Point(flcontrols.Width - btngo.Width - 2, 2); + btnback.Enabled = wbmain.CanGoBack; + btnforward.Enabled = wbmain.CanGoForward; + }; + uiupdate.Interval = 100; + } + + Timer uiupdate = null; + + public void OnLoad() + { + uiupdate.Start(); + wbmain.Url = new Uri("http://getshiftos.ml/"); + } + + public void OnSkinLoad() + { + } + + public bool OnUnload() + { + uiupdate.Stop(); + return true; + } + + public void OnUpgrade() + { + } + + private void btnback_Click(object sender, EventArgs e) + { + wbmain.GoBack(); + } + + private void btnforward_Click(object sender, EventArgs e) + { + wbmain.GoForward(); + } + + private void btngo_Click(object sender, EventArgs e) + { + wbmain.Navigate(txturl.Text); + } + + private void wbmain_NewWindow(object sender, CancelEventArgs e) + { + e.Cancel = true; + if (Shiftorium.UpgradeInstalled("web_browser_new_window")) + { + AppearanceManager.SetupWindow(new WebBrowser()); + } + } + + private void txturl_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Enter) + btngo_Click(sender, EventArgs.Empty); + } + + private void wbmain_Navigated(object sender, WebBrowserNavigatedEventArgs e) + { + txturl.Text = wbmain.Url.ToString(); + AppearanceManager.SetWindowTitle(this, wbmain.DocumentTitle + " - " + NameChangerBackend.GetNameRaw(this.GetType())); + } + } +} diff --git a/ShiftOS.WinForms/Applications/WebBrowser.resx b/ShiftOS.WinForms/Applications/WebBrowser.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/ShiftOS.WinForms/Applications/WebBrowser.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/ShiftOS.WinForms/Resources/Shiftorium.txt b/ShiftOS.WinForms/Resources/Shiftorium.txt index 4bd2e8d..cc68c6f 100644 --- a/ShiftOS.WinForms/Resources/Shiftorium.txt +++ b/ShiftOS.WinForms/Resources/Shiftorium.txt @@ -8,8 +8,6 @@ Category: "Enhancements", }, { -<<<<<<< HEAD -======= Name: "Shift Progress Bar", Cost: 150, Description: "Want to customize the look of all ShiftOS Progress Bars? Buy this upgrade today and you'll get the ability to set the foreground and background color of the progress bar, and many more things!.", @@ -24,7 +22,6 @@ Category: "Customization" }, { ->>>>>>> 9999324bd7751f536741c108322766421dae1a52 Name: "GUI Based Login Screen", Cost: 500, Description: "Tired of using the text-based login screen in ShiftOS? Well, we have a functioning window manager, and a functioning desktop, why not use these tools to create a functioning and awesome-looking login screen?", diff --git a/ShiftOS.WinForms/ShiftOS.WinForms.csproj b/ShiftOS.WinForms/ShiftOS.WinForms.csproj index b74003f..9675744 100644 --- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj +++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj @@ -274,6 +274,12 @@ VideoPlayer.cs + + UserControl + + + WebBrowser.cs + UserControl @@ -523,6 +529,9 @@ VideoPlayer.cs + + WebBrowser.cs + WidgetManagerFrontend.cs -- cgit v1.2.3 From 8e345174ee0796084c542681208c57fa8f962f61 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 24 May 2017 16:41:49 -0400 Subject: Dramatically increase terminal performance. --- ShiftOS.WinForms/Controls/TerminalBox.cs | 2 + ShiftOS_TheReturn/Commands.cs | 133 ++------- ShiftOS_TheReturn/KernelWatchdog.cs | 34 +-- ShiftOS_TheReturn/SaveSystem.cs | 3 +- ShiftOS_TheReturn/Shiftorium.cs | 2 + ShiftOS_TheReturn/TerminalBackend.cs | 496 ++++++++++++++++--------------- 6 files changed, 302 insertions(+), 368 deletions(-) (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.WinForms/Controls/TerminalBox.cs b/ShiftOS.WinForms/Controls/TerminalBox.cs index e95d038..a6dd610 100644 --- a/ShiftOS.WinForms/Controls/TerminalBox.cs +++ b/ShiftOS.WinForms/Controls/TerminalBox.cs @@ -63,6 +63,7 @@ namespace ShiftOS.WinForms.Controls public void Write(string text) { + Thread.Sleep(5); this.SuspendLayout(); this.HideSelection = true; this.SelectionFont = ConstructFont(); @@ -88,6 +89,7 @@ namespace ShiftOS.WinForms.Controls public void WriteLine(string text) { + Thread.Sleep(5); this.SuspendLayout(); Engine.AudioManager.PlayStream(Properties.Resources.writesound); this.HideSelection = true; diff --git a/ShiftOS_TheReturn/Commands.cs b/ShiftOS_TheReturn/Commands.cs index c2005f2..96e5af5 100644 --- a/ShiftOS_TheReturn/Commands.cs +++ b/ShiftOS_TheReturn/Commands.cs @@ -330,8 +330,13 @@ namespace ShiftOS.Engine { foreach (var upg in Shiftorium.GetDefaults()) { - Shiftorium.Buy(upg.ID, 0); + if (!SaveSystem.CurrentSave.Upgrades.ContainsKey(upg.ID)) + SaveSystem.CurrentSave.Upgrades.Add(upg.ID, true); + else + SaveSystem.CurrentSave.Upgrades[upg.ID] = true; } + Shiftorium.InvokeUpgradeInstalled(); + SkinEngine.LoadSkin(); return true; } @@ -453,122 +458,40 @@ namespace ShiftOS.Engine [Command("help", "{COMMAND_HELP_USAGE", "{COMMAND_HELP_DESCRIPTION}")] public static bool Help(Dictionary args) { - Console.WriteLine("Retrieving help data..."); + var sb = new StringBuilder(); + sb.AppendLine("Retrieving help data."); + if (args.ContainsKey("ns")) { - if (args["ns"] is string) + string ns = args["ns"].ToString(); + //First let's check for a command that has this namespace. + var cmdtest = TerminalBackend.Commands.FirstOrDefault(x => x.NamespaceInfo.name == ns); + if (cmdtest == null) //Namespace not found. + sb.AppendLine("Error retrieving help for namespace \"" + ns + "\". Namespace not found."); + else { - string ns = args["ns"].ToString(); - bool foundNS = false; - foreach (var exec in System.IO.Directory.GetFiles(Environment.CurrentDirectory)) + //Now do the actual scan. + sb.AppendLine("Namespace: " + ns); + foreach(var cmd in TerminalBackend.Commands.Where(x => x.NamespaceInfo.name == ns)) { - if (exec.EndsWith(".exe") || exec.EndsWith(".dll")) - { - try - { - var asm = Assembly.LoadFile(exec); - - var types = asm.GetTypes(); - - foreach (var type in types) - { - if (Shiftorium.UpgradeAttributesUnlocked(type)) - { - var nsa = (Namespace)type.GetCustomAttributes(false).FirstOrDefault(x => x is Namespace && (x as Namespace).name == ns); - - if (nsa != null) - { - - if (!nsa.hide) - { - foundNS = true; - string descp = "{NAMESPACE_" + nsa.name.ToUpper() + "_DESCRIPTION}"; - if (descp == Localization.Parse(descp)) - descp = ""; - else - descp = Shiftorium.UpgradeInstalled("help_description") ? Localization.Parse("{SEPERATOR}" + descp) : ""; - - Console.WriteLine($"{{NAMESPACE}}{nsa.name}" + descp); - - foreach (var method in type.GetMethods(BindingFlags.Public | BindingFlags.Static)) - { - if (Shiftorium.UpgradeAttributesUnlocked(method)) - { - foreach (var ma in method.GetCustomAttributes(false)) - { - if (ma is Command) - { - var cmd = ma as Command; - - if (!cmd.hide) - { - string descriptionparse = "{COMMAND_" + nsa.name.ToUpper() + "_" + cmd.name.ToUpper() + "_DESCRIPTION}"; - string usageparse = "{COMMAND_" + nsa.name.ToUpper() + "_" + cmd.name.ToUpper() + "_USAGE}"; - if (descriptionparse == Localization.Parse(descriptionparse)) - descriptionparse = ""; - else - descriptionparse = Shiftorium.UpgradeInstalled("help_description") ? Localization.Parse("{SEPERATOR}" + descriptionparse) : ""; - - if (usageparse == Localization.Parse(usageparse)) - usageparse = ""; - else - usageparse = Shiftorium.UpgradeInstalled("help_usage") ? Localization.Parse("{SEPERATOR}" + usageparse, new Dictionary() { - {"%ns", nsa.name}, - {"%cmd", cmd.name} - }) : ""; - - Console.WriteLine($"{{COMMAND}}{nsa.name}.{cmd.name}" + usageparse + descriptionparse); - } - } - } - } - - } - } - } - } - } - - } - - - - - catch { } - } + string str = cmd.ToString(); + str = str.Replace(str.Substring(str.LastIndexOf("|")), ""); + sb.AppendLine(str); } - if (foundNS == false) - { - Console.WriteLine("Error: Namespace not found! Couldn't retrieve help info."); - } - } - return true; } - - foreach(var exec in System.IO.Directory.GetFiles(Environment.CurrentDirectory)) + else { - if(exec.ToLower().EndsWith(".exe") || exec.ToLower().EndsWith(".dll")) + + //print all unique namespaces. + foreach(var n in TerminalBackend.Commands.Select(x => x.NamespaceInfo.name).Distinct()) { - try - { - var asm = Assembly.LoadFile(exec); - foreach(var type in asm.GetTypes()) - { - Namespace ns = type.GetCustomAttributes(false).FirstOrDefault(x => x is Namespace) as Namespace; - if(ns != null) - { - if(!ns.hide) - { - Console.WriteLine("sos.help{ns:\"" + ns.name + "\"}"); - } - } - } - } - catch { } + sb.AppendLine("sos.help{ns:\"" + n + "\"}"); } } + Console.WriteLine(sb.ToString()); + return true; } diff --git a/ShiftOS_TheReturn/KernelWatchdog.cs b/ShiftOS_TheReturn/KernelWatchdog.cs index 66ec1f7..0608c46 100644 --- a/ShiftOS_TheReturn/KernelWatchdog.cs +++ b/ShiftOS_TheReturn/KernelWatchdog.cs @@ -66,41 +66,19 @@ namespace ShiftOS.Engine } } - //determines if user is root - public static bool IsSafe(Type type) + public static bool IsSafe(TerminalBackend.TerminalCommand cmd) { - if (SaveSystem.CurrentUser.Permissions == Objects.UserPermissions.Root) + if (!cmd.RequiresElevation) return true; - - foreach (var attrib in type.GetCustomAttributes(false)) + else { - if (attrib is KernelModeAttribute) - { - if (SaveSystem.CurrentUser.Permissions == Objects.UserPermissions.Root) - return true; + if (SaveSystem.CurrentUser.Permissions == Objects.UserPermissions.Root) + return true; + else return false; - } } - return true; } - //also determines if user is root, only for a method instead - public static bool IsSafe(MethodInfo type) - { - if (SaveSystem.CurrentUser.Permissions == Objects.UserPermissions.Root) - return true; - - foreach (var attrib in type.GetCustomAttributes(false)) - { - if (attrib is KernelModeAttribute) - { - if (SaveSystem.CurrentUser.Permissions == Objects.UserPermissions.Root) - return true; - return false; - } - } - return true; - } static string regularUsername = ""; //put regular username in here later diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index 9c812c7..d74006a 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -137,7 +137,8 @@ namespace ShiftOS.Engine Thread.Sleep(100); Console.WriteLine("[sfs] 4096 blocks read."); Console.WriteLine("[simpl-conf] Reading configuration files (global-3.conf)"); - + Console.WriteLine("[termdb] Building command database from filesystem..."); + TerminalBackend.PopulateTerminalCommands(); Console.WriteLine("[inetd] Connecting to network..."); Ready = false; diff --git a/ShiftOS_TheReturn/Shiftorium.cs b/ShiftOS_TheReturn/Shiftorium.cs index fe436d4..0ac784e 100644 --- a/ShiftOS_TheReturn/Shiftorium.cs +++ b/ShiftOS_TheReturn/Shiftorium.cs @@ -312,6 +312,8 @@ namespace ShiftOS.Engine /// Whether the upgrade is installed. public static bool UpgradeInstalled(string id) { + if (string.IsNullOrWhiteSpace(id)) + return true; if (SaveSystem.CurrentSave != null) { if (!IsInitiated) diff --git a/ShiftOS_TheReturn/TerminalBackend.cs b/ShiftOS_TheReturn/TerminalBackend.cs index 79c6349..6a15d3e 100644 --- a/ShiftOS_TheReturn/TerminalBackend.cs +++ b/ShiftOS_TheReturn/TerminalBackend.cs @@ -24,6 +24,7 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Reflection; using System.Text; @@ -136,6 +137,218 @@ namespace ShiftOS.Engine return JsonConvert.SerializeObject(args); } + public class TerminalCommand + { + public override int GetHashCode() + { + int hash = 0; + foreach (char c in ToString()) + { + hash += (int)c; + } + return hash; + } + + public Namespace NamespaceInfo { get; set; } + public Command CommandInfo { get; set; } + + public List RequiredArguments { get; set; } + public string Dependencies { get; set; } + + public MethodInfo CommandHandler; + + public Type CommandType; + + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append(this.NamespaceInfo.name); + sb.Append("."); + sb.Append(this.CommandInfo.name); + if (this.RequiredArguments.Count > 0) + { + sb.Append("{"); + foreach (var arg in RequiredArguments) + { + sb.Append(arg); + sb.Append(":"); + if (RequiredArguments.IndexOf(arg) < RequiredArguments.Count - 1) + sb.Append(','); + } + sb.Append("}"); + } + sb.Append("|"); + sb.Append(CommandHandler.Name + "()"); + return sb.ToString(); + } + + public bool RequiresElevation { get; set; } + + public void Invoke(Dictionary args) + { + List errors = new List(); + bool requiresAuth = false; + if (!KernelWatchdog.IsSafe(this)) + { + if (SaveSystem.CurrentUser.Permissions == Objects.UserPermissions.Admin) + requiresAuth = true; + else + errors.Add("You can't run this command - you do not have permission."); + } + if (errors.Count > 0) + { + foreach (var error in errors) + { + Console.WriteLine("Command error: " + error); + } + return; + } + if (requiresAuth) + { + Infobox.PromptText("Enter your password.", "This command requires you to have elevated permissions. Please enter your password to confirm this action.", (pass) => + { + if (pass == SaveSystem.CurrentUser.Password) + { + var uname = SaveSystem.CurrentUser.Username; + SaveSystem.CurrentUser = SaveSystem.CurrentSave.Users.FirstOrDefault(x => x.Username == "root"); + try + { + var h = CommandHandler; + h.Invoke(null, new[] { args }); + } + catch + { + var h = CommandHandler; + h.Invoke(null, null); + } + SaveSystem.CurrentUser = SaveSystem.CurrentSave.Users.FirstOrDefault(x => x.Username == uname); + } + else + { + Infobox.Show("Access denied.", "Incorrect password provided. The command will not run."); + } + }, true); + } + + try + { + CommandHandler.Invoke(null, new[] { args }); + } + catch + { + CommandHandler.Invoke(null, null); + } + } + } + + public class MemoryTextWriter : System.IO.TextWriter + { + public override Encoding Encoding + { + get + { + return Encoding.Unicode; + } + } + + private StringBuilder sb = null; + + public MemoryTextWriter() + { + sb = new StringBuilder(); + } + + public override string ToString() + { + return sb.ToString(); + } + + public override void Write(char value) + { + sb.Append(value); + } + + public override void WriteLine() + { + sb.AppendLine(); + } + + public override void Write(string value) + { + sb.Append(value); + } + + public override void Close() + { + sb.Clear(); + sb = null; + base.Close(); + } + + public override void WriteLine(string value) + { + sb.AppendLine(value); + } + } + + public static List Commands { get; private set; } + + public static void PopulateTerminalCommands() + { + Commands = new List(); + foreach(var exec in System.IO.Directory.GetFiles(Environment.CurrentDirectory)) + { + if(exec.ToLower().EndsWith(".exe") || exec.ToLower().EndsWith(".dll")) + { + try + { + var asm = Assembly.LoadFile(exec); + foreach(var type in asm.GetTypes()) + { + var ns = type.GetCustomAttributes(false).FirstOrDefault(x => x is Namespace) as Namespace; + if(ns != null) + { + foreach(var mth in type.GetMethods(BindingFlags.Public | BindingFlags.Static)) + { + var cmd = mth.GetCustomAttributes(false).FirstOrDefault(x => x is Command); + if(cmd != null) + { + var tc = new TerminalCommand(); + tc.RequiresElevation = !(type.GetCustomAttributes(false).FirstOrDefault(x => x is KernelModeAttribute) == null); + + tc.NamespaceInfo = ns; + + tc.CommandInfo = cmd as Command; + tc.RequiresElevation = tc.RequiresElevation || !(mth.GetCustomAttributes(false).FirstOrDefault(x => x is KernelModeAttribute) == null); + tc.RequiredArguments = new List(); + foreach (var arg in mth.GetCustomAttributes(false).Where(x=>x is RequiresArgument)) + { + var rarg = arg as RequiresArgument; + tc.RequiredArguments.Add(rarg.argument); + } + var rupg = mth.GetCustomAttributes(false).FirstOrDefault(x => x is RequiresUpgradeAttribute) as RequiresUpgradeAttribute; + if (rupg != null) + tc.Dependencies = rupg.Upgrade; + else + tc.Dependencies = ""; + tc.CommandType = type; + tc.CommandHandler = mth; + if (!Commands.Contains(tc)) + Commands.Add(tc); + } + } + } + } + } + catch(Exception e) + { + Console.WriteLine("[termdb] Error: " + e.ToString()); + } + } + } + Console.WriteLine("[termdb] " + Commands.Count + " commands found."); + } + /// /// Invokes a ShiftOS terminal command. /// @@ -150,19 +363,27 @@ namespace ShiftOS.Engine var args = GetArgs(ref text); + Stopwatch debugger = new Stopwatch(); + debugger.Start(); bool commandWasClient = RunClient(text, args, isRemote); if (!commandWasClient) { - PrefixEnabled = false; - - ServerManager.SendMessage("script", $@"{{ - user: ""{text.Split('.')[0]}"", - script: ""{text.Split('.')[1]}"", - args: ""{GetSentArgs(args)}"" -}}"); + Console.WriteLine("Command not found."); + debugger.Stop(); + return; } CommandProcessed?.Invoke(text, GetSentArgs(args)); + debugger.Stop(); + ConsoleEx.ForegroundColor = ConsoleColor.White; + Console.Write("<"); + ConsoleEx.Bold = true; + ConsoleEx.ForegroundColor = ConsoleColor.Blue; + Console.Write("debugger"); + ConsoleEx.ForegroundColor = ConsoleColor.White; + ConsoleEx.Bold = false; + Console.Write("> "); + Console.WriteLine("Command " + text + " took " + debugger.Elapsed.ToString() + " to execute."); } catch (Exception ex) { @@ -263,237 +484,44 @@ namespace ShiftOS.Engine //Console.WriteLine(text + " " + "{" + string.Join(",", args.Select(kv => kv.Key + "=" + kv.Value).ToArray()) + "}" + " " + isRemote); - foreach (var asmExec in System.IO.Directory.GetFiles(Environment.CurrentDirectory)) + var tw = new MemoryTextWriter(); + Console.SetOut(tw); + + string[] split = text.Split('.'); + var cmd = Commands.FirstOrDefault(x => x.NamespaceInfo.name == split[0] && x.CommandInfo.name == split[1]); + if (cmd == null) + return false; + if (!Shiftorium.UpgradeInstalled(cmd.Dependencies)) + return false; + if(cmd.RequiredArguments.Count != args.Count) { - try + Console.WriteLine("Command error: Argument count mismatch! You supplied " + args.Count + " arguments to a command that expects " + cmd.RequiredArguments.Count + "."); + return true; + } + bool res = false; + foreach (var arg in cmd.RequiredArguments) + { + if (!args.ContainsKey(arg)) { - var asm = Assembly.LoadFile(asmExec); - - var types = asm.GetTypes(); - foreach (var type in types) - { - if (Shiftorium.UpgradeAttributesUnlocked(type)) - { - foreach (var a in type.GetCustomAttributes(false)) - { - if (a is Namespace) - { - var ns = a as Namespace; - if (text.Split('.')[0] == ns.name) - { - if (KernelWatchdog.IsSafe(type)) - { - if (KernelWatchdog.CanRunOffline(type)) - { - foreach (var method in type.GetMethods(BindingFlags.Public | BindingFlags.Static)) - { - if (Shiftorium.UpgradeAttributesUnlocked(method)) - { - foreach (var ma in method.GetCustomAttributes(false)) - { - if (ma is Command) - { - var cmd = ma as Command; - if (text.Split('.')[1] == cmd.name) - { - if (KernelWatchdog.IsSafe(method)) - { - if (KernelWatchdog.CanRunOffline(method)) - { - var attr = method.GetCustomAttribute(); - - if (attr != null) - { - string newcommand = attr.newcommand; - if (attr.warn) - { - Console.WriteLine(Localization.Parse((newcommand == "" ? "{ERROR}" : "{WARN}") + attr.reason, new Dictionary() { - {"%newcommand", newcommand} - })); - } - if (newcommand != "") - { - // redo the entire process running newcommand - - return RunClient(newcommand, args); - } - } - - var requiresArgs = method.GetCustomAttributes(); - bool error = false; - bool providedusage = false; - - foreach (RequiresArgument argument in requiresArgs) - { - if (!args.ContainsKey(argument.argument)) - { - - if (!providedusage) - { - string usageparse = "{COMMAND_" + ns.name.ToUpper() + "_" + cmd.name.ToUpper() + "_USAGE}"; - if (usageparse == Localization.Parse(usageparse)) - usageparse = ""; - else - usageparse = Shiftorium.UpgradeInstalled("help_usage") ? Localization.Parse("{ERROR}{USAGE}" + usageparse, new Dictionary() { - {"%ns", ns.name}, - {"%cmd", cmd.name} - }) : ""; - - Console.WriteLine(usageparse); - - providedusage = true; - } - if (Shiftorium.UpgradeInstalled("help_usage")) - { - Console.WriteLine(Localization.Parse("{ERROR_ARGUMENT_REQUIRED}", new Dictionary() { - {"%argument", argument.argument} - })); - } - else - { - Console.WriteLine(Localization.Parse("{ERROR_ARGUMENT_REQUIRED_NO_USAGE}")); - } - - error = true; - } - } - - if (error) - { - throw new Exception("{ERROR_COMMAND_WRONG}"); - } - - try - { - return (bool)method.Invoke(null, new[] { args }); - } - catch (TargetInvocationException e) - { - Console.WriteLine(Localization.Parse("{ERROR_EXCEPTION_THROWN_IN_METHOD}")); - Console.WriteLine(e.InnerException.Message); - Console.WriteLine(e.InnerException.StackTrace); - return true; - } - catch - { - return (bool)method.Invoke(null, new object[] { }); - } - } - else - { - Console.Write("<"); - ConsoleEx.Bold = true; - ConsoleEx.ForegroundColor = ConsoleColor.DarkRed; - Console.Write("session_mgr"); - ConsoleEx.ForegroundColor = SkinEngine.LoadedSkin.TerminalForeColorCC; - ConsoleEx.Bold = false; - Console.Write(">"); - ConsoleEx.Italic = true; - ConsoleEx.ForegroundColor = ConsoleColor.DarkYellow; - Console.WriteLine(" You cannot run this command while disconnected from the multi-user domain.."); - return true; - - } - } - else - { - if (SaveSystem.CurrentUser.Permissions == Objects.UserPermissions.Admin) - { - Infobox.PromptText("Elevate to root mode", "This command cannot be run as a regular user. To run this command, please enter your password to elevate to root mode temporarily.", (pass) => - { - if (pass == SaveSystem.CurrentUser.Password) - { - KernelWatchdog.EnterKernelMode(); - RunClient(text, args, isRemote); - KernelWatchdog.LeaveKernelMode(); - } - else - { - Infobox.Show("Access denied.", "You did not type in the correct password."); - } - }, true); - return true; - } - Console.Write("<"); - ConsoleEx.Bold = true; - ConsoleEx.ForegroundColor = ConsoleColor.DarkRed; - Console.Write("watchdog"); - ConsoleEx.ForegroundColor = SkinEngine.LoadedSkin.TerminalForeColorCC; - ConsoleEx.Bold = false; - Console.Write(">"); - ConsoleEx.Italic = true; - ConsoleEx.ForegroundColor = ConsoleColor.DarkYellow; - Console.WriteLine(" You cannot run this command. You do not have permission. Incident reported."); - KernelWatchdog.Log("potential_sys_breach", "user attempted to run kernel mode command " + text + " - watchdog has prevented this, good sir."); - return true; - } - } - } - - - } - } - - else - { - Console.Write("<"); - ConsoleEx.Bold = true; - ConsoleEx.ForegroundColor = ConsoleColor.DarkRed; - Console.Write("session_mgr"); - ConsoleEx.ForegroundColor = SkinEngine.LoadedSkin.TerminalForeColorCC; - ConsoleEx.Bold = false; - Console.Write(">"); - ConsoleEx.Italic = true; - ConsoleEx.ForegroundColor = ConsoleColor.DarkYellow; - Console.WriteLine(" You cannot run this command while disconnected from the multi-user domain.."); - return true; - - } - - } - } - else - { - if (SaveSystem.CurrentUser.Permissions == Objects.UserPermissions.Admin) - { - Infobox.PromptText("Elevate to root mode", "This command cannot be run as a regular user. To run this command, please enter your password to elevate to root mode temporarily.", (pass) => - { - if (pass == SaveSystem.CurrentUser.Password) - { - KernelWatchdog.EnterKernelMode(); - RunClient(text, args, isRemote); - KernelWatchdog.LeaveKernelMode(); - } - else - { - Infobox.Show("Access denied.", "You did not type in the correct password."); - } - }, true); - return true; - } - Console.Write("<"); - ConsoleEx.Bold = true; - ConsoleEx.ForegroundColor = ConsoleColor.DarkRed; - Console.Write("watchdog"); - ConsoleEx.ForegroundColor = SkinEngine.LoadedSkin.TerminalForeColorCC; - ConsoleEx.Bold = false; - Console.Write(">"); - ConsoleEx.Italic = true; - ConsoleEx.ForegroundColor = ConsoleColor.DarkYellow; - Console.WriteLine(" You cannot run this command. You do not have permission. Incident reported."); - KernelWatchdog.Log("potential_sys_breach", "user attempted to run kernel mode command " + text + " - watchdog has prevented this, good sir."); - return true; - } - } - } - } - } - } - } + res = true; + Console.WriteLine("You are missing an argument with the key \"" + arg + "\"."); } - catch { } } - return false; + if (res == true) + return true; + try + { + cmd.Invoke(args); + } + catch(Exception ex) + { + Console.WriteLine("Command error: " + ex.Message); + } + + string buffer = tw.ToString(); + Console.SetOut(new TerminalTextWriter()); + Console.Write(buffer); + return true; } /// -- cgit v1.2.3 From 97e22b35ada5898fdcb2556628f764d927cff913 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 26 May 2017 17:06:38 -0400 Subject: SLIGHT optimizations? --- ShiftOS.WinForms/Applications/Shifter.cs | 679 ++++++++++++----------- ShiftOS.WinForms/Applications/Terminal.cs | 4 + ShiftOS.WinForms/Servers/RemoteTerminalServer.cs | 161 ++++++ ShiftOS.WinForms/ShiftOS.WinForms.csproj | 1 + ShiftOS.WinForms/Tools/ControlManager.cs | 13 +- ShiftOS_TheReturn/Localization.cs | 4 - ShiftOS_TheReturn/Server.cs | 40 ++ ShiftOS_TheReturn/ServerManager.cs | 62 +++ ShiftOS_TheReturn/ShiftOS.Engine.csproj | 1 + ShiftOS_TheReturn/TerminalBackend.cs | 9 +- 10 files changed, 635 insertions(+), 339 deletions(-) create mode 100644 ShiftOS.WinForms/Servers/RemoteTerminalServer.cs create mode 100644 ShiftOS_TheReturn/Server.cs (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.WinForms/Applications/Shifter.cs b/ShiftOS.WinForms/Applications/Shifter.cs index acb64a5..1a59c80 100644 --- a/ShiftOS.WinForms/Applications/Shifter.cs +++ b/ShiftOS.WinForms/Applications/Shifter.cs @@ -31,6 +31,8 @@ using System.Reflection; using System.Windows.Forms; using ShiftOS.Engine; using ShiftOS.WinForms.Tools; +using System.Linq; +using System.Threading; namespace ShiftOS.WinForms.Applications { @@ -540,400 +542,425 @@ namespace ShiftOS.WinForms.Applications { flbody.Controls.Clear(); - List cats = new List(); + IEnumerable cats = this.settings.Where(x => x.SubCategory == subcat && x.Category == cat && x.Field.FlagFullfilled(LoadedSkin)).OrderBy(x=>x.Name); - foreach (var c in this.settings) + new Thread(() => { - if (c.SubCategory == subcat && c.Category == cat) + foreach (var c in cats) { - if (c.Field.FlagFullfilled(LoadedSkin)) + Label lbl = null; + int labelHeight = 0; + Desktop.InvokeOnWorkerThread(() => { - if (!cats.Contains(c)) - { - cats.Add(c); - } - } - } - } - - foreach(var c in cats) - { - var lbl = new Label(); - int labelHeight = 0; - lbl.AutoSize = true; - lbl.Text = c.Name + ":"; - flbody.Controls.Add(lbl); - lbl.TextAlign = ContentAlignment.MiddleLeft; - lbl.Show(); - //Cool - label's in. - if(c.Field.FieldType == typeof(Point)) - { - var width = new TextBox(); - var height = new TextBox(); - labelHeight = width.Height; //irony? - width.Width = 30; - height.Width = width.Width; - width.Text = ((Point)c.Field.GetValue(this.LoadedSkin)).X.ToString(); - height.Text = ((Point)c.Field.GetValue(this.LoadedSkin)).Y.ToString(); - flbody.SetFlowBreak(height, true); - ControlManager.SetupControl(width); - ControlManager.SetupControl(height); - - flbody.Controls.Add(width); - width.Show(); - flbody.Controls.Add(height); - height.Show(); - - EventHandler tc = (o, a) => + lbl = new Label(); + lbl.AutoSize = true; + lbl.Text = c.Name + ":"; + flbody.Controls.Add(lbl); + lbl.TextAlign = ContentAlignment.MiddleLeft; + lbl.Show(); + }); + //Cool - label's in. + if (c.Field.FieldType == typeof(Point)) { - try + TextBox width = null; + TextBox height = null; + Desktop.InvokeOnWorkerThread(() => { - int x = Convert.ToInt32(width.Text); - int y = Convert.ToInt32(height.Text); + width = new TextBox(); + height = new TextBox(); + labelHeight = width.Height; //irony? + width.Width = 30; + height.Width = width.Width; + width.Text = ((Point)c.Field.GetValue(this.LoadedSkin)).X.ToString(); + height.Text = ((Point)c.Field.GetValue(this.LoadedSkin)).Y.ToString(); + flbody.SetFlowBreak(height, true); + ControlManager.SetupControl(width); + ControlManager.SetupControl(height); - int oldx = ((Point)c.Field.GetValue(this.LoadedSkin)).X; - int oldy = ((Point)c.Field.GetValue(this.LoadedSkin)).Y; + flbody.Controls.Add(width); + width.Show(); + flbody.Controls.Add(height); + height.Show(); - if(x != oldx || y != oldy) + EventHandler tc = (o, a) => { - c.Field.SetValue(LoadedSkin, new Point(x, y)); - CodepointValue += 200; - } - } - catch - { - width.Text = ((Point)c.Field.GetValue(this.LoadedSkin)).X.ToString(); - height.Text = ((Point)c.Field.GetValue(this.LoadedSkin)).Y.ToString(); - } - InvokeSetup(cat); - }; + try + { + int x = Convert.ToInt32(width.Text); + int y = Convert.ToInt32(height.Text); - width.TextChanged += tc; - height.TextChanged += tc; + int oldx = ((Point)c.Field.GetValue(this.LoadedSkin)).X; + int oldy = ((Point)c.Field.GetValue(this.LoadedSkin)).Y; - } - else if(c.Field.FieldType == typeof(string)) - { - var str = new TextBox(); - str.Width = 120; - ControlManager.SetupControl(str); - labelHeight = str.Height; - str.Text = c.Field.GetValue(LoadedSkin).ToString(); - flbody.SetFlowBreak(str, true); - str.TextChanged += (o, a) => - { - c.Field.SetValue(LoadedSkin, str.Text); CodepointValue += 100; + if (x != oldx || y != oldy) + { + c.Field.SetValue(LoadedSkin, new Point(x, y)); + CodepointValue += 200; + } + } + catch + { + width.Text = ((Point)c.Field.GetValue(this.LoadedSkin)).X.ToString(); + height.Text = ((Point)c.Field.GetValue(this.LoadedSkin)).Y.ToString(); + } + InvokeSetup(cat); + }; - InvokeSetup(cat); - }; - flbody.Controls.Add(str); - str.Show(); - } - else if(c.Field.FieldType == typeof(byte[])) - { - //We'll assume that this is an image file. - var color = new Button(); - color.Width = 40; - labelHeight = color.Height; - //just so it's flat like the system. - ControlManager.SetupControl(color); - flbody.SetFlowBreak(color, true); - - color.BackgroundImage = SkinEngine.ImageFromBinary((byte[])c.Field.GetValue(this.LoadedSkin)); - color.Click += (o, a) => + width.TextChanged += tc; + height.TextChanged += tc; + }); + } + else if (c.Field.FieldType == typeof(string)) { - AppearanceManager.SetupDialog(new GraphicPicker(color.BackgroundImage, c.Name, GetLayout(c.Field.GetImageName()), new Action((col, gdiImg, layout) => + Desktop.InvokeOnWorkerThread(() => { - c.Field.SetValue(LoadedSkin, col); - color.BackgroundImage = SkinEngine.ImageFromBinary(col); - color.BackgroundImageLayout = layout; - LoadedSkin.SkinImageLayouts[c.Field.GetImageName()] = layout; - CodepointValue += 700; - InvokeSetup(cat); - - }))); - }; - flbody.Controls.Add(color); - color.Show(); - } - else if (c.Field.FieldType == typeof(Size)) - { - var width = new TextBox(); - var height = new TextBox(); - width.Width = 30; - height.Width = width.Width; - labelHeight = width.Height; - flbody.SetFlowBreak(height, true); - - width.Text = ((Size)c.Field.GetValue(this.LoadedSkin)).Width.ToString(); - height.Text = ((Size)c.Field.GetValue(this.LoadedSkin)).Height.ToString(); - ControlManager.SetupControl(width); - ControlManager.SetupControl(height); - - flbody.Controls.Add(width); - width.Show(); - flbody.Controls.Add(height); - height.Show(); - - EventHandler tc = (o, a) => + var str = new TextBox(); + str.Width = 120; + ControlManager.SetupControl(str); + labelHeight = str.Height; + str.Text = c.Field.GetValue(LoadedSkin).ToString(); + flbody.SetFlowBreak(str, true); + str.TextChanged += (o, a) => + { + c.Field.SetValue(LoadedSkin, str.Text); CodepointValue += 100; + + InvokeSetup(cat); + }; + flbody.Controls.Add(str); + str.Show(); + }); + } + else if (c.Field.FieldType == typeof(byte[])) { - try + Desktop.InvokeOnWorkerThread(() => { - int x = Convert.ToInt32(width.Text); - int y = Convert.ToInt32(height.Text); - - int oldx = ((Size)c.Field.GetValue(this.LoadedSkin)).Width; - int oldy = ((Size)c.Field.GetValue(this.LoadedSkin)).Height; - - if (x != oldx || y != oldy) + //We'll assume that this is an image file. + var color = new Button(); + color.Width = 40; + labelHeight = color.Height; + //just so it's flat like the system. + ControlManager.SetupControl(color); + flbody.SetFlowBreak(color, true); + + color.BackgroundImage = SkinEngine.ImageFromBinary((byte[])c.Field.GetValue(this.LoadedSkin)); + color.Click += (o, a) => { - c.Field.SetValue(LoadedSkin, new Size(x, y)); - CodepointValue += 200; - } - } - catch + AppearanceManager.SetupDialog(new GraphicPicker(color.BackgroundImage, c.Name, GetLayout(c.Field.GetImageName()), new Action((col, gdiImg, layout) => + { + c.Field.SetValue(LoadedSkin, col); + color.BackgroundImage = SkinEngine.ImageFromBinary(col); + color.BackgroundImageLayout = layout; + LoadedSkin.SkinImageLayouts[c.Field.GetImageName()] = layout; + CodepointValue += 700; + InvokeSetup(cat); + + }))); + }; + flbody.Controls.Add(color); + color.Show(); + }); + } + else if (c.Field.FieldType == typeof(Size)) + { + Desktop.InvokeOnWorkerThread(() => { + var width = new TextBox(); + var height = new TextBox(); + width.Width = 30; + height.Width = width.Width; + labelHeight = width.Height; + flbody.SetFlowBreak(height, true); + width.Text = ((Size)c.Field.GetValue(this.LoadedSkin)).Width.ToString(); height.Text = ((Size)c.Field.GetValue(this.LoadedSkin)).Height.ToString(); - } - InvokeSetup(cat); + ControlManager.SetupControl(width); + ControlManager.SetupControl(height); - }; + flbody.Controls.Add(width); + width.Show(); + flbody.Controls.Add(height); + height.Show(); - width.TextChanged += tc; - height.TextChanged += tc; + EventHandler tc = (o, a) => + { + try + { + int x = Convert.ToInt32(width.Text); + int y = Convert.ToInt32(height.Text); - } - else if(c.Field.FieldType == typeof(bool)) - { - var check = new CheckBox(); - check.Checked = ((bool)c.Field.GetValue(LoadedSkin)); - labelHeight = check.Height; - check.CheckedChanged += (o, a) => - { - c.Field.SetValue(LoadedSkin, check.Checked); - CodepointValue += 50; - InvokeSetup(cat); + int oldx = ((Size)c.Field.GetValue(this.LoadedSkin)).Width; + int oldy = ((Size)c.Field.GetValue(this.LoadedSkin)).Height; - }; - flbody.SetFlowBreak(check, true); + if (x != oldx || y != oldy) + { + c.Field.SetValue(LoadedSkin, new Size(x, y)); + CodepointValue += 200; + } + } + catch + { + width.Text = ((Size)c.Field.GetValue(this.LoadedSkin)).Width.ToString(); + height.Text = ((Size)c.Field.GetValue(this.LoadedSkin)).Height.ToString(); + } + InvokeSetup(cat); - flbody.Controls.Add(check); - check.Show(); - } - else if(c.Field.FieldType == typeof(Font)) - { - var name = new ComboBox(); - var size = new TextBox(); - var style = new ComboBox(); - - name.Width = 120; - labelHeight = name.Height; - size.Width = 40; - style.Width = 80; - flbody.SetFlowBreak(style, true); - - ControlManager.SetupControl(name); - ControlManager.SetupControl(size); - ControlManager.SetupControl(style); - - //populate the font name box - foreach(var font in FontFamily.Families) - { - name.Items.Add(font.Name); + }; + + width.TextChanged += tc; + height.TextChanged += tc; + }); } - name.Text = ((Font)c.Field.GetValue(LoadedSkin)).Name; + else if (c.Field.FieldType == typeof(bool)) + { + Desktop.InvokeOnWorkerThread(() => + { + var check = new CheckBox(); + check.Checked = ((bool)c.Field.GetValue(LoadedSkin)); + labelHeight = check.Height; + check.CheckedChanged += (o, a) => + { + c.Field.SetValue(LoadedSkin, check.Checked); + CodepointValue += 50; + InvokeSetup(cat); - size.Text = ((Font)c.Field.GetValue(LoadedSkin)).Size.ToString(); + }; + flbody.SetFlowBreak(check, true); - //populate the style box - foreach(var s in (FontStyle[])Enum.GetValues(typeof(FontStyle))) - { - style.Items.Add(s.ToString()); + flbody.Controls.Add(check); + check.Show(); + }); } - style.Text = ((Font)c.Field.GetValue(LoadedSkin)).Style.ToString(); - - name.SelectedIndexChanged += (o, a) => + else if (c.Field.FieldType == typeof(Font)) { - var en = (FontStyle[])Enum.GetValues(typeof(FontStyle)); + Desktop.InvokeOnWorkerThread(() => + { + var name = new ComboBox(); + var size = new TextBox(); + var style = new ComboBox(); + + name.Width = 120; + labelHeight = name.Height; + size.Width = 40; + style.Width = 80; + flbody.SetFlowBreak(style, true); + + ControlManager.SetupControl(name); + ControlManager.SetupControl(size); + ControlManager.SetupControl(style); + + //populate the font name box + foreach (var font in FontFamily.Families) + { + name.Items.Add(font.Name); + } + name.Text = ((Font)c.Field.GetValue(LoadedSkin)).Name; - var f = en[style.SelectedIndex]; + size.Text = ((Font)c.Field.GetValue(LoadedSkin)).Size.ToString(); - c.Field.SetValue(LoadedSkin, new Font(name.Text, (float)Convert.ToDouble(size.Text), f)); - CodepointValue += 100; - InvokeSetup(cat); + //populate the style box + foreach (var s in (FontStyle[])Enum.GetValues(typeof(FontStyle))) + { + style.Items.Add(s.ToString()); + } + style.Text = ((Font)c.Field.GetValue(LoadedSkin)).Style.ToString(); - }; + name.SelectedIndexChanged += (o, a) => + { + var en = (FontStyle[])Enum.GetValues(typeof(FontStyle)); - style.SelectedIndexChanged += (o, a) => - { - var en = (FontStyle[])Enum.GetValues(typeof(FontStyle)); + var f = en[style.SelectedIndex]; - var f = en[style.SelectedIndex]; + c.Field.SetValue(LoadedSkin, new Font(name.Text, (float)Convert.ToDouble(size.Text), f)); + CodepointValue += 100; + InvokeSetup(cat); - c.Field.SetValue(LoadedSkin, new Font(name.Text, (float)Convert.ToDouble(size.Text), f)); - CodepointValue += 50; - InvokeSetup(cat); + }; - }; + style.SelectedIndexChanged += (o, a) => + { + var en = (FontStyle[])Enum.GetValues(typeof(FontStyle)); - size.TextChanged += (o, a) => - { - try - { - var en = (FontStyle[])Enum.GetValues(typeof(FontStyle)); + var f = en[style.SelectedIndex]; - var f = en[style.SelectedIndex]; + c.Field.SetValue(LoadedSkin, new Font(name.Text, (float)Convert.ToDouble(size.Text), f)); + CodepointValue += 50; + InvokeSetup(cat); - c.Field.SetValue(LoadedSkin, new Font(name.Text, (float)Convert.ToDouble(size.Text), f)); - } - catch - { - size.Text = ((Font)c.Field.GetValue(LoadedSkin)).Size.ToString(); - } - CodepointValue += 50; - InvokeSetup(cat); + }; - }; + size.TextChanged += (o, a) => + { + try + { + var en = (FontStyle[])Enum.GetValues(typeof(FontStyle)); - flbody.Controls.Add(name); - flbody.Controls.Add(size); - flbody.Controls.Add(style); + var f = en[style.SelectedIndex]; - name.Show(); - size.Show(); - style.Show(); + c.Field.SetValue(LoadedSkin, new Font(name.Text, (float)Convert.ToDouble(size.Text), f)); + } + catch + { + size.Text = ((Font)c.Field.GetValue(LoadedSkin)).Size.ToString(); + } + CodepointValue += 50; + InvokeSetup(cat); - } - else if(c.Field.FieldType == typeof(Color)) - { - var color = new Button(); - color.Width = 40; - labelHeight = color.Height; - //just so it's flat like the system. - ControlManager.SetupControl(color); - - color.BackColor = ((Color)c.Field.GetValue(LoadedSkin)); - color.Click += (o, a) => - { - AppearanceManager.SetupDialog(new ColorPicker((Color)c.Field.GetValue(LoadedSkin), c.Name, new Action((col) => - { - color.BackColor = col; - c.Field.SetValue(LoadedSkin, col); - CodepointValue += 300; - InvokeSetup(cat); - - }))); - }; - flbody.SetFlowBreak(color, true); - color.Tag = "keepbg"; - flbody.Controls.Add(color); - color.Show(); - } - else if(c.Field.FieldType.IsEnum == true) - { - var cBox = new ComboBox(); - cBox.Width = 150; - ControlManager.SetupControl(cBox); + }; + + flbody.Controls.Add(name); + flbody.Controls.Add(size); + flbody.Controls.Add(style); - foreach(var itm in Enum.GetNames(c.Field.FieldType)) + name.Show(); + size.Show(); + style.Show(); + }); + } + else if (c.Field.FieldType == typeof(Color)) { - cBox.Items.Add(itm); + Desktop.InvokeOnWorkerThread(() => + { + var color = new Button(); + color.Width = 40; + labelHeight = color.Height; + //just so it's flat like the system. + ControlManager.SetupControl(color); + + color.BackColor = ((Color)c.Field.GetValue(LoadedSkin)); + color.Click += (o, a) => + { + AppearanceManager.SetupDialog(new ColorPicker((Color)c.Field.GetValue(LoadedSkin), c.Name, new Action((col) => + { + color.BackColor = col; + c.Field.SetValue(LoadedSkin, col); + CodepointValue += 300; + InvokeSetup(cat); + + }))); + }; + flbody.SetFlowBreak(color, true); + color.Tag = "keepbg"; + flbody.Controls.Add(color); + color.Show(); + }); } - - cBox.Text = c.Field.GetValue(LoadedSkin).ToString(); - - cBox.SelectedIndexChanged += (o, a) => + else if (c.Field.FieldType.IsEnum == true) { - c.Field.SetValue(LoadedSkin, Enum.Parse(c.Field.FieldType, cBox.Text)); - InvokeSetup(cat); + Desktop.InvokeOnWorkerThread(() => + { + var cBox = new ComboBox(); + cBox.Width = 150; + ControlManager.SetupControl(cBox); - }; + foreach (var itm in Enum.GetNames(c.Field.FieldType)) + { + cBox.Items.Add(itm); + } - labelHeight = cBox.Height; + cBox.Text = c.Field.GetValue(LoadedSkin).ToString(); - flbody.Controls.Add(cBox); - cBox.Show(); - flbody.SetFlowBreak(cBox, true); - } - else if(c.Field.FieldType == typeof(int)) - { - if (c.Field.HasShifterEnumMask()) - { - var name = new ComboBox(); - name.Width = 120; - ControlManager.SetupControl(name); - string[] items = c.Field.GetShifterEnumMask(); - foreach(var item in items) - { - name.Items.Add(item); - } - name.SelectedIndex = (int)c.Field.GetValue(LoadedSkin); - name.SelectedIndexChanged += (o, a) => - { - c.Field.SetValue(LoadedSkin, name.SelectedIndex); - CodepointValue += 75; - InvokeSetup(cat); + cBox.SelectedIndexChanged += (o, a) => + { + c.Field.SetValue(LoadedSkin, Enum.Parse(c.Field.FieldType, cBox.Text)); + InvokeSetup(cat); + + }; - }; - labelHeight = name.Height; - flbody.Controls.Add(name); - name.Show(); - flbody.SetFlowBreak(name, true); + labelHeight = cBox.Height; + flbody.Controls.Add(cBox); + cBox.Show(); + flbody.SetFlowBreak(cBox, true); + }); } - else + else if (c.Field.FieldType == typeof(int)) { - var width = new TextBox(); - width.Width = 30; - width.Text = ((int)c.Field.GetValue(this.LoadedSkin)).ToString(); - ControlManager.SetupControl(width); - labelHeight = width.Height; - flbody.Controls.Add(width); - width.Show(); - - EventHandler tc = (o, a) => + Desktop.InvokeOnWorkerThread(() => { - try + if (c.Field.HasShifterEnumMask()) { - int x = Convert.ToInt32(width.Text); - - int oldx = ((int)c.Field.GetValue(this.LoadedSkin)); - - if (x != oldx) + var name = new ComboBox(); + name.Width = 120; + ControlManager.SetupControl(name); + string[] items = c.Field.GetShifterEnumMask(); + foreach (var item in items) { - c.Field.SetValue(LoadedSkin, x); - CodepointValue += 75; + name.Items.Add(item); } + name.SelectedIndex = (int)c.Field.GetValue(LoadedSkin); + name.SelectedIndexChanged += (o, a) => + { + c.Field.SetValue(LoadedSkin, name.SelectedIndex); + CodepointValue += 75; + InvokeSetup(cat); + + }; + labelHeight = name.Height; + flbody.Controls.Add(name); + name.Show(); + flbody.SetFlowBreak(name, true); + } - catch + else { + var width = new TextBox(); + width.Width = 30; width.Text = ((int)c.Field.GetValue(this.LoadedSkin)).ToString(); - } - InvokeSetup(cat); + ControlManager.SetupControl(width); + labelHeight = width.Height; + flbody.Controls.Add(width); + width.Show(); + + EventHandler tc = (o, a) => + { + try + { + int x = Convert.ToInt32(width.Text); + + int oldx = ((int)c.Field.GetValue(this.LoadedSkin)); - }; + if (x != oldx) + { + c.Field.SetValue(LoadedSkin, x); + CodepointValue += 75; + } + } + catch + { + width.Text = ((int)c.Field.GetValue(this.LoadedSkin)).ToString(); + } + InvokeSetup(cat); - width.TextChanged += tc; - flbody.SetFlowBreak(width, true); + }; + width.TextChanged += tc; + flbody.SetFlowBreak(width, true); + + } + }); } - } - lbl.AutoSize = false; - lbl.Width = (int)this.CreateGraphics().MeasureString(lbl.Text, SkinEngine.LoadedSkin.MainFont).Width + 15; - lbl.Height = labelHeight; - lbl.TextAlign = ContentAlignment.MiddleLeft; + Desktop.InvokeOnWorkerThread(() => + { + lbl.AutoSize = false; + lbl.Width = (int)this.CreateGraphics().MeasureString(lbl.Text, SkinEngine.LoadedSkin.MainFont).Width + 15; + lbl.Height = labelHeight; + lbl.TextAlign = ContentAlignment.MiddleLeft; + }); - if (!string.IsNullOrWhiteSpace(c.Description)) - { - var desc = new Label(); - flbody.SetFlowBreak(desc, true); - desc.Text = c.Description; - desc.AutoSize = true; - flbody.Controls.Add(desc); - desc.Show(); + if (!string.IsNullOrWhiteSpace(c.Description)) + { + Desktop.InvokeOnWorkerThread(() => + { + var desc = new Label(); + flbody.SetFlowBreak(desc, true); + desc.Text = c.Description; + desc.AutoSize = true; + flbody.Controls.Add(desc); + desc.Show(); + }); + } } - } + }).Start(); } public ImageLayout GetLayout(string name) diff --git a/ShiftOS.WinForms/Applications/Terminal.cs b/ShiftOS.WinForms/Applications/Terminal.cs index 664b657..ea24686 100644 --- a/ShiftOS.WinForms/Applications/Terminal.cs +++ b/ShiftOS.WinForms/Applications/Terminal.cs @@ -442,6 +442,10 @@ namespace ShiftOS.WinForms.Applications }).Start(); } + public static string RemoteSystemName { get; set; } + public static string RemoteUser { get; set; } + public static string RemotePass { get; set; } + [Story("first_steps")] public static void FirstSteps() { diff --git a/ShiftOS.WinForms/Servers/RemoteTerminalServer.cs b/ShiftOS.WinForms/Servers/RemoteTerminalServer.cs new file mode 100644 index 0000000..d57e28f --- /dev/null +++ b/ShiftOS.WinForms/Servers/RemoteTerminalServer.cs @@ -0,0 +1,161 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using Newtonsoft.Json; +using ShiftOS.Engine; +using ShiftOS.Objects; + +namespace ShiftOS.WinForms.Servers +{ + [Namespace("rts")] + [Server("Remote Terminal Server", 21)] + //[RequiresUpgrade("story_hacker101_breakingthebonds")] //Uncomment when story is implemented. + public class RemoteTerminalServer : Server + { + public void MessageReceived(ServerMessage msg) + { + var rtsMessage = JsonConvert.DeserializeObject(msg.Contents); + if (msg.Name == "disconnected") + { + if (Applications.Terminal.IsInRemoteSystem == true) + { + if (Applications.Terminal.RemoteSystemName == rtsMessage.SenderSystemName) + { + if(Applications.Terminal.RemoteUser == rtsMessage.Username) + if(Applications.Terminal.RemotePass == rtsMessage.Password) + { + Applications.Terminal.IsInRemoteSystem = false; + Applications.Terminal.RemoteSystemName = ""; + Applications.Terminal.RemoteUser = ""; + Applications.Terminal.RemotePass = ""; + TerminalBackend.PrefixEnabled = true; + TerminalBackend.PrintPrompt(); + } + } + } + return; + } + + string currentUserName = SaveSystem.CurrentUser.Username; + + var user = SaveSystem.CurrentSave.Users.FirstOrDefault(x => x.Username == rtsMessage.Username && x.Password == rtsMessage.Password); + + if(user == null) + { + ServerManager.SendMessageToIngameServer(rtsMessage.SenderSystemName, 0, "Access denied.", "The username and password you have provided was denied."); + return; + } + else + { + SaveSystem.CurrentUser = user; + + string cmd = rtsMessage.Namespace + "." + rtsMessage.Command + JsonConvert.SerializeObject(rtsMessage.Arguments); + TerminalBackend.InvokeCommand(cmd, true); + ServerManager.SendMessageToIngameServer(rtsMessage.SenderSystemName, 1, "writeline", TerminalBackend.LastCommandBuffer); + ServerManager.SendMessageToIngameServer(rtsMessage.SenderSystemName, 1, "write", $"{rtsMessage.Username}@{SaveSystem.CurrentSave.SystemName}:~$ "); + + SaveSystem.CurrentUser = SaveSystem.Users.FirstOrDefault(x => x.Username == currentUserName); + } + } + + [Command("connect")] + [RequiresArgument("sysname")] + [RequiresArgument("username")] + [RequiresArgument("password")] + public static bool Connect(Dictionary args) + { + string sysname = args["sysname"].ToString(); + string username = args["username"].ToString(); + string password = args["password"].ToString(); + + bool connectionFinished = false; + + + new Thread(() => + { + Thread.Sleep(10000); + if (connectionFinished == false) + { + Applications.Terminal.IsInRemoteSystem = false; + Applications.Terminal.RemoteSystemName = ""; + Applications.Terminal.RemoteUser = ""; + Applications.Terminal.RemotePass = ""; + TerminalBackend.PrefixEnabled = true; + Console.WriteLine("[rts] Connection failed, target system did not respond."); + TerminalBackend.PrintPrompt(); + + } + }).Start(); + + ServerMessageReceived smr = null; + smr = (msg) => + { + if (msg.Name == "msgtosys") + { + var m = JsonConvert.DeserializeObject(msg.Contents); + if (m.GUID.Split('|')[2] != ServerManager.thisGuid.ToString()) + { + connectionFinished = true; + ServerManager.MessageReceived -= smr; + } + } + }; + ServerManager.MessageReceived += smr; + ServerManager.SendMessageToIngameServer(sysname, 21, "cmd", JsonConvert.SerializeObject(new RTSMessage + { + SenderSystemName = SaveSystem.CurrentSave.SystemName, + Username = username, + Password = password, + Namespace = "trm", + Command = "clear" + })); + Applications.Terminal.IsInRemoteSystem = true; + Applications.Terminal.RemoteSystemName = sysname; + Applications.Terminal.RemoteUser = username; + Applications.Terminal.RemotePass = password; + TerminalBackend.PrefixEnabled = false; + return true; + } + } + + [Server("Generic port 0", 0)] + public class InfoboxServer : Server + { + public void MessageReceived(ServerMessage msg) + { + Infobox.Show(msg.Name, msg.Contents); + } + } + + [Server("Generic port 1", 1)] + public class ConsoleServer : Server + { + public void MessageReceived(ServerMessage msg) + { + switch (msg.Name) + { + case "write": + Console.Write(msg.Contents); + break; + case "writeline": + Console.WriteLine(msg.Contents); + break; + } + } + } + + public class RTSMessage + { + public string SenderSystemName { get; set; } + + public string Namespace { get; set; } + public string Command { get; set; } + public Dictionary Arguments { get; set; } + + public string Username { get; set; } + public string Password { get; set; } + } +} diff --git a/ShiftOS.WinForms/ShiftOS.WinForms.csproj b/ShiftOS.WinForms/ShiftOS.WinForms.csproj index 9675744..da8eafc 100644 --- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj +++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj @@ -363,6 +363,7 @@ Resources.resx + UserControl diff --git a/ShiftOS.WinForms/Tools/ControlManager.cs b/ShiftOS.WinForms/Tools/ControlManager.cs index fc9567d..1643b23 100644 --- a/ShiftOS.WinForms/Tools/ControlManager.cs +++ b/ShiftOS.WinForms/Tools/ControlManager.cs @@ -144,10 +144,7 @@ namespace ShiftOS.WinForms.Tools public static void SetupControl(Control ctrl) { - Desktop.InvokeOnWorkerThread(new Action(() => - { - ctrl.SuspendLayout(); - })); + if (!(ctrl is MenuStrip) && !(ctrl is ToolStrip) && !(ctrl is StatusStrip) && !(ctrl is ContextMenuStrip)) { string tag = ""; @@ -306,7 +303,6 @@ namespace ShiftOS.WinForms.Tools { MakeDoubleBuffered(ctrl); - ctrl.ResumeLayout(); }); ControlSetup?.Invoke(ctrl); } @@ -330,17 +326,18 @@ namespace ShiftOS.WinForms.Tools public static void SetupControls(Control frm, bool runInThread = true) { - SetupControl(frm); frm.Click += (o, a) => { Desktop.HideAppLauncher(); }; ThreadStart ts = () => { - for (int i = 0; i < frm.Controls.Count; i++) + var ctrls = frm.Controls.ToList(); + for (int i = 0; i < ctrls.Count(); i++) { - SetupControls(frm.Controls[i], false); + SetupControls(ctrls[i]); } + SetupControl(frm); }; diff --git a/ShiftOS_TheReturn/Localization.cs b/ShiftOS_TheReturn/Localization.cs index 2c701c9..5d848b0 100644 --- a/ShiftOS_TheReturn/Localization.cs +++ b/ShiftOS_TheReturn/Localization.cs @@ -117,10 +117,6 @@ namespace ShiftOS.Engine } List orphaned = new List(); - if (Utils.FileExists("0:/dev_orphaned_lang.txt")) - { - orphaned = JsonConvert.DeserializeObject>(Utils.ReadAllText("0:/dev_orphaned_lang.txt")); // if this file exists read from it and put in list orphaned - } int start_index = 0; diff --git a/ShiftOS_TheReturn/Server.cs b/ShiftOS_TheReturn/Server.cs new file mode 100644 index 0000000..ddbd15b --- /dev/null +++ b/ShiftOS_TheReturn/Server.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ShiftOS.Objects; + +namespace ShiftOS.Engine +{ + public interface Server + { + /// + /// Occurs when someone sends a message to the server. + /// + /// The message from the client. + void MessageReceived(ServerMessage msg); + } + + [AttributeUsage(AttributeTargets.Class, AllowMultiple=false)] + public class ServerAttribute : Attribute + { + public ServerAttribute(string name, int port) + { + Name = name; + Port = port; + } + + + /// + /// Gets the name of the server. + /// + public string Name { get; } + + /// + /// Gets the port of the server. + /// + public int Port { get; } + + } +} diff --git a/ShiftOS_TheReturn/ServerManager.cs b/ShiftOS_TheReturn/ServerManager.cs index 95e86e9..217b9ee 100644 --- a/ShiftOS_TheReturn/ServerManager.cs +++ b/ShiftOS_TheReturn/ServerManager.cs @@ -36,6 +36,8 @@ using static ShiftOS.Engine.SaveSystem; using Newtonsoft.Json; using System.Net.Sockets; using System.Diagnostics; +using System.IO; +using System.Reflection; namespace ShiftOS.Engine { @@ -104,6 +106,43 @@ Ping: {ServerManager.DigitalSocietyPing} ms /// public static event Action GUIDReceived; + private static void delegateToServer(ServerMessage msg) + { + string[] split = msg.GUID.Split('|'); + bool finished = false; + foreach (var exec in Directory.GetFiles(Environment.CurrentDirectory)) + { + if(exec.ToLower().EndsWith(".exe") || exec.ToLower().EndsWith(".dll")) + { + try + { + var asm = Assembly.LoadFile(exec); + foreach(var type in asm.GetTypes().Where(x => x.GetInterfaces().Contains(typeof(Server)))) + { + var attrib = type.GetCustomAttributes().FirstOrDefault(x => x is ServerAttribute) as ServerAttribute; + if(attrib != null) + { + if(split[0] == SaveSystem.CurrentSave.SystemName && split[1] == attrib.Port.ToString()) + { + if (Shiftorium.UpgradeAttributesUnlocked(type)) + { + type.GetMethods(BindingFlags.Public | BindingFlags.Instance).FirstOrDefault(x => x.Name == "MessageReceived")?.Invoke(Activator.CreateInstance(type), null); + finished = true; + } + } + } + } + } + catch { } + } + } + if (finished == false) + { + Forward(split[2], "Error", $"{split[0]}:{split[1]}: connection refused"); + } + } + + private static void ServerManager_MessageReceived(ServerMessage msg) { switch(msg.Name) @@ -119,12 +158,35 @@ Ping: {ServerManager.DigitalSocietyPing} ms })); } break; + case "msgtosys": + try + { + var m = JsonConvert.DeserializeObject(msg.Contents); + if(m.GUID.Split('|')[2] != thisGuid.ToString()) + { + delegateToServer(m); + } + } + catch { } + break; case "getguid_reply": GUIDReceived?.Invoke(msg.Contents); break; } } + public static void SendMessageToIngameServer(string sysname, int port, string title, string contents) + { + var smsg = new ServerMessage + { + Name = title, + GUID = $"{sysname}|{port}|{thisGuid.ToString()}", + Contents = contents + }; + Forward("all", "msgtosys", JsonConvert.SerializeObject(smsg)); + + } + public static void Detach_ServerManager_MessageReceived() { MessageReceived -= new ServerMessageReceived(ServerManager_MessageReceived); diff --git a/ShiftOS_TheReturn/ShiftOS.Engine.csproj b/ShiftOS_TheReturn/ShiftOS.Engine.csproj index 8b48023..9d7d696 100644 --- a/ShiftOS_TheReturn/ShiftOS.Engine.csproj +++ b/ShiftOS_TheReturn/ShiftOS.Engine.csproj @@ -124,6 +124,7 @@ + diff --git a/ShiftOS_TheReturn/TerminalBackend.cs b/ShiftOS_TheReturn/TerminalBackend.cs index c8619b5..b18e27c 100644 --- a/ShiftOS_TheReturn/TerminalBackend.cs +++ b/ShiftOS_TheReturn/TerminalBackend.cs @@ -84,6 +84,11 @@ namespace ShiftOS.Engine ///
public static string LastCommand = ""; + /// + /// Gets the output of the last command. + /// + public static string LastCommandBuffer { get; private set; } + /// /// Invokes a ShiftOS terminal command. /// @@ -395,8 +400,10 @@ namespace ShiftOS.Engine } string buffer = tw.ToString(); + LastCommandBuffer = buffer; Console.SetOut(new TerminalTextWriter()); - Console.Write(buffer); + if(!isRemote) + Console.Write(buffer); } -- cgit v1.2.3 From fde832b35763443afdc57dc8a5d82fb3bb25009b Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 27 May 2017 12:11:36 -0400 Subject: simplesrc refurbishment --- ShiftOS.Objects/ChatRoom.cs | 16 +++ ShiftOS.Objects/ShiftOS.Objects.csproj | 1 + ShiftOS.WinForms/Applications/Chat.Designer.cs | 97 +++++++++++++ ShiftOS.WinForms/Applications/Chat.cs | 161 +++++++++++++--------- ShiftOS.WinForms/Applications/MUDControlCentre.cs | 3 +- ShiftOS_TheReturn/Story.cs | 7 +- 6 files changed, 220 insertions(+), 65 deletions(-) create mode 100644 ShiftOS.Objects/ChatRoom.cs (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.Objects/ChatRoom.cs b/ShiftOS.Objects/ChatRoom.cs new file mode 100644 index 0000000..e4c89ce --- /dev/null +++ b/ShiftOS.Objects/ChatRoom.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ShiftOS.Objects +{ + public class ChatRoom + { + public string Id { get; set; } + public string Name { get; set; } + + public List Messages { get; set; } + } +} diff --git a/ShiftOS.Objects/ShiftOS.Objects.csproj b/ShiftOS.Objects/ShiftOS.Objects.csproj index 3c36d8c..9ed8c3b 100644 --- a/ShiftOS.Objects/ShiftOS.Objects.csproj +++ b/ShiftOS.Objects/ShiftOS.Objects.csproj @@ -45,6 +45,7 @@
+ diff --git a/ShiftOS.WinForms/Applications/Chat.Designer.cs b/ShiftOS.WinForms/Applications/Chat.Designer.cs index d4b7211..d51b732 100644 --- a/ShiftOS.WinForms/Applications/Chat.Designer.cs +++ b/ShiftOS.WinForms/Applications/Chat.Designer.cs @@ -61,13 +61,23 @@ namespace ShiftOS.WinForms.Applications this.tsbottombar = new System.Windows.Forms.ToolStrip(); this.txtuserinput = new System.Windows.Forms.ToolStripTextBox(); this.btnsend = new System.Windows.Forms.ToolStripButton(); + this.pnlstart = new System.Windows.Forms.Panel(); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); + this.txtchatid = new System.Windows.Forms.TextBox(); + this.btnjoin = new System.Windows.Forms.Button(); this.panel1.SuspendLayout(); this.toolStrip1.SuspendLayout(); this.tsbottombar.SuspendLayout(); + this.pnlstart.SuspendLayout(); + this.flowLayoutPanel1.SuspendLayout(); this.SuspendLayout(); // // panel1 // + this.panel1.Controls.Add(this.pnlstart); this.panel1.Controls.Add(this.rtbchat); this.panel1.Controls.Add(this.toolStrip1); this.panel1.Controls.Add(this.tsbottombar); @@ -141,6 +151,82 @@ namespace ShiftOS.WinForms.Applications this.btnsend.Text = "Send"; this.btnsend.Click += new System.EventHandler(this.btnsend_Click); // + // pnlstart + // + this.pnlstart.Controls.Add(this.flowLayoutPanel1); + this.pnlstart.Controls.Add(this.label3); + this.pnlstart.Controls.Add(this.label2); + this.pnlstart.Controls.Add(this.label1); + this.pnlstart.Dock = System.Windows.Forms.DockStyle.Fill; + this.pnlstart.Location = new System.Drawing.Point(0, 25); + this.pnlstart.Name = "pnlstart"; + this.pnlstart.Size = new System.Drawing.Size(633, 268); + this.pnlstart.TabIndex = 4; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Dock = System.Windows.Forms.DockStyle.Top; + this.label1.Location = new System.Drawing.Point(0, 0); + this.label1.Name = "label1"; + this.label1.Padding = new System.Windows.Forms.Padding(10); + this.label1.Size = new System.Drawing.Size(143, 33); + this.label1.TabIndex = 0; + this.label1.Tag = "header1"; + this.label1.Text = "Welcome to SimpleSRC!"; + // + // label2 + // + this.label2.Dock = System.Windows.Forms.DockStyle.Top; + this.label2.Location = new System.Drawing.Point(0, 33); + this.label2.Name = "label2"; + this.label2.Padding = new System.Windows.Forms.Padding(10); + this.label2.Size = new System.Drawing.Size(633, 52); + this.label2.TabIndex = 1; + this.label2.Text = "SimpleSRC is a simple chat program that utilises the ShiftOS Relay Chat protocol." + + " All you have to do is enter a chat code or system name, and SimpleSRC will try " + + "to initiate a chat for you."; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Dock = System.Windows.Forms.DockStyle.Top; + this.label3.Location = new System.Drawing.Point(0, 85); + this.label3.Name = "label3"; + this.label3.Padding = new System.Windows.Forms.Padding(10); + this.label3.Size = new System.Drawing.Size(79, 33); + this.label3.TabIndex = 2; + this.label3.Tag = "header3"; + this.label3.Text = "Join a chat"; + // + // flowLayoutPanel1 + // + this.flowLayoutPanel1.AutoSize = true; + this.flowLayoutPanel1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.flowLayoutPanel1.Controls.Add(this.txtchatid); + this.flowLayoutPanel1.Controls.Add(this.btnjoin); + this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Top; + this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 118); + this.flowLayoutPanel1.Name = "flowLayoutPanel1"; + this.flowLayoutPanel1.Size = new System.Drawing.Size(633, 29); + this.flowLayoutPanel1.TabIndex = 3; + // + // txtchatid + // + this.txtchatid.Location = new System.Drawing.Point(3, 3); + this.txtchatid.Name = "txtchatid"; + this.txtchatid.Size = new System.Drawing.Size(192, 20); + this.txtchatid.TabIndex = 0; + // + // btnjoin + // + this.btnjoin.Location = new System.Drawing.Point(201, 3); + this.btnjoin.Name = "btnjoin"; + this.btnjoin.Size = new System.Drawing.Size(75, 23); + this.btnjoin.TabIndex = 1; + this.btnjoin.Text = "Join"; + this.btnjoin.UseVisualStyleBackColor = true; + // // Chat // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -154,6 +240,10 @@ namespace ShiftOS.WinForms.Applications this.toolStrip1.PerformLayout(); this.tsbottombar.ResumeLayout(false); this.tsbottombar.PerformLayout(); + this.pnlstart.ResumeLayout(false); + this.pnlstart.PerformLayout(); + this.flowLayoutPanel1.ResumeLayout(false); + this.flowLayoutPanel1.PerformLayout(); this.ResumeLayout(false); } @@ -168,5 +258,12 @@ namespace ShiftOS.WinForms.Applications private System.Windows.Forms.ToolStrip tsbottombar; private System.Windows.Forms.ToolStripTextBox txtuserinput; private System.Windows.Forms.ToolStripButton btnsend; + private System.Windows.Forms.Panel pnlstart; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1; + private System.Windows.Forms.TextBox txtchatid; + private System.Windows.Forms.Button btnjoin; } } diff --git a/ShiftOS.WinForms/Applications/Chat.cs b/ShiftOS.WinForms/Applications/Chat.cs index caf8cd2..e150b1a 100644 --- a/ShiftOS.WinForms/Applications/Chat.cs +++ b/ShiftOS.WinForms/Applications/Chat.cs @@ -33,75 +33,26 @@ using System.Threading.Tasks; using System.Windows.Forms; using Newtonsoft.Json; using ShiftOS.Engine; +using System.Threading; namespace ShiftOS.WinForms.Applications { [MultiplayerOnly] + [WinOpen("simplesrc")] + [Launcher("SimpleSRC Client", false, null, "Networking")] + [DefaultTitle("SimpleSRC Client")] public partial class Chat : UserControl, IShiftOSWindow { - public Chat(string chatId) + public Chat() { InitializeComponent(); - id = chatId; - ServerManager.MessageReceived += (msg) => - { - if (msg.Name == "chat_msgreceived") - { - try - { - this.Invoke(new Action(() => - { - try - { - var args = JsonConvert.DeserializeObject>(msg.Contents); - var cmsg = new ShiftOS.Objects.ChatMessage(args["Username"] as string, args["SystemName"] as string, args["Message"] as string, args["Channel"] as string); - if (id == cmsg.Channel) - rtbchat.AppendText($"[{cmsg.Username}@{cmsg.SystemName}]: {cmsg.Message}{Environment.NewLine}"); - } - catch (Exception ex) - { - rtbchat.AppendText($"[system@multiuserdomain] Exception thrown by client: {ex}"); - } - })); - } - catch { } - } - else if(msg.Name == "chatlog") - { - try - { - this.Invoke(new Action(() => - { - rtbchat.AppendText(msg.Contents); - })); - } - catch { } - } - }; } - public void SendMessage(string msg) - { - if (!string.IsNullOrWhiteSpace(msg)) - { - rtbchat.AppendText($"[{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}] {msg}{Environment.NewLine}"); - - ServerManager.SendMessage("chat_send", JsonConvert.SerializeObject(new ShiftOS.Objects.ChatMessage(SaveSystem.CurrentSave.Username, SaveSystem.CurrentSave.SystemName, msg, id))); - } - else - { - rtbchat.AppendText($"[sys@multiuserdomain] You can't send blank messages. (only you can see this)"); - } - } - - - private string id = ""; - public void OnLoad() { - ServerManager.SendMessage("chat_getlog", JsonConvert.SerializeObject(new ShiftOS.Objects.ChatLogRequest(id, 50))); - - SendMessage("User has joined the chat."); + AllInstances.Add(this); + if (!string.IsNullOrWhiteSpace(ChatID)) + pnlstart.SendToBack(); RefreshUserInput(); } @@ -112,8 +63,8 @@ namespace ShiftOS.WinForms.Applications public bool OnUnload() { - SendMessage("User has left the chat."); - id = null; + AllInstances.Remove(this); + ChatID = null; return true; } @@ -146,15 +97,101 @@ namespace ShiftOS.WinForms.Applications { rtbchat.SelectionStart = rtbchat.Text.Length; rtbchat.ScrollToCaret(); - tschatid.Text = id; - tsuserdata.Text = $"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}"; + tschatid.Text = ChatID; + AppearanceManager.SetWindowTitle(this, tschatid.Text + " - SimpleSRC Client"); + tsuserdata.Text = $"{SaveSystem.CurrentUser.Username}@{SaveSystem.CurrentSave.SystemName}"; RefreshUserInput(); } + public static readonly List AllInstances = new List(); + + public static void SendMessage(string user, string destination, string msg) + { + foreach(var chat in AllInstances) + { + chat.PostMessage(user, destination, msg); + } + } + + public string ChatID = ""; + + public void PostMessage(string user, string destination, string message) + { + if (ChatID == destination) + { + this.Invoke(new Action(() => + { + rtbchat.SelectionFont = new Font(rtbchat.Font, FontStyle.Bold); + rtbchat.AppendText($"[{user}] "); + rtbchat.SelectionFont = rtbchat.Font; + rtbchat.AppendText(message); + rtbchat.AppendText(Environment.NewLine + Environment.NewLine); + })); + } + } + private void btnsend_Click(object sender, EventArgs e) { - SendMessage(txtuserinput.Text); + //Update ALL chat windows with this message if they're connected to this chat. + SendMessage($"{SaveSystem.CurrentUser.Username}@{SaveSystem.CurrentSave.SystemName}", ChatID, txtuserinput.Text); txtuserinput.Text = ""; } + + [Story("story_thefennfamily")] + public static void Story_TheFennFamily() + { + bool complete = false; + Infobox.Show("SimpleSRC", "A direct message has been sent to you on SimpleSRC from user \"maureenfenn@trisys\".", () => + { + string ch = "maureenfenn@trisys"; + var c = new Chat(); + c.ChatID = ch; + AppearanceManager.SetupWindow(c); + string you = $"{SaveSystem.CurrentUser.Username}@{SaveSystem.CurrentSave.SystemName}"; + + var t = new Thread(() => + { + SendMessage(you, ch, "User has joined the chat."); + Thread.Sleep(2000); + SendMessage(ch, ch, "Hello, " + you + ". My name is Maureen. Maureen Fenn."); + Thread.Sleep(2500); + SendMessage(ch, ch, "I am the author of the various Tri applications you may see on Appscape."); + Thread.Sleep(2000); + SendMessage(ch, ch, "I need your help with something..."); + Thread.Sleep(2500); + SendMessage(ch, ch, "Firstly, a little backstory. There was a time in ShiftOS when none of us were connected."); + Thread.Sleep(2500); + SendMessage(ch, ch, "There wasn't a Digital Society, we didn't have chat applications or anything..."); + Thread.Sleep(2000); + SendMessage(ch, ch, "All we had was the Shiftnet."); + Thread.Sleep(2500); + SendMessage(ch, ch, "However, in 2016, something happened called the \"connected revolution\". It was like, the invention of the Internet - it was huge for the world of ShiftOS."); + Thread.Sleep(2500); + SendMessage(ch, ch, "Before this, the only way you could earn Codepoints was through playing games in ShiftOS."); + Thread.Sleep(2500); + SendMessage(ch, ch, "I was the one who coded those games, and I would put them on a Shiftnet website that you can still access today, shiftnet/main/shiftgames."); + Thread.Sleep(2500); + SendMessage(ch, ch, "But when the Connected Revolution took place, things got difficult. My son, Nalyr Fenn, was born, and people stopped using my software and instead moved on to hacking eachother and stealing peoples' Codepoints."); + Thread.Sleep(2500); + SendMessage(ch, ch, "When Nalyr's sentience levels reached near human - i.e, he grew up, we decided to start TriOffice. It was a huge success, thanks to Aiden Nirh, the guy who runs Appscape."); + Thread.Sleep(2500); + SendMessage(ch, ch, "However... a few months ago he cut contact with us and we stopped receiving Codepoints from TriOffice."); + Thread.Sleep(2500); + SendMessage(ch, ch, "I'm running low - I can't afford to keep my system running much longer. You have to help!"); + Thread.Sleep(2500); + SendMessage(ch, ch, "Perhaps, you could breach Aiden's server and look for clues as to why he's against us? I'll reward you with the last Codepoints I have."); + Thread.Sleep(2500); + SendMessage(you, ch, "Alright, I'm in - but I don't know where to begin..."); + Thread.Sleep(2500); + SendMessage(ch, ch, "A little birdie tells me you know about the RTS exploits going around... Try using that on Aiden's server. You can find his systemname on Appscape under \"Contact Us.\" He has a mailserver on Appscape - and also has RTS on the same server."); + Thread.Sleep(2500); + SendMessage(ch, ch, "Good luck... My life depends on you!"); + }); + t.IsBackground = true; + t.Start(); + }); + while (!complete) + Thread.Sleep(10); + } } } diff --git a/ShiftOS.WinForms/Applications/MUDControlCentre.cs b/ShiftOS.WinForms/Applications/MUDControlCentre.cs index b8ba5f3..ab89ffd 100644 --- a/ShiftOS.WinForms/Applications/MUDControlCentre.cs +++ b/ShiftOS.WinForms/Applications/MUDControlCentre.cs @@ -274,9 +274,10 @@ namespace ShiftOS.WinForms.Applications } + [Obsolete("MUD control center is dying! KILL IT!")] public void OpenChat(string id) { - AppearanceManager.SetupWindow(new Chat(id)); +// AppearanceManager.SetupWindow(new Chat(id)); } private Shop editingShop = null; diff --git a/ShiftOS_TheReturn/Story.cs b/ShiftOS_TheReturn/Story.cs index bcee49c..d62dae4 100644 --- a/ShiftOS_TheReturn/Story.cs +++ b/ShiftOS_TheReturn/Story.cs @@ -66,8 +66,11 @@ namespace ShiftOS.Engine var story = attrib as StoryAttribute; if(story.StoryID == stid) { - mth.Invoke(null, null); - SaveSystem.CurrentSave.StoriesExperienced.Add(stid); + new Thread(() => + { + mth.Invoke(null, null); + SaveSystem.CurrentSave.StoriesExperienced.Add(stid); + }).Start(); return; } } -- cgit v1.2.3 From e841b168e13e0bd699c0e0d19857167aa725f1ca Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 27 May 2017 16:59:54 -0400 Subject: stuff --- ShiftOS.WinForms/Applications/Chat.cs | 1 + ShiftOS.WinForms/Controls/TerminalBox.cs | 11 ++++--- ShiftOS.WinForms/Stories/LegionStory.cs | 9 +----- ShiftOS.WinForms/WinformsDesktop.cs | 49 ++++++++++++++++++-------------- ShiftOS_TheReturn/AppearanceManager.cs | 2 +- 5 files changed, 35 insertions(+), 37 deletions(-) (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.WinForms/Applications/Chat.cs b/ShiftOS.WinForms/Applications/Chat.cs index e150b1a..f9e601f 100644 --- a/ShiftOS.WinForms/Applications/Chat.cs +++ b/ShiftOS.WinForms/Applications/Chat.cs @@ -186,6 +186,7 @@ namespace ShiftOS.WinForms.Applications SendMessage(ch, ch, "A little birdie tells me you know about the RTS exploits going around... Try using that on Aiden's server. You can find his systemname on Appscape under \"Contact Us.\" He has a mailserver on Appscape - and also has RTS on the same server."); Thread.Sleep(2500); SendMessage(ch, ch, "Good luck... My life depends on you!"); + complete = true; }); t.IsBackground = true; t.Start(); diff --git a/ShiftOS.WinForms/Controls/TerminalBox.cs b/ShiftOS.WinForms/Controls/TerminalBox.cs index a6dd610..7658c8c 100644 --- a/ShiftOS.WinForms/Controls/TerminalBox.cs +++ b/ShiftOS.WinForms/Controls/TerminalBox.cs @@ -63,15 +63,12 @@ namespace ShiftOS.WinForms.Controls public void Write(string text) { - Thread.Sleep(5); - this.SuspendLayout(); this.HideSelection = true; this.SelectionFont = ConstructFont(); this.SelectionColor = ControlManager.ConvertColor(ConsoleEx.ForegroundColor); this.SelectionBackColor = ControlManager.ConvertColor(ConsoleEx.BackgroundColor); this.AppendText(Localization.Parse(text)); this.HideSelection = false; - this.ResumeLayout(); } private Font ConstructFont() @@ -89,8 +86,6 @@ namespace ShiftOS.WinForms.Controls public void WriteLine(string text) { - Thread.Sleep(5); - this.SuspendLayout(); Engine.AudioManager.PlayStream(Properties.Resources.writesound); this.HideSelection = true; this.Select(this.TextLength, 0); @@ -99,11 +94,12 @@ namespace ShiftOS.WinForms.Controls this.SelectionBackColor = ControlManager.ConvertColor(ConsoleEx.BackgroundColor); this.AppendText(Localization.Parse(text) + Environment.NewLine); this.HideSelection = false; - this.ResumeLayout(); } bool quickCopying = false; + bool busy = false; + protected override void OnMouseDown(MouseEventArgs e) { //if right-clicking, then we initiate a quick-copy. @@ -255,8 +251,11 @@ namespace ShiftOS.WinForms.Controls } } + public string ThreadId = ""; + public TerminalBox() : base() { + ThreadId = Thread.CurrentThread.ManagedThreadId.ToString(); this.Tag = "keepbg keepfg keepfont"; } } diff --git a/ShiftOS.WinForms/Stories/LegionStory.cs b/ShiftOS.WinForms/Stories/LegionStory.cs index 9b4966f..53d55fb 100644 --- a/ShiftOS.WinForms/Stories/LegionStory.cs +++ b/ShiftOS.WinForms/Stories/LegionStory.cs @@ -92,14 +92,7 @@ namespace ShiftOS.WinForms.Stories ConsoleEx.ForegroundColor = ConsoleColor.Gray; ConsoleEx.Bold = false; - foreach (var c in text) - { - Desktop.InvokeOnWorkerThread(() => - { - Console.Write(c); - }); - Thread.Sleep(75); - } + Console.WriteLine(text); Thread.Sleep(1000); } diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs index 15ecb7a..6ce8cc9 100644 --- a/ShiftOS.WinForms/WinformsDesktop.cs +++ b/ShiftOS.WinForms/WinformsDesktop.cs @@ -188,14 +188,40 @@ namespace ShiftOS.WinForms widget.OnSkinLoad(); } + SetupDesktop(); }; + + long lastcp = 0; + + var storythread = new Thread(() => + { + do + { + if (SaveSystem.CurrentSave != null) + { + if (SaveSystem.CurrentSave.Codepoints != lastcp) + lastcp = SaveSystem.CurrentSave.Codepoints; + if (lastcp >= 10000) + { + if (!Shiftorium.UpgradeInstalled("victortran_shiftnet")) + { + Story.Start("victortran_shiftnet"); + } + } + } + } while (!SaveSystem.ShuttingDown); + }); + storythread.IsBackground = true; + storythread.Start(); + time.Tick += (o, a) => { if (Shiftorium.IsInitiated == true) { - if (SaveSystem.CurrentSave != null && TutorialManager.IsInTutorial == false) + if (SaveSystem.CurrentSave != null) { + lbtime.Text = Applications.Terminal.GetTime(); lbtime.Left = pnlnotifications.Width - lbtime.Width - LoadedSkin.DesktopPanelClockFromRight.X; lbtime.Top = LoadedSkin.DesktopPanelClockFromRight.Y; @@ -230,27 +256,6 @@ namespace ShiftOS.WinForms }; time.Start(); - var ssThread = new Thread(() => - { - while(this.Visible == true) - { - var mousePos = Cursor.Position; - while(Cursor.Position == mousePos) - { - if(millisecondsUntilScreensaver <= 0) - { - ShowScreensaver(); - } - millisecondsUntilScreensaver--; - Thread.Sleep(1); - } - millisecondsUntilScreensaver = 300000; - HideScreensaver(); - } - }); - ssThread.IsBackground = true; - ssThread.Start(); - this.DoubleBuffered = true; } diff --git a/ShiftOS_TheReturn/AppearanceManager.cs b/ShiftOS_TheReturn/AppearanceManager.cs index 81858d3..7cf06c9 100644 --- a/ShiftOS_TheReturn/AppearanceManager.cs +++ b/ShiftOS_TheReturn/AppearanceManager.cs @@ -190,7 +190,7 @@ namespace ShiftOS.Engine ServerManager.Disconnect(); Desktop.InvokeOnWorkerThread(() => { - Environment.Exit(0); //bye bye + Process.GetCurrentProcess().Kill(); //bye bye }); } -- cgit v1.2.3 From dc0b8c66885593f7412e24bf7132bc08f6c40a9c Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 28 May 2017 06:44:58 -0400 Subject: Fix a bug with command-line login. --- ShiftOS.WinForms/Applications/Terminal.cs | 7 +++++++ ShiftOS_TheReturn/SaveSystem.cs | 8 ++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.WinForms/Applications/Terminal.cs b/ShiftOS.WinForms/Applications/Terminal.cs index ea24686..4cd4806 100644 --- a/ShiftOS.WinForms/Applications/Terminal.cs +++ b/ShiftOS.WinForms/Applications/Terminal.cs @@ -269,6 +269,13 @@ namespace ShiftOS.WinForms.Applications try { a.SuppressKeyPress = true; + if (!TerminalBackend.PrefixEnabled) + { + string textraw = txt.Lines[txt.Lines.Length - 1]; + TextSent?.Invoke(textraw); + TerminalBackend.SendText(textraw); + return; + } Console.WriteLine(""); var text = txt.Lines.ToArray(); var text2 = text[text.Length - 2]; diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index d74006a..f3d95be 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -349,6 +349,7 @@ namespace ShiftOS.Engine { if (CurrentSave.Users.FirstOrDefault(x => x.Username == getuser) == null) { + Console.WriteLine(); Console.WriteLine("User not found."); goback = true; progress++; @@ -360,6 +361,7 @@ namespace ShiftOS.Engine } else { + Console.WriteLine(); Console.WriteLine("Username not provided."); TerminalBackend.TextSent -= ev; goback = true; @@ -373,13 +375,14 @@ namespace ShiftOS.Engine var user = CurrentSave.Users.FirstOrDefault(x => x.Username == username); if (user.Password == getpass) { + Console.WriteLine(); Console.WriteLine("Welcome to ShiftOS."); CurrentUser = user; - Thread.Sleep(2000); progress++; } else { + Console.WriteLine(); Console.WriteLine("Access denied."); goback = true; progress++; @@ -388,7 +391,7 @@ namespace ShiftOS.Engine } }; TerminalBackend.TextSent += ev; - + Console.WriteLine(); Console.Write(CurrentSave.SystemName + " login: "); while (progress == 0) { @@ -396,6 +399,7 @@ namespace ShiftOS.Engine } if (goback) goto Login; + Console.WriteLine(); Console.Write("password: "); while (progress == 1) Thread.Sleep(10); -- cgit v1.2.3 From 8e3bdf71e71096711f11a0d51b2b384e117391ee Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 28 May 2017 07:21:16 -0400 Subject: strip things down but make things better --- ShiftOS.WinForms/Applications/Terminal.cs | 6 ++--- ShiftOS.WinForms/Controls/TerminalBox.cs | 6 ----- ShiftOS_TheReturn/ConsoleEx.cs | 7 +++++ ShiftOS_TheReturn/SaveSystem.cs | 2 ++ ShiftOS_TheReturn/TerminalBackend.cs | 11 +++----- ShiftOS_TheReturn/TerminalTextWriter.cs | 45 ++++++++++++++++++------------- 6 files changed, 42 insertions(+), 35 deletions(-) (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.WinForms/Applications/Terminal.cs b/ShiftOS.WinForms/Applications/Terminal.cs index 4cd4806..6039456 100644 --- a/ShiftOS.WinForms/Applications/Terminal.cs +++ b/ShiftOS.WinForms/Applications/Terminal.cs @@ -268,7 +268,8 @@ namespace ShiftOS.WinForms.Applications { try { - a.SuppressKeyPress = true; + if (!TerminalBackend.InStory) + a.SuppressKeyPress = false; if (!TerminalBackend.PrefixEnabled) { string textraw = txt.Lines[txt.Lines.Length - 1]; @@ -276,9 +277,8 @@ namespace ShiftOS.WinForms.Applications TerminalBackend.SendText(textraw); return; } - Console.WriteLine(""); var text = txt.Lines.ToArray(); - var text2 = text[text.Length - 2]; + var text2 = text[text.Length - 1]; var text3 = ""; var text4 = Regex.Replace(text2, @"\t|\n|\r", ""); diff --git a/ShiftOS.WinForms/Controls/TerminalBox.cs b/ShiftOS.WinForms/Controls/TerminalBox.cs index 7658c8c..25f7144 100644 --- a/ShiftOS.WinForms/Controls/TerminalBox.cs +++ b/ShiftOS.WinForms/Controls/TerminalBox.cs @@ -64,9 +64,6 @@ namespace ShiftOS.WinForms.Controls public void Write(string text) { this.HideSelection = true; - this.SelectionFont = ConstructFont(); - this.SelectionColor = ControlManager.ConvertColor(ConsoleEx.ForegroundColor); - this.SelectionBackColor = ControlManager.ConvertColor(ConsoleEx.BackgroundColor); this.AppendText(Localization.Parse(text)); this.HideSelection = false; } @@ -89,9 +86,6 @@ namespace ShiftOS.WinForms.Controls Engine.AudioManager.PlayStream(Properties.Resources.writesound); this.HideSelection = true; this.Select(this.TextLength, 0); - this.SelectionFont = ConstructFont(); - this.SelectionColor = ControlManager.ConvertColor(ConsoleEx.ForegroundColor); - this.SelectionBackColor = ControlManager.ConvertColor(ConsoleEx.BackgroundColor); this.AppendText(Localization.Parse(text) + Environment.NewLine); this.HideSelection = false; } diff --git a/ShiftOS_TheReturn/ConsoleEx.cs b/ShiftOS_TheReturn/ConsoleEx.cs index 90f9cc0..74483dc 100644 --- a/ShiftOS_TheReturn/ConsoleEx.cs +++ b/ShiftOS_TheReturn/ConsoleEx.cs @@ -48,5 +48,12 @@ namespace ShiftOS.Engine /// Gets or sets whether text in the Terminal is underlined. /// public static bool Underline { get; set; } + + internal static void Flush() + { + OnFlush?.Invoke(); + } + + public static Action OnFlush; } } diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index f3d95be..24a491d 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -393,6 +393,7 @@ namespace ShiftOS.Engine TerminalBackend.TextSent += ev; Console.WriteLine(); Console.Write(CurrentSave.SystemName + " login: "); + ConsoleEx.Flush(); while (progress == 0) { Thread.Sleep(10); @@ -401,6 +402,7 @@ namespace ShiftOS.Engine goto Login; Console.WriteLine(); Console.Write("password: "); + ConsoleEx.Flush(); while (progress == 1) Thread.Sleep(10); if (goback) diff --git a/ShiftOS_TheReturn/TerminalBackend.cs b/ShiftOS_TheReturn/TerminalBackend.cs index b18e27c..1c024eb 100644 --- a/ShiftOS_TheReturn/TerminalBackend.cs +++ b/ShiftOS_TheReturn/TerminalBackend.cs @@ -361,14 +361,12 @@ namespace ShiftOS.Engine /// Whether the command should be sent through Remote Terminal Session (RTS). public static void InvokeCommand(string text, bool isRemote = false) { + if (string.IsNullOrWhiteSpace(text)) + return; var tw = new MemoryTextWriter(); Console.SetOut(tw); try { - - if (string.IsNullOrWhiteSpace(text)) - return; - var args = GetArgs(ref text); Stopwatch debugger = new Stopwatch(); @@ -533,10 +531,9 @@ namespace ShiftOS.Engine /// public static void PrintPrompt() { + Console.WriteLine(); if (SaveSystem.CurrentSave != null && CurrentUser != null) { - Desktop.InvokeOnWorkerThread(() => - { ConsoleEx.BackgroundColor = SkinEngine.LoadedSkin.TerminalBackColorCC; ConsoleEx.Italic = false; ConsoleEx.Underline = false; @@ -566,7 +563,7 @@ namespace ShiftOS.Engine ConsoleEx.Bold = false; ConsoleEx.ForegroundColor = SkinEngine.LoadedSkin.TerminalForeColorCC; Console.Write(" "); - }); + ConsoleEx.Flush(); } } diff --git a/ShiftOS_TheReturn/TerminalTextWriter.cs b/ShiftOS_TheReturn/TerminalTextWriter.cs index 010e02c..4c0c3a0 100644 --- a/ShiftOS_TheReturn/TerminalTextWriter.cs +++ b/ShiftOS_TheReturn/TerminalTextWriter.cs @@ -37,14 +37,19 @@ namespace ShiftOS.Engine /// public class TerminalTextWriter : TextWriter { - /// - /// Win32 API call to lock the window from being updated. - /// - /// The Win32 window handle - /// ...I....have no idea. - [System.Runtime.InteropServices.DllImport("user32.dll")] - public static extern bool LockWindowUpdate(IntPtr hWndLock); + public TerminalTextWriter() + { + ConsoleEx.OnFlush = () => + { + Desktop.InvokeOnWorkerThread(() => + { + UnderlyingControl?.Write(buffer); + buffer = ""; + }); + }; + } + /// /// Gets the encoding format for this . God bless the Unicode Consortiem. /// @@ -94,11 +99,17 @@ namespace ShiftOS.Engine } else { - Desktop.InvokeOnWorkerThread(new Action(() => - { - UnderlyingControl?.Write(value.ToString()); - select(); - })); + buffer += value; + } + } + + private string buffer = ""; + + public string Buffer + { + get + { + return buffer; } } @@ -118,11 +129,8 @@ namespace ShiftOS.Engine else { - Desktop.InvokeOnWorkerThread(new Action(() => - { - UnderlyingControl?.WriteLine(value); - select(); - })); + buffer += value + Environment.NewLine; + ConsoleEx.Flush(); } } @@ -149,8 +157,7 @@ namespace ShiftOS.Engine Desktop.InvokeOnWorkerThread(new Action(() => { - UnderlyingControl?.Write(value.ToString()); - select(); + buffer += value; })); } } -- cgit v1.2.3 From 80899fc5de1c0c194043ce94a10707bf8b7afcf0 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 28 May 2017 10:12:59 -0400 Subject: Cool startup logo :smiley: --- ShiftOS.WinForms/Applications/ShiftLetters.cs | 2 +- ShiftOS.WinForms/Applications/ShiftSweeper.cs | 2 +- ShiftOS.WinForms/Resources/Shiftorium.txt | 14 --- ShiftOS.WinForms/ShiftOS.WinForms.csproj | 9 ++ .../ShiftnetSites/ShiftGames.Designer.cs | 74 ++++++++++++ ShiftOS.WinForms/ShiftnetSites/ShiftGames.cs | 39 +++++++ ShiftOS.WinForms/ShiftnetSites/ShiftGames.resx | 125 +++++++++++++++++++++ ShiftOS_TheReturn/SaveSystem.cs | 26 +++++ 8 files changed, 275 insertions(+), 16 deletions(-) create mode 100644 ShiftOS.WinForms/ShiftnetSites/ShiftGames.Designer.cs create mode 100644 ShiftOS.WinForms/ShiftnetSites/ShiftGames.cs create mode 100644 ShiftOS.WinForms/ShiftnetSites/ShiftGames.resx (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.WinForms/Applications/ShiftLetters.cs b/ShiftOS.WinForms/Applications/ShiftLetters.cs index b5e9aa4..42e19f8 100644 --- a/ShiftOS.WinForms/Applications/ShiftLetters.cs +++ b/ShiftOS.WinForms/Applications/ShiftLetters.cs @@ -38,7 +38,7 @@ namespace ShiftOS.WinForms.Applications { [MultiplayerOnly] [Launcher("ShiftLetters", false, null, "Games")] - [RequiresUpgrade("shiftletters")] + [AppscapeEntry("ShiftLetters", "Let's see how much you know about ShiftOS by playing this tiny little Hangman game! Shiftorium Upgrades exist to allow you to buy different word sets!", 300, 150, null, "Games")] [WinOpen("shiftletters")] [DefaultIcon("iconShiftLetters")] public partial class ShiftLetters : UserControl, IShiftOSWindow diff --git a/ShiftOS.WinForms/Applications/ShiftSweeper.cs b/ShiftOS.WinForms/Applications/ShiftSweeper.cs index 72e9062..f23ed73 100644 --- a/ShiftOS.WinForms/Applications/ShiftSweeper.cs +++ b/ShiftOS.WinForms/Applications/ShiftSweeper.cs @@ -35,7 +35,7 @@ using ShiftOS.Engine; namespace ShiftOS.WinForms.Applications { [Launcher("ShiftSweeper", true, "al_shiftsweeper", "Games")] - [RequiresUpgrade("shiftsweeper")] + [AppscapeEntry("ShiftSweeper", "A simple Minesweeper game built for ShiftOS! Careful, it's a hard one.", 1600, 800, "shiftletters", "Games")] [MultiplayerOnly] [WinOpen("shiftsweeper")] [DefaultIcon("iconShiftSweeper")] diff --git a/ShiftOS.WinForms/Resources/Shiftorium.txt b/ShiftOS.WinForms/Resources/Shiftorium.txt index cc68c6f..41b50a7 100644 --- a/ShiftOS.WinForms/Resources/Shiftorium.txt +++ b/ShiftOS.WinForms/Resources/Shiftorium.txt @@ -151,13 +151,6 @@ }, // SHIFTLETTERS AND WORDLISTS - { - Name: "ShiftLetters", - Cost: 150, - Dependencies: null, - Category: "Applications", - Description: "Sick and tired of playing Pong? Buy this upgrade to get a whole new game!" - }, { Name: "AL ShiftLetters", Cost: 150, @@ -1028,13 +1021,6 @@ // SHIFTSWEEPER - { - Name: "ShiftSweeper", - Cost: 800, - Dependencies: "shiftletters", - Category: "Applications", - Description: "Getting bored with Pong and ShiftLetters? Try this BRAND NEW game called ShiftSweeper!" - }, { Name: "AL ShiftSweeper", Cost: 100, diff --git a/ShiftOS.WinForms/ShiftOS.WinForms.csproj b/ShiftOS.WinForms/ShiftOS.WinForms.csproj index da8eafc..9844657 100644 --- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj +++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj @@ -382,6 +382,12 @@ MainHomepage.cs + + UserControl + + + ShiftGames.cs + @@ -574,6 +580,9 @@ MainHomepage.cs + + ShiftGames.cs + UniteLoginDialog.cs diff --git a/ShiftOS.WinForms/ShiftnetSites/ShiftGames.Designer.cs b/ShiftOS.WinForms/ShiftnetSites/ShiftGames.Designer.cs new file mode 100644 index 0000000..3b4bf9e --- /dev/null +++ b/ShiftOS.WinForms/ShiftnetSites/ShiftGames.Designer.cs @@ -0,0 +1,74 @@ +namespace ShiftOS.WinForms.ShiftnetSites +{ + partial class ShiftGames + { + /// + /// 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() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ShiftGames)); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // label1 + // + this.label1.Dock = System.Windows.Forms.DockStyle.Top; + this.label1.Location = new System.Drawing.Point(0, 0); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(571, 65); + this.label1.TabIndex = 0; + this.label1.Tag = "header2"; + this.label1.Text = "ShiftGames/Minimatch"; + this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // label2 + // + this.label2.Dock = System.Windows.Forms.DockStyle.Fill; + this.label2.Location = new System.Drawing.Point(0, 65); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(571, 309); + this.label2.TabIndex = 1; + this.label2.Text = resources.GetString("label2.Text"); + this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // ShiftGames + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.label2); + this.Controls.Add(this.label1); + this.Name = "ShiftGames"; + this.Size = new System.Drawing.Size(571, 374); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + } +} diff --git a/ShiftOS.WinForms/ShiftnetSites/ShiftGames.cs b/ShiftOS.WinForms/ShiftnetSites/ShiftGames.cs new file mode 100644 index 0000000..4ce0435 --- /dev/null +++ b/ShiftOS.WinForms/ShiftnetSites/ShiftGames.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using ShiftOS.Engine; +using ShiftOS.WinForms.Tools; + +namespace ShiftOS.WinForms.ShiftnetSites +{ + [ShiftnetSite("shiftnet/main/shiftgames", "ShiftGames (formerly Minimatch)", "The one true Shiftnet site for virus-free, quality games.")] + public partial class ShiftGames : UserControl, IShiftnetSite + { + public ShiftGames() + { + InitializeComponent(); + } + + public event Action GoBack; + public event Action GoToUrl; + + public void OnSkinLoad() + { + ControlManager.SetupControls(this); + } + + public void OnUpgrade() + { + } + + public void Setup() + { + } + } +} diff --git a/ShiftOS.WinForms/ShiftnetSites/ShiftGames.resx b/ShiftOS.WinForms/ShiftnetSites/ShiftGames.resx new file mode 100644 index 0000000..ef8aebe --- /dev/null +++ b/ShiftOS.WinForms/ShiftnetSites/ShiftGames.resx @@ -0,0 +1,125 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + ShiftGames has been shut down as of May 2016. We have moved our inventory to the Appscape Repository. Thanks for being with us, and apologies for the inconvenience. + +Copyright (c) 2014-2016 Maureen Fenn + + \ No newline at end of file diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index 24a491d..489b718 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -298,6 +298,32 @@ namespace ShiftOS.Engine if (CurrentSave.Users == null) CurrentSave.Users = new List(); + Console.WriteLine($@" + `-:/++++::.` + .+ydNMMMMMNNMMMMMNhs/. + /yNMMmy+:-` `````.-/ohNMMms- + `oNMMh/.`:oydmNMMMMNmhs+- .+dMMm+` Welcome to ShiftOS. + `oMMmo``+dMMMMMMMMMMMMMMMMMNh/`.sNMN+ + :NMN+ -yMMMMMMMNdhyssyyhdmNMMMMNs``sMMd. SYSTEM STATUS: + oMMd.`sMMMMMMd+. `/MMMMN+ -mMN: ---------------------- + oMMh .mMMMMMM/ `-::::-.` :MMMMMMh`.mMM: + :MMd .NMMMMMMs .dMMMMMMMMMNddMMMMMMMd`.NMN. Codepoints: {SaveSystem.CurrentSave.Codepoints} + mMM. dMMMMMMMo -mMMMMMMMMMMMMMMMMMMMMs /MMy Upgrades: {SaveSystem.CurrentSave.CountUpgrades()} installed + :MMh :MMMMMMMMm` .+shmMMMMMMMMMMMMMMMN` NMN` {Shiftorium.GetAvailable().Count()} available + oMM+ sMMMMMMMMMN+` `-/smMMMMMMMMMMM: hMM: Filesystems: {Utils.Mounts.Count} filesystems mounted in memory. + sMM+ sMMMMMMMMMMMMds/-` .sMMMMMMMMM/ yMM/ + +MMs +MMMMMMMMMMMMMMMMMmhs:` +MMMMMMMM- dMM- System name: {CurrentSave.SystemName.ToUpper()} + .MMm `NMMMMMMMMMMMMMMMMMMMMMo `NMMMMMMd .MMN Users: {Users.Count()} found. + hMM+ +MMMMMMmsdNMMMMMMMMMMN/ -MMMMMMN- yMM+ + `NMN- oMMMMMd `-/+osso+- .mMMMMMN: +MMd + -NMN: /NMMMm` :yMMMMMMm- oMMd` + -mMMs``sMMMMNdhso++///+oydNMMMMMMNo .hMMh` + `yMMm/ .omMMMMMMMMMMMMMMMMMMMMd+``oNMNo + -hMMNo. -ohNMMMMMMMMMMMMmy+. -yNMNy` + .sNMMms/. `-/+++++/:-` ./yNMMmo` + :sdMMMNdyso+++ooshdNMMMdo- + `:+yhmNNMMMMNNdhs+- + ```` "); if (CurrentSave.Users.Count == 0) { -- cgit v1.2.3 From 4036e97f3f3ecb6541cc623165e960e8c172f242 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 28 May 2017 10:26:11 -0400 Subject: Don't clear the terminal when in fullscreen --- ShiftOS.WinForms/Applications/Terminal.cs | 54 +------------------------------ 1 file changed, 1 insertion(+), 53 deletions(-) (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.WinForms/Applications/Terminal.cs b/ShiftOS.WinForms/Applications/Terminal.cs index 6039456..bfc4425 100644 --- a/ShiftOS.WinForms/Applications/Terminal.cs +++ b/ShiftOS.WinForms/Applications/Terminal.cs @@ -130,8 +130,6 @@ namespace ShiftOS.WinForms.Applications { this.Invoke(new Action(() => { - ResetAllKeywords(); - rtbterm.Text = ""; if (Shiftorium.UpgradeInstalled("first_steps")) { if (!Shiftorium.UpgradeInstalled("desktop")) @@ -203,52 +201,6 @@ namespace ShiftOS.WinForms.Applications public static event TextSentEventHandler TextSent; - public void ResetAllKeywords() - { - string primary = SaveSystem.CurrentUser.Username + " "; - string secondary = "shiftos "; - - - var asm = Assembly.GetExecutingAssembly(); - - var types = asm.GetTypes(); - - foreach (var type in types) - { - foreach (var a in type.GetCustomAttributes(false)) - { - if (ShiftoriumFrontend.UpgradeAttributesUnlocked(type)) - { - if (a is Namespace) - { - var ns = a as Namespace; - if (!primary.Contains(ns.name)) - { - primary += ns.name + " "; - } - foreach (var method in type.GetMethods(BindingFlags.Public | BindingFlags.Static)) - { - if (ShiftoriumFrontend.UpgradeAttributesUnlocked(method)) - { - foreach (var ma in method.GetCustomAttributes(false)) - { - if (ma is Command) - { - var cmd = ma as Command; - if (!secondary.Contains(cmd.name)) - secondary += cmd.name + " "; - } - } - } - } - } - } - } - } - - - } - public static void MakeWidget(Controls.TerminalBox txt) { AppearanceManager.StartConsoleOut(); @@ -436,17 +388,13 @@ namespace ShiftOS.WinForms.Applications if (SaveSystem.CurrentSave != null) { + TerminalBackend.PrintPrompt(); if (!ShiftoriumFrontend.UpgradeInstalled("window_manager")) { rtbterm.Select(rtbterm.TextLength, 0); } } - new Thread(() => - { - Thread.Sleep(1000); - TerminalBackend.PrintPrompt(); - }).Start(); } public static string RemoteSystemName { get; set; } -- cgit v1.2.3 From 03ebdf42d9f12b678d48f954736664f6f3eb1f84 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 28 May 2017 12:40:06 -0400 Subject: Funny, disabling localization makes things easier... --- ShiftOS.WinForms/Applications/Chat.cs | 1 + ShiftOS.WinForms/Applications/Terminal.cs | 6 +- ShiftOS.WinForms/Resources/Shiftorium.txt | 5 +- ShiftOS.WinForms/Tools/ControlManager.cs | 139 +++++++++++------------------- ShiftOS.WinForms/WinformsDesktop.cs | 10 ++- ShiftOS_TheReturn/Localization.cs | 45 +--------- ShiftOS_TheReturn/TerminalTextWriter.cs | 1 + 7 files changed, 72 insertions(+), 135 deletions(-) (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.WinForms/Applications/Chat.cs b/ShiftOS.WinForms/Applications/Chat.cs index f9e601f..7a2de81 100644 --- a/ShiftOS.WinForms/Applications/Chat.cs +++ b/ShiftOS.WinForms/Applications/Chat.cs @@ -41,6 +41,7 @@ namespace ShiftOS.WinForms.Applications [WinOpen("simplesrc")] [Launcher("SimpleSRC Client", false, null, "Networking")] [DefaultTitle("SimpleSRC Client")] + [AppscapeEntry("SimpleSRC", "A simple ShiftOS Relay Chat client that allows you to talk with other ShiftOS users from all over the world.", 300, 145, "file_skimmer", "Networking")] public partial class Chat : UserControl, IShiftOSWindow { public Chat() diff --git a/ShiftOS.WinForms/Applications/Terminal.cs b/ShiftOS.WinForms/Applications/Terminal.cs index bfc4425..3d17d35 100644 --- a/ShiftOS.WinForms/Applications/Terminal.cs +++ b/ShiftOS.WinForms/Applications/Terminal.cs @@ -504,11 +504,11 @@ namespace ShiftOS.WinForms.Applications Thread.Sleep(2000); Console.WriteLine("As you know, ShiftOS doesn't have very many features."); Thread.Sleep(2000); - Console.WriteLine("Using the applications you have, I need you to earn 50,000 Codepoints."); + Console.WriteLine("Using the applications you have, I need you to earn as many Codepoints as you can."); Thread.Sleep(2000); - Console.WriteLine("You can use the Codepoints you earn to buy new applications and features in the Shiftorium, to help earn Codepoints."); + Console.WriteLine("You can use the Codepoints you earn to buy new applications and features in the Shiftorium, to help earn even more Codepoints."); Thread.Sleep(2000); - Console.WriteLine("Start small, try to earn 500. Once you do, I'll contact you with more details."); + Console.WriteLine("Once you earn 1,000 Codepoints, I will check back with you and see how well you've done."); Thread.Sleep(2000); Console.WriteLine("I'll leave you to it, you've got the hang of it! One last thing, if ever you find yourself in another program, and want to exit, simply press CTRL+T to return to the Terminal."); Thread.Sleep(2000); diff --git a/ShiftOS.WinForms/Resources/Shiftorium.txt b/ShiftOS.WinForms/Resources/Shiftorium.txt index 41b50a7..0eac58e 100644 --- a/ShiftOS.WinForms/Resources/Shiftorium.txt +++ b/ShiftOS.WinForms/Resources/Shiftorium.txt @@ -283,7 +283,7 @@ Name: "AL Widget Manager", Cost: 125, Description: "Desktop Widgets are a huge advancement in ShiftOS technology, allowing access to system information, and quick control of your system, without even opening a window. However, we still need to be able to modify each widget. This upgrade adds an App Launcher entry for the Desktop Widget Manager.", - Description: "app_launcher;desktop_widgets", + Dependencies: "app_launcher;desktop_widgets", Category: "GUI" }, { @@ -704,7 +704,8 @@ Name: "Artpad", Cost: 7500, Category: "Applications", - Description: "ArtPad is a very extensible tool that allows you to draw images within ShiftOS. Buy this upgrade to gain access to it through win.open{}!" + Description: "ArtPad is a very extensible tool that allows you to draw images within ShiftOS. Buy this upgrade to gain access to it through win.open{}!", + Dependencies: "color_depth_8_bits" }, { Name: "AL Artpad", diff --git a/ShiftOS.WinForms/Tools/ControlManager.cs b/ShiftOS.WinForms/Tools/ControlManager.cs index 1643b23..83ab7fe 100644 --- a/ShiftOS.WinForms/Tools/ControlManager.cs +++ b/ShiftOS.WinForms/Tools/ControlManager.cs @@ -1,3 +1,5 @@ +#define SLOW_LOCALIZATION + /* * MIT License * @@ -144,77 +146,66 @@ namespace ShiftOS.WinForms.Tools public static void SetupControl(Control ctrl) { - - if (!(ctrl is MenuStrip) && !(ctrl is ToolStrip) && !(ctrl is StatusStrip) && !(ctrl is ContextMenuStrip)) + Desktop.InvokeOnWorkerThread(() => { - string tag = ""; - - try + if (!(ctrl is MenuStrip) && !(ctrl is ToolStrip) && !(ctrl is StatusStrip) && !(ctrl is ContextMenuStrip)) { - if(ctrl.Tag != null) - tag = ctrl.Tag.ToString(); - } - catch { } + string tag = ""; - if (!tag.Contains("keepbg")) - { - if (ctrl.BackColor != Control.DefaultBackColor) + try { - Desktop.InvokeOnWorkerThread(() => + if (ctrl.Tag != null) + tag = ctrl.Tag.ToString(); + } + catch { } + + if (!tag.Contains("keepbg")) + { + if (ctrl.BackColor != Control.DefaultBackColor) { ctrl.BackColor = SkinEngine.LoadedSkin.ControlColor; - }); + } } - } - if (!tag.Contains("keepfont")) - { - Desktop.InvokeOnWorkerThread(() => + if (!tag.Contains("keepfont")) { ctrl.ForeColor = SkinEngine.LoadedSkin.ControlTextColor; ctrl.Font = SkinEngine.LoadedSkin.MainFont; - }); - if (tag.Contains("header1")) - { - Desktop.InvokeOnWorkerThread(() => + if (tag.Contains("header1")) { - ctrl.Font = SkinEngine.LoadedSkin.HeaderFont; - }); - } + Desktop.InvokeOnWorkerThread(() => + { + ctrl.Font = SkinEngine.LoadedSkin.HeaderFont; + }); + } - if (tag.Contains("header2")) - { - Desktop.InvokeOnWorkerThread(() => + if (tag.Contains("header2")) { ctrl.Font = SkinEngine.LoadedSkin.Header2Font; - }); - } + } - if (tag.Contains("header3")) - { - Desktop.InvokeOnWorkerThread(() => + if (tag.Contains("header3")) { ctrl.Font = SkinEngine.LoadedSkin.Header3Font; - }); + } } - } - try - { - string ctrlText = Localization.Parse(ctrl.Text); - Desktop.InvokeOnWorkerThread(() => + try + { +#if !SLOW_LOCALIZATION + if (!string.IsNullOrWhiteSpace(ctrl.Text)) + { + string ctrlText = Localization.Parse(ctrl.Text); + ctrl.Text = ctrlText; + } +#endif + } + catch { - ctrl.Text = ctrlText; - }); - } - catch - { - } + } - if(ctrl is Button) - { - Desktop.InvokeOnWorkerThread(() => + if (ctrl is Button) { Button b = ctrl as Button; if (!b.Tag.ToString().ToLower().Contains("keepbg")) @@ -229,7 +220,7 @@ namespace ShiftOS.WinForms.Tools b.FlatAppearance.BorderColor = SkinEngine.LoadedSkin.ButtonForegroundColor; b.ForeColor = SkinEngine.LoadedSkin.ButtonForegroundColor; } - if(!b.Tag.ToString().ToLower().Contains("keepfont")) + if (!b.Tag.ToString().ToLower().Contains("keepfont")) b.Font = SkinEngine.LoadedSkin.ButtonTextFont; Color orig_bg = b.BackColor; @@ -260,15 +251,12 @@ namespace ShiftOS.WinForms.Tools b.BackgroundImageLayout = SkinEngine.GetImageLayout("buttonpressed"); }; - }); + } } - if(ctrl is TextBox) + if (ctrl is TextBox) { - Desktop.InvokeOnWorkerThread(() => - { - (ctrl as TextBox).BorderStyle = BorderStyle.FixedSingle; - }); + (ctrl as TextBox).BorderStyle = BorderStyle.FixedSingle; } ctrl.KeyDown += (o, a) => @@ -286,27 +274,19 @@ namespace ShiftOS.WinForms.Tools }; if (ctrl is Button) { - Desktop.InvokeOnWorkerThread(() => - { - (ctrl as Button).FlatStyle = FlatStyle.Flat; - }); + (ctrl as Button).FlatStyle = FlatStyle.Flat; } else if (ctrl is WindowBorder) { - Desktop.InvokeOnWorkerThread(() => - { - (ctrl as WindowBorder).Setup(); - }); + (ctrl as WindowBorder).Setup(); } - } - Desktop.InvokeOnWorkerThread(() => - { - MakeDoubleBuffered(ctrl); + ControlSetup?.Invoke(ctrl); }); - ControlSetup?.Invoke(ctrl); } + + public static event Action ControlSetup; public static void MakeDoubleBuffered(Control c) @@ -330,27 +310,12 @@ namespace ShiftOS.WinForms.Tools { Desktop.HideAppLauncher(); }; - ThreadStart ts = () => - { - var ctrls = frm.Controls.ToList(); - for (int i = 0; i < ctrls.Count(); i++) - { - SetupControls(ctrls[i]); - } - SetupControl(frm); - - }; - - if (runInThread == true) - { - var t = new Thread(ts); - t.IsBackground = true; - t.Start(); - } - else + var ctrls = frm.Controls.ToList(); + for (int i = 0; i < ctrls.Count(); i++) { - ts?.Invoke(); + SetupControls(ctrls[i]); } + SetupControl(frm); } } diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs index 6ce8cc9..85eab55 100644 --- a/ShiftOS.WinForms/WinformsDesktop.cs +++ b/ShiftOS.WinForms/WinformsDesktop.cs @@ -202,13 +202,21 @@ namespace ShiftOS.WinForms { if (SaveSystem.CurrentSave.Codepoints != lastcp) lastcp = SaveSystem.CurrentSave.Codepoints; - if (lastcp >= 10000) + if (lastcp >= 2500) { if (!Shiftorium.UpgradeInstalled("victortran_shiftnet")) { Story.Start("victortran_shiftnet"); } } + if(lastcp >= 5000) + { + if(Shiftorium.UpgradeInstalled("triwrite") && Shiftorium.UpgradeInstalled("simplesrc") && Shiftorium.UpgradeInstalled("victortran_shiftnet") && Shiftorium.UpgradeInstalled("story_hacker101_breakingthebonds")) + { + if (!Shiftorium.UpgradeInstalled("story_thefennfamily")) + Story.Start("story_thefennfamily"); + } + } } } while (!SaveSystem.ShuttingDown); }); diff --git a/ShiftOS_TheReturn/Localization.cs b/ShiftOS_TheReturn/Localization.cs index 5d848b0..c542c2a 100644 --- a/ShiftOS_TheReturn/Localization.cs +++ b/ShiftOS_TheReturn/Localization.cs @@ -111,50 +111,11 @@ namespace ShiftOS.Engine localizationStrings = JsonConvert.DeserializeObject>(Utils.ReadAllText(Paths.GetPath("english.local"))); //if no provider fall back to english } - foreach (var kv in localizationStrings) + foreach (var kv in localizationStrings.Where(x=>original.Contains(x.Key))) { original = original.Replace(kv.Key, kv.Value); // goes through and replaces all the localization blocks } - List orphaned = new List(); - - - int start_index = 0; - int length = 0; - bool indexing = false; - - foreach (var c in original) - { - // start paying attenion when you see a "{" - if (c == '{') - { - start_index = original.IndexOf(c); - indexing = true; - } - - if (indexing == true) - { - // stop paying attention when you see a "}" after seeing a "{" - length++; - if (c == '}') - { - indexing = false; - string o = original.Substring(start_index, length); - if (!orphaned.Contains(o)) - { - orphaned.Add(o); - } - start_index = 0; - length = 0; - } - } - } - - if (orphaned.Count > 0) - { - Utils.WriteAllText("0:/dev_orphaned_lang.txt", JsonConvert.SerializeObject(orphaned, Formatting.Indented)); //format if from this txt file - } - //string original2 = Parse(original); string usernameReplace = ""; @@ -203,13 +164,13 @@ namespace ShiftOS.Engine }; // actually do the replacement - foreach (KeyValuePair replacement in replace) + foreach (KeyValuePair replacement in replace.Where(x => original.Contains(x.Key))) { original = original.Replace(replacement.Key, Parse(replacement.Value)); } // do the replacement but default - foreach (KeyValuePair replacement in defaultReplace) + foreach (KeyValuePair replacement in defaultReplace.Where(x => original.Contains(x.Key))) { original = original.Replace(replacement.Key, replacement.Value); } diff --git a/ShiftOS_TheReturn/TerminalTextWriter.cs b/ShiftOS_TheReturn/TerminalTextWriter.cs index 4c0c3a0..63e88eb 100644 --- a/ShiftOS_TheReturn/TerminalTextWriter.cs +++ b/ShiftOS_TheReturn/TerminalTextWriter.cs @@ -42,6 +42,7 @@ namespace ShiftOS.Engine { ConsoleEx.OnFlush = () => { + System.Diagnostics.Debug.WriteLine("[terminal] " + buffer); Desktop.InvokeOnWorkerThread(() => { UnderlyingControl?.Write(buffer); -- cgit v1.2.3 From 6123e06842ec9eea60bd2d73588ac6c545d0ea99 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 28 May 2017 13:36:28 -0400 Subject: make localization 50 billion times faster --- ShiftOS.WinForms/Applications/Pong.cs | 10 +++++----- ShiftOS.WinForms/Tools/ControlManager.cs | 1 - ShiftOS_TheReturn/Localization.cs | 4 +++- 3 files changed, 8 insertions(+), 7 deletions(-) (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.WinForms/Applications/Pong.cs b/ShiftOS.WinForms/Applications/Pong.cs index 02d9963..84177b7 100644 --- a/ShiftOS.WinForms/Applications/Pong.cs +++ b/ShiftOS.WinForms/Applications/Pong.cs @@ -343,10 +343,10 @@ namespace ShiftOS.WinForms.Applications if (IsLeader) { //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 = Localization.Parse("{H_VEL}: ") + xveldec; - lblstatsY.Text = Localization.Parse("{V_VEL}: ") + yveldec; - lblstatscodepoints.Text = Localization.Parse("{CODEPOINTS}: ") + (levelrewards[level - 1] + beatairewardtotal).ToString(); - lbllevelandtime.Text = Localization.Parse("{LEVEL}: " + level + " - " + secondsleft + " {SECONDS_LEFT}"); + lblstatsX.Text = "X vel: " + xveldec; + lblstatsY.Text = "Y vel: " + yveldec; + lblstatscodepoints.Text = "Codepoints: " + (levelrewards[level - 1] + beatairewardtotal).ToString(); + lbllevelandtime.Text = "Level: " + level + " - " + secondsleft + " seconds left"; if (xVel > 20 || xVel < -20) { @@ -634,7 +634,7 @@ namespace ShiftOS.WinForms.Applications CompleteLevel(); } - lblstatscodepoints.Text = Localization.Parse("{CODEPOINTS}: ") + (levelrewards[level - 1] + beatairewardtotal).ToString(); + lblstatscodepoints.Text = "Codepoints: " + (levelrewards[level - 1] + beatairewardtotal).ToString(); } } SetupStats(); diff --git a/ShiftOS.WinForms/Tools/ControlManager.cs b/ShiftOS.WinForms/Tools/ControlManager.cs index 83ab7fe..fe77884 100644 --- a/ShiftOS.WinForms/Tools/ControlManager.cs +++ b/ShiftOS.WinForms/Tools/ControlManager.cs @@ -1,4 +1,3 @@ -#define SLOW_LOCALIZATION /* * MIT License diff --git a/ShiftOS_TheReturn/Localization.cs b/ShiftOS_TheReturn/Localization.cs index c542c2a..8adfa5a 100644 --- a/ShiftOS_TheReturn/Localization.cs +++ b/ShiftOS_TheReturn/Localization.cs @@ -160,7 +160,9 @@ namespace ShiftOS.Engine {"%domain", domainReplace}, {"%ns", namespaceReplace}, {"%cmd", commandReplace}, - {"%cp", SaveSystem.CurrentSave?.Codepoints.ToString() }, +#if LOCALIZE_CODEPOINTS + { "%cp", SaveSystem.CurrentSave?.Codepoints.ToString() }, +#endif }; // actually do the replacement -- cgit v1.2.3 From 9914c18456a0c08019e778479ce727ac937b1e57 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 28 May 2017 14:40:42 -0400 Subject: Fuck --- ShiftOS.WinForms/Applications/Terminal.cs | 1 + ShiftOS.WinForms/Controls/TerminalBox.cs | 6 +++ ShiftOS.WinForms/Tools/ControlManager.cs | 6 +-- ShiftOS_TheReturn/SaveSystem.cs | 64 +++++++++++++++---------------- ShiftOS_TheReturn/ServerManager.cs | 17 -------- ShiftOS_TheReturn/ShiftOS.Engine.csproj | 4 -- 6 files changed, 42 insertions(+), 56 deletions(-) (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.WinForms/Applications/Terminal.cs b/ShiftOS.WinForms/Applications/Terminal.cs index 3d17d35..de4888b 100644 --- a/ShiftOS.WinForms/Applications/Terminal.cs +++ b/ShiftOS.WinForms/Applications/Terminal.cs @@ -232,6 +232,7 @@ namespace ShiftOS.WinForms.Applications var text = txt.Lines.ToArray(); var text2 = text[text.Length - 1]; var text3 = ""; + Console.WriteLine(); var text4 = Regex.Replace(text2, @"\t|\n|\r", ""); if (IsInRemoteSystem == true) diff --git a/ShiftOS.WinForms/Controls/TerminalBox.cs b/ShiftOS.WinForms/Controls/TerminalBox.cs index 25f7144..c188321 100644 --- a/ShiftOS.WinForms/Controls/TerminalBox.cs +++ b/ShiftOS.WinForms/Controls/TerminalBox.cs @@ -64,6 +64,9 @@ namespace ShiftOS.WinForms.Controls public void Write(string text) { this.HideSelection = true; + this.SelectionColor = ControlManager.ConvertColor(ConsoleEx.ForegroundColor); + this.SelectionBackColor = ControlManager.ConvertColor(ConsoleEx.BackgroundColor); + this.SelectionFont = ConstructFont(); this.AppendText(Localization.Parse(text)); this.HideSelection = false; } @@ -85,6 +88,9 @@ namespace ShiftOS.WinForms.Controls { Engine.AudioManager.PlayStream(Properties.Resources.writesound); this.HideSelection = true; + this.SelectionColor = ControlManager.ConvertColor(ConsoleEx.ForegroundColor); + this.SelectionBackColor = ControlManager.ConvertColor(ConsoleEx.BackgroundColor); + this.SelectionFont = ConstructFont(); this.Select(this.TextLength, 0); this.AppendText(Localization.Parse(text) + Environment.NewLine); this.HideSelection = false; diff --git a/ShiftOS.WinForms/Tools/ControlManager.cs b/ShiftOS.WinForms/Tools/ControlManager.cs index fe77884..92482fa 100644 --- a/ShiftOS.WinForms/Tools/ControlManager.cs +++ b/ShiftOS.WinForms/Tools/ControlManager.cs @@ -207,19 +207,19 @@ namespace ShiftOS.WinForms.Tools if (ctrl is Button) { Button b = ctrl as Button; - if (!b.Tag.ToString().ToLower().Contains("keepbg")) + if (!tag.Contains("keepbg")) { b.BackColor = SkinEngine.LoadedSkin.ButtonBackgroundColor; b.BackgroundImage = SkinEngine.GetImage("buttonidle"); b.BackgroundImageLayout = SkinEngine.GetImageLayout("buttonidle"); } b.FlatAppearance.BorderSize = SkinEngine.LoadedSkin.ButtonBorderWidth; - if (!b.Tag.ToString().ToLower().Contains("keepfg")) + if (!tag.Contains("keepfg")) { b.FlatAppearance.BorderColor = SkinEngine.LoadedSkin.ButtonForegroundColor; b.ForeColor = SkinEngine.LoadedSkin.ButtonForegroundColor; } - if (!b.Tag.ToString().ToLower().Contains("keepfont")) + if (!tag.Contains("keepfont")) b.Font = SkinEngine.LoadedSkin.ButtonTextFont; Color orig_bg = b.BackColor; diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index 489b718..55f5cd5 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -153,50 +153,50 @@ namespace ShiftOS.Engine } } - if (defaultConf.ConnectToMud == true) + + + bool guidReceived = false; + ServerManager.GUIDReceived += (str) => { - bool guidReceived = false; - ServerManager.GUIDReceived += (str) => - { //Connection successful! Stop waiting! guidReceived = true; - Console.WriteLine("[inetd] Connection successful."); - }; + Console.WriteLine("[inetd] Connection successful."); + }; - try - { - - ServerManager.Initiate(UserConfig.Get().DigitalSocietyAddress, UserConfig.Get().DigitalSocietyPort); - //This haults the client until the connection is successful. - while (ServerManager.thisGuid == new Guid()) - { - Thread.Sleep(10); - } - Console.WriteLine("[inetd] DHCP GUID recieved, finished setup"); - FinishBootstrap(); - } - catch (Exception ex) + try + { + + ServerManager.Initiate(UserConfig.Get().DigitalSocietyAddress, UserConfig.Get().DigitalSocietyPort); + //This haults the client until the connection is successful. + while (ServerManager.thisGuid == new Guid()) { - //No errors, this never gets called. - Console.WriteLine("[inetd] SEVERE: " + ex.Message); - Thread.Sleep(3000); - ServerManager.StartLANServer(); - while (ServerManager.thisGuid == new Guid()) - { - Thread.Sleep(10); - } - Console.WriteLine("[inetd] DHCP GUID recieved, finished setup"); - FinishBootstrap(); + Thread.Sleep(10); } + Console.WriteLine("[inetd] DHCP GUID recieved, finished setup"); + FinishBootstrap(); } - else + catch (Exception ex) { - ServerManager.StartLANServer(); + //No errors, this never gets called. + Console.WriteLine("[inetd] SEVERE: " + ex.Message); + Thread.Sleep(3000); + Console.WriteLine("[sys] SEVERE: Cannot connect to server. Shutting down in 5..."); + Thread.Sleep(1000); + Console.WriteLine("[sys] 4..."); + Thread.Sleep(1000); + Console.WriteLine("[sys] 3..."); + Thread.Sleep(1000); + Console.WriteLine("[sys] 2..."); + Thread.Sleep(1000); + Console.WriteLine("[sys] 1..."); + Thread.Sleep(1000); + Console.WriteLine("[sys] Bye bye."); + System.Diagnostics.Process.GetCurrentProcess().Kill(); } //Nothing happens past this point - but the client IS connected! It shouldn't be stuck in that while loop above. - + })); thread.IsBackground = true; thread.Start(); diff --git a/ShiftOS_TheReturn/ServerManager.cs b/ShiftOS_TheReturn/ServerManager.cs index 217b9ee..f0acaa2 100644 --- a/ShiftOS_TheReturn/ServerManager.cs +++ b/ShiftOS_TheReturn/ServerManager.cs @@ -316,23 +316,6 @@ Ping: {ServerManager.DigitalSocietyPing} ms private static bool singleplayer = false; public static bool IsSingleplayer { get { return singleplayer; } } - public static void StartLANServer() - { - singleplayer = true; - ShiftOS.Server.Program.ServerStarted += (address) => - { - Console.WriteLine($"Connecting to {address}..."); - Initiate(address, 13370); - }; - Disconnected += () => - { - ShiftOS.Server.Program.Stop(); - }; - ShiftOS.Server.Program.Main(new[] { "" }); - - - } - /// /// Occurs when the server sends a message to this client. /// diff --git a/ShiftOS_TheReturn/ShiftOS.Engine.csproj b/ShiftOS_TheReturn/ShiftOS.Engine.csproj index 9d7d696..4cbce72 100644 --- a/ShiftOS_TheReturn/ShiftOS.Engine.csproj +++ b/ShiftOS_TheReturn/ShiftOS.Engine.csproj @@ -162,10 +162,6 @@ {A069089A-8962-4607-B2B2-4CF4A371066E} ShiftOS.Objects - - {226C63B4-E60D-4949-B4E7-7A2DDBB96776} - ShiftOS.Server - -- cgit v1.2.3 From c7ba7d733c756d196f98dd4533289a1ef4db715f Mon Sep 17 00:00:00 2001 From: Rylan/wowmom98 Date: Sun, 28 May 2017 14:44:08 -0400 Subject: un obsoleting --- ShiftOS.Server/Core.cs | 3 ++- ShiftOS.WinForms/Applications/MUDControlCentre.cs | 16 ++++++++-------- ShiftOS.WinForms/Applications/Skin Loader.cs | 2 +- ShiftOS.WinForms/HackerCommands.cs | 8 ++++---- ShiftOS.WinForms/Oobe.cs | 2 +- ShiftOS.WinForms/Stories/LegionStory.cs | 2 +- ShiftOS_TheReturn/Commands.cs | 2 +- ShiftOS_TheReturn/Scripting.cs | 2 +- ShiftOS_TheReturn/ServerManager.cs | 4 ++-- ShiftOS_TheReturn/TerminalBackend.cs | 8 ++++---- 10 files changed, 25 insertions(+), 24 deletions(-) (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.Server/Core.cs b/ShiftOS.Server/Core.cs index 7bb5b1d..a53a5bc 100644 --- a/ShiftOS.Server/Core.cs +++ b/ShiftOS.Server/Core.cs @@ -32,6 +32,7 @@ using NetSockets; using Newtonsoft.Json; using System.IO; using static ShiftOS.Server.Program; +using ShiftOS.Engine namespace ShiftOS.Server @@ -180,7 +181,7 @@ namespace ShiftOS.Server if (sve.EndsWith(".save")) { var save = JsonConvert.DeserializeObject(File.ReadAllText(sve)); - accs.Add($"{save.Username}@{save.SystemName}"); + accs.Add($"{ShiftOS.Engine.SaveSytem.CurrentUser.Username}@{save.SystemName}"); } } diff --git a/ShiftOS.WinForms/Applications/MUDControlCentre.cs b/ShiftOS.WinForms/Applications/MUDControlCentre.cs index ab89ffd..97212e7 100644 --- a/ShiftOS.WinForms/Applications/MUDControlCentre.cs +++ b/ShiftOS.WinForms/Applications/MUDControlCentre.cs @@ -100,7 +100,7 @@ namespace ShiftOS.WinForms.Applications { ServerManager.SendMessage("shop_removeowned", JsonConvert.SerializeObject(new { - username = SaveSystem.CurrentSave.Username + username = SaveSystem.CurrentUser.Username })); ShowCreateShop(); } @@ -290,7 +290,7 @@ namespace ShiftOS.WinForms.Applications creatingShop = true; editingShop.Name = "My shop"; editingShop.Description = "My shop has lots of awesome items. You should buy from my shop."; - editingShop.Owner = SaveSystem.CurrentSave.Username; + editingShop.Owner = SaveSystem.CurrentUser.Username; editingShop.Items = new List(); shop_editor.BringToFront(); PopulateShopEditor(); @@ -402,7 +402,7 @@ namespace ShiftOS.WinForms.Applications lbprice.Text = $"Cost: {item.Cost} CP"; btnbuy.Show(); }; - if(shop.Owner == SaveSystem.CurrentSave.Username) + if(shop.Owner == SaveSystem.CurrentUser.Username) { btneditshop.Show(); } @@ -560,7 +560,7 @@ namespace ShiftOS.WinForms.Applications you_systemstatus.BringToFront(); - lblsysstatus.Text = $@"Username: {SaveSystem.CurrentSave.Username} + lblsysstatus.Text = $@"Username: {SaveSystem.CurrentUser.Username} System name: {SaveSystem.CurrentSave.SystemName} Codepoints: {SaveSystem.CurrentSave.Codepoints} @@ -591,7 +591,7 @@ Current legions: {legionname}"; private void tsMemos_Click(object sender, EventArgs e) { ServerManager.SendMessage("get_memos_for_user", $@"{{ - username: ""{SaveSystem.CurrentSave.Username}"" + username: ""{SaveSystem.CurrentUser.Username}"" }}"); you_memos.BringToFront(); } @@ -812,7 +812,7 @@ Current legions: {legionname}"; { ServerManager.SendMessage("user_shop_check", JsonConvert.SerializeObject(new { - username = SaveSystem.CurrentSave.Username + username = SaveSystem.CurrentUser.Username })); } @@ -895,7 +895,7 @@ Current legions: {legionname}"; private void myShopToolStripMenuItem_Click(object sender, EventArgs e) { - ServerManager.SendMessage("user_get_shop", SaveSystem.CurrentSave.Username); + ServerManager.SendMessage("user_get_shop", SaveSystem.CurrentUser.Username); } private void btneditshop_Click(object sender, EventArgs e) @@ -923,7 +923,7 @@ Current legions: {legionname}"; { ServerManager.SendMessage("delete_save", JsonConvert.SerializeObject(new ClientSave { - Username = SaveSystem.CurrentSave.Username, + Username = SaveSystem.CurrentUser.Username, Password = SaveSystem.CurrentSave.Password })); diff --git a/ShiftOS.WinForms/Applications/Skin Loader.cs b/ShiftOS.WinForms/Applications/Skin Loader.cs index 90b05a1..e4f0597 100644 --- a/ShiftOS.WinForms/Applications/Skin Loader.cs +++ b/ShiftOS.WinForms/Applications/Skin Loader.cs @@ -306,7 +306,7 @@ namespace ShiftOS.WinForms.Applications System.IO.Directory.CreateDirectory(Paths.SharedFolder + "\\skins"); } - string path = Paths.SharedFolder + "\\skins\\" + SaveSystem.CurrentSave.Username + "-" + fname; + string path = Paths.SharedFolder + "\\skins\\" + SaveSystem.CurrentUser.Username + "-" + fname; System.IO.File.WriteAllText(path, JsonConvert.SerializeObject(LoadedSkin)); }))); diff --git a/ShiftOS.WinForms/HackerCommands.cs b/ShiftOS.WinForms/HackerCommands.cs index 86981f4..47b486d 100644 --- a/ShiftOS.WinForms/HackerCommands.cs +++ b/ShiftOS.WinForms/HackerCommands.cs @@ -107,7 +107,7 @@ namespace ShiftOS.WinForms Thread.Sleep(2000); writeSlow($"Hello there, fellow multi-user domain user."); writeSlow("My name, as you can tell, is hacker101."); - writeSlow("And yours must be... don't say it... it's " + SaveSystem.CurrentSave.Username + "@" + SaveSystem.CurrentSave.SystemName + ", right?"); + writeSlow("And yours must be... don't say it... it's " + SaveSystem.CurrentUser.Username + "@" + SaveSystem.CurrentSave.SystemName + ", right?"); writeSlow("Of course it is."); writeSlow("And I bet you 10,000 Codepoints that you have... " + SaveSystem.CurrentSave.Codepoints.ToString() + " Codepoints."); writeSlow("Oh, and how much upgrades have you installed since you first started using ShiftOS?"); @@ -135,7 +135,7 @@ namespace ShiftOS.WinForms Console.Write(" ..done"); TerminalBackend.InStory = false; TerminalBackend.PrefixEnabled = true; - Console.Write($"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ "); + Console.Write($"{SaveSystem.CurrentUser.Username}@{SaveSystem.CurrentSave.SystemName}:~$ "); StartHackerTutorial(); TerminalBackend.PrefixEnabled = true; TerminalBackend.PrintPrompt(); @@ -454,7 +454,7 @@ namespace ShiftOS.WinForms var sve = JsonConvert.DeserializeObject(msg.Contents); if(sve.Password == pass) { - Console.WriteLine("Username: " + sve.Username); + Console.WriteLine("Username: " + SaveSystem.CurrentUser.Username); Console.WriteLine("Password: " + sve.Password); Console.WriteLine("System name: " + sve.SystemName); Console.WriteLine(); @@ -531,7 +531,7 @@ namespace ShiftOS.WinForms } sve.Codepoints -= amount; - SaveSystem.TransferCodepointsFrom(sve.Username, amount); + SaveSystem.TransferCodepointsFrom(SaveSystem.CurrentUser.Username, amount); ServerManager.SendMessage("mud_save_allow_dead", JsonConvert.SerializeObject(sve)); SaveSystem.SaveGame(); } diff --git a/ShiftOS.WinForms/Oobe.cs b/ShiftOS.WinForms/Oobe.cs index 9182b4b..90395a7 100644 --- a/ShiftOS.WinForms/Oobe.cs +++ b/ShiftOS.WinForms/Oobe.cs @@ -302,7 +302,7 @@ namespace ShiftOS.WinForms var client = new UniteClient("http://getshiftos.ml", token); var sve = new Save(); - sve.Username = client.GetEmail(); + SaveSystem.CurrentUser.Username = client.GetEmail(); sve.Password = Guid.NewGuid().ToString(); sve.SystemName = client.GetSysName(); sve.UniteAuthToken = token; diff --git a/ShiftOS.WinForms/Stories/LegionStory.cs b/ShiftOS.WinForms/Stories/LegionStory.cs index 53d55fb..433ad2d 100644 --- a/ShiftOS.WinForms/Stories/LegionStory.cs +++ b/ShiftOS.WinForms/Stories/LegionStory.cs @@ -142,7 +142,7 @@ namespace ShiftOS.WinForms.Stories { WriteLine("DevX@mud - user connecting to your system.", false); Thread.Sleep(2000); - WriteLine($"Hello, {SaveSystem.CurrentSave.Username}. It's been a while."); + WriteLine($"Hello, {SaveSystem.CurrentUser.Username}. It's been a while."); WriteLine("My intelligence suggests you've installed all GUI-based Shiftorium upgrades."); WriteLine("Bet you're liking ShiftOS now that the terminal isn't the only way you can control it."); WriteLine("Well, now it's time to introduce your next task."); diff --git a/ShiftOS_TheReturn/Commands.cs b/ShiftOS_TheReturn/Commands.cs index 96e5af5..b97cd1d 100644 --- a/ShiftOS_TheReturn/Commands.cs +++ b/ShiftOS_TheReturn/Commands.cs @@ -95,7 +95,7 @@ namespace ShiftOS.Engine { TerminalBackend.IsForwardingConsoleWrites = forwarding; TerminalBackend.ForwardGUID = (forwarding == true) ? fGuid : null; - Console.WriteLine($"{SaveSystem.CurrentSave.Username} says \"{result}\"."); + Console.WriteLine($"{SaveSystem.CurrentUser.Username} says \"{result}\"."); TerminalBackend.IsForwardingConsoleWrites = false; }; Desktop.InvokeOnWorkerThread(new Action(() => diff --git a/ShiftOS_TheReturn/Scripting.cs b/ShiftOS_TheReturn/Scripting.cs index dd5acfd..61c6676 100644 --- a/ShiftOS_TheReturn/Scripting.cs +++ b/ShiftOS_TheReturn/Scripting.cs @@ -312,7 +312,7 @@ end"); { Console.WriteLine(""); Lua(lua); - Console.WriteLine($"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ "); + Console.WriteLine($"{SaveSystem.CurrentUser.Username}@{SaveSystem.CurrentSave.SystemName}:~$ "); } catch (Exception e) { diff --git a/ShiftOS_TheReturn/ServerManager.cs b/ShiftOS_TheReturn/ServerManager.cs index f0acaa2..abb674d 100644 --- a/ShiftOS_TheReturn/ServerManager.cs +++ b/ShiftOS_TheReturn/ServerManager.cs @@ -148,7 +148,7 @@ Ping: {ServerManager.DigitalSocietyPing} ms switch(msg.Name) { case "getguid_fromserver": - if(SaveSystem.CurrentSave.Username == msg.Contents) + if(SaveSystem.CurrentUser.Username == msg.Contents) { client.Send(new NetObject("yes_i_am", new ServerMessage { @@ -244,7 +244,7 @@ Ping: {ServerManager.DigitalSocietyPing} ms else if(msg.Name == "update_your_cp") { var args = JsonConvert.DeserializeObject>(msg.Contents); - if(args["username"] as string == SaveSystem.CurrentSave.Username) + if(args["username"] as string == SaveSystem.CurrentUser.Username) { SaveSystem.CurrentSave.Codepoints += (long)args["amount"]; Desktop.InvokeOnWorkerThread(new Action(() => diff --git a/ShiftOS_TheReturn/TerminalBackend.cs b/ShiftOS_TheReturn/TerminalBackend.cs index 1c024eb..6104927 100644 --- a/ShiftOS_TheReturn/TerminalBackend.cs +++ b/ShiftOS_TheReturn/TerminalBackend.cs @@ -581,7 +581,7 @@ namespace ShiftOS.Engine if (TerminalBackend.PrefixEnabled) { - text3 = text4.Remove(0, $"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ ".Length); + text3 = text4.Remove(0, $"{SaveSystem.CurrentUser.Username}@{SaveSystem.CurrentSave.SystemName}:~$ ".Length); } IsForwardingConsoleWrites = true; if (TerminalBackend.InStory == false) @@ -590,7 +590,7 @@ namespace ShiftOS.Engine } if (TerminalBackend.PrefixEnabled) { - Console.Write($"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ "); + Console.Write($"{SaveSystem.CurrentUser.Username}@{SaveSystem.CurrentSave.SystemName}:~$ "); } IsForwardingConsoleWrites = false; } @@ -605,7 +605,7 @@ namespace ShiftOS.Engine string pass = a["password"] as string; string sys = a["sysname"] as string; string guid = msg.GUID; - if (SaveSystem.CurrentSave.Username == uName && SaveSystem.CurrentSave.Password == pass && CurrentSave.SystemName == sys) + if (SaveSystem.CurrentUser.Username == uName && SaveSystem.CurrentSave.Password == pass && CurrentSave.SystemName == sys) { ForwardGUID = guid; ServerManager.SendMessage("trm_handshake_accept", $@"{{ @@ -615,7 +615,7 @@ namespace ShiftOS.Engine IsForwardingConsoleWrites = true; InvokeCommand("sos.status"); - Console.Write($"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ "); + Console.Write($"{SaveSystem.CurrentUser.Username}@{SaveSystem.CurrentSave.SystemName}:~$ "); IsForwardingConsoleWrites = false; } } -- cgit v1.2.3 From e85832a5a4caefe854f3f27b7e60663e2bf26624 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 28 May 2017 16:05:51 -0400 Subject: fix double login issue and oobe bugs --- ShiftOS.WinForms/OobeStory.cs | 2 ++ ShiftOS_TheReturn/SaveSystem.cs | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.WinForms/OobeStory.cs b/ShiftOS.WinForms/OobeStory.cs index a35e1d8..8d86b9e 100644 --- a/ShiftOS.WinForms/OobeStory.cs +++ b/ShiftOS.WinForms/OobeStory.cs @@ -111,6 +111,7 @@ namespace ShiftOS.WinForms ConsoleEx.Bold = false; ConsoleEx.BackgroundColor = ConsoleColor.Black; Console.Write("Formatting: ["); + ConsoleEx.OnFlush?.Invoke(); int formatProgress = 3; while (formatProgress <= 100) { @@ -118,6 +119,7 @@ namespace ShiftOS.WinForms { ConsoleEx.BackgroundColor = ConsoleColor.White; Console.Write(" "); + ConsoleEx.OnFlush?.Invoke(); ConsoleEx.BackgroundColor = ConsoleColor.Black; } Desktop.InvokeOnWorkerThread(() => Engine.AudioManager.PlayStream(Properties.Resources.typesound)); diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index 55f5cd5..c8996d4 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -21,6 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ +// #define NOSAVE //#define ONLINEMODE @@ -213,15 +214,14 @@ namespace ShiftOS.Engine savehandshake = (msg) => { + ServerManager.MessageReceived -= savehandshake; if (msg.Name == "mud_savefile") { CurrentSave = JsonConvert.DeserializeObject(msg.Contents); - ServerManager.MessageReceived -= savehandshake; } else if (msg.Name == "mud_login_denied") { oobe.PromptForLogin(); - ServerManager.MessageReceived -= savehandshake; } }; ServerManager.MessageReceived += savehandshake; @@ -554,6 +554,7 @@ namespace ShiftOS.Engine /// public static void SaveGame() { +#if !NOSAVE if(!Shiftorium.Silent) Console.WriteLine(""); if(!Shiftorium.Silent) @@ -566,6 +567,7 @@ namespace ShiftOS.Engine if (!Shiftorium.Silent) Console.WriteLine(" ...{DONE}."); System.IO.File.WriteAllText(Paths.SaveFile, Utils.ExportMount(0)); +#endif } /// -- cgit v1.2.3 From 58c9152351b02b37e63fc193060474478f1e9a65 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 29 May 2017 11:38:11 -0400 Subject: various things from last night --- ShiftOS.WinForms/Applications/Chat.Designer.cs | 178 ++++++++++----------- ShiftOS.WinForms/Applications/Terminal.cs | 2 +- ShiftOS.WinForms/Oobe.cs | 2 +- ShiftOS.WinForms/ShiftOS.WinForms.csproj | 9 ++ .../ShiftnetSites/ShiftSoft_Ping.Designer.cs | 89 +++++++++++ ShiftOS.WinForms/ShiftnetSites/ShiftSoft_Ping.cs | 92 +++++++++++ ShiftOS.WinForms/ShiftnetSites/ShiftSoft_Ping.resx | 120 ++++++++++++++ ShiftOS.WinForms/Stories/LegionStory.cs | 6 + 8 files changed, 407 insertions(+), 91 deletions(-) create mode 100644 ShiftOS.WinForms/ShiftnetSites/ShiftSoft_Ping.Designer.cs create mode 100644 ShiftOS.WinForms/ShiftnetSites/ShiftSoft_Ping.cs create mode 100644 ShiftOS.WinForms/ShiftnetSites/ShiftSoft_Ping.resx (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.WinForms/Applications/Chat.Designer.cs b/ShiftOS.WinForms/Applications/Chat.Designer.cs index d51b732..7bfa4dd 100644 --- a/ShiftOS.WinForms/Applications/Chat.Designer.cs +++ b/ShiftOS.WinForms/Applications/Chat.Designer.cs @@ -54,6 +54,13 @@ namespace ShiftOS.WinForms.Applications { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Chat)); this.panel1 = new System.Windows.Forms.Panel(); + this.pnlstart = new System.Windows.Forms.Panel(); + this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); + this.txtchatid = new System.Windows.Forms.TextBox(); + this.btnjoin = new System.Windows.Forms.Button(); + this.label3 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); this.rtbchat = new System.Windows.Forms.RichTextBox(); this.toolStrip1 = new System.Windows.Forms.ToolStrip(); this.tschatid = new System.Windows.Forms.ToolStripLabel(); @@ -61,18 +68,11 @@ namespace ShiftOS.WinForms.Applications this.tsbottombar = new System.Windows.Forms.ToolStrip(); this.txtuserinput = new System.Windows.Forms.ToolStripTextBox(); this.btnsend = new System.Windows.Forms.ToolStripButton(); - this.pnlstart = new System.Windows.Forms.Panel(); - this.label1 = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); - this.label3 = new System.Windows.Forms.Label(); - this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); - this.txtchatid = new System.Windows.Forms.TextBox(); - this.btnjoin = new System.Windows.Forms.Button(); this.panel1.SuspendLayout(); - this.toolStrip1.SuspendLayout(); - this.tsbottombar.SuspendLayout(); this.pnlstart.SuspendLayout(); this.flowLayoutPanel1.SuspendLayout(); + this.toolStrip1.SuspendLayout(); + this.tsbottombar.SuspendLayout(); this.SuspendLayout(); // // panel1 @@ -87,6 +87,82 @@ namespace ShiftOS.WinForms.Applications this.panel1.Size = new System.Drawing.Size(633, 318); this.panel1.TabIndex = 0; // + // pnlstart + // + this.pnlstart.Controls.Add(this.flowLayoutPanel1); + this.pnlstart.Controls.Add(this.label3); + this.pnlstart.Controls.Add(this.label2); + this.pnlstart.Controls.Add(this.label1); + this.pnlstart.Dock = System.Windows.Forms.DockStyle.Fill; + this.pnlstart.Location = new System.Drawing.Point(0, 25); + this.pnlstart.Name = "pnlstart"; + this.pnlstart.Size = new System.Drawing.Size(633, 268); + this.pnlstart.TabIndex = 4; + // + // flowLayoutPanel1 + // + this.flowLayoutPanel1.AutoSize = true; + this.flowLayoutPanel1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.flowLayoutPanel1.Controls.Add(this.txtchatid); + this.flowLayoutPanel1.Controls.Add(this.btnjoin); + this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Top; + this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 118); + this.flowLayoutPanel1.Name = "flowLayoutPanel1"; + this.flowLayoutPanel1.Size = new System.Drawing.Size(633, 29); + this.flowLayoutPanel1.TabIndex = 3; + // + // txtchatid + // + this.txtchatid.Location = new System.Drawing.Point(3, 3); + this.txtchatid.Name = "txtchatid"; + this.txtchatid.Size = new System.Drawing.Size(192, 20); + this.txtchatid.TabIndex = 0; + // + // btnjoin + // + this.btnjoin.Location = new System.Drawing.Point(201, 3); + this.btnjoin.Name = "btnjoin"; + this.btnjoin.Size = new System.Drawing.Size(75, 23); + this.btnjoin.TabIndex = 1; + this.btnjoin.Text = "Join"; + this.btnjoin.UseVisualStyleBackColor = true; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Dock = System.Windows.Forms.DockStyle.Top; + this.label3.Location = new System.Drawing.Point(0, 85); + this.label3.Name = "label3"; + this.label3.Padding = new System.Windows.Forms.Padding(10); + this.label3.Size = new System.Drawing.Size(79, 33); + this.label3.TabIndex = 2; + this.label3.Tag = "header3"; + this.label3.Text = "Join a chat"; + // + // label2 + // + this.label2.Dock = System.Windows.Forms.DockStyle.Top; + this.label2.Location = new System.Drawing.Point(0, 33); + this.label2.Name = "label2"; + this.label2.Padding = new System.Windows.Forms.Padding(10); + this.label2.Size = new System.Drawing.Size(633, 52); + this.label2.TabIndex = 1; + this.label2.Text = "SimpleSRC is a simple chat program that utilises the ShiftOS Relay Chat protocol." + + " All you have to do is enter a chat code or system name, and SimpleSRC will try " + + "to initiate a chat for you."; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Dock = System.Windows.Forms.DockStyle.Top; + this.label1.Location = new System.Drawing.Point(0, 0); + this.label1.Name = "label1"; + this.label1.Padding = new System.Windows.Forms.Padding(10); + this.label1.Size = new System.Drawing.Size(143, 33); + this.label1.TabIndex = 0; + this.label1.Tag = "header1"; + this.label1.Text = "Welcome to SimpleSRC!"; + // // rtbchat // this.rtbchat.Dock = System.Windows.Forms.DockStyle.Fill; @@ -151,82 +227,6 @@ namespace ShiftOS.WinForms.Applications this.btnsend.Text = "Send"; this.btnsend.Click += new System.EventHandler(this.btnsend_Click); // - // pnlstart - // - this.pnlstart.Controls.Add(this.flowLayoutPanel1); - this.pnlstart.Controls.Add(this.label3); - this.pnlstart.Controls.Add(this.label2); - this.pnlstart.Controls.Add(this.label1); - this.pnlstart.Dock = System.Windows.Forms.DockStyle.Fill; - this.pnlstart.Location = new System.Drawing.Point(0, 25); - this.pnlstart.Name = "pnlstart"; - this.pnlstart.Size = new System.Drawing.Size(633, 268); - this.pnlstart.TabIndex = 4; - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Dock = System.Windows.Forms.DockStyle.Top; - this.label1.Location = new System.Drawing.Point(0, 0); - this.label1.Name = "label1"; - this.label1.Padding = new System.Windows.Forms.Padding(10); - this.label1.Size = new System.Drawing.Size(143, 33); - this.label1.TabIndex = 0; - this.label1.Tag = "header1"; - this.label1.Text = "Welcome to SimpleSRC!"; - // - // label2 - // - this.label2.Dock = System.Windows.Forms.DockStyle.Top; - this.label2.Location = new System.Drawing.Point(0, 33); - this.label2.Name = "label2"; - this.label2.Padding = new System.Windows.Forms.Padding(10); - this.label2.Size = new System.Drawing.Size(633, 52); - this.label2.TabIndex = 1; - this.label2.Text = "SimpleSRC is a simple chat program that utilises the ShiftOS Relay Chat protocol." + - " All you have to do is enter a chat code or system name, and SimpleSRC will try " + - "to initiate a chat for you."; - // - // label3 - // - this.label3.AutoSize = true; - this.label3.Dock = System.Windows.Forms.DockStyle.Top; - this.label3.Location = new System.Drawing.Point(0, 85); - this.label3.Name = "label3"; - this.label3.Padding = new System.Windows.Forms.Padding(10); - this.label3.Size = new System.Drawing.Size(79, 33); - this.label3.TabIndex = 2; - this.label3.Tag = "header3"; - this.label3.Text = "Join a chat"; - // - // flowLayoutPanel1 - // - this.flowLayoutPanel1.AutoSize = true; - this.flowLayoutPanel1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.flowLayoutPanel1.Controls.Add(this.txtchatid); - this.flowLayoutPanel1.Controls.Add(this.btnjoin); - this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Top; - this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 118); - this.flowLayoutPanel1.Name = "flowLayoutPanel1"; - this.flowLayoutPanel1.Size = new System.Drawing.Size(633, 29); - this.flowLayoutPanel1.TabIndex = 3; - // - // txtchatid - // - this.txtchatid.Location = new System.Drawing.Point(3, 3); - this.txtchatid.Name = "txtchatid"; - this.txtchatid.Size = new System.Drawing.Size(192, 20); - this.txtchatid.TabIndex = 0; - // - // btnjoin - // - this.btnjoin.Location = new System.Drawing.Point(201, 3); - this.btnjoin.Name = "btnjoin"; - this.btnjoin.Size = new System.Drawing.Size(75, 23); - this.btnjoin.TabIndex = 1; - this.btnjoin.Text = "Join"; - this.btnjoin.UseVisualStyleBackColor = true; - // // Chat // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -236,14 +236,14 @@ namespace ShiftOS.WinForms.Applications this.Size = new System.Drawing.Size(633, 318); this.panel1.ResumeLayout(false); this.panel1.PerformLayout(); - this.toolStrip1.ResumeLayout(false); - this.toolStrip1.PerformLayout(); - this.tsbottombar.ResumeLayout(false); - this.tsbottombar.PerformLayout(); this.pnlstart.ResumeLayout(false); this.pnlstart.PerformLayout(); this.flowLayoutPanel1.ResumeLayout(false); this.flowLayoutPanel1.PerformLayout(); + this.toolStrip1.ResumeLayout(false); + this.toolStrip1.PerformLayout(); + this.tsbottombar.ResumeLayout(false); + this.tsbottombar.PerformLayout(); this.ResumeLayout(false); } diff --git a/ShiftOS.WinForms/Applications/Terminal.cs b/ShiftOS.WinForms/Applications/Terminal.cs index de4888b..2d2b4c5 100644 --- a/ShiftOS.WinForms/Applications/Terminal.cs +++ b/ShiftOS.WinForms/Applications/Terminal.cs @@ -232,7 +232,7 @@ namespace ShiftOS.WinForms.Applications var text = txt.Lines.ToArray(); var text2 = text[text.Length - 1]; var text3 = ""; - Console.WriteLine(); + txt.AppendText(Environment.NewLine); var text4 = Regex.Replace(text2, @"\t|\n|\r", ""); if (IsInRemoteSystem == true) diff --git a/ShiftOS.WinForms/Oobe.cs b/ShiftOS.WinForms/Oobe.cs index 90395a7..9182b4b 100644 --- a/ShiftOS.WinForms/Oobe.cs +++ b/ShiftOS.WinForms/Oobe.cs @@ -302,7 +302,7 @@ namespace ShiftOS.WinForms var client = new UniteClient("http://getshiftos.ml", token); var sve = new Save(); - SaveSystem.CurrentUser.Username = client.GetEmail(); + sve.Username = client.GetEmail(); sve.Password = Guid.NewGuid().ToString(); sve.SystemName = client.GetSysName(); sve.UniteAuthToken = token; diff --git a/ShiftOS.WinForms/ShiftOS.WinForms.csproj b/ShiftOS.WinForms/ShiftOS.WinForms.csproj index 9844657..22bd1d2 100644 --- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj +++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj @@ -388,6 +388,12 @@ ShiftGames.cs + + UserControl + + + ShiftSoft_Ping.cs + @@ -583,6 +589,9 @@ ShiftGames.cs + + ShiftSoft_Ping.cs + UniteLoginDialog.cs diff --git a/ShiftOS.WinForms/ShiftnetSites/ShiftSoft_Ping.Designer.cs b/ShiftOS.WinForms/ShiftnetSites/ShiftSoft_Ping.Designer.cs new file mode 100644 index 0000000..244f6d4 --- /dev/null +++ b/ShiftOS.WinForms/ShiftnetSites/ShiftSoft_Ping.Designer.cs @@ -0,0 +1,89 @@ +namespace ShiftOS.WinForms.ShiftnetSites +{ + partial class ShiftSoft_Ping + { + /// + /// 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.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.fllist = new System.Windows.Forms.FlowLayoutPanel(); + this.SuspendLayout(); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Dock = System.Windows.Forms.DockStyle.Top; + this.label1.Location = new System.Drawing.Point(0, 0); + this.label1.Name = "label1"; + this.label1.Padding = new System.Windows.Forms.Padding(10); + this.label1.Size = new System.Drawing.Size(48, 33); + this.label1.TabIndex = 0; + this.label1.Tag = "header2"; + this.label1.Text = "Ping"; + // + // label2 + // + this.label2.Dock = System.Windows.Forms.DockStyle.Top; + this.label2.Location = new System.Drawing.Point(0, 33); + this.label2.Name = "label2"; + this.label2.Padding = new System.Windows.Forms.Padding(10); + this.label2.Size = new System.Drawing.Size(734, 56); + this.label2.TabIndex = 1; + this.label2.Text = "Ping is a simple service that lets you see all the sites on the shiftnet/ cluster" + + ". These sites are safe for you to use and do not contain malware or other threat" + + "s."; + // + // fllist + // + this.fllist.Dock = System.Windows.Forms.DockStyle.Fill; + this.fllist.FlowDirection = System.Windows.Forms.FlowDirection.TopDown; + this.fllist.Location = new System.Drawing.Point(0, 89); + this.fllist.Name = "fllist"; + this.fllist.Size = new System.Drawing.Size(734, 389); + this.fllist.TabIndex = 2; + // + // ShiftSoft_Ping + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.fllist); + this.Controls.Add(this.label2); + this.Controls.Add(this.label1); + this.Name = "ShiftSoft_Ping"; + this.Size = new System.Drawing.Size(734, 478); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.FlowLayoutPanel fllist; + } +} diff --git a/ShiftOS.WinForms/ShiftnetSites/ShiftSoft_Ping.cs b/ShiftOS.WinForms/ShiftnetSites/ShiftSoft_Ping.cs new file mode 100644 index 0000000..1c64390 --- /dev/null +++ b/ShiftOS.WinForms/ShiftnetSites/ShiftSoft_Ping.cs @@ -0,0 +1,92 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using System.Reflection; +using System.IO; +using ShiftOS.Engine; +using ShiftOS.WinForms.Tools; + +namespace ShiftOS.WinForms.ShiftnetSites +{ + [ShiftnetSite("shiftnet/shiftsoft/ping", "Ping", "A site listing hosted by ShiftSoft.")] + public partial class ShiftSoft_Ping : UserControl, IShiftnetSite + { + public ShiftSoft_Ping() + { + InitializeComponent(); + } + + public event Action GoBack; + public event Action GoToUrl; + + public void OnLoad() + { + SetupListing(); + } + + public void OnSkinLoad() + { + ControlManager.SetupControls(this); + SetupListing(); + } + + public void SetupListing() + { + foreach(var exec in Directory.GetFiles(Environment.CurrentDirectory)) + { + if(exec.ToLower().EndsWith(".exe") || exec.ToLower().EndsWith(".dll")) + { + try + { + var asm = Assembly.LoadFile(exec); + var types = asm.GetTypes(); + foreach (var type in types) + { + if (type.GetInterfaces().Contains(typeof(IShiftnetSite))) + { + var attr = type.GetCustomAttributes(false).Where(x => x is ShiftnetSiteAttribute) as ShiftnetSiteAttribute; + if (attr != null) + { + var lnk = new LinkLabel(); + lnk.LinkColor = SkinEngine.LoadedSkin.ControlTextColor; + lnk.Tag = "header3"; + lnk.Text = attr.Name; + var desc = new Label(); + desc.AutoSize = true; + lnk.AutoSize = true; + desc.MaximumSize = new Size(this.Width / 3, 0); + desc.Text = attr.Description; + lnk.Click += (o, a) => + { + GoToUrl?.Invoke(attr.Url); + }; + fllist.Controls.Add(lnk); + fllist.Controls.Add(desc); + ControlManager.SetupControls(lnk); + lnk.Show(); + desc.Show(); + } + } + } + } + catch { } + } + } + } + + public void OnUpgrade() + { + } + + public void Setup() + { + SetupListing(); + } + } +} diff --git a/ShiftOS.WinForms/ShiftnetSites/ShiftSoft_Ping.resx b/ShiftOS.WinForms/ShiftnetSites/ShiftSoft_Ping.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/ShiftOS.WinForms/ShiftnetSites/ShiftSoft_Ping.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/ShiftOS.WinForms/Stories/LegionStory.cs b/ShiftOS.WinForms/Stories/LegionStory.cs index 433ad2d..a0fc9bf 100644 --- a/ShiftOS.WinForms/Stories/LegionStory.cs +++ b/ShiftOS.WinForms/Stories/LegionStory.cs @@ -51,6 +51,8 @@ namespace ShiftOS.WinForms.Stories Desktop.InvokeOnWorkerThread(() => { Story.Start("installer"); + while (!Shiftorium.UpgradeInstalled("installer")) + Thread.Sleep(20); AppearanceManager.SetupWindow(installer); installer.InitiateInstall(new ShiftnetInstallation()); }); @@ -64,6 +66,10 @@ namespace ShiftOS.WinForms.Stories WriteLine("There are also lots of companies offering many services."); WriteLine("I'd stay on the shiftnet/ cluster though, others may be dangerous."); WriteLine("I'd also stick to the sites listed on shiftnet/shiftsoft/ping - that site is regularly updated with the most safe Shiftnet sites."); + WriteLine("Oh, that reminds me. I have set you up with ShiftSoft's service provider, Freebie Solutions."); + WriteLine("It's a free provider, but it offers only 256 bytes per second download and upload speeds."); + WriteLine("You may want to go look for another provider when you can afford it."); + WriteLine("Trust me - with this provider, things get slow."); WriteLine("Anyways, it was nice meeting you, hopefully someday you'll give theShell a try."); TerminalBackend.PrefixEnabled = true; -- cgit v1.2.3 From ff47625d2547deed441a853569f9fe84197e23b6 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 29 May 2017 16:08:59 -0400 Subject: fix some clientside save softlocks --- ShiftOS.WinForms/Applications/Terminal.cs | 31 +++++++++++++++++-------------- ShiftOS.WinForms/Oobe.cs | 3 ++- ShiftOS_TheReturn/SaveSystem.cs | 15 ++++++++++++--- 3 files changed, 31 insertions(+), 18 deletions(-) (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.WinForms/Applications/Terminal.cs b/ShiftOS.WinForms/Applications/Terminal.cs index 2d2b4c5..080e8bb 100644 --- a/ShiftOS.WinForms/Applications/Terminal.cs +++ b/ShiftOS.WinForms/Applications/Terminal.cs @@ -313,21 +313,24 @@ namespace ShiftOS.WinForms.Applications } else if (a.KeyCode == Keys.Left) { - var getstring = txt.Lines[txt.Lines.Length - 1]; - var stringlen = getstring.Length + 1; - var header = $"{SaveSystem.CurrentUser.Username}@{SaveSystem.CurrentSave.SystemName}:~$ "; - var headerlen = header.Length + 1; - var selstart = txt.SelectionStart; - var remstrlen = txt.TextLength - stringlen; - var finalnum = selstart - remstrlen; - - if (finalnum != headerlen) + if (SaveSystem.CurrentSave != null) { - AppearanceManager.CurrentPosition--; - } - else - { - a.SuppressKeyPress = true; + var getstring = txt.Lines[txt.Lines.Length - 1]; + var stringlen = getstring.Length + 1; + var header = $"{SaveSystem.CurrentUser.Username}@{SaveSystem.CurrentSave.SystemName}:~$ "; + var headerlen = header.Length + 1; + var selstart = txt.SelectionStart; + var remstrlen = txt.TextLength - stringlen; + var finalnum = selstart - remstrlen; + + if (finalnum != headerlen) + { + AppearanceManager.CurrentPosition--; + } + else + { + a.SuppressKeyPress = true; + } } } else if (a.KeyCode == Keys.Up) diff --git a/ShiftOS.WinForms/Oobe.cs b/ShiftOS.WinForms/Oobe.cs index 9182b4b..96c2bf5 100644 --- a/ShiftOS.WinForms/Oobe.cs +++ b/ShiftOS.WinForms/Oobe.cs @@ -207,14 +207,15 @@ namespace ShiftOS.WinForms ServerMessageReceived smr = null; smr = (msg) => { - ServerManager.MessageReceived -= smr; if (msg.Name == "mud_savefile") { + ServerManager.MessageReceived -= smr; SaveSystem.CurrentSave = JsonConvert.DeserializeObject(msg.Contents); SaveSystem.SaveGame(); } else if(msg.Name=="mud_login_denied") { + ServerManager.MessageReceived -= smr; LinkSaveFile(token); } }; diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index c8996d4..d1b92fd 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -214,13 +214,22 @@ namespace ShiftOS.Engine savehandshake = (msg) => { - ServerManager.MessageReceived -= savehandshake; if (msg.Name == "mud_savefile") { - CurrentSave = JsonConvert.DeserializeObject(msg.Contents); - } + ServerManager.MessageReceived -= savehandshake; + try + { + CurrentSave = JsonConvert.DeserializeObject(msg.Contents); + } + catch + { + Console.WriteLine("[system] [SEVERE] Cannot parse configuration file."); + oobe.PromptForLogin(); + } + } else if (msg.Name == "mud_login_denied") { + ServerManager.MessageReceived -= savehandshake; oobe.PromptForLogin(); } }; -- cgit v1.2.3 From 37ac4c684ce3904c5ec614362ed99bb9867ca0f3 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 29 May 2017 20:08:30 -0400 Subject: It's amazing what talking to Rylan can do to an integer datatype. --- ShiftOS.Objects/EngineShiftnetSubscription.cs | 2 +- ShiftOS.Objects/Save.cs | 4 ++-- ShiftOS.Objects/Shop.cs | 2 +- ShiftOS.Objects/UniteClient.cs | 12 ++++++------ ShiftOS.WinForms/Applications/Pong.cs | 20 ++++++++++---------- ShiftOS.WinForms/Applications/ShiftLetters.cs | 2 +- ShiftOS.WinForms/Applications/ShiftLotto.cs | 4 ++-- ShiftOS.WinForms/Applications/ShiftSweeper.cs | 8 ++++---- ShiftOS.WinForms/Applications/Shifter.cs | 2 +- ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs | 4 ++-- ShiftOS.WinForms/Applications/ShopItemCreator.cs | 4 ++-- ShiftOS.WinForms/HackerCommands.cs | 2 +- ShiftOS.WinForms/JobTasks.cs | 4 ++-- ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs | 4 ++-- ShiftOS.WinForms/WinformsDesktop.cs | 2 +- ShiftOS_TheReturn/Commands.cs | 4 ++-- ShiftOS_TheReturn/SaveSystem.cs | 4 ++-- ShiftOS_TheReturn/Scripting.cs | 4 ++-- ShiftOS_TheReturn/ServerManager.cs | 2 +- ShiftOS_TheReturn/Shiftorium.cs | 10 +++++----- 20 files changed, 50 insertions(+), 50 deletions(-) (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.Objects/EngineShiftnetSubscription.cs b/ShiftOS.Objects/EngineShiftnetSubscription.cs index 1296a98..c319f18 100644 --- a/ShiftOS.Objects/EngineShiftnetSubscription.cs +++ b/ShiftOS.Objects/EngineShiftnetSubscription.cs @@ -10,7 +10,7 @@ namespace ShiftOS.Objects { public string Name { get; set; } public string Description { get; set; } - public int CostPerMonth { get; set; } + public uint CostPerMonth { get; set; } public int DownloadSpeed { get; set; } public string Company { get; set; } } diff --git a/ShiftOS.Objects/Save.cs b/ShiftOS.Objects/Save.cs index 8675a35..0fef7b3 100644 --- a/ShiftOS.Objects/Save.cs +++ b/ShiftOS.Objects/Save.cs @@ -41,9 +41,9 @@ namespace ShiftOS.Objects [Obsolete("This save variable is no longer used in Beta 2.4 and above of ShiftOS. Please use ShiftOS.Engine.SaveSystem.CurrentUser.Username to access the current user's username.")] public string Username { get; set; } - private long _cp = 0; + private ulong _cp = 0; - public long Codepoints + public ulong Codepoints { get { diff --git a/ShiftOS.Objects/Shop.cs b/ShiftOS.Objects/Shop.cs index 65f5746..c603523 100644 --- a/ShiftOS.Objects/Shop.cs +++ b/ShiftOS.Objects/Shop.cs @@ -42,7 +42,7 @@ namespace ShiftOS.Objects { public string Name { get; set; } public string Description { get; set; } - public int Cost { get; set; } + public ulong Cost { get; set; } public int FileType { get; set; } public byte[] MUDFile { get; set; } } diff --git a/ShiftOS.Objects/UniteClient.cs b/ShiftOS.Objects/UniteClient.cs index d8e34b7..ccd721b 100644 --- a/ShiftOS.Objects/UniteClient.cs +++ b/ShiftOS.Objects/UniteClient.cs @@ -83,9 +83,9 @@ namespace ShiftOS.Unite /// Get the Pong codepoint highscore for the current user. /// /// The amount of Codepoints returned by the server - public int GetPongCP() + public ulong GetPongCP() { - return Convert.ToInt32(MakeCall("/API/GetPongCP")); + return Convert.ToUInt64(MakeCall("/API/GetPongCP")); } /// @@ -110,7 +110,7 @@ namespace ShiftOS.Unite /// Set the pong Codepoints record for the user /// /// The amount of Codepoints to set the record to - public void SetPongCP(int value) + public void SetPongCP(ulong value) { MakeCall("/API/SetPongCP/" + value.ToString()); } @@ -182,16 +182,16 @@ namespace ShiftOS.Unite /// Get the user's codepoints. /// /// The amount of codepoints stored on the server for this user. - public long GetCodepoints() + public ulong GetCodepoints() { - return Convert.ToInt64(MakeCall("/API/GetCodepoints")); + return Convert.ToUInt64(MakeCall("/API/GetCodepoints")); } /// /// Set the user's codepoints. /// /// The amount of codepoints to set the user's codepoints value to. - public void SetCodepoints(long value) + public void SetCodepoints(ulong value) { MakeCall("/API/SetCodepoints/" + value.ToString()); } diff --git a/ShiftOS.WinForms/Applications/Pong.cs b/ShiftOS.WinForms/Applications/Pong.cs index 84177b7..6d81c64 100644 --- a/ShiftOS.WinForms/Applications/Pong.cs +++ b/ShiftOS.WinForms/Applications/Pong.cs @@ -58,10 +58,10 @@ namespace ShiftOS.WinForms.Applications double incrementy = 0.2; int levelxspeed = 3; int levelyspeed = 3; - int beatairewardtotal; - int beataireward = 1; - int[] levelrewards = new int[50]; - int totalreward; + ulong beatairewardtotal; + ulong beataireward = 1; + ulong[] levelrewards = new ulong[50]; + ulong totalreward; int countdown = 3; bool aiShouldIsbeEnabled = true; @@ -297,11 +297,11 @@ namespace ShiftOS.WinForms.Applications lblmissedout.Text = Localization.Parse("{YOU_MISSED_OUT_ON}:") + Environment.NewLine + lblstatscodepoints.Text.Replace(Localization.Parse("{CODEPOINTS}: "), "") + Localization.Parse(" {CODEPOINTS}"); if (ShiftoriumFrontend.UpgradeInstalled("pong_upgrade_2")) { - totalreward = levelrewards[level - 1] + beatairewardtotal; + totalreward = (ulong)(levelrewards[level - 1] + beatairewardtotal); double onePercent = (totalreward / 100); lblbutyougained.Show(); lblbutyougained.Text = Localization.Parse("{BUT_YOU_GAINED}:") + Environment.NewLine + onePercent.ToString("") + (Localization.Parse(" {CODEPOINTS}")); - SaveSystem.TransferCodepointsFrom("pong", (totalreward / 100)); + SaveSystem.TransferCodepointsFrom("pong", (ulong)(totalreward / 100)); } else { @@ -715,10 +715,10 @@ namespace ShiftOS.WinForms.Applications { if (ShiftoriumFrontend.UpgradeInstalled("pong_upgrade")) { - beataireward = level * 10; + beataireward = (ulong)(level * 10); } else { - beataireward = level * 5; + beataireward = (ulong)(level * 5); } } else @@ -726,11 +726,11 @@ namespace ShiftOS.WinForms.Applications if (ShiftoriumFrontend.UpgradeInstalled("pong_upgrade")) { double br = levelrewards[level - 1] / 10; - beataireward = (int)Math.Round(br) * 10; + beataireward = (ulong)Math.Round(br) * 10; } else { double br = levelrewards[level - 1] / 10; - beataireward = (int)Math.Round(br) * 5; + beataireward = (ulong)Math.Round(br) * 5; } } diff --git a/ShiftOS.WinForms/Applications/ShiftLetters.cs b/ShiftOS.WinForms/Applications/ShiftLetters.cs index 42e19f8..0e9f74a 100644 --- a/ShiftOS.WinForms/Applications/ShiftLetters.cs +++ b/ShiftOS.WinForms/Applications/ShiftLetters.cs @@ -217,7 +217,7 @@ namespace ShiftOS.WinForms.Applications if (!lblword.Text.Contains("_")) { int oldlives = lives; - int cp = (word.Length * oldlives) * 2; //drunky michael made this 5x... + ulong cp = (ulong)(word.Length * oldlives) * 2; //drunky michael made this 5x... SaveSystem.TransferCodepointsFrom("shiftletters", cp); StartGame(); } diff --git a/ShiftOS.WinForms/Applications/ShiftLotto.cs b/ShiftOS.WinForms/Applications/ShiftLotto.cs index 5ab8154..3f940c7 100644 --- a/ShiftOS.WinForms/Applications/ShiftLotto.cs +++ b/ShiftOS.WinForms/Applications/ShiftLotto.cs @@ -88,7 +88,7 @@ namespace ShiftOS.WinForms.Applications } else { - if (SaveSystem.CurrentSave.Codepoints - (codePoints * difficulty) <= 0) + if (SaveSystem.CurrentSave.Codepoints - (ulong)(codePoints * difficulty) <= 0) { Infobox.Show("Not enough Codepoints", "You do not have enough Codepoints to gamble this amount!"); } @@ -102,7 +102,7 @@ namespace ShiftOS.WinForms.Applications int winningNumber = rnd.Next(0, difficulty); // Multiply CodePoints * Difficulty - int jackpot = codePoints * difficulty; + ulong jackpot = (ulong)(codePoints * difficulty); // Test the random ints if (guessedNumber == winningNumber) diff --git a/ShiftOS.WinForms/Applications/ShiftSweeper.cs b/ShiftOS.WinForms/Applications/ShiftSweeper.cs index f23ed73..772ec26 100644 --- a/ShiftOS.WinForms/Applications/ShiftSweeper.cs +++ b/ShiftOS.WinForms/Applications/ShiftSweeper.cs @@ -300,12 +300,12 @@ namespace ShiftOS.WinForms.Applications { } public void winGame() { - int cp = 0; - int origminecount = gameBombCount * 10; + ulong cp = 0; + ulong origminecount = (ulong)(gameBombCount * 10); if (minetimer < 31) cp = (origminecount * 3); - else if (minetimer < 61) cp = (Int32)(origminecount * 2.5); + else if (minetimer < 61) cp = (ulong)(origminecount * 2.5); else if (minetimer < 91) cp = (origminecount * 2); - else if (minetimer < 121) cp = (Int32)(origminecount * 1.5); + else if (minetimer < 121) cp = (ulong)(origminecount * 1.5); else if (minetimer > 120) cp = (origminecount * 1); SaveSystem.TransferCodepointsFrom("shiftsweeper", cp); panelGameStatus.Image = Properties.Resources.SweeperWinFace; diff --git a/ShiftOS.WinForms/Applications/Shifter.cs b/ShiftOS.WinForms/Applications/Shifter.cs index 1a59c80..3b3a4f1 100644 --- a/ShiftOS.WinForms/Applications/Shifter.cs +++ b/ShiftOS.WinForms/Applications/Shifter.cs @@ -391,7 +391,7 @@ namespace ShiftOS.WinForms.Applications } - public int CodepointValue = 0; + public uint CodepointValue = 0; public List settings = new List(); public Skin LoadedSkin = null; diff --git a/ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs b/ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs index 08e6c8f..d6b014d 100644 --- a/ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs +++ b/ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs @@ -213,9 +213,9 @@ namespace ShiftOS.WinForms.Applications private void btnbuy_Click(object sender, EventArgs e) { - long cpCost = 0; + ulong cpCost = 0; backend.Silent = true; - Dictionary UpgradesToBuy = new Dictionary(); + Dictionary UpgradesToBuy = new Dictionary(); foreach (var itm in lbupgrades.SelectedItems) { cpCost += upgrades[itm.ToString()].Cost; diff --git a/ShiftOS.WinForms/Applications/ShopItemCreator.cs b/ShiftOS.WinForms/Applications/ShopItemCreator.cs index 61e7491..d2836ee 100644 --- a/ShiftOS.WinForms/Applications/ShopItemCreator.cs +++ b/ShiftOS.WinForms/Applications/ShopItemCreator.cs @@ -73,7 +73,7 @@ namespace ShiftOS.WinForms.Applications Infobox.Show("No file chosen.", "Please select a file to sell."); return; } - Item.Cost = Convert.ToInt32(txtcost.Text); + Item.Cost = Convert.ToUInt64(txtcost.Text); Item.Description = txtdescription.Text; Item.Name = txtitemname.Text; Callback?.Invoke(Item); @@ -101,7 +101,7 @@ namespace ShiftOS.WinForms.Applications { try { - Item.Cost = Convert.ToInt32(txtcost.Text); + Item.Cost = Convert.ToUInt64(txtcost.Text); } catch { diff --git a/ShiftOS.WinForms/HackerCommands.cs b/ShiftOS.WinForms/HackerCommands.cs index 47b486d..f467eb2 100644 --- a/ShiftOS.WinForms/HackerCommands.cs +++ b/ShiftOS.WinForms/HackerCommands.cs @@ -504,7 +504,7 @@ namespace ShiftOS.WinForms string usr = args["user"].ToString(); string sys = args["sys"].ToString(); string pass = args["pass"].ToString(); - long amount = (long)args["amount"]; + ulong amount = (ulong)args["amount"]; if(amount < 0) { Console.WriteLine("--invalid codepoint amount - halting..."); diff --git a/ShiftOS.WinForms/JobTasks.cs b/ShiftOS.WinForms/JobTasks.cs index 622e287..d862961 100644 --- a/ShiftOS.WinForms/JobTasks.cs +++ b/ShiftOS.WinForms/JobTasks.cs @@ -35,12 +35,12 @@ namespace ShiftOS.WinForms { public class AcquireCodepointsJobTask : JobTask { - public AcquireCodepointsJobTask(int amount) + public AcquireCodepointsJobTask(uint amount) { CodepointsRequired = SaveSystem.CurrentSave.Codepoints + amount; } - public long CodepointsRequired { get; private set; } + public ulong CodepointsRequired { get; private set; } public override bool IsComplete { diff --git a/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs b/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs index fa575f4..c7830d0 100644 --- a/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs +++ b/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs @@ -372,7 +372,7 @@ namespace ShiftOS.WinForms /// public class AppscapeEntryAttribute : RequiresUpgradeAttribute { - public AppscapeEntryAttribute(string name, string description, int downloadSize, long cost, string dependencies = "", string category = "Misc") : base(name.ToLower().Replace(' ', '_')) + public AppscapeEntryAttribute(string name, string description, int downloadSize, ulong cost, string dependencies = "", string category = "Misc") : base(name.ToLower().Replace(' ', '_')) { Name = name; Description = description; @@ -385,7 +385,7 @@ namespace ShiftOS.WinForms public string Name { get; private set; } public string Description { get; private set; } public string Category { get; private set; } - public long Cost { get; private set; } + public ulong Cost { get; private set; } public string DependencyString { get; private set; } public int DownloadSize { get; private set; } } diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs index 85eab55..95e7c1a 100644 --- a/ShiftOS.WinForms/WinformsDesktop.cs +++ b/ShiftOS.WinForms/WinformsDesktop.cs @@ -192,7 +192,7 @@ namespace ShiftOS.WinForms SetupDesktop(); }; - long lastcp = 0; + ulong lastcp = 0; var storythread = new Thread(() => { diff --git a/ShiftOS_TheReturn/Commands.cs b/ShiftOS_TheReturn/Commands.cs index b97cd1d..ec89539 100644 --- a/ShiftOS_TheReturn/Commands.cs +++ b/ShiftOS_TheReturn/Commands.cs @@ -311,7 +311,7 @@ namespace ShiftOS.Engine if (args.ContainsKey("amount")) try { - long codepointsToAdd = Convert.ToInt64(args["amount"].ToString()); + ulong codepointsToAdd = Convert.ToUInt64(args["amount"].ToString()); SaveSystem.CurrentSave.Codepoints += codepointsToAdd; return true; } @@ -639,7 +639,7 @@ shiftorium.buy{{upgrade:""{upg.ID}""}}"); cat = args["cat"].ToString(); } - Dictionary upgrades = new Dictionary(); + Dictionary upgrades = new Dictionary(); int maxLength = 5; IEnumerable upglist = Shiftorium.GetAvailable(); diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index d1b92fd..395db85 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -480,7 +480,7 @@ namespace ShiftOS.Engine /// Deducts a set amount of Codepoints from the save file... and sends them to a place where they'll never be seen again. /// /// The amount of Codepoints to deduct. - public static void TransferCodepointsToVoid(long amount) + public static void TransferCodepointsToVoid(ulong amount) { if (amount < 0) throw new ArgumentOutOfRangeException("We see what you did there. Trying to pull Codepoints from the void? That won't work."); @@ -584,7 +584,7 @@ namespace ShiftOS.Engine /// /// The character name /// The amount of Codepoints. - public static void TransferCodepointsFrom(string who, long amount) + public static void TransferCodepointsFrom(string who, ulong amount) { if (amount < 0) throw new ArgumentOutOfRangeException("We see what you did there... You can't just give a fake character Codepoints like that. It's better if you transfer them to the void."); diff --git a/ShiftOS_TheReturn/Scripting.cs b/ShiftOS_TheReturn/Scripting.cs index 61c6676..5021f50 100644 --- a/ShiftOS_TheReturn/Scripting.cs +++ b/ShiftOS_TheReturn/Scripting.cs @@ -444,7 +444,7 @@ end"); /// Retrieves the user's Codepoints from the save file. /// /// The user's Codepoints. - public long getCodepoints() { return SaveSystem.CurrentSave.Codepoints; } + public ulong getCodepoints() { return SaveSystem.CurrentSave.Codepoints; } /// /// Run a command in the Terminal. @@ -462,7 +462,7 @@ end"); /// Adds the specified amount of Codepoints to the save flie. /// /// The codepoints to add. - public void addCodepoints(int cp) + public void addCodepoints(uint cp) { if (cp > 100 || cp <= 0) { diff --git a/ShiftOS_TheReturn/ServerManager.cs b/ShiftOS_TheReturn/ServerManager.cs index abb674d..1439c0d 100644 --- a/ShiftOS_TheReturn/ServerManager.cs +++ b/ShiftOS_TheReturn/ServerManager.cs @@ -246,7 +246,7 @@ Ping: {ServerManager.DigitalSocietyPing} ms var args = JsonConvert.DeserializeObject>(msg.Contents); if(args["username"] as string == SaveSystem.CurrentUser.Username) { - SaveSystem.CurrentSave.Codepoints += (long)args["amount"]; + SaveSystem.CurrentSave.Codepoints += (ulong)args["amount"]; Desktop.InvokeOnWorkerThread(new Action(() => { Infobox.Show($"MUD Control Centre", $"Someone bought an item in your shop, and they have paid {args["amount"]}, and as such, you have been granted these Codepoints."); diff --git a/ShiftOS_TheReturn/Shiftorium.cs b/ShiftOS_TheReturn/Shiftorium.cs index bd7105f..975939f 100644 --- a/ShiftOS_TheReturn/Shiftorium.cs +++ b/ShiftOS_TheReturn/Shiftorium.cs @@ -112,7 +112,7 @@ namespace ShiftOS.Engine /// The upgrade ID to buy /// The amount of Codepoints to deduct /// True if the upgrade was installed successfully, false if the user didn't have enough Codepoints or the upgrade wasn' found. - public static bool Buy(string id, long cost) + public static bool Buy(string id, ulong cost) { if (SaveSystem.CurrentSave.Codepoints >= cost) { @@ -365,7 +365,7 @@ namespace ShiftOS.Engine /// /// The upgrade ID to search /// The codepoint value. - public static long GetCPValue(string id) + public static ulong GetCPValue(string id) { foreach (var upg in GetDefaults()) { @@ -520,7 +520,7 @@ namespace ShiftOS.Engine { public string Name { get; set; } public string Description { get; set; } - public long Cost { get; set; } + public ulong Cost { get; set; } public string ID { get { return (this.Id != null ? this.Id : (Name.ToLower().Replace(" ", "_"))); } } public string Id { get; set; } public string Category { get; set; } @@ -536,7 +536,7 @@ namespace ShiftOS.Engine public class ShiftoriumUpgradeAttribute : RequiresUpgradeAttribute { - public ShiftoriumUpgradeAttribute(string name, long cost, string desc, string dependencies, string category) : base(name.ToLower().Replace(" ", "_")) + public ShiftoriumUpgradeAttribute(string name, ulong cost, string desc, string dependencies, string category) : base(name.ToLower().Replace(" ", "_")) { Name = name; Description = desc; @@ -547,7 +547,7 @@ namespace ShiftOS.Engine public string Name { get; private set; } public string Description { get; private set; } - public long Cost { get; private set; } + public ulong Cost { get; private set; } public string Dependencies { get; private set; } public string Category { get; private set; } } -- cgit v1.2.3 From 0ca2fffe7a214fb5cc4c6482ca6fb8d1e4d2c4ea Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 30 May 2017 13:18:08 -0400 Subject: storydev.list command --- ShiftOS.WinForms/HackerCommands.cs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.WinForms/HackerCommands.cs b/ShiftOS.WinForms/HackerCommands.cs index f467eb2..316b7fc 100644 --- a/ShiftOS.WinForms/HackerCommands.cs +++ b/ShiftOS.WinForms/HackerCommands.cs @@ -2,12 +2,14 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; +using System.Reflection; using System.Text; using System.Threading; using System.Threading.Tasks; using Newtonsoft.Json; using ShiftOS.Engine; using ShiftOS.Objects; +using ShiftOS.Objects.ShiftFS; using ShiftOS.WinForms.Applications; using static ShiftOS.Objects.ShiftFS.Utils; @@ -674,6 +676,34 @@ namespace ShiftOS.WinForms return true; } + [Command("list", description ="Lists all story IDs.")] + public static bool ListIds() + { + foreach(var exec in System.IO.Directory.GetFiles(Environment.CurrentDirectory)) + { + if(exec.ToLower().EndsWith(".exe") || exec.ToLower().EndsWith(".dll")) + { + try + { + var asm = Assembly.LoadFile(exec); + { + foreach(var type in asm.GetTypes()) + { + foreach(var method in type.GetMethods(BindingFlags.Public | BindingFlags.Static)) + { + var attr = method.GetCustomAttributes(false).FirstOrDefault(x => x is StoryAttribute); + if (attr != null) + Console.WriteLine(" - " + (attr as StoryAttribute).StoryID); + } + } + } + } + catch { } + } + } + return true; + } + [Command("unexperience", description = "Marks a story plot as not-experienced yet.", usage ="id:string")] [RemoteLock] [RequiresArgument("id")] -- cgit v1.2.3 From 0451b5d15703987b6be1160917ea31d36f6ee125 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 30 May 2017 16:34:31 -0400 Subject: Slight Shiftnet mods, new default skin. --- ShiftOS.WinForms/Applications/Chat.resx | 6 ++ ShiftOS.WinForms/Applications/Shiftnet.cs | 3 + ShiftOS.WinForms/ShiftOS.WinForms.csproj | 9 ++ .../ShiftnetSites/ShiftSoft.Designer.cs | 61 +++++++++++ ShiftOS.WinForms/ShiftnetSites/ShiftSoft.cs | 38 +++++++ ShiftOS.WinForms/ShiftnetSites/ShiftSoft.resx | 120 +++++++++++++++++++++ ShiftOS.WinForms/ShiftnetSites/ShiftSoft_Ping.cs | 51 +++++---- ShiftOS_TheReturn/Skinning.cs | 12 +-- 8 files changed, 271 insertions(+), 29 deletions(-) create mode 100644 ShiftOS.WinForms/ShiftnetSites/ShiftSoft.Designer.cs create mode 100644 ShiftOS.WinForms/ShiftnetSites/ShiftSoft.cs create mode 100644 ShiftOS.WinForms/ShiftnetSites/ShiftSoft.resx (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.WinForms/Applications/Chat.resx b/ShiftOS.WinForms/Applications/Chat.resx index a7b2b93..e4a35ad 100644 --- a/ShiftOS.WinForms/Applications/Chat.resx +++ b/ShiftOS.WinForms/Applications/Chat.resx @@ -123,6 +123,12 @@ 122, 17 + + 17, 17 + + + 122, 17 + diff --git a/ShiftOS.WinForms/Applications/Shiftnet.cs b/ShiftOS.WinForms/Applications/Shiftnet.cs index 7f5d3c1..22b53a0 100644 --- a/ShiftOS.WinForms/Applications/Shiftnet.cs +++ b/ShiftOS.WinForms/Applications/Shiftnet.cs @@ -80,6 +80,7 @@ namespace ShiftOS.WinForms.Applications txturl.Location = new Point(btnforward.Left + btnforward.Width + 2, 2); txturl.Width = flcontrols.Width - btnback.Width - 2 - btnforward.Width - 2 - (btngo.Width*2) - 2; btngo.Location = new Point(flcontrols.Width - btngo.Width - 2, 2); + flcontrols.BackColor = SkinEngine.LoadedSkin.TitleBackgroundColor; } public bool OnUnload() @@ -147,6 +148,7 @@ namespace ShiftOS.WinForms.Applications public void NavigateToUrl(string url) { + txturl.Text = url; foreach(var exe in Directory.GetFiles(Environment.CurrentDirectory)) { @@ -188,6 +190,7 @@ namespace ShiftOS.WinForms.Applications obj.OnUpgrade(); obj.OnSkinLoad(); obj.Setup(); + AppearanceManager.SetWindowTitle(this, attribute.Name + " - Shiftnet"); return; } } diff --git a/ShiftOS.WinForms/ShiftOS.WinForms.csproj b/ShiftOS.WinForms/ShiftOS.WinForms.csproj index 22bd1d2..65a512e 100644 --- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj +++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj @@ -388,6 +388,12 @@ ShiftGames.cs + + UserControl + + + ShiftSoft.cs + UserControl @@ -589,6 +595,9 @@ ShiftGames.cs + + ShiftSoft.cs + ShiftSoft_Ping.cs diff --git a/ShiftOS.WinForms/ShiftnetSites/ShiftSoft.Designer.cs b/ShiftOS.WinForms/ShiftnetSites/ShiftSoft.Designer.cs new file mode 100644 index 0000000..a62b5a8 --- /dev/null +++ b/ShiftOS.WinForms/ShiftnetSites/ShiftSoft.Designer.cs @@ -0,0 +1,61 @@ +namespace ShiftOS.WinForms.ShiftnetSites +{ + partial class ShiftSoft + { + /// + /// 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.label1 = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Font = new System.Drawing.Font("Franklin Gothic Heavy", 24.75F, System.Drawing.FontStyle.Italic); + this.label1.Location = new System.Drawing.Point(13, 17); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(152, 38); + this.label1.TabIndex = 0; + this.label1.Tag = "keepfont"; + this.label1.Text = "Shiftsoft"; + // + // ShiftSoft + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.label1); + this.Name = "ShiftSoft"; + this.Size = new System.Drawing.Size(523, 384); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label label1; + } +} diff --git a/ShiftOS.WinForms/ShiftnetSites/ShiftSoft.cs b/ShiftOS.WinForms/ShiftnetSites/ShiftSoft.cs new file mode 100644 index 0000000..18968cd --- /dev/null +++ b/ShiftOS.WinForms/ShiftnetSites/ShiftSoft.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using ShiftOS.Engine; + +namespace ShiftOS.WinForms.ShiftnetSites +{ + [ShiftnetSite("shiftnet/shiftsoft", "ShiftSoft", "What do you want to shift today?")] + [ShiftnetFundamental] + public partial class ShiftSoft : UserControl, IShiftnetSite + { + public ShiftSoft() + { + InitializeComponent(); + } + + public event Action GoBack; + public event Action GoToUrl; + + public void OnSkinLoad() + { + } + + public void OnUpgrade() + { + } + + public void Setup() + { + } + } +} diff --git a/ShiftOS.WinForms/ShiftnetSites/ShiftSoft.resx b/ShiftOS.WinForms/ShiftnetSites/ShiftSoft.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/ShiftOS.WinForms/ShiftnetSites/ShiftSoft.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/ShiftOS.WinForms/ShiftnetSites/ShiftSoft_Ping.cs b/ShiftOS.WinForms/ShiftnetSites/ShiftSoft_Ping.cs index 1c64390..1593117 100644 --- a/ShiftOS.WinForms/ShiftnetSites/ShiftSoft_Ping.cs +++ b/ShiftOS.WinForms/ShiftnetSites/ShiftSoft_Ping.cs @@ -25,11 +25,6 @@ namespace ShiftOS.WinForms.ShiftnetSites public event Action GoBack; public event Action GoToUrl; - public void OnLoad() - { - SetupListing(); - } - public void OnSkinLoad() { ControlManager.SetupControls(this); @@ -38,6 +33,7 @@ namespace ShiftOS.WinForms.ShiftnetSites public void SetupListing() { + fllist.Controls.Clear(); foreach(var exec in Directory.GetFiles(Environment.CurrentDirectory)) { if(exec.ToLower().EndsWith(".exe") || exec.ToLower().EndsWith(".dll")) @@ -50,27 +46,36 @@ namespace ShiftOS.WinForms.ShiftnetSites { if (type.GetInterfaces().Contains(typeof(IShiftnetSite))) { - var attr = type.GetCustomAttributes(false).Where(x => x is ShiftnetSiteAttribute) as ShiftnetSiteAttribute; + var attr = type.GetCustomAttributes(false).FirstOrDefault(x => x is ShiftnetSiteAttribute) as ShiftnetSiteAttribute; if (attr != null) { - var lnk = new LinkLabel(); - lnk.LinkColor = SkinEngine.LoadedSkin.ControlTextColor; - lnk.Tag = "header3"; - lnk.Text = attr.Name; - var desc = new Label(); - desc.AutoSize = true; - lnk.AutoSize = true; - desc.MaximumSize = new Size(this.Width / 3, 0); - desc.Text = attr.Description; - lnk.Click += (o, a) => + if (attr.Url.StartsWith("shiftnet/")) { - GoToUrl?.Invoke(attr.Url); - }; - fllist.Controls.Add(lnk); - fllist.Controls.Add(desc); - ControlManager.SetupControls(lnk); - lnk.Show(); - desc.Show(); + var lnk = new LinkLabel(); + lnk.LinkColor = SkinEngine.LoadedSkin.ControlTextColor; + lnk.Text = attr.Name; + var desc = new Label(); + desc.AutoSize = true; + lnk.AutoSize = true; + desc.MaximumSize = new Size(this.Width / 3, 0); + desc.Text = attr.Description; + desc.Padding = new Padding + { + Bottom = 25, + Top = 0, + Left = 10, + Right = 10 + }; + lnk.Click += (o, a) => + { + GoToUrl?.Invoke(attr.Url); + }; + fllist.Controls.Add(lnk); + fllist.Controls.Add(desc); + ControlManager.SetupControls(lnk); + lnk.Show(); + desc.Show(); + } } } } diff --git a/ShiftOS_TheReturn/Skinning.cs b/ShiftOS_TheReturn/Skinning.cs index f5dd211..5bd4ab1 100644 --- a/ShiftOS_TheReturn/Skinning.cs +++ b/ShiftOS_TheReturn/Skinning.cs @@ -332,18 +332,18 @@ namespace ShiftOS.Engine public class Skin { //borrowing from the discourse theme for the default skin - private static readonly Color DefaultBackground = Color.FromArgb(0, 0x44, 0x00); + private static readonly Color DefaultBackground = Color.FromArgb(0x11, 0x11, 0x11); private static readonly Color DefaultForeground = Color.FromArgb(0xDD, 0xDD, 0xDD); private static readonly Color Accent1 = Color.FromArgb(0x66, 0x66, 0x66); private static readonly Color Accent2 = Color.FromArgb(0x80, 0, 0); - private static readonly Color DesktopBG = Color.FromArgb(0x22, 0x22, 0x22); + private static readonly Color DesktopBG = Color.FromArgb(0x00, 0x00, 0x00); private static readonly Font SysFont = new Font("Tahoma", 9F); private static readonly Font SysFont2 = new Font("Tahoma", 10F, FontStyle.Bold); - private static readonly Font Header1 = new Font("Helvetica", 20F, FontStyle.Bold); - private static readonly Font Header2 = new Font("Helvetica", 17.5F, FontStyle.Bold); - private static readonly Font Header3 = new Font("Tahoma", 15F, FontStyle.Bold); + private static readonly Font Header1 = new Font("Courier New", 20F, FontStyle.Bold); + private static readonly Font Header2 = new Font("Courier New", 17.5F, FontStyle.Bold); + private static readonly Font Header3 = new Font("Courier New", 15F, FontStyle.Bold); - private static readonly Color TitleBG = Color.FromArgb(0x11, 0x11, 0x11); + private static readonly Color TitleBG = Color.FromArgb(0x55, 0x11, 0x11); private static readonly Color TitleFG = Color.FromArgb(0xaa, 0xaa, 0xaa); //Todo: When making Shifter GUI we need to label all these with proper Shifter attributes to get 'em displaying in the right places. -- cgit v1.2.3 From ecf5297dbb9fd551005963dc1d430ed348848390 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 30 May 2017 21:50:19 -0400 Subject: slightly fix balloon notes --- ShiftOS.WinForms/WinformsDesktop.cs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs index 95e7c1a..76c5050 100644 --- a/ShiftOS.WinForms/WinformsDesktop.cs +++ b/ShiftOS.WinForms/WinformsDesktop.cs @@ -47,8 +47,24 @@ namespace ShiftOS.WinForms /// /// Winforms desktop. /// + [Namespace("desktop")] public partial class WinformsDesktop : Form, IDesktop { + [Command("pushnote")] + [RequiresArgument("target")] + [RequiresArgument("title")] + [RequiresArgument("body")] + public static bool PushNote(Dictionary args) + { + string ta = args["target"].ToString(); + string ti = args["title"].ToString(); + string bo = args["body"].ToString(); + + Desktop.PushNotification(ta, ti, bo); + + return true; + } + public List Widgets = new List(); @@ -64,7 +80,7 @@ namespace ShiftOS.WinForms pnlnotificationbox.Left = desktoppanel.Width - pnlnotificationbox.Width; else { - int left = ctl.PointToScreen(ctl.Location).X; + int left = ctl.Parent.PointToScreen(ctl.Location).X; int realleft = left - pnlnotificationbox.Width; realleft += ctl.Width; pnlnotificationbox.Left = realleft; @@ -75,6 +91,7 @@ namespace ShiftOS.WinForms pnlnotificationbox.Top = desktoppanel.Height; else pnlnotificationbox.Top = this.Height - desktoppanel.Height - pnlnotificationbox.Height; + ControlManager.SetupControls(pnlnotificationbox); var notekiller = new System.Windows.Forms.Timer(); notekiller.Interval = 10000; notekiller.Tick += (o, a) => @@ -83,6 +100,7 @@ namespace ShiftOS.WinForms }; Engine.AudioManager.PlayStream(Properties.Resources.infobox); pnlnotificationbox.Show(); + pnlnotificationbox.BringToFront(); notekiller.Start(); } -- cgit v1.2.3 From 3dd402277bba874f24fab11865d257133c6f782c Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 31 May 2017 08:40:29 -0400 Subject: Fix sizing issue with notifications, and UP key in terminal --- ShiftOS.WinForms/Applications/Terminal.cs | 1 + ShiftOS.WinForms/WinformsDesktop.cs | 7 +++++++ 2 files changed, 8 insertions(+) (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.WinForms/Applications/Terminal.cs b/ShiftOS.WinForms/Applications/Terminal.cs index 080e8bb..a4b77ae 100644 --- a/ShiftOS.WinForms/Applications/Terminal.cs +++ b/ShiftOS.WinForms/Applications/Terminal.cs @@ -338,6 +338,7 @@ namespace ShiftOS.WinForms.Applications var tostring3 = txt.Lines[txt.Lines.Length - 1]; if (tostring3 == $"{SaveSystem.CurrentUser.Username}@{SaveSystem.CurrentSave.SystemName}:~$ ") Console.Write(TerminalBackend.LastCommand); + ConsoleEx.OnFlush?.Invoke(); a.SuppressKeyPress = true; } diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs index 76c5050..643c02a 100644 --- a/ShiftOS.WinForms/WinformsDesktop.cs +++ b/ShiftOS.WinForms/WinformsDesktop.cs @@ -74,6 +74,10 @@ namespace ShiftOS.WinForms { lbnotemsg.Text = msg; lbnotetitle.Text = title; + int height = pnlnotificationbox.Height; + pnlnotificationbox.AutoSize = false; + pnlnotificationbox.Height = height; + pnlnotificationbox.Width = lbnotetitle.Width; var ctl = flnotifications.Controls.ToList().FirstOrDefault(x => x.Tag.ToString() == app); if (ctl == null) @@ -97,8 +101,11 @@ namespace ShiftOS.WinForms notekiller.Tick += (o, a) => { pnlnotificationbox.Hide(); + pnlnotificationbox.AutoSize = true; }; Engine.AudioManager.PlayStream(Properties.Resources.infobox); + + pnlnotificationbox.Show(); pnlnotificationbox.BringToFront(); notekiller.Start(); -- cgit v1.2.3 From c63117276194d18890f14c75b8864749fbd33a0e Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 31 May 2017 09:03:19 -0400 Subject: modular notifications --- ShiftOS.WinForms/WinformsDesktop.cs | 44 +++++++++++++++++++++++++++++++++ ShiftOS_TheReturn/IStatusIcon.cs | 14 +++++++++++ ShiftOS_TheReturn/NotificationDaemon.cs | 30 ++++++++++++++++++++++ ShiftOS_TheReturn/ShiftOS.Engine.csproj | 1 + 4 files changed, 89 insertions(+) create mode 100644 ShiftOS_TheReturn/IStatusIcon.cs (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs index 643c02a..0cfd667 100644 --- a/ShiftOS.WinForms/WinformsDesktop.cs +++ b/ShiftOS.WinForms/WinformsDesktop.cs @@ -70,6 +70,46 @@ namespace ShiftOS.WinForms private int millisecondsUntilScreensaver = 300000; + public void LoadIcons() + { + //That shot me back to 0.0.x with that name. Whatever. + flnotifications.Controls.Clear(); //Clear the status tray + + foreach(var itype in NotificationDaemon.GetAllStatusIcons()) + { + //We have the types. No need for shiftorium calls or anything. + //First create the icon control... + + var ic = new PictureBox(); + //We can use the type name, in lowercase, for the icon tag. + ic.Tag = itype.Name.ToLower(); + //Next get the icon data if any. + + var iconattrib = itype.GetCustomAttributes(false).FirstOrDefault(x => x is DefaultIconAttribute) as DefaultIconAttribute; + if(iconattrib != null) + { + //We can use this attribute's ID in the skin engine to get an icon. + var img = GetIcon(iconattrib.ID); + //Make it transparent. + (img as Bitmap).MakeTransparent(LoadedSkin.SystemKey); + //Assign it to the control + ic.Image = img; + //Set the sizing mode + ic.SizeMode = PictureBoxSizeMode.StretchImage; + } + else + { + ic.BackColor = Color.White; //TODO: Make it skinnable. + } + ic.Size = new Size(20, 20); //TODO: make it skinnable + //add to the notification tray + flnotifications.Controls.Add(ic); + ic.Show(); + + //TODO: Settings pane on click. + } + } + public void PushNotification(string app, string title, string msg) { lbnotemsg.Text = msg; @@ -134,6 +174,8 @@ namespace ShiftOS.WinForms widget.OnUpgrade(); } + LoadIcons(); + //Only if the DevX Legions story hasn't been experienced yet. if (!Shiftorium.UpgradeInstalled("devx_legions")) { @@ -180,6 +222,7 @@ namespace ShiftOS.WinForms SaveSystem.GameReady += () => { + this.Invoke(new Action(LoadIcons)); if (this.Visible == true) this.Invoke(new Action(() => SetupDesktop())); }; @@ -208,6 +251,7 @@ namespace ShiftOS.WinForms }; SkinEngine.SkinLoaded += () => { + LoadIcons(); foreach (var widget in Widgets) { widget.OnSkinLoad(); diff --git a/ShiftOS_TheReturn/IStatusIcon.cs b/ShiftOS_TheReturn/IStatusIcon.cs new file mode 100644 index 0000000..f32d1c1 --- /dev/null +++ b/ShiftOS_TheReturn/IStatusIcon.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ShiftOS.Engine +{ + public interface IStatusIcon + { + void Setup(); + + } +} diff --git a/ShiftOS_TheReturn/NotificationDaemon.cs b/ShiftOS_TheReturn/NotificationDaemon.cs index a90510a..0725782 100644 --- a/ShiftOS_TheReturn/NotificationDaemon.cs +++ b/ShiftOS_TheReturn/NotificationDaemon.cs @@ -25,6 +25,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Reflection; using System.Text; using System.Threading.Tasks; using Newtonsoft.Json; @@ -34,6 +35,35 @@ namespace ShiftOS.Engine { public static class NotificationDaemon { + /// + /// Gets a list of all objects that meet their Shiftorium dependencies. + /// + /// An array of s containing the found objects. + public static Type[] GetAllStatusIcons() + { + List lst = new List(); + foreach(var exec in System.IO.Directory.GetFiles(Environment.CurrentDirectory)) + { + if(exec.ToLower().EndsWith(".exe") || exec.ToLower().EndsWith(".dll")) + { + try + { + var asm = Assembly.LoadFile(exec); + foreach(var type in asm.GetTypes().Where(x => x.GetInterfaces().Contains(typeof(IStatusIcon)))) + { + if (Shiftorium.UpgradeAttributesUnlocked(type)) + { + lst.Add(type); + } + } + } + catch { } + } + } + return lst.ToArray(); + } + + //if the notifications file already exists then get them public static Notification[] GetAllFromFile() { diff --git a/ShiftOS_TheReturn/ShiftOS.Engine.csproj b/ShiftOS_TheReturn/ShiftOS.Engine.csproj index 4cbce72..f70c41e 100644 --- a/ShiftOS_TheReturn/ShiftOS.Engine.csproj +++ b/ShiftOS_TheReturn/ShiftOS.Engine.csproj @@ -109,6 +109,7 @@ + -- cgit v1.2.3 From b0da30bbde2bb198850ea45dc0006762b23f99a3 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 31 May 2017 09:14:27 -0400 Subject: COMPLETELY WORKING notification system! --- ShiftOS.WinForms/WinformsDesktop.cs | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs index 0cfd667..b9c4f37 100644 --- a/ShiftOS.WinForms/WinformsDesktop.cs +++ b/ShiftOS.WinForms/WinformsDesktop.cs @@ -106,7 +106,32 @@ namespace ShiftOS.WinForms flnotifications.Controls.Add(ic); ic.Show(); - //TODO: Settings pane on click. + ic.Click += (o, a) => + { + HideAppLauncher(); + + if(itype.BaseType == typeof(UserControl)) + { + UserControl ctrl = (UserControl)Activator.CreateInstance(itype); + (ctrl as IStatusIcon).Setup(); + currentSettingsPane = ctrl; + if(LoadedSkin.DesktopPanelPosition == 0) + { + ctrl.Top = desktoppanel.Height; + } + else + { + ctrl.Top = this.Height - desktoppanel.Height - ctrl.Height; + } + int noteleft = flnotifications.PointToScreen(ic.Location).X; + int realleft = (this.Width - (noteleft + ic.Width)) - ctrl.Width; + ctrl.Left = realleft; + ControlManager.SetupControls(ctrl); + ctrl.Show(); + } + + + }; } } @@ -151,6 +176,8 @@ namespace ShiftOS.WinForms notekiller.Start(); } + private UserControl currentSettingsPane = null; + /// /// Initializes a new instance of the class. /// @@ -1101,6 +1128,8 @@ namespace ShiftOS.WinForms { this.Invoke(new Action(() => { + currentSettingsPane?.Hide(); + currentSettingsPane = null; pnladvancedal.Hide(); })); } -- cgit v1.2.3 From 324104eb0b8650969b2205404e3ad83401fb100e Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 31 May 2017 19:23:40 -0400 Subject: volume control slider and other goodies --- ShiftOS.WinForms/Controls/ShiftedProgressBar.cs | 88 ++++++++------- ShiftOS.WinForms/Properties/Resources.Designer.cs | 16 ++- ShiftOS.WinForms/Properties/Resources.resx | 3 + ShiftOS.WinForms/Resources/iconSpeaker.bmp | Bin 0 -> 3382 bytes ShiftOS.WinForms/ShiftOS.WinForms.csproj | 19 ++++ .../StatusIcons/ShiftnetStatus.Designer.cs | 90 ++++++++++++++++ ShiftOS.WinForms/StatusIcons/ShiftnetStatus.cs | 33 ++++++ ShiftOS.WinForms/StatusIcons/ShiftnetStatus.resx | 120 +++++++++++++++++++++ ShiftOS.WinForms/StatusIcons/Volume.Designer.cs | 59 ++++++++++ ShiftOS.WinForms/StatusIcons/Volume.cs | 67 ++++++++++++ ShiftOS.WinForms/StatusIcons/Volume.resx | 120 +++++++++++++++++++++ ShiftOS.WinForms/Tools/ControlManager.cs | 15 ++- ShiftOS.WinForms/WinformsDesktop.Designer.cs | 29 ++--- ShiftOS.WinForms/WinformsDesktop.cs | 32 +++--- ShiftOS.WinForms/WinformsDesktop.resx | 3 - 15 files changed, 617 insertions(+), 77 deletions(-) create mode 100644 ShiftOS.WinForms/Resources/iconSpeaker.bmp create mode 100644 ShiftOS.WinForms/StatusIcons/ShiftnetStatus.Designer.cs create mode 100644 ShiftOS.WinForms/StatusIcons/ShiftnetStatus.cs create mode 100644 ShiftOS.WinForms/StatusIcons/ShiftnetStatus.resx create mode 100644 ShiftOS.WinForms/StatusIcons/Volume.Designer.cs create mode 100644 ShiftOS.WinForms/StatusIcons/Volume.cs create mode 100644 ShiftOS.WinForms/StatusIcons/Volume.resx (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.WinForms/Controls/ShiftedProgressBar.cs b/ShiftOS.WinForms/Controls/ShiftedProgressBar.cs index ceaff02..c5a6d05 100644 --- a/ShiftOS.WinForms/Controls/ShiftedProgressBar.cs +++ b/ShiftOS.WinForms/Controls/ShiftedProgressBar.cs @@ -140,51 +140,65 @@ namespace ShiftOS.WinForms.Controls protected override void OnPaint(PaintEventArgs pe) { - pe.Graphics.Clear(this.RealBackColor); - if(RealBackgroundImage != null) + try { - pe.Graphics.FillRectangle(new TextureBrush(RealBackgroundImage), new Rectangle(0, 0, this.Width, this.Height)); - } - switch (Style) - { - case ProgressBarStyle.Continuous: - double width = linear(this.Value, 0, this.Maximum, 0, this.Width); - if (ProgressImage != null) - { - pe.Graphics.FillRectangle(new TextureBrush(ProgressImage), new RectangleF(0, 0, (float)width, this.Height)); - } - else - { - pe.Graphics.FillRectangle(new SolidBrush(ProgressColor), new RectangleF(0, 0, (float)width, this.Height)); - } - break; - case ProgressBarStyle.Blocks: - int block_count = this.Width / (this.BlockSize + 2); - int blocks = (int)linear(this.Value, 0, this.Maximum, 0, block_count); - for(int i = 0; i < blocks - 1; i++) - { - int position = i * (BlockSize + 2); + pe.Graphics.Clear(this.RealBackColor); + if (RealBackgroundImage != null) + { + pe.Graphics.FillRectangle(new TextureBrush(RealBackgroundImage), new Rectangle(0, 0, this.Width, this.Height)); + } + switch (Style) + { + case ProgressBarStyle.Continuous: + double width = linear(this.Value, 0, this.Maximum, 0, this.Width); if (ProgressImage != null) { - pe.Graphics.FillRectangle(new TextureBrush(ProgressImage), new Rectangle(position, 0, BlockSize, this.Height)); + pe.Graphics.FillRectangle(new TextureBrush(ProgressImage), new RectangleF(0, 0, (float)width, this.Height)); + } + else + { + pe.Graphics.FillRectangle(new SolidBrush(ProgressColor), new RectangleF(0, 0, (float)width, this.Height)); + } + break; + case ProgressBarStyle.Blocks: + int block_count = this.Width / (this.BlockSize + 2); + int blocks = (int)linear(this.Value, 0, this.Maximum, 0, block_count); + for (int i = 0; i < blocks - 1; i++) + { + int position = i * (BlockSize + 2); + if (ProgressImage != null) + { + pe.Graphics.FillRectangle(new TextureBrush(ProgressImage), new Rectangle(position, 0, BlockSize, this.Height)); + } + else + { + pe.Graphics.FillRectangle(new SolidBrush(ProgressColor), new Rectangle(position, 0, BlockSize, this.Height)); + } + } + break; + case ProgressBarStyle.Marquee: + if (ProgressImage != null) + { + pe.Graphics.FillRectangle(new TextureBrush(ProgressImage), new Rectangle(_marqueePos, 0, this.Width / 4, this.Height)); } else { - pe.Graphics.FillRectangle(new SolidBrush(ProgressColor), new Rectangle(position, 0, BlockSize, this.Height)); + pe.Graphics.FillRectangle(new SolidBrush(ProgressColor), new Rectangle(_marqueePos, 0, this.Width / 4, this.Height)); } - } - break; - case ProgressBarStyle.Marquee: - if (ProgressImage != null) - { - pe.Graphics.FillRectangle(new TextureBrush(ProgressImage), new Rectangle(_marqueePos, 0, this.Width / 4, this.Height)); - } - else - { - pe.Graphics.FillRectangle(new SolidBrush(ProgressColor), new Rectangle(_marqueePos, 0, this.Width / 4, this.Height)); - } - break; + break; + } + } + catch + { + pe.Graphics.Clear(Color.Black); + string text = "Preview mode. This control can't be drawn without an initiated ShiftOS engine."; + SizeF sz = pe.Graphics.MeasureString(text, this.Font); + PointF loc = new PointF( + (this.Width - sz.Width) / 2, + (this.Height - sz.Height) / 2 + ); + pe.Graphics.DrawString(text, Font, new SolidBrush(Color.White), loc); } } diff --git a/ShiftOS.WinForms/Properties/Resources.Designer.cs b/ShiftOS.WinForms/Properties/Resources.Designer.cs index 3e83c3f..0386237 100644 --- a/ShiftOS.WinForms/Properties/Resources.Designer.cs +++ b/ShiftOS.WinForms/Properties/Resources.Designer.cs @@ -947,6 +947,16 @@ namespace ShiftOS.WinForms.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap iconSpeaker { + get { + object obj = ResourceManager.GetObject("iconSpeaker", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// @@ -1103,9 +1113,9 @@ namespace ShiftOS.WinForms.Properties { /// Category: "Enhancements", /// }, /// { - /// Name: "GUI Based Login Screen", - /// Cost: 500, - /// Description: "Tired of using the text-based login screen in ShiftOS? Well, we have a functioning window manager, and a functioning desktop, w [rest of string was truncated]";. + /// Name: "Shift Progress Bar", + /// Cost: 150, + /// Description: "Want to customize the look of all ShiftOS Progress Bars? Buy this upgrade today and you'll get the ability to set the foreground an [rest of string was truncated]";. /// internal static string Shiftorium { get { diff --git a/ShiftOS.WinForms/Properties/Resources.resx b/ShiftOS.WinForms/Properties/Resources.resx index 1db7a46..d1a3544 100644 --- a/ShiftOS.WinForms/Properties/Resources.resx +++ b/ShiftOS.WinForms/Properties/Resources.resx @@ -34603,4 +34603,7 @@ ..\Resources\notestate_connection_full.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\iconSpeaker.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/ShiftOS.WinForms/Resources/iconSpeaker.bmp b/ShiftOS.WinForms/Resources/iconSpeaker.bmp new file mode 100644 index 0000000..ec2defb Binary files /dev/null and b/ShiftOS.WinForms/Resources/iconSpeaker.bmp differ diff --git a/ShiftOS.WinForms/ShiftOS.WinForms.csproj b/ShiftOS.WinForms/ShiftOS.WinForms.csproj index 65a512e..fd875e9 100644 --- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj +++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj @@ -403,6 +403,18 @@ + + UserControl + + + ShiftnetStatus.cs + + + UserControl + + + Volume.cs + @@ -601,6 +613,12 @@ ShiftSoft_Ping.cs + + ShiftnetStatus.cs + + + Volume.cs + UniteLoginDialog.cs @@ -827,6 +845,7 @@ + diff --git a/ShiftOS.WinForms/StatusIcons/ShiftnetStatus.Designer.cs b/ShiftOS.WinForms/StatusIcons/ShiftnetStatus.Designer.cs new file mode 100644 index 0000000..65aed28 --- /dev/null +++ b/ShiftOS.WinForms/StatusIcons/ShiftnetStatus.Designer.cs @@ -0,0 +1,90 @@ +namespace ShiftOS.WinForms.StatusIcons +{ + partial class ShiftnetStatus + { + /// + /// 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.label1 = new System.Windows.Forms.Label(); + this.lbserviceprovider = new System.Windows.Forms.Label(); + this.lbstatus = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Dock = System.Windows.Forms.DockStyle.Top; + this.label1.Location = new System.Drawing.Point(0, 0); + this.label1.Name = "label1"; + this.label1.Padding = new System.Windows.Forms.Padding(5); + this.label1.Size = new System.Drawing.Size(53, 23); + this.label1.TabIndex = 0; + this.label1.Tag = "header2"; + this.label1.Text = "Shiftnet"; + // + // lbserviceprovider + // + this.lbserviceprovider.AutoSize = true; + this.lbserviceprovider.Dock = System.Windows.Forms.DockStyle.Top; + this.lbserviceprovider.Location = new System.Drawing.Point(0, 23); + this.lbserviceprovider.Name = "lbserviceprovider"; + this.lbserviceprovider.Padding = new System.Windows.Forms.Padding(5); + this.lbserviceprovider.Size = new System.Drawing.Size(98, 23); + this.lbserviceprovider.TabIndex = 1; + this.lbserviceprovider.Tag = "header3"; + this.lbserviceprovider.Text = "Freebie Solutions"; + // + // lbstatus + // + this.lbstatus.Dock = System.Windows.Forms.DockStyle.Fill; + this.lbstatus.Location = new System.Drawing.Point(0, 46); + this.lbstatus.Name = "lbstatus"; + this.lbstatus.Padding = new System.Windows.Forms.Padding(5); + this.lbstatus.Size = new System.Drawing.Size(331, 144); + this.lbstatus.TabIndex = 2; + this.lbstatus.Text = "This will show the Shiftnet status."; + // + // ShiftnetStatus + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.lbstatus); + this.Controls.Add(this.lbserviceprovider); + this.Controls.Add(this.label1); + this.Name = "ShiftnetStatus"; + this.Size = new System.Drawing.Size(331, 190); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label lbserviceprovider; + private System.Windows.Forms.Label lbstatus; + } +} diff --git a/ShiftOS.WinForms/StatusIcons/ShiftnetStatus.cs b/ShiftOS.WinForms/StatusIcons/ShiftnetStatus.cs new file mode 100644 index 0000000..f1d31af --- /dev/null +++ b/ShiftOS.WinForms/StatusIcons/ShiftnetStatus.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using ShiftOS.Engine; + +namespace ShiftOS.WinForms.StatusIcons +{ + [DefaultIcon("iconShiftnet")] + [RequiresUpgrade("victortran_shiftnet")] + public partial class ShiftnetStatus : UserControl, IStatusIcon + { + public ShiftnetStatus() + { + InitializeComponent(); + } + + public void Setup() + { + var subscription = Applications.DownloadManager.GetAllSubscriptions()[SaveSystem.CurrentSave.ShiftnetSubscription]; + float kilobytes = (float)subscription.DownloadSpeed / 1024F; + lbserviceprovider.Text = subscription.Name; + lbstatus.Text = $@"Company: {subscription.Company} +Download speed (KB/s): {kilobytes}"; + + } + } +} diff --git a/ShiftOS.WinForms/StatusIcons/ShiftnetStatus.resx b/ShiftOS.WinForms/StatusIcons/ShiftnetStatus.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/ShiftOS.WinForms/StatusIcons/ShiftnetStatus.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/ShiftOS.WinForms/StatusIcons/Volume.Designer.cs b/ShiftOS.WinForms/StatusIcons/Volume.Designer.cs new file mode 100644 index 0000000..aa8aa7a --- /dev/null +++ b/ShiftOS.WinForms/StatusIcons/Volume.Designer.cs @@ -0,0 +1,59 @@ +namespace ShiftOS.WinForms.StatusIcons +{ + partial class Volume + { + /// + /// 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.lbvolume = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // lbvolume + // + this.lbvolume.AutoSize = true; + this.lbvolume.Location = new System.Drawing.Point(4, 4); + this.lbvolume.Name = "lbvolume"; + this.lbvolume.Size = new System.Drawing.Size(81, 13); + this.lbvolume.TabIndex = 0; + this.lbvolume.Text = "System volume:"; + // + // Volume + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.lbvolume); + this.Name = "Volume"; + this.Size = new System.Drawing.Size(444, 44); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label lbvolume; + } +} diff --git a/ShiftOS.WinForms/StatusIcons/Volume.cs b/ShiftOS.WinForms/StatusIcons/Volume.cs new file mode 100644 index 0000000..329faf0 --- /dev/null +++ b/ShiftOS.WinForms/StatusIcons/Volume.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using ShiftOS.Engine; +using ShiftOS.WinForms.Controls; + +namespace ShiftOS.WinForms.StatusIcons +{ + [DefaultIcon("iconSpeaker")] + public partial class Volume : UserControl, IStatusIcon + { + public Volume() + { + InitializeComponent(); + } + + public void Setup() + { + lbvolume.Top = (this.Height - lbvolume.Height) / 2; + bool moving = false; + var prg = new ShiftedProgressBar(); + prg.Tag = "ignoreal"; //Don't close AL or current widget when this control is clicked. + this.Controls.Add(prg); + prg.Height = this.Height / 3; + prg.Maximum = 100; + prg.Value = SaveSystem.CurrentSave.MusicVolume; + prg.Width = this.Width - lbvolume.Width - 50; + prg.Left = lbvolume.Left + lbvolume.Width + 15; + prg.Top = (this.Height - prg.Height) / 2; + prg.MouseDown += (o, a) => + { + moving = true; + }; + + prg.MouseMove += (o, a) => + { + if (moving) + { + int val = (int)linear(a.X, 0, prg.Width, 0, 100); + SaveSystem.CurrentSave.MusicVolume = val; + prg.Value = val; + } + }; + + prg.MouseUp += (o, a) => + { + moving = false; + }; + prg.Show(); + } + + static public double linear(double x, double x0, double x1, double y0, double y1) + { + if ((x1 - x0) == 0) + { + return (y0 + y1) / 2; + } + return y0 + (x - x0) * (y1 - y0) / (x1 - x0); + } + } +} diff --git a/ShiftOS.WinForms/StatusIcons/Volume.resx b/ShiftOS.WinForms/StatusIcons/Volume.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/ShiftOS.WinForms/StatusIcons/Volume.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/ShiftOS.WinForms/Tools/ControlManager.cs b/ShiftOS.WinForms/Tools/ControlManager.cs index 92482fa..548a62a 100644 --- a/ShiftOS.WinForms/Tools/ControlManager.cs +++ b/ShiftOS.WinForms/Tools/ControlManager.cs @@ -158,6 +158,15 @@ namespace ShiftOS.WinForms.Tools } catch { } + if (!tag.Contains("ignoreal")) + { + ctrl.Click += (o, a) => + { + Desktop.HideAppLauncher(); + }; + + } + if (!tag.Contains("keepbg")) { if (ctrl.BackColor != Control.DefaultBackColor) @@ -279,6 +288,8 @@ namespace ShiftOS.WinForms.Tools { (ctrl as WindowBorder).Setup(); } + + MakeDoubleBuffered(ctrl); ControlSetup?.Invoke(ctrl); }); @@ -305,10 +316,6 @@ namespace ShiftOS.WinForms.Tools public static void SetupControls(Control frm, bool runInThread = true) { - frm.Click += (o, a) => - { - Desktop.HideAppLauncher(); - }; var ctrls = frm.Controls.ToList(); for (int i = 0; i < ctrls.Count(); i++) { diff --git a/ShiftOS.WinForms/WinformsDesktop.Designer.cs b/ShiftOS.WinForms/WinformsDesktop.Designer.cs index 968a31c..d82bc0c 100644 --- a/ShiftOS.WinForms/WinformsDesktop.Designer.cs +++ b/ShiftOS.WinForms/WinformsDesktop.Designer.cs @@ -55,6 +55,7 @@ namespace ShiftOS.WinForms this.desktoppanel = new System.Windows.Forms.Panel(); this.pnlnotifications = new System.Windows.Forms.Panel(); this.flnotifications = new System.Windows.Forms.FlowLayoutPanel(); + this.ntconnectionstatus = new System.Windows.Forms.PictureBox(); this.lbtime = new System.Windows.Forms.Label(); this.panelbuttonholder = new System.Windows.Forms.FlowLayoutPanel(); this.sysmenuholder = new System.Windows.Forms.Panel(); @@ -63,7 +64,6 @@ namespace ShiftOS.WinForms this.pnlscreensaver = new System.Windows.Forms.Panel(); this.pnlssicon = new System.Windows.Forms.Panel(); this.pnlwidgetlayer = new System.Windows.Forms.Panel(); - this.ntconnectionstatus = new System.Windows.Forms.PictureBox(); this.pnlnotificationbox = new System.Windows.Forms.Panel(); this.lbnotemsg = new System.Windows.Forms.Label(); this.lbnotetitle = new System.Windows.Forms.Label(); @@ -77,10 +77,10 @@ namespace ShiftOS.WinForms this.desktoppanel.SuspendLayout(); this.pnlnotifications.SuspendLayout(); this.flnotifications.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.ntconnectionstatus)).BeginInit(); this.sysmenuholder.SuspendLayout(); this.menuStrip1.SuspendLayout(); this.pnlscreensaver.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.ntconnectionstatus)).BeginInit(); this.pnlnotificationbox.SuspendLayout(); this.pnladvancedal.SuspendLayout(); this.pnlalsystemactions.SuspendLayout(); @@ -121,6 +121,18 @@ namespace ShiftOS.WinForms this.flnotifications.Name = "flnotifications"; this.flnotifications.Size = new System.Drawing.Size(22, 24); this.flnotifications.TabIndex = 1; + this.flnotifications.WrapContents = false; + // + // ntconnectionstatus + // + this.ntconnectionstatus.Image = global::ShiftOS.WinForms.Properties.Resources.notestate_connection_full; + this.ntconnectionstatus.Location = new System.Drawing.Point(3, 3); + this.ntconnectionstatus.Name = "ntconnectionstatus"; + this.ntconnectionstatus.Size = new System.Drawing.Size(16, 16); + this.ntconnectionstatus.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; + this.ntconnectionstatus.TabIndex = 0; + this.ntconnectionstatus.TabStop = false; + this.ntconnectionstatus.Tag = "digitalsociety"; // // lbtime // @@ -200,17 +212,6 @@ namespace ShiftOS.WinForms this.pnlwidgetlayer.Size = new System.Drawing.Size(1296, 714); this.pnlwidgetlayer.TabIndex = 1; // - // ntconnectionstatus - // - this.ntconnectionstatus.Image = global::ShiftOS.WinForms.Properties.Resources.notestate_connection_full; - this.ntconnectionstatus.Location = new System.Drawing.Point(3, 3); - this.ntconnectionstatus.Name = "ntconnectionstatus"; - this.ntconnectionstatus.Size = new System.Drawing.Size(16, 16); - this.ntconnectionstatus.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; - this.ntconnectionstatus.TabIndex = 0; - this.ntconnectionstatus.TabStop = false; - this.ntconnectionstatus.Tag = "digitalsociety"; - // // pnlnotificationbox // this.pnlnotificationbox.AutoSize = true; @@ -341,12 +342,12 @@ namespace ShiftOS.WinForms this.pnlnotifications.PerformLayout(); this.flnotifications.ResumeLayout(false); this.flnotifications.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.ntconnectionstatus)).EndInit(); this.sysmenuholder.ResumeLayout(false); this.sysmenuholder.PerformLayout(); this.menuStrip1.ResumeLayout(false); this.menuStrip1.PerformLayout(); this.pnlscreensaver.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.ntconnectionstatus)).EndInit(); this.pnlnotificationbox.ResumeLayout(false); this.pnlnotificationbox.PerformLayout(); this.pnladvancedal.ResumeLayout(false); diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs index b9c4f37..f1dbe48 100644 --- a/ShiftOS.WinForms/WinformsDesktop.cs +++ b/ShiftOS.WinForms/WinformsDesktop.cs @@ -85,27 +85,24 @@ namespace ShiftOS.WinForms ic.Tag = itype.Name.ToLower(); //Next get the icon data if any. - var iconattrib = itype.GetCustomAttributes(false).FirstOrDefault(x => x is DefaultIconAttribute) as DefaultIconAttribute; - if(iconattrib != null) - { //We can use this attribute's ID in the skin engine to get an icon. - var img = GetIcon(iconattrib.ID); + var img = GetIcon(itype.Name); //Make it transparent. - (img as Bitmap).MakeTransparent(LoadedSkin.SystemKey); + (img as Bitmap).MakeTransparent(Color.White); //Assign it to the control ic.Image = img; //Set the sizing mode ic.SizeMode = PictureBoxSizeMode.StretchImage; - } - else - { - ic.BackColor = Color.White; //TODO: Make it skinnable. - } - ic.Size = new Size(20, 20); //TODO: make it skinnable + ic.Size = new Size(16, 16); //TODO: make it skinnable //add to the notification tray flnotifications.Controls.Add(ic); ic.Show(); + ic.BringToFront(); + + flnotifications.Show(); + + ic.Click += (o, a) => { HideAppLauncher(); @@ -115,7 +112,14 @@ namespace ShiftOS.WinForms UserControl ctrl = (UserControl)Activator.CreateInstance(itype); (ctrl as IStatusIcon).Setup(); currentSettingsPane = ctrl; - if(LoadedSkin.DesktopPanelPosition == 0) + ControlManager.SetupControls(ctrl); + this.Controls.Add(ctrl); + ctrl.BringToFront(); + int left = ic.Parent.PointToScreen(ic.Location).X; + int realleft = left - ctrl.Width; + realleft += ic.Width; + ctrl.Left = realleft; + if (LoadedSkin.DesktopPanelPosition == 0) { ctrl.Top = desktoppanel.Height; } @@ -123,10 +127,6 @@ namespace ShiftOS.WinForms { ctrl.Top = this.Height - desktoppanel.Height - ctrl.Height; } - int noteleft = flnotifications.PointToScreen(ic.Location).X; - int realleft = (this.Width - (noteleft + ic.Width)) - ctrl.Width; - ctrl.Left = realleft; - ControlManager.SetupControls(ctrl); ctrl.Show(); } diff --git a/ShiftOS.WinForms/WinformsDesktop.resx b/ShiftOS.WinForms/WinformsDesktop.resx index b77504b..d5494e3 100644 --- a/ShiftOS.WinForms/WinformsDesktop.resx +++ b/ShiftOS.WinForms/WinformsDesktop.resx @@ -120,7 +120,4 @@ 17, 17 - - 17, 17 - \ No newline at end of file -- cgit v1.2.3 From 03cf891c53cc648bb1ed4ea3d78755c1a440a713 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 1 Jun 2017 17:09:22 -0400 Subject: Icon Manager and various icon bugfixes. --- .../Applications/IconManager.Designer.cs | 163 ++++++++++++++ ShiftOS.WinForms/Applications/IconManager.cs | 244 +++++++++++++++++++++ ShiftOS.WinForms/Applications/IconManager.resx | 120 ++++++++++ ShiftOS.WinForms/Resources/Shiftorium.txt | 14 ++ ShiftOS.WinForms/ShiftOS.WinForms.csproj | 18 ++ .../StatusIcons/TestStatus.Designer.cs | 60 +++++ ShiftOS.WinForms/StatusIcons/TestStatus.cs | 26 +++ ShiftOS.WinForms/StatusIcons/TestStatus.resx | 120 ++++++++++ ShiftOS_TheReturn/Skinning.cs | 10 +- 9 files changed, 774 insertions(+), 1 deletion(-) create mode 100644 ShiftOS.WinForms/Applications/IconManager.Designer.cs create mode 100644 ShiftOS.WinForms/Applications/IconManager.cs create mode 100644 ShiftOS.WinForms/Applications/IconManager.resx create mode 100644 ShiftOS.WinForms/StatusIcons/TestStatus.Designer.cs create mode 100644 ShiftOS.WinForms/StatusIcons/TestStatus.cs create mode 100644 ShiftOS.WinForms/StatusIcons/TestStatus.resx (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.WinForms/Applications/IconManager.Designer.cs b/ShiftOS.WinForms/Applications/IconManager.Designer.cs new file mode 100644 index 0000000..25bcee4 --- /dev/null +++ b/ShiftOS.WinForms/Applications/IconManager.Designer.cs @@ -0,0 +1,163 @@ +namespace ShiftOS.WinForms.Applications +{ + partial class IconManager + { + /// + /// 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.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); + this.btnclose = new System.Windows.Forms.Button(); + this.btnreset = new System.Windows.Forms.Button(); + this.btnapply = new System.Windows.Forms.Button(); + this.flbody = new System.Windows.Forms.FlowLayoutPanel(); + this.lbcurrentpage = new System.Windows.Forms.Label(); + this.btnprev = new System.Windows.Forms.Button(); + this.btnnext = new System.Windows.Forms.Button(); + this.flowLayoutPanel1.SuspendLayout(); + this.SuspendLayout(); + // + // flowLayoutPanel1 + // + this.flowLayoutPanel1.AutoSize = true; + this.flowLayoutPanel1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.flowLayoutPanel1.Controls.Add(this.btnclose); + this.flowLayoutPanel1.Controls.Add(this.btnreset); + this.flowLayoutPanel1.Controls.Add(this.btnapply); + this.flowLayoutPanel1.Controls.Add(this.lbcurrentpage); + this.flowLayoutPanel1.Controls.Add(this.btnprev); + this.flowLayoutPanel1.Controls.Add(this.btnnext); + this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Bottom; + this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 416); + this.flowLayoutPanel1.Name = "flowLayoutPanel1"; + this.flowLayoutPanel1.Size = new System.Drawing.Size(393, 29); + this.flowLayoutPanel1.TabIndex = 0; + // + // btnclose + // + this.btnclose.AutoSize = true; + this.btnclose.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.btnclose.Location = new System.Drawing.Point(3, 3); + this.btnclose.Name = "btnclose"; + this.btnclose.Size = new System.Drawing.Size(43, 23); + this.btnclose.TabIndex = 0; + this.btnclose.Text = "Close"; + this.btnclose.UseVisualStyleBackColor = true; + this.btnclose.Click += new System.EventHandler(this.btnclose_Click); + // + // btnreset + // + this.btnreset.AutoSize = true; + this.btnreset.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.btnreset.Location = new System.Drawing.Point(52, 3); + this.btnreset.Name = "btnreset"; + this.btnreset.Size = new System.Drawing.Size(45, 23); + this.btnreset.TabIndex = 1; + this.btnreset.Text = "Reset"; + this.btnreset.UseVisualStyleBackColor = true; + this.btnreset.Click += new System.EventHandler(this.btnreset_Click); + // + // btnapply + // + this.btnapply.AutoSize = true; + this.btnapply.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.btnapply.Location = new System.Drawing.Point(103, 3); + this.btnapply.Name = "btnapply"; + this.btnapply.Size = new System.Drawing.Size(43, 23); + this.btnapply.TabIndex = 2; + this.btnapply.Text = "Apply"; + this.btnapply.UseVisualStyleBackColor = true; + this.btnapply.Click += new System.EventHandler(this.btnapply_Click); + // + // flbody + // + this.flbody.Dock = System.Windows.Forms.DockStyle.Fill; + this.flbody.FlowDirection = System.Windows.Forms.FlowDirection.TopDown; + this.flbody.Location = new System.Drawing.Point(0, 0); + this.flbody.Name = "flbody"; + this.flbody.Size = new System.Drawing.Size(393, 416); + this.flbody.TabIndex = 1; + this.flbody.WrapContents = false; + // + // lbcurrentpage + // + this.lbcurrentpage.AutoSize = true; + this.lbcurrentpage.Location = new System.Drawing.Point(152, 0); + this.lbcurrentpage.Name = "lbcurrentpage"; + this.lbcurrentpage.Size = new System.Drawing.Size(71, 13); + this.lbcurrentpage.TabIndex = 3; + this.lbcurrentpage.Text = "Current page:"; + // + // btnprev + // + this.btnprev.AutoSize = true; + this.btnprev.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.btnprev.Location = new System.Drawing.Point(229, 3); + this.btnprev.Name = "btnprev"; + this.btnprev.Size = new System.Drawing.Size(51, 23); + this.btnprev.TabIndex = 4; + this.btnprev.Text = " < Prev"; + this.btnprev.UseVisualStyleBackColor = true; + this.btnprev.Click += new System.EventHandler(this.btnprev_Click); + // + // btnnext + // + this.btnnext.AutoSize = true; + this.btnnext.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.btnnext.Location = new System.Drawing.Point(286, 3); + this.btnnext.Name = "btnnext"; + this.btnnext.Size = new System.Drawing.Size(48, 23); + this.btnnext.TabIndex = 5; + this.btnnext.Text = "Next >"; + this.btnnext.UseVisualStyleBackColor = true; + this.btnnext.Click += new System.EventHandler(this.btnnext_Click); + // + // IconManager + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.flbody); + this.Controls.Add(this.flowLayoutPanel1); + this.Name = "IconManager"; + this.Size = new System.Drawing.Size(393, 445); + this.flowLayoutPanel1.ResumeLayout(false); + this.flowLayoutPanel1.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1; + private System.Windows.Forms.Button btnclose; + private System.Windows.Forms.Button btnreset; + private System.Windows.Forms.Button btnapply; + private System.Windows.Forms.FlowLayoutPanel flbody; + private System.Windows.Forms.Label lbcurrentpage; + private System.Windows.Forms.Button btnprev; + private System.Windows.Forms.Button btnnext; + } +} diff --git a/ShiftOS.WinForms/Applications/IconManager.cs b/ShiftOS.WinForms/Applications/IconManager.cs new file mode 100644 index 0000000..0c6e119 --- /dev/null +++ b/ShiftOS.WinForms/Applications/IconManager.cs @@ -0,0 +1,244 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using ShiftOS.Engine; +using System.Reflection; +using ShiftOS.WinForms.Tools; +using Newtonsoft.Json; + +namespace ShiftOS.WinForms.Applications +{ + [RequiresUpgrade("icon_manager")] + [Launcher("Icon Manager", true, "al_icon_manager", "Customization")] + [DefaultTitle("Icon Manager")] + [DefaultIcon("iconIconManager")] + public partial class IconManager : UserControl, IShiftOSWindow + { + public IconManager() + { + InitializeComponent(); + } + + public void OnLoad() + { + LoadIconsFromEngine(); + SetupUI(); + } + + public void OnSkinLoad() + { + LoadIconsFromEngine(); + SetupUI(); + } + + public bool OnUnload() + { + Icons = null; + return true; + } + + private Dictionary Icons = null; + + private const int pageSize = 10; + private int currentPage = 0; + private int pageCount = 0; + + public Image GetIcon(string id) + { + if (!Icons.ContainsKey(id)) + Icons.Add(id, null); + + if (Icons[id] == null) + { + var img = SkinEngine.GetDefaultIcon(id); + using (var mstr = new System.IO.MemoryStream()) + { + img.Save(mstr, System.Drawing.Imaging.ImageFormat.Png); + Icons[id] = mstr.ToArray(); + } + return img; + } + else + { + using (var sr = new System.IO.MemoryStream(Icons[id])) + { + return Image.FromStream(sr); + } + } + } + + public void SetIcon(string key, byte[] raw) + { + if (!Icons.ContainsKey(key)) + Icons.Add(key, raw); + Icons[key] = raw; + } + + public void LoadIconsFromEngine() + { + //We have to serialize the engine icon list to JSON to break references with the data. + string json = JsonConvert.SerializeObject(SkinEngine.LoadedSkin.AppIcons); + //And deserialize to the local instance...essentially making a clone. + Icons = JsonConvert.DeserializeObject>(json); + } + + public void SetupUI() + { + flbody.Controls.Clear(); //Clear the icon list. + + List types = new List(); + + foreach(var exe in System.IO.Directory.GetFiles(Environment.CurrentDirectory)) + { + if(exe.ToLower().EndsWith(".exe") || exe.ToLower().EndsWith(".dll")) + { + try + { + var asm = Assembly.LoadFile(exe); + + var typeList = asm.GetTypes().Where(x => x.GetCustomAttributes(false).FirstOrDefault(y => y is DefaultIconAttribute) != null); + types.AddRange(typeList); + + } + catch { } + } + } + + pageCount = types.ToArray().GetPageCount(pageSize); + + foreach (var type in types.ToArray().GetItemsOnPage(currentPage, pageSize)) + { + if (Shiftorium.UpgradeAttributesUnlocked(type)) + { + var pnl = new Panel(); + pnl.Height = 30; + pnl.Width = flbody.Width - 15; + flbody.Controls.Add(pnl); + pnl.Show(); + var pic = new PictureBox(); + pic.SizeMode = PictureBoxSizeMode.StretchImage; + pic.Size = new Size(24, 24); + pic.Image = GetIcon(type.Name); + pnl.Controls.Add(pic); + pic.Left = 5; + pic.Top = (pnl.Height - pic.Height) / 2; + pic.Show(); + var lbl = new Label(); + lbl.Tag = "header3"; + lbl.AutoSize = true; + lbl.Text = NameChangerBackend.GetNameRaw(type); + ControlManager.SetupControl(lbl); + pnl.Controls.Add(lbl); + lbl.CenterParent(); + lbl.Show(); + var btn = new Button(); + btn.Text = "Change..."; + btn.AutoSize = true; + btn.AutoSizeMode = AutoSizeMode.GrowAndShrink; + pnl.Controls.Add(btn); + btn.Left = (pnl.Width - btn.Width) - 5; + btn.Top = (pnl.Height - btn.Height) / 2; + btn.Click += (o, a) => + { + var gfp = new GraphicPicker(pic.Image, lbl.Text + " icon", ImageLayout.Stretch, (raw, img, layout) => + { + pic.Image = img; + SetIcon(type.Name, raw); + }); + AppearanceManager.SetupDialog(gfp); + }; + btn.Show(); + ControlManager.SetupControls(pnl); + } + } + + btnnext.Visible = (currentPage < pageCount - 1); + btnprev.Visible = (currentPage > 0); + + lbcurrentpage.Text = "Page " + (currentPage + 1).ToString() + " of " + pageCount.ToString(); + } + + public void OnUpgrade() + { + LoadIconsFromEngine(); + SetupUI(); + } + + private void btnprev_Click(object sender, EventArgs e) + { + currentPage--; + SetupUI(); + } + + public void ResetToDefaults() + { + currentPage = 0; + foreach (var key in Icons.Keys) + { + var img = SkinEngine.GetDefaultIcon(key); + using(var ms = new System.IO.MemoryStream()) + { + img.Save(ms, System.Drawing.Imaging.ImageFormat.Png); + Icons[key] = ms.ToArray(); + } + } + SetupUI(); + } + + private void btnnext_Click(object sender, EventArgs e) + { + currentPage++; + SetupUI(); + } + + private void btnclose_Click(object sender, EventArgs e) + { + AppearanceManager.Close(this); + } + + private void btnreset_Click(object sender, EventArgs e) + { + ResetToDefaults(); + } + + private void btnapply_Click(object sender, EventArgs e) + { + SkinEngine.LoadedSkin.AppIcons = Icons; + SkinEngine.SaveSkin(); + SkinEngine.LoadSkin(); + Infobox.Show("Icons applied!", "The new icons have been applied to ShiftOS successfully!"); + } + } + + public static class PaginationExtensions + { + public static int GetPageCount(this IEnumerable collection, int pageSize) + { + return (collection.Count() + pageSize - 1) / pageSize; + } + + public static T[] GetItemsOnPage(this T[] collection, int page, int pageSize) + { + List obj = new List(); + + for (int i = pageSize * page; i <= pageSize + (pageSize * page) && i < collection.Count(); i++) + { + try + { + obj.Add(collection[i]); + } + catch + { + } + } + return obj.ToArray(); + } + } + +} diff --git a/ShiftOS.WinForms/Applications/IconManager.resx b/ShiftOS.WinForms/Applications/IconManager.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/ShiftOS.WinForms/Applications/IconManager.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/ShiftOS.WinForms/Resources/Shiftorium.txt b/ShiftOS.WinForms/Resources/Shiftorium.txt index 0eac58e..1a6d8c2 100644 --- a/ShiftOS.WinForms/Resources/Shiftorium.txt +++ b/ShiftOS.WinForms/Resources/Shiftorium.txt @@ -7,6 +7,20 @@ Dependencies: "desktop", Category: "Enhancements", }, + { + Name: "Icon Manager", + Cost: 450, + Description: "This tool allows you to add and edit application icons within ShiftOS for the small prive of 450 Codepoints!", + Dependencies: "skinning", + Category: "Application" + }, + { + Name: "AL Icon Manager", + Costs: 150, + Description: "Add an App Launcher entry for the Icon Manager.", + Dependencies: "icon_manager;app_launcher", + Category: "Customization" + }, { Name: "Shift Progress Bar", Cost: 150, diff --git a/ShiftOS.WinForms/ShiftOS.WinForms.csproj b/ShiftOS.WinForms/ShiftOS.WinForms.csproj index fd875e9..0a59c00 100644 --- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj +++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj @@ -70,6 +70,12 @@ About.cs + + UserControl + + + IconManager.cs + UserControl @@ -409,6 +415,12 @@ ShiftnetStatus.cs + + UserControl + + + TestStatus.cs + UserControl @@ -461,6 +473,9 @@ About.cs + + IconManager.cs + TriPresent.cs @@ -616,6 +631,9 @@ ShiftnetStatus.cs + + TestStatus.cs + Volume.cs diff --git a/ShiftOS.WinForms/StatusIcons/TestStatus.Designer.cs b/ShiftOS.WinForms/StatusIcons/TestStatus.Designer.cs new file mode 100644 index 0000000..3643d2d --- /dev/null +++ b/ShiftOS.WinForms/StatusIcons/TestStatus.Designer.cs @@ -0,0 +1,60 @@ +namespace ShiftOS.WinForms.StatusIcons +{ + partial class TestStatus + { + /// + /// 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.label1 = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // label1 + // + this.label1.Dock = System.Windows.Forms.DockStyle.Fill; + this.label1.Location = new System.Drawing.Point(0, 0); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(264, 52); + this.label1.TabIndex = 0; + this.label1.Tag = "header1"; + this.label1.Text = "This is a test."; + this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // TestStatus + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.label1); + this.Name = "TestStatus"; + this.Size = new System.Drawing.Size(264, 52); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Label label1; + } +} diff --git a/ShiftOS.WinForms/StatusIcons/TestStatus.cs b/ShiftOS.WinForms/StatusIcons/TestStatus.cs new file mode 100644 index 0000000..90baafc --- /dev/null +++ b/ShiftOS.WinForms/StatusIcons/TestStatus.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using ShiftOS.Engine; + +namespace ShiftOS.WinForms.StatusIcons +{ + [DefaultIcon("iconShiftorium")] + public partial class TestStatus : UserControl, IStatusIcon + { + public TestStatus() + { + InitializeComponent(); + } + + public void Setup() + { + } + } +} diff --git a/ShiftOS.WinForms/StatusIcons/TestStatus.resx b/ShiftOS.WinForms/StatusIcons/TestStatus.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/ShiftOS.WinForms/StatusIcons/TestStatus.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/ShiftOS_TheReturn/Skinning.cs b/ShiftOS_TheReturn/Skinning.cs index 5bd4ab1..4a073f4 100644 --- a/ShiftOS_TheReturn/Skinning.cs +++ b/ShiftOS_TheReturn/Skinning.cs @@ -287,7 +287,15 @@ namespace ShiftOS.Engine LoadedSkin.AppIcons.Add(id, null); if (LoadedSkin.AppIcons[id] == null) - return GetDefaultIcon(id); + { + var img = GetDefaultIcon(id); + using (var mstr = new MemoryStream()) + { + img.Save(mstr, System.Drawing.Imaging.ImageFormat.Png); + LoadedSkin.AppIcons[id] = mstr.ToArray(); + } + return img; + } else { using (var sr = new MemoryStream(LoadedSkin.AppIcons[id])) -- cgit v1.2.3 From d001b613fba71bcee04163492940f17a0027daa7 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 1 Jun 2017 17:45:59 -0400 Subject: Fix Graphic Picker UI. --- .../Applications/GraphicPicker.Designer.cs | 45 ++++++++++++++-------- ShiftOS.WinForms/Applications/GraphicPicker.cs | 9 +++++ 2 files changed, 37 insertions(+), 17 deletions(-) (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.WinForms/Applications/GraphicPicker.Designer.cs b/ShiftOS.WinForms/Applications/GraphicPicker.Designer.cs index 988acbd..889c8aa 100644 --- a/ShiftOS.WinForms/Applications/GraphicPicker.Designer.cs +++ b/ShiftOS.WinForms/Applications/GraphicPicker.Designer.cs @@ -86,12 +86,12 @@ namespace ShiftOS.WinForms.Applications this.pgcontents.Dock = System.Windows.Forms.DockStyle.Fill; this.pgcontents.Location = new System.Drawing.Point(0, 0); this.pgcontents.Name = "pgcontents"; - this.pgcontents.Size = new System.Drawing.Size(390, 383); + this.pgcontents.Size = new System.Drawing.Size(487, 383); this.pgcontents.TabIndex = 20; // // btncancel // - this.btncancel.Anchor = System.Windows.Forms.AnchorStyles.Bottom; + this.btncancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.btncancel.Location = new System.Drawing.Point(21, 335); this.btncancel.Name = "btncancel"; this.btncancel.Size = new System.Drawing.Size(109, 32); @@ -102,10 +102,11 @@ namespace ShiftOS.WinForms.Applications // // btnreset // - this.btnreset.Anchor = System.Windows.Forms.AnchorStyles.Bottom; + this.btnreset.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.btnreset.Location = new System.Drawing.Point(136, 335); this.btnreset.Name = "btnreset"; - this.btnreset.Size = new System.Drawing.Size(109, 32); + this.btnreset.Size = new System.Drawing.Size(206, 32); this.btnreset.TabIndex = 22; this.btnreset.Text = "Reset"; this.btnreset.UseVisualStyleBackColor = true; @@ -113,8 +114,8 @@ namespace ShiftOS.WinForms.Applications // // btnapply // - this.btnapply.Anchor = System.Windows.Forms.AnchorStyles.Bottom; - this.btnapply.Location = new System.Drawing.Point(251, 335); + this.btnapply.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnapply.Location = new System.Drawing.Point(348, 335); this.btnapply.Name = "btnapply"; this.btnapply.Size = new System.Drawing.Size(118, 32); this.btnapply.TabIndex = 21; @@ -124,19 +125,21 @@ namespace ShiftOS.WinForms.Applications // // Label2 // - this.Label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.Label2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.Label2.Font = new System.Drawing.Font("Arial", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.Label2.Location = new System.Drawing.Point(125, 260); this.Label2.Name = "Label2"; - this.Label2.Size = new System.Drawing.Size(163, 28); + this.Label2.Size = new System.Drawing.Size(260, 28); this.Label2.TabIndex = 12; + this.Label2.Tag = "header3"; this.Label2.Text = "Idle"; this.Label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // btnidlebrowse // - this.btnidlebrowse.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.btnidlebrowse.Location = new System.Drawing.Point(295, 260); + this.btnidlebrowse.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnidlebrowse.Location = new System.Drawing.Point(392, 260); this.btnidlebrowse.Name = "btnidlebrowse"; this.btnidlebrowse.Size = new System.Drawing.Size(73, 60); this.btnidlebrowse.TabIndex = 10; @@ -146,14 +149,15 @@ namespace ShiftOS.WinForms.Applications // // txtidlefile // - this.txtidlefile.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.txtidlefile.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.txtidlefile.BackColor = System.Drawing.Color.White; this.txtidlefile.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.txtidlefile.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.txtidlefile.Location = new System.Drawing.Point(125, 291); this.txtidlefile.Multiline = true; this.txtidlefile.Name = "txtidlefile"; - this.txtidlefile.Size = new System.Drawing.Size(163, 29); + this.txtidlefile.Size = new System.Drawing.Size(260, 29); this.txtidlefile.TabIndex = 9; this.txtidlefile.Text = "None"; this.txtidlefile.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; @@ -172,9 +176,10 @@ namespace ShiftOS.WinForms.Applications // // btnzoom // + this.btnzoom.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.btnzoom.FlatAppearance.BorderColor = System.Drawing.Color.Black; this.btnzoom.FlatAppearance.BorderSize = 0; - this.btnzoom.Location = new System.Drawing.Point(286, 144); + this.btnzoom.Location = new System.Drawing.Point(383, 144); this.btnzoom.Name = "btnzoom"; this.btnzoom.Size = new System.Drawing.Size(82, 65); this.btnzoom.TabIndex = 7; @@ -184,9 +189,10 @@ namespace ShiftOS.WinForms.Applications // // btnstretch // + this.btnstretch.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.btnstretch.FlatAppearance.BorderColor = System.Drawing.Color.Black; this.btnstretch.FlatAppearance.BorderSize = 0; - this.btnstretch.Location = new System.Drawing.Point(197, 144); + this.btnstretch.Location = new System.Drawing.Point(294, 144); this.btnstretch.Name = "btnstretch"; this.btnstretch.Size = new System.Drawing.Size(82, 65); this.btnstretch.TabIndex = 6; @@ -228,6 +234,9 @@ namespace ShiftOS.WinForms.Applications // // picgraphic // + this.picgraphic.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.picgraphic.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; this.picgraphic.Location = new System.Drawing.Point(0, 0); this.picgraphic.Name = "picgraphic"; @@ -237,11 +246,14 @@ namespace ShiftOS.WinForms.Applications // // lblobjecttoskin // + this.lblobjecttoskin.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.lblobjecttoskin.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lblobjecttoskin.Location = new System.Drawing.Point(19, 9); this.lblobjecttoskin.Name = "lblobjecttoskin"; - this.lblobjecttoskin.Size = new System.Drawing.Size(350, 23); + this.lblobjecttoskin.Size = new System.Drawing.Size(447, 23); this.lblobjecttoskin.TabIndex = 2; + this.lblobjecttoskin.Tag = "header1"; this.lblobjecttoskin.Text = "Close Button"; this.lblobjecttoskin.TextAlign = System.Drawing.ContentAlignment.TopCenter; // @@ -249,10 +261,9 @@ namespace ShiftOS.WinForms.Applications // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(390, 383); this.Controls.Add(this.pgcontents); this.Name = "GraphicPicker"; - this.Text = "{GRAPHIC_PICKER_NAME}"; + this.Size = new System.Drawing.Size(487, 383); this.Load += new System.EventHandler(this.Graphic_Picker_Load); this.pgcontents.ResumeLayout(false); this.pgcontents.PerformLayout(); diff --git a/ShiftOS.WinForms/Applications/GraphicPicker.cs b/ShiftOS.WinForms/Applications/GraphicPicker.cs index 85f95bd..f299f0d 100644 --- a/ShiftOS.WinForms/Applications/GraphicPicker.cs +++ b/ShiftOS.WinForms/Applications/GraphicPicker.cs @@ -45,6 +45,12 @@ namespace ShiftOS.WinForms.Applications { InitializeComponent(); SelectedLayout = layout; + Image = old; + using(var ms = new System.IO.MemoryStream()) + { + Image.Save(ms, System.Drawing.Imaging.ImageFormat.Png); + ImageAsBinary = ms.ToArray(); + } Callback = cb; lblobjecttoskin.Text = name; @@ -123,10 +129,12 @@ namespace ShiftOS.WinForms.Applications public void OnLoad() { + Setup(); } public void OnSkinLoad() { + Setup(); } public bool OnUnload() @@ -136,6 +144,7 @@ namespace ShiftOS.WinForms.Applications public void OnUpgrade() { + Setup(); } } } -- cgit v1.2.3 From 5246798b0ad07ac1a2dd9a1369da4ecad2383488 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 2 Jun 2017 08:05:53 -0400 Subject: Make stories not happen until user is logged in. --- ShiftOS.WinForms/WinformsDesktop.cs | 29 ++++------------------------- 1 file changed, 4 insertions(+), 25 deletions(-) (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs index f1dbe48..4614842 100644 --- a/ShiftOS.WinForms/WinformsDesktop.cs +++ b/ShiftOS.WinForms/WinformsDesktop.cs @@ -196,38 +196,14 @@ namespace ShiftOS.WinForms SetupControl(desktoppanel); Shiftorium.Installed += () => { - foreach(var widget in Widgets) + foreach (var widget in Widgets) { widget.OnUpgrade(); } LoadIcons(); - //Only if the DevX Legions story hasn't been experienced yet. - if (!Shiftorium.UpgradeInstalled("devx_legions")) - { - //Check for shiftnet story experience - if (Shiftorium.UpgradeInstalled("shiftnet")) - { - //Check for saturation of the "GUI" upgrade set - if (Shiftorium.IsCategoryEmptied("GUI")) - { - //Start the MUD Control Centre story. - Story.Start("devx_legions"); - } - } - } - if (!Shiftorium.UpgradeInstalled("victortran_shiftnet")) - { - if (SaveSystem.CurrentSave.Codepoints >= 50000) - { - if (Shiftorium.IsCategoryEmptied("Applications")) - { - Story.Start("victortran_shiftnet"); - } - } - } }; this.TopMost = false; @@ -294,6 +270,9 @@ namespace ShiftOS.WinForms { do { + while (SaveSystem.CurrentUser == null) + Thread.Sleep(10); + if (SaveSystem.CurrentSave != null) { if (SaveSystem.CurrentSave.Codepoints != lastcp) -- cgit v1.2.3 From 17f3f6f68567b0151474af86d6ba265b35029b8e Mon Sep 17 00:00:00 2001 From: RogueAI42 Date: Sat, 3 Jun 2017 00:43:20 +1000 Subject: Fixed Pong? there are some sound crashes but Michael told me to just make the PR and let him fix the audio backend so that's what I'm doing. --- ShiftOS.WinForms/Applications/Pong.Designer.cs | 3 - ShiftOS.WinForms/Applications/Pong.cs | 406 +++++++++---------------- ShiftOS.WinForms/Applications/Pong.resx | 3 + 3 files changed, 140 insertions(+), 272 deletions(-) (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.WinForms/Applications/Pong.Designer.cs b/ShiftOS.WinForms/Applications/Pong.Designer.cs index 0254e94..c5ea375 100644 --- a/ShiftOS.WinForms/Applications/Pong.Designer.cs +++ b/ShiftOS.WinForms/Applications/Pong.Designer.cs @@ -182,7 +182,6 @@ namespace ShiftOS.WinForms.Applications this.pgcontents.Name = "pgcontents"; this.pgcontents.Size = new System.Drawing.Size(912, 504); this.pgcontents.TabIndex = 20; - this.pgcontents.Paint += new System.Windows.Forms.PaintEventHandler(this.pgcontents_Paint); this.pgcontents.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pongMain_MouseMove); // // pnlmultiplayerhandshake @@ -250,7 +249,6 @@ namespace ShiftOS.WinForms.Applications this.Label6.TabIndex = 15; this.Label6.Text = "{PONG_DESC}"; this.Label6.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.Label6.Click += new System.EventHandler(this.Label6_Click); // // btnstartgame // @@ -273,7 +271,6 @@ namespace ShiftOS.WinForms.Applications this.Label8.Size = new System.Drawing.Size(280, 31); this.Label8.TabIndex = 14; this.Label8.Text = "{PONG_WELCOME}"; - this.Label8.Click += new System.EventHandler(this.Label8_Click); // // pnlhighscore // diff --git a/ShiftOS.WinForms/Applications/Pong.cs b/ShiftOS.WinForms/Applications/Pong.cs index 6d81c64..87f0306 100644 --- a/ShiftOS.WinForms/Applications/Pong.cs +++ b/ShiftOS.WinForms/Applications/Pong.cs @@ -60,11 +60,60 @@ namespace ShiftOS.WinForms.Applications int levelyspeed = 3; ulong beatairewardtotal; ulong beataireward = 1; - ulong[] levelrewards = new ulong[50]; + readonly uint[] levelrewards = { + 0, + 20, + 60, + 140, + 290, + 400, + 600, + 900, + 1200, + 1600, + 2000, + 2500, + 3000, + 4000, + 5000, + 6000, + 8000, + 10000, + 13000, + 16000, + 20000, + 25000, + 32000, + 40000, + 50000, + 60000, + 75000, + 90000, + 110000, + 140000, + 180000, + 220000, + 270000, + 320000, + 400000, + 500000, + 640000, + 800000, + 1000000, + 1500000, + 2000000}; ulong totalreward; int countdown = 3; + int rwdmultiplier; + Thread soundThread; - bool aiShouldIsbeEnabled = true; + bool aiShouldIsbeEnabled = true; // who named this variable? and were they having a stroke? + + private void playsound(System.IO.Stream stream) + { + soundThread = new Thread((a) => ShiftOS.Engine.AudioManager.PlayStream((System.IO.Stream)a)); + soundThread.Start(stream); + } public Pong() { @@ -73,11 +122,9 @@ namespace ShiftOS.WinForms.Applications private void Pong_Load(object sender, EventArgs e) { - setuplevelrewards(); + rwdmultiplier = ShiftoriumFrontend.UpgradeInstalled("pong_upgrade") ? 2 : 1; } - - // Move the paddle according to the mouse position. private void pongMain_MouseMove(object sender, MouseEventArgs e) { @@ -133,9 +180,7 @@ namespace ShiftOS.WinForms.Applications { if (this.Left < Screen.PrimaryScreen.Bounds.Width) { - ball.BackColor = SkinEngine.LoadedSkin.ControlTextColor; - paddleComputer.BackColor = SkinEngine.LoadedSkin.ControlTextColor; - paddleHuman.BackColor = SkinEngine.LoadedSkin.ControlTextColor; + ball.BackColor = paddleComputer.BackColor = paddleHuman.BackColor = SkinEngine.LoadedSkin.ControlTextColor; //Check if paddle upgrade has been bought and change paddles accordingly //if (ShiftoriumFrontend.UpgradeInstalled("pong_increased_paddle_size")) @@ -146,7 +191,7 @@ namespace ShiftOS.WinForms.Applications //I don't know the point of this but I'm fucking 86ing it. - Michael //Set the computer player to move according to the ball's position. - if (IsMultiplayerSession == true) + if (IsMultiplayerSession) { //If we're multiplayer, then we want to set the computer Y to the opponent's Y. //If we're the leader, we set the AI paddle, else we set the player paddle. @@ -160,83 +205,63 @@ namespace ShiftOS.WinForms.Applications if (aiShouldIsbeEnabled) if (ball.Location.X > (this.Width - (this.Width / 3)) - xVel * 10 && xVel > 0) { - if (ball.Location.Y > paddleComputer.Location.Y + 50) - { - paddleComputer.Location = new Point(paddleComputer.Location.X, paddleComputer.Location.Y + computerspeed); - } - if (ball.Location.Y < paddleComputer.Location.Y + 50) - { - paddleComputer.Location = new Point(paddleComputer.Location.X, paddleComputer.Location.Y - computerspeed); - } + if (ball.Top > paddleComputer.Top + 50) + paddleComputer.Top += computerspeed; + else + paddleComputer.Top -= computerspeed; casualposition = rand.Next(-150, 201); } else { //used to be me.location.y - except it's fucking C# and this comment is misleading as fuck. OH WAIT! I didn't write it! And none of the current devs did either! - Michael - if (paddleComputer.Location.Y > this.Size.Height / 2 - paddleComputer.Height + casualposition) - { - paddleComputer.Location = new Point(paddleComputer.Location.X, paddleComputer.Location.Y - computerspeed); - } - //Rylan is hot. Used to be //used to be me.location.y - if (paddleComputer.Location.Y < this.Size.Height / 2 - paddleComputer.Height + casualposition) - { - paddleComputer.Location = new Point(paddleComputer.Location.X, paddleComputer.Location.Y + computerspeed); - } + if (paddleComputer.Top > this.Height / 2 - paddleComputer.Height + casualposition) + paddleComputer.Top -= computerspeed; + else + paddleComputer.Top += computerspeed; } } //Set Xvel and Yvel speeds from decimal if (xVel > 0) xVel = (int)Math.Round(xveldec); - if (xVel < 0) + else xVel = (int)-Math.Round(xveldec); if (yVel > 0) yVel = (int)Math.Round(yveldec); - if (yVel < 0) + else yVel = (int)-Math.Round(yveldec); - bool BallPhysics = true; - - if (IsMultiplayerSession) + if (IsMultiplayerSession && !IsLeader) { - //Logic for moving the ball in Multiplayer. - if (IsLeader) - { - ball.Location = new Point(ball.Location.X + xVel, ball.Location.Y + yVel); - } - else - { - //Move it to the leader's ball position. - ball.Location = new Point(LeaderX, LeaderY); - BallPhysics = false; - } + // Move it to the leader's ball position. + ball.Location = new Point(LeaderX, LeaderY); } else - {// Move the game ball. - ball.Location = new Point(ball.Location.X + xVel, ball.Location.Y + yVel); - } - if (BallPhysics) { + var newRect = new Rectangle(ball.Location, ball.Size); // copy ball's Bounds + newRect.X += xVel; + newRect.Y += yVel; + // Check for top wall. - if (ball.Location.Y < 0) + if (newRect.Y < 0) { - ball.Location = new Point(ball.Location.X, 0); + newRect.Y = 0; yVel = -yVel; - ShiftOS.Engine.AudioManager.PlayStream(Properties.Resources.typesound); + playsound(Properties.Resources.typesound); } // Check for bottom wall. - if (ball.Location.Y > pgcontents.Height - ball.Height) + if (newRect.Y > pgcontents.Height - ball.Height) { - ball.Location = new Point(ball.Location.X, pgcontents.Height - ball.Size.Height); + newRect.Y = pgcontents.Height - ball.Height; yVel = -yVel; - ShiftOS.Engine.AudioManager.PlayStream(Properties.Resources.typesound); + playsound(Properties.Resources.typesound); } // Check for player paddle. - if (ball.Bounds.IntersectsWith(paddleHuman.Bounds)) + if (newRect.IntersectsWith(paddleHuman.Bounds)) { - ball.Location = new Point(paddleHuman.Location.X + ball.Size.Width + 1, ball.Location.Y); + newRect.X = paddleHuman.Left + ball.Width + 1; //randomly increase x or y speed of ball switch (rand.Next(1, 3)) { @@ -246,23 +271,24 @@ namespace ShiftOS.WinForms.Applications case 2: if (yveldec > 0) yveldec = yveldec + incrementy; - if (yveldec < 0) + else yveldec = yveldec - incrementy; break; } xVel = -xVel; - ShiftOS.Engine.AudioManager.PlayStream(Properties.Resources.writesound); + playsound(Properties.Resources.writesound); } // Check for computer paddle. - if (ball.Bounds.IntersectsWith(paddleComputer.Bounds)) + if (newRect.IntersectsWith(paddleComputer.Bounds)) { - ball.Location = new Point(paddleComputer.Location.X - paddleComputer.Size.Width - 1, ball.Location.Y); + newRect.X = paddleComputer.Left - paddleComputer.Width - 1; xveldec = xveldec + incrementx; xVel = -xVel; - ShiftOS.Engine.AudioManager.PlayStream(Properties.Resources.writesound); + playsound(Properties.Resources.writesound); } + ball.Location = newRect.Location; } @@ -297,11 +323,11 @@ namespace ShiftOS.WinForms.Applications lblmissedout.Text = Localization.Parse("{YOU_MISSED_OUT_ON}:") + Environment.NewLine + lblstatscodepoints.Text.Replace(Localization.Parse("{CODEPOINTS}: "), "") + Localization.Parse(" {CODEPOINTS}"); if (ShiftoriumFrontend.UpgradeInstalled("pong_upgrade_2")) { - totalreward = (ulong)(levelrewards[level - 1] + beatairewardtotal); + totalreward = (levelrewards[level - 1] * (ulong) rwdmultiplier + beatairewardtotal); double onePercent = (totalreward / 100); lblbutyougained.Show(); lblbutyougained.Text = Localization.Parse("{BUT_YOU_GAINED}:") + Environment.NewLine + onePercent.ToString("") + (Localization.Parse(" {CODEPOINTS}")); - SaveSystem.TransferCodepointsFrom("pong", (ulong)(totalreward / 100)); + SaveSystem.TransferCodepointsFrom("pong", (ulong)(onePercent)); } else { @@ -345,7 +371,7 @@ namespace ShiftOS.WinForms.Applications //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 = "X vel: " + xveldec; lblstatsY.Text = "Y vel: " + yveldec; - lblstatscodepoints.Text = "Codepoints: " + (levelrewards[level - 1] + beatairewardtotal).ToString(); + lblstatscodepoints.Text = "Codepoints: " + (levelrewards[level - 1] * (ulong) rwdmultiplier + beatairewardtotal).ToString(); lbllevelandtime.Text = "Level: " + level + " - " + secondsleft + " seconds left"; if (xVel > 20 || xVel < -20) @@ -355,8 +381,7 @@ namespace ShiftOS.WinForms.Applications } else { - paddleHuman.Width = 20; - paddleComputer.Width = 20; + paddleHuman.Width = paddleComputer.Width = 20; } } if (!IsMultiplayerSession) @@ -415,7 +440,7 @@ namespace ShiftOS.WinForms.Applications StartLevel(); })); } - else if(msg.Name == "pong_mp_levelcompleted") + else if (msg.Name == "pong_mp_levelcompleted") { level = Convert.ToInt32(msg.Contents) + 1; this.Invoke(new Action(CompleteLevel)); @@ -434,7 +459,7 @@ namespace ShiftOS.WinForms.Applications pnlmultiplayerhandshake.Hide(); })); } - else if(msg.Name == "pong_mp_cashedout") + else if (msg.Name == "pong_mp_cashedout") { this.Invoke(new Action(() => { @@ -442,19 +467,19 @@ namespace ShiftOS.WinForms.Applications })); Infobox.Show("Cashed out.", "The other player has cashed out their Codepoints. Therefore, we have automatically cashed yours out."); } - else if(msg.Name == "pong_mp_startlevel") + else if (msg.Name == "pong_mp_startlevel") { OpponentAgrees = true; - if(YouAgree == false) + if (YouAgree == false) { - Infobox.PromptYesNo("Play another level?", "The opponent wants to play another level. Would you like to as well?", (answer)=> + Infobox.PromptYesNo("Play another level?", "The opponent wants to play another level. Would you like to as well?", (answer) => { YouAgree = answer; ServerManager.Forward(OpponentGUID, "pong_mp_level_callback", YouAgree.ToString()); }); } } - else if(msg.Name == "pong_mp_level_callback") + else if (msg.Name == "pong_mp_level_callback") { bool agreed = bool.Parse(msg.Contents); OpponentAgrees = agreed; @@ -472,7 +497,7 @@ namespace ShiftOS.WinForms.Applications this.PossibleMatchmakes.Remove(msg.Contents); this.Invoke(new Action(ListMatchmakes)); } - else if(msg.Name == "pong_mp_clockupdate") + else if (msg.Name == "pong_mp_clockupdate") { secondsleft = Convert.ToInt32(msg.Contents); } @@ -566,7 +591,7 @@ namespace ShiftOS.WinForms.Applications public void LoseMP() { ball.Location = new Point(this.Size.Width / 2 + 200, this.Size.Height / 2); - if(IsLeader) + if (IsLeader) if (xVel > 0) xVel = -xVel; lblbeatai.Show(); @@ -634,7 +659,7 @@ namespace ShiftOS.WinForms.Applications CompleteLevel(); } - lblstatscodepoints.Text = "Codepoints: " + (levelrewards[level - 1] + beatairewardtotal).ToString(); + lblstatscodepoints.Text = "Codepoints: " + (levelrewards[level - 1] * (ulong) rwdmultiplier + beatairewardtotal).ToString(); } } SetupStats(); @@ -670,200 +695,56 @@ namespace ShiftOS.WinForms.Applications lblpreviousstats.Text = Localization.Parse("{INITIAL_H_VEL}: " + levelxspeed + Environment.NewLine + "{INITIAL_V_VEL}: " + levelyspeed + Environment.NewLine + "{INC_H_VEL}: " + incrementx + Environment.NewLine + "{INC_V_VEL}: " + incrementy); - switch (rand.Next(1, 3)) - { - case 1: - levelxspeed = levelxspeed + 1; - break; - case 2: - levelxspeed = levelxspeed + 2; - break; - } + levelxspeed += rand.Next(1, 3); - switch (rand.Next(1, 3)) - { - case 1: - levelyspeed = levelyspeed + 1; - break; - case 2: - levelyspeed = levelyspeed + 2; - break; - } + levelyspeed += rand.Next(1, 3); - switch (rand.Next(1, 6)) - { - case 1: - incrementx = incrementx + 0.1; - break; - case 2: - incrementx = incrementx + 0.2; - break; - case 3: - incrementy = incrementy + 0.1; - break; - case 4: - incrementy = incrementy + 0.2; - break; - case 5: - incrementy = incrementy + 0.3; - break; - } + int rndinc = rand.Next(1, 6); + if (rndinc == 5) + incrementy += 0.3; + else + incrementy += (((rndinc - 1) % 2) + 1) / 10; lblnextstats.Text = Localization.Parse("{INITIAL_H_VEL}: " + levelxspeed + Environment.NewLine + "{INITIAL_V_VEL}: " + levelyspeed + Environment.NewLine + "{INC_H_VEL}: " + incrementx + Environment.NewLine + "{INC_V_VEL}: " + incrementy); if (level < 15) { + beataireward = (ulong)(level * 5); if (ShiftoriumFrontend.UpgradeInstalled("pong_upgrade")) - { - beataireward = (ulong)(level * 10); - } else - { - beataireward = (ulong)(level * 5); - } + beataireward *= 2; } else - { if (ShiftoriumFrontend.UpgradeInstalled("pong_upgrade")) - { - double br = levelrewards[level - 1] / 10; - beataireward = (ulong)Math.Round(br) * 10; - } else - { - double br = levelrewards[level - 1] / 10; - beataireward = (ulong)Math.Round(br) * 5; - } - } + beataireward = levelrewards[level - 1]; + else + beataireward = (ulong)Math.Round((double) levelrewards[level - 1] / 2); - totalreward = levelrewards[level - 1] + beatairewardtotal; + totalreward = levelrewards[level - 1] * (ulong) rwdmultiplier + beatairewardtotal; btncashout.Text = Localization.Parse("{CASH_OUT_WITH_CODEPOINTS}"); btnplayon.Text = Localization.Parse("{PONG_PLAY_ON_FOR_MORE}"); } - private void setuplevelrewards() - { - if (ShiftoriumFrontend.UpgradeInstalled("pong_upgrade")) - { - levelrewards[0] = 0; - levelrewards[1] = 40; - levelrewards[2] = 120; - levelrewards[3] = 280; - levelrewards[4] = 580; - levelrewards[5] = 800; - levelrewards[6] = 1200; - levelrewards[7] = 1800; - levelrewards[8] = 2400; - levelrewards[9] = 3200; - levelrewards[10] = 4000; - levelrewards[11] = 5000; - levelrewards[12] = 6000; - levelrewards[13] = 8000; - levelrewards[14] = 10000; - levelrewards[15] = 12000; - levelrewards[16] = 16000; - levelrewards[17] = 20000; - levelrewards[18] = 26000; - levelrewards[19] = 32000; - levelrewards[20] = 40000; - levelrewards[21] = 50000; - levelrewards[22] = 64000; - levelrewards[23] = 80000; - levelrewards[24] = 100000; - levelrewards[25] = 120000; - levelrewards[26] = 150000; - levelrewards[27] = 180000; - levelrewards[28] = 220000; - levelrewards[29] = 280000; - levelrewards[30] = 360000; - levelrewards[31] = 440000; - levelrewards[32] = 540000; - levelrewards[33] = 640000; - levelrewards[34] = 800000; - levelrewards[35] = 1000000; - levelrewards[36] = 1280000; - levelrewards[37] = 1600000; - levelrewards[38] = 2000000; - levelrewards[39] = 3000000; - levelrewards[40] = 4000000; - } else - { - levelrewards[0] = 0; - levelrewards[1] = 20; - levelrewards[2] = 60; - levelrewards[3] = 140; - levelrewards[4] = 290; - levelrewards[5] = 400; - levelrewards[6] = 600; - levelrewards[7] = 900; - levelrewards[8] = 1200; - levelrewards[9] = 1600; - levelrewards[10] = 2000; - levelrewards[11] = 2500; - levelrewards[12] = 3000; - levelrewards[13] = 4000; - levelrewards[14] = 5000; - levelrewards[15] = 6000; - levelrewards[16] = 8000; - levelrewards[17] = 10000; - levelrewards[18] = 13000; - levelrewards[19] = 16000; - levelrewards[20] = 20000; - levelrewards[21] = 25000; - levelrewards[22] = 32000; - levelrewards[23] = 40000; - levelrewards[24] = 50000; - levelrewards[25] = 60000; - levelrewards[26] = 75000; - levelrewards[27] = 90000; - levelrewards[28] = 110000; - levelrewards[29] = 140000; - levelrewards[30] = 180000; - levelrewards[31] = 220000; - levelrewards[32] = 270000; - levelrewards[33] = 320000; - levelrewards[34] = 400000; - levelrewards[35] = 500000; - levelrewards[36] = 640000; - levelrewards[37] = 800000; - levelrewards[38] = 1000000; - levelrewards[39] = 1500000; - levelrewards[40] = 2000000; - } - } - // ERROR: Handles clauses are not supported in C# private void countdown_Tick(object sender, EventArgs e) { if (this.Left < Screen.PrimaryScreen.Bounds.Width) { - switch (countdown) + if (countdown == 0) { - case 0: - countdown = 3; - lblcountdown.Hide(); - lblbeatai.Hide(); - gameTimer.Start(); - counter.Start(); - tmrcountdown.Stop(); - break; - case 1: - lblcountdown.Text = "1"; - countdown = countdown - 1; - ShiftOS.Engine.AudioManager.PlayStream(Properties.Resources.typesound); - break; - case 2: - lblcountdown.Text = "2"; - countdown = countdown - 1; - ShiftOS.Engine.AudioManager.PlayStream(Properties.Resources.typesound); - break; - case 3: - lblcountdown.Text = "3"; - countdown = countdown - 1; - lblcountdown.Show(); - ShiftOS.Engine.AudioManager.PlayStream(Properties.Resources.typesound); - break; + countdown = 3; + lblcountdown.Hide(); + lblbeatai.Hide(); + gameTimer.Start(); + counter.Start(); + tmrcountdown.Stop(); + return; } - + if (!lblcountdown.Visible) + lblcountdown.Show(); + lblcountdown.Text = countdown.ToString(); + countdown -= 1; + playsound(Properties.Resources.typesound); } } @@ -874,7 +755,7 @@ namespace ShiftOS.WinForms.Applications pnlfinalstats.Show(); lblfinalcodepointswithtext.Text = Localization.Parse("{YOU_WON} " + totalreward + " {CODEPOINTS}!"); lblfinallevelreached.Text = Localization.Parse("{CODEPOINTS_FOR_BEATING_LEVEL}: ") + (level - 1).ToString(); - lblfinallevelreward.Text = levelrewards[level - 1].ToString(); + lblfinallevelreward.Text = (levelrewards[level - 1] * rwdmultiplier).ToString(); lblfinalcomputerreward.Text = beatairewardtotal.ToString(); lblfinalcodepoints.Text = totalreward + Localization.Parse(" {CODEPOINTS_SHORT}"); SaveSystem.TransferCodepointsFrom("pong", totalreward); @@ -912,7 +793,8 @@ namespace ShiftOS.WinForms.Applications if (ShiftoriumFrontend.UpgradeInstalled("pong_upgrade")) { beataireward = 10; - } else + } + else { beataireward = 5; } @@ -981,7 +863,7 @@ namespace ShiftOS.WinForms.Applications var hs = unite.GetPongHighscores(); foreach (var score in hs.Highscores) { - if(this.ParentForm.Visible == false) + if (this.ParentForm.Visible == false) { Thread.CurrentThread.Abort(); } @@ -1000,7 +882,7 @@ namespace ShiftOS.WinForms.Applications { try { - if (this.ParentForm.Visible == true) + if (this.ParentForm.Visible) { Infobox.Show("Service unavailable.", "The Pong Highscore service is unavailable at this time."); this.Invoke(new Action(pnlgamestats.BringToFront)); @@ -1030,7 +912,7 @@ namespace ShiftOS.WinForms.Applications { newgame(); } - + // ERROR: Handles clauses are not supported in C# private void btnstartgame_Click(object sender, EventArgs e) { @@ -1045,9 +927,7 @@ namespace ShiftOS.WinForms.Applications int i = rand.Next(0, 100); if (i >= 25 && i <= 50) - { tmrstoryline.Stop(); - } } @@ -1057,25 +937,13 @@ namespace ShiftOS.WinForms.Applications tmrstoryline.Stop(); } - private void Label6_Click(object sender, EventArgs e) - { - - } - - private void Label8_Click(object sender, EventArgs e) + private void ball_MouseEnter(object sender, EventArgs e) { - - } - - private void pgcontents_Paint(object sender, PaintEventArgs e) { - - } - - private void ball_MouseEnter(object sender, EventArgs e) { aiShouldIsbeEnabled = false; } - private void ball_MouseLeave(object sender, EventArgs e) { + private void ball_MouseLeave(object sender, EventArgs e) + { aiShouldIsbeEnabled = true; } @@ -1102,9 +970,9 @@ namespace ShiftOS.WinForms.Applications public bool OnUnload() { - if(IsMultiplayerSession == true) + if (IsMultiplayerSession) { - if(!string.IsNullOrWhiteSpace(OpponentGUID)) + if (!string.IsNullOrWhiteSpace(OpponentGUID)) ServerManager.Forward(OpponentGUID, "pong_mp_left", null); LeaveMatchmake(); } @@ -1134,10 +1002,10 @@ namespace ShiftOS.WinForms.Applications private void lvotherplayers_DoubleClick(object sender, EventArgs e) { - if(lvotherplayers.SelectedItems.Count > 0) + if (lvotherplayers.SelectedItems.Count > 0) { SendLeaderGUID(lvotherplayers.SelectedItems[0].Text); } } } -} +} \ No newline at end of file diff --git a/ShiftOS.WinForms/Applications/Pong.resx b/ShiftOS.WinForms/Applications/Pong.resx index 3b5619d..cc96099 100644 --- a/ShiftOS.WinForms/Applications/Pong.resx +++ b/ShiftOS.WinForms/Applications/Pong.resx @@ -129,4 +129,7 @@ 17, 17 + + 472, 17 + \ No newline at end of file -- cgit v1.2.3 From 11e80a6a6134e2cbee1041d6ddc95781a265bead Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 2 Jun 2017 11:38:38 -0400 Subject: fix the audio system --- ShiftOS.Objects/Save.cs | 6 ++-- ShiftOS.WinForms/AudioManager.cs | 51 +++++++++++++++++++++++--------- ShiftOS_TheReturn/AudioManager.cs | 61 +++++++++++++++++++++++++-------------- ShiftOS_TheReturn/Commands.cs | 40 +++++++++++++++++++------ 4 files changed, 111 insertions(+), 47 deletions(-) (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.Objects/Save.cs b/ShiftOS.Objects/Save.cs index 0fef7b3..cbd77e2 100644 --- a/ShiftOS.Objects/Save.cs +++ b/ShiftOS.Objects/Save.cs @@ -34,9 +34,9 @@ namespace ShiftOS.Objects //Better to store this stuff server-side so we can do some neat stuff with hacking... public class Save { - - public int MusicVolume { get; set; } - public int SfxVolume { get; set; } + public bool MusicEnabled = true; + public bool SoundEnabled = true; + public int MusicVolume = 100; [Obsolete("This save variable is no longer used in Beta 2.4 and above of ShiftOS. Please use ShiftOS.Engine.SaveSystem.CurrentUser.Username to access the current user's username.")] public string Username { get; set; } diff --git a/ShiftOS.WinForms/AudioManager.cs b/ShiftOS.WinForms/AudioManager.cs index ec12614..afa0d78 100644 --- a/ShiftOS.WinForms/AudioManager.cs +++ b/ShiftOS.WinForms/AudioManager.cs @@ -88,23 +88,46 @@ namespace ShiftOS.WinForms }; while (shuttingDown == false) { - str = new MemoryStream(GetRandomSong()); - mp3 = new NAudio.Wave.Mp3FileReader(str); - o = new NAudio.Wave.WaveOut(); - o.Init(mp3); - bool c = false; - o.Play(); - o.PlaybackStopped += (s, a) => + if (Engine.SaveSystem.CurrentSave != null) { - c = true; - }; - while (!c) - { - try + if (Engine.SaveSystem.CurrentSave.MusicEnabled) + { + str = new MemoryStream(GetRandomSong()); + mp3 = new NAudio.Wave.Mp3FileReader(str); + o = new NAudio.Wave.WaveOut(); + o.Init(mp3); + bool c = false; + o.Play(); + o.PlaybackStopped += (s, a) => + { + c = true; + }; + + while (!c) + { + if (Engine.SaveSystem.CurrentSave.MusicEnabled) + { + try + { + o.Volume = (float)Engine.SaveSystem.CurrentSave.MusicVolume / 100; + } + catch { } + } + else + { + o.Stop(); + c = true; + } + Thread.Sleep(10); + } + } + else { - o.Volume = (float)Engine.SaveSystem.CurrentSave.MusicVolume / 100; + Thread.Sleep(10); } - catch { } + } + else + { Thread.Sleep(10); } } diff --git a/ShiftOS_TheReturn/AudioManager.cs b/ShiftOS_TheReturn/AudioManager.cs index 553a1d9..0a1a210 100644 --- a/ShiftOS_TheReturn/AudioManager.cs +++ b/ShiftOS_TheReturn/AudioManager.cs @@ -83,21 +83,28 @@ namespace ShiftOS.Engine /// The file to play. public static void Play(string file) { - try + bool play = true; + float volume = 1f; + if (SaveSystem.CurrentSave != null) { - _reader = new AudioFileReader(file); - _out = new WaveOut(); - _out.Init(_reader); - _out.Play(); - if (SaveSystem.CurrentSave == null) - _out.Volume = 1.0f; - else - _out.Volume = (float)SaveSystem.CurrentSave.MusicVolume / 100; - _out.PlaybackStopped += (o, a) => { PlayCompleted?.Invoke(); }; + play = (SaveSystem.CurrentSave.SoundEnabled); + volume = (float)SaveSystem.CurrentSave.MusicVolume / 100f; } - catch(Exception ex) + if (play) { - Console.WriteLine("Audio error: " + ex.Message); + try + { + _reader = new AudioFileReader(file); + _out = new WaveOut(); + _out.Init(_reader); + _out.Volume = volume; + _out.Play(); + _out.PlaybackStopped += (o, a) => { PlayCompleted?.Invoke(); }; + } + catch (Exception ex) + { + Console.WriteLine("Audio error: " + ex.Message); + } } } @@ -107,15 +114,27 @@ namespace ShiftOS.Engine /// The stream to read from. public static void PlayStream(Stream str) { - var bytes = new byte[str.Length]; - str.Read(bytes, 0, bytes.Length); - ShiftOS.Engine.AudioManager.Stop(); - if (File.Exists("snd.wav")) - File.Delete("snd.wav"); - File.WriteAllBytes("snd.wav", bytes); - - ShiftOS.Engine.AudioManager.Play("snd.wav"); - + try + { + bool play = true; + float volume = 1f; + if (SaveSystem.CurrentSave != null) + { + play = (SaveSystem.CurrentSave.SoundEnabled); + volume = (float)SaveSystem.CurrentSave.MusicVolume / 100f; + } + if (play) + { + ShiftOS.Engine.AudioManager.Stop(); + _out = new WaveOut(); + var mp3 = new WaveFileReader(str); + _out.Init(mp3); + _out.Volume = volume; + _out.Play(); + _out.PlaybackStopped += (o, a) => { PlayCompleted?.Invoke(); }; + } + } + catch { } } public static event Action PlayCompleted; diff --git a/ShiftOS_TheReturn/Commands.cs b/ShiftOS_TheReturn/Commands.cs index ec89539..e379a50 100644 --- a/ShiftOS_TheReturn/Commands.cs +++ b/ShiftOS_TheReturn/Commands.cs @@ -383,26 +383,48 @@ namespace ShiftOS.Engine [Namespace("sos")] public static class ShiftOSCommands { - [Command("setsfxvolume", description = "Set the volume of various sound effects to a value between 1 and 100.")] + + [Command("setsfxenabled", description = "Set whether or not sound effects are enabled in the system.")] [RequiresArgument("value")] - public static bool SetSfxVolume(Dictionary args) + public static bool SetSfxEnabled(Dictionary args) { - int value = int.Parse(args["value"].ToString()); - if (value >= 0 && value <= 100) + try { - SaveSystem.CurrentSave.SfxVolume = value; + bool value = Convert.ToBoolean(args["value"].ToString()); + SaveSystem.CurrentSave.SoundEnabled = value; SaveSystem.SaveGame(); } - else + catch { - Console.WriteLine("Volume must be between 0 and 100!"); + Console.WriteLine("Error: Value must be either true or false."); } return true; } - [Command("setmusicvolume", description ="Set the music volume to a value between 1 and 100.")] + + + [Command("setmusicenabled", description = "Set whether or not music is enabled in the system.")] [RequiresArgument("value")] - public static bool SetMusicVolume(Dictionary args) + public static bool SetMusicEnabled(Dictionary args) + { + try + { + bool value = Convert.ToBoolean(args["value"].ToString()); + SaveSystem.CurrentSave.MusicEnabled = value; + SaveSystem.SaveGame(); + } + catch + { + Console.WriteLine("Error: Value must be either true or false."); + } + return true; + } + + + + [Command("setsfxvolume", description ="Set the system sound volume to a value between 1 and 100.")] + [RequiresArgument("value")] + public static bool SetSfxVolume(Dictionary args) { int value = int.Parse(args["value"].ToString()); if(value >= 0 && value <= 100) -- cgit v1.2.3 From 719f2e4170e0a42ca372ff142e5b9613177db1be Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 2 Jun 2017 21:06:31 -0400 Subject: Rebalance shiftnet subscriptions --- ShiftOS.WinForms/Applications/Shiftnet.cs | 2 +- ShiftOS.WinForms/Resources/ShiftnetServices.txt | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.WinForms/Applications/Shiftnet.cs b/ShiftOS.WinForms/Applications/Shiftnet.cs index 22b53a0..6ccdb19 100644 --- a/ShiftOS.WinForms/Applications/Shiftnet.cs +++ b/ShiftOS.WinForms/Applications/Shiftnet.cs @@ -173,7 +173,7 @@ namespace ShiftOS.WinForms.Applications var obj = (IShiftnetSite)Activator.CreateInstance(type, null); obj.GoToUrl += (u) => { - History.Push(u); + History.Push(CurrentUrl); NavigateToUrl(u); }; obj.GoBack += () => diff --git a/ShiftOS.WinForms/Resources/ShiftnetServices.txt b/ShiftOS.WinForms/Resources/ShiftnetServices.txt index d8582b6..fa3988b 100644 --- a/ShiftOS.WinForms/Resources/ShiftnetServices.txt +++ b/ShiftOS.WinForms/Resources/ShiftnetServices.txt @@ -11,21 +11,22 @@ With Freebie Solutions from ShiftSoft, you'll be able to traverse the Shiftnet w { Company: "Shiftcast", Name: "NetXtreme Hyper Edition", - CostPerMonth: 1500, + CostPerMonth: 150, DownloadSpeed: 524288, //512 kb/s Description: "It's time to supercharge your Shiftnet experience. With all the multimedia available, fast download speeds are a must on the Shiftnet. Start your subscription today for the low price of 1500 Codepoints and become a hyper-traveller today." }, { - Company: "Plumb Corp.", - Name: "youConnect", - CostPerMonth: 6000, + Company: "Bit Communications", + Name: "EncoderNet", + CostPerMonth: 600, DownloadSpeed: 1048576, //1 mb/s + Description: "The most reliable service provider on the Shiftnet." }, { - Company: "theCorp", - Name: "theNet", - CostPerMonth: 3000, + Company: "SOL Communications", + Name: "ShiftOS Online", + CostPerMonth: 300, DownloadSpeed: 786342, //768 kb/s - Description: "theNet is not *just* a Shiftnet service provider. It is theGateway to all of theShiftnet and your needs. It is also theValue service provider with theGreatest price and download speed." + Description: "SOL is the Shiftnet." }, ] \ No newline at end of file -- cgit v1.2.3 From cc55af0c8b4d14053bfb46ec14c3e1887d375f7d Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 3 Jun 2017 09:16:44 -0400 Subject: story objectives system --- ShiftOS.WinForms/ShiftOS.WinForms.csproj | 1 + ShiftOS.WinForms/Stories/DevXSkinningStory.cs | 99 ++++++++++++++++++++++++ ShiftOS_TheReturn/Commands.cs | 15 +++- ShiftOS_TheReturn/Story.cs | 104 +++++++++++++++++++++++++- 4 files changed, 215 insertions(+), 4 deletions(-) create mode 100644 ShiftOS.WinForms/Stories/DevXSkinningStory.cs (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.WinForms/ShiftOS.WinForms.csproj b/ShiftOS.WinForms/ShiftOS.WinForms.csproj index 0a59c00..e1afa84 100644 --- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj +++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj @@ -427,6 +427,7 @@ Volume.cs + diff --git a/ShiftOS.WinForms/Stories/DevXSkinningStory.cs b/ShiftOS.WinForms/Stories/DevXSkinningStory.cs new file mode 100644 index 0000000..09dfd7f --- /dev/null +++ b/ShiftOS.WinForms/Stories/DevXSkinningStory.cs @@ -0,0 +1,99 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using ShiftOS.Engine; + +namespace ShiftOS.WinForms.Stories +{ + public class DevXSkinningStory + { + [Story("devx_1000_codepoints")] + public static void DevX1000CPStory() + { + Desktop.InvokeOnWorkerThread(() => + { + var t = new Applications.Terminal(); + AppearanceManager.SetupWindow(t); + }); + TerminalBackend.InStory = true; + TerminalBackend.PrefixEnabled = false; + Thread.Sleep(3000); + Engine.AudioManager.PlayStream(Properties.Resources._3beepvirus); + Console.WriteLine("devx@anon_127420: Connection established."); + Thread.Sleep(1500); + Console.WriteLine("DevX: Hello, " + SaveSystem.CurrentUser.Username + "@" + SaveSystem.CurrentSave.SystemName + "! I see you've gotten a decent amount of Codepoints."); + Thread.Sleep(2000); + Console.WriteLine("DevX: Have you gotten a chance to install my \"Shifter\" application yet?"); + Thread.Sleep(1500); + if (!Shiftorium.UpgradeInstalled("shifter")) + { + Console.WriteLine("You: Not yet. What's it for?"); + Thread.Sleep(2000); + Console.WriteLine("DevX: The Shifter is a very effective way to make ShiftOS look however you want it to."); + Thread.Sleep(2000); + Console.WriteLine("DevX: It can even be adapted to support other applications, features and upgrades."); + Thread.Sleep(2000); + } + else + { + Console.WriteLine("You: Yeah. Just seems kinda lackluster to me. What is it supposed to do?"); + Thread.Sleep(2000); + Console.WriteLine("DevX: The Shifter is a very effective way to make ShiftOS look however you want it to."); + Thread.Sleep(2000); + Console.WriteLine("DevX: It can even be adapted to support other applications, features and upgrades."); + Thread.Sleep(2000); + Console.WriteLine("DevX: I haven't finished it just yet. Keep upgrading it and you'll notice it gets a lot better."); + Thread.Sleep(2000); + } + Console.WriteLine("DevX: I'd also recommend going for the Skin Loader, that way you can save your creations to the disk. Also, go for the Skinning upgrade - which will allow more rich customization of certain elements."); + Thread.Sleep(2000); + Console.WriteLine("You: This still ain't gonna help me get back to my old system and out of this stupid Digital Society, is it?"); + Thread.Sleep(2000); + Console.WriteLine("DevX: How the...How do you know about the Digital Societ....Who the hell talked!?"); + Thread.Sleep(2000); + Console.WriteLine("You: Whoa! Just... calm down, will ya? I heard about it in the news, shortly before I got infected by this damn virus of an operating system."); + Thread.Sleep(2000); + Console.WriteLine("DevX: Whatever. That doesn't matter yet. Just focus on upgrading ShiftOS and earning Codepoints. I'll let you know when we're done. I've gotta go...work on something else."); + Thread.Sleep(1500); + Console.WriteLine("User disconnected."); + Thread.Sleep(2000); + Console.WriteLine("You: Something doesn't seem right about DevX. I wonder what he's really up to."); + + if (Shiftorium.UpgradeInstalled("shifter")) + PushObjectives(); + else + Story.PushObjective("Buy the Shifter.", "The Shifter is a super-effective way to earn more Codepoints. It is an essential buy if you haven't already bought it. Save up for the Shifter, and buy it using shiftorium.buy{upgrade:\"shifter\"}.", () => + { + return Shiftorium.UpgradeInstalled("shifter"); + }, () => + { + PushObjectives(); + }); + Story.Context.AutoComplete = false; + TerminalBackend.InStory = false; + TerminalBackend.PrefixEnabled = false; + TerminalBackend.PrintPrompt(); + } + + public static void PushObjectives() + { + Story.PushObjective("Buy the Skinning upgrade", "The Skinning upgrade will allow you to set pictures in place of solid colors for most UI elements. If you want richer customization and more Codepoints, this upgrade is a necessity.", () => + { + return Shiftorium.UpgradeInstalled("skinning"); + }, ()=> + { + Story.PushObjective("Buy the Skin Loader.", "The Skin Loader is an application that allows you to save and load .skn files containing Shifter skin data. These files can be loaded in to the Skin Loader and applied to the system to give ShiftOS a completely different feel. It's Shiftorium upgrade ID is \"skin_loader\".", () => + { + return Shiftorium.UpgradeInstalled("skin_loader"); + }, + () => + { + Story.Context.MarkComplete(); + }); + }); + } + } +} diff --git a/ShiftOS_TheReturn/Commands.cs b/ShiftOS_TheReturn/Commands.cs index e379a50..72bccb1 100644 --- a/ShiftOS_TheReturn/Commands.cs +++ b/ShiftOS_TheReturn/Commands.cs @@ -533,11 +533,20 @@ namespace ShiftOS.Engine Codepoints: {SaveSystem.CurrentSave.Codepoints} Upgrades: {SaveSystem.CurrentSave.CountUpgrades()} installed, - {Shiftorium.GetAvailable().Length} available"; + {Shiftorium.GetAvailable().Length} available + +"; - if (Shiftorium.UpgradeInstalled("mud_control_centre")) - status += Environment.NewLine + $"Reputation: {SaveSystem.CurrentSave.RawReputation} ({SaveSystem.CurrentSave.Reputation})"; Console.WriteLine(status); + + if(Story.CurrentObjective != null) + { + Console.WriteLine("CURRENT OBJECTIVE: " + Story.CurrentObjective.Name); + Console.WriteLine("-------------------------------"); + Console.WriteLine(); + Console.WriteLine(Story.CurrentObjective.Description); + } + return true; } } diff --git a/ShiftOS_TheReturn/Story.cs b/ShiftOS_TheReturn/Story.cs index d62dae4..848c757 100644 --- a/ShiftOS_TheReturn/Story.cs +++ b/ShiftOS_TheReturn/Story.cs @@ -35,11 +35,100 @@ using Newtonsoft.Json; namespace ShiftOS.Engine { + public class StoryContext + { + public string Id { get; set; } + public MethodInfo Method { get; set; } + public bool AutoComplete = false; + + public StoryContext() + { + AutoComplete = true; + } + + public void MarkComplete() + { + SaveSystem.CurrentSave.StoriesExperienced.Add(Id); + OnComplete?.Invoke(); + } + + public event Action OnComplete; + } + + public class Objective + { + private Func _completeFunc = null; + + public string Name { get; set; } + public string Description { get; set; } + + public bool IsComplete + { + get + { + return (bool)_completeFunc?.Invoke(); + } + } + + public Objective(string name, string desc, Func completeFunc, Action onComplete) + { + _completeFunc = completeFunc; + Name = name; + Description = desc; + this.onComplete = onComplete; + } + + private Action onComplete = null; + + public void Complete() + { + onComplete?.Invoke(); + } + } + /// /// Storyline management class. /// public static class Story { + public static StoryContext Context { get; private set; } + public static event Action StoryComplete; + public static Objective CurrentObjective { get; private set; } + + public static void PushObjective(string name, string desc, Func completeFunc, Action onComplete) + { + if (CurrentObjective != null) + { + if (CurrentObjective.IsComplete == false) + { + throw new Exception("Cannot start objective - an objective is already running."); + } + else + { + CurrentObjective = null; + } + } + + CurrentObjective = new Objective(name, desc, completeFunc, onComplete); + + var t = new Thread(() => + { + var obj = CurrentObjective; + while (!obj.IsComplete) + { + Thread.Sleep(5000); + } + obj.Complete(); + CurrentObjective = null; + }); + t.IsBackground = true; + t.Start(); + + Console.WriteLine("NEW OBJECTIVE:"); + Console.WriteLine("A new objective has been added to your system. Run sos.status to find out what you need to do."); + } + + /// /// Starts the storyline with the specified Storyline ID. /// @@ -68,8 +157,21 @@ namespace ShiftOS.Engine { new Thread(() => { + Context = new Engine.StoryContext + { + Id = stid, + Method = mth, + AutoComplete = true, + }; + Context.OnComplete += () => + { + StoryComplete?.Invoke(stid); + }; mth.Invoke(null, null); - SaveSystem.CurrentSave.StoriesExperienced.Add(stid); + if (Context.AutoComplete) + { + Context.MarkComplete(); + } }).Start(); return; } -- cgit v1.2.3 From 7fe5d790dc9d73056e86af8116ba4db9674fd612 Mon Sep 17 00:00:00 2001 From: RogueAI42 Date: Sun, 4 Jun 2017 01:29:21 +1000 Subject: fixed shiftorium just in time for chrimbus --- ShiftOS.Objects/Save.cs | 75 +++++++-- .../Applications/ShiftoriumFrontend.Designer.cs | 3 - .../Applications/ShiftoriumFrontend.cs | 186 ++++++++------------- ShiftOS_TheReturn/SaveSystem.cs | 11 +- 4 files changed, 136 insertions(+), 139 deletions(-) (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.Objects/Save.cs b/ShiftOS.Objects/Save.cs index cbd77e2..e0282e8 100644 --- a/ShiftOS.Objects/Save.cs +++ b/ShiftOS.Objects/Save.cs @@ -26,8 +26,7 @@ using System; using System.Collections.Generic; using System.Dynamic; using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Threading; namespace ShiftOS.Objects { @@ -41,33 +40,77 @@ namespace ShiftOS.Objects [Obsolete("This save variable is no longer used in Beta 2.4 and above of ShiftOS. Please use ShiftOS.Engine.SaveSystem.CurrentUser.Username to access the current user's username.")] public string Username { get; set; } - private ulong _cp = 0; + private List _setCpCallbacks = new List(); // everything in this list is called by Codepoints.set() and syncCp(). + private ulong _cp = 0; // locally cached codepoints counter + private Object _cpLock = new Object(); // locked when modifying or reading the codepoints counter + private Object _webLock = new Object(); // locked when communicating with the server + private Timer _updTimer; // timer to start a new sync thread every 5 minutes + + // Sync local Codepoints count with the server. + public void syncCp() + { + new Thread(() => + { + lock (_cpLock) + { + lock (_webLock) + { + var uc = new ShiftOS.Unite.UniteClient("", UniteAuthToken); + _cp = uc.GetCodepoints(); + } + } + foreach (Action a in _setCpCallbacks) + a(); + }).Start(); + } + + // we have to write these wrapper functions so we can keep _setCpCallbacks private, + // so that it doesn't get serialised + public void addSetCpCallback(Action callback) + { + _setCpCallbacks.Add(callback); + } + + public void removeSetCpCallback(Action callback) + { + _setCpCallbacks.Remove(callback); + } public ulong Codepoints { get { - try - { - var uc = new ShiftOS.Unite.UniteClient("", UniteAuthToken); - return uc.GetCodepoints(); - } - catch + if (_updTimer == null) + _updTimer = new Timer((o) => syncCp(), null, 0, 300000); + lock (_cpLock) { return _cp; } } set { - try + lock (_cpLock) + { + _cp = value; + new Thread(() => { - var uc = new ShiftOS.Unite.UniteClient("", UniteAuthToken); - uc.SetCodepoints(value); - } - catch + lock (_webLock) + { + try + { + var uc = new ShiftOS.Unite.UniteClient("", UniteAuthToken); + uc.SetCodepoints(value); + } + catch + { } + } + }) { - _cp = value; - } + IsBackground = false + }.Start(); + } + foreach (Action a in _setCpCallbacks) + a(); } } diff --git a/ShiftOS.WinForms/Applications/ShiftoriumFrontend.Designer.cs b/ShiftOS.WinForms/Applications/ShiftoriumFrontend.Designer.cs index dc107c4..e4e493e 100644 --- a/ShiftOS.WinForms/Applications/ShiftoriumFrontend.Designer.cs +++ b/ShiftOS.WinForms/Applications/ShiftoriumFrontend.Designer.cs @@ -189,7 +189,6 @@ namespace ShiftOS.WinForms.Applications this.lblcategorytext.TabIndex = 2; this.lblcategorytext.Text = "No Upgrades"; this.lblcategorytext.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.lblcategorytext.Click += new System.EventHandler(this.lblcategorytext_Click); // // btncat_forward // @@ -226,7 +225,6 @@ namespace ShiftOS.WinForms.Applications this.lbcodepoints.Size = new System.Drawing.Size(135, 13); this.lbcodepoints.TabIndex = 3; this.lbcodepoints.Text = "You have: %cp Codepoints"; - this.lbcodepoints.Click += new System.EventHandler(this.lbcodepoints_Click); // // label1 // @@ -280,7 +278,6 @@ namespace ShiftOS.WinForms.Applications this.ForeColor = System.Drawing.Color.LightGreen; this.Name = "ShiftoriumFrontend"; this.Size = new System.Drawing.Size(782, 427); - this.Load += new System.EventHandler(this.Shiftorium_Load); this.panel1.ResumeLayout(false); this.panel2.ResumeLayout(false); this.pnlupgradeactions.ResumeLayout(false); diff --git a/ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs b/ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs index d6b014d..0ae0803 100644 --- a/ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs +++ b/ShiftOS.WinForms/Applications/ShiftoriumFrontend.cs @@ -47,19 +47,22 @@ namespace ShiftOS.WinForms.Applications public partial class ShiftoriumFrontend : UserControl, IShiftOSWindow { public int CategoryId = 0; - public static System.Timers.Timer timer100; + private string[] cats = backend.GetCategories(); + private ShiftoriumUpgrade[] avail; + public void updatecounter() + { + Desktop.InvokeOnWorkerThread(() => { lbcodepoints.Text = $"You have {SaveSystem.CurrentSave.Codepoints} Codepoints."; }); + } + public ShiftoriumFrontend() { - cp_update = new System.Windows.Forms.Timer(); - cp_update.Tick += (o, a) => - { - lbcodepoints.Text = $"You have {SaveSystem.CurrentSave.Codepoints} Codepoints."; - }; - cp_update.Interval = 100; InitializeComponent(); - PopulateShiftorium(); + SaveSystem.CurrentSave.addSetCpCallback(updatecounter); + updatecounter(); + Populate(); + SetList(); lbupgrades.SelectedIndexChanged += (o, a) => { try @@ -82,84 +85,57 @@ namespace ShiftOS.WinForms.Applications public void SelectUpgrade(string name) { btnbuy.Show(); - var upg = upgrades[name]; + var upg = upgrades[CategoryId][name]; lbupgradetitle.Text = Localization.Parse(upg.Name); lbupgradedesc.Text = Localization.Parse(upg.Description); } - Dictionary upgrades = new Dictionary(); - - public void PopulateShiftorium() + Dictionary[] upgrades; + + private void Populate() { - var t = new Thread(() => + upgrades = new Dictionary[cats.Length]; + int numComplete = 0; + avail = backend.GetAvailable(); + foreach (var it in cats.Select((catName, catId) => new { catName, catId })) { - try + var upl = new Dictionary(); + upgrades[it.catId] = upl; + var t = new Thread((tupobj) => { - Desktop.InvokeOnWorkerThread(() => - { - lbnoupgrades.Hide(); - lbupgrades.Items.Clear(); - upgrades.Clear(); - Timer(); - }); - - foreach (var upg in backend.GetAvailable().Where(x => x.Category == backend.GetCategories()[CategoryId])) - { - string name = Localization.Parse(upg.Name) + " - " + upg.Cost.ToString() + "CP"; - upgrades.Add(name, upg); - Desktop.InvokeOnWorkerThread(() => - { - lbupgrades.Items.Add(name); - }); - } - - if (lbupgrades.Items.Count == 0) - { - Desktop.InvokeOnWorkerThread(() => - { - lbnoupgrades.Show(); - lbnoupgrades.Location = new Point( - (lbupgrades.Width - lbnoupgrades.Width) / 2, - lbupgrades.Top + (lbupgrades.Height - lbnoupgrades.Height) / 2 - ); - }); - } - else - { - Desktop.InvokeOnWorkerThread(() => - { - lbnoupgrades.Hide(); - }); - } - - Desktop.InvokeOnWorkerThread(() => - { - try - { - lblcategorytext.Text = Shiftorium.GetCategories()[CategoryId]; - btncat_back.Visible = (CategoryId > 0); - btncat_forward.Visible = (CategoryId < backend.GetCategories().Length - 1); - } - catch - { + foreach (var upg in avail.Where(x => x.Category == it.catName)) + upl.Add(Localization.Parse(upg.Name) + " - " + upg.Cost.ToString() + "CP", upg); + numComplete++; + }); + t.Start(); + } + while (numComplete < cats.Length) { } // wait for all threads to finish their job + } - } - }); - } - catch - { - Desktop.InvokeOnWorkerThread(() => - { - lbnoupgrades.Show(); - lbnoupgrades.Location = new Point( - (lbupgrades.Width - lbnoupgrades.Width) / 2, - lbupgrades.Top + (lbupgrades.Height - lbnoupgrades.Height) / 2 - ); - }); - } - }); - t.IsBackground = true; - t.Start(); + private void SetList() + { + lbnoupgrades.Hide(); + lbupgrades.Items.Clear(); + try + { + lbupgrades.Items.AddRange(upgrades[CategoryId].Keys.ToArray()); + } + catch + { + Engine.Infobox.Show("Shiftorium Machine Broke", "Category ID " + CategoryId.ToString() + " is invalid, modulo is broken, and the world is doomed. Please tell Declan about this."); + return; + } + if (lbupgrades.Items.Count == 0) + { + lbnoupgrades.Show(); + lbnoupgrades.Location = new Point( + (lbupgrades.Width - lbnoupgrades.Width) / 2, + lbupgrades.Top + (lbupgrades.Height - lbnoupgrades.Height) / 2 + ); + } + else + lbnoupgrades.Hide(); + lblcategorytext.Text = cats[CategoryId]; } public static bool UpgradeInstalled(string upg) @@ -218,8 +194,9 @@ namespace ShiftOS.WinForms.Applications Dictionary UpgradesToBuy = new Dictionary(); foreach (var itm in lbupgrades.SelectedItems) { - cpCost += upgrades[itm.ToString()].Cost; - UpgradesToBuy.Add(upgrades[itm.ToString()].ID, upgrades[itm.ToString()].Cost); + var upg = upgrades[CategoryId][itm.ToString()]; + cpCost += upg.Cost; + UpgradesToBuy.Add(upg.ID, upg.Cost); } if (SaveSystem.CurrentSave.Codepoints < cpCost) { @@ -230,7 +207,6 @@ namespace ShiftOS.WinForms.Applications { foreach(var upg in UpgradesToBuy) { - SaveSystem.CurrentSave.Codepoints -= upg.Value; if (SaveSystem.CurrentSave.Upgrades.ContainsKey(upg.Key)) { SaveSystem.CurrentSave.Upgrades[upg.Key] = true; @@ -242,20 +218,15 @@ namespace ShiftOS.WinForms.Applications SaveSystem.SaveGame(); backend.InvokeUpgradeInstalled(); } + SaveSystem.CurrentSave.Codepoints -= cpCost; } backend.Silent = false; - PopulateShiftorium(); btnbuy.Hide(); } - private void Shiftorium_Load(object sender, EventArgs e) { - - } - public void OnLoad() { - cp_update.Start(); lbnoupgrades.Hide(); } @@ -264,12 +235,9 @@ namespace ShiftOS.WinForms.Applications } - System.Windows.Forms.Timer cp_update = new System.Windows.Forms.Timer(); - public bool OnUnload() { - cp_update.Stop(); - cp_update = null; + SaveSystem.CurrentSave.removeSetCpCallback(updatecounter); return true; } @@ -277,44 +245,26 @@ namespace ShiftOS.WinForms.Applications { lbupgrades.SelectionMode = (UpgradeInstalled("shiftorium_gui_bulk_buy") == true) ? SelectionMode.MultiExtended : SelectionMode.One; lbcodepoints.Visible = Shiftorium.UpgradeInstalled("shiftorium_gui_codepoints_display"); + Populate(); + SetList(); } - private void lbcodepoints_Click(object sender, EventArgs e) + private void moveCat(short direction) // direction is -1 to move backwards or 1 to move forwards { - - } - - void Timer() - { - timer100 = new System.Timers.Timer(); - timer100.Interval = 2000; - //CLARIFICATION: What is this supposed to do? - Michael - //timer100.Elapsed += ???; - timer100.AutoReset = true; - timer100.Enabled = true; + CategoryId += direction; + CategoryId %= cats.Length; + if (CategoryId < 0) CategoryId += cats.Length; // fix modulo on negatives + SetList(); } private void btncat_back_Click(object sender, EventArgs e) { - if(CategoryId > 0) - { - CategoryId--; - PopulateShiftorium(); - } + moveCat(-1); } private void btncat_forward_Click(object sender, EventArgs e) { - if(CategoryId < backend.GetCategories().Length - 1) - { - CategoryId++; - PopulateShiftorium(); - } - } - - private void lblcategorytext_Click(object sender, EventArgs e) - { - + moveCat(1); } } } diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index 395db85..155f002 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -570,8 +570,15 @@ namespace ShiftOS.Engine Console.Write("{SE_SAVING}... "); if (SaveSystem.CurrentSave != null) { - Utils.WriteAllText(Paths.GetPath("user.dat"), CurrentSave.UniteAuthToken); - ServerManager.SendMessage("mud_save", JsonConvert.SerializeObject(CurrentSave, Formatting.Indented)); + Utils.WriteAllText(Paths.GetPath("user.dat"), CurrentSave.UniteAuthToken); + var serialisedSaveFile = JsonConvert.SerializeObject(CurrentSave, Formatting.Indented); + new Thread(() => + { + // please don't do networking on the main thread if you're just going to + // discard the response, it's extremely slow + ServerManager.SendMessage("mud_save", serialisedSaveFile); + }) + { IsBackground = false }.Start(); } if (!Shiftorium.Silent) Console.WriteLine(" ...{DONE}."); -- cgit v1.2.3 From 69aba3b373f9c9c70ec4ef2250e71465d3327299 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 4 Jun 2017 15:18:53 -0400 Subject: A fuckton of storyline features. --- ShiftOS.Objects/Save.cs | 5 ++ ShiftOS.WinForms/Applications/Terminal.cs | 82 ++++++++++++++++- ShiftOS.WinForms/Commands.cs | 1 - ShiftOS.WinForms/Oobe.cs | 6 +- ShiftOS.WinForms/Stories/LegionStory.cs | 144 +++++++++++++++++++++--------- ShiftOS.WinForms/Tools/ControlManager.cs | 12 ++- ShiftOS_TheReturn/Commands.cs | 27 ++++-- ShiftOS_TheReturn/SaveSystem.cs | 10 +++ ShiftOS_TheReturn/Story.cs | 25 ++---- 9 files changed, 239 insertions(+), 73 deletions(-) (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.Objects/Save.cs b/ShiftOS.Objects/Save.cs index e0282e8..7891a22 100644 --- a/ShiftOS.Objects/Save.cs +++ b/ShiftOS.Objects/Save.cs @@ -173,6 +173,11 @@ namespace ShiftOS.Objects } public List Users { get; set; } + + /// + /// DO NOT MODIFY THIS. EVER. YOU WILL BREAK THE STORYLINE. Let the engine do it's job. + /// + public string PickupPoint { get; set; } } public class SettingsObject : DynamicObject diff --git a/ShiftOS.WinForms/Applications/Terminal.cs b/ShiftOS.WinForms/Applications/Terminal.cs index a4b77ae..687b2b9 100644 --- a/ShiftOS.WinForms/Applications/Terminal.cs +++ b/ShiftOS.WinForms/Applications/Terminal.cs @@ -410,8 +410,6 @@ namespace ShiftOS.WinForms.Applications public static void FirstSteps() { TerminalBackend.PrefixEnabled = false; - new Thread(() => - { TerminalBackend.InStory = true; Console.WriteLine("Hey there, and welcome to ShiftOS."); Thread.Sleep(2000); @@ -521,8 +519,86 @@ namespace ShiftOS.WinForms.Applications TerminalBackend.InStory = false; SaveSystem.SaveGame(); Thread.Sleep(1000); + + Story.Context.AutoComplete = false; + + Console.WriteLine(@"Welcome to the ShiftOS Newbie's Guide. + +This tutorial will guide you through the more intermediate features of ShiftOS, +such as earning Codepoints, buying Shiftoorium Upgrades, and using the objectives system. + +Every now and then, you'll get a notification in your terminal of a ""NEW OBJECTIVE"". +This means that someone has instructed you to do something inside ShiftOS. At any moment +you may type ""sos.status"" in your Terminal to see your current objectives. + +This command is very useful as not only does it allow you to see your current objectives +but you can also see the amount of Codepoints you have as well as the upgrades you've +installed and how many upgrades are available. + +Now, onto your first objective! All you need to do is earn 200 Codepoints using any +program on your system."); + + Story.PushObjective("First Steps: Your First Codepoints", "Play a few rounds of Pong, or use another program to earn 200 Codepoints.", () => + { + return SaveSystem.CurrentSave.Codepoints >= 200; + }, () => + { + Desktop.InvokeOnWorkerThread(() => + { + AppearanceManager.SetupWindow(new Terminal()); + }); + Console.WriteLine("Good job! You've earned " + SaveSystem.CurrentSave.Codepoints + @" Codepoints! You can use these inside the +Shiftorium to buy new upgrades inside ShiftOS. + +These upgrades can give ShiftOS more features, fixes and programs, +which can make the operating system easier to use and navigate around +and also make it easier for you to earn more Codepoints and thus upgrade +te system further. + +Be cautious though! Only certain upgrades offer the ability to earn more +Codepoints. These upgrades are typically in the form of new programs. + +So, try to get as many new programs as possible for your computer, and save +the system feature upgrades for later unless you absolutely need them. + +The worst thing that could happen is you end up stuck with very little Codepoints +and only a few small programs to use to earn very little amounts of Codepoints. + +Now, let's get you your first Shiftorium upgrade!"); + + Story.PushObjective("First Steps: The Shiftorium", "Buy your first Shiftorium upgrade with your new Codepoints using shiftorium.list, shiftorium.info and shiftorium.buy.", + () => + { + return SaveSystem.CurrentSave.CountUpgrades() > 0; + }, () => + { + Console.WriteLine("This concludes the ShiftOS Newbie's Guide! Now, go, and shift it your way!"); + Console.WriteLine(@" +Your goal: Earn 1,000 Codepoints."); + Story.Context.MarkComplete(); + Story.Start("first_steps_transition"); + }); TerminalBackend.PrintPrompt(); - }).Start(); + }); + + TerminalBackend.PrintPrompt(); + } + + + [Story("first_steps_transition")] + public static void FirstStepsTransition() + { + Story.PushObjective("Earn 1000 Codepoints", "You now know the basics of ShiftOS. Let's get your system up and running with a few upgrades, and get a decent amount of Codepoints.", () => + { + return SaveSystem.CurrentSave.Codepoints >= 1000; + }, + () => + { + Story.Context.MarkComplete(); + Story.Start("victortran_shiftnet"); + }); + + Story.Context.AutoComplete = false; } public void OnSkinLoad() diff --git a/ShiftOS.WinForms/Commands.cs b/ShiftOS.WinForms/Commands.cs index 2d297f5..b04ffe7 100644 --- a/ShiftOS.WinForms/Commands.cs +++ b/ShiftOS.WinForms/Commands.cs @@ -80,7 +80,6 @@ namespace ShiftOS.WinForms } } - [Namespace("coherence")] [RequiresUpgrade("kernel_coherence")] public static class CoherenceCommands diff --git a/ShiftOS.WinForms/Oobe.cs b/ShiftOS.WinForms/Oobe.cs index 96c2bf5..271e1fd 100644 --- a/ShiftOS.WinForms/Oobe.cs +++ b/ShiftOS.WinForms/Oobe.cs @@ -91,6 +91,7 @@ namespace ShiftOS.WinForms slashcount++; if (slashcount == 5) slashcount = 1; + Engine.AudioManager.PlayStream(Properties.Resources.writesound); Thread.Sleep(50); } rtext += Environment.NewLine; @@ -138,7 +139,10 @@ namespace ShiftOS.WinForms TextType("Your computer has been taken over by ShiftOS, and is currently being wiped clean of all existing files and programs."); Thread.Sleep(2000); Clear(); - TextType("I will not share my identity or my intentions at this moment.I will just proceed with the installation.There’s nothing you can do to stop it."); + TextType("I will not share my identity or my intentions at this moment."); + Thread.Sleep(2000); + Clear(); + TextType("I will just proceed with the installation.There’s nothing you can do to stop it."); Thread.Sleep(2000); Clear(); TextType("All I will say, is I need your help.Once ShiftOS is installed, I will explain."); diff --git a/ShiftOS.WinForms/Stories/LegionStory.cs b/ShiftOS.WinForms/Stories/LegionStory.cs index a0fc9bf..8c79f0e 100644 --- a/ShiftOS.WinForms/Stories/LegionStory.cs +++ b/ShiftOS.WinForms/Stories/LegionStory.cs @@ -16,8 +16,8 @@ namespace ShiftOS.WinForms.Stories [Story("victortran_shiftnet")] public static void ShiftnetStoryFeaturingTheBlueSmileyFaceHolyFuckThisFunctionNameIsLong() { - CharacterName = "victor_tran"; - SysName = "theos"; + CharacterName = "aiden"; + SysName = "appscape_main"; bool waiting = false; var installer = new Applications.Installer(); installer.InstallCompleted += () => @@ -35,53 +35,107 @@ namespace ShiftOS.WinForms.Stories AppearanceManager.SetupWindow(term); } - var t = new Thread(() => + WriteLine("aiden@appscape_main - user connecting to your system.", false); + Thread.Sleep(2000); + WriteLine("Hello there! My name's Aiden Nirh."); + WriteLine("I run a small Shiftnet website known simply as \"Appscape\"."); + WriteLine("Oh - wait... you don't know what the Shiftnet is..."); + WriteLine("Well, the Shiftnet is like... a private Internet, only accessible through ShiftOS."); + WriteLine("It has many sites and companies on it - banks, software centres, service providers, you name it."); + WriteLine("Appscape is one of them. I host many applications on Appscape, from games to utilities to productivity programs, and anything in between. If it exists as a ShiftOS program, it's either on the Shiftorium or Appscape."); + WriteLine("I'm going to assume you're interested... and I'll install the Shiftnet just in case."); + WriteLine("Beginning installation of Shiftnet..."); + //Set up an Installer. + waiting = true; + Desktop.InvokeOnWorkerThread(() => { - WriteLine("victortran@theos - user connecting to your system.", false); - Thread.Sleep(2000); - WriteLine("Hey there - yes, I am not just a sentient being. I am indeed Victor Tran."); - WriteLine("I am the creator of a Linux desktop environment called theShell."); - WriteLine("I'm in the middle of working on a ShiftOS version of it."); - WriteLine("However, before I start, I feel I need to show you something."); - WriteLine("You have a lot of ShiftOS applications, and you can earn lots of Codepoints - and you already have lots."); - WriteLine("Well, you'd be a perfect candidate for me to install the Shiftnet Client on your system."); - WriteLine("I'll begin the installation right now."); - //Set up an Installer. - waiting = true; - Desktop.InvokeOnWorkerThread(() => - { - Story.Start("installer"); - while (!Shiftorium.UpgradeInstalled("installer")) - Thread.Sleep(20); - AppearanceManager.SetupWindow(installer); - installer.InitiateInstall(new ShiftnetInstallation()); - }); - while (waiting == true) - Thread.Sleep(25); + SaveSystem.CurrentSave.StoriesExperienced.Add("installer"); + SaveSystem.CurrentSave.StoriesExperienced.Add("downloader"); - WriteLine("All installed! Once I disconnect, type win.open to see a list of your new apps."); - WriteLine("The Shiftnet is a vast network of websites only accessible through ShiftOS."); - WriteLine("Think of it as the DarkNet, but much darker, and much more secretive."); - WriteLine("There are lots of apps, games, skins and utilities on the Shiftnet."); - WriteLine("There are also lots of companies offering many services."); - WriteLine("I'd stay on the shiftnet/ cluster though, others may be dangerous."); - WriteLine("I'd also stick to the sites listed on shiftnet/shiftsoft/ping - that site is regularly updated with the most safe Shiftnet sites."); - WriteLine("Oh, that reminds me. I have set you up with ShiftSoft's service provider, Freebie Solutions."); - WriteLine("It's a free provider, but it offers only 256 bytes per second download and upload speeds."); - WriteLine("You may want to go look for another provider when you can afford it."); - WriteLine("Trust me - with this provider, things get slow."); - WriteLine("Anyways, it was nice meeting you, hopefully someday you'll give theShell a try."); + while (!Shiftorium.UpgradeInstalled("installer")) + Thread.Sleep(20); + AppearanceManager.SetupWindow(installer); + installer.InitiateInstall(new ShiftnetInstallation()); + }); + while (waiting == true) + Thread.Sleep(25); - TerminalBackend.PrefixEnabled = true; + WriteLine("All good to go! Once I disconnect, type win.open to see a list of your new apps."); + WriteLine("I've installed everything you need, for free."); + WriteLine("You've got the Downloader, a simple application to help you track Shiftnet file downloads..."); + WriteLine("...the Installer which will help you unpack programs from .stp files and install them to your system..."); + WriteLine("...and lastly, the Shiftnet browser itself. This program lets you browse the Shiftnet, much like you would the real Internet."); + WriteLine("I'd stay on the shiftnet/ cluster though, because although there are many services on the Shiftnet, some of them may try to scam you into losing loads of Codepoints, or worse, wrecking your system with viruses."); + WriteLine("If you want a nice list of safe Shiftnet services, head to ShiftSoft's \"Ping\" site, at shiftnet/shiftsoft/ping."); + WriteLine("Oh, also, the Shiftnet, much like the real internet, is not free."); + WriteLine("It requires a service provider. Service providers cost a fair amount of Codepoints, but if you want to get faster speeds and more reliable connections on the Shiftnet, finding a good service provider is a necessity."); + WriteLine("Right now, you are on ShiftSoft's free trial plan, Freebie Solutions, which gives you access to the Shiftnet however you are locked at 256 bytes per second file downloads and can't leave the shiftnet/ cluster."); + WriteLine("It's enough to get you started - you'll want to find a faster provider though.."); + WriteLine("Anyways, that's all I'll say for now. Have fun on the Shiftnet. I have to go work on something."); + WriteLine("One of my friends'll contact you once you've gotten a new service provider."); + + Story.PushObjective("Register with a new Shiftnet service provider.", "You've just unlocked the Shiftnet, which has opened up a whole new world of applications and features for ShiftOS. Before you go nuts with it, you may want to register with a better service provider than Freebie Solutions.", () => + { + return SaveSystem.CurrentSave.ShiftnetSubscription != 0; + }, + () => + { + Story.Context.MarkComplete(); + SaveSystem.SaveGame(); TerminalBackend.PrintPrompt(); + Story.Start("hacker101_breakingbonds_1"); }); - t.IsBackground = true; - t.Start(); - TerminalBackend.PrefixEnabled = false; + TerminalBackend.PrefixEnabled = true; + TerminalBackend.PrintPrompt(); + Story.Context.AutoComplete = false; } + [Story("hacker101_breakingbonds_1")] + public static void BreakingTheBondsIntro() + { + CharacterName = "hacker101"; + SysName = "pebcak"; + + if (!terminalOpen()) + { + var term = new Applications.Terminal(); + AppearanceManager.SetupWindow(term); + } + + WriteLine("hacker101@pebcak - user connecting to your system.", false); + Thread.Sleep(2000); + WriteLine("Greetings, user."); + WriteLine("My name is hacker101. I have a few things to show you."); + WriteLine("Before I can do that, however, I need you to do a few things."); + WriteLine("I'll assign what I need you to do as an objective. When you're done, I'll tell you what you need to know."); + + Story.PushObjective("Breaking the Bonds: Errand Boy", @"hacker101 has something he needs to show you, however before he can, you need to do the following: + + - Buy ""TriWrite"" from Appscape + - Buy ""Address Book"" from Appscape + - Buy ""SimpleSRC"" from Appscape", () => + { + bool flag1 = Shiftorium.UpgradeInstalled("address_book"); + bool flag2 = Shiftorium.UpgradeInstalled("triwrite"); + bool flag3 = Shiftorium.UpgradeInstalled("simplesrc"); + return flag1 && flag2 && flag3; + }, () => + { + Story.Context.MarkComplete(); + SaveSystem.SaveGame(); + Story.Start("hacker101_breakingbonds_2"); + }); + + TerminalBackend.PrefixEnabled = true; + TerminalBackend.PrintPrompt(); + + Story.Context.AutoComplete = false; + + } + + private static void WriteLine(string text, bool showCharacterName=true) { Console.WriteLine(); @@ -90,15 +144,23 @@ namespace ShiftOS.WinForms.Stories ConsoleEx.Bold = true; ConsoleEx.ForegroundColor = ConsoleColor.DarkMagenta; Console.Write(CharacterName); + ConsoleEx.OnFlush?.Invoke(); Console.ForegroundColor = ConsoleColor.White; Console.Write("@"); + ConsoleEx.OnFlush?.Invoke(); ConsoleEx.ForegroundColor = ConsoleColor.Yellow; Console.Write(SysName + ": "); + ConsoleEx.OnFlush?.Invoke(); } ConsoleEx.ForegroundColor = ConsoleColor.Gray; ConsoleEx.Bold = false; - Console.WriteLine(text); + foreach(var c in text) + { + Console.Write(c); + ConsoleEx.OnFlush?.Invoke(); + Thread.Sleep(45); + } Thread.Sleep(1000); } diff --git a/ShiftOS.WinForms/Tools/ControlManager.cs b/ShiftOS.WinForms/Tools/ControlManager.cs index 548a62a..7fbfd1b 100644 --- a/ShiftOS.WinForms/Tools/ControlManager.cs +++ b/ShiftOS.WinForms/Tools/ControlManager.cs @@ -137,10 +137,14 @@ namespace ShiftOS.WinForms.Tools /// The control to center (this is an extension method - you can call it on a control as though it was a method in that control) public static void CenterParent(this Control ctrl) { - ctrl.Location = new Point( - (ctrl.Parent.Width - ctrl.Width) / 2, - (ctrl.Parent.Height - ctrl.Height) / 2 - ); + try + { + ctrl.Location = new Point( + (ctrl.Parent.Width - ctrl.Width) / 2, + (ctrl.Parent.Height - ctrl.Height) / 2 + ); + } + catch { } } public static void SetupControl(Control ctrl) diff --git a/ShiftOS_TheReturn/Commands.cs b/ShiftOS_TheReturn/Commands.cs index 72bccb1..f37bcb3 100644 --- a/ShiftOS_TheReturn/Commands.cs +++ b/ShiftOS_TheReturn/Commands.cs @@ -538,15 +538,28 @@ Upgrades: {SaveSystem.CurrentSave.CountUpgrades()} installed, "; Console.WriteLine(status); - - if(Story.CurrentObjective != null) + Console.WriteLine("Objectives:"); + try + { + if (Story.CurrentObjectives.Count > 0) + { + foreach (var obj in Story.CurrentObjectives) + { + Console.WriteLine(obj.Name); + Console.WriteLine("-------------------------------"); + Console.WriteLine(); + Console.WriteLine(obj.Description); + } + } + else + { + Console.WriteLine(" - No objectives are running. Check back later!"); + } + } + catch { - Console.WriteLine("CURRENT OBJECTIVE: " + Story.CurrentObjective.Name); - Console.WriteLine("-------------------------------"); - Console.WriteLine(); - Console.WriteLine(Story.CurrentObjective.Description); + Console.WriteLine(" - No objectives are running. Check back later!"); } - return true; } } diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index 155f002..e98a51e 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -453,6 +453,16 @@ namespace ShiftOS.Engine Desktop.InvokeOnWorkerThread(new Action(() => Desktop.PopulateAppLauncher())); GameReady?.Invoke(); + + if (!string.IsNullOrWhiteSpace(CurrentSave.PickupPoint)) + { + try + { + Story.Start(CurrentSave.PickupPoint); + TerminalBackend.PrintPrompt(); + } + catch { } + } } /// diff --git a/ShiftOS_TheReturn/Story.cs b/ShiftOS_TheReturn/Story.cs index 848c757..4d1d5cc 100644 --- a/ShiftOS_TheReturn/Story.cs +++ b/ShiftOS_TheReturn/Story.cs @@ -93,33 +93,24 @@ namespace ShiftOS.Engine { public static StoryContext Context { get; private set; } public static event Action StoryComplete; - public static Objective CurrentObjective { get; private set; } + public static List CurrentObjectives { get; private set; } public static void PushObjective(string name, string desc, Func completeFunc, Action onComplete) { - if (CurrentObjective != null) - { - if (CurrentObjective.IsComplete == false) - { - throw new Exception("Cannot start objective - an objective is already running."); - } - else - { - CurrentObjective = null; - } - } - - CurrentObjective = new Objective(name, desc, completeFunc, onComplete); + if (CurrentObjectives == null) + CurrentObjectives = new List(); + var currentObjective = new Objective(name, desc, completeFunc, onComplete); + CurrentObjectives.Add(currentObjective); var t = new Thread(() => { - var obj = CurrentObjective; + var obj = currentObjective; while (!obj.IsComplete) { Thread.Sleep(5000); } + CurrentObjectives.Remove(obj); obj.Complete(); - CurrentObjective = null; }); t.IsBackground = true; t.Start(); @@ -163,9 +154,11 @@ namespace ShiftOS.Engine Method = mth, AutoComplete = true, }; + SaveSystem.CurrentSave.Password = Context.Id; Context.OnComplete += () => { StoryComplete?.Invoke(stid); + SaveSystem.CurrentSave.PickupPoint = null; }; mth.Invoke(null, null); if (Context.AutoComplete) -- cgit v1.2.3 From 3e11eca70481841b6e2f2253d667944779cfd5fb Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 4 Jun 2017 21:07:43 -0400 Subject: Fix story autosave --- ShiftOS.Server/Program.cs | 9 +-------- ShiftOS.WinForms/Stories/LegionStory.cs | 2 +- ShiftOS_TheReturn/Story.cs | 2 +- 3 files changed, 3 insertions(+), 10 deletions(-) (limited to 'ShiftOS.WinForms') diff --git a/ShiftOS.Server/Program.cs b/ShiftOS.Server/Program.cs index fa9ebee..5170ccd 100644 --- a/ShiftOS.Server/Program.cs +++ b/ShiftOS.Server/Program.cs @@ -155,13 +155,7 @@ namespace ShiftOS.Server Console.WriteLine("FUCK. Something HORRIBLE JUST HAPPENED."); }; - AppDomain.CurrentDomain.UnhandledException += (o, a) => - { - if(server.IsOnline == true) - server.Stop(); - System.Diagnostics.Process.Start("ShiftOS.Server.exe"); - }; - + server.OnReceived += (o, a) => { var obj = a.Data.Object; @@ -208,7 +202,6 @@ namespace ShiftOS.Server task.Wait(); */ - RandomUserGenerator.StartThread(); while (server.IsOnline) { diff --git a/ShiftOS.WinForms/Stories/LegionStory.cs b/ShiftOS.WinForms/Stories/LegionStory.cs index 8c79f0e..056fe85 100644 --- a/ShiftOS.WinForms/Stories/LegionStory.cs +++ b/ShiftOS.WinForms/Stories/LegionStory.cs @@ -368,7 +368,7 @@ namespace ShiftOS.WinForms.Stories SetProgress(i); Thread.Sleep(100); } - Story.Start("downloader"); + SaveSystem.CurrentSave.StoriesExperienced.Add("downloader"); SetProgress(0); SetStatus("Dependencies installed."); Thread.Sleep(2000); diff --git a/ShiftOS_TheReturn/Story.cs b/ShiftOS_TheReturn/Story.cs index 4d1d5cc..f473f89 100644 --- a/ShiftOS_TheReturn/Story.cs +++ b/ShiftOS_TheReturn/Story.cs @@ -154,7 +154,7 @@ namespace ShiftOS.Engine Method = mth, AutoComplete = true, }; - SaveSystem.CurrentSave.Password = Context.Id; + SaveSystem.CurrentSave.PickupPoint = Context.Id; Context.OnComplete += () => { StoryComplete?.Invoke(stid); -- cgit v1.2.3