genmtlnamesdialog.cpp 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  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. /***********************************************************************************************
  19. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Max2W3D *
  23. * *
  24. * $Archive:: /Commando/Code/Tools/max2w3d/genmtlnamesdialog.cpp $*
  25. * *
  26. * Original Author:: Greg Hjelstrom *
  27. * *
  28. * $Author:: Greg_h $*
  29. * *
  30. * $Modtime:: 10/10/00 11:12a $*
  31. * *
  32. * $Revision:: 1 $*
  33. * *
  34. *---------------------------------------------------------------------------------------------*
  35. * Functions: *
  36. * GenMtlNamesDialogClass::GenMtlNamesDialogClass -- Constructor *
  37. * GenMtlNamesDialogClass::~GenMtlNamesDialogClass -- Destructor *
  38. * GenMtlNamesDialogClass::Get_Options -- present the dialog, get user input *
  39. * GenMtlNamesDialogClass::Ok_To_Exit -- verify that the input is valid *
  40. * GenMtlNamesDialogClass::Dialog_Proc -- windows message handling *
  41. * _gen_mtl_names_dialog_proc -- windows dialog proc for GenMtlNamesDialog *
  42. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  43. #include "genmtlnamesdialog.h"
  44. #include "dllmain.h"
  45. #include "resource.h"
  46. #include "w3d_file.h"
  47. #include <Max.h>
  48. static BOOL CALLBACK _gen_mtl_names_dialog_proc(HWND Hwnd,UINT message,WPARAM wParam,LPARAM lParam);
  49. /**********************************************************************************************
  50. **
  51. ** GenMtlNamesDialogClass Implementation
  52. **
  53. **********************************************************************************************/
  54. /***********************************************************************************************
  55. * GenMtlNamesDialogClass::GenMtlNamesDialogClass -- Constructor *
  56. * *
  57. * INPUT: *
  58. * *
  59. * OUTPUT: *
  60. * *
  61. * WARNINGS: *
  62. * *
  63. * HISTORY: *
  64. *=============================================================================================*/
  65. GenMtlNamesDialogClass::GenMtlNamesDialogClass(Interface * maxinterface) :
  66. Hwnd(NULL),
  67. Options(NULL),
  68. MaxInterface(maxinterface),
  69. NameIndexSpin(NULL)
  70. {
  71. }
  72. /***********************************************************************************************
  73. * GenMtlNamesDialogClass::~GenMtlNamesDialogClass -- Destructor *
  74. * *
  75. * INPUT: *
  76. * *
  77. * OUTPUT: *
  78. * *
  79. * WARNINGS: *
  80. * *
  81. * HISTORY: *
  82. * 10/10/2000 gth : Created. *
  83. *=============================================================================================*/
  84. GenMtlNamesDialogClass::~GenMtlNamesDialogClass(void)
  85. {
  86. ReleaseISpinner(NameIndexSpin);
  87. }
  88. /***********************************************************************************************
  89. * GenMtlNamesDialogClass::Get_Options -- present the dialog, get user input *
  90. * *
  91. * INPUT: *
  92. * options - pointer to structure to hold the user's input *
  93. * *
  94. * OUTPUT: *
  95. * true - user pressed ok and the input is valid *
  96. * *
  97. * WARNINGS: *
  98. * *
  99. * HISTORY: *
  100. * 10/10/2000 gth : Created. *
  101. *=============================================================================================*/
  102. bool GenMtlNamesDialogClass::Get_Options(OptionsStruct * options)
  103. {
  104. Options = options;
  105. // Put up the options dialog box.
  106. BOOL result = DialogBoxParam
  107. (
  108. AppInstance,
  109. MAKEINTRESOURCE (IDD_GENERATE_MTL_NAMES_DIALOG),
  110. MaxInterface->GetMAXHWnd(),
  111. (DLGPROC) _gen_mtl_names_dialog_proc,
  112. (LPARAM) this
  113. );
  114. if (result == TRUE) {
  115. return true;
  116. } else {
  117. return false;
  118. }
  119. }
  120. /***********************************************************************************************
  121. * GenMtlNamesDialogClass::Ok_To_Exit -- verify that the input is valid *
  122. * *
  123. * INPUT: *
  124. * *
  125. * OUTPUT: *
  126. * *
  127. * WARNINGS: *
  128. * *
  129. * HISTORY: *
  130. * 10/10/2000 gth : Created. *
  131. *=============================================================================================*/
  132. bool GenMtlNamesDialogClass::Ok_To_Exit(void)
  133. {
  134. // just check that the user entered a name
  135. char buf[W3D_NAME_LEN];
  136. GetWindowText(GetDlgItem(Hwnd,IDC_BASE_NAME_EDIT),buf,sizeof(buf));
  137. if (strlen(buf) == 0) {
  138. MessageBox(Hwnd,"Please enter a root name to use.\n","Error",MB_OK);
  139. return false;
  140. } else {
  141. return true;
  142. }
  143. return true;
  144. }
  145. /***********************************************************************************************
  146. * GenMtlNamesDialogClass::Dialog_Proc -- windows message handling *
  147. * *
  148. * INPUT: *
  149. * *
  150. * OUTPUT: *
  151. * *
  152. * WARNINGS: *
  153. * *
  154. * HISTORY: *
  155. * 10/10/2000 gth : Created. *
  156. *=============================================================================================*/
  157. bool GenMtlNamesDialogClass::Dialog_Proc(HWND hWnd,UINT message,WPARAM wParam,LPARAM)
  158. {
  159. switch (message ) {
  160. case WM_INITDIALOG:
  161. NameIndexSpin = SetupIntSpinner
  162. (
  163. Hwnd,
  164. IDC_NAME_INDEX_SPIN,
  165. IDC_NAME_INDEX_EDIT,
  166. MIN_NAME_INDEX,MAX_NAME_INDEX,INITIAL_NAME_INDEX
  167. );
  168. // limit the edit box characters
  169. SendDlgItemMessage(Hwnd,IDC_BASE_NAME_EDIT,EM_LIMITTEXT,MAX_ROOT_NAME_LEN,0);
  170. // set initial name to root of the filename
  171. char buf[_MAX_FNAME];
  172. _splitpath(MaxInterface->GetCurFileName(),NULL,NULL,buf,NULL);
  173. buf[MAX_ROOT_NAME_LEN+1] = 0;
  174. SetWindowText(GetDlgItem(Hwnd,IDC_BASE_NAME_EDIT),buf);
  175. // init radio buttons
  176. CheckDlgButton(Hwnd,IDC_AFFECT_ALL_RADIO,BST_UNCHECKED);
  177. CheckDlgButton(Hwnd,IDC_AFFECT_SELECTED_RADIO,BST_CHECKED);
  178. return 1;
  179. case WM_COMMAND:
  180. switch (LOWORD(wParam))
  181. {
  182. case IDOK:
  183. if (Ok_To_Exit()) {
  184. // general options
  185. Options->OnlyAffectSelected = (IsDlgButtonChecked(Hwnd,IDC_AFFECT_SELECTED_RADIO) == BST_CHECKED);
  186. // naming options
  187. Options->NameIndex = NameIndexSpin->GetIVal();
  188. GetWindowText(GetDlgItem(Hwnd,IDC_BASE_NAME_EDIT),Options->RootName,sizeof(Options->RootName));
  189. EndDialog(Hwnd, 1);
  190. }
  191. break;
  192. case IDCANCEL:
  193. EndDialog(Hwnd, 0);
  194. break;
  195. }
  196. return 1;
  197. }
  198. return 0;
  199. }
  200. /***********************************************************************************************
  201. * _gen_mtl_names_dialog_proc -- windows dialog proc for GenMtlNamesDialog *
  202. * *
  203. * INPUT: *
  204. * *
  205. * OUTPUT: *
  206. * *
  207. * WARNINGS: *
  208. * *
  209. * HISTORY: *
  210. * 10/10/2000 gth : Created. *
  211. *=============================================================================================*/
  212. static BOOL CALLBACK _gen_mtl_names_dialog_proc(HWND hwnd,UINT message,WPARAM wparam,LPARAM lparam)
  213. {
  214. static GenMtlNamesDialogClass * dialog = NULL;
  215. if (message == WM_INITDIALOG) {
  216. dialog = (GenMtlNamesDialogClass *)lparam;
  217. dialog->Hwnd = hwnd;
  218. }
  219. if (dialog) {
  220. return dialog->Dialog_Proc(hwnd, message, wparam, lparam);
  221. } else {
  222. return FALSE;
  223. }
  224. }