diff --git a/game/content-hash.txt b/game/content-hash.txt index e81d69e..1fca07a 100644 --- a/game/content-hash.txt +++ b/game/content-hash.txt @@ -1 +1 @@ -master-c3312fa76076c1b2e32b7e4bf49ac647e6c5f87c +master-8394de137ea6d45de7f52f9fbd1d3104bdc300d8 diff --git a/game/game_libs/ui/BaseMenu.cpp b/game/game_libs/ui/BaseMenu.cpp index 76244f7..92dc0dc 100644 --- a/game/game_libs/ui/BaseMenu.cpp +++ b/game/game_libs/ui/BaseMenu.cpp @@ -62,7 +62,8 @@ const char* uiSounds[] = { "media/launch_select1.wav", "media/launch_deny1.wav", "", - ""}; + "" +}; // they match default WON colors.lst now, except alpha unsigned int uiColorHelp = 0xFF7F7F7F; // 127, 127, 127, 255 // hint letters color @@ -198,7 +199,8 @@ void UI_DrawPic( int height, const unsigned int color, CImage& pic, - const ERenderMode eRenderMode) + const ERenderMode eRenderMode +) { HIMAGE hPic = pic.Handle(); @@ -315,7 +317,8 @@ int UI_DrawString( const unsigned int color, int charH, uint justify, - uint flags) + uint flags +) { uint modulate, shadowModulate = 0; int xx = 0, yy, ofsX = 0, ofsY = 0, ch; @@ -1032,17 +1035,29 @@ static void UI_LoadSounds(void) for ( int i = 0; i < SND_COUNT; i++ ) { if ( !uiSounds[i] || *uiSounds[i] == '\0' ) + { continue; + } if ( !EngFuncs::FileExists(uiSounds[i]) ) { size_t len = strlen(uiSoundOldPrefix); if ( !strncmp(uiSounds[i], uiSoundOldPrefix, len) ) - PlatformLib_SNPrintF(uiStatic.sounds[i], sizeof(uiStatic.sounds[i]), "%s%s", uiSoundNewPrefix, uiSounds[i] + len); + { + PlatformLib_SNPrintF( + uiStatic.sounds[i], + sizeof(uiStatic.sounds[i]), + "%s%s", + uiSoundNewPrefix, + uiSounds[i] + len + ); + } } else + { Q_strncpy(uiStatic.sounds[i], uiSounds[i], sizeof(uiStatic.sounds[i])); + } } } diff --git a/game/game_libs/ui_new/src/framework/MenuPage.cpp b/game/game_libs/ui_new/src/framework/MenuPage.cpp index 50873c2..05fc265 100644 --- a/game/game_libs/ui_new/src/framework/MenuPage.cpp +++ b/game/game_libs/ui_new/src/framework/MenuPage.cpp @@ -34,7 +34,7 @@ void MenuPage::ProcessEvent(Rml::Event& event) { const int keyId = GetEventKeyId(event); - if ( keyId == Rml::Input::KI_ESCAPE && m_RequestPopOnEscapeKey ) + if ( keyId == Rml::Input::KI_ESCAPE && m_RequestPopOnEscapeKey && ShouldPop("") ) { event.StopPropagation(); SetCurrentRequest(MenuRequestType::PopMenu); @@ -70,6 +70,11 @@ void MenuPage::OnBeginDocumentUnloaded() void MenuPage::RequestPop(Rml::String menuToSwapIn) { + if ( !ShouldPop(menuToSwapIn) ) + { + return; + } + Rml::VariantList args; if ( !menuToSwapIn.empty() ) @@ -80,6 +85,11 @@ void MenuPage::RequestPop(Rml::String menuToSwapIn) SetCurrentRequest(MenuRequestType::PopMenu, args); } +bool MenuPage::ShouldPop(const Rml::String&) const +{ + return true; +} + void MenuPage::HandlePushMenu(Rml::DataModelHandle, Rml::Event&, const Rml::VariantList& args) { SetCurrentRequest(MenuRequestType::PushMenu, args); diff --git a/game/game_libs/ui_new/src/framework/MenuPage.h b/game/game_libs/ui_new/src/framework/MenuPage.h index 600d0f3..2e8c401 100644 --- a/game/game_libs/ui_new/src/framework/MenuPage.h +++ b/game/game_libs/ui_new/src/framework/MenuPage.h @@ -21,6 +21,7 @@ class MenuPage : public BaseMenu void OnBeginDocumentUnloaded() override; void RequestPop(Rml::String menuToSwapIn = Rml::String()); + virtual bool ShouldPop(const Rml::String& menuToSwapIn) const; private: void ProcessEvent(Rml::Event& event); diff --git a/game/game_libs/ui_new/src/framework/MenuStack.cpp b/game/game_libs/ui_new/src/framework/MenuStack.cpp index 0449dbd..0e99a6e 100644 --- a/game/game_libs/ui_new/src/framework/MenuStack.cpp +++ b/game/game_libs/ui_new/src/framework/MenuStack.cpp @@ -29,6 +29,7 @@ const MenuDirectoryEntry* MenuStack::Pop() { if ( m_Stack.empty() ) { + ASSERT(false); return nullptr; } @@ -88,25 +89,29 @@ size_t MenuStack::Size() const void MenuStack::SetTopDocumentVisible(bool visible) { - if ( !m_Stack.empty() ) + if ( m_Stack.empty() ) { - const MenuDirectoryEntry* entry = m_Stack.back(); - Rml::ElementDocument* document = entry->document; + return; + } - if ( document ) - { - if ( visible ) - { - document->Show(); - } - else - { - // If there are any pending requests, cancel them. - entry->menuPtr->ClearCurrentRequest(); + const MenuDirectoryEntry* entry = m_Stack.back(); + Rml::ElementDocument* document = entry->document; - document->Hide(); - } - } + if ( !document ) + { + return; + } + + if ( visible ) + { + document->Show(); + } + else + { + // If there are any pending requests, cancel them. + entry->menuPtr->ClearCurrentRequest(); + + document->Hide(); } } @@ -176,15 +181,7 @@ void MenuStack::HandlePopMenuRequest(const Rml::String& name) { if ( name.empty() ) { - if ( m_Stack.size() > 1 ) - { - Pop(); - } - else - { - Rml::Log::Message(Rml::Log::Type::LT_WARNING, "Ignoring pop request from only menu in stack"); - } - + Pop(); return; } diff --git a/game/game_libs/ui_new/src/menus/MainMenu.cpp b/game/game_libs/ui_new/src/menus/MainMenu.cpp index dd7ae4d..8f352d1 100644 --- a/game/game_libs/ui_new/src/menus/MainMenu.cpp +++ b/game/game_libs/ui_new/src/menus/MainMenu.cpp @@ -1,4 +1,8 @@ #include "menus/MainMenu.h" +#include "udll_int.h" + +static constexpr const char* const NAME_SHOW_CONSOLE_BUTTON = "showConsoleButton"; +static constexpr const char* const EVENT_SHOW_DEVELOPER_CONSOLE = "showDeveloperConsole"; const char* const MainMenu::NAME = "main_menu"; @@ -10,5 +14,38 @@ MainMenu::MainMenu() : bool MainMenu::OnSetUpDataModelBindings(Rml::DataModelConstructor& constructor) { - return MenuPage::OnSetUpDataModelBindings(constructor) && m_MenuFrameDataBinding.SetUpDataBindings(constructor); + if ( !MenuPage::OnSetUpDataModelBindings(constructor) || !m_MenuFrameDataBinding.SetUpDataBindings(constructor) ) + { + return false; + } + + if ( !constructor.BindEventCallback(EVENT_SHOW_DEVELOPER_CONSOLE, &MainMenu::HandleShowDeveloperConsole, this) ) + { + return false; + } + + const bool bindSuccess = constructor.BindFunc( + NAME_SHOW_CONSOLE_BUTTON, + [this](Rml::Variant& outValue) + { + outValue = Rml::Variant(ShouldPop("")); + } + ); + + if ( !bindSuccess ) + { + return false; + } + + return true; +} + +bool MainMenu::ShouldPop(const Rml::String&) const +{ + return gpGlobals->developer != 0; +} + +void MainMenu::HandleShowDeveloperConsole(Rml::DataModelHandle, Rml::Event&, const Rml::VariantList&) +{ + RequestPop(); } diff --git a/game/game_libs/ui_new/src/menus/MainMenu.h b/game/game_libs/ui_new/src/menus/MainMenu.h index 249a56b..85c1418 100644 --- a/game/game_libs/ui_new/src/menus/MainMenu.h +++ b/game/game_libs/ui_new/src/menus/MainMenu.h @@ -12,7 +12,10 @@ class MainMenu : public MenuPage protected: bool OnSetUpDataModelBindings(Rml::DataModelConstructor& constructor) override; + bool ShouldPop(const Rml::String& menuToSwapIn) const override; private: + void HandleShowDeveloperConsole(Rml::DataModelHandle handle, Rml::Event& event, const Rml::VariantList& args); + MenuFrameDataBinding m_MenuFrameDataBinding; }; diff --git a/game/game_libs/ui_new/src/rmlui/RenderInterfaceImpl.cpp b/game/game_libs/ui_new/src/rmlui/RenderInterfaceImpl.cpp index c76731e..26bbf09 100644 --- a/game/game_libs/ui_new/src/rmlui/RenderInterfaceImpl.cpp +++ b/game/game_libs/ui_new/src/rmlui/RenderInterfaceImpl.cpp @@ -224,65 +224,3 @@ void RenderInterfaceImpl::SetTransform(const Rml::Matrix4f* transform) gUiGlFuncs.renderer.setTransform(nullptr); } - -void RenderInterfaceImpl::RenderDebugTriangle() -{ - static Rml::CompiledGeometryHandle geom = 0; - static Rml::TextureHandle texture = 0; - - if ( !geom ) - { - static const float extent = 200.0f; - - static const Rml::Vertex verticesArray[] = { - {{0, 0}, Rml::ColourbPremultiplied {255, 0, 0, 255}, {0, 0}}, - {{extent, 0}, Rml::ColourbPremultiplied {255, 0, 0, 255}, {1, 0}}, - {{extent / 2.0f, extent}, Rml::ColourbPremultiplied {255, 0, 0, 255}, {0.5f, 1}}, - }; - - static const int indicesArray[] = { - 0, - 1, - 2, - }; - - Rml::Span vertices(verticesArray, 3); - Rml::Span indices(indicesArray, 3); - geom = CompileGeometry(vertices, indices); - } - - if ( !texture ) - { - static constexpr int WIDTH = 16; - static constexpr int HEIGHT = 16; - - uint32_t texDataRGBA[WIDTH * HEIGHT]; - memset(&texDataRGBA, 0xFF, sizeof(texDataRGBA)); - - Rml::Span texData(reinterpret_cast(texDataRGBA), sizeof(texDataRGBA)); - texture = GenerateTexture(texData, Rml::Vector2i(WIDTH, HEIGHT)); - } - - gUiGlFuncs.renderer.beginFrame(0, 0, m_ViewportWidth, m_ViewportHeight); - gUiGlFuncs.renderer.clear(0x000000FF, 0); - - gUiGlFuncs.renderer.pushProjectionMatrixTranslation(20, 50, 0); - - const GeometryView* geometry = reinterpret_cast(geom); - const Rml::Vertex* vertices = geometry->vertices.data(); - const int* indices = geometry->indices.data(); - const int num_indices = static_cast(geometry->indices.size()); - - gUiGlFuncs.renderer.prepareToDrawWithTexture( - static_cast(texture), - vertices, - sizeof(Rml::Vertex), - offsetof(Rml::Vertex, position), - offsetof(Rml::Vertex, colour), - offsetof(Rml::Vertex, tex_coord) - ); - - gUiGlFuncs.renderer.drawElements(num_indices, indices); - gUiGlFuncs.renderer.popProjectionMatrix(); - gUiGlFuncs.renderer.endFrame(); -} diff --git a/game/game_libs/ui_new/src/rmlui/RenderInterfaceImpl.h b/game/game_libs/ui_new/src/rmlui/RenderInterfaceImpl.h index 08a2b5d..a8d98d0 100644 --- a/game/game_libs/ui_new/src/rmlui/RenderInterfaceImpl.h +++ b/game/game_libs/ui_new/src/rmlui/RenderInterfaceImpl.h @@ -50,8 +50,6 @@ class RenderInterfaceImpl : public Rml::RenderInterface void SetTransform(const Rml::Matrix4f* transform) override; - void RenderDebugTriangle(); - private: struct GeometryView { diff --git a/game/game_libs/ui_new/src/rmlui/RmlUiBackend.cpp b/game/game_libs/ui_new/src/rmlui/RmlUiBackend.cpp index 1cb4fa5..9a389d5 100644 --- a/game/game_libs/ui_new/src/rmlui/RmlUiBackend.cpp +++ b/game/game_libs/ui_new/src/rmlui/RmlUiBackend.cpp @@ -124,30 +124,21 @@ bool RmlUiBackend::IsVisible() const return m_Visible; } -void RmlUiBackend::ReceiveStartupComplete() +void RmlUiBackend::ReceiveShowMenu() { - ASSERT(IsInitialised()); - if ( !IsInitialised() ) { return; } - const MenuDirectoryEntry* menu = m_MenuDirectory.GetMenuEntry(MainMenu::NAME); - ASSERT(menu); - - m_MenuStack.Push(menu); - ReceiveShowMenu(); -} + m_Visible = true; -void RmlUiBackend::ReceiveShowMenu() -{ - if ( !IsInitialised() ) + if ( m_MenuStack.IsEmpty() ) { - return; + const MenuDirectoryEntry* menu = m_MenuDirectory.GetMenuEntry(MainMenu::NAME); + ASSERT(menu); + m_MenuStack.Push(menu); } - - m_Visible = true; } void RmlUiBackend::ReceiveHideMenu() @@ -283,6 +274,13 @@ Rml::Context* RmlUiBackend::GetRmlContext() const return m_RmlContext; } +bool RmlUiBackend::ShouldPopToConsole() +{ + bool out = m_ShouldPopToConsole; + m_ShouldPopToConsole = false; + return out; +} + void RmlUiBackend::SetStoreNextKey(bool onPressed) { if ( !IsInitialised() ) @@ -331,8 +329,16 @@ void RmlUiBackend::Update(float currentTime) return; } + bool hadMenusInStack = !m_MenuStack.IsEmpty(); + m_MenuStack.Update(currentTime); m_RmlContext->Update(); + m_MenuStack.HandleRequests(); + + if ( hadMenusInStack && m_MenuStack.IsEmpty() ) + { + m_ShouldPopToConsole = true; + } } void RmlUiBackend::Render() @@ -345,19 +351,6 @@ void RmlUiBackend::Render() m_RenderInterface.BeginFrame(); m_RmlContext->Render(); m_RenderInterface.EndFrame(); - - // Now that rendering is done, modify the menu stack if needed. - m_MenuStack.HandleRequests(); -} - -void RmlUiBackend::RenderDebugTriangle() -{ - if ( !IsInitialised() ) - { - return; - } - - m_RenderInterface.RenderDebugTriangle(); } void RmlUiBackend::ReleaseResources() diff --git a/game/game_libs/ui_new/src/rmlui/RmlUiBackend.h b/game/game_libs/ui_new/src/rmlui/RmlUiBackend.h index 589c5b8..59470ec 100644 --- a/game/game_libs/ui_new/src/rmlui/RmlUiBackend.h +++ b/game/game_libs/ui_new/src/rmlui/RmlUiBackend.h @@ -32,7 +32,6 @@ class RmlUiBackend void ShutDown(); bool IsInitialised() const; bool IsVisible() const; - void ReceiveStartupComplete(); void ReceiveShowMenu(); void ReceiveHideMenu(); void ReceiveMouseMove(int x, int y); @@ -45,6 +44,7 @@ class RmlUiBackend void Render(); Rml::Context* GetRmlContext() const; + bool ShouldPopToConsole(); void SetStoreNextKey(bool onPressed); void ClearStoreNextKey(); @@ -52,8 +52,6 @@ class RmlUiBackend bool HasStoredKey() const; StoredKey TakeStoredKey(); - void RenderDebugTriangle(); - private: struct MainMenuData; @@ -74,6 +72,7 @@ class RmlUiBackend MenuDirectory m_MenuDirectory; MenuStack m_MenuStack; bool m_Visible = false; + bool m_ShouldPopToConsole = false; bool m_StoreNextKey = false; StoredKey m_StoredKey {}; diff --git a/game/game_libs/ui_new/src/udll_int.cpp b/game/game_libs/ui_new/src/udll_int.cpp index a1534a9..28cafec 100644 --- a/game/game_libs/ui_new/src/udll_int.cpp +++ b/game/game_libs/ui_new/src/udll_int.cpp @@ -10,6 +10,8 @@ ui_extendedfuncs_t gTextfuncs; ui_globalvars_t* gpGlobals = nullptr; ui_gl_functions gUiGlFuncs; +static void pfnSetActiveMenu(int active); + static int pfnVidInit(void) { RmlUiBackend& backend = RmlUiBackend::StaticInstance(); @@ -32,12 +34,16 @@ static void pfnRedraw(float flTime) { RmlUiBackend& backend = RmlUiBackend::StaticInstance(); -#ifdef RENDER_DEBUG_TRIANGLE - backend.RenderDebugTriangle(); -#else backend.Update(flTime); + + if ( backend.ShouldPopToConsole() ) + { + pfnSetActiveMenu(0); + gEngfuncs.pfnSetKeyDest(key_console); + return; + } + backend.Render(); -#endif } static void pfnKeyEvent(int key, int down) @@ -223,9 +229,12 @@ static void pfnConnectionProgress_ParseServerInfo(const char* /* server */) // TODO } -static void pfnStartupComplete(void) +static void pfnStartupComplete(qboolean toConsole) { - RmlUiBackend::StaticInstance().ReceiveStartupComplete(); + if ( !toConsole ) + { + RmlUiBackend::StaticInstance().ReceiveShowMenu(); + } } static const UI_FUNCTIONS gFunctionTable = { diff --git a/xash3d_engine/engine/src/client/cl_gameui.c b/xash3d_engine/engine/src/client/cl_gameui.c index fc60c9b..277d24e 100644 --- a/xash3d_engine/engine/src/client/cl_gameui.c +++ b/xash3d_engine/engine/src/client/cl_gameui.c @@ -1387,11 +1387,11 @@ static char* pfnParseFileSafe(char* data, char* buf, const int size, unsigned in return COM_ParseFileSafe(data, buf, size, flags, len, NULL); } -void UI_StartupComplete(void) +void UI_StartupComplete(qboolean toConsole) { if ( gameui.dllFuncs2.pfnStartupComplete ) { - gameui.dllFuncs2.pfnStartupComplete(); + gameui.dllFuncs2.pfnStartupComplete(toConsole); } } diff --git a/xash3d_engine/engine/src/client/cl_scrn.c b/xash3d_engine/engine/src/client/cl_scrn.c index a26ac08..7a0f195 100644 --- a/xash3d_engine/engine/src/client/cl_scrn.c +++ b/xash3d_engine/engine/src/client/cl_scrn.c @@ -839,10 +839,14 @@ void SCR_Init(void) SCR_InitCinematic(); CL_InitNetgraph(); - if ( host.allow_console && Sys_CheckParm("-toconsole") ) - Cbuf_AddText("toggleconsole\n"); - else + // We used to do toggleconsole here, but that has no effect this early + // because cls.state is still "disconnected" by the time the command + // is executed. Instead, we just don't set the UI as active, and let + // the engine fall into console mode naturally. + if ( !(host.allow_console && Sys_CheckParm("-toconsole")) ) + { UI_SetActiveMenu(true); + } scr_init = true; } diff --git a/xash3d_engine/engine/src/client/client.h b/xash3d_engine/engine/src/client/client.h index 58a5094..e6d8eaf 100644 --- a/xash3d_engine/engine/src/client/client.h +++ b/xash3d_engine/engine/src/client/client.h @@ -1160,7 +1160,7 @@ void pfnPIC_Draw(int x, int y, int width, int height, const wrect_t* prc); void pfnPIC_DrawTrans(int x, int y, int width, int height, const wrect_t* prc); void pfnPIC_DrawHoles(int x, int y, int width, int height, const wrect_t* prc); void pfnPIC_DrawAdditive(int x, int y, int width, int height, const wrect_t* prc); -void UI_StartupComplete(void); +void UI_StartupComplete(qboolean toConsole); // // cl_mobile.c diff --git a/xash3d_engine/engine/src/client/console.c b/xash3d_engine/engine/src/client/console.c index 4645ebf..9478fa1 100644 --- a/xash3d_engine/engine/src/client/console.c +++ b/xash3d_engine/engine/src/client/console.c @@ -290,13 +290,17 @@ Con_ToggleConsole_f void Con_ToggleConsole_f(void) { if ( !host.allow_console || UI_CreditsActive() ) + { return; // disabled + } SCR_EndLoadingPlaque(); // show console only in game or by special call from menu if ( cls.state != ca_active || cls.key_dest == key_menu ) + { return; + } Con_ClearTyping(); Con_ClearNotify(); @@ -304,9 +308,13 @@ void Con_ToggleConsole_f(void) if ( cls.key_dest == key_console ) { if ( Cvar_VariableInteger("sv_background") || Cvar_VariableInteger("cl_background") ) + { UI_SetActiveMenu(true); + } else + { UI_SetActiveMenu(false); + } } else { @@ -1113,7 +1121,8 @@ void GAME_EXPORT Con_NXPrintf(con_nprint_t* info, const char* fmt, ...) (byte)(info->color[0] * 255), (byte)(info->color[1] * 255), (byte)(info->color[2] * 255), - 255); + 255 + ); con.draw_notify = true; } @@ -1175,7 +1184,8 @@ void GAME_EXPORT UI_NXPrintf(con_nprint_t* info, const char* fmt, ...) (byte)(info->color[0] * 255), (byte)(info->color[1] * 255), (byte)(info->color[2] * 255), - 255); + 255 + ); con.draw_notify = true; } @@ -1813,7 +1823,8 @@ int Con_DrawDebugLines(void) notify->szNotify, notify->color, con.curFont, - FONT_DRAW_UTF8 | FONT_DRAW_NOLF); + FONT_DRAW_UTF8 | FONT_DRAW_NOLF + ); } return count; @@ -1841,7 +1852,8 @@ void Con_DrawDebug(void) host.downloadcount, host.downloadfile, scr_download->value, - Sys_DoubleTime() - timeStart); + Sys_DoubleTime() - timeStart + ); x = refState.width - 500; y = (int)(con.curFont->charHeight * 1.05f); Con_DrawString(x, y, dlstring, g_color_table[7]); @@ -2001,7 +2013,8 @@ void Con_DrawSolidConsole(int lines) 0, 1, 1, - R_GetBuiltinTexture(REF_BLACK_TEXTURE)); + R_GetBuiltinTexture(REF_BLACK_TEXTURE) + ); ref.dllFuncs.R_DrawStretchPic( 0, (float)(lines - refState.width * 3 / 4), @@ -2011,7 +2024,8 @@ void Con_DrawSolidConsole(int lines) 0, 1, 1, - con.background); + con.background + ); if ( !con.curFont || !host.allow_console ) return; // nothing to draw @@ -2026,7 +2040,8 @@ void Con_DrawSolidConsole(int lines) PROTOCOL_VERSION, BuildPlatform_PlatformString(), BuildPlatform_ArchitectureString(), - Q_buildnum()); + Q_buildnum() + ); Con_DrawStringLen(curbuild, &stringLen, &charH); @@ -2193,7 +2208,8 @@ void Con_DrawVersion(void) PROTOCOL_VERSION, BuildPlatform_PlatformString(), BuildPlatform_ArchitectureString(), - Q_buildnum()); + Q_buildnum() + ); else Q_snprintf( curbuild, @@ -2202,7 +2218,8 @@ void Con_DrawVersion(void) PROTOCOL_VERSION, BuildPlatform_PlatformString(), BuildPlatform_ArchitectureString(), - Q_buildnum()); + Q_buildnum() + ); Con_DrawStringLen(curbuild, &stringLen, &charH); start = (int)(refState.width - stringLen * 1.05f); @@ -2337,28 +2354,40 @@ void Con_VidInit(void) { // trying to load truecolor image first if ( FS_FileExists("gfx/shell/conback.bmp", false) || FS_FileExists("gfx/shell/conback.tga", false) ) + { con.background = ref.dllFuncs.GL_LoadTexture("gfx/shell/conback", NULL, 0, TF_IMAGE); + } if ( !con.background ) { if ( FS_FileExists("cached/conback640", false) ) + { con.background = ref.dllFuncs.GL_LoadTexture("cached/conback640", NULL, 0, TF_IMAGE); + } else if ( FS_FileExists("cached/conback", false) ) + { con.background = ref.dllFuncs.GL_LoadTexture("cached/conback", NULL, 0, TF_IMAGE); + } } } else { // trying to load truecolor image first if ( FS_FileExists("gfx/shell/loading.bmp", false) || FS_FileExists("gfx/shell/loading.tga", false) ) + { con.background = ref.dllFuncs.GL_LoadTexture("gfx/shell/loading", NULL, 0, TF_IMAGE); + } if ( !con.background ) { if ( FS_FileExists("cached/loading640", false) ) + { con.background = ref.dllFuncs.GL_LoadTexture("cached/loading640", NULL, 0, TF_IMAGE); + } else if ( FS_FileExists("cached/loading", false) ) + { con.background = ref.dllFuncs.GL_LoadTexture("cached/loading", NULL, 0, TF_IMAGE); + } } } @@ -2370,13 +2399,19 @@ void Con_VidInit(void) // NOTE: only these games want to draw build number into console background if ( !Q_stricmp(FS_Gamedir(), "id1") ) + { draw_to_console = true; + } if ( !Q_stricmp(FS_Gamedir(), "hipnotic") ) + { draw_to_console = true; + } if ( !Q_stricmp(FS_Gamedir(), "rogue") ) + { draw_to_console = true; + } if ( draw_to_console && con.curFont && (buf = ref.dllFuncs.R_GetTextureOriginalBuffer(con.curFont->hFontTexture)) != NULL ) @@ -2391,21 +2426,32 @@ void Con_VidInit(void) len = Q_snprintf(ver, 64, "%i", Q_buildnum()); // can store only buildnum dest = (byte*)(cb + 1) + 320 * 186 + 320 - 11 - 8 * len; y = len; + for ( x = 0; x < y; x++ ) + { Con_DrawCharToConback(ver[x], buf, dest + (x << 3)); + } + con.background = ref.dllFuncs.GL_LoadTexture("#gfx/conback.lmp", (byte*)cb, length, TF_IMAGE); } + if ( cb ) + { Mem_Free(cb); + } } if ( !con.background ) // trying the load unmodified conback + { con.background = ref.dllFuncs.GL_LoadTexture("gfx/conback.lmp", NULL, 0, TF_IMAGE); + } } // missed console image will be replaced as gray background like X-Ray or Crysis if ( con.background == R_GetBuiltinTexture(REF_DEFAULT_TEXTURE) || con.background == 0 ) + { con.background = R_GetBuiltinTexture(REF_GRAY_TEXTURE); + } } /* diff --git a/xash3d_engine/engine/src/common/host.c b/xash3d_engine/engine/src/common/host.c index ee452d2..fa0ceec 100644 --- a/xash3d_engine/engine/src/common/host.c +++ b/xash3d_engine/engine/src/common/host.c @@ -1400,7 +1400,8 @@ int EXPORT Host_Main(int argc, char** argv, const char* progname, int bChangeGam #if !XASH_DEDICATED() if ( !Host_IsDedicated() ) { - UI_StartupComplete(); + const qboolean toConsole = host.allow_console && Sys_CheckParm("-toconsole"); + UI_StartupComplete(toConsole); } #endif diff --git a/xash3d_engine/engineinternalapi/include/EngineInternalAPI/menu_int.h b/xash3d_engine/engineinternalapi/include/EngineInternalAPI/menu_int.h index 425f5a1..4ba0055 100644 --- a/xash3d_engine/engineinternalapi/include/EngineInternalAPI/menu_int.h +++ b/xash3d_engine/engineinternalapi/include/EngineInternalAPI/menu_int.h @@ -278,7 +278,11 @@ typedef struct void (*pfnConnectionProgress_Connect)(const char* server); // NULL for local server void (*pfnConnectionProgress_ChangeLevel)(void); void (*pfnConnectionProgress_ParseServerInfo)(const char* server); - void (*pfnStartupComplete)(void); // Called when the main menu is first reached. + + // Called when the main menu is first reached, and cvars are available to be read. + // if toConsole is true, -toconsole was passed on the command line, so the menu + // should not be shown yet. + void (*pfnStartupComplete)(qboolean toConsole); } UI_EXTENDED_FUNCTIONS; typedef int (*MENUAPI)(UI_FUNCTIONS* pFunctionTable, ui_enginefuncs_t* engfuncs, ui_globalvars_t* pGlobals);