messagebox (not working yet)

This commit is contained in:
Eduardo Bart
2011-04-23 17:04:49 -03:00
parent a98f1d67db
commit 3960240b8e
9 changed files with 61 additions and 94 deletions

View File

@@ -50,41 +50,3 @@ void Dispatcher::addTask(const SimpleCallback& callback)
{
m_taskList.push(new Task(callback));
}
/*
* #include <prerequisites.h>
#include <core/dispatcher.h>
#include <core/engine.h>
#include <stack>
Dispatcher g_dispatcher;
void Dispatcher::poll()
{
if(!m_taskList.empty()) {
auto it = m_taskList.begin();
m_taskList.erase(it);
(*it)();
}
while(!m_scheduledTaskList.empty()) {
ScheduledTask *task = m_scheduledTaskList.top();
if(g_engine.getCurrentFrameTicks() < task->ticks)
break;
m_scheduledTaskList.pop();
task->callback();
delete task;
}
}
void Dispatcher::scheduleTask(const SimpleCallback& callback, int delay)
{
m_scheduledTaskList.push(new ScheduledTask(g_engine.getCurrentFrameTicks() + delay, callback));
}
void Dispatcher::addTask(const SimpleCallback& callback)
{
m_taskList.push_back(callback);
}
*/

View File

@@ -61,39 +61,4 @@ private:
extern Dispatcher g_dispatcher;
/*
* class ScheduledTask {
public:
inline ScheduledTask(const SimpleCallback& _callback) : ticks(0), callback(_callback) { }
inline ScheduledTask(int _ticks, const SimpleCallback& _callback) : ticks(_ticks), callback(_callback) { }
inline bool operator<(const ScheduledTask& other) const { return ticks > other.ticks; }
int ticks;
SimpleCallback callback;
};
class lessScheduledTask : public std::binary_function<ScheduledTask*&, ScheduledTask*&, bool> {
public:
bool operator()(ScheduledTask*& t1,ScheduledTask*& t2) { return (*t1) < (*t2); }
};
class Dispatcher
{
public:
Dispatcher() { }
/// Execute scheduled events
void poll();
/// Add an event
void addTask(const SimpleCallback& callback);
/// Schedula an event
void scheduleTask(const SimpleCallback& callback, int delay);
private:
std::vector<SimpleCallback> m_taskList;
std::priority_queue<ScheduledTask*, std::vector<ScheduledTask*>, lessScheduledTask> m_scheduledTaskList;
};
extern Dispatcher g_dispatcher;*/
#endif // DISPATCHER_H

View File

@@ -24,3 +24,10 @@
#include <prerequisites.h>
#include <ui/uilabel.h>
void UILabel::setText(const std::string& text)
{
m_text = text;
// text size changed, reaplly skin
getSkin()->apply(this);
}

View File

@@ -37,7 +37,7 @@ public:
m_align(ALIGN_TOP_LEFT),
m_color(Color::white) { }
void setText(const std::string& text) { m_text = text; }
void setText(const std::string& text);
const std::string& getText() const { return m_text; }
void setAlign(int align) { m_align = align; }

View File

@@ -151,24 +151,6 @@ void UILoader::loadElements(const UIElementPtr& parent, const YAML::Node& node)
void UILoader::loadElement(const UIElementPtr& element, const YAML::Node& node)
{
// load specific element type
if(element->getElementType() == UI::Button)
loadButton(boost::static_pointer_cast<UIButton>(element), node);
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["skin"].GetType() == YAML::CT_SCALAR) {
@@ -249,6 +231,26 @@ void UILoader::loadElement(const UIElementPtr& element, const YAML::Node& node)
} else
throw YAML::Exception(cnode.GetMark(), "failed to parse lua script");
}
// load specific element type
if(element->getElementType() == UI::Button)
loadButton(boost::static_pointer_cast<UIButton>(element), node);
else if(element->getElementType() == UI::Window) {
UIWindowPtr window = boost::static_pointer_cast<UIWindow>(element);
if(node.FindValue("title"))
window->setTitle(node["title"].Read<std::string>());
}
else if(element->getElementType() == UI::Label) {
UILabelPtr label = boost::static_pointer_cast<UILabel>(element);
if(node.FindValue("text"))
label->setText(node["text"].Read<std::string>());
if(node.FindValue("align")) {
std::string alignDesc;
node["align"] >> alignDesc;
if(alignDesc == "center")
label->setAlign(ALIGN_CENTER);
}
}
}
void UILoader::loadElementAnchor(const UIElementPtr& element, EAnchorType type, const YAML::Node& node)