Changeset - f1323ba34306
[Not reviewed]
default
0 8 0
Jason Maltzen - 5 years ago 2019-11-07 16:31:54
jason@hiddenachievement.com
Improved logging, sanity checking of settings (especially pixel multiplier), updated readme with some additional details on advanced settings.
8 files changed with 157 insertions and 95 deletions:
0 comments (0 inline, 0 general)
AppSettings.cs
Show inline comments
...
 
@@ -9,15 +9,21 @@ namespace DesertPaintLab
 
        }
 

	
 
        private static Settings _settings = new Settings();
 

	
 
        public static void Get(string key, out int value)
 
        public static void Get(string key, out int value, int defaultValue)
 
        {
 
            _settings.Get(key, out value);
 
            if (!_settings.TryGet(key, out value))
 
            {
 
                value = defaultValue;
 
            }
 
        }
 
        public static void Get(string key, out bool value)
 
        public static void Get(string key, out bool value, bool defaultValue)
 
        {
 
            _settings.Get(key, out value);
 
            if (!_settings.TryGet(key, out value))
 
            {
 
                value = defaultValue;
 
            }
 
        }
 
        public static void Set(string key, int value)
 
        {
 
            _settings.Set(key, value);
...
 
@@ -31,9 +37,9 @@ namespace DesertPaintLab
 
        {
 
            string settingsPath = System.IO.Path.Combine(FileUtils.AppDataPath, "settings");
 
            _settings.Save(settingsPath);
 
        }
 
        
 

 
        public static bool Load()
 
        {
 
            string settingsPath = System.IO.Path.Combine(FileUtils.AppDataPath, "settings");
 
            return _settings.Load(settingsPath);
MainWindow.cs
Show inline comments
...
 
@@ -112,9 +112,9 @@ public partial class MainWindow : Gtk.Wi
 

	
 
        ShowPreferencesDialog();
 

	
 
        bool enableDebugMenu;
 
        AppSettings.Get("EnableDebugMenu", out enableDebugMenu);
 
        AppSettings.Get("EnableDebugMenu", out enableDebugMenu, false);
 
        this.DebugAction.Visible = enableDebugMenu;
 

	
 
        ReactionRecorder.Instance.OnReactionRecorded += OnReactionRecorded;
 

	
...
 
@@ -349,11 +349,12 @@ public partial class MainWindow : Gtk.Wi
 

	
 
    protected virtual void OnDebugScreenshot(object sender, System.EventArgs e)
 
    {
 
        int screenWidth, screenHeight;
 
        rootWindow.GetSize(out screenWidth, out screenHeight);
 
        DesertPaintLab.AppSettings.Get("ScreenWidth", out screenWidth);
 
        DesertPaintLab.AppSettings.Get("ScreenHeight", out screenHeight);
 
        int windowScreenWidth, windowScreenHeight;
 
        rootWindow.GetSize(out windowScreenWidth, out windowScreenHeight);
 
        AppSettings.Get("ScreenWidth", out screenWidth, windowScreenWidth);
 
        AppSettings.Get("ScreenHeight", out screenHeight, windowScreenHeight);
 
        Gdk.Image rootImage = rootWindow.GetImage(0, 0, screenWidth, screenHeight);
 
        screenBuffer.GetFromImage(rootImage, rootImage.Colormap, 0, 0, 0, 0, screenWidth, screenHeight);
 
        string screenshotDir = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
 
        string filename;
...
 
@@ -724,14 +725,17 @@ public partial class MainWindow : Gtk.Wi
 
        int screenHeight = detectedScreenHeight;
 
        int pixelMultiplier = 1;
 
        int interfaceSizeIndex = (int)(InterfaceSize.Small);
 

	
 
        AppSettings.Get("ScreenWidth", out screenWidth);
 
        AppSettings.Get("ScreenHeight", out screenHeight);
 
        AppSettings.Get("PixelMultiplier", out pixelMultiplier);
 
        AppSettings.Get("InterfaceSize", out interfaceSizeIndex);
 
        AppSettings.Get("ScreenWidth", out screenWidth, detectedScreenWidth);
 
        AppSettings.Get("ScreenHeight", out screenHeight, detectedScreenHeight);
 
        AppSettings.Get("PixelMultiplier", out pixelMultiplier, 1);
 
        AppSettings.Get("InterfaceSize", out interfaceSizeIndex, (int)InterfaceSize.Small);
 
        InterfaceSize interfaceSize = (InterfaceSize)interfaceSizeIndex;
 

	
 
        // Sanitize
 
        pixelMultiplier = Math.Max(1, Math.Min(pixelMultiplier, 4));
 

	
 
        ScreenCheckDialog screenCheckDialog = new ScreenCheckDialog {
 
            DetectedScreenWidth = detectedScreenWidth,
 
            DetectedScreenHeight = detectedScreenHeight,
 
            ScreenWidth = screenWidth,
...
 
@@ -763,17 +767,17 @@ public partial class MainWindow : Gtk.Wi
 
    protected void OnPreferences(object sender, EventArgs e)
 
    {
 
        ShowPreferencesDialog();
 

	
 
        int screenWidth = 1920;
 
        int screenHeight = 1080;
 
        int pixelMultiplier = 1;
 
        int interfaceSizeIndex = (int)(InterfaceSize.Small);
 
        int screenWidth;
 
        int screenHeight;
 
        int pixelMultiplier;
 
        int interfaceSizeIndex;
 

	
 
        AppSettings.Get("ScreenWidth", out screenWidth);
 
        AppSettings.Get("ScreenHeight", out screenHeight);
 
        AppSettings.Get("PixelMultiplier", out pixelMultiplier);
 
        AppSettings.Get("InterfaceSize", out interfaceSizeIndex);
 
        AppSettings.Get("ScreenWidth", out screenWidth, 1920);
 
        AppSettings.Get("ScreenHeight", out screenHeight, 1080);
 
        AppSettings.Get("PixelMultiplier", out pixelMultiplier, 1);
 
        AppSettings.Get("InterfaceSize", out interfaceSizeIndex, (int)InterfaceSize.Small);
 

	
 
        captureView.ScreenBuffer = screenBuffer;
 
    }
 
}
README.md
Show inline comments
...
 
@@ -103,9 +103,9 @@ When you're done testing your reactions,
 
## Known Issues
 

	
 
### Slowness
 

	
 
If you are running on a multi-screen system, or a very high-resolution screen, you may find that Desert Paint Lab is rather slow in determining paint reactions.  That's because you have a lot of screen real-estate to scan, to look for the Pigment Lab dialog.  You can speed up the scanning process by ensuring that your Pigment Lab Dialog is as far to the upper-left of the screen as possible.
 
If you are running on a multi-screen system, or a very high-resolution screen, you may find that Desert Paint Lab is rather slow in determining paint reactions.  That's because you have a lot of screen real-estate to scan, to look for the Pigment Lab dialog.  You can speed up the scanning process by ensuring that your Pigment Lab Dialog is as far to the upper-left of the screen as possible. Also see the advanced settings (below) for some additional options that may help.
 

	
 
### Multiple Displays
 

	
 
When Desert Paint Lab asks for the resolution for a multiple-display setup, enter the combined resolution of all displays. Generally the detected default for this will be correct. For example, two 1920x1080 displays in a side-by-side configuration would be a combined resolution of 3840x1080. In a stacked configuration, they would be 1920x2160.
...
 
@@ -119,7 +119,19 @@ High DPI screens may be displaying the g
 
Q: How do I find my native screen resolution?
 

	
 
A: You can find it by opening up "About this Mac" from the Apple menu and clicking on the "Displays" tab. That should show the screen size and resolution to enter.
 

	
 
## Advanced Settings
 

	
 
The settings file has several advanced options that are not available in the interface. Some of these are for debugging, while others are useful for improving the speed of finding the pigment lab interface. The settings file is found in AppData\Local\DesertPaintLab\settings on Windows, and in ~/.local/share/DesertPaintLab/settings on macOS.
 

	
 
* _scanarea.min.x_ sets the starting horizontal offset when searching for the pigment lab. This is useful in multi-screen setups to skip any leftmost displays. For example, a dual-screen setup with two side-by-side 3840x2160 displays where the game runs on the right screen would set this to 3840 to bypass scanning the left display.
 
* _scanarea.min.y_ Like scanarea.min.x, but skips the upper section of display
 
* _scanarea.max.x_ defines the rightmost edge of the area to scan
 
* _scanarea.max.y_ defines the bottom edge of the area to scan
 
* _enabledebugmenu_ enables debug tool menu to help track down problems. This also causes DPL to write debug log files during scanning and recipe generation. This can slow down scanning and recipe searching.
 
* _debugscreenshot_ automatically saves out a screenshot when searching for the pigment lab to help in debugging
 
* _logging.verbosity_ sets the verbosity of the logging between 0 and 3. The higher the value, the more detail is included in the log file.
 

	
 
## For Developers
 

	
 
This application was developed using [MonoDevelop](http://www.monodevelop.com/), and originally used the [Stetic GTK UI designer](http://www.monodevelop.com/documentation/stetic-gui-designer/).
ReactionRecorder.cs
Show inline comments
...
 
@@ -30,8 +30,16 @@ namespace DesertPaintLab
 
    {
 
        public delegate void CaptureProgressHandler(int x, int y);
 
        public CaptureProgressHandler OnCaptureProgress;
 

	
 
        public enum LogVerbosity
 
        {
 
            Low,
 
            Normal,
 
            High,
 
            Excessive
 
        }
 

	
 
        const int COLOR_TOLERANCE = 3;
 

	
 
        const InterfaceSize DEFAULT_INTERFACE_SIZE = InterfaceSize.Small;
 

	
...
 
@@ -156,8 +164,10 @@ namespace DesertPaintLab
 
        int lastSwatchY = -1;
 
        public int SwatchX { get { return lastSwatchX; } }
 
        public int SwatchY { get { return lastSwatchY; } }
 

	
 
        private LogVerbosity logVerbosity = LogVerbosity.Normal;
 

	
 
        private class PixelColor
 
        {
 
            public byte r;
 
            public byte g;
...
 
@@ -305,11 +315,11 @@ namespace DesertPaintLab
 
            }
 
        }
 

	
 
        public StreamWriter Log { get; set; }
 
        private void WriteLog(string format, params object[] args)
 
        private void WriteLog(LogVerbosity verbosity, string format, params object[] args)
 
        {
 
            if (Log != null)
 
            if ((Log != null) && (verbosity <= logVerbosity))
 
            {
 
                Log.WriteLine(format, args);
 
            }
 
        }
...
 
@@ -402,9 +412,9 @@ namespace DesertPaintLab
 
            }
 

	
 
            if (!result)
 
            {
 
                WriteLog("Swatch slice at {0}, {1} failed to match", x, y);
 
                WriteLog(LogVerbosity.Normal, "Swatch slice at {0}, {1} failed to match", x, y);
 
            }
 

	
 
            return result;
 
        }
...
 
@@ -414,9 +424,9 @@ namespace DesertPaintLab
 
            int testPixelStart = pixels.ComputeOffset(x, y);
 

	
 
            if (testPixelStart < pixels.stride)
 
            {
 
                WriteLog("Can't test {0},{1} - is not at least 1 row in", x, y);
 
                WriteLog(LogVerbosity.Normal, "Can't test {0},{1} - is not at least 1 row in", x, y);
 
                return false;
 
            }
 

	
 
            bool result = true;
...
 
@@ -433,33 +443,33 @@ namespace DesertPaintLab
 

	
 
            // Check the other 3 corners of the swatch size for color match
 
            PixelColor testColor = new PixelColor();
 
            bool upperRightResult = pixels.DoesPixelMatch(swatchSolidRightX, swatchSolidTopY, swatchColor.IsMatch);
 
            //if (!upperRightResult)
 
            //{
 
            //    pixels.ColorAt(swatchSolidRightX, swatchSolidTopY, ref testColor);
 
            //    WriteLog("Upper-right mismatch for {8}, {9} - found {0},{1},{2} at {3}, {4} expected {5},{6},{7}", testColor.r, testColor.g, testColor.b, swatchSolidRightX, swatchSolidTopY, swatchColor.r, swatchColor.g, swatchColor.b, x, y);
 
            //}
 
            if (!upperRightResult)
 
            {
 
                pixels.ColorAt(swatchSolidRightX, swatchSolidTopY, ref testColor);
 
                WriteLog(LogVerbosity.Excessive, "Upper-right mismatch for {8}, {9} - found {0},{1},{2} at {3}, {4} expected {5},{6},{7}", testColor.r, testColor.g, testColor.b, swatchSolidRightX, swatchSolidTopY, swatchColor.r, swatchColor.g, swatchColor.b, x, y);
 
            }
 
            bool lowerLeftResult = pixels.DoesPixelMatch(swatchSolidLeftX, swatchSolidBottomY, swatchColor.IsMatch);
 
            //if (!lowerLeftResult)
 
            //{
 
            //    pixels.ColorAt(swatchSolidLeftX, swatchSolidBottomY, ref testColor);
 
            //    WriteLog("Lower-left mismatch for {8}, {9} - found {0},{1},{2} at {3}, {4} expected {5},{6},{7}", testColor.r, testColor.g, testColor.b, swatchSolidLeftX, swatchSolidBottomY, swatchColor.r, swatchColor.g, swatchColor.b, x, y);
 
            //}
 
            if (!lowerLeftResult)
 
            {
 
                pixels.ColorAt(swatchSolidLeftX, swatchSolidBottomY, ref testColor);
 
                WriteLog(LogVerbosity.Excessive, "Lower-left mismatch for {8}, {9} - found {0},{1},{2} at {3}, {4} expected {5},{6},{7}", testColor.r, testColor.g, testColor.b, swatchSolidLeftX, swatchSolidBottomY, swatchColor.r, swatchColor.g, swatchColor.b, x, y);
 
            }
 
            bool lowerRightResult = pixels.DoesPixelMatch(swatchSolidRightX, swatchSolidBottomY, swatchColor.IsMatch);
 
            //if (!lowerRightResult)
 
            //{
 
            //    pixels.ColorAt(swatchSolidRightX, swatchSolidBottomY, ref testColor);
 
            //    WriteLog("Lower-right mismatch for {8}, {9} - found {0},{1},{2} at {3}, {4} expected {5},{6},{7}", testColor.r, testColor.g, testColor.b, swatchSolidRightX, swatchSolidBottomY, swatchColor.r, swatchColor.g, swatchColor.b, x, y);
 
            //}
 
            if (!lowerRightResult)
 
            {
 
                pixels.ColorAt(swatchSolidRightX, swatchSolidBottomY, ref testColor);
 
                WriteLog(LogVerbosity.Excessive, "Lower-right mismatch for {8}, {9} - found {0},{1},{2} at {3}, {4} expected {5},{6},{7}", testColor.r, testColor.g, testColor.b, swatchSolidRightX, swatchSolidBottomY, swatchColor.r, swatchColor.g, swatchColor.b, x, y);
 
            }
 

	
 
            result &= upperRightResult;
 
            result &= lowerLeftResult;
 
            result &= lowerRightResult;
 
            if (!result)
 
            {
 
                // Box corners test failed
 
                // WriteLog("Failed to find left edge for potential swatch of color {2}, {3}, {4} at {0}, {1}", x, y, swatch_r, swatch_g, swatch_b);
 
                WriteLog(LogVerbosity.High, "Failed to find left edge for potential swatch of color {2}, {3}, {4} at {0}, {1}", x, y, swatchColor.r, swatchColor.g, swatchColor.b);
 
                return false;
 
            }
 

	
 
            // scan down the right and left sides
...
 
@@ -478,9 +488,9 @@ namespace DesertPaintLab
 
                }
 
            }
 
            if (!result)
 
            {
 
                WriteLog("Failed to find left/right edges for potential swatch of color {2}, {3}, {4} at {0}, {1} [failed color = {5},{6},{7}]", x, y, swatchColor.r, swatchColor.g, swatchColor.b, testColor.r, testColor.g, testColor.b);
 
                WriteLog(LogVerbosity.Normal, "Failed to find left/right edges for potential swatch of color {2}, {3}, {4} at {0}, {1} [failed color = {5},{6},{7}]", x, y, swatchColor.r, swatchColor.g, swatchColor.b, testColor.r, testColor.g, testColor.b);
 
                return false;
 
            }
 
            for (int xOff = 1; xOff < (swatchSolidWidth - 1); ++xOff)
 
            {
...
 
@@ -498,9 +508,9 @@ namespace DesertPaintLab
 
                }
 
            }
 
            if (!result)
 
            {
 
                WriteLog("Failed to match upper/lower edges for potential swatch of color {2}, {3}, {4} at {0}, {1} [failed color = {5},{6},{7}]", x, y, swatchColor.r, swatchColor.g, swatchColor.b, testColor.r, testColor.g, testColor.b);
 
                WriteLog(LogVerbosity.Normal, "Failed to match upper/lower edges for potential swatch of color {2}, {3}, {4} at {0}, {1} [failed color = {5},{6},{7}]", x, y, swatchColor.r, swatchColor.g, swatchColor.b, testColor.r, testColor.g, testColor.b);
 
                return false;
 
            }
 

	
 

	
