From a79dde901d38bd3cc4d235975b890bb877c78757 Mon Sep 17 00:00:00 2001 From: RD42 <42702181+dashr9230@users.noreply.github.com> Date: Sun, 28 Jul 2024 22:40:51 +0800 Subject: [PATCH] [saco] Implement/match `CNewPlayerTags::DeleteDeviceObjects()` --- saco/cmdwindow.cpp | 112 +++++++++++++++++++++++++++++++++++++---- saco/cmdwindow.h | 23 +++++++-- saco/newplayertags.cpp | 8 +++ saco/newplayertags.h | 1 + 4 files changed, 130 insertions(+), 14 deletions(-) diff --git a/saco/cmdwindow.cpp b/saco/cmdwindow.cpp index 361d2b1..d3c708d 100644 --- a/saco/cmdwindow.cpp +++ b/saco/cmdwindow.cpp @@ -1,13 +1,14 @@ #include "main.h" -extern CConfig *pConfig; +extern CGame *pGame; +extern CConfig *pConfig; //---------------------------------------------------- -// MATCH + CCmdWindow::CCmdWindow(IDirect3DDevice9 *pD3DDevice) { - field_14E0 = 0; + m_bEnabled = FALSE; m_pD3DDevice = pD3DDevice; m_iCmdCount = 0; field_1AF4 = 0; @@ -15,12 +16,18 @@ CCmdWindow::CCmdWindow(IDirect3DDevice9 *pD3DDevice) field_1AF0 = -1; memset(&field_1565[0],0,1290); - memset(&field_14E4[0],0,129); + memset(&m_szInputBuffer[0],0,(MAX_CMD_INPUT+1)); memset(&field_1A6F[0],0,129); } //---------------------------------------------------- -// MATCH + +CCmdWindow::~CCmdWindow() +{ +} + +//---------------------------------------------------- + void CCmdWindow::ResetDialogControls(CDXUTDialog *pGameUI) { m_pGameUI = pGameUI; @@ -42,14 +49,92 @@ void CCmdWindow::ResetDialogControls(CDXUTDialog *pGameUI) } //---------------------------------------------------- -// MATCH -void CCmdWindow::AddDefaultCmdProc(CMDPROC cmdDefault) + +void CCmdWindow::GetDialogSize(RECT *pRect) { - m_pDefaultCmd = cmdDefault; + memset(pRect,0,sizeof(RECT)); + + if(m_pGameUI) { + pRect->right = m_pGameUI->GetWidth(); + pRect->bottom = m_pGameUI->GetHeight(); + } } //---------------------------------------------------- -// MATCH + +void CCmdWindow::Enable() +{ + if(m_bEnabled) return; + + if(m_pEditControl) { + RECT rect; + GetClientRect(pGame->GetMainWindowHwnd(), &rect); + + m_pEditControl->SetEnabled(true); + m_pEditControl->SetVisible(true); + + // TODO: CCmdWindow::Enable() + } + + m_bEnabled = TRUE; +} + +//---------------------------------------------------- + +void CCmdWindow::Disable() +{ + if(!m_bEnabled) return; + + if(m_pEditControl) { + m_pEditControl->OnFocusOut(); + m_pEditControl->SetEnabled(false); + m_pEditControl->SetVisible(false); + } + pGame->ToggleKeyInputsDisabled(0, TRUE); + m_bEnabled = FALSE; +} + +//---------------------------------------------------- + + + + + +//---------------------------------------------------- + +void CCmdWindow::ProcessInput() +{ + if(!m_pEditControl) return; + + strncpy(m_szInputBuffer,m_pEditControl->GetTextA(),MAX_CMD_INPUT); + m_szInputBuffer[MAX_CMD_INPUT] = '\0'; + + // TODO: CCmdWindow::ProcessInput() +} + +//---------------------------------------------------- + +CMDPROC CCmdWindow::GetCmdHandler(PCHAR szCmdName) +{ + int x=0; + while(x!=m_iCmdCount) { + if(!stricmp(szCmdName,m_szCmdNames[x])) { + return m_pCmds[x]; + } + x++; + } + return NULL; +} + +//---------------------------------------------------- + +void CCmdWindow::AddDefaultCmdProc(CMDPROC cmdDefault) +{ + m_pDefaultCmd = cmdDefault; +} + +//---------------------------------------------------- + void CCmdWindow::AddCmdProc(PCHAR szCmdName, CMDPROC cmdHandler) { if(m_iCmdCount < MAX_CMDS && (strlen(szCmdName) < MAX_CMD_STRLEN)) { @@ -61,3 +146,12 @@ void CCmdWindow::AddCmdProc(PCHAR szCmdName, CMDPROC cmdHandler) //---------------------------------------------------- + + + + + + + + + diff --git a/saco/cmdwindow.h b/saco/cmdwindow.h index 62b8ae3..9fb44b7 100644 --- a/saco/cmdwindow.h +++ b/saco/cmdwindow.h @@ -1,12 +1,15 @@ #pragma once +#define MAX_CMD_INPUT 128 #define MAX_CMDS 144 #define MAX_CMD_STRLEN 32 typedef void (__cdecl *CMDPROC)(PCHAR); -class CCmdWindow // size: 6908 +//---------------------------------------------------- + +class CCmdWindow { private: @@ -20,21 +23,31 @@ public: CHAR m_szCmdNames[MAX_CMDS][MAX_CMD_STRLEN+1]; int m_iCmdCount; - int field_14E0; - char field_14E4[129]; + BOOL m_bEnabled; + + char m_szInputBuffer[MAX_CMD_INPUT + 1]; char field_1565[1290]; char field_1A6F[129]; int field_1AF0; int field_1AF4; - CMDPROC m_pDefaultCmd; // used when no command specifier was // used (ie. a normal chat message) + void GetDialogSize(RECT *pRect); - CCmdWindow(IDirect3DDevice9 *pD3DDevice); + void Enable(); + void Disable(); + void ProcessInput(); + + CMDPROC GetCmdHandler(PCHAR szCmdName); void AddDefaultCmdProc(CMDPROC cmdDefault); void AddCmdProc(PCHAR szCmdName, CMDPROC cmdHandler); void ResetDialogControls(CDXUTDialog *pGameUI); + CCmdWindow(IDirect3DDevice9 *pD3DDevice); + ~CCmdWindow(); }; + +//---------------------------------------------------- +// EOF diff --git a/saco/newplayertags.cpp b/saco/newplayertags.cpp index 1165249..30b42d3 100644 --- a/saco/newplayertags.cpp +++ b/saco/newplayertags.cpp @@ -16,6 +16,14 @@ CNewPlayerTags::~CNewPlayerTags() SAFE_DELETE(m_pSprite); } +void CNewPlayerTags::DeleteDeviceObjects() +{ + SAFE_RELEASE(m_pStates); + + if(m_pSprite) + m_pSprite->OnLostDevice(); +} + void CNewPlayerTags::RestoreDeviceObjects() { if(m_pSprite) diff --git a/saco/newplayertags.h b/saco/newplayertags.h index 7959476..c6b8773 100644 --- a/saco/newplayertags.h +++ b/saco/newplayertags.h @@ -12,5 +12,6 @@ public: CNewPlayerTags(IDirect3DDevice9* pDevice); ~CNewPlayerTags(); + void DeleteDeviceObjects(); void RestoreDeviceObjects(); };