mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-25 11:52:40 +01:00
clang-format files in rwviewer/views
This commit is contained in:
parent
46628d98d9
commit
11a9907f07
@ -1,93 +1,86 @@
|
|||||||
#include "ModelViewer.hpp"
|
#include "ModelViewer.hpp"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <widgets/ModelFramesWidget.hpp>
|
|
||||||
#include <data/Skeleton.hpp>
|
#include <data/Skeleton.hpp>
|
||||||
#include <engine/Animator.hpp>
|
#include <engine/Animator.hpp>
|
||||||
#include <objects/GameObject.hpp>
|
|
||||||
#include "ViewerWidget.hpp"
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <objects/GameObject.hpp>
|
||||||
|
#include <widgets/ModelFramesWidget.hpp>
|
||||||
|
#include "ViewerWidget.hpp"
|
||||||
|
|
||||||
ModelViewer::ModelViewer(ViewerWidget* viewer, QWidget* parent, Qt::WindowFlags f)
|
ModelViewer::ModelViewer(ViewerWidget* viewer, QWidget* parent,
|
||||||
: ViewerInterface(parent, f), viewing(nullptr), skeleton(nullptr)
|
Qt::WindowFlags f)
|
||||||
{
|
: ViewerInterface(parent, f), viewing(nullptr), skeleton(nullptr) {
|
||||||
mainSplit = new QSplitter;
|
mainSplit = new QSplitter;
|
||||||
mainLayout = new QVBoxLayout;
|
mainLayout = new QVBoxLayout;
|
||||||
|
|
||||||
viewerWidget = viewer;
|
viewerWidget = viewer;
|
||||||
viewerWidget->setMinimumSize(250,250);
|
viewerWidget->setMinimumSize(250, 250);
|
||||||
|
|
||||||
animationWidget = new AnimationListWidget;
|
animationWidget = new AnimationListWidget;
|
||||||
connect(animationWidget, SIGNAL(selectedAnimationChanged(Animation*)),
|
connect(animationWidget, SIGNAL(selectedAnimationChanged(Animation*)),
|
||||||
SLOT(playAnimation(Animation*)));
|
SLOT(playAnimation(Animation*)));
|
||||||
|
|
||||||
frames = new ModelFramesWidget;
|
frames = new ModelFramesWidget;
|
||||||
frames->setMaximumWidth(300);
|
frames->setMaximumWidth(300);
|
||||||
|
|
||||||
mainSplit->addWidget(frames);
|
mainSplit->addWidget(frames);
|
||||||
mainSplit->addWidget(animationWidget);
|
mainSplit->addWidget(animationWidget);
|
||||||
mainLayout->addWidget(mainSplit);
|
mainLayout->addWidget(mainSplit);
|
||||||
|
|
||||||
this->setLayout(mainLayout);
|
this->setLayout(mainLayout);
|
||||||
|
|
||||||
connect(frames, SIGNAL(selectedFrameChanged(ModelFrame*)),
|
connect(frames, SIGNAL(selectedFrameChanged(ModelFrame*)), viewerWidget,
|
||||||
viewerWidget, SLOT(selectFrame(ModelFrame*)));
|
SLOT(selectFrame(ModelFrame*)));
|
||||||
setViewerWidget(viewerWidget);
|
setViewerWidget(viewerWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelViewer::setViewerWidget(ViewerWidget* widget)
|
void ModelViewer::setViewerWidget(ViewerWidget* widget) {
|
||||||
{
|
viewerWidget = widget;
|
||||||
viewerWidget = widget;
|
mainSplit->addWidget(viewerWidget);
|
||||||
mainSplit->addWidget(viewerWidget);
|
showModel(viewing);
|
||||||
showModel(viewing);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelViewer::showModel(Model* model)
|
void ModelViewer::showModel(Model* model) {
|
||||||
{
|
viewing = model;
|
||||||
viewing = model;
|
if (skeleton) {
|
||||||
if( skeleton )
|
delete skeleton;
|
||||||
{
|
}
|
||||||
delete skeleton;
|
skeleton = new Skeleton();
|
||||||
}
|
viewerWidget->showModel(model);
|
||||||
skeleton = new Skeleton();
|
frames->setModel(model, nullptr);
|
||||||
viewerWidget->showModel(model);
|
|
||||||
frames->setModel(model, nullptr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelViewer::showObject(uint16_t object)
|
void ModelViewer::showObject(uint16_t object) {
|
||||||
{
|
viewerWidget->showObject(object);
|
||||||
viewerWidget->showObject(object);
|
viewing = viewerWidget->currentModel();
|
||||||
viewing = viewerWidget->currentModel();
|
skeleton = viewerWidget->currentObject()->skeleton;
|
||||||
skeleton = viewerWidget->currentObject()->skeleton;
|
frames->setModel(viewing, skeleton);
|
||||||
frames->setModel(viewing, skeleton);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelViewer::loadAnimations(const QString& file)
|
void ModelViewer::loadAnimations(const QString& file) {
|
||||||
{
|
std::ifstream dfile(file.toStdString().c_str(), std::ios_base::binary);
|
||||||
std::ifstream dfile(file.toStdString().c_str(), std::ios_base::binary);
|
AnimationList anims;
|
||||||
AnimationList anims;
|
|
||||||
|
|
||||||
if(dfile.is_open())
|
if (dfile.is_open()) {
|
||||||
{
|
dfile.seekg(0, std::ios_base::end);
|
||||||
dfile.seekg(0, std::ios_base::end);
|
size_t length = dfile.tellg();
|
||||||
size_t length = dfile.tellg();
|
dfile.seekg(0);
|
||||||
dfile.seekg(0);
|
char* file = new char[length];
|
||||||
char *file = new char[length];
|
dfile.read(file, length);
|
||||||
dfile.read(file, length);
|
|
||||||
|
|
||||||
LoaderIFP loader;
|
LoaderIFP loader;
|
||||||
if( loader.loadFromMemory(file) ) {
|
if (loader.loadFromMemory(file)) {
|
||||||
for(auto& f : loader.animations) {
|
for (auto& f : loader.animations) {
|
||||||
anims.push_back(f);
|
anims.push_back(f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delete[] file;
|
delete[] file;
|
||||||
}
|
}
|
||||||
|
|
||||||
animationWidget->setAnimations(anims);
|
animationWidget->setAnimations(anims);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelViewer::playAnimation(Animation* anim)
|
void ModelViewer::playAnimation(Animation* anim) {
|
||||||
{
|
viewerWidget->currentObject()->animator->playAnimation(0, anim, 1.f, true);
|
||||||
viewerWidget->currentObject()->animator->playAnimation(0, anim, 1.f, true);
|
|
||||||
}
|
}
|
||||||
|
@ -7,11 +7,11 @@
|
|||||||
|
|
||||||
#include "ViewerInterface.hpp"
|
#include "ViewerInterface.hpp"
|
||||||
|
|
||||||
#include <QTreeView>
|
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QVBoxLayout>
|
|
||||||
#include <QSplitter>
|
|
||||||
#include <QLayout>
|
#include <QLayout>
|
||||||
|
#include <QSplitter>
|
||||||
|
#include <QTreeView>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
class ViewerWidget;
|
class ViewerWidget;
|
||||||
class Model;
|
class Model;
|
||||||
@ -19,41 +19,41 @@ class Skeleton;
|
|||||||
class ModelFramesWidget;
|
class ModelFramesWidget;
|
||||||
class Animation;
|
class Animation;
|
||||||
|
|
||||||
class ModelViewer : public ViewerInterface
|
class ModelViewer : public ViewerInterface {
|
||||||
{
|
Q_OBJECT
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
Model* viewing;
|
Model* viewing;
|
||||||
Skeleton* skeleton;
|
Skeleton* skeleton;
|
||||||
|
|
||||||
QSplitter* mainSplit;
|
QSplitter* mainSplit;
|
||||||
QVBoxLayout* mainLayout;
|
QVBoxLayout* mainLayout;
|
||||||
ViewerWidget* viewerWidget;
|
ViewerWidget* viewerWidget;
|
||||||
|
|
||||||
ModelFramesWidget* frames;
|
ModelFramesWidget* frames;
|
||||||
|
|
||||||
|
AnimationList loadedAnimations;
|
||||||
|
AnimationListWidget* animationWidget;
|
||||||
|
|
||||||
AnimationList loadedAnimations;
|
|
||||||
AnimationListWidget *animationWidget;
|
|
||||||
public:
|
public:
|
||||||
|
ModelViewer(ViewerWidget* viewer = 0, QWidget* parent = 0,
|
||||||
|
Qt::WindowFlags f = 0);
|
||||||
|
|
||||||
ModelViewer(ViewerWidget *viewer = 0, QWidget* parent = 0, Qt::WindowFlags f = 0);
|
void setViewerWidget(ViewerWidget* widget) override;
|
||||||
|
|
||||||
void setViewerWidget( ViewerWidget* widget ) override;
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display a raw model
|
* Display a raw model
|
||||||
*/
|
*/
|
||||||
void showModel(Model* model);
|
void showModel(Model* model);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display a game object's model
|
* Display a game object's model
|
||||||
*/
|
*/
|
||||||
void showObject(uint16_t object);
|
void showObject(uint16_t object);
|
||||||
|
|
||||||
void loadAnimations(const QString& file);
|
void loadAnimations(const QString& file);
|
||||||
void playAnimation(Animation* anim);
|
void playAnimation(Animation* anim);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,123 +1,107 @@
|
|||||||
#include "ObjectViewer.hpp"
|
#include "ObjectViewer.hpp"
|
||||||
#include <models/ObjectListModel.hpp>
|
|
||||||
#include "ViewerWidget.hpp"
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
#include <models/ObjectListModel.hpp>
|
||||||
|
#include "ViewerWidget.hpp"
|
||||||
|
|
||||||
ObjectViewer::ObjectViewer(ViewerWidget* viewer, QWidget* parent, Qt::WindowFlags f)
|
ObjectViewer::ObjectViewer(ViewerWidget* viewer, QWidget* parent,
|
||||||
: ViewerInterface(parent, f)
|
Qt::WindowFlags f)
|
||||||
{
|
: ViewerInterface(parent, f) {
|
||||||
mainLayout = new QHBoxLayout;
|
mainLayout = new QHBoxLayout;
|
||||||
|
|
||||||
objectList = new QTableView;
|
objectList = new QTableView;
|
||||||
|
|
||||||
objectMenu = new QMenu(objectList);
|
objectMenu = new QMenu(objectList);
|
||||||
objectList->setContextMenuPolicy(Qt::CustomContextMenu);
|
objectList->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
auto viewModelAction = new QAction("View Model", objectMenu);
|
auto viewModelAction = new QAction("View Model", objectMenu);
|
||||||
objectMenu->addAction(viewModelAction);
|
objectMenu->addAction(viewModelAction);
|
||||||
connect(viewModelAction, SIGNAL(triggered()), this, SLOT(menuViewModel()));
|
connect(viewModelAction, SIGNAL(triggered()), this, SLOT(menuViewModel()));
|
||||||
connect(objectList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onCustomContextMenu(QPoint)));
|
connect(objectList, SIGNAL(customContextMenuRequested(QPoint)), this,
|
||||||
|
SLOT(onCustomContextMenu(QPoint)));
|
||||||
|
|
||||||
mainLayout->addWidget(objectList);
|
mainLayout->addWidget(objectList);
|
||||||
|
|
||||||
previewWidget = viewer;
|
previewWidget = viewer;
|
||||||
previewWidget->setMinimumSize(250,250);
|
previewWidget->setMinimumSize(250, 250);
|
||||||
|
|
||||||
infoLayout = new QGridLayout;
|
infoLayout = new QGridLayout;
|
||||||
|
|
||||||
previewID = new QLabel;
|
previewID = new QLabel;
|
||||||
previewModel = new QLabel;
|
previewModel = new QLabel;
|
||||||
previewClass = new QLabel;
|
previewClass = new QLabel;
|
||||||
infoLayout->addWidget(new QLabel("ID"), 1, 0);
|
infoLayout->addWidget(new QLabel("ID"), 1, 0);
|
||||||
infoLayout->addWidget(previewID, 1, 1);
|
infoLayout->addWidget(previewID, 1, 1);
|
||||||
infoLayout->addWidget(new QLabel("Type"), 2, 0);
|
infoLayout->addWidget(new QLabel("Type"), 2, 0);
|
||||||
infoLayout->addWidget(previewClass, 2, 1);
|
infoLayout->addWidget(previewClass, 2, 1);
|
||||||
infoLayout->addWidget(new QLabel("Model"), 3, 0);
|
infoLayout->addWidget(new QLabel("Model"), 3, 0);
|
||||||
infoLayout->addWidget(previewModel, 3, 1);
|
infoLayout->addWidget(previewModel, 3, 1);
|
||||||
|
|
||||||
mainLayout->addLayout(infoLayout);
|
mainLayout->addLayout(infoLayout);
|
||||||
|
|
||||||
this->setLayout(mainLayout);
|
this->setLayout(mainLayout);
|
||||||
|
|
||||||
setViewerWidget(previewWidget);
|
setViewerWidget(previewWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectViewer::setViewerWidget(ViewerWidget* widget)
|
void ObjectViewer::setViewerWidget(ViewerWidget* widget) {
|
||||||
{
|
// widgetLayout->removeWidget(previewWidget);
|
||||||
//widgetLayout->removeWidget(previewWidget);
|
previewWidget = widget;
|
||||||
previewWidget = widget;
|
infoLayout->addWidget(previewWidget, 0, 0, 1, 2);
|
||||||
infoLayout->addWidget(previewWidget, 0, 0, 1, 2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectViewer::worldChanged()
|
void ObjectViewer::worldChanged() {
|
||||||
{
|
if (objectList->model()) {
|
||||||
if( objectList->model() )
|
delete objectList->model();
|
||||||
{
|
}
|
||||||
delete objectList->model();
|
|
||||||
}
|
|
||||||
|
|
||||||
objectList->setModel(new ObjectListModel(world()->data, objectList));
|
objectList->setModel(new ObjectListModel(world()->data, objectList));
|
||||||
connect(objectList->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(showItem(QModelIndex)));
|
connect(objectList->selectionModel(),
|
||||||
|
SIGNAL(currentChanged(QModelIndex, QModelIndex)), this,
|
||||||
|
SLOT(showItem(QModelIndex)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::map<ObjectInformation::ObjectClass, QString> gDataType =
|
static std::map<ObjectInformation::ObjectClass, QString> gDataType = {
|
||||||
{
|
{ObjectInformation::_class("OBJS"), "Object"},
|
||||||
{ ObjectInformation::_class("OBJS"), "Object" },
|
{ObjectInformation::_class("CARS"), "Vehicle"},
|
||||||
{ ObjectInformation::_class("CARS"), "Vehicle" },
|
{ObjectInformation::_class("PEDS"), "Pedestrian"},
|
||||||
{ ObjectInformation::_class("PEDS"), "Pedestrian" },
|
{ObjectInformation::_class("HIER"), "Cutscene"}};
|
||||||
{ ObjectInformation::_class("HIER"), "Cutscene" }
|
|
||||||
};
|
|
||||||
|
|
||||||
void ObjectViewer::showItem(qint16 item)
|
void ObjectViewer::showItem(qint16 item) {
|
||||||
{
|
auto def = world()->data->objectTypes[item];
|
||||||
auto def = world()->data->objectTypes[item];
|
|
||||||
|
|
||||||
if( def )
|
if (def) {
|
||||||
{
|
previewID->setText(QString::number(def->ID));
|
||||||
previewID->setText(QString::number(def->ID));
|
previewClass->setText(gDataType[def->class_type]);
|
||||||
previewClass->setText(gDataType[def->class_type]);
|
|
||||||
|
|
||||||
if(def->class_type == ObjectData::class_id)
|
if (def->class_type == ObjectData::class_id) {
|
||||||
{
|
auto v = std::static_pointer_cast<ObjectData>(def);
|
||||||
auto v = std::static_pointer_cast<ObjectData>(def);
|
previewModel->setText(QString::fromStdString(v->modelName));
|
||||||
previewModel->setText(QString::fromStdString(v->modelName));
|
} else if (def->class_type == VehicleData::class_id) {
|
||||||
}
|
auto v = std::static_pointer_cast<VehicleData>(def);
|
||||||
else if(def->class_type == VehicleData::class_id)
|
previewModel->setText(QString::fromStdString(v->modelName));
|
||||||
{
|
} else if (def->class_type == CharacterData::class_id) {
|
||||||
auto v = std::static_pointer_cast<VehicleData>(def);
|
auto v = std::static_pointer_cast<CharacterData>(def);
|
||||||
previewModel->setText(QString::fromStdString(v->modelName));
|
previewModel->setText(QString::fromStdString(v->modelName));
|
||||||
}
|
}
|
||||||
else if(def->class_type == CharacterData::class_id)
|
|
||||||
{
|
|
||||||
auto v = std::static_pointer_cast<CharacterData>(def);
|
|
||||||
previewModel->setText(QString::fromStdString(v->modelName));
|
|
||||||
}
|
|
||||||
|
|
||||||
previewWidget->showObject(item);
|
previewWidget->showObject(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectViewer::showItem(QModelIndex model)
|
void ObjectViewer::showItem(QModelIndex model) {
|
||||||
{
|
showItem(model.internalId());
|
||||||
showItem(model.internalId());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectViewer::onCustomContextMenu(const QPoint& p)
|
void ObjectViewer::onCustomContextMenu(const QPoint& p) {
|
||||||
{
|
contextMenuIndex = objectList->indexAt(p);
|
||||||
contextMenuIndex = objectList->indexAt(p);
|
if (contextMenuIndex.isValid()) {
|
||||||
if ( contextMenuIndex.isValid() )
|
|
||||||
{
|
|
||||||
objectMenu->exec(objectList->mapToGlobal(p));
|
objectMenu->exec(objectList->mapToGlobal(p));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectViewer::menuViewModel()
|
void ObjectViewer::menuViewModel() {
|
||||||
{
|
if (contextMenuIndex.isValid()) {
|
||||||
if( contextMenuIndex.isValid() )
|
auto id = contextMenuIndex.internalId();
|
||||||
{
|
showObjectModel(id);
|
||||||
auto id = contextMenuIndex.internalId();
|
}
|
||||||
showObjectModel(id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,54 +6,54 @@
|
|||||||
|
|
||||||
#include "ViewerInterface.hpp"
|
#include "ViewerInterface.hpp"
|
||||||
|
|
||||||
#include <QTableView>
|
|
||||||
#include <QLabel>
|
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QTableView>
|
||||||
|
|
||||||
class ViewerWidget;
|
class ViewerWidget;
|
||||||
class Model;
|
class Model;
|
||||||
|
|
||||||
class ObjectViewer : public ViewerInterface
|
class ObjectViewer : public ViewerInterface {
|
||||||
{
|
Q_OBJECT
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
QTableView* objectList;
|
QTableView* objectList;
|
||||||
|
|
||||||
QHBoxLayout* mainLayout;
|
QHBoxLayout* mainLayout;
|
||||||
QGridLayout* infoLayout;
|
QGridLayout* infoLayout;
|
||||||
ViewerWidget* previewWidget;
|
ViewerWidget* previewWidget;
|
||||||
QLabel* previewID;
|
QLabel* previewID;
|
||||||
QLabel* previewModel;
|
QLabel* previewModel;
|
||||||
QLabel* previewClass;
|
QLabel* previewClass;
|
||||||
|
|
||||||
|
QMenu* objectMenu;
|
||||||
|
QModelIndex contextMenuIndex;
|
||||||
|
|
||||||
QMenu* objectMenu;
|
|
||||||
QModelIndex contextMenuIndex;
|
|
||||||
public:
|
public:
|
||||||
|
ObjectViewer(ViewerWidget* viewer = 0, QWidget* parent = 0,
|
||||||
|
Qt::WindowFlags f = 0);
|
||||||
|
|
||||||
ObjectViewer(ViewerWidget *viewer = 0, QWidget* parent = 0, Qt::WindowFlags f = 0);
|
void setViewerWidget(ViewerWidget* widget);
|
||||||
|
|
||||||
void setViewerWidget( ViewerWidget* widget );
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void worldChanged() override;
|
void worldChanged() override;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
void modelChanged(Model* model);
|
void modelChanged(Model* model);
|
||||||
|
|
||||||
void showObjectModel(uint16_t object);
|
void showObjectModel(uint16_t object);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
void showItem(qint16 item);
|
void showItem(qint16 item);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void showItem(QModelIndex model);
|
void showItem(QModelIndex model);
|
||||||
|
|
||||||
void onCustomContextMenu(const QPoint &);
|
void onCustomContextMenu(const QPoint&);
|
||||||
void menuViewModel();
|
void menuViewModel();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -6,33 +6,31 @@
|
|||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
class ViewerInterface : public QWidget
|
class ViewerInterface : public QWidget {
|
||||||
{
|
Q_OBJECT
|
||||||
Q_OBJECT
|
|
||||||
public:
|
public:
|
||||||
ViewerInterface(QWidget* parent = 0, Qt::WindowFlags f = 0)
|
ViewerInterface(QWidget* parent = 0, Qt::WindowFlags f = 0)
|
||||||
: QWidget(parent, f)
|
: QWidget(parent, f), m_world(nullptr) {
|
||||||
, m_world(nullptr)
|
}
|
||||||
{
|
|
||||||
|
|
||||||
}
|
virtual void setViewerWidget(ViewerWidget* widget) = 0;
|
||||||
|
|
||||||
virtual void setViewerWidget( ViewerWidget* widget ) = 0;
|
GameWorld* world() {
|
||||||
|
return m_world;
|
||||||
GameWorld* world() { return m_world; }
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void worldChanged() { }
|
virtual void worldChanged() {
|
||||||
|
}
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void showData(GameWorld* world)
|
void showData(GameWorld* world) {
|
||||||
{
|
m_world = world;
|
||||||
m_world = world;
|
worldChanged();
|
||||||
worldChanged();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GameWorld* m_world;
|
GameWorld* m_world;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -3,36 +3,32 @@
|
|||||||
|
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
|
|
||||||
WorldViewer::WorldViewer(ViewerWidget* viewer, QWidget* parent, Qt::WindowFlags f)
|
WorldViewer::WorldViewer(ViewerWidget* viewer, QWidget* parent,
|
||||||
: ViewerInterface(parent, f)
|
Qt::WindowFlags f)
|
||||||
{
|
: ViewerInterface(parent, f) {
|
||||||
mainLayout = new QVBoxLayout;
|
mainLayout = new QVBoxLayout;
|
||||||
|
|
||||||
viewerWidget = viewer;
|
viewerWidget = viewer;
|
||||||
viewerWidget->setMinimumSize(250,250);
|
viewerWidget->setMinimumSize(250, 250);
|
||||||
|
|
||||||
this->setLayout(mainLayout);
|
this->setLayout(mainLayout);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldViewer::setViewerWidget(ViewerWidget* widget)
|
void WorldViewer::setViewerWidget(ViewerWidget* widget) {
|
||||||
{
|
viewerWidget = widget;
|
||||||
viewerWidget = widget;
|
// Clear the active model
|
||||||
// Clear the active model
|
widget->showModel(nullptr);
|
||||||
widget->showModel(nullptr);
|
mainLayout->addWidget(viewerWidget);
|
||||||
mainLayout->addWidget(viewerWidget);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldViewer::loadPlacements(const QString& file)
|
void WorldViewer::loadPlacements(const QString& file) {
|
||||||
{
|
world()->placeItems(file.toStdString());
|
||||||
world()->placeItems(file.toStdString());
|
placementsLoaded(file);
|
||||||
placementsLoaded(file);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldViewer::loadPlacements()
|
void WorldViewer::loadPlacements() {
|
||||||
{
|
QFileDialog dialog(this, "Open Placements", "", "Placement (*.ipl)");
|
||||||
QFileDialog dialog(this, "Open Placements", "", "Placement (*.ipl)");
|
if (dialog.exec()) {
|
||||||
if(dialog.exec()) {
|
loadPlacements(dialog.selectedFiles()[0]);
|
||||||
loadPlacements(dialog.selectedFiles()[0]);
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,29 +5,30 @@
|
|||||||
|
|
||||||
#include "ViewerInterface.hpp"
|
#include "ViewerInterface.hpp"
|
||||||
|
|
||||||
#include <QTreeView>
|
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QVBoxLayout>
|
|
||||||
#include <QSplitter>
|
|
||||||
#include <QLayout>
|
#include <QLayout>
|
||||||
|
#include <QSplitter>
|
||||||
|
#include <QTreeView>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
class WorldViewer : public ViewerInterface
|
class WorldViewer : public ViewerInterface {
|
||||||
{
|
Q_OBJECT
|
||||||
Q_OBJECT
|
|
||||||
|
QVBoxLayout* mainLayout;
|
||||||
|
ViewerWidget* viewerWidget;
|
||||||
|
|
||||||
QVBoxLayout* mainLayout;
|
|
||||||
ViewerWidget* viewerWidget;
|
|
||||||
public:
|
public:
|
||||||
WorldViewer(ViewerWidget *viewer = 0, QWidget* parent = 0, Qt::WindowFlags f = 0);
|
WorldViewer(ViewerWidget* viewer = 0, QWidget* parent = 0,
|
||||||
|
Qt::WindowFlags f = 0);
|
||||||
|
|
||||||
void setViewerWidget( ViewerWidget* widget ) override;
|
void setViewerWidget(ViewerWidget* widget) override;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void placementsLoaded(const QString& file);
|
void placementsLoaded(const QString& file);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void loadPlacements(const QString& file);
|
void loadPlacements(const QString& file);
|
||||||
void loadPlacements();
|
void loadPlacements();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user