...
 
@@ -512,9 +522,9 @@ namespace DesertPaintLab
 
            }
 
            if (!result)
 
            {
 
                // No dark border on the left side
 
                WriteLog("Failed to find left border for potential swatch of color {2}, {3}, {4} at {0}, {1}", x, y, swatchColor.r, swatchColor.g, swatchColor.b);
 
                WriteLog(LogVerbosity.Normal, "Failed to find left border for potential swatch of color {2}, {3}, {4} at {0}, {1}", x, y, swatchColor.r, swatchColor.g, swatchColor.b);
 
                return false;
 
            }
 

	
 
            // test the dark top border and for papyrus above and below the swatch
...
 
@@ -525,9 +535,9 @@ namespace DesertPaintLab
 
                bool isBorder = pixels.DoesPixelMatch(x + i, y, PixelColor.IsDark);
 
                result &= isBorder;
 
                if (!isBorder)
 
                {
 
                    WriteLog("Probably swatch at {0},{1} failed upper border test at {2},{3}", x, y, x + i, y);
 
                    WriteLog(LogVerbosity.Normal, "Probable swatch at {0},{1} failed upper border test at {2},{3}", x, y, x + i, y);
 
                    borderError = true;
 
                }
 

	
 
                // Checking along the top of the swatch for papyrus
