Skip to content

Commit

Permalink
temporary fix for importing from ark-tools regarding wrong TE-values.…
Browse files Browse the repository at this point in the history
… added more menu-options for easier importing. added server-column in library. added server-property to multisetter. added server-filter to library.
  • Loading branch information
cadaei committed Feb 11, 2018
1 parent c8f2b12 commit 895388a
Show file tree
Hide file tree
Showing 12 changed files with 311 additions and 112 deletions.
2 changes: 2 additions & 0 deletions ARKBreedingStats/Creature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ public class Creature : IEquatable<Creature>
public DateTime domesticatedAt = new DateTime(0);
public bool neutered = false;
public int mutationCounter;
public int mutationsMaternal;
public int mutationsPaternal;
public List<string> tags = new List<string>();

public Creature()
Expand Down
2 changes: 2 additions & 0 deletions ARKBreedingStats/CreatureCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ namespace ARKBreedingStats
public List<IncubationTimerEntry> incubationListEntries = new List<IncubationTimerEntry>();
[XmlArray]
public List<string> hiddenOwners = new List<string>(); // which owners are not selected to be shown
[XmlArray]
internal List<string> hiddenServers = new List<string>();
public bool showDeads = true;
public bool showUnavailable = true;
public bool showNeutered = true;
Expand Down
167 changes: 123 additions & 44 deletions ARKBreedingStats/Form1.Designer.cs

Large diffs are not rendered by default.

169 changes: 126 additions & 43 deletions ARKBreedingStats/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1314,24 +1314,6 @@ private void loadCollection(bool add = false)
}
}

private void importToolStripMenuItem_Click(object sender, EventArgs e)
{
if (collectionDirty)
{
if (MessageBox.Show("Your Creature Collection has been modified since it was last saved, are you sure you want to import without saving first?", "Discard Changes?", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.No)
return;
}
OpenFileDialog dlg = new OpenFileDialog();
string previousImport = Properties.Settings.Default.LastImportFile;
if (!String.IsNullOrWhiteSpace(previousImport)) dlg.InitialDirectory = Path.GetDirectoryName(previousImport);
dlg.FileName = Path.GetFileName(previousImport);
dlg.Filter = "ARK Tools output (classes.json)|classes.json";
if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
importCollectionFromArkTools(dlg.FileName);
}
}

