mirror of
https://github.com/isledecomp/SIEdit.git
synced 2025-04-12 04:44:26 -04:00
app: separate compiled SI viewer to separate dialog
This commit is contained in:
parent
1448fb8b27
commit
5a63794921
23 changed files with 299 additions and 216 deletions
|
@ -4,28 +4,28 @@ find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
|
|||
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
|
||||
|
||||
set(PROJECT_SOURCES
|
||||
panels/mxch.cpp
|
||||
panels/mxch.h
|
||||
panels/mxhd.cpp
|
||||
panels/mxhd.h
|
||||
panels/mxob.cpp
|
||||
panels/mxob.h
|
||||
panels/mxof.cpp
|
||||
panels/mxof.h
|
||||
panels/panel.cpp
|
||||
panels/panel.h
|
||||
panels/riff.cpp
|
||||
panels/riff.h
|
||||
siview/chunkmodel.cpp
|
||||
siview/chunkmodel.h
|
||||
siview/panels/mxch.cpp
|
||||
siview/panels/mxch.h
|
||||
siview/panels/mxhd.cpp
|
||||
siview/panels/mxhd.h
|
||||
siview/panels/mxob.cpp
|
||||
siview/panels/mxob.h
|
||||
siview/panels/mxof.cpp
|
||||
siview/panels/mxof.h
|
||||
siview/panels/riff.cpp
|
||||
siview/panels/riff.h
|
||||
siview/siview.cpp
|
||||
siview/siview.h
|
||||
|
||||
abstractsiitemmodel.cpp
|
||||
abstractsiitemmodel.h
|
||||
chunkmodel.cpp
|
||||
chunkmodel.h
|
||||
main.cpp
|
||||
mainwindow.cpp
|
||||
mainwindow.h
|
||||
objectmodel.cpp
|
||||
objectmodel.h
|
||||
#objectmodel.cpp
|
||||
#objectmodel.h
|
||||
panel.cpp
|
||||
panel.h
|
||||
vector3edit.cpp
|
||||
vector3edit.h
|
||||
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
#include "abstractsiitemmodel.h"
|
||||
|
||||
using namespace si;
|
||||
|
||||
AbstractSIItemModel::AbstractSIItemModel(QObject *parent) :
|
||||
QAbstractItemModel{parent},
|
||||
chunk_(nullptr)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void AbstractSIItemModel::SetChunk(si::Chunk *c)
|
||||
{
|
||||
beginResetModel();
|
||||
chunk_ = c;
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
si::Chunk *AbstractSIItemModel::GetChunkFromIndex(const QModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid()) {
|
||||
return chunk_;
|
||||
} else {
|
||||
return static_cast<Chunk*>(index.internalPointer());
|
||||
}
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
#ifndef ABSTRACTSIITEMMODEL_H
|
||||
#define ABSTRACTSIITEMMODEL_H
|
||||
|
||||
#include <chunk.h>
|
||||
#include <QAbstractItemModel>
|
||||
|
||||
class AbstractSIItemModel : public QAbstractItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AbstractSIItemModel(QObject *parent = nullptr);
|
||||
|
||||
void SetChunk(si::Chunk *c);
|
||||
|
||||
protected:
|
||||
si::Chunk *GetChunkFromIndex(const QModelIndex &index) const;
|
||||
|
||||
si::Chunk *root() const { return chunk_; }
|
||||
|
||||
private:
|
||||
si::Chunk *chunk_;
|
||||
|
||||
};
|
||||
|
||||
#endif // ABSTRACTSIITEMMODEL_H
|
|
@ -3,8 +3,12 @@
|
|||
#include <iostream>
|
||||
#include <QFileDialog>
|
||||
#include <QMenuBar>
|
||||
#include <QMessageBox>
|
||||
#include <QSplitter>
|
||||
|
||||
#include "interleaf.h"
|
||||
#include "siview/siview.h"
|
||||
|
||||
using namespace si;
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
|
@ -15,20 +19,12 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
splitter->setChildrenCollapsible(false);
|
||||
this->setCentralWidget(splitter);
|
||||
|
||||
auto tree_tab = new QTabWidget();
|
||||
splitter->addWidget(tree_tab);
|
||||
|
||||
/*auto simple_tree = new QTreeView();
|
||||
simple_tree->setModel(&object_model_);
|
||||
tree_tab->addTab(simple_tree, tr("Simple"));
|
||||
connect(simple_tree->selectionModel(), &QItemSelectionModel::currentRowChanged, this, &MainWindow::SelectionChanged);*/
|
||||
|
||||
lowlevel_tree_ = new QTreeView();
|
||||
lowlevel_tree_->setModel(&chunk_model_);
|
||||
lowlevel_tree_->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
tree_tab->addTab(lowlevel_tree_, tr("Advanced"));
|
||||
connect(lowlevel_tree_->selectionModel(), &QItemSelectionModel::currentRowChanged, this, &MainWindow::SelectionChanged);
|
||||
connect(lowlevel_tree_, &QTreeView::customContextMenuRequested, this, &MainWindow::ShowContextMenu);
|
||||
tree_ = new QTreeView();
|
||||
//tree_->setModel(&chunk_model_);
|
||||
tree_->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(tree_->selectionModel(), &QItemSelectionModel::currentRowChanged, this, &MainWindow::SelectionChanged);
|
||||
connect(tree_, &QTreeView::customContextMenuRequested, this, &MainWindow::ShowContextMenu);
|
||||
splitter->addWidget(tree_);
|
||||
|
||||
config_stack_ = new QStackedWidget();
|
||||
splitter->addWidget(config_stack_);
|
||||
|
@ -36,21 +32,6 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
panel_blank_ = new Panel();
|
||||
config_stack_->addWidget(panel_blank_);
|
||||
|
||||
panel_mxhd_ = new MxHdPanel();
|
||||
config_stack_->addWidget(panel_mxhd_);
|
||||
|
||||
panel_riff_ = new RIFFPanel();
|
||||
config_stack_->addWidget(panel_riff_);
|
||||
|
||||
panel_mxch_ = new MxChPanel();
|
||||
config_stack_->addWidget(panel_mxch_);
|
||||
|
||||
panel_mxof_ = new MxOfPanel();
|
||||
config_stack_->addWidget(panel_mxof_);
|
||||
|
||||
panel_mxob_ = new MxObPanel();
|
||||
config_stack_->addWidget(panel_mxob_);
|
||||
|
||||
InitializeMenuBar();
|
||||
|
||||
splitter->setSizes({99999, 99999});
|
||||
|
@ -58,12 +39,16 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
|
||||
void MainWindow::OpenFilename(const QString &s)
|
||||
{
|
||||
object_model_.SetChunk(nullptr);
|
||||
chunk_model_.SetChunk(nullptr);
|
||||
SetPanel(panel_blank_, nullptr);
|
||||
chunk_.Read(s.toStdString());
|
||||
object_model_.SetChunk(&chunk_);
|
||||
chunk_model_.SetChunk(&chunk_);
|
||||
Chunk si;
|
||||
if (si.Read(s.toStdString())) {
|
||||
SIViewDialog d(SIViewDialog::Import, &si, this);
|
||||
if (d.exec() == QDialog::Accepted) {
|
||||
Interleaf interleaf;
|
||||
interleaf.Parse(&si);
|
||||
}
|
||||
} else {
|
||||
QMessageBox::critical(this, QString(), tr("Failed to load Interleaf file."));
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::InitializeMenuBar()
|
||||
|
@ -72,6 +57,8 @@ void MainWindow::InitializeMenuBar()
|
|||
|
||||
auto file_menu = menubar->addMenu(tr("&File"));
|
||||
|
||||
auto new_action = file_menu->addAction(tr("&New"));
|
||||
|
||||
auto open_action = file_menu->addAction(tr("&Open"), this, &MainWindow::OpenFile, tr("Ctrl+O"));
|
||||
|
||||
auto save_action = file_menu->addAction(tr("&Save"));
|
||||
|
@ -79,6 +66,10 @@ void MainWindow::InitializeMenuBar()
|
|||
|
||||
file_menu->addSeparator();
|
||||
|
||||
auto export_action = file_menu->addAction(tr("&Export"));
|
||||
|
||||
file_menu->addSeparator();
|
||||
|
||||
auto exit_action = file_menu->addAction(tr("E&xit"));
|
||||
connect(exit_action, &QAction::triggered, this, &MainWindow::close);
|
||||
|
||||
|
@ -109,27 +100,7 @@ void MainWindow::SelectionChanged(const QModelIndex &index)
|
|||
Chunk *c = static_cast<Chunk*>(index.internalPointer());
|
||||
|
||||
if (c) {
|
||||
switch (c->type()) {
|
||||
case Chunk::TYPE_MxHd:
|
||||
p = panel_mxhd_;
|
||||
break;
|
||||
case Chunk::TYPE_RIFF:
|
||||
case Chunk::TYPE_LIST:
|
||||
p = panel_riff_;
|
||||
break;
|
||||
case Chunk::TYPE_MxCh:
|
||||
p = panel_mxch_;
|
||||
break;
|
||||
case Chunk::TYPE_MxOf:
|
||||
p = panel_mxof_;
|
||||
break;
|
||||
case Chunk::TYPE_MxOb:
|
||||
p = panel_mxob_;
|
||||
break;
|
||||
case Chunk::TYPE_MxSt:
|
||||
case Chunk::TYPE_pad_:
|
||||
break;
|
||||
}
|
||||
// HECK
|
||||
}
|
||||
|
||||
if (p != config_stack_->currentWidget() || c != last_set_data_) {
|
||||
|
@ -149,7 +120,7 @@ void MainWindow::ShowContextMenu(const QPoint &p)
|
|||
|
||||
void MainWindow::ExtractSelectedItems()
|
||||
{
|
||||
auto selected = lowlevel_tree_->selectionModel()->selectedRows();
|
||||
auto selected = tree_->selectionModel()->selectedRows();
|
||||
if (selected.empty()) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -6,14 +6,7 @@
|
|||
#include <QStackedWidget>
|
||||
#include <QTreeView>
|
||||
|
||||
#include "chunkmodel.h"
|
||||
#include "objectmodel.h"
|
||||
#include "panels/mxch.h"
|
||||
#include "panels/mxhd.h"
|
||||
#include "panels/mxob.h"
|
||||
#include "panels/mxof.h"
|
||||
#include "panels/riff.h"
|
||||
#include "panels/panel.h"
|
||||
#include "panel.h"
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
|
@ -32,20 +25,11 @@ private:
|
|||
|
||||
void SetPanel(Panel *panel, si::Chunk *chunk);
|
||||
|
||||
ObjectModel object_model_;
|
||||
ChunkModel chunk_model_;
|
||||
si::Chunk chunk_;
|
||||
|
||||
QStackedWidget *config_stack_;
|
||||
|
||||
QTreeView *lowlevel_tree_;
|
||||
QTreeView *tree_;
|
||||
|
||||
Panel *panel_blank_;
|
||||
RIFFPanel *panel_riff_;
|
||||
MxHdPanel *panel_mxhd_;
|
||||
MxChPanel *panel_mxch_;
|
||||
MxOfPanel *panel_mxof_;
|
||||
MxObPanel *panel_mxob_;
|
||||
|
||||
si::Chunk *last_set_data_;
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#include "objectmodel.h"
|
||||
|
||||
#define super AbstractSIItemModel
|
||||
#include <chunk.h>
|
||||
|
||||
#define super QAbstractItemModel
|
||||
|
||||
using namespace si;
|
||||
|
||||
|
@ -34,7 +36,7 @@ int ObjectModel::rowCount(const QModelIndex &parent) const
|
|||
return 0;
|
||||
}
|
||||
|
||||
return mxof->data("Offsets").size() / sizeof(u32);
|
||||
return int(mxof->data("Offsets").size() / sizeof(u32));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
#ifndef OBJECTMODEL_H
|
||||
#define OBJECTMODEL_H
|
||||
|
||||
#include "abstractsiitemmodel.h"
|
||||
#include <QAbstractItemModel>
|
||||
|
||||
class ObjectModel : public AbstractSIItemModel
|
||||
class ObjectModel : public QAbstractItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Columns {
|
||||
kColIndex,
|
||||
kColOffset,
|
||||
kColName,
|
||||
|
||||
kColCount
|
||||
|
@ -24,10 +23,6 @@ public:
|
|||
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||
|
||||
private:
|
||||
si::Chunk *GetMxOf() const;
|
||||
si::Chunk *GetItem(size_t index, si::u32 *offset_out = NULL) const;
|
||||
|
||||
};
|
||||
|
||||
#endif // OBJECTMODEL_H
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
Panel::Panel(QWidget *parent) :
|
||||
QWidget{parent},
|
||||
chunk_(nullptr)
|
||||
data_(nullptr)
|
||||
{
|
||||
outer_layout_ = new QVBoxLayout(this);
|
||||
|
||||
|
@ -10,16 +10,16 @@ Panel::Panel(QWidget *parent) :
|
|||
outer_layout_->addLayout(layout_);
|
||||
}
|
||||
|
||||
void Panel::SetData(si::Chunk *chunk)
|
||||
void Panel::SetData(void *data)
|
||||
{
|
||||
if (chunk_) {
|
||||
OnClosingData(chunk_);
|
||||
if (data_) {
|
||||
OnClosingData(data_);
|
||||
}
|
||||
|
||||
chunk_ = chunk;
|
||||
data_ = data;
|
||||
|
||||
if (chunk_) {
|
||||
OnOpeningData(chunk_);
|
||||
if (data_) {
|
||||
OnOpeningData(data_);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
#ifndef PANEL_H
|
||||
#define PANEL_H
|
||||
|
||||
#include <chunk.h>
|
||||
#include <QGridLayout>
|
||||
#include <QWidget>
|
||||
|
||||
|
@ -11,20 +10,20 @@ class Panel : public QWidget
|
|||
public:
|
||||
explicit Panel(QWidget *parent = nullptr);
|
||||
|
||||
void SetData(si::Chunk *chunk);
|
||||
void SetData(void *data);
|
||||
|
||||
signals:
|
||||
|
||||
protected:
|
||||
virtual void OnOpeningData(si::Chunk *chunk){}
|
||||
virtual void OnClosingData(si::Chunk *chunk){}
|
||||
virtual void OnOpeningData(void *data){}
|
||||
virtual void OnClosingData(void *data){}
|
||||
|
||||
QGridLayout *layout() const { return layout_; }
|
||||
|
||||
void FinishLayout();
|
||||
|
||||
private:
|
||||
si::Chunk *chunk_;
|
||||
void *data_;
|
||||
|
||||
QVBoxLayout *outer_layout_;
|
||||
QGridLayout *layout_;
|
|
@ -2,12 +2,13 @@
|
|||
|
||||
#include <iostream>
|
||||
|
||||
#define super AbstractSIItemModel
|
||||
#define super QAbstractItemModel
|
||||
|
||||
using namespace si;
|
||||
|
||||
ChunkModel::ChunkModel(QObject *parent) :
|
||||
super{parent}
|
||||
super{parent},
|
||||
chunk_(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -33,12 +34,12 @@ QModelIndex ChunkModel::parent(const QModelIndex &index) const
|
|||
return QModelIndex();
|
||||
}
|
||||
|
||||
Chunk *parent = child->GetParent();
|
||||
Core *parent = child->GetParent();
|
||||
if (!parent) {
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
Chunk *grandparent = parent->GetParent();
|
||||
Core *grandparent = parent->GetParent();
|
||||
if (!grandparent) {
|
||||
return QModelIndex();
|
||||
}
|
||||
|
@ -107,3 +108,19 @@ QVariant ChunkModel::headerData(int section, Qt::Orientation orientation, int ro
|
|||
|
||||
return super::headerData(section, orientation, role);
|
||||
}
|
||||
|
||||
void ChunkModel::SetChunk(si::Chunk *c)
|
||||
{
|
||||
beginResetModel();
|
||||
chunk_ = c;
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
si::Chunk *ChunkModel::GetChunkFromIndex(const QModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid()) {
|
||||
return chunk_;
|
||||
} else {
|
||||
return static_cast<Chunk*>(index.internalPointer());
|
||||
}
|
||||
}
|
|
@ -1,9 +1,10 @@
|
|||
#ifndef CHUNKMODEL_H
|
||||
#define CHUNKMODEL_H
|
||||
|
||||
#include "abstractsiitemmodel.h"
|
||||
#include <chunk.h>
|
||||
#include <QAbstractItemModel>
|
||||
|
||||
class ChunkModel : public AbstractSIItemModel
|
||||
class ChunkModel : public QAbstractItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
@ -26,6 +27,16 @@ public:
|
|||
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||
|
||||
void SetChunk(si::Chunk *c);
|
||||
|
||||
protected:
|
||||
si::Chunk *GetChunkFromIndex(const QModelIndex &index) const;
|
||||
|
||||
si::Chunk *root() const { return chunk_; }
|
||||
|
||||
private:
|
||||
si::Chunk *chunk_;
|
||||
|
||||
};
|
||||
|
||||
#endif // CHUNKMODEL_H
|
|
@ -1,5 +1,6 @@
|
|||
#include "mxch.h"
|
||||
|
||||
#include <chunk.h>
|
||||
#include <QFontDatabase>
|
||||
#include <QGroupBox>
|
||||
#include <QLabel>
|
||||
|
@ -70,18 +71,13 @@ MxChPanel::MxChPanel(QWidget *parent) :
|
|||
data_sz_edit_->setMaximum(INT_MAX);
|
||||
layout()->addWidget(data_sz_edit_, row, 1);
|
||||
|
||||
row++;
|
||||
|
||||
data_edit_ = new QTextEdit();
|
||||
layout()->addWidget(data_edit_, row, 0, 1, 2);
|
||||
|
||||
data_edit_->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));
|
||||
|
||||
FinishLayout();
|
||||
}
|
||||
|
||||
void MxChPanel::OnOpeningData(Chunk *chunk)
|
||||
void MxChPanel::OnOpeningData(void *d)
|
||||
{
|
||||
Chunk *chunk = static_cast<Chunk*>(d);
|
||||
|
||||
flag_edit_->setText(QString::number(chunk->data("Flags"), 16));
|
||||
obj_edit_->setValue(chunk->data("Object"));
|
||||
ms_offset_edit_->setValue(chunk->data("Time"));
|
||||
|
@ -90,15 +86,11 @@ void MxChPanel::OnOpeningData(Chunk *chunk)
|
|||
for (QCheckBox *cb : qAsConst(flag_checkboxes_)) {
|
||||
cb->setChecked(cb->property("flag").toUInt() & chunk->data("Flags"));
|
||||
}
|
||||
|
||||
const Data &data = chunk->data("Data");
|
||||
QByteArray ba(data.data(), int(data.size()));
|
||||
data_edit_->setPlainText(ba.toHex());
|
||||
}
|
||||
|
||||
void MxChPanel::OnClosingData(Chunk *chunk)
|
||||
void MxChPanel::OnClosingData(void *data)
|
||||
{
|
||||
bool ok;
|
||||
/*bool ok;
|
||||
u16 flags = flag_edit_->text().toUShort(&ok, 16);
|
||||
if (ok) {
|
||||
chunk->data("Flags") = flags;
|
||||
|
@ -106,7 +98,7 @@ void MxChPanel::OnClosingData(Chunk *chunk)
|
|||
|
||||
chunk->data("Object") = u32(obj_edit_->value());
|
||||
chunk->data("Time") = u32(ms_offset_edit_->value());
|
||||
chunk->data("DataSize") = u32(data_sz_edit_->value());
|
||||
chunk->data("DataSize") = u32(data_sz_edit_->value());*/
|
||||
}
|
||||
|
||||
void MxChPanel::FlagCheckBoxClicked(bool e)
|
|
@ -15,15 +15,14 @@ public:
|
|||
explicit MxChPanel(QWidget *parent = nullptr);
|
||||
|
||||
protected:
|
||||
virtual void OnOpeningData(si::Chunk *chunk) override;
|
||||
virtual void OnClosingData(si::Chunk *chunk) override;
|
||||
virtual void OnOpeningData(void *data) override;
|
||||
virtual void OnClosingData(void *data) override;
|
||||
|
||||
private:
|
||||
QLineEdit *flag_edit_;
|
||||
QSpinBox *obj_edit_;
|
||||
QSpinBox *ms_offset_edit_;
|
||||
QSpinBox *data_sz_edit_;
|
||||
QTextEdit *data_edit_;
|
||||
|
||||
QVector<QCheckBox*> flag_checkboxes_;
|
||||
|
|
@ -1,11 +1,12 @@
|
|||
#include "mxhd.h"
|
||||
|
||||
#include <chunk.h>
|
||||
#include <QLabel>
|
||||
|
||||
using namespace si;
|
||||
|
||||
MxHdPanel::MxHdPanel(QWidget *parent)
|
||||
: Panel{parent}
|
||||
MxHdPanel::MxHdPanel(QWidget *parent) :
|
||||
Panel{parent}
|
||||
{
|
||||
int row = 0;
|
||||
|
||||
|
@ -47,8 +48,9 @@ MxHdPanel::MxHdPanel(QWidget *parent)
|
|||
FinishLayout();
|
||||
}
|
||||
|
||||
void MxHdPanel::OnOpeningData(Chunk *chunk)
|
||||
void MxHdPanel::OnOpeningData(void *data)
|
||||
{
|
||||
Chunk *chunk = static_cast<Chunk*>(data);
|
||||
si::u32 version = chunk->data("Version");
|
||||
uint16_t major_ver = version >> 16;
|
||||
uint16_t minor_ver = version;
|
||||
|
@ -59,9 +61,9 @@ void MxHdPanel::OnOpeningData(Chunk *chunk)
|
|||
buffer_count_edit_->setValue(chunk->data("BufferCount"));
|
||||
}
|
||||
|
||||
void MxHdPanel::OnClosingData(Chunk *chunk)
|
||||
void MxHdPanel::OnClosingData(void *data)
|
||||
{
|
||||
chunk->data("Version") = (major_version_edit_->value() << 16 | (minor_version_edit_->value() & 0xFFFF));
|
||||
/*chunk->data("Version") = (major_version_edit_->value() << 16 | (minor_version_edit_->value() & 0xFFFF));
|
||||
chunk->data("BufferSize") = buffer_alignment_edit_->value();
|
||||
chunk->data("BufferCount") = buffer_count_edit_->value();
|
||||
chunk->data("BufferCount") = buffer_count_edit_->value();*/
|
||||
}
|
|
@ -15,8 +15,8 @@ public:
|
|||
signals:
|
||||
|
||||
protected:
|
||||
virtual void OnOpeningData(si::Chunk *chunk) override;
|
||||
virtual void OnClosingData(si::Chunk *chunk) override;
|
||||
virtual void OnOpeningData(void *data) override;
|
||||
virtual void OnClosingData(void *data) override;
|
||||
|
||||
private:
|
||||
QSpinBox *major_version_edit_;
|
|
@ -1,5 +1,6 @@
|
|||
#include "mxob.h"
|
||||
|
||||
#include <chunk.h>
|
||||
#include <sitypes.h>
|
||||
#include <QGroupBox>
|
||||
#include <QLabel>
|
||||
|
@ -125,7 +126,7 @@ MxObPanel::MxObPanel(QWidget *parent) :
|
|||
loops_edit_->setMinimum(0);
|
||||
loops_edit_->setMaximum(INT_MAX);
|
||||
layout()->addWidget(loops_edit_, row, 1);
|
||||
|
||||
|
||||
row++;
|
||||
|
||||
auto pos_grp = new QGroupBox(tr("Position"));
|
||||
|
@ -156,8 +157,10 @@ MxObPanel::MxObPanel(QWidget *parent) :
|
|||
FinishLayout();
|
||||
}
|
||||
|
||||
void MxObPanel::OnOpeningData(si::Chunk *chunk)
|
||||
void MxObPanel::OnOpeningData(void *data)
|
||||
{
|
||||
Chunk *chunk = static_cast<Chunk*>(data);
|
||||
|
||||
type_combo_->setCurrentIndex(chunk->data("Type"));
|
||||
name_edit_->setText(QString(chunk->data("Name")));
|
||||
filename_edit_->setText(QString(chunk->data("FileName")));
|
||||
|
@ -178,9 +181,9 @@ void MxObPanel::OnOpeningData(si::Chunk *chunk)
|
|||
up_edit_->SetValue(chunk->data("Up"));
|
||||
}
|
||||
|
||||
void MxObPanel::OnClosingData(si::Chunk *chunk)
|
||||
void MxObPanel::OnClosingData(void *data)
|
||||
{
|
||||
chunk->data("Type") = type_combo_->currentIndex();
|
||||
/*chunk->data("Type") = type_combo_->currentIndex();
|
||||
|
||||
bool ok;
|
||||
u32 flags = flag_edit_->text().toUInt(&ok, 16);
|
||||
|
@ -193,7 +196,7 @@ void MxObPanel::OnClosingData(si::Chunk *chunk)
|
|||
|
||||
chunk->data("Position") = pos_edit_->GetValue();
|
||||
chunk->data("Direction") = dir_edit_->GetValue();
|
||||
chunk->data("Up") = up_edit_->GetValue();
|
||||
chunk->data("Up") = up_edit_->GetValue();*/
|
||||
}
|
||||
|
||||
void MxObPanel::FlagCheckBoxClicked(bool e)
|
||||
|
@ -211,4 +214,4 @@ void MxObPanel::FlagCheckBoxClicked(bool e)
|
|||
|
||||
flag_edit_->setText(QString::number(current, 16));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -16,8 +16,8 @@ public:
|
|||
explicit MxObPanel(QWidget *parent = nullptr);
|
||||
|
||||
protected:
|
||||
virtual void OnOpeningData(si::Chunk *chunk) override;
|
||||
virtual void OnClosingData(si::Chunk *chunk) override;
|
||||
virtual void OnOpeningData(void *data) override;
|
||||
virtual void OnClosingData(void *data) override;
|
||||
|
||||
private:
|
||||
QComboBox *type_combo_;
|
||||
|
@ -27,7 +27,7 @@ private:
|
|||
QSpinBox *obj_id_edit_;
|
||||
|
||||
QLineEdit* flag_edit_;
|
||||
|
||||
|
||||
QSpinBox *duration_edit_;
|
||||
QSpinBox *loops_edit_;
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
#include "mxof.h"
|
||||
|
||||
#include <chunk.h>
|
||||
#include <QLabel>
|
||||
|
||||
using namespace si;
|
||||
|
@ -24,8 +25,9 @@ MxOfPanel::MxOfPanel(QWidget *parent) :
|
|||
FinishLayout();
|
||||
}
|
||||
|
||||
void MxOfPanel::OnOpeningData(si::Chunk *chunk)
|
||||
void MxOfPanel::OnOpeningData(void *data)
|
||||
{
|
||||
Chunk *chunk = static_cast<Chunk*>(data);
|
||||
const Data &offsets_bytes = chunk->data("Offsets");
|
||||
const u32 *offsets = reinterpret_cast<const u32*>(offsets_bytes.data());
|
||||
size_t offset_count = offsets_bytes.size() / sizeof(u32);
|
||||
|
@ -39,7 +41,7 @@ void MxOfPanel::OnOpeningData(si::Chunk *chunk)
|
|||
}
|
||||
}
|
||||
|
||||
void MxOfPanel::OnClosingData(si::Chunk *chunk)
|
||||
void MxOfPanel::OnClosingData(void *data)
|
||||
{
|
||||
list_->clear();
|
||||
}
|
|
@ -14,8 +14,8 @@ public:
|
|||
explicit MxOfPanel(QWidget *parent = nullptr);
|
||||
|
||||
protected:
|
||||
virtual void OnOpeningData(si::Chunk *chunk) override;
|
||||
virtual void OnClosingData(si::Chunk *chunk) override;
|
||||
virtual void OnOpeningData(void *data) override;
|
||||
virtual void OnClosingData(void *data) override;
|
||||
|
||||
private:
|
||||
QSpinBox *obj_count_edit_;
|
|
@ -1,5 +1,6 @@
|
|||
#include "riff.h"
|
||||
|
||||
#include <chunk.h>
|
||||
#include <QLabel>
|
||||
|
||||
using namespace si;
|
||||
|
@ -18,15 +19,16 @@ RIFFPanel::RIFFPanel(QWidget *parent) :
|
|||
FinishLayout();
|
||||
}
|
||||
|
||||
void RIFFPanel::OnOpeningData(Chunk *chunk)
|
||||
void RIFFPanel::OnOpeningData(void *data)
|
||||
{
|
||||
Chunk *chunk = static_cast<Chunk*>(data);
|
||||
QString s = QString::fromLatin1(chunk->data("Format").c_str(), sizeof(u32));
|
||||
id_edit_->setText(s);
|
||||
}
|
||||
|
||||
void RIFFPanel::OnClosingData(Chunk *chunk)
|
||||
void RIFFPanel::OnClosingData(void *data)
|
||||
{
|
||||
QByteArray d = id_edit_->text().toLatin1();
|
||||
/*QByteArray d = id_edit_->text().toLatin1();
|
||||
|
||||
const int target_sz = sizeof(u32);
|
||||
if (d.size() != target_sz) {
|
||||
|
@ -38,5 +40,5 @@ void RIFFPanel::OnClosingData(Chunk *chunk)
|
|||
}
|
||||
}
|
||||
|
||||
chunk->data("Format") = *(u32*)d.data();
|
||||
chunk->data("Format") = *(u32*)d.data();*/
|
||||
}
|
|
@ -12,8 +12,8 @@ public:
|
|||
explicit RIFFPanel(QWidget *parent = nullptr);
|
||||
|
||||
protected:
|
||||
virtual void OnOpeningData(si::Chunk *chunk) override;
|
||||
virtual void OnClosingData(si::Chunk *chunk) override;
|
||||
virtual void OnOpeningData(void *data) override;
|
||||
virtual void OnClosingData(void *data) override;
|
||||
|
||||
private:
|
||||
QLineEdit *id_edit_;
|
108
app/siview/siview.cpp
Normal file
108
app/siview/siview.cpp
Normal file
|
@ -0,0 +1,108 @@
|
|||
#include "siview.h"
|
||||
|
||||
#include <QPushButton>
|
||||
#include <QSplitter>
|
||||
#include <QTreeView>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
using namespace si;
|
||||
|
||||
SIViewDialog::SIViewDialog(Mode mode, Chunk *riff, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
last_set_data_(nullptr)
|
||||
{
|
||||
setWindowTitle(mode == Import ? tr("Import SI File") : tr("Export SI File"));
|
||||
|
||||
auto layout = new QVBoxLayout(this);
|
||||
|
||||
auto splitter = new QSplitter();
|
||||
splitter->setChildrenCollapsible(false);
|
||||
layout->addWidget(splitter);
|
||||
|
||||
auto tree = new QTreeView();
|
||||
chunk_model_.SetChunk(riff);
|
||||
tree->setModel(&chunk_model_);
|
||||
tree->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(tree->selectionModel(), &QItemSelectionModel::currentRowChanged, this, &SIViewDialog::SelectionChanged);
|
||||
splitter->addWidget(tree);
|
||||
|
||||
config_stack_ = new QStackedWidget();
|
||||
splitter->addWidget(config_stack_);
|
||||
|
||||
panel_blank_ = new Panel();
|
||||
config_stack_->addWidget(panel_blank_);
|
||||
|
||||
panel_mxhd_ = new MxHdPanel();
|
||||
config_stack_->addWidget(panel_mxhd_);
|
||||
|
||||
panel_riff_ = new RIFFPanel();
|
||||
config_stack_->addWidget(panel_riff_);
|
||||
|
||||
panel_mxch_ = new MxChPanel();
|
||||
config_stack_->addWidget(panel_mxch_);
|
||||
|
||||
panel_mxof_ = new MxOfPanel();
|
||||
config_stack_->addWidget(panel_mxof_);
|
||||
|
||||
panel_mxob_ = new MxObPanel();
|
||||
config_stack_->addWidget(panel_mxob_);
|
||||
|
||||
auto btn_layout = new QHBoxLayout();
|
||||
layout->addLayout(btn_layout);
|
||||
|
||||
btn_layout->addStretch();
|
||||
|
||||
auto accept_btn = new QPushButton(mode == Import ? tr("De-Weave") : tr("Weave"));
|
||||
connect(accept_btn, &QPushButton::clicked, this, &SIViewDialog::accept);
|
||||
btn_layout->addWidget(accept_btn);
|
||||
|
||||
auto reject_btn = new QPushButton(tr("Cancel"));
|
||||
connect(reject_btn, &QPushButton::clicked, this, &SIViewDialog::reject);
|
||||
btn_layout->addWidget(reject_btn);
|
||||
|
||||
btn_layout->addStretch();
|
||||
}
|
||||
|
||||
void SIViewDialog::SetPanel(Panel *panel, si::Chunk *chunk)
|
||||
{
|
||||
auto current = static_cast<Panel*>(config_stack_->currentWidget());
|
||||
current->SetData(nullptr);
|
||||
|
||||
config_stack_->setCurrentWidget(panel);
|
||||
panel->SetData(chunk);
|
||||
last_set_data_ = chunk;
|
||||
}
|
||||
|
||||
void SIViewDialog::SelectionChanged(const QModelIndex &index)
|
||||
{
|
||||
Panel *p = panel_blank_;
|
||||
Chunk *c = static_cast<Chunk*>(index.internalPointer());
|
||||
|
||||
if (c) {
|
||||
switch (c->type()) {
|
||||
case Chunk::TYPE_MxHd:
|
||||
p = panel_mxhd_;
|
||||
break;
|
||||
case Chunk::TYPE_RIFF:
|
||||
case Chunk::TYPE_LIST:
|
||||
p = panel_riff_;
|
||||
break;
|
||||
case Chunk::TYPE_MxCh:
|
||||
p = panel_mxch_;
|
||||
break;
|
||||
case Chunk::TYPE_MxOf:
|
||||
p = panel_mxof_;
|
||||
break;
|
||||
case Chunk::TYPE_MxOb:
|
||||
p = panel_mxob_;
|
||||
break;
|
||||
case Chunk::TYPE_MxSt:
|
||||
case Chunk::TYPE_pad_:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (p != config_stack_->currentWidget() || c != last_set_data_) {
|
||||
SetPanel(p, c);
|
||||
}
|
||||
}
|
47
app/siview/siview.h
Normal file
47
app/siview/siview.h
Normal file
|
@ -0,0 +1,47 @@
|
|||
#ifndef SIVIEW_H
|
||||
#define SIVIEW_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QStackedWidget>
|
||||
|
||||
#include "chunkmodel.h"
|
||||
#include "panels/mxch.h"
|
||||
#include "panels/mxhd.h"
|
||||
#include "panels/mxob.h"
|
||||
#include "panels/mxof.h"
|
||||
#include "panels/riff.h"
|
||||
#include "panel.h"
|
||||
|
||||
class SIViewDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Mode {
|
||||
Import,
|
||||
Export
|
||||
};
|
||||
|
||||
SIViewDialog(Mode mode, si::Chunk *riff, QWidget *parent = nullptr);
|
||||
|
||||
private:
|
||||
void SetPanel(Panel *panel, si::Chunk *chunk);
|
||||
|
||||
QStackedWidget *config_stack_;
|
||||
|
||||
ChunkModel chunk_model_;
|
||||
|
||||
Panel *panel_blank_;
|
||||
RIFFPanel *panel_riff_;
|
||||
MxHdPanel *panel_mxhd_;
|
||||
MxChPanel *panel_mxch_;
|
||||
MxOfPanel *panel_mxof_;
|
||||
MxObPanel *panel_mxob_;
|
||||
|
||||
si::Chunk *last_set_data_;
|
||||
|
||||
private slots:
|
||||
void SelectionChanged(const QModelIndex &index);
|
||||
|
||||
};
|
||||
|
||||
#endif // SIVIEW_H
|
Loading…
Add table
Reference in a new issue