class HennaInfoWnd extends UICommonAPI;

// ?–Â®?Ð· ?Â¤?? ?Â©ÂµÂµ?Ð¼?? Â»???
const HENNA_EQUIP=1;		// ?–Â®?Ð·Â»?Â±Ð²Â±Ð²
const HENNA_UNEQUIP=2;		// ?–Â®?Ð·???Ð¼Â±Ð²
const DIALOG_ID_ADD = 12302;
const DIALOG_ID_DEL = 12303;

var int m_iState;
var int m_iHennaID;
var int m_iClassID;
var int m_iSeverID;
var bool bHasNeedDyeItem;
var int nSelectCostItemClassID;
var UIControlNeedItemList needItemListEquip;
var UIControlNeedItemList selectNeedItemListEquip;
var UIControlNeedItemList needItemListUnEquip;
var UIControlNeedItemList selectNeedItemListUnEquip;

function OnRegisterEvent()
{
	RegisterEvent(EV_HennaInfoWndShowHideEquip);
	RegisterEvent(EV_HennaInfoWndShowHideUnEquip);
	RegisterEvent(EV_NeedResetUIData);
	RegisterEvent(EV_ProtocolBegin + class'UIPacket'.const.S_EX_NEW_HENNA_EQUIP);
	RegisterEvent(EV_ProtocolBegin + class'UIPacket'.const.S_EX_NEW_HENNA_UNEQUIP);
	RegisterEvent(EV_DialogOK);
	RegisterEvent(EV_DialogCancel);
}

function OnLoad()
{
	SetClosingOnESC();

	OnRegisterEvent();

	GetTextBoxHandle("HennaInfoWnd.HennaInfoWndUnEquip.txtSTRString").SetTooltipCustomType(MakeTooltipSimpleText(GetSystemString(3366), 154));
	GetTextBoxHandle("HennaInfoWnd.HennaInfoWndUnEquip.txtDEXString").SetTooltipCustomType(MakeTooltipSimpleText(GetSystemString(3368), 154));
	GetTextBoxHandle("HennaInfoWnd.HennaInfoWndUnEquip.txtCONString").SetTooltipCustomType(MakeTooltipSimpleText(GetSystemString(3370), 154));
	GetTextBoxHandle("HennaInfoWnd.HennaInfoWndUnEquip.txtINTString").SetTooltipCustomType(MakeTooltipSimpleText(GetSystemString(3367), 154));

	GetTextBoxHandle("HennaInfoWnd.HennaInfoWndUnEquip.txtWITString").SetTooltipCustomType(MakeTooltipSimpleText(GetSystemString(3369), 154));
	GetTextBoxHandle("HennaInfoWnd.HennaInfoWndUnEquip.txtMENString").SetTooltipCustomType(MakeTooltipSimpleText(GetSystemString(3371), 154));
	GetTextBoxHandle("HennaInfoWnd.HennaInfoWndUnEquip.txtLUCString").SetTooltipCustomType(MakeTooltipSimpleText(GetSystemString(3372), 154));
	GetTextBoxHandle("HennaInfoWnd.HennaInfoWndUnEquip.txtCHAString").SetTooltipCustomType(MakeTooltipSimpleText(GetSystemString(3373), 154));
	initUIControlNeedItemList();	
}

function initUIControlNeedItemList()
{
	needItemListEquip = new class'UIControlNeedItemList';
	needItemListEquip.SetRichListControler(GetMeRichListCtrl("HennaInfoWndEquip.NeedItemRichListCtrl"));
	needItemListEquip.StartNeedItemList(1);
	needItemListEquip.SetHideMyNum(true);
	selectNeedItemListEquip = new class'UIControlNeedItemList';
	selectNeedItemListEquip.SetRichListControler(GetMeRichListCtrl("HennaInfoWndEquip.NeedItemSelectDialog_wnd.NeedItemSelect_ListCtrl"));
	GetMeRichListCtrl("HennaInfoWndEquip.NeedItemSelectDialog_wnd.NeedItemSelect_ListCtrl").SetSelectable(true);
	needItemListUnEquip = new class'UIControlNeedItemList';
	needItemListUnEquip.SetRichListControler(GetMeRichListCtrl("HennaInfoWndUnEquip.NeedItemRichListCtrl"));
	needItemListUnEquip.StartNeedItemList(1);
	needItemListUnEquip.SetHideMyNum(true);
	selectNeedItemListUnEquip = new class'UIControlNeedItemList';
	selectNeedItemListUnEquip.SetRichListControler(GetMeRichListCtrl("HennaInfoWndUnEquip.NeedItemSelectDialog_wnd.NeedItemSelect_ListCtrl"));
	GetMeRichListCtrl("HennaInfoWndUnEquip.NeedItemSelectDialog_wnd.NeedItemSelect_ListCtrl").SetSelectable(true);	
}

