mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-03 15:39:41 +00:00
added script table
This commit is contained in:
parent
4daaa4030d
commit
ff1d908af4
10 changed files with 56 additions and 5 deletions
|
@ -1182,7 +1182,7 @@ void Record<ESM::Script>::print()
|
||||||
std::cout << " Variable: " << *vit << std::endl;
|
std::cout << " Variable: " << *vit << std::endl;
|
||||||
|
|
||||||
std::cout << " ByteCode: ";
|
std::cout << " ByteCode: ";
|
||||||
std::vector<char>::iterator cit;
|
std::vector<unsigned char>::iterator cit;
|
||||||
for (cit = mData.mScriptData.begin(); cit != mData.mScriptData.end(); cit++)
|
for (cit = mData.mScriptData.begin(); cit != mData.mScriptData.end(); cit++)
|
||||||
std::cout << boost::format("%02X") % (int)(*cit);
|
std::cout << boost::format("%02X") % (int)(*cit);
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
|
|
|
@ -84,6 +84,9 @@ CSMWorld::Data::Data()
|
||||||
mSounds.addColumn (new SoundParamColumn<ESM::Sound> (SoundParamColumn<ESM::Sound>::Type_MaxRange));
|
mSounds.addColumn (new SoundParamColumn<ESM::Sound> (SoundParamColumn<ESM::Sound>::Type_MaxRange));
|
||||||
mSounds.addColumn (new SoundFileColumn<ESM::Sound>);
|
mSounds.addColumn (new SoundFileColumn<ESM::Sound>);
|
||||||
|
|
||||||
|
mScripts.addColumn (new StringIdColumn<ESM::Script>);
|
||||||
|
mScripts.addColumn (new RecordStateColumn<ESM::Script>);
|
||||||
|
|
||||||
addModel (new IdTable (&mGlobals), UniversalId::Type_Globals, UniversalId::Type_Global);
|
addModel (new IdTable (&mGlobals), UniversalId::Type_Globals, UniversalId::Type_Global);
|
||||||
addModel (new IdTable (&mGmsts), UniversalId::Type_Gmsts, UniversalId::Type_Gmst);
|
addModel (new IdTable (&mGmsts), UniversalId::Type_Gmsts, UniversalId::Type_Gmst);
|
||||||
addModel (new IdTable (&mSkills), UniversalId::Type_Skills, UniversalId::Type_Skill);
|
addModel (new IdTable (&mSkills), UniversalId::Type_Skills, UniversalId::Type_Skill);
|
||||||
|
@ -91,6 +94,7 @@ CSMWorld::Data::Data()
|
||||||
addModel (new IdTable (&mFactions), UniversalId::Type_Factions, UniversalId::Type_Faction);
|
addModel (new IdTable (&mFactions), UniversalId::Type_Factions, UniversalId::Type_Faction);
|
||||||
addModel (new IdTable (&mRaces), UniversalId::Type_Races, UniversalId::Type_Race);
|
addModel (new IdTable (&mRaces), UniversalId::Type_Races, UniversalId::Type_Race);
|
||||||
addModel (new IdTable (&mSounds), UniversalId::Type_Sounds, UniversalId::Type_Sound);
|
addModel (new IdTable (&mSounds), UniversalId::Type_Sounds, UniversalId::Type_Sound);
|
||||||
|
addModel (new IdTable (&mScripts), UniversalId::Type_Scripts, UniversalId::Type_Script);
|
||||||
}
|
}
|
||||||
|
|
||||||
CSMWorld::Data::~Data()
|
CSMWorld::Data::~Data()
|
||||||
|
@ -169,6 +173,16 @@ CSMWorld::IdCollection<ESM::Sound>& CSMWorld::Data::getSounds()
|
||||||
return mSounds;
|
return mSounds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const CSMWorld::IdCollection<ESM::Script>& CSMWorld::Data::getScripts() const
|
||||||
|
{
|
||||||
|
return mScripts;
|
||||||
|
}
|
||||||
|
|
||||||
|
CSMWorld::IdCollection<ESM::Script>& CSMWorld::Data::getScripts()
|
||||||
|
{
|
||||||
|
return mScripts;
|
||||||
|
}
|
||||||
|
|
||||||
QAbstractItemModel *CSMWorld::Data::getTableModel (const UniversalId& id)
|
QAbstractItemModel *CSMWorld::Data::getTableModel (const UniversalId& id)
|
||||||
{
|
{
|
||||||
std::map<UniversalId::Type, QAbstractItemModel *>::iterator iter = mModelIndex.find (id.getType());
|
std::map<UniversalId::Type, QAbstractItemModel *>::iterator iter = mModelIndex.find (id.getType());
|
||||||
|
@ -210,6 +224,7 @@ void CSMWorld::Data::loadFile (const boost::filesystem::path& path, bool base)
|
||||||
case ESM::REC_FACT: mFactions.load (reader, base); break;
|
case ESM::REC_FACT: mFactions.load (reader, base); break;
|
||||||
case ESM::REC_RACE: mRaces.load (reader, base); break;
|
case ESM::REC_RACE: mRaces.load (reader, base); break;
|
||||||
case ESM::REC_SOUN: mSounds.load (reader, base); break;
|
case ESM::REC_SOUN: mSounds.load (reader, base); break;
|
||||||
|
case ESM::REC_SCPT: mScripts.load (reader, base); break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include <components/esm/loadfact.hpp>
|
#include <components/esm/loadfact.hpp>
|
||||||
#include <components/esm/loadrace.hpp>
|
#include <components/esm/loadrace.hpp>
|
||||||
#include <components/esm/loadsoun.hpp>
|
#include <components/esm/loadsoun.hpp>
|
||||||
|
#include <components/esm/loadscpt.hpp>
|
||||||
|
|
||||||
#include "idcollection.hpp"
|
#include "idcollection.hpp"
|
||||||
#include "universalid.hpp"
|
#include "universalid.hpp"
|
||||||
|
@ -30,6 +31,7 @@ namespace CSMWorld
|
||||||
IdCollection<ESM::Faction> mFactions;
|
IdCollection<ESM::Faction> mFactions;
|
||||||
IdCollection<ESM::Race> mRaces;
|
IdCollection<ESM::Race> mRaces;
|
||||||
IdCollection<ESM::Sound> mSounds;
|
IdCollection<ESM::Sound> mSounds;
|
||||||
|
IdCollection<ESM::Script> mScripts;
|
||||||
std::vector<QAbstractItemModel *> mModels;
|
std::vector<QAbstractItemModel *> mModels;
|
||||||
std::map<UniversalId::Type, QAbstractItemModel *> mModelIndex;
|
std::map<UniversalId::Type, QAbstractItemModel *> mModelIndex;
|
||||||
|
|
||||||
|
@ -74,6 +76,10 @@ namespace CSMWorld
|
||||||
|
|
||||||
IdCollection<ESM::Sound>& getSounds();
|
IdCollection<ESM::Sound>& getSounds();
|
||||||
|
|
||||||
|
const IdCollection<ESM::Script>& getScripts() const;
|
||||||
|
|
||||||
|
IdCollection<ESM::Script>& getScripts();
|
||||||
|
|
||||||
QAbstractItemModel *getTableModel (const UniversalId& id);
|
QAbstractItemModel *getTableModel (const UniversalId& id);
|
||||||
///< If no table model is available for \a id, an exception is thrown.
|
///< If no table model is available for \a id, an exception is thrown.
|
||||||
///
|
///
|
||||||
|
|
|
@ -24,6 +24,7 @@ namespace
|
||||||
{ CSMWorld::UniversalId::Class_RecordList, CSMWorld::UniversalId::Type_Factions, "Factions" },
|
{ CSMWorld::UniversalId::Class_RecordList, CSMWorld::UniversalId::Type_Factions, "Factions" },
|
||||||
{ CSMWorld::UniversalId::Class_RecordList, CSMWorld::UniversalId::Type_Races, "Races" },
|
{ CSMWorld::UniversalId::Class_RecordList, CSMWorld::UniversalId::Type_Races, "Races" },
|
||||||
{ CSMWorld::UniversalId::Class_RecordList, CSMWorld::UniversalId::Type_Sounds, "Sounds" },
|
{ CSMWorld::UniversalId::Class_RecordList, CSMWorld::UniversalId::Type_Sounds, "Sounds" },
|
||||||
|
{ CSMWorld::UniversalId::Class_RecordList, CSMWorld::UniversalId::Type_Scripts, "Scripts" },
|
||||||
|
|
||||||
{ CSMWorld::UniversalId::Class_None, CSMWorld::UniversalId::Type_None, 0 } // end marker
|
{ CSMWorld::UniversalId::Class_None, CSMWorld::UniversalId::Type_None, 0 } // end marker
|
||||||
};
|
};
|
||||||
|
@ -37,6 +38,7 @@ namespace
|
||||||
{ CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_Faction, "Faction" },
|
{ CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_Faction, "Faction" },
|
||||||
{ CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_Race, "Race" },
|
{ CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_Race, "Race" },
|
||||||
{ CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_Sound, "Sound" },
|
{ CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_Sound, "Sound" },
|
||||||
|
{ CSMWorld::UniversalId::Class_Record, CSMWorld::UniversalId::Type_Script, "Script" },
|
||||||
|
|
||||||
{ CSMWorld::UniversalId::Class_None, CSMWorld::UniversalId::Type_None, 0 } // end marker
|
{ CSMWorld::UniversalId::Class_None, CSMWorld::UniversalId::Type_None, 0 } // end marker
|
||||||
};
|
};
|
||||||
|
|
|
@ -47,7 +47,9 @@ namespace CSMWorld
|
||||||
Type_Races,
|
Type_Races,
|
||||||
Type_Race,
|
Type_Race,
|
||||||
Type_Sounds,
|
Type_Sounds,
|
||||||
Type_Sound
|
Type_Sound,
|
||||||
|
Type_Scripts,
|
||||||
|
Type_Script
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -109,6 +109,10 @@ void CSVDoc::View::setupWorldMenu()
|
||||||
QAction *sounds = new QAction (tr ("Sounds"), this);
|
QAction *sounds = new QAction (tr ("Sounds"), this);
|
||||||
connect (sounds, SIGNAL (triggered()), this, SLOT (addSoundsSubView()));
|
connect (sounds, SIGNAL (triggered()), this, SLOT (addSoundsSubView()));
|
||||||
world->addAction (sounds);
|
world->addAction (sounds);
|
||||||
|
|
||||||
|
QAction *scripts = new QAction (tr ("Scripts"), this);
|
||||||
|
connect (scripts, SIGNAL (triggered()), this, SLOT (addScriptsSubView()));
|
||||||
|
world->addAction (scripts);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVDoc::View::setupUi()
|
void CSVDoc::View::setupUi()
|
||||||
|
@ -289,6 +293,11 @@ void CSVDoc::View::addSoundsSubView()
|
||||||
addSubView (CSMWorld::UniversalId::Type_Sounds);
|
addSubView (CSMWorld::UniversalId::Type_Sounds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVDoc::View::addScriptsSubView()
|
||||||
|
{
|
||||||
|
addSubView (CSMWorld::UniversalId::Type_Scripts);
|
||||||
|
}
|
||||||
|
|
||||||
void CSVDoc::View::abortOperation (int type)
|
void CSVDoc::View::abortOperation (int type)
|
||||||
{
|
{
|
||||||
mDocument->abortOperation (type);
|
mDocument->abortOperation (type);
|
||||||
|
|
|
@ -125,6 +125,8 @@ namespace CSVDoc
|
||||||
void addRacesSubView();
|
void addRacesSubView();
|
||||||
|
|
||||||
void addSoundsSubView();
|
void addSoundsSubView();
|
||||||
|
|
||||||
|
void addScriptsSubView();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ void CSVWorld::addSubViewFactories (CSVDoc::SubViewFactoryManager& manager)
|
||||||
CSMWorld::UniversalId::Type_Factions,
|
CSMWorld::UniversalId::Type_Factions,
|
||||||
CSMWorld::UniversalId::Type_Races,
|
CSMWorld::UniversalId::Type_Races,
|
||||||
CSMWorld::UniversalId::Type_Sounds,
|
CSMWorld::UniversalId::Type_Sounds,
|
||||||
|
CSMWorld::UniversalId::Type_Scripts,
|
||||||
|
|
||||||
CSMWorld::UniversalId::Type_None // end marker
|
CSMWorld::UniversalId::Type_None // end marker
|
||||||
};
|
};
|
||||||
|
|
|
@ -64,7 +64,7 @@ void Script::save(ESMWriter &esm)
|
||||||
memcpy(data.mName.name, mId.c_str(), mId.size());
|
memcpy(data.mName.name, mId.c_str(), mId.size());
|
||||||
|
|
||||||
esm.writeHNT("SCHD", data, 52);
|
esm.writeHNT("SCHD", data, 52);
|
||||||
|
|
||||||
if (!mVarNames.empty())
|
if (!mVarNames.empty())
|
||||||
{
|
{
|
||||||
esm.startSubRecord("SCVR");
|
esm.startSubRecord("SCVR");
|
||||||
|
@ -76,10 +76,21 @@ void Script::save(ESMWriter &esm)
|
||||||
}
|
}
|
||||||
|
|
||||||
esm.startSubRecord("SCDT");
|
esm.startSubRecord("SCDT");
|
||||||
esm.write(&mScriptData[0], mData.mScriptDataSize);
|
esm.write(reinterpret_cast<const char * >(&mScriptData[0]), mData.mScriptDataSize);
|
||||||
esm.endRecord("SCDT");
|
esm.endRecord("SCDT");
|
||||||
|
|
||||||
esm.writeHNOString("SCTX", mScriptText);
|
esm.writeHNOString("SCTX", mScriptText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Script::blank()
|
||||||
|
{
|
||||||
|
mData.mNumShorts = mData.mNumLongs = mData.mNumFloats = 0;
|
||||||
|
mData.mScriptDataSize = 0;
|
||||||
|
mData.mStringTableSize = 0;
|
||||||
|
|
||||||
|
mVarNames.clear();
|
||||||
|
mScriptData.clear();
|
||||||
|
mScriptText = "Begin " + mId + "\n\nEnd " + mId + "\n";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,11 +52,14 @@ public:
|
||||||
SCHDstruct mData;
|
SCHDstruct mData;
|
||||||
|
|
||||||
std::vector<std::string> mVarNames; // Variable names
|
std::vector<std::string> mVarNames; // Variable names
|
||||||
std::vector<char> mScriptData; // Compiled bytecode
|
std::vector<unsigned char> mScriptData; // Compiled bytecode
|
||||||
std::string mScriptText; // Uncompiled script
|
std::string mScriptText; // Uncompiled script
|
||||||
|
|
||||||
void load(ESMReader &esm);
|
void load(ESMReader &esm);
|
||||||
void save(ESMWriter &esm);
|
void save(ESMWriter &esm);
|
||||||
|
|
||||||
|
void blank();
|
||||||
|
///< Set record to default state (does not touch the ID/index).
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue