MatchDlg.cpp 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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. // MatchDlg.cpp : implementation file
  19. //
  20. #include "stdafx.h"
  21. #include "noxstring.h"
  22. #include "MatchDlg.h"
  23. #ifdef _DEBUG
  24. #define new DEBUG_NEW
  25. #undef THIS_FILE
  26. static char THIS_FILE[] = __FILE__;
  27. #endif
  28. NoxText *MatchingNoxText = NULL;
  29. NoxText *MatchOriginalText;
  30. NoxLabel *MatchLabel;
  31. #define MAX_MATCH 256
  32. static NoxText *current_match = NULL;
  33. /////////////////////////////////////////////////////////////////////////////
  34. // CMatchDlg dialog
  35. CMatchDlg::CMatchDlg(CWnd* pParent /*=NULL*/)
  36. : CDialog(CMatchDlg::IDD, pParent)
  37. {
  38. //{{AFX_DATA_INIT(CMatchDlg)
  39. // NOTE: the ClassWizard will add member initialization here
  40. //}}AFX_DATA_INIT
  41. }
  42. void CMatchDlg::DoDataExchange(CDataExchange* pDX)
  43. {
  44. CDialog::DoDataExchange(pDX);
  45. //{{AFX_DATA_MAP(CMatchDlg)
  46. // NOTE: the ClassWizard will add DDX and DDV calls here
  47. //}}AFX_DATA_MAP
  48. }
  49. BEGIN_MESSAGE_MAP(CMatchDlg, CDialog)
  50. //{{AFX_MSG_MAP(CMatchDlg)
  51. ON_BN_CLICKED(IDC_NOMATCH, OnNomatch)
  52. ON_BN_CLICKED(IDC_MATCH, OnMatch)
  53. ON_BN_CLICKED(IDC_SKIP, OnSkip)
  54. ON_CBN_SELCHANGE(IDC_MATCHCOMBO, OnSelchangeMatchcombo)
  55. //}}AFX_MSG_MAP
  56. END_MESSAGE_MAP()
  57. /////////////////////////////////////////////////////////////////////////////
  58. // CMatchDlg message handlers
  59. void CMatchDlg::OnCancel()
  60. {
  61. // TODO: Add extra cleanup here
  62. MatchingNoxText = NULL;
  63. CDialog::OnCancel();
  64. }
  65. void CMatchDlg::OnNomatch()
  66. {
  67. // TODO: Add your control notification handler code here
  68. MatchingNoxText = NULL;
  69. CDialog::OnOK ();
  70. }
  71. void CMatchDlg::OnMatch()
  72. {
  73. // TODO: Add your control notification handler code here
  74. if ( (MatchingNoxText = current_match ) )
  75. {
  76. CButton *check = (CButton *) GetDlgItem ( IDC_CHECKRETRANSLATE );
  77. current_match->SetRetranslate ( check->GetCheck ());
  78. }
  79. CDialog::OnOK ();
  80. }
  81. BOOL CMatchDlg::OnInitDialog()
  82. {
  83. NoxText *text;
  84. ListSearch sh;
  85. int index;
  86. CStatic *newtext;
  87. CComboBox *combo;
  88. static char buffer[4*1024];
  89. sprintf ( buffer, "Resolve umatched text from \"%s\" on line %d", MatchLabel->NameSB(),
  90. MatchOriginalText->LineNumber() );
  91. SetWindowText ( buffer );
  92. CDialog::OnInitDialog();
  93. current_match = NULL;
  94. newtext = (CStatic *) GetDlgItem ( IDC_NEWTEXT );
  95. newtext->SetWindowText ( MatchOriginalText->GetSB());
  96. combo = (CComboBox *) GetDlgItem ( IDC_MATCHCOMBO );
  97. CButton *check = (CButton *) GetDlgItem ( IDC_CHECKRETRANSLATE );
  98. check->SetCheck ( 1 );
  99. text = MatchLabel->FirstText ( sh );
  100. index = 0;
  101. while ( text )
  102. {
  103. if ( !text->Matched ())
  104. {
  105. int result;
  106. result = combo->InsertString ( index, text->GetSB ());
  107. result = combo->SetItemDataPtr ( index, text );
  108. if ( result == CB_ERR )
  109. {
  110. result = 0;
  111. }
  112. if ( result == CB_ERRSPACE )
  113. {
  114. result = 0;
  115. }
  116. index++;
  117. }
  118. text = MatchLabel->NextText ( sh );
  119. }
  120. combo->SetCurSel ( 0 );
  121. OnSelchangeMatchcombo();
  122. MatchingNoxText = NULL;
  123. // TODO: Add extra initialization here
  124. return TRUE; // return TRUE unless you set the focus to a control
  125. // EXCEPTION: OCX Property Pages should return FALSE
  126. }
  127. void CMatchDlg::OnSelchangeMatchcombo()
  128. {
  129. // TODO: Add your control notification handler code here
  130. int index;
  131. CComboBox *combo = (CComboBox *) GetDlgItem ( IDC_MATCHCOMBO );
  132. index = combo->GetCurSel ();
  133. if ( index >= 0 )
  134. {
  135. CStatic *newtext = (CStatic *) GetDlgItem ( IDC_MATCHTEXT );
  136. current_match = (NoxText *) combo->GetItemDataPtr ( index );
  137. newtext->SetWindowText ( current_match->GetSB());
  138. }
  139. else
  140. {
  141. current_match = NULL;
  142. }
  143. }
  144. void CMatchDlg::OnSkip()
  145. {
  146. // TODO: Add your control notification handler code here
  147. EndDialog ( IDSKIP );
  148. }