TopicInfos result script are now displayed in dialogue subviews.

test
cc9cii 10 years ago
parent cb3396643b
commit 18162557b0

@ -25,7 +25,7 @@ opencs_units (model/world
opencs_units_noqt (model/world
universalid record commands columnbase scriptcontext cell refidcollection
refidadapter refiddata refidadapterimp ref collectionbase refcollection columns infocollection tablemimedata cellcoordinates cellselection resources resourcesmanager scope
pathgrid landtexture land nestedtablewrapper nestedcollection nestedcoladapterimp
pathgrid landtexture land nestedtablewrapper nestedcollection nestedcoladapterimp nestedinfocollection
)
opencs_hdrs_noqt (model/world

@ -178,8 +178,8 @@ namespace CSMWorld
template<typename ESXRecordT>
struct NestedParentColumn : public Column<ESXRecordT>
{
NestedParentColumn (int id) : Column<ESXRecordT> (id,
ColumnBase::Display_NestedHeader, ColumnBase::Flag_Dialogue)
NestedParentColumn (int id, int flags = ColumnBase::Flag_Dialogue) : Column<ESXRecordT> (id,
ColumnBase::Display_NestedHeader, flags)
{}
virtual QVariant get (const Record<ESXRecordT>& record) const

@ -272,6 +272,8 @@ namespace CSMWorld
{ ColumnId_PowerList, "Powers" },
{ ColumnId_SkillImpact, "Skills" },
{ ColumnId_InfoList, "Info List" },
{ ColumnId_UseValue1, "Use value 1" },
{ ColumnId_UseValue2, "Use value 2" },
{ ColumnId_UseValue3, "Use value 3" },

@ -262,6 +262,8 @@ namespace CSMWorld
ColumnId_PowerList = 238,
ColumnId_SkillImpact = 239, // impact from magic effects
ColumnId_InfoList = 240,
// Allocated to a separate value range, so we don't get a collision should we ever need
// to extend the number of use values.
ColumnId_UseValue1 = 0x10000,

@ -193,11 +193,11 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc
index = mSpells.getColumns()-1;
mSpells.addAdapter (std::make_pair(&mSpells.getColumn(index), new EffectsListAdapter<ESM::Spell> ()));
mSpells.getNestableColumn(index)->addColumn(
new NestedChildColumn (Columns::ColumnId_EffectId, ColumnBase::Display_EffectId)); // false means no edit
new NestedChildColumn (Columns::ColumnId_EffectId, ColumnBase::Display_EffectId));
mSpells.getNestableColumn(index)->addColumn(
new NestedChildColumn (Columns::ColumnId_SkillImpact, ColumnBase::Display_SkillImpact));
mSpells.getNestableColumn(index)->addColumn(
new NestedChildColumn (Columns::ColumnId_Attribute, ColumnBase::Display_Attribute)); // reuse attribute
new NestedChildColumn (Columns::ColumnId_Attribute, ColumnBase::Display_Attribute));
mSpells.getNestableColumn(index)->addColumn(
new NestedChildColumn (Columns::ColumnId_EffectRange, ColumnBase::Display_EffectRange));
mSpells.getNestableColumn(index)->addColumn(
@ -235,6 +235,13 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc
mTopicInfos.addColumn (new PcRankColumn<Info>);
mTopicInfos.addColumn (new SoundFileColumn<Info>);
mTopicInfos.addColumn (new ResponseColumn<Info>);
// Result script
mTopicInfos.addColumn (new NestedParentColumn<Info> (Columns::ColumnId_InfoList,
ColumnBase::Flag_Dialogue | ColumnBase::Flag_Dialogue_List));
index = mTopicInfos.getColumns()-1;
mTopicInfos.addAdapter (std::make_pair(&mTopicInfos.getColumn(index), new InfoListAdapter ()));
mTopicInfos.getNestableColumn(index)->addColumn(
new NestedChildColumn (Columns::ColumnId_ScriptText, ColumnBase::Display_ScriptLines));
mJournalInfos.addColumn (new StringIdColumn<Info> (true));
mJournalInfos.addColumn (new RecordStateColumn<Info>);
@ -271,7 +278,7 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc
mEnchantments.getNestableColumn(index)->addColumn(
new NestedChildColumn (Columns::ColumnId_SkillImpact, ColumnBase::Display_SkillImpact));
mEnchantments.getNestableColumn(index)->addColumn(
new NestedChildColumn (Columns::ColumnId_Attribute, ColumnBase::Display_Attribute)); // reuse attribute
new NestedChildColumn (Columns::ColumnId_Attribute, ColumnBase::Display_Attribute));
mEnchantments.getNestableColumn(index)->addColumn(
new NestedChildColumn (Columns::ColumnId_EffectRange, ColumnBase::Display_EffectRange));
mEnchantments.getNestableColumn(index)->addColumn(
@ -423,7 +430,8 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc
addModel (new IdTree (&mSpells, &mSpells), UniversalId::Type_Spell);
addModel (new IdTable (&mTopics), UniversalId::Type_Topic);
addModel (new IdTable (&mJournals), UniversalId::Type_Journal);
addModel (new IdTable (&mTopicInfos, IdTable::Feature_ReorderWithinTopic), UniversalId::Type_TopicInfo);
addModel (new IdTree (&mTopicInfos, &mTopicInfos, IdTable::Feature_ReorderWithinTopic),
UniversalId::Type_TopicInfo);
addModel (new IdTable (&mJournalInfos, IdTable::Feature_ReorderWithinTopic), UniversalId::Type_JournalInfo);
addModel (new IdTable (&mCells, IdTable::Feature_ViewId), UniversalId::Type_Cell);
addModel (new IdTree (&mEnchantments, &mEnchantments), UniversalId::Type_Enchantment);

@ -42,6 +42,7 @@
#include "refidcollection.hpp"
#include "refcollection.hpp"
#include "infocollection.hpp"
#include "nestedinfocollection.hpp"
#include "pathgrid.hpp"
#ifndef Q_MOC_RUN
#include "subcellcollection.hpp"
@ -85,7 +86,7 @@ namespace CSMWorld
IdCollection<ESM::DebugProfile> mDebugProfiles;
IdCollection<ESM::SoundGenerator> mSoundGens;
IdCollection<ESM::StartScript> mStartScripts;
InfoCollection mTopicInfos;
NestedInfoCollection mTopicInfos;
InfoCollection mJournalInfos;
IdCollection<Cell> mCells;
IdCollection<LandTexture> mLandTextures;

@ -5,6 +5,7 @@
#include "idcollection.hpp"
#include "pathgrid.hpp"
#include "info.hpp"
namespace CSMWorld
{
@ -470,4 +471,61 @@ namespace CSMWorld
{
return static_cast<int>(record.get().mSoundList.size());
}
InfoListAdapter::InfoListAdapter () {}
void InfoListAdapter::addRow(Record<Info>& record, int position) const
{
throw std::logic_error ("cannot add a row to a fixed table");
}
void InfoListAdapter::removeRow(Record<Info>& record, int rowToRemove) const
{
throw std::logic_error ("cannot add a row to a fixed table");
}
void InfoListAdapter::setTable(Record<Info>& record,
const NestedTableWrapperBase& nestedTable) const
{
throw std::logic_error ("table operation not supported");
}
NestedTableWrapperBase* InfoListAdapter::table(const Record<Info>& record) const
{
throw std::logic_error ("table operation not supported");
}
QVariant InfoListAdapter::getData(const Record<Info>& record,
int subRowIndex, int subColIndex) const
{
Info info = record.get();
if (subColIndex == 0)
return QString(info.mResultScript.c_str());
else
throw std::runtime_error("Trying to access non-existing column in the nested table!");
}
void InfoListAdapter::setData(Record<Info>& record,
const QVariant& value, int subRowIndex, int subColIndex) const
{
Info info = record.get();
if (subColIndex == 0)
info.mResultScript = value.toString().toStdString();
else
throw std::runtime_error("Trying to access non-existing column in the nested table!");
record.setModified (info);
}
int InfoListAdapter::getColumnsCount(const Record<Info>& record) const
{
return 1;
}
int InfoListAdapter::getRowsCount(const Record<Info>& record) const
{
return 1; // fixed at size 1
}
}

@ -21,6 +21,7 @@ namespace ESM
namespace CSMWorld
{
struct Pathgrid;
struct Info;
struct PathgridPointsWrap : public NestedTableWrapperBase
{
@ -386,6 +387,31 @@ namespace CSMWorld
return static_cast<int>(record.get().mEffects.mList.size());
}
};
class InfoListAdapter : public NestedColumnAdapter<Info>
{
public:
InfoListAdapter ();
virtual void addRow(Record<Info>& record, int position) const;
virtual void removeRow(Record<Info>& record, int rowToRemove) const;
virtual void setTable(Record<Info>& record,
const NestedTableWrapperBase& nestedTable) const;
virtual NestedTableWrapperBase* table(const Record<Info>& record) const;
virtual QVariant getData(const Record<Info>& record,
int subRowIndex, int subColIndex) const;
virtual void setData(Record<Info>& record,
const QVariant& value, int subRowIndex, int subColIndex) const;
virtual int getColumnsCount(const Record<Info>& record) const;
virtual int getRowsCount(const Record<Info>& record) const;
};
}
#endif // CSM_WOLRD_NESTEDCOLADAPTERIMP_H

@ -0,0 +1,110 @@
#include "nestedinfocollection.hpp"
#include "nestedcoladapterimp.hpp"
namespace CSMWorld
{
NestedInfoCollection::NestedInfoCollection ()
{}
NestedInfoCollection::~NestedInfoCollection()
{
for (std::map<const ColumnBase *, NestedColumnAdapter<Info>* >::iterator
iter (mAdapters.begin()); iter!=mAdapters.end(); ++iter)
{
delete (*iter).second;
}
}
void NestedInfoCollection::addAdapter(std::pair<const ColumnBase*,
NestedColumnAdapter<Info>* > adapter)
{
mAdapters.insert(adapter);
}
const NestedColumnAdapter<Info>& NestedInfoCollection::getAdapter(const ColumnBase &column) const
{
std::map<const ColumnBase *, NestedColumnAdapter<Info>* >::const_iterator iter =
mAdapters.find (&column);
if (iter==mAdapters.end())
throw std::logic_error("No such column in the nestedidadapter");
return *iter->second;
}
void NestedInfoCollection::addNestedRow(int row, int column, int position)
{
Record<Info> record;
record.assign(Collection<Info, IdAccessor<Info> >::getRecord(row));
getAdapter(Collection<Info, IdAccessor<Info> >::getColumn(column)).addRow(record, position);
Collection<Info, IdAccessor<Info> >::setRecord(row, record);
}
void NestedInfoCollection::removeNestedRows(int row, int column, int subRow)
{
Record<Info> record;
record.assign(Collection<Info, IdAccessor<Info> >::getRecord(row));
getAdapter(Collection<Info, IdAccessor<Info> >::getColumn(column)).removeRow(record, subRow);
Collection<Info, IdAccessor<Info> >::setRecord(row, record);
}
QVariant NestedInfoCollection::getNestedData (int row,
int column, int subRow, int subColumn) const
{
return getAdapter(Collection<Info, IdAccessor<Info> >::getColumn(column)).getData(
Collection<Info, IdAccessor<Info> >::getRecord(row), subRow, subColumn);
}
void NestedInfoCollection::setNestedData(int row,
int column, const QVariant& data, int subRow, int subColumn)
{
Record<Info> record;
record.assign(Collection<Info, IdAccessor<Info> >::getRecord(row));
getAdapter(Collection<Info, IdAccessor<Info> >::getColumn(column)).setData(
record, data, subRow, subColumn);
Collection<Info, IdAccessor<Info> >::setRecord(row, record);
}
CSMWorld::NestedTableWrapperBase* NestedInfoCollection::nestedTable(int row,
int column) const
{
return getAdapter(Collection<Info, IdAccessor<Info> >::getColumn(column)).table(
Collection<Info, IdAccessor<Info> >::getRecord(row));
}
void NestedInfoCollection::setNestedTable(int row,
int column, const CSMWorld::NestedTableWrapperBase& nestedTable)
{
Record<Info> record;
record.assign(Collection<Info, IdAccessor<Info> >::getRecord(row));
getAdapter(Collection<Info, IdAccessor<Info> >::getColumn(column)).setTable(
record, nestedTable);
Collection<Info, IdAccessor<Info> >::setRecord(row, record);
}
int NestedInfoCollection::getNestedRowsCount(int row, int column) const
{
return getAdapter(Collection<Info, IdAccessor<Info> >::getColumn(column)).getRowsCount(
Collection<Info, IdAccessor<Info> >::getRecord(row));
}
int NestedInfoCollection::getNestedColumnsCount(int row, int column) const
{
return getAdapter(Collection<Info, IdAccessor<Info> >::getColumn(column)).getColumnsCount(
Collection<Info, IdAccessor<Info> >::getRecord(row));
}
CSMWorld::NestableColumn *NestedInfoCollection::getNestableColumn(int column)
{
return Collection<Info, IdAccessor<Info> >::getNestableColumn(column);
}
}

@ -0,0 +1,50 @@
#ifndef CSM_WOLRD_NESTEDINFOCOLLECTION_H
#define CSM_WOLRD_NESTEDINFOCOLLECTION_H
#include <map>
#include "infocollection.hpp"
#include "nestedcollection.hpp"
namespace CSMWorld
{
struct NestedTableWrapperBase;
template<typename ESXRecordT>
class NestedColumnAdapter;
class NestedInfoCollection : public InfoCollection, public NestedCollection
{
std::map<const ColumnBase*, NestedColumnAdapter<Info>* > mAdapters;
const NestedColumnAdapter<Info>& getAdapter(const ColumnBase &column) const;
public:
NestedInfoCollection ();
~NestedInfoCollection();
virtual void addNestedRow(int row, int column, int position);
virtual void removeNestedRows(int row, int column, int subRow);
virtual QVariant getNestedData(int row, int column, int subRow, int subColumn) const;
virtual void setNestedData(int row, int column, const QVariant& data, int subRow, int subColumn);
virtual NestedTableWrapperBase* nestedTable(int row, int column) const;
virtual void setNestedTable(int row, int column, const NestedTableWrapperBase& nestedTable);
virtual int getNestedRowsCount(int row, int column) const;
virtual int getNestedColumnsCount(int row, int column) const;
// this method is inherited from NestedCollection, not from Collection<Info, IdAccessor<Info> >
virtual NestableColumn *getNestableColumn(int column);
void addAdapter(std::pair<const ColumnBase*, NestedColumnAdapter<Info>* > adapter);
};
}
#endif // CSM_WOLRD_NESTEDINFOCOLLECTION_H

@ -85,7 +85,7 @@ CSMWorld::RefIdCollection::RefIdCollection()
mColumns.back().addColumn(
new NestedChildColumn (Columns::ColumnId_SkillImpact, ColumnBase::Display_SkillImpact));
mColumns.back().addColumn(
new NestedChildColumn (Columns::ColumnId_Attribute, ColumnBase::Display_Attribute)); // reuse attribute
new NestedChildColumn (Columns::ColumnId_Attribute, ColumnBase::Display_Attribute));
mColumns.back().addColumn(
new NestedChildColumn (Columns::ColumnId_EffectRange, ColumnBase::Display_EffectRange));
mColumns.back().addColumn(

Loading…
Cancel
Save