2014-02-12 07:42:07 +01:00
|
|
|
#include "ModelFramesWidget.hpp"
|
2017-01-03 15:18:06 +01:00
|
|
|
#include <data/Clump.hpp>
|
2014-06-10 21:26:04 +02:00
|
|
|
#include <glm/gtx/string_cast.hpp>
|
|
|
|
|
2017-10-27 17:38:36 +02:00
|
|
|
void ModelFramesWidget::updateInfoBox(ClumpPtr, ModelFrame* f) {
|
2016-09-09 22:13:21 +02:00
|
|
|
if (f == nullptr) {
|
|
|
|
_frameLabel->setText("");
|
|
|
|
} else {
|
2017-01-08 21:43:18 +01:00
|
|
|
auto labText = QString("Name: %1\nTranslation: %2")
|
2016-09-09 22:13:21 +02:00
|
|
|
.arg(QString::fromStdString(f->getName()))
|
|
|
|
.arg(QString::fromStdString(
|
|
|
|
glm::to_string(f->getDefaultTranslation())));
|
|
|
|
_frameLabel->setText(labText);
|
|
|
|
}
|
2014-06-10 21:26:04 +02:00
|
|
|
}
|
|
|
|
|
2016-09-09 22:13:21 +02:00
|
|
|
void ModelFramesWidget::selectedModelChanged(const QModelIndex& n,
|
|
|
|
const QModelIndex&) {
|
2018-07-27 22:53:35 +02:00
|
|
|
updateInfoBox(gmodel, static_cast<ModelFrame*>(n.internalPointer()));
|
|
|
|
selectedFrameChanged(static_cast<ModelFrame*>(n.internalPointer()));
|
2014-06-10 21:26:04 +02:00
|
|
|
}
|
2014-02-12 07:42:07 +01:00
|
|
|
|
|
|
|
ModelFramesWidget::ModelFramesWidget(QWidget* parent, Qt::WindowFlags flags)
|
2016-09-09 22:13:21 +02:00
|
|
|
: QWidget(parent, flags), gmodel(nullptr), framemodel(nullptr) {
|
|
|
|
setWindowTitle("Frames");
|
2014-06-10 21:26:04 +02:00
|
|
|
|
2016-09-09 22:13:21 +02:00
|
|
|
_layout = new QVBoxLayout;
|
|
|
|
tree = new QTreeView(this);
|
|
|
|
_layout->addWidget(tree);
|
|
|
|
_frameLabel = new QLabel(this);
|
|
|
|
_layout->addWidget(_frameLabel);
|
2014-06-10 21:26:04 +02:00
|
|
|
|
2016-09-09 22:13:21 +02:00
|
|
|
setLayout(_layout);
|
2014-02-12 07:42:07 +01:00
|
|
|
}
|
|
|
|
|
rwlib: Use ClumpPtr instead of Clump*
Should fix these memory leaks:
==22737== 14,598,040 (131,472 direct, 14,466,568 indirect) bytes in 2,739 blocks are definitely lost in loss record 3,124 of 3,126
==22737== at 0x4C2F1CA: operator new(unsigned long) (vg_replace_malloc.c:334)
==22737== by 0x90FE4B: LoaderDFF::loadFromMemory(std::shared_ptr<FileContentsInfo>) (LoaderDFF.cpp:443)
==22737== by 0x7BCC86: GameData::loadModel(unsigned short) (GameData.cpp:474)
==22737== by 0x7DF7BC: GameWorld::createInstance(unsigned short, glm::tvec3<float, (glm::precision)0> const&, glm::tquat<float, (glm::precision)0> const&) (GameWorld.cpp:144)
==22737== by 0x7DF44C: GameWorld::placeItems(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (GameWorld.cpp:120)
==22737== by 0x758D38: RWGame::newGame() (RWGame.cpp:116)
==22737== by 0x786389: LoadingState::enter() (LoadingState.cpp:9)
==22737== by 0x75DC59: void StateManager::enter<LoadingState, RWGame*, RWGame::RWGame(Logger&, int, char**)::{lambda()#1}>(RWGame*&&, RWGame::RWGame(Logger&, int, char**)::{lambda()#1}&&) (StateManager.hpp:40)
==22737== by 0x758484: RWGame::RWGame(Logger&, int, char**) (RWGame.cpp:81)
==22737== by 0x747815: main (main.cpp:13)
2017-09-13 00:47:22 +02:00
|
|
|
void ModelFramesWidget::setModel(ClumpPtr model) {
|
2016-09-09 22:13:21 +02:00
|
|
|
if (framemodel) {
|
|
|
|
delete framemodel;
|
|
|
|
framemodel = nullptr;
|
|
|
|
tree->setModel(nullptr);
|
|
|
|
}
|
|
|
|
gmodel = model;
|
rwlib: Use ClumpPtr instead of Clump*
Should fix these memory leaks:
==22737== 14,598,040 (131,472 direct, 14,466,568 indirect) bytes in 2,739 blocks are definitely lost in loss record 3,124 of 3,126
==22737== at 0x4C2F1CA: operator new(unsigned long) (vg_replace_malloc.c:334)
==22737== by 0x90FE4B: LoaderDFF::loadFromMemory(std::shared_ptr<FileContentsInfo>) (LoaderDFF.cpp:443)
==22737== by 0x7BCC86: GameData::loadModel(unsigned short) (GameData.cpp:474)
==22737== by 0x7DF7BC: GameWorld::createInstance(unsigned short, glm::tvec3<float, (glm::precision)0> const&, glm::tquat<float, (glm::precision)0> const&) (GameWorld.cpp:144)
==22737== by 0x7DF44C: GameWorld::placeItems(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (GameWorld.cpp:120)
==22737== by 0x758D38: RWGame::newGame() (RWGame.cpp:116)
==22737== by 0x786389: LoadingState::enter() (LoadingState.cpp:9)
==22737== by 0x75DC59: void StateManager::enter<LoadingState, RWGame*, RWGame::RWGame(Logger&, int, char**)::{lambda()#1}>(RWGame*&&, RWGame::RWGame(Logger&, int, char**)::{lambda()#1}&&) (StateManager.hpp:40)
==22737== by 0x758484: RWGame::RWGame(Logger&, int, char**) (RWGame.cpp:81)
==22737== by 0x747815: main (main.cpp:13)
2017-09-13 00:47:22 +02:00
|
|
|
if (model.get() != nullptr) {
|
2017-01-08 20:46:00 +01:00
|
|
|
framemodel = new DFFFramesTreeModel(model, this);
|
2016-09-09 22:13:21 +02:00
|
|
|
tree->setModel(framemodel);
|
|
|
|
tree->setDisabled(false);
|
|
|
|
connect(tree->selectionModel(),
|
|
|
|
SIGNAL(currentChanged(QModelIndex, QModelIndex)),
|
|
|
|
SLOT(selectedModelChanged(QModelIndex, QModelIndex)));
|
|
|
|
} else {
|
|
|
|
tree->setDisabled(true);
|
|
|
|
}
|
2014-02-12 07:42:07 +01:00
|
|
|
}
|