From fc436d94896c79a2f730161a18a2a5cad97e5252 Mon Sep 17 00:00:00 2001 From: RD42 <42702181+dashr9230@users.noreply.github.com> Date: Tue, 16 Jul 2024 23:12:10 +0800 Subject: [PATCH] [saco] Implement/match `CMenuPool::New(...)` * Implement/match CMenu constructor * Update CMenuPool constructor --- saco/game/game.h | 1 + saco/game/menu.cpp | 27 +++++++++++++++++++++++++++ saco/game/menu.h | 43 +++++++++++++++++++++++++++++++++++++++++++ saco/net/menupool.cpp | 21 ++++++++++++++++++--- saco/net/menupool.h | 11 ++++++++--- 5 files changed, 97 insertions(+), 6 deletions(-) create mode 100644 saco/game/menu.cpp create mode 100644 saco/game/menu.h diff --git a/saco/game/game.h b/saco/game/game.h index 63848ec..f53a481 100644 --- a/saco/game/game.h +++ b/saco/game/game.h @@ -7,6 +7,7 @@ #include "audio.h" #include "camera.h" #include "scripting.h" +#include "menu.h" //----------------------------------------------------------- diff --git a/saco/game/menu.cpp b/saco/game/menu.cpp new file mode 100644 index 0000000..d157899 --- /dev/null +++ b/saco/game/menu.cpp @@ -0,0 +1,27 @@ + +#include "../main.h" + + +CMenu::CMenu(float fX, float fY, BYTE byteColumns, float fCol1Width, float fCol2Width, MENU_INT *MenuInteraction) +{ + for (int i = 0; i < MAX_MENU_ITEMS; i++) + { + memset(m_charItems[i][0], 0, sizeof(m_charItems[i][0])); + memset(m_charItems[i][1], 0, sizeof(m_charItems[i][1])); + } + memset(m_charHeader[0], 0, sizeof(m_charHeader[0])); + memset(m_charHeader[1], 0, sizeof(m_charHeader[1])); + memset(m_charTitle, 0, sizeof(m_charTitle)); + + m_fXPos = fX; + m_fYPos = fY; + m_fCol1Width = fCol1Width; + m_fCol2Width = fCol2Width; + + if (byteColumns == 2) m_byteColumns = 2; + else m_byteColumns = 1; + memcpy(&m_MenuInteraction, MenuInteraction, sizeof (MENU_INT)); + + m_dwPanel = 0; +} + diff --git a/saco/game/menu.h b/saco/game/menu.h new file mode 100644 index 0000000..e150c42 --- /dev/null +++ b/saco/game/menu.h @@ -0,0 +1,43 @@ + +#pragma once + +#define MAX_MENU_ITEMS 12 +#define MAX_MENU_LINE 32 +#define MAX_COLUMNS 2 + +//---------------------------------------------------- + +struct MENU_INT +{ + BOOL bMenu; + BOOL bRow[MAX_MENU_ITEMS]; + BOOL bPadding[8 - ((MAX_MENU_ITEMS + 1) % 8)]; +}; + +class CMenu +{ +private: + + //char _gap0[979]; + BYTE m_byteMenuID; + + CHAR m_charTitle[MAX_MENU_LINE+1]; + CHAR m_charItems[MAX_MENU_ITEMS][MAX_COLUMNS][MAX_MENU_LINE+1]; + CHAR m_charHeader[MAX_COLUMNS][MAX_MENU_LINE+1]; + + float m_fXPos; + float m_fYPos; + float m_fCol1Width; + float m_fCol2Width; + BYTE m_byteColumns; + MENU_INT m_MenuInteraction; + + BYTE m_byteColCount[MAX_COLUMNS]; + + DWORD m_dwPanel; + +public: + + CMenu(float fX, float fY, BYTE byteColumns, float fCol1Width, float fCol2Width, MENU_INT *MenuInteraction); + +}; diff --git a/saco/net/menupool.cpp b/saco/net/menupool.cpp index f2dbed3..a61280c 100644 --- a/saco/net/menupool.cpp +++ b/saco/net/menupool.cpp @@ -8,10 +8,25 @@ CMenuPool::CMenuPool() // loop through and initialize all net players to null and slot states to false for (BYTE byteMenuID = 0; byteMenuID < MAX_MENUS; byteMenuID++) { - field_200[byteMenuID] = 0; - field_0[byteMenuID] = 0; + m_bMenuSlotState[byteMenuID] = FALSE; + m_pMenus[byteMenuID] = NULL; } - field_400 = -128; + m_byteCurrentMenu = MAX_MENUS; } //---------------------------------------------------- + +CMenu* CMenuPool::New(BYTE byteMenuID, float fX, float fY, BYTE byteColumns, float fCol1Width, float fCol2Width, MENU_INT *MenuInteraction) +{ + SAFE_DELETE(m_pMenus[byteMenuID]); + m_bMenuSlotState[byteMenuID] = FALSE; + CMenu* pMenu = new CMenu(fX, fY, byteColumns, fCol1Width, fCol2Width, MenuInteraction); + + if (pMenu) + { + m_bMenuSlotState[byteMenuID] = TRUE; + m_pMenus[byteMenuID] = pMenu; + return pMenu; + } + return NULL; +} diff --git a/saco/net/menupool.h b/saco/net/menupool.h index bc6b71f..066b0bb 100644 --- a/saco/net/menupool.h +++ b/saco/net/menupool.h @@ -6,13 +6,18 @@ class CMenuPool { private: - int field_0[MAX_MENUS]; - int field_200[MAX_MENUS]; - char field_400; char field_401; + + CMenu *m_pMenus[MAX_MENUS]; + BOOL m_bMenuSlotState[MAX_MENUS]; + BYTE m_byteCurrentMenu; + public: CMenuPool(); + CMenu* New(BYTE byteMenuID, float fX, float fY, BYTE byteColumns, float fCol1Width, float fCol2Width, MENU_INT *MenuInteraction); + + }; //----------------------------------------------------