From 1b6aeefb49661b41fe7d2cc92770479d4286a755 Mon Sep 17 00:00:00 2001 From: = Date: Fri, 4 Apr 2025 20:40:45 -0400 Subject: [PATCH] update zonefile logic. --- libs/zonefile/zonefile.cpp | 60 ++++++++++++++++++++++++++++++++++++++ libs/zonefile/zonefile.h | 10 +++++-- libs/zonefile/zonefile.pro | 2 +- 3 files changed, 69 insertions(+), 3 deletions(-) diff --git a/libs/zonefile/zonefile.cpp b/libs/zonefile/zonefile.cpp index 2bdb9ca..ac9aae8 100644 --- a/libs/zonefile/zonefile.cpp +++ b/libs/zonefile/zonefile.cpp @@ -1,5 +1,6 @@ #include "zonefile.h" #include "utils.h" +#include "logmanager.h" #include #include @@ -43,6 +44,65 @@ ZoneFile &ZoneFile::operator=(const ZoneFile &other) { return *this; } +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; +} + QString ZoneFile::GetStem() { return mStem; } diff --git a/libs/zonefile/zonefile.h b/libs/zonefile/zonefile.h index c4cc15c..1e08020 100644 --- a/libs/zonefile/zonefile.h +++ b/libs/zonefile/zonefile.h @@ -2,6 +2,7 @@ #define ZONEFILE_H #include "asset_structs.h" +#include "qicon.h" #include @@ -13,9 +14,14 @@ public: ZoneFile(const ZoneFile &aZoneFile); ZoneFile &operator=(const ZoneFile &other); - virtual bool Load(const QByteArray aFileData, const QString aFileStem, FF_PLATFORM platform = FF_PLATFORM_NONE) = 0; + virtual bool Load(const QByteArray aFileData, FF_PLATFORM platform = FF_PLATFORM_NONE) = 0; virtual QString AssetTypeToString(const QString aAssetType) = 0; + QIcon AssetStrToIcon(const QString aAssetStr); + + virtual QByteArray GetBinaryData() = 0; + virtual bool SaveZoneFile(const QString aZoneFilePath); + QString GetStem(); quint32 GetSize(); quint32 GetTagCount(); @@ -33,7 +39,7 @@ public: void SetAssetMap(const AssetMap aAssetMap); private slots: - virtual void pParseZoneHeader(QDataStream *aZoneFileStream) = 0; + virtual void pParseZoneHeader(QDataStream *aZoneFileStream, FF_PLATFORM aPlatform) = 0; virtual quint32 pParseZoneSize(QDataStream *aZoneFileStream) = 0; virtual void pParseZoneUnknownsA(QDataStream *aZoneFileStream) = 0; virtual quint32 pParseZoneTagCount(QDataStream *aZoneFileStream) = 0; diff --git a/libs/zonefile/zonefile.pro b/libs/zonefile/zonefile.pro index 9ce3ac5..ec85195 100644 --- a/libs/zonefile/zonefile.pro +++ b/libs/zonefile/zonefile.pro @@ -1,6 +1,6 @@ QT += core widgets TEMPLATE = lib -CONFIG += staticlib c++17 debug +CONFIG += staticlib c++17 SOURCES += \ zonefile.cpp \