info window

master
Eduardo Bart 13 years ago
parent c5da620d59
commit 9dfb33f2ed

@ -1,5 +1,5 @@
glyph height: 10 glyph height: 10
glyph spacing: [1, 1] glyph spacing: [1, 4]
top margin: 3 top margin: 3
image: tibia-10px-antialised.png image: tibia-10px-antialised.png
image glyph size: [8, 16] image glyph size: [8, 16]

@ -48,8 +48,16 @@ panels:
flatPanel: flatPanel:
bordered image: bordered image:
left border: [275,0,1,96]
right border: [276,0,1,96]
top border: [2,210,91,1]
bottom border: [2,211,91,1]
top left corner: [275,0,1,1]
top right corner: [276,0,1,1]
bottom left corner: [2,210,1,1]
bottom right corner: [276,95,1,1]
center: [0, 0, 96, 96]
labels: labels:
default: default:
font: tibia-10px-antialised font: tibia-10px-antialised
@ -96,4 +104,8 @@ text edits:
bottom right corner: [319,107,1,1] bottom right corner: [319,107,1,1]
center: [309,97,10,10] center: [309,97,10,10]
line decorations:
default:
bordered image:
top border: [2,210,96,2]

@ -10,20 +10,20 @@ window#infoWindow:
anchors.left: parent.left anchors.left: parent.left
anchors.top: parent.top anchors.top: parent.top
margin.top: 32 margin.top: 32
margin.left: 24 margin.left: 18
label#infoLabel: label#infoLabel:
size: [218, 83] size: [208, 84]
align: center align: center
text: | text: |-
OTClient OTClient
Version 0.2.0 Version 0.2.0
Copyright (C) 2011 Created by edubart
Developed by edubart anchors.left: parent.left
anchors.top: parent.top
separator#bottomSeparator: lineDecoration#bottomSeparator:
orientation: horizontal size: [190,2]
width: 190
anchors.left: parent.left anchors.left: parent.left
anchors.top: parent.top anchors.top: parent.top
margin.top: 83 margin.top: 83
@ -32,20 +32,19 @@ window#infoWindow:
label#websiteLabel: label#websiteLabel:
text: Official Website text: Official Website
anchors.left: parent.left anchors.left: parent.left
anchors.top: parent.top anchors.bottom: parent.bottom
margin.top: 105 margin.bottom: 14
margin.left: 8 margin.left: 9
button#websiteButton: button#websiteButton:
text: github.com/otclient text: Github Page
anchors.left: parent.left anchors.right: parent.right
anchors.top: parent.top anchors.bottom: parent.bottom
margin.top: 99 margin.bottom: 9
margin.left: 131 margin.right: 9
separator#bottomSeparator: lineDecoration#bottomSeparator:
orientation: horizontal size: [218,2]
width: 218
anchors.left: parent.left anchors.left: parent.left
anchors.top: parent.top anchors.top: parent.top
margin.top: 181 margin.top: 181

