CmTestTextSprite.cpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 "BsEngineGUI.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)
  32. {
  33. }
  34. TestTextSprite::~TestTextSprite()
  35. {
  36. }
  37. void TestTextSprite::init(const HCamera& camera, const String& text, CM::RenderTexturePtr sceneView)
  38. {
  39. setSkin(EngineGUI::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. area->getLayout().addElement(GUIListBox::create(*this, dropDownElements, GUIOptions(GUIOption::fixedWidth(50), GUIOption::fixedHeight(13))));
  50. GUIButton* button = GUIButton::create(*this, HString(L"dbgBtn"));
  51. button->onClick.connect(boost::bind(&TestTextSprite::dbgBtn, this));
  52. area->getLayout().addElement(button);
  53. area->getLayout().addFlexibleSpace();
  54. labelString = HString(L"\\{0}, {1}");
  55. mLabel->setContent(GUIContent(labelString));
  56. }
  57. void TestTextSprite::update()
  58. {
  59. labelString.setParameter(0, toWString(Input::instance().getCursorPosition().x));
  60. //labelString.setParameter(1, toWString(Input::instance().getCursorPosition().y));
  61. }
  62. void TestTextSprite::dbgBtn()
  63. {
  64. static int dbg = 0;
  65. if(dbg == 0)
  66. {
  67. StringTable::instance().setString(L"dbgBtn", Language::Abkhazian, L"ALOALO");
  68. StringTable::instance().setActiveLanguage(Language::Abkhazian);
  69. }
  70. else if(dbg == 1)
  71. {
  72. StringTable::instance().removeString(L"dbgBtn");
  73. }
  74. dbg++;
  75. }
  76. }