OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
tooltips.hpp
Go to the documentation of this file.
1 #ifndef MWGUI_TOOLTIPS_H
2 #define MWGUI_TOOLTIPS_H
3 
4 #include "layout.hpp"
5 #include "../mwworld/ptr.hpp"
6 
7 #include "widgets.hpp"
8 
9 namespace ESM
10 {
11  struct Class;
12  struct Race;
13 }
14 
15 namespace MWGui
16 {
17  // Info about tooltip that is supplied by the MWWorld::Class object
18  struct ToolTipInfo
19  {
20  public:
22  : imageSize(32)
24  , isPotion(false)
25  , wordWrap(true)
26  {}
27 
28  std::string caption;
29  std::string text;
30  std::string icon;
31  int imageSize;
32 
33  // enchantment (for cloth, armor, weapons)
34  std::string enchant;
36 
37  // effects (for potions, ingredients)
39 
40  // local map notes
41  std::vector<std::string> notes;
42 
43  bool isPotion; // potions do not show target in the tooltip
44  bool wordWrap;
45  };
46 
47  class ToolTips : public Layout
48  {
49  public:
50  ToolTips();
51 
52  void onFrame(float frameDuration);
53 
54  void setEnabled(bool enabled);
55 
56  bool toggleFullHelp();
57  bool getFullHelp() const;
58 
59  void setDelay(float delay);
60 
61  void setFocusObject(const MWWorld::ConstPtr& focus);
62  void setFocusObjectScreenCoords(float min_x, float min_y, float max_x, float max_y);
64 
65  static std::string getWeightString(const float weight, const std::string& prefix);
66  static std::string getValueString(const int value, const std::string& prefix);
68 
69  static std::string getMiscString(const std::string& text, const std::string& prefix);
71 
72  static std::string toString(const float value);
73  static std::string toString(const int value);
74 
75  static std::string getCountString(const int value);
77 
78  static std::string getCellRefString(const MWWorld::CellRef& cellref);
80 
81  // these do not create an actual tooltip, but they fill in the data that is required so the tooltip
82  // system knows what to show in case this widget is hovered
83  static void createSkillToolTip(MyGUI::Widget* widget, int skillId);
84  static void createAttributeToolTip(MyGUI::Widget* widget, int attributeId);
85  static void createSpecializationToolTip(MyGUI::Widget* widget, const std::string& name, int specId);
86  static void createBirthsignToolTip(MyGUI::Widget* widget, const std::string& birthsignId);
87  static void createRaceToolTip(MyGUI::Widget* widget, const ESM::Race* playerRace);
88  static void createClassToolTip(MyGUI::Widget* widget, const ESM::Class& playerClass);
89  static void createMagicEffectToolTip(MyGUI::Widget* widget, short id);
90 
91  bool checkOwned();
93 
94  private:
95  MyGUI::Widget* mDynamicToolTipBox;
96 
98 
99  MyGUI::IntSize getToolTipViaPtr (int count, bool image=true);
101 
102  MyGUI::IntSize createToolTip(const ToolTipInfo& info, bool isFocusObject);
105 
108 
110  void position(MyGUI::IntPoint& position, MyGUI::IntSize size, MyGUI::IntSize viewportSize);
111 
112  static std::string sSchoolNames[6];
113 
115 
116 
117  float mDelay;
118  float mRemainingDelay; // remaining time until tooltip will show
119 
122 
123  bool mEnabled;
124 
125  bool mFullHelp;
126 
128  };
129 }
130 #endif
Definition: tooltips.hpp:18
static std::string sSchoolNames[6]
Definition: tooltips.hpp:112
Encapsulated variant of ESM::CellRef with change tracking.
Definition: cellref.hpp:15
static void createBirthsignToolTip(MyGUI::Widget *widget, const std::string &birthsignId)
Definition: tooltips.cpp:721
std::vector< std::string > notes
Definition: tooltips.hpp:41
static std::string toString(const float value)
Definition: tooltips.cpp:571
MyGUI::IntSize getToolTipViaPtr(int count, bool image=true)
Definition: tooltips.cpp:325
void setFocusObject(const MWWorld::ConstPtr &focus)
Definition: tooltips.cpp:320
bool wordWrap
Definition: tooltips.hpp:44
bool mFullHelp
Definition: tooltips.hpp:125
void setDelay(float delay)
Definition: tooltips.cpp:833
int mLastMouseY
Definition: tooltips.hpp:121
std::string caption
Definition: tooltips.hpp:28
static std::string getMiscString(const std::string &text, const std::string &prefix)
Definition: tooltips.cpp:605
std::string enchant
Definition: tooltips.hpp:34
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
Definition: tooltips.cpp:655
static void createRaceToolTip(MyGUI::Widget *widget, const ESM::Race *playerRace)
Definition: tooltips.cpp:785
static void createSkillToolTip(MyGUI::Widget *widget, int skillId)
Definition: tooltips.cpp:661
void onFrame(float frameDuration)
Definition: tooltips.cpp:69
float mFocusToolTipY
Definition: tooltips.hpp:107
static void createMagicEffectToolTip(MyGUI::Widget *widget, short id)
Definition: tooltips.cpp:814
MWWorld::ConstPtr mFocusObject
Definition: tooltips.hpp:97
Widgets::SpellEffectList effects
Definition: tooltips.hpp:38
MyGUI::Widget * mDynamicToolTipBox
Returns True if taking mFocusObject would be crime.
Definition: tooltips.hpp:95
std::vector< SpellEffectParams > SpellEffectList
Definition: widgets.hpp:89
ToolTips()
Definition: tooltips.cpp:31
static void createClassToolTip(MyGUI::Widget *widget, const ESM::Class &playerClass)
Definition: tooltips.cpp:793
static std::string getWeightString(const float weight, const std::string &prefix)
Definition: tooltips.cpp:589
bool getFullHelp() const
Definition: tooltips.cpp:650
bool toggleFullHelp()
show extra info in item tooltips (owner, script)
Definition: tooltips.cpp:644
MyGUI::IntSize createToolTip(const ToolTipInfo &info, bool isFocusObject)
Definition: tooltips.cpp:369
static std::string getCellRefString(const MWWorld::CellRef &cellref)
Returns a string containing debug tooltip information about the given cellref.
Definition: tooltips.cpp:621
Pointer to a const LiveCellRef.
Definition: ptr.hpp:90
void position(MyGUI::IntPoint &position, MyGUI::IntSize size, MyGUI::IntSize viewportSize)
Adjust position for a tooltip so that it doesn't leave the screen and does not obscure the mouse curs...
Definition: tooltips.cpp:305
void setEnabled(bool enabled)
Definition: tooltips.cpp:64
ToolTipInfo()
Definition: tooltips.hpp:21
Definition: layout.hpp:13
float mRemainingDelay
Definition: tooltips.hpp:118
Definition: loadclas.hpp:18
Definition: loadrace.hpp:18
static void createSpecializationToolTip(MyGUI::Widget *widget, const std::string &name, int specId)
Definition: tooltips.cpp:702
static void createAttributeToolTip(MyGUI::Widget *widget, int attributeId)
Definition: tooltips.cpp:686
int mShowOwned
Definition: tooltips.hpp:127
bool mEnabled
Definition: tooltips.hpp:123
int mHorizontalScrollIndex
Definition: tooltips.hpp:114
bool isPotion
Definition: tooltips.hpp:43
Definition: tooltips.hpp:47
std::string text
Definition: tooltips.hpp:29
int imageSize
Definition: tooltips.hpp:31
bool checkOwned()
Definition: tooltips.cpp:350
float mFocusToolTipX
Definition: tooltips.hpp:106
float mDelay
Definition: tooltips.hpp:117
int mLastMouseX
Definition: tooltips.hpp:120
static std::string getCountString(const int value)
Definition: tooltips.cpp:613
std::string icon
Definition: tooltips.hpp:30
static std::string getValueString(const int value, const std::string &prefix)
Definition: tooltips.cpp:597
const char * name
Definition: crashcatcher.cpp:59
int remainingEnchantCharge
Definition: tooltips.hpp:35