From 5f1d3e0e2fb2c209d7ad23c6c53d69d4258e6788 Mon Sep 17 00:00:00 2001 From: Nelsson Huotari Date: Sat, 9 Jan 2021 22:20:57 +0200 Subject: [PATCH 1/5] Use the Topic ID of the cloned target from topicinfos --- apps/opencs/model/world/collection.hpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/apps/opencs/model/world/collection.hpp b/apps/opencs/model/world/collection.hpp index 451ef9d0e1..f657c67a1c 100644 --- a/apps/opencs/model/world/collection.hpp +++ b/apps/opencs/model/world/collection.hpp @@ -15,6 +15,7 @@ #include "columnbase.hpp" #include "collectionbase.hpp" +#include "info.hpp" #include "land.hpp" #include "landtexture.hpp" #include "ref.hpp" @@ -264,6 +265,13 @@ namespace CSMWorld CSMWorld::CellRef* ptr = (CSMWorld::CellRef*) ©.mModified; ptr->mRefNum.mIndex = 0; } + if (type == UniversalId::Type_TopicInfo || type == UniversalId::Type_JournalInfo) + { + CSMWorld::Info* ptr = (CSMWorld::Info*) ©.mModified; + std::vector splitStringContainer; + Misc::StringUtils::split(destination, splitStringContainer, "#"); + ptr->mTopicId = splitStringContainer[0]; + } int index = getAppendIndex(destination, type); insertRecord(copy, getAppendIndex(destination, type)); From 29416269b27434f0e1bf7854f736fb2ada47c9eb Mon Sep 17 00:00:00 2001 From: Nelsson Huotari Date: Sun, 10 Jan 2021 01:07:03 +0200 Subject: [PATCH 2/5] Update changelog --- CHANGELOG.md | 1 + CHANGELOG_PR.md | 1 + 2 files changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ee84ae6d70..123936d42e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ Bug #4055: Local scripts don't inherit variables from their base record Bug #4083: Door animation freezes when colliding with actors Bug #4247: Cannot walk up stairs in Ebonheart docks + Bug #4363: Editor: Defect in Clone Function for Dialogue Info records Bug #4447: Actor collision capsule shape allows looking through some walls Bug #4465: Collision shape overlapping causes twitching Bug #4476: Abot Gondoliers: player hangs in air during scenic travel diff --git a/CHANGELOG_PR.md b/CHANGELOG_PR.md index fdf27dc932..f70fbad575 100644 --- a/CHANGELOG_PR.md +++ b/CHANGELOG_PR.md @@ -35,6 +35,7 @@ Bug Fixes: Editor Bug Fixes: - Deleted and moved objects within a cell are now saved properly (#832) +- Topic and Journal Info records can now be cloned with a different parent Topic/Journal Id (#4363) - Verifier no longer checks for alleged 'race' entries in clothing body parts (#5400) - Loading mods now keeps the master index (#5675) - Flicker and crashing on XFCE4 fixed (#5703) From 3045d20a970afd0da6a63081186e545ca940bfe6 Mon Sep 17 00:00:00 2001 From: Nelsson Huotari Date: Sun, 10 Jan 2021 01:25:40 +0200 Subject: [PATCH 3/5] Make sure that vector isn't empty, just in case --- apps/opencs/model/world/collection.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/opencs/model/world/collection.hpp b/apps/opencs/model/world/collection.hpp index f657c67a1c..16ebb3a616 100644 --- a/apps/opencs/model/world/collection.hpp +++ b/apps/opencs/model/world/collection.hpp @@ -270,7 +270,7 @@ namespace CSMWorld CSMWorld::Info* ptr = (CSMWorld::Info*) ©.mModified; std::vector splitStringContainer; Misc::StringUtils::split(destination, splitStringContainer, "#"); - ptr->mTopicId = splitStringContainer[0]; + if (!splitStringContainer.empty()) ptr->mTopicId = splitStringContainer[0]; } int index = getAppendIndex(destination, type); From 7196ad74557d8c608a9401273a51220fd786f8db Mon Sep 17 00:00:00 2001 From: Nelsson Huotari Date: Sun, 10 Jan 2021 21:23:52 +0200 Subject: [PATCH 4/5] Implement an override-value when cloning, use when cloning info records --- apps/opencs/model/world/collection.hpp | 8 -------- apps/opencs/model/world/commands.cpp | 9 +++++++++ apps/opencs/model/world/commands.hpp | 3 +++ apps/opencs/view/world/infocreator.cpp | 4 ++++ 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/apps/opencs/model/world/collection.hpp b/apps/opencs/model/world/collection.hpp index 16ebb3a616..451ef9d0e1 100644 --- a/apps/opencs/model/world/collection.hpp +++ b/apps/opencs/model/world/collection.hpp @@ -15,7 +15,6 @@ #include "columnbase.hpp" #include "collectionbase.hpp" -#include "info.hpp" #include "land.hpp" #include "landtexture.hpp" #include "ref.hpp" @@ -265,13 +264,6 @@ namespace CSMWorld CSMWorld::CellRef* ptr = (CSMWorld::CellRef*) ©.mModified; ptr->mRefNum.mIndex = 0; } - if (type == UniversalId::Type_TopicInfo || type == UniversalId::Type_JournalInfo) - { - CSMWorld::Info* ptr = (CSMWorld::Info*) ©.mModified; - std::vector splitStringContainer; - Misc::StringUtils::split(destination, splitStringContainer, "#"); - if (!splitStringContainer.empty()) ptr->mTopicId = splitStringContainer[0]; - } int index = getAppendIndex(destination, type); insertRecord(copy, getAppendIndex(destination, type)); diff --git a/apps/opencs/model/world/commands.cpp b/apps/opencs/model/world/commands.cpp index e33be11397..34485a46d7 100644 --- a/apps/opencs/model/world/commands.cpp +++ b/apps/opencs/model/world/commands.cpp @@ -397,6 +397,10 @@ void CSMWorld::CloneCommand::redo() { mModel.cloneRecord (mIdOrigin, mId, mType); applyModifications(); + for (auto& value : mOverrideValues) + { + mModel.setData(mModel.getModelIndex (mId, value.first), value.second); + } } void CSMWorld::CloneCommand::undo() @@ -404,6 +408,11 @@ void CSMWorld::CloneCommand::undo() mModel.removeRow (mModel.getModelIndex (mId, 0).row()); } +void CSMWorld::CloneCommand::setOverrideValue(int column, QVariant value) +{ + mOverrideValues.emplace_back(std::make_pair(column, value)); +} + CSMWorld::CreatePathgridCommand::CreatePathgridCommand(IdTable& model, const std::string& id, QUndoCommand *parent) : CreateCommand(model, id, parent) { diff --git a/apps/opencs/model/world/commands.hpp b/apps/opencs/model/world/commands.hpp index 5776cae363..33608304f4 100644 --- a/apps/opencs/model/world/commands.hpp +++ b/apps/opencs/model/world/commands.hpp @@ -183,6 +183,7 @@ namespace CSMWorld class CloneCommand : public CreateCommand { std::string mIdOrigin; + std::vector> mOverrideValues; public: @@ -194,6 +195,8 @@ namespace CSMWorld void redo() override; void undo() override; + + void setOverrideValue(int column, QVariant value); }; class RevertCommand : public QUndoCommand diff --git a/apps/opencs/view/world/infocreator.cpp b/apps/opencs/view/world/infocreator.cpp index 2f1615c876..505de753c6 100644 --- a/apps/opencs/view/world/infocreator.cpp +++ b/apps/opencs/view/world/infocreator.cpp @@ -40,10 +40,14 @@ void CSVWorld::InfoCreator::configureCreateCommand (CSMWorld::CreateCommand& com command.addValue (table.findColumnIndex(CSMWorld::Columns::ColumnId_Rank), -1); command.addValue (table.findColumnIndex(CSMWorld::Columns::ColumnId_Gender), -1); command.addValue (table.findColumnIndex(CSMWorld::Columns::ColumnId_PcRank), -1); + CSMWorld::CloneCommand* cloneCommand = dynamic_cast (&command); + if (cloneCommand) cloneCommand->setOverrideValue(table.findColumnIndex(CSMWorld::Columns::ColumnId_Topic), mTopic->text()); } else { command.addValue (table.findColumnIndex(CSMWorld::Columns::ColumnId_Journal), mTopic->text()); + CSMWorld::CloneCommand* cloneCommand = dynamic_cast (&command); + if (cloneCommand) cloneCommand->setOverrideValue(table.findColumnIndex(CSMWorld::Columns::ColumnId_Journal), mTopic->text()); } } From 93b1b444f2a3abd13d5105b0bb35c41fc5498cd3 Mon Sep 17 00:00:00 2001 From: Nelsson Huotari Date: Mon, 11 Jan 2021 12:53:34 +0200 Subject: [PATCH 5/5] Optimize CreateCommand and CloneCommand configuration --- apps/opencs/view/world/infocreator.cpp | 27 +++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/apps/opencs/view/world/infocreator.cpp b/apps/opencs/view/world/infocreator.cpp index 505de753c6..cf1b48a195 100644 --- a/apps/opencs/view/world/infocreator.cpp +++ b/apps/opencs/view/world/infocreator.cpp @@ -34,20 +34,29 @@ void CSVWorld::InfoCreator::configureCreateCommand (CSMWorld::CreateCommand& com { CSMWorld::IdTable& table = dynamic_cast (*getData().getTableModel (getCollectionId())); + CSMWorld::CloneCommand* cloneCommand = dynamic_cast (&command); if (getCollectionId() == CSMWorld::UniversalId::Type_TopicInfos) { - command.addValue (table.findColumnIndex(CSMWorld::Columns::ColumnId_Topic), mTopic->text()); - command.addValue (table.findColumnIndex(CSMWorld::Columns::ColumnId_Rank), -1); - command.addValue (table.findColumnIndex(CSMWorld::Columns::ColumnId_Gender), -1); - command.addValue (table.findColumnIndex(CSMWorld::Columns::ColumnId_PcRank), -1); - CSMWorld::CloneCommand* cloneCommand = dynamic_cast (&command); - if (cloneCommand) cloneCommand->setOverrideValue(table.findColumnIndex(CSMWorld::Columns::ColumnId_Topic), mTopic->text()); + if (!cloneCommand) + { + command.addValue (table.findColumnIndex(CSMWorld::Columns::ColumnId_Topic), mTopic->text()); + command.addValue (table.findColumnIndex(CSMWorld::Columns::ColumnId_Rank), -1); + command.addValue (table.findColumnIndex(CSMWorld::Columns::ColumnId_Gender), -1); + command.addValue (table.findColumnIndex(CSMWorld::Columns::ColumnId_PcRank), -1); + } + else + { + cloneCommand->setOverrideValue(table.findColumnIndex(CSMWorld::Columns::ColumnId_Topic), mTopic->text()); + } } else { - command.addValue (table.findColumnIndex(CSMWorld::Columns::ColumnId_Journal), mTopic->text()); - CSMWorld::CloneCommand* cloneCommand = dynamic_cast (&command); - if (cloneCommand) cloneCommand->setOverrideValue(table.findColumnIndex(CSMWorld::Columns::ColumnId_Journal), mTopic->text()); + if (!cloneCommand) + { + command.addValue (table.findColumnIndex(CSMWorld::Columns::ColumnId_Journal), mTopic->text()); + } + else + cloneCommand->setOverrideValue(table.findColumnIndex(CSMWorld::Columns::ColumnId_Journal), mTopic->text()); } }