...
 
@@ -559,9 +569,9 @@ namespace DesertPaintLab
 
            if (!result && ((i > (swatchWidth*0.8)) || (papyErrorCount >= (swatchWidth/20))))
 
            {
 
                if (!borderError && (papyErrorCount < swatchWidth))
 
                {
 
                    WriteLog("Found a potential swatch candidate of width {0} at {1},{2} that had {3} failures matching papyrus texture", i, x, y, papyErrorCount);
 
                    WriteLog(LogVerbosity.Normal, "Found a potential swatch candidate of width {0} at {1},{2} that had {3} failures matching papyrus texture", i, x, y, papyErrorCount);
 
                }
 
            }
 

	
 
            return result;
...
 
@@ -574,22 +584,22 @@ namespace DesertPaintLab
 
            // Check 4 corners of solid area and left/right solid bar areas
 
            bool foundSwatch = IsPossibleSwatchUpperLeft(pixels, x, y); // ((pixel_r < 0x46) && (pixel_g < 0x46) && (pixel_b < 0x46));
 
            if (foundSwatch)
 
            {
 
                WriteLog("Found probable swatch at {0},{1} - checking border slices", x, y);
 
                WriteLog(LogVerbosity.Normal, "Found probable swatch at {0},{1} - checking border slices", x, y);
 
                int borderXOffset = 0;
 
                for (borderXOffset = 2; foundSwatch && (borderXOffset < swatchTestWidth); ++borderXOffset)
 
                {
 
                    foundSwatch &= IsPossibleSwatchSlice(pixels, x + borderXOffset, y);
 
                    if (!foundSwatch)
 
                    {
 
                        WriteLog("Failed slice test at {0},{1}", x + borderXOffset, y);
 
                        WriteLog(LogVerbosity.Normal, "Failed slice test at {0},{1}", x + borderXOffset, y);
 
                        break;
 
                    }
 
                    foundSwatch &= IsPossibleSwatchSlice(pixels, x + swatchWidth - borderXOffset, y);
 
                    if (!foundSwatch)
 
                    {
 
                        WriteLog("Failed slice test at {0},{1}", x + swatchWidth - borderXOffset, y);
 
                        WriteLog(LogVerbosity.Normal, "Failed slice test at {0},{1}", x + swatchWidth - borderXOffset, y);
 
                        break;
 
                    }
 
                }
 
            }
