//class DetailStatusWnd extends UIScript;
class DetailStatusWndClassic extends UICommonAPI;

const DIALOG_DetailStatusWnd = 90005;
const NSTATUS_SMALLBARSIZE = 85;
const NSTATUS_BARHEIGHT = 12;

const ElixirItemID = 94314;

struct SubjobInfo
{
	var int Id;
	var int ClassID;
	var int Level;
	var int Type;
};

var String m_Statsinfo_UsePoint_Win;
var String m_WindowName;
var int m_UserID;
var HennaInfo m_HennaInfo;
//var UserInfo currentUserInfo;

var WindowHandle		Me;

//Handle
var TextBoxHandle txtClassName;
var TextBoxHandle txtSP;
var TextBoxHandle txtName1;
var TextBoxHandle txtName2;
var TextBoxHandle txtHeadPledge;
var TextBoxHandle txtPledge;
var TextBoxHandle txtLvHead;
var TextBoxHandle txtLvName;
var TextBoxHandle txtHeadRank;
var TextBoxHandle txtRank;
var StatusBarHandle texHP;
var StatusBarHandle texMP;
var StatusBarHandle texExp;
var StatusBarHandle texCP;
var TextBoxHandle txtPhysicalAttack;
var TextBoxHandle txtPhysicalDefense;
var TextBoxHandle txtHitRate;
var TextBoxHandle txtCriticalRate;
var TextBoxHandle txtPhysicalAttackSpeed;
var TextBoxHandle txtMagicalAttack;
var TextBoxHandle txtMagicDefense;
var TextBoxHandle txtPhysicalAvoid;
var TextBoxHandle txtGmMoving;
var TextBoxHandle txtHeadMovingSpeed;
var TextBoxHandle txtMovingSpeed;
var TextBoxHandle txtHeadMagicCastingSpeed;
var TextBoxHandle txtMagicCastingSpeed;

var TextBoxHandle txtCriminalRate;
var TextBoxHandle txtSociality_PVP;
var TextBoxHandle txtSociality_PK;
var TextBoxHandle txtBonusVote;
var TextBoxHandle txtRaidPoint;
var TextureHandle texPledgeCrest;
var TextureHandle VitalityTex;

var ButtonHandle SpExtractOpenBtn;

var AnimTextureHandle APActive;

var int MaxVitality; //ldw

var int nCanUseAP; //ldw

var L2Util util;//bluesun 툴팁 제어 용

var TextBoxHandle txtDisapprove;

//------------------------------
//    클래스변경메인
//------------------------------
// 깜빡이는현재클래스, 이펙트
var AnimTextureHandle ClassChangeLightBig;

// 현재클래스텍스쳐
// 메인: l2ui_ct1.PlayerStatusWnd_ClassBgMain_Big (빨강)
// 서브: l2ui_ct1.PlayerStatusWnd_ClassBgSub_Big  (청색)
var TextureHandle ClassBgMain_Big;

// 클래스마크텍스쳐
var TextureHandle ClassMarkBig;


// 클래식 속성(정령) 시스템 2017-05-2

// 속성 선택 표시
var ButtonHandle BtnElementalInfo;

// 속성, 자물쇠 이미지
var TextureHandle Element_Lock1;
var TextureHandle Element_Lock2;
var TextureHandle Element_Lock3;
var TextureHandle Element_Lock4;

// 버튼
var TextBoxHandle txtFireAttack;
var TextBoxHandle txtWaterAttack;
var TextBoxHandle txtWindAttack;
var TextBoxHandle txtEarthAttack;

// 선택된 속성 텍스트
var TextBoxHandle txtFireDefence;
var TextBoxHandle txtWaterDefence;
var TextBoxHandle txtWindDefence;
var TextBoxHandle txtEarthDefence;


//------------------------------
//     클래스변경버튼
//------------------------------
//var AnimTextureHandle ClassChangeLightSmall1, ClassChangeLightSmall2, ClassChangeLightSmall3;

// 클래스배경텍스쳐1,2,3
//var TextureHandle ClassBgMain_Small1, ClassBgMain_Small2, ClassBgMain_Small3;

// 클래스마크
//var TextureHandle ClassMarkSmall1, ClassMarkSmall2, ClassMarkSmall3;

// 듀얼, 서브클래스변경버튼
//var ButtonHandle ClassFrameBtn1, ClassFrameBtn2, ClassFrameBtn3;

// 섭잡정보
var array<SubjobInfo> subjobInfoArray;
var SubjobInfo beforeSubjobInfo;

// 현재활성화되어있는클래스
var int currentSubjobClassNum;

// 현재 듀얼 클래스 서브잡이 있는가?
var bool    isDualClass;

// 임시로 듀얼 클래스 , 서브잡 정보를 저장해서 창이 열릴때 마다 갱신 할때 사용한다.
// var string  saveUpdateSubjobInfoParam;

// 마지막으로 받은 서브잡, 듀얼 관련 이벤트 값 저장
// var int updateSubjobLastEvent;
/*
History: UObject::ProcessEvent <-(DamageText Transient.DamageText, Function Interface.DamageText.OnEvent) <- 
GFxUIManager::ExecuteUIEvent <- ID:580, param:Index=361 Param1=1209048809 Param2=1209050262 <- ExecuteUIEvent
<- NSystemMessageManager::EndSystemMessageParam <- NConsoleWnd::EndSystemMessageParam <- SystemMessagePacket <- 
UNetworkHandler::Tick <- Function Name=SystemMessagePa <- UGameEngine::Tick <- UpdateWorld <- MainLoop
 **/

var int statusCanPlus;
var int statusMax;
var int statusPlusedCurrent;
var ButtonHandle UsePoint_Apply_BTN;
var ButtonHandle UsePoint_Cancel_BTN;
var ButtonHandle UsePoint_Reset_BTN;
var TextBoxHandle Statsinfo_UsePoint_text;
var WindowHandle StatConfirmResetWnd;
var WindowHandle StatConfirmApplyWnd;
var WindowHandle ConfirmWnd;
var RichListCtrlHandle ResetCharge_ListCtrl;
var TextBoxHandle NumPoint_text;
var array<int> statusPlused;
var ButtonHandle Reset_Btn;
var ButtonHandle FightInfo_BTN;

var ElementalSpiritWnd ElementalSpiritWndScript;
var TextBoxHandle ElixirPoint_txt;

var int race;

/**
 * OnRegisterEvent
 **/
function OnRegisterEvent()
{
	//Level과Exp는UserInfo패킷으로처리한다.
	RegisterEvent(EV_UpdateUserInfo);
	RegisterEvent(EV_UpdateHennaInfo);
	
	//JYLee, 의미없는 함수호출을 막기 위해 status 정보를 내 정보와 다른 캐릭터의 정보로 분리
	RegisterEvent(EV_UpdateMyHP);
	RegisterEvent(EV_UpdateMyMaxHP);
	RegisterEvent(EV_UpdateMyMP);
	RegisterEvent(EV_UpdateMyMaxMP);
	RegisterEvent(EV_UpdateMyCP);
	RegisterEvent(EV_UpdateMyMaxCP);

	// 활력업데이트
	RegisterEvent(EV_VitalityPointInfo);	

	// 다이얼로그(서브클래스변경확인용)
	RegisterEvent(EV_DialogOK);
	RegisterEvent(EV_DialogCancel);

	//듀얼클래스및서브클래스리스트
	RegisterEvent(EV_NotifySubjob);
	// CurrentSubjobClassID=3 Count=3 SubjobID_1 SubjobClassID_1=44 SubjobLevel_1=55 SubjobType_1
	RegisterEvent(EV_CreatedSubjob);
	RegisterEvent(EV_ChangedSubjob);

	RegisterEvent(EV_Restart);

// CurrentSubjobClassID=117 Count=3 SubjobID_1=1 SubjobClassID_1=3 SubjobLevel_1=55 SubjobType_1=0 SubjobID_2=1 SubjobClassID_2=73 SubjobLevel_2=55 SubjobType_2=1 SubjobID_3=1 SubjobClassID_3=131 SubjobLevel_3=55 SubjobType_3=2
	// 듀얼클래스및서브클래스리스트
	// const EV_NotifySubjob = 5310;
	// const EV_CreatedSubjob = 5311;
	// const EV_ChangedSubjob = 5312;
	// 길드그랜드마스터한테가서
	// 일회성퀘스트234 1
	// 일회성퀘스트235 1
	// 서브추가

	//branch
	// F2P 서비스 활력 개선 - gorillazin
	RegisterEvent(EV_VitalityEffectInfo);	
	//
	//end of branch
	
	//branch120703
	RegisterEvent(EV_ToggleDetailStatusWnd);

	RegisterEvent(EV_AdenaInvenCount);
	RegisterEvent(EV_SetMaxCount);

}

function OnLoad()
{
	SetClosingOnESC();
	
	InitializeCOD();

	Me.EnableWindow();

	// 클래스변경버튼비활성화
	//initClassChangeButton(false);
	MaxVitality = GetMaxVitality();//ldw
	nCanUseAP = 0;
	texExp.SetDecimalPlace(4);
}

/**
 * 클래스변경버튼비활성화
 **/ 
