using System;

public class WindowPartsMekureCheckBox : WFCheckBox
{
	public override void Awake()
	{
		base.Awake();
		this.onClick.Add(delegate(WFCheckBox check_box)
		{
			this.Apply();
			this.UpdateGui();
		});
	}

	public void SetMaid(Maid maid)
	{
		this.maid_ = maid;
		this.UpdateGui();
	}

	public void UpdateGui()
	{
		if (this.maid_ == null)
		{
			bool flag = false;
			base.check = flag;
			base.enabled = flag;
		}
		else if (!this.IsItemChangeEnabled(this.maid_))
		{
			bool flag = false;
			base.check = flag;
			base.enabled = flag;
		}
		else
		{
			base.enabled = true;
			base.check = this.IsItemChange(this.maid_);
		}
	}

	public void Apply()
	{
		if (this.maid_ == null || !this.IsItemChangeEnabled(this.maid_))
		{
			return;
		}
		if (!base.check)
		{
			string[] category_array = this.category_array;
			for (int i = 0; i < category_array.Length; i++)
			{
				this.maid_.ResetProp(category_array[i], false);
			}
		}
		else
		{
			string[] category_array2 = this.category_array;
			for (int j = 0; j < category_array2.Length; j++)
			{
				this.maid_.ItemChangeTemp(category_array2[j], this.prop_value_name);
			}
		}
		this.maid_.AllProcProp();
		GravityControlWindow gravityControlWindow = this.mgr.GetWindow(PhotoWindowManager.WindowType.GravityContro) as GravityControlWindow;
		gravityControlWindow.OnChangeMekure();
	}

	private bool IsItemChangeEnabled(Maid maid)
	{
		bool result = false;
		string[] category_array = this.category_array;
		for (int i = 0; i < category_array.Length; i++)
		{
			if (maid.IsItemChangeEnabled(category_array[i], this.prop_value_name))
			{
				result = true;
				break;
			}
		}
		return result;
	}

	private bool IsItemChange(Maid maid)
	{
		bool result = false;
		string[] category_array = this.category_array;
		for (int i = 0; i < category_array.Length; i++)
		{
			if (maid.IsItemChange(category_array[i], this.prop_value_name))
			{
				result = true;
				break;
			}
		}
		return result;
	}

	private string[] category_array
	{
		get
		{
			if (this.CheckBoxMode == WindowPartsMekureCheckBox.Mode.MekureFront)
			{
				return new string[]
				{
					"skirt",
					"onepiece"
				};
			}
			if (this.CheckBoxMode == WindowPartsMekureCheckBox.Mode.MekureBack)
			{
				return new string[]
				{
					"skirt",
					"onepiece"
				};
			}
			return new string[]
			{
				"panz",
				"mizugi"
			};
		}
	}

	private string prop_value_name
	{
		get
		{
			if (this.CheckBoxMode == WindowPartsMekureCheckBox.Mode.MekureFront)
			{
				return "めくれスカート";
			}
			if (this.CheckBoxMode == WindowPartsMekureCheckBox.Mode.MekureBack)
			{
				return "めくれスカート後ろ";
			}
			return "パンツずらし";
		}
	}

	public WindowPartsMekureCheckBox.Mode CheckBoxMode;

	public PhotoWindowManager mgr;

	private Maid maid_;

	public enum Mode
	{
		MekureFront,
		MekureBack,
		Zurasi
	}
}
