Changeset - 64ef4331f012
[Not reviewed]
Jason Maltzen (jmaltzen) - 9 years ago 2016-03-11 09:18:35
jason.maltzen@unsanctioned.net
Update version to 1.7.15
2 files changed with 2 insertions and 2 deletions:
0 comments (0 inline, 0 general)
MainWindow.cs
Show inline comments
 
/*
 
 * Copyright (c) 2010, Tess Snider
 

	
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
 
 of this software and associated documentation files (the "Software"), to deal
 
 in the Software without restriction, including without limitation the rights
 
 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 
 copies of the Software, and to permit persons to whom the Software is
 
 furnished to do so, subject to the following conditions:
 

	
 
 The above copyright notice and this permission notice shall be included in
 
 all copies or substantial portions of the Software.
 

	
 
 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 
 THE SOFTWARE.
 
*/
 

	
 
using System;
 
using System.IO;
 
using System.Collections.Generic;
 
using System.Text.RegularExpressions;
 
using Gtk;
 
using DesertPaintLab;
 

	
 
public partial class MainWindow : Gtk.Window
 
{
 
    const string APP_VERSION = "1.7.14";
 
    const string APP_VERSION = "1.7.15";
 

	
 
	bool unsavedData = false;
 
	bool shouldShutDown = false;
 
	List<string> profileList = new List<string>();
 
	PlayerProfile profile = null;
 
	
 
	Gdk.Window rootWindow = null;
 
	Gdk.Pixbuf screenBuffer = null;
 

	
 
    // views
 
    RecipeGeneratorView generatorView;
 
    SimulatorView simulatorView;
 
    CaptureView captureView;
 

	
 
	public bool ShouldShutDown
 
	{
 
		get
 
		{
 
			return shouldShutDown;
 
		}
 
	}
 
	
 
	public MainWindow () : base(Gtk.WindowType.Toplevel)
 
	{
 
        string appDataPath = FileUtils.AppDataPath;
 
		if (!System.IO.Directory.Exists(appDataPath))
 
		{
 
			System.IO.Directory.CreateDirectory(appDataPath);	
 
		}
 
		
 
		DirectoryInfo di = new DirectoryInfo(appDataPath);
 
		DirectoryInfo[] dirs = di.GetDirectories();
 
		foreach (DirectoryInfo dir in dirs)
 
		{
 
			if (dir.Name != "template")
 
			{
 
				profileList.Add(dir.Name);
 
			}
 
		}
 

	
 
        string colorsPath = FileUtils.FindApplicationResourceFile("colors.txt");
 
        if (colorsPath == null)
 
        {
 
            // failed to find colors.txt file
 
            MessageDialog md = new MessageDialog(this, 
 
                DialogFlags.DestroyWithParent,
 
                MessageType.Error, ButtonsType.Close, 
 
                "Failed to find colors.txt file. Please check your installation.");
 
       
 
            md.Run();
 
            md.Destroy();
 
            Application.Quit();
 
        }
 
		Palette.Load(colorsPath);
 

	
 
        string ingredientsPath = FileUtils.FindApplicationResourceFile("ingredients.txt");
 
        if (ingredientsPath == null)
 
        {
 
            // failed to find ingredients.txt file
 
            MessageDialog md = new MessageDialog(this, 
 
                DialogFlags.DestroyWithParent,
 
                MessageType.Error, ButtonsType.Close, 
 
                "Failed to find ingredients.txt file. Please check your installation.");
 
       
 
            md.Run();
 
            md.Destroy();
 
            Application.Quit();
 
        }
 
        ReagentManager.Load(ingredientsPath);
 
		
 
		Build();
 
		
 
		// get the root window
 
		rootWindow = Gdk.Global.DefaultRootWindow;
 

	
 
		// get its width and height
 
        int screenWidth;
 
        int screenHeight;
 
		rootWindow.GetSize(out screenWidth, out screenHeight);
 
        int pixelMultiplier = 1;
 

	
 
        if ( DesertPaintLab.AppSettings.Load() == true )
 
        {
 
            DesertPaintLab.AppSettings.Get("ScreenWidth", out screenWidth);
 
            DesertPaintLab.AppSettings.Get("ScreenHeight", out screenHeight);
 
            DesertPaintLab.AppSettings.Get("PixelMultiplier", out pixelMultiplier);
 
        }
 

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

	
 
		ScreenCheckDialog screenCheckDialog = new ScreenCheckDialog();
 
		screenCheckDialog.ScreenWidth = screenWidth;
 
		screenCheckDialog.ScreenHeight = screenHeight;
 
        screenCheckDialog.GamePixelWidth = pixelMultiplier;
 
		ResponseType resp = (ResponseType)screenCheckDialog.Run();
 
        screenWidth = screenCheckDialog.ScreenWidth;
 
        screenHeight = screenCheckDialog.ScreenHeight;
 
        pixelMultiplier = screenCheckDialog.GamePixelWidth;
 
		screenCheckDialog.Destroy();
 

	
 
        DesertPaintLab.AppSettings.Set("ScreenWidth", screenWidth);
 
        DesertPaintLab.AppSettings.Set("ScreenHeight", screenHeight);
 
        DesertPaintLab.AppSettings.Set("PixelMultiplier", pixelMultiplier);
 
        DesertPaintLab.AppSettings.Save();
 

	
 
		screenBuffer = new Gdk.Pixbuf(Gdk.Colorspace.Rgb, false, 8, screenWidth, screenHeight);
 
	
 
        ReactionRecorder.Instance.SetPixelMultiplier(pixelMultiplier);
 

	
 
		if (!OpenProfile())
 
		{
 
			shouldShutDown = true;
 
		}
 

	
 
        captureView = new CaptureView(profile, screenBuffer);
 
        generatorView = new RecipeGeneratorView(profile);
 
        generatorView.SetStatus += OnStatusUpdate;
 
        generatorView.Started += OnGeneratorRunning;
 
        generatorView.Stopped += OnGeneratorStopped;
 
        simulatorView = new SimulatorView(profile);
 

	
 
        contentContainer.Add(captureView);
 
        captureView.Show();
 
	}
 

	
 
