Skip to content

Commit

Permalink
Character Filter
Browse files Browse the repository at this point in the history
- Made a simple character filter dropdown box
- Minor change to hopefully make scanning mails a little faster
  • Loading branch information
Deantwo committed Jun 22, 2014
1 parent 245611d commit 4489187
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 21 deletions.
10 changes: 10 additions & 0 deletions HObj.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,22 @@ public byte AttentionCode
get { return _attentionCode; }
}

protected List<string> _owners = new List<string>();
public List<string> Onwers
{
get { return _owners; }
}

public virtual void Update(HMail mail)
{
_name = mail.From; // Incase sender changed name.
_lastUpdated = mail.DateTime;
_attentionCode = 0x00; // 0b00000000

string tempOwner = HHelper.ToID(mail.RecipientID);
if (!_owners.Contains(tempOwner))
_owners.Add(tempOwner); // Wish I could get the name of the empire instead!!!

// Full body test, mostly used for debuging.
_body = mail.Body;
}
Expand Down
16 changes: 16 additions & 0 deletions Main.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

71 changes: 61 additions & 10 deletions Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public partial class Main : Form
List<HShip> hShipList = new List<HShip>();
List<HOfficer> hOfficerList = new List<HOfficer>();

List<string> charIdList = new List<string>();

Image imageCity;
Image imageShip;
Image imageOfficer;
Expand All @@ -36,7 +38,8 @@ public Main()
imageShip = HazeronAdviser.Properties.Resources.GovSpacecraft;
imageOfficer = HazeronAdviser.Properties.Resources.Officer;
dgvCity.Columns["ColumnCityAbandonment"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
dgvCity.Columns["ColumnCityAbandonment"].DefaultCellStyle.Font = new Font("Lucida Console", 9);
dgvCity.Columns["ColumnCityAbandonment"].DefaultCellStyle.Font = new Font("Lucida Console", 9);
cmbCharFilter.SelectedIndex = 0;
}

private void button1_Click(object sender, EventArgs e)
Expand All @@ -51,6 +54,10 @@ private void button1_Click(object sender, EventArgs e)
return;
}
string[] fileList = Directory.GetFiles(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Shores of Hazeron", "Mail")); // %USERPROFILE%\Shores of Hazeron\Mail
cmbCharFilter.Enabled = false;
cmbCharFilter.Items.Clear();
cmbCharFilter.Items.Add("Show all");
cmbCharFilter.SelectedIndex = 0;
toolStripProgressBar1.Value = 0;
toolStripProgressBar1.Maximum = fileList.Length;
toolStripProgressBar1.Visible = true;
Expand All @@ -66,6 +73,7 @@ private void button1_Click(object sender, EventArgs e)
tbxCity.Clear();
tbxShip.Clear();
tbxOfficer.Clear();
#region Scan HMails
foreach (string file in fileList)
{
if (HMail.IsUni4(file)) // Check if signature is 0x2110 before trying to read it.
Expand All @@ -74,30 +82,33 @@ private void button1_Click(object sender, EventArgs e)
try
{
#endif
if (HMail.IsCityReport(file))
HMail mail = new HMail(file);
if (HMail.IsCityReport(mail))
{
HCity temp = new HCity(new HMail(file));
HCity temp = new HCity(mail);
if (hCityList.Any(city => city.ID == temp.ID))
hCityList[hCityList.FindIndex(city => city.ID == temp.ID)].Update(new HMail(file));
hCityList[hCityList.FindIndex(city => city.ID == temp.ID)].Update(mail);
else
hCityList.Add(temp);
}
else if (HMail.IsShipLog(file))
else if (HMail.IsShipLog(mail))
{
HShip temp = new HShip(new HMail(file));
HShip temp = new HShip(mail);
if (hShipList.Any(ship => ship.ID == temp.ID))
hShipList[hShipList.FindIndex(ship => ship.ID == temp.ID)].Update(new HMail(file));
hShipList[hShipList.FindIndex(ship => ship.ID == temp.ID)].Update(mail);
else
hShipList.Add(temp);
}
else if (HMail.IsOfficerTenFour(file))
else if (HMail.IsOfficerTenFour(mail))
{
HOfficer temp = new HOfficer(new HMail(file));
HOfficer temp = new HOfficer(mail);
if (hOfficerList.Any(officer => officer.ID == temp.ID))
hOfficerList[hOfficerList.FindIndex(ship => ship.ID == temp.ID)].Update(new HMail(file));
hOfficerList[hOfficerList.FindIndex(ship => ship.ID == temp.ID)].Update(mail);
else
hOfficerList.Add(temp);
}
if (!charIdList.Contains(HHelper.ToID(mail.RecipientID)))
charIdList.Add(HHelper.ToID(mail.RecipientID));
toolStripProgressBar1.Increment(1);
#if RELEASE
}
Expand All @@ -113,6 +124,7 @@ private void button1_Click(object sender, EventArgs e)
#endif
}
}
#endregion
toolStripProgressBar2.Value = 0;
toolStripProgressBar2.Maximum = hCityList.Count + hShipList.Count + hOfficerList.Count;
toolStripProgressBar2.Visible = true;
Expand Down Expand Up @@ -230,8 +242,14 @@ private void button1_Click(object sender, EventArgs e)
toolStripProgressBar2.Increment(1);
}
#endregion
foreach (string charId in charIdList)
cmbCharFilter.Items.Add(charId);
cmbCharFilter.Enabled = true;
toolStripProgressBar1.Visible = false;
toolStripProgressBar2.Visible = false;
dgvCity.ClearSelection();
dgvShip.ClearSelection();
dgvOfficer.ClearSelection();
toolStripStatusLabel1.Text = "Done!";
}

