TranslationExportDialog.cpp 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. /*
  2. ** Command & Conquer Renegade(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. // TranslationExportDialog.cpp : implementation file
  19. //
  20. #include "stdafx.h"
  21. #include "leveledit.h"
  22. #include "translationexportdialog.h"
  23. #include "translatedb.h"
  24. #include "export.h"
  25. #include "utils.h"
  26. #include "stringsmgr.h"
  27. #ifdef _DEBUG
  28. #define new DEBUG_NEW
  29. #undef THIS_FILE
  30. static char THIS_FILE[] = __FILE__;
  31. #endif
  32. /////////////////////////////////////////////////////////////////////////////
  33. // TranslationExportDialogClass dialog
  34. TranslationExportDialogClass::TranslationExportDialogClass(CWnd* pParent /*=NULL*/) :
  35. IsInstaller (false),
  36. CDialog(TranslationExportDialogClass::IDD, pParent)
  37. {
  38. //{{AFX_DATA_INIT(TranslationExportDialogClass)
  39. // NOTE: the ClassWizard will add member initialization here
  40. //}}AFX_DATA_INIT
  41. return ;
  42. }
  43. void
  44. TranslationExportDialogClass::DoDataExchange(CDataExchange* pDX)
  45. {
  46. CDialog::DoDataExchange(pDX);
  47. //{{AFX_DATA_MAP(TranslationExportDialogClass)
  48. // NOTE: the ClassWizard will add DDX and DDV calls here
  49. //}}AFX_DATA_MAP
  50. return ;
  51. }
  52. BEGIN_MESSAGE_MAP(TranslationExportDialogClass, CDialog)
  53. //{{AFX_MSG_MAP(TranslationExportDialogClass)
  54. //}}AFX_MSG_MAP
  55. END_MESSAGE_MAP()
  56. /////////////////////////////////////////////////////////////////////////////
  57. // TranslationExportDialogClass message handlers
  58. ///////////////////////////////////////////////////////////////////////////
  59. //
  60. // OnInitDialog
  61. //
  62. ///////////////////////////////////////////////////////////////////////////
  63. BOOL
  64. TranslationExportDialogClass::OnInitDialog (void)
  65. {
  66. CDialog::OnInitDialog ();
  67. //
  68. // Select english by default
  69. //
  70. SendDlgItemMessage (IDC_LANG_COMBO, CB_SETCURSEL, TranslateDBClass::LANGID_ENGLISH);
  71. return TRUE;
  72. }
  73. ///////////////////////////////////////////////////////////////////////////
  74. //
  75. // OnOK
  76. //
  77. ///////////////////////////////////////////////////////////////////////////
  78. void
  79. TranslationExportDialogClass::OnOK (void)
  80. {
  81. //
  82. // Export the data...
  83. //
  84. int lang_id = SendDlgItemMessage (IDC_LANG_COMBO, CB_GETCURSEL);
  85. if (lang_id >= 0) {
  86. //
  87. // Make sure the translate database is loaded into memory
  88. //
  89. StringsMgrClass::Load_Translation_Database ();
  90. //
  91. // Switch the database to the requested language...
  92. //
  93. TranslateDBClass::Set_Current_Language (lang_id);
  94. TranslateDBClass::Enable_Single_Language_Export (true);
  95. //
  96. // Export the installer string separate from the game strings
  97. //
  98. if (IsInstaller == false) {
  99. Export_Game_Strings ();
  100. } else {
  101. Export_Installer_Strings ();
  102. }
  103. //
  104. // Restore english
  105. //
  106. TranslateDBClass::Enable_Single_Language_Export (false);
  107. TranslateDBClass::Set_Current_Language (TranslateDBClass::LANGID_ENGLISH);
  108. }
  109. CDialog::OnOK();
  110. return ;
  111. }
  112. ///////////////////////////////////////////////////////////////////////////
  113. //
  114. // Export_Game_Strings
  115. //
  116. ///////////////////////////////////////////////////////////////////////////
  117. void
  118. TranslationExportDialogClass::Export_Game_Strings (void)
  119. {
  120. #if 0
  121. //
  122. // Don't export the installer strings...
  123. //
  124. TDBCategoryClass *category = TranslateDBClass::Find_Category ("Installer");
  125. if (category != NULL) {
  126. //
  127. // Filter out any strings that do not belong to this category
  128. //
  129. TranslateDBClass::Set_Export_Filter (TranslateDBClass::FILTER_IF_EQUAL, category->Get_ID ());
  130. }
  131. #endif
  132. //
  133. // Export this language
  134. //
  135. ExporterClass exporter;
  136. exporter.Export_Database_Mix (::Strip_Filename_From_Path (Filename));
  137. //
  138. // Turn off any filters we may have enabled
  139. //
  140. TranslateDBClass::Set_Export_Filter (TranslateDBClass::FILTER_DISABLED, 0);
  141. return ;
  142. }
  143. ///////////////////////////////////////////////////////////////////////////
  144. //
  145. // Export_Installer_Strings
  146. //
  147. ///////////////////////////////////////////////////////////////////////////
  148. void
  149. TranslationExportDialogClass::Export_Installer_Strings (void)
  150. {
  151. //
  152. // Find the category we wish to export
  153. //
  154. TDBCategoryClass *category = TranslateDBClass::Find_Category ("Installer");
  155. if (category != NULL) {
  156. //
  157. // Filter out any strings that do not belong to this category
  158. //
  159. TranslateDBClass::Set_Export_Filter (TranslateDBClass::FILTER_IF_NOT_EQUAL, category->Get_ID ());
  160. //
  161. // Save the database and restore the default filter
  162. //
  163. StringsMgrClass::Save_Translation_Database (Filename);
  164. TranslateDBClass::Set_Export_Filter (TranslateDBClass::FILTER_DISABLED, 0);
  165. }
  166. return ;
  167. }