Skip to content

Commit

Permalink
fix notification service timers getting disposed, adjust track title …
Browse files Browse the repository at this point in the history
…detection
  • Loading branch information
TalicZealot committed Mar 1, 2022
1 parent 275bbd1 commit 3f50287
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 123 deletions.
2 changes: 1 addition & 1 deletion SotnRandoTools/src/Configuration/KhaosConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ public void DefaultActions()
},
new Action{
Name = "Endurance",
Description = "The next boss spawns a clone. Both get increased HP. Waits for the next boss, so it will not activate in the current room if it has a boss. Does not apply to Beelzebub and Dracula.",
Description = "The next boss spawns a clone or gets buffed. Both get increased HP. Waits for the next boss, so it will not activate in the current room if it has a boss.",
Meter = 7,
AlertPath = Paths.DeathLaughAlternateSound,
Cooldown = new System.TimeSpan(0, 6, 0),
Expand Down
166 changes: 83 additions & 83 deletions SotnRandoTools/src/Constants/Khaos.cs
Original file line number Diff line number Diff line change
Expand Up @@ -384,92 +384,92 @@ public static class Khaos

public static string[] AcceptedMusicTrackTitles =
{
"Lost Painting",
"Cursed Sanctuary",
"Requiem for the Gods",
"Rainbow Cemetary",
"Wood Carving Partita",
"Crystal Teardrops",
"Marble Galery",
"Dracula Castle",
"The Tragic Prince",
"Tower of Evil Mist",
"Doorway of Spirits",
"Dance of Pearls",
"Abandoned Pit",
"Heavenly Doorway",
"Festival of Servants",
"Dance of Illusions",
"Prologue",
"Wandering Ghosts",
"Doorway to the Abyss",
"Metamorphosis",
"Metamorphosis 2",
"Dance of Gold",
"Enchanted Banquet",
"Prayer",
"Death's Ballad",
"Blood Relations",
"Finale Toccata",
"Black Banquet",
"Silence",
"Nocturne",
"Moonlight Nocturne"
"lost painting",
"cursed sanctuary",
"requiem for the gods",
"rainbow cemetary",
"wood carving partita",
"crystal teardrops",
"marble galery",
"dracula castle",
"the tragic prince",
"tower of evil mist",
"doorway of spirits",
"dance of pearls",
"abandoned pit",
"heavenly doorway",
"festival of servants",
"dance of illusions",
"prologue",
"wandering ghosts",
"doorway to the abyss",
"metamorphosis",
"metamorphosis 2",
"dance of gold",
"enchanted banquet",
"prayer",
"death's ballad",
"blood relations",
"finale toccata",
"black banquet",
"silence",
"nocturne",
"moonlight nocturne"
};
public static Dictionary<string, string> AlternateTrackTitles = new Dictionary<string, string>
{
{ "deaths ballad", "Death's Ballad" },
{ "death ballad", "Death's Ballad" },
{ "poetic ddeath", "Death's Ballad" },
{ "illusionary dance", "Dance of Illusions" },
{ "dracula", "Dance of Illusions" },
{ "nocturne in the moonlight", "Moonlight Nocturne" },
{ "dracula's castle", "Dracula Castle" },
{ "draculas castle", "Dracula Castle" },
{ "castle entrance", "Dracula Castle" },
{ "entrance", "Dracula Castle" },
{ "tower of mist", "Tower of Evil Mist" },
{ "outer wall", "Tower of Evil Mist" },
{ "library", "Wood Carving Partita" },
{ "alchemy lab", "Dance of Gold" },
{ "alchemy laboratory", "Dance of Gold" },
{ "chapel", "Requiem for the Gods" },
{ "royal chapel", "Requiem for the Gods" },
{ "crystal teardrop", "Crystal Teardrops" },
{ "caverns", "Crystal Teardrops" },
{ "underground caverns", "Crystal Teardrops" },
{ "departer way", "Abandoned Pit" },
{ "pit", "Abandoned Pit" },
{ "mines", "Abandoned Pit" },
{ "mine", "Abandoned Pit" },
{ "catacombs", "Rainbow Cemetary" },
{ "lost paintings", "Lost Painting" },
{ "antichapel", "Lost Painting" },
{ "reverse caverns", "Lost Painting" },
{ "forbidden library", "Lost Painting" },
{ "waltz of pearls", "Dance of Pearls" },
{ "olrox's quarters", "Dance of Pearls" },
{ "olroxs quarters", "Dance of Pearls" },
{ "olrox quarters", "Dance of Pearls" },
{ "cursed zone", "Cursed Sanctuary" },
{ "floating catacombs", "Cursed Sanctuary" },
{ "reverse catacombs", "Cursed Sanctuary" },
{ "demonic banquet", "Enchanted Banquet" },
{ "medusa", "Enchanted Banquet" },
{ "succubus", "Enchanted Banquet" },
{ "colosseum", "Wandering Ghosts" },
{ "pitiful scion", "The Tragic Prince" },
{ "clock Tower", "The Tragic Prince" },
{ "tragic Prince", "The Tragic Prince" },
{ "alucard", "The Tragic Prince" },
{ "door to the abyss", "Doorway to the Abyss" },
{ "doorway to heaven", "Heavenly Doorway" },
{ "keep", "Heavenly Doorway" },
{ "castle keep", "Heavenly Doorway" },
{ "divine bloodlines", "Blood Relations" },
{ "strange bloodlines", "Blood Relations" },
{ "richter belmont", "Blood Relations" },
{ "richter", "Blood Relations" },
{ "deaths ballad", "death's ballad" },
{ "death ballad", "death's ballad" },
{ "poetic death", "death's ballad" },
{ "illusionary dance", "dance of illusions" },
{ "dracula", "dance of illusions" },
{ "nocturne in the moonlight", "moonlight nocturne" },
{ "dracula's castle", "dracula castle" },
{ "draculas castle", "dracula castle" },
{ "castle entrance", "dracula castle" },
{ "entrance", "dracula castle" },
{ "tower of mist", "tower of evil mist" },
{ "outer wall", "tower of evil mist" },
{ "library", "wood carving partita" },
{ "alchemy lab", "dance of gold" },
{ "alchemy laboratory", "dance of gold" },
{ "chapel", "requiem for the gods" },
{ "royal chapel", "requiem for the gods" },
{ "crystal teardrop", "crystal teardrops" },
{ "caverns", "crystal teardrops" },
{ "underground caverns", "crystal teardrops" },
{ "departer way", "abandoned pit" },
{ "pit", "abandoned pit" },
{ "mines", "abandoned pit" },
{ "mine", "abandoned pit" },
{ "catacombs", "rainbow cemetary" },
{ "lost paintings", "lost painting" },
{ "antichapel", "lost painting" },
{ "reverse caverns", "lost painting" },
{ "forbidden library", "lost painting" },
{ "waltz of pearls", "dance of pearls" },
{ "olrox's quarters", "dance of pearls" },
{ "olroxs quarters", "dance of pearls" },
{ "olrox quarters", "dance of pearls" },
{ "cursed zone", "cursed sanctuary" },
{ "floating catacombs", "cursed sanctuary" },
{ "reverse catacombs", "cursed sanctuary" },
{ "demonic banquet", "enchanted banquet" },
{ "medusa", "enchanted banquet" },
{ "succubus", "enchanted banquet" },
{ "colosseum", "wandering ghosts" },
{ "pitiful scion", "the tragic prince" },
{ "clock tower", "the tragic prince" },
{ "tragic prince", "the tragic prince" },
{ "alucard", "the tragic prince" },
{ "door to the abyss", "doorway to the abyss" },
{ "doorway to heaven", "heavenly doorway" },
{ "keep", "heavenly doorway" },
{ "castle keep", "heavenly doorway" },
{ "divine bloodlines", "blood relations" },
{ "strange bloodlines", "blood relations" },
{ "richter belmont", "blood relations" },
{ "richter", "blood relations" },
};

public static float SuperWeakenFactor = 0.5F;
Expand Down
17 changes: 8 additions & 9 deletions SotnRandoTools/src/Khaos/KhaosController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -381,25 +381,24 @@ public void KhaoticBurst(string user = "Khaos")
}
public void KhaosTrack(string track, string user = "Khaos")
{
uint trackIndex = 0;
string foundTrack = Constants.Khaos.AcceptedMusicTrackTitles.Where(t => t.ToLower().Trim() == track.ToLower().Trim()).FirstOrDefault();
int trackIndex = Array.IndexOf(Constants.Khaos.AcceptedMusicTrackTitles, track.ToLower().Trim());
bool alternateTitle = Constants.Khaos.AlternateTrackTitles.ContainsKey(track.ToLower().Trim());

if (foundTrack is not null)
if (trackIndex >= 0)
{
trackIndex = SotnApi.Constants.Values.Game.Various.MusicTracks[foundTrack];
trackIndex = (int)SotnApi.Constants.Values.Game.Various.MusicTracks[Constants.Khaos.AcceptedMusicTrackTitles[trackIndex]];
}
else if (alternateTitle)
{
foundTrack = Constants.Khaos.AlternateTrackTitles[track.ToLower().Trim()];
trackIndex = SotnApi.Constants.Values.Game.Various.MusicTracks[foundTrack];
string foundTrack = Constants.Khaos.AlternateTrackTitles[track.ToLower().Trim()];
trackIndex = (int)SotnApi.Constants.Values.Game.Various.MusicTracks[foundTrack];
}
else
{
int roll = rng.Next(0, Constants.Khaos.AcceptedMusicTrackTitles.Length);
trackIndex = SotnApi.Constants.Values.Game.Various.MusicTracks[Constants.Khaos.AcceptedMusicTrackTitles[roll]];
int roll = rng.Next(0, Constants.Khaos.AcceptedMusicTrackTitles.Length - 1);
trackIndex = (int)SotnApi.Constants.Values.Game.Various.MusicTracks[Constants.Khaos.AcceptedMusicTrackTitles[roll]];
}
music.PokeValue((int) trackIndex);
music.PokeValue(trackIndex);
music.Enable();
khaosTrackTimer.Start();
notificationService.AddMessage($"{user} queued {track}");
Expand Down
1 change: 0 additions & 1 deletion SotnRandoTools/src/KhaosForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,6 @@ private void khaosTrackButton_Click(object sender, EventArgs e)
}
else
{

khaosControler.KhaosTrack("random");
}
}
Expand Down
8 changes: 4 additions & 4 deletions SotnRandoTools/src/Services/NotificationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public class NotificationService : INotificationService
private readonly IToolConfig toolConfig;
private readonly IEmuClientApi clientAPI;

