ViewDBsDlg.cpp 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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. // ViewDBsDlg.cpp : implementation file
  19. //
  20. #include "stdafx.h"
  21. #include "noxstring.h"
  22. #include "noxstringdlg.h"
  23. #include "VIEWDBSII.h"
  24. #include "transdb.h"
  25. #ifdef _DEBUG
  26. #define new DEBUG_NEW
  27. #undef THIS_FILE
  28. static char THIS_FILE[] = __FILE__;
  29. #endif
  30. int ViewChanges = FALSE;
  31. /////////////////////////////////////////////////////////////////////////////
  32. // CViewDBsDlg dialog
  33. VIEWDBSII::VIEWDBSII(CWnd* pParent /*=NULL*/)
  34. : CDialog(VIEWDBSII::IDD, pParent)
  35. {
  36. //{{AFX_DATA_INIT(CViewDBsDlg)
  37. // NOTE: the ClassWizard will add member initialization here
  38. //}}AFX_DATA_INIT
  39. }
  40. void VIEWDBSII::DoDataExchange(CDataExchange* pDX)
  41. {
  42. CDialog::DoDataExchange(pDX);
  43. //{{AFX_DATA_MAP(CViewDBsDlg)
  44. // NOTE: the ClassWizard will add DDX and DDV calls here
  45. //}}AFX_DATA_MAP
  46. }
  47. BEGIN_MESSAGE_MAP(VIEWDBSII, CDialog)
  48. //{{AFX_MSG_MAP(CViewDBsDlg)
  49. ON_WM_CLOSE()
  50. //}}AFX_MSG_MAP
  51. END_MESSAGE_MAP()
  52. /////////////////////////////////////////////////////////////////////////////
  53. // CViewDBsDlg message handlers
  54. static int label_count;
  55. static void progress_cb ( void )
  56. {
  57. label_count++;
  58. if ( MainDLG )
  59. {
  60. MainDLG->SetProgress ( label_count );
  61. }
  62. }
  63. HTREEITEM VIEWDBSII::create_full_view ( void )
  64. {
  65. CTreeCtrl *tc = ( CTreeCtrl *) GetDlgItem ( IDC_TREEVIEW );
  66. HTREEITEM root;
  67. TransDB *db;
  68. int count = 0;
  69. char *title = "Building database view...";
  70. MainDLG->Log ("");
  71. MainDLG->Status ( title );
  72. root = tc->InsertItem ( "DBs" );
  73. db = FirstTransDB ( );
  74. while ( db )
  75. {
  76. count += db->NumLabels ();
  77. count += db->NumObsolete ();
  78. db = db->Next ();
  79. }
  80. MainDLG->InitProgress ( count );
  81. label_count = 0;
  82. db = FirstTransDB ( );
  83. while ( db )
  84. {
  85. char buffer[100];
  86. sprintf ( buffer, "%s%s", title, db->Name());
  87. MainDLG->Status ( buffer, FALSE );
  88. db->AddToTree ( tc, root, FALSE, progress_cb );
  89. db = db->Next ();
  90. }
  91. MainDLG->Log ("OK", SAME_LINE );
  92. tc->Expand ( root, TVE_EXPAND );
  93. return root;
  94. }
  95. HTREEITEM VIEWDBSII::create_changes_view ( void )
  96. {
  97. CTreeCtrl *tc = ( CTreeCtrl *) GetDlgItem ( IDC_TREEVIEW );
  98. HTREEITEM root;
  99. TransDB *db;
  100. int count = 0;
  101. char *title = "Building changes view...";
  102. MainDLG->Log ("");
  103. MainDLG->Status ( title );
  104. db = FirstTransDB ( );
  105. while ( db )
  106. {
  107. if ( db->IsChanged ())
  108. {
  109. count += db->NumLabels ();
  110. count += db->NumObsolete ();
  111. }
  112. db = db->Next ();
  113. }
  114. if ( MainDLG )
  115. {
  116. MainDLG->InitProgress ( count );
  117. }
  118. if ( count )
  119. {
  120. root = tc->InsertItem ( "Changes" );
  121. }
  122. else
  123. {
  124. root = tc->InsertItem ( "No Changes" );
  125. }
  126. label_count = 0;
  127. db = FirstTransDB ( );
  128. while ( db )
  129. {
  130. char buffer[100];
  131. if ( db->IsChanged ())
  132. {
  133. sprintf ( buffer, "%s%s", title, db->Name());
  134. MainDLG->Status ( buffer, FALSE );
  135. db->AddToTree ( tc, root, TRUE, progress_cb );
  136. }
  137. db = db->Next ();
  138. }
  139. if ( MainDLG )
  140. {
  141. MainDLG->ProgressComplete ( );
  142. MainDLG->Log ("OK", SAME_LINE );
  143. MainDLG->Ready ();
  144. }
  145. tc->Expand ( root, TVE_EXPAND );
  146. return root;
  147. }
  148. BOOL VIEWDBSII::OnInitDialog()
  149. {
  150. HTREEITEM root;
  151. CDialog::OnInitDialog();
  152. // TODO: Add extra initialization here
  153. if ( !ViewChanges )
  154. {
  155. root = create_full_view ();
  156. }
  157. else
  158. {
  159. root = create_changes_view ();
  160. }
  161. MainDLG->Ready();
  162. return TRUE; // return TRUE unless you set the focus to a control
  163. // EXCEPTION: OCX Property Pages should return FALSE
  164. }
  165. void VIEWDBSII::OnClose()
  166. {
  167. // TODO: Add your message handler code here and/or call default
  168. CTreeCtrl *tc = ( CTreeCtrl *) GetDlgItem ( IDC_TREEVIEW );
  169. HTREEITEM root = tc->GetRootItem ();
  170. tc->Expand ( root, TVE_COLLAPSE );
  171. tc->DeleteAllItems ();
  172. CDialog::OnClose();
  173. }