Merge remote branch 'zini/newchar' into gui-windows

actorid
Jan Borsodi 14 years ago
commit edb2df7d27

@ -83,4 +83,29 @@ namespace MWMechanics
}
}
}
void MechanicsManager::setPlayerName (const std::string& name)
{
}
void MechanicsManager::setPlayerRace (const std::string& race, bool male)
{
}
void MechanicsManager::setPlayerBirthsign (const std::string& id)
{
}
void MechanicsManager::setPlayerClass (const std::string& id)
{
}
void MechanicsManager::setPlayerClass (const ESM::Class& class_)
{
}
}

@ -26,30 +26,44 @@ namespace MWMechanics
std::set<MWWorld::Ptr> mActors;
MWWorld::Ptr mWatched;
CreatureStats mWatchedCreature;
public:
MechanicsManager (const ESMS::ESMStore& store, MWGui::WindowManager& windowManager);
void configureGUI();
void addActor (const MWWorld::Ptr& ptr);
///< Register an actor for stats management
void removeActor (const MWWorld::Ptr& ptr);
///< Deregister an actor for stats management
void dropActors (const MWWorld::Ptr::CellStore *cellStore);
///< Deregister all actors in the given cell.
void watchActor (const MWWorld::Ptr& ptr);
///< On each update look for changes in a previously registered actor and update the
/// GUI accordingly.
void update();
///< Update actor stats
void setPlayerName (const std::string& name);
///< Set player name.
void setPlayerRace (const std::string& id, bool male);
///< Set player race.
void setPlayerBirthsign (const std::string& id);
///< Set player birthsign.
void setPlayerClass (const std::string& id);
///< Set player class to stock class.
void setPlayerClass (const ESM::Class& class_);
///< Set player class to custom class.
};
}
#endif

@ -41,9 +41,20 @@ namespace MWScript
runtime.pop();
ESM::Position pos;
pos.pos[0] = pos.pos[1] = pos.pos[2] = 0;
pos.rot[0] = pos.rot[1] = pos.rot[2] = 0;
context.getWorld().changeCell (cell, pos);
pos.pos[2] = 0;
if (const ESM::Cell *exterior = context.getWorld().getExterior (cell))
{
context.getWorld().indexToPosition (exterior->data.gridX, exterior->data.gridY,
pos.pos[0], pos.pos[1], true);
context.getWorld().changeToExteriorCell (pos);
}
else
{
pos.pos[0] = pos.pos[1] = 0;
context.getWorld().changeCell (cell, pos);
}
}
};
@ -64,7 +75,7 @@ namespace MWScript
ESM::Position pos;
context.getWorld().indexToPosition (x, y, pos.pos[0], pos.pos[1]);
context.getWorld().indexToPosition (x, y, pos.pos[0], pos.pos[1], true);
pos.pos[2] = 0;
pos.rot[0] = pos.rot[1] = pos.rot[2] = 0;

@ -691,6 +691,30 @@ namespace MWWorld
changeCell (x, y, position);
}
const ESM::Cell *World::getExterior (const std::string& cellName) const
{
// first try named cells
if (const ESM::Cell *cell = mStore.cells.searchExtByName (cellName))
return cell;
// didn't work -> now check for regions
std::string cellName2 = ESMS::RecListT<ESM::Region>::toLower (cellName);
for (ESMS::RecListT<ESM::Region>::MapType::const_iterator iter (mStore.regions.list.begin());
iter!=mStore.regions.list.end(); ++iter)
{
if (ESMS::RecListT<ESM::Region>::toLower (iter->second.name)==cellName2)
{
if (const ESM::Cell *cell = mStore.cells.searchExtByRegion (iter->first))
return cell;
break;
}
}
return 0;
}
void World::markCellAsUnchanged()
{
mCellChanged = false;
@ -756,12 +780,18 @@ namespace MWWorld
// TODO cell change for non-player ref
}
void World::indexToPosition (int cellX, int cellY, float &x, float &y) const
void World::indexToPosition (int cellX, int cellY, float &x, float &y, bool centre) const
{
const int cellSize = 8192;
x = cellSize * cellX;
y = cellSize * cellY;
if (centre)
{
x += cellSize/2;
y += cellSize/2;
}
}
void World::positionToIndex (float x, float y, int &cellX, int &cellY) const

@ -145,6 +145,9 @@ namespace MWWorld
void changeToExteriorCell (const ESM::Position& position);
const ESM::Cell *getExterior (const std::string& cellName) const;
///< Return a cell matching the given name or a 0-pointer, if there is no such cell.
void markCellAsUnchanged();
std::string getFacedHandle();
@ -154,7 +157,7 @@ namespace MWWorld
void moveObject (Ptr ptr, float x, float y, float z);
void indexToPosition (int cellX, int cellY, float &x, float &y) const;
void indexToPosition (int cellX, int cellY, float &x, float &y, bool centre = false) const;
///< Convert cell numbers to position.
void positionToIndex (float x, float y, int &cellX, int &cellY) const;

@ -65,6 +65,7 @@ struct Skill
void load(ESMReader &esm)
{
esm.getHNT(index, "INDX");
esm.getHNT(data, "SKDT", 24);
description = esm.getHNOString("DESC");
}