...
 
@@ -605,9 +615,9 @@ namespace DesertPaintLab
 
                reactedColor.Green = (byte)Math.Round((float)greenPixelCount * 255f / (float)colorBarWidth);
 

	
 
                int bluePixelCount = pixels.LengthOfColorAt(x, y + blueBarSpacing, PixelColor.IsBlue);
 
                reactedColor.Blue = (byte)Math.Round((float)bluePixelCount * 255f / (float)colorBarWidth);
 
                WriteLog("Found the color swatch at {0}, {1}. Color={2} Red={3}px Green={4}px Blue={5}px", x, y, reactedColor, redPixelCount, greenPixelCount, bluePixelCount);
 
                WriteLog(LogVerbosity.Low, "Found the color swatch at {0}, {1}. Color={2} Red={3}px Green={4}px Blue={5}px", x, y, reactedColor, redPixelCount, greenPixelCount, bluePixelCount);
 
                return true;
 
            }
 
            return false;
 
        }
...
 
@@ -647,24 +657,24 @@ namespace DesertPaintLab
 
                    firstRun = true;
 
                }
 
            }
 

	
 
            int verbosityIdx;
 
            AppSettings.Get("Log.Verbosity", out verbosityIdx, 1);
 
            logVerbosity = (LogVerbosity)verbosityIdx;
 

	
 
            int startX;
 
            int endX;
 
            int startY;
 
            int endY;
 
            DesertPaintLab.AppSettings.Get("ScanOffsetX", out startX);
 
            DesertPaintLab.AppSettings.Get("ScanOffsetY", out startY);
 
            DesertPaintLab.AppSettings.Get("ScanLimitX", out endX);
 
            DesertPaintLab.AppSettings.Get("ScanLimitY", out endY);
 
            if (endX == 0) endX = screenshotWidth;
 
            if (endY == 0) endY = screenshotHeight;
 
            if (endX > screenshotWidth) endX = screenshotWidth;
 
            if (endY > screenshotHeight) endY = screenshotHeight;
 
            if (startX < 2) startX = 2;
 
            if (startY < 2) startY = 2;
 
            if (startX > screenshotWidth) startX = 2;
 
            if (startY > screenshotHeight) startY = 2;
 
            AppSettings.Get("ScanArea.Min.X", out startX, 0);
 
            AppSettings.Get("ScanArea.Min.Y", out startY, 0);
 
            AppSettings.Get("ScanArea.Max.X", out endX, screenshotWidth);
 
            AppSettings.Get("ScanArea.Max.Y", out endY, screenshotHeight);
 
            startX = Math.Max(2, Math.Min(startX, screenshotWidth-2));
 
            startY = Math.Max(2, Math.Min(startY, screenshotHeight-2));
 
            endX = Math.Min(screenshotWidth-2, Math.Max(2, endX));
 
            endY = Math.Min(screenshotHeight-2, Math.Max(2, endY));
 

	
 
            int patchTestSize = ((swatchHeight - 5) / 2) - 1;
 
            PixelColor patchColor = new PixelColor();
 
            for (int roughX = startX; roughX < endX - colorBarWidth + patchTestSize; roughX += patchTestSize)
...
 
@@ -673,14 +683,14 @@ namespace DesertPaintLab
 
                {
 
                    OnCaptureProgress?.Invoke(roughX, roughY);
 
                    if (!pixels.IsSolidPatchAt(roughX, roughY, patchTestSize, patchTestSize)) continue;
 
                    pixels.ColorAt(roughX, roughY, ref patchColor);
 
                    //Console.WriteLine("Found a solid patch of {2},{3},{4} at {0}, {1}", roughX, roughY, patchColor.r, patchColor.g, patchColor.b);
 
                    WriteLog(LogVerbosity.Excessive, "Found a solid patch of {2},{3},{4} at {0}, {1}", roughX, roughY, patchColor.r, patchColor.g, patchColor.b);
 
                    for (X = Math.Max(0, roughX - patchTestSize); X < roughX; ++X)
 
                    {
 
                        for (Y = Math.Max(0, roughY - patchTestSize); Y < roughY; ++Y)
 
                        {
 
                            //WriteLog("Checking for potential swatch at {0},{1} after found square at {2},{3}", X, Y, roughX, roughY);
 
                            WriteLog(LogVerbosity.Excessive, "Searching for potential swatch at {0},{1} after found square at {2},{3}", X, Y, roughX, roughY);
 
                            if (TestPosition(X, Y, pixels, ref reactedColor, ref redPixelStart))
 
                            {
 
                                RedBarX = (redPixelStart % stride) / numChannels;
 
                                RedBarY = redPixelStart / stride;
...
 
@@ -692,9 +702,9 @@ namespace DesertPaintLab
 
                                return true;
 
                            }
 
                        }
 
                    }
 
                    //System.Console.WriteLine("False-positive patch of color {0},{1},{2} at {3},{4}", patchColor.r, patchColor.g, patchColor.b, roughX, roughY);
 
                    WriteLog(LogVerbosity.Excessive, "False-positive patch of color {0},{1},{2} at {3},{4}", patchColor.r, patchColor.g, patchColor.b, roughX, roughY);
 
                }
 
            }
 
            return false;
 
        }
