Changeset - 58b2186f7ffc
[Not reviewed]
Tess Snider (Malkyne) - 9 years ago 2015-10-12 10:45:26
this@malkyne.org
Color bar width fixed for T7. RC1.
5 files changed with 271 insertions and 27 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 Gtk;
 
using DesertPaintLab;
 

 
public partial class MainWindow : Gtk.Window
 
{
 
	const int swatchHeight = 24;
 
	const int colorBarWidth = 260;
 
	const int colorBarWidth = 306;
 
	const int redBarSpacing = 32;
 
	const int greenBarSpacing = 42;
 
	const int blueBarSpacing = 52;
 
	const int colorTolerance = 2;
 
	
 
	
 
	bool unsavedData = false;
 
	bool shouldShutDown = false;
 
	string appDataPath;
 
	List<string> profileList = new List<string>();
 
	PlayerProfile profile = null;
 
	PaintColor expectedColor = new PaintColor();
 
	PaintColor reactedColor = new PaintColor();
 
	
 
	int screenWidth = 0;
 
	int screenHeight = 0;
 

 
	Gdk.Window rootWindow = null;
 
	Gdk.Pixbuf screenBuffer = null;
 

 
	Reagent reagent1 = null;
 
	Reagent reagent2 = null;
 
	Reagent reagent3 = null;
 

 
	
 
	
 
	public bool ShouldShutDown
 
	{
 
		get
 
		{
 
			return shouldShutDown;	
 
		}
 
	}
 
	
 
	
 
	public MainWindow () : base(Gtk.WindowType.Toplevel)
 
