Vector3Dialog.cpp 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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. // Vector3Dialog.cpp : implementation file
  19. //
  20. #include "stdafx.h"
  21. #include "leveledit.h"
  22. #include "Vector3Dialog.h"
  23. #include "utils.h"
  24. #ifdef _DEBUG
  25. #define new DEBUG_NEW
  26. #undef THIS_FILE
  27. static char THIS_FILE[] = __FILE__;
  28. #endif
  29. /////////////////////////////////////////////////////////////////////////////
  30. //
  31. // Vector3DialogClass
  32. //
  33. /////////////////////////////////////////////////////////////////////////////
  34. Vector3DialogClass::Vector3DialogClass (CWnd *parent)
  35. : m_DefaultValue (0, 0, 0),
  36. CDialog (Vector3DialogClass::IDD, parent)
  37. {
  38. //{{AFX_DATA_INIT(Vector3DialogClass)
  39. // NOTE: the ClassWizard will add member initialization here
  40. //}}AFX_DATA_INIT
  41. return ;
  42. }
  43. /////////////////////////////////////////////////////////////////////////////
  44. //
  45. // DoDataExchange
  46. //
  47. /////////////////////////////////////////////////////////////////////////////
  48. void
  49. Vector3DialogClass::DoDataExchange (CDataExchange* pDX)
  50. {
  51. CDialog::DoDataExchange(pDX);
  52. //{{AFX_DATA_MAP(Vector3DialogClass)
  53. DDX_Control(pDX, IDC_Z_STATIC, m_ZStatic);
  54. DDX_Control(pDX, IDC_Y_STATIC, m_YStatic);
  55. DDX_Control(pDX, IDC_X_STATIC, m_XStatic);
  56. DDX_Control(pDX, IDC_Z_EDIT, m_ZEdit);
  57. DDX_Control(pDX, IDC_Y_EDIT, m_YEdit);
  58. DDX_Control(pDX, IDC_X_EDIT, m_XEdit);
  59. DDX_Control(pDX, IDC_Z_SPIN, m_ZSpin);
  60. DDX_Control(pDX, IDC_Y_SPIN, m_YSpin);
  61. DDX_Control(pDX, IDC_X_SPIN, m_XSpin);
  62. //}}AFX_DATA_MAP
  63. return ;
  64. }
  65. BEGIN_MESSAGE_MAP(Vector3DialogClass, CDialog)
  66. //{{AFX_MSG_MAP(Vector3DialogClass)
  67. ON_WM_CREATE()
  68. //}}AFX_MSG_MAP
  69. END_MESSAGE_MAP()
  70. /////////////////////////////////////////////////////////////////////////////
  71. //
  72. // OnCreate
  73. //
  74. /////////////////////////////////////////////////////////////////////////////
  75. int
  76. Vector3DialogClass::OnCreate (LPCREATESTRUCT lpCreateStruct)
  77. {
  78. if (CDialog::OnCreate(lpCreateStruct) == -1)
  79. return -1;
  80. return 0;
  81. }
  82. /////////////////////////////////////////////////////////////////////////////
  83. //
  84. // Set_Default_Value
  85. //
  86. /////////////////////////////////////////////////////////////////////////////
  87. void
  88. Vector3DialogClass::Set_Default_Value (const Vector3 &value)
  89. {
  90. m_DefaultValue = value;
  91. //
  92. // Put the default values into the controls
  93. //
  94. ::SetWindowFloat (m_XEdit, m_DefaultValue.X);
  95. ::SetWindowFloat (m_YEdit, m_DefaultValue.Y);
  96. ::SetWindowFloat (m_ZEdit, m_DefaultValue.Z);
  97. return ;
  98. }
  99. /////////////////////////////////////////////////////////////////////////////
  100. //
  101. // Get_Current_Value
  102. //
  103. /////////////////////////////////////////////////////////////////////////////
  104. Vector3
  105. Vector3DialogClass::Get_Current_Value (void)
  106. {
  107. Vector3 retval (0, 0, 0);
  108. //
  109. // Get the current value from the controls
  110. //
  111. retval.X = ::GetWindowFloat (m_XEdit, true);
  112. retval.Y = ::GetWindowFloat (m_YEdit, true);
  113. retval.Z = ::GetWindowFloat (m_ZEdit, true);
  114. return retval;
  115. }
  116. /////////////////////////////////////////////////////////////////////////////
  117. //
  118. // Create
  119. //
  120. /////////////////////////////////////////////////////////////////////////////
  121. void
  122. Vector3DialogClass::Create (CWnd *parent)
  123. {
  124. CDialog::Create (Vector3DialogClass::IDD, parent);
  125. return ;
  126. }
  127. /////////////////////////////////////////////////////////////////////////////
  128. //
  129. // OnInitDialog
  130. //
  131. /////////////////////////////////////////////////////////////////////////////
  132. BOOL
  133. Vector3DialogClass::OnInitDialog (void)
  134. {
  135. CDialog::OnInitDialog();
  136. //
  137. // Turn all the edit controls into 'float' controls that will
  138. // allow the user to type only numbers (with decimals and signs)
  139. //
  140. ::Make_Edit_Float_Ctrl (m_XEdit);
  141. ::Make_Edit_Float_Ctrl (m_YEdit);
  142. ::Make_Edit_Float_Ctrl (m_ZEdit);
  143. //
  144. // Set the float control ranges
  145. //
  146. m_XSpin.SetRange32 (-1000000, 1000000);
  147. m_YSpin.SetRange32 (-1000000, 1000000);
  148. m_ZSpin.SetRange32 (-1000000, 1000000);
  149. //
  150. // Set the default values for the control
  151. //
  152. ::SetWindowFloat (m_XEdit, m_DefaultValue.X);
  153. ::SetWindowFloat (m_YEdit, m_DefaultValue.Y);
  154. ::SetWindowFloat (m_ZEdit, m_DefaultValue.Z);
  155. return TRUE;
  156. }