mostly complete

actorid
scrawl 13 years ago
parent ab4e03f05f
commit 705d4c6d54

@ -251,14 +251,18 @@ void StatsWindow::addGroup(const std::string &label, MyGUI::IntCoord &coord1, My
coord2.top += lineHeight; coord2.top += lineHeight;
} }
MyGUI::TextBox* StatsWindow::addValueItem(const std::string text, const std::string &value, ColorStyle style, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) MyGUI::TextBox* StatsWindow::addValueItem(const std::string text, const std::string& tooltip, const std::string &value, ColorStyle style, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2)
{ {
MyGUI::TextBox *skillNameWidget, *skillValueWidget; MyGUI::TextBox *skillNameWidget, *skillValueWidget;
skillNameWidget = skillClientWidget->createWidget<MyGUI::TextBox>("SandText", coord1, MyGUI::Align::Default); skillNameWidget = skillClientWidget->createWidget<MyGUI::TextBox>("SandText", coord1, MyGUI::Align::Default);
skillNameWidget->setCaption(text); skillNameWidget->setCaption(text);
skillNameWidget->setUserString("ToolTipType", "Text");
skillNameWidget->setUserString("ToolTipText", tooltip);
skillValueWidget = skillClientWidget->createWidget<MyGUI::TextBox>("SandTextRight", coord2, MyGUI::Align::Default); skillValueWidget = skillClientWidget->createWidget<MyGUI::TextBox>("SandTextRight", coord2, MyGUI::Align::Default);
skillValueWidget->setUserString("ToolTipType", "Text");
skillValueWidget->setUserString("ToolTipText", tooltip);
setStyledText(skillValueWidget, style, value); setStyledText(skillValueWidget, style, value);
skillWidgets.push_back(skillNameWidget); skillWidgets.push_back(skillNameWidget);
@ -310,7 +314,7 @@ void StatsWindow::addSkills(const SkillList &skills, const std::string &titleId,
style = CS_Super; style = CS_Super;
else if (modified < base) else if (modified < base)
style = CS_Sub; style = CS_Sub;
MyGUI::TextBox* widget = addValueItem(mWindowManager.getGameSettingString(skillNameId, skillNameId), boost::lexical_cast<std::string>(static_cast<int>(modified)), style, coord1, coord2); MyGUI::TextBox* widget = addValueItem(mWindowManager.getGameSettingString(skillNameId, skillNameId), "", boost::lexical_cast<std::string>(static_cast<int>(modified)), style, coord1, coord2);
skillWidgetMap[skillId] = widget; skillWidgetMap[skillId] = widget;
} }
} }
@ -369,8 +373,12 @@ void StatsWindow::updateSkillArea()
if (!skillWidgets.empty()) if (!skillWidgets.empty())
addSeparator(coord1, coord2); addSeparator(coord1, coord2);
addValueItem(mWindowManager.getGameSettingString("sReputation", "Reputation"), boost::lexical_cast<std::string>(static_cast<int>(reputation)), CS_Normal, coord1, coord2); addValueItem(mWindowManager.getGameSettingString("sReputation", "Reputation"),
addValueItem(mWindowManager.getGameSettingString("sBounty", "Bounty"), boost::lexical_cast<std::string>(static_cast<int>(bounty)), CS_Normal, coord1, coord2); mWindowManager.getGameSettingString("sSkillsMenuReputationHelp", ""),
boost::lexical_cast<std::string>(static_cast<int>(reputation)), CS_Normal, coord1, coord2);
addValueItem(mWindowManager.getGameSettingString("sBounty", "Bounty"),
mWindowManager.getGameSettingString("sCrimeHelp", ""),
boost::lexical_cast<std::string>(static_cast<int>(bounty)), CS_Normal, coord1, coord2);
clientHeight = coord1.top; clientHeight = coord1.top;
updateScroller(); updateScroller();

@ -53,7 +53,7 @@ namespace MWGui
void addSkills(const SkillList &skills, const std::string &titleId, const std::string &titleDefault, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); void addSkills(const SkillList &skills, const std::string &titleId, const std::string &titleDefault, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2);
void addSeparator(MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); void addSeparator(MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2);
void addGroup(const std::string &label, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); void addGroup(const std::string &label, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2);
MyGUI::TextBox* addValueItem(const std::string text, const std::string &value, ColorStyle style, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); MyGUI::TextBox* addValueItem(const std::string text, const std::string& tooltip, const std::string &value, ColorStyle style, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2);
void addItem(const std::string text, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); void addItem(const std::string text, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2);
void updateScroller(); void updateScroller();

