848 lines
22 KiB
C++
848 lines
22 KiB
C++
|
|
/// 2011.09.30 안쓰임 - prodongi
|
|
#ifndef _E7_P4_QUEST_RENEW_
|
|
|
|
#include "stdafx.h"
|
|
#include "SGameManager.h"
|
|
#include "SGameMessage.h"
|
|
#include "SGameMessageUI.h"
|
|
#include "SkillBaseFile.h"
|
|
#include "SItemDB.h"
|
|
#include "SQuestDB.h"
|
|
#include "SStringDB.h"
|
|
#include "SQuestMgr.h"
|
|
#include "SPlayerInfoMgr.h"
|
|
#include "KUIControlStatic.h"
|
|
#include "KUIControl.h"
|
|
#include "KUIControlScroll.h"
|
|
#include "SUIDisplayInfo.h"
|
|
#include "SUIQuestDialogWnd.h"
|
|
#include "SGame.h"
|
|
#include "SGameNpc.h"
|
|
#include "XStringUtil.h"
|
|
#include "nsl.h"
|
|
#include "nslreg.h"
|
|
#include "SUISysMsgDefine.h"
|
|
|
|
// ---------------------------------------------------------------------------------------------------
|
|
// EXTERNS
|
|
|
|
// implemented at GameVM.cpp
|
|
extern std::string ParseQuestText( const char *szQuestString, int nQuestCode );
|
|
extern int SplitBR( std::string & strSrc, std::vector<std::string>& strDstlist, bool bDef );
|
|
|
|
// trigger actions
|
|
|
|
namespace
|
|
{
|
|
const char* c_szStaticExp = "static_exp";
|
|
const char* c_szStaticJp = "static_jp";
|
|
const char* c_szStaticRupy = "static_rupy";
|
|
|
|
const char* c_szQuestPrevButton = "quest_smallbutton_next";
|
|
const char* c_szQuestNextButton = "quest_smallbutton_pre";
|
|
|
|
const char* c_szQuestPage = "npc_name_2";
|
|
|
|
unsigned int c_nPageStringSizeMax = 400;
|
|
};
|
|
|
|
SUIQuestDialogWnd::~SUIQuestDialogWnd()
|
|
{
|
|
_ClearTriggerControls();
|
|
|
|
m_vQuestContent.clear();
|
|
}
|
|
|
|
bool SUIQuestDialogWnd::InitControls( KPoint point )
|
|
{
|
|
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;
|
|
};
|
|
|
|
SetCustomMovingRect( KRect( 0, 0, 348, 20 ) );
|
|
|
|
_ClearTriggerControls();
|
|
|
|
_AddTriggerControl( "quest_button_yes", GetStringDB().GetString( 19 ), "ui_click_accept01.wav",
|
|
new closeQuestDialog( *m_pGameManager ) );
|
|
_AddTriggerControl( "quest_button_no", GetStringDB().GetString( 20 ), "",
|
|
new closeQuestDialog( *m_pGameManager ) );
|
|
|
|
SetChildShow( "quest_selectitem", false );
|
|
|
|
SetChildCaption( c_szStaticExp, GetStringDB().GetString( STRING_EXP ) );
|
|
SetChildCaption( c_szStaticJp, GetStringDB().GetString( STRING_QUEST_REWORD_JP ) );
|
|
SetChildCaption( c_szStaticRupy, GetStringDB().GetString( STRING_QUEST_REWORD_R ) );
|
|
|
|
return true;
|
|
}
|
|
|
|
void SUIQuestDialogWnd::OnNotifyUIWindowOpen( bool bOpen, bool bLimitWnd )
|
|
{
|
|
m_isOpen = bOpen;
|
|
m_questContentIndex = 0;
|
|
_PlaySound();
|
|
_Refresh();
|
|
return SUIWnd::OnNotifyUIWindowOpen( bOpen, false );
|
|
}
|
|
|
|
void SUIQuestDialogWnd::ProcMsgAtStatic( SGameMessage* pMsg )
|
|
{
|
|
switch( pMsg->nType )
|
|
{
|
|
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 );
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
return SUIWnd::ProcMsgAtStatic( pMsg );
|
|
}
|
|
|
|
void SUIQuestDialogWnd::PumpUpMessage( LPCSTR lpszControlID
|
|
, DWORD nMessage
|
|
, DWORD lparam
|
|
, DWORD wparam )
|
|
{
|
|
switch( nMessage )
|
|
{
|
|
case KUI_MESSAGE::KSCROLL_SELECT: // 스크롤 선택
|
|
{
|
|
int nPos = int(lparam);
|
|
nPos = max( nPos, 0 );
|
|
|
|
if( !_stricmp( lpszControlID, "vscroll_quest_story" ) )
|
|
{
|
|
m_questContentIndex = nPos;
|
|
_RefreshQuestDialog();
|
|
}
|
|
}
|
|
break;
|
|
|
|
case KUI_MESSAGE::KBUTTON_CLICK:
|
|
{
|
|
if( ::_stricmp( lpszControlID, "button_close" ) == 0 )
|
|
{
|
|
// close this window
|
|
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW(
|
|
SIMSG_TOGGLE_UIWINDOW::UIWINDOW_QUEST_DIALOG, false ) );
|
|
}
|
|
else if( ::_stricmp( lpszControlID, "button_next" ) == 0 )
|
|
{
|
|
// show me the next page
|
|
}
|
|
else if( ::_stricmp( lpszControlID, "button_prev" ) == 0 )
|
|
{
|
|
// show me the previous page
|
|
}
|
|
else if( ::_stricmp( lpszControlID, c_szQuestPrevButton ) == 0 )
|
|
{
|
|
if( m_vQuestContent.empty() ) break;
|
|
|
|
int nOldPage = m_nCurrentPage;
|
|
|
|
if( --m_nCurrentPage <= 0 )
|
|
{
|
|
SetControlEnable(c_szQuestPrevButton, false );
|
|
m_nCurrentPage = 0;
|
|
}
|
|
else
|
|
{
|
|
SetControlEnable(c_szQuestPrevButton, true );
|
|
}
|
|
|
|
SetControlEnable(c_szQuestNextButton, true );
|
|
|
|
if( nOldPage != m_nCurrentPage )
|
|
_RefreshQuestDialog();
|
|
}
|
|
else if( ::_stricmp( lpszControlID, c_szQuestNextButton ) == 0 )
|
|
{
|
|
if( m_vQuestContent.empty() ) break;
|
|
|
|
int nOldPage = m_nCurrentPage;
|
|
|
|
int nQuestSize = (int)m_vQuestContent.size() - 1;
|
|
if( ++m_nCurrentPage >= nQuestSize )
|
|
{
|
|
SetControlEnable(c_szQuestNextButton, false );
|
|
m_nCurrentPage = nQuestSize;
|
|
}
|
|
else
|
|
{
|
|
SetControlEnable(c_szQuestNextButton, true );
|
|
}
|
|
|
|
SetControlEnable(c_szQuestPrevButton, true );
|
|
|
|
if( nOldPage != m_nCurrentPage )
|
|
_RefreshQuestDialog();
|
|
}
|
|
else
|
|
{
|
|
_ReleaseTrigger( lpszControlID );
|
|
}
|
|
}
|
|
break;
|
|
|
|
case KUI_MESSAGE::KGENWND_MOVE:
|
|
{
|
|
LimitMoveWnd();
|
|
}
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
|
|
return SUIWnd::PumpUpMessage( lpszControlID, nMessage, lparam, wparam );
|
|
}
|
|
|
|
void SUIQuestDialogWnd::_Refresh()
|
|
{
|
|
if( !m_isOpen ) return;
|
|
|
|
QuestBase* quest_data = GetQuestDB().GetQuestData( m_questCode );
|
|
|
|
if( !quest_data )
|
|
{
|
|
_RefreshQuestDialog();
|
|
}
|
|
else
|
|
{
|
|
_RefreshHeader( *quest_data );
|
|
_MakeContentUsing( *quest_data );
|
|
_RefreshReward( *quest_data );
|
|
}
|
|
|
|
#ifdef _KUI_INVALIDATION
|
|
InvalidateWnd();
|
|
#endif
|
|
}
|
|
|
|
void SUIQuestDialogWnd::_RefreshHeader( const QuestBase& quest_data )
|
|
{
|
|
// quest name
|
|
SetChildCaption( "questname", _GetQuestName( quest_data ).c_str() );
|
|
|
|
// npc name
|
|
SetChildCaption( "npc_name", _DecorateNpcName( m_questNpc.c_str() ).c_str() );
|
|
}
|
|
|
|
void SUIQuestDialogWnd::_RefreshQuestDialog()
|
|
{
|
|
if( m_vQuestContent.empty() ) return;
|
|
|
|
if( m_nCurrentPage >= (int)m_vQuestContent.size() || m_nCurrentPage < 0 ) return;
|
|
|
|
KUIControl* dialog = dynamicCast< KUIControl* >( GetChild( "quest_dialog" ) );
|
|
if( !dialog ) return;
|
|
|
|
std::vector< std::string > content_list;
|
|
|
|
dialog->SplitLine( content_list, m_vQuestContent[m_nCurrentPage], KTextRender::KDEFAULT_FONT_NAME, m_fontSize, true, true );
|
|
|
|
if( _IsOverContentLine( content_list.size() ) )
|
|
{
|
|
//중동 오른쪽에서 왼쪽으로 퀘스트 내용 출력하게 수정
|
|
//스트링 db로 어케 해야 하지 않을지...
|
|
//2009-06-29: hunee
|
|
#ifdef _COUNTRY_ME_
|
|
std::string strCaption = "<RIGHT>";
|
|
strCaption += _MakeContentFittable( content_list );
|
|
#else
|
|
std::string strCaption = _MakeContentFittable( content_list );
|
|
#endif
|
|
|
|
dialog->SetCaption( strCaption.c_str() );
|
|
}
|
|
else
|
|
{
|
|
#ifdef _COUNTRY_ME_
|
|
std::string strCaption = "<RIGHT>";
|
|
strCaption += m_vQuestContent[m_nCurrentPage];
|
|
#else
|
|
std::string strCaption = m_vQuestContent[m_nCurrentPage];
|
|
#endif
|
|
|
|
dialog->SetCaption( strCaption.c_str() );
|
|
}
|
|
|
|
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, "%d/%d", nCurPage, nTotalPage );
|
|
SetChildCaption( c_szQuestPage, strPage.c_str() );
|
|
|
|
_RearrangeScroll( content_list.size() );
|
|
|
|
content_list.clear();
|
|
}
|
|
|
|
std::string SUIQuestDialogWnd::_MakeContentFittable( const std::vector< std::string >& content_list )
|
|
{
|
|
std::string strNewContent;
|
|
|
|
for( int index = m_questContentIndex;
|
|
index < m_questContentIndex + m_questContentLine && index < content_list.size(); ++index )
|
|
{
|
|
if( !content_list[ index ].empty() )
|
|
strNewContent += content_list[ index ].c_str();
|
|
strNewContent += "<BR>";
|
|
}
|
|
return strNewContent;
|
|
}
|
|
|
|
void SUIQuestDialogWnd::_RearrangeScroll( int line )
|
|
{
|
|
KUIControlScrollBase* scroll =
|
|
dynamicCast< KUIControlScrollBase* >( GetChild( "vscroll_quest_story" ) );
|
|
if( scroll ) scroll->SetScrollRange( m_questContentLine, line );
|
|
}
|
|
|
|
std::string SUIQuestDialogWnd::_DecorateQuestProgressString( const std::string& strQuestProgress )
|
|
{
|
|
// hide current progress number
|
|
|
|
// { [sonador][7.7.11] 퀘스트 다이얼로그 오류 수정.진행 정보 표시
|
|
std::string pattern = "(-[0-9]+)([ a-zA-Z]*)/([ a-zA-Z]*)([0-9]+)([ a-zA-Z]*)";
|
|
std::string result = strQuestProgress;
|
|
std::vector< std::string > match_list;
|
|
while( nsl::regex::match( pattern.c_str(), result.c_str(), &match_list ) )
|
|
{
|
|
std::string goal;
|
|
XStringUtil::Format( goal, ": %s%s", match_list[ 4 ].c_str(), match_list[ 5 ].c_str() );
|
|
nsl::replace( &result, match_list[ 0 ].c_str(), goal.c_str() );
|
|
match_list.clear();
|
|
}
|
|
// }
|
|
return result;
|
|
}
|
|
|
|
void SUIQuestDialogWnd::_MakeContentUsing( const QuestBase& quest_data )
|
|
{
|
|
m_nCurrentPage = 0;
|
|
m_vQuestContent.clear();
|
|
|
|
SStringDB & stringdb = GetStringDB();
|
|
|
|
std::string strContent, strFontSize;
|
|
XStringUtil::Format( strFontSize, "<size:%d>", m_fontSize );
|
|
strFontSize += "<top>";
|
|
|
|
std::string strQuestText = ParseQuestText( stringdb.GetString( m_questTextId ), m_questCode );
|
|
CStringUtil::ReplacePhrase( strQuestText, "<P>", "" );
|
|
|
|
std::string strPage;
|
|
size_t nTextSize = strQuestText.size();
|
|
if( nTextSize < c_nPageStringSizeMax )
|
|
{
|
|
strPage = strFontSize;
|
|
strPage += strQuestText;
|
|
m_vQuestContent.push_back( strPage );
|
|
}
|
|
else
|
|
{
|
|
do
|
|
{
|
|
strPage = strFontSize;
|
|
|
|
int nPos = strQuestText.find( ".", c_nPageStringSizeMax ) + 1;
|
|
if( nPos > 1 )
|
|
{
|
|
strPage += strQuestText.substr( 0, nPos );
|
|
m_vQuestContent.push_back( strPage );
|
|
|
|
strQuestText.erase( 0, nPos );
|
|
|
|
size_t QuestTextSize = strQuestText.size();
|
|
if( QuestTextSize > 0 && ( QuestTextSize < c_nPageStringSizeMax ) )
|
|
{
|
|
strPage = strFontSize;
|
|
strPage += strQuestText;
|
|
m_vQuestContent.push_back( strPage );
|
|
break;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
strPage += strQuestText;
|
|
m_vQuestContent.push_back( strPage );
|
|
break;
|
|
}
|
|
|
|
nTextSize = strQuestText.size();
|
|
|
|
} while( nTextSize >= c_nPageStringSizeMax );
|
|
}
|
|
|
|
// 요약정보
|
|
strContent = strFontSize;
|
|
strContent += stringdb.GetString( 6529 ); //퀘스트 목표 :
|
|
strContent += "<br><br>";
|
|
strContent += ParseQuestText( stringdb.GetQuestString( quest_data.nSummaryTextId ), m_questCode );
|
|
strContent += "<br><br>";
|
|
|
|
//진행 상황
|
|
std::string strProgress;
|
|
if( quest_data.nStatusTextId )
|
|
{
|
|
strProgress = _DecorateQuestProgressString( ParseQuestText(
|
|
stringdb.GetQuestString( quest_data.nStatusTextId ), m_questCode ) );
|
|
}
|
|
|
|
std::vector< std::string > strlist;
|
|
SplitBR( strProgress, strlist, false );
|
|
|
|
for( unsigned i(0); strlist.size()>i; i++ )
|
|
{
|
|
strContent += strlist[i];
|
|
strContent += "<br>";
|
|
}
|
|
strlist.clear();
|
|
|
|
//퀘스트 남은 시간 출력
|
|
//2009-07-14: hunee
|
|
if (quest_data.nTimeLimit > 0)
|
|
{
|
|
//int sec = quest_data.nTimeLimit % 60;
|
|
int min = quest_data.nTimeLimit / 60 % 60;
|
|
int hour = quest_data.nTimeLimit / 3600;
|
|
|
|
std::string strRemain;
|
|
strRemain = "<br>";
|
|
|
|
if (hour > 0)
|
|
{
|
|
strRemain += GetStringDB().GetString( 535 ); //<size:10><#2B79F9>"제한 시간 : #@time@#시간 #@min@#분"
|
|
|
|
XStringUtil::Replace( strRemain, "#@time@#", SStringDB::ToString( hour ).c_str() );
|
|
XStringUtil::Replace( strRemain, "#@min@#", SStringDB::ToString( min ).c_str() );
|
|
}
|
|
else if (min > 0)
|
|
{
|
|
strRemain += GetStringDB().GetString( 537 ); //<size:10>제한 시간 : #@min@#분
|
|
|
|
XStringUtil::Replace( strRemain, "#@min@#", SStringDB::ToString( min ).c_str() );
|
|
}
|
|
|
|
strContent += strRemain;
|
|
}
|
|
|
|
CStringUtil::ReplacePhrase( strContent, "<P>", "" );
|
|
|
|
m_vQuestContent.push_back( strContent );
|
|
|
|
if( m_vQuestContent.size() > 1 )
|
|
{
|
|
SetControlEnable(c_szQuestNextButton, true );
|
|
SetControlEnable(c_szQuestPrevButton, false );
|
|
}
|
|
else
|
|
{
|
|
SetControlEnable(c_szQuestNextButton, false );
|
|
SetControlEnable(c_szQuestPrevButton, false );
|
|
}
|
|
|
|
_RefreshQuestDialog();
|
|
}
|
|
|
|
void SUIQuestDialogWnd::_SetMod( const QuestBase& quest_data )
|
|
{
|
|
//랜덤 퀘일 경우 계산됨
|
|
if( quest_data.nType == QuestBase::QUEST_RANDOM_KILL_INDIVIDUAL ||
|
|
quest_data.nType == QuestBase::QUEST_RANDOM_COLLECT )
|
|
{
|
|
int nCount1 = SQuestMgr::GetInstance().GetQuestRandomValue( m_questCode, 2-1 );
|
|
int nCount2 = SQuestMgr::GetInstance().GetQuestRandomValue( m_questCode, 4-1 );
|
|
int nCount3 = SQuestMgr::GetInstance().GetQuestRandomValue( m_questCode, 6-1 );
|
|
|
|
float fValue1 = float(quest_data.nValue[4-1])/100.f;
|
|
float fValue2 = float(quest_data.nValue[8-1])/100.f;
|
|
float fValue3 = float(quest_data.nValue[12-1])/100.f;
|
|
|
|
m_mod = ( ( fValue1 * nCount1 ) + ( fValue2 * nCount2 ) + ( fValue3 * nCount3 ) );
|
|
}
|
|
}
|
|
|
|
std::string SUIQuestDialogWnd::_GetExpString( const QuestBase& quest_data )
|
|
{
|
|
if( quest_data.nExp )
|
|
{
|
|
return CStringUtil::StringFormat(
|
|
"<size:10><right>%s",
|
|
CStringUtil::GetCommaNumberString( quest_data.nExp * m_mod ).c_str()
|
|
);
|
|
}
|
|
else
|
|
{
|
|
return CStringUtil::StringFormat( "<size:10><right>%d", 0 );
|
|
}
|
|
}
|
|
|
|
std::string SUIQuestDialogWnd::_GetJPString( const QuestBase& quest_data )
|
|
{
|
|
if( quest_data.nJP )
|
|
{
|
|
return CStringUtil::StringFormat(
|
|
"<size:10><right>%s",
|
|
CStringUtil::GetCommaNumberString( quest_data.nJP * m_mod ).c_str()
|
|
).c_str();
|
|
}
|
|
else
|
|
{
|
|
return CStringUtil::StringFormat( "<size:10><right>%d", 0 );
|
|
}
|
|
}
|
|
|
|
// 2009. 2. 13 hunee 은신감지 관련 추가, 기획쪽 담당자 김동민
|
|
std::string SUIQuestDialogWnd::_GetHolicPointString( const QuestBase& quest_data )
|
|
{
|
|
if( quest_data.nHolicPoint )
|
|
{
|
|
return CStringUtil::StringFormat(
|
|
"<size:10><right>%s",
|
|
CStringUtil::GetCommaNumberString( quest_data.nHolicPoint * m_mod ).c_str()
|
|
).c_str();
|
|
}
|
|
else
|
|
{
|
|
return CStringUtil::StringFormat( "<size:10><right>%d", 0 );
|
|
}
|
|
}
|
|
|
|
std::string SUIQuestDialogWnd::_GetRPString( const QuestBase& quest_data )
|
|
{
|
|
if( quest_data.nGold )
|
|
{
|
|
return CStringUtil::StringFormat(
|
|
"<size:10><right>%s",
|
|
CStringUtil::GetCommaNumberString( quest_data.nGold * m_mod ).c_str()
|
|
);
|
|
}
|
|
else
|
|
{
|
|
return CStringUtil::StringFormat( "<size:10><right>%d", 0 );
|
|
}
|
|
}
|
|
|
|
std::string SUIQuestDialogWnd::_GetDefaultRewardString( const QuestBase& quest_data )
|
|
{
|
|
if( quest_data.DefaultReward.nItemCode )
|
|
{
|
|
return CStringUtil::StringFormat( "<size:10><#FFFFFFFF><hcenter><vcenter>%s", S(-240) );
|
|
}
|
|
else
|
|
{
|
|
return CStringUtil::StringFormat( "<size:10><#797979><hcenter><vcenter>%s", S(-240) );
|
|
}
|
|
}
|
|
|
|
std::string SUIQuestDialogWnd::_GetOptionalRewardString( const QuestBase& quest_data )
|
|
{
|
|
if( quest_data.OptionalReward[ 0 ].nItemCode )
|
|
{
|
|
return CStringUtil::StringFormat( "<size:10><hcenter><vcenter><#FFFFFFFF>%s", S(-241) );
|
|
}
|
|
else
|
|
{
|
|
return CStringUtil::StringFormat( "<size:10><hcenter><vcenter><#797979>%s", S(6202) );
|
|
}
|
|
}
|
|
|
|
std::string SUIQuestDialogWnd::_GetQuestName( const QuestBase& quest_data )
|
|
{
|
|
return _DecorateQuestName( quest_data.nQuestDifficulty, quest_data.nLimitLevel,
|
|
GetStringDB().GetQuestString( quest_data.nQuestTextId ) );
|
|
}
|
|
|
|
std::string SUIQuestDialogWnd::_DecorateQuestName(
|
|
int nDificullty, int nLimitLevel, const std::string & strQuestName )
|
|
{
|
|
int nPlayerLevel = m_displayInfo->GetPlayerInfoManager()->GetPlayerInfo().GetLevel();
|
|
|
|
const char *WHITE = "<vcenter><hcenter><size:11><#FFFFFF>";
|
|
const char *GRAY = "<vcenter><hcenter><size:11><#CCCCCC>";
|
|
const char *GREEN = "<vcenter><hcenter><size:11><#55BB55>";
|
|
const char *ORANGE = "<vcenter><hcenter><size:11><#AA7733>";
|
|
|
|
std::string strTitleColor = WHITE;
|
|
|
|
switch( nDificullty )
|
|
{
|
|
case 0:
|
|
if( nLimitLevel + 4 < nPlayerLevel ) strTitleColor = GRAY;
|
|
else if( nLimitLevel - 4 <= nPlayerLevel && nPlayerLevel <= nLimitLevel + 4 ) strTitleColor = GREEN;
|
|
else if( nPlayerLevel < nLimitLevel - 4 ) strTitleColor = ORANGE;
|
|
break;
|
|
case 1:
|
|
if( nLimitLevel + 8 < nPlayerLevel ) strTitleColor = GRAY;
|
|
else if( nLimitLevel <= nPlayerLevel && nPlayerLevel <= nLimitLevel + 8 ) strTitleColor = GREEN;
|
|
else if( nPlayerLevel < nLimitLevel ) strTitleColor = ORANGE;
|
|
break;
|
|
case 2:
|
|
if( nLimitLevel + 12 < nPlayerLevel ) strTitleColor = GRAY;
|
|
else if( nLimitLevel + 4 <= nPlayerLevel && nPlayerLevel <= nLimitLevel + 12 ) strTitleColor = GREEN;
|
|
else if( nPlayerLevel < nLimitLevel + 4 ) strTitleColor = ORANGE;
|
|
break;
|
|
case 3:
|
|
if( nLimitLevel + 16 < nPlayerLevel ) strTitleColor = GRAY;
|
|
else if( nLimitLevel + 8 <= nPlayerLevel && nPlayerLevel <= nLimitLevel + 16 ) strTitleColor = GREEN;
|
|
else if( nPlayerLevel < nLimitLevel + 8 ) strTitleColor = ORANGE;
|
|
break;
|
|
}
|
|
|
|
return strTitleColor + strQuestName;
|
|
}
|
|
|
|
std::string SUIQuestDialogWnd::_DecorateNpcName( const char* npc_name )
|
|
{
|
|
return CStringUtil::StringFormat(
|
|
"<right><top><vcenter><b><#FF8040><size:11>%s",
|
|
npc_name
|
|
);
|
|
}
|
|
|
|
void SUIQuestDialogWnd::_SetItemSlot( ItemBase::ItemCode code
|
|
, int nCount
|
|
, const char *szIconControl
|
|
, const char *szNumberControl )
|
|
{
|
|
// 아이콘 설정
|
|
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 );
|
|
pIcon->SetTooltip( m_displayInfo->GetItemTooltipText( code, true ).c_str() );
|
|
pIcon->SetTooltipSprite( c_szDEF_SPR_NAME );
|
|
}
|
|
else
|
|
{
|
|
pIcon->SetIcon( c_szDEF_SPR_NAME, "static_common_itemslot" );
|
|
pIcon->SetTooltip( "" );
|
|
}
|
|
}
|
|
|
|
// 수량 설정
|
|
KUIWnd* pNum = GetChild( szNumberControl );
|
|
if( pNum )
|
|
{
|
|
if( code && GetItemDB().IsJoin( code ) )
|
|
{
|
|
pNum->SetCaption(
|
|
CStringUtil::StringFormat( "%s<shadow><right><size:8>%d", S(-438), nCount ).c_str()
|
|
);
|
|
pNum->SetShow( true );
|
|
}
|
|
else
|
|
{
|
|
pNum->SetShow( false );
|
|
}
|
|
}
|
|
}
|
|
|
|
void SUIQuestDialogWnd::_RefreshReward( const QuestBase& quest_data )
|
|
{
|
|
_SetMod( quest_data );
|
|
|
|
// 보상
|
|
|
|
// EXP
|
|
SetChildCaption( "quest_compens_expnumber", _GetExpString( quest_data ).c_str() );
|
|
|
|
// JP
|
|
SetChildCaption( "quest_compens_jpnumber", _GetJPString( quest_data ).c_str() );
|
|
|
|
// RP
|
|
SetChildCaption( "quest_compens_rpnumber", _GetRPString( quest_data ).c_str() );
|
|
|
|
// 2009. 2. 13 hunee 은신감지 관련 추가, 기획쪽 담당자 김동민
|
|
// P
|
|
SetChildCaption( "quest_compens_pointnumber", _GetHolicPointString( quest_data ).c_str() );
|
|
|
|
// 기본아이템
|
|
SetChildCaption( "static_quest_base", _GetDefaultRewardString( quest_data ).c_str() );
|
|
if( quest_data.DefaultReward.nItemCode )
|
|
{
|
|
_SetItemSlot(
|
|
quest_data.DefaultReward.nItemCode,
|
|
quest_data.DefaultReward.nQuantity,
|
|
"quest_baseitem_itemback",
|
|
"quest_baseitem_itemnumber"
|
|
);
|
|
}
|
|
else
|
|
{
|
|
_SetItemSlot( 0, 0, "quest_baseitem_itemback", "quest_baseitem_itemnumber" );
|
|
}
|
|
|
|
// 옵셔널 아이템
|
|
SetChildCaption( "static_quest_select", _GetOptionalRewardString( quest_data ).c_str() );
|
|
if( quest_data.OptionalReward[0].nItemCode )
|
|
{
|
|
for( size_t slot_idx = 0; slot_idx < QuestBase::MAX_OPTIONAL_REWARD; ++slot_idx )
|
|
_SetItemSlot(
|
|
quest_data.OptionalReward[slot_idx].nItemCode,
|
|
quest_data.OptionalReward[slot_idx].nQuantity,
|
|
CStringUtil::StringFormat( "quest_selectitem_itemback_%02d", slot_idx ).c_str(),
|
|
CStringUtil::StringFormat( "quest_selectitem_itemnumber%02d", slot_idx ).c_str()
|
|
);
|
|
}
|
|
else
|
|
{
|
|
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()
|
|
);
|
|
}
|
|
}
|
|
|
|
void SUIQuestDialogWnd::_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 SUIQuestDialogWnd::_ClearTriggerControls()
|
|
{
|
|
t_trigger_controls::iterator iTrigger = m_triggerControls.begin();
|
|
for( ; iTrigger != m_triggerControls.end(); ++iTrigger )
|
|
{
|
|
SAFE_DELETE( iTrigger->second );
|
|
}
|
|
}
|
|
|
|
void SUIQuestDialogWnd::_AssignTriggers( const std::vector< SMSG_NPC_DIALOG::DLGMENU >& menus )
|
|
{
|
|
m_triggerMenus.clear();
|
|
m_triggerMenus.assign( menus.begin(), menus.end() );
|
|
}
|
|
|
|
bool SUIQuestDialogWnd::_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() )
|
|
{
|
|
m_pGameManager->ProcMsgAtStatic( &SIMSG_UI_ACT_NPCDIALOG( (*iTrigger).strTrigger.c_str() ) );
|
|
m_pGameManager->PlaySound( trigger.sound.c_str() );
|
|
trigger.action->onRelease();
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
void SUIQuestDialogWnd::_PlaySound()
|
|
{
|
|
if( m_isOpen )
|
|
m_pGameManager->PlaySound( "ui_popup_window01.wav" );
|
|
}
|
|
|
|
void SUIQuestDialogWnd::SetControlEnableWithColor( const char* lpControl, bool bEnable, const char* lpColor )
|
|
{
|
|
if( lpControl == NULL || lpColor ) return;
|
|
|
|
SetControlEnable(lpControl, bEnable);
|
|
|
|
if( bEnable ) SetControlEnableColor( lpControl, lpColor);
|
|
else SetControlDisableColor( lpControl, lpColor);
|
|
|
|
SetControlEnable( lpControl, bEnable );
|
|
}
|
|
|
|
void SUIQuestDialogWnd::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 SUIQuestDialogWnd::SetControlEnableColor( const char * pControlName, const char* lpColor )
|
|
{
|
|
if( pControlName == NULL || lpColor ) return;
|
|
|
|
KUIControl * pControl = dynamicCast<KUIControl *>(GetChild(pControlName));
|
|
if( pControl )
|
|
{
|
|
pControl->SetEnableColor(lpColor);
|
|
}
|
|
}
|
|
|
|
void SUIQuestDialogWnd::SetControlDisableColor( const char * pControlName, const char* lpColor )
|
|
{
|
|
if( pControlName == NULL || lpColor ) return;
|
|
|
|
KUIControl * pControl = dynamicCast<KUIControl *>(GetChild(pControlName));
|
|
if( pControl )
|
|
{
|
|
pControl->SetDisableColor(lpColor);
|
|
}
|
|
}
|
|
|
|
#endif |