1 /*! 2 @file 3 @author Albert Semenov 4 @date 08/2008 5 */ 6 #include "Precompiled.h" 7 #include "DemoKeeper.h" 8 #include "Base/Main.h" 9 10 #ifdef MYGUI_STATIC 11 #include "Plugin.h" 12 plugin::Plugin* plugin_item = nullptr; 13 #endif 14 15 #if MYGUI_DEBUG_MODE 16 #if MYGUI_PLATFORM == MYGUI_PLATFORM_WIN32 17 #define plugin_name "Plugin_StrangeButton_d.dll" 18 #else 19 #define plugin_name "libPlugin_StrangeButton_d.so" 20 #endif 21 #else 22 #if MYGUI_PLATFORM == MYGUI_PLATFORM_WIN32 23 #define plugin_name "Plugin_StrangeButton.dll" 24 #else 25 #define plugin_name "libPlugin_StrangeButton.so" 26 #endif 27 #endif 28 29 namespace demo 30 { 31 DemoKeeper()32 DemoKeeper::DemoKeeper() : 33 m_button(nullptr) 34 { 35 } 36 setupResources()37 void DemoKeeper::setupResources() 38 { 39 base::BaseManager::setupResources(); 40 addResourceLocation(getRootMedia() + "/Common/Demos"); 41 } 42 createScene()43 void DemoKeeper::createScene() 44 { 45 base::BaseDemoManager::createScene(); 46 MyGUI::LayoutManager::getInstance().loadLayout("Wallpaper.layout"); 47 const MyGUI::VectorWidgetPtr& root = MyGUI::LayoutManager::getInstance().loadLayout("HelpPanel.layout"); 48 root.at(0)->findWidget("Text")->castType<MyGUI::TextBox>()->setCaption("Example of using plugins in MyGUI. Actually nothing interesting to look at."); 49 50 const MyGUI::IntSize& view = MyGUI::RenderManager::getInstance().getViewSize(); 51 const MyGUI::IntSize size(300, 26); 52 53 #ifdef MYGUI_STATIC 54 plugin_item = new plugin::Plugin(); 55 MyGUI::PluginManager::getInstance().installPlugin(plugin_item); 56 #else 57 MyGUI::PluginManager::getInstance().loadPlugin(plugin_name); 58 #endif 59 60 MyGUI::Widget* widget = MyGUI::Gui::getInstance().createWidgetT("StrangeButton", "Button", MyGUI::IntCoord((view.width - size.width) / 2, (view.height - size.height) / 2, size.width, size.height), MyGUI::Align::Default, "Main"); 61 m_button = widget->castType<MyGUI::TextBox>(); 62 m_button->setCaption("Plugin StrangeButton demo"); 63 } 64 destroyScene()65 void DemoKeeper::destroyScene() 66 { 67 MyGUI::Gui::getInstance().destroyChildWidget(m_button); 68 69 #ifdef MYGUI_STATIC 70 MyGUI::PluginManager::getInstance().uninstallPlugin(plugin_item); 71 delete plugin_item; 72 plugin_item = nullptr; 73 #else 74 # ifdef _DEBUG 75 MyGUI::PluginManager::getInstance().unloadPlugin("Plugin_StrangeButton_d.dll"); 76 # else 77 MyGUI::PluginManager::getInstance().unloadPlugin("Plugin_StrangeButton.dll"); 78 # endif 79 #endif 80 } 81 82 } // namespace demo 83 84 MYGUI_APP(demo::DemoKeeper) 85