function InitializeCOD()
{
	isDualClass = false;

	Me = GetWindowHandle("DetailStatusWndClassic");
	ClassBgMain_Big = GetTextureHandle(m_WindowName $ ".ClassBgMain_Big");
	ClassMarkBig = GetTextureHandle(m_WindowName $ ".ClassMarkBig");
	// 클래스변경깜빡이텍스쳐
	//ClassChangeLightBig    = GetAnimTextureHandle(m_WindowName $ ".ClassChangeLightBig");
	//ClassChangeLightSmall1 = GetAnimTextureHandle(m_WindowName $ ".ClassChangeLightSmall1");
	//ClassChangeLightSmall2 = GetAnimTextureHandle(m_WindowName $ ".ClassChangeLightSmall2");
	//ClassChangeLightSmall3 = GetAnimTextureHandle(m_WindowName $ ".ClassChangeLightSmall3");

	// 클래스변경배경텍스쳐
	//ClassBgMain_Big    = GetTextureHandle(m_WindowName $ ".ClassBgMain_Big");
	//ClassBgMain_Small1 = GetTextureHandle(m_WindowName $ ".ClassBgMain_Small1");
	//ClassBgMain_Small2 = GetTextureHandle(m_WindowName $ ".ClassBgMain_Small2");
	//ClassBgMain_Small3 = GetTextureHandle(m_WindowName $ ".ClassBgMain_Small3");

	// 클래스변경버튼	
	//ClassFrameBtn1 = GetButtonHandle(m_WindowName $ ".ClassFrameBtn1");
	//ClassFrameBtn2 = GetButtonHandle(m_WindowName $ ".ClassFrameBtn2");
	//ClassFrameBtn3 = GetButtonHandle(m_WindowName $ ".ClassFrameBtn3");

	// 클래스변경마크
	//ClassMarkSmall1 = GetTextureHandle(m_WindowName $ ".ClassMarkSmall1");
	//ClassMarkSmall2 = GetTextureHandle(m_WindowName $ ".ClassMarkSmall2");
	//ClassMarkSmall3 = GetTextureHandle(m_WindowName $ ".ClassMarkSmall3");

	txtClassName = GetTextBoxHandle(m_WindowName $ ".txtClassName");
	txtSP = GetTextBoxHandle(m_WindowName $ ".txtSP");
	txtName1 = GetTextBoxHandle(m_WindowName $ ".txtName1");
	txtName2 = GetTextBoxHandle(m_WindowName $ ".txtName2");
	txtHeadPledge = GetTextBoxHandle(m_WindowName $ ".txtHeadPledge");
	txtPledge = GetTextBoxHandle(m_WindowName $ ".txtPledge");
	txtLvHead = GetTextBoxHandle(m_WindowName $ ".txtLvHead");
	txtLvName = GetTextBoxHandle(m_WindowName $ ".txtLvName");
	txtHeadRank = GetTextBoxHandle(m_WindowName $ ".txtHeadRank");
	txtRank = GetTextBoxHandle(m_WindowName $ ".txtRank");
	texHP = GetStatusBarHandle(m_WindowName $ ".texHP");
	texMP = GetStatusBarHandle(m_WindowName $ ".texMP");
	texExp = GetStatusBarHandle(m_WindowName $ ".texExp");
	texCP = GetStatusBarHandle(m_WindowName $ ".texCP");
	txtPhysicalAttack = GetTextBoxHandle(m_WindowName $ ".txtPhysicalAttack");
	txtPhysicalDefense = GetTextBoxHandle(m_WindowName $ ".txtPhysicalDefense");
	txtHitRate = GetTextBoxHandle(m_WindowName $ ".txtHitRate");
	txtCriticalRate = GetTextBoxHandle(m_WindowName $ ".txtCriticalRate");
	txtPhysicalAttackSpeed = GetTextBoxHandle(m_WindowName $ ".txtPhysicalAttackSpeed");
	txtMagicalAttack = GetTextBoxHandle(m_WindowName $ ".txtMagicalAttack");
	txtMagicDefense = GetTextBoxHandle(m_WindowName $ ".txtMagicDefense");
	txtPhysicalAvoid = GetTextBoxHandle(m_WindowName $ ".txtPhysicalAvoid");
	txtGmMoving = GetTextBoxHandle(m_WindowName $ ".txtGmMoving");
	txtMovingSpeed = GetTextBoxHandle(m_WindowName $ ".txtMovingSpeed");
	txtMagicCastingSpeed = GetTextBoxHandle(m_WindowName $ ".txtMagicCastingSpeed");
	txtHeadMovingSpeed = GetTextBoxHandle(m_WindowName $ ".txtHeadMovingSpeed");
	txtHeadMagicCastingSpeed = GetTextBoxHandle(m_WindowName $ ".txtHeadMagicCastingSpeed");

	txtCriminalRate = GetTextBoxHandle(m_WindowName $ ".txtCriminalRate");
	//txtPVP = GetTextBoxHandle(m_WindowName $ ".txtPVP");
	txtSociality_PVP = GetTextBoxHandle(m_WindowName $ ".txtSociality_PVP");
	txtSociality_PK = GetTextBoxHandle(m_WindowName $ ".txtSociality_PK");
	txtBonusVote = GetTextBoxHandle(m_WindowName $ ".txtRemainSulffrage");
	txtDisapprove = GetTextBoxHandle(m_WindowName $ ".txtDisapprove");
	txtRaidPoint = GetTextBoxHandle(m_WindowName $ ".txtRaidPoint");
	//texHero = GetTextureHandle(m_WindowName $ ".texHero");
	texPledgeCrest = GetTextureHandle(m_WindowName $ ".texPledgeCrest");
	VitalityTex = GetTextureHandle(m_WindowName $ ".LifeForceTex") ;

	//txtLUC = GetTextBoxHandle(m_WindowName $ ".txtLUC");
	//txtCHA = GetTextBoxHandle(m_WindowName $ ".txtCHA");

	//texVP = GetStatusBarHandle(m_WindowName $".texVP");//ldw //branch121212

	SpExtractOpenBtn = GetButtonHandle(m_WindowName $ ".SPExtract_Btn");

	APActive = GetAnimTextureHandle(m_WindowName $".APActive");

	//------------------------------------------------------------------------------------------------------------------------------
	// 속성 시스템
	//------------------------------------------------------------------------------------------------------------------------------
	FightInfo_BTN = GetButtonHandle(m_WindowName $ ".FightInfo_BTN");
	BtnElementalInfo = GetButtonHandle(m_WindowName $ ".btnElementalInfo");
	BtnElementalInfo.DisableWindow();
	txtFireDefence = GetTextBoxHandle(m_WindowName $ ".txtFireDefence");
	txtWaterDefence = GetTextBoxHandle(m_WindowName $ ".txtWaterDefence");
	txtWindDefence = GetTextBoxHandle(m_WindowName $ ".txtWindDefence");
	txtEarthDefence = GetTextBoxHandle(m_WindowName $ ".txtEarthDefence");
	txtFireAttack = GetTextBoxHandle(m_WindowName $ ".txtFireAttack");
	txtWaterAttack = GetTextBoxHandle(m_WindowName $ ".txtWaterAttack");
	txtWindAttack = GetTextBoxHandle(m_WindowName $ ".txtWindAttack");
	txtEarthAttack = GetTextBoxHandle(m_WindowName $ ".txtEarthAttack");

	Element_Lock1 = GetTextureHandle(m_WindowName $ ".Element_Lock1");
	Element_Lock2 = GetTextureHandle(m_WindowName $ ".Element_Lock2");
	Element_Lock3 = GetTextureHandle(m_WindowName $ ".Element_Lock3");
	Element_Lock4 = GetTextureHandle(m_WindowName $ ".Element_Lock4");

	Element_Lock1.SetTooltipCustomType(MakeTooltipSimpleText(GetSystemMessage(5169)));
	Element_Lock2.SetTooltipCustomType(MakeTooltipSimpleText(GetSystemMessage(5169)));
	Element_Lock3.SetTooltipCustomType(MakeTooltipSimpleText(GetSystemMessage(5169)));
	Element_Lock4.SetTooltipCustomType(MakeTooltipSimpleText(GetSystemMessage(5169)));
	ElixirPoint_txt = GetTextBoxHandle(m_WindowName $ ".Statsinfo_Elixir_Win.ElixirPoint_txt");
	//-----------------------------------------------------------------------------------------------------------------------------
	//AbilityOpen.SetAnchor("", EAnchorPointType.ANCHORPOINT_Top, EAnchorPointType.ANCHORPOINT_CenterCenter, 0 , 0);
	//------------------------------------------------------------------------------------------------------------------------------

	UsePoint_Apply_BTN = GetButtonHandle(m_Statsinfo_UsePoint_Win $ ".UsePoint_Apply_BTN");
	UsePoint_Cancel_BTN = GetButtonHandle(m_Statsinfo_UsePoint_Win $ ".UsePoint_Cancel_BTN");
	UsePoint_Reset_BTN = GetButtonHandle(m_Statsinfo_UsePoint_Win $ ".UsePoint_Reset_BTN");
	Statsinfo_UsePoint_text = GetTextBoxHandle(m_Statsinfo_UsePoint_Win $ ".Statsinfo_UsePoint_text");
	StatConfirmResetWnd = GetWindowHandle(m_WindowName $ ".ConfirmWnd.ResetWnd");
	StatConfirmApplyWnd = GetWindowHandle(m_WindowName $ ".ConfirmWnd.ApplyWnd");
	ConfirmWnd = GetWindowHandle(m_WindowName $ ".ConfirmWnd");
	StatConfirmResetWnd.HideWindow();
	StatConfirmApplyWnd.HideWindow();
	ConfirmWnd.HideWindow();
	ResetCharge_ListCtrl = GetRichListCtrlHandle(m_WindowName $ ".ConfirmWnd.ResetWnd.ResetCharge_ListCtrl");
	NumPoint_text = GetTextBoxHandle(m_WindowName $ ".ConfirmWnd.ResetWnd.NumPoint_text");
	GetTextBoxHandle(m_WindowName $ ".ConfirmWnd.ResetWnd.ResetPoint_text").SetText(GetSystemString(13118) $ "/" $ GetSystemString(3155));
	Reset_Btn = GetButtonHandle(m_WindowName $ ".ConfirmWnd.ResetWnd.Reset_BTN");
	ElementalSpiritWndScript = ElementalSpiritWnd(GetScript("ElementalSpiritWnd"));
	if(! IsAdenServer())
	{
		FightInfo_BTN.HideWindow();
	}
}

//branch
// F2P 서비스 활력 개선 - gorillazin
/*
function UpdateVp(int Vitality)//ldw 수정
{
	if(Vitality < 2205 && Vitality > 0){ // 최대 140000 일 경우 1806 부터 스탯창에 눈금이 없어 vp가 없어 보인다는 수정 내용을 위한 예외 처리 , statusbarWnd, lobbyMenuWnd 에도 같이 처리 되었음 ldw 2011.02.23
		texVP.SetPoint(2205, MaxVitality);		

	} else {
		texVP.SetPoint(Vitality, MaxVitality);		
	}	
}
*/
// 이 function의 필요 없는 부분 주석 처리
//end of branch


function OnEnterState(name a_CurrentStateName)
{
	HandleUpdateUserInfo();
}

function OnShow()
{
	if(IsUseRenewalSkillWnd())
	{
		SpExtractOpenBtn.ShowWindow();		
	}
	else
	{
		SpExtractOpenBtn.HideWindow();
	}
	SetElixirInfo();
	HandleUpdateUserInfo();
	//RequestElementalSpiritInfo();
	InitStatusInfo();
}

function OnEvent(int Event_ID, string param)
{
	if(Event_ID == EV_UpdateUserInfo)
	{
		HandleUpdateUserInfo();		
		
	}
	else if(Event_ID == EV_UpdateHennaInfo)
	{
		HandleUpdateHennaInfo(param);
	}
	else if(Event_ID == EV_UpdateMyHP)
	{
		HandleUpdateStatusGauge(param, 0);
	}
	else if(Event_ID == EV_UpdateMyMaxHP)
	{
		HandleUpdateStatusGauge(param, 0);
	}
	else if(Event_ID == EV_UpdateMyMP)
	{
		HandleUpdateStatusGauge(param,1);
	}
	else if(Event_ID == EV_UpdateMyMaxMP)
	{
		HandleUpdateStatusGauge(param,1);
	}
	else if(Event_ID == EV_UpdateMyCP)
	{
		HandleUpdateStatusGauge(param,2);
	}
	else if(Event_ID == EV_UpdateMyMaxCP)
	{
		HandleUpdateStatusGauge(param,2);
	}
	else if(Event_ID == EV_ToggleDetailStatusWnd)
	{		
		HandleToggle();
	}
	//classic//
	/*
	else if(Event_ID == EV_VitalityPointInfo)	// 활력정보업데이트
	{
		HandleVitalityPointInfo(param);
	}
*/
	// 처음 직업 정보를 받음
	else if(Event_ID == EV_NotifySubjob)
	{
		//Debug("-------------------------------");
		//Debug("EV_NotifySubjob:" @ param);
		// updateSubjobLastEvent = Event_ID;
		updateSubjobInfo(param, Event_ID);	
	}
	// 아레나의 메인 잡 아이콘 변경을 위해 EV_CreatedSubjob 이벤트 전체 주석 해제 - 관련 TT 75064
	else if(Event_ID == EV_CreatedSubjob)
	{	    
		// 메인 잡 아이콘 변경을 위해 아래 함수만 남겨 둠
		updateSubjobInfo(param, Event_ID);
		
		/*
		 * Show 이벤트는 동작 하지 않도록 함.
		if(Me.IsShowWindow() == false)
		{
			Me.ShowWindow();
			Me.SetFocus();
		}
		ExecuteEvent(EV_NPCDialogWndHide);
		*/
	}
	// 직업 정보가 바뀔 때 받음
	else if(Event_ID == EV_ChangedSubjob)
	{
		// updateSubjobLastEvent = Event_ID;
//		Debug("EV_ChangedSubjob" @ param);
		updateSubjobInfo(param, Event_ID);
		ExecuteEvent(EV_NPCDialogWndHide);
	}

	else if	(Event_ID == EV_DialogOK)
	{
		HandleDialogOK();
	}
	else if	(Event_ID == EV_DialogCancel)
	{
		if(DialogIsMine())
		{
			Me.EnableWindow();
		}
	}
	//~ else if(Event_ID == EV_ShowWindow)
	//~ {
		//~ if(param == DetailStatusWnd)
		//~ {
			//~ ToggleOpenCharInfoWnd();
		//~ }
	//~ }

	//branch
	// F2P 서비스 활력 개선 - gorillazin
	else if(Event_ID == EV_VitalityEffectInfo)
	{
		HandleVitalityEffectInfo(param);
	}
	else if(Event_ID == EV_AdenaInvenCount || Event_ID == EV_SetMaxCount)
	{
		if(StatConfirmResetWnd.IsShowWindow())
		{
			HandleItemUpdate();
		}
	}
	else if(Event_ID == EV_Restart)
	{
		_LockElement();
	}

	//// 속성 정령 정보
	//else if(Event_ID == EV_ElementalSpiritInfo)
	//{
	//	setElementalSpiritInfo(param);
	//}

	//
	//end of branch
}

function _LockElement()
{
	Element_Lock1.ShowWindow();
	Element_Lock2.ShowWindow();
	Element_Lock3.ShowWindow();
	Element_Lock4.ShowWindow();
	BtnElementalInfo.DisableWindow();	
}

function _UnLockElement()
{
	Element_Lock1.HideWindow();
	Element_Lock2.HideWindow();
	Element_Lock3.HideWindow();
	Element_Lock4.HideWindow();
	BtnElementalInfo.EnableWindow();	
}


/**
 *  최초들어오는서브잡, 듀얼등의정보를받아기록한다.
 **/
//classic 에서는 메인 job만 있지만, 언제 생길지 모르니 놔둠.//
function updateSubjobInfo(string param, int Event_ID)
{	
	local int count, i;

	local int currentSubjobClassID;
	
	local UserInfo myUserInfo;

	local bool bFlag;

	local SubjobInfo tempSubjobInfo;

	// 종족
	//local int  race;

	isDualClass = false;

	//hideAlchemyWindow("AlchemyItemConversionWnd");			
	//hideAlchemyWindow("AlchemyMixCubeWnd");

	// saveUpdateSubjobInfoParam = param;

	//GetMyUserInfo(myUserInfo);
	GetPlayerInfo(myUserInfo);


//	debug("현재 클래스 : " @ GetClassType(myUserInfo.nSubClass));
//	debug("현재전직상태: " @ GetClassTransferDegree(myUserInfo.nSubClass));

	// 해당직업수를리턴받는다.
	ParseInt(param, "Count"  , count);
	
	// 현재중인클래스아이디
	ParseInt(param, "currentSubjobClassID", currentSubjobClassID);

//	debug("현재전직상태->: " @ GetClassTransferDegree(currentSubjobClassID));
	//Debug("현재classID ->: " @ currentSubjobClassID);
	// 삭제
	if(subjobInfoArray.Length > 0)
	{
		subjobInfoArray.Remove(0, subjobInfoArray.Length);
	}

	bFlag = false;
		

	
	ParseInt(param, "Race", race);

//	debug("종족 race:" @ Race);
	//debug("종족이름 :" @ getRaceString(Race));

	// 서브잡리스트를받는다.(0메인, 서브듀얼개1,2,3(최대))
	for(i = 0; i < count; i++)
	{
		subjobInfoArray.Insert(subjobInfoArray.Length, 1);
		
		ParseInt(param, "SubjobClassID_" $ i, subjobInfoArray[i].ClassID);
		ParseInt(param, "SubjobID_"      $ i, subjobInfoArray[i].Id);
		ParseInt(param, "SubjobLevel_"   $ i, subjobInfoArray[i].Level);
		ParseInt(param, "SubjobType_"    $ i, subjobInfoArray[i].Type);

		// Debug("subjobInfoArray[i].ClassID" @ subjobInfoArray[i].ClassID);
		// Debug("subjobInfoArray[i].Id" @ subjobInfoArray[i].Id);
		// Debug("subjobInfoArray[i].Level" @ subjobInfoArray[i].Level);
		// Debug("subjobInfoArray[i].Type" @ subjobInfoArray[i].Type);

		// 듀얼 클래스가 하나라도 있다면..
		if(subjobInfoArray[i].Type == 1) 
		{ 
			isDualClass = true; 
		//	Debug("듀얼이 있다! ");
		}
	}
	for(i = 0; i < count; i++)
	{
		if(currentSubjobClassID == subjobInfoArray[i].ClassID)
		{
//			Debug("같다 subjobInfoArray[i].ClassID" @ subjobInfoArray[i].ClassID);
			//			currentSubjobClassNum = i;

			// 서로교체
			tempSubjobInfo = subjobInfoArray[i];
			subjobInfoArray[i] = subjobInfoArray[0];
			subjobInfoArray[0] = tempSubjobInfo;

			currentSubjobClassNum = 0;
			break;
		}
	}

//	debug("subjobInfoArray ::::: " @ subjobInfoArray.Length);

	// 서브 클래스가 있다면.. 버튼들이 보이도록 초기화
	//if(count > 0) initClassChangeButton(true);
	//else initClassChangeButton(false);

	// 직업정보업데이트
	//  1,2,3 까지들어올수있음. 현재캐릭터1 + 서버(듀얼) 3개= 총4개
	for(i = 1; i < count; i++)
	{
		if(i < count)
		{
			// Debug("-------------" @ i);
//			Debug("subjobInfoArray[i].ClassID" @ subjobInfoArray[i].ClassID);
			//---- 3종버튼업데이트-----
			// Debug("버튼배치작은거" @ subjobInfoArray[i].ClassID);

			// 이전의상태와같은것이였다면.. 깜빡이는이팩트
			if(beforeSubjobInfo.ClassID == subjobInfoArray[i].ClassID)
				 bFlag = true;
			else
				 bFlag = false;

			// Debug("서브, 메인검사 subjobInfoArray[i].Type : " @subjobInfoArray[i].Type);
			// debug("GetClassTransferDegree(myUserInfo.nSubClass)"@ GetClassTransferDegree(myUserInfo.nSubClass));
			// debug("종족 race:" @ myUserInfo.Race);
			// debug("종족이름 :" @ getRaceString(myUserInfo.Race));

			/* XML 을 보니 안쓰고 있어서 주석처리
			// 메인:0, 듀얼:1 서브:2
			// 서브: 청색
			if(subjobInfoArray[i].Type == 2)
			{
				if(GetClassTransferDegree(subjobInfoArray[i].ClassID) > 1)
					setclasstexture(i, "l2ui_ct1.playerstatuswnd_ClassBgSub_Small", "l2ui_ct1.PlayerStatusWnd_ClassMark_" $ subjobInfoArray[i].ClassID $ "_Small", bFlag);
				else 
					setclasstexture(i, "l2ui_ct1.playerstatuswnd_ClassBgSub_Small", "l2ui_ct1.PlayerStatusWnd_ClassMark_" $ getRaceString(race) $ "_Small", bFlag);
			}			
			// 듀얼 : 파랑
			else if(subjobInfoArray[i].Type == 1)
			{	
				if(GetClassTransferDegree(subjobInfoArray[i].ClassID) > 1)
					setClassTexture(i, "l2ui_ct1.PlayerStatusWnd_ClassBgDual_Small", "l2ui_ct1.PlayerStatusWnd_ClassMark_" $ subjobInfoArray[i].ClassID $ "_Small", bFlag);
				else
					setClassTexture(i, "l2ui_ct1.PlayerStatusWnd_ClassBgDual_Small", "l2ui_ct1.PlayerStatusWnd_ClassMark_" $ getRaceString(race) $ "_Small", bFlag);
			}
			//메인 :빨강
			else if(subjobInfoArray[i].Type == 0)
			{
				if(GetClassTransferDegree(subjobInfoArray[i].ClassID) > 1)
					setClassTexture(i, "l2ui_ct1.PlayerStatusWnd_ClassBgMain_Small", "l2ui_ct1.PlayerStatusWnd_ClassMark_" $ subjobInfoArray[i].ClassID $ "_Small", bFlag);
				else
					setClassTexture(i, "l2ui_ct1.PlayerStatusWnd_ClassBgMain_Small", "l2ui_ct1.PlayerStatusWnd_ClassMark_" $ getRaceString(race) $ "_Small", bFlag);
			}

			GetButtonHandle(m_WindowName $ ".ClassFrameBtn" $ i).EnableWindow();
			GetButtonHandle(m_WindowName $ ".ClassFrameBtn" $ i).ShowWindow();

			// Debug("버튼 " @ m_WindowName $ ".ClassFrameBtn" $ i);
			// GetButtonHandle(m_WindowName $ ".ClassFrameBtn" $ i + 1).ShowWindow();

			GetButtonHandle(m_WindowName $ ".ClassFrameBtn" $ i).SetTexture("L2UI_ct1.PlayerStatusWnd_ClassFrameBtn",
																			 "L2UI_ct1.PlayerStatusWnd_ClassFrameBtn_down",
																			 "L2UI_ct1.PlayerStatusWnd_ClassFrameBtn_over");

			GetButtonHandle(m_WindowName $ ".ClassFrameBtn" $ i).SetTooltipCustomType(subjobButtonToolTips(i));
			GetTextureHandle(m_WindowName $ ".ClassSlotBlank" $ i).HideWindow();
			*/
		}
	}
	
	// ---- 큰클래스이미지업데이트-----
	// 2차전직이상이라면..

	// 3차 전직 이상한 캐릭터가 있고 , 서브 잡 1개 이상 있다면, 지정한 클래스 아이콘을 적용
	//if(GetClassTransferDegree(myUserInfo.nSubClass) > 1 && count > 1)

	// debug("myUserInfo.nSubClass >: " @ myUserInfo.nSubClass);
	// debug("GetClassTransferDegree(myUserInfo.nSubClass) >: " @ GetClassTransferDegree(myUserInfo.nSubClass));


	// 메인:0, 듀얼:1 서브:2
	// 4차 전직 된 캐릭터라면..
	if(GetClassTransferDegree(subjobInfoArray[currentSubjobClassNum].ClassID) > 0)
	{
		// 교체된상태라면이팩트출력
		if(EV_ChangedSubjob == Event_ID)
			bFlag = true;
		else
			bFlag = false;

		// debug("서브애들:" @ subjobInfoArray[currentSubjobClassNum].Type);
		// 서브면청색
		if(subjobInfoArray[currentSubjobClassNum].Type == 2)
		{
			setClassTexture(0, "l2ui_ct1.PlayerStatusWnd_ClassBgSub_Big", 
							   "l2ui_ct1.PlayerStatusWnd_ClassMark_" $ subjobInfoArray[currentSubjobClassNum].ClassID $ "_Big", bFlag);
		}
		// 듀얼,메인은빨강0: 메인, 1 듀얼
		else if(subjobInfoArray[currentSubjobClassNum].Type == 1)
		{			
			setClassTexture(0, "l2ui_ct1.PlayerStatusWnd_ClassBgDual_Big", 
							   "l2ui_ct1.PlayerStatusWnd_ClassMark_" $ subjobInfoArray[currentSubjobClassNum].ClassID $ "_Big", bFlag);
		}
		else if(subjobInfoArray[currentSubjobClassNum].Type == 0)
		{
			setClassTexture(0, "l2ui_ct1.PlayerStatusWnd_ClassBgMain_Big", 
							   "l2ui_ct1.PlayerStatusWnd_ClassMark_" $ subjobInfoArray[currentSubjobClassNum].ClassID $ "_Big", bFlag);
		}
	}
	else
	{
		// 서브면청색
		if(subjobInfoArray[currentSubjobClassNum].Type == 2)
		{
			setClassTexture(0, "l2ui_ct1.PlayerStatusWnd_ClassBgSub_Big", 
							   "l2ui_ct1.PlayerStatusWnd_ClassMark_" $ getRaceString(race) $ "_Big", false);
		}
		// 듀얼,메인은빨강0: 메인, 1 듀얼
		else if(subjobInfoArray[currentSubjobClassNum].Type == 1)
		{			
			// 서브잡을 안한.. 1차 전직도 안한 유저의 아이콘
			//initClassChangeButton(false);
			// 각종족별심볼이미지
			setClassTexture(0, "l2ui_ct1.PlayerStatusWnd_ClassBgDual_Big", 
							   "l2ui_ct1.PlayerStatusWnd_ClassMark_" $ getRaceString(race) $ "_Big", false);
		}
		else if(subjobInfoArray[currentSubjobClassNum].Type == 0)
		{
			setClassTexture(0, "l2ui_ct1.PlayerStatusWnd_ClassBgMain_Big", 
							   "l2ui_ct1.PlayerStatusWnd_ClassMark_" $ getRaceString(race) $ "_Big", false);
		}

		// UserInfo(
		// 수정해야함race
		// Debug("종족별---::" @ myUserInfo.race);
		
		//GetRaceTicketString(int Blessed);
	}

	beforeSubjobInfo = subjobInfoArray[currentSubjobClassNum];

	// Type : 0 메인, 1 듀얼. 2 서브
	// debug("myUserInfo.Class : " @ GetClassRoleName(classID)) ;
	
		//native final function string GetClassStr(int ClassID); 
	// CurrentSubjobClassID=3 Count=3 SubjobID_1=1 SubjobClassID_1=117 SubjobLevel_1=55 SubjobType_1=0 SubjobID_2=1 SubjobClassID_2=73 SubjobLevel_2=55 SubjobType_2=1 SubjobID_3=1 SubjobClassID_3=131 SubjobLevel_3=55 SubjobType_3=2
	// CurrentSubjobClassID=3 Count=3 SubjobID_1=1 SubjobClassID_1=117 SubjobLevel_1=55 SubjobType_1=1 SubjobID_2=1 SubjobClassID_2=73 SubjobLevel_2=55 SubjobType_2=1 SubjobID_3=1 SubjobClassID_3=131 SubjobLevel_3=55 SubjobType_3=1 
	// CurrentSubjobClassID=3 Count=1 SubjobID_1=1 SubjobClassID_1=134 SubjobLevel_1=55 SubjobType_1=1
}


