Skip to content

Commit b77c803

Browse files
committed
Merge branch 'dev'
2 parents 3605bb4 + 5eb66c2 commit b77c803

11 files changed

+127
-44
lines changed

ARKBreedingStats/Form1.cs

-26
Original file line numberDiff line numberDiff line change
@@ -409,32 +409,6 @@ private void LoadAppSettings()
409409
}
410410
UpdatePatternButtons();
411411

412-
// conversion of global color level settings to specific options. Remove around 2024-09
413-
if (Properties.Settings.Default.ChartHueEvenMax != int.MaxValue)
414-
{
415-
var defaultSettings = StatsLevelColors.StatsOptionsDict[string.Empty].StatOptions;
416-
for (var s = 0; s < Stats.StatsCount; s++)
417-
{
418-
defaultSettings[s].LevelGraphRepresentation.LowerColor = Utils.ColorFromHue(Properties.Settings.Default.ChartHueEvenMin);
419-
defaultSettings[s].LevelGraphRepresentation.UpperColor = Utils.ColorFromHue(Properties.Settings.Default.ChartHueEvenMax);
420-
defaultSettings[s].LevelGraphRepresentation.ColorGradientReversed = Properties.Settings.Default.ChartHueEvenMax < Properties.Settings.Default.ChartHueEvenMin;
421-
422-
if (Properties.Settings.Default.HighlightEvenOdd)
423-
{
424-
defaultSettings[s].LevelGraphRepresentationOdd = new LevelGraphRepresentation
425-
{
426-
LowerColor = Utils.ColorFromHue(Properties.Settings.Default.ChartHueOddMin),
427-
UpperColor = Utils.ColorFromHue(Properties.Settings.Default.ChartHueOddMax),
428-
ColorGradientReversed = Properties.Settings.Default.ChartHueOddMax < Properties.Settings.Default.ChartHueOddMin,
429-
};
430-
defaultSettings[s].UseDifferentColorsForOddLevels = true;
431-
}
432-
}
433-
434-
Properties.Settings.Default.ChartHueEvenMax = int.MaxValue;
435-
}
436-
// end of level color settings conversion
437-
438412
// Load column-widths, display-indices and sort-order of the TimerControlListView
439413
LoadListViewSettings(timerList1.ListViewTimers, nameof(Properties.Settings.Default.TCLVColumnWidths),
440414
nameof(Properties.Settings.Default.TCLVColumnDisplayIndices),

ARKBreedingStats/Form1.extractor.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1283,7 +1283,7 @@ private void SetCreatureValuesToExtractor(CreatureValues cv, bool setInfoInput =
12831283
}
12841284
else if (cv.motherArkId != 0)
12851285
{
1286-
cv.Mother = new Creature(cv.motherArkId);
1286+
cv.Mother = new Creature(cv.motherArkId, cv.Species);
12871287
_creatureCollection.creatures.Add(cv.Mother);
12881288
}
12891289
}
@@ -1296,7 +1296,7 @@ private void SetCreatureValuesToExtractor(CreatureValues cv, bool setInfoInput =
12961296
}
12971297
else if (cv.fatherArkId != 0)
12981298
{
1299-
cv.Father = new Creature(cv.fatherArkId);
1299+
cv.Father = new Creature(cv.fatherArkId, cv.Species);
13001300
_creatureCollection.creatures.Add(cv.Father);
13011301
}
13021302
}

ARKBreedingStats/Form1.library.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,8 @@ private void CalculateTopStats(List<Creature> creatures, Species onlySpecies = n
572572
var considerTopStats = new Dictionary<Species, bool[]>();
573573
foreach (Creature c in creatures)
574574
{
575-
if (c.Species == null) continue;
575+
if (c.Species == null || c.flags.HasFlag(CreatureFlags.Placeholder))
576+
continue;
576577
if (!considerTopStats.TryGetValue(c.Species, out var consideredTopStats))
577578
{
578579
consideredTopStats = StatsTopStats.GetStatsOptions(c.Species).StatOptions.Select(si => si.ConsiderStat).ToArray();

ARKBreedingStats/Properties/AssemblyInfo.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@
3030
// Revision
3131
//
3232
[assembly: AssemblyVersion("1.0.0.0")]
33-
[assembly: AssemblyFileVersion("0.63.0.1")]
33+
[assembly: AssemblyFileVersion("0.63.1.0")]
3434
[assembly: NeutralResourcesLanguage("en")]
3535

ARKBreedingStats/StatsOptions/LevelColorSettings/LevelGraphOptionsControl.cs

+35-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Windows.Forms;
1+
using System;
2+
using System.Windows.Forms;
23

34
namespace ARKBreedingStats.StatsOptions.LevelColorSettings
45
{
@@ -15,22 +16,52 @@ protected override void InitializeStatControls()
1516
{
1617
var c = new StatLevelGraphOptionsControl($"[{si}] {Utils.StatName(si, true)}", si, Tt);
1718
_statOptionsControls[si] = c;
18-
StatsContainer.Controls.Add(c);
19-
StatsContainer.SetFlowBreak(c, true);
19+
AddWithFlowBreak(c);
2020
}
21-
StatsContainer.Controls.Add(new Label
21+
22+
AddWithFlowBreak(new Label
2223
{
2324
Text = @"Drag color gradient with mouse for fast editing.
2425
On color gradients use shift + right click to copy and shift + left click to paste color settings.
2526
Ctrl + left click to cycle through presets.",
2627
AutoSize = true
2728
});
29+
30+
var btReset = new Button { Text = "Reset all stats to default colors and ranges", AutoSize = true };
31+
btReset.Click += ResetCurrentSettingsToDefault;
32+
AddWithFlowBreak(btReset);
33+
34+
return;
35+
36+
void AddWithFlowBreak(Control c)
37+
{
38+
StatsContainer.Controls.Add(c);
39+
StatsContainer.SetFlowBreak(c, true);
40+
}
2841
}
2942

3043
protected override void UpdateStatsControls(bool isNotRoot)
3144
{
3245
for (var si = 0; si < Stats.StatsCount; si++)
3346
_statOptionsControls[si].SetStatOptions(SelectedStatsOptions.StatOptions?[si], isNotRoot, SelectedStatsOptions.ParentOptions);
3447
}
48+
49+
private void ResetCurrentSettingsToDefault(object sender, EventArgs e)
50+
{
51+
if (SelectedStatsOptions == null) return;
52+
if (SelectedStatsOptions.StatOptions == null)
53+
SelectedStatsOptions.StatOptions = new StatLevelColors[Stats.StatsCount];
54+
55+
var isNotRoot = !string.IsNullOrEmpty(SelectedStatsOptions.Name);
56+
for (var si = 0; si < Stats.StatsCount; si++)
57+
{
58+
SelectedStatsOptions.StatOptions[si] = new StatLevelColors
59+
{
60+
LevelGraphRepresentation = LevelGraphRepresentation.GetDefaultValue,
61+
LevelGraphRepresentationMutation = LevelGraphRepresentation.GetDefaultMutationLevelValue
62+
};
63+
_statOptionsControls[si].SetStatOptions(SelectedStatsOptions.StatOptions[si], isNotRoot, SelectedStatsOptions.ParentOptions);
64+
}
65+
}
3566
}
3667
}

ARKBreedingStats/StatsOptions/LevelColorSettings/StatLevelGraphOptionsControl.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public StatLevelGraphOptionsControl(string name, int statIndex, ToolTip tt) : th
2020
_statIndex = statIndex;
2121
hueControl.UpdateTooltips(tt);
2222
hueControlOdd.UpdateTooltips(tt);
23-
tt.SetToolTip(CbUseDifferentColorsForOddLevels, "Use different colors for odd levels");
23+
tt.SetToolTip(CbUseDifferentColorsForOddLevels, "Use different colors for odd wild levels");
2424
tt.SetToolTip(CbUseDifferentColorsForMutationLevels, "Use different colors for mutation levels");
2525
}
2626

@@ -33,7 +33,7 @@ public void SetStatOptions(StatLevelColors so, bool isNotRoot, StatsOptions<Stat
3333
hueControl.SetValues(so?.LevelGraphRepresentation);
3434
hueControlOdd.SetValues(so?.LevelGraphRepresentationOdd);
3535
HueControlMutations.SetValues(so?.LevelGraphRepresentationMutation);
36-
CbOverrideGraphSettings.Checked = so?.OverrideParent == true;
36+
CbOverrideGraphSettings.Checked = !isNotRoot || so?.OverrideParent == true;
3737
CbOverrideGraphSettings.Visible = isNotRoot;
3838
}
3939

ARKBreedingStats/StatsOptions/StatsOptions.cs

+10
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@ public class StatsOptions<T> where T : StatOptionsBase
3030
[JsonProperty]
3131
public T[] StatOptions;
3232

33+
/// <summary>
34+
/// List of species these settings are valid.
35+
/// Possible values are the blueprint path and shorter defined names, e.g. Species.name, Species.DescriptiveName.
36+
/// </summary>
37+
[JsonProperty("sp", DefaultValueHandling = DefaultValueHandling.Ignore)]
38+
public string[] AffectedSpecies;
39+
40+
/// <summary>
41+
/// Used for UI layout.
42+
/// </summary>
3343
public int HierarchyLevel;
3444
}
3545
}