Settings.cs
Show inline comments
...
 
@@ -12,25 +12,29 @@ namespace DesertPaintLab
 
        }
 

	
 
        private Dictionary<string, string> _settings = new Dictionary<string, string>();
 

	
 
        public void Get(string key, out int value)
 
        public bool TryGet(string key, out int value)
 
        {
 
            value = 0;
 
            string valStr;
 
            if ( _settings.TryGetValue(key.ToLower(), out valStr) )
 
            bool found = _settings.TryGetValue(key.ToLower(), out valStr);
 
            if (found)
 
            {
 
                Int32.TryParse(valStr, out value);
 
            }
 
            return found;
 
        }
 
        public void Get(string key, out bool value)
 
        public bool TryGet(string key, out bool value)
 
        {
 
            value = false;
 
            string valStr;
 
            if ( _settings.TryGetValue(key.ToLower(), out valStr) )
 
            bool found = _settings.TryGetValue(key.ToLower(), out valStr);
 
            if (found)
 
            {
 
                Boolean.TryParse(valStr, out value);
 
            }
 
            return found;
 
        }
 
        public void Set(string key, int value)
 
        {
 
            _settings[key.ToLower()] = value.ToString();
UI/CaptureView.cs
Show inline comments
...
 
@@ -275,10 +275,10 @@ namespace DesertPaintLab
 

	
 
            progressBar.Show();
 
            recordButton.Hide();
 

	
 
            bool enableDebugMenu = false;
 
            DesertPaintLab.AppSettings.Get("EnableDebugMenu", out enableDebugMenu);
 
            bool enableDebugMenu;
 
            AppSettings.Get("EnableDebugMenu", out enableDebugMenu, false);
 

	
 
            StreamWriter log = null;
 
            if (enableDebugMenu)
 
            {
...
 
@@ -346,12 +346,12 @@ namespace DesertPaintLab
 
                log = null;
 
                ReactionRecorder.Instance.Log = null;
 
            }
 

	
 
            bool enableDebugMenu = false;
 
            DesertPaintLab.AppSettings.Get("EnableDebugMenu", out enableDebugMenu);
 
            bool debugScreenshot = false;
 
            DesertPaintLab.AppSettings.Get("DebugScreenshot", out debugScreenshot);
 
            bool enableDebugMenu;
 
            DesertPaintLab.AppSettings.Get("EnableDebugMenu", out enableDebugMenu, false);
 
            bool debugScreenshot;
 
            DesertPaintLab.AppSettings.Get("DebugScreenshot", out debugScreenshot, false);
 
            if (enableDebugMenu && debugScreenshot)
 
            {
 
                if (!isCaptured)
 
                {
...
 
@@ -472,21 +472,21 @@ namespace DesertPaintLab
 
        {
 
            // Take a screenshot.
 
            int screenWidth, screenHeight;
 
            Gdk.Window rootWindow = Gdk.Global.DefaultRootWindow;
 
            DesertPaintLab.AppSettings.Get("ScreenWidth", out screenWidth);
 
            DesertPaintLab.AppSettings.Get("ScreenHeight", out screenHeight);
 
            AppSettings.Get("ScreenWidth", out screenWidth, 1920);
 
            AppSettings.Get("ScreenHeight", out screenHeight, 1080);
 
            Gdk.Image rootImage = rootWindow.GetImage(0, 0, screenWidth, screenHeight);
 
            RecordBuffer = screenBuffer;
 
            RecordBuffer.GetFromImage(rootImage, rootImage.Colormap, 0, 0, 0, 0, screenWidth, screenHeight);
 
            rootImage.Unref();
 
            System.GC.Collect(); // really, clean up now
 

	
 
            int pixelMultiplier;
 
            AppSettings.Get("PixelMultiplier", out pixelMultiplier);
 
            AppSettings.Get("PixelMultiplier", out pixelMultiplier, 1);
 
            if (pixelMultiplier == 0) pixelMultiplier = 1;
 
            int interfaceSizeIndex = 1;
 
            AppSettings.Get("InterfaceSize", out interfaceSizeIndex);
 
            int interfaceSizeIndex;
 
            AppSettings.Get("InterfaceSize", out interfaceSizeIndex, (int)InterfaceSize.Small);
 
            InterfaceSize interfaceSize = (InterfaceSize)interfaceSizeIndex;
 
            ReactionRecorder.Instance.PixelMultiplier = pixelMultiplier;
 
            ReactionRecorder.Instance.InterfaceSize = interfaceSize;
 

	
UI/RecipeGeneratorView.cs
Show inline comments
...
 
@@ -112,9 +112,9 @@ namespace DesertPaintLab
 
            pauseForCheckpoint = false;
 

	
 
            generator = new RecipeGenerator(profile.Reactions);
 
            int threads;
 
            DesertPaintLab.AppSettings.Get("GeneratorThreads", out threads);
 
            DesertPaintLab.AppSettings.Get("GeneratorThreads", out threads, 15);
 
            if (threads <= 0) { threads = 15; }
 
            generator.MaxThreads = (uint)threads;
 
            generator.InitRecipes(profile.Recipes);
 

	
...
 
@@ -210,9 +210,9 @@ namespace DesertPaintLab
 
            reagentListView.AppendColumn(reagentCostColumn);
 
            reagentListView.AppendColumn(reagentMaxColumn);
 

	
 
            bool ribbons = false;
 
            profile.ProfileSettings.Get("Generator.Ribbons", out ribbons);
 
            bool foundSetting = profile.ProfileSettings.TryGet("Generator.Ribbons", out ribbons);
 
            if (ribbons)
 
            {
 
                checkButtonRibbon.Active = true;
 
                InitStateForRibbons();
...
 
@@ -233,20 +233,20 @@ namespace DesertPaintLab
 
            if (generator == null)
 
            {
 
                generator = new RecipeGenerator(profile.Reactions);
 
                int threads;
 
                DesertPaintLab.AppSettings.Get("GeneratorThreads", out threads);
 
                AppSettings.Get("GeneratorThreads", out threads, 15);
 
                if (threads <= 0) { threads = 15; }
 
                generator.MaxThreads = (uint)threads;
 

	
 
                generator.Progress += OnProgress;
 
                generator.Finished += OnFinished;
 
                generator.NewRecipe += OnNewRecipe;
 

	
 
                bool enableDebugMenu = false;
 
                DesertPaintLab.AppSettings.Get("EnableDebugMenu", out enableDebugMenu);
 
                bool logGenerator = false;
 
                DesertPaintLab.AppSettings.Get("GeneratorLog", out logGenerator);
 
                bool enableDebugMenu;
 
                AppSettings.Get("EnableDebugMenu", out enableDebugMenu, false);
 
                bool logGenerator;
 
                AppSettings.Get("GeneratorLog", out logGenerator, false);
 
                if (enableDebugMenu && logGenerator)
 
                {
 
                    string logDir = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
 
                    generator.Log = System.IO.Path.Combine(logDir, "dpl_generator.txt");
...
 
@@ -303,9 +303,9 @@ namespace DesertPaintLab
 
            if (generator == null)
 
            {
 
                generator = new RecipeGenerator(profile.Reactions);
 
                int threads;
 
                DesertPaintLab.AppSettings.Get("GeneratorThreads", out threads);
 
                AppSettings.Get("GeneratorThreads", out threads, 15);
 
                if (threads <= 0) { threads = 15; }
 
                generator.MaxThreads = (uint)threads;
 

	
 
                generator.Progress += OnProgress;
...
 
@@ -365,9 +365,9 @@ namespace DesertPaintLab
 
                    profile.LoadRecipes();
 

	
 
                    generator = new RecipeGenerator(profile.Reactions);
 
                    int threads;
 
                    DesertPaintLab.AppSettings.Get("GeneratorThreads", out threads);
 
                    AppSettings.Get("GeneratorThreads", out threads, 15);
 
                    if (threads <= 0) { threads = 15; }
 
                    generator.MaxThreads = (uint)threads;
 
        
 
                    generator.Progress += OnProgress;
gtk-gui/DesertPaintLab.ScreenCheckDialog.cs
Show inline comments
...
 
@@ -16,12 +16,16 @@ namespace DesertPaintLab
 
		
 
		private global::Gtk.Entry screenHeightEntry;
 
		
 
		private global::Gtk.HBox hbox2;
 

	
 
        private global::Gtk.VBox vbox3;
 
		
 
		private global::Gtk.Label label2;
 
		
 
		private global::Gtk.Entry gamePixelWidthEntry;
 

	
 
        private global::Gtk.Entry gamePixelWidthEntry;
 

	
 
        private global::Gtk.Label label3;
 

	
 
        private global::Gtk.HBox hbox3;
 

	
 
        private global::Gtk.Label interfaceSizeLlabel;
...
 
@@ -97,8 +101,14 @@ namespace DesertPaintLab
 
            wDR.Position =  1;
 
            wDR.Expand = false;
 
            wDR.Fill = false;
 

	
 
            // Container child dialog1_VBox.Gtk.Box+BoxChild
 
            this.vbox3 = new global::Gtk.VBox();
 
            this.vbox3.Name = "vbox3";
 
            this.vbox3.Spacing = 2;
 
            this.vbox3.BorderWidth = ((uint)(20));
 

	
 
            // Container child vbox2.Gtk.Box+BoxChild
 
            this.hbox2 = new global::Gtk.HBox ();
 
			this.hbox2.Name = "hbox2";
 
			this.hbox2.Spacing = 20;
...
 
@@ -123,14 +133,30 @@ namespace DesertPaintLab
 
			global::Gtk.Box.BoxChild w7 = ((global::Gtk.Box.BoxChild)(this.hbox2 [this.gamePixelWidthEntry]));
 
			w7.Position = 1;
 
			w7.Expand = false;
 
			w7.Fill = false;
 
			this.vbox2.Add (this.hbox2);
 
			global::Gtk.Box.BoxChild w8 = ((global::Gtk.Box.BoxChild)(this.vbox2 [this.hbox2]));
 
			w8.Position = 2;
 
			this.vbox3.Add (this.hbox2);
 
			global::Gtk.Box.BoxChild w8 = ((global::Gtk.Box.BoxChild)(this.vbox3 [this.hbox2]));
 
			w8.Position = 0;
 
			w8.Expand = false;
 
			w8.Fill = false;
 

	
 
            // Container child hbox2.Gtk.Box+BoxChild
 
            this.label3 = new global::Gtk.Label();
 
            this.label3.Name = "label2";
 
            this.label3.LabelProp = "(Advanced, should be 1 for most displays and 2 for Macs with retina displays)";
 
            this.vbox3.Add(this.label3);
 
            global::Gtk.Box.BoxChild w8a = ((global::Gtk.Box.BoxChild)(this.vbox3[this.label3]));
 
            w8a.Position = 1;
 
            w8a.Expand = false;
 
            w8a.Fill = false;
 

	
 
            this.vbox2.Add(this.vbox3);
 
            global::Gtk.Box.BoxChild w8b = ((global::Gtk.Box.BoxChild)(this.vbox2[this.vbox3]));
 
            w8b.Position = 2;
 
            w8b.Expand = false;
 
            w8b.Fill = false;
 

	
 
            // Container child vbox2.Gtk.Box+BoxChild
 
            this.hbox3 = new global::Gtk.HBox();
 
            this.hbox3.Name = "hbox3";
 
            this.hbox3.Spacing = 20;
0 comments (0 inline, 0 general)