Skip to content

Commit

Permalink
Rename SDrawStaticStruct -> StaticDrawableWrapper.
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel Kovalenko committed Oct 4, 2014
1 parent 0d00ac8 commit e86bd60
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 31 deletions.
2 changes: 1 addition & 1 deletion res/gamedata/scripts/lua_help.script
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ C++ class color {

};

C++ class SDrawStaticStruct {
C++ class StaticDrawableWrapper {
property m_endTime;

function wnd();
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/ActorInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ void CActor::IR_OnKeyboardPress(int cmd)
inventory().ClientEat (itm);
}

SDrawStaticStruct* _s = CurrentGameUI()->AddCustomStatic("item_used", true);
StaticDrawableWrapper* _s = CurrentGameUI()->AddCustomStatic("item_used", true);
string1024 str;
strconcat (sizeof(str),str,*CStringTable().translate("st_item_used"),": ", itm->NameItem());
_s->wnd()->TextItemControl()->SetText(str);
Expand Down
26 changes: 13 additions & 13 deletions src/xrGame/UIGameCustom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct predicate_find_stat
{
const char* id;
predicate_find_stat(const char* id) { this->id = id; }
bool operator()(SDrawStaticStruct* s)
bool operator()(StaticDrawableWrapper* s)
{
return s->m_name == id;
}
Expand Down Expand Up @@ -55,7 +55,7 @@ void CUIGameCustom::OnFrame()
CDialogHolder::OnFrame();
for (auto item : CustomStatics)
item->Update();
auto comparer = [](const SDrawStaticStruct* s1, const SDrawStaticStruct* s2)
auto comparer = [](const StaticDrawableWrapper* s1, const StaticDrawableWrapper* s2)
{
return s1->IsActual() > s2->IsActual();
};
Expand All @@ -79,7 +79,7 @@ void CUIGameCustom::OnFrame()

void CUIGameCustom::Render()
{
for (SDrawStaticStruct* item : CustomStatics)
for (StaticDrawableWrapper* item : CustomStatics)
item->Draw();
Window->Draw();
CEntity* pEntity = smart_cast<CEntity*>(Level().CurrentEntity());
Expand All @@ -105,7 +105,7 @@ void CUIGameCustom::Render()
DoRenderDialogs();
}

SDrawStaticStruct* CUIGameCustom::AddCustomStatic(const char* id, bool singleInstance)
StaticDrawableWrapper* CUIGameCustom::AddCustomStatic(const char* id, bool singleInstance)
{
if (singleInstance)
{
Expand All @@ -114,8 +114,8 @@ SDrawStaticStruct* CUIGameCustom::AddCustomStatic(const char* id, bool singleIns
return *it;
}
CUIXmlInit xmlInit;
CustomStatics.push_back(xr_new<SDrawStaticStruct>());
SDrawStaticStruct* sss = CustomStatics.back();
CustomStatics.push_back(xr_new<StaticDrawableWrapper>());
StaticDrawableWrapper* sss = CustomStatics.back();
sss->m_static = xr_new<CUIStatic>();
sss->m_name = id;
xmlInit.InitStatic(*MsgConfig, id, 0, sss->m_static);
Expand All @@ -125,7 +125,7 @@ SDrawStaticStruct* CUIGameCustom::AddCustomStatic(const char* id, bool singleIns
return sss;
}

SDrawStaticStruct* CUIGameCustom::GetCustomStatic(const char* id)
StaticDrawableWrapper* CUIGameCustom::GetCustomStatic(const char* id)
{
auto it = std::find_if(CustomStatics.begin(), CustomStatics.end(), predicate_find_stat(id));
if (it != CustomStatics.end())
Expand Down Expand Up @@ -270,25 +270,25 @@ void CUIGameCustom::enable_fake_indicators(bool enable)
UIMainIngameWnd->get_hud_states()->EnableFakeIndicators(enable);
}

SDrawStaticStruct::SDrawStaticStruct()
StaticDrawableWrapper::StaticDrawableWrapper()
{
m_static = nullptr;
m_endTime = -1.0f;
}

void SDrawStaticStruct::destroy()
void StaticDrawableWrapper::destroy()
{
delete_data(m_static);
}

bool SDrawStaticStruct::IsActual() const
bool StaticDrawableWrapper::IsActual() const
{
if (m_endTime < 0)
return true;
return Device.fTimeGlobal < m_endTime;
}

void SDrawStaticStruct::SetText(const char* text)
void StaticDrawableWrapper::SetText(const char* text)
{
m_static->Show(text != nullptr);
if (text)
Expand All @@ -298,13 +298,13 @@ void SDrawStaticStruct::SetText(const char* text)
}
}

void SDrawStaticStruct::Draw()
void StaticDrawableWrapper::Draw()
{
if (m_static->IsShown())
m_static->Draw();
}

void SDrawStaticStruct::Update()
void StaticDrawableWrapper::Update()
{
if (IsActual() && m_static->IsShown())
m_static->Update();
Expand Down
13 changes: 7 additions & 6 deletions src/xrGame/UIGameCustom.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ struct KillMessageStruct;
class CUIMainIngameWnd;
class CUIMessagesWindow;

struct SDrawStaticStruct : public IPureDestroyableObject
struct StaticDrawableWrapper : public IPureDestroyableObject
{
SDrawStaticStruct();
virtual void destroy();
CUIStatic* m_static;
float m_endTime;
shared_str m_name;

StaticDrawableWrapper();
virtual void destroy();
void Draw();
void Update();
CUIStatic* wnd() { return m_static; }
Expand Down Expand Up @@ -81,7 +82,7 @@ class CUIGameCustom :
protected:
CUIWindow* Window;
CUIXml* MsgConfig;
xr_vector<SDrawStaticStruct*> CustomStatics;
xr_vector<StaticDrawableWrapper*> CustomStatics;
CUIActorMenu* ActorMenu;
CUIPdaWnd* PdaMenu;
bool showGameIndicators;
Expand Down Expand Up @@ -111,8 +112,8 @@ class CUIGameCustom :
void ShowCrosshair(bool show) { psHUD_Flags.set(HUD_CROSSHAIR_RT, show); }
bool CrosshairShown() { return !!psHUD_Flags.test(HUD_CROSSHAIR_RT); }
virtual void HideShownDialogs() {}
SDrawStaticStruct* AddCustomStatic(const char* id, bool singleInstance);
SDrawStaticStruct* GetCustomStatic(const char* id);
StaticDrawableWrapper* AddCustomStatic(const char* id, bool singleInstance);
StaticDrawableWrapper* GetCustomStatic(const char* id);
void RemoveCustomStatic(const char* id);
void CommonMessageOut(const char* text);
virtual void ChangeTotalMoneyIndicator(const char* newMoneyString) {}
Expand Down
6 changes: 3 additions & 3 deletions src/xrGame/UIGameCustom_script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ void CUIGameCustom::script_register(lua_State *L)
{
module(L)
[
class_< SDrawStaticStruct >("SDrawStaticStruct")
.def_readwrite("m_endTime", &SDrawStaticStruct::m_endTime)
.def("wnd", &SDrawStaticStruct::wnd),
class_< StaticDrawableWrapper >("StaticDrawableWrapper")
.def_readwrite("m_endTime", &StaticDrawableWrapper::m_endTime)
.def("wnd", &StaticDrawableWrapper::wnd),

class_< CUIGameCustom >("CUIGameCustom")
.def("AddDialogToRender", &CUIGameCustom::AddDialogToRender)
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/UIGameSP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ bool CUIGameSP::IR_UIOnKeyboardPress(int dik)

if ( t1 && t1->m_Description.c_str() )
{
SDrawStaticStruct* sm2 = AddCustomStatic("secondary_task", true);
StaticDrawableWrapper* sm2 = AddCustomStatic("secondary_task", true);
sm2->m_static->TextItemControl()->SetTextST (t1->m_Description.c_str());
}
}break;
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/UIGameSP.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class CUIGameSP : public CUIGameCustom
CUITalkWnd* TalkMenu;
CChangeLevelWnd* UIChangeLevelWnd;

SDrawStaticStruct* m_game_objective;
StaticDrawableWrapper* m_game_objective;
};


Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/ai/monsters/basemonster/base_monster_feel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ void CBaseMonster::HitEntity(const CEntity *pEntity, float fDamage, float impuls
if (pEntityNC == Actor() && draw_hit_marks) {
START_PROFILE("BaseMonster/Animation/HitEntity");

SDrawStaticStruct* s = CurrentGameUI()->AddCustomStatic("monster_claws", false);
StaticDrawableWrapper* s = CurrentGameUI()->AddCustomStatic("monster_claws", false);

float h1,p1;
Device.vCameraDirection.getHP (h1,p1);
Expand Down
4 changes: 2 additions & 2 deletions src/xrGame/ai/monsters/controller/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ void CController::UpdateCL()

if (percent < TEXTURE_SIZE_PERCENT ) {
CurrentGameUI()->RemoveCustomStatic("controller_fx2");
SDrawStaticStruct* s = CurrentGameUI()->AddCustomStatic("controller_fx", true);
StaticDrawableWrapper* s = CurrentGameUI()->AddCustomStatic("controller_fx", true);

float x1 = Device.dwWidth / 2 - ((Device.dwWidth / 2) * percent);
float y1 = Device.dwHeight / 2 - ((Device.dwHeight / 2) * percent);
Expand All @@ -447,7 +447,7 @@ void CController::UpdateCL()
s->wnd()->SetWndRect (Frect().set(x1,y1,x2-x1,y2-y1));
} else if (percent2 > 0){
CurrentGameUI()->RemoveCustomStatic("controller_fx");
SDrawStaticStruct* s = CurrentGameUI()->AddCustomStatic("controller_fx2", true);
StaticDrawableWrapper* s = CurrentGameUI()->AddCustomStatic("controller_fx2", true);

float x1 = Device.dwWidth / 2 - ((Device.dwWidth / 2) * percent2);
float y1 = Device.dwHeight / 2 - ((Device.dwHeight / 2) * percent2);
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/console_commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ class CCC_ALifeSave : public IConsole_Command {
#ifdef DEBUG
Msg ("Game save overhead : %f milliseconds",timer.GetElapsed_sec()*1000.f);
#endif
SDrawStaticStruct* _s = CurrentGameUI()->AddCustomStatic("game_saved", true);
StaticDrawableWrapper* _s = CurrentGameUI()->AddCustomStatic("game_saved", true);
LPSTR save_name;
STRCONCAT (save_name, CStringTable().translate("st_game_saved").c_str(), ": ", S);
_s->wnd()->TextItemControl()->SetText(save_name);
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/game_cl_mp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ void game_cl_mp::OnWarnMessage(NET_Packet* P)
{
string512 _buff;
xr_sprintf (_buff,"max_ping_warn_%d", _cnt);
SDrawStaticStruct* ss = CurrentGameUI()->AddCustomStatic(_buff, true);
StaticDrawableWrapper* ss = CurrentGameUI()->AddCustomStatic(_buff, true);

xr_sprintf (_buff,"%d ms.", _ping);
ss->m_static->TextItemControl()->SetText (_buff);
Expand Down

0 comments on commit e86bd60

Please sign in to comment.