class WorldExchangeBuyWnd extends UICommonAPI;

const INSERT_ONCE_LIST_NUM = 10;
const LOAD_ONCE_LIST_NUM = 100;
const REFRESHLIMIT = 1000;
const REFRESHLIMITMIN = 500;
const RESTARTPOINTITEM_LCOIN = 91663;
const MAIN_TAB_CLASSIC_MAX = 6;
const MAIN_TAB_LIVE_MAX = 7;

enum ItemMainType 
{
	Adena,
	Equipment,
	Artifact,
	Enchant,
	Consumable,
	EtcType,
	Collection,
	home
};

enum ItemSubtype 
{
	Weapon,
	Armor,
	Accessary,
	EtcEquipment,
	ArtifactB1,
	ArtifactC1,
	ArtifactD1,
	ArtifactA1,
	ENCHANTSCROLL,
	BlessEnchantScroll,
	MultiEnchantScroll,
	AncientEnchantScroll,
	Spiritshot,
	Soulshot,
	Buff,
	VariationStone,
	dye,
	SoulCrystal,
	SkillBook,
	EtcEnchant,
	PotionAndEtcScroll,
	ticket,
	Craft,
	IncEnchantProp,
	Adena,
	EtcSubtype
};

enum E_WORLD_EXCHANGE_SORT_TYPE 
{
	EWEST_NONE,
	EWEST_ITEM_NAME,
	EWEST_ENCHANT_ASCE,
	EWEST_ENCHANT_DESC,
	EWEST_PRICE_ASCE,
	EWEST_PRICE_DESC,
	EWEST_AMOUNT_ASCE,
	EWEST_AMOUNT_DESC,
	EWEST_PRICE_PER_PIECE_ASCE,
	EWEST_PRICE_PER_PIECE_DESC
};

enum HEADER_TYPE 
{
	ItemName,
	ItemNum,
	totalprice,
	perPrice
};

struct categoryStruct
{
	var int subSelectedIndex;
	var array<int> subCategoryStringArray;
	var array<int> subCategoryKeyArray;
	var array<int> subCategoryDotShow;
};

var INT64 ADENA_BASIC_UNIT;
var INT64 ADENA_MIN;
var INT64 ADENA_MAX;
var int refreshMinCount;
var int lastLoadedPage;
var int nMaxPage;
var bool bRQ_C_EX_WORLD_EXCHANGE_ITEM_LIST;
var array<UIPacket._WorldExchangeItemData> _itemDatas;
var L2UITimerObject tObjectListAdd;
var L2UITimerObject tObjectListRefreshDefaultDelay;
var UIControlTextInput uicontrolTextInputScr;
var RichListCtrlHandle List_RichList;
var RichListCtrlHandle List_RichListAdena;
var WindowHandle itemBuyDialog_Wnd;
var WindowHandle ItemBuyPopUp_Wnd;
var WindowHandle ItemBuyResultPopUp_Wnd;
var WindowHandle FindDisable_Wnd;
var string lastFindString;
var array<int> ItemList;
var bool bFirst;
var int scrollPos;
var int requestedScrollPos;
var UIControlGroupButtonAssets TopGroupButtonAsset;
var UIControlGroupButtonAssets SubGroupButtonAsset;
var CheckBoxHandle compareTooltipCheckBox;
var INT64 nWEIndex;
var int ShowHeaderIndex;
var int ShowHeaderIndexAdena;
var array<categoryStruct> categoryArray;
var private bool bFormSetting;

static function WorldExchangeBuyWnd Inst()
{
	return WorldExchangeBuyWnd(GetScript("WorldExchangeBUyWNd"));
}

event OnRegisterEvent()
{
	RegisterEvent(EV_Restart);
	RegisterEvent(EV_PacketID(class'UIPacket'.const.S_EX_WORLD_EXCHANGE_ITEM_LIST));
	RegisterEvent(EV_PacketID(class'UIPacket'.const.S_EX_WORLD_EXCHANGE_BUY_ITEM));
}

event OnLoad()
{
	SetClosingOnESC();
	InitHomeWnd();
	initGroupButton();
	List_RichList = GetRichListCtrlHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".List_RichList");
	List_RichList.SetSelectedSelTooltip(false);
	List_RichList.SetAppearTooltipAtMouseX(true);
	List_RichList.SetSortable(false);
	List_RichListAdena = GetRichListCtrlHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".List_RichListAdena");
	List_RichListAdena.SetSelectedSelTooltip(false);
	List_RichListAdena.SetAppearTooltipAtMouseX(true);
	List_RichListAdena.SetSortable(false);
	OnLoadEachServer();
	itemBuyDialog_Wnd = GetWindowHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".ItemBuyDialog_Wnd");
	ItemBuyPopUp_Wnd = GetWindowHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".ItemBuyDialog_Wnd.ItemBuyPopUp_Wnd");
	ItemBuyResultPopUp_Wnd = GetWindowHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".ItemBuyDialog_Wnd.ItemBuyResultPopUp_Wnd");
	FindDisable_Wnd = GetWindowHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".FindDisable_Wnd");
	FindDisable_Wnd.ShowWindow();
	ShowBuyResultPopup();
	uicontrolTextInputScr = class'UIControlTextInput'.static.InitScript(GetWindowHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".ItemFind_Wnd.TextInput"));
	uicontrolTextInputScr.DelegateESCKey = DelegateESCKey;
	uicontrolTextInputScr.DelegateOnChangeEdited = DelegateOnChangeEdited;
	uicontrolTextInputScr.DelegateOnCompleteEditBox = DelegateOnCompleteEditBox;
	uicontrolTextInputScr.DelegateOnClear = DelegateOnClear;
	uicontrolTextInputScr.SetDefaultString(GetSystemString(2507));
	uicontrolTextInputScr.SetEdtiable(true);
	uicontrolTextInputScr.SetDisable(true);
	InitTimerObject();
	compareTooltipCheckBox = GetCheckBoxHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".CompareTooltip_CheckBox");
	InitCompareTooltipCheckBox();
	SetSortType(E_WORLD_EXCHANGE_SORT_TYPE.EWEST_PRICE_PER_PIECE_ASCE/*8*/);
	List_RichList.SetAscend(0, true);
	List_RichList.ShowSortIcon(0);
	TopGroupButtonAsset._GetGroupButtonsInstance().DelegateOnClickButton = DelegateOnClickButtonTop;
	SubGroupButtonAsset._GetGroupButtonsInstance().DelegateOnClickButton = DelegateOnClickButtonSub;
	TopGroupButtonAsset._GetGroupButtonsInstance()._setTopOrder(0, true);
	TopGroupButtonAsset._GetGroupButtonsInstance()._SetDisable(TopGroupButtonAsset._GetGroupButtonsInstance()._FindButtonIndexByValue(6));
	GetTextureHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".TabIcon04_Tex").SetAlpha(100, 0.50f);
	TransformToHome();
}

private function InitHomeWnd()
{
	local WindowHandle Home_Wnd, SearchResult_Wnd;

	Home_Wnd = GetWindowHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".Home_Wnd");
	Home_Wnd.SetScript("WorldExchangeBuyHome");
	class'WorldExchangeBuyHome'.static.Inst().m_hOwnerWnd = Home_Wnd;
	SearchResult_Wnd = GetWindowHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".SearchResult_Wnd");
	SearchResult_Wnd.SetFocus();
	SearchResult_Wnd.HideWindow();
}

private function InitCompareTooltipCheckBox()
{
	local int compareTooltipEnable;

	if(! GetINIBool("WorldExchangeBuyWnd", "a", compareTooltipEnable, "WindowsInfo.ini"))
	{
		compareTooltipEnable = 1;
		SetINIBool("WorldExchangeBuyWnd", "a", bool(compareTooltipEnable), "WindowsInfo.ini");
	}
	compareTooltipCheckBox.SetCheck(bool(compareTooltipEnable));
	SetShowCompareTooltipOnWorldExchange(bool(compareTooltipEnable));	
}

private function InitTimerObject()
{
	local int Time, Count;

	Count = LOAD_ONCE_LIST_NUM / INSERT_ONCE_LIST_NUM;
	Time = REFRESHLIMIT / Count;
	tObjectListAdd = class'L2UITimer'.static.Inst()._AddNewTimerObject(Time, Count);
	tObjectListAdd._DelegateOnTime = TInsertRecordOnTime;
	tObjectListAdd._DelegateOnEnd = TInserDelayCheck;
	refreshMinCount = REFRESHLIMITMIN / Time;	
}

event OnClickHeaderCtrl(string strID, int Index)
{
	if(bRQ_C_EX_WORLD_EXCHANGE_ITEM_LIST)
	{
		return;
	}
	if(! SetSortByHeaderIndex(Index))
	{
		return;
	}
	RQWorldExchangeItemList(uicontrolTextInputScr.GetString());
	Debug("-- RQ_C_EX_WORLD_EXCHANGE_ITEM_LIST " @ "OnClickHeaderCtrl");
	RQ_C_EX_WORLD_EXCHANGE_ITEM_LIST();	
}

event OnEvent(int EventID, string param)
{
	switch(EventID)
	{
		case EV_Restart:
			bFormSetting = false;
			break;
		case EV_PacketID(class'UIPacket'.const.S_EX_WORLD_EXCHANGE_ITEM_LIST):
			RT_S_EX_WORLD_EXCHANGE_ITEM_LIST();
			break;
		case EV_PacketID(class'UIPacket'.const.S_EX_WORLD_EXCHANGE_BUY_ITEM):
			RT_S_EX_WORLD_EXCHANGE_BUY_ITEM();
			break;
	}
}

event OnShow()
{
	if(! CheckOpenCondition())
	{
		m_hOwnerWnd.HideWindow();
		return;
	}
	HandleOnGameStart();
	class'WorldExchangeRegiWnd'.static.Inst()._Hide();
	HideBuyDialog();
	getInstanceL2Util().ItemRelationWindowHide(getCurrentWindowName(string(self)));
	if(bRQ_C_EX_WORLD_EXCHANGE_ITEM_LIST)
	{
		tObjectListAdd._Reset();
	}
	if(getInstanceUIData().getIsLiveServer())
	{
		SideBar(GetScript("SideBar")).ToggleByWindowName(getCurrentWindowName(string(self)), true);
	}
	class'WorldExchangeBuyHome'.static.Inst()._RQ_COININFO();
}

event OnHide()
{
	if(DialogIsMine())
	{
		class'DialogBox'.static.Inst().HideDialog();
	}
	if(getInstanceUIData().getIsLiveServer())
	{
		SideBar(GetScript("SideBar")).ToggleByWindowName(getCurrentWindowName(string(self)), false);
	}	
}

event OnClickButtonWithHandle(ButtonHandle a_ButtonHandle)
{
	Debug("OnClickButtonWithHandle" @ a_ButtonHandle.GetWindowName());
	switch(a_ButtonHandle)
	{
		case GetButtonHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".ItemFind_Wnd.BtnFind"):
			HandleBtnFind();
			break;
		case GetButtonHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".SearchResult_Wnd.BtnFind"):
			break;
	}	
}

event OnClickButton(string strID)
{
	Debug("OnClickButton" @ strID);
	switch(strID)
	{
		case "WndClose_BTN":
			_Hide();
			break;
		case "Refresh_btn":
			HandleBtnRefresh();
			break;
		case "MoveWnd_Btn":
			HandleBtnSwap();
			break;
		case "Cancel_Btn":
			HideBuyDialog();
			break;
		case "Ok_Btn":
			RQ_C_EX_WORLD_EXCHANGE_BUY_ITEM();
			HideBuyDialog();
			break;
		case "OkResult_Btn":
			HideBuyDialog();
			break;
		case "Back_Btn":
			class'WorldExchangeBuyHome'.static.Inst()._SwapToFind();
			break;
		case "gotoBtn":
			class'WorldExchangeBuyHome'.static.Inst()._GotoFind();
			break;
		default:
			ChckBtnName(strID);
			break;
	}
}

event OnDBClickListCtrlRecord(string ListCtrlID)
{
	local RichListCtrlRowData rowData;

	switch(_GetCurrentMainType())
	{
		case MAIN_TAB_LIVE_MAX:
			class'WorldExchangeBuyHome'.static.Inst()._GotoFind();
			break;
		default:
			GetCurrentRichlistCtrlHandle().GetSelectedRec(rowData);
			SetShowBuyDialogWindow(int(rowData.nReserved1));
			break;
			break;
	}
}

event OnScrollMove(string strID, int pos)
{
	switch(strID)
	{
		case "List_RichList":
		case "List_RichLIstAdena":
			HandleScrollMove(pos);
			break;
	}
}

event OnCilckCheckBoxWithHandle(CheckBoxHandle a_CheckBoxHandle)
{
	if(a_CheckBoxHandle == compareTooltipCheckBox)
	{
		SetINIBool("WorldExchangeBuyWnd", "a", compareTooltipCheckBox.IsChecked(), "WindowsInfo.ini");
		SetShowCompareTooltipOnWorldExchange(compareTooltipCheckBox.IsChecked());
	}	
}


function initGroupButton()
{
	TopGroupButtonAsset = class'UIControlGroupButtonAssets'.static._InitScript(GetWindowHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".UIControlGroupButtonAsset1"));
	TopGroupButtonAsset._SetStartInfo("L2UI_EPIC.PrivateShopFindWnd.PrivateShopFindWnd_Tab_Center_Unselected", "L2UI_EPIC.PrivateShopFindWnd.PrivateShopFindWnd_Tab_Center_Selected", "L2UI_EPIC.PrivateShopFindWnd.PrivateShopFindWnd_Tab_Center_Unselected_Over", true);
	SubGroupButtonAsset = class'UIControlGroupButtonAssets'.static._InitScript(GetWindowHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".SubUIControlGroupButtonAsset"));
	SubGroupButtonAsset._SetStartInfo("L2UI_ct1.RankingWnd.RankingWnd_SubTabButton", "L2UI_ct1.RankingWnd.RankingWnd_SubTabButton_Down", "L2UI_ct1.RankingWnd.RankingWnd_SubTabButton_Over", true);	
}

function SetMainCategoryButtons()
{
	local UIControlGroupButtons mainGroupBtnScr;

	mainGroupBtnScr = TopGroupButtonAsset._GetGroupButtonsInstance();
	mainGroupBtnScr._setButtonText(0, "");
	mainGroupBtnScr._setButtonValue(0, 7);
	if(GetLanguage() == LANG_Russia || GetLanguage() == LANG_Euro)
	{
		mainGroupBtnScr._setButtonText(1, GetSystemString(6002));		
	}
	else
	{
		mainGroupBtnScr._setButtonText(1, GetSystemString(469));
	}
	mainGroupBtnScr._setButtonValue(1, 0);
	mainGroupBtnScr._setButtonText(2, GetSystemString(116));
	mainGroupBtnScr._setButtonValue(2, 1);
	mainGroupBtnScr._setButtonText(3, GetSystemString(2066));
	mainGroupBtnScr._setButtonValue(3, 3);
	mainGroupBtnScr._setButtonText(4, GetSystemString(13891));
	mainGroupBtnScr._setButtonValue(4, 4);
	mainGroupBtnScr._setButtonText(5, GetSystemString(13476));
	mainGroupBtnScr._setButtonValue(5, 6);
	mainGroupBtnScr._setShowButtonNum(6);
	mainGroupBtnScr._setAutoWidth(958, 0);
	mainGroupBtnScr._setButtonTexture(mainGroupBtnScr._FindButtonIndexByValue(6), "L2UI_EPIC.PrivateShopFindWnd.PrivateShopFindWnd_Tab_Right_Unselected", "L2UI_EPIC.PrivateShopFindWnd.PrivateShopFindWnd_Tab_Right_Selected", "L2UI_EPIC.PrivateShopFindWnd.PrivateShopFindWnd_Tab_Right_Unselected_Over");
	GetMeTexture("TabIcon01_Tex").ShowWindow();
	GetMeTexture("TabIcon02_Tex").ShowWindow();
	GetMeTexture("TabIcon03_Tex").ShowWindow();
	GetMeTexture("TabIcon04_Tex").ShowWindow();
	GetMeTexture("TabIcon05_Tex").ShowWindow();
	GetMeTexture("TabIcon06_Tex").ShowWindow();
	GetMeTexture("TabIcon07_Tex").HideWindow();
	GetMeTexture("TabIcon02_Tex").SetTexture("L2UI.WorldExchangeWnd.WorldExchange_Adena");
	GetMeTexture("TabIcon03_Tex").SetTexture("L2UI.WorldExchangeWnd.WorldExchange_EquipIcon");
	GetMeTexture("TabIcon04_Tex").SetTexture("L2UI.WorldExchangeWnd.WorldExchange_EnchantIcon");
	GetMeTexture("TabIcon05_Tex").SetTexture("L2UI.WorldExchangeWnd.WorldExchange_EtcIcon");
	GetMeTexture("TabIcon06_Tex").SetTexture("L2UI.WorldExchangeWnd.WorldExchange_CollectionIcon");
	mainGroupBtnScr._setTextureLoc(0, GetMeTexture("TabIcon01_Tex"), 0, 6, "center");
	mainGroupBtnScr._setTextureLoc(1, GetMeTexture("TabIcon02_Tex"), 8, 6, "left");
	mainGroupBtnScr._setTextureLoc(2, GetMeTexture("TabIcon03_Tex"), 8, 6, "left");
	mainGroupBtnScr._setTextureLoc(3, GetMeTexture("TabIcon04_Tex"), 8, 6, "left");
	mainGroupBtnScr._setTextureLoc(4, GetMeTexture("TabIcon05_Tex"), 8, 6, "left");
	mainGroupBtnScr._setTextureLoc(5, GetMeTexture("TabIcon06_Tex"), 8, 6, "left");
	mainGroupBtnScr._setTextureLoc(5, GetMeTexture("TabIconRibbon_Tex"), 0, 0, "left");	
}