ARKBreedingStats/StatsOptions/StatsOptionsControl.cs

+59-1
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@ internal class StatsOptionsControl<T> : TableLayoutPanel where T : StatOptionsBa
1919
protected Button BtRemove;
2020
protected TextBox TbOptionsName;
2121
protected Label LbParent;
22+
protected Label LbParentParent;
23+
protected Label LbAffectedSpecies;
2224
protected StatsOptions<T> SelectedStatsOptions;
2325
protected StatsOptionsSettings<T> StatsOptionsSettings;
26+
protected TextBox TbAffectedSpecies;
2427
protected FlowLayoutPanel StatsContainer;
2528
protected ToolTip Tt;
2629
private bool _ignoreIndexChange;
@@ -74,6 +77,22 @@ protected void InitializeControls(StatsOptionsSettings<T> settings, ToolTip tt)
7477
CbbParent.SelectedIndexChanged += CbbParent_SelectedIndexChanged;
7578
flpHeaderControls.Controls.Add(CbbParent);
7679

80+
var marginLabelDefault = new Padding(5, 7, 5, 0);
81+
82+
LbParentParent = new Label { Margin = marginLabelDefault, AutoSize = true };
83+
tt.SetToolTip(LbParentParent, "If the parent setting has no value for a stat, the parent's parent's values are used etc.");
84+
flpHeaderControls.Controls.Add(LbParentParent);
85+
flpHeaderControls.SetFlowBreak(LbParentParent, true);
86+
87+
LbAffectedSpecies = new Label { Text = "Affected species: ", Margin = marginLabelDefault, AutoSize = true };
88+
tt.SetToolTip(LbAffectedSpecies, @"Comma separated list of species affected by this setting.
89+
More specific identifier will be used first. Specificity order is
90+
BlueprintPath > DescriptiveNameAndMod > DescriptiveName > Name");
91+
flpHeaderControls.Controls.Add(LbAffectedSpecies);
92+
TbAffectedSpecies = new TextBox { AutoSize = true, MinimumSize = new Size(50, 0) };
93+
flpHeaderControls.Controls.Add(TbAffectedSpecies);
94+
TbAffectedSpecies.Leave += TbAffectedSpeciesLeave;
95+
7796
InitializeStatControls();
7897
InitializeOptions();
7998
}
@@ -150,13 +169,47 @@ private void CbbOptions_SelectedIndexChanged(object sender, EventArgs e)
150169
LbParent.Visible = isNotRoot;
151170
CbbParent.Visible = isNotRoot;
152171
BtRemove.Visible = isNotRoot;
172+
LbParentParent.Text = ParentsParentText(SelectedStatsOptions.ParentOptions);
173+
LbAffectedSpecies.Visible = isNotRoot;
174+
TbAffectedSpecies.Visible = isNotRoot;
175+
TbAffectedSpecies.Text = SelectedStatsOptions.AffectedSpecies == null ? string.Empty : string.Join(", ", SelectedStatsOptions.AffectedSpecies);
153176

154177
UpdateStatsControls(isNotRoot);
155178

156179
CbbParent.SelectedItem = SelectedStatsOptions.ParentOptions;
157180
this.ResumeDrawing();
158181
}
159182

