From fb8a2093cd1a40762cc823c827d292dda02c2f1c Mon Sep 17 00:00:00 2001 From: MAtahualpa Date: Sat, 18 Feb 2017 15:40:07 +0100 Subject: [PATCH] Replace "Female" check box with a combo box, part 2/2 (fixes #3757) Replaces the "Female" check box in BodyPart records with a "Gender" combo box. This is the second of two related fixes, the first one covering NPC records. Related issue: - Fixes #3757: Editor: Replace "Female" check box in BodyPart records with "Gender" combo box (https://bugs.openmw.org/issues/3757) Tests: The changes were successfully tested in OpenMW-CS by manipulating several BodyPart records. --- apps/opencs/model/world/columnimp.hpp | 35 +++++++++++++++++++++++++++ apps/opencs/model/world/data.cpp | 2 +- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/apps/opencs/model/world/columnimp.hpp b/apps/opencs/model/world/columnimp.hpp index 4e608dbbd..33a71e97a 100644 --- a/apps/opencs/model/world/columnimp.hpp +++ b/apps/opencs/model/world/columnimp.hpp @@ -1757,6 +1757,41 @@ namespace CSMWorld return true; } }; + + template + struct GenderNpcColumn : public Column + { + GenderNpcColumn() + : Column(Columns::ColumnId_GenderNpc, ColumnBase::Display_GenderNpc) + {} + + virtual QVariant get(const Record& record) const + { + // Implemented this way to allow additional gender types in the future. + if ((record.get().mData.mFlags & ESM::BodyPart::BPF_Female) == ESM::BodyPart::BPF_Female) + return 1; + + return 0; + } + + virtual void set(Record& record, const QVariant& data) + { + ESXRecordT record2 = record.get(); + + // Implemented this way to allow additional gender types in the future. + if (data.toInt() == 1) + record2.mData.mFlags = (record2.mData.mFlags & ~ESM::BodyPart::BPF_Female) | ESM::BodyPart::BPF_Female; + else + record2.mData.mFlags = record2.mData.mFlags & ~ESM::BodyPart::BPF_Female; + + record.setModified(record2); + } + + virtual bool isEditable() const + { + return true; + } + }; template struct EnchantmentTypeColumn : public Column diff --git a/apps/opencs/model/world/data.cpp b/apps/opencs/model/world/data.cpp index da4942eec..5a59f19f7 100644 --- a/apps/opencs/model/world/data.cpp +++ b/apps/opencs/model/world/data.cpp @@ -363,7 +363,7 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc mBodyParts.addColumn (new FixedRecordTypeColumn (UniversalId::Type_BodyPart)); mBodyParts.addColumn (new BodyPartTypeColumn); mBodyParts.addColumn (new VampireColumn); - mBodyParts.addColumn (new FlagColumn (Columns::ColumnId_Female, ESM::BodyPart::BPF_Female)); + mBodyParts.addColumn(new GenderNpcColumn); mBodyParts.addColumn (new FlagColumn (Columns::ColumnId_Playable, ESM::BodyPart::BPF_NotPlayable, ColumnBase::Flag_Table | ColumnBase::Flag_Dialogue, true));