function SetMainCategoryButtonsLive()
{
	local UIControlGroupButtons mainGroupBtnScr;

	mainGroupBtnScr = TopGroupButtonAsset._GetGroupButtonsInstance();
	mainGroupBtnScr._setButtonText(0, GetSystemString(469));
	mainGroupBtnScr._setButtonValue(0, 0);
	mainGroupBtnScr._setButtonText(1, GetSystemString(116));
	mainGroupBtnScr._setButtonValue(1, 1);
	mainGroupBtnScr._setButtonText(2, GetSystemString(3877));
	mainGroupBtnScr._setButtonValue(2, 2);
	mainGroupBtnScr._setButtonText(3, GetSystemString(1532));
	mainGroupBtnScr._setButtonValue(3, 3);
	mainGroupBtnScr._setButtonText(4, GetSystemString(3935));
	mainGroupBtnScr._setButtonValue(4, 4);
	mainGroupBtnScr._setButtonText(5, GetSystemString(49));
	mainGroupBtnScr._setButtonValue(5, 5);
	mainGroupBtnScr._setButtonText(6, GetSystemString(13476));
	mainGroupBtnScr._setButtonValue(6, 6);
	mainGroupBtnScr._setShowButtonNum(7);
	mainGroupBtnScr._setAutoWidth(958, 0);
	GetMeTexture("TabIcon01_Tex").ShowWindow();
	GetMeTexture("TabIcon02_Tex").ShowWindow();
	GetMeTexture("TabIcon03_Tex").ShowWindow();
	GetMeTexture("TabIcon04_Tex").ShowWindow();
	GetMeTexture("TabIcon05_Tex").ShowWindow();
	GetMeTexture("TabIcon06_Tex").ShowWindow();
	GetMeTexture("TabIcon07_Tex").ShowWindow();
	GetMeTexture("TabIcon01_Tex").SetTexture("L2UI.WorldExchangeWnd.WorldExchange_Adena");
	GetMeTexture("TabIcon02_Tex").SetTexture("L2UI.WorldExchangeWnd.WorldExchange_EquipIcon");
	GetMeTexture("TabIcon03_Tex").SetTexture("L2UI.WorldExchangeWnd.WorldExchange_EnchantIcon");
	GetMeTexture("TabIcon04_Tex").SetTexture("L2UI.WorldExchangeWnd.WorldExchange_CollectionIcon");
	GetMeTexture("TabIcon05_Tex").SetTexture("L2UI.WorldExchangeWnd.WorldExchange_EtcIcon");
	GetMeTexture("TabIcon06_Tex").SetTexture("L2UI.WorldExchangeWnd.WorldExchange_EtcIcon");
	GetMeTexture("TabIcon07_Tex").SetTexture("L2UI.WorldExchangeWnd.WorldExchange_CollectionIcon");
	mainGroupBtnScr._setTextureLoc(0, GetMeTexture("TabIcon01_Tex"), 8, 6, "left");
	mainGroupBtnScr._setTextureLoc(1, GetMeTexture("TabIcon02_Tex"), 8, 6, "left");
	mainGroupBtnScr._setTextureLoc(2, GetMeTexture("TabIcon03_Tex"), 8, 6, "left");
	mainGroupBtnScr._setTextureLoc(3, GetMeTexture("TabIcon04_Tex"), 8, 6, "left");
	mainGroupBtnScr._setTextureLoc(4, GetMeTexture("TabIcon05_Tex"), 8, 6, "left");
	mainGroupBtnScr._setTextureLoc(5, GetMeTexture("TabIcon06_Tex"), 8, 6, "left");
	mainGroupBtnScr._setTextureLoc(6, GetMeTexture("TabIcon07_Tex"), 8, 6, "left");
	mainGroupBtnScr._setTextureLoc(6, GetMeTexture("TabIconRibbon_Tex"), 0, 0, "left");
	mainGroupBtnScr._setButtonTexture(mainGroupBtnScr._FindButtonIndexByValue(6), "L2UI_EPIC.PrivateShopFindWnd.PrivateShopFindWnd_Tab_Right_Unselected", "L2UI_EPIC.PrivateShopFindWnd.PrivateShopFindWnd_Tab_Right_Selected", "L2UI_EPIC.PrivateShopFindWnd.PrivateShopFindWnd_Tab_Right_Unselected_Over");	
}

private function AddSubCategoryData(int mainType, int Key, int stringNum)
{
	local int subIndex;
	local categoryStruct Data;

	Data = categoryArray[mainType];
	subIndex = Data.subCategoryKeyArray.Length;
	Data.subCategoryKeyArray[subIndex] = Key;
	Data.subCategoryStringArray[subIndex] = stringNum;
	categoryArray[mainType] = Data;
}

private function SetSubCategoryData()
{
	AddSubCategoryData(0, 24, 144);
	categoryArray[0].subCategoryDotShow.Length = 1;
	AddSubCategoryData(1, 0, 2520);
	AddSubCategoryData(1, 1, 2532);
	AddSubCategoryData(1, 2, 2537);
	AddSubCategoryData(1, 3, 49);
	categoryArray[1].subCategoryDotShow.Length = 4;
	AddSubCategoryData(2, 0, 0);
	categoryArray[2].subCategoryDotShow.Length = 0;
	AddSubCategoryData(3, 8, 1532);
	AddSubCategoryData(3, 17, 2554);
	AddSubCategoryData(3, 15, 2553);
	AddSubCategoryData(3, 16, 25);
	AddSubCategoryData(3, 18, 2558);
	AddSubCategoryData(3, 19, 49);
	categoryArray[3].subCategoryDotShow.Length = 6;
	AddSubCategoryData(4, 20, 13848);
	AddSubCategoryData(4, 21, 5834);
	AddSubCategoryData(4, 22, 13892);
	AddSubCategoryData(4, 25, 49);
	categoryArray[4].subCategoryDotShow.Length = 4;
	AddSubCategoryData(5, 0, 0);
	categoryArray[5].subCategoryDotShow.Length = 0;
	AddSubCategoryData(6, 1, 116);
	AddSubCategoryData(6, 3, 13846);
	AddSubCategoryData(6, 5, 49);
	categoryArray[6].subCategoryDotShow.Length = 3;	
}

private function SetSubCategoryDataLive()
{
	AddSubCategoryData(0, 24, 144);
	AddSubCategoryData(1, 0, 2520);
	AddSubCategoryData(1, 1, 2532);
	AddSubCategoryData(1, 2, 2537);
	AddSubCategoryData(2, 4, 3891);
	AddSubCategoryData(2, 5, 3892);
	AddSubCategoryData(2, 6, 3893);
	AddSubCategoryData(2, 7, 3894);
	AddSubCategoryData(3, 8, 2611);
	AddSubCategoryData(3, 9, 13841);
	AddSubCategoryData(3, 10, 13842);
	AddSubCategoryData(3, 11, 13843);
	AddSubCategoryData(4, 12, 2545);
	AddSubCategoryData(4, 13, 2544);
	AddSubCategoryData(4, 14, 13318);
	AddSubCategoryData(5, 15, 3349);
	AddSubCategoryData(5, 16, 25);
	AddSubCategoryData(5, 23, 13844);
	AddSubCategoryData(5, 25, 49);	
}

function SetGroupButtonCategorySub(int mainType)
{
	local int i, Len;
	local UIControlGroupButtons subGroupBtnScr;

	subGroupBtnScr = SubGroupButtonAsset._GetGroupButtonsInstance();
	Len = categoryArray[mainType].subCategoryStringArray.Length;
	subGroupBtnScr._setShowButtonNum(Len);
	subGroupBtnScr._fixedWidth(110, 5);
	for(i = 0; i < Len; i++)
	{
		subGroupBtnScr._setButtonText(i, GetSystemString(categoryArray[mainType].subCategoryStringArray[i]));
		subGroupBtnScr._setButtonValue(i, categoryArray[mainType].subCategoryKeyArray[i]);
	}
}

function ReselectCategorySub(int mainType)
{
	SubGroupButtonAsset._GetGroupButtonsInstance()._setTopOrder(categoryArray[mainType].subSelectedIndex);	
}

private function DelegateOnClickButtonSub(string parentWndName, string strName, int subIndex)
{
	local int mainType;

	mainType = _GetCurrentMainType();
	if(mainType == MAIN_TAB_LIVE_MAX)
	{
		return;
	}
	categoryArray[mainType].subSelectedIndex = subIndex;
	Debug("-- RQ_C_EX_WORLD_EXCHANGE_ITEM_LIST " @ "DelegateOnClickButtonSub");
	RQ_C_EX_WORLD_EXCHANGE_ITEM_LIST();
}

private function DelegateOnClickButtonTop(string parentWndName, string strName, int mainIndex)
{
	local int mainType;

	mainType = _GetCurrentMainType();
	SetGroupButtonCategorySub(mainType);
	ReselectCategorySub(mainType);
	TransformByMainType();
}

function bool GetCategoryIndex(int ClassID, out int mainCategoryIndex, out int subCategoryIndex)
{
	local int i, j, subCategoryKey, mainType;
	local UIControlGroupButtons mainGroupBtnScr;

	subCategoryKey = API_GetServerPrivateStoreSearchItemSubType(ClassID);
	Debug("mainCategoryType" @ string(subCategoryKey));
	if(subCategoryKey == -1)
	{
		return false;
	}
	mainGroupBtnScr = TopGroupButtonAsset._GetGroupButtonsInstance();

	for(i = 1; i < mainGroupBtnScr._getShowButtonNum(); i++)
	{
		mainType = GetMainCategoryType(i);
		Debug(" -- MainCategoryIndex :" @ string(i));

		for(j = 0; j < categoryArray[mainType].subCategoryKeyArray.Length; j++)
		{
			if(categoryArray[mainType].subCategoryKeyArray[j] == subCategoryKey)
			{
				mainCategoryIndex = i;
				subCategoryIndex = j;
				return true;
			}
		}
	}
	return false;
}