Expand Down Expand Up @@ -263,6 +281,39 @@ private void dgvOfficer_SelectionChanged(object sender, EventArgs e)
}
#endregion

private void cmbCharFilter_SelectedIndexChanged(object sender, EventArgs e)
{
if (cmbCharFilter.Enabled)
{
if (cmbCharFilter.SelectedIndex == 0)
{
foreach (DataGridViewRow row in dgvCity.Rows)
row.Visible = true;
foreach (DataGridViewRow row in dgvShip.Rows)
row.Visible = true;
foreach (DataGridViewRow row in dgvOfficer.Rows)
row.Visible = true;
}
else
{
foreach (DataGridViewRow row in dgvCity.Rows)
row.Visible = hCityList[(int)row.Cells["ColumnCityIndex"].Value].Onwers.Contains(charIdList[cmbCharFilter.SelectedIndex - 1]);
foreach (DataGridViewRow row in dgvShip.Rows)
row.Visible = hShipList[(int)row.Cells["ColumnShipIndex"].Value].Onwers.Contains(charIdList[cmbCharFilter.SelectedIndex - 1]);
foreach (DataGridViewRow row in dgvOfficer.Rows)
row.Visible = hOfficerList[(int)row.Cells["ColumnOfficerIndex"].Value].Onwers.Contains(charIdList[cmbCharFilter.SelectedIndex - 1]);
}
dgvCity.ClearSelection();
dgvShip.ClearSelection();
dgvOfficer.ClearSelection();
tbxCity.Clear();
tbxShip.Clear();
tbxOfficer.Clear();
pCityStatisticsPop.Refresh();
pCityStatisticsMorale.Refresh();
}
}

#region Statistics Graphics
private void pCityStatistics_Paint(object sender, PaintEventArgs e) // gCityStatisticsPop
{
Expand Down
22 changes: 11 additions & 11 deletions Main.resx
Original file line number Diff line number Diff line change
Expand Up @@ -189,17 +189,6 @@
<metadata name="ColumnCityDate.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>133, 17</value>
</metadata>
<data name="pCityStatisticsPop.ToolTip" xml:space="preserve">
<value>Yellow - Loyal Citizens (often hidden under Population)
Orange - Disloyal Citizens (often hidden under Population)
Light Green - Population (often hidden under Homes)
Green - Homes
Blue - Jobs
Red - Population Limit for the city's resource zone</value>
</data>
<metadata name="ColumnCityIndex.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
Expand Down Expand Up @@ -227,6 +216,17 @@ Red - Population Limit for the city's resource zone</value>
<metadata name="ColumnCityDate.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>133, 17</value>
</metadata>
<data name="pCityStatisticsPop.ToolTip" xml:space="preserve">
<value>Yellow - Loyal Citizens (often hidden under Population)
Orange - Disloyal Citizens (often hidden under Population)
Light Green - Population (often hidden under Homes)
Green - Homes
Blue - Jobs
Red - Population Limit for the city's resource zone</value>
</data>
<metadata name="ColumnOfficerIndex.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
Expand Down

0 comments on commit 4489187

Please sign in to comment.