2011-01-02 16:17:33 +00:00
|
|
|
#include "stats_window.hpp"
|
|
|
|
|
|
|
|
#include <cmath>
|
|
|
|
#include <algorithm>
|
|
|
|
#include <iterator>
|
2012-05-19 12:19:21 +00:00
|
|
|
|
2011-01-02 16:17:33 +00:00
|
|
|
#include <boost/lexical_cast.hpp>
|
|
|
|
|
2012-05-19 12:19:21 +00:00
|
|
|
#include "../mwbase/environment.hpp"
|
2012-07-03 10:30:50 +00:00
|
|
|
#include "../mwbase/world.hpp"
|
|
|
|
|
|
|
|
#include "../mwworld/player.hpp"
|
|
|
|
#include "../mwworld/class.hpp"
|
|
|
|
|
|
|
|
#include "../mwmechanics/mechanicsmanager.hpp"
|
2012-05-19 12:19:21 +00:00
|
|
|
|
|
|
|
#include "window_manager.hpp"
|
2012-05-27 04:39:10 +00:00
|
|
|
#include "tooltips.hpp"
|
2012-05-19 12:19:21 +00:00
|
|
|
|
|
|
|
|
2011-01-02 16:17:33 +00:00
|
|
|
using namespace MWGui;
|
2012-07-13 10:51:58 +00:00
|
|
|
const int StatsWindow::sLineHeight = 18;
|
2011-01-02 16:17:33 +00:00
|
|
|
|
2011-02-21 19:36:35 +00:00
|
|
|
StatsWindow::StatsWindow (WindowManager& parWindowManager)
|
2012-07-03 09:34:20 +00:00
|
|
|
: WindowPinnableBase("openmw_stats_window.layout", parWindowManager)
|
2012-07-13 10:51:58 +00:00
|
|
|
, mSkillAreaWidget(NULL)
|
|
|
|
, mSkillClientWidget(NULL)
|
|
|
|
, mSkillScrollerWidget(NULL)
|
|
|
|
, mLastPos(0)
|
|
|
|
, mClientHeight(0)
|
|
|
|
, mMajorSkills()
|
|
|
|
, mMinorSkills()
|
|
|
|
, mMiscSkills()
|
|
|
|
, mSkillValues()
|
|
|
|
, mSkillWidgetMap()
|
|
|
|
, mFactionWidgetMap()
|
2012-05-19 12:19:21 +00:00
|
|
|
, mFactions()
|
2012-07-13 10:51:58 +00:00
|
|
|
, mBirthSignId()
|
|
|
|
, mReputation(0)
|
|
|
|
, mBounty(0)
|
|
|
|
, mSkillWidgets()
|
2012-05-19 12:19:21 +00:00
|
|
|
, mChanged(true)
|
2011-01-02 16:17:33 +00:00
|
|
|
{
|
|
|
|
setCoord(0,0,498, 342);
|
|
|
|
|
|
|
|
const char *names[][2] =
|
|
|
|
{
|
|
|
|
{ "Attrib1", "sAttributeStrength" },
|
|
|
|
{ "Attrib2", "sAttributeIntelligence" },
|
|
|
|
{ "Attrib3", "sAttributeWillpower" },
|
|
|
|
{ "Attrib4", "sAttributeAgility" },
|
|
|
|
{ "Attrib5", "sAttributeSpeed" },
|
|
|
|
{ "Attrib6", "sAttributeEndurance" },
|
|
|
|
{ "Attrib7", "sAttributePersonality" },
|
|
|
|
{ "Attrib8", "sAttributeLuck" },
|
|
|
|
{ 0, 0 }
|
|
|
|
};
|
|
|
|
|
2011-02-21 19:36:35 +00:00
|
|
|
const ESMS::ESMStore &store = mWindowManager.getStore();
|
2011-01-02 16:17:33 +00:00
|
|
|
for (int i=0; names[i][0]; ++i)
|
|
|
|
{
|
|
|
|
setText (names[i][0], store.gameSettings.find (names[i][1])->str);
|
|
|
|
}
|
|
|
|
|
2012-07-13 10:51:58 +00:00
|
|
|
getWidget(mSkillAreaWidget, "Skills");
|
|
|
|
getWidget(mSkillClientWidget, "SkillClient");
|
|
|
|
getWidget(mSkillScrollerWidget, "SkillScroller");
|
2012-05-11 06:15:22 +00:00
|
|
|
getWidget(mLeftPane, "LeftPane");
|
|
|
|
getWidget(mRightPane, "RightPane");
|
2011-01-02 16:17:33 +00:00
|
|
|
|
2012-07-13 10:51:58 +00:00
|
|
|
mSkillClientWidget->eventMouseWheel += MyGUI::newDelegate(this, &StatsWindow::onMouseWheel);
|
2012-05-11 06:45:03 +00:00
|
|
|
|
2012-07-13 10:51:58 +00:00
|
|
|
mSkillScrollerWidget->eventScrollChangePosition += MyGUI::newDelegate(this, &StatsWindow::onScrollChangePosition);
|
2011-01-02 16:17:33 +00:00
|
|
|
updateScroller();
|
|
|
|
|
|
|
|
for (int i = 0; i < ESM::Skill::Length; ++i)
|
|
|
|
{
|
2012-07-13 10:51:58 +00:00
|
|
|
mSkillValues.insert(std::pair<int, MWMechanics::Stat<float> >(i, MWMechanics::Stat<float>()));
|
|
|
|
mSkillWidgetMap.insert(std::pair<int, MyGUI::TextBox*>(i, nullptr));
|
2011-01-02 16:17:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MyGUI::WindowPtr t = static_cast<MyGUI::WindowPtr>(mMainWidget);
|
2012-03-21 12:27:08 +00:00
|
|
|
t->eventWindowChangeCoord += MyGUI::newDelegate(this, &StatsWindow::onWindowResize);
|
2011-01-02 16:17:33 +00:00
|
|
|
}
|
|
|
|
|
2012-03-22 14:23:23 +00:00
|
|
|
void StatsWindow::onScrollChangePosition(MyGUI::ScrollBar* scroller, size_t pos)
|
2011-01-02 16:17:33 +00:00
|
|
|
{
|
2012-07-13 10:51:58 +00:00
|
|
|
int diff = mLastPos - pos;
|
2011-01-02 16:17:33 +00:00
|
|
|
// Adjust position of all widget according to difference
|
|
|
|
if (diff == 0)
|
|
|
|
return;
|
2012-07-13 10:51:58 +00:00
|
|
|
mLastPos = pos;
|
2011-01-02 16:17:33 +00:00
|
|
|
|
2012-07-13 10:51:58 +00:00
|
|
|
std::vector<MyGUI::WidgetPtr>::const_iterator end = mSkillWidgets.end();
|
|
|
|
for (std::vector<MyGUI::WidgetPtr>::const_iterator it = mSkillWidgets.begin(); it != end; ++it)
|
2011-01-02 16:17:33 +00:00
|
|
|
{
|
|
|
|
(*it)->setCoord((*it)->getCoord() + MyGUI::IntPoint(0, diff));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-11 06:45:03 +00:00
|
|
|
void StatsWindow::onMouseWheel(MyGUI::Widget* _sender, int _rel)
|
|
|
|
{
|
2012-07-13 10:51:58 +00:00
|
|
|
if (mSkillScrollerWidget->getScrollPosition() - _rel*0.3 < 0)
|
|
|
|
mSkillScrollerWidget->setScrollPosition(0);
|
|
|
|
else if (mSkillScrollerWidget->getScrollPosition() - _rel*0.3 > mSkillScrollerWidget->getScrollRange()-1)
|
|
|
|
mSkillScrollerWidget->setScrollPosition(mSkillScrollerWidget->getScrollRange()-1);
|
2012-05-11 06:45:03 +00:00
|
|
|
else
|
2012-07-13 10:51:58 +00:00
|
|
|
mSkillScrollerWidget->setScrollPosition(mSkillScrollerWidget->getScrollPosition() - _rel*0.3);
|
2012-05-11 06:45:03 +00:00
|
|
|
|
2012-07-13 10:51:58 +00:00
|
|
|
onScrollChangePosition(mSkillScrollerWidget, mSkillScrollerWidget->getScrollPosition());
|
2012-05-11 06:45:03 +00:00
|
|
|
}
|
|
|
|
|
2011-03-12 12:54:00 +00:00
|
|
|
void StatsWindow::onWindowResize(MyGUI::Window* window)
|
2011-01-02 16:17:33 +00:00
|
|
|
{
|
2012-05-11 06:15:22 +00:00
|
|
|
mLeftPane->setCoord( MyGUI::IntCoord(0, 0, 0.44*window->getSize().width, window->getSize().height) );
|
|
|
|
mRightPane->setCoord( MyGUI::IntCoord(0.44*window->getSize().width, 0, 0.56*window->getSize().width, window->getSize().height) );
|
2011-01-02 16:17:33 +00:00
|
|
|
updateScroller();
|
|
|
|
}
|
|
|
|
|
|
|
|
void StatsWindow::setBar(const std::string& name, const std::string& tname, int val, int max)
|
|
|
|
{
|
|
|
|
MyGUI::ProgressPtr pt;
|
|
|
|
getWidget(pt, name);
|
|
|
|
pt->setProgressRange(max);
|
|
|
|
pt->setProgressPosition(val);
|
|
|
|
|
|
|
|
std::stringstream out;
|
|
|
|
out << val << "/" << max;
|
|
|
|
setText(tname, out.str().c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
void StatsWindow::setPlayerName(const std::string& playerName)
|
|
|
|
{
|
2012-05-19 12:19:21 +00:00
|
|
|
static_cast<MyGUI::Window*>(mMainWidget)->setCaption(playerName);
|
|
|
|
adjustWindowCaption();
|
2011-01-02 16:17:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void StatsWindow::setValue (const std::string& id, const MWMechanics::Stat<int>& value)
|
|
|
|
{
|
|
|
|
static const char *ids[] =
|
|
|
|
{
|
|
|
|
"AttribVal1", "AttribVal2", "AttribVal3", "AttribVal4", "AttribVal5",
|
|
|
|
"AttribVal6", "AttribVal7", "AttribVal8",
|
|
|
|
0
|
|
|
|
};
|
|
|
|
|
|
|
|
for (int i=0; ids[i]; ++i)
|
|
|
|
if (ids[i]==id)
|
|
|
|
{
|
|
|
|
std::ostringstream valueString;
|
|
|
|
valueString << value.getModified();
|
|
|
|
setText (id, valueString.str());
|
|
|
|
|
2012-04-16 13:48:01 +00:00
|
|
|
MyGUI::TextBox* box;
|
|
|
|
getWidget(box, id);
|
|
|
|
|
2011-01-02 16:17:33 +00:00
|
|
|
if (value.getModified()>value.getBase())
|
2012-04-16 13:48:01 +00:00
|
|
|
box->_setWidgetState("increased");
|
2011-01-02 16:17:33 +00:00
|
|
|
else if (value.getModified()<value.getBase())
|
2012-04-16 13:48:01 +00:00
|
|
|
box->_setWidgetState("decreased");
|
2011-01-02 16:17:33 +00:00
|
|
|
else
|
2012-04-16 13:48:01 +00:00
|
|
|
box->_setWidgetState("normal");
|
2011-01-02 16:17:33 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void StatsWindow::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)
|
2012-05-21 03:14:07 +00:00
|
|
|
{
|
2011-01-02 16:17:33 +00:00
|
|
|
if (ids[i]==id)
|
|
|
|
{
|
|
|
|
std::string id (ids[i]);
|
|
|
|
setBar (id, id + "T", value.getCurrent(), value.getModified());
|
2012-05-21 03:14:07 +00:00
|
|
|
|
|
|
|
// 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);
|
|
|
|
}
|
2011-01-02 16:17:33 +00:00
|
|
|
}
|
2012-05-21 03:14:07 +00:00
|
|
|
}
|
2011-01-02 16:17:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void StatsWindow::setValue (const std::string& id, const std::string& value)
|
|
|
|
{
|
|
|
|
if (id=="name")
|
|
|
|
setPlayerName (value);
|
|
|
|
else if (id=="race")
|
|
|
|
setText ("RaceText", value);
|
|
|
|
else if (id=="class")
|
|
|
|
setText ("ClassText", value);
|
|
|
|
}
|
|
|
|
|
|
|
|
void StatsWindow::setValue (const std::string& id, int value)
|
|
|
|
{
|
|
|
|
if (id=="level")
|
|
|
|
{
|
|
|
|
std::ostringstream text;
|
|
|
|
text << value;
|
|
|
|
setText("LevelText", text.str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-02 16:35:03 +00:00
|
|
|
void StatsWindow::setValue(const ESM::Skill::SkillEnum parSkill, const MWMechanics::Stat<float>& value)
|
2011-01-02 16:17:33 +00:00
|
|
|
{
|
2012-07-13 10:51:58 +00:00
|
|
|
mSkillValues[parSkill] = value;
|
|
|
|
MyGUI::TextBox* widget = mSkillWidgetMap[(int)parSkill];
|
2011-01-02 16:35:03 +00:00
|
|
|
if (widget)
|
2011-01-02 16:17:33 +00:00
|
|
|
{
|
2011-01-02 16:35:03 +00:00
|
|
|
float modified = value.getModified(), base = value.getBase();
|
|
|
|
std::string text = boost::lexical_cast<std::string>(std::floor(modified));
|
2012-04-16 13:48:01 +00:00
|
|
|
std::string state = "normal";
|
2011-01-02 16:35:03 +00:00
|
|
|
if (modified > base)
|
2012-04-16 13:48:01 +00:00
|
|
|
state = "increased";
|
2011-01-02 16:35:03 +00:00
|
|
|
else if (modified < base)
|
2012-04-16 13:48:01 +00:00
|
|
|
state = "decreased";
|
2011-01-02 16:35:03 +00:00
|
|
|
|
2012-04-16 13:48:01 +00:00
|
|
|
widget->setCaption(text);
|
|
|
|
widget->_setWidgetState(state);
|
2011-01-02 16:17:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void StatsWindow::configureSkills (const std::vector<int>& major, const std::vector<int>& minor)
|
|
|
|
{
|
2012-07-13 10:51:58 +00:00
|
|
|
mMajorSkills = major;
|
|
|
|
mMinorSkills = minor;
|
2011-01-02 16:17:33 +00:00
|
|
|
|
|
|
|
// Update misc skills with the remaining skills not in major or minor
|
|
|
|
std::set<int> skillSet;
|
|
|
|
std::copy(major.begin(), major.end(), std::inserter(skillSet, skillSet.begin()));
|
|
|
|
std::copy(minor.begin(), minor.end(), std::inserter(skillSet, skillSet.begin()));
|
|
|
|
boost::array<ESM::Skill::SkillEnum, ESM::Skill::Length>::const_iterator end = ESM::Skill::skillIds.end();
|
2012-07-13 10:51:58 +00:00
|
|
|
mMiscSkills.clear();
|
2011-01-02 16:17:33 +00:00
|
|
|
for (boost::array<ESM::Skill::SkillEnum, ESM::Skill::Length>::const_iterator it = ESM::Skill::skillIds.begin(); it != end; ++it)
|
|
|
|
{
|
|
|
|
int skill = *it;
|
|
|
|
if (skillSet.find(skill) == skillSet.end())
|
2012-07-13 10:51:58 +00:00
|
|
|
mMiscSkills.push_back(skill);
|
2011-01-02 16:17:33 +00:00
|
|
|
}
|
2012-05-28 08:50:00 +00:00
|
|
|
|
|
|
|
updateSkillArea();
|
2011-01-02 16:17:33 +00:00
|
|
|
}
|
|
|
|
|
2012-05-19 12:19:21 +00:00
|
|
|
void StatsWindow::onFrame ()
|
2011-01-02 16:17:33 +00:00
|
|
|
{
|
2012-05-19 12:55:09 +00:00
|
|
|
if (mMainWidget->getVisible())
|
|
|
|
return;
|
|
|
|
|
2012-05-19 12:19:21 +00:00
|
|
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
|
|
|
MWMechanics::NpcStats PCstats = MWWorld::Class::get(player).getNpcStats(player);
|
|
|
|
|
2012-07-06 16:23:48 +00:00
|
|
|
setFactions(PCstats.getFactionRanks());
|
2012-05-19 12:19:21 +00:00
|
|
|
|
2012-05-19 12:55:09 +00:00
|
|
|
setBirthSign(MWBase::Environment::get().getWorld()->getPlayer().getBirthsign());
|
|
|
|
|
2012-05-19 12:19:21 +00:00
|
|
|
if (mChanged)
|
|
|
|
updateSkillArea();
|
|
|
|
}
|
|
|
|
|
|
|
|
void StatsWindow::setFactions (const FactionList& factions)
|
|
|
|
{
|
|
|
|
if (mFactions != factions)
|
|
|
|
{
|
|
|
|
mFactions = factions;
|
|
|
|
mChanged = true;
|
|
|
|
}
|
2011-01-02 16:17:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void StatsWindow::setBirthSign (const std::string& signId)
|
|
|
|
{
|
2012-07-13 10:51:58 +00:00
|
|
|
if (signId != mBirthSignId)
|
2012-05-19 12:55:09 +00:00
|
|
|
{
|
2012-07-13 10:51:58 +00:00
|
|
|
mBirthSignId = signId;
|
2012-05-19 12:55:09 +00:00
|
|
|
mChanged = true;
|
|
|
|
}
|
2011-01-02 16:17:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void StatsWindow::addSeparator(MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2)
|
|
|
|
{
|
2012-07-13 10:51:58 +00:00
|
|
|
MyGUI::ImageBox* separator = mSkillClientWidget->createWidget<MyGUI::ImageBox>("MW_HLine",
|
2012-05-10 09:29:28 +00:00
|
|
|
MyGUI::IntCoord(10, coord1.top, coord1.width + coord2.width - 4, 18),
|
|
|
|
MyGUI::Align::Left | MyGUI::Align::Top | MyGUI::Align::HStretch);
|
2012-05-11 06:45:03 +00:00
|
|
|
separator->eventMouseWheel += MyGUI::newDelegate(this, &StatsWindow::onMouseWheel);
|
2012-07-13 10:51:58 +00:00
|
|
|
mSkillWidgets.push_back(separator);
|
2011-01-02 16:17:33 +00:00
|
|
|
|
|
|
|
coord1.top += separator->getHeight();
|
|
|
|
coord2.top += separator->getHeight();
|
|
|
|
}
|
|
|
|
|
|
|
|
void StatsWindow::addGroup(const std::string &label, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2)
|
|
|
|
{
|
2012-07-13 10:51:58 +00:00
|
|
|
MyGUI::TextBox* groupWidget = mSkillClientWidget->createWidget<MyGUI::TextBox>("SandBrightText",
|
2012-05-10 09:29:28 +00:00
|
|
|
MyGUI::IntCoord(0, coord1.top, coord1.width + coord2.width, coord1.height),
|
|
|
|
MyGUI::Align::Left | MyGUI::Align::Top | MyGUI::Align::HStretch);
|
2011-01-02 16:17:33 +00:00
|
|
|
groupWidget->setCaption(label);
|
2012-05-11 06:45:03 +00:00
|
|
|
groupWidget->eventMouseWheel += MyGUI::newDelegate(this, &StatsWindow::onMouseWheel);
|
2012-07-13 10:51:58 +00:00
|
|
|
mSkillWidgets.push_back(groupWidget);
|
2011-01-02 16:17:33 +00:00
|
|
|
|
2012-07-13 10:51:58 +00:00
|
|
|
coord1.top += sLineHeight;
|
|
|
|
coord2.top += sLineHeight;
|
2011-01-02 16:17:33 +00:00
|
|
|
}
|
|
|
|
|
2012-05-20 23:58:11 +00:00
|
|
|
MyGUI::TextBox* StatsWindow::addValueItem(const std::string& text, const std::string &value, const std::string& state, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2)
|
2011-01-02 16:17:33 +00:00
|
|
|
{
|
2012-03-21 13:54:02 +00:00
|
|
|
MyGUI::TextBox *skillNameWidget, *skillValueWidget;
|
2011-01-02 16:17:33 +00:00
|
|
|
|
2012-07-13 10:51:58 +00:00
|
|
|
skillNameWidget = mSkillClientWidget->createWidget<MyGUI::TextBox>("SandText", coord1, MyGUI::Align::Left | MyGUI::Align::Top | MyGUI::Align::HStretch);
|
2011-01-02 16:17:33 +00:00
|
|
|
skillNameWidget->setCaption(text);
|
2012-05-11 06:45:03 +00:00
|
|
|
skillNameWidget->eventMouseWheel += MyGUI::newDelegate(this, &StatsWindow::onMouseWheel);
|
2011-01-02 16:17:33 +00:00
|
|
|
|
2012-07-13 10:51:58 +00:00
|
|
|
skillValueWidget = mSkillClientWidget->createWidget<MyGUI::TextBox>("SandTextRight", coord2, MyGUI::Align::Right | MyGUI::Align::Top);
|
2012-04-16 13:48:01 +00:00
|
|
|
skillValueWidget->setCaption(value);
|
|
|
|
skillValueWidget->_setWidgetState(state);
|
2012-05-11 06:45:03 +00:00
|
|
|
skillValueWidget->eventMouseWheel += MyGUI::newDelegate(this, &StatsWindow::onMouseWheel);
|
2011-01-02 16:17:33 +00:00
|
|
|
|
2012-07-13 10:51:58 +00:00
|
|
|
mSkillWidgets.push_back(skillNameWidget);
|
|
|
|
mSkillWidgets.push_back(skillValueWidget);
|
2011-01-02 16:17:33 +00:00
|
|
|
|
2012-07-13 10:51:58 +00:00
|
|
|
coord1.top += sLineHeight;
|
|
|
|
coord2.top += sLineHeight;
|
2011-01-02 16:17:33 +00:00
|
|
|
|
|
|
|
return skillValueWidget;
|
|
|
|
}
|
|
|
|
|
2012-06-06 18:29:30 +00:00
|
|
|
MyGUI::Widget* StatsWindow::addItem(const std::string& text, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2)
|
2011-01-02 16:17:33 +00:00
|
|
|
{
|
2012-03-21 13:54:02 +00:00
|
|
|
MyGUI::TextBox* skillNameWidget;
|
2011-01-02 16:17:33 +00:00
|
|
|
|
2012-07-13 10:51:58 +00:00
|
|
|
skillNameWidget = mSkillClientWidget->createWidget<MyGUI::TextBox>("SandText", coord1 + MyGUI::IntSize(coord2.width, 0), MyGUI::Align::Default);
|
2011-01-02 16:17:33 +00:00
|
|
|
skillNameWidget->setCaption(text);
|
2012-05-11 06:45:03 +00:00
|
|
|
skillNameWidget->eventMouseWheel += MyGUI::newDelegate(this, &StatsWindow::onMouseWheel);
|
2011-01-02 16:17:33 +00:00
|
|
|
|
2012-07-13 10:51:58 +00:00
|
|
|
mSkillWidgets.push_back(skillNameWidget);
|
2011-01-02 16:17:33 +00:00
|
|
|
|
2012-07-13 10:51:58 +00:00
|
|
|
coord1.top += sLineHeight;
|
|
|
|
coord2.top += sLineHeight;
|
2012-05-20 20:45:30 +00:00
|
|
|
|
|
|
|
return skillNameWidget;
|
2011-01-02 16:17:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void StatsWindow::addSkills(const SkillList &skills, const std::string &titleId, const std::string &titleDefault, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2)
|
|
|
|
{
|
|
|
|
// Add a line separator if there are items above
|
2012-07-13 10:51:58 +00:00
|
|
|
if (!mSkillWidgets.empty())
|
2011-01-02 16:17:33 +00:00
|
|
|
{
|
|
|
|
addSeparator(coord1, coord2);
|
|
|
|
}
|
|
|
|
|
2011-02-21 19:36:35 +00:00
|
|
|
addGroup(mWindowManager.getGameSettingString(titleId, titleDefault), coord1, coord2);
|
2011-01-02 16:17:33 +00:00
|
|
|
|
|
|
|
SkillList::const_iterator end = skills.end();
|
|
|
|
for (SkillList::const_iterator it = skills.begin(); it != end; ++it)
|
|
|
|
{
|
|
|
|
int skillId = *it;
|
|
|
|
if (skillId < 0 || skillId > ESM::Skill::Length) // Skip unknown skill indexes
|
|
|
|
continue;
|
|
|
|
assert(skillId >= 0 && skillId < ESM::Skill::Length);
|
|
|
|
const std::string &skillNameId = ESMS::Skill::sSkillNameIds[skillId];
|
2012-07-13 10:51:58 +00:00
|
|
|
const MWMechanics::Stat<float> &stat = mSkillValues.find(skillId)->second;
|
2011-01-02 16:17:33 +00:00
|
|
|
float base = stat.getBase();
|
|
|
|
float modified = stat.getModified();
|
2012-05-21 08:48:25 +00:00
|
|
|
int progressPercent = (modified - float(static_cast<int>(modified))) * 100;
|
2011-01-02 16:17:33 +00:00
|
|
|
|
2012-05-20 23:58:11 +00:00
|
|
|
const ESM::Skill* skill = mWindowManager.getStore().skills.search(skillId);
|
|
|
|
assert(skill);
|
|
|
|
|
|
|
|
std::string icon = "icons\\k\\" + ESM::Skill::sIconNames[skillId];
|
|
|
|
|
|
|
|
const ESM::Attribute* attr = mWindowManager.getStore().attributes.search(skill->data.attribute);
|
|
|
|
assert(attr);
|
|
|
|
|
2012-04-16 13:48:01 +00:00
|
|
|
std::string state = "normal";
|
2011-01-02 16:17:33 +00:00
|
|
|
if (modified > base)
|
2012-04-16 13:48:01 +00:00
|
|
|
state = "increased";
|
2011-01-02 16:17:33 +00:00
|
|
|
else if (modified < base)
|
2012-04-16 13:48:01 +00:00
|
|
|
state = "decreased";
|
2012-05-20 23:58:11 +00:00
|
|
|
MyGUI::TextBox* widget = addValueItem(mWindowManager.getGameSettingString(skillNameId, skillNameId),
|
2012-04-16 13:48:01 +00:00
|
|
|
boost::lexical_cast<std::string>(static_cast<int>(modified)), state, coord1, coord2);
|
2012-05-20 23:58:11 +00:00
|
|
|
|
|
|
|
for (int i=0; i<2; ++i)
|
|
|
|
{
|
2012-07-13 10:51:58 +00:00
|
|
|
mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("ToolTipType", "Layout");
|
|
|
|
mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("ToolTipLayout", "SkillToolTip");
|
|
|
|
mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("Caption_SkillName", "#{"+skillNameId+"}");
|
|
|
|
mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("Caption_SkillDescription", skill->description);
|
|
|
|
mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("Caption_SkillAttribute", "#{sGoverningAttribute}: #{" + attr->name + "}");
|
|
|
|
mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("ImageTexture_SkillImage", icon);
|
|
|
|
mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("Caption_SkillProgressText", boost::lexical_cast<std::string>(progressPercent)+"/100");
|
|
|
|
mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("Range_SkillProgress", "100");
|
|
|
|
mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("RangePosition_SkillProgress", boost::lexical_cast<std::string>(progressPercent));
|
2012-05-20 23:58:11 +00:00
|
|
|
}
|
|
|
|
|
2012-07-13 10:51:58 +00:00
|
|
|
mSkillWidgetMap[skillId] = widget;
|
2011-01-02 16:17:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void StatsWindow::updateSkillArea()
|
|
|
|
{
|
2012-05-19 12:19:21 +00:00
|
|
|
mChanged = false;
|
|
|
|
|
2012-07-13 10:51:58 +00:00
|
|
|
for (std::vector<MyGUI::WidgetPtr>::iterator it = mSkillWidgets.begin(); it != mSkillWidgets.end(); ++it)
|
2011-01-02 16:17:33 +00:00
|
|
|
{
|
|
|
|
MyGUI::Gui::getInstance().destroyWidget(*it);
|
|
|
|
}
|
2012-07-13 10:51:58 +00:00
|
|
|
mSkillWidgets.clear();
|
2011-01-02 16:17:33 +00:00
|
|
|
|
2012-07-13 10:51:58 +00:00
|
|
|
mSkillScrollerWidget->setScrollPosition(0);
|
|
|
|
onScrollChangePosition(mSkillScrollerWidget, 0);
|
|
|
|
mClientHeight = 0;
|
2012-05-19 12:55:09 +00:00
|
|
|
|
2011-01-02 16:17:33 +00:00
|
|
|
const int valueSize = 40;
|
2012-07-13 10:51:58 +00:00
|
|
|
MyGUI::IntCoord coord1(10, 0, mSkillClientWidget->getWidth() - (10 + valueSize), 18);
|
2011-01-02 16:17:33 +00:00
|
|
|
MyGUI::IntCoord coord2(coord1.left + coord1.width, coord1.top, valueSize, coord1.height);
|
|
|
|
|
2012-07-13 10:51:58 +00:00
|
|
|
if (!mMajorSkills.empty())
|
|
|
|
addSkills(mMajorSkills, "sSkillClassMajor", "Major Skills", coord1, coord2);
|
2011-01-02 16:17:33 +00:00
|
|
|
|
2012-07-13 10:51:58 +00:00
|
|
|
if (!mMinorSkills.empty())
|
|
|
|
addSkills(mMinorSkills, "sSkillClassMinor", "Minor Skills", coord1, coord2);
|
2011-01-02 16:17:33 +00:00
|
|
|
|
2012-07-13 10:51:58 +00:00
|
|
|
if (!mMiscSkills.empty())
|
|
|
|
addSkills(mMiscSkills, "sSkillClassMisc", "Misc Skills", coord1, coord2);
|
2011-01-02 16:17:33 +00:00
|
|
|
|
2011-04-21 08:49:45 +00:00
|
|
|
const ESMS::ESMStore &store = mWindowManager.getStore();
|
2011-01-02 16:17:33 +00:00
|
|
|
|
2012-05-21 03:14:07 +00:00
|
|
|
// race tooltip
|
|
|
|
const ESM::Race* playerRace = store.races.find (MWBase::Environment::get().getWorld()->getPlayer().getRace());
|
|
|
|
MyGUI::Widget* raceWidget;
|
|
|
|
getWidget(raceWidget, "RaceText");
|
2012-05-27 04:39:10 +00:00
|
|
|
ToolTips::createRaceToolTip(raceWidget, playerRace);
|
2012-05-21 03:14:07 +00:00
|
|
|
getWidget(raceWidget, "Race_str");
|
2012-05-27 04:39:10 +00:00
|
|
|
ToolTips::createRaceToolTip(raceWidget, playerRace);
|
2012-05-21 03:14:07 +00:00
|
|
|
|
|
|
|
// class tooltip
|
|
|
|
MyGUI::Widget* classWidget;
|
|
|
|
const ESM::Class& playerClass = MWBase::Environment::get().getWorld()->getPlayer().getClass();
|
|
|
|
getWidget(classWidget, "ClassText");
|
2012-05-27 04:39:10 +00:00
|
|
|
ToolTips::createClassToolTip(classWidget, playerClass);
|
2012-05-21 03:14:07 +00:00
|
|
|
getWidget(classWidget, "Class_str");
|
2012-05-27 04:39:10 +00:00
|
|
|
ToolTips::createClassToolTip(classWidget, playerClass);
|
2012-05-21 03:14:07 +00:00
|
|
|
|
2012-05-19 12:19:21 +00:00
|
|
|
if (!mFactions.empty())
|
2011-01-02 16:17:33 +00:00
|
|
|
{
|
|
|
|
// Add a line separator if there are items above
|
2012-07-13 10:51:58 +00:00
|
|
|
if (!mSkillWidgets.empty())
|
2011-01-02 16:17:33 +00:00
|
|
|
addSeparator(coord1, coord2);
|
|
|
|
|
2011-02-21 19:36:35 +00:00
|
|
|
addGroup(mWindowManager.getGameSettingString("sFaction", "Faction"), coord1, coord2);
|
2012-05-19 12:19:21 +00:00
|
|
|
FactionList::const_iterator end = mFactions.end();
|
|
|
|
for (FactionList::const_iterator it = mFactions.begin(); it != end; ++it)
|
2011-01-02 16:17:33 +00:00
|
|
|
{
|
|
|
|
const ESM::Faction *faction = store.factions.find(it->first);
|
2012-05-21 00:58:06 +00:00
|
|
|
MyGUI::Widget* w = addItem(faction->name, coord1, coord2);
|
|
|
|
|
|
|
|
std::string text;
|
|
|
|
|
|
|
|
text += std::string("#DDC79E") + faction->name;
|
|
|
|
text += std::string("\n#BF9959") + faction->ranks[it->second];
|
|
|
|
|
2012-05-21 03:19:20 +00:00
|
|
|
if (it->second < 9)
|
2012-05-21 00:58:06 +00:00
|
|
|
{
|
|
|
|
// player doesn't have max rank yet
|
|
|
|
text += std::string("\n\n#DDC79E#{sNextRank} ") + faction->ranks[it->second+1];
|
|
|
|
|
|
|
|
ESM::RankData rankData = faction->data.rankData[it->second+1];
|
|
|
|
const ESM::Attribute* attr1 = mWindowManager.getStore().attributes.search(faction->data.attribute1);
|
|
|
|
const ESM::Attribute* attr2 = mWindowManager.getStore().attributes.search(faction->data.attribute2);
|
|
|
|
assert(attr1 && attr2);
|
|
|
|
|
|
|
|
text += "\n#BF9959#{" + attr1->name + "}: " + boost::lexical_cast<std::string>(rankData.attribute1)
|
|
|
|
+ ", #{" + attr2->name + "}: " + boost::lexical_cast<std::string>(rankData.attribute2);
|
|
|
|
|
|
|
|
text += "\n\n#DDC79E#{sFavoriteSkills}";
|
|
|
|
text += "\n#BF9959";
|
|
|
|
for (int i=0; i<6; ++i)
|
|
|
|
{
|
|
|
|
const ESM::Skill* skill = mWindowManager.getStore().skills.search(faction->data.skillID[i]);
|
|
|
|
assert(skill);
|
|
|
|
text += "#{"+ESM::Skill::sSkillNameIds[faction->data.skillID[i]]+"}";
|
|
|
|
if (i<5)
|
|
|
|
text += ", ";
|
|
|
|
}
|
|
|
|
|
|
|
|
text += "\n";
|
|
|
|
|
|
|
|
if (rankData.skill1 > 0)
|
|
|
|
text += "\n#{sNeedOneSkill} " + boost::lexical_cast<std::string>(rankData.skill1);
|
|
|
|
if (rankData.skill2 > 0)
|
|
|
|
text += "\n#{sNeedTwoSkills} " + boost::lexical_cast<std::string>(rankData.skill2);
|
|
|
|
}
|
|
|
|
|
|
|
|
w->setUserString("ToolTipType", "Layout");
|
|
|
|
w->setUserString("ToolTipLayout", "TextToolTip");
|
|
|
|
w->setUserString("Caption_Text", text);
|
2011-01-02 16:17:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-13 10:51:58 +00:00
|
|
|
if (!mBirthSignId.empty())
|
2011-01-02 16:17:33 +00:00
|
|
|
{
|
|
|
|
// Add a line separator if there are items above
|
2012-07-13 10:51:58 +00:00
|
|
|
if (!mSkillWidgets.empty())
|
2011-01-02 16:17:33 +00:00
|
|
|
addSeparator(coord1, coord2);
|
|
|
|
|
2012-05-11 06:45:03 +00:00
|
|
|
addGroup(mWindowManager.getGameSettingString("sBirthSign", "Sign"), coord1, coord2);
|
2012-07-13 10:51:58 +00:00
|
|
|
const ESM::BirthSign *sign = store.birthSigns.find(mBirthSignId);
|
2012-05-20 20:45:30 +00:00
|
|
|
MyGUI::Widget* w = addItem(sign->name, coord1, coord2);
|
|
|
|
|
2012-07-13 10:51:58 +00:00
|
|
|
ToolTips::createBirthsignToolTip(w, mBirthSignId);
|
2011-01-02 16:17:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Add a line separator if there are items above
|
2012-07-13 10:51:58 +00:00
|
|
|
if (!mSkillWidgets.empty())
|
2011-01-02 16:17:33 +00:00
|
|
|
addSeparator(coord1, coord2);
|
|
|
|
|
2012-04-15 19:14:14 +00:00
|
|
|
addValueItem(mWindowManager.getGameSettingString("sReputation", "Reputation"),
|
2012-07-13 10:51:58 +00:00
|
|
|
boost::lexical_cast<std::string>(static_cast<int>(mReputation)), "normal", coord1, coord2);
|
2012-05-20 23:58:11 +00:00
|
|
|
|
|
|
|
for (int i=0; i<2; ++i)
|
|
|
|
{
|
2012-07-13 10:51:58 +00:00
|
|
|
mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("ToolTipType", "Layout");
|
|
|
|
mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("ToolTipLayout", "TextToolTip");
|
|
|
|
mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("Caption_Text", "#{sSkillsMenuReputationHelp}");
|
2012-05-20 23:58:11 +00:00
|
|
|
}
|
2012-07-03 10:30:50 +00:00
|
|
|
|
2012-04-15 19:14:14 +00:00
|
|
|
addValueItem(mWindowManager.getGameSettingString("sBounty", "Bounty"),
|
2012-07-13 10:51:58 +00:00
|
|
|
boost::lexical_cast<std::string>(static_cast<int>(mBounty)), "normal", coord1, coord2);
|
2011-01-02 16:17:33 +00:00
|
|
|
|
2012-05-20 23:58:11 +00:00
|
|
|
for (int i=0; i<2; ++i)
|
|
|
|
{
|
2012-07-13 10:51:58 +00:00
|
|
|
mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("ToolTipType", "Layout");
|
|
|
|
mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("ToolTipLayout", "TextToolTip");
|
|
|
|
mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("Caption_Text", "#{sCrimeHelp}");
|
2012-05-20 23:58:11 +00:00
|
|
|
}
|
|
|
|
|
2012-07-13 10:51:58 +00:00
|
|
|
mClientHeight = coord1.top;
|
2011-01-02 16:17:33 +00:00
|
|
|
updateScroller();
|
|
|
|
}
|
|
|
|
|
|
|
|
void StatsWindow::updateScroller()
|
|
|
|
{
|
2012-07-13 10:51:58 +00:00
|
|
|
mSkillScrollerWidget->setScrollRange(std::max(mClientHeight - mSkillClientWidget->getHeight(), 0));
|
|
|
|
mSkillScrollerWidget->setScrollPage(std::max(mSkillClientWidget->getHeight() - sLineHeight, 0));
|
|
|
|
if (mClientHeight != 0)
|
|
|
|
mSkillScrollerWidget->setTrackSize( (mSkillAreaWidget->getHeight() / float(mClientHeight)) * mSkillScrollerWidget->getLineSize() );
|
2011-01-02 16:17:33 +00:00
|
|
|
}
|
2012-04-05 22:17:23 +00:00
|
|
|
|
|
|
|
void StatsWindow::onPinToggled()
|
|
|
|
{
|
|
|
|
mWindowManager.setHMSVisibility(!mPinned);
|
|
|
|
}
|