Editor: add creator for body parts

Added creator subclass for body parts to allow adding first person
parts. IDs for first person body parts are expected to end with ".1st".
pull/191/head^2
Rob Cutmore 8 years ago
parent 77bf1efc1a
commit 343f2cb81d

@ -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

@ -0,0 +1,54 @@
#include "bodypartcreator.hpp"
#include <QCheckBox>
#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();
}

@ -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

@ -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<TableSubView, CreatorFactory<GenericCreator> >);
manager.add (CSMWorld::UniversalId::Type_BodyParts,
new CSVDoc::SubViewFactoryWithCreator<TableSubView, CreatorFactory<BodyPartCreator> >);
manager.add (CSMWorld::UniversalId::Type_StartScripts,
new CSVDoc::SubViewFactoryWithCreator<TableSubView, StartScriptCreatorFactory>);
@ -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<DialogueSubView,
CreatorFactory<GenericCreator> > (false));
manager.add (CSMWorld::UniversalId::Type_BodyPart,
new CSVDoc::SubViewFactoryWithCreator<DialogueSubView, CreatorFactory<BodyPartCreator> > (false));
manager.add (CSMWorld::UniversalId::Type_StartScript,
new CSVDoc::SubViewFactoryWithCreator<DialogueSubView, StartScriptCreatorFactory>(false));

Loading…
Cancel
Save