From a506c08b3586f8a6d3527c0afab7e09ca1db97b7 Mon Sep 17 00:00:00 2001 From: friends111 Date: Fri, 27 Jul 2018 18:14:45 +0200 Subject: [PATCH] add LST support for TXT files --- Source/Decryptors/NosTextOthersFileDecryptor.cpp | 16 +++++++++++++--- Source/Decryptors/NosTextOthersFileDecryptor.h | 2 ++ Source/Openers/NosCCInfOpener.cpp | 3 ++- Source/Openers/NosTextOpener.cpp | 7 +++++-- Source/Openers/NosTextOpener.h | 2 ++ Source/Ui/OnexNSmpData.cpp | 4 ++-- 6 files changed, 26 insertions(+), 8 deletions(-) diff --git a/Source/Decryptors/NosTextOthersFileDecryptor.cpp b/Source/Decryptors/NosTextOthersFileDecryptor.cpp index c3b363e..88295bc 100644 --- a/Source/Decryptors/NosTextOthersFileDecryptor.cpp +++ b/Source/Decryptors/NosTextOthersFileDecryptor.cpp @@ -13,9 +13,19 @@ QByteArray NosTextOthersFileDecryptor::encrypt(QByteArray &array) QByteArray NosTextOthersFileDecryptor::decrypt(QByteArray &array) { QByteArray result; + int lines = qFromLittleEndian(array.mid(0, 4)); + int pos = 4; - for (auto& byte : array) - result.push_back(byte ^ 0x1); - + for (int i = 0; i < lines; i++) + { + int strLen = qFromLittleEndian(array.mid(pos, 4)); + pos += 4; + QByteArray str = array.mid(pos, strLen); + pos += strLen; + for (auto& byte : str) + result.push_back(byte ^ 0x1); + result.push_back('\n'); + } + qDebug() << result; return result; } diff --git a/Source/Decryptors/NosTextOthersFileDecryptor.h b/Source/Decryptors/NosTextOthersFileDecryptor.h index 91288a4..5b7aad0 100644 --- a/Source/Decryptors/NosTextOthersFileDecryptor.h +++ b/Source/Decryptors/NosTextOthersFileDecryptor.h @@ -1,6 +1,8 @@ #ifndef NOSTEXTOTHERSFILEDECRYPTOR_H #define NOSTEXTOTHERSFILEDECRYPTOR_H #include "INosDecryptor.h" +#include +#include class NosTextOthersFileDecryptor : public INosDecryptor { diff --git a/Source/Openers/NosCCInfOpener.cpp b/Source/Openers/NosCCInfOpener.cpp index 574f98c..051e3af 100644 --- a/Source/Openers/NosCCInfOpener.cpp +++ b/Source/Openers/NosCCInfOpener.cpp @@ -16,9 +16,10 @@ OnexTreeItem *NosCCInfOpener::decrypt(QFile &file) file.read(1); //0x00 int fileAmount = readNextInt(file); qDebug() << fileAmount; + return NULL; } QByteArray NosCCInfOpener::encrypt(OnexTreeItem *item) { - + return QByteArray(); } diff --git a/Source/Openers/NosTextOpener.cpp b/Source/Openers/NosTextOpener.cpp index b2edfa3..2ebeb64 100644 --- a/Source/Openers/NosTextOpener.cpp +++ b/Source/Openers/NosTextOpener.cpp @@ -20,8 +20,11 @@ OnexTreeItem *NosTextOpener::decrypt(QFile &file) int isDat = readNextInt(file); int fileSize = readNextInt(file); QByteArray fileContent = file.read(fileSize); - - QByteArray decryptedArray = datDecryptor.decrypt(fileContent); + QByteArray decryptedArray; + if (isDat) + decryptedArray = datDecryptor.decrypt(fileContent); + else //.lst + decryptedArray = lstDecryptor.decrypt(fileContent); item->addChild(new OnexTreeText(stringName, this, fileNumber, isDat, decryptedArray)); } diff --git a/Source/Openers/NosTextOpener.h b/Source/Openers/NosTextOpener.h index 48e4544..d18478a 100644 --- a/Source/Openers/NosTextOpener.h +++ b/Source/Openers/NosTextOpener.h @@ -5,6 +5,7 @@ #include #include "INosFileOpener.h" #include "../Decryptors/NosTextDatFileDecryptor.h" +#include "../Decryptors/NosTextOthersFileDecryptor.h" #include "../Ui/OnexTreeText.h" class NosTextOpener : public QObject, INosFileOpener @@ -12,6 +13,7 @@ class NosTextOpener : public QObject, INosFileOpener Q_OBJECT private: NosTextDatFileDecryptor datDecryptor; + NosTextOthersFileDecryptor lstDecryptor; public: NosTextOpener(); virtual OnexTreeItem* decrypt(QFile& file); diff --git a/Source/Ui/OnexNSmpData.cpp b/Source/Ui/OnexNSmpData.cpp index 1520c88..6b172f6 100644 --- a/Source/Ui/OnexNSmpData.cpp +++ b/Source/Ui/OnexNSmpData.cpp @@ -8,12 +8,12 @@ OnexNSmpData::OnexNSmpData(QString name, QByteArray content, NosZlibOpener *open QImage OnexNSmpData::getImage() { - + return QImage(); } ImageResolution OnexNSmpData::getResolution() { - + return ImageResolution(); } OnexNSmpData::~OnexNSmpData()