mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-21 11:23:51 +00:00
Merge branch 'faction'
This commit is contained in:
commit
df658d29f0
20 changed files with 180 additions and 33 deletions
|
@ -679,14 +679,14 @@ void Record<ESM::Faction>::print()
|
|||
std::cout << " Hidden: " << mData.mData.mIsHidden << std::endl;
|
||||
if (mData.mData.mUnknown != -1)
|
||||
std::cout << " Unknown: " << mData.mData.mUnknown << std::endl;
|
||||
std::cout << " Attribute1: " << attributeLabel(mData.mData.mAttribute1)
|
||||
<< " (" << mData.mData.mAttribute1 << ")" << std::endl;
|
||||
std::cout << " Attribute2: " << attributeLabel(mData.mData.mAttribute2)
|
||||
<< " (" << mData.mData.mAttribute2 << ")" << std::endl;
|
||||
std::cout << " Attribute1: " << attributeLabel(mData.mData.mAttributes[0])
|
||||
<< " (" << mData.mData.mAttributes[0] << ")" << std::endl;
|
||||
std::cout << " Attribute2: " << attributeLabel(mData.mData.mAttributes[1])
|
||||
<< " (" << mData.mData.mAttributes[1] << ")" << std::endl;
|
||||
for (int i = 0; i != 6; i++)
|
||||
if (mData.mData.mSkillID[i] != -1)
|
||||
std::cout << " Skill: " << skillLabel(mData.mData.mSkillID[i])
|
||||
<< " (" << mData.mData.mSkillID[i] << ")" << std::endl;
|
||||
if (mData.mData.mSkills[i] != -1)
|
||||
std::cout << " Skill: " << skillLabel(mData.mData.mSkills[i])
|
||||
<< " (" << mData.mData.mSkills[i] << ")" << std::endl;
|
||||
for (int i = 0; i != 10; i++)
|
||||
if (mData.mRanks[i] != "")
|
||||
{
|
||||
|
|
|
@ -347,15 +347,15 @@ namespace CSMWorld
|
|||
int mIndex;
|
||||
bool mMajor;
|
||||
|
||||
SkillsColumn (int index, bool major)
|
||||
: Column<ESXRecordT> ((major ? "Major Skill #" : "Minor Skill #")+
|
||||
SkillsColumn (int index, bool typePrefix = false, bool major = false)
|
||||
: Column<ESXRecordT> ((typePrefix ? (major ? "Major Skill #" : "Minor Skill #") : "Skill #")+
|
||||
boost::lexical_cast<std::string> (index), ColumnBase::Display_String),
|
||||
mIndex (index), mMajor (major)
|
||||
{}
|
||||
|
||||
virtual QVariant get (const Record<ESXRecordT>& record) const
|
||||
{
|
||||
int skill = record.get().mData.mSkills[mIndex][mMajor ? 1 : 0];
|
||||
int skill = record.get().mData.getSkill (mIndex, mMajor);
|
||||
|
||||
return QString::fromUtf8 (ESM::Skill::indexToId (skill).c_str());
|
||||
}
|
||||
|
@ -373,7 +373,7 @@ namespace CSMWorld
|
|||
{
|
||||
ESXRecordT record2 = record.get();
|
||||
|
||||
record2.mData.mSkills[mIndex][mMajor ? 1 : 0] = index;
|
||||
record2.mData.getSkill (mIndex, mMajor) = index;
|
||||
|
||||
record.setModified (record2);
|
||||
}
|
||||
|
@ -409,6 +409,31 @@ namespace CSMWorld
|
|||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename ESXRecordT>
|
||||
struct HiddenColumn : public Column<ESXRecordT>
|
||||
{
|
||||
HiddenColumn() : Column<ESXRecordT> ("Hidden", ColumnBase::Display_Boolean) {}
|
||||
|
||||
virtual QVariant get (const Record<ESXRecordT>& record) const
|
||||
{
|
||||
return record.get().mData.mIsHidden!=0;
|
||||
}
|
||||
|
||||
virtual void set (Record<ESXRecordT>& record, const QVariant& data)
|
||||
{
|
||||
ESXRecordT record2 = record.get();
|
||||
|
||||
record2.mData.mIsHidden = data.toInt();
|
||||
|
||||
record.setModified (record2);
|
||||
}
|
||||
|
||||
virtual bool isEditable() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
|
@ -51,16 +51,24 @@ CSMWorld::Data::Data()
|
|||
mClasses.addColumn (new AttributesColumn<ESM::Class> (1));
|
||||
mClasses.addColumn (new SpecialisationColumn<ESM::Class>);
|
||||
for (int i=0; i<5; ++i)
|
||||
mClasses.addColumn (new SkillsColumn<ESM::Class> (i, true));
|
||||
mClasses.addColumn (new SkillsColumn<ESM::Class> (i, true, true));
|
||||
for (int i=0; i<5; ++i)
|
||||
mClasses.addColumn (new SkillsColumn<ESM::Class> (i, false));
|
||||
mClasses.addColumn (new SkillsColumn<ESM::Class> (i, true, false));
|
||||
mClasses.addColumn (new PlayableColumn<ESM::Class>);
|
||||
mClasses.addColumn (new DescriptionColumn<ESM::Class>);
|
||||
|
||||
mFactions.addColumn (new StringIdColumn<ESM::Faction>);
|
||||
mFactions.addColumn (new RecordStateColumn<ESM::Faction>);
|
||||
mFactions.addColumn (new NameColumn<ESM::Faction>);
|
||||
mFactions.addColumn (new HiddenColumn<ESM::Faction>);
|
||||
for (int i=0; i<6; ++i)
|
||||
mFactions.addColumn (new SkillsColumn<ESM::Faction> (i));
|
||||
|
||||
addModel (new IdTable (&mGlobals), UniversalId::Type_Globals, UniversalId::Type_Global);
|
||||
addModel (new IdTable (&mGmsts), UniversalId::Type_Gmsts, UniversalId::Type_Gmst);
|
||||
addModel (new IdTable (&mSkills), UniversalId::Type_Skills, UniversalId::Type_Skill);
|
||||
addModel (new IdTable (&mClasses), UniversalId::Type_Classes, UniversalId::Type_Class);
|
||||
addModel (new IdTable (&mFactions), UniversalId::Type_Factions, UniversalId::Type_Faction);
|
||||
}
|
||||
|
||||
CSMWorld::Data::~Data()
|
||||
|
@ -99,6 +107,16 @@ CSMWorld::IdCollection<ESM::Skill>& CSMWorld::Data::getSkills()
|
|||
return mSkills;
|
||||
}
|
||||
|
||||
const CSMWorld::IdCollection<ESM::Faction>& CSMWorld::Data::getFactions() const
|
||||
{
|
||||
return mFactions;
|
||||
}
|
||||
|
||||
CSMWorld::IdCollection<ESM::Faction>& CSMWorld::Data::getFactions()
|
||||
{
|
||||
return mFactions;
|
||||
}
|
||||
|
||||
QAbstractItemModel *CSMWorld::Data::getTableModel (const UniversalId& id)
|
||||
{
|
||||
std::map<UniversalId::Type, QAbstractItemModel *>::iterator iter = mModelIndex.find (id.getType());
|
||||
|
@ -137,6 +155,7 @@ void CSMWorld::Data::loadFile (const boost::filesystem::path& path, bool base)
|
|||
case ESM::REC_GMST: mGmsts.load (reader, base); break;
|
||||
case ESM::REC_SKIL: mSkills.load (reader, base); break;
|
||||
case ESM::REC_CLAS: mClasses.load (reader, base); break;
|
||||
case ESM::REC_FACT: mFactions.load (reader, base); break;
|
||||
|
||||
default:
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <components/esm/loadgmst.hpp>
|
||||
#include <components/esm/loadskil.hpp>
|
||||
#include <components/esm/loadclas.hpp>
|
||||
#include <components/esm/loadfact.hpp>
|
||||
|
||||
#include "idcollection.hpp"
|
||||
#include "universalid.hpp"
|
||||
|
@ -24,6 +25,7 @@ namespace CSMWorld
|
|||
IdCollection<ESM::GameSetting> mGmsts;
|
||||
IdCollection<ESM::Skill> mSkills;
|
||||
IdCollection<ESM::Class> mClasses;
|
||||
IdCollection<ESM::Faction> mFactions;
|
||||
std::vector<QAbstractItemModel *> mModels;
|
||||
std::map<UniversalId::Type, QAbstractItemModel *> mModelIndex;
|
||||
|
||||
|
@ -52,6 +54,10 @@ namespace CSMWorld
|
|||
|
||||
IdCollection<ESM::Skill>& getSkills();
|
||||
|
||||
const IdCollection<ESM::Faction>& getFactions() const;
|
||||
|
||||
IdCollection<ESM::Faction>& getFactions();
|
||||
|
||||
QAbstractItemModel *getTableModel (const UniversalId& id);
|
||||
///< If no table model is available for \a id, an exception is thrown.
|
||||
///
|
||||
|
|
|
@ -21,6 +21,7 @@ namespace
|
|||
{ CSMWorld::UniversalId::Class_RecordList, CSMWorld::UniversalId::Type_Gmsts, "Game Settings" },
|
||||
{ CSMWorld::UniversalId::Class_RecordList, CSMWorld::UniversalId::Type_Skills, "Skills" },
|
||||
{ CSMWorld::UniversalId::Class_RecordList, CSMWorld::UniversalId::Type_Classes, "Classes" },
|
||||
{ CSMWorld::UniversalId::Class_RecordList, CSMWorld::UniversalId::Type_Factions, "Factions" },
|
||||
|
||||
{ CSMWorld::UniversalId::Class_None, CSMWorld::UniversalId::Type_None, 0 } // end marker
|
||||
};
|
||||
|
@ -31,6 +32,7 @@ namespace
|
|||
{ CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_Gmst, "Game Setting" },
|
||||
{ CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_Skill, "Skill" },
|
||||
{ CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_Class, "Class" },
|
||||
{ CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_Faction, "Faction" },
|
||||
|
||||
{ CSMWorld::UniversalId::Class_None, CSMWorld::UniversalId::Type_None, 0 } // end marker
|
||||
};
|
||||
|
|
|
@ -41,7 +41,9 @@ namespace CSMWorld
|
|||
Type_Skills,
|
||||
Type_Skill,
|
||||
Type_Classes,
|
||||
Type_Class
|
||||
Type_Class,
|
||||
Type_Factions,
|
||||
Type_Faction
|
||||
};
|
||||
|
||||
private:
|
||||
|
|
|
@ -94,6 +94,10 @@ void CSVDoc::View::setupWorldMenu()
|
|||
connect (classes, SIGNAL (triggered()), this, SLOT (addClassesSubView()));
|
||||
world->addAction (classes);
|
||||
|
||||
QAction *factions = new QAction (tr ("Factions"), this);
|
||||
connect (factions, SIGNAL (triggered()), this, SLOT (addFactionsSubView()));
|
||||
world->addAction (factions);
|
||||
|
||||
mVerify = new QAction (tr ("&Verify"), this);
|
||||
connect (mVerify, SIGNAL (triggered()), this, SLOT (verify()));
|
||||
world->addAction (mVerify);
|
||||
|
@ -262,6 +266,11 @@ void CSVDoc::View::addClassesSubView()
|
|||
addSubView (CSMWorld::UniversalId::Type_Classes);
|
||||
}
|
||||
|
||||
void CSVDoc::View::addFactionsSubView()
|
||||
{
|
||||
addSubView (CSMWorld::UniversalId::Type_Factions);
|
||||
}
|
||||
|
||||
void CSVDoc::View::abortOperation (int type)
|
||||
{
|
||||
mDocument->abortOperation (type);
|
||||
|
|
|
@ -119,6 +119,8 @@ namespace CSVDoc
|
|||
void addSkillsSubView();
|
||||
|
||||
void addClassesSubView();
|
||||
|
||||
void addFactionsSubView();
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ CSVDoc::ViewManager::ViewManager (CSMDoc::DocumentManager& documentManager)
|
|||
new CSVWorld::EnumDelegateFactory (sSpecialisations));
|
||||
|
||||
mDelegateFactories->add (CSMWorld::ColumnBase::Display_Attribute,
|
||||
new CSVWorld::EnumDelegateFactory (sAttributes));
|
||||
new CSVWorld::EnumDelegateFactory (sAttributes, true));
|
||||
}
|
||||
|
||||
CSVDoc::ViewManager::~ViewManager()
|
||||
|
|
|
@ -92,10 +92,13 @@ void CSVWorld::EnumDelegate::paint (QPainter *painter, const QStyleOptionViewIte
|
|||
|
||||
CSVWorld::EnumDelegateFactory::EnumDelegateFactory() {}
|
||||
|
||||
CSVWorld::EnumDelegateFactory::EnumDelegateFactory (const char **names)
|
||||
CSVWorld::EnumDelegateFactory::EnumDelegateFactory (const char **names, bool allowNone)
|
||||
{
|
||||
assert (names);
|
||||
|
||||
if (allowNone)
|
||||
add (-1, "");
|
||||
|
||||
for (int i=0; names[i]; ++i)
|
||||
add (i, names[i]);
|
||||
}
|
||||
|
|
|
@ -47,8 +47,9 @@ namespace CSVWorld
|
|||
|
||||
EnumDelegateFactory();
|
||||
|
||||
EnumDelegateFactory (const char **names);
|
||||
EnumDelegateFactory (const char **names, bool allowNone = false);
|
||||
///< \param names Array of char pointer with a 0-pointer as end mark
|
||||
/// \param allowNone Use value of -1 for "none selected" (empty string)
|
||||
|
||||
virtual CommandDelegate *makeDelegate (QUndoStack& undoStack, QObject *parent) const;
|
||||
///< The ownership of the returned CommandDelegate is transferred to the caller.
|
||||
|
|
|
@ -20,6 +20,9 @@ void CSVWorld::addSubViewFactories (CSVDoc::SubViewFactoryManager& manager)
|
|||
manager.add (CSMWorld::UniversalId::Type_Classes,
|
||||
new CSVDoc::SubViewFactoryWithCreateFlag<TableSubView> (true));
|
||||
|
||||
manager.add (CSMWorld::UniversalId::Type_Factions,
|
||||
new CSVDoc::SubViewFactoryWithCreateFlag<TableSubView> (true));
|
||||
|
||||
// manager.add (CSMWorld::UniversalId::Type_Global,
|
||||
// new CSVDoc::SubViewFactoryWithCreateFlag<DialogueSubView> (true));
|
||||
}
|
|
@ -569,8 +569,8 @@ bool MWDialogue::Filter::hasFactionRankSkillRequirements (const MWWorld::Ptr& ac
|
|||
|
||||
MWMechanics::CreatureStats& stats = MWWorld::Class::get (actor).getCreatureStats (actor);
|
||||
|
||||
return stats.getAttribute (faction.mData.mAttribute1).getBase()>=faction.mData.mRankData[rank].mAttribute1 &&
|
||||
stats.getAttribute (faction.mData.mAttribute2).getBase()>=faction.mData.mRankData[rank].mAttribute2;
|
||||
return stats.getAttribute (faction.mData.mAttributes[0]).getBase()>=faction.mData.mRankData[rank].mAttribute1 &&
|
||||
stats.getAttribute (faction.mData.mAttributes[1]).getBase()>=faction.mData.mRankData[rank].mAttribute2;
|
||||
}
|
||||
|
||||
bool MWDialogue::Filter::hasFactionRankReputationRequirements (const MWWorld::Ptr& actor,
|
||||
|
|
|
@ -500,8 +500,8 @@ void StatsWindow::updateSkillArea()
|
|||
text += std::string("\n\n#DDC79E#{sNextRank} ") + faction->mRanks[it->second+1];
|
||||
|
||||
ESM::RankData rankData = faction->mData.mRankData[it->second+1];
|
||||
const ESM::Attribute* attr1 = store.get<ESM::Attribute>().find(faction->mData.mAttribute1);
|
||||
const ESM::Attribute* attr2 = store.get<ESM::Attribute>().find(faction->mData.mAttribute2);
|
||||
const ESM::Attribute* attr1 = store.get<ESM::Attribute>().find(faction->mData.mAttributes[0]);
|
||||
const ESM::Attribute* attr2 = store.get<ESM::Attribute>().find(faction->mData.mAttributes[1]);
|
||||
assert(attr1 && attr2);
|
||||
|
||||
text += "\n#BF9959#{" + attr1->mName + "}: " + boost::lexical_cast<std::string>(rankData.mAttribute1)
|
||||
|
@ -511,7 +511,7 @@ void StatsWindow::updateSkillArea()
|
|||
text += "\n#BF9959";
|
||||
for (int i=0; i<6; ++i)
|
||||
{
|
||||
text += "#{"+ESM::Skill::sSkillNameIds[faction->mData.mSkillID[i]]+"}";
|
||||
text += "#{"+ESM::Skill::sSkillNameIds[faction->mData.mSkills[i]]+"}";
|
||||
if (i<5)
|
||||
text += ", ";
|
||||
}
|
||||
|
|
|
@ -334,7 +334,7 @@ bool MWMechanics::NpcStats::hasSkillsForRank (const std::string& factionId, int
|
|||
std::vector<int> skills;
|
||||
|
||||
for (int i=0; i<6; ++i)
|
||||
skills.push_back (static_cast<int> (getSkill (faction.mData.mSkillID[i]).getModified()));
|
||||
skills.push_back (static_cast<int> (getSkill (faction.mData.mSkills[i]).getModified()));
|
||||
|
||||
std::sort (skills.begin(), skills.end());
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include "loadclas.hpp"
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
#include "esmreader.hpp"
|
||||
#include "esmwriter.hpp"
|
||||
|
||||
|
@ -18,6 +20,23 @@ const char *Class::sGmstSpecializationIds[3] = {
|
|||
"sSpecializationStealth"
|
||||
};
|
||||
|
||||
|
||||
int& Class::CLDTstruct::getSkill (int index, bool major)
|
||||
{
|
||||
if (index<0 || index>=5)
|
||||
throw std::logic_error ("skill index out of range");
|
||||
|
||||
return mSkills[index][major ? 1 : 0];
|
||||
}
|
||||
|
||||
int Class::CLDTstruct::getSkill (int index, bool major) const
|
||||
{
|
||||
if (index<0 || index>=5)
|
||||
throw std::logic_error ("skill index out of range");
|
||||
|
||||
return mSkills[index][major ? 1 : 0];
|
||||
}
|
||||
|
||||
void Class::load(ESMReader &esm)
|
||||
{
|
||||
mName = esm.getHNString("FNAM");
|
||||
|
|
|
@ -58,6 +58,12 @@ struct Class
|
|||
|
||||
// I have no idea how to autocalculate these items...
|
||||
int mCalc;
|
||||
|
||||
int& getSkill (int index, bool major);
|
||||
///< Throws an exception for invalid values of \a index.
|
||||
|
||||
int getSkill (int index, bool major) const;
|
||||
///< Throws an exception for invalid values of \a index.
|
||||
}; // 60 bytes
|
||||
|
||||
std::string mId, mName, mDescription;
|
||||
|
|
|
@ -1,10 +1,27 @@
|
|||
#include "loadfact.hpp"
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
#include "esmreader.hpp"
|
||||
#include "esmwriter.hpp"
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
int& Faction::FADTstruct::getSkill (int index, bool ignored)
|
||||
{
|
||||
if (index<0 || index>=6)
|
||||
throw std::logic_error ("skill index out of range");
|
||||
|
||||
return mSkills[index];
|
||||
}
|
||||
|
||||
int Faction::FADTstruct::getSkill (int index, bool ignored) const
|
||||
{
|
||||
if (index<0 || index>=6)
|
||||
throw std::logic_error ("skill index out of range");
|
||||
|
||||
return mSkills[index];
|
||||
}
|
||||
|
||||
void Faction::load(ESMReader &esm)
|
||||
{
|
||||
|
@ -33,7 +50,7 @@ void Faction::load(ESMReader &esm)
|
|||
void Faction::save(ESMWriter &esm)
|
||||
{
|
||||
esm.writeHNCString("FNAM", mName);
|
||||
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
if (mRanks[i].empty())
|
||||
|
@ -43,7 +60,7 @@ void Faction::save(ESMWriter &esm)
|
|||
}
|
||||
|
||||
esm.writeHNT("FADT", mData, 240);
|
||||
|
||||
|
||||
for (std::vector<Reaction>::iterator it = mReactions.begin(); it != mReactions.end(); ++it)
|
||||
{
|
||||
esm.writeHNString("ANAM", it->mFaction);
|
||||
|
@ -51,4 +68,25 @@ void Faction::save(ESMWriter &esm)
|
|||
}
|
||||
}
|
||||
|
||||
void Faction::blank()
|
||||
{
|
||||
mName.clear();
|
||||
mData.mAttributes[0] = mData.mAttributes[1] = 0;
|
||||
mData.mUnknown = -1;
|
||||
mData.mIsHidden = 0;
|
||||
|
||||
for (int i=0; i<10; ++i)
|
||||
{
|
||||
mData.mRankData[i].mAttribute1 = mData.mRankData[i].mAttribute2 = 0;
|
||||
mData.mRankData[i].mSkill1 = mData.mRankData[i].mSkill2 = 0;
|
||||
mData.mRankData[i].mFactReaction = 0;
|
||||
|
||||
mRanks[i].clear();
|
||||
}
|
||||
|
||||
for (int i=0; i<6; ++i)
|
||||
mData.mSkills[i] = 0;
|
||||
|
||||
mReactions.clear();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,13 +34,19 @@ struct Faction
|
|||
struct FADTstruct
|
||||
{
|
||||
// Which attributes we like
|
||||
int mAttribute1, mAttribute2;
|
||||
int mAttributes[2];
|
||||
|
||||
RankData mRankData[10];
|
||||
|
||||
int mSkillID[6]; // IDs of skills this faction require
|
||||
int mSkills[6]; // IDs of skills this faction require
|
||||
int mUnknown; // Always -1?
|
||||
int mIsHidden; // 1 - hidden from player
|
||||
|
||||
int& getSkill (int index, bool ignored = false);
|
||||
///< Throws an exception for invalid values of \a index.
|
||||
|
||||
int getSkill (int index, bool ignored = false) const;
|
||||
///< Throws an exception for invalid values of \a index.
|
||||
}; // 240 bytes
|
||||
|
||||
FADTstruct mData;
|
||||
|
@ -58,6 +64,9 @@ struct Faction
|
|||
|
||||
void load(ESMReader &esm);
|
||||
void save(ESMWriter &esm);
|
||||
|
||||
void blank();
|
||||
///< Set record to default state (does not touch the ID/index).
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -127,15 +127,18 @@ void Skill::save(ESMWriter &esm)
|
|||
{
|
||||
std::ostringstream stream;
|
||||
|
||||
stream << "#";
|
||||
if (index!=-1)
|
||||
{
|
||||
stream << "#";
|
||||
|
||||
if (index<10)
|
||||
stream << "0";
|
||||
if (index<10)
|
||||
stream << "0";
|
||||
|
||||
stream << index;
|
||||
stream << index;
|
||||
|
||||
if (index>=0 && index<Length)
|
||||
stream << sSkillNameIds[index].substr (6);
|
||||
if (index>=0 && index<Length)
|
||||
stream << sSkillNameIds[index].substr (6);
|
||||
}
|
||||
|
||||
return stream.str();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue