25 #include <boost/bind.hpp> 50 _parentWidget(0), _parentModel(0),
51 _empty(true), _visible(false), _align(0.0f),
52 _offscreen(false), _x(0.0f), _y(0.0f), _z(0.0f),
53 _lineHeight(0.0f), _lineSpacing(0.0f),
_width(0.0f),
_height(0.0f),
54 _needCamera(false), _detectEdge(false) {
60 _parentWidget(&parent), _parentModel(0),
61 _empty(true), _visible(false), _align(0.0f),
62 _offscreen(false), _x(0.0f), _y(0.0f), _z(0.0f),
63 _lineHeight(0.0f), _lineSpacing(0.0f),
_width(0.0f),
_height(0.0f),
64 _needCamera(false), _detectEdge(true) {
70 _parentWidget(0), _parentModel(&parent),
71 _empty(true), _visible(false), _align(0.0f),
72 _offscreen(false), _x(0.0f), _y(0.0f), _z(0.0f),
73 _lineHeight(0.0f), _lineSpacing(0.0f),
_width(0.0f),
_height(0.0f),
74 _needCamera(true), _detectEdge(false) {
107 std::vector<Common::UString> lines;
110 for (std::vector<Common::UString>::const_iterator l = lines.begin();
111 l != lines.end(); ++l) {
150 bool onscreen =
true;
159 if (!
GfxMan.project(aX, aY, aZ, x, y, z))
162 onscreen = ((z >= 0.0f) && (z <= 1.0f));
190 const float bubbleWidth = hasBubble ? (
_bubble->getWidth () - 30.0f) :
_width;
191 const float bubbleHeight = hasBubble ? (
_bubble->getHeight() - 8.0f) :
_height;
193 const float bubbleWantX = pX +
_x - (bubbleWidth / 2.0f);
194 const float bubbleRight = bubbleWantX + bubbleWidth + 15.0f;
197 const float overX =
_detectEdge ?
MAX(0.0f, bubbleRight - maxX) : 0.0f;
199 const float bubbleX = bubbleWantX - overX;
200 const float bubbleY = pY + bubbleHeight +
_y;
201 const float bubbleZ = pZ +
_z;
204 _bubble->setPosition(floorf(bubbleX), floorf(bubbleY), floorf(bubbleZ));
211 const float portraitWidth = hasPortrait ?
_portrait->getWidth () : 0.0f;
212 const float portraitHeight = hasPortrait ?
_portrait->getHeight() : 0.0f;
214 const float portraitX = bubbleX;
215 const float portraitY = bubbleY - portraitHeight - 3.0f;
216 const float portraitZ = bubbleZ - 1.0f;
219 _portrait->setPosition(floorf(portraitX), floorf(portraitY), floorf(portraitZ));
224 const float portraitSpacerWidth = portraitWidth + (
_portrait ? 2.0f : 0.0f);
226 const float bubbleTextWidth = bubbleWidth - portraitSpacerWidth;
230 const float textBorderY = (bubbleHeight - textHeight) / 2.0f;
232 const float textBottomX = bubbleX + portraitSpacerWidth;
233 const float textBottomY = bubbleY - textBorderY + 1.0f;
234 const float textBottomZ = bubbleZ - 1.0f;
236 float textY = textBottomY;
237 for (std::vector<Graphics::Aurora::Text *>::iterator t =
_texts.begin(); t !=
_texts.end(); ++t) {
238 const float textWidth = (*t)->getWidth();
239 const float textBorderX = (bubbleTextWidth - textWidth) *
_align;
240 const float textX = textBottomX + textBorderX;
241 const float lineY = textY - (*t)->getHeight();
242 (*t)->setPosition(floorf(textX), floorf(lineY), floorf(textBottomZ));
292 width =
MAX(width, (*t)->getWidth());
320 for (std::vector<Line>::const_iterator l =
_lines.begin(); l !=
_lines.end(); l++) {
321 std::vector<Common::UString> lineLines;
325 for (std::vector<Common::UString>::const_iterator i = lineLines.begin(); i != lineLines.end(); ++i) {
327 _texts.back()->setTag(
"Tooltip#Text");
335 bool needRedo = force;
337 bool showBubble, showText, showPortrait;
342 if ((fontName !=
_font ) ||
391 warning(
"Tooltip::redoBubble(): Failed loading model \"%s\"", bubbleModel.
c_str());
395 _bubble->setTag(
"Tooltip#Bubble");
479 showBubble = mode == 2;
480 showText = mode >= 1;
481 showPortrait = mode == 2;
487 showPortrait =
false;
500 return ConfigMan.getBool(
"largefonts") ?
"fnt_dialog_big16" :
"fnt_dialog16x16";
519 else if (lines <= 10)
521 else if (lines <= 16)
526 if ((modelLines >= 1) && (modelLines <= 3)) {
529 else if (width <= 150.0f)
The global graphics manager.
A class holding an UTF-8 string.
void reset(PointerType o=0)
Resets the pointer with the new value.
The global config manager.
virtual float getLineSpacing() const
Return the size of space between lines.
float split(const Common::UString &line, std::vector< Common::UString > &lines, float maxWidth=0.0f, float maxHeight=0.0f, bool trim=true) const
#define TimerMan
Shortcut for accessing the timer manager.
A vector of pointer to objects, with automatic deletion.
const char * c_str() const
Return the (utf8 encoded) string data.
static UString format(const char *s,...) GCC_PRINTF(1
Print formatted data into an UString object, similar to sprintf().
#define ConfigMan
Shortcut for accessing the config manager.
Utility templates and functions.
bool empty() const
Is the string empty?
void warning(const char *s,...)
Convenience class that locks a mutex on creation and unlocks it on destruction.
#define WindowMan
Shortcut for accessing the window manager.
void getTooltipAnchor(float &x, float &y, float &z) const
Get the point where the feedback tooltip is anchored.
Graphics::Aurora::Model * loadModelGUI(const Common::UString &resref)
A portrait model and widget.
void split(iterator splitPoint, UString &left, UString &right, bool remove=false) const
A textured quad for a GUI element.
virtual float getHeight() const =0
Return the height of a character.
#define GfxMan
Shortcut for accessing the graphics manager.
#define FontMan
Shortcut for accessing the font manager.
Generic Aurora engines model functions.