/***
 *   종료 리포트 (종료, 리스타트 창)
 *   
 *   - 인존 정보 삭제 버전
 **/
class QuitReportWnd extends UICommonAPI;

const TIMER_ID = 999001;
const Refresh_Timer_ID = 999002;

const MAGIC_LAMP_MAX_GRADE = 4;

struct MagicLampExpInfo
{
	var INT64 Exp;
	var INT64 Count;
};

struct MagicLampGetInfo
{
	var MagicLampExpInfo expInfos[MAGIC_LAMP_MAX_GRADE];
	var INT64 totalNum;
};

var WindowHandle  Me;
var WindowHandle reportContainer;
var WindowHandle expInfoContainer;
var WindowHandle adenaInfoContainer;
var WindowHandle itemInfoContainer;
var WindowHandle magicLampInfoContainer;
var WindowHandle playTimeInfoContainer;
var TextureHandle ButtonIconImg_Texture;
var TextBoxHandle txtPlayReportWnd_Title;
var TextBoxHandle txtPlayReportWnd_item;
var TextBoxHandle txtPlayReportWnd_magicLamp;
var TextBoxHandle txtPlayReportWnd_exp;
var TextBoxHandle txtPlayReportWnd_GameSession;
var HtmlHandle txtPlayReportWnd_adena;

var ButtonHandle   ITEMButton_Right;
var ButtonHandle   ITEMButton_Reset;
// var WindowHandle   InstanceDungeonWnd;

// var TextureHandle  InstanceDungeon_ListBG;
// var TextBoxHandle  txtInstanceDungeon_Title;

// var ListCtrlHandle InstanceDungeon_ListCtrl;

var ButtonHandle BtnRestart;
var ButtonHandle BtnCancel;


var int64 beforeExp, exp, beforeAdena, adena;  //, beforeNPKCount;

var bool firstSetting, firstAdenaSetting;

var string quitOrRestartExeStr;
var ButtonHandle magicLampListOpenBtn;
// 얻은 아이템 목록
var array<ItemInfo>	getItemInfoArray;
var MagicLampGetInfo _getMagicLampInfo;
var L2Util util;
var InventoryWnd inventoryWndScript;
var QuitReportDrawerWnd QuitReportDrawerWndScript;

var QuitReportDrawerMagicLampWnd drawerMagicLampScript;
var UserInfo playerInfo;

// RequestInzoneWaitingTime() 의 이벤트를 받기전에 true로 되어 있을때만 받음.
//var bool enableRequestAPI;
var QuitReportDrawerInstantZoneWnd QuitReportDrawerInstantZoneWndScript;

static function QuitReportWnd Inst()
{
	return QuitReportWnd(GetScript("QuitReportWnd"));	
}

function OnRegisterEvent()
{
	RegisterEvent(EV_Restart);
	RegisterEvent(EV_UpdateUserInfo);
	// registerEvent(EV_InzoneWaitingInfo)
	// 
	RegisterEvent( EV_AdenaInvenCount );

	RegisterEvent( EV_OpenDialogQuit );
	RegisterEvent( EV_OpenDialogRestart );

	RegisterEvent( EV_ChangedSubjob );
	RegisterEvent(EV_PacketID(class'UIPacket'.const.S_EX_MAGICLAMP_RESULT));
}

function OnLoad()
{
	SetClosingOnESC();
	Initialize();
	
	// 끄기로 했음(사업부에서 끄기로 했음)
	// Me.SetModal(true);
}

function OnShow()
{
	Me.SetFocus();
	UpdateUserInfoHandler();

	updateGameSessionText();
	UpdateInfoControls();
	Me.SetTimer(Refresh_Timer_ID,10000);

	//Me.BringToFront();
}

function OnHide ()
{
	drawerMagicLampScript.ClearListControls();
	Me.KillTimer(Refresh_Timer_ID);
}

