Skip to content

Commit

Permalink
Wav form fixes, including #49
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeG621 committed Mar 6, 2021
1 parent 3f671f3 commit f882ede
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 9 deletions.
2 changes: 1 addition & 1 deletion BriefingForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1014,7 +1014,7 @@ bool processEvent(int evtIndex, bool rebuild)
{
_mapX = _events[i, 2];
_mapY = _events[i, 3];
if (_platform == Settings.Platform.XvT || _platform == Settings.Platform.BoP)
if (_platform == Settings.Platform.XvT || _platform == Settings.Platform.BoP || _platform == Settings.Platform.XWA) // HACK: added XWA, still off some
{
_mapX /= 2;
_mapY /= 2;
Expand Down
5 changes: 5 additions & 0 deletions Readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ Version History

- (All) Craft Type dropdown now lists 20 items instead of the default 8 [Issue #45]
- (Test) Fixed a load failure when testing a mission that isn't located in a platform directory
- Number of things in the XWA Wav dialog:
- Fixed the wrong EoM button being hidden when WAV file doesn't exist
- Fixed a crash when using multi-digit battle or mission numbers [Issue #49]
- PrePost text fields now clear when changing categories
- PrePost text fields now provide a comment about random Pre-briefing WAVS when none are defined

v1.9.1, 30 Jan 21
- Couple fixes from Random Starfighter (JB)
Expand Down
4 changes: 2 additions & 2 deletions XwaForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2188,7 +2188,7 @@ void menuTest_Click(object sender, EventArgs e)
sw.Close();
bool localMission = _mission.MissionPath.ToLower().Contains(path.ToLower());
if (!localMission)
File.Copy(_mission.MissionPath, path + "Missions\\" + _mission.MissionFileName);
File.Copy(_mission.MissionPath, path + "Missions\\" + _mission.MissionFileName);// BUG: fix override issue

xwa.Start();
System.Threading.Thread.Sleep(1000);
Expand Down Expand Up @@ -2233,7 +2233,7 @@ void menuWav_Click(object sender, EventArgs e)
else
{
_fWav = new XwaWavForm(_config, _mission);
_fWav.Show();
if (!_fWav.IsDisposed) _fWav.Show();
}
}
#endregion
Expand Down
43 changes: 37 additions & 6 deletions XwaWavForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
* Copyright (C) 2007-2021 Michael Gaisser (mjgaisser@gmail.com)
* Licensed under the MPL v2.0 or later
*
* VERSION: 1.9
* VERSION: 1.9+
*/

/* CHANGELOG
* [FIX] Crash due to multi-digit battle or mission numbers [#49]
* [FIX] Wrong EoM button hiding if message doesn't exist
* [UPD] Notes about random pre-briefing messages
* v1.9, 210108
* [NEW] Created
*/
Expand All @@ -15,6 +18,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
using System.Windows.Forms;

namespace Idmr.Yogeme
Expand Down Expand Up @@ -45,10 +49,17 @@ public XwaWavForm(Settings config, Mission mission)
_mission = mission;
_wave = _config.XwaPath + "\\Wave\\";
_lstFile = _wave + "MissionVoice\\" + Path.GetFileNameWithoutExtension(_mission.MissionFileName) + ".LST";
// need to confirm if double-digits are allowed in B or M numbers, and if triple is allowed in message indexes
_frontend = _wave + "FrontEnd\\" + Path.GetFileNameWithoutExtension(_mission.MissionFileName).Substring(1).Remove(4) + "\\";
_battleNumber = int.Parse(Directory.GetParent(_frontend).Name.Substring(1, 1));
_missionNumber = int.Parse(Directory.GetParent(_frontend).Name.Substring(3, 1));
Regex rx = new Regex(@"1B(\d+)M(\d+)\D\w*", RegexOptions.Compiled | RegexOptions.IgnoreCase);
Match match = rx.Match(Path.GetFileNameWithoutExtension(_mission.MissionFileName));
if (!match.Success)
{
MessageBox.Show("Mission is not named correctly. Must start with \"1B#M#\".");
Close();
return;
}
_battleNumber = int.Parse(match.Groups[1].Value);
_missionNumber = int.Parse(match.Groups[2].Value);
_frontend = _wave + "FrontEnd\\B" + _battleNumber + "M" + _missionNumber + "\\";
opnWav.InitialDirectory = _wave;
Reload();
}
Expand Down Expand Up @@ -166,7 +177,7 @@ private void lstEom_SelectedIndexChanged(object sender, EventArgs e)
lblEomNote.Text = _mission.Teams[0].EomNotes[lstEom.SelectedIndex / 2];

if (_messages != null) txtEom.Text = _messages[lstEom.SelectedIndex + 64];
cmdEom.Visible = File.Exists(_wave + txtEom.Text);
cmdPlayEom.Visible = File.Exists(_wave + txtEom.Text);
}
private void lstMessages_SelectedIndexChanged(object sender, EventArgs e)
{
Expand Down Expand Up @@ -309,12 +320,32 @@ private void lstPrePostCategories_SelectedIndexChanged(object sender, EventArgs
stopPlayback();
lstPrePost.Items.Clear();


int index = 1;
while (File.Exists(_frontend + _prefix + _battleNumber.ToString("D2") + _missionNumber.ToString("D2") + index.ToString("D2") + _wavExt))
{
lstPrePost.Items.Add("Message #" + index++);
}
cmdAdd.Enabled = true;

if (lstPrePostCategories.SelectedIndex == 0 && lstPrePost.Items.Count == 0)
{
string off = "??", officer = "Unknown";
switch (_mission.Officer)
{
case 0: off = "DE"; officer = "Devers"; break;
case 1: off = "KU"; officer = "Kupalo"; break;
case 2: off = "ZL"; officer = "Zaletta"; break;
case 8: off = "MC"; officer = "Emkay"; break;
}
txtPrePost.Text = "(None defined, randomly selected based on Briefing Officer, " + officer + ")";
txtPrePostWav.Text = "FrontEnd\\N01" + off + "##.WAV";
}
else
{
txtPrePost.Text = "";
txtPrePostWav.Text = "";
}
}
#endregion controls

Expand Down

0 comments on commit f882ede

Please sign in to comment.