Files
2026-06-01 12:46:52 +02:00

462 lines
14 KiB
C++

#ifndef _PARTY_RENEWAL_
#include "stdafx.h"
#include "SGameManager.h"
#include "SUIDungeonStoneWnd.h"
#include "SGameMessageUI.h"
#include "SGameMessage.h"
#include "KUIControlList.h"
#include "KUIControlListItem.h"
#include "SStringDB.h"
#include "SDungeonResourceDB.h"
#include "nsl.h"
#include "nsluni.h"
#include "XEnv.h"
#include "SNpcResourceDB.h"
//#define _DUNGEON_LIST_TEST_
extern void MsgSplit( const char* szMsg, std::vector<std::string>& vecText, const wchar_t* lpDelimiter, bool bProcSpecialCharacter=false );
SUIDungeonStoneWnd::~SUIDungeonStoneWnd()
{
}
bool SUIDungeonStoneWnd::InitControls( KPoint kPos )
{
SetCustomMovingRect( KRect( 0, 0, m_rcRegion.GetWidth(), 20 ) );
KUIControIStringList* pList = (KUIControIStringList*)(GetChild("list"));
if( pList )
{
pList->SetItemShowCnt(3);
pList->SetScroll(true);
}
return SUIWnd::InitControls( kPos );
}
bool SUIDungeonStoneWnd::InitData( bool bReload /*= false*/ )
{
return SUIWnd::InitData( bReload );
}
void SUIDungeonStoneWnd::ClearList()
{
KUIControIStringList* pList = (KUIControIStringList*)(GetChild("list"));
if( pList ) pList->ClearItem();
m_vecRaidList.clear();
}
void SUIDungeonStoneWnd::ClearDungeonInfo()
{
m_sDungeonInfo.strDungeonName.erase();
m_sDungeonInfo.nLv = 0;
m_sDungeonInfo.nSiegeCnt = 0;
m_sDungeonInfo.strGuild.erase();
m_sDungeonInfo.strMaster.erase();
m_sDungeonInfo.nMasterLv = 0;
m_sDungeonInfo.UserCnt = 0;
m_sDungeonInfo.nApplicationCnt = 0;
ClearList();
}
void SUIDungeonStoneWnd::PumpUpMessage( LPCSTR lpszControlID, DWORD nMessage, DWORD lparam, DWORD wparam )
{
switch( nMessage )
{
case KUI_MESSAGE::KBUTTON_CLICK:
{
if( ::_stricmp( lpszControlID, "button_close" ) == 0 )
{
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_DUNGEON_STONE , false) );
}
else if( ::_stricmp( lpszControlID, "button_ok" ) == 0 ) //servantes 2010.10.13
{
//신청 버튼
m_pGameManager->PostMsgAtDynamic( new SIMSG_REQ_OPEN_MSGBOX( SIMSG_REQ_OPEN_MSGBOX::MSGBOX_DUNGEONSTONE_REQUEST, S(-435), true ) );
}
else if( ::_stricmp( lpszControlID, "button_cancel" ) == 0 ) //servantes 2010.10.13
{
//취소 버튼
m_pGameManager->PostMsgAtDynamic( new SIMSG_REQ_OPEN_MSGBOX( SIMSG_REQ_OPEN_MSGBOX::MSGBOX_DUNGEONSTONE_CANCEL, S(-436), true ) );
}
else if( ::_stricmp( lpszControlID, "button_manage" ) == 0 ) //servantes 2010.10.13
{
//관리 버튼
m_pGameManager->PostMsgAtDynamic( new SIMSG_REQ_OPEN_MSGBOX( SIMSG_REQ_OPEN_MSGBOX::MSGBOX_DUNGEONSTONE_MANAGE, S(-437), true ) );
}
}
break;
case KUI_MESSAGE::KGENWND_MOVE:
{
LimitMoveWnd();
}
}
SUIWnd::PumpUpMessage( lpszControlID, nMessage, lparam, wparam );
}
void SUIDungeonStoneWnd::ProcMsgAtStatic( SGameMessage* pMsg )
{
switch( pMsg->nType )
{
case MSG_NPC_DIALOG:
{
SMSG_NPC_DIALOG* pNPCDlgMsg = (SMSG_NPC_DIALOG*)pMsg;
ClearDungeonInfo();
SetDungeonInfo(pNPCDlgMsg);
SetRaidList(pNPCDlgMsg);
SetControlButton(pNPCDlgMsg);
UpdateStoneInfo();
}
break;
case IMSG_UI_DUNGEONSTONE:
{
SIMSG_UI_DUNGEONSTONE* pDungeonMsg = (SIMSG_UI_DUNGEONSTONE*)pMsg;
if( pDungeonMsg->m_nReqType == SIMSG_UI_DUNGEONSTONE::DUNGEONSTONE_REQUEST )
{
if( m_strHanDle[0] != " " )
{
m_pGameManager->ProcMsgAtStatic( &SIMSG_UI_ACT_NPCDIALOG(m_strHanDle[0].c_str()) );
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_DUNGEON_STONE, false ) );
ClearList();
// bintitle 2010.06.14. 레이드신청시, 길드UI - 길드관리 - 공격대결성 UI에 알림.
this->m_pGameManager->PostMsgAtDynamic( new SIMSG_UI_SEND_DATA( SIMSG_TOGGLE_UIWINDOW::_UIWINDOW_TYPE::UIWINDOW_GUILD_SUB_MANAGE, "RAID_REQUEST" ) );
}
}
else if( pDungeonMsg->m_nReqType == SIMSG_UI_DUNGEONSTONE::DUNGEONSTONE_CANCEL )
{
if( m_strHanDle[1] != " " )
{
m_pGameManager->ProcMsgAtStatic( &SIMSG_UI_ACT_NPCDIALOG(m_strHanDle[1].c_str()) );
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_DUNGEON_STONE, false ) );
ClearList();
}
}
else if( pDungeonMsg->m_nReqType == SIMSG_UI_DUNGEONSTONE::DUNGEONSTONE_MANAGE )
{
if( m_strHanDle[2] != " " )
{
m_pGameManager->ProcMsgAtStatic( &SIMSG_UI_ACT_NPCDIALOG(m_strHanDle[2].c_str()) );
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_DUNGEON_STONE, false ) );
ClearList();
}
}
}
break;
}
}
int SUIDungeonStoneWnd::GetLocalFlag()
{
// sonador 0.2.2 국가별 로컬 비트셋 통합 및 유럽 분리
return GameRule::GetCurrentLocalBitSet();
}
void SUIDungeonStoneWnd::SetDungeonInfo(SMSG_NPC_DIALOG* pNPCDlgMsg)
{
#ifdef _DUNGEON_LIST_TEST_
m_sDungeonInfo.strDungeonName = "최고던전";
m_sDungeonInfo.nLv = 100;
m_sDungeonInfo.nSiegeCnt = 30;
m_sDungeonInfo.strGuild = "던전길드";
m_sDungeonInfo.strMaster = "길드짱";
m_sDungeonInfo.nMasterLv = 300;
m_sDungeonInfo.UserCnt = 89;
m_sDungeonInfo.nApplicationCnt = 9;
#endif
if( pNPCDlgMsg == NULL ) return;
std::vector<std::string> DungeonStrList;
GetStringList(DungeonStrList, pNPCDlgMsg->strTitle);
int nDungeonNum(0);
const DungeonResource* pDungeon(NULL);
int nSize = DungeonStrList.size();
if( nSize >=2 )
{
nDungeonNum = ::atoi( DungeonStrList[0].c_str() );
m_sDungeonInfo.nApplicationCnt = ::atoi( DungeonStrList[1].c_str() );
pDungeon = GetDungeonResDB().GetDungeonRes(nDungeonNum, GetLocalFlag());
}
#ifdef _DEV_GUILD
if( nSize >= 7 )
{
m_sDungeonInfo.strGuild = DungeonStrList[2];
m_sDungeonInfo.strMaster = DungeonStrList[3];
m_sDungeonInfo.nMasterLv = ::atoi(DungeonStrList[4].c_str());
m_sDungeonInfo.UserCnt = ::atoi(DungeonStrList[5].c_str());
}
#else
if( nSize >= 7 )
{
m_sDungeonInfo.strGuild = DungeonStrList[2];
m_sDungeonInfo.strMaster = DungeonStrList[3];
m_sDungeonInfo.nMasterLv = ::atoi(DungeonStrList[4].c_str());
m_sDungeonInfo.UserCnt = ::atoi(DungeonStrList[5].c_str());
}
#endif
DungeonStrList.clear();
if( pDungeon )
{
int nDungeonNameID( GetDungeonResDB().GetDungeonNameID(pDungeon->id) );
m_sDungeonInfo.strDungeonName = GetStringDB().GetString( nDungeonNameID );
m_sDungeonInfo.nLv = pDungeon->dungeon_level;
m_sDungeonInfo.nSiegeCnt = pDungeon->num_party_guild*8 + pDungeon->num_party_mercenary*8;
}
}
void SUIDungeonStoneWnd::SetRaidList(SMSG_NPC_DIALOG* pNPCDlgMsg)
{
#ifdef _DUNGEON_LIST_TEST_
m_vecRaidList.push_back( Raid("길드1","길드장1",1,1,100) );
m_vecRaidList.push_back( Raid("길드2","길드장2",2,2,0) );
m_vecRaidList.push_back( Raid("길드3","길드장3",3,3,3000) );
m_vecRaidList.push_back( Raid("길드4","길드장4",4,4,0) );
m_vecRaidList.push_back( Raid("길드5","길드장5",5,5,0) );
m_vecRaidList.push_back( Raid("길드6","길드장6",6,6,2345) );
m_vecRaidList.push_back( Raid("길드7","길드장7",7,7,4321) );
m_vecRaidList.push_back( Raid("길드8","길드장8",8,8,3322) );
m_vecRaidList.push_back( Raid("길드9","길드장9",9,9,89) );
m_vecRaidList.push_back( Raid("길드10","길드장10",10,10,0) );
m_vecRaidList.push_back( Raid("길드11","길드장11",11,11,2341) );
m_vecRaidList.push_back( Raid("길드12","길드장12",12,12,234) );
m_vecRaidList.push_back( Raid("길드13","길드장13",13,13,0) );
m_vecRaidList.push_back( Raid("길드14","길드장14",14,14,20) );
m_vecRaidList.push_back( Raid("길드15","길드장15",15,15,0) );
m_vecRaidList.push_back( Raid("길드16","길드장16",16,16,0) );
m_vecRaidList.push_back( Raid("길드17","길드장17",17,17,72000000) );
#endif
if( pNPCDlgMsg == NULL || pNPCDlgMsg->vtTexts.empty() ) return;
std::vector<std::string> GuildList;
GetStringList(GuildList, pNPCDlgMsg->vtTexts[0]);
int nGuildListSize( GuildList.size() );
//for( int i=0, j=0; j < m_sDungeonInfo.nApplicationCnt && i < nGuildListSize; i+=7, ++j )
//{
// if( 6+i < nGuildListSize )
// {
// Raid raid( GuildList[0+i], GuildList[1+i], ::atoi( GuildList[2+i].c_str() ), GuildList[3+i], ::atoi( GuildList[4+i].c_str() ), ::atoi( GuildList[5+i].c_str() ), ::atoi( GuildList[6+i].c_str() ) );
// m_vecRaidList.push_back( raid );
// }
//}
// 2010.06.11. bintitle.
// 공격대장, 공경대장레벨 제외.
for( int i=0, j=0; j < m_sDungeonInfo.nApplicationCnt && i < nGuildListSize; i+=5, ++j )
{
if( 4+i < nGuildListSize )
{
Raid raid( GuildList[0+i], GuildList[1+i], ::atoi( GuildList[2+i].c_str() ), ::atoi( GuildList[3+i].c_str() ), ::atoi( GuildList[4+i].c_str() ) );
m_vecRaidList.push_back( raid );
}
}
GuildList.clear();
SortRaidList();
}
void SUIDungeonStoneWnd::SetControlButton(SMSG_NPC_DIALOG* pNPCDlgMsg)
{
for( int i(0); i<pNPCDlgMsg->vtMenus.size(); ++i )
{
SMSG_NPC_DIALOG::DLGMENU dlgMenu(pNPCDlgMsg->vtMenus[i].strMenuName.c_str(), pNPCDlgMsg->vtMenus[i].strTrigger.c_str(), pNPCDlgMsg->vtMenus[i].nButtonType);
if( dlgMenu.strMenuName == "REQUEST")
{
m_strHanDle[0] = dlgMenu.strTrigger;
KUIControl* pButton = dynamicCast<KUIControl*>(GetChild("button00"));
if( pButton )
{
if( dlgMenu.strTrigger == " " )
pButton->Disable();
else pButton->Enable();
}
}
else if( dlgMenu.strMenuName == "CANCEL")
{
m_strHanDle[1] = dlgMenu.strTrigger;
KUIControl* pButton = dynamicCast<KUIControl*>(GetChild("button01"));
if( pButton )
{
if( dlgMenu.strTrigger == " " )
pButton->Disable();
else pButton->Enable();
}
}
else if( dlgMenu.strMenuName == "MANAGE")
{
m_strHanDle[2] = dlgMenu.strTrigger;
KUIControl* pButton = dynamicCast<KUIControl*>(GetChild("button02"));
if( pButton )
{
if( dlgMenu.strTrigger == " " )
pButton->Disable();
else pButton->Enable();
}
}
}
//현재는 던선 커스터마이징 미구현
KUIControl* pButton = dynamicCast<KUIControl*>(GetChild("button02"));
if( pButton ) pButton->Disable();
}
std::string SUIDungeonStoneWnd::GetDungeonRank(int nLv)
{
if( nLv <= 50 ) return GetStringDB().GetString( 9502 ); // "BASIC";
else if( nLv <= 70 ) return GetStringDB().GetString( 9503 ); // "COMMON";
else if( nLv <= 90 ) return GetStringDB().GetString( 9504 ); // "UNCOMMON";
else if( nLv <= 120 ) return GetStringDB().GetString( 9505 ); // "RARE";
else return GetStringDB().GetString( 9506 ); // "UNIQUE";
}
void SUIDungeonStoneWnd::SetDungeonInfoCaption(DungeonInfo dungeon)
{
std::string strCaption;
strCaption = CStringUtil::StringFormat( "<size:15><left><vcenter>%s", dungeon.strDungeonName.c_str());
SetChildCaption("static00", strCaption.c_str());
//'Lv'을 String DB 9501로 참조하도록 한다 2009.09.25. sfreer
if( dungeon.nLv == 0 )
{
strCaption = "<vcenter><size:11><left>";
strCaption += GetStringDB().GetString(9501);
}
else
{
strCaption = CStringUtil::StringFormat( "<vcenter><size:11><left>%s %d",GetStringDB().GetString(9501), dungeon.nLv);
}
SetChildCaption("static02", strCaption.c_str());
strCaption = CStringUtil::StringFormat( "<vcenter><size:11><left>%s", GetDungeonRank(dungeon.nLv).c_str());
SetChildCaption("static03", strCaption.c_str());
if( dungeon.nSiegeCnt == 0 )
strCaption = "<vcenter><size:11><left>";
else strCaption = CStringUtil::StringFormat( "<vcenter><size:11><left>%d", dungeon.nSiegeCnt) + S(-434);
SetChildCaption("static05", strCaption.c_str());
strCaption = CStringUtil::StringFormat( "<vcenter><size:11><left>%s", dungeon.strGuild.c_str());
SetChildCaption("static07", strCaption.c_str());
strCaption = CStringUtil::StringFormat( "<vcenter><size:11><left>%s", dungeon.strMaster.c_str());
SetChildCaption("static09", strCaption.c_str());
if( dungeon.nMasterLv == 0 )
{
strCaption = "<vcenter><size:11><left>";
strCaption += GetStringDB().GetString(9501);
}
else
{
strCaption = CStringUtil::StringFormat( "<vcenter><size:11><left>%s %d",GetStringDB().GetString(9501), dungeon.nMasterLv);
}
SetChildCaption("static10", strCaption.c_str());
if( dungeon.UserCnt == 0 )
strCaption = "<vcenter><size:11><left>";
else strCaption = CStringUtil::StringFormat( "<vcenter><size:11><left>%d", dungeon.UserCnt);
SetChildCaption("static12", strCaption.c_str());
strCaption = CStringUtil::StringFormat( "<vcenter><size:11><left>%d", dungeon.nApplicationCnt);
SetChildCaption("static16", strCaption.c_str());
}
std::string SUIDungeonStoneWnd::GetListCaption(Raid raid)
{
std::string TempCaption = SR(-432,"#@guild_name@#", raid.strGuildName.c_str(), "#@master_name@#", raid.strMasterName.c_str() );
TempCaption = SStringDB::ParseString( TempCaption.c_str(), "#@master_lv@#", CStringUtil::StringFormat( "%d", raid.nMasterLv ).c_str() );
TempCaption = SStringDB::ParseString( TempCaption.c_str(), "#@cnt@#", CStringUtil::StringFormat( "%d", raid.nUserCnt ).c_str() );
TempCaption = SStringDB::ParseString( TempCaption.c_str(), "#@time@#", GetTimeString( raid.nTime/100.0f ).c_str() );
return TempCaption;
}
std::string SUIDungeonStoneWnd::GetTimeString( float f_Time )
{
std::string strTime;
int hour(0);
int min(0);
int sec(0);
if( f_Time >= 3600 )
{
hour = f_Time/3600;
f_Time -= 3600*hour;
}
if( f_Time >= 60 )
{
min = f_Time/60;
f_Time = f_Time -= 60*min;
}
sec = f_Time;
strTime = CStringUtil::StringFormat( " %02d : %02d : %02d", hour, min, sec );
return strTime;
}
void SUIDungeonStoneWnd::UpdateStoneInfo()
{
SetDungeonInfoCaption( m_sDungeonInfo );
KUIControIStringList* pList = (KUIControIStringList*)(GetChild("list"));
if( !pList ) return;
for( int i(0); i<m_vecRaidList.size(); ++i )
{
pList->AddItem( _STRITEM(GetListCaption(m_vecRaidList[i]).c_str()) );
}
}
void SUIDungeonStoneWnd::SortRaidList()
{
struct TRaidLess
{
//두인자가 같을 경우 무조건 false가 나오도록 해야한다. 흠 false가 바꾸는 것인데...
bool operator () ( const Raid& a, const Raid& b )
{
if ( a.nTime == 0 )
return false;
else if ( b.nTime == 0 )
return true;
else return a.nTime < b.nTime;
}
} pred;
std::sort( m_vecRaidList.begin(), m_vecRaidList.end(), pred );
}
void SUIDungeonStoneWnd::GetStringList( std::vector<std::string>& rStrList, std::string Text )
{
std::vector<std::string> vStrList;
MsgSplit( Text.c_str(), vStrList, L"|" );
for( int i(0); i<vStrList.size(); ++i )
{
rStrList.push_back( vStrList[i].c_str() );
}
vStrList.clear();
}
void SUIDungeonStoneWnd::OnNotifyUIWindowOpen( bool bOpen, bool bLimitWnd /*= true*/ )
{
if( bOpen )
m_pGameManager->PlaySound( "ui_popup_window01.wav" );
SUIWnd::OnNotifyUIWindowOpen( bOpen, bLimitWnd );
}
#endif