diff --git a/tools/compro/compro.pro b/tools/compro/compro.pro new file mode 100644 index 0000000..5c437c8 --- /dev/null +++ b/tools/compro/compro.pro @@ -0,0 +1,28 @@ +QT += core widgets gui multimedia + +SUBDIRS += compro + +CONFIG += c++17 + +SOURCES += \ + compromain.cpp \ + mainwindow.cpp + +HEADERS += \ + mainwindow.h + +LIBS += \ + -L$$OUT_PWD/../../libs/ -lcompression \ + -L$$PWD/../../third_party/xbox_sdk/lib -lxcompress64 + +INCLUDEPATH += \ + $$PWD/../../libs/compression \ + $$PWD/../../third_party/xbox_sdk/include + +DEPENDPATH += \ + $$PWD/../../libs/compression \ + $$PWD/../../third_party/xbox_sdk/include + +FORMS += \ + mainwindow.ui + diff --git a/tools/compro/compromain.cpp b/tools/compro/compromain.cpp new file mode 100644 index 0000000..fd3e533 --- /dev/null +++ b/tools/compro/compromain.cpp @@ -0,0 +1,11 @@ +#include "mainwindow.h" + +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + MainWindow w; + w.show(); + return a.exec(); +} diff --git a/tools/compro/mainwindow.cpp b/tools/compro/mainwindow.cpp new file mode 100644 index 0000000..8907cb0 --- /dev/null +++ b/tools/compro/mainwindow.cpp @@ -0,0 +1,66 @@ +#include "mainwindow.h" +#include "ui_mainwindow.h" + +#include "compression.h" + +MainWindow::MainWindow(QWidget *parent) + : QMainWindow(parent) + , ui(new Ui::MainWindow) +{ + ui->setupUi(this); + + connect(ui->plainTextEdit_Input, &QPlainTextEdit::textChanged, this, &MainWindow::InputChanged); +} + +MainWindow::~MainWindow() +{ + delete ui; +} + +void MainWindow::InputChanged() +{ + QString input = ui->plainTextEdit_Input->toPlainText(); + if (input.isEmpty()) { + qDebug() << "Input data was empty!"; + return; + } + + QByteArray inputData = QByteArray::fromHex(input.remove(' ').toUtf8()); + if (inputData.isEmpty()) { + qDebug() << "Failed to parse valid HEX data!"; + return; + } + + bool flagOk; + int flag = QString("0x%1").arg(ui->spinBox_Flags->value()).toInt(&flagOk, 16); + if (!flagOk) + { + qDebug() << "Failed to parse flag!"; + return; + } + + bool windowSizeOk; + int windowSize = QString("0x%1").arg(ui->spinBox_WindowSize->value()).toInt(&windowSizeOk, 16); + if (!windowSizeOk) + { + qDebug() << "Failed to parse window size!"; + return; + } + + bool partSizeOk; + int partitionSize = QString("0x%1").arg(ui->spinBox_PartitionSize->value()).toInt(&partSizeOk, 16); + if (!partSizeOk) + { + qDebug() << "Failed to parse partition size!"; + return; + } + + try { + QByteArray output = Compression::DecompressXMem(inputData, flag, windowSize, partitionSize); + ui->plainTextEdit_Output->setPlainText(output.toHex(' ').toUpper()); + } catch (const std::exception &e) { + ui->plainTextEdit_Output->setPlainText(QString("Decompression failed: %1").arg(e.what())); + } catch (...) { + ui->plainTextEdit_Output->setPlainText("Decompression failed: Unknown error"); + } +} diff --git a/tools/compro/mainwindow.h b/tools/compro/mainwindow.h new file mode 100644 index 0000000..84d720d --- /dev/null +++ b/tools/compro/mainwindow.h @@ -0,0 +1,25 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include + +namespace Ui { +class MainWindow; +} + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit MainWindow(QWidget *parent = nullptr); + ~MainWindow(); + +private slots: + void InputChanged(); + +private: + Ui::MainWindow *ui; +}; + +#endif // MAINWINDOW_H diff --git a/tools/compro/mainwindow.ui b/tools/compro/mainwindow.ui new file mode 100644 index 0000000..bbcb887 --- /dev/null +++ b/tools/compro/mainwindow.ui @@ -0,0 +1,153 @@ + + + MainWindow + + + + 0 + 0 + 1006 + 600 + + + + MainWindow + + + + + + + 0 + + + + LZX + + + + + + + + Input + + + + + + Input HEX Data (Ex: 63 60 C0 04...) + + + + + + + + + + Qt::Orientation::Vertical + + + + + + + Parameters + + + + + + Flags: + + + + + + + Window Size: + + + + + + + Compression Partition Size: + + + + + + + 0x + + + + + + + 0x + + + 100000 + + + 20000 + + + + + + + 0x + + + 100000 + + + 80000 + + + + + + + + + + + + Qt::Orientation::Horizontal + + + + + + + Output + + + + + + true + + + Output HEX Data + + + + + + + + + + + + + + + +