[saco] Implement/match CMenuPool::ShowMenu(...)

* Implement/match `CMenu::Show()`
* Implement/match `CMenu::MS(...)`
This commit is contained in:
RD42 2024-07-16 23:24:53 +08:00
parent 37642d51d4
commit 6fb501be50
5 changed files with 68 additions and 1 deletions

View File

@ -1,6 +1,7 @@
#include "../main.h"
extern CHAR g_szMenuItems[MAX_MENU_ITEMS][MAX_COLUMNS][MAX_MENU_LINE+1];
CMenu::CMenu(float fX, float fY, BYTE byteColumns, float fCol1Width, float fCol2Width, MENU_INT *MenuInteraction)
{
@ -25,8 +26,38 @@ CMenu::CMenu(float fX, float fY, BYTE byteColumns, float fCol1Width, float fCol2
m_dwPanel = 0;
}
void CMenu::Show()
{
ScriptCommand(&create_panel, m_charTitle[0] ? "SAMPHED" : "DUMMY", m_fXPos, m_fYPos, (m_fCol1Width + m_fCol2Width) / m_byteColumns, m_byteColumns, m_MenuInteraction.bMenu, 1, 1, &m_dwPanel);
ScriptCommand(&set_panel_column_data, m_dwPanel, 0, m_charHeader[0][0] ? "SAMPRW1" : "DUMMY"
, MS(0,0), MS(1,0), MS(2,0)
, MS(3,0), MS(4,0), MS(5,0)
, MS(6,0), MS(7,0), MS(8,0)
, MS(9,0), MS(10,0), MS(11,0));
ScriptCommand(&set_panel_column_width, m_dwPanel, 0, (int)m_fCol1Width);
if (m_byteColumns == 2)
{
ScriptCommand(&set_panel_column_data, m_dwPanel, 1, m_charHeader[1][0] ? "SAMPRW2" : "DUMMY"
, MS(0,1), MS(1,1), MS(2,1)
, MS(3,1), MS(4,1), MS(5,1)
, MS(6,1), MS(7,1), MS(8,1)
, MS(9,1), MS(10,1), MS(11,1));
ScriptCommand(&set_panel_column_width, m_dwPanel, 1, (int)m_fCol1Width);
}
for (BYTE i = 0; i < MAX_MENU_ITEMS; i++)
{
ScriptCommand(&set_panel_row_enable, m_dwPanel, i, m_MenuInteraction.bRow[i]);
}
}
void CMenu::Hide()
{
ScriptCommand(&remove_panel, m_dwPanel);
}
PCHAR CMenu::MS(BYTE byteRow, BYTE byteColumn)
{
if (m_charItems[byteRow][byteColumn][0]) return g_szMenuItems[byteRow][byteColumn];
return "DUMMY";
}

View File

@ -40,5 +40,7 @@ public:
CMenu(float fX, float fY, BYTE byteColumns, float fCol1Width, float fCol2Width, MENU_INT *MenuInteraction);
void Show();
void Hide();
PCHAR MS(BYTE byteColumn, BYTE byteRow);
};

View File

@ -82,6 +82,11 @@ const SCRIPT_COMMAND text_clear_all = { 0x00be, "" };
const SCRIPT_COMMAND create_radar_marker_icon = { 0x0570, "fffiv" };
const SCRIPT_COMMAND remove_panel = { 0x08DA, "i" };
const SCRIPT_COMMAND create_panel = { 0x08D4, "sfffiiiiv" };
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 restore_camera_to_user_defined = { 0x925, "" };
const SCRIPT_COMMAND set_camera_position_to = { 0x936, "ffffffii" };

View File

@ -1,6 +1,22 @@
#include "../main.h"
CHAR g_szMenuItems[MAX_MENU_ITEMS][MAX_COLUMNS][MAX_MENU_LINE+1] =
{
{"SAMP000", "SAMP100"},
{"SAMP001", "SAMP101"},
{"SAMP002", "SAMP102"},
{"SAMP003", "SAMP103"},
{"SAMP004", "SAMP104"},
{"SAMP005", "SAMP105"},
{"SAMP006", "SAMP106"},
{"SAMP007", "SAMP107"},
{"SAMP008", "SAMP108"},
{"SAMP009", "SAMP109"},
{"SAMP010", "SAMP110"},
{"SAMP011", "SAMP111"},
};
//----------------------------------------------------
CMenuPool::CMenuPool()
@ -64,3 +80,15 @@ BOOL CMenuPool::Delete(BYTE byteMenuID)
//----------------------------------------------------
void CMenuPool::ShowMenu(BYTE byteMenuID)
{
if (byteMenuID >= MAX_MENUS) return;
if (m_bMenuSlotState[byteMenuID] == FALSE || !m_pMenus[byteMenuID]) return;
if (m_byteCurrentMenu != MAX_MENUS) m_pMenus[m_byteCurrentMenu]->Hide();
m_pMenus[byteMenuID]->Show();
m_byteCurrentMenu = byteMenuID;
m_byteExited = 0;
}

View File

@ -6,11 +6,11 @@
class CMenuPool
{
private:
char field_401;
CMenu *m_pMenus[MAX_MENUS];
BOOL m_bMenuSlotState[MAX_MENUS];
BYTE m_byteCurrentMenu;
BYTE m_byteExited;
public:
CMenuPool();
@ -20,6 +20,7 @@ public:
BOOL Delete(BYTE byteMenuID);
void ShowMenu(BYTE byteMenuID);
};
//----------------------------------------------------