From 1f733909514f1b069533304df11fb7ba3d258f3f Mon Sep 17 00:00:00 2001 From: cadaei Date: Tue, 8 Oct 2019 21:25:42 +0200 Subject: [PATCH 01/14] added Play-button to test custom sounds in the Timer-tab (#974). --- ARKBreedingStats/Form1.cs | 6 +- ARKBreedingStats/Properties/AssemblyInfo.cs | 2 +- ARKBreedingStats/TimerControl.Designer.cs | 31 ++++-- ARKBreedingStats/TimerControl.cs | 115 ++++++++++++-------- ARKBreedingStats/raising/RaisingControl.cs | 4 +- 5 files changed, 99 insertions(+), 59 deletions(-) diff --git a/ARKBreedingStats/Form1.cs b/ARKBreedingStats/Form1.cs index 8785d5a4..42775d6c 100644 --- a/ARKBreedingStats/Form1.cs +++ b/ARKBreedingStats/Form1.cs @@ -130,7 +130,7 @@ public Form1() breedingPlan1.ExportToClipboard += ExportAsTextToClipboard; breedingPlan1.SetMessageLabelText += SetMessageLabelText; breedingPlan1.SetGlobalSpecies += SetSpecies; - timerList1.onTimerChange += SetCollectionChanged; + timerList1.OnTimerChange += SetCollectionChanged; breedingPlan1.BindChildrenControlEvents(); raisingControl1.onChange += SetCollectionChanged; tamingControl1.CreateTimer += CreateTimer; @@ -2067,7 +2067,7 @@ private void wildValuesToolStripMenuItem_Click(object sender, EventArgs e) private void CreateTimer(string name, DateTime time, Creature c, string group) { - timerList1.addTimer(name, time, c, group); + timerList1.AddTimer(name, time, c, group); } private void TestEnteredDragData(object sender, DragEventArgs e) @@ -2722,7 +2722,7 @@ private void toolStripButtonDeleteExpiredIncubationTimers_Click(object sender, E if (tabControlMain.SelectedTab == tabPageRaising) raisingControl1.DeleteAllExpiredIncubationTimers(); else if (tabControlMain.SelectedTab == tabPageTimer) - timerList1.deleteAllExpiredTimers(); + timerList1.DeleteAllExpiredTimers(); } private void OcrupdateWhiteThreshold(int value) diff --git a/ARKBreedingStats/Properties/AssemblyInfo.cs b/ARKBreedingStats/Properties/AssemblyInfo.cs index a005eae2..6b3e4c65 100644 --- a/ARKBreedingStats/Properties/AssemblyInfo.cs +++ b/ARKBreedingStats/Properties/AssemblyInfo.cs @@ -30,6 +30,6 @@ // Revision // [assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("0.34.2.0")] +[assembly: AssemblyFileVersion("0.34.4.0")] [assembly: NeutralResourcesLanguage("en")] diff --git a/ARKBreedingStats/TimerControl.Designer.cs b/ARKBreedingStats/TimerControl.Designer.cs index 4fe22d83..7d244248 100644 --- a/ARKBreedingStats/TimerControl.Designer.cs +++ b/ARKBreedingStats/TimerControl.Designer.cs @@ -40,6 +40,7 @@ private void InitializeComponent() this.removeAllExpiredTimersToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); this.groupBoxAddTimer = new System.Windows.Forms.GroupBox(); + this.btOpenSoundFolder = new System.Windows.Forms.Button(); this.SoundListBox = new System.Windows.Forms.ComboBox(); this.SoundLabel = new System.Windows.Forms.Label(); this.groupBox1 = new System.Windows.Forms.GroupBox(); @@ -51,7 +52,7 @@ private void InitializeComponent() this.dateTimePickerTimerFinish = new System.Windows.Forms.DateTimePicker(); this.textBoxTimerName = new System.Windows.Forms.TextBox(); this.buttonAddTimer = new System.Windows.Forms.Button(); - this.btOpenSoundFolder = new System.Windows.Forms.Button(); + this.btPlaySelectedSound = new System.Windows.Forms.Button(); this.contextMenuStrip1.SuspendLayout(); this.tableLayoutPanel1.SuspendLayout(); this.groupBoxAddTimer.SuspendLayout(); @@ -146,6 +147,7 @@ private void InitializeComponent() // // groupBoxAddTimer // + this.groupBoxAddTimer.Controls.Add(this.btPlaySelectedSound); this.groupBoxAddTimer.Controls.Add(this.btOpenSoundFolder); this.groupBoxAddTimer.Controls.Add(this.SoundListBox); this.groupBoxAddTimer.Controls.Add(this.SoundLabel); @@ -162,6 +164,16 @@ private void InitializeComponent() this.groupBoxAddTimer.TabStop = false; this.groupBoxAddTimer.Text = "Add Manual Timer"; // + // btOpenSoundFolder + // + this.btOpenSoundFolder.Location = new System.Drawing.Point(72, 97); + this.btOpenSoundFolder.Name = "btOpenSoundFolder"; + this.btOpenSoundFolder.Size = new System.Drawing.Size(156, 23); + this.btOpenSoundFolder.TabIndex = 15; + this.btOpenSoundFolder.Text = "Open custom sounds folder"; + this.btOpenSoundFolder.UseVisualStyleBackColor = true; + this.btOpenSoundFolder.Click += new System.EventHandler(this.btOpenSoundFolder_Click); + // // SoundListBox // this.SoundListBox.FormattingEnabled = true; @@ -263,15 +275,15 @@ private void InitializeComponent() this.buttonAddTimer.UseVisualStyleBackColor = true; this.buttonAddTimer.Click += new System.EventHandler(this.buttonAddTimer_Click); // - // btOpenSoundFolder + // btPlaySelectedSound // - this.btOpenSoundFolder.Location = new System.Drawing.Point(72, 97); - this.btOpenSoundFolder.Name = "btOpenSoundFolder"; - this.btOpenSoundFolder.Size = new System.Drawing.Size(156, 23); - this.btOpenSoundFolder.TabIndex = 15; - this.btOpenSoundFolder.Text = "Open custom sounds folder"; - this.btOpenSoundFolder.UseVisualStyleBackColor = true; - this.btOpenSoundFolder.Click += new System.EventHandler(this.btOpenSoundFolder_Click); + this.btPlaySelectedSound.Location = new System.Drawing.Point(6, 97); + this.btPlaySelectedSound.Name = "btPlaySelectedSound"; + this.btPlaySelectedSound.Size = new System.Drawing.Size(60, 23); + this.btPlaySelectedSound.TabIndex = 16; + this.btPlaySelectedSound.Text = "⏵"; + this.btPlaySelectedSound.UseVisualStyleBackColor = true; + this.btPlaySelectedSound.Click += new System.EventHandler(this.btPlaySelectedSound_Click); // // TimerControl // @@ -315,5 +327,6 @@ private void InitializeComponent() private System.Windows.Forms.ComboBox SoundListBox; private System.Windows.Forms.Label SoundLabel; private System.Windows.Forms.Button btOpenSoundFolder; + private System.Windows.Forms.Button btPlaySelectedSound; } } diff --git a/ARKBreedingStats/TimerControl.cs b/ARKBreedingStats/TimerControl.cs index 167bbab9..b2f6f2e8 100644 --- a/ARKBreedingStats/TimerControl.cs +++ b/ARKBreedingStats/TimerControl.cs @@ -18,7 +18,7 @@ public partial class TimerControl : UserControl public bool updateTimer; private List timerListEntries; - public event Form1.collectionChangedEventHandler onTimerChange; + public event Form1.collectionChangedEventHandler OnTimerChange; private List creatures; public SoundPlayer[] sounds; private List timerAlerts; @@ -46,12 +46,14 @@ public TimerControl() int i = 0; foreach (KeyValuePair ts in times) { - var bta = new uiControls.ButtonAddTime(); - bta.timeSpan = ts.Value; - bta.Text = ts.Key; + var bta = new uiControls.ButtonAddTime + { + timeSpan = ts.Value, + Text = ts.Key, + Size = new Size(54, 23), + Location = new Point(6 + i % 3 * 60, 48 + i / 3 * 29) + }; bta.addTimer += buttonAddTime_addTimer; - bta.Size = new Size(54, 23); - bta.Location = new Point(6 + i % 3 * 60, 48 + i / 3 * 29); groupBox1.Controls.Add(bta); i++; } @@ -74,7 +76,7 @@ private void TimerControl_Load(object sender, EventArgs e) SoundListBox.SelectedIndex = 0; } - public void addTimer(string name, DateTime finishTime, Creature c, string group = "Custom") + public void AddTimer(string name, DateTime finishTime, Creature c, string group = "Custom") { TimerListEntry tle = new TimerListEntry { @@ -86,7 +88,7 @@ public void addTimer(string name, DateTime finishTime, Creature c, string group ? null : SoundListBox.SelectedItem as string }; - tle.lvi = createLvi(name, finishTime, tle); + tle.lvi = CreateLvi(name, finishTime, tle); int i = 0; while (i < listViewTimer.Items.Count && ((TimerListEntry)listViewTimer.Items[i].Tag).time < finishTime) { @@ -94,18 +96,18 @@ public void addTimer(string name, DateTime finishTime, Creature c, string group } listViewTimer.Items.Insert(i, tle.lvi); timerListEntries.Add(tle); - onTimerChange?.Invoke(); + OnTimerChange?.Invoke(); } - private void removeTimer(TimerListEntry timerEntry, bool invokeChange = true) + private void RemoveTimer(TimerListEntry timerEntry, bool invokeChange = true) { timerEntry.lvi.Remove(); timerListEntries.Remove(timerEntry); if (invokeChange) - onTimerChange?.Invoke(); + OnTimerChange?.Invoke(); } - private ListViewItem createLvi(string name, DateTime finishTime, TimerListEntry tle) + private ListViewItem CreateLvi(string name, DateTime finishTime, TimerListEntry tle) { // check if group of timers exists ListViewGroup g = null; @@ -155,7 +157,7 @@ public void Tick() { if (diff.TotalSeconds < timerAlerts[i] + 0.8 && diff.TotalSeconds > timerAlerts[i] - 0.8) { - playSound(t.@group, i, "", t.sound); + PlaySound(t.@group, i, "", t.sound); break; } } @@ -164,35 +166,23 @@ public void Tick() } } - public void playSound(string group, int alert, string speakText = "", string customSoundFile = null) + public void PlaySound(string group, int alert, string speakText = "", string customSoundFile = null) { - string soundPath = null; - if (!string.IsNullOrEmpty(customSoundFile)) - { - soundPath = Path.Combine(FileService.GetPath("sounds"), customSoundFile); - if (!File.Exists(soundPath)) - soundPath = null; - } - if (!string.IsNullOrEmpty(soundPath)) - { - using (var sp = new SoundPlayer(soundPath)) - playSoundFile(sp); - } - else if (string.IsNullOrEmpty(speakText)) + if (!PlayCustomSound(customSoundFile) && string.IsNullOrEmpty(speakText)) { switch (group) { case "Starving": - playSoundFile(sounds[0]); + PlaySoundFile(sounds[0]); break; case "Wakeup": - playSoundFile(sounds[1]); + PlaySoundFile(sounds[1]); break; case "Birth": - playSoundFile(sounds[2]); + PlaySoundFile(sounds[2]); break; case "Custom": - playSoundFile(sounds[3]); + PlaySoundFile(sounds[3]); break; default: SystemSounds.Hand.Play(); @@ -209,7 +199,7 @@ public void playSound(string group, int alert, string speakText = "", string cus } } - private void playSoundFile(SoundPlayer sound) + private void PlaySoundFile(SoundPlayer sound) { if (sound == null) SystemSounds.Hand.Play(); else sound.Play(); @@ -266,7 +256,7 @@ public CreatureCollection CreatureCollection foreach (TimerListEntry tle in timerListEntries) { - tle.lvi = createLvi(tle.name, tle.time, tle); + tle.lvi = CreateLvi(tle.name, tle.time, tle); int i = 0; while (i < listViewTimer.Items.Count && ((TimerListEntry)listViewTimer.Items[i].Tag).time < tle.time) { @@ -308,16 +298,16 @@ private void removeSelectedEntry() , "Remove Timer?", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { for (int t = listViewTimer.SelectedIndices.Count - 1; t >= 0; t--) - removeTimer((TimerListEntry)listViewTimer.SelectedItems[t].Tag, false); + RemoveTimer((TimerListEntry)listViewTimer.SelectedItems[t].Tag, false); - refreshOverlayTimers(); - onTimerChange?.Invoke(); + RefreshOverlayTimers(); + OnTimerChange?.Invoke(); } } private void buttonAddTimer_Click(object sender, EventArgs e) { - addTimer(textBoxTimerName.Text, dateTimePickerTimerFinish.Value, null); + AddTimer(textBoxTimerName.Text, dateTimePickerTimerFinish.Value, null); } private void bSetTimerNow_Click(object sender, EventArgs e) @@ -344,11 +334,11 @@ private void addToOverlayToolStripMenuItem_Click(object sender, EventArgs e) bool show = !((TimerListEntry)listViewTimer.SelectedItems[0].Tag).showInOverlay; for (int i = 0; i < listViewTimer.SelectedIndices.Count; i++) ((TimerListEntry)listViewTimer.SelectedItems[i].Tag).showInOverlay = show; - refreshOverlayTimers(); + RefreshOverlayTimers(); } } - private void refreshOverlayTimers() + private void RefreshOverlayTimers() { if (ARKOverlay.theOverlay != null) { @@ -381,24 +371,24 @@ public enum TimerGroups Starving } - internal void deleteAllExpiredTimers() + internal void DeleteAllExpiredTimers() { if (MessageBox.Show("Delete all expired timers?", "Delete?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { for (int i = 0; i < timerListEntries.Count; i++) { if (timerListEntries[i].time < DateTime.Now) - removeTimer(timerListEntries[i--], false); + RemoveTimer(timerListEntries[i--], false); } - refreshOverlayTimers(); + RefreshOverlayTimers(); - onTimerChange?.Invoke(); + OnTimerChange?.Invoke(); } } private void removeAllExpiredTimersToolStripMenuItem_Click(object sender, EventArgs e) { - deleteAllExpiredTimers(); + DeleteAllExpiredTimers(); } private void btOpenSoundFolder_Click(object sender, EventArgs e) @@ -416,5 +406,42 @@ private void btOpenSoundFolder_Click(object sender, EventArgs e) if (Directory.Exists(soundPath)) System.Diagnostics.Process.Start(soundPath); } + + private void btPlaySelectedSound_Click(object sender, EventArgs e) + { + string customSoundfile = SoundListBox.SelectedItem?.ToString(); + if (customSoundfile == DefaultSoundName) + { + SystemSounds.Hand.Play(); + return; + } + + PlayCustomSound(customSoundfile); + } + + /// + /// Plays a custom sound file at a specific folder. Returns false if the file wasn't found. + /// + /// + /// + private bool PlayCustomSound(string fileName) + { + string soundPath = null; + if (!string.IsNullOrEmpty(fileName)) + { + soundPath = Path.Combine(FileService.GetPath("sounds"), fileName); + if (!File.Exists(soundPath)) + soundPath = null; + } + if (!string.IsNullOrEmpty(soundPath)) + { + using (var sp = new SoundPlayer(soundPath)) + { + PlaySoundFile(sp); + return true; + } + } + return false; + } } } diff --git a/ARKBreedingStats/raising/RaisingControl.cs b/ARKBreedingStats/raising/RaisingControl.cs index 347e1448..fa946e17 100644 --- a/ARKBreedingStats/raising/RaisingControl.cs +++ b/ARKBreedingStats/raising/RaisingControl.cs @@ -312,7 +312,7 @@ public void Tick() double diff = t.incubationEnd.Subtract(alertTime).TotalSeconds; if (diff >= 0 && diff < 1) { - timerControl.playSound("Birth", 1); + timerControl.PlaySound("Birth", 1); } else if (diff < 0) { @@ -354,7 +354,7 @@ public void Tick() var t = (IncubationTimerEntry)lvi.Tag; double diff = t.incubationEnd.Subtract(alertTime).TotalSeconds; if (diff >= 0 && diff < 1) - timerControl.playSound("Birth", 1); + timerControl.PlaySound("Birth", 1); } } } From 9d9a445680852f63539ee34326b46cc35c0ea96d Mon Sep 17 00:00:00 2001 From: cadaei Date: Tue, 8 Oct 2019 22:09:18 +0200 Subject: [PATCH 02/14] fix for UTC-converted timers. --- ARKBreedingStats/library/CreatureCollection.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ARKBreedingStats/library/CreatureCollection.cs b/ARKBreedingStats/library/CreatureCollection.cs index c4b3531b..bcb4fc3a 100644 --- a/ARKBreedingStats/library/CreatureCollection.cs +++ b/ARKBreedingStats/library/CreatureCollection.cs @@ -386,6 +386,21 @@ public void RemoveUnlinkedPlaceholders() private void InitializeProperties(StreamingContext ct) { if (tags == null) tags = new List(); + + // convert DateTimes to local times + foreach (var tle in timerListEntries) + tle.time = tle.time.ToLocalTime(); + + foreach (var ile in incubationListEntries) + ile.incubationEnd = ile.incubationEnd.ToLocalTime(); + + foreach (var c in creatures) + { + c.cooldownUntil = c.cooldownUntil?.ToLocalTime(); + c.growingUntil = c.growingUntil?.ToLocalTime(); + c.domesticatedAt = c.domesticatedAt?.ToLocalTime(); + c.addedToLibrary = c.addedToLibrary?.ToLocalTime(); + } } } } From 77a4f1abb487a112178a1fea74f35755a4bc948f Mon Sep 17 00:00:00 2001 From: Biagio Spit <47725236+Spit-Biagio@users.noreply.github.com> Date: Wed, 9 Oct 2019 16:27:43 +0200 Subject: [PATCH 03/14] Update it language fixed issue from translation, Stamina = Vigore, nope Gigore, and other "witten". thanks! --- ARKBreedingStats/local/strings.it.resx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ARKBreedingStats/local/strings.it.resx b/ARKBreedingStats/local/strings.it.resx index 5c604596..b3c2cb43 100644 --- a/ARKBreedingStats/local/strings.it.resx +++ b/ARKBreedingStats/local/strings.it.resx @@ -1,4 +1,4 @@ - +