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: ToolTipInfoMWGui::ToolTipInfo21 ToolTipInfo() 22 : imageSize(32) 23 , remainingEnchantCharge(-1) 24 , isPotion(false) 25 , isIngredient(false) 26 , wordWrap(true) 27 {} 28 29 std::string caption; 30 std::string text; 31 std::string icon; 32 int imageSize; 33 34 // enchantment (for cloth, armor, weapons) 35 std::string enchant; 36 int remainingEnchantCharge; 37 38 // effects (for potions, ingredients) 39 Widgets::SpellEffectList effects; 40 41 // local map notes 42 std::vector<std::string> notes; 43 44 bool isPotion; // potions do not show target in the tooltip 45 bool isIngredient; // ingredients have no effect magnitude 46 bool wordWrap; 47 }; 48 49 class ToolTips : public Layout 50 { 51 public: 52 ToolTips(); 53 54 void onFrame(float frameDuration); 55 void update(float frameDuration); 56 57 void setEnabled(bool enabled); 58 59 bool toggleFullHelp(); ///< show extra info in item tooltips (owner, script) 60 bool getFullHelp() const; 61 62 void setDelay(float delay); 63 64 void clear(); 65 66 void setFocusObject(const MWWorld::Ptr& focus); 67 void setFocusObjectScreenCoords(float min_x, float min_y, float max_x, float max_y); 68 ///< set the screen-space position of the tooltip for focused object 69 70 static std::string getWeightString(const float weight, const std::string& prefix); 71 static std::string getPercentString(const float value, const std::string& prefix); 72 static std::string getValueString(const int value, const std::string& prefix); 73 ///< @return "prefix: value" or "" if value is 0 74 75 static std::string getMiscString(const std::string& text, const std::string& prefix); 76 ///< @return "prefix: text" or "" if text is empty 77 78 static std::string toString(const float value); 79 static std::string toString(const int value); 80 81 static std::string getCountString(const int value); 82 ///< @return blank string if count is 1, or else " (value)" 83 84 static std::string getSoulString(const MWWorld::CellRef& cellref); 85 ///< Returns a string containing the name of the creature that the ID in the cellref's soul field belongs to. 86 87 static std::string getCellRefString(const MWWorld::CellRef& cellref); 88 ///< Returns a string containing debug tooltip information about the given cellref. 89 90 static std::string getDurationString (float duration, const std::string& prefix); 91 ///< Returns duration as two largest time units, rounded down. Note: not localized; no line break. 92 93 // these do not create an actual tooltip, but they fill in the data that is required so the tooltip 94 // system knows what to show in case this widget is hovered 95 static void createSkillToolTip(MyGUI::Widget* widget, int skillId); 96 static void createAttributeToolTip(MyGUI::Widget* widget, int attributeId); 97 static void createSpecializationToolTip(MyGUI::Widget* widget, const std::string& name, int specId); 98 static void createBirthsignToolTip(MyGUI::Widget* widget, const std::string& birthsignId); 99 static void createRaceToolTip(MyGUI::Widget* widget, const ESM::Race* playerRace); 100 static void createClassToolTip(MyGUI::Widget* widget, const ESM::Class& playerClass); 101 static void createMagicEffectToolTip(MyGUI::Widget* widget, short id); 102 103 bool checkOwned(); 104 /// Returns True if taking mFocusObject would be crime 105 106 private: 107 MyGUI::Widget* mDynamicToolTipBox; 108 109 MWWorld::Ptr mFocusObject; 110 111 MyGUI::IntSize getToolTipViaPtr (int count, bool image = true, bool isOwned = false); 112 ///< @return requested tooltip size 113 114 MyGUI::IntSize createToolTip(const ToolTipInfo& info, bool isOwned = false); 115 ///< @return requested tooltip size 116 /// @param isFocusObject Is the object this tooltips originates from mFocusObject? 117 118 float mFocusToolTipX; 119 float mFocusToolTipY; 120 121 /// Adjust position for a tooltip so that it doesn't leave the screen and does not obscure the mouse cursor 122 void position(MyGUI::IntPoint& position, MyGUI::IntSize size, MyGUI::IntSize viewportSize); 123 124 static std::string sSchoolNames[6]; 125 126 int mHorizontalScrollIndex; 127 128 129 float mDelay; 130 float mRemainingDelay; // remaining time until tooltip will show 131 132 int mLastMouseX; 133 int mLastMouseY; 134 135 bool mEnabled; 136 137 bool mFullHelp; 138 139 int mShowOwned; 140 141 float mFrameDuration; 142 }; 143 } 144 #endif 145