function Initialize()
{
	local string ownerFullPath;

	ownerFullPath = m_hOwnerWnd.m_WindowNameWithFullPath;
	Me = GetWindowHandle(ownerFullPath);
	reportContainer = GetWindowHandle(ownerFullPath $ ".PlayReportWnd");
	expInfoContainer = GetWindowHandle(reportContainer.m_WindowNameWithFullPath $ ".EXP_ReportWnd");
	adenaInfoContainer = GetWindowHandle(reportContainer.m_WindowNameWithFullPath $ ".Adena_ReportWnd");
	itemInfoContainer = GetWindowHandle(reportContainer.m_WindowNameWithFullPath $ ".Item_ReportWnd");
	magicLampInfoContainer = GetWindowHandle(reportContainer.m_WindowNameWithFullPath $ ".Magiclamp_ReportWnd");
	playTimeInfoContainer = GetWindowHandle(reportContainer.m_WindowNameWithFullPath $ ".GameSession_ReportWnd");
	txtPlayReportWnd_exp = GetTextBoxHandle(expInfoContainer.m_WindowNameWithFullPath $ ".txtPlayReportWnd_exp");
	txtPlayReportWnd_adena = GetHtmlHandle(adenaInfoContainer.m_WindowNameWithFullPath $ ".txtPlayReportWnd_adena");
	txtPlayReportWnd_item = GetTextBoxHandle(itemInfoContainer.m_WindowNameWithFullPath $ ".txtPlayReportWnd_item");
	txtPlayReportWnd_magicLamp = GetTextBoxHandle(magicLampInfoContainer.m_WindowNameWithFullPath $ ".txtPlayReportWnd_Magiclamp");
	txtPlayReportWnd_GameSession = GetTextBoxHandle(playTimeInfoContainer.m_WindowNameWithFullPath $ ".txtPlayReportWnd_GameSession");
	magicLampListOpenBtn = GetButtonHandle("QuitReportWnd.PlayReportWnd.MagicLampButton_Right");
	ITEMButton_Right = GetButtonHandle("QuitReportWnd.PlayReportWnd.ITEMButton_Right");
	ITEMButton_Reset = GetButtonHandle("QuitReportWnd.PlayReportWnd.ITEMButton_Reset");
	BtnRestart = GetButtonHandle("QuitReportWnd.BtnRestart");
	btnCancel = GetButtonHandle("QuitReportWnd.BtnCancel");
	// 종료 버튼 이미지 
	ButtonIconImg_Texture = GetTextureHandle("QuitReportWnd.ButtonIconImg_Texture");
	util = L2Util(GetScript("L2Util"));
	inventoryWndScript = InventoryWnd(GetScript("inventoryWnd"));
	QuitReportDrawerWndScript = QuitReportDrawerWnd(GetScript("QuitReportDrawerWnd"));
	QuitReportDrawerInstantZoneWndScript = QuitReportDrawerInstantZoneWnd(GetScript("QuitReportDrawerInstantZoneWnd"));
	drawerMagicLampScript = QuitReportDrawerMagicLampWnd(GetScript("QuitReportDrawerMagicLampWnd"));
	init();
}

// 초기화
function init()
{
	//quitOrRestartExeStr = "quit";
	beforeExp = 0;
	exp = 0;

	adena = 0;
	beforeAdena = GetAdena();
	
	//beforeNPKCount = -1;
	firstSetting = false;
	firstAdenaSetting = false;
	//enableRequestAPI = false;

	if (GetWindowHandle("QuitReportDrawerWnd").IsShowWindow())
	{
		setDrawerButtonState(true);
		GetWindowHandle("QuitReportDrawerWnd").HideWindow();
	}
	if(GetWindowHandle("QuitReportDrawerMagicLampWnd").IsShowWindow())
	{
		SetDrawerMagicLampButtonState(true);
		GetWindowHandle("QuitReportDrawerMagicLampWnd").HideWindow();
	}
	ResetMagicLampGetInfo();
	SetForm();
	UpdateInfoControls();
}