	{
 
		appDataPath = System.IO.Path.Combine(
 
			Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
 
		    "DesertPaintLab");
 
		
 
		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);
 
			}
 
		}
 
		
 
		Palette.Load(System.IO.Path.Combine(
 
				System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location),
 
		    	"colors.txt"));
 
		
 
		Build();                      
 
		
 
		unmodifiedSwatch.Clear();
 
		reactionSwatch.Clear();
 
		
 

 
		// get the root window
 
		rootWindow = Gdk.Global.DefaultRootWindow;
 

 
		// get its width and height
 
		rootWindow.GetSize(out screenWidth, out screenHeight);
 
		
 
		screenBuffer = new Gdk.Pixbuf(Gdk.Colorspace.Rgb, false, 8, 
 
                                       screenWidth, screenHeight);
 
	
 
		if (!OpenProfile())
 
		{
 
			shouldShutDown = true;
 
		}
 
	}
 

 
	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;
 
	}
 
	
 
	void SetProfileName(string name)
 
	{	
 
		profile = new PlayerProfile(name,
 
		                System.IO.Path.Combine(appDataPath, name));
 
		
 
		statusBar.Push(0, name);
 
	}
 
	
 
	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 == 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);
 
				
 
				profile.Initialize();
 
						
 
				newProfileCreated = true;
 
			}
 
		}
 
		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)) 
 
				// Selected a profile.
 
			{
 
				SetProfileName(selectedProfile);
 
				profileSelected = true;
 
			}
 
			else if (resp == ResponseType.Accept) // New profile.
 
			{
 
				profileSelected = NewProfile();
 
			}
 
		}
 
		else
 
		{
 
			FirstRunDialog firstRunDialog = new FirstRunDialog();
 
			ResponseType resp = (ResponseType)firstRunDialog.Run();
 
			firstRunDialog.Destroy();
 
			if (resp == ResponseType.Ok) // New profile
 
			{
 
				profileSelected = NewProfile();			
 
			}
 
			else if (resp == ResponseType.Accept) // Import
 
			{
 
				FileChooserDialog fileDialog =
 
					new FileChooserDialog("Select reactions.txt file.",
 
				    this, FileChooserAction.Open,
 
					Gtk.Stock.Cancel, ResponseType.Cancel,
 
		            Gtk.Stock.Open, ResponseType.Accept);
 
				resp = (ResponseType)fileDialog.Run();
 
				if (resp == ResponseType.Accept)
 
				{
 
					string fileName = fileDialog.Filename;
 
					string directory = fileDialog.CurrentFolder;
 
					if (fileName == "reactions.txt")
 
					{
 
						profileSelected = NewProfile();
 
						if (profileSelected)
 
						{
bin/Debug/colors.txt
Show inline comments
 
#F0F8FF		AliceBlue
 
#FAEBD7		AntiqueWhite
 
#9966CC		Amethyst
 
#FAEB7E		AntiqueWhite
 
#00FFFF		Aqua
 
#7FFFD4		Aquamarine
 
#F0FFFF		Azure
 
#FF91AF		BakerMillerPink
 
#E3CF57		BananaYellow
 
#7C0A02		BarnRed
 
#8E388E		Beet
 
#F5F5DC		Beige
 
#FFE4C4		Bisque
 
#010101		Black
 
#FFEBCD		BlanchedAlmond
 
#FF6700		BlazeOrange
 
#0000FF		Blue
 
#8A2BE2		BlueViolet
 
#873260		Boysenberry
 
#FF007F		BrightPink
 
#A52A2A		Brown
 
#DEB887		Burlywood
 
#800020		BurgundyRed
 
#DEB887		BurlyWood
 
#8A360F		BurntSienna
 
#8A3324		BurntUmber
 
#5F9EA0		CadetBlue
 
#FF6103		CadmiumOrange
 
#FF9912		CadmiumYellow
 
#E07020		Carrot
 
#7FFF00		Chartreuse
 
#D2691E		Chocolate
 
#3D59AB		CobaltBlue
 
#3D9140		CobaltGreen
 
#FF7F50		Coral
 
#6495ED		CornflowerBlue
 
#FFF8DC		Cornsilk
 
#DC143C		Crimson
 
#00008B		DarkBlue
 
#008B8B		DarkCyan
 
#B8860B		DarkGoldenrod
 
#A9A9A9		DarkGray
 
#00B8B8		DarkCyan
 
#B8860B		DarkGoldenRod
 
#006400		DarkGreen
 
#A9A9A9		DarkGrey
 
#1A2421		DarkJungleGreen
 
#BDB76B		DarkKhaki
 
#8B008B		DarkMagenta
 
#556B2F		DarkOliveGreen
 
#FF8C00		DarkOrange
 
#9932CC		DarkOrchid
 
#8B0000		DarkRed
 
#E9967A		DarkSalmon
 
#560319		DarkScarlet
 
#8FBC8F		DarkSeaGreen
 
#3C1414		DarkSienna
 
#483D8B		DarkSlateBlue
 
#2F4F4F		DarkSlateGray
 
#2F4F4F		DarkSlateGrey
 
#00CED1		DarkTurquoise
 
#9400D3		DarkViolet
 
#FF1493		DeepPink
 
#00BFFF		DeepSkyBlue
 
#696969		DimGray
 
#696969		DimGrey
 
#1E90FF		DodgerBlue
 
#00009C		DukeBlue
 
#FCE6C9		EggshellWhite
 
#00C957		EmeraldGreen
 
#D19275		Feldspar
 
#B22222		FireBrick
 
#FFFAF0		FloralWhite
 
#228B22		ForestGreen
 
#FF00FF		Fuchsia
 
#DCDCDC		Gainsboro
 
#F8F8FF		GhostWhite
 
#FFD700		Gold
 
#DAA520		Goldenrod
 
#808080		Gray
 
#DAA520		GoldenRod
 
#008000		Green
 
#ADFF2F		GreenYellow
 
#F0FFF0		Honeydew
 
#808080		Grey
 
#F0FFF0		HoneyDew
 
#FF69B4		HotPink
 
#1A2421		ImperialBlue
 
#CD5C5C		IndianRed
 
#4B0082		Indigo
 
#FFFFF0		Ivory
 
#F0E68C		Khaki
 
#E6E6FA		Lavender
 
#FFF0F5		LavenderBlush
 
#7CFC00		LawnGreen
 
#FFFACD		LemonChiffon
 
#1A1110		Licorice
 
#ADD8E6		LightBlue
 
#F08080		LightCoral
 
#E0FFFF		LightCyan
 
#FAFAD2		LightGoldenrodYellow
 
#FAFAD2		LightGoldenRodYellow
 
#90EE90		LightGreen
 
#D3D3D3		LightGrey
 
#FFB6C1		LightPink
 
#FFA07A		LightSalmon
 
#20B2AA		LightSeaGreen
 
#87CEFA		LightSkyBlue
 
#8470FF		LightSlateBlue
 
#778899		LightSlateGray
 
#778899		LightSlateGrey
 
#B0C4DE		LightSteelBlue
 
#FFFFE0		LightYellow
 
#00FF00		Lime
 
#32CD32		LimeGreen
 
#FAF0E6		Linen
 
#800000		Maroon 
 
#66CDAA		MediumAquamarine
 
#0000CD		MediumBlue 
 
#800000		Maroon
 
#66CDAA		MediumAquaBlue
 
#0000CD		MediumBlue
 
#BA55D3		MediumOrchid
 
#9370DB		MediumPurple
 
#3CB371		MediumSeaGreen
 
#7B68EE		MediumSlateBlue
 
#00FA9A		MediumSpringGreen
 
#48D1CC		MediumTurquoise
 
#C71585		MediumVioletRed
 
#E3A869		Melon
 
#191970		MidnightBlue
 
#F5FFFA		MintCream
 
#F5FFFF		MintCream
 
#FFE4E1		MistyRose
 
#FFE4B5		Moccasin
 
#FFDEAD		NavajoWhite
 
#000080		Navy 
 
#FFDEAD		NavahoWhite
 
#000080		Navy
 
#FDF5E6		OldLace
 
#808000		Olive
 
#6B8E23		OliveDrab
 
#FFA500		Orange
 
#FF4500		OrangeRed
 
#DA70D6		Orchid
 
#EEE8AA		PaleGoldenrod
 
#002147		OxfordBlue
 
#EEE8AA		PaleGolden Rod
 
#98FB98		PaleGreen
 
#AFEEEE		PaleTurquoise
 
#DB7093		PaleVioletRed
 
#ADEEEE		PaleTurquoise
 
#DB7093		PaleViolet
 
#FFEFD5		PapayaWhip
 
#FFDAB9		PeachPuff
 
#33A1C9		Peacock
 
#32127A		PersianIndigo
 
#F77FBE		PersianPink
 
#CD853F		Peru
 
#FFC0CB		Pink
 
#DDA0DD		Plum
 
#B0E0E6		PowderBlue
 
#800080		Purple 
 
#003153		PrussianBlue
 
#800080		Purple
 
#C76114		RawSienna
 
#FF0000		Red
 
#860111		RedDevil
 
#004040		RichBlack
 
#BC8F8F		RosyBrown
 
#4169E1		RoyalBlue
 
#9B111E		RubyRed
 
#8B4513		SaddleBrown
 
#FA8072		Salmon
 
#F4A460		SandyBrown
 
#92000A		Sangria
 
#308014		SapGreen
 
#2E8B57		SeaGreen
 
#FFF5EE		Seashell
 
#FFF5EE		SeaShell
 
#321414		SealBrown
 
#A0522D		Sienna
 
#C0C0C0		Silver
 
#87CEEB		SkyBlue
 
#6A5ACD		SlateBlue
 
#708090		SlateGray
 
#708090		SlateGrey
 
#100C08		SmokeyBlack
 
#FFFAFA		Snow
 
#00FF7F		SpringGreen
 
#4682B4		SteelBlue 
 
#4682B4		SteelBlue
 
#CC3366		SteelPink
 
#D2B48C		Tan
 
#008080		Teal
 
#D8BFD8		Thistle
 
#FF6347		Tomato
 
#40E0D0		Turquoise
 
#660023		TyrianPurple
 
#EE82EE		Violet
 
#D02090		VioletRed
 
#F5DEB3		Wheat
 
#FFFFFF		White
 
#F5F5F5		WhiteSmoke
 
#FFFF00		Yellow
 
#9ACD32		YellowGreen
...
 
\ No newline at end of file
 
#9ACD32		YellowGreen
 
#0014A8		Zaffre
bin/Release/colors.txt
Show inline comments
 
new file 100644
 
#F0F8FF		AliceBlue
 
#9966CC		Amethyst
 
#FAEB7E		AntiqueWhite
 
#00FFFF		Aqua
 
#7FFFD4		Aquamarine
 
#F0FFFF		Azure
 
#FF91AF		BakerMillerPink
 
#E3CF57		BananaYellow
 
#7C0A02		BarnRed
 
#8E388E		Beet
 
#F5F5DC		Beige
 
#FFE4C4		Bisque
 
#010101		Black
 
#FFEBCD		BlanchedAlmond
 
#FF6700		BlazeOrange
 
#0000FF		Blue
 
#8A2BE2		BlueViolet
 
#873260		Boysenberry
 
#FF007F		BrightPink
 
#A52A2A		Brown
 
#800020		BurgundyRed
 
#DEB887		BurlyWood
 
#8A360F		BurntSienna
 
#8A3324		BurntUmber
 
#5F9EA0		CadetBlue
 
#FF6103		CadmiumOrange
 
#FF9912		CadmiumYellow
 
#E07020		Carrot
 
#7FFF00		Chartreuse
 
#D2691E		Chocolate
 
#3D59AB		CobaltBlue
 
#3D9140		CobaltGreen
 
#FF7F50		Coral
 
#6495ED		CornflowerBlue
 
#FFF8DC		Cornsilk
 
#DC143C		Crimson
 
#00008B		DarkBlue
 
#00B8B8		DarkCyan
 
#B8860B		DarkGoldenRod
 
#006400		DarkGreen
 
#A9A9A9		DarkGrey
 
#1A2421		DarkJungleGreen
 
#BDB76B		DarkKhaki
 
#8B008B		DarkMagenta
 
#556B2F		DarkOliveGreen
 
#FF8C00		DarkOrange
 
#9932CC		DarkOrchid
 
#8B0000		DarkRed
 
#E9967A		DarkSalmon
 
#560319		DarkScarlet
 
#8FBC8F		DarkSeaGreen
 
#3C1414		DarkSienna
 
#483D8B		DarkSlateBlue
 
#2F4F4F		DarkSlateGrey
 
#00CED1		DarkTurquoise
 
#9400D3		DarkViolet
 
#FF1493		DeepPink
 
#00BFFF		DeepSkyBlue
 
#696969		DimGrey
 
#1E90FF		DodgerBlue
 
#00009C		DukeBlue
 
#FCE6C9		EggshellWhite
 
#00C957		EmeraldGreen
 
#D19275		Feldspar
 
#B22222		FireBrick
 
#FFFAF0		FloralWhite
 
#228B22		ForestGreen
 
#FF00FF		Fuchsia
 
#DCDCDC		Gainsboro
 
#F8F8FF		GhostWhite
 
#FFD700		Gold
 
#DAA520		GoldenRod
 
#008000		Green
 
#ADFF2F		GreenYellow
 
#808080		Grey
 
#F0FFF0		HoneyDew
 
#FF69B4		HotPink
 
#1A2421		ImperialBlue
 
#CD5C5C		IndianRed
 
#4B0082		Indigo
 
#FFFFF0		Ivory
 
#F0E68C		Khaki
 
#E6E6FA		Lavender
 
#FFF0F5		LavenderBlush
 
#7CFC00		LawnGreen
 
#FFFACD		LemonChiffon
 
#1A1110		Licorice
 
#ADD8E6		LightBlue
 
#F08080		LightCoral
 
#E0FFFF		LightCyan
 
#FAFAD2		LightGoldenRodYellow
 
#90EE90		LightGreen
 
#D3D3D3		LightGrey
 
#FFB6C1		LightPink
 
#FFA07A		LightSalmon
 
#20B2AA		LightSeaGreen
 
#87CEFA		LightSkyBlue
 
#8470FF		LightSlateBlue
 
#778899		LightSlateGrey
 
#B0C4DE		LightSteelBlue
 
#FFFFE0		LightYellow
 
#00FF00		Lime
 
#32CD32		LimeGreen
 
#FAF0E6		Linen
 
#800000		Maroon
 
#66CDAA		MediumAquaBlue
 
#0000CD		MediumBlue
 
#BA55D3		MediumOrchid
 
#9370DB		MediumPurple
 
#3CB371		MediumSeaGreen
 
#7B68EE		MediumSlateBlue
 
#00FA9A		MediumSpringGreen
 
#48D1CC		MediumTurquoise
 
#C71585		MediumVioletRed
 
#E3A869		Melon
 
#191970		MidnightBlue
 
#F5FFFF		MintCream
 
#FFE4E1		MistyRose
 
#FFE4B5		Moccasin
 
#FFDEAD		NavahoWhite
 
#000080		Navy
 
#FDF5E6		OldLace
 
#808000		Olive
 
#6B8E23		OliveDrab
 
#FFA500		Orange
 
#FF4500		OrangeRed
 
#DA70D6		Orchid
 
#002147		OxfordBlue
 
#EEE8AA		PaleGolden Rod
 
#98FB98		PaleGreen
 
#ADEEEE		PaleTurquoise
 
#DB7093		PaleViolet
 
#FFEFD5		PapayaWhip
 
#FFDAB9		PeachPuff
 
#33A1C9		Peacock
 
#32127A		PersianIndigo
 
#F77FBE		PersianPink
 
#CD853F		Peru
 
#FFC0CB		Pink
 
#DDA0DD		Plum
 
#B0E0E6		PowderBlue
 
#003153		PrussianBlue
 
#800080		Purple
 
#C76114		RawSienna
 
#FF0000		Red
 
#860111		RedDevil
 
#004040		RichBlack
 
#BC8F8F		RosyBrown
 
#4169E1		RoyalBlue
 
#9B111E		RubyRed
 
#8B4513		SaddleBrown
 
#FA8072		Salmon
 
#F4A460		SandyBrown
 
#92000A		Sangria
 
#308014		SapGreen
 
#2E8B57		SeaGreen
 
#FFF5EE		SeaShell
 
#321414		SealBrown
 
#A0522D		Sienna
 
#C0C0C0		Silver
 
#87CEEB		SkyBlue
 
#6A5ACD		SlateBlue
 
#708090		SlateGrey
 
#100C08		SmokeyBlack
 
#FFFAFA		Snow
 
#00FF7F		SpringGreen
 
#4682B4		SteelBlue
 
#CC3366		SteelPink
 
#D2B48C		Tan
 
#008080		Teal
 
#D8BFD8		Thistle
 
#FF6347		Tomato
 
#40E0D0		Turquoise
 
#660023		TyrianPurple
 
#EE82EE		Violet
 
#D02090		VioletRed
 
#F5DEB3		Wheat
 
#FFFFFF		White
 
#F5F5F5		WhiteSmoke
 
#FFFF00		Yellow
 
#9ACD32		YellowGreen
 
#0014A8		Zaffre
bin/Release/template/dp_reactions.txt
Show inline comments
 
new file 100644
 

...
 
\ No newline at end of file
bin/Release/template/ingredients.txt
Show inline comments
 
new file 100644
 
// Ingredients are in the form:
 
// Name | RGB values | cost | enabled (Y/N) | bulk/normal | max items per paint (1-20)
 
//
 
// It is recommended to only change the cost value
 
// It is not recommended to set many of the ingredients above 10 per paint
 

 
Cabbage		| 128, 64, 144   | 8      | Y | bulk    | 10
 
Clay		| 128, 96, 32    | 4      | Y | bulk    | 20
 
Carrot		| 224, 112, 32   | 10     | Y | bulk    | 10
 
Copper		| 64, 192, 192   | 30     | Y | normal  | 8
 
Iron		| 96, 48, 32     | 30     | Y | normal  | 8
 
Lead		| 80, 80, 96     | 50     | Y | normal  | 6
 
RedSand		| 144, 16, 24    | 10     | Y | bulk    | 20
 
Silver		| 16, 16, 32     | 50     | N | normal  | 6
 
ToadSkin	| 48, 96, 48     | 500    | N | normal  | 4
 
DeadTongue	| 112, 64, 64    | 500    | N | normal  | 4
 
EarthLight	| 128, 240, 224  | 10000  | N | normal  | 4
 
Lime        | catalyst       | 20     | Y | normal  | 1
 
Sulfur      | catalyst       | 10     | Y | normal  | 1
 
Potash      | catalyst       | 50     | Y | normal  | 1
 
Saltpeter   | catalyst       | 10     | Y | normal  | 1
...
 
\ No newline at end of file
0 comments (0 inline, 0 general)