private System.Windows.Forms.Timer messageTimer;
private System.Windows.Forms.Timer countdownTimer;
private System.Timers.Timer messageTimer;
private System.Timers.Timer countdownTimer;
private int scale;
private Image textbox;
private Image scaledTextbox;
Expand All @@ -46,11 +46,11 @@ public NotificationService(IToolConfig toolConfig, IGuiApi guiApi, IEmuClientApi
overlaySocketServer = new OverlaySocketServer(toolConfig);
messageTimer = new();
messageTimer.Interval = NotificationTime;
messageTimer.Tick += DequeueMessage;
messageTimer.Elapsed += DequeueMessage;
messageTimer.Start();
countdownTimer = new();
countdownTimer.Interval = 1000;
countdownTimer.Tick += RefreshUI;
countdownTimer.Elapsed += RefreshUI;
textbox = Image.FromFile(Paths.TextboxImage);
scale = GetScale();
ResizeImages();
Expand Down
2 changes: 1 addition & 1 deletion SotnRandoTools/src/SotnRandoTools.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<OutputType>Library</OutputType>
<EnforceCodeStyleInBuild>false</EnforceCodeStyleInBuild>
<AnalysisLevel>5.0</AnalysisLevel>
<Version>1.2.6</Version>
<Version>1.2.7</Version>
<Description>A collection of tools to enhance the experience of playign the SotN randomizer.</Description>
<Copyright />
<PackageProjectUrl>https://taliczealot.github.io/</PackageProjectUrl>
Expand Down
28 changes: 4 additions & 24 deletions SotnRandoTools/src/ToolMainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,6 @@ private void ToolMainForm_Load(object sender, EventArgs e)
coopSettingsPanel = new CoopSettingsPanel(toolConfig);
coopSettingsPanel.Location = new Point(0, PanelOffset);
this.Controls.Add(coopSettingsPanel);

if (notificationService is not null)
{
lock (notificationService)
{
khaosSettingsPanel.NotificationService = notificationService;
}
}
}