function SetForm()
{
	if(UseMagicLampSystem())
	{
		expInfoContainer.SetAnchor(reportContainer.m_WindowNameWithFullPath, "TopCenter", "TopCenter", 0, 51);
		adenaInfoContainer.SetAnchor(reportContainer.m_WindowNameWithFullPath, "TopCenter", "TopCenter", 0, 90);
		itemInfoContainer.SetAnchor(reportContainer.m_WindowNameWithFullPath, "TopCenter", "TopCenter", 0, 130);
		playTimeInfoContainer.SetAnchor(reportContainer.m_WindowNameWithFullPath, "TopCenter", "TopCenter", 0, 206);
		magicLampInfoContainer.ShowWindow();		
	}
	else
	{
		expInfoContainer.SetAnchor(reportContainer.m_WindowNameWithFullPath, "TopCenter", "TopCenter", 0, 66);
		adenaInfoContainer.SetAnchor(reportContainer.m_WindowNameWithFullPath, "TopCenter", "TopCenter", 0, 104);
		itemInfoContainer.SetAnchor(reportContainer.m_WindowNameWithFullPath, "TopCenter", "TopCenter", 0, 143);
		playTimeInfoContainer.SetAnchor(reportContainer.m_WindowNameWithFullPath, "TopCenter", "TopCenter", 0, 190);
		magicLampInfoContainer.HideWindow();
	}	
}

function ResetMagicLampGetInfo()
{
	local MagicLampGetInfo defaultInfo;

	_getMagicLampInfo = defaultInfo;	
}

// 보조 윈도우, 열고 닫을때, >  < 버튼 텍스쳐 변경
function setDrawerButtonState(bool bShow)
{
	if (bShow)
	{
		ITEMButton_Right.SetTexture("L2UI_CT1.Button.Button_DF_Right_Down", 
									"L2UI_CT1.Button.Button_DF_Right_Down",
									"L2UI_CT1.Button.Button_DF_Right_Over");
	}
	else
	{
		ITEMButton_Right.SetTexture("L2UI_CT1.Button.Button_DF_Left_Down", 
									"L2UI_CT1.Button.Button_DF_Left_Down", 
									"L2UI_CT1.Button.Button_DF_Left_Over");
	}	
}

function SetDrawerMagicLampButtonState(bool bShow)
{
	if(bShow)
	{
		magicLampListOpenBtn.SetTexture("L2UI_CT1.Button.Button_DF_Right_Down", "L2UI_CT1.Button.Button_DF_Right_Down", "L2UI_CT1.Button.Button_DF_Right_Over");		
	}
	else
	{
		magicLampListOpenBtn.SetTexture("L2UI_CT1.Button.Button_DF_Left_Down", "L2UI_CT1.Button.Button_DF_Left_Down", "L2UI_CT1.Button.Button_DF_Left_Over");
	}	
}

//-----------------------------------------------------------------------------------------------------------
// OnClickButton
//-----------------------------------------------------------------------------------------------------------
function OnClickButton( string Name )
{
	switch( Name )
	{
		case "ITEMButton_Right":
			 if(!GetWindowHandle("QuitReportDrawerWnd").IsShowWindow())
			 {
				setDrawerButtonState(false);
				GetWindowHandle("QuitReportDrawerWnd").ShowWindow();
				SetDrawerMagicLampButtonState(true);
				GetWindowHandle("QuitReportDrawerMagicLampWnd").HideWindow();
			 }
			 else 
			 {
				setDrawerButtonState(true);				
				GetWindowHandle("QuitReportDrawerWnd").HideWindow();
			 }
			 break;
		case "MagicLampButton_Right":
			if(! GetWindowHandle("QuitReportDrawerMagicLampWnd").IsShowWindow())
			{
				SetDrawerMagicLampButtonState(false);
				GetWindowHandle("QuitReportDrawerMagicLampWnd").ShowWindow();
				setDrawerButtonState(true);
				GetWindowHandle("QuitReportDrawerWnd").HideWindow();				
			}
			else
			{
				SetDrawerMagicLampButtonState(true);
				GetWindowHandle("QuitReportDrawerMagicLampWnd").HideWindow();
			}
			break;
		case "ITEMButton_Reset":
			 OnITEMButton_ResetClick();
			 break;

		case "BtnRestart":
			 ExecuteQuitOrRestart();
			 Me.HideWindow();
			 break;

		case "BtnCancel":
			 OnBtnCancelClick();

			 break;
	}
}

