From 30e992146a020e86c93fb297a34f904b517ba19c Mon Sep 17 00:00:00 2001 From: jxjacob <4712066+jxjacob@users.noreply.github.com> Date: Sun, 21 May 2023 18:19:00 -0400 Subject: [PATCH] medallion + songs + gossip added compatibility for medallions & songs for both the broadcast view and load/save states. also fixed the gossip stone compatibility for broadcast that i didnt know that i broke at some point --- GSTHD/CollectedItem.cs | 2 +- GSTHD/Form1.cs | 51 ++++++++++++++ GSTHD/GossipStone.cs | 44 ++++++------ GSTHD/Item.cs | 2 +- GSTHD/Layout.cs | 10 +-- GSTHD/Medallion.cs | 91 +++++++++++++++++++------ GSTHD/Song.cs | 151 ++++++++++++++++++++++++++++++----------- 7 files changed, 261 insertions(+), 90 deletions(-) diff --git a/GSTHD/CollectedItem.cs b/GSTHD/CollectedItem.cs index 904c108..04f8c8f 100644 --- a/GSTHD/CollectedItem.cs +++ b/GSTHD/CollectedItem.cs @@ -44,7 +44,7 @@ public CollectedItem(ObjectPointCollectedItem data, Settings settings, bool isBr CollectedItems = System.Math.Min(System.Math.Max(CollectedItemMin, CollectedItemDefault), CollectedItemMax); Step = data.Step == 0 ? 1 : data.Step; CollectedItemSize = data.Size; - isBroadcastable = data.isBroadcastable; + isBroadcastable = data.isBroadcastable && !isBroadcast; if (ImageNames.Length > 0) { diff --git a/GSTHD/Form1.cs b/GSTHD/Form1.cs index 7b5c9b0..b15cb1c 100644 --- a/GSTHD/Form1.cs +++ b/GSTHD/Form1.cs @@ -193,6 +193,30 @@ public void SaveState() } } } + foreach (Medallion x in this.Controls[0].Controls.OfType()) + { + if (x.Name != "") + { + MedallionState state = x.GetState(); + string conv = state.ToString(); + if (conv != "0,0") + { + thejson.Add(x.Name, conv); + } + } + } + foreach (Song x in this.Controls[0].Controls.OfType()) + { + if (x.Name != "") + { + SongState state = x.GetWholeState(); + string conv = state.ToString(); + if (conv != "0,False,,0") + { + thejson.Add(x.Name, conv); + } + } + } foreach (PanelWothBarren x in this.Controls[0].Controls.OfType()) { if (x.Name != "") @@ -282,6 +306,33 @@ public void LoadState() }; ((GossipStone)found).SetState(newstate); } + else if (found is Medallion) + { + string conv = (string)x.Value; + string[] words = conv.Split(','); + MedallionState newstate = new MedallionState() + { + DungeonIndex = int.Parse(words[0]), + ImageIndex = int.Parse(words[1]), + }; + ((Medallion)found).SetState(newstate); + } + else if (found is Song) + { + string conv = (string)x.Value; + string[] words = conv.Split(','); + SongState newstate = new SongState() + { + ImageIndex = int.Parse(words[0]), + MarkerState = new SongMarkerState() + { + HoldsImage = Boolean.Parse(words[1]), + HeldImageName = words[2], + ImageIndex = int.Parse(words[3]), + }, + }; + ((Song)found).SetWholeState(newstate); + } else if (found is PanelWothBarren) { if (((PanelWothBarren)found).isWotH){ diff --git a/GSTHD/GossipStone.cs b/GSTHD/GossipStone.cs index 8e169dd..7491d33 100644 --- a/GSTHD/GossipStone.cs +++ b/GSTHD/GossipStone.cs @@ -32,10 +32,10 @@ public class GossipStone : PictureBox, ProgressibleElement, Dr Size GossipStoneSize; - public GossipStone(ObjectPoint data, Settings settings) - : this(settings, data.Name, data.X, data.Y, data.ImageCollection, data.Size, data.isScrollable, data.SizeMode, data.isBroadcastable) { } + public GossipStone(ObjectPoint data, Settings settings, bool isOnBroadcast = false) + : this(settings, data.Name, data.X, data.Y, data.ImageCollection, data.Size, data.isScrollable, data.SizeMode, data.isBroadcastable, isOnBroadcast) { } - public GossipStone(Settings settings, string name, int x, int y, string[] imageCollection, Size imageSize, bool isScrollable, PictureBoxSizeMode SizeMode, bool isBroadcastable) + public GossipStone(Settings settings, string name, int x, int y, string[] imageCollection, Size imageSize, bool isScrollable, PictureBoxSizeMode SizeMode, bool isBroadcastable, bool isOnBroadcast = false) { Settings = settings; @@ -65,16 +65,19 @@ public GossipStone(Settings settings, string name, int x, int y, string[] imageC this.isBroadcastable = isBroadcastable; + if (!isOnBroadcast) + { + this.MouseUp += DragBehaviour.Mouse_ClickUp; + this.MouseDown += ProgressBehaviour.Mouse_ClickDown; + this.MouseDown += DragBehaviour.Mouse_ClickDown; + this.MouseMove += Mouse_Move; + this.DragEnter += Mouse_DragEnter; + this.DragDrop += Mouse_DragDrop; + this.MouseWheel += Mouse_Wheel; + this.MouseEnter += Panel_MouseEnter; + this.MouseLeave += Panel_MouseLeave; + } - this.MouseUp += DragBehaviour.Mouse_ClickUp; - this.MouseDown += ProgressBehaviour.Mouse_ClickDown; - this.MouseDown += DragBehaviour.Mouse_ClickDown; - this.MouseMove += Mouse_Move; - this.DragEnter += Mouse_DragEnter; - this.DragDrop += Mouse_DragDrop; - this.MouseWheel += Mouse_Wheel; - this.MouseEnter += Panel_MouseEnter; - this.MouseLeave += Panel_MouseLeave; } // both of these functions are for when the stone is in a WOTH panel, so that it can be scrolled without the whole WOTH panle scrolling as well @@ -98,10 +101,6 @@ private void Mouse_Wheel(object sender, MouseEventArgs e) if (ImageIndex < 0) ImageIndex = 0; else if (ImageIndex >= ImageNames.Length) ImageIndex = ImageNames.Length - 1; UpdateImage(); - if (isBroadcastable && Application.OpenForms["GSTHD_DK64 Broadcast View"] != null) - { - ((GossipStone)Application.OpenForms["GSTHD_DK64 Broadcast View"].Controls.Find(this.Name, true)[0]).Mouse_Wheel(sender, e); - }; } } @@ -150,6 +149,7 @@ private void UpdateImage() Image = Image.FromFile(@"Resources/" + ImageNames[ImageIndex]); if (isBroadcastable && Application.OpenForms["GSTHD_DK64 Broadcast View"] != null) { + ((GossipStone)Application.OpenForms["GSTHD_DK64 Broadcast View"].Controls.Find(this.Name, true)[0]).HoldsImage = false; ((GossipStone)Application.OpenForms["GSTHD_DK64 Broadcast View"].Controls.Find(this.Name, true)[0]).ImageIndex = ImageIndex; ((GossipStone)Application.OpenForms["GSTHD_DK64 Broadcast View"].Controls.Find(this.Name, true)[0]).UpdateImage(); } @@ -189,10 +189,6 @@ public void IncrementState() RemoveImage = true; if (ImageIndex < ImageNames.Length - 1) ImageIndex += 1; UpdateImage(); - if (isBroadcastable && Application.OpenForms["GSTHD_DK64 Broadcast View"] != null) - { - ((GossipStone)Application.OpenForms["GSTHD_DK64 Broadcast View"].Controls.Find(this.Name, true)[0]).IncrementState(); - }; } public void DecrementState() @@ -200,15 +196,15 @@ public void DecrementState() RemoveImage = true; if (ImageIndex > 0) ImageIndex -= 1; UpdateImage(); - if (isBroadcastable && Application.OpenForms["GSTHD_DK64 Broadcast View"] != null) - { - ((GossipStone)Application.OpenForms["GSTHD_DK64 Broadcast View"].Controls.Find(this.Name, true)[0]).DecrementState(); - }; } public void ResetState() { RemoveImage = true; + if (isBroadcastable && Application.OpenForms["GSTHD_DK64 Broadcast View"] != null) + { + ((GossipStone)Application.OpenForms["GSTHD_DK64 Broadcast View"].Controls.Find(this.Name, true)[0]).RemoveImage = true; + } ImageIndex = 0; UpdateImage(); } diff --git a/GSTHD/Item.cs b/GSTHD/Item.cs index 772ce44..9b194f9 100644 --- a/GSTHD/Item.cs +++ b/GSTHD/Item.cs @@ -32,7 +32,7 @@ public Item(ObjectPoint data, Settings settings, bool isBroadcast = false) Name = data.Name; BackColor = data.BackColor; - this.isBroadcastable = data.isBroadcastable; + this.isBroadcastable = data.isBroadcastable && !isBroadcast; this.isDraggable = data.isDraggable; diff --git a/GSTHD/Layout.cs b/GSTHD/Layout.cs index 88af9e1..6f26aab 100644 --- a/GSTHD/Layout.cs +++ b/GSTHD/Layout.cs @@ -834,7 +834,7 @@ public void LoadBroadcastLayout(Panel panelLayout, Settings settings, SortedSet< { if (song.Visible) { - var s = new Song(song, settings); + var s = new Song(song, settings, true); panelLayout.Controls.Add(s); ListUpdatables.Add(s); } @@ -865,7 +865,7 @@ public void LoadBroadcastLayout(Panel panelLayout, Settings settings, SortedSet< { if (medallion.Visible) { - var element = new Medallion(medallion, settings); + var element = new Medallion(medallion, settings, true); panelLayout.Controls.Add(element); panelLayout.Controls.Add(element.SelectedDungeon); ListUpdatables.Add(element); @@ -889,7 +889,7 @@ public void LoadBroadcastLayout(Panel panelLayout, Settings settings, SortedSet< foreach (var item in ListGossipStones) { if (item.Visible) - panelLayout.Controls.Add(new GossipStone(item, settings)); + panelLayout.Controls.Add(new GossipStone(item, settings, true)); } } @@ -915,7 +915,7 @@ public void LoadBroadcastLayout(Panel panelLayout, Settings settings, SortedSet< Visible = item.Visible, SizeMode= item.SizeMode }; - panelLayout.Controls.Add(new GossipStone(gs, settings)); + panelLayout.Controls.Add(new GossipStone(gs, settings, true)); } } } @@ -1051,6 +1051,7 @@ public class ObjectPointSong public string[] TinyImageCollection { get; set; } public string ActiveSongImage { get; set; } public string ActiveTinySongImage { get; set; } + public bool isBroadcastable { get; set; } = false; } public class MedallionLabel @@ -1072,6 +1073,7 @@ public class ObjectPointMedallion public bool Visible { get; set; } public string[] ImageCollection { get; set; } public MedallionLabel Label { get; set; } + public bool isBroadcastable { get; set; } = false; } public class ObjectPointGrid diff --git a/GSTHD/Medallion.cs b/GSTHD/Medallion.cs index 7442be5..c7cbd2d 100644 --- a/GSTHD/Medallion.cs +++ b/GSTHD/Medallion.cs @@ -5,11 +5,19 @@ namespace GSTHD { - public class Medallion : PictureBox, UpdatableFromSettings, ProgressibleElement, DraggableAutocheckElement + public struct MedallionState + { + public int DungeonIndex; + public int ImageIndex; + + public override string ToString() => $"{DungeonIndex},{ImageIndex}"; + } + + public class Medallion : PictureBox, UpdatableFromSettings, ProgressibleElement, DraggableElement { private readonly Settings Settings; - private readonly ProgressibleElementBehaviour ProgressBehaviour; - private readonly DraggableAutocheckElementBehaviour DragBehaviour; + private readonly ProgressibleElementBehaviour ProgressBehaviour; + private readonly DraggableElementBehaviour DragBehaviour; private string[] ImageNames; private string[] DungeonNames; @@ -21,7 +29,9 @@ public class Medallion : PictureBox, UpdatableFromSettings, ProgressibleElement< public Label SelectedDungeon; - public Medallion(ObjectPointMedallion data, Settings settings) + private bool isBroadcastable; + + public Medallion(ObjectPointMedallion data, Settings settings, bool isBroadcast = false) { Settings = settings; @@ -52,6 +62,7 @@ public Medallion(ObjectPointMedallion data, Settings settings) DefaultDungeonIndex = data.Label.DefaultValue.Value; DungeonIndex = DefaultDungeonIndex; Wraparound = data.Label.Wraparound.Value; + isBroadcastable = data.isBroadcastable && !isBroadcast; Name = data.Name; BackColor = Color.Transparent; @@ -63,16 +74,20 @@ public Medallion(ObjectPointMedallion data, Settings settings) Size = data.Size; } - ProgressBehaviour = new ProgressibleElementBehaviour(this, Settings); - DragBehaviour = new DraggableAutocheckElementBehaviour(this, Settings); + ProgressBehaviour = new ProgressibleElementBehaviour(this, Settings); + DragBehaviour = new DraggableElementBehaviour(this, Settings); Location = new Point(data.X, data.Y); TabStop = false; AllowDrop = false; - MouseUp += DragBehaviour.Mouse_ClickUp; - MouseDown += ProgressBehaviour.Mouse_ClickDown; - MouseDown += DragBehaviour.Mouse_ClickDown; - MouseMove += DragBehaviour.Mouse_Move_WithAutocheck; + if (!isBroadcast) + { + MouseUp += DragBehaviour.Mouse_ClickUp; + MouseDown += ProgressBehaviour.Mouse_ClickDown; + MouseDown += DragBehaviour.Mouse_ClickDown; + MouseMove += DragBehaviour.Mouse_Move; + } + SelectedDungeon = new Label { @@ -85,12 +100,16 @@ public Medallion(ObjectPointMedallion data, Settings settings) SelectedDungeon.Location = new Point(Location.X + Size.Width / 2, (int)(Location.Y + Size.Height * 0.75)); - SelectedDungeon.MouseUp += DragBehaviour.Mouse_ClickUp; - SelectedDungeon.MouseDown += ProgressBehaviour.Mouse_ClickDown; - SelectedDungeon.MouseDown += DragBehaviour.Mouse_ClickDown; - SelectedDungeon.MouseMove += DragBehaviour.Mouse_Move_WithAutocheck; + if (!isBroadcast) + { + SelectedDungeon.MouseUp += DragBehaviour.Mouse_ClickUp; + SelectedDungeon.MouseDown += ProgressBehaviour.Mouse_ClickDown; + SelectedDungeon.MouseDown += DragBehaviour.Mouse_ClickDown; + SelectedDungeon.MouseMove += DragBehaviour.Mouse_Move; - UpdateFromSettings(); + UpdateFromSettings(); + } + } public void UpdateFromSettings() @@ -127,6 +146,11 @@ private void Mouse_Wheel(object sender, MouseEventArgs e) else if (DungeonIndex >= DungeonNames.Length) DungeonIndex = DungeonNames.Length - 1; SelectedDungeon.Text = DungeonNames[DungeonIndex]; SetSelectedDungeonLocation(); + if (isBroadcastable && Application.OpenForms["GSTHD_DK64 Broadcast View"] != null) + { + ((Medallion)Application.OpenForms["GSTHD_DK64 Broadcast View"].Controls.Find(this.Name, true)[0]).SelectedDungeon.Text = DungeonNames[DungeonIndex]; + ((Medallion)Application.OpenForms["GSTHD_DK64 Broadcast View"].Controls.Find(this.Name, true)[0]).SetSelectedDungeonLocation(); + } } } @@ -139,23 +163,45 @@ private void Mouse_Wheel_WithWraparound(object sender, MouseEventArgs e) DungeonIndex = Math.EMod(newIndex, DungeonNames.Length); SelectedDungeon.Text = DungeonNames[DungeonIndex]; SetSelectedDungeonLocation(); + if (isBroadcastable && Application.OpenForms["GSTHD_DK64 Broadcast View"] != null) + { + ((Medallion)Application.OpenForms["GSTHD_DK64 Broadcast View"].Controls.Find(this.Name, true)[0]).SelectedDungeon.Text = DungeonNames[DungeonIndex]; + ((Medallion)Application.OpenForms["GSTHD_DK64 Broadcast View"].Controls.Find(this.Name, true)[0]).SetSelectedDungeonLocation(); + } } } private void UpdateImage() { Image = Image.FromFile(@"Resources/" + ImageNames[ImageIndex]); + if (isBroadcastable && Application.OpenForms["GSTHD_DK64 Broadcast View"] != null) + { + ((Medallion)Application.OpenForms["GSTHD_DK64 Broadcast View"].Controls.Find(this.Name, true)[0]).ImageIndex = ImageIndex; + ((Medallion)Application.OpenForms["GSTHD_DK64 Broadcast View"].Controls.Find(this.Name, true)[0]).UpdateImage(); + } } - public int GetState() + public MedallionState GetState() { - return ImageIndex; + return new MedallionState() + { + DungeonIndex = DungeonIndex, + ImageIndex = ImageIndex, + }; } - public void SetState(int state) + public void SetState(MedallionState state) { - ImageIndex = state; + ImageIndex = state.ImageIndex; UpdateImage(); + DungeonIndex = state.DungeonIndex; + SelectedDungeon.Text = DungeonNames[DungeonIndex]; + SetSelectedDungeonLocation(); + if (isBroadcastable && Application.OpenForms["GSTHD_DK64 Broadcast View"] != null) + { + ((Medallion)Application.OpenForms["GSTHD_DK64 Broadcast View"].Controls.Find(this.Name, true)[0]).SelectedDungeon.Text = DungeonNames[DungeonIndex]; + ((Medallion)Application.OpenForms["GSTHD_DK64 Broadcast View"].Controls.Find(this.Name, true)[0]).SetSelectedDungeonLocation(); + } } public void IncrementState() @@ -175,11 +221,16 @@ public void ResetState() DungeonIndex = DefaultDungeonIndex; SelectedDungeon.Text = DungeonNames[DungeonIndex]; SetSelectedDungeonLocation(); + if (isBroadcastable && Application.OpenForms["GSTHD_DK64 Broadcast View"] != null) + { + ((Medallion)Application.OpenForms["GSTHD_DK64 Broadcast View"].Controls.Find(this.Name, true)[0]).SelectedDungeon.Text = DungeonNames[DungeonIndex]; + ((Medallion)Application.OpenForms["GSTHD_DK64 Broadcast View"].Controls.Find(this.Name, true)[0]).SetSelectedDungeonLocation(); + } } public void StartDragDrop() { - var dropContent = new DragDropContent(DragBehaviour.AutocheckDragDrop, ImageNames[1]); + var dropContent = new DragDropContent(false, ImageNames[1]); DoDragDrop(dropContent, DragDropEffects.Copy); } diff --git a/GSTHD/Song.cs b/GSTHD/Song.cs index fed3283..baf47c3 100644 --- a/GSTHD/Song.cs +++ b/GSTHD/Song.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using GSTHD; +using System.Collections.Generic; using System.Drawing; using System.Linq; using System.Windows.Forms; @@ -12,6 +13,14 @@ public struct SongMarkerState public int ImageIndex; } + public struct SongState + { + public int ImageIndex; + public SongMarkerState MarkerState; + + public override string ToString() => $"{ImageIndex},{MarkerState.HoldsImage},{MarkerState.HeldImageName},{MarkerState.ImageIndex}"; + } + public class SongMarker : PictureBox, UpdatableFromSettings, ProgressibleElement, DraggableElement { private readonly Settings Settings; @@ -24,13 +33,17 @@ public class SongMarker : PictureBox, UpdatableFromSettings, ProgressibleElement private int ImageIndex = 0; private bool RemoveImage; + bool isBroadcastable; + bool isOnBroadcast; public Song Song; - public SongMarker(Song song, Settings settings, string[] imageCollection) + public SongMarker(Song song, Settings settings, string[] imageCollection, bool isBroadcast = false) { Song = song; Settings = settings; + isBroadcastable = song.isBroadcastable && !isBroadcast; + isOnBroadcast = isBroadcast; ProgressBehaviour = new ProgressibleElementBehaviour(this, settings); DragBehaviour = new DraggableElementBehaviour(this, settings); @@ -61,7 +74,7 @@ public SongMarker(Song song, Settings settings, string[] imageCollection) } public void UpdateFromSettings() - { + { MouseDown -= ProgressBehaviour.Mouse_ClickDown; MouseDown -= Mouse_MiddleClickDown; MouseUp -= DragBehaviour.Mouse_ClickUp; @@ -120,10 +133,22 @@ public void UpdateImage() if (HoldsImage) { Image = Image.FromFile(@"Resources/" + HeldImageName); + if (isBroadcastable && Application.OpenForms["GSTHD_DK64 Broadcast View"] != null) + { + ((SongMarker)Application.OpenForms["GSTHD_DK64 Broadcast View"].Controls.Find(this.Name, true)[0]).HeldImageName = HeldImageName; + ((SongMarker)Application.OpenForms["GSTHD_DK64 Broadcast View"].Controls.Find(this.Name, true)[0]).HoldsImage = true; + ((SongMarker)Application.OpenForms["GSTHD_DK64 Broadcast View"].Controls.Find(this.Name, true)[0]).UpdateImage(); + } } else { Image = Image.FromFile(@"Resources/" + ImageNames[ImageIndex]); + if (isBroadcastable && Application.OpenForms["GSTHD_DK64 Broadcast View"] != null) + { + ((SongMarker)Application.OpenForms["GSTHD_DK64 Broadcast View"].Controls.Find(this.Name, true)[0]).HoldsImage = false; + ((SongMarker)Application.OpenForms["GSTHD_DK64 Broadcast View"].Controls.Find(this.Name, true)[0]).ImageIndex = ImageIndex; + ((SongMarker)Application.OpenForms["GSTHD_DK64 Broadcast View"].Controls.Find(this.Name, true)[0]).UpdateImage(); + } } } @@ -175,6 +200,7 @@ public void SetState(SongMarkerState state) HoldsImage = state.HoldsImage; HeldImageName = state.HeldImageName; ImageIndex = state.ImageIndex; + UpdateImage(); } public void IncrementState() @@ -230,6 +256,8 @@ public class Song : PictureBox, UpdatableFromSettings, ProgressibleElement, public string[] ImageNames; string ActiveImageName; + public bool isBroadcastable; + private bool isOnBroadcast; private int ImageIndex = 0; @@ -237,7 +265,7 @@ public class Song : PictureBox, UpdatableFromSettings, ProgressibleElement, Size SongSize; - public Song(ObjectPointSong data, Settings settings) + public Song(ObjectPointSong data, Settings settings, bool isBroadcast = false) { Settings = settings; ProgressBehaviour = new ProgressibleElementBehaviour(this, settings); @@ -251,6 +279,8 @@ public Song(ObjectPointSong data, Settings settings) Name = data.Name; SongSize = data.Size; + isBroadcastable = data.isBroadcastable && !isBroadcast; + isOnBroadcast = isBroadcast; BackColor = Color.Transparent; Location = new Point(data.X, data.Y); @@ -268,7 +298,7 @@ public Song(ObjectPointSong data, Settings settings) DragPictureName = data.DragAndDropImageName; } - SongMarker = new SongMarker(this, settings, data.TinyImageCollection) + SongMarker = new SongMarker(this, settings, data.TinyImageCollection, isBroadcast) { BackColor = Color.Transparent, TabStop = false, @@ -279,25 +309,32 @@ public Song(ObjectPointSong data, Settings settings) Controls.Add(SongMarker); SongMarker.BringToFront(); - MouseUp += DragBehaviour.Mouse_ClickUp; - MouseDown += ProgressBehaviour.Mouse_ClickDown; - MouseDown += DragBehaviour.Mouse_ClickDown; - DragEnter += Mouse_DragEnter; + if (!isOnBroadcast) + { + MouseUp += DragBehaviour.Mouse_ClickUp; + MouseDown += ProgressBehaviour.Mouse_ClickDown; + MouseDown += DragBehaviour.Mouse_ClickDown; + DragEnter += Mouse_DragEnter; + } UpdateFromSettings(); + } public void UpdateFromSettings() { - SongMarker.DragEnter -= Mouse_DragEnter; - DragDrop -= Mouse_DragDrop; - DragDrop -= Mouse_DragDrop_WithMoveLocationToSong; - DragDrop -= SongMarker.Mouse_DragDrop; - MouseMove -= Mouse_Move; - MouseMove -= Mouse_Move_WithMoveLocationToSong; - SongMarker.MouseMove -= Mouse_Move; - SongMarker.MouseMove -= Mouse_Move_WithMoveLocationToSong; - + if (!isOnBroadcast) + { + SongMarker.DragEnter -= Mouse_DragEnter; + DragDrop -= Mouse_DragDrop; + DragDrop -= Mouse_DragDrop_WithMoveLocationToSong; + DragDrop -= SongMarker.Mouse_DragDrop; + MouseMove -= Mouse_Move; + MouseMove -= Mouse_Move_WithMoveLocationToSong; + SongMarker.MouseMove -= Mouse_Move; + SongMarker.MouseMove -= Mouse_Move_WithMoveLocationToSong; + } + if (Settings.SongMarkerBehaviour != Settings.SongMarkerBehaviourOption.None) { if (ImageNames.Length > 0) @@ -307,41 +344,53 @@ public void UpdateFromSettings() SongSize.Height - SongMarker.Height / 6 ); } - - if (Settings.SongMarkerBehaviour == Settings.SongMarkerBehaviourOption.CheckOnly) - { - MouseMove += Mouse_Move; - SongMarker.MouseMove += Mouse_Move; - } - else if (Settings.SongMarkerBehaviour == Settings.SongMarkerBehaviourOption.DropOnly - || Settings.SongMarkerBehaviour == Settings.SongMarkerBehaviourOption.DropAndCheck - || Settings.SongMarkerBehaviour == Settings.SongMarkerBehaviourOption.DragAndDrop - || Settings.SongMarkerBehaviour == Settings.SongMarkerBehaviourOption.Full) + if (!isOnBroadcast) { - SongMarker.DragEnter += Mouse_DragEnter; - DragDrop += SongMarker.Mouse_DragDrop; - - if (Settings.MoveLocationToSong) - { - DragDrop += Mouse_DragDrop_WithMoveLocationToSong; - MouseMove += Mouse_Move_WithMoveLocationToSong; - SongMarker.MouseMove += Mouse_Move_WithMoveLocationToSong; - } - else + if (Settings.SongMarkerBehaviour == Settings.SongMarkerBehaviourOption.CheckOnly) { - DragDrop += Mouse_DragDrop; MouseMove += Mouse_Move; SongMarker.MouseMove += Mouse_Move; } + else if (Settings.SongMarkerBehaviour == Settings.SongMarkerBehaviourOption.DropOnly + || Settings.SongMarkerBehaviour == Settings.SongMarkerBehaviourOption.DropAndCheck + || Settings.SongMarkerBehaviour == Settings.SongMarkerBehaviourOption.DragAndDrop + || Settings.SongMarkerBehaviour == Settings.SongMarkerBehaviourOption.Full) + { + SongMarker.DragEnter += Mouse_DragEnter; + DragDrop += SongMarker.Mouse_DragDrop; + + if (Settings.MoveLocationToSong) + { + DragDrop += Mouse_DragDrop_WithMoveLocationToSong; + MouseMove += Mouse_Move_WithMoveLocationToSong; + SongMarker.MouseMove += Mouse_Move_WithMoveLocationToSong; + } + else + { + DragDrop += Mouse_DragDrop; + MouseMove += Mouse_Move; + SongMarker.MouseMove += Mouse_Move; + } + } } + } - SongMarker.UpdateFromSettings(); + if (!isOnBroadcast) + { + SongMarker.UpdateFromSettings(); + } + } private void UpdateImage() { Image = Image.FromFile(@"Resources/" + ImageNames[ImageIndex]); + if (isBroadcastable && Application.OpenForms["GSTHD_DK64 Broadcast View"] != null) + { + ((Song)Application.OpenForms["GSTHD_DK64 Broadcast View"].Controls.Find(this.Name, true)[0]).ImageIndex = ImageIndex; + ((Song)Application.OpenForms["GSTHD_DK64 Broadcast View"].Controls.Find(this.Name, true)[0]).UpdateImage(); + } } private void Mouse_Move(object sender, MouseEventArgs e) @@ -382,6 +431,28 @@ public void SetState(int state) UpdateImage(); } + public SongState GetWholeState() + { + return new SongState() + { + ImageIndex = ImageIndex, + MarkerState = SongMarker.GetState(), + }; + } + + public void SetWholeState(SongState state) + { + ImageIndex = state.ImageIndex; + SongMarkerState temp = new SongMarkerState() + { + HoldsImage = state.MarkerState.HoldsImage, + HeldImageName = state.MarkerState.HeldImageName, + ImageIndex = state.MarkerState.ImageIndex, + }; + SongMarker.SetState(temp); + UpdateImage(); + } + public void IncrementState() { if (ImageIndex < ImageNames.Length - 1)