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

227 lines
6.7 KiB
C++

#include "stdafx.h"
/// 2011.02.08 - prodongi
#include "CharacterInfo/SUICharacterInfoSubAddedWnd.h"
#include "CharacterInfo/SUICharacterInfoWnd.h"
#include "Arena\\ArenaUtility.h"
#include "CommonUtil.h"
#include <toolkit/XStringUtil.h>
#include "SGameMessage.h"
#include "SPlayerInfoMgr.h"
#include "SNetMessage.h"
#include "SMessage.h"
#include "SStringDB.h"
//#include "Util.h"
bool SUICharacterInfoSubAddedWnd::InitControls( KPoint kPos )
{
bool ret = SUIWnd::InitControls(kPos);
m_moralGageCube = GetChild("added_gauge_cube");
m_moralGage = GetChild("added_gauge");
return ret;
}
void SUICharacterInfoSubAddedWnd::refreshAll()
{
refreshPropensity();
}
void SUICharacterInfoSubAddedWnd::refreshGameScore(SMSG_INSTANCE_GAME_SCORE* score)
{
if (score)
{
std::string str, strTag;
strTag = "<font:font_01><left><size:9><#ffffff><hcenter>";
str = strTag + CStringUtil::GetCommaNumberString( score->deathmatch_kill_count );
SetChildCaption( "text_victory_num", str.c_str());
str = strTag + CStringUtil::GetCommaNumberString( score->deathmatch_death_count );
SetChildCaption( "text_lose_num", str.c_str());
strTag = "<font:font_01><right><size:9><#ffffff>";
str = strTag + CStringUtil::GetCommaNumberString( score->holicpoint );
SetChildCaption( "text_holic_num", str.c_str());
str = strTag + CStringUtil::GetCommaNumberString( score->bearroad_ranking );
SetChildCaption( "text_rank_num", str.c_str());
str = CStringUtil::GetCommaNumberString("<font:font_01><hcenter><size:9><#ffffff><right>", score->battle_arena_point);
SetChildCaption("text_arena_num_00", str.c_str());
str = CStringUtil::GetCommaNumberString("<font:font_01><right><size:9><#ffffff>", score->battle_arena_mvp_count);
SetChildCaption("text_arena_mvp_num_00", str.c_str());
struct sSetArenaScore
{
public:
sSetArenaScore() : m_totalWin(0), m_totalLose(0) {}
void setCaption(SUIWnd* wnd, int win, int lose, int index)
{
setCaption(wnd, "text_arena_record_win_%02d", "<#1061da>", win, index);
setCaption(wnd, "text_arena_record_lose_%02d", "<#9e0b0f>", lose, index);
setCaptionTotal(wnd, "text_winning_rate_num_%02d", win, lose, index);
m_totalWin += win;
m_totalLose += lose;
}
private:
void setCaption(SUIWnd* wnd, char const* format, char const* color, int score, int index)
{
std::string str, id;
XStringUtil::Format(id, format, index);
std::string tag;
XStringUtil::Format(tag, "<font:font_01><right><size:9>%s", color);
str = CStringUtil::GetCommaNumberString(tag.c_str(), score);
wnd->SetChildCaption(id.c_str(), str.c_str());
}
void setCaptionTotal(SUIWnd* wnd, char const* format, int win, int lose, int index)
{
int p = 0;
int total = win + lose;
if (0 != total)
p = (win * 100)/total;
std::string str, id;
XStringUtil::Format(id, format, index);
XStringUtil::Format(str, "<font:font_01><hcenter><size:9>%d%%", p);
wnd->SetChildCaption(id.c_str(), str.c_str());
}
public:
int m_totalWin;
int m_totalLose;
};
sSetArenaScore setScore;
for (int m = 0; m < sArenaUtility::MAX_MODE_NUM; ++m)
{
setScore.setCaption(this, score->battle_arena_record[m][0], score->battle_arena_record[m][1], m+1);
}
setScore.setCaption(this, setScore.m_totalWin, setScore.m_totalLose, 0);
}
else
{
SetChildCaption( "text_victory_num", "");
SetChildCaption( "text_lose_num", "");
SetChildCaption( "text_holic_num", "");
SetChildCaption( "text_rank_num", "");
}
}
void SUICharacterInfoSubAddedWnd::refreshPropensity()
{
SPlayerInfo & info = m_PlayerInfoMgr.GetPlayerInfo();
//이모럴
__int64 moral = info.GetMoral();
char const* fontColor;
if (moral == 0)
{
fontColor = "<#FFFFFF>";
}
if( moral < 0 )
{
moral = _abs64(moral);
fontColor = "<#1D79D7>";
}
else
{
fontColor = "<#AE0000>";
}
// bintitle. 2011.11.07. int => __int64.
__int64 moralQuotient = moral/10000;
int moralRemainder = moral%10000;
SetChildCaption("text_immoral_num_evil_01", CStringUtil::StringFormat("<font:font_01><hcenter><size:9>%s%I64d", fontColor, moralQuotient).c_str());
SetChildCaption("text_immoral_num_evil_02", CStringUtil::StringFormat("<font:font_01><size:7><center><vcenter>%s%d", fontColor, moralRemainder).c_str());
//PK
int index;
if( info.GetStatus() & TS_ENTER::PlayerInfo::FLAG_PK_ON ) index = 6403;
else index = 6404;
SetChildCaption( "text_pk_status_on_off", CStringUtil::StringFormat( "<font:font_01><hcenter><size:9><#ffffff>%s", S(index) ).c_str() );
//PK COUNT
SetChildCaption( "text_pk_num", CStringUtil::StringFormat( "<font:font_01><hcenter><size:9><#ffffff>%d",info.GetPk_count() ).c_str() );
//학살 횟수
SetChildCaption( "text_kill_num", CStringUtil::StringFormat( "<font:font_01><hcenter><size:9><#ffffff>%d",info.GetDk_count() ).c_str() );
// moral gage
int moralPos = calcMoralGagePos(info.GetMoral());
KPoint offset(m_moralGage->GetRect().left, m_moralGageCube->GetRect().top);
m_moralGageCube->MovePos(moralPos + offset.x + 2, offset.y);
}
// bintitle. 2011.11.07. int => __int64.
int SUICharacterInfoSubAddedWnd::calcMoralGagePos(__int64 moral) const
{
int moralNeutral = 110000;
int moralTotal = 220000;
int gageWidth = m_moralGage->GetRect().GetWidth();
int cubeWidth = m_moralGageCube->GetRect().GetWidth();
int gageRealWidth = gageWidth - cubeWidth;
float moralInterval = (float)gageRealWidth/(float)moralTotal;
__int64 pos;
moral /= 10000;
if (0 == moral) // 중립
{
pos = moralNeutral;
}
else
{
bool good = (0 > moral) ? true : false;
moral = _abs64(moral);
if( 110000 <= moral ) moral = 110000;
if (good) pos = moralNeutral + moral;
else pos = moralNeutral - moral;
}
int _pos = (int)((double)pos * moralInterval);
return _pos;
}
void SUICharacterInfoSubAddedWnd::setExpand(bool expand, bool applyParent)
{
m_isExpand = expand;
/// parent
if (applyParent)
{
SUICharacterInfoWnd* parent = dynamicCast<SUICharacterInfoWnd*>(GetParent());
parent->setExpand(expand);
}
bool show = expand ? true : false;
/// 데스매치 전적
SetChildShow("text_added_01", show);
SetChildShow("text_vicroty", show);
SetChildShow("text_victory_num", show);
SetChildShow("text_lose", show);
SetChildShow("text_lose_num", show);
SetChildShow("added_table_01", show);
/// 베어로드 전적
SetChildShow("text_added_02", show);
SetChildShow("text_holic", show);
SetChildShow("text_holic_num", show);
SetChildShow("text_p", show);
SetChildShow("text_rank", show);
SetChildShow("text_rank_num", show);
SetChildShow("text_rank_01", show);
SetChildShow("added_table_02", show);
SetChildShow("tab_select_cyan_01", false);
SetChildShow("tab_select_cyan_02", false);
if (!expand) SetChildShow("tab_select_cyan_01", true);
else SetChildShow("tab_select_cyan_02", true);
setShowFoldButton(expand);
}