private void LoadCheats()
Expand Down Expand Up @@ -236,10 +228,7 @@ public override void Restart()
notificationService = new NotificationService(toolConfig, _maybeGuiAPI, _maybeClientAPI);
if (khaosSettingsPanel is not null)
{
lock (notificationService)
{
khaosSettingsPanel.NotificationService = notificationService;
}
khaosSettingsPanel.NotificationService = notificationService;
}
}

Expand Down Expand Up @@ -313,10 +302,7 @@ private void autotrackerLaunch_Click(object sender, EventArgs e)
trackerForm.Close();
trackerForm.Dispose();
}
lock (notificationService)
{
trackerForm = new TrackerForm(toolConfig, watchlistService, sotnApi, notificationService);
}
trackerForm = new TrackerForm(toolConfig, watchlistService, sotnApi, notificationService);
trackerForm.Show();
if (khaosForm is not null && !khaosForm.IsDisposed)
{
Expand All @@ -334,10 +320,7 @@ private void khaosChatLaunch_Click(object sender, EventArgs e)
khaosForm.Close();
khaosForm.Dispose();
}
lock (notificationService)
{
khaosForm = new KhaosForm(toolConfig, this.MainForm.CheatList, sotnApi, notificationService, inputService, _memoryDomains);
}
khaosForm = new KhaosForm(toolConfig, this.MainForm.CheatList, sotnApi, notificationService, inputService, _memoryDomains);
khaosForm.Show();
if (trackerForm is not null && !trackerForm.IsDisposed)
{
Expand All @@ -355,10 +338,7 @@ private void multiplayerLaunch_Click(object sender, EventArgs e)
coopForm.Close();
coopForm.Dispose();
}
lock (notificationService)
{
coopForm = new CoopForm(toolConfig, watchlistService, inputService, sotnApi, APIs.Joypad, notificationService);
}
coopForm = new CoopForm(toolConfig, watchlistService, inputService, sotnApi, APIs.Joypad, notificationService);
coopForm.Show();
}
}
Expand Down

0 comments on commit 3f50287

Please sign in to comment.