private void importCollectionFromArkTools(string classesFile)
{
// parse classes.json to find species
Expand Down Expand Up @@ -1595,12 +1577,14 @@ private void updateTreeListSpecies(List<Creature> creatures)
private void createOwnerList()
{
filterListAllowed = false;

// owner checkboxes
checkedListBoxOwner.Items.Clear();
bool removeWOOwner = true;
checkedListBoxOwner.Items.Add("n/a", (creatureCollection.hiddenOwners.IndexOf("n/a") == -1));
foreach (Creature c in creatureCollection.creatures)
{
if (c.owner == null || c.owner.Length == 0)
if (String.IsNullOrEmpty(c.owner))
removeWOOwner = false;
else if (c.owner.Length > 0 && checkedListBoxOwner.Items.IndexOf(c.owner) == -1)
{
Expand All @@ -1612,6 +1596,24 @@ private void createOwnerList()
if (removeWOOwner)
checkedListBoxOwner.Items.RemoveAt(0);

// server checkboxes
List<string> serverList = new List<string>();
checkedListBoxFilterServers.Items.Clear();
bool removeWOServer = true;
checkedListBoxFilterServers.Items.Add("n/a", (creatureCollection.hiddenOwners.IndexOf("n/a") == -1));
foreach (Creature c in creatureCollection.creatures)
{
if (String.IsNullOrEmpty(c.server))
removeWOServer = false;
else if (c.server.Length > 0 && checkedListBoxFilterServers.Items.IndexOf(c.server) == -1)
{
checkedListBoxFilterServers.Items.Add(c.server, (creatureCollection.hiddenOwners.IndexOf(c.server) == -1));
serverList.Add(c.server);
}
}
if (removeWOServer)
checkedListBoxFilterServers.Items.RemoveAt(0);

// owners
string[] owners = tribesControl1.playerNames;
creatureInfoInputExtractor.AutocompleteOwnerList = owners;
Expand All @@ -1628,9 +1630,9 @@ private void createOwnerList()
creatureInfoInputTester.OwnersTribes = ownersTribes;

// server
string[] serverList = creatureCollection.creatures.Select(c => c.server).Distinct().OrderBy(s => s).ToArray();
creatureInfoInputExtractor.ServersList = serverList;
creatureInfoInputTester.ServersList = serverList;
var serverArray = serverList.ToArray();
creatureInfoInputExtractor.ServersList = serverArray;
creatureInfoInputTester.ServersList = serverArray;

filterListAllowed = true;
}
Expand Down Expand Up @@ -1716,6 +1718,7 @@ private ListViewItem createCreatureLVItem(Creature cr, ListViewGroup g)
string[] subItems = (new string[] { cr.name + (cr.status != CreatureStatus.Available ? " (" + Utils.statusSymbol(cr.status) + ")" : ""),
cr.owner + (String.IsNullOrEmpty(cr.tribe) ? "" : " (" + cr.tribe + ")"),
cr.note,
cr.server,
Utils.sexSymbol(cr.gender),
cr.domesticatedAt.ToString("yyyy'-'MM'-'dd HH':'mm"),
cr.topness.ToString(),
Expand All @@ -1736,13 +1739,13 @@ private ListViewItem createCreatureLVItem(Creature cr, ListViewGroup g)
// color unknown levels
if (cr.levelsWild[s] < 0)
{
lvi.SubItems[s + 11].ForeColor = Color.WhiteSmoke;
lvi.SubItems[s + 11].BackColor = Color.WhiteSmoke;
lvi.SubItems[s + 12].ForeColor = Color.WhiteSmoke;
lvi.SubItems[s + 12].BackColor = Color.WhiteSmoke;
}
else
lvi.SubItems[s + 11].BackColor = Utils.getColorFromPercent((int)(cr.levelsWild[s] * (s == 7 ? colorFactor / 7 : colorFactor)), (considerStatHighlight[s] ? (cr.topBreedingStats[s] ? 0.2 : 0.7) : 0.93));
lvi.SubItems[s + 12].BackColor = Utils.getColorFromPercent((int)(cr.levelsWild[s] * (s == 7 ? colorFactor / 7 : colorFactor)), (considerStatHighlight[s] ? (cr.topBreedingStats[s] ? 0.2 : 0.7) : 0.93));
}
lvi.SubItems[3].BackColor = cr.neutered ? SystemColors.GrayText : (cr.gender == Sex.Female ? Color.FromArgb(255, 230, 255) : (cr.gender == Sex.Male ? Color.FromArgb(220, 235, 255) : SystemColors.Window));
lvi.SubItems[4].BackColor = cr.neutered ? SystemColors.GrayText : (cr.gender == Sex.Female ? Color.FromArgb(255, 230, 255) : (cr.gender == Sex.Male ? Color.FromArgb(220, 235, 255) : SystemColors.Window));

if (cr.status == CreatureStatus.Dead)
{
Expand All @@ -1765,42 +1768,42 @@ private ListViewItem createCreatureLVItem(Creature cr, ListViewGroup g)
{
if (cr.topBreedingCreature)
lvi.BackColor = Color.LightGreen;
lvi.SubItems[6].BackColor = Utils.getColorFromPercent(cr.topStatsCount * 8 + 44, 0.7);
lvi.SubItems[7].BackColor = Utils.getColorFromPercent(cr.topStatsCount * 8 + 44, 0.7);
}
else
{
lvi.SubItems[6].ForeColor = Color.LightGray;
lvi.SubItems[7].ForeColor = Color.LightGray;
}

// color for timestamp added
if (cr.domesticatedAt.Year < 2015)
{
lvi.SubItems[4].Text = "n/a";
lvi.SubItems[4].ForeColor = Color.LightGray;
lvi.SubItems[5].Text = "n/a";
lvi.SubItems[5].ForeColor = Color.LightGray;
}

// color for topness
lvi.SubItems[5].BackColor = Utils.getColorFromPercent(cr.topness * 2 - 100, 0.8); // topness is in percent. gradient from 50-100
lvi.SubItems[6].BackColor = Utils.getColorFromPercent(cr.topness * 2 - 100, 0.8); // topness is in percent. gradient from 50-100

// color for generation
if (cr.generation == 0)
lvi.SubItems[7].ForeColor = Color.LightGray;
lvi.SubItems[8].ForeColor = Color.LightGray;

// color of WildLevelColumn
if (cr.levelFound == 0)
lvi.SubItems[8].ForeColor = Color.LightGray;
lvi.SubItems[9].ForeColor = Color.LightGray;

// color for mutation
if (cr.mutationCounter > 0)
lvi.SubItems[9].BackColor = Color.FromArgb(225, 192, 255);
lvi.SubItems[10].BackColor = Color.FromArgb(225, 192, 255);
else
lvi.SubItems[9].ForeColor = Color.LightGray;
lvi.SubItems[10].ForeColor = Color.LightGray;

// color for cooldown
Color forecolor, backcolor;
cooldownColors(cr, out forecolor, out backcolor);
lvi.SubItems[10].ForeColor = forecolor;
lvi.SubItems[10].BackColor = backcolor;
lvi.SubItems[11].ForeColor = forecolor;
lvi.SubItems[11].BackColor = backcolor;

if (Properties.Settings.Default.showColorsInLibrary)
{
Expand All @@ -1809,12 +1812,12 @@ private ListViewItem createCreatureLVItem(Creature cr, ListViewGroup g)
{
if (cr.colors[cl] != 0)
{
lvi.SubItems[19 + cl].BackColor = Utils.creatureColor(cr.colors[cl]);
lvi.SubItems[19 + cl].ForeColor = Utils.foreColor(lvi.SubItems[19 + cl].BackColor);
lvi.SubItems[20 + cl].BackColor = Utils.creatureColor(cr.colors[cl]);
lvi.SubItems[20 + cl].ForeColor = Utils.foreColor(lvi.SubItems[20 + cl].BackColor);
}
else
{
lvi.SubItems[19 + cl].ForeColor = Color.White;
lvi.SubItems[20 + cl].ForeColor = Color.White;
}
}
}
Expand Down Expand Up @@ -2234,6 +2237,38 @@ private void listBoxSpeciesLib_SelectedIndexChanged(object sender, EventArgs e)
filterLib();
}

private void cbOwnerFilterAll_CheckedChanged(object sender, EventArgs e)
{
filterListAllowed = false;

bool chck = cbOwnerFilterAll.Checked;
creatureCollection.hiddenOwners.Clear();
for (int i = 0; i < checkedListBoxOwner.Items.Count; i++)
{
checkedListBoxOwner.SetItemChecked(i, chck);
if (!chck) creatureCollection.hiddenOwners.Add(checkedListBoxOwner.Items[i].ToString());
}

filterListAllowed = true;
filterLib();
}

private void cbServerFilterAll_CheckedChanged(object sender, EventArgs e)
{
filterListAllowed = false;

bool chck = cbServerFilterAll.Checked;
creatureCollection.hiddenServers.Clear();
for (int i = 0; i < checkedListBoxFilterServers.Items.Count; i++)
{
checkedListBoxFilterServers.SetItemChecked(i, chck);
if (!chck) creatureCollection.hiddenServers.Add(checkedListBoxFilterServers.Items[i].ToString());
}

filterListAllowed = true;
filterLib();
}

private void checkedListBoxOwner_ItemCheck(object sender, ItemCheckEventArgs e)
{
if (filterListAllowed)
Expand All @@ -2248,6 +2283,20 @@ private void checkedListBoxOwner_ItemCheck(object sender, ItemCheckEventArgs e)
}
}

private void checkedListBoxFilterServers_ItemCheck(object sender, ItemCheckEventArgs e)
{
if (filterListAllowed)
{
// update shownServers
string server = checkedListBoxFilterServers.Items[e.Index].ToString();
if (e.NewValue == CheckState.Unchecked) { creatureCollection.hiddenServers.Add(server); }
else { creatureCollection.hiddenServers.Remove(server); }

recalculateTopStatsIfNeeded();
filterLib();
}
}

/// <summary>
/// Recalculate topstats if filters are used in topstat-calculation
/// </summary>
Expand Down Expand Up @@ -2315,6 +2364,10 @@ private IEnumerable<Creature> applyLibraryFilterSettings(IEnumerable<Creature> c
bool hideWOOwner = (creatureCollection.hiddenOwners.IndexOf("n/a") >= 0);
creatures = creatures.Where(c => !creatureCollection.hiddenOwners.Contains(c.owner) && (!hideWOOwner || c.owner != ""));

// server filter
bool hideWOServer = (creatureCollection.hiddenServers.IndexOf("n/a") >= 0);
creatures = creatures.Where(c => !creatureCollection.hiddenServers.Contains(c.server) && (!hideWOServer || c.server != ""));

// show also dead creatures?
if (!libraryViews["Dead"])
creatures = creatures.Where(c => c.status != CreatureStatus.Dead);
Expand Down Expand Up @@ -4326,7 +4379,7 @@ private void cbExactlyImprinting_CheckedChanged(object sender, EventArgs e)
"Are you sure you want this?", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}

private void aRKToolsExtractionToolStripMenuItem_Click(object sender, EventArgs e)
private bool performDefaultExtractionFromARKTools()
{
if (Properties.Settings.Default.arkToolsPath.Length > 0
&& Properties.Settings.Default.arkSavegamePath.Length > 0
Expand Down Expand Up @@ -4357,9 +4410,39 @@ private void aRKToolsExtractionToolStripMenuItem_Click(object sender, EventArgs
Arguments = "/C ark-tools.exe tamed \"" + Properties.Settings.Default.arkSavegamePath + "\" \"" + Properties.Settings.Default.savegameExtractionPath + "\""
};
System.Diagnostics.Process.Start(startInfo);
return true;
}
else
MessageBox.Show("Not all the necessary default-paths are given. Set them in the Settings in the Import-tab.", "Import Paths are missing", MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox.Show("Not all the necessary default-paths are given. Set them in the Settings in the Import-tab.", "Import Paths are missing", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}

private void importCreatedJsonfileToolStripMenuItem_Click(object sender, EventArgs e)
{
if (collectionDirty)
{
if (MessageBox.Show("Your Creature Collection has been modified since it was last saved, are you sure you want to import without saving first?", "Discard Changes?", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.No)
return;
}
OpenFileDialog dlg = new OpenFileDialog();
string previousImport = Properties.Settings.Default.LastImportFile;
if (!String.IsNullOrWhiteSpace(previousImport)) dlg.InitialDirectory = Path.GetDirectoryName(previousImport);
dlg.FileName = Path.GetFileName(previousImport);
dlg.Filter = "ARK Tools output (classes.json)|classes.json";
if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
importCollectionFromArkTools(dlg.FileName);
}
}

private void runDefaultExtractionToolStripMenuItem_Click(object sender, EventArgs e)
{
performDefaultExtractionFromARKTools();
}

private void runDefaultExtractionAndImportFileToolStripMenuItem_Click(object sender, EventArgs e)
{
if (performDefaultExtractionFromARKTools())
importCollectionFromArkTools(Properties.Settings.Default.savegameExtractionPath + @"\classes.json");
}

/// <summary>
Expand Down
6 changes: 3 additions & 3 deletions ARKBreedingStats/Form1.resx
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ The TE can differ 0.1% due to ingame-rounding.</value>
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="contextMenuStripLibrary.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>364, 17</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="radarChart1.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
Expand Down Expand Up @@ -274,9 +277,6 @@ The TE can differ 0.1% due to ingame-rounding.</value>
a4ywyrbxQbAB3Ak3qLu41mHMfwCWaqdyEzp1TQAAAABJRU5ErkJggg==
</value>
</data>
<metadata name="contextMenuStripLibrary.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>364, 17</value>
</metadata>
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>248, 17</value>
</metadata>
Expand Down
14 changes: 9 additions & 5 deletions ARKBreedingStats/Importer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,21 +77,25 @@ private Creature ConvertCreature(ImportedCreature lc, int? levelStep)
{
var owner = String.IsNullOrWhiteSpace(lc.Imprinter) ? lc.Tamer : lc.Imprinter;
int[] wildLevels = new int[] { -1, -1, -1, -1, -1, -1, -1, -1 }; // -1 is unknown
int[] tamedLevels = new int[] { -1, -1, -1, -1, -1, -1, -1, -1 };
int[] tamedLevels = new int[8];
if (lc.WildLevels != null) wildLevels = ConvertLevels(lc.WildLevels, lc.BaseLevel - 1);
if (lc.TamedLevels != null) tamedLevels = ConvertLevels(lc.TamedLevels);

string convertedSpeciesName = ConvertSpecies(lc.Type);

// fix for wrong TE (bug in ark-tools) TODO. got it fixed in ark-tools?
double te = 1 / (2 - lc.TamingEffectiveness);

var creature = new Creature(convertedSpeciesName, lc.Name, owner, lc.Tribe,
lc.Female ? Sex.Female : Sex.Male,
wildLevels, tamedLevels,
lc.TamingEffectiveness, !string.IsNullOrWhiteSpace(lc.Imprinter), lc.ImprintingQuality, levelStep);
te, !string.IsNullOrWhiteSpace(lc.Imprinter), lc.ImprintingQuality, levelStep);

creature.guid = ConvertIdToGuid(lc.Id);
creature.domesticatedAt = DateTime.Now;
creature.imprintingBonus = lc.ImprintingQuality;
creature.tamingEff = lc.TamingEffectiveness;
creature.domesticatedAt = DateTime.Now; // TODO: convert ingame-time to realtime?
creature.mutationCounter = lc.MutationsMaleLine + lc.MutationsFemaleLine;
creature.mutationsMaternal = lc.MutationsFemaleLine;
creature.mutationsPaternal = lc.MutationsMaleLine;

// If it's a baby and still growing, work out growingUntil
if (lc.Baby || (!lc.Baby && !String.IsNullOrWhiteSpace(lc.Imprinter)))
Expand Down
2 changes: 1 addition & 1 deletion ARKBreedingStats/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@
// übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("0.25.1")]
[assembly: AssemblyFileVersion("0.25.2")]
Loading

0 comments on commit 895388a

Please sign in to comment.