Skip to content

Commit

Permalink
also carry over eventMultipliers for new collection
Browse files Browse the repository at this point in the history
  • Loading branch information
cadon committed Feb 28, 2024
1 parent e7d26a1 commit 99a9ef8
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 22 deletions.
30 changes: 18 additions & 12 deletions ARKBreedingStats/Form1.collection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,31 +51,36 @@ private void NewCollection(bool resetCollection = false)
}
}

// use previously used multipliers again in the new file
var oldMultipliers = _creatureCollection.serverMultipliers;
var asaMode = _creatureCollection.Game == Ark.Asa;
ServerMultipliers oldMultipliers = null;
ServerMultipliers oldEventMultipliers = null;
bool asaMode;

if (!Properties.Settings.Default.KeepMultipliersForNewLibrary)
if (Properties.Settings.Default.KeepMultipliersForNewLibrary)
{
oldMultipliers = null; // use default
// use previously used multipliers again in the new file
oldMultipliers = _creatureCollection.serverMultipliers;
oldEventMultipliers = _creatureCollection.serverMultipliersEvents;
}

// ask which game version if no default is set
switch (Properties.Settings.Default.NewLibraryGame)
{
case Ark.Game.Unknown:
var gameVersionDialog = new ArkVersionDialog(this);
gameVersionDialog.ShowDialog();
if (gameVersionDialog.UseSelectionAsDefault)
Properties.Settings.Default.NewLibraryGame = gameVersionDialog.GameVersion;
asaMode = gameVersionDialog.GameVersion == Ark.Game.Asa;
break;
case Ark.Game.Ase:
asaMode = false;
break;
case Ark.Game.Asa:
asaMode = true;
break;
case Ark.Game.SameAsBefore:
asaMode = _creatureCollection.Game == Ark.Asa;
break;
default:
var gameVersionDialog = new ArkVersionDialog(this);
gameVersionDialog.ShowDialog();
if (gameVersionDialog.UseSelectionAsDefault)
Properties.Settings.Default.NewLibraryGame = gameVersionDialog.GameVersion;
asaMode = gameVersionDialog.GameVersion == Ark.Game.Asa;
break;
}

if (oldMultipliers == null)
Expand All @@ -84,6 +89,7 @@ private void NewCollection(bool resetCollection = false)
_creatureCollection = new CreatureCollection
{
serverMultipliers = oldMultipliers,
serverMultipliersEvents = oldEventMultipliers,
ModList = new List<Mod>()
};
_currentFileName = null;
Expand Down
11 changes: 3 additions & 8 deletions ARKBreedingStats/library/CreatureCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ public class CreatureCollection
{
public const string CurrentLibraryFormatVersion = "1.13";

public CreatureCollection()
{
FormatVersion = CurrentLibraryFormatVersion;
}

public const int MaxDomLevelDefault = 88;
public const int MaxDomLevelSinglePlayerDefault = 88;

Expand All @@ -28,7 +23,7 @@ public CreatureCollection()
[JsonIgnore]
public static CreatureCollection CurrentCreatureCollection;
[JsonProperty]
public string FormatVersion;
public string FormatVersion = CurrentLibraryFormatVersion;
[JsonProperty]
public List<Creature> creatures = new List<Creature>();
[JsonProperty]
Expand Down Expand Up @@ -65,12 +60,12 @@ public CreatureCollection()
[JsonProperty]
public ServerMultipliers serverMultipliers;
[JsonProperty]
public ServerMultipliers serverMultipliersEvents; // this object's statMultipliers are not used
public ServerMultipliers serverMultipliersEvents; // only the taming and breeding multipliers of this are used

/// <summary>
/// Deprecated setting, remove on 2025-01-01
/// </summary>
[JsonProperty]
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public bool singlePlayerSettings;

/// <summary>
Expand Down
3 changes: 3 additions & 0 deletions ARKBreedingStats/settings/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1157,6 +1157,8 @@ private void ApplyMultiplierPreset(ServerMultipliers sm, bool onlyStatMultiplier

CbAllowSpeedLeveling.Checked = sm.AllowSpeedLeveling;
CbAllowFlyerSpeedLeveling.Checked = sm.AllowFlyerSpeedLeveling;
cbSingleplayerSettings.Checked = sm.SinglePlayerSettings;
CbAtlasSettings.Checked = sm.AtlasSettings;
}

if (sm.statMultipliers == null) return;
Expand Down Expand Up @@ -1731,6 +1733,7 @@ private void BtAutoImportLocalSettings_Click(object sender, EventArgs e)
"Select one of the configs to import.", "Auto import configs", 40);
if (importIndex == -1) return;

CbAtlasSettings.Checked = false;
ExtractSettingsFromFile(Path.Combine(localConfigPaths[importIndex].Item1, "game.ini"), true);
ExtractSettingsFromFile(Path.Combine(localConfigPaths[importIndex].Item1, "gameUserSettings.ini"), true);

Expand Down
4 changes: 2 additions & 2 deletions ARKBreedingStats/values/Values.cs
Original file line number Diff line number Diff line change
Expand Up @@ -468,8 +468,8 @@ private void OrderSpeciesAndApplyCustomVariants()
/// </summary>
public void ApplyMultipliers(CreatureCollection cc, bool eventMultipliers = false, bool applyStatMultipliers = true)
{
currentServerMultipliers = (eventMultipliers ? cc.serverMultipliersEvents : cc.serverMultipliers)?.Copy(false);
if (currentServerMultipliers == null) currentServerMultipliers = V.serverMultipliersPresets.GetPreset(ServerMultipliersPresets.Official);
currentServerMultipliers = (eventMultipliers ? cc.serverMultipliersEvents : cc.serverMultipliers)?.Copy(false)
?? V.serverMultipliersPresets.GetPreset(ServerMultipliersPresets.Official);
if (currentServerMultipliers == null)
{
throw new FileNotFoundException("No default server multiplier values found.\nIt's recommend to redownload ARK Smart Breeding.");
Expand Down

0 comments on commit 99a9ef8

Please sign in to comment.