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
parent
77bf1efc1a
commit
343f2cb81d
@ -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
|
Loading…
Reference in New Issue