CmTestTextSprite.cpp 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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. #include "BsGUISceneTreeView.h"
  28. using namespace CamelotFramework;
  29. using namespace BansheeEngine;
  30. namespace BansheeEditor
  31. {
  32. TestTextSprite::TestTextSprite(const HSceneObject& parent, CM::Viewport* target)
  33. :GUIWidget(parent, target), mListBox(nullptr)
  34. {
  35. }
  36. TestTextSprite::~TestTextSprite()
  37. {
  38. }
  39. void TestTextSprite::init(const HCamera& camera, const String& text, CM::RenderTexturePtr sceneView)
  40. {
  41. setSkin(BansheeEditor::EditorGUI::instance().getSkin());
  42. setDepth(128);
  43. GUIArea* area = GUIArea::createStretchedXY(*this, 0, 0, 0, 0);
  44. mSceneTreeView = GUISceneTreeView::create(*this, GUIOptions(GUIOption::flexibleWidth(), GUIOption::flexibleHeight()));
  45. GUILayout& sceneTreeViewLayout = area->getLayout().addLayoutY();
  46. sceneTreeViewLayout.addFlexibleSpace();
  47. sceneTreeViewLayout.addElement(mSceneTreeView);
  48. sceneTreeViewLayout.addFlexibleSpace();
  49. area->getLayout().addElement(GUIRenderTexture::create(*this, sceneView, GUIOptions(GUIOption::fixedWidth(800), GUIOption::fixedHeight(600))));
  50. //mLabel = GUILabel::create(*this, HString(L""));
  51. //area->getLayout().addElement(mLabel);
  52. //Vector<HString>::type dropDownElements;
  53. //dropDownElements.push_back(HString(L"Ejlement #1"));
  54. //dropDownElements.push_back(HString(L"Element #2"));
  55. //dropDownElements.push_back(HString(L"Element #3"));
  56. //mListBox = GUIListBox::create(*this, dropDownElements, GUIOptions(GUIOption::fixedWidth(50), GUIOption::fixedHeight(13)));
  57. //area->getLayout().addElement(mListBox);
  58. GUIButton* button = GUIButton::create(*this, HString(L"dbgBtn"));
  59. button->onClick.connect(boost::bind(&TestTextSprite::dbgBtn, this));
  60. area->getLayout().addElement(button);
  61. button = GUIButton::create(*this, HString(L"Add GameObjects"));
  62. button->onClick.connect(boost::bind(&TestTextSprite::dbgAdd, this));
  63. area->getLayout().addElement(button);
  64. button = GUIButton::create(*this, HString(L"Rename GameObject"));
  65. button->onClick.connect(boost::bind(&TestTextSprite::dbgRename, this));
  66. area->getLayout().addElement(button);
  67. button = GUIButton::create(*this, HString(L"Remove child GameObjects"));
  68. button->onClick.connect(boost::bind(&TestTextSprite::dbgRemoveChildren, this));
  69. area->getLayout().addElement(button);
  70. button = GUIButton::create(*this, HString(L"Remove parent GameObjects"));
  71. button->onClick.connect(boost::bind(&TestTextSprite::dbgRemoveParents, this));
  72. area->getLayout().addElement(button);
  73. area->getLayout().addFlexibleSpace();
  74. labelString = HString(L"\\{0}, {1}");
  75. //mLabel->setContent(GUIContent(labelString));
  76. }
  77. void TestTextSprite::update()
  78. {
  79. labelString.setParameter(0, toWString(Input::instance().getCursorPosition().x));
  80. mSceneTreeView->update();
  81. //labelString.setParameter(1, toWString(Input::instance().getCursorPosition().y));
  82. }
  83. void TestTextSprite::dbgBtn()
  84. {
  85. static int dbg = 0;
  86. if(dbg == 0)
  87. {
  88. //Vector<HString>::type dropDownElements;
  89. //dropDownElements.push_back(HString(L"Element #4"));
  90. //dropDownElements.push_back(HString(L"Element #5"));
  91. //dropDownElements.push_back(HString(L"Element #6"));
  92. //mListBox->setElements(dropDownElements);
  93. //StringTable::instance().setString(L"dbgBtn", Language::Abkhazian, L"ALOALO");
  94. //StringTable::instance().setActiveLanguage(Language::Abkhazian);
  95. }
  96. else if(dbg == 1)
  97. {
  98. //StringTable::instance().removeString(L"dbgBtn");
  99. }
  100. dbg++;
  101. }
  102. void TestTextSprite::dbgAdd()
  103. {
  104. mDbgMainA = SceneObject::create("DEBUG_A");
  105. mDbgChildA = SceneObject::create("DEBUG_CHILD_0");
  106. mDbgChildA->setParent(mDbgMainA);
  107. mDbgChildB = SceneObject::create("DEBUG_CHILD_1");
  108. mDbgChildB->setParent(mDbgMainA);
  109. mDbgChildC = SceneObject::create("DEBUG_CHILD_2");
  110. mDbgChildC->setParent(mDbgMainA);
  111. mDbgMainB = SceneObject::create("DEBUG_B");
  112. }
  113. void TestTextSprite::dbgRename()
  114. {
  115. mDbgMainA->setName("Z_DEBUG_RENAMED_A");
  116. }
  117. void TestTextSprite::dbgRemoveChildren()
  118. {
  119. mDbgChildA->destroy();
  120. mDbgChildB->destroy();
  121. }
  122. void TestTextSprite::dbgRemoveParents()
  123. {
  124. mDbgMainA->destroy();
  125. mDbgMainB->destroy();
  126. }
  127. }