2013-04-10 00:32:05 -04:00
|
|
|
#include "statswindow.hpp"
|
|
|
|
|
2023-06-18 19:10:29 +02:00
|
|
|
#include <MyGUI_Button.h>
|
2015-01-10 02:50:43 +01:00
|
|
|
#include <MyGUI_Gui.h>
|
|
|
|
#include <MyGUI_ImageBox.h>
|
2019-04-26 11:37:57 +04:00
|
|
|
#include <MyGUI_InputManager.h>
|
2020-12-28 11:45:17 +04:00
|
|
|
#include <MyGUI_LanguageManager.h>
|
2015-01-10 02:50:43 +01:00
|
|
|
#include <MyGUI_ProgressBar.h>
|
|
|
|
#include <MyGUI_ScrollView.h>
|
2022-06-04 15:26:36 +02:00
|
|
|
#include <MyGUI_TextIterator.h>
|
2015-01-10 02:50:43 +01:00
|
|
|
#include <MyGUI_Window.h>
|
|
|
|
|
2023-07-31 16:29:14 +04:00
|
|
|
#include <components/debug/debuglog.hpp>
|
|
|
|
|
2022-09-05 19:35:15 +02:00
|
|
|
#include <components/esm3/loadbsgn.hpp>
|
|
|
|
#include <components/esm3/loadclas.hpp>
|
|
|
|
#include <components/esm3/loadfact.hpp>
|
|
|
|
#include <components/esm3/loadgmst.hpp>
|
|
|
|
#include <components/esm3/loadrace.hpp>
|
|
|
|
|
2023-04-12 00:33:36 +02:00
|
|
|
#include <components/settings/values.hpp>
|
2017-04-10 10:18:00 +04:00
|
|
|
|
2013-04-10 00:32:05 -04:00
|
|
|
#include "../mwbase/environment.hpp"
|
|
|
|
#include "../mwbase/windowmanager.hpp"
|
|
|
|
#include "../mwbase/world.hpp"
|
|
|
|
|
|
|
|
#include "../mwworld/class.hpp"
|
2015-01-10 03:56:06 +01:00
|
|
|
#include "../mwworld/esmstore.hpp"
|
2014-01-08 18:39:44 +01:00
|
|
|
#include "../mwworld/player.hpp"
|
2013-04-10 00:32:05 -04:00
|
|
|
|
2015-08-21 21:12:39 +12:00
|
|
|
#include "../mwmechanics/actorutil.hpp"
|
2013-04-10 00:32:05 -04:00
|
|
|
#include "../mwmechanics/npcstats.hpp"
|
|
|
|
|
|
|
|
#include "tooltips.hpp"
|
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
namespace MWGui
|
2013-04-10 00:32:05 -04:00
|
|
|
{
|
2014-01-26 14:47:01 +01:00
|
|
|
StatsWindow::StatsWindow(DragAndDrop* drag)
|
2013-04-17 18:56:48 -04:00
|
|
|
: WindowPinnableBase("openmw_stats_window.layout")
|
2014-01-26 14:47:01 +01:00
|
|
|
, NoDrop(drag, mMainWidget)
|
2018-10-09 10:21:12 +04:00
|
|
|
, mSkillView(nullptr)
|
2013-04-17 18:56:48 -04:00
|
|
|
, mReputation(0)
|
|
|
|
, mBounty(0)
|
|
|
|
, mChanged(true)
|
2019-07-17 00:44:36 -04:00
|
|
|
, mMinFullWidth(mMainWidget->getSize().width)
|
2013-04-10 00:32:05 -04:00
|
|
|
{
|
|
|
|
|
2023-04-20 21:07:53 +02:00
|
|
|
const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore();
|
2023-06-18 19:10:29 +02:00
|
|
|
MyGUI::Widget* attributeView = getWidget("AttributeView");
|
2023-06-18 19:55:33 +02:00
|
|
|
MyGUI::IntCoord coord{ 0, 0, 204, 18 };
|
2023-06-21 22:11:01 +02:00
|
|
|
const MyGUI::Align alignment = MyGUI::Align::Left | MyGUI::Align::Top | MyGUI::Align::HStretch;
|
2023-06-18 19:10:29 +02:00
|
|
|
for (const ESM::Attribute& attribute : store.get<ESM::Attribute>())
|
2013-04-17 18:56:48 -04:00
|
|
|
{
|
2023-06-21 22:11:01 +02:00
|
|
|
auto* box = attributeView->createWidget<MyGUI::Button>({}, coord, alignment);
|
2023-06-18 19:10:29 +02:00
|
|
|
box->setUserString("ToolTipType", "Layout");
|
|
|
|
box->setUserString("ToolTipLayout", "AttributeToolTip");
|
|
|
|
box->setUserString("Caption_AttributeName", attribute.mName);
|
|
|
|
box->setUserString("Caption_AttributeDescription", attribute.mDescription);
|
|
|
|
box->setUserString("ImageTexture_AttributeImage", attribute.mIcon);
|
2023-06-18 19:55:33 +02:00
|
|
|
coord.top += coord.height;
|
2023-06-21 22:11:01 +02:00
|
|
|
auto* name = box->createWidget<MyGUI::TextBox>("SandText", { 0, 0, 160, 18 }, alignment);
|
2023-06-18 19:10:29 +02:00
|
|
|
name->setNeedMouseFocus(false);
|
|
|
|
name->setCaption(attribute.mName);
|
|
|
|
auto* value = box->createWidget<MyGUI::TextBox>(
|
|
|
|
"SandTextRight", { 160, 0, 44, 18 }, MyGUI::Align::Right | MyGUI::Align::Top);
|
|
|
|
value->setNeedMouseFocus(false);
|
|
|
|
mAttributeWidgets.emplace(attribute.mId, value);
|
2013-04-17 18:56:48 -04:00
|
|
|
}
|
2013-04-10 00:32:05 -04:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
getWidget(mSkillView, "SkillView");
|
|
|
|
getWidget(mLeftPane, "LeftPane");
|
|
|
|
getWidget(mRightPane, "RightPane");
|
2013-04-10 00:32:05 -04:00
|
|
|
|
2023-06-06 12:35:01 +02:00
|
|
|
for (const ESM::Skill& skill : store.get<ESM::Skill>())
|
2013-04-17 18:56:48 -04:00
|
|
|
{
|
2023-06-06 12:35:01 +02:00
|
|
|
mSkillValues.emplace(skill.mId, MWMechanics::SkillValue());
|
|
|
|
mSkillWidgetMap.emplace(skill.mId, std::make_pair<MyGUI::TextBox*, MyGUI::TextBox*>(nullptr, nullptr));
|
2013-04-17 18:56:48 -04:00
|
|
|
}
|
2013-04-10 00:32:05 -04:00
|
|
|
|
2014-09-13 04:07:40 +02:00
|
|
|
MyGUI::Window* t = mMainWidget->castType<MyGUI::Window>();
|
2013-04-17 18:56:48 -04:00
|
|
|
t->eventWindowChangeCoord += MyGUI::newDelegate(this, &StatsWindow::onWindowResize);
|
2017-02-06 02:40:35 +01:00
|
|
|
|
|
|
|
onWindowResize(t);
|
2013-04-17 18:56:48 -04:00
|
|
|
}
|
2013-04-10 00:32:05 -04:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
void StatsWindow::onMouseWheel(MyGUI::Widget* _sender, int _rel)
|
|
|
|
{
|
|
|
|
if (mSkillView->getViewOffset().top + _rel * 0.3 > 0)
|
|
|
|
mSkillView->setViewOffset(MyGUI::IntPoint(0, 0));
|
|
|
|
else
|
2015-03-08 13:07:29 +13:00
|
|
|
mSkillView->setViewOffset(
|
|
|
|
MyGUI::IntPoint(0, static_cast<int>(mSkillView->getViewOffset().top + _rel * 0.3)));
|
2013-04-17 18:56:48 -04:00
|
|
|
}
|
2013-04-10 00:32:05 -04:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
void StatsWindow::onWindowResize(MyGUI::Window* window)
|
|
|
|
{
|
2019-07-17 00:44:36 -04:00
|
|
|
int windowWidth = window->getSize().width;
|
|
|
|
int windowHeight = window->getSize().height;
|
|
|
|
|
|
|
|
// initial values defined in openmw_stats_window.layout, if custom options are not present in .layout, a default
|
|
|
|
// is loaded
|
2021-04-19 15:36:58 +04:00
|
|
|
float leftPaneRatio = 0.44f;
|
2019-07-17 00:44:36 -04:00
|
|
|
if (mLeftPane->isUserString("LeftPaneRatio"))
|
|
|
|
leftPaneRatio = MyGUI::utility::parseFloat(mLeftPane->getUserString("LeftPaneRatio"));
|
|
|
|
|
|
|
|
int leftOffsetWidth = 24;
|
|
|
|
if (mLeftPane->isUserString("LeftOffsetWidth"))
|
|
|
|
leftOffsetWidth = MyGUI::utility::parseInt(mLeftPane->getUserString("LeftOffsetWidth"));
|
|
|
|
|
|
|
|
float rightPaneRatio = 1.f - leftPaneRatio;
|
|
|
|
int minLeftWidth = static_cast<int>(mMinFullWidth * leftPaneRatio);
|
|
|
|
int minLeftOffsetWidth = minLeftWidth + leftOffsetWidth;
|
|
|
|
|
|
|
|
// if there's no space for right pane
|
|
|
|
mRightPane->setVisible(windowWidth >= minLeftOffsetWidth);
|
|
|
|
if (!mRightPane->getVisible())
|
|
|
|
{
|
|
|
|
mLeftPane->setCoord(MyGUI::IntCoord(0, 0, windowWidth - leftOffsetWidth, windowHeight));
|
|
|
|
}
|
|
|
|
// if there's some space for right pane
|
|
|
|
else if (windowWidth < mMinFullWidth)
|
|
|
|
{
|
|
|
|
mLeftPane->setCoord(MyGUI::IntCoord(0, 0, minLeftWidth, windowHeight));
|
|
|
|
mRightPane->setCoord(MyGUI::IntCoord(minLeftWidth, 0, windowWidth - minLeftWidth, windowHeight));
|
|
|
|
}
|
|
|
|
// if there's enough space for both panes
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mLeftPane->setCoord(MyGUI::IntCoord(0, 0, static_cast<int>(leftPaneRatio * windowWidth), windowHeight));
|
|
|
|
mRightPane->setCoord(MyGUI::IntCoord(static_cast<int>(leftPaneRatio * windowWidth), 0,
|
|
|
|
static_cast<int>(rightPaneRatio * windowWidth), windowHeight));
|
|
|
|
}
|
|
|
|
|
2014-07-26 02:23:42 +02:00
|
|
|
// Canvas size must be expressed with VScroll disabled, otherwise MyGUI would expand the scroll area when the
|
|
|
|
// scrollbar is hidden
|
|
|
|
mSkillView->setVisibleVScroll(false);
|
2013-07-31 18:46:32 +02:00
|
|
|
mSkillView->setCanvasSize(mSkillView->getWidth(), mSkillView->getCanvasSize().height);
|
2014-07-26 02:23:42 +02:00
|
|
|
mSkillView->setVisibleVScroll(true);
|
2013-04-17 18:56:48 -04:00
|
|
|
}
|
2013-04-10 00:32:05 -04:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
void StatsWindow::setBar(const std::string& name, const std::string& tname, int val, int max)
|
|
|
|
{
|
2014-09-13 04:07:40 +02:00
|
|
|
MyGUI::ProgressBar* pt;
|
2013-04-17 18:56:48 -04:00
|
|
|
getWidget(pt, name);
|
|
|
|
|
|
|
|
std::stringstream out;
|
|
|
|
out << val << "/" << max;
|
2017-10-15 17:03:11 +02:00
|
|
|
setText(tname, out.str());
|
2017-08-29 18:04:31 +04:00
|
|
|
|
|
|
|
pt->setProgressRange(std::max(0, max));
|
|
|
|
pt->setProgressPosition(std::max(0, val));
|
2013-04-17 18:56:48 -04:00
|
|
|
}
|
2013-04-10 00:32:05 -04:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
void StatsWindow::setPlayerName(const std::string& playerName)
|
2013-04-10 00:32:05 -04:00
|
|
|
{
|
2014-09-13 04:07:40 +02:00
|
|
|
mMainWidget->castType<MyGUI::Window>()->setCaption(playerName);
|
2013-04-17 18:56:48 -04:00
|
|
|
}
|
2013-04-10 00:32:05 -04:00
|
|
|
|
2023-08-03 20:21:44 +02:00
|
|
|
void StatsWindow::setAttribute(ESM::RefId id, const MWMechanics::AttributeValue& value)
|
2013-04-17 18:56:48 -04:00
|
|
|
{
|
2023-06-18 19:10:29 +02:00
|
|
|
auto it = mAttributeWidgets.find(id);
|
|
|
|
if (it != mAttributeWidgets.end())
|
|
|
|
{
|
|
|
|
MyGUI::TextBox* box = it->second;
|
|
|
|
box->setCaption(std::to_string(static_cast<int>(value.getModified())));
|
|
|
|
if (value.getModified() > value.getBase())
|
|
|
|
box->_setWidgetState("increased");
|
|
|
|
else if (value.getModified() < value.getBase())
|
|
|
|
box->_setWidgetState("decreased");
|
|
|
|
else
|
|
|
|
box->_setWidgetState("normal");
|
|
|
|
}
|
2013-04-17 18:56:48 -04:00
|
|
|
}
|
2013-04-10 00:32:05 -04:00
|
|
|
|
2022-10-02 23:16:43 +02:00
|
|
|
void StatsWindow::setValue(std::string_view id, const MWMechanics::DynamicStat<float>& value)
|
2013-04-10 00:32:05 -04:00
|
|
|
{
|
2017-08-29 18:04:31 +04:00
|
|
|
int current = static_cast<int>(value.getCurrent());
|
2022-02-10 20:31:27 +01:00
|
|
|
int modified = static_cast<int>(value.getModified(false));
|
2013-04-10 00:32:05 -04:00
|
|
|
|
2017-08-29 18:04:31 +04:00
|
|
|
// Fatigue can be negative
|
2022-10-02 23:16:43 +02:00
|
|
|
if (id != "FBar")
|
2017-08-29 18:04:31 +04:00
|
|
|
current = std::max(0, current);
|
|
|
|
|
2022-10-02 23:16:43 +02:00
|
|
|
setBar(std::string(id), std::string(id) + "T", current, modified);
|
2013-12-10 00:41:36 +01:00
|
|
|
|
|
|
|
// health, magicka, fatigue tooltip
|
|
|
|
MyGUI::Widget* w;
|
2017-04-30 22:39:05 +04:00
|
|
|
std::string valStr = MyGUI::utility::toString(current) + " / " + MyGUI::utility::toString(modified);
|
2022-10-02 23:16:43 +02:00
|
|
|
if (id == "HBar")
|
2013-04-17 18:56:48 -04:00
|
|
|
{
|
2013-12-10 00:41:36 +01:00
|
|
|
getWidget(w, "Health");
|
|
|
|
w->setUserString("Caption_HealthDescription", "#{sHealthDesc}\n" + valStr);
|
|
|
|
}
|
2022-10-02 23:16:43 +02:00
|
|
|
else if (id == "MBar")
|
2013-12-10 00:41:36 +01:00
|
|
|
{
|
|
|
|
getWidget(w, "Magicka");
|
2015-11-20 14:57:42 -05:00
|
|
|
w->setUserString("Caption_HealthDescription", "#{sMagDesc}\n" + valStr);
|
2013-12-10 00:41:36 +01:00
|
|
|
}
|
2022-10-02 23:16:43 +02:00
|
|
|
else if (id == "FBar")
|
2013-12-10 00:41:36 +01:00
|
|
|
{
|
|
|
|
getWidget(w, "Fatigue");
|
|
|
|
w->setUserString("Caption_HealthDescription", "#{sFatDesc}\n" + valStr);
|
2013-04-10 00:32:05 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-02 23:16:43 +02:00
|
|
|
void StatsWindow::setValue(std::string_view id, const std::string& value)
|
2013-04-10 00:32:05 -04:00
|
|
|
{
|
2022-10-02 23:16:43 +02:00
|
|
|
if (id == "name")
|
2013-04-17 18:56:48 -04:00
|
|
|
setPlayerName(value);
|
2022-10-02 23:16:43 +02:00
|
|
|
else if (id == "race")
|
2013-04-17 18:56:48 -04:00
|
|
|
setText("RaceText", value);
|
2022-10-02 23:16:43 +02:00
|
|
|
else if (id == "class")
|
2013-04-17 18:56:48 -04:00
|
|
|
setText("ClassText", value);
|
2013-04-10 00:32:05 -04:00
|
|
|
}
|
|
|
|
|
2022-10-02 23:16:43 +02:00
|
|
|
void StatsWindow::setValue(std::string_view id, int value)
|
2013-04-10 00:32:05 -04:00
|
|
|
{
|
2022-10-02 23:16:43 +02:00
|
|
|
if (id == "level")
|
2013-04-17 18:56:48 -04:00
|
|
|
{
|
|
|
|
std::ostringstream text;
|
|
|
|
text << value;
|
|
|
|
setText("LevelText", text.str());
|
|
|
|
}
|
2013-04-10 00:32:05 -04:00
|
|
|
}
|
|
|
|
|
2023-06-05 21:21:30 +02:00
|
|
|
void setSkillProgress(MyGUI::Widget* w, float progress, ESM::RefId skillId)
|
2017-02-06 02:40:35 +01:00
|
|
|
{
|
|
|
|
MWWorld::Ptr player = MWMechanics::getPlayer();
|
2023-04-20 21:07:53 +02:00
|
|
|
const MWWorld::ESMStore& esmStore = *MWBase::Environment::get().getESMStore();
|
2017-02-06 02:40:35 +01:00
|
|
|
|
|
|
|
float progressRequirement = player.getClass().getNpcStats(player).getSkillProgressRequirement(
|
|
|
|
skillId, *esmStore.get<ESM::Class>().find(player.get<ESM::NPC>()->mBase->mClass));
|
|
|
|
|
|
|
|
// This is how vanilla MW displays the progress bar (I think). Note it's slightly inaccurate,
|
|
|
|
// due to the int casting in the skill levelup logic. Also the progress label could in rare cases
|
|
|
|
// reach 100% without the skill levelling up.
|
|
|
|
// Leaving the original display logic for now, for consistency with ess-imported savegames.
|
|
|
|
int progressPercent = int(float(progress) / float(progressRequirement) * 100.f + 0.5f);
|
|
|
|
|
|
|
|
w->setUserString("Caption_SkillProgressText", MyGUI::utility::toString(progressPercent) + "/100");
|
|
|
|
w->setUserString("RangePosition_SkillProgress", MyGUI::utility::toString(progressPercent));
|
|
|
|
}
|
|
|
|
|
2023-06-06 12:35:01 +02:00
|
|
|
void StatsWindow::setValue(ESM::RefId id, const MWMechanics::SkillValue& value)
|
2013-04-10 00:32:05 -04:00
|
|
|
{
|
2023-06-06 12:35:01 +02:00
|
|
|
mSkillValues[id] = value;
|
|
|
|
std::pair<MyGUI::TextBox*, MyGUI::TextBox*> widgets = mSkillWidgetMap[id];
|
2017-02-06 02:40:35 +01:00
|
|
|
MyGUI::TextBox* valueWidget = widgets.second;
|
|
|
|
MyGUI::TextBox* nameWidget = widgets.first;
|
|
|
|
if (valueWidget && nameWidget)
|
2013-04-17 18:56:48 -04:00
|
|
|
{
|
2014-01-13 07:05:52 +01:00
|
|
|
int modified = value.getModified(), base = value.getBase();
|
2015-01-10 03:01:01 +01:00
|
|
|
std::string text = MyGUI::utility::toString(modified);
|
2013-04-17 18:56:48 -04:00
|
|
|
std::string state = "normal";
|
|
|
|
if (modified > base)
|
|
|
|
state = "increased";
|
|
|
|
else if (modified < base)
|
|
|
|
state = "decreased";
|
|
|
|
|
2017-02-06 02:40:35 +01:00
|
|
|
int widthBefore = valueWidget->getTextSize().width;
|
|
|
|
|
|
|
|
valueWidget->setCaption(text);
|
|
|
|
valueWidget->_setWidgetState(state);
|
|
|
|
|
|
|
|
int widthAfter = valueWidget->getTextSize().width;
|
|
|
|
if (widthBefore != widthAfter)
|
|
|
|
{
|
|
|
|
valueWidget->setCoord(valueWidget->getLeft() - (widthAfter - widthBefore), valueWidget->getTop(),
|
|
|
|
valueWidget->getWidth() + (widthAfter - widthBefore), valueWidget->getHeight());
|
|
|
|
nameWidget->setSize(nameWidget->getWidth() - (widthAfter - widthBefore), nameWidget->getHeight());
|
|
|
|
}
|
|
|
|
|
2017-03-12 17:24:43 -07:00
|
|
|
if (value.getBase() < 100)
|
|
|
|
{
|
|
|
|
nameWidget->setUserString("Visible_SkillMaxed", "false");
|
|
|
|
nameWidget->setUserString("UserData^Hidden_SkillMaxed", "true");
|
|
|
|
nameWidget->setUserString("Visible_SkillProgressVBox", "true");
|
|
|
|
nameWidget->setUserString("UserData^Hidden_SkillProgressVBox", "false");
|
|
|
|
|
|
|
|
valueWidget->setUserString("Visible_SkillMaxed", "false");
|
|
|
|
valueWidget->setUserString("UserData^Hidden_SkillMaxed", "true");
|
|
|
|
valueWidget->setUserString("Visible_SkillProgressVBox", "true");
|
|
|
|
valueWidget->setUserString("UserData^Hidden_SkillProgressVBox", "false");
|
|
|
|
|
2023-06-05 21:21:30 +02:00
|
|
|
setSkillProgress(nameWidget, value.getProgress(), id);
|
|
|
|
setSkillProgress(valueWidget, value.getProgress(), id);
|
2017-03-13 13:57:05 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-03-12 17:02:07 -07:00
|
|
|
nameWidget->setUserString("Visible_SkillMaxed", "true");
|
|
|
|
nameWidget->setUserString("UserData^Hidden_SkillMaxed", "false");
|
|
|
|
nameWidget->setUserString("Visible_SkillProgressVBox", "false");
|
|
|
|
nameWidget->setUserString("UserData^Hidden_SkillProgressVBox", "true");
|
|
|
|
|
|
|
|
valueWidget->setUserString("Visible_SkillMaxed", "true");
|
|
|
|
valueWidget->setUserString("UserData^Hidden_SkillMaxed", "false");
|
|
|
|
valueWidget->setUserString("Visible_SkillProgressVBox", "false");
|
|
|
|
valueWidget->setUserString("UserData^Hidden_SkillProgressVBox", "true");
|
2017-03-12 16:44:56 -07:00
|
|
|
}
|
2013-04-17 18:56:48 -04:00
|
|
|
}
|
2013-04-10 00:32:05 -04:00
|
|
|
}
|
|
|
|
|
2023-06-06 19:17:03 +02:00
|
|
|
void StatsWindow::configureSkills(const std::vector<ESM::RefId>& major, const std::vector<ESM::RefId>& minor)
|
2013-04-17 18:56:48 -04:00
|
|
|
{
|
|
|
|
mMajorSkills = major;
|
|
|
|
mMinorSkills = minor;
|
|
|
|
|
|
|
|
// Update misc skills with the remaining skills not in major or minor
|
2023-06-06 19:17:03 +02:00
|
|
|
std::set<ESM::RefId> skillSet;
|
2013-04-17 18:56:48 -04:00
|
|
|
std::copy(major.begin(), major.end(), std::inserter(skillSet, skillSet.begin()));
|
|
|
|
std::copy(minor.begin(), minor.end(), std::inserter(skillSet, skillSet.begin()));
|
|
|
|
mMiscSkills.clear();
|
2023-05-27 21:54:13 +02:00
|
|
|
const auto& store = MWBase::Environment::get().getWorld()->getStore().get<ESM::Skill>();
|
|
|
|
for (const auto& skill : store)
|
2013-04-17 18:56:48 -04:00
|
|
|
{
|
2023-06-06 19:17:03 +02:00
|
|
|
if (!skillSet.contains(skill.mId))
|
|
|
|
mMiscSkills.push_back(skill.mId);
|
2013-04-17 18:56:48 -04:00
|
|
|
}
|
2013-04-10 00:32:05 -04:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
updateSkillArea();
|
|
|
|
}
|
2013-04-10 00:32:05 -04:00
|
|
|
|
2014-01-26 14:47:01 +01:00
|
|
|
void StatsWindow::onFrame(float dt)
|
2013-04-10 00:32:05 -04:00
|
|
|
{
|
2014-01-26 14:47:01 +01:00
|
|
|
NoDrop::onFrame(dt);
|
|
|
|
|
2015-08-21 21:12:39 +12:00
|
|
|
MWWorld::Ptr player = MWMechanics::getPlayer();
|
2014-05-22 20:37:22 +02:00
|
|
|
const MWMechanics::NpcStats& PCstats = player.getClass().getNpcStats(player);
|
2023-05-28 15:10:53 +02:00
|
|
|
const auto& store = MWBase::Environment::get().getESMStore();
|
2013-04-10 00:32:05 -04:00
|
|
|
|
2022-08-16 01:43:28 +03:00
|
|
|
std::stringstream detail;
|
2023-05-22 14:32:08 +02:00
|
|
|
bool first = true;
|
2023-05-28 15:10:53 +02:00
|
|
|
for (const auto& attribute : store->get<ESM::Attribute>())
|
2022-08-16 01:43:28 +03:00
|
|
|
{
|
2023-05-28 15:10:53 +02:00
|
|
|
float mult = PCstats.getLevelupAttributeMultiplier(attribute.mId);
|
|
|
|
mult = std::min(mult, 100 - PCstats.getAttribute(attribute.mId).getBase());
|
2022-08-16 01:43:28 +03:00
|
|
|
if (mult > 1)
|
2023-05-21 16:39:32 +02:00
|
|
|
{
|
2023-05-22 14:32:08 +02:00
|
|
|
if (!first)
|
2023-05-21 16:39:32 +02:00
|
|
|
detail << '\n';
|
2023-05-31 17:02:18 +02:00
|
|
|
detail << attribute.mName << " x" << MyGUI::utility::toString(mult);
|
2023-05-22 14:32:08 +02:00
|
|
|
first = false;
|
2023-05-21 16:39:32 +02:00
|
|
|
}
|
2022-08-16 01:43:28 +03:00
|
|
|
}
|
2023-05-31 17:02:18 +02:00
|
|
|
std::string detailText = detail.str();
|
2022-08-16 01:43:28 +03:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
// level progress
|
|
|
|
MyGUI::Widget* levelWidget;
|
|
|
|
for (int i = 0; i < 2; ++i)
|
|
|
|
{
|
2023-05-28 15:10:53 +02:00
|
|
|
int max = store->get<ESM::GameSetting>().find("iLevelUpTotal")->mValue.getInteger();
|
2013-04-17 18:56:48 -04:00
|
|
|
getWidget(levelWidget, i == 0 ? "Level_str" : "LevelText");
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2015-01-10 03:01:01 +01:00
|
|
|
levelWidget->setUserString(
|
|
|
|
"RangePosition_LevelProgress", MyGUI::utility::toString(PCstats.getLevelProgress()));
|
|
|
|
levelWidget->setUserString("Range_LevelProgress", MyGUI::utility::toString(max));
|
|
|
|
levelWidget->setUserString("Caption_LevelProgressText",
|
|
|
|
MyGUI::utility::toString(PCstats.getLevelProgress()) + "/" + MyGUI::utility::toString(max));
|
2022-08-16 01:43:28 +03:00
|
|
|
levelWidget->setUserString("Caption_LevelDetailText", detailText);
|
2013-04-17 18:56:48 -04:00
|
|
|
}
|
2013-04-10 00:32:05 -04:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
setFactions(PCstats.getFactionRanks());
|
|
|
|
setExpelled(PCstats.getExpelled());
|
2013-04-10 00:32:05 -04:00
|
|
|
|
2022-10-13 23:14:00 +02:00
|
|
|
const auto& signId = MWBase::Environment::get().getWorld()->getPlayer().getBirthSign();
|
2013-04-10 00:32:05 -04:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
setBirthSign(signId);
|
|
|
|
setReputation(PCstats.getReputation());
|
|
|
|
setBounty(PCstats.getBounty());
|
2013-04-10 00:32:05 -04:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
if (mChanged)
|
|
|
|
updateSkillArea();
|
2013-04-10 00:32:05 -04:00
|
|
|
}
|
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
void StatsWindow::setFactions(const FactionList& factions)
|
2013-04-10 00:32:05 -04:00
|
|
|
{
|
2013-04-17 18:56:48 -04:00
|
|
|
if (mFactions != factions)
|
|
|
|
{
|
|
|
|
mFactions = factions;
|
|
|
|
mChanged = true;
|
|
|
|
}
|
2013-04-10 00:32:05 -04:00
|
|
|
}
|
|
|
|
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
void StatsWindow::setExpelled(const std::set<ESM::RefId>& expelled)
|
2013-04-10 00:32:05 -04:00
|
|
|
{
|
2013-04-17 18:56:48 -04:00
|
|
|
if (mExpelled != expelled)
|
|
|
|
{
|
|
|
|
mExpelled = expelled;
|
|
|
|
mChanged = true;
|
|
|
|
}
|
2013-04-10 00:32:05 -04:00
|
|
|
}
|
|
|
|
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
void StatsWindow::setBirthSign(const ESM::RefId& signId)
|
2013-04-17 18:56:48 -04:00
|
|
|
{
|
|
|
|
if (signId != mBirthSignId)
|
|
|
|
{
|
|
|
|
mBirthSignId = signId;
|
|
|
|
mChanged = true;
|
|
|
|
}
|
|
|
|
}
|
2013-04-10 00:32:05 -04:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
void StatsWindow::addSeparator(MyGUI::IntCoord& coord1, MyGUI::IntCoord& coord2)
|
|
|
|
{
|
|
|
|
MyGUI::ImageBox* separator = mSkillView->createWidget<MyGUI::ImageBox>("MW_HLine",
|
|
|
|
MyGUI::IntCoord(10, coord1.top, coord1.width + coord2.width - 4, 18),
|
|
|
|
MyGUI::Align::Left | MyGUI::Align::Top | MyGUI::Align::HStretch);
|
|
|
|
separator->eventMouseWheel += MyGUI::newDelegate(this, &StatsWindow::onMouseWheel);
|
|
|
|
mSkillWidgets.push_back(separator);
|
|
|
|
|
|
|
|
coord1.top += separator->getHeight();
|
|
|
|
coord2.top += separator->getHeight();
|
|
|
|
}
|
2013-04-10 00:32:05 -04:00
|
|
|
|
2022-08-24 22:16:03 +02:00
|
|
|
void StatsWindow::addGroup(std::string_view label, MyGUI::IntCoord& coord1, MyGUI::IntCoord& coord2)
|
2013-04-17 18:56:48 -04:00
|
|
|
{
|
|
|
|
MyGUI::TextBox* groupWidget = mSkillView->createWidget<MyGUI::TextBox>("SandBrightText",
|
|
|
|
MyGUI::IntCoord(0, coord1.top, coord1.width + coord2.width, coord1.height),
|
|
|
|
MyGUI::Align::Left | MyGUI::Align::Top | MyGUI::Align::HStretch);
|
2023-11-22 22:02:06 +01:00
|
|
|
groupWidget->setCaption(MyGUI::UString(label));
|
2013-04-17 18:56:48 -04:00
|
|
|
groupWidget->eventMouseWheel += MyGUI::newDelegate(this, &StatsWindow::onMouseWheel);
|
|
|
|
mSkillWidgets.push_back(groupWidget);
|
|
|
|
|
2023-07-16 20:46:54 +02:00
|
|
|
const int lineHeight = Settings::gui().mFontSize + 2;
|
2018-06-18 13:43:39 +04:00
|
|
|
coord1.top += lineHeight;
|
|
|
|
coord2.top += lineHeight;
|
2013-04-17 18:56:48 -04:00
|
|
|
}
|
2013-04-10 00:32:05 -04:00
|
|
|
|
2022-08-24 22:16:03 +02:00
|
|
|
std::pair<MyGUI::TextBox*, MyGUI::TextBox*> StatsWindow::addValueItem(std::string_view text,
|
|
|
|
const std::string& value, const std::string& state, MyGUI::IntCoord& coord1, MyGUI::IntCoord& coord2)
|
2013-04-17 18:56:48 -04:00
|
|
|
{
|
|
|
|
MyGUI::TextBox *skillNameWidget, *skillValueWidget;
|
2013-04-10 00:32:05 -04:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
skillNameWidget = mSkillView->createWidget<MyGUI::TextBox>(
|
|
|
|
"SandText", coord1, MyGUI::Align::Left | MyGUI::Align::Top | MyGUI::Align::HStretch);
|
2023-11-22 22:02:06 +01:00
|
|
|
skillNameWidget->setCaption(MyGUI::UString(text));
|
2013-04-17 18:56:48 -04:00
|
|
|
skillNameWidget->eventMouseWheel += MyGUI::newDelegate(this, &StatsWindow::onMouseWheel);
|
2013-04-10 00:32:05 -04:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
skillValueWidget = mSkillView->createWidget<MyGUI::TextBox>(
|
|
|
|
"SandTextRight", coord2, MyGUI::Align::Right | MyGUI::Align::Top);
|
|
|
|
skillValueWidget->setCaption(value);
|
|
|
|
skillValueWidget->_setWidgetState(state);
|
|
|
|
skillValueWidget->eventMouseWheel += MyGUI::newDelegate(this, &StatsWindow::onMouseWheel);
|
2013-04-10 00:32:05 -04:00
|
|
|
|
2014-07-19 14:04:38 +02:00
|
|
|
// resize dynamically according to text size
|
|
|
|
int textWidthPlusMargin = skillValueWidget->getTextSize().width + 12;
|
|
|
|
skillValueWidget->setCoord(
|
|
|
|
coord2.left + coord2.width - textWidthPlusMargin, coord2.top, textWidthPlusMargin, coord2.height);
|
|
|
|
skillNameWidget->setSize(skillNameWidget->getSize() + MyGUI::IntSize(coord2.width - textWidthPlusMargin, 0));
|
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
mSkillWidgets.push_back(skillNameWidget);
|
|
|
|
mSkillWidgets.push_back(skillValueWidget);
|
2013-04-10 00:32:05 -04:00
|
|
|
|
2023-07-16 20:46:54 +02:00
|
|
|
const int lineHeight = Settings::gui().mFontSize + 2;
|
2018-06-18 13:43:39 +04:00
|
|
|
coord1.top += lineHeight;
|
|
|
|
coord2.top += lineHeight;
|
2013-04-10 00:32:05 -04:00
|
|
|
|
2017-02-06 02:40:35 +01:00
|
|
|
return std::make_pair(skillNameWidget, skillValueWidget);
|
2013-04-17 18:56:48 -04:00
|
|
|
}
|
2013-04-10 00:32:05 -04:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
MyGUI::Widget* StatsWindow::addItem(const std::string& text, MyGUI::IntCoord& coord1, MyGUI::IntCoord& coord2)
|
|
|
|
{
|
|
|
|
MyGUI::TextBox* skillNameWidget;
|
2013-04-10 00:32:05 -04:00
|
|
|
|
2014-12-27 01:25:26 +01:00
|
|
|
skillNameWidget = mSkillView->createWidget<MyGUI::TextBox>("SandText", coord1, MyGUI::Align::Default);
|
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
skillNameWidget->setCaption(text);
|
|
|
|
skillNameWidget->eventMouseWheel += MyGUI::newDelegate(this, &StatsWindow::onMouseWheel);
|
2013-04-10 00:32:05 -04:00
|
|
|
|
2014-12-27 01:25:26 +01:00
|
|
|
int textWidth = skillNameWidget->getTextSize().width;
|
|
|
|
skillNameWidget->setSize(textWidth, skillNameWidget->getHeight());
|
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
mSkillWidgets.push_back(skillNameWidget);
|
2013-04-10 00:32:05 -04:00
|
|
|
|
2023-07-16 20:46:54 +02:00
|
|
|
const int lineHeight = Settings::gui().mFontSize + 2;
|
2018-06-18 13:43:39 +04:00
|
|
|
coord1.top += lineHeight;
|
|
|
|
coord2.top += lineHeight;
|
2013-04-10 00:32:05 -04:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
return skillNameWidget;
|
2013-04-10 00:32:05 -04:00
|
|
|
}
|
|
|
|
|
2023-06-06 21:02:46 +02:00
|
|
|
void StatsWindow::addSkills(const std::vector<ESM::RefId>& skills, const std::string& titleId,
|
|
|
|
const std::string& titleDefault, MyGUI::IntCoord& coord1, MyGUI::IntCoord& coord2)
|
2013-04-10 00:32:05 -04:00
|
|
|
{
|
2013-04-17 18:56:48 -04:00
|
|
|
// Add a line separator if there are items above
|
|
|
|
if (!mSkillWidgets.empty())
|
2013-04-10 00:32:05 -04:00
|
|
|
{
|
2013-04-17 18:56:48 -04:00
|
|
|
addSeparator(coord1, coord2);
|
2013-04-10 00:32:05 -04:00
|
|
|
}
|
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
addGroup(
|
|
|
|
MWBase::Environment::get().getWindowManager()->getGameSettingString(titleId, titleDefault), coord1, coord2);
|
2013-04-10 00:32:05 -04:00
|
|
|
|
2023-06-05 12:41:01 +02:00
|
|
|
const MWWorld::ESMStore& esmStore = *MWBase::Environment::get().getESMStore();
|
2023-06-06 19:17:03 +02:00
|
|
|
for (const ESM::RefId& skillId : skills)
|
2013-04-17 18:56:48 -04:00
|
|
|
{
|
2023-06-06 19:17:03 +02:00
|
|
|
const ESM::Skill* skill = esmStore.get<ESM::Skill>().search(skillId);
|
2023-06-05 12:41:01 +02:00
|
|
|
if (!skill) // Skip unknown skills
|
2013-04-17 18:56:48 -04:00
|
|
|
continue;
|
|
|
|
|
2023-07-31 16:29:14 +04:00
|
|
|
auto skillValue = mSkillValues.find(skill->mId);
|
|
|
|
if (skillValue == mSkillValues.end())
|
|
|
|
{
|
|
|
|
Log(Debug::Error) << "Failed to update stats window: can not find value for skill " << skill->mId;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2023-08-03 20:21:44 +02:00
|
|
|
const ESM::Attribute* attr
|
|
|
|
= esmStore.get<ESM::Attribute>().find(ESM::Attribute::indexToRefId(skill->mData.mAttribute));
|
2013-04-17 18:56:48 -04:00
|
|
|
|
2023-05-29 17:56:14 +02:00
|
|
|
std::pair<MyGUI::TextBox*, MyGUI::TextBox*> widgets
|
|
|
|
= addValueItem(skill->mName, {}, "normal", coord1, coord2);
|
2023-07-29 11:44:39 +04:00
|
|
|
mSkillWidgetMap[skill->mId] = std::move(widgets);
|
2013-04-17 18:56:48 -04:00
|
|
|
|
|
|
|
for (int i = 0; i < 2; ++i)
|
|
|
|
{
|
|
|
|
mSkillWidgets[mSkillWidgets.size() - 1 - i]->setUserString("ToolTipType", "Layout");
|
|
|
|
mSkillWidgets[mSkillWidgets.size() - 1 - i]->setUserString("ToolTipLayout", "SkillToolTip");
|
|
|
|
mSkillWidgets[mSkillWidgets.size() - 1 - i]->setUserString(
|
2023-05-29 17:56:14 +02:00
|
|
|
"Caption_SkillName", MyGUI::TextIterator::toTagsString(skill->mName));
|
2013-04-17 18:56:48 -04:00
|
|
|
mSkillWidgets[mSkillWidgets.size() - 1 - i]->setUserString(
|
|
|
|
"Caption_SkillDescription", skill->mDescription);
|
2023-05-31 17:02:18 +02:00
|
|
|
mSkillWidgets[mSkillWidgets.size() - 1 - i]->setUserString("Caption_SkillAttribute",
|
|
|
|
"#{sGoverningAttribute}: " + MyGUI::TextIterator::toTagsString(attr->mName));
|
2023-05-30 20:22:04 +02:00
|
|
|
mSkillWidgets[mSkillWidgets.size() - 1 - i]->setUserString("ImageTexture_SkillImage", skill->mIcon);
|
2017-02-06 02:40:35 +01:00
|
|
|
mSkillWidgets[mSkillWidgets.size() - 1 - i]->setUserString("Range_SkillProgress", "100");
|
2013-04-17 18:56:48 -04:00
|
|
|
}
|
2013-04-10 00:32:05 -04:00
|
|
|
|
2023-07-31 16:29:14 +04:00
|
|
|
setValue(skill->mId, skillValue->second);
|
2013-04-17 18:56:48 -04:00
|
|
|
}
|
2013-04-10 00:32:05 -04:00
|
|
|
}
|
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
void StatsWindow::updateSkillArea()
|
|
|
|
{
|
|
|
|
mChanged = false;
|
2013-04-10 00:32:05 -04:00
|
|
|
|
2019-03-02 13:27:59 +04:00
|
|
|
for (MyGUI::Widget* widget : mSkillWidgets)
|
2013-04-17 18:56:48 -04:00
|
|
|
{
|
2019-03-02 13:27:59 +04:00
|
|
|
MyGUI::Gui::getInstance().destroyWidget(widget);
|
2013-04-17 18:56:48 -04:00
|
|
|
}
|
|
|
|
mSkillWidgets.clear();
|
2013-04-10 00:32:05 -04:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
const int valueSize = 40;
|
|
|
|
MyGUI::IntCoord coord1(10, 0, mSkillView->getWidth() - (10 + valueSize) - 24, 18);
|
|
|
|
MyGUI::IntCoord coord2(coord1.left + coord1.width, coord1.top, valueSize, coord1.height);
|
2013-04-10 00:32:05 -04:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
if (!mMajorSkills.empty())
|
|
|
|
addSkills(mMajorSkills, "sSkillClassMajor", "Major Skills", coord1, coord2);
|
2013-04-10 00:32:05 -04:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
if (!mMinorSkills.empty())
|
|
|
|
addSkills(mMinorSkills, "sSkillClassMinor", "Minor Skills", coord1, coord2);
|
2013-04-10 00:32:05 -04:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
if (!mMiscSkills.empty())
|
|
|
|
addSkills(mMiscSkills, "sSkillClassMisc", "Misc Skills", coord1, coord2);
|
2013-04-10 00:32:05 -04:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
MWBase::World* world = MWBase::Environment::get().getWorld();
|
|
|
|
const MWWorld::ESMStore& store = world->getStore();
|
2014-01-08 18:39:44 +01:00
|
|
|
const ESM::NPC* player = world->getPlayerPtr().get<ESM::NPC>()->mBase;
|
2013-04-10 00:32:05 -04:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
// race tooltip
|
|
|
|
const ESM::Race* playerRace = store.get<ESM::Race>().find(player->mRace);
|
2013-04-10 00:32:05 -04:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
MyGUI::Widget* raceWidget;
|
|
|
|
getWidget(raceWidget, "RaceText");
|
|
|
|
ToolTips::createRaceToolTip(raceWidget, playerRace);
|
|
|
|
getWidget(raceWidget, "Race_str");
|
|
|
|
ToolTips::createRaceToolTip(raceWidget, playerRace);
|
2013-04-10 00:32:05 -04:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
// class tooltip
|
|
|
|
MyGUI::Widget* classWidget;
|
2013-04-10 00:32:05 -04:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
const ESM::Class* playerClass = store.get<ESM::Class>().find(player->mClass);
|
2013-04-10 00:32:05 -04:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
getWidget(classWidget, "ClassText");
|
|
|
|
ToolTips::createClassToolTip(classWidget, *playerClass);
|
|
|
|
getWidget(classWidget, "Class_str");
|
|
|
|
ToolTips::createClassToolTip(classWidget, *playerClass);
|
2013-04-10 00:32:05 -04:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
if (!mFactions.empty())
|
2013-04-10 00:32:05 -04:00
|
|
|
{
|
2016-10-02 17:48:54 +09:00
|
|
|
MWWorld::Ptr playerPtr = MWMechanics::getPlayer();
|
|
|
|
const MWMechanics::NpcStats& PCstats = playerPtr.getClass().getNpcStats(playerPtr);
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
const std::set<ESM::RefId>& expelled = PCstats.getExpelled();
|
2013-04-10 00:32:05 -04:00
|
|
|
|
2014-05-29 17:53:54 +02:00
|
|
|
bool firstFaction = true;
|
2019-03-02 13:27:59 +04:00
|
|
|
for (auto& factionPair : mFactions)
|
2013-04-10 00:32:05 -04:00
|
|
|
{
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID
Slowly going through all the changes to make, still hundreds of errors
a lot of functions/structures use std::string or stringview to designate an ID. So it takes time
Continues slowly replacing ids. There are technically more and more compilation errors
I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type
Continue moving forward, changes to the stores
slowly moving along
Starting to see the fruit of those changes.
still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type.
More replacements. Things are starting to get easier
I can see more and more often the issue is that the function is awaiting a RefId, but is given a string
there is less need to go down functions and to fix a long list of them.
Still moving forward, and for the first time error count is going down!
Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably
Cells are back to using string for the name, haven't fixed everything yet. Many other changes
Under the bar of 400 compilation errors.
more good progress <100 compile errors!
More progress
Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string
some more progress on other fronts
Mostly game settings clean
one error opened a lot of other errors. Down to 18, but more will prbably appear
only link errors left??
Fixed link errors
OpenMW compiles, and launches, with some issues, but still!
2022-09-25 13:17:09 +02:00
|
|
|
const ESM::RefId& factionId = factionPair.first;
|
2019-03-02 13:27:59 +04:00
|
|
|
const ESM::Faction* faction = store.get<ESM::Faction>().find(factionId);
|
2014-05-29 17:53:54 +02:00
|
|
|
if (faction->mData.mIsHidden == 1)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (firstFaction)
|
|
|
|
{
|
|
|
|
// Add a line separator if there are items above
|
|
|
|
if (!mSkillWidgets.empty())
|
|
|
|
addSeparator(coord1, coord2);
|
|
|
|
|
|
|
|
addGroup(MWBase::Environment::get().getWindowManager()->getGameSettingString("sFaction", "Faction"),
|
|
|
|
coord1, coord2);
|
|
|
|
|
|
|
|
firstFaction = false;
|
|
|
|
}
|
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
MyGUI::Widget* w = addItem(faction->mName, coord1, coord2);
|
2013-04-10 00:32:05 -04:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
std::string text;
|
2013-04-10 00:32:05 -04:00
|
|
|
|
2014-09-20 09:07:47 +02:00
|
|
|
text += std::string("#{fontcolourhtml=header}") + faction->mName;
|
2013-04-10 00:32:05 -04:00
|
|
|
|
2019-03-02 13:27:59 +04:00
|
|
|
if (expelled.find(factionId) != expelled.end())
|
2014-09-20 09:07:47 +02:00
|
|
|
text += "\n#{fontcolourhtml=normal}#{sExpelled}";
|
2013-04-17 18:56:48 -04:00
|
|
|
else
|
|
|
|
{
|
2021-11-06 07:30:28 +03:00
|
|
|
const int rank = std::clamp(factionPair.second, 0, 9);
|
2014-09-20 09:07:47 +02:00
|
|
|
text += std::string("\n#{fontcolourhtml=normal}") + faction->mRanks[rank];
|
2013-04-10 00:32:05 -04:00
|
|
|
|
2014-06-18 23:50:55 +02:00
|
|
|
if (rank < 9)
|
2013-04-10 00:32:05 -04:00
|
|
|
{
|
2013-04-17 18:56:48 -04:00
|
|
|
// player doesn't have max rank yet
|
2014-09-20 09:07:47 +02:00
|
|
|
text += std::string("\n\n#{fontcolourhtml=header}#{sNextRank} ") + faction->mRanks[rank + 1];
|
2013-04-17 18:56:48 -04:00
|
|
|
|
2023-06-03 13:11:49 +02:00
|
|
|
const ESM::RankData& rankData = faction->mData.mRankData[rank + 1];
|
2023-08-03 20:21:44 +02:00
|
|
|
const ESM::Attribute* attr1 = store.get<ESM::Attribute>().find(
|
|
|
|
ESM::Attribute::indexToRefId(faction->mData.mAttribute[0]));
|
|
|
|
const ESM::Attribute* attr2 = store.get<ESM::Attribute>().find(
|
|
|
|
ESM::Attribute::indexToRefId(faction->mData.mAttribute[1]));
|
2013-04-17 18:56:48 -04:00
|
|
|
|
2023-05-31 17:02:18 +02:00
|
|
|
text += "\n#{fontcolourhtml=normal}" + MyGUI::TextIterator::toTagsString(attr1->mName) + ": "
|
|
|
|
+ MyGUI::utility::toString(rankData.mAttribute1) + ", "
|
|
|
|
+ MyGUI::TextIterator::toTagsString(attr2->mName) + ": "
|
|
|
|
+ MyGUI::utility::toString(rankData.mAttribute2);
|
2013-04-17 18:56:48 -04:00
|
|
|
|
2014-09-20 09:07:47 +02:00
|
|
|
text += "\n\n#{fontcolourhtml=header}#{sFavoriteSkills}";
|
|
|
|
text += "\n#{fontcolourhtml=normal}";
|
2014-06-15 23:05:38 +02:00
|
|
|
bool firstSkill = true;
|
2023-06-03 13:11:49 +02:00
|
|
|
for (int id : faction->mData.mSkills)
|
2013-04-17 18:56:48 -04:00
|
|
|
{
|
2023-06-05 12:41:01 +02:00
|
|
|
const ESM::Skill* skill = store.get<ESM::Skill>().search(ESM::Skill::indexToRefId(id));
|
|
|
|
if (skill)
|
2014-06-15 23:05:38 +02:00
|
|
|
{
|
|
|
|
if (!firstSkill)
|
|
|
|
text += ", ";
|
|
|
|
|
|
|
|
firstSkill = false;
|
2023-05-29 17:56:14 +02:00
|
|
|
text += MyGUI::TextIterator::toTagsString(skill->mName);
|
2014-06-15 23:05:38 +02:00
|
|
|
}
|
2013-04-17 18:56:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
text += "\n";
|
|
|
|
|
2020-06-26 11:47:59 +04:00
|
|
|
if (rankData.mPrimarySkill > 0)
|
|
|
|
text += "\n#{sNeedOneSkill} " + MyGUI::utility::toString(rankData.mPrimarySkill);
|
|
|
|
if (rankData.mFavouredSkill > 0)
|
|
|
|
text += " #{sand} #{sNeedTwoSkills} " + MyGUI::utility::toString(rankData.mFavouredSkill);
|
2013-04-10 00:32:05 -04:00
|
|
|
}
|
|
|
|
}
|
2013-04-17 18:56:48 -04:00
|
|
|
|
|
|
|
w->setUserString("ToolTipType", "Layout");
|
2017-05-01 10:00:51 +04:00
|
|
|
w->setUserString("ToolTipLayout", "FactionToolTip");
|
|
|
|
w->setUserString("Caption_FactionText", text);
|
2013-04-10 00:32:05 -04:00
|
|
|
}
|
2013-04-17 18:56:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!mBirthSignId.empty())
|
|
|
|
{
|
|
|
|
// Add a line separator if there are items above
|
|
|
|
if (!mSkillWidgets.empty())
|
|
|
|
addSeparator(coord1, coord2);
|
2013-04-10 00:32:05 -04:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
addGroup(MWBase::Environment::get().getWindowManager()->getGameSettingString("sBirthSign", "Sign"), coord1,
|
|
|
|
coord2);
|
|
|
|
const ESM::BirthSign* sign = store.get<ESM::BirthSign>().find(mBirthSignId);
|
|
|
|
MyGUI::Widget* w = addItem(sign->mName, coord1, coord2);
|
|
|
|
|
|
|
|
ToolTips::createBirthsignToolTip(w, mBirthSignId);
|
2013-04-10 00:32:05 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Add a line separator if there are items above
|
|
|
|
if (!mSkillWidgets.empty())
|
|
|
|
addSeparator(coord1, coord2);
|
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
addValueItem(MWBase::Environment::get().getWindowManager()->getGameSettingString("sReputation", "Reputation"),
|
2015-01-10 03:01:01 +01:00
|
|
|
MyGUI::utility::toString(static_cast<int>(mReputation)), "normal", coord1, coord2);
|
2013-04-10 00:32:05 -04:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
for (int i = 0; i < 2; ++i)
|
|
|
|
{
|
|
|
|
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}");
|
|
|
|
}
|
2013-04-10 00:32:05 -04:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
addValueItem(MWBase::Environment::get().getWindowManager()->getGameSettingString("sBounty", "Bounty"),
|
2015-01-10 03:01:01 +01:00
|
|
|
MyGUI::utility::toString(static_cast<int>(mBounty)), "normal", coord1, coord2);
|
2013-04-17 18:56:48 -04:00
|
|
|
|
|
|
|
for (int i = 0; i < 2; ++i)
|
|
|
|
{
|
|
|
|
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}");
|
|
|
|
}
|
2013-04-10 00:32:05 -04:00
|
|
|
|
2014-07-26 02:23:42 +02:00
|
|
|
// Canvas size must be expressed with VScroll disabled, otherwise MyGUI would expand the scroll area when the
|
|
|
|
// scrollbar is hidden
|
|
|
|
mSkillView->setVisibleVScroll(false);
|
2013-07-31 18:46:32 +02:00
|
|
|
mSkillView->setCanvasSize(mSkillView->getWidth(), std::max(mSkillView->getHeight(), coord1.top));
|
2014-07-26 02:23:42 +02:00
|
|
|
mSkillView->setVisibleVScroll(true);
|
2013-04-10 00:32:05 -04:00
|
|
|
}
|
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
void StatsWindow::onPinToggled()
|
2013-04-10 00:32:05 -04:00
|
|
|
{
|
2023-04-12 00:33:36 +02:00
|
|
|
Settings::windows().mStatsPin.set(mPinned);
|
2017-04-10 10:18:00 +04:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
MWBase::Environment::get().getWindowManager()->setHMSVisibility(!mPinned);
|
2013-04-10 00:32:05 -04:00
|
|
|
}
|
2014-08-04 17:03:47 +02:00
|
|
|
|
|
|
|
void StatsWindow::onTitleDoubleClicked()
|
|
|
|
{
|
2019-04-26 11:37:57 +04:00
|
|
|
if (MyGUI::InputManager::getInstance().isShiftPressed())
|
|
|
|
{
|
|
|
|
MWBase::Environment::get().getWindowManager()->toggleMaximized(this);
|
|
|
|
MyGUI::Window* t = mMainWidget->castType<MyGUI::Window>();
|
|
|
|
onWindowResize(t);
|
|
|
|
}
|
|
|
|
else if (!mPinned)
|
2014-08-04 17:03:47 +02:00
|
|
|
MWBase::Environment::get().getWindowManager()->toggleVisible(GW_Stats);
|
|
|
|
}
|
2013-04-10 00:32:05 -04:00
|
|
|
}
|