systemselect.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #ifndef _XBOX
  2. #include "systemselect.h"
  3. #include "..\CustomControls\StrUtil.h"
  4. #include "..\..\..\Common_h\FileService.h"
  5. #define SYSTEMS_PLACE "resource\\particles"
  6. extern bool AlphabetSortFuncCompare (const string &a1, const string &a2);
  7. TSystemSelector::TSystemSelector () : GUIWindow (NULL, 0, 0, 250, 400)
  8. {
  9. OkPressed = false;
  10. SystemName = "";
  11. pFS = (IFileService*)api->GetService("FileService");
  12. pFont->SetName("arialcyrsmall");
  13. Caption = "Select system";
  14. SetScreenCenter();
  15. pSystemsList = NEW GUIListBox(this, 10, 10, 230, 330);
  16. pSystemsList->MakeFlat(true);
  17. //pSystemsList->OnChange = (CONTROL_EVENT)OnSelectProject;
  18. pOKButton = NEW GUIButton (this, 25+10, 345, 80, 22);
  19. pOKButton->FlatButton = true;
  20. pOKButton->Caption = "Add";
  21. pOKButton->OnMouseClick = (CONTROL_EVENT)&TSystemSelector::OnAddSystem;
  22. pCancelButton = NEW GUIButton (this, 35+100, 345, 80, 22);
  23. pCancelButton->FlatButton = true;
  24. pCancelButton->Caption = "Cancel";
  25. pCancelButton->OnMouseClick = (CONTROL_EVENT)&TSystemSelector::OnCancelSelect;
  26. BuildSystemsList ();
  27. }
  28. TSystemSelector::~TSystemSelector ()
  29. {
  30. }
  31. void TSystemSelector::Draw ()
  32. {
  33. GUIWindow::Draw();
  34. }
  35. void TSystemSelector::BuildSystemsList ()
  36. {
  37. pSystemsList->Items.Clear();
  38. IFinder* finder = pFS->CreateFinder(SYSTEMS_PLACE, "*.xps", find_all_files_no_mirrors | find_no_files_from_packs, _FL_);
  39. for (dword i = 0; i < finder->Count(); i++)
  40. {
  41. string filename = string(finder->FilePath(i)).GetRelativePath (SYSTEMS_PLACE);
  42. string name;
  43. name.GetFileName(filename);
  44. if (finder->IsMirror(i))
  45. name = string ("#c0000FF") + name;
  46. else
  47. name = string ("#c000000") + name;
  48. pSystemsList->Items.Add(name);
  49. }
  50. finder->Release();
  51. }
  52. void _cdecl TSystemSelector::OnAddSystem ()
  53. {
  54. OkPressed = true;
  55. if (pSystemsList->SelectedLine < 0)
  56. {
  57. Application->MessageBox("You must select system", "Error", GUIMB_OK);
  58. return;
  59. }
  60. SystemName = pSystemsList->Items[pSystemsList->SelectedLine].GetBuffer()+8;
  61. Close (this);
  62. }
  63. void _cdecl TSystemSelector::OnCancelSelect ()
  64. {
  65. OkPressed = false;
  66. Close (this);
  67. }
  68. #endif