	bool ConfirmedExit()
 
	{
 
		if (unsavedData)
 
		{
 
			MessageDialog md = new MessageDialog(this, 
 
	            DialogFlags.DestroyWithParent,
 
	            MessageType.Warning, ButtonsType.OkCancel, 
 
	            "Your last reaction was unsaved." +
 
	            "Are you sure you want to quit?");
 
	   
 
			ResponseType resp = (ResponseType)md.Run();
 
			md.Destroy();
 
			return (resp == ResponseType.Ok);
 
		}
 
		return true;
 
	}
 

	
 
    protected void OnStatusUpdate(object sender, EventArgs args)
 
    {
 
        StatusUpdateEventArgs statusArgs = (StatusUpdateEventArgs)args;
 
        statusBar.Push(0, statusArgs.Status);
 
    }
 

	
 
    protected void OnGeneratorRunning(object sender, EventArgs args)
 
    {
 
        NewProfileAction.Sensitive = false;
 
        OpenProfileAction.Sensitive = false;
 
        ImportProfileAction.Sensitive = false;
 
        if (captureView != null)
 
        {
 
            captureView.DisableRecord();
 
        }
 
    }
 

	
 
    protected void OnGeneratorStopped(object sender, EventArgs args)
 
    {
 
        NewProfileAction.Sensitive = true;
 
        OpenProfileAction.Sensitive = true;
 
        ImportProfileAction.Sensitive = true;
 
        if (captureView != null)
 
        {
 
            captureView.EnableRecord();
 
        }
 
    }
 
	
 
	void SetProfileName(string name)
 
	{	
 
		profile = new PlayerProfile(name,
 
            System.IO.Path.Combine(FileUtils.AppDataPath, name));
 
	}
 

	
 
    void ProfileChanged()
 
    {
 
        statusBar.Push(0, "Profile: " + profile.Name);
 
        Title  = "Desert Paint Lab - " + profile.Name;
 

	
 
        if (generatorView != null)
 
        {
 
            generatorView.Profile = profile;
 
        }
 
        if (simulatorView != null)
 
        {
 
            simulatorView.Profile = profile;
 
        }
 
        if (captureView != null)
 
        {
 
            captureView.Profile = profile;
 
        }
 
    }
 
	
 
	bool NewProfile()
 
	{
 
		bool newProfileCreated = false;
 
		bool duplicateName = false;
 
		NewProfileDialog newProfileDialog = new NewProfileDialog();
 
		ResponseType resp = (ResponseType)newProfileDialog.Run();
 
		if (resp == ResponseType.Ok)
 
		{
 
			// Make sure profile doesn't already exist.
 
			foreach (string profileName in profileList)
 
			{
 
				if (profileName.Equals(newProfileDialog.ProfileName))
 
				{
 
					MessageDialog md = new MessageDialog(this, 
 
	            		DialogFlags.DestroyWithParent,
 
	            		MessageType.Error, ButtonsType.Ok, 
 
	            		"That profile name already exists.");
 
					resp = (ResponseType)md.Run();
 
					md.Destroy();
 
					duplicateName = true;
 
					break;	
 
				}
 
			}
 
			
 
			if (!duplicateName)
 
			{
 
				// Set profile name.
 
				SetProfileName(newProfileDialog.ProfileName);
 
				
 
                newProfileCreated = profile.Initialize();
 
                if (!newProfileCreated)
 
                {
 
                    MessageDialog md = new MessageDialog(this, 
 
                        DialogFlags.DestroyWithParent,
 
                        MessageType.Error, ButtonsType.Ok, 
 
                        "Failed to initialize profile: " + profile.LastError);
 
                    resp = (ResponseType)md.Run();
 
                    md.Destroy();
 
                    duplicateName = false;
 
                }
 
                ProfileChanged();
 
			}
 
		}
 
		newProfileDialog.Destroy();
 
		return newProfileCreated;
 
	}
 
	
 
	bool OpenProfile()
 
