CmTestTextSprite.cpp 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #include "CmTestTextSprite.h"
  2. #include "CmSceneObject.h"
  3. #include "BsRenderable.h"
  4. #include "CmMesh.h"
  5. #include "CmVector2.h"
  6. #include "BsTextSprite.h"
  7. #include "CmFont.h"
  8. #include "CmMaterial.h"
  9. #include "BsGUILabel.h"
  10. #include "BsGUIListBox.h"
  11. #include "BsGUISkin.h"
  12. #include "BsOverlayManager.h"
  13. #include "BsSpriteTexture.h"
  14. #include "BsEditorGUI.h"
  15. #include "BsGUITexture.h"
  16. #include "BsGUIRenderTexture.h"
  17. #include "BsGUIArea.h"
  18. #include "BsGUILayout.h"
  19. #include "BsGUISpace.h"
  20. #include "BsGUIViewport.h"
  21. #include "BsGUIButton.h"
  22. #include "BsCamera.h"
  23. #include "CmInput.h"
  24. #include "CmPlatform.h"
  25. #include "BsGUIContent.h"
  26. #include "CmStringTable.h"
  27. using namespace BansheeEngine;
  28. namespace CamelotFramework
  29. {
  30. TestTextSprite::TestTextSprite(const HSceneObject& parent, CM::Viewport* target)
  31. :GUIWidget(parent, target), mListBox(nullptr)
  32. {
  33. }
  34. TestTextSprite::~TestTextSprite()
  35. {
  36. }
  37. void TestTextSprite::init(const HCamera& camera, const String& text, CM::RenderTexturePtr sceneView)
  38. {
  39. setSkin(BansheeEditor::EditorGUI::instance().getSkin());
  40. setDepth(128);
  41. GUIArea* area = GUIArea::createStretchedXY(*this, 0, 0, 0, 0);
  42. area->getLayout().addElement(GUIRenderTexture::create(*this, sceneView, GUIOptions(GUIOption::fixedWidth(800), GUIOption::fixedHeight(600))));
  43. mLabel = GUILabel::create(*this, HString(L""));
  44. area->getLayout().addElement(mLabel);
  45. Vector<HString>::type dropDownElements;
  46. dropDownElements.push_back(HString(L"Ejlement #1"));
  47. dropDownElements.push_back(HString(L"Element #2"));
  48. dropDownElements.push_back(HString(L"Element #3"));
  49. mListBox = GUIListBox::create(*this, dropDownElements, GUIOptions(GUIOption::fixedWidth(50), GUIOption::fixedHeight(13)));
  50. area->getLayout().addElement(mListBox);
  51. GUIButton* button = GUIButton::create(*this, HString(L"dbgBtn"));
  52. button->onClick.connect(boost::bind(&TestTextSprite::dbgBtn, this));
  53. area->getLayout().addElement(button);
  54. area->getLayout().addFlexibleSpace();
  55. labelString = HString(L"\\{0}, {1}");
  56. mLabel->setContent(GUIContent(labelString));
  57. }
  58. void TestTextSprite::update()
  59. {
  60. labelString.setParameter(0, toWString(Input::instance().getCursorPosition().x));
  61. //labelString.setParameter(1, toWString(Input::instance().getCursorPosition().y));
  62. }
  63. void TestTextSprite::dbgBtn()
  64. {
  65. static int dbg = 0;
  66. if(dbg == 0)
  67. {
  68. Vector<HString>::type dropDownElements;
  69. dropDownElements.push_back(HString(L"Element #4"));
  70. dropDownElements.push_back(HString(L"Element #5"));
  71. dropDownElements.push_back(HString(L"Element #6"));
  72. mListBox->setElements(dropDownElements);
  73. //StringTable::instance().setString(L"dbgBtn", Language::Abkhazian, L"ALOALO");
  74. //StringTable::instance().setActiveLanguage(Language::Abkhazian);
  75. }
  76. else if(dbg == 1)
  77. {
  78. //StringTable::instance().removeString(L"dbgBtn");
  79. }
  80. dbg++;
  81. }
  82. }