LocStringForm.cpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. #include "locstringform.h"
  2. #include "locstringattr.h"
  3. #include "..\strutil.h"
  4. #include "..\pathutils.h"
  5. #include "..\..\forms\mainwindow.h"
  6. #include "..\..\forms\resourceselect.h"
  7. #include "..\..\..\common_h\mission.h"
  8. extern TMainWindow* MainWindow;
  9. extern IMission* miss;
  10. #define WINDOW_WIDTH 280
  11. #define WINDOW_HEIGHT 65
  12. extern IRender* pRS;
  13. string currentLocStr_value;
  14. extern ILocStrings* pLocStr;
  15. TLocStringEdit::TLocStringEdit (int posX, int posY) : GUIWindow (NULL, posX, posY, WINDOW_WIDTH, WINDOW_HEIGHT)
  16. {
  17. currentValue = -1;
  18. bPopupStyle = true;
  19. bAlwaysOnTop = true;
  20. bSystemButton = false;
  21. Caption = STRINGEDIT_WINDOWNAME;
  22. TextValue = NEW GUIEdit (this, 6, 6, 217-12, 19);
  23. TextValue->pFont->SetName("arialcyrsmall");
  24. TextValue->Flat = true;
  25. TextValue->Enabled = false;
  26. btnOK = NEW GUIButton (this, 30+9+15,30, 78, 24);
  27. btnOK->Glyph->Load ("meditor\\ok");
  28. btnOK->Caption = "Accept";
  29. btnOK->pFont->SetName("arialcyrsmall");
  30. btnOK->FlatButton = true;
  31. btnCancel = NEW GUIButton (this, 30+95+15,30, 78, 24);
  32. btnCancel->Glyph->Load ("meditor\\cancel");
  33. btnCancel->Caption = "Cancel";
  34. btnCancel->pFont->SetName("arialcyrsmall");
  35. btnCancel->FlatButton = true;
  36. //------------------
  37. btnTakeFromTranslatedString = NEW GUIButton (this, 212+5,6, 22, 22);
  38. btnTakeFromTranslatedString->Glyph->Load ("meditor\\local_text");
  39. btnTakeFromTranslatedString->OnMousePressed = (CONTROL_EVENT)&TLocStringEdit::OnSelectFromLocalText;
  40. btnTakeFromTranslatedString->FlatButton = true;
  41. btnTakeFromTranslatedString->Hint = "Take string from file";
  42. btnOK->OnMousePressed = (CONTROL_EVENT)&TLocStringEdit::OnButtonOK;
  43. btnCancel->OnMousePressed = (CONTROL_EVENT)&TLocStringEdit::OnButtonCancel;
  44. }
  45. TLocStringEdit::~TLocStringEdit ()
  46. {
  47. }
  48. void _cdecl TLocStringEdit::OnButtonOK (GUIControl* sender)
  49. {
  50. MasterAttrib->SetValue (currentValue);
  51. Close (this);
  52. }
  53. void _cdecl TLocStringEdit::OnButtonCancel (GUIControl* sender)
  54. {
  55. Close (this);
  56. }
  57. void TLocStringEdit::KeyPressed(int key, bool bSysKey)
  58. {
  59. if (!bSysKey) return;
  60. if (bLocked) return;
  61. if (key == 13) OnButtonOK (this);
  62. }
  63. void _cdecl TLocStringEdit::OnSelectFromLocalText (GUIControl* sender)
  64. {
  65. TLocTextEditor* locEditor = NULL;
  66. locEditor = NEW TLocTextEditor (0, 0);
  67. locEditor->OnClose = (CONTROL_EVENT)&TLocStringEdit::OnSelectFromLocalTextClose;
  68. bLocked = true;
  69. Application->ShowModal (locEditor);
  70. }
  71. void _cdecl TLocStringEdit::OnSelectFromLocalTextClose (GUIControl* sender)
  72. {
  73. TLocTextEditor* sndr = (TLocTextEditor*)sender;
  74. currentValue = sndr->listBox->SelectedLine;
  75. if (currentValue >= 0)
  76. {
  77. currentLocStr_value = sndr->listBox->Items.Get(currentValue).c_str();
  78. } else
  79. {
  80. currentLocStr_value = "";
  81. }
  82. currentValue = pLocStr->GetIdByIndex(currentValue);
  83. TextValue->Text = currentLocStr_value;
  84. bLocked = false;
  85. }