From b2668ebc3f2ba8c78bf285aca1189a2be73da711 Mon Sep 17 00:00:00 2001 From: D1firehail Date: Sat, 18 Feb 2023 17:40:39 +0100 Subject: [PATCH 01/15] Remove traces of SlowSecondProcess --- WFInfo/Ocr.cs | 191 +-------------------------- WFInfo/Settings/SettingsViewModel.cs | 9 -- WFInfo/Settings/SettingsWindow.xaml | 1 + 3 files changed, 5 insertions(+), 196 deletions(-) diff --git a/WFInfo/Ocr.cs b/WFInfo/Ocr.cs index e84d0f78..bf602b59 100644 --- a/WFInfo/Ocr.cs +++ b/WFInfo/Ocr.cs @@ -130,12 +130,9 @@ public enum WindowStyle private static Bitmap partialScreenshot; private static Bitmap partialScreenshotExpanded; - private static WFtheme activeTheme; private static string[] firstChecks; - private static List secondChecks; #pragma warning disable IDE0044 // Add readonly modifier private static int[] firstProximity = { -1, -1, -1, -1 }; - private static int[] secondProximity = { -1, -1, -1, -1 }; //TODO is never being written to, essentialy dissabling slow processing #pragma warning restore IDE0044 // Add readonly modifier private static string timestamp; @@ -182,7 +179,7 @@ internal static void ProcessRewardScreen(Bitmap file = null) bigScreenshot = file ?? CaptureScreenshot(); try { - parts = ExtractPartBoxAutomatically(out uiScaling, out activeTheme, bigScreenshot); + parts = ExtractPartBoxAutomatically(out uiScaling, out _, bigScreenshot); } catch (Exception e) { @@ -352,13 +349,6 @@ internal static void ProcessRewardScreen(Bitmap file = null) Main.overlays[bestPlatItem].BestPlatChoice(); }); } - - if (partialScreenshot.Height < 70 && _settings.DoDoubleCheck) - { - // SlowSecondProcess(); secondProximity is never being written to, thus this will always result in that there is no change in the first scan. I've commented this out to increase preformance. @Dapal - end = watch.ElapsedMilliseconds; - Main.StatusUpdate("Completed second pass(" + (end - start) + "ms)", 0); - } Main.AddLog(("---- Total Processing Time " + (end - start) + " ms ------------------------------------------------------------------------------------------").Substring(0, 108)); watch.Stop(); } @@ -501,191 +491,18 @@ internal static int GetSelectedReward(Point lastClick) private const double ERROR_DETECTION_THRESH = 0.25; private static bool CheckIfError() { - if (firstChecks == null || firstProximity == null || secondChecks == null || secondProximity == null) + if (firstChecks == null || firstProximity == null) return false; - int max = Math.Min(Math.Min(Math.Min(firstChecks.Length, firstProximity.Length), secondChecks.Count), secondProximity.Length); + int max = Math.Min(firstChecks.Length, firstProximity.Length); for (int i = 0; i < max; i++) - if (firstProximity[i] > ERROR_DETECTION_THRESH * firstChecks[i].Length && - (secondProximity[i] == -1 || secondProximity[i] > ERROR_DETECTION_THRESH * secondChecks[i].Length)) + if (firstProximity[i] > ERROR_DETECTION_THRESH * firstChecks[i].Length) return true; return false; } - public static void SlowSecondProcess() - { - #region initilizers - var tempclipboard = ""; - Bitmap newFilter = ScaleUpAndFilter(partialScreenshot, activeTheme, out _, out _ ); - partialScreenshotExpanded.Save(Main.AppPath + @"\Debug\PartShotUpscaled " + timestamp + ".png"); - newFilter.Save(Main.AppPath + @"\Debug\PartShotUpscaledFiltered " + timestamp + ".png"); - Main.AddLog(("---- SECOND OCR CHECK ------------------------------------------------------------------------------------------").Substring(0, 108)); - secondChecks = SeparatePlayers(newFilter, _tesseractService.SecondEngine); - var primeRewards = new List(); - - var tempAmountOfRewardsDisplayed = 0; - double bestPlat = 0; - var bestDucat = 0; - var bestPlatItem = 0; - var bestDucatItem = 0; - List unownedItems = new List(); - bool hideRewardInfo = false; - int partNumber = 0; - #endregion - try - { - for (int i = 0; i < firstChecks.Length; i++) - { - Debug.WriteLine(firstChecks[i]); - string first = firstChecks[i]; - if (secondProximity[i] == -1) { - Main.AddLog("Second proximity was not set"); - continue; - } else { - Main.AddLog($"First proximity {firstProximity[i]}, Second proximity {secondProximity[i]} Is the newer closer?: {secondProximity[i] > firstProximity[i]}"); - } - if (first.Replace(" ", "").Length > 6) - { - Debug.WriteLine(secondChecks[i]); - string second = secondChecks[i]; - string secondName = Main.dataBase.GetPartName(second, out secondProximity[i], false); - //if (secondProximity[i] < firstProximity[i]) - //{ - JObject job = Main.dataBase.marketData.GetValue(secondName).ToObject(); - string ducats = job["ducats"].ToObject(); - string plat = job["plat"].ToObject(); - string volume = job["volume"].ToObject(); - bool vaulted = Main.dataBase.IsPartVaulted(secondName); - bool mastered = Main.dataBase.IsPartMastered(secondName); - string partsOwned = Main.dataBase.PartsOwned(secondName); - string partsCount = Main.dataBase.PartsCount(secondName); - double platinum = double.Parse(plat, styles, Main.culture); - int duc = int.Parse(ducats, Main.culture); - tempAmountOfRewardsDisplayed++; - - if (duc == 0) - { - hideRewardInfo = true; - } - //else if (secondName != "Kuva" || secondName != "Exilus Weapon Adapter Blueprint" || secondName != "Riven Sliver" || secondName != "Ayatan Amber Star") - //{ - Debug.WriteLine($"Adding : {secondName}"); - primeRewards.Add(secondName); - //} - #region clipboard - if (platinum > 0) - { - if (!string.IsNullOrEmpty(tempclipboard)) { tempclipboard += "- "; } - - tempclipboard += "[" + secondName.Replace(" Blueprint", "") + "]: " + platinum + ":platinum: "; - - if (_settings.ClipboardVaulted) - { - tempclipboard += ducats + ":ducats:"; - if (vaulted) - tempclipboard += "(V)"; - } - } - if ((partNumber == firstChecks.Length - 1) && (!string.IsNullOrEmpty(tempclipboard))) - { - tempclipboard += _settings.ClipboardTemplate; - } - - #endregion - - #region highlight - if (platinum >= bestPlat) - { - bestPlat = platinum; bestPlatItem = i; - if (duc >= bestDucat) - { - bestDucat = duc; bestDucatItem = i; - } - } - if (duc > bestDucat) - { - bestDucat = duc; bestDucatItem = i; - } - if (duc > 0) - { - if (int.Parse(partsOwned, Main.culture) < int.Parse(partsCount, Main.culture)) - { - unownedItems.Add(i); - } - } - #endregion - - #region display - - Main.RunOnUIThread(() => - { - if (_settings.IsOverlaySelected) - { - Main.overlays[partNumber].LoadTextData(secondName, plat, ducats, volume, vaulted, mastered, $"{partsOwned} / {partsCount}", "", hideRewardInfo); - } - else if (!_settings.IsLightSelected) - { - Main.overlays[partNumber].LoadTextData(secondName, plat, ducats, volume, vaulted, mastered, $"{partsOwned} / {partsCount}", "", hideRewardInfo); - } - else - Main.window.loadTextData(secondName, plat, ducats, volume, vaulted, mastered, $"{partsOwned} / {partsCount}", partNumber, false, hideRewardInfo); - - if (_settings.Clipboard && !string.IsNullOrEmpty(tempclipboard)) - Clipboard.SetText(tempclipboard); - }); - #endregion - - - //} - hideRewardInfo = false; - partNumber++; - } - } - - numberOfRewardsDisplayed = tempAmountOfRewardsDisplayed; - Main.listingHelper.PrimeRewards.RemoveAt(Main.listingHelper.PrimeRewards.Count - 1); - var msg = primeRewards.Aggregate("", (current, item) => current + $"{item}, "); - - Main.AddLog($"Replacing the last entry as slow processing found another rewards: {msg} to list"); - Main.listingHelper.PrimeRewards.Add(primeRewards); - - if (_settings.HighlightRewards) - { - Main.RunOnUIThread(() => - { - foreach (var overlay in Main.overlays) - { - overlay.Clear(); - } - foreach (int item in unownedItems) - { - Main.overlays[item].BestOwnedChoice(); - Debug.WriteLine($"nr: {item} is unowned"); - } - Main.overlays[bestDucatItem].BestDucatChoice(); - Main.overlays[bestPlatItem].BestPlatChoice(); - Debug.WriteLine($"Best ducat: {bestDucatItem}, Best plat: {bestPlatItem}"); - }); - } - newFilter.Dispose(); - } - catch (Exception ex) - { - DateTime time = DateTime.UtcNow; - timestamp = time.ToString("yyyy-MM-dd HH-mm-ssff", Main.culture); - processingActive = false; - Main.AddLog($"Couldn't process second check {ex.ToString()}"); - Main.StatusUpdate("Couldn't process second check", 1); - Main.RunOnUIThread(() => - { - Main.SpawnErrorPopup(time); - }); - throw; - } - } - /// /// Processes the theme, parse image to detect the theme in the image. Parse null to detect the theme from the screen. /// closeestThresh is used for getting the most "Accuracte" result, anything over 100 is sure to be correct. diff --git a/WFInfo/Settings/SettingsViewModel.cs b/WFInfo/Settings/SettingsViewModel.cs index ea924ffe..89b702e8 100644 --- a/WFInfo/Settings/SettingsViewModel.cs +++ b/WFInfo/Settings/SettingsViewModel.cs @@ -242,15 +242,6 @@ public bool AutoList } } - public bool DoDoubleCheck - { - get => _settings.DoDoubleCheck; - set { - _settings.DoDoubleCheck = value; - RaisePropertyChanged(); - } - } - public double MaximumEfficiencyValue { get => _settings.MaximumEfficiencyValue; diff --git a/WFInfo/Settings/SettingsWindow.xaml b/WFInfo/Settings/SettingsWindow.xaml index 37b69936..49980c72 100644 --- a/WFInfo/Settings/SettingsWindow.xaml +++ b/WFInfo/Settings/SettingsWindow.xaml @@ -10,6 +10,7 @@ Title="Settings" MaxWidth="334" MinWidth="334" + Height="634" BorderBrush="#FF707070" WindowStyle="None" From 66974b75a03b4a932df7b121f7b1d63f8e86ec7f Mon Sep 17 00:00:00 2001 From: D1firehail Date: Sat, 18 Feb 2023 19:32:53 +0100 Subject: [PATCH 02/15] UI and settings for theme selection --- WFInfo/Ocr.cs | 45 ++++++++-------- WFInfo/Settings/ApplicationSettings.cs | 2 + .../Settings/IReadOnlyApplicationSettings.cs | 1 + WFInfo/Settings/SettingsViewModel.cs | 10 ++++ WFInfo/Settings/SettingsWindow.xaml | 51 ++++++++++++++++++- WFInfo/Settings/SettingsWindow.xaml.cs | 5 ++ 6 files changed, 92 insertions(+), 22 deletions(-) diff --git a/WFInfo/Ocr.cs b/WFInfo/Ocr.cs index bf602b59..69588b81 100644 --- a/WFInfo/Ocr.cs +++ b/WFInfo/Ocr.cs @@ -26,6 +26,29 @@ namespace WFInfo { + public enum WFtheme : int + { + VITRUVIAN, + STALKER, + BARUUK, + CORPUS, + FORTUNA, + GRINEER, + LOTUS, + NIDUS, + OROKIN, + TENNO, + HIGH_CONTRAST, + LEGACY, + EQUINOX, + DARK_LOTUS, + ZEPHYR, + UNKNOWN = -1, + AUTO = -2, + CUSTOM = -3 + + } + class OCR { private static readonly string applicationDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\WFInfo"; @@ -33,25 +56,7 @@ class OCR private static Screen wfScreen = Screen.PrimaryScreen; #region variabels and sizzle - public enum WFtheme : int - { - VITRUVIAN, - STALKER, - BARUUK, - CORPUS, - FORTUNA, - GRINEER, - LOTUS, - NIDUS, - OROKIN, - TENNO, - HIGH_CONTRAST, - LEGACY, - EQUINOX, - DARK_LOTUS, - ZEPHYR, - UNKNOWN = -1 - } + // Colors for the top left "profile bar" public static Color[] ThemePrimary = new Color[] { Color.FromArgb(190, 169, 102), //VITRUVIAN @@ -582,7 +587,7 @@ private static WFtheme GetClosestTheme(Color clr, out int threshold) foreach (WFtheme theme in (WFtheme[])Enum.GetValues(typeof(WFtheme))) { - if (theme != WFtheme.UNKNOWN) + if ((int)theme >= 0) //ignore special theme values { Color themeColor = ThemePrimary[(int)theme]; int tempThresh = ColorDifference(clr, themeColor); diff --git a/WFInfo/Settings/ApplicationSettings.cs b/WFInfo/Settings/ApplicationSettings.cs index 926a70dc..2a1355c1 100644 --- a/WFInfo/Settings/ApplicationSettings.cs +++ b/WFInfo/Settings/ApplicationSettings.cs @@ -81,6 +81,8 @@ public Point MainWindowLocation public double SnapColEmptyDensity { get; set; } = 0.005; public int MinOverlayWidth { get; set; } = 120; public int MaxOverlayWidth { get; set; } = 160; + + public WFtheme ThemeSelection { get; set; } = WFtheme.AUTO; public string Ignored { get; set; } = null; [OnError] internal void OnError(StreamingContext context, ErrorContext errorContext) diff --git a/WFInfo/Settings/IReadOnlyApplicationSettings.cs b/WFInfo/Settings/IReadOnlyApplicationSettings.cs index a82b1050..b9010f2f 100644 --- a/WFInfo/Settings/IReadOnlyApplicationSettings.cs +++ b/WFInfo/Settings/IReadOnlyApplicationSettings.cs @@ -56,6 +56,7 @@ public interface IReadOnlyApplicationSettings double SnapColEmptyDensity { get; } int MinOverlayWidth { get; } int MaxOverlayWidth { get; } + WFtheme ThemeSelection { get; } string Ignored { get; } } } \ No newline at end of file diff --git a/WFInfo/Settings/SettingsViewModel.cs b/WFInfo/Settings/SettingsViewModel.cs index 89b702e8..4b3c7457 100644 --- a/WFInfo/Settings/SettingsViewModel.cs +++ b/WFInfo/Settings/SettingsViewModel.cs @@ -379,6 +379,16 @@ public int MaxOverlayWidth } } + public WFtheme ThemeSelection + { + get => _settings.ThemeSelection; + set + { + _settings.ThemeSelection = value; + RaisePropertyChanged(); + } + } + public string Ignored{ get => _settings.Ignored; set { diff --git a/WFInfo/Settings/SettingsWindow.xaml b/WFInfo/Settings/SettingsWindow.xaml index 49980c72..e50b4f54 100644 --- a/WFInfo/Settings/SettingsWindow.xaml +++ b/WFInfo/Settings/SettingsWindow.xaml @@ -10,14 +10,21 @@ Title="Settings" MaxWidth="334" MinWidth="334" - - Height="634" + Width="334" + Height="900" BorderBrush="#FF707070" WindowStyle="None" FontSize="16" d:DataContext="{d:DesignInstance Type=settings:SettingsWindow}" AllowsTransparency="True" ResizeMode="CanResizeWithGrip"> + + + + + + + + + + + + + + + - - - - - - - - - + + + + + + + + - - + + - - - - - - - + + + + + + - - - - - - - - - + + + + + + + + - - + + - - - - - - - + + + + + + - - - - - - - - - + + + + + + + + - - - + + + + - + + - - - - - - - + + + + + + - - - - - - - - - + + + + + + + + - - - - - - - - - + + + + + + + + - - - - - - - - - + + + + + + + + - - - - - - - - - + + + + + + + + - - - - - - - - - + + + + + + + + - - - - - + + + + - + + - - - - - - - + + + + + + - - - - - - - - - + + + + + + + + - - + + - - - - - - - + + + + + + - - - - - - - - - + + + + + + + + - - + + - - - - - - - + + + + + + - - - - - - - - - + + + + + + + + - - - - - + + + + From 8f1bb15913e402e8879975b5d63050468712b503 Mon Sep 17 00:00:00 2001 From: D1firehail Date: Sun, 19 Feb 2023 18:20:24 +0100 Subject: [PATCH 06/15] Reward Overlay Location for 1/2 rewards. Better logging of auto-list options --- WFInfo/Data.cs | 12 +- WFInfo/Main.cs | 7 +- WFInfo/Ocr.cs | 163 +++++++++++++------------- WFInfo/Settings/ThemeAdjuster.xaml.cs | 7 ++ 4 files changed, 105 insertions(+), 84 deletions(-) diff --git a/WFInfo/Data.cs b/WFInfo/Data.cs index 29978347..659f5e20 100644 --- a/WFInfo/Data.cs +++ b/WFInfo/Data.cs @@ -1029,7 +1029,8 @@ private void LogChanged(object sender, string line) Overlay.rewardsDisplaying = true; } - if (!line.Contains("MatchingService::EndSession") || !_settings.AutoList) return; + //abort if autolist disabled, or line doesn't contain end-of-session message or timer finished message + if (!(line.Contains("MatchingService::EndSession") || line.Contains("Relic timer closed")) || !_settings.AutoList) return; if (Main.listingHelper.PrimeRewards == null || Main.listingHelper.PrimeRewards.Count == 0) { @@ -1048,7 +1049,14 @@ private void LogChanged(object sender, string line) Main.AddLog("Looping through rewards"); foreach (var rewardscreen in Main.listingHelper.PrimeRewards) { - Main.AddLog(rewardscreen.ToString()); + string rewards = ""; + for(int i = 0; i < rewardscreen.Count; i++) + { + rewards += rewardscreen[i]; + if (i + 1 < rewardscreen.Count) + rewards += " || "; + } + Main.AddLog(rewards); var rewardCollection = Task.Run(() => Main.listingHelper.GetRewardCollection(rewardscreen)).Result; if (rewardCollection.PrimeNames.Count == 0) return; diff --git a/WFInfo/Main.cs b/WFInfo/Main.cs index 62e206e5..7cd35dc9 100644 --- a/WFInfo/Main.cs +++ b/WFInfo/Main.cs @@ -305,11 +305,16 @@ public void OnMouseAction(MouseButton key) } else if (key == MouseButton.Left && OCR.Warframe != null && !OCR.Warframe.HasExited && Overlay.rewardsDisplaying) { + if (_settings.Display != Display.Overlay && _settings.AutoList == false) + { + Overlay.rewardsDisplaying = false; //only "naturally" set to false on overlay disappearing and/or specific log message with auto-list enabled + return; + } Task.Run((() => { lastClick = System.Windows.Forms.Cursor.Position; int index = OCR.GetSelectedReward(lastClick); - Debug.WriteLine(index); + Main.AddLog("Chosen reward index: " + index); if (index < 0) return; listingHelper.SelectedRewardIndex = (short)index; })); diff --git a/WFInfo/Ocr.cs b/WFInfo/Ocr.cs index f67e849d..db18cf66 100644 --- a/WFInfo/Ocr.cs +++ b/WFInfo/Ocr.cs @@ -203,8 +203,8 @@ internal static void ProcessRewardScreen(Bitmap file = null) } Task.WaitAll(tasks); - // Remove any empty items from the array - firstChecks = firstChecks.Where(s => !string.IsNullOrEmpty(s)).ToArray(); + // Remove any empty (or suspiciously short) items from the array + firstChecks = firstChecks.Where(s => !string.IsNullOrEmpty(s) && s.Replace(" ", "").Length > 6).ToArray(); if (firstChecks == null || firstChecks.Length == 0 || CheckIfError()) { processingActive = false; @@ -229,11 +229,12 @@ internal static void ProcessRewardScreen(Bitmap file = null) #region processing data if (firstChecks.Length > 0) { + numberOfRewardsDisplayed = firstChecks.Length; clipboard = string.Empty; int width = (int)(pixleRewardWidth * screenScaling * uiScaling) + 10; int startX = center.X - width / 2 + (int)(width * 0.004); - if (firstChecks.Length == 3 && firstChecks[0].Length > 0) { startX += width / 8; } - if (firstChecks.Length == 4 && firstChecks[0].Replace(" ", "").Length < 6) { startX += 2 * (width / 8); } + if (firstChecks.Length % 2 == 1) { startX += width / 8; } + if (firstChecks.Length <= 2) { startX += 2 * (width / 8); } int overWid = (int)(width / (4.1 * dpiScaling)); int startY = (int)(center.Y / dpiScaling - 20 * screenScaling * uiScaling); int partNumber = 0; @@ -241,98 +242,94 @@ internal static void ProcessRewardScreen(Bitmap file = null) for (int i = 0; i < firstChecks.Length; i++) { string part = firstChecks[i]; - if (part.Replace(" ", "").Length > 6) + #region found a part + string correctName = Main.dataBase.GetPartName(part, out firstProximity[i], false); + JObject job = Main.dataBase.marketData.GetValue(correctName).ToObject(); + string ducats = job["ducats"].ToObject(); + if (int.Parse(ducats, Main.culture) == 0) { - #region found a part - string correctName = Main.dataBase.GetPartName(part, out firstProximity[i], false); - JObject job = Main.dataBase.marketData.GetValue(correctName).ToObject(); - string ducats = job["ducats"].ToObject(); - if (int.Parse(ducats, Main.culture) == 0) - { - hideRewardInfo = true; - } - //else if (correctName != "Kuva" || correctName != "Exilus Weapon Adapter Blueprint" || correctName != "Riven Sliver" || correctName != "Ayatan Amber Star") - primeRewards.Add(correctName); - string plat = job["plat"].ToObject(); - double platinum = double.Parse(plat, styles, Main.culture); - string volume = job["volume"].ToObject(); - bool vaulted = Main.dataBase.IsPartVaulted(correctName); - bool mastered = Main.dataBase.IsPartMastered(correctName); - string partsOwned = Main.dataBase.PartsOwned(correctName); - string partsCount = Main.dataBase.PartsCount(correctName); - int duc = int.Parse(ducats, Main.culture); - numberOfRewardsDisplayed++; - #endregion - - #region hilighting - if (platinum >= bestPlat) - { - bestPlat = platinum; bestPlatItem = i; - if (duc >= bestDucat) - { - bestDucat = duc; bestDucatItem = i; - } - } - if (duc > bestDucat) + hideRewardInfo = true; + } + //else if (correctName != "Kuva" || correctName != "Exilus Weapon Adapter Blueprint" || correctName != "Riven Sliver" || correctName != "Ayatan Amber Star") + primeRewards.Add(correctName); + string plat = job["plat"].ToObject(); + double platinum = double.Parse(plat, styles, Main.culture); + string volume = job["volume"].ToObject(); + bool vaulted = Main.dataBase.IsPartVaulted(correctName); + bool mastered = Main.dataBase.IsPartMastered(correctName); + string partsOwned = Main.dataBase.PartsOwned(correctName); + string partsCount = Main.dataBase.PartsCount(correctName); + int duc = int.Parse(ducats, Main.culture); + #endregion + + #region hilighting + if (platinum >= bestPlat) + { + bestPlat = platinum; bestPlatItem = i; + if (duc >= bestDucat) { bestDucat = duc; bestDucatItem = i; } - if (duc > 0) + } + if (duc > bestDucat) + { + bestDucat = duc; bestDucatItem = i; + } + if (duc > 0) + { + if (!mastered && int.Parse(partsOwned, Main.culture) < int.Parse(partsCount, Main.culture)) { - if (!mastered && int.Parse(partsOwned, Main.culture) < int.Parse(partsCount, Main.culture)) - { - unownedItems.Add(i); - } + unownedItems.Add(i); } - #endregion + } + #endregion - #region clipboard - if (platinum > 0) - { - if (!string.IsNullOrEmpty(clipboard)) { clipboard += "- "; } + #region clipboard + if (platinum > 0) + { + if (!string.IsNullOrEmpty(clipboard)) { clipboard += "- "; } - clipboard += "[" + correctName.Replace(" Blueprint", "") + "]: " + plat + ":platinum: "; + clipboard += "[" + correctName.Replace(" Blueprint", "") + "]: " + plat + ":platinum: "; - if (_settings.ClipboardVaulted) - { - clipboard += ducats + ":ducats:"; - if (vaulted) - clipboard += "(V)"; - } + if (_settings.ClipboardVaulted) + { + clipboard += ducats + ":ducats:"; + if (vaulted) + clipboard += "(V)"; } + } + + if ((partNumber == firstChecks.Length - 1) && (!string.IsNullOrEmpty(clipboard))) + { + clipboard += _settings.ClipboardTemplate; + } + #endregion + + #region display part + Main.RunOnUIThread(() => + { + Overlay.rewardsDisplaying = true; - if ((partNumber == firstChecks.Length - 1) && (!string.IsNullOrEmpty(clipboard))) + if (_settings.IsOverlaySelected) { - clipboard += _settings.ClipboardTemplate; + Main.overlays[partNumber].LoadTextData(correctName, plat, ducats, volume, vaulted, mastered, $"{partsOwned} / {partsCount}", "", hideRewardInfo); + Main.overlays[partNumber].Resize(overWid); + Main.overlays[partNumber].Display((int)((startX + width / 4 * partNumber + _settings.OverlayXOffsetValue) / dpiScaling), startY + (int)(_settings.OverlayYOffsetValue / dpiScaling), _settings.Delay); } - #endregion - - #region display part - Main.RunOnUIThread(() => + else if (!_settings.IsLightSelected) { - Overlay.rewardsDisplaying = true; - - if (_settings.IsOverlaySelected) - { - Main.overlays[partNumber].LoadTextData(correctName, plat, ducats, volume, vaulted, mastered, $"{partsOwned} / {partsCount}", "", hideRewardInfo); - Main.overlays[partNumber].Resize(overWid); - Main.overlays[partNumber].Display((int)((startX + width / 4 * partNumber + _settings.OverlayXOffsetValue) / dpiScaling), startY + (int)(_settings.OverlayYOffsetValue / dpiScaling), _settings.Delay); - } - else if (!_settings.IsLightSelected) - { - Main.window.loadTextData(correctName, plat, ducats, volume, vaulted, mastered, $"{partsOwned} / {partsCount}", partNumber, true, hideRewardInfo); - } - //else - //Main.window.loadTextData(correctName, plat, ducats, volume, vaulted, $"{partsOwned} / {partsCount}", partNumber, false, hideRewardInfo); + Main.window.loadTextData(correctName, plat, ducats, volume, vaulted, mastered, $"{partsOwned} / {partsCount}", partNumber, true, hideRewardInfo); + } + //else + //Main.window.loadTextData(correctName, plat, ducats, volume, vaulted, $"{partsOwned} / {partsCount}", partNumber, false, hideRewardInfo); - if (_settings.Clipboard && !string.IsNullOrEmpty(clipboard)) - Clipboard.SetText(clipboard); + if (_settings.Clipboard && !string.IsNullOrEmpty(clipboard)) + Clipboard.SetText(clipboard); - }); - partNumber++; - hideRewardInfo = false; - #endregion - } + }); + partNumber++; + hideRewardInfo = false; + #endregion } var end = watch.ElapsedMilliseconds; Main.StatusUpdate("Completed processing (" + (end - start) + "ms)", 0); @@ -417,7 +414,11 @@ internal static int GetSelectedReward(Point lastClick) var lowestDistance = int.MaxValue; var lowestDistancePoint = new Point(); - if (numberOfRewardsDisplayed != 3) + if (numberOfRewardsDisplayed == 1) //rare, but can happen if others don't get enough traces + { + primeRewardIndex = 0; + } + else if (numberOfRewardsDisplayed != 3) { foreach (var pnt in RewardPoints4) { diff --git a/WFInfo/Settings/ThemeAdjuster.xaml.cs b/WFInfo/Settings/ThemeAdjuster.xaml.cs index 0e94ee15..5344bdbb 100644 --- a/WFInfo/Settings/ThemeAdjuster.xaml.cs +++ b/WFInfo/Settings/ThemeAdjuster.xaml.cs @@ -162,6 +162,13 @@ private void LoadFromFile(object sender, RoutedEventArgs e) private void Hide(object sender, RoutedEventArgs e) { + if (unfiltered != null) + { + unfiltered.Dispose(); + } + unfiltered = null; + displayImage = null; + previewImage.Source = null; Hide(); } From adf05a0e8df7f9f5a20120de668663721a74ddb3 Mon Sep 17 00:00:00 2001 From: D1firehail Date: Sun, 19 Feb 2023 20:14:16 +0100 Subject: [PATCH 07/15] if AFK checker or VerifyWarframe notices game closed, check for restart --- WFInfo/Main.cs | 6 ++++++ WFInfo/Ocr.cs | 11 +++++++++++ 2 files changed, 17 insertions(+) diff --git a/WFInfo/Main.cs b/WFInfo/Main.cs index 7cd35dc9..2eb0da1e 100644 --- a/WFInfo/Main.cs +++ b/WFInfo/Main.cs @@ -111,6 +111,12 @@ private static async void TimeoutCheck() if (OCR.Warframe != null && OCR.Warframe.HasExited && LastMarketStatus != "invisible") {//set user offline if Warframe has closed but no new game was found Debug.WriteLine($"Warframe was detected as closed"); + //reset warframe process variables, and reset LogCapture so new game process gets noticed + dataBase.DisableLogCapture(); + OCR.Warframe.Dispose(); + OCR.Warframe = null; + if (ApplicationSettings.GlobalReadonlySettings.Auto) + dataBase.EnableLogCapture(); await Task.Run(async () => { diff --git a/WFInfo/Ocr.cs b/WFInfo/Ocr.cs index db18cf66..d7fbca4c 100644 --- a/WFInfo/Ocr.cs +++ b/WFInfo/Ocr.cs @@ -2434,6 +2434,16 @@ public static bool VerifyWarframe() { if (Warframe != null && !Warframe.HasExited) { // don't update status return true; } + if (Warframe!= null && Warframe.HasExited) + { + //reset warframe process variables, and reset LogCapture so new game process gets noticed + Main.dataBase.DisableLogCapture(); + Warframe.Dispose(); + Warframe = null; + if (ApplicationSettings.GlobalReadonlySettings.Auto) + Main.dataBase.EnableLogCapture(); + } + Task.Run(() => { foreach (Process process in Process.GetProcesses()) if (process.ProcessName == "Warframe.x64") { @@ -2459,6 +2469,7 @@ public static bool VerifyWarframe() { return true; } catch (System.ComponentModel.Win32Exception e) { + Warframe = null; Main.AddLog($"Failed to get Warframe process due to: {e.Message}"); Main.StatusUpdate("Restart Warframe without admin privileges", 1); return _settings.Debug ? true : false; From 2b7836ddb93ea2840919edfe19e62ca0e36e1822 Mon Sep 17 00:00:00 2001 From: D1firehail Date: Sun, 19 Feb 2023 22:43:31 +0100 Subject: [PATCH 08/15] Reward Choice to CSV --- WFInfo/Data.cs | 64 ++++++++++++++----- WFInfo/Main.cs | 2 +- WFInfo/Settings/ApplicationSettings.cs | 1 + .../Settings/IReadOnlyApplicationSettings.cs | 1 + WFInfo/Settings/SettingsViewModel.cs | 16 ++++- WFInfo/Settings/SettingsWindow.xaml | 8 ++- WFInfo/Settings/SettingsWindow.xaml.cs | 4 ++ 7 files changed, 75 insertions(+), 21 deletions(-) diff --git a/WFInfo/Data.cs b/WFInfo/Data.cs index 659f5e20..55cd3deb 100644 --- a/WFInfo/Data.cs +++ b/WFInfo/Data.cs @@ -1029,8 +1029,8 @@ private void LogChanged(object sender, string line) Overlay.rewardsDisplaying = true; } - //abort if autolist disabled, or line doesn't contain end-of-session message or timer finished message - if (!(line.Contains("MatchingService::EndSession") || line.Contains("Relic timer closed")) || !_settings.AutoList) return; + //abort if autolist and autocsv disabled, or line doesn't contain end-of-session message or timer finished message + if (!(line.Contains("MatchingService::EndSession") || line.Contains("Relic timer closed")) || ! (_settings.AutoList || _settings.AutoCSV)) return; if (Main.listingHelper.PrimeRewards == null || Main.listingHelper.PrimeRewards.Count == 0) { @@ -1046,32 +1046,66 @@ private void LogChanged(object sender, string line) } Overlay.rewardsDisplaying = false; + string csv = ""; Main.AddLog("Looping through rewards"); foreach (var rewardscreen in Main.listingHelper.PrimeRewards) { string rewards = ""; - for(int i = 0; i < rewardscreen.Count; i++) + for (int i = 0; i < rewardscreen.Count; i++) { rewards += rewardscreen[i]; if (i + 1 < rewardscreen.Count) rewards += " || "; } Main.AddLog(rewards); - var rewardCollection = Task.Run(() => Main.listingHelper.GetRewardCollection(rewardscreen)).Result; - if (rewardCollection.PrimeNames.Count == 0) - return; - Main.listingHelper.ScreensList.Add(new KeyValuePair("", rewardCollection)); + if (_settings.AutoList) + { + + var rewardCollection = Task.Run(() => Main.listingHelper.GetRewardCollection(rewardscreen)).Result; + if (rewardCollection.PrimeNames.Count == 0) + continue; + + Main.listingHelper.ScreensList.Add(new KeyValuePair("", rewardCollection)); + } + + if (_settings.AutoCSV) + { + if (csv.Length == 0 && !File.Exists(applicationDirectory + @"\rewardExport.csv")) + csv += "Timestamp,ChosenIndex,Reward_0_Name,Reward_0_Plat,Reward_0_Ducats,Reward_1_Name,Reward_1_Plat,Reward_1_Ducats,Reward_2_Name,Reward_2_Plat,Reward_2_Ducats,Reward_3_Name,Reward_3_Plat,Reward_3_Ducats" + Environment.NewLine; + csv += DateTime.UtcNow.ToString("yyyy-MM-dd HH-mm-ssff", Main.culture) + "," + Main.listingHelper.SelectedRewardIndex; + for (int i = 0; i < 4; i++) + { + if (i < rewardscreen.Count) + { + JObject job = Main.dataBase.marketData.GetValue(rewardscreen[i]).ToObject(); + string plat = job["plat"].ToObject(); + string ducats = job["ducats"].ToObject(); + csv += "," + rewardscreen[i] + "," + plat + "," + ducats; + } + else + { + csv += ",\"\",0,0"; //fill empty slots with "",0,0 + } + } + csv += Environment.NewLine; + } + } - Main.RunOnUIThread(() => + if (_settings.AutoCSV) { - if (Main.listingHelper.ScreensList.Count == 1) - Main.listingHelper.SetScreen(0); - Main.listingHelper.PrimeRewards.Clear(); - Main.listingHelper.Show(); - Main.listingHelper.Topmost = true; - Main.listingHelper.Topmost = false; - }); + File.AppendAllText(applicationDirectory + @"\rewardExport.csv", csv); + } + if (_settings.AutoList) + Main.RunOnUIThread(() => + { + if (Main.listingHelper.ScreensList.Count == 1) + Main.listingHelper.SetScreen(0); + Main.listingHelper.PrimeRewards.Clear(); + Main.listingHelper.Show(); + Main.listingHelper.Topmost = true; + Main.listingHelper.Topmost = false; + }); }); } diff --git a/WFInfo/Main.cs b/WFInfo/Main.cs index 2eb0da1e..671f0283 100644 --- a/WFInfo/Main.cs +++ b/WFInfo/Main.cs @@ -311,7 +311,7 @@ public void OnMouseAction(MouseButton key) } else if (key == MouseButton.Left && OCR.Warframe != null && !OCR.Warframe.HasExited && Overlay.rewardsDisplaying) { - if (_settings.Display != Display.Overlay && _settings.AutoList == false) + if (_settings.Display != Display.Overlay && !_settings.AutoList && !_settings.AutoCSV) { Overlay.rewardsDisplaying = false; //only "naturally" set to false on overlay disappearing and/or specific log message with auto-list enabled return; diff --git a/WFInfo/Settings/ApplicationSettings.cs b/WFInfo/Settings/ApplicationSettings.cs index aa6dd1d3..bee3b2c9 100644 --- a/WFInfo/Settings/ApplicationSettings.cs +++ b/WFInfo/Settings/ApplicationSettings.cs @@ -67,6 +67,7 @@ public Point MainWindowLocation public int OverlayXOffsetValue { get; set; } = 0; public int OverlayYOffsetValue { get; set; } = 0; public bool AutoList { get; set; } = false; + public bool AutoCSV { get; set; } = false; public bool DoDoubleCheck { get; set; } = true; public double MaximumEfficiencyValue { get; set; } = 9.5; public double MinimumEfficiencyValue { get; set; } = 4.5; diff --git a/WFInfo/Settings/IReadOnlyApplicationSettings.cs b/WFInfo/Settings/IReadOnlyApplicationSettings.cs index 6e9a6209..fec8f2d0 100644 --- a/WFInfo/Settings/IReadOnlyApplicationSettings.cs +++ b/WFInfo/Settings/IReadOnlyApplicationSettings.cs @@ -42,6 +42,7 @@ public interface IReadOnlyApplicationSettings int OverlayXOffsetValue { get; } int OverlayYOffsetValue { get; } bool AutoList { get; } + bool AutoCSV { get; } bool DoDoubleCheck { get; } double MaximumEfficiencyValue { get; } double MinimumEfficiencyValue { get; } diff --git a/WFInfo/Settings/SettingsViewModel.cs b/WFInfo/Settings/SettingsViewModel.cs index c64eded2..002f9c1c 100644 --- a/WFInfo/Settings/SettingsViewModel.cs +++ b/WFInfo/Settings/SettingsViewModel.cs @@ -236,9 +236,21 @@ public int OverlayYOffsetValue public bool AutoList { get => _settings.AutoList; - set { + set + { _settings.AutoList = value; - RaisePropertyChanged(); + RaisePropertyChanged(); + } + } + + + public bool AutoCSV + { + get => _settings.AutoCSV; + set + { + _settings.AutoCSV = value; + RaisePropertyChanged(); } } diff --git a/WFInfo/Settings/SettingsWindow.xaml b/WFInfo/Settings/SettingsWindow.xaml index 4de6c35a..6d527576 100644 --- a/WFInfo/Settings/SettingsWindow.xaml +++ b/WFInfo/Settings/SettingsWindow.xaml @@ -470,18 +470,20 @@ - + + diff --git a/WFInfo/Settings/SettingsWindow.xaml.cs b/WFInfo/Settings/SettingsWindow.xaml.cs index 06c04d45..179cbca1 100644 --- a/WFInfo/Settings/SettingsWindow.xaml.cs +++ b/WFInfo/Settings/SettingsWindow.xaml.cs @@ -46,10 +46,12 @@ public void populate() { autoCheckbox.IsChecked = true; Autolist.IsEnabled = true; + Autocsv.IsEnabled = true; } else { Autolist.IsEnabled = false; + Autocsv.IsEnabled = false; } foreach (ComboBoxItem localeItem in localeCombobox.Items) @@ -115,6 +117,7 @@ private void AutoClicked(object sender, RoutedEventArgs e) { Main.dataBase.EnableLogCapture(); Autolist.IsEnabled = true; + Autocsv.IsEnabled = true; } else { @@ -122,6 +125,7 @@ private void AutoClicked(object sender, RoutedEventArgs e) autoCheckbox.IsChecked = false; Main.dataBase.DisableLogCapture(); Autolist.IsEnabled = false; + Autocsv.IsEnabled = false; } } else From 9f20267854d5740bd7389c65eed3d720ed1fce65 Mon Sep 17 00:00:00 2001 From: D1firehail Date: Mon, 20 Feb 2023 17:41:44 +0100 Subject: [PATCH 09/15] Add Auto Count --- WFInfo/AutoAddViewModel.cs | 138 +++++++++++ WFInfo/AutoCount.xaml | 214 ++++++++++++++++++ WFInfo/AutoCount.xaml.cs | 119 ++++++++++ WFInfo/Data.cs | 57 +++-- WFInfo/Main.cs | 3 +- WFInfo/Settings/ApplicationSettings.cs | 1 + .../Settings/IReadOnlyApplicationSettings.cs | 1 + WFInfo/Settings/SettingsViewModel.cs | 9 + WFInfo/Settings/SettingsWindow.xaml | 4 + WFInfo/Settings/SettingsWindow.xaml.cs | 7 + 10 files changed, 539 insertions(+), 14 deletions(-) create mode 100644 WFInfo/AutoAddViewModel.cs create mode 100644 WFInfo/AutoCount.xaml create mode 100644 WFInfo/AutoCount.xaml.cs diff --git a/WFInfo/AutoAddViewModel.cs b/WFInfo/AutoAddViewModel.cs new file mode 100644 index 00000000..6fc2a29f --- /dev/null +++ b/WFInfo/AutoAddViewModel.cs @@ -0,0 +1,138 @@ +using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; + +namespace WFInfo +{ + public class AutoAddViewModel : INPC + { + private ObservableCollection _itemList; + + public ObservableCollection ItemList + { + get => _itemList; + private set + { + _itemList = value; + RaisePropertyChanged(); + } + } + public AutoAddViewModel() + { + _itemList = new ObservableCollection(); + } + + public void addItem(AutoAddSingleItem item) + { + _itemList.Add(item); + RaisePropertyChanged(); + } + + public void removeItem(AutoAddSingleItem item) + { + _itemList.Remove(item); + RaisePropertyChanged(); + } + } + + public class AutoAddSingleItem : INPC + { + public AutoAddViewModel _parent; + + private ObservableCollection _rewardOptions; + + public ObservableCollection RewardOptions + { + get => _rewardOptions; + private set + { + _rewardOptions = value; + RaisePropertyChanged(); + } + } + + private string _activeOption; + public string ActiveOption + { + get => _activeOption; + set + { + _activeOption = value; + RaisePropertyChanged(); + } + } + + public SimpleCommand Increment { get; } + + public SimpleCommand Remove { get; } + + public AutoAddSingleItem(List options, int activeIndex, AutoAddViewModel parent) + { + + RewardOptions = new ObservableCollection(options); + activeIndex = Math.Min(RewardOptions.Count - 1, activeIndex); + if (activeIndex >= 0 && options != null) + { + ActiveOption = options[activeIndex]; + } else + { + ActiveOption = ""; + } + _parent = parent; + Remove = new SimpleCommand(() => RemoveFromParent()); + Increment = new SimpleCommand(() => AddCount(true)); + } + + public void AddCount(bool save) + { + //get item count, increment, save + bool saveFailed = false; + string item = ActiveOption; + if (item.Contains("Prime")) + { + string[] nameParts = item.Split(new string[] { "Prime" }, 2, StringSplitOptions.None); + string primeName = nameParts[0] + "Prime"; + string partName = primeName + ((nameParts[1].Length > 10 && !nameParts[1].Contains("Kubrow")) ? nameParts[1].Replace(" Blueprint", "") : nameParts[1]); + + + Main.AddLog("Incrementing owned amount for part \"" + partName + "\""); + try + { + + int count = Main.dataBase.equipmentData[primeName]["parts"][partName]["owned"].ToObject(); + + Main.dataBase.equipmentData[primeName]["parts"][partName]["owned"] = count + 1; + } + catch (Exception ex) + { + Main.AddLog("FAILED to increment owned amount, Name: " + item + ", primeName: " + primeName + ", partName: " + partName + Environment.NewLine + ex.Message); + saveFailed = true; + } + } + if (saveFailed) + { + //shouldn't need Main.RunOnUIThread since this is already on the UI Thread + //adjust for time diff between snap-it finishing and save being pressed, in case of long delay + Main.SpawnErrorPopup(DateTime.UtcNow); + Main.StatusUpdate("Failed to save one or more item, report to dev", 2); + } + + RemoveFromParent(); + if (save) + { + Main.dataBase.SaveAllJSONs(); + EquipmentWindow.INSTANCE.reloadItems(); + } + } + + private void RemoveFromParent() + { + if (_parent != null) + { + _parent.removeItem(this); + } + RaisePropertyChanged(); + } + } +} diff --git a/WFInfo/AutoCount.xaml b/WFInfo/AutoCount.xaml new file mode 100644 index 00000000..3fee8d76 --- /dev/null +++ b/WFInfo/AutoCount.xaml @@ -0,0 +1,214 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/WFInfo/AutoCount.xaml.cs b/WFInfo/AutoCount.xaml.cs new file mode 100644 index 00000000..5ffe8174 --- /dev/null +++ b/WFInfo/AutoCount.xaml.cs @@ -0,0 +1,119 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Shapes; + +namespace WFInfo +{ + /// + /// Interaction logic for AutoCount.xaml + /// + public partial class AutoCount : Window + { + + //private readonly Settings.SettingsViewModel _viewModel; + //public Settings.SettingsViewModel SettingsViewModel => _viewModel; + + public static AutoCount INSTANCE; + public AutoAddViewModel viewModel { get; } + public SimpleCommand IncrementAll { get; } + public SimpleCommand RemoveAll { get; } + + public AutoCount() + { + INSTANCE = this; + viewModel = new AutoAddViewModel(); + + RemoveAll = new SimpleCommand(() => RemoveFromParentAll()); + IncrementAll = new SimpleCommand(() => AddCountAll()); + + for (int i = 0; i < 30; i++) + { + List tmp = new List(); + tmp.Add("Ivara Prime Blueprint"); + tmp.Add("Braton Prime Blueprint"); + tmp.Add("Paris Prime Upper Limb"); + AutoAddSingleItem tmpItem = new AutoAddSingleItem(tmp, i % 5, viewModel); + viewModel.addItem(tmpItem); + } + InitializeComponent(); + } + public static void ShowAutoCount() + { + if (INSTANCE != null) + { + INSTANCE.Show(); + INSTANCE.Focus(); + } + } + + private void Hide(object sender, RoutedEventArgs e) + { + Hide(); + } + + private void AddCountAll() + { + foreach (AutoAddSingleItem item in viewModel.ItemList) + { + if (item._parent != viewModel) + { + item._parent = viewModel; + } + } + + while (viewModel.ItemList.Count > 0) + { + viewModel.ItemList.FirstOrDefault().AddCount(false); + } + Main.dataBase.SaveAllJSONs(); + EquipmentWindow.INSTANCE.reloadItems(); + } + + private void RemoveFromParentAll() + { + foreach (AutoAddSingleItem item in viewModel.ItemList) + { + if (item._parent != viewModel) + { + item._parent = viewModel; + } + } + + while (viewModel.ItemList.Count > 0) + { + viewModel.ItemList.FirstOrDefault().Remove.Execute(null); + } + } + + // Allows the draging of the window + private new void MouseDown(object sender, MouseButtonEventArgs e) + { + if (e.ChangedButton == MouseButton.Left) + DragMove(); + } + + private void RedirectScrollToParent(object sender, MouseWheelEventArgs e) + { + object tmp = VisualTreeHelper.GetParent(sender as DependencyObject); + if (tmp is ScrollContentPresenter) + { + ScrollContentPresenter SCP = tmp as ScrollContentPresenter; + MouseWheelEventArgs eventArgs = new MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta); + eventArgs.RoutedEvent = MouseWheelEvent; + eventArgs.Source = sender; + SCP.RaiseEvent(eventArgs); + } + } + } +} diff --git a/WFInfo/Data.cs b/WFInfo/Data.cs index 55cd3deb..6ac7d870 100644 --- a/WFInfo/Data.cs +++ b/WFInfo/Data.cs @@ -1030,7 +1030,7 @@ private void LogChanged(object sender, string line) } //abort if autolist and autocsv disabled, or line doesn't contain end-of-session message or timer finished message - if (!(line.Contains("MatchingService::EndSession") || line.Contains("Relic timer closed")) || ! (_settings.AutoList || _settings.AutoCSV)) return; + if (!(line.Contains("MatchingService::EndSession") || line.Contains("Relic timer closed")) || ! (_settings.AutoList || _settings.AutoCSV || _settings.AutoCount)) return; if (Main.listingHelper.PrimeRewards == null || Main.listingHelper.PrimeRewards.Count == 0) { @@ -1039,7 +1039,7 @@ private void LogChanged(object sender, string line) Task.Run(async () => { - if (inGameName.IsNullOrEmpty()) + if (_settings.AutoList && inGameName.IsNullOrEmpty()) if (!await IsJWTvalid()) { Disconnect(); @@ -1048,6 +1048,7 @@ private void LogChanged(object sender, string line) Overlay.rewardsDisplaying = false; string csv = ""; Main.AddLog("Looping through rewards"); + Main.AddLog("AutoList: " + _settings.AutoList + ", AutoCSV: " + _settings.AutoCSV + ", AutoCount: " + _settings.AutoCount); foreach (var rewardscreen in Main.listingHelper.PrimeRewards) { string rewards = ""; @@ -1057,16 +1058,8 @@ private void LogChanged(object sender, string line) if (i + 1 < rewardscreen.Count) rewards += " || "; } - Main.AddLog(rewards); - if (_settings.AutoList) - { - - var rewardCollection = Task.Run(() => Main.listingHelper.GetRewardCollection(rewardscreen)).Result; - if (rewardCollection.PrimeNames.Count == 0) - continue; + Main.AddLog(rewards + ", detected choice: " + Main.listingHelper.SelectedRewardIndex); - Main.listingHelper.ScreensList.Add(new KeyValuePair("", rewardCollection)); - } if (_settings.AutoCSV) { @@ -1089,23 +1082,61 @@ private void LogChanged(object sender, string line) } csv += Environment.NewLine; } - + + if (_settings.AutoCount) + { + Main.RunOnUIThread(() => + { + Main.autoCount.viewModel.addItem(new AutoAddSingleItem(rewardscreen, Main.listingHelper.SelectedRewardIndex, Main.autoCount.viewModel)); + }); + } + + if (_settings.AutoList) + { + + var rewardCollection = Task.Run(() => Main.listingHelper.GetRewardCollection(rewardscreen)).Result; + if (rewardCollection.PrimeNames.Count == 0) + continue; + + Main.listingHelper.ScreensList.Add(new KeyValuePair("", rewardCollection)); + } + + } + + if (_settings.AutoCount) + { + Main.AddLog("Opening AutoCount interface"); + Main.RunOnUIThread(() => + { + AutoCount.ShowAutoCount(); + }); } if (_settings.AutoCSV) { + Main.AddLog("appending rewardExport.csv"); File.AppendAllText(applicationDirectory + @"\rewardExport.csv", csv); } + if (_settings.AutoList) + { + Main.AddLog("Opening AutoList interface"); Main.RunOnUIThread(() => { if (Main.listingHelper.ScreensList.Count == 1) Main.listingHelper.SetScreen(0); - Main.listingHelper.PrimeRewards.Clear(); Main.listingHelper.Show(); Main.listingHelper.Topmost = true; Main.listingHelper.Topmost = false; }); + } + + Main.AddLog("Clearing listingHelper.PrimeRewards"); + Main.RunOnUIThread(() => + { + Main.listingHelper.PrimeRewards.Clear(); + }); + }); } diff --git a/WFInfo/Main.cs b/WFInfo/Main.cs index 671f0283..74002994 100644 --- a/WFInfo/Main.cs +++ b/WFInfo/Main.cs @@ -27,6 +27,7 @@ class Main public static SettingsWindow settingsWindow = new SettingsWindow(); public static ThemeAdjuster themeAdjuster = new ThemeAdjuster(); public static VerifyCount verifyCount = new VerifyCount(); + public static AutoCount autoCount = new AutoCount(); public static ErrorDialogue popup; public static FullscreenReminder fullscreenpopup; public static UpdateDialogue update; @@ -311,7 +312,7 @@ public void OnMouseAction(MouseButton key) } else if (key == MouseButton.Left && OCR.Warframe != null && !OCR.Warframe.HasExited && Overlay.rewardsDisplaying) { - if (_settings.Display != Display.Overlay && !_settings.AutoList && !_settings.AutoCSV) + if (_settings.Display != Display.Overlay && !_settings.AutoList && !_settings.AutoCSV && !_settings.AutoCount) { Overlay.rewardsDisplaying = false; //only "naturally" set to false on overlay disappearing and/or specific log message with auto-list enabled return; diff --git a/WFInfo/Settings/ApplicationSettings.cs b/WFInfo/Settings/ApplicationSettings.cs index bee3b2c9..3998fa16 100644 --- a/WFInfo/Settings/ApplicationSettings.cs +++ b/WFInfo/Settings/ApplicationSettings.cs @@ -68,6 +68,7 @@ public Point MainWindowLocation public int OverlayYOffsetValue { get; set; } = 0; public bool AutoList { get; set; } = false; public bool AutoCSV { get; set; } = false; + public bool AutoCount { get; set; } = false; public bool DoDoubleCheck { get; set; } = true; public double MaximumEfficiencyValue { get; set; } = 9.5; public double MinimumEfficiencyValue { get; set; } = 4.5; diff --git a/WFInfo/Settings/IReadOnlyApplicationSettings.cs b/WFInfo/Settings/IReadOnlyApplicationSettings.cs index fec8f2d0..e2b4bded 100644 --- a/WFInfo/Settings/IReadOnlyApplicationSettings.cs +++ b/WFInfo/Settings/IReadOnlyApplicationSettings.cs @@ -43,6 +43,7 @@ public interface IReadOnlyApplicationSettings int OverlayYOffsetValue { get; } bool AutoList { get; } bool AutoCSV { get; } + bool AutoCount { get; } bool DoDoubleCheck { get; } double MaximumEfficiencyValue { get; } double MinimumEfficiencyValue { get; } diff --git a/WFInfo/Settings/SettingsViewModel.cs b/WFInfo/Settings/SettingsViewModel.cs index 002f9c1c..11e7a1ef 100644 --- a/WFInfo/Settings/SettingsViewModel.cs +++ b/WFInfo/Settings/SettingsViewModel.cs @@ -253,6 +253,15 @@ public bool AutoCSV RaisePropertyChanged(); } } + public bool AutoCount + { + get => _settings.AutoCount; + set + { + _settings.AutoCount = value; + RaisePropertyChanged(); + } + } public double MaximumEfficiencyValue { diff --git a/WFInfo/Settings/SettingsWindow.xaml b/WFInfo/Settings/SettingsWindow.xaml index 6d527576..8817d842 100644 --- a/WFInfo/Settings/SettingsWindow.xaml +++ b/WFInfo/Settings/SettingsWindow.xaml @@ -484,6 +484,10 @@ Content="Auto CSV" ToolTip="Save reward options and choice to CSV file in application directory (%appdata%/WFInfo%)" IsChecked="{Binding SettingsViewModel.AutoCSV, Mode=TwoWay}" /> + diff --git a/WFInfo/Settings/SettingsWindow.xaml.cs b/WFInfo/Settings/SettingsWindow.xaml.cs index 179cbca1..59b502ed 100644 --- a/WFInfo/Settings/SettingsWindow.xaml.cs +++ b/WFInfo/Settings/SettingsWindow.xaml.cs @@ -47,11 +47,13 @@ public void populate() autoCheckbox.IsChecked = true; Autolist.IsEnabled = true; Autocsv.IsEnabled = true; + Autoadd.IsEnabled = true; } else { Autolist.IsEnabled = false; Autocsv.IsEnabled = false; + Autoadd.IsEnabled = false; } foreach (ComboBoxItem localeItem in localeCombobox.Items) @@ -118,6 +120,7 @@ private void AutoClicked(object sender, RoutedEventArgs e) Main.dataBase.EnableLogCapture(); Autolist.IsEnabled = true; Autocsv.IsEnabled = true; + Autoadd.IsEnabled = true; } else { @@ -126,11 +129,15 @@ private void AutoClicked(object sender, RoutedEventArgs e) Main.dataBase.DisableLogCapture(); Autolist.IsEnabled = false; Autocsv.IsEnabled = false; + Autoadd.IsEnabled = false; } } else { _viewModel.Auto = false; + Autolist.IsEnabled = false; + Autocsv.IsEnabled = false; + Autoadd.IsEnabled = false; Main.dataBase.DisableLogCapture(); } Save(); From 73872c9a1ec2fa5695601b83c92cb07d9dd8d08b Mon Sep 17 00:00:00 2001 From: D1firehail Date: Mon, 20 Feb 2023 17:54:28 +0100 Subject: [PATCH 10/15] capitalization --- WFInfo/Settings/SettingsWindow.xaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/WFInfo/Settings/SettingsWindow.xaml b/WFInfo/Settings/SettingsWindow.xaml index 8817d842..e6c70fb9 100644 --- a/WFInfo/Settings/SettingsWindow.xaml +++ b/WFInfo/Settings/SettingsWindow.xaml @@ -477,7 +477,7 @@ ToolTip="Automatically detects when the relic screen is visible." Click="AutoClicked" /> From c69554c84e345a56cd251fac0115c6113ecec5fb Mon Sep 17 00:00:00 2001 From: D1firehail Date: Mon, 20 Feb 2023 18:41:26 +0100 Subject: [PATCH 11/15] remove test fill code from AutoCount --- WFInfo/AutoCount.xaml.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/WFInfo/AutoCount.xaml.cs b/WFInfo/AutoCount.xaml.cs index 5ffe8174..ea87d818 100644 --- a/WFInfo/AutoCount.xaml.cs +++ b/WFInfo/AutoCount.xaml.cs @@ -37,7 +37,8 @@ public AutoCount() RemoveAll = new SimpleCommand(() => RemoveFromParentAll()); IncrementAll = new SimpleCommand(() => AddCountAll()); - for (int i = 0; i < 30; i++) + /* + for (int i = 0; i < 30; i++) //test fill block { List tmp = new List(); tmp.Add("Ivara Prime Blueprint"); @@ -46,6 +47,7 @@ public AutoCount() AutoAddSingleItem tmpItem = new AutoAddSingleItem(tmp, i % 5, viewModel); viewModel.addItem(tmpItem); } + */ InitializeComponent(); } public static void ShowAutoCount() From 2797b9e5f1e2455a629d44090e161dbe5cb310dc Mon Sep 17 00:00:00 2001 From: D1firehail Date: Mon, 20 Feb 2023 18:42:45 +0100 Subject: [PATCH 12/15] auto-add title --- WFInfo/AutoCount.xaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WFInfo/AutoCount.xaml b/WFInfo/AutoCount.xaml index 3fee8d76..477317c9 100644 --- a/WFInfo/AutoCount.xaml +++ b/WFInfo/AutoCount.xaml @@ -124,7 +124,7 @@ Style="{StaticResource Label_Button}" VerticalContentAlignment="Stretch" DockPanel.Dock="Right" /> - Date: Mon, 20 Feb 2023 18:43:37 +0100 Subject: [PATCH 13/15] other auto-add title --- WFInfo/AutoCount.xaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WFInfo/AutoCount.xaml b/WFInfo/AutoCount.xaml index 477317c9..9bc512ce 100644 --- a/WFInfo/AutoCount.xaml +++ b/WFInfo/AutoCount.xaml @@ -6,7 +6,7 @@ xmlns:wfInfo="clr-namespace:WFInfo" xmlns:components="clr-namespace:WFInfo.Components" mc:Ignorable="d" - Title="Theme Adjuster" + Title="Auto Add" MaxWidth="400" MinWidth="400" Width="400" From bbf234c2e803d33cb3d4a3dcbd690364c1bddf85 Mon Sep 17 00:00:00 2001 From: Dmitry Romanenko Date: Mon, 20 Feb 2023 21:51:45 +0000 Subject: [PATCH 14/15] Fix the old typo --- WFInfo/Ocr.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WFInfo/Ocr.cs b/WFInfo/Ocr.cs index d7fbca4c..02d76b39 100644 --- a/WFInfo/Ocr.cs +++ b/WFInfo/Ocr.cs @@ -262,7 +262,7 @@ internal static void ProcessRewardScreen(Bitmap file = null) int duc = int.Parse(ducats, Main.culture); #endregion - #region hilighting + #region highlighting if (platinum >= bestPlat) { bestPlat = platinum; bestPlatItem = i; From 19e1f2f85c4475d998f50bcc77d136940724db80 Mon Sep 17 00:00:00 2001 From: D1firehail Date: Tue, 21 Feb 2023 15:03:52 +0100 Subject: [PATCH 15/15] reset reward choice without auto-list, treat unknown theme as custom --- WFInfo/Data.cs | 3 +++ WFInfo/Ocr.cs | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/WFInfo/Data.cs b/WFInfo/Data.cs index 4a5909d6..01e8e261 100644 --- a/WFInfo/Data.cs +++ b/WFInfo/Data.cs @@ -1107,6 +1107,9 @@ private void LogChanged(object sender, string line) continue; Main.listingHelper.ScreensList.Add(new KeyValuePair("", rewardCollection)); + } else + { + Main.listingHelper.SelectedRewardIndex = 0; //otherwise done by GetRewardCollection, but that calls WFM API } } diff --git a/WFInfo/Ocr.cs b/WFInfo/Ocr.cs index ab8f6f72..b6bb493c 100644 --- a/WFInfo/Ocr.cs +++ b/WFInfo/Ocr.cs @@ -1815,7 +1815,7 @@ private static List FindOwnedItems(Bitmap ProfileImage, string ti return foundItems; } - private static int ColorDifference(Color test, Color thresh) + private static int ColorDifference(Color test, Color thresh) { return Math.Abs(test.R - thresh.R) + Math.Abs(test.G - thresh.G) + Math.Abs(test.B - thresh.B); } @@ -1860,7 +1860,7 @@ public static bool CustomThresholdFilter(Color test) public static bool ThemeThresholdFilter(Color test, WFtheme theme) { - if (theme == WFtheme.CUSTOM) + if (theme == WFtheme.CUSTOM || theme == WFtheme.UNKNOWN) //treat unknown as custom, for safety return CustomThresholdFilter(test); Color primary = ThemePrimary[(int)theme]; Color secondary = ThemeSecondary[(int)theme];