mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-21 11:23:51 +00:00
Added display of skills in stat window, the skills are configured with MWGui::WindowManager::configureSkills().
This commit is contained in:
parent
3d01e51254
commit
0868e76ffb
5 changed files with 140 additions and 2 deletions
|
@ -42,6 +42,7 @@ set(GAMEGUI_HEADER
|
||||||
)
|
)
|
||||||
set(GAMEGUI
|
set(GAMEGUI
|
||||||
mwgui/window_manager.cpp
|
mwgui/window_manager.cpp
|
||||||
|
mwgui/layouts.cpp
|
||||||
mwgui/console.cpp
|
mwgui/console.cpp
|
||||||
mwgui/text_input.cpp
|
mwgui/text_input.cpp
|
||||||
mwgui/race.cpp
|
mwgui/race.cpp
|
||||||
|
|
107
apps/openmw/mwgui/layouts.cpp
Normal file
107
apps/openmw/mwgui/layouts.cpp
Normal file
|
@ -0,0 +1,107 @@
|
||||||
|
#include "layouts.hpp"
|
||||||
|
|
||||||
|
#include "../mwworld/class.hpp"
|
||||||
|
#include "../mwmechanics/mechanicsmanager.hpp"
|
||||||
|
#include "../mwgui/window_manager.hpp"
|
||||||
|
|
||||||
|
#include <boost/lexical_cast.hpp>
|
||||||
|
|
||||||
|
using namespace MWGui;
|
||||||
|
|
||||||
|
void StatsWindow::configureSkills (const std::set<int>& major, const std::set<int>& minor, const std::set<int>& misc)
|
||||||
|
{
|
||||||
|
majorSkills = major;
|
||||||
|
minorSkills = minor;
|
||||||
|
miscSkills = misc;
|
||||||
|
|
||||||
|
updateSkillArea();
|
||||||
|
}
|
||||||
|
|
||||||
|
void StatsWindow::addSkills(const std::set<int> &skills, const std::string &titleId, const std::string &titleDefault, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2)
|
||||||
|
{
|
||||||
|
// Get player and stats
|
||||||
|
MWWorld::Ptr ptr = environment.mWorld->getPlayerPos().getPlayer();
|
||||||
|
MWMechanics::CreatureStats& creatureStats = MWWorld::Class::get (ptr).getCreatureStats (ptr);
|
||||||
|
MWMechanics::NpcStats& npcStats = MWWorld::Class::get (ptr).getNpcStats (ptr);
|
||||||
|
|
||||||
|
WindowManager *wm = environment.mWindowManager;
|
||||||
|
MWMechanics::MechanicsManager *mm = environment.mMechanicsManager;
|
||||||
|
ESMS::ESMStore &store = environment.mWorld->getStore();
|
||||||
|
|
||||||
|
MyGUI::StaticTextPtr skillNameWidget, skillValueWidget;
|
||||||
|
const int lineHeight = 18;
|
||||||
|
|
||||||
|
// Add a line separator if there are items above
|
||||||
|
if (!skillWidgets.empty())
|
||||||
|
{
|
||||||
|
MyGUI::StaticImagePtr separator = skillAreaWidget->createWidget<MyGUI::StaticImage>("MW_HLine", MyGUI::IntCoord(2 + 10, coord1.top, coord1.width + coord2.width - 8, 18), MyGUI::Align::Default);
|
||||||
|
skillWidgets.push_back(separator);
|
||||||
|
coord1.top += separator->getHeight();
|
||||||
|
coord2.top += separator->getHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
skillNameWidget = skillAreaWidget->createWidget<MyGUI::StaticText>("SandBrightText", MyGUI::IntCoord(4, coord1.top, coord1.width + coord2.width, coord1.height), MyGUI::Align::Default);
|
||||||
|
skillNameWidget->setCaption(wm->getGameSettingString(titleId, titleDefault));
|
||||||
|
skillWidgets.push_back(skillNameWidget);
|
||||||
|
|
||||||
|
coord1.top += lineHeight;
|
||||||
|
coord2.top += lineHeight;
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
std::set<int>::const_iterator end = skills.end();
|
||||||
|
for (std::set<int>::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];
|
||||||
|
assert(skillId < sizeof(npcStats.mSkill)/sizeof(npcStats.mSkill[0]));
|
||||||
|
MWMechanics::Stat<float> &stat = npcStats.mSkill[skillId];
|
||||||
|
float base = stat.getBase();
|
||||||
|
float modified = stat.getModified();
|
||||||
|
|
||||||
|
skillNameWidget = skillAreaWidget->createWidget<MyGUI::StaticText>("SandText", coord1, MyGUI::Align::Default,
|
||||||
|
std::string("SkillName") + boost::lexical_cast<std::string>(i));
|
||||||
|
skillNameWidget->setCaption(wm->getGameSettingString(skillNameId, skillNameId));
|
||||||
|
|
||||||
|
skillValueWidget = skillAreaWidget->createWidget<MyGUI::StaticText>("SandTextRight", coord2, MyGUI::Align::Default,
|
||||||
|
std::string("SkillValue") + boost::lexical_cast<std::string>(i));
|
||||||
|
skillValueWidget->setCaption(boost::lexical_cast<std::string>(static_cast<int>(modified)));
|
||||||
|
if (modified > base)
|
||||||
|
skillValueWidget->setTextColour(MyGUI::Colour(0, 1, 0));
|
||||||
|
else if (modified < base)
|
||||||
|
skillValueWidget->setTextColour(MyGUI::Colour(1, 0, 0));
|
||||||
|
else
|
||||||
|
skillValueWidget->setTextColour(MyGUI::Colour(1, 1, 1));
|
||||||
|
|
||||||
|
skillWidgets.push_back(skillNameWidget);
|
||||||
|
skillWidgets.push_back(skillValueWidget);
|
||||||
|
|
||||||
|
coord1.top += lineHeight;
|
||||||
|
coord2.top += lineHeight;
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void StatsWindow::updateSkillArea()
|
||||||
|
{
|
||||||
|
for (std::vector<MyGUI::WidgetPtr>::iterator it = skillWidgets.begin(); it != skillWidgets.end(); ++it)
|
||||||
|
{
|
||||||
|
MyGUI::Gui::getInstance().destroyWidget(*it);
|
||||||
|
}
|
||||||
|
skillWidgets.clear();
|
||||||
|
|
||||||
|
const int valueSize = 40;
|
||||||
|
MyGUI::IntCoord coord1(14, 4, skillAreaWidget->getWidth() - (14 + valueSize + 4), 18);
|
||||||
|
MyGUI::IntCoord coord2(coord1.left + coord1.width, coord1.top, valueSize, coord1.height);
|
||||||
|
|
||||||
|
if (!majorSkills.empty())
|
||||||
|
addSkills(majorSkills, "sSkillClassMajor", "Major Skills", coord1, coord2);
|
||||||
|
|
||||||
|
if (!minorSkills.empty())
|
||||||
|
addSkills(minorSkills, "sSkillClassMinor", "Minor Skills", coord1, coord2);
|
||||||
|
|
||||||
|
if (!miscSkills.empty())
|
||||||
|
addSkills(miscSkills, "sSkillClassMisc", "Misc Skills", coord1, coord2);
|
||||||
|
}
|
|
@ -8,6 +8,11 @@
|
||||||
#include <boost/array.hpp>
|
#include <boost/array.hpp>
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <set>
|
||||||
|
|
||||||
|
#include "../mwmechanics/stat.hpp"
|
||||||
|
#include "../mwworld/environment.hpp"
|
||||||
|
#include "../mwworld/world.hpp"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This file contains classes corresponding to all the window layouts
|
This file contains classes corresponding to all the window layouts
|
||||||
|
@ -185,8 +190,9 @@ namespace MWGui
|
||||||
setText(tname, out.str().c_str());
|
setText(tname, out.str().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
StatsWindow (const ESMS::ESMStore& store)
|
StatsWindow (MWWorld::Environment& environment)
|
||||||
: Layout("openmw_stats_window_layout.xml")
|
: Layout("openmw_stats_window_layout.xml")
|
||||||
|
, environment(environment)
|
||||||
{
|
{
|
||||||
setCoord(0,0,498, 342);
|
setCoord(0,0,498, 342);
|
||||||
|
|
||||||
|
@ -209,10 +215,13 @@ namespace MWGui
|
||||||
{ 0, 0 }
|
{ 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const ESMS::ESMStore &store = environment.mWorld->getStore();
|
||||||
for (int i=0; names[i][0]; ++i)
|
for (int i=0; names[i][0]; ++i)
|
||||||
{
|
{
|
||||||
setText (names[i][0], store.gameSettings.find (names[i][1])->str);
|
setText (names[i][0], store.gameSettings.find (names[i][1])->str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getWidget(skillAreaWidget, "Skills");
|
||||||
}
|
}
|
||||||
|
|
||||||
void setPlayerName(const std::string& playerName)
|
void setPlayerName(const std::string& playerName)
|
||||||
|
@ -283,6 +292,17 @@ namespace MWGui
|
||||||
setText("LevelText", text.str());
|
setText("LevelText", text.str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void configureSkills (const std::set<int>& major, const std::set<int>& minor, const std::set<int>& misc);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void updateSkillArea();
|
||||||
|
void addSkills(const std::set<int> &skills, const std::string &titleId, const std::string &titleDefault, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2);
|
||||||
|
|
||||||
|
MWWorld::Environment& environment;
|
||||||
|
MyGUI::WidgetPtr skillAreaWidget;
|
||||||
|
std::set<int> majorSkills, minorSkills, miscSkills;
|
||||||
|
std::vector<MyGUI::WidgetPtr> skillWidgets; //< Skills and other information
|
||||||
};
|
};
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
|
|
@ -37,7 +37,7 @@ WindowManager::WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment
|
||||||
hud = new HUD(w,h);
|
hud = new HUD(w,h);
|
||||||
menu = new MainMenu(w,h);
|
menu = new MainMenu(w,h);
|
||||||
map = new MapWindow();
|
map = new MapWindow();
|
||||||
stats = new StatsWindow (environment.mWorld->getStore());
|
stats = new StatsWindow (environment);
|
||||||
#if 0
|
#if 0
|
||||||
inventory = new InventoryWindow ();
|
inventory = new InventoryWindow ();
|
||||||
#endif
|
#endif
|
||||||
|
@ -166,6 +166,11 @@ void WindowManager::setValue (const std::string& id, int value)
|
||||||
stats->setValue (id, value);
|
stats->setValue (id, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WindowManager::configureSkills (const std::set<int>& major, const std::set<int>& minor, const std::set<int>& misc)
|
||||||
|
{
|
||||||
|
stats->configureSkills (major, minor, misc);
|
||||||
|
}
|
||||||
|
|
||||||
void WindowManager::messageBox (const std::string& message, const std::vector<std::string>& buttons)
|
void WindowManager::messageBox (const std::string& message, const std::vector<std::string>& buttons)
|
||||||
{
|
{
|
||||||
std::cout << "message box: " << message << std::endl;
|
std::cout << "message box: " << message << std::endl;
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <set>
|
||||||
|
|
||||||
#include "../mwmechanics/stat.hpp"
|
#include "../mwmechanics/stat.hpp"
|
||||||
#include "mode.hpp"
|
#include "mode.hpp"
|
||||||
|
@ -137,6 +138,10 @@ namespace MWGui
|
||||||
void setValue (const std::string& id, int value);
|
void setValue (const std::string& id, int value);
|
||||||
///< set value for the given ID.
|
///< set value for the given ID.
|
||||||
|
|
||||||
|
void configureSkills (const std::set<int>& major, const std::set<int>& minor, const std::set<int>& misc);
|
||||||
|
///< configure skill groups, each set contains the skill ID for that group.
|
||||||
|
|
||||||
|
|
||||||
void messageBox (const std::string& message, const std::vector<std::string>& buttons);
|
void messageBox (const std::string& message, const std::vector<std::string>& buttons);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue