VSSResourceBrowser.cpp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. #include "VSSResourceBrowser.h"
  2. #include "mainwindow.h"
  3. #include "panel.h"
  4. #define WINDOW_POSX 400
  5. #define WINDOW_POSY 10
  6. #define WINDOW_WIDTH 440
  7. #define WINDOW_HEIGHT 300
  8. extern TMainWindow* MainWindow;
  9. extern string VSSUserName;
  10. extern IGUIManager* igui;
  11. //extern SourceSafeItem VSSRoot;
  12. extern string MissionsSrcLocalFolder;
  13. extern TPanelWindow* PanelWindow;
  14. extern bool LoadCameraPosition;
  15. TVSSResourceBrowser::TVSSResourceBrowser (const char* szUserName) : GUIWindow (NULL, WINDOW_POSX, WINDOW_POSY, WINDOW_WIDTH, WINDOW_HEIGHT)
  16. {
  17. strVSSUserName = szUserName;
  18. bAlwaysOnTop = true;
  19. bSystemButton = false;
  20. Caption = "VSS Browser";
  21. TreeView1 = NEW GUITreeView(this, 5, 5, 320, 250);
  22. TreeView1->FontColor = 0xFF000000;
  23. TreeView1->pFont->SetName("arialcyrsmall");
  24. TreeView1->SetImagesArray ("gtree");
  25. //TreeView1->OnChange = (CONTROL_EVENT)SelectEvent;
  26. //TreeView1->OnBeforeChange = (CONTROL_EVENT)BeforeSelectEvent;
  27. //TreeView1->OnDblClick = (CONTROL_EVENT)SelectionChange;
  28. TreeView1->Items->Clear ();
  29. TreeView1->bDragAndDrop = false;
  30. //TreeView1->AfterDrop = (CONTROL_EVENT)WhenDrop;
  31. //TreeView1->BeforeDrop = (CONTROL_EVENT)BeforeDropItem;
  32. //TreeView1->OnCopyNode = (CONTROL_EVENT)WhenCopy;
  33. //TreeView1->OnBeforeHintShow = (CONTROL_EVENT)TreeShowHint;
  34. //TreeView1->OnRightSelect = (CONTROL_EVENT)FastObjectPropView;
  35. TreeView1->MakeFlat (true);
  36. btnOK = NEW GUIButton (this, 340,9, 78, 24);
  37. btnOK->Glyph->Load ("ok");
  38. btnOK->Caption = "Load";
  39. btnOK->pFont->SetSize (12);
  40. btnOK->OnMousePressed = (CONTROL_EVENT)&TVSSResourceBrowser::onOKPressed;
  41. btnOK->FlatButton = true;
  42. btnCancel = NEW GUIButton (this, 340,39, 78, 24);
  43. btnCancel->Glyph->Load ("cancel");
  44. btnCancel->Caption = "Cancel";
  45. btnCancel->pFont->SetSize (12);
  46. btnCancel->OnMousePressed = (CONTROL_EVENT)&TVSSResourceBrowser::onCancelPressed;
  47. btnCancel->FlatButton = true;
  48. SetScreenCenter ();
  49. }
  50. void TVSSResourceBrowser::OnCreate ()
  51. {
  52. //Max
  53. return;
  54. /*
  55. bool bDatabase = VSSAcess::VSSEnumDatabase(VSSRoot, strVSSUserName.c_str());
  56. if (bDatabase == false)
  57. {
  58. igui->MessageBox("Can't open VSS database", "Error", GUIMB_OK, true);
  59. Close (this);
  60. return;
  61. }
  62. SourceSafeItem &new_root = VSSRoot.Childs[0];
  63. //показываем не с корня а от нужного нам узла VSS
  64. GUITreeNode* pRoot = NEW GUITreeNode;
  65. pRoot->Text = new_root.Name;
  66. //pRoot->Text = root.Name;
  67. pRoot->Image->Load ("folder");
  68. pRoot->CanCopy = false;
  69. pRoot->Data = &VSSRoot.Childs[0];
  70. TreeView1->Items->Add (pRoot);
  71. AddRecursive(&pRoot->Childs, new_root);
  72. //AddRecursive(&pRoot->Childs, root);
  73. */
  74. }
  75. TVSSResourceBrowser::~TVSSResourceBrowser ()
  76. {
  77. }
  78. /*
  79. void TVSSResourceBrowser::AddRecursive (GUITreeNodes* pNodes, SourceSafeItem &root)
  80. {
  81. for (dword i = 0; i < root.Childs.Size(); i++)
  82. {
  83. GUITreeNode* pRoot = NEW GUITreeNode;
  84. pRoot->Text = root.Childs[i].Name;
  85. pRoot->Data = &root.Childs[i];
  86. SourceSafeItem* pSSItem = (SourceSafeItem*)pRoot->Data;
  87. if (root.Childs[i].Type == SourceSafeItem::VSS_PROJECT)
  88. {
  89. pRoot->Image->Load ("folder");
  90. } else
  91. {
  92. if (!root.Childs[i].bCheckedOut)
  93. {
  94. pRoot->Image->Load ("meditor\\vss_normal");
  95. } else
  96. {
  97. pRoot->Image->Load ("meditor\\vss_checkedout");
  98. }
  99. }
  100. //
  101. pRoot->CanCopy = false;
  102. pNodes->Add (pRoot);
  103. AddRecursive(&pRoot->Childs, root.Childs[i]);
  104. }
  105. }
  106. */
  107. void _cdecl TVSSResourceBrowser::onOKPressed (GUIControl* sender)
  108. {
  109. /*
  110. GUITreeNode* pSelectedNode = TreeView1->GetSelectedNode();
  111. if (pSelectedNode)
  112. {
  113. SourceSafeItem* pSSItem = (SourceSafeItem*)pSelectedNode->Data;
  114. //pSSItem->Checkout("d:\\projects");
  115. bool bResult = pSSItem->GetLatestVersion(MissionsSrcLocalFolder.c_str());
  116. if (bResult)
  117. {
  118. string msr_name;
  119. msr_name = MissionsSrcLocalFolder;
  120. msr_name += "\\";
  121. msr_name += pSSItem->Name;
  122. PanelWindow->StartLoad(msr_name);
  123. }
  124. }
  125. Close (this);
  126. */
  127. }
  128. void _cdecl TVSSResourceBrowser::onCancelPressed (GUIControl* sender)
  129. {
  130. Close (this);
  131. }
  132. void TVSSResourceBrowser::KeyPressed(int Key, bool bSysKey)
  133. {
  134. if (!bSysKey) return;
  135. if (Key == 13) onOKPressed (NULL);
  136. if (Key == VK_ESCAPE) onCancelPressed (NULL);
  137. }