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 5, 2024
2 parents ec76dfe + 6ea8486 commit 177d3ed
Show file tree
Hide file tree
Showing 12 changed files with 76 additions and 55 deletions.
3 changes: 3 additions & 0 deletions ARKBreedingStats/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,9 @@
<setting name="OverlayInfoSize" serializeAs="String">
<value>400, 800</value>
</setting>
<setting name="CopyNameToClipboardOnImport" serializeAs="String">
<value>False</value>
</setting>
</ARKBreedingStats.Properties.Settings>
</userSettings>
</configuration>
15 changes: 14 additions & 1 deletion ARKBreedingStats/AsbServer/Connection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Forms.VisualStyles;
using ARKBreedingStats.importExportGun;
using ARKBreedingStats.Library;
Expand Down Expand Up @@ -300,7 +301,7 @@ public static string CreateNewToken()
// use last character as check digit
// checkSum % 15, add 1 (to avoid ambiguous 0), display as hex digit (range [1-9a-f])
token[tokenLength - 1] = ((checkSum % 15) + 1).ToString("x")[0];

return new string(token);
}

Expand All @@ -310,5 +311,17 @@ public static string CreateNewToken()
public static string TokenStringForDisplay(string token) => Properties.Settings.Default.StreamerMode ? "****" : token;

public static bool IsCurrentlyListening => _lastCancellationTokenSource?.IsCancellationRequested == false;

/// <summary>
/// If the token is in the clipboard, remove it from there, when the user is not expecting it to be there.
/// </summary>
public static void ClearTokenFromClipboard()
{
var clipboardText = Clipboard.GetText();
if (!string.IsNullOrEmpty(clipboardText) && clipboardText == Properties.Settings.Default.ExportServerToken)
{
Clipboard.SetText(string.Empty);
}
}
}
}
13 changes: 4 additions & 9 deletions ARKBreedingStats/Form1.exportGun.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,13 @@ private void AsbServerDataSent(ProgressReportAsbServer data)