/** 다이얼로그박스OK 클릭시*/
function HandleDialogOK()
{
	local int dialogValue;
	local ItemInfo infItem;

	
	if(DialogIsMine())
	{
		if(DialogGetID() == DIALOG_DetailStatusWnd)
		{					
			
			dialogValue = DialogGetReservedInt();
			
			switch(dialogValue)
			{
				// subjobInfoArray[dialogValue].Type  // 0메인, 1듀얼, 2서브
				case 0 : 
				case 1 : 
				case 2 : 
				case 3 :
						ExecuteEvent(EV_NPCDialogWndHide);
						// Debug("subjobInfoArray[dialogValue].Type  "  @ subjobInfoArray[dialogValue].Type);
						// 메인, 듀얼이라면..
						if(subjobInfoArray[dialogValue].Type == 0)
						{
							// 스킬 번호임 
							infItem.ID.ClassID = 1566;

							//infItem.ID.ServerID = 1566;
							// 메인클래스로변경
							// Debug("메인 스킬사용" @ infItem.ID.ClassID);
							UseSkill(infItem.ID, int(EShortCutItemType.SCIT_SKILL));
							// ExecuteCommand("//use_skill 1566 1");
						}
						else
						{
							// 듀얼 이라면.. 처리
							if(subjobInfoArray[dialogValue].Type == 1) 
							{
								// 현재 없음
								// empty
							}

							// 1567, 1568, 1569 순서되로.. 서브슬롯1,2,3 변경
							infItem.ID.ClassID = 1567 +(dialogValue - 1);
							//infItem.ID.ServerID = 1568 +(dialogValue - 1);

							// Debug("스킬사용" @ infItem.ID.ClassID);
							UseSkill(infItem.ID, int(EShortCutItemType.SCIT_SKILL));
							// ExecuteCommand("//use_skill " $ String(infItem.ID.ClassID) $ " 1");
						}
			}

			// 변경스킬사용
			Me.EnableWindow();
		}
	}
}

/**
 * 다이얼로그박스(서브클래스로변신할지물어보는다이얼로그)
 * 0..1..2 
 **/
function askDialogBox(int currentClickSubjobNum)
{
	local WindowHandle m_dialogWnd;	
	m_dialogWnd = GetWindowHandle("DialogBox");
	if(!m_dialogWnd.IsShowWindow())
	{
		// 현재클래스와클릭한서브클래스가같지않다면.. 변신을물어본다.
		if(subjobInfoArray[0].ClassID != subjobInfoArray[currentClickSubjobNum].ClassID)
		{
			DialogSetID(DIALOG_DetailStatusWnd);

			DialogSetReservedInt(currentClickSubjobNum);

			// 메인클래스, 둠브링거, 서브소울테이커, 로변경하시겠습니까?   이런식
			Me.DisableWindow();
			DialogShow(DialogModalType_Modalless, DialogType_Warning, 
						MakeFullSystemMsg(GetSystemMessage(3280), 
										   "<" $ GetClassType(subjobInfoArray[0].ClassID) $ "> " $ getSubjobTypeStr(subjobInfoArray[0].Type) $ "", 
										   "<" $ GetClassType(subjobInfoArray[currentClickSubjobNum].ClassID) $ "> "$ getSubjobTypeStr(subjobInfoArray[currentClickSubjobNum].Type) $ ""),
										   string(Self));
		}
	}
}


/***
 *  현재서브잡스트링을리턴받는다.
 **/
function string getSubjobTypeStr(int nType)
{	
	local string tempStr;
	
	// 0 메인, 1 듀얼(현재는메인으로처리-듀얼이라는용어는아직사용안함) , 2 서브
	switch(nType)
	{
		case 0 : tempStr = GetSystemString(2340); break; // 메인클래스
		case 1 : tempStr = GetSystemString(2737); break; // 듀얼클래스
		case 2 : tempStr = GetSystemString(2339); break; // 서브클래스
	}

	return tempStr;
}

/**
 * OnClickButton
 **/
function OnClickButton(string strID)
{
	// debug("strID : " $ strID);

	switch(strID)
	{
		case "btnElementalInfo" :
			 
			 if(class'UIAPI_WINDOW'.static.IsShowWindow("elementalSpiritWnd"))
		 		 class'UIAPI_WINDOW'.static.HideWindow("elementalSpiritWnd");
			 else
			 {
				ElementalSpiritWnd(GetScript("ElementalSpiritWnd"))._API_RequestElementalSpiritInfo(true);
			 }
			 break;
		case "StatBonusInfo_BTN":
			if(Class'UIAPI_WINDOW'.static.IsShowWindow("StatBonusWndClassic"))
			{
				Class'UIAPI_WINDOW'.static.HideWindow("StatBonusWndClassic");
			}
			else
			{
				Class'UIAPI_WINDOW'.static.ShowWindow("StatBonusWndClassic");
				Class'UIAPI_WINDOW'.static.SetFocus("StatBonusWndClassic");
			}
			break;
		case "UsePoint_Apply_BTN":
			StatConfirmApplyWnd.ShowWindow();
			ConfirmWnd.ShowWindow();
			ConfirmWnd.SetFocus();
			break;
		case "UsePoint_Reset_BTN":
			HandleShowResetWindow();
			break;
		case "UsePoint_Cancel_BTN":
			HandleOnCliCKUsePointCancel();
			break;
		case "Cancel_BTN":
			StatConfirmApplyWnd.HideWindow();
			StatConfirmResetWnd.HideWindow();
			ConfirmWnd.HideWindow();
			break;
		case "Apply_BTN":
			API_C_EX_SET_STATUS_BONUS();
			HandleOnCliCKUsePointCancel();
			StatConfirmApplyWnd.HideWindow();
			ConfirmWnd.HideWindow();
			break;
		case "Reset_BTN":
			API_C_EX_RESET_STATUS_BONUS();
			HandleOnCliCKUsePointCancel();
			StatConfirmResetWnd.HideWindow();
			ConfirmWnd.HideWindow();
			break;
		case "FightInfo_BTN":
			if(class'UIAPI_WINDOW'.static.IsShowWindow("InfoFightWndClassic"))
			{
				class'UIAPI_WINDOW'.static.HideWindow("InfoFightWndClassic");				
			}
			else
			{
				class'UIAPI_WINDOW'.static.ShowWindow("InfoFightWndClassic");
				class'UIAPI_WINDOW'.static.SetFocus("InfoFightWndClassic");
			}
			break;
		case "SPExtract_Btn":
			toggleWindow("SkillSpExtractWnd", true, true);
			break;
/*
		case "ClassFrameBtn1" : if(GetButtonHandle(m_WindowName $ ".ClassFrameBtn1").IsEnableWindow() && subjobInfoArray.Length > 1) 
								{ ExecuteEvent(EV_NPCDialogWndHide); effectAniTexture(1); askDialogBox(1); } break;
		case "ClassFrameBtn2" : if(GetButtonHandle(m_WindowName $ ".ClassFrameBtn2").IsEnableWindow() && subjobInfoArray.Length > 2) 
								{ ExecuteEvent(EV_NPCDialogWndHide); effectAniTexture(2); askDialogBox(2); } break;
		case "ClassFrameBtn3" : if(GetButtonHandle(m_WindowName $ ".ClassFrameBtn3").IsEnableWindow() && subjobInfoArray.Length > 3) 
								{ ExecuteEvent(EV_NPCDialogWndHide); effectAniTexture(3); askDialogBox(3); } break;
*/
	}
}

function OnClickButtonWithHandle(ButtonHandle a_ButtonHandle)
{
	switch(a_ButtonHandle.GetWindowName())
	{
		case "Statsinfo_PointPlusNum_BTN":
			HandleOnClickPlusBtn(int(Right(a_ButtonHandle.GetParentWindowName(),1)));
			break;
		case "Statsinfo_PointMinusNum_BTN":
			HandleOnClickMinusBtn(int(Right(a_ButtonHandle.GetParentWindowName(),1)));
			break;
	}
}


/**
 *  버튼애니이팩트(1 ~ 3 번버튼효과) 
 **/

function effectAniTexture(int targetType)
{
	GetAnimTextureHandle(m_WindowName $ ".ClassChangeLightSmall" $ targetType).SetTexture("l2ui_ct1.PlayerStatusWnd_ClassChangeLightSmall_00");
	GetAnimTextureHandle(m_WindowName $ ".ClassChangeLightSmall" $ targetType).ShowWindow();
	GetAnimTextureHandle(m_WindowName $ ".ClassChangeLightSmall" $ targetType).SetLoopCount(1);
	GetAnimTextureHandle(m_WindowName $ ".ClassChangeLightSmall" $ targetType).Stop();
	GetAnimTextureHandle(m_WindowName $ ".ClassChangeLightSmall" $ targetType).Play();
}

/**
 * setClassTexture 
 * 
 * 클래스변경시, 텍스쳐교체, 종족별마크텍스쳐, 빤짝거리는효과보여줄것인지..
 **/

function setClassTexture(int targetType, string bgTexture, string markTextureStr, bool effectFlag)
{
	if(targetType == 0)
	{

		// 큰메인클래스(현재클래스)

		// 배경
		ClassBgMain_Big.SetTexture(bgTexture);
		// debug("bgTexture" @ bgTexture);

		// 마크변경
		//debug("markTextureStr : " @ markTextureStr);
		ClassMarkBig.SetTexture(markTextureStr);
		// ClassMarkBig.HideWindow();

		// 깜빡이는효과보여주기
		if(effectFlag == true)
		{
			GetAnimTextureHandle(m_WindowName $ ".ClassChangeLightBig").SetTexture("l2ui_ct1.PlayerStatusWnd_ClassChangeLightBig_00");
			GetAnimTextureHandle(m_WindowName $ ".ClassChangeLightBig").ShowWindow();
			GetAnimTextureHandle(m_WindowName $ ".ClassChangeLightBig").SetLoopCount(1);
			GetAnimTextureHandle(m_WindowName $ ".ClassChangeLightBig").Stop();
			GetAnimTextureHandle(m_WindowName $ ".ClassChangeLightBig").Play();
		}
	}
	
	/* XML 을 보니 안쓰고 있어서 주석처리
	else
	{
		// 배경
		GetTextureHandle(m_WindowName $ ".ClassBgMain_Small" $ targetType).SetTexture(bgTexture);
		
		// GetTextureHandle(m_WindowName $ ".ClassBgMain_Small" $ targetType).SetAlpha(255);
		// Debug("배경bgTexture " @ bgTexture);

		// 마크변경
		GetTextureHandle(m_WindowName $ ".ClassMarkSmall" $ targetType).SetTexture(markTextureStr);
		GetTextureHandle(m_WindowName $ ".ClassMarkSmall" $ targetType).ShowWindow();
		

		// 깜빡이는효과보여주기
		//GetTextureHandle(m_WindowName $ ".ClassChangeLightSmall" $ targetType).SetTexture("");		

		if(effectFlag == true)
		{			
			effectAniTexture(targetType);
		}
	}
	*/
}


function HandleToggle()
{
	if(!getInstanceUIData().getIsClassicServer()) return;
	if(m_hOwnerWnd.IsShowWindow())
	{
		m_hOwnerWnd.HideWindow();
	}
	else
	{
		m_hOwnerWnd.ShowWindow();
		m_hOwnerWnd.SetFocus();
	}
}

//게이지만업데이트
function HandleUpdateStatusGauge(string param, int Type)
{
	local int ServerID;
	
	if(m_hOwnerWnd.IsShowWindow())	// lpislhy
	{
		ParseInt(param, "ServerID", ServerID);
		if(m_UserID == ServerID)
			HandleUpdateUserGauge(Type);
	}
}

