From ffa678770e44fa16c1ff82f262d1017964490964 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Thu, 21 Jun 2018 21:29:56 +0300 Subject: [PATCH 01/18] ... --- menus/ServerBrowser.cpp | 62 ++++++++++++++++------------------------- 1 file changed, 24 insertions(+), 38 deletions(-) diff --git a/menus/ServerBrowser.cpp b/menus/ServerBrowser.cpp index f9cadef7..00331164 100644 --- a/menus/ServerBrowser.cpp +++ b/menus/ServerBrowser.cpp @@ -176,7 +176,6 @@ class CMenuServerBrowser: public CMenuFramework static void Connect( server_t &server ); CMenuPicButton *joinGame; - CMenuPicButton *createGame; CMenuPicButton *refresh; CMenuSwitch natOrDirect; @@ -416,16 +415,6 @@ void CMenuServerBrowser::_Init( void ) VoidCb( &CMenuServerBrowser::JoinGame ), QMF_GRAYED ); joinGame->onActivatedClActive = msgBox.MakeOpenEvent(); - createGame = AddButton( "Create game", NULL, PC_CREATE_GAME ); - SET_EVENT_MULTI( createGame->onActivated, - { - if( ((CMenuServerBrowser*)pSelf->Parent())->m_bLanOnly ) - EngFuncs::CvarSetValue( "public", 0.0f ); - else EngFuncs::CvarSetValue( "public", 1.0f ); - - UI_CreateGame_Menu(); - }); - // TODO: implement! AddButton( "View game info", "Get detail game info", PC_VIEW_GAME_INFO, CEventCallback::NoopCb, QMF_GRAYED ); @@ -439,6 +428,7 @@ void CMenuServerBrowser::_Init( void ) msgBox.onPositive = VoidCb( &CMenuServerBrowser::JoinGame ); msgBox.Link( this ); + gameList.SetRect( 360, 255, -20, 440 ); gameList.SetCharSize( QM_SMALLFONT ); gameList.SetupColumn( 0, NULL, 32.0f, true ); gameList.SetupColumn( 1, "Name", 0.40f ); @@ -449,11 +439,14 @@ void CMenuServerBrowser::_Init( void ) gameList.bFramedHintText = true; gameList.bAllowSorting = true; - natOrDirect.AddSwitch( "Direct" ); - natOrDirect.AddSwitch( "NAT" ); + natOrDirect.bKeepToggleWidth = true; + natOrDirect.size.w = 400; + natOrDirect.SetCoord( -20 - natOrDirect.size.w, 255 - gameList.charSize.h * 1.5 - UI_OUTLINE_WIDTH * 2 - natOrDirect.size.h ); + natOrDirect.AddSwitch("Direct"); + natOrDirect.AddSwitch("NAT"); + natOrDirect.AddSwitch("LAN"); natOrDirect.eTextAlignment = QM_CENTER; natOrDirect.bMouseToggle = false; - natOrDirect.LinkCvar( "cl_nat" ); natOrDirect.iSelectColor = uiInputFgColor; // bit darker natOrDirect.iFgTextColor = uiInputFgColor - 0x00151515; @@ -462,15 +455,27 @@ void CMenuServerBrowser::_Init( void ) CMenuSwitch *self = (CMenuSwitch*)pSelf; CMenuServerBrowser *parent = (CMenuServerBrowser*)self->Parent(); - self->WriteCvar(); + switch( self->GetState() ) + { + case 0: + EngFuncs::CvarSetString("cl_nat", "0"); + parent->SetLANOnly(false); + break; + case 1: + EngFuncs::CvarSetString("cl_nat", "1"); + parent->SetLANOnly(false); + break; + case 2: + EngFuncs::CvarSetString("cl_nat", "0"); + parent->SetLANOnly(true); + break; + default: break; + } + parent->ClearList(); parent->RefreshList(); }); - // server.dll needs for reading savefiles or startup newgame - if( !EngFuncs::CheckGameDll( )) - createGame->SetGrayed( true ); // server.dll is missed - remote servers only - password.bHideInput = true; password.bAllowColorstrings = false; password.bNumbersOnly = false; @@ -512,22 +517,6 @@ CMenuServerBrowser::VidInit */ void CMenuServerBrowser::_VidInit() { - if( m_bLanOnly ) - { - banner.SetPicture( ART_BANNER_LAN ); - createGame->szStatusText = ( "Create new LAN game" ); - natOrDirect.Hide(); - } - else - { - banner.SetPicture( ART_BANNER_INET ); - createGame->szStatusText = ( "Create new Internet game" ); - natOrDirect.Show(); - } - - gameList.SetRect( 360, 230, -20, 465 ); - natOrDirect.SetCoord( -20 - natOrDirect.size.w, gameList.pos.y - UI_OUTLINE_WIDTH - natOrDirect.size.h ); - refreshTime = uiStatic.realTime + 500; // delay before update 0.5 sec refreshTime2 = uiStatic.realTime + 500; } @@ -571,9 +560,6 @@ CMenuServerBrowser::Menu */ void UI_ServerBrowser_Menu( void ) { - if ( gMenu.m_gameinfo.gamemode == GAME_SINGLEPLAYER_ONLY ) - return; - // stop demos to allow network sockets to open if ( gpGlobals->demoplayback && EngFuncs::GetCvarFloat( "cl_background" )) { From b8083fb90fbb26d7005b68b916d6ef564e5c42c3 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Thu, 21 Jun 2018 21:29:56 +0300 Subject: [PATCH 02/18] ... --- menus/ServerBrowser.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/menus/ServerBrowser.cpp b/menus/ServerBrowser.cpp index 00331164..ba9d87d8 100644 --- a/menus/ServerBrowser.cpp +++ b/menus/ServerBrowser.cpp @@ -517,6 +517,9 @@ CMenuServerBrowser::VidInit */ void CMenuServerBrowser::_VidInit() { + gameList.SetRect( 360, 230, -20, 465 ); + natOrDirect.SetCoord( -20 - natOrDirect.size.w, gameList.pos.y - UI_OUTLINE_WIDTH - natOrDirect.size.h ); + refreshTime = uiStatic.realTime + 500; // delay before update 0.5 sec refreshTime2 = uiStatic.realTime + 500; } From 6f7cb867f55422c23d6d8dff434fa58b135b83ce Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Thu, 21 Jun 2018 21:30:35 +0300 Subject: [PATCH 03/18] Add cs interface --- CMakeLists.txt | 8 +++++++- udll_int.cpp | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ad524b63..49e8869f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,6 +37,10 @@ option(MAINUI_USE_STB "Use stb_truetype.h for rendering(*nix-only)" OFF) option(MAINUI_RENDER_PICBUTTON_TEXT "Use custom font render to render picbuttons(experimental)" OFF) option(MAINUI_FONT_SCALE "Scale fonts by height" OFF) +if(NOT XASH_SDK) + set(XASH_SDK "../") +endif() + set(MAINUI_CONTROLS_SOURCES controls/Framework.cpp controls/BaseItem.cpp @@ -114,6 +118,7 @@ set(MAINUI_SOURCES Utils.cpp Scissor.cpp udll_int.cpp + ${XASH_SDK}/common/interface.cpp ) if(CS16CLIENT) @@ -158,7 +163,7 @@ if(APPLE) set(MAINUI_USE_STB TRUE) endif() -include_directories(${XASH_SDK}/common ${XASH_SDK}/engine ${XASH_SDK}/pm_shared . controls/ menus/ utl/ font/ model/) +include_directories(${XASH_SDK}/common ${XASH_SDK}/engine ${XASH_SDK}/pm_shared ${XASH_SDK}/public . controls/ menus/ utl/ font/ model/) if(MSVC) add_definitions(-D_CRT_SECURE_NO_WARNINGS) @@ -205,5 +210,6 @@ if(XASH_64BIT) OUTPUT_NAME ${MAINUI_NAME}64) endif() +target_link_libraries(${MAINUI_LIBRARY} ${CMAKE_DL_LIBS}) fwgs_set_default_properties(${MAINUI_LIBRARY}) fwgs_install(${MAINUI_LIBRARY}) diff --git a/udll_int.cpp b/udll_int.cpp index 88535ab0..940d04c7 100644 --- a/udll_int.cpp +++ b/udll_int.cpp @@ -17,12 +17,14 @@ GNU General Public License for more details. #include "extdll_menu.h" #include "BaseMenu.h" #include "Utils.h" +#include "cl_dll/IGameClientExports.h" ui_enginefuncs_t EngFuncs::engfuncs; #ifndef XASH_DISABLE_FWGS_EXTENSIONS ui_textfuncs_t EngFuncs::textfuncs; #endif ui_globalvars_t *gpGlobals; +IGameClientExports *g_pClient; CMenu gMenu; static UI_FUNCTIONS gFunctionTable = @@ -80,3 +82,33 @@ extern "C" EXPORT int GiveTextAPI( ui_textfuncs_t* pTextfuncsFromEngine ) return TRUE; } #endif + +class CGameMenuExports : public IGameMenuExports +{ +public: + bool Initialize( CreateInterfaceFn factory ) + { + g_pClient = (IGameClientExports*)factory( GAMECLIENTEXPORTS_INTERFACE_VERSION, NULL ); + + return g_pClient ? true : false; + } + + int HudFontHeight(float scale) + { + return g_FontMgr.GetFontTall( uiStatic.hSmallFont ) * scale; + } + + int HudCharacterWidth(int num, float scale) + { + return g_FontMgr.GetCharacterWidthScaled( uiStatic.hSmallFont, num, UI_SMALL_CHAR_HEIGHT * scale ); + } + + int HudDrawCharacter(int x, int y, int num, int r, int g, int b, float scale) + { + int color = PackRGBA( r, g, b, 255 ); + + return g_FontMgr.DrawCharacter( uiStatic.hSmallFont, num, Point( x, y ), Size( 0, UI_SMALL_CHAR_HEIGHT * scale ), color ); + } +} s_Menu; + +EXPOSE_SINGLE_INTERFACE_GLOBALVAR(CGameMenuExports, IGameMenuExports, GAMEMENUEXPORTS_INTERFACE_VERSION, s_Menu ); From f0af584275561c876afda7b254cfc9f7589c7367 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Wed, 18 Jul 2018 01:13:27 +0300 Subject: [PATCH 04/18] ... --- Android.mk | 6 ++++-- controls/PicButton.cpp | 17 ++++++++++++++--- controls/PicButton.h | 2 ++ 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/Android.mk b/Android.mk index 255f1bdb..4fca3a03 100644 --- a/Android.mk +++ b/Android.mk @@ -12,7 +12,7 @@ ifeq ($(TARGET_ARCH_ABI),armeabi-v7a-hard) endif LOCAL_MODULE := menu -LOCAL_CPPFLAGS := -std=gnu++11 -DMAINUI_USE_STB -DMAINUI_USE_CUSTOM_FONT_RENDER -DNO_STL -fno-rtti -fno-exceptions +LOCAL_CPPFLAGS := -std=gnu++11 -DMAINUI_USE_STB -DMAINUI_USE_CUSTOM_FONT_RENDER -DNO_STL -fno-rtti -fno-exceptions -DMAINUI_RENDER_PICBUTTON_TEXT LOCAL_C_INCLUDES := \ $(SDL_PATH)/include \ @@ -22,6 +22,7 @@ LOCAL_C_INCLUDES := \ $(LOCAL_PATH)/../engine \ $(LOCAL_PATH)/../engine/common \ $(LOCAL_PATH)/../utils/vgui/include \ + $(LOCAL_PATH)/../public/ \ $(LOCAL_PATH)/menus \ $(LOCAL_PATH)/controls \ $(LOCAL_PATH)/font \ @@ -89,6 +90,7 @@ LOCAL_SRC_FILES := \ Scissor.cpp \ udll_int.cpp \ CFGScript.cpp \ - EngineCallback.cpp + EngineCallback.cpp \ + ../common/interface.cpp include $(BUILD_SHARED_LIBRARY) diff --git a/controls/PicButton.cpp b/controls/PicButton.cpp index 0bbdcd5b..91693cb9 100644 --- a/controls/PicButton.cpp +++ b/controls/PicButton.cpp @@ -144,6 +144,20 @@ void CMenuPicButton::Draw( ) { int state = BUTTON_NOFOCUS; + if( UI_CursorInRect( m_scPos, m_scSize ) && m_pParent == uiStatic.menuActive ) + { + if( !bRollOver ) + { + EngFuncs::PlayLocalSound( uiSoundRollOver ); + bRollOver = true; + } + } + else + { + if( bRollOver ) + bRollOver = false; + } + if( iFlags & (QMF_HASMOUSEFOCUS|QMF_HASKEYBOARDFOCUS)) { state = BUTTON_FOCUS; @@ -235,9 +249,6 @@ void CMenuPicButton::Draw( ) if( iFlags & QMF_GRAYED ) { #ifdef MAINUI_RENDER_PICBUTTON_TEXT - if( UI_CursorInRect( m_scPos, m_scSize ) ) - a = 255; - if( a > 0 ) { UI_DrawString( uiStatic.hHeavyBlur, m_scPos, m_scSize, szName, diff --git a/controls/PicButton.h b/controls/PicButton.h index 8749b5ac..a926d1db 100644 --- a/controls/PicButton.h +++ b/controls/PicButton.h @@ -57,6 +57,8 @@ class CMenuPicButton : public CMenuBaseItem static void RootChanged( bool isForward ); private: + bool bRollOver; + enum animState_e { AS_TO_TITLE = 0, AS_TO_BUTTON }; struct Quad { From e036cd7f535f26bc7b2499e7c167e69d54350f61 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Wed, 18 Jul 2018 01:44:07 +0300 Subject: [PATCH 05/18] Rework main menu --- menus/Main.cpp | 208 +++++-------------------------------------------- 1 file changed, 19 insertions(+), 189 deletions(-) diff --git a/menus/Main.cpp b/menus/Main.cpp index c8e7ffa1..108767b9 100644 --- a/menus/Main.cpp +++ b/menus/Main.cpp @@ -49,62 +49,22 @@ class CMenuMain: public CMenuFramework void QuitDialog( void *pExtra = NULL ); void DisconnectDialogCb(); - void HazardCourseDialogCb(); - void HazardCourseCb(); CMenuPicButton console; - class CMenuMainBanner : public CMenuBannerBitmap - { - public: - virtual void Draw(); - } banner; - CMenuPicButton resumeGame; CMenuPicButton disconnect; - CMenuPicButton newGame; - CMenuPicButton hazardCourse; + CMenuPicButton createGame; CMenuPicButton configuration; - CMenuPicButton saveRestore; CMenuPicButton multiPlayer; - CMenuPicButton customGame; CMenuPicButton previews; CMenuPicButton quit; - // buttons on top right. Maybe should be drawn if fullscreen == 1? - CMenuBitmap minimizeBtn; - CMenuBitmap quitButton; - // quit dialog CMenuYesNoMessageBox dialog; - - bool bTrainMap; - bool bCustomGame; }; static CMenuMain uiMain; -void CMenuMain::CMenuMainBanner::Draw() -{ - if( !uiMain.background.ShouldDrawLogoMovie() ) - return; // no logos for steam background - - if( EngFuncs::GetLogoLength() <= 0.05f || EngFuncs::GetLogoWidth() <= 32 ) - return; // don't draw stub logo (GoldSrc rules) - - float logoWidth, logoHeight, logoPosY; - float scaleX, scaleY; - - scaleX = ScreenWidth / 640.0f; - scaleY = ScreenHeight / 480.0f; - - // a1ba: multiply by height scale to look better on widescreens - logoWidth = EngFuncs::GetLogoWidth() * scaleX; - logoHeight = EngFuncs::GetLogoHeight() * scaleY * uiStatic.scaleY; - logoPosY = 70 * scaleY * uiStatic.scaleY; // 70 it's empirically determined value (magic number) - - EngFuncs::DrawLogo( "logo.avi", 0, logoPosY, logoWidth, logoHeight ); -} - void CMenuMain::QuitDialog(void *pExtra) { if( CL_IsActive() && EngFuncs::GetCvarFloat( "host_serverstate" ) && EngFuncs::GetCvarFloat( "maxplayers" ) == 1.0f ) @@ -123,13 +83,6 @@ void CMenuMain::DisconnectDialogCb() dialog.Show(); } -void CMenuMain::HazardCourseDialogCb() -{ - dialog.onPositive = VoidCb( &CMenuMain::HazardCourseCb );; - dialog.SetMessage( MenuStrings[IDS_TRAINING_EXITCURRENT] ); - dialog.Show(); -} - /* ================= CMenuMain::Key @@ -171,48 +124,13 @@ const char *CMenuMain::Activate( void ) disconnect.Hide(); } - if( gpGlobals->developer ) - { - console.pos.y = CL_IsActive() ? 130 : 230; - } - CMenuPicButton::ClearButtonStack(); return 0; } -/* -================= -UI_Main_HazardCourse -================= -*/ -void CMenuMain::HazardCourseCb() -{ - if( EngFuncs::GetCvarFloat( "host_serverstate" ) && EngFuncs::GetCvarFloat( "maxplayers" ) > 1 ) - EngFuncs::HostEndGame( "end of the game" ); - - EngFuncs::CvarSetValue( "skill", 1.0f ); - EngFuncs::CvarSetValue( "deathmatch", 0.0f ); - EngFuncs::CvarSetValue( "teamplay", 0.0f ); - EngFuncs::CvarSetValue( "pausable", 1.0f ); // singleplayer is always allowing pause - EngFuncs::CvarSetValue( "coop", 0.0f ); - EngFuncs::CvarSetValue( "maxplayers", 1.0f ); // singleplayer - - EngFuncs::PlayBackgroundTrack( NULL, NULL ); - - EngFuncs::ClientCmd( FALSE, "hazardcourse\n" ); -} - void CMenuMain::_Init( void ) { - if( gMenu.m_gameinfo.trainmap[0] && stricmp( gMenu.m_gameinfo.trainmap, gMenu.m_gameinfo.startmap ) != 0 ) - bTrainMap = true; - else bTrainMap = false; - - if( EngFuncs::GetCvarFloat( "host_allow_changegame" )) - bCustomGame = true; - else bCustomGame = false; - // console console.SetNameAndStatus( "Console", "Show console" ); console.iFlags |= QMF_NOTIFY; @@ -223,6 +141,11 @@ void CMenuMain::_Init( void ) EngFuncs::KEY_SetDest( KEY_CONSOLE ); }); + createGame.SetNameAndStatus( "Create Game", MenuStrings[IDS_MAIN_RETURNHELP] ); + createGame.SetPicture( PC_CREATE_GAME ); + createGame.iFlags |= QMF_NOTIFY; + createGame.onActivated = UI_CreateGame_Menu; + resumeGame.SetNameAndStatus( "Resume Game", MenuStrings[IDS_MAIN_RETURNHELP] ); resumeGame.SetPicture( PC_RESUME_GAME ); resumeGame.iFlags |= QMF_NOTIFY; @@ -233,17 +156,6 @@ void CMenuMain::_Init( void ) disconnect.iFlags |= QMF_NOTIFY; disconnect.onActivated = VoidCb( &CMenuMain::DisconnectDialogCb ); - newGame.SetNameAndStatus( "New Game", MenuStrings[IDS_MAIN_NEWGAMEHELP] ); - newGame.SetPicture( PC_NEW_GAME ); - newGame.iFlags |= QMF_NOTIFY; - newGame.onActivated = UI_NewGame_Menu; - - hazardCourse.SetNameAndStatus( "Hazard Course", MenuStrings[IDS_MAIN_TRAININGHELP] ); - hazardCourse.SetPicture( PC_HAZARD_COURSE ); - hazardCourse.iFlags |= QMF_NOTIFY; - hazardCourse.onActivatedClActive = VoidCb( &CMenuMain::HazardCourseDialogCb ); - hazardCourse.onActivated = VoidCb( &CMenuMain::HazardCourseCb ); - multiPlayer.SetNameAndStatus( "Multiplayer", MenuStrings[IDS_MAIN_MULTIPLAYERHELP] ); multiPlayer.SetPicture( PC_MULTIPLAYER ); multiPlayer.iFlags |= QMF_NOTIFY; @@ -254,15 +166,6 @@ void CMenuMain::_Init( void ) configuration.iFlags |= QMF_NOTIFY; configuration.onActivated = UI_Options_Menu; - saveRestore.iFlags |= QMF_NOTIFY; - saveRestore.onActivatedClActive = UI_SaveLoad_Menu; - saveRestore.onActivated = UI_LoadGame_Menu; - - customGame.SetNameAndStatus( "Custom Game", MenuStrings[IDS_MAIN_CUSTOMHELP] ); - customGame.SetPicture( PC_CUSTOM_GAME ); - customGame.iFlags |= QMF_NOTIFY; - customGame.onActivated = UI_CustomGame_Menu; - previews.SetNameAndStatus( "Previews", MenuStrings[ IDS_MAIN_PREVIEWSHELP ] ); previews.SetPicture( PC_PREVIEWS ); previews.iFlags |= QMF_NOTIFY; @@ -273,62 +176,17 @@ void CMenuMain::_Init( void ) quit.iFlags |= QMF_NOTIFY; quit.onActivated = MenuCb( &CMenuMain::QuitDialog ); - quitButton.SetPicture( ART_CLOSEBTN_N, ART_CLOSEBTN_F, ART_CLOSEBTN_D ); - quitButton.iFlags = QMF_MOUSEONLY|QMF_ACT_ONRELEASE; - quitButton.eFocusAnimation = QM_HIGHLIGHTIFFOCUS; - quitButton.onActivated = MenuCb( &CMenuMain::QuitDialog ); - - minimizeBtn.SetPicture( ART_MINIMIZE_N, ART_MINIMIZE_F, ART_MINIMIZE_D ); - minimizeBtn.iFlags = QMF_MOUSEONLY|QMF_ACT_ONRELEASE; - minimizeBtn.eFocusAnimation = QM_HIGHLIGHTIFFOCUS; - minimizeBtn.onActivated.SetCommand( FALSE, "minimize\n" ); - - if ( gMenu.m_gameinfo.gamemode == GAME_MULTIPLAYER_ONLY || gMenu.m_gameinfo.startmap[0] == 0 ) - newGame.SetGrayed( true ); - - if ( gMenu.m_gameinfo.gamemode == GAME_SINGLEPLAYER_ONLY ) - multiPlayer.SetGrayed( true ); - - if ( gMenu.m_gameinfo.gamemode == GAME_MULTIPLAYER_ONLY ) - { - saveRestore.SetGrayed( true ); - hazardCourse.SetGrayed( true ); - } - - // server.dll needs for reading savefiles or startup newgame - if( !EngFuncs::CheckGameDll( )) - { - saveRestore.SetGrayed( true ); - hazardCourse.SetGrayed( true ); - newGame.SetGrayed( true ); - } - dialog.Link( this ); AddItem( background ); - AddItem( banner ); - - if ( gpGlobals->developer ) - AddItem( console ); - + if( gpGlobals->developer ) AddItem( console ); AddItem( disconnect ); AddItem( resumeGame ); - AddItem( newGame ); - - if ( bTrainMap ) - AddItem( hazardCourse ); - - AddItem( saveRestore ); - AddItem( configuration ); + AddItem( createGame ); AddItem( multiPlayer ); - - if ( bCustomGame ) - AddItem( customGame ); - + AddItem( configuration ); AddItem( previews ); AddItem( quit ); - AddItem( minimizeBtn ); - AddItem( quitButton ); } /* @@ -340,40 +198,21 @@ void CMenuMain::_VidInit( void ) { Activate(); - console.pos.x = 72; - resumeGame.SetCoord( 72, 230 ); - disconnect.SetCoord( 72, 180 ); - newGame.SetCoord( 72, 280 ); - hazardCourse.SetCoord( 72, 330 ); - - if( CL_IsActive( )) + if( CL_IsActive() ) { - saveRestore.SetNameAndStatus( "Save\\Load Game", MenuStrings[IDS_MAIN_LOADSAVEHELP] ); - saveRestore.SetPicture( PC_SAVE_LOAD_GAME ); + console.SetCoord( 72, 280 ); + resumeGame.SetCoord( 72, 330 ); + disconnect.SetCoord( 72, 380 ); } else { - saveRestore.SetNameAndStatus( "Load Game", MenuStrings[IDS_MAIN_LOADHELP] ); - saveRestore.SetPicture( PC_LOAD_GAME ); + console.SetCoord( 72, 380 ); } - - saveRestore.SetCoord( 72, bTrainMap ? 380 : 330 ); - configuration.SetCoord( 72, bTrainMap ? 430 : 380 ); - multiPlayer.SetCoord( 72, bTrainMap ? 480 : 430 ); - - customGame.SetCoord( 72, bTrainMap ? 530 : 480 ); - - previews.SetCoord( 72, (bCustomGame) ? (bTrainMap ? 580 : 530) : (bTrainMap ? 530 : 480) ); - - // too short execute string - not a real command - if( strlen( MenuStrings[IDS_MEDIA_PREVIEWURL] ) <= 3 ) - previews.SetGrayed( true ); - - quit.SetCoord( 72, (bCustomGame) ? (bTrainMap ? 630 : 580) : (bTrainMap ? 580 : 530)); - - minimizeBtn.SetRect( uiStatic.width - 72, 13, 32, 32 ); - - quitButton.SetRect( uiStatic.width - 36, 13, 32, 32 ); + createGame.SetCoord( 72, 430 ); + multiPlayer.SetCoord( 72, 480 ); + configuration.SetCoord( 72, 530 ); + previews.SetCoord( 72, 580 ); + quit.SetCoord( 72, 630 ); } /* @@ -383,15 +222,6 @@ UI_Main_Precache */ void UI_Main_Precache( void ) { - EngFuncs::PIC_Load( ART_MINIMIZE_N ); - EngFuncs::PIC_Load( ART_MINIMIZE_F ); - EngFuncs::PIC_Load( ART_MINIMIZE_D ); - EngFuncs::PIC_Load( ART_CLOSEBTN_N ); - EngFuncs::PIC_Load( ART_CLOSEBTN_F ); - EngFuncs::PIC_Load( ART_CLOSEBTN_D ); - - // precache .avi file and get logo width and height - EngFuncs::PrecacheLogo( "logo.avi" ); } /* From 7e9aa639e542db4c8e223bee11776718050a3aa4 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Fri, 20 Jul 2018 00:43:52 +0300 Subject: [PATCH 06/18] Remove useless code --- CMakeLists.txt | 5 - menus/Configuration.cpp | 2 + menus/CustomGame.cpp | 208 --------------------- menus/LoadGame.cpp | 404 ---------------------------------------- menus/Main.cpp | 2 +- menus/Multiplayer.cpp | 118 ------------ menus/NewGame.cpp | 137 -------------- menus/SaveLoad.cpp | 96 ---------- 8 files changed, 3 insertions(+), 969 deletions(-) delete mode 100644 menus/CustomGame.cpp delete mode 100644 menus/LoadGame.cpp delete mode 100644 menus/Multiplayer.cpp delete mode 100644 menus/NewGame.cpp delete mode 100644 menus/SaveLoad.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 49e8869f..ddaa0cbe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -72,17 +72,12 @@ set(MAINUI_MENUS_SOURCES menus/Controls.cpp menus/CreateGame.cpp menus/Credits.cpp - menus/CustomGame.cpp menus/FileDialog.cpp menus/GameOptions.cpp menus/Gamepad.cpp menus/InputDevices.cpp - menus/LoadGame.cpp menus/Main.cpp - menus/Multiplayer.cpp - menus/NewGame.cpp menus/PlayerSetup.cpp - menus/SaveLoad.cpp menus/ServerBrowser.cpp menus/TouchButtons.cpp menus/Touch.cpp diff --git a/menus/Configuration.cpp b/menus/Configuration.cpp index 2f759791..f76edb49 100644 --- a/menus/Configuration.cpp +++ b/menus/Configuration.cpp @@ -68,6 +68,8 @@ void CMenuOptions::_Init( void ) PC_TOUCH, UI_Touch_Menu, QMF_NOTIFY ); AddButton( "Gamepad", "Change gamepad axis and button settings", PC_GAMEPAD, UI_GamePad_Menu, QMF_NOTIFY ); + AddButton( "Multiplayer", "Choose your player name, crosshair size", + PC_MULTIPLAYER, UI_PlayerSetup_Menu, QMF_NOTIFY ); AddButton( "Update", "Check for updates", PC_UPDATE, msgBox.MakeOpenEvent(), QMF_NOTIFY ); AddButton( "Done", "Go back to the Main menu", diff --git a/menus/CustomGame.cpp b/menus/CustomGame.cpp deleted file mode 100644 index a8fcee98..00000000 --- a/menus/CustomGame.cpp +++ /dev/null @@ -1,208 +0,0 @@ -/* -Copyright (C) 1997-2001 Id Software, Inc. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -#include "Framework.h" -#include "Bitmap.h" -#include "PicButton.h" -#include "Action.h" -#include "Table.h" -#include "YesNoMessageBox.h" -#include "keydefs.h" - -#define ART_BANNER "gfx/shell/head_custom" - -#define MAX_MODS 512 // engine limit - -class CMenuModListModel : public CMenuBaseModel -{ -public: - void Update() override; - int GetColumns() const override { return 4; } - int GetRows() const override { return m_iNumItems; } - const char *GetCellText( int line, int column ) override - { - return modsDescription[line][column]; - } - - char modsDir[MAX_MODS][64]; - char modsWebSites[MAX_MODS][256]; - char modsDescription[MAX_MODS][5][32]; - - int m_iNumItems; -}; - -class CMenuCustomGame: public CMenuFramework -{ -public: - CMenuCustomGame() : CMenuFramework("CMenuCustomGame") { } - -private: - void ChangeGame( void *pExtra ); - void Go2Site( void *pExtra ); - void UpdateExtras( ); - virtual void _Init( ) override; - - CMenuPicButton *load; - CMenuPicButton *go2url; - - // prompt dialog - CMenuYesNoMessageBox msgBox; - - CMenuTable modList; - CMenuModListModel modListModel; -}; - -static CMenuCustomGame uiCustomGame; - -void CMenuCustomGame::ChangeGame( void *pExtra ) -{ - char cmd[128]; - sprintf( cmd, "game %s\n", (const char*)pExtra ); - EngFuncs::ClientCmd( FALSE, cmd ); -} - -void CMenuCustomGame::Go2Site( void *pExtra ) -{ - const char *url = (const char *)pExtra; - if( url[0] ) - EngFuncs::ShellExecute( url, NULL, false ); -} - -void CMenuCustomGame::UpdateExtras( ) -{ - int i = modList.GetCurrentIndex(); - - load->onActivated.pExtra = modListModel.modsDir[i]; - load->SetGrayed( !stricmp( modListModel.modsDir[i], gMenu.m_gameinfo.gamefolder ) ); - - go2url->onActivated.pExtra = modListModel.modsWebSites[i]; - go2url->SetGrayed( modListModel.modsWebSites[i][0] == 0 ); - - msgBox.onPositive.pExtra = modListModel.modsDir[i]; -} - -/* -================= -CMenuModListModel::Update -================= -*/ -void CMenuModListModel::Update( void ) -{ - int numGames, i; - GAMEINFO **games; - - games = EngFuncs::GetGamesList( &numGames ); - - for( i = 0; i < numGames; i++ ) - { - Q_strncpy( modsDir[i], games[i]->gamefolder, sizeof( modsDir[i] )); - Q_strncpy( modsWebSites[i], games[i]->game_url, sizeof( modsWebSites[i] )); - - Q_strncpy( modsDescription[i][0], games[i]->type, 32 ); - - if( ColorStrlen( games[i]->title ) > 31 ) // NAME_LENGTH - { - Q_strncpy( modsDescription[i][1], games[i]->title, 32 - 4 ); - // I am lazy to put strncat here :( - modsDescription[i][1][28] = modsDescription[i][1][29] = modsDescription[i][1][30] = '.'; - modsDescription[i][1][31] = 0; - } - else Q_strncpy( modsDescription[i][1], games[i]->title, 32 ); - - Q_strncpy( modsDescription[i][2], games[i]->version, 32 ); - - if( games[i]->size[0] && atoi( games[i]->size ) != 0 ) - Q_strncpy( modsDescription[i][3], games[i]->size, 32 ); - else Q_strncpy( modsDescription[i][3], "0.0 Mb", 32 ); - } - - m_iNumItems = numGames; -} - -/* -================= -UI_CustomGame_Init -================= -*/ -void CMenuCustomGame::_Init( void ) -{ - banner.SetPicture( ART_BANNER ); - - AddItem( background ); - AddItem( banner ); - load = AddButton( "Activate", "Activate selected custom game", PC_ACTIVATE, - MenuCb( &CMenuCustomGame::ChangeGame ) ); - load->onActivatedClActive = msgBox.MakeOpenEvent(); - - go2url = AddButton( "Visit web site", "Visit the web site of game developers", PC_VISIT_WEB_SITE, - MenuCb( &CMenuCustomGame::Go2Site ) ); - AddButton( "Done", "Return to main menu", PC_DONE, - VoidCb( &CMenuCustomGame::Hide ) ); - - modList.onChanged = VoidCb( &CMenuCustomGame::UpdateExtras ); - modList.SetupColumn( 0, "Type", 0.20f ); - modList.SetupColumn( 1, "Name", 0.50f ); - modList.SetupColumn( 2, "Ver", 0.15f ); - modList.SetupColumn( 3, "Size", 0.15f ); - modList.SetModel( &modListModel ); - modList.SetRect( 360, 230, -20, 465 ); - - msgBox.SetMessage( "Leave current game?" ); - msgBox.onPositive = MenuCb( &CMenuCustomGame::ChangeGame ); - msgBox.Link( this ); - - AddItem( modList ); - - for( int i = 0; i < modListModel.GetRows(); i++ ) - { - if( !stricmp( modListModel.modsDir[i], gMenu.m_gameinfo.gamefolder ) ) - { - modList.SetCurrentIndex( i ); - if( modList.onChanged ) - modList.onChanged( &modList ); - break; - } - } -} - -/* -================= -UI_CustomGame_Precache -================= -*/ -void UI_CustomGame_Precache( void ) -{ - EngFuncs::PIC_Load( ART_BANNER ); -} - -/* -================= -UI_CustomGame_Menu -================= -*/ -void UI_CustomGame_Menu( void ) -{ - // current instance is not support game change - if( !EngFuncs::GetCvarFloat( "host_allow_changegame" )) - return; - - uiCustomGame.Show(); -} -ADD_MENU( menu_customgame, UI_CustomGame_Precache, UI_CustomGame_Menu ); diff --git a/menus/LoadGame.cpp b/menus/LoadGame.cpp deleted file mode 100644 index c6313e1e..00000000 --- a/menus/LoadGame.cpp +++ /dev/null @@ -1,404 +0,0 @@ -/* -Copyright (C) 1997-2001 Id Software, Inc. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -#include "Framework.h" -#include "keydefs.h" -#include "Bitmap.h" -#include "PicButton.h" -#include "Table.h" -#include "Action.h" -#include "YesNoMessageBox.h" - -#define ART_BANNER_LOAD "gfx/shell/head_load" -#define ART_BANNER_SAVE "gfx/shell/head_save" - -#define LEVELSHOT_X 72 -#define LEVELSHOT_Y 400 -#define LEVELSHOT_W 192 -#define LEVELSHOT_H 160 - -#define MAX_CELLSTRING 64 - -class CMenuSavePreview : public CMenuBaseItem -{ -public: - CMenuSavePreview() : CMenuBaseItem() - { - iFlags = QMF_INACTIVE; - } - - void Draw() override; -}; - -class CMenuSavesListModel : public CMenuBaseModel -{ -public: - void Update() override; - int GetColumns() const override - { - // time, name, gametime - return 3; - } - int GetRows() const override - { - return m_iNumItems; - } - const char *GetCellText( int line, int column ) override - { - return m_szCells[line][column]; - } - unsigned int GetAlignmentForColumn(int column) const override - { - if( column == 2 ) - return QM_RIGHT; - return QM_LEFT; - } - void OnDeleteEntry( int line ) override; - - char saveName[UI_MAXGAMES][CS_SIZE]; - char delName[UI_MAXGAMES][CS_SIZE]; - -private: - char m_szCells[UI_MAXGAMES][3][MAX_CELLSTRING]; - int m_iNumItems; -}; - -static class CMenuLoadGame : public CMenuFramework -{ -public: - CMenuLoadGame() : CMenuFramework( "CMenuLoadGame" ) { } - - // true to turn this menu into save mode, false to turn into load mode - void SetSaveMode( bool saveMode ); - bool IsSaveMode() { return m_fSaveMode; } - void UpdateList() { savesListModel.Update(); } - -private: - void _Init( void ); - - void LoadGame(); - void SaveGame(); - void UpdateGame(); - void DeleteGame(); - - CMenuPicButton load; - CMenuPicButton save; - CMenuPicButton remove; - CMenuPicButton cancel; - - CMenuTable savesList; - - CMenuSavePreview levelShot; - bool m_fSaveMode; - char hintText[MAX_HINT_TEXT]; - - // prompt dialog - CMenuYesNoMessageBox msgBox; - CMenuSavesListModel savesListModel; - - friend class CMenuSavesListModel; -} uiLoadGame; - -void CMenuSavePreview::Draw() -{ - const char *fallback = "{GRAF001"; - - if( szName && *szName ) - { - char saveshot[128]; - - snprintf( saveshot, sizeof( saveshot ), - "save/%s.bmp", szName ); - - if( EngFuncs::FileExists( saveshot )) - UI_DrawPic( m_scPos, m_scSize, uiColorWhite, saveshot ); - else - UI_DrawPicAdditive( m_scPos, m_scSize, uiColorWhite, fallback ); - } - else - UI_DrawPicAdditive( m_scPos, m_scSize, uiColorWhite, fallback ); - - // draw the rectangle - UI_DrawRectangle( m_scPos, m_scSize, uiInputFgColor ); -} - -/* -================= -CMenuSavesListModel::Update -================= -*/ -void CMenuSavesListModel::Update( void ) -{ - char comment[256]; - char **filenames; - int i = 0, j, numFiles; - - filenames = EngFuncs::GetFilesList( "save/*.sav", &numFiles, TRUE ); - - // sort the saves in reverse order (oldest past at the end) - qsort( filenames, numFiles, sizeof( char* ), (cmpfunc)COM_CompareSaves ); - - if ( uiLoadGame.IsSaveMode() && CL_IsActive() ) - { - // create new entry for current save game - Q_strncpy( saveName[i], "new", CS_SIZE ); - Q_strncpy( delName[i], "", CS_SIZE ); - strcpy( m_szCells[i][0], "Current" ); - strcpy( m_szCells[i][1], "New Saved Game" ); - strcpy( m_szCells[i][2], "New" ); - i++; - } - - for ( j = 0; j < numFiles; i++, j++ ) - { - if( i >= UI_MAXGAMES ) break; - - if( !EngFuncs::GetSaveComment( filenames[j], comment )) - { - if( comment[0] ) - { - // get name string even if not found - SV_GetComment can be mark saves - // as etc - Q_strncpy( m_szCells[i][0], comment, MAX_CELLSTRING ); - m_szCells[i][1][0] = 0; - m_szCells[i][2][0] = 0; - COM_FileBase( filenames[j], saveName[i] ); - COM_FileBase( filenames[j], delName[i] ); - } - continue; - } - - // strip path, leave only filename (empty slots doesn't have savename) - COM_FileBase( filenames[j], saveName[i] ); - COM_FileBase( filenames[j], delName[i] ); - - // fill save desc - snprintf( m_szCells[i][0], MAX_CELLSTRING, "%s %s", comment + CS_SIZE, comment + CS_SIZE + CS_TIME ); - Q_strncpy( m_szCells[i][1], comment, MAX_CELLSTRING ); - Q_strncpy( m_szCells[i][2], comment + CS_SIZE + (CS_TIME * 2), MAX_CELLSTRING ); - } - - m_iNumItems = i; - - if ( saveName[0][0] == 0 ) - { - uiLoadGame.load.SetGrayed( true ); - } - else - { - uiLoadGame.levelShot.szName = saveName[0]; - uiLoadGame.load.SetGrayed( false ); - } - - if ( saveName[0][0] == 0 || !CL_IsActive() ) - uiLoadGame.save.SetGrayed( true ); - else uiLoadGame.save.SetGrayed( false ); - - if ( delName[0][0] == 0 ) - uiLoadGame.remove.SetGrayed( true ); - else uiLoadGame.remove.SetGrayed( false ); -} - -void CMenuSavesListModel::OnDeleteEntry(int line) -{ - uiLoadGame.msgBox.Show(); -} - -/* -================= -UI_LoadGame_Init -================= -*/ -void CMenuLoadGame::_Init( void ) -{ - save.SetNameAndStatus( "Save", "Save curret game" ); - save.SetPicture( PC_SAVE_GAME ); - save.onActivated = VoidCb( &CMenuLoadGame::SaveGame ); - save.SetCoord( 72, 230 ); - - load.SetNameAndStatus( "Load", "Load saved game" ); - load.SetPicture( PC_LOAD_GAME ); - load.onActivated = VoidCb( &CMenuLoadGame::LoadGame ); - load.SetCoord( 72, 230 ); - - remove.SetNameAndStatus( "Delete", "Delete saved game" ); - remove.SetPicture( PC_DELETE ); - remove.onActivated = msgBox.MakeOpenEvent(); - remove.SetCoord( 72, 280 ); - - cancel.SetNameAndStatus( "Cancel", "Return back to main menu" ); - cancel.SetPicture( PC_CANCEL ); - cancel.onActivated = VoidCb( &CMenuLoadGame::Hide ); - cancel.SetCoord( 72, 330 ); - - savesList.szName = hintText; - savesList.onChanged = VoidCb( &CMenuLoadGame::UpdateGame ); - // savesList.onDeleteEntry = msgBox.MakeOpenEvent(); - savesList.SetupColumn( 0, "Time", 0.30f ); - savesList.SetupColumn( 1, "Game", 0.55f ); - savesList.SetupColumn( 2, "Elapsed Time", 0.15f ); - - savesList.SetModel( &savesListModel ); - savesList.SetCharSize( QM_SMALLFONT ); - savesList.SetRect( 360, 230, -20, 465 ); - - msgBox.SetMessage( "Delete this save?" ); - msgBox.onPositive = VoidCb( &CMenuLoadGame::DeleteGame ); - msgBox.Link( this ); - - levelShot.SetRect( LEVELSHOT_X, LEVELSHOT_Y, LEVELSHOT_W, LEVELSHOT_H ); - - AddItem( background ); - AddItem( banner ); - AddItem( load ); - AddItem( save ); - AddItem( remove ); - AddItem( cancel ); - AddItem( levelShot ); - AddItem( savesList ); -} - -void CMenuLoadGame::LoadGame() -{ - const char *saveName = savesListModel.saveName[savesList.GetCurrentIndex()]; - if( saveName[0] ) - { - char cmd[128]; - sprintf( cmd, "load \"%s\"\n", saveName ); - - EngFuncs::StopBackgroundTrack( ); - - EngFuncs::ClientCmd( FALSE, cmd ); - - UI_CloseMenu(); - } -} - -void CMenuLoadGame::SaveGame() -{ - const char *saveName = savesListModel.saveName[savesList.GetCurrentIndex()]; - if( saveName[0] ) - { - char cmd[128]; - - sprintf( cmd, "save/%s.bmp", saveName ); - EngFuncs::PIC_Free( cmd ); - - sprintf( cmd, "save \"%s\"\n", saveName ); - EngFuncs::ClientCmd( FALSE, cmd ); - - UI_CloseMenu(); - } -} - -void CMenuLoadGame::UpdateGame() -{ - // first item is for creating new saves - if( IsSaveMode() && savesList.GetCurrentIndex() == 0 ) - { - remove.SetGrayed( true ); - levelShot.szName = NULL; - } - else - { - remove.SetGrayed( false ); - levelShot.szName = savesListModel.saveName[savesList.GetCurrentIndex()]; - } -} - -void CMenuLoadGame::DeleteGame() -{ - const char *delName = savesListModel.delName[savesList.GetCurrentIndex()]; - - if( delName[0] ) - { - char cmd[128]; - sprintf( cmd, "killsave \"%s\"\n", delName ); - - EngFuncs::ClientCmd( TRUE, cmd ); - - sprintf( cmd, "save/%s.bmp", delName ); - EngFuncs::PIC_Free( cmd ); - - savesListModel.Update(); - } -} - -void CMenuLoadGame::SetSaveMode(bool saveMode) -{ - m_fSaveMode = saveMode; - if( saveMode ) - { - banner.SetPicture( ART_BANNER_SAVE ); - save.SetVisibility( true ); - load.SetVisibility( false ); - szName = "CMenuSaveGame"; - } - else - { - banner.SetPicture( ART_BANNER_LOAD ); - save.SetVisibility( false ); - load.SetVisibility( true ); - szName = "CMenuLoadGame"; - } -} - -/* -================= -UI_LoadGame_Precache -================= -*/ -void UI_LoadGame_Precache( void ) -{ - EngFuncs::PIC_Load( ART_BANNER_SAVE ); - EngFuncs::PIC_Load( ART_BANNER_LOAD ); -} - -void UI_LoadSaveGame_Menu( bool saveMode ) -{ - if( gMenu.m_gameinfo.gamemode == GAME_MULTIPLAYER_ONLY ) - { - // completely ignore save\load menus for multiplayer_only - return; - } - - if( !EngFuncs::CheckGameDll( )) return; - - uiLoadGame.Show(); - uiLoadGame.SetSaveMode( saveMode ); - uiLoadGame.UpdateList(); -} - -/* -================= -UI_LoadGame_Menu -================= -*/ -void UI_LoadGame_Menu( void ) -{ - UI_LoadSaveGame_Menu( false ); -} - -void UI_SaveGame_Menu( void ) -{ - UI_LoadSaveGame_Menu( true ); -} -ADD_MENU( menu_loadgame, UI_LoadGame_Precache, UI_LoadGame_Menu ); -ADD_MENU( menu_savegame, NULL, UI_SaveGame_Menu ); diff --git a/menus/Main.cpp b/menus/Main.cpp index 108767b9..c331c107 100644 --- a/menus/Main.cpp +++ b/menus/Main.cpp @@ -159,7 +159,7 @@ void CMenuMain::_Init( void ) multiPlayer.SetNameAndStatus( "Multiplayer", MenuStrings[IDS_MAIN_MULTIPLAYERHELP] ); multiPlayer.SetPicture( PC_MULTIPLAYER ); multiPlayer.iFlags |= QMF_NOTIFY; - multiPlayer.onActivated = UI_MultiPlayer_Menu; + multiPlayer.onActivated = UI_ServerBrowser_Menu; configuration.SetNameAndStatus( "Configuration", MenuStrings[IDS_MAIN_CONFIGUREHELP] ); configuration.SetPicture( PC_CONFIG ); diff --git a/menus/Multiplayer.cpp b/menus/Multiplayer.cpp deleted file mode 100644 index 6cbbc28f..00000000 --- a/menus/Multiplayer.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/* -Copyright (C) 1997-2001 Id Software, Inc. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -#include "Framework.h" -#include "Bitmap.h" -#include "YesNoMessageBox.h" -#include "keydefs.h" -#include "PlayerIntroduceDialog.h" - -#define ART_BANNER "gfx/shell/head_multi" - -class CMenuMultiplayer : public CMenuFramework -{ -public: - CMenuMultiplayer() : CMenuFramework( "CMenuMultiplayer" ) { } - - void AskPredictEnable() { msgBox.Show(); } - -private: - void _Init() override; - - // prompt dialog - CMenuYesNoMessageBox msgBox; -}; - -static CMenuMultiplayer uiMultiPlayer; - - -/* -================= -CMenuMultiplayer::Init -================= -*/ -void CMenuMultiplayer::_Init( void ) -{ - // memset( &uiMultiPlayer, 0, sizeof( CMenuMultiplayer )); - AddItem( background ); - - banner.SetPicture( ART_BANNER ); - AddItem( banner ); - - AddButton( "Internet game", "View list of a game internet servers and join the one of your choice", PC_INET_GAME, UI_InternetGames_Menu, QMF_NOTIFY ); - // AddButton( "Spectate game", "Spectate internet games", PC_SPECTATE_GAMES, NoopCb, QMF_GRAYED | QMF_NOTIFY ); - AddButton( "LAN game", "Set up the game on the local area network", PC_LAN_GAME, UI_LanGame_Menu, QMF_NOTIFY ); - AddButton( "Customize", "Choose your player name, and select visual options for your character", PC_CUSTOMIZE, UI_PlayerSetup_Menu, QMF_NOTIFY ); - AddButton( "Controls", "Change keyboard and mouse settings", PC_CONTROLS, UI_Controls_Menu, QMF_NOTIFY ); - AddButton( "Done", "Go back to the Main menu", PC_DONE, VoidCb( &CMenuMultiplayer::Hide ), QMF_NOTIFY ); - - msgBox.SetMessage( "It is recomended to enable client movement prediction.\nPress OK to enable it now or enable it later in ^5(Multiplayer/Customize)"); - msgBox.SetPositiveButton( "Ok", PC_OK ); - msgBox.SetNegativeButton( "Cancel", PC_CANCEL ); - msgBox.HighlightChoice( CMenuYesNoMessageBox::HIGHLIGHT_YES ); - SET_EVENT_MULTI( msgBox.onPositive, - { - EngFuncs::CvarSetValue( "cl_predict", 1.0f ); - EngFuncs::CvarSetValue( "menu_mp_firsttime", 0.0f ); - - UI_PlayerIntroduceDialog_Show( &uiMultiPlayer ); - }); - SET_EVENT_MULTI( msgBox.onNegative, - { - EngFuncs::CvarSetValue( "menu_mp_firsttime", 0.0f ); - - UI_PlayerIntroduceDialog_Show( &uiMultiPlayer ); - }); - msgBox.Link( this ); - -} - -/* -================= -CMenuMultiplayer::Precache -================= -*/ -void UI_MultiPlayer_Precache( void ) -{ - EngFuncs::PIC_Load( ART_BANNER ); -} - -/* -================= -UI_MultiPlayer_Menu -================= -*/ -void UI_MultiPlayer_Menu( void ) -{ - if ( gMenu.m_gameinfo.gamemode == GAME_SINGLEPLAYER_ONLY ) - return; - - uiMultiPlayer.Show(); - - if( EngFuncs::GetCvarFloat( "menu_mp_firsttime" ) && !EngFuncs::GetCvarFloat( "cl_predict" ) ) - { - uiMultiPlayer.AskPredictEnable(); - } - else if( !UI::Names::CheckIsNameValid( EngFuncs::GetCvarString( "name" ) ) ) - { - UI_PlayerIntroduceDialog_Show( &uiMultiPlayer ); - } -} -ADD_MENU( menu_multiplayer, UI_MultiPlayer_Precache, UI_MultiPlayer_Menu ); diff --git a/menus/NewGame.cpp b/menus/NewGame.cpp deleted file mode 100644 index 22884a30..00000000 --- a/menus/NewGame.cpp +++ /dev/null @@ -1,137 +0,0 @@ -/* -Copyright (C) 1997-2001 Id Software, Inc. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -#include "Framework.h" -#include "Bitmap.h" -#include "PicButton.h" -#include "YesNoMessageBox.h" -#include "keydefs.h" -#include "MenuStrings.h" - -#define ART_BANNER "gfx/shell/head_newgame" - -class CMenuNewGame : public CMenuFramework -{ -public: - CMenuNewGame() : CMenuFramework( "CMenuNewGame" ) { } - static void StartGameCb( float skill ); -private: - void _Init() override; - - static void ShowDialogCb( CMenuBaseItem *pSelf, void *pExtra ); - - CMenuYesNoMessageBox msgBox; - - CEventCallback easyCallback; - CEventCallback normCallback; - CEventCallback hardCallback; -}; - -static CMenuNewGame uiNewGame; - -/* -================= -CMenuNewGame::StartGame -================= -*/ -void CMenuNewGame::StartGameCb( float skill ) -{ - if( EngFuncs::GetCvarFloat( "host_serverstate" ) && EngFuncs::GetCvarFloat( "maxplayers" ) > 1 ) - EngFuncs::HostEndGame( "end of the game" ); - - EngFuncs::CvarSetValue( "skill", skill ); - EngFuncs::CvarSetValue( "deathmatch", 0.0f ); - EngFuncs::CvarSetValue( "teamplay", 0.0f ); - EngFuncs::CvarSetValue( "pausable", 1.0f ); // singleplayer is always allowing pause - EngFuncs::CvarSetValue( "maxplayers", 1.0f ); - EngFuncs::CvarSetValue( "coop", 0.0f ); - - EngFuncs::PlayBackgroundTrack( NULL, NULL ); - - EngFuncs::ClientCmd( FALSE, "newgame\n" ); -} - -void CMenuNewGame::ShowDialogCb( CMenuBaseItem *pSelf, void *pExtra ) -{ - CMenuNewGame *ui = (CMenuNewGame*)pSelf->Parent(); - - ui->msgBox.onPositive = *(CEventCallback*)pExtra; - ui->msgBox.Show(); -} - -/* -================= -CMenuNewGame::Init -================= -*/ -void CMenuNewGame::_Init( void ) -{ - AddItem( background ); - AddItem( banner ); - - banner.SetPicture( ART_BANNER ); - - SET_EVENT( easyCallback, CMenuNewGame::StartGameCb( 1.0f ) ); - SET_EVENT( normCallback, CMenuNewGame::StartGameCb( 2.0f ) ); - SET_EVENT( hardCallback, CMenuNewGame::StartGameCb( 3.0f ) ); - - CMenuPicButton *easy = AddButton( "Easy", MenuStrings[IDS_NEWGAME_EASYHELP], PC_EASY, easyCallback, QMF_NOTIFY ); - CMenuPicButton *norm = AddButton( "Medium", MenuStrings[IDS_NEWGAME_MEDIUMHELP], PC_MEDIUM, normCallback, QMF_NOTIFY ); - CMenuPicButton *hard = AddButton( "Difficult", MenuStrings[IDS_NEWGAME_DIFFICULTHELP], PC_DIFFICULT, hardCallback, QMF_NOTIFY ); - - easy->onActivatedClActive = - norm->onActivatedClActive = - hard->onActivatedClActive = ShowDialogCb; - easy->onActivatedClActive.pExtra = &easyCallback; - norm->onActivatedClActive.pExtra = &normCallback; - hard->onActivatedClActive.pExtra = &hardCallback; - - AddButton( "Cancel", "Go back to the main menu", PC_CANCEL, VoidCb( &CMenuNewGame::Hide ), QMF_NOTIFY ); - - msgBox.SetMessage( MenuStrings[IDS_NEWGAME_NEWPROMPT] ); - msgBox.HighlightChoice( CMenuYesNoMessageBox::HIGHLIGHT_NO ); - msgBox.Link( this ); - -} - -/* -================= -UI_NewGame_Precache -================= -*/ -void UI_NewGame_Precache( void ) -{ - EngFuncs::PIC_Load( ART_BANNER ); -} - -/* -================= -UI_NewGame_Menu -================= -*/ -void UI_NewGame_Menu( void ) -{ - // completely ignore save\load menus for multiplayer_only - if( gMenu.m_gameinfo.gamemode == GAME_MULTIPLAYER_ONLY || !EngFuncs::CheckGameDll() ) - return; - - uiNewGame.Show(); -} -ADD_MENU( menu_newgame, UI_NewGame_Precache, UI_NewGame_Menu ); diff --git a/menus/SaveLoad.cpp b/menus/SaveLoad.cpp deleted file mode 100644 index eb80bddf..00000000 --- a/menus/SaveLoad.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/* -Copyright (C) 1997-2001 Id Software, Inc. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -#include "Framework.h" -#include "Bitmap.h" -#include "PicButton.h" -#include "Action.h" - -#define ART_BANNER "gfx/shell/head_saveload" - -class CMenuSaveLoad : public CMenuFramework -{ -public: - CMenuSaveLoad() : CMenuFramework( "CMenuSaveLoad" ) { } -private: - void _Init(); - - CMenuAction hintMessage; - char hintText[MAX_HINT_TEXT]; -}; - -static CMenuSaveLoad uiSaveLoad; - - -/* -================= -UI_SaveLoad_Init -================= -*/ -void CMenuSaveLoad::_Init( void ) -{ - strcat( hintText, "During play, you can quickly save your game by pressing " ); - strcat( hintText, EngFuncs::KeynumToString( KEY_GetKey( "save quick" ))); - strcat( hintText, ".\nLoad this game again by pressing " ); - strcat( hintText, EngFuncs::KeynumToString( KEY_GetKey( "load quick" ))); - strcat( hintText, ".\n" ); - - banner.SetPicture(ART_BANNER ); - - hintMessage.iFlags = QMF_INACTIVE; - hintMessage.iColor = uiColorHelp; - hintMessage.SetCharSize( QM_SMALLFONT ); - hintMessage.szName = hintText; - hintMessage.SetCoord( 360, 480 ); - - AddItem( background ); - AddItem( banner ); - AddButton( "Load game", "Load a previously saved game", PC_LOAD_GAME, UI_LoadGame_Menu, QMF_NOTIFY ); - AddButton( "Save game", "Save current game", PC_SAVE_GAME, UI_SaveGame_Menu, QMF_NOTIFY ); - AddButton( "Done", "Go back to the Main menu", PC_DONE, VoidCb( &CMenuSaveLoad::Hide ), QMF_NOTIFY ); - AddItem( hintMessage ); -} - -/* -================= -UI_SaveLoad_Precache -================= -*/ -void UI_SaveLoad_Precache( void ) -{ - EngFuncs::PIC_Load( ART_BANNER ); -} - -/* -================= -UI_SaveLoad_Menu -================= -*/ -void UI_SaveLoad_Menu( void ) -{ - if( gMenu.m_gameinfo.gamemode == GAME_MULTIPLAYER_ONLY ) - { - // completely ignore save\load menus for multiplayer_only - return; - } - - uiSaveLoad.Show(); -} -ADD_MENU( menu_saveload, UI_SaveLoad_Precache, UI_SaveLoad_Menu ); From 1e7f3d35faa1f79fa23d2c0a170506d6129cbac0 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Mon, 30 Jul 2018 21:43:16 +0300 Subject: [PATCH 07/18] Disable banners --- controls/Bitmap.cpp | 35 ++++------------------------------- controls/PicButton.cpp | 12 ++++++++++++ controls/PicButton.h | 1 + 3 files changed, 17 insertions(+), 31 deletions(-) diff --git a/controls/Bitmap.cpp b/controls/Bitmap.cpp index b84db79f..e029aef1 100644 --- a/controls/Bitmap.cpp +++ b/controls/Bitmap.cpp @@ -149,44 +149,17 @@ void CMenuBitmap::Draw( void ) void CMenuBannerBitmap::Draw() { - // don't draw banners until transition is done -#ifdef TA_ALT_MODE - return; -#endif - CMenuBaseWindow *window = NULL; - - if( m_pParent->IsWindow() ) - window = (CMenuBaseWindow*) m_pParent; + const char *text = CMenuPicButton::GetLastButtonText(); - if( CMenuPicButton::GetTitleTransFraction() < 1.0f ) + if( !text ) return; - if( window && window->IsRoot() && window->bInTransition && - window->eTransitionType == CMenuBaseWindow::ANIM_OUT ) - return; + UI_DrawString( uiStatic.hBigFont, m_scPos, m_scSize, text, uiPromptTextColor, m_scChSize, QM_LEFT, ETF_SHADOW | ETF_NOSIZELIMIT ); - BaseClass::Draw(); + return; } void CMenuBannerBitmap::VidInit() { BaseClass::VidInit(); - if( !szPic ) - return; - - HIMAGE hPic = EngFuncs::PIC_Load( szPic ); - - if( !hPic ) - return; - - Size sz = EngFuncs::PIC_Size( hPic ); - float factor = (float)m_scSize.h / (float)sz.h; - m_scSize.w = sz.w * factor; - - // CMenuPicButton::SetTitleAnim( CMenuPicButton::AS_TO_TITLE ); - CMenuPicButton::SetupTitleQuadForLast( uiStatic.xOffset + pos.x, uiStatic.yOffset + pos.y, m_scSize.w, m_scSize.h ); -#if defined(TA_ALT_MODE2) && !defined(TA_ALT_MODE) - CMenuPicButton::SetTransPicForLast( EngFuncs::PIC_Load( szPic ) ); -#endif - } diff --git a/controls/PicButton.cpp b/controls/PicButton.cpp index 91693cb9..6e1c591e 100644 --- a/controls/PicButton.cpp +++ b/controls/PicButton.cpp @@ -335,6 +335,18 @@ void CMenuPicButton::PopPButtonStack() } } +const char *CMenuPicButton::GetLastButtonText() +{ + if( ButtonStackDepth ) + { + if( ButtonStack[ButtonStackDepth-1] ) + { + return ButtonStack[ButtonStackDepth-1]->szName; + } + } + return NULL; +} + // Opened new menu, awaiting Quad from Banner void CMenuPicButton::PushPButtonStack() { diff --git a/controls/PicButton.h b/controls/PicButton.h index a926d1db..1230fd65 100644 --- a/controls/PicButton.h +++ b/controls/PicButton.h @@ -70,6 +70,7 @@ class CMenuPicButton : public CMenuBaseItem void TACheckMenuDepth( void ); void PushPButtonStack( void ); static void PopPButtonStack( void ); + static const char *GetLastButtonText( void ); void DrawButton( int r, int g, int b, int a, wrect_t *rects, int state ); From 01df71eb8e7445180c2cdc195f06f80eb4347d81 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Mon, 30 Jul 2018 21:47:49 +0300 Subject: [PATCH 08/18] Customize menu --- Utils.h | 3 +- menus/Main.cpp | 14 +++++++-- menus/ServerBrowser.cpp | 2 +- udll_int.cpp | 64 +++++++++++++++++++++++++++++++++++------ 4 files changed, 71 insertions(+), 12 deletions(-) diff --git a/Utils.h b/Utils.h index ebc3756b..42744b7a 100644 --- a/Utils.h +++ b/Utils.h @@ -44,7 +44,8 @@ void DBG_AssertFunction( bool fExpr, const char* szExpr, const char* szFile, int #define ASSERTSZ( f, sz ) #endif -extern ui_globalvars_t *gpGlobals; +extern ui_globalvars_t *gpGlobals_menu; +#define gpGlobals gpGlobals_menu // exports extern int UI_VidInit( void ); diff --git a/menus/Main.cpp b/menus/Main.cpp index c331c107..a62b7f36 100644 --- a/menus/Main.cpp +++ b/menus/Main.cpp @@ -27,6 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "keydefs.h" #include "MenuStrings.h" #include "PlayerIntroduceDialog.h" +#include "Switch.h" #define ART_MINIMIZE_N "gfx/shell/min_n" #define ART_MINIMIZE_F "gfx/shell/min_f" @@ -58,6 +59,7 @@ class CMenuMain: public CMenuFramework CMenuPicButton multiPlayer; CMenuPicButton previews; CMenuPicButton quit; + CMenuSwitch renderworld; // quit dialog CMenuYesNoMessageBox dialog; @@ -176,6 +178,15 @@ void CMenuMain::_Init( void ) quit.iFlags |= QMF_NOTIFY; quit.onActivated = MenuCb( &CMenuMain::QuitDialog ); + renderworld.bKeepToggleWidth = true; + renderworld.bUpdateImmediately = true; + renderworld.szName = ""; + renderworld.AddSwitch( "O" ); + renderworld.AddSwitch( "I" ); + renderworld.LinkCvar( "ui_renderworld" ); + renderworld.SetSize( renderworld.size.w * 0.75f, renderworld.size.h ); + renderworld.SetCoord( -renderworld.size.w - renderworld.size.h, renderworld.size.h ); + dialog.Link( this ); AddItem( background ); @@ -187,6 +198,7 @@ void CMenuMain::_Init( void ) AddItem( configuration ); AddItem( previews ); AddItem( quit ); + AddItem( renderworld ); } /* @@ -196,8 +208,6 @@ UI_Main_Init */ void CMenuMain::_VidInit( void ) { - Activate(); - if( CL_IsActive() ) { console.SetCoord( 72, 280 ); diff --git a/menus/ServerBrowser.cpp b/menus/ServerBrowser.cpp index ba9d87d8..ac4e996b 100644 --- a/menus/ServerBrowser.cpp +++ b/menus/ServerBrowser.cpp @@ -441,7 +441,7 @@ void CMenuServerBrowser::_Init( void ) natOrDirect.bKeepToggleWidth = true; natOrDirect.size.w = 400; - natOrDirect.SetCoord( -20 - natOrDirect.size.w, 255 - gameList.charSize.h * 1.5 - UI_OUTLINE_WIDTH * 2 - natOrDirect.size.h ); + natOrDirect.SetCoord( -20 - natOrDirect.size.w, 255 - gameList.charSize * 1.5 - UI_OUTLINE_WIDTH * 2 - natOrDirect.size.h ); natOrDirect.AddSwitch("Direct"); natOrDirect.AddSwitch("NAT"); natOrDirect.AddSwitch("LAN"); diff --git a/udll_int.cpp b/udll_int.cpp index 940d04c7..60070b0a 100644 --- a/udll_int.cpp +++ b/udll_int.cpp @@ -83,7 +83,7 @@ extern "C" EXPORT int GiveTextAPI( ui_textfuncs_t* pTextfuncsFromEngine ) } #endif -class CGameMenuExports : public IGameMenuExports +static class CGameMenuExports : public IGameMenuExports { public: bool Initialize( CreateInterfaceFn factory ) @@ -93,21 +93,69 @@ class CGameMenuExports : public IGameMenuExports return g_pClient ? true : false; } - int HudFontHeight(float scale) + bool IsActive() { - return g_FontMgr.GetFontTall( uiStatic.hSmallFont ) * scale; + return UI_IsVisible(); } - int HudCharacterWidth(int num, float scale) + void Key( int key, int down ) { - return g_FontMgr.GetCharacterWidthScaled( uiStatic.hSmallFont, num, UI_SMALL_CHAR_HEIGHT * scale ); + UI_KeyEvent( key, down ); } - int HudDrawCharacter(int x, int y, int num, int r, int g, int b, float scale) + void MouseMove( int x, int y ) + { + UI_MouseMove( x, y ); + } + + HFont BuildFont( CFontBuilder &builder ) + { + return builder.Create(); + } + + void GetCharABCWide( HFont font, int ch, int &a, int &b, int &c ) + { + g_FontMgr.GetCharABCWide( font, ch, a, b, c ); + } + + int GetFontTall( HFont font ) + { + return g_FontMgr.GetFontTall( font ); + } + + int GetCharacterWidth(HFont font, int ch, int charH ) + { + return g_FontMgr.GetCharacterWidthScaled( font, ch, charH ); + } + + void GetTextSize( HFont font, const char *text, int *wide, int *height = 0, int size = -1 ) + { + g_FontMgr.GetTextSize( font, text, wide, height, size ); + } + + int GetTextHeight( HFont font, const char *text, int size = -1 ) + { + return g_FontMgr.GetTextHeight( font, text, size ); + } + + int DrawCharacter( HFont font, int ch, int x, int y, int charH, const unsigned int color, bool forceAdditive = false ) + { + return g_FontMgr.DrawCharacter( font, ch, Point( x, y ), charH, color, forceAdditive ); + } + + void DrawScoreboard( void ) + { + + } + + void DrawSpectatorMenu( void ) + { + + } + + void ShowVGUIMenu( int ) { - int color = PackRGBA( r, g, b, 255 ); - return g_FontMgr.DrawCharacter( uiStatic.hSmallFont, num, Point( x, y ), Size( 0, UI_SMALL_CHAR_HEIGHT * scale ), color ); } } s_Menu; From 360e8a29f32c6206456351d089023acc928771a1 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Mon, 30 Jul 2018 21:48:31 +0300 Subject: [PATCH 09/18] Show renderworld only when active --- menus/Main.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/menus/Main.cpp b/menus/Main.cpp index a62b7f36..53db9fb4 100644 --- a/menus/Main.cpp +++ b/menus/Main.cpp @@ -119,11 +119,13 @@ const char *CMenuMain::Activate( void ) { resumeGame.Show(); disconnect.Show(); + renderworld.Show(); } else { resumeGame.Hide(); disconnect.Hide(); + renderworld.Hide(); } CMenuPicButton::ClearButtonStack(); From 6470f8b1d8e4577ffc62d682ecd0943447dd9054 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Thu, 20 Sep 2018 21:16:24 +0300 Subject: [PATCH 10/18] Update interface --- udll_int.cpp | 66 +++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 47 insertions(+), 19 deletions(-) diff --git a/udll_int.cpp b/udll_int.cpp index 60070b0a..e802be79 100644 --- a/udll_int.cpp +++ b/udll_int.cpp @@ -18,6 +18,7 @@ GNU General Public License for more details. #include "BaseMenu.h" #include "Utils.h" #include "cl_dll/IGameClientExports.h" +#include "Scoreboard.h" ui_enginefuncs_t EngFuncs::engfuncs; #ifndef XASH_DISABLE_FWGS_EXTENSIONS @@ -83,79 +84,106 @@ extern "C" EXPORT int GiveTextAPI( ui_textfuncs_t* pTextfuncsFromEngine ) } #endif +void UI_JoinGame_Show( int param1, int param2 ); +void UI_JoinClassT_Show( int param1, int param2 ); +void UI_JoinClassCT_Show( int param1, int param2 ); +void UI_BuyMenu_Show( int param1, int param2 ); +void UI_BuyMenu_Pistol_Show( int param1, int param2 ); +void UI_BuyMenu_Shotgun_Show( int param1, int param2 ); +void UI_BuyMenu_Submachine_Show( int param1, int param2 ); +void UI_BuyMenu_Rifle_Show( int param1, int param2 ); +void UI_BuyMenu_Machinegun_Show( int param1, int param2 ); +void UI_BuyMenu_Item_Show( int param1, int param2 ); + static class CGameMenuExports : public IGameMenuExports { public: - bool Initialize( CreateInterfaceFn factory ) + bool Initialize( CreateInterfaceFn factory ) override { g_pClient = (IGameClientExports*)factory( GAMECLIENTEXPORTS_INTERFACE_VERSION, NULL ); return g_pClient ? true : false; } - bool IsActive() + bool IsActive() override + { + return uiStatic.client.IsActive() && !uiStatic.menu.IsActive(); + } + + bool IsMainMenuActive() override { - return UI_IsVisible(); + return uiStatic.menu.IsActive(); } - void Key( int key, int down ) + void Key( int key, int down ) override { - UI_KeyEvent( key, down ); + uiStatic.client.KeyEvent( key, down ); } - void MouseMove( int x, int y ) + void MouseMove( int x, int y ) override { - UI_MouseMove( x, y ); + uiStatic.cursorX = x; + uiStatic.cursorY = y; + uiStatic.client.MouseEvent( x, y ); } - HFont BuildFont( CFontBuilder &builder ) + HFont BuildFont( CFontBuilder &builder ) override { return builder.Create(); } - void GetCharABCWide( HFont font, int ch, int &a, int &b, int &c ) + void GetCharABCWide( HFont font, int ch, int &a, int &b, int &c ) override { g_FontMgr.GetCharABCWide( font, ch, a, b, c ); } - int GetFontTall( HFont font ) + int GetFontTall( HFont font ) override { return g_FontMgr.GetFontTall( font ); } - int GetCharacterWidth(HFont font, int ch, int charH ) + int GetCharacterWidth(HFont font, int ch, int charH ) override { return g_FontMgr.GetCharacterWidthScaled( font, ch, charH ); } - void GetTextSize( HFont font, const char *text, int *wide, int *height = 0, int size = -1 ) + void GetTextSize( HFont font, const char *text, int *wide, int *height = 0, int size = -1 ) override { g_FontMgr.GetTextSize( font, text, wide, height, size ); } - int GetTextHeight( HFont font, const char *text, int size = -1 ) + int GetTextHeight( HFont font, const char *text, int size = -1 ) override { return g_FontMgr.GetTextHeight( font, text, size ); } - int DrawCharacter( HFont font, int ch, int x, int y, int charH, const unsigned int color, bool forceAdditive = false ) + int DrawCharacter( HFont font, int ch, int x, int y, int charH, const unsigned int color, bool forceAdditive = false ) override { return g_FontMgr.DrawCharacter( font, ch, Point( x, y ), charH, color, forceAdditive ); } - void DrawScoreboard( void ) + void SetupScoreboard( int xstart, int xend, int ystart, int yend, unsigned int color, bool drawStroke ) override { - + UI_SetupScoreboard( xstart, xend, ystart, yend, color, drawStroke ); } - void DrawSpectatorMenu( void ) + void DrawScoreboard( void ) override { - + UI_DrawScoreboard(); } - void ShowVGUIMenu( int ) + void DrawSpectatorMenu( void ) override { + } + void ShowVGUIMenu( int menuType, int param1, int param2 ) override + { + switch( menuType ) + { + case MENU_TEAM: UI_JoinGame_Show( param1, param2 ); break; + case MENU_CLASS_T: UI_JoinClassT_Show( param1, param2 ); break; + case MENU_CLASS_CT: UI_JoinClassCT_Show( param1, param2 ); break; + } } } s_Menu; From 0876e997520b3fb6fbaa21f0f9baf52952eee1b4 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Thu, 20 Sep 2018 21:16:54 +0300 Subject: [PATCH 11/18] Patch controls for cs16client --- controls/Bitmap.h | 1 + controls/PicButton.cpp | 3 ++- controls/PlayerModelView.cpp | 49 ++++++++++++++++++++++-------------- controls/PlayerModelView.h | 15 +++++++++++ 4 files changed, 48 insertions(+), 20 deletions(-) diff --git a/controls/Bitmap.h b/controls/Bitmap.h index 9502bb44..a99d7fef 100644 --- a/controls/Bitmap.h +++ b/controls/Bitmap.h @@ -57,6 +57,7 @@ class CMenuBannerBitmap : public CMenuBitmap CMenuBannerBitmap() : BaseClass() { iFlags = QMF_INACTIVE; + SetCharSize( QM_BIGFONT ); SetRect( UI_BANNER_POSX, UI_BANNER_POSY, UI_BANNER_WIDTH, UI_BANNER_HEIGHT ); bDrawAdditive = true; } diff --git a/controls/PicButton.cpp b/controls/PicButton.cpp index 6e1c591e..582650cf 100644 --- a/controls/PicButton.cpp +++ b/controls/PicButton.cpp @@ -144,7 +144,8 @@ void CMenuPicButton::Draw( ) { int state = BUTTON_NOFOCUS; - if( UI_CursorInRect( m_scPos, m_scSize ) && m_pParent == uiStatic.menuActive ) + if( UI_CursorInRect( m_scPos, m_scSize ) && + m_pParent && m_pParent->IsVisible() ) { if( !bRollOver ) { diff --git a/controls/PlayerModelView.cpp b/controls/PlayerModelView.cpp index cc964c0e..181e6f36 100644 --- a/controls/PlayerModelView.cpp +++ b/controls/PlayerModelView.cpp @@ -27,31 +27,31 @@ CMenuPlayerModelView::CMenuPlayerModelView() : CMenuBaseItem() prevCursorY = 0; hPlayerImage = 0; eFocusAnimation = QM_HIGHLIGHTIFFOCUS; + + eOverrideMode = PMV_DONTCARE; + iOutlineWidth = -1; } void CMenuPlayerModelView::VidInit() { - CMenuBaseItem::VidInit(); + backgroundColor.SetDefault( uiColorHelp ); + outlineColor.SetDefault( uiInputFgColor ); + outlineFocusColor.SetDefault( uiInputTextColor ); - ent = EngFuncs::GetPlayerModel(); + if( iOutlineWidth == -1 ) + iOutlineWidth = uiStatic.outlineWidth; - if( !ent ) - return; - - EngFuncs::SetModel( ent, "models/player.mdl" ); + CMenuBaseItem::VidInit(); - // setup render and actor - refdef.fov_x = 40; + ent = &ent2; - refdef.viewport[0] = m_scPos.x; - refdef.viewport[1] = m_scPos.y; - refdef.viewport[2] = m_scSize.w; - refdef.viewport[3] = m_scSize.h; + memset( ent, 0, sizeof( cl_entity_t )); - CalcFov(); + EngFuncs::SetModel( ent, "models/player.mdl" ); // adjust entity params - ent->curstate.number = 1; // IMPORTANT: always set playerindex to 1 + ent->index = 0; + ent->curstate.number = 700; // IMPORTANT: always set playerindex to 1 ent->curstate.animtime = gpGlobals->time; // start animation ent->curstate.sequence = 1; ent->curstate.scale = 1.0f; @@ -70,7 +70,7 @@ void CMenuPlayerModelView::VidInit() ent->origin[2] = ent->curstate.origin[2] = 2.0f; ent->angles[1] = ent->curstate.angles[1] = 180.0f; - ent->player = true; // yes, draw me as playermodel + ent->player = false; // yes, draw me as playermodel } const char *CMenuPlayerModelView::Key(int key, int down) @@ -134,15 +134,16 @@ const char *CMenuPlayerModelView::Key(int key, int down) void CMenuPlayerModelView::Draw() { // draw the background - UI_FillRect( m_scPos, m_scSize, uiPromptBgColor ); + UI_FillRect( m_scPos, m_scSize, backgroundColor ); // draw the rectangle if( eFocusAnimation == QM_HIGHLIGHTIFFOCUS && IsCurrentSelected() ) - UI_DrawRectangle( m_scPos, m_scSize, uiInputTextColor ); + UI_DrawRectangleExt( m_scPos, m_scSize, outlineFocusColor, iOutlineWidth ); else - UI_DrawRectangle( m_scPos, m_scSize, uiInputFgColor ); + UI_DrawRectangleExt( m_scPos, m_scSize, outlineColor, iOutlineWidth ); - if( !ui_showmodels->value ) + if( ( eOverrideMode == PMV_DONTCARE && !ui_showmodels->value ) || // controlled by engine cvar + ( eOverrideMode == PMV_SHOWIMAGE ) ) // controlled by menucode { if( hPlayerImage ) { @@ -163,6 +164,16 @@ void CMenuPlayerModelView::Draw() refdef.time = gpGlobals->time; refdef.frametime = gpGlobals->frametime; #endif + // setup render and actor + refdef.fov_x = 40; + + refdef.viewport[0] = m_scPos.x; + refdef.viewport[1] = m_scPos.y; + refdef.viewport[2] = m_scSize.w; + refdef.viewport[3] = m_scSize.h; + + CalcFov(); + ent->curstate.body = 0; if( uiStatic.enableAlphaFactor ) diff --git a/controls/PlayerModelView.h b/controls/PlayerModelView.h index a5c6c539..416550de 100644 --- a/controls/PlayerModelView.h +++ b/controls/PlayerModelView.h @@ -39,7 +39,22 @@ class CMenuPlayerModelView : public CMenuBaseItem ref_menu_params_t refdef; cl_entity_t *ent; + + enum + { + PMV_DONTCARE = 0, + PMV_SHOWMODEL, + PMV_SHOWIMAGE + } eOverrideMode; + + + CColor backgroundColor; + CColor outlineColor; + CColor outlineFocusColor; + int iOutlineWidth; private: + cl_entity_t ent2; + bool mouseYawControl; int prevCursorX, prevCursorY; From 4c679d3d6eaf7cba3cf90ef1a797a0b5a9fcffab Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Thu, 20 Sep 2018 21:17:08 +0300 Subject: [PATCH 12/18] Patch menus for cs16client --- menus/PlayerSetup.cpp | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/menus/PlayerSetup.cpp b/menus/PlayerSetup.cpp index 24cd3991..b93ab941 100644 --- a/menus/PlayerSetup.cpp +++ b/menus/PlayerSetup.cpp @@ -106,7 +106,7 @@ static class CMenuPlayerSetup : public CMenuFramework } logoImage; CMenuSpinControl logo; - CMenuSpinControl logoColor; + CMenuSpinControl logoColor; CMenuYesNoMessageBox msgBox; @@ -119,12 +119,21 @@ void CMenuPlayerSetup::CMenuLogoPreview::Draw() // draw the background UI_FillRect( m_scPos, m_scSize, uiPromptBgColor ); +#ifdef NEW_ENGINE_INTERFACE UI_DrawString( font, m_scPos, m_scSize, "No logo", iColor, m_scChSize, QM_CENTER, ETF_SHADOW ); +#else + UI_DrawString( font, m_scPos, m_scSize, "Coming soon!", iColor, m_scChSize, QM_CENTER, ETF_SHADOW ); +#endif } else { EngFuncs::PIC_Set( hImage, r, g, b, 255 ); EngFuncs::PIC_Draw( m_scPos, m_scSize ); + +#ifndef NEW_ENGINE_INTERFACE + UI_FillRect( m_scPos, m_scSize, uiColorBlack ); + UI_DrawString( font, m_scPos, m_scSize, "Coming soon!", iColor, m_scChSize, QM_CENTER, ETF_SHADOW ); +#endif } // draw the rectangle @@ -282,7 +291,9 @@ void CMenuPlayerSetup::UpdateLogo() logoImage.hImage = EngFuncs::PIC_Load( image, 0 ); ApplyColorToLogoPreview(); +#ifdef NEW_ENGINE_INTERFACE EngFuncs::CvarSetString( "cl_logofile", mdl ); +#endif } void CMenuPlayerSetup::ApplyColorToImagePreview() @@ -351,9 +362,9 @@ void CMenuPlayerSetup::_Init( void ) hideModels = true; // old engine cannot support logo customization, just don't add them -#ifndef NEW_ENGINE_INTERFACE +/*#ifndef NEW_ENGINE_INTERFACE hideLogos = true; -#endif +#endif*/ if( gMenu.m_gameinfo.flags & GFL_NOMODELS ) addFlags |= QMF_INACTIVE; @@ -448,12 +459,20 @@ void CMenuPlayerSetup::_Init( void ) logoImage.SetRect( 72, 230 + m_iBtnsNum * 50 + 10, 200, 200 ); logo.Setup( &logosModel ); +#ifdef NEW_ENGINE_INTERFACE logo.LinkCvar( "cl_logofile", CMenuEditable::CVAR_STRING ); +#else // NEW_ENGINE_INTERFACE + logo.SetCurrentValue( 0.0f ); +#endif logo.onChanged = VoidCb( &CMenuPlayerSetup::UpdateLogo ); logo.SetRect( 72, logoImage.pos.y + logoImage.size.h + UI_OUTLINE_WIDTH, 200, 32 ); logoColor.Setup( &colors ); +#ifdef NEW_ENGINE_INTERFACE logoColor.LinkCvar( "cl_logocolor", CMenuEditable::CVAR_STRING ); +#else // NEW_ENGINE_INTERFACE + logoColor.SetCurrentValue( 0.0f ); +#endif logoColor.onChanged = VoidCb( &CMenuPlayerSetup::ApplyColorToLogoPreview );; logoColor.SetRect( 72, logo.pos.y + logo.size.h + UI_OUTLINE_WIDTH, 200, 32 ); } From a2cbe4a54b2838fa1db5746edca831013a8fcb3c Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Thu, 20 Sep 2018 21:24:54 +0300 Subject: [PATCH 13/18] Add scoreboard --- menus/Scoreboard.cpp | 380 +++++++++++++++++++++++++++++++++++++++++++ menus/Scoreboard.h | 6 + 2 files changed, 386 insertions(+) create mode 100644 menus/Scoreboard.cpp create mode 100644 menus/Scoreboard.h diff --git a/menus/Scoreboard.cpp b/menus/Scoreboard.cpp new file mode 100644 index 00000000..4d5ad22f --- /dev/null +++ b/menus/Scoreboard.cpp @@ -0,0 +1,380 @@ +#include +#include "BaseWindow.h" +#include "Action.h" +#include "Table.h" +#include "BaseModel.h" +#include "Scoreboard.h" +#include "com_model.h" + + +#define RGB_YELLOWISH 0x00FFA000 //255,160,0 +#define RGB_REDISH 0x00FF1010 //255,16,16 +#define RGB_GREENISH 0x0000A000 //0,160,0 +#define RGB_WHITE 0x00FFFFFF + +uint g_ColorBlue = PackRGB( 154, 204, 255 ); +uint g_ColorRed = PackRGB( 255, 64, 64 ); + +struct player_t +{ + int kills; + const char *name; + const char *attrib; + byte thisplayer; + char deaths[6]; + char kills_buf[6]; + char ping[7]; +}; + +class CMenuScoreboardModel : public CMenuBaseModel +{ +public: + CMenuScoreboardModel() : CMenuBaseModel() + { + players.EnsureCapacity( 32 ); + } + + static int PlayerCompar( const void *a, const void *b ) + { + const player_t *_a = (const player_t *)a; + const player_t *_b = (const player_t *)b; + + if( _a->kills < _b->kills ) return 1; + else if( _a->kills > _b->kills ) return -1; + return 0; + } + + void Update() override + { + qsort( players.Base(), players.Count(), sizeof( player_t ), PlayerCompar ); + } + + int GetColumns() const override + { + return 5; + } + + int GetRows() const override + { + return players.Count(); + } + + const char *GetCellText( int line, int column ) override + { + switch( column ) + { + case 0: return players[line].name; + case 1: return players[line].attrib; + case 2: return players[line].kills_buf; + case 3: return players[line].deaths; + case 4: return players[line].ping; + } + + return NULL; + } + bool GetLineColor( int line, uint &color, bool &force ) const override + { + if( players[line].thisplayer ) + { + color = PackRGBA( 255, 255, 255, 32 ); + force = true; + return true; + } + + return false; + } + + bool GetCellColors( int line, int column, uint &color, bool &force ) const override + { + color = isTerrorist ? g_ColorRed : g_ColorBlue; + if( column == 0 ) + force = EngFuncs::GetCvarFloat("hud_colored") != 0.0f ? false : true; + else force = false; + return true; + } + + unsigned int GetAlignmentForColumn( int column ) const override + { + if( column == 0 ) + return QM_LEFT; + return QM_RIGHT; + } + + bool isTerrorist; + CUtlVector players; +}; + +class CMenuScoreboard : public CMenuBaseWindow +{ +public: + CMenuScoreboard( ) : CMenuBaseWindow( "Scoreboard" ){ } + + void _Init() override; + void _VidInit() override; + void Draw() override; + + void Clear(); + + bool bDrawStroke; + +private: + CMenuScoreboardModel CTs_model; + CMenuScoreboardModel Ts_model; + CMenuScoreboardModel specs_model; + + CMenuAction CTs_text; + CMenuAction CTs_score; + CMenuAction Ts_text; + CMenuAction Ts_score; + CMenuAction specs_text; + CMenuAction serverName; + CMenuTable CTs; + CMenuTable Ts; + + CUtlVector spectators; + + char spectators_buf[1024]; + char serverName_buf[256]; + char Ts_score_buf[8]; + char CTs_score_buf[8]; +}; + +static CMenuScoreboard scoreboard; + +void CMenuScoreboard::Clear() +{ + Ts_score_buf[0] = CTs_score_buf[0] = '0'; + Ts_score_buf[1] = CTs_score_buf[1] = '\0'; + + snprintf( serverName_buf, sizeof( serverName_buf ), "Server name: %s", g_pClient->GetServerHostName() ); + + spectators.RemoveAll(); + + CTs_model.players.RemoveAll(); + Ts_model.players.RemoveAll(); +} + +void CMenuScoreboard::Draw() +{ + Clear(); + + for( int i = 0; i < MAX_CLIENTS; i++ ) + { + if( i < 3 ) // MAX_TEAMS + { + team_info_t *team; + if( g_pClient->GetTeamInfo( i, &team ) ) + { + if( !strcmp( team->name, "TERRORIST" ) ) + snprintf( Ts_score_buf, sizeof( Ts_score_buf ), "%d", team->frags ); + else if ( !strcmp( team->name, "CT" ) ) + snprintf( CTs_score_buf, sizeof( CTs_score_buf ), "%d", team->frags ); + } + } + + extra_player_info_t *extra; + hud_player_info_t *pplayer; + bool isBot; + + if( g_pClient->GetPlayerExtraInfo( i, &pplayer, &extra, &isBot )) + { + player_t player; + + player.kills = extra->frags; + player.name = pplayer->name; + if( isBot ) strcpy( player.ping, "BOT" ); + else snprintf( player.ping, sizeof( player.ping), "%d", pplayer->ping ); + snprintf( player.deaths, sizeof( player.deaths), "%d", extra->deaths ); + snprintf( player.kills_buf, sizeof( player.kills_buf), "%d", player.kills ); + player.thisplayer = pplayer->thisplayer; + if( extra->dead ) player.attrib = "Dead"; + else if( extra->has_c4 ) player.attrib = "Bomb"; + else if( extra->vip ) player.attrib = "VIP"; + else player.attrib = NULL; + + switch( extra->teamnumber ) + { + case TEAM_TERRORIST: + Ts_model.players.AddToTail( player ); break; + case TEAM_CT: + CTs_model.players.AddToTail( player ); break; + case TEAM_SPECTATOR: + case TEAM_UNASSIGNED: + spectators.AddToTail( player ); break; + } + } + } + snprintf( spectators_buf, sizeof( spectators_buf ), "%s: ", g_pClient->Localize( "Cstrike_TitlesTXT_Spectators" ) ); + if( spectators.Count() ) + { + char temp[128]; + + for( int i = 0; i < spectators.Count() - 1; i++ ) + { + snprintf( temp, sizeof( temp ), "^7%s, ^7", spectators[i].name ); + + strncat( spectators_buf, temp, sizeof( spectators_buf )); + } + strncat( spectators_buf, spectators[spectators.Count() - 1].name, sizeof( spectators_buf ) ); + } + specs_text.size.h = g_FontMgr.GetTextHeightExt( specs_text.font, spectators_buf, specs_text.charSize, specs_text.size.w ); + specs_text.pos.y = -specs_text.size.h; + specs_text.CalcSizes(); + specs_text.CalcPosition(); + specs_text.bIgnoreColorstring = EngFuncs::GetCvarFloat("hud_colored") == 0.0f; + + int newSize = size.h - CTs.pos.y - specs_text.size.h; + if( newSize != CTs.size.h ) + { + Ts.size.h = CTs.size.h = newSize; + Ts.VidInit(); + CTs.VidInit(); + } + + CTs_model.Update(); + Ts_model.Update(); + + background.bDrawStroke = bDrawStroke; + + CMenuBaseWindow::Draw(); +} + +void CMenuScoreboard::_Init() +{ + Clear(); + + iFlags |= QMF_DISABLESCAILING; + + background.bForceColor = true; + background.iStrokeColor = uiInputTextColor; + + serverName.iFlags |= QMF_DISABLESCAILING; + serverName.SetCharSize( QM_SMALLFONT ); + serverName.eTextAlignment = QM_LEFT; + serverName.szName = serverName_buf; + + specs_text.iFlags |= QMF_DISABLESCAILING; + specs_text.SetCharSize( QM_SMALLFONT ); + specs_text.eTextAlignment = QM_LEFT|QM_TOP; + specs_text.szName = spectators_buf; + + CTs_text.iFlags |= QMF_DISABLESCAILING; + CTs_text.SetCharSize( QM_BIGFONT ); + CTs_text.SetBackground( PackRGBA( 0, 0, 255, 64 ) ); + CTs_text.szName = g_pClient->Localize( "Cstrike_ScoreBoard_CT" ); + + Ts_text.iFlags |= QMF_DISABLESCAILING; + Ts_text.SetCharSize( QM_BIGFONT ); + Ts_text.SetBackground( PackRGBA( 255, 0, 0, 64 ) ); + Ts_text.szName = g_pClient->Localize( "Cstrike_ScoreBoard_Ter" ); + + CTs_score.iFlags |= QMF_DISABLESCAILING; + CTs_score.SetCharSize( QM_BIGFONT ); + CTs_score.szName = CTs_score_buf; + + Ts_score.iFlags |= QMF_DISABLESCAILING; + Ts_score.SetCharSize( QM_BIGFONT ); + Ts_score.szName = Ts_score_buf; + + CTs_text.eTextAlignment = Ts_score.eTextAlignment = QM_LEFT; + Ts_text.eTextAlignment = CTs_score.eTextAlignment = QM_RIGHT; + + CTs_score.iColor = Ts_score.iColor = CTs_text.iColor = Ts_text.iColor = uiColorWhite; + + CTs.iFlags |= QMF_DISABLESCAILING|QMF_INACTIVE; + Ts.bShowScrollBar = CTs.bShowScrollBar = false; + Ts.bDrawStroke = CTs.bDrawStroke = true; + Ts.iOutlineWidth = CTs.iOutlineWidth = 1; + Ts.iStrokeColor = CTs.iStrokeColor = uiInputTextColor; + Ts.iBackgroundColor = CTs.iBackgroundColor = 0; + CTs.iHeaderColor = g_ColorBlue; + CTs.SetupColumn( 0, g_pClient->Localize( "Cstrike_TitlesTXT_PLAYERS" ), 0.4f ); + CTs.SetupColumn( 1, "", 0.15f ); + CTs.SetupColumn( 2, g_pClient->Localize( "Cstrike_TitlesTXT_SCORE" ), 0.15f ); + CTs.SetupColumn( 3, g_pClient->Localize( "Cstrike_TitlesTXT_DEATHS" ), 0.15f ); + CTs.SetupColumn( 4, g_pClient->Localize( "Cstrike_TitlesTXT_LATENCY" ), 0.15f ); + CTs.SetModel( &CTs_model ); + CTs.SetCharSize( QM_DEFAULTFONT ); + + CTs_model.isTerrorist = false; + Ts_model.isTerrorist = true; + Ts.iFlags |= QMF_DISABLESCAILING|QMF_INACTIVE; + Ts.iHeaderColor = g_ColorRed; + Ts.SetupColumn( 0, g_pClient->Localize( "Cstrike_TitlesTXT_PLAYERS" ), 0.4f ); + Ts.SetupColumn( 1, "", 0.15f ); + Ts.SetupColumn( 2, g_pClient->Localize( "Cstrike_TitlesTXT_SCORE" ), 0.15f ); + Ts.SetupColumn( 3, g_pClient->Localize( "Cstrike_TitlesTXT_DEATHS" ), 0.15f ); + Ts.SetupColumn( 4, g_pClient->Localize( "Cstrike_TitlesTXT_LATENCY" ), 0.15f ); + Ts.SetModel( &Ts_model ); + Ts.SetCharSize( QM_DEFAULTFONT ); + + AddItem( background ); + AddItem( serverName ); + AddItem( specs_text ); + AddItem( CTs_text ); + AddItem( CTs_score ); + AddItem( Ts_text ); + AddItem( Ts_score ); + AddItem( CTs ); + AddItem( Ts ); +} + +void CMenuScoreboard::_VidInit() +{ + serverName.pos = Point( 4, 4 ); + serverName.size = Size( size.w - 8, g_FontMgr.GetFontTall( serverName.font ) * 1.25f ); + + specs_text.size = Size( size.w - 8, 1 ); + specs_text.pos = Point( 4, size.h ); + + CTs_score.pos = CTs_text.pos = Point( 4, serverName.size.h + serverName.pos.y + 4 ); + Ts_score.pos = Ts_text.pos = Point( size.w / 2 + 4, serverName.size.h + serverName.pos.y + 4 ); + + Ts_score.size = Ts_text.size = CTs_score.size = CTs_text.size = + Size( size.w / 2 - 8, g_FontMgr.GetFontTall( CTs_text.font ) * 1.25f ); + + Ts_score.pos.x += g_FontMgr.GetFontTall( Ts_text.font ) / 2; + CTs_score.size.w -= g_FontMgr.GetFontTall( Ts_text.font ) / 2; + + CTs.pos = Point( CTs_text.pos.x, CTs_text.size.h + CTs_text.pos.y + 4 ); + Ts.pos = Point( Ts_text.pos.x, Ts_text.size.h + Ts_text.pos.y + 4 ); + Ts.size = CTs.size = Size( CTs_text.size.w, size.h - CTs.pos.y ); +} + +void UI_SetupScoreboard( int xstart, int xend, int ystart, int yend, unsigned int color, bool drawStroke ) +{ + Point pt = scoreboard.GetRenderPosition(); + Size sz = scoreboard.GetRenderSize(); + bool vidinit = false; + + if( pt.x != xstart || pt.y != ystart ) + { + scoreboard.SetCoord( xstart, ystart ); + vidinit = true; + } + + if( sz.w != xend - xstart || sz.h != yend - ystart ) + { + scoreboard.SetSize( xend - xstart, yend - ystart ); + vidinit = true; + } + + if( vidinit ) + { + UI_VidInitScoreboard(); + } + + scoreboard.bDrawStroke = drawStroke; + scoreboard.background.iColor = color; +} + +void UI_VidInitScoreboard() +{ + scoreboard.Init(); + scoreboard.VidInit(); +} + +void UI_DrawScoreboard() +{ + scoreboard.Draw(); +} diff --git a/menus/Scoreboard.h b/menus/Scoreboard.h new file mode 100644 index 00000000..143eaeca --- /dev/null +++ b/menus/Scoreboard.h @@ -0,0 +1,6 @@ +#pragma once + +void UI_SetupScoreboard( int xstart, int xend, int ystart, int yend, unsigned int color, bool drawStroke ); +void UI_ResortScoreboard( void ); +void UI_VidInitScoreboard(); +void UI_DrawScoreboard(); From 1d19ba950ec772dca9c18e7fb17e129f7065fe80 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Fri, 26 Oct 2018 00:09:41 +0300 Subject: [PATCH 14/18] Revert "Action: don't change public m_bLimitBySize" This reverts commit fd0eff09ca9398d38c33cbf00cd8603655b3cfd1. --- controls/Action.cpp | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/controls/Action.cpp b/controls/Action.cpp index c79a1228..26d75d10 100644 --- a/controls/Action.cpp +++ b/controls/Action.cpp @@ -24,7 +24,6 @@ CMenuAction::CMenuAction() : BaseClass() { m_szBackground = NULL; m_bfillBackground = false; - m_bLimitBySize = false; } /* @@ -34,44 +33,33 @@ CMenuAction::Init */ void CMenuAction::VidInit( ) { - bool calcSizes = true; - m_iBackcolor.SetDefault( 0 ); if( size.w < 1 || size.h < 1 ) { - // no need to check for scailing, already in physical units - if( m_szBackground ) { HIMAGE handle = EngFuncs::PIC_Load( m_szBackground ); - m_scSize.w = EngFuncs::PIC_Width( handle ); - m_scSize.h = EngFuncs::PIC_Height( handle ); + size.w = EngFuncs::PIC_Width( handle ); + size.h = EngFuncs::PIC_Height( handle ); } else { if( size.w < 1 ) - m_scSize.w = g_FontMgr.GetTextWideScaled( font, szName, charSize ); + size.w = g_FontMgr.GetTextWideScaled( font, szName, charSize ) / uiStatic.scaleX; if( size.h < 1 ) - m_scSize.h = g_FontMgr.GetTextHeightExt( font, szName, charSize, m_scSize.w / uiStatic.scaleX ); + size.h = g_FontMgr.GetTextHeightExt( font, szName, charSize, size.w ) / uiStatic.scaleX; } m_bLimitBySize = false; - - calcSizes = false; } else { m_bLimitBySize = true; } - CalcPosition(); - if( calcSizes ) CalcSizes(); - - iColor.SetDefault( uiPromptTextColor ); - iFocusColor.SetDefault( uiPromptFocusColor ); - iStrokeColor.SetDefault( uiInputFgColor ); + BaseClass::VidInit(); } /* @@ -138,7 +126,7 @@ void CMenuAction::Draw( ) if( bDrawStroke ) { - UI_DrawRectangleExt( m_scPos, m_scSize, iStrokeColor, iStrokeWidth ); + UI_DrawRectangleExt( m_scPos, m_scSize, iStrokeColor, 1 ); } if( m_szBackground ) From 44976b815b08b7cd4d9d5406f4f8824a395e1f4f Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Fri, 26 Oct 2018 02:19:36 +0300 Subject: [PATCH 15/18] remove legacy --- legacy/menu_playdemo.cpp | 464 ------------------------------------- legacy/menu_playrec.cpp | 178 -------------- legacy/menu_recdemo.cpp | 487 --------------------------------------- 3 files changed, 1129 deletions(-) delete mode 100644 legacy/menu_playdemo.cpp delete mode 100644 legacy/menu_playrec.cpp delete mode 100644 legacy/menu_recdemo.cpp diff --git a/legacy/menu_playdemo.cpp b/legacy/menu_playdemo.cpp deleted file mode 100644 index 19c9a9b4..00000000 --- a/legacy/menu_playdemo.cpp +++ /dev/null @@ -1,464 +0,0 @@ -/* -Copyright (C) 1997-2001 Id Software, Inc. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -#include "extdll.h" -#include "basemenu.h" -#include "utils.h" -#include "keydefs.h" - -#define ART_BANNER "gfx/shell/head_load" - -#define ID_BACKGROUND 0 -#define ID_BANNER 1 -#define ID_PLAY 2 -#define ID_DELETE 3 -#define ID_CANCEL 4 -#define ID_DEMOLIST 5 -#define ID_TABLEHINT 6 -#define ID_LEVELSHOT 7 -#define ID_MSGBOX 8 -#define ID_MSGTEXT 9 -#define ID_YES 10 -#define ID_NO 11 - -#define LEVELSHOT_X 72 -#define LEVELSHOT_Y 400 -#define LEVELSHOT_W 192 -#define LEVELSHOT_H 160 - -#define TITLE_LENGTH 32 -#define MAPNAME_LENGTH 24+TITLE_LENGTH -#define MAXCLIENTS_LENGTH 16+MAPNAME_LENGTH - -typedef struct -{ - char demoName[UI_MAXGAMES][CS_SIZE]; - char delName[UI_MAXGAMES][CS_SIZE]; - char demoDescription[UI_MAXGAMES][256]; - char *demoDescriptionPtr[UI_MAXGAMES]; - - menuFramework_s menu; - - menuBitmap_s background; - menuBitmap_s banner; - menuAction_s play; - menuAction_s remove; - menuAction_s cancel; - - menuScrollList_s demosList; - - menuBitmap_s levelShot; - menuAction_s hintMessage; - char hintText[MAX_HINT_TEXT]; - - // prompt dialog - menuAction_s msgBox; - menuAction_s promptMessage; - menuAction_s yes; - menuAction_s no; -} uiPlayDemo_t; - -static uiPlayDemo_t uiPlayDemo; - -/* -================= -UI_MsgBox_Ownerdraw -================= -*/ -static void UI_MsgBox_Ownerdraw( void *self ) -{ - menuCommon_s *item = (menuCommon_s *)self; - - UI_FillRect( item->x, item->y, item->width, item->height, uiPromptBgColor ); -} - -static void UI_DeleteDialog( void ) -{ - // toggle main menu between active\inactive - // show\hide remove dialog - uiPlayDemo.play.generic.flags ^= QMF_INACTIVE; - uiPlayDemo.remove.generic.flags ^= QMF_INACTIVE; - uiPlayDemo.cancel.generic.flags ^= QMF_INACTIVE; - uiPlayDemo.demosList.generic.flags ^= QMF_INACTIVE; - - uiPlayDemo.msgBox.generic.flags ^= QMF_HIDDEN; - uiPlayDemo.promptMessage.generic.flags ^= QMF_HIDDEN; - uiPlayDemo.no.generic.flags ^= QMF_HIDDEN; - uiPlayDemo.yes.generic.flags ^= QMF_HIDDEN; - -} - -/* -================= -UI_PlayDemo_KeyFunc -================= -*/ -static const char *UI_PlayDemo_KeyFunc( int key, int down ) -{ - if( down && key == K_ESCAPE && uiPlayDemo.play.generic.flags & QMF_INACTIVE ) - { - UI_DeleteDialog(); - return uiSoundNull; - } - return UI_DefaultKey( &uiPlayDemo.menu, key, down ); -} - -/* -================= -UI_PlayDemo_GetDemoList -================= -*/ -static void UI_PlayDemo_GetDemoList( void ) -{ - char comment[256]; - char **filenames; - int i, numFiles; - - filenames = FS_SEARCH( "demos/*.dem", &numFiles, TRUE ); - - for( i = 0; i < numFiles; i++ ) - { - if( i >= UI_MAXGAMES ) break; - - if( !GET_DEMO_COMMENT( filenames[i], comment )) - { - if( strlen( comment )) - { - // get name string even if not found - CL_GetComment can be mark demos - // as etc - StringConcat( uiPlayDemo.demoDescription[i], uiEmptyString, TITLE_LENGTH ); - StringConcat( uiPlayDemo.demoDescription[i], comment, MAPNAME_LENGTH ); - StringConcat( uiPlayDemo.demoDescription[i], uiEmptyString, MAXCLIENTS_LENGTH ); - uiPlayDemo.demoDescriptionPtr[i] = uiPlayDemo.demoDescription[i]; - COM_FileBase( filenames[i], uiPlayDemo.delName[i] ); - } - else uiPlayDemo.demoDescriptionPtr[i] = NULL; - continue; - } - - // strip path, leave only filename (empty slots doesn't have savename) - COM_FileBase( filenames[i], uiPlayDemo.demoName[i] ); - COM_FileBase( filenames[i], uiPlayDemo.delName[i] ); - - // fill demo desc - StringConcat( uiPlayDemo.demoDescription[i], comment + CS_SIZE, TITLE_LENGTH ); - StringConcat( uiPlayDemo.demoDescription[i], uiEmptyString, TITLE_LENGTH ); - StringConcat( uiPlayDemo.demoDescription[i], comment, MAPNAME_LENGTH ); - StringConcat( uiPlayDemo.demoDescription[i], uiEmptyString, MAPNAME_LENGTH ); // fill remaining entries - StringConcat( uiPlayDemo.demoDescription[i], comment + CS_SIZE * 2, MAXCLIENTS_LENGTH ); - StringConcat( uiPlayDemo.demoDescription[i], uiEmptyString, MAXCLIENTS_LENGTH ); - uiPlayDemo.demoDescriptionPtr[i] = uiPlayDemo.demoDescription[i]; - } - - for ( ; i < UI_MAXGAMES; i++ ) - uiPlayDemo.demoDescriptionPtr[i] = NULL; - uiPlayDemo.demosList.itemNames = (const char **)uiPlayDemo.demoDescriptionPtr; - - if( strlen( uiPlayDemo.demoName[0] ) == 0 ) - uiPlayDemo.play.generic.flags |= QMF_GRAYED; - else uiPlayDemo.play.generic.flags &= ~QMF_GRAYED; - - if( strlen( uiPlayDemo.delName[0] ) == 0 || !stricmp( gpGlobals->demoname, uiPlayDemo.delName[uiPlayDemo.demosList.curItem] )) - uiPlayDemo.remove.generic.flags |= QMF_GRAYED; - else uiPlayDemo.remove.generic.flags &= ~QMF_GRAYED; -} - -/* -================= -UI_PlayDemo_Callback -================= -*/ -static void UI_PlayDemo_Callback( void *self, int event ) -{ - menuCommon_s *item = (menuCommon_s *)self; - - if( event == QM_CHANGED ) - { - if( strlen( uiPlayDemo.demoName[uiPlayDemo.demosList.curItem] ) == 0 ) - uiPlayDemo.play.generic.flags |= QMF_GRAYED; - else uiPlayDemo.play.generic.flags &= ~QMF_GRAYED; - - if( strlen( uiPlayDemo.delName[uiPlayDemo.demosList.curItem] ) == 0 || !stricmp( gpGlobals->demoname, uiPlayDemo.delName[uiPlayDemo.demosList.curItem] )) - uiPlayDemo.remove.generic.flags |= QMF_GRAYED; - else uiPlayDemo.remove.generic.flags &= ~QMF_GRAYED; - return; - } - - if( event != QM_ACTIVATED ) - return; - - switch( item->id ) - { - case ID_CANCEL: - UI_PopMenu(); - break; - case ID_PLAY: - if( gpGlobals->demoplayback || gpGlobals->demorecording ) - { - CLIENT_COMMAND( FALSE, "stop" ); - uiPlayDemo.play.generic.name = "Play"; - uiPlayDemo.play.generic.statusText = "Play a demo"; - uiPlayDemo.remove.generic.flags &= ~QMF_GRAYED; - } - else if( strlen( uiPlayDemo.demoName[uiPlayDemo.demosList.curItem] )) - { - char cmd[128]; - sprintf( cmd, "playdemo \"%s\"\n", uiPlayDemo.demoName[uiPlayDemo.demosList.curItem] ); - CLIENT_COMMAND( FALSE, cmd ); - } - break; - case ID_NO: - case ID_DELETE: - UI_DeleteDialog(); - break; - case ID_YES: - if( strlen( uiPlayDemo.delName[uiPlayDemo.demosList.curItem] )) - { - char cmd[128]; - sprintf( cmd, "killdemo \"%s\"\n", uiPlayDemo.delName[uiPlayDemo.demosList.curItem] ); - - CLIENT_COMMAND( TRUE, cmd ); - - sprintf( cmd, "demos/%s.bmp", uiPlayDemo.delName[uiPlayDemo.demosList.curItem] ); - PIC_Free( cmd ); - - // restarts the menu - UI_PopMenu(); - UI_PlayDemo_Menu(); - return; - } - UI_DeleteDialog(); - break; - } -} - -/* -================= -UI_PlayDemo_Ownerdraw -================= -*/ -static void UI_PlayDemo_Ownerdraw( void *self ) -{ - menuCommon_s *item = (menuCommon_s *)self; - - if( item->type != QMTYPE_ACTION && item->id == ID_LEVELSHOT ) - { - int x, y, w, h; - - // draw the levelshot - x = LEVELSHOT_X; - y = LEVELSHOT_Y; - w = LEVELSHOT_W; - h = LEVELSHOT_H; - - UI_ScaleCoords( &x, &y, &w, &h ); - - if( strlen( uiPlayDemo.demoName[uiPlayDemo.demosList.curItem] )) - { - char demoshot[128]; - - sprintf( demoshot, "demos/%s.bmp", uiPlayDemo.demoName[uiPlayDemo.demosList.curItem] ); - - if( !FILE_EXISTS( demoshot )) - UI_DrawPicAdditive( x, y, w, h, uiColorWhite, "{GRAF001" ); - else UI_DrawPic( x, y, w, h, uiColorWhite, demoshot ); - } - else UI_DrawPicAdditive( x, y, w, h, uiColorWhite, "{GRAF001" ); - - // draw the rectangle - UI_DrawRectangle( item->x, item->y, item->width, item->height, uiInputFgColor ); - } -} - -/* -================= -UI_PlayDemo_Init -================= -*/ -static void UI_PlayDemo_Init( void ) -{ - memset( &uiPlayDemo, 0, sizeof( uiPlayDemo_t )); - - uiPlayDemo.menu.vidInitFunc = UI_PlayDemo_Init; - uiPlayDemo.menu.keyFunc = UI_PlayDemo_KeyFunc; - - StringConcat( uiPlayDemo.hintText, "Title", TITLE_LENGTH ); - StringConcat( uiPlayDemo.hintText, uiEmptyString, TITLE_LENGTH ); - StringConcat( uiPlayDemo.hintText, "Map", MAPNAME_LENGTH ); - StringConcat( uiPlayDemo.hintText, uiEmptyString, MAPNAME_LENGTH ); - StringConcat( uiPlayDemo.hintText, "Max Clients", MAXCLIENTS_LENGTH ); - StringConcat( uiPlayDemo.hintText, uiEmptyString, MAXCLIENTS_LENGTH ); - - uiPlayDemo.background.generic.id = ID_BACKGROUND; - uiPlayDemo.background.generic.type = QMTYPE_BITMAP; - uiPlayDemo.background.generic.flags = QMF_INACTIVE; - uiPlayDemo.background.generic.x = 0; - uiPlayDemo.background.generic.y = 0; - uiPlayDemo.background.generic.width = 1024; - uiPlayDemo.background.generic.height = 768; - uiPlayDemo.background.pic = ART_BACKGROUND; - - uiPlayDemo.banner.generic.id = ID_BANNER; - uiPlayDemo.banner.generic.type = QMTYPE_BITMAP; - uiPlayDemo.banner.generic.flags = QMF_INACTIVE|QMF_DRAW_ADDITIVE; - uiPlayDemo.banner.generic.x = UI_BANNER_POSX; - uiPlayDemo.banner.generic.y = UI_BANNER_POSY; - uiPlayDemo.banner.generic.width = UI_BANNER_WIDTH; - uiPlayDemo.banner.generic.height = UI_BANNER_HEIGHT; - uiPlayDemo.banner.pic = ART_BANNER; - - uiPlayDemo.play.generic.id = ID_PLAY; - uiPlayDemo.play.generic.type = QMTYPE_ACTION; - uiPlayDemo.play.generic.flags = QMF_HIGHLIGHTIFFOCUS|QMF_DROPSHADOW; - uiPlayDemo.play.generic.x = 72; - uiPlayDemo.play.generic.y = 230; - - if ( gpGlobals->demoplayback ) - { - uiPlayDemo.play.generic.name = "Stop"; - uiPlayDemo.play.generic.statusText = "Stop a demo playing"; - } - else if ( gpGlobals->demorecording ) - { - uiPlayDemo.play.generic.name = "Stop"; - uiPlayDemo.play.generic.statusText = "Stop a demo recording"; - } - else - { - uiPlayDemo.play.generic.name = "Play"; - uiPlayDemo.play.generic.statusText = "Play a demo"; - } - uiPlayDemo.play.generic.callback = UI_PlayDemo_Callback; - - uiPlayDemo.remove.generic.id = ID_DELETE; - uiPlayDemo.remove.generic.type = QMTYPE_ACTION; - uiPlayDemo.remove.generic.flags = QMF_HIGHLIGHTIFFOCUS|QMF_DROPSHADOW; - uiPlayDemo.remove.generic.x = 72; - uiPlayDemo.remove.generic.y = 280; - uiPlayDemo.remove.generic.name = "Delete"; - uiPlayDemo.remove.generic.statusText = "Delete a demo"; - uiPlayDemo.remove.generic.callback = UI_PlayDemo_Callback; - - uiPlayDemo.cancel.generic.id = ID_CANCEL; - uiPlayDemo.cancel.generic.type = QMTYPE_ACTION; - uiPlayDemo.cancel.generic.flags = QMF_HIGHLIGHTIFFOCUS|QMF_DROPSHADOW; - uiPlayDemo.cancel.generic.x = 72; - uiPlayDemo.cancel.generic.y = 330; - uiPlayDemo.cancel.generic.name = "Cancel"; - uiPlayDemo.cancel.generic.statusText = "Return back to main menu"; - uiPlayDemo.cancel.generic.callback = UI_PlayDemo_Callback; - - uiPlayDemo.hintMessage.generic.id = ID_TABLEHINT; - uiPlayDemo.hintMessage.generic.type = QMTYPE_ACTION; - uiPlayDemo.hintMessage.generic.flags = QMF_INACTIVE|QMF_SMALLFONT; - uiPlayDemo.hintMessage.generic.color = uiColorHelp; - uiPlayDemo.hintMessage.generic.name = uiPlayDemo.hintText; - uiPlayDemo.hintMessage.generic.x = 360; - uiPlayDemo.hintMessage.generic.y = 225; - - uiPlayDemo.levelShot.generic.id = ID_LEVELSHOT; - uiPlayDemo.levelShot.generic.type = QMTYPE_BITMAP; - uiPlayDemo.levelShot.generic.flags = QMF_INACTIVE; - uiPlayDemo.levelShot.generic.x = LEVELSHOT_X; - uiPlayDemo.levelShot.generic.y = LEVELSHOT_Y; - uiPlayDemo.levelShot.generic.width = LEVELSHOT_W; - uiPlayDemo.levelShot.generic.height = LEVELSHOT_H; - uiPlayDemo.levelShot.generic.ownerdraw = UI_PlayDemo_Ownerdraw; - - uiPlayDemo.demosList.generic.id = ID_DEMOLIST; - uiPlayDemo.demosList.generic.type = QMTYPE_SCROLLLIST; - uiPlayDemo.demosList.generic.flags = QMF_HIGHLIGHTIFFOCUS|QMF_DROPSHADOW|QMF_SMALLFONT; - uiPlayDemo.demosList.generic.x = 360; - uiPlayDemo.demosList.generic.y = 255; - uiPlayDemo.demosList.generic.width = 640; - uiPlayDemo.demosList.generic.height = 440; - uiPlayDemo.demosList.generic.callback = UI_PlayDemo_Callback; - - uiPlayDemo.msgBox.generic.id = ID_MSGBOX; - uiPlayDemo.msgBox.generic.type = QMTYPE_ACTION; - uiPlayDemo.msgBox.generic.flags = QMF_INACTIVE|QMF_HIDDEN; - uiPlayDemo.msgBox.generic.ownerdraw = UI_MsgBox_Ownerdraw; // just a fill rectangle - uiPlayDemo.msgBox.generic.x = 192; - uiPlayDemo.msgBox.generic.y = 256; - uiPlayDemo.msgBox.generic.width = 640; - uiPlayDemo.msgBox.generic.height = 256; - - uiPlayDemo.promptMessage.generic.id = ID_MSGBOX; - uiPlayDemo.promptMessage.generic.type = QMTYPE_ACTION; - uiPlayDemo.promptMessage.generic.flags = QMF_INACTIVE|QMF_DROPSHADOW|QMF_HIDDEN; - uiPlayDemo.promptMessage.generic.name = "Delete selected demo?"; - uiPlayDemo.promptMessage.generic.x = 315; - uiPlayDemo.promptMessage.generic.y = 280; - - uiPlayDemo.yes.generic.id = ID_YES; - uiPlayDemo.yes.generic.type = QMTYPE_ACTION; - uiPlayDemo.yes.generic.flags = QMF_HIGHLIGHTIFFOCUS|QMF_DROPSHADOW|QMF_HIDDEN; - uiPlayDemo.yes.generic.name = "Ok"; - uiPlayDemo.yes.generic.x = 380; - uiPlayDemo.yes.generic.y = 460; - uiPlayDemo.yes.generic.callback = UI_PlayDemo_Callback; - - uiPlayDemo.no.generic.id = ID_NO; - uiPlayDemo.no.generic.type = QMTYPE_ACTION; - uiPlayDemo.no.generic.flags = QMF_HIGHLIGHTIFFOCUS|QMF_DROPSHADOW|QMF_HIDDEN; - uiPlayDemo.no.generic.name = "Cancel"; - uiPlayDemo.no.generic.x = 530; - uiPlayDemo.no.generic.y = 460; - uiPlayDemo.no.generic.callback = UI_PlayDemo_Callback; - - UI_PlayDemo_GetDemoList(); - - UI_AddItem( &uiPlayDemo.menu, (void *)&uiPlayDemo.background ); - UI_AddItem( &uiPlayDemo.menu, (void *)&uiPlayDemo.banner ); - UI_AddItem( &uiPlayDemo.menu, (void *)&uiPlayDemo.play ); - UI_AddItem( &uiPlayDemo.menu, (void *)&uiPlayDemo.remove ); - UI_AddItem( &uiPlayDemo.menu, (void *)&uiPlayDemo.cancel ); - UI_AddItem( &uiPlayDemo.menu, (void *)&uiPlayDemo.hintMessage ); - UI_AddItem( &uiPlayDemo.menu, (void *)&uiPlayDemo.levelShot ); - UI_AddItem( &uiPlayDemo.menu, (void *)&uiPlayDemo.demosList ); - UI_AddItem( &uiPlayDemo.menu, (void *)&uiPlayDemo.msgBox ); - UI_AddItem( &uiPlayDemo.menu, (void *)&uiPlayDemo.promptMessage ); - UI_AddItem( &uiPlayDemo.menu, (void *)&uiPlayDemo.no ); - UI_AddItem( &uiPlayDemo.menu, (void *)&uiPlayDemo.yes ); -} - -/* -================= -UI_PlayDemo_Precache -================= -*/ -void UI_PlayDemo_Precache( void ) -{ - PIC_Load( ART_BACKGROUND ); - PIC_Load( ART_BANNER ); -} - -/* -================= -UI_PlayDemo_Menu -================= -*/ -void UI_PlayDemo_Menu( void ) -{ - UI_PlayDemo_Precache(); - UI_PlayDemo_Init(); - - UI_PushMenu( &uiPlayDemo.menu ); -} \ No newline at end of file diff --git a/legacy/menu_playrec.cpp b/legacy/menu_playrec.cpp deleted file mode 100644 index 72570595..00000000 --- a/legacy/menu_playrec.cpp +++ /dev/null @@ -1,178 +0,0 @@ -/* -Copyright (C) 1997-2001 Id Software, Inc. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -#include "extdll.h" -#include "basemenu.h" -#include "utils.h" - -#define ART_BANNER "gfx/shell/head_saveload" - -#define ID_BACKGROUND 0 -#define ID_BANNER 1 - -#define ID_PLAY 2 -#define ID_RECORD 3 -#define ID_DONE 4 - -#define ID_MSGHINT 5 - -typedef struct -{ - menuFramework_s menu; - - menuBitmap_s background; - menuBitmap_s banner; - - menuAction_s record; - menuAction_s play; - menuAction_s done; - - menuAction_s hintMessage; - char hintText[MAX_HINT_TEXT]; -} uiPlayRec_t; - -static uiPlayRec_t uiPlayRec; - -/* -================= -UI_PlayRec_Callback -================= -*/ -static void UI_PlayRec_Callback( void *self, int event ) -{ - menuCommon_s *item = (menuCommon_s *)self; - - if( event != QM_ACTIVATED ) - return; - - switch( item->id ) - { - case ID_PLAY: - UI_PlayDemo_Menu(); - break; - case ID_RECORD: - UI_RecDemo_Menu(); - break; - case ID_DONE: - UI_PopMenu(); - break; - } -} - -/* -================= -UI_PlayRec_Init -================= -*/ -static void UI_PlayRec_Init( void ) -{ - memset( &uiPlayRec, 0, sizeof( uiPlayRec_t )); - - uiPlayRec.menu.vidInitFunc = UI_PlayRec_Init; - - strcat( uiPlayRec.hintText, "During play or record demo, you can quickly stop\n" ); - strcat( uiPlayRec.hintText, "playing/recording demo by pressing " ); - strcat( uiPlayRec.hintText, KEY_KeynumToString( KEY_GetKey( "stop" ))); - strcat( uiPlayRec.hintText, ".\n" ); - - uiPlayRec.background.generic.id = ID_BACKGROUND; - uiPlayRec.background.generic.type = QMTYPE_BITMAP; - uiPlayRec.background.generic.flags = QMF_INACTIVE; - uiPlayRec.background.generic.x = 0; - uiPlayRec.background.generic.y = 0; - uiPlayRec.background.generic.width = 1024; - uiPlayRec.background.generic.height = 768; - uiPlayRec.background.pic = ART_BACKGROUND; - - uiPlayRec.banner.generic.id = ID_BANNER; - uiPlayRec.banner.generic.type = QMTYPE_BITMAP; - uiPlayRec.banner.generic.flags = QMF_INACTIVE|QMF_DRAW_ADDITIVE; - uiPlayRec.banner.generic.x = UI_BANNER_POSX; - uiPlayRec.banner.generic.y = UI_BANNER_POSY; - uiPlayRec.banner.generic.width = UI_BANNER_WIDTH; - uiPlayRec.banner.generic.height = UI_BANNER_HEIGHT; - uiPlayRec.banner.pic = ART_BANNER; - - uiPlayRec.play.generic.id = ID_PLAY; - uiPlayRec.play.generic.type = QMTYPE_ACTION; - uiPlayRec.play.generic.flags = QMF_HIGHLIGHTIFFOCUS|QMF_DROPSHADOW|QMF_NOTIFY; - uiPlayRec.play.generic.name = "Play demo"; - uiPlayRec.play.generic.statusText = "Play a specified demo"; - uiPlayRec.play.generic.x = 72; - uiPlayRec.play.generic.y = 230; - uiPlayRec.play.generic.callback = UI_PlayRec_Callback; - - uiPlayRec.record.generic.id = ID_RECORD; - uiPlayRec.record.generic.type = QMTYPE_ACTION; - uiPlayRec.record.generic.flags = QMF_HIGHLIGHTIFFOCUS|QMF_DROPSHADOW|QMF_NOTIFY; - uiPlayRec.record.generic.name = "Record demo"; - uiPlayRec.record.generic.statusText = "Record demo at this time"; - uiPlayRec.record.generic.x = 72; - uiPlayRec.record.generic.y = 280; - uiPlayRec.record.generic.callback = UI_PlayRec_Callback; - - uiPlayRec.done.generic.id = ID_DONE; - uiPlayRec.done.generic.type = QMTYPE_ACTION; - uiPlayRec.done.generic.flags = QMF_HIGHLIGHTIFFOCUS|QMF_DROPSHADOW|QMF_NOTIFY; - uiPlayRec.done.generic.name = "Done"; - uiPlayRec.done.generic.statusText = "Go back to the Main Menu"; - uiPlayRec.done.generic.x = 72; - uiPlayRec.done.generic.y = 330; - uiPlayRec.done.generic.callback = UI_PlayRec_Callback; - - uiPlayRec.hintMessage.generic.id = ID_MSGHINT; - uiPlayRec.hintMessage.generic.type = QMTYPE_ACTION; - uiPlayRec.hintMessage.generic.flags = QMF_INACTIVE|QMF_SMALLFONT; - uiPlayRec.hintMessage.generic.color = uiColorHelp; - uiPlayRec.hintMessage.generic.name = uiPlayRec.hintText; - uiPlayRec.hintMessage.generic.x = 360; - uiPlayRec.hintMessage.generic.y = 480; - - UI_AddItem( &uiPlayRec.menu, (void *)&uiPlayRec.background ); - UI_AddItem( &uiPlayRec.menu, (void *)&uiPlayRec.banner ); - UI_AddItem( &uiPlayRec.menu, (void *)&uiPlayRec.play ); - UI_AddItem( &uiPlayRec.menu, (void *)&uiPlayRec.record ); - UI_AddItem( &uiPlayRec.menu, (void *)&uiPlayRec.done ); - UI_AddItem( &uiPlayRec.menu, (void *)&uiPlayRec.hintMessage ); -} - -/* -================= -UI_PlayRec_Precache -================= -*/ -void UI_PlayRec_Precache( void ) -{ - PIC_Load( ART_BACKGROUND ); - PIC_Load( ART_BANNER ); -} - -/* -================= -UI_PlayRec_Menu -================= -*/ -void UI_PlayRec_Menu( void ) -{ - UI_PlayRec_Precache(); - UI_PlayRec_Init(); - - UI_PushMenu( &uiPlayRec.menu ); -} \ No newline at end of file diff --git a/legacy/menu_recdemo.cpp b/legacy/menu_recdemo.cpp deleted file mode 100644 index 66c3b774..00000000 --- a/legacy/menu_recdemo.cpp +++ /dev/null @@ -1,487 +0,0 @@ -/* -Copyright (C) 1997-2001 Id Software, Inc. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -#include "extdll.h" -#include "basemenu.h" -#include "utils.h" -#include "keydefs.h" - -#define ART_BANNER "gfx/shell/head_save" - -#define ID_BACKGROUND 0 -#define ID_BANNER 1 -#define ID_RECORD 2 -#define ID_DELETE 3 -#define ID_CANCEL 4 -#define ID_DEMOLIST 5 -#define ID_TABLEHINT 6 -#define ID_LEVELSHOT 7 -#define ID_MSGBOX 8 -#define ID_MSGTEXT 9 -#define ID_YES 10 -#define ID_NO 11 - -#define LEVELSHOT_X 72 -#define LEVELSHOT_Y 400 -#define LEVELSHOT_W 192 -#define LEVELSHOT_H 160 - -#define TITLE_LENGTH 32 -#define MAPNAME_LENGTH 24+TITLE_LENGTH -#define MAXCLIENTS_LENGTH 16+MAPNAME_LENGTH - -typedef struct -{ - char demoName[UI_MAXGAMES][CS_SIZE]; - char delName[UI_MAXGAMES][CS_SIZE]; - char demoDescription[UI_MAXGAMES][256]; - char *demoDescriptionPtr[UI_MAXGAMES]; - - menuFramework_s menu; - - menuBitmap_s background; - menuBitmap_s banner; - menuAction_s record; - menuAction_s remove; - menuAction_s cancel; - - menuScrollList_s demosList; - - menuBitmap_s levelShot; - menuAction_s hintMessage; - char hintText[MAX_HINT_TEXT]; - - // prompt dialog - menuAction_s msgBox; - menuAction_s promptMessage; - menuAction_s yes; - menuAction_s no; -} uiRecDemo_t; - -static uiRecDemo_t uiRecDemo; - -/* -================= -UI_MsgBox_Ownerdraw -================= -*/ -static void UI_MsgBox_Ownerdraw( void *self ) -{ - menuCommon_s *item = (menuCommon_s *)self; - - UI_FillRect( item->x, item->y, item->width, item->height, uiPromptBgColor ); -} - -static void UI_DeleteDialog( void ) -{ - // toggle main menu between active\inactive - // show\hide remove dialog - uiRecDemo.record.generic.flags ^= QMF_INACTIVE; - uiRecDemo.remove.generic.flags ^= QMF_INACTIVE; - uiRecDemo.cancel.generic.flags ^= QMF_INACTIVE; - uiRecDemo.demosList.generic.flags ^= QMF_INACTIVE; - - uiRecDemo.msgBox.generic.flags ^= QMF_HIDDEN; - uiRecDemo.promptMessage.generic.flags ^= QMF_HIDDEN; - uiRecDemo.no.generic.flags ^= QMF_HIDDEN; - uiRecDemo.yes.generic.flags ^= QMF_HIDDEN; - -} - -/* -================= -UI_RecDemo_KeyFunc -================= -*/ -static const char *UI_RecDemo_KeyFunc( int key, int down ) -{ - if( down && key == K_ESCAPE && uiRecDemo.record.generic.flags & QMF_INACTIVE ) - { - UI_DeleteDialog(); - return uiSoundNull; - } - return UI_DefaultKey( &uiRecDemo.menu, key, down ); -} - -/* -================= -UI_RecDemo_GetDemoList -================= -*/ -static void UI_RecDemo_GetDemoList( void ) -{ - char comment[256]; - char **filenames; - int i = 0, j, numFiles; - - filenames = FS_SEARCH( "demos/*.dem", &numFiles, TRUE ); - - if ( CL_IsActive () && !gpGlobals->demorecording && !gpGlobals->demoplayback ) - { - char maxClients[32]; - sprintf( maxClients, "%i", gpGlobals->maxClients ); - - // create new entry for current save game - strncpy( uiRecDemo.demoName[i], "new", CS_SIZE ); - StringConcat( uiRecDemo.demoDescription[i], gpGlobals->maptitle, TITLE_LENGTH ); - StringConcat( uiRecDemo.demoDescription[i], uiEmptyString, TITLE_LENGTH ); // fill remaining entries - StringConcat( uiRecDemo.demoDescription[i], "New Demo", MAPNAME_LENGTH ); - StringConcat( uiRecDemo.demoDescription[i], uiEmptyString, MAPNAME_LENGTH ); - StringConcat( uiRecDemo.demoDescription[i], maxClients, MAXCLIENTS_LENGTH ); - StringConcat( uiRecDemo.demoDescription[i], uiEmptyString, MAXCLIENTS_LENGTH ); - uiRecDemo.demoDescriptionPtr[i] = uiRecDemo.demoDescription[i]; - i++; - } - - for( j = 0; j < numFiles; i++, j++ ) - { - if( i >= UI_MAXGAMES ) break; - - if( !GET_DEMO_COMMENT( filenames[j], comment )) - { - if( strlen( comment )) - { - // get name string even if not found - C:_GetComment can be mark demos - // as etc - // get name string even if not found - SV_GetComment can be mark saves - // as etc - StringConcat( uiRecDemo.demoDescription[i], uiEmptyString, TITLE_LENGTH ); - StringConcat( uiRecDemo.demoDescription[i], comment, MAPNAME_LENGTH ); - StringConcat( uiRecDemo.demoDescription[i], uiEmptyString, MAXCLIENTS_LENGTH ); - uiRecDemo.demoDescriptionPtr[i] = uiRecDemo.demoDescription[i]; - COM_FileBase( filenames[j], uiRecDemo.demoName[i] ); - COM_FileBase( filenames[j], uiRecDemo.delName[i] ); - } - else uiRecDemo.demoDescriptionPtr[i] = NULL; - continue; - } - - // strip path, leave only filename (empty slots doesn't have demoname) - COM_FileBase( filenames[j], uiRecDemo.demoName[i] ); - COM_FileBase( filenames[j], uiRecDemo.delName[i] ); - - // fill demo desc - StringConcat( uiRecDemo.demoDescription[i], comment + CS_SIZE, TITLE_LENGTH ); - StringConcat( uiRecDemo.demoDescription[i], uiEmptyString, TITLE_LENGTH ); - StringConcat( uiRecDemo.demoDescription[i], comment, MAPNAME_LENGTH ); - StringConcat( uiRecDemo.demoDescription[i], uiEmptyString, MAPNAME_LENGTH ); // fill remaining entries - StringConcat( uiRecDemo.demoDescription[i], comment + CS_SIZE * 2, MAXCLIENTS_LENGTH ); - StringConcat( uiRecDemo.demoDescription[i], uiEmptyString, MAXCLIENTS_LENGTH ); - uiRecDemo.demoDescriptionPtr[i] = uiRecDemo.demoDescription[i]; - } - - for ( ; i < UI_MAXGAMES; i++ ) - uiRecDemo.demoDescriptionPtr[i] = NULL; - uiRecDemo.demosList.itemNames = (const char **)uiRecDemo.demoDescriptionPtr; - - if( strlen( uiRecDemo.demoName[0] ) == 0 || !CL_IsActive () || gpGlobals->demoplayback ) - uiRecDemo.record.generic.flags |= QMF_GRAYED; - else uiRecDemo.record.generic.flags &= ~QMF_GRAYED; - - if( strlen( uiRecDemo.delName[0] ) == 0 || !stricmp( gpGlobals->demoname, uiRecDemo.delName[uiRecDemo.demosList.curItem] )) - uiRecDemo.remove.generic.flags |= QMF_GRAYED; - else uiRecDemo.remove.generic.flags &= ~QMF_GRAYED; -} - -/* -================= -UI_RecDemo_Callback -================= -*/ -static void UI_RecDemo_Callback( void *self, int event ) -{ - menuCommon_s *item = (menuCommon_s *)self; - - if( event == QM_CHANGED ) - { - // never overwrite existing saves, because their names was never get collision - if( strlen( uiRecDemo.demoName[uiRecDemo.demosList.curItem] ) == 0 || !CL_IsActive() || gpGlobals->demoplayback ) - uiRecDemo.record.generic.flags |= QMF_GRAYED; - else uiRecDemo.record.generic.flags &= ~QMF_GRAYED; - - if( strlen( uiRecDemo.delName[uiRecDemo.demosList.curItem] ) == 0 || !stricmp( gpGlobals->demoname, uiRecDemo.delName[uiRecDemo.demosList.curItem] )) - uiRecDemo.remove.generic.flags |= QMF_GRAYED; - else uiRecDemo.remove.generic.flags &= ~QMF_GRAYED; - return; - } - - if( event != QM_ACTIVATED ) - return; - - switch( item->id ) - { - case ID_CANCEL: - UI_PopMenu(); - break; - case ID_RECORD: - if( gpGlobals->demorecording ) - { - CLIENT_COMMAND( FALSE, "stop" ); - uiRecDemo.record.generic.name = "Record"; - uiRecDemo.record.generic.statusText = "Record a new demo"; - uiRecDemo.remove.generic.flags &= ~QMF_GRAYED; - } - else if( strlen( uiRecDemo.demoName[uiRecDemo.demosList.curItem] )) - { - char cmd[128]; - - sprintf( cmd, "demos/%s.bmp", uiRecDemo.demoName[uiRecDemo.demosList.curItem] ); - PIC_Free( cmd ); - - sprintf( cmd, "record \"%s\"\n", uiRecDemo.demoName[uiRecDemo.demosList.curItem] ); - CLIENT_COMMAND( FALSE, cmd ); - UI_CloseMenu(); - } - break; - case ID_NO: - case ID_DELETE: - UI_DeleteDialog(); - break; - case ID_YES: - if( strlen( uiRecDemo.delName[uiRecDemo.demosList.curItem] )) - { - char cmd[128]; - sprintf( cmd, "killdemo \"%s\"\n", uiRecDemo.delName[uiRecDemo.demosList.curItem] ); - - CLIENT_COMMAND( TRUE, cmd ); - - sprintf( cmd, "demos/%s.bmp", uiRecDemo.delName[uiRecDemo.demosList.curItem] ); - PIC_Free( cmd ); - - // restarts the menu - UI_PopMenu(); - UI_RecDemo_Menu(); - return; - } - UI_DeleteDialog(); - break; - } -} - -/* -================= -UI_RecDemo_Ownerdraw -================= -*/ -static void UI_RecDemo_Ownerdraw( void *self ) -{ - menuCommon_s *item = (menuCommon_s *)self; - - if( item->type != QMTYPE_ACTION && item->id == ID_LEVELSHOT ) - { - int x, y, w, h; - - // draw the levelshot - x = LEVELSHOT_X; - y = LEVELSHOT_Y; - w = LEVELSHOT_W; - h = LEVELSHOT_H; - - UI_ScaleCoords( &x, &y, &w, &h ); - - if( strlen( uiRecDemo.demoName[uiRecDemo.demosList.curItem] )) - { - char demoshot[128]; - - sprintf( demoshot, "demos/%s.bmp", uiRecDemo.demoName[uiRecDemo.demosList.curItem] ); - - if( !FILE_EXISTS( demoshot )) - UI_DrawPicAdditive( x, y, w, h, uiColorWhite, "{GRAF001" ); - else UI_DrawPic( x, y, w, h, uiColorWhite, demoshot ); - } - else UI_DrawPicAdditive( x, y, w, h, uiColorWhite, "{GRAF001" ); - - // draw the rectangle - UI_DrawRectangle( item->x, item->y, item->width, item->height, uiInputFgColor ); - } -} - -/* -================= -UI_RecDemo_Init -================= -*/ -static void UI_RecDemo_Init( void ) -{ - memset( &uiRecDemo, 0, sizeof( uiRecDemo_t )); - - uiRecDemo.menu.vidInitFunc = UI_RecDemo_Init; - uiRecDemo.menu.keyFunc = UI_RecDemo_KeyFunc; - - StringConcat( uiRecDemo.hintText, "Title", TITLE_LENGTH ); - StringConcat( uiRecDemo.hintText, uiEmptyString, TITLE_LENGTH ); - StringConcat( uiRecDemo.hintText, "Map", MAPNAME_LENGTH ); - StringConcat( uiRecDemo.hintText, uiEmptyString, MAPNAME_LENGTH ); - StringConcat( uiRecDemo.hintText, "Max Clients", MAXCLIENTS_LENGTH ); - StringConcat( uiRecDemo.hintText, uiEmptyString, MAXCLIENTS_LENGTH ); - - uiRecDemo.background.generic.id = ID_BACKGROUND; - uiRecDemo.background.generic.type = QMTYPE_BITMAP; - uiRecDemo.background.generic.flags = QMF_INACTIVE; - uiRecDemo.background.generic.x = 0; - uiRecDemo.background.generic.y = 0; - uiRecDemo.background.generic.width = 1024; - uiRecDemo.background.generic.height = 768; - uiRecDemo.background.pic = ART_BACKGROUND; - - uiRecDemo.banner.generic.id = ID_BANNER; - uiRecDemo.banner.generic.type = QMTYPE_BITMAP; - uiRecDemo.banner.generic.flags = QMF_INACTIVE|QMF_DRAW_ADDITIVE; - uiRecDemo.banner.generic.x = UI_BANNER_POSX; - uiRecDemo.banner.generic.y = UI_BANNER_POSY; - uiRecDemo.banner.generic.width = UI_BANNER_WIDTH; - uiRecDemo.banner.generic.height = UI_BANNER_HEIGHT; - uiRecDemo.banner.pic = ART_BANNER; - - uiRecDemo.record.generic.id = ID_RECORD; - uiRecDemo.record.generic.type = QMTYPE_ACTION; - uiRecDemo.record.generic.flags = QMF_HIGHLIGHTIFFOCUS|QMF_DROPSHADOW; - uiRecDemo.record.generic.x = 72; - uiRecDemo.record.generic.y = 230; - - if( gpGlobals->demorecording ) - { - uiRecDemo.record.generic.name = "Stop"; - uiRecDemo.record.generic.statusText = "Stop a demo recording"; - } - else - { - uiRecDemo.record.generic.name = "Record"; - uiRecDemo.record.generic.statusText = "Record a new demo"; - } - uiRecDemo.record.generic.callback = UI_RecDemo_Callback; - - uiRecDemo.remove.generic.id = ID_DELETE; - uiRecDemo.remove.generic.type = QMTYPE_ACTION; - uiRecDemo.remove.generic.flags = QMF_HIGHLIGHTIFFOCUS|QMF_DROPSHADOW; - uiRecDemo.remove.generic.x = 72; - uiRecDemo.remove.generic.y = 280; - uiRecDemo.remove.generic.name = "Delete"; - uiRecDemo.remove.generic.statusText = "Delete a demo"; - uiRecDemo.remove.generic.callback = UI_RecDemo_Callback; - - uiRecDemo.cancel.generic.id = ID_CANCEL; - uiRecDemo.cancel.generic.type = QMTYPE_ACTION; - uiRecDemo.cancel.generic.flags = QMF_HIGHLIGHTIFFOCUS|QMF_DROPSHADOW; - uiRecDemo.cancel.generic.x = 72; - uiRecDemo.cancel.generic.y = 330; - uiRecDemo.cancel.generic.name = "Cancel"; - uiRecDemo.cancel.generic.statusText = "Return back to main menu"; - uiRecDemo.cancel.generic.callback = UI_RecDemo_Callback; - - uiRecDemo.hintMessage.generic.id = ID_TABLEHINT; - uiRecDemo.hintMessage.generic.type = QMTYPE_ACTION; - uiRecDemo.hintMessage.generic.flags = QMF_INACTIVE|QMF_SMALLFONT; - uiRecDemo.hintMessage.generic.color = uiColorHelp; - uiRecDemo.hintMessage.generic.name = uiRecDemo.hintText; - uiRecDemo.hintMessage.generic.x = 360; - uiRecDemo.hintMessage.generic.y = 225; - - uiRecDemo.levelShot.generic.id = ID_LEVELSHOT; - uiRecDemo.levelShot.generic.type = QMTYPE_BITMAP; - uiRecDemo.levelShot.generic.flags = QMF_INACTIVE; - uiRecDemo.levelShot.generic.x = LEVELSHOT_X; - uiRecDemo.levelShot.generic.y = LEVELSHOT_Y; - uiRecDemo.levelShot.generic.width = LEVELSHOT_W; - uiRecDemo.levelShot.generic.height = LEVELSHOT_H; - uiRecDemo.levelShot.generic.ownerdraw = UI_RecDemo_Ownerdraw; - - uiRecDemo.demosList.generic.id = ID_DEMOLIST; - uiRecDemo.demosList.generic.type = QMTYPE_SCROLLLIST; - uiRecDemo.demosList.generic.flags = QMF_HIGHLIGHTIFFOCUS|QMF_DROPSHADOW|QMF_SMALLFONT; - uiRecDemo.demosList.generic.x = 360; - uiRecDemo.demosList.generic.y = 255; - uiRecDemo.demosList.generic.width = 640; - uiRecDemo.demosList.generic.height = 440; - uiRecDemo.demosList.generic.callback = UI_RecDemo_Callback; - - uiRecDemo.msgBox.generic.id = ID_MSGBOX; - uiRecDemo.msgBox.generic.type = QMTYPE_ACTION; - uiRecDemo.msgBox.generic.flags = QMF_INACTIVE|QMF_HIDDEN; - uiRecDemo.msgBox.generic.ownerdraw = UI_MsgBox_Ownerdraw; // just a fill rectangle - uiRecDemo.msgBox.generic.x = 192; - uiRecDemo.msgBox.generic.y = 256; - uiRecDemo.msgBox.generic.width = 640; - uiRecDemo.msgBox.generic.height = 256; - - uiRecDemo.promptMessage.generic.id = ID_MSGBOX; - uiRecDemo.promptMessage.generic.type = QMTYPE_ACTION; - uiRecDemo.promptMessage.generic.flags = QMF_INACTIVE|QMF_DROPSHADOW|QMF_HIDDEN; - uiRecDemo.promptMessage.generic.name = "Delete selected demo?"; - uiRecDemo.promptMessage.generic.x = 315; - uiRecDemo.promptMessage.generic.y = 280; - - uiRecDemo.yes.generic.id = ID_YES; - uiRecDemo.yes.generic.type = QMTYPE_ACTION; - uiRecDemo.yes.generic.flags = QMF_HIGHLIGHTIFFOCUS|QMF_DROPSHADOW|QMF_HIDDEN; - uiRecDemo.yes.generic.name = "Ok"; - uiRecDemo.yes.generic.x = 380; - uiRecDemo.yes.generic.y = 460; - uiRecDemo.yes.generic.callback = UI_RecDemo_Callback; - - uiRecDemo.no.generic.id = ID_NO; - uiRecDemo.no.generic.type = QMTYPE_ACTION; - uiRecDemo.no.generic.flags = QMF_HIGHLIGHTIFFOCUS|QMF_DROPSHADOW|QMF_HIDDEN; - uiRecDemo.no.generic.name = "Cancel"; - uiRecDemo.no.generic.x = 530; - uiRecDemo.no.generic.y = 460; - uiRecDemo.no.generic.callback = UI_RecDemo_Callback; - - UI_RecDemo_GetDemoList(); - - UI_AddItem( &uiRecDemo.menu, (void *)&uiRecDemo.background ); - UI_AddItem( &uiRecDemo.menu, (void *)&uiRecDemo.banner ); - UI_AddItem( &uiRecDemo.menu, (void *)&uiRecDemo.record ); - UI_AddItem( &uiRecDemo.menu, (void *)&uiRecDemo.remove ); - UI_AddItem( &uiRecDemo.menu, (void *)&uiRecDemo.cancel ); - UI_AddItem( &uiRecDemo.menu, (void *)&uiRecDemo.hintMessage ); - UI_AddItem( &uiRecDemo.menu, (void *)&uiRecDemo.levelShot ); - UI_AddItem( &uiRecDemo.menu, (void *)&uiRecDemo.demosList ); - UI_AddItem( &uiRecDemo.menu, (void *)&uiRecDemo.msgBox ); - UI_AddItem( &uiRecDemo.menu, (void *)&uiRecDemo.promptMessage ); - UI_AddItem( &uiRecDemo.menu, (void *)&uiRecDemo.no ); - UI_AddItem( &uiRecDemo.menu, (void *)&uiRecDemo.yes ); -} - -/* -================= -UI_RecDemo_Precache -================= -*/ -void UI_RecDemo_Precache( void ) -{ - PIC_Load( ART_BACKGROUND ); - PIC_Load( ART_BANNER ); -} - -/* -================= -UI_RecDemo_Menu -================= -*/ -void UI_RecDemo_Menu( void ) -{ - if( !CheckGameDll( )) return; - - UI_RecDemo_Precache(); - UI_RecDemo_Init(); - - UI_PushMenu( &uiRecDemo.menu ); -} \ No newline at end of file From 3ec49ce1a068cf78754dea9f85f3b99683635832 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Sun, 11 Nov 2018 01:27:49 +0300 Subject: [PATCH 16/18] cs update --- Android.mk | 74 +++++--------------------------------------- CMakeLists.txt | 4 ++- font/FontManager.cpp | 3 +- menus/Scoreboard.cpp | 30 +++++++++--------- 4 files changed, 29 insertions(+), 82 deletions(-) diff --git a/Android.mk b/Android.mk index 0b9d71a7..c1f86319 100644 --- a/Android.mk +++ b/Android.mk @@ -12,7 +12,7 @@ ifeq ($(TARGET_ARCH_ABI),armeabi-v7a-hard) endif LOCAL_MODULE := menu -LOCAL_CPPFLAGS := -std=gnu++11 -DMAINUI_USE_STB -DMAINUI_USE_CUSTOM_FONT_RENDER -DNO_STL -fno-rtti -fno-exceptions -DMAINUI_RENDER_PICBUTTON_TEXT +LOCAL_CPPFLAGS := -std=gnu++11 -DMAINUI_USE_STB -DMAINUI_USE_CUSTOM_FONT_RENDER -DNO_STL -fno-rtti -fno-exceptions -DMAINUI_RENDER_PICBUTTON_TEXT -DCS16CLIENT LOCAL_C_INCLUDES := \ $(SDL_PATH)/include \ @@ -23,77 +23,19 @@ LOCAL_C_INCLUDES := \ $(LOCAL_PATH)/../engine/common \ $(LOCAL_PATH)/../utils/vgui/include \ $(LOCAL_PATH)/../public/ \ + $(LOCAL_PATH)/../dlls \ $(LOCAL_PATH)/menus \ $(LOCAL_PATH)/controls \ $(LOCAL_PATH)/font \ $(LOCAL_PATH)/utl \ - $(LOCAL_PATH)/model \ + $(LOCAL_PATH)/model LOCAL_SRC_FILES := \ - controls/Framework.cpp \ - controls/BaseItem.cpp \ - controls/Action.cpp \ - controls/Bitmap.cpp \ - controls/Editable.cpp \ - controls/CheckBox.cpp \ - controls/ItemsHolder.cpp \ - controls/Field.cpp \ - controls/PicButton.cpp \ - controls/Slider.cpp \ - controls/SpinControl.cpp \ - controls/YesNoMessageBox.cpp \ - controls/MessageBox.cpp \ - controls/Switch.cpp \ - controls/ProgressBar.cpp \ - controls/BaseWindow.cpp \ - controls/BackgroundBitmap.cpp \ - controls/Table.cpp \ - controls/TabView.cpp \ - controls/PlayerModelView.cpp \ - controls/ScrollView.cpp \ - menus/AdvancedControls.cpp \ - menus/Audio.cpp \ - menus/Configuration.cpp \ - menus/ConnectionProgress.cpp \ - menus/ConnectionWarning.cpp \ - menus/Controls.cpp \ - menus/CreateGame.cpp \ - menus/Credits.cpp \ - menus/CustomGame.cpp \ - menus/FileDialog.cpp \ - menus/GameOptions.cpp \ - menus/Gamepad.cpp \ - menus/InputDevices.cpp \ - menus/LoadGame.cpp \ - menus/Main.cpp \ - menus/Multiplayer.cpp \ - menus/NewGame.cpp \ - menus/PlayerIntroduceDialog.cpp \ - menus/PlayerSetup.cpp \ - menus/SaveLoad.cpp \ - menus/ServerBrowser.cpp \ - menus/TouchButtons.cpp \ - menus/Touch.cpp \ - menus/TouchEdit.cpp \ - menus/TouchOptions.cpp \ - menus/Video.cpp \ - menus/VideoModes.cpp \ - menus/VideoOptions.cpp \ - menus/dynamic/ScriptMenu.cpp \ - font/FontManager.cpp \ - font/BaseFontBackend.cpp \ - font/StbFont.cpp \ - font/BitmapFont.cpp \ - utl/unicode_strtools.cpp \ - EventSystem.cpp \ - BaseMenu.cpp \ - Btns.cpp \ - MenuStrings.cpp \ - Utils.cpp \ - Scissor.cpp \ - udll_int.cpp \ - CFGScript.cpp \ - EngineCallback.cpp \ + $(subst $(LOCAL_PATH)/,,$(shell find $(LOCAL_PATH) -name *.cpp)) \ + $(subst $(LOCAL_PATH)/,,$(shell find $(LOCAL_PATH)/controls -name *.cpp)) \ + $(subst $(LOCAL_PATH)/,,$(shell find $(LOCAL_PATH)/menus -name *.cpp)) \ + $(subst $(LOCAL_PATH)/,,$(shell find $(LOCAL_PATH)/utl -name *.cpp)) \ + $(subst $(LOCAL_PATH)/,,$(shell find $(LOCAL_PATH)/font -name *.cpp)) \ ../common/interface.cpp include $(BUILD_SHARED_LIBRARY) diff --git a/CMakeLists.txt b/CMakeLists.txt index ddaa0cbe..35e70dde 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,6 +63,7 @@ set(MAINUI_CONTROLS_SOURCES controls/TabView.cpp controls/PlayerModelView.cpp controls/ScrollView.cpp + controls/BaseClientWindow.cpp ) set(MAINUI_MENUS_SOURCES @@ -117,13 +118,14 @@ set(MAINUI_SOURCES ) if(CS16CLIENT) - add_definitions(-DCS16CLIENT) + add_definitions(-DCS16CLIENT -DMAINUI_RENDER_PICBUTTON_TEXT) list(APPEND MAINUI_SOURCES ${XASH_SDK}/common/interface.cpp menus/Scoreboard.cpp menus/client/JoinGame.cpp menus/client/JoinClass.cpp menus/client/ClientWindow.cpp + menus/client/BuyMenu.cpp ) endif() diff --git a/font/FontManager.cpp b/font/FontManager.cpp index d303835f..abe07265 100644 --- a/font/FontManager.cpp +++ b/font/FontManager.cpp @@ -92,7 +92,8 @@ void CFontManager::VidInit( void ) uiStatic.hHeavyBlur = CFontBuilder( DEFAULT_MENUFONT, UI_MED_CHAR_HEIGHT * scale, 1000 ) .SetHandleNum( QM_HEAVYBLUR ) - .SetBlurParams( 8, 1.75f ) + .SetBlurParams( 10, 2.0f ) // 1.75f ) // 1.75f ) + .SetScanlineParams( 3, 0.2 ) .Create(); #endif uiStatic.hConsoleFont = CFontBuilder( DEFAULT_CONFONT, UI_CONSOLE_CHAR_HEIGHT * scale, 500 ) diff --git a/menus/Scoreboard.cpp b/menus/Scoreboard.cpp index 4d5ad22f..8e9d767b 100644 --- a/menus/Scoreboard.cpp +++ b/menus/Scoreboard.cpp @@ -1,9 +1,13 @@ +#include "cl_dll/IGameClientExports.h" #include +#include "BaseMenu.h" #include "BaseWindow.h" #include "Action.h" #include "Table.h" #include "BaseModel.h" #include "Scoreboard.h" +#include "mathlib.h" +#include "const.h" #include "com_model.h" @@ -115,8 +119,6 @@ class CMenuScoreboard : public CMenuBaseWindow void Clear(); - bool bDrawStroke; - private: CMenuScoreboardModel CTs_model; CMenuScoreboardModel Ts_model; @@ -204,7 +206,7 @@ void CMenuScoreboard::Draw() } } } - snprintf( spectators_buf, sizeof( spectators_buf ), "%s: ", g_pClient->Localize( "Cstrike_TitlesTXT_Spectators" ) ); + snprintf( spectators_buf, sizeof( spectators_buf ), "%s: ", L( "Cstrike_TitlesTXT_Spectators" ) ); if( spectators.Count() ) { char temp[128]; @@ -261,12 +263,12 @@ void CMenuScoreboard::_Init() CTs_text.iFlags |= QMF_DISABLESCAILING; CTs_text.SetCharSize( QM_BIGFONT ); CTs_text.SetBackground( PackRGBA( 0, 0, 255, 64 ) ); - CTs_text.szName = g_pClient->Localize( "Cstrike_ScoreBoard_CT" ); + CTs_text.szName = L( "Cstrike_ScoreBoard_CT" ); Ts_text.iFlags |= QMF_DISABLESCAILING; Ts_text.SetCharSize( QM_BIGFONT ); Ts_text.SetBackground( PackRGBA( 255, 0, 0, 64 ) ); - Ts_text.szName = g_pClient->Localize( "Cstrike_ScoreBoard_Ter" ); + Ts_text.szName = L( "Cstrike_ScoreBoard_Ter" ); CTs_score.iFlags |= QMF_DISABLESCAILING; CTs_score.SetCharSize( QM_BIGFONT ); @@ -284,15 +286,15 @@ void CMenuScoreboard::_Init() CTs.iFlags |= QMF_DISABLESCAILING|QMF_INACTIVE; Ts.bShowScrollBar = CTs.bShowScrollBar = false; Ts.bDrawStroke = CTs.bDrawStroke = true; - Ts.iOutlineWidth = CTs.iOutlineWidth = 1; + Ts.iStrokeWidth = CTs.iStrokeWidth = 1; Ts.iStrokeColor = CTs.iStrokeColor = uiInputTextColor; Ts.iBackgroundColor = CTs.iBackgroundColor = 0; CTs.iHeaderColor = g_ColorBlue; - CTs.SetupColumn( 0, g_pClient->Localize( "Cstrike_TitlesTXT_PLAYERS" ), 0.4f ); + CTs.SetupColumn( 0, L( "Cstrike_TitlesTXT_PLAYERS" ), 0.3f ); CTs.SetupColumn( 1, "", 0.15f ); - CTs.SetupColumn( 2, g_pClient->Localize( "Cstrike_TitlesTXT_SCORE" ), 0.15f ); - CTs.SetupColumn( 3, g_pClient->Localize( "Cstrike_TitlesTXT_DEATHS" ), 0.15f ); - CTs.SetupColumn( 4, g_pClient->Localize( "Cstrike_TitlesTXT_LATENCY" ), 0.15f ); + CTs.SetupColumn( 2, L( "Cstrike_TitlesTXT_SCORE" ), 0.15f ); + CTs.SetupColumn( 3, L( "Cstrike_TitlesTXT_DEATHS" ), 0.2f ); + CTs.SetupColumn( 4, L( "Cstrike_TitlesTXT_LATENCY" ), 0.2f ); CTs.SetModel( &CTs_model ); CTs.SetCharSize( QM_DEFAULTFONT ); @@ -300,11 +302,11 @@ void CMenuScoreboard::_Init() Ts_model.isTerrorist = true; Ts.iFlags |= QMF_DISABLESCAILING|QMF_INACTIVE; Ts.iHeaderColor = g_ColorRed; - Ts.SetupColumn( 0, g_pClient->Localize( "Cstrike_TitlesTXT_PLAYERS" ), 0.4f ); + Ts.SetupColumn( 0, L( "Cstrike_TitlesTXT_PLAYERS" ), 0.4f ); Ts.SetupColumn( 1, "", 0.15f ); - Ts.SetupColumn( 2, g_pClient->Localize( "Cstrike_TitlesTXT_SCORE" ), 0.15f ); - Ts.SetupColumn( 3, g_pClient->Localize( "Cstrike_TitlesTXT_DEATHS" ), 0.15f ); - Ts.SetupColumn( 4, g_pClient->Localize( "Cstrike_TitlesTXT_LATENCY" ), 0.15f ); + Ts.SetupColumn( 2, L( "Cstrike_TitlesTXT_SCORE" ), 0.15f ); + Ts.SetupColumn( 3, L( "Cstrike_TitlesTXT_DEATHS" ), 0.15f ); + Ts.SetupColumn( 4, L( "Cstrike_TitlesTXT_LATENCY" ), 0.15f ); Ts.SetModel( &Ts_model ); Ts.SetCharSize( QM_DEFAULTFONT ); From 6c547de7ed32a3213cebb1a4ec6fb4cd71288640 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Sun, 11 Nov 2018 01:38:08 +0300 Subject: [PATCH 17/18] add cs menus --- controls/PicButton.cpp | 10 +- menus/PlayerSetup.cpp | 4 +- menus/Scoreboard.cpp | 8 +- menus/client/BuyMenu.cpp | 562 ++++++++++++++++++++++++++++++++++ menus/client/ClientWindow.cpp | 79 +++++ menus/client/ClientWindow.h | 66 ++++ menus/client/JoinClass.cpp | 238 ++++++++++++++ menus/client/JoinGame.cpp | 166 ++++++++++ 8 files changed, 1122 insertions(+), 11 deletions(-) create mode 100644 menus/client/BuyMenu.cpp create mode 100644 menus/client/ClientWindow.cpp create mode 100644 menus/client/ClientWindow.h create mode 100644 menus/client/JoinClass.cpp create mode 100644 menus/client/JoinGame.cpp diff --git a/controls/PicButton.cpp b/controls/PicButton.cpp index 3d04535a..a739175d 100644 --- a/controls/PicButton.cpp +++ b/controls/PicButton.cpp @@ -270,7 +270,7 @@ void CMenuPicButton::Draw( ) if( a > 0 ) { UI_DrawString( uiStatic.hHeavyBlur, m_scPos, m_scSize, szName, - InterpColor( uiColorBlack, iColor, a / 255.0f ), m_scChSize, eTextAlignment, textflags ); + InterpColor( uiColorBlack, colorBase, a / 255.0f ), m_scChSize, eTextAlignment, textflags ); } #endif UI_DrawString( font, m_scPos, m_scSize, szName, colorBase, m_scChSize, eTextAlignment, textflags ); @@ -280,8 +280,8 @@ void CMenuPicButton::Draw( ) if( eFocusAnimation == QM_HIGHLIGHTIFFOCUS ) { #ifdef MAINUI_RENDER_PICBUTTON_TEXT - UI_DrawString( uiStatic.hHeavyBlur, m_scPos, m_scSize, szName, iColor, m_scChSize, eTextAlignment, textflags ); - UI_DrawString( font, m_scPos, m_scSize, szName, iColor, m_scChSize, eTextAlignment, textflags ); + UI_DrawString( uiStatic.hHeavyBlur, m_scPos, m_scSize, szName, colorBase, m_scChSize, eTextAlignment, textflags ); + UI_DrawString( font, m_scPos, m_scSize, szName, colorBase, m_scChSize, eTextAlignment, textflags ); #else UI_DrawString( font, m_scPos, m_scSize, szName, colorFocus, m_scChSize, eTextAlignment, textflags ); #endif @@ -292,8 +292,8 @@ void CMenuPicButton::Draw( ) #ifdef MAINUI_RENDER_PICBUTTON_TEXT UI_DrawString( uiStatic.hHeavyBlur, m_scPos, m_scSize, szName, - InterpColor( uiColorBlack, iColor, pulsar ), m_scChSize, eTextAlignment, textflags ); - UI_DrawString( font, m_scPos, m_scSize, szName, iColor, m_scChSize, eTextAlignment, textflags ); + InterpColor( uiColorBlack, colorBase, pulsar ), m_scChSize, eTextAlignment, textflags ); + UI_DrawString( font, m_scPos, m_scSize, szName, colorBase, m_scChSize, eTextAlignment, textflags ); #else UI_DrawString( font, m_scPos, m_scSize, szName, InterpColor( colorBase, colorFocus, pulsar ), m_scChSize, eTextAlignment, textflags ); diff --git a/menus/PlayerSetup.cpp b/menus/PlayerSetup.cpp index b93ab941..697357e7 100644 --- a/menus/PlayerSetup.cpp +++ b/menus/PlayerSetup.cpp @@ -122,7 +122,7 @@ void CMenuPlayerSetup::CMenuLogoPreview::Draw() #ifdef NEW_ENGINE_INTERFACE UI_DrawString( font, m_scPos, m_scSize, "No logo", iColor, m_scChSize, QM_CENTER, ETF_SHADOW ); #else - UI_DrawString( font, m_scPos, m_scSize, "Coming soon!", iColor, m_scChSize, QM_CENTER, ETF_SHADOW ); + UI_DrawString( font, m_scPos, m_scSize, "Coming soon!", colorBase, m_scChSize, QM_CENTER, ETF_SHADOW ); #endif } else @@ -132,7 +132,7 @@ void CMenuPlayerSetup::CMenuLogoPreview::Draw() #ifndef NEW_ENGINE_INTERFACE UI_FillRect( m_scPos, m_scSize, uiColorBlack ); - UI_DrawString( font, m_scPos, m_scSize, "Coming soon!", iColor, m_scChSize, QM_CENTER, ETF_SHADOW ); + UI_DrawString( font, m_scPos, m_scSize, "Coming soon!", colorBase, m_scChSize, QM_CENTER, ETF_SHADOW ); #endif } diff --git a/menus/Scoreboard.cpp b/menus/Scoreboard.cpp index 8e9d767b..e05c8ced 100644 --- a/menus/Scoreboard.cpp +++ b/menus/Scoreboard.cpp @@ -248,7 +248,7 @@ void CMenuScoreboard::_Init() iFlags |= QMF_DISABLESCAILING; background.bForceColor = true; - background.iStrokeColor = uiInputTextColor; + background.colorStroke = uiInputTextColor; serverName.iFlags |= QMF_DISABLESCAILING; serverName.SetCharSize( QM_SMALLFONT ); @@ -281,13 +281,13 @@ void CMenuScoreboard::_Init() CTs_text.eTextAlignment = Ts_score.eTextAlignment = QM_LEFT; Ts_text.eTextAlignment = CTs_score.eTextAlignment = QM_RIGHT; - CTs_score.iColor = Ts_score.iColor = CTs_text.iColor = Ts_text.iColor = uiColorWhite; + CTs_score.colorBase = Ts_score.colorBase = CTs_text.colorBase = Ts_text.colorBase = uiColorWhite; CTs.iFlags |= QMF_DISABLESCAILING|QMF_INACTIVE; Ts.bShowScrollBar = CTs.bShowScrollBar = false; Ts.bDrawStroke = CTs.bDrawStroke = true; Ts.iStrokeWidth = CTs.iStrokeWidth = 1; - Ts.iStrokeColor = CTs.iStrokeColor = uiInputTextColor; + Ts.colorStroke = CTs.colorStroke = uiInputTextColor; Ts.iBackgroundColor = CTs.iBackgroundColor = 0; CTs.iHeaderColor = g_ColorBlue; CTs.SetupColumn( 0, L( "Cstrike_TitlesTXT_PLAYERS" ), 0.3f ); @@ -367,7 +367,7 @@ void UI_SetupScoreboard( int xstart, int xend, int ystart, int yend, unsigned in } scoreboard.bDrawStroke = drawStroke; - scoreboard.background.iColor = color; + scoreboard.background.colorBase = color; } void UI_VidInitScoreboard() diff --git a/menus/client/BuyMenu.cpp b/menus/client/BuyMenu.cpp new file mode 100644 index 00000000..da2c7256 --- /dev/null +++ b/menus/client/BuyMenu.cpp @@ -0,0 +1,562 @@ +#include "BaseMenu.h" +#include "ClientWindow.h" +#include "ScrollView.h" +#include "CheckBox.h" + +struct BuyMenuWeaponInfo +{ + const char *name, *image, *command, *name2; +}; + +class CClientBaseBuyMenu : public CClientWindow +{ +public: + virtual void Init() + { + if( !WasInit() ) + { + CClientWindow::Init(); + + if( eAmmoClass == BUY_EQUIPMENT ) + { + AddButton( '0', L("Cancel"), Point( 100, 580 ), VoidCb( &CMenuBaseItem::Hide )); + } + else + { + AddButton( '0', L("Cancel"), Point( 100, 530 ), VoidCb( &CMenuBaseItem::Hide )); + } + + if( eAmmoClass == BUY_PRIMAMMO ) + { + bitmap.SetSize( 400, 100 ); + } + else + { + bitmap.SetSize( 400, 200 ); + } + + bitmap.SetCoord( 400, 180 ); + bitmap.bDrawStroke = true; + bitmap.SetInactive( true ); + bitmap.eRenderMode = QM_DRAWTRANS; + bitmap.colorStroke = uiInputTextColor; + bitmap.iStrokeWidth = 1; + AddItem( bitmap ); + + int startH; + if( eAmmoClass == BUY_PRIMAMMO ) + { + startH = 300; + } + else + { + startH = 400; + } + + Point pt = Point( 400, startH ); + + confirm.SetRect( 700, startH, 100, 32 ); + confirm.onActivated = MenuCb( &CClientBaseBuyMenu::confirmCb ); + confirm.SetCharSize( QM_SMALLFONT ); + confirm.bDrawStroke = true; + confirm.colorStroke = uiInputTextColor; + confirm.iStrokeWidth = 1; + confirm.szName = L( "Buy" ); + confirm.SetBackground( 0U, PackRGBA( 255, 0, 0, 64 ) ); + AddItem( confirm ); + + priceLabel.SetInactive( true ); + priceLabel.pos = pt; + priceLabel.m_bLimitBySize = false; + priceLabel.szName = L("CStrike_PriceLabel"); + priceLabel.SetCharSize( QM_SMALLFONT ); + AddItem( priceLabel ); + const int height = g_FontMgr.GetFontTall( priceLabel.font ); + pt.y += height; + + originLabel.SetInactive( true ); + originLabel.pos = pt; + originLabel.m_bLimitBySize = false; + if( eAmmoClass == BUY_EQUIPMENT ) + originLabel.szName = L("CStrike_DescriptionLabel"); + else originLabel.szName = L("CStrike_OriginLabel"); + originLabel.SetCharSize( QM_SMALLFONT ); + AddItem( originLabel ); + pt.y += height; + + if( eAmmoClass != BUY_EQUIPMENT ) + { + calibreLabel.SetInactive( true ); + calibreLabel.pos = pt; + calibreLabel.m_bLimitBySize = false; + calibreLabel.szName = L("CStrike_CalibreLabel"); + calibreLabel.SetCharSize( QM_SMALLFONT ); + AddItem( calibreLabel ); + pt.y += height; + + clipLabel.SetInactive( true ); + clipLabel.pos = pt; + clipLabel.m_bLimitBySize = false; + clipLabel.szName = L("CStrike_ClipCapacityLabel"); + clipLabel.SetCharSize( QM_SMALLFONT ); + AddItem( clipLabel ); + pt.y += height; + + rofLabel.SetInactive( true ); + rofLabel.pos = pt; + rofLabel.m_bLimitBySize = false; + rofLabel.szName = L("CStrike_RateOfFireLabel"); + rofLabel.SetCharSize( QM_SMALLFONT ); + AddItem( rofLabel ); + pt.y += height; + + weightLabel.SetInactive( true ); + weightLabel.pos = pt; + weightLabel.m_bLimitBySize = false; + weightLabel.szName = L("CStrike_WeightEmptyLabel"); + weightLabel.SetCharSize( QM_SMALLFONT ); + AddItem( weightLabel ); + pt.y += height; + + projectLabel.SetInactive( true ); + projectLabel.pos = pt; + projectLabel.m_bLimitBySize = false; + projectLabel.szName = L("CStrike_ProjectileWeightLabel"); + projectLabel.SetCharSize( QM_SMALLFONT ); + AddItem( projectLabel ); + pt.y += height; + + muzzlevelLabel.SetInactive( true ); + muzzlevelLabel.pos = pt; + muzzlevelLabel.m_bLimitBySize = false; + muzzlevelLabel.szName = L("CStrike_MuzzleVelocityLabel"); + muzzlevelLabel.SetCharSize( QM_SMALLFONT ); + AddItem( muzzlevelLabel ); + pt.y += height; + + muzzleenLabel.SetInactive( true ); + muzzleenLabel.pos = pt; + muzzleenLabel.m_bLimitBySize = false; + muzzleenLabel.szName = L("CStrike_MuzzleEnergyLabel"); + muzzleenLabel.SetCharSize( QM_SMALLFONT ); + AddItem( muzzleenLabel ); + pt.y += height; + } + + pt = Point( 600, startH ); + + priceLabel_.SetInactive( true ); + priceLabel_.pos = pt; + priceLabel_.m_bLimitBySize = false; + priceLabel_.SetCharSize( QM_SMALLFONT ); + AddItem( priceLabel_ ); + pt.y += height; + + originLabel_.SetInactive( true ); + originLabel_.pos = pt; + originLabel_.m_bLimitBySize = eAmmoClass == BUY_EQUIPMENT; + originLabel_.SetCharSize( QM_SMALLFONT ); + originLabel_.SetSize( 200, 999 ); + AddItem( originLabel_ ); + pt.y += height; + + if( eAmmoClass != BUY_EQUIPMENT ) + { + calibreLabel_.SetInactive( true ); + calibreLabel_.pos = pt; + calibreLabel_.m_bLimitBySize = false; + calibreLabel_.SetCharSize( QM_SMALLFONT ); + AddItem( calibreLabel_ ); + pt.y += height; + + clipLabel_.SetInactive( true ); + clipLabel_.pos = pt; + clipLabel_.m_bLimitBySize = false; + clipLabel_.SetCharSize( QM_SMALLFONT ); + AddItem( clipLabel_ ); + pt.y += height; + + rofLabel_.SetInactive( true ); + rofLabel_.pos = pt; + rofLabel_.m_bLimitBySize = false; + rofLabel_.SetCharSize( QM_SMALLFONT ); + AddItem( rofLabel_ ); + pt.y += height; + + weightLabel_.SetInactive( true ); + weightLabel_.pos = pt; + weightLabel_.m_bLimitBySize = false; + weightLabel_.SetCharSize( QM_SMALLFONT ); + AddItem( weightLabel_ ); + pt.y += height; + + projectLabel_.SetInactive( true ); + projectLabel_.pos = pt; + projectLabel_.m_bLimitBySize = false; + projectLabel_.SetCharSize( QM_SMALLFONT ); + AddItem( projectLabel_ ); + pt.y += height; + + muzzlevelLabel_.SetInactive( true ); + muzzlevelLabel_.pos = pt; + muzzlevelLabel_.m_bLimitBySize = false; + muzzlevelLabel_.SetCharSize( QM_SMALLFONT ); + AddItem( muzzlevelLabel_ ); + pt.y += height; + + muzzleenLabel_.SetInactive( true ); + muzzleenLabel_.pos = pt; + muzzleenLabel_.m_bLimitBySize = false; + muzzleenLabel_.SetCharSize( QM_SMALLFONT ); + AddItem( muzzleenLabel_ ); + pt.y += height; + } + } + } + + virtual void Reload() + { + bitmap.SetPicture( NULL ); + bitmap.colorBase = 0x0; + confirm.Hide(); + priceLabel_.szName = + originLabel_.szName = + calibreLabel_.szName = + clipLabel_.szName = + rofLabel_.szName = + weightLabel_.szName = + projectLabel_.szName = + muzzlevelLabel_.szName = + muzzleenLabel_.szName = ""; + weightLabel.szName = L( "CStrike_WeightEmptyLabel" ); + } + + void AddWeapon( BuyMenuWeaponInfo info ) + { + weapons[numWeapons] = info; + + int key = '0' + numWeapons; + Point pt; + pt.x = 100; + pt.y = 180 + numWeapons * 50; + + CEventCallback cb_; + + cb_ = MenuCb( &CClientBaseBuyMenu::cb ); + cb_.pExtra = &weapons[numWeapons]; + + snprintf( buf, sizeof( buf ), "Cstrike_%s", info.name ); + + AddButton( key, L( buf ), pt, cb_ ); + + numWeapons++; + } + + CMenuBitmap bitmap; + CMenuAction confirm; + CMenuAction priceLabel, priceLabel_; + CMenuAction originLabel, originLabel_; + CMenuAction calibreLabel, calibreLabel_; + CMenuAction clipLabel, clipLabel_; + CMenuAction rofLabel, rofLabel_; + CMenuAction weightLabel, weightLabel_; + CMenuAction projectLabel, projectLabel_; + CMenuAction muzzlevelLabel, muzzlevelLabel_; + CMenuAction muzzleenLabel, muzzleenLabel_; + + BuyMenuWeaponInfo weapons[10]; + int numWeapons = 0; + + enum ammoClass_e + { + BUY_NONE, + BUY_PRIMAMMO, + BUY_SECAMMO, + BUY_EQUIPMENT + } eAmmoClass; + + char buf[1024]; + char buf2[1024]; + + void cb( void *pExtra ) + { + BuyMenuWeaponInfo *weapon = (BuyMenuWeaponInfo*)pExtra; + + confirm.Show(); + + snprintf( buf, sizeof( buf ), "CStrike_%sPrice", weapon->name2 ); + priceLabel_.szName = L( buf ); + + if( eAmmoClass == BUY_EQUIPMENT ) + { + snprintf( buf, sizeof( buf ), "CStrike_%sDescription", weapon->name2 ); + int i = 0; + for( const char *t = L( buf ); *t; t++ ) + { + if( *t == '\\' && *(t+1) == 'n' ) + { + t+=2; + continue; + } + buf2[i++] = *t; + } + originLabel_.szName = buf2; + } + else + { + snprintf( buf, sizeof( buf ), "CStrike_%sOrigin", weapon->name2 ); + originLabel_.szName = L( buf ); + + snprintf( buf, sizeof( buf ), "CStrike_%sCalibre", weapon->name2 ); + calibreLabel_.szName = L( buf ); + + snprintf( buf, sizeof( buf ), "CStrike_%sClipCapacity", weapon->name2 ); + clipLabel_.szName = L( buf ); + + snprintf( buf, sizeof( buf ), "CStrike_%sRateOfFire", weapon->name2 ); + rofLabel_.szName = L( buf ); + + snprintf( buf, sizeof( buf ), "CStrike_%sWeightEmpty", weapon->name2 ); + const char *tr = L( buf ); + + if( tr == buf ) // no translation + { + weightLabel.szName = L( "CStrike_WeightLoadedLabel" ); + snprintf( buf, sizeof( buf ), "CStrike_%sWeightLoaded", weapon->name2 ); + tr = L( buf ); + } + else + { + weightLabel.szName = L( "CStrike_WeightEmptyLabel" ); + } + + weightLabel_.szName = L( tr ); + + snprintf( buf, sizeof( buf ), "CStrike_%sProjectileWeight", weapon->name2 ); + projectLabel_.szName = L( buf ); + + snprintf( buf, sizeof( buf ), "CStrike_%sMuzzleVelocity", weapon->name2 ); + muzzlevelLabel_.szName = L( buf ); + + snprintf( buf, sizeof( buf ), "CStrike_%sMuzzleEnergy", weapon->name2 ); + muzzleenLabel_.szName = L( buf ); + } + + confirm.onActivated.pExtra = (void*)weapon->command; + + snprintf( buf, sizeof( buf ), "gfx/vgui/%s.tga", weapon->image ); + bitmap.SetPicture( buf ); + bitmap.colorBase = uiColorWhite; + } + + void confirmCb( void *pExtra ) + { + const char *command = (const char*)pExtra; + EngFuncs::ClientCmd( TRUE, command ); + + if( EngFuncs::GetCvarFloat( "ui_cs_autofill" )) + { + switch( eAmmoClass ) + { + case BUY_NONE: + break; + case BUY_PRIMAMMO: EngFuncs::ClientCmd( FALSE, "primammo" ); break; + case BUY_SECAMMO: EngFuncs::ClientCmd( FALSE, "secammo" ); break; + case BUY_EQUIPMENT: break; + } + } + Hide(); + } +}; +class CClientMainBuyMenu : public CClientWindow { +public: + virtual void _Init() override; + +private: + CMenuCheckBox autoFill; +}; +class CClientPistolsTMenu : public CClientBaseBuyMenu { virtual void _Init() override; }; +class CClientPistolsCTMenu : public CClientBaseBuyMenu { virtual void _Init() override; }; +class CClientShotgunsMenu : public CClientBaseBuyMenu { virtual void _Init() override; }; +class CClientSubMachineGunsTMenu : public CClientBaseBuyMenu { virtual void _Init() override; }; +class CClientSubMachineGunsCTMenu : public CClientBaseBuyMenu { virtual void _Init() override; }; +class CClientRiflesTMenu : public CClientBaseBuyMenu { virtual void _Init() override; }; +class CClientRiflesCTMenu : public CClientBaseBuyMenu { virtual void _Init() override; }; +class CClientMachineGunsMenu : public CClientBaseBuyMenu { virtual void _Init() override; }; +class CClientItemTMenu : public CClientBaseBuyMenu { virtual void _Init() override; }; +class CClientItemCTMenu : public CClientBaseBuyMenu { virtual void _Init() override; }; + +template +void Menu_Show( void ) +{ + static T menu; + menu.Show(); +} + +template +void Menu_Show_Team( int num ) { num == TEAM_TERRORIST ? Menu_Show() : Menu_Show(); } + +template +void Menu_Show_Team( CMenuBaseItem *item, void *pExtra ) { + item->Parent()->Hide(); + Menu_Show_Team( g_pClient->GetLocalPlayerTeam() ); +} + +void UI_BuyMenu_Show( int param1, int param2 ) { Menu_Show(); } +void UI_BuyMenu_Pistol_Show(int param1, int param2 ) { Menu_Show_Team( param2 ); } +void UI_BuyMenu_Shotgun_Show(int param1, int param2 ) { Menu_Show( ); } +void UI_BuyMenu_Submachine_Show(int param1, int param2 ) { Menu_Show_Team( param2 ); } +void UI_BuyMenu_Rifle_Show(int param1, int param2 ) { Menu_Show_Team( param2 ); } +void UI_BuyMenu_Machinegun_Show(int param1, int param2 ) { Menu_Show_Team( param2 ); } +void UI_BuyMenu_Item_Show(int param1, int param2 ) { Menu_Show_Team( param2 ); } + +void CClientMainBuyMenu::_Init() +{ + szName = L("Cstrike_Select_Category"); + + Point pt = Point( 100, 180 ); + AddButton( '1', L( "Cstrike_Pistols" ), pt, Menu_Show_Team ); + pt.y += 50; + AddButton( '2', L( "Cstrike_Shotguns" ), pt, Menu_Show_Team ); + pt.y += 50; + AddButton( '3', L( "Cstrike_SubMachineGuns" ), pt, Menu_Show_Team ); + pt.y += 50; + AddButton( '4', L( "Cstrike_Rifles" ), pt, Menu_Show_Team ); + pt.y += 50; + AddButton( '5', L( "Cstrike_MachineGuns" ), pt, Menu_Show_Team ); + pt.y += 50; + AddButton( '6', L( "Cstrike_Prim_Ammo" ), pt, ExecAndHide( "primammo" ) ); + pt.y += 50; + AddButton( '7', L( "Cstrike_Sec_Ammo" ), pt, ExecAndHide( "secammo" )); + pt.y += 50; + AddButton( '8', L( "Cstrike_Equipment" ), pt, Menu_Show_Team ); + pt.y += 50; + AddButton( '0', L( "Cancel" ), pt, VoidCb( &CMenuBaseItem::Hide ) ); + + pt.x = 400; + pt.y = 180; + AddButton( 0, L( "Cstrike_BuyMenuAutobuy" ), pt, ExecAndHide( "autobuy" ) ); + pt.y += 50; + AddButton( 0, L( "Cstrike_BuyMenuRebuy" ), pt, ExecAndHide( "rebuy" ) ); + pt.y += 50; + + autoFill.szName = L( "Auto buy ammo" ); + autoFill.pos = pt; + autoFill.SetCharSize( QM_SMALLFONT ); + autoFill.colorBase = uiPromptTextColor; + autoFill.LinkCvar( "ui_cs_autofill" ); + autoFill.onChanged = CMenuEditable::WriteCvarCb; + + AddItem( autoFill ); +} +void CClientPistolsTMenu::_Init() +{ + szName = L( "Cstrike_PistolsLabel" ); + eAmmoClass = BUY_SECAMMO; + + AddWeapon( BuyMenuWeaponInfo{ "Glock18", "glock18", "glock", "Glock" }); + AddWeapon( BuyMenuWeaponInfo{ "USP45", "usp45", "usp", "USP45" }); + AddWeapon( BuyMenuWeaponInfo{ "P228", "p228", "p228", "P228" }); + AddWeapon( BuyMenuWeaponInfo{ "DesertEagle", "deserteagle", "deagle", "DesertEagle" }); + AddWeapon( BuyMenuWeaponInfo{ "Elites", "elites", "elites", "Elites" }); + +} +void CClientPistolsCTMenu::_Init() +{ + szName = L( "Cstrike_PistolsLabel" ); + eAmmoClass = BUY_SECAMMO; + + AddWeapon( BuyMenuWeaponInfo{ "Glock18", "glock18", "glock", "Glock" }); + AddWeapon( BuyMenuWeaponInfo{ "USP45", "usp45", "usp", "USP45" }); + AddWeapon( BuyMenuWeaponInfo{ "P228", "p228", "p228", "P228" }); + AddWeapon( BuyMenuWeaponInfo{ "DesertEagle", "deserteagle", "deagle", "DesertEagle" }); + AddWeapon( BuyMenuWeaponInfo{ "FiveSeven", "fiveseven", "fiveseven", "FiveSeven" }); +} +void CClientShotgunsMenu::_Init() +{ + szName = L( "Cstrike_ShotgunsLabel" ); + eAmmoClass = BUY_PRIMAMMO; + + AddWeapon( BuyMenuWeaponInfo{ "M3", "m3", "m3", "M3" }); + AddWeapon( BuyMenuWeaponInfo{ "XM1014", "xm1014", "xm1014", "XM1014" }); +} + +void CClientSubMachineGunsTMenu::_Init() +{ + szName = L( "Cstrike_SubmachinegunsLabel" ); + eAmmoClass = BUY_PRIMAMMO; + + AddWeapon( BuyMenuWeaponInfo{ "MAC10", "mac10", "mac10", "MAC10" }); + AddWeapon( BuyMenuWeaponInfo{ "MP5", "mp5", "mp5", "MP5" }); + AddWeapon( BuyMenuWeaponInfo{ "UMP45", "ump45", "ump45", "UMP45" }); + AddWeapon( BuyMenuWeaponInfo{ "P90", "p90", "p90", "P90" }); +} +void CClientSubMachineGunsCTMenu::_Init() +{ + szName = L( "Cstrike_SubmachinegunsLabel" ); + eAmmoClass = BUY_PRIMAMMO; + + AddWeapon( BuyMenuWeaponInfo{ "Tmp", "tmp", "tmp", "TMP" }); + AddWeapon( BuyMenuWeaponInfo{ "MP5", "mp5", "mp5", "MP5" }); + AddWeapon( BuyMenuWeaponInfo{ "UMP45", "ump45", "ump45", "UMP45" }); + AddWeapon( BuyMenuWeaponInfo{ "P90", "p90", "p90", "P90" }); +} +void CClientRiflesTMenu::_Init() +{ + szName = L( "Cstrike_RiflesLabel" ); + eAmmoClass = BUY_PRIMAMMO; + + AddWeapon( BuyMenuWeaponInfo{ "Galil", "galil", "galil", "Galil" }); + AddWeapon( BuyMenuWeaponInfo{ "AK47", "ak47", "ak47", "AK47" }); + AddWeapon( BuyMenuWeaponInfo{ "Scout_TER", "scout", "scout", "Scout" }); + AddWeapon( BuyMenuWeaponInfo{ "SG552", "sg552", "sg552", "SG552" }); + AddWeapon( BuyMenuWeaponInfo{ "AWP_TER", "awp", "awp", "AWP" }); + AddWeapon( BuyMenuWeaponInfo{ "G3SG1", "g3sg1", "g3sg1", "G3SG1" }); + +} +void CClientRiflesCTMenu::_Init() +{ + szName = L( "Cstrike_RiflesLabel" ); + eAmmoClass = BUY_PRIMAMMO; + + AddWeapon( BuyMenuWeaponInfo{ "Famas", "famas", "famas", "Famas" }); + AddWeapon( BuyMenuWeaponInfo{ "Scout_CT", "scout", "scout", "Scout" }); + AddWeapon( BuyMenuWeaponInfo{ "M4A1", "m4a1", "m4a1", "M4A1" }); + AddWeapon( BuyMenuWeaponInfo{ "Aug", "aug", "aug", "Aug" }); + AddWeapon( BuyMenuWeaponInfo{ "SG550", "sg550", "sg550", "SG550" }); + AddWeapon( BuyMenuWeaponInfo{ "AWP_CT", "awp", "awp", "AWP" }); + +} +void CClientMachineGunsMenu::_Init() +{ + szName = L( "Cstrike_MachinegunsLabel" ); + eAmmoClass = BUY_PRIMAMMO; + + AddWeapon( BuyMenuWeaponInfo{ "M249", "m249", "m249", "M249" }); +} +void CClientItemTMenu::_Init() +{ + szName = L( "Cstrike_EquipmentLabel" ); + eAmmoClass = BUY_EQUIPMENT; + + AddWeapon( BuyMenuWeaponInfo{ "Kevlar", "kevlar", "vest", "Kevlar" }); + AddWeapon( BuyMenuWeaponInfo{ "Kevlar_Helmet", "kevlar_helmet", "vesthelm", "KevlarHelmet" }); + AddWeapon( BuyMenuWeaponInfo{ "Flashbang", "flashbang", "flash", "Flashbang" }); + AddWeapon( BuyMenuWeaponInfo{ "HE_Grenade", "hegrenade", "hegren", "Flashbang" }); + AddWeapon( BuyMenuWeaponInfo{ "Smoke_Grenade", "smokegrenade", "sgren", "SmokeGrenade" }); + AddWeapon( BuyMenuWeaponInfo{ "NightVision_Button_TER", "nightvision", "nvgs", "Nightvision" }); +} +void CClientItemCTMenu::_Init() +{ + szName = L( "Cstrike_EquipmentLabel" ); + eAmmoClass = BUY_EQUIPMENT; + + AddWeapon( BuyMenuWeaponInfo{ "Kevlar", "kevlar", "vest", "Kevlar" }); + AddWeapon( BuyMenuWeaponInfo{ "Kevlar_Helmet", "kevlar_helmet", "vesthelm", "KevlarHelmet" }); + AddWeapon( BuyMenuWeaponInfo{ "Flashbang", "flashbang", "flash", "Flashbang" }); + AddWeapon( BuyMenuWeaponInfo{ "HE_Grenade", "hegrenade", "hegren", "Flashbang" }); + AddWeapon( BuyMenuWeaponInfo{ "Smoke_Grenade", "smokegrenade", "sgren", "SmokeGrenade" }); + AddWeapon( BuyMenuWeaponInfo{ "Defuser", "defuser", "defuser", "Defuser" }); + AddWeapon( BuyMenuWeaponInfo{ "NightVision_Button_CT", "nightvision", "nvgs", "Nightvision" }); + AddWeapon( BuyMenuWeaponInfo{ "Shield", "shield", "shield", "Shield" }); +} diff --git a/menus/client/ClientWindow.cpp b/menus/client/ClientWindow.cpp new file mode 100644 index 00000000..73e058a1 --- /dev/null +++ b/menus/client/ClientWindow.cpp @@ -0,0 +1,79 @@ +#include "BaseMenu.h" +#include "ClientWindow.h" + +void CClientWindow::VidInit() +{ + size.w = 1024 - 100; + size.h = 768 - 100; + pos.x = (( ScreenWidth - uiStatic.scaleX * 1024 ) / 2) / uiStatic.scaleX + 50; + pos.y = 50; + + BaseClass::VidInit(); + roundCornerSize = Size( 16, 16 ).Scale(); + + iTitleHeight = 96 * uiStatic.scaleY; + iGap = 2 * uiStatic.scaleY > 1 ? 4 * uiStatic.scaleY : 1; +} + +void CClientWindow::Draw() +{ + UI_DrawPic( m_scPos, roundCornerSize, uiColorBlack, "gfx/vgui/round_corner_nw.tga", QM_DRAWTRANS ); + UI_DrawPic( m_scPos + Size( m_scSize.w - roundCornerSize.w, 0 ), roundCornerSize, uiColorBlack, "gfx/vgui/round_corner_ne.tga", QM_DRAWTRANS ); + UI_DrawPic( m_scPos + Size( 0, m_scSize.h - roundCornerSize.h ), roundCornerSize, uiColorBlack, "gfx/vgui/round_corner_sw.tga", QM_DRAWTRANS ); + UI_DrawPic( m_scPos + (m_scSize - roundCornerSize), roundCornerSize, uiColorBlack, "gfx/vgui/round_corner_se.tga", QM_DRAWTRANS ); + + UI_DrawPic( m_scPos + roundCornerSize, roundCornerSize * 4, PackAlpha( uiPromptTextColor, 255 ), "gfx/vgui/CS_logo.tga", QM_DRAWTRANS ); + + UI_DrawString( font, m_scPos + Size( roundCornerSize.w * 6, roundCornerSize.h ), Size( m_scSize.w - roundCornerSize.w * 6, roundCornerSize.h * 4 ), + szName, PackAlpha( uiPromptTextColor, 255 ), m_scChSize, QM_LEFT, ETF_NOSIZELIMIT ); + + UI_FillRect( m_scPos + Size( roundCornerSize.w, 0 ), Size( m_scSize.w - roundCornerSize.w * 2, roundCornerSize.h ), uiColorBlack ); + UI_FillRect( m_scPos + Size( 0, roundCornerSize.h ), Size( m_scSize.w, iTitleHeight - roundCornerSize.h ), uiColorBlack ); + + UI_FillRect( m_scPos + Size( 0, iTitleHeight + iGap ), Size( m_scSize.w, m_scSize.h - roundCornerSize.h - iTitleHeight - iGap ), uiColorBlack ); + UI_FillRect( m_scPos + Size( roundCornerSize.w, m_scSize.h - roundCornerSize.h ), Size( m_scSize.w - roundCornerSize.w * 2, roundCornerSize.h ), uiColorBlack ); + + BaseClass::Draw(); +} + +const char *CClientWindow::Key( int key, int down ) +{ + if( down && key >= '0' && key <= '9' ) + { + if( keys[key-'0'] ) + { + (keys[key-'0'])( buttons[0] ); + return uiSoundNull; + } + } + + return BaseClass::Key( key, down ); +} + +CMenuAction *CClientWindow::AddButton( int key, const char *name, Point pos, CEventCallback callback ) +{ + CMenuAction *act = new CMenuAction(); + + act->pos = pos; + act->onActivated = callback; + act->SetBackground( 0U, PackRGBA( 255, 0, 0, 64 ) ); + if( *name == '&' ) // fast hack + name++; + act->szName = name; + act->SetCharSize( QM_SMALLFONT ); + act->size = Size( 250, 32 ); + act->bDrawStroke = true; + act->m_bLimitBySize = true; + act->colorStroke = uiInputTextColor; + act->iStrokeWidth = 1; + + if( key >= '0' && key <= '9' ) + keys[key - '0'] = callback; + + buttons[m_iNumBtns] = act; + m_iNumBtns++; + + AddItem( act ); + + return act; +} diff --git a/menus/client/ClientWindow.h b/menus/client/ClientWindow.h new file mode 100644 index 00000000..9b2c7468 --- /dev/null +++ b/menus/client/ClientWindow.h @@ -0,0 +1,66 @@ +#pragma once + +#include "BaseClientWindow.h" +#include "Action.h" + +class CClientWindow : public CMenuBaseClientWindow +{ +public: + typedef CMenuBaseClientWindow BaseClass; + CClientWindow( const char *name = "CClientWindow" ) : BaseClass( name ) + { + // SetCharSize( QM_DEFAULTFONT ); + m_iNumBtns = 0; + } + ~CClientWindow() + { + for( int i = 0; i < m_iNumBtns; i++ ) + { + delete buttons[i]; + } + } + + void Show() override + { + if( m_pStack->menuDepth == 0 ) + { + EngFuncs::KEY_SetDest( KEY_MENU ); + EngFuncs::ClientCmd( TRUE, "touch_setclientonly 1"); + } + BaseClass::Show(); + + } + void Hide() override + { + BaseClass::Hide(); + if( m_pStack->menuDepth == 0 ) + { + EngFuncs::KEY_SetDest( KEY_GAME ); + EngFuncs::ClientCmd( FALSE, "touch_setclientonly 0"); + } + } + + CEventCallback ExecAndHide( const char *szCmd ) + { + return CEventCallback( []( CMenuBaseItem *pSelf, void *pExtra ) + { + pSelf->Parent()->Hide(); + EngFuncs::ClientCmd( FALSE, (const char*)pExtra ); + }, (void *)szCmd ); + } + + CMenuAction *AddButton( int key, const char *name, Point pos, CEventCallback callback ); + + const char *Key( int key, int down ) override; + void VidInit() override; + void Draw() override; + CEventCallback keys[10]; + +protected: + CMenuAction *buttons[16]; + int m_iNumBtns; +private: + Size roundCornerSize; + int iTitleHeight; + int iGap; +}; diff --git a/menus/client/JoinClass.cpp b/menus/client/JoinClass.cpp new file mode 100644 index 00000000..752321ef --- /dev/null +++ b/menus/client/JoinClass.cpp @@ -0,0 +1,238 @@ +#include "BaseMenu.h" +#include "ClientWindow.h" +#include "PlayerModelView.h" + +class CClientJoinClass : public CClientWindow +{ +public: + typedef CClientWindow BaseClass; + CClientJoinClass() : BaseClass( "CClientJoinClass" ) {} + + CEventCallback MakeCb( const char *cmd ) + { + return CEventCallback( MenuCb( &CClientJoinClass::cb ), (void*)cmd ); + } + + void _Init(); + void Reload(); + + CMenuAction *AddButton( int key, const char *name, const char *modelname, Point pos ); + + bool hasCzero; + bool hasCancel; + CMenuAction *confirm; + CMenuAction *cancel; + CMenuPlayerModelView player; + CMenuAction text; + + void ConfirmSelection() + { + EngFuncs::ClientCmd( FALSE, command ); + Hide(); + } + +private: + const char *command; + char textbuffer[1024]; + + void cb( void *pExtra ) + { + const char *sz = (const char *)pExtra; + const char *loctext; + char model[256]; + static const char *table[5 * 6] = + { + "terror", "urban", "joinclass 1", "Cstrike_Terror_Label", "Cstrike_Urban_Label", + "leet", "gsg9", "joinclass 2", "Cstrike_Leet_Label", "Cstrike_GSG9_Label", + "arctic", "sas", "joinclass 3", "Cstrike_Arctic_Label", "Cstrike_SAS_Label", + "guerilla", "gign", "joinclass 4", "Cstrike_Guerilla_Label", "Cstrike_GIGN_Label", + "militia", "spetsnaz", "joinclass 5", "Cstrike_Militia_Label", "Cstrike_Spetsnaz_Label", + "ct_random", "t_random", "joinclass 6", "Cstrike_AutoSelect_Label", "Cstrike_AutoSelect_Label", + }; + + confirm->Show(); + + int i; + for( i = 0; i <= 5 * 6; i += 5 ) + { + if( !strcmp( sz, table[i+0]) ) + { + command = table[i+2]; + loctext = L( table[i+3] ); + break; + } + + if( !strcmp( sz, table[i+1]) ) + { + command = table[i+2]; + loctext = L( table[i+4] ); + break; + } + } + + bool showModel = true; + + if( i >= 5 * 5 ) + showModel = false; + + i = 0; + const char *t = loctext; + while( t && *t && i < sizeof( textbuffer ) - 1 ) + { + if( *t == '\\' && *(t+1) == 'n' ) + { + t += 2; + } + else + { + textbuffer[i] = *t; + i++; + t++; + } + } + textbuffer[i] = '\0'; + + if( showModel ) // try to load model + { + snprintf( model, sizeof( model ), "models/player/%s/%s.mdl", sz, sz ); + + player.eOverrideMode = CMenuPlayerModelView::PMV_SHOWMODEL; + player.ent->model = g_pClient->LoadModel( model, &player.ent->curstate.modelindex ); + if( !player.ent->model ) + showModel = false; + } + + if( !showModel ) // failed, load picture + { + snprintf( model, sizeof( model ), "gfx/vgui/%s.tga", sz ); + + player.hPlayerImage = EngFuncs::PIC_Load( model ); + player.eOverrideMode = CMenuPlayerModelView::PMV_SHOWIMAGE; + } + } +}; + +static class CClientJoinClassT: public CClientJoinClass +{ + typedef CClientJoinClass BaseClass; +public: + void _Init(); +} uiJoinClassT; + +static class CClientJoinClassCT: public CClientJoinClass +{ + typedef CClientJoinClass BaseClass; +public: + void _Init(); +} uiJoinClassCT; + +void CClientJoinClass::_Init() +{ + confirm = CClientWindow::AddButton( 0, L( "CONFIRM CLASS" ), + Point( 100, 480 ), CEventCallback( VoidCb( &CClientJoinClass::ConfirmSelection ))); + + cancel = CClientWindow::AddButton( '0', L( "Cancel" ), + Point( 100, 530 ), CEventCallback( VoidCb( &CMenuBaseWindow::Hide ) ) ); + + player.SetRect( 400, 180, 284, 284 ); + player.backgroundColor = uiColorBlack; + player.colorStroke = uiPromptTextColor; + player.iStrokeWidth = 1; + player.eFocusAnimation = QM_NOFOCUSANIMATION; + player.iFlags |= QMF_INACTIVE; + player.bDrawAsPlayer = false; + + text.SetRect( 400, 500, 400, 200 ); + text.SetBackground( 0U ); + text.iFlags |= QMF_INACTIVE; + text.SetCharSize( QM_SMALLFONT ); + text.szName = textbuffer; + + szName = L( "Cstrike_Join_Class" ); + AddItem( player ); + AddItem( text ); +} + +void CClientJoinClass::Reload() +{ + if( hasCancel ) + { + keys[0] = cancel->onActivated; + cancel->Show(); + } + else + { + keys[0].Reset(); + cancel->Hide(); + } + + confirm->Hide(); + textbuffer[0] = 0; + //if( player.ent ) + // memset( player.ent, 0, sizeof( player.ent )); + player.ent->angles[1] += 15; +} + + +CMenuAction *CClientJoinClass::AddButton( int key, const char *name, const char *modelname, Point pos ) +{ + CMenuAction *act = CClientWindow::AddButton( key, name, pos, MakeCb( modelname ) ); + + act->szStatusText = modelname; + + return act; +} + +void CClientJoinClassT::_Init() +{ + AddButton( '1', L( "Cstrike_Terror" ), "terror", + Point( 100, 180 )); + AddButton( '2', L( "Cstrike_L337_Krew" ), "leet", + Point( 100, 230 )); + AddButton( '3', L( "Cstrike_Arctic" ), "arctic", + Point( 100, 280 )); + AddButton( '4', L( "Cstrike_Guerilla" ), "guerilla", + Point( 100, 330 )); + if( hasCzero ) + AddButton( '5', L( "Cstrike_Militia" ), "militia", + Point( 100, 380 )); + AddButton( '6', L( "Cstrike_Auto_Select" ), "t_random", + Point( 100, 430 )); + + BaseClass::_Init(); +} + +void CClientJoinClassCT::_Init() +{ + AddButton( '1', L( "Cstrike_Urban" ), "urban", + Point( 100, 180 )); + AddButton( '2', L( "Cstrike_GSG9" ), "gsg9", + Point( 100, 230 )); + AddButton( '3', L( "Cstrike_SAS" ), "sas", + Point( 100, 280 )); + AddButton( '4', L( "Cstrike_GIGN" ), "gign", + Point( 100, 330 )); + if( hasCzero ) + AddButton( '5', L( "Cstrike_Spetsnaz" ), "spetsnaz", + Point( 100, 380 )); + AddButton( '6', L( "Cstrike_Auto_Select" ), "ct_random", + Point( 100, 430 )); + + BaseClass::_Init(); +} + +void UI_JoinClassT_Show( int param1, int param2 ) +{ + uiJoinClassT.hasCzero = param1; + uiJoinClassT.hasCancel = param2; + EngFuncs::KEY_SetDest( KEY_MENU ); + uiJoinClassT.Show(); +} + +void UI_JoinClassCT_Show( int param1, int param2 ) +{ + uiJoinClassCT.hasCzero = param1; + uiJoinClassCT.hasCancel = param2; + EngFuncs::KEY_SetDest( KEY_MENU ); + uiJoinClassCT.Show(); +} diff --git a/menus/client/JoinGame.cpp b/menus/client/JoinGame.cpp new file mode 100644 index 00000000..ca0076df --- /dev/null +++ b/menus/client/JoinGame.cpp @@ -0,0 +1,166 @@ +#include "BaseMenu.h" +#include "ClientWindow.h" +#include "ScrollView.h" + +static class CClientJoinGame : public CClientWindow +{ +public: + typedef CClientWindow BaseClass; + CClientJoinGame() : BaseClass( "CClientJoinGame" ) {} + + void _Init(); + void Reload(); + void Draw(); + + bool hasSpectator; + bool hasVIP; + bool hasCancel; + CMenuAction *spectate; + CMenuAction *vipbutton; + CMenuAction *confirm; + CMenuAction *cancel; + CMenuAction text; + CMenuScrollView scroll; + + CEventCallback MakeCb( const char *cmd ) + { + return CEventCallback( MenuCb( &CClientJoinGame::cb ), (void*)cmd ); + } + +private: + const char *command; + char textbuffer[1024]; + + void ConfirmSelection() + { + EngFuncs::ClientCmd( FALSE, command ); + Hide(); + } + + void cb( void *pExtra ) + { + command = (const char*)pExtra; + confirm->Show(); + } + +} uiJoinGame; + +void CClientJoinGame::_Init() +{ + AddButton( '1', L( "Cstrike_Terrorist_Forces" ), + Point( 100, 180 ), MakeCb( "jointeam 1" )); + AddButton( '2', L( "Cstrike_CT_Forces" ), + Point( 100, 230 ), MakeCb( "jointeam 2" )); + vipbutton = AddButton( '3', L( "Cstrike_VIP_Team" ), + Point( 100, 280 ), MakeCb( "jointeam 3" )); + + AddButton( '5', L( "Cstrike_Team_AutoAssign" ), + Point( 100, 380 ), MakeCb( "jointeam 5" )); + spectate = AddButton( '6', L( "Cstrike_Menu_Spectate" ), + Point( 100, 430 ), MakeCb( "jointeam 6" )); + + confirm = AddButton( 0, L( "Cstrike_Join_Team" ), + Point( 100, 480 ), CEventCallback( VoidCb( &CClientJoinGame::ConfirmSelection ))); + + cancel = AddButton( '0', L( "Cancel" ), + Point( 100, 530 ), CEventCallback( VoidCb( &CMenuBaseWindow::Hide ) ) ); + + scroll.SetRect( 400, 180, 400, 200 ); + scroll.bDrawStroke = true; + scroll.colorStroke = uiInputTextColor; + scroll.iStrokeWidth = 1; + + text.SetRect( 0, 0, scroll.size.w, 0); + text.SetBackground( 0U ); + text.SetInactive( true ); + text.SetCharSize( QM_SMALLFONT ); + text.szName = textbuffer; + text.m_bLimitBySize = false; + + scroll.AddItem( text ); + AddItem( scroll ); + + szName = L("Cstrike_Join_Team"); +} + +void CClientJoinGame::Reload() +{ + if( hasSpectator ) + { + spectate->Show(); + keys[6] = spectate->onActivated; + } + else + { + keys[6].Reset(); + spectate->Hide(); + } + + if( hasVIP ) + { + keys[3] = vipbutton->onActivated; + vipbutton->Show(); + } + else + { + keys[3].Reset(); + vipbutton->Hide(); + } + + if( hasCancel ) + { + keys[0] = cancel->onActivated; + cancel->Show(); + } + else + { + keys[0].Reset(); + cancel->Hide(); + } + + confirm->Hide(); + + const char *mapname; + + if( (mapname = g_pClient->GetLevelName())[0] ) + { + char buf[256]; + snprintf( buf, 256, "maps/%s.txt", mapname ); + + char *txt = (char*)EngFuncs::COM_LoadFile( buf ); + + if( txt ) + { + Q_strncpy( textbuffer, txt, sizeof( textbuffer )); + + EngFuncs::COM_FreeFile( txt ); + } + else + { + Q_strncpy( textbuffer, L( "Cstrike_TitlesTXT_Map_Description_not_available" ), sizeof( textbuffer )); + } + } + else + { + Q_strncpy( textbuffer, L( "Cstrike_TitlesTXT_Map_Description_not_available" ), sizeof( textbuffer )); + } + + text.size.h = 0; // recalc + scroll.VidInit(); +} + +void CClientJoinGame::Draw() +{ + // HACK! + BaseClass::Draw(); +} + +void UI_JoinGame_Show( int param1, int param2 ) +{ + uiJoinGame.hasSpectator = param1 & 1; + uiJoinGame.hasVIP = param1 & 2; + uiJoinGame.hasCancel = param1 & 4; + + EngFuncs::KEY_SetDest( KEY_MENU ); + uiJoinGame.Show(); +} From 77eae748ecca572226db7a05f58dedd5d56b5167 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Fri, 14 Dec 2018 21:57:15 +0300 Subject: [PATCH 18/18] Update interface --- udll_int.cpp | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/udll_int.cpp b/udll_int.cpp index e802be79..23cd8361 100644 --- a/udll_int.cpp +++ b/udll_int.cpp @@ -13,11 +13,10 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ - +#include "cl_dll/IGameClientExports.h" #include "extdll_menu.h" #include "BaseMenu.h" #include "Utils.h" -#include "cl_dll/IGameClientExports.h" #include "Scoreboard.h" ui_enginefuncs_t EngFuncs::engfuncs; @@ -88,12 +87,12 @@ void UI_JoinGame_Show( int param1, int param2 ); void UI_JoinClassT_Show( int param1, int param2 ); void UI_JoinClassCT_Show( int param1, int param2 ); void UI_BuyMenu_Show( int param1, int param2 ); -void UI_BuyMenu_Pistol_Show( int param1, int param2 ); -void UI_BuyMenu_Shotgun_Show( int param1, int param2 ); -void UI_BuyMenu_Submachine_Show( int param1, int param2 ); -void UI_BuyMenu_Rifle_Show( int param1, int param2 ); -void UI_BuyMenu_Machinegun_Show( int param1, int param2 ); -void UI_BuyMenu_Item_Show( int param1, int param2 ); +void UI_BuyMenu_Pistol_Show(int param1, int param2 ); +void UI_BuyMenu_Shotgun_Show(int param1, int param2 ); +void UI_BuyMenu_Submachine_Show(int param1, int param2 ); +void UI_BuyMenu_Rifle_Show(int param1, int param2 ); +void UI_BuyMenu_Machinegun_Show(int param1, int param2 ); +void UI_BuyMenu_Item_Show(int param1, int param2 ); static class CGameMenuExports : public IGameMenuExports { @@ -105,6 +104,11 @@ static class CGameMenuExports : public IGameMenuExports return g_pClient ? true : false; } + const char *L( const char *szStr ) override + { + return ::L( szStr ); + } + bool IsActive() override { return uiStatic.client.IsActive() && !uiStatic.menu.IsActive(); @@ -183,6 +187,13 @@ static class CGameMenuExports : public IGameMenuExports case MENU_TEAM: UI_JoinGame_Show( param1, param2 ); break; case MENU_CLASS_T: UI_JoinClassT_Show( param1, param2 ); break; case MENU_CLASS_CT: UI_JoinClassCT_Show( param1, param2 ); break; + case MENU_BUY: UI_BuyMenu_Show( param1, param2 ); break; + case MENU_BUY_PISTOL: UI_BuyMenu_Pistol_Show( param1, param2 ); break; + case MENU_BUY_SHOTGUN: UI_BuyMenu_Shotgun_Show( param1, param2 ); break; + case MENU_BUY_RIFLE: UI_BuyMenu_Rifle_Show( param1, param2 ); break; + case MENU_BUY_SUBMACHINEGUN: UI_BuyMenu_Submachine_Show( param1, param2 ); break; + case MENU_BUY_MACHINEGUN: UI_BuyMenu_Machinegun_Show( param1, param2 ); break; + case MENU_BUY_ITEM: UI_BuyMenu_Item_Show( param1, param2 ); break; } } } s_Menu;