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

259 lines
6.3 KiB
C++

#include "stdafx.h"
#include <kfile/KStream.h>
#include "KResourceManager.h"
#include <kfile/KFileManager.h>
#include "SGameManager.h"
#include "KUIControlScroll.h"
#include "SStringDB.h"
//#include "SGameMessageUI.h"
#include "SUISysMsgDefine.h"
#include "SUIServerNoticeWnd.h"
void SUIServerNoticeWnd::SetNotice( const char* szNotice, int nUseType )
{
m_nNoticeIndex = 0;
m_nOldNoticeIndex = 0;
std::string strNotice( szNotice );
if( std::string::npos != strNotice.find( "<HTML>" ) ||
std::string::npos != strNotice.find( "<html>" ) )
strNotice = std::string( S(6313)/*"<size:9><top><font:\"돋움\">"*/ ) + std::string( S(112)/*"공지사항을 읽지 못했습니다."*/);
strNotice = std::string( S(6313)/*"<size:9><top><font:\"돋움\">"*/ ) + strNotice;
//파싱 규칙
//첫째 줄은 날짜
//둘째 줄부터 내용
if( nUseType == SIMSG_SET_NOTICEWND::NOTICE_DEF )
{
m_strNotice = strNotice.c_str();
RefreshNoticeText();
//
}
else if( nUseType == SIMSG_SET_NOTICEWND::NOTICE_OLD )
{
// m_strOldNotice = strNotice.c_str();
// RefreshOldNoticeText();
//
}
}
void SUIServerNoticeWnd::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, "notice_scroll" ) )
{
m_nNoticeIndex = nPos;
RefreshNoticeText();
return;
}
else if( !_stricmp( lpszControlID, "vscroll_01" ) )
{
m_nOldNoticeIndex = nPos;
RefreshOldNoticeText();
return;
}
}
break;
}
}
void SUIServerNoticeWnd::RefreshNoticeText()
{
std::string strNewStory;
const int MAX_STORY_LINE_COUNT = 24;
// 대화내용 넘침 방지
std::vector< std::string > vLineList;
vLineList.clear();
dynamicCast< KUIControl* >( GetChild( "notice_text" ) )->SplitLine( vLineList, m_strNotice, S(6425), 7 );
strNewStory += std::string( S(6313)/*"<size:9><top><font:\"돋움\">"*/ );
#ifdef _COUNTRY_ME_
strNewStory += "<RIGHT>";
#endif
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_nNoticeIndex + i ) break;
strNewStory += vLineList[ m_nNoticeIndex + i ];
strNewStory += "<BR>";
}
KUIControlScrollBase* pScroll = dynamicCast< KUIControlScrollBase* >(GetChild( "notice_scroll" ));
if( pScroll )
pScroll->SetScrollRange( MAX_STORY_LINE_COUNT, vLineList.size() );
}
else
{
#ifdef _COUNTRY_ME_
strNewStory += m_strNotice;
#else
strNewStory = m_strNotice;
#endif
m_nNoticeIndex = 0;
}
vLineList.clear();
SetChildCaption( "notice_text", strNewStory.c_str() );
}
void SUIServerNoticeWnd::RefreshOldNoticeText()
{
std::string strNewStory;
const int MAX_STORY_LINE_COUNT = 13;
// 대화내용 넘침 방지
std::vector< std::string > vLineList;
vLineList.clear();
dynamicCast< KUIControl* >( GetChild( "static_notice01_value" ) )->SplitLine( vLineList, m_strOldNotice, S(6425), 9 );
strNewStory += std::string( S(6313)/*"<size:9><top><font:\"돋움\">"*/ );
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_nOldNoticeIndex + i ) break;
strNewStory += vLineList[ m_nOldNoticeIndex + i ];
strNewStory += "<BR>";
}
KUIControlScrollBase* pScroll = dynamicCast< KUIControlScrollBase* >(GetChild( "vscroll_01" ));
if( pScroll )
pScroll->SetScrollRange( MAX_STORY_LINE_COUNT, vLineList.size() );
}
else
{
strNewStory = m_strOldNotice;
m_nOldNoticeIndex = 0;
}
vLineList.clear();
SetChildCaption( "static_notice01_value", strNewStory.c_str() );
}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//약관 동의
SUILicenseWnd::~SUILicenseWnd()
{
}
bool SUILicenseWnd::InitControls( KPoint kPos )
{
return SUIWnd::InitControls(kPos);
}
bool SUILicenseWnd::InitData( bool bReload/* = false*/ )
{
m_nIndex = 0;
KStream * pRes = KFileManager::Instance().CreateStreamFromResource( "license_personal.txt" );
if( pRes )
{
size_t nLen = pRes->GetLength();
char * pstrTemp = new char[nLen+1];
pstrTemp[nLen] = '\0';
for( size_t i(0); nLen>i; i++ )
{
pRes->Read( &pstrTemp[i], 1 );
}
m_strLicense = pstrTemp;
RefreshScroll();
delete [] pstrTemp;
KFileManager::Instance().DeleteStream( pRes );
}
return SUIWnd::InitData(bReload);
}
void SUILicenseWnd::PumpUpMessage( LPCSTR lpszControlID, DWORD nMessage, DWORD lparam, DWORD wparam )
{
switch( nMessage )
{
case KUI_MESSAGE::KBUTTON_CLICK:
{
if( !_stricmp( lpszControlID, "button00" ) )
{ //약관 동의
m_pGameManager->ProcMsgAtStatic( &SIMSG_LICENSE_AGREE( true ) );
}
else if( !_stricmp( lpszControlID, "button01" ) )
{ //약관 동의 안 함
m_pGameManager->ProcMsgAtStatic( &SIMSG_REQ_OPEN_MSGBOX( SIMSG_REQ_OPEN_MSGBOX::MSGBOX_EXITGAME, SYS_MSG_SERVER_EXITGAME ) );
}
}
break;
case KUI_MESSAGE::KSCROLL_SELECT: // 스크롤 선택
{
int nPos = int(lparam);
nPos = max( nPos, 0 );
if( !_stricmp( lpszControlID, "notice01_scroll" ) )
{
m_nIndex = nPos;
RefreshScroll();
return;
}
}
break;
}
SUIWnd::PumpUpMessage( lpszControlID, nMessage, lparam, wparam );
}
void SUILicenseWnd::RefreshScroll()
{
const int MAX_STORY_LINE_COUNT = 33;
std::string strNewStory;
// 대화내용 넘침 방지
std::vector< std::string > vLineList;
vLineList.clear();
dynamicCast< KUIControl* >( GetChild( "notice01_text" ) )->SplitLine( vLineList, m_strLicense );
strNewStory += std::string( S(6313)/*"<size:9><top><font:\"돋움\">"*/ );
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_nIndex + i ) break;
strNewStory += vLineList[ m_nIndex + i ];
strNewStory += "<BR>";
}
KUIControlScrollBase* pScroll = dynamicCast< KUIControlScrollBase* >(GetChild( "notice01_scroll" ));
if( pScroll )
pScroll->SetScrollRange( MAX_STORY_LINE_COUNT, vLineList.size() );
}
else
{
strNewStory = m_nIndex;
m_nIndex = 0;
}
vLineList.clear();
SetChildCaption( "notice01_text", CStringUtil::StringFormat("%s%s", S(6425), strNewStory.c_str()).c_str() );
}