Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
cadon committed Nov 29, 2024
2 parents 112809e + 1c54c36 commit 364f7c8
Show file tree
Hide file tree
Showing 19 changed files with 1,809 additions and 1,647 deletions.
5 changes: 5 additions & 0 deletions ARKBreedingStats/ARKBreedingStats.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
<Compile Include="library\DummyCreatures.cs" />
<Compile Include="NamePatterns\JavaScriptNamePattern.cs" />
<Compile Include="NamePatterns\TokenModel.cs" />
<Compile Include="species\CanHaveWildLevelExceptions.cs" />
<Compile Include="StatsOptions\StatsOptionsControl.cs">
<SubType>Component</SubType>
</Compile>
Expand Down Expand Up @@ -707,6 +708,7 @@
<Compile Include="utils\ExceptionMessages.cs" />
<Compile Include="utils\ExtensionMethods.cs" />
<Compile Include="utils\CreatureListSorter.cs" />
<Compile Include="utils\Logging.cs" />
<Compile Include="utils\MessageBoxes.cs" />
<Compile Include="NamePatterns\NamePatternFunctions.cs" />
<Compile Include="utils\NaturalComparer.cs" />
Expand All @@ -719,6 +721,9 @@
<Compile Include="values\Values.cs" />
<Compile Include="utils\Win32API.cs" />
<Compile Include="values\ValuesFile.cs" />
<None Include="json\canHaveWildLevelExceptions.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="json\values\ASA-values.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down
3 changes: 3 additions & 0 deletions ARKBreedingStats/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,9 @@
<setting name="OverlayImportPattern" serializeAs="String">
<value />
</setting>
<setting name="ExtractorConvertWildTorporTotalLevel" serializeAs="String">
<value>True</value>
</setting>
</ARKBreedingStats.Properties.Settings>
</userSettings>
</configuration>
34 changes: 22 additions & 12 deletions ARKBreedingStats/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
using ARKBreedingStats.mods;
using ARKBreedingStats.NamePatterns;
using ARKBreedingStats.StatsOptions;
using ARKBreedingStats.StatsOptions.LevelColorSettings;
using ARKBreedingStats.StatsOptions.TopStatsSettings;
using ARKBreedingStats.utils;
using static ARKBreedingStats.settings.Settings;
Expand Down Expand Up @@ -2228,13 +2227,18 @@ private void StatIOQuickWildLevelCheck(StatIO sIo)
{
_clearExtractionCreatureData =
true; // as soon as the user changes stat-values, it's assumed it's not an exported creature anymore
if (sIo.statIndex == Stats.Torpidity && rbWildExtractor.Checked)

if (sIo.statIndex == Stats.Torpidity
&& rbWildExtractor.Checked
&& Properties.Settings.Default.ExtractorConvertWildTorporTotalLevel
&& speciesSelector1.SelectedSpecies?.stats is SpeciesStat[] speciesStats)
{
if (!(speciesSelector1.SelectedSpecies?.stats is SpeciesStat[] speciesStats)) return;
var trp = speciesStats[Stats.Torpidity];
if (trp == null || trp.BaseValue == 0 || trp.IncPerWildLevel == 0) return;
numericUpDownLevel.ValueSaveDouble = (sIo.Input / trp.BaseValue - 1) / trp.IncPerWildLevel;
return;
var torpidity = speciesStats[Stats.Torpidity];
if (torpidity != null && torpidity.BaseValue != 0 && torpidity.IncPerWildLevel != 0)
{
numericUpDownLevel.ValueSaveDouble =
Math.Round((sIo.Input / torpidity.BaseValue - 1) / torpidity.IncPerWildLevel + 1);
}
}

if (!cbQuickWildCheck.Checked) return;
Expand Down Expand Up @@ -3733,16 +3737,19 @@ private async void DisplayUpdateModules(bool onlyShowDialogIfUpdatesAreAvailable
{
if (!modules.UpdateAvailable && !selectDefaultImagesIfNotYet && onlyShowDialogIfUpdatesAreAvailable)
{
if (initializeImages) InitializeImages();
InitializeImages(!initializeImages);
return;
}

if (selectDefaultImagesIfNotYet)
modules.SelectDefaultImages();

modules.ShowDialog();
if (modules.DialogResult != DialogResult.OK)
return;
var dialogResult = modules.DialogResult;

InitializeImages(true);

if (dialogResult != DialogResult.OK) return;

var result = await modules.DownloadRequestedModulesAsync();

Expand All @@ -3757,12 +3764,15 @@ private async void DisplayUpdateModules(bool onlyShowDialogIfUpdatesAreAvailable
InitializeImages();
}

void InitializeImages()
void InitializeImages(bool onlyIfNotYetSet = false)
{
if (onlyIfNotYetSet && !string.IsNullOrEmpty(Properties.Settings.Default.SpeciesImagesFolder))
return;

Properties.Settings.Default.SpeciesImagesFolder = modules.GetSpeciesImagesFolder();
CreatureColored.InitializeSpeciesImageLocation();

if (Properties.Settings.Default.SpeciesImagesFolder != null)
if (!string.IsNullOrEmpty(Properties.Settings.Default.SpeciesImagesFolder))
speciesSelector1.InitializeSpeciesImages(Values.V.species);
}
}
Expand Down
13 changes: 10 additions & 3 deletions ARKBreedingStats/Form1.extractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
using ARKBreedingStats.utils;
using ARKBreedingStats.ocr;
using ARKBreedingStats.uiControls;
using System.Reflection;

namespace ARKBreedingStats
{
Expand Down Expand Up @@ -443,6 +442,11 @@ private bool ExtractLevels(bool autoExtraction = false, bool statInputsHighPreci
{
possibleExtractionIssues |= IssueNotes.Issue.SinglePlayer;
}
// if the stat is speed, the allowSpeedLeveling could be set incorrectly. For bred creatures that setting affects if speed is changed by imprinting.
if (s == Stats.SpeedMultiplier && rbBredExtractor.Checked && numericUpDownImprintingBonusExtractor.Value > 0)
{
possibleExtractionIssues |= IssueNotes.Issue.SpeedLevelingSetting;
}
}
}
if (!_extractor.ValidResults)
Expand Down Expand Up @@ -1554,10 +1558,13 @@ private void BtSetImprinting100_Click(object sender, EventArgs e)

private void numericUpDownLevel_ValueChanged(object sender, EventArgs e)
{
if (!(rbWildExtractor.Checked && speciesSelector1.SelectedSpecies is Species species)) return;
if (!(Properties.Settings.Default.ExtractorConvertWildTorporTotalLevel
&& rbWildExtractor.Checked
&& speciesSelector1.SelectedSpecies is Species species
)) return;

_statIOs[Stats.Torpidity].Input = StatValueCalculation.CalculateValue(species,
Stats.Torpidity, (int)numericUpDownLevel.Value, 0, 0, false);
Stats.Torpidity, (int)numericUpDownLevel.Value - 1, 0, 0, false);
}
}
}
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.64.0.0")]
[assembly: AssemblyFileVersion("0.64.1.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 @@ -596,5 +596,8 @@
<Setting Name="OverlayImportPattern" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="ExtractorConvertWildTorporTotalLevel" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
</Settings>
</SettingsFile>
8 changes: 2 additions & 6 deletions ARKBreedingStats/Updater/UpdateModules.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,8 @@ internal async Task<string> DownloadRequestedModulesAsync()
return sb.ToString();
}

public string GetSpeciesImagesFolder()
{
if (!(_checkboxesSelectModule?.Any() ?? false)) return null;

return _checkboxesSelectModule.Where(cb => cb.Checked).Select(cb => cb.Tag as AsbModule)
public string GetSpeciesImagesFolder() =>
_checkboxesSelectModule?.Where(cb => cb.Checked).Select(cb => cb.Tag as AsbModule)
.FirstOrDefault(m => m?.Category == "Species Images")?.LocalPath;
}
}
}
2 changes: 1 addition & 1 deletion ARKBreedingStats/_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"ARK Smart Breeding": {
"Id": "ARK Smart Breeding",
"Category": "main",
"version": "0.64.0.0"
"version": "0.64.1.0"
},
"SpeciesColorImages": {
"Id": "SpeciesColorImages",
Expand Down
31 changes: 24 additions & 7 deletions ARKBreedingStats/importExportGun/ReadExportFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,37 @@ public static string ReadFile(string filePath, string expectedStartString, out s
}

const string strProp = "StrProperty";
if (!SearchBytes(br, Encoding.ASCII.GetBytes(strProp)))
if (!SearchBytes(br, Encoding.ASCII.GetBytes(strProp + '\0')))
{
error = $"Expected property {strProp} not found";
return null;
}

br.ReadBytes(9); // skipping to json string length
var jsonLength = br.ReadInt32();
if (jsonLength <= 0)
// Assumption of the next 12 bytes:
// first the length of the string in bytes including 4 leading bytes (i.e. 4 bytes longer than the actual string)
// then four \0 bytes
// the next 4 bytes are the length of the actual string, depending on the encoding:
// If >0 it's the length in bytes and the string uses utf8, if it's <0 it's the negative length of the string in double bytes
var jsonByteLength = br.ReadInt32() - 4; // string length (subtracting the 4 encoding length bytes)
br.ReadBytes(4); // skipping \0 bytes
var jsonCharLength = br.ReadInt32();
var useUtf16 = false;
if (jsonCharLength <= 0)
{
error = $"Json length {jsonLength} at position {(br.BaseStream.Position - 4)} invalid";
return null;
if (jsonCharLength * -2 == jsonByteLength)
{
useUtf16 = true;
}
else
{
error = $"Json length {jsonCharLength} at position {(br.BaseStream.Position - 4)} invalid";
return null;
}
}
return Encoding.UTF8.GetString(br.ReadBytes(jsonLength));

return useUtf16
? Encoding.Unicode.GetString(br.ReadBytes(jsonByteLength))
: Encoding.UTF8.GetString(br.ReadBytes(jsonByteLength));
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions ARKBreedingStats/json/canHaveWildLevelExceptions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"Karkinos": 8,
"Basilisk": 8
}
4 changes: 2 additions & 2 deletions ARKBreedingStats/json/values/_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"mod": { "id": "1139775728", "tag": "Confuciusornis", "title": "Confuciusornis" }
},
"1169020368-Trex.json": {
"version": "358.24.1730042845",
"version": "358.24.1730398078",
"mod": { "id": "1169020368", "tag": "Trex", "title": "Ark Creature Rebalance (AG Reborn)" }
},
"1178308359-ShadDragon.json": {
Expand Down Expand Up @@ -370,7 +370,7 @@
"mod": { "id": "814833973", "tag": "Wyvern_Mating", "title": "Wyvern Mating" }
},
"839162288-Primal_Fear.json": {
"version": "358.11.1693416578",
"version": "358.24.1730580742",
"mod": { "id": "839162288", "tag": "Primal_Fear", "title": "Primal Fear" }
},
"883957187-WyvernWorld.json": {
Expand Down
Loading

0 comments on commit 364f7c8

Please sign in to comment.