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

141 lines
4.8 KiB
C++
Raw Normal View History

2012-04-14 17:47:44 +02:00
#ifndef MWGUI_TOOLTIPS_H
#define MWGUI_TOOLTIPS_H
#include "../mwworld/ptr.hpp"
2022-09-22 21:26:05 +03:00
#include "layout.hpp"
2012-04-14 17:47:44 +02:00
#include "widgets.hpp"
namespace ESM
{
struct Class;
struct Race;
}
2012-04-14 17:47:44 +02:00
namespace MWGui
{
// Info about tooltip that is supplied by the MWWorld::Class object
struct ToolTipInfo
{
public:
ToolTipInfo()
2015-04-25 13:37:42 -05:00
: imageSize(32)
, remainingEnchantCharge(-1)
2015-04-25 13:37:42 -05:00
, isPotion(false)
2019-05-06 23:48:13 +00:00
, isIngredient(false)
2015-04-25 13:37:42 -05:00
, wordWrap(true)
2022-09-22 21:26:05 +03:00
{
}
std::string caption;
std::string text;
std::string icon;
2013-03-03 12:01:19 +01:00
int imageSize;
// enchantment (for cloth, armor, weapons)
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID Slowly going through all the changes to make, still hundreds of errors a lot of functions/structures use std::string or stringview to designate an ID. So it takes time Continues slowly replacing ids. There are technically more and more compilation errors I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type Continue moving forward, changes to the stores slowly moving along Starting to see the fruit of those changes. still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type. More replacements. Things are starting to get easier I can see more and more often the issue is that the function is awaiting a RefId, but is given a string there is less need to go down functions and to fix a long list of them. Still moving forward, and for the first time error count is going down! Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably Cells are back to using string for the name, haven't fixed everything yet. Many other changes Under the bar of 400 compilation errors. more good progress <100 compile errors! More progress Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string some more progress on other fronts Mostly game settings clean one error opened a lot of other errors. Down to 18, but more will prbably appear only link errors left?? Fixed link errors OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
ESM::RefId 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
2019-05-06 23:48:13 +00:00
bool isIngredient; // ingredients have no effect magnitude
2013-03-03 12:01:19 +01:00
bool wordWrap;
};
2015-05-01 02:09:57 +02:00
class ToolTips : public Layout
2012-04-14 17:47:44 +02:00
{
public:
ToolTips();
2012-04-14 17:47:44 +02:00
void onFrame(float frameDuration);
void update(float frameDuration);
2012-04-14 17:47:44 +02:00
void setEnabled(bool enabled);
bool toggleFullHelp(); ///< show extra info in item tooltips (owner, script)
bool getFullHelp() const;
2012-04-16 15:00:44 +02:00
2012-05-28 09:46:05 +02:00
void setDelay(float delay);
2018-11-13 10:00:12 +04:00
void clear();
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 getWeightString(const float weight, const std::string& prefix);
static std::string getPercentString(const float value, const std::string& prefix);
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 13:46:03 +02:00
static std::string getCountString(const int value);
///< @return blank string if count is 1, or else " (value)"
static std::string getSoulString(const MWWorld::CellRef& cellref);
///< Returns a string containing the name of the creature that the ID in the cellref's soul field belongs to.
static std::string getCellRefString(const MWWorld::CellRef& cellref);
///< Returns a string containing debug tooltip information about the given cellref.
2022-09-22 21:26:05 +03:00
static std::string getDurationString(float duration, const std::string& prefix);
///< Returns duration as two largest time units, rounded down. Note: not localized; no line break.
// 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
2023-06-06 17:24:22 +02:00
static void createSkillToolTip(MyGUI::Widget* widget, ESM::RefId skillId);
2023-06-19 20:41:54 +02:00
static void createAttributeToolTip(MyGUI::Widget* widget, ESM::Attribute::AttributeID attributeId);
static void createSpecializationToolTip(MyGUI::Widget* widget, const std::string& name, int specId);
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID Slowly going through all the changes to make, still hundreds of errors a lot of functions/structures use std::string or stringview to designate an ID. So it takes time Continues slowly replacing ids. There are technically more and more compilation errors I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type Continue moving forward, changes to the stores slowly moving along Starting to see the fruit of those changes. still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type. More replacements. Things are starting to get easier I can see more and more often the issue is that the function is awaiting a RefId, but is given a string there is less need to go down functions and to fix a long list of them. Still moving forward, and for the first time error count is going down! Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably Cells are back to using string for the name, haven't fixed everything yet. Many other changes Under the bar of 400 compilation errors. more good progress <100 compile errors! More progress Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string some more progress on other fronts Mostly game settings clean one error opened a lot of other errors. Down to 18, but more will prbably appear only link errors left?? Fixed link errors OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
static void createBirthsignToolTip(MyGUI::Widget* widget, const ESM::RefId& birthsignId);
static void createRaceToolTip(MyGUI::Widget* widget, const ESM::Race* playerRace);
static void createClassToolTip(MyGUI::Widget* widget, const ESM::Class& playerClass);
2012-09-23 00:36:20 +02:00
static void createMagicEffectToolTip(MyGUI::Widget* widget, short id);
2022-09-22 21:26:05 +03:00
bool checkOwned();
/// Returns True if taking mFocusObject would be crime
2022-09-22 21:26:05 +03:00
2012-04-14 17:47:44 +02:00
private:
MyGUI::Widget* mDynamicToolTipBox;
MWWorld::Ptr mFocusObject;
2012-04-15 21:14:14 +02:00
2022-09-22 21:26:05 +03:00
MyGUI::IntSize getToolTipViaPtr(int count, bool image = true, bool isOwned = false);
2012-04-15 21:14:14 +02:00
///< @return requested tooltip size
MyGUI::IntSize createToolTip(const ToolTipInfo& info, bool isOwned = false);
2012-04-16 00:16:35 +02:00
///< @return requested tooltip size
/// @param isFocusObject Is the object this tooltips originates from mFocusObject?
2012-04-16 00:16:35 +02:00
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);
int mHorizontalScrollIndex;
2012-05-28 09:46:05 +02:00
float mDelay;
float mRemainingDelay; // remaining time until tooltip will show
int mLastMouseX;
int mLastMouseY;
bool mEnabled;
2012-04-16 15:00:44 +02:00
bool mFullHelp;
2022-09-22 21:26:05 +03:00
float mFrameDuration;
2012-04-14 17:47:44 +02:00
};
}
#endif