master
Eduardo Bart 13 years ago
parent 9d1ddf34bf
commit 5de660a20e

@ -29,6 +29,7 @@
UIElement::UIElement(UI::EElementType type) :
AnchorLayout(),
m_type(type),
m_skin(NULL),
m_visible(true),
m_enabled(true)
{

@ -76,15 +76,15 @@ ImagePtr UIElementSkin::loadImage(const YAML::Node& node)
}
image = ImagePtr(new BorderedImage(texture,
left,
right,
top,
bottom,
topLeft,
topRight,
bottomLeft,
bottomRight,
center));
left,
right,
top,
bottom,
topLeft,
topRight,
bottomLeft,
bottomRight,
center));
}
return image;
}

@ -38,6 +38,7 @@ public:
UIElementSkin(const std::string& name, UI::EElementType elementType) :
m_name(name),
m_elementType(elementType) { }
virtual ~UIElementSkin() { }
virtual void load(const YAML::Node& node);
virtual void draw(UIElement *element);

@ -32,10 +32,18 @@
UISkins g_uiSkins;
UISkins::~UISkins()
void UISkins::init()
{
// load default skin
g_uiSkins.load("skins/tibiaskin.yml");
}
void UISkins::terminate()
{
for(auto it = m_elementSkins.begin(); it != m_elementSkins.end(); ++it)
delete (*it);
m_elementSkins.clear();
}
bool UISkins::load(const std::string& file)

@ -35,7 +35,9 @@ class UISkins
{
public:
UISkins() { }
~UISkins();
void init();
void terminate();
bool load(const std::string& file);

@ -109,8 +109,7 @@ int main(int argc, const char *argv[])
// init engine
g_engine.init();
// load UI skin
g_uiSkins.load("skins/tibiaskin.yml");
g_uiSkins.init();
// state scope
{
@ -129,6 +128,8 @@ int main(int argc, const char *argv[])
// terminate stuff
g_engine.terminate();
g_uiSkins.terminate();
}
// save configurations before exiting

@ -127,6 +127,7 @@ void MenuState::createMainMenu()
// login window
UIWindowPtr window(new UIWindow("Enter Game"));
UIElementWeakPtr weakWindow(window);
window->setSize(Size(236, 178));
window->anchorHorizontalCenter(g_ui->horizontalCenter());
window->anchorVerticalCenter(g_ui->verticalCenter());
@ -162,7 +163,11 @@ void MenuState::createMainMenu()
button->anchorRight(window->right());
button->anchorBottom(window->bottom());
button->setMargin(0, 0, 10, 66);
button->onClick([window]{ window->setVisible(false); });
button->onClick([weakWindow]{
UIElementPtr window = weakWindow.lock();
if(window)
window->setVisible(false);
});
window->addChild(button);
button = UIButtonPtr(new UIButton("Cancel"));
@ -170,7 +175,11 @@ void MenuState::createMainMenu()
button->anchorRight(window->right());
button->anchorBottom(window->bottom());
button->setMargin(0, 0, 10, 13);
button->onClick([window]{ window->setVisible(false); });
button->onClick([weakWindow]{
UIElementPtr window = weakWindow.lock();
if(window)
window->setVisible(false);
});
window->addChild(button);
UITextEditPtr textEdit(new UITextEdit);
@ -185,5 +194,9 @@ void MenuState::createMainMenu()
textEdit->setMargin(61, 0, 0, 18);
window->addChild(textEdit);
enterGameButton->onClick([window] { window->setVisible(true); });
enterGameButton->onClick([weakWindow]{
UIElementPtr window = weakWindow.lock();
if(window)
window->setVisible(true);
});
}

Loading…
Cancel
Save