@ -1,12 +1,15 @@
#include "tooltips.hpp" #include "tooltips.hpp"
#include "window_manager.hpp"
#include <boost/lexical_cast.hpp>
using namespace MWGui; using namespace MWGui;
using namespace MyGUI; using namespace MyGUI;
ToolTips::ToolTips() : ToolTips::ToolTips(WindowManager* windowManager) :
Layout("openmw_tooltips.xml") Layout("openmw_tooltips.xml")
, mGameMode(true) , mGameMode(true)
, mFocusChanged(true) , mWindowManager(windowManager)
{ {
getWidget(mTextToolTip, "TextToolTip"); getWidget(mTextToolTip, "TextToolTip");
getWidget(mTextToolTipBox, "TextToolTipBox"); getWidget(mTextToolTipBox, "TextToolTipBox");
@ -31,19 +34,32 @@ void ToolTips::onFrame(float frameDuration)
if (!mGameMode) if (!mGameMode)
{ {
mDynamicToolTipBox->setVisible(false); mDynamicToolTipBox->setVisible(false);
mTextToolTipBox->setVisible(true);
Widget* focus = InputManager::getInstance().getMouseFocusWidget(); Widget* focus = InputManager::getInstance().getMouseFocusWidget();
if (focus == 0) return; if (focus == 0)
{
mTextToolTipBox->setVisible(false);
return;
}
std::string type = focus->getUserString("ToolTipType");
std::string text = focus->getUserString("ToolTipText");
if (type == "" || text == "")
{
mTextToolTipBox->setVisible(false);
return;
}
// this the maximum width of the tooltip before it starts word-wrapping // this the maximum width of the tooltip before it starts word-wrapping
setCoord(0, 0, 300, 300); setCoord(0, 0, 300, 300);
mTextToolTip->setCaption("Focused: " + focus->getName() + "\nType: " + focus->getTypeName()); mTextToolTip->setCaption(text);
const IntSize &textSize = mTextToolTip->getTextSize(); const IntSize &textSize = mTextToolTip->getTextSize();
IntPoint tooltipPosition = InputManager::getInstance().getMousePosition() + IntPoint(0, 24); IntPoint tooltipPosition = InputManager::getInstance().getMousePosition() + IntPoint(0, 24);
IntSize size = textSize + IntSize(12, 12); IntSize size = textSize + IntSize(6, 6);
// make the tooltip stay completely in the viewport // make the tooltip stay completely in the viewport
if ((tooltipPosition.left + size.width) > viewSize.width) if ((tooltipPosition.left + size.width) > viewSize.width)
{ {
@ -62,8 +78,42 @@ void ToolTips::onFrame(float frameDuration)
if (!mFocusObject.isEmpty()) if (!mFocusObject.isEmpty())
{ {
if (mFocusChanged) IntSize tooltipSize = getToolTipViaPtr();
tooltipSize += IntSize(6,6); // padding, adjust for skin
// adjust tooltip size to fit its content, position it above the crosshair
/// \todo Slide the tooltip along the bounding box of the focused object (like in Morrowind)
setCoord(viewSize.width/2 - (tooltipSize.width)/2.f,
viewSize.height/2 - (tooltipSize.height) - 32,
tooltipSize.width,
tooltipSize.height);
}
else
mDynamicToolTipBox->setVisible(false);
}
}
void ToolTips::enterGameMode()
{
mGameMode = true;
}
void ToolTips::enterGuiMode()
{
mGameMode = false;
}
void ToolTips::setFocusObject(const MWWorld::Ptr& focus)
{
mFocusObject = focus;
}
IntSize ToolTips::getToolTipViaPtr ()
{ {
/// \todo we are destroying/creating the tooltip widgets every frame here,
/// because the tooltip might change (e.g. when trap is activated)
/// is there maybe a better way (listener when the object changes)?
for (size_t i=0; i<mDynamicToolTipBox->getChildCount(); ++i) for (size_t i=0; i<mDynamicToolTipBox->getChildCount(); ++i)
{ {
mDynamicToolTipBox->_destroyChildWidget(mDynamicToolTipBox->getChildAt(i)); mDynamicToolTipBox->_destroyChildWidget(mDynamicToolTipBox->getChildAt(i));
@ -74,35 +124,26 @@ void ToolTips::onFrame(float frameDuration)
IntSize tooltipSize; IntSize tooltipSize;
/// \todo Not sure about levelled lists (ESM::CreateLevList and ESM::ItemLevList). I think
/// they are supposed to spawn a concrete object (Creature or item of any type), so
/// the player wouldn't encounter them and we don't have to handle them here.
// -------------------- Door ------------------------------- // -------------------- Door -------------------------------
if (mFocusObject.getTypeName() == typeid(ESM::Door).name()) if (mFocusObject.getTypeName() == typeid(ESM::Door).name())
{ {
ESMS::LiveCellRef<ESM::Door, MWWorld::RefData>* ref = mFocusObject.get<ESM::Door>(); ESMS::LiveCellRef<ESM::Door, MWWorld::RefData>* ref = mFocusObject.get<ESM::Door>();
EditBox* box = mDynamicToolTipBox->createWidget<EditBox>("MW_TextEdit", IntCoord(0, 0, 300, 300), Align::Stretch, "ToolTip"); std::string text;
box->setTextAlign(Align::HCenter);
box->setProperty("Static", "true");
box->setProperty("MultiLine", "true");
std::string caption = ref->base->name;
/// \todo If destCell is empty, the teleport target is an exterior cell. In that case we /// \todo If destCell is empty, the teleport target is an exterior cell. In that case we
/// need to fetch that cell (via target position) and retrieve the region name. /// need to fetch that cell (via target position) and retrieve the region name.
if (ref->ref.teleport && (ref->ref.destCell != "")) if (ref->ref.teleport && (ref->ref.destCell != ""))
{ {
caption += "\n-"; text += "\n" + mWindowManager->getGameSettingString("sTo", "to");
caption += "\n"+ref->ref.destCell; text += "\n"+ref->ref.destCell;
} }
box->setCaption(caption);
/// \todo Lock level, trap (retrieve GMST)
tooltipSize = box->getTextSize() + IntSize(12,12); if (ref->ref.lockLevel > 0)
text += "\n" + mWindowManager->getGameSettingString("sLockLevel", "Lock") + ": " + toString(ref->ref.lockLevel);
if (ref->ref.trap != "")
text += "\n" + mWindowManager->getGameSettingString("sTrapped", "Trapped!");
mDynamicToolTipBox->setVisible(true); tooltipSize = createToolTip(ref->base->name, text);
} }
// -------------------- NPC ------------------------------- // -------------------- NPC -------------------------------
@ -111,48 +152,16 @@ void ToolTips::onFrame(float frameDuration)
/// \todo We don't want tooltips for NPCs in combat mode. /// \todo We don't want tooltips for NPCs in combat mode.
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData>* ref = mFocusObject.get<ESM::NPC>(); ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData>* ref = mFocusObject.get<ESM::NPC>();
EditBox* box = mDynamicToolTipBox->createWidget<EditBox>("MW_TextEdit", IntCoord(0, 0, 300, 300), Align::Stretch, "ToolTip"); tooltipSize = createToolTip(ref->base->name, "");
box->setTextAlign(Align::HCenter);
box->setProperty("Static", "true");
box->setCaption(ref->base->name);
tooltipSize = box->getTextSize() + IntSize(12,12);
mDynamicToolTipBox->setVisible(true);
} }
// -------------------- Creature ------------------------------- // -------------------- Creature -------------------------------
else if (mFocusObject.getTypeName() == typeid(ESM::Creature).name()) else if (mFocusObject.getTypeName() == typeid(ESM::Creature).name())
{ {
/// \todo We don't want tooltips for Creatures in combat mode.
ESMS::LiveCellRef<ESM::Creature, MWWorld::RefData>* ref = mFocusObject.get<ESM::Creature>(); ESMS::LiveCellRef<ESM::Creature, MWWorld::RefData>* ref = mFocusObject.get<ESM::Creature>();
EditBox* box = mDynamicToolTipBox->createWidget<EditBox>("MW_TextEdit", IntCoord(0, 0, 300, 300), Align::Stretch, "ToolTip"); tooltipSize = createToolTip(ref->base->name, "");
box->setTextAlign(Align::HCenter);
box->setProperty("Static", "true");
box->setCaption(ref->base->name);
/// \todo
tooltipSize = box->getTextSize() + IntSize(12,12);
mDynamicToolTipBox->setVisible(true);
}
// -------------------- CreatureLevList -------------------------------
else if (mFocusObject.getTypeName() == typeid(ESM::Creature).name())
{
ESMS::LiveCellRef<ESM::Creature, MWWorld::RefData>* ref = mFocusObject.get<ESM::Creature>();
EditBox* box = mDynamicToolTipBox->createWidget<EditBox>("MW_TextEdit", IntCoord(0, 0, 300, 300), Align::Stretch, "ToolTip");
box->setTextAlign(Align::HCenter);
box->setProperty("Static", "true");
box->setCaption(ref->base->name);
/// \todo
tooltipSize = box->getTextSize() + IntSize(12,12);
mDynamicToolTipBox->setVisible(true);
} }
// -------------------- Container ------------------------------- // -------------------- Container -------------------------------
@ -160,16 +169,14 @@ void ToolTips::onFrame(float frameDuration)
{ {
ESMS::LiveCellRef<ESM::Container, MWWorld::RefData>* ref = mFocusObject.get<ESM::Container>(); ESMS::LiveCellRef<ESM::Container, MWWorld::RefData>* ref = mFocusObject.get<ESM::Container>();
EditBox* box = mDynamicToolTipBox->createWidget<EditBox>("MW_TextEdit", IntCoord(0, 0, 300, 300), Align::Stretch, "ToolTip"); std::string text;
box->setTextAlign(Align::HCenter);
box->setProperty("Static", "true");
box->setCaption(ref->base->name);
/// \todo Lock level, trap (retrieve GMST)
tooltipSize = box->getTextSize() + IntSize(12,12); if (ref->ref.lockLevel > 0)
text += "\n" + mWindowManager->getGameSettingString("sLockLevel", "Lock") + ": " + toString(ref->ref.lockLevel);
if (ref->ref.trap != "")
text += "\n" + mWindowManager->getGameSettingString("sTrapped", "Trapped!");
mDynamicToolTipBox->setVisible(true); tooltipSize = createToolTip(ref->base->name, text);
} }
// -------------------- Potion ------------------------------- // -------------------- Potion -------------------------------
@ -177,33 +184,25 @@ void ToolTips::onFrame(float frameDuration)
{ {
ESMS::LiveCellRef<ESM::Potion, MWWorld::RefData>* ref = mFocusObject.get<ESM::Potion>(); ESMS::LiveCellRef<ESM::Potion, MWWorld::RefData>* ref = mFocusObject.get<ESM::Potion>();
EditBox* box = mDynamicToolTipBox->createWidget<EditBox>("MW_TextEdit", IntCoord(0, 0, 300, 300), Align::Stretch, "ToolTip"); /// \todo magic effects
box->setTextAlign(Align::HCenter); std::string text;
box->setProperty("Static", "true"); text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight);
box->setCaption(ref->base->name); text += getValueString(ref->base->data.value);
/// \todo
tooltipSize = box->getTextSize() + IntSize(12,12);
mDynamicToolTipBox->setVisible(true); tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, text);
} }
// -------------------- Apparatus ------------------------------- // -------------------- Apparatus -------------------------------
else if (mFocusObject.getTypeName() == typeid(ESM::Apparatus).name()) else if (mFocusObject.getTypeName() == typeid(ESM::Apparatus).name())
{ {
ESMS::LiveCellRef<ESM::Potion, MWWorld::RefData>* ref = mFocusObject.get<ESM::Potion>(); ESMS::LiveCellRef<ESM::Apparatus, MWWorld::RefData>* ref = mFocusObject.get<ESM::Apparatus>();
EditBox* box = mDynamicToolTipBox->createWidget<EditBox>("MW_TextEdit", IntCoord(0, 0, 300, 300), Align::Stretch, "ToolTip");
box->setTextAlign(Align::HCenter);
box->setProperty("Static", "true");
box->setCaption(ref->base->name);
/// \todo
tooltipSize = box->getTextSize() + IntSize(12,12); std::string text;
text += "\n" + mWindowManager->getGameSettingString("sQuality", "Quality") + ": " + toString(ref->base->data.quality);
text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight);
text += getValueString(ref->base->data.value);
mDynamicToolTipBox->setVisible(true); tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, text);
} }
// -------------------- Armor ------------------------------- // -------------------- Armor -------------------------------
@ -211,16 +210,16 @@ void ToolTips::onFrame(float frameDuration)
{ {
ESMS::LiveCellRef<ESM::Armor, MWWorld::RefData>* ref = mFocusObject.get<ESM::Armor>(); ESMS::LiveCellRef<ESM::Armor, MWWorld::RefData>* ref = mFocusObject.get<ESM::Armor>();
EditBox* box = mDynamicToolTipBox->createWidget<EditBox>("MW_TextEdit", IntCoord(0, 0, 300, 300), Align::Stretch, "ToolTip"); /// \todo magic effects, armor type (medium/light/heavy)
box->setTextAlign(Align::HCenter); std::string text;
box->setProperty("Static", "true"); text += "\n" + mWindowManager->getGameSettingString("sArmorRating", "Armor Rating") + ": " + toString(ref->base->data.armor);
box->setCaption(ref->base->name);
/// \todo weight, armor value, value, durability.. /// \todo where is the current armor health stored?
//text += "\n" + mWindowManager->getGameSettingString("sCondition", "Condition") + ": " + toString(ref->base->data.health);
text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight);
text += getValueString(ref->base->data.value);
tooltipSize = box->getTextSize() + IntSize(12,12); tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, text);
mDynamicToolTipBox->setVisible(true);
} }
// -------------------- Book ------------------------------- // -------------------- Book -------------------------------
@ -228,16 +227,11 @@ void ToolTips::onFrame(float frameDuration)
{ {
ESMS::LiveCellRef<ESM::Book, MWWorld::RefData>* ref = mFocusObject.get<ESM::Book>(); ESMS::LiveCellRef<ESM::Book, MWWorld::RefData>* ref = mFocusObject.get<ESM::Book>();
EditBox* box = mDynamicToolTipBox->createWidget<EditBox>("MW_TextEdit", IntCoord(0, 0, 300, 300), Align::Stretch, "ToolTip"); std::string text;
box->setTextAlign(Align::HCenter); text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight);
box->setProperty("Static", "true"); text += getValueString(ref->base->data.value);
box->setCaption(ref->base->name);
/// \todo
tooltipSize = box->getTextSize() + IntSize(12,12);
mDynamicToolTipBox->setVisible(true); tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, text);
} }
// -------------------- Clothing ------------------------------- // -------------------- Clothing -------------------------------
@ -245,16 +239,12 @@ void ToolTips::onFrame(float frameDuration)
{ {
ESMS::LiveCellRef<ESM::Clothing, MWWorld::RefData>* ref = mFocusObject.get<ESM::Clothing>(); ESMS::LiveCellRef<ESM::Clothing, MWWorld::RefData>* ref = mFocusObject.get<ESM::Clothing>();
EditBox* box = mDynamicToolTipBox->createWidget<EditBox>("MW_TextEdit", IntCoord(0, 0, 300, 300), Align::Stretch, "ToolTip"); /// \todo magic effects
box->setTextAlign(Align::HCenter); std::string text;
box->setProperty("Static", "true"); text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight);
box->setCaption(ref->base->name); text += getValueString(ref->base->data.value);
/// \todo
tooltipSize = box->getTextSize() + IntSize(12,12);
mDynamicToolTipBox->setVisible(true); tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, text);
} }
// -------------------- Ingredient ------------------------------- // -------------------- Ingredient -------------------------------
@ -262,16 +252,12 @@ void ToolTips::onFrame(float frameDuration)
{ {
ESMS::LiveCellRef<ESM::Ingredient, MWWorld::RefData>* ref = mFocusObject.get<ESM::Ingredient>(); ESMS::LiveCellRef<ESM::Ingredient, MWWorld::RefData>* ref = mFocusObject.get<ESM::Ingredient>();
EditBox* box = mDynamicToolTipBox->createWidget<EditBox>("MW_TextEdit", IntCoord(0, 0, 300, 300), Align::Stretch, "ToolTip"); /// \todo magic effects
box->setTextAlign(Align::HCenter); std::string text;
box->setProperty("Static", "true"); text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight);
box->setCaption(ref->base->name); text += getValueString(ref->base->data.value);
/// \todo
tooltipSize = box->getTextSize() + IntSize(12,12); tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, text);
mDynamicToolTipBox->setVisible(true);
} }
// -------------------- Light ------------------------------- // -------------------- Light -------------------------------
@ -279,16 +265,11 @@ void ToolTips::onFrame(float frameDuration)
{ {
ESMS::LiveCellRef<ESM::Light, MWWorld::RefData>* ref = mFocusObject.get<ESM::Light>(); ESMS::LiveCellRef<ESM::Light, MWWorld::RefData>* ref = mFocusObject.get<ESM::Light>();
EditBox* box = mDynamicToolTipBox->createWidget<EditBox>("MW_TextEdit", IntCoord(0, 0, 300, 300), Align::Stretch, "ToolTip"); std::string text;
box->setTextAlign(Align::HCenter); text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight);
box->setProperty("Static", "true"); text += getValueString(ref->base->data.value);
box->setCaption(ref->base->name);
/// \todo
tooltipSize = box->getTextSize() + IntSize(12,12);
mDynamicToolTipBox->setVisible(ref->base->name != ""); tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, text);
} }
// -------------------- Tool ------------------------------- // -------------------- Tool -------------------------------
@ -296,16 +277,13 @@ void ToolTips::onFrame(float frameDuration)
{ {
ESMS::LiveCellRef<ESM::Tool, MWWorld::RefData>* ref = mFocusObject.get<ESM::Tool>(); ESMS::LiveCellRef<ESM::Tool, MWWorld::RefData>* ref = mFocusObject.get<ESM::Tool>();
EditBox* box = mDynamicToolTipBox->createWidget<EditBox>("MW_TextEdit", IntCoord(0, 0, 300, 300), Align::Stretch, "ToolTip"); std::string text;
box->setTextAlign(Align::HCenter); text += "\n" + mWindowManager->getGameSettingString("sUses", "Uses") + ": " + toString(ref->base->data.uses);
box->setProperty("Static", "true"); text += "\n" + mWindowManager->getGameSettingString("sQuality", "Quality") + ": " + toString(ref->base->data.quality);
box->setCaption(ref->base->name); text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight);
text += getValueString(ref->base->data.value);
/// \todo
tooltipSize = box->getTextSize() + IntSize(12,12); tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, text);
mDynamicToolTipBox->setVisible(true);
} }
// -------------------- Miscellaneous ------------------------------- // -------------------- Miscellaneous -------------------------------
@ -313,16 +291,11 @@ void ToolTips::onFrame(float frameDuration)
{ {
ESMS::LiveCellRef<ESM::Miscellaneous, MWWorld::RefData>* ref = mFocusObject.get<ESM::Miscellaneous>(); ESMS::LiveCellRef<ESM::Miscellaneous, MWWorld::RefData>* ref = mFocusObject.get<ESM::Miscellaneous>();
EditBox* box = mDynamicToolTipBox->createWidget<EditBox>("MW_TextEdit", IntCoord(0, 0, 300, 300), Align::Stretch, "ToolTip"); std::string text;
box->setTextAlign(Align::HCenter); text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight);
box->setProperty("Static", "true"); text += getValueString(ref->base->data.value);
box->setCaption(ref->base->name);
/// \todo
tooltipSize = box->getTextSize() + IntSize(12,12);
mDynamicToolTipBox->setVisible(true); tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, text);
} }
// -------------------- Probe ------------------------------- // -------------------- Probe -------------------------------
@ -330,16 +303,13 @@ void ToolTips::onFrame(float frameDuration)
{ {
ESMS::LiveCellRef<ESM::Probe, MWWorld::RefData>* ref = mFocusObject.get<ESM::Probe>(); ESMS::LiveCellRef<ESM::Probe, MWWorld::RefData>* ref = mFocusObject.get<ESM::Probe>();
EditBox* box = mDynamicToolTipBox->createWidget<EditBox>("MW_TextEdit", IntCoord(0, 0, 300, 300), Align::Stretch, "ToolTip"); std::string text;
box->setTextAlign(Align::HCenter); text += "\n" + mWindowManager->getGameSettingString("sUses", "Uses") + ": " + toString(ref->base->data.uses);
box->setProperty("Static", "true"); text += "\n" + mWindowManager->getGameSettingString("sQuality", "Quality") + ": " + toString(ref->base->data.quality);
box->setCaption(ref->base->name); text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight);
text += getValueString(ref->base->data.value);
/// \todo
tooltipSize = box->getTextSize() + IntSize(12,12);
mDynamicToolTipBox->setVisible(true); tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, text);
} }
// -------------------- Repair ------------------------------- // -------------------- Repair -------------------------------
@ -347,16 +317,13 @@ void ToolTips::onFrame(float frameDuration)
{ {
ESMS::LiveCellRef<ESM::Repair, MWWorld::RefData>* ref = mFocusObject.get<ESM::Repair>(); ESMS::LiveCellRef<ESM::Repair, MWWorld::RefData>* ref = mFocusObject.get<ESM::Repair>();
EditBox* box = mDynamicToolTipBox->createWidget<EditBox>("MW_TextEdit", IntCoord(0, 0, 300, 300), Align::Stretch, "ToolTip"); std::string text;
box->setTextAlign(Align::HCenter); text += "\n" + mWindowManager->getGameSettingString("sUses", "Uses") + ": " + toString(ref->base->data.uses);
box->setProperty("Static", "true"); text += "\n" + mWindowManager->getGameSettingString("sQuality", "Quality") + ": " + toString(ref->base->data.quality);
box->setCaption(ref->base->name); text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight);
text += getValueString(ref->base->data.value);
/// \todo
tooltipSize = box->getTextSize() + IntSize(12,12); tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, text);
mDynamicToolTipBox->setVisible(true);
} }
// -------------------- Weapon ------------------------------- // -------------------- Weapon -------------------------------
@ -364,16 +331,13 @@ void ToolTips::onFrame(float frameDuration)
{ {
ESMS::LiveCellRef<ESM::Weapon, MWWorld::RefData>* ref = mFocusObject.get<ESM::Weapon>(); ESMS::LiveCellRef<ESM::Weapon, MWWorld::RefData>* ref = mFocusObject.get<ESM::Weapon>();
EditBox* box = mDynamicToolTipBox->createWidget<EditBox>("MW_TextEdit", IntCoord(0, 0, 300, 300), Align::Stretch, "ToolTip"); /// \todo weapon damage, magic effects, health (condition)
box->setTextAlign(Align::HCenter);
box->setProperty("Static", "true");
box->setCaption(ref->base->name);
/// \todo std::string text;
text += "\n" + mWindowManager->getGameSettingString("sWeight", "Weight") + ": " + toString(ref->base->data.weight);
text += getValueString(ref->base->data.value);
tooltipSize = box->getTextSize() + IntSize(12,12); tooltipSize = createImageToolTip(ref->base->name, ref->base->icon, "");
mDynamicToolTipBox->setVisible(true);
} }
// -------------------- Activator ------------------------------- // -------------------- Activator -------------------------------
@ -381,16 +345,7 @@ void ToolTips::onFrame(float frameDuration)
{ {
ESMS::LiveCellRef<ESM::Activator, MWWorld::RefData>* ref = mFocusObject.get<ESM::Activator>(); ESMS::LiveCellRef<ESM::Activator, MWWorld::RefData>* ref = mFocusObject.get<ESM::Activator>();
EditBox* box = mDynamicToolTipBox->createWidget<EditBox>("MW_TextEdit", IntCoord(0, 0, 300, 300), Align::Stretch, "ToolTip"); tooltipSize = createToolTip(ref->base->name, "");
box->setTextAlign(Align::HCenter);
box->setProperty("Static", "true");
box->setCaption(ref->base->name);
/// \todo
tooltipSize = box->getTextSize() + IntSize(12,12);
mDynamicToolTipBox->setVisible(ref->base->name != "");
} }
else else
@ -399,35 +354,98 @@ void ToolTips::onFrame(float frameDuration)
mDynamicToolTipBox->setVisible(false); mDynamicToolTipBox->setVisible(false);
} }
// adjust tooltip size to fit its content, position it above the crosshair return tooltipSize;
/// \todo Slide the tooltip along the bounding box of the focused object (like in Morrowind)
setCoord(viewSize.width/2 - (tooltipSize.width)/2.f,
viewSize.height/2 - (tooltipSize.height) - 32,
tooltipSize.width,
tooltipSize.height);
}
mFocusChanged = false;
} }
else
mDynamicToolTipBox->setVisible(false); void ToolTips::findImageExtension(std::string& image)
{
int len = image.size();
if (len < 4) return;
if (!Ogre::ResourceGroupManager::getSingleton().resourceExists(Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME, image))
{
// Change texture extension to .dds
image[len-3] = 'd';
image[len-2] = 'd';
image[len-1] = 's';
} }
} }
void ToolTips::enterGameMode() IntSize ToolTips::createImageToolTip(const std::string& caption, const std::string& image, const std::string& text)
{ {
mGameMode = true; // remove the first newline (easier this way)
std::string realText = text;
if (realText.size() > 0)
realText.erase(0, 1);
std::string realImage = "icons\\" + image;
findImageExtension(realImage);
const int imageSize = 32;
EditBox* captionWidget = mDynamicToolTipBox->createWidget<EditBox>("NormalText", IntCoord(0, 0, 300, 300), Align::Left | Align::Top, "ToolTipCaption");
captionWidget->setProperty("Static", "true");
captionWidget->setCaption(caption);
EditBox* textWidget = mDynamicToolTipBox->createWidget<EditBox>("SandText", IntCoord(0, imageSize, 300, 262), Align::Stretch, "ToolTipText");
textWidget->setProperty("Static", "true");
textWidget->setProperty("MultiLine", "true");
textWidget->setCaption(realText);
textWidget->setTextAlign(Align::HCenter);
IntSize captionSize = captionWidget->getTextSize();
IntSize textSize = textWidget->getTextSize();
captionSize += IntSize(imageSize, 0); // adjust for image
IntSize totalSize = IntSize( std::max(textSize.width, captionSize.width), ((realText != "") ? textSize.height : 0) + imageSize );
ImageBox* imageWidget = mDynamicToolTipBox->createWidget<ImageBox>("ImageBox",
IntCoord((totalSize.width - captionSize.width)/2, 0, imageSize, imageSize),
Align::Left | Align::Top, "ToolTipImage");
imageWidget->setImageTexture(realImage);
captionWidget->setCoord( (totalSize.width - captionSize.width)/2 + imageSize, (32-captionSize.height)/2, captionSize.width-imageSize, captionSize.height);
mDynamicToolTipBox->setVisible(caption != "");
return totalSize;
} }
void ToolTips::enterGuiMode() IntSize ToolTips::createToolTip(const std::string& caption, const std::string& text)
{ {
mGameMode = false; // remove the first newline (easier this way)
std::string realText = text;
if (realText.size() > 0)
realText.erase(0, 1);
EditBox* box = mDynamicToolTipBox->createWidget<EditBox>("NormalText", IntCoord(0, 0, 300, 300), Align::Stretch, "ToolTip");
box->setTextAlign(Align::HCenter);
box->setProperty("Static", "true");
box->setProperty("MultiLine", "true");
box->setCaption(caption + (realText != "" ? "\n#BF9959" + realText : ""));
mDynamicToolTipBox->setVisible(caption != "");
return box->getTextSize();
} }
void ToolTips::setFocusObject(const MWWorld::Ptr& focus) std::string ToolTips::toString(const float value)
{ {
if (focus != mFocusObject) std::ostringstream stream;
stream << std::setprecision(3) << value;
return stream.str();
}
std::string ToolTips::toString(const int value)
{ {
mFocusObject = focus; std::ostringstream stream;
mFocusChanged = true; stream << value;
return stream.str();
} }
std::string ToolTips::getValueString(const int value)
{
if (value == 0)
return "";
else
return "\n" + mWindowManager->getGameSettingString("sValue", "Value") + ": " + toString(value);
} }

