Add compro tool.
This commit is contained in:
parent
b5595d9855
commit
c005d19fa8
28
tools/compro/compro.pro
Normal file
28
tools/compro/compro.pro
Normal file
@ -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
|
||||
|
||||
11
tools/compro/compromain.cpp
Normal file
11
tools/compro/compromain.cpp
Normal file
@ -0,0 +1,11 @@
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
MainWindow w;
|
||||
w.show();
|
||||
return a.exec();
|
||||
}
|
||||
66
tools/compro/mainwindow.cpp
Normal file
66
tools/compro/mainwindow.cpp
Normal file
@ -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");
|
||||
}
|
||||
}
|
||||
25
tools/compro/mainwindow.h
Normal file
25
tools/compro/mainwindow.h
Normal file
@ -0,0 +1,25 @@
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
|
||||
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
|
||||
153
tools/compro/mainwindow.ui
Normal file
153
tools/compro/mainwindow.ui
Normal file
@ -0,0 +1,153 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1006</width>
|
||||
<height>600</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
<string>LZX</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Input</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QPlainTextEdit" name="plainTextEdit_Input">
|
||||
<property name="placeholderText">
|
||||
<string>Input HEX Data (Ex: 63 60 C0 04...)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_3">
|
||||
<property name="title">
|
||||
<string>Parameters</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Flags:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Window Size:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Compression Partition Size:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QSpinBox" name="spinBox_Flags">
|
||||
<property name="prefix">
|
||||
<string>0x</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QSpinBox" name="spinBox_WindowSize">
|
||||
<property name="prefix">
|
||||
<string>0x</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>100000</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>20000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QSpinBox" name="spinBox_PartitionSize">
|
||||
<property name="prefix">
|
||||
<string>0x</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>100000</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>80000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Output</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QPlainTextEdit" name="plainTextEdit_Output">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>Output HEX Data</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Loading…
x
Reference in New Issue
Block a user