Skip to content

Commit

Permalink
The massive FINAL (hopefully) commit before release!
Browse files Browse the repository at this point in the history
- (THE BIG ONE) The program now SAVES AND LOADS the rest of the data, autonomous or otherwise, to and from memory/the XML file!!

- Updated TODO List
- You can now simply pass whether or not the TeamFrm should change anything after a team is picked directly to it as a boolean, vs the old method.
- The Pre-Scouting form doesn't close when you hit "Apply" now, allowing you to more easily fill in a bunch of data.
- Fixed a crash-causing bug with GenReportFrm.
- Moved the pre-scouting button into the team panel so as to allow the user to pre-scout for multiple events rather than just the first one.
- Various GUI "tweaks" for more optimized usage as well as better design.
  • Loading branch information
Radfordhound committed Mar 10, 2016
1 parent 3e7de9b commit d7d24a6
Show file tree
Hide file tree
Showing 11 changed files with 566 additions and 323 deletions.
456 changes: 275 additions & 181 deletions MyScout/MyScout/MainFrm.Designer.cs

Large diffs are not rendered by default.

39 changes: 31 additions & 8 deletions MyScout/MyScout/MainFrm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,18 @@ public void RefreshControls()
RDComments.Text = Program.events[Program.currentevent].rounds[Program.currentround].diedcomments[Program.selectedteamroundindex];
RDDefenseChkbx.SelectedIndex = Program.events[Program.currentevent].rounds[Program.currentround].dieddefense[Program.selectedteamroundindex];
TCommentsTxtbx.Text = Program.events[Program.currentevent].rounds[Program.currentround].comments[Program.selectedteamroundindex];
TLowGoalNUD.Value = Program.events[Program.currentevent].rounds[Program.currentround].lowgoalcount[Program.selectedteamroundindex];
THighGoalNUD.Value = Program.events[Program.currentevent].rounds[Program.currentround].highgoalcount[Program.selectedteamroundindex];

if (!TeleOpRB.Checked)
{
TLowGoalNUD.Value = Program.events[Program.currentevent].rounds[Program.currentround].AOlowgoalcount[Program.selectedteamroundindex];
THighGoalNUD.Value = Program.events[Program.currentevent].rounds[Program.currentround].AOhighgoalcount[Program.selectedteamroundindex];
}
else
{
TLowGoalNUD.Value = Program.events[Program.currentevent].rounds[Program.currentround].TOlowgoalcount[Program.selectedteamroundindex];
THighGoalNUD.Value = Program.events[Program.currentevent].rounds[Program.currentround].TOhighgoalcount[Program.selectedteamroundindex];
}

TChallengedTowerChkbx.Checked = Program.events[Program.currentevent].rounds[Program.currentround].challengedtower[Program.selectedteamroundindex];
TScaledTowerChkbx.Checked = Program.events[Program.currentevent].rounds[Program.currentround].scaledtower[Program.selectedteamroundindex];
RDDied.Checked = Program.events[Program.currentevent].rounds[Program.currentround].died[Program.selectedteamroundindex];
Expand Down Expand Up @@ -198,7 +208,7 @@ private void MainFrm_Load(object sender, EventArgs e)
/// </summary>
private void MainFrm_FormClosing(object sender, FormClosingEventArgs e)
{
if (Program.events.Count > 0 && MessageBox.Show("You have unsaved changes! Would you like to save them now?", "MyScout 2016", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
if (Program.events.Count > 0 && MessageBox.Show("You have unsaved changes! Would you like to save them now?", "MyScout 2016", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
{
new Thread(new ThreadStart(IO.SaveAllEvents)).Start();
}
Expand All @@ -217,7 +227,7 @@ protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
RemoveEventBtn.PerformClick();
return true;
}
else if (konamicodeindex > 9) { konamicodeindex = 0; }
else if (konamicodeindex > 9) { konamicodeindex = 0; return true; }
else if (!konamicodeactivated && keyData == konamicodekeys[konamicodeindex])
{
if (konamicodeindex < 9)
Expand All @@ -241,6 +251,7 @@ protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
}
}
}
return true;
}
}

