summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/playerrelations.cpp2
-rw-r--r--src/text.cpp21
-rw-r--r--src/text.h18
3 files changed, 18 insertions, 23 deletions
diff --git a/src/playerrelations.cpp b/src/playerrelations.cpp
index 47577f9e..f949203e 100644
--- a/src/playerrelations.cpp
+++ b/src/playerrelations.cpp
@@ -349,7 +349,7 @@ public:
void ignore(Being *being, unsigned int flags) override
{
- being->flashName(200);
+ being->flashName(1500);
}
};
diff --git a/src/text.cpp b/src/text.cpp
index b71667c5..26124666 100644
--- a/src/text.cpp
+++ b/src/text.cpp
@@ -136,20 +136,21 @@ void Text::draw(gcn::Graphics *graphics, int xOff, int yOff)
*mColor, mFont, !mIsSpeech, true);
}
-FlashText::FlashText(const std::string &text, int x, int y,
- gcn::Graphics::Alignment alignment,
- const gcn::Color *color, gcn::Font *font) :
- Text(text, x, y, alignment, color, false, font),
- mTime(0)
-{
-}
void FlashText::draw(gcn::Graphics *graphics, int xOff, int yOff)
{
- if (mTime)
+ if (mTimer.isSet())
{
- if ((--mTime & 4) == 0)
- return;
+ if (!mTimer.passed())
+ {
+ if ((mTimer.elapsed() & 64) == 0)
+ return;
+ }
+ else
+ {
+ mTimer.reset();
+ }
}
+
Text::draw(graphics, xOff, yOff);
}
diff --git a/src/text.h b/src/text.h
index 2a5c8dde..9fa6104f 100644
--- a/src/text.h
+++ b/src/text.h
@@ -25,6 +25,8 @@
#include "graphics.h"
+#include "utils/time.h"
+
#include <guichan/color.hpp>
class TextManager;
@@ -82,20 +84,12 @@ class Text
class FlashText : public Text
{
public:
- FlashText(const std::string &text, int x, int y,
- gcn::Graphics::Alignment alignment,
- const gcn::Color* color,
- gcn::Font *font = nullptr);
-
- /**
- * Remove the text from the screen
- */
- ~FlashText() override {}
+ using Text::Text;
/**
- * Flash the text for so many refreshes.
+ * Flash the text for so many milliseconds.
*/
- void flash(int time) { mTime = time; }
+ void flash(int time) { mTimer.set(time); }
/**
* Draws the text.
@@ -103,7 +97,7 @@ class FlashText : public Text
void draw(gcn::Graphics *graphics, int xOff, int yOff) override;
private:
- int mTime; /**< Time left for flashing */
+ Timer mTimer; /**< Time left for flashing */
};
#endif // TEXT_H