DebugWindow.cpp 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. /*
  2. ** Command & Conquer Generals(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. // DebugWindow.cpp : Defines the initialization routines for the DLL.
  19. //
  20. #include "stdafx.h"
  21. #include "DebugWindow.h"
  22. #include "DebugWindowDialog.h"
  23. #ifdef _DEBUG
  24. #define new DEBUG_NEW
  25. #undef THIS_FILE
  26. static char THIS_FILE[] = __FILE__;
  27. #endif
  28. //
  29. // Note!
  30. //
  31. // If this DLL is dynamically linked against the MFC
  32. // DLLs, any functions exported from this DLL which
  33. // call into MFC must have the AFX_MANAGE_STATE macro
  34. // added at the very beginning of the function.
  35. //
  36. // For example:
  37. //
  38. // extern "C" BOOL PASCAL EXPORT ExportedFunction()
  39. // {
  40. // AFX_MANAGE_STATE(AfxGetStaticModuleState());
  41. // // normal function body here
  42. // }
  43. //
  44. // It is very important that this macro appear in each
  45. // function, prior to any calls into MFC. This means that
  46. // it must appear as the first statement within the
  47. // function, even before any object variable declarations
  48. // as their constructors may generate calls into the MFC
  49. // DLL.
  50. //
  51. // Please see MFC Technical Notes 33 and 58 for additional
  52. // details.
  53. //
  54. /////////////////////////////////////////////////////////////////////////////
  55. // CDebugWindowApp
  56. BEGIN_MESSAGE_MAP(CDebugWindowApp, CWinApp)
  57. //{{AFX_MSG_MAP(CDebugWindowApp)
  58. // NOTE - the ClassWizard will add and remove mapping macros here.
  59. // DO NOT EDIT what you see in these blocks of generated code!
  60. //}}AFX_MSG_MAP
  61. END_MESSAGE_MAP()
  62. /////////////////////////////////////////////////////////////////////////////
  63. // CDebugWindowApp construction
  64. CDebugWindowApp::CDebugWindowApp()
  65. {
  66. AfxInitialize(true);
  67. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  68. m_DialogWindow = NULL;
  69. }
  70. DebugWindowDialog* CDebugWindowApp::GetDialogWindow(void)
  71. {
  72. return m_DialogWindow;
  73. }
  74. void CDebugWindowApp::SetDialogWindow(DebugWindowDialog* pWnd)
  75. {
  76. m_DialogWindow = pWnd;
  77. }
  78. CDebugWindowApp::~CDebugWindowApp()
  79. {
  80. }
  81. /////////////////////////////////////////////////////////////////////////////
  82. // The one and only CDebugWindowApp object
  83. CDebugWindowApp theApp;
  84. void __declspec(dllexport) CreateDebugDialog(void)
  85. {
  86. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  87. DebugWindowDialog* tmpWnd;
  88. tmpWnd = new DebugWindowDialog;
  89. tmpWnd->Create(DebugWindowDialog::IDD);
  90. tmpWnd->SetWindowPos(NULL, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
  91. tmpWnd->ShowWindow(SW_SHOW);
  92. if (tmpWnd->GetMainWndHWND()) {
  93. SetFocus(tmpWnd->GetMainWndHWND());
  94. }
  95. theApp.SetDialogWindow(tmpWnd);
  96. }
  97. void __declspec(dllexport) DestroyDebugDialog(void)
  98. {
  99. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  100. DebugWindowDialog* tmpWnd = theApp.GetDialogWindow();
  101. if (tmpWnd) {
  102. tmpWnd->DestroyWindow();
  103. delete tmpWnd;
  104. theApp.SetDialogWindow(NULL);
  105. }
  106. }
  107. bool __declspec(dllexport) CanAppContinue(void)
  108. {
  109. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  110. DebugWindowDialog* pDbg;
  111. pDbg = theApp.GetDialogWindow();
  112. if (!pDbg) {
  113. return true;
  114. }
  115. return pDbg->CanProceed();
  116. }
  117. void __declspec(dllexport) ForceAppContinue(void)
  118. {
  119. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  120. DebugWindowDialog* pDbg;
  121. pDbg = theApp.GetDialogWindow();
  122. if (!pDbg) {
  123. return;
  124. }
  125. pDbg->ForceContinue();
  126. }
  127. bool __declspec(dllexport) RunAppFast(void)
  128. {
  129. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  130. DebugWindowDialog* pDbg;
  131. pDbg = theApp.GetDialogWindow();
  132. if (!pDbg) {
  133. return true;
  134. }
  135. return pDbg->RunAppFast();
  136. }
  137. void __declspec(dllexport) AppendMessage(const char* messageToPass)
  138. {
  139. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  140. DebugWindowDialog* pDbg;
  141. pDbg = theApp.GetDialogWindow();
  142. if (pDbg) {
  143. pDbg->AppendMessage(messageToPass);
  144. }
  145. }
  146. void __declspec(dllexport) SetFrameNumber(int frameNumber)
  147. {
  148. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  149. DebugWindowDialog* pDbg;
  150. pDbg = theApp.GetDialogWindow();
  151. if (pDbg) {
  152. pDbg->SetFrameNumber(frameNumber);
  153. }
  154. }
  155. void __declspec(dllexport) AppendMessageAndPause(const char* messageToPass)
  156. {
  157. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  158. DebugWindowDialog* pDbg;
  159. pDbg = theApp.GetDialogWindow();
  160. if (pDbg) {
  161. pDbg->AppendMessage(messageToPass);
  162. pDbg->ForcePause();
  163. }
  164. }
  165. void __declspec(dllexport) AdjustVariable(const char* variable, const char* value)
  166. {
  167. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  168. DebugWindowDialog* pDbg;
  169. pDbg = theApp.GetDialogWindow();
  170. if (pDbg) {
  171. pDbg->AdjustVariable(variable, value);
  172. }
  173. }
  174. void __declspec(dllexport) AdjustVariableAndPause(const char* variable, const char* value)
  175. {
  176. AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
  177. DebugWindowDialog* pDbg;
  178. pDbg = theApp.GetDialogWindow();
  179. if (pDbg) {
  180. pDbg->AdjustVariable(variable, value);
  181. pDbg->ForcePause();
  182. }
  183. }