From 144788e2fe8ce8982906e4dd1433d286baab78a1 Mon Sep 17 00:00:00 2001 From: Pavel Kovalenko Date: Sat, 4 Oct 2014 13:40:27 +0400 Subject: [PATCH] Fix conventions. --- src/xrGame/ActorInput.cpp | 2 +- src/xrGame/Actor_Network.cpp | 4 +- src/xrGame/GamePersistent.cpp | 2 +- src/xrGame/Inventory.cpp | 4 +- src/xrGame/InventoryBox.cpp | 4 +- src/xrGame/Level_network.cpp | 2 +- src/xrGame/UIGameAHunt.cpp | 6 +- src/xrGame/UIGameCTA.cpp | 30 +- src/xrGame/UIGameCustom.cpp | 696 +++++++++----------- src/xrGame/UIGameCustom.h | 189 +++--- src/xrGame/UIGameDM.cpp | 26 +- src/xrGame/UIGameMP.cpp | 2 +- src/xrGame/UIGameSP.cpp | 32 +- src/xrGame/UIGameTDM.cpp | 10 +- src/xrGame/console_commands.cpp | 4 +- src/xrGame/game_cl_artefacthunt.cpp | 2 +- src/xrGame/game_cl_capture_the_artefact.cpp | 2 +- src/xrGame/game_cl_deathmatch.cpp | 12 +- src/xrGame/game_cl_teamdeathmatch.cpp | 4 +- src/xrGame/ui/ChangeWeatherDialog.cpp | 8 +- src/xrGame/ui/UIGameTutorial.cpp | 4 +- src/xrGame/ui/UIGameTutorialSimpleItem.cpp | 22 +- src/xrGame/ui/UIMainIngameWnd.cpp | 2 +- src/xrGame/ui/UIMapList.cpp | 18 +- 24 files changed, 504 insertions(+), 583 deletions(-) diff --git a/src/xrGame/ActorInput.cpp b/src/xrGame/ActorInput.cpp index 46acf50d23b..cb441ad4d03 100644 --- a/src/xrGame/ActorInput.cpp +++ b/src/xrGame/ActorInput.cpp @@ -184,7 +184,7 @@ void CActor::IR_OnKeyboardPress(int cmd) strconcat (sizeof(str),str,*CStringTable().translate("st_item_used"),": ", itm->NameItem()); _s->wnd()->TextItemControl()->SetText(str); - CurrentGameUI()->ActorMenu().m_pQuickSlot->ReloadReferences(this); + CurrentGameUI()->GetActorMenu().m_pQuickSlot->ReloadReferences(this); } } }break; diff --git a/src/xrGame/Actor_Network.cpp b/src/xrGame/Actor_Network.cpp index 005834073da..1ae7c804b17 100644 --- a/src/xrGame/Actor_Network.cpp +++ b/src/xrGame/Actor_Network.cpp @@ -1344,7 +1344,7 @@ void CActor::save(NET_Packet &output_packet) inherited::save(output_packet); CInventoryOwner::save(output_packet); output_packet.w_u8(u8(m_bOutBorder)); - CUITaskWnd* task_wnd = HUD().GetGameUI()->PdaMenu().pUITaskWnd; + CUITaskWnd* task_wnd = HUD().GetGameUI()->GetPdaMenu().pUITaskWnd; output_packet.w_u8(task_wnd->IsTreasuresEnabled() ? 1 : 0); output_packet.w_u8(task_wnd->IsQuestNpcsEnabled() ? 1 : 0); output_packet.w_u8(task_wnd->IsSecondaryTasksEnabled() ? 1 : 0); @@ -1361,7 +1361,7 @@ void CActor::load(IReader &input_packet) inherited::load(input_packet); CInventoryOwner::load(input_packet); m_bOutBorder=!!(input_packet.r_u8()); - CUITaskWnd* task_wnd = HUD().GetGameUI()->PdaMenu().pUITaskWnd; + CUITaskWnd* task_wnd = HUD().GetGameUI()->GetPdaMenu().pUITaskWnd; task_wnd->TreasuresEnabled(!!input_packet.r_u8()); task_wnd->QuestNpcsEnabled(!!input_packet.r_u8()); task_wnd->SecondaryTasksEnabled(!!input_packet.r_u8()); diff --git a/src/xrGame/GamePersistent.cpp b/src/xrGame/GamePersistent.cpp index 6def8317a65..833f30cf5c6 100644 --- a/src/xrGame/GamePersistent.cpp +++ b/src/xrGame/GamePersistent.cpp @@ -706,7 +706,7 @@ void CGamePersistent::OnEvent(EVENT E, u64 P1, u64 P2) { CurrentGameUI()->HideShownDialogs(); CurrentGameUI()->UIMainIngameWnd->reset_ui(); - CurrentGameUI()->PdaMenu().Reset(); + CurrentGameUI()->GetPdaMenu().Reset(); } if(g_tutorial) diff --git a/src/xrGame/Inventory.cpp b/src/xrGame/Inventory.cpp index 16c85884b61..2e2a36a8e66 100644 --- a/src/xrGame/Inventory.cpp +++ b/src/xrGame/Inventory.cpp @@ -195,9 +195,9 @@ void CInventory::Take(CGameObject *pObj, bool bNotActivate, bool strict_placemen { CurrentGameUI()->OnInventoryAction(pIItem, GE_OWNERSHIP_TAKE); } - else if(CurrentGameUI()->ActorMenu().GetMenuMode()==mmDeadBodySearch) + else if(CurrentGameUI()->GetActorMenu().GetMenuMode()==mmDeadBodySearch) { - if(m_pOwner==CurrentGameUI()->ActorMenu().GetPartner()) + if(m_pOwner==CurrentGameUI()->GetActorMenu().GetPartner()) CurrentGameUI()->OnInventoryAction(pIItem, GE_OWNERSHIP_TAKE); } }; diff --git a/src/xrGame/InventoryBox.cpp b/src/xrGame/InventoryBox.cpp index 12fbd9c4819..8d809ffc6db 100644 --- a/src/xrGame/InventoryBox.cpp +++ b/src/xrGame/InventoryBox.cpp @@ -42,9 +42,9 @@ void CInventoryBox::OnEvent(NET_Packet& P, u16 type) VERIFY (pIItem); if( CurrentGameUI() ) { - if(CurrentGameUI()->ActorMenu().GetMenuMode()==mmDeadBodySearch) + if(CurrentGameUI()->GetActorMenu().GetMenuMode()==mmDeadBodySearch) { - if(this==CurrentGameUI()->ActorMenu().GetInvBox()) + if(this==CurrentGameUI()->GetActorMenu().GetInvBox()) CurrentGameUI()->OnInventoryAction(pIItem, GE_OWNERSHIP_TAKE); } }; diff --git a/src/xrGame/Level_network.cpp b/src/xrGame/Level_network.cpp index a6e02a29e72..d1ca5df6f2d 100644 --- a/src/xrGame/Level_network.cpp +++ b/src/xrGame/Level_network.cpp @@ -124,7 +124,7 @@ void CLevel::net_Stop () if(CurrentGameUI()) { CurrentGameUI()->HideShownDialogs(); - CurrentGameUI()->PdaMenu().Reset(); + CurrentGameUI()->GetPdaMenu().Reset(); } if(g_tutorial && !g_tutorial->Persistent()) diff --git a/src/xrGame/UIGameAHunt.cpp b/src/xrGame/UIGameAHunt.cpp index 0fe25fa7ce4..f618e2639d5 100644 --- a/src/xrGame/UIGameAHunt.cpp +++ b/src/xrGame/UIGameAHunt.cpp @@ -25,7 +25,7 @@ void CUIGameAHunt::Init (int stage) if(stage==0) { // shared inherited::Init (stage); - m_buy_msg_caption = UIHelper::CreateTextWnd(*m_msgs_xml, "mp_ah_buy", m_window); + m_buy_msg_caption = UIHelper::CreateTextWnd(*MsgConfig, "mp_ah_buy", Window); } if(stage==1) { //unique @@ -34,7 +34,7 @@ void CUIGameAHunt::Init (int stage) CUIXml uiXml; uiXml.Load (CONFIG_PATH, UI_PATH, "ui_game_ahunt.xml"); - CUIXmlInit::InitWindow (uiXml, "global", 0, m_window); + CUIXmlInit::InitWindow (uiXml, "global", 0, Window); CUIXmlInit::InitTextWnd (uiXml, "fraglimit",0, m_pFragLimitIndicator); m_pReinforcementInidcator = xr_new(); @@ -52,7 +52,7 @@ void CUIGameAHunt::Init (int stage) if(stage==2) { //after inherited::Init (stage); - m_window->AttachChild (m_pReinforcementInidcator); + Window->AttachChild (m_pReinforcementInidcator); } }; diff --git a/src/xrGame/UIGameCTA.cpp b/src/xrGame/UIGameCTA.cpp index 28797661c32..56650351502 100644 --- a/src/xrGame/UIGameCTA.cpp +++ b/src/xrGame/UIGameCTA.cpp @@ -64,14 +64,14 @@ void CUIGameCTA::Init(int stage) { if(stage==0) { - m_round_result_caption = UIHelper::CreateTextWnd(*m_msgs_xml, "mp_round_result", m_window); - m_pressbuy_caption = UIHelper::CreateTextWnd(*m_msgs_xml, "mp_pressbuy", m_window); - m_pressjump_caption = UIHelper::CreateTextWnd(*m_msgs_xml, "mp_pressjump", m_window); - m_spectator_caption = UIHelper::CreateTextWnd(*m_msgs_xml, "mp_spectator", m_window); - m_spectrmode_caption = UIHelper::CreateTextWnd(*m_msgs_xml, "mp_spetatormode", m_window); - m_warm_up_caption = UIHelper::CreateTextWnd(*m_msgs_xml, "mp_warm_up", m_window); - m_time_caption = UIHelper::CreateTextWnd(*m_msgs_xml, "mp_timelimit", m_window); - m_demo_play_caption = UIHelper::CreateTextWnd(*m_msgs_xml, "mp_demo_play", m_window); + m_round_result_caption = UIHelper::CreateTextWnd(*MsgConfig, "mp_round_result", Window); + m_pressbuy_caption = UIHelper::CreateTextWnd(*MsgConfig, "mp_pressbuy", Window); + m_pressjump_caption = UIHelper::CreateTextWnd(*MsgConfig, "mp_pressjump", Window); + m_spectator_caption = UIHelper::CreateTextWnd(*MsgConfig, "mp_spectator", Window); + m_spectrmode_caption = UIHelper::CreateTextWnd(*MsgConfig, "mp_spetatormode", Window); + m_warm_up_caption = UIHelper::CreateTextWnd(*MsgConfig, "mp_warm_up", Window); + m_time_caption = UIHelper::CreateTextWnd(*MsgConfig, "mp_timelimit", Window); + m_demo_play_caption = UIHelper::CreateTextWnd(*MsgConfig, "mp_demo_play", Window); teamPanels = xr_new(); teamPanels->Init (TEAM_PANELS_XML_NAME, "team_panels_wnd"); @@ -80,7 +80,7 @@ void CUIGameCTA::Init(int stage) CUIXml uiXml; uiXml.Load (CONFIG_PATH, UI_PATH, CTA_GAME_WND_XML); - CUIXmlInit::InitWindow (uiXml, "global", 0, m_window); + CUIXmlInit::InitWindow (uiXml, "global", 0, Window); m_pMoneyIndicator = xr_new(); m_pMoneyIndicator->SetAutoDelete(true); @@ -114,12 +114,12 @@ void CUIGameCTA::Init(int stage) if(stage==2) { inherited::Init (stage); - m_window->AttachChild (m_pMoneyIndicator); - m_window->AttachChild (m_pRankIndicator); - m_window->AttachChild (m_pReinforcementInidcator); - m_window->AttachChild (m_pFragLimitIndicator); - m_window->AttachChild (m_team1_score); - m_window->AttachChild (m_team2_score); + Window->AttachChild (m_pMoneyIndicator); + Window->AttachChild (m_pRankIndicator); + Window->AttachChild (m_pReinforcementInidcator); + Window->AttachChild (m_pFragLimitIndicator); + Window->AttachChild (m_team1_score); + Window->AttachChild (m_team2_score); } } diff --git a/src/xrGame/UIGameCustom.cpp b/src/xrGame/UIGameCustom.cpp index 1b01067845b..f365d7738ee 100644 --- a/src/xrGame/UIGameCustom.cpp +++ b/src/xrGame/UIGameCustom.cpp @@ -16,488 +16,432 @@ #include "inventory.h" #include "game_cl_base.h" -#include "../xrEngine/x_ray.h" +#include "xrEngine/x_ray.h" -EGameIDs ParseStringToGameType(LPCSTR str); +EGameIDs ParseStringToGameType(const char* str); -bool predicate_sort_stat(const SDrawStaticStruct* s1, const SDrawStaticStruct* s2) +bool predicate_sort_stat(const SDrawStaticStruct* s1, const SDrawStaticStruct* s2) { - return ( s1->IsActual() > s2->IsActual() ); + return s1->IsActual() > s2->IsActual(); } -struct predicate_find_stat +struct predicate_find_stat { - LPCSTR m_id; - predicate_find_stat(LPCSTR id):m_id(id) {} - bool operator() (SDrawStaticStruct* s) - { - return ( s->m_name==m_id ); - } + const char* id; + predicate_find_stat(const char* id) { this->id = id; } + bool operator()(SDrawStaticStruct* s) + { + return s->m_name == id; + } }; CUIGameCustom::CUIGameCustom() -:m_msgs_xml(NULL),m_ActorMenu(NULL),m_PdaMenu(NULL),m_window(NULL),UIMainIngameWnd(NULL),m_pMessagesWnd(NULL) { - ShowGameIndicators (true); - ShowCrosshair (true); - + MsgConfig = nullptr; + ActorMenu = nullptr; + PdaMenu = nullptr; + Window = nullptr; + UIMainIngameWnd = nullptr; + m_pMessagesWnd = nullptr; + ShowGameIndicators(true); + ShowCrosshair(true); } + bool g_b_ClearGameCaptions = false; CUIGameCustom::~CUIGameCustom() { - delete_data (m_custom_statics); - g_b_ClearGameCaptions = false; -} - - -void CUIGameCustom::OnFrame() -{ - CDialogHolder::OnFrame(); - st_vec_it it = m_custom_statics.begin(); - st_vec_it it_e = m_custom_statics.end(); - for(;it!=it_e;++it) - (*it)->Update(); - - std::sort( it, it_e, predicate_sort_stat ); - - - while(!m_custom_statics.empty() && !m_custom_statics.back()->IsActual()) - { - delete_data (m_custom_statics.back()); - m_custom_statics.pop_back (); - } - - if(g_b_ClearGameCaptions) - { - delete_data (m_custom_statics); - g_b_ClearGameCaptions = false; - } - m_window->Update(); - - //update windows - if( GameIndicatorsShown() && psHUD_Flags.is(HUD_DRAW|HUD_DRAW_RT) ) - UIMainIngameWnd->Update (); - - m_pMessagesWnd->Update(); + delete_data(CustomStatics); + g_b_ClearGameCaptions = false; +} + +void CUIGameCustom::OnFrame() +{ + CDialogHolder::OnFrame(); + auto it = CustomStatics.begin(); + auto it_e = CustomStatics.end(); + for (; it != it_e; ++it) + (*it)->Update(); + // BUG: sort is never performed here, so not all inactual items will be deleted + std::sort(it, it_e, predicate_sort_stat); + while (!CustomStatics.empty() && !CustomStatics.back()->IsActual()) + { + delete_data(CustomStatics.back()); + CustomStatics.pop_back(); + } + if (g_b_ClearGameCaptions) + { + delete_data(CustomStatics); + g_b_ClearGameCaptions = false; + } + Window->Update(); + //update windows + if (GameIndicatorsShown() && psHUD_Flags.is(HUD_DRAW | HUD_DRAW_RT)) + UIMainIngameWnd->Update(); + m_pMessagesWnd->Update(); } void CUIGameCustom::Render() { - st_vec_it it = m_custom_statics.begin(); - st_vec_it it_e = m_custom_statics.end(); - for(;it!=it_e;++it) - (*it)->Draw(); - - m_window->Draw(); - - CEntity* pEntity = smart_cast(Level().CurrentEntity()); - if (pEntity) - { - CActor* pActor = smart_cast(pEntity); - if(pActor && pActor->HUDview() && pActor->g_Alive() && psHUD_Flags.is(HUD_WEAPON|HUD_WEAPON_RT|HUD_WEAPON_RT2)) - { - u16 ISlot = pActor->inventory().FirstSlot(); - u16 ESlot = pActor->inventory().LastSlot(); - - for( ; ISlot<=ESlot; ++ISlot) - { - PIItem itm = pActor->inventory().ItemFromSlot(ISlot); - if(itm && itm->render_item_ui_query()) - itm->render_item_ui(); - } - } - - if( GameIndicatorsShown() && psHUD_Flags.is(HUD_DRAW | HUD_DRAW_RT) ) - UIMainIngameWnd->Draw(); - } - - m_pMessagesWnd->Draw(); - - DoRenderDialogs(); -} - -SDrawStaticStruct* CUIGameCustom::AddCustomStatic(LPCSTR id, bool bSingleInstance) -{ - if(bSingleInstance) - { - st_vec::iterator it = std::find_if(m_custom_statics.begin(),m_custom_statics.end(), predicate_find_stat(id) ); - if(it!=m_custom_statics.end()) - return (*it); - } - - CUIXmlInit xml_init; - m_custom_statics.push_back ( xr_new() ); - SDrawStaticStruct* sss = m_custom_statics.back(); - - sss->m_static = xr_new(); - sss->m_name = id; - xml_init.InitStatic (*m_msgs_xml, id, 0, sss->m_static); - float ttl = m_msgs_xml->ReadAttribFlt(id, 0, "ttl", -1); - if(ttl>0.0f) - sss->m_endTime = Device.fTimeGlobal + ttl; - - return sss; -} - -SDrawStaticStruct* CUIGameCustom::GetCustomStatic(LPCSTR id) -{ - st_vec::iterator it = std::find_if(m_custom_statics.begin(),m_custom_statics.end(), predicate_find_stat(id)); - if(it!=m_custom_statics.end()) - return (*it); - - return NULL; -} - -void CUIGameCustom::RemoveCustomStatic(LPCSTR id) -{ - st_vec::iterator it = std::find_if(m_custom_statics.begin(),m_custom_statics.end(), predicate_find_stat(id) ); - if(it!=m_custom_statics.end()) - { - delete_data (*it); - m_custom_statics.erase (it); - } -} - -void CUIGameCustom::OnInventoryAction(PIItem item, u16 action_type) -{ - if ( m_ActorMenu->IsShown() ) - m_ActorMenu->OnInventoryAction( item, action_type ); + for (SDrawStaticStruct* item : CustomStatics) + item->Draw(); + Window->Draw(); + CEntity* pEntity = smart_cast(Level().CurrentEntity()); + if (pEntity) + { + CActor* pActor = smart_cast(pEntity); + if (pActor && pActor->HUDview() && pActor->g_Alive() && + psHUD_Flags.is(HUD_WEAPON | HUD_WEAPON_RT | HUD_WEAPON_RT2)) + { + CInventory& inventory = pActor->inventory(); + u16 lastSlot = inventory.LastSlot(); + for (u16 slot = inventory.FirstSlot(); slot <= lastSlot; slot++) + { + CInventoryItem* item = inventory.ItemFromSlot(slot); + if (item && item->render_item_ui_query()) + item->render_item_ui(); + } + } + if (GameIndicatorsShown() && psHUD_Flags.is(HUD_DRAW | HUD_DRAW_RT)) + UIMainIngameWnd->Draw(); + } + m_pMessagesWnd->Draw(); + DoRenderDialogs(); +} + +SDrawStaticStruct* CUIGameCustom::AddCustomStatic(const char* id, bool singleInstance) +{ + if (singleInstance) + { + auto it = std::find_if(CustomStatics.begin(), CustomStatics.end(), predicate_find_stat(id)); + if (it != CustomStatics.end()) + return *it; + } + CUIXmlInit xmlInit; + CustomStatics.push_back(xr_new()); + SDrawStaticStruct* sss = CustomStatics.back(); + sss->m_static = xr_new(); + sss->m_name = id; + xmlInit.InitStatic(*MsgConfig, id, 0, sss->m_static); + float ttl = MsgConfig->ReadAttribFlt(id, 0, "ttl", -1.0f); + if (ttl > 0.0f) + sss->m_endTime = Device.fTimeGlobal+ttl; + return sss; +} + +SDrawStaticStruct* CUIGameCustom::GetCustomStatic(const char* id) +{ + auto it = std::find_if(CustomStatics.begin(), CustomStatics.end(), predicate_find_stat(id)); + if (it != CustomStatics.end()) + return *it; + return nullptr; +} + +void CUIGameCustom::RemoveCustomStatic(const char* id) +{ + auto it = std::find_if(CustomStatics.begin(), CustomStatics.end(), predicate_find_stat(id)); + if (it != CustomStatics.end()) + { + delete_data(*it); + CustomStatics.erase(it); + } +} + +void CUIGameCustom::OnInventoryAction(PIItem item, u16 actionType) +{ + if (ActorMenu->IsShown()) + ActorMenu->OnInventoryAction(item, actionType); } #include "ui/UIGameTutorial.h" - +// XXX nitrocaster: move to appropriate header extern CUISequencer* g_tutorial; extern CUISequencer* g_tutorial2; bool CUIGameCustom::ShowActorMenu() { - if ( m_ActorMenu->IsShown() ) - { - m_ActorMenu->HideDialog(); - }else - { - HidePdaMenu(); - CInventoryOwner* pIOActor = smart_cast( Level().CurrentViewEntity() ); - VERIFY (pIOActor); - m_ActorMenu->SetActor (pIOActor); - m_ActorMenu->SetMenuMode (mmInventory); - m_ActorMenu->ShowDialog (true); - } - return true; + if (ActorMenu->IsShown()) + { + ActorMenu->HideDialog(); + } + else + { + HidePdaMenu(); + auto actor = smart_cast(Level().CurrentViewEntity()); + VERIFY(actor); + ActorMenu->SetActor(actor); + ActorMenu->SetMenuMode(mmInventory); + ActorMenu->ShowDialog(true); + } + return true; } void CUIGameCustom::HideActorMenu() { - if ( m_ActorMenu->IsShown() ) - { - m_ActorMenu->HideDialog(); - } + if (ActorMenu->IsShown()) + ActorMenu->HideDialog(); } void CUIGameCustom::HideMessagesWindow() { - if ( m_pMessagesWnd->IsShown() ) - m_pMessagesWnd->Show(false); + if (m_pMessagesWnd->IsShown()) + m_pMessagesWnd->Show(false); } void CUIGameCustom::ShowMessagesWindow() { - if ( !m_pMessagesWnd->IsShown() ) - m_pMessagesWnd->Show(true); + if (!m_pMessagesWnd->IsShown()) + m_pMessagesWnd->Show(true); } bool CUIGameCustom::ShowPdaMenu() { - HideActorMenu(); - m_PdaMenu->ShowDialog(true); - return true; + HideActorMenu(); + PdaMenu->ShowDialog(true); + return true; } void CUIGameCustom::HidePdaMenu() { - if ( m_PdaMenu->IsShown() ) - { - m_PdaMenu->HideDialog(); - } + if (PdaMenu->IsShown()) + PdaMenu->HideDialog(); } -void CUIGameCustom::SetClGame(game_cl_GameState* g) +void CUIGameCustom::SetClGame(game_cl_GameState* gameState) { - g->SetGameUI(this); + gameState->SetGameUI(this); } void CUIGameCustom::UnLoad() { - xr_delete (m_msgs_xml); - xr_delete (m_ActorMenu); - xr_delete (m_PdaMenu); - xr_delete (m_window); - xr_delete (UIMainIngameWnd); - xr_delete (m_pMessagesWnd); + xr_delete(MsgConfig); + xr_delete(ActorMenu); + xr_delete(PdaMenu); + xr_delete(Window); + xr_delete(UIMainIngameWnd); + xr_delete(m_pMessagesWnd); } void CUIGameCustom::Load() { - if(g_pGameLevel) - { - R_ASSERT (NULL==m_msgs_xml); - m_msgs_xml = xr_new(); - m_msgs_xml->Load (CONFIG_PATH, UI_PATH, "ui_custom_msgs.xml"); - - R_ASSERT (NULL==m_ActorMenu); - m_ActorMenu = xr_new (); - - R_ASSERT (NULL==m_PdaMenu); - m_PdaMenu = xr_new (); - - R_ASSERT (NULL==m_window); - m_window = xr_new (); - - R_ASSERT (NULL==UIMainIngameWnd); - UIMainIngameWnd = xr_new (); - UIMainIngameWnd->Init (); - - R_ASSERT (NULL==m_pMessagesWnd); - m_pMessagesWnd = xr_new(); - - Init (0); - Init (1); - Init (2); - } + if (!g_pGameLevel) + return; + R_ASSERT(!MsgConfig); + MsgConfig = xr_new(); + MsgConfig->Load(CONFIG_PATH, UI_PATH, "ui_custom_msgs.xml"); + R_ASSERT(!ActorMenu); + ActorMenu = xr_new(); + R_ASSERT(!PdaMenu); + PdaMenu = xr_new(); + R_ASSERT(!Window); + Window = xr_new(); + R_ASSERT(!UIMainIngameWnd); + UIMainIngameWnd = xr_new(); + UIMainIngameWnd->Init(); + R_ASSERT(!m_pMessagesWnd); + m_pMessagesWnd = xr_new(); + Init(0); + Init(1); + Init(2); } void CUIGameCustom::OnConnected() { - if(g_pGameLevel) - { - if(!UIMainIngameWnd) - Load(); - - UIMainIngameWnd->OnConnected(); - } + if (!g_pGameLevel) + return; + if (!UIMainIngameWnd) + Load(); + UIMainIngameWnd->OnConnected(); } void CUIGameCustom::CommonMessageOut(LPCSTR text) { - m_pMessagesWnd->AddLogMessage(text); + m_pMessagesWnd->AddLogMessage(text); } + void CUIGameCustom::UpdatePda() { - PdaMenu().UpdatePda(); + GetPdaMenu().UpdatePda(); } void CUIGameCustom::update_fake_indicators(u8 type, float power) { - UIMainIngameWnd->get_hud_states()->FakeUpdateIndicatorType(type, power); + UIMainIngameWnd->get_hud_states()->FakeUpdateIndicatorType(type, power); } void CUIGameCustom::enable_fake_indicators(bool enable) { - UIMainIngameWnd->get_hud_states()->EnableFakeIndicators(enable); + UIMainIngameWnd->get_hud_states()->EnableFakeIndicators(enable); } -SDrawStaticStruct::SDrawStaticStruct () +SDrawStaticStruct::SDrawStaticStruct() { - m_static = NULL; - m_endTime = -1.0f; + m_static = nullptr; + m_endTime = -1.0f; } void SDrawStaticStruct::destroy() { - delete_data(m_static); + delete_data(m_static); } bool SDrawStaticStruct::IsActual() const { - if(m_endTime<0) return true; - return (Device.fTimeGlobal < m_endTime); + if (m_endTime < 0) + return true; + return Device.fTimeGlobal < m_endTime; } -void SDrawStaticStruct::SetText(LPCSTR text) +void SDrawStaticStruct::SetText(const char* text) { - m_static->Show(text!=NULL); - if(text) - { - m_static->TextItemControl()->SetTextST(text); - m_static->ResetColorAnimation(); - } + m_static->Show(text != nullptr); + if (text) + { + m_static->TextItemControl()->SetTextST(text); + m_static->ResetColorAnimation(); + } } void SDrawStaticStruct::Draw() { - if(m_static->IsShown()) - m_static->Draw(); + if (m_static->IsShown()) + m_static->Draw(); } void SDrawStaticStruct::Update() { - if(IsActual() && m_static->IsShown()) - m_static->Update(); -} - -CMapListHelper gMapListHelper; -xr_token game_types[]; - -void CMapListHelper::LoadMapInfo(LPCSTR map_cfg_fn, const xr_string& map_name, LPCSTR map_ver) -{ - CInifile ini (map_cfg_fn); - - shared_str _map_name = map_name.substr(0,map_name.find('\\')).c_str(); - shared_str _map_ver = map_ver; - - if(ini.section_exist("map_usage")) - { - if(ini.line_exist("map_usage","ver") && !map_ver) - _map_ver = ini.r_string("map_usage", "ver"); - - CInifile::Sect S = ini.r_section("map_usage"); - CInifile::SectCIt si = S.Data.begin(); - CInifile::SectCIt si_e = S.Data.end(); - for( ;si!=si_e; ++si) - { - const shared_str& game_type = (*si).first; - - if(game_type=="ver") continue; - - SGameTypeMaps* M = GetMapListInt(game_type); - if(!M) - { - Msg ("--unknown game type-%s",game_type.c_str()); - m_storage.resize (m_storage.size()+1); - SGameTypeMaps& Itm = m_storage.back(); - Itm.m_game_type_name = game_type; - Itm.m_game_type_id = ParseStringToGameType(game_type.c_str()); - M = &m_storage.back(); - } - - SGameTypeMaps::SMapItm Itm; - Itm.map_name = _map_name; - Itm.map_ver = _map_ver; - - if(M->m_map_names.end()!=std::find(M->m_map_names.begin(),M->m_map_names.end(),Itm)) - { - Msg("! duplicate map found [%s] [%s]", _map_name.c_str(), _map_ver.c_str()); - }else - { + if (IsActual() && m_static->IsShown()) + m_static->Update(); +} + +CMapListHelper gMapListHelper; + +void CMapListHelper::LoadMapInfo(const char* cfgName, const xr_string& levelName, const char* levelVer /*= "1.0"*/) +{ + CInifile levelCfg(cfgName); + shared_str shLevelName = levelName.substr(0, levelName.find('\\')).c_str(); + shared_str shLevelVer = levelVer; + if (levelCfg.section_exist("map_usage")) + { + if (levelCfg.line_exist("map_usage", "ver") && !levelVer) + shLevelVer = levelCfg.r_string("map_usage", "ver"); + for (CInifile::Item& kv : levelCfg.r_section("map_usage").Data) + { + const shared_str& gameType = kv.first; + if (gameType == "ver") + continue; + SGameTypeMaps* suitableLevels = GetMapListInt(gameType); + if (!suitableLevels) + { + Msg("--unknown game type-%s", gameType.c_str()); + m_storage.resize(m_storage.size()+1); + SGameTypeMaps& lastItem = m_storage.back(); + lastItem.m_game_type_name = gameType; + lastItem.m_game_type_id = ParseStringToGameType(gameType.c_str()); + suitableLevels = &m_storage.back(); + } + SGameTypeMaps::SMapItm levelDesc; + levelDesc.map_name = shLevelName; + levelDesc.map_ver = shLevelVer; + auto& levelNames = suitableLevels->m_map_names; + if (std::find(levelNames.begin(), levelNames.end(), levelDesc) != levelNames.end()) + { + Msg("! duplicate map found [%s] [%s]", shLevelName.c_str(), shLevelVer.c_str()); + } + else + { #ifndef MASTER_GOLD - Msg("added map [%s] [%s]", _map_name.c_str(), _map_ver.c_str()); -#endif // #ifndef MASTER_GOLD - M->m_map_names.push_back (Itm); - } - } - } - + Msg("added map [%s] [%s]", shLevelName.c_str(), shLevelVer.c_str()); +#endif + levelNames.push_back(levelDesc); + } + } + } } void CMapListHelper::Load() { - string_path fn; - FS.update_path (fn, "$game_config$", "mp\\map_list.ltx"); - CInifile map_list_cfg (fn); - - //read weathers set - CInifile::Sect w = map_list_cfg.r_section("weather"); - CInifile::SectCIt wi = w.Data.begin(); - CInifile::SectCIt wi_e = w.Data.end(); - for( ;wi!=wi_e; ++wi) - { - m_weathers.resize (m_weathers.size()+1); - SGameWeathers& gw = m_weathers.back(); - gw.m_weather_name = (*wi).first; - gw.m_start_time = (*wi).second; - } - - // scan for additional maps - FS_FileSet fset; - FS.file_list (fset,"$game_levels$",FS_ListFiles,"*level.ltx"); - - FS_FileSetIt fit = fset.begin(); - FS_FileSetIt fit_e = fset.end(); - - for( ;fit!=fit_e; ++fit) - { - string_path map_cfg_fn; - FS.update_path (map_cfg_fn, "$game_levels$", (*fit).name.c_str()); - LoadMapInfo (map_cfg_fn, (*fit).name); - } - //scan all not laoded archieves - LPCSTR tmp_entrypoint = "temporary_gamedata\\"; - FS_Path* game_levels = FS.get_path("$game_levels$"); - xr_string prev_root = game_levels->m_Root; - game_levels->_set_root (tmp_entrypoint); - - CLocatorAPI::archives_it it = FS.m_archives.begin(); - CLocatorAPI::archives_it it_e = FS.m_archives.end(); - - for(;it!=it_e;++it) - { - CLocatorAPI::archive& A = *it; - if(A.hSrcFile) continue; - - LPCSTR ln = A.header->r_string("header", "level_name"); - LPCSTR lv = A.header->r_string("header", "level_ver"); - FS.LoadArchive (A, tmp_entrypoint); - - string_path map_cfg_fn; - FS.update_path (map_cfg_fn, "$game_levels$", ln); - - - xr_strcat (map_cfg_fn,"\\level.ltx"); - LoadMapInfo (map_cfg_fn, ln, lv); - FS.unload_archive (A); - } - game_levels->_set_root (prev_root.c_str()); - - - R_ASSERT2 (m_storage.size(), "unable to fill map list"); - R_ASSERT2 (m_weathers.size(), "unable to fill weathers list"); -} - - -const SGameTypeMaps& CMapListHelper::GetMapListFor(const shared_str& game_type) -{ - if( !m_storage.size() ) - Load (); - - return *GetMapListInt(game_type); -} - -SGameTypeMaps* CMapListHelper::GetMapListInt(const shared_str& game_type) -{ - - TSTORAGE_CIT it = m_storage.begin(); - TSTORAGE_CIT it_e = m_storage.end(); - for( ;it!=it_e; ++it) - { - if(game_type==(*it).m_game_type_name ) - return &(*it); - } - return NULL; -} - -const SGameTypeMaps& CMapListHelper::GetMapListFor(const EGameIDs game_id) -{ - if( !m_storage.size() ) - { - Load (); - R_ASSERT2 (m_storage.size(), "unable to fill map list"); - } - TSTORAGE_CIT it = m_storage.begin(); - TSTORAGE_CIT it_e = m_storage.end(); - for( ;it!=it_e; ++it) - { - if(game_id==(*it).m_game_type_id ) - return (*it); - } + string_path cfgFileName; + FS.update_path(cfgFileName, "$game_config$", "mp\\map_list.ltx"); + CInifile maplistCfg(cfgFileName); + //read weathers set + CInifile::Sect weatherCfg = maplistCfg.r_section("weather"); + m_weathers.reserve(weatherCfg.Data.size()); + for (CInifile::Item& weatherDesc : weatherCfg.Data) + { + SGameWeathers gw; + gw.Name = weatherDesc.first; + gw.StartTime = weatherDesc.second; + m_weathers.push_back(gw); + } + // scan for additional maps + FS_FileSet levelCfgs; + FS.file_list(levelCfgs, "$game_levels$", FS_ListFiles, "*level.ltx"); + for (const FS_File& cfg : levelCfgs) + { + FS.update_path(cfgFileName, "$game_levels$", cfg.name.c_str()); + LoadMapInfo(cfgFileName, cfg.name); + } + //scan all not loaded archieves + LPCSTR tempRoot = "temporary_gamedata\\"; + FS_Path* levelsPath = FS.get_path("$game_levels$"); + xr_string prevRoot = levelsPath->m_Root; + levelsPath->_set_root(tempRoot); + for (CLocatorAPI::archive& arch : FS.m_archives) + { + if (arch.hSrcFile) + continue; // skip if loaded + const char* levelName = arch.header->r_string("header", "level_name"); + const char* levelVersion = arch.header->r_string("header", "level_ver"); + FS.LoadArchive(arch, tempRoot); + FS.update_path(cfgFileName, "$game_levels$", levelName); + xr_strcat(cfgFileName, "\\level.ltx"); + LoadMapInfo(cfgFileName, levelName, levelVersion); + FS.unload_archive(arch); + } + levelsPath->_set_root(prevRoot.c_str()); + // XXX nitrocaster: is that really fatal? + R_ASSERT2(m_storage.size() > 0, "unable to fill map list"); + R_ASSERT2(m_weathers.size() > 0, "unable to fill weathers list"); +} + +const SGameTypeMaps& CMapListHelper::GetMapListFor(const shared_str& gameType) +{ + if (m_storage.size() == 0) + Load(); + // XXX nitrocaster: always use enum for game type representation + return *GetMapListInt(gameType); +} + +SGameTypeMaps* CMapListHelper::GetMapListInt(const shared_str& gameType) +{ + for (SGameTypeMaps& maps : m_storage) + { + if (maps.m_game_type_name == gameType) + return &maps; + } + return nullptr; +} + +const SGameTypeMaps& CMapListHelper::GetMapListFor(const EGameIDs gameId) +{ + if (m_storage.size() == 0) + { + Load(); + // XXX nitrocaster: is that really fatal? + R_ASSERT2(m_storage.size() > 0, "unable to fill map list"); + } + for (SGameTypeMaps& maps : m_storage) + { + if (maps.m_game_type_id == gameId) + return maps; + } return m_storage[0]; } -const GAME_WEATHERS& CMapListHelper::GetGameWeathers() +const xr_vector& CMapListHelper::GetGameWeathers() { - if(!m_weathers.size()) - Load(); - - return m_weathers; + if (m_weathers.size() == 0) + Load(); + return m_weathers; } - diff --git a/src/xrGame/UIGameCustom.h b/src/xrGame/UIGameCustom.h index ea3b6e95791..37841478f7c 100644 --- a/src/xrGame/UIGameCustom.h +++ b/src/xrGame/UIGameCustom.h @@ -5,7 +5,7 @@ #include "inventory_space.h" #include "gametype_chooser.h" #include "UIDialogHolder.h" -#include "../xrEngine/CustomHUD.h" +#include "xrEngine/CustomHUD.h" // refs class CUI; class CTeamBaseZone; @@ -21,127 +21,110 @@ struct KillMessageStruct; class CUIMainIngameWnd; class CUIMessagesWindow; - -struct SDrawStaticStruct :public IPureDestroyableObject +struct SDrawStaticStruct : public IPureDestroyableObject { - SDrawStaticStruct (); - virtual void destroy (); - CUIStatic* m_static; - float m_endTime; - shared_str m_name; - void Draw(); - void Update(); - CUIStatic* wnd() {return m_static;} - bool IsActual() const; - void SetText (LPCSTR); + SDrawStaticStruct(); + virtual void destroy(); + CUIStatic* m_static; + float m_endTime; + shared_str m_name; + void Draw(); + void Update(); + CUIStatic* wnd() { return m_static; } + bool IsActual() const; + void SetText(const char* text); }; - struct SGameTypeMaps { - shared_str m_game_type_name; - EGameIDs m_game_type_id; - struct SMapItm{ - shared_str map_name; - shared_str map_ver; - bool operator ==(const SMapItm& other){return map_name==other.map_name && map_ver==other.map_ver;} - }; - xr_vector m_map_names; + struct SMapItm + { + shared_str map_name; + shared_str map_ver; + bool operator == (const SMapItm& rhs) { return map_name == rhs.map_name && map_ver == rhs.map_ver; } + }; + + shared_str m_game_type_name; + EGameIDs m_game_type_id; + xr_vector m_map_names; }; struct SGameWeathers { - shared_str m_weather_name; - shared_str m_start_time; + shared_str Name; + shared_str StartTime; }; -typedef xr_vector GAME_WEATHERS; -typedef xr_vector::iterator GAME_WEATHERS_IT; -typedef xr_vector::const_iterator GAME_WEATHERS_CIT; class CMapListHelper { - typedef xr_vector TSTORAGE; - typedef TSTORAGE::iterator TSTORAGE_IT; - typedef TSTORAGE::iterator TSTORAGE_CIT; - TSTORAGE m_storage; - GAME_WEATHERS m_weathers; - void Load (); - void LoadMapInfo (LPCSTR file_name, const xr_string& map_name, LPCSTR map_ver="1.0"); - SGameTypeMaps* GetMapListInt (const shared_str& game_type); +private: + xr_vector m_storage; + xr_vector m_weathers; + public: - const SGameTypeMaps& GetMapListFor (const shared_str& game_type); - const SGameTypeMaps& GetMapListFor (const EGameIDs game_id); - const GAME_WEATHERS& GetGameWeathers (); + const SGameTypeMaps& GetMapListFor(const shared_str& gameType); + const SGameTypeMaps& GetMapListFor(const EGameIDs gameId); + const xr_vector& GetGameWeathers(); + +private: + void Load(); + void LoadMapInfo(const char* cfgName, const xr_string& levelName, const char* levelVer = "1.0"); + SGameTypeMaps* GetMapListInt(const shared_str& gameType); }; -extern CMapListHelper gMapListHelper; +extern CMapListHelper gMapListHelper; -class CUIGameCustom :public DLL_Pure, public CDialogHolder +class CUIGameCustom : + public DLL_Pure, + public CDialogHolder { protected: - CUIWindow* m_window; - CUIXml* m_msgs_xml; - typedef xr_vector st_vec; - typedef st_vec::iterator st_vec_it; - st_vec m_custom_statics; - - CUIActorMenu* m_ActorMenu; - CUIPdaWnd* m_PdaMenu; - - bool m_bShowGameIndicators; + CUIWindow* Window; + CUIXml* MsgConfig; + xr_vector CustomStatics; + CUIActorMenu* ActorMenu; + CUIPdaWnd* PdaMenu; + bool showGameIndicators; public: - CUIMainIngameWnd* UIMainIngameWnd; - CUIMessagesWindow* m_pMessagesWnd; - - virtual void SetClGame (game_cl_GameState* g); - virtual void OnInventoryAction (PIItem item, u16 action_type); - - - CUIGameCustom (); - virtual ~CUIGameCustom (); - - virtual void Init (int stage) {}; - - virtual void Render (); - virtual void _BCL OnFrame (); - - IC CUIActorMenu& ActorMenu () const { return *m_ActorMenu; } - IC CUIPdaWnd& PdaMenu () const { return *m_PdaMenu; } - bool ShowActorMenu (); - void HideActorMenu (); - bool ShowPdaMenu (); - void HidePdaMenu (); - void ShowMessagesWindow (); - void HideMessagesWindow (); - - void ShowGameIndicators (bool b) {m_bShowGameIndicators = b;}; - bool GameIndicatorsShown () {return m_bShowGameIndicators;}; - void ShowCrosshair (bool b) {psHUD_Flags.set (HUD_CROSSHAIR_RT, b);} - bool CrosshairShown () {return !!psHUD_Flags.test (HUD_CROSSHAIR_RT);} - - - virtual void HideShownDialogs (){}; - - SDrawStaticStruct* AddCustomStatic (LPCSTR id, bool bSingleInstance); - SDrawStaticStruct* GetCustomStatic (LPCSTR id); - void RemoveCustomStatic (LPCSTR id); - - void CommonMessageOut (LPCSTR text); - - virtual void ChangeTotalMoneyIndicator(LPCSTR newMoneyString) {}; - virtual void DisplayMoneyChange (LPCSTR deltaMoney) {}; - virtual void DisplayMoneyBonus (KillMessageStruct* bonus) {}; - - virtual void UnLoad (); - void Load (); - - void OnConnected (); - - void UpdatePda (); - void update_fake_indicators (u8 type, float power); - void enable_fake_indicators (bool enable); + // XXX nitrocaster: make not public + CUIMainIngameWnd* UIMainIngameWnd; + CUIMessagesWindow* m_pMessagesWnd; + + CUIGameCustom(); + virtual ~CUIGameCustom(); + virtual void SetClGame(game_cl_GameState* gameState); + virtual void OnInventoryAction(PIItem item, u16 actionType); + virtual void Init(int stage) {} + virtual void Render(); + virtual void _BCL OnFrame() override; + IC CUIActorMenu& GetActorMenu() const { return *ActorMenu; } + IC CUIPdaWnd& GetPdaMenu() const { return *PdaMenu; } + bool ShowActorMenu(); + void HideActorMenu(); + bool ShowPdaMenu(); + void HidePdaMenu(); + void ShowMessagesWindow(); + void HideMessagesWindow(); + void ShowGameIndicators(bool show) { showGameIndicators = show; } + bool GameIndicatorsShown() { return showGameIndicators; } + 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); + void RemoveCustomStatic(const char* id); + void CommonMessageOut(const char* text); + virtual void ChangeTotalMoneyIndicator(const char* newMoneyString) {} + virtual void DisplayMoneyChange(const char* deltaMoney) {} + virtual void DisplayMoneyBonus(KillMessageStruct* bonus) {} + virtual void UnLoad(); + void Load(); + void OnConnected(); + void UpdatePda(); + void update_fake_indicators(u8 type, float power); + void enable_fake_indicators(bool enable); + DECLARE_SCRIPT_REGISTER_FUNCTION +}; - DECLARE_SCRIPT_REGISTER_FUNCTION -}; // class CUIGameCustom -extern CUIGameCustom* CurrentGameUI(); \ No newline at end of file +extern CUIGameCustom* CurrentGameUI(); diff --git a/src/xrGame/UIGameDM.cpp b/src/xrGame/UIGameDM.cpp index 5e7af645ef4..fc042aca54d 100644 --- a/src/xrGame/UIGameDM.cpp +++ b/src/xrGame/UIGameDM.cpp @@ -72,22 +72,22 @@ void CUIGameDM::Init(int stage) m_pFragLimitIndicator->SetAutoDelete(true); inherited::Init (stage); - m_time_caption = UIHelper::CreateTextWnd(*m_msgs_xml, "mp_timelimit", m_window); - m_spectrmode_caption = UIHelper::CreateTextWnd(*m_msgs_xml, "mp_spetatormode", m_window); - m_spectator_caption = UIHelper::CreateTextWnd(*m_msgs_xml, "mp_spectator", m_window); - m_pressjump_caption = UIHelper::CreateTextWnd(*m_msgs_xml, "mp_pressjump", m_window); - m_pressbuy_caption = UIHelper::CreateTextWnd(*m_msgs_xml, "mp_pressbuy", m_window); - m_round_result_caption = UIHelper::CreateTextWnd(*m_msgs_xml, "mp_round_result", m_window); - m_force_respawn_time_caption = UIHelper::CreateTextWnd(*m_msgs_xml, "mp_force_respawn_time", m_window); - m_demo_play_caption = UIHelper::CreateTextWnd(*m_msgs_xml, "mp_demo_play", m_window); - m_warm_up_caption = UIHelper::CreateTextWnd(*m_msgs_xml, "mp_warm_up", m_window); + m_time_caption = UIHelper::CreateTextWnd(*MsgConfig, "mp_timelimit", Window); + m_spectrmode_caption = UIHelper::CreateTextWnd(*MsgConfig, "mp_spetatormode", Window); + m_spectator_caption = UIHelper::CreateTextWnd(*MsgConfig, "mp_spectator", Window); + m_pressjump_caption = UIHelper::CreateTextWnd(*MsgConfig, "mp_pressjump", Window); + m_pressbuy_caption = UIHelper::CreateTextWnd(*MsgConfig, "mp_pressbuy", Window); + m_round_result_caption = UIHelper::CreateTextWnd(*MsgConfig, "mp_round_result", Window); + m_force_respawn_time_caption = UIHelper::CreateTextWnd(*MsgConfig, "mp_force_respawn_time", Window); + m_demo_play_caption = UIHelper::CreateTextWnd(*MsgConfig, "mp_demo_play", Window); + m_warm_up_caption = UIHelper::CreateTextWnd(*MsgConfig, "mp_warm_up", Window); } if(stage==1) { //unique m_pTeamPanels->Init (TEAM_PANELS_DM_XML_NAME, "team_panels_wnd"); CUIXml uiXml; uiXml.Load (CONFIG_PATH, UI_PATH, "ui_game_dm.xml"); - CUIXmlInit::InitWindow (uiXml,"global", 0, m_window); + CUIXmlInit::InitWindow (uiXml,"global", 0, Window); m_pMoneyIndicator->InitFromXML (uiXml); m_pRankIndicator->InitFromXml (uiXml); CUIXmlInit::InitTextWnd (uiXml,"fraglimit",0, m_pFragLimitIndicator); @@ -95,9 +95,9 @@ void CUIGameDM::Init(int stage) if(stage==2) { //after inherited::Init (stage); - m_window->AttachChild (m_pMoneyIndicator); - m_window->AttachChild (m_pRankIndicator); - m_window->AttachChild (m_pFragLimitIndicator); + Window->AttachChild (m_pMoneyIndicator); + Window->AttachChild (m_pRankIndicator); + Window->AttachChild (m_pFragLimitIndicator); } }; diff --git a/src/xrGame/UIGameMP.cpp b/src/xrGame/UIGameMP.cpp index 79017870b2b..4edc0494bc9 100644 --- a/src/xrGame/UIGameMP.cpp +++ b/src/xrGame/UIGameMP.cpp @@ -125,7 +125,7 @@ void UIGameMP::SetClGame(game_cl_GameState* g) m_pServerInfo = xr_new(); m_pAchivementIdicator = xr_new(); m_pAchivementIdicator->SetAutoDelete(true); - m_window->AttachChild (m_pAchivementIdicator); + Window->AttachChild (m_pAchivementIdicator); } diff --git a/src/xrGame/UIGameSP.cpp b/src/xrGame/UIGameSP.cpp index 134ecd8b8c9..89d17fe0146 100644 --- a/src/xrGame/UIGameSP.cpp +++ b/src/xrGame/UIGameSP.cpp @@ -155,22 +155,22 @@ void CUIGameSP::StartTrade(CInventoryOwner* pActorInv, CInventoryOwner* pOtherO { //. if( MainInputReceiver() ) return; - m_ActorMenu->SetActor (pActorInv); - m_ActorMenu->SetPartner (pOtherOwner); + ActorMenu->SetActor (pActorInv); + ActorMenu->SetPartner (pOtherOwner); - m_ActorMenu->SetMenuMode (mmTrade); - m_ActorMenu->ShowDialog (true); + ActorMenu->SetMenuMode (mmTrade); + ActorMenu->ShowDialog (true); } void CUIGameSP::StartUpgrade(CInventoryOwner* pActorInv, CInventoryOwner* pMech) { //. if( MainInputReceiver() ) return; - m_ActorMenu->SetActor (pActorInv); - m_ActorMenu->SetPartner (pMech); + ActorMenu->SetActor (pActorInv); + ActorMenu->SetPartner (pMech); - m_ActorMenu->SetMenuMode (mmUpgrade); - m_ActorMenu->ShowDialog (true); + ActorMenu->SetMenuMode (mmUpgrade); + ActorMenu->ShowDialog (true); } void CUIGameSP::StartTalk(bool disable_break) @@ -187,23 +187,23 @@ void CUIGameSP::StartCarBody(CInventoryOwner* pActorInv, CInventoryOwner* pOther { if( TopInputReceiver() ) return; - m_ActorMenu->SetActor (pActorInv); - m_ActorMenu->SetPartner (pOtherOwner); + ActorMenu->SetActor (pActorInv); + ActorMenu->SetPartner (pOtherOwner); - m_ActorMenu->SetMenuMode (mmDeadBodySearch); - m_ActorMenu->ShowDialog (true); + ActorMenu->SetMenuMode (mmDeadBodySearch); + ActorMenu->ShowDialog (true); } void CUIGameSP::StartCarBody(CInventoryOwner* pActorInv, CInventoryBox* pBox) //Deadbody search { if( TopInputReceiver() ) return; - m_ActorMenu->SetActor (pActorInv); - m_ActorMenu->SetInvBox (pBox); + ActorMenu->SetActor (pActorInv); + ActorMenu->SetInvBox (pBox); VERIFY( pBox ); - m_ActorMenu->SetMenuMode (mmDeadBodySearch); - m_ActorMenu->ShowDialog (true); + ActorMenu->SetMenuMode (mmDeadBodySearch); + ActorMenu->ShowDialog (true); } diff --git a/src/xrGame/UIGameTDM.cpp b/src/xrGame/UIGameTDM.cpp index 9a365167327..4fc48d2e360 100644 --- a/src/xrGame/UIGameTDM.cpp +++ b/src/xrGame/UIGameTDM.cpp @@ -45,7 +45,7 @@ void CUIGameTDM::Init (int stage) m_buy_msg_caption->SetAutoDelete(true); inherited::Init (stage); - CUIXmlInit::InitTextWnd (*m_msgs_xml, "mp_tdm_buy",0, m_buy_msg_caption); + CUIXmlInit::InitTextWnd (*MsgConfig, "mp_tdm_buy",0, m_buy_msg_caption); } if(stage==1) { //unique @@ -54,7 +54,7 @@ void CUIGameTDM::Init (int stage) CUIXml uiXml, xml2; uiXml.Load (CONFIG_PATH, UI_PATH, "ui_game_tdm.xml"); - CUIXmlInit::InitWindow (uiXml, "global", 0, m_window); + CUIXmlInit::InitWindow (uiXml, "global", 0, Window); CUIXmlInit::InitStatic (uiXml, "team1_icon", 0, m_team1_icon); CUIXmlInit::InitStatic (uiXml, "team2_icon", 0, m_team2_icon); CUIXmlInit::InitTextWnd (uiXml, "team1_score", 0, m_team1_score); @@ -67,9 +67,9 @@ void CUIGameTDM::Init (int stage) if(stage==2) { //after inherited::Init(stage); - m_window->AttachChild (m_team1_score); - m_window->AttachChild (m_team2_score); - m_window->AttachChild (m_buy_msg_caption); + Window->AttachChild (m_team1_score); + Window->AttachChild (m_team2_score); + Window->AttachChild (m_buy_msg_caption); } } diff --git a/src/xrGame/console_commands.cpp b/src/xrGame/console_commands.cpp index c79bf4bde5e..9f497d7fb1a 100644 --- a/src/xrGame/console_commands.cpp +++ b/src/xrGame/console_commands.cpp @@ -1649,7 +1649,7 @@ class CCC_InvUpgradesCurItem : public IConsole_Command { return; } - PIItem item = ui_game_sp->ActorMenu().get_upgrade_item(); + PIItem item = ui_game_sp->GetActorMenu().get_upgrade_item(); if ( item ) { item->log_upgrades(); @@ -1678,7 +1678,7 @@ class CCC_InvDropAllItems : public IConsole_Command } int d = 0; sscanf( args, "%d", &d ); - if ( ui_game_sp->ActorMenu().DropAllItemsFromRuck( d == 1 ) ) + if ( ui_game_sp->GetActorMenu().DropAllItemsFromRuck( d == 1 ) ) { Msg( "- All items from ruck of Actor is dropping now." ); } diff --git a/src/xrGame/game_cl_artefacthunt.cpp b/src/xrGame/game_cl_artefacthunt.cpp index dff8c7f352f..002eea9b034 100644 --- a/src/xrGame/game_cl_artefacthunt.cpp +++ b/src/xrGame/game_cl_artefacthunt.cpp @@ -520,7 +520,7 @@ BOOL game_cl_ArtefactHunt::CanCallBuyMenu () { return FALSE; }; - if ( m_game_ui && m_game_ui->ActorMenu().IsShown() ) + if ( m_game_ui && m_game_ui->GetActorMenu().IsShown() ) { return FALSE; } diff --git a/src/xrGame/game_cl_capture_the_artefact.cpp b/src/xrGame/game_cl_capture_the_artefact.cpp index c325cdda8a9..f49d78995bd 100644 --- a/src/xrGame/game_cl_capture_the_artefact.cpp +++ b/src/xrGame/game_cl_capture_the_artefact.cpp @@ -984,7 +984,7 @@ bool game_cl_CaptureTheArtefact::OnKeyboardPress(int key) }break; case kINVENTORY: { - if ( m_game_ui->ActorMenu().IsShown() ) + if ( m_game_ui->GetActorMenu().IsShown() ) { m_game_ui->HideActorMenu(); } diff --git a/src/xrGame/game_cl_deathmatch.cpp b/src/xrGame/game_cl_deathmatch.cpp index a047393beda..a2302cbb00b 100644 --- a/src/xrGame/game_cl_deathmatch.cpp +++ b/src/xrGame/game_cl_deathmatch.cpp @@ -251,7 +251,7 @@ BOOL game_cl_Deathmatch::CanCallBuyMenu () { return FALSE; }; - if ( m_game_ui && m_game_ui->ActorMenu().IsShown() ) + if ( m_game_ui && m_game_ui->GetActorMenu().IsShown() ) { return FALSE; } @@ -265,7 +265,7 @@ BOOL game_cl_Deathmatch::CanCallBuyMenu () BOOL game_cl_Deathmatch::CanCallSkinMenu () { if (Phase()!=GAME_PHASE_INPROGRESS) return false; - if ( m_game_ui && m_game_ui->ActorMenu().IsShown() ) + if ( m_game_ui && m_game_ui->GetActorMenu().IsShown() ) { return FALSE; } @@ -659,7 +659,7 @@ void game_cl_Deathmatch::shedule_Update (u32 dt) //----------------------------------------------- //if (m_game_ui->m_pInventoryMenu && m_game_ui->m_pInventoryMenu->IsShown() && !CanCallInventoryMenu()) // StartStopMenu(m_game_ui->m_pInventoryMenu,true); - if ( m_game_ui && m_game_ui->ActorMenu().IsShown() && !CanCallInventoryMenu() ) + if ( m_game_ui && m_game_ui->GetActorMenu().IsShown() && !CanCallInventoryMenu() ) { m_game_ui->HideActorMenu(); } @@ -711,7 +711,7 @@ bool game_cl_Deathmatch::OnKeyboardPress (int key) { if (m_game_ui) { - if ( m_game_ui->ActorMenu().IsShown() ) + if ( m_game_ui->GetActorMenu().IsShown() ) { m_game_ui->HideActorMenu(); } @@ -1109,7 +1109,7 @@ void game_cl_Deathmatch::OnGameRoundStarted () } if (pCurBuyMenu) pCurBuyMenu->ClearPreset(_preset_idx_last); //----------------------------------------------------------------- - if ( m_game_ui && m_game_ui->ActorMenu().IsShown() ) + if ( m_game_ui && m_game_ui->GetActorMenu().IsShown() ) { m_game_ui->HideActorMenu(); } @@ -1187,7 +1187,7 @@ void game_cl_Deathmatch::OnPlayerFlagsChanged(game_PlayerState* ps) if (ps->testFlag(GAME_PLAYER_FLAG_VERY_VERY_DEAD)) { - if ( ps == local_player && m_game_ui && m_game_ui->ActorMenu().IsShown() ) + if ( ps == local_player && m_game_ui && m_game_ui->GetActorMenu().IsShown() ) { m_game_ui->HideActorMenu(); } diff --git a/src/xrGame/game_cl_teamdeathmatch.cpp b/src/xrGame/game_cl_teamdeathmatch.cpp index e488b86ce59..66f557c5d5c 100644 --- a/src/xrGame/game_cl_teamdeathmatch.cpp +++ b/src/xrGame/game_cl_teamdeathmatch.cpp @@ -594,7 +594,7 @@ BOOL game_cl_TeamDeathmatch::CanCallBuyMenu () if (pCurSkinMenu && pCurSkinMenu->IsShown()) return FALSE; - if ( m_game_ui && m_game_ui->ActorMenu().IsShown() ) + if ( m_game_ui && m_game_ui->GetActorMenu().IsShown() ) return FALSE; return m_bBuyEnabled; @@ -623,7 +623,7 @@ BOOL game_cl_TeamDeathmatch::CanCallTeamSelectMenu () { if (Phase()!=GAME_PHASE_INPROGRESS) return false; if (!local_player) return false; - if ( m_game_ui && m_game_ui->ActorMenu().IsShown() ) + if ( m_game_ui && m_game_ui->GetActorMenu().IsShown() ) { return FALSE; } diff --git a/src/xrGame/ui/ChangeWeatherDialog.cpp b/src/xrGame/ui/ChangeWeatherDialog.cpp index f107922d766..eb628982878 100644 --- a/src/xrGame/ui/ChangeWeatherDialog.cpp +++ b/src/xrGame/ui/ChangeWeatherDialog.cpp @@ -98,12 +98,12 @@ void ChangeWeatherDialog::InitChangeWeather(CUIXml& xmlDoc) string256 path; for (u32 i = 0; i < weathers.size(); i++) { - xr_sprintf(path, "change_weather:btn_%s", gameWeathers[i].m_weather_name.c_str()); + xr_sprintf(path, "change_weather:btn_%s", gameWeathers[i].Name.c_str()); CUIXmlInit::Init3tButton(xmlDoc, path, 0, GetButton(i).Button); - xr_sprintf(path, "change_weather:txt_%s", gameWeathers[i].m_weather_name.c_str()); + xr_sprintf(path, "change_weather:txt_%s", gameWeathers[i].Name.c_str()); CUIXmlInit::InitTextWnd(xmlDoc, path, 0, GetButton(i).Text); - weathers[i].Name = gameWeathers[i].m_weather_name; - weathers[i].Time = gameWeathers[i].m_start_time; + weathers[i].Name = gameWeathers[i].Name; + weathers[i].Time = gameWeathers[i].StartTime; } } diff --git a/src/xrGame/ui/UIGameTutorial.cpp b/src/xrGame/ui/UIGameTutorial.cpp index 1415fd57824..26078aa4d94 100644 --- a/src/xrGame/ui/UIGameTutorial.cpp +++ b/src/xrGame/ui/UIGameTutorial.cpp @@ -404,12 +404,12 @@ void CUISequencer::IR_OnKeyboardPress (int dik) if(binded && CurrentGameUI()) { - if(CurrentGameUI()->ActorMenu().IsShown()) + if(CurrentGameUI()->GetActorMenu().IsShown()) { CurrentGameUI()->HideActorMenu(); return; } - if(CurrentGameUI()->PdaMenu().IsShown()) + if(CurrentGameUI()->GetPdaMenu().IsShown()) { CurrentGameUI()->HidePdaMenu(); return; diff --git a/src/xrGame/ui/UIGameTutorialSimpleItem.cpp b/src/xrGame/ui/UIGameTutorialSimpleItem.cpp index c65acdacc28..3d1c892ca9a 100644 --- a/src/xrGame/ui/UIGameTutorialSimpleItem.cpp +++ b/src/xrGame/ui/UIGameTutorialSimpleItem.cpp @@ -203,8 +203,8 @@ void CUISequenceSimpleItem::Update() if(ui_game_sp) { - if ( ui_game_sp->PdaMenu().IsShown() || - ui_game_sp->ActorMenu().IsShown() || + if ( ui_game_sp->GetPdaMenu().IsShown() || + ui_game_sp->GetActorMenu().IsShown() || ui_game_sp->TalkMenu->IsShown() || ui_game_sp->UIChangeLevelWnd->IsShown() || (MainMenu()->IsActive() && !m_owner->m_flags.test(CUISequencer::etsOverMainMenu) ) @@ -248,20 +248,20 @@ void CUISequenceSimpleItem::Start() bool bShowPda = false; CUIGameSP* ui_game_sp = smart_cast(CurrentGameUI()); - if ( !stricmp( m_pda_section, "pda_tasks" ) ) {ui_game_sp->PdaMenu().SetActiveSubdialog("eptTasks"); bShowPda = true; } - else if( !stricmp( m_pda_section, "pda_ranking" ) ) {ui_game_sp->PdaMenu().SetActiveSubdialog("eptRanking"); bShowPda = true; } - else if( !stricmp( m_pda_section, "pda_logs" ) ) {ui_game_sp->PdaMenu().SetActiveSubdialog("eptLogs"); bShowPda = true; } + if ( !stricmp( m_pda_section, "pda_tasks" ) ) {ui_game_sp->GetPdaMenu().SetActiveSubdialog("eptTasks"); bShowPda = true; } + else if( !stricmp( m_pda_section, "pda_ranking" ) ) {ui_game_sp->GetPdaMenu().SetActiveSubdialog("eptRanking"); bShowPda = true; } + else if( !stricmp( m_pda_section, "pda_logs" ) ) {ui_game_sp->GetPdaMenu().SetActiveSubdialog("eptLogs"); bShowPda = true; } else if( !stricmp( m_pda_section, "pda_show_second_task_wnd" ) ) { - ui_game_sp->PdaMenu().Show_SecondTaskWnd(true); bShowPda = true; + ui_game_sp->GetPdaMenu().Show_SecondTaskWnd(true); bShowPda = true; } if ( ui_game_sp ) { - if ( ( !ui_game_sp->PdaMenu().IsShown() && bShowPda ) || - ( ui_game_sp->PdaMenu().IsShown() && !bShowPda ) ) + if ( ( !ui_game_sp->GetPdaMenu().IsShown() && bShowPda ) || + ( ui_game_sp->GetPdaMenu().IsShown() && !bShowPda ) ) { - ui_game_sp->PdaMenu().HideDialog(); + ui_game_sp->GetPdaMenu().HideDialog(); } } } @@ -289,9 +289,9 @@ bool CUISequenceSimpleItem::Stop (bool bForce) if ( g_pGameLevel ) { CUIGameSP* ui_game_sp = smart_cast( CurrentGameUI() ); - if ( ui_game_sp && ui_game_sp->PdaMenu().IsShown() ) + if ( ui_game_sp && ui_game_sp->GetPdaMenu().IsShown() ) { - ui_game_sp->PdaMenu().HideDialog(); + ui_game_sp->GetPdaMenu().HideDialog(); } } inherited::Stop (); diff --git a/src/xrGame/ui/UIMainIngameWnd.cpp b/src/xrGame/ui/UIMainIngameWnd.cpp index ae4b7003fb9..da147e99613 100644 --- a/src/xrGame/ui/UIMainIngameWnd.cpp +++ b/src/xrGame/ui/UIMainIngameWnd.cpp @@ -664,7 +664,7 @@ void CUIMainIngameWnd::UpdateMainIndicators() UpdateQuickSlots(); if (IsGameTypeSingle()) - CurrentGameUI()->PdaMenu().UpdateRankingWnd(); + CurrentGameUI()->GetPdaMenu().UpdateRankingWnd(); u8 flags = 0; flags |= LA_CYCLIC; diff --git a/src/xrGame/ui/UIMapList.cpp b/src/xrGame/ui/UIMapList.cpp index cf79f914ba7..7f67d67d7b3 100644 --- a/src/xrGame/ui/UIMapList.cpp +++ b/src/xrGame/ui/UIMapList.cpp @@ -246,18 +246,12 @@ const char* CUIMapList::GetCommandLine(LPCSTR player_name){ #include "../UIGameCustom.h" void CUIMapList::LoadMapList() { - - GAME_WEATHERS game_weathers = gMapListHelper.GetGameWeathers(); - GAME_WEATHERS_CIT it = game_weathers.begin(); - GAME_WEATHERS_CIT it_e = game_weathers.end(); - - u32 cnt=0; - for( ;it!=it_e; ++it, ++cnt) - { - AddWeather ( (*it).m_weather_name, (*it).m_start_time, cnt); - } - if( game_weathers.size() ) - m_pWeatherSelector->SetItemIDX(0); + const auto& weathers = gMapListHelper.GetGameWeathers(); + u32 cnt = 0; + for (const SGameWeathers& weather : weathers) + AddWeather(weather.Name, weather.StartTime, cnt++); + if (weathers.size() > 0) + m_pWeatherSelector->SetItemIDX(0); } void CUIMapList::SaveMapList()