// 종료, 리스타트 처리
function ExecuteQuitOrRestart()
{
	local InventoryWnd Script;
	Script = InventoryWnd(GetScript("InventoryWnd"));
	Script.SaveInventoryOrder();

	if (quitOrRestartExeStr == "quit")
	{
		ExecQuit();
	}
	else
	{
		//리스타트시 숨길 윈도우(기존에 있던거라 넣음)
		//GetWindowHandle("SystemMenuWnd").HideWindow();		
		ExecRestart();
	}
}

// 초기화
function OnITEMButton_ResetClick()
{

	GetPlayerInfo(playerInfo);

	beforeExp      = playerInfo.nCurExp;
	//beforeExp = 0;
	exp = 0;

	adena = 0;
	beforeAdena = GetAdena();
	
	//beforeNPKCount = -1;
	firstSetting = true;
	firstAdenaSetting = true;
	//enableRequestAPI = false;

	QuitReportDrawerWndScript.init();

	// RequestInzoneWaitingTime();
	if (GetWindowHandle("QuitReportDrawerWnd").IsShowWindow())
	{
		setDrawerButtonState(true);
		GetWindowHandle("QuitReportDrawerWnd").HideWindow();
	}
	if(GetWindowHandle("QuitReportDrawerMagicLampWnd").IsShowWindow())
	{
		SetDrawerMagicLampButtonState(true);
		GetWindowHandle("QuitReportDrawerMagicLampWnd").HideWindow();
	}
	ResetMagicLampGetInfo();
	UpdateInfoControls();
}

function OnBtnCancelClick()
{
	Me.HideWindow();
}

//-----------------------------------------------------------------------------------------------------------
// Evnet
//-----------------------------------------------------------------------------------------------------------
function OnEvent( int a_EventID, String a_Param )
{
	local int64 pAdena;
	local int nQuitRestrictField;
	
	if(a_EventID == EV_AdenaInvenCount)
	{
		ParseINT64 (a_Param, "Adena", pAdena);
		//Debug("EV_AdenaInvenCount: " @ a_Param);
		UpdateAdena(pAdena);
	}
	else if( a_EventID == EV_Restart )
	{
		ParseInt(a_Param, "QuitRestrictField", nQuitRestrictField);
		if(nQuitRestrictField == 0)
		{
			init();
			QuitReportDrawerWndScript.Init();
		}
	}
	else if( a_EventID == EV_OpenDialogQuit )
	{
		quitOrRestartExeStr = "quit";
		ButtonIconImg_Texture.SetTexture("L2UI_CT1.Icon.QuitIcon");
		BtnRestart.SetButtonName(148);
		setWindowTitleByString(GetSystemString(148));

		// enableRequestAPI = true;
		// RequestInzoneWaitingTime();

		Me.ShowWindow();
		Me.SetFocus();
	}
	else if( a_EventID == EV_OpenDialogRestart )
	{
		quitOrRestartExeStr = "restart";
		ButtonIconImg_Texture.SetTexture("L2UI_CT1.Icon.RestartIcon");
		BtnRestart.SetButtonName(147);
		setWindowTitleByString(GetSystemString(147));

		// enableRequestAPI = true;
		// RequestInzoneWaitingTime();

		Me.ShowWindow();
		Me.SetFocus();
	}
	else if( a_EventID == EV_UpdateUserInfo )
	{
		//  Debug("EV_UpdateUserInfo" @ EV_UpdateUserInfo);
		UpdateUserInfoHandler();
	}
	// 듀얼 서브 변신 할때, exp 초기화 
	else if (a_EventID  == EV_ChangedSubjob )
	{		
		// 경험치 부분만 초기화
		firstSetting = false;
		beforeExp = 0;
		exp = 0;
		txtPlayReportWnd_exp.SetText(MakeFullSystemMsg(GetSystemMessage(4323), "0"));
	}
	else if(a_EventID == (EV_PacketID(class'UIPacket'.const.S_EX_MAGICLAMP_RESULT)))
	{
		Nt_S_EX_MAGICLAMP_RESULT();
	}

	//else if( a_EventID == EV_InzoneWaitingInfo )
	//{
	//	if (enableRequestAPI)
	//	{
	//		handleInzoneWaitingInfo(a_Param);
	//		enableRequestAPI = false;
	//	}
	//	//Debug("handleInzoneWaitingInfo : " @ a_Param);
	//}
}

