Browse Source

arm64 : fix vgui2 VPAMEL in messagemap

pull/71/head
hymei 2 years ago committed by nillerusr
parent
commit
3bc519aecf
  1. 6
      game/client/cstrike/VGUI/buypreset_listbox.cpp
  2. 15
      game/client/cstrike/VGUI/buypreset_listbox.h
  3. 7
      gameui/BasePanel.cpp
  4. 1
      public/vgui_controls/BuildGroup.h
  5. 4
      public/vgui_controls/Menu.h
  6. 3
      public/vgui_controls/MessageMap.h
  7. 13
      public/vgui_controls/PHandle.h
  8. 2
      public/vgui_controls/Panel.h
  9. 12
      vgui2/vgui_controls/BuildGroup.cpp
  10. 6
      vgui2/vgui_controls/Menu.cpp
  11. 4
      vgui2/vgui_controls/MenuItem.cpp
  12. 31
      vgui2/vgui_controls/Panel.cpp

6
game/client/cstrike/VGUI/buypreset_listbox.cpp

@ -135,7 +135,7 @@ int BuyPresetListBox::computeVPixelsNeeded( void ) @@ -135,7 +135,7 @@ int BuyPresetListBox::computeVPixelsNeeded( void )
/**
* Adds an item to the end of the listbox. UserData is assumed to be a pointer that can be freed by the listbox if non-NULL.
*/
int BuyPresetListBox::AddItem( vgui::Panel *panel, void * userData )
int BuyPresetListBox::AddItem( vgui::Panel *panel, IBuyPresetListBoxUserData * userData )
{
assert(panel);
@ -192,7 +192,7 @@ Panel * BuyPresetListBox::GetItemPanel(int index) const @@ -192,7 +192,7 @@ Panel * BuyPresetListBox::GetItemPanel(int index) const
/**
* Returns the userData in the given index, or NULL
*/
void * BuyPresetListBox::GetItemUserData(int index)
auto BuyPresetListBox::GetItemUserData(int index) -> IBuyPresetListBoxUserData *
{
if ( index < 0 || index >= m_items.Count() )
{
@ -206,7 +206,7 @@ void * BuyPresetListBox::GetItemUserData(int index) @@ -206,7 +206,7 @@ void * BuyPresetListBox::GetItemUserData(int index)
/**
* Sets the userData in the given index
*/
void BuyPresetListBox::SetItemUserData( int index, void * userData )
void BuyPresetListBox::SetItemUserData( int index, IBuyPresetListBoxUserData * userData )
{
if ( index < 0 || index >= m_items.Count() )
return;

15
game/client/cstrike/VGUI/buypreset_listbox.h

@ -27,14 +27,21 @@ public: @@ -27,14 +27,21 @@ public:
BuyPresetListBox( vgui::Panel *parent, char const *panelName );
~BuyPresetListBox();
virtual int AddItem( vgui::Panel *panel, void * userData ); ///< Adds an item to the end of the listbox. UserData is assumed to be a pointer that can be freed by the listbox if non-NULL.
class IBuyPresetListBoxUserData
{
protected:
friend BuyPresetListBox;
virtual ~IBuyPresetListBoxUserData() {};
};
virtual int AddItem( vgui::Panel *panel, IBuyPresetListBoxUserData *userData ); ///< Adds an item to the end of the listbox. UserData is assumed to be a pointer that will be deleted by the listbox if non-NULL.
virtual int GetItemCount( void ) const; ///< Returns the number of items in the listbox
void SwapItems( int index1, int index2 ); ///< Exchanges two items in the listbox
void MakeItemVisible( int index ); ///< Try to ensure that the given index is visible
vgui::Panel * GetItemPanel( int index ) const; ///< Returns the panel in the given index, or NULL
void * GetItemUserData( int index ); ///< Returns the userData in the given index, or NULL
void SetItemUserData( int index, void * userData ); ///< Sets the userData in the given index
IBuyPresetListBoxUserData * GetItemUserData( int index ); ///< Returns the userData in the given index, or NULL
void SetItemUserData( int index, IBuyPresetListBoxUserData * userData ); ///< Sets the userData in the given index
virtual void RemoveItem( int index ); ///< Removes an item from the table (changing the indices of all following items), deleting the panel and userData
virtual void DeleteAllItems(); ///< clears the listbox, deleting all panels and userData
@ -60,7 +67,7 @@ private: @@ -60,7 +67,7 @@ private:
typedef struct dataitem_s
{
vgui::Panel *panel;
void * userData;
IBuyPresetListBoxUserData * userData;
} DataItem;
CUtlVector< DataItem > m_items;

7
gameui/BasePanel.cpp

@ -633,7 +633,7 @@ public: @@ -633,7 +633,7 @@ public:
}
}
MESSAGE_FUNC_INT( OnCursorEnteredMenuItem, "CursorEnteredMenuItem", VPanel);
MESSAGE_FUNC_HANDLE( OnCursorEnteredMenuItem, "CursorEnteredMenuItem", menuItem);
private:
CFooterPanel *m_pConsoleFooter;
@ -644,9 +644,8 @@ private: @@ -644,9 +644,8 @@ private:
//-----------------------------------------------------------------------------
// Purpose: Respond to cursor entering a menuItem.
//-----------------------------------------------------------------------------
void CGameMenu::OnCursorEnteredMenuItem(int VPanel)
void CGameMenu::OnCursorEnteredMenuItem(VPANEL menuItem)
{
VPANEL menuItem = (VPANEL)VPanel;
MenuItem *item = static_cast<MenuItem *>(ipanel()->GetPanel(menuItem, GetModuleName()));
KeyValues *pCommand = item->GetCommand();
if ( !pCommand->GetFirstSubKey() )
@ -655,7 +654,7 @@ void CGameMenu::OnCursorEnteredMenuItem(int VPanel) @@ -655,7 +654,7 @@ void CGameMenu::OnCursorEnteredMenuItem(int VPanel)
if ( !pszCmd || !pszCmd[0] )
return;
BaseClass::OnCursorEnteredMenuItem( VPanel );
BaseClass::OnCursorEnteredMenuItem( menuItem );
}
static CBackgroundMenuButton* CreateMenuButton( CBasePanel *parent, const char *panelName, const wchar_t *panelText )

1
public/vgui_controls/BuildGroup.h

@ -94,6 +94,7 @@ public: @@ -94,6 +94,7 @@ public:
virtual const char *GetResourceName(void) { return m_pResourceName; }
virtual void PanelAdded(Panel* panel);
virtual void PanelRemoved(Panel* panel);
virtual bool MousePressed(MouseCode code,Panel* panel);
virtual bool MouseReleased(MouseCode code,Panel* panel);

4
public/vgui_controls/Menu.h

@ -295,8 +295,8 @@ protected: @@ -295,8 +295,8 @@ protected:
void SetCurrentlySelectedItem(MenuItem *item);
void SetCurrentlySelectedItem(int itemID);
MESSAGE_FUNC_INT( OnCursorEnteredMenuItem, "CursorEnteredMenuItem", VPanel);
MESSAGE_FUNC_INT( OnCursorExitedMenuItem, "CursorExitedMenuItem", VPanel);
MESSAGE_FUNC_HANDLE( OnCursorEnteredMenuItem, "CursorEnteredMenuItem", menuItem);
MESSAGE_FUNC_HANDLE( OnCursorExitedMenuItem, "CursorExitedMenuItem", menuItem);
void MoveAlongMenuItemList(int direction, int loopCount);

3
public/vgui_controls/MessageMap.h

@ -46,7 +46,7 @@ class __virtual_inheritance Panel; @@ -46,7 +46,7 @@ class __virtual_inheritance Panel;
#else
class Panel;
#endif
typedef unsigned int VPANEL;
typedef uintp VPANEL;
typedef void (Panel::*MessageFunc_t)(void);
@ -222,6 +222,7 @@ public: \ @@ -222,6 +222,7 @@ public: \
#define MESSAGE_FUNC_PTR_WCHARPTR( name, scriptname, p1, p2 ) _MessageFuncCommon( name, scriptname, 2, vgui::DATATYPE_PTR, #p1, vgui::DATATYPE_CONSTWCHARPTR, #p2 ); virtual void name( vgui::Panel *p1, const wchar_t *p2 )
#define MESSAGE_FUNC_HANDLE_WCHARPTR( name, scriptname, p1, p2 ) _MessageFuncCommon( name, scriptname, 2, vgui::DATATYPE_HANDLE, #p1, vgui::DATATYPE_CONSTWCHARPTR, #p2 ); virtual void name( vgui::VPANEL p1, const wchar_t *p2 )
#define MESSAGE_FUNC_CHARPTR_CHARPTR( name, scriptname, p1, p2 ) _MessageFuncCommon( name, scriptname, 2, vgui::DATATYPE_CONSTCHARPTR, #p1, vgui::DATATYPE_CONSTCHARPTR, #p2 ); virtual void name( const char *p1, const char *p2 )
#define MESSAGE_FUNC_HANDLE_HANDLE( name, scriptname, p1, p2 ) _MessageFuncCommon( name, scriptname, 2, vgui::DATATYPE_HANDLE, #p1, vgui::DATATYPE_HANDLE, #p2 ); virtual void name( vgui::VPANEL p1, vgui::VPANEL p2 )
// unlimited parameters (passed in the whole KeyValues)
#define MESSAGE_FUNC_PARAMS( name, scriptname, p1 ) _MessageFuncCommon( name, scriptname, 1, vgui::DATATYPE_KEYVALUES, NULL, 0, 0 ); virtual void name( KeyValues *p1 )

13
public/vgui_controls/PHandle.h

@ -27,16 +27,21 @@ class PHandle @@ -27,16 +27,21 @@ class PHandle
public:
PHandle() : m_iPanelID(INVALID_PANEL) {} //m_iSerialNumber(0), m_pListEntry(0) {}
Panel *Get();
Panel *Get() const;
Panel *Set( Panel *pPanel );
Panel *Set( HPanel hPanel );
operator Panel *() { return Get(); }
operator Panel *() const { return Get(); }
Panel * operator ->() { return Get(); }
Panel * operator = (Panel *pPanel) { return Set(pPanel); }
bool operator == (Panel *pPanel) { return (Get() == pPanel); }
operator bool () { return Get() != 0; }
//bool operator == (Panel *pPanel) { return (Get() == pPanel); }
operator bool () const { return Get() != 0; }
friend bool operator == ( const PHandle &p1, const PHandle &p2 )
{
return p1.m_iPanelID == p2.m_iPanelID;
}
private:
HPanel m_iPanelID;

2
public/vgui_controls/Panel.h

@ -673,7 +673,7 @@ protected: @@ -673,7 +673,7 @@ protected:
protected:
virtual void OnChildSettingsApplied( KeyValues *pInResourceData, Panel *pChild );
MESSAGE_FUNC_ENUM_ENUM( OnRequestFocus, "OnRequestFocus", VPANEL, subFocus, VPANEL, defaultPanel);
MESSAGE_FUNC_HANDLE_HANDLE( OnRequestFocus, "OnRequestFocus", subFocus, defaultPanel);
MESSAGE_FUNC_INT_INT( OnScreenSizeChanged, "OnScreenSizeChanged", oldwide, oldtall );
virtual void *QueryInterface(EInterfaceID id);

12
vgui2/vgui_controls/BuildGroup.cpp

@ -869,6 +869,18 @@ void BuildGroup::PanelAdded(Panel *panel) @@ -869,6 +869,18 @@ void BuildGroup::PanelAdded(Panel *panel)
_panelDar.AddToTail(temp);
}
//-----------------------------------------------------------------------------
// Purpose: Add panel the list of panels that are in the build group
//-----------------------------------------------------------------------------
void BuildGroup::PanelRemoved(Panel *panel)
{
Assert(panel);
PHandle temp;
temp = panel;
_panelDar.FindAndRemove(temp);
}
//-----------------------------------------------------------------------------
// Purpose: loads the control settings from file
//-----------------------------------------------------------------------------

6
vgui2/vgui_controls/Menu.cpp

@ -2365,9 +2365,8 @@ int Menu::GetCurrentlyHighlightedItem() @@ -2365,9 +2365,8 @@ int Menu::GetCurrentlyHighlightedItem()
//-----------------------------------------------------------------------------
// Purpose: Respond to cursor entering a menuItem.
//-----------------------------------------------------------------------------
void Menu::OnCursorEnteredMenuItem(int VPanel)
void Menu::OnCursorEnteredMenuItem(VPANEL menuItem)
{
VPANEL menuItem = (VPANEL)VPanel;
// if we are in mouse mode
if (m_iInputMode == MOUSE)
{
@ -2389,9 +2388,8 @@ void Menu::OnCursorEnteredMenuItem(int VPanel) @@ -2389,9 +2388,8 @@ void Menu::OnCursorEnteredMenuItem(int VPanel)
//-----------------------------------------------------------------------------
// Purpose: Respond to cursor exiting a menuItem
//-----------------------------------------------------------------------------
void Menu::OnCursorExitedMenuItem(int VPanel)
void Menu::OnCursorExitedMenuItem(VPANEL menuItem)
{
VPANEL menuItem = (VPANEL)VPanel;
// only care if we are in mouse mode
if (m_iInputMode == MOUSE)
{

4
vgui2/vgui_controls/MenuItem.cpp

@ -222,7 +222,7 @@ void MenuItem::OnCursorEntered() @@ -222,7 +222,7 @@ void MenuItem::OnCursorEntered()
// forward the message on to the parent of this menu.
KeyValues *msg = new KeyValues ("CursorEnteredMenuItem");
// tell the parent this menuitem is the one that was entered so it can highlight it
msg->SetInt("VPanel", GetVPanel());
msg->SetInt("menuItem", ToHandle() );
ivgui()->PostMessage(GetVParent(), msg, NULL);
}
@ -236,7 +236,7 @@ void MenuItem::OnCursorExited() @@ -236,7 +236,7 @@ void MenuItem::OnCursorExited()
// forward the message on to the parent of this menu.
KeyValues *msg = new KeyValues ("CursorExitedMenuItem");
// tell the parent this menuitem is the one that was entered so it can unhighlight it
msg->SetInt("VPanel", GetVPanel());
msg->SetInt("menuItem", ToHandle() );
ivgui()->PostMessage(GetVParent(), msg, NULL);
}

31
vgui2/vgui_controls/Panel.cpp

@ -880,7 +880,7 @@ const char *Panel::GetClassName() @@ -880,7 +880,7 @@ const char *Panel::GetClassName()
{
// loop up the panel map name
PanelMessageMap *panelMap = GetMessageMap();
if ( panelMap )
if ( panelMap && panelMap->pfnClassName )
{
return panelMap->pfnClassName();
}
@ -3575,7 +3575,7 @@ void Panel::RequestFocus(int direction) @@ -3575,7 +3575,7 @@ void Panel::RequestFocus(int direction)
//-----------------------------------------------------------------------------
void Panel::OnRequestFocus(VPANEL subFocus, VPANEL defaultPanel)
{
CallParentFunction(new KeyValues("OnRequestFocus", "subFocus", subFocus, "defaultPanel", defaultPanel));
CallParentFunction(new KeyValues("OnRequestFocus", "subFocus", ivgui()->PanelToHandle( subFocus ), "defaultPanel", ivgui()->PanelToHandle( defaultPanel )));
}
//-----------------------------------------------------------------------------
@ -3800,13 +3800,17 @@ void Panel::SetTall(int tall) @@ -3800,13 +3800,17 @@ void Panel::SetTall(int tall)
void Panel::SetBuildGroup(BuildGroup* buildGroup)
{
//TODO: remove from old group
Assert(buildGroup != NULL);
_buildGroup = buildGroup;
_buildGroup->PanelAdded(this);
if ( _buildGroup == buildGroup )
return;
if ( _buildGroup.Get() )
{
_buildGroup->PanelRemoved( this );
}
_buildGroup = buildGroup;
if ( _buildGroup.Get() )
{
_buildGroup->PanelAdded(this);
}
}
bool Panel::IsBuildGroupEnabled()
@ -5134,6 +5138,13 @@ void Panel::OnMessage(const KeyValues *params, VPANEL ifromPanel) @@ -5134,6 +5138,13 @@ void Panel::OnMessage(const KeyValues *params, VPANEL ifromPanel)
VPANEL vp = ivgui()->HandleToPanel( param1->GetInt() );
(this->*((MessageFunc_HandleConstCharPtr_t)pMap->func))( vp, param2->GetWString() );
}
else if ( (DATATYPE_HANDLE == pMap->firstParamType) && (DATATYPE_HANDLE == pMap->secondParamType) )
{
typedef void (Panel::*MessageFunc_HandleConstCharPtr_t)(VPANEL, VPANEL);
VPANEL vp1 = ivgui()->HandleToPanel( param1->GetInt() );
VPANEL vp2 = ivgui()->HandleToPanel( param1->GetInt() );
(this->*((MessageFunc_HandleConstCharPtr_t)pMap->func))( vp1, vp2 );
}
else
{
// the message isn't handled
@ -5515,7 +5526,7 @@ void Panel::OnDelete() @@ -5515,7 +5526,7 @@ void Panel::OnDelete()
// Purpose: Panel handle implementation
// Returns a pointer to a valid panel, NULL if the panel has been deleted
//-----------------------------------------------------------------------------
Panel *PHandle::Get()
Panel *PHandle::Get() const
{
if (m_iPanelID != INVALID_PANEL)
{

Loading…
Cancel
Save