diff --git a/ShiftOS.WinForms/Applications/AddressBook.Designer.cs b/ShiftOS.WinForms/Applications/AddressBook.Designer.cs index 956e2a2..afb6b7a 100644 --- a/ShiftOS.WinForms/Applications/AddressBook.Designer.cs +++ b/ShiftOS.WinForms/Applications/AddressBook.Designer.cs @@ -28,21 +28,23 @@ /// private void InitializeComponent() { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AddressBook)); this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.addContactToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.removeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.clearToolStripMenuItem = 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.menuStrip1.SuspendLayout(); + this.panel1.SuspendLayout(); this.SuspendLayout(); // // menuStrip1 // this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.addContactToolStripMenuItem, - this.removeToolStripMenuItem, - this.clearToolStripMenuItem}); + this.removeToolStripMenuItem}); this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Name = "menuStrip1"; this.menuStrip1.Size = new System.Drawing.Size(872, 24); @@ -61,12 +63,7 @@ this.removeToolStripMenuItem.Name = "removeToolStripMenuItem"; this.removeToolStripMenuItem.Size = new System.Drawing.Size(62, 20); this.removeToolStripMenuItem.Text = "Remove"; - // - // clearToolStripMenuItem - // - this.clearToolStripMenuItem.Name = "clearToolStripMenuItem"; - this.clearToolStripMenuItem.Size = new System.Drawing.Size(46, 20); - this.clearToolStripMenuItem.Text = "Clear"; + this.removeToolStripMenuItem.Click += new System.EventHandler(this.removeToolStripMenuItem_Click); // // tvcontacts // @@ -78,12 +75,35 @@ // // 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(73, 13); + this.lbtitle.TabIndex = 0; + this.lbtitle.Tag = "header1"; + this.lbtitle.Text = "Address Book"; + // // AddressBook // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -93,8 +113,11 @@ this.Controls.Add(this.menuStrip1); this.Name = "AddressBook"; this.Size = new System.Drawing.Size(872, 575); + this.Load += new System.EventHandler(this.AddressBook_Load); this.menuStrip1.ResumeLayout(false); this.menuStrip1.PerformLayout(); + this.panel1.ResumeLayout(false); + this.panel1.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); @@ -105,8 +128,9 @@ private System.Windows.Forms.MenuStrip menuStrip1; private System.Windows.Forms.ToolStripMenuItem addContactToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem removeToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem clearToolStripMenuItem; private System.Windows.Forms.TreeView tvcontacts; private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.Label txtbody; + private System.Windows.Forms.Label lbtitle; } } diff --git a/ShiftOS.WinForms/Applications/AddressBook.cs b/ShiftOS.WinForms/Applications/AddressBook.cs index 0347669..9a4ce51 100644 --- a/ShiftOS.WinForms/Applications/AddressBook.cs +++ b/ShiftOS.WinForms/Applications/AddressBook.cs @@ -27,12 +27,20 @@ namespace ShiftOS.WinForms.Applications string data_dir = Paths.GetPath("data") + "/address_book"; public void OnLoad() { + removeToolStripMenuItem.Visible = false; if (!DirectoryExists(data_dir)) CreateDirectory(data_dir); tvcontacts.Nodes.RemoveByKey("userdefined"); var userDefined = new TreeNode(); userDefined.Name = "userdefined"; userDefined.Text = "User-defined"; + tvcontacts.Click += (o, a) => + { + if (tvcontacts.SelectedNode == userDefined) + { + removeToolStripMenuItem.Visible = false; + } + }; foreach(var f in GetFiles(data_dir)) { try @@ -42,6 +50,20 @@ namespace ShiftOS.WinForms.Applications node.Text = contact.UserName + "@" + contact.SystemName; node.Tag = contact; userDefined.Nodes.Add(node); + tvcontacts.Click += (o, a) => + { + if(tvcontacts.SelectedNode == node) + { + lbtitle.Text = contact.Name; + txtbody.Text = $@"Username: {contact.UserName} +System Name: {contact.SystemName} + +Description: +{contact.Description}"; + removeToolStripMenuItem.Visible = true; + SelectedContact = contact; + } + }; } catch { } } @@ -49,6 +71,8 @@ namespace ShiftOS.WinForms.Applications userDefined.Expand(); } + public Contact SelectedContact = null; + public void OnSkinLoad() { } @@ -110,6 +134,30 @@ namespace ShiftOS.WinForms.Applications } }); } + + private void AddressBook_Load(object sender, EventArgs e) + { + + } + + private void removeToolStripMenuItem_Click(object sender, EventArgs e) + { + if(SelectedContact != null) + { + string file = data_dir + "/" + SelectedContact.Name; + if (FileExists(file)) + { + Infobox.PromptYesNo("Remove contact", $"Are you sure you want to remove {SelectedContact.Name} from your Address Book?", (result) => + { + if (result == true) + { + Delete(file); + OnLoad(); + } + }); + } + } + } } public class Contact diff --git a/ShiftOS.WinForms/Applications/AddressBook.resx b/ShiftOS.WinForms/Applications/AddressBook.resx index d5494e3..e150f33 100644 --- a/ShiftOS.WinForms/Applications/AddressBook.resx +++ b/ShiftOS.WinForms/Applications/AddressBook.resx @@ -120,4 +120,11 @@ 17, 17 + + The Address Book helps you keep track of all your contacts within the digital society, whether they be friends, enemies, or whatnot. + +On the left, we have made a list of all your contacts. You can click on one to view full details on the contact. + +To add a contact, simply click "Add Contact", and to remove one, click "Remove". Some contacts may not be removed as they are integral to the progression of your adventures within the digital society. + \ No newline at end of file diff --git a/ShiftOS.WinForms/Applications/AudioPlayer.cs b/ShiftOS.WinForms/Applications/AudioPlayer.cs index 28e1c56..9940ddd 100644 --- a/ShiftOS.WinForms/Applications/AudioPlayer.cs +++ b/ShiftOS.WinForms/Applications/AudioPlayer.cs @@ -162,20 +162,17 @@ namespace ShiftOS.WinForms.Applications } if (o.PlaybackState == NAudio.Wave.PlaybackState.Stopped) { - if (lbtracks.SelectedIndex < lbtracks.Items.Count - 1) + this.Invoke(new Action(() => { - this.Invoke(new Action(() => + if (lbtracks.SelectedIndex < lbtracks.Items.Count - 1) { lbtracks.SelectedIndex++; - })); - } - else if(loopToolStripMenuItem.Checked == true) - { - this.Invoke(new Action(() => + } + else if (loopToolStripMenuItem.Checked == true) { lbtracks.SelectedIndex = 0; - })); - } + } + })); } }).Start(); } diff --git a/ShiftOS.WinForms/Applications/Dialog.cs b/ShiftOS.WinForms/Applications/Dialog.cs index 593d64b..6e358e6 100644 --- a/ShiftOS.WinForms/Applications/Dialog.cs +++ b/ShiftOS.WinForms/Applications/Dialog.cs @@ -72,7 +72,7 @@ namespace ShiftOS.WinForms.Applications internal void OpenInternal(string title, string msg) { Title = title; - AppearanceManager.SetupWindow(this); + AppearanceManager.SetupDialog(this); lbmessage.Text = msg; txtinput.Hide(); flyesno.Hide(); @@ -93,11 +93,12 @@ namespace ShiftOS.WinForms.Applications new Dialog().OpenInternal(title, msg); } - public void PromptTextInternal(string title, string message, Action callback) + public void PromptTextInternal(string title, string message, Action callback, bool isPassword) { Title = title; - AppearanceManager.SetupWindow(this); + AppearanceManager.SetupDialog(this); lbmessage.Text = message; + txtinput.UseSystemPasswordChar = isPassword; txtinput.Show(); flyesno.Hide(); btnok.Show(); @@ -117,9 +118,9 @@ namespace ShiftOS.WinForms.Applications }; } - public void PromptText(string title, string message, Action callback) + public void PromptText(string title, string message, Action callback, bool isPassword) { - new Dialog().PromptTextInternal(title, message, callback); + new Dialog().PromptTextInternal(title, message, callback, isPassword); } public void PromptYesNo(string title, string message, Action callback) @@ -132,7 +133,7 @@ namespace ShiftOS.WinForms.Applications public void PromptYesNoInternal(string title, string message, Action callback) { Title = title; - AppearanceManager.SetupWindow(this); + AppearanceManager.SetupDialog(this); lbmessage.Text = message; txtinput.Hide(); flyesno.Show(); diff --git a/ShiftOS.WinForms/Oobe.cs b/ShiftOS.WinForms/Oobe.cs index 5b767e0..6017d35 100644 --- a/ShiftOS.WinForms/Oobe.cs +++ b/ShiftOS.WinForms/Oobe.cs @@ -221,18 +221,50 @@ You must join the digital society, rise up the ranks, and save us. public void PromptForLogin() { - this.Show(); - this.TopMost = true; - lblHijack.Text = ""; - textgeninput = lblhackwords; - - var fsw = new FakeSetupScreen(this, 10); - fsw.Show(); - fsw.TopMost = true; - fsw.DoneLoggingIn += () => + ServerMessageReceived MessageReceived = null; + MessageReceived = (msg) => { - this.Close(); + if(msg.Name == "mud_savefile") + { + SaveSystem.CurrentSave = JsonConvert.DeserializeObject(msg.Contents); + SaveSystem.SaveGame(); + Application.Restart(); + } + else if(msg.Name == "mud_notfound") + { + ServerManager.MessageReceived -= MessageReceived; + + PromptForLogin(); + } }; + ServerManager.MessageReceived += MessageReceived; + Infobox.PromptYesNo("Login", "You are missing a digital society authentication link. Would you like to generate a new link with an existing account? Choosing \"No\" will restart the session in the out-of-box experience.", (result)=> + { + if (result == true) + { + Infobox.PromptText("Login", "Please enter your digital society username.", (uname) => + { + Infobox.PromptText("Login", "Please enter your password.", (pword) => + { + ServerManager.SendMessage("mud_login", JsonConvert.SerializeObject(new + { + username = uname, + password = pword + })); + }, true); + }); + } + else + { + //restart in OOBE + if (Objects.ShiftFS.Utils.FileExists(Paths.GetPath("user.dat"))) + { + Utils.Delete(Paths.GetPath("user.dat")); + } + Application.Restart(); + } + }); + } public void StartTrailer() diff --git a/ShiftOS_TheReturn/Commands.cs b/ShiftOS_TheReturn/Commands.cs index ce94030..7980635 100644 --- a/ShiftOS_TheReturn/Commands.cs +++ b/ShiftOS_TheReturn/Commands.cs @@ -247,7 +247,10 @@ namespace ShiftOS.Engine { try { - SaveSystem.CurrentSave.Upgrades[args["upgrade"] as string] = false; + SaveSystem.CurrentSave.Upgrades[args["upgrade"].ToString()] = false; + SaveSystem.SaveGame(); + Desktop.PopulateAppLauncher(); + Desktop.CurrentDesktop.SetupDesktop(); } catch { diff --git a/ShiftOS_TheReturn/Infobox.cs b/ShiftOS_TheReturn/Infobox.cs index 5900bc4..62abcb7 100644 --- a/ShiftOS_TheReturn/Infobox.cs +++ b/ShiftOS_TheReturn/Infobox.cs @@ -65,13 +65,13 @@ namespace ShiftOS.Engine }); } - public static void PromptText(string title, string message, Action callback) + public static void PromptText(string title, string message, Action callback, bool isPassword = false) { title = Localization.Parse(title); message = Localization.Parse(message); Desktop.InvokeOnWorkerThread(() => { - _infobox.PromptText(title, message, callback); + _infobox.PromptText(title, message, callback, isPassword); }); } @@ -99,7 +99,7 @@ namespace ShiftOS.Engine public interface IInfobox { void Open(string title, string msg, Action callback = null); - void PromptText(string title, string message, Action callback); + void PromptText(string title, string message, Action callback, bool isPassword); void PromptYesNo(string title, string message, Action callback); } }