function _SetCategoryIndexByClassID(int ClassID)
{
	local int mainCategoryIndex, subCategoryIndex, mainType;
	local ItemInfo iInfo;

	if(! GetCategoryIndex(ClassID, mainCategoryIndex, subCategoryIndex))
	{
		return;
	}
	if(! class'UIDATA_ITEM'.static.GetItemInfo(GetItemID(ClassID), iInfo))
	{
		return;
	}
	uicontrolTextInputScr.SetString(lastFindString);
	GetButtonHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".ItemFind_Wnd.BtnFind").DisableWindow();
	lastFindString = GetItemNameAll(iInfo);
	CheckFindString(lastFindString, ItemList);
	mainType = GetMainCategoryType(mainCategoryIndex);
	categoryArray[mainType].subSelectedIndex = subCategoryIndex;
	TopGroupButtonAsset._GetGroupButtonsInstance()._setTopOrder(mainCategoryIndex);
}

function _DotTextureAllHide()
{
	local int i, j;

	TopGroupButtonAsset._DotTextureAllShow(false);
	SubGroupButtonAsset._DotTextureAllShow(false);

	for(i = 0; i < categoryArray.Length; i++)
	{
		for(j = 0; j < categoryArray[i].subCategoryDotShow.Length; j++)
		{
			categoryArray[i].subCategoryDotShow[j] = 0;
		}
	}	
}

function _DotAdd(int ClassID)
{
	local int mainCategoryIndex, subCategoryIndex, mainCategoryType;

	if(! GetCategoryIndex(ClassID, mainCategoryIndex, subCategoryIndex))
	{
		return;
	}
	mainCategoryType = GetMainCategoryType(mainCategoryIndex);
	categoryArray[mainCategoryType].subCategoryDotShow[subCategoryIndex]++;
	Debug("_DotAdd" @ string(mainCategoryType) @ string(subCategoryIndex) @ string(categoryArray[mainCategoryType].subCategoryDotShow[subCategoryIndex]));
	TopGroupButtonAsset._DotTextureShow(mainCategoryIndex, true);
	TopGroupButtonAsset._DotTextureColorModify(mainCategoryIndex, GetColor(0, 255, 0, 255));	
}

function _DotSubCurrentSet()
{
	local int mainCategoryType, i;

	mainCategoryType = _GetCurrentMainType();
	Debug("_DotSubCurrentSet" @ string(mainCategoryType) @ string(categoryArray[mainCategoryType].subCategoryDotShow.Length));

	for(i = 0; i < categoryArray[mainCategoryType].subCategoryDotShow.Length; i++)
	{
		if(categoryArray[mainCategoryType].subCategoryDotShow[i] > 0)
		{
			SubGroupButtonAsset._DotTextureShow(i, true);
			SubGroupButtonAsset._DotTextureColorModify(i, GetColor(0, 255, 0, 255));
			// [Explicit Continue]
			continue;
		}
		SubGroupButtonAsset._DotTextureShow(i, false);
	}	
}

private function TransformToHome()
{
	FindDisable_Wnd.HideWindow();
	List_RichList.HideWindow();
	List_RichListAdena.HideWindow();
	GetWindowHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".ItemFind_Wnd").HideWindow();
	SubGroupButtonAsset._GetGroupButtonsInstance()._HideAllButtons();
	GetTextureHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".ListDeco_Tex").HideWindow();
	GetButtonHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".Refresh_Btn").HideWindow();
	GetTextBoxHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".WorldExchange_Txt").ShowWindow();
	class'WorldExchangeBuyHome'.static.Inst()._Show();
	compareTooltipCheckBox.HideWindow();
}

private function TransformByMainType()
{
	switch(_GetCurrentMainType())
	{
		case MAIN_TAB_LIVE_MAX:
			TransformToHome();
			break;
		case 0:
			class'WorldExchangeBuyWnd'.static.Inst()._DotTextureAllHide();
			List_RichList.HideWindow();
			List_RichListAdena.ShowWindow();
			GetWindowHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".ItemFind_Wnd").HideWindow();
			GetTextureHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".ListDeco_Tex").ShowWindow();
			SetSortType(E_WORLD_EXCHANGE_SORT_TYPE.EWEST_PRICE_PER_PIECE_ASCE/*8*/);
			class'WorldExchangeBuyHome'.static.Inst()._Hide();
			GetButtonHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".Refresh_Btn").ShowWindow();
			GetTextBoxHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".WorldExchange_Txt").ShowWindow();
			compareTooltipCheckBox.HideWindow();
			break;
		default:
			class'WorldExchangeBuyWnd'.static.Inst()._DotTextureAllHide();
			List_RichList.ShowWindow();
			List_RichListAdena.HideWindow();
			GetWindowHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".ItemFind_Wnd").ShowWindow();
			GetTextureHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".ListDeco_Tex").ShowWindow();
			class'WorldExchangeBuyHome'.static.Inst()._Hide();
			GetButtonHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".Refresh_Btn").ShowWindow();
			GetTextBoxHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".WorldExchange_Txt").HideWindow();
			compareTooltipCheckBox.ShowWindow();
			break;
	}
}

function HandleClear()
{
	lastFindString = "";
	ItemList.Length = 0;
	Debug("-- RQ_C_EX_WORLD_EXCHANGE_ITEM_LIST " @ "HandleClear");
	_DotTextureAllHide();
	RQ_C_EX_WORLD_EXCHANGE_ITEM_LIST();
}

function DelegateESCKey()
{
	OnReceivedCloseUI();
}

function DelegateOnClear()
{
	HandleClear();
}

function DelegateOnChangeEdited(string Text)
{
	if(lastFindString == Text)
	{
		GetButtonHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".ItemFind_Wnd.BtnFind").DisableWindow();		
	}
	else
	{
		GetButtonHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".ItemFind_Wnd.BtnFind").EnableWindow();
	}
}

function bool CheckFindString(string Text, out array<int> _itemList)
{
	if(Text == "")
	{
		return true;
	}
	API_GetStringMatchingItemList(Text, " ", EStringMatchingItemFilter.SMIF_WorldExchangeItem, List_RichList.IsAscending(0), _itemList);
	return _itemList.Length > 0;
}

function DelegateOnCompleteEditBox(string Text)
{
	SetSortType(E_WORLD_EXCHANGE_SORT_TYPE.EWEST_PRICE_PER_PIECE_ASCE/*8*/);
	RQWorldExchangeItemList(Text);	
}

function RQWorldExchangeItemList(string Text)
{
	local array<int> _itemList;

	if(! CheckFindString(Text, _itemList))
	{
		class'L2Util'.static.Inst().showGfxScreenMessage("&#34;" $ Text $ "&#34;" $ GetSystemMessage(4356));
		return;
	}
	if(_itemList.Length > 300)
	{
		class'L2Util'.static.Inst().showGfxScreenMessage(GetSystemMessage(13767));
		return;
	}
	lastFindString = Text;
	ItemList = _itemList;
	Debug("-- RQ_C_EX_WORLD_EXCHANGE_ITEM_LIST " @ "RQWorldExchangeItemList");
	RQ_C_EX_WORLD_EXCHANGE_ITEM_LIST();
}

function _Show()
{
	m_hOwnerWnd.ShowWindow();
	m_hOwnerWnd.SetFocus();
}

function _Hide()
{
	m_hOwnerWnd.HideWindow();
}

private function HandleBtnSwap()
{
	_Hide();
	class'WorldExchangeRegiWnd'.static.Inst()._Show();
	getInstanceL2Util().syncWindowLoc(m_hOwnerWnd.m_WindowNameWithFullPath, "WorldExchangeRegiWnd");
}

private function HandleBtnRefresh()
{
	Debug("-- RQ_C_EX_WORLD_EXCHANGE_ITEM_LIST " @ "HandleBtnRefresh");
	RQ_C_EX_WORLD_EXCHANGE_ITEM_LIST();
}

private function HandleBtnFind()
{
	SetSortType(E_WORLD_EXCHANGE_SORT_TYPE.EWEST_PRICE_PER_PIECE_ASCE/*8*/);
	RQWorldExchangeItemList(uicontrolTextInputScr.GetString());	
}

private function HandleScrollMove(optional int pos)
{
	scrollPos = pos;
	if(bRQ_C_EX_WORLD_EXCHANGE_ITEM_LIST)
	{
		return;
	}
	Debug("HandleScrollMove" @ string(pos) @ string(GetCurrentRichlistCtrlHandle().GetRecordCount()) @ string(GetCurrentRichlistCtrlHandle().GetShowRow()) @ string(lastLoadedPage) @ string(nMaxPage));
	if(pos == (GetCurrentRichlistCtrlHandle().GetRecordCount() - GetCurrentRichlistCtrlHandle().GetShowRow()))
	{
		Debug("-- RQ_C_EX_WORLD_EXCHANGE_ITEM_LIST " @ "HandleScrollMove");
		RQ_C_EX_WORLD_EXCHANGE_ITEM_LIST(lastLoadedPage + 1);
	}
}

