280 lines
7.2 KiB
C++
280 lines
7.2 KiB
C++
#include "stdafx.h"
|
|
#include "SUINotificationWnd.h"
|
|
//#include "SGameMessageUI.h"
|
|
#include "NotificationEffect.h"
|
|
#include "SGameManager.h"
|
|
#include "SGameMessage.h"
|
|
#include "CommonUtil.h"
|
|
#include "SStringDB.h"
|
|
|
|
float SUINotificationWnd::SEQUENCE_UPDATE_TIME = 1.0f;
|
|
float SUINotificationWnd::LAST_UPDATE_TIME = 6.0f;
|
|
|
|
SUINotificationWnd::SUINotificationWnd(SGameManager* gameManager) : SUIWnd(gameManager),
|
|
m_time(0),
|
|
m_notificationStatic(NULL)
|
|
{
|
|
m_notificationEffect = new sNotificationEffect;
|
|
}
|
|
|
|
SUINotificationWnd::~SUINotificationWnd()
|
|
{
|
|
m_notificationList.clear();
|
|
m_notificationBuffer.clear();
|
|
|
|
//_LEAK_SUN
|
|
SAFE_DELETE( m_notificationEffect );
|
|
}
|
|
|
|
bool SUINotificationWnd::InitData(bool reload)
|
|
{
|
|
getWndInfo();
|
|
initFp();
|
|
hideUnUsedControl();
|
|
initEffect();
|
|
initTooltip();
|
|
|
|
return SUIWnd::InitData(reload);
|
|
}
|
|
|
|
void SUINotificationWnd::getWndInfo()
|
|
{
|
|
m_notificationStatic = GetChild("text_notify_titlebar_03");
|
|
assert( m_notificationStatic != NULL && "failed get notification static control");
|
|
|
|
m_closeAllButton = GetChild("button_close_all_01");
|
|
assert( m_closeAllButton != NULL && "failed get close all button control");
|
|
}
|
|
|
|
void SUINotificationWnd::initFp()
|
|
{
|
|
/// control
|
|
m_controlFp.add("button_close_all_01", &SUINotificationWnd::close);
|
|
m_controlFp.add("button_notify_close_01", &SUINotificationWnd::removeFirstNotification);
|
|
|
|
/// msg
|
|
m_msgFp.add(IMSG_UI_SEND_DATA, &SUINotificationWnd::procMsgData);
|
|
}
|
|
|
|
void SUINotificationWnd::initTooltip()
|
|
{
|
|
SetChildTooltip("button_close_all_01", S(2363));
|
|
SetChildTooltip("button_notify_close_01", S(2362));
|
|
}
|
|
|
|
void SUINotificationWnd::hideUnUsedControl()
|
|
{
|
|
SetChildShow("mark_notify_arena_01", false);
|
|
SetChildShow("text_notify_titlebar_02", false);
|
|
SetChildShow("button_notify_close_02", false);
|
|
SetChildShow("button_notify_titlebar_01", false);
|
|
SetChildShow("button_notify_disable_01", false);
|
|
}
|
|
|
|
void SUINotificationWnd::initEffect()
|
|
{
|
|
m_notificationEffect->initialize(this);
|
|
|
|
/// body control
|
|
m_notificationEffect->addControl("inframe_notify_01", sNotificationEffect::CONTROL_TYPE_BODY);
|
|
m_notificationEffect->addControl("inframe_notify_contents_01", sNotificationEffect::CONTROL_TYPE_BODY);
|
|
m_notificationEffect->addControl("mark_arena_alliance_01", sNotificationEffect::CONTROL_TYPE_BODY, false);
|
|
m_notificationEffect->addControl("button_notify_close_01", sNotificationEffect::CONTROL_TYPE_BODY, false);
|
|
m_notificationEffect->addControl("text_notify_titlebar_03", sNotificationEffect::CONTROL_TYPE_BODY);
|
|
m_notificationEffect->addControl("outframe_notify_01", sNotificationEffect::CONTROL_TYPE_BODY);
|
|
|
|
/// title control
|
|
m_notificationEffect->addControl("arena_titlebar_default_01", sNotificationEffect::CONTROL_TYPE_TITLE, false);
|
|
m_notificationEffect->addControl("button_close_all_01", sNotificationEffect::CONTROL_TYPE_TITLE, false);
|
|
m_notificationEffect->addControl("text_notify_titlebar_01", sNotificationEffect::CONTROL_TYPE_TITLE, false);
|
|
m_notificationEffect->addControl("button_notify_disable_01", sNotificationEffect::CONTROL_TYPE_TITLE, false);
|
|
}
|
|
|
|
void SUINotificationWnd::OnNotifyUIWindowOpen(bool bOpen, bool bLimitWnd)
|
|
{
|
|
if (bOpen)
|
|
{
|
|
m_time = 0;
|
|
syncPos();
|
|
checkCloseAllButtonVisible();
|
|
m_notificationEffect->start(true);
|
|
m_notificationStatic->SetCaption("");
|
|
/// show 될 때는 항상 맨 위로 오게 해준다
|
|
m_pGameManager->PostMsgAtDynamic( new SIMSG_UI_LIST_MOVE_FORCE_BACK( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_NOTIFICATION ) );
|
|
m_pGameManager->StartSound( "ui_popup_window01.wav" );
|
|
}
|
|
}
|
|
|
|
void SUINotificationWnd::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;
|
|
procEffect(e);
|
|
if (!m_notificationEffect->isActive())
|
|
procUpdate(e);
|
|
}
|
|
|
|
void SUINotificationWnd::procUpdate(float elapsedTime)
|
|
{
|
|
if (!m_updateTime.update(elapsedTime))
|
|
{
|
|
removeFirstNotification();
|
|
}
|
|
}
|
|
|
|
void SUINotificationWnd::procEffect(float elapsedTime)
|
|
{
|
|
if (m_notificationEffect->isActive())
|
|
{
|
|
m_notificationEffect->proc(elapsedTime);
|
|
|
|
if (!m_notificationEffect->isActive())
|
|
{
|
|
applyNotification();
|
|
startEffect();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
startEffect();
|
|
}
|
|
}
|
|
|
|
void SUINotificationWnd::startEffect()
|
|
{
|
|
if (m_notificationBuffer.empty())
|
|
return ;
|
|
|
|
bool first = IsShow() ? false : true;
|
|
m_notificationEffect->start(first);
|
|
//m_notificationEffect->start(m_notificationBuffer.front().c_str());
|
|
}
|
|
|
|
void SUINotificationWnd::applyNotification()
|
|
{
|
|
beginUpdateTime();
|
|
if (!m_notificationBuffer.empty())
|
|
pushNotification(m_notificationBuffer.front().c_str());
|
|
popNotificationBuffer();
|
|
setNotificationToControl();
|
|
}
|
|
|
|
void SUINotificationWnd::checkCloseAllButtonVisible()
|
|
{
|
|
bool show = (1 >= m_notificationList.size()) ? false : true;
|
|
m_closeAllButton->SetShow(show);
|
|
}
|
|
|
|
void SUINotificationWnd::ProcMsgAtStatic( SGameMessage* msg )
|
|
{
|
|
m_msgFp.call(msg->nType, this, msg);
|
|
}
|
|
|
|
void SUINotificationWnd::PumpUpMessage( LPCTSTR controlID, DWORD msg, DWORD lparam, DWORD wparam )
|
|
{
|
|
switch (msg)
|
|
{
|
|
case KUI_MESSAGE::KBUTTON_CLICK: m_controlFp.call(controlID, this); break;
|
|
}
|
|
}
|
|
|
|
void SUINotificationWnd::close()
|
|
{
|
|
m_updateTime.end();
|
|
m_notificationList.clear();
|
|
m_notificationBuffer.clear();
|
|
if (IsShow())
|
|
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_NOTIFICATION, false) );
|
|
}
|
|
|
|
void SUINotificationWnd::popFirstNotification()
|
|
{
|
|
if (m_notificationList.empty())
|
|
return ;
|
|
m_notificationList.pop_front();
|
|
checkCloseAllButtonVisible();
|
|
}
|
|
|
|
void SUINotificationWnd::popNotificationBuffer()
|
|
{
|
|
if (m_notificationBuffer.empty())
|
|
return ;
|
|
m_notificationBuffer.pop_front();
|
|
}
|
|
|
|
void SUINotificationWnd::pushNotification(char const* notification)
|
|
{
|
|
m_notificationList.push_front(notification);
|
|
checkCloseAllButtonVisible();
|
|
}
|
|
|
|
void SUINotificationWnd::pushNotificationBuffer(char const* notification)
|
|
{
|
|
m_notificationBuffer.push_back(notification);
|
|
}
|
|
|
|
bool SUINotificationWnd::isEmptyNotification() const
|
|
{
|
|
return m_notificationList.empty();
|
|
}
|
|
|
|
void SUINotificationWnd::syncPos()
|
|
{
|
|
SUIWnd* menuWnd = m_pGameManager->GetSUI(SIMSG_TOGGLE_UIWINDOW::UIWINDOW_MAINMENU);
|
|
if (menuWnd)
|
|
MovePos(menuWnd->GetRect().left, menuWnd->GetRect().top - GetRect().GetHeight());
|
|
}
|
|
|
|
void SUINotificationWnd::setNotificationToControl()
|
|
{
|
|
if (isEmptyNotification())
|
|
return ;
|
|
|
|
std::string msg;
|
|
msg = "<font:font_01><size:9><#acacac><b><hcenter><top>";
|
|
msg += m_notificationList.front();
|
|
m_notificationStatic->SetCaption(msg.c_str());
|
|
}
|
|
|
|
void SUINotificationWnd::procMsgData(SGameMessage* msg)
|
|
{
|
|
msg->bUse = true;
|
|
|
|
SIMSG_UI_SEND_DATA* msgData = dynamicCast<SIMSG_UI_SEND_DATA*>(msg);
|
|
|
|
if ("pushNotification" == msgData->m_strString)
|
|
{
|
|
if (!IsShow())
|
|
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_NOTIFICATION, true) );
|
|
pushNotificationBuffer(msgData->m_strText.c_str());
|
|
}
|
|
}
|
|
|
|
void SUINotificationWnd::removeFirstNotification()
|
|
{
|
|
popFirstNotification();
|
|
if (isEmptyNotification())
|
|
{
|
|
close();
|
|
}
|
|
else
|
|
{
|
|
setNotificationToControl();
|
|
beginUpdateTime();
|
|
}
|
|
}
|
|
|
|
void SUINotificationWnd::beginUpdateTime()
|
|
{
|
|
if (1 == m_notificationBuffer.size())
|
|
m_updateTime.begin(LAST_UPDATE_TIME);
|
|
else
|
|
m_updateTime.begin(SEQUENCE_UPDATE_TIME);
|
|
}
|