Skip to content

Commit

Permalink
add LST support for TXT files
Browse files Browse the repository at this point in the history
  • Loading branch information
friends111 committed Jul 27, 2018
1 parent 84d17b7 commit a506c08
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 8 deletions.
16 changes: 13 additions & 3 deletions Source/Decryptors/NosTextOthersFileDecryptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,19 @@ QByteArray NosTextOthersFileDecryptor::encrypt(QByteArray &array)
QByteArray NosTextOthersFileDecryptor::decrypt(QByteArray &array)
{
QByteArray result;
int lines = qFromLittleEndian<int>(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<int>(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;
}
2 changes: 2 additions & 0 deletions Source/Decryptors/NosTextOthersFileDecryptor.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef NOSTEXTOTHERSFILEDECRYPTOR_H
#define NOSTEXTOTHERSFILEDECRYPTOR_H
#include "INosDecryptor.h"
#include <QtEndian>
#include <QDebug>

class NosTextOthersFileDecryptor : public INosDecryptor
{
Expand Down
3 changes: 2 additions & 1 deletion Source/Openers/NosCCInfOpener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
7 changes: 5 additions & 2 deletions Source/Openers/NosTextOpener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
2 changes: 2 additions & 0 deletions Source/Openers/NosTextOpener.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
#include <QDebug>
#include "INosFileOpener.h"
#include "../Decryptors/NosTextDatFileDecryptor.h"
#include "../Decryptors/NosTextOthersFileDecryptor.h"
#include "../Ui/OnexTreeText.h"

class NosTextOpener : public QObject, INosFileOpener
{
Q_OBJECT
private:
NosTextDatFileDecryptor datDecryptor;
NosTextOthersFileDecryptor lstDecryptor;
public:
NosTextOpener();
virtual OnexTreeItem* decrypt(QFile& file);
Expand Down
4 changes: 2 additions & 2 deletions Source/Ui/OnexNSmpData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ OnexNSmpData::OnexNSmpData(QString name, QByteArray content, NosZlibOpener *open

QImage OnexNSmpData::getImage()
{

return QImage();
}

ImageResolution OnexNSmpData::getResolution()
{

return ImageResolution();
}

OnexNSmpData::~OnexNSmpData()
Expand Down

0 comments on commit a506c08

Please sign in to comment.