XPlor/libs/zonefile/zonefile.cpp

162 lines
5.3 KiB
C++
Raw Normal View History

2025-02-08 19:58:54 -05:00
#include "zonefile.h"
#include "utils.h"
2025-04-04 20:40:45 -04:00
#include "logmanager.h"
2025-02-08 19:58:54 -05:00
#include <QFile>
#include <QDataStream>
#include <QDebug>
ZoneFile::ZoneFile() :
2025-02-19 19:17:31 -05:00
mStem(),
mSize(),
mTagCount(),
mTags(),
mRecordCount(),
mRecords(),
mAssetMap() {
2025-02-08 19:58:54 -05:00
}
ZoneFile::~ZoneFile() {
}
ZoneFile::ZoneFile(const ZoneFile &aZoneFile) {
2025-02-19 19:17:31 -05:00
mStem = aZoneFile.mStem;
mSize = aZoneFile.mSize;
mTagCount = aZoneFile.mTagCount;
mTags = aZoneFile.mTags;
mRecordCount = aZoneFile.mRecordCount;
mRecords = aZoneFile.mRecords;
mAssetMap = aZoneFile.mAssetMap;
2025-02-08 19:58:54 -05:00
}
ZoneFile &ZoneFile::operator=(const ZoneFile &other) {
if (this != &other) {
2025-02-19 19:17:31 -05:00
mStem = other.mStem;
mSize = other.mSize;
mTagCount = other.mTagCount;
mTags = other.mTags;
mRecordCount = other.mRecordCount;
mRecords = other.mRecords;
mAssetMap = other.mAssetMap;
2025-02-08 19:58:54 -05:00
}
return *this;
}
2025-04-04 20:40:45 -04:00
QIcon ZoneFile::AssetStrToIcon(const QString aAssetStr) {
const QString cleanedType = aAssetStr.toUpper();
if (cleanedType == "LOCAL STRING") { // localized string PARTIALLY VERIFIED
return QIcon(":/icons/icons/Icon_StringFile.png");
} else if (cleanedType == "RAW FILE") { // raw_file PARTIALLY VERIFIED
return QIcon(":/icons/icons/Icon_RawFile.png");
} else if (cleanedType == "GSC FILE") { // raw_file PARTIALLY VERIFIED
return QIcon(":/icons/icons/Icon_GSCFile.png");
} else if (cleanedType == "EFFECT") { // fx PARTIALLY VERIFIED
return QIcon(":/icons/icons/Icon_Effect.png");
} else if (cleanedType == "SOUND") { // loaded_sound PARTIALLY VERIFIED
return QIcon(":/icons/icons/Icon_Sound.png");
} else if (cleanedType == "ANIMATION") { // x_anim PARTIALLY VERIFIED
return QIcon(":/icons/icons/Icon_Animation.png");
} else if (cleanedType == "COLLISION MAP") { // collision_map PARTIALLY VERIFIED
//return "COLLISION MAP";
} else if (cleanedType == "STRING TABLE") { // string_table PARTIALLY VERIFIED
return QIcon(":/icons/icons/Icon_StringTable.png");
} else if (cleanedType == "MENU") { // menu_file PARTIALLY VERIFIED
return QIcon(":/icons/icons/Icon_MenuFile.png");
} else if (cleanedType == "TECH SET") { // tech set PARTIALLY VERIFIED
return QIcon(":/icons/icons/Icon_TechSetFile.png");
} else if (cleanedType == "WEAPON") { // weapon PARTIALLY VERIFIED
return QIcon(":/icons/icons/Icon_Weapon.png");
} else if (cleanedType == "GFX MAP") { // gfx map PARTIALLY VERIFIED
return QIcon(":/icons/icons/Icon_FXMap.png");
} else if (cleanedType == "LIGHT DEF") { // light_def PARTIALLY VERIFIED
return QIcon(":/icons/icons/Icon_LightDef.png");
} else if (cleanedType == "FONT") { // font PARTIALLY VERIFIED
return QIcon(":/icons/icons/Icon_Font.png");
} else if (cleanedType == "MODEL") { // xmodel PARTIALLY VERIFIED
return QIcon(":/icons/icons/Icon_Model.png");
} else if (cleanedType == "D3DBSP") { // d3dbsp PARTIALLY VERIFIED
return QIcon(":/icons/icons/Icon_BSP.png");
} else if (cleanedType == "IMAGE") { // image PARTIALLY VERIFIED
return QIcon(":/icons/icons/Icon_Image.png");
} else if (cleanedType == "GAME MAP SP") { // game map sp PARTIALLY VERIFIED
return QIcon(":/icons/icons/Icon_GameMapSp.png");
} else if (cleanedType == "COL MAP SP") { // col map sp PARTIALLY VERIFIED
return QIcon(":/icons/icons/Icon_ColMapSp.png");
} else if (cleanedType == "PHYS PRESET") { // col map sp PARTIALLY VERIFIED
return QIcon(":/icons/icons/Icon_PhysPreset.png");
} else if (cleanedType == "DESTRUCTIBLE") { // col map sp PARTIALLY VERIFIED
return QIcon(":/icons/icons/Icon_Destructible.png");
}
return QIcon();
}
bool ZoneFile::SaveZoneFile(const QString aZoneFilePath) {
QFile zoneFile(aZoneFilePath);
if (!zoneFile.open(QIODevice::WriteOnly)) {
LogManager::instance().addEntry("Failed to write zone file! " + zoneFile.errorString());
return false;
}
zoneFile.write(GetBinaryData());
zoneFile.close();
return true;
}
2025-02-19 19:17:31 -05:00
QString ZoneFile::GetStem() {
return mStem;
2025-02-08 19:58:54 -05:00
}
quint32 ZoneFile::GetSize() {
2025-02-19 19:17:31 -05:00
return mSize;
2025-02-08 19:58:54 -05:00
}
quint32 ZoneFile::GetTagCount() {
2025-02-19 19:17:31 -05:00
return mTagCount;
2025-02-08 19:58:54 -05:00
}
QStringList ZoneFile::GetTags() {
2025-02-19 19:17:31 -05:00
return mTags;
2025-02-08 19:58:54 -05:00
}
quint32 ZoneFile::GetRecordCount() {
2025-02-19 19:17:31 -05:00
return mRecordCount;
2025-02-08 19:58:54 -05:00
}
QStringList ZoneFile::GetRecords() {
2025-02-19 19:17:31 -05:00
return mRecords;
2025-02-08 19:58:54 -05:00
}
AssetMap ZoneFile::GetAssetMap() {
2025-02-19 19:17:31 -05:00
return mAssetMap;
2025-02-08 19:58:54 -05:00
}
2025-02-19 19:17:31 -05:00
void ZoneFile::SetStem(const QString aStem) {
mStem = aStem;
2025-02-08 19:58:54 -05:00
}
2025-02-19 19:17:31 -05:00
void ZoneFile::SetSize(quint32 aSize) {
mSize = aSize;
2025-02-08 19:58:54 -05:00
}
2025-02-19 19:17:31 -05:00
void ZoneFile::SetTagCount(quint32 aTagCount) {
mTagCount = aTagCount;
2025-02-08 19:58:54 -05:00
}
2025-02-19 19:17:31 -05:00
void ZoneFile::SetTags(const QStringList aTags) {
mTags = aTags;
2025-02-08 19:58:54 -05:00
}
2025-02-19 19:17:31 -05:00
void ZoneFile::SetRecordCount(quint32 aRecordCount) {
mRecordCount = aRecordCount;
2025-02-08 19:58:54 -05:00
}
2025-02-19 19:17:31 -05:00
void ZoneFile::SetRecords(const QStringList aRecords) {
mRecords = aRecords;
2025-02-08 19:58:54 -05:00
}
2025-02-19 19:17:31 -05:00
void ZoneFile::SetAssetMap(const AssetMap aAssetMap) {
mAssetMap = aAssetMap;
2025-02-08 19:58:54 -05:00
}