mirror of
https://github.com/martravi/wiiqt6.git
synced 2024-11-21 21:19:15 +01:00
start of an editor for breft files
git-svn-id: http://wiiqt.googlecode.com/svn/trunk@31 389f4c8b-5dfe-645f-db0e-df882bc27289
This commit is contained in:
parent
a3e6288604
commit
fd20bc4484
96
breft_editor/breft.cpp
Normal file
96
breft_editor/breft.cpp
Normal file
@ -0,0 +1,96 @@
|
||||
#include "breft.h"
|
||||
|
||||
QDataStream
|
||||
&operator<<( QDataStream &stream, const header &data)
|
||||
{
|
||||
stream << data.magic.value << data.endian;
|
||||
stream << data.version_hi << data.version_lo;
|
||||
stream << data.length << data.header_size << data.chunk_cnt;
|
||||
return stream;
|
||||
}
|
||||
QDataStream
|
||||
&operator>>( QDataStream &stream, header &data)
|
||||
{
|
||||
stream >> data.magic.value >> data.endian;
|
||||
stream >> data.version_hi >> data.version_lo;
|
||||
stream >> data.length >> data.header_size >> data.chunk_cnt;
|
||||
return stream;
|
||||
}
|
||||
|
||||
QDataStream
|
||||
&operator<<( QDataStream &stream, const reft &data)
|
||||
{
|
||||
stream << data.magic.value << data.length;
|
||||
return stream;
|
||||
}
|
||||
QDataStream
|
||||
&operator>>( QDataStream &stream, reft &data)
|
||||
{
|
||||
stream >> data.magic.value >> data.length;
|
||||
return stream;
|
||||
}
|
||||
|
||||
QDataStream
|
||||
&operator<<( QDataStream &stream, const projct &data)
|
||||
{
|
||||
stream << data.length << data.unk1 << data.unk2;
|
||||
stream << data.str_length << data.unk3;
|
||||
return stream;
|
||||
}
|
||||
QDataStream
|
||||
&operator>>( QDataStream &stream, projct &data)
|
||||
{
|
||||
stream >> data.length >> data.unk1 >> data.unk2;
|
||||
stream >> data.str_length >> data.unk3;
|
||||
return stream;
|
||||
}
|
||||
|
||||
QDataStream
|
||||
&operator<<( QDataStream &stream, const section1 &data)
|
||||
{
|
||||
stream << data.length << data.count << data.padding;
|
||||
return stream;
|
||||
}
|
||||
QDataStream
|
||||
&operator>>( QDataStream &stream, section1 &data)
|
||||
{
|
||||
stream >> data.length >> data.count >> data.padding;
|
||||
return stream;
|
||||
}
|
||||
|
||||
QDataStream
|
||||
&operator<<( QDataStream &stream, const section1b &data)
|
||||
{
|
||||
stream << data.offset << data.length;
|
||||
return stream;
|
||||
}
|
||||
QDataStream
|
||||
&operator>>( QDataStream &stream, section1b &data)
|
||||
{
|
||||
stream >> data.offset >> data.length;
|
||||
return stream;
|
||||
}
|
||||
|
||||
QDataStream
|
||||
&operator<<( QDataStream &stream, const picture_header &data)
|
||||
{
|
||||
stream << data.unk1 << data.height << data.width << data.size;
|
||||
stream << data.format << data.unk2 << data.unk3 << data.unk4;
|
||||
stream << data.unk5 << data.unk6 << data.rptx << data.rpty;
|
||||
stream << data.unk7 << data.unk8 << data.unk9 << data.unkA;
|
||||
stream << data.unkB << data.unkC << data.unkD << data.unkE;
|
||||
stream << data.unkF << data.unkG;
|
||||
return stream;
|
||||
}
|
||||
QDataStream
|
||||
&operator>>( QDataStream &stream, picture_header &data)
|
||||
{
|
||||
stream >> data.unk1 >> data.height >> data.width >> data.size;
|
||||
stream >> data.format >> data.unk2 >> data.unk3 >> data.unk4;
|
||||
stream >> data.unk5 >> data.unk6 >> data.rptx >> data.rpty;
|
||||
stream >> data.unk7 >> data.unk8 >> data.unk9 >> data.unkA;
|
||||
stream >> data.unkB >> data.unkC >> data.unkD >> data.unkE;
|
||||
stream >> data.unkF >> data.unkG;
|
||||
return stream;
|
||||
}
|
||||
|
106
breft_editor/breft.h
Normal file
106
breft_editor/breft.h
Normal file
@ -0,0 +1,106 @@
|
||||
#ifndef BREFT_H
|
||||
#define BREFT_H
|
||||
|
||||
#include <QtCore>
|
||||
|
||||
union Magic {
|
||||
quint32 value;
|
||||
char string[4];
|
||||
};
|
||||
|
||||
struct header {
|
||||
Magic magic;
|
||||
quint16 endian;
|
||||
quint8 version_hi;
|
||||
quint8 version_lo;
|
||||
quint32 length;
|
||||
quint16 header_size;
|
||||
quint16 chunk_cnt;
|
||||
};
|
||||
|
||||
struct reft {
|
||||
Magic magic;
|
||||
quint32 length;
|
||||
};
|
||||
|
||||
struct projct {
|
||||
quint32 length;
|
||||
quint32 unk1;
|
||||
quint32 unk2;
|
||||
quint16 str_length;
|
||||
quint16 unk3;
|
||||
};
|
||||
|
||||
struct section1 {
|
||||
quint32 length;
|
||||
quint16 count;
|
||||
quint16 padding;
|
||||
};
|
||||
|
||||
struct section1b {
|
||||
quint32 offset;
|
||||
quint32 length;
|
||||
};
|
||||
|
||||
struct picture_header {
|
||||
quint32 unk1; //00
|
||||
quint16 height; //04
|
||||
quint16 width; //06
|
||||
quint32 size; //08
|
||||
quint8 format; //0c
|
||||
quint8 unk2;
|
||||
quint8 unk3;
|
||||
quint8 unk4;
|
||||
quint32 unk5; //10
|
||||
quint8 unk6; //14
|
||||
quint8 rptx; //15
|
||||
quint8 rpty; //16
|
||||
quint8 unk7; //17
|
||||
quint32 unk8; //18
|
||||
quint32 unk9; //1c
|
||||
quint32 unkA; //20
|
||||
quint32 unkB; //24
|
||||
quint32 unkC; //28
|
||||
quint32 unkD; //30
|
||||
quint32 unkE; //34
|
||||
quint32 unkF; //38
|
||||
quint32 unkG; //3c
|
||||
};
|
||||
|
||||
struct tpl_header {
|
||||
Magic magic;
|
||||
quint32 count;
|
||||
quint32 header_size;
|
||||
quint32 offset;
|
||||
};
|
||||
|
||||
struct tpl_header2 {
|
||||
quint16 height;
|
||||
quint16 width;
|
||||
quint32 format;
|
||||
quint32 offset;
|
||||
quint32 wrap_s;
|
||||
quint32 wrap_t;
|
||||
quint32 min;
|
||||
quint32 mag;
|
||||
float lod_bias;
|
||||
quint8 edge_lod;
|
||||
quint8 min_lod;
|
||||
quint8 max_lod;
|
||||
quint8 unpacked;
|
||||
};
|
||||
|
||||
QDataStream &operator<<( QDataStream &stream, const header &data);
|
||||
QDataStream &operator>>( QDataStream &stream, header &data);
|
||||
QDataStream &operator<<( QDataStream &stream, const reft &data);
|
||||
QDataStream &operator>>( QDataStream &stream, reft &data);
|
||||
QDataStream &operator<<( QDataStream &stream, const projct &data);
|
||||
QDataStream &operator>>( QDataStream &stream, projct &data);
|
||||
QDataStream &operator<<( QDataStream &stream, const section1 &data);
|
||||
QDataStream &operator>>( QDataStream &stream, section1 &data);
|
||||
QDataStream &operator<<( QDataStream &stream, const section1b &data);
|
||||
QDataStream &operator>>( QDataStream &stream, section1b &data);
|
||||
QDataStream &operator<<( QDataStream &stream, const picture_header &data);
|
||||
QDataStream &operator>>( QDataStream &stream, picture_header &data);
|
||||
|
||||
#endif /*BREFT_H*/
|
17
breft_editor/breft.pro
Normal file
17
breft_editor/breft.pro
Normal file
@ -0,0 +1,17 @@
|
||||
QT += core gui\
|
||||
network
|
||||
|
||||
TARGET = breft_editor
|
||||
TEMPLATE = app
|
||||
|
||||
|
||||
SOURCES += main.cpp\
|
||||
mainwindow.cpp \
|
||||
breft.cpp \
|
||||
../WiiQt/tools.cpp \
|
||||
../WiiQt/aes.c \
|
||||
../WiiQt/sha1.c
|
||||
|
||||
HEADERS += mainwindow.h \
|
||||
breft.h \
|
||||
../WiiQt/tools.h \
|
11
breft_editor/main.cpp
Normal file
11
breft_editor/main.cpp
Normal file
@ -0,0 +1,11 @@
|
||||
#include <QtGui/QApplication>
|
||||
#include "mainwindow.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
MainWindow w;
|
||||
w.show();
|
||||
|
||||
return a.exec();
|
||||
}
|
187
breft_editor/mainwindow.cpp
Normal file
187
breft_editor/mainwindow.cpp
Normal file
@ -0,0 +1,187 @@
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include "../WiiQt/tools.h"
|
||||
#include "breft.h"
|
||||
|
||||
MainWindow::MainWindow( QWidget *parent ) : QMainWindow( parent)
|
||||
{
|
||||
setObjectName("MainWindow");
|
||||
resize(1024, 768);
|
||||
|
||||
setUnifiedTitleAndToolBarOnMac(true);
|
||||
|
||||
QFrame *centralwidget = new QFrame;
|
||||
Layout = new QGridLayout(centralwidget);
|
||||
|
||||
setupForms();
|
||||
|
||||
setupActions();
|
||||
setupMenu();
|
||||
|
||||
setCentralWidget(centralwidget);
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
}
|
||||
|
||||
void MainWindow::setupForms()
|
||||
{
|
||||
QVBoxLayout* mainLayout = new QVBoxLayout;
|
||||
|
||||
plainTextEdit_log = new QPlainTextEdit;
|
||||
mainLayout->addWidget(plainTextEdit_log);
|
||||
|
||||
Layout->addLayout(mainLayout, 0, 0);
|
||||
|
||||
ShowMessage( tr("Done creating forms") );
|
||||
}
|
||||
|
||||
void MainWindow::setupActions()
|
||||
{
|
||||
actionQuit = new QAction(this);
|
||||
actionQuit->setText("Quit");
|
||||
actionQuit->setToolTip("Quits the program.");
|
||||
connect(actionQuit, SIGNAL(triggered()), this, SLOT(on_actionQuit_triggered()));
|
||||
|
||||
actionLoad = new QAction(this);
|
||||
actionLoad->setText("Load");
|
||||
actionLoad->setToolTip("Loads a breft.");
|
||||
connect(actionLoad, SIGNAL(triggered()), this, SLOT(on_actionLoad_triggered()));
|
||||
|
||||
ShowMessage( tr("Done creating actions") );
|
||||
}
|
||||
|
||||
void MainWindow::setupMenu()
|
||||
{
|
||||
menubar = new QMenuBar(this);
|
||||
|
||||
menuFile = new QMenu(tr("&File"), this);
|
||||
menuFile->addAction(actionLoad);
|
||||
menuFile->addAction(actionQuit);
|
||||
menubar->addAction(menuFile->menuAction());
|
||||
menubar->addMenu(menuFile);
|
||||
|
||||
setMenuBar(menubar);
|
||||
|
||||
ShowMessage( tr("Done creating menu") );
|
||||
}
|
||||
|
||||
void MainWindow::on_actionQuit_triggered()
|
||||
{
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
void MainWindow::on_actionLoad_triggered()
|
||||
{
|
||||
//DO SOMETHING COOL
|
||||
QString fn = QFileDialog::getOpenFileName( this,
|
||||
tr("Effects files(*.breft)"),
|
||||
QCoreApplication::applicationDirPath(),
|
||||
tr("BreftFiles (*.breft)"));
|
||||
if(fn == "") {
|
||||
ShowMessage( tr("No breft selected") );
|
||||
return;
|
||||
}
|
||||
|
||||
QByteArray data = ReadFile( fn );
|
||||
if( data.isEmpty() ) {
|
||||
ShowMessage( tr("Bad breft file") );
|
||||
return;
|
||||
}
|
||||
|
||||
QDataStream stream(data);
|
||||
header head;
|
||||
stream >> head;
|
||||
ShowMessage( tr("Header loaded") );
|
||||
reft rft;
|
||||
stream >> rft;
|
||||
ShowMessage( tr("Reft loaded") );
|
||||
qint64 curr_pos = stream.device()->pos();
|
||||
projct proj;
|
||||
stream >> proj;
|
||||
ShowMessage( tr("Project loaded") );
|
||||
char* project_name = new char[proj.str_length];
|
||||
stream.readRawData(project_name, proj.str_length);
|
||||
ShowMessage( QString("Project name: %1").arg(project_name) );
|
||||
delete[] project_name;
|
||||
stream.device()->seek(proj.length + curr_pos);
|
||||
|
||||
qint64 temp_pos = stream.device()->pos();
|
||||
section1 sec1;
|
||||
stream >> sec1;
|
||||
|
||||
for(quint32 ii=0; ii<sec1.count; ii++) {
|
||||
quint16 len;
|
||||
stream >> len;
|
||||
char* string_name = new char[len];
|
||||
stream.readRawData(string_name, len);
|
||||
ShowMessage( tr("String Name: %1").arg(string_name) );
|
||||
section1b sec1b;
|
||||
stream >> sec1b;
|
||||
curr_pos = stream.device()->pos();
|
||||
qint64 my_pos = temp_pos + sec1b.offset;
|
||||
stream.device()->seek(my_pos);
|
||||
picture_header pic_head;
|
||||
stream >> pic_head;
|
||||
ShowMessage( tr("Picture Header read") );
|
||||
QByteArray pic_data(pic_head.size, '\x00');
|
||||
stream.readRawData( pic_data.data() , pic_head.size );
|
||||
|
||||
// SHOW TPL ON SCREEN
|
||||
|
||||
// SAVE TPL TO FILE
|
||||
#if 0
|
||||
QFile tpl( "tpl_data/" + QString(string_name) + ".tpl" );
|
||||
if( !tpl.open( QIODevice::WriteOnly ) )
|
||||
{
|
||||
ShowMessage( "<b>Couldn't open " + QString(string_name) + " for writing<\b>" );
|
||||
}else{
|
||||
//Write header1
|
||||
QByteArray tplHead1;
|
||||
char tpl_head[0x14] = { 0, 0x20, 0xaf, 0x30,
|
||||
0x00, 0x00, 0x00, 0x01,
|
||||
0x00, 0x00, 0x00, 0x0c,
|
||||
0x00, 0x00, 0x00, 0x14,
|
||||
0x00, 0x00, 0x00, 0x00 };
|
||||
tplHead1.append(tpl_head, 0x14);
|
||||
tpl.write( tplHead1 );
|
||||
//Write header2
|
||||
QByteArray tplHead2;
|
||||
char tpl_head2[44] = {
|
||||
0x00, 0x80, 0x00, 0x80, //height && width
|
||||
0x00, 0x00, 0x00, 0x04, //format
|
||||
0x00, 0x00, 0x00, 0x40, //offset
|
||||
0x00, 0x00, 0x00, 0x00, //wrap_s
|
||||
0x00, 0x00, 0x00, 0x00, //wrap_t
|
||||
0x00, 0x00, 0x00, 0x01, //min
|
||||
0x00, 0x00, 0x00, 0x01, //mag
|
||||
0x00, 0x00, 0x00, 0x00, //lod_bias
|
||||
0x00, 0x00, 0x00, 0x00, //lods and unpacked
|
||||
0x00, 0x00, 0x00, 0x00, //padding
|
||||
0x00, 0x00, 0x00, 0x00 };
|
||||
*(quint16*)(tpl_head2 + 0) = qToBigEndian(pic_head.height);
|
||||
*(quint16*)(tpl_head2 + 2) = qToBigEndian(pic_head.width);
|
||||
*(quint32*)(tpl_head2 + 4) = qToBigEndian((quint32)pic_head.format);
|
||||
tplHead2.append(tpl_head2, 44);
|
||||
tpl.write( tplHead2 );
|
||||
//Write data
|
||||
tpl.write( pic_data );
|
||||
tpl.close();
|
||||
ShowMessage( "Saved " + QString(string_name) );
|
||||
}
|
||||
#endif
|
||||
|
||||
stream.device()->seek(curr_pos);
|
||||
delete[] string_name;
|
||||
}
|
||||
|
||||
ShowMessage( tr("Done loading a breft") );
|
||||
}
|
||||
|
||||
void MainWindow::ShowMessage( const QString& mes )
|
||||
{
|
||||
QString str = mes;
|
||||
plainTextEdit_log->appendHtml( str );
|
||||
}
|
||||
|
46
breft_editor/mainwindow.h
Normal file
46
breft_editor/mainwindow.h
Normal file
@ -0,0 +1,46 @@
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include "../WiiQt/includes.h"
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow( QWidget *parent = 0 );
|
||||
~MainWindow();
|
||||
void ShowMessage( const QString& mes );
|
||||
|
||||
private:
|
||||
void setupForms();
|
||||
void setupActions();
|
||||
void setupMenu();
|
||||
QGridLayout* Layout;
|
||||
QAction* actionQuit;
|
||||
QAction* actionLoad;
|
||||
QMenuBar* menubar;
|
||||
QMenu* menuFile;
|
||||
QPlainTextEdit* plainTextEdit_log;
|
||||
|
||||
public slots:
|
||||
|
||||
private slots:
|
||||
void on_actionQuit_triggered();
|
||||
void on_actionLoad_triggered();
|
||||
/*
|
||||
void on_pushButton_CachePathBrowse_clicked();
|
||||
void on_actionFlush_triggered();
|
||||
void on_actionSetting_txt_triggered();
|
||||
void on_actionImportWad_triggered();
|
||||
void on_pushButton_wad_clicked();
|
||||
void on_pushButton_decFolder_clicked();
|
||||
void on_pushButton_nandPath_clicked();
|
||||
void on_radioButton_wad_toggled(bool checked);
|
||||
void on_radioButton_folder_toggled(bool checked);
|
||||
void on_radioButton_nand_toggled(bool checked);
|
||||
void on_pushButton_GetTitle_clicked();
|
||||
*/
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
@ -219,6 +219,7 @@
|
||||
<addaction name="actionSetting_txt"/>
|
||||
<addaction name="actionFlush"/>
|
||||
<addaction name="actionImportWad"/>
|
||||
<addaction name="actionImportFolder"/>
|
||||
</widget>
|
||||
<addaction name="menuNand_Dump"/>
|
||||
</widget>
|
||||
@ -249,6 +250,11 @@
|
||||
<string>Ctrl+I</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionImportFolder">
|
||||
<property name="text">
|
||||
<string>Import Folder</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources/>
|
||||
|
Loading…
Reference in New Issue
Block a user