private function SetDisablbRefresh()
{
	local int i;

	bRQ_C_EX_WORLD_EXCHANGE_ITEM_LIST = true;
	GetButtonHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".Refresh_btn").DisableWindow();
	GetButtonHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".ItemFind_Wnd.BtnFind").DisableWindow();
	uicontrolTextInputScr.SetDisable(true);
	TopGroupButtonAsset._SetDisable();
	SubGroupButtonAsset._SetDisable();
	GetButtonHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".MoveWnd_Btn").DisableWindow();

	for(i = 1; i <= TopGroupButtonAsset._GetGroupButtonsInstance()._getShowButtonNum(); i++)
	{
		if(TopGroupButtonAsset._GetGroupButtonsInstance()._getSelectButtonIndex() + 1 != i)
		{
			GetTextureHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".TabIcon0" $ string(i) $ "_Tex").SetAlpha(100, 0.50f);
			// [Explicit Continue]
			continue;
		}
		GetTextureHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".TabIcon0" $ string(i) $ "_Tex").SetAlpha(180, 0.50f);
	}
	tObjectListAdd._Reset();
}

private function SetEnableRefresh()
{
	local int i;

	bRQ_C_EX_WORLD_EXCHANGE_ITEM_LIST = false;
	GetButtonHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".Refresh_btn").EnableWindow();
	if(lastFindString != uicontrolTextInputScr.GetString())
	{
		GetButtonHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".ItemFind_Wnd.BtnFind").EnableWindow();
	}
	uicontrolTextInputScr.SetDisable(false);
	TopGroupButtonAsset._SetEnable();
	SubGroupButtonAsset._SetEnable();
	GetButtonHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".MoveWnd_Btn").EnableWindow();

	for(i = 1; i <= TopGroupButtonAsset._GetGroupButtonsInstance()._getShowButtonNum(); i++)
	{
		GetTextureHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".TabIcon0" $ string(i) $ "_Tex").SetAlpha(255, 0.50f);
	}
}

private function bool IsAscending(int HeaderIndex)
{
	return GetCurrentRichlistCtrlHandle().IsAscending(HeaderIndex);	
}

private function bool IsAscendingCurrent()
{
	return IsAscending(GetCurrentHeaderIndex());	
}

private function HEADER_TYPE GetCurrentHeaderType()
{
	return GetHeaderType(GetCurrentHeaderIndex());	
}

private function int GetCurrentHeaderIndex()
{
	if(_GetCurrentMainType() == 0)
	{
		return ShowHeaderIndexAdena;		
	}
	else
	{
		return ShowHeaderIndex;
	}	
}

private function HEADER_TYPE GetHeaderType(int HeaderIndex)
{
	if(_GetCurrentMainType() == 0)
	{
		switch(HeaderIndex)
		{
			case 0:
				return HEADER_TYPE.ItemName/*0*/;
			case 1:
				return HEADER_TYPE.totalprice/*2*/;
			case 2:
				return HEADER_TYPE.perPrice/*3*/;
		}
	}
	return HEADER_TYPE(HeaderIndex);	
}

private function int GetHeaderIndex(HEADER_TYPE Type)
{
	if(_GetCurrentMainType() == 0)
	{
		switch(Type)
		{
			case HEADER_TYPE.ItemName/*0*/:
				return 0;
			case HEADER_TYPE.totalprice/*2*/:
				return 1;
			case HEADER_TYPE.perPrice/*3*/:
				return 2;
		}
	}
	return Type;	
}

private function int GetCurrentSortType()
{
	switch(GetCurrentHeaderType())
	{
		case HEADER_TYPE.ItemName/*0*/:
			if(IsAscendingCurrent())
			{
				return 2;				
			}
			else
			{
				return 3;
			}
		case HEADER_TYPE.ItemNum/*1*/:
			if(IsAscendingCurrent())
			{
				return 6;				
			}
			else
			{
				return 7;
			}
		case HEADER_TYPE.totalprice/*2*/:
			if(IsAscendingCurrent())
			{
				return 4;				
			}
			else
			{
				return 5;
			}
		case HEADER_TYPE.perPrice/*3*/:
			if(IsAscendingCurrent())
			{
				return 8;				
			}
			else
			{
				return 9;
			}
		default:
			return 2;
	}
}

private function bool SetSortByHeaderIndex(int HeaderIndex)
{
	local bool bAscending;

	if(GetCurrentHeaderIndex() == HeaderIndex)
	{
		bAscending = IsAscending(HeaderIndex);
	}
	switch(GetHeaderType(HeaderIndex))
	{
		case HEADER_TYPE.ItemName/*0*/:
			if(bAscending)
			{
				SetSortType(E_WORLD_EXCHANGE_SORT_TYPE.EWEST_ENCHANT_DESC/*3*/);				
			}
			else
			{
				SetSortType(E_WORLD_EXCHANGE_SORT_TYPE.EWEST_ENCHANT_ASCE/*2*/);
			}
			break;
		case HEADER_TYPE.ItemNum/*1*/:
			if(bAscending)
			{
				SetSortType(E_WORLD_EXCHANGE_SORT_TYPE.EWEST_AMOUNT_DESC/*7*/);				
			}
			else
			{
				SetSortType(E_WORLD_EXCHANGE_SORT_TYPE.EWEST_AMOUNT_ASCE/*6*/);
			}
			break;
		case HEADER_TYPE.totalprice/*2*/:
			if(bAscending)
			{
				SetSortType(E_WORLD_EXCHANGE_SORT_TYPE.EWEST_PRICE_DESC/*5*/);				
			}
			else
			{
				SetSortType(E_WORLD_EXCHANGE_SORT_TYPE.EWEST_PRICE_ASCE/*4*/);
			}
			break;
		case HEADER_TYPE.perPrice/*3*/:
			if(bAscending)
			{
				SetSortType(E_WORLD_EXCHANGE_SORT_TYPE.EWEST_PRICE_PER_PIECE_DESC/*9*/);				
			}
			else
			{
				SetSortType(E_WORLD_EXCHANGE_SORT_TYPE.EWEST_PRICE_PER_PIECE_ASCE/*8*/);
			}
			break;
		default:
			return false;
	}
	return true;	
}

private function SetSortType(WorldExchangeBuyWnd.E_WORLD_EXCHANGE_SORT_TYPE sortType)
{
	local bool bAscend;
	local int HeaderIndex;
	local HEADER_TYPE headerType;
	local RichListCtrlHandle List;

	switch(sortType)
	{
		case E_WORLD_EXCHANGE_SORT_TYPE.EWEST_ENCHANT_ASCE/*2*/:
			headerType = HEADER_TYPE.ItemName/*0*/;
			bAscend = true;
			break;
		case E_WORLD_EXCHANGE_SORT_TYPE.EWEST_ENCHANT_DESC/*3*/:
			headerType = HEADER_TYPE.ItemName/*0*/;
			bAscend = false;
			break;
		case E_WORLD_EXCHANGE_SORT_TYPE.EWEST_AMOUNT_ASCE/*6*/:
			headerType = HEADER_TYPE.ItemNum/*1*/;
			bAscend = true;
			break;
		case E_WORLD_EXCHANGE_SORT_TYPE.EWEST_AMOUNT_DESC/*7*/:
			headerType = HEADER_TYPE.ItemNum/*1*/;
			bAscend = false;
			break;
		case E_WORLD_EXCHANGE_SORT_TYPE.EWEST_PRICE_ASCE/*4*/:
			headerType = HEADER_TYPE.totalprice/*2*/;
			bAscend = true;
			break;
		case E_WORLD_EXCHANGE_SORT_TYPE.EWEST_PRICE_DESC/*5*/:
			headerType = HEADER_TYPE.totalprice/*2*/;
			bAscend = false;
			break;
		case E_WORLD_EXCHANGE_SORT_TYPE.EWEST_PRICE_PER_PIECE_ASCE/*8*/:
			headerType = HEADER_TYPE.perPrice/*3*/;
			bAscend = true;
			break;
		case E_WORLD_EXCHANGE_SORT_TYPE.EWEST_PRICE_PER_PIECE_DESC/*9*/:
			headerType = HEADER_TYPE.perPrice/*3*/;
			bAscend = false;
			break;
		default:
			headerType = HEADER_TYPE.ItemName/*0*/;
			bAscend = true;
			break;
	}
	HeaderIndex = GetHeaderIndex(headerType);
	if((_GetCurrentMainType()) == 0)
	{
		List = List_RichListAdena;
		ShowHeaderIndexAdena = HeaderIndex;		
	}
	else
	{
		List = List_RichList;
		ShowHeaderIndex = HeaderIndex;
	}
	Debug("SetSortType" @ string(HeaderIndex) @ string(headerType) @ List.GetWindowName());
	List.SetAscend(HeaderIndex, bAscend);
	List.ShowSortIcon(HeaderIndex);
}

private function RichListCtrlHandle GetCurrentRichlistCtrlHandle()
{
	if((_GetCurrentMainType()) == 0)
	{
		return List_RichListAdena;		
	}
	else
	{
		return List_RichList;
	}	
}

delegate int OnSortCompareByName(int classIDA, int classIDB)
{
	if(class'UIDATA_ITEM'.static.GetItemName(GetItemID(classIDA)) < class'UIDATA_ITEM'.static.GetItemName(GetItemID(classIDB)))
	{
		return -1;		
	}
	else
	{
		return 0;
	}
}

