2010-09-14 22:01:45 +02:00
|
|
|
#include "race.hpp"
|
2010-09-12 14:06:10 +02:00
|
|
|
|
2015-01-10 02:50:43 +01:00
|
|
|
#include <MyGUI_Gui.h>
|
|
|
|
#include <MyGUI_ImageBox.h>
|
|
|
|
#include <MyGUI_ListBox.h>
|
2022-06-04 15:26:36 +02:00
|
|
|
#include <MyGUI_ScrollBar.h>
|
2023-11-23 19:52:18 +01:00
|
|
|
#include <MyGUI_UString.h>
|
2015-01-10 02:50:43 +01:00
|
|
|
|
2015-05-20 02:18:20 +02:00
|
|
|
#include <osg/Texture2D>
|
|
|
|
|
2018-08-14 23:05:43 +04:00
|
|
|
#include <components/debug/debuglog.hpp>
|
2022-09-05 19:35:15 +02:00
|
|
|
#include <components/esm3/loadbody.hpp>
|
|
|
|
#include <components/esm3/loadrace.hpp>
|
2023-07-16 20:46:54 +02:00
|
|
|
#include <components/myguiplatform/myguitexture.hpp>
|
|
|
|
#include <components/settings/values.hpp>
|
2022-09-05 19:35:15 +02:00
|
|
|
|
2012-08-12 14:36:46 +02:00
|
|
|
#include "../mwbase/environment.hpp"
|
2012-08-12 18:11:09 +02:00
|
|
|
#include "../mwbase/windowmanager.hpp"
|
2015-01-10 03:56:06 +01:00
|
|
|
#include "../mwrender/characterpreview.hpp"
|
2014-12-19 11:26:54 +01:00
|
|
|
#include "../mwworld/esmstore.hpp"
|
2012-08-12 14:36:46 +02:00
|
|
|
|
2012-05-27 06:39:10 +02:00
|
|
|
#include "tooltips.hpp"
|
|
|
|
|
2013-03-30 20:04:05 +01:00
|
|
|
namespace
|
|
|
|
{
|
2013-04-17 18:56:48 -04:00
|
|
|
int wrap(int index, int max)
|
|
|
|
{
|
|
|
|
if (index < 0)
|
|
|
|
return max - 1;
|
|
|
|
else if (index >= max)
|
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
return index;
|
|
|
|
}
|
2014-12-23 19:51:17 +01: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
|
|
|
bool sortRaces(const std::pair<ESM::RefId, std::string>& left, const std::pair<ESM::RefId, std::string>& right)
|
2014-12-23 19:51:17 +01:00
|
|
|
{
|
|
|
|
return left.second.compare(right.second) < 0;
|
|
|
|
}
|
|
|
|
|
2010-09-15 19:37:06 +02:00
|
|
|
}
|
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
namespace MWGui
|
2010-09-15 19:37:06 +02:00
|
|
|
{
|
|
|
|
|
2016-08-16 22:47:45 +02:00
|
|
|
RaceDialog::RaceDialog(osg::Group* parent, Resource::ResourceSystem* resourceSystem)
|
2013-04-17 18:56:48 -04:00
|
|
|
: WindowModal("openmw_chargen_race.layout")
|
2016-08-16 22:47:45 +02:00
|
|
|
, mParent(parent)
|
2015-05-20 02:18:20 +02:00
|
|
|
, mResourceSystem(resourceSystem)
|
2013-04-17 18:56:48 -04:00
|
|
|
, mGenderIndex(0)
|
|
|
|
, mFaceIndex(0)
|
|
|
|
, mHairIndex(0)
|
|
|
|
, mCurrentAngle(0)
|
2013-07-06 17:02:40 +02:00
|
|
|
, mPreviewDirty(true)
|
2013-04-17 18:56:48 -04:00
|
|
|
{
|
|
|
|
// Centre dialog
|
|
|
|
center();
|
|
|
|
|
|
|
|
setText("AppearanceT",
|
|
|
|
MWBase::Environment::get().getWindowManager()->getGameSettingString("sRaceMenu1", "Appearance"));
|
|
|
|
getWidget(mPreviewImage, "PreviewImage");
|
|
|
|
|
2022-08-06 11:25:27 +04:00
|
|
|
mPreviewImage->eventMouseWheel += MyGUI::newDelegate(this, &RaceDialog::onPreviewScroll);
|
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
getWidget(mHeadRotate, "HeadRotate");
|
2014-03-15 20:34:12 +01:00
|
|
|
|
|
|
|
mHeadRotate->setScrollRange(1000);
|
|
|
|
mHeadRotate->setScrollPosition(500);
|
|
|
|
mHeadRotate->setScrollViewPage(50);
|
|
|
|
mHeadRotate->setScrollPage(50);
|
2014-10-01 23:24:03 +02:00
|
|
|
mHeadRotate->setScrollWheelPage(50);
|
2013-04-17 18:56:48 -04:00
|
|
|
mHeadRotate->eventScrollChangePosition += MyGUI::newDelegate(this, &RaceDialog::onHeadRotate);
|
|
|
|
|
|
|
|
// Set up next/previous buttons
|
|
|
|
MyGUI::Button *prevButton, *nextButton;
|
|
|
|
|
|
|
|
setText("GenderChoiceT",
|
|
|
|
MWBase::Environment::get().getWindowManager()->getGameSettingString("sRaceMenu2", "Change Sex"));
|
|
|
|
getWidget(prevButton, "PrevGenderButton");
|
|
|
|
getWidget(nextButton, "NextGenderButton");
|
|
|
|
prevButton->eventMouseButtonClick += MyGUI::newDelegate(this, &RaceDialog::onSelectPreviousGender);
|
|
|
|
nextButton->eventMouseButtonClick += MyGUI::newDelegate(this, &RaceDialog::onSelectNextGender);
|
|
|
|
|
|
|
|
setText("FaceChoiceT",
|
|
|
|
MWBase::Environment::get().getWindowManager()->getGameSettingString("sRaceMenu3", "Change Face"));
|
|
|
|
getWidget(prevButton, "PrevFaceButton");
|
|
|
|
getWidget(nextButton, "NextFaceButton");
|
|
|
|
prevButton->eventMouseButtonClick += MyGUI::newDelegate(this, &RaceDialog::onSelectPreviousFace);
|
|
|
|
nextButton->eventMouseButtonClick += MyGUI::newDelegate(this, &RaceDialog::onSelectNextFace);
|
|
|
|
|
|
|
|
setText("HairChoiceT",
|
|
|
|
MWBase::Environment::get().getWindowManager()->getGameSettingString("sRaceMenu4", "Change Hair"));
|
|
|
|
getWidget(prevButton, "PrevHairButton");
|
|
|
|
getWidget(nextButton, "NextHairButton");
|
|
|
|
prevButton->eventMouseButtonClick += MyGUI::newDelegate(this, &RaceDialog::onSelectPreviousHair);
|
|
|
|
nextButton->eventMouseButtonClick += MyGUI::newDelegate(this, &RaceDialog::onSelectNextHair);
|
|
|
|
|
|
|
|
setText("RaceT", MWBase::Environment::get().getWindowManager()->getGameSettingString("sRaceMenu5", "Race"));
|
|
|
|
getWidget(mRaceList, "RaceList");
|
|
|
|
mRaceList->setScrollVisible(true);
|
2014-01-28 20:12:37 +01:00
|
|
|
mRaceList->eventListSelectAccept += MyGUI::newDelegate(this, &RaceDialog::onAccept);
|
2013-04-17 18:56:48 -04:00
|
|
|
mRaceList->eventListChangePosition += MyGUI::newDelegate(this, &RaceDialog::onSelectRace);
|
|
|
|
|
|
|
|
setText("SkillsT",
|
|
|
|
MWBase::Environment::get().getWindowManager()->getGameSettingString("sBonusSkillTitle", "Skill Bonus"));
|
|
|
|
getWidget(mSkillList, "SkillList");
|
|
|
|
setText("SpellPowerT",
|
|
|
|
MWBase::Environment::get().getWindowManager()->getGameSettingString("sRaceMenu7", "Specials"));
|
|
|
|
getWidget(mSpellPowerList, "SpellPowerList");
|
|
|
|
|
|
|
|
MyGUI::Button* backButton;
|
|
|
|
getWidget(backButton, "BackButton");
|
|
|
|
backButton->eventMouseButtonClick += MyGUI::newDelegate(this, &RaceDialog::onBackClicked);
|
|
|
|
|
|
|
|
MyGUI::Button* okButton;
|
|
|
|
getWidget(okButton, "OKButton");
|
2023-11-22 22:02:06 +01:00
|
|
|
okButton->setCaption(
|
|
|
|
MyGUI::UString(MWBase::Environment::get().getWindowManager()->getGameSettingString("sOK", {})));
|
2013-04-17 18:56:48 -04:00
|
|
|
okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &RaceDialog::onOkClicked);
|
2010-09-12 14:06:10 +02:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
updateRaces();
|
|
|
|
updateSkills();
|
|
|
|
updateSpellPowers();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RaceDialog::setNextButtonShow(bool shown)
|
|
|
|
{
|
|
|
|
MyGUI::Button* okButton;
|
|
|
|
getWidget(okButton, "OKButton");
|
|
|
|
|
|
|
|
if (shown)
|
2022-08-24 22:16:03 +02:00
|
|
|
okButton->setCaption(
|
2023-11-22 22:02:06 +01:00
|
|
|
MyGUI::UString(MWBase::Environment::get().getWindowManager()->getGameSettingString("sNext", {})));
|
2013-04-17 18:56:48 -04:00
|
|
|
else
|
2022-08-24 22:16:03 +02:00
|
|
|
okButton->setCaption(
|
2023-11-22 22:02:06 +01:00
|
|
|
MyGUI::UString(MWBase::Environment::get().getWindowManager()->getGameSettingString("sOK", {})));
|
2013-04-17 18:56:48 -04:00
|
|
|
}
|
2013-02-25 06:57:32 +01:00
|
|
|
|
2017-09-22 17:10:53 +02:00
|
|
|
void RaceDialog::onOpen()
|
2013-04-17 18:56:48 -04:00
|
|
|
{
|
2017-09-22 17:10:53 +02:00
|
|
|
WindowModal::onOpen();
|
2012-09-24 00:42:05 +02:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
updateRaces();
|
|
|
|
updateSkills();
|
|
|
|
updateSpellPowers();
|
2012-09-24 00:42:05 +02:00
|
|
|
|
2018-10-09 10:21:12 +04:00
|
|
|
mPreviewImage->setRenderItemTexture(nullptr);
|
2014-08-13 19:30:46 +02:00
|
|
|
|
2018-10-09 10:21:12 +04:00
|
|
|
mPreview.reset(nullptr);
|
|
|
|
mPreviewTexture.reset(nullptr);
|
2014-08-13 19:30:46 +02:00
|
|
|
|
2022-05-29 13:24:48 +02:00
|
|
|
mPreview = std::make_unique<MWRender::RaceSelectionPreview>(mParent, mResourceSystem);
|
2015-05-20 02:18:20 +02:00
|
|
|
mPreview->rebuild();
|
|
|
|
mPreview->setAngle(mCurrentAngle);
|
2014-08-13 19:30:46 +02:00
|
|
|
|
2022-05-29 13:24:48 +02:00
|
|
|
mPreviewTexture
|
|
|
|
= std::make_unique<osgMyGUI::OSGTexture>(mPreview->getTexture(), mPreview->getTextureStateSet());
|
2015-05-20 02:18:20 +02:00
|
|
|
mPreviewImage->setRenderItemTexture(mPreviewTexture.get());
|
2016-02-05 20:23:41 +01:00
|
|
|
mPreviewImage->getSubWidgetMain()->_setUVSet(MyGUI::FloatRect(0.f, 0.f, 1.f, 1.f));
|
2013-04-10 00:32:05 -04:00
|
|
|
|
2015-05-20 02:18:20 +02:00
|
|
|
const ESM::NPC& proto = mPreview->getPrototype();
|
2013-04-17 18:56:48 -04:00
|
|
|
setRaceId(proto.mRace);
|
2017-04-14 23:19:48 +04:00
|
|
|
setGender(proto.isMale() ? GM_Male : GM_Female);
|
2013-04-17 18:56:48 -04:00
|
|
|
recountParts();
|
2012-11-10 21:54:43 +04:00
|
|
|
|
2023-06-03 16:30:35 +02:00
|
|
|
for (size_t i = 0; i < mAvailableHeads.size(); ++i)
|
2014-12-02 01:37:19 +01:00
|
|
|
{
|
2022-10-18 09:26:55 +02:00
|
|
|
if (mAvailableHeads[i] == proto.mHead)
|
2014-12-02 01:37:19 +01:00
|
|
|
mFaceIndex = i;
|
|
|
|
}
|
2012-11-10 19:57:50 +04:00
|
|
|
|
2023-06-03 16:30:35 +02:00
|
|
|
for (size_t i = 0; i < mAvailableHairs.size(); ++i)
|
2014-12-02 01:37:19 +01:00
|
|
|
{
|
2022-10-18 09:26:55 +02:00
|
|
|
if (mAvailableHairs[i] == proto.mHair)
|
2014-12-02 01:37:19 +01:00
|
|
|
mHairIndex = i;
|
|
|
|
}
|
2010-09-15 21:36:32 +02:00
|
|
|
|
2013-07-06 17:02:40 +02:00
|
|
|
mPreviewDirty = true;
|
2010-09-15 19:37:06 +02:00
|
|
|
|
2014-12-23 19:51:17 +01:00
|
|
|
size_t initialPos = mHeadRotate->getScrollRange() / 2 + mHeadRotate->getScrollRange() / 10;
|
|
|
|
mHeadRotate->setScrollPosition(initialPos);
|
|
|
|
onHeadRotate(mHeadRotate, initialPos);
|
2017-09-23 12:55:28 +02:00
|
|
|
|
2019-06-09 02:08:09 +03:00
|
|
|
MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(mRaceList);
|
2014-12-23 19:51:17 +01:00
|
|
|
}
|
2013-04-17 18:56:48 -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 RaceDialog::setRaceId(const ESM::RefId& raceId)
|
2010-09-14 14:16:26 +02:00
|
|
|
{
|
2013-04-17 18:56:48 -04:00
|
|
|
mCurrentRaceId = raceId;
|
|
|
|
mRaceList->setIndexSelected(MyGUI::ITEM_NONE);
|
|
|
|
size_t count = mRaceList->getItemCount();
|
|
|
|
for (size_t i = 0; i < count; ++i)
|
2010-09-14 14:16:26 +02:00
|
|
|
{
|
2022-11-18 01:55:07 +01:00
|
|
|
if (*mRaceList->getItemDataAt<ESM::RefId>(i) == raceId)
|
2013-04-17 18:56:48 -04:00
|
|
|
{
|
|
|
|
mRaceList->setIndexSelected(i);
|
|
|
|
break;
|
|
|
|
}
|
2010-09-14 14:16:26 +02:00
|
|
|
}
|
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
updateSkills();
|
|
|
|
updateSpellPowers();
|
|
|
|
}
|
2010-09-14 14:16:26 +02:00
|
|
|
|
2017-09-22 17:10:53 +02:00
|
|
|
void RaceDialog::onClose()
|
2013-04-17 18:56:48 -04:00
|
|
|
{
|
2017-09-24 13:57:09 +02:00
|
|
|
WindowModal::onClose();
|
|
|
|
|
2018-10-09 10:21:12 +04:00
|
|
|
mPreviewImage->setRenderItemTexture(nullptr);
|
2015-05-20 02:18:20 +02:00
|
|
|
|
2018-10-09 10:21:12 +04:00
|
|
|
mPreviewTexture.reset(nullptr);
|
|
|
|
mPreview.reset(nullptr);
|
2013-04-17 18:56:48 -04:00
|
|
|
}
|
2012-09-24 00:42:05 +02:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
// widget controls
|
2010-09-12 14:06:10 +02:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
void RaceDialog::onOkClicked(MyGUI::Widget* _sender)
|
|
|
|
{
|
|
|
|
if (mRaceList->getIndexSelected() == MyGUI::ITEM_NONE)
|
|
|
|
return;
|
|
|
|
eventDone(this);
|
|
|
|
}
|
2010-09-14 19:33:40 +02:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
void RaceDialog::onBackClicked(MyGUI::Widget* _sender)
|
|
|
|
{
|
|
|
|
eventBack();
|
|
|
|
}
|
2010-09-14 19:33:40 +02:00
|
|
|
|
2022-08-06 11:25:27 +04:00
|
|
|
void RaceDialog::onPreviewScroll(MyGUI::Widget*, int _delta)
|
|
|
|
{
|
|
|
|
size_t oldPos = mHeadRotate->getScrollPosition();
|
|
|
|
size_t maxPos = mHeadRotate->getScrollRange() - 1;
|
|
|
|
size_t scrollPage = mHeadRotate->getScrollWheelPage();
|
|
|
|
if (_delta < 0)
|
|
|
|
mHeadRotate->setScrollPosition(oldPos + std::min(maxPos - oldPos, scrollPage));
|
|
|
|
else
|
|
|
|
mHeadRotate->setScrollPosition(oldPos - std::min(oldPos, scrollPage));
|
|
|
|
|
|
|
|
onHeadRotate(mHeadRotate, mHeadRotate->getScrollPosition());
|
|
|
|
}
|
|
|
|
|
2014-03-15 20:34:12 +01:00
|
|
|
void RaceDialog::onHeadRotate(MyGUI::ScrollBar* scroll, size_t _position)
|
2013-04-17 18:56:48 -04:00
|
|
|
{
|
2018-09-17 14:52:43 +04:00
|
|
|
float angle = (float(_position) / (scroll->getScrollRange() - 1) - 0.5f) * osg::PI * 2;
|
2015-05-20 02:18:20 +02:00
|
|
|
mPreview->setAngle(angle);
|
|
|
|
|
2014-12-23 19:51:17 +01:00
|
|
|
mCurrentAngle = angle;
|
2013-04-17 18:56:48 -04:00
|
|
|
}
|
2010-09-12 14:06:10 +02:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
void RaceDialog::onSelectPreviousGender(MyGUI::Widget*)
|
|
|
|
{
|
|
|
|
mGenderIndex = wrap(mGenderIndex - 1, 2);
|
2012-11-10 19:57:50 +04:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
recountParts();
|
|
|
|
updatePreview();
|
|
|
|
}
|
2010-09-12 14:06:10 +02:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
void RaceDialog::onSelectNextGender(MyGUI::Widget*)
|
|
|
|
{
|
|
|
|
mGenderIndex = wrap(mGenderIndex + 1, 2);
|
2012-11-10 19:57:50 +04:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
recountParts();
|
|
|
|
updatePreview();
|
|
|
|
}
|
2010-09-12 14:06:10 +02:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
void RaceDialog::onSelectPreviousFace(MyGUI::Widget*)
|
|
|
|
{
|
2013-04-17 19:38:13 -04:00
|
|
|
mFaceIndex = wrap(mFaceIndex - 1, mAvailableHeads.size());
|
2013-04-17 18:56:48 -04:00
|
|
|
updatePreview();
|
|
|
|
}
|
2010-09-12 14:06:10 +02:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
void RaceDialog::onSelectNextFace(MyGUI::Widget*)
|
|
|
|
{
|
2013-04-17 19:38:13 -04:00
|
|
|
mFaceIndex = wrap(mFaceIndex + 1, mAvailableHeads.size());
|
2013-04-17 18:56:48 -04:00
|
|
|
updatePreview();
|
|
|
|
}
|
2010-09-12 14:06:10 +02:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
void RaceDialog::onSelectPreviousHair(MyGUI::Widget*)
|
|
|
|
{
|
2013-04-17 19:38:13 -04:00
|
|
|
mHairIndex = wrap(mHairIndex - 1, mAvailableHairs.size());
|
2013-04-17 18:56:48 -04:00
|
|
|
updatePreview();
|
|
|
|
}
|
2010-09-12 14:06:10 +02:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
void RaceDialog::onSelectNextHair(MyGUI::Widget*)
|
|
|
|
{
|
2013-04-17 19:38:13 -04:00
|
|
|
mHairIndex = wrap(mHairIndex + 1, mAvailableHairs.size());
|
2013-04-17 18:56:48 -04:00
|
|
|
updatePreview();
|
|
|
|
}
|
2010-09-12 14:06:10 +02:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
void RaceDialog::onSelectRace(MyGUI::ListBox* _sender, size_t _index)
|
|
|
|
{
|
|
|
|
if (_index == MyGUI::ITEM_NONE)
|
|
|
|
return;
|
2010-09-14 15:30:47 +02:00
|
|
|
|
2022-11-18 01:55:07 +01:00
|
|
|
ESM::RefId& raceId = *mRaceList->getItemDataAt<ESM::RefId>(_index);
|
2022-10-18 09:26:55 +02:00
|
|
|
if (mCurrentRaceId == raceId)
|
2013-04-17 18:56:48 -04:00
|
|
|
return;
|
2010-09-14 14:16:26 +02: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
|
|
|
mCurrentRaceId = raceId;
|
2012-11-10 11:41:12 +04:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
recountParts();
|
2012-11-10 19:57:50 +04:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
updatePreview();
|
|
|
|
updateSkills();
|
|
|
|
updateSpellPowers();
|
|
|
|
}
|
2012-11-10 19:57:50 +04:00
|
|
|
|
2014-01-28 20:12:37 +01:00
|
|
|
void RaceDialog::onAccept(MyGUI::ListBox* _sender, size_t _index)
|
|
|
|
{
|
|
|
|
onSelectRace(_sender, _index);
|
|
|
|
if (mRaceList->getIndexSelected() == MyGUI::ITEM_NONE)
|
|
|
|
return;
|
|
|
|
eventDone(this);
|
|
|
|
}
|
|
|
|
|
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 RaceDialog::getBodyParts(int part, std::vector<ESM::RefId>& out)
|
2013-04-18 00:19:34 +02:00
|
|
|
{
|
2013-04-17 19:38:13 -04:00
|
|
|
out.clear();
|
2023-04-20 21:07:53 +02:00
|
|
|
const MWWorld::Store<ESM::BodyPart>& store = MWBase::Environment::get().getESMStore()->get<ESM::BodyPart>();
|
2013-04-17 19:38:13 -04:00
|
|
|
|
2019-03-02 13:27:59 +04:00
|
|
|
for (const ESM::BodyPart& bodypart : store)
|
2013-04-17 19:38:13 -04:00
|
|
|
{
|
|
|
|
if (bodypart.mData.mFlags & ESM::BodyPart::BPF_NotPlayable)
|
|
|
|
continue;
|
|
|
|
if (bodypart.mData.mType != ESM::BodyPart::MT_Skin)
|
|
|
|
continue;
|
|
|
|
if (bodypart.mData.mPart != static_cast<ESM::BodyPart::MeshPart>(part))
|
|
|
|
continue;
|
|
|
|
if (mGenderIndex != (bodypart.mData.mFlags & ESM::BodyPart::BPF_Female))
|
|
|
|
continue;
|
2023-03-03 16:00:16 +01:00
|
|
|
if (ESM::isFirstPersonBodyPart(bodypart))
|
2013-04-17 19:38:13 -04:00
|
|
|
continue;
|
2022-10-18 09:26:55 +02:00
|
|
|
if (bodypart.mRace == mCurrentRaceId)
|
2013-04-17 19:38:13 -04:00
|
|
|
out.push_back(bodypart.mId);
|
|
|
|
}
|
2013-04-18 00:19:34 +02:00
|
|
|
}
|
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
void RaceDialog::recountParts()
|
|
|
|
{
|
2013-04-17 19:38:13 -04:00
|
|
|
getBodyParts(ESM::BodyPart::MP_Hair, mAvailableHairs);
|
|
|
|
getBodyParts(ESM::BodyPart::MP_Head, mAvailableHeads);
|
2013-03-30 20:04:05 +01:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
mFaceIndex = 0;
|
|
|
|
mHairIndex = 0;
|
|
|
|
}
|
2012-11-10 21:30:16 +04:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
// update widget content
|
2012-11-10 19:57:50 +04:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
void RaceDialog::updatePreview()
|
|
|
|
{
|
2015-05-20 02:18:20 +02:00
|
|
|
ESM::NPC record = mPreview->getPrototype();
|
2013-04-17 18:56:48 -04:00
|
|
|
record.mRace = mCurrentRaceId;
|
|
|
|
record.setIsMale(mGenderIndex == 0);
|
2012-11-10 11:41:12 +04:00
|
|
|
|
2016-06-06 01:04:14 +02:00
|
|
|
if (mFaceIndex >= 0 && mFaceIndex < int(mAvailableHeads.size()))
|
|
|
|
record.mHead = mAvailableHeads[mFaceIndex];
|
|
|
|
|
|
|
|
if (mHairIndex >= 0 && mHairIndex < int(mAvailableHairs.size()))
|
|
|
|
record.mHair = mAvailableHairs[mHairIndex];
|
2012-11-10 19:57:50 +04:00
|
|
|
|
2014-12-03 00:02:14 +01:00
|
|
|
try
|
|
|
|
{
|
2015-05-20 02:18:20 +02:00
|
|
|
mPreview->setPrototype(record);
|
2014-12-03 00:02:14 +01:00
|
|
|
}
|
|
|
|
catch (std::exception& e)
|
|
|
|
{
|
2018-08-14 23:05:43 +04:00
|
|
|
Log(Debug::Error) << "Error creating preview: " << e.what();
|
2014-12-03 00:02:14 +01:00
|
|
|
}
|
2012-11-10 11:41:12 +04:00
|
|
|
}
|
2010-09-12 14:06:10 +02:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
void RaceDialog::updateRaces()
|
|
|
|
{
|
|
|
|
mRaceList->removeAllItems();
|
2010-09-14 14:16:26 +02:00
|
|
|
|
2023-04-20 21:07:53 +02:00
|
|
|
const MWWorld::Store<ESM::Race>& races = MWBase::Environment::get().getESMStore()->get<ESM::Race>();
|
2011-04-21 10:49:45 +02: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
|
|
|
std::vector<std::pair<ESM::RefId, std::string>> items; // ID, name
|
2019-03-02 13:27:59 +04:00
|
|
|
for (const ESM::Race& race : races)
|
2013-04-17 18:56:48 -04:00
|
|
|
{
|
2019-03-02 13:27:59 +04:00
|
|
|
bool playable = race.mData.mFlags & ESM::Race::Playable;
|
2013-04-17 18:56:48 -04:00
|
|
|
if (!playable) // Only display playable races
|
|
|
|
continue;
|
|
|
|
|
2020-10-17 12:26:35 +04:00
|
|
|
items.emplace_back(race.mId, race.mName);
|
2014-12-23 15:28:02 +01:00
|
|
|
}
|
2014-12-23 19:51:17 +01:00
|
|
|
std::sort(items.begin(), items.end(), sortRaces);
|
2014-12-23 15:28:02 +01:00
|
|
|
|
|
|
|
int index = 0;
|
2019-03-02 13:27:59 +04:00
|
|
|
for (auto& item : items)
|
2014-12-23 15:28:02 +01:00
|
|
|
{
|
2019-03-02 13:27:59 +04:00
|
|
|
mRaceList->addItem(item.second, item.first);
|
2022-10-18 09:26:55 +02:00
|
|
|
if (item.first == mCurrentRaceId)
|
2013-04-17 18:56:48 -04:00
|
|
|
mRaceList->setIndexSelected(index);
|
|
|
|
++index;
|
|
|
|
}
|
2010-09-14 21:55:41 +02:00
|
|
|
}
|
2010-09-12 14:06:10 +02:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
void RaceDialog::updateSkills()
|
2010-09-14 21:55:41 +02:00
|
|
|
{
|
2019-03-02 13:27:59 +04:00
|
|
|
for (MyGUI::Widget* widget : mSkillItems)
|
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
|
|
|
}
|
|
|
|
mSkillItems.clear();
|
2010-09-12 14:06:10 +02:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
if (mCurrentRaceId.empty())
|
|
|
|
return;
|
2010-09-14 14:16:26 +02:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
Widgets::MWSkillPtr skillWidget;
|
2023-07-16 20:46:54 +02:00
|
|
|
const int lineHeight = Settings::gui().mFontSize + 2;
|
2013-04-17 18:56:48 -04:00
|
|
|
MyGUI::IntCoord coord1(0, 0, mSkillList->getWidth(), 18);
|
2010-09-12 14:06:10 +02:00
|
|
|
|
2023-04-20 21:07:53 +02:00
|
|
|
const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore();
|
2013-04-17 18:56:48 -04:00
|
|
|
const ESM::Race* race = store.get<ESM::Race>().find(mCurrentRaceId);
|
2023-06-03 10:45:32 +02:00
|
|
|
for (const auto& bonus : race->mData.mBonus)
|
2013-04-17 18:56:48 -04:00
|
|
|
{
|
2023-06-06 17:24:22 +02:00
|
|
|
ESM::RefId skill = ESM::Skill::indexToRefId(bonus.mSkill);
|
|
|
|
if (skill.empty()) // Skip unknown skill indexes
|
2013-04-17 18:56:48 -04:00
|
|
|
continue;
|
2010-09-14 14:16:26 +02:00
|
|
|
|
2023-06-03 10:45:32 +02:00
|
|
|
skillWidget = mSkillList->createWidget<Widgets::MWSkill>("MW_StatNameValue", coord1, MyGUI::Align::Default);
|
2023-06-06 17:24:22 +02:00
|
|
|
skillWidget->setSkillId(skill);
|
2023-06-03 10:45:32 +02:00
|
|
|
skillWidget->setSkillValue(Widgets::MWSkill::SkillValue(static_cast<float>(bonus.mBonus), 0.f));
|
2023-06-06 17:24:22 +02:00
|
|
|
ToolTips::createSkillToolTip(skillWidget, skill);
|
2012-05-27 06:39:10 +02:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
mSkillItems.push_back(skillWidget);
|
2010-09-12 14:06:10 +02:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
coord1.top += lineHeight;
|
|
|
|
}
|
2010-09-14 21:55:41 +02:00
|
|
|
}
|
2010-09-12 14:06:10 +02:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
void RaceDialog::updateSpellPowers()
|
2010-09-14 21:55:41 +02:00
|
|
|
{
|
2019-03-02 13:27:59 +04:00
|
|
|
for (MyGUI::Widget* widget : mSpellPowerItems)
|
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
|
|
|
}
|
|
|
|
mSpellPowerItems.clear();
|
2010-09-12 14:06:10 +02:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
if (mCurrentRaceId.empty())
|
|
|
|
return;
|
2010-09-14 14:30:12 +02:00
|
|
|
|
2023-07-16 20:46:54 +02:00
|
|
|
const int lineHeight = Settings::gui().mFontSize + 2;
|
2022-08-17 21:51:36 +04:00
|
|
|
MyGUI::IntCoord coord(0, 0, mSpellPowerList->getWidth(), lineHeight);
|
2010-09-12 14:06:10 +02:00
|
|
|
|
2023-04-20 21:07:53 +02:00
|
|
|
const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore();
|
2013-04-17 18:56:48 -04:00
|
|
|
const ESM::Race* race = store.get<ESM::Race>().find(mCurrentRaceId);
|
2010-09-12 14:06:10 +02:00
|
|
|
|
2019-03-02 13:27:59 +04:00
|
|
|
int i = 0;
|
2023-03-24 01:32:27 +01:00
|
|
|
for (const ESM::RefId& spellpower : race->mPowers.mList)
|
2013-04-17 18:56:48 -04:00
|
|
|
{
|
2015-01-10 03:01:01 +01:00
|
|
|
Widgets::MWSpellPtr spellPowerWidget = mSpellPowerList->createWidget<Widgets::MWSpell>(
|
|
|
|
"MW_StatName", coord, MyGUI::Align::Default, std::string("SpellPower") + MyGUI::utility::toString(i));
|
2013-04-17 18:56:48 -04:00
|
|
|
spellPowerWidget->setSpellId(spellpower);
|
|
|
|
spellPowerWidget->setUserString("ToolTipType", "Spell");
|
2023-03-24 01:32:27 +01:00
|
|
|
spellPowerWidget->setUserString("Spell", spellpower.serialize());
|
2010-09-12 14:06:10 +02:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
mSpellPowerItems.push_back(spellPowerWidget);
|
2010-09-12 14:06:10 +02:00
|
|
|
|
2013-04-17 18:56:48 -04:00
|
|
|
coord.top += lineHeight;
|
|
|
|
++i;
|
|
|
|
}
|
2010-09-14 21:55:41 +02:00
|
|
|
}
|
2015-01-10 03:56:06 +01:00
|
|
|
|
|
|
|
const ESM::NPC& RaceDialog::getResult() const
|
|
|
|
{
|
2015-05-20 02:18:20 +02:00
|
|
|
return mPreview->getPrototype();
|
2015-01-10 03:56:06 +01:00
|
|
|
}
|
2010-09-12 14:06:10 +02:00
|
|
|
}
|