EditConversationRemarkDialog.cpp 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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. // EditConversationRemarkDialog.cpp : implementation file
  19. //
  20. #include "stdafx.h"
  21. #include "leveledit.h"
  22. #include "editconversationremarkdialog.h"
  23. #include "stringsmgr.h"
  24. #include "translatedb.h"
  25. #include "translateobj.h"
  26. #ifdef _DEBUG
  27. #define new DEBUG_NEW
  28. #undef THIS_FILE
  29. static char THIS_FILE[] = __FILE__;
  30. #endif
  31. /////////////////////////////////////////////////////////////////////////////
  32. // Constants
  33. /////////////////////////////////////////////////////////////////////////////
  34. static const int ORATOR_MAX = 7;
  35. typedef struct _ORATOR_BUTTON_INFO
  36. {
  37. int button_id;
  38. int icon_id;
  39. } ORATOR_BUTTON_INFO;
  40. const ORATOR_BUTTON_INFO ORATOR_BUTTONS[ORATOR_MAX] =
  41. {
  42. { IDC_ORATOR1_RADIO, IDI_ORATOR1 },
  43. { IDC_ORATOR2_RADIO, IDI_ORATOR2 },
  44. { IDC_ORATOR3_RADIO, IDI_ORATOR3 },
  45. { IDC_ORATOR4_RADIO, IDI_ORATOR4 },
  46. { IDC_ORATOR5_RADIO, IDI_ORATOR5 },
  47. { IDC_ORATOR6_RADIO, IDI_ORATOR6 },
  48. { IDC_ORATOR7_RADIO, IDI_ORATOR7 }
  49. };
  50. /////////////////////////////////////////////////////////////////////////////
  51. //
  52. // EditConversationRemarkDialogClass
  53. //
  54. /////////////////////////////////////////////////////////////////////////////
  55. EditConversationRemarkDialogClass::EditConversationRemarkDialogClass(CWnd* pParent /*=NULL*/)
  56. : m_OratorBitmask (1),
  57. CDialog(EditConversationRemarkDialogClass::IDD, pParent)
  58. {
  59. //{{AFX_DATA_INIT(EditConversationRemarkDialogClass)
  60. // NOTE: the ClassWizard will add member initialization here
  61. //}}AFX_DATA_INIT
  62. return ;
  63. }
  64. /////////////////////////////////////////////////////////////////////////////
  65. //
  66. // DoDataExchange
  67. //
  68. /////////////////////////////////////////////////////////////////////////////
  69. void
  70. EditConversationRemarkDialogClass::DoDataExchange (CDataExchange *pDX)
  71. {
  72. CDialog::DoDataExchange(pDX);
  73. //{{AFX_DATA_MAP(EditConversationRemarkDialogClass)
  74. //}}AFX_DATA_MAP
  75. return ;
  76. }
  77. BEGIN_MESSAGE_MAP(EditConversationRemarkDialogClass, CDialog)
  78. //{{AFX_MSG_MAP(EditConversationRemarkDialogClass)
  79. //}}AFX_MSG_MAP
  80. END_MESSAGE_MAP()
  81. /////////////////////////////////////////////////////////////////////////////
  82. //
  83. // OnInitDialog
  84. //
  85. /////////////////////////////////////////////////////////////////////////////
  86. BOOL
  87. EditConversationRemarkDialogClass::OnInitDialog (void)
  88. {
  89. CDialog::OnInitDialog ();
  90. //
  91. // Assign icons to each of the orator buttons
  92. //
  93. for (int index = 0; index < ORATOR_MAX; index ++) {
  94. HICON icon = ::LoadIcon (::AfxGetResourceHandle (), MAKEINTRESOURCE (ORATOR_BUTTONS[index].icon_id));
  95. SendDlgItemMessage (ORATOR_BUTTONS[index].button_id, BM_SETIMAGE, IMAGE_ICON, (LPARAM)icon);
  96. //
  97. // Disable this button if the user hasn't configured the orator
  98. //
  99. if ((m_OratorBitmask & (1 << index)) == false) {
  100. ::EnableWindow (::GetDlgItem (m_hWnd, ORATOR_BUTTONS[index].button_id), FALSE);
  101. }
  102. }
  103. //
  104. // Select the current orator
  105. //
  106. SendDlgItemMessage (ORATOR_BUTTONS[Remark.Get_Orator_ID ()].button_id, BM_SETCHECK, TRUE);
  107. //
  108. // Put the animation name into the text field
  109. //
  110. SetDlgItemText (IDC_ANIMATION_NAME, Remark.Get_Animation_Name ());
  111. //
  112. // Calculate the rectangle where we are to display the string picker
  113. //
  114. CRect rect;
  115. ::GetWindowRect (::GetDlgItem (m_hWnd, IDC_PICKER_AREA), &rect);
  116. ScreenToClient (&rect);
  117. //
  118. // Create the string picker
  119. //
  120. StringPicker.Set_Selection (Remark.Get_Text_ID ());
  121. StringPicker.Create (this);
  122. StringPicker.SetWindowPos (NULL, rect.left, rect.top, rect.Width (), rect.Height (), SWP_NOZORDER);
  123. StringPicker.ShowWindow (SW_SHOW);
  124. return TRUE;
  125. }
  126. /////////////////////////////////////////////////////////////////////////////
  127. //
  128. // OnOK
  129. //
  130. /////////////////////////////////////////////////////////////////////////////
  131. void
  132. EditConversationRemarkDialogClass::OnOK (void)
  133. {
  134. //
  135. // Assign icons to each of the orator buttons
  136. //
  137. for (int index = 0; index < ORATOR_MAX; index ++) {
  138. if (SendDlgItemMessage (ORATOR_BUTTONS[index].button_id, BM_GETCHECK) == 1) {
  139. Remark.Set_Orator_ID (index);
  140. break;
  141. }
  142. }
  143. //
  144. // Get the selected string from the picker object
  145. //
  146. Remark.Set_Text_ID (StringPicker.Get_Selection ());
  147. //
  148. // Get the animation name from the text field
  149. //
  150. CString animation_name;
  151. GetDlgItemText (IDC_ANIMATION_NAME, animation_name);
  152. //
  153. // Pass the animation name onto the remark object
  154. //
  155. Remark.Set_Animation_Name (animation_name);
  156. CDialog::OnOK ();
  157. return ;
  158. }