From e833a9bf2751f16d8614af9aa20f5b9bec3d81a8 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 23 Apr 2017 14:53:10 -0400 Subject: FUCKTONS OF SHIFTORIUM WORK --- ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs | 208 +++++++++++++++++++++++++ 1 file changed, 208 insertions(+) create mode 100644 ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs (limited to 'ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs') diff --git a/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs b/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs new file mode 100644 index 0000000..88db07b --- /dev/null +++ b/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs @@ -0,0 +1,208 @@ +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/appscape", "Appscape", "Bringing ShiftOS to life")] + [ShiftnetFundamental] + public partial class AppscapeMain : UserControl, IShiftnetSite + { + public AppscapeMain() + { + InitializeComponent(); + } + + public event Action GoBack; + public event Action GoToUrl; + + public void OnSkinLoad() + { + ControlManager.SetupControls(this); + } + + public void OnUpgrade() + { + } + + public string Category = "All"; + + public string[] GetCategories() + { + var upgrades = Shiftorium.GetDefaults().Where(x => x.Dependencies.Contains("appscape_")); + List cats = new List(); + cats.Add("All"); + try + { + if (upgrades.Count() > 0) + foreach (var upg in upgrades) + { + if (!cats.Contains(upg.Category)) + cats.Add(upg.Category); + } + } + catch { } + return cats.ToArray(); + } + + public ShiftoriumUpgrade CurrentUpgrade = null; + + public void SetupCategory(string cat) + { + pnlappslist.Controls.Clear(); + pnlappslist.Show(); + pnlappslist.BringToFront(); + Category = cat; + var upgrades = GetAllInCategory(); + lbtitle.Text = cat; + if(upgrades.Length == 0) + { + var err = new Label(); + err.AutoSize = true; + err.Text = "There are no apps in this list! Come back later for more."; + pnlappslist.Controls.Add(err); + err.Show(); + } + else + { + var fl = new FlowLayoutPanel(); + fl.Dock = DockStyle.Fill; + pnlappslist.Controls.Add(fl); + fl.Show(); + foreach(var upg in upgrades) + { + var pnl = new Panel(); + pnl.Height = 250; + pnl.Width = 200; + fl.Controls.Add(pnl); + pnl.Show(); + var upgTitle = new Label(); + upgTitle.Text = upg.Name; + upgTitle.Dock = DockStyle.Top; + upgTitle.AutoSize = true; + upgTitle.MaximumSize = new Size(pnl.Width, 0); + upgTitle.Tag = "header3"; + pnl.Controls.Add(upgTitle); + upgTitle.Show(); + + var cp_display = new Panel(); + cp_display.Height = 30; + cp_display.Dock = DockStyle.Bottom; + pnl.Controls.Add(cp_display); + cp_display.Show(); + + var cp_value = new Label(); + if (Shiftorium.UpgradeInstalled(upg.ID)) + { + cp_value.Text = "Out of stock."; + } + else + { + cp_value.Text = $"{upg.Cost} CP"; + } + cp_value.AutoSize = true; + cp_value.Top = (cp_display.Height - cp_value.Height) / 2; + cp_value.Left = 5; + cp_display.Controls.Add(cp_value); + cp_value.Show(); + + + if(cp_value.Text != "Out of stock.") + { + var more_info = new Button(); + more_info.Text = "More info"; + more_info.Click += (o, a) => + { + ViewMoreInfo(upg); + }; + more_info.AutoSize = false; + more_info.AutoSizeMode = AutoSizeMode.GrowAndShrink; + more_info.Top = (cp_display.Height - more_info.Height) / 2; + more_info.Left = cp_display.Width - more_info.Width - 5; + cp_display.Controls.Add(more_info); + more_info.Show(); + } + + var desc = new Label(); + desc.Text = upg.Description; + desc.AutoSize = false; + desc.Dock = DockStyle.Fill; + pnl.Controls.Add(desc); + desc.Show(); + desc.BringToFront(); + + + ControlManager.SetupControls(pnl); + } + } + } + + public void ViewMoreInfo(ShiftoriumUpgrade upg) + { + + } + + public ShiftoriumUpgrade[] GetAllInCategory() + { + var upgrades = Shiftorium.GetDefaults().Where(x => (x.Dependencies == null) ? false : x.Dependencies.Contains("appscape_")); + if (upgrades.Count() == 0) + return new ShiftoriumUpgrade[0]; + + if (Category == "All") + return upgrades.ToArray(); + else + return upgrades.Where(x => x.Category == Category).ToArray(); + } + + public void Setup() + { + flcategories.Controls.Clear(); + foreach(var cat in this.GetCategories()) + { + var btn = new Button(); + btn.Text = cat; + btn.Click += (o, a) => + { + SetupCategory(cat); + }; + ControlManager.SetupControl(btn); + btn.Width = flcategories.Width - 2; + flcategories.Controls.Add(btn); + btn.Show(); + } + SetupCategory("All"); + } + } +} + +namespace ShiftOS.WinForms +{ + /// + /// Special version of for specifying Appscape applications as Shiftorium upgrades. + /// + public class AppscapeEntryAttribute : RequiresUpgradeAttribute + { + public AppscapeEntryAttribute(string name, string description, long cost, string dependencies = "", string category = "Misc") : base((string.IsNullOrWhiteSpace(dependencies)) ? name.ToLower().Replace(" ","_") : name.ToLower().Replace(" ", "_") + dependencies) + { + Name = name; + Description = description; + Category = category; + Cost = cost; + DependencyString = dependencies; + } + + 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 string DependencyString { get; private set; } + } +} \ No newline at end of file -- cgit v1.2.3 From bc66ccccd77627d78f57bc8cfdaa851c9bbd1623 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 23 Apr 2017 15:36:02 -0400 Subject: more appscape ui work --- ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs') diff --git a/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs b/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs index 88db07b..53bd6d1 100644 --- a/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs +++ b/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs @@ -37,7 +37,7 @@ namespace ShiftOS.WinForms.ShiftnetSites public string[] GetCategories() { - var upgrades = Shiftorium.GetDefaults().Where(x => x.Dependencies.Contains("appscape_")); + var upgrades = Shiftorium.GetDefaults().Where(x => (x.Dependencies == null) ? false : x.Dependencies.Contains("appscape_")); List cats = new List(); cats.Add("All"); try -- cgit v1.2.3 From ba157cdeddef2a856600bb6e12aef9496974a213 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 23 Apr 2017 18:22:16 -0400 Subject: Finish Appscape. --- ShiftOS.WinForms/Applications/FormatEditor.cs | 2 +- ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs | 172 ++++++++++++++++++++++++- 2 files changed, 170 insertions(+), 4 deletions(-) (limited to 'ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs') diff --git a/ShiftOS.WinForms/Applications/FormatEditor.cs b/ShiftOS.WinForms/Applications/FormatEditor.cs index db52d85..6c84661 100644 --- a/ShiftOS.WinForms/Applications/FormatEditor.cs +++ b/ShiftOS.WinForms/Applications/FormatEditor.cs @@ -36,7 +36,7 @@ using ShiftOS.Engine; namespace ShiftOS.WinForms.Applications { [MultiplayerOnly] [Launcher("Format Editor", true, "al_format_editor", "Customization")] - [AppscapeEntry("Format Editor", "Edit the syntax of your Terminal to be however you like.", 750, "file_skimmer", "Customization")] + [AppscapeEntry("Format Editor", "Edit the syntax of your Terminal to be however you like.", 740, 750, "file_skimmer", "Customization")] [WinOpen("formateditor")] [DefaultTitle("Format Editor")] [DefaultIcon("iconFormatEditor")] diff --git a/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs b/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs index 53bd6d1..fc10a17 100644 --- a/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs +++ b/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs @@ -9,6 +9,9 @@ using System.Threading.Tasks; using System.Windows.Forms; using ShiftOS.Engine; using ShiftOS.WinForms.Tools; +using System.IO; +using System.Reflection; +using System.Threading; namespace ShiftOS.WinForms.ShiftnetSites { @@ -102,7 +105,7 @@ namespace ShiftOS.WinForms.ShiftnetSites var cp_value = new Label(); if (Shiftorium.UpgradeInstalled(upg.ID)) { - cp_value.Text = "Out of stock."; + cp_value.Text = "Already Purchased."; } else { @@ -115,7 +118,7 @@ namespace ShiftOS.WinForms.ShiftnetSites cp_value.Show(); - if(cp_value.Text != "Out of stock.") + if(cp_value.Text != "Already Purchased.") { var more_info = new Button(); more_info.Text = "More info"; @@ -147,6 +150,121 @@ namespace ShiftOS.WinForms.ShiftnetSites public void ViewMoreInfo(ShiftoriumUpgrade upg) { + lbtitle.Text = upg.Name; + pnlappslist.Controls.Clear(); + + var cp_display = new Panel(); + cp_display.Height = 30; + cp_display.Dock = DockStyle.Bottom; + pnlappslist.Controls.Add(cp_display); + cp_display.Show(); + + var cp_value = new Label(); + if (Shiftorium.UpgradeInstalled(upg.ID)) + { + cp_value.Text = "Already Purchased."; + } + else + { + cp_value.Text = $"{upg.Cost} CP"; + } + cp_value.AutoSize = true; + cp_value.Top = (cp_display.Height - cp_value.Height) / 2; + cp_value.Left = 5; + cp_display.Controls.Add(cp_value); + cp_value.Show(); + + + if (cp_value.Text != "Already Purchased.") + { + var more_info = new Button(); + more_info.Text = "More info"; + more_info.Click += (o, a) => + { + //Detect if dependencies are installed. + if (Shiftorium.DependenciesInstalled(upg)) + { + //Detect sufficient codepoints + if (SaveSystem.CurrentSave.Codepoints >= upg.Cost) + { + Infobox.PromptYesNo("Confirm Purchase", "Do you want to purchase " + upg.Name + " from Appscape for " + upg.Cost.ToString() + " Codepoints?", (result) => + { + if (result == true) + { + SaveSystem.CurrentSave.Codepoints -= upg.Cost; + 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) + { + if (attrib.Name == upg.Name) + { + var installer = new Applications.Installer(); + var installation = new AppscapeInstallation(upg.Name, attrib.DownloadSize, upg.ID); + AppearanceManager.SetupWindow(installer); + installer.InitiateInstall(installation); + } + } + } + } + catch { } + } + } + + } + }); + } + else + { + Infobox.Show("Not enough Codepoints", "You do not have enough Codepoints to buy this package."); + } + } + else + { + Infobox.Show("Missing dependencies", "You are missing some Shiftorium upgrades that this package requires. Please upgrade your system and try again!"); + } + }; + more_info.AutoSize = false; + more_info.AutoSizeMode = AutoSizeMode.GrowAndShrink; + more_info.Top = (cp_display.Height - more_info.Height) / 2; + more_info.Left = cp_display.Width - more_info.Width - 5; + cp_display.Controls.Add(more_info); + more_info.Show(); + } + + var desc = new Label(); + desc.Text = upg.Description; + desc.AutoSize = false; + desc.Dock = DockStyle.Fill; + pnlappslist.Controls.Add(desc); + desc.Show(); + desc.BringToFront(); + + desc.Text += Environment.NewLine + Environment.NewLine + "Dependencies:" + Environment.NewLine; + string[] deplist = upg.Dependencies.Split(';'); + if(deplist.Length > 1) + { + for(int i = 1; i < deplist.Length; i++) + { + ShiftoriumUpgrade dep = Shiftorium.GetDefaults().FirstOrDefault(x => x.ID == deplist[i]); + if(dep != null) + { + desc.Text += $" - {dep.Name}{Environment.NewLine}"; + } + } + } + else + { + desc.Text += " - No dependencies."; + } + } @@ -181,6 +299,52 @@ namespace ShiftOS.WinForms.ShiftnetSites SetupCategory("All"); } } + + public class AppscapeInstallation : Applications.Installation + { + public AppscapeInstallation(string name, int size, string s_id) + { + Name = name; + ShiftoriumId = s_id; + Size = size; + } + + public string ShiftoriumId { get; private set; } + public int Size { get; private set; } + public string Name { get; private set; } + + protected override void Run() + { + this.SetStatus("Downloading..."); + SetProgress(0); + new Thread(() => + { + int i = 0; + while (i <= Size) + { + SetProgress((i / Size) * 100); + i++; + Thread.Sleep(100); + } + SetProgress(0); + SetStatus("Installing..."); + i = 0; + while (i <= Size) + { + SetProgress((i / Size) * 100); + i++; + Thread.Sleep(50); + } + Shiftorium.Buy(ShiftoriumId, 0); + Desktop.InvokeOnWorkerThread(() => + { + Infobox.Show("Install complete!", "The installation of " + Name + " has completed."); + SaveSystem.SaveGame(); + }); + }) + { IsBackground = true }.Start(); + } + } } namespace ShiftOS.WinForms @@ -190,13 +354,14 @@ namespace ShiftOS.WinForms /// public class AppscapeEntryAttribute : RequiresUpgradeAttribute { - public AppscapeEntryAttribute(string name, string description, long cost, string dependencies = "", string category = "Misc") : base((string.IsNullOrWhiteSpace(dependencies)) ? name.ToLower().Replace(" ","_") : name.ToLower().Replace(" ", "_") + dependencies) + public AppscapeEntryAttribute(string name, string description, int downloadSize, long cost, string dependencies = "", string category = "Misc") : base((string.IsNullOrWhiteSpace(dependencies)) ? name.ToLower().Replace(" ", "_") : name.ToLower().Replace(" ", "_") + dependencies) { Name = name; Description = description; Category = category; Cost = cost; DependencyString = dependencies; + DownloadSize = downloadSize; } public string Name { get; private set; } @@ -204,5 +369,6 @@ namespace ShiftOS.WinForms public string Category { get; private set; } public long Cost { get; private set; } public string DependencyString { get; private set; } + public int DownloadSize { get; private set; } } } \ No newline at end of file -- cgit v1.2.3 From d4316e75fc876ec7ceac3f1a9362ef7b36ca40cf Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 24 Apr 2017 21:01:42 -0400 Subject: Audio Player work. --- .../Applications/AudioPlayer.Designer.cs | 174 ++++++++++++++++++++- ShiftOS.WinForms/Applications/AudioPlayer.cs | 133 +++++++++++++++- ShiftOS.WinForms/Applications/AudioPlayer.resx | 134 ++++++++++++++++ ShiftOS.WinForms/Resources/Shiftorium.txt | 7 - ShiftOS.WinForms/ShiftOS.WinForms.csproj | 26 +++ ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs | 2 +- ShiftOS.WinForms/packages.config | 1 + ShiftOS_TheReturn/Shiftorium.cs | 10 ++ 8 files changed, 477 insertions(+), 10 deletions(-) create mode 100644 ShiftOS.WinForms/Applications/AudioPlayer.resx (limited to 'ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs') diff --git a/ShiftOS.WinForms/Applications/AudioPlayer.Designer.cs b/ShiftOS.WinForms/Applications/AudioPlayer.Designer.cs index 83f41d2..825413d 100644 --- a/ShiftOS.WinForms/Applications/AudioPlayer.Designer.cs +++ b/ShiftOS.WinForms/Applications/AudioPlayer.Designer.cs @@ -52,10 +52,182 @@ namespace ShiftOS.WinForms.Applications /// private void InitializeComponent() { - components = new System.ComponentModel.Container(); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AudioPlayer)); + this.wpaudio = new AxWMPLib.AxWindowsMediaPlayer(); + this.toolStripContainer1 = new System.Windows.Forms.ToolStripContainer(); + this.lbtracks = new System.Windows.Forms.ListBox(); + 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.clearToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.shuffleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.removeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + ((System.ComponentModel.ISupportInitialize)(this.wpaudio)).BeginInit(); + this.toolStripContainer1.ContentPanel.SuspendLayout(); + this.toolStripContainer1.TopToolStripPanel.SuspendLayout(); + this.toolStripContainer1.SuspendLayout(); + this.flcontrols.SuspendLayout(); + this.menuStrip1.SuspendLayout(); + this.SuspendLayout(); + // + // 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(798, 471); + this.wpaudio.TabIndex = 0; + this.wpaudio.Visible = false; + // + // toolStripContainer1 + // + // + // toolStripContainer1.ContentPanel + // + this.toolStripContainer1.ContentPanel.Controls.Add(this.lbtracks); + this.toolStripContainer1.ContentPanel.Controls.Add(this.flcontrols); + this.toolStripContainer1.ContentPanel.Size = new System.Drawing.Size(798, 447); + 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(798, 471); + this.toolStripContainer1.TabIndex = 1; + this.toolStripContainer1.Text = "toolStripContainer1"; + // + // toolStripContainer1.TopToolStripPanel + // + this.toolStripContainer1.TopToolStripPanel.Controls.Add(this.menuStrip1); + // + // lbtracks + // + this.lbtracks.Dock = System.Windows.Forms.DockStyle.Fill; + this.lbtracks.FormattingEnabled = true; + this.lbtracks.Location = new System.Drawing.Point(0, 0); + this.lbtracks.Name = "lbtracks"; + this.lbtracks.Size = new System.Drawing.Size(798, 418); + this.lbtracks.TabIndex = 1; + this.lbtracks.SelectedIndexChanged += new System.EventHandler(this.lbtracks_SelectedIndexChanged); + // + // 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, 418); + this.flcontrols.Name = "flcontrols"; + this.flcontrols.Size = new System.Drawing.Size(798, 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; + // + // menuStrip1 + // + this.menuStrip1.Dock = System.Windows.Forms.DockStyle.None; + this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.addSongToolStripMenuItem, + this.clearToolStripMenuItem, + this.shuffleToolStripMenuItem, + this.removeToolStripMenuItem}); + this.menuStrip1.Location = new System.Drawing.Point(0, 0); + this.menuStrip1.Name = "menuStrip1"; + this.menuStrip1.Size = new System.Drawing.Size(798, 24); + this.menuStrip1.TabIndex = 0; + this.menuStrip1.Text = "menuStrip1"; + // + // addSongToolStripMenuItem + // + this.addSongToolStripMenuItem.Name = "addSongToolStripMenuItem"; + this.addSongToolStripMenuItem.Size = new System.Drawing.Size(71, 20); + this.addSongToolStripMenuItem.Text = "Add Song"; + this.addSongToolStripMenuItem.Click += new System.EventHandler(this.addSongToolStripMenuItem_Click); + // + // clearToolStripMenuItem + // + this.clearToolStripMenuItem.Name = "clearToolStripMenuItem"; + this.clearToolStripMenuItem.Size = new System.Drawing.Size(46, 20); + this.clearToolStripMenuItem.Text = "Clear"; + this.clearToolStripMenuItem.Click += new System.EventHandler(this.clearToolStripMenuItem_Click); + // + // shuffleToolStripMenuItem + // + this.shuffleToolStripMenuItem.Name = "shuffleToolStripMenuItem"; + this.shuffleToolStripMenuItem.Size = new System.Drawing.Size(56, 20); + this.shuffleToolStripMenuItem.Text = "Shuffle"; + this.shuffleToolStripMenuItem.Click += new System.EventHandler(this.shuffleToolStripMenuItem_Click); + // + // removeToolStripMenuItem + // + this.removeToolStripMenuItem.Name = "removeToolStripMenuItem"; + this.removeToolStripMenuItem.Size = new System.Drawing.Size(62, 20); + this.removeToolStripMenuItem.Text = "Remove"; + this.removeToolStripMenuItem.Click += new System.EventHandler(this.removeToolStripMenuItem_Click); + // + // AudioPlayer + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.toolStripContainer1); + this.Controls.Add(this.wpaudio); + this.Name = "AudioPlayer"; + this.Size = new System.Drawing.Size(798, 471); + ((System.ComponentModel.ISupportInitialize)(this.wpaudio)).EndInit(); + 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(); + this.ResumeLayout(false); + } #endregion + + private AxWMPLib.AxWindowsMediaPlayer wpaudio; + private System.Windows.Forms.ToolStripContainer toolStripContainer1; + private System.Windows.Forms.MenuStrip menuStrip1; + private System.Windows.Forms.ToolStripMenuItem addSongToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem clearToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem shuffleToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem removeToolStripMenuItem; + private System.Windows.Forms.ListBox lbtracks; + private System.Windows.Forms.FlowLayoutPanel flcontrols; + private System.Windows.Forms.Button btnplay; + private Controls.ShiftedProgressBar pgplaytime; } } 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; + } + } } } diff --git a/ShiftOS.WinForms/Applications/AudioPlayer.resx b/ShiftOS.WinForms/Applications/AudioPlayer.resx new file mode 100644 index 0000000..d484b91 --- /dev/null +++ b/ShiftOS.WinForms/Applications/AudioPlayer.resx @@ -0,0 +1,134 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + + AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w + LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACFTeXN0 + ZW0uV2luZG93cy5Gb3Jtcy5BeEhvc3QrU3RhdGUBAAAABERhdGEHAgIAAAAJAwAAAA8DAAAAtwAAAAIB + AAAAAQAAAAAAAAAAAAAAAKIAAAAAAwAACAAAAAAABQAAAAAAAADwPwMAAAAAAAUAAAAAAAAAAAAIAAIA + AAAAAAMAAQAAAAsA//8DAAAAAAALAP//CAACAAAAAAADADIAAAALAAAACAAKAAAAbgBvAG4AZQAAAAsA + AAALAAAACwD//wsA//8LAAAACAACAAAAAAAIAAIAAAAAAAgAAgAAAAAACAACAAAAAAALAAAAelIAAK4w + AAAL + + + + 17, 17 + + \ No newline at end of file diff --git a/ShiftOS.WinForms/Resources/Shiftorium.txt b/ShiftOS.WinForms/Resources/Shiftorium.txt index e68277c..79d4dd0 100644 --- a/ShiftOS.WinForms/Resources/Shiftorium.txt +++ b/ShiftOS.WinForms/Resources/Shiftorium.txt @@ -633,13 +633,6 @@ Category: "Enhancements", Dependencies: "mud_fundamentals;window_manager;pong_upgrade" }, - { - Name: "Audio Player", - Cost: 10000, - Description: "Want to listen to the greatest tunes? Well get this app asap!", - Category: "Applications", - Dependencies: "desktop;wm_free_placement" - }, { Name: "Audio Player AL", Cost: 150, diff --git a/ShiftOS.WinForms/ShiftOS.WinForms.csproj b/ShiftOS.WinForms/ShiftOS.WinForms.csproj index a8d1aaa..dac803d 100644 --- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj +++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj @@ -38,6 +38,10 @@ True + + ..\packages\NAudio.1.8.0\lib\net35\NAudio.dll + True + ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll True @@ -374,6 +378,9 @@ Artpad.cs + + AudioPlayer.cs + Calculator.cs @@ -746,6 +753,25 @@ + + + {6BF52A50-394A-11D3-B153-00C04F79FAA6} + 1 + 0 + 0 + aximp + False + + + {6BF52A50-394A-11D3-B153-00C04F79FAA6} + 1 + 0 + 0 + tlbimp + False + True + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + + AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w + LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACFTeXN0 + ZW0uV2luZG93cy5Gb3Jtcy5BeEhvc3QrU3RhdGUBAAAABERhdGEHAgIAAAAJAwAAAA8DAAAAtwAAAAIB + AAAAAQAAAAAAAAAAAAAAAKIAAAAAAwAACAAAAAAABQAAAAAAAADwPwMAAAAAAAUAAAAAAAAAAAAIAAIA + AAAAAAMAAQAAAAsA//8DAAAAAAALAP//CAACAAAAAAADADIAAAALAAAACAAKAAAAbgBvAG4AZQAAAAsA + AAALAAAACwD//wsA//8LAAAACAACAAAAAAAIAAIAAAAAAAgAAgAAAAAACAACAAAAAAALAAAAelIAAK4w + AAAL + + + + 17, 17 + + \ No newline at end of file diff --git a/ShiftOS.WinForms/ShiftOS.WinForms.csproj b/ShiftOS.WinForms/ShiftOS.WinForms.csproj index dac803d..7c39078 100644 --- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj +++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj @@ -244,6 +244,12 @@ UpdateManager.cs + + UserControl + + + VideoPlayer.cs + UserControl @@ -459,6 +465,9 @@ UpdateManager.cs + + VideoPlayer.cs + WidgetManagerFrontend.cs diff --git a/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs b/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs index 17a6e4c..84783e5 100644 --- a/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs +++ b/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs @@ -79,6 +79,7 @@ namespace ShiftOS.WinForms.ShiftnetSites var fl = new FlowLayoutPanel(); fl.Dock = DockStyle.Fill; pnlappslist.Controls.Add(fl); + fl.AutoScroll = true; fl.Show(); foreach(var upg in upgrades) { @@ -148,6 +149,20 @@ namespace ShiftOS.WinForms.ShiftnetSites } } + public bool DependenciesInstalled(ShiftoriumUpgrade upg) + { + string[] split = upg.Dependencies.Split(';'); + foreach(var u in split) + { + if (!u.StartsWith("appscape_handled")) + { + if (!Shiftorium.UpgradeInstalled(u)) + return false; + } + } + return true; + } + public void ViewMoreInfo(ShiftoriumUpgrade upg) { lbtitle.Text = upg.Name; @@ -178,11 +193,11 @@ namespace ShiftOS.WinForms.ShiftnetSites if (cp_value.Text != "Already Purchased.") { var more_info = new Button(); - more_info.Text = "More info"; + more_info.Text = "Buy"; more_info.Click += (o, a) => { //Detect if dependencies are installed. - if (Shiftorium.DependenciesInstalled(upg)) + if (DependenciesInstalled(upg)) { //Detect sufficient codepoints if (SaveSystem.CurrentSave.Codepoints >= upg.Cost) @@ -210,6 +225,7 @@ namespace ShiftOS.WinForms.ShiftnetSites var installation = new AppscapeInstallation(upg.Name, attrib.DownloadSize, upg.ID); AppearanceManager.SetupWindow(installer); installer.InitiateInstall(installation); + return; } } } @@ -237,6 +253,7 @@ namespace ShiftOS.WinForms.ShiftnetSites more_info.Left = cp_display.Width - more_info.Width - 5; cp_display.Controls.Add(more_info); more_info.Show(); + ControlManager.SetupControls(pnlappslist); } var desc = new Label(); @@ -311,38 +328,33 @@ namespace ShiftOS.WinForms.ShiftnetSites public string ShiftoriumId { get; private set; } public int Size { get; private set; } - public string Name { get; private set; } - + protected override void Run() { this.SetStatus("Downloading..."); SetProgress(0); - new Thread(() => + int i = 0; + while (i <= Size) { - int i = 0; - while (i <= Size) - { - SetProgress((i / Size) * 100); - i++; - Thread.Sleep(100); - } - SetProgress(0); - SetStatus("Installing..."); - i = 0; - while (i <= Size) - { - SetProgress((i / Size) * 100); - i++; - Thread.Sleep(50); - } - Shiftorium.Buy(ShiftoriumId, 0); - Desktop.InvokeOnWorkerThread(() => - { - Infobox.Show("Install complete!", "The installation of " + Name + " has completed."); - SaveSystem.SaveGame(); - }); - }) - { IsBackground = true }.Start(); + SetProgress((i / Size) * 100); + i++; + Thread.Sleep(100); + } + SetProgress(0); + SetStatus("Installing..."); + i = 0; + while (i <= Size) + { + SetProgress((i / Size) * 100); + i++; + Thread.Sleep(50); + } + Shiftorium.Buy(ShiftoriumId, 0); + Desktop.InvokeOnWorkerThread(() => + { + Infobox.Show("Install complete!", "The installation of " + Name + " has completed."); + SaveSystem.SaveGame(); + }); } } } diff --git a/ShiftOS_TheReturn/Paths.cs b/ShiftOS_TheReturn/Paths.cs index a84271b..10fd7d7 100644 --- a/ShiftOS_TheReturn/Paths.cs +++ b/ShiftOS_TheReturn/Paths.cs @@ -208,7 +208,8 @@ namespace ShiftOS.Engine foreach (var file in System.IO.Directory.GetFiles(folder)) { string mfsDir = file.Replace(SharedFolder, $"{mount}:").Replace("\\", "/"); - WriteAllBytes(mfsDir, System.IO.File.ReadAllBytes(file)); + if (!FileExists(mfsDir)) + WriteAllBytes(mfsDir, System.IO.File.ReadAllBytes(file)); } foreach (var directory in System.IO.Directory.GetDirectories(folder)) { -- cgit v1.2.3 From 91c6b3bf1c709cc392d52391407a70feabc9214b Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 25 Apr 2017 12:24:44 -0400 Subject: fix Appscape install bugs --- ShiftOS.WinForms/Applications/Installer.cs | 11 ++++++++--- ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs | 20 +++++++++++++------- 2 files changed, 21 insertions(+), 10 deletions(-) (limited to 'ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs') diff --git a/ShiftOS.WinForms/Applications/Installer.cs b/ShiftOS.WinForms/Applications/Installer.cs index 2193f8a..4d8b712 100644 --- a/ShiftOS.WinForms/Applications/Installer.cs +++ b/ShiftOS.WinForms/Applications/Installer.cs @@ -8,6 +8,7 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using ShiftOS.Engine; +using System.Threading; namespace ShiftOS.WinForms.Applications { @@ -29,21 +30,21 @@ namespace ShiftOS.WinForms.Applications pnlselectfile.Hide(); install.ProgressReported += (p) => { - this.Invoke(new Action(() => + Desktop.InvokeOnWorkerThread(new Action(() => { pginstall.Value = p; })); }; install.StatusReported += (s) => { - this.Invoke(new Action(() => + Desktop.InvokeOnWorkerThread(new Action(() => { lbprogress.Text = s; })); }; install.InstallCompleted += () => { - this.Invoke(new Action(() => + Desktop.InvokeOnWorkerThread(new Action(() => { lbtitle.Text = "Select file"; pnlselectfile.Show(); @@ -51,6 +52,10 @@ namespace ShiftOS.WinForms.Applications isInstalling = false; InstallCompleted?.Invoke(); }; + while (!this.Visible) + { + + } isInstalling = true; install.Install(); } diff --git a/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs b/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs index 84783e5..691f622 100644 --- a/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs +++ b/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs @@ -336,22 +336,28 @@ namespace ShiftOS.WinForms.ShiftnetSites int i = 0; while (i <= Size) { - SetProgress((i / Size) * 100); - i++; - Thread.Sleep(100); + double progress = ((i / Size) * 100); + + SetProgress((int)progress); + + i += Applications.DownloadManager.GetDownloadSpeed(); + Thread.Sleep(1000); } SetProgress(0); SetStatus("Installing..."); i = 0; while (i <= Size) { - SetProgress((i / Size) * 100); - i++; - Thread.Sleep(50); + double progress = ((i / Size) * 100); + + SetProgress((int)progress); + + i+=1024; + Thread.Sleep(1000); } - Shiftorium.Buy(ShiftoriumId, 0); Desktop.InvokeOnWorkerThread(() => { + Shiftorium.Buy(ShiftoriumId, 0); Infobox.Show("Install complete!", "The installation of " + Name + " has completed."); SaveSystem.SaveGame(); }); -- cgit v1.2.3 From 6f250a0498a2318e363c82f0647866572e0895bc Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 28 Apr 2017 21:47:35 -0400 Subject: fix appscape button sizing --- ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs') diff --git a/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs b/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs index 691f622..fa575f4 100644 --- a/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs +++ b/ShiftOS.WinForms/ShiftnetSites/AppscapeMain.cs @@ -309,7 +309,7 @@ namespace ShiftOS.WinForms.ShiftnetSites SetupCategory(cat); }; ControlManager.SetupControl(btn); - btn.Width = flcategories.Width - 2; + btn.Width = flcategories.Width - 10; flcategories.Controls.Add(btn); btn.Show(); } -- cgit v1.2.3