function int API_GetServerPrivateStoreSearchItemSubType(int ClassID)
{
	return GetServerPrivateStoreSearchItemSubType(ClassID);	
}

function WorldExchangeUIData API_GetWorldExchangeData()
{
	return GetWorldExchangeData();
}

function int API_GetServerNo()
{
	return GetServerNo();
}

function API_GetStringMatchingItemList(string a_str, string a_delim, EStringMatchingItemFilter a_filter, bool a_bAscend, out array<int> o_ItemList)
{
	class'UIDATA_ITEM'.static.GetStringMatchingItemList(a_str, a_delim, a_filter, a_bAscend, o_ItemList);
}

function RQ_C_EX_WORLD_EXCHANGE_ITEM_LIST(optional int Page)
{
	local array<byte> stream;
	local UIPacket._C_EX_WORLD_EXCHANGE_ITEM_LIST packet;

	if(bRQ_C_EX_WORLD_EXCHANGE_ITEM_LIST)
	{
		return;
	}
	Debug("RQ_C_EX_WORLD_EXCHANGE_ITEM_LIST 첫 페이지 :" @ string(Page) @ string(GetCurrentSubType()) @ string(GetCurrentSortType()));
	if(Page > 0)
	{
		if(nMaxPage < Page)
		{
			return;
		}
	}
	requestedScrollPos = scrollPos;
	if(_itemDatas.Length > 0)
	{
		return;
	}
	uicontrolTextInputScr.SetString(lastFindString);
	SetDisablbRefresh();
	lastLoadedPage = Page;
	packet.nCategory = GetCurrentSubType();
	packet.cSortType = GetCurrentSortType();
	packet.nPage = Page;
	if(packet.nCategory != 24)
	{
		packet.vItemIDList = ItemList;
	}
	if(! class'UIPacket'.static.Encode_C_EX_WORLD_EXCHANGE_ITEM_LIST(stream, packet))
	{
		return;
	}
	class'UIPacket'.static.RequestUIPacket(class'UIPacket'.const.C_EX_WORLD_EXCHANGE_ITEM_LIST, stream);
}

function RT_S_EX_WORLD_EXCHANGE_ITEM_LIST()
{
	local UIPacket._S_EX_WORLD_EXCHANGE_ITEM_LIST packet;

	if(! m_hOwnerWnd.IsShowWindow())
	{
		return;
	}
	if(! class'UIPacket'.static.Decode_S_EX_WORLD_EXCHANGE_ITEM_LIST(packet))
	{
		return;
	}
	if(lastLoadedPage == 0)
	{
		if(ItemList.Length > 0)
		{
			class'WorldExchangeBuyHome'.static.Inst()._RQ_C_EX_WORLD_EXCHANGE_TOTAL_LIST_WithInfos(ItemList);
		}
		_itemDatas.Length = 0;
		GetCurrentRichlistCtrlHandle().DeleteAllItem();
		FindDisable_Wnd.ShowWindow();
		nMaxPage = 0;
	}
	if(packet.vItemDataList.Length == LOAD_ONCE_LIST_NUM)
	{
		nMaxPage++;		
	}
	else
	{
		nMaxPage = lastLoadedPage;
	}
	Handle_S_EX_WORLD_EXCHANGE_ITEM_LIST(packet);
}

function Handle_S_EX_WORLD_EXCHANGE_ITEM_LIST(UIPacket._S_EX_WORLD_EXCHANGE_ITEM_LIST packet)
{
	local int i;

	Debug("Handle_S_EX_WORLD_EXCHANGE_ITEM_LIST" @ string(packet.vItemDataList.Length));
	tObjectListAdd._Reset();
	if(packet.vItemDataList.Length == 0)
	{
		SetEnableRefresh();
		return;
	}
	FindDisable_Wnd.HideWindow();

	for(i = 0; i < packet.vItemDataList.Length; i++)
	{
		_itemDatas[_itemDatas.Length] = packet.vItemDataList[i];
	}
}

function TInsertRecordOnTime(int Count)
{
	TInsertRecord();
}

function TInsertRecord()
{
	local int i, Cnt;
	local RichListCtrlRowData rowData;

	if(_itemDatas.Length == 0)
	{
		if(tObjectListAdd._curCount >= refreshMinCount)
		{
			tObjectListAdd._Stop();
			TInserDelayCheck();
		}
		return;
	}
	Cnt = Min(INSERT_ONCE_LIST_NUM, _itemDatas.Length);
	if(_GetCurrentMainType() == 0)
	{
		for(i = 0; i < Cnt; i++)
		{
			if(_MakeRowDataAdena(_itemDatas[i], rowData))
			{
				List_RichListAdena.InsertRecord(rowData);
			}
		}		
	}
	else
	{
		for(i = 0; i < Cnt; i++)
		{
			if(MakeRowData(_itemDatas[i], rowData))
			{
				List_RichList.InsertRecord(rowData);
			}
		}
	}
	_itemDatas.Remove(0, Cnt);	
}

function TInserDelayCheck()
{
	Debug("타이머 종료");
	SetEnableRefresh();
	if(requestedScrollPos != scrollPos)
	{
		HandleScrollMove(scrollPos);
	}
}

function RQ_C_EX_WORLD_EXCHANGE_BUY_ITEM()
{
	local array<byte> stream;
	local UIPacket._C_EX_WORLD_EXCHANGE_BUY_ITEM packet;

	packet.nWEIndex = nWEIndex;
	if(! class'UIPacket'.static.Encode_C_EX_WORLD_EXCHANGE_BUY_ITEM(stream, packet))
	{
		return;
	}
	Debug("RQ_C_EX_WORLD_EXCHANGE_BUY_ITEM");
	class'UIPacket'.static.RequestUIPacket(class'UIPacket'.const.C_EX_WORLD_EXCHANGE_BUY_ITEM, stream);
}

function RT_S_EX_WORLD_EXCHANGE_BUY_ITEM()
{
	local UIPacket._S_EX_WORLD_EXCHANGE_BUY_ITEM packet;

	Debug("RT_S_EX_WORLD_EXCHANGE_BUY_ITEM");
	if(! class'UIPacket'.static.Decode_S_EX_WORLD_EXCHANGE_BUY_ITEM(packet))
	{
		return;
	}
	Debug(string(packet.nItemClassID) @ string(packet.nAmount) @ string(packet.cSuccess));
	switch(packet.cSuccess)
	{
		case 1:
			ShowBuyResultPopup();
			break;
		case 0:
			getInstanceL2Util().showGfxScreenMessage(GetSystemMessage(13681));
			break;
		case -1:
			getInstanceL2Util().showGfxScreenMessage(GetSystemMessage(13687));
			break;
	}
}

function int _GetCurrentMainType()
{
	local int topSelectedIndex;

	topSelectedIndex = TopGroupButtonAsset._GetGroupButtonsInstance()._getSelectButtonIndex();
	return GetMainCategoryType(topSelectedIndex);
}

function int GetCurrentSubType()
{
	local int subSelectedIndex;

	subSelectedIndex = SubGroupButtonAsset._GetGroupButtonsInstance()._getSelectButtonIndex();
	return GetSubCategoryType(subSelectedIndex);
}

private function int GetMainCategoryType(int mainCategoryIndex)
{
	return TopGroupButtonAsset._GetGroupButtonsInstance()._getButtonValue(mainCategoryIndex);
}

private function int GetSubCategoryType(int subCategoryIndex)
{
	return SubGroupButtonAsset._GetGroupButtonsInstance()._getButtonValue(subCategoryIndex);
}

private function int GetSimpleRound(INT64 _adena, INT64 _unit)
{
	return int(_adena / _unit);	
}

function string _MakeAdenaString(INT64 Adena)
{
	local int hundredMillion, tenMillion, million;
	local string adenaString;

	if(Adena == 0)
	{
		return "";
	}
	if(GetLanguage() == LANG_English || GetLanguage() == LANG_Russia || GetLanguage() == LANG_Euro)
	{
		return MakeCostString(string(Adena)) @ GetSystemString(469);
	}
	hundredMillion = GetSimpleRound(Adena, 100000000);
	tenMillion = int(float(GetSimpleRound(Adena, 10000000)) % 10);
	million = int(float(GetSimpleRound(Adena, 1000000)) % 10);
	if(hundredMillion > 0)
	{
		adenaString = string(hundredMillion) $ GetSystemString(14189);
	}
	if(tenMillion > 0)
	{
		if(adenaString != "")
		{
			adenaString = adenaString @ string(tenMillion) $ GetSystemString(14188);			
		}
		else
		{
			adenaString = string(tenMillion) $ GetSystemString(14188);
		}
	}
	if(million > 0)
	{
		if(adenaString != "")
		{
			adenaString = adenaString @ string(million) $ GetSystemString(14426);			
		}
		else
		{
			adenaString = string(million) $ GetSystemString(14426);
		}
	}
	return adenaString @ GetSystemString(469);	
}

