1528 lines
43 KiB
C++
1528 lines
43 KiB
C++
|
|
#include "stdafx.h"
|
|
|
|
#include "KUIControlStatic.h"
|
|
//#include "KUIControl.h"
|
|
#include "KUIControlScroll.h"
|
|
|
|
#include "SGameManager.h"
|
|
#include "SGameMessage.h"
|
|
//#include "SGameMessageUI.h"
|
|
#include "SkillBaseFile.h"
|
|
#include "SItemDB.h"
|
|
#include "SQuestDB.h"
|
|
#include "SStringDB.h"
|
|
#include "SUISysMsgDefine.h"
|
|
#include "SUIQuestInfoWnd.h"
|
|
#include "SQuestMgr.h"
|
|
#include "SUIDisplayInfo.h"
|
|
#include "SPlayerInfoMgr.h"
|
|
#include "SInventoryMgr.h"
|
|
// 2010.06.04 epic6에서 갖고옵 - prodongi
|
|
#include "SGameSystem.h"
|
|
#include "SGameAvatarEx.h"
|
|
#include <toolkit/XStringUtil.h>
|
|
#include "SGameInterface.h"
|
|
#include "KUIControlButton.h"
|
|
#include "STitleMgr.h"
|
|
#include "SUILazyTooltip.h"
|
|
#include "SUIChattingWnd.h"
|
|
|
|
namespace
|
|
{
|
|
//const char* c_szStaticExp = "static_exp";
|
|
//const char* c_szStaticJp = "static_jp";
|
|
//const char* c_szStaticRupy = "static_rupy";
|
|
|
|
//이유는 모르지만 prev,next가 잘못 처리 되어있다 =_=
|
|
const char* c_szQuestPrevButton = "quest_smallbutton_next";
|
|
const char* c_szQuestNextButton = "quest_smallbutton_pre";
|
|
|
|
const char* c_szQuestYesButton = "quest_button_yes";
|
|
const char* c_szQuestNoButton = "quest_button_no";
|
|
|
|
const char* c_szQuestConfirmButton = "quest_button_confirm";
|
|
|
|
const char* c_szQuestPage = "quest_page_number";
|
|
|
|
unsigned int c_nPageStringSizeMax = 400;
|
|
|
|
const unsigned int c_nImgCountMax = 10;
|
|
/// 한 페이지당 최대 라인 수
|
|
//const int MAX_STORY_LINE_COUNT = 13;
|
|
/// 2012.08.07 텍스트가 넘어가서 12줄로 수정함
|
|
const int MAX_STORY_LINE_COUNT = 12;
|
|
const char* c_szImgControlName = "quest_dialog_backimg_";
|
|
|
|
const char *c_szQuestName = "questname";
|
|
//const char *c_szNpcName = "npc_name";
|
|
|
|
|
|
};
|
|
|
|
// 2010.06.04 epic6에서 갖고옴 - prodongi
|
|
extern SGameSystem* g_pCurrentGameSystem;
|
|
|
|
SUIQuestInfoWnd::~SUIQuestInfoWnd()
|
|
{
|
|
_ClearTriggerControls();
|
|
m_extractQuestTarget.clear(); /// 2011.08.19 - prodongi
|
|
m_vQuestContent.clear();
|
|
m_triggerMenus.clear();
|
|
m_vHideCtrl.clear();
|
|
}
|
|
|
|
|
|
extern void LoadTexture(const char *filename, K3DTexture* texture);
|
|
|
|
|
|
void SUIQuestInfoWnd::Create(KUIWND_CREATE_ARG& CREATE_ARG)
|
|
{
|
|
SUIWnd::Create( CREATE_ARG ) ;
|
|
|
|
int nFixImgWidth = 541;
|
|
int nFixImgHeight = 320;
|
|
|
|
for(int i=0;i<c_nImgCountMax; i++)
|
|
{
|
|
K3DTextureSPtr spTmpTextrue;
|
|
|
|
KUIWND_CREATE_ARG arg;
|
|
arg.lpszAniName = "";
|
|
arg.lpszSprName = m_sSprName.c_str();
|
|
arg.dwFlag = KFLAG_NO_GET_MESSAGE;
|
|
arg.dwStyle = 0;
|
|
arg.pParent = this;
|
|
arg.dwFlag = KFLAG_GET_PASS_MESSAGE;
|
|
arg.lpszClassName = "dynamictexture_static";
|
|
arg.lpszID = CStringUtil::StringFormat("%s%02d", c_szImgControlName,i).c_str();
|
|
arg.rcRect = KRect(24,64,554,354); // 530 290
|
|
KUIControlDynamicTexture* pWndDynamicTex = (KUIControlDynamicTexture*)m_pManager->CreateControl(arg);
|
|
|
|
int nExpX, nExpY;
|
|
K3DRenderDevice::GetSquareSize( nFixImgWidth, nFixImgHeight, nExpX, nExpY );
|
|
|
|
if( KUITextureManager::GetHWType() == KUITextureManager::HW_SUPPORT )
|
|
{
|
|
spTmpTextrue = KDeviceManager::GetDeviceManager()->GetRenderDevice()->CreateTexture( nExpX, nExpY, KUSAGE_DYNAMIC, K3DFMT_A8R8G8B8, D3DPOOL_DEFAULT );
|
|
}
|
|
else
|
|
{
|
|
//Intel Chip 계열에서 지원 안 되는 넘들이 있음.
|
|
spTmpTextrue = KDeviceManager::GetDeviceManager()->GetRenderDevice()->CreateTexture( nExpX, nExpY, K3DFMT_A8R8G8B8, D3DPOOL_MANAGED );
|
|
}
|
|
|
|
if( pWndDynamicTex )
|
|
pWndDynamicTex->SetRenderTarget( spTmpTextrue, nFixImgWidth, nFixImgHeight );
|
|
|
|
//LoadTexture( "test.png", spTmpTextrue );
|
|
|
|
//pWndDynamicTex->SetShow( false );
|
|
pWndDynamicTex->SetShow( false );
|
|
|
|
m_vQuestInfoImgName.push_back( "" );
|
|
m_vQuestInfospTexture.push_back( spTmpTextrue );
|
|
}
|
|
}
|
|
|
|
static int GetIconControlNum( const char* szSlotControlID )
|
|
{
|
|
for( int nSlotIndex( 0 ); nSlotIndex < QuestBase::MAX_OPTIONAL_REWARD; ++nSlotIndex )
|
|
{
|
|
if( 0 == ::_stricmp( CStringUtil::StringFormat( "quest_selectitem_item_%02d", nSlotIndex ).c_str(), szSlotControlID ) )
|
|
return nSlotIndex;
|
|
}
|
|
|
|
return (-1);
|
|
}
|
|
|
|
bool SUIQuestInfoWnd::InitControls( KPoint kPos )
|
|
{
|
|
// 커스텀 윈도우 move 영역 설정
|
|
SetCustomMovingRect( KRect( 0, 0, 594, 25 ) );
|
|
|
|
struct closeQuestDialog : public ITriggerAction
|
|
{
|
|
closeQuestDialog( SGameManager& mgr ) : game_manager( mgr ) {}
|
|
virtual void onRelease()
|
|
{
|
|
// game_manager.PostMsgAtDynamic(
|
|
// new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_QUEST_DIALOG, false ) );
|
|
}
|
|
|
|
private:
|
|
|
|
SGameManager& game_manager;
|
|
};
|
|
|
|
struct yesCloseQuestDialog : public closeQuestDialog
|
|
{
|
|
yesCloseQuestDialog( SGameManager& mgr ) : closeQuestDialog( mgr ) {}
|
|
virtual bool isValid() const
|
|
{
|
|
return SQuestMgr::GetInstance().GetQuestCount(false) < SQuestMgr::MAX_QUEST_NUM;
|
|
}
|
|
};
|
|
|
|
|
|
_ClearTriggerControls();
|
|
_AddTriggerControl( "quest_button_yes", GetStringDB().GetString( 19 ), "ui_click_accept01.wav",
|
|
new yesCloseQuestDialog( *m_pGameManager ) );
|
|
_AddTriggerControl( "quest_button_no", GetStringDB().GetString( 20 ), "",
|
|
new closeQuestDialog( *m_pGameManager ) );
|
|
|
|
|
|
|
|
//SetChildCaption( c_szStaticExp, GetStringDB().GetString( STRING_EXP ) );
|
|
//SetChildCaption( c_szStaticJp, GetStringDB().GetString( STRING_JP ) );
|
|
//SetChildCaption( c_szStaticRupy, GetStringDB().GetString( STRING_R ) ); // #2.1.11
|
|
|
|
for(int i=0;i<c_nImgCountMax;i++)
|
|
{
|
|
SetChildShow( CStringUtil::StringFormat("%s%02d", c_szImgControlName,i).c_str(), false );
|
|
SetChildAsTop( CStringUtil::StringFormat("%s%02d", c_szImgControlName,i).c_str() );
|
|
}
|
|
|
|
/// 순서가 중요하기 때문에 주석처리 하면 안된다. nui의 컨트롤 순서를 바꿀까도 했지만 파트3까지 이렇게 되어 있어서 그대로 유지함.
|
|
SetChildAsTop( "quest_dialog" );
|
|
SetChildAsTop( "quest_smallbutton_next" );
|
|
SetChildAsTop( "quest_smallbutton_pre" );
|
|
SetChildAsTop( "quest_page_number" );
|
|
SetChildAsTop( "quest_smallbutton_pre_01" );
|
|
|
|
/// 2011.09.29 - prodongi
|
|
setDifficultyToolTip();
|
|
|
|
m_ctrlComplete = dynamicCast<KUIControlButton*>(GetChild(c_szQuestConfirmButton));
|
|
m_ctrlGiveUp = dynamicCast<KUIControlButton*>(GetChild("quest_button_giveup_01"));
|
|
m_ctrlAccept = dynamicCast<KUIControlButton*>(GetChild(c_szQuestYesButton));
|
|
m_ctrlReject = dynamicCast<KUIControlButton*>(GetChild(c_szQuestNoButton));
|
|
m_ctrlQuestName = dynamicCast<KUIControlStatic*>(GetChild(c_szQuestName));
|
|
|
|
/// give up 버튼 위치 조정
|
|
if (m_ctrlReject && m_ctrlGiveUp)
|
|
{
|
|
m_ctrlGiveUp->MovePos(m_ctrlReject->GetRect().left, m_ctrlReject->GetRect().top);
|
|
}
|
|
|
|
KUIControlSimpleButton* buttonPre = dynamicCast<KUIControlSimpleButton*>(GetChild("quest_smallbutton_pre_01"));
|
|
if (buttonPre)
|
|
buttonPre->SetTooltip(S(1463));
|
|
|
|
addhideCtrl("reward_text_03");
|
|
addhideCtrl("reward_bg_03");
|
|
addhideCtrl("questname_03");
|
|
|
|
return true;
|
|
}
|
|
|
|
void SUIQuestInfoWnd::addhideCtrl(LPCSTR ctrlName)
|
|
{
|
|
KUIControlStatic *pCtrl = dynamicCast<KUIControlStatic*>(GetChild(ctrlName));
|
|
if(pCtrl)
|
|
m_vHideCtrl.push_back(pCtrl);
|
|
}
|
|
void SUIQuestInfoWnd::setTitleShow(bool bShow)
|
|
{
|
|
for( size_t i=0 ; i<m_vHideCtrl.size() ; ++i)
|
|
m_vHideCtrl[i]->SetShow(bShow);
|
|
}
|
|
void SUIQuestInfoWnd::setTitleName()
|
|
{
|
|
std::string strTitleName = m_TitleMgr.GetTitleNameForQuest(m_questCode);
|
|
if( strTitleName != "")
|
|
{
|
|
GetChild("questname_03")->SetCaption(CStringUtil::StringFormat("<font:font_01><right><size:10><#f7941d>%s",strTitleName.c_str()).c_str());
|
|
setTitleShow(true);
|
|
}
|
|
else
|
|
setTitleShow(false);
|
|
}
|
|
|
|
|
|
void SUIQuestInfoWnd::IconFocus( int nIndex )
|
|
{
|
|
KUIWnd *pWnd = GetChild( "quest_selectitem" );
|
|
if( !pWnd ) return;
|
|
|
|
QuestBase::QuestCode code = m_questCode;
|
|
QuestBase *pBase = GetQuestDB().GetQuestData( code );
|
|
if( !pBase )
|
|
{
|
|
pWnd->SetShow( false );
|
|
return;
|
|
}
|
|
|
|
int nOptionalRewardCount = 0;
|
|
for( nOptionalRewardCount = QuestBase::MAX_OPTIONAL_REWARD; nOptionalRewardCount > 0; --nOptionalRewardCount )
|
|
{
|
|
if( pBase->OptionalReward[ nOptionalRewardCount-1 ].nItemCode ) break;
|
|
}
|
|
|
|
if( nIndex < 0 || nIndex >= nOptionalRewardCount )
|
|
{
|
|
pWnd->SetShow( false );
|
|
return;
|
|
}
|
|
|
|
m_rewardFocus = nIndex;
|
|
|
|
pWnd->SetShow( true );
|
|
KUIWnd * pItemIcon = GetChild( CStringUtil::StringFormat( "quest_selectitem_itemback_%02d", nIndex ).c_str() );
|
|
if( pItemIcon )
|
|
{
|
|
pWnd->MovePos( pItemIcon->GetRect().left, pItemIcon->GetRect().top );
|
|
}
|
|
}
|
|
|
|
void SUIQuestInfoWnd::PumpUpMessage( LPCSTR lpszControlID, DWORD nMessage, DWORD lparam, DWORD wparam )
|
|
{
|
|
switch(nMessage)
|
|
{
|
|
case KUI_MESSAGE::KBUTTON_CLICK:
|
|
{
|
|
int nSlotIndex = GetIconControlNum( lpszControlID );
|
|
if( nSlotIndex >= 0 )
|
|
{
|
|
m_pGameManager->StartSound( "ui_button_click.wav" );
|
|
|
|
IconFocus( nSlotIndex );
|
|
break;
|
|
}
|
|
else if( ::_stricmp( lpszControlID, "button_close" ) == 0 )
|
|
{
|
|
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_QUEST_INFO, false) );
|
|
break;
|
|
}
|
|
else if( ::_stricmp( lpszControlID, c_szQuestPrevButton ) == 0 )
|
|
{
|
|
setCurPage(m_nCurrentPage - 1);
|
|
}
|
|
else if( ::_stricmp( lpszControlID, c_szQuestNextButton ) == 0 )
|
|
{
|
|
setCurPage(m_nCurrentPage + 1);
|
|
}
|
|
else if (0 == ::_stricmp(lpszControlID, "quest_smallbutton_pre_01"))
|
|
{
|
|
setCurPage(m_vQuestContent.size() - 1);
|
|
}
|
|
else if( ::_stricmp( lpszControlID, c_szQuestConfirmButton ) == 0 )
|
|
{
|
|
bool bSendResult = false;
|
|
if( IsQuestNeedRewardItem() )
|
|
{
|
|
if( m_rewardFocus >= 0 )
|
|
bSendResult = true;
|
|
}
|
|
else
|
|
{
|
|
bSendResult = true;
|
|
m_rewardFocus = -1;
|
|
}
|
|
|
|
if( bSendResult )
|
|
{
|
|
m_pGameManager->StartSound( "ui_click_complete01.wav" ); //퀘스트 완료
|
|
|
|
std::string strTrigger;
|
|
XStringUtil::Format( strTrigger, "end_quest( %d, %d )", m_questCode, m_rewardFocus );
|
|
m_pGameManager->PostMsgAtDynamic( new SIMSG_UI_ACT_NPCDIALOG( strTrigger.c_str() ) );
|
|
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_QUEST_INFO, false) );
|
|
}
|
|
else
|
|
{
|
|
m_pDisplayInfo->AddSystemMessage( S(512), 99 );
|
|
m_pGameManager->ProcMsgAtStatic( &SIMSG_REQ_OPEN_MSGBOX( SIMSG_REQ_OPEN_MSGBOX::_MSGBOXID::MSGBOX_GENERAL, S(512), true ) );
|
|
}
|
|
}
|
|
else if( ::_stricmp( lpszControlID, "quest_button_giveup_01" ) == 0 )
|
|
{
|
|
m_pGameManager->PostMsgAtDynamic( new SIMSG_REQ_OPEN_MSGBOX(SIMSG_REQ_OPEN_MSGBOX::MSGBOX_GIVEUPQUEST, (801), true) );
|
|
}
|
|
else
|
|
{
|
|
|
|
_ReleaseTrigger( lpszControlID );
|
|
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_QUEST_INFO, false) );
|
|
//quest_button_yes, quest_button_no,quest_button_confirm -> 창닫을껄
|
|
//m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_QUEST_INFO, false) );
|
|
}
|
|
}
|
|
break;
|
|
|
|
case KUI_MESSAGE::KGENWND_MOVE: // 윈도우 이동
|
|
{
|
|
LimitMoveWnd(); // 게임 외부로 나가지 못하게 제한
|
|
}
|
|
break;
|
|
}
|
|
|
|
return SUIWnd::PumpUpMessage( lpszControlID, nMessage, lparam, wparam );
|
|
}
|
|
|
|
void SUIQuestInfoWnd::Process(DWORD dwTime)
|
|
{
|
|
KUIGenWnd::Process(dwTime);
|
|
|
|
// RefreshStoryText();
|
|
static AR_TIME nPrevArTime2 = 0;
|
|
AR_TIME nCurArTime2 = GetArTime();
|
|
|
|
if ( nCurArTime2 > nPrevArTime2+50 )
|
|
{
|
|
nPrevArTime2 = nCurArTime2;
|
|
Refresh(false);
|
|
refreshRealTime();
|
|
}
|
|
|
|
// 2010.06.04 epic6에서 갖고옴 - prodongi
|
|
if (m_nDialogType == TS_SC_DIALOG::TYPE_QUEST_INFO_AND_START)
|
|
{
|
|
SGameAvatarEx* pLocalPlayer = g_pCurrentGameSystem->GetLocalPlayer();
|
|
|
|
K3DVector local = *pLocalPlayer->GetPosition();
|
|
local.z = 0;
|
|
|
|
float len = GetDistance( local, m_vecQuestStart );
|
|
if( len > 100.f )
|
|
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_QUEST_INFO, false) );
|
|
}
|
|
|
|
}
|
|
|
|
void* SUIQuestInfoWnd::Perform( KID id, KArg& msg )
|
|
{
|
|
return SUIWnd::Perform( id, msg );
|
|
}
|
|
|
|
void SUIQuestInfoWnd::ProcMsgAtStatic( SGameMessage* pMsg )
|
|
{
|
|
switch( pMsg->nType )
|
|
{
|
|
case MSG_NPC_DIALOG:
|
|
{
|
|
//SetChildShow(c_szQuestYesButton, false);
|
|
//SetChildShow(c_szQuestNoButton, false);
|
|
//SetChildShow(c_szQuestConfirmButton, false);
|
|
|
|
SMSG_NPC_DIALOG* pData = dynamicCast< SMSG_NPC_DIALOG* >( pMsg );
|
|
|
|
// 2010.06.04 epic6에서 갖고옴 - prodongi
|
|
SGameAvatarEx* pLocalPlayer = g_pCurrentGameSystem->GetLocalPlayer();
|
|
m_nDialogType = pData->nDialogType;
|
|
|
|
refreshConfirmButtonStatus(m_nDialogType);
|
|
|
|
if(TS_SC_DIALOG::TYPE_QUEST_INFO_AND_START == m_nDialogType ||
|
|
TS_SC_DIALOG::TYPE_QUEST_INFO_IN_PROGRESS == m_nDialogType ||
|
|
TS_SC_DIALOG::TYPE_QUEST_INFO_AND_END == m_nDialogType)
|
|
{
|
|
if(TS_SC_DIALOG::TYPE_QUEST_INFO_AND_START == m_nDialogType)
|
|
{
|
|
// 2010.06.04 epic6에서 갖고옴 - prodongi
|
|
m_vecQuestStart = *pLocalPlayer->GetPosition();
|
|
m_vecQuestStart.z = 0;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
IconFocus( -1);
|
|
m_rewardFocus = -1;
|
|
Refresh();
|
|
break;
|
|
}
|
|
/*
|
|
if(pData->nDialogType == TS_SC_DIALOG::TYPE_QUEST_INFO_AND_START)
|
|
{
|
|
// 2010.06.04 epic6에서 갖고옴 - prodongi
|
|
m_vecQuestStart = *pLocalPlayer->GetPosition();
|
|
m_vecQuestStart.z = 0;
|
|
|
|
//수락,거절 버튼 냅둘것.
|
|
SetChildShow(c_szQuestYesButton, true);
|
|
SetChildShow(c_szQuestNoButton, true);
|
|
}
|
|
else if(pData->nDialogType == TS_SC_DIALOG::TYPE_QUEST_INFO_IN_PROGRESS)
|
|
{
|
|
setConfirmButtonType(m_nDialogType);
|
|
SetChildShow(c_szQuestConfirmButton, true);
|
|
}
|
|
else if(pData->nDialogType == TS_SC_DIALOG::TYPE_QUEST_INFO_AND_END)
|
|
{
|
|
//보상받기 버튼 냅둘것.
|
|
setConfirmButtonType(m_nDialogType);
|
|
SetChildShow(c_szQuestConfirmButton, true);
|
|
}
|
|
else
|
|
{
|
|
IconFocus( -1);
|
|
m_rewardFocus = -1;
|
|
Refresh();
|
|
break;
|
|
}
|
|
*/
|
|
m_questCode = pData->nQuestCode;
|
|
m_questTextId = pData->nQuestTextID;
|
|
m_questNpc = pData->strTitle.c_str();
|
|
|
|
extractQuestTarget(); /// 2011.08.19 - prodongi
|
|
|
|
_AssignTriggers( pData->vtMenus );
|
|
Refresh();
|
|
/// 2012.02.15 자동 선택 - prodongi
|
|
autoSelectOptionalReward(m_questCode);
|
|
}
|
|
break;
|
|
|
|
case IMSG_UI_SEND_DATA:
|
|
{
|
|
SIMSG_UI_SEND_DATA* pData = dynamicCast< SIMSG_UI_SEND_DATA* >( pMsg );
|
|
/*
|
|
//퀘스트 내용 업데이트
|
|
if( pData->m_strString == "set_quest_code" )
|
|
{
|
|
if( m_nQuestCode == pData->m_nNumber.getAmount() )
|
|
return;
|
|
|
|
m_nQuestCode = pData->m_nNumber.getAmount();
|
|
|
|
Refresh();
|
|
}
|
|
*/
|
|
if( pData->m_strString == "quest_status_updated" )
|
|
{
|
|
Refresh(true, false);
|
|
}
|
|
}
|
|
break;
|
|
case IMSG_UI_FOCUS:
|
|
{
|
|
m_pManager->SetFocus(this);
|
|
pMsg->bUse = true;
|
|
}
|
|
break;
|
|
/*(case MSG_NPC_DIALOG:
|
|
{
|
|
//퀘스트 시작시 넘어오는 곳?!?!?
|
|
SMSG_NPC_DIALOG* pData = dynamicCast< SMSG_NPC_DIALOG* >( pMsg );
|
|
m_questCode = pData->nQuestCode;
|
|
//m_questTextId = pData->nQuestTextID;
|
|
//m_questNpc = pData->strTitle.c_str();
|
|
//_AssignTriggers( pData->vtMenus );
|
|
|
|
Refresh();
|
|
}
|
|
break;*/
|
|
case IMSG_HOTKEY_EX: //servantes 2010.10.19
|
|
{
|
|
SIMSG_HOTKEY_EX* pHotKey = dynamicCast<SIMSG_HOTKEY_EX*>(pMsg);
|
|
|
|
if( pHotKey->wParam == VK_SHIFT )
|
|
m_bShiftKey = (pHotKey->bUp == 0); //servantes 2010.10.15
|
|
if( pHotKey->wParam == VK_CONTROL ) //servantes 2010.10.15
|
|
m_bControlKey = (pHotKey->bUp == 0);
|
|
if( pHotKey->wParam == VK_MENU )
|
|
{
|
|
bool bPreState = m_bAltKey;
|
|
m_bAltKey = (pHotKey->bUp == 0);
|
|
|
|
if( bPreState != m_bAltKey && IsShow() )
|
|
{
|
|
QuestBase *pBase = GetQuestDB().GetQuestData(m_questCode);
|
|
setCompensationItem(pBase);
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
return SUIWnd::ProcMsgAtStatic( pMsg );
|
|
}
|
|
|
|
void SUIQuestInfoWnd::OnNotifyUIWindowOpen( bool bOpen, bool bLimitWnd )
|
|
{
|
|
if( bOpen )
|
|
{
|
|
m_pGameManager->StartSound( "ui_popup_window01.wav" );
|
|
|
|
//m_nStoryIndex = 0;
|
|
// m_nSummaryIndex = 0;
|
|
|
|
movePosAboutQuestList();
|
|
|
|
Refresh();
|
|
}
|
|
|
|
return SUIWnd::OnNotifyUIWindowOpen( bOpen, false );
|
|
}
|
|
|
|
void SUIQuestInfoWnd::movePosAboutQuestList()
|
|
{
|
|
KUIWnd *pWnd = m_pManager->FindWnd( "window_quest_list_main" );
|
|
if (!pWnd)
|
|
return ;
|
|
|
|
KRect questRect = pWnd->GetRect();
|
|
/// 퀘스트 리스트창 왼쪽
|
|
if (questRect.left <= questRect.GetWidth())
|
|
{
|
|
MovePos( questRect.left + questRect.GetWidth(), questRect.top);
|
|
}
|
|
/// 퀘스트 리스트창 오른쪽
|
|
else
|
|
{
|
|
MovePos( questRect.left - GetRect().GetWidth(), questRect.top);
|
|
}
|
|
|
|
LimitMoveWnd();
|
|
}
|
|
|
|
std::string SUIQuestInfoWnd::CoordinateQuestName( int nDifficulty, int nLimitLevel, const std::string & strQuestName )
|
|
{
|
|
std::string strColor;
|
|
m_pDisplayInfo->getQuestDifficultyColor(nDifficulty, nLimitLevel, strColor);
|
|
return "<font:font_01><left><top><vcenter><size:9><b>" + strColor + strQuestName;
|
|
}
|
|
|
|
extern int SplitBR( std::string & strSrc, std::vector<std::string>& strDstlist, bool bDef );
|
|
|
|
void SUIQuestInfoWnd::Refresh(bool bInit, bool initPage)
|
|
{
|
|
QuestBase::QuestCode code = m_questCode;
|
|
QuestBase *pBase = GetQuestDB().GetQuestData( code );
|
|
|
|
if( !pBase )
|
|
{
|
|
m_vQuestContent.clear();
|
|
|
|
RefreshStoryText();
|
|
return;
|
|
}
|
|
|
|
if(bInit)
|
|
{
|
|
refreshWhenRecv(initPage);
|
|
}
|
|
/*
|
|
|
|
|
|
//SetChildShow( "quest_selectitem", false );
|
|
|
|
|
|
|
|
SetChildShow( "npcname", false ); //아직 데이타 없음.
|
|
|
|
|
|
std::string strQuestText, strFontSize = "<font:font_01><left><top><size:10><out>";
|
|
|
|
strQuestText += ParseQuestText( GetStringDB().GetString( m_questTextId ), m_questCode );
|
|
CStringUtil::ReplacePhrase( strQuestText, "<P>", "" );
|
|
|
|
replaceQuestTargetToText(strQuestText); /// 2011.08.19 - prodongi
|
|
|
|
/// 2011.09.29 최대 라인 수로 쪼갠다 - prodongi
|
|
std::string strPage;
|
|
std::vector<std::string> splitedStr;
|
|
splitMaxLineString(strQuestText, splitedStr);
|
|
for (size_t i = 0; i < splitedStr.size(); ++i)
|
|
{
|
|
strPage = strFontSize;
|
|
strPage += splitedStr[i];
|
|
m_vQuestContent.push_back(strPage);
|
|
}
|
|
splitedStr.clear();
|
|
|
|
//요약
|
|
std::string strSummary = ParseQuestText( GetStringDB().GetQuestString( pBase->nSummaryTextId ), code );
|
|
replaceQuestTargetToText(strSummary); /// 2011.08.19 - prodongi
|
|
|
|
strQuestText = strFontSize;
|
|
strQuestText += GetStringDB().GetString( 6529 ); //퀘스트 목표 :
|
|
strQuestText += "<br><br>";
|
|
strQuestText += strSummary;
|
|
strQuestText += "<br><br>";
|
|
|
|
//진행 상황
|
|
std::string strProgress, strTmp;
|
|
if( pBase->nStatusTextId ) strProgress = ParseQuestText( GetStringDB().GetQuestString( pBase->nStatusTextId ), code );
|
|
|
|
replaceQuestTargetToText(strProgress); /// 2011.08.19 - prodongi
|
|
|
|
std::vector< std::string > strlist;
|
|
SplitBR( strProgress, strlist, false );
|
|
|
|
for( unsigned i(0); strlist.size()>i; i++ )
|
|
{
|
|
strQuestText += strlist[i];
|
|
strQuestText += "<br>";
|
|
}
|
|
strlist.clear();
|
|
|
|
m_vQuestContent.push_back( strQuestText );
|
|
*/
|
|
|
|
//이미지 태그추가 2009.11.26 sfreer.
|
|
RefreshStoryText();
|
|
}
|
|
|
|
void SUIQuestInfoWnd::SetItemSlot( ItemBase::ItemCode code, int nCount, const char *szIconControl, const char *szNumberControl, const char *szTooltipControl )
|
|
{
|
|
// 아이콘 설정
|
|
KUIControlIconStatic *pIcon = dynamicCast< KUIControlIconStatic* >( GetChild( szIconControl ) );
|
|
if( pIcon )
|
|
{
|
|
if( code )
|
|
{
|
|
const ItemBaseEx_info * base = GetItemDB().GetItemData( code );
|
|
|
|
pIcon->SetIcon( c_szDEF_SPR_NAME, base->pIcon_name );
|
|
}
|
|
else
|
|
{
|
|
pIcon->SetIcon( c_szDEF_SPR_NAME, "static_common_itemslot" );
|
|
}
|
|
}
|
|
|
|
// 수량 설정
|
|
KUIWnd* pNum = GetChild( szNumberControl );
|
|
if( pNum )
|
|
{
|
|
if( code && GetItemDB().IsJoin( code, false ) )
|
|
{
|
|
pNum->SetCaption( CStringUtil::StringFormat( "<font:font_01><size:8><right>%d", nCount ).c_str() );
|
|
pNum->SetShow( true );
|
|
}
|
|
else
|
|
{
|
|
pNum->SetShow( false );
|
|
}
|
|
}
|
|
|
|
KUIControl* pTooltip = dynamicCast< KUIControl* >(GetChild( szTooltipControl ));
|
|
if(pTooltip)
|
|
{
|
|
if( code )
|
|
{
|
|
const ItemBaseEx_info *base( GetItemDB().GetItemData( code ) );
|
|
if( base )
|
|
{
|
|
std::string toolTip = m_pDisplayInfo->GetItemTooltipText(code, true, 0, 1, XFlag<int>(), 0, 0, 0, 0, 0, 0, 0, 0, 0, false, -1, -1, 0, base->nSummonId, true,0);
|
|
pTooltip->SetTooltip( toolTip.c_str() );
|
|
pTooltip->SetTooltipSprite( c_szDEF_SPR_NAME );
|
|
|
|
if( m_bAltKey )
|
|
{
|
|
m_pDisplayInfo->SetComparableEquipItemSubTooltip( pTooltip, code );
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
pTooltip->SetTooltip( "" );
|
|
}
|
|
}
|
|
}
|
|
|
|
void SUIQuestInfoWnd::RefreshStoryText()
|
|
{
|
|
std::string strNewStory;
|
|
//const int MAX_STORY_LINE_COUNT = 14;
|
|
|
|
// 대화내용 넘침 방지
|
|
//std::vector< std::string > vLineList;
|
|
//vLineList.clear();
|
|
|
|
//중동 오른쪽에서 왼쪽으로 퀘스트 내용 출력하게 수정
|
|
//스트링 db로 어케 해야 하지 않을지...
|
|
//2009-06-29: hunee
|
|
|
|
#ifdef _COUNTRY_ME_
|
|
strNewStory += "<RIGHT>";
|
|
#endif
|
|
|
|
KUIControl* pControl = dynamicCast<KUIControl*>(GetChild( "quest_dialog" ));
|
|
if( !pControl ) return;
|
|
|
|
if( m_vQuestContent.empty() ) return;
|
|
|
|
if( m_nCurrentPage >= (int)m_vQuestContent.size() || m_nCurrentPage < 0 ) return;
|
|
|
|
/// 2011.09.29 이미 페이지가 맥스 라인으로 쪼개져 있기 때문에 여기서는 고려 안해도 된다 - prodongi
|
|
/*
|
|
// pControl->SplitLine( vLineList, m_vQuestContent[m_nCurrentPage], S(6307), 9 );
|
|
pControl->SplitLine( vLineList, m_vQuestContent[m_nCurrentPage], S(6426), 9 );
|
|
|
|
if( vLineList.size() > MAX_STORY_LINE_COUNT )
|
|
{
|
|
for( int i = 0; i < vLineList.size(); ++i )
|
|
{
|
|
if( i >= MAX_STORY_LINE_COUNT ) break;
|
|
if( vLineList.size() <= (m_nStoryIndex + i) ) break;
|
|
|
|
if( vLineList[ (m_nStoryIndex + i) ].length() )
|
|
strNewStory += vLineList[ (m_nStoryIndex + i) ].c_str();
|
|
|
|
strNewStory += "<BR>";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
#ifdef _COUNTRY_ME_
|
|
strNewStory += m_vQuestContent[m_nCurrentPage];
|
|
#else
|
|
strNewStory = m_vQuestContent[m_nCurrentPage];
|
|
#endif
|
|
|
|
m_nStoryIndex = 0;
|
|
}
|
|
*/
|
|
#ifdef _COUNTRY_ME_
|
|
strNewStory += m_vQuestContent[m_nCurrentPage];
|
|
#else
|
|
strNewStory = m_vQuestContent[m_nCurrentPage];
|
|
#endif
|
|
//m_nStoryIndex = 0;
|
|
|
|
|
|
|
|
//퀘스트 남은 시간 출력
|
|
//2009-07-14: hunee
|
|
//int nScrollMax = int( vLineList.size() );
|
|
|
|
//vLineList.clear();
|
|
|
|
static AR_TIME nPrevArTime = 0;
|
|
AR_TIME nCurArTime = GetArTime();
|
|
|
|
if (m_nCurrentPage2 != m_nCurrentPage || nCurArTime > nPrevArTime+50 )
|
|
{
|
|
nPrevArTime = nCurArTime;
|
|
|
|
QuestBase::QuestCode code = m_questCode;
|
|
QuestBase *pBase = GetQuestDB().GetQuestData( code );
|
|
|
|
if( m_nCurrentPage == (int)m_vQuestContent.size() - 1)
|
|
{
|
|
switch (SQuestMgr::GetInstance().GetQuestProgress( code ))
|
|
{
|
|
case SQuestMgr::QUEST_IN_PROGRESS:
|
|
if (pBase->nTimeLimit > 0)
|
|
{
|
|
|
|
AR_TIME nTimeLimit = SQuestMgr::GetInstance().GetQuestTimeLimit( code );
|
|
if (nCurArTime < nTimeLimit)
|
|
{
|
|
nTimeLimit -= nCurArTime;
|
|
|
|
int sec = nTimeLimit /100 % 60;
|
|
int min = nTimeLimit / 6000 % 60;
|
|
int hour = nTimeLimit / 360000; //100*60*60 1/100초 기준
|
|
|
|
std::string strRemain;
|
|
strRemain = "<br>";
|
|
|
|
if (hour > 0)
|
|
{
|
|
strRemain += GetStringDB().GetString( 87 ); //"남은 시간 : #@time@#시간 #@min@#분"
|
|
|
|
XStringUtil::Replace( strRemain, "#@time@#", SStringDB::ToString( hour ).c_str() );
|
|
XStringUtil::Replace( strRemain, "#@min@#", SStringDB::ToString( min ).c_str() );
|
|
XStringUtil::Replace( strRemain, "#@second@#", SStringDB::ToString( sec ).c_str() );
|
|
}
|
|
else if (min > 0)
|
|
{
|
|
strRemain += GetStringDB().GetString( 539 ); //"남은 시간 : #@min@#분"
|
|
XStringUtil::Replace( strRemain, "#@min@#", SStringDB::ToString( min ).c_str() );
|
|
}
|
|
else if (sec > 0)
|
|
{
|
|
strRemain += GetStringDB().GetString( 582 ); //"남은 시간 : #@second@#초"
|
|
XStringUtil::Replace( strRemain, "#@second@#", SStringDB::ToString( sec ).c_str() );
|
|
}
|
|
|
|
strNewStory += strRemain;
|
|
|
|
//nScrollMax += 2;
|
|
}
|
|
}
|
|
break;
|
|
case SQuestMgr::QUEST_SUCCEED:
|
|
{
|
|
//<size:10><#e04444>퀘스트 완료
|
|
std::string strRemain;
|
|
strRemain = "<br>";
|
|
strRemain += GetStringDB().GetString( 536 );
|
|
strNewStory += strRemain;
|
|
}
|
|
break;
|
|
case SQuestMgr::QUEST_FAILED:
|
|
{
|
|
//<size:10><#e04444>퀘스트 실패
|
|
std::string strRemain;
|
|
strRemain = "<br>";
|
|
strRemain += GetStringDB().GetString( 534 );
|
|
strNewStory += strRemain;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
m_nCurrentPage2 = m_nCurrentPage;
|
|
|
|
|
|
|
|
for(int i=0;i<c_nImgCountMax;i++)
|
|
{
|
|
SetChildShow( CStringUtil::StringFormat("%s%02d", c_szImgControlName,i).c_str(), false );
|
|
}
|
|
|
|
int nImgCount = 0;
|
|
|
|
//strNewStory = "#@img:test.png,0,0,35,132@#";
|
|
size_t nFindPos = strNewStory.find( "#@img:" );
|
|
|
|
while( nFindPos != string::npos )
|
|
{
|
|
size_t nFindPos2 = strNewStory.find( "@#",nFindPos+1 );
|
|
if( nFindPos2 != string::npos )
|
|
{
|
|
size_t nFindPos3 = strNewStory.find( ",",nFindPos+1 );
|
|
size_t nFindPos4 = strNewStory.find( ",",nFindPos3+1 );
|
|
size_t nFindPos5 = strNewStory.find( ",",nFindPos4+1 );
|
|
size_t nFindPos6 = strNewStory.find( ",",nFindPos5+1 );
|
|
|
|
std::string imgfilename = strNewStory.substr(nFindPos+6, nFindPos3-(nFindPos+6) );
|
|
//std::string x = strNewStory.substr(nFindPos3+1, nFindPos4 - (nFindPos3+1));
|
|
//std::string y = strNewStory.substr(nFindPos4+1, nFindPos2 - (nFindPos4+1));
|
|
int x = atoi( strNewStory.substr(nFindPos3+1, nFindPos4 - (nFindPos3+1)).c_str() );
|
|
int y = atoi( strNewStory.substr(nFindPos4+1, nFindPos5 - (nFindPos4+1)).c_str() );
|
|
int w = atoi( strNewStory.substr(nFindPos5+1, nFindPos6 - (nFindPos5+1)).c_str() );
|
|
int h = atoi( strNewStory.substr(nFindPos6+1, nFindPos2 - (nFindPos6+1)).c_str() );
|
|
|
|
_oprint("questinfo img %s[%d,%d] w:%d h:%d\n",imgfilename.c_str(),x,y,w,h);
|
|
|
|
KUIControlDynamicTexture *pWnd = dynamicCast<KUIControlDynamicTexture*>(GetChild( CStringUtil::StringFormat("%s%02d", c_szImgControlName,nImgCount).c_str() ));
|
|
KUIWnd *pWnd2 = GetChild( "quest_dialog_backimg_area" );
|
|
if(pWnd&&pWnd2)
|
|
{
|
|
KRect newrect(x+pWnd2->GetRect().left,y+pWnd2->GetRect().top,
|
|
w+x+pWnd2->GetRect().left,h+y+pWnd2->GetRect().top);
|
|
pWnd->SetRect( newrect );
|
|
//if( ::_strcmpi(aniname.c_str(), pWnd->GetAniName()) != 0 )
|
|
if(::_strcmpi( m_vQuestInfoImgName[nImgCount].c_str(), imgfilename.c_str() ) != 0)
|
|
{
|
|
//pWnd->SetAniName(aniname.c_str());
|
|
pWnd->SetRenderTarget( m_vQuestInfospTexture[nImgCount], newrect.GetWidth(), newrect.GetHeight() );//nFixImgWidth, nFixImgHeight );
|
|
LoadTexture( imgfilename.c_str(), m_vQuestInfospTexture[nImgCount] );
|
|
m_vQuestInfoImgName[nImgCount] = imgfilename;
|
|
}
|
|
pWnd->SetShow(true);
|
|
|
|
m_nCurrentPage2 = m_nCurrentPage;
|
|
}
|
|
nImgCount++;
|
|
|
|
}
|
|
else
|
|
{
|
|
break;
|
|
}
|
|
|
|
strNewStory.erase( nFindPos, (nFindPos2-nFindPos)+2 );
|
|
nFindPos = strNewStory.find( "#@img:" );
|
|
}
|
|
|
|
|
|
// if( nFindPos == std::string::npos ) break;
|
|
|
|
SetChildCaption( "quest_dialog", CStringUtil::StringFormat( "<top><size:9>%s%s", S(6425), strNewStory.c_str() ).c_str() );
|
|
|
|
/// 2011.09.29 refreshWhenRecv에서 설정 - prodongi
|
|
/*
|
|
int nCurPage = 0, nTotalPage = 0;
|
|
if( m_vQuestContent.empty() == false )
|
|
{
|
|
nCurPage = m_nCurrentPage+1;
|
|
nTotalPage = (int)m_vQuestContent.size();
|
|
}
|
|
|
|
std::string strPage;
|
|
XStringUtil::Format( strPage, "<font:font_01><size:9><out><vcenter><hcenter>%d/%d", nCurPage, nTotalPage );
|
|
SetChildCaption( c_szQuestPage, strPage.c_str() );
|
|
|
|
/// npc 이름은 없어짐
|
|
/*
|
|
std::string strNpcName = "<right><top><vcenter><b><font:돋움><#FF8040><size:10> ";
|
|
strNpcName += m_questNpc;
|
|
SetChildCaption( c_szNpcName, strNpcName.c_str() );
|
|
*/
|
|
//QuestBase *pBase = GetQuestDB().GetQuestData( m_questCode );
|
|
/*
|
|
std::string strQuestName = "<font:font_01><left><top><vcenter><size:9><b>";
|
|
strQuestName += GetStringDB().GetQuestString( pBase->nQuestTextId );
|
|
SetChildCaption( c_szQuestName, strQuestName.c_str() );
|
|
*/
|
|
}
|
|
|
|
}
|
|
|
|
void SUIQuestInfoWnd::SetControlEnableWithColor( const char* lpControl, bool bEnable, const char* lpColor )
|
|
{
|
|
if( lpControl == NULL ) return;
|
|
|
|
SetControlEnable(lpControl, bEnable);
|
|
|
|
if( bEnable ) SetControlEnableColor( lpControl, lpColor);
|
|
else SetControlDisableColor( lpControl, lpColor);
|
|
|
|
SetControlEnable( lpControl, bEnable );
|
|
}
|
|
|
|
void SUIQuestInfoWnd::SetControlEnable( const char * pControlName, bool bEnable )
|
|
{
|
|
if( pControlName == NULL ) return;
|
|
|
|
KUIControl * pControl = dynamicCast<KUIControl *>(GetChild(pControlName));
|
|
if( pControl )
|
|
{
|
|
if( bEnable )
|
|
pControl->Enable();
|
|
else
|
|
pControl->Disable();
|
|
}
|
|
}
|
|
|
|
void SUIQuestInfoWnd::SetControlEnableColor( const char * pControlName, const char* lpColor )
|
|
{
|
|
if( pControlName == NULL ) return;
|
|
|
|
KUIControl * pControl = dynamicCast<KUIControl *>(GetChild(pControlName));
|
|
if( pControl )
|
|
{
|
|
pControl->SetEnableColor(lpColor);
|
|
}
|
|
}
|
|
|
|
void SUIQuestInfoWnd::SetControlDisableColor( const char * pControlName, const char* lpColor )
|
|
{
|
|
if( pControlName == NULL ) return;
|
|
|
|
KUIControl * pControl = dynamicCast<KUIControl *>(GetChild(pControlName));
|
|
if( pControl )
|
|
{
|
|
pControl->SetDisableColor(lpColor);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void SUIQuestInfoWnd::_AddTriggerControl(
|
|
const char* control_name,
|
|
const char* trigger_name,
|
|
const char* trigger_sound,
|
|
ITriggerAction* trigger_action )
|
|
{
|
|
TriggerInfo* trigger = new TriggerInfo();
|
|
trigger->name = trigger_name;
|
|
trigger->sound = trigger_sound;
|
|
trigger->action = trigger_action;
|
|
m_triggerControls.insert( std::make_pair( control_name, trigger ) );
|
|
}
|
|
|
|
void SUIQuestInfoWnd::_ClearTriggerControls()
|
|
{
|
|
t_trigger_controls::iterator iTrigger = m_triggerControls.begin();
|
|
for( ; iTrigger != m_triggerControls.end(); ++iTrigger )
|
|
{
|
|
SAFE_DELETE( iTrigger->second );
|
|
}
|
|
m_triggerControls.clear();
|
|
}
|
|
|
|
void SUIQuestInfoWnd::_AssignTriggers( const std::vector< SMSG_NPC_DIALOG::DLGMENU >& menus )
|
|
{
|
|
m_triggerMenus.clear();
|
|
m_triggerMenus.assign( menus.begin(), menus.end() );
|
|
}
|
|
|
|
bool SUIQuestInfoWnd::_ReleaseTrigger( const char* control_id )
|
|
{
|
|
struct triggerFinder : public std::unary_function< SMSG_NPC_DIALOG::DLGMENU, bool >
|
|
{
|
|
triggerFinder( const std::string& menu_name )
|
|
: m_menu_name( menu_name )
|
|
{}
|
|
bool operator () ( const SMSG_NPC_DIALOG::DLGMENU& menu ) const
|
|
{
|
|
return menu.strMenuName == m_menu_name;
|
|
}
|
|
const std::string& m_menu_name;
|
|
};
|
|
|
|
t_trigger_controls::iterator iControl = m_triggerControls.find( control_id );
|
|
if( iControl != m_triggerControls.end() )
|
|
{
|
|
TriggerInfo& trigger = *( iControl->second );
|
|
|
|
t_trigger_menus::iterator iTrigger = std::find_if(
|
|
m_triggerMenus.begin(),
|
|
m_triggerMenus.end(),
|
|
triggerFinder( trigger.name ) );
|
|
|
|
if( iTrigger != m_triggerMenus.end() )
|
|
{
|
|
if (trigger.action->isValid())
|
|
{
|
|
m_pGameManager->ProcMsgAtStatic( &SIMSG_UI_ACT_NPCDIALOG( (*iTrigger).strTrigger.c_str() ) );
|
|
}
|
|
else
|
|
{
|
|
m_pGameManager->GetGameInterface()->OpenMessageBox(SIMSG_REQ_OPEN_MSGBOX::MSGBOX_OK, SIMSG_REQ_OPEN_MSGBOX::MSGBOX_GENERAL, 0, -1, S(1464));
|
|
}
|
|
|
|
m_pGameManager->StartSound( trigger.sound.c_str() );
|
|
trigger.action->onRelease();
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
/// 2011.08.19 ParseQuestStringElement함수에서 갖고 옴 - prodongi
|
|
void SUIQuestInfoWnd::extractQuestTarget()
|
|
{
|
|
extern void extractQuestTarget(std::vector<std::string>& questTargetList, int questCode);
|
|
|
|
extractQuestTarget(m_extractQuestTarget, m_questCode);
|
|
}
|
|
|
|
void SUIQuestInfoWnd::replaceQuestTargetToText(std::string& text, bool addMobNameDiff)
|
|
{
|
|
std::string replaceText, temp;
|
|
std::vector<std::string>::iterator it = m_extractQuestTarget.begin();
|
|
for (; it != m_extractQuestTarget.end(); ++it)
|
|
{
|
|
replaceText = makeQuestTargetTagText(*it);
|
|
temp = *it;
|
|
if (addMobNameDiff) temp += "_";
|
|
XStringUtil::Replace(text, temp, replaceText);
|
|
}
|
|
}
|
|
|
|
std::string SUIQuestInfoWnd::makeQuestTargetTagText(std::string const& str)
|
|
{
|
|
std::string strRet;
|
|
XStringUtil::Format(strRet, "<#ff0000>%s<#ffffff>", str.c_str());
|
|
return strRet;
|
|
}
|
|
|
|
void SUIQuestInfoWnd::refreshWhenRecv(bool initPage)
|
|
{
|
|
QuestBase *pBase = GetQuestDB().GetQuestData(m_questCode);
|
|
|
|
std::string temp;
|
|
|
|
/// difficulty
|
|
setDifficultyIcon(pBase);
|
|
/// quest name
|
|
if (m_ctrlQuestName)
|
|
{
|
|
temp = CoordinateQuestName(pBase->nQuestDifficulty, pBase->nLimitLevel, GetStringDB().GetQuestString( pBase->nQuestTextId ));
|
|
m_ctrlQuestName->SetCaption(temp.c_str());
|
|
}
|
|
/* npc 이름은 없어짐
|
|
/// npc name
|
|
temp = "<font:font_01><right><#a36109><size:9><b>";
|
|
temp += m_questNpc;
|
|
SetChildCaption( c_szNpcName, temp.c_str() );
|
|
*/
|
|
/// progress status
|
|
setProgressStatus(m_questCode);
|
|
///
|
|
if (initPage)
|
|
{
|
|
m_nCurrentPage = -1;
|
|
m_nCurrentPage2 = -1;
|
|
setCurPage(0);
|
|
}
|
|
///
|
|
setCompensationPoint(pBase);
|
|
setCompensationItem(pBase);
|
|
//
|
|
setQuestContent(pBase);
|
|
|
|
// 2012. 5. 21 - marine 퀘스트 완료시 획득 하는 호칭 이름 설정
|
|
setTitleName();
|
|
}
|
|
|
|
void SUIQuestInfoWnd::setDifficultyIcon(QuestBase* base)
|
|
{
|
|
int diff = m_pDisplayInfo->getQuestDifficulty(base->nQuestDifficulty, base->nLimitLevel);
|
|
KUIWnd* wnd = GetChild("quest_difficulty_easy_01");
|
|
if (!wnd)
|
|
return ;
|
|
|
|
char const* aniName = "common_mark_quest_difficulty_easy";
|
|
switch (diff)
|
|
{
|
|
case 0: aniName = "common_mark_quest_difficulty_easy"; break;
|
|
case 1: aniName = "common_mark_quest_difficulty_nomal"; break;
|
|
case 2: aniName = "common_mark_quest_difficulty_hard"; break;
|
|
}
|
|
wnd->SetAniName(aniName);
|
|
}
|
|
|
|
void SUIQuestInfoWnd::setProgressStatus(int questCode)
|
|
{
|
|
KUIWnd* wnd = GetChild("mark_status_quest_01");
|
|
if (!wnd)
|
|
return ;
|
|
|
|
int type = SQuestMgr::GetInstance().GetQuestProgress(questCode);
|
|
|
|
char const* aniName = "common_mark_npc_quest01_big";
|
|
switch (type)
|
|
{
|
|
case SQuestMgr::STARTABLE: aniName = "common_mark_npc_quest01_big"; break;
|
|
case SQuestMgr::QUEST_IN_PROGRESS: aniName = "common_mark_npc_quest02_big"; break;
|
|
case SQuestMgr::QUEST_SUCCEED: aniName = "common_mark_npc_quest03_big"; break;
|
|
case SQuestMgr::QUEST_FAILED: aniName = "common_mark_npc_quest03_big"; break;
|
|
};
|
|
wnd->SetAniName(aniName);
|
|
}
|
|
|
|
void SUIQuestInfoWnd::setCurPage(int page)
|
|
{
|
|
if( m_vQuestContent.empty() ) return ;
|
|
|
|
int nOldPage = m_nCurrentPage;
|
|
|
|
int nQuestSize = (int)m_vQuestContent.size() - 1;
|
|
if( page >= nQuestSize )
|
|
{
|
|
SetControlEnable(c_szQuestPrevButton, true );
|
|
SetControlEnable(c_szQuestNextButton, false );
|
|
m_nCurrentPage = nQuestSize;
|
|
}
|
|
else if (0 >= page)
|
|
{
|
|
SetControlEnable(c_szQuestPrevButton, false );
|
|
SetControlEnable(c_szQuestNextButton, true );
|
|
m_nCurrentPage = 0;
|
|
}
|
|
else
|
|
{
|
|
SetControlEnable(c_szQuestPrevButton, true );
|
|
SetControlEnable(c_szQuestNextButton, true );
|
|
m_nCurrentPage = page;
|
|
}
|
|
|
|
if( nOldPage != m_nCurrentPage )
|
|
{
|
|
RefreshStoryText();
|
|
|
|
int nCurPage = 0, nTotalPage = 0;
|
|
if( m_vQuestContent.empty() == false )
|
|
{
|
|
nCurPage = m_nCurrentPage+1;
|
|
nTotalPage = (int)m_vQuestContent.size();
|
|
}
|
|
|
|
std::string strPage;
|
|
XStringUtil::Format( strPage, "<font:font_01><size:9><out><vcenter><hcenter>%d/%d", nCurPage, nTotalPage );
|
|
SetChildCaption( c_szQuestPage, strPage.c_str() );
|
|
}
|
|
}
|
|
|
|
void SUIQuestInfoWnd::setCompensationPoint(QuestBase* base)
|
|
{
|
|
c_fixed10 fMod = GameRule::GetQuestRewardFactor( base );
|
|
|
|
char const* tag = "<font:font_01><size:9><b><right>";
|
|
|
|
// EXP
|
|
if( base->nExp )
|
|
{
|
|
int nRewardExp = base->nExp * fMod;
|
|
SetChildCaption( "quest_compens_expnumber", CStringUtil::StringFormat( "<font:font_01><size:9><b><right>%s%s", tag, CStringUtil::GetCommaNumberString( nRewardExp ).c_str() ).c_str() );
|
|
}
|
|
else
|
|
{
|
|
SetChildCaption( "quest_compens_expnumber", CStringUtil::StringFormat( "<font:font_01><size:9><b><right>%s%d", tag, 0 ).c_str() );
|
|
}
|
|
|
|
// JP
|
|
if( base->nJP )
|
|
{
|
|
int nRewardJP = base->nJP * fMod;
|
|
SetChildCaption( "quest_compens_jpnumber", CStringUtil::StringFormat( "%s%s", tag, CStringUtil::GetCommaNumberString( nRewardJP ).c_str() ).c_str() );
|
|
}
|
|
else
|
|
{
|
|
SetChildCaption( "quest_compens_jpnumber", CStringUtil::StringFormat( "%s%d", tag, 0 ).c_str() );
|
|
}
|
|
|
|
// RP
|
|
if( base->nGold )
|
|
{
|
|
int nRewardGold = base->nGold * fMod;
|
|
SetChildCaption( "quest_compens_rpnumber", CStringUtil::StringFormat( "%s%s", tag, CStringUtil::GetCommaNumberString( nRewardGold ).c_str() ).c_str() );
|
|
}
|
|
else
|
|
{
|
|
SetChildCaption( "quest_compens_rpnumber", CStringUtil::StringFormat( "%s%d", tag, 0 ).c_str() );
|
|
}
|
|
|
|
// P
|
|
// 2009. 2. 13 hunee 은신감지 관련 추가, 기획쪽 담당자 김동민
|
|
if (base->nHolicPoint)
|
|
{
|
|
int nRewardP = base->nHolicPoint * fMod;
|
|
SetChildCaption( "quest_compens_pointnumber", CStringUtil::StringFormat( "%s%s", tag, CStringUtil::GetCommaNumberString( nRewardP ).c_str() ).c_str() );
|
|
}
|
|
else
|
|
{
|
|
SetChildCaption( "quest_compens_pointnumber", CStringUtil::StringFormat( "%s%d", tag, 0 ).c_str() );
|
|
}
|
|
}
|
|
|
|
void SUIQuestInfoWnd::setCompensationItem(QuestBase *base)
|
|
{
|
|
c_fixed10 fMod = GameRule::GetQuestRewardFactor( base );
|
|
|
|
// 기본아이템
|
|
if( base->DefaultReward.nItemCode )
|
|
{
|
|
SetChildCaption( "static_quest_base", CStringUtil::StringFormat( "<size:10><#FFFFFFFF><hcenter><vcenter>%s", S(6201) ).c_str() );
|
|
SetItemSlot( base->DefaultReward.nItemCode, base->DefaultReward.nQuantity, "quest_baseitem_itemback", "quest_baseitem_itemnumber","quest_baseitem_itemback" );
|
|
}
|
|
else
|
|
{
|
|
SetChildCaption( "static_quest_base", CStringUtil::StringFormat( "<size:10><#797979><hcenter><vcenter>%s", S(6201) ).c_str() );
|
|
SetItemSlot( 0, 0, "quest_baseitem_itemback", "quest_baseitem_itemnumber","quest_baseitem_itemback" );
|
|
}
|
|
|
|
SetQuestRewardItem( false );
|
|
// 옵셔널 아이템
|
|
if( base->OptionalReward[0].nItemCode )
|
|
{
|
|
SetChildCaption( "static_quest_select", CStringUtil::StringFormat( "<size:10><hcenter><vcenter><#FFFFFFFF>%s", S(6202) ).c_str() );
|
|
|
|
for( size_t slot_idx = 0; slot_idx < QuestBase::MAX_OPTIONAL_REWARD; ++slot_idx )
|
|
{
|
|
ItemBase::ItemCode code = base->OptionalReward[slot_idx].nItemCode;
|
|
int nCount = base->OptionalReward[slot_idx].nQuantity;
|
|
|
|
SetItemSlot( code, nCount, CStringUtil::StringFormat( "quest_selectitem_itemback_%02d", slot_idx ).c_str(), CStringUtil::StringFormat( "quest_selectitem_itemnumber%02d", slot_idx ).c_str(), CStringUtil::StringFormat( "quest_selectitem_item_%02d", slot_idx ).c_str() );
|
|
}
|
|
|
|
SetQuestRewardItem( true );
|
|
}
|
|
else
|
|
{
|
|
SetChildCaption( "static_quest_select", CStringUtil::StringFormat( "<size:10><hcenter><vcenter><#797979>%s", S(6202) ).c_str() );
|
|
|
|
for( size_t slot_idx = 0; slot_idx < QuestBase::MAX_OPTIONAL_REWARD; ++slot_idx )
|
|
SetItemSlot( 0, 0, CStringUtil::StringFormat( "quest_selectitem_itemback_%02d", slot_idx ).c_str(), CStringUtil::StringFormat( "quest_selectitem_itemnumber%02d", slot_idx ).c_str(), CStringUtil::StringFormat( "quest_selectitem_item_%02d", slot_idx ).c_str() );
|
|
|
|
SetQuestRewardItem( false );
|
|
}
|
|
}
|
|
|
|
void SUIQuestInfoWnd::setDifficultyToolTip()
|
|
{
|
|
KUIControlStatic* diff = dynamicCast<KUIControlStatic*>(GetChild("quest_difficulty_easy_01"));
|
|
if (!diff)
|
|
return ;
|
|
|
|
std::string tooltip;
|
|
tooltip += "#@quest_easy@#"; tooltip += " "; tooltip += S(1460); tooltip += "<br>";
|
|
tooltip += "#@quest_normal@#"; tooltip += " "; tooltip += S(1462); tooltip += "<br>";
|
|
tooltip += "#@quest_hard@#"; tooltip += " "; tooltip += S(1461);
|
|
|
|
diff->SetTooltip(tooltip.c_str());
|
|
}
|
|
|
|
void SUIQuestInfoWnd::splitMaxLineString(std::string const& totalStr, std::vector<std::string>& splitedStr)
|
|
{
|
|
if (totalStr.empty())
|
|
return ;
|
|
|
|
KUIControl* pControl = dynamicCast<KUIControl*>(GetChild( "quest_dialog" ));
|
|
if( !pControl ) return;
|
|
|
|
std::vector<std::string> lineList;
|
|
|
|
pControl->SplitLine(lineList, totalStr, "font_01", 10);
|
|
|
|
std::string str;
|
|
size_t count = 0;
|
|
for (size_t i = 0; i < lineList.size(); ++i)
|
|
{
|
|
str += lineList[i];
|
|
++count;
|
|
|
|
if (count >= MAX_STORY_LINE_COUNT)
|
|
{
|
|
splitedStr.push_back(str);
|
|
str.clear();
|
|
count = 0;
|
|
}
|
|
else
|
|
{
|
|
str += "<br>";
|
|
}
|
|
}
|
|
|
|
if (!str.empty())
|
|
{
|
|
splitedStr.push_back(str);
|
|
}
|
|
|
|
lineList.clear();
|
|
}
|
|
|
|
void SUIQuestInfoWnd::setQuestContent(QuestBase* pBase)
|
|
{
|
|
extern std::string ParseQuestText( const char *szQuestString, int nQuestCode ); // GameVM.cpp
|
|
extern std::string ParseQuestTextAddMobDiff( const char *szQuestString, int nQuestCode ); // GameVM.cpp
|
|
|
|
m_vQuestContent.clear();
|
|
|
|
SetChildShow( "npcname", false ); //아직 데이타 없음.
|
|
|
|
std::string strQuestText, strFontSize = "<font:font_01><left><top><size:10><out>";
|
|
|
|
/// 설명
|
|
strQuestText += ParseQuestText( GetStringDB().GetString( m_questTextId ), m_questCode );
|
|
CStringUtil::ReplacePhrase( strQuestText, "<P>", "" );
|
|
replaceQuestTargetToText(strQuestText); /// 2011.08.19 - prodongi
|
|
|
|
/// 2011.09.29 최대 라인 수로 쪼갠다 - prodongi
|
|
std::string strPage;
|
|
std::vector<std::string> splitedStr;
|
|
splitMaxLineString(strQuestText, splitedStr);
|
|
for (size_t i = 0; i < splitedStr.size(); ++i)
|
|
{
|
|
strPage = strFontSize;
|
|
strPage += splitedStr[i];
|
|
m_vQuestContent.push_back(strPage);
|
|
}
|
|
splitedStr.clear();
|
|
|
|
//요약
|
|
std::string strSummary = ParseQuestText( GetStringDB().GetQuestString( pBase->nSummaryTextId ), m_questCode );
|
|
replaceQuestTargetToText(strSummary); /// 2011.08.19 - prodongi
|
|
|
|
strQuestText = strFontSize;
|
|
strQuestText += GetStringDB().GetString( 6529 ); //퀘스트 목표 :
|
|
strQuestText += "<br><br>";
|
|
strQuestText += strSummary;
|
|
strQuestText += "<br><br>";
|
|
|
|
//진행 상황
|
|
std::string strProgress, strTmp;
|
|
if( pBase->nStatusTextId ) strProgress = ParseQuestTextAddMobDiff( GetStringDB().GetQuestString( pBase->nStatusTextId ), m_questCode );
|
|
|
|
/// 중복되는 이름이 있을 경우, 이중 체크가 될 수 있기 때문에, 변환했는지를 체크하기 위해 스페이스 체크를 추가한다
|
|
replaceQuestTargetToText(strProgress, true); /// 2011.08.19 - prodongi
|
|
|
|
std::vector< std::string > strlist;
|
|
SplitBR( strProgress, strlist, false );
|
|
|
|
for( unsigned i(0); strlist.size()>i; i++ )
|
|
{
|
|
strQuestText += strlist[i];
|
|
strQuestText += "<br>";
|
|
}
|
|
strlist.clear();
|
|
|
|
m_vQuestContent.push_back( strQuestText );
|
|
}
|
|
|
|
void SUIQuestInfoWnd::refreshConfirmButtonStatus(int dialogType)
|
|
{
|
|
if (!m_ctrlComplete || !m_ctrlAccept || !m_ctrlReject)
|
|
return ;
|
|
|
|
m_ctrlComplete->SetShow(false);
|
|
m_ctrlGiveUp->SetShow(false);
|
|
m_ctrlAccept->SetShow(false);
|
|
m_ctrlReject->SetShow(false);
|
|
|
|
std::string str;
|
|
if (TS_SC_DIALOG::TYPE_QUEST_INFO_AND_START == dialogType)
|
|
{
|
|
m_ctrlAccept->SetShow(true);
|
|
m_ctrlReject->SetShow(true);
|
|
}
|
|
else if (TS_SC_DIALOG::TYPE_QUEST_INFO_IN_PROGRESS == dialogType)
|
|
{
|
|
m_ctrlGiveUp->SetShow(true);
|
|
}
|
|
else if (TS_SC_DIALOG::TYPE_QUEST_INFO_AND_END == dialogType)
|
|
{
|
|
m_ctrlComplete->SetShow(true);
|
|
m_ctrlGiveUp->SetShow(true);
|
|
}
|
|
}
|
|
|
|
void SUIQuestInfoWnd::refreshRealTime()
|
|
{
|
|
QuestBase *pBase = GetQuestDB().GetQuestData(m_questCode);
|
|
|
|
/// difficulty
|
|
setDifficultyIcon(pBase);
|
|
/// quest name
|
|
if (m_ctrlQuestName)
|
|
{
|
|
std::string name = CoordinateQuestName(pBase->nQuestDifficulty, pBase->nLimitLevel, GetStringDB().GetQuestString( pBase->nQuestTextId ));
|
|
if ( g_GMDEV )
|
|
{
|
|
name += CStringUtil::StringFormat("(%d)",m_questCode).c_str();
|
|
|
|
}
|
|
m_ctrlQuestName->SetCaption(name.c_str());
|
|
}
|
|
/// progress status
|
|
setProgressStatus(m_questCode);
|
|
/// buttons
|
|
refreshConfirmButtonStatus(m_nDialogType);
|
|
}
|
|
|
|
void SUIQuestInfoWnd::autoSelectOptionalReward(int questCode)
|
|
{
|
|
QuestBase* base = GetQuestDB().GetQuestData(questCode);
|
|
if (!base)
|
|
return ;
|
|
QuestBase::Reward* reward = base->OptionalReward;
|
|
|
|
/// 선택 보상 아이템 개수
|
|
int itemCount = 0;
|
|
for (int i = 0; i < QuestBase::MAX_OPTIONAL_REWARD; ++i)
|
|
{
|
|
if (reward[i].nItemCode) ++itemCount;
|
|
}
|
|
|
|
/// 선택 보상이 한개일 때만 자동 선택함
|
|
if (1 == itemCount)
|
|
{
|
|
/// 선택 보상 아이템이 있는 슬롯을 찾아서 선택
|
|
for (int i = 0; i < QuestBase::MAX_OPTIONAL_REWARD; ++i)
|
|
{
|
|
if (reward[i].nItemCode)
|
|
{
|
|
IconFocus(i);
|
|
return ;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
IconFocus(-1);
|
|
m_rewardFocus = -1;
|
|
}
|
|
} |