mirror of
https://github.com/edubart/otclient.git
synced 2025-10-16 20:43:26 +02:00
remove lambdas
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user