Expand Down Expand Up @@ -588,8 +599,6 @@ private void DefenseRB_CheckedChanged(object sender, EventArgs e)
RadioButton rb = sender as RadioButton;
Panel containingpnl = (rb != null && rb.Parent != null) ? rb.Parent as Panel : null;

Console.WriteLine($"{containingpnl.Name} , {(containingpnl.Controls[1] as RadioButton).Checked} , {(containingpnl.Controls[2] as RadioButton).Checked} , {(containingpnl.Controls[3] as RadioButton).Checked}");

if (containingpnl != null && defensepnls.Contains(containingpnl))
{
if (!TeleOpRB.Checked)
Expand Down Expand Up @@ -629,15 +638,29 @@ private void TLowGoalNUD_ValueChanged(object sender, EventArgs e)
{
if (Program.selectedteamroundindex != -1)
{
Program.events[Program.currentevent].rounds[Program.currentround].lowgoalcount[Program.selectedteamroundindex] = (int)TLowGoalNUD.Value;
if (!TeleOpRB.Checked)
{
Program.events[Program.currentevent].rounds[Program.currentround].AOlowgoalcount[Program.selectedteamroundindex] = (int)TLowGoalNUD.Value;
}
else
{
Program.events[Program.currentevent].rounds[Program.currentround].TOlowgoalcount[Program.selectedteamroundindex] = (int)TLowGoalNUD.Value;
}
}
}

private void THighGoalNUD_ValueChanged(object sender, EventArgs e)
{
if (Program.selectedteamroundindex != -1)
{
Program.events[Program.currentevent].rounds[Program.currentround].highgoalcount[Program.selectedteamroundindex] = (int)THighGoalNUD.Value;
if (!TeleOpRB.Checked)
{
Program.events[Program.currentevent].rounds[Program.currentround].AOhighgoalcount[Program.selectedteamroundindex] = (int)THighGoalNUD.Value;
}
else
{
Program.events[Program.currentevent].rounds[Program.currentround].TOhighgoalcount[Program.selectedteamroundindex] = (int)THighGoalNUD.Value;
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion MyScout/MyScout/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ static class Program
/// <summary>
/// The current version of the application in string form.
/// </summary>
public static string versionstring = "3.1";
public static string versionstring = "3.4";
/// <summary>
/// The list of events to be used by the application.
/// </summary>
Expand Down
96 changes: 63 additions & 33 deletions MyScout/MyScout/src/Classes/IO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ public static void LoadEvent(int eventid)

reader.ReadStartElement("Rounds");
Program.events[Program.events.Count - 1].lastviewedround = Convert.ToInt32(reader.ReadElementString("Current"));
Round.score[0] = Convert.ToInt32(reader.ReadElementString("AllianceScore1"));
Round.score[1] = Convert.ToInt32(reader.ReadElementString("AllianceScore2"));
List<object> AllianceScores = TokenizeStringHandler.ReadTokenizedString(reader.ReadElementString("AllianceScoreTokens"));
Round.score = new int[2] { Convert.ToInt32(AllianceScores[0]), Convert.ToInt32(AllianceScores[1]) };

count = Convert.ToInt32(reader.ReadElementString("Count"));
for (int i = 0; i < count; i++)
Expand Down Expand Up @@ -124,7 +124,20 @@ public static void LoadEvent(int eventid)
}
reader.ReadEndElement();

Program.events[Program.events.Count - 1].rounds.Add(round);
round.scaledtower = TokenizeStringHandler.ReadTokenizedString(reader.ReadElementString("TOScaledTokens")).Cast<bool>().ToArray();
round.challengedtower = TokenizeStringHandler.ReadTokenizedString(reader.ReadElementString("TOChallengedTokens")).Cast<bool>().ToArray();
round.AOhighgoalcount = TokenizeStringHandler.ReadTokenizedString(reader.ReadElementString("AOHighGoalTokens")).Cast<int>().ToArray();
round.AOlowgoalcount = TokenizeStringHandler.ReadTokenizedString(reader.ReadElementString("AOLowGoalTokens")).Cast<int>().ToArray();
round.TOhighgoalcount = TokenizeStringHandler.ReadTokenizedString(reader.ReadElementString("TOHighGoalTokens")).Cast<int>().ToArray();
round.TOlowgoalcount = TokenizeStringHandler.ReadTokenizedString(reader.ReadElementString("TOLowGoalTokens")).Cast<int>().ToArray();

round.comments = TokenizeStringHandler.ReadTokenizedString(reader.ReadElementString("CommentTokens")).Cast<string>().ToArray();
round.humancomments = TokenizeStringHandler.ReadTokenizedString(reader.ReadElementString("HumanCommentTokens")).Cast<string>().ToArray();
round.died = TokenizeStringHandler.ReadTokenizedString(reader.ReadElementString("DiedTokens")).Cast<bool>().ToArray();
round.dieddefense = TokenizeStringHandler.ReadTokenizedString(reader.ReadElementString("DiedDefenseTokens")).Cast<int>().ToArray();
round.diedcomments = TokenizeStringHandler.ReadTokenizedString(reader.ReadElementString("DiedCommentTokens")).Cast<string>().ToArray();

Program.events[Program.events.Count - 1].rounds.Add(round); //Add the round we just made to the round list.
reader.ReadEndElement();
}

Expand All @@ -139,7 +152,7 @@ public static void LoadEvent(int eventid)
{
MessageBox.Show($"Event #{eventid.ToString()} could not be loaded. \n\n{ex.Message}", "MyScout 2016", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
#endregion

#region scOutput-related functions (pun brought to you by the amazing Ethan™)
Expand All @@ -150,7 +163,11 @@ public static void SaveAllEvents()
{
if (Directory.Exists(Program.startuppath + "\\Events") && Directory.GetFiles(Program.startuppath + "\\Events").Length > 0)
{
Directory.Delete(Program.startuppath + "\\Events",true);
if (Directory.Exists(Program.startuppath + "\\Events Backup"))
{
Directory.Delete(Program.startuppath + "\\Events Backup",true);
}
Directory.Move(Program.startuppath + "\\Events", Program.startuppath + "\\Events Backup");
}
Directory.CreateDirectory(Program.startuppath + "\\Events");

Expand Down Expand Up @@ -232,15 +249,12 @@ public static void SaveEvent(int eventid)

writer.WriteStartElement("Rounds");
writer.WriteElementString("Current", (Program.events[eventid].lastviewedround == -1)? (Program.events[eventid].rounds.Count-1).ToString(): Program.events[eventid].lastviewedround.ToString());
writer.WriteElementString("AllianceScore1", Round.score[0].ToString());
writer.WriteElementString("AllianceScore2", Round.score[1].ToString());
writer.WriteElementString("AllianceScoreTokens", TokenizeStringHandler.CreateTokenizedString(new List<object> { Round.score[0], Round.score[1] }));

writer.WriteElementString("Count", Program.events[eventid].rounds.Count.ToString());
int debugTicker = 0;

foreach (Round round in Program.events[eventid].rounds)
{
debugTicker++;

writer.WriteStartElement("Round");
writer.WriteStartElement("Teams");

Expand Down Expand Up @@ -273,16 +287,25 @@ public static void SaveEvent(int eventid)
writer.WriteElementString("AOCrossedTokens", TokenizeStringHandler.CreateTokenizedString(AOCrossedTokens));
writer.WriteElementString("TOCrossedTokens", TokenizeStringHandler.CreateTokenizedString(TOCrossedTokens));
}

//TODO: WORK ON THE XML SAVING!!!!!
//writer.WriteElementString("TOScaledTokens", TokenizeStringHandler.CreateTokenizedString(round.scaledtower.ToList()));

writer.WriteEndElement();
writer.WriteEndElement(); //Defenses

writer.WriteElementString("TOScaledTokens", TokenizeStringHandler.CreateTokenizedString(round.scaledtower.Cast<object>().ToList()));
writer.WriteElementString("TOChallengedTokens", TokenizeStringHandler.CreateTokenizedString(round.challengedtower.Cast<object>().ToList()));
writer.WriteElementString("AOHighGoalTokens", TokenizeStringHandler.CreateTokenizedString(round.AOhighgoalcount.Cast<object>().ToList()));
writer.WriteElementString("AOLowGoalTokens", TokenizeStringHandler.CreateTokenizedString(round.AOlowgoalcount.Cast<object>().ToList()));
writer.WriteElementString("TOHighGoalTokens", TokenizeStringHandler.CreateTokenizedString(round.TOhighgoalcount.Cast<object>().ToList()));
writer.WriteElementString("TOLowGoalTokens", TokenizeStringHandler.CreateTokenizedString(round.TOlowgoalcount.Cast<object>().ToList()));
writer.WriteElementString("CommentTokens", TokenizeStringHandler.CreateTokenizedString(round.comments.Cast<object>().ToList()));
writer.WriteElementString("HumanCommentTokens", TokenizeStringHandler.CreateTokenizedString(round.humancomments.Cast<object>().ToList()));
writer.WriteElementString("DiedTokens", TokenizeStringHandler.CreateTokenizedString(round.died.Cast<object>().ToList()));
writer.WriteElementString("DiedDefenseTokens", TokenizeStringHandler.CreateTokenizedString(round.dieddefense.Cast<object>().ToList()));
writer.WriteElementString("DiedCommentTokens", TokenizeStringHandler.CreateTokenizedString(round.diedcomments.Cast<object>().ToList()));
writer.WriteEndElement();
}

writer.WriteEndElement();
writer.WriteEndElement();

}
}
catch (Exception ex)
Expand All @@ -300,8 +323,8 @@ public static void SaveDataToTeams()
for(int i = 0; i < Program.events[Program.currentevent].teams.Count; i++)
{
Team team = Program.events[Program.currentevent].teams[i];
List<int> highGoalsToAvg = new List<int>();
List<int> lowGoalsToAvg = new List<int>();
List<int> TOhighGoalsToAvg = new List<int>();
List<int> TOlowGoalsToAvg = new List<int>();
List<int> autoHighGoalsToAvg = new List<int>();
List<int> autoLowGoalsToAvg = new List<int>();

Expand All @@ -327,10 +350,10 @@ public static void SaveDataToTeams()

team.updateDefenseStats();

highGoalsToAvg.Add(r.highgoalcount[j]);
lowGoalsToAvg.Add(r.lowgoalcount[j]);
//TODO: add Auto High Goal and Auto Low Goal saves

TOhighGoalsToAvg.Add(r.TOhighgoalcount[j]);
TOlowGoalsToAvg.Add(r.TOlowgoalcount[j]);
autoHighGoalsToAvg.Add(r.AOhighgoalcount[j]);
autoHighGoalsToAvg.Add(r.AOlowgoalcount[j]);

//Add to the death count
team.deathCount += r.died[j] ? 1 : 0;
Expand All @@ -345,16 +368,16 @@ public static void SaveDataToTeams()
}
//Avg high goals
int highGoalAvg = 0;
for(int j = 0; j < highGoalsToAvg.Count; j++)
for(int j = 0; j < TOhighGoalsToAvg.Count; j++)
{
highGoalAvg += highGoalsToAvg[j];
highGoalAvg += TOhighGoalsToAvg[j];
}

//Avg low goals
int lowGoalAvg = 0;
for(int j = 0; j < lowGoalsToAvg.Count; j++)
for(int j = 0; j < TOlowGoalsToAvg.Count; j++)
{
lowGoalAvg += lowGoalsToAvg[j];
lowGoalAvg += TOlowGoalsToAvg[j];
}

//Avg auto high goals
Expand All @@ -371,11 +394,11 @@ public static void SaveDataToTeams()
autoLowGoalAvg += autoLowGoalsToAvg[j];
}

if(highGoalsToAvg.Count > 0)
team.teleHighGoals = highGoalAvg / highGoalsToAvg.Count;
if(TOhighGoalsToAvg.Count > 0)
team.teleHighGoals = highGoalAvg / TOhighGoalsToAvg.Count;

if(lowGoalsToAvg.Count > 0)
team.teleLowGoals = lowGoalAvg / lowGoalsToAvg.Count;
if(TOlowGoalsToAvg.Count > 0)
team.teleLowGoals = lowGoalAvg / TOlowGoalsToAvg.Count;

if(autoHighGoalsToAvg.Count > 0)
team.autoHighGoals = autoHighGoalAvg / autoHighGoalsToAvg.Count;
Expand Down Expand Up @@ -603,13 +626,20 @@ public static void GenerateSpreadsheet(Event ev, int sorting)
/// <param name="sorting"></param>
public static void GenerateSpreadsheet(Event ev, int roundID, int sorting)
{
if(roundID != -1)
try
{
CreateRoundSpreadsheet(ev, roundID, sorting);
if (roundID != -1)
{
CreateRoundSpreadsheet(ev, roundID, sorting);
}
else
{
CreateEventSpreadsheet(ev, sorting);
}
}
else
catch (Exception ex)
{
CreateEventSpreadsheet(ev, sorting);
MessageBox.Show($"The spreadsheet could not be generated. \n\n{ex.Message}", "MyScout 2016", MessageBoxButtons.OK,MessageBoxIcon.Error);
}
}
#endregion
Expand Down
18 changes: 13 additions & 5 deletions MyScout/MyScout/src/Classes/Round.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,27 @@ public class Round
/// <summary>
/// TODO: Documentation
/// </summary>
public int[] highgoalcount = new int[6] { 0, 0, 0, 0, 0, 0 };
public int[] AOhighgoalcount = new int[6] { 0, 0, 0, 0, 0, 0 };
/// <summary>
/// TODO: Documentation
/// </summary>
public int[] lowgoalcount = new int[6] { 0, 0, 0, 0, 0, 0 };
public int[] AOlowgoalcount = new int[6] { 0, 0, 0, 0, 0, 0 };
/// <summary>
/// TODO: Documentation
/// </summary>
public string[] comments = new string[6] { "", "", "", "", "", "" };
public int[] TOhighgoalcount = new int[6] { 0, 0, 0, 0, 0, 0 };
/// <summary>
/// TODO: Documentation
/// </summary>
public string[] humancomments = new string[6] { "", "", "", "", "", "" };
public int[] TOlowgoalcount = new int[6] { 0, 0, 0, 0, 0, 0 };
/// <summary>
/// TODO: Documentation
/// </summary>
public string[] comments = new string[6] { " ", " ", " ", " ", " ", " " };
/// <summary>
/// TODO: Documentation
/// </summary>
public string[] humancomments = new string[6] { " ", " ", " ", " ", " ", " " };
/// <summary>
/// TODO: Documentation
/// </summary>
Expand All @@ -60,7 +68,7 @@ public class Round
/// <summary>
/// TODO: Documentation
/// </summary>
public string[] diedcomments = new string[6] { "", "", "", "", "", "" };
public string[] diedcomments = new string[6] { " ", " ", " ", " ", " ", " " };

public Round()
{
Expand Down
Loading

0 comments on commit d7d24a6

Please sign in to comment.