//// 인스턴스 던전 이용 제한 시간 
//function string handleInzoneWaitingInfo(string param)
//{
//	local int currentInzoneID;
//	local int sizeOfBlockedInzone ;
//	local int blockedInzoneID ;
//	local int blockedInzoneLeftSeconds ;
//	local string currentInzoneName;
//	local string blockedInzoneName;
//	local string LeftTime;

//	local int i;

//	local string strParam ;
	
//	parseInt (param, "currentInzoneID" , currentInzoneID );
//	currentInzoneName = GetInZoneNameWithZoneID(currentInzoneID);
//	if (currentInzoneName == "Invalid inzone ID") currentInzoneName =  "";

//	ParamAdd( strParam, "currentInzoneName", currentInzoneName ) ;
	
//	parseInt (param, "sizeOfBlockedInzone" , sizeOfBlockedInzone );	
//	ParamAdd( strParam, "sizeOfBlockedInzone", String ( sizeOfBlockedInzone ) ) ;
	
//	//Debug("sizeOfBlockedInzone=== " @ sizeOfBlockedInzone);

//	//InstanceDungeon_ListCtrl.DeleteAllItem();

//	for (i = 0 ; i <  sizeOfBlockedInzone ; i++ ) 
//	{
//		parseInt (param, "blockedInzoneID_"$i, blockedInzoneID );		
//		parseInt (param, "blockedInzoneLeftSeconds_"$i , blockedInzoneLeftSeconds );		
//		blockedInzoneName = GetInZoneNameWithZoneID(blockedInzoneID);
//		LeftTime = setTimeString ( blockedInzoneLeftSeconds );

//		ParamAdd( strParam, "blockedInzoneName_"$i, blockedInzoneName );
//		ParamAdd( strParam, "blockedInzoneTimeString_"$i, LeftTime );
//		ParamAdd( strParam, "blockedInzoneTime_"$i, String( blockedInzoneLeftSeconds ) );

//		// 인존이름, 남은 시간
//		addInzoneListItem(blockedInzoneName, LeftTime);
//	}

//	// Debug("blockedInzoneName" @ blockedInzoneName);
//	// Debug("LeftTime" @ LeftTime);

//	return strParam;
//}

function updateGameSessionText ()
{
	local L2UITime UITimeStruct;

	UITimeStruct = getInstanceUIData().getCurrentRealLocalTime();
	txtPlayReportWnd_GameSession.SetText(getInstanceUIData().gameConnectTimeString());
	GetTimeStruct(60,UITimeStruct);
}

/** 아이템을 추가 한다. */
function addInzoneListItem(string inzoneName, string remainTimeStr)
{
	local LVDataRecord Record;

	Record.LVDataList.length = 2;
	//Record.LVDataList[0].textColor = getColor(100,30,3, 255);
	Record.LVDataList[0].szData = inzoneName;
	Record.LVDataList[1].szData = remainTimeStr;

	//InstanceDungeon_ListCtrl.InsertRecord( Record );
}

function string setTimeString(int tmpTime)
{
	//규칙 1시간 이상은 시간만
	//1시간 이하는 분만
	//1분 이하는 1분 이하
	local string timeStr;
	local int timeHour;
	local int timeMin;
	//local int stringNum
	//Debug("타임을 세팅합니다.");
	//Debug("tmpTime=== " @ tmpTime);
	if ( tmpTime < 60 ) //분 미만으로
	{ 			
		timeStr = MakeFullSystemMsg( GetSystemMessage(3390), string(1)); //1 분
		timeStr = MakeFullSystemMsg( GetSystemMessage(3408), timeStr);   //미만
	} 
	else if ( tmpTime < 3600 ) {//몇 분으로	
		tmpTime = tmpTime/60;
		timeStr = MakeFullSystemMsg( GetSystemMessage(3390), string(tmpTime));			
	} 
	else {//시간
		//tmpTime = tmpTime/3600;
		//timeStr = MakeFullSystemMsg( GetSystemMessage(3406), string(tmpTime));	
		//timeHour = 	tmpTime/3600;	
			

		timeHour = tmpTime/3600;
		timeMin	= (tmpTime - timeHour*3600)/60;
		//Debug("timeHour=== " @ timeHour);
		//Debug("timeMin=== " @ timeMin);
		if(timeMin > 0){
			timeStr = MakeFullSystemMsg( GetSystemMessage(3406), string(timeHour)) @ MakeFullSystemMsg( GetSystemMessage(3390), string(timeMin));
		}else {
			timeStr = MakeFullSystemMsg( GetSystemMessage(3406), string(timeHour));
		}
		
	}
	//Debug("timeStr=== " @ timeStr);
	return timeStr;
}

