Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Layer SDL Animation base class editor #79

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/PrpShop/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ set(PrpShop_Headers
PRP/Surface/QFadeOpacityMod.h
PRP/Surface/QLayer.h
PRP/Surface/QLayerAnimation.h
PRP/Surface/QLayerAnimationBase.h
PRP/Surface/QLayerLinkAnimation.h
PRP/Surface/QLayerMovie.h
PRP/Surface/QLayerSDLAnimation.h
Expand Down Expand Up @@ -126,6 +127,7 @@ set(PrpShop_Sources
PRP/Surface/QFadeOpacityMod.cpp
PRP/Surface/QLayer.cpp
PRP/Surface/QLayerAnimation.cpp
PRP/Surface/QLayerAnimationBase.cpp
PRP/Surface/QLayerLinkAnimation.cpp
PRP/Surface/QLayerMovie.cpp
PRP/Surface/QLayerSDLAnimation.cpp
Expand Down
3 changes: 3 additions & 0 deletions src/PrpShop/PRP/QCreatable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ void QCreatable::closeEvent(QCloseEvent*)
#include "PRP/Surface/QFadeOpacityMod.h"
#include "PRP/Surface/QLayer.h"
#include "PRP/Surface/QLayerAnimation.h"
#include "PRP/Surface/QLayerAnimationBase.h"
#include "PRP/Surface/QLayerLinkAnimation.h"
#include "PRP/Surface/QLayerMovie.h"
#include "PRP/Surface/QLayerSDLAnimation.h"
Expand Down Expand Up @@ -210,6 +211,8 @@ QCreatable* pqMakeCreatableForm(plCreatable* pCre, QWidget* parent, int forceTyp
return new QLayer(pCre, parent);
case kLayerAnimation:
return new QLayerAnimation(pCre, parent);
case kLayerAnimationBase:
return new QLayerAnimationBase(pCre, parent);
case kLayerAVI:
return new QLayerMovie(pCre, parent);
case kLayerBink:
Expand Down
173 changes: 6 additions & 167 deletions src/PrpShop/PRP/Surface/QLayerAnimation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,184 +16,23 @@

#include "QLayerAnimation.h"

#include <QLabel>
#include <QGroupBox>
#include <QGridLayout>
#include <QSpacerItem>
#include <ResManager/plFactory.h>
#include "Main.h"
#include "QKeyDialog.h"
#include <PRP/Surface/plLayerAnimation.h>

QLayerAnimation::QLayerAnimation(plCreatable* pCre, QWidget* parent)
: QCreatable(pCre, kLayerAnimation, parent)
{
plLayerAnimation* lay = plLayerAnimation::Convert(fCreatable);

fSynchObjLink = new QCreatableLink(this, false);
fSynchObjLink->setCreatable(lay, tr("Synch Flags"));
fSynchObjLink->setForceType(kSynchedObject);

fBaseLayer = new QCreatableLink(this);
fBaseLayer->setKey(lay->getUnderLay());

QGroupBox* controllerGroup = new QGroupBox(tr("Animation Controllers"), this);
QGridLayout* controllerLayout = new QGridLayout(controllerGroup);
controllerLayout->setVerticalSpacing(0);
controllerLayout->setHorizontalSpacing(8);
fPreshade = new QControllerLink(tr("Preshade Color"), controllerGroup);
fRuntime = new QControllerLink(tr("Runtime Color"), controllerGroup);
fAmbient = new QControllerLink(tr("Ambient Color"), controllerGroup);
fSpecular = new QControllerLink(tr("Specular Color"), controllerGroup);
fOpacity = new QControllerLink(tr("Opacity"), controllerGroup);
fTransform = new QControllerLink(tr("UVW Transform"), controllerGroup);
controllerLayout->addWidget(fPreshade, 0, 0);
controllerLayout->addWidget(fRuntime, 1, 0);
controllerLayout->addWidget(fAmbient, 2, 0);
controllerLayout->addWidget(fSpecular, 3, 0);
controllerLayout->addWidget(fOpacity, 4, 0);
controllerLayout->addWidget(fTransform, 5, 0);

fPreshade->setCreatable(lay->getPreshadeCtl());
fRuntime->setCreatable(lay->getRuntimeCtl());
fAmbient->setCreatable(lay->getAmbientCtl());
fSpecular->setCreatable(lay->getSpecularCtl());
fOpacity->setCreatable(lay->getOpacityCtl());
fTransform->setCreatable(lay->getTransformCtl());
fLayerAnimBaseLink = new QCreatableLink(this, false);
fLayerAnimBaseLink->setCreatable(lay, tr("Layer Animation Properties"));
fLayerAnimBaseLink->setForceType(kLayerAnimationBase);

fAnimTimeConvert = new QCreatableLink(this, false);
fAnimTimeConvert->setCreatable(&lay->getTimeConvert(), tr("Animation Time Properties"));

QGridLayout* layout = new QGridLayout(this);
layout->setContentsMargins(8, 8, 8, 8);
layout->addWidget(fSynchObjLink, 0, 0, 1, 2);
layout->addWidget(new QLabel(tr("Base Layer:"), this), 1, 0);
layout->addWidget(fBaseLayer, 1, 1);
layout->addWidget(controllerGroup, 2, 0, 1, 2);
layout->addWidget(fAnimTimeConvert, 3, 0, 1, 2);

connect(fBaseLayer, &QCreatableLink::addObject, this, &QLayerAnimation::setBaseLayer);
connect(fBaseLayer, &QCreatableLink::delObject, this, &QLayerAnimation::unsetBaseLayer);
connect(fPreshade, &QControllerLink::createObject, this, &QLayerAnimation::newPreshade);
connect(fPreshade, &QControllerLink::delObject, this, &QLayerAnimation::delPreshade);
connect(fRuntime, &QControllerLink::createObject, this, &QLayerAnimation::newRuntime);
connect(fRuntime, &QControllerLink::delObject, this, &QLayerAnimation::delRuntime);
connect(fAmbient, &QControllerLink::createObject, this, &QLayerAnimation::newAmbient);
connect(fAmbient, &QControllerLink::delObject, this, &QLayerAnimation::delAmbient);
connect(fSpecular, &QControllerLink::createObject, this, &QLayerAnimation::newSpecular);
connect(fSpecular, &QControllerLink::delObject, this, &QLayerAnimation::delSpecular);
connect(fOpacity, &QControllerLink::createObject, this, &QLayerAnimation::newOpacity);
connect(fOpacity, &QControllerLink::delObject, this, &QLayerAnimation::delOpacity);
connect(fTransform, &QControllerLink::createObject, this, &QLayerAnimation::newTransform);
connect(fTransform, &QControllerLink::delObject, this, &QLayerAnimation::delTransform);
}

void QLayerAnimation::setBaseLayer()
{
plLayerAnimation* lay = plLayerAnimation::Convert(fCreatable);
QFindKeyDialog dlg(this);
if (lay->getUnderLay().Exists())
dlg.init(PrpShopMain::ResManager(), lay->getUnderLay());
else
dlg.init(PrpShopMain::ResManager(), lay->getKey()->getLocation(), kLayer);
if (dlg.exec() == QDialog::Accepted) {
lay->setUnderLay(dlg.selection());
fBaseLayer->setKey(lay->getUnderLay());
}
}

void QLayerAnimation::unsetBaseLayer()
{
plLayerAnimation* lay = plLayerAnimation::Convert(fCreatable);
lay->setUnderLay(plKey());
fBaseLayer->setCreatable(NULL, "(None)");
}

void QLayerAnimation::newPreshade(short type)
{
plLayerAnimation* lay = plLayerAnimation::Convert(fCreatable);
plController* pCre = plController::Convert(plFactory::Create(type));
lay->setPreshadeCtl(pCre);
fPreshade->setCreatable(pCre);
}

void QLayerAnimation::newRuntime(short type)
{
plLayerAnimation* lay = plLayerAnimation::Convert(fCreatable);
plController* pCre = plController::Convert(plFactory::Create(type));
lay->setRuntimeCtl(pCre);
fRuntime->setCreatable(pCre);
}

void QLayerAnimation::newAmbient(short type)
{
plLayerAnimation* lay = plLayerAnimation::Convert(fCreatable);
plController* pCre = plController::Convert(plFactory::Create(type));
lay->setAmbientCtl(pCre);
fAmbient->setCreatable(pCre);
}

void QLayerAnimation::newSpecular(short type)
{
plLayerAnimation* lay = plLayerAnimation::Convert(fCreatable);
plController* pCre = plController::Convert(plFactory::Create(type));
lay->setSpecularCtl(pCre);
fSpecular->setCreatable(pCre);
}

void QLayerAnimation::newOpacity(short type)
{
plLayerAnimation* lay = plLayerAnimation::Convert(fCreatable);
plController* pCre = plController::Convert(plFactory::Create(type));
lay->setOpacityCtl(pCre);
fOpacity->setCreatable(pCre);
}

void QLayerAnimation::newTransform(short type)
{
plLayerAnimation* lay = plLayerAnimation::Convert(fCreatable);
plController* pCre = plController::Convert(plFactory::Create(type));
lay->setTransformCtl(pCre);
fTransform->setCreatable(pCre);
}

void QLayerAnimation::delPreshade()
{
plLayerAnimation* lay = plLayerAnimation::Convert(fCreatable);
lay->setPreshadeCtl(NULL);
fPreshade->setCreatable(NULL);
}

void QLayerAnimation::delRuntime()
{
plLayerAnimation* lay = plLayerAnimation::Convert(fCreatable);
lay->setRuntimeCtl(NULL);
fRuntime->setCreatable(NULL);
}

void QLayerAnimation::delAmbient()
{
plLayerAnimation* lay = plLayerAnimation::Convert(fCreatable);
lay->setAmbientCtl(NULL);
fAmbient->setCreatable(NULL);
}

void QLayerAnimation::delSpecular()
{
plLayerAnimation* lay = plLayerAnimation::Convert(fCreatable);
lay->setSpecularCtl(NULL);
fSpecular->setCreatable(NULL);
}

void QLayerAnimation::delOpacity()
{
plLayerAnimation* lay = plLayerAnimation::Convert(fCreatable);
lay->setOpacityCtl(NULL);
fOpacity->setCreatable(NULL);
}

void QLayerAnimation::delTransform()
{
plLayerAnimation* lay = plLayerAnimation::Convert(fCreatable);
lay->setTransformCtl(NULL);
fTransform->setCreatable(NULL);
layout->addWidget(fLayerAnimBaseLink, 0, 0);
layout->addWidget(fAnimTimeConvert, 1, 0);
}
29 changes: 1 addition & 28 deletions src/PrpShop/PRP/Surface/QLayerAnimation.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,45 +19,18 @@

#include "PRP/QCreatable.h"

#include <PRP/Surface/plLayerAnimation.h>
#include "PRP/QObjLink.h"
#include "PRP/QMatrix44.h"
#include "QColorEdit.h"

class QLayerAnimation : public QCreatable
{
Q_OBJECT

protected:
QCreatableLink* fSynchObjLink;
QCreatableLink* fBaseLayer;
QControllerLink* fPreshade;
QControllerLink* fRuntime;
QControllerLink* fAmbient;
QControllerLink* fSpecular;
QControllerLink* fOpacity;
QControllerLink* fTransform;
QCreatableLink* fLayerAnimBaseLink;
QCreatableLink* fAnimTimeConvert;

public:
QLayerAnimation(plCreatable* pCre, QWidget* parent = NULL);

protected slots:
void setBaseLayer();
void unsetBaseLayer();

void newPreshade(short type);
void newRuntime(short type);
void newAmbient(short type);
void newSpecular(short type);
void newOpacity(short type);
void newTransform(short type);
void delPreshade();
void delRuntime();
void delAmbient();
void delSpecular();
void delOpacity();
void delTransform();
};

#endif
Loading