Skip to content

Commit

Permalink
- Added a fix for the menu interact bug, the menu will now properly c…
Browse files Browse the repository at this point in the history
…lose on exit.
  • Loading branch information
BerntA committed Jun 6, 2021
1 parent be17c43 commit 87e1541
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 20 deletions.
Binary file modified bin/client.dll
Binary file not shown.
Binary file modified bin/ms.dll
Binary file not shown.
2 changes: 2 additions & 0 deletions cl_dll/MasterSword/CLPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1168,6 +1168,7 @@ void __CmdFunc_ToggleServerBrowser(void);
bool fBroswerVisible();
void ShowVGUIMenu(int iMenu);
void Player_UseStamina(float flAddAmt);
extern float g_fMenuLastClosed;

int __MsgFunc_CLDllFunc(const char *pszName, int iSize, void *pbuf)
{
Expand All @@ -1187,6 +1188,7 @@ int __MsgFunc_CLDllFunc(const char *pszName, int iSize, void *pbuf)

player.Spawn();
logfile << "Player Successfully Spawned" << endl;
g_fMenuLastClosed = 0.0f;
break;
case 1: //Killed
if (player.m_CharacterState == CHARSTATE_UNLOADED)
Expand Down
29 changes: 16 additions & 13 deletions cl_dll/MasterSword/vgui_menu_interact.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ enum interactbtn_e
INTERACT_FORGIVE,
INTERACT_CANCEL
};

extern void IN_UseUp();
extern float g_fMenuLastClosed;

void ShowWeaponDesc(CGenericItem *pItem);

// Interact Menu
Expand Down Expand Up @@ -55,11 +59,14 @@ class VGUI_MenuInteract : public VGUI_MenuBase

void Open()
{
IN_UseUp();

m_Title->setFont(g_FontTitle);
m_Title->setText(Localized("#MENU_INTERACT_TITLE"));
m_LastButton = 0;
m_EntIdx = -1;
m_Options.clearitems();

for (int i = 0; i < m_Buttons.size(); i++) //Reset all buttons except cance
{
m_Buttons[i]->setVisible(false);
Expand Down Expand Up @@ -95,10 +102,10 @@ class VGUI_MenuInteract : public VGUI_MenuBase
g_FontTitle->getTextSize(NPCName, textw, texth);
//Thothie JAN2008a can't figure how title text centers self
//- so always using small text as it looks less odd uncentered
/*if( textw >= (m_pMainPanel->getWide()-XRES(5)) )
/*if( textw >= (m_pMainPanel->getWide()-XRES(5)) )
{
m_Title->setFont( g_FontSml );
m_Title->setText( NPCName );
m_Title->setFont( g_FontSml );
m_Title->setText( NPCName );
}*/

m_Title->setFont(g_FontSml); //JAN2008a - see above
Expand Down Expand Up @@ -131,9 +138,9 @@ class VGUI_MenuInteract : public VGUI_MenuBase
//Thothie JAN2007a - was: m_pMainPanel->setSize(w,YRES(72) + YRES(m_Options.size()*20 ) );
//- change to attempt to get more width out of menus
m_pMainPanel->setSize(XRES(200), YRES(72) + YRES((m_Options.size() + 1) * 20)); //Dynamically change the menu size to fit all number of options.
// 50 (header size)
// 22 (button size - cancel isn't included in m_Options)
// 72 (Total displacement)
// 50 (header size)
// 22 (button size - cancel isn't included in m_Options)
// 72 (Total displacement)
//[/MiB]

SetButton(m_LastButton++, Localized(MenuOption.Title), MenuOption.Type);
Expand Down Expand Up @@ -166,13 +173,8 @@ class VGUI_MenuInteract : public VGUI_MenuBase

void Select(int BtnIdx, msvariant &Data)
{
//Thothie AUG2013 - attempting to fix new steam bug that causes +use not to release when menu closes
//so far, all failed
//player.pev->button = 0;
//player.ClearConditions(IN_USE);
//player.pbs.ButtonsDown = 0;
//gHUD.m_Spectator.HandleButtonsUp( IN_USE );
//player.m_StatusFlags = ClearBits(player.m_StatusFlags,IN_USE);
IN_UseUp();
g_fMenuLastClosed = gEngfuncs.GetClientTime();

bool SendCmd = true;
if (BtnIdx >= 0 && BtnIdx < (signed)m_Options.size())
Expand Down Expand Up @@ -215,6 +217,7 @@ void VGUI_ShowMenuInteract()
VGUI_MainPanel *pPanel = VGUI::FindPanel(INTERACT_MENU_NAME);
if (!pPanel)
return;

VGUI_MenuInteract *pInteractPanel = (VGUI_MenuInteract *)pPanel;

int EntIdx = READ_LONG();
Expand Down
3 changes: 3 additions & 0 deletions cl_dll/MasterSword/vgui_menubase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,11 @@
#include "vgui_MenuBase.h"
#include "vgui_Menu_Main.h"
#include "vgui_Menu_Interact.h"

//------------

float g_fMenuLastClosed = 0.0f;

CAction_SelectMainOption::CAction_SelectMainOption(class VGUI_MenuBase *pPanel, int iValue, msvariant Data)
{
m_pPanel = pPanel;
Expand Down
3 changes: 3 additions & 0 deletions cl_dll/cdll_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ extern "C"
cl_enginefunc_t gEngfuncs;
CHud gHUD;
TeamFortressViewport *gViewPort = NULL;
extern float g_fMenuLastClosed;

// IMAGE-SPACE GLOW - Thothie TWHL JUN2010_22 - see comments in CLRender.cpp
extern void InitScreenGlow(void);
Expand Down Expand Up @@ -305,6 +306,8 @@ the hud variables.

void DLLEXPORT HUD_Init(void)
{
g_fMenuLastClosed = 0.0f;

DBG_INPUT;
startdbg;

Expand Down
7 changes: 7 additions & 0 deletions cl_dll/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ int CL_ButtonBits(int);

// xxx need client dll function to get and clear impuse
extern cvar_t *in_joystick;
extern float g_fMenuLastClosed;

int in_impulse = 0;
int in_cancel = 0;
Expand Down Expand Up @@ -806,6 +807,12 @@ void DLLEXPORT CL_CreateMove(float frametime, struct usercmd_s *cmd, int active)
//
cmd->buttons = CL_ButtonBits(1);

if ((cmd->buttons & IN_USE) && ((gEngfuncs.GetClientTime() - g_fMenuLastClosed) < 0.5f))
{
cmd->buttons &= ~IN_USE;
IN_UseUp();
}

// If they're in a modal dialog, ignore the attack button.
if (GetClientVoiceMgr()->IsInSquelchMode())
cmd->buttons &= ~IN_ATTACK;
Expand Down
7 changes: 0 additions & 7 deletions dlls/Monsters/msmonsterserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2837,13 +2837,6 @@ void CMSMonster::OpenMenu(CBasePlayer *pPlayer)
void CMSMonster::UseMenuOption(CBasePlayer *pPlayer, int Option)
{
pPlayer->InMenu = false;
//Thothie AUG2013_09 - attempt to fix bug where refuses to release +use on menu exit, since the Steam update. (failed)
//CLIENT_COMMAND( pPlayer->edict(), "-use" );
//pPlayer->m_afButtonReleased = IN_USE;
//pPlayer->pev->button = 0;
//pPlayer->m_StatusFlags = ClearBits(pPlayer->m_StatusFlags,IN_USE);
CLIENT_COMMAND(pPlayer->edict(), "+use;-use\n");

mslist<menuoption_t> &Menuoptions = m_MenuOptions[pPlayer->entindex()];

//Thothie JAN2008a - need a way of dealing with canceled menus
Expand Down

0 comments on commit 87e1541

Please sign in to comment.