mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-20 07:23:51 +00:00
added GUI update for health, magicka and fatigue
This commit is contained in:
parent
9e9b014f1d
commit
9a7880ff7f
5 changed files with 99 additions and 30 deletions
|
@ -89,6 +89,40 @@ namespace MWGui
|
|||
void setEffect(const char *img)
|
||||
{ effect1->setImageTexture(img); }
|
||||
|
||||
void setValue (const std::string& id, const MWMechanics::DynamicStat<int>& value)
|
||||
{
|
||||
static const char *ids[] =
|
||||
{
|
||||
"HBar", "MBar", "FBar",
|
||||
0
|
||||
};
|
||||
|
||||
for (int i=0; ids[i]; ++i)
|
||||
if (ids[i]==id)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
|
||||
health->setProgressRange (value.getModified());
|
||||
health->setProgressPosition (value.getCurrent());
|
||||
break;
|
||||
|
||||
case 1:
|
||||
|
||||
magicka->setProgressRange (value.getModified());
|
||||
magicka->setProgressPosition (value.getCurrent());
|
||||
break;
|
||||
|
||||
case 2:
|
||||
|
||||
stamina->setProgressRange (value.getModified());
|
||||
stamina->setProgressPosition (value.getCurrent());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MyGUI::ProgressPtr health, magicka, stamina;
|
||||
|
||||
MyGUI::StaticImagePtr weapImage, spellImage;
|
||||
|
@ -136,7 +170,7 @@ namespace MWGui
|
|||
class StatsWindow : public OEngine::GUI::Layout
|
||||
{
|
||||
public:
|
||||
void setBar(const char* name, const char* tname, int val, int max)
|
||||
void setBar(const std::string& name, const std::string& tname, int val, int max)
|
||||
{
|
||||
MyGUI::ProgressPtr pt;
|
||||
getWidget(pt, name);
|
||||
|
@ -169,10 +203,6 @@ namespace MWGui
|
|||
setText("RaceText", "Wood Elf");
|
||||
setText("ClassText", "Pilgrim");
|
||||
|
||||
setBar("HBar", "HBarT", 60, 100);
|
||||
setBar("MBar", "MBarT", 30, 100);
|
||||
setBar("FBar", "FBarT", 80, 100);
|
||||
|
||||
setText("AttribVal1", "30");
|
||||
setText("AttribVal2", "40");
|
||||
setText("AttribVal3", "30");
|
||||
|
@ -234,6 +264,21 @@ namespace MWGui
|
|||
}
|
||||
}
|
||||
|
||||
void setValue (const std::string& id, const MWMechanics::DynamicStat<int>& value)
|
||||
{
|
||||
static const char *ids[] =
|
||||
{
|
||||
"HBar", "MBar", "FBar",
|
||||
0
|
||||
};
|
||||
|
||||
for (int i=0; ids[i]; ++i)
|
||||
if (ids[i]==id)
|
||||
{
|
||||
std::string id (ids[i]);
|
||||
setBar (id, id + "T", value.getCurrent(), value.getModified());
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -95,3 +95,8 @@ void WindowManager::setValue (const std::string& id, const MWMechanics::Stat<int
|
|||
stats->setValue (id, value);
|
||||
}
|
||||
|
||||
void WindowManager::setValue (const std::string& id, const MWMechanics::DynamicStat<int>& value)
|
||||
{
|
||||
stats->setValue (id, value);
|
||||
hud->setValue (id, value);
|
||||
}
|
||||
|
|
|
@ -144,6 +144,9 @@ namespace MWGui
|
|||
|
||||
void setValue (const std::string& id, const MWMechanics::Stat<int>& value);
|
||||
///< Set value for the given ID.
|
||||
|
||||
void setValue (const std::string& id, const MWMechanics::DynamicStat<int>& value);
|
||||
///< Set value for the given ID.
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -80,6 +80,11 @@ namespace MWMechanics
|
|||
"AttribVal6", "AttribVal7", "AttribVal8"
|
||||
};
|
||||
|
||||
static const char *dynamicNames[3] =
|
||||
{
|
||||
"HBar", "MBar", "FBar"
|
||||
};
|
||||
|
||||
for (int i=0; i<8; ++i)
|
||||
{
|
||||
if (stats.mAttributes[i]!=mWatchedCreature.mAttributes[i])
|
||||
|
@ -89,7 +94,16 @@ namespace MWMechanics
|
|||
mWindowManager.setValue (attributeNames[i], stats.mAttributes[i]);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i=0; i<3; ++i)
|
||||
{
|
||||
if (stats.mDynamic[i]!=mWatchedCreature.mDynamic[i])
|
||||
{
|
||||
mWatchedCreature.mDynamic[i] = stats.mDynamic[i];
|
||||
|
||||
mWindowManager.setValue (dynamicNames[i], stats.mDynamic[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -87,6 +87,8 @@ namespace MWMechanics
|
|||
|
||||
public:
|
||||
|
||||
DynamicStat() : mCurrent (0) {}
|
||||
|
||||
const T& getBase() const
|
||||
{
|
||||
return mStatic.getBase();
|
||||
|
|
Loading…
Reference in a new issue