366 lines
8.0 KiB
C++
366 lines
8.0 KiB
C++
#include "stdafx.h"
|
|
#include "SUIArenaGuideTooltipWnd.h"
|
|
#include "Arena\\ArenaSystem.h"
|
|
//#include "SGameMessageUI.h"
|
|
#include "SUIPartyWndDual.h"
|
|
#include "SUIPartyWndMgr.h"
|
|
#include "SMessengerMgr.h"
|
|
#include "SGameManager.h"
|
|
#include "SGameInterface.h"
|
|
#include "SUIPartyTypes.h"
|
|
#include "SGameSystem.h"
|
|
#include "CommonUtil.h"
|
|
//#include "KUIControl.h"
|
|
#include "SStringDB.h"
|
|
|
|
extern SGameSystem* g_pCurrentGameSystem;
|
|
|
|
void SUIArenaGuideTooltipWnd::sScreenChecker::process(float elapsedtime, SUIWnd* parent)
|
|
{
|
|
KSize const& res = KUIWndManager::GetResolution();
|
|
KRect const& wndRect = parent->GetRect();
|
|
|
|
/// 화면 영역을 벗어 났을 때
|
|
if (0 >= wndRect.left || 0 >= wndRect.top || res.width <= wndRect.right || res.height <= wndRect.bottom)
|
|
{
|
|
m_incAlpha = false;
|
|
}
|
|
else
|
|
{
|
|
m_incAlpha = true;
|
|
}
|
|
|
|
float alpha = parent->GetAlpha();
|
|
float v = 4.0f;
|
|
float s = v * elapsedtime;
|
|
if (m_incAlpha)
|
|
{
|
|
alpha += s;
|
|
alpha = min(1.0f, alpha);
|
|
}
|
|
else
|
|
{
|
|
alpha -= s;
|
|
alpha = max(0.0f, alpha);
|
|
}
|
|
|
|
parent->ChangeAlpha(alpha);
|
|
}
|
|
|
|
SUIArenaGuideTooltipWnd::SUIArenaGuideTooltipWnd(SGameManager* pGameManager) : SUIWnd(pGameManager),
|
|
m_textControl(NULL)
|
|
{
|
|
}
|
|
|
|
bool SUIArenaGuideTooltipWnd::InitControls(KPoint kPos)
|
|
{
|
|
bool ret = SUIWnd::InitControls(kPos);
|
|
getWndInfo();
|
|
initGuideType();
|
|
initFp();
|
|
|
|
SetShow(false);
|
|
|
|
return ret;
|
|
}
|
|
|
|
void SUIArenaGuideTooltipWnd::OnNotifyUIWindowOpen( bool bOpen, bool bLimitWnd )
|
|
{
|
|
if (!bOpen)
|
|
{
|
|
m_time = 0;
|
|
}
|
|
}
|
|
|
|
void SUIArenaGuideTooltipWnd::initFp()
|
|
{
|
|
m_msgFp.add(MSG_BATTLE_ARENA_BATTLE_INFO, &SUIArenaGuideTooltipWnd::procMsgBattleInfo);
|
|
}
|
|
|
|
void SUIArenaGuideTooltipWnd::getWndInfo()
|
|
{
|
|
m_textControl = GetChild("help_text");
|
|
assert(!m_textControl && "faild get guide tooltip text control");
|
|
/// arrow
|
|
m_arrowControl[GUIDE_A].set(this, "sign_tooltip_right_00");
|
|
m_arrowControl[GUIDE_B].set(this, "sign_tooltip_left_00");
|
|
m_arrowControl[GUIDE_C].set(this, "sign_tooltip_long_bottom_00");
|
|
|
|
m_oriTextControlHeight = m_textControl->GetRect().GetHeight();
|
|
}
|
|
|
|
void SUIArenaGuideTooltipWnd::initGuideType()
|
|
{
|
|
m_guideType = GUIDE_NONE;
|
|
|
|
m_guide[GUIDE_A].m_wndId = SIMSG_TOGGLE_UIWINDOW::UIWINDOW_ARENA_GAME_SLAUGHTER_PRACTICE;
|
|
m_guide[GUIDE_A].m_offset = KPoint(13, 147);
|
|
m_guide[GUIDE_A].m_stringId = 2388;
|
|
|
|
m_guide[GUIDE_B].m_wndId = SIMSG_TOGGLE_UIWINDOW::UIWINDOW_PARTY;
|
|
m_guide[GUIDE_B].m_offset = KPoint(138, 13);
|
|
m_guide[GUIDE_B].m_stringId = 2389;
|
|
|
|
m_guide[GUIDE_C].m_wndId = SIMSG_TOGGLE_UIWINDOW::UIWINDOW_ARENA_PRACTICE_WAITING;
|
|
m_guide[GUIDE_C].m_offset = KPoint(3, 193);
|
|
m_guide[GUIDE_C].m_stringId = 2390;
|
|
}
|
|
|
|
void SUIArenaGuideTooltipWnd::Process(DWORD dwTime)
|
|
{
|
|
DWORD elapsedtime = 0;
|
|
if (m_time)
|
|
elapsedtime = dwTime - m_time;
|
|
m_time = dwTime;
|
|
|
|
SUIWnd::Process(dwTime);
|
|
|
|
if (IsShow())
|
|
{
|
|
syncTargetPos();
|
|
|
|
float e = (float)elapsedtime/1000.0f;
|
|
m_screenChecker.process(e, this);
|
|
}
|
|
}
|
|
|
|
void SUIArenaGuideTooltipWnd::syncTargetPos()
|
|
{
|
|
if (GUIDE_NONE == m_guideType)
|
|
return ;
|
|
|
|
sGuide* guide = m_guide + m_guideType;
|
|
if (guide->m_wnd)
|
|
{
|
|
int targetX = guide->m_wnd->GetRect().left + guide->m_offset.x;
|
|
int targetY = guide->m_wnd->GetRect().top + guide->m_offset.y;
|
|
|
|
int x = 0, y = 0;
|
|
calcArrowRelativelyPos(targetX, targetY, x, y);
|
|
MovePos(x, y);
|
|
}
|
|
}
|
|
|
|
void SUIArenaGuideTooltipWnd::postShowMsg(bool show)
|
|
{
|
|
if (IsShow() == show)
|
|
return ;
|
|
m_pGameManager->PostMsgAtDynamic( new SIMSG_SHOW_UIWINDOW( SIMSG_TOGGLE_UIWINDOW::UIWINDOW_ARENA_GUIDE_TOOLTIP, show) );
|
|
}
|
|
|
|
void SUIArenaGuideTooltipWnd::resizeWndAtText()
|
|
{
|
|
struct sResize
|
|
{
|
|
void apply(KUIWnd* wnd, int height)
|
|
{
|
|
if (!wnd)
|
|
return ;
|
|
KRect r = wnd->GetRect();
|
|
r.bottom = r.top + height;
|
|
wnd->Resize(r);
|
|
}
|
|
};
|
|
|
|
int textHeight = m_textControl->GetCaptionPhraseSize().height;
|
|
|
|
/// 18이라는 수치는 help_text와 outframe_tooltip의 차이 값이다. 별로 안좋다,,
|
|
sResize r;
|
|
r.apply(m_textControl, textHeight);
|
|
r.apply(GetChild("outframe_tooltip"), textHeight + 18);
|
|
r.apply(this, textHeight + 122);
|
|
|
|
/// c 타입은 늘어난 길이 만큼 화살표를 이동 시켜 줘야 된다
|
|
if (GUIDE_C == m_guideType)
|
|
{
|
|
KPoint offset = m_arrowControl[m_guideType].m_oriOffset;
|
|
int changedHeight = textHeight - m_oriTextControlHeight;
|
|
offset.y += changedHeight;
|
|
|
|
KPoint pos(GetRect().left, GetRect().top);
|
|
pos.x += offset.x;
|
|
pos.y += offset.y;
|
|
|
|
m_arrowControl[m_guideType].m_control->MovePos(pos.x, pos.y);
|
|
}
|
|
|
|
LimitMoveWnd();
|
|
}
|
|
|
|
void SUIArenaGuideTooltipWnd::calcArrowRelativelyPos(int targetX, int targetY, int& x, int& y)
|
|
{
|
|
if (m_guideType == GUIDE_NONE)
|
|
return ;
|
|
|
|
int ax = 0, ay = 0;
|
|
KRect aRect = m_arrowControl[m_guideType].m_control->GetRect();
|
|
if (GUIDE_B == m_guideType)
|
|
{
|
|
ax = targetX;
|
|
ay = targetY;
|
|
}
|
|
if (GUIDE_A == m_guideType)
|
|
{
|
|
ax = targetX - aRect.GetWidth();
|
|
ay = targetY;
|
|
}
|
|
else if (GUIDE_C == m_guideType)
|
|
{
|
|
ax = targetX - aRect.GetWidth();
|
|
ay = targetY - aRect.GetHeight();
|
|
}
|
|
|
|
int offsetX = GetRect().left - aRect.left;
|
|
int offsetY = GetRect().top - aRect.top;
|
|
x = ax + offsetX;
|
|
y = ay + offsetY;
|
|
}
|
|
|
|
void SUIArenaGuideTooltipWnd::procCheckGuideType()
|
|
{
|
|
if (!g_pCurrentGameSystem->isArenaExercise() || g_pCurrentGameSystem->isInArena())
|
|
{
|
|
setGuideType(GUIDE_NONE); return ;
|
|
}
|
|
|
|
if (checkGuideTypeA())
|
|
return ;
|
|
if (checkGuideTypeB())
|
|
return ;
|
|
if (checkGuideTypeC())
|
|
return ;
|
|
|
|
setGuideType(GUIDE_NONE);
|
|
}
|
|
|
|
void SUIArenaGuideTooltipWnd::checkValidWnd(int guideType)
|
|
{
|
|
sGuide* guide = m_guide + guideType;
|
|
if (guide->m_wnd)
|
|
return ;
|
|
|
|
if (GUIDE_B == guideType)
|
|
{
|
|
int id;
|
|
SUIPartyWndMgr* wnd = dynamicCast<SUIPartyWndMgr*>(m_pGameManager->GetSUI(guide->m_wndId));
|
|
guide->m_wnd = wnd->FindWnd(m_PartyMgr.GetPartyName(), id);
|
|
}
|
|
else
|
|
{
|
|
guide->m_wnd = m_pGameManager->GetSUI(guide->m_wndId);
|
|
}
|
|
}
|
|
|
|
bool SUIArenaGuideTooltipWnd::checkGuideTypeA()
|
|
{
|
|
checkValidWnd(GUIDE_A);
|
|
sGuide* guide = m_guide + GUIDE_A;
|
|
if (!guide->m_wnd)
|
|
return false;
|
|
if (!guide->m_wnd->IsShow())
|
|
return false;
|
|
|
|
KUIControl* control = dynamicCast<KUIControl*>(guide->m_wnd->GetChild("button_member_invite_witch_01"));
|
|
if (control && control->IsShow())
|
|
{
|
|
setGuideType(GUIDE_A);
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
bool SUIArenaGuideTooltipWnd::checkGuideTypeB()
|
|
{
|
|
checkValidWnd(GUIDE_B);
|
|
sGuide* guide = m_guide + GUIDE_B;
|
|
if (!guide->m_wnd)
|
|
return false;
|
|
if (!guide->m_wnd->IsShow())
|
|
return false;
|
|
|
|
sArenaSystem* arenaSystem = g_pCurrentGameSystem->getArenaSystem();
|
|
int myTeam = arenaSystem->getMyTeam();
|
|
|
|
/// 래뒤 상태면 안보이도록 한다
|
|
if (arenaSystem->isReady(myTeam))
|
|
return false;
|
|
|
|
if (1 == arenaSystem->getPlayerCount(myTeam))
|
|
{
|
|
setGuideType(GUIDE_B);
|
|
|
|
bool show = true;
|
|
/// b 타입 일 경우에는 우클릭 메뉴에 따라서 show/hide가 바뀐다
|
|
if (m_pGameManager->GetGameInterface()->IsShow(SIMSG_TOGGLE_UIWINDOW::UIWINDOW_PARTY_MENU))
|
|
show = false;
|
|
postShowMsg(show);
|
|
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
bool SUIArenaGuideTooltipWnd::checkGuideTypeC()
|
|
{
|
|
checkValidWnd(GUIDE_C);
|
|
sGuide* guide = m_guide + GUIDE_C;
|
|
if (!guide->m_wnd)
|
|
return false;
|
|
if (!guide->m_wnd->IsShow())
|
|
return false;
|
|
|
|
sArenaSystem* arenaSystem = g_pCurrentGameSystem->getArenaSystem();
|
|
int myTeam = arenaSystem->getMyTeam();
|
|
bool isUnitLeader = m_PartyMgr.IsPartyLeader();
|
|
if (isUnitLeader)
|
|
{
|
|
if (!arenaSystem->isReady(myTeam))
|
|
{
|
|
setGuideType(GUIDE_C);
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
void SUIArenaGuideTooltipWnd::setGuideType(int guideType)
|
|
{
|
|
if (guideType == m_guideType)
|
|
{
|
|
return ;
|
|
}
|
|
|
|
m_guideType = guideType;
|
|
|
|
if (GUIDE_NONE == guideType)
|
|
{
|
|
postShowMsg(false);
|
|
return ;
|
|
}
|
|
|
|
postShowMsg(true);
|
|
|
|
sGuide* guide = m_guide + guideType;
|
|
m_textControl->SetCaption(S(guide->m_stringId));
|
|
|
|
for (int i = GUIDE_A; i < MAX_GUIDE_NUM; ++i)
|
|
m_arrowControl[i].setShow(false);
|
|
m_arrowControl[m_guideType].setShow(true);
|
|
|
|
resizeWndAtText();
|
|
|
|
syncTargetPos();
|
|
}
|
|
|
|
void SUIArenaGuideTooltipWnd::ProcMsgAtStatic(SGameMessage* msg)
|
|
{
|
|
m_msgFp.call(msg->nType, this, msg);
|
|
}
|
|
|
|
void SUIArenaGuideTooltipWnd::procMsgBattleInfo(SGameMessage *msg)
|
|
{
|
|
setGuideType(GUIDE_NONE);
|
|
}
|