store results of character creation and update GUI

actorid
Marc Zinnschlag 15 years ago
parent 5b0cb097cf
commit fff4bc29f4

@ -215,7 +215,6 @@ namespace MWGui
// These are just demo values, you should replace these with
// real calls from outside the class later.
setText("LevelText", "5");
setText("RaceText", "Wood Elf");
setText("ClassText", "Pilgrim");
}
@ -272,6 +271,8 @@ namespace MWGui
{
if (id=="name")
setPlayerName (value);
else if (id=="race")
setText ("RaceText", value);
}
};

@ -54,7 +54,7 @@ namespace MWMechanics
}
MechanicsManager::MechanicsManager (MWWorld::Environment& environment)
: mEnvironment (environment), mSetName (true)
: mEnvironment (environment), mUpdatePlayer (true)
{
buildPlayer();
}
@ -126,42 +126,48 @@ namespace MWMechanics
}
}
if (mSetName)
if (mUpdatePlayer)
{
// basic player profile; should not change anymore after the creation phase is finished.
mEnvironment.mWindowManager->setValue ("name", mEnvironment.mWorld->getPlayerPos().getName());
mSetName = false;
mEnvironment.mWindowManager->setValue ("race", mEnvironment.mWorld->getPlayerPos().getRace());
mEnvironment.mWindowManager->setValue ("class",
mEnvironment.mWorld->getPlayerPos().getClass().name);
mUpdatePlayer = false;
}
}
void MechanicsManager::setPlayerName (const std::string& name)
{
mEnvironment.mWorld->getPlayerPos().setName (name);
mSetName = true;
mUpdatePlayer = true;
}
void MechanicsManager::setPlayerRace (const std::string& race, bool male)
{
mEnvironment.mWorld->getPlayerPos().setGender (male);
mEnvironment.mWorld->getPlayerPos().setRace (race);
buildPlayer();
mUpdatePlayer = true;
}
void MechanicsManager::setPlayerBirthsign (const std::string& id)
{
mEnvironment.mWorld->getPlayerPos().setBirthsign (id);
buildPlayer();
}
void MechanicsManager::setPlayerClass (const std::string& id)
{
mEnvironment.mWorld->getPlayerPos().setClass (*mEnvironment.mWorld->getStore().classes.find (id));
buildPlayer();
mUpdatePlayer = true;
}
void MechanicsManager::setPlayerClass (const ESM::Class& class_)
{
mEnvironment.mWorld->getPlayerPos().setClass (class_);
buildPlayer();
mUpdatePlayer = true;
}
}

@ -20,7 +20,7 @@ namespace MWMechanics
std::set<MWWorld::Ptr> mActors;
MWWorld::Ptr mWatched;
CreatureStats mWatchedCreature;
bool mSetName;
bool mUpdatePlayer;
void buildPlayer();
///< build player according to stored class/race/birthsign information. Will

@ -5,6 +5,22 @@
namespace MWRender
{
PlayerPos::PlayerPos (Ogre::Camera *cam, const ESM::NPC *player, MWWorld::World& world) :
mCellStore (0), camera(cam), mWorld (world), mClass (0)
{
mPlayer.base = player;
mName = player->name;
mMale = !(player->flags & ESM::NPC::Female);
mRace = player->race;
mPlayer.ref.pos.pos[0] = mPlayer.ref.pos.pos[1] = mPlayer.ref.pos.pos[2] = 0;
mClass = new ESM::Class (*world.getStore().classes.find (player->cls));
}
PlayerPos::~PlayerPos()
{
delete mClass;
}
void PlayerPos::setPos(float x, float y, float z, bool updateCamera)
{
mWorld.moveObject (getPlayer(), x, y, z);
@ -15,4 +31,11 @@ namespace MWRender
mPlayer.ref.pos.pos[2],
-mPlayer.ref.pos.pos[1]));
}
void PlayerPos::setClass (const ESM::Class& class_)
{
ESM::Class *new_class = new ESM::Class (class_);
delete mClass;
mClass = new_class;
}
}

@ -25,15 +25,16 @@ namespace MWRender
Ogre::Camera *camera;
MWWorld::World& mWorld;
std::string mName;
bool mMale;
std::string mRace;
std::string mBirthsign;
ESM::Class *mClass;
public:
PlayerPos(Ogre::Camera *cam, const ESM::NPC *player, MWWorld::World& world) :
mCellStore (0), camera(cam), mWorld (world)
{
mPlayer.base = player;
mName = player->name;
mPlayer.ref.pos.pos[0] = mPlayer.ref.pos.pos[1] = mPlayer.ref.pos.pos[2] = 0;
}
PlayerPos(Ogre::Camera *cam, const ESM::NPC *player, MWWorld::World& world);
~PlayerPos();
// Set the player position. Uses Morrowind coordinates.
void setPos(float _x, float _y, float _z, bool updateCamera = false);
@ -81,10 +82,47 @@ namespace MWRender
mName = name;
}
void setGender (bool male)
{
mMale = male;
}
void setRace (const std::string& race)
{
mRace = race;
}
void setBirthsign (const std::string& birthsign)
{
mBirthsign = birthsign;
}
void setClass (const ESM::Class& class_);
std::string getName() const
{
return mName;
}
bool isMale() const
{
return mMale;
}
std::string getRace() const
{
return mRace;
}
std::string getBirthsign() const
{
return mBirthsign;
}
const ESM::Class& getClass() const
{
return *mClass;
}
};
}
#endif

Loading…
Cancel
Save