forked from mirror/openmw-tes3mp
Merge branch 'master' of https://github.com/zinnschlag/openmw.git into inventoryGUI
Conflicts: apps/openmw/CMakeLists.txt apps/openmw/mwclass/apparatus.cpp apps/openmw/mwclass/armor.cpp apps/openmw/mwclass/book.cpp apps/openmw/mwclass/clothing.cpp apps/openmw/mwclass/container.cpp apps/openmw/mwclass/ingredient.cpp apps/openmw/mwclass/light.cpp apps/openmw/mwclass/lockpick.cpp apps/openmw/mwclass/misc.cpp apps/openmw/mwclass/potion.cpp apps/openmw/mwclass/probe.cpp apps/openmw/mwclass/repair.cpp apps/openmw/mwclass/weapon.cpp apps/openmw/mwgui/window_manager.cpp apps/openmw/mwgui/window_manager.hpp apps/openmw/mwworld/class.cppactorid
commit
8e8f80807e
@ -0,0 +1,161 @@
|
||||
|
||||
#include "environment.hpp"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include "../mwinput/inputmanager.hpp"
|
||||
|
||||
#include "../mwscript/scriptmanager.hpp"
|
||||
|
||||
#include "../mwsound/soundmanager.hpp"
|
||||
|
||||
#include "../mwworld/world.hpp"
|
||||
|
||||
#include "../mwdialogue/dialoguemanager.hpp"
|
||||
#include "../mwdialogue/journal.hpp"
|
||||
|
||||
#include "../mwmechanics/mechanicsmanager.hpp"
|
||||
|
||||
MWBase::Environment *MWBase::Environment::sThis = 0;
|
||||
|
||||
MWBase::Environment::Environment()
|
||||
: mWorld (0), mSoundManager (0), mScriptManager (0), mWindowManager (0),
|
||||
mMechanicsManager (0), mDialogueManager (0), mJournal (0), mInputManager (0), mFrameDuration (0)
|
||||
{
|
||||
assert (!sThis);
|
||||
sThis = this;
|
||||
}
|
||||
|
||||
MWBase::Environment::~Environment()
|
||||
{
|
||||
cleanup();
|
||||
sThis = 0;
|
||||
}
|
||||
|
||||
void MWBase::Environment::setWorld (MWWorld::World *world)
|
||||
{
|
||||
mWorld = world;
|
||||
}
|
||||
|
||||
void MWBase::Environment::setSoundManager (MWSound::SoundManager *soundManager)
|
||||
{
|
||||
mSoundManager = soundManager;
|
||||
}
|
||||
|
||||
void MWBase::Environment::setScriptManager (MWScript::ScriptManager *scriptManager)
|
||||
{
|
||||
mScriptManager = scriptManager;
|
||||
}
|
||||
|
||||
void MWBase::Environment::setWindowManager (MWGui::WindowManager *windowManager)
|
||||
{
|
||||
mWindowManager = windowManager;
|
||||
}
|
||||
|
||||
void MWBase::Environment::setMechanicsManager (MWMechanics::MechanicsManager *mechanicsManager)
|
||||
{
|
||||
mMechanicsManager = mechanicsManager;
|
||||
}
|
||||
|
||||
void MWBase::Environment::setDialogueManager (MWDialogue::DialogueManager *dialogueManager)
|
||||
{
|
||||
mDialogueManager = dialogueManager;
|
||||
}
|
||||
|
||||
void MWBase::Environment::setJournal (MWDialogue::Journal *journal)
|
||||
{
|
||||
mJournal = journal;
|
||||
}
|
||||
|
||||
void MWBase::Environment::setInputManager (MWInput::MWInputManager *inputManager)
|
||||
{
|
||||
mInputManager = inputManager;
|
||||
}
|
||||
|
||||
void MWBase::Environment::setFrameDuration (float duration)
|
||||
{
|
||||
mFrameDuration = duration;
|
||||
}
|
||||
|
||||
MWWorld::World *MWBase::Environment::getWorld() const
|
||||
{
|
||||
assert (mWorld);
|
||||
return mWorld;
|
||||
}
|
||||
|
||||
MWSound::SoundManager *MWBase::Environment::getSoundManager() const
|
||||
{
|
||||
assert (mSoundManager);
|
||||
return mSoundManager;
|
||||
}
|
||||
|
||||
MWScript::ScriptManager *MWBase::Environment::getScriptManager() const
|
||||
{
|
||||
assert (mScriptManager);
|
||||
return mScriptManager;
|
||||
}
|
||||
|
||||
MWGui::WindowManager *MWBase::Environment::getWindowManager() const
|
||||
{
|
||||
assert (mWindowManager);
|
||||
return mWindowManager;
|
||||
}
|
||||
|
||||
MWMechanics::MechanicsManager *MWBase::Environment::getMechanicsManager() const
|
||||
{
|
||||
assert (mMechanicsManager);
|
||||
return mMechanicsManager;
|
||||
}
|
||||
|
||||
MWDialogue::DialogueManager *MWBase::Environment::getDialogueManager() const
|
||||
{
|
||||
assert (mDialogueManager);
|
||||
return mDialogueManager;
|
||||
}
|
||||
|
||||
MWDialogue::Journal *MWBase::Environment::getJournal() const
|
||||
{
|
||||
assert (mJournal);
|
||||
return mJournal;
|
||||
}
|
||||
|
||||
MWInput::MWInputManager *MWBase::Environment::getInputManager() const
|
||||
{
|
||||
assert (mInputManager);
|
||||
return mInputManager;
|
||||
}
|
||||
|
||||
float MWBase::Environment::getFrameDuration() const
|
||||
{
|
||||
return mFrameDuration;
|
||||
}
|
||||
|
||||
void MWBase::Environment::cleanup()
|
||||
{
|
||||
delete mInputManager;
|
||||
mInputManager = 0;
|
||||
|
||||
delete mSoundManager;
|
||||
mSoundManager = 0;
|
||||
|
||||
delete mMechanicsManager;
|
||||
mMechanicsManager = 0;
|
||||
|
||||
delete mDialogueManager;
|
||||
mDialogueManager = 0;
|
||||
|
||||
delete mJournal;
|
||||
mJournal = 0;
|
||||
|
||||
delete mScriptManager;
|
||||
mScriptManager = 0;
|
||||
|
||||
delete mWorld;
|
||||
mWorld = 0;
|
||||
}
|
||||
|
||||
const MWBase::Environment& MWBase::Environment::get()
|
||||
{
|
||||
assert (sThis);
|
||||
return *sThis;
|
||||
}
|
@ -0,0 +1,119 @@
|
||||
#ifndef GAME_BASE_INVIRONMENT_H
|
||||
#define GAME_BASE_INVIRONMENT_H
|
||||
|
||||
namespace MWSound
|
||||
{
|
||||
class SoundManager;
|
||||
}
|
||||
|
||||
namespace MWScript
|
||||
{
|
||||
class ScriptManager;
|
||||
}
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
class WindowManager;
|
||||
}
|
||||
|
||||
namespace MWMechanics
|
||||
{
|
||||
class MechanicsManager;
|
||||
}
|
||||
|
||||
namespace MWDialogue
|
||||
{
|
||||
class DialogueManager;
|
||||
class Journal;
|
||||
}
|
||||
|
||||
namespace MWInput
|
||||
{
|
||||
struct MWInputManager;
|
||||
}
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
class World;
|
||||
}
|
||||
|
||||
namespace MWBase
|
||||
{
|
||||
/// \brief Central hub for mw-subsystems
|
||||
///
|
||||
/// This class allows each mw-subsystem to access any others subsystem's top-level manager class.
|
||||
///
|
||||
/// \attention Environment takes ownership of the manager class instances it is handed over in
|
||||
/// the set* functions.
|
||||
class Environment
|
||||
{
|
||||
static Environment *sThis;
|
||||
|
||||
MWWorld::World *mWorld;
|
||||
MWSound::SoundManager *mSoundManager;
|
||||
MWScript::ScriptManager *mScriptManager;
|
||||
MWGui::WindowManager *mWindowManager;
|
||||
MWMechanics::MechanicsManager *mMechanicsManager;
|
||||
MWDialogue::DialogueManager *mDialogueManager;
|
||||
MWDialogue::Journal *mJournal;
|
||||
MWInput::MWInputManager *mInputManager;
|
||||
float mFrameDuration;
|
||||
|
||||
Environment (const Environment&);
|
||||
///< not implemented
|
||||
|
||||
Environment& operator= (const Environment&);
|
||||
///< not implemented
|
||||
|
||||
public:
|
||||
|
||||
Environment();
|
||||
|
||||
~Environment();
|
||||
|
||||
void setWorld (MWWorld::World *world);
|
||||
|
||||
void setSoundManager (MWSound::SoundManager *soundManager);
|
||||
|
||||
void setScriptManager (MWScript::ScriptManager *scriptManager);
|
||||
|
||||
void setWindowManager (MWGui::WindowManager *windowManager);
|
||||
|
||||
void setMechanicsManager (MWMechanics::MechanicsManager *mechanicsManager);
|
||||
|
||||
void setDialogueManager (MWDialogue::DialogueManager *dialogueManager);
|
||||
|
||||
void setJournal (MWDialogue::Journal *journal);
|
||||
|
||||
void setInputManager (MWInput::MWInputManager *inputManager);
|
||||
|
||||
void setFrameDuration (float duration);
|
||||
///< Set length of current frame in seconds.
|
||||
|
||||
MWWorld::World *getWorld() const;
|
||||
|
||||
MWSound::SoundManager *getSoundManager() const;
|
||||
|
||||
MWScript::ScriptManager *getScriptManager() const;
|
||||
|
||||
MWGui::WindowManager *getWindowManager() const;
|
||||
|
||||
MWMechanics::MechanicsManager *getMechanicsManager() const;
|
||||
|
||||
MWDialogue::DialogueManager *getDialogueManager() const;
|
||||
|
||||
MWDialogue::Journal *getJournal() const;
|
||||
|
||||
MWInput::MWInputManager *getInputManager() const;
|
||||
|
||||
float getFrameDuration() const;
|
||||
|
||||
void cleanup();
|
||||
///< Delete all mw*-subsystems.
|
||||
|
||||
static const Environment& get();
|
||||
///< Return instance of this class.
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,361 @@
|
||||
#include "tooltips.hpp"
|
||||
|
||||
#include "window_manager.hpp"
|
||||
#include "widgets.hpp"
|
||||
#include "../mwworld/class.hpp"
|
||||
#include "../mwworld/world.hpp"
|
||||
#include "../mwbase/environment.hpp"
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
using namespace MWGui;
|
||||
using namespace MyGUI;
|
||||
|
||||
ToolTips::ToolTips(WindowManager* windowManager) :
|
||||
Layout("openmw_tooltips.xml")
|
||||
, mGameMode(true)
|
||||
, mWindowManager(windowManager)
|
||||
, mFullHelp(false)
|
||||
{
|
||||
getWidget(mDynamicToolTipBox, "DynamicToolTipBox");
|
||||
|
||||
mDynamicToolTipBox->setVisible(false);
|
||||
|
||||
// turn off mouse focus so that getMouseFocusWidget returns the correct widget,
|
||||
// even if the mouse is over the tooltip
|
||||
mDynamicToolTipBox->setNeedMouseFocus(false);
|
||||
mMainWidget->setNeedMouseFocus(false);
|
||||
}
|
||||
|
||||
void ToolTips::onFrame(float frameDuration)
|
||||
{
|
||||
/// \todo Store a MWWorld::Ptr in the widget user data, retrieve it here and construct a tooltip dynamically
|
||||
|
||||
MyGUI::Gui::getInstance().destroyWidget(mDynamicToolTipBox);
|
||||
mDynamicToolTipBox = mMainWidget->createWidget<Widget>("HUD_Box",
|
||||
IntCoord(0, 0, mMainWidget->getCoord().width, mMainWidget->getCoord().height),
|
||||
Align::Stretch, "DynamicToolTipBox");
|
||||
|
||||
const IntSize &viewSize = RenderManager::getInstance().getViewSize();
|
||||
|
||||
if (!mGameMode)
|
||||
{
|
||||
Widget* focus = InputManager::getInstance().getMouseFocusWidget();
|
||||
if (focus == 0)
|
||||
{
|
||||
mDynamicToolTipBox->setVisible(false);
|
||||
return;
|
||||
}
|
||||
|
||||
IntSize tooltipSize;
|
||||
|
||||
std::string type = focus->getUserString("ToolTipType");
|
||||
std::string text = focus->getUserString("ToolTipText");
|
||||
|
||||
ToolTipInfo info;
|
||||
if (type == "")
|
||||
{
|
||||
mDynamicToolTipBox->setVisible(false);
|
||||
return;
|
||||
}
|
||||
else if (type == "Text")
|
||||
{
|
||||
info.text = text;
|
||||
}
|
||||
else if (type == "CaptionText")
|
||||
{
|
||||
std::string caption = focus->getUserString("ToolTipCaption");
|
||||
info.caption = caption;
|
||||
info.text = text;
|
||||
}
|
||||
else if (type == "ImageCaptionText")
|
||||
{
|
||||
std::string caption = focus->getUserString("ToolTipCaption");
|
||||
std::string image = focus->getUserString("ToolTipImage");
|
||||
std::string sizeString = focus->getUserString("ToolTipImageSize");
|
||||
|
||||
info.text = text;
|
||||
info.caption = caption;
|
||||
info.icon = image;
|
||||
}
|
||||
tooltipSize = createToolTip(info);
|
||||
|
||||
IntPoint tooltipPosition = InputManager::getInstance().getMousePosition() + IntPoint(0, 24);
|
||||
|
||||
// make the tooltip stay completely in the viewport
|
||||
if ((tooltipPosition.left + tooltipSize.width) > viewSize.width)
|
||||
{
|
||||
tooltipPosition.left = viewSize.width - tooltipSize.width;
|
||||
}
|
||||
if ((tooltipPosition.top + tooltipSize.height) > viewSize.height)
|
||||
{
|
||||
tooltipPosition.top = viewSize.height - tooltipSize.height;
|
||||
}
|
||||
|
||||
setCoord(tooltipPosition.left, tooltipPosition.top, tooltipSize.width, tooltipSize.height);
|
||||
mDynamicToolTipBox->setVisible(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!mFocusObject.isEmpty())
|
||||
{
|
||||
IntSize tooltipSize = getToolTipViaPtr();
|
||||
|
||||
// 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 ()
|
||||
{
|
||||
// this the maximum width of the tooltip before it starts word-wrapping
|
||||
setCoord(0, 0, 300, 300);
|
||||
|
||||
IntSize tooltipSize;
|
||||
|
||||
const MWWorld::Class& object = MWWorld::Class::get (mFocusObject);
|
||||
if (!object.hasToolTip(mFocusObject))
|
||||
{
|
||||
mDynamicToolTipBox->setVisible(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
mDynamicToolTipBox->setVisible(true);
|
||||
|
||||
ToolTipInfo info = object.getToolTipInfo(mFocusObject);
|
||||
tooltipSize = createToolTip(info);
|
||||
}
|
||||
|
||||
return tooltipSize;
|
||||
}
|
||||
|
||||
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';
|
||||
}
|
||||
}
|
||||
|
||||
IntSize ToolTips::createToolTip(const ToolTipInfo& info)
|
||||
{
|
||||
std::string caption = info.caption;
|
||||
std::string image = info.icon;
|
||||
int imageSize = (image != "") ? 32 : 0;
|
||||
std::string text = info.text;
|
||||
|
||||
// remove the first newline (easier this way)
|
||||
if (text.size() > 0 && text[0] == '\n')
|
||||
text.erase(0, 1);
|
||||
|
||||
const ESM::Enchantment* enchant;
|
||||
const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
|
||||
if (info.enchant != "")
|
||||
{
|
||||
enchant = store.enchants.search(info.enchant);
|
||||
if (enchant->data.type == ESM::Enchantment::CastOnce)
|
||||
text += "\n" + store.gameSettings.search("sItemCastOnce")->str;
|
||||
else if (enchant->data.type == ESM::Enchantment::WhenStrikes)
|
||||
text += "\n" + store.gameSettings.search("sItemCastWhenStrikes")->str;
|
||||
else if (enchant->data.type == ESM::Enchantment::WhenUsed)
|
||||
text += "\n" + store.gameSettings.search("sItemCastWhenUsed")->str;
|
||||
else if (enchant->data.type == ESM::Enchantment::ConstantEffect)
|
||||
text += "\n" + store.gameSettings.search("sItemCastConstant")->str;
|
||||
}
|
||||
|
||||
// this the maximum width of the tooltip before it starts word-wrapping
|
||||
setCoord(0, 0, 300, 300);
|
||||
|
||||
const IntPoint padding(8, 8);
|
||||
|
||||
const int imageCaptionHPadding = (caption != "" ? 8 : 0);
|
||||
const int imageCaptionVPadding = (caption != "" ? 4 : 0);
|
||||
|
||||
std::string realImage = "icons\\" + image;
|
||||
findImageExtension(realImage);
|
||||
|
||||
EditBox* captionWidget = mDynamicToolTipBox->createWidget<EditBox>("NormalText", IntCoord(0, 0, 300, 300), Align::Left | Align::Top, "ToolTipCaption");
|
||||
captionWidget->setProperty("Static", "true");
|
||||
captionWidget->setCaption(caption);
|
||||
IntSize captionSize = captionWidget->getTextSize();
|
||||
|
||||
int captionHeight = std::max(caption != "" ? captionSize.height : 0, imageSize);
|
||||
|
||||
EditBox* textWidget = mDynamicToolTipBox->createWidget<EditBox>("SandText", IntCoord(0, captionHeight+imageCaptionVPadding, 300, 300-captionHeight-imageCaptionVPadding), Align::Stretch, "ToolTipText");
|
||||
textWidget->setProperty("Static", "true");
|
||||
textWidget->setProperty("MultiLine", "true");
|
||||
textWidget->setProperty("WordWrap", "true");
|
||||
textWidget->setCaption(text);
|
||||
textWidget->setTextAlign(Align::HCenter | Align::Top);
|
||||
IntSize textSize = textWidget->getTextSize();
|
||||
|
||||
captionSize += IntSize(imageSize, 0); // adjust for image
|
||||
IntSize totalSize = IntSize( std::max(textSize.width, captionSize.width + ((image != "") ? imageCaptionHPadding : 0)),
|
||||
((text != "") ? textSize.height + imageCaptionVPadding : 0) + captionHeight );
|
||||
|
||||
if (info.effects != 0)
|
||||
{
|
||||
Widget* effectArea = mDynamicToolTipBox->createWidget<Widget>("",
|
||||
IntCoord(0, totalSize.height, 300, 300-totalSize.height),
|
||||
Align::Stretch, "ToolTipEffectArea");
|
||||
|
||||
IntCoord coord(0, 6, totalSize.width, 24);
|
||||
|
||||
/**
|
||||
* \todo
|
||||
* the various potion effects should appear in the tooltip depending if the player
|
||||
* has enough skill in alchemy to know about the effects of this potion.
|
||||
*/
|
||||
|
||||
Widgets::MWEffectListPtr effectsWidget = effectArea->createWidget<Widgets::MWEffectList>
|
||||
("MW_StatName", coord, Align::Default, "ToolTipEffectsWidget");
|
||||
effectsWidget->setWindowManager(mWindowManager);
|
||||
effectsWidget->setEffectList(info.effects);
|
||||
|
||||
std::vector<MyGUI::WidgetPtr> effectItems;
|
||||
effectsWidget->createEffectWidgets(effectItems, effectArea, coord, true, Widgets::MWEffectList::EF_Potion);
|
||||
totalSize.height += coord.top-6;
|
||||
totalSize.width = std::max(totalSize.width, coord.width);
|
||||
}
|
||||
|
||||
if (info.enchant != "")
|
||||
{
|
||||
Widget* enchantArea = mDynamicToolTipBox->createWidget<Widget>("",
|
||||
IntCoord(0, totalSize.height, 300, 300-totalSize.height),
|
||||
Align::Stretch, "ToolTipEnchantArea");
|
||||
|
||||
IntCoord coord(0, 6, totalSize.width, 24);
|
||||
|
||||
Widgets::MWEffectListPtr enchantWidget = enchantArea->createWidget<Widgets::MWEffectList>
|
||||
("MW_StatName", coord, Align::Default, "ToolTipEnchantWidget");
|
||||
enchantWidget->setWindowManager(mWindowManager);
|
||||
enchantWidget->setEffectList(&enchant->effects);
|
||||
|
||||
std::vector<MyGUI::WidgetPtr> enchantEffectItems;
|
||||
int flag = (enchant->data.type == ESM::Enchantment::ConstantEffect) ? Widgets::MWEffectList::EF_Constant : 0;
|
||||
enchantWidget->createEffectWidgets(enchantEffectItems, enchantArea, coord, true, flag);
|
||||
totalSize.height += coord.top-6;
|
||||
totalSize.width = std::max(totalSize.width, coord.width);
|
||||
|
||||
if (enchant->data.type == ESM::Enchantment::WhenStrikes
|
||||
|| enchant->data.type == ESM::Enchantment::WhenUsed)
|
||||
{
|
||||
/// \todo store the current enchantment charge somewhere
|
||||
int charge = enchant->data.charge;
|
||||
|
||||
const int chargeWidth = 204;
|
||||
|
||||
TextBox* chargeText = enchantArea->createWidget<TextBox>("SandText", IntCoord(0, 0, 10, 18), Align::Default, "ToolTipEnchantChargeText");
|
||||
chargeText->setCaption(store.gameSettings.search("sCharges")->str);
|
||||
chargeText->setProperty("Static", "true");
|
||||
const int chargeTextWidth = chargeText->getTextSize().width + 5;
|
||||
|
||||
const int chargeAndTextWidth = chargeWidth + chargeTextWidth;
|
||||
chargeText->setCoord((totalSize.width - chargeAndTextWidth)/2, coord.top+6, chargeTextWidth, 18);
|
||||
|
||||
IntCoord chargeCoord;
|
||||
if (totalSize.width < chargeWidth)
|
||||
{
|
||||
totalSize.width = chargeWidth;
|
||||
chargeCoord = IntCoord(0, coord.top+6, chargeWidth, 18);
|
||||
}
|
||||
else
|
||||
{
|
||||
chargeCoord = IntCoord((totalSize.width - chargeAndTextWidth)/2 + chargeTextWidth, coord.top+6, chargeWidth, 18);
|
||||
}
|
||||
Widgets::MWDynamicStatPtr chargeWidget = enchantArea->createWidget<Widgets::MWDynamicStat>
|
||||
("MW_ChargeBar", chargeCoord, Align::Default, "ToolTipEnchantCharge");
|
||||
chargeWidget->setValue(charge, charge);
|
||||
totalSize.height += 24;
|
||||
}
|
||||
}
|
||||
|
||||
captionWidget->setCoord( (totalSize.width - captionSize.width)/2 + imageSize,
|
||||
(captionHeight-captionSize.height)/2,
|
||||
captionSize.width-imageSize,
|
||||
captionSize.height);
|
||||
|
||||
captionWidget->setPosition (captionWidget->getPosition() + padding);
|
||||
textWidget->setPosition (textWidget->getPosition() + IntPoint(0, padding.top)); // only apply vertical padding, the horizontal works automatically due to Align::HCenter
|
||||
|
||||
if (image != "")
|
||||
{
|
||||
ImageBox* imageWidget = mDynamicToolTipBox->createWidget<ImageBox>("ImageBox",
|
||||
IntCoord((totalSize.width - captionSize.width - imageCaptionHPadding)/2, 0, imageSize, imageSize),
|
||||
Align::Left | Align::Top, "ToolTipImage");
|
||||
imageWidget->setImageTexture(realImage);
|
||||
imageWidget->setPosition (imageWidget->getPosition() + padding);
|
||||
}
|
||||
|
||||
totalSize += IntSize(padding.left*2, padding.top*2);
|
||||
|
||||
return totalSize;
|
||||
}
|
||||
|
||||
std::string ToolTips::toString(const float value)
|
||||
{
|
||||
std::ostringstream stream;
|
||||
stream << std::setprecision(3) << value;
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
std::string ToolTips::toString(const int value)
|
||||
{
|
||||
std::ostringstream stream;
|
||||
stream << value;
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
std::string ToolTips::getValueString(const int value, const std::string& prefix)
|
||||
{
|
||||
if (value == 0)
|
||||
return "";
|
||||
else
|
||||
return "\n" + prefix + ": " + toString(value);
|
||||
}
|
||||
|
||||
std::string ToolTips::getMiscString(const std::string& text, const std::string& prefix)
|
||||
{
|
||||
if (text == "")
|
||||
return "";
|
||||
else
|
||||
return "\n" + prefix + ": " + text;
|
||||
}
|
||||
|
||||
void ToolTips::toggleFullHelp()
|
||||
{
|
||||
mFullHelp = !mFullHelp;
|
||||
}
|
||||
|
||||
bool ToolTips::getFullHelp() const
|
||||
{
|
||||
return mFullHelp;
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
|
||||
#ifndef MWGUI_TOOLTIPS_H
|
||||
#define MWGUI_TOOLTIPS_H
|
||||
|
||||
#include <openengine/gui/layout.hpp>
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
class WindowManager;
|
||||
|
||||
// Info about tooltip that is supplied by the MWWorld::Class object
|
||||
struct ToolTipInfo
|
||||
{
|
||||
public:
|
||||
ToolTipInfo() :
|
||||
effects(0)
|
||||
{
|
||||
};
|
||||
|
||||
std::string caption;
|
||||
std::string text;
|
||||
std::string icon;
|
||||
|
||||
// enchantment (for cloth, armor, weapons)
|
||||
std::string enchant;
|
||||
|
||||
// effects (for potions, ingredients)
|
||||
const ESM::EffectList* effects;
|
||||
};
|
||||
|
||||
class ToolTips : public OEngine::GUI::Layout
|
||||
{
|
||||
public:
|
||||
ToolTips(WindowManager* windowManager);
|
||||
|
||||
void onFrame(float frameDuration);
|
||||
|
||||
void enterGameMode();
|
||||
void enterGuiMode();
|
||||
|
||||
void toggleFullHelp(); ///< show extra info in item tooltips (owner, script)
|
||||
bool getFullHelp() const;
|
||||
|
||||
void setFocusObject(const MWWorld::Ptr& focus);
|
||||
|
||||
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);
|
||||
|
||||
private:
|
||||
MyGUI::Widget* mDynamicToolTipBox;
|
||||
|
||||
WindowManager* mWindowManager;
|
||||
|
||||
MWWorld::Ptr mFocusObject;
|
||||
|
||||
void findImageExtension(std::string& image);
|
||||
|
||||
MyGUI::IntSize getToolTipViaPtr ();
|
||||
///< @return requested tooltip size
|
||||
|
||||
MyGUI::IntSize createToolTip(const ToolTipInfo& info);
|
||||
///< @return requested tooltip size
|
||||
|
||||
bool mGameMode;
|
||||
|
||||
bool mFullHelp;
|
||||
};
|
||||
}
|
||||
#endif
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue