GenerateDlg.cpp 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  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. // GenerateDlg.cpp : implementation file
  19. //
  20. #include "stdafx.h"
  21. #include "noxstring.h"
  22. #include "GenerateDlg.h"
  23. #include "direct.h"
  24. #ifdef _DEBUG
  25. #define new DEBUG_NEW
  26. #undef THIS_FILE
  27. static char THIS_FILE[] = __FILE__;
  28. #endif
  29. /////////////////////////////////////////////////////////////////////////////
  30. // CGenerateDlg dialog
  31. CGenerateDlg::CGenerateDlg(CWnd* pParent /*=NULL*/)
  32. : CDialog(CGenerateDlg::IDD, pParent)
  33. {
  34. options.format = GN_UNICODE;
  35. options.untranslated = GN_USEIDS;
  36. langids[0] = LANGID_UNKNOWN;
  37. filename[0] = 0;
  38. //{{AFX_DATA_INIT(CGenerateDlg)
  39. // NOTE: the ClassWizard will add member initialization here
  40. //}}AFX_DATA_INIT
  41. }
  42. void CGenerateDlg::DoDataExchange(CDataExchange* pDX)
  43. {
  44. CDialog::DoDataExchange(pDX);
  45. //{{AFX_DATA_MAP(CGenerateDlg)
  46. // NOTE: the ClassWizard will add DDX and DDV calls here
  47. //}}AFX_DATA_MAP
  48. }
  49. BEGIN_MESSAGE_MAP(CGenerateDlg, CDialog)
  50. //{{AFX_MSG_MAP(CGenerateDlg)
  51. ON_BN_CLICKED(IDC_SELECTALL, OnSelectall)
  52. ON_BN_CLICKED(IDC_INVERT, OnInvert)
  53. ON_EN_CHANGE(IDC_PREFIX, OnChangePrefix)
  54. ON_BN_CLICKED(IDC_NOXSTR, OnNoxstr)
  55. ON_BN_CLICKED(IDC_UNICODE, OnUnicode)
  56. ON_BN_CLICKED(IDC_IDS, OnIds)
  57. ON_BN_CLICKED(IDC_ORIGINAL, OnOriginal)
  58. //}}AFX_MSG_MAP
  59. END_MESSAGE_MAP()
  60. /////////////////////////////////////////////////////////////////////////////
  61. // CGenerateDlg message handlers
  62. BOOL CGenerateDlg::OnInitDialog()
  63. {
  64. int index;
  65. LANGINFO *info;
  66. edit = (CEdit *) GetDlgItem ( IDC_PREFIX );
  67. unicode = (CButton *) GetDlgItem ( IDC_UNICODE );
  68. strfile = (CButton *) GetDlgItem ( IDC_NOXSTR );
  69. useids = (CButton *) GetDlgItem ( IDC_IDS );
  70. usetext = (CButton *) GetDlgItem ( IDC_ORIGINAL );
  71. list = (CListBox *) GetDlgItem ( IDC_LANGUAGE );
  72. filetext = ( CStatic *) GetDlgItem ( IDC_FILENAME );
  73. CDialog::OnInitDialog();
  74. // TODO: Add extra initialization here
  75. unicode->SetCheck ( 1 );
  76. useids->SetCheck ( 1 );
  77. edit->SetWindowText ( "Generals" );
  78. edit->SetLimitText ( 5 );
  79. OnChangePrefix ();
  80. index = 0;
  81. while ( (info = GetLangInfo ( index )) )
  82. {
  83. list->InsertString ( index, info->name );
  84. if ( info->langid == CurrentLanguage )
  85. {
  86. list->SetSel ( index );
  87. }
  88. index++;
  89. }
  90. num_langs = index;
  91. return TRUE; // return TRUE unless you set the focus to a control
  92. // EXCEPTION: OCX Property Pages should return FALSE
  93. }
  94. void CGenerateDlg::OnSelectall()
  95. {
  96. // TODO: Add your control notification handler code here
  97. list->SelItemRange ( TRUE, 0, num_langs-1 );
  98. }
  99. void CGenerateDlg::OnInvert()
  100. {
  101. // TODO: Add your control notification handler code here
  102. int index = 0;
  103. while ( index < num_langs )
  104. {
  105. list->SetSel ( index, !list->GetSel ( index ));
  106. index++;
  107. }
  108. }
  109. void CGenerateDlg::OnChangePrefix()
  110. {
  111. char buffer[30];
  112. edit->GetWindowText ( buffer, 6 );
  113. if ( options.format == GN_NOXSTR )
  114. {
  115. strcat ( buffer, "_{xx}.str" );
  116. }
  117. else
  118. {
  119. strcat ( buffer, "_{xx}.csf" );
  120. }
  121. filetext->SetWindowText ( buffer );
  122. }
  123. void CGenerateDlg::OnNoxstr()
  124. {
  125. // TODO: Add your control notification handler code here
  126. options.format = GN_NOXSTR;
  127. OnChangePrefix ();
  128. unicode->SetCheck ( 0 );
  129. }
  130. void CGenerateDlg::OnUnicode()
  131. {
  132. // TODO: Add your control notification handler code here
  133. options.format = GN_UNICODE;
  134. OnChangePrefix ();
  135. strfile->SetCheck ( 0 );
  136. }
  137. void CGenerateDlg::OnCancel()
  138. {
  139. // TODO: Add extra cleanup here
  140. CDialog::OnCancel();
  141. }
  142. void CGenerateDlg::OnOK()
  143. {
  144. char buffer[30];
  145. int count;
  146. int i;
  147. // TODO: Add extra validation here
  148. edit->GetWindowText ( buffer, sizeof ( filename) -1 );
  149. _getcwd ( filename, sizeof (filename ) -1 );
  150. strcat ( filename, "\\" );
  151. strcat ( filename, buffer );
  152. count = list->GetSelItems ( num_langs, langindices );
  153. if ( !count )
  154. {
  155. AfxMessageBox ( "No languages selected" );
  156. return;
  157. }
  158. num_langs = 0;
  159. for ( i = 0; i <count; i++ )
  160. {
  161. LANGINFO *info;
  162. if ( info = GetLangInfo ( langindices[i] ))
  163. {
  164. langids[num_langs++] = info->langid;
  165. }
  166. }
  167. langids[num_langs] = LANGID_UNKNOWN;
  168. CDialog::OnOK();
  169. }
  170. void CGenerateDlg::OnIds()
  171. {
  172. options.untranslated = GN_USEIDS;
  173. usetext->SetCheck ( 0 );
  174. }
  175. void CGenerateDlg::OnOriginal()
  176. {
  177. options.untranslated = GN_USEORIGINAL;
  178. useids->SetCheck ( 0 );
  179. }