context: using UnityEngine;
  using System.Collections;
  using Frontiers.World.WIScripts;
  
  namespace Frontiers.World {
  	public class BannerEditor : MonoBehaviour {
  
  		#if UNITY_EDITOR
  		[FrontiersAvailableModsAttribute ("Sigil")]
  		public string BannerName = string.Empty;
  		public Sigil Banner = new Sigil ();
  		public bool CreatingNewBanner = false;
  
  		int selectedItemIndex = 0;
  		int selectedRowIndex = 0;
  		bool openWindow = false;
  		bool chooseResult = false;
  
  		public void Update ()
  		{
  			LoadBanner (false);
  		}
  
  		public void DrawEditor ()
  		{
  			if (CreatingNewBanner) {
  				UnityEngine.GUI.color = Color.red;
  				GUILayout.Label ("[Editing new Banner - this Banner has not been saved]");
  			}
  			UnityEngine.GUI.color = Color.cyan;
  			GUILayout.BeginHorizontal ();
  
  			int colorIndexOneTwoThreeFour = 0;
  			int colorIndexTwoFour = 0;
  			int colorIndexOneThree = 0;
  
  //			switch (Banner.Style) {
  //			case CoatOfArms.Style.OneColorFourItems:
  //				colorIndexOneTwoThreeFour = Props.BannerItemColorIndex [0];
  //				if (Type == SigilType.BannerTwoItems) {
  //					UpdateBannerItem (0, colorIndexOneTwoThreeFour, Props.BannerItemIconIndex [0], true);
  //					UpdateBannerItem (1, colorIndexOneTwoThreeFour, Props.BannerItemIconIndex [1], true);				
  //				} else {
  //					UpdateBannerItem (0, colorIndexOneTwoThreeFour, Props.BannerItemIconIndex [0], true);
  //					UpdateBannerItem (1, colorIndexOneTwoThreeFour, Props.BannerItemIconIndex [1], true);
  //					UpdateBannerItem (2, colorIndexOneTwoThreeFour, Props.BannerItemIconIndex [2], true);
  //					UpdateBannerItem (3, colorIndexOneTwoThreeFour, Props.BannerItemIconIndex [3], true);
  //				}
  //				break;
  //
  //			case CoatOfArms.Style.FourColorFourItems:
  //				if (Type == SigilType.BannerTwoItems) {
  //					UpdateBannerItem (0, Props.BannerItemColorIndex [0], Props.BannerItemIconIndex [0], true);
  //					UpdateBannerItem (1, Props.BannerItemColorIndex [1], Props.BannerItemIconIndex [1], true);				
  //				} else {
  //					UpdateBannerItem (0, Props.BannerItemColorIndex [0], Props.BannerItemIconIndex [0], true);
  //					UpdateBannerItem (1, Props.BannerItemColorIndex [1], Props.BannerItemIconIndex [1], true);
  //					UpdateBannerItem (2, Props.BannerItemColorIndex [2], Props.BannerItemIconIndex [2], true);
  //					UpdateBannerItem (3, Props.BannerItemColorIndex [3], Props.BannerItemIconIndex [3], true);
  //				}
  //				break;
  //
  //			case CoatOfArms.Style.OneColorTwoItems:
  //				colorIndexTwoFour = Props.BannerItemColorIndex [0];
  //				if (Type == SigilType.BannerTwoItems) {
  //					UpdateBannerItem (0, colorIndexTwoFour, Props.BannerItemIconIndex [0], true);
  //					UpdateBannerItem (1, colorIndexTwoFour, Props.BannerItemIconIndex [1], true);
  //				} else {
  //					UpdateBannerItem (0, colorIndexTwoFour, Props.BannerItemIconIndex [0], false);
  //					UpdateBannerItem (1, colorIndexTwoFour, Props.BannerItemIconIndex [1], true);
  //					UpdateBannerItem (2, colorIndexTwoFour, Props.BannerItemIconIndex [2], false);
  //					UpdateBannerItem (3, colorIndexTwoFour, Props.BannerItemIconIndex [3], true);
  //				}
  //				break;
  //
  //			case CoatOfArms.Style.TwoColorFourItems:
  //				colorIndexTwoFour = Props.BannerItemColorIndex [0];
  //				colorIndexOneThree	= Props.BannerItemColorIndex [1];
  //				if (Type == SigilType.BannerTwoItems) {
  //					UpdateBannerItem (0, colorIndexOneThree, Props.BannerItemIconIndex [0], true);
  //					UpdateBannerItem (1, colorIndexTwoFour, Props.BannerItemIconIndex [1], true);
  //				} else {
  //					UpdateBannerItem (0, colorIndexOneThree, Props.BannerItemIconIndex [0], true);
  //					UpdateBannerItem (1, colorIndexTwoFour, Props.BannerItemIconIndex [1], true);
  //					UpdateBannerItem (2, colorIndexOneThree, Props.BannerItemIconIndex [2], true);
  //					UpdateBannerItem (3, colorIndexTwoFour, Props.BannerItemIconIndex [3], true);
  //				}
  //				break;
  //
  //			case CoatOfArms.Style.TwoColorTwoItems:
  //				colorIndexTwoFour = Props.BannerItemColorIndex [0];
  //				colorIndexOneThree	= Props.BannerItemColorIndex [1];
  //				if (Type == SigilType.BannerTwoItems) {
  //					UpdateBannerItem (0, colorIndexOneThree, Props.BannerItemIconIndex [0], true);
  //					UpdateBannerItem (1, colorIndexTwoFour, Props.BannerItemIconIndex [1], true);
  //				} else {
  //					UpdateBannerItem (0, colorIndexOneThree, Props.BannerItemIconIndex [0], false);
  //					UpdateBannerItem (1, colorIndexTwoFour, Props.BannerItemIconIndex [1], true);
  //					UpdateBannerItem (2, colorIndexOneThree, Props.BannerItemIconIndex [2], false);
  //					UpdateBannerItem (3, colorIndexTwoFour, Props.BannerItemIconIndex [3], true);
  //				}
  //				break;
  //
  //			default:
  //				break;
  //			}
  		
  			GUILayout.EndHorizontal ();
  			UnityEngine.GUI.color = Color.cyan;
  			GUILayout.BeginHorizontal ();
  			GUILayout.Label ("Name:");
  			Banner.Name = GUILayout.TextField (Banner.Name);
  			if (string.IsNullOrEmpty (Banner.Name)) {
  				Banner.Name = "New Sigil";
  			}
  			GUILayout.Label ("Family Name:");
  			Banner.FamilyName = GUILayout.TextField (Banner.FamilyName);
  			GUILayout.EndHorizontal ();
  
  			GUILayout.BeginHorizontal ();
  			GUILayout.Label ("Banner Style");
  			Banner.Style = (CoatOfArms.Style) UnityEditor.EditorGUILayout.EnumPopup (Banner.Style, GUILayout.Width (100));
  
  			if (Colors.BannerColors == null) {
  				Manager.WakeUp <Colors> ("Frontiers_ArtResourceManagers");
  			}
  
  			int [] bannerColorIndexes = new int [Colors.BannerColors.BannerColors.Count];
  			string [] bannerColorNames = new string [bannerColorIndexes.Length];
  			for (int i = 0; i < bannerColorIndexes.Length; i++) {
  				bannerColorIndexes [i] = i;
  				bannerColorNames [i] = "Color " + (i + 1).ToString ();
  			}
  			GUILayout.Label ("Banner Color:", GUILayout.Width (200));
  			Banner.BannerColorIndex = UnityEditor.EditorGUILayout.IntPopup (Banner.BannerColorIndex, bannerColorNames, bannerColorIndexes, GUILayout.Width (200));
  			Color selectedColor = Colors.BannerColors.BannerColors [Banner.BannerColorIndex];
  			UnityEditor.EditorGUILayout.ColorField (selectedColor);
  			Banner.Royalty = GUILayout.Toggle (Banner.Royalty, "Royalty");
  			GUILayout.EndHorizontal ();
  
  			int [] bannerIconColorIndexes = new int [Colors.BannerColors.ObjectColors.Count];
  			string [] bannerIconColorNames = new string [bannerColorIndexes.Length];
  			for (int i = 0; i < bannerIconColorIndexes.Length; i++) {
  				bannerIconColorIndexes [i] = i;
  				bannerIconColorNames [i] = "Icon Color " + (i + 1).ToString ();
  			}
  			Color color1 = Colors.BannerColors.ObjectColors [Banner.BannerItemColorIndex [0]];
  			Color color2 = Colors.BannerColors.ObjectColors [Banner.BannerItemColorIndex [1]];
  			Color color3 = Colors.BannerColors.ObjectColors [Banner.BannerItemColorIndex [2]];
  			Color color4 = Colors.BannerColors.ObjectColors [Banner.BannerItemColorIndex [3]];
  
  			string color1Text = "Color 1";
  			string color2Text = "Color 2";
  			string color3Text = "Color 3";
  			string color4Text = "Color 4";
  
  			Color color1Color = Color.cyan;
  			Color color2Color = Color.cyan;
  			Color color3Color = Color.cyan;
  			Color color4Color = Color.cyan;
  
  			if (Banner.Style == CoatOfArms.Style.OneColorFourItems || Banner.Style == CoatOfArms.Style.OneColorTwoItems) {
  				color2Text = "(None)";
  				color3Text = "(None)";
  				color4Text = "(None)";
  
  				color2 = color1;
  				color3 = color1;
  				color4 = color1;
  
  				color2Color = Color.gray;
  				color3Color = Color.gray;
  				color4Color = Color.gray;
  
  			} else if (Banner.Style == CoatOfArms.Style.TwoColorFourItems || Banner.Style == CoatOfArms.Style.TwoColorTwoItems) {
  				color3Text = "(None)";
  				color4Text = "(None)";
  
  				color3 = color1;
  				color4 = color2;
  
  				color3Color = Color.gray;
  				color4Color = Color.gray;
  			}
  
  
  			UnityEngine.GUI.color = Color.yellow;
  			GUILayout.Label ("\nCOLORS:");
  			UnityEngine.GUI.color = Color.cyan;
  
  			GUILayout.BeginHorizontal ();
  			UnityEngine.GUI.color = color1Color;
  			GUILayout.Label (color1Text, GUILayout.Width (100));
  			UnityEditor.EditorGUILayout.ColorField (color1);
  			Banner.BannerItemColorIndex [0] = UnityEditor.EditorGUILayout.IntPopup (Banner.BannerItemColorIndex [0], bannerIconColorNames, bannerIconColorIndexes);
  			GUILayout.EndHorizontal ();
  
  			GUILayout.BeginHorizontal ();
  			UnityEngine.GUI.color = color2Color;
  			GUILayout.Label (color2Text, GUILayout.Width (100));
  			UnityEditor.EditorGUILayout.ColorField (color2);
  			Banner.BannerItemColorIndex [1] = UnityEditor.EditorGUILayout.IntPopup (Banner.BannerItemColorIndex [1], bannerIconColorNames, bannerIconColorIndexes);
  			GUILayout.EndHorizontal ();
  
  			GUILayout.BeginHorizontal ();
  			UnityEngine.GUI.color = color3Color;
  			GUILayout.Label (color3Text, GUILayout.Width (100));
  			UnityEditor.EditorGUILayout.ColorField (color3);
  			Banner.BannerItemColorIndex [2] = UnityEditor.EditorGUILayout.IntPopup (Banner.BannerItemColorIndex [2], bannerIconColorNames, bannerIconColorIndexes);
  			GUILayout.EndHorizontal ();
  
  			GUILayout.BeginHorizontal ();
  			UnityEngine.GUI.color = color4Color;
  			GUILayout.Label (color4Text, GUILayout.Width (100));
  			UnityEditor.EditorGUILayout.ColorField (color4);
  			Banner.BannerItemColorIndex [3] = UnityEditor.EditorGUILayout.IntPopup (Banner.BannerItemColorIndex [3], bannerIconColorNames, bannerIconColorIndexes);
  			GUILayout.EndHorizontal ();
  
  			Colors.BannerColors.Refresh ();
  
  			UnityEngine.GUI.color = Color.yellow;
  			GUILayout.Label ("\nICONS");
  			UnityEngine.GUI.color = Color.cyan;
  			string [] bannerIconNames = Colors.BannerColors.ObjectIconNames.ToArray ( );
  			int [] bannerIconIndexes = new int [bannerIconNames.Length];
  			for (int i = 0; i < bannerIconIndexes.Length; i++) {
  				bannerIconIndexes [i] = i;
  			}
  
  			string icon1Text = "Icon 1";
  			string icon2Text = "Icon 2";
  			string icon3Text = "Icon 3";
  			string icon4Text = "Icon 4";
  
  			Color icon1Color = color1;
  			Color icon2Color = color2;
  			Color icon3Color = color3;
  			Color icon4Color = color4;
  
  			if (Banner.Style == CoatOfArms.Style.OneColorTwoItems || Banner.Style == CoatOfArms.Style.OneColorTwoItems) {
  				icon3Text = "(None)";
  				icon4Text = "(None)";
  			}
  
  			GUILayout.BeginHorizontal ();
  			UnityEngine.GUI.color = icon1Color;
  
gt: 			GUILayout.Label (icon1Text, GUILayout.Width (100));