//플레이어의문양정보처리
function HandleUpdateHennaInfo(string param)
{
	ParseInt(param, "HennaID", m_HennaInfo.HennaID);
	ParseInt(param, "ClassID", m_HennaInfo.ClassID);
	ParseInt(param, "Num", m_HennaInfo.Num);
	ParseInt(param, "Fee", m_HennaInfo.Fee);
	ParseInt(param, "CanUse", m_HennaInfo.CanUse);
	ParseInt(param, "INTnow", m_HennaInfo.INTnow);
	ParseInt(param, "INTchange", m_HennaInfo.INTchange);
	ParseInt(param, "STRnow", m_HennaInfo.STRnow);
	ParseInt(param, "STRchange", m_HennaInfo.STRchange);
	ParseInt(param, "CONnow", m_HennaInfo.CONnow);
	ParseInt(param, "CONchange", m_HennaInfo.CONchange);
	ParseInt(param, "MENnow", m_HennaInfo.MENnow);
	ParseInt(param, "MENchange", m_HennaInfo.MENchange);
	ParseInt(param, "DEXnow", m_HennaInfo.DEXnow);
	ParseInt(param, "DEXchange", m_HennaInfo.DEXchange);
	ParseInt(param, "WITnow", m_HennaInfo.WITnow);
	ParseInt(param, "WITchange", m_HennaInfo.WITchange);

	//신규스탯 카리스마 럭키
	ParseInt(param, "LUCnow", m_HennaInfo.LUCnow);
	ParseInt(param, "LUCchange", m_HennaInfo.LUCchange);

	ParseInt(param, "CHAnow", m_HennaInfo.CHAnow);
	ParseInt(param, "CHAchange", m_HennaInfo.CHAchange);
}

function bool GetMyUserInfo(out UserInfo a_MyUserInfo)
{
	return GetPlayerInfo(a_MyUserInfo);
}

function String GetMovingSpeed(UserInfo a_UserInfo)
{
	local float MovingSpeed;
	local EMoveType	MoveType;
	local EEnvType	EnvType;

	// Moving Speed
	MoveType			= class'UIDATA_PLAYER'.static.GetPlayerMoveType();
	EnvType				= class'UIDATA_PLAYER'.static.GetPlayerEnvironment();

	// debug("MovingSpeed : STEP 1" $a_UserInfo.fNonAttackSpeedModifier);
	if(MoveType == MVT_FAST)
	{
		MovingSpeed = float(a_UserInfo.nGroundMaxSpeed) * a_UserInfo.fNonAttackSpeedModifier;
		// debug("MovingSpeed : STEP 2" $a_UserInfo.nGroundMaxSpeed);
		switch(EnvType)
		{
		case ET_UNDERWATER:
			MovingSpeed = float(a_UserInfo.nWaterMaxSpeed) * a_UserInfo.fNonAttackSpeedModifier;
			// debug("MovingSpeed : STEP 3"$a_UserInfo.nWaterMaxSpeed);
			break;
		case ET_AIR:
			MovingSpeed = float(a_UserInfo.nAirMaxSpeed) * a_UserInfo.fNonAttackSpeedModifier;
			// debug("MovingSpeed : STEP 4" $a_UserInfo.nAirMaxSpeed $"  " $a_UserInfo.fNonAttackSpeedModifier);
			break;
		}
	}
	else if(MoveType == MVT_SLOW)
	{
		MovingSpeed = float(a_UserInfo.nGroundMinSpeed) * a_UserInfo.fNonAttackSpeedModifier;
		// debug("MovingSpeed : STEP 5");
		switch(EnvType)
		{
		case ET_UNDERWATER:
			MovingSpeed = float(a_UserInfo.nWaterMinSpeed) * a_UserInfo.fNonAttackSpeedModifier;
			// debug("MovingSpeed : STEP 6" $a_UserInfo.nWaterMinSpeed);
			break;
		case ET_AIR:
			MovingSpeed = float(a_UserInfo.nAirMinSpeed) * a_UserInfo.fNonAttackSpeedModifier;
			// debug("MovingSpeed : STEP 7" $a_UserInfo.nAirMinSpeed);
			break;
		}
	}
	//debug("MovingSpeed : STEP 8 : " $ MovingSpeed);
	return String(appRound(MovingSpeed));
}

function float GetMyExpRate()
{
	return class'UIDATA_PLAYER'.static.GetPlayerEXPRate() * 100.0f;
}

//플레이어게이지정보처리
function HandleUpdateUserGauge(int Type)
{
	local int CurValue;
	local int MaxValue;
	local int Vitality;	
	local UserInfo info;

	
	if(GetMyUserInfo(info))
	{
		Vitality = info.nVitality;
		m_UserID = info.nID;
		
		switch(Type)
		{
		case 0:
			CurValue = info.nCurHP;
			MaxValue = info.nMaxHP;
			UpdateHPBar(CurValue, MaxValue);
		break;
		case 1:
			CurValue = info.nCurMP;
			MaxValue = info.nMaxMP;
			UpdateMPBar(CurValue, MaxValue);
		break;
		case 2:
			CurValue = info.nCurCP;
			MaxValue = info.nMaxCP;
			UpdateCPBar(CurValue, MaxValue);
		break;

//		UpdateVp(Vitality);
		}
	}
}

//플레이어정보처리
function HandleUpdateUserInfo()
{
	if(m_hOwnerWnd.IsShowWindow())	// lpislhy
		UpdateInterface();
}

function UpdateInterface()
{
	local Rect rectWnd;
	local int Width1;
	local int Height1;
	local int Width2;
	local int Height2;
	
	local string	Name;
	local string	NickName;
	local color	NameColor;
	local color	NickNameColor;
	local int		SubClassID;
	local string	ClassName;
	local string	UserRank;
	local int		HP;
	local int		MaxHP;
	local int		MP;
	local int		MaxMP;
	local int		CP;
	local int		MaxCP;
	local INT64		SP;
	local int		Level;
	//local float		fExpRate;
	
	local int		PledgeID;
	local string	PledgeName;
	local texture	PledgeCrestTexture;
	local bool		bPledgeCrestTexture;
	local color	PledgeNameColor;

	local int PhysicalAttack;
	local int PhysicalDefense;
	local int HitRate;
	local int CriticalRate;
	local int PhysicalAttackSpeed;
	local int MagicalAttack;
	local int MagicDefense;
	local int PhysicalAvoid;
	local String	MovingSpeed;
	local int MagicCastingSpeed;
	
	local int CriminalRate;
	local int iNameColorRate;
	local string strCriminalRate;
	local int DualCount;
	local int PKCount;
	//local int		PvPPoint;
	
	local int VoteCount;
	local int BonusCount;
	local int NegativeVoteCount;
	local int Notoriety;

	local int RaidPoint;

	local int nMagicAvoid, nMagicHitRate, nMagicCriticalRate;

	
	//변신관련데이터
	//local int nTransformID;
	local int activatedElixirPoint;
	
	local UserInfo	info;
	
	//활력
	//local int Vitality;
	
	//초기화
	texPledgeCrest.SetTexture("");
	rectWnd = m_hOwnerWnd.GetRect();
	if(GetMyUserInfo(info))
	{
		StatesByUserInfoUpdate(Info);
		HandleOnChangeState();

		// ClassChangeLightBig.SetTexture("");
		// ClassChangeLightSmall1.SetTexture("");
		// ClassChangeLightSmall2.SetTexture("");
		//ClassChangeLightSmall3.SetTexture(""); 
		// Debug("info race"  @ info.race);

		m_UserID = info.nID;
		Name = info.Name;
		NickName = info.strNickName;
		SubClassID = info.nSubClass;
		ClassName = GetClassType(SubClassID);
		SP = info.nSP;
		Level = info.nLevel;
		UserRank = GetUserRankString(info.nUserRank);
		HP = info.nCurHP;
		MaxHP = info.nMaxHP;
		MP = info.nCurMP;
		MaxMP = info.nMaxMP;
		CP = info.nCurCP;
		MaxCP = info.nMaxCP;
		PledgeID = info.nClanID;
		NickNameColor = info.NicknameColor;
		PhysicalAttack = info.nPhysicalAttack;
		PhysicalDefense = info.nPhysicalDefense;
		HitRate = info.nHitRate;
		CriticalRate = info.nCriticalRate;
		if(IsUseSkillCastingSpeedStat())
		{
			PhysicalAttackSpeed = info.nPhysicalSkillCastingSpeed;			
		}
		else
		{
			PhysicalAttackSpeed = info.nPhysicalAttackSpeed;
		}
		MagicalAttack = info.nMagicalAttack;
		MagicDefense = info.nMagicDefense;
		PhysicalAvoid = info.nPhysicalAvoid;
		MagicCastingSpeed = info.nMagicCastingSpeed;
		MovingSpeed = GetMovingSpeed(info);
		CriminalRate = info.nCriminalRate;
		DualCount = info.nDualCount;
		PKCount = info.nPKCount;
		VoteCount = Info.nVoteCount;
		BonusCount = Info.nBonusCount;
		NegativeVoteCount = Info.nNegativeVoteCount;
		Notoriety = Info.nNotoriety;

		RaidPoint = info.RaidPoint;
		//Vitality = info.nVitality;
		// 신규 추가  2010.10.11 CT3 스탯 정보 개선
		nMagicAvoid = info.nMagicAvoid;
		nMagicHitRate = info.nMagicHitRate;
		nMagicCriticalRate = info.nMagicCriticalRate;
		activatedElixirPoint = Info.nActivatedElixirPoint;

		// debug("nMagicAvoid:"@ nMagicAvoid);
		// debug("nMagicHitRate:"@ nMagicHitRate);
		// debug("nMagicCriticalRate:"@ nMagicCriticalRate);

		//~ debug("속성정보: " @ AttrAttackType);
		//~ debug("속성정보: " @  AttrAttackValue);
		//~ debug("속성정보: " @  AttrDefenseValFire);
		//~ debug("속성정보: " @  AttrDefenseValWater);
		//~ debug("속성정보: " @  AttrDefenseValWind);
		//~ debug("속성정보: " @ AttrDefenseValEarth);
		//~ debug("속성정보: " @ AttrDefenseValHoly);
		//~ debug("속성정보: " @ AttrDefenseValUnholy);
		
		/*
		Switch(AttrAttackType)
		{
			case -2:
				AttrAttackTypeTxt = GetSystemString(27);
				break;
			case 0:
				AttrAttackTypeTxt = GetSystemString(1630);
				break;
			case 1:
				AttrAttackTypeTxt = GetSystemString(1631);
				break;
			case 2:
				AttrAttackTypeTxt = GetSystemString(1632);
				break;
			case 3:
				AttrAttackTypeTxt = GetSystemString(1633);
				break;
			case 4:
				AttrAttackTypeTxt = GetSystemString(1634);
				break;
			case 5:
				AttrAttackTypeTxt = GetSystemString(1635);
				break;
		}*/
		
		//debug("활력도:" @ Vitality);
//		UpdateVp(Vitality);
		
		//~ switch(Vitality)
		//~ {
			//~ case 0:
			//~ VitalityTex.SetTexture("l2ui_ct1.Icon_df_LifeForce_01");
			//~ break;
			//~ case 1:
			//~ VitalityTex.SetTexture("l2ui_ct1.Icon_df_LifeForce_02");
			//~ break;
			//~ case 2:
			//~ VitalityTex.SetTexture("l2ui_ct1.Icon_df_LifeForce_03");
			//~ break;
			//~ case 3:
			//~ VitalityTex.SetTexture("l2ui_ct1.Icon_df_LifeForce_04");
			//~ break;
			//~ case 4:
			//~ VitalityTex.SetTexture("l2ui_ct1.Icon_df_LifeForce_05");
			//~ break;
			//~ case 5:
			//~ VitalityTex.SetTexture("l2ui_ct1.Icon_df_LifeForce_01");
			//~ break;
		//~ }
		

		//아르테이어 종족일 경우 
//		setSubjobSlot(info.Race == 6) ;
	}
	
	if(CriminalRate > 0)
	{
		iNameColorRate = Min((100 +(CriminalRate / 100)), 255);
		NameColor.R = 0;
		NameColor.G = iNameColorRate;
		NameColor.B = 0;
		NameColor.A = 255;
		
		if(CriminalRate>999999)
			strCriminalRate = string(999999) $ "(+)";	
		else			
			strCriminalRate = string(CriminalRate);		
	}
	else if(CriminalRate < 0)
	{
		iNameColorRate = Min((100 +(-CriminalRate / 100)), 255);		
		NameColor.R = iNameColorRate;
		NameColor.G = 0;
		NameColor.B = 0;
		NameColor.A = 255;

		if(CriminalRate<-999999)
			strCriminalRate = string(-999999) $ "(+)";	
		else			
			strCriminalRate = string(CriminalRate);	
		
	}
	else // if CriminalRate == 0
	{
		NameColor.R = 230;
		NameColor.G = 230;
		NameColor.B = 230;
		NameColor.A = 255;
		strCriminalRate = "" $ CriminalRate;
	}
	// End Change	
	
	if(Len(NickName)>0)
	{
		GetTextSizeDefault(Name, Width1, Height1);
		GetTextSizeDefault(NickName, Width2, Height2);
		if(Width1 + Width2 > 220)
		{
			if(Width1 > 109)
			{
				Name = Left(Name, 8);
				GetTextSizeDefault(Name, Width1, Height1);
			}
			if(Width2 > 109)
			{
				GetTextSizeDefault(NickName, Width2, Height2);
			}
		}
		txtName1.SetFormatString(NickName);
		txtName1.SetTextColor(NickNameColor);
		txtName2.SetText(Name);
		txtName2.SetTextColor(NameColor);
		txtName2.MoveTo(rectWnd.nX + 15 + Width2 + 47, rectWnd.nY +41); //~ debug("음..:rectWnd: " @ rectWnd.nY );
	}
	else
	{
		txtName1.SetText(Name);
		txtName1.SetTextColor(NameColor);
		txtName2.SetText("");
	}
	
	txtLvName.SetText("" $ Level);
	txtClassName.SetText(ClassName);
	// Debug("=====:: ClassName " @ ClassName);
	txtRank.SetText(UserRank);
	txtSP.SetText(string(SP));

	//혈맹
	if(PledgeID > 0)
	{
		//텍스쳐
		bPledgeCrestTexture = class'UIDATA_CLAN'.static.GetCrestTexture(PledgeID, PledgeCrestTexture);
		PledgeName = class'UIDATA_CLAN'.static.GetName(PledgeID);
		PledgeNameColor.R = 176;
		PledgeNameColor.G = 155;
		PledgeNameColor.B = 121;
		PledgeNameColor.A = 255;
	}
	else
	{
		PledgeName = GetSystemString(431);
		PledgeNameColor.R = 230;
		PledgeNameColor.G = 230;
		PledgeNameColor.B = 230;
		PledgeNameColor.A = 255;
	}
	txtPledge.SetText(PledgeName);
	txtPledge.SetTextColor(PledgeNameColor);

	// 혈맹이미지가있다면..
	if(bPledgeCrestTexture)
	{
		texPledgeCrest.SetTextureWithObject(PledgeCrestTexture);
		txtPledge.MoveTo(rectWnd.nX + 118, rectWnd.nY + 59); //수정
	}
	else
	{
		// 혈맹이미지가없다면..
		txtPledge.MoveTo(rectWnd.nX + 86, rectWnd.nY + 59);
	}

	nMagicAvoid = info.nMagicAvoid;
	nMagicHitRate = info.nMagicHitRate;
	nMagicCriticalRate = info.nMagicCriticalRate;
	GetTextBoxHandle(m_WindowName $ ".txtMagicAvoid").SetText(String(nMagicAvoid));
	GetTextBoxHandle(m_WindowName $ ".txtMagicHit").SetText(String(nMagicHitRate));
	GetTextBoxHandle(m_WindowName $ ".txtMagicCritical").SetText(String(nMagicCriticalRate));
	txtPhysicalAttack.SetText(string(PhysicalAttack));
	txtPhysicalDefense.SetText(string(PhysicalDefense));
	txtHitRate.SetText(string(HitRate));
	txtCriticalRate.SetText(string(CriticalRate));
	txtPhysicalAttackSpeed.SetText(string(PhysicalAttackSpeed));
	txtMagicalAttack.SetText(string(MagicalAttack));
	txtMagicDefense.SetText(string(MagicDefense));
	txtPhysicalAvoid.SetText(string(PhysicalAvoid));
	txtMovingSpeed.SetText(MovingSpeed);
	txtMagicCastingSpeed.SetText(string(MagicCastingSpeed));
	if(int(strCriminalRate) < 0)
	{
		txtCriminalRate.SetTextColor(NameColor);		
	}
	else
	{
		txtCriminalRate.SetTextColor(GetColor(200, 200, 200, 255));
	}
	txtCriminalRate.SetText(strCriminalRate);
	//txtPVP.SetText(string(PvPPoint));
	txtSociality_PVP.SetText(string(DualCount));
	if(PKCount > 0)
	{
		txtSociality_PK.SetTextColor(GetColor(255, 102, 102, 255));		
	}
	else
	{
		txtSociality_PK.SetTextColor(GetColor(200, 200, 200, 255));
	}
	txtSociality_PK.SetText(string(PKCount));
	txtBonusVote.SetText(string(BonusCount) $ " / " $ string(VoteCount));
	txtRaidPoint.SetText(string(RaidPoint));

	UpdateHPBar(HP, MaxHP);
	UpdateMPBar(MP, MaxMP);
	UpdateCPBar(CP, MaxCP);
	UpdateEXPBar(info.fExpPercentRate);
	txtFireDefence.SetText(string(Info.nFireDefend));
	txtWaterDefence.SetText(string(Info.nWaterDefend));
	txtWindDefence.SetText(string(Info.nWindDefend));
	txtEarthDefence.SetText(string(Info.nEarthDefend));
	txtFireAttack.SetText(string(Info.nFireAttack));
	txtWaterAttack.SetText(string(Info.nWaterAttack));
	txtWindAttack.SetText(string(Info.nWindAttack));
	txtEarthAttack.SetText(string(Info.nEarthAttack));
	txtDisapprove.SetText(string(Notoriety) $ " / " $ string(NegativeVoteCount));
	ElixirPoint_txt.SetText(string(activatedElixirPoint) $ "/" $ string(API_GetMaxElixir()));
}