@ -49,10 +49,14 @@ namespace ESMS
// Find the given object ID, or return NULL if not found.
const X* search(const std::string &id) const
{
std::string id2 = toLower (id);
if(list.find(id2) == list.end())
return NULL;
return &list.find(id2)->second;
std::string id2 = toLower (id);
typename MapType::const_iterator iter = list.find (id2);
if (iter == list.end())
return NULL;
return &iter->second;
}
// Find the given object ID (throws an exception if not found)
@ -87,10 +91,13 @@ namespace ESMS
// Find the given object ID, or return NULL if not found.
const X* search(const std::string &id) const
{
std::string id2 = toLower (id);
if(list.find(id2) == list.end())
return NULL;
return &list.find(id2)->second;
std::string id2 = toLower (id);
typename MapType::const_iterator iter = list.find (id2);
if (iter == list.end())
return NULL;
return &iter->second;
}
// Find the given object ID (throws an exception if not found)
@ -129,10 +136,14 @@ namespace ESMS
// Find the given object ID, or return NULL if not found.
const X* search(const std::string &id) const
{
std::string id2 = toLower (id);
if(list.find(id2) == list.end())
return NULL;
return &list.find(id2)->second;
std::string id2 = toLower (id);
typename MapType::const_iterator iter = list.find (id2);
if (iter == list.end())
return NULL;
return &iter->second;
}
// Find the given object ID (throws an exception if not found)
@ -209,6 +220,38 @@ namespace ESMS
return it2->second;
}
const Cell *searchExtByName (const std::string& id) const
{
for (ExtCells::const_iterator iter = extCells.begin(); iter!=extCells.end(); ++iter)
{
const ExtCellsCol& column = iter->second;
for (ExtCellsCol::const_iterator iter = column.begin(); iter!=column.end(); ++iter)
{
if (iter->second->name==id)
return iter->second;
}
}
return 0;
}
const Cell *searchExtByRegion (const std::string& id) const
{
std::string id2 = toLower (id);
for (ExtCells::const_iterator iter = extCells.begin(); iter!=extCells.end(); ++iter)
{
const ExtCellsCol& column = iter->second;
for (ExtCellsCol::const_iterator iter = column.begin(); iter!=column.end(); ++iter)
{
if (toLower (iter->second->region)==id)
return iter->second;
}
}
return 0;
}
void load(ESMReader &esm, const std::string &id)
{
using namespace std;
@ -256,10 +299,14 @@ namespace ESMS
// Find the given object ID, or return NULL if not found.
const X* search(const std::string &id) const
{
std::string id2 = toLower (id);
if(list.find(id2) == list.end())
return NULL;
return &list.find(id2)->second;
std::string id2 = toLower (id);
typename MapType::const_iterator iter = list.find (id2);
if (iter == list.end())
return NULL;
return &iter->second;
}
// Find the given object ID (throws an exception if not found)
@ -276,12 +323,55 @@ namespace ESMS
int getSize() { return list.size(); }
};
template <typename X>
struct IndexListT
{
typedef std::map<int, X> MapType;
MapType list;
void load(ESMReader &esm)
{
X ref;
ref.load (esm);
int index = ref.index;
list[index] = ref;
}
int getSize()
{
return list.size();
}
// Find the given object ID, or return NULL if not found.
const X* search (int id) const
{
typename MapType::const_iterator iter = list.find (id);
if (iter == list.end())
return NULL;
return &iter->second;
}
// Find the given object ID (throws an exception if not found)
const X* find (int id) const
{
const X *object = search (id);
if (!object)
{
std::ostringstream error;
error << "object " << id << " not found";
throw std::runtime_error (error.str());
}
return object;
}
};
/* We need special lists for:
Magic effects
Skills
Dialog / Info combo
Scripts
Land
Path grids
Land textures

@ -46,15 +46,21 @@ void ESMStore::load(ESMReader &esm)
{
std::cerr << "error: info record without dialog" << std::endl;
esm.skipRecord();
continue;
}
}
else if (n.val==ESM::REC_MGEF)
{
magicEffects.load (esm);
}
else if (n.val==ESM::REC_SKIL)
{
skills.load (esm);
}
else
{
// Not found (this would be an error later)
esm.skipRecord();
missing.insert(n.toString());
continue;
}
}
else

@ -71,9 +71,9 @@ namespace ESMS
RecIDListT<GameSetting> gameSettings;
//RecListT<Land> lands;
//RecListT<LandTexture> landTexts;
//RecListT<MagicEffect> magicEffects;
IndexListT<MagicEffect> magicEffects;
ScriptListT<Script> scripts;
//RecListT<Skill> skills;
IndexListT<Skill> skills;
//RecListT<PathGrid> pathgrids;
// Lookup of all IDs. Makes looking up references faster. Just
@ -118,7 +118,6 @@ namespace ESMS
recLists[REC_LIGH] = &lights;
recLists[REC_LOCK] = &lockpicks;
//recLists[REC_LTEX] = &landTexts;
//recLists[REC_MGEF] = &magicEffects;
recLists[REC_MISC] = &miscItems;
recLists[REC_NPC_] = &npcs;
recLists[REC_NPCC] = &npcChange;
@ -128,7 +127,6 @@ namespace ESMS
recLists[REC_REGN] = &regions;
recLists[REC_REPA] = &repairs;
recLists[REC_SCPT] = &scripts;
//recLists[REC_SKIL] = &skills;
recLists[REC_SNDG] = &soundGens;
recLists[REC_SOUN] = &sounds;
recLists[REC_SPEL] = &spells;

Loading…
Cancel
Save