Report.cpp 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. /*
  2. ** Command & Conquer Generals Zero Hour(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. // Report.cpp : implementation file
  19. //
  20. #include "stdafx.h"
  21. #include "Babylon.h"
  22. #include "Report.h"
  23. #include <limits.h>
  24. #ifdef _DEBUG
  25. #define new DEBUG_NEW
  26. #undef THIS_FILE
  27. static char THIS_FILE[] = __FILE__;
  28. #endif
  29. /////////////////////////////////////////////////////////////////////////////
  30. // CReport dialog
  31. CReport::CReport(CWnd* pParent /*=NULL*/)
  32. : CDialog(CReport::IDD, pParent)
  33. {
  34. options.translations = TRUE;
  35. options.dialog = TRUE;
  36. options.limit = 0;
  37. langids[0] = LANGID_UNKNOWN;
  38. filename[0] = 0;
  39. //{{AFX_DATA_INIT(CReport)
  40. // NOTE: the ClassWizard will add member initialization here
  41. //}}AFX_DATA_INIT
  42. }
  43. void CReport::DoDataExchange(CDataExchange* pDX)
  44. {
  45. CDialog::DoDataExchange(pDX);
  46. //{{AFX_DATA_MAP(CReport)
  47. // NOTE: the ClassWizard will add DDX and DDV calls here
  48. //}}AFX_DATA_MAP
  49. }
  50. BEGIN_MESSAGE_MAP(CReport, CDialog)
  51. //{{AFX_MSG_MAP(CReport)
  52. ON_BN_CLICKED(IDC_INVERT, OnInvert)
  53. ON_BN_CLICKED(IDC_SELECTALL, OnSelectall)
  54. ON_BN_CLICKED(IDC_SHOW_DETAILS, OnShowDetails)
  55. //}}AFX_MSG_MAP
  56. END_MESSAGE_MAP()
  57. /////////////////////////////////////////////////////////////////////////////
  58. // CReport message handlers
  59. BOOL CReport::OnInitDialog()
  60. {
  61. int index;
  62. LANGINFO *info;
  63. limit = (CEdit *) GetDlgItem ( IDC_LIMIT );
  64. trans_status = (CButton *) GetDlgItem ( IDC_TRANSLATION_STATUS );
  65. dialog_status = (CButton *) GetDlgItem ( IDC_DIALOG_STATUS );
  66. show_details = (CButton *) GetDlgItem ( IDC_SHOW_DETAILS );
  67. ifless = (CButton *) GetDlgItem ( IDC_IFLESS );
  68. list = (CListBox *) GetDlgItem ( IDC_LANGUAGE );
  69. items = (CStatic *) GetDlgItem ( IDC_ITEMS );
  70. CDialog::OnInitDialog();
  71. // TODO: Add extra initialization here
  72. trans_status->SetCheck ( options.translations );
  73. dialog_status->SetCheck ( options.dialog );
  74. show_details->SetCheck ( 0 );
  75. ifless->SetCheck ( 1 );
  76. limit->EnableWindow ( FALSE );
  77. ifless->EnableWindow ( FALSE );
  78. items->EnableWindow ( FALSE );
  79. limit->SetWindowText ( "100" );
  80. limit->SetLimitText ( 50 );
  81. options.limit = 100;
  82. index = 0;
  83. while ( (info = GetLangInfo ( index )) )
  84. {
  85. list->InsertString ( index, info->name );
  86. if ( info->langid == CurrentLanguage )
  87. {
  88. list->SetSel ( index );
  89. }
  90. index++;
  91. }
  92. num_langs = index;
  93. return TRUE; // return TRUE unless you set the focus to a control
  94. // EXCEPTION: OCX Property Pages should return FALSE
  95. }
  96. void CReport::OnSelectall()
  97. {
  98. // TODO: Add your control notification handler code here
  99. list->SelItemRange ( TRUE, 0, num_langs-1 );
  100. }
  101. void CReport::OnInvert()
  102. {
  103. // TODO: Add your control notification handler code here
  104. int index = 0;
  105. while ( index < num_langs )
  106. {
  107. list->SetSel ( index, !list->GetSel ( index ));
  108. index++;
  109. }
  110. }
  111. void CReport::OnShowDetails()
  112. {
  113. // TODO: Add your control notification handler code here
  114. if ( show_details->GetCheck () == 0 )
  115. {
  116. ifless->EnableWindow ( FALSE );
  117. limit->EnableWindow ( FALSE );
  118. items->EnableWindow ( FALSE );
  119. }
  120. else
  121. {
  122. ifless->EnableWindow ( TRUE );
  123. limit->EnableWindow ( TRUE );
  124. items->EnableWindow ( TRUE );
  125. }
  126. }
  127. void CReport::OnOK()
  128. {
  129. int count;
  130. int i;
  131. char buffer[100];
  132. count = list->GetSelItems ( num_langs, langindices );
  133. if ( !count )
  134. {
  135. AfxMessageBox ( "No languages selected" );
  136. return;
  137. }
  138. // get the filename
  139. CFileDialog fd ( FALSE , NULL, "*.txt", OFN_OVERWRITEPROMPT | OFN_NOCHANGEDIR );
  140. if ( fd.DoModal () != IDOK )
  141. {
  142. return;
  143. }
  144. strcpy ( filename, fd.GetPathName ());
  145. num_langs = 0;
  146. for ( i = 0; i <count; i++ )
  147. {
  148. LANGINFO *info;
  149. if ( info = GetLangInfo ( langindices[i] ))
  150. {
  151. langids[num_langs++] = info->langid;
  152. }
  153. }
  154. langids[num_langs] = LANGID_UNKNOWN;
  155. options.dialog = dialog_status->GetCheck ();
  156. options.translations = trans_status->GetCheck ();
  157. limit->GetWindowText( buffer, sizeof(buffer)-1);
  158. options.limit = atoi ( buffer );
  159. if ( !show_details->GetCheck () )
  160. {
  161. options.limit = 0;
  162. }
  163. else if ( !ifless->GetCheck () )
  164. {
  165. options.limit = INT_MAX;
  166. }
  167. CDialog::OnOK();
  168. }
  169. void CReport::OnCancel()
  170. {
  171. // TODO: Add extra cleanup here
  172. CDialog::OnCancel();
  173. }