183+
private void TbAffectedSpeciesLeave(object sender, EventArgs e)
184+
{
185+
if (SelectedStatsOptions == null) return;
186+
var sp = TbAffectedSpecies.Text
187+
.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
188+
.Select(s => s.Trim()).Where(s => !string.IsNullOrEmpty(s))
189+
.Distinct()
190+
.ToArray();
191+
SelectedStatsOptions.AffectedSpecies = sp.Any() ? sp : null;
192+
}
193+
194+
private string ParentsParentText(StatsOptions<T> selectedStatsOptions)
195+
{
196+
var maxGenerationsShown = 5;
197+
var currentParent = selectedStatsOptions?.ParentOptions;
198+
var parentText = string.Empty;
199+
while (currentParent != null)
200+
{
201+
if (maxGenerationsShown-- <= 0)
202+
{
203+
parentText += " \u2794 …";
204+
break;
205+
}
206+
parentText += " \u2794 " + (string.IsNullOrEmpty(currentParent.Name) ? currentParent.ToString() : currentParent.Name);
207+
currentParent = currentParent.ParentOptions;
208+
}
209+
210+
return parentText;
211+
}
212+
160213
/// <summary>
161214
/// Override this method to update the UI of the stat controls.
162215
/// </summary>
@@ -167,7 +220,9 @@ private void CbbParent_SelectedIndexChanged(object sender, EventArgs e)
167220
if (_ignoreIndexChange) return;
168221
SelectedStatsOptions = CbbOptions.SelectedItem as StatsOptions<T>;
169222
if (SelectedStatsOptions == null) return;
170-
SelectedStatsOptions.ParentOptions = CbbParent.SelectedItem as StatsOptions<T>;
223+
var selectedParent = CbbParent.SelectedItem as StatsOptions<T>;
224+
if (SelectedStatsOptions == selectedParent) return; // ignore if node itself is selected as parent
225+
SelectedStatsOptions.ParentOptions = selectedParent;
171226
InitializeOptions(true);
172227
StatsOptionsSettings.ClearSpeciesCache();
173228
}
@@ -187,6 +242,9 @@ private void TbOptionsName_Leave(object sender, EventArgs e)
187242
StatsOptionsSettings.StatsOptionsDict.Add(newName, SelectedStatsOptions);
188243
// update text in combobox
189244
CbbOptions.Items[CbbOptions.SelectedIndex] = SelectedStatsOptions;
245+
var cbbParentIndex = CbbParent.Items.IndexOf(SelectedStatsOptions);
246+
if (cbbParentIndex >= 0)
247+
CbbParent.Items[cbbParentIndex] = SelectedStatsOptions;
190248
StatsOptionsSettings.ClearSpeciesCache();
191249
}
192250

ARKBreedingStats/StatsOptions/StatsOptionsSettings.cs

+13-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
namespace ARKBreedingStats.StatsOptions
1010
{
1111
/// <summary>
12-
/// Base access to stats options.
12+
/// Base access to all stats options of one kind, e.g. all level color options.
1313
/// </summary>
1414
/// <typeparam name="T"></typeparam>
1515
public class StatsOptionsSettings<T> where T : StatOptionsBase
@@ -150,10 +150,18 @@ public StatsOptions<T> GetStatsOptions(Species species)
150150
if (_cache.TryGetValue(species.blueprintPath, out var o)) return o;
151151

152152
StatsOptions<T> speciesStatsOptions;
153-
if (StatsOptionsDict.TryGetValue(species.blueprintPath, out o)
154-
|| StatsOptionsDict.TryGetValue(species.DescriptiveNameAndMod, out o)
155-
|| StatsOptionsDict.TryGetValue(species.DescriptiveName, out o)
156-
|| StatsOptionsDict.TryGetValue(species.name, out o))
153+
154+
var dict = new Dictionary<string, StatsOptions<T>>();
155+
var list = StatsOptionsDict
156+
.Where(kv => kv.Value.AffectedSpecies != null)
157+
.SelectMany(kv => kv.Value.AffectedSpecies.Select(sp => (sp, kv.Value)));
158+
foreach (var sp in list)
159+
dict[sp.sp] = sp.Value;
160+
161+
if (dict.TryGetValue(species.blueprintPath, out o)
162+
|| dict.TryGetValue(species.DescriptiveNameAndMod, out o)
163+
|| dict.TryGetValue(species.DescriptiveName, out o)
164+
|| dict.TryGetValue(species.name, out o))
157165
{
158166
speciesStatsOptions = GenerateStatsOptions(o);
159167
}

ARKBreedingStats/_manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"ARK Smart Breeding": {
55
"Id": "ARK Smart Breeding",
66
"Category": "main",
7-
"version": "0.63.0.1"
7+
"version": "0.63.1.0"
88
},
99
"SpeciesColorImages": {
1010
"Id": "SpeciesColorImages",

ARKBreedingStats/library/Creature.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -287,11 +287,12 @@ public Species Species
287287
/// Creates a placeholder creature with the given ArkId, which have to be imported
288288
/// </summary>
289289
/// <param name="arkId">ArkId from an imported source (no user input)</param>
290-
public Creature(long arkId)
290+
public Creature(long arkId, Species species)
291291
{
292292
ArkId = arkId;
293293
ArkIdImported = true;
294294
guid = Utils.ConvertArkIdToGuid(arkId);
295+
Species = species;
295296
flags = CreatureFlags.Placeholder;
296297
}
297298

0 commit comments

Comments
 (0)