Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
cadaei committed Apr 29, 2020
2 parents ab53b6e + c9db1b4 commit e1a3ea9
Show file tree
Hide file tree
Showing 40 changed files with 1,489 additions and 1,468 deletions.
10 changes: 4 additions & 6 deletions ARKBreedingStats/ASBManifest.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
using System.Collections.Generic;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using System.Collections.Generic;

namespace ARKBreedingStats
{
/// <summary>
/// Contains infos about the versions of different parts of this application
/// </summary>
[DataContract]
class ASBManifest
[JsonObject]
public class ASBManifest
{
/// <summary>
/// Must be present and a supported value.
/// </summary>
[DataMember]
private string format;

/// <summary>
/// Dictionary of Versions.
/// Expected is at least the key "version" in each entry.
/// </summary>
[DataMember]
public Dictionary<string, Dictionary<string, string>> versions;
}
}
3 changes: 3 additions & 0 deletions ARKBreedingStats/FileService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ public static bool SaveJSONFile(string filePath, object data, out string errorMe
errorMessage = null;
data = null;
if (!File.Exists(filePath))
{
errorMessage = $"File not found: {filePath}";
return false;
}

// load json-file of data
try
Expand Down
2 changes: 2 additions & 0 deletions ARKBreedingStats/Form1.collection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,8 @@ private bool LoadCollectionFile(string filePath, bool keepCurrentCreatures = fal
MessageBox.Show($"This library format is unsupported in this version of ARK Smart Breeding." +
"\n\nTry updating to a newer version.",
"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
if ((DateTime.Now - Properties.Settings.Default.lastUpdateCheck).TotalMinutes < 10)
CheckForUpdates();
return false;
}
catch (InvalidOperationException e)
Expand Down
2 changes: 1 addition & 1 deletion ARKBreedingStats/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1102,7 +1102,7 @@ private async void CheckForUpdates(bool silentCheck = false)
success.statValuesLoaded = true;
}

success.kibbleValuesLoaded = Kibbles.K.loadValues();
success.kibbleValuesLoaded = Kibbles.K.LoadValues();
if (!success.kibbleValuesLoaded)
{
MessageBox.Show("The kibbles-file couldn't be loaded, the kibble-recipes will not be available. " +
Expand Down
2 changes: 2 additions & 0 deletions ARKBreedingStats/Form1.values.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ private bool LoadStatValues(Values values)
catch (FormatException)
{
FormatExceptionMessageBox(FileService.ValuesJson);
if ((DateTime.Now - Properties.Settings.Default.lastUpdateCheck).TotalMinutes < 10)
CheckForUpdates();
}
catch (SerializationException e)
{
Expand Down
21 changes: 7 additions & 14 deletions ARKBreedingStats/IncubationTimerEntry.cs
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
using ARKBreedingStats.Library;
using Newtonsoft.Json;
using System;
using System.Runtime.Serialization;

namespace ARKBreedingStats
{
[DataContract]
[JsonObject(MemberSerialization.OptIn)]
public class IncubationTimerEntry
{
[DataMember]
[JsonProperty]
public bool timerIsRunning;
[IgnoreDataMember]
public TimeSpan incubationDuration;
[DataMember]
[JsonProperty]
public DateTime incubationEnd;
[IgnoreDataMember]
public Creature _mother;
[IgnoreDataMember]
public Creature _father;
[DataMember]
[JsonProperty]
public Guid motherGuid;
[DataMember]
[JsonProperty]
public Guid fatherGuid;
[IgnoreDataMember]
public string kind; // contains "Egg" or "Gestation", depending on the species
[IgnoreDataMember]
public bool expired;

public IncubationTimerEntry()
Expand Down Expand Up @@ -69,7 +64,6 @@ public void startStopTimer(bool start)
else pauseTimer();
}

[IgnoreDataMember]
public Creature mother
{
get => _mother;
Expand All @@ -80,7 +74,6 @@ public Creature mother
}
}

[IgnoreDataMember]
public Creature father
{
get => _father;
Expand All @@ -93,7 +86,7 @@ public Creature father

// XmlSerializer does not support TimeSpan, so use this property for serialization instead.
[System.ComponentModel.Browsable(false)]
[DataMember(Name = "incubationDuration")]
[JsonProperty("incubationDuration")]
public string incubationDurationString
{
get => System.Xml.XmlConvert.ToString(incubationDuration);
Expand Down
38 changes: 15 additions & 23 deletions ARKBreedingStats/Kibbles.cs
Original file line number Diff line number Diff line change
@@ -1,56 +1,48 @@
using ARKBreedingStats.species;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;
using System.Windows.Forms;

namespace ARKBreedingStats
{
[DataContract]
[JsonObject(MemberSerialization.OptIn)]
public class Kibbles
{
[DataMember]
[JsonProperty]
private string ver = "0.0";

[DataMember]
[JsonProperty]
public Dictionary<string, Kibble> kibble = new Dictionary<string, Kibble>();

public Version version = new Version(0, 0);
private static Kibbles _K;
public static Kibbles K => _K ?? (_K = new Kibbles());

public bool loadValues()
public bool LoadValues()
{
_K.version = new Version(0, 0);

try
{
using (FileStream file = FileService.GetJsonFileStream(FileService.KibblesJson))
{
DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(Kibbles), new DataContractJsonSerializerSettings()
{
UseSimpleDictionaryFormat = true
});

_K = (Kibbles)ser.ReadObject(file);

_K.version = new Version(_K.ver);
}
return true;
}
catch (FileNotFoundException)
string filePath = FileService.GetJsonPath(FileService.KibblesJson);
if (!File.Exists(filePath))
{
if (MessageBox.Show($"Kibble-File {FileService.KibblesJson} not found. " +
"This tool will not show kibble recipes without this file.\n\n" +
"Do you want to visit the homepage of the tool to redownload it?",
"Error", MessageBoxButtons.YesNo, MessageBoxIcon.Error) == DialogResult.Yes)
System.Diagnostics.Process.Start(Updater.ReleasesUrl);
}
catch (Exception e)
else if (FileService.LoadJSONFile(filePath, out Kibbles tempK, out string errorMessage))
{
_K = tempK;
_K.version = new Version(_K.ver);
return true;
}
else
{
MessageBox.Show($"File {FileService.KibblesJson} couldn\'t be opened or read.\nErrormessage:\n\n{e.Message}", "Error",
MessageBox.Show($"File {FileService.KibblesJson} couldn\'t be opened or read.\nErrormessage:\n\n{errorMessage}", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
return false;
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.39.4.0")]
[assembly: AssemblyFileVersion("0.39.5.0")]
[assembly: NeutralResourcesLanguage("en")]

4 changes: 2 additions & 2 deletions ARKBreedingStats/TamingControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public void SetSpecies(Species species, bool forceRefresh = false)
int i = 0;
if (td.eats != null)
{
for (i = 0; i < td.eats.Count; i++)
for (i = 0; i < td.eats.Length; i++)
{
string f = td.eats[i];
TamingFoodControl tf;
Expand Down Expand Up @@ -205,7 +205,7 @@ private void UpdateTamingData()

if (tameable && selectedSpecies.taming.eats != null)
{
int foodCounter = selectedSpecies.taming.eats.Count;
int foodCounter = selectedSpecies.taming.eats.Length;
foreach (TamingFoodControl tfc in foodControls)
{
if (foodCounter == 0)
Expand Down
20 changes: 8 additions & 12 deletions ARKBreedingStats/TimerListEntry.cs
Original file line number Diff line number Diff line change
@@ -1,30 +1,26 @@
using ARKBreedingStats.Library;
using Newtonsoft.Json;
using System;
using System.Runtime.Serialization;

namespace ARKBreedingStats
{
[DataContract]
[JsonObject(MemberSerialization.OptIn)]
public class TimerListEntry
{
[DataMember]
[JsonProperty]
public DateTime time;
[DataMember]
[JsonProperty]
public string name;
[DataMember]
[JsonProperty]
public string sound;
[DataMember]
[JsonProperty]
public string group;
[IgnoreDataMember]
public System.Windows.Forms.ListViewItem lvi;
[IgnoreDataMember]
public bool showInOverlay;
[DataMember]
public Guid creatureGuid = Guid.Empty;
[IgnoreDataMember]
[JsonProperty]
public Guid creatureGuid;
private Creature _creature;

[IgnoreDataMember]
public Creature creature
{
get => _creature;
Expand Down
2 changes: 1 addition & 1 deletion ARKBreedingStats/json/serverMultipliers.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"format": "1.12",
"format": "1.13",
"version": "1.0",
"serverMultiplierDictionary": {
"official": {
Expand Down
2 changes: 1 addition & 1 deletion ARKBreedingStats/json/tamingFoodData.json

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions ARKBreedingStats/json/values/_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"mod": { "id": "1523045986", "tag": "Paranoia", "title": "Additional Creatures 2: Paranoia!" }
},
"1565015734-BetterDinosTest.json": {
"version": "310.41.1587685372",
"version": "310.41.1587774145",
"mod": { "id": "1565015734", "tag": "BetterDinosTest", "title": "Better Dinos" }
},
"1576299694-ElementalDinos.json": {
Expand Down Expand Up @@ -202,7 +202,8 @@
"mod": { "id": "919470289", "tag": "SSFlyer", "title": "SSFlyer" }
},
"values.json": {
"version": "310.41.4923984"
"version": "310.47.4923984",
"format": "1.13"
}
}
}
10 changes: 7 additions & 3 deletions ARKBreedingStats/json/values/values.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"version": "310.41.4923984",
"format": "1.12",
"version": "310.47.4923984",
"format": "1.13",
"species": [
{
"name": "Rockwell",
Expand Down Expand Up @@ -63674,5 +63674,9 @@
[ "Navy Coloring", [ 0.03, 0.03, 0.15, 0 ] ],
[ "Olive Coloring", [ 0.5, 0.5, 0.1, 0 ] ],
[ "Slate Coloring", [ 0.1, 0.1, 0.1, 0 ] ]
]
],
"remaps": {
"/Game/Mods/Valguero/Assets/Dinos/IceWyvern/Ragnarok_Wyvern_Override_Ice.Ragnarok_Wyvern_Override_Ice": "/Game/Mods/Ragnarok/Custom_Assets/Dinos/Wyvern/Ice_Wyvern/Ragnarok_Wyvern_Override_Ice.Ragnarok_Wyvern_Override_Ice",
"/Game/Mods/Valguero/Assets/Dinos/PolarBear/Polar_Bear.Polar_Bear": "/Game/Mods/Ragnarok/Custom_Assets/Dinos/Polar_Bear/Polar_Bear.Polar_Bear"
}
}
3 changes: 2 additions & 1 deletion ARKBreedingStats/library/Creature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ public Species Species
set
{
_species = value;
speciesBlueprint = value?.blueprintPath ?? string.Empty;
if (value != null)
speciesBlueprint = value.blueprintPath;
}
get { return _species; }
}
Expand Down

0 comments on commit e1a3ea9

Please sign in to comment.