OpenMW
apps/openmw/mwgui/tooltips.hpp
Go to the documentation of this file.
00001 
00002 #ifndef MWGUI_TOOLTIPS_H
00003 #define MWGUI_TOOLTIPS_H
00004 
00005 #include <openengine/gui/layout.hpp>
00006 #include "../mwworld/ptr.hpp"
00007 
00008 #include "widgets.hpp"
00009 
00010 namespace MWGui
00011 {
00012     // Info about tooltip that is supplied by the MWWorld::Class object
00013     struct ToolTipInfo
00014     {
00015     public:
00016         ToolTipInfo()
00017             : isPotion(false)
00018             , imageSize(32)
00019             , wordWrap(true)
00020             , remainingEnchantCharge(-1)
00021         {}
00022 
00023         std::string caption;
00024         std::string text;
00025         std::string icon;
00026         int imageSize;
00027 
00028         // enchantment (for cloth, armor, weapons)
00029         std::string enchant;
00030         int remainingEnchantCharge;
00031 
00032         // effects (for potions, ingredients)
00033         Widgets::SpellEffectList effects;
00034 
00035         bool isPotion; // potions do not show target in the tooltip
00036         bool wordWrap;
00037     };
00038 
00039     class ToolTips : public OEngine::GUI::Layout
00040     {
00041     public:
00042         ToolTips();
00043 
00044         void onFrame(float frameDuration);
00045 
00046         void setEnabled(bool enabled);
00047 
00048         void toggleFullHelp(); 
00049         bool getFullHelp() const;
00050 
00051         void setDelay(float delay);
00052 
00053         void setFocusObject(const MWWorld::Ptr& focus);
00054         void setFocusObjectScreenCoords(float min_x, float min_y, float max_x, float max_y);
00056 
00057         static std::string getValueString(const int value, const std::string& prefix);
00059 
00060         static std::string getMiscString(const std::string& text, const std::string& prefix);
00062 
00063         static std::string toString(const float value);
00064         static std::string toString(const int value);
00065 
00066         static std::string getCountString(const int value);
00068 
00069         // these do not create an actual tooltip, but they fill in the data that is required so the tooltip
00070         // system knows what to show in case this widget is hovered
00071         static void createSkillToolTip(MyGUI::Widget* widget, int skillId);
00072         static void createAttributeToolTip(MyGUI::Widget* widget, int attributeId);
00073         static void createSpecializationToolTip(MyGUI::Widget* widget, const std::string& name, int specId);
00074         static void createBirthsignToolTip(MyGUI::Widget* widget, const std::string& birthsignId);
00075         static void createRaceToolTip(MyGUI::Widget* widget, const ESM::Race* playerRace);
00076         static void createClassToolTip(MyGUI::Widget* widget, const ESM::Class& playerClass);
00077         static void createMagicEffectToolTip(MyGUI::Widget* widget, short id);
00078 
00079     private:
00080         MyGUI::Widget* mDynamicToolTipBox;
00081 
00082         MWWorld::Ptr mFocusObject;
00083 
00084         void findImageExtension(std::string& image);
00085 
00086         MyGUI::IntSize getToolTipViaPtr (bool image=true);
00088 
00089         MyGUI::IntSize createToolTip(const ToolTipInfo& info);
00091 
00092         float mFocusToolTipX;
00093         float mFocusToolTipY;
00094 
00096         void position(MyGUI::IntPoint& position, MyGUI::IntSize size, MyGUI::IntSize viewportSize);
00097 
00098         int mHorizontalScrollIndex;
00099 
00100 
00101         float mDelay;
00102         float mRemainingDelay; // remaining time until tooltip will show
00103 
00104         int mLastMouseX;
00105         int mLastMouseY;
00106 
00107         bool mEnabled;
00108 
00109         bool mFullHelp;
00110     };
00111 }
00112 #endif