Skip to content

Commit

Permalink
Background map support (#870)
Browse files Browse the repository at this point in the history
* hide gui elements we do not want

* overwrite valve.rc with startupmenu
  • Loading branch information
AdamTadeusz authored Feb 6, 2025
1 parent f67dac7 commit 761a22f
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 9 deletions.
16 changes: 16 additions & 0 deletions mp/game/neo/cfg/valve.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// load the base configuration
//exec default.cfg

// Setup custom controller
exec joystick.cfg

// run a user script file if present
exec autoexec.cfg

//
// stuff command line statements
//
stuffcmds

// background map
startupmenu
4 changes: 4 additions & 0 deletions mp/src/game/client/hud_basechat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1802,6 +1802,10 @@ void CBaseHudChat::LevelShutdown( void )
//-----------------------------------------------------------------------------
void CBaseHudChat::ChatPrintf( int iPlayerIndex, int iFilter, const char *fmt, ... )
{
if (engine->IsLevelMainMenuBackground())
{
return;
}
va_list marker;
char msg[4096];

Expand Down
2 changes: 1 addition & 1 deletion mp/src/game/client/neo/c_neo_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1289,7 +1289,7 @@ void C_NEO_Player::Spawn( void )
}
}

if (GetTeamNumber() == TEAM_UNASSIGNED)
if (GetTeamNumber() == TEAM_UNASSIGNED && !engine->IsLevelMainMenuBackground())
{
engine->ClientCmd(teammenu.GetName());
}
Expand Down
2 changes: 1 addition & 1 deletion mp/src/game/client/neo/ui/neo_hud_childelement.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class CNEOHud_ChildElement

void PaintNeoElement()
{
if (!engine->IsDrawingLoadingImage())
if (!engine->IsDrawingLoadingImage() && !engine->IsLevelMainMenuBackground())
{
if (ShouldUpdateYet())
{
Expand Down
14 changes: 7 additions & 7 deletions mp/src/game/client/neo/ui/neo_root.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -535,14 +535,14 @@ void CNeoRoot::MainLoopRoot(const MainLoopParam param)
NeoUI::BeginContext(&g_uiCtx, param.eMode, nullptr, "CtxRoot");
NeoUI::BeginSection(true);
{
const int iFlagToMatch = engine->IsInGame() ? FLAG_SHOWINGAME : FLAG_SHOWINMAIN;
const int iFlagToMatch = IsInGame() ? FLAG_SHOWINGAME : FLAG_SHOWINMAIN;
for (int i = 0; i < BTNS_TOTAL; ++i)
{
const auto btnInfo = BTNS_INFO[i];
if (btnInfo.flags & iFlagToMatch)
{
const auto retBtn = NeoUI::Button(m_wszDispBtnTexts[i]);
if (retBtn.bPressed || (i == MMBTN_QUIT && !engine->IsInGame() && NeoUI::Bind(KEY_ESCAPE)))
if (retBtn.bPressed || (i == MMBTN_QUIT && !IsInGame() && NeoUI::Bind(KEY_ESCAPE)))
{
surface()->PlaySound("ui/buttonclickrelease.wav");
if (btnInfo.gamemenucommand)
Expand Down Expand Up @@ -670,7 +670,7 @@ void CNeoRoot::MainLoopRoot(const MainLoopParam param)

g_uiCtx.dPanel.x = iRightXPos;
g_uiCtx.dPanel.y = iRightSideYStart;
if (engine->IsInGame())
if (IsInGame())
{
g_uiCtx.dPanel.wide = m_flWideAs43 * 0.7f;
g_uiCtx.flWgXPerc = 0.25f;
Expand All @@ -681,7 +681,7 @@ void CNeoRoot::MainLoopRoot(const MainLoopParam param)
}
NeoUI::BeginSection();
{
if (engine->IsInGame())
if (IsInGame())
{
// Show the current server's information
NeoUI::Label(L"Hostname:", m_wszHostname);
Expand Down Expand Up @@ -868,7 +868,7 @@ void CNeoRoot::MainLoopNewGame(const MainLoopParam param)
NeoUI::Pad();
if (NeoUI::Button(L"Start").bPressed)
{
if (engine->IsInGame())
if (IsInGame())
{
engine->ClientCmd_Unrestricted("disconnect");
}
Expand Down Expand Up @@ -1107,7 +1107,7 @@ void CNeoRoot::MainLoopServerBrowser(const MainLoopParam param)
{
if (bEnterServer || NeoUI::Button(L"Enter").bPressed)
{
if (engine->IsInGame())
if (IsInGame())
{
engine->ClientCmd_Unrestricted("disconnect");
}
Expand Down Expand Up @@ -1278,7 +1278,7 @@ void CNeoRoot::MainLoopServerDetails(const MainLoopParam param)

void CNeoRoot::MainLoopPlayerList(const MainLoopParam param)
{
if (engine->IsInGame())
if (IsInGame())
{
const int iTallTotal = g_uiCtx.iRowTall * (g_iRowsInScreen + 2);
g_uiCtx.dPanel.wide = g_iRootSubPanelWide;
Expand Down
1 change: 1 addition & 0 deletions mp/src/game/client/neo/ui/neo_root.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ class CNeoRoot : public vgui::EditablePanel, public CGameEventListener
void OnCursorMoved(int x, int y) final;
void OnTick() final;
void FireGameEvent(IGameEvent *event) final;
bool IsInGame() { return (engine->IsInGame() && !engine->IsLevelMainMenuBackground()); }

void OnMainLoop(const NeoUI::Mode eMode);

Expand Down
8 changes: 8 additions & 0 deletions mp/src/game/shared/neo/neo_gamerules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,14 @@ void CNEORules::CheckGameType()

void CNEORules::Think(void)
{
#ifdef GAME_DLL
if (gpGlobals->eLoadType == MapLoad_Background)
#else // CLIENT_DLL
if (engine->IsLevelMainMenuBackground())
#endif // GAME_DLL || CLIENT_DLL
{
return;
}
#ifdef GAME_DLL
const bool bIsIdleState = m_nRoundStatus == NeoRoundStatus::Idle || m_nRoundStatus == NeoRoundStatus::Warmup;
bool bIsPause = m_nRoundStatus == NeoRoundStatus::Pause;
Expand Down

0 comments on commit 761a22f

Please sign in to comment.