tibia-client/src/client/statictext.h

69 lines
2.4 KiB
C
Raw Normal View History

2011-12-29 18:45:59 +01:00
/*
* Copyright (c) 2010-2013 OTClient <https://github.com/edubart/otclient>
2011-12-29 18:45:59 +01:00
*
* 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 STATICTEXT_H
#define STATICTEXT_H
2012-06-22 05:14:13 +02:00
#include "thing.h"
#include <framework/graphics/cachedtext.h>
#include <framework/core/timer.h>
2011-12-29 18:45:59 +01:00
2012-06-22 05:14:13 +02:00
// @bindclass
class StaticText : public Thing
2011-12-29 18:45:59 +01:00
{
public:
StaticText();
2012-06-17 23:47:05 +02:00
void drawText(const Point& dest, const Rect& parentRect);
2011-12-29 18:45:59 +01:00
std::string getName() { return m_name; }
Otc::MessageMode getMessageMode() { return m_mode; }
2012-07-27 00:56:46 +02:00
std::string getFirstMessage() { return m_messages[0].first; }
2011-12-29 18:45:59 +01:00
bool isYell() { return m_mode == Otc::MessageYell || m_mode == Otc::MessageMonsterYell || m_mode == Otc::MessageBarkLoud; }
2012-01-30 01:00:12 +01:00
void setText(const std::string& text);
void setFont(const std::string& fontName);
bool addMessage(const std::string& name, Otc::MessageMode mode, const std::string& text);
2011-12-29 18:45:59 +01:00
StaticTextPtr asStaticText() { return static_self_cast<StaticText>(); }
2012-06-05 17:36:27 +02:00
bool isStaticText() { return true; }
2011-12-29 18:45:59 +01:00
void setColor(const Color& color) { m_color = color; }
Color getColor() { return m_color; }
2011-12-29 18:45:59 +01:00
private:
void update();
void scheduleUpdate();
2011-12-29 18:45:59 +01:00
void compose();
2012-07-29 12:32:44 +02:00
stdext::boolean<false> m_yell;
2012-07-27 00:56:46 +02:00
std::deque<std::pair<std::string, ticks_t>> m_messages;
std::string m_name;
Otc::MessageMode m_mode;
2011-12-29 18:45:59 +01:00
Color m_color;
CachedText m_cachedText;
ScheduledEventPtr m_updateEvent;
2011-12-29 18:45:59 +01:00
};
#endif