SelectFromMission.cpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #include "SelectFromMission.h"
  2. #include "..\..\missioneditor.h"
  3. #define WINDOW_WIDTH 320
  4. #define WINDOW_HEIGHT 270
  5. extern MissionEditor* sMission;
  6. extern string my_val;
  7. bool TSSFMission::FuncCompare (const string& s1, const string& s2)
  8. {
  9. if (s1 < s2) return true;
  10. return false;
  11. }
  12. TSSFMission::TSSFMission (int posX, int posY) : GUIWindow (NULL, posX, posY, WINDOW_WIDTH, WINDOW_HEIGHT)
  13. {
  14. bPopupStyle = true;
  15. bAlwaysOnTop = true;
  16. Caption = "Select object";
  17. ListBox1 = NEW GUIListBox (this, 5, 5, 300, 230);
  18. ListBox1->FontColor = 0xFF000000;
  19. ListBox1->pFont->SetName ("arialcyrsmall");
  20. ListBox1->Items.Clear ();
  21. ListBox1->MakeFlat (true);
  22. //btnCANCEL;
  23. btnOK = NEW GUIButton (this, 5, 240, 100, 24);
  24. btnOK->Glyph->Load ("ok");
  25. btnOK->Caption = "Select";
  26. btnOK->FontColor = 0xFF000000;
  27. btnOK->pFont->SetName ("arialcyrsmall");
  28. btnOK->OnMousePressed = (CONTROL_EVENT)&TSSFMission::OKPressed;
  29. btnOK->FlatButton = true;
  30. btnCANCEL = NEW GUIButton (this, 116, 240, 100, 24);
  31. btnCANCEL->Glyph->Load ("cancel");
  32. btnCANCEL->Caption = "cancel";
  33. btnCANCEL->FontColor = 0xFF000000;
  34. btnCANCEL->pFont->SetName ("arialcyrsmall");
  35. btnCANCEL->OnMousePressed = (CONTROL_EVENT)&TSSFMission::CANCELPressed;
  36. btnCANCEL->FlatButton = true;
  37. // Заполняем объектами миссии...
  38. int count = sMission->GetCreatedMissionObjectsCount();
  39. for (int n =0; n < count; n++)
  40. {
  41. MOSafePointer pMo = sMission->GetCreatedMissionObjectByIndex(n);
  42. ListBox1->Items.Add (pMo.Ptr()->GetObjectID ().c_str());
  43. }
  44. ListBox1->Items.Sort (FuncCompare);
  45. }
  46. TSSFMission::~TSSFMission ()
  47. {
  48. delete btnOK;
  49. delete btnCANCEL;
  50. }
  51. void _cdecl TSSFMission::OKPressed (GUIControl* sender)
  52. {
  53. int s_line = ListBox1->SelectedLine;;
  54. if (s_line >= 0)
  55. {
  56. my_val = ListBox1->Items[s_line];
  57. } else
  58. {
  59. my_val = "";
  60. }
  61. Close (this);
  62. }
  63. void _cdecl TSSFMission::CANCELPressed (GUIControl* sender)
  64. {
  65. Close (this);
  66. }