Files
Leviathan/Client/Game/game/Interface/Title/SUITitleWnd.cpp
T
2026-06-01 12:46:52 +02:00

1610 lines
50 KiB
C++

#include "stdafx.h"
#include "stdafx.h"
#include "KUIWndManager.h"
#include "KUIControlStatic.h"
#include "KUIControlScroll.h"
#include "KUIControlButton.h"
#include "KUIControlClockBox.h"
#include "KUIControlScroll.h"
#include "KUITabControl.h"
#include "SNetMessage.h"
#include "SGameManager.h"
//#include "SGameMessageUI.h"
#include "SStringDB.h"
//#include "Util.h"
#include "SGameInterface.h"
#include "SGameVM.h"
#include <toolkit/XStringUtil.h>
#include "SGame.h"
#include "SContents.h"
#include "KUITipControl.h"
//#include "SUIUtil.h"
#include "SUIDisplayInfo.h"
#include "ItemEffectResource.h"
#include "SItemEffectResourceDB.h"
#include "SUITitleWnd.h"
#include "STitleMgr.h"
#include "SGameAvatarEx.h"
#include "SGameSystem.h"
extern SGameSystem* g_pCurrentGameSystem;
extern bool g_bRenderUI;
int SUITitleWnd::m_iSelectedSlot = -1;
int SUITitleWnd::m_iSelectedKind = -1;
int SUITitleWnd::m_iSelcetedID= -1;
/*namespace{*/
////////////////// 전체 호칭 리스트 컨트롤 ////////////////
const size_t ALL_TITLE_MAX = 13; // 전체 호칭
const size_t ALL_TITLE_DELTA_Y = 30;
const size_t ALL_SLOT_CONTROL_NUM = 5;
const size_t INFO_TEXT_LINE_NUM = 9;
const size_t INFO_TEXT_DELTA_Y = 15;
const size_t LIMITED_LANK = 6;
const int MAX_COOLTIME = 30000;
static char *s_szAllSlotControlName[ ALL_SLOT_CONTROL_NUM ] // 전체호칭 슬롯
= {
"line_title_list_",
"check_favorite_",
"title_name_gain_text_",
"button_title_equip_",
"new_title_mark_",
};
static char *s_szInfoSlotControlName[ ALL_SLOT_CONTROL_NUM ] // 호칭 정보 슬롯
= {
"line_title_list_view_",
"mark_favorite_able_view_",
"title_name_gain_view_text_",
"equip_title_mark_",
"mark_title_gain_view_",
};
////////////////// 사용중인 호칭 리스트 컨트롤 ////////////////
const size_t SUB_TITLE_MAX = 5; // 장착된 부호칭 리스트
const size_t SUB_TITLE_DELTA_Y = 32;
const size_t USING_SLOT_CONTROL_NUM = 4;
static char *s_szMainSlotControlName[ USING_SLOT_CONTROL_NUM ] // 주호칭 슬롯
= {
"line_main_title_equip_",
"mark_main_favorite_able_",
"main_title_name_equip_text_",
"button_main_title_unequip_",
};
static char *s_szSubSlotControlName[ USING_SLOT_CONTROL_NUM ] // 부호칭 슬롯
= {
"line_sub_title_equip_",
"mark_sub_favorite_disable_",
"sub_title_name_equip_text_",
"button_sub_title_unequip_",
};
///////////////////// sprite 이름 ////////////////////
// 배경이 되는 바가 6종류가 있다 -_-;;; 초기화는 initcontrol에서... ㅎㄷㄷ
std::string c_strSelectBar;
std::string c_strMainEquip;
std::string c_strMainUnEquip;
std::string c_strSubEquip;
std::string c_strSubUnEquip;
std::string c_strAllEquip;
std::string c_strAllUnEquip;
std::string c_strInfoUnEquip;
std::string c_strEquipBtn; // 장착 버튼 활성화 ani
std::string c_strUnEquipBtn; // 장착 버튼 비활성화 ani
std::string c_strNew; // 새로운 호칭 ani
std::string c_strBookmark; // 즐겨찾기
std::string c_strNoBookmark; // 비즐겨찾기
std::string c_strInfoBack; // 호칭정보 백
KColor c_CoolTimeColor = KColor(163, 163, 163, 30);
/*};*/
extern std::string ParserTitleText( const char *sz, int id ); // GameVM.cpp
bool CutButtonID( std::string& str, LPCSTR lpszID ,int& nID)
{
if( str.find(lpszID) != -1 )
{
std::string strNumber = str.substr(str.size()-2,2); // "xxxxxxx_xxxxxxxx_10" 에서 숫자부분만 자른다.
nID = atoi(strNumber.c_str());
return true;
}
else
return false;
}
SUITitleWnd::SUITitleWnd( SGameManager* pGameManager ,SUIDisplayInfo* pDisplayInfo )
:SUIWnd(pGameManager),
m_pDisplayInfo(pDisplayInfo),
m_bScrollRefresh(false),
m_ScrollPos(0),
m_InfoScrollPos(0),
m_CooltimeCheck(false),
m_MouseX(0),
m_MouseY(0),
m_bFirstOpen(true),
m_dwBeforeTime(0)
{
//m_iSelectedKind = -1;
//m_iSelectedSlot = -1;
//m_iSelcetedID = -1;
m_uiReceivedTime = 0;
}
void SUITitleWnd::OnNotifyUIWindowOpen( bool bOpen, bool bLimitWnd /* = true */ )
{
if(bOpen)
{
if(m_bFirstOpen)
{
InitList();
m_bFirstOpen = false;
}
}
SUIWnd::OnNotifyUIWindowOpen( bOpen );
}
void SUITitleWnd::ProcMsgAtStatic(SGameMessage *pMsg)
{
m_msgFp.call(pMsg->nType, this, pMsg);
}
void SUITitleWnd::InitList()
{
m_InfoSlot.SetShow(false); // 기본정렬
m_pStaticSortAse->SetShow(false); // 정렬상태 표식 없애고
m_pStaticSortDes->SetShow(false);
Refresh(); // 슬롯 리프레쉬
SetInstallSlot(); // 장착가능 슬롯 표시 설정
}
void SUITitleWnd::Refresh()
{
m_TitleMgr.Refresh();
RefreshAllSlot();
RefreshEquipSlot();
}
void SUITitleWnd::RefreshEquipSlot()
{
stTitleUsingID EquipList = m_TitleMgr.GetEquipList();
// 메인
stTitleUI *title = m_TitleMgr.GetTitleUiByID(EquipList.nMain);
if(title)
m_vMainSlot.at(0).SetSlot(title->bBookMark,title->bUsing, EquipList.nMain, title->iStringID);
else
m_vMainSlot.at(0).SetShowSlot(false);
// 서브
std::vector<stSubSlot>::iterator it = m_vSubSlot.begin();
for( int i=0 ; it != m_vSubSlot.end() ; ++it ,++i )
{
stTitleUI *sTitle = m_TitleMgr.GetTitleUiByID(EquipList.nSub[i]);
if(sTitle)
it->SetSlot(sTitle->bBookMark,sTitle->bUsing, EquipList.nSub[i], sTitle->iStringID);
else
it->SetShowSlot(false);
}
}
void SUITitleWnd::stSubSlot::SetShowSlot(bool bEnable)
{
if(bEnable == false)
SetTitleIDReset();
m_pBookMark->SetShow(bEnable);
m_pName->SetShow(bEnable);
m_pUsing->SetShow(bEnable);
m_pBack->SetAniName( (bEnable)?c_strSubEquip.c_str() : c_strSubUnEquip.c_str() );
}
void SUITitleWnd::SetInstallSlot()
{
if( m_vMainSlot.at(0).GetTitleID() == SLOT_KIND::NONE_SLOT)
{
MoveInstallSloat(SLOT_KIND::MAIN_SLOT);
SetSubTitleString(-1);
return;
}
else
{
std::vector<stSubSlot>::iterator it = m_vSubSlot.begin();
for(int i= 0 ; it<m_vSubSlot.end() ; ++it, ++i)
{
if(it->GetTitleID() == SLOT_KIND::NONE_SLOT)
{
MoveInstallSloat(SLOT_KIND::SUB_SLOT, i);
SetSubTitleString(i);
return;
}
}
}
m_pStaticInstallSlot->SetShow(false); /// 여기까지 왔다면 빈슬롯이 없다
SetSubTitleString(-1);
m_iEmptySlotKind = -1;
m_iEmptySlotKind = -1;
}
void SUITitleWnd::MoveInstallSloat(int nKind, int nSlotNum /* = 0 */ )
{
m_pStaticInstallSlot->SetShow(true);
KRect rc;
if(nKind == SLOT_KIND::MAIN_SLOT)
rc = m_vMainSlot.at(0).GetRect();
else
rc = m_vSubSlot.at(nSlotNum).GetRect();
m_pStaticInstallSlot->MovePos(rc.left -14 , rc.top -3); // 기준점보다 14, 3 만큼 이동해야한다.
// 빈슬롯 정보 저장
m_iEmptySlotKind = nKind;
m_iEmptySlotIndex = nSlotNum;
}
void SUITitleWnd::stMainSlot::SetShowSlot(bool bEnable)
{
if(bEnable == false)
SetTitleIDReset();
m_pBookMark->SetShow(bEnable);
m_pName->SetShow(bEnable);
m_pUsing->SetShow(bEnable);
m_pBack->SetAniName( (bEnable)?c_strMainEquip.c_str() : c_strMainUnEquip.c_str() );
}
void SUITitleWnd::stMainSlot::SetSlot(bool bBookmark, bool bUsing, int nId, int nStringID)
{
SetShowSlot(true);
m_iID = nId;
ChangeBar(bUsing); // 배경
SetBookmark(bBookmark); // 북마크 상태
ChangeTitleName(S(nStringID)); // 호칭 이름 변경
}
void SUITitleWnd::stSubSlot::SetSlot(bool bBookmark, bool bUsing, int nId, int nStringID)
{
if(bUsing)
{
m_iID = nId;
SetShowSlot(true); // show
ChangeBar(bUsing); // 배경
SetBookmark(bBookmark); // 북마크 상태
ChangeTitleName(S(nStringID)); // 호칭 이름 변경
}
else
m_iID = -1;
}
void SUITitleWnd::RefreshAllSlot()
{
std::vector<stTitleUI> title = m_TitleMgr.GetTitleUI();
std::vector<stTitleUI>::iterator it= title.begin();
int nSlotCount = ( title.size() < ALL_TITLE_MAX )? title.size() : ALL_TITLE_MAX;
for(int i=0 ; i<m_vAllSlot.size() ; ++i)
{
if( i <nSlotCount ) // 사용중인 슬롯
{
m_vAllSlot.at(i).SetSlot(it->bAchieve, it->bBookMark, it->bUsing, it->nID, it->iStringID, it->bIsNew);
++it;
}
else
{
m_vAllSlot.at(i).SetEmptySlot();
}
}
// 획득 카운트 텍스트
SetAchieveCountText();
// 스크롤 재설정
SetListScrollRange(title.size());
}
void SUITitleWnd::SetAchieveCountText()
{
std::string strToolTip = (S(690000006)); // "획득한 호칭 #@num@#개"
std::string strText = CStringUtil::StringFormat( "<font:font_01><hcenter><size:8><right>%s",S(690000024) ); // "#@num:0#@ 개"
std::string strCount = CStringUtil::StringFormat( "%d",m_TitleMgr.GetAchieveTitleCount() );
// 툴팁
CStringUtil::ReplacePhrase( strToolTip,"#@num@#", strCount );
m_pAchieveCount->SetTooltip( strToolTip.c_str() );
// 텍스트
CStringUtil::ReplacePhrase( strText, "#@num:0#@", strCount );
m_pAchieveCount->SetCaption( strText.c_str() );
}
void SUITitleWnd::SetSubTitleString(int index)
{
for(size_t i=0 ; i<SUB_TITLE_MAX ; ++i)
m_vSubSlot.at(i).SetStringInfo(false);
if( (index >= 0) && ( index <SUB_TITLE_MAX ) )
m_vSubSlot.at(index).SetStringInfo(true);
}
bool SUITitleWnd::InitControls( KPoint kPos )
{
SetCustomMovingRect( GetChild("titlebar")->GetRect() );
InitAllSlot(); // 전체 호칭 목록 컨트롤 생성 및 초기화
InitUsingSlot(); // 사용중인 호칭 목록 컨트롤 생성 및 초기화
initInfoSlot(); // 호칭정보 슬롯 초기화
InitAniName(); // 스프라이트셋 이름을 저장..
InitCoolTime(); // 쿨타임 컨트롤 초기화
InitToolTip(); // 툴팁 초기화
m_msgFp.add(IMSG_UI_TITLE_SET_MAIN, &SUITitleWnd::fpSetMainTitle);
m_msgFp.add(IMSG_UI_TITLE_SET_SUB, &SUITitleWnd::fpSetSubTitle);
m_msgFp.add(IMSG_UI_TITLE_SET_ACHIEVE, &SUITitleWnd::fpSetAchieveTitle);
m_msgFp.add(IMSG_UI_TITLE_SET_OPEN, &SUITitleWnd::fpSetOpenTitle);
m_msgFp.add(IMSG_UI_TITLE_SET_BOOKMARK, &SUITitleWnd::fpSetBookmarkTitle);
m_msgFp.add(IMSG_UI_TITLE_SET_CONDITION, &SUITitleWnd::fpSetConditionTitle);
m_msgFp.add(IMSG_UI_TITLE_SET_COOLTIME, &SUITitleWnd::fpSetCooltime);
m_msgFp.add(IMSG_MOUSEMOVE, &SUITitleWnd::fpMouseMove);
m_msgFp.add(IMSG_UI_TITLE_NEW_ALRAM, &SUITitleWnd::fpNewTitleNotify);
m_msgFp.add(IMSG_UI_TITLE_WND_OPEN, &SUITitleWnd::fpWndOpen);
m_msgFp.add(IMSG_UI_SEND_DATA, &SUITitleWnd::fpReset );
return SUIWnd::InitControls(kPos);
}
void SUITitleWnd::InitToolTip()
{
SetChildTooltip("button_lineup_title_gain",S(690000003)); // 획득 / 미획득 호칭 정렬
SetChildTooltip("button_lineup_title_favorite",S(690000004)); //즐겨찾기 호칭 정렬
//SetChildTooltip("button_lineup_title_favorite_01",S(690000005)); //장착된 호칭 정렬
SetChildTooltip("button_default_view_01",S(690000007)); //기본 정렬
}
void SUITitleWnd::fpSetMainTitle(SGameMessage *pMsg)
{
SIMSG_UI_TITLE_SET_MAIN *pTitleMsg = dynamicCast<SIMSG_UI_TITLE_SET_MAIN*>(pMsg);
if(pTitleMsg)
{
SGameAvatarEx* localPlayer = g_pCurrentGameSystem->GetLocalPlayer();
if( !localPlayer || (localPlayer->GetArID() != pTitleMsg->handle) ) // 내꺼가 아니면 패스
return;
}
else
return;
// 메인 슬롯 장착, 해제
stTitleUsingID usingList = m_TitleMgr.GetEquipList();
stTitleUI *title = m_TitleMgr.GetTitleUiByID(usingList.nMain);
if(title)
m_vMainSlot.at(0).SetSlot(title->bBookMark,title->bUsing, title->nID, title->iStringID);
else
{
m_vMainSlot.at(0).SetShowSlot(false);
title = m_TitleMgr.GetTitleUiByID(usingList.nBeforeMain); // 해제된 아이디를 얻어온다.
}
// 전체 슬롯에서 해당아이디 리프레시
if(title)
{
int nID = title->nID;
std::vector<stAllSlot>::iterator it = m_vAllSlot.begin();
for( ; it != m_vAllSlot.end() ; ++it )
{
if(it->m_iID == nID)
it->SetSlot(title->bAchieve,title->bBookMark,title->bUsing,title->nID,title->iStringID, title->bIsNew);
}
SetInstallSlot();
}
SetSlotInfo(m_iSelectedKind,m_iSelectedSlot,true);
}
void SUITitleWnd::fpSetSubTitle(SGameMessage *pMsg)
{
SIMSG_UI_TITLE_SET_SUB *titleMsg = dynamicCast<SIMSG_UI_TITLE_SET_SUB*>(pMsg);
int index = titleMsg->index;
int id = titleMsg->id;
if(id == 0) // 해제
{
id = m_vSubSlot[index].m_iID;
m_vSubSlot[index].SetShowSlot(false);
}
else // 장착
{
stTitleUI *title = m_TitleMgr.GetTitleUiByID(id);
if(title == NULL)
return;
m_vSubSlot[index].SetSlot(title->bBookMark,title->bUsing,title->nID,title->iStringID);
}
RefreshAllSlotUnit(id);
SetInstallSlot();
SetSlotInfo(m_iSelectedKind,m_iSelectedSlot,true);
}
void SUITitleWnd::RefreshAllSlotUnit(int id)
{
stTitleUI *title = m_TitleMgr.GetTitleUiByID(id);
if(title == NULL)
return;
for(int i=0 ; i<m_vAllSlot.size() ; ++i)
{
if(m_vAllSlot[i].m_iID == id) // 일치하는 아이디 슬롯을 찾아서 설정
{
m_vAllSlot[i].SetSlot(title->bAchieve,title->bBookMark,title->bUsing,title->nID,title->iStringID, title->bIsNew);
break;
}
}
}
void SUITitleWnd::fpSetAchieveTitle(SGameMessage *pMsg)
{
SIMSG_UI_TITLE_SET_ACHIEVE * titleMsg = dynamicCast<SIMSG_UI_TITLE_SET_ACHIEVE*>(pMsg);
std::vector<stAllSlot>::iterator it = m_vAllSlot.begin();
for( ; it != m_vAllSlot.end() ; ++it )
{
if(it->m_iID == titleMsg->id )
{
it->ChangeGain(true,true);
break;
}
}
SetSlotInfo(m_iSelectedKind,m_iSelectedSlot,true);
}
void SUITitleWnd::fpSetOpenTitle(SGameMessage *pMsg)
{
SIMSG_UI_TITLE_SET_OPEN* titleMsg = dynamicCast<SIMSG_UI_TITLE_SET_OPEN*>(pMsg);
stTitleUI *titleUI = m_TitleMgr.GetTitleUiByID(titleMsg->id);
if(titleUI)
{
m_TitleMgr.Refresh();
RefreshAllSlot();
}
}
void SUITitleWnd::fpSetBookmarkTitle(SGameMessage *pMsg)
{
SIMSG_UI_TITLE_SET_BOOKMARK* titleMsg = dynamicCast<SIMSG_UI_TITLE_SET_BOOKMARK*>(pMsg);
// 전체 호칭쪽 리프레시
std::vector<stAllSlot>::iterator it = m_vAllSlot.begin();
for( ; it != m_vAllSlot.end() ; ++it )
{
if(it->m_iID == titleMsg->id )
it->ChangeBookmark( titleMsg->equip );
}
// 장착쪽 리프레시
if(m_vMainSlot.at(0).m_iID == titleMsg->id)
m_vMainSlot.at(0).SetBookmark( titleMsg->equip );
else
{
for(size_t i=0 ; i<SUB_TITLE_MAX ; ++i)
{
if(m_vSubSlot[i].m_iID == titleMsg->id)
{
m_vSubSlot[i].SetBookmark( titleMsg->equip );
break;
}
}
}
SetSlotInfo(m_iSelectedKind,m_iSelectedSlot,true);
}
void SUITitleWnd::fpSetConditionTitle(SGameMessage *pMsg )
{
int pos = m_pScrollInfo->GetPosition(); // 기존의 스크롤 위치를 저장하고
SetSlotInfo(m_iSelectedKind,m_iSelectedSlot,true); // 갱신된 스트링을 셋팅하고
m_InfoSlot.SetShowText(pos); // 원래의 스크롤 위치로 복원한다.
m_pScrollInfo->SetPosition(pos);
}
void SUITitleWnd::fpSetCooltime(SGameMessage *pMsg )
{
SIMSG_UI_TITLE_SET_COOLTIME* titleMsg = dynamicCast<SIMSG_UI_TITLE_SET_COOLTIME*>(pMsg);
if(titleMsg)
SetCoolTime(MAX_COOLTIME*10, ((int)titleMsg->time)*10 );
}
void SUITitleWnd::fpMouseMove(SGameMessage *pMsg)
{
SIMSG_MOUSEMOVE* pMouse = dynamicCast<SIMSG_MOUSEMOVE*>(pMsg);
if(pMsg)
{
m_MouseX = ((int)(short)LOWORD(pMouse->lParam));
m_MouseY = ((int)(short)HIWORD(pMouse->lParam));
}
}
void SUITitleWnd::fpNewTitleNotify(SGameMessage *pMsg)
{
SetSorting(SORTKIND::BASE,std::string("button_default_view_01")); // 기본정렬 시킨다.
}
void SUITitleWnd::fpWndOpen(SGameMessage *pMsg)
{
OpenTitleWnd();
}
void SUITitleWnd::fpReset(SGameMessage *pMsg)
{
SIMSG_UI_SEND_DATA* pData = (SIMSG_UI_SEND_DATA *)pMsg;
if(pData->m_strString == "refresh") // 리프레시 한다.
{
m_bFirstOpen = true;
m_dwBeforeTime = 0;
m_TitleMgr.ResetTitle();
}
}
void SUITitleWnd::InitCoolTime()
{
KUIControlSimpleButton *pBtn = dynamicCast<KUIControlSimpleButton*>(GetChild("button_main_title_unequip_00"));
if(pBtn)
{
KUIWND_CREATE_ARG ClockArg( "clockbox", "main_title_cooltime_99", " ", pBtn->GetRect(), 0, KFLAG_NO_GET_MESSAGE, this, "",
"ui_frame.spr", m_pManager, 0, "", KANCHOR_LEFT | KANCHOR_TOP );
KUIWnd* pWnd = m_pManager->CreateControl( ClockArg );
m_pCooltime = dynamicCast<KUIControlClockBox*>(pWnd);
m_pCooltime->SetColor( c_CoolTimeColor );
m_pCooltime->OnAlphaChangeNotify(0.5f);
}
}
void SUITitleWnd::SetCoolTime(int nMaxTime, int nRemain)
{
//! 여기서 클라 시간을 기록해 놓고 창을 다시 열때 시간을 보정해준다.
if( nRemain > 100 ) //0.1초
m_uiReceivedTime = GetSafeTickCount();
if(m_pCooltime)
{
m_dwCooltimeRemain = nRemain;
m_pCooltime->SetMaxTime( nMaxTime );
m_pCooltime->SetCurTime( nMaxTime - nRemain );
m_pCooltime->Begin();
m_pCooltime->SetShow(true);
m_vMainSlot.at(0).SetBtnState( false ); // 쿨타임이 돌면 버튼이 비활성화 되어야 한다.
m_CooltimeCheck = true;
}
}
void SUITitleWnd::Process(DWORD dwTime)
{
SUIWnd::Process( dwTime );
if(m_dwBeforeTime == 0)
m_dwBeforeTime = dwTime;
// 쿨타임 체크
if(m_CooltimeCheck)
{
//gmpbigsun( 20130305, #26393 ) : 호칭쿨타임 버그, 쿨타임표현 UI의 쿨타임과 this의 쿨타임 2개가 존재한다. 통합하고싶지만 담기회에...
if( m_uiReceivedTime > 0 ) //server로부터 시간을 받은후 최초Process
{
int nVal = GetSafeTickCount() - m_uiReceivedTime;
if( nVal > 0 )
{
//해당 윈도우가 활성화될때 Process가 불리기때문에 이때! 시간을 보정함.
if( nVal > m_dwCooltimeRemain )
m_dwCooltimeRemain = 0;
else m_dwCooltimeRemain -= nVal;
}
m_uiReceivedTime = 0;
//sync
if( m_pCooltime )
m_pCooltime->SetCurTime( m_pCooltime->GetMaxTime() - m_dwCooltimeRemain );
}
//end_sun----------------------------------
if( m_dwCooltimeRemain <= (dwTime-m_dwBeforeTime) )
{
m_CooltimeCheck = false;
m_vMainSlot.at(0).SetBtnState( true );
m_vMainSlot.at(0).m_pUsing->SetTooltip( S(690000002) );
}
else
{
m_dwCooltimeRemain -= (dwTime-m_dwBeforeTime);
DWORD min = m_dwCooltimeRemain/60000;
DWORD sec = (m_dwCooltimeRemain%60000)/1000;
std::string strTime = S(690000001);
CStringUtil::ReplacePhrase(strTime,"#@minutes@#", CStringUtil::StringFormat("%02d",min));
CStringUtil::ReplacePhrase(strTime,"#@seconds@#", CStringUtil::StringFormat("%02d",sec));
m_vMainSlot.at(0).m_pUsing->SetTooltip( strTime.c_str() );
}
}
m_dwBeforeTime = dwTime;
// 스크롤 리프레시
if(m_bScrollRefresh)
{
std::vector<stTitleUI> title = m_TitleMgr.GetTitleUI();
std::vector<stTitleUI>::iterator it= title.begin();
int start = m_ScrollPos;
for(int i=0; i<ALL_TITLE_MAX ; ++i)
{
stTitleUI ui = title[start+i];
m_vAllSlot[i].SetSlot(ui.bAchieve, ui.bBookMark ,ui.bUsing, ui.nID, ui.iStringID, ui.bIsNew);
}
m_bScrollRefresh = false;
}
}
void SUITitleWnd::InitAniName()
{
m_pScrollAll = dynamicCast<KUIControlVScrollSmallEx*>(GetChild("vscroll_title_list"));
m_pScrollInfo = dynamicCast<KUIControlVScrollSmallEx*>(GetChild("vscroll_title_info"));
m_pStaticSortDes = dynamicCast<KUIControlStatic*>(GetChild("mark_sort_up_01"));
m_pStaticSortAse = dynamicCast<KUIControlStatic*>(GetChild("mark_sort_down_01"));
m_pStaticInstallSlot = dynamicCast<KUIControlStatic*>(GetChild("equip_railbox_01"));
m_pListAreaCheck = dynamicCast<KUIControlStatic*>(GetChild("select_list_cyan"));
m_pInfoAreaCheck = dynamicCast<KUIControlStatic*>(GetChild("select_list_cyan_01"));
m_pEquipAeraCheck = dynamicCast<KUIControlStatic*>(GetChild("inframe_rail"));
m_pAchieveCount = dynamicCast<KUIControlStatic*>(GetChild("text_title_gain_num_01"));
c_strSelectBar = GetChild("title_list_select_00")->GetAniName();
c_strMainEquip = GetChild("line_main_title_equip_00")->GetAniName();
c_strMainUnEquip = GetChild("line_main_title_unequip_00")->GetAniName();
c_strSubEquip = GetChild("line_sub_title_equip_00")->GetAniName();
c_strSubUnEquip = GetChild("line_sub_title_unequip_00")->GetAniName();
c_strAllEquip = GetChild("line_title_list_equip_00")->GetAniName();
c_strAllUnEquip = GetChild("line_title_list_00")->GetAniName();
c_strEquipBtn = GetChild("button_title_equip_00")->GetAniName();
c_strUnEquipBtn = GetChild("button_main_title_unequip_00")->GetAniName();
c_strNew = GetChild("new_title_mark_00")->GetAniName();
c_strBookmark = GetChild("mark_main_favorite_able_00")->GetAniName();
c_strNoBookmark = GetChild("mark_sub_favorite_disable_00")->GetAniName();
c_strInfoUnEquip = GetChild("line_title_list_view_00")->GetAniName();
c_strInfoBack = GetChild("line_title_list_view_00")->GetAniName();
}
bool SUITitleWnd::stBaseSlot::IsInRect(int x, int y) {return m_pBack->IsInRect(x, y); } // 뒷배경 안에 클릭이 됐는지 확인
bool SUITitleWnd::stBaseSlot::IsSelectSlot() {return m_bSelected;}
void SUITitleWnd::stBaseSlot::SetSelectFlag(bool bFlag) { m_bSelected = bFlag; }
bool SUITitleWnd::stAllSlot::IsSelectSlot()
{
// 스크롤바 때문에 다른 슬롯과는 다른 처리가 필요
// 슬롯 타입이 같고, 아이디가 같아야 선택된놈이다.
return (SUITitleWnd::m_iSelectedKind == SLOT_KIND::ALL_SLOT) && (SUITitleWnd::m_iSelcetedID == m_iID) ;
}
int SUITitleWnd::stBaseSlot::SelectBar(bool bSelect ,bool bEquip /* = false */)
{
SetSelectFlag(bSelect);
ChangeBar(bEquip);
return m_iID;
}
void SUITitleWnd::stAllSlot::ChangeBar( bool bEquip )
{
if( IsSelectSlot() )
m_pBack->SetAniName( c_strSelectBar.c_str() );
else
m_pBack->SetAniName( bEquip ? c_strAllEquip.c_str() : c_strAllUnEquip.c_str() );
}
void SUITitleWnd::stMainSlot::ChangeBar( bool bEquip )
{
if( IsSelectSlot() )
m_pBack->SetAniName( c_strSelectBar.c_str() );
else
m_pBack->SetAniName( bEquip ? c_strMainEquip.c_str() : c_strMainUnEquip.c_str() );
}
void SUITitleWnd::stSubSlot::ChangeBar( bool bEquip )
{
if( IsSelectSlot() )
m_pBack->SetAniName( c_strSelectBar.c_str() );
else
m_pBack->SetAniName( bEquip ? c_strSubEquip.c_str() : c_strSubUnEquip.c_str() );
}
void SUITitleWnd::stSubSlot::SetBookmark(bool bBookmark)
{
if(bBookmark)
m_pBookMark->SetAniName( c_strBookmark.c_str() );
else
m_pBookMark->SetAniName( c_strNoBookmark.c_str() );
}
void SUITitleWnd::stSubSlot::SetStringInfo(bool bShow)
{
std::string str = (bShow)? CStringUtil::StringFormat("<font:font_01><hcenter><b><vcenter><#265445><size:8>%s",S(690000028)).c_str() : "";
m_pBack->SetCaption( str.c_str() );
}
void SUITitleWnd::stBaseSlot::ChangeEquipBtn( bool bEquip )
{
if(bEquip) // 장착
{
m_pUsing->DisableAndButtonState(KUIControlSimpleButton::KBUTTON_DOWN);
}
else // 비장착
{
m_pUsing->Enable();
m_pUsing->SetButtonState(KUIControlSimpleButton::KBUTTON_NORMAL);
}
}
void SUITitleWnd::stAllSlot::ChangeBookmark(bool bCheck)
{
m_pBookMark->SetCheck(bCheck);
}
void SUITitleWnd::stAllSlot::ChangeGain(bool bGain, bool bNew)
{
if(bNew)
{
m_pGain->SetAniName(c_strNew.c_str());
m_pGain->SetTooltip(S(690000023)); //새로운 호칭
}
else
{
m_pGain->SetTooltipOff();
}
m_pGain->SetShow(bNew);
ChangeControlState(bGain);
}
void SUITitleWnd::stAllSlot::ChangeControlState(bool bEnable)
{
if(bEnable)
{
m_pGain->Enable();
if(!m_pUsing->IsDisable())
m_pUsing->Enable(); // 장착되서 비활성화 일경우에는 활성화되지 않게 한다..
m_pName->Enable();
}
else
{
m_pGain->Disable();
m_pUsing->Disable();
m_pName->Disable();
}
}
void SUITitleWnd::stAllSlot::ShowControl(bool bShow)
{
m_pGain->SetShow(bShow);
m_pUsing->SetShow(bShow);
m_pName->SetShow(bShow);
m_pBookMark->SetShow(bShow);
}
void SUITitleWnd::stAllSlot::SetSlot(bool bGain, bool bBookmark, bool bUsing, int nId, int nStringID, bool bNew)
{
m_iID = nId;
ShowControl(true);
ChangeEquipBtn(bUsing); // 장착 버튼
ChangeBar(bUsing); // 배경
ChangeBookmark(bBookmark);; // 북마크 상태
ChangeGain(bGain,bNew); // 획득 상태
ChangeTitleName(S(nStringID)); // 호칭 이름 변경
}
void SUITitleWnd::stAllSlot::SetEmptySlot()
{
m_iID = -1;
ShowControl(false);
ChangeEquipBtn(false); // 장착 버튼
ChangeBar(false); // 배경
ChangeBookmark(false);; // 북마크 상태
ChangeGain(false,false); // 획득 상태
ChangeTitleName(""); // 호칭 이름 변경
}
void SUITitleWnd::PumpUpTitleBtn(LPCSTR lpszID)
{
std::string strID = lpszID;
int nID = -1;
if( CutButtonID(strID, "button_title_equip_", nID) ) // 1. 장착 버튼
{
if( m_TitleMgr.IsAllEquip() )
return;
if(m_iEmptySlotIndex == -1 && m_iEmptySlotKind == -1) // 장착할 슬롯 없음..
return;
if(m_iEmptySlotKind == SLOT_KIND::MAIN_SLOT) // 메인 슬롯 장착
m_TitleMgr.RequestSetUpMainTitle( m_vAllSlot.at(nID).GetTitleID() );
else // 부 슬롯 장착
m_TitleMgr.RequestSetUpSubtitle( m_vAllSlot.at(nID).GetTitleID() , m_iEmptySlotIndex );
}
else if(CutButtonID(strID, "button_main_title_unequip_", nID) ) // 2. 메인 해제 버튼
m_TitleMgr.RequestSetDownMainTitle();
else if(CutButtonID(strID, "button_sub_title_unequip_", nID) ) // 3. 서브 해제 버튼
m_TitleMgr.RequestSetDownSubtitle( m_vAllSlot.at(nID).GetTitleID() , nID );
else if(CutButtonID(strID, "check_favorite_", nID) ) // 4. 즐겨찾기 장착 해제
m_TitleMgr.RequestSetBookmark( m_vAllSlot.at(nID).GetTitleID() );
}
void SUITitleWnd::SetListScrollRange(int count)
{
m_pScrollAll->SetScrollRange( ALL_TITLE_MAX, count );
}
void SUITitleWnd::OpenTitleWnd()
{
bool bOpen = this->IsShow();
if(bOpen)
{
m_TitleMgr.SetNewTitleClose(); // 닫힐 때 새로운 호칭 체크를 없애야 한다.
}
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_TITLE_MAIN, !bOpen ) );
}
void SUITitleWnd::PumpUpMessage(LPCSTR lpszControlID, DWORD nMessage, DWORD lparam, DWORD wparam)
{
switch( nMessage )
{
case KUI_MESSAGE::KFOCUS_ACTIVATED: // 영역 판정을 해야 한다. 주호칭(1개)부호칭(5개)전체호칭(13개)..
{
IsSlotClick(lparam,wparam);
}break;
case KUI_MESSAGE::KBUTTON_CLICK:
{
if( ::_stricmp( lpszControlID, "button_close" ) == 0 )
OpenTitleWnd();
else
PumpUpTitleBtn(lpszControlID); // 장착, 해제 버튼 처리
}
break;
case KUI_MESSAGE::KCHECK_CHANGE:
{
PumpUpTitleBtn(lpszControlID);
}break;
case KUI_MESSAGE::KBUTTON_PRESSING:
{
if( ::_stricmp( lpszControlID, "button_lineup_title_gain" ) == 0 ) // 획득 순
SetSorting( SORTKIND::GAIN, std::string("button_lineup_title_gain") );
else if( ::_stricmp( lpszControlID, "button_lineup_title_favorite" ) == 0 ) // 즐겨찾기 순
SetSorting(SORTKIND::BOOKMARK, std::string("button_lineup_title_favorite"));
else if( ::_stricmp( lpszControlID, "button_lineup_title_name" ) == 0 ) // 이름 순
SetSorting(SORTKIND::NAME, std::string("button_lineup_title_name"));
//else if( ::_stricmp( lpszControlID, "button_lineup_title_favorite_01" ) == 0 ) // 장착 순 -- 없어짐..
// SetSorting(SORTKIND::USING,std::string("button_lineup_title_favorite_01"));
else if( ::_stricmp( lpszControlID, "button_default_view_01" ) == 0 ) // 기본 정렬..
SetSorting(SORTKIND::BASE,std::string("button_default_view_01"));
}break;
case KUI_MESSAGE::KGENWND_MOVE:
{
LimitMoveWnd();
}break;
case KUI_MESSAGE::KSCROLL_SELECT:
{
SetScroll(lpszControlID, lparam);
}break;
}
}
void SUITitleWnd::SetScroll(LPCSTR lpszControlID, DWORD lparam)
{
if( ::_stricmp( lpszControlID, "vscroll_title_list" ) == 0 )
{
if(m_pListAreaCheck->IsInRect(m_MouseX,m_MouseY) == false)
{
m_pScrollAll->SetPosition(m_ScrollPos);
return;
}
std::vector<stTitleUI> title = m_TitleMgr.GetTitleUI();
std::vector<stTitleUI>::iterator it= title.begin();
if(title.size() < ALL_TITLE_MAX)
return;
int nPos = int(lparam); // 스크롤 리프레시는 process에서
m_ScrollPos = max( nPos, 0 );
m_bScrollRefresh = true;
}
else if( ::_stricmp( lpszControlID, "vscroll_title_info" ) == 0 )
{
if(m_pInfoAreaCheck->IsInRect(m_MouseX,m_MouseY) == false)
{
m_pScrollInfo->SetPosition(m_InfoScrollPos);
return;
}
int nPos = int(lparam);
m_InfoScrollPos = max( nPos, 0 );
m_InfoSlot.SetShowText(nPos);
}
}
void SUITitleWnd::SetSorting( int nKind, std::string strCtrl )
{
int nState = m_TitleMgr.ReQuestSorting(nKind);
RefreshAllSlot();
ChangeSmall(nKind, nState, strCtrl);
m_pScrollAll->SetPosition(0);
}
void SUITitleWnd::ChangeSmall(int nKind, int nState, std::string strCtrl)
{
m_pStaticSortAse->SetShow(false);
m_pStaticSortDes->SetShow(false);
if(nKind != SORTKIND::BASE && nState != SORTSTATE::NONE)
{
KRect rc = GetChild(strCtrl.c_str())->GetRect();
if( nState == SORTSTATE::DES)
{
m_pStaticSortDes->SetShow(true);
m_pStaticSortDes->MovePos(rc.left, rc.top);
}
else
{
m_pStaticSortAse->SetShow(true);
m_pStaticSortAse->MovePos(rc.right - m_pStaticSortAse->GetRect().GetWidth() ,
rc.bottom - m_pStaticSortAse->GetRect().GetHeight() );
}
}
}
DWORD SUITitleWnd::OnMouseMessage(DWORD dwMessage, int x, int y)
{
switch( dwMessage )
{
case KMOUSE_MOVE :
{
IsSlotOver( x, y );
}break;
}
return SUIWnd::OnMouseMessage(dwMessage, x, y);
}
void SUITitleWnd::InitAllSlot()
{
// 전체호칭 리스트 컨트롤을 만들고 위치 설정을 한다.
KRect pos[ALL_SLOT_CONTROL_NUM];
for(size_t i=0 ; i<ALL_TITLE_MAX ; ++i)
{
stAllSlot slot;
// 첫번째 슬롯은 만들어져 있으니까 포인터만 얻고 나머지는 복사를 한다.
if(i==0)
{
slot.m_pBack = dynamicCast<KUIControlStatic*>(GetChild(CStringUtil::StringFormat("%s%02d",s_szAllSlotControlName[TITLE_SLOT::BACK],i).c_str()));
slot.m_pBookMark = dynamicCast<KUIControlCheck*>(GetChild(CStringUtil::StringFormat("%s%02d",s_szAllSlotControlName[TITLE_SLOT::BOOKMARK],i).c_str()));
slot.m_pGain = dynamicCast<KUIControlStatic*>(GetChild(CStringUtil::StringFormat("%s%02d",s_szAllSlotControlName[TITLE_SLOT::GAIN],i).c_str()));
slot.m_pName = dynamicCast<KUIControlStatic*>(GetChild(CStringUtil::StringFormat("%s%02d",s_szAllSlotControlName[TITLE_SLOT::NAME],i).c_str()));
slot.m_pUsing = dynamicCast<KUIControlSimpleButton*>(GetChild(CStringUtil::StringFormat("%s%02d",s_szAllSlotControlName[TITLE_SLOT::USING],i).c_str()));
pos[TITLE_SLOT::BACK] = slot.m_pBack->GetRect();
pos[TITLE_SLOT::BOOKMARK] = slot.m_pBookMark->GetRect();
pos[TITLE_SLOT::GAIN] = slot.m_pGain->GetRect();
pos[TITLE_SLOT::NAME] = slot.m_pName->GetRect();
pos[TITLE_SLOT::USING] = slot.m_pUsing->GetRect();
}
else
{
CopyControl( CStringUtil::StringFormat("%s%02d",s_szAllSlotControlName[TITLE_SLOT::BACK],0 ).c_str(),
CStringUtil::StringFormat("%s%02d",s_szAllSlotControlName[TITLE_SLOT::BACK],i).c_str() ,KRect(0,0,0,0) );
CopyControl( CStringUtil::StringFormat("%s%02d",s_szAllSlotControlName[TITLE_SLOT::BOOKMARK],0 ).c_str(),
CStringUtil::StringFormat("%s%02d",s_szAllSlotControlName[TITLE_SLOT::BOOKMARK],i).c_str() ,KRect(0,0,0,0) );
CopyControl( CStringUtil::StringFormat("%s%02d",s_szAllSlotControlName[TITLE_SLOT::GAIN],0 ).c_str(),
CStringUtil::StringFormat("%s%02d",s_szAllSlotControlName[TITLE_SLOT::GAIN],i).c_str() ,KRect(0,0,0,0) );
CopyControl( CStringUtil::StringFormat("%s%02d",s_szAllSlotControlName[TITLE_SLOT::NAME],0 ).c_str(),
CStringUtil::StringFormat("%s%02d",s_szAllSlotControlName[TITLE_SLOT::NAME],i).c_str() ,KRect(0,0,0,0) );
CopyControl( CStringUtil::StringFormat("%s%02d",s_szAllSlotControlName[TITLE_SLOT::USING],0 ).c_str(),
CStringUtil::StringFormat("%s%02d",s_szAllSlotControlName[TITLE_SLOT::USING],i).c_str() ,KRect(0,0,0,0) );
slot.m_pBack = dynamicCast<KUIControlStatic*>(GetChild(CStringUtil::StringFormat("%s%02d",s_szAllSlotControlName[TITLE_SLOT::BACK],i).c_str()));
slot.m_pBookMark = dynamicCast<KUIControlCheck*>(GetChild(CStringUtil::StringFormat("%s%02d",s_szAllSlotControlName[TITLE_SLOT::BOOKMARK],i).c_str()));
slot.m_pGain = dynamicCast<KUIControlStatic*>(GetChild(CStringUtil::StringFormat("%s%02d",s_szAllSlotControlName[TITLE_SLOT::GAIN],i).c_str()));
slot.m_pName = dynamicCast<KUIControlStatic*>(GetChild(CStringUtil::StringFormat("%s%02d",s_szAllSlotControlName[TITLE_SLOT::NAME],i).c_str()));
slot.m_pUsing = dynamicCast<KUIControlSimpleButton*>(GetChild(CStringUtil::StringFormat("%s%02d",s_szAllSlotControlName[TITLE_SLOT::USING],i).c_str()));
slot.m_pBack->MovePos( pos[TITLE_SLOT::BACK].left, pos[TITLE_SLOT::BACK].top + i*ALL_TITLE_DELTA_Y );
slot.m_pBookMark->MovePos( pos[TITLE_SLOT::BOOKMARK].left, pos[TITLE_SLOT::BOOKMARK].top + i*ALL_TITLE_DELTA_Y );
slot.m_pGain->MovePos( pos[TITLE_SLOT::GAIN].left, pos[TITLE_SLOT::GAIN].top + i*ALL_TITLE_DELTA_Y );
slot.m_pName->MovePos( pos[TITLE_SLOT::NAME].left, pos[TITLE_SLOT::NAME].top + i*ALL_TITLE_DELTA_Y );
slot.m_pUsing->MovePos( pos[TITLE_SLOT::USING].left, pos[TITLE_SLOT::USING].top + i*ALL_TITLE_DELTA_Y );
}
slot.m_pUsing->SetTooltip(S(690000008)); //호칭 장착
slot.m_pBookMark->SetTooltip(S(690000009)); //즐겨찾기
m_vAllSlot.push_back(slot);
}
}
void SUITitleWnd::InitUsingSlot()
{
// 주호칭 컨트롤 포인터를 저장
stMainSlot mainSlot;
mainSlot.m_pBack = dynamicCast<KUIControlStatic*>(GetChild(CStringUtil::StringFormat("%s%02d",s_szMainSlotControlName[TITLE_SLOT::BACK],0).c_str()));
mainSlot.m_pBookMark = dynamicCast<KUIControlStatic*>(GetChild(CStringUtil::StringFormat("%s%02d",s_szMainSlotControlName[TITLE_SLOT::BOOKMARK],0).c_str()));
mainSlot.m_pName = dynamicCast<KUIControlStatic*>(GetChild(CStringUtil::StringFormat("%s%02d",s_szMainSlotControlName[TITLE_SLOT::NAME],0).c_str()));
mainSlot.m_pUsing = dynamicCast<KUIControlSimpleButton*>(GetChild(CStringUtil::StringFormat("%s%02d",s_szMainSlotControlName[TITLE_SLOT::USING],0).c_str()));
mainSlot.m_pUsing->SetTooltip(S(690000002)); //장착된 호칭 해제
m_vMainSlot.push_back(mainSlot);
// 부호칭 컨트롤 을 만들고 위치설정을 해준다.
KRect pos[USING_SLOT_CONTROL_NUM];
for(size_t i=0 ; i<SUB_TITLE_MAX ; ++i)
{
stSubSlot slot;
// 첫번째 슬롯은 만들어져 있으니까 포인터만 얻고 나머지는 복사를 한다.
if(i==0)
{
slot.m_pBack = dynamicCast<KUIControlStatic*>(GetChild(CStringUtil::StringFormat("%s%02d",s_szSubSlotControlName[TITLE_SLOT::BACK],i).c_str()));
slot.m_pBookMark = dynamicCast<KUIControlStatic*>(GetChild(CStringUtil::StringFormat("%s%02d",s_szSubSlotControlName[TITLE_SLOT::BOOKMARK],i).c_str()));
slot.m_pName = dynamicCast<KUIControlStatic*>(GetChild(CStringUtil::StringFormat("%s%02d",s_szSubSlotControlName[TITLE_SLOT::NAME],i).c_str()));
slot.m_pUsing = dynamicCast<KUIControlSimpleButton*>(GetChild(CStringUtil::StringFormat("%s%02d",s_szSubSlotControlName[TITLE_SLOT::USING],i).c_str()));
// 첫번째 슬롯의 위치를 기준으로 나머지 위치를 정해주므로 저장해둔다.
pos[TITLE_SLOT::BACK] = slot.m_pBack->GetRect();
pos[TITLE_SLOT::BOOKMARK] = slot.m_pBookMark->GetRect();
pos[TITLE_SLOT::NAME] = slot.m_pName->GetRect();
pos[TITLE_SLOT::USING] = slot.m_pUsing->GetRect();
}
else
{
CopyControl( CStringUtil::StringFormat("%s%02d",s_szSubSlotControlName[TITLE_SLOT::BACK],0 ).c_str(),
CStringUtil::StringFormat("%s%02d",s_szSubSlotControlName[TITLE_SLOT::BACK],i).c_str() ,KRect(0,0,0,0) );
CopyControl( CStringUtil::StringFormat("%s%02d",s_szSubSlotControlName[TITLE_SLOT::BOOKMARK],0 ).c_str(),
CStringUtil::StringFormat("%s%02d",s_szSubSlotControlName[TITLE_SLOT::BOOKMARK],i).c_str() ,KRect(0,0,0,0) );
CopyControl( CStringUtil::StringFormat("%s%02d",s_szSubSlotControlName[TITLE_SLOT::NAME],0 ).c_str(),
CStringUtil::StringFormat("%s%02d",s_szSubSlotControlName[TITLE_SLOT::NAME],i).c_str() ,KRect(0,0,0,0) );
CopyControl( CStringUtil::StringFormat("%s%02d",s_szSubSlotControlName[TITLE_SLOT::USING],0 ).c_str(),
CStringUtil::StringFormat("%s%02d",s_szSubSlotControlName[TITLE_SLOT::USING],i).c_str() ,KRect(0,0,0,0) );
slot.m_pBack = dynamicCast<KUIControlStatic*>(GetChild(CStringUtil::StringFormat("%s%02d",s_szSubSlotControlName[TITLE_SLOT::BACK],i).c_str()));
slot.m_pBookMark = dynamicCast<KUIControlStatic*>(GetChild(CStringUtil::StringFormat("%s%02d",s_szSubSlotControlName[TITLE_SLOT::BOOKMARK],i).c_str()));
slot.m_pName = dynamicCast<KUIControlStatic*>(GetChild(CStringUtil::StringFormat("%s%02d",s_szSubSlotControlName[TITLE_SLOT::NAME],i).c_str()));
slot.m_pUsing = dynamicCast<KUIControlSimpleButton*>(GetChild(CStringUtil::StringFormat("%s%02d",s_szSubSlotControlName[TITLE_SLOT::USING],i).c_str()));
slot.m_pBack->MovePos( pos[TITLE_SLOT::BACK].left, pos[TITLE_SLOT::BACK].top + i*SUB_TITLE_DELTA_Y );
slot.m_pBookMark->MovePos( pos[TITLE_SLOT::BOOKMARK].left, pos[TITLE_SLOT::BOOKMARK].top + i*SUB_TITLE_DELTA_Y );
slot.m_pName->MovePos( pos[TITLE_SLOT::NAME].left, pos[TITLE_SLOT::NAME].top + i*SUB_TITLE_DELTA_Y );
slot.m_pUsing->MovePos( pos[TITLE_SLOT::USING].left, pos[TITLE_SLOT::USING].top + i*SUB_TITLE_DELTA_Y );
}
slot.m_pUsing->SetTooltip(S(690000002)); //장착된 호칭 해제
m_vSubSlot.push_back(slot);
}
}
void SUITitleWnd::initInfoSlot()
{
m_InfoSlot.m_pBack = dynamicCast<KUIControlStatic*>(GetChild(CStringUtil::StringFormat("%s%02d",s_szInfoSlotControlName[TITLE_SLOT::BACK],0).c_str()));
m_InfoSlot.m_pBookMark = dynamicCast<KUIControlStatic*>(GetChild(CStringUtil::StringFormat("%s%02d",s_szInfoSlotControlName[TITLE_SLOT::BOOKMARK],0).c_str()));
m_InfoSlot.m_pName = dynamicCast<KUIControlStatic*>(GetChild(CStringUtil::StringFormat("%s%02d",s_szInfoSlotControlName[TITLE_SLOT::NAME],0).c_str()));
m_InfoSlot.m_pUsing = dynamicCast<KUIControlStatic*>(GetChild(CStringUtil::StringFormat("%s%02d",s_szInfoSlotControlName[TITLE_SLOT::USING],0).c_str()));
m_InfoSlot.m_pScrollInfo = dynamicCast<KUIControlVScrollSmallEx*>(GetChild("vscroll_title_info"));
m_InfoSlot.m_pText = dynamicCast<KUIControlStatic*>(GetChild("info_text_01"));
m_InfoSlot.m_pEmptyText = dynamicCast<KUIControlStatic*>(GetChild("info_empty_text_01"));
m_InfoSlot.m_pText->SetCaption("");
}
void SUITitleWnd::stInfoSlot::SetDetailText(std::string _str)
{
int pos = 0;
m_vString.clear();
std::string str = "<font:font_01><top>";
str += _str;
SetTextList(INFO_TEXT_LINE_NUM, str,std::string(),"font_01" ,(KUIControl*)m_pText, (KUIControlScrollBase*)m_pScrollInfo,pos, m_vString, true);
}
void SUITitleWnd::stInfoSlot::SetShowText(int pos)
{
SetTextList(INFO_TEXT_LINE_NUM, std::string(),std::string(),"font_01" ,(KUIControl*)m_pText, (KUIControlScrollBase*)m_pScrollInfo,pos, m_vString, false);
}
bool SUITitleWnd::stInfoSlot::IsSameId(int id)
{
if(m_curID == id)
return true;
else
{
m_curID = id;
return false;
}
}
void SUITitleWnd::IsSlotClick(DWORD _x, DWORD _y)
{
int nKind = SLOT_KIND::NONE_SLOT;
int nSlotNum = SLOT_KIND::NONE_SLOT;
if( IsInSlotRect(_x,_y,nKind,nSlotNum))
MoveSelectBar(nKind, nSlotNum);
}
void SUITitleWnd::IsSlotOver(DWORD x, DWORD y)
{
if( (m_pEquipAeraCheck->IsInRect(x,y) == false) && (m_pListAreaCheck->IsInRect(x,y) == false ) &&(m_pInfoAreaCheck->IsInRect(x,y) == false) ) // 체크영역이 아닐경우 리턴
return;
int nKind = SLOT_KIND::NONE_SLOT;
int nSlotNum = SLOT_KIND::NONE_SLOT;
if( IsInSlotRect( x, y, nKind, nSlotNum ))
SetSlotInfo( nKind, nSlotNum );
else
{
if(m_iSelectedKind == SLOT_KIND::MAIN_SLOT)
SetSlotInfo(m_iSelectedKind,m_iSelectedSlot);
else if(m_iSelectedKind == SLOT_KIND::SUB_SLOT)
SetSlotInfo(m_iSelectedKind,m_iSelectedSlot);
else if(m_iSelectedKind == SLOT_KIND::ALL_SLOT)
SetSlotInfoWithID(m_iSelcetedID);
}
}
void SUITitleWnd::SetSlotInfo(int _nKind, int _nSlotNum, bool refresh /* = false */)
{
static int nKind = -1;
static int nSlotNum = -1;
if(refresh == false) // 리프레시가 아니고
{
if(nKind == _nKind && nSlotNum == _nSlotNum) // 동일한 슬롯은 리턴
return;
}
// 종류,인덱스 저장
nKind = _nKind;
nSlotNum = _nSlotNum;
// 호칭 아이디 얻고
int nId = GetTitleID(nKind,nSlotNum);
SetSlotInfoWithID(nId,refresh);
}
void SUITitleWnd::SetSlotInfoWithID(int nId, bool refresh /* = false */)
{
if(!refresh)
{
if(m_InfoSlot.IsSameId(nId))
return;
}
// 슬롯 정보
stTitleUI *pTitle = NULL;
pTitle = m_TitleMgr.GetTitleUiByID(nId);
if(pTitle)
{
m_InfoSlot.SetShow(true);
m_InfoSlot.SetInfo(pTitle);
// 선택된 호칭 상세 정보
std::string strDetailInfo;
if( GetDetailInfoString( nId,strDetailInfo ) )
{
// 스트링을 잘라서 넣어줘야 한다....
m_InfoSlot.SetDetailText( strDetailInfo );
}
}
else
{
m_InfoSlot.SetShow(false);
m_pScrollInfo->SetScrollRange( 0,0 );
}
}
// 호칭 정보 상세 스트링 얻기
bool SUITitleWnd::GetDetailInfoString(int nID, std::string& strDetailInfo)
{
stTitleRes titleRes;
if( m_TitleMgr.getTitleRes(nID, titleRes) )
{
strDetailInfo += CStringUtil::StringFormat("<font:font_01><size:8><#898989><b>[%s]<br>",S(690000021) ); // 효과
strDetailInfo += "<#ffffff><size:8>";
strDetailInfo += getOptionString(titleRes); // 추가 성능
strDetailInfo += CStringUtil::StringFormat( "<br><br><size:8><#898989><b>[%s]<br>", S(9543) ) ; // 9543 획득 조건
strDetailInfo += "<#ffffff>";
strDetailInfo += getGainConditionString(titleRes); // 획득 조건
return true;
}
return false;
}
// 추가 성능 스트링 얻기
std::string SUITitleWnd::getOptionString(stTitleRes res)
{
TitleResource titleRes = res.m_title;
std::string strRet = "";
// 추가 성능 값 넣고
bool isBeforeOpt = false;
for(int i=0 ; i<8 ; ++i) // TitleResource 의 추가 성능이 8개이다..
{
if(titleRes.opt_type[i] == 0)
break;
if(isBeforeOpt)
strRet += "<br>"; // 옵션이 여러가지일 경우 줄바꿈이 안되므로 체크해서 넣자.
std::string strGet = "#@bitset_text@#";
m_pDisplayInfo->getTitleEffectInfo( strGet, titleRes.opt_type[i], titleRes.opt_var1[i], titleRes.opt_var2[i] );
strGet = " " + strGet;
CStringUtil::ReplacePhrase(strGet,"/","<br><size:8>");
strRet += "<size:8>";
strRet += strGet;
isBeforeOpt = true;
}
if( titleRes.rate >= c_Available_SUbTitle_Max_Rank ) // 6랭크 이상은 부호칭으로 사용 불가 메세지를 뿌린다.
{
strRet += "<br>";
strRet += S(690000013);
}
// 특수 성능 넣는다.
if(titleRes.effect_id)
{
SItemEffectResourceDB::FoundResult found;
GetItemEffectResourceDB().Find( titleRes.effect_id, found );
SItemEffectResourceDB::FoundResult::iterator it = found.begin();
ItemEffectResource const* reso = *it;
strRet += S(reso->tooltip_id);
CStringUtil::ReplacePhrase(strRet,"<br>","<br><size:8>");
CStringUtil::ReplacePhrase(strRet,"<BR>","<br><size:8>");
}
return strRet;
}
// 획득 조건 스트링 얻기
std::string SUITitleWnd::getGainConditionString(stTitleRes _res)
{
stTitleRes res = _res;
std::string strDescripton = "<size:8>";
strDescripton += S(res.m_title.tooltip_id); // 획득 조건 설명
strDescripton += "<br>";
strDescripton +="<size:8>";
if(res.m_title.status_id != 82010204 ) // 상태 text가 비어 있는 경우
{
for( size_t i=0 ; i <res.vCondition.size() ; ++i)
{
if( res.vCondition[i].IsAchieveCondition() )
{
std::string tag = S(res.m_title.status_id);
if(tag.compare("0") == 0) // 획득조건에 아무것도 안들어간 경우가 있다.
break;
__int64 curCount = ( res.vCondition[i].nCurCount > res.vCondition[i].nCount )? res.vCondition[i].nCount: res.vCondition[i].nCurCount; // 2234/1000 일경우 2234를 1000으로 출력
CStringUtil::ReplacePhrase(tag,"#@num:0@#", CStringUtil::StringFormat("%I64d",res.vCondition[i].nCount) );
CStringUtil::ReplacePhrase(tag,"#@m_status:0@#", CStringUtil::StringFormat("%I64d", curCount ) );
CStringUtil::ReplacePhrase(tag,"#@i_item:0@#","#@i_name:0@#");
std::string strCondition = ParserTitleText( tag.c_str(), res.vCondition[i].nTypeID ); // 상세 조건
strDescripton += strCondition;
strDescripton += "<br><size:8>";
}
}
}
return strDescripton;
}
int SUITitleWnd::GetTitleID(int _nKind, int _nSlotNum)
{
int nID;
if(_nKind == SLOT_KIND::MAIN_SLOT)
nID = m_vMainSlot.at(0).GetTitleID();
else if(_nKind == SLOT_KIND::SUB_SLOT)
nID = m_vSubSlot.at(_nSlotNum).GetTitleID();
else if(_nKind == SLOT_KIND::ALL_SLOT)
nID = m_vAllSlot.at(_nSlotNum).GetTitleID();
else
nID = -1;
return nID;
}
void SUITitleWnd::stInfoSlot::SetInfo(const TITLEMGR::stTitleUI *ptitle)
{
// 아이디가 없다면 빈슬롯
if(ptitle == NULL)
SetShow(false);
else
{
SetShow(true);
m_pName->Enable();
m_pBack->SetAniName( (ptitle->bUsing)? c_strAllEquip.c_str() : c_strInfoUnEquip.c_str() );
m_pBookMark->SetAniName( (ptitle->bBookMark)? c_strBookmark.c_str() : c_strNoBookmark.c_str() );
m_pName->SetCaption( CStringUtil::StringFormat( "<font:font_02><hcenter><vcenter><#ffffff><size:9>%s",S(ptitle->iStringID) ).c_str() );
(ptitle->bUsing)? m_pUsing->SetShow(true) : m_pUsing->SetShow(false);
(ptitle->bAchieve)? m_pName->Enable() : m_pName->Disable();
}
}
void SUITitleWnd::stInfoSlot::SetShow(bool bShow)
{
if(bShow == false)
m_pBack->SetAniName( c_strInfoBack.c_str() );
m_pEmptyText->SetShow(!bShow);
m_pBack->SetShow(bShow);
m_pBookMark->SetShow(bShow);
m_pName->SetShow(bShow);
m_pUsing->SetShow(bShow);
m_pText->SetShow(bShow);
}
bool SUITitleWnd::IsInSlotRect(DWORD _x, DWORD _y, int &nKind, int &nSlotNum)
{
int x = (int)_x;
int y = (int)_y;
if( m_pListAreaCheck->IsInRect(x,y) ) // 전체 호칭 리스트 안인가?
{
for(int i=0 ; i<ALL_TITLE_MAX ; ++i)
{
if( m_vAllSlot.at(i).IsInRect(x,y) )
{
nKind = SLOT_KIND::ALL_SLOT;
nSlotNum = i;
break;
}
}
}
else if(m_pEquipAeraCheck->IsInRect(x,y)) // 사용중인 호칭 리스트 안인가?
{
if( m_vMainSlot.at(0).IsInRect(x,y) ) // 주 호칭
{
nKind = SLOT_KIND::MAIN_SLOT;
nSlotNum = 0;
}
else // 부 호칭
{
for(int i=0 ; i<SUB_TITLE_MAX ; ++i)
{
if( m_vSubSlot.at(i).IsInRect(x,y) )
{
nKind = SLOT_KIND::SUB_SLOT;
nSlotNum = i;
}
}
}
}
if(nKind != SLOT_KIND::NONE_SLOT && nSlotNum != SLOT_KIND::NONE_SLOT)
return true;
else
return false;
}
void SUITitleWnd::MoveSelectBar(int kind, int nSlot /* = 0 */)
{
//if(m_iSelectedKind == kind && m_iSelectedSlot == nSlot )
// return;
if( IsEmptySlot( kind, nSlot) )
return;
int beforeKind = m_iSelectedKind;
int beforeSlot = m_iSelectedSlot;
int beforeID = m_iSelcetedID;
setSelectiedKind(kind);
setSelectedSlot(nSlot);
// 선택된 놈 셀렉트 상태로
if( kind == SLOT_KIND::MAIN_SLOT )
{
m_iSelcetedID = m_vMainSlot.at(nSlot).SelectBar(true);
}
else if( kind == SLOT_KIND::SUB_SLOT )
m_iSelcetedID = m_vSubSlot.at(nSlot).SelectBar(true);
else if( kind == SLOT_KIND::ALL_SLOT)
{
m_iSelcetedID = m_vAllSlot.at(nSlot).m_iID;
m_vAllSlot.at(nSlot).SelectBar(true);
SetSlotInfo(kind,nSlot,true);
}
bool bEquip = m_TitleMgr.IsEquipID(beforeID);
// 이전 셀렉트는 언셀렉트
if( beforeKind != -1 )
{
if( beforeKind == SLOT_KIND::MAIN_SLOT )
m_vMainSlot.at(beforeSlot).SelectBar(false,bEquip);
else if( beforeKind == SLOT_KIND::SUB_SLOT )
m_vSubSlot.at(beforeSlot).SelectBar(false,bEquip);
else if( beforeKind == SLOT_KIND::ALL_SLOT)
{
for(int i=0 ; i<ALL_TITLE_MAX ; ++i)
{
if(m_vAllSlot[i].m_iID == beforeID)
{
m_vAllSlot[i].SelectBar(false,bEquip);
}
}
}
}
}
// 빈슬롯을 클릭했다면 true 리턴
bool SUITitleWnd::IsEmptySlot( int kind, int nSlot )
{
if( kind == SLOT_KIND::MAIN_SLOT )
{
if( m_vMainSlot.at(0).m_iID == SLOT_KIND::NONE_SLOT )
return true;
}
else if( kind == SLOT_KIND::SUB_SLOT )
{
if( m_vSubSlot.at(nSlot).m_iID == SLOT_KIND::NONE_SLOT )
return true;
}
else if( kind == SLOT_KIND::ALL_SLOT)
{
if( m_vAllSlot.at(nSlot).m_iID == SLOT_KIND::NONE_SLOT )
return true;
}
return false;
}
///////////////////////////////////////////////////////////////// 호칭 획득 결과 알림 창 //////////////////////////////////////////////////////////////////////////
SUITitleGainResultWnd::SUITitleGainResultWnd( SGameManager* pGameManager )
:SUIWnd(pGameManager), m_fTitleAlpha(0.0f)
{
}
bool SUITitleGainResultWnd::InitData( bool bReload )
{
m_pShowText = dynamicCast<KUIControlStatic*>(GetChild("title_gain_text_01"));
m_pOutFrame = dynamicCast<KUIControlStatic*>(GetChild("outframe"));
return SUIWnd::InitData(bReload);
}
void SUITitleGainResultWnd::MovePosCustom(KSize size)
{
// 가로 중앙위치, 세로 2/3 정도 위치
this->MovePos( (size.width-GetRect().GetWidth())/2 , size.height*3/5 );
}
void SUITitleGainResultWnd::SetAlpha(int type, DWORD dwTime)
{
switch( type )
{
case TITLE_ALPHA::ALPHA_1:
{
m_fTitleAlpha = 1.0f;
}break;
case TITLE_ALPHA::ALPHA_DEC:
{
m_fTitleAlpha -= AlphaTimeCal(dwTime);
}break;
}
if(m_pOutFrame) m_pOutFrame->ChangeAlpha(m_fTitleAlpha);
if(m_pShowText) m_pShowText->ChangeAlpha(m_fTitleAlpha);
}
float SUITitleGainResultWnd::AlphaTimeCal(DWORD dwTime)
{
std::vector<stTitleList>::iterator it = m_vTitle.begin();
DWORD elapsedtime = dwTime - it->dwBeforeTime;
it->dwBeforeTime = dwTime;
float t = (float)elapsedtime/1000.0f;
return t*c_fFadeSpeed;
}
bool SUITitleGainResultWnd::IsTitleRemain()
{
return !m_vTitle.empty();
}
void SUITitleGainResultWnd::Process(DWORD dwTime)
{
if( g_bRenderUI == false ) // UI가 그려지고 있지 않을 때는 process를 돌리지 않는다.
return;
SUIWnd::Process( dwTime );
if(IsTitleRemain())
{
std::vector<stTitleList>::iterator it = m_vTitle.begin();
// 무조건 첫번째 놈이 그려지고 있어야 하므로
switch ( it->nState )
{
case TITLE_DATA::STATE_WAIT: // 대기 상태
{
SetAlpha(TITLE_ALPHA::ALPHA_1);
m_dwStartTime = dwTime;
m_pShowText->SetCaption(it->strTitleName.c_str());
it->nState = TITLE_DATA::STATE_SHOW;
}
break;
case TITLE_DATA::STATE_SHOW: // 보여지고 있는 상태
{
// showtime 이 넘어가면 상태 변경
if( ( dwTime - m_dwStartTime ) > c_dwShowTime )
{
it->dwBeforeTime = dwTime;
it->nState = TITLE_DATA::STATE_FADE;
}
}break;
case TITLE_DATA::STATE_FADE: // 페이드 아웃 되고 있는 상태
{
SetAlpha(TITLE_ALPHA::ALPHA_DEC,dwTime);
// 페이드 아웃이 끝났으면 삭제
if( m_fTitleAlpha < 0.0f )
{
m_vTitle.erase(it);
if(IsTitleRemain() == false)
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_TITLE_GAIN_RESULT, false ) );
}
}
}
}
}
//2012. 4. 5 - marine 해당스트링을 만들어서 벡터에 넣어두자.
void SUITitleGainResultWnd::PushTitle( std::string str )
{
stTitleList title;
title.strTitleName = c_strTitleNotifyTag + str;
m_vTitle.push_back(title);
}
void SUITitleGainResultWnd::ProcMsgAtStatic( SGameMessage* pMsg )
{
switch( pMsg->nType )
{
case IMSG_UI_TITLE_GAIN_NOTIFY:
{
SIMSG_UI_TITLE_GAIN_NOTIFY* msg = dynamicCast<SIMSG_UI_TITLE_GAIN_NOTIFY*>(pMsg);
if(msg)
{
PushTitle(msg->str);
if(m_pGameManager->IsShow(SIMSG_TOGGLE_UIWINDOW::UIWINDOW_TITLE_GAIN_RESULT) == false)
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_TITLE_GAIN_RESULT, true ) );
}
}break;
}
}