From 910b4de8c0802b0cfef212ab34d71ceebbc7c1e7 Mon Sep 17 00:00:00 2001 From: cadon Date: Sun, 11 Sep 2022 01:10:14 +0200 Subject: [PATCH 1/8] fix for creature flags (fixes #1286), thanks vulli321 --- ARKBreedingStats/CreatureInfoInput.cs | 4 ++++ ARKBreedingStats/Form1.collection.cs | 7 +++++++ ARKBreedingStats/library/DummyCreatures.cs | 3 +++ 3 files changed, 14 insertions(+) diff --git a/ARKBreedingStats/CreatureInfoInput.cs b/ARKBreedingStats/CreatureInfoInput.cs index 6fc80b82..94dc1b09 100644 --- a/ARKBreedingStats/CreatureInfoInput.cs +++ b/ARKBreedingStats/CreatureInfoInput.cs @@ -425,6 +425,10 @@ public CreatureFlags CreatureFlags if (CbMutagen.Checked) _creatureFlags |= CreatureFlags.MutagenApplied; else _creatureFlags &= ~CreatureFlags.MutagenApplied; + if (MutationCounterMother > 0 || MutationCounterFather > 0) + _creatureFlags |= CreatureFlags.Mutated; + else _creatureFlags &= ~CreatureFlags.Mutated; + return _creatureFlags; } set diff --git a/ARKBreedingStats/Form1.collection.cs b/ARKBreedingStats/Form1.collection.cs index 9452db53..6a7189e6 100644 --- a/ARKBreedingStats/Form1.collection.cs +++ b/ARKBreedingStats/Form1.collection.cs @@ -532,6 +532,13 @@ private bool LoadCollectionFile(string filePath, bool keepCurrentCreatures = fal // calculate creature values RecalculateAllCreaturesValues(); + foreach (var c in _creatureCollection.creatures) + { + c.InitializeFlags(); + if (c.ArkIdImported && c.ArkIdInGame == null) + c.ArkIdInGame = Utils.ConvertImportedArkIdToIngameVisualization(c.ArkId); + } + if (!keepCurrentSelections && _creatureCollection.creatures.Any()) tabControlMain.SelectedTab = tabPageLibrary; diff --git a/ARKBreedingStats/library/DummyCreatures.cs b/ARKBreedingStats/library/DummyCreatures.cs index 91c29501..de97708a 100644 --- a/ARKBreedingStats/library/DummyCreatures.cs +++ b/ARKBreedingStats/library/DummyCreatures.cs @@ -141,6 +141,8 @@ public static List CreateCreatures(int count, Species species = null, if (setServer) creature.server = $"Server {rand.Next(5) + 1}"; + creature.InitializeFlags(); + creatures.Add(creature); } @@ -310,6 +312,7 @@ private static List BreedCreatures(Creature[] creatures, Species speci creature.RecalculateNewMutations(); creature.RecalculateAncestorGenerations(); + creature.InitializeFlags(); if (noGender) allCreatures.Add(creature); From 8680d6102dbc9ae6bd49929b8e144251805767d1 Mon Sep 17 00:00:00 2001 From: cadon Date: Sun, 11 Sep 2022 20:04:27 +0200 Subject: [PATCH 2/8] naming pattern keywords case insensitive --- ARKBreedingStats/NamePatterns/NamePattern.cs | 27 +++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/ARKBreedingStats/NamePatterns/NamePattern.cs b/ARKBreedingStats/NamePatterns/NamePattern.cs index 9c061e53..aa62d3a1 100644 --- a/ARKBreedingStats/NamePatterns/NamePattern.cs +++ b/ARKBreedingStats/NamePatterns/NamePattern.cs @@ -23,7 +23,6 @@ public static string GenerateCreatureName(Creature creature, Creature[] sameSpec bool showDuplicateNameWarning, int namingPatternIndex, bool showTooLongWarning = true, string pattern = null, bool displayError = true, Dictionary tokenDictionary = null, CreatureCollection.ColorExisting[] colorsExisting = null) { - var creatureNames = sameSpecies?.Where(c => c.guid != creature.guid).Select(x => x.name).ToArray() ?? Array.Empty(); if (pattern == null) { if (namingPatternIndex == -1) @@ -70,6 +69,10 @@ public static string GenerateCreatureName(Creature creature, Creature[] sameSpec ResolveKeysToValues(tokenDictionary, pattern.Replace("\r", string.Empty).Replace("\n", string.Empty)), creature, customReplacings, displayError, false, colorsExisting); + string[] creatureNames = null; + if (showDuplicateNameWarning || name.Contains("{n}")) + creatureNames = sameSpecies?.Where(c => c.guid != creature.guid).Select(x => x.name).ToArray() ?? Array.Empty(); + if (name.Contains("{n}")) { // replace the unique number key with the lowest possible positive number >= 1 to get a unique name. @@ -306,8 +309,8 @@ public static Dictionary CreateTokenDictionary(Creature creature var dict = new Dictionary { { "species", creature.Species.name }, - { "spcsNm", spcsNm }, - { "firstWordOfOldest", firstWordOfOldest }, + { "spcsnm", spcsNm }, + { "firstwordofoldest", firstWordOfOldest }, { "owner", creature.owner }, { "tribe", creature.tribe }, @@ -316,7 +319,7 @@ public static Dictionary CreateTokenDictionary(Creature creature { "sex", creature.sex.ToString() }, { "sex_short", creature.sex.ToString().Substring(0, 1) }, - { "effImp_short", effImpShort}, + { "effimp_short", effImpShort}, { "index", indexStr}, { "oldname", oldName }, { "sex_lang", Loc.S(creature.sex.ToString()) }, @@ -324,9 +327,9 @@ public static Dictionary CreateTokenDictionary(Creature creature { "sex_lang_gen", Loc.S(creature.sex.ToString() + "_gen") }, { "sex_lang_short_gen", Loc.S(creature.sex.ToString() + "_gen").Substring(0, 1) }, - { "topPercent" , (creature.topness / 10f).ToString() }, + { "toppercent" , (creature.topness / 10f).ToString() }, { "baselvl" , creature.LevelHatched.ToString() }, - { "effImp" , effImp }, + { "effimp" , effImp }, { "muta", creature.Mutations.ToString()}, { "mutam", creature.mutationsMaternal.ToString()}, { "mutap", creature.mutationsPaternal.ToString()}, @@ -340,7 +343,7 @@ public static Dictionary CreateTokenDictionary(Creature creature { "sn", speciesSexCount.ToString()}, { "dom", dom}, { "arkid", arkid }, - { "alreadyExists", speciesCreatures.Contains(creature) ? "1" : string.Empty }, + { "alreadyexists", speciesCreatures.Contains(creature) ? "1" : string.Empty }, { "highest1l", levelOrder[0].Item2.ToString() }, { "highest2l", levelOrder[1].Item2.ToString() }, { "highest3l", levelOrder[2].Item2.ToString() }, @@ -359,13 +362,13 @@ public static Dictionary CreateTokenDictionary(Creature creature { dict.Add(StatAbbreviationFromIndex[s], creature.levelsWild[s].ToString()); dict.Add($"{StatAbbreviationFromIndex[s]}_vb", (creature.valuesBreeding[s] * (Utils.Precision(s) == 3 ? 100 : 1)).ToString()); - dict.Add($"isTop{StatAbbreviationFromIndex[s]}", speciesTopLevels == null ? (creature.levelsWild[s] > 0 ? "1" : string.Empty) : + dict.Add($"istop{StatAbbreviationFromIndex[s]}", speciesTopLevels == null ? (creature.levelsWild[s] > 0 ? "1" : string.Empty) : creature.levelsWild[s] >= speciesTopLevels[s] ? "1" : string.Empty); - dict.Add($"isNewTop{StatAbbreviationFromIndex[s]}", speciesTopLevels == null ? (creature.levelsWild[s] > 0 ? "1" : string.Empty) : + dict.Add($"isnewtop{StatAbbreviationFromIndex[s]}", speciesTopLevels == null ? (creature.levelsWild[s] > 0 ? "1" : string.Empty) : creature.levelsWild[s] > speciesTopLevels[s] ? "1" : string.Empty); - dict.Add($"isLowest{StatAbbreviationFromIndex[s]}", speciesLowestLevels == null ? (creature.levelsWild[s] == 0 ? "1" : string.Empty) : + dict.Add($"islowest{StatAbbreviationFromIndex[s]}", speciesLowestLevels == null ? (creature.levelsWild[s] == 0 ? "1" : string.Empty) : speciesLowestLevels[s] != -1 && creature.levelsWild[s] != -1 && creature.levelsWild[s] <= speciesLowestLevels[s] ? "1" : string.Empty); - dict.Add($"isNewLowest{StatAbbreviationFromIndex[s]}", speciesLowestLevels == null ? (creature.levelsWild[s] == 0 ? "1" : string.Empty) : + dict.Add($"isnewlowest{StatAbbreviationFromIndex[s]}", speciesLowestLevels == null ? (creature.levelsWild[s] == 0 ? "1" : string.Empty) : speciesLowestLevels[s] != -1 && creature.levelsWild[s] != -1 && creature.levelsWild[s] < speciesLowestLevels[s] ? "1" : string.Empty); } @@ -405,7 +408,7 @@ private static string ResolveKeysToValues(Dictionary tokenDictio pattern = pattern.Replace("{n}", uniqueNumber.ToString()); } - return r.Replace(pattern, m => tokenDictionary.TryGetValue(m.Groups["key"].Value, out string replacement) ? replacement : m.Value); + return r.Replace(pattern, m => tokenDictionary.TryGetValue(m.Groups["key"].Value.ToLowerInvariant(), out string replacement) ? replacement : m.Value); } } } From b256ee4309b4c8245cbcd64c328af3a0d73a9d40 Mon Sep 17 00:00:00 2001 From: cadon Date: Sun, 18 Sep 2022 13:14:07 +0200 Subject: [PATCH 3/8] library color filter multiregion --- ARKBreedingStats/Form1.library.cs | 24 ++-- ARKBreedingStats/local/strings.de.resx | 3 +- ARKBreedingStats/local/strings.fr.resx | 5 +- ARKBreedingStats/local/strings.ja.resx | 3 +- ARKBreedingStats/local/strings.pl.resx | 3 +- ARKBreedingStats/local/strings.pt-br.resx | 152 ++++++++++------------ ARKBreedingStats/local/strings.resx | 3 +- ARKBreedingStats/local/strings.ru.resx | 3 +- ARKBreedingStats/local/strings.zh-tw.resx | 3 +- 9 files changed, 97 insertions(+), 102 deletions(-) diff --git a/ARKBreedingStats/Form1.library.cs b/ARKBreedingStats/Form1.library.cs index ed5ba1b6..186af542 100644 --- a/ARKBreedingStats/Form1.library.cs +++ b/ARKBreedingStats/Form1.library.cs @@ -14,6 +14,7 @@ using System.Text.RegularExpressions; using ARKBreedingStats.library; using ARKBreedingStats.settings; +using System.Runtime.ConstrainedExecution; namespace ARKBreedingStats { @@ -1311,30 +1312,31 @@ private void FilterLib(bool selectFirstIfNothingIsSelected = false) var statFilterRegex = new Regex(@"(\w{2}) ?(<|>|==) ?(\d+)"); // color filter - var colorFilter = new Dictionary(); - var colorFilterRegex = new Regex(@"c([0-5]): ?([\d ]+)"); + var colorFilterOr = new Dictionary(); // includes creatures that have in one of the regions one of the colors + var colorFilterRegexOr = new Regex(@"c([0-5 ]+): ?([\d ]+)"); // mutation filter var mutationFilterEqualTo = -1; var mutationFilterGreaterThan = -1; var mutationFilterLessThan = -1; - var removeFilterIndex = new List(); + var removeFilterIndex = new List(); // remove all filter entries that are added to specific filter properties + // start at the end, so the removed filter indices are also removed from the end for (var i = filterStrings.Count - 1; i >= 0; i--) { var f = filterStrings[i]; // color region filter - var m = colorFilterRegex.Match(f); + var m = colorFilterRegexOr.Match(f); if (m.Success) { - var colorRegion = int.Parse(m.Groups[1].Value); - if (colorFilter.ContainsKey(colorRegion)) continue; - - var colorIds = m.Groups[2].Value.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(cId => int.Parse(cId)).Distinct().ToArray(); + var colorIds = m.Groups[2].Value.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries) + .Select(int.Parse).Distinct().ToArray(); if (!colorIds.Any()) continue; - colorFilter[colorRegion] = colorIds; + var colorRegions = m.Groups[1].Value.Where(r => r != ' ').Select(r => int.Parse(r.ToString())).ToArray(); + + colorFilterOr[colorRegions] = colorIds; removeFilterIndex.Add(i); continue; } @@ -1382,7 +1384,7 @@ private void FilterLib(bool selectFirstIfNothingIsSelected = false) if (!statGreaterThan.Any()) statGreaterThan = null; if (!statLessThan.Any()) statLessThan = null; if (!statEqualTo.Any()) statEqualTo = null; - if (!colorFilter.Any()) colorFilter = null; + if (!colorFilterOr.Any()) colorFilterOr = null; foreach (var i in removeFilterIndex) filterStrings.RemoveAt(i); @@ -1399,7 +1401,7 @@ private void FilterLib(bool selectFirstIfNothingIsSelected = false) && (statGreaterThan?.All(si => c.levelsWild[si.Key] > si.Value) ?? true) && (statLessThan?.All(si => c.levelsWild[si.Key] < si.Value) ?? true) && (statEqualTo?.All(si => c.levelsWild[si.Key] == si.Value) ?? true) - && (colorFilter?.All(cr => cr.Value.Contains(c.colors[cr.Key])) ?? true) + && (colorFilterOr?.All(colorRegions => colorRegions.Key.Any(colorRegion => colorRegions.Value.Contains(c.colors[colorRegion]))) ?? true) && (mutationFilterGreaterThan == -1 || mutationFilterGreaterThan < c.Mutations) && (mutationFilterLessThan == -1 || mutationFilterLessThan > c.Mutations) && (mutationFilterEqualTo == -1 || mutationFilterEqualTo == c.Mutations) diff --git a/ARKBreedingStats/local/strings.de.resx b/ARKBreedingStats/local/strings.de.resx index 123b1f85..9590615a 100644 --- a/ARKBreedingStats/local/strings.de.resx +++ b/ARKBreedingStats/local/strings.de.resx @@ -1280,7 +1280,8 @@ Ark id im Spiel Server Tags Filter nach Stats mit {englische statAbkürzung} [==|<|>] {Wert}, z.B. hp > 20, st == 35 -Filter nach Farben mit c{Region}: {FarbCode} {FarbCode2}, z.B. c0: 20, c5: 3 4 5 6, c1: 13 14 +Filter nach Farben mit c{Regionen}: {FarbCode} {FarbCode2}, z.B. c0: 20, c5: 3 4 5 6, c1: 13 14 +Es ist auch möglich Tiere mit einer Farbe in mehreren möglichen Regionen zu filtern. Z.B. um alle Tiere mit der Farb-Id 10 oder 20 in irgendeiner Region anzuzeigen nutze: c0 1 2 3 4 5: 10 20 Klicken um Datei im Explorer anzuzeigen diff --git a/ARKBreedingStats/local/strings.fr.resx b/ARKBreedingStats/local/strings.fr.resx index 6f8e8886..9f32a500 100644 --- a/ARKBreedingStats/local/strings.fr.resx +++ b/ARKBreedingStats/local/strings.fr.resx @@ -1286,8 +1286,9 @@ Remarque Ark id dans le jeu Serveur Tags -Filtre pour les stats avec {statAbb} [==|<|>] {value}, par exemple pv > 20, en == 35 -Filtre pour les couleurs avec c{region}: {colorValue} {colorValue2}, par exemple c0: 20, c5: 3 4 5 6, c1: 13 14 +Filtre pour les stats avec {statAbb} [==|&lt;|&gt;] {value}, par exemple pv &gt; 20, en == 35 +Filtre pour les couleurs avec c{region}: {colorValue} {colorValue2}, par exemple c0: 20, c5: 3 4 5 6, c1: 13 14 +It's also possible to filter for creatures with a color in one of multiple possible regions. E.g. to display all creatures with the color 10 or 20 in any region use: c0 1 2 3 4 5: 10 20 Cliquer pour afficher le fichier dans l'explorateur diff --git a/ARKBreedingStats/local/strings.ja.resx b/ARKBreedingStats/local/strings.ja.resx index 09e3f65c..9da6f026 100644 --- a/ARKBreedingStats/local/strings.ja.resx +++ b/ARKBreedingStats/local/strings.ja.resx @@ -1291,7 +1291,8 @@ BabyCuddleIntervallMultiplierとBabyMatureSpeedMultiplierが正しいか確認 サーバ タグ Filter for a stats with {statAbb} [==|<|>] {value}, e.g. hp > 20, st == 35 -Filter for colors with c{region}: {colorValue}, e.g. c0: 20, c5: 3 +Filter for colors with c{regions}: {colorValue} {colorValue2}, e.g. c0: 20, c5: 3 4 5 6, c1: 13 14 +It's also possible to filter for creatures with a color in one of multiple possible regions. E.g. to display all creatures with the color 10 or 20 in any region use: c0 1 2 3 4 5: 10 20 クリックでファイルをエクスプローラーで表示 diff --git a/ARKBreedingStats/local/strings.pl.resx b/ARKBreedingStats/local/strings.pl.resx index 47dcd0d3..be125222 100644 --- a/ARKBreedingStats/local/strings.pl.resx +++ b/ARKBreedingStats/local/strings.pl.resx @@ -1011,7 +1011,8 @@ Identyfikator w grze Serwer Tagi Filter for a stats with {statAbb} [==|<|>] {value}, e.g. hp > 20, st == 35 -Filter for colors with c{region}: {colorValue} {colorValue2}, e.g. c0: 20, c5: 3 4 5 6, c1: 13 14 +Filter for colors with c{regions}: {colorValue} {colorValue2}, e.g. c0: 20, c5: 3 4 5 6, c1: 13 14 +It's also possible to filter for creatures with a color in one of multiple possible regions. E.g. to display all creatures with the color 10 or 20 in any region use: c0 1 2 3 4 5: 10 20 Uwaga: temu zwierzu może zabraknąć jedzenia. Możliwe, że będziesz musiał je nakarmić przed tym czasem, by go nie zagłodzić (sprawdź ekwipunek)! diff --git a/ARKBreedingStats/local/strings.pt-br.resx b/ARKBreedingStats/local/strings.pt-br.resx index 08e555e4..980dc876 100644 --- a/ARKBreedingStats/local/strings.pt-br.resx +++ b/ARKBreedingStats/local/strings.pt-br.resx @@ -150,7 +150,7 @@ Mude o breeding-mode para "Maior Status" para melhores Sugestões. Melhor possível - {0} Melhor possível para essa biblioteca + Melhor possível {0} para essa biblioteca Corpo @@ -1043,30 +1043,6 @@ Alguns descendentes podem ser piores do que no modo de status altos, mas você t Status - - Add Note Adicionar Nota - - - BestPossibleSpeciesLibraryFiltered {0} Melhor possivel para esse filtro - - - Discard changes? Discartar alterações? - - - Discard changes and load file Descartar as alterações e carregar uma nova biblioteca - - - Discard changes and new Descartar as alterações e criar uma nova biblioteca - - - Discard changes and quit Descartar alterações e sair - - - Fortitude Fortitude - - - Fortitude_Abb Fr - Certifique-se de que o BabyCuddleIntervallMultiplier e o BabyMatureSpeedMultiplier estão definidos corretamente. @@ -1079,63 +1055,6 @@ Alguns descendentes podem ser piores do que no modo de status altos, mas você t Se um número com um sinal de mais for mostrado, a soma é muito alta e você precisa escolher outra possibilidade nas listas de status amarelos." - - BtBeepTopTT Este som ira tocar quando o level de uma criatura com top stat, ex. igual ao atual maior nivel da sua biblioteca - - - max wild level Lvl max Selvagem - - - noColor sem cor - - - Nursing Effectiveness Nursing Effectiveness - - - Nursing Effectiveness_Abb NE - - - Remove Note Remover Nota - - - Temperature Temperatura - - - Temperature_Abb Te - - - tsBtAddAsExtractionTest Adic como Teste - - - until até - - - Water Água - - - btUpdateLibraryCreature Atualizar criatura na biblioteca - - - Water_Abb Wa - - - Cancel quitting Cancelar saida - - - Collection changed discard and load? Sua coleção de criaturas foi modificada desde que foi salva pela última vez, tem certeza que deseja descartar as alterações e carregar o arquivo sem salvar primeiro? - - - Collection changed discard and new? Sua coleção de criaturas foi modificada desde que foi salva pela última vez, tem certeza de que deseja descartar as alterações e criar uma nova biblioteca sem salvar? - - - Collection changed discard and quit? Sua coleção de criaturas foi modificada desde que foi salva pela última vez, tem certeza de que deseja descartar as alterações e sair sem salvar? - - - Crafting Speed_Abb Cr - - - CurrentCreature Criatura atual - Idioma do Sistema @@ -1221,7 +1140,8 @@ Ark id no Jogo Servidor Tags Filtrar por status com {statAbb} [==|&lt;|&gt;] {value}, ex. hp &gt; 20, st == 35 -Filtrar por cor com c{region}: {colorValue} {colorValue2}, e.g. c0: 20, c5: 3 4 5 6, c1: 13 14 +Filtrar por cor com c{region}: {colorValue} {colorValue2}, e.g. c0: 20, c5: 3 4 5 6, c1: 13 14 +It's also possible to filter for creatures with a color in one of multiple possible regions. E.g. to display all creatures with the color 10 or 20 in any region use: c0 1 2 3 4 5: 10 20 Top @@ -1334,4 +1254,70 @@ Filtrar por cor com c{region}: {colorValue} {colorValue2}, e.g. c0: 20, c5: 3 4 Agrupar por Especie + + Adicionar Nota + + + Melhor possivel {0} para esse filtro + + + Discartar alterações? + + + Descartar as alterações e carregar uma nova biblioteca + + + Descartar as alterações e criar uma nova biblioteca + + + Descartar alterações e sair + + + Lvl max Selvagem + + + sem cor + + + até + + + Água + + + Wa + + + Cancelar saida + + + Temperatura + + + Te + + + Remover Nota + + + Adic como Teste + + + Atualizar criatura na biblioteca + + + Criatura atual + + + Este som ira tocar quando o level de uma criatura com top stat, ex. igual ao atual maior nivel da sua biblioteca + + + Sua coleção de criaturas foi modificada desde que foi salva pela última vez, tem certeza de que deseja descartar as alterações e sair sem salvar? + + + Sua coleção de criaturas foi modificada desde que foi salva pela última vez, tem certeza de que deseja descartar as alterações e criar uma nova biblioteca sem salvar? + + + Sua coleção de criaturas foi modificada desde que foi salva pela última vez, tem certeza que deseja descartar as alterações e carregar o arquivo sem salvar primeiro? + \ No newline at end of file diff --git a/ARKBreedingStats/local/strings.resx b/ARKBreedingStats/local/strings.resx index 6182dc8d..2e4897ef 100644 --- a/ARKBreedingStats/local/strings.resx +++ b/ARKBreedingStats/local/strings.resx @@ -1289,7 +1289,8 @@ Ark id in game Server Tags Filter for a stats with {statAbb} [==|<|>] {value}, e.g. hp > 20, st == 35 -Filter for colors with c{region}: {colorValue} {colorValue2}, e.g. c0: 20, c5: 3 4 5 6, c1: 13 14 +Filter for colors with c{regions}: {colorValue} {colorValue2}, e.g. c0: 20, c5: 3 4 5 6, c1: 13 14 +It's also possible to filter for creatures with a color in one of multiple possible regions. E.g. to display all creatures with the color 10 or 20 in any region use: c0 1 2 3 4 5: 10 20 Click to show file in explorer diff --git a/ARKBreedingStats/local/strings.ru.resx b/ARKBreedingStats/local/strings.ru.resx index 1172e304..1c6882b0 100644 --- a/ARKBreedingStats/local/strings.ru.resx +++ b/ARKBreedingStats/local/strings.ru.resx @@ -1185,7 +1185,8 @@ Ark id в игре Сервер Теги Filter for a stats with {statAbb} [==|<|>] {value}, e.g. hp > 20, st == 35 -Filter for colors with c{region}: {colorValue} {colorValue2}, e.g. c0: 20, c5: 3 4 5 6, c1: 13 14 +Filter for colors with c{region}: {colorValue} {colorValue2}, e.g. c0: 20, c5: 3 4 5 6, c1: 13 14 +It's also possible to filter for creatures with a color in one of multiple possible regions. E.g. to display all creatures with the color 10 or 20 in any region use: c0 1 2 3 4 5: 10 20 Нажмите, чтобы показать файл в проводнике diff --git a/ARKBreedingStats/local/strings.zh-tw.resx b/ARKBreedingStats/local/strings.zh-tw.resx index 674003f5..fb8cfd7d 100644 --- a/ARKBreedingStats/local/strings.zh-tw.resx +++ b/ARKBreedingStats/local/strings.zh-tw.resx @@ -1206,7 +1206,8 @@ 伺服器 標籤 使用 {屬性簡稱} [==|&lt;|&gt;] {數值} 過濾屬性,例如: HP &gt; 20, 耐 == 35 -使用 c{region} 過濾顏色:{colorValue} {colorValue2},例如: c0: 20, c5: 3 4 5 6, c1: 13 14 +使用 c{region} 過濾顏色:{colorValue} {colorValue2},例如: c0: 20, c5: 3 4 5 6, c1: 13 14 +It's also possible to filter for creatures with a color in one of multiple possible regions. E.g. to display all creatures with the color 10 or 20 in any region use: c0 1 2 3 4 5: 10 20 最大 From 59d072d85d92e569941df07408f132290366c798 Mon Sep 17 00:00:00 2001 From: cadon Date: Wed, 28 Sep 2022 22:22:29 +0200 Subject: [PATCH 4/8] don't warn if asterix is used in savefilepath (#1289) --- ARKBreedingStats/settings/Settings.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ARKBreedingStats/settings/Settings.cs b/ARKBreedingStats/settings/Settings.cs index 52a351df..435da2f3 100644 --- a/ARKBreedingStats/settings/Settings.cs +++ b/ARKBreedingStats/settings/Settings.cs @@ -643,7 +643,7 @@ private void btAddSavegameFileLocation_Click(object sender, EventArgs e) /// private void CheckSaveImportPath(string filePath) { - if (!filePath.EndsWith(".ark")) + if (!filePath.EndsWith(".ark") && !filePath.Contains("*")) { MessageBoxes.ShowMessageBox($"The file location must include the path and the filename of the save file. The set path\n{filePath}\ndoesn't end with \".ark\" and seems to miss the file name.", "Possibly wrong path", MessageBoxIcon.Warning); } From ee6fc719d03bec6622e8de53fb60c8460370a63b Mon Sep 17 00:00:00 2001 From: cadon Date: Sat, 1 Oct 2022 16:14:44 +0200 Subject: [PATCH 5/8] improved newest file selection in ftp-import (closes #1289) --- ARKBreedingStats/Form1.importSave.cs | 98 ++++++++++++++----- .../ATImportFileLocationDialog.Designer.cs | 14 +++ .../settings/ATImportFileLocationDialog.cs | 6 ++ .../settings/FtpProgress.Designer.cs | 15 +-- ARKBreedingStats/settings/FtpProgress.cs | 24 ++--- ARKBreedingStats/settings/Settings.cs | 2 +- 6 files changed, 112 insertions(+), 47 deletions(-) diff --git a/ARKBreedingStats/Form1.importSave.cs b/ARKBreedingStats/Form1.importSave.cs index dc7fe8cf..3370a3e2 100644 --- a/ARKBreedingStats/Form1.importSave.cs +++ b/ARKBreedingStats/Form1.importSave.cs @@ -12,7 +12,6 @@ using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; -using ARKBreedingStats.uiControls; using ARKBreedingStats.utils; namespace ARKBreedingStats @@ -50,18 +49,32 @@ private async Task RunSavegameImport(ATImportFileLocation atImportFileLo workingCopyFolderPath = Path.GetTempPath(); } + var fileLocation = atImportFileLocation.FileLocation; + string uriFileRegex = null; - if (Uri.TryCreate(atImportFileLocation.FileLocation, UriKind.Absolute, out var uri) + var indexLastSlash = fileLocation.LastIndexOf('/'); + if (indexLastSlash > 0) + { + var lastUriSegment = fileLocation.Split('/').Last(); + if (lastUriSegment.Contains("*") || lastUriSegment.Contains("(?<")) + { + fileLocation = fileLocation.Substring(0, indexLastSlash); + uriFileRegex = lastUriSegment; + } + } + + if (Uri.TryCreate(fileLocation, UriKind.Absolute, out var uri) && uri.Scheme != "file") { switch (uri.Scheme) { case "ftp": - workingCopyFilePath = await CopyFtpFileAsync(uri, atImportFileLocation.ConvenientName, + string errorMessage; + (workingCopyFilePath, errorMessage) = await CopyFtpFileAsync(uri, uriFileRegex, atImportFileLocation.ConvenientName, workingCopyFolderPath); - if (workingCopyFilePath == null) + if (errorMessage != null) // the user didn't enter credentials - return "no credentials"; + return errorMessage; break; default: throw new Exception($"Unsupported uri scheme: {uri.Scheme}"); @@ -131,7 +144,7 @@ await ImportSavegame.ImportCollectionFromSavegame(_creatureCollection, workingCo return null; // no error } - private async Task CopyFtpFileAsync(Uri ftpUri, string serverName, string workingCopyFolder) + private async Task<(string filePath, string errorMessage)> CopyFtpFileAsync(Uri ftpUri, string fileRegex, string serverName, string workingCopyFolder) { var credentialsByServerName = LoadSavedCredentials(); credentialsByServerName.TryGetValue(serverName, out var credentials); @@ -150,7 +163,7 @@ private async Task CopyFtpFileAsync(Uri ftpUri, string serverName, strin { if (dialog.ShowDialog(this) == DialogResult.Cancel) { - return null; + return (null, "no credentials given, aborted by user"); } credentials = dialog.Credentials; @@ -164,9 +177,13 @@ private async Task CopyFtpFileAsync(Uri ftpUri, string serverName, strin } } var client = new FtpClient(ftpUri.Host, ftpUri.Port, credentials.Username, credentials.Password); + string ftpPath = null; try { + if (progressDialog.IsDisposed) + return (null, "aborted by user"); + progressDialog.StatusText = $"Authenticating on server {serverName}"; if (!progressDialog.Visible) progressDialog.Show(this); @@ -181,14 +198,15 @@ private async Task CopyFtpFileAsync(Uri ftpUri, string serverName, strin progressDialog.StatusText = "Finding most recent file"; await Task.Yield(); - var ftpPath = ftpUri.AbsolutePath; - var lastSegment = ftpUri.Segments.Last(); - if (lastSegment.Contains("*")) + ftpPath = ftpUri.AbsolutePath; + + if (fileRegex != null) { - var mostRecentlyModifiedMatch = await GetLastModifiedFileAsync(client, ftpUri, cancellationTokenSource.Token); + var mostRecentlyModifiedMatch = + await GetLastModifiedFileAsync(client, ftpUri, fileRegex, cancellationTokenSource.Token); if (mostRecentlyModifiedMatch == null) { - throw new Exception($"No file found matching pattern '{lastSegment}'"); + throw new Exception($"No file found matching pattern '{fileRegex}'"); } ftpPath = mostRecentlyModifiedMatch.FullName; @@ -212,7 +230,7 @@ private async Task CopyFtpFileAsync(Uri ftpUri, string serverName, strin filePath = await DecompressGZippedFileAsync(filePath, cancellationTokenSource.Token); } - return filePath; + return (filePath, null); } catch (FtpAuthenticationException ex) { @@ -224,16 +242,18 @@ private async Task CopyFtpFileAsync(Uri ftpUri, string serverName, strin catch (OperationCanceledException) { client.Dispose(); - return null; + return (null, "aborted by user"); } catch (Exception ex) { + var errorMessage = $"Unexpected error while downloading file\n{ftpPath}:\n{ex.Message}{(string.IsNullOrEmpty(ex.InnerException?.Message) ? null : "\n\nInner Exception:\n" + ex.InnerException?.Message)}"; if (progressDialog.IsDisposed) { client.Dispose(); - return null; + return (null, errorMessage); } - progressDialog.StatusText = $"Unexpected error: {ex.Message}"; + progressDialog.StatusText = errorMessage + "\n\nTrying again in some seconds."; + await Task.Delay(3000); } finally { @@ -282,17 +302,51 @@ private async Task DecompressGZippedFileAsync(string filePath, Cancellat return newFileName; } - public async Task GetLastModifiedFileAsync(FtpClient client, Uri ftpUri, CancellationToken cancellationToken) + public async Task GetLastModifiedFileAsync(FtpClient client, Uri ftpUri, string fileRegex, CancellationToken cancellationToken) { var folderUri = new Uri(ftpUri, "."); var listItems = await client.GetListingAsync(folderUri.AbsolutePath, cancellationToken); - // Turn the wildcard into a regex pattern "super*.foo" -> "^super.*?\.foo$" - var nameRegex = new Regex("^" + Regex.Escape(ftpUri.Segments.Last()).Replace(@"\*", ".*?") + "$"); + Regex fileNameRegex; + if (!fileRegex.Contains("(?<")) + { + // assume only simple wildcard + // Turn the wildcard into a regex pattern "super*.foo" -> "^super.*?\.foo$" + fileNameRegex = new Regex("^" + Regex.Escape(fileRegex).Replace(@"\*", ".*?") + "$"); + + return listItems + .OrderByDescending(x => x.Modified) + .FirstOrDefault(x => fileNameRegex.IsMatch(x.Name)); + } + + fileNameRegex = new Regex(fileRegex); + + // order by named groups descending + var listWithMatches = listItems.Select(f => (ftpFile: f, match: fileNameRegex.Match(f.Name))).Where(f => f.Item2.Success).ToArray(); + + switch (listWithMatches.Length) + { + case 0: return null; + case 1: return listWithMatches[0].ftpFile; + } + + var regexGroupNames = fileNameRegex.GetGroupNames().Where(n => n != "0").OrderBy(n => n).ToArray(); + if (regexGroupNames.Length == 0) + return listWithMatches.First().ftpFile; + + var orderedListWithMatches = + listWithMatches.OrderByDescending(f => f.match.Groups[regexGroupNames[0]].Value); + + for (int g = 1; g < regexGroupNames.Length; g++) + { + var groupName = regexGroupNames[g]; // closure + orderedListWithMatches = + orderedListWithMatches.ThenByDescending(f => f.match.Groups[groupName].Value); + } + + var orderedList = orderedListWithMatches.ToArray(); - return listItems - .OrderByDescending(x => x.Modified) - .FirstOrDefault(x => nameRegex.IsMatch(x.Name)); + return orderedList.First().ftpFile; } /// diff --git a/ARKBreedingStats/settings/ATImportFileLocationDialog.Designer.cs b/ARKBreedingStats/settings/ATImportFileLocationDialog.Designer.cs index 3b6f4dd2..8fed40d9 100644 --- a/ARKBreedingStats/settings/ATImportFileLocationDialog.Designer.cs +++ b/ARKBreedingStats/settings/ATImportFileLocationDialog.Designer.cs @@ -33,6 +33,7 @@ private void InitializeComponent() { this.button_FileSelect = new System.Windows.Forms.Button(); this.button_Cancel = new System.Windows.Forms.Button(); this.button_Ok = new System.Windows.Forms.Button(); + this.LlFtpHelp = new System.Windows.Forms.LinkLabel(); this.SuspendLayout(); // // label_ConvenientName @@ -117,6 +118,17 @@ private void InitializeComponent() { this.button_Ok.Text = "OK"; this.button_Ok.UseVisualStyleBackColor = true; // + // LlFtpHelp + // + this.LlFtpHelp.AutoSize = true; + this.LlFtpHelp.Location = new System.Drawing.Point(12, 128); + this.LlFtpHelp.Name = "LlFtpHelp"; + this.LlFtpHelp.Size = new System.Drawing.Size(164, 13); + this.LlFtpHelp.TabIndex = 9; + this.LlFtpHelp.TabStop = true; + this.LlFtpHelp.Text = "Manual for configuring ftp access"; + this.LlFtpHelp.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.LlFtpHelp_LinkClicked); + // // ATImportFileLocationDialog // this.AcceptButton = this.button_Ok; @@ -124,6 +136,7 @@ private void InitializeComponent() { this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.CancelButton = this.button_Cancel; this.ClientSize = new System.Drawing.Size(448, 158); + this.Controls.Add(this.LlFtpHelp); this.Controls.Add(this.button_Ok); this.Controls.Add(this.button_Cancel); this.Controls.Add(this.button_FileSelect); @@ -158,5 +171,6 @@ private void InitializeComponent() { private System.Windows.Forms.Button button_FileSelect; private System.Windows.Forms.Button button_Cancel; private System.Windows.Forms.Button button_Ok; + private System.Windows.Forms.LinkLabel LlFtpHelp; } } \ No newline at end of file diff --git a/ARKBreedingStats/settings/ATImportFileLocationDialog.cs b/ARKBreedingStats/settings/ATImportFileLocationDialog.cs index f85bb547..5b319e1a 100644 --- a/ARKBreedingStats/settings/ATImportFileLocationDialog.cs +++ b/ARKBreedingStats/settings/ATImportFileLocationDialog.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics; using System.IO; using System.Windows.Forms; using ARKBreedingStats.utils; @@ -58,5 +59,10 @@ private void button_FileSelect_Click(object sender, EventArgs e) } } } + + private void LlFtpHelp_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) + { + RepositoryInfo.OpenWikiPage("Ftp-access"); + } } } diff --git a/ARKBreedingStats/settings/FtpProgress.Designer.cs b/ARKBreedingStats/settings/FtpProgress.Designer.cs index 477acfd1..64e10b73 100644 --- a/ARKBreedingStats/settings/FtpProgress.Designer.cs +++ b/ARKBreedingStats/settings/FtpProgress.Designer.cs @@ -36,7 +36,7 @@ private void InitializeComponent() // this.button_Cancel.Anchor = System.Windows.Forms.AnchorStyles.Bottom; this.button_Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.button_Cancel.Location = new System.Drawing.Point(155, 71); + this.button_Cancel.Location = new System.Drawing.Point(155, 109); this.button_Cancel.Name = "button_Cancel"; this.button_Cancel.Size = new System.Drawing.Size(75, 23); this.button_Cancel.TabIndex = 9; @@ -46,11 +46,12 @@ private void InitializeComponent() // // StatusLabel // - this.StatusLabel.Anchor = System.Windows.Forms.AnchorStyles.Top; + this.StatusLabel.Dock = System.Windows.Forms.DockStyle.Fill; this.StatusLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.StatusLabel.Location = new System.Drawing.Point(12, 9); + this.StatusLabel.Location = new System.Drawing.Point(0, 0); this.StatusLabel.Name = "StatusLabel"; - this.StatusLabel.Size = new System.Drawing.Size(360, 59); + this.StatusLabel.Padding = new System.Windows.Forms.Padding(0, 0, 0, 30); + this.StatusLabel.Size = new System.Drawing.Size(384, 144); this.StatusLabel.TabIndex = 10; this.StatusLabel.Text = "Status Text"; this.StatusLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -60,10 +61,10 @@ private void InitializeComponent() this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.CancelButton = this.button_Cancel; - this.ClientSize = new System.Drawing.Size(384, 106); - this.Controls.Add(this.StatusLabel); + this.ClientSize = new System.Drawing.Size(384, 144); this.Controls.Add(this.button_Cancel); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.Controls.Add(this.StatusLabel); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow; this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "FtpProgressForm"; diff --git a/ARKBreedingStats/settings/FtpProgress.cs b/ARKBreedingStats/settings/FtpProgress.cs index 99716acc..75ebbf22 100644 --- a/ARKBreedingStats/settings/FtpProgress.cs +++ b/ARKBreedingStats/settings/FtpProgress.cs @@ -1,5 +1,4 @@ -using ARKBreedingStats.miscClasses; -using FluentFTP; +using FluentFTP; using System; using System.Diagnostics; using System.Threading; @@ -17,22 +16,16 @@ public FtpProgressForm(CancellationTokenSource cancellationTokenSource) public string StatusText { - get - { - return StatusLabel.Text; - } - set - { - StatusLabel.Text = value; - } + get => StatusLabel.Text; + set => StatusLabel.Text = value; } public string FileName { get; set; } - private Stopwatch stopwatch = new Stopwatch(); + private readonly Stopwatch _stopwatch = new Stopwatch(); public void Report(FtpProgress value) { - if (value.Progress < 100 && stopwatch.IsRunning && stopwatch.ElapsedMilliseconds < 250) + if (value.Progress < 100 && _stopwatch.IsRunning && _stopwatch.ElapsedMilliseconds < 250) { // only update the progress every 250ms unless setting it to 100% return; @@ -40,12 +33,9 @@ public void Report(FtpProgress value) var statusText = $"Downloading {FileName}\r\n{value.Progress:F0}% complete\r\n{value.TransferSpeedToString()}"; StatusLabel.Invoke(new Action(() => StatusLabel.Text = statusText)); - stopwatch.Restart(); + _stopwatch.Restart(); } - private void button_Cancel_Click(object sender, EventArgs e) - { - this.Close(); - } + private void button_Cancel_Click(object sender, EventArgs e) => Close(); } } diff --git a/ARKBreedingStats/settings/Settings.cs b/ARKBreedingStats/settings/Settings.cs index 435da2f3..02c52e54 100644 --- a/ARKBreedingStats/settings/Settings.cs +++ b/ARKBreedingStats/settings/Settings.cs @@ -643,7 +643,7 @@ private void btAddSavegameFileLocation_Click(object sender, EventArgs e) /// private void CheckSaveImportPath(string filePath) { - if (!filePath.EndsWith(".ark") && !filePath.Contains("*")) + if (!filePath.EndsWith(".ark") && !filePath.EndsWith(".gz") && !filePath.Contains("*") && !filePath.Contains("(?<")) { MessageBoxes.ShowMessageBox($"The file location must include the path and the filename of the save file. The set path\n{filePath}\ndoesn't end with \".ark\" and seems to miss the file name.", "Possibly wrong path", MessageBoxIcon.Warning); } From ddc006bf669032294b75eff63b8a7e384655fd89 Mon Sep 17 00:00:00 2001 From: cadon Date: Sun, 2 Oct 2022 21:47:13 +0200 Subject: [PATCH 6/8] multiple label sets for ocr --- ARKBreedingStats/ARKOverlay.cs | 2 +- ARKBreedingStats/Form1.Designer.cs | 99 +++++++---- ARKBreedingStats/Form1.cs | 3 + ARKBreedingStats/Form1.extractor.cs | 34 ++++ ARKBreedingStats/Form1.resx | 6 +- ARKBreedingStats/ocr/ArkOCR.cs | 23 +-- ARKBreedingStats/ocr/OCRControl.Designer.cs | 180 +++++++++++++------- ARKBreedingStats/ocr/OCRControl.cs | 92 ++++++++-- ARKBreedingStats/ocr/OCRTemplate.cs | 130 ++++++++++++-- 9 files changed, 432 insertions(+), 137 deletions(-) diff --git a/ARKBreedingStats/ARKOverlay.cs b/ARKBreedingStats/ARKOverlay.cs index 7d6ccf12..fb9bcdc6 100644 --- a/ARKBreedingStats/ARKOverlay.cs +++ b/ARKBreedingStats/ARKOverlay.cs @@ -78,7 +78,7 @@ public void InitLabelPositions() for (int statIndex = 0; statIndex < _labels.Length; statIndex++) { - Rectangle r = ArkOcr.Ocr.ocrConfig.labelRectangles[statIndex]; + Rectangle r = ArkOcr.Ocr.ocrConfig.UsedLabelRectangles[statIndex]; _labels[statIndex].Location = new Point(r.Left + r.Width + 30, r.Top - 10); } lblStatus.Location = new Point(50, 10); diff --git a/ARKBreedingStats/Form1.Designer.cs b/ARKBreedingStats/Form1.Designer.cs index 5291fb76..2d2328e4 100644 --- a/ARKBreedingStats/Form1.Designer.cs +++ b/ARKBreedingStats/Form1.Designer.cs @@ -337,6 +337,9 @@ private void InitializeComponent() this.ToolStripTextBoxLibraryFilter = new System.Windows.Forms.ToolStripTextBox(); this.ToolStripButtonLibraryFilterClear = new System.Windows.Forms.ToolStripButton(); this.ToolStripButtonSaveFilterPreset = new System.Windows.Forms.ToolStripButton(); + this.TsSpOcrLabel = new System.Windows.Forms.ToolStripSeparator(); + this.TsLbLabelSet = new System.Windows.Forms.ToolStripLabel(); + this.TsCbbLabelSets = new System.Windows.Forms.ToolStripComboBox(); this.panelToolBar = new System.Windows.Forms.Panel(); this.btImportLastExported = new System.Windows.Forms.Button(); this.pbSpecies = new System.Windows.Forms.PictureBox(); @@ -975,7 +978,7 @@ private void InitializeComponent() this.devToolStripMenuItem}); this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Name = "menuStrip1"; - this.menuStrip1.Size = new System.Drawing.Size(1134, 24); + this.menuStrip1.Size = new System.Drawing.Size(1878, 24); this.menuStrip1.TabIndex = 0; this.menuStrip1.Text = "menuStrip1"; // @@ -1455,7 +1458,7 @@ private void InitializeComponent() this.tabControlMain.Location = new System.Drawing.Point(0, 103); this.tabControlMain.Name = "tabControlMain"; this.tabControlMain.SelectedIndex = 1; - this.tabControlMain.Size = new System.Drawing.Size(1134, 775); + this.tabControlMain.Size = new System.Drawing.Size(1878, 775); this.tabControlMain.TabIndex = 3; this.tabControlMain.SelectedIndexChanged += new System.EventHandler(this.tabControl1_SelectedIndexChanged); // @@ -1473,7 +1476,7 @@ private void InitializeComponent() this.tabPageStatTesting.Location = new System.Drawing.Point(4, 22); this.tabPageStatTesting.Name = "tabPageStatTesting"; this.tabPageStatTesting.Padding = new System.Windows.Forms.Padding(3); - this.tabPageStatTesting.Size = new System.Drawing.Size(1126, 749); + this.tabPageStatTesting.Size = new System.Drawing.Size(1870, 749); this.tabPageStatTesting.TabIndex = 1; this.tabPageStatTesting.Text = "Stat Testing"; this.tabPageStatTesting.UseVisualStyleBackColor = true; @@ -1752,7 +1755,7 @@ private void InitializeComponent() this.tabPageExtractor.Location = new System.Drawing.Point(4, 22); this.tabPageExtractor.Name = "tabPageExtractor"; this.tabPageExtractor.Padding = new System.Windows.Forms.Padding(3); - this.tabPageExtractor.Size = new System.Drawing.Size(1126, 749); + this.tabPageExtractor.Size = new System.Drawing.Size(1870, 749); this.tabPageExtractor.TabIndex = 0; this.tabPageExtractor.Text = "Extractor"; this.tabPageExtractor.UseVisualStyleBackColor = true; @@ -2015,7 +2018,7 @@ private void InitializeComponent() this.tabPageLibrary.Location = new System.Drawing.Point(4, 22); this.tabPageLibrary.Name = "tabPageLibrary"; this.tabPageLibrary.Padding = new System.Windows.Forms.Padding(3); - this.tabPageLibrary.Size = new System.Drawing.Size(1126, 749); + this.tabPageLibrary.Size = new System.Drawing.Size(1870, 749); this.tabPageLibrary.TabIndex = 2; this.tabPageLibrary.Text = "Library"; this.tabPageLibrary.UseVisualStyleBackColor = true; @@ -2032,7 +2035,7 @@ private void InitializeComponent() this.tableLayoutPanelLibrary.Name = "tableLayoutPanelLibrary"; this.tableLayoutPanelLibrary.RowCount = 1; this.tableLayoutPanelLibrary.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tableLayoutPanelLibrary.Size = new System.Drawing.Size(1120, 743); + this.tableLayoutPanelLibrary.Size = new System.Drawing.Size(1864, 743); this.tableLayoutPanelLibrary.TabIndex = 4; // // listViewLibrary @@ -2755,7 +2758,7 @@ private void InitializeComponent() this.tabPagePedigree.Location = new System.Drawing.Point(4, 22); this.tabPagePedigree.Name = "tabPagePedigree"; this.tabPagePedigree.Padding = new System.Windows.Forms.Padding(3); - this.tabPagePedigree.Size = new System.Drawing.Size(1126, 749); + this.tabPagePedigree.Size = new System.Drawing.Size(1870, 749); this.tabPagePedigree.TabIndex = 3; this.tabPagePedigree.Text = "Pedigree"; this.tabPagePedigree.UseVisualStyleBackColor = true; @@ -2767,7 +2770,7 @@ private void InitializeComponent() this.pedigree1.LeftColumnWidth = 203; this.pedigree1.Location = new System.Drawing.Point(3, 3); this.pedigree1.Name = "pedigree1"; - this.pedigree1.Size = new System.Drawing.Size(1120, 743); + this.pedigree1.Size = new System.Drawing.Size(1864, 743); this.pedigree1.TabIndex = 0; // // tabPageTaming @@ -2776,7 +2779,7 @@ private void InitializeComponent() this.tabPageTaming.Location = new System.Drawing.Point(4, 22); this.tabPageTaming.Name = "tabPageTaming"; this.tabPageTaming.Padding = new System.Windows.Forms.Padding(3); - this.tabPageTaming.Size = new System.Drawing.Size(1126, 749); + this.tabPageTaming.Size = new System.Drawing.Size(1870, 749); this.tabPageTaming.TabIndex = 8; this.tabPageTaming.Text = "Taming"; this.tabPageTaming.UseVisualStyleBackColor = true; @@ -2787,7 +2790,7 @@ private void InitializeComponent() this.tamingControl1.Dock = System.Windows.Forms.DockStyle.Fill; this.tamingControl1.Location = new System.Drawing.Point(3, 3); this.tamingControl1.Name = "tamingControl1"; - this.tamingControl1.Size = new System.Drawing.Size(1120, 743); + this.tamingControl1.Size = new System.Drawing.Size(1864, 743); this.tamingControl1.TabIndex = 0; this.tamingControl1.WeaponDamages = new double[] { 100D, @@ -2805,7 +2808,7 @@ private void InitializeComponent() this.tabPageBreedingPlan.Location = new System.Drawing.Point(4, 22); this.tabPageBreedingPlan.Name = "tabPageBreedingPlan"; this.tabPageBreedingPlan.Padding = new System.Windows.Forms.Padding(3); - this.tabPageBreedingPlan.Size = new System.Drawing.Size(1126, 749); + this.tabPageBreedingPlan.Size = new System.Drawing.Size(1870, 749); this.tabPageBreedingPlan.TabIndex = 4; this.tabPageBreedingPlan.Text = "Breeding Plan"; this.tabPageBreedingPlan.UseVisualStyleBackColor = true; @@ -2818,7 +2821,7 @@ private void InitializeComponent() this.breedingPlan1.Location = new System.Drawing.Point(3, 3); this.breedingPlan1.MutationLimit = 0; this.breedingPlan1.Name = "breedingPlan1"; - this.breedingPlan1.Size = new System.Drawing.Size(1120, 743); + this.breedingPlan1.Size = new System.Drawing.Size(1864, 743); this.breedingPlan1.TabIndex = 0; // // tabPageHatching @@ -2827,7 +2830,7 @@ private void InitializeComponent() this.tabPageHatching.Location = new System.Drawing.Point(4, 22); this.tabPageHatching.Name = "tabPageHatching"; this.tabPageHatching.Padding = new System.Windows.Forms.Padding(3); - this.tabPageHatching.Size = new System.Drawing.Size(1126, 749); + this.tabPageHatching.Size = new System.Drawing.Size(1870, 749); this.tabPageHatching.TabIndex = 13; this.tabPageHatching.Text = "Hatching"; this.tabPageHatching.UseVisualStyleBackColor = true; @@ -2837,7 +2840,7 @@ private void InitializeComponent() this.hatching1.Dock = System.Windows.Forms.DockStyle.Fill; this.hatching1.Location = new System.Drawing.Point(3, 3); this.hatching1.Name = "hatching1"; - this.hatching1.Size = new System.Drawing.Size(1120, 743); + this.hatching1.Size = new System.Drawing.Size(1864, 743); this.hatching1.TabIndex = 0; // // tabPageRaising @@ -2846,7 +2849,7 @@ private void InitializeComponent() this.tabPageRaising.Location = new System.Drawing.Point(4, 22); this.tabPageRaising.Name = "tabPageRaising"; this.tabPageRaising.Padding = new System.Windows.Forms.Padding(3); - this.tabPageRaising.Size = new System.Drawing.Size(1126, 749); + this.tabPageRaising.Size = new System.Drawing.Size(1870, 749); this.tabPageRaising.TabIndex = 9; this.tabPageRaising.Text = "Raising"; this.tabPageRaising.UseVisualStyleBackColor = true; @@ -2857,7 +2860,7 @@ private void InitializeComponent() this.raisingControl1.Dock = System.Windows.Forms.DockStyle.Fill; this.raisingControl1.Location = new System.Drawing.Point(3, 3); this.raisingControl1.Name = "raisingControl1"; - this.raisingControl1.Size = new System.Drawing.Size(1120, 743); + this.raisingControl1.Size = new System.Drawing.Size(1864, 743); this.raisingControl1.TabIndex = 0; // // tabPageTimer @@ -2866,7 +2869,7 @@ private void InitializeComponent() this.tabPageTimer.Location = new System.Drawing.Point(4, 22); this.tabPageTimer.Name = "tabPageTimer"; this.tabPageTimer.Padding = new System.Windows.Forms.Padding(3); - this.tabPageTimer.Size = new System.Drawing.Size(1126, 749); + this.tabPageTimer.Size = new System.Drawing.Size(1870, 749); this.tabPageTimer.TabIndex = 6; this.tabPageTimer.Text = "Timer"; this.tabPageTimer.UseVisualStyleBackColor = true; @@ -2876,7 +2879,7 @@ private void InitializeComponent() this.timerList1.Dock = System.Windows.Forms.DockStyle.Fill; this.timerList1.Location = new System.Drawing.Point(3, 3); this.timerList1.Name = "timerList1"; - this.timerList1.Size = new System.Drawing.Size(1120, 743); + this.timerList1.Size = new System.Drawing.Size(1864, 743); this.timerList1.TabIndex = 0; this.timerList1.TimerAlertsCSV = ""; // @@ -2886,7 +2889,7 @@ private void InitializeComponent() this.tabPagePlayerTribes.Location = new System.Drawing.Point(4, 22); this.tabPagePlayerTribes.Name = "tabPagePlayerTribes"; this.tabPagePlayerTribes.Padding = new System.Windows.Forms.Padding(3); - this.tabPagePlayerTribes.Size = new System.Drawing.Size(1126, 749); + this.tabPagePlayerTribes.Size = new System.Drawing.Size(1870, 749); this.tabPagePlayerTribes.TabIndex = 7; this.tabPagePlayerTribes.Text = "Player"; this.tabPagePlayerTribes.UseVisualStyleBackColor = true; @@ -2896,7 +2899,7 @@ private void InitializeComponent() this.tribesControl1.Dock = System.Windows.Forms.DockStyle.Fill; this.tribesControl1.Location = new System.Drawing.Point(3, 3); this.tribesControl1.Name = "tribesControl1"; - this.tribesControl1.Size = new System.Drawing.Size(1120, 743); + this.tribesControl1.Size = new System.Drawing.Size(1864, 743); this.tribesControl1.TabIndex = 0; // // tabPageNotes @@ -2905,7 +2908,7 @@ private void InitializeComponent() this.tabPageNotes.Location = new System.Drawing.Point(4, 22); this.tabPageNotes.Name = "tabPageNotes"; this.tabPageNotes.Padding = new System.Windows.Forms.Padding(3); - this.tabPageNotes.Size = new System.Drawing.Size(1126, 749); + this.tabPageNotes.Size = new System.Drawing.Size(1870, 749); this.tabPageNotes.TabIndex = 10; this.tabPageNotes.Text = "Notes"; this.tabPageNotes.UseVisualStyleBackColor = true; @@ -2915,7 +2918,7 @@ private void InitializeComponent() this.notesControl1.Dock = System.Windows.Forms.DockStyle.Fill; this.notesControl1.Location = new System.Drawing.Point(3, 3); this.notesControl1.Name = "notesControl1"; - this.notesControl1.Size = new System.Drawing.Size(1120, 743); + this.notesControl1.Size = new System.Drawing.Size(1864, 743); this.notesControl1.TabIndex = 0; // // TabPageOCR @@ -2924,7 +2927,7 @@ private void InitializeComponent() this.TabPageOCR.Location = new System.Drawing.Point(4, 22); this.TabPageOCR.Name = "TabPageOCR"; this.TabPageOCR.Padding = new System.Windows.Forms.Padding(3); - this.TabPageOCR.Size = new System.Drawing.Size(1126, 749); + this.TabPageOCR.Size = new System.Drawing.Size(1870, 749); this.TabPageOCR.TabIndex = 5; this.TabPageOCR.Text = "Experimental OCR"; this.TabPageOCR.UseVisualStyleBackColor = true; @@ -2934,7 +2937,7 @@ private void InitializeComponent() this.ocrControl1.Dock = System.Windows.Forms.DockStyle.Fill; this.ocrControl1.Location = new System.Drawing.Point(3, 3); this.ocrControl1.Name = "ocrControl1"; - this.ocrControl1.Size = new System.Drawing.Size(1120, 743); + this.ocrControl1.Size = new System.Drawing.Size(1864, 743); this.ocrControl1.TabIndex = 2; // // tabPageExtractionTests @@ -2943,7 +2946,7 @@ private void InitializeComponent() this.tabPageExtractionTests.Location = new System.Drawing.Point(4, 22); this.tabPageExtractionTests.Name = "tabPageExtractionTests"; this.tabPageExtractionTests.Padding = new System.Windows.Forms.Padding(3); - this.tabPageExtractionTests.Size = new System.Drawing.Size(1126, 749); + this.tabPageExtractionTests.Size = new System.Drawing.Size(1870, 749); this.tabPageExtractionTests.TabIndex = 11; this.tabPageExtractionTests.Text = "Extraction Tests"; this.tabPageExtractionTests.UseVisualStyleBackColor = true; @@ -2953,7 +2956,7 @@ private void InitializeComponent() this.extractionTestControl1.Dock = System.Windows.Forms.DockStyle.Fill; this.extractionTestControl1.Location = new System.Drawing.Point(3, 3); this.extractionTestControl1.Name = "extractionTestControl1"; - this.extractionTestControl1.Size = new System.Drawing.Size(1120, 743); + this.extractionTestControl1.Size = new System.Drawing.Size(1864, 743); this.extractionTestControl1.TabIndex = 0; // // tabPageMultiplierTesting @@ -2962,7 +2965,7 @@ private void InitializeComponent() this.tabPageMultiplierTesting.Location = new System.Drawing.Point(4, 22); this.tabPageMultiplierTesting.Name = "tabPageMultiplierTesting"; this.tabPageMultiplierTesting.Padding = new System.Windows.Forms.Padding(3); - this.tabPageMultiplierTesting.Size = new System.Drawing.Size(1126, 749); + this.tabPageMultiplierTesting.Size = new System.Drawing.Size(1870, 749); this.tabPageMultiplierTesting.TabIndex = 12; this.tabPageMultiplierTesting.Text = "Multiplier Testing"; this.tabPageMultiplierTesting.UseVisualStyleBackColor = true; @@ -2972,7 +2975,7 @@ private void InitializeComponent() this.statsMultiplierTesting1.Dock = System.Windows.Forms.DockStyle.Fill; this.statsMultiplierTesting1.Location = new System.Drawing.Point(3, 3); this.statsMultiplierTesting1.Name = "statsMultiplierTesting1"; - this.statsMultiplierTesting1.Size = new System.Drawing.Size(1120, 743); + this.statsMultiplierTesting1.Size = new System.Drawing.Size(1864, 743); this.statsMultiplierTesting1.TabIndex = 0; // // btReadValuesFromArk @@ -3004,7 +3007,7 @@ private void InitializeComponent() this.ToolStripStatusLabelImport}); this.statusStrip1.Location = new System.Drawing.Point(0, 878); this.statusStrip1.Name = "statusStrip1"; - this.statusStrip1.Size = new System.Drawing.Size(1134, 22); + this.statusStrip1.Size = new System.Drawing.Size(1878, 22); this.statusStrip1.TabIndex = 44; this.statusStrip1.Text = "statusStrip1"; // @@ -3055,10 +3058,13 @@ private void InitializeComponent() this.ToolStripLabelFilter, this.ToolStripTextBoxLibraryFilter, this.ToolStripButtonLibraryFilterClear, - this.ToolStripButtonSaveFilterPreset}); + this.ToolStripButtonSaveFilterPreset, + this.TsSpOcrLabel, + this.TsLbLabelSet, + this.TsCbbLabelSets}); this.toolStrip2.Location = new System.Drawing.Point(0, 24); this.toolStrip2.Name = "toolStrip2"; - this.toolStrip2.Size = new System.Drawing.Size(1134, 25); + this.toolStrip2.Size = new System.Drawing.Size(1878, 25); this.toolStrip2.TabIndex = 1; this.toolStrip2.Text = "toolStrip2"; // @@ -3288,6 +3294,24 @@ private void InitializeComponent() this.ToolStripButtonSaveFilterPreset.Visible = false; this.ToolStripButtonSaveFilterPreset.Click += new System.EventHandler(this.ToolStripButtonSaveFilterPresetClick); // + // TsSpOcrLabel + // + this.TsSpOcrLabel.Name = "TsSpOcrLabel"; + this.TsSpOcrLabel.Size = new System.Drawing.Size(6, 25); + // + // TsLbLabelSet + // + this.TsLbLabelSet.Name = "TsLbLabelSet"; + this.TsLbLabelSet.Size = new System.Drawing.Size(77, 22); + this.TsLbLabelSet.Text = "OCR label set"; + // + // TsCbbLabelSets + // + this.TsCbbLabelSets.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.TsCbbLabelSets.Name = "TsCbbLabelSets"; + this.TsCbbLabelSets.Size = new System.Drawing.Size(121, 25); + this.TsCbbLabelSets.SelectedIndexChanged += new System.EventHandler(this.TsCbbLabelSets_SelectedIndexChanged); + // // panelToolBar // this.panelToolBar.Controls.Add(this.btReadValuesFromArk); @@ -3303,7 +3327,7 @@ private void InitializeComponent() this.panelToolBar.Dock = System.Windows.Forms.DockStyle.Top; this.panelToolBar.Location = new System.Drawing.Point(0, 49); this.panelToolBar.Name = "panelToolBar"; - this.panelToolBar.Size = new System.Drawing.Size(1134, 54); + this.panelToolBar.Size = new System.Drawing.Size(1878, 54); this.panelToolBar.TabIndex = 2; // // btImportLastExported @@ -3353,7 +3377,7 @@ private void InitializeComponent() this.cbToggleOverlay.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.cbToggleOverlay.Appearance = System.Windows.Forms.Appearance.Button; this.cbToggleOverlay.AutoSize = true; - this.cbToggleOverlay.Location = new System.Drawing.Point(1069, 28); + this.cbToggleOverlay.Location = new System.Drawing.Point(1813, 28); this.cbToggleOverlay.Name = "cbToggleOverlay"; this.cbToggleOverlay.Size = new System.Drawing.Size(53, 23); this.cbToggleOverlay.TabIndex = 7; @@ -3367,7 +3391,7 @@ private void InitializeComponent() this.lbListening.AutoSize = true; this.lbListening.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lbListening.ForeColor = System.Drawing.SystemColors.GrayText; - this.lbListening.Location = new System.Drawing.Point(1101, 3); + this.lbListening.Location = new System.Drawing.Point(1845, 3); this.lbListening.Name = "lbListening"; this.lbListening.Size = new System.Drawing.Size(25, 20); this.lbListening.TabIndex = 6; @@ -3412,7 +3436,7 @@ private void InitializeComponent() this.speciesSelector1.LastSpecies = new string[0]; this.speciesSelector1.Location = new System.Drawing.Point(0, 103); this.speciesSelector1.Name = "speciesSelector1"; - this.speciesSelector1.Size = new System.Drawing.Size(1134, 775); + this.speciesSelector1.Size = new System.Drawing.Size(1878, 775); this.speciesSelector1.SplitterDistance = 500; this.speciesSelector1.TabIndex = 0; // @@ -3422,7 +3446,7 @@ private void InitializeComponent() this.AllowDrop = true; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(1134, 900); + this.ClientSize = new System.Drawing.Size(1878, 900); this.Controls.Add(this.tabControlMain); this.Controls.Add(this.speciesSelector1); this.Controls.Add(this.panelToolBar); @@ -3836,5 +3860,8 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripMenuItem colorDefinitionsToClipboardToolStripMenuItem; private System.Windows.Forms.ToolStripSeparator toolStripSeparator26; private System.Windows.Forms.ToolStripMenuItem applyChangedSortingToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator TsSpOcrLabel; + private System.Windows.Forms.ToolStripLabel TsLbLabelSet; + private System.Windows.Forms.ToolStripComboBox TsCbbLabelSets; } } diff --git a/ARKBreedingStats/Form1.cs b/ARKBreedingStats/Form1.cs index 8007a7bc..085c5b6c 100644 --- a/ARKBreedingStats/Form1.cs +++ b/ARKBreedingStats/Form1.cs @@ -176,6 +176,8 @@ public Form1() ArkOcr.Ocr.SetOcrControl(ocrControl1); ocrControl1.UpdateWhiteThreshold += OcrUpdateWhiteThreshold; ocrControl1.DoOcr += DoOcr; + ocrControl1.OcrLabelSetsChanged += InitializeOcrLabelSets; + ocrControl1.OcrLabelSelectedSetChanged += SetCurrentOcrLabelSet; openSettingsToolStripMenuItem.ShortcutKeyDisplayString = new KeysConverter() .ConvertTo(Keys.Control, typeof(string))?.ToString().Replace("None", ","); @@ -325,6 +327,7 @@ private void Form1_Load(object sender, EventArgs e) // OCR ocrControl1.Initialize(); cbGuessSpecies.Checked = Properties.Settings.Default.OcrGuessSpecies; + InitializeOcrLabelSets(); // initialize speech recognition if enabled InitializeSpeechRecognition(); diff --git a/ARKBreedingStats/Form1.extractor.cs b/ARKBreedingStats/Form1.extractor.cs index d9c98213..35b79d67 100644 --- a/ARKBreedingStats/Form1.extractor.cs +++ b/ARKBreedingStats/Form1.extractor.cs @@ -10,6 +10,7 @@ using System.Threading; using System.Windows.Forms; using ARKBreedingStats.utils; +using ARKBreedingStats.ocr; namespace ARKBreedingStats { @@ -1150,5 +1151,38 @@ private void LbBlueprintPath_Click(object sender, EventArgs e) && !string.IsNullOrEmpty(bp)) Clipboard.SetText(bp); } + + #region OCR label sets + + private void InitializeOcrLabelSets() + { + TsCbbLabelSets.Items.Clear(); + var labelSetNames = ArkOcr.Ocr.ocrConfig?.LabelRectangles?.Keys.ToArray(); + var displayControl = (labelSetNames?.Length ?? 0) > 1; + + TsCbbLabelSets.Visible = displayControl; + TsLbLabelSet.Visible = displayControl; + TsSpOcrLabel.Visible = displayControl; + + if (!displayControl) + return; + + TsCbbLabelSets.Items.AddRange(labelSetNames); + TsCbbLabelSets.SelectedItem = ArkOcr.Ocr.ocrConfig.SelectedLabelSetName; + } + + private void SetCurrentOcrLabelSet() + { + TsCbbLabelSets.SelectedItem = ArkOcr.Ocr.ocrConfig.SelectedLabelSetName; + } + + private void TsCbbLabelSets_SelectedIndexChanged(object sender, EventArgs e) + { + if (ArkOcr.Ocr.ocrConfig == null) return; + ArkOcr.Ocr.ocrConfig.SetLabelSet(((ToolStripComboBox)sender).SelectedItem.ToString()); + ocrControl1.SetOcrLabelSetToCurrent(); + } + + #endregion } } diff --git a/ARKBreedingStats/Form1.resx b/ARKBreedingStats/Form1.resx index c404f61a..1241c003 100644 --- a/ARKBreedingStats/Form1.resx +++ b/ARKBreedingStats/Form1.resx @@ -129,7 +129,7 @@ The TE can differ 0.1% due to ingame-rounding. iVBORw0KGgoAAAANSUhEUgAAAGQAAAAyCAYAAACqNX6+AAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO - wQAADsEBuJFr7QAACDpJREFUeF7tWX9slOUdf3AkVocTN/7ossVgYlznjMFNLL01GzFu8Z85M8jSKTka + vQAADr0BR/uQrQAACDpJREFUeF7tWX9slOUdf3AkVocTN/7ossVgYlznjMFNLL01GzFu8Z85M8jSKTka rICWUX5bqNy6gsMB0pq48aMy/3FjIwtmgwsNw9SMLXS4ecgEpVavqUKr5frDg7Z34H32+dzdM98dveu1 9Mi4vp/mm+f98dz7vO/383x/1rhw4eIq4luUfYnD/8J5TcdIkRcpUygucoBsCHHeFxEiZF78zMW4Y7SE CA9RRIqLHGC0hLgWkmNI4akxQuIkJPXeOoqLHGG0FuIix3AJ+T+DS0iOoCBrfXwrpZKSDa6UkLGum9eQ @@ -170,7 +170,7 @@ The TE can differ 0.1% due to ingame-rounding. iVBORw0KGgoAAAANSUhEUgAAAGQAAAAyCAYAAACqNX6+AAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO - wQAADsEBuJFr7QAACDpJREFUeF7tWX9slOUdf3AkVocTN/7ossVgYlznjMFNLL01GzFu8Z85M8jSKTka + vQAADr0BR/uQrQAACDpJREFUeF7tWX9slOUdf3AkVocTN/7ossVgYlznjMFNLL01GzFu8Z85M8jSKTka rICWUX5bqNy6gsMB0pq48aMy/3FjIwtmgwsNw9SMLXS4ecgEpVavqUKr5frDg7Z34H32+dzdM98dveu1 9Mi4vp/mm+f98dz7vO/383x/1rhw4eIq4luUfYnD/8J5TcdIkRcpUygucoBsCHHeFxEiZF78zMW4Y7SE CA9RRIqLHGC0hLgWkmNI4akxQuIkJPXeOoqLHGG0FuIix3AJ+T+DS0iOoCBrfXwrpZKSDa6UkLGum9eQ @@ -245,7 +245,7 @@ It's recommended to first create a backup file of you library. iVBORw0KGgoAAAANSUhEUgAAAGQAAAAyCAYAAACqNX6+AAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO - wQAADsEBuJFr7QAACDpJREFUeF7tWX9slOUdf3AkVocTN/7ossVgYlznjMFNLL01GzFu8Z85M8jSKTka + vQAADr0BR/uQrQAACDpJREFUeF7tWX9slOUdf3AkVocTN/7ossVgYlznjMFNLL01GzFu8Z85M8jSKTka rICWUX5bqNy6gsMB0pq48aMy/3FjIwtmgwsNw9SMLXS4ecgEpVavqUKr5frDg7Z34H32+dzdM98dveu1 9Mi4vp/mm+f98dz7vO/383x/1rhw4eIq4luUfYnD/8J5TcdIkRcpUygucoBsCHHeFxEiZF78zMW4Y7SE CA9RRIqLHGC0hLgWkmNI4akxQuIkJPXeOoqLHGG0FuIix3AJ+T+DS0iOoCBrfXwrpZKSDa6UkLGum9eQ diff --git a/ARKBreedingStats/ocr/ArkOCR.cs b/ARKBreedingStats/ocr/ArkOCR.cs index 45d7c8a7..098101ff 100644 --- a/ARKBreedingStats/ocr/ArkOCR.cs +++ b/ARKBreedingStats/ocr/ArkOCR.cs @@ -314,24 +314,25 @@ public double[] DoOcr(out string OcrText, out string dinoName, out string specie tribeName = string.Empty; sex = Sex.Unknown; double[] finalValues = { 0 }; - if (ocrConfig?.labelRectangles == null) + if (ocrConfig?.UsedLabelRectangles == null) { OcrText = "Error: OCR not configured.\nYou can configure the OCR in the OCR-tab by loading or creating an OCR config-file.\nFor more details see the online manual."; ProcessScreenshot(out _); return finalValues; } - bool labelsValid = true; - foreach (var rect in ocrConfig.labelRectangles) + // check if there is at least one rectangle not empty + bool oneLabelNotEmpty = false; + foreach (var rect in ocrConfig.UsedLabelRectangles) { - if (rect.IsEmpty) + if (!rect.IsEmpty) { - labelsValid = false; + oneLabelNotEmpty = true; break; } } - if (!labelsValid) + if (!oneLabelNotEmpty) { OcrText = "Error: The rectangles where to read the text in the image with OCR are not configured.\nYou can configure them by navigating to the OCR-tab then to the Labels tab.\nFor more details see the online manual."; ProcessScreenshot(out _); @@ -447,7 +448,7 @@ Bitmap ProcessScreenshot(out string errorText) return bmp; } - finalValues = new double[ocrConfig.labelRectangles.Length]; + finalValues = new double[ocrConfig.UsedLabelRectangles.Length]; finalValues[8] = -1; // set imprinting to -1 to mark it as unknown and to set a difference to a creature with 0% imprinting. if (changeForegroundWindow) @@ -494,11 +495,13 @@ Bitmap ProcessScreenshot(out string errorText) break; } - Rectangle rec = ocrConfig.labelRectangles[lbI]; + Rectangle rec = ocrConfig.UsedLabelRectangles[lbI]; + if (rec.IsEmpty) + continue; // wild creatures don't have the xp-bar, all stats are moved one row up if (wild && stI < 9) - rec.Offset(0, ocrConfig.labelRectangles[0].Top - ocrConfig.labelRectangles[1].Top); + rec.Offset(0, ocrConfig.UsedLabelRectangles[0].Top - ocrConfig.UsedLabelRectangles[1].Top); Bitmap testbmp = SubImage(screenShotBmp, rec.X, rec.Y, rec.Width, rec.Height); //AddBitmapToDebug(testbmp); @@ -741,7 +744,7 @@ public bool IsDinoInventoryVisible() return false; const OcrTemplate.OcrLabels label = OcrTemplate.OcrLabels.Level; - Rectangle rec = ocrConfig.labelRectangles[(int)label]; + Rectangle rec = ocrConfig.UsedLabelRectangles[(int)label]; Bitmap bmp = SubImage(screenshotBmp, rec.X, rec.Y, rec.Width, rec.Height); string statOCR = PatternOcr.ReadImageOcr(bmp, true, Properties.Settings.Default.OCRWhiteThreshold); diff --git a/ARKBreedingStats/ocr/OCRControl.Designer.cs b/ARKBreedingStats/ocr/OCRControl.Designer.cs index 90db472a..10c2c9e4 100644 --- a/ARKBreedingStats/ocr/OCRControl.Designer.cs +++ b/ARKBreedingStats/ocr/OCRControl.Designer.cs @@ -35,6 +35,11 @@ private void InitializeComponent() this.OCRDebugLayoutPanel = new System.Windows.Forms.FlowLayoutPanel(); this.tabControlManage = new System.Windows.Forms.TabControl(); this.tabPage1 = new System.Windows.Forms.TabPage(); + this.groupBox11 = new System.Windows.Forms.GroupBox(); + this.LbReplacingsFileStatus = new System.Windows.Forms.Label(); + this.BtReplacingLoadFile = new System.Windows.Forms.Button(); + this.BtReplacingOpenFile = new System.Windows.Forms.Button(); + this.label18 = new System.Windows.Forms.Label(); this.LlOcrManual = new System.Windows.Forms.LinkLabel(); this.groupBox6 = new System.Windows.Forms.GroupBox(); this.BtNewOcrConfig = new System.Windows.Forms.Button(); @@ -99,11 +104,11 @@ private void InitializeComponent() this.label4 = new System.Windows.Forms.Label(); this.groupBox3 = new System.Windows.Forms.GroupBox(); this.listBoxLabelRectangles = new System.Windows.Forms.ListBox(); - this.groupBox11 = new System.Windows.Forms.GroupBox(); - this.label18 = new System.Windows.Forms.Label(); - this.BtReplacingOpenFile = new System.Windows.Forms.Button(); - this.BtReplacingLoadFile = new System.Windows.Forms.Button(); - this.LbReplacingsFileStatus = new System.Windows.Forms.Label(); + this.CbbLabelSets = new System.Windows.Forms.ComboBox(); + this.BtNewLabelSet = new System.Windows.Forms.Button(); + this.BtDeleteLabelSet = new System.Windows.Forms.Button(); + this.groupBox12 = new System.Windows.Forms.GroupBox(); + this.TbLabelSetName = new System.Windows.Forms.TextBox(); this.ocrLetterEditTemplate = new ARKBreedingStats.ocr.OCRLetterEdit(); this.ocrLetterEditRecognized = new ARKBreedingStats.ocr.OCRLetterEdit(); this.nudResolutionHeight = new ARKBreedingStats.uiControls.Nud(); @@ -119,6 +124,7 @@ private void InitializeComponent() this.tableLayoutPanel4.SuspendLayout(); this.tabControlManage.SuspendLayout(); this.tabPage1.SuspendLayout(); + this.groupBox11.SuspendLayout(); this.groupBox6.SuspendLayout(); this.tabPage2.SuspendLayout(); this.groupBox1.SuspendLayout(); @@ -133,7 +139,7 @@ private void InitializeComponent() this.tabPage3.SuspendLayout(); this.groupBox4.SuspendLayout(); this.groupBox3.SuspendLayout(); - this.groupBox11.SuspendLayout(); + this.groupBox12.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.ocrLetterEditTemplate)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.ocrLetterEditRecognized)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nudResolutionHeight)).BeginInit(); @@ -204,6 +210,55 @@ private void InitializeComponent() this.tabPage1.Text = "OCR Info"; this.tabPage1.UseVisualStyleBackColor = true; // + // groupBox11 + // + this.groupBox11.Controls.Add(this.LbReplacingsFileStatus); + this.groupBox11.Controls.Add(this.BtReplacingLoadFile); + this.groupBox11.Controls.Add(this.BtReplacingOpenFile); + this.groupBox11.Controls.Add(this.label18); + this.groupBox11.Location = new System.Drawing.Point(6, 420); + this.groupBox11.Name = "groupBox11"; + this.groupBox11.Size = new System.Drawing.Size(337, 185); + this.groupBox11.TabIndex = 3; + this.groupBox11.TabStop = false; + this.groupBox11.Text = "Manual corrections"; + // + // LbReplacingsFileStatus + // + this.LbReplacingsFileStatus.AutoSize = true; + this.LbReplacingsFileStatus.Location = new System.Drawing.Point(6, 157); + this.LbReplacingsFileStatus.Name = "LbReplacingsFileStatus"; + this.LbReplacingsFileStatus.Size = new System.Drawing.Size(0, 13); + this.LbReplacingsFileStatus.TabIndex = 3; + // + // BtReplacingLoadFile + // + this.BtReplacingLoadFile.Location = new System.Drawing.Point(87, 128); + this.BtReplacingLoadFile.Name = "BtReplacingLoadFile"; + this.BtReplacingLoadFile.Size = new System.Drawing.Size(113, 23); + this.BtReplacingLoadFile.TabIndex = 2; + this.BtReplacingLoadFile.Text = "Load replacings"; + this.BtReplacingLoadFile.UseVisualStyleBackColor = true; + this.BtReplacingLoadFile.Click += new System.EventHandler(this.BtReplacingLoadFile_Click); + // + // BtReplacingOpenFile + // + this.BtReplacingOpenFile.Location = new System.Drawing.Point(6, 128); + this.BtReplacingOpenFile.Name = "BtReplacingOpenFile"; + this.BtReplacingOpenFile.Size = new System.Drawing.Size(75, 23); + this.BtReplacingOpenFile.TabIndex = 1; + this.BtReplacingOpenFile.Text = "Open file"; + this.BtReplacingOpenFile.UseVisualStyleBackColor = true; + this.BtReplacingOpenFile.Click += new System.EventHandler(this.BtReplacingOpenFile_Click); + // + // label18 + // + this.label18.Location = new System.Drawing.Point(6, 16); + this.label18.Name = "label18"; + this.label18.Size = new System.Drawing.Size(325, 109); + this.label18.TabIndex = 0; + this.label18.Text = resources.GetString("label18.Text"); + // // LlOcrManual // this.LlOcrManual.AutoSize = true; @@ -759,6 +814,10 @@ private void InitializeComponent() // tabPage3 // this.tabPage3.AutoScroll = true; + this.tabPage3.Controls.Add(this.groupBox12); + this.tabPage3.Controls.Add(this.BtDeleteLabelSet); + this.tabPage3.Controls.Add(this.BtNewLabelSet); + this.tabPage3.Controls.Add(this.CbbLabelSets); this.tabPage3.Controls.Add(this.groupBox4); this.tabPage3.Controls.Add(this.groupBox3); this.tabPage3.Location = new System.Drawing.Point(4, 22); @@ -786,7 +845,7 @@ private void InitializeComponent() this.groupBox4.Controls.Add(this.nudY); this.groupBox4.Controls.Add(this.label4); this.groupBox4.Controls.Add(this.nudX); - this.groupBox4.Location = new System.Drawing.Point(6, 275); + this.groupBox4.Location = new System.Drawing.Point(6, 355); this.groupBox4.Name = "groupBox4"; this.groupBox4.Size = new System.Drawing.Size(293, 214); this.groupBox4.TabIndex = 1; @@ -879,7 +938,7 @@ private void InitializeComponent() // groupBox3 // this.groupBox3.Controls.Add(this.listBoxLabelRectangles); - this.groupBox3.Location = new System.Drawing.Point(6, 6); + this.groupBox3.Location = new System.Drawing.Point(6, 86); this.groupBox3.Name = "groupBox3"; this.groupBox3.Size = new System.Drawing.Size(221, 263); this.groupBox3.TabIndex = 0; @@ -895,54 +954,52 @@ private void InitializeComponent() this.listBoxLabelRectangles.TabIndex = 0; this.listBoxLabelRectangles.SelectedIndexChanged += new System.EventHandler(this.listBoxLabelRectangles_SelectedIndexChanged); // - // groupBox11 - // - this.groupBox11.Controls.Add(this.LbReplacingsFileStatus); - this.groupBox11.Controls.Add(this.BtReplacingLoadFile); - this.groupBox11.Controls.Add(this.BtReplacingOpenFile); - this.groupBox11.Controls.Add(this.label18); - this.groupBox11.Location = new System.Drawing.Point(6, 420); - this.groupBox11.Name = "groupBox11"; - this.groupBox11.Size = new System.Drawing.Size(337, 185); - this.groupBox11.TabIndex = 3; - this.groupBox11.TabStop = false; - this.groupBox11.Text = "Manual corrections"; - // - // label18 - // - this.label18.Location = new System.Drawing.Point(6, 16); - this.label18.Name = "label18"; - this.label18.Size = new System.Drawing.Size(325, 109); - this.label18.TabIndex = 0; - this.label18.Text = resources.GetString("label18.Text"); - // - // BtReplacingOpenFile - // - this.BtReplacingOpenFile.Location = new System.Drawing.Point(6, 128); - this.BtReplacingOpenFile.Name = "BtReplacingOpenFile"; - this.BtReplacingOpenFile.Size = new System.Drawing.Size(75, 23); - this.BtReplacingOpenFile.TabIndex = 1; - this.BtReplacingOpenFile.Text = "Open file"; - this.BtReplacingOpenFile.UseVisualStyleBackColor = true; - this.BtReplacingOpenFile.Click += new System.EventHandler(this.BtReplacingOpenFile_Click); - // - // BtReplacingLoadFile - // - this.BtReplacingLoadFile.Location = new System.Drawing.Point(87, 128); - this.BtReplacingLoadFile.Name = "BtReplacingLoadFile"; - this.BtReplacingLoadFile.Size = new System.Drawing.Size(113, 23); - this.BtReplacingLoadFile.TabIndex = 2; - this.BtReplacingLoadFile.Text = "Load replacings"; - this.BtReplacingLoadFile.UseVisualStyleBackColor = true; - this.BtReplacingLoadFile.Click += new System.EventHandler(this.BtReplacingLoadFile_Click); - // - // LbReplacingsFileStatus - // - this.LbReplacingsFileStatus.AutoSize = true; - this.LbReplacingsFileStatus.Location = new System.Drawing.Point(6, 157); - this.LbReplacingsFileStatus.Name = "LbReplacingsFileStatus"; - this.LbReplacingsFileStatus.Size = new System.Drawing.Size(0, 13); - this.LbReplacingsFileStatus.TabIndex = 3; + // CbbLabelSets + // + this.CbbLabelSets.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.CbbLabelSets.Location = new System.Drawing.Point(6, 8); + this.CbbLabelSets.Name = "CbbLabelSets"; + this.CbbLabelSets.Size = new System.Drawing.Size(202, 21); + this.CbbLabelSets.TabIndex = 2; + this.CbbLabelSets.SelectedIndexChanged += new System.EventHandler(this.CbbLabelSets_SelectedIndexChanged); + // + // BtNewLabelSet + // + this.BtNewLabelSet.Location = new System.Drawing.Point(214, 6); + this.BtNewLabelSet.Name = "BtNewLabelSet"; + this.BtNewLabelSet.Size = new System.Drawing.Size(57, 23); + this.BtNewLabelSet.TabIndex = 3; + this.BtNewLabelSet.Text = "new"; + this.BtNewLabelSet.UseVisualStyleBackColor = true; + this.BtNewLabelSet.Click += new System.EventHandler(this.BtNewLabelSet_Click); + // + // BtDeleteLabelSet + // + this.BtDeleteLabelSet.Location = new System.Drawing.Point(277, 6); + this.BtDeleteLabelSet.Name = "BtDeleteLabelSet"; + this.BtDeleteLabelSet.Size = new System.Drawing.Size(63, 23); + this.BtDeleteLabelSet.TabIndex = 4; + this.BtDeleteLabelSet.Text = "delete"; + this.BtDeleteLabelSet.UseVisualStyleBackColor = true; + this.BtDeleteLabelSet.Click += new System.EventHandler(this.BtDeleteLabelSet_Click); + // + // groupBox12 + // + this.groupBox12.Controls.Add(this.TbLabelSetName); + this.groupBox12.Location = new System.Drawing.Point(6, 35); + this.groupBox12.Name = "groupBox12"; + this.groupBox12.Size = new System.Drawing.Size(334, 45); + this.groupBox12.TabIndex = 5; + this.groupBox12.TabStop = false; + this.groupBox12.Text = "Label set name"; + // + // TbLabelSetName + // + this.TbLabelSetName.Location = new System.Drawing.Point(6, 19); + this.TbLabelSetName.Name = "TbLabelSetName"; + this.TbLabelSetName.Size = new System.Drawing.Size(322, 20); + this.TbLabelSetName.TabIndex = 0; + this.TbLabelSetName.Leave += new System.EventHandler(this.TbLabelSetName_Leave); // // ocrLetterEditTemplate // @@ -1175,6 +1232,8 @@ private void InitializeComponent() this.tabControlManage.ResumeLayout(false); this.tabPage1.ResumeLayout(false); this.tabPage1.PerformLayout(); + this.groupBox11.ResumeLayout(false); + this.groupBox11.PerformLayout(); this.groupBox6.ResumeLayout(false); this.tabPage2.ResumeLayout(false); this.tabPage2.PerformLayout(); @@ -1196,8 +1255,8 @@ private void InitializeComponent() this.groupBox4.ResumeLayout(false); this.groupBox4.PerformLayout(); this.groupBox3.ResumeLayout(false); - this.groupBox11.ResumeLayout(false); - this.groupBox11.PerformLayout(); + this.groupBox12.ResumeLayout(false); + this.groupBox12.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.ocrLetterEditTemplate)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.ocrLetterEditRecognized)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.nudResolutionHeight)).EndInit(); @@ -1301,5 +1360,10 @@ private void InitializeComponent() private System.Windows.Forms.Button BtReplacingLoadFile; private System.Windows.Forms.Button BtReplacingOpenFile; private System.Windows.Forms.Label label18; + private System.Windows.Forms.GroupBox groupBox12; + private System.Windows.Forms.TextBox TbLabelSetName; + private System.Windows.Forms.Button BtDeleteLabelSet; + private System.Windows.Forms.Button BtNewLabelSet; + private System.Windows.Forms.ComboBox CbbLabelSets; } } diff --git a/ARKBreedingStats/ocr/OCRControl.cs b/ARKBreedingStats/ocr/OCRControl.cs index 94467445..e2501124 100644 --- a/ARKBreedingStats/ocr/OCRControl.cs +++ b/ARKBreedingStats/ocr/OCRControl.cs @@ -231,9 +231,9 @@ private void listBoxLabelRectangles_SelectedIndexChanged(object sender, EventArg private void SetLabelControls(int rectangleIndex) { - if (rectangleIndex < 0 || rectangleIndex >= ArkOcr.Ocr.ocrConfig.labelRectangles.Length) return; + if (rectangleIndex < 0 || rectangleIndex >= ArkOcr.Ocr.ocrConfig.UsedLabelRectangles.Length) return; - Rectangle rec = ArkOcr.Ocr.ocrConfig.labelRectangles[rectangleIndex]; + Rectangle rec = ArkOcr.Ocr.ocrConfig.UsedLabelRectangles[rectangleIndex]; _ignoreValueChange = true; nudX.Value = rec.X; nudY.Value = rec.Y; @@ -313,9 +313,9 @@ private void RedrawScreenshot(int highlightIndex = -1, bool showLabels = true, i } else { - for (int r = 0; r < ArkOcr.Ocr.ocrConfig.labelRectangles.Length; r++) + for (int r = 0; r < ArkOcr.Ocr.ocrConfig.UsedLabelRectangles.Length; r++) { - var rec = ArkOcr.Ocr.ocrConfig.labelRectangles[r]; + var rec = ArkOcr.Ocr.ocrConfig.UsedLabelRectangles[r]; rec.Inflate(2, 2); g.DrawRectangle(r == highlightIndex ? penY : penW, rec); rec.Inflate(2, 2); @@ -325,7 +325,7 @@ private void RedrawScreenshot(int highlightIndex = -1, bool showLabels = true, i } var magnifiedRectangle = highlightIndex != -1 - ? ArkOcr.Ocr.ocrConfig.labelRectangles[highlightIndex] + ? ArkOcr.Ocr.ocrConfig.UsedLabelRectangles[highlightIndex] : !manualRectangle.IsEmpty ? manualRectangle : Rectangle.Empty; @@ -493,16 +493,16 @@ private void UpdateRectangle() { if (!_updateDrawing) return; int i = listBoxLabelRectangles.SelectedIndex; - if (i >= 0 && i < ArkOcr.Ocr.ocrConfig.labelRectangles.Length) + if (i >= 0 && i < ArkOcr.Ocr.ocrConfig.UsedLabelRectangles.Length) { // set all stat-labels if wanted if (chkbSetAllStatLabels.Checked && i < 9) { for (int s = 0; s < 9; s++) if (i != s) - ArkOcr.Ocr.ocrConfig.labelRectangles[s] = new Rectangle((int)nudX.Value, ArkOcr.Ocr.ocrConfig.labelRectangles[s].Y, (int)nudWidth.Value, (int)nudHeight.Value); + ArkOcr.Ocr.ocrConfig.UsedLabelRectangles[s] = new Rectangle((int)nudX.Value, ArkOcr.Ocr.ocrConfig.UsedLabelRectangles[s].Y, (int)nudWidth.Value, (int)nudHeight.Value); } - ArkOcr.Ocr.ocrConfig.labelRectangles[i] = new Rectangle((int)nudX.Value, (int)nudY.Value, (int)nudWidth.Value, (int)nudHeight.Value); + ArkOcr.Ocr.ocrConfig.UsedLabelRectangles[i] = new Rectangle((int)nudX.Value, (int)nudY.Value, (int)nudWidth.Value, (int)nudHeight.Value); _redrawingDebouncer.Debounce(100, RedrawScreenshot, Dispatcher.CurrentDispatcher, (i, true, -1, Rectangle.Empty)); } @@ -583,6 +583,7 @@ private void btUnloadOCR_Click(object sender, EventArgs e) { Properties.Settings.Default.ocrFile = null; ArkOcr.Ocr.ocrConfig = null; + InitializeComboboxLabelSetNames(); UpdateOcrLabel(); } @@ -615,6 +616,7 @@ private bool LoadAndInitializeOcrTemplate(string filePath) UpdateOcrLabel(filePath); if (loadedOcrConfig == null) return false; + InitializeComboboxLabelSetNames(); InitLabelEntries(); nudResizing.Value = ArkOcr.Ocr.ocrConfig.resize == 0 ? 1 : (decimal)ArkOcr.Ocr.ocrConfig.resize; CbTrainRecognition.Checked = ArkOcr.Ocr.ocrConfig.RecognitionPatterns.TrainingSettings.IsTrainingEnabled; @@ -682,15 +684,15 @@ private void buttonLoadCalibrationImage_Click(object sender, EventArgs e) // get font sizes from label heights var fontSizesChars = new Dictionary(4) { - {ArkOcr.Ocr.ocrConfig.labelRectangles[10].Height, textChars} // name, species + {ArkOcr.Ocr.ocrConfig.UsedLabelRectangles[10].Height, textChars} // name, species }; - if (!fontSizesChars.ContainsKey(ArkOcr.Ocr.ocrConfig.labelRectangles[0].Height)) - fontSizesChars.Add(ArkOcr.Ocr.ocrConfig.labelRectangles[0].Height, statValueChars); // stats - if (!fontSizesChars.ContainsKey(ArkOcr.Ocr.ocrConfig.labelRectangles[9].Height)) - fontSizesChars.Add(ArkOcr.Ocr.ocrConfig.labelRectangles[9].Height, levelChars); // level - if (!fontSizesChars.ContainsKey(ArkOcr.Ocr.ocrConfig.labelRectangles[11].Height)) - fontSizesChars.Add(ArkOcr.Ocr.ocrConfig.labelRectangles[11].Height, textChars); // owner + if (!fontSizesChars.ContainsKey(ArkOcr.Ocr.ocrConfig.UsedLabelRectangles[0].Height)) + fontSizesChars.Add(ArkOcr.Ocr.ocrConfig.UsedLabelRectangles[0].Height, statValueChars); // stats + if (!fontSizesChars.ContainsKey(ArkOcr.Ocr.ocrConfig.UsedLabelRectangles[9].Height)) + fontSizesChars.Add(ArkOcr.Ocr.ocrConfig.UsedLabelRectangles[9].Height, levelChars); // level + if (!fontSizesChars.ContainsKey(ArkOcr.Ocr.ocrConfig.UsedLabelRectangles[11].Height)) + fontSizesChars.Add(ArkOcr.Ocr.ocrConfig.UsedLabelRectangles[11].Height, textChars); // owner string fontFilePath = null; foreach (var c in fontSizesChars) @@ -926,7 +928,7 @@ private void labelOCRFile_Click(object sender, EventArgs e) private void BtSetStatPositionBasedOnFirstTwo_Click(object sender, EventArgs e) { - var rectangles = ArkOcr.Ocr.ocrConfig.labelRectangles; + var rectangles = ArkOcr.Ocr.ocrConfig.UsedLabelRectangles; int y = rectangles[0].Y; int yDiff = rectangles[1].Y - y; if (yDiff < 0) return; @@ -999,5 +1001,63 @@ private void BtReplacingLoadFile_Click(object sender, EventArgs e) ArkOcr.Ocr.LoadReplacingsFile(); LbReplacingsFileStatus.Text = ArkOcr.Ocr.RegexReplacingsStatus; } + + #region OCR label sets + + public event Action OcrLabelSetsChanged; + public event Action OcrLabelSelectedSetChanged; + + private void BtNewLabelSet_Click(object sender, EventArgs e) + { + if (ArkOcr.Ocr.ocrConfig == null) return; + ArkOcr.Ocr.ocrConfig.SetLabelSet(ArkOcr.Ocr.ocrConfig.NewLabelSet()); + InitializeComboboxLabelSetNames(); + } + + private void BtDeleteLabelSet_Click(object sender, EventArgs e) + { + if (ArkOcr.Ocr.ocrConfig == null) return; + ArkOcr.Ocr.ocrConfig.DeleteCurrentLabelSet(); + InitializeComboboxLabelSetNames(); + } + + private void TbLabelSetName_Leave(object sender, EventArgs e) + { + if (ArkOcr.Ocr.ocrConfig == null) return; + + if (ArkOcr.Ocr.ocrConfig.LabelSetChangeName(TbLabelSetName.Text, out var errorMessage)) + InitializeComboboxLabelSetNames(); + if (!string.IsNullOrEmpty(errorMessage)) + MessageBoxes.ShowMessageBox(errorMessage, "Label set name change error"); + } + + private void InitializeComboboxLabelSetNames() + { + CbbLabelSets.Items.Clear(); + OcrLabelSetsChanged?.Invoke(); + if (ArkOcr.Ocr.ocrConfig == null) + { + TbLabelSetName.Text = string.Empty; + return; + } + CbbLabelSets.Items.AddRange(ArkOcr.Ocr.ocrConfig.LabelRectangles.Keys.ToArray()); + CbbLabelSets.SelectedItem = ArkOcr.Ocr.ocrConfig.SelectedLabelSetName; + } + + private void CbbLabelSets_SelectedIndexChanged(object sender, EventArgs e) + { + if (ArkOcr.Ocr.ocrConfig == null) return; + ArkOcr.Ocr.ocrConfig.SetLabelSet(((ComboBox)sender).SelectedItem.ToString()); + TbLabelSetName.Text = ArkOcr.Ocr.ocrConfig.SelectedLabelSetName; + RedrawScreenshot(); + OcrLabelSelectedSetChanged?.Invoke(); + } + + public void SetOcrLabelSetToCurrent() + { + CbbLabelSets.SelectedItem = ArkOcr.Ocr.ocrConfig.SelectedLabelSetName; + } + + #endregion } } diff --git a/ARKBreedingStats/ocr/OCRTemplate.cs b/ARKBreedingStats/ocr/OCRTemplate.cs index 2f9b8173..20b73bff 100644 --- a/ARKBreedingStats/ocr/OCRTemplate.cs +++ b/ARKBreedingStats/ocr/OCRTemplate.cs @@ -34,27 +34,32 @@ public class OcrTemplate /// /// Contains all the patterns of all the recognizable strings. /// - [JsonProperty] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] public RecognitionPatterns RecognitionPatterns; + /// + /// Coordinates of the rectangles to read. Kept for backwards compatibility, now uses LabelRectangles. + /// [JsonProperty] public Rectangle[] labelRectangles; + /// + /// Coordinates of the rectangles to read. Multiple sets. + /// + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public Dictionary LabelRectangles; - //public Dictionary labelNameIndices; // TODO remove - //public List labelNames; // TODO remove - - public List> reducedIndices = new List>(); // indices of letters for reduced set (only [0-9\.,/%:]) - - //#region Old file format properties, kept for backwards compatibility + /// + /// Currently used label coordinates. + /// + public Rectangle[] UsedLabelRectangles; - //[JsonProperty] - //public List> letterArrays; - //[JsonProperty] - //public List> letters; + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public string SelectedLabelSetName; - //#endregion + public const string DefaultLabelsName = "default"; + public List> reducedIndices = new List>(); // indices of letters for reduced set (only [0-9\.,/%:]) public OcrTemplate() { @@ -65,7 +70,27 @@ public OcrTemplate() public void InitializeOcrTemplate() { if (RecognitionPatterns == null) RecognitionPatterns = new RecognitionPatterns(); - if (labelRectangles == null) labelRectangles = new Rectangle[Enum.GetValues(typeof(OcrLabels)).Length]; + if (LabelRectangles == null) LabelRectangles = new Dictionary(); + + if (labelRectangles != null) + { + if (!LabelRectangles.ContainsKey(DefaultLabelsName)) + LabelRectangles[DefaultLabelsName] = labelRectangles; + labelRectangles = null; + } + + if (string.IsNullOrEmpty(SelectedLabelSetName) || + !LabelRectangles.TryGetValue(SelectedLabelSetName, out var currentRecSet)) + { + if (!LabelRectangles.ContainsKey(DefaultLabelsName)) + LabelRectangles[DefaultLabelsName] = EmptyLabelSet; + UsedLabelRectangles = LabelRectangles[DefaultLabelsName]; + SelectedLabelSetName = DefaultLabelsName; + } + else + { + UsedLabelRectangles = currentRecSet; + } var currentVersion = new Version(CurrentVersion); if (Version == null || Version.Major < currentVersion.Major) @@ -121,5 +146,84 @@ public enum OcrLabels { Health, Stamina, Oxygen, Food, Weight, MeleeDamage, MovementSpeed, Torpidity, Imprinting, Level, NameSpecies, Tribe, Owner } + + private Rectangle[] EmptyLabelSet => new Rectangle[Enum.GetValues(typeof(OcrLabels)).Length]; + + public void SetLabelSet(string setName) + { + if (string.IsNullOrEmpty(setName) + || SelectedLabelSetName == setName) return; + + SelectedLabelSetName = setName; + if (LabelRectangles.TryGetValue(setName, out var set)) + { + UsedLabelRectangles = set; + } + else + { + UsedLabelRectangles = EmptyLabelSet; + LabelRectangles[setName] = UsedLabelRectangles; + } + } + + public void DeleteLabelSet(string setName) + { + if (string.IsNullOrEmpty(setName)) return; + + LabelRectangles.Remove(setName); + if (setName == SelectedLabelSetName) + { + SelectedLabelSetName = DefaultLabelsName; + if (LabelRectangles.TryGetValue(SelectedLabelSetName, out var currentRecSet)) + { + UsedLabelRectangles = currentRecSet; + } + else + { + UsedLabelRectangles = EmptyLabelSet; + LabelRectangles[SelectedLabelSetName] = UsedLabelRectangles; + } + } + } + + public string NewLabelSet() + { + var newSetNameBase = "new label set"; + string newSetName = newSetNameBase; + int suffix = 1; + while (LabelRectangles.ContainsKey(newSetName)) + { + newSetName = newSetNameBase + " " + (++suffix); + } + + LabelRectangles[newSetName] = EmptyLabelSet; + return newSetName; + } + + public void DeleteCurrentLabelSet() + { + DeleteLabelSet(SelectedLabelSetName); + } + + /// + /// Changes the name of the currently selected set. Returns true if the name was changed. + /// + public bool LabelSetChangeName(string newName, out string errorMessage) + { + errorMessage = null; + if (string.IsNullOrEmpty(newName) + || newName == SelectedLabelSetName) return false; + + if (LabelRectangles.ContainsKey(newName)) + { + errorMessage = "new name is already used by another set"; + return false; + } + + LabelRectangles[newName] = UsedLabelRectangles; + LabelRectangles.Remove(SelectedLabelSetName); + SelectedLabelSetName = newName; + return true; + } } } From 816ee5a9c56fcf634c0c9c81b0b52ca3db995b51 Mon Sep 17 00:00:00 2001 From: cadon Date: Sun, 2 Oct 2022 22:13:47 +0200 Subject: [PATCH 7/8] enable timer only if needed --- ARKBreedingStats/Form1.collection.cs | 1 - ARKBreedingStats/Form1.cs | 10 ++++++++-- ARKBreedingStats/TimerControl.cs | 17 ++++++++++++----- ARKBreedingStats/raising/RaisingControl.cs | 8 ++++++++ 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/ARKBreedingStats/Form1.collection.cs b/ARKBreedingStats/Form1.collection.cs index 6a7189e6..568f16a8 100644 --- a/ARKBreedingStats/Form1.collection.cs +++ b/ARKBreedingStats/Form1.collection.cs @@ -14,7 +14,6 @@ using System.Xml.Serialization; using ARKBreedingStats.uiControls; using ARKBreedingStats.utils; -using System.Diagnostics; namespace ARKBreedingStats { diff --git a/ARKBreedingStats/Form1.cs b/ARKBreedingStats/Form1.cs index 085c5b6c..2e37a8d3 100644 --- a/ARKBreedingStats/Form1.cs +++ b/ARKBreedingStats/Form1.cs @@ -151,12 +151,14 @@ public Form1() creatureInfoInputExtractor.SetMessageLabelText += SetMessageLabelText; creatureInfoInputTester.SetMessageLabelText += SetMessageLabelText; timerList1.OnTimerChange += SetCollectionChanged; + timerList1.TimerAddedRemoved += EnableGlobalTimerIfNeeded; breedingPlan1.BindChildrenControlEvents(); raisingControl1.onChange += SetCollectionChanged; tamingControl1.CreateTimer += CreateTimer; raisingControl1.ExtractBaby += ExtractBaby; raisingControl1.SetGlobalSpecies += SetSpecies; raisingControl1.timerControl = timerList1; + raisingControl1.TimerAddedRemoved += EnableGlobalTimerIfNeeded; notesControl1.changed += SetCollectionChanged; creatureInfoInputExtractor.CreatureDataRequested += CreatureInfoInput_CreatureDataRequested; creatureInfoInputTester.CreatureDataRequested += CreatureInfoInput_CreatureDataRequested; @@ -449,8 +451,6 @@ private void Form1_Load(object sender, EventArgs e) SetupExportFileWatcher(); timerList1.SetTimerPresets(Properties.Settings.Default.TimerPresets); - - _timerGlobal.Start(); } /// @@ -2724,6 +2724,12 @@ private void CreateIncubationTimer(Creature mother, Creature father, TimeSpan in _libraryNeedsUpdate = true; // because mating-cooldown of mother was set } + private void EnableGlobalTimerIfNeeded() + { + _timerGlobal.Enabled = timerList1.TimerIsNeeded + || raisingControl1.TimerIsNeeded; + } + private void TimerGlobal_Tick(object sender, EventArgs e) { timerList1.Tick(); diff --git a/ARKBreedingStats/TimerControl.cs b/ARKBreedingStats/TimerControl.cs index f1d1bf45..14baa16d 100644 --- a/ARKBreedingStats/TimerControl.cs +++ b/ARKBreedingStats/TimerControl.cs @@ -21,6 +21,7 @@ public partial class TimerControl : UserControl public bool updateTimer; private List timerListEntries; public event Form1.CollectionChangedEventHandler OnTimerChange; + public event Action TimerAddedRemoved; private List creatures; public SoundPlayer[] sounds; /// @@ -31,7 +32,7 @@ public partial class TimerControl : UserControl public TimerControl() { - this.Load += TimerControl_Load; + Load += TimerControl_Load; InitializeComponent(); sounds = new SoundPlayer[4]; timerAlerts = new List(); @@ -63,8 +64,6 @@ public TimerControl() groupBox1.Controls.Add(bta); i++; } - - } private void TimerControl_Load(object sender, EventArgs e) @@ -107,6 +106,7 @@ public void AddTimer(string name, DateTime finishTime, Creature creature = null, listViewTimer.Items.Insert(i, tle.lvi); timerListEntries.Add(tle); OnTimerChange?.Invoke(); + TimerAddedRemoved?.Invoke(); RefreshOverlayTimers(); } @@ -114,8 +114,9 @@ private void RemoveTimer(TimerListEntry timerEntry, bool invokeChange = true) { timerEntry.lvi.Remove(); timerListEntries.Remove(timerEntry); - if (invokeChange) - OnTimerChange?.Invoke(); + if (!invokeChange) return; + OnTimerChange?.Invoke(); + TimerAddedRemoved?.Invoke(); } private ListViewItem CreateLvi(string name, TimerListEntry tle) @@ -143,6 +144,8 @@ private ListViewItem CreateLvi(string name, TimerListEntry tle) return lvi; } + public bool TimerIsNeeded => timerListEntries?.Any() == true; + public void Tick() { if (timerListEntries == null || !timerListEntries.Any()) return; @@ -312,6 +315,7 @@ private void RemoveSelectedEntry() RefreshOverlayTimers(); OnTimerChange?.Invoke(); + TimerAddedRemoved?.Invoke(); } } @@ -418,7 +422,10 @@ internal void DeleteAllExpiredTimers(bool confirm = true, bool triggerLibraryCha RefreshOverlayTimers(); if (triggerLibraryChange && timerRemoved) + { OnTimerChange?.Invoke(); + TimerAddedRemoved?.Invoke(); + } } } diff --git a/ARKBreedingStats/raising/RaisingControl.cs b/ARKBreedingStats/raising/RaisingControl.cs index e4b7d115..936de593 100644 --- a/ARKBreedingStats/raising/RaisingControl.cs +++ b/ARKBreedingStats/raising/RaisingControl.cs @@ -18,6 +18,7 @@ public partial class RaisingControl : UserControl public event Form1.CollectionChangedEventHandler onChange; public event Action AdjustTimersByOffset; public event Action SetGlobalSpecies; + public event Action TimerAddedRemoved; private Species _selectedSpecies; public bool updateListView; private TimeSpan _babyTime; @@ -258,6 +259,7 @@ public void AddIncubationTimer(Creature mother, Creature father, TimeSpan incuba _cc.incubationListEntries.Add( new IncubationTimerEntry(mother, father, incubationDuration, incubationStarted)); onChange?.Invoke(); + TimerAddedRemoved?.Invoke(); RecreateList(); } @@ -364,8 +366,11 @@ public void RecreateList() listViewBabies.EndUpdate(); updateListView = true; + TimerAddedRemoved?.Invoke(); } + public bool TimerIsNeeded => listViewBabies.Items.Count != 0; + public void Tick() { DateTime now = DateTime.Now; @@ -478,6 +483,7 @@ private void deleteTimerToolStripMenuItem_Click(object sender, EventArgs e) RecreateList(); onChange?.Invoke(); + TimerAddedRemoved?.Invoke(); } } else @@ -508,6 +514,7 @@ public void DeleteAllExpiredIncubationTimers() RecreateList(); onChange?.Invoke(); + TimerAddedRemoved?.Invoke(); } } @@ -696,6 +703,7 @@ private void bSaveTimerEdit_Click(object sender, EventArgs e) RecreateList(); onChange?.Invoke(); + TimerAddedRemoved?.Invoke(); } internal void SetLocalizations() From e81a702ac1962525e236ccddc36695ab1bfc1934 Mon Sep 17 00:00:00 2001 From: cadon Date: Sat, 8 Oct 2022 22:05:37 +0200 Subject: [PATCH 8/8] ver --- ARKBreedingStats/Properties/AssemblyInfo.cs | 2 +- ARKBreedingStats/_manifest.json | 2 +- ARKBreedingStats/json/values/_manifest.json | 16 ++++++++-------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ARKBreedingStats/Properties/AssemblyInfo.cs b/ARKBreedingStats/Properties/AssemblyInfo.cs index f8864e7b..f3e7c60e 100644 --- a/ARKBreedingStats/Properties/AssemblyInfo.cs +++ b/ARKBreedingStats/Properties/AssemblyInfo.cs @@ -30,6 +30,6 @@ // Revision // [assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("0.50.4.0")] +[assembly: AssemblyFileVersion("0.50.5.0")] [assembly: NeutralResourcesLanguage("en")] diff --git a/ARKBreedingStats/_manifest.json b/ARKBreedingStats/_manifest.json index 04a435a9..8760030d 100644 --- a/ARKBreedingStats/_manifest.json +++ b/ARKBreedingStats/_manifest.json @@ -4,7 +4,7 @@ "ARK Smart Breeding": { "Id": "ARK Smart Breeding", "Category": "main", - "version": "0.50.4.0" + "version": "0.50.5.0" }, "SpeciesColorImages": { "Id": "SpeciesColorImages", diff --git a/ARKBreedingStats/json/values/_manifest.json b/ARKBreedingStats/json/values/_manifest.json index af08eddf..5d182ccf 100644 --- a/ARKBreedingStats/json/values/_manifest.json +++ b/ARKBreedingStats/json/values/_manifest.json @@ -6,7 +6,7 @@ "mod": { "id": "1083349027", "tag": "SpeedyFlyers", "title": "Najs Speedy Flyers" } }, "1090809604-Pyria.json": { - "version": "345.39.1654507944", + "version": "350.5.1665173924", "mod": { "id": "1090809604", "tag": "Pyria", "title": "Pyria: Mythos Evolved" } }, "1092784125-Gryphons.json": { @@ -35,7 +35,7 @@ "mod": { "id": "1139775728", "tag": "Confuciusornis", "title": "Confuciusornis" } }, "1169020368-Trex.json": { - "version": "349.2.1661969243", + "version": "349.27.1663957342", "mod": { "id": "1169020368", "tag": "Trex", "title": "Ark Creature Rebalance (AG Reborn)" } }, "1178308359-ShadDragon.json": { @@ -100,7 +100,7 @@ "mod": { "id": "1522327484", "tag": "Additions_Pack", "title": "ARK Additions!" } }, "1523045986-Paranoia.json": { - "version": "346.16.1655416900", + "version": "349.27.1664841143", "mod": { "id": "1523045986", "tag": "Paranoia", "title": "Additional Creatures 2: Paranoia!" } }, "1565015734-BetterDinosTest.json": { @@ -108,7 +108,7 @@ "mod": { "id": "1565015734", "tag": "BetterDinosTest", "title": "Better Dinos" } }, "1576299694-ElementalDinos.json": { - "version": "348.6.1659523193", + "version": "349.27.1664277537", "mod": { "id": "1576299694", "tag": "ElementalDinos", "title": "Elemental Ark" } }, "1587391872-FasterFlyers.json": { @@ -141,11 +141,11 @@ "mod": { "id": "1662691167", "tag": "Senior", "title": "Additional Creatures: Senior Class" } }, "1675895024-NoUntameables.json": { - "version": "340.3.1635215511", + "version": "349.27.1664641331", "mod": { "id": "1675895024", "tag": "NoUntameables", "title": "No Untameables" } }, "1676159020-Aquaria.json": { - "version": "345.31.1652950451", + "version": "349.27.1664719853", "mod": { "id": "1676159020", "tag": "Aquaria", "title": "Additional Creatures: Aquaria" } }, "1681125667-Primal_Fear_EX.json": { @@ -263,7 +263,7 @@ "mod": { "id": "2135314513", "tag": "CI_Dinos", "title": "Crystal Isles Dino Addition" } }, "2447186973-ArkOmega.json": { - "version": "349.2.1661580009", + "version": "350.5.1665202463", "mod": { "id": "2447186973", "tag": "ArkOmega", "title": "Ark Omega" } }, "729352919-IndomRex.json": { @@ -283,7 +283,7 @@ "mod": { "id": "883957187", "tag": "WyvernWorld", "title": "Wyvern World" } }, "893735676-AE.json": { - "version": "349.2.1661548349", + "version": "349.22.1662742607", "mod": { "id": "893735676", "tag": "AE", "title": "Ark Eternal" } }, "895711211-ClassicFlyers.json": {