// 아데나 업데이트
function UpdateAdena(Int64 pAdena)
{
	// 최초 정보를 받았을때만..
	if (firstAdenaSetting == false)
	{	
		adena = 0;
		beforeAdena = pAdena;
		firstAdenaSetting = true;
	}

	if (pAdena > beforeAdena)
	{   
		adena = adena + (pAdena - beforeAdena);
	}
	beforeAdena = pAdena;
	UpdateAdenaInfoControl();
	SetMPlayerClientVar("earned_adn", string(adena));
}

// 유저 정보가 업데이트 될때 
function UpdateUserInfoHandler()
{	
	//local string HtmlString;
	local int64 itemCount;

	// 게이밍 스테이트인 동안만
	if (GetGameStateName() != "GAMINGSTATE") return;

	GetPlayerInfo(playerInfo);

	// 최초 정보를 받았을때만..
	if (firstSetting == false)
	{		
		firstSetting   = true;
		beforeExp      = playerInfo.nCurExp;
		exp            = 0;

		// Debug("- playerInfo.nCurExp" @ playerInfo.nCurExp);
		if (Me.IsShowWindow())
		{
			UpdateExpInfoControl();
		}
	}

	if (playerInfo.nCurExp > beforeExp)
	{   
		exp = exp + (playerInfo.nCurExp - beforeExp);
	}
	beforeExp = playerInfo.nCurExp;
	itemCount = QuitReportDrawerWndScript.getTotalItemCount();
	// 일질적으로 창이 열려 있을때만 갱신한다.
	if (Me.IsShowWindow())
	{
		UpdateExpInfoControl();
		UpdateItemInfoControl();
	}
	SetMPlayerClientVar("earned_exp", string(exp));
	SetMPlayerClientVar("item_cnt", string(itemCount));	
}

function UpdateExpInfoControl()
{
	local string expStr;
	local Color expStrColor;

	if(Me.IsShowWindow() == false)
	{
		return;
	}
	if(UseExpAdenaColorString())
	{
		if(Exp == 0)
		{
			expStr = string(Exp);			
		}
		else
		{
			expStr = ConvertNumToTextNoAdena(string(Exp));
		}
		expStrColor = GetExpNumericColor(string(Exp));		
	}
	else
	{
		expStr = MakeFullSystemMsg(GetSystemMessage(4323), MakeCostString(string(Exp)));
		expStrColor = GetColor(170, 153, 119, 255);
	}
	txtPlayReportWnd_exp.SetText(expStr);
	txtPlayReportWnd_exp.SetTextColor(expStrColor);	
}

function UpdateAdenaInfoControl()
{
	local string htmlAdd, adenaHexColor, adenaStr;

	if(Me.IsShowWindow() == false)
	{
		return;
	}
	if(UseExpAdenaColorString())
	{
		if(Adena == 0)
		{
			adenaStr = string(Adena);			
		}
		else
		{
			adenaStr = ConvertNumToTextNoAdena(string(Adena));
		}
		adenaHexColor = getColorHexString(GetNumericColor(string(Adena)));		
	}
	else
	{
		adenaStr = MakeCostString(string(Adena));
		adenaHexColor = "AA9977";
	}
	htmlAdd = htmlAddTableTD(MakeFullSystemMsg(htmlAddText(GetSystemMessage(2932), "hs10", "AA9977"), htmlAddText(adenaStr, "hs10", adenaHexColor)), "center", "center", 0, 0, "", false);
	htmlSetTableTR(htmlAdd);
	htmlSetTable(htmlAdd, 0, 174, 0, "", 0, 0);
	txtPlayReportWnd_adena.LoadHtmlFromString(htmlSetHtmlStart(htmlAdd), false);	
}

function UpdateItemInfoControl()
{
	if(Me.IsShowWindow() == false)
	{
		return;
	}
	txtPlayReportWnd_item.SetText(MakeFullSystemMsg(GetSystemMessage(1983), MakeCostString(string(QuitReportDrawerWndScript.getTotalItemCount()))));	
}

function UpdateInfoControls()
{
	UpdateExpInfoControl();
	UpdateAdenaInfoControl();
	UpdateItemInfoControl();
	UpdateMagicLampInfoControls();	
}

function OnTimer(int TimerID)
{
	if( TimerID == TIMER_ID)
	{
		beforeAdena    = GetAdena();
		Me.KillTimer( TIMER_ID );
	}
	else if( TimerID == Refresh_Timer_ID)
		updateGameSessionText();
}

// 외부(인벤토리) 에서 아이템을 추가 하는 것
function externalAddItem(ItemInfo addItemInfo)
{
	// 아데나 카운트 갱신 
	QuitReportDrawerWndScript.externalAddItem(addItemInfo);
	QuitReportDrawerInstantZoneWndScript.externalAddItem(addItemInfo);
}

///**
// * 윈도우 ESC 키로 닫기 처리 
// * "Esc" Key
// ***/
//function OnKeyUp( WindowHandle a_WindowHandle, EInputKey Key )
//{
//	if( Key == IK_Escape )
//	{
//		PlayConsoleSound(IFST_WINDOW_CLOSE);		
//		GetWindowHandle( getCurrentWindowName(string(Self))).HideWindow();
//	}
//}

function UpdateMagicLampInfoControls()
{
	if(Me.IsShowWindow() == false)
	{
		return;
	}
	txtPlayReportWnd_magicLamp.SetText(MakeFullSystemMsg(GetSystemMessage(1983), MakeCostString(string(_getMagicLampInfo.totalNum))));
	drawerMagicLampScript.UpdateMagicLampList();	
}

function MagicLampGetInfo GetMagicLampGetInfo()
{
	return _getMagicLampInfo;	
}

function AddMagicLampGetInfo(int Grade, INT64 Exp)
{
	local MagicLampExpInfo tempInfo;
	local int validGrade;

	if(Grade > MAGIC_LAMP_MAX_GRADE)
	{
		Debug("AddMagicLampGetInfo Grade out" @ string(Grade));
		return;
	}
	validGrade = Grade - 1;
	tempInfo = _getMagicLampInfo.expInfos[validGrade];
	tempInfo.Count = tempInfo.Count + 1;
	tempInfo.Exp = tempInfo.Exp + Exp;
	_getMagicLampInfo.totalNum = _getMagicLampInfo.totalNum + 1;
	_getMagicLampInfo.expInfos[validGrade] = tempInfo;	
}

function Nt_S_EX_MAGICLAMP_RESULT()
{
	local UIPacket._S_EX_MAGICLAMP_RESULT packet;

	if(! class'UIPacket'.static.Decode_S_EX_MAGICLAMP_RESULT(packet))
	{
		return;
	}
	AddMagicLampGetInfo(packet.nGrade, packet.nEXP);
	UpdateMagicLampInfoControls();	
}

function bool UseMagicLampSystem()
{
	return IsAdenServer();	
}

function bool UseExpAdenaColorString()
{
	return getInstanceUIData().getIsClassicServer();	
}

/**
 * 윈도우 ESC 키로 닫기 처리 
 * "Esc" Key
 ***/
function OnReceivedCloseUI()
{
	PlayConsoleSound(IFST_WINDOW_CLOSE);
	GetWindowHandle( getCurrentWindowName(string(Self))).HideWindow();
}
defaultproperties
{
}
