Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
cadaei committed Jun 2, 2020
2 parents e84ecd7 + ceeb434 commit 4c0afde
Show file tree
Hide file tree
Showing 19 changed files with 264 additions and 267 deletions.
2 changes: 1 addition & 1 deletion ARKBreedingStats/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@
<setting name="applyNamePatternOnAutoImportForNewCreatures" serializeAs="String">
<value>False</value>
</setting>
<setting name="AskedToDownloadImageFiles" serializeAs="String">
<setting name="AlreadyAskedToDownloadImageFiles" serializeAs="String">
<value>False</value>
</setting>
</ARKBreedingStats.Properties.Settings>
Expand Down
6 changes: 3 additions & 3 deletions ARKBreedingStats/BreedingPlan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -281,19 +281,19 @@ private void CalculateBreedingScoresAndDisplayPairs(BreedingMode breedingMode, b
else selectMales = FilterByTags(males);

// filter by servers
if (cbServerFilterLibrary.Checked)
if (cbServerFilterLibrary.Checked && (Properties.Settings.Default.FilterHideServers?.Any() ?? false))
{
selectFemales = selectFemales.Where(c => !Properties.Settings.Default.FilterHideServers.Contains(c.server));
selectMales = selectMales.Where(c => !Properties.Settings.Default.FilterHideServers.Contains(c.server));
}
// filter by owner
if (cbOwnerFilterLibrary.Checked)
if (cbOwnerFilterLibrary.Checked && (Properties.Settings.Default.FilterHideOwners?.Any() ?? false))
{
selectFemales = selectFemales.Where(c => !Properties.Settings.Default.FilterHideOwners.Contains(c.owner));
selectMales = selectMales.Where(c => !Properties.Settings.Default.FilterHideOwners.Contains(c.owner));
}
// filter by tribe
if (cbTribeFilterLibrary.Checked)
if (cbTribeFilterLibrary.Checked && (Properties.Settings.Default.FilterHideTribes?.Any() ?? false))
{
selectFemales = selectFemales.Where(c => !Properties.Settings.Default.FilterHideTribes.Contains(c.tribe));
selectMales = selectMales.Where(c => !Properties.Settings.Default.FilterHideTribes.Contains(c.tribe));
Expand Down
102 changes: 51 additions & 51 deletions ARKBreedingStats/CreatureBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace ARKBreedingStats
{
public partial class CreatureBox : UserControl
{
private Creature creature;
private Creature _creature;
public event Action<Creature, bool, bool> Changed;
public event Action<Creature> GiveParents;
private Sex sex;
Expand All @@ -30,7 +30,7 @@ public CreatureBox()
tt.Dispose();
};

creature = null;
_creature = null;
parentComboBoxMother.naLabel = "- Mother n/a";
parentComboBoxFather.naLabel = "- Father n/a";
regionColorChooser1.RegionColorChosen += RegionColorChooser1_RegionColorChosen;
Expand All @@ -47,7 +47,7 @@ public CreatureBox()
public void SetCreature(Creature creature)
{
Clear();
this.creature = creature;
this._creature = creature;
regionColorChooser1.SetSpecies(creature.Species, creature.colors);
colorRegionUseds = regionColorChooser1.ColorRegionsUseds;

Expand All @@ -65,24 +65,24 @@ public CreatureCollection CreatureCollection

private void buttonEdit_Click(object sender, EventArgs e)
{
if (creature != null)
if (_creature != null)
{
if (panel1.Visible)
{
CloseSettings(false);
}
else
{
checkBoxIsBred.Checked = creature.isBred;
panelParents.Visible = creature.isBred;
if (creature.isBred)
checkBoxIsBred.Checked = _creature.isBred;
panelParents.Visible = _creature.isBred;
if (_creature.isBred)
PopulateParentsList();
textBoxName.Text = creature.name;
textBoxOwner.Text = creature.owner;
textBoxNote.Text = creature.note;
sex = creature.sex;
textBoxName.Text = _creature.name;
textBoxOwner.Text = _creature.owner;
textBoxNote.Text = _creature.note;
sex = _creature.sex;
buttonSex.Text = Utils.SexSymbol(sex);
creatureStatus = creature.Status;
creatureStatus = _creature.Status;
SetStatusButton(creatureStatus);
textBoxName.SelectAll();
textBoxName.Focus();
Expand All @@ -101,45 +101,45 @@ private void PopulateParentsList()
{
if (parentList[0] == null || parentList[1] == null)
{
GiveParents(creature);
GiveParents(_creature);

parentComboBoxMother.parentsSimilarity = parentListSimilarity[0];
parentComboBoxMother.ParentList = parentList[0];
parentComboBoxMother.PreselectedCreatureGuid = creature.motherGuid;
parentComboBoxMother.PreselectedCreatureGuid = _creature.motherGuid;
parentComboBoxFather.parentsSimilarity = parentListSimilarity[1];
parentComboBoxFather.ParentList = parentList[1];
parentComboBoxFather.PreselectedCreatureGuid = creature.fatherGuid;
parentComboBoxFather.PreselectedCreatureGuid = _creature.fatherGuid;
}
}

public void UpdateLabel()
{
labelParents.Text = "";
if (creature != null)
if (_creature != null)
{
groupBox1.Text = $"{creature.name} (Lvl {creature.Level}/{creature.LevelHatched + cc.maxDomLevel})";
if (creature.Mother != null || creature.Father != null)
groupBox1.Text = $"{_creature.name} (Lvl {_creature.Level}/{_creature.LevelHatched + cc.maxDomLevel})";
if (_creature.Mother != null || _creature.Father != null)
{
if (creature.Mother != null)
labelParents.Text = "Mo: " + creature.Mother.name;
if (creature.Father != null && creature.Mother != null)
if (_creature.Mother != null)
labelParents.Text = "Mo: " + _creature.Mother.name;
if (_creature.Father != null && _creature.Mother != null)
labelParents.Text += "; ";
if (creature.Father != null)
labelParents.Text += "Fa: " + creature.Father.name;
if (_creature.Father != null)
labelParents.Text += "Fa: " + _creature.Father.name;
}
else if (creature.isBred)
else if (_creature.isBred)
{
labelParents.Text = "bred, click 'edit' to add parents";
}
else
{
labelParents.Text = "found wild " + creature.levelFound + (creature.tamingEff >= 0 ? ", tamed with TE: " + (creature.tamingEff * 100).ToString("N1") + "%" : ", TE unknown.");
labelParents.Text = "found wild " + _creature.levelFound + (_creature.tamingEff >= 0 ? ", tamed with TE: " + (_creature.tamingEff * 100).ToString("N1") + "%" : ", TE unknown.");
}
statsDisplay1.SetCreatureValues(creature);
labelNotes.Text = creature.note;
labelSpecies.Text = creature.Species.name;
pictureBox1.Image = CreatureColored.GetColoredCreature(creature.colors, creature.Species, colorRegionUseds, creatureSex: creature.sex);
tt.SetToolTip(pictureBox1, CreatureColored.RegionColorInfo(creature.Species, creature.colors)
statsDisplay1.SetCreatureValues(_creature);
labelNotes.Text = _creature.note;
labelSpecies.Text = _creature.Species.name;
pictureBox1.Image = CreatureColored.GetColoredCreature(_creature.colors, _creature.Species, colorRegionUseds, creatureSex: _creature.sex);
tt.SetToolTip(pictureBox1, CreatureColored.RegionColorInfo(_creature.Species, _creature.colors)
+ "\n\nClick to copy creature infos as image to the clipboard");
pictureBox1.Visible = true;
}
Expand All @@ -150,38 +150,38 @@ private void CloseSettings(bool save)
panel1.Visible = false;
if (save)
{
creature.name = textBoxName.Text;
creature.sex = sex;
creature.owner = textBoxOwner.Text;
_creature.name = textBoxName.Text;
_creature.sex = sex;
_creature.owner = textBoxOwner.Text;
Creature parent = null;
if (checkBoxIsBred.Checked)
parent = parentComboBoxMother.SelectedParent;
creature.motherGuid = parent?.guid ?? Guid.Empty;
_creature.motherGuid = parent?.guid ?? Guid.Empty;
bool parentsChanged = false;
if (creature.Mother != parent)
if (_creature.Mother != parent)
{
creature.Mother = parent;
_creature.Mother = parent;
parentsChanged = true;
}
parent = null;
if (checkBoxIsBred.Checked)
parent = parentComboBoxFather.SelectedParent;
creature.fatherGuid = parent?.guid ?? Guid.Empty;
if (creature.Father != parent)
_creature.fatherGuid = parent?.guid ?? Guid.Empty;
if (_creature.Father != parent)
{
creature.Father = parent;
_creature.Father = parent;
parentsChanged = true;
}
if (parentsChanged)
creature.RecalculateAncestorGenerations();
_creature.RecalculateAncestorGenerations();

creature.isBred = checkBoxIsBred.Checked;
_creature.isBred = checkBoxIsBred.Checked;

creature.note = textBoxNote.Text;
bool creatureStatusChanged = (creature.Status != creatureStatus);
creature.Status = creatureStatus;
_creature.note = textBoxNote.Text;
bool creatureStatusChanged = (_creature.Status != creatureStatus);
_creature.Status = creatureStatus;

Changed?.Invoke(creature, creatureStatusChanged, true);
Changed?.Invoke(_creature, creatureStatusChanged, true);
UpdateLabel();
}
}
Expand All @@ -194,7 +194,7 @@ public void Clear()
parentList = new List<Creature>[2];
CloseSettings(false);
groupBox1.Text = string.Empty;
creature = null;
_creature = null;
labelParents.Text = string.Empty;
statsDisplay1.Clear();
pictureBox1.Visible = false;
Expand Down Expand Up @@ -232,16 +232,16 @@ private void checkBoxIsBred_CheckedChanged(object sender, EventArgs e)

private void RegionColorChooser1_RegionColorChosen()
{
if (creature == null) return;
if (_creature == null) return;

pictureBox1.Image = CreatureColored.GetColoredCreature(creature.colors, creature.Species, colorRegionUseds, creatureSex: creature.sex);
creature.colors = regionColorChooser1.ColorIDs;
Changed?.Invoke(creature, false, false);
pictureBox1.Image = CreatureColored.GetColoredCreature(_creature.colors, _creature.Species, colorRegionUseds, creatureSex: _creature.sex);
_creature.colors = regionColorChooser1.ColorIDs;
Changed?.Invoke(_creature, false, false);
}

private void pictureBox1_Click(object sender, EventArgs e)
{
creature?.ExportInfoGraphicToClipboard(cc);
_creature?.ExportInfoGraphicToClipboard(cc);
}
}
}
7 changes: 3 additions & 4 deletions ARKBreedingStats/CreatureColored.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static Bitmap GetColoredCreature(int[] colorIds, Species species, bool[]
}

string speciesBackgroundFilePath = Path.Combine(imgFolder, speciesName + extension);
string cacheFileName = Path.Combine(cacheFolder, speciesName.Substring(0, Math.Min(speciesName.Length, 5)) + "_" + (speciesName + string.Join("", colorIds.Select(i => i.ToString()))).GetHashCode().ToString("X8") + extension);
string cacheFileName = Path.Combine(cacheFolder, speciesName.Substring(0, Math.Min(speciesName.Length, 5)) + "_" + (speciesName + string.Join(".", colorIds.Select(i => i.ToString()))).GetHashCode().ToString("X8") + extension);
string speciesColorMaskFilePath = Path.Combine(imgFolder, speciesName + "_m" + extension);
if (!onlyColors && File.Exists(speciesBackgroundFilePath) && File.Exists(speciesColorMaskFilePath) && !File.Exists(cacheFileName))
{
Expand All @@ -82,9 +82,8 @@ public static Bitmap GetColoredCreature(int[] colorIds, Species species, bool[]
float o = 0;
try
{
const int shadowValue = 220;
// background
using (var b = new SolidBrush(Color.FromArgb(100, shadowValue, shadowValue, shadowValue)))
// shadow
using (var b = new SolidBrush(Color.FromArgb(12, 0, 0, 0)))
{
int scx = defaultSizeOfTemplates / 2;
int scy = (int)(scx * 1.6);
Expand Down
25 changes: 20 additions & 5 deletions ARKBreedingStats/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,18 @@ public Form1()
Properties.Settings.Default.NamingPatterns = new string[6];
Properties.Settings.Default.NamingPatterns[0] = Properties.Settings.Default.sequentialUniqueNamePattern;
}
else
{
var newPatterns = new string[6];
// update isTopHP etc. to new format
Regex r = new Regex(@"(?<!\{)is(new)?top(hp|st|to|ox|fo|wa|te|we|dm|sp|fr|cr)(?!\})", RegexOptions.IgnoreCase);
for (int i = 0; i < 6; i++)
{
newPatterns[i] = r.Replace(Properties.Settings.Default.NamingPatterns[i], m => $"{{is{m.Groups[1].Value}Top{m.Groups[2].Value.ToLowerInvariant()}}}");
}

Properties.Settings.Default.NamingPatterns = newPatterns;
}

_tt = new ToolTip();
initLocalization();
Expand Down Expand Up @@ -384,9 +396,9 @@ private void Form1_Load(object sender, EventArgs e)
if (DateTime.Now.AddHours(-20) > Properties.Settings.Default.lastUpdateCheck)
CheckForUpdates(true);

if (!Properties.Settings.Default.AskedToDownloadImageFiles)
if (!Properties.Settings.Default.AlreadyAskedToDownloadImageFiles)
{
Properties.Settings.Default.AskedToDownloadImageFiles = true;
Properties.Settings.Default.AlreadyAskedToDownloadImageFiles = true;
if (!File.Exists(FileService.GetPath("img", "Giant Queen Bee.png"))
&& MessageBox.Show("Download species images to display the creature colors?\n\nThe file to be downloaded has a size of ~13 MB.",
"Download species images?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
Expand Down Expand Up @@ -1025,7 +1037,10 @@ private void UpdateParentListInput(CreatureInfoInput input)
{
// set possible parents
bool fromExtractor = input == creatureInfoInputExtractor;
Creature creature = new Creature(speciesSelector1.SelectedSpecies, "", "", "", 0, GetCurrentWildLevels(fromExtractor), levelStep: _creatureCollection.getWildLevelStep());
Creature creature = new Creature(speciesSelector1.SelectedSpecies, "", "", "", 0, GetCurrentWildLevels(fromExtractor), levelStep: _creatureCollection.getWildLevelStep())
{
guid = input.CreatureGuid
};
List<Creature>[] parents = FindPossibleParents(creature);
input.ParentsSimilarities = FindParentSimilarities(parents, creature);
input.Parents = parents;
Expand Down Expand Up @@ -1245,10 +1260,10 @@ private void CreatureBoxListView_FindParents(Creature creature)
private List<Creature>[] FindPossibleParents(Creature creature)
{
var fatherList = _creatureCollection.creatures
.Where(cr => cr.Species == creature.Species && cr.sex == Sex.Male && cr != creature)
.Where(cr => cr.Species == creature.Species && cr.sex == Sex.Male && cr.guid != creature.guid && !cr.flags.HasFlag(CreatureFlags.Placeholder))
.OrderBy(cr => cr.name);
var motherList = _creatureCollection.creatures
.Where(cr => cr.Species == creature.Species && cr.sex == Sex.Female && cr != creature)
.Where(cr => cr.Species == creature.Species && cr.sex == Sex.Female && cr.guid != creature.guid && !cr.flags.HasFlag(CreatureFlags.Placeholder))
.OrderBy(cr => cr.name);

// display new results
Expand Down
2 changes: 1 addition & 1 deletion ARKBreedingStats/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@
// Revision
//
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("0.40.0.0")]
[assembly: AssemblyFileVersion("0.40.1.0")]
[assembly: NeutralResourcesLanguage("en")]

6 changes: 3 additions & 3 deletions ARKBreedingStats/Properties/Settings.Designer.cs

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

2 changes: 1 addition & 1 deletion ARKBreedingStats/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@
<Setting Name="applyNamePatternOnAutoImportForNewCreatures" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="AskedToDownloadImageFiles" Type="System.Boolean" Scope="User">
<Setting Name="AlreadyAskedToDownloadImageFiles" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
</Settings>
Expand Down
1 change: 1 addition & 0 deletions ARKBreedingStats/Updater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ private static bool Download(string url, string outFileName)

try
{
Directory.CreateDirectory(imagesFolderPath);
using (var archive = ZipFile.OpenRead(tempFilePath))
{
foreach (ZipArchiveEntry file in archive.Entries)
Expand Down
Loading

0 comments on commit 4c0afde

Please sign in to comment.