Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
cadon committed May 7, 2023
2 parents 7035324 + 3753060 commit dbc48e5
Show file tree
Hide file tree
Showing 22 changed files with 492 additions and 377 deletions.
1 change: 1 addition & 0 deletions ARKBreedingStats/ARKBreedingStats.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,7 @@
</EmbeddedResource>
<EmbeddedResource Include="TamingControl.resx">
<DependentUpon>TamingControl.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="TamingFoodControl.resx">
<DependentUpon>TamingFoodControl.cs</DependentUpon>
Expand Down
3 changes: 3 additions & 0 deletions ARKBreedingStats/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,9 @@
<setting name="AlwaysShowAllColorRegions" serializeAs="String">
<value>False</value>
</setting>
<setting name="language2" serializeAs="String">
<value />
</setting>
</ARKBreedingStats.Properties.Settings>
</userSettings>
</configuration>
2 changes: 1 addition & 1 deletion ARKBreedingStats/Form1.l10n.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ public partial class Form1
{
private void InitLocalization()
{
Loc.LoadResourceFile();
Loc.LoadResourceFile(Properties.Settings.Default.language, Properties.Settings.Default.language2);
Utils.InitializeLocalizations();
}

Expand Down
22 changes: 10 additions & 12 deletions ARKBreedingStats/Form1.library.cs
Original file line number Diff line number Diff line change
Expand Up @@ -733,18 +733,16 @@ private Creature EnsurePlaceholderCreature(List<Creature> placeholders, Creature
/// <param name="cc"></param>
private void UpdateIncubationParents(CreatureCollection cc)
{
foreach (Creature c in cc.creatures)
if (!cc.incubationListEntries.Any()) return;

var dict = cc.creatures.ToDictionary(c => c.guid);

foreach (IncubationTimerEntry it in cc.incubationListEntries)
{
if (c.guid != Guid.Empty)
{
foreach (IncubationTimerEntry it in cc.incubationListEntries)
{
if (c.guid == it.motherGuid)
it.mother = c;
else if (c.guid == it.fatherGuid)
it.father = c;
}
}
if (it.motherGuid != Guid.Empty && dict.TryGetValue(it.motherGuid, out var m))
it.Mother = m;
if (it.fatherGuid != Guid.Empty && dict.TryGetValue(it.fatherGuid, out var f))
it.Father = f;
}
}

Expand Down Expand Up @@ -1594,7 +1592,7 @@ private void ExportForSpreadsheet()
}
if (listViewLibrary.SelectedIndices.Count > 0)
{
var exportCount = ExportImportCreatures.ExportTable(listViewLibrary.SelectedIndices.Cast<int>().Select(i => _creaturesDisplayed[i]));
var exportCount = ExportImportCreatures.ExportTable(listViewLibrary.SelectedIndices.Cast<int>().Select(i => _creaturesDisplayed[i]).ToArray());
if (exportCount != 0)
SetMessageLabelText($"{exportCount} creatures were exported to the clipboard for pasting in a spreadsheet.", MessageBoxIcon.Information);

Expand Down
20 changes: 7 additions & 13 deletions ARKBreedingStats/IncubationTimerEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,21 @@ public class IncubationTimerEntry
public TimeSpan incubationDuration;
[JsonProperty]
public DateTime incubationEnd;
public Creature _mother;
public Creature _father;
private Creature _mother;
private Creature _father;
[JsonProperty]
public Guid motherGuid;
[JsonProperty]
public Guid fatherGuid;
public string kind; // contains "Egg" or "Gestation", depending on the species
public bool expired;

public IncubationTimerEntry()
{
mother = new Creature();
father = new Creature();
incubationDuration = new TimeSpan();
incubationEnd = new DateTime();
}
public IncubationTimerEntry() { }

public IncubationTimerEntry(Creature mother, Creature father, TimeSpan incubationDuration, bool incubationStarted)
{
this.mother = mother;
this.father = father;
Mother = mother;
Father = father;
this.incubationDuration = incubationDuration;
incubationEnd = new DateTime();
if (incubationStarted)
Expand Down Expand Up @@ -64,7 +58,7 @@ public void StartStopTimer(bool start)
else PauseTimer();
}

public Creature mother
public Creature Mother
{
get => _mother;
set
Expand All @@ -74,7 +68,7 @@ public Creature mother
}
}

public Creature father
public Creature Father
{
get => _father;
set
Expand Down
47 changes: 30 additions & 17 deletions ARKBreedingStats/Loc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,52 @@ namespace ARKBreedingStats
/// </summary>
internal static class Loc
{
private static ResourceManager rm;
private static ResourceManager _rm;
/// <summary>
/// Second language can be used in parts of the app.
/// </summary>
private static CultureInfo _secondaryCulture;

public static void LoadResourceFile()
public static void LoadResourceFile(string language, string language2 = null)
{
CultureInfo culture;
if (string.IsNullOrEmpty(Properties.Settings.Default.language))
{
culture = CultureInfo.CurrentCulture;
}
else
CultureInfo LoadCultureInfo(string l)
{
if (string.IsNullOrEmpty(l))
{
return null;
}
try
{
culture = new CultureInfo(Properties.Settings.Default.language);
return new CultureInfo(l);
}
catch (CultureNotFoundException)
{
culture = CultureInfo.CurrentCulture;
return null;
}
}

Thread.CurrentThread.CurrentUICulture = culture;
if (!string.IsNullOrEmpty(language2) && language2 != language)
_secondaryCulture = LoadCultureInfo(language2);
else _secondaryCulture = null;

rm = new ResourceManager("ARKBreedingStats.local.strings", typeof(Form1).Assembly);
var culture = LoadCultureInfo(language) ?? CultureInfo.CurrentCulture;
Thread.CurrentThread.CurrentUICulture = culture;
if (_rm == null)
_rm = new ResourceManager("ARKBreedingStats.local.strings", typeof(Form1).Assembly);
}

public static bool UseSecondaryCulture => _secondaryCulture != null;

/// <summary>
/// Returns the localized string.
/// </summary>
public static string S(string key, bool returnKeyIfValueNa = true)
public static string S(string key, bool returnKeyIfValueNa = true, bool secondaryCulture = false)
{
if (rm == null) return null;
string s = rm.GetString(key);
if (_rm == null) return null;
if (secondaryCulture && _secondaryCulture != null)
return S(key, _secondaryCulture, returnKeyIfValueNa);

var s = _rm.GetString(key);
//if (string.IsNullOrEmpty(s) && !key.EndsWith("TT")) System.Console.WriteLine("missing: " + key); // for debugging
return s ?? (returnKeyIfValueNa ? key : null);
}
Expand All @@ -52,8 +65,8 @@ public static string S(string key, bool returnKeyIfValueNa = true)
/// </summary>
public static string S(string key, CultureInfo culture, bool returnKeyIfValueNa = true)
{
if (rm == null) return null;
string s = rm.GetString(key, culture);
if (_rm == null) return null;
string s = _rm.GetString(key, culture);
//if (string.IsNullOrEmpty(s) && !key.EndsWith("TT")) System.Console.WriteLine("missing: " + key); // for debugging
return s ?? (returnKeyIfValueNa ? key : null);
}
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.53.1.0")]
[assembly: AssemblyFileVersion("0.54.0.0")]
[assembly: NeutralResourcesLanguage("en")]

12 changes: 12 additions & 0 deletions ARKBreedingStats/Properties/Settings.Designer.cs

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

3 changes: 3 additions & 0 deletions ARKBreedingStats/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -551,5 +551,8 @@
<Setting Name="CustomStatWeightOddEven" Type="System.Byte[][]" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="language2" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
</Settings>
</SettingsFile>
12 changes: 6 additions & 6 deletions ARKBreedingStats/Taming.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static class Taming

public static void TamingTimes(Species species, int level, double tamingSpeedMultiplier, double tamingFoodRateMultiplier,
List<string> usedFood, List<int> foodAmount, out List<int> foodAmountUsed, out TimeSpan duration,
out int neededNarcoberries, out int neededAscerbicMushrooms, out int neededNarcotics, out int neededBioToxins, out double te, out double hunger, out int bonusLevel, out bool enoughFood)
out int neededNarcoberries, out int neededAscerbicMushrooms, out int neededNarcotics, out int neededBioToxins, out double te, out double hunger, out int bonusLevel, out bool enoughFood, bool useSanguineElixir = false)
{
double totalTorpor = 0;
double torporDepletionPerSecond = 0;
Expand All @@ -41,7 +41,7 @@ public static void TamingTimes(Species species, int level, double tamingSpeedMul
if (species != null && species.taming != null)
{

double affinityNeeded = species.taming.affinityNeeded0 + species.taming.affinityIncreasePL * level;
double affinityNeeded = (species.taming.affinityNeeded0 + species.taming.affinityIncreasePL * level) * (useSanguineElixir ? 0.7 : 1);

// test if creature is tamed non-violently, then use wakeTame multipliers
if (!species.taming.nonViolent)
Expand Down Expand Up @@ -147,19 +147,19 @@ public static void TamingTimes(Species species, int level, double tamingSpeedMul
public static void TamingTimes(Species species, int level, double tamingSpeedMultiplier, double tamingFoodRateMultiplier,
string usedFood, int foodAmount,
out List<int> foodAmountUsed, out TimeSpan duration, out int neededNarcoberries, out int neededAscerbicMushrooms, out int neededNarcotics,
out int neededBioToxins, out double te, out double hunger, out int bonusLevel, out bool enoughFood)
out int neededBioToxins, out double te, out double hunger, out int bonusLevel, out bool enoughFood, bool useSanguineElixir = false)
{
TamingTimes(species, level, tamingSpeedMultiplier, tamingFoodRateMultiplier,
new List<string> { usedFood }, new List<int> { foodAmount },
out foodAmountUsed, out duration, out neededNarcoberries, out neededAscerbicMushrooms, out neededNarcotics, out neededBioToxins,
out te, out hunger, out bonusLevel, out enoughFood);
out te, out hunger, out bonusLevel, out enoughFood, useSanguineElixir);
}

public static int FoodAmountNeeded(Species species, int level, double tamingSpeedMultiplier, string foodName, bool nonViolent = false)
public static int FoodAmountNeeded(Species species, int level, double tamingSpeedMultiplier, string foodName, bool nonViolent = false, bool useSanguineElixir = false)
{
if (species != null)
{
double affinityNeeded = species.taming.affinityNeeded0 + species.taming.affinityIncreasePL * level;
double affinityNeeded = (species.taming.affinityNeeded0 + species.taming.affinityIncreasePL * level) * (useSanguineElixir ? 0.7 : 1);

var food = Values.V.GetTamingFood(species, foodName);
if (food == null) return 0;
Expand Down
Loading

0 comments on commit dbc48e5

Please sign in to comment.