diff --git a/saco/game/menu.cpp b/saco/game/menu.cpp index 7322003..c4a8f6e 100644 --- a/saco/game/menu.cpp +++ b/saco/game/menu.cpp @@ -104,3 +104,10 @@ PCHAR CMenu::MS(BYTE byteRow, BYTE byteColumn) return "DUMMY"; } +BYTE CMenu::GetSelectedRow() +{ + if (!m_MenuInteraction.bMenu) return 0xFF; + DWORD dwRetVal; + ScriptCommand(&get_panel_active_row, m_dwPanel, &dwRetVal); + return (BYTE)dwRetVal; +} diff --git a/saco/game/menu.h b/saco/game/menu.h index 183354f..b74f761 100644 --- a/saco/game/menu.h +++ b/saco/game/menu.h @@ -49,4 +49,5 @@ public: PCHAR GetMenuTitle(); PCHAR GetMenuHeader(BYTE byteColumn); PCHAR MS(BYTE byteColumn, BYTE byteRow); + BYTE GetSelectedRow(); }; diff --git a/saco/game/scripting.h b/saco/game/scripting.h index 6c1f404..7d3ab54 100644 --- a/saco/game/scripting.h +++ b/saco/game/scripting.h @@ -87,6 +87,8 @@ const SCRIPT_COMMAND set_panel_column_data = { 0x08DB, "iisssssssssssss" }; const SCRIPT_COMMAND set_panel_column_width = { 0x09DB, "iii" }; const SCRIPT_COMMAND set_panel_row_enable = { 0x08D9, "iii" }; +const SCRIPT_COMMAND get_panel_active_row = { 0x08D7, "iv" }; + const SCRIPT_COMMAND restore_camera_to_user_defined = { 0x925, "" }; const SCRIPT_COMMAND set_camera_position_to = { 0x936, "ffffffii" }; diff --git a/saco/net/menupool.cpp b/saco/net/menupool.cpp index 9e29fa3..8102887 100644 --- a/saco/net/menupool.cpp +++ b/saco/net/menupool.cpp @@ -1,5 +1,6 @@ #include "../main.h" +#include "../game/keystuff.h" CHAR g_szMenuItems[MAX_MENU_ITEMS][MAX_COLUMNS][MAX_MENU_LINE+1] = { @@ -17,6 +18,8 @@ CHAR g_szMenuItems[MAX_MENU_ITEMS][MAX_COLUMNS][MAX_MENU_LINE+1] = {"SAMP011", "SAMP111"}, }; +extern CNetGame* pNetGame; + //---------------------------------------------------- CMenuPool::CMenuPool() @@ -117,3 +120,32 @@ PCHAR CMenuPool::GetTextPointer(PCHAR szName) return NULL; } +void CMenuPool::Process() +{ + if (m_byteCurrentMenu == MAX_MENUS) return; + + GTA_CONTROLSET * pControls = GameGetInternalKeys(); + RakClientInterface* pRak = pNetGame->GetRakClient(); + if (pControls->wKeys1[16] && !pControls->wKeys2[16]) // Selected an item + { + BYTE row = m_pMenus[m_byteCurrentMenu]->GetSelectedRow(); + if (row != 0xFF) + { + m_byteExited = 1; + RakNet::BitStream bsSend; + bsSend.Write(row); + pRak->RPC(RPC_MenuSelect, &bsSend, HIGH_PRIORITY, RELIABLE, 0, FALSE); + } + } + else if (pControls->wKeys1[15] && !pControls->wKeys2[15]) // Exited + { + m_byteExited = 1; + pRak->RPC(RPC_MenuQuit, NULL, HIGH_PRIORITY, RELIABLE, 0, FALSE); + } + else if (m_byteExited) + { + // Delay clearing for one frame to allow SA to make the nice noise + HideMenu(m_byteCurrentMenu); + m_byteExited = 0; + } +} diff --git a/saco/net/menupool.h b/saco/net/menupool.h index 6433ddf..9dac02e 100644 --- a/saco/net/menupool.h +++ b/saco/net/menupool.h @@ -25,6 +25,7 @@ public: PCHAR GetTextPointer(PCHAR szName); + void Process(); }; //----------------------------------------------------