	{
 
		bool profileSelected = false;
 
		
 
		if (profileList.Count > 0)
 
		{
 
			SelectProfileDialog selectProfileDialog = new SelectProfileDialog();
 
			selectProfileDialog.ProfileList = profileList;
 
			ResponseType resp = (ResponseType)selectProfileDialog.Run();
 
			selectProfileDialog.Destroy();
 
			string selectedProfile = selectProfileDialog.SelectedProfile;
 
			if ((resp == ResponseType.Ok) && (selectedProfile.Length > 0)) 
README.md
Show inline comments
 
# Desert Paint Lab
 

 
This is a tool for players to record their [Pigment Laboratory](http://www.atitd.org/wiki/tale6/Pigment_Laboratory)
 
ingredient reactions in [A Tale in the Desert](http://www.atitd.com/).
 

 
### Features
 

 
* Easily scans your screen for the paint bench reaction values, without any math, measuring, or manual number entry.
 
* Warns you when a reaction clipped below 0.
 
* Supports multiple character profiles.
 
* Can export to [PracticalPaint](http://www.atitd.org/wiki/tale7/File:PracticalPaint.Zip) data format.
 
* Includes simulator for experimenting with recipes without spending ingredients.
 
* Includes a recipe generator
 

 
## Tale 7
 

 
This application has been updated for Tale 7.  The current version is a **RELEASE CANDIDATE**.  It may be buggy.
 
If you find any problems with it, please [open an issue](https://bitbucket.org/Malkyne/desert-paint-lab/issues) or /chat Afrah or Snoerr
 
in the game.
 

 
## Directions
 

 
### Download Desert Paint Lab
 

 
You can always find the available downloads, on [the download page](https://bitbucket.org/Malkyne/desert-paint-lab/downloads).
 

 
The most recent version is [T7 Release Candidate 14](https://bitbucket.org/Malkyne/desert-paint-lab/downloads/DesertPaintLab_T7_RC14.zip). For Mac, you can download a [dmg containing a Mac app bundle](https://bitbucket.org/Malkyne/desert-paint-lab/downloads/DesertPaintLab_T7_RC14.dmg).
 
The most recent version is [T7 Release Candidate 15](https://bitbucket.org/Malkyne/desert-paint-lab/downloads/DesertPaintLab_T7_RC15.zip). For Mac, you can download a [dmg containing a Mac app bundle](https://bitbucket.org/Malkyne/desert-paint-lab/downloads/DesertPaintLab_T7_RC15.dmg).
 

 
This application should run under Mono on Mac, Linux, and Windows.  If you are on Windows,
 
and do not have Mono installed, you can install [GTK# for .NET](http://www.mono-project.com/download/#download-win),
 
without the need for installing Mono. On Mac or Linux, download and install the [Mono runtime](http://www.mono-project.com/download).
 

 
### Set Up a Profile
 

 
The first time you run Desert Paint Lab, it will prompt you to make a profile.  You may either create a new profile, or import an existing PracticalPaint reactions.txt file.
 

 
### Start Testing!
 

 
Add two ingredients to your paint bench.  Select those same ingredients in Desert Paint Lab.  Then, with the Pigment Lab dialog unobstructred, select the **Capture** button.  Once you are satisfied with the result, click the **Record** button.  The data will automatically be added to your profile.
 

 
### Clipped?  Huh?
 

 
Occasionally, you will see a warning dialog that informs you that a "Reaction clipped."  That means that one or more of the color components moved outside of the testable range.  This makes it impossible to calculate the reaction from these two ingredients.
 

 
You can solve this by doing a three-way test.
 

 
1. In your clipped reaction, let's call your **1st** ingredient **A** and your **2nd** ingredient **B**.
 
1. Select a **non-catalyst** ingredient **C** for which you have already tested **C + A** and **C + B**.  It is OK if there was a reaction in those earlier tests.  Desert Paint Lab can work out the math.
 
1. In Desert Paint Lab, select ingredients as follows:
 
    1. **C**
 
    2. **A**
 
    3. **B**
 
1. Add the ingredients in your Pigment Lab _in exactly that order_.
 
1. Capture.
 
1. Record.
 

 
For clipped reactions, your **C** ingredient should be one that corrects for the clipped color.  Here are some suggested **C** ingredients for clipping correction:
 

 

 
Clip Color  | Clip Direction | Correction | Suggested "C" Ingredient
 
------------|----------------|------------|---------------------------
 
Red         | Low            | +Red       | Carrot (224) or Red Sand (144)
 
Red         | High           | -Red       | Silver Powder (16) or Toad Skin (48)
 
Green       | Low            | +Green     | Earth Light (240) or Copper (192)
 
Green       | High           | -Green     | Red Sand (16) or Silver Powder (16)
 
Blue        | Low            | +Blue      | Earth Light (224) or Copper (192)
 
Blue        | High           | -Blue      | Red Sand (24) or Clay (32) or Carrot (32) or Silver Powder (32)
 

 

 
In many cases, it may be easiest to go back and do these three-way tests after you have finished all of your other testing.
 

 
### Catalysts
 

 
For catalyst to catalyst reaction tests, follow the three-way instructions, as above.
 

 
### Finishing Up
 

 
When you're done testing your reactions, you can either use the built-in Pigment Lab simulator (`Window > Run Simulator`) to experiment with recipes, without dipping into your precious ingredient stocks.  Alternatively, you can export your reactions in PracticalPaint format.
 

 
## 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.
 

 
### 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.
 

 
### Retina / High-Density Screens
 

 
High DPI screens may be displaying the game at something other than a 1:1 game-pixel to screen-pixel ratio.  These screens didn't exist, back when Desert Paint Lab was created. The current version now prompts you for your screen resolution when it starts to work around this. If you see a crash when trying to capture a reaction, it's likely because the resolution is incorrect. For example, Snoerr's MacBook Pro has a retina screen with a resolution of 2880x1800. Mono (and therefore DesertPaintLab) detects it as having a resolution of 1440x900. He enters his resolution as 2880x1800 and sets the Game pixel width in screen pixels to 2.
 

 
## Mac user FAQ
 

 
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.
 

 
## For Developers
 

 
This application was developed using [MonoDevelop](http://www.monodevelop.com/), using the [Stetic GTK UI designer](http://www.monodevelop.com/documentation/stetic-gui-designer/).
0 comments (0 inline, 0 general)