//HP바갱신
function UpdateHPBar(int Value, int MaxValue)
{
	texHP.SetPoint(Value, MaxValue);
}

//MP바갱신
function UpdateMPBar(int Value, int MaxValue)
{
	texMP.SetPoint(Value, MaxValue);
}

//EXP바갱신
function UpdateEXPBar(float ExpPercent)
{
	texEXP.SetPointExpPercentRate(ExpPercent);
}

//CP바갱신
function UpdateCPBar(int Value, int MaxValue)
{
	texCP.SetPoint(Value, MaxValue);
}

function ToggleOpenCharInfoWnd()
{
	switch(m_hOwnerWnd.IsShowWindow())
	{
		case true:
			m_hOwnerWnd.HideWindow();
			PlaySound("InterfaceSound.charstat_close_01");
			break;
		case false:
			m_hOwnerWnd.ShowWindow();
			m_hOwnerWnd.SetFocus();
			PlaySound("InterfaceSound.charstat_open_01");
			break;
	}
}



//branch
// F2P 서비스 활력 개선 - gorillazin
function HandleVitalityEffectInfo(string param)
{
	local CustomTooltip T;
	local string tmpStr;
	local string sSysMsgParamString;
	local int nVitality;
	local int nVitalityBonus;
	local int nVitalityItemRestoreCount;

	ParseInt(param, "vitalityPoint", nVitality);
	ParseInt(param, "vitalityBonus", nVitalityBonus);
	ParseInt(param, "restoreCount", nVitalityItemRestoreCount);
	// maxRestoreCount 에 대한 내용은 이 UI에서는 사용하지 않습니다.

	util = L2Util(GetScript("L2Util"));
	util.setCustomTooltip(T);
	util.ToopTipInsertText(GetSystemString(2494), true, false);

	//활력이 0일 경우, 활력이 20일 경우 그 외 경우로 나눠 짐.
	if(nVitality <= 0)
	{
		tmpStr = GetSystemString(2496);
		util.ToopTipInsertText(tmpStr, true, false, util.ETooltipTextType.COLOR_GRAY);
		tmpStr = ", ";
		util.ToopTipInsertText(tmpStr, true, false);
		sSysMsgParamString = "";
		tmpStr = "";
		ParamAdd(sSysMsgParamString, "Type", string(int(ESystemMsgParamType.SMPT_NUMBER)));
		ParamAdd(sSysMsgParamString, "param1", string(nVitalityItemRestoreCount));
		AddSystemMessageParam(sSysMsgParamString);
		tmpStr = EndSystemMessageParam(6073, true);

		util.ToopTipInsertText(tmpStr, true, false);
	}
	else
	{
		sSysMsgParamString = "";
		tmpStr = "";
		ParamAdd(sSysMsgParamString, "Type", string(int(ESystemMsgParamType.SMPT_NUMBER)));
		ParamAdd(sSysMsgParamString, "param1", string(nVitalityBonus));
		AddSystemMessageParam(sSysMsgParamString);
		tmpStr = EndSystemMessageParam(6072, true);
		util.ToopTipInsertText(tmpStr, true, false);

		tmpStr = " ";
		util.ToopTipInsertText(tmpStr, true, false);

		tmpStr = "";
		sSysMsgParamString = "";
		ParamAdd(sSysMsgParamString, "Type", string(int(ESystemMsgParamType.SMPT_NUMBER)));
		ParamAdd(sSysMsgParamString, "param1", string(nVitalityItemRestoreCount));
		AddSystemMessageParam(sSysMsgParamString);
		tmpStr = EndSystemMessageParam(6073, true);

		util.ToopTipInsertText(tmpStr, true, false);
	}
	//texVP.SetTooltipCustomType(util.getCustomTooltip());//bluesun 커스터마이즈 툴팁
}
//
//end of branch

function InitStatusInfo()
{
	local int i;
	local UserInfo uInfo;

	if(!GetPlayerInfo(uInfo))
	{
		return;
	}
	statusPlused.Length = 6;
	StatConfirmApplyWnd.HideWindow();
	StatConfirmResetWnd.HideWindow();
	ConfirmWnd.HideWindow();

	for(i = 0;i < 6; i++)
	{
		GetPlusWindowByIndex(i).HideWindow();
		GetTxtBoxHandlePlusByIndex(i).SetText("0");
		GetTxtBoxHandlePlusByIndex(i).SetTextColor(GetColor(150,150,150,255));
		statusPlused[i] = 0;
	}
	StatesByUserInfoUpdate(uInfo);
	CheckStatusButtomBtns(false);
}

function StatesByUserInfoUpdate(UserInfo uInfo)
{
	local int i;

	statusCanPlus = uInfo.nTotalBonus - GetTotalBonusAdded(uInfo) - GetAllStatusPlused();
	statusMax = uInfo.nTotalBonus;
	
	for(i = 0;i < 6; i++)
	{
		GetTxtBoxHandleBasicByIndex(i).SetText(string(GetStatusStatByIndex(i,uInfo)));
		if(GetStatusBonusByType(i,uInfo) > 0)
		{
			GetTextureHandleAddedByIndex(i).ShowWindow();
		} else {
			GetTextureHandleAddedByIndex(i).HideWindow();
		}
	}
	CheckStatusResetButton(uInfo);
	SetCanUsePointText();
	CheckStatusPlusButtons();
	CheckStatusMinusButtons();
	GetWindowHandle(GetStatusPlusPathByIndex(0)).SetTooltipCustomType(MakeStatusCustomTooltip(GetSystemString(3366),0,uInfo));
	GetWindowHandle(GetStatusPlusPathByIndex(2)).SetTooltipCustomType(MakeStatusCustomTooltip(GetSystemString(3368),2,uInfo));
	GetWindowHandle(GetStatusPlusPathByIndex(4)).SetTooltipCustomType(MakeStatusCustomTooltip(GetSystemString(3370),4,uInfo));
	GetWindowHandle(GetStatusPlusPathByIndex(1)).SetTooltipCustomType(MakeStatusCustomTooltip(GetSystemString(3367),1,uInfo));
	GetWindowHandle(GetStatusPlusPathByIndex(3)).SetTooltipCustomType(MakeStatusCustomTooltip(GetSystemString(3369),3,uInfo));
	GetWindowHandle(GetStatusPlusPathByIndex(5)).SetTooltipCustomType(MakeStatusCustomTooltip(GetSystemString(3371),5,uInfo));
	StatBonusWndClassic(GetScript("StatBonusWndClassic")).ResetData();
}

function CustomTooltip MakeStatusCustomTooltip(string Title, int Type, UserInfo uInfo)
{
	local CustomTooltip m_Tooltip;
	local int basicStatus;
	local int hennaItemSkillStatus;
	local int bonusStatus;
	local int currentindex;

	basicStatus = GetStatusStatByIndex(Type,uInfo);
	hennaItemSkillStatus = GetStatusHennaSkillItemBonusByType(Type,uInfo);
	bonusStatus = GetStatusBonusByType(Type,uInfo);
	m_Tooltip.DrawList.Length = 3;
	m_Tooltip.MinimumWidth = 214;
	m_Tooltip.DrawList[0].eType = DIT_TEXT;
	m_Tooltip.DrawList[0].t_color.R = 200;
	m_Tooltip.DrawList[0].t_color.G = 200;
	m_Tooltip.DrawList[0].t_color.B = 200;
	m_Tooltip.DrawList[0].t_color.A = 255;
	m_Tooltip.DrawList[0].t_strText = Title;
	m_Tooltip.DrawList[1].bLineBreak = true;
	m_Tooltip.DrawList[1].eType = DIT_TEXT;
	m_Tooltip.DrawList[1].t_color.R = 153;
	m_Tooltip.DrawList[1].t_color.G = 153;
	m_Tooltip.DrawList[1].t_color.B = 153;
	m_Tooltip.DrawList[1].t_color.A = 255;
	m_Tooltip.DrawList[1].t_strText = GetSystemString(103) @ ": ";
	m_Tooltip.DrawList[2].eType = DIT_TEXT;
	m_Tooltip.DrawList[2].t_color.R = 187;
	m_Tooltip.DrawList[2].t_color.G = 170;
	m_Tooltip.DrawList[2].t_color.B = 136;
	m_Tooltip.DrawList[2].t_color.A = 255;
	m_Tooltip.DrawList[2].t_strText = string(basicStatus - bonusStatus - hennaItemSkillStatus);
	currentindex = m_Tooltip.DrawList.Length;
	if(hennaItemSkillStatus != 0)
	{
		m_Tooltip.DrawList.Length = m_Tooltip.DrawList.Length + 2;
		m_Tooltip.DrawList[currentindex].bLineBreak = true;
		m_Tooltip.DrawList[currentindex].eType = DIT_TEXT;
		m_Tooltip.DrawList[currentindex].t_color.R = 153;
		m_Tooltip.DrawList[currentindex].t_color.G = 153;
		m_Tooltip.DrawList[currentindex].t_color.B = 153;
		m_Tooltip.DrawList[currentindex].t_color.A = 255;
		m_Tooltip.DrawList[currentindex].t_strText = GetSystemString(13165) $ " : ";
		currentindex = currentindex + 1;
		m_Tooltip.DrawList[currentindex].eType = DIT_TEXT;
		m_Tooltip.DrawList[currentindex].t_color.R = 187;
		m_Tooltip.DrawList[currentindex].t_color.G = 170;
		m_Tooltip.DrawList[currentindex].t_color.B = 136;
		m_Tooltip.DrawList[currentindex].t_color.A = 255;
		m_Tooltip.DrawList[currentindex].t_strText = string(hennaItemSkillStatus);
		currentindex = currentindex + 1;
	}
	if(bonusStatus > 0)
	{
		m_Tooltip.DrawList.Length = m_Tooltip.DrawList.Length + 2;
		m_Tooltip.DrawList[currentindex].bLineBreak = true;
		m_Tooltip.DrawList[currentindex].eType = DIT_TEXT;
		m_Tooltip.DrawList[currentindex].t_color.R = 153;
		m_Tooltip.DrawList[currentindex].t_color.G = 153;
		m_Tooltip.DrawList[currentindex].t_color.B = 153;
		m_Tooltip.DrawList[currentindex].t_color.A = 255;
		m_Tooltip.DrawList[currentindex].t_strText = GetSystemString(13117) @ ": ";
		currentindex = currentindex + 1;
		m_Tooltip.DrawList[currentindex].eType = DIT_TEXT;
		m_Tooltip.DrawList[currentindex].t_color.R = 187;
		m_Tooltip.DrawList[currentindex].t_color.G = 170;
		m_Tooltip.DrawList[currentindex].t_color.B = 136;
		m_Tooltip.DrawList[currentindex].t_color.A = 255;
		m_Tooltip.DrawList[currentindex].t_strText = string(bonusStatus);
	}
	return m_Tooltip;
}

function CheckStatusResetButton(UserInfo uInfo)
{
	if(GetTotalBonusAdded(uInfo) > 0)
	{
		UsePoint_Reset_BTN.EnableWindow();
	} else {
		UsePoint_Reset_BTN.DisableWindow();
	}
}

function bool GetIsPlused()
{
	local int i;

	for(i = 0;i < 6; i++)
	{
		if(statusPlused[i] > 0)
		{
			return true;
		}
	}
	return false;
}

function int GetAllStatusPlused()
{
	local int i;
	local int allplused;

	for(i = 0;i < 6; i++)
	{
		allplused = allplused + statusPlused[i];
	}
	return allplused;
}

function SetCanUsePointText()
{
	local int statusCanPlusUInt;

	statusCanPlusUInt = statusCanPlus;
	if(statusCanPlusUInt < 0)
	{
		statusCanPlusUInt = 0;
	}
	Statsinfo_UsePoint_text.SetText(string(statusCanPlusUInt) $ "/" $ string(statusMax));
}

function HandleOnCliCKUsePointCancel()
{
	local int i;

	statusCanPlus = statusCanPlus + GetAllStatusPlused();
	for(i = 0;i < 6; i++)
	{
		HandleUsePointCancelByType(i);
	}
	CheckStatusButtomBtns(false);
	SetCanUsePointText();
}

function HandleUsePointCancelByType(int Type)
{
	GetPlusWindowByIndex(Type).HideWindow();
	GetTxtBoxHandlePlusByIndex(Type).SetText("0");
	GetTxtBoxHandlePlusByIndex(Type).SetTextColor(GetColor(150, 150, 150, 255));
	statusPlused[Type] = 0;
	GetStatusPlusBtnByIndex(Type).EnableWindow();
	GetStatusMinusBtnByIndex(Type).DisableWindow();
	StatBonusWndClassic(GetScript("StatBonusWndClassic")).HandleOnChangedStatusType(Type);
}

function HandleShowResetWindow()
{
	HandleItemUpdate();
	StatConfirmResetWnd.ShowWindow();
	ConfirmWnd.ShowWindow();
	ConfirmWnd.SetFocus();
	getInstanceL2Util().ItemRelationWindowHide("DetailStatusWndClassic.ConfirmWnd");
}

function HandleItemUpdate()
{
	local UserInfo uInfo;
	local array<RequestItem> arrStatBonusResetUIData;
	local int i;

	arrStatBonusResetUIData = API_GetStatBonusResetData();
	if(	!GetPlayerInfo(uInfo))
	{
		return;
	}
	ResetCharge_ListCtrl.DeleteAllItem();
	Reset_Btn.EnableWindow();
	
	for(i = 0;i < arrStatBonusResetUIData.Length; i++)
	{
		ResetCharge_ListCtrl.InsertRecord(MakeRowDataStatusResetNeedItem(arrStatBonusResetUIData[i].Id,arrStatBonusResetUIData[i].Amount));
	}
	NumPoint_text.SetText(string(GetTotalBonusAdded(uInfo)) $ "/" $ string(uInfo.nTotalBonus));
}

function RichListCtrlRowData MakeRowDataStatusResetNeedItem(int ClassID, INT64 Amount)
{
	local RichListCtrlRowData rowData;
	local Color itemNumColor;
	local ItemID cID;
	local InventoryWnd inventoryWndScript;
	local INT64 ItemCount;

	rowData.cellDataList.Length = 1;
	cID.ClassID = ClassID;
	addRichListCtrlTexture(rowData.cellDataList[0].drawitems,"L2UI_ct1.ItemWindow.ItemWindow_df_slotbox_2x2",36,36,0,1);
	addRichListCtrlTexture(rowData.cellDataList[0].drawitems,Class'UIDATA_ITEM'.static.GetItemTextureName(cID),32,32,-34,1);
	addRichListCtrlString(rowData.cellDataList[0].drawitems,Class'UIDATA_ITEM'.static.GetItemName(cID),util.BrightWhite,false,5,0);
	inventoryWndScript = InventoryWnd(GetScript("InventoryWnd"));
	ItemCount = inventoryWndScript.getItemCountByClassID(ClassID);
	if(ItemCount < Amount)
	{
		Reset_Btn.DisableWindow();
		itemNumColor = GetColor(255,0,0,255);
	} else {
		itemNumColor = GetColor(0,176,255,255);
	}
	addRichListCtrlString(rowData.cellDataList[0].drawitems,"x" $ MakeCostStringINT64(Amount),util.White,true,40,5);
	addRichListCtrlString(rowData.cellDataList[0].drawitems,"(" $ MakeCostStringINT64(ItemCount) $ ")",itemNumColor,false);
	return rowData;
}

function HandleOnClickMinusBtn(int Type)
{
	if(statusPlused[Type] == 0)
	{
		return;
	}
	statusPlused[Type] = statusPlused[Type] - 1;
	statusCanPlus++;
	if(statusPlused[Type] == 0)
	{
		HandleUsePointCancelByType(Type);
		CheckStatusButtomBtns(GetAllStatusPlused() > 0);
	} else {
		GetTxtBoxHandleAddedByIndex(Type).SetText("/" $ string(GetStatusPlused(int(GetTxtBoxHandleBasicByIndex(Type).GetText()) + statusPlused[Type])));
		GetTxtBoxHandlePlusByIndex(Type).SetText("+" $ string(statusPlused[Type]));
	}
	CheckStatusPlusButtons();
	SetCanUsePointText();
	StatBonusWndClassic(GetScript("StatBonusWndClassic")).HandleOnChangedStatusType(Type);
}

function HandleOnClickPlusBtn(int Type)
{
	statusPlused[Type] = statusPlused[Type] + 1;
	GetTxtBoxHandleAddedByIndex(Type).SetText("/" $ string(GetStatusPlused(int(GetTxtBoxHandleBasicByIndex(Type).GetText()) + statusPlused[Type])));
	GetPlusWindowByIndex(Type).ShowWindow();
	statusCanPlus--;
	SetCanUsePointText();
	GetTxtBoxHandlePlusByIndex(Type).SetText("+" $ string(statusPlused[Type]));
	GetTxtBoxHandlePlusByIndex(Type).SetTextColor(GetColor(255, 228, 0, 255));
	CheckStatusPlusButtons();
	GetStatusMinusBtnByIndex(Type).EnableWindow();
	CheckStatusButtomBtns(true);
	StatBonusWndClassic(GetScript("StatBonusWndClassic")).HandleOnChangedStatusType(Type);
}

function HandleOnChangeState()
{
	local int i;

	for(i = 0; i < statusPlused.Length; i++)
	{
		if(GetPlusWindowByIndex(i).IsShowWindow())
		{
			GetTxtBoxHandleAddedByIndex(i).SetText("/" $ string(GetStatusPlused(int(GetTxtBoxHandleBasicByIndex(i).GetText()) + statusPlused[i])));
		}
	}
}

function int GetStatusPlused(int plusedNum)
{
	if(plusedNum > 200)
	{
		return 200;
	}
	return plusedNum;
}

function CheckStatusPlusButtons()
{
	local int i;

	if(statusCanPlus > 0)
	{
		for(i = 0;i < 6; i++)
		{
			GetStatusPlusBtnByIndex(i).EnableWindow();
		}
	} else {
		for(i = 0;i < 6; i++)
		{
			GetStatusPlusBtnByIndex(i).DisableWindow();
		}
	}
}

function CheckStatusMinusButtons()
{
	local int i;

	for(i = 0;i < 6; i++)
	{
		if(statusPlused[i] > 0)
		{
			GetStatusMinusBtnByIndex(i).EnableWindow();
		} else {
			GetStatusMinusBtnByIndex(i).DisableWindow();
		}
	}
}

function CheckStatusButtomBtns(bool isPlused)
{
	if(isPlused)
	{
		UsePoint_Apply_BTN.ShowWindow();
		UsePoint_Cancel_BTN.ShowWindow();
		UsePoint_Reset_BTN.HideWindow();
	}
	else
	{
		UsePoint_Apply_BTN.HideWindow();
		UsePoint_Cancel_BTN.HideWindow();
		UsePoint_Reset_BTN.ShowWindow();
	}
}

function SetElixirInfo()
{
	local ItemInfo iInfo;

	iInfo = GetItemInfoByClassID(ElixirItemID);
	GetItemWindowHandle(m_WindowName $ ".Statsinfo_Elixir_Win.ElixirItem").AddItem(iInfo);
	GetTextBoxHandle(m_WindowName $ ".Statsinfo_Elixir_Win.ElixirTitle_txt").SetText(iInfo.Name);
}

function TextBoxHandle GetTxtBoxHandleBasicByIndex(int Index)
{
	return GetTextBoxHandle(GetStatusPlusPathByIndex(Index) $ ".Statsinfo_Num_text");
}

function TextBoxHandle GetTxtBoxHandleAddedByIndex(int Index)
{
	return GetTextBoxHandle(GetStatusPlusPathByIndex(Index) $ ".STR_PreviewNum_Wnd" $ ".Statsinfo_PreviewNum_text");
}

function WindowHandle GetPlusWindowByIndex(int Index)
{
	return GetWindowHandle(GetStatusPlusPathByIndex(Index) $ ".STR_PreviewNum_Wnd");
}

function TextureHandle GetTextureHandleAddedByIndex(int Index)
{
	return GetTextureHandle(GetStatusPlusPathByIndex(Index) $ ".Statsinfo_IconPointPanel_tex");
}

function TextBoxHandle GetTxtBoxHandlePlusByIndex(int Index)
{
	return GetTextBoxHandle(GetStatusPlusPathByIndex(Index) $ ".Statsinfo_PointPlusNum_Text");
}

function ButtonHandle GetStatusPlusBtnByIndex(int Index)
{
	return GetButtonHandle(GetStatusPlusPathByIndex(Index) $ ".Statsinfo_PointPlusNum_BTN");
}

function ButtonHandle GetStatusMinusBtnByIndex(int Index)
{
	return GetButtonHandle(GetStatusPlusPathByIndex(Index) $ ".Statsinfo_PointMinusNum_BTN");
}

function string GetStatusPlusPathByIndex(int Index)
{
	return m_Statsinfo_UsePoint_Win $ ".Win0" $ string(Index);
}


/**
 * 커스텀툴팁(서브잡클래스변환버튼에사용)
 **/
function CustomTooltip subjobButtonToolTips(int targetType)
{
	local CustomTooltip m_Tooltip;
	
	local int subjobSlotStringNum;
	// Debug("targetType tool " @ targetType);

	// 서브클래스를등록하는자리입니다.. 같은안내맨트..
	if(targetType == -1)
	{
		m_Tooltip.DrawList.Length = 1;
		m_Tooltip.MinimumWidth = 210;//160->183px 로 수정됨
		m_Tooltip.DrawList[0].eType = DIT_TEXT;
		m_Tooltip.DrawList[0].t_color.R = 220;
		m_Tooltip.DrawList[0].t_color.G = 220;
		m_Tooltip.DrawList[0].t_color.B = 220;
		m_Tooltip.DrawList[0].t_color.A = 255;		

		//아르테이어의 경우 툴팁 텍스트가 다름
		subjobSlotStringNum = 2342;

		if(race == 6) 
		{				
			subjobSlotStringNum = 3315;
		}


		m_Tooltip.DrawList[0].t_strText = GetSystemString(subjobSlotStringNum);
	}
	else
	{
		m_Tooltip.DrawList.Length = 5;
		if(GetLanguage() == LANG_Russia || GetLanguage() == LANG_Euro)
		{
			m_Tooltip.MinimumWidth = 260;			
		}
		else
		{
			m_Tooltip.MinimumWidth = 214;
		}

		m_Tooltip.DrawList[0].eType = DIT_TEXT;
		m_Tooltip.DrawList[0].t_color.R = 200;
		m_Tooltip.DrawList[0].t_color.G = 200;
		m_Tooltip.DrawList[0].t_color.B = 200;
		m_Tooltip.DrawList[0].t_color.A = 255;
		m_Tooltip.DrawList[0].t_strText = "Lv";
		
		m_Tooltip.DrawList[1].eType = DIT_TEXT;
		m_Tooltip.DrawList[1].t_color.R = 175;
		m_Tooltip.DrawList[1].t_color.G = 152;
		m_Tooltip.DrawList[1].t_color.B = 120;
		m_Tooltip.DrawList[1].t_color.A = 255;
		m_Tooltip.DrawList[1].t_strText = subjobInfoArray[targetType].Level @ GetClassType(subjobInfoArray[targetType].ClassID);


		m_Tooltip.DrawList[2].eType = DIT_TEXT;
		m_Tooltip.DrawList[2].t_color.R = 200;
		m_Tooltip.DrawList[2].t_color.G = 200;
		m_Tooltip.DrawList[2].t_color.B = 200;
		m_Tooltip.DrawList[2].t_color.A = 255;

		// Debug("GetClassType(subjobInfoArray[targetType].ClassID)" @ subjobInfoArray[targetType].ClassID);
		// Debug("GetClassType(subjobInfoArray[targetType] 이름:)" @ GetClassType(subjobInfoArray[targetType].ClassID));

		// 메인:0, 듀얼:1 서브:2
		// 서브클래스라면..
		if(subjobInfoArray[targetType].Type == 2)
		{
			// "서브" 
			m_Tooltip.DrawList[2].t_strText = "(" $ GetSystemString(2341) $ ")";			
		}
		else if(subjobInfoArray[targetType].Type == 1)
		{
			// "듀얼" 
			m_Tooltip.DrawList[2].t_strText = "(" $ GetSystemString(2739) $ ")";			
		}
		else
		{
			m_Tooltip.DrawList[2].t_strText = "(" $ GetSystemString(2738) $ ")";
		}	
		//m_Tooltip.DrawList[2].t_bDrawOneLine = true;
		//m_Tooltip.DrawList[2].bLineBreak = true;

		 
		m_Tooltip.DrawList[3].eType = DIT_TEXT;

		// m_Tooltip.DrawList[3].nOffSetY = 2;
		m_Tooltip.DrawList[3].bLineBreak = true;
		m_Tooltip.DrawList[3].t_color.R = 220;
		m_Tooltip.DrawList[3].t_color.G = 220;
		m_Tooltip.DrawList[3].t_color.B = 220;
		m_Tooltip.DrawList[3].t_color.A = 255;

		m_Tooltip.DrawList[3].t_strText = GetSystemString(2343);
		// 서브라면..
		// 80레벨이후메인클래스로성장할수있습니다. 메세지보여줌
		m_Tooltip.DrawList[4].eType = DIT_TEXT;

		// 듀얼 클래스가 하나도 없는 경우
		// 80레벨 이후 메인클래스로 성장할 수 있습니다 
		// 라는 툴팁을 보여준다. 
		if(subjobInfoArray[targetType].Type == 2 && isDualClass == false)
		{
			m_Tooltip.DrawList[4].bLineBreak = true;
			m_Tooltip.DrawList[4].t_color.R = 110;
			m_Tooltip.DrawList[4].t_color.G = 140;
			m_Tooltip.DrawList[4].t_color.B = 170;
			m_Tooltip.DrawList[4].t_color.A = 255;
			m_Tooltip.DrawList[4].t_strText = GetSystemString(2344);
		}
		else
		{
			m_Tooltip.DrawList[4].t_strText = "";
		}
	}

	return m_Tooltip;
}

function array<RequestItem> API_GetStatBonusResetData()
{
	local array<RequestItem> arrStatBonusResetUIData;
	local UserInfo uInfo;

	if(!GetPlayerInfo(uInfo))
	{
		return arrStatBonusResetUIData;
	}
	GetStatBonusResetData(GetTotalBonusAdded(uInfo),arrStatBonusResetUIData);
	return arrStatBonusResetUIData;
}

function int API_GetMaxElixir()
{
	return GetMaxElixir();
}

function API_C_EX_SET_STATUS_BONUS()
{
	local array<byte> stream;
	local UIPacket._C_EX_SET_STATUS_BONUS packet;
	local UserInfo uInfo;

	if(! GetPlayerInfo(uInfo))
	{
		return;
	}
	packet.additionalStatBonus.nStrBonus = statusPlused[0];
	packet.additionalStatBonus.nDexBonus = statusPlused[2];
	packet.additionalStatBonus.nConBonus = statusPlused[4];
	packet.additionalStatBonus.nIntBonus = statusPlused[1];
	packet.additionalStatBonus.nWitBonus = statusPlused[3];
	packet.additionalStatBonus.nMenBonus = statusPlused[5];
	if(! class'UIPacket'.static.Encode_C_EX_SET_STATUS_BONUS(stream, packet))
	{
		return;
	}
	Class'UIPacket'.static.RequestUIPacket(class'UIPacket'.const.C_EX_SET_STATUS_BONUS,stream);
}

function API_C_EX_RESET_STATUS_BONUS()
{
	local array<byte> stream;
	local UIPacket._C_EX_RESET_STATUS_BONUS packet;

	if(! class'UIPacket'.static.Encode_C_EX_RESET_STATUS_BONUS(stream, packet))
	{
		return;
	}
	Class'UIPacket'.static.RequestUIPacket(class'UIPacket'.const.C_EX_RESET_STATUS_BONUS,stream);
}

function int GetStatusStatByIndex(int Index, UserInfo uInfo)
{
	switch(Index)
	{
		case 0:
			return uInfo.nStr;
		case 1:
			return uInfo.nInt;
		case 2:
			return uInfo.nDex;
		case 3:
			return uInfo.nWit;
		case 4:
			return uInfo.nCon;
		case 5:
			return uInfo.nMen;
	}
	return -1;
}

function int GetStatusBonusByType(int Type, UserInfo uInfo)
{
	switch(Type)
	{
		case 0:
			return uInfo.nStrBonus;
		case 1:
			return uInfo.nIntBonus;
		case 2:
			return uInfo.nDexBonus;
		case 3:
			return uInfo.nWitBonus;
		case 4:
			return uInfo.nConBonus;
		case 5:
			return uInfo.nMenBonus;
	}
	return -1;
}

function int GetStatusHennaSkillItemBonusByType(int Type, UserInfo uInfo)
{
	switch(Type)
	{
		case 0:
			return uInfo.nStrAdditional;
		case 1:
			return uInfo.nIntAdditional;
		case 2:
			return uInfo.nDexAdditional;
		case 3:
			return uInfo.nWitAdditional;
		case 4:
			return uInfo.nConAdditional;
		case 5:
			return uInfo.nMenAdditional;
	}
	return -1;
}

function int GetTotalBonusAdded(UserInfo uInfo)
{
	local int i;
	local int total;

	for(i = 0; i < 6 ;i++)
	{
		total = total + GetStatusBonusByType(i,uInfo);
	}
	return total;
}

function _ElementalActive(int Index)
{
	local string spiritName;
	local Color Color;

	switch(Index)
	{
		case 0:
			spiritName = "Fire";
			Color = GetColor(255, 68, 68, 255);
			break;
		case 1:
			spiritName = "Water";
			Color = GetColor(0, 153, 255, 255);
			break;
		case 2:
			spiritName = "Wind";
			Color = GetColor(153, 255, 153, 255);
			break;
		case 3:
			spiritName = "Earth";
			Color = GetColor(255, 255, 153, 255);
			break;
	}
	GetTextureHandle(spiritName $ "ActiveTexture").ShowWindow();
	GetTextBoxHandle("txtHead" $ spiritName $ "Title").SetTextColor(Color);	
}

function _ElementalDeActive(int Index)
{
	local string spiritName;

	switch(Index)
	{
		case 0:
			spiritName = "Fire";
			break;
		case 1:
			spiritName = "Water";
			break;
		case 2:
			spiritName = "Wind";
			break;
		case 3:
			spiritName = "Earth";
			break;
		default:
			break;
	}
	GetTextureHandle(spiritName $ "ActiveTexture").HideWindow();
	GetTextBoxHandle("txtHead" $ spiritName $ "Title").SetTextColor(GetColor(200, 200, 200, 255));	
}

/**
 * 윈도우ESC 키로닫기처리
 * "Esc" Key
 ***/
function OnReceivedCloseUI()
{
	PlayConsoleSound(IFST_WINDOW_CLOSE);
	if(ConfirmWnd.IsShowWindow())
	{
		ConfirmWnd.HideWindow();
	}
	else
	{
		GetWindowHandle(m_WindowName).HideWindow();
	}
}

defaultproperties
{
	m_WindowName="DetailStatusWndClassic"
	m_Statsinfo_UsePoint_Win="DetailStatusWndClassic.Statsinfo_UsePoint_Win"
}
