mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-05 11:15:34 +00:00
finished tooltips for everything in the stats window, some gui refactoring
This commit is contained in:
parent
76d71f86bc
commit
1079bb2677
7 changed files with 242 additions and 38 deletions
|
@ -129,16 +129,6 @@ void HUD::setBatchCount(size_t count)
|
|||
batchcounter->setCaption(boost::lexical_cast<std::string>(count));
|
||||
}
|
||||
|
||||
void HUD::setStats(int h, int hmax, int m, int mmax, int s, int smax)
|
||||
{
|
||||
health->setProgressRange(hmax);
|
||||
health->setProgressPosition(h);
|
||||
magicka->setProgressRange(mmax);
|
||||
magicka->setProgressPosition(m);
|
||||
stamina->setProgressRange(smax);
|
||||
stamina->setProgressPosition(s);
|
||||
}
|
||||
|
||||
void HUD::setWeapIcon(const char *str)
|
||||
{
|
||||
weapImage->setImageTexture(str);
|
||||
|
@ -176,19 +166,27 @@ void HUD::setValue(const std::string& id, const MWMechanics::DynamicStat<int>& v
|
|||
for (int i=0; ids[i]; ++i)
|
||||
if (ids[i]==id)
|
||||
{
|
||||
MyGUI::Widget* w;
|
||||
std::string valStr = boost::lexical_cast<std::string>(value.getCurrent()) + "/" + boost::lexical_cast<std::string>(value.getModified());
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
health->setProgressRange (value.getModified());
|
||||
health->setProgressPosition (value.getCurrent());
|
||||
getWidget(w, "HealthFrame");
|
||||
w->setUserString("Caption_HealthDescription", "#{sHealthDesc}\n" + valStr);
|
||||
break;
|
||||
case 1:
|
||||
magicka->setProgressRange (value.getModified());
|
||||
magicka->setProgressPosition (value.getCurrent());
|
||||
getWidget(w, "MagickaFrame");
|
||||
w->setUserString("Caption_HealthDescription", "#{sIntDesc}\n" + valStr);
|
||||
break;
|
||||
case 2:
|
||||
stamina->setProgressRange (value.getModified());
|
||||
stamina->setProgressPosition (value.getCurrent());
|
||||
getWidget(w, "FatigueFrame");
|
||||
w->setUserString("Caption_HealthDescription", "#{sFatDesc}\n" + valStr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ namespace MWGui
|
|||
{
|
||||
public:
|
||||
HUD(int width, int height, int fpsLevel, DragAndDrop* dragAndDrop);
|
||||
void setStats(int h, int hmax, int m, int mmax, int s, int smax);
|
||||
void setWeapIcon(const char *str);
|
||||
void setSpellIcon(const char *str);
|
||||
void setWeapStatus(int s, int smax);
|
||||
|
|
|
@ -172,10 +172,31 @@ void StatsWindow::setValue (const std::string& id, const MWMechanics::DynamicSta
|
|||
};
|
||||
|
||||
for (int i=0; ids[i]; ++i)
|
||||
{
|
||||
if (ids[i]==id)
|
||||
{
|
||||
std::string id (ids[i]);
|
||||
setBar (id, id + "T", value.getCurrent(), value.getModified());
|
||||
|
||||
// health, magicka, fatigue tooltip
|
||||
MyGUI::Widget* w;
|
||||
std::string valStr = boost::lexical_cast<std::string>(value.getCurrent()) + "/" + boost::lexical_cast<std::string>(value.getModified());
|
||||
if (i==0)
|
||||
{
|
||||
getWidget(w, "Health");
|
||||
w->setUserString("Caption_HealthDescription", "#{sHealthDesc}\n" + valStr);
|
||||
}
|
||||
else if (i==1)
|
||||
{
|
||||
getWidget(w, "Magicka");
|
||||
w->setUserString("Caption_HealthDescription", "#{sIntDesc}\n" + valStr);
|
||||
}
|
||||
else if (i==2)
|
||||
{
|
||||
getWidget(w, "Fatigue");
|
||||
w->setUserString("Caption_HealthDescription", "#{sFatDesc}\n" + valStr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -417,6 +438,37 @@ void StatsWindow::updateSkillArea()
|
|||
|
||||
const ESMS::ESMStore &store = mWindowManager.getStore();
|
||||
|
||||
// race tooltip
|
||||
const ESM::Race* playerRace = store.races.find (MWBase::Environment::get().getWorld()->getPlayer().getRace());
|
||||
MyGUI::Widget* raceWidget;
|
||||
getWidget(raceWidget, "RaceText");
|
||||
raceWidget->setUserString("Caption_CenteredCaption", playerRace->name);
|
||||
raceWidget->setUserString("Caption_CenteredCaptionText", playerRace->description);
|
||||
getWidget(raceWidget, "Race_str");
|
||||
raceWidget->setUserString("Caption_CenteredCaption", playerRace->name);
|
||||
raceWidget->setUserString("Caption_CenteredCaptionText", playerRace->description);
|
||||
|
||||
// class tooltip
|
||||
MyGUI::Widget* classWidget;
|
||||
const ESM::Class& playerClass = MWBase::Environment::get().getWorld()->getPlayer().getClass();
|
||||
int spec = playerClass.data.specialization;
|
||||
std::string specStr;
|
||||
if (spec == 0)
|
||||
specStr = "#{sSpecializationCombat}";
|
||||
else if (spec == 1)
|
||||
specStr = "#{sSpecializationMagic}";
|
||||
else if (spec == 2)
|
||||
specStr = "#{sSpecializationStealth}";
|
||||
|
||||
getWidget(classWidget, "ClassText");
|
||||
classWidget->setUserString("Caption_ClassName", playerClass.name);
|
||||
classWidget->setUserString("Caption_ClassDescription", playerClass.description);
|
||||
classWidget->setUserString("Caption_ClassSpecialisation", "#{sSpecialization}: " + specStr);
|
||||
getWidget(classWidget, "Class_str");
|
||||
classWidget->setUserString("Caption_ClassName", playerClass.name);
|
||||
classWidget->setUserString("Caption_ClassDescription", playerClass.description);
|
||||
classWidget->setUserString("Caption_ClassSpecialisation", "#{sSpecialization}: " + specStr);
|
||||
|
||||
if (!mFactions.empty())
|
||||
{
|
||||
// Add a line separator if there are items above
|
||||
|
|
|
@ -85,9 +85,14 @@ void ToolTips::onFrame(float frameDuration)
|
|||
getWidget(tooltip, focus->getUserString("ToolTipLayout"));
|
||||
|
||||
tooltip->setVisible(true);
|
||||
tooltip->setCoord(0, 0, 300, 300);
|
||||
if (!tooltip->isUserString("DontResize"))
|
||||
{
|
||||
tooltip->setCoord(0, 0, 450, 300); // this is the maximum width of the tooltip before it starts word-wrapping
|
||||
|
||||
tooltipSize = MyGUI::IntSize(0, tooltip->getSize().height);
|
||||
}
|
||||
else
|
||||
tooltipSize = tooltip->getSize();
|
||||
|
||||
std::map<std::string, std::string> userStrings = focus->getUserStrings();
|
||||
for (std::map<std::string, std::string>::iterator it = userStrings.begin();
|
||||
|
@ -116,7 +121,7 @@ void ToolTips::onFrame(float frameDuration)
|
|||
MyGUI::TextBox* text = w->castType<MyGUI::TextBox>();
|
||||
tooltipSize.width = std::max(tooltipSize.width, w->getLeft() + text->getTextSize().width + 8);
|
||||
}
|
||||
else
|
||||
else if (!tooltip->isUserString("DontResize"))
|
||||
tooltipSize.width = std::max(tooltipSize.width, w->getLeft() + w->getWidth() + 8);
|
||||
|
||||
if (w->isUserString("AutoResizeVertical"))
|
||||
|
@ -133,7 +138,6 @@ void ToolTips::onFrame(float frameDuration)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
tooltip->setCoord(0, 0, tooltipSize.width, tooltipSize.height);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -3,12 +3,30 @@
|
|||
<MyGUI type="Layout">
|
||||
<Widget type="Widget" layer="HUD" position="0 0 300 200" name="_Main">
|
||||
<!-- Energy bars -->
|
||||
<Widget type="ProgressBar" skin="MW_EnergyBar_Red" position="13 146 65 12"
|
||||
align="Left Bottom" name="Health"/>
|
||||
<Widget type="ProgressBar" skin="MW_EnergyBar_Blue" position="13 161 65 12"
|
||||
align="Left Bottom" name="Magicka"/>
|
||||
<Widget type="ProgressBar" skin="MW_EnergyBar_Green" position="13 176 65 12"
|
||||
align="Left Bottom" name="Stamina"/>
|
||||
<Widget type="Button" skin="" position="13 146 65 12" align="Left Bottom" name="HealthFrame">
|
||||
<UserString key="ToolTipType" value="Layout"/>
|
||||
<UserString key="ToolTipLayout" value="HealthToolTip"/>
|
||||
<UserString key="ImageTexture_HealthImage" value="icons\k\health.dds"/>
|
||||
<Widget type="ProgressBar" skin="MW_EnergyBar_Red" position="0 0 65 12" align="Left Bottom" name="Health">
|
||||
<Property key="NeedMouse" value="false"/>
|
||||
</Widget>
|
||||
</Widget>
|
||||
<Widget type="Button" skin="" position="13 161 65 12" align="Left Bottom" name="MagickaFrame">
|
||||
<UserString key="ToolTipType" value="Layout"/>
|
||||
<UserString key="ToolTipLayout" value="HealthToolTip"/>
|
||||
<UserString key="ImageTexture_HealthImage" value="icons\k\magicka.dds"/>
|
||||
<Widget type="ProgressBar" skin="MW_EnergyBar_Blue" position="0 0 65 12" align="Left Bottom" name="Magicka">
|
||||
<Property key="NeedMouse" value="false"/>
|
||||
</Widget>
|
||||
</Widget>
|
||||
<Widget type="Button" skin="" position="13 176 65 12" align="Left Bottom" name="FatigueFrame">
|
||||
<UserString key="ToolTipType" value="Layout"/>
|
||||
<UserString key="ToolTipLayout" value="HealthToolTip"/>
|
||||
<UserString key="ImageTexture_HealthImage" value="icons\k\fatigue.dds"/>
|
||||
<Widget type="ProgressBar" skin="MW_EnergyBar_Green" position="0 0 65 12" align="Left Bottom" name="Stamina">
|
||||
<Property key="NeedMouse" value="false"/>
|
||||
</Widget>
|
||||
</Widget>
|
||||
|
||||
<!-- Equipped weapon box -->
|
||||
<Widget type="Widget" position="82 146 36 41" align="Left Bottom" name="WeapBox">
|
||||
|
|
|
@ -7,37 +7,95 @@
|
|||
|
||||
<!-- Player health stats -->
|
||||
<Widget type="Widget" skin="MW_Box" position="8 8 212 62" align="Left Top HStretch">
|
||||
<Widget type="TextBox" skin="NormalText" position="4 4 70 18" name="Health_str" align="Left Top HStretch">
|
||||
<!-- Health -->
|
||||
<Widget type="Widget" skin="" position="4 4 204 18" name="Health" align="Left Top HStretch">
|
||||
<Property key="NeedMouse" value="true"/>
|
||||
<UserString key="ToolTipType" value="Layout"/>
|
||||
<UserString key="ToolTipLayout" value="HealthToolTip"/>
|
||||
<UserString key="ImageTexture_HealthImage" value="icons\k\health.dds"/>
|
||||
<Widget type="TextBox" skin="NormalText" position="0 0 70 18" name="Health_str" align="Left Top HStretch">
|
||||
<Property key="NeedMouse" value="false"/>
|
||||
<Property key="Caption" value="#{sHealth}"/>
|
||||
</Widget>
|
||||
<Widget type="TextBox" skin="NormalText" position="4 22 70 18" name="Magicka_str" align="Left Top HStretch">
|
||||
<Widget type="ProgressBar" skin="MW_Progress_Red" position="74 0 130 18" name="HBar" align="Right Top">
|
||||
<Property key="NeedMouse" value="false"/>
|
||||
</Widget>
|
||||
<Widget type="TextBox" skin="ProgressText" position="74 0 130 18" name="HBarT" align="Right Top">
|
||||
<Property key="NeedMouse" value="false"/>
|
||||
</Widget>
|
||||
</Widget>
|
||||
|
||||
<!-- Magicka -->
|
||||
<Widget type="Widget" skin="" position="4 22 204 18" name="Magicka" align="Left Top HStretch">
|
||||
<Property key="NeedMouse" value="true"/>
|
||||
<UserString key="ToolTipType" value="Layout"/>
|
||||
<UserString key="ToolTipLayout" value="HealthToolTip"/>
|
||||
<UserString key="ImageTexture_HealthImage" value="icons\k\magicka.dds"/>
|
||||
|
||||
<Widget type="TextBox" skin="NormalText" position="0 0 70 18" name="Magicka_str" align="Left Top HStretch">
|
||||
<Property key="Caption" value="#{sMagic}"/>
|
||||
<Property key="NeedMouse" value="false"/>
|
||||
</Widget>
|
||||
<Widget type="TextBox" skin="NormalText" position="4 40 70 18" name="Fatigue_str" align="Left Top HStretch">
|
||||
|
||||
<Widget type="ProgressBar" skin="MW_Progress_Blue" position="74 0 130 18" name="MBar" align="Right Top">
|
||||
<Property key="NeedMouse" value="false"/>
|
||||
</Widget>
|
||||
|
||||
<Widget type="TextBox" skin="ProgressText" position="74 0 130 18" name="MBarT" align="Right Top">
|
||||
<Property key="NeedMouse" value="false"/>
|
||||
</Widget>
|
||||
</Widget>
|
||||
|
||||
<!-- Fatigue -->
|
||||
<Widget type="Widget" skin="" position="4 40 204 18" name="Fatigue" align="Left Top HStretch">
|
||||
<Property key="NeedMouse" value="true"/>
|
||||
<UserString key="ToolTipType" value="Layout"/>
|
||||
<UserString key="ToolTipLayout" value="HealthToolTip"/>
|
||||
<UserString key="ImageTexture_HealthImage" value="icons\k\fatigue.dds"/>
|
||||
|
||||
<Widget type="TextBox" skin="NormalText" position="0 0 70 18" name="Fatigue_str" align="Left Top HStretch">
|
||||
<Property key="Caption" value="#{sFatigue}"/>
|
||||
<Property key="NeedMouse" value="false"/>
|
||||
</Widget>
|
||||
|
||||
<Widget type="ProgressBar" skin="MW_Progress_Green" position="74 0 130 18" name="FBar" align="Right Top">
|
||||
<Property key="NeedMouse" value="false"/>
|
||||
</Widget>
|
||||
<Widget type="TextBox" skin="ProgressText" position="74 0 130 18" name="FBarT" align="Right Top">
|
||||
<Property key="NeedMouse" value="false"/>
|
||||
</Widget>
|
||||
</Widget>
|
||||
<Widget type="ProgressBar" skin="MW_Progress_Red" position="78 4 130 18" name="HBar" align="Right Top"/>
|
||||
<Widget type="ProgressBar" skin="MW_Progress_Blue" position="78 22 130 18" name="MBar" align="Right Top"/>
|
||||
<Widget type="ProgressBar" skin="MW_Progress_Green" position="78 40 130 18" name="FBar" align="Right Top"/>
|
||||
<Widget type="TextBox" skin="ProgressText" position="78 4 130 18" name="HBarT" align="Right Top"/>
|
||||
<Widget type="TextBox" skin="ProgressText" position="78 22 130 18" name="MBarT" align="Right Top"/>
|
||||
<Widget type="TextBox" skin="ProgressText" position="78 40 130 18" name="FBarT" align="Right Top"/>
|
||||
</Widget>
|
||||
|
||||
<!-- Player level, race and class -->
|
||||
<Widget type="Widget" skin="MW_Box" position="8 78 212 62" align="Left Top HStretch">
|
||||
<Widget type="TextBox" skin="NormalText" position="4 4 100 18" name="Level_str" align="Left Top HStretch">
|
||||
<Property key="Caption" value="#{sLevel}"/>
|
||||
<UserString key="ToolTipType" value="Layout"/>
|
||||
<UserString key="ToolTipLayout" value="LevelToolTip"/>
|
||||
</Widget>
|
||||
<Widget type="TextBox" skin="NormalText" position="4 22 100 18" name="Race_str" align="Left Top HStretch">
|
||||
<Property key="Caption" value="#{sRace}"/>
|
||||
<UserString key="ToolTipType" value="Layout"/>
|
||||
<UserString key="ToolTipLayout" value="TextWithCenteredCaptionToolTip"/>
|
||||
</Widget>
|
||||
<Widget type="TextBox" skin="NormalText" position="4 40 100 18" name="Class_str" align="Left Top HStretch">
|
||||
<Property key="Caption" value="#{sClass}"/>
|
||||
<UserString key="ToolTipType" value="Layout"/>
|
||||
<UserString key="ToolTipLayout" value="ClassToolTip"/>
|
||||
</Widget>
|
||||
<Widget type="TextBox" skin="SandTextRight" position="104 4 104 18" name="LevelText" align="Right Top">
|
||||
<UserString key="ToolTipType" value="Layout"/>
|
||||
<UserString key="ToolTipLayout" value="LevelToolTip"/>
|
||||
</Widget>
|
||||
<Widget type="TextBox" skin="SandTextRight" position="104 22 104 18" name="RaceText" align="Right Top">
|
||||
<UserString key="ToolTipType" value="Layout"/>
|
||||
<UserString key="ToolTipLayout" value="TextWithCenteredCaptionToolTip"/>
|
||||
</Widget>
|
||||
<Widget type="TextBox" skin="SandTextRight" position="104 40 104 18" name="ClassText" align="Right Top">
|
||||
<UserString key="ToolTipType" value="Layout"/>
|
||||
<UserString key="ToolTipLayout" value="ClassToolTip"/>
|
||||
</Widget>
|
||||
<Widget type="TextBox" skin="SandTextRight" position="104 4 104 18" name="LevelText" align="Right Top"/>
|
||||
<Widget type="TextBox" skin="SandTextRight" position="104 22 104 18" name="RaceText" align="Right Top"/>
|
||||
<Widget type="TextBox" skin="SandTextRight" position="104 40 104 18" name="ClassText" align="Right Top"/>
|
||||
</Widget>
|
||||
|
||||
<Widget type="Widget" skin="MW_Box" position="8 148 212 152" align="Left Top Stretch">
|
||||
|
|
|
@ -21,6 +21,62 @@
|
|||
</Widget>
|
||||
</Widget>
|
||||
|
||||
<!-- Text with centered caption tooltip -->
|
||||
<Widget type="Widget" skin="HUD_Box" position="0 0 300 56" align="Stretch" name="TextWithCenteredCaptionToolTip">
|
||||
<Property key="Visible" value="false"/>
|
||||
|
||||
<Widget type="TextBox" skin="NormalText" position="8 8 284 18" align="Left Top HStretch" name="CenteredCaption">
|
||||
<Property key="TextAlign" value="Center"/>
|
||||
<UserString key="AutoResizeHorizontal" value="true"/>
|
||||
</Widget>
|
||||
|
||||
<Widget type="EditBox" skin="SandText" position="8 30 284 18" align="Left Top Stretch" name="CenteredCaptionText">
|
||||
<Property key="MultiLine" value="true"/>
|
||||
<Property key="WordWrap" value="true"/>
|
||||
<Property key="TextAlign" value="Left Top"/>
|
||||
<UserString key="AutoResizeHorizontal" value="true"/>
|
||||
<UserString key="AutoResizeVertical" value="true"/>
|
||||
</Widget>
|
||||
</Widget>
|
||||
|
||||
<!-- Class tooltip -->
|
||||
<Widget type="Widget" skin="HUD_Box" position="0 0 300 78" align="Stretch" name="ClassToolTip">
|
||||
<Property key="Visible" value="false"/>
|
||||
|
||||
<Widget type="TextBox" skin="NormalText" position="8 8 284 18" align="Left Top HStretch" name="ClassName">
|
||||
<Property key="TextAlign" value="Center"/>
|
||||
<UserString key="AutoResizeHorizontal" value="true"/>
|
||||
</Widget>
|
||||
|
||||
<Widget type="EditBox" skin="SandText" position="8 30 284 18" align="Left Top Stretch" name="ClassDescription">
|
||||
<Property key="MultiLine" value="true"/>
|
||||
<Property key="WordWrap" value="true"/>
|
||||
<Property key="TextAlign" value="Left Top"/>
|
||||
<UserString key="AutoResizeHorizontal" value="true"/>
|
||||
<UserString key="AutoResizeVertical" value="true"/>
|
||||
</Widget>
|
||||
|
||||
<Widget type="EditBox" skin="SandText" position="8 52 284 18" align="Left Bottom HStretch" name="ClassSpecialisation">
|
||||
<Property key="TextAlign" value="Center"/>
|
||||
<UserString key="AutoResizeHorizontal" value="true"/>
|
||||
</Widget>
|
||||
</Widget>
|
||||
|
||||
<!-- Health tooltip -->
|
||||
<Widget type="Widget" skin="HUD_Box" position="0 0 300 300" align="Stretch" name="HealthToolTip">
|
||||
<Property key="Visible" value="false"/>
|
||||
|
||||
<Widget type="ImageBox" skin="ImageBox" position="8 8 32 32" align="Left Top" name="HealthImage"/>
|
||||
|
||||
<Widget type="EditBox" skin="SandText" position="44 8 248 284" align="Left Top Stretch" name="HealthDescription">
|
||||
<Property key="MultiLine" value="true"/>
|
||||
<Property key="WordWrap" value="true"/>
|
||||
<Property key="TextAlign" value="Left Top"/>
|
||||
<UserString key="AutoResizeHorizontal" value="true"/>
|
||||
<UserString key="AutoResizeVertical" value="true"/>
|
||||
</Widget>
|
||||
</Widget>
|
||||
|
||||
<!-- Attribute tooltip -->
|
||||
<Widget type="Widget" skin="HUD_Box" position="0 0 300 300" align="Stretch" name="AttributeToolTip">
|
||||
<Property key="Visible" value="false"/>
|
||||
|
@ -78,6 +134,27 @@
|
|||
</Widget>
|
||||
</Widget>
|
||||
|
||||
<!-- Level tooltip -->
|
||||
<Widget type="Widget" skin="HUD_Box" position="0 0 300 58" align="Left Top" name="LevelToolTip">
|
||||
<Property key="Visible" value="false"/>
|
||||
<UserString key="DontResize" value="true"/>
|
||||
|
||||
<Widget type="TextBox" skin="NormalText" position="8 8 284 18" align="Left Top HStretch">
|
||||
<UserString key="AutoResizeHorizontal" value="true"/>
|
||||
<Property key="Caption" value="#{sLevelProgress}"/>
|
||||
<Property key="TextAlign" value="Center"/>
|
||||
</Widget>
|
||||
|
||||
<Widget type="ProgressBar" skin="MW_Progress_Red" position="50 30 200 20" align="HCenter Bottom" name="LevelProgress">
|
||||
<Property key="Range" value="10"/>
|
||||
<Property key="RangePosition" value="0"/>
|
||||
<Widget type="TextBox" skin="ProgressText" position="0 0 200 20" align="Stretch" name="LevelProgressText">
|
||||
<Property key="TextAlign" value="Center"/>
|
||||
<Property key="Caption" value="0/10"/>
|
||||
</Widget>
|
||||
</Widget>
|
||||
</Widget>
|
||||
|
||||
<!-- Birthsign tooltip -->
|
||||
<Widget type="Widget" skin="HUD_Box" position="0 0 300 300" align="Stretch" name="BirthSignToolTip">
|
||||
<Property key="Visible" value="false"/>
|
||||
|
@ -88,8 +165,6 @@
|
|||
</Widget>
|
||||
|
||||
<Widget type="TextBox" skin="NormalText" position="8 154 284 138" align="Top Stretch" name="BirthSignText">
|
||||
<Property key="MultiLine" value="true"/>
|
||||
<Property key="WordWrap" value="true"/>
|
||||
<Property key="TextAlign" value="Top HCenter"/>
|
||||
<UserString key="AutoResizeHorizontal" value="true"/>
|
||||
<UserString key="AutoResizeVertical" value="true"/>
|
||||
|
|
Loading…
Reference in a new issue