MCPcopy Create free account
hub / github.com/OpenDungeons/OpenDungeons / createStatsWindow

Method createStatsWindow

source/entities/Creature.cpp:1851–1887  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1849}
1850
1851void Creature::createStatsWindow()
1852{
1853 if (mStatsWindow != nullptr)
1854 return;
1855
1856 ClientNotification *clientNotification = new ClientNotification(
1857 ClientNotificationType::askCreatureInfos);
1858 std::string name = getName();
1859 clientNotification->mPacket << name << true;
1860 ODClient::getSingleton().queueClientNotification(clientNotification);
1861
1862 CEGUI::WindowManager* wmgr = CEGUI::WindowManager::getSingletonPtr();
1863 CEGUI::Window* rootWindow = CEGUI::System::getSingleton().getDefaultGUIContext().getRootWindow();
1864
1865 mStatsWindow = wmgr->createWindow("OD/FrameWindow", std::string("CreatureStatsWindows_") + getName());
1866 mStatsWindow->setPosition(CEGUI::UVector2(CEGUI::UDim(0.3, 0), CEGUI::UDim(0.3, 0)));
1867 mStatsWindow->setSize(CEGUI::USize(CEGUI::UDim(0, 380), CEGUI::UDim(0, 400)));
1868
1869 CEGUI::Window* textWindow = wmgr->createWindow("OD/StaticText", "TextDisplay");
1870 textWindow->setPosition(CEGUI::UVector2(CEGUI::UDim(0.05, 0), CEGUI::UDim(0.1, 0)));
1871 textWindow->setSize(CEGUI::USize(CEGUI::UDim(0.9, 0), CEGUI::UDim(0.85, 0)));
1872 textWindow->setProperty("FrameEnabled", "False");
1873 textWindow->setProperty("BackgroundEnabled", "False");
1874
1875 // We want to close the window when the cross is clicked
1876 mStatsWindow->subscribeEvent(CEGUI::FrameWindow::EventCloseClicked,
1877 CEGUI::Event::Subscriber(&Creature::CloseStatsWindow, this));
1878
1879 // Set the window title
1880 mStatsWindow->setText(getName() + " (" + getDefinition()->getClassName() + ")");
1881
1882 mStatsWindow->addChild(textWindow);
1883 rootWindow->addChild(mStatsWindow);
1884 mStatsWindow->show();
1885
1886 updateStatsWindow("Loading...");
1887}
1888
1889void Creature::destroyStatsWindow()
1890{

Callers 2

mousePressedMethod · 0.45
mousePressedMethod · 0.45

Calls 4

setTextMethod · 0.80
showMethod · 0.80
setPositionMethod · 0.45

Tested by

no test coverage detected