1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-11 09:36:37 +00:00
OpenMW/apps/openmw/mwgui/tooltips.hpp

129 lines
3.9 KiB
C++
Raw Normal View History

2012-04-14 15:47:44 +00:00
#ifndef MWGUI_TOOLTIPS_H
#define MWGUI_TOOLTIPS_H
2015-05-01 00:09:57 +00:00
#include "layout.hpp"
#include "../mwworld/ptr.hpp"
2012-04-14 15:47:44 +00:00
#include "widgets.hpp"
namespace ESM
{
struct Class;
struct Race;
}
2012-04-14 15:47:44 +00:00
namespace MWGui
{
// Info about tooltip that is supplied by the MWWorld::Class object
struct ToolTipInfo
{
public:
ToolTipInfo()
2015-04-25 18:37:42 +00:00
: imageSize(32)
, remainingEnchantCharge(-1)
2015-04-25 18:37:42 +00:00
, isPotion(false)
, wordWrap(true)
{}
std::string caption;
std::string text;
std::string icon;
2013-03-03 11:01:19 +00:00
int imageSize;
// enchantment (for cloth, armor, weapons)
std::string enchant;
int remainingEnchantCharge;
// effects (for potions, ingredients)
Widgets::SpellEffectList effects;
// local map notes
std::vector<std::string> notes;
bool isPotion; // potions do not show target in the tooltip
2013-03-03 11:01:19 +00:00
bool wordWrap;
};
2015-05-01 00:09:57 +00:00
class ToolTips : public Layout
2012-04-14 15:47:44 +00:00
{
public:
ToolTips();
2012-04-14 15:47:44 +00:00
void onFrame(float frameDuration);
void setEnabled(bool enabled);
bool toggleFullHelp(); ///< show extra info in item tooltips (owner, script)
bool getFullHelp() const;
2012-04-16 13:00:44 +00:00
2012-05-28 07:46:05 +00:00
void setDelay(float delay);
void setFocusObject(const MWWorld::Ptr& focus);
void setFocusObjectScreenCoords(float min_x, float min_y, float max_x, float max_y);
///< set the screen-space position of the tooltip for focused object
static std::string getValueString(const int value, const std::string& prefix);
///< @return "prefix: value" or "" if value is 0
static std::string getMiscString(const std::string& text, const std::string& prefix);
///< @return "prefix: text" or "" if text is empty
static std::string toString(const float value);
static std::string toString(const int value);
2012-05-12 11:46:03 +00:00
static std::string getCountString(const int value);
///< @return blank string if count is 1, or else " (value)"
static std::string getCellRefString(const MWWorld::CellRef& cellref);
///< Returns a string containing debug tooltip information about the given cellref.
// these do not create an actual tooltip, but they fill in the data that is required so the tooltip
// system knows what to show in case this widget is hovered
static void createSkillToolTip(MyGUI::Widget* widget, int skillId);
static void createAttributeToolTip(MyGUI::Widget* widget, int attributeId);
static void createSpecializationToolTip(MyGUI::Widget* widget, const std::string& name, int specId);
static void createBirthsignToolTip(MyGUI::Widget* widget, const std::string& birthsignId);
static void createRaceToolTip(MyGUI::Widget* widget, const ESM::Race* playerRace);
static void createClassToolTip(MyGUI::Widget* widget, const ESM::Class& playerClass);
2012-09-22 22:36:20 +00:00
static void createMagicEffectToolTip(MyGUI::Widget* widget, short id);
bool checkOwned();
/// Returns True if taking mFocusObject would be crime
2012-04-14 15:47:44 +00:00
private:
MyGUI::Widget* mDynamicToolTipBox;
MWWorld::Ptr mFocusObject;
2012-04-15 19:14:14 +00:00
MyGUI::IntSize getToolTipViaPtr (bool image=true);
2012-04-15 19:14:14 +00:00
///< @return requested tooltip size
MyGUI::IntSize createToolTip(const ToolTipInfo& info);
2012-04-15 22:16:35 +00:00
///< @return requested tooltip size
float mFocusToolTipX;
float mFocusToolTipY;
/// Adjust position for a tooltip so that it doesn't leave the screen and does not obscure the mouse cursor
void position(MyGUI::IntPoint& position, MyGUI::IntSize size, MyGUI::IntSize viewportSize);
2014-08-24 18:51:41 +00:00
static std::string sSchoolNames[6];
int mHorizontalScrollIndex;
2012-05-28 07:46:05 +00:00
float mDelay;
float mRemainingDelay; // remaining time until tooltip will show
int mLastMouseX;
int mLastMouseY;
bool mEnabled;
2012-04-16 13:00:44 +00:00
bool mFullHelp;
2015-07-18 15:13:20 +00:00
int mShowOwned;
2012-04-14 15:47:44 +00:00
};
}
#endif