remove lambdas
This commit is contained in:
parent
451719479b
commit
08b6563fd5
|
@ -79,6 +79,7 @@ windows:
|
|||
text edits:
|
||||
default:
|
||||
default size: [86, 16]
|
||||
font: tibia-10px-antialised
|
||||
text margin: 2
|
||||
bordered image:
|
||||
left border: [308,97,1,1]
|
||||
|
|
|
@ -29,8 +29,6 @@
|
|||
|
||||
#include <queue>
|
||||
|
||||
typedef std::function<void (void)> Callback;
|
||||
|
||||
class Task {
|
||||
public:
|
||||
inline Task(const Callback& _callback) : ticks(0), callback(_callback) { }
|
||||
|
|
|
@ -27,8 +27,6 @@
|
|||
#include "textures.h"
|
||||
#include "graphics.h"
|
||||
|
||||
|
||||
|
||||
void Font::calculateGlyphsWidthsAutomatically(const Size& glyphSize)
|
||||
{
|
||||
int numHorizontalGlyphs = m_texture->getSize().width() / glyphSize.width();
|
||||
|
|
|
@ -64,8 +64,11 @@ typedef int8_t int8;
|
|||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#define foreach BOOST_FOREACH
|
||||
|
||||
typedef std::function<void()> Callback;
|
||||
|
||||
// yaml
|
||||
#include <yaml-cpp/yaml.h>
|
||||
|
||||
|
|
|
@ -29,8 +29,6 @@
|
|||
#include "uielement.h"
|
||||
#include "graphics/borderedimage.h"
|
||||
|
||||
typedef std::function<void()> Callback;
|
||||
|
||||
class UIButton : public UIElement
|
||||
{
|
||||
public:
|
||||
|
@ -45,7 +43,7 @@ public:
|
|||
|
||||
UI::EButtonState getState() { return m_state; }
|
||||
|
||||
void onClick(const Callback& callback) { m_buttonClickCallback = callback; }
|
||||
void setOnClick(const Callback& callback) { m_buttonClickCallback = callback; }
|
||||
|
||||
private:
|
||||
std::string m_text;
|
||||
|
|
|
@ -45,6 +45,8 @@ void UILabelSkin::load(const YAML::Node& node)
|
|||
|
||||
void UILabelSkin::draw(UIElement *element)
|
||||
{
|
||||
UIElementSkin::draw(element);
|
||||
|
||||
UILabel *label = static_cast<UILabel*>(element);
|
||||
|
||||
m_font->renderText(label->getText(), label->getRect(), ALIGN_TOP_LEFT, m_textColor);
|
||||
|
|
|
@ -25,26 +25,12 @@
|
|||
#include "uitextedit.h"
|
||||
#include "graphics/fonts.h"
|
||||
|
||||
UITextEdit::UITextEdit(Font* font) :
|
||||
UITextEdit::UITextEdit() :
|
||||
UIElement(UI::TextEdit),
|
||||
m_cursorPos(0),
|
||||
m_startRenderPos(0),
|
||||
m_font(font)
|
||||
m_startRenderPos(0)
|
||||
{
|
||||
if(!font)
|
||||
m_font = g_fonts.get("tibia-10px-antialised");
|
||||
}
|
||||
|
||||
void UITextEdit::render()
|
||||
{
|
||||
UIElement::render();
|
||||
|
||||
Rect textRect = getRect();
|
||||
textRect.setLeft(textRect.left() + 2);
|
||||
textRect.setRight(textRect.right() - 2);
|
||||
|
||||
// render text
|
||||
m_font->renderText(m_text, textRect, ALIGN_LEFT, Color(0xFFBFBFBF), Point(m_startRenderPos, 0), m_cursorPos);
|
||||
}
|
||||
|
||||
void UITextEdit::onInputEvent(const InputEvent& event)
|
||||
|
|
|
@ -33,12 +33,10 @@ class Font;
|
|||
class UITextEdit : public UIElement
|
||||
{
|
||||
public:
|
||||
UITextEdit(Font *font = NULL);
|
||||
UITextEdit();
|
||||
|
||||
void onInputEvent(const InputEvent& event);
|
||||
|
||||
void render();
|
||||
|
||||
void clearText();
|
||||
void setText(const std::string& text);
|
||||
const std::string& getText() const { return m_text; }
|
||||
|
@ -57,7 +55,6 @@ private:
|
|||
uint m_cursorPos;
|
||||
int m_startRenderPos;
|
||||
std::string m_text;
|
||||
Font *m_font;
|
||||
};
|
||||
|
||||
typedef std::shared_ptr<UITextEdit> UITextEditPtr;
|
||||
|
|
|
@ -23,4 +23,35 @@
|
|||
|
||||
|
||||
#include "uitexteditskin.h"
|
||||
#include "uitextedit.h"
|
||||
#include "graphics/fonts.h"
|
||||
|
||||
void UITextEditSkin::load(const YAML::Node& node)
|
||||
{
|
||||
UIElementSkin::load(node);
|
||||
std::string tmp;
|
||||
|
||||
if(node.FindValue("font")) {
|
||||
node["font"] >> tmp;
|
||||
m_font = g_fonts.get(tmp);
|
||||
} else
|
||||
m_font = g_fonts.getDefaultFont();
|
||||
|
||||
if(node.FindValue("text color"))
|
||||
node["text color"] >> m_textColor;
|
||||
else
|
||||
m_textColor = Color::white;
|
||||
|
||||
if(node.FindValue("text margin"))
|
||||
node["text margin"] >> m_textMargin;
|
||||
else
|
||||
m_textMargin = 2;
|
||||
}
|
||||
|
||||
void UITextEditSkin::draw(UIElement* element)
|
||||
{
|
||||
UIElementSkin::draw(element);
|
||||
|
||||
UITextEdit *textEdit = static_cast<UITextEdit*>(element);
|
||||
m_font->renderText(textEdit->getText(), textEdit->getRect(), ALIGN_TOP_LEFT, m_textColor);
|
||||
}
|
||||
|
|
|
@ -29,12 +29,24 @@
|
|||
#include "uiconstants.h"
|
||||
#include "uielementskin.h"
|
||||
|
||||
class Font;
|
||||
|
||||
class UITextEditSkin : public UIElementSkin
|
||||
{
|
||||
public:
|
||||
UITextEditSkin(const std::string& name) :
|
||||
UIElementSkin(name, UI::TextEdit) { }
|
||||
|
||||
void load(const YAML::Node& node);
|
||||
void draw(UIElement *element);
|
||||
|
||||
Font *getFont() const { return m_font; }
|
||||
int getTextMargin() const { return m_textMargin; }
|
||||
|
||||
private:
|
||||
Font *m_font;
|
||||
int m_textMargin;
|
||||
Color m_textColor;
|
||||
};
|
||||
|
||||
#endif // UITEXTEDITSKIN_H
|
||||
|
|
|
@ -115,9 +115,7 @@ int main(int argc, const char *argv[])
|
|||
{
|
||||
std::shared_ptr<MenuState> initialState(new MenuState);
|
||||
//std::shared_ptr<TestState> initialState(new TestState);
|
||||
g_dispatcher.addTask([&initialState]{
|
||||
g_engine.changeState(initialState.get());
|
||||
});
|
||||
g_dispatcher.addTask(boost::bind(&Engine::changeState, &g_engine, initialState.get()));
|
||||
|
||||
Platform::showWindow();
|
||||
//Platform::hideMouseCursor();
|
||||
|
|
|
@ -42,17 +42,10 @@ void MenuState::onEnter()
|
|||
UIContainerPtr mainMenuPanel = UILoader::loadFile("ui/mainMenu.yml")->asUIContainer();
|
||||
|
||||
UIButtonPtr button = std::static_pointer_cast<UIButton>(mainMenuPanel->getChildById("exitGameButton"));
|
||||
button->onClick([this]{
|
||||
this->onClose();
|
||||
});
|
||||
button->setOnClick(boost::bind(&MenuState::onClose, this));
|
||||
|
||||
button = std::static_pointer_cast<UIButton>(mainMenuPanel->getChildById("enterGameButton"));
|
||||
button->onClick([mainMenuPanel]{
|
||||
UIElementPtr window = UIContainer::getRootContainer()->getChildById("enterGameWindow");
|
||||
if(!window)
|
||||
window = UILoader::loadFile("ui/enterGameWindow.yml");
|
||||
mainMenuPanel->setEnabled(false);
|
||||
});
|
||||
button->setOnClick(boost::bind(&MenuState::enterGameButton_clicked, this));
|
||||
}
|
||||
|
||||
void MenuState::onLeave()
|
||||
|
@ -89,3 +82,12 @@ void MenuState::render()
|
|||
texCoords.moveBottomRight(texSize.toPoint());
|
||||
g_graphics.drawTexturedRect(Rect(0, 0, screenSize), m_background, texCoords);
|
||||
}
|
||||
|
||||
void MenuState::enterGameButton_clicked()
|
||||
{
|
||||
UIElementPtr window = UIContainer::getRootContainer()->getChildById("enterGameWindow");
|
||||
if(!window)
|
||||
window = UILoader::loadFile("ui/enterGameWindow.yml");
|
||||
window->getParent()->setEnabled(false);
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ public:
|
|||
void render();
|
||||
|
||||
private:
|
||||
void createMainMenu();
|
||||
void enterGameButton_clicked();
|
||||
|
||||
UIPanelPtr m_menuPanel;
|
||||
TexturePtr m_background;
|
||||
|
|
|
@ -36,11 +36,13 @@ ProtocolTibia87::ProtocolTibia87()
|
|||
|
||||
void ProtocolTibia87::begin()
|
||||
{
|
||||
/*
|
||||
connect("icechaw.otland.net", 7171,
|
||||
[this](){
|
||||
this->afterConnect();
|
||||
}
|
||||
);
|
||||
*/
|
||||
}
|
||||
|
||||
void ProtocolTibia87::login(const std::string& account, const std::string& password)
|
||||
|
@ -73,11 +75,13 @@ void ProtocolTibia87::sendAccount(const std::string& account, const std::string&
|
|||
networkMessage->setMessageLength(m_notEncriptedLen + 128);
|
||||
networkMessage->updateHeaderLength();
|
||||
|
||||
/*
|
||||
send(networkMessage,
|
||||
[this](){
|
||||
this->afterSendAccount();
|
||||
}
|
||||
);
|
||||
*/
|
||||
}
|
||||
|
||||
void ProtocolTibia87::afterConnect()
|
||||
|
@ -87,11 +91,13 @@ void ProtocolTibia87::afterConnect()
|
|||
|
||||
void ProtocolTibia87::afterSendAccount()
|
||||
{
|
||||
/*
|
||||
recv(
|
||||
[this](NetworkMessagePtr networkMessage){
|
||||
this->parseCharacterList(networkMessage);
|
||||
}
|
||||
);
|
||||
*/
|
||||
}
|
||||
|
||||
void ProtocolTibia87::onError(const boost::system::error_code& error, const std::string& msg)
|
||||
|
|
Loading…
Reference in New Issue