diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index e7e19be94..8a3d3c1c8 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -70,6 +70,7 @@ opencs_units (view/world cellcreator pathgridcreator referenceablecreator startscriptcreator referencecreator scenesubview infocreator scriptedit dialoguesubview previewsubview regionmap dragrecordtable nestedtable dialoguespinbox recordbuttonbar tableeditidaction scripterrortable extendedcommandconfigurator + bodypartcreator ) opencs_units_noqt (view/world diff --git a/apps/opencs/view/world/bodypartcreator.cpp b/apps/opencs/view/world/bodypartcreator.cpp new file mode 100644 index 000000000..a9fc3e063 --- /dev/null +++ b/apps/opencs/view/world/bodypartcreator.cpp @@ -0,0 +1,54 @@ +#include "bodypartcreator.hpp" + +#include + +#include "../../model/world/data.hpp" +#include "../../model/world/universalid.hpp" + +std::string CSVWorld::BodyPartCreator::getId() const +{ + std::string id = CSVWorld::GenericCreator::getId(); + + if (mFirstPerson->isChecked()) + { + id += ".1st"; + } + + return id; +} + +CSVWorld::BodyPartCreator::BodyPartCreator( + CSMWorld::Data& data, + QUndoStack& undoStack, + const CSMWorld::UniversalId& id +) : GenericCreator(data, undoStack, id) +{ + mFirstPerson = new QCheckBox("First Person", this); + insertBeforeButtons(mFirstPerson, false); + + connect(mFirstPerson, SIGNAL(clicked(bool)), this, SLOT(checkboxClicked())); +} + +std::string CSVWorld::BodyPartCreator::getErrors() const +{ + std::string errors; + + std::string id = getId(); + if (getData().hasId(id)) + { + errors = "ID is already in use"; + } + + return errors; +} + +void CSVWorld::BodyPartCreator::reset() +{ + CSVWorld::GenericCreator::reset(); + mFirstPerson->setChecked(false); +} + +void CSVWorld::BodyPartCreator::checkboxClicked() +{ + update(); +} diff --git a/apps/opencs/view/world/bodypartcreator.hpp b/apps/opencs/view/world/bodypartcreator.hpp new file mode 100644 index 000000000..3c27136dd --- /dev/null +++ b/apps/opencs/view/world/bodypartcreator.hpp @@ -0,0 +1,47 @@ +#ifndef BODYPARTCREATOR_HPP +#define BODYPARTCREATOR_HPP + +class QCheckBox; + +#include "genericcreator.hpp" + +namespace CSMWorld +{ + class Data; + class UniversalId; +} + +namespace CSVWorld +{ + /// \brief Record creator for body parts. + class BodyPartCreator : public GenericCreator + { + Q_OBJECT + + QCheckBox *mFirstPerson; + + private: + + /// \return ID entered by user. + virtual std::string getId() const; + + public: + + BodyPartCreator( + CSMWorld::Data& data, + QUndoStack& undoStack, + const CSMWorld::UniversalId& id); + + /// \return Error description for current user input. + virtual std::string getErrors() const; + + /// \brief Clear ID and checkbox input widgets. + virtual void reset(); + + private slots: + + void checkboxClicked(); + }; +} + +#endif // BODYPARTCREATOR_HPP diff --git a/apps/opencs/view/world/subviews.cpp b/apps/opencs/view/world/subviews.cpp index 93e105106..7c27bdf7a 100644 --- a/apps/opencs/view/world/subviews.cpp +++ b/apps/opencs/view/world/subviews.cpp @@ -17,6 +17,7 @@ #include "infocreator.hpp" #include "pathgridcreator.hpp" #include "previewsubview.hpp" +#include "bodypartcreator.hpp" void CSVWorld::addSubViewFactories (CSVDoc::SubViewFactoryManager& manager) { @@ -41,7 +42,6 @@ void CSVWorld::addSubViewFactories (CSVDoc::SubViewFactoryManager& manager) CSMWorld::UniversalId::Type_Birthsigns, CSMWorld::UniversalId::Type_Spells, CSMWorld::UniversalId::Type_Enchantments, - CSMWorld::UniversalId::Type_BodyParts, CSMWorld::UniversalId::Type_SoundGens, CSMWorld::UniversalId::Type_None // end marker @@ -51,6 +51,9 @@ void CSVWorld::addSubViewFactories (CSVDoc::SubViewFactoryManager& manager) manager.add (sTableTypes[i], new CSVDoc::SubViewFactoryWithCreator >); + manager.add (CSMWorld::UniversalId::Type_BodyParts, + new CSVDoc::SubViewFactoryWithCreator >); + manager.add (CSMWorld::UniversalId::Type_StartScripts, new CSVDoc::SubViewFactoryWithCreator); @@ -129,7 +132,6 @@ void CSVWorld::addSubViewFactories (CSVDoc::SubViewFactoryManager& manager) CSMWorld::UniversalId::Type_Sound, CSMWorld::UniversalId::Type_Faction, CSMWorld::UniversalId::Type_Enchantment, - CSMWorld::UniversalId::Type_BodyPart, CSMWorld::UniversalId::Type_SoundGen, CSMWorld::UniversalId::Type_None // end marker @@ -140,6 +142,9 @@ void CSVWorld::addSubViewFactories (CSVDoc::SubViewFactoryManager& manager) new CSVDoc::SubViewFactoryWithCreator > (false)); + manager.add (CSMWorld::UniversalId::Type_BodyPart, + new CSVDoc::SubViewFactoryWithCreator > (false)); + manager.add (CSMWorld::UniversalId::Type_StartScript, new CSVDoc::SubViewFactoryWithCreator(false));