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

373 lines
9.1 KiB
C++

#include "stdafx.h"
#include "Arena\\ArenaJoinSituationChecker.h"
#include "SUIArenaGameBingoBoardWnd.h"
#include "Arena\\ArenaSystem.h"
#include "SUIArenaGameWnd.h"
//#include "SGameMessageUI.h"
#include "ArenaBingoBoard.h"
#include "KUIControlStatic.h"
#include "SGameManager.h"
#include "SGameSystem.h"
#include <toolkit/XStringUtil.h>
#include "SStringDB.h"
//#include "Util.h"
extern SGameSystem* g_pCurrentGameSystem;
struct sDoubleEffect
{
enum { STATE_NONE, STATE_MOVE, STATE_WAIT, STATE_HIDE };
struct sControl
{
KUIControlStatic* m_control;
int m_offsetX;
int m_oriWidth;
};
sDoubleEffect() : m_moveV(400.0f),
m_maxMoveXLen(400.0f),
m_state(0)
{}
~sDoubleEffect() { }
void setParent(SUIWnd* parent)
{
m_parent = parent;
}
void setGameManager(SGameManager* gameManager)
{
m_gameManager = gameManager;
}
void setTextControl(char const* id)
{
setControl(m_text, id);
}
void setBgControl(char const* id)
{
setControl(m_bg, id);
}
void begin()
{
setState(STATE_MOVE);
}
void checkBegin(int bingoCount)
{
if ( 2 > bingoCount)
return ;
setText(bingoCount);
begin();
}
void setText(int bingoCount)
{
int stringId;
if (2 == bingoCount) stringId = 2492;
else if (3 == bingoCount) stringId = 2493;
else return ;
std::string str;
str = "<font:font_02><size:16><#fff568><@252525><out><hcenter>";
str += S(stringId);
/// setcaption 하기 전에 크기를 조절해 준다
resize(str.c_str());
m_text.m_control->SetCaption(str.c_str());
}
void resize(char const* str)
{
KSize size = KTextPhrase::GetStringSize(str, 1024 );
KRect r;
r = m_text.m_control->GetRect();
r.right = r.left + size.width;
m_text.m_control->Resize(r);
/// 배경은 텍스트의 변경된 길이 만큼 바뀌어야 된다.
int modifyTextWidth = size.width - m_text.m_oriWidth;
int newWidth = m_bg.m_oriWidth + modifyTextWidth;
r = m_bg.m_control->GetRect();
r.right = r.left + newWidth;
m_bg.m_control->Resize(r);
}
bool move(float offsetX)
{
bool stop = false;
m_moveXLen += offsetX;
if (m_moveXLen > m_maxMoveXLen)
{
stop = true;
m_moveXLen = m_maxMoveXLen;
}
int px = m_parent->GetRect().left;
int x;
/// text
x = m_text.m_offsetX - (int)m_moveXLen;
m_text.m_control->MovePos(px + x, m_text.m_control->GetRect().top);
/// bg
x = m_bg.m_offsetX - (int)m_moveXLen;
m_bg.m_control->MovePos(px + x, m_bg.m_control->GetRect().top);
return stop;
}
void setState(int state)
{
m_state = state;
switch (state)
{
case STATE_NONE: setShow(false);
break;
case STATE_MOVE: m_moveXLen = 0;
move(0);
setShow(true);
m_gameManager->StartSound( "ui_popup_window01.wav" );
break;
case STATE_WAIT: m_updateTime.begin(3.0f);
break;
case STATE_HIDE : setShow(false);
break;
}
};
void setShow(bool show)
{
m_text.m_control->SetShow(show);
m_bg.m_control->SetShow(show);
}
void process(float elapsedTime)
{
switch (m_state)
{
case STATE_MOVE: procMove(elapsedTime); break;
case STATE_WAIT: procWait(elapsedTime); break;
}
}
void procMove(float elapsedTime)
{
float s = elapsedTime * m_moveV;
bool stop = move(s);
if (stop)
setState(STATE_WAIT);
}
void procWait(float elapsedTime)
{
if (!m_updateTime.update(elapsedTime))
{
setState(STATE_HIDE);
}
}
private:
void setControl(sControl& control, char const* id)
{
control.m_control = dynamicCast<KUIControlStatic*>(m_parent->GetChild(id));
control.m_offsetX = control.m_control->GetRect().left - m_parent->GetRect().left;
control.m_oriWidth = control.m_control->GetRect().GetWidth();
}
public:
int m_state;
float m_moveXLen;
float m_maxMoveXLen;
float m_moveV;
sControl m_text;
sControl m_bg;
SUIWnd* m_parent;
sUpdateTime<float> m_updateTime;
SGameManager* m_gameManager;
};
SUIArenaGameBingoBoardWnd::SUIArenaGameBingoBoardWnd(SGameManager *pGameManager) : SUIWnd(pGameManager),
m_bingoBoard(NULL),
m_doubleEffect(NULL)
{
}
SUIArenaGameBingoBoardWnd::~SUIArenaGameBingoBoardWnd()
{
SAFE_DELETE(m_bingoBoard);
SAFE_DELETE(m_doubleEffect);
m_hideList.clear();
}
bool SUIArenaGameBingoBoardWnd::InitData(bool bReload)
{
initFp();
initHideList();
initDoubleEffect();
createBingoBoard();
return SUIWnd::InitData(bReload);
}
void SUIArenaGameBingoBoardWnd::initFp()
{
m_msgFp.add(MSG_BATTLE_ARENA_BATTLE_STATUS, &SUIArenaGameBingoBoardWnd::procMsgBattleStatus);
m_msgFp.add(MSG_BATTLE_ARENA_BATTLE_INFO, &SUIArenaGameBingoBoardWnd::procMsgBattleInfo);
m_msgFp.add(IMSG_UI_MOVE, &SUIArenaGameBingoBoardWnd::procMsgMove);
m_msgFp.add(IMSG_UI_SEND_DATA, &SUIArenaGameBingoBoardWnd::procMsgSendData);
}
void SUIArenaGameBingoBoardWnd::initHideList()
{
m_hideList.push_back(GetChild("inframe01"));
m_hideList.push_back(GetChild("outframe"));
}
void SUIArenaGameBingoBoardWnd::initDoubleEffect()
{
m_doubleEffect = new sDoubleEffect;
m_doubleEffect->setParent(this);
m_doubleEffect->setGameManager(m_pGameManager);
m_doubleEffect->setTextControl("text_effect_00");
m_doubleEffect->setBgControl("text_effect_bg_00");
m_doubleEffect->setState(sDoubleEffect::STATE_NONE);
}
void SUIArenaGameBingoBoardWnd::createBingoBoard()
{
m_bingoBoard = new sBingoBoard;
m_bingoBoard->initialize(this);
m_bingoBoard->reset();
}
void SUIArenaGameBingoBoardWnd::ProcMsgAtStatic( SGameMessage* msg )
{
m_msgFp.call(msg->nType, this, msg);
}
void SUIArenaGameBingoBoardWnd::Process(DWORD dwTime)
{
SUIWnd::Process(dwTime);
DWORD elapsedTime = 0;
if (m_time)
elapsedTime = dwTime - m_time;
m_time = dwTime;
float e = (float)elapsedTime/1000.0f;
int bingoCount;
m_bingoBoard->process(e, bingoCount);
m_doubleEffect->checkBegin(bingoCount);
m_doubleEffect->process(e);
}
void SUIArenaGameBingoBoardWnd::OnNotifyUIWindowOpen( bool bOpen, bool bLimitWnd )
{
if (bOpen)
{
m_time = 0;
syncPos();
}
}
void SUIArenaGameBingoBoardWnd::setStatus(int bingoManStatus, int bingoManIndex)
{
m_bingoBoard->setStatus(bingoManStatus, bingoManIndex);
}
void SUIArenaGameBingoBoardWnd::syncPos()
{
SUIWnd* bingoWnd = m_pGameManager->GetSUI(SIMSG_TOGGLE_UIWINDOW::UIWINDOW_ARENA_GAME_BINGO);
if (bingoWnd)
MovePos(bingoWnd->GetRect().left, bingoWnd->GetRect().bottom);
}
void SUIArenaGameBingoBoardWnd::procMsgBattleStatus(SGameMessage* msg)
{
msg->bUse = true;
SMSG_BATTLE_ARENA_BATTLE_STATUS* _msg = dynamicCast<SMSG_BATTLE_ARENA_BATTLE_STATUS*>(msg);
/*
빙고일 경우에는 빙고 정보와 함께 빙고된 프랍의 속성이 0으로 되서 날라온다
그런데 클라이언트에서는 빙고 연출을 해야 되기 때문에 0으로 세팅하면 안된다.
그래서 빙고 이전에 받은 프랍 속성을 가지고 클라이언트에서 빙고를 연출해 주고
빙고일 때 받은 메세지는 그냥 넘긴다.
클라의 빙고 연출도 서버에서 받은 빙고 속성 데이타를 쓰기 때문에 동기화는 깨지지 않는다
*/
int bingoCount = 0;
for (int line = 0; line < sBingo::MAX_BINGOLINE_NUM; ++line)
{
if (_msg->IsActivatedBingoLine(line))
{
++bingoCount;
}
}
if (0 < bingoCount)
{
setArenaJoinSituationByBingoCount(bingoCount);
return ;
}
int existPropCount = 0; /// 존재하고 있는 프랍 개수
for (int i = 0; i < sBingoManTable::MAX_BINGOMAN_NUM; ++i)
{
setStatus(_msg->GetPropState(i), i);
if (_PROP_STATE::PS_NOT_EXIST != _msg->GetPropState(i))
++existPropCount;
}
/// 존재하는 프랍이 0일 경우에는 빈 빙고판을 보여준다.
bool showEmptyPanel = (0 == existPropCount) ? true : false;
setShowEmptyBingoPanel(showEmptyPanel);
}
void SUIArenaGameBingoBoardWnd::procMsgBattleInfo(SGameMessage* msg)
{
msg->bUse = true;
m_bingoBoard->reset();
}
void SUIArenaGameBingoBoardWnd::procMsgMove(SGameMessage* msg)
{
msg->bUse = true;
SIMSG_UI_MOVE* _msg = dynamicCast<SIMSG_UI_MOVE*>(msg);
MovePos(_msg->m_nX, _msg->m_nY);
}
void SUIArenaGameBingoBoardWnd::procMsgSendData(SGameMessage* msg)
{
SIMSG_UI_SEND_DATA* _msg = dynamicCast<SIMSG_UI_SEND_DATA*>(msg);
if ("bingoboard_opacity" == _msg->m_strString)
{
setOpacity((bool)_msg->m_dwData);
}
}
void SUIArenaGameBingoBoardWnd::setOpacity(bool opacity)
{
bool show = opacity ? true : false;
std::list<KUIWnd*>::iterator it = m_hideList.begin();
for (; it != m_hideList.end(); ++it)
(*it)->SetShow(show);
}
void SUIArenaGameBingoBoardWnd::setArenaJoinSituationByBingoCount(int bingoCount)
{
int stringId;
if (2 == bingoCount) stringId = 2492; /// 빙고 더블 크래쉬
else if (3 == bingoCount) stringId = 2493; /// 빙고 트리플 크래쉬
else return ;
sArenaJoinSituationCondition situationCondition;
/// way
situationCondition.m_notificationWays = cArenaJoinSituationChecker::WAY_CENTER_NOTICE;
situationCondition.addNone(S(stringId));
g_pCurrentGameSystem->isValidArenaJoinSituation(situationCondition);
}
void SUIArenaGameBingoBoardWnd::setShowEmptyBingoPanel(bool show)
{
sArenaSystem* arenaSystem = g_pCurrentGameSystem->getArenaSystem();
if (show)
{
/// 플레이 중에는 보여주지 않는다
if (arenaSystem->isPlaying())
return ;
}
SetChildShow("panel_bingo_emapty", show);
}