ExportDlg.cpp 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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. // ExportDlg.cpp : implementation file
  19. //
  20. #include "stdafx.h"
  21. #include "noxstring.h"
  22. #include "ExportDlg.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. static int max_index;
  30. /////////////////////////////////////////////////////////////////////////////
  31. // CExportDlg dialog
  32. CExportDlg::CExportDlg(CWnd* pParent /*=NULL*/)
  33. : CDialog(CExportDlg::IDD, pParent)
  34. {
  35. //{{AFX_DATA_INIT(CExportDlg)
  36. // NOTE: the ClassWizard will add member initialization here
  37. //}}AFX_DATA_INIT
  38. }
  39. void CExportDlg::DoDataExchange(CDataExchange* pDX)
  40. {
  41. CDialog::DoDataExchange(pDX);
  42. //{{AFX_DATA_MAP(CExportDlg)
  43. // NOTE: the ClassWizard will add DDX and DDV calls here
  44. //}}AFX_DATA_MAP
  45. }
  46. BEGIN_MESSAGE_MAP(CExportDlg, CDialog)
  47. //{{AFX_MSG_MAP(CExportDlg)
  48. ON_CBN_SELCHANGE(IDC_COMBOLANG, OnSelchangeCombolang)
  49. ON_CBN_SELENDOK(IDC_COMBOLANG, OnSelendokCombolang)
  50. //}}AFX_MSG_MAP
  51. END_MESSAGE_MAP()
  52. /////////////////////////////////////////////////////////////////////////////
  53. // CExportDlg message handlers
  54. void CExportDlg::OnOK()
  55. {
  56. char buffer[100];
  57. char *ptr;
  58. // TODO: Add extra validation here
  59. CEdit *edit = (CEdit *) GetDlgItem ( IDC_FILENAME );
  60. CButton *all = (CButton *) GetDlgItem ( IDC_RADIOALL );
  61. CButton *button;
  62. CButton *sample = (CButton *) GetDlgItem ( IDC_RADIOSAMPLE );
  63. CButton *dialog = (CButton *) GetDlgItem ( IDC_RADIODIALOG );
  64. CButton *nondialog = (CButton *) GetDlgItem ( IDC_RADIONONDIALOG );
  65. CButton *unverified = (CButton *) GetDlgItem ( IDC_RADIOUNVERIFIED );
  66. CButton *missing = (CButton *) GetDlgItem ( IDC_RADIOMISSING );
  67. CButton *unsent = (CButton *) GetDlgItem ( IDC_RADIOUNSENT );
  68. edit->GetWindowText ( buffer, sizeof ( filename) -1 );
  69. _getcwd ( filename, sizeof (filename ) -1 );
  70. strcat ( filename, "\\" );
  71. if ( ( ptr = strchr ( buffer, '.' )))
  72. {
  73. *ptr = 0;
  74. }
  75. strcat ( filename, buffer );
  76. if ( all->GetCheck ())
  77. {
  78. options.filter = TR_ALL;
  79. }
  80. else if ( dialog->GetCheck ())
  81. {
  82. options.filter = TR_DIALOG;
  83. }
  84. else if ( nondialog->GetCheck ())
  85. {
  86. options.filter = TR_NONDIALOG;
  87. }
  88. else if ( sample->GetCheck ())
  89. {
  90. options.filter = TR_SAMPLE;
  91. }
  92. else if ( unverified->GetCheck ())
  93. {
  94. options.filter = TR_UNVERIFIED;
  95. }
  96. else if ( missing->GetCheck ())
  97. {
  98. options.filter = TR_MISSING_DIALOG;
  99. }
  100. else if ( unsent->GetCheck ())
  101. {
  102. options.filter = TR_UNSENT;
  103. }
  104. else
  105. {
  106. options.filter = TR_CHANGES;
  107. }
  108. options.include_comments = FALSE;
  109. button = (CButton *) GetDlgItem ( IDC_CHECKTRANS );
  110. options.include_translations = button->GetCheck ();
  111. CDialog::OnOK();
  112. }
  113. void CExportDlg::OnCancel()
  114. {
  115. // TODO: Add extra cleanup here
  116. langid = LANGID_UNKNOWN;
  117. CDialog::OnCancel();
  118. }
  119. BOOL CExportDlg::OnInitDialog()
  120. {
  121. int index;
  122. int lang_index;
  123. LANGINFO *info;
  124. CComboBox *combo;
  125. CEdit *edit = (CEdit *) GetDlgItem ( IDC_FILENAME );
  126. CButton *button = (CButton *) GetDlgItem ( IDC_RADIOCHANGES );
  127. CDialog::OnInitDialog();
  128. // TODO: Add extra initialization here
  129. combo = (CComboBox *) GetDlgItem ( IDC_COMBOLANG );
  130. combo->SetItemDataPtr ( 0, NULL );
  131. options.filter = TR_CHANGES;
  132. options.include_comments = FALSE;
  133. options.include_translations = FALSE;
  134. langid = LANGID_UNKNOWN;
  135. filename[0] = 0;
  136. button->SetCheck ( 1 );
  137. index = 0;
  138. lang_index = 0;
  139. got_lang = FALSE;
  140. while ( (info = GetLangInfo ( lang_index )) )
  141. {
  142. if ( TRUE )//info->langid != LANGID_US )
  143. {
  144. combo->InsertString ( index, info->name );
  145. combo->SetItemDataPtr ( index, info );
  146. if ( info->langid == CurrentLanguage )
  147. {
  148. combo->SetCurSel ( index );
  149. got_lang = TRUE;
  150. }
  151. index++;
  152. }
  153. lang_index++;
  154. }
  155. max_index = index;
  156. if ( !got_lang )
  157. {
  158. combo->InsertString ( 0, "Select language" );
  159. combo->SetCurSel ( 0 );
  160. max_index++;
  161. }
  162. edit->SetLimitText ( 8 );
  163. OnSelchangeCombolang ();
  164. return TRUE; // return TRUE unless you set the focus to a control
  165. // EXCEPTION: OCX Property Pages should return FALSE
  166. }
  167. void CExportDlg::OnSelchangeCombolang()
  168. {
  169. // TODO: Add your control notification handler code here
  170. LANGINFO *info = NULL;
  171. int index;
  172. CButton *export = (CButton *) GetDlgItem ( IDOK );
  173. CComboBox *combo = (CComboBox *) GetDlgItem ( IDC_COMBOLANG );
  174. CEdit *edit = (CEdit *) GetDlgItem ( IDC_FILENAME );
  175. index = combo->GetCurSel ();
  176. if ( index >= 0 && index < max_index )
  177. {
  178. info = (LANGINFO *) combo->GetItemDataPtr ( index );
  179. }
  180. if ( info )
  181. {
  182. char buffer[10];
  183. edit->EnableWindow ( TRUE );
  184. sprintf ( buffer, "Generals_%s", info->initials );
  185. edit->SetWindowText ( buffer );
  186. export->EnableWindow ( TRUE );
  187. langid = info->langid;
  188. if ( !got_lang )
  189. {
  190. combo->DeleteString ( 0 );
  191. max_index--;
  192. got_lang = TRUE;
  193. }
  194. }
  195. else
  196. {
  197. edit->SetWindowText ("");
  198. edit->EnableWindow ( FALSE );
  199. export->EnableWindow ( FALSE );
  200. langid = LANGID_UNKNOWN;
  201. }
  202. }
  203. void CExportDlg::OnSelendokCombolang()
  204. {
  205. // TODO: Add your control notification handler code here
  206. int i = 0;
  207. }