@ -7,10 +7,12 @@
namespace MWGui namespace MWGui
{ {
class WindowManager;
class ToolTips : public OEngine::GUI::Layout class ToolTips : public OEngine::GUI::Layout
{ {
public: public:
ToolTips(); ToolTips(WindowManager* windowManager);
void onFrame(float frameDuration); void onFrame(float frameDuration);
@ -27,8 +29,26 @@ namespace MWGui
MyGUI::Widget* mDynamicToolTipBox; MyGUI::Widget* mDynamicToolTipBox;
WindowManager* mWindowManager;
MWWorld::Ptr mFocusObject; MWWorld::Ptr mFocusObject;
bool mFocusChanged;
void findImageExtension(std::string& image);
MyGUI::IntSize getToolTipViaPtr ();
///< @return requested tooltip size
MyGUI::IntSize createImageToolTip(const std::string& caption, const std::string& image, const std::string& text);
///< @return requested tooltip size
MyGUI::IntSize createToolTip(const std::string& caption, const std::string& text);
///< @return requested tooltip size
std::string getValueString(const int value);
///< get "Value: X" string or "" if value is 0
std::string toString(const float value);
std::string toString(const int value);
bool mGameMode; bool mGameMode;
}; };

@ -82,7 +82,7 @@ WindowManager::WindowManager(MWWorld::Environment& environment,
mJournal = new JournalWindow(*this); mJournal = new JournalWindow(*this);
mMessageBoxManager = new MessageBoxManager(this); mMessageBoxManager = new MessageBoxManager(this);
dialogueWindow = new DialogueWindow(*this,environment); dialogueWindow = new DialogueWindow(*this,environment);
mToolTips = new ToolTips(); mToolTips = new ToolTips(this);
// The HUD is always on // The HUD is always on
hud->setVisible(true); hud->setVisible(true);

@ -6,7 +6,7 @@
<!-- Simple text-only tooltip --> <!-- Simple text-only tooltip -->
<Widget type="Widget" skin="HUD_Box" position="0 0 300 300" align="Stretch" name="TextToolTipBox"> <Widget type="Widget" skin="HUD_Box" position="0 0 300 300" align="Stretch" name="TextToolTipBox">
<Property key="Visible" value="false"/> <Property key="Visible" value="false"/>
<Widget type="EditBox" skin="MW_TextEdit" position="0 0 300 300" align="Stretch" name="TextToolTip"> <Widget type="EditBox" skin="NormalText" position="0 0 300 300" align="Stretch" name="TextToolTip">
<Property key="WordWrap" value="true"/> <Property key="WordWrap" value="true"/>
<Property key="Static" value="true"/> <Property key="Static" value="true"/>
<Property key="TextAlign" value="Left Top"/> <Property key="TextAlign" value="Left Top"/>

Loading…
Cancel
Save