GeneratingPathfindDialog.cpp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. /*
  2. ** Command & Conquer Renegade(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. // GeneratingPathfindDialog.cpp : implementation file
  19. //
  20. #include "stdafx.h"
  21. #include "leveledit.h"
  22. #include "GeneratingPathfindDialog.h"
  23. #ifdef _DEBUG
  24. #define new DEBUG_NEW
  25. #undef THIS_FILE
  26. static char THIS_FILE[] = __FILE__;
  27. #endif
  28. /////////////////////////////////////////////////////////////////////////////
  29. //
  30. // GeneratingPathfindDialogClass
  31. //
  32. /////////////////////////////////////////////////////////////////////////////
  33. GeneratingPathfindDialogClass::GeneratingPathfindDialogClass(CWnd *parent)
  34. : m_Cancelled (false),
  35. CDialog(GeneratingPathfindDialogClass::IDD, parent)
  36. {
  37. //{{AFX_DATA_INIT(GeneratingPathfindDialogClass)
  38. // NOTE: the ClassWizard will add member initialization here
  39. //}}AFX_DATA_INIT
  40. Create (GeneratingPathfindDialogClass::IDD, parent);
  41. return ;
  42. }
  43. /////////////////////////////////////////////////////////////////////////////
  44. //
  45. // DoDataExchange
  46. //
  47. /////////////////////////////////////////////////////////////////////////////
  48. void
  49. GeneratingPathfindDialogClass::DoDataExchange (CDataExchange *pDX)
  50. {
  51. CDialog::DoDataExchange (pDX);
  52. //{{AFX_DATA_MAP(GeneratingPathfindDialogClass)
  53. DDX_Control(pDX, IDC_PROGRESS_BAR, m_ProgressBar);
  54. //}}AFX_DATA_MAP
  55. return ;
  56. }
  57. BEGIN_MESSAGE_MAP(GeneratingPathfindDialogClass, CDialog)
  58. //{{AFX_MSG_MAP(GeneratingPathfindDialogClass)
  59. //}}AFX_MSG_MAP
  60. END_MESSAGE_MAP()
  61. /////////////////////////////////////////////////////////////////////////////
  62. //
  63. // OnInitDialog
  64. //
  65. /////////////////////////////////////////////////////////////////////////////
  66. BOOL
  67. GeneratingPathfindDialogClass::OnInitDialog (void)
  68. {
  69. CDialog::OnInitDialog ();
  70. Set_State (STATE_FLOODFILL);
  71. m_ProgressBar.SetRange (0, 100);
  72. return TRUE;
  73. }
  74. /////////////////////////////////////////////////////////////////////////////
  75. //
  76. // OnCancel
  77. //
  78. /////////////////////////////////////////////////////////////////////////////
  79. void
  80. GeneratingPathfindDialogClass::OnCancel (void)
  81. {
  82. m_Cancelled = true;
  83. ::EnableWindow (::GetDlgItem (m_hWnd, IDCANCEL), FALSE);
  84. CWaitCursor wait_cursor;
  85. Set_Status ("Operation Cancelled!", -1);
  86. return ;
  87. }
  88. /////////////////////////////////////////////////////////////////////////////
  89. //
  90. // Set_State
  91. //
  92. /////////////////////////////////////////////////////////////////////////////
  93. void
  94. GeneratingPathfindDialogClass::Set_State (STATE state)
  95. {
  96. if (state == STATE_FLOODFILL) {
  97. ::ShowWindow (::GetDlgItem (m_hWnd, IDC_FLOODFILL_MARK), SW_SHOW);
  98. ::ShowWindow (::GetDlgItem (m_hWnd, IDC_COMPRESSING_MARK), SW_HIDE);
  99. } else if (state == STATE_COMPRESS) {
  100. ::ShowWindow (::GetDlgItem (m_hWnd, IDC_FLOODFILL_MARK), SW_HIDE);
  101. ::ShowWindow (::GetDlgItem (m_hWnd, IDC_COMPRESSING_MARK), SW_SHOW);
  102. }
  103. return ;
  104. }
  105. /////////////////////////////////////////////////////////////////////////////
  106. //
  107. // Set_Status
  108. //
  109. /////////////////////////////////////////////////////////////////////////////
  110. void
  111. GeneratingPathfindDialogClass::Set_Status (LPCTSTR text, float percent)
  112. {
  113. if (percent > 0) {
  114. m_ProgressBar.SetPos (percent * 100);
  115. }
  116. SetDlgItemText (IDC_STATUS_TEXT, text);
  117. return ;
  118. }
  119. /////////////////////////////////////////////////////////////////////////////
  120. //
  121. // WindowProc
  122. //
  123. /////////////////////////////////////////////////////////////////////////////
  124. LRESULT
  125. GeneratingPathfindDialogClass::WindowProc
  126. (
  127. UINT message,
  128. WPARAM wParam,
  129. LPARAM lParam
  130. )
  131. {
  132. if (message == WM_USER + 101) {
  133. ::DestroyWindow (m_hWnd);
  134. ::PostQuitMessage (0);
  135. }
  136. return CDialog::WindowProc (message, wParam, lParam);
  137. }