function OnClickButton(string strID)
{
	switch(strID)
	{
		case "btnPrev" :
			if(m_iState==HENNA_EQUIP)
			{
				RequestHennaItemList();
			}
			class'UIAPI_WINDOW'.static.HideWindow("HennaInfoWnd");
			break;
		case "btnOK" :
			if(m_iState==HENNA_EQUIP)
			{
				DialogSetID(12302);
				DialogSetCancelD(12302);
				DialogSetDefaultCancle();
				DialogShow(DialogModalType_Modalless, DialogType_OKCancel, GetSystemString(13906), string(self));
			}
			break;
		case "btnextract":
			if(m_iState == HENNA_UNEQUIP)
			{
				DialogSetID(12303);
				DialogSetCancelD(12303);
				DialogSetDefaultCancle();
				DialogShow(DialogModalType_Modalless, DialogType_OKCancel, GetSystemString(13907), string(self));
			}
			break;
		case "EXIT_Btn":
			OnReceivedCloseUI();
			break;
		case "NeedItemSelectArrow_btn":
			onToggleSelectNeedItem();
			break;
	}
}

function onToggleSelectNeedItem()
{
	if(m_iState == 1)
	{
		if(GetMeWindow("HennaInfoWndEquip.NeedItemSelectDialog_wnd").IsShowWindow())
		{
			GetMeWindow("HennaInfoWndEquip.NeedItemSelectDialog_wnd").HideWindow();			
		}
		else
		{
			GetMeWindow("HennaInfoWndEquip.NeedItemSelectDialog_wnd").ShowWindow();
		}		
	}
	else
	{
		if(GetMeWindow("HennaInfoWndUnEquip.NeedItemSelectDialog_wnd").IsShowWindow())
		{
			GetMeWindow("HennaInfoWndUnEquip.NeedItemSelectDialog_wnd").HideWindow();			
		}
		else
		{
			GetMeWindow("HennaInfoWndUnEquip.NeedItemSelectDialog_wnd").ShowWindow();
		}
	}	
}

function OnShow()
{
	// Â»????? Âµ?Â¶? ?Â©ÂµÂµ?Â¦ ???Â©?Ð¦Â°Ð½ ??Â°Ð¬?Ð­???Ð©
	if(m_iState == HENNA_EQUIP)
	{
		// ?????? - ?–Â®?Ð·Â»?Â±Ð²Â±Ð²
		setWindowTitleByString(GetSystemString(651));
		class'UIAPI_WINDOW'.static.HideWindow("HennaInfoWnd.HennaInfoWndUnEquip");
		class'UIAPI_WINDOW'.static.ShowWindow("HennaInfoWnd.HennaInfoWndEquip");
	}
	else if(m_iState==HENNA_UNEQUIP)
	{
		// ?????? - ?–Â®?Ð·???Ð¼Â±Ð²
		setWindowTitleByString(GetSystemString(652));
		class'UIAPI_WINDOW'.static.HideWindow("HennaInfoWnd.HennaInfoWndEquip");
		class'UIAPI_WINDOW'.static.ShowWindow("HennaInfoWnd.HennaInfoWndUnEquip");
	}
	else
	{
		//debug("??Â·???Â·? ??Â»???Â»?~~");
	}
}

function OnHide()
{
	getInstanceL2Util().syncWindowLoc(getCurrentWindowName(string(self)), "HennaListWnd");
	if(DialogIsMine())
	{
		DialogHide();
	}
}

function OnEvent(int Event_ID, string param)
{
	if(! getInstanceUIData().getIsClassicServer())
	{
		return;
	}
	switch(Event_ID)
	{
		case EV_DialogOK:
			if(DialogIsMine())
			{
				if((DialogGetID()) == 12302)
				{
					API_C_EX_NEW_HENNA_EQUIP(HennaMenuWnd(GetScript("HennaMenuWnd")).getSelectIndexSlot(), m_iSeverID, nSelectCostItemClassID);					
				}
				else if((DialogGetID()) == 12303)
				{
					API_C_EX_NEW_HENNA_UNEQUIP(nSelectCostItemClassID);
				}
			}
			break;
		case EV_DialogCancel:
			break;
	case EV_HennaInfoWndShowHideEquip :
			m_iState=HENNA_EQUIP;		// Â»????Â¦ "?–Â®?Ð·Â»?Â±Ð²Â±Ð²"Â·? ?–Ð©?Ð¯???Ð©.
			GetButtonHandle("HennaInfoWnd.btnPrev").ShowWindow();
			GetButtonHandle("HennaInfoWnd.btnOK").ShowWindow();
			GetButtonHandle("HennaInfoWnd.btnOK").DisableWindow();
			GetButtonHandle("HennaInfoWnd.btnextract").HideWindow();
			ShowHennaInfoWnd(param);
			break;
	case EV_HennaInfoWndShowHideUnEquip :
			m_iState=HENNA_UNEQUIP;		// Â»????Â¦ "?–Â®?Ð·???Ð¼Â±Ð²"Â·? ?–Ð©?Ð¯???Ð©.
			GetButtonHandle("HennaInfoWnd.btnPrev").HideWindow();
			GetButtonHandle("HennaInfoWnd.btnOK").HideWindow();
			GetButtonHandle("HennaInfoWnd.btnextract").ShowWindow();
			GetButtonHandle("HennaInfoWnd.btnextract").DisableWindow();
			ShowHennaInfoWnd(param);
			break;
	case EV_NeedResetUIData :       // Â»????Â¦ LUC, CHA?Â¦ ?Â­?–? ?????? Âµ?Â¶? ????Â°??? ?????? ??Â°Ð¤ ?Ð¥???Ð©.
		
		if(getInstanceUIData().getIsClassicServer())
		{
			class'UIAPI_WINDOW'.static.HideWindow("HennaInfoWnd.txtLUCString");
			class'UIAPI_WINDOW'.static.HideWindow("HennaInfoWnd.txtLUCBefore");
			class'UIAPI_WINDOW'.static.HideWindow("HennaInfoWnd.txtLUCArrow");
			class'UIAPI_WINDOW'.static.HideWindow("HennaInfoWnd.txtLUCAfter");
			class'UIAPI_WINDOW'.static.HideWindow("HennaInfoWnd.txtCHAString");
			class'UIAPI_WINDOW'.static.HideWindow("HennaInfoWnd.txtCHABefore");
			class'UIAPI_WINDOW'.static.HideWindow("HennaInfoWnd.txtCHAArrow");
			class'UIAPI_WINDOW'.static.HideWindow("HennaInfoWnd.txtCHAAfter");		
		}
		else 
		{
			class'UIAPI_WINDOW'.static.ShowWindow("HennaInfoWnd.txtLUCString");
			class'UIAPI_WINDOW'.static.ShowWindow("HennaInfoWnd.txtLUCBefore");
			class'UIAPI_WINDOW'.static.ShowWindow("HennaInfoWnd.txtLUCArrow");
			class'UIAPI_WINDOW'.static.ShowWindow("HennaInfoWnd.txtLUCAfter");
			class'UIAPI_WINDOW'.static.ShowWindow("HennaInfoWnd.txtCHAString");
			class'UIAPI_WINDOW'.static.ShowWindow("HennaInfoWnd.txtCHABefore");
			class'UIAPI_WINDOW'.static.ShowWindow("HennaInfoWnd.txtCHAArrow");
			class'UIAPI_WINDOW'.static.ShowWindow("HennaInfoWnd.txtCHAAfter");		
		}
		break;
		case EV_ProtocolBegin + class'UIPacket'.const.S_EX_NEW_HENNA_EQUIP:
			ParsePacket_S_EX_NEW_HENNA_EQUIP();
			break;
		case EV_ProtocolBegin + class'UIPacket'.const.S_EX_NEW_HENNA_UNEQUIP:
			ParsePacket_S_EX_NEW_HENNA_UNEQUIP();
			break;
	}
}

function ParsePacket_S_EX_NEW_HENNA_EQUIP()
{
	local UIPacket._S_EX_NEW_HENNA_EQUIP packet;
	local ItemInfo dyeItemInfo;
	local int dyeItemClassID;

	if(! class'UIPacket'.static.Decode_S_EX_NEW_HENNA_EQUIP(packet))
	{
		return;
	}
	Debug(" -->  Decode_S_EX_NEW_HENNA_EQUIP :  " @ string(packet.cSlotID) @ string(packet.nHennaID) @ string(packet.cSuccess));
	class'UIAPI_WINDOW'.static.HideWindow("HennaInfoWnd");
	class'UIAPI_WINDOW'.static.ShowWindow("HennaMenuWnd");
	class'UIAPI_WINDOW'.static.SetFocus("HennaMenuWnd");
	class'UIDATA_HENNA'.static.GetHennaDyeItemClassID(packet.nHennaID, dyeItemClassID);
	dyeItemInfo = GetItemInfoByClassID(dyeItemClassID);
	Debug("?¥ì°© dyeItemInfo" @ dyeItemInfo.Name);
	if(packet.cSuccess > 0)
	{
		getInstanceL2Util().showGfxScreenMessage(GetSystemMessage(877));
	}
}

function ParsePacket_S_EX_NEW_HENNA_UNEQUIP()
{
	local UIPacket._S_EX_NEW_HENNA_UNEQUIP packet;

	if(! class'UIPacket'.static.Decode_S_EX_NEW_HENNA_UNEQUIP(packet))
	{
		return;
	}
	Debug(" -->  Decode_S_EX_NEW_HENNA_UNEQUIP :  " @ string(packet.cSlotID) @ string(packet.cSuccess));
	class'UIAPI_WINDOW'.static.HideWindow("HennaInfoWnd");
	class'UIAPI_WINDOW'.static.ShowWindow("HennaMenuWnd");
	class'UIAPI_WINDOW'.static.SetFocus("HennaMenuWnd");
	if(packet.cSuccess > 0)
	{
		getInstanceL2Util().showGfxScreenMessage(GetSystemMessage(878));
	}
}

event OnClickListCtrlRecord(string strID)
{
	local int selectNeedItemIndex, selectedClassID;
	local INT64 selectedAmount;

	Debug("strID" @ strID);
	if(m_iState == HENNA_EQUIP)
	{
		selectNeedItemIndex = GetMeRichListCtrl("HennaInfoWndEquip.NeedItemSelectDialog_wnd.NeedItemSelect_ListCtrl").GetSelectedIndex();
		selectNeedItemListEquip.GetItemClassID(selectNeedItemIndex, selectedClassID);
		selectNeedItemListEquip.GetItemNeedAmount(selectNeedItemIndex, selectedAmount);
		nSelectCostItemClassID = selectedClassID;
		needItemListEquip.CleariObjects();
		needItemListEquip.AddNeedItemClassID(selectedClassID, selectedAmount);
		needItemListEquip.SetBuyNum(1);
		GetMeWindow("HennaInfoWndEquip.NeedItemSelectDialog_wnd").HideWindow();
		GetMeWindow("HennaInfoWndEquip.NeedItemSelect_wnd").HideWindow();
		if(bHasNeedDyeItem && needItemListEquip.GetCanBuy())
		{
			GetMeButton("btnOK").EnableWindow();
			GetMeButton("btnOK").ClearTooltip();			
		}
		else
		{
			GetMeButton("btnOK").DisableWindow();
			GetMeButton("btnOK").SetTooltipCustomType(MakeTooltipSimpleText(GetSystemString(13448)));
		}		
	}
	else
	{
		selectNeedItemIndex = GetMeRichListCtrl("HennaInfoWndUnEquip.NeedItemSelectDialog_wnd.NeedItemSelect_ListCtrl").GetSelectedIndex();
		selectNeedItemListUnEquip.GetItemClassID(selectNeedItemIndex, selectedClassID);
		selectNeedItemListUnEquip.GetItemNeedAmount(selectNeedItemIndex, selectedAmount);
		nSelectCostItemClassID = selectedClassID;
		needItemListUnEquip.CleariObjects();
		needItemListUnEquip.AddNeedItemClassID(selectedClassID, selectedAmount);
		needItemListUnEquip.SetBuyNum(1);
		GetMeWindow("HennaInfoWndUnEquip.NeedItemSelectDialog_wnd").HideWindow();
		GetMeWindow("HennaInfoWndUnEquip.NeedItemSelect_wnd").HideWindow();
		if(needItemListUnEquip.GetCanBuy())
		{
			GetMeButton("btnextract").EnableWindow();
			GetMeButton("btnextract").ClearTooltip();			
		}
		else
		{
			GetMeButton("btnextract").DisableWindow();
			GetMeButton("btnextract").SetTooltipCustomType(MakeTooltipSimpleText(GetSystemString(13448)));
		}
	}	
}

function ShowHennaInfoWnd(string param)
{
	local string strAdenaComma;

	local INT64 iAdena;
	local string strDyeName;			// ?Â°Â·Ð±
	local string strDyeIconName;
	local int iHennaID;
	local int iClassID;
	local INT64 iNum;

	local string strTattooName;			// ?–Â®?Ð·
	local string strTattooAddName;		// ?–Â®?Ð·
	local string strTattooIconName;

	local int iINTnow, iINTchange, iSTRnow, iSTRchange, iCONnow, iCONchange,
		iMENnow, iMENchange, iDEXnow, iDEXchange, iWITnow,
		iWITchange, iLUCnow, iLUCchange, iCHAnow, iCHAchange,
		dyeItemlevel, iNeedCount, iCancelCount;

	local color col;
	local int i, nWearFeeItemListCount, nWearFeeItemClassID, nWearFeeItemAmount, nCancelFeeItemListCount, nCancelFeeItemClassID,
		nCancelFeeItemAmount;
	local array<ItemInfo> itemInfoArray;

	ParseINT64(param, "Adena", iAdena);						// ??Âµ???
	ParseString(param, "DyeIconName", strDyeIconName);		// ?Â°Â·Ð± Icon ???Â§
	ParseString(param, "DyeName", strDyeName);				// ?Â°Â·Ð±???Â§
	ParseInt(param, "HennaID", iHennaID);				 
	ParseInt(param, "ClassID", iClassID);

	ParseString(param, "TattooIconName", strTattooIconName);	// ?–Â®?Ð·?????Ð¬???Â§
	ParseString(param, "TattooName", strTattooName);		// ?–Â®?Ð·???Â§
	ParseString(param, "TattooAddName", strTattooAddName);	// ?–Â®?Ð·?Â¤?? - ??????Âµ??Ð¨???Â® 

	ParseInt(param, "INTnow", iINTnow);
	ParseInt(param, "INTchange", iINTchange);
	ParseInt(param, "STRnow", iSTRnow);
	ParseInt(param, "STRchange", iSTRchange);
	ParseInt(param, "CONnow", iCONnow);
	ParseInt(param, "CONchange", iCONchange);
	ParseInt(param, "MENnow", iMENnow);
	ParseInt(param, "MENchange", iMENchange);
	ParseInt(param, "DEXnow", iDEXnow);
	ParseInt(param, "DEXchange", iDEXchange);
	ParseInt(param, "WITnow", iWITnow);
	ParseInt(param, "WITchange", iWITchange);
	
	//??Â±Ð¤???? Â·Â°?Â°, ?Â«?Â®???Â¶
	ParseInt(param, "LUCnow", iLUCnow);
	ParseInt(param, "LUCchange", iLUCchange);
	ParseInt(param, "CHAnow", iCHAnow);
	ParseInt(param, "CHAchange", iCHAchange);
	ParseINT64(param, "NumOfItem", iNum);
	ParseInt(param, "WearFeeItemListCount", nWearFeeItemListCount);

	m_iHennaID=iHennaID;		// ?–Â®?Ð·?Â» Â»?Â±Ð²Â°??? ?Â¦Â°??Ð¢Â¶Â§ ???Ð´???–?Â·? ID?Â¦ ???Ðµ?Ð¨ÂµÐ£???Ð©
	m_iClassID = iClassID;
	class'UIDATA_HENNA'.static.GetHennaDyeItemLevel(iHennaID, dyeItemlevel);
	class'UIDATA_INVENTORY'.static.FindItemByClassID(m_iClassID, itemInfoArray);
	m_iSeverID = itemInfoArray[0].Id.ServerID;
	if(m_iState == HENNA_EQUIP)
	{
		ParseInt(param, "NeedCount", iNeedCount);
		// ?Â°Â·Ð±
		class'UIAPI_TEXTBOX'.static.SetText("HennaInfoWnd.txtDyeInfo", GetSystemString(638));			// "?Â°Â·Ð±?Â¤??"
		class'UIAPI_TEXTURECTRL'.static.SetTexture("HennaInfoWnd.textureDyeIconName", strDyeIconName);	// ?Â°Â·Ð± Icon
		class'UIAPI_TEXTBOX'.static.SetText("HennaInfoWnd.txtDyeName", strDyeName);						// ?Â°Â·Ð±???Â§

		col.R=168;
		col.G=168;
		col.B=168;
		class'UIAPI_TEXTBOX'.static.SetText("HennaInfoWnd.txtFee", GetSystemString(637)$ " : ");		// "????Â·Ð± : "
		class'UIAPI_TEXTBOX'.static.SetTextColor("HennaInfoWnd.txtFee", col);		

		// ?–Â®?Ð·
		class'UIAPI_TEXTBOX'.static.SetText("HennaInfoWnd.txtTattooInfo", GetSystemString(639));		// "?–Â®?Ð·?Â¤??"
		class'UIAPI_TEXTURECTRL'.static.SetTexture("HennaInfoWnd.textureTattooIconName", strTattooIconName);	// ?–Â®?Ð· Icon
		class'UIAPI_TEXTBOX'.static.SetText("HennaInfoWnd.txtTattooName", strTattooName);		// ?–Â®?Ð·???Â§
		class'UIAPI_TEXTBOX'.static.SetText("HennaInfoWnd.txtTattooAddName", strTattooAddName);
		if(iNeedCount <= iNum)
		{
			class'UIAPI_TEXTBOX'.static.SetTextColor("HennaInfoWnd.txtDyeNeedItem", GTColor().White);
			bHasNeedDyeItem = true;			
		}
		else
		{
			class'UIAPI_TEXTBOX'.static.SetTextColor("HennaInfoWnd.txtDyeNeedItem", GTColor().Red);
			bHasNeedDyeItem = false;
		}
		class'UIAPI_TEXTBOX'.static.SetText("HennaInfoWnd.txtDyeNeedItem", MakeFullSystemMsg(GetSystemMessage(2781), string(iNeedCount)));
		selectNeedItemListEquip.CleariObjects();
		if(nWearFeeItemListCount == 0)
		{
			GetMeWindow("HennaInfoWndEquip.NeedItemSelectArrow_btn").HideWindow();
			GetMeWindow("HennaInfoWndEquip.NeedItemSelect_wnd").ShowWindow();
			GetMeTextBox("HennaInfoWndEquip.NeedItemSelect_wnd.text").SetText(GetSystemString(13466));
			GetMeWindow("HennaInfoWndEquip.NeedItemSelectDialog_wnd").HideWindow();
			nSelectCostItemClassID = 0;
			if(bHasNeedDyeItem)
			{
				GetMeButton("btnOK").EnableWindow();
				GetMeButton("btnOK").ClearTooltip();				
			}
			else
			{
				GetMeButton("btnOK").DisableWindow();
				GetMeButton("btnOK").SetTooltipCustomType(MakeTooltipSimpleText(GetSystemString(13448)));
			}			
		}
		else if(nWearFeeItemListCount == 1)
		{
			GetMeWindow("HennaInfoWndEquip.NeedItemSelectArrow_btn").HideWindow();
				
			for(i = 0; i < nWearFeeItemListCount; i++)
			{
				ParseInt(param, "WearFeeItemClassID_" $ string(i), nWearFeeItemClassID);
				ParseInt(param, "WearFeeItemAmount_" $ string(i), nWearFeeItemAmount);
			}
			needItemListEquip.CleariObjects();
			needItemListEquip.CleariObjects();
			needItemListEquip.AddNeedItemClassID(nWearFeeItemClassID, nWearFeeItemAmount);
			needItemListEquip.SetBuyNum(1);
			nSelectCostItemClassID = nWearFeeItemClassID;
			GetMeWindow("HennaInfoWndEquip.NeedItemSelect_wnd").HideWindow();
			GetMeWindow("HennaInfoWndEquip.NeedItemSelectDialog_wnd").HideWindow();
			if(bHasNeedDyeItem && needItemListEquip.GetCanBuy())
			{
				GetMeButton("btnOK").EnableWindow();
				GetMeButton("btnOK").ClearTooltip();					
			}
			else
			{
				GetMeButton("btnOK").DisableWindow();
				GetMeButton("btnOK").SetTooltipCustomType(MakeTooltipSimpleText(GetSystemString(13448)));
			}				
		}
		else
		{
			GetMeWindow("HennaInfoWndEquip.NeedItemSelectArrow_btn").ShowWindow();
			GetMeWindow("HennaInfoWndEquip.NeedItemSelectDialog_wnd").SetWindowSize(284, (40 * nWearFeeItemListCount) + 12);
			selectNeedItemListEquip.StartNeedItemList(nWearFeeItemListCount);
			GetMeRichListCtrl("HennaInfoWndEquip.NeedItemSelectDialog_wnd.NeedItemSelect_ListCtrl").AdjustShowRow(nWearFeeItemListCount);
			GetMeRichListCtrl("HennaInfoWndEquip.NeedItemSelectDialog_wnd.NeedItemSelect_ListCtrl").SetWindowSize(280, 40 * nWearFeeItemListCount);
			selectNeedItemListEquip.SetBuyNum(1);

			for(i = 0; i < nWearFeeItemListCount; i++)
			{
				ParseInt(param, "WearFeeItemClassID_" $ string(i), nWearFeeItemClassID);
				ParseInt(param, "WearFeeItemAmount_" $ string(i), nWearFeeItemAmount);
				selectNeedItemListEquip.AddNeedItemClassID(nWearFeeItemClassID, nWearFeeItemAmount);
			}
			GetMeTextBox("HennaInfoWndUnEquip.NeedItemSelect_wnd.text").SetText(GetSystemString(14054));
			GetMeWindow("HennaInfoWndEquip.NeedItemSelect_wnd").ShowWindow();
			GetMeWindow("HennaInfoWndEquip.NeedItemSelectDialog_wnd").ShowWindow();
			GetMeWindow("HennaInfoWndEquip.NeedItemSelectDialog_wnd").SetFocus();
		}
	}
	else if(m_iState==HENNA_UNEQUIP)
	{
		ParseInt(param, "CancelCount", iCancelCount);
		ParseInt(param, "CancelFeeItemListCount", nCancelFeeItemListCount);
		// ?–Â®?Ð·
		class'UIAPI_TEXTBOX'.static.SetText("HennaInfoWnd.txtTattooInfoUnEquip", GetSystemString(639));		// "?–Â®?Ð·?Â¤??"
		class'UIAPI_TEXTURECTRL'.static.SetTexture("HennaInfoWnd.textureTattooIconNameUnEquip", strTattooIconName);	// ?–Â®?Ð· Icon
		class'UIAPI_TEXTBOX'.static.SetText("HennaInfoWnd.txtTattooNameUnEquip", GetSystemString(652)$":"$strTattooName);		// ?–Â®?Ð·???Â§
		class'UIAPI_TEXTBOX'.static.SetText("HennaInfoWnd.txtTattooAddNameUnEquip", strTattooAddName);		// ?–Â®?Ð·??Â°??Â¤??

		// ?Â°Â·Ð±
		class'UIAPI_TEXTBOX'.static.SetText("HennaInfoWnd.txtDyeInfoUnEquip", GetSystemString(638));			// "?Â°Â·Ð±?Â¤??"
		class'UIAPI_TEXTURECTRL'.static.SetTexture("HennaInfoWnd.textureDyeIconNameUnEquip", strDyeIconName);	// ?Â°Â·Ð± Icon
		class'UIAPI_TEXTBOX'.static.SetText("HennaInfoWnd.txtDyeNameUnEquip", strDyeName);						// ?Â°Â·Ð±???Â§

		col.R=168;
		col.G=168;
		col.B=168;
		class'UIAPI_TEXTBOX'.static.SetText("HennaInfoWnd.txtFeeUnEquip", GetSystemString(637)$ " : ");		// "????Â·Ð± : "
		class'UIAPI_TEXTBOX'.static.SetTextColor("HennaInfoWnd.txtFeeUnEquip", col);		

		class'UIAPI_TEXTBOX'.static.SetText("HennaInfoWnd.HennaInfoWndUnEquip.txtTattooNameStepUnEquip", MakeFullSystemMsg(GetSystemMessage(5203), string(dyeItemlevel)));
		class'UIAPI_TEXTBOX'.static.SetText("HennaInfoWnd.HennaInfoWndUnEquip.txtDyeExtractItemUnEquip", MakeFullSystemMsg(GetSystemMessage(2781), string(iCancelCount)));
		Debug("nCancelFeeItemListCount" @ string(nCancelFeeItemListCount));
		if(nCancelFeeItemListCount == 0)
		{
			GetMeButton("HennaInfoWndUnEquip.NeedItemSelectArrow_btn").HideWindow();
			GetMeWindow("HennaInfoWndUnEquip.NeedItemSelect_wnd").ShowWindow();
			GetMeTextBox("HennaInfoWndUnEquip.NeedItemSelect_wnd.text").SetText(GetSystemString(13466));
			GetMeWindow("HennaInfoWndEquip.NeedItemSelectDialog_wnd").HideWindow();
			nSelectCostItemClassID = 0;
			GetMeButton("btnextract").EnableWindow();				
		}
		else if(nCancelFeeItemListCount == 1)
		{
			GetMeButton("HennaInfoWndUnEquip.NeedItemSelectArrow_btn").HideWindow();
			
			for(i = 0; i < nCancelFeeItemListCount; i++)
			{
				ParseInt(param, "CancelFeeItemClassID_" $ string(i), nCancelFeeItemClassID);
				ParseInt(param, "CancelFeeItemAmount_" $ string(i), nCancelFeeItemAmount);
			}
			needItemListUnEquip.CleariObjects();
			needItemListUnEquip.CleariObjects();
			needItemListUnEquip.AddNeedItemClassID(nCancelFeeItemClassID, nCancelFeeItemAmount);
			needItemListUnEquip.SetBuyNum(1);
			nSelectCostItemClassID = nCancelFeeItemClassID;
			GetMeWindow("HennaInfoWndUnEquip.NeedItemSelect_wnd").HideWindow();
			GetMeWindow("HennaInfoWndUnEquip.NeedItemSelectDialog_wnd").HideWindow();
			if(needItemListUnEquip.GetCanBuy())
			{
				GetMeButton("btnextract").EnableWindow();
				GetMeButton("btnextract").ClearTooltip();						
			}
			else
			{
				GetMeButton("btnextract").DisableWindow();
				GetMeButton("btnextract").SetTooltipCustomType(MakeTooltipSimpleText(GetSystemString(13448)));
			}					
		}
		else
		{
			GetMeWindow("HennaInfoWndUnEquip.NeedItemSelectArrow_btn").ShowWindow();
			selectNeedItemListEquip.CleariObjects();
			GetMeTextBox("HennaInfoWndUnEquip.NeedItemSelect_wnd.text").SetText(GetSystemString(14054));
			GetMeWindow("HennaInfoWndUnEquip.NeedItemSelectDialog_wnd").SetWindowSize(284, (40 * nCancelFeeItemListCount) + 12);
			selectNeedItemListUnEquip.StartNeedItemList(nCancelFeeItemListCount);
			GetMeRichListCtrl("HennaInfoWndUnEquip.NeedItemSelectDialog_wnd.NeedItemSelect_ListCtrl").AdjustShowRow(nCancelFeeItemListCount);
			GetMeRichListCtrl("HennaInfoWndUnEquip.NeedItemSelectDialog_wnd.NeedItemSelect_ListCtrl").SetWindowSize(280, 40 * nCancelFeeItemListCount);
			selectNeedItemListUnEquip.SetBuyNum(1);
			
			for(i = 0; i < nCancelFeeItemListCount; i++)
			{
				ParseInt(param, "CancelFeeItemClassID_" $ string(i), nCancelFeeItemClassID);
				ParseInt(param, "CancelFeeItemAmount_" $ string(i), nCancelFeeItemAmount);
				selectNeedItemListUnEquip.AddNeedItemClassID(nCancelFeeItemClassID, nCancelFeeItemAmount);
			}
			GetMeWindow("HennaInfoWndUnEquip.NeedItemSelect_wnd").ShowWindow();
			GetMeWindow("HennaInfoWndUnEquip.NeedItemSelectDialog_wnd").ShowWindow();
			GetMeWindow("HennaInfoWndUnEquip.NeedItemSelectDialog_wnd").SetFocus();
		}
	}

	class'UIAPI_TEXTBOX'.static.SetText("HennaInfoWnd.txtTattooNameStep", MakeFullSystemMsg(GetSystemMessage(5203), string(dyeItemlevel)));
	// ???????Â­
	class'UIAPI_TEXTBOX'.static.SetInt("HennaInfoWnd.txtSTRBefore", iSTRnow);		// STR ???Ð·
	class'UIAPI_TEXTBOX'.static.SetInt("HennaInfoWnd.txtSTRAfter", iSTRchange);		// STR ???Â­??
	class'UIAPI_TEXTBOX'.static.SetInt("HennaInfoWnd.txtDEXBefore", iDEXnow);		// DEX ???Ð·
	class'UIAPI_TEXTBOX'.static.SetInt("HennaInfoWnd.txtDEXAfter", iDEXchange);		// DEX ???Â­??
	class'UIAPI_TEXTBOX'.static.SetInt("HennaInfoWnd.txtCONBefore", iCONnow);		// CON ???Ð·
	class'UIAPI_TEXTBOX'.static.SetInt("HennaInfoWnd.txtCONAfter", iCONchange);		// CON ???Â­??
	class'UIAPI_TEXTBOX'.static.SetInt("HennaInfoWnd.txtINTBefore", iINTnow);		// INT ???Ð·
	class'UIAPI_TEXTBOX'.static.SetInt("HennaInfoWnd.txtINTAfter", iINTchange);		// INT ???Â­??
	class'UIAPI_TEXTBOX'.static.SetInt("HennaInfoWnd.txtWITBefore", iWITnow);		// WIT ???Ð·
	class'UIAPI_TEXTBOX'.static.SetInt("HennaInfoWnd.txtWITAfter", iWITchange);		// WIT ???Â­??
	class'UIAPI_TEXTBOX'.static.SetInt("HennaInfoWnd.txtMENBefore", iMENnow);		// MEN ???Ð·
	class'UIAPI_TEXTBOX'.static.SetInt("HennaInfoWnd.txtMENAfter", iMENchange);		// MEN ???Â­??

	//??Â±Ð¤???? Â·Â°?Â°, ?Â«?Â®???Â¶
	class'UIAPI_TEXTBOX'.static.SetInt("HennaInfoWnd.txtLUCBefore", iLUCnow);		// LUC ???Ð·
	class'UIAPI_TEXTBOX'.static.SetInt("HennaInfoWnd.txtLUCAfter", iLUCchange);		// LUC ???Â­??
	class'UIAPI_TEXTBOX'.static.SetInt("HennaInfoWnd.txtCHABefore", iCHAnow);		// CHA ???Ð·
	class'UIAPI_TEXTBOX'.static.SetInt("HennaInfoWnd.txtCHAAfter", iCHAchange);		// CHA ???Â­??

	class'UIAPI_WINDOW'.static.HideWindow("HennaListWnd");

	class'UIAPI_WINDOW'.static.ShowWindow("HennaInfoWnd");
	class'UIAPI_WINDOW'.static.SetFocus("HennaInfoWnd");
}

function API_C_EX_NEW_HENNA_EQUIP(int nSlotID, int nItemSid, int nCostItemId)
{
	local array<byte> stream;
	local UIPacket._C_EX_NEW_HENNA_EQUIP packet;

	packet.cSlotID = nSlotID;
	packet.nItemSid = nItemSid;
	packet.nCostItemId = nCostItemId;
	if(! class'UIPacket'.static.Encode_C_EX_NEW_HENNA_EQUIP(stream, packet))
	{
		return;
	}
	class'UIPacket'.static.RequestUIPacket(class'UIPacket'.const.C_EX_NEW_HENNA_EQUIP, stream);
	Debug("Api Call -----> C_EX_NEW_HENNA_EQUIP" @ string(packet.cSlotID) @ string(packet.nItemSid) @ string(packet.nCostItemId));
}

function API_C_EX_NEW_HENNA_UNEQUIP(int nCostItemId)
{
	local array<byte> stream;
	local UIPacket._C_EX_NEW_HENNA_UNEQUIP packet;

	packet.cSlotID = HennaMenuWnd(GetScript("HennaMenuWnd")).getSelectIndexSlot();
	packet.nCostItemId = nCostItemId;
	if(! class'UIPacket'.static.Encode_C_EX_NEW_HENNA_UNEQUIP(stream, packet))
	{
		return;
	}
	class'UIPacket'.static.RequestUIPacket(class'UIPacket'.const.C_EX_NEW_HENNA_UNEQUIP, stream);
	Debug("Api Call -----> C_EX_NEW_HENNA_UNEQUIP" @ string(packet.cSlotID) @ string(packet.nCostItemId));
}

/**
 * ?Â©ÂµÂµ?Ð¼ ESC ?Â°Â·? ?Ð­Â±Ð² ???Â® 
 * "Esc" Key
 ***/
function OnReceivedCloseUI()
{
	PlayConsoleSound(IFST_WINDOW_CLOSE);
	GetWindowHandle("HennaInfoWnd").HideWindow();
	ShowWindowWithFocus("HennaMenuWnd");
}