@ -80,18 +80,16 @@ void BorderedImage::setTexCoords(const Rect& left,
void BorderedImage::draw(const Rect& screenCoords) void BorderedImage::draw(const Rect& screenCoords)
{ {
// check minumim size
if(screenCoords.size() <= m_cornersSize)
return;
Rect rectCoords; Rect rectCoords;
Size centerSize = screenCoords.size() - m_cornersSize; Size centerSize = screenCoords.size() - m_cornersSize;
// first the center // first the center
rectCoords = Rect(screenCoords.left() + m_leftBorderTexCoords.width(), if(centerSize.area() > 0) {
screenCoords.top() + m_topBorderTexCoords.height(), rectCoords = Rect(screenCoords.left() + m_leftBorderTexCoords.width(),
centerSize); screenCoords.top() + m_topBorderTexCoords.height(),
g_graphics.drawRepeatedTexturedRect(rectCoords, m_texture, m_centerTexCoords); centerSize);
g_graphics.drawRepeatedTexturedRect(rectCoords, m_texture, m_centerTexCoords);
}
// top left corner // top left corner
rectCoords = Rect(screenCoords.topLeft(), rectCoords = Rect(screenCoords.topLeft(),

@ -223,7 +223,7 @@ const std::vector<Point>& Font::calculateGlyphsPositions(const std::string& text
return glyphsPositions; return glyphsPositions;
} }
// resize glyphsPositions vector, if needed // resize glyphsPositions vector when needed
if(textLength > (int)glyphsPositions.size()) if(textLength > (int)glyphsPositions.size())
glyphsPositions.resize(textLength); glyphsPositions.resize(textLength);
@ -250,9 +250,6 @@ const std::vector<Point>& Font::calculateGlyphsPositions(const std::string& text
for(i = 0; i < textLength; ++i) { for(i = 0; i < textLength; ++i) {
glyph = (uchar)text[i]; glyph = (uchar)text[i];
// store current glyph topLeft
glyphsPositions[i] = virtualPos;
// new line or first glyph // new line or first glyph
if(glyph == (uchar)'\n' || i == 0) { if(glyph == (uchar)'\n' || i == 0) {
if(glyph == (uchar)'\n') { if(glyph == (uchar)'\n') {
@ -270,6 +267,9 @@ const std::vector<Point>& Font::calculateGlyphsPositions(const std::string& text
} }
} }
// store current glyph topLeft
glyphsPositions[i] = virtualPos;
// render only if the glyph is valid // render only if the glyph is valid
if(glyph >= 32 && glyph != (uchar)'\n') { if(glyph >= 32 && glyph != (uchar)'\n') {
virtualPos.x += m_glyphsSize[glyph].width() + m_glyphSpacing.width(); virtualPos.x += m_glyphsSize[glyph].width() + m_glyphSpacing.width();
@ -278,7 +278,7 @@ const std::vector<Point>& Font::calculateGlyphsPositions(const std::string& text
if(textBoxSize) { if(textBoxSize) {
textBoxSize->setWidth(maxLineWidth); textBoxSize->setWidth(maxLineWidth);
textBoxSize->setHeight(virtualPos.y + m_glyphHeight); textBoxSize->setHeight(virtualPos.y + m_glyphHeight + m_glyphSpacing.height());
} }
return glyphsPositions; return glyphsPositions;

@ -139,7 +139,7 @@ void Graphics::disableDrawing()
void Graphics::drawTexturedRect(const Rect& screenCoords, const TexturePtr& texture, const Rect& textureCoords, const Color& color) void Graphics::drawTexturedRect(const Rect& screenCoords, const TexturePtr& texture, const Rect& textureCoords, const Color& color)
{ {
if(screenCoords.isEmpty()) if(screenCoords.isEmpty() || textureCoords.isEmpty())
return; return;
// rect correction for opengl // rect correction for opengl
@ -170,7 +170,7 @@ void Graphics::drawTexturedRect(const Rect& screenCoords, const TexturePtr& text
void Graphics::drawRepeatedTexturedRect(const Rect& screenCoords, const TexturePtr& texture, const Rect& textureCoords, const Color& color) void Graphics::drawRepeatedTexturedRect(const Rect& screenCoords, const TexturePtr& texture, const Rect& textureCoords, const Color& color)
{ {
if(screenCoords.isEmpty()) if(screenCoords.isEmpty() || textureCoords.isEmpty())
return; return;
// render many repeated texture rects // render many repeated texture rects

@ -293,7 +293,7 @@ void TextArea::appendCharacter(char c)
void TextArea::removeCharacter(bool right) void TextArea::removeCharacter(bool right)
{ {
if(m_cursorPos >= 0) { if(m_cursorPos >= 0 && m_text.length() > 0) {
if(right && (uint)m_cursorPos < m_text.length()) if(right && (uint)m_cursorPos < m_text.length())
m_text.erase(m_text.begin() + m_cursorPos); m_text.erase(m_text.begin() + m_cursorPos);
else if((uint)m_cursorPos == m_text.length()) { else if((uint)m_cursorPos == m_text.length()) {

@ -37,5 +37,7 @@
#include "uiwindow.h" #include "uiwindow.h"
#include "uitextedit.h" #include "uitextedit.h"
#include "uiloader.h" #include "uiloader.h"
#include "uilinedecoration.h"
#include "uicheckbox.h"
#endif // UI_H #endif // UI_H

@ -60,7 +60,8 @@ namespace UI {
Label, Label,
TextEdit, TextEdit,
Button, Button,
CheckBox CheckBox,
LineDecoration
}; };
} }

@ -49,19 +49,11 @@ void UIElement::destroy()
assert(asUIElement().use_count() == 4); assert(asUIElement().use_count() == 4);
} }
bool UIElement::setSkin(const std::string& skinName)
{
setSkin(g_uiSkins.getElementSkin(m_type, skinName));
return m_skin != NULL;
}
void UIElement::setSkin(UIElementSkin* skin) void UIElement::setSkin(UIElementSkin* skin)
{ {
m_skin = skin; m_skin = skin;
if(skin && !getRect().isValid()) { if(skin)
setSize(skin->getDefaultSize());
skin->apply(this); skin->apply(this);
}
} }
void UIElement::render() void UIElement::render()

@ -60,7 +60,6 @@ public:
void moveTo(Point pos); void moveTo(Point pos);
bool setSkin(const std::string& skinName);
void setSkin(UIElementSkin *skin); void setSkin(UIElementSkin *skin);
UIElementSkin *getSkin() { return m_skin; } UIElementSkin *getSkin() { return m_skin; }

@ -28,12 +28,6 @@
#include "graphics/textures.h" #include "graphics/textures.h"
#include "uiskins.h" #include "uiskins.h"
void UIElementSkin::draw(UIElement *element)
{
if(m_defaultImage)
m_defaultImage->draw(element->getRect());
}
void UIElementSkin::load(const YAML::Node& node) void UIElementSkin::load(const YAML::Node& node)
{ {
if(node.FindValue("default size")) if(node.FindValue("default size"))
@ -41,6 +35,17 @@ void UIElementSkin::load(const YAML::Node& node)
m_defaultImage = loadImage(node); m_defaultImage = loadImage(node);
} }
void UIElementSkin::apply(UIElement* element)
{
if(!element->getRect().isValid() && m_defaultSize.isValid())
element->setSize(m_defaultSize);
}
void UIElementSkin::draw(UIElement *element)
{
if(m_defaultImage)
m_defaultImage->draw(element->getRect());
}
ImagePtr UIElementSkin::loadImage(const YAML::Node& node) ImagePtr UIElementSkin::loadImage(const YAML::Node& node)
{ {
ImagePtr image; ImagePtr image;

@ -40,7 +40,7 @@ public:
virtual ~UIElementSkin() { } virtual ~UIElementSkin() { }
virtual void load(const YAML::Node& node); virtual void load(const YAML::Node& node);
virtual void apply(UIElement *element) { } virtual void apply(UIElement *element);
virtual void draw(UIElement *element); virtual void draw(UIElement *element);
const std::string& getName() const { return m_name; } const std::string& getName() const { return m_name; }

@ -23,13 +23,3 @@
#include "uilabel.h" #include "uilabel.h"
#include "graphics/fonts.h"
#include "uilabelskin.h"
void UILabel::setText(const std::string& text)
{
UILabelSkin *skin = static_cast<UILabelSkin*>(getSkin());
setSize(skin->getFont()->calculateTextRectSize(text));
m_text = text;
}

@ -27,18 +27,26 @@
#include "prerequisites.h" #include "prerequisites.h"
#include "uielement.h" #include "uielement.h"
#include "graphics/font.h"
class UILabel : public UIElement class UILabel : public UIElement
{ {
public: public:
UILabel() : UILabel() :
UIElement(UI::Label) { } UIElement(UI::Label),
m_align(ALIGN_TOP_LEFT),
m_color(Color::white) { }
void setText(const std::string& text); void setText(const std::string& text) { m_text = text; }
const std::string& getText() const { return m_text; } const std::string& getText() const { return m_text; }
void setAlign(int align) { m_align = align; }
int getAlign() const { return m_align; }
private: private:
std::string m_text; std::string m_text;
int m_align;
Color m_color;
}; };
typedef boost::shared_ptr<UILabel> UILabelPtr; typedef boost::shared_ptr<UILabel> UILabelPtr;

@ -41,11 +41,16 @@ void UILabelSkin::load(const YAML::Node& node)
m_textColor = Color::white; m_textColor = Color::white;
} }
void UILabelSkin::apply(UIElement* element)
{
UIElementSkin::apply(element);
UILabel *label = static_cast<UILabel*>(element);
label->setSize(m_font->calculateTextRectSize(label->getText()));
}
void UILabelSkin::draw(UIElement *element) void UILabelSkin::draw(UIElement *element)
{ {
UIElementSkin::draw(element); UIElementSkin::draw(element);
UILabel *label = static_cast<UILabel*>(element); UILabel *label = static_cast<UILabel*>(element);
m_font->renderText(label->getText(), label->getRect(), label->getAlign(), m_textColor);
m_font->renderText(label->getText(), label->getRect(), ALIGN_TOP_LEFT, m_textColor);
} }

@ -26,24 +26,25 @@
#define UILABELSKIN_H #define UILABELSKIN_H
#include "prerequisites.h" #include "prerequisites.h"
#include "uiconstants.h"
#include "uielementskin.h" #include "uielementskin.h"
#include "graphics/font.h"
class Font;
class UILabelSkin : public UIElementSkin class UILabelSkin : public UIElementSkin
{ {
public: public:
UILabelSkin(const std::string& name) : UILabelSkin(const std::string& name) :
UIElementSkin(name, UI::Label) { } UIElementSkin(name, UI::Label),
m_align(ALIGN_TOP_LEFT) { }
void load(const YAML::Node& node); void load(const YAML::Node& node);
void apply(UIElement *element);
void draw(UIElement *element); void draw(UIElement *element);
Font *getFont() const { return m_font; } Font *getFont() const { return m_font; }
private: private:
Font *m_font; Font *m_font;
int m_align;
Color m_textColor; Color m_textColor;
}; };

@ -1,2 +1,26 @@
/* The MIT License
*
* Copyright (c) 2010 OTClient, https://github.com/edubart/otclient
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "uilinedecoration.h" #include "uilinedecoration.h"

@ -1,8 +1,40 @@
/* The MIT License
*
* Copyright (c) 2010 OTClient, https://github.com/edubart/otclient
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef UILINEDECORATION_H #ifndef UILINEDECORATION_H
#define UILINEDECORATION_H #define UILINEDECORATION_H
class UILineDecoration #include "prerequisites.h"
#include "uielement.h"
class UILineDecoration : public UIElement
{ {
public:
UILineDecoration() :
UIElement(UI::LineDecoration) { }
}; };
typedef boost::shared_ptr<UILineDecoration> UILineDecorationPtr;
#endif // UILINEDECORATION_H #endif // UILINEDECORATION_H

@ -1,2 +1,30 @@
/* The MIT License
*
* Copyright (c) 2010 OTClient, https://github.com/edubart/otclient
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "uilinedecorationskin.h" #include "uilinedecorationskin.h"
void UILineDecorationSkin::draw(UIElement* element)
{
UIElementSkin::draw(element);
}

@ -1,8 +1,40 @@
/* The MIT License
*
* Copyright (c) 2010 OTClient, https://github.com/edubart/otclient
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef UILINEDECORATIONSKIN_H #ifndef UILINEDECORATIONSKIN_H
#define UILINEDECORATIONSKIN_H #define UILINEDECORATIONSKIN_H
class UILineDecorationSkin #include "prerequisites.h"
#include "uielementskin.h"
class UILineDecorationSkin : public UIElementSkin
{ {
public:
UILineDecorationSkin(const std::string& name) :
UIElementSkin(name, UI::LineDecoration) { }
void draw(UIElement *element);
}; };
#endif // UILINEDECORATIONSKIN_H #endif // UILINEDECORATIONSKIN_H

@ -48,13 +48,14 @@ UIElementPtr UILoader::createElementFromId(const std::string& id)
element = UIElementPtr(new UIWindow); element = UIElementPtr(new UIWindow);
} else if(elementType == "textEdit") { } else if(elementType == "textEdit") {
element = UIElementPtr(new UITextEdit); element = UIElementPtr(new UITextEdit);
} else if(elementType == "lineDecoration") {
element = UIElementPtr(new UILineDecoration);
} else if(elementType == "checkBox") {
element = UIElementPtr(new UICheckBox);
} }
if(element) { if(element) {
element->setId(elementId); element->setId(elementId);
// apply default skin
element->setSkin(g_uiSkins.getElementSkin(element->getElementType()));
} }
return element; return element;
@ -146,9 +147,33 @@ void UILoader::loadElements(const UIElementPtr& parent, const YAML::Node& node)
void UILoader::loadElement(const UIElementPtr& element, const YAML::Node& node) void UILoader::loadElement(const UIElementPtr& element, const YAML::Node& node)
{ {
// load specific element type
if(element->getElementType() == UI::Button) {
UIButtonPtr button = boost::static_pointer_cast<UIButton>(element);
button->setText(node["text"].Read<std::string>());
}
else if(element->getElementType() == UI::Window) {
UIWindowPtr window = boost::static_pointer_cast<UIWindow>(element);
window->setTitle(node["title"].Read<std::string>());
}
else if(element->getElementType() == UI::Label) {
UILabelPtr label = boost::static_pointer_cast<UILabel>(element);
label->setText(node["text"].Read<std::string>());
if(node.FindValue("align")) {
std::string alignDesc;
node["align"] >> alignDesc;
if(alignDesc == "center")
label->setAlign(ALIGN_CENTER);
}
}
// set element skin
if(node.FindValue("skin")) if(node.FindValue("skin"))
element->setSkin(g_uiSkins.getElementSkin(element->getElementType(), node["skin"])); element->setSkin(g_uiSkins.getElementSkin(element->getElementType(), node["skin"]));
else // apply default skin
element->setSkin(g_uiSkins.getElementSkin(element->getElementType(), "default"));
// load elements common proprieties
if(node.FindValue("size")) { if(node.FindValue("size")) {
Size size; Size size;
node["size"] >> size; node["size"] >> size;
@ -193,20 +218,6 @@ void UILoader::loadElement(const UIElementPtr& element, const YAML::Node& node)
if(node.FindValue("anchors.verticalCenter")) if(node.FindValue("anchors.verticalCenter"))
loadElementAnchor(element, ANCHOR_VERTICAL_CENTER, node["anchors.verticalCenter"]); loadElementAnchor(element, ANCHOR_VERTICAL_CENTER, node["anchors.verticalCenter"]);
// load specific element type
if(element->getElementType() == UI::Button) {
UIButtonPtr button = boost::static_pointer_cast<UIButton>(element);
button->setText(node["text"].Read<std::string>());
}
else if(element->getElementType() == UI::Window) {
UIWindowPtr window = boost::static_pointer_cast<UIWindow>(element);
window->setTitle(node["title"].Read<std::string>());
}
else if(element->getElementType() == UI::Label) {
UILabelPtr label = boost::static_pointer_cast<UILabel>(element);
label->setText(node["text"].Read<std::string>());
}
} }
void UILoader::loadElementAnchor(const UIElementPtr& element, EAnchorType type, const YAML::Node& node) void UILoader::loadElementAnchor(const UIElementPtr& element, EAnchorType type, const YAML::Node& node)

@ -30,6 +30,7 @@
#include "uiwindowskin.h" #include "uiwindowskin.h"
#include "uitexteditskin.h" #include "uitexteditskin.h"
#include "uilabelskin.h" #include "uilabelskin.h"
#include "uilinedecorationskin.h"
UISkins g_uiSkins; UISkins g_uiSkins;
@ -111,6 +112,19 @@ void UISkins::load(const std::string& skinsFile)
m_elementSkins.push_back(skin); m_elementSkins.push_back(skin);
} }
} }
{
const YAML::Node& node = doc["line decorations"];
for(auto it = node.begin(); it != node.end(); ++it) {
std::string name;
it.first() >> name;
UIElementSkin *skin = new UILineDecorationSkin(name);
skin->load(it.second());
m_elementSkins.push_back(skin);
}
}
} catch (YAML::Exception& e) { } catch (YAML::Exception& e) {
logFatal("Malformed skin file \"%s\":\n %s", skinsFile.c_str(), e.what()); logFatal("Malformed skin file \"%s\":\n %s", skinsFile.c_str(), e.what());
} }

@ -48,6 +48,7 @@ void UITextEditSkin::load(const YAML::Node& node)
void UITextEditSkin::apply(UIElement* element) void UITextEditSkin::apply(UIElement* element)
{ {
UIElementSkin::apply(element);
UITextEdit *textEdit = static_cast<UITextEdit*>(element); UITextEdit *textEdit = static_cast<UITextEdit*>(element);
textEdit->getTextArea().setFont(m_font); textEdit->getTextArea().setFont(m_font);
} }

@ -46,6 +46,9 @@ void MenuState::onEnter()
button = boost::static_pointer_cast<UIButton>(mainMenuPanel->getChildById("enterGameButton")); button = boost::static_pointer_cast<UIButton>(mainMenuPanel->getChildById("enterGameButton"));
button->setOnClick(boost::bind(&MenuState::enterGameButton_clicked, this)); button->setOnClick(boost::bind(&MenuState::enterGameButton_clicked, this));
button = boost::static_pointer_cast<UIButton>(mainMenuPanel->getChildById("infoButton"));
button->setOnClick(boost::bind(&MenuState::infoButton_clicked, this));
} }
void MenuState::onLeave() void MenuState::onLeave()
@ -86,13 +89,25 @@ void MenuState::render()
void MenuState::enterGameButton_clicked() void MenuState::enterGameButton_clicked()
{ {
UIWindowPtr window = boost::static_pointer_cast<UIWindow>(UILoader::loadFile("ui/enterGameWindow.yml")); UIWindowPtr window = boost::static_pointer_cast<UIWindow>(UILoader::loadFile("ui/enterGameWindow.yml"));
UIContainerPtr windowParent = window->getParent(); window->getParent()->lockElement(window);
windowParent->lockElement(window);
UIButtonPtr button = boost::static_pointer_cast<UIButton>(window->getChildById("cancelButton")); UIButtonPtr button = boost::static_pointer_cast<UIButton>(window->getChildById("cancelButton"));
button->setOnClick([] { button->setOnClick([] {
UIWindowPtr window = boost::static_pointer_cast<UIWindow>(UIContainer::getRootContainer()->getChildById("enterGameWindow")); UIWindowPtr window = boost::static_pointer_cast<UIWindow>(UIContainer::getRootContainer()->getChildById("enterGameWindow"));
UIContainer::getRootContainer()->unlockElement(); window->getParent()->unlockElement();
window->destroy();
});
}
void MenuState::infoButton_clicked()
{
UIWindowPtr window = boost::static_pointer_cast<UIWindow>(UILoader::loadFile("ui/infoWindow.yml"));
window->getParent()->lockElement(window);
UIButtonPtr button = boost::static_pointer_cast<UIButton>(window->getChildById("okButton"));
button->setOnClick([] {
UIWindowPtr window = boost::static_pointer_cast<UIWindow>(UIContainer::getRootContainer()->getChildById("infoWindow"));
window->getParent()->unlockElement();
window->destroy(); window->destroy();
}); });
} }

@ -47,6 +47,7 @@ public:
private: private:
void enterGameButton_clicked(); void enterGameButton_clicked();
void infoButton_clicked();
UIPanelPtr m_menuPanel; UIPanelPtr m_menuPanel;
TexturePtr m_background; TexturePtr m_background;

Loading…
Cancel
Save