mirror of
https://github.com/OpenMW/openmw.git
synced 2025-06-19 19:11:32 +00:00
Merge branch 'ref_id_universal_id' into 'master'
Fix RefId based UniversalId (#7747) Closes #7747 See merge request OpenMW/openmw!3702
This commit is contained in:
commit
8a91e7057f
5 changed files with 19 additions and 5 deletions
|
@ -188,6 +188,8 @@ namespace
|
||||||
{
|
{
|
||||||
mStream << ": " << value;
|
mStream << ": " << value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void operator()(const ESM::RefId& value) const { mStream << ": " << value.toString(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GetTypeData
|
struct GetTypeData
|
||||||
|
@ -327,6 +329,12 @@ CSMWorld::UniversalId::UniversalId(Type type, ESM::RefId id)
|
||||||
throw std::logic_error("invalid RefId argument UniversalId type: " + std::to_string(type));
|
throw std::logic_error("invalid RefId argument UniversalId type: " + std::to_string(type));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CSMWorld::UniversalId::UniversalId(Type type, const UniversalId& id)
|
||||||
|
: mType(type)
|
||||||
|
, mValue(id.mValue)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
CSMWorld::UniversalId::UniversalId(Type type, int index)
|
CSMWorld::UniversalId::UniversalId(Type type, int index)
|
||||||
: mType(type)
|
: mType(type)
|
||||||
, mValue(index)
|
, mValue(index)
|
||||||
|
@ -361,6 +369,10 @@ const std::string& CSMWorld::UniversalId::getId() const
|
||||||
if (const std::string* result = std::get_if<std::string>(&mValue))
|
if (const std::string* result = std::get_if<std::string>(&mValue))
|
||||||
return *result;
|
return *result;
|
||||||
|
|
||||||
|
if (const ESM::RefId* refId = std::get_if<ESM::RefId>(&mValue))
|
||||||
|
if (const ESM::StringRefId* result = refId->getIf<ESM::StringRefId>())
|
||||||
|
return result->getValue();
|
||||||
|
|
||||||
throw std::logic_error("invalid access to ID of " + ::toString(getArgumentType()) + " UniversalId");
|
throw std::logic_error("invalid access to ID of " + ::toString(getArgumentType()) + " UniversalId");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -159,6 +159,8 @@ namespace CSMWorld
|
||||||
UniversalId(Type type, int index);
|
UniversalId(Type type, int index);
|
||||||
///< Using a type for a non-index-argument UniversalId will throw an exception.
|
///< Using a type for a non-index-argument UniversalId will throw an exception.
|
||||||
|
|
||||||
|
UniversalId(Type type, const UniversalId& id);
|
||||||
|
|
||||||
Class getClass() const;
|
Class getClass() const;
|
||||||
|
|
||||||
ArgumentType getArgumentType() const;
|
ArgumentType getArgumentType() const;
|
||||||
|
|
|
@ -629,7 +629,7 @@ void CSVDoc::View::addSubView(const CSMWorld::UniversalId& id, const std::string
|
||||||
if (isReferenceable)
|
if (isReferenceable)
|
||||||
{
|
{
|
||||||
view = mSubViewFactory.makeSubView(
|
view = mSubViewFactory.makeSubView(
|
||||||
CSMWorld::UniversalId(CSMWorld::UniversalId::Type_Referenceable, id.getId()), *mDocument);
|
CSMWorld::UniversalId(CSMWorld::UniversalId::Type_Referenceable, id), *mDocument);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -694,10 +694,10 @@ void CSVWorld::Table::previewRecord()
|
||||||
|
|
||||||
if (selectedRows.size() == 1)
|
if (selectedRows.size() == 1)
|
||||||
{
|
{
|
||||||
std::string id = getUniversalId(selectedRows.begin()->row()).getId();
|
CSMWorld::UniversalId id = getUniversalId(selectedRows.begin()->row());
|
||||||
|
|
||||||
QModelIndex index
|
QModelIndex index
|
||||||
= mModel->getModelIndex(id, mModel->findColumnIndex(CSMWorld::Columns::ColumnId_Modification));
|
= mModel->getModelIndex(id.getId(), mModel->findColumnIndex(CSMWorld::Columns::ColumnId_Modification));
|
||||||
|
|
||||||
if (mModel->data(index) != CSMWorld::RecordBase::State_Deleted)
|
if (mModel->data(index) != CSMWorld::RecordBase::State_Deleted)
|
||||||
emit editRequest(CSMWorld::UniversalId(CSMWorld::UniversalId::Type_Preview, id), "");
|
emit editRequest(CSMWorld::UniversalId(CSMWorld::UniversalId::Type_Preview, id), "");
|
||||||
|
|
|
@ -177,11 +177,11 @@ namespace CSMWorld
|
||||||
UniversalId::ArgumentType_Id, "Instance", "Instance: f", ":./instance.png" },
|
UniversalId::ArgumentType_Id, "Instance", "Instance: f", ":./instance.png" },
|
||||||
|
|
||||||
Params{ UniversalId(UniversalId::Type_Reference, ESM::RefId::stringRefId("g")), UniversalId::Type_Reference,
|
Params{ UniversalId(UniversalId::Type_Reference, ESM::RefId::stringRefId("g")), UniversalId::Type_Reference,
|
||||||
UniversalId::Class_SubRecord, UniversalId::ArgumentType_RefId, "Instance", "Instance: \"g\"",
|
UniversalId::Class_SubRecord, UniversalId::ArgumentType_RefId, "Instance", "Instance: g",
|
||||||
":./instance.png" },
|
":./instance.png" },
|
||||||
Params{ UniversalId(UniversalId::Type_Reference, ESM::RefId::index(ESM::REC_SKIL, 42)),
|
Params{ UniversalId(UniversalId::Type_Reference, ESM::RefId::index(ESM::REC_SKIL, 42)),
|
||||||
UniversalId::Type_Reference, UniversalId::Class_SubRecord, UniversalId::ArgumentType_RefId, "Instance",
|
UniversalId::Type_Reference, UniversalId::Class_SubRecord, UniversalId::ArgumentType_RefId, "Instance",
|
||||||
"Instance: Index:SKIL:0x2a", ":./instance.png" },
|
"Instance: SKIL:0x2a", ":./instance.png" },
|
||||||
};
|
};
|
||||||
|
|
||||||
INSTANTIATE_TEST_SUITE_P(ValidParams, CSMWorldUniversalIdValidPerTypeTest, ValuesIn(validParams));
|
INSTANTIATE_TEST_SUITE_P(ValidParams, CSMWorldUniversalIdValidPerTypeTest, ValuesIn(validParams));
|
||||||
|
|
Loading…
Reference in a new issue