function bool _MakeAdenaitemInfo(out ItemInfo iInfo)
{
	if(! IsAdena(iInfo.Id))
	{
		return false;
	}
	if(iInfo.ItemNum < 10000000)
	{
		iInfo.IconName = "Icon.etc_i.etc_adena_i00";		
	}
	else if(iInfo.ItemNum < 100000000)
	{
		iInfo.IconName = "L2UI.WorldExchangeWnd.Icon_Adena";			
	}
	else if(iInfo.ItemNum < 1000000000)
	{
		iInfo.IconName = "L2UI.WorldExchangeWnd.Icon_AdenaBag";				
	}
	else if(iInfo.ItemNum < 6056184812580896770)
	{
		iInfo.IconName = "L2UI.WorldExchangeWnd.Icon_AdenaBox";					
	}
	else
	{
		iInfo.IconName = "L2UI.WorldExchangeWnd.Icon_AdenaBox2";
	}
	return true;	
}

function _SetFindString(string Str, optional array<int> _itemList)
{
	if(_itemList.Length == 0)
	{
		RQWorldExchangeItemList(Str);		
	}
	else
	{
		lastFindString = Str;
		uicontrolTextInputScr.SetString(Str);
		GetButtonHandle(m_hOwnerWnd.m_WindowNameWithFullPath $ ".ItemFind_Wnd.BtnFind").DisableWindow();
		ItemList = _itemList;
	}
}

function bool _MakeRowDataAdena(UIPacket._WorldExchangeItemData _itemData, out RichListCtrlRowData outRowData)
{
	local RichListCtrlRowData rowData;
	local ItemInfo iInfo;
	local string strcom, itemParam;
	local float unitPrice;

	rowData.cellDataList.Length = 4;
	if(_itemData.nItemClassID < 1)
	{
		return false;
	}
	rowData.nReserved1 = _itemData.nWEIndex;
	iInfo = GetItemInfoByClassID(57);
	iInfo.ItemNum = _itemData.nAmount;
	iInfo.Price = _itemData.nPrice;
	strcom = MakeCostStringINT64(iInfo.Price);
	addRichListCtrlTexture(rowData.cellDataList[0].drawitems, "l2ui_ct1.ItemWindow_DF_SlotBox_Default", 36, 36, 0, 1);
	_MakeAdenaitemInfo(iInfo);
	AddRichListCtrlItem(rowData.cellDataList[0].drawitems, iInfo, 32, 32, -34, 2);
	addRichListCtrlString(rowData.cellDataList[0].drawitems, _MakeAdenaString(iInfo.ItemNum), GetNumericColor(string(iInfo.ItemNum)), false, 5, 7, "hs10");
	addRichListCtrlString(rowData.cellDataList[1].drawitems, GetSystemString(3931), GetColor(147, 136, 112, 255), false, 18, 0);
	addRichListCtrlString(rowData.cellDataList[1].drawitems, strcom, GetNumericColor(strcom), false, 5, 0);
	unitPrice = float(iInfo.Price) / (float(iInfo.ItemNum) / float(ADENA_BASIC_UNIT));
	strcom = MakeCostStringINT64(iInfo.Price / (iInfo.ItemNum / ADENA_BASIC_UNIT));
	addRichListCtrlString(rowData.cellDataList[2].drawitems, "." $ GetDecimalNnmStr(unitPrice), GetColor(123, 123, 123, 255), false, 0, 1, "hs7");
	addRichListCtrlString(rowData.cellDataList[2].drawitems, strcom, GetNumericColor(strcom), false, 0, -2);
	addRichListCtrlButton(rowData.cellDataList[3].drawitems, "btnBuy_" $ string(_itemData.nWEIndex), 0, 0, "L2UI_CT1.LCoinShopWnd.LCoinShopWnd_Buy_Button", "L2UI_CT1.LCoinShopWnd.LCoinShopWnd_Buy_Button_Down", "L2UI_CT1.LCoinShopWnd.LCoinShopWnd_Buy_Button_Over", 32, 32, 32, 32);
	ItemInfoToParam(iInfo, itemParam);
	rowData.szReserved = itemParam;
	outRowData = rowData;
	return true;
}

private function bool MakeRowData(UIPacket._WorldExchangeItemData _itemData, out RichListCtrlRowData outRowData)
{
	local RichListCtrlRowData rowData;
	local ItemInfo iInfo;
	local string strcom, itemParam;
	local float unitPrice;

	rowData.cellDataList.Length = 5;
	if(_itemData.nItemClassID < 1)
	{
		return false;
	}
	if(! class'UIDATA_ITEM'.static.GetItemInfo(GetItemID(_itemData.nItemClassID), iInfo))
	{
		return false;
	}
	rowData.nReserved1 = _itemData.nWEIndex;
	iInfo.ItemNum = _itemData.nAmount;
	iInfo.bShowCount = IsStackableItem(iInfo.ConsumeType);
	iInfo.Enchanted = _itemData.nEnchant;
	iInfo.RefineryOp1 = _itemData.nVariationOpt1;
	iInfo.RefineryOp2 = _itemData.nVariationOpt2;
	iInfo.AttackAttributeType = _itemData.nBaseAttributeAttackType;
	iInfo.AttackAttributeValue = _itemData.nBaseAttributeAttackValue;
	iInfo.DefenseAttributeValueFire = _itemData.nBaseAttributeDefendValue[0];
	iInfo.DefenseAttributeValueWater = _itemData.nBaseAttributeDefendValue[1];
	iInfo.DefenseAttributeValueWind = _itemData.nBaseAttributeDefendValue[2];
	iInfo.DefenseAttributeValueEarth = _itemData.nBaseAttributeDefendValue[3];
	iInfo.DefenseAttributeValueHoly = _itemData.nBaseAttributeDefendValue[4];
	iInfo.DefenseAttributeValueUnholy = _itemData.nBaseAttributeDefendValue[5];
	iInfo.LookChangeItemID = _itemData.nShapeShiftingClassId;
	iInfo.LookChangeItemName = class'UIDATA_ITEM'.static.GetItemName(GetItemID(_itemData.nShapeShiftingClassId));
	if(_itemData.nShapeShiftingClassId > 0)
	{
		iInfo.LookChangeIconPanel = "BranchSys3.Icon.pannel_lookChange";
	}
	iInfo.EnsoulOption[1 - 1].OptionArray[0] = _itemData.nEsoulOption[0];
	iInfo.EnsoulOption[1 - 1].OptionArray[1] = _itemData.nEsoulOption[1];
	iInfo.EnsoulOption[2 - 1].OptionArray[0] = _itemData.nEsoulOption[2];
	iInfo.IsBlessedItem = _itemData.nBlessOption == 1;
	addRichListCtrlTexture(rowData.cellDataList[0].drawitems, "l2ui_ct1.ItemWindow_DF_SlotBox_Default", 36, 36, 0, 1);
	AddRichListCtrlItem(rowData.cellDataList[0].drawitems, iInfo, 32, 32, -34, 2);
	addRichListCtrlString(rowData.cellDataList[0].drawitems, GetItemNameAll(iInfo), GTColor().White, false, 4, 9);
	addRichListCtrlString(rowData.cellDataList[1].drawitems, string(_itemData.nAmount), GTColor().White, false);
	iInfo.Price = _itemData.nPrice;
	strcom = MakeCostStringINT64(iInfo.Price);
	addRichListCtrlString(rowData.cellDataList[2].drawitems, GetSystemString(3931), GetColor(147, 136, 112, 255), false, 18, 0);
	addRichListCtrlString(rowData.cellDataList[2].drawitems, strcom, GetNumericColor(strcom), false, 5, 0);
	unitPrice = float(iInfo.Price) / float(iInfo.ItemNum);
	strcom = MakeCostStringINT64(iInfo.Price / iInfo.ItemNum);
	addRichListCtrlString(rowData.cellDataList[3].drawitems, "." $ GetDecimalNnmStr(unitPrice), GetColor(123, 123, 123, 255), false, 0, 1, "hs7");
	addRichListCtrlString(rowData.cellDataList[3].drawitems, strcom, GetNumericColor(strcom), false, 0, -2);
	addRichListCtrlButton(rowData.cellDataList[4].drawitems, "btnBuy_" $ string(_itemData.nWEIndex), 0, 0, "L2UI_CT1.LCoinShopWnd.LCoinShopWnd_Buy_Button", "L2UI_CT1.LCoinShopWnd.LCoinShopWnd_Buy_Button_Down", "L2UI_CT1.LCoinShopWnd.LCoinShopWnd_Buy_Button_Over", 32, 32, 32, 32);
	ItemInfoToParam(iInfo, itemParam);
	rowData.szReserved = itemParam;
	outRowData = rowData;
	return true;
}

function bool CheckOpenCondition()
{
	if(IsPlayerOnWorldRaidServer())
	{
		getInstanceL2Util().showGfxScreenMessage(GetSystemMessage(4047));
		return false;
	}
	if(! ChkUseableLevel())
	{
		getInstanceL2Util().showGfxScreenMessage(MakeFullSystemMsg(GetSystemMessage(113), GetSystemString(14063)));
		return false;
	}
	if(! ChkUseableServerID())
	{
		getInstanceL2Util().showGfxScreenMessage(MakeFullSystemMsg(GetSystemMessage(113), GetSystemString(14063)));
		return false;
	}
	if(GetWindowHandle("PrivateShopWndReport").IsShowWindow())
	{
		getInstanceL2Util().showGfxScreenMessage(GetSystemMessage(4217));
		return false;
	}
	return true;
}

function bool ChkUseableServerID()
{
	if(GetBRWorldExchange())
	{
		return true;
	}
	return false;
}

function bool ChkUseableLevel()
{
	local UserInfo uInfo;

	if(! GetPlayerInfo(uInfo))
	{
		return false;
	}
	return uInfo.nLevel >= API_GetWorldExchangeData().UseableLevel;
}

function ChckBtnName(string btnName)
{
	local array<string> names;

	Split(btnName, "_", names);
	switch(names[0])
	{
		case "btnBuy":
			SetShowBuyDialogWindow(int(names[1]));
			break;
	}
}

function SetShowBuyDialogWindow(int _nWEIndex)
{
	local string popupPath;
	local RichListCtrlRowData rowData;
	local ItemInfo iInfo;
	local INT64 lcoinCount;
	local float unitPrice;

	popupPath = ItemBuyPopUp_Wnd.m_WindowNameWithFullPath;
	GetCurrentRichlistCtrlHandle().GetSelectedRec(rowData);
	if(rowData.nReserved1 != _nWEIndex)
	{
		return;
	}
	ParamToItemInfo(rowData.szReserved, iInfo);
	GetItemWindowHandle(popupPath $ ".Item_ItemWnd").Clear();
	if(IsAdena(iInfo.Id))
	{
		GetTextBoxHandle(popupPath $ ".ItemName_Txt").SetTextColor(GetNumericColor(string(iInfo.ItemNum)));
		GetTextBoxHandle(popupPath $ ".ItemName_Txt").SetText(_MakeAdenaString(iInfo.ItemNum));
		GetTextBoxHandle(popupPath $ ".ItemNum_Txt").SetText("x1");
		unitPrice = float(iInfo.Price) / float(iInfo.ItemNum / ADENA_BASIC_UNIT);
		if(class'WorldExchangeBuyWnd'.static.Inst()._IsNewServer())
		{
			GetTextBoxHandle(popupPath $ ".UnitPriceTitle_Txt").SetText(GetSystemString(14424));			
		}
		else
		{
			GetTextBoxHandle(popupPath $ ".UnitPriceTitle_Txt").SetText(GetSystemString(14192));
		}		
	}
	else
	{
		GetTextBoxHandle(popupPath $ ".ItemName_Txt").SetTextColor(GetColor(153, 153, 153, 255));
		GetTextBoxHandle(popupPath $ ".ItemName_Txt").SetText(GetItemNameAll(iInfo));
		GetTextBoxHandle(popupPath $ ".ItemNum_Txt").SetText("x" $ string(iInfo.ItemNum));
		unitPrice = float(iInfo.Price) / float(iInfo.ItemNum);
		GetTextBoxHandle(popupPath $ ".UnitPriceTitle_Txt").SetText(GetSystemString(14088));
	}
	GetItemWindowHandle(popupPath $ ".Item_ItemWnd").AddItem(iInfo);
	GetTextBoxHandle(popupPath $ ".UnitPriceCount_txt").SetText(MakeUintString(unitPrice));
	GetTextBoxHandle(popupPath $ ".TotalPiceCount_txt").SetText(MakeCostString(string(iInfo.Price)));
	lcoinCount = GetInventoryItemCount(GetItemID(RESTARTPOINTITEM_LCOIN));
	GetTextBoxHandle(popupPath $ ".MyLcoinPiceCount_txt").SetText(MakeCostString(string(lcoinCount)));
	if(lcoinCount < iInfo.Price)
	{
		GetButtonHandle(popupPath $ ".Ok_Btn").DisableWindow();
		GetTextBoxHandle(popupPath $ ".MyLcoinPiceCount_txt").SetTextColor(GTColor().Red);		
	}
	else
	{
		GetButtonHandle(popupPath $ ".Ok_Btn").EnableWindow();
		GetTextBoxHandle(popupPath $ ".MyLcoinPiceCount_txt").SetTextColor(GTColor().BLUE01);
		nWEIndex = _nWEIndex;
	}
	ShowBuyDialog();
}

function string GetDecimalNnmStr(float Num)
{
	local string floatString;
	local array<string> nums;

	floatString = ConvertFloatToString(Num, 2, false);
	Split(floatString, ".", nums);
	return nums[1];
}

function string GetInt64NumStr(float Num)
{
	local array<string> nums;

	Split(string(Num), ".", nums);
	return nums[0];
}

function string MakeUintString(float unitPrice)
{
	local string int64numStr, unitPricStr;

	int64numStr = MakeCostString(GetInt64NumStr(unitPrice));
	unitPricStr = GetDecimalNnmStr(unitPrice);
	return (int64numStr $ ".") $ unitPricStr;
}

function ShowBuyDialog()
{
	itemBuyDialog_Wnd.ShowWindow();
	ItemBuyPopUp_Wnd.ShowWindow();
	ItemBuyResultPopUp_Wnd.HideWindow();
	uicontrolTextInputScr.SetDisable(true);
}

function showDisable()
{
	itemBuyDialog_Wnd.ShowWindow();
	ItemBuyPopUp_Wnd.HideWindow();
	ItemBuyResultPopUp_Wnd.HideWindow();
	uicontrolTextInputScr.SetDisable(true);
}

function ShowBuyResultPopup()
{
	local int SelectedIndex;
	local string popupPath;
	local ItemWindowHandle Result_ItemWnd;
	local RichListCtrlRowData rowData;
	local ItemInfo iInfo;
	local RichListCtrlHandle List;

	List = GetCurrentRichlistCtrlHandle();
	SelectedIndex = List.GetSelectedIndex();
	List.GetSelectedRec(rowData);
	ParamToItemInfo(rowData.szReserved, iInfo);
	List.DeleteRecord(SelectedIndex);
	popupPath = m_hOwnerWnd.m_WindowNameWithFullPath $ ".ItemBuyDialog_Wnd.ItemBuyResultPopUp_Wnd";
	Result_ItemWnd = GetItemWindowHandle(popupPath $ ".Result_ItemWnd");
	Result_ItemWnd.Clear();
	Result_ItemWnd.AddItem(iInfo);
	if(((IsAdena(iInfo.Id) && GetLanguage() == LANG_English) || GetLanguage() == LANG_Russia) || GetLanguage() == LANG_Euro)
	{
		GetTextBoxHandle(popupPath $ ".ItemName_Txt").SetText(_MakeAdenaString(iInfo.ItemNum));		
	}
	else
	{
		GetTextBoxHandle(popupPath $ ".ItemName_Txt").SetText((GetItemNameAll(iInfo)) @ "(" $ string(iInfo.ItemNum) $ ")");
	}
	itemBuyDialog_Wnd.ShowWindow();
	ItemBuyPopUp_Wnd.HideWindow();
	ItemBuyResultPopUp_Wnd.ShowWindow();
	uicontrolTextInputScr.SetDisable(true);
	if(iInfo.Id.ClassID == 57)
	{
		class'WorldExchangeBuyHome'.static.Inst()._RQ_COININFO();
	}	
}

function HideBuyDialog()
{
	itemBuyDialog_Wnd.HideWindow();
	uicontrolTextInputScr.SetDisable(false);
}

function HideDisable()
{
	itemBuyDialog_Wnd.HideWindow();
	uicontrolTextInputScr.SetDisable(false);
}

function bool _IsNewServer()
{
	local UserInfo uInfo;
	local ServerInfoUIData ServerInfo;

	GetPlayerInfo(uInfo);
	if(class'UIDataManager'.static.GetServerInfo(uInfo.nWorldID, ServerInfo))
	{
		if(ServerInfo.ServerID == 96 || ServerInfo.ServerID == 97)
		{
			return true;
		}
	}
	return false;	
}

private function HandleOnGameStart()
{
	if(bFormSetting)
	{
		return;
	}
	if(_IsNewServer())
	{
		ADENA_BASIC_UNIT = 1000000;
		List_RichListAdena.SetColumnString(2, 14424);		
	}
	else
	{
		ADENA_BASIC_UNIT = 10000000;
		List_RichListAdena.SetColumnString(2, 14192);
	}
	ADENA_MIN = ADENA_BASIC_UNIT;
	ADENA_MAX = 1000000000;
	bFormSetting = true;
	class'WorldExchangeRegiWnd'.static.Inst()._OnLoadEachServer();
	class'WorldExchangeBuyHome'.static.Inst()._OnLoadEachServer();	
}

private function OnLoadEachServer()
{
	GetMeTexture("ItemBuyDialog_Wnd.ItemBuyPopUp_Wnd.TotalPiceIcon_Tex").SetTexture("L2UI_CT1.LCoinShopWnd.LCoinShopWnd_Icon_Lcoin");
	GetMeTexture("ItemBuyDialog_Wnd.ItemBuyPopUp_Wnd.MyLcoinIcon_Tex").SetTexture("L2UI_CT1.LCoinShopWnd.LCoinShopWnd_Icon_Lcoin");
	SetMainCategoryButtons();
	SetSubCategoryData();	
}

event OnReceivedCloseUI()
{
	if(itemBuyDialog_Wnd.IsShowWindow())
	{
		HideBuyDialog();
	}
	else
	{
		PlayConsoleSound(IFST_WINDOW_CLOSE);
		_Hide();
	}
}
