From d4316e75fc876ec7ceac3f1a9362ef7b36ca40cf Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 24 Apr 2017 21:01:42 -0400 Subject: Audio Player work. --- ShiftOS.WinForms/Applications/AudioPlayer.cs | 133 ++++++++++++++++++++++++++- 1 file changed, 132 insertions(+), 1 deletion(-) (limited to 'ShiftOS.WinForms/Applications/AudioPlayer.cs') diff --git a/ShiftOS.WinForms/Applications/AudioPlayer.cs b/ShiftOS.WinForms/Applications/AudioPlayer.cs index b8be6af..6d4d58a 100644 --- a/ShiftOS.WinForms/Applications/AudioPlayer.cs +++ b/ShiftOS.WinForms/Applications/AudioPlayer.cs @@ -32,9 +32,15 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using ShiftOS.Engine; +using NAudio; +using System.Threading; namespace ShiftOS.WinForms.Applications { + [AppscapeEntry("Audio Player", "Play music and other sounds on your computer.", 3047, 1000, "file_skimmer", "Entertainment")] + [Launcher("Audio Player", false, null, "Entertainment")] + [WinOpen("audio_player")] + [DefaultTitle("Audio Player")] public partial class AudioPlayer : UserControl, IShiftOSWindow { public AudioPlayer() @@ -42,9 +48,12 @@ namespace ShiftOS.WinForms.Applications InitializeComponent(); } + NAudio.Wave.WaveOut o = null; + + public void OnLoad() { - + wpaudio.Hide(); } public void OnSkinLoad() @@ -54,6 +63,9 @@ namespace ShiftOS.WinForms.Applications public bool OnUnload() { + o?.Dispose(); + mp3?.Dispose(); + memstream?.Dispose(); return true; } @@ -61,5 +73,124 @@ namespace ShiftOS.WinForms.Applications { } + + private void addSongToolStripMenuItem_Click(object sender, EventArgs e) + { + FileSkimmerBackend.GetFile(new[] { ".mp3", ".wav" }, FileOpenerStyle.Open, (path) => + { + if (!lbtracks.Items.Contains(path)) + lbtracks.Items.Add(path); + else + Infobox.Show("Song already added!", "That song is already added to the Audio Player playlist."); + }); + } + + private void clearToolStripMenuItem_Click(object sender, EventArgs e) + { + lbtracks.Items.Clear(); + } + + private void shuffleToolStripMenuItem_Click(object sender, EventArgs e) + { + var lst = new object[lbtracks.Items.Count]; + lbtracks.Items.CopyTo(lst, 0); + var shuffle = new List(lst); + shuffle.Shuffle(); + lbtracks.Items.Clear(); + lbtracks.Items.AddRange(shuffle.ToArray()); + } + + private void removeToolStripMenuItem_Click(object sender, EventArgs e) + { + lbtracks.Items.RemoveAt(lbtracks.SelectedIndex); + } + + private void btnplay_Click(object sender, EventArgs e) + { + if(o == null) + { + if (lbtracks.Items.Count > 0) + { + Play(lbtracks.Items[0].ToString()); + btnplay.Text = "Pause"; + } + else + Infobox.Show("Error", "No tracks to play! Please add a track to the playlist."); + } + else if(o.PlaybackState == NAudio.Wave.PlaybackState.Paused) + { + o.Resume(); + btnplay.Text = "Pause"; + } + else if(o.PlaybackState == NAudio.Wave.PlaybackState.Playing) + { + o.Pause(); + btnplay.Text = "Play"; + } + } + + System.IO.Stream memstream = null; + NAudio.Wave.Mp3FileReader mp3 = null; + + public void Play(string track) + { + if (o != null) + { + o.Dispose(); + mp3.Dispose(); + memstream.Dispose(); + } + var bytes = ShiftOS.Objects.ShiftFS.Utils.ReadAllBytes(track); + memstream = new System.IO.MemoryStream(bytes); + mp3 = new NAudio.Wave.Mp3FileReader(memstream); + o = new NAudio.Wave.WaveOut(); + o.Init(mp3); + o.Play(); + + pgplaytime.Value = 0; + pgplaytime.Maximum = (int)mp3.Length; + new Thread(() => + { + while(o.PlaybackState == NAudio.Wave.PlaybackState.Playing || o.PlaybackState == NAudio.Wave.PlaybackState.Paused) + { + long time = mp3.Position; + if(time != mp3.Position) + { + time = mp3.Position; + this.Invoke(new Action(() => + { + pgplaytime.Value = (int)time; + })); + } + } + }).Start(); + } + + private void lbtracks_SelectedIndexChanged(object sender, EventArgs e) + { + try + { + Play(lbtracks.SelectedItem.ToString()); + } + catch { } + } + } + + public static class ListExtensions + { + private static Random rng = new Random(); + + public static void Shuffle(this IList list) + { + int n = list.Count; + while (n > 1) + { + n--; + int k = rng.Next(n + 1); + T value = list[k]; + list[k] = list[n]; + list[n] = value; + } + } } } -- cgit v1.2.3 From 99b438dd8f22fc95c7512b724618ca3e1c7af790 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 24 Apr 2017 21:10:27 -0400 Subject: Smoother Audio Player progress bar --- ShiftOS.WinForms/Applications/AudioPlayer.cs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'ShiftOS.WinForms/Applications/AudioPlayer.cs') diff --git a/ShiftOS.WinForms/Applications/AudioPlayer.cs b/ShiftOS.WinForms/Applications/AudioPlayer.cs index 6d4d58a..3edf965 100644 --- a/ShiftOS.WinForms/Applications/AudioPlayer.cs +++ b/ShiftOS.WinForms/Applications/AudioPlayer.cs @@ -58,7 +58,7 @@ namespace ShiftOS.WinForms.Applications public void OnSkinLoad() { - + pgplaytime.Width = flcontrols.Width - btnplay.Width - 25; } public bool OnUnload() @@ -151,17 +151,14 @@ namespace ShiftOS.WinForms.Applications pgplaytime.Maximum = (int)mp3.Length; new Thread(() => { - while(o.PlaybackState == NAudio.Wave.PlaybackState.Playing || o.PlaybackState == NAudio.Wave.PlaybackState.Paused) + while (o.PlaybackState == NAudio.Wave.PlaybackState.Playing || o.PlaybackState == NAudio.Wave.PlaybackState.Paused) { long time = mp3.Position; - if(time != mp3.Position) + this.Invoke(new Action(() => { - time = mp3.Position; - this.Invoke(new Action(() => - { - pgplaytime.Value = (int)time; - })); - } + pgplaytime.Value = (int)time; + })); + Thread.Sleep(50); } }).Start(); } -- cgit v1.2.3 From d22957d2abb77f162ac5ef43a064a4ce056fc046 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 24 Apr 2017 21:51:52 -0400 Subject: audio player scrubbing --- .../Applications/AudioPlayer.Designer.cs | 15 ++++++- ShiftOS.WinForms/Applications/AudioPlayer.cs | 52 ++++++++++++++++++++++ 2 files changed, 66 insertions(+), 1 deletion(-) (limited to 'ShiftOS.WinForms/Applications/AudioPlayer.cs') diff --git a/ShiftOS.WinForms/Applications/AudioPlayer.Designer.cs b/ShiftOS.WinForms/Applications/AudioPlayer.Designer.cs index 825413d..6263ff7 100644 --- a/ShiftOS.WinForms/Applications/AudioPlayer.Designer.cs +++ b/ShiftOS.WinForms/Applications/AudioPlayer.Designer.cs @@ -64,6 +64,7 @@ namespace ShiftOS.WinForms.Applications this.clearToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.shuffleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.removeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.loopToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); ((System.ComponentModel.ISupportInitialize)(this.wpaudio)).BeginInit(); this.toolStripContainer1.ContentPanel.SuspendLayout(); this.toolStripContainer1.TopToolStripPanel.SuspendLayout(); @@ -150,6 +151,9 @@ namespace ShiftOS.WinForms.Applications 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 // @@ -158,7 +162,8 @@ namespace ShiftOS.WinForms.Applications this.addSongToolStripMenuItem, this.clearToolStripMenuItem, this.shuffleToolStripMenuItem, - this.removeToolStripMenuItem}); + this.removeToolStripMenuItem, + this.loopToolStripMenuItem}); this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Name = "menuStrip1"; this.menuStrip1.Size = new System.Drawing.Size(798, 24); @@ -193,6 +198,13 @@ namespace ShiftOS.WinForms.Applications this.removeToolStripMenuItem.Text = "Remove"; this.removeToolStripMenuItem.Click += new System.EventHandler(this.removeToolStripMenuItem_Click); // + // loopToolStripMenuItem + // + this.loopToolStripMenuItem.CheckOnClick = true; + this.loopToolStripMenuItem.Name = "loopToolStripMenuItem"; + this.loopToolStripMenuItem.Size = new System.Drawing.Size(46, 20); + this.loopToolStripMenuItem.Text = "Loop"; + // // AudioPlayer // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -229,5 +241,6 @@ namespace ShiftOS.WinForms.Applications private System.Windows.Forms.FlowLayoutPanel flcontrols; private System.Windows.Forms.Button btnplay; private Controls.ShiftedProgressBar pgplaytime; + private System.Windows.Forms.ToolStripMenuItem loopToolStripMenuItem; } } diff --git a/ShiftOS.WinForms/Applications/AudioPlayer.cs b/ShiftOS.WinForms/Applications/AudioPlayer.cs index 3edf965..28e1c56 100644 --- a/ShiftOS.WinForms/Applications/AudioPlayer.cs +++ b/ShiftOS.WinForms/Applications/AudioPlayer.cs @@ -160,6 +160,23 @@ namespace ShiftOS.WinForms.Applications })); Thread.Sleep(50); } + if (o.PlaybackState == NAudio.Wave.PlaybackState.Stopped) + { + if (lbtracks.SelectedIndex < lbtracks.Items.Count - 1) + { + this.Invoke(new Action(() => + { + lbtracks.SelectedIndex++; + })); + } + else if(loopToolStripMenuItem.Checked == true) + { + this.Invoke(new Action(() => + { + lbtracks.SelectedIndex = 0; + })); + } + } }).Start(); } @@ -171,6 +188,41 @@ namespace ShiftOS.WinForms.Applications } catch { } } + + bool scrubbing = false; + + private void startScrub(object sender, MouseEventArgs e) + { + scrubbing = true; + } + + 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); + } + + private void pgplaytime_MouseMove(object sender, MouseEventArgs e) + { + if (mp3 != null) + try + { + if (scrubbing) + { + long s_pos = (long)linear(e.X, 0, pgplaytime.Width, 0, (double)mp3.Length); + mp3.Position = s_pos; + } + } + catch { } + } + + private void pgplaytime_MouseUp(object sender, MouseEventArgs e) + { + scrubbing = false; + } } public static class ListExtensions -- cgit v1.2.3 From 712d38a2be53b415c2635b86e1f539faec0ace19 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 28 Apr 2017 20:01:04 -0400 Subject: Final Beta 2.3 adjustments. --- .../Applications/AddressBook.Designer.cs | 44 +++++++++++++----- ShiftOS.WinForms/Applications/AddressBook.cs | 48 ++++++++++++++++++++ ShiftOS.WinForms/Applications/AddressBook.resx | 7 +++ ShiftOS.WinForms/Applications/AudioPlayer.cs | 15 +++---- ShiftOS.WinForms/Applications/Dialog.cs | 13 +++--- ShiftOS.WinForms/Oobe.cs | 52 +++++++++++++++++----- ShiftOS_TheReturn/Commands.cs | 5 ++- ShiftOS_TheReturn/Infobox.cs | 6 +-- 8 files changed, 151 insertions(+), 39 deletions(-) (limited to 'ShiftOS.WinForms/Applications/AudioPlayer.cs') 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); } } -- cgit v1.2.3