var addCreature = Properties.Settings.Default.OnAutoImportAddToLibrary;
var gotoLibraryTab = addCreature && Properties.Settings.Default.AutoImportGotoLibraryAfterSuccess;
if (addCreature)
{
DetermineLevelStatusAndSoundFeedback(creature, Properties.Settings.Default.PlaySoundOnAutoImport);

SetNameOfImportedCreature(creature, null, out _,
DetermineLevelStatusAndSoundFeedback(creature, Properties.Settings.Default.PlaySoundOnAutoImport);
SetNameOfImportedCreature(creature, null, out _,
_creatureCollection.creatures.FirstOrDefault(c => c.guid == creature.guid));

if (addCreature)
{
data.TaskNameGenerated?.SetResult(creature.name);

_creatureCollection.MergeCreatureList(new[] { creature }, true);
Expand All @@ -137,11 +137,6 @@ private void AsbServerDataSent(ProgressReportAsbServer data)
else
{
SetCreatureValuesLevelsAndInfoToExtractor(creature);

if (Properties.Settings.Default.PlaySoundOnAutoImport)
{
SoundFeedback.BeepSignalCurrentLevelFlags(IsCreatureAlreadyInLibrary(creature.guid, creature.ArkId, out _));
}
}

if (resultText == null)
Expand Down
6 changes: 3 additions & 3 deletions ARKBreedingStats/Form1.extractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -980,6 +980,7 @@ private void CopyExtractionToClipboard()
/// </summary>
private bool GenerateCreatureNameAndCopyNameToClipboardIfSet(Creature alreadyExistingCreature)
{
var nameWasApplied = false;
if (Properties.Settings.Default.applyNamePatternOnAutoImportAlways
|| (Properties.Settings.Default.applyNamePatternOnImportIfEmptyName
&& string.IsNullOrEmpty(creatureInfoInputExtractor.CreatureName))
Expand All @@ -988,10 +989,9 @@ private bool GenerateCreatureNameAndCopyNameToClipboardIfSet(Creature alreadyExi
)
{
CreatureInfoInput_CreatureDataRequested(creatureInfoInputExtractor, false, false, false, 0, alreadyExistingCreature);
return CopyCreatureNameToClipboardOnImportIfSetting(creatureInfoInputExtractor.CreatureName);
nameWasApplied = true;
}

return false;
return CopyCreatureNameToClipboardOnImportIfSetting(creatureInfoInputExtractor.CreatureName, nameWasApplied);
}

/// <summary>
Expand Down
23 changes: 15 additions & 8 deletions ARKBreedingStats/Form1.importExported.cs
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ private Creature ImportExportedAddIfPossible(string filePath)
private bool SetNameOfImportedCreature(Creature creature, Creature[] creaturesOfSpeciesIn, out Creature[] creaturesOfSpecies, Creature alreadyExistingCreature, int totalCreatureCount = -1)
{
creaturesOfSpecies = creaturesOfSpeciesIn;
var nameWasApplied = false;
if (ShouldNamingPatternBeApplied(creature, alreadyExistingCreature))
{
// don't overwrite existing ASB creature name with empty ingame name
Expand All @@ -338,10 +339,10 @@ private bool SetNameOfImportedCreature(Creature creature, Creature[] creaturesOf
alreadyExistingCreature.name = creature.name; // if alreadyExistingCreature was already updated and creature is not used anymore make sure name is not lost
}

return CopyCreatureNameToClipboardOnImportIfSetting(creature.name);
nameWasApplied = true;
}

return false;
return CopyCreatureNameToClipboardOnImportIfSetting(creature.name, nameWasApplied);
}

/// <summary>
Expand All @@ -357,13 +358,19 @@ private bool ShouldNamingPatternBeApplied(Creature creature, Creature alreadyExi
/// <summary>
/// Copies name to clipboard if the according setting is enabled. Returns true if copied.
/// </summary>
private bool CopyCreatureNameToClipboardOnImportIfSetting(string creatureName)
private bool CopyCreatureNameToClipboardOnImportIfSetting(string creatureName, bool nameWasJustApplied)
{
if (!Properties.Settings.Default.copyNameToClipboardOnImportWhenAutoNameApplied) return false;
Clipboard.SetText(string.IsNullOrEmpty(creatureName)
? "<no name>"
: creatureName);
return true;
if (Properties.Settings.Default.CopyNameToClipboardOnImport
|| (nameWasJustApplied && Properties.Settings.Default.copyNameToClipboardOnImportWhenAutoNameApplied))
{
Clipboard.SetText(string.IsNullOrEmpty(creatureName)
? "<no name>"
: creatureName);
return true;
}

AsbServer.Connection.ClearTokenFromClipboard();
return false;
}

/// <summary>
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.61.0.0")]
[assembly: AssemblyFileVersion("0.61.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 @@ -599,5 +599,8 @@
<Setting Name="OverlayInfoSize" Type="System.Drawing.Size" Scope="User">
<Value Profile="(Default)">400, 800</Value>
</Setting>
<Setting Name="CopyNameToClipboardOnImport" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
</Settings>
</SettingsFile>
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.61.0.0"
"version": "0.61.1.0"
},
"SpeciesColorImages": {
"Id": "SpeciesColorImages",
Expand Down
23 changes: 18 additions & 5 deletions ARKBreedingStats/settings/Settings.Designer.cs

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

2 changes: 2 additions & 0 deletions ARKBreedingStats/settings/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ private void LoadSettings(CreatureCollection cc)
cbApplyNamePatternOnImportOnEmptyNames.Checked = Properties.Settings.Default.applyNamePatternOnImportIfEmptyName;
cbApplyNamePatternOnImportOnNewCreatures.Checked = Properties.Settings.Default.applyNamePatternOnAutoImportForNewCreatures;
cbCopyPatternNameToClipboard.Checked = Properties.Settings.Default.copyNameToClipboardOnImportWhenAutoNameApplied;
CbCopyNameToClipboardOnImport.Checked = Properties.Settings.Default.CopyNameToClipboardOnImport;
cbAutoImportExported.Checked = Properties.Settings.Default.AutoImportExportedCreatures;
CbAutoExtractAddToLibrary.Checked = Properties.Settings.Default.OnAutoImportAddToLibrary;
cbPlaySoundOnAutomaticImport.Checked = Properties.Settings.Default.PlaySoundOnAutoImport;
Expand Down Expand Up @@ -662,6 +663,7 @@ private void SaveSettings()
Properties.Settings.Default.applyNamePatternOnImportIfEmptyName = cbApplyNamePatternOnImportOnEmptyNames.Checked;
Properties.Settings.Default.applyNamePatternOnAutoImportForNewCreatures = cbApplyNamePatternOnImportOnNewCreatures.Checked;
Properties.Settings.Default.copyNameToClipboardOnImportWhenAutoNameApplied = cbCopyPatternNameToClipboard.Checked;
Properties.Settings.Default.CopyNameToClipboardOnImport = CbCopyNameToClipboardOnImport.Checked;
Properties.Settings.Default.AutoImportExportedCreatures = cbAutoImportExported.Checked;
Properties.Settings.Default.OnAutoImportAddToLibrary = CbAutoExtractAddToLibrary.Checked;
Properties.Settings.Default.PlaySoundOnAutoImport = cbPlaySoundOnAutomaticImport.Checked;
Expand Down
27 changes: 0 additions & 27 deletions ARKBreedingStats/settings/Settings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -136,30 +136,6 @@ If you set the according files below, you can start the process automatically fr
<metadata name="aTImportFileLocationBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="dgvFileLocation_Change.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ImportWithQuickImport.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="dgvFileLocation_Delete.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="aTImportFileLocationBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="dgvExportFolderChange.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="dgvExportFolderDelete.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="dgvExportMakeDefault.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="aTExportFolderLocationsBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>262, 17</value>
</metadata>
<metadata name="dgvExportFolderChange.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
Expand Down Expand Up @@ -189,9 +165,6 @@ The window-mode "Fullscreen-Windowed" should be set ingame.</value>
<metadata name="colorDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>526, 17</value>
</metadata>
<metadata name="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>647, 17</value>
</metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>73</value>
</metadata>
Expand Down

0 comments on commit 177d3ed

Please sign in to comment.