From 33cd04b37d6d1cc2d7c1d4a1d1fdbe8060ebe7c9 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 25 Sep 2014 11:40:45 +0200 Subject: [PATCH] added missing sound gen table columns --- apps/opencs/model/world/columnbase.hpp | 3 +- apps/opencs/model/world/columnimp.hpp | 82 ++++++++++++++++++++++++++ apps/opencs/model/world/columns.cpp | 9 +++ apps/opencs/model/world/columns.hpp | 2 + apps/opencs/model/world/data.cpp | 3 + apps/opencs/view/doc/viewmanager.cpp | 3 +- 6 files changed, 100 insertions(+), 2 deletions(-) diff --git a/apps/opencs/model/world/columnbase.hpp b/apps/opencs/model/world/columnbase.hpp index 45cb47ba0..85675c8a3 100644 --- a/apps/opencs/model/world/columnbase.hpp +++ b/apps/opencs/model/world/columnbase.hpp @@ -101,7 +101,8 @@ namespace CSMWorld Display_Texture, Display_Video, Display_Colour, - Display_ScriptLines // console context + Display_ScriptLines, // console context + Display_SoundGeneratorType }; int mColumnId; diff --git a/apps/opencs/model/world/columnimp.hpp b/apps/opencs/model/world/columnimp.hpp index b93deccb7..a43be43d4 100644 --- a/apps/opencs/model/world/columnimp.hpp +++ b/apps/opencs/model/world/columnimp.hpp @@ -1982,6 +1982,88 @@ namespace CSMWorld return false; } }; + + template + struct SoundColumn : public Column + { + SoundColumn() + : Column (Columns::ColumnId_Sound, ColumnBase::Display_Sound) + {} + + virtual QVariant get (const Record& record) const + { + return QString::fromUtf8 (record.get().mSound.c_str()); + } + + virtual void set (Record& record, const QVariant& data) + { + ESXRecordT record2 = record.get(); + + record2.mSound = data.toString().toUtf8().constData(); + + record.setModified (record2); + } + + virtual bool isEditable() const + { + return true; + } + }; + + template + struct CreatureColumn : public Column + { + CreatureColumn() + : Column (Columns::ColumnId_Creature, ColumnBase::Display_Creature) + {} + + virtual QVariant get (const Record& record) const + { + return QString::fromUtf8 (record.get().mCreature.c_str()); + } + + virtual void set (Record& record, const QVariant& data) + { + ESXRecordT record2 = record.get(); + + record2.mCreature = data.toString().toUtf8().constData(); + + record.setModified (record2); + } + + virtual bool isEditable() const + { + return true; + } + }; + + template + struct SoundGeneratorTypeColumn : public Column + { + SoundGeneratorTypeColumn() + : Column (Columns::ColumnId_SoundGeneratorType, ColumnBase::Display_SoundGeneratorType) + {} + + virtual QVariant get (const Record& record) const + { + return static_cast (record.get().mType); + } + + virtual void set (Record& record, const QVariant& data) + { + ESXRecordT record2 = record.get(); + + record2.mType = data.toInt(); + + record.setModified (record2); + } + + virtual bool isEditable() const + { + return true; + } + }; + } #endif diff --git a/apps/opencs/model/world/columns.cpp b/apps/opencs/model/world/columns.cpp index 90af20059..44d8755c1 100644 --- a/apps/opencs/model/world/columns.cpp +++ b/apps/opencs/model/world/columns.cpp @@ -186,6 +186,8 @@ namespace CSMWorld { ColumnId_GlobalProfile, "Global Profile" }, { ColumnId_RefNumCounter, "RefNum Counter" }, { ColumnId_RefNum, "RefNum" }, + { ColumnId_Creature, "Creature" }, + { ColumnId_SoundGeneratorType, "Sound Generator Type" }, { ColumnId_UseValue1, "Use value 1" }, { ColumnId_UseValue2, "Use value 2" }, @@ -327,6 +329,12 @@ namespace "Skin", "Clothing", "Armour", 0 }; + static const char *sSoundGeneratorType[] = + { + "Left Foot", "Right Foot", "Swim Left", "Swim Right", "Moan", "Roar", "Scream", + "Land", 0 + }; + const char **getEnumNames (CSMWorld::Columns::ColumnId column) { switch (column) @@ -347,6 +355,7 @@ namespace case CSMWorld::Columns::ColumnId_EnchantmentType: return sEnchantmentTypes; case CSMWorld::Columns::ColumnId_BodyPartType: return sBodyPartTypes; case CSMWorld::Columns::ColumnId_MeshType: return sMeshTypes; + case CSMWorld::Columns::ColumnId_SoundGeneratorType: return sSoundGeneratorType; default: return 0; } diff --git a/apps/opencs/model/world/columns.hpp b/apps/opencs/model/world/columns.hpp index 5da1765a4..ea8a9200d 100644 --- a/apps/opencs/model/world/columns.hpp +++ b/apps/opencs/model/world/columns.hpp @@ -179,6 +179,8 @@ namespace CSMWorld ColumnId_GlobalProfile = 167, ColumnId_RefNumCounter = 168, ColumnId_RefNum = 169, + ColumnId_Creature = 170, + ColumnId_SoundGeneratorType = 171, // Allocated to a separate value range, so we don't get a collision should we ever need // to extend the number of use values. diff --git a/apps/opencs/model/world/data.cpp b/apps/opencs/model/world/data.cpp index 7bca63277..b74984c10 100644 --- a/apps/opencs/model/world/data.cpp +++ b/apps/opencs/model/world/data.cpp @@ -224,6 +224,9 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc mSoundGens.addColumn (new StringIdColumn); mSoundGens.addColumn (new RecordStateColumn); mSoundGens.addColumn (new FixedRecordTypeColumn (UniversalId::Type_SoundGen)); + mSoundGens.addColumn (new CreatureColumn); + mSoundGens.addColumn (new SoundColumn); + mSoundGens.addColumn (new SoundGeneratorTypeColumn); mRefs.addColumn (new StringIdColumn (true)); mRefs.addColumn (new RecordStateColumn); diff --git a/apps/opencs/view/doc/viewmanager.cpp b/apps/opencs/view/doc/viewmanager.cpp index 638b42d5f..608762c6c 100644 --- a/apps/opencs/view/doc/viewmanager.cpp +++ b/apps/opencs/view/doc/viewmanager.cpp @@ -81,7 +81,8 @@ CSVDoc::ViewManager::ViewManager (CSMDoc::DocumentManager& documentManager) { CSMWorld::ColumnBase::Display_EnchantmentType, CSMWorld::Columns::ColumnId_EnchantmentType, false }, { CSMWorld::ColumnBase::Display_BodyPartType, CSMWorld::Columns::ColumnId_BodyPartType, false }, { CSMWorld::ColumnBase::Display_MeshType, CSMWorld::Columns::ColumnId_MeshType, false }, - { CSMWorld::ColumnBase::Display_Gender, CSMWorld::Columns::ColumnId_Gender, true } + { CSMWorld::ColumnBase::Display_Gender, CSMWorld::Columns::ColumnId_Gender, true }, + { CSMWorld::ColumnBase::Display_SoundGeneratorType, CSMWorld::Columns::ColumnId_SoundGeneratorType, false } }; for (std::size_t i=0; i