BackgroundBMPDialog.cpp 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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. // BackgroundBMPDialog.cpp : implementation file
  19. //
  20. #include "stdafx.h"
  21. #include "w3dview.h"
  22. #include "BackgroundBMPDialog.h"
  23. #include "W3DViewDoc.H"
  24. #include "Utils.H"
  25. #ifdef _DEBUG
  26. #define new DEBUG_NEW
  27. #undef THIS_FILE
  28. static char THIS_FILE[] = __FILE__;
  29. #endif
  30. /////////////////////////////////////////////////////////////////////////////
  31. // CBackgroundBMPDialog dialog
  32. /////////////////////////////////////////////////////////////
  33. //
  34. // CBackgroundBMPDialog
  35. //
  36. CBackgroundBMPDialog::CBackgroundBMPDialog (CWnd* pParent /*=NULL*/)
  37. : CDialog(CBackgroundBMPDialog::IDD, pParent)
  38. {
  39. //{{AFX_DATA_INIT(CBackgroundBMPDialog)
  40. // NOTE: the ClassWizard will add member initialization here
  41. //}}AFX_DATA_INIT
  42. return ;
  43. }
  44. /////////////////////////////////////////////////////////////
  45. //
  46. // DoDataExchange
  47. //
  48. void
  49. CBackgroundBMPDialog::DoDataExchange (CDataExchange* pDX)
  50. {
  51. // Allow the base class to process this message
  52. CDialog::DoDataExchange (pDX);
  53. //{{AFX_DATA_MAP(CBackgroundBMPDialog)
  54. // NOTE: the ClassWizard will add DDX and DDV calls here
  55. //}}AFX_DATA_MAP
  56. return ;
  57. }
  58. BEGIN_MESSAGE_MAP(CBackgroundBMPDialog, CDialog)
  59. //{{AFX_MSG_MAP(CBackgroundBMPDialog)
  60. ON_BN_CLICKED(IDC_BROWSE, OnBrowse)
  61. //}}AFX_MSG_MAP
  62. END_MESSAGE_MAP()
  63. /////////////////////////////////////////////////////////////////////////////
  64. // CBackgroundBMPDialog message handlers
  65. /////////////////////////////////////////////////////////////
  66. //
  67. // OnInitDialog
  68. //
  69. BOOL
  70. CBackgroundBMPDialog::OnInitDialog (void)
  71. {
  72. // Allow the base class to process this message
  73. CDialog::OnInitDialog ();
  74. // Center the dialog around the data tree view instead
  75. // of the direct center of the screen
  76. ::CenterDialogAroundTreeView (m_hWnd);
  77. // Gett a pointer to the current document
  78. CW3DViewDoc *pCDoc = ::GetCurrentDocument ();
  79. if (pCDoc)
  80. {
  81. // Set the initial filename in the edit control
  82. SetDlgItemText (IDC_FILENAME_EDIT, pCDoc->GetBackgroundBMP ());
  83. }
  84. return TRUE;
  85. }
  86. /////////////////////////////////////////////////////////////
  87. //
  88. // OnOK
  89. //
  90. void
  91. CBackgroundBMPDialog::OnOK (void)
  92. {
  93. // Gett a pointer to the current document
  94. CW3DViewDoc *pCDoc = ::GetCurrentDocument ();
  95. if (pCDoc)
  96. {
  97. CString stringBackgroundBMPName;
  98. // Get the filename the user entered
  99. if (GetDlgItemText (IDC_FILENAME_EDIT, stringBackgroundBMPName) > 0)
  100. {
  101. // Ask the doc to create a new background from this BMP
  102. pCDoc->SetBackgroundBMP (stringBackgroundBMPName);
  103. }
  104. else
  105. {
  106. // Ask the doc to clear any existing background BMP
  107. pCDoc->SetBackgroundBMP (NULL);
  108. }
  109. }
  110. // Allow the base class to process this message
  111. CDialog::OnOK ();
  112. return ;
  113. }
  114. /////////////////////////////////////////////////////////////
  115. //
  116. // OnBrowse
  117. //
  118. void
  119. CBackgroundBMPDialog::OnBrowse (void)
  120. {
  121. // Get a pointer to the current document
  122. CW3DViewDoc *pCDoc = ::GetCurrentDocument ();
  123. if (pCDoc)
  124. {
  125. CFileDialog openFileDialog (TRUE,
  126. ".tga",
  127. pCDoc->GetBackgroundBMP (),
  128. OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_EXPLORER,
  129. "Targa files (*.tga)|*.tga||",
  130. this);
  131. // Ask the user what Targa file they wish to load
  132. if (openFileDialog.DoModal () == IDOK)
  133. {
  134. // Set the text of the filename edit control
  135. SetDlgItemText (IDC_FILENAME_EDIT, openFileDialog.GetPathName ());
  136. }
  137. }
  138. return ;
  139. }