forked from mirror/openmw-tes3mp
spell widget i18n improvements (used e.g. in birth menu)
This commit is contained in:
parent
2e57cf5730
commit
d568b27b92
4 changed files with 81 additions and 27 deletions
|
@ -326,6 +326,36 @@ namespace MWClass
|
|||
text += "\n" + environment.mWorld->getStore().gameSettings.search("sWeight")->str + ": " + MWGui::ToolTips::toString(ref->base->data.weight);
|
||||
text += MWGui::ToolTips::getValueString(ref->base->data.value, environment.mWorld->getStore().gameSettings.search("sValue")->str);
|
||||
|
||||
// this should be going into a custom mygui widget MWEnchantment
|
||||
/*
|
||||
// enchantments
|
||||
if (ref->base->enchant != "")
|
||||
{
|
||||
const ESM::Enchantment* enchant = environment.mWorld->getStore().enchants.search(ref->base->enchant);
|
||||
if (enchant->data.type == ESM::Enchantment::CastOnce)
|
||||
text += "\n" + environment.mWorld->getStore().gameSettings.search("sItemCastOnce")->str;
|
||||
else if (enchant->data.type == ESM::Enchantment::WhenStrikes)
|
||||
text += "\n" + environment.mWorld->getStore().gameSettings.search("sItemCastWhenStrikes")->str;
|
||||
else if (enchant->data.type == ESM::Enchantment::WhenUsed)
|
||||
text += "\n" + environment.mWorld->getStore().gameSettings.search("sItemCastWhenUsed")->str;
|
||||
else if (enchant->data.type == ESM::Enchantment::ConstantEffect)
|
||||
text += "\n" + environment.mWorld->getStore().gameSettings.search("sItemCastConstant")->str;
|
||||
|
||||
if (enchant->data.type == ESM::Enchantment::WhenStrikes
|
||||
|| enchant->data.type == ESM::Enchantment::WhenUsed)
|
||||
{
|
||||
/// \todo store the current enchantment charge somewhere
|
||||
// info.currentCharge = enchant->data.charge;
|
||||
//info.totalCharge = enchant->data.charge;
|
||||
}
|
||||
}
|
||||
*/
|
||||
if (ref->base->enchant != "")
|
||||
{
|
||||
const ESM::Enchantment* enchant = environment.mWorld->getStore().enchants.search(ref->base->enchant);
|
||||
info.enchant = enchant;
|
||||
}
|
||||
|
||||
if (environment.mWindowManager->getFullHelp()) {
|
||||
text += MWGui::ToolTips::getMiscString(ref->ref.owner, "Owner");
|
||||
text += MWGui::ToolTips::getMiscString(ref->base->script, "Script");
|
||||
|
|
|
@ -51,26 +51,35 @@ void ToolTips::onFrame(float frameDuration)
|
|||
|
||||
std::string type = focus->getUserString("ToolTipType");
|
||||
std::string text = focus->getUserString("ToolTipText");
|
||||
|
||||
ToolTipInfo info;
|
||||
|
||||
if (type == "")
|
||||
{
|
||||
mDynamicToolTipBox->setVisible(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (type == "Text")
|
||||
tooltipSize = createToolTip(text, "", 0, "");
|
||||
{
|
||||
info.caption = text;
|
||||
}
|
||||
else if (type == "CaptionText")
|
||||
{
|
||||
std::string caption = focus->getUserString("ToolTipCaption");
|
||||
tooltipSize = createToolTip(caption, "", 0, text);
|
||||
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");
|
||||
int size = (sizeString != "" ? boost::lexical_cast<int>(sizeString) : 32);
|
||||
tooltipSize = createToolTip(caption, image, size, text);
|
||||
|
||||
info.text = text;
|
||||
info.caption = caption;
|
||||
info.icon = image;
|
||||
}
|
||||
tooltipSize = createToolTip(info);
|
||||
|
||||
IntPoint tooltipPosition = InputManager::getInstance().getMousePosition() + IntPoint(0, 24);
|
||||
|
||||
|
@ -137,14 +146,7 @@ IntSize ToolTips::getToolTipViaPtr ()
|
|||
mDynamicToolTipBox->setVisible(true);
|
||||
|
||||
ToolTipInfo info = object.getToolTipInfo(mFocusObject, mWindowManager->getEnvironment());
|
||||
if (info.icon == "")
|
||||
{
|
||||
tooltipSize = createToolTip(info.caption, "", 0, info.text);
|
||||
}
|
||||
else
|
||||
{
|
||||
tooltipSize = createToolTip(info.caption, info.icon, 32, info.text);
|
||||
}
|
||||
tooltipSize = createToolTip(info);
|
||||
}
|
||||
|
||||
return tooltipSize;
|
||||
|
@ -164,12 +166,16 @@ void ToolTips::findImageExtension(std::string& image)
|
|||
}
|
||||
}
|
||||
|
||||
IntSize ToolTips::createToolTip(const std::string& caption, const std::string& image, const int imageSize, const std::string& text)
|
||||
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)
|
||||
std::string realText = text;
|
||||
if (realText.size() > 0 && realText[0] == '\n')
|
||||
realText.erase(0, 1);
|
||||
if (text.size() > 0 && text[0] == '\n')
|
||||
text.erase(0, 1);
|
||||
|
||||
// this the maximum width of the tooltip before it starts word-wrapping
|
||||
setCoord(0, 0, 300, 300);
|
||||
|
@ -193,13 +199,13 @@ IntSize ToolTips::createToolTip(const std::string& caption, const std::string& i
|
|||
textWidget->setProperty("Static", "true");
|
||||
textWidget->setProperty("MultiLine", "true");
|
||||
textWidget->setProperty("WordWrap", "true");
|
||||
textWidget->setCaption(realText);
|
||||
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)),
|
||||
((realText != "") ? textSize.height + imageCaptionVPadding : 0) + captionHeight );
|
||||
((text != "") ? textSize.height + imageCaptionVPadding : 0) + captionHeight );
|
||||
|
||||
if (image != "")
|
||||
{
|
||||
|
|
|
@ -13,11 +13,21 @@ namespace MWGui
|
|||
struct ToolTipInfo
|
||||
{
|
||||
public:
|
||||
ToolTipInfo() :
|
||||
enchant(0),
|
||||
effects(0)
|
||||
{
|
||||
};
|
||||
|
||||
std::string caption;
|
||||
std::string text;
|
||||
std::string icon;
|
||||
|
||||
/// \todo enchantments (armor, cloth, weapons), magic effects (potions, ingredients)
|
||||
// enchantment (for cloth, armor, weapons)
|
||||
const ESM::Enchantment* enchant;
|
||||
|
||||
// effects (for potions, ingredients)
|
||||
const ESM::EffectList* effects;
|
||||
};
|
||||
|
||||
class ToolTips : public OEngine::GUI::Layout
|
||||
|
@ -56,7 +66,7 @@ namespace MWGui
|
|||
MyGUI::IntSize getToolTipViaPtr ();
|
||||
///< @return requested tooltip size
|
||||
|
||||
MyGUI::IntSize createToolTip(const std::string& caption, const std::string& image, const int imageSize, const std::string& text);
|
||||
MyGUI::IntSize createToolTip(const ToolTipInfo& info);
|
||||
///< @return requested tooltip size
|
||||
|
||||
bool mGameMode;
|
||||
|
|
|
@ -290,6 +290,12 @@ void MWSpellEffect::updateWidgets()
|
|||
{
|
||||
if (magicEffect)
|
||||
{
|
||||
std::string pt = mWindowManager->getGameSettingString("spoint", "");
|
||||
std::string pts = mWindowManager->getGameSettingString("spoints", "");
|
||||
std::string to = " " + mWindowManager->getGameSettingString("sTo", "") + " ";
|
||||
std::string sec = " " + mWindowManager->getGameSettingString("ssecond", "");
|
||||
std::string secs = " " + mWindowManager->getGameSettingString("sseconds", "");
|
||||
|
||||
// TODO: Get name of effect from GMST
|
||||
std::string spellLine = "";
|
||||
if (effect.skill >= 0 && effect.skill < ESM::Skill::Length)
|
||||
|
@ -313,22 +319,24 @@ void MWSpellEffect::updateWidgets()
|
|||
if (effect.magnMin >= 0 || effect.magnMax >= 0)
|
||||
{
|
||||
if (effect.magnMin == effect.magnMax)
|
||||
spellLine += " " + boost::lexical_cast<std::string>(effect.magnMin) + " pts";
|
||||
spellLine += " " + boost::lexical_cast<std::string>(effect.magnMin) + " " + ((effect.magnMin == 1) ? pt : pts);
|
||||
else
|
||||
{
|
||||
spellLine += " " + boost::lexical_cast<std::string>(effect.magnMin) + " to " + boost::lexical_cast<std::string>(effect.magnMin) + " pts";
|
||||
spellLine += " " + boost::lexical_cast<std::string>(effect.magnMin) + to + boost::lexical_cast<std::string>(effect.magnMin) + " " + pts;
|
||||
}
|
||||
}
|
||||
if (effect.duration >= 0)
|
||||
{
|
||||
spellLine += " for " + boost::lexical_cast<std::string>(effect.duration) + " secs";
|
||||
spellLine += " " + mWindowManager->getGameSettingString("sfor", "") + " " + boost::lexical_cast<std::string>(effect.duration) + ((effect.duration == 1) ? sec : secs);
|
||||
}
|
||||
|
||||
std::string on = mWindowManager->getGameSettingString("sonword", "");
|
||||
if (effect.range == ESM::RT_Self)
|
||||
spellLine += " on Self";
|
||||
spellLine += " " + on + " " + mWindowManager->getGameSettingString("sRangeSelf", "");
|
||||
else if (effect.range == ESM::RT_Touch)
|
||||
spellLine += " on Touch";
|
||||
spellLine += " " + on + " " + mWindowManager->getGameSettingString("sRangeTouch", "");
|
||||
else if (effect.range == ESM::RT_Target)
|
||||
spellLine += " on Target";
|
||||
spellLine += " " + on + " " + mWindowManager->getGameSettingString("sRangeTarget", "");
|
||||
static_cast<MyGUI::TextBox*>(textWidget)->setCaption(spellLine);
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue