Uplifted tf outta the ui
36
Data.qrc
@ -1,36 +0,0 @@
|
||||
<RCC>
|
||||
<qresource prefix="/obj">
|
||||
<file>data/obj/defaultactor_LOD0.bin</file>
|
||||
<file>data/obj/defaultactor_LOD0.cast</file>
|
||||
<file>data/obj/defaultactor_LOD0.gltf</file>
|
||||
<file>data/obj/defaultactor_LOD0.ma</file>
|
||||
<file>data/obj/defaultactor_LOD0.mesh.ascii</file>
|
||||
<file>data/obj/defaultactor_LOD0.obj</file>
|
||||
<file>data/obj/defaultactor_LOD0.semodel</file>
|
||||
<file>data/obj/defaultactor_LOD0.smd</file>
|
||||
<file>data/obj/defaultactor_LOD0.XMODEL_BIN</file>
|
||||
<file>data/obj/defaultactor_LOD0.XMODEL_EXPORT</file>
|
||||
<file>data/obj/defaultactor_LOD0_BIND.mel</file>
|
||||
<file>data/obj/defaultactor_LOD0_cosmetics.mel</file>
|
||||
<file>data/obj/mtl_body_default_character.mtl</file>
|
||||
<file>data/obj/mtl_body_default_character_images.txt</file>
|
||||
<file>data/obj/diffusemap.png</file>
|
||||
<file>data/obj/normalmap.png</file>
|
||||
</qresource>
|
||||
<qresource prefix="/d3dbsp">
|
||||
<file>data/d3dbsp/asset_viewer.d3dbsp</file>
|
||||
<file>data/d3dbsp/barebones.d3dbsp</file>
|
||||
</qresource>
|
||||
<qresource prefix="/images">
|
||||
<file>data/images/XPlor.png</file>
|
||||
<file>data/images/copy.svg</file>
|
||||
<file>data/images/cut.svg</file>
|
||||
<file>data/images/new_file.svg</file>
|
||||
<file>data/images/open_file.svg</file>
|
||||
<file>data/images/open_folder.svg</file>
|
||||
<file>data/images/paste.svg</file>
|
||||
<file>data/images/refresh.svg</file>
|
||||
<file>data/images/save.svg</file>
|
||||
<file>data/images/multiple.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
13
DevILSDK/include/IL/DevIL.i
Normal file
@ -0,0 +1,13 @@
|
||||
%module DevIL
|
||||
%{
|
||||
#include "il.h"
|
||||
#include "ilu.h"
|
||||
#include "ilut.h"
|
||||
//#include "ilu_region.h"
|
||||
%}
|
||||
|
||||
%include "il.h"
|
||||
%include "ilu.h"
|
||||
%include "ilut.h"
|
||||
//%include "ilu_region.h"
|
||||
|
||||
51
DevILSDK/include/IL/build-lua
Normal file
@ -0,0 +1,51 @@
|
||||
IL_INCLUDE_PATH="/usr/include"
|
||||
IL_LIB_PATH="/usr/lib"
|
||||
LUA_INCLUDE_PATH="/usr/include/lua5.1"
|
||||
LUA_LIB_PATH="/usr/lib"
|
||||
OSX=no
|
||||
|
||||
echo "Building the lua binding!"
|
||||
|
||||
export SWIG_FEATURES="-I$IL_INCLUDE_PATH"
|
||||
swig -lua DevIL.i
|
||||
if [ $? -ne 0 ] ; then
|
||||
echo "swig Failed to build the lua interface"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
compile() {
|
||||
gcc luadevil.c "$1" -o luadevil "-L$LUA_LIB_PATH" "-I$LUA_INCLUDE_PATH" "-I$IL_LIB_PATH" -lIL -lILU -lILUT -llua5.1 &>/dev/null
|
||||
err=$?
|
||||
if [ "$OSX" = "no" ] ; then
|
||||
gcc -shared "$1" -o DevIL.so "-L$LUA_LIB_PATH" "-I$LUA_INCLUDE_PATH" "-I$IL_LIB_PATH" -lIL -lILU -lILUT &>/dev/null
|
||||
else
|
||||
gcc -bundle -undefined dynamic_lookup "$1" -o DevIL.so "-L$LUA_LIB_PATH" "-I$LUA_INCLUDE_PATH" "-I$IL_LIB_PATH" -lIL -lILU -lILUT &>/dev/null
|
||||
fi
|
||||
return $err
|
||||
}
|
||||
|
||||
compile DevIL_wrap.c
|
||||
if [ $? -ne 0 ] ; then
|
||||
echo 'Failed compilation'
|
||||
echo 'On some platform the file malloc.h is not present and produces a compilation error'
|
||||
echo -n 'it can be removed safely, try [y/n] ? '
|
||||
while read i ; do
|
||||
if [ "$i" = "y" ] ; then
|
||||
sed 's/\#include\ \<malloc\.h\>//' < DevIL_wrap.c > DevIL_wrap.mod.c
|
||||
compile "DevIL_wrap.mod.c"
|
||||
if [ $? -ne 0 ] ; then
|
||||
echo 'still failing...'
|
||||
exit 2
|
||||
fi
|
||||
exit 0
|
||||
elif [ "$i" = "n" ] ; then
|
||||
echo 'ok, failing...'
|
||||
exit 3
|
||||
else
|
||||
echo 'Unknown command [y/n] ? '
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
echo "ok!"
|
||||
exit 0
|
||||
17
DevILSDK/include/IL/build-python
Normal file
@ -0,0 +1,17 @@
|
||||
#! /bin/bash
|
||||
|
||||
IL_INCLUDE_PATH="/usr/local/include"
|
||||
IL_LIB_PATH="/usr/local/lib"
|
||||
PYTHON_INCLUDE_PATH="/usr/include/python2.5"
|
||||
|
||||
swig "-I$IL_INCLUDE_PATH" -python -interface DevIL DevIL.i
|
||||
if [ $? -ne 0 ] ; then
|
||||
echo Error while building the swig interface
|
||||
exit 1
|
||||
fi
|
||||
|
||||
gcc -shared "-I$IL_INCLUDE_PATH" "-I$PYTHON_INCLUDE_PATH" "-L$IL_LIB_PATH" -lIL -lILU -lILUT DevIL_wrap.c -o DevIL.so
|
||||
if [ $? -ne 0 ] ; then
|
||||
echo Error while compiling the python module
|
||||
fi
|
||||
echo "DevIL.py and DevIL.so are ready"
|
||||
79
DevILSDK/include/IL/config.h.win
Normal file
@ -0,0 +1,79 @@
|
||||
#ifndef __CONFIG_H__
|
||||
#define __CONFIG_H__
|
||||
|
||||
#define IL_USE_PRAGMA_LIBS // Links to only the libraries that are requested.
|
||||
#define IL_INLINE_ASM 1 // Define if you can support at least some ASM
|
||||
|
||||
// Supported images formats (IL)
|
||||
|
||||
// #define IL_NO_BLP
|
||||
// #define IL_NO_BMP
|
||||
// #define IL_NO_CUT
|
||||
// #define IL_NO_CHEAD
|
||||
// #define IL_NO_DCX
|
||||
// #define IL_NO_DDS
|
||||
// #define IL_NO_DICOM
|
||||
// #define IL_NO_DOOM
|
||||
// #define IL_NO_EXR
|
||||
// #define IL_NO_FITS
|
||||
// #define IL_NO_FTX
|
||||
// #define IL_NO_GIF
|
||||
// #define IL_NO_HDR
|
||||
// #define IL_NO_ICO
|
||||
// #define IL_NO_ICNS
|
||||
// #define IL_NO_IWI
|
||||
// #define IL_NO_JP2
|
||||
// #define IL_NO_JPG
|
||||
// #define IL_NO_LCMS
|
||||
// #define IL_NO_LIF
|
||||
// #define IL_NO_MDL
|
||||
// #define IL_NO_MNG
|
||||
// #define IL_NO_PCD
|
||||
// #define IL_NO_PCX
|
||||
// #define IL_NO_PIC
|
||||
// #define IL_NO_PIX
|
||||
// #define IL_NO_PNG
|
||||
// #define IL_NO_PNM
|
||||
// #define IL_NO_PSD
|
||||
// #define IL_NO_PSP
|
||||
// #define IL_NO_PXR
|
||||
// #define IL_NO_RAW
|
||||
// #define IL_NO_ROT
|
||||
// #define IL_NO_SGI
|
||||
// #define IL_NO_SUN
|
||||
// #define IL_NO_TGA
|
||||
// #define IL_NO_TIF
|
||||
// #define IL_NO_TPL
|
||||
// #define IL_NO_WAL
|
||||
// #define IL_NO_WDP
|
||||
// #define IL_NO_XPM
|
||||
|
||||
#define IL_USE_JPEGLIB_UNMODIFIED 1
|
||||
#define IL_USE_DXTC_NVIDIA
|
||||
#define IL_USE_DXTC_SQUISH
|
||||
|
||||
//#define IL_NO_GAMES
|
||||
|
||||
/* Supported api (ilut) */
|
||||
|
||||
|
||||
//
|
||||
// sorry just
|
||||
// cant get this one to work under windows
|
||||
// have disabled for the now
|
||||
//
|
||||
// will look at it some more later
|
||||
//
|
||||
// Kriss
|
||||
//
|
||||
#undef ILUT_USE_ALLEGRO
|
||||
|
||||
#undef ILUT_USE_DIRECTX8
|
||||
#define ILUT_USE_DIRECTX9
|
||||
#define ILUT_USE_DIRECTX10
|
||||
#define ILUT_USE_OPENGL
|
||||
#define ILUT_USE_SDL
|
||||
#define ILUT_USE_WIN32
|
||||
|
||||
|
||||
#endif /* __CONFIG_H__ */
|
||||
952
DevILSDK/include/IL/devil_cpp_wrapper.hpp
Normal file
@ -0,0 +1,952 @@
|
||||
#ifndef DEVIL_CPP_WRAPPER_HPP
|
||||
#define DEVIL_CPP_WRAPPER_HPP
|
||||
|
||||
#include <IL/ilut.h> // Probably only have to #include this one
|
||||
|
||||
class ilImage
|
||||
{
|
||||
public:
|
||||
ilImage();
|
||||
ilImage(ILconst_string);
|
||||
ilImage(const ilImage &);
|
||||
virtual ~ilImage();
|
||||
|
||||
ILboolean Load(ILconst_string);
|
||||
ILboolean Load(ILconst_string, ILenum);
|
||||
ILboolean Save(ILconst_string);
|
||||
ILboolean Save(ILconst_string, ILenum);
|
||||
|
||||
// ImageLib functions
|
||||
ILboolean ActiveImage(ILuint);
|
||||
ILboolean ActiveLayer(ILuint);
|
||||
ILboolean ActiveMipmap(ILuint);
|
||||
ILboolean Clear(void);
|
||||
void ClearColour(ILclampf, ILclampf, ILclampf, ILclampf);
|
||||
ILboolean Convert(ILenum);
|
||||
ILboolean Copy(ILuint);
|
||||
ILboolean Default(void);
|
||||
ILboolean Flip(void);
|
||||
ILboolean SwapColours(void);
|
||||
ILboolean Resize(ILuint, ILuint, ILuint);
|
||||
ILboolean TexImage(ILuint, ILuint, ILuint, ILubyte, ILenum, ILenum, void*);
|
||||
|
||||
// Image handling
|
||||
void Bind(void) const;
|
||||
void Bind(ILuint);
|
||||
void Close(void) { this->Delete(); }
|
||||
void Delete(void);
|
||||
void iGenBind();
|
||||
ILenum PaletteAlphaIndex();
|
||||
|
||||
// Image characteristics
|
||||
ILuint Width(void);
|
||||
ILuint Height(void);
|
||||
ILuint Depth(void);
|
||||
ILubyte Bpp(void);
|
||||
ILubyte Bitpp(void);
|
||||
ILenum PaletteType(void);
|
||||
ILenum Format(void);
|
||||
ILenum Type(void);
|
||||
ILuint NumImages(void);
|
||||
ILuint NumMipmaps(void);
|
||||
ILuint GetId(void) const;
|
||||
ILenum GetOrigin(void);
|
||||
ILubyte *GetData(void);
|
||||
ILubyte *GetPalette(void);
|
||||
|
||||
// Rendering
|
||||
ILuint BindImage(void);
|
||||
ILuint BindImage(ILenum);
|
||||
|
||||
// Operators
|
||||
ilImage& operator = (ILuint);
|
||||
ilImage& operator = (const ilImage &);
|
||||
|
||||
protected:
|
||||
ILuint Id;
|
||||
|
||||
private:
|
||||
static int ilStartUp();
|
||||
static ILboolean ilStartedUp;
|
||||
};
|
||||
|
||||
// ensure that init is called exactly once
|
||||
int ilImage::ilStartUp()
|
||||
{
|
||||
ilInit();
|
||||
iluInit();
|
||||
//ilutInit();
|
||||
return true;
|
||||
}
|
||||
ILboolean ilImage::ilStartedUp = ilStartUp();
|
||||
|
||||
class ilFilters
|
||||
{
|
||||
public:
|
||||
static ILboolean Alienify(ilImage &);
|
||||
static ILboolean BlurAvg(ilImage &, ILuint Iter);
|
||||
static ILboolean BlurGaussian(ilImage &, ILuint Iter);
|
||||
static ILboolean Contrast(ilImage &, ILfloat Contrast);
|
||||
static ILboolean EdgeDetectE(ilImage &);
|
||||
static ILboolean EdgeDetectP(ilImage &);
|
||||
static ILboolean EdgeDetectS(ilImage &);
|
||||
static ILboolean Emboss(ilImage &);
|
||||
static ILboolean Gamma(ilImage &, ILfloat Gamma);
|
||||
static ILboolean Negative(ilImage &);
|
||||
static ILboolean Noisify(ilImage &, ILubyte Factor);
|
||||
static ILboolean Pixelize(ilImage &, ILuint PixSize);
|
||||
static ILboolean Saturate(ilImage &, ILfloat Saturation);
|
||||
static ILboolean Saturate(ilImage &, ILfloat r, ILfloat g, ILfloat b, ILfloat Saturation);
|
||||
static ILboolean ScaleColours(ilImage &, ILfloat r, ILfloat g, ILfloat b);
|
||||
static ILboolean Sharpen(ilImage &, ILfloat Factor, ILuint Iter);
|
||||
};
|
||||
|
||||
#ifdef ILUT_USE_OPENGL
|
||||
class ilOgl
|
||||
{
|
||||
public:
|
||||
static void Init(void);
|
||||
static GLuint BindTex(ilImage &);
|
||||
static ILboolean Upload(ilImage &, ILuint);
|
||||
static GLuint Mipmap(ilImage &);
|
||||
static ILboolean Screen(void);
|
||||
static ILboolean Screenie(void);
|
||||
};
|
||||
#endif//ILUT_USE_OPENGL
|
||||
|
||||
|
||||
#ifdef ILUT_USE_ALLEGRO
|
||||
class ilAlleg
|
||||
{
|
||||
public:
|
||||
static void Init(void);
|
||||
static BITMAP *Convert(ilImage &);
|
||||
};
|
||||
#endif//ILUT_USE_ALLEGRO
|
||||
|
||||
|
||||
#ifdef ILUT_USE_WIN32
|
||||
class ilWin32
|
||||
{
|
||||
public:
|
||||
static void Init(void);
|
||||
static HBITMAP Convert(ilImage &);
|
||||
static ILboolean GetClipboard(ilImage &);
|
||||
static void GetInfo(ilImage &, BITMAPINFO *Info);
|
||||
static ILubyte *GetPadData(ilImage &);
|
||||
static HPALETTE GetPal(ilImage &);
|
||||
static ILboolean GetResource(ilImage &, HINSTANCE hInst, ILint ID, char *ResourceType);
|
||||
static ILboolean GetResource(ilImage &, HINSTANCE hInst, ILint ID, char *ResourceType, ILenum Type);
|
||||
static ILboolean SetClipboard(ilImage &);
|
||||
};
|
||||
#endif//ILUT_USE_WIN32
|
||||
|
||||
|
||||
class ilValidate
|
||||
{
|
||||
public:
|
||||
static ILboolean Valid(ILenum, ILconst_string);
|
||||
static ILboolean Valid(ILenum, FILE *);
|
||||
static ILboolean Valid(ILenum, void *, ILuint);
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
class ilState
|
||||
{
|
||||
public:
|
||||
static ILboolean Disable(ILenum);
|
||||
static ILboolean Enable(ILenum);
|
||||
static void Get(ILenum, ILboolean &);
|
||||
static void Get(ILenum, ILint &);
|
||||
static ILboolean GetBool(ILenum);
|
||||
static ILint GetInt(ILenum);
|
||||
static const char *GetString(ILenum);
|
||||
static ILboolean IsDisabled(ILenum);
|
||||
static ILboolean IsEnabled(ILenum);
|
||||
static ILboolean Origin(ILenum);
|
||||
static void Pop(void);
|
||||
static void Push(ILuint);
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
|
||||
class ilError
|
||||
{
|
||||
public:
|
||||
static void Check(void (*Callback)(const char*));
|
||||
static void Check(void (*Callback)(ILenum));
|
||||
static ILenum Get(void);
|
||||
static const char *String(void);
|
||||
static const char *String(ILenum);
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// ILIMAGE
|
||||
//
|
||||
ilImage::ilImage()
|
||||
{
|
||||
this->Id = 0;
|
||||
//this->iStartUp(); // This was commented out, but it needs to be somewhere...
|
||||
this->iGenBind();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
ilImage::ilImage(ILconst_string FileName)
|
||||
{
|
||||
this->Id = 0;
|
||||
//this->iStartUp(); // This was commented out, but it needs to be somewhere...
|
||||
this->iGenBind();
|
||||
ilLoadImage(FileName);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
ilImage::ilImage(const ilImage &Image)
|
||||
{
|
||||
this->Id = 0;
|
||||
// this->iStartUp();
|
||||
this->iGenBind();
|
||||
*this = Image;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
ilImage::~ilImage()
|
||||
{
|
||||
if (this->Id)
|
||||
ilDeleteImages(1, &this->Id);
|
||||
this->Id = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
ILboolean ilImage::Load(ILconst_string FileName)
|
||||
{
|
||||
this->iGenBind();
|
||||
return ilLoadImage(FileName);
|
||||
}
|
||||
|
||||
|
||||
ILboolean ilImage::Load(ILconst_string FileName, ILenum Type)
|
||||
{
|
||||
this->iGenBind();
|
||||
return ilLoad(Type, FileName);
|
||||
}
|
||||
|
||||
|
||||
ILboolean ilImage::Save(ILconst_string FileName)
|
||||
{
|
||||
this->iGenBind();
|
||||
return ilSaveImage(FileName);
|
||||
}
|
||||
|
||||
|
||||
ILboolean ilImage::Save(ILconst_string FileName, ILenum Type)
|
||||
{
|
||||
this->iGenBind();
|
||||
return ilSave(Type, FileName);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
// ImageLib functions
|
||||
//
|
||||
ILboolean ilImage::ActiveImage(ILuint Number)
|
||||
{
|
||||
if (this->Id) {
|
||||
this->Bind();
|
||||
return ilActiveImage(Number);
|
||||
}
|
||||
return IL_FALSE;
|
||||
}
|
||||
|
||||
|
||||
ILboolean ilImage::ActiveLayer(ILuint Number)
|
||||
{
|
||||
if (this->Id) {
|
||||
this->Bind();
|
||||
return ilActiveLayer(Number);
|
||||
}
|
||||
return IL_FALSE;
|
||||
}
|
||||
|
||||
|
||||
ILboolean ilImage::ActiveMipmap(ILuint Number)
|
||||
{
|
||||
if (this->Id) {
|
||||
this->Bind();
|
||||
return ilActiveMipmap(Number);
|
||||
}
|
||||
return IL_FALSE;
|
||||
}
|
||||
|
||||
|
||||
ILboolean ilImage::Clear()
|
||||
{
|
||||
if (this->Id) {
|
||||
this->Bind();
|
||||
return ilClearImage();
|
||||
}
|
||||
return IL_FALSE;
|
||||
}
|
||||
|
||||
|
||||
void ilImage::ClearColour(ILclampf Red, ILclampf Green, ILclampf Blue, ILclampf Alpha)
|
||||
{
|
||||
ilClearColour(Red, Green, Blue, Alpha);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
ILboolean ilImage::Convert(ILenum NewFormat)
|
||||
{
|
||||
if (this->Id) {
|
||||
this->Bind();
|
||||
return ilConvertImage(NewFormat, IL_UNSIGNED_BYTE);
|
||||
}
|
||||
return IL_FALSE;
|
||||
}
|
||||
|
||||
|
||||
ILboolean ilImage::Copy(ILuint Src)
|
||||
{
|
||||
if (this->Id) {
|
||||
this->Bind();
|
||||
return ilCopyImage(Src);
|
||||
}
|
||||
return IL_FALSE;
|
||||
}
|
||||
|
||||
|
||||
ILboolean ilImage::Default()
|
||||
{
|
||||
if (this->Id) {
|
||||
this->Bind();
|
||||
return ilDefaultImage();
|
||||
}
|
||||
return IL_FALSE;
|
||||
}
|
||||
|
||||
|
||||
ILboolean ilImage::Flip()
|
||||
{
|
||||
if (this->Id) {
|
||||
this->Bind();
|
||||
return iluFlipImage();
|
||||
}
|
||||
return IL_FALSE;
|
||||
}
|
||||
|
||||
|
||||
ILboolean ilImage::SwapColours()
|
||||
{
|
||||
if (this->Id) {
|
||||
this->Bind();
|
||||
return iluSwapColours();
|
||||
}
|
||||
return IL_FALSE;
|
||||
}
|
||||
|
||||
|
||||
ILboolean ilImage::Resize(ILuint Width, ILuint Height, ILuint Depth)
|
||||
{
|
||||
if (this->Id) {
|
||||
this->Bind();
|
||||
return iluScale(Width, Height, Depth);
|
||||
}
|
||||
return IL_FALSE;
|
||||
}
|
||||
|
||||
|
||||
ILboolean ilImage::TexImage(ILuint Width, ILuint Height, ILuint Depth, ILubyte Bpp, ILenum Format, ILenum Type, void *Data)
|
||||
{
|
||||
if (this->Id) {
|
||||
this->Bind();
|
||||
return ilTexImage(Width, Height, Depth, Bpp, Format, Type, Data);
|
||||
}
|
||||
return IL_FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Image handling
|
||||
//
|
||||
void ilImage::Bind() const
|
||||
{
|
||||
if (this->Id)
|
||||
ilBindImage(this->Id);
|
||||
return;
|
||||
}
|
||||
|
||||
// Note: Behaviour may be changed!
|
||||
void ilImage::Bind(ILuint Image)
|
||||
{
|
||||
if (this->Id == Image)
|
||||
return;
|
||||
this->Delete(); // Should we delete it?
|
||||
this->Id = Image;
|
||||
ilBindImage(this->Id);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void ilImage::Delete()
|
||||
{
|
||||
if (this->Id == 0)
|
||||
return;
|
||||
ilDeleteImages(1, &this->Id);
|
||||
this->Id = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Image characteristics
|
||||
//
|
||||
ILuint ilImage::Width()
|
||||
{
|
||||
if (this->Id) {
|
||||
this->Bind();
|
||||
return ilGetInteger(IL_IMAGE_WIDTH);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
ILuint ilImage::Height()
|
||||
{
|
||||
if (this->Id) {
|
||||
this->Bind();
|
||||
return ilGetInteger(IL_IMAGE_HEIGHT);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
ILuint ilImage::Depth()
|
||||
{
|
||||
if (this->Id) {
|
||||
this->Bind();
|
||||
return ilGetInteger(IL_IMAGE_DEPTH);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
ILubyte ilImage::Bpp()
|
||||
{
|
||||
if (this->Id) {
|
||||
this->Bind();
|
||||
return ilGetInteger(IL_IMAGE_BYTES_PER_PIXEL);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
ILubyte ilImage::Bitpp()
|
||||
{
|
||||
if (this->Id) {
|
||||
this->Bind();
|
||||
return ilGetInteger(IL_IMAGE_BITS_PER_PIXEL);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
ILenum ilImage::Format()
|
||||
{
|
||||
if (this->Id) {
|
||||
this->Bind();
|
||||
return ilGetInteger(IL_IMAGE_FORMAT);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
ILenum ilImage::PaletteType()
|
||||
{
|
||||
if (this->Id) {
|
||||
this->Bind();
|
||||
return ilGetInteger(IL_PALETTE_TYPE);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
ILenum ilImage::PaletteAlphaIndex()
|
||||
{
|
||||
if (this->Id) {
|
||||
this->Bind();
|
||||
return ilGetInteger(IL_PNG_ALPHA_INDEX);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
ILenum ilImage::Type()
|
||||
{
|
||||
if (this->Id) {
|
||||
this->Bind();
|
||||
return ilGetInteger(IL_IMAGE_TYPE);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
ILenum ilImage::NumImages()
|
||||
{
|
||||
if (this->Id) {
|
||||
this->Bind();
|
||||
return ilGetInteger(IL_NUM_IMAGES);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
ILenum ilImage::NumMipmaps()
|
||||
{
|
||||
if (this->Id) {
|
||||
this->Bind();
|
||||
return ilGetInteger(IL_NUM_MIPMAPS);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
ILuint ilImage::GetId() const
|
||||
{
|
||||
return this->Id;
|
||||
}
|
||||
|
||||
ILenum ilImage::GetOrigin(void)
|
||||
{
|
||||
ILinfo Info;
|
||||
|
||||
if (this->Id) {
|
||||
this->Bind();
|
||||
iluGetImageInfo(&Info);
|
||||
return Info.Origin;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
ILubyte* ilImage::GetData()
|
||||
{
|
||||
if (this->Id) {
|
||||
this->Bind();
|
||||
return ilGetData();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
ILubyte* ilImage::GetPalette()
|
||||
{
|
||||
if (this->Id) {
|
||||
this->Bind();
|
||||
return ilGetPalette();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Private members
|
||||
//
|
||||
/*void ilImage::iStartUp()
|
||||
{
|
||||
ilInit();
|
||||
iluInit();
|
||||
ilutInit();
|
||||
return;
|
||||
}*/
|
||||
|
||||
void ilImage::iGenBind()
|
||||
{
|
||||
if (this->Id == 0) {
|
||||
ilGenImages(1, &this->Id);
|
||||
}
|
||||
ilBindImage(this->Id);
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Operators
|
||||
//
|
||||
ilImage& ilImage::operator = (ILuint Image)
|
||||
{
|
||||
if (this->Id == 0)
|
||||
this->Id = Image;
|
||||
else {
|
||||
this->Bind();
|
||||
ilCopyImage(Image);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
ilImage& ilImage::operator = (const ilImage &Image)
|
||||
{
|
||||
if (Id == 0)
|
||||
Id = Image.GetId();
|
||||
else {
|
||||
Bind();
|
||||
ilCopyImage(Image.GetId());
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//
|
||||
// ILFILTERS
|
||||
//
|
||||
ILboolean ilFilters::Alienify(ilImage &Image)
|
||||
{
|
||||
Image.Bind();
|
||||
return iluAlienify();
|
||||
}
|
||||
|
||||
ILboolean ilFilters::BlurAvg(ilImage &Image, ILuint Iter)
|
||||
{
|
||||
Image.Bind();
|
||||
return iluBlurAvg(Iter);
|
||||
}
|
||||
|
||||
ILboolean ilFilters::BlurGaussian(ilImage &Image, ILuint Iter)
|
||||
{
|
||||
Image.Bind();
|
||||
return iluBlurGaussian(Iter);
|
||||
}
|
||||
|
||||
ILboolean ilFilters::Contrast(ilImage &Image, ILfloat Contrast)
|
||||
{
|
||||
Image.Bind();
|
||||
return iluContrast(Contrast);
|
||||
}
|
||||
|
||||
ILboolean ilFilters::EdgeDetectE(ilImage &Image)
|
||||
{
|
||||
Image.Bind();
|
||||
return iluEdgeDetectP();
|
||||
}
|
||||
|
||||
ILboolean ilFilters::EdgeDetectP(ilImage &Image)
|
||||
{
|
||||
Image.Bind();
|
||||
return iluEdgeDetectP();
|
||||
}
|
||||
|
||||
ILboolean ilFilters::EdgeDetectS(ilImage &Image)
|
||||
{
|
||||
Image.Bind();
|
||||
return iluEdgeDetectS();
|
||||
}
|
||||
|
||||
ILboolean ilFilters::Emboss(ilImage &Image)
|
||||
{
|
||||
Image.Bind();
|
||||
return iluEmboss();
|
||||
}
|
||||
|
||||
ILboolean ilFilters::Gamma(ilImage &Image, ILfloat Gamma)
|
||||
{
|
||||
Image.Bind();
|
||||
return iluGammaCorrect(Gamma);
|
||||
}
|
||||
|
||||
ILboolean ilFilters::Negative(ilImage &Image)
|
||||
{
|
||||
Image.Bind();
|
||||
return iluNegative();
|
||||
}
|
||||
|
||||
ILboolean ilFilters::Noisify(ilImage &Image, ILubyte Factor)
|
||||
{
|
||||
Image.Bind();
|
||||
return iluNoisify(Factor);
|
||||
}
|
||||
|
||||
ILboolean ilFilters::Pixelize(ilImage &Image, ILuint PixSize)
|
||||
{
|
||||
Image.Bind();
|
||||
return iluPixelize(PixSize);
|
||||
}
|
||||
|
||||
ILboolean ilFilters::Saturate(ilImage &Image, ILfloat Saturation)
|
||||
{
|
||||
Image.Bind();
|
||||
return iluSaturate1f(Saturation);
|
||||
}
|
||||
|
||||
ILboolean ilFilters::Saturate(ilImage &Image, ILfloat r, ILfloat g, ILfloat b, ILfloat Saturation)
|
||||
{
|
||||
Image.Bind();
|
||||
return iluSaturate4f(r, g, b, Saturation);
|
||||
}
|
||||
|
||||
ILboolean ilFilters::ScaleColours(ilImage &Image, ILfloat r, ILfloat g, ILfloat b)
|
||||
{
|
||||
Image.Bind();
|
||||
return iluScaleColours(r, g, b);
|
||||
}
|
||||
|
||||
|
||||
ILboolean ilFilters::Sharpen(ilImage &Image, ILfloat Factor, ILuint Iter)
|
||||
{
|
||||
Image.Bind();
|
||||
return iluSharpen(Factor, Iter);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// ILOPENGL
|
||||
//
|
||||
#ifdef ILUT_USE_OPENGL
|
||||
void ilOgl::Init()
|
||||
{
|
||||
ilutRenderer(ILUT_OPENGL);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
GLuint ilOgl::BindTex(ilImage &Image)
|
||||
{
|
||||
Image.Bind();
|
||||
return ilutGLBindTexImage();
|
||||
}
|
||||
|
||||
ILboolean ilOgl::Upload(ilImage &Image, ILuint Level)
|
||||
{
|
||||
Image.Bind();
|
||||
return ilutGLTexImage(Level);
|
||||
}
|
||||
|
||||
|
||||
GLuint ilOgl::Mipmap(ilImage &Image)
|
||||
{
|
||||
Image.Bind();
|
||||
return ilutGLBuildMipmaps();
|
||||
}
|
||||
|
||||
ILboolean ilOgl::Screen()
|
||||
{
|
||||
return ilutGLScreen();
|
||||
}
|
||||
|
||||
|
||||
ILboolean ilOgl::Screenie()
|
||||
{
|
||||
return ilutGLScreenie();
|
||||
}
|
||||
#endif//ILUT_USE_OPENGL
|
||||
|
||||
//
|
||||
// ILALLEGRO
|
||||
//
|
||||
#ifdef ILUT_USE_ALLEGRO
|
||||
void ilAlleg::Init()
|
||||
{
|
||||
ilutRenderer(IL_ALLEGRO);
|
||||
return;
|
||||
}
|
||||
|
||||
BITMAP *ilAlleg::Convert(ilImage &Image, PALETTE Pal)
|
||||
{
|
||||
Image.Bind();
|
||||
return ilutConvertToAlleg(Pal);
|
||||
}
|
||||
#endif//ILUT_USE_ALLEGRO
|
||||
|
||||
//
|
||||
// ILWIN32
|
||||
//
|
||||
#ifdef ILUT_USE_WIN32
|
||||
void ilWin32::Init()
|
||||
{
|
||||
ilutRenderer(ILUT_WIN32);
|
||||
return;
|
||||
}
|
||||
|
||||
HBITMAP ilWin32::Convert(ilImage &Image)
|
||||
{
|
||||
Image.Bind();
|
||||
return ilutConvertToHBitmap(GetDC(NULL));
|
||||
}
|
||||
|
||||
ILboolean ilWin32::GetClipboard(ilImage &Image)
|
||||
{
|
||||
Image.Bind();
|
||||
return ilutGetWinClipboard();
|
||||
}
|
||||
|
||||
void ilWin32::GetInfo(ilImage &Image, BITMAPINFO *Info)
|
||||
{
|
||||
Image.Bind();
|
||||
ilutGetBmpInfo(Info);
|
||||
return;
|
||||
}
|
||||
|
||||
ILubyte* ilWin32::GetPadData(ilImage &Image)
|
||||
{
|
||||
Image.Bind();
|
||||
return ilutGetPaddedData();
|
||||
}
|
||||
|
||||
HPALETTE ilWin32::GetPal(ilImage &Image)
|
||||
{
|
||||
Image.Bind();
|
||||
return ilutGetHPal();
|
||||
}
|
||||
|
||||
ILboolean ilWin32::GetResource(ilImage &Image, HINSTANCE hInst, ILint ID, char *ResourceType)
|
||||
{
|
||||
Image.Bind();
|
||||
return ilutLoadResource(hInst, ID, ResourceType, IL_TYPE_UNKNOWN);
|
||||
}
|
||||
|
||||
ILboolean ilWin32::GetResource(ilImage &Image, HINSTANCE hInst, ILint ID, char *ResourceType, ILenum Type)
|
||||
{
|
||||
Image.Bind();
|
||||
return ilutLoadResource(hInst, ID, ResourceType, Type);
|
||||
}
|
||||
|
||||
ILboolean ilWin32::SetClipboard(ilImage &Image)
|
||||
{
|
||||
Image.Bind();
|
||||
return ilutSetWinClipboard();
|
||||
}
|
||||
#endif//ILUT_USE_WIN32
|
||||
|
||||
//
|
||||
// ILVALIDATE
|
||||
//
|
||||
ILboolean ilValidate::Valid(ILenum Type, ILconst_string FileName)
|
||||
{
|
||||
return ilIsValid(Type, FileName);
|
||||
}
|
||||
|
||||
ILboolean ilValidate::Valid(ILenum Type, FILE *File)
|
||||
{
|
||||
return ilIsValidF(Type, File);
|
||||
}
|
||||
|
||||
ILboolean ilValidate::Valid(ILenum Type, void *Lump, ILuint Size)
|
||||
{
|
||||
return ilIsValidL(Type, Lump, Size);
|
||||
}
|
||||
|
||||
//
|
||||
// ILSTATE
|
||||
//
|
||||
ILboolean ilState::Disable(ILenum State)
|
||||
{
|
||||
return ilDisable(State);
|
||||
}
|
||||
|
||||
ILboolean ilState::Enable(ILenum State)
|
||||
{
|
||||
return ilEnable(State);
|
||||
}
|
||||
|
||||
void ilState::Get(ILenum Mode, ILboolean &Param)
|
||||
{
|
||||
ilGetBooleanv(Mode, &Param);
|
||||
return;
|
||||
}
|
||||
|
||||
void ilState::Get(ILenum Mode, ILint &Param)
|
||||
{
|
||||
ilGetIntegerv(Mode, &Param);
|
||||
return;
|
||||
}
|
||||
|
||||
ILboolean ilState::GetBool(ILenum Mode)
|
||||
{
|
||||
return ilGetBoolean(Mode);
|
||||
}
|
||||
|
||||
ILint ilState::GetInt(ILenum Mode)
|
||||
{
|
||||
return ilGetInteger(Mode);
|
||||
}
|
||||
|
||||
const char *ilState::GetString(ILenum StringName)
|
||||
{
|
||||
return ilGetString(StringName);
|
||||
}
|
||||
|
||||
ILboolean ilState::IsDisabled(ILenum Mode)
|
||||
{
|
||||
return ilIsDisabled(Mode);
|
||||
}
|
||||
|
||||
ILboolean ilState::IsEnabled(ILenum Mode)
|
||||
{
|
||||
return ilIsEnabled(Mode);
|
||||
}
|
||||
|
||||
ILboolean ilState::Origin(ILenum Mode)
|
||||
{
|
||||
return ilOriginFunc(Mode);
|
||||
}
|
||||
|
||||
void ilState::Pop()
|
||||
{
|
||||
ilPopAttrib();
|
||||
return;
|
||||
}
|
||||
|
||||
void ilState::Push(ILuint Bits = IL_ALL_ATTRIB_BITS)
|
||||
{
|
||||
ilPushAttrib(Bits);
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// ILERROR
|
||||
//
|
||||
void ilError::Check(void (*Callback)(const char*))
|
||||
{
|
||||
static ILenum Error;
|
||||
|
||||
while ((Error = ilGetError()) != IL_NO_ERROR) {
|
||||
Callback(iluErrorString(Error));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void ilError::Check(void (*Callback)(ILenum))
|
||||
{
|
||||
static ILenum Error;
|
||||
|
||||
while ((Error = ilGetError()) != IL_NO_ERROR) {
|
||||
Callback(Error);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
ILenum ilError::Get()
|
||||
{
|
||||
return ilGetError();
|
||||
}
|
||||
|
||||
const char *ilError::String()
|
||||
{
|
||||
return iluErrorString(ilGetError());
|
||||
}
|
||||
|
||||
const char *ilError::String(ILenum Error)
|
||||
{
|
||||
return iluErrorString(Error);
|
||||
}
|
||||
|
||||
#endif// DEVIL_CPP_WRAPPER_HPP
|
||||
159
DevILSDK/include/IL/devil_internal_exports.h
Normal file
@ -0,0 +1,159 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// ImageLib Sources
|
||||
// Copyright (C) 2000-2017 by Denton Woods
|
||||
// Last modified: 01/06/2009
|
||||
//
|
||||
// Filename: IL/devil_internal_exports.h
|
||||
//
|
||||
// Description: Internal stuff for DevIL (IL, ILU and ILUT)
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef IL_EXPORTS_H
|
||||
#define IL_EXPORTS_H
|
||||
|
||||
#include "IL/il.h"
|
||||
|
||||
#ifdef DEBUG
|
||||
#include <assert.h>
|
||||
#else
|
||||
#define assert(x)
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef NOINLINE
|
||||
// No inlining. Treat all inline funcs as static.
|
||||
// Functions will be replicated in all translation units
|
||||
// use them.
|
||||
#define STATIC_INLINE static
|
||||
#else
|
||||
#if defined(_MSC_VER) && !defined(__cplusplus)
|
||||
// MSVC compiler uses __inline when compiling C (not C++)
|
||||
#define STATIC_INLINE static __inline
|
||||
#else
|
||||
// Portable across C99, GNU89, C++...
|
||||
#define STATIC_INLINE static inline
|
||||
#endif
|
||||
#endif // NOINLINE
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define IL_MAX(a,b) (((a) > (b)) ? (a) : (b))
|
||||
#define IL_MIN(a,b) (((a) < (b)) ? (a) : (b))
|
||||
|
||||
|
||||
//! Basic Palette struct
|
||||
typedef struct ILpal
|
||||
{
|
||||
ILubyte* Palette; //!< the image palette (if any)
|
||||
ILuint PalSize; //!< size of the palette (in bytes)
|
||||
ILenum PalType; //!< the palette types in il.h (0x0500 range)
|
||||
} ILpal;
|
||||
|
||||
|
||||
//! The Fundamental Image structure
|
||||
/*! Every bit of information about an image is stored in this internal structure.*/
|
||||
typedef struct ILimage
|
||||
{
|
||||
ILuint Width; //!< the image's width
|
||||
ILuint Height; //!< the image's height
|
||||
ILuint Depth; //!< the image's depth
|
||||
ILubyte Bpp; //!< bytes per pixel (now number of channels)
|
||||
ILubyte Bpc; //!< bytes per channel
|
||||
ILuint Bps; //!< bytes per scanline (components for IL)
|
||||
ILubyte* Data; //!< the image data
|
||||
ILuint SizeOfData; //!< the total size of the data (in bytes)
|
||||
ILuint SizeOfPlane; //!< SizeOfData in a 2d image, size of each plane slice in a 3d image (in bytes)
|
||||
ILenum Format; //!< image format (in IL enum style)
|
||||
ILenum Type; //!< image type (in IL enum style)
|
||||
ILenum Origin; //!< origin of the image
|
||||
ILpal Pal; //!< palette details
|
||||
ILuint Duration; //!< length of the time to display this "frame"
|
||||
ILenum CubeFlags; //!< cube map flags for sides present in chain
|
||||
struct ILimage* Mipmaps; //!< mipmapped versions of this image terminated by a NULL - usu. NULL
|
||||
struct ILimage* Next; //!< next image in the chain - usu. NULL
|
||||
struct ILimage* Faces; //!< next cubemap face in the chain - usu. NULL
|
||||
struct ILimage* Layers; //!< subsequent layers in the chain - usu. NULL
|
||||
ILuint* AnimList; //!< animation list
|
||||
ILuint AnimSize; //!< animation list size
|
||||
void* Profile; //!< colour profile
|
||||
ILuint ProfileSize; //!< colour profile size
|
||||
ILuint OffX; //!< x-offset of the image
|
||||
ILuint OffY; //!< y-offset of the image
|
||||
ILubyte* DxtcData; //!< compressed data
|
||||
ILenum DxtcFormat; //!< compressed data format
|
||||
ILuint DxtcSize; //!< compressed data size
|
||||
} ILimage;
|
||||
|
||||
|
||||
// Memory functions
|
||||
ILAPI void* ILAPIENTRY ialloc(const ILsizei Size);
|
||||
ILAPI void ILAPIENTRY ifree(const void *Ptr);
|
||||
ILAPI void* ILAPIENTRY icalloc(const ILsizei Size, const ILsizei Num);
|
||||
#ifdef ALTIVEC_GCC
|
||||
ILAPI void* ILAPIENTRY ivec_align_buffer(void *buffer, const ILuint size);
|
||||
#endif
|
||||
|
||||
// Internal library functions in IL
|
||||
ILAPI ILimage* ILAPIENTRY ilGetCurImage(void);
|
||||
ILAPI void ILAPIENTRY ilSetCurImage(ILimage *Image);
|
||||
ILAPI void ILAPIENTRY ilSetError(ILenum Error);
|
||||
ILAPI void ILAPIENTRY ilSetPal(ILpal *Pal);
|
||||
|
||||
//
|
||||
// Utility functions
|
||||
//
|
||||
ILAPI ILubyte ILAPIENTRY ilGetBppFormat(ILenum Format);
|
||||
ILAPI ILenum ILAPIENTRY ilGetFormatBpp(ILubyte Bpp);
|
||||
ILAPI ILubyte ILAPIENTRY ilGetBpcType(ILenum Type);
|
||||
ILAPI ILenum ILAPIENTRY ilGetTypeBpc(ILubyte Bpc);
|
||||
ILAPI ILubyte ILAPIENTRY ilGetBppPal(ILenum PalType);
|
||||
ILAPI ILenum ILAPIENTRY ilGetPalBaseType(ILenum PalType);
|
||||
ILAPI ILuint ILAPIENTRY ilNextPower2(ILuint Num);
|
||||
ILAPI ILenum ILAPIENTRY ilTypeFromExt(ILconst_string FileName);
|
||||
ILAPI void ILAPIENTRY ilReplaceCurImage(ILimage *Image);
|
||||
ILAPI void ILAPIENTRY iMemSwap(ILubyte *, ILubyte *, const ILuint);
|
||||
|
||||
//
|
||||
// Image functions
|
||||
//
|
||||
ILAPI void ILAPIENTRY iBindImageTemp (void);
|
||||
ILAPI ILboolean ILAPIENTRY ilClearImage_ (ILimage *Image);
|
||||
ILAPI void ILAPIENTRY ilCloseImage (ILimage *Image);
|
||||
ILAPI void ILAPIENTRY ilClosePal (ILpal *Palette);
|
||||
ILAPI ILpal* ILAPIENTRY iCopyPal (void);
|
||||
ILAPI ILboolean ILAPIENTRY ilCopyImageAttr (ILimage *Dest, ILimage *Src);
|
||||
ILAPI ILimage* ILAPIENTRY ilCopyImage_ (ILimage *Src);
|
||||
ILAPI void ILAPIENTRY ilGetClear (void *Colours, ILenum Format, ILenum Type);
|
||||
ILAPI ILuint ILAPIENTRY ilGetCurName (void);
|
||||
ILAPI ILboolean ILAPIENTRY ilIsValidPal (ILpal *Palette);
|
||||
ILAPI ILimage* ILAPIENTRY ilNewImage (ILuint Width, ILuint Height, ILuint Depth, ILubyte Bpp, ILubyte Bpc);
|
||||
ILAPI ILimage* ILAPIENTRY ilNewImageFull (ILuint Width, ILuint Height, ILuint Depth, ILubyte Bpp, ILenum Format, ILenum Type, void *Data);
|
||||
ILAPI ILboolean ILAPIENTRY ilInitImage (ILimage *Image, ILuint Width, ILuint Height, ILuint Depth, ILubyte Bpp, ILenum Format, ILenum Type, void *Data);
|
||||
ILAPI ILboolean ILAPIENTRY ilResizeImage (ILimage *Image, ILuint Width, ILuint Height, ILuint Depth, ILubyte Bpp, ILubyte Bpc);
|
||||
ILAPI ILboolean ILAPIENTRY ilTexImage_ (ILimage *Image, ILuint Width, ILuint Height, ILuint Depth, ILubyte Bpp, ILenum Format, ILenum Type, void *Data);
|
||||
ILAPI ILboolean ILAPIENTRY ilTexImageSurface_(ILimage *Image, ILuint Width, ILuint Height, ILuint Depth, ILubyte Bpp, ILenum Format, ILenum Type, void *Data);
|
||||
ILAPI ILboolean ILAPIENTRY ilTexSubImage_ (ILimage *Image, void *Data);
|
||||
ILAPI void* ILAPIENTRY ilConvertBuffer (ILuint SizeOfData, ILenum SrcFormat, ILenum DestFormat, ILenum SrcType, ILenum DestType, ILpal *SrcPal, void *Buffer);
|
||||
ILAPI ILimage* ILAPIENTRY iConvertImage (ILimage *Image, ILenum DestFormat, ILenum DestType);
|
||||
ILAPI ILpal* ILAPIENTRY iConvertPal (ILpal *Pal, ILenum DestFormat);
|
||||
ILAPI ILubyte* ILAPIENTRY iGetFlipped (ILimage *Image);
|
||||
ILAPI ILboolean ILAPIENTRY iMirror();
|
||||
ILAPI void ILAPIENTRY iFlipBuffer(ILubyte *buff, ILuint depth, ILuint line_size, ILuint line_num);
|
||||
ILubyte* iFlipNewBuffer(ILubyte *buff, ILuint depth, ILuint line_size, ILuint line_num);
|
||||
ILAPI void ILAPIENTRY iGetIntegervImage(ILimage *Image, ILenum Mode, ILint *Param);
|
||||
|
||||
// Internal library functions in ILU
|
||||
ILAPI ILimage* ILAPIENTRY iluRotate_(ILimage *Image, ILfloat Angle);
|
||||
ILAPI ILimage* ILAPIENTRY iluRotate3D_(ILimage *Image, ILfloat x, ILfloat y, ILfloat z, ILfloat Angle);
|
||||
ILAPI ILimage* ILAPIENTRY iluScale_(ILimage *Image, ILuint Width, ILuint Height, ILuint Depth);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif//IL_EXPORTS_H
|
||||
645
DevILSDK/include/IL/il.h
Normal file
@ -0,0 +1,645 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// ImageLib Sources
|
||||
// Copyright (C) 2000-2017 by Denton Woods
|
||||
// Last modified: 03/07/2009
|
||||
//
|
||||
// Filename: IL/il.h
|
||||
//
|
||||
// Description: The main include file for DevIL
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Doxygen comment
|
||||
/*! \file il.h
|
||||
The main include file for DevIL
|
||||
*/
|
||||
|
||||
#ifndef __il_h_
|
||||
#ifndef __IL_H__
|
||||
|
||||
#define __il_h_
|
||||
#define __IL_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//this define controls if floats and doubles are clamped to [0..1]
|
||||
//during conversion. It takes a little more time, but it is the correct
|
||||
//way of doing this. If you are sure your floats are always valid,
|
||||
//you can undefine this value...
|
||||
#define CLAMP_HALF 1
|
||||
#define CLAMP_FLOATS 1
|
||||
#define CLAMP_DOUBLES 1
|
||||
|
||||
/*#ifdef _WIN32_WCE
|
||||
#define IL_NO_EXR
|
||||
#define IL_NO_GIF
|
||||
#define IL_NO_JP2
|
||||
#define IL_NO_JPG
|
||||
#define IL_NO_MNG
|
||||
#define IL_NO_PNG
|
||||
#define IL_NO_TIF
|
||||
#define IL_NO_LCMS
|
||||
#endif //_WIN32_WCE
|
||||
|
||||
#ifdef DJGPP
|
||||
#define IL_NO_EXR
|
||||
#define IL_NO_GIF
|
||||
#define IL_NO_JP2
|
||||
#define IL_NO_JPG
|
||||
#define IL_NO_MNG
|
||||
#define IL_NO_PNG
|
||||
#define IL_NO_TIF
|
||||
#define IL_NO_LCMS
|
||||
#endif //DJGPP*/
|
||||
|
||||
#ifdef _WIN32
|
||||
#if (defined(IL_USE_PRAGMA_LIBS)) && (!defined(_IL_BUILD_LIBRARY))
|
||||
#if defined(_MSC_VER) || defined(__BORLANDC__)
|
||||
#pragma comment(lib, "DevIL.lib")
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(RESTRICT_KEYWORD) && !defined(__cplusplus)
|
||||
#define RESTRICT restrict
|
||||
#define CONST_RESTRICT const restrict
|
||||
#else
|
||||
#define RESTRICT
|
||||
#define CONST_RESTRICT const
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
typedef unsigned int ILenum;
|
||||
typedef unsigned char ILboolean;
|
||||
typedef unsigned int ILbitfield;
|
||||
typedef signed char ILbyte;
|
||||
typedef signed short ILshort;
|
||||
typedef int ILint;
|
||||
typedef size_t ILsizei;
|
||||
typedef unsigned char ILubyte;
|
||||
typedef unsigned short ILushort;
|
||||
typedef unsigned int ILuint;
|
||||
typedef float ILfloat;
|
||||
typedef float ILclampf;
|
||||
typedef double ILdouble;
|
||||
typedef double ILclampd;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
typedef __int64 ILint64;
|
||||
typedef unsigned __int64 ILuint64;
|
||||
#else
|
||||
typedef long long int ILint64;
|
||||
typedef long long unsigned int ILuint64;
|
||||
#endif
|
||||
|
||||
|
||||
#include <limits.h>
|
||||
#ifdef _UNICODE
|
||||
#ifndef _WIN32_WCE
|
||||
#include <wchar.h>
|
||||
#endif
|
||||
//if we use a define instead of a typedef,
|
||||
//ILconst_string works as intended
|
||||
#define ILchar wchar_t
|
||||
#define ILstring wchar_t*
|
||||
#define ILconst_string wchar_t const *
|
||||
#else
|
||||
//if we use a define instead of a typedef,
|
||||
//ILconst_string works as intended
|
||||
#define ILchar char
|
||||
#define ILstring char*
|
||||
#define ILconst_string char const *
|
||||
#endif //_UNICODE
|
||||
|
||||
#define IL_FALSE 0
|
||||
#define IL_TRUE 1
|
||||
|
||||
// Matches OpenGL's right now.
|
||||
//! Data formats \link Formats Formats\endlink
|
||||
#define IL_COLOUR_INDEX 0x1900
|
||||
#define IL_COLOR_INDEX 0x1900
|
||||
#define IL_ALPHA 0x1906
|
||||
#define IL_RGB 0x1907
|
||||
#define IL_RGBA 0x1908
|
||||
#define IL_BGR 0x80E0
|
||||
#define IL_BGRA 0x80E1
|
||||
#define IL_LUMINANCE 0x1909
|
||||
#define IL_LUMINANCE_ALPHA 0x190A
|
||||
|
||||
//! Data types \link Types Types\endlink
|
||||
#define IL_BYTE 0x1400
|
||||
#define IL_UNSIGNED_BYTE 0x1401
|
||||
#define IL_SHORT 0x1402
|
||||
#define IL_UNSIGNED_SHORT 0x1403
|
||||
#define IL_INT 0x1404
|
||||
#define IL_UNSIGNED_INT 0x1405
|
||||
#define IL_FLOAT 0x1406
|
||||
#define IL_DOUBLE 0x140A
|
||||
#define IL_HALF 0x140B
|
||||
|
||||
|
||||
#define IL_MAX_BYTE SCHAR_MAX
|
||||
#define IL_MAX_UNSIGNED_BYTE UCHAR_MAX
|
||||
#define IL_MAX_SHORT SHRT_MAX
|
||||
#define IL_MAX_UNSIGNED_SHORT USHRT_MAX
|
||||
#define IL_MAX_INT INT_MAX
|
||||
#define IL_MAX_UNSIGNED_INT UINT_MAX
|
||||
|
||||
#define IL_LIMIT(x,m,M) (x<m?m:(x>M?M:x))
|
||||
#define IL_CLAMP(x) IL_LIMIT(x,0,1)
|
||||
|
||||
#define IL_VENDOR 0x1F00
|
||||
#define IL_LOAD_EXT 0x1F01
|
||||
#define IL_SAVE_EXT 0x1F02
|
||||
|
||||
|
||||
//
|
||||
// IL-specific #define's
|
||||
//
|
||||
|
||||
#define IL_VERSION_1_8_0 1
|
||||
#define IL_VERSION 180
|
||||
|
||||
|
||||
// Attribute Bits
|
||||
#define IL_ORIGIN_BIT 0x00000001
|
||||
#define IL_FILE_BIT 0x00000002
|
||||
#define IL_PAL_BIT 0x00000004
|
||||
#define IL_FORMAT_BIT 0x00000008
|
||||
#define IL_TYPE_BIT 0x00000010
|
||||
#define IL_COMPRESS_BIT 0x00000020
|
||||
#define IL_LOADFAIL_BIT 0x00000040
|
||||
#define IL_FORMAT_SPECIFIC_BIT 0x00000080
|
||||
#define IL_ALL_ATTRIB_BITS 0x000FFFFF
|
||||
|
||||
|
||||
// Palette types
|
||||
#define IL_PAL_NONE 0x0400
|
||||
#define IL_PAL_RGB24 0x0401
|
||||
#define IL_PAL_RGB32 0x0402
|
||||
#define IL_PAL_RGBA32 0x0403
|
||||
#define IL_PAL_BGR24 0x0404
|
||||
#define IL_PAL_BGR32 0x0405
|
||||
#define IL_PAL_BGRA32 0x0406
|
||||
|
||||
|
||||
// Image types
|
||||
#define IL_TYPE_UNKNOWN 0x0000
|
||||
#define IL_BMP 0x0420 //!< Microsoft Windows Bitmap - .bmp extension
|
||||
#define IL_CUT 0x0421 //!< Dr. Halo - .cut extension
|
||||
#define IL_DOOM 0x0422 //!< DooM walls - no specific extension
|
||||
#define IL_DOOM_FLAT 0x0423 //!< DooM flats - no specific extension
|
||||
#define IL_ICO 0x0424 //!< Microsoft Windows Icons and Cursors - .ico and .cur extensions
|
||||
#define IL_JPG 0x0425 //!< JPEG - .jpg, .jpe and .jpeg extensions
|
||||
#define IL_JFIF 0x0425 //!<
|
||||
#define IL_ILBM 0x0426 //!< Amiga IFF (FORM ILBM) - .iff, .ilbm, .lbm extensions
|
||||
#define IL_PCD 0x0427 //!< Kodak PhotoCD - .pcd extension
|
||||
#define IL_PCX 0x0428 //!< ZSoft PCX - .pcx extension
|
||||
#define IL_PIC 0x0429 //!< PIC - .pic extension
|
||||
#define IL_PNG 0x042A //!< Portable Network Graphics - .png extension
|
||||
#define IL_PNM 0x042B //!< Portable Any Map - .pbm, .pgm, .ppm and .pnm extensions
|
||||
#define IL_SGI 0x042C //!< Silicon Graphics - .sgi, .bw, .rgb and .rgba extensions
|
||||
#define IL_TGA 0x042D //!< TrueVision Targa File - .tga, .vda, .icb and .vst extensions
|
||||
#define IL_TIF 0x042E //!< Tagged Image File Format - .tif and .tiff extensions
|
||||
#define IL_CHEAD 0x042F //!< C-Style Header - .h extension
|
||||
#define IL_RAW 0x0430 //!< Raw Image Data - any extension
|
||||
#define IL_MDL 0x0431 //!< Half-Life Model Texture - .mdl extension
|
||||
#define IL_WAL 0x0432 //!< Quake 2 Texture - .wal extension
|
||||
#define IL_LIF 0x0434 //!< Homeworld Texture - .lif extension
|
||||
#define IL_MNG 0x0435 //!< Multiple-image Network Graphics - .mng extension
|
||||
#define IL_JNG 0x0435 //!<
|
||||
#define IL_GIF 0x0436 //!< Graphics Interchange Format - .gif extension
|
||||
#define IL_DDS 0x0437 //!< DirectDraw Surface - .dds extension
|
||||
#define IL_DCX 0x0438 //!< ZSoft Multi-PCX - .dcx extension
|
||||
#define IL_PSD 0x0439 //!< Adobe PhotoShop - .psd extension
|
||||
#define IL_EXIF 0x043A //!<
|
||||
#define IL_PSP 0x043B //!< PaintShop Pro - .psp extension
|
||||
#define IL_PIX 0x043C //!< PIX - .pix extension
|
||||
#define IL_PXR 0x043D //!< Pixar - .pxr extension
|
||||
#define IL_XPM 0x043E //!< X Pixel Map - .xpm extension
|
||||
#define IL_HDR 0x043F //!< Radiance High Dynamic Range - .hdr extension
|
||||
#define IL_ICNS 0x0440 //!< Macintosh Icon - .icns extension
|
||||
#define IL_JP2 0x0441 //!< Jpeg 2000 - .jp2 extension
|
||||
#define IL_EXR 0x0442 //!< OpenEXR - .exr extension
|
||||
#define IL_WDP 0x0443 //!< Microsoft HD Photo - .wdp and .hdp extension
|
||||
#define IL_VTF 0x0444 //!< Valve Texture Format - .vtf extension
|
||||
#define IL_WBMP 0x0445 //!< Wireless Bitmap - .wbmp extension
|
||||
#define IL_SUN 0x0446 //!< Sun Raster - .sun, .ras, .rs, .im1, .im8, .im24 and .im32 extensions
|
||||
#define IL_IFF 0x0447 //!< Interchange File Format - .iff extension
|
||||
#define IL_TPL 0x0448 //!< Gamecube Texture - .tpl extension
|
||||
#define IL_FITS 0x0449 //!< Flexible Image Transport System - .fit and .fits extensions
|
||||
#define IL_DICOM 0x044A //!< Digital Imaging and Communications in Medicine (DICOM) - .dcm and .dicom extensions
|
||||
#define IL_IWI 0x044B //!< Call of Duty Infinity Ward Image - .iwi extension
|
||||
#define IL_BLP 0x044C //!< Blizzard Texture Format - .blp extension
|
||||
#define IL_FTX 0x044D //!< Heavy Metal: FAKK2 Texture - .ftx extension
|
||||
#define IL_ROT 0x044E //!< Homeworld 2 - Relic Texture - .rot extension
|
||||
#define IL_TEXTURE 0x044F //!< Medieval II: Total War Texture - .texture extension
|
||||
#define IL_DPX 0x0450 //!< Digital Picture Exchange - .dpx extension
|
||||
#define IL_UTX 0x0451 //!< Unreal (and Unreal Tournament) Texture - .utx extension
|
||||
#define IL_MP3 0x0452 //!< MPEG-1 Audio Layer 3 - .mp3 extension
|
||||
#define IL_KTX 0x0453 //!< Khronos Texture - .ktx extension
|
||||
|
||||
|
||||
#define IL_JASC_PAL 0x0475 //!< PaintShop Pro Palette
|
||||
|
||||
|
||||
// Error Types
|
||||
#define IL_NO_ERROR 0x0000
|
||||
#define IL_INVALID_ENUM 0x0501
|
||||
#define IL_OUT_OF_MEMORY 0x0502
|
||||
#define IL_FORMAT_NOT_SUPPORTED 0x0503
|
||||
#define IL_INTERNAL_ERROR 0x0504
|
||||
#define IL_INVALID_VALUE 0x0505
|
||||
#define IL_ILLEGAL_OPERATION 0x0506
|
||||
#define IL_ILLEGAL_FILE_VALUE 0x0507
|
||||
#define IL_INVALID_FILE_HEADER 0x0508
|
||||
#define IL_INVALID_PARAM 0x0509
|
||||
#define IL_COULD_NOT_OPEN_FILE 0x050A
|
||||
#define IL_INVALID_EXTENSION 0x050B
|
||||
#define IL_FILE_ALREADY_EXISTS 0x050C
|
||||
#define IL_OUT_FORMAT_SAME 0x050D
|
||||
#define IL_STACK_OVERFLOW 0x050E
|
||||
#define IL_STACK_UNDERFLOW 0x050F
|
||||
#define IL_INVALID_CONVERSION 0x0510
|
||||
#define IL_BAD_DIMENSIONS 0x0511
|
||||
#define IL_FILE_READ_ERROR 0x0512 // 05/12/2002: Addition by Sam.
|
||||
#define IL_FILE_WRITE_ERROR 0x0512
|
||||
|
||||
#define IL_LIB_GIF_ERROR 0x05E1
|
||||
#define IL_LIB_JPEG_ERROR 0x05E2
|
||||
#define IL_LIB_PNG_ERROR 0x05E3
|
||||
#define IL_LIB_TIFF_ERROR 0x05E4
|
||||
#define IL_LIB_MNG_ERROR 0x05E5
|
||||
#define IL_LIB_JP2_ERROR 0x05E6
|
||||
#define IL_LIB_EXR_ERROR 0x05E7
|
||||
#define IL_UNKNOWN_ERROR 0x05FF
|
||||
|
||||
|
||||
// Origin Definitions
|
||||
#define IL_ORIGIN_SET 0x0600
|
||||
#define IL_ORIGIN_LOWER_LEFT 0x0601
|
||||
#define IL_ORIGIN_UPPER_LEFT 0x0602
|
||||
#define IL_ORIGIN_MODE 0x0603
|
||||
|
||||
|
||||
// Format and Type Mode Definitions
|
||||
#define IL_FORMAT_SET 0x0610
|
||||
#define IL_FORMAT_MODE 0x0611
|
||||
#define IL_TYPE_SET 0x0612
|
||||
#define IL_TYPE_MODE 0x0613
|
||||
|
||||
|
||||
// File definitions
|
||||
#define IL_FILE_OVERWRITE 0x0620
|
||||
#define IL_FILE_MODE 0x0621
|
||||
|
||||
|
||||
// Palette definitions
|
||||
#define IL_CONV_PAL 0x0630
|
||||
|
||||
|
||||
// Load fail definitions
|
||||
#define IL_DEFAULT_ON_FAIL 0x0632
|
||||
|
||||
|
||||
// Key colour and alpha definitions
|
||||
#define IL_USE_KEY_COLOUR 0x0635
|
||||
#define IL_USE_KEY_COLOR 0x0635
|
||||
#define IL_BLIT_BLEND 0x0636
|
||||
|
||||
|
||||
// Interlace definitions
|
||||
#define IL_SAVE_INTERLACED 0x0639
|
||||
#define IL_INTERLACE_MODE 0x063A
|
||||
|
||||
|
||||
// Quantization definitions
|
||||
#define IL_QUANTIZATION_MODE 0x0640
|
||||
#define IL_WU_QUANT 0x0641
|
||||
#define IL_NEU_QUANT 0x0642
|
||||
#define IL_NEU_QUANT_SAMPLE 0x0643
|
||||
#define IL_MAX_QUANT_INDEXS 0x0644 //XIX : ILint : Maximum number of colors to reduce to, default of 256. and has a range of 2-256
|
||||
#define IL_MAX_QUANT_INDICES 0x0644 // Redefined, since the above #define is misspelled
|
||||
|
||||
|
||||
// Hints
|
||||
#define IL_FASTEST 0x0660
|
||||
#define IL_LESS_MEM 0x0661
|
||||
#define IL_DONT_CARE 0x0662
|
||||
#define IL_MEM_SPEED_HINT 0x0665
|
||||
#define IL_USE_COMPRESSION 0x0666
|
||||
#define IL_NO_COMPRESSION 0x0667
|
||||
#define IL_COMPRESSION_HINT 0x0668
|
||||
|
||||
|
||||
// Compression
|
||||
#define IL_NVIDIA_COMPRESS 0x0670
|
||||
#define IL_SQUISH_COMPRESS 0x0671
|
||||
|
||||
|
||||
// Subimage types
|
||||
#define IL_SUB_NEXT 0x0680
|
||||
#define IL_SUB_MIPMAP 0x0681
|
||||
#define IL_SUB_LAYER 0x0682
|
||||
|
||||
|
||||
// Compression definitions
|
||||
#define IL_COMPRESS_MODE 0x0700
|
||||
#define IL_COMPRESS_NONE 0x0701
|
||||
#define IL_COMPRESS_RLE 0x0702
|
||||
#define IL_COMPRESS_LZO 0x0703
|
||||
#define IL_COMPRESS_ZLIB 0x0704
|
||||
|
||||
|
||||
// File format-specific values
|
||||
#define IL_TGA_CREATE_STAMP 0x0710
|
||||
#define IL_JPG_QUALITY 0x0711
|
||||
#define IL_PNG_INTERLACE 0x0712
|
||||
#define IL_TGA_RLE 0x0713
|
||||
#define IL_BMP_RLE 0x0714
|
||||
#define IL_SGI_RLE 0x0715
|
||||
#define IL_TGA_ID_STRING 0x0717
|
||||
#define IL_TGA_AUTHNAME_STRING 0x0718
|
||||
#define IL_TGA_AUTHCOMMENT_STRING 0x0719
|
||||
#define IL_PNG_AUTHNAME_STRING 0x071A
|
||||
#define IL_PNG_TITLE_STRING 0x071B
|
||||
#define IL_PNG_DESCRIPTION_STRING 0x071C
|
||||
#define IL_TIF_DESCRIPTION_STRING 0x071D
|
||||
#define IL_TIF_HOSTCOMPUTER_STRING 0x071E
|
||||
#define IL_TIF_DOCUMENTNAME_STRING 0x071F
|
||||
#define IL_TIF_AUTHNAME_STRING 0x0720
|
||||
#define IL_JPG_SAVE_FORMAT 0x0721
|
||||
#define IL_CHEAD_HEADER_STRING 0x0722
|
||||
#define IL_PCD_PICNUM 0x0723
|
||||
#define IL_PNG_ALPHA_INDEX 0x0724 // currently has no effect!
|
||||
#define IL_JPG_PROGRESSIVE 0x0725
|
||||
#define IL_VTF_COMP 0x0726
|
||||
|
||||
|
||||
// DXTC definitions
|
||||
#define IL_DXTC_FORMAT 0x0705
|
||||
#define IL_DXT1 0x0706
|
||||
#define IL_DXT2 0x0707
|
||||
#define IL_DXT3 0x0708
|
||||
#define IL_DXT4 0x0709
|
||||
#define IL_DXT5 0x070A
|
||||
#define IL_DXT_NO_COMP 0x070B
|
||||
#define IL_KEEP_DXTC_DATA 0x070C
|
||||
#define IL_DXTC_DATA_FORMAT 0x070D
|
||||
#define IL_3DC 0x070E
|
||||
#define IL_RXGB 0x070F
|
||||
#define IL_ATI1N 0x0710
|
||||
#define IL_DXT1A 0x0711 // Normally the same as IL_DXT1, except for nVidia Texture Tools.
|
||||
|
||||
// Environment map definitions
|
||||
#define IL_CUBEMAP_POSITIVEX 0x00000400
|
||||
#define IL_CUBEMAP_NEGATIVEX 0x00000800
|
||||
#define IL_CUBEMAP_POSITIVEY 0x00001000
|
||||
#define IL_CUBEMAP_NEGATIVEY 0x00002000
|
||||
#define IL_CUBEMAP_POSITIVEZ 0x00004000
|
||||
#define IL_CUBEMAP_NEGATIVEZ 0x00008000
|
||||
#define IL_SPHEREMAP 0x00010000
|
||||
|
||||
|
||||
// Values
|
||||
#define IL_VERSION_NUM 0x0DE2
|
||||
#define IL_IMAGE_WIDTH 0x0DE4
|
||||
#define IL_IMAGE_HEIGHT 0x0DE5
|
||||
#define IL_IMAGE_DEPTH 0x0DE6
|
||||
#define IL_IMAGE_SIZE_OF_DATA 0x0DE7
|
||||
#define IL_IMAGE_BPP 0x0DE8
|
||||
#define IL_IMAGE_BYTES_PER_PIXEL 0x0DE8
|
||||
#define IL_IMAGE_BPP 0x0DE8
|
||||
#define IL_IMAGE_BITS_PER_PIXEL 0x0DE9
|
||||
#define IL_IMAGE_FORMAT 0x0DEA
|
||||
#define IL_IMAGE_TYPE 0x0DEB
|
||||
#define IL_PALETTE_TYPE 0x0DEC
|
||||
#define IL_PALETTE_SIZE 0x0DED
|
||||
#define IL_PALETTE_BPP 0x0DEE
|
||||
#define IL_PALETTE_NUM_COLS 0x0DEF
|
||||
#define IL_PALETTE_BASE_TYPE 0x0DF0
|
||||
#define IL_NUM_FACES 0x0DE1
|
||||
#define IL_NUM_IMAGES 0x0DF1
|
||||
#define IL_NUM_MIPMAPS 0x0DF2
|
||||
#define IL_NUM_LAYERS 0x0DF3
|
||||
#define IL_ACTIVE_IMAGE 0x0DF4
|
||||
#define IL_ACTIVE_MIPMAP 0x0DF5
|
||||
#define IL_ACTIVE_LAYER 0x0DF6
|
||||
#define IL_ACTIVE_FACE 0x0E00
|
||||
#define IL_CUR_IMAGE 0x0DF7
|
||||
#define IL_IMAGE_DURATION 0x0DF8
|
||||
#define IL_IMAGE_PLANESIZE 0x0DF9
|
||||
#define IL_IMAGE_BPC 0x0DFA
|
||||
#define IL_IMAGE_OFFX 0x0DFB
|
||||
#define IL_IMAGE_OFFY 0x0DFC
|
||||
#define IL_IMAGE_CUBEFLAGS 0x0DFD
|
||||
#define IL_IMAGE_ORIGIN 0x0DFE
|
||||
#define IL_IMAGE_CHANNELS 0x0DFF
|
||||
|
||||
# if defined __GNUC__ && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 0))
|
||||
// __attribute__((deprecated)) is supported by GCC 3.1 and later.
|
||||
# define DEPRECATED(D) D __attribute__((deprecated))
|
||||
# elif defined _MSC_VER && _MSC_VER >= 1300
|
||||
// __declspec(deprecated) is supported by MSVC 7.0 and later.
|
||||
# define DEPRECATED(D) __declspec(deprecated) D
|
||||
# else
|
||||
# define DEPRECATED (D) D
|
||||
# endif
|
||||
|
||||
//
|
||||
// Section shamelessly modified from the glut header.
|
||||
//
|
||||
|
||||
// This is from Win32's <windef.h>
|
||||
#if (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED) || defined(__BORLANDC__) || defined(__LCC__)
|
||||
#define ILAPIENTRY __stdcall
|
||||
#define IL_PACKSTRUCT
|
||||
//#elif defined(linux) || defined(MACOSX) || defined(__CYGWIN__) //fix bug 840364
|
||||
#elif defined( __GNUC__ )
|
||||
// this should work for any of the above commented platforms
|
||||
// plus any platform using GCC
|
||||
#ifdef __MINGW32__
|
||||
#define ILAPIENTRY __stdcall
|
||||
#else
|
||||
#define ILAPIENTRY
|
||||
#endif
|
||||
#define IL_PACKSTRUCT __attribute__ ((packed))
|
||||
#else
|
||||
#define ILAPIENTRY
|
||||
#define IL_PACKSTRUCT
|
||||
#endif
|
||||
|
||||
// This is from Win32's <wingdi.h> and <winnt.h>
|
||||
#if defined(__LCC__)
|
||||
#define ILAPI __stdcall
|
||||
#elif defined(_WIN32) //changed 20031221 to fix bug 840421
|
||||
#ifdef IL_STATIC_LIB
|
||||
#define ILAPI
|
||||
#else
|
||||
#ifdef _IL_BUILD_LIBRARY
|
||||
#define ILAPI __declspec(dllexport)
|
||||
#else
|
||||
#define ILAPI __declspec(dllimport)
|
||||
#endif
|
||||
#endif
|
||||
#elif __APPLE__
|
||||
#define ILAPI extern
|
||||
#else
|
||||
#define ILAPI
|
||||
#endif
|
||||
|
||||
|
||||
#define IL_SEEK_SET 0
|
||||
#define IL_SEEK_CUR 1
|
||||
#define IL_SEEK_END 2
|
||||
#define IL_EOF -1
|
||||
|
||||
|
||||
// Callback functions for file reading
|
||||
typedef void* ILHANDLE;
|
||||
typedef void (ILAPIENTRY *fCloseRProc)(ILHANDLE);
|
||||
typedef ILboolean (ILAPIENTRY *fEofProc) (ILHANDLE);
|
||||
typedef ILint (ILAPIENTRY *fGetcProc) (ILHANDLE);
|
||||
typedef ILHANDLE (ILAPIENTRY *fOpenRProc) (ILconst_string);
|
||||
typedef ILint (ILAPIENTRY *fReadProc) (void*, ILuint, ILuint, ILHANDLE);
|
||||
typedef ILint (ILAPIENTRY *fSeekRProc) (ILHANDLE, ILint, ILint);
|
||||
typedef ILint (ILAPIENTRY *fTellRProc) (ILHANDLE);
|
||||
|
||||
// Callback functions for file writing
|
||||
typedef void (ILAPIENTRY *fCloseWProc)(ILHANDLE);
|
||||
typedef ILHANDLE (ILAPIENTRY *fOpenWProc) (ILconst_string);
|
||||
typedef ILint (ILAPIENTRY *fPutcProc) (ILubyte, ILHANDLE);
|
||||
typedef ILint (ILAPIENTRY *fSeekWProc) (ILHANDLE, ILint, ILint);
|
||||
typedef ILint (ILAPIENTRY *fTellWProc) (ILHANDLE);
|
||||
typedef ILint (ILAPIENTRY *fWriteProc) (const void*, ILuint, ILuint, ILHANDLE);
|
||||
|
||||
// Callback functions for allocation and deallocation
|
||||
typedef void* (ILAPIENTRY *mAlloc)(const ILsizei);
|
||||
typedef void (ILAPIENTRY *mFree) (const void* CONST_RESTRICT);
|
||||
|
||||
// Registered format procedures
|
||||
typedef ILenum (ILAPIENTRY *IL_LOADPROC)(ILconst_string);
|
||||
typedef ILenum (ILAPIENTRY *IL_SAVEPROC)(ILconst_string);
|
||||
|
||||
|
||||
// ImageLib Functions
|
||||
ILAPI ILboolean ILAPIENTRY ilActiveFace(ILuint Number);
|
||||
ILAPI ILboolean ILAPIENTRY ilActiveImage(ILuint Number);
|
||||
ILAPI ILboolean ILAPIENTRY ilActiveLayer(ILuint Number);
|
||||
ILAPI ILboolean ILAPIENTRY ilActiveMipmap(ILuint Number);
|
||||
ILAPI ILboolean ILAPIENTRY ilApplyPal(ILconst_string FileName);
|
||||
ILAPI ILboolean ILAPIENTRY ilApplyProfile(ILstring InProfile, ILstring OutProfile);
|
||||
ILAPI void ILAPIENTRY ilBindImage(ILuint Image);
|
||||
ILAPI ILboolean ILAPIENTRY ilBlit(ILuint Source, ILint DestX, ILint DestY, ILint DestZ, ILuint SrcX, ILuint SrcY, ILuint SrcZ, ILuint Width, ILuint Height, ILuint Depth);
|
||||
ILAPI ILboolean ILAPIENTRY ilClampNTSC(void);
|
||||
ILAPI void ILAPIENTRY ilClearColour(ILclampf Red, ILclampf Green, ILclampf Blue, ILclampf Alpha);
|
||||
ILAPI ILboolean ILAPIENTRY ilClearImage(void);
|
||||
ILAPI ILuint ILAPIENTRY ilCloneCurImage(void);
|
||||
ILAPI ILubyte* ILAPIENTRY ilCompressDXT(ILubyte *Data, ILuint Width, ILuint Height, ILuint Depth, ILenum DXTCFormat, ILuint *DXTCSize);
|
||||
ILAPI ILboolean ILAPIENTRY ilCompressFunc(ILenum Mode);
|
||||
ILAPI ILboolean ILAPIENTRY ilConvertImage(ILenum DestFormat, ILenum DestType);
|
||||
ILAPI ILboolean ILAPIENTRY ilConvertPal(ILenum DestFormat);
|
||||
ILAPI ILboolean ILAPIENTRY ilCopyImage(ILuint Src);
|
||||
ILAPI ILuint ILAPIENTRY ilCopyPixels(ILuint XOff, ILuint YOff, ILuint ZOff, ILuint Width, ILuint Height, ILuint Depth, ILenum Format, ILenum Type, void *Data);
|
||||
ILAPI ILuint ILAPIENTRY ilCreateSubImage(ILenum Type, ILuint Num);
|
||||
ILAPI ILboolean ILAPIENTRY ilDefaultImage(void);
|
||||
ILAPI void ILAPIENTRY ilDeleteImage(const ILuint Num);
|
||||
ILAPI void ILAPIENTRY ilDeleteImages(ILsizei Num, const ILuint *Images);
|
||||
ILAPI ILenum ILAPIENTRY ilDetermineType(ILconst_string FileName);
|
||||
ILAPI ILenum ILAPIENTRY ilDetermineTypeF(ILHANDLE File);
|
||||
ILAPI ILenum ILAPIENTRY ilDetermineTypeL(const void *Lump, ILuint Size);
|
||||
ILAPI ILboolean ILAPIENTRY ilDisable(ILenum Mode);
|
||||
ILAPI ILboolean ILAPIENTRY ilDxtcDataToImage(void);
|
||||
ILAPI ILboolean ILAPIENTRY ilDxtcDataToSurface(void);
|
||||
ILAPI ILboolean ILAPIENTRY ilEnable(ILenum Mode);
|
||||
ILAPI void ILAPIENTRY ilFlipSurfaceDxtcData(void);
|
||||
ILAPI ILboolean ILAPIENTRY ilFormatFunc(ILenum Mode);
|
||||
ILAPI void ILAPIENTRY ilGenImages(ILsizei Num, ILuint *Images);
|
||||
ILAPI ILuint ILAPIENTRY ilGenImage(void);
|
||||
ILAPI ILubyte* ILAPIENTRY ilGetAlpha(ILenum Type);
|
||||
ILAPI ILboolean ILAPIENTRY ilGetBoolean(ILenum Mode);
|
||||
ILAPI void ILAPIENTRY ilGetBooleanv(ILenum Mode, ILboolean *Param);
|
||||
ILAPI ILubyte* ILAPIENTRY ilGetData(void);
|
||||
ILAPI ILuint ILAPIENTRY ilGetDXTCData(void *Buffer, ILuint BufferSize, ILenum DXTCFormat);
|
||||
ILAPI ILenum ILAPIENTRY ilGetError(void);
|
||||
ILAPI ILint ILAPIENTRY ilGetInteger(ILenum Mode);
|
||||
ILAPI void ILAPIENTRY ilGetIntegerv(ILenum Mode, ILint *Param);
|
||||
ILAPI ILuint ILAPIENTRY ilGetLumpPos(void);
|
||||
ILAPI ILubyte* ILAPIENTRY ilGetPalette(void);
|
||||
ILAPI ILconst_string ILAPIENTRY ilGetString(ILenum StringName);
|
||||
ILAPI void ILAPIENTRY ilHint(ILenum Target, ILenum Mode);
|
||||
ILAPI ILboolean ILAPIENTRY ilInvertSurfaceDxtcDataAlpha(void);
|
||||
ILAPI void ILAPIENTRY ilInit(void);
|
||||
ILAPI ILboolean ILAPIENTRY ilImageToDxtcData(ILenum Format);
|
||||
ILAPI ILboolean ILAPIENTRY ilIsDisabled(ILenum Mode);
|
||||
ILAPI ILboolean ILAPIENTRY ilIsEnabled(ILenum Mode);
|
||||
ILAPI ILboolean ILAPIENTRY ilIsImage(ILuint Image);
|
||||
ILAPI ILboolean ILAPIENTRY ilIsValid(ILenum Type, ILconst_string FileName);
|
||||
ILAPI ILboolean ILAPIENTRY ilIsValidF(ILenum Type, ILHANDLE File);
|
||||
ILAPI ILboolean ILAPIENTRY ilIsValidL(ILenum Type, void *Lump, ILuint Size);
|
||||
ILAPI void ILAPIENTRY ilKeyColour(ILclampf Red, ILclampf Green, ILclampf Blue, ILclampf Alpha);
|
||||
ILAPI ILboolean ILAPIENTRY ilLoad(ILenum Type, ILconst_string FileName);
|
||||
ILAPI ILboolean ILAPIENTRY ilLoadF(ILenum Type, ILHANDLE File);
|
||||
ILAPI ILboolean ILAPIENTRY ilLoadImage(ILconst_string FileName);
|
||||
ILAPI ILboolean ILAPIENTRY ilLoadL(ILenum Type, const void *Lump, ILuint Size);
|
||||
ILAPI ILboolean ILAPIENTRY ilLoadPal(ILconst_string FileName);
|
||||
ILAPI void ILAPIENTRY ilModAlpha(ILdouble AlphaValue);
|
||||
ILAPI ILboolean ILAPIENTRY ilOriginFunc(ILenum Mode);
|
||||
ILAPI ILboolean ILAPIENTRY ilOverlayImage(ILuint Source, ILint XCoord, ILint YCoord, ILint ZCoord);
|
||||
ILAPI void ILAPIENTRY ilPopAttrib(void);
|
||||
ILAPI void ILAPIENTRY ilPushAttrib(ILuint Bits);
|
||||
ILAPI void ILAPIENTRY ilRegisterFormat(ILenum Format);
|
||||
ILAPI ILboolean ILAPIENTRY ilRegisterLoad(ILconst_string Ext, IL_LOADPROC Load);
|
||||
ILAPI ILboolean ILAPIENTRY ilRegisterMipNum(ILuint Num);
|
||||
ILAPI ILboolean ILAPIENTRY ilRegisterNumFaces(ILuint Num);
|
||||
ILAPI ILboolean ILAPIENTRY ilRegisterNumImages(ILuint Num);
|
||||
ILAPI void ILAPIENTRY ilRegisterOrigin(ILenum Origin);
|
||||
ILAPI void ILAPIENTRY ilRegisterPal(void *Pal, ILuint Size, ILenum Type);
|
||||
ILAPI ILboolean ILAPIENTRY ilRegisterSave(ILconst_string Ext, IL_SAVEPROC Save);
|
||||
ILAPI void ILAPIENTRY ilRegisterType(ILenum Type);
|
||||
ILAPI ILboolean ILAPIENTRY ilRemoveLoad(ILconst_string Ext);
|
||||
ILAPI ILboolean ILAPIENTRY ilRemoveSave(ILconst_string Ext);
|
||||
ILAPI void ILAPIENTRY ilResetMemory(void); // Deprecated
|
||||
ILAPI void ILAPIENTRY ilResetRead(void);
|
||||
ILAPI void ILAPIENTRY ilResetWrite(void);
|
||||
ILAPI ILboolean ILAPIENTRY ilSave(ILenum Type, ILconst_string FileName);
|
||||
ILAPI ILuint ILAPIENTRY ilSaveF(ILenum Type, ILHANDLE File);
|
||||
ILAPI ILboolean ILAPIENTRY ilSaveImage(ILconst_string FileName);
|
||||
ILAPI ILuint ILAPIENTRY ilSaveL(ILenum Type, void *Lump, ILuint Size);
|
||||
ILAPI ILboolean ILAPIENTRY ilSavePal(ILconst_string FileName);
|
||||
ILAPI ILboolean ILAPIENTRY ilSetAlpha(ILdouble AlphaValue);
|
||||
ILAPI ILboolean ILAPIENTRY ilSetData(void *Data);
|
||||
ILAPI ILboolean ILAPIENTRY ilSetDuration(ILuint Duration);
|
||||
ILAPI void ILAPIENTRY ilSetInteger(ILenum Mode, ILint Param);
|
||||
ILAPI void ILAPIENTRY ilSetMemory(mAlloc, mFree);
|
||||
ILAPI void ILAPIENTRY ilSetPixels(ILint XOff, ILint YOff, ILint ZOff, ILuint Width, ILuint Height, ILuint Depth, ILenum Format, ILenum Type, void *Data);
|
||||
ILAPI void ILAPIENTRY ilSetRead(fOpenRProc, fCloseRProc, fEofProc, fGetcProc, fReadProc, fSeekRProc, fTellRProc);
|
||||
ILAPI void ILAPIENTRY ilSetString(ILenum Mode, const char *String);
|
||||
ILAPI void ILAPIENTRY ilSetWrite(fOpenWProc, fCloseWProc, fPutcProc, fSeekWProc, fTellWProc, fWriteProc);
|
||||
ILAPI void ILAPIENTRY ilShutDown(void);
|
||||
ILAPI ILboolean ILAPIENTRY ilSurfaceToDxtcData(ILenum Format);
|
||||
ILAPI ILboolean ILAPIENTRY ilTexImage(ILuint Width, ILuint Height, ILuint Depth, ILubyte NumChannels, ILenum Format, ILenum Type, void *Data);
|
||||
ILAPI ILboolean ILAPIENTRY ilTexImageDxtc(ILint w, ILint h, ILint d, ILenum DxtFormat, const ILubyte* data);
|
||||
ILAPI ILenum ILAPIENTRY ilTypeFromExt(ILconst_string FileName);
|
||||
ILAPI ILboolean ILAPIENTRY ilTypeFunc(ILenum Mode);
|
||||
ILAPI ILboolean ILAPIENTRY ilLoadData(ILconst_string FileName, ILuint Width, ILuint Height, ILuint Depth, ILubyte Bpp);
|
||||
ILAPI ILboolean ILAPIENTRY ilLoadDataF(ILHANDLE File, ILuint Width, ILuint Height, ILuint Depth, ILubyte Bpp);
|
||||
ILAPI ILboolean ILAPIENTRY ilLoadDataL(void *Lump, ILuint Size, ILuint Width, ILuint Height, ILuint Depth, ILubyte Bpp);
|
||||
ILAPI ILboolean ILAPIENTRY ilSaveData(ILconst_string FileName);
|
||||
|
||||
// For all those weirdos that spell "colour" without the 'u'.
|
||||
#define ilClearColor ilClearColour
|
||||
#define ilKeyColor ilKeyColour
|
||||
|
||||
#define imemclear(x,y) memset(x,0,y);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __IL_H__
|
||||
#endif // __il_h__
|
||||
205
DevILSDK/include/IL/il_wrap.h
Normal file
@ -0,0 +1,205 @@
|
||||
#ifndef WRAPPER_H
|
||||
#define WRAPPER_H
|
||||
|
||||
/*#include <il/il.h>
|
||||
#include <il/ilu.h>*/
|
||||
#include <IL/ilut.h> // Probably only have to #include this one
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#ifndef _IL_WRAP_BUILD_LIB
|
||||
#pragma comment(lib, "il_wrap.lib")
|
||||
#endif
|
||||
#endif
|
||||
|
||||
class ilImage
|
||||
{
|
||||
public:
|
||||
ilImage();
|
||||
ilImage(char *);
|
||||
ilImage(const ilImage &);
|
||||
virtual ~ilImage();
|
||||
|
||||
ILboolean Load(char *);
|
||||
ILboolean Load(char *, ILenum);
|
||||
ILboolean Save(char *);
|
||||
ILboolean Save(char *, ILenum);
|
||||
|
||||
|
||||
// ImageLib functions
|
||||
ILboolean ActiveImage(ILuint);
|
||||
ILboolean ActiveLayer(ILuint);
|
||||
ILboolean ActiveMipmap(ILuint);
|
||||
ILboolean Clear(void);
|
||||
ILvoid ClearColour(ILclampf, ILclampf, ILclampf, ILclampf);
|
||||
ILboolean Convert(ILenum);
|
||||
ILboolean Copy(ILuint);
|
||||
ILboolean Default(void);
|
||||
ILboolean Flip(void);
|
||||
ILboolean SwapColours(void);
|
||||
ILboolean Resize(ILuint, ILuint, ILuint);
|
||||
ILboolean TexImage(ILuint, ILuint, ILuint, ILubyte, ILenum, ILenum, ILvoid*);
|
||||
|
||||
|
||||
// Image handling
|
||||
ILvoid Bind(void) const;
|
||||
ILvoid Bind(ILuint);
|
||||
ILvoid Close(void) { this->Delete(); }
|
||||
ILvoid Delete(void);
|
||||
ILvoid iGenBind();
|
||||
ILenum PaletteAlphaIndex();
|
||||
|
||||
// Image characteristics
|
||||
ILuint Width(void);
|
||||
ILuint Height(void);
|
||||
ILuint Depth(void);
|
||||
ILubyte Bpp(void);
|
||||
ILubyte Bitpp(void);
|
||||
ILenum PaletteType(void);
|
||||
ILenum Format(void);
|
||||
ILenum Type(void);
|
||||
ILuint NumImages(void);
|
||||
ILuint NumMipmaps(void);
|
||||
ILuint GetId(void) const;
|
||||
ILenum GetOrigin(void);
|
||||
ILubyte *GetData(void);
|
||||
ILubyte *GetPalette(void);
|
||||
|
||||
|
||||
// Rendering
|
||||
ILuint BindImage(void);
|
||||
ILuint BindImage(ILenum);
|
||||
|
||||
|
||||
// Operators
|
||||
ilImage& operator = (ILuint);
|
||||
ilImage& operator = (const ilImage &);
|
||||
|
||||
|
||||
protected:
|
||||
ILuint Id;
|
||||
|
||||
private:
|
||||
ILvoid iStartUp();
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
class ilFilters
|
||||
{
|
||||
public:
|
||||
static ILboolean Alienify(ilImage &);
|
||||
static ILboolean BlurAvg(ilImage &, ILuint Iter);
|
||||
static ILboolean BlurGaussian(ilImage &, ILuint Iter);
|
||||
static ILboolean Contrast(ilImage &, ILfloat Contrast);
|
||||
static ILboolean EdgeDetectE(ilImage &);
|
||||
static ILboolean EdgeDetectP(ilImage &);
|
||||
static ILboolean EdgeDetectS(ilImage &);
|
||||
static ILboolean Emboss(ilImage &);
|
||||
static ILboolean Gamma(ilImage &, ILfloat Gamma);
|
||||
static ILboolean Negative(ilImage &);
|
||||
static ILboolean Noisify(ilImage &, ILubyte Factor);
|
||||
static ILboolean Pixelize(ilImage &, ILuint PixSize);
|
||||
static ILboolean Saturate(ilImage &, ILfloat Saturation);
|
||||
static ILboolean Saturate(ilImage &, ILfloat r, ILfloat g, ILfloat b, ILfloat Saturation);
|
||||
static ILboolean ScaleColours(ilImage &, ILfloat r, ILfloat g, ILfloat b);
|
||||
static ILboolean Sharpen(ilImage &, ILfloat Factor, ILuint Iter);
|
||||
};
|
||||
|
||||
|
||||
#ifdef ILUT_USE_OPENGL
|
||||
class ilOgl
|
||||
{
|
||||
public:
|
||||
static ILvoid Init(void);
|
||||
static GLuint BindTex(ilImage &);
|
||||
static ILboolean Upload(ilImage &, ILuint);
|
||||
static GLuint Mipmap(ilImage &);
|
||||
static ILboolean Screen(void);
|
||||
static ILboolean Screenie(void);
|
||||
};
|
||||
#endif//ILUT_USE_OPENGL
|
||||
|
||||
|
||||
#ifdef ILUT_USE_ALLEGRO
|
||||
class ilAlleg
|
||||
{
|
||||
public:
|
||||
static ILvoid Init(void);
|
||||
static BITMAP *Convert(ilImage &);
|
||||
};
|
||||
#endif//ILUT_USE_ALLEGRO
|
||||
|
||||
|
||||
#ifdef ILUT_USE_WIN32
|
||||
class ilWin32
|
||||
{
|
||||
public:
|
||||
static ILvoid Init(void);
|
||||
static HBITMAP Convert(ilImage &);
|
||||
static ILboolean GetClipboard(ilImage &);
|
||||
static ILvoid GetInfo(ilImage &, BITMAPINFO *Info);
|
||||
static ILubyte *GetPadData(ilImage &);
|
||||
static HPALETTE GetPal(ilImage &);
|
||||
static ILboolean GetResource(ilImage &, HINSTANCE hInst, ILint ID, char *ResourceType);
|
||||
static ILboolean GetResource(ilImage &, HINSTANCE hInst, ILint ID, char *ResourceType, ILenum Type);
|
||||
static ILboolean SetClipboard(ilImage &);
|
||||
};
|
||||
#endif//ILUT_USE_WIN32
|
||||
|
||||
|
||||
class ilValidate
|
||||
{
|
||||
public:
|
||||
static ILboolean Valid(ILenum, char *);
|
||||
static ILboolean Valid(ILenum, FILE *);
|
||||
static ILboolean Valid(ILenum, ILvoid *, ILuint);
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
|
||||
class ilState
|
||||
{
|
||||
public:
|
||||
static ILboolean Disable(ILenum);
|
||||
static ILboolean Enable(ILenum);
|
||||
static ILvoid Get(ILenum, ILboolean &);
|
||||
static ILvoid Get(ILenum, ILint &);
|
||||
static ILboolean GetBool(ILenum);
|
||||
static ILint GetInt(ILenum);
|
||||
static const char *GetString(ILenum);
|
||||
static ILboolean IsDisabled(ILenum);
|
||||
static ILboolean IsEnabled(ILenum);
|
||||
static ILboolean Origin(ILenum);
|
||||
static ILvoid Pop(void);
|
||||
static ILvoid Push(ILuint);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
|
||||
class ilError
|
||||
{
|
||||
public:
|
||||
static ILvoid Check(ILvoid (*Callback)(const char*));
|
||||
static ILvoid Check(ILvoid (*Callback)(ILenum));
|
||||
static ILenum Get(void);
|
||||
static const char *String(void);
|
||||
static const char *String(ILenum);
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif//WRAPPER_H
|
||||
198
DevILSDK/include/IL/ilu.h
Normal file
@ -0,0 +1,198 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// ImageLib Utility Sources
|
||||
// Copyright (C) 2000-2017 by Denton Woods
|
||||
// Last modified: 03/07/2009
|
||||
//
|
||||
// Filename: IL/ilu.h
|
||||
//
|
||||
// Description: The main include file for ILU
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Doxygen comment
|
||||
/*! \file ilu.h
|
||||
The main include file for ILU
|
||||
*/
|
||||
|
||||
#ifndef __ilu_h_
|
||||
#ifndef __ILU_H__
|
||||
|
||||
#define __ilu_h_
|
||||
#define __ILU_H__
|
||||
|
||||
#include "DevILSDK/include/IL/il.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
#if (defined(IL_USE_PRAGMA_LIBS)) && (!defined(_IL_BUILD_LIBRARY))
|
||||
#if defined(_MSC_VER) || defined(__BORLANDC__)
|
||||
#pragma comment(lib, "ILU.lib")
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#define ILU_VERSION_1_8_0 1
|
||||
#define ILU_VERSION 180
|
||||
|
||||
|
||||
#define ILU_FILTER 0x2600
|
||||
#define ILU_NEAREST 0x2601
|
||||
#define ILU_LINEAR 0x2602
|
||||
#define ILU_BILINEAR 0x2603
|
||||
#define ILU_SCALE_BOX 0x2604
|
||||
#define ILU_SCALE_TRIANGLE 0x2605
|
||||
#define ILU_SCALE_BELL 0x2606
|
||||
#define ILU_SCALE_BSPLINE 0x2607
|
||||
#define ILU_SCALE_LANCZOS3 0x2608
|
||||
#define ILU_SCALE_MITCHELL 0x2609
|
||||
|
||||
|
||||
// Error types
|
||||
#define ILU_INVALID_ENUM 0x0501
|
||||
#define ILU_OUT_OF_MEMORY 0x0502
|
||||
#define ILU_INTERNAL_ERROR 0x0504
|
||||
#define ILU_INVALID_VALUE 0x0505
|
||||
#define ILU_ILLEGAL_OPERATION 0x0506
|
||||
#define ILU_INVALID_PARAM 0x0509
|
||||
|
||||
|
||||
// Values
|
||||
#define ILU_PLACEMENT 0x0700
|
||||
#define ILU_LOWER_LEFT 0x0701
|
||||
#define ILU_LOWER_RIGHT 0x0702
|
||||
#define ILU_UPPER_LEFT 0x0703
|
||||
#define ILU_UPPER_RIGHT 0x0704
|
||||
#define ILU_CENTER 0x0705
|
||||
#define ILU_CONVOLUTION_MATRIX 0x0710
|
||||
|
||||
#define ILU_VERSION_NUM IL_VERSION_NUM
|
||||
#define ILU_VENDOR IL_VENDOR
|
||||
|
||||
|
||||
// Languages
|
||||
#define ILU_ENGLISH 0x0800
|
||||
#define ILU_ARABIC 0x0801
|
||||
#define ILU_DUTCH 0x0802
|
||||
#define ILU_JAPANESE 0x0803
|
||||
#define ILU_SPANISH 0x0804
|
||||
#define ILU_GERMAN 0x0805
|
||||
#define ILU_FRENCH 0x0806
|
||||
#define ILU_ITALIAN 0x0807
|
||||
|
||||
|
||||
// Filters
|
||||
/*
|
||||
#define ILU_FILTER_BLUR 0x0803
|
||||
#define ILU_FILTER_GAUSSIAN_3x3 0x0804
|
||||
#define ILU_FILTER_GAUSSIAN_5X5 0x0805
|
||||
#define ILU_FILTER_EMBOSS1 0x0807
|
||||
#define ILU_FILTER_EMBOSS2 0x0808
|
||||
#define ILU_FILTER_LAPLACIAN1 0x080A
|
||||
#define ILU_FILTER_LAPLACIAN2 0x080B
|
||||
#define ILU_FILTER_LAPLACIAN3 0x080C
|
||||
#define ILU_FILTER_LAPLACIAN4 0x080D
|
||||
#define ILU_FILTER_SHARPEN1 0x080E
|
||||
#define ILU_FILTER_SHARPEN2 0x080F
|
||||
#define ILU_FILTER_SHARPEN3 0x0810
|
||||
*/
|
||||
|
||||
|
||||
typedef struct ILinfo
|
||||
{
|
||||
ILuint Id; // the image's id
|
||||
ILubyte *Data; // the image's data
|
||||
ILuint Width; // the image's width
|
||||
ILuint Height; // the image's height
|
||||
ILuint Depth; // the image's depth
|
||||
ILubyte Bpp; // bytes per pixel (not bits) of the image
|
||||
ILuint SizeOfData; // the total size of the data (in bytes)
|
||||
ILenum Format; // image format (in IL enum style)
|
||||
ILenum Type; // image type (in IL enum style)
|
||||
ILenum Origin; // origin of the image
|
||||
ILubyte *Palette; // the image's palette
|
||||
ILenum PalType; // palette type
|
||||
ILuint PalSize; // palette size
|
||||
ILenum CubeFlags; // flags for what cube map sides are present
|
||||
ILuint NumNext; // number of images following
|
||||
ILuint NumMips; // number of mipmaps
|
||||
ILuint NumLayers; // number of layers
|
||||
} ILinfo;
|
||||
|
||||
|
||||
typedef struct ILpointf {
|
||||
ILfloat x;
|
||||
ILfloat y;
|
||||
} ILpointf;
|
||||
|
||||
typedef struct ILpointi {
|
||||
ILint x;
|
||||
ILint y;
|
||||
} ILpointi;
|
||||
|
||||
ILAPI ILboolean ILAPIENTRY iluAlienify(void);
|
||||
ILAPI ILboolean ILAPIENTRY iluBlurAvg(ILuint Iter);
|
||||
ILAPI ILboolean ILAPIENTRY iluBlurGaussian(ILuint Iter);
|
||||
ILAPI ILboolean ILAPIENTRY iluBuildMipmaps(void);
|
||||
ILAPI ILuint ILAPIENTRY iluColoursUsed(void);
|
||||
ILAPI ILboolean ILAPIENTRY iluCompareImage(ILuint Comp);
|
||||
ILAPI ILboolean ILAPIENTRY iluContrast(ILfloat Contrast);
|
||||
ILAPI ILboolean ILAPIENTRY iluCrop(ILuint XOff, ILuint YOff, ILuint ZOff, ILuint Width, ILuint Height, ILuint Depth);
|
||||
ILAPI void ILAPIENTRY iluDeleteImage(ILuint Id); // Deprecated
|
||||
ILAPI ILboolean ILAPIENTRY iluEdgeDetectE(void);
|
||||
ILAPI ILboolean ILAPIENTRY iluEdgeDetectP(void);
|
||||
ILAPI ILboolean ILAPIENTRY iluEdgeDetectS(void);
|
||||
ILAPI ILboolean ILAPIENTRY iluEmboss(void);
|
||||
ILAPI ILboolean ILAPIENTRY iluEnlargeCanvas(ILuint Width, ILuint Height, ILuint Depth);
|
||||
ILAPI ILboolean ILAPIENTRY iluEnlargeImage(ILfloat XDim, ILfloat YDim, ILfloat ZDim);
|
||||
ILAPI ILboolean ILAPIENTRY iluEqualize(void);
|
||||
ILAPI ILboolean ILAPIENTRY iluEqualize2(void);
|
||||
ILAPI ILconst_string ILAPIENTRY iluErrorString(ILenum Error);
|
||||
ILAPI ILboolean ILAPIENTRY iluConvolution(ILint *matrix, ILint scale, ILint bias);
|
||||
ILAPI ILboolean ILAPIENTRY iluFlipImage(void);
|
||||
ILAPI ILboolean ILAPIENTRY iluGammaCorrect(ILfloat Gamma);
|
||||
ILAPI ILuint ILAPIENTRY iluGenImage(void); // Deprecated
|
||||
ILAPI void ILAPIENTRY iluGetImageInfo(ILinfo *Info);
|
||||
ILAPI ILint ILAPIENTRY iluGetInteger(ILenum Mode);
|
||||
ILAPI void ILAPIENTRY iluGetIntegerv(ILenum Mode, ILint *Param);
|
||||
ILAPI ILstring ILAPIENTRY iluGetString(ILenum StringName);
|
||||
ILAPI void ILAPIENTRY iluImageParameter(ILenum PName, ILenum Param);
|
||||
ILAPI void ILAPIENTRY iluInit(void);
|
||||
ILAPI ILboolean ILAPIENTRY iluInvertAlpha(void);
|
||||
ILAPI ILuint ILAPIENTRY iluLoadImage(ILconst_string FileName);
|
||||
ILAPI ILboolean ILAPIENTRY iluMirror(void);
|
||||
ILAPI ILboolean ILAPIENTRY iluNegative(void);
|
||||
ILAPI ILboolean ILAPIENTRY iluNoisify(ILclampf Tolerance);
|
||||
ILAPI ILboolean ILAPIENTRY iluPixelize(ILuint PixSize);
|
||||
ILAPI void ILAPIENTRY iluRegionfv(ILpointf *Points, ILuint n);
|
||||
ILAPI void ILAPIENTRY iluRegioniv(ILpointi *Points, ILuint n);
|
||||
ILAPI ILboolean ILAPIENTRY iluReplaceColour(ILubyte Red, ILubyte Green, ILubyte Blue, ILfloat Tolerance);
|
||||
ILAPI ILboolean ILAPIENTRY iluRotate(ILfloat Angle);
|
||||
ILAPI ILboolean ILAPIENTRY iluRotate3D(ILfloat x, ILfloat y, ILfloat z, ILfloat Angle);
|
||||
ILAPI ILboolean ILAPIENTRY iluSaturate1f(ILfloat Saturation);
|
||||
ILAPI ILboolean ILAPIENTRY iluSaturate4f(ILfloat r, ILfloat g, ILfloat b, ILfloat Saturation);
|
||||
ILAPI ILboolean ILAPIENTRY iluScale(ILuint Width, ILuint Height, ILuint Depth);
|
||||
ILAPI ILboolean ILAPIENTRY iluScaleAlpha(ILfloat scale);
|
||||
ILAPI ILboolean ILAPIENTRY iluScaleColours(ILfloat r, ILfloat g, ILfloat b);
|
||||
ILAPI ILboolean ILAPIENTRY iluSepia(void);
|
||||
ILAPI ILboolean ILAPIENTRY iluSetLanguage(ILenum Language);
|
||||
ILAPI ILboolean ILAPIENTRY iluSharpen(ILfloat Factor, ILuint Iter);
|
||||
ILAPI ILboolean ILAPIENTRY iluSwapColours(void);
|
||||
ILAPI ILboolean ILAPIENTRY iluWave(ILfloat Angle);
|
||||
|
||||
#define iluColorsUsed iluColoursUsed
|
||||
#define iluSwapColors iluSwapColours
|
||||
#define iluReplaceColor iluReplaceColour
|
||||
#define iluScaleColor iluScaleColour
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __ILU_H__
|
||||
#endif // __ilu_h_
|
||||
25
DevILSDK/include/IL/ilu_region.h
Normal file
@ -0,0 +1,25 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// ImageLib Utility Sources
|
||||
// Copyright (C) 2000-2002 by Denton Woods
|
||||
// Last modified: 07/09/2002 <--Y2K Compliant! =]
|
||||
//
|
||||
// Filename: src-ILU/src/ilu_region.h
|
||||
//
|
||||
// Description: Creates an image region.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef ILU_REGION_H
|
||||
#define ILU_REGION_H
|
||||
|
||||
typedef struct Edge
|
||||
{
|
||||
ILint yUpper;
|
||||
ILfloat xIntersect, dxPerScan;
|
||||
struct Edge *next;
|
||||
} Edge;
|
||||
|
||||
|
||||
#endif//ILU_REGION_H
|
||||
|
||||
354
DevILSDK/include/IL/ilut.h
Normal file
@ -0,0 +1,354 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// ImageLib Utility Toolkit Sources
|
||||
// Copyright (C) 2000-2017 by Denton Woods
|
||||
// Last modified: 03/07/2009
|
||||
//
|
||||
// Filename: IL/ilut.h
|
||||
//
|
||||
// Description: The main include file for ILUT
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Doxygen comment
|
||||
/*! \file ilut.h
|
||||
The main include file for ILUT
|
||||
*/
|
||||
|
||||
#ifndef __ilut_h_
|
||||
#ifndef __ILUT_H__
|
||||
|
||||
#define __ilut_h_
|
||||
#define __ILUT_H__
|
||||
|
||||
#include "DevILSDK/include/IL/il.h"
|
||||
#include "DevILSDK/include/IL/ilu.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Defines
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#define ILUT_VERSION_1_8_0 1
|
||||
#define ILUT_VERSION 180
|
||||
|
||||
|
||||
// Attribute Bits
|
||||
#define ILUT_OPENGL_BIT 0x00000001
|
||||
#define ILUT_D3D_BIT 0x00000002
|
||||
#define ILUT_ALL_ATTRIB_BITS 0x000FFFFF
|
||||
|
||||
|
||||
// Error Types
|
||||
#define ILUT_INVALID_ENUM 0x0501
|
||||
#define ILUT_OUT_OF_MEMORY 0x0502
|
||||
#define ILUT_INVALID_VALUE 0x0505
|
||||
#define ILUT_ILLEGAL_OPERATION 0x0506
|
||||
#define ILUT_INVALID_PARAM 0x0509
|
||||
#define ILUT_COULD_NOT_OPEN_FILE 0x050A
|
||||
#define ILUT_STACK_OVERFLOW 0x050E
|
||||
#define ILUT_STACK_UNDERFLOW 0x050F
|
||||
#define ILUT_BAD_DIMENSIONS 0x0511
|
||||
#define ILUT_NOT_SUPPORTED 0x0550
|
||||
|
||||
|
||||
// State Definitions
|
||||
#define ILUT_PALETTE_MODE 0x0600
|
||||
#define ILUT_OPENGL_CONV 0x0610
|
||||
#define ILUT_D3D_MIPLEVELS 0x0620
|
||||
#define ILUT_MAXTEX_WIDTH 0x0630
|
||||
#define ILUT_MAXTEX_HEIGHT 0x0631
|
||||
#define ILUT_MAXTEX_DEPTH 0x0632
|
||||
#define ILUT_GL_USE_S3TC 0x0634
|
||||
#define ILUT_D3D_USE_DXTC 0x0634
|
||||
#define ILUT_GL_GEN_S3TC 0x0635
|
||||
#define ILUT_D3D_GEN_DXTC 0x0635
|
||||
#define ILUT_S3TC_FORMAT 0x0705
|
||||
#define ILUT_DXTC_FORMAT 0x0705
|
||||
#define ILUT_D3D_POOL 0x0706
|
||||
#define ILUT_D3D_ALPHA_KEY_COLOR 0x0707
|
||||
#define ILUT_D3D_ALPHA_KEY_COLOUR 0x0707
|
||||
#define ILUT_FORCE_INTEGER_FORMAT 0x0636
|
||||
|
||||
//This new state does automatic texture target detection
|
||||
//if enabled. Currently, only cubemap detection is supported.
|
||||
//if the current image is no cubemap, the 2d texture is chosen.
|
||||
#define ILUT_GL_AUTODETECT_TEXTURE_TARGET 0x0807
|
||||
|
||||
|
||||
// Values
|
||||
#define ILUT_VERSION_NUM IL_VERSION_NUM
|
||||
#define ILUT_VENDOR IL_VENDOR
|
||||
|
||||
// The different rendering api's...more to be added later?
|
||||
#define ILUT_OPENGL 0
|
||||
#define ILUT_ALLEGRO 1
|
||||
#define ILUT_WIN32 2
|
||||
#define ILUT_DIRECT3D8 3
|
||||
#define ILUT_DIRECT3D9 4
|
||||
#define ILUT_X11 5
|
||||
#define ILUT_DIRECT3D10 6
|
||||
|
||||
|
||||
#if (defined(_WIN32) || defined(_WIN64))
|
||||
#if (defined(IL_USE_PRAGMA_LIBS)) && (!defined(_IL_BUILD_LIBRARY))
|
||||
#if defined(_MSC_VER) || defined(__BORLANDC__)
|
||||
#pragma comment(lib, "ILUT.lib")
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <DevILSDK/include/IL/ilut_config.h>
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
//////////////
|
||||
// OpenGL
|
||||
//////////////
|
||||
|
||||
#ifdef ILUT_USE_OPENGL
|
||||
#if defined(_MSC_VER) || defined(_WIN32)
|
||||
//#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#endif//_MSC_VER
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <OpenGL/gl.h>
|
||||
#include <OpenGL/glu.h>
|
||||
#else
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
#endif//__APPLE__
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef ILUT_USE_WIN32
|
||||
//#define WIN32_LEAN_AND_MEAN
|
||||
#ifdef _DEBUG
|
||||
#define _CRTDBG_MAP_ALLOC
|
||||
#include <stdlib.h>
|
||||
#ifndef _WIN32_WCE
|
||||
#include <crtdbg.h>
|
||||
#endif
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
// If we can avoid including these in all cases thing tend to break less
|
||||
// and we can keep all of them defined as available
|
||||
//
|
||||
// Kriss
|
||||
//
|
||||
|
||||
// ImageLib Utility Toolkit's Allegro Functions
|
||||
#ifdef ILUT_USE_ALLEGRO
|
||||
// #include <allegro.h>
|
||||
#endif//ILUT_USE_ALLEGRO
|
||||
|
||||
#ifdef ILUT_USE_SDL
|
||||
// #include <SDL.h>
|
||||
#endif
|
||||
|
||||
#ifdef ILUT_USE_DIRECTX8
|
||||
#include <d3d8.h>
|
||||
#endif//ILUT_USE_DIRECTX9
|
||||
|
||||
#ifdef ILUT_USE_DIRECTX9
|
||||
#include <d3d9.h>
|
||||
#endif//ILUT_USE_DIRECTX9
|
||||
|
||||
#ifdef ILUT_USE_DIRECTX10
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4201) // Disables 'nonstandard extension used : nameless struct/union' warning
|
||||
#include <rpcsal.h>
|
||||
#include <sal.h>
|
||||
#include <d3d10.h>
|
||||
#pragma warning(pop)
|
||||
#endif//ILUT_USE_DIRECTX10
|
||||
|
||||
#ifdef ILUT_USE_X11
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#ifdef ILUT_USE_XSHM
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/shm.h>
|
||||
#include <X11/extensions/XShm.h>
|
||||
#endif//ILUT_USE_XSHM
|
||||
#endif//ILUT_USE_X11
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Functions
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// ImageLib Utility Toolkit Functions
|
||||
ILAPI ILboolean ILAPIENTRY ilutDisable(ILenum Mode);
|
||||
ILAPI ILboolean ILAPIENTRY ilutEnable(ILenum Mode);
|
||||
ILAPI ILboolean ILAPIENTRY ilutGetBoolean(ILenum Mode);
|
||||
ILAPI void ILAPIENTRY ilutGetBooleanv(ILenum Mode, ILboolean *Param);
|
||||
ILAPI ILint ILAPIENTRY ilutGetInteger(ILenum Mode);
|
||||
ILAPI void ILAPIENTRY ilutGetIntegerv(ILenum Mode, ILint *Param);
|
||||
ILAPI ILstring ILAPIENTRY ilutGetString(ILenum StringName);
|
||||
ILAPI void ILAPIENTRY ilutInit(void);
|
||||
ILAPI ILboolean ILAPIENTRY ilutIsDisabled(ILenum Mode);
|
||||
ILAPI ILboolean ILAPIENTRY ilutIsEnabled(ILenum Mode);
|
||||
ILAPI void ILAPIENTRY ilutPopAttrib(void);
|
||||
ILAPI void ILAPIENTRY ilutPushAttrib(ILuint Bits);
|
||||
ILAPI void ILAPIENTRY ilutSetInteger(ILenum Mode, ILint Param);
|
||||
|
||||
ILAPI ILboolean ILAPIENTRY ilutRenderer(ILenum Renderer);
|
||||
|
||||
|
||||
// ImageLib Utility Toolkit's OpenGL Functions
|
||||
#ifdef ILUT_USE_OPENGL
|
||||
ILAPI GLuint ILAPIENTRY ilutGLBindTexImage();
|
||||
ILAPI GLuint ILAPIENTRY ilutGLBindMipmaps(void);
|
||||
ILAPI ILboolean ILAPIENTRY ilutGLBuildMipmaps(void);
|
||||
ILAPI GLuint ILAPIENTRY ilutGLLoadImage(ILstring FileName);
|
||||
ILAPI ILboolean ILAPIENTRY ilutGLScreen(void);
|
||||
ILAPI ILboolean ILAPIENTRY ilutGLScreenie(void);
|
||||
ILAPI ILboolean ILAPIENTRY ilutGLSaveImage(ILstring FileName, GLuint TexID);
|
||||
ILAPI ILboolean ILAPIENTRY ilutGLSubTex2D(GLuint TexID, ILuint XOff, ILuint YOff);
|
||||
ILAPI ILboolean ILAPIENTRY ilutGLSubTex3D(GLuint TexID, ILuint XOff, ILuint YOff, ILuint ZOff);
|
||||
ILAPI ILboolean ILAPIENTRY ilutGLSetTex2D(GLuint TexID);
|
||||
ILAPI ILboolean ILAPIENTRY ilutGLSetTex3D(GLuint TexID);
|
||||
ILAPI ILboolean ILAPIENTRY ilutGLTexImage(GLuint Level);
|
||||
ILAPI ILboolean ILAPIENTRY ilutGLSubTex(GLuint TexID, ILuint XOff, ILuint YOff);
|
||||
|
||||
ILAPI ILboolean ILAPIENTRY ilutGLSetTex(GLuint TexID); // Deprecated - use ilutGLSetTex2D.
|
||||
ILAPI ILboolean ILAPIENTRY ilutGLSubTex(GLuint TexID, ILuint XOff, ILuint YOff); // Use ilutGLSubTex2D.
|
||||
#endif//ILUT_USE_OPENGL
|
||||
|
||||
|
||||
// ImageLib Utility Toolkit's Allegro Functions
|
||||
#ifdef ILUT_USE_ALLEGRO
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include <allegro.h>
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
ILAPI BITMAP* ILAPIENTRY ilutAllegLoadImage(ILstring FileName);
|
||||
ILAPI BITMAP* ILAPIENTRY ilutConvertToAlleg(PALETTE Pal);
|
||||
#endif//ILUT_USE_ALLEGRO
|
||||
|
||||
|
||||
// ImageLib Utility Toolkit's SDL Functions
|
||||
#ifdef ILUT_USE_SDL
|
||||
ILAPI struct SDL_Surface* ILAPIENTRY ilutConvertToSDLSurface(unsigned int flags);
|
||||
ILAPI struct SDL_Surface* ILAPIENTRY ilutSDLSurfaceLoadImage(ILstring FileName);
|
||||
ILAPI ILboolean ILAPIENTRY ilutSDLSurfaceFromBitmap(struct SDL_Surface *Bitmap);
|
||||
#endif//ILUT_USE_SDL
|
||||
|
||||
|
||||
// ImageLib Utility Toolkit's BeOS Functions
|
||||
#ifdef ILUT_USE_BEOS
|
||||
ILAPI BBitmap ILAPIENTRY ilutConvertToBBitmap(void);
|
||||
#endif//ILUT_USE_BEOS
|
||||
|
||||
|
||||
// ImageLib Utility Toolkit's Win32 GDI Functions
|
||||
#ifdef ILUT_USE_WIN32
|
||||
ILAPI HBITMAP ILAPIENTRY ilutConvertToHBitmap(HDC hDC);
|
||||
ILAPI HBITMAP ILAPIENTRY ilutConvertSliceToHBitmap(HDC hDC, ILuint slice);
|
||||
ILAPI void ILAPIENTRY ilutFreePaddedData(ILubyte *Data);
|
||||
ILAPI void ILAPIENTRY ilutGetBmpInfo(BITMAPINFO *Info);
|
||||
ILAPI HPALETTE ILAPIENTRY ilutGetHPal(void);
|
||||
ILAPI ILubyte* ILAPIENTRY ilutGetPaddedData(void);
|
||||
ILAPI ILboolean ILAPIENTRY ilutGetWinClipboard(void);
|
||||
ILAPI ILboolean ILAPIENTRY ilutLoadResource(HINSTANCE hInst, ILint ID, ILstring ResourceType, ILenum Type);
|
||||
ILAPI ILboolean ILAPIENTRY ilutSetHBitmap(HBITMAP Bitmap);
|
||||
ILAPI ILboolean ILAPIENTRY ilutSetHPal(HPALETTE Pal);
|
||||
ILAPI ILboolean ILAPIENTRY ilutSetWinClipboard(void);
|
||||
ILAPI HBITMAP ILAPIENTRY ilutWinLoadImage(ILstring FileName, HDC hDC);
|
||||
ILAPI ILboolean ILAPIENTRY ilutWinLoadUrl(ILstring Url);
|
||||
ILAPI ILboolean ILAPIENTRY ilutWinPrint(ILuint XPos, ILuint YPos, ILuint Width, ILuint Height, HDC hDC);
|
||||
ILAPI ILboolean ILAPIENTRY ilutWinSaveImage(ILstring FileName, HBITMAP Bitmap);
|
||||
#endif//ILUT_USE_WIN32
|
||||
|
||||
// ImageLib Utility Toolkit's DirectX 8 Functions
|
||||
#ifdef ILUT_USE_DIRECTX8
|
||||
// ILAPI void ILAPIENTRY ilutD3D8MipFunc(ILuint NumLevels);
|
||||
ILAPI struct IDirect3DTexture8* ILAPIENTRY ilutD3D8Texture(struct IDirect3DDevice8 *Device);
|
||||
ILAPI struct IDirect3DVolumeTexture8* ILAPIENTRY ilutD3D8VolumeTexture(struct IDirect3DDevice8 *Device);
|
||||
ILAPI ILboolean ILAPIENTRY ilutD3D8TexFromFile(struct IDirect3DDevice8 *Device, char *FileName, struct IDirect3DTexture8 **Texture);
|
||||
ILAPI ILboolean ILAPIENTRY ilutD3D8VolTexFromFile(struct IDirect3DDevice8 *Device, char *FileName, struct IDirect3DVolumeTexture8 **Texture);
|
||||
ILAPI ILboolean ILAPIENTRY ilutD3D8TexFromFileInMemory(struct IDirect3DDevice8 *Device, void *Lump, ILuint Size, struct IDirect3DTexture8 **Texture);
|
||||
ILAPI ILboolean ILAPIENTRY ilutD3D8VolTexFromFileInMemory(struct IDirect3DDevice8 *Device, void *Lump, ILuint Size, struct IDirect3DVolumeTexture8 **Texture);
|
||||
ILAPI ILboolean ILAPIENTRY ilutD3D8TexFromFileHandle(struct IDirect3DDevice8 *Device, ILHANDLE File, struct IDirect3DTexture8 **Texture);
|
||||
ILAPI ILboolean ILAPIENTRY ilutD3D8VolTexFromFileHandle(struct IDirect3DDevice8 *Device, ILHANDLE File, struct IDirect3DVolumeTexture8 **Texture);
|
||||
// These two are not tested yet.
|
||||
ILAPI ILboolean ILAPIENTRY ilutD3D8TexFromResource(struct IDirect3DDevice8 *Device, HMODULE SrcModule, char *SrcResource, struct IDirect3DTexture8 **Texture);
|
||||
ILAPI ILboolean ILAPIENTRY ilutD3D8VolTexFromResource(struct IDirect3DDevice8 *Device, HMODULE SrcModule, char *SrcResource, struct IDirect3DVolumeTexture8 **Texture);
|
||||
ILAPI ILboolean ILAPIENTRY ilutD3D8LoadSurface(struct IDirect3DDevice8 *Device, struct IDirect3DSurface8 *Surface);
|
||||
#endif//ILUT_USE_DIRECTX8
|
||||
|
||||
#ifdef ILUT_USE_DIRECTX9
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4115) // Disables 'named type definition in parentheses' warning
|
||||
// ILAPI void ILAPIENTRY ilutD3D9MipFunc(ILuint NumLevels);
|
||||
ILAPI struct IDirect3DTexture9* ILAPIENTRY ilutD3D9Texture (struct IDirect3DDevice9* Device);
|
||||
ILAPI struct IDirect3DVolumeTexture9* ILAPIENTRY ilutD3D9VolumeTexture (struct IDirect3DDevice9* Device);
|
||||
ILAPI struct IDirect3DCubeTexture9* ILAPIENTRY ilutD3D9CubeTexture (struct IDirect3DDevice9* Device);
|
||||
|
||||
ILAPI ILboolean ILAPIENTRY ilutD3D9CubeTexFromFile(struct IDirect3DDevice9 *Device, ILconst_string FileName, struct IDirect3DCubeTexture9 **Texture);
|
||||
ILAPI ILboolean ILAPIENTRY ilutD3D9CubeTexFromFileInMemory(struct IDirect3DDevice9 *Device, void *Lump, ILuint Size, struct IDirect3DCubeTexture9 **Texture);
|
||||
ILAPI ILboolean ILAPIENTRY ilutD3D9CubeTexFromFileHandle(struct IDirect3DDevice9 *Device, ILHANDLE File, struct IDirect3DCubeTexture9 **Texture);
|
||||
ILAPI ILboolean ILAPIENTRY ilutD3D9CubeTexFromResource(struct IDirect3DDevice9 *Device, HMODULE SrcModule, ILconst_string SrcResource, struct IDirect3DCubeTexture9 **Texture);
|
||||
|
||||
ILAPI ILboolean ILAPIENTRY ilutD3D9TexFromFile(struct IDirect3DDevice9 *Device, ILconst_string FileName, struct IDirect3DTexture9 **Texture);
|
||||
ILAPI ILboolean ILAPIENTRY ilutD3D9VolTexFromFile(struct IDirect3DDevice9 *Device, ILconst_string FileName, struct IDirect3DVolumeTexture9 **Texture);
|
||||
ILAPI ILboolean ILAPIENTRY ilutD3D9TexFromFileInMemory(struct IDirect3DDevice9 *Device, void *Lump, ILuint Size, struct IDirect3DTexture9 **Texture);
|
||||
ILAPI ILboolean ILAPIENTRY ilutD3D9VolTexFromFileInMemory(struct IDirect3DDevice9 *Device, void *Lump, ILuint Size, struct IDirect3DVolumeTexture9 **Texture);
|
||||
ILAPI ILboolean ILAPIENTRY ilutD3D9TexFromFileHandle(struct IDirect3DDevice9 *Device, ILHANDLE File, struct IDirect3DTexture9 **Texture);
|
||||
ILAPI ILboolean ILAPIENTRY ilutD3D9VolTexFromFileHandle(struct IDirect3DDevice9 *Device, ILHANDLE File, struct IDirect3DVolumeTexture9 **Texture);
|
||||
|
||||
// These three are not tested yet.
|
||||
ILAPI ILboolean ILAPIENTRY ilutD3D9TexFromResource(struct IDirect3DDevice9 *Device, HMODULE SrcModule, ILconst_string SrcResource, struct IDirect3DTexture9 **Texture);
|
||||
ILAPI ILboolean ILAPIENTRY ilutD3D9VolTexFromResource(struct IDirect3DDevice9 *Device, HMODULE SrcModule, ILconst_string SrcResource, struct IDirect3DVolumeTexture9 **Texture);
|
||||
ILAPI ILboolean ILAPIENTRY ilutD3D9LoadSurface(struct IDirect3DDevice9 *Device, struct IDirect3DSurface9 *Surface);
|
||||
#pragma warning(pop)
|
||||
#endif//ILUT_USE_DIRECTX9
|
||||
|
||||
#ifdef ILUT_USE_DIRECTX10
|
||||
ILAPI ID3D10Texture2D* ILAPIENTRY ilutD3D10Texture(ID3D10Device *Device);
|
||||
ILAPI ILboolean ILAPIENTRY ilutD3D10TexFromFile(ID3D10Device *Device, ILconst_string FileName, ID3D10Texture2D **Texture);
|
||||
ILAPI ILboolean ILAPIENTRY ilutD3D10TexFromFileInMemory(ID3D10Device *Device, void *Lump, ILuint Size, ID3D10Texture2D **Texture);
|
||||
ILAPI ILboolean ILAPIENTRY ilutD3D10TexFromResource(ID3D10Device *Device, HMODULE SrcModule, ILconst_string SrcResource, ID3D10Texture2D **Texture);
|
||||
ILAPI ILboolean ILAPIENTRY ilutD3D10TexFromFileHandle(ID3D10Device *Device, ILHANDLE File, ID3D10Texture2D **Texture);
|
||||
#endif//ILUT_USE_DIRECTX10
|
||||
|
||||
|
||||
|
||||
#ifdef ILUT_USE_X11
|
||||
ILAPI XImage * ILAPIENTRY ilutXCreateImage( Display* );
|
||||
ILAPI Pixmap ILAPIENTRY ilutXCreatePixmap( Display*,Drawable );
|
||||
ILAPI XImage * ILAPIENTRY ilutXLoadImage( Display*,char* );
|
||||
ILAPI Pixmap ILAPIENTRY ilutXLoadPixmap( Display*,Drawable,char* );
|
||||
#ifdef ILUT_USE_XSHM
|
||||
ILAPI XImage * ILAPIENTRY ilutXShmCreateImage( Display*,XShmSegmentInfo* );
|
||||
ILAPI void ILAPIENTRY ilutXShmDestroyImage( Display*,XImage*,XShmSegmentInfo* );
|
||||
ILAPI Pixmap ILAPIENTRY ilutXShmCreatePixmap( Display*,Drawable,XShmSegmentInfo* );
|
||||
ILAPI void ILAPIENTRY ilutXShmFreePixmap( Display*,Pixmap,XShmSegmentInfo* );
|
||||
ILAPI XImage * ILAPIENTRY ilutXShmLoadImage( Display*,char*,XShmSegmentInfo* );
|
||||
ILAPI Pixmap ILAPIENTRY ilutXShmLoadPixmap( Display*,Drawable,char*,XShmSegmentInfo* );
|
||||
#endif//ILUT_USE_XSHM
|
||||
#endif//ILUT_USE_X11
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __ILUT_H__
|
||||
#endif // __ilut_h_
|
||||
26
DevILSDK/include/IL/ilut_config.h
Normal file
@ -0,0 +1,26 @@
|
||||
#ifndef __ILUT_CONFIG_H__
|
||||
#define __ILUT_CONFIG_H__
|
||||
|
||||
//#define IL_USE_PRAGMA_LIBS
|
||||
|
||||
// Supported APIs (ILUT)
|
||||
|
||||
//
|
||||
// sorry just
|
||||
// cant get this one to work under windows
|
||||
// have disabled for the now
|
||||
//
|
||||
// will look at it some more later
|
||||
//
|
||||
// Kriss
|
||||
//
|
||||
#undef ILUT_USE_ALLEGRO
|
||||
|
||||
#undef ILUT_USE_DIRECTX8
|
||||
//#define ILUT_USE_DIRECTX9
|
||||
//#define ILUT_USE_DIRECTX10
|
||||
#define ILUT_USE_OPENGL
|
||||
//#define ILUT_USE_SDL
|
||||
#define ILUT_USE_WIN32
|
||||
|
||||
#endif//__ILUT_CONFIG_H__
|
||||
393
DevILSDK/include/IL/luadevil.c
Normal file
@ -0,0 +1,393 @@
|
||||
/*
|
||||
** $Id: luadevil.c,v 1.1 2007-02-12 21:03:04 darkyojimbo Exp $
|
||||
** Lua stand-alone interpreter
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define lua_c
|
||||
|
||||
#include "lua.h"
|
||||
|
||||
#include "lauxlib.h"
|
||||
#include "lualib.h"
|
||||
|
||||
|
||||
|
||||
static lua_State *globalL = NULL;
|
||||
|
||||
static const char *progname = LUA_PROGNAME;
|
||||
|
||||
|
||||
|
||||
static void lstop (lua_State *L, lua_Debug *ar) {
|
||||
(void)ar; /* unused arg. */
|
||||
lua_sethook(L, NULL, 0, 0);
|
||||
luaL_error(L, "interrupted!");
|
||||
}
|
||||
|
||||
|
||||
static void laction (int i) {
|
||||
signal(i, SIG_DFL); /* if another SIGINT happens before lstop,
|
||||
terminate process (default action) */
|
||||
lua_sethook(globalL, lstop, LUA_MASKCALL | LUA_MASKRET | LUA_MASKCOUNT, 1);
|
||||
}
|
||||
|
||||
|
||||
static void print_usage (void) {
|
||||
fprintf(stderr,
|
||||
"usage: %s [options] [script [args]].\n"
|
||||
"Available options are:\n"
|
||||
" -e stat execute string " LUA_QL("stat") "\n"
|
||||
" -l name require library " LUA_QL("name") "\n"
|
||||
" -i enter interactive mode after executing " LUA_QL("script") "\n"
|
||||
" -v show version information\n"
|
||||
" -- stop handling options\n"
|
||||
" - execute stdin and stop handling options\n"
|
||||
,
|
||||
progname);
|
||||
fflush(stderr);
|
||||
}
|
||||
|
||||
|
||||
static void l_message (const char *pname, const char *msg) {
|
||||
if (pname) fprintf(stderr, "%s: ", pname);
|
||||
fprintf(stderr, "%s\n", msg);
|
||||
fflush(stderr);
|
||||
}
|
||||
|
||||
|
||||
static int report (lua_State *L, int status) {
|
||||
if (status && !lua_isnil(L, -1)) {
|
||||
const char *msg = lua_tostring(L, -1);
|
||||
if (msg == NULL) msg = "(error object is not a string)";
|
||||
l_message(progname, msg);
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
static int traceback (lua_State *L) {
|
||||
lua_getfield(L, LUA_GLOBALSINDEX, "debug");
|
||||
if (!lua_istable(L, -1)) {
|
||||
lua_pop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
lua_getfield(L, -1, "traceback");
|
||||
if (!lua_isfunction(L, -1)) {
|
||||
lua_pop(L, 2);
|
||||
return 1;
|
||||
}
|
||||
lua_pushvalue(L, 1); /* pass error message */
|
||||
lua_pushinteger(L, 2); /* skip this function and traceback */
|
||||
lua_call(L, 2, 1); /* call debug.traceback */
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static int docall (lua_State *L, int narg, int clear) {
|
||||
int status;
|
||||
int base = lua_gettop(L) - narg; /* function index */
|
||||
lua_pushcfunction(L, traceback); /* push traceback function */
|
||||
lua_insert(L, base); /* put it under chunk and args */
|
||||
signal(SIGINT, laction);
|
||||
status = lua_pcall(L, narg, (clear ? 0 : LUA_MULTRET), base);
|
||||
signal(SIGINT, SIG_DFL);
|
||||
lua_remove(L, base); /* remove traceback function */
|
||||
/* force a complete garbage collection in case of errors */
|
||||
if (status != 0) lua_gc(L, LUA_GCCOLLECT, 0);
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
static void print_version (void) {
|
||||
l_message(NULL, LUA_RELEASE " " LUA_COPYRIGHT);
|
||||
}
|
||||
|
||||
|
||||
static int getargs (lua_State *L, char **argv, int n) {
|
||||
int narg;
|
||||
int i;
|
||||
int argc = 0;
|
||||
while (argv[argc]) argc++; /* count total number of arguments */
|
||||
narg = argc - (n + 1); /* number of arguments to the script */
|
||||
luaL_checkstack(L, narg + 3, "too many arguments to script");
|
||||
for (i=n+1; i < argc; i++)
|
||||
lua_pushstring(L, argv[i]);
|
||||
lua_createtable(L, narg, n + 1);
|
||||
for (i=0; i < argc; i++) {
|
||||
lua_pushstring(L, argv[i]);
|
||||
lua_rawseti(L, -2, i - n);
|
||||
}
|
||||
return narg;
|
||||
}
|
||||
|
||||
|
||||
static int dofile (lua_State *L, const char *name) {
|
||||
int status = luaL_loadfile(L, name) || docall(L, 0, 1);
|
||||
return report(L, status);
|
||||
}
|
||||
|
||||
|
||||
static int dostring (lua_State *L, const char *s, const char *name) {
|
||||
int status = luaL_loadbuffer(L, s, strlen(s), name) || docall(L, 0, 1);
|
||||
return report(L, status);
|
||||
}
|
||||
|
||||
|
||||
static int dolibrary (lua_State *L, const char *name) {
|
||||
lua_getglobal(L, "require");
|
||||
lua_pushstring(L, name);
|
||||
return report(L, lua_pcall(L, 1, 0, 0));
|
||||
}
|
||||
|
||||
|
||||
static const char *get_prompt (lua_State *L, int firstline) {
|
||||
const char *p;
|
||||
lua_getfield(L, LUA_GLOBALSINDEX, firstline ? "_PROMPT" : "_PROMPT2");
|
||||
p = lua_tostring(L, -1);
|
||||
if (p == NULL) p = (firstline ? LUA_PROMPT : LUA_PROMPT2);
|
||||
lua_pop(L, 1); /* remove global */
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
static int incomplete (lua_State *L, int status) {
|
||||
if (status == LUA_ERRSYNTAX) {
|
||||
size_t lmsg;
|
||||
const char *msg = lua_tolstring(L, -1, &lmsg);
|
||||
const char *tp = msg + lmsg - (sizeof(LUA_QL("<eof>")) - 1);
|
||||
if (strstr(msg, LUA_QL("<eof>")) == tp) {
|
||||
lua_pop(L, 1);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0; /* else... */
|
||||
}
|
||||
|
||||
|
||||
static int pushline (lua_State *L, int firstline) {
|
||||
char buffer[LUA_MAXINPUT];
|
||||
char *b = buffer;
|
||||
size_t l;
|
||||
const char *prmt = get_prompt(L, firstline);
|
||||
if (lua_readline(L, b, prmt) == 0)
|
||||
return 0; /* no input */
|
||||
l = strlen(b);
|
||||
if (l > 0 && b[l-1] == '\n') /* line ends with newline? */
|
||||
b[l-1] = '\0'; /* remove it */
|
||||
if (firstline && b[0] == '=') /* first line starts with `=' ? */
|
||||
lua_pushfstring(L, "return %s", b+1); /* change it to `return' */
|
||||
else
|
||||
lua_pushstring(L, b);
|
||||
lua_freeline(L, b);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static int loadline (lua_State *L) {
|
||||
int status;
|
||||
lua_settop(L, 0);
|
||||
if (!pushline(L, 1))
|
||||
return -1; /* no input */
|
||||
for (;;) { /* repeat until gets a complete line */
|
||||
status = luaL_loadbuffer(L, lua_tostring(L, 1), lua_strlen(L, 1), "=stdin");
|
||||
if (!incomplete(L, status)) break; /* cannot try to add lines? */
|
||||
if (!pushline(L, 0)) /* no more input? */
|
||||
return -1;
|
||||
lua_pushliteral(L, "\n"); /* add a new line... */
|
||||
lua_insert(L, -2); /* ...between the two lines */
|
||||
lua_concat(L, 3); /* join them */
|
||||
}
|
||||
lua_saveline(L, 1);
|
||||
lua_remove(L, 1); /* remove line */
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
static void dotty (lua_State *L) {
|
||||
int status;
|
||||
const char *oldprogname = progname;
|
||||
progname = NULL;
|
||||
while ((status = loadline(L)) != -1) {
|
||||
if (status == 0) status = docall(L, 0, 0);
|
||||
report(L, status);
|
||||
if (status == 0 && lua_gettop(L) > 0) { /* any result to print? */
|
||||
lua_getglobal(L, "print");
|
||||
lua_insert(L, 1);
|
||||
if (lua_pcall(L, lua_gettop(L)-1, 0, 0) != 0)
|
||||
l_message(progname, lua_pushfstring(L,
|
||||
"error calling " LUA_QL("print") " (%s)",
|
||||
lua_tostring(L, -1)));
|
||||
}
|
||||
}
|
||||
lua_settop(L, 0); /* clear stack */
|
||||
fputs("\n", stdout);
|
||||
fflush(stdout);
|
||||
progname = oldprogname;
|
||||
}
|
||||
|
||||
|
||||
static int handle_script (lua_State *L, char **argv, int n) {
|
||||
int status;
|
||||
const char *fname;
|
||||
int narg = getargs(L, argv, n); /* collect arguments */
|
||||
lua_setglobal(L, "arg");
|
||||
fname = argv[n];
|
||||
if (strcmp(fname, "-") == 0 && strcmp(argv[n-1], "--") != 0)
|
||||
fname = NULL; /* stdin */
|
||||
status = luaL_loadfile(L, fname);
|
||||
lua_insert(L, -(narg+1));
|
||||
if (status == 0)
|
||||
status = docall(L, narg, 0);
|
||||
else
|
||||
lua_pop(L, narg);
|
||||
return report(L, status);
|
||||
}
|
||||
|
||||
|
||||
/* check that argument has no extra characters at the end */
|
||||
#define notail(x) {if ((x)[2] != '\0') return -1;}
|
||||
|
||||
|
||||
static int collectargs (char **argv, int *pi, int *pv, int *pe) {
|
||||
int i;
|
||||
for (i = 1; argv[i] != NULL; i++) {
|
||||
if (argv[i][0] != '-') /* not an option? */
|
||||
return i;
|
||||
switch (argv[i][1]) { /* option */
|
||||
case '-':
|
||||
notail(argv[i]);
|
||||
return (argv[i+1] != NULL ? i+1 : 0);
|
||||
case '\0':
|
||||
return i;
|
||||
case 'i':
|
||||
notail(argv[i]);
|
||||
*pi = 1; /* go through */
|
||||
case 'v':
|
||||
notail(argv[i]);
|
||||
*pv = 1;
|
||||
break;
|
||||
case 'e':
|
||||
*pe = 1; /* go through */
|
||||
case 'l':
|
||||
if (argv[i][2] == '\0') {
|
||||
i++;
|
||||
if (argv[i] == NULL) return -1;
|
||||
}
|
||||
break;
|
||||
default: return -1; /* invalid option */
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int runargs (lua_State *L, char **argv, int n) {
|
||||
int i;
|
||||
for (i = 1; i < n; i++) {
|
||||
if (argv[i] == NULL) continue;
|
||||
lua_assert(argv[i][0] == '-');
|
||||
switch (argv[i][1]) { /* option */
|
||||
case 'e': {
|
||||
const char *chunk = argv[i] + 2;
|
||||
if (*chunk == '\0') chunk = argv[++i];
|
||||
lua_assert(chunk != NULL);
|
||||
if (dostring(L, chunk, "=(command line)") != 0)
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
case 'l': {
|
||||
const char *filename = argv[i] + 2;
|
||||
if (*filename == '\0') filename = argv[++i];
|
||||
lua_assert(filename != NULL);
|
||||
if (dolibrary(L, filename))
|
||||
return 1; /* stop if file fails */
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int handle_luainit (lua_State *L) {
|
||||
const char *init = getenv(LUA_INIT);
|
||||
if (init == NULL) return 0; /* status OK */
|
||||
else if (init[0] == '@')
|
||||
return dofile(L, init+1);
|
||||
else
|
||||
return dostring(L, init, "=" LUA_INIT);
|
||||
}
|
||||
|
||||
|
||||
struct Smain {
|
||||
int argc;
|
||||
char **argv;
|
||||
int status;
|
||||
};
|
||||
|
||||
|
||||
static int pmain (lua_State *L) {
|
||||
struct Smain *s = (struct Smain *)lua_touserdata(L, 1);
|
||||
char **argv = s->argv;
|
||||
int script;
|
||||
int has_i = 0, has_v = 0, has_e = 0;
|
||||
globalL = L;
|
||||
if (argv[0] && argv[0][0]) progname = argv[0];
|
||||
lua_gc(L, LUA_GCSTOP, 0); /* stop collector during initialization */
|
||||
luaL_openlibs(L); /* open libraries */
|
||||
lua_gc(L, LUA_GCRESTART, 0);
|
||||
s->status = handle_luainit(L);
|
||||
if (s->status != 0) return 0;
|
||||
script = collectargs(argv, &has_i, &has_v, &has_e);
|
||||
if (script < 0) { /* invalid args? */
|
||||
print_usage();
|
||||
s->status = 1;
|
||||
return 0;
|
||||
}
|
||||
if (has_v) print_version();
|
||||
s->status = runargs(L, argv, (script > 0) ? script : s->argc);
|
||||
if (s->status != 0) return 0;
|
||||
if (script)
|
||||
s->status = handle_script(L, argv, script);
|
||||
if (s->status != 0) return 0;
|
||||
if (has_i)
|
||||
dotty(L);
|
||||
else if (script == 0 && !has_e && !has_v) {
|
||||
if (lua_stdin_is_tty()) {
|
||||
print_version();
|
||||
dotty(L);
|
||||
}
|
||||
else dofile(L, NULL); /* executes stdin as a file */
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int main (int argc, char **argv) {
|
||||
int status;
|
||||
struct Smain s;
|
||||
lua_State *L = lua_open(); /* create state */
|
||||
printf("DevIL embedded lua interpreter\n");
|
||||
//@TODO: Where the heck is this defined?
|
||||
//Devil_Init(L);
|
||||
if (L == NULL) {
|
||||
l_message(argv[0], "cannot create state: not enough memory");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
s.argc = argc;
|
||||
s.argv = argv;
|
||||
status = lua_cpcall(L, &pmain, &s);
|
||||
report(L, status);
|
||||
lua_close(L);
|
||||
return (status || s.status) ? EXIT_FAILURE : EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
1
DevILSDK/include/IL/stamp-h.in
Normal file
@ -0,0 +1 @@
|
||||
timestamp
|
||||
BIN
DevILSDK/lib/x64/Release/DevIL.dll
Normal file
BIN
DevILSDK/lib/x64/Release/DevIL.lib
Normal file
BIN
DevILSDK/lib/x64/Release/ILU.dll
Normal file
BIN
DevILSDK/lib/x64/Release/ILU.lib
Normal file
BIN
DevILSDK/lib/x64/Release/ILUT.dll
Normal file
BIN
DevILSDK/lib/x64/Release/ILUT.lib
Normal file
BIN
DevILSDK/lib/x64/unicode/Release/DevIL.dll
Normal file
BIN
DevILSDK/lib/x64/unicode/Release/DevIL.lib
Normal file
BIN
DevILSDK/lib/x64/unicode/Release/ILU.dll
Normal file
BIN
DevILSDK/lib/x64/unicode/Release/ILU.lib
Normal file
BIN
DevILSDK/lib/x64/unicode/Release/ILUT.dll
Normal file
BIN
DevILSDK/lib/x64/unicode/Release/ILUT.lib
Normal file
BIN
DevILSDK/lib/x86/Release/DevIL.dll
Normal file
BIN
DevILSDK/lib/x86/Release/DevIL.lib
Normal file
BIN
DevILSDK/lib/x86/Release/ILU.dll
Normal file
BIN
DevILSDK/lib/x86/Release/ILU.lib
Normal file
BIN
DevILSDK/lib/x86/Release/ILUT.dll
Normal file
BIN
DevILSDK/lib/x86/Release/ILUT.lib
Normal file
BIN
DevILSDK/lib/x86/unicode/Release/DevIL.dll
Normal file
BIN
DevILSDK/lib/x86/unicode/Release/DevIL.lib
Normal file
BIN
DevILSDK/lib/x86/unicode/Release/ILU.dll
Normal file
BIN
DevILSDK/lib/x86/unicode/Release/ILU.lib
Normal file
BIN
DevILSDK/lib/x86/unicode/Release/ILUT.dll
Normal file
BIN
DevILSDK/lib/x86/unicode/Release/ILUT.lib
Normal file
@ -1,43 +0,0 @@
|
||||
QT += core gui 3dcore 3drender 3dinput 3dextras
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
RC_ICONS = XPlor.ico
|
||||
|
||||
CONFIG += c++17
|
||||
|
||||
# INCLUDEPATH += "C:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/um"
|
||||
# LIBS += -L"C:/Program Files (x86)/Windows Kits/10/Lib/10.0.26100.0/um/x64" \
|
||||
# -ldxcompiler
|
||||
|
||||
# You can make your code fail to compile if it uses deprecated APIs.
|
||||
# In order to do so, uncomment the following line.
|
||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||
|
||||
SOURCES += \
|
||||
aboutdialog.cpp \
|
||||
main.cpp \
|
||||
mainwindow.cpp \
|
||||
modelviewer.cpp
|
||||
|
||||
HEADERS += \
|
||||
aboutdialog.h \
|
||||
compression.h \
|
||||
enums.h \
|
||||
ffparser.h \
|
||||
mainwindow.h \
|
||||
modelviewer.h \
|
||||
structs.h \
|
||||
utils.h \
|
||||
zfparser.h
|
||||
|
||||
FORMS += \
|
||||
aboutdialog.ui \
|
||||
mainwindow.ui
|
||||
|
||||
# Default rules for deployment.
|
||||
qnx: target.path = /tmp/$${TARGET}/bin
|
||||
else: unix:!android: target.path = /opt/$${TARGET}/bin
|
||||
!isEmpty(target.path): INSTALLS += target
|
||||
|
||||
RESOURCES += \
|
||||
Data.qrc
|
||||
@ -1,271 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 15.0.0, 2025-01-12T21:27:06. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>EnvironmentId</variable>
|
||||
<value type="QByteArray">{40d992cb-ac11-4385-a22b-016f1b4251a7}</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
||||
<value type="qlonglong">0</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.EditorSettings</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
|
||||
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
|
||||
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
|
||||
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
|
||||
<value type="QString" key="language">Cpp</value>
|
||||
<valuemap type="QVariantMap" key="value">
|
||||
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
|
||||
</valuemap>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
|
||||
<value type="QString" key="language">QmlJS</value>
|
||||
<valuemap type="QVariantMap" key="value">
|
||||
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
|
||||
</valuemap>
|
||||
</valuemap>
|
||||
<value type="qlonglong" key="EditorConfiguration.CodeStyle.Count">2</value>
|
||||
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
|
||||
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
|
||||
<value type="int" key="EditorConfiguration.IndentSize">4</value>
|
||||
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
|
||||
<value type="int" key="EditorConfiguration.LineEndingBehavior">0</value>
|
||||
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
|
||||
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
|
||||
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
|
||||
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
|
||||
<value type="int" key="EditorConfiguration.PreferAfterWhitespaceComments">0</value>
|
||||
<value type="bool" key="EditorConfiguration.PreferSingleLineComments">false</value>
|
||||
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
|
||||
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
|
||||
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">2</value>
|
||||
<value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
|
||||
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
|
||||
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
|
||||
<value type="int" key="EditorConfiguration.TabSize">8</value>
|
||||
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
|
||||
<value type="bool" key="EditorConfiguration.UseIndenter">false</value>
|
||||
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
|
||||
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
|
||||
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
|
||||
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
|
||||
<value type="QString" key="EditorConfiguration.ignoreFileTypes">*.md, *.MD, Makefile</value>
|
||||
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
|
||||
<value type="bool" key="EditorConfiguration.skipTrailingWhitespace">true</value>
|
||||
<value type="bool" key="EditorConfiguration.tintMarginArea">true</value>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.PluginSettings</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<valuemap type="QVariantMap" key="AutoTest.ActiveFrameworks">
|
||||
<value type="bool" key="AutoTest.Framework.Boost">true</value>
|
||||
<value type="bool" key="AutoTest.Framework.CTest">false</value>
|
||||
<value type="bool" key="AutoTest.Framework.Catch">true</value>
|
||||
<value type="bool" key="AutoTest.Framework.GTest">true</value>
|
||||
<value type="bool" key="AutoTest.Framework.QtQuickTest">true</value>
|
||||
<value type="bool" key="AutoTest.Framework.QtTest">true</value>
|
||||
</valuemap>
|
||||
<value type="bool" key="AutoTest.ApplyFilter">false</value>
|
||||
<valuemap type="QVariantMap" key="AutoTest.CheckStates"/>
|
||||
<valuelist type="QVariantList" key="AutoTest.PathFilters"/>
|
||||
<value type="int" key="AutoTest.RunAfterBuild">0</value>
|
||||
<value type="bool" key="AutoTest.UseGlobal">true</value>
|
||||
<valuemap type="QVariantMap" key="ClangTools">
|
||||
<value type="bool" key="ClangTools.AnalyzeOpenFiles">true</value>
|
||||
<value type="bool" key="ClangTools.BuildBeforeAnalysis">true</value>
|
||||
<value type="QString" key="ClangTools.DiagnosticConfig">Builtin.DefaultTidyAndClazy</value>
|
||||
<value type="int" key="ClangTools.ParallelJobs">16</value>
|
||||
<value type="bool" key="ClangTools.PreferConfigFile">true</value>
|
||||
<valuelist type="QVariantList" key="ClangTools.SelectedDirs"/>
|
||||
<valuelist type="QVariantList" key="ClangTools.SelectedFiles"/>
|
||||
<valuelist type="QVariantList" key="ClangTools.SuppressedDiagnostics"/>
|
||||
<value type="bool" key="ClangTools.UseGlobalSettings">true</value>
|
||||
</valuemap>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.Target.0</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<value type="QString" key="DeviceType">Desktop</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 6.8.1 MSVC2022 64bit</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 6.8.1 MSVC2022 64bit</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.qt6.681.win64_msvc2022_64_kit</value>
|
||||
<value type="qlonglong" key="ProjectExplorer.Target.ActiveBuildConfiguration">1</value>
|
||||
<value type="qlonglong" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
|
||||
<value type="qlonglong" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
|
||||
<value type="int" key="EnableQmlDebugging">0</value>
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:\Users\njohnson\Projects\FastFile_WaW\build\Desktop_Qt_6_8_1_MSVC2022_64bit-Debug</value>
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">C:/Users/njohnson/Projects/FastFile_WaW/build/Desktop_Qt_6_8_1_MSVC2022_64bit-Debug</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
|
||||
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
</valuemap>
|
||||
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
|
||||
</valuemap>
|
||||
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
|
||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Debug</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
|
||||
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:\Users\njohnson\Projects\FastFile_WaW\build\Desktop_Qt_6_8_1_MSVC2022_64bit-Release</value>
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">C:/Users/njohnson/Projects/FastFile_WaW/build/Desktop_Qt_6_8_1_MSVC2022_64bit-Release</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
|
||||
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
</valuemap>
|
||||
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
|
||||
</valuemap>
|
||||
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
|
||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Release</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
|
||||
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
|
||||
<value type="int" key="QtQuickCompiler">0</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
|
||||
<value type="int" key="EnableQmlDebugging">0</value>
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:\Users\njohnson\Projects\FastFile_WaW\build\Desktop_Qt_6_8_1_MSVC2022_64bit-Profile</value>
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">C:/Users/njohnson/Projects/FastFile_WaW/build/Desktop_Qt_6_8_1_MSVC2022_64bit-Profile</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
|
||||
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
</valuemap>
|
||||
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
|
||||
</valuemap>
|
||||
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
|
||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ParseStandardOutput">false</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Profile</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
|
||||
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
|
||||
<value type="int" key="QtQuickCompiler">0</value>
|
||||
<value type="int" key="SeparateDebugInfo">0</value>
|
||||
</valuemap>
|
||||
<value type="qlonglong" key="ProjectExplorer.Target.BuildConfigurationCount">3</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<value type="qlonglong" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Deploy</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.DeployConfiguration.CustomData"/>
|
||||
<value type="bool" key="ProjectExplorer.DeployConfiguration.CustomDataEnabled">false</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
|
||||
</valuemap>
|
||||
<value type="qlonglong" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
|
||||
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
|
||||
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
|
||||
<value type="int" key="Analyzer.Valgrind.Callgrind.CostFormat">0</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
|
||||
<valuelist type="QVariantList" key="CustomOutputParsers"/>
|
||||
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
||||
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||
<value type="bool" key="PE.EnvironmentAspect.PrintOnRun">false</value>
|
||||
<value type="QString" key="PerfRecordArgsId">-e cpu-cycles --call-graph "dwarf,4096" -F 250</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">FastFile_WaW2</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:</value>
|
||||
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">C:/Users/njohnson/Projects/XPlor/FastFile_WaW.pro</value>
|
||||
<value type="bool" key="ProjectExplorer.RunConfiguration.Customized">true</value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
|
||||
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
||||
<value type="QString" key="RunConfiguration.WorkingDirectory.default">C:/Users/njohnson/Projects/FastFile_WaW/build/Desktop_Qt_6_8_1_MSVC2022_64bit-Release</value>
|
||||
</valuemap>
|
||||
<value type="qlonglong" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.TargetCount</variable>
|
||||
<value type="qlonglong">1</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
|
||||
<value type="int">22</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>Version</variable>
|
||||
<value type="int">22</value>
|
||||
</data>
|
||||
</qtcreator>
|
||||
75
XPlor.pro
Normal file
@ -0,0 +1,75 @@
|
||||
QT += core gui 3dcore 3drender 3dinput 3dextras
|
||||
|
||||
RC_ICONS = XPlor.ico
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
CONFIG += c++17
|
||||
|
||||
SOURCES += \
|
||||
aboutdialog.cpp \
|
||||
ddsfile.cpp \
|
||||
ddsviewer.cpp \
|
||||
fastfile.cpp \
|
||||
fastfileviewer.cpp \
|
||||
imagewidget.cpp \
|
||||
iwifile.cpp \
|
||||
iwiviewer.cpp \
|
||||
localstringviewer.cpp \
|
||||
lzokay.cpp \
|
||||
main.cpp \
|
||||
mainwindow.cpp \
|
||||
modelviewer.cpp \
|
||||
iwifile.cpp \
|
||||
techsetviewer.cpp \
|
||||
xtreewidget.cpp \
|
||||
zonefile.cpp \
|
||||
zonefileviewer.cpp
|
||||
|
||||
HEADERS += \
|
||||
aboutdialog.h \
|
||||
asset_structs.h \
|
||||
compressor.h \
|
||||
d3dbsp_structs.h \
|
||||
dds_structs.h \
|
||||
ddsfile.h \
|
||||
ddsviewer.h \
|
||||
enums.h \
|
||||
fastfile.h \
|
||||
fastfileviewer.h \
|
||||
imagewidget.h \
|
||||
ipak_structs.h \
|
||||
iwifile.h \
|
||||
iwiviewer.h \
|
||||
localstringviewer.h \
|
||||
lzokay.hpp \
|
||||
lzx.h \
|
||||
mainwindow.h \
|
||||
modelviewer.h \
|
||||
techsetviewer.h \
|
||||
utils.h \
|
||||
xtreewidget.h \
|
||||
iwifile.h \
|
||||
zonefile.h \
|
||||
zonefileviewer.h
|
||||
|
||||
FORMS += \
|
||||
aboutdialog.ui \
|
||||
ddsviewer.ui \
|
||||
fastfileviewer.ui \
|
||||
imagewidget.ui \
|
||||
iwiviewer.ui \
|
||||
localstringviewer.ui \
|
||||
mainwindow.ui \
|
||||
techsetviewer.ui \
|
||||
zonefileviewer.ui
|
||||
|
||||
RESOURCES += \
|
||||
data/Data.qrc
|
||||
|
||||
LIBS += -L$$PWD/DevILSDK/lib/x64/Unicode/Release -lDevIL
|
||||
LIBS += -L$$PWD/DevILSDK/lib/x64/Unicode/Release -lILU
|
||||
LIBS += -L$$PWD/DevILSDK/lib/x64/Unicode/Release -lILUT
|
||||
|
||||
#LIBS += -L"C:/Program Files (x86)/Windows Kits/10/Lib/10.0.26100.0/um/x64" -ldxcompiler
|
||||
|
||||
|
||||
346
asset_structs.h
Normal file
@ -0,0 +1,346 @@
|
||||
#ifndef ASSET_STRUCTS_H
|
||||
#define ASSET_STRUCTS_H
|
||||
|
||||
#include "enums.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QColor>
|
||||
#include <QRectF>
|
||||
|
||||
struct LocalString {
|
||||
QString string;
|
||||
QString alias;
|
||||
};
|
||||
|
||||
struct RawFile {
|
||||
quint32 length;
|
||||
QString path;
|
||||
QString contents;
|
||||
};
|
||||
|
||||
struct TechSet {
|
||||
QString name;
|
||||
bool hasShaders = false;
|
||||
QVector<quint32> pointers;
|
||||
};
|
||||
|
||||
struct Shader {
|
||||
quint32 shaderPtr;
|
||||
};
|
||||
|
||||
struct XModelCollSurf_s
|
||||
{
|
||||
float mins[3];
|
||||
float maxs[3];
|
||||
int boneIdx;
|
||||
int contents;
|
||||
int surfFlags;
|
||||
};
|
||||
|
||||
struct XModelLodInfo
|
||||
{
|
||||
float dist;
|
||||
unsigned short numsurfs;
|
||||
unsigned short surfIndex;
|
||||
int partBits[5];
|
||||
};
|
||||
|
||||
struct XModelHighMipBounds
|
||||
{
|
||||
float mins[3];
|
||||
float maxs[3];
|
||||
};
|
||||
|
||||
struct XModelStreamInfo
|
||||
{
|
||||
XModelHighMipBounds *highMipBounds;
|
||||
};
|
||||
|
||||
struct XBoneInfo
|
||||
{
|
||||
float bounds[2][3];
|
||||
float offset[3];
|
||||
float radiusSquared;
|
||||
};
|
||||
|
||||
struct Model {
|
||||
quint32 namePtr;
|
||||
quint8 tagCount;
|
||||
quint8 rootTagCount;
|
||||
quint8 surfCount;
|
||||
quint8 unknownCount;
|
||||
quint32 boneNamePtr;
|
||||
quint32 parentListPtr;
|
||||
quint32 quatsPtr;
|
||||
quint32 transPtr;
|
||||
quint32 partClassPtr;
|
||||
quint32 baseMatPtr;
|
||||
quint32 surfsPtr;
|
||||
quint32 materialHandlesPtr;
|
||||
|
||||
XModelLodInfo lodInfo[4];
|
||||
quint32 collSurfsPtr;
|
||||
int numCollSurfs;
|
||||
int contents;
|
||||
quint32 boneInfoPtr;
|
||||
float radius;
|
||||
float mins[3];
|
||||
float maxs[3];
|
||||
short numLods;
|
||||
short collLod;
|
||||
quint32 streamInfoPtr; // is not loaded on ps3
|
||||
int memUsage;
|
||||
char flags;
|
||||
quint32 physPresetPtr;
|
||||
quint32 physGeomsPtr;
|
||||
|
||||
QString modelName;
|
||||
};
|
||||
|
||||
struct Animation {
|
||||
quint16 dataByteCount;
|
||||
quint16 dataShortCount;
|
||||
quint16 dataIntCount;
|
||||
quint16 randomDataByteCount;
|
||||
quint16 randomDataIntCount;
|
||||
quint16 numframes;
|
||||
bool isLooped;
|
||||
bool isDelta;
|
||||
quint8 noneRotatedBoneCount;
|
||||
quint8 twoDRotatedBoneCount;
|
||||
quint8 normalRotatedBoneCount;
|
||||
quint8 twoDStaticRotatedBoneCount;
|
||||
quint8 normalStaticRotatedBoneCount;
|
||||
quint8 normalTranslatedBoneCount;
|
||||
quint8 preciseTranslatedBoneCount;
|
||||
quint8 staticTranslatedBoneCount;
|
||||
quint8 noneTranslatedBoneCount;
|
||||
quint8 totalBoneCount;
|
||||
quint8 otherBoneCount1;
|
||||
quint8 otherBoneCount2;
|
||||
quint8 notifyCount;
|
||||
quint8 assetType;
|
||||
bool pad;
|
||||
unsigned int randomDataShortCount;
|
||||
unsigned int indexCount;
|
||||
float frameRate;
|
||||
float frequency;
|
||||
quint32 boneIDsPtr;
|
||||
quint32 dataBytePtr;
|
||||
quint32 dataShortPtr;
|
||||
quint32 dataIntPtr;
|
||||
quint32 randomDataShortPtr;
|
||||
quint32 randomDataBytePtr;
|
||||
quint32 randomDataIntPtr;
|
||||
quint32 longIndiciesPtr;
|
||||
quint32 notificationsPtr;
|
||||
quint32 deltaPartsPtr;
|
||||
QString name;
|
||||
};
|
||||
|
||||
struct StringTable {
|
||||
quint32 columnCount;
|
||||
quint32 rowCount;
|
||||
QString name;
|
||||
};
|
||||
|
||||
struct Image {
|
||||
QString name;
|
||||
QString materialName;
|
||||
quint32 size1;
|
||||
quint32 size2;
|
||||
IMAGE_COMPRESSION compression;
|
||||
quint32 unknowna;
|
||||
quint32 unknownb;
|
||||
quint32 unknownc;
|
||||
quint32 unknownd;
|
||||
quint32 unknowne;
|
||||
quint32 unknownf;
|
||||
quint32 unknowng;
|
||||
quint32 unknownh;
|
||||
quint32 unknowni;
|
||||
quint32 unknownj;
|
||||
quint32 unknownk;
|
||||
quint32 unknownl;
|
||||
quint32 unknownm;
|
||||
quint32 unknown1;
|
||||
quint32 unknown2;
|
||||
quint32 unknown3;
|
||||
quint32 unknown4;
|
||||
quint32 unknown5;
|
||||
quint32 unknown6;
|
||||
quint32 unknown7;
|
||||
quint32 unknown8;
|
||||
quint32 unknown9;
|
||||
};
|
||||
|
||||
struct Menu {
|
||||
QString filePath;
|
||||
QString name;
|
||||
QString definition;
|
||||
quint32 menuNamePtr;
|
||||
QRectF rect;
|
||||
MENU_H_ALIGNMENT hAlign;
|
||||
MENU_V_ALIGNMENT vAlign;
|
||||
QRectF clientRect;
|
||||
MENU_H_ALIGNMENT hClientAlign;
|
||||
MENU_V_ALIGNMENT vClientAlign;
|
||||
quint32 groupPtr;
|
||||
MENU_WINDOW_STYLE style;
|
||||
MENU_WINDOW_BORDER border;
|
||||
quint32 ownerDraw;
|
||||
quint32 ownerDrawFlags;
|
||||
float borderSize;
|
||||
int staticFlags;
|
||||
float dynamicFlags;
|
||||
float nextTime;
|
||||
QColor foregroundColor;
|
||||
QColor backgroundColor;
|
||||
QColor borderColor;
|
||||
QColor outlineColor;
|
||||
quint32 materialPtr;
|
||||
quint32 fontPtr;
|
||||
quint32 fullScreen;
|
||||
quint32 itemCount;
|
||||
quint32 fontIndex;
|
||||
quint32 cursorItem;
|
||||
quint32 fadeCycle;
|
||||
float fadeClamp;
|
||||
float fadeAmount;
|
||||
float fadeInAmount;
|
||||
float blurRadius;
|
||||
quint32 onOpenPtr;
|
||||
quint32 onFocusPtr;
|
||||
quint32 onClosePtr;
|
||||
quint32 onESCPtr;
|
||||
quint32 onKeyPtr;
|
||||
quint32 visibleExpCount;
|
||||
quint32 expEntryPtr;
|
||||
quint32 allowedBindingPtr;
|
||||
quint32 soundNamePtr;
|
||||
quint32 imageTrack;
|
||||
QColor focusColor;
|
||||
QColor disabledColor;
|
||||
quint32 rectXExpCount;
|
||||
quint32 rectXExpPtr;
|
||||
quint32 rectYExpCount;
|
||||
quint32 rectYExpPtr;
|
||||
quint32 itemWindowDefNamePtr;
|
||||
QRectF itemRect;
|
||||
MENU_H_ALIGNMENT itemHAlignment;
|
||||
MENU_V_ALIGNMENT itemVAlignment;
|
||||
quint32 itemGroupPtr;
|
||||
MENU_WINDOW_STYLE itemWindowStyle;
|
||||
MENU_WINDOW_BORDER itemWindowBorder;
|
||||
quint32 itemOwnerDraw;
|
||||
quint32 itemOwnerDrawFlags;
|
||||
float itemBorderSize;
|
||||
int itemStaticFlags;
|
||||
int itemDynamicFlags;
|
||||
int itemNextTime;
|
||||
QColor itemForegroundColor;
|
||||
QColor itemBackgroundColor;
|
||||
QColor itemBorderColor;
|
||||
QColor itemOutlineColor;
|
||||
quint32 itemMaterialPtr;
|
||||
QRectF itemTextRect;
|
||||
MENU_H_ALIGNMENT itemText_hAlign;
|
||||
MENU_V_ALIGNMENT itemText_vAlign;
|
||||
MENU_ITEM_TYPE itemType;
|
||||
quint32 dataType;
|
||||
quint32 alignment;
|
||||
MENU_FONT_TYPE fontEnum;
|
||||
quint32 textAlignMode;
|
||||
float textalignx;
|
||||
float textaligny;
|
||||
float textscale;
|
||||
MENU_ITEM_TEXTSTYLE textStyle;
|
||||
int gameMsgWindowIndex;
|
||||
int gameMsgWindowMode;
|
||||
quint32 testPtr;
|
||||
quint32 textSavegameInfo;
|
||||
quint32 parentPtr;
|
||||
quint32 mouseEnterText;
|
||||
quint32 mouseExitText;
|
||||
quint32 mouseEnter;
|
||||
quint32 mouseExit;
|
||||
quint32 action;
|
||||
quint32 onAccept;
|
||||
quint32 onFocus;
|
||||
quint32 leaveFocus;
|
||||
quint32 dvar;
|
||||
quint32 dvarTest;
|
||||
quint32 keyHandlerPtr;
|
||||
quint32 enableDvarPtr;
|
||||
quint32 dvarFlags;
|
||||
quint32 focusSoundPtr;
|
||||
float special;
|
||||
quint32 cursorPos;
|
||||
// itemDefData_t typeData;
|
||||
// listBoxDef_s *listBox;
|
||||
quint32 startPos;
|
||||
quint32 endPos;
|
||||
quint32 drawPadding;
|
||||
float elementWidth, elementHeight;
|
||||
quint32 elementStyle, numColumns;
|
||||
//columnInfo_s columnInfo[16];
|
||||
quint32 doubleClickPtr;
|
||||
int notselectable;
|
||||
int noScrollBars;
|
||||
int usePaging;
|
||||
QColor itemSelectBorderColor;
|
||||
QColor itemDisableColor;
|
||||
QColor itemFocusColor;
|
||||
quint32 selectIconPtr;
|
||||
quint32 backgroundItemListboxPtr;
|
||||
quint32 highlightTexturePtr;
|
||||
// editFieldDef_s *editField;
|
||||
float minVal;
|
||||
float maxVal;
|
||||
float defVal;
|
||||
float range;
|
||||
int maxChars;
|
||||
int maxCharsGotoNext;
|
||||
int maxPaintChars;
|
||||
int paintOffset;
|
||||
// multiDef_s *multi;
|
||||
QVector<quint32> dvarListPtrs;
|
||||
QVector<quint32> dvarStrPtrs;
|
||||
QVector<float> dvarValues;
|
||||
quint32 count;
|
||||
quint32 strDef;
|
||||
quint32 enumDvarNamePtr;
|
||||
quint32 dataPtr;
|
||||
quint32 itemImageTrack;
|
||||
};
|
||||
|
||||
struct MenuFile {
|
||||
quint32 menuCount;
|
||||
QVector<Menu> menuDefs;
|
||||
};
|
||||
|
||||
struct AssetMap {
|
||||
QVector<LocalString> localStrings;
|
||||
QVector<RawFile> rawFiles;
|
||||
//QVector<PhysPreset> phyPresets;
|
||||
QVector<Model> models;
|
||||
//QVector<Material> rawFiles;
|
||||
//QVector<Shader> shaders;
|
||||
QVector<TechSet> techSets;
|
||||
QVector<Image> images;
|
||||
//QVector<Sound> sounds;
|
||||
//QVector<CollisionMap> collMaps;
|
||||
//QVector<LightDefinition> lightDefs;
|
||||
//QVector<UiMap> uiMaps;
|
||||
//QVector<DriverGlobal> driverGlobals;
|
||||
//QVector<AiType> aiType;
|
||||
//QVector<Effect> effects;
|
||||
QVector<Animation> animations;
|
||||
QVector<StringTable> stringTables;
|
||||
QVector<MenuFile> menuFiles;
|
||||
//QVector<Weapon> weapons;
|
||||
//QVector<D3DBSP> d3dbspDumps;
|
||||
//QVector<SingleplayerMap> spMaps;
|
||||
};
|
||||
|
||||
#endif // ASSET_STRUCTS_H
|
||||
@ -1,34 +0,0 @@
|
||||
#ifndef COMPRESSION_H
|
||||
#define COMPRESSION_H
|
||||
|
||||
#include "utils.h"
|
||||
#include "QtZlib/zlib.h"
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QDebug>
|
||||
|
||||
class Compressor {
|
||||
public:
|
||||
static QByteArray DecompressZLIB(QByteArray compressedData) {
|
||||
QByteArray decompressedData;
|
||||
uLongf decompressedSize = compressedData.size() * 4;
|
||||
decompressedData.resize(static_cast<int>(decompressedSize));
|
||||
|
||||
Bytef *destination = reinterpret_cast<Bytef*>(decompressedData.data());
|
||||
uLongf *destLen = &decompressedSize;
|
||||
const Bytef *source = reinterpret_cast<const Bytef*>(compressedData.data());
|
||||
uLong sourceLen = compressedData.size();
|
||||
|
||||
int result = uncompress(destination, destLen, source, sourceLen);
|
||||
|
||||
if (result == Z_OK) {
|
||||
decompressedData.resize(static_cast<int>(decompressedSize));
|
||||
} else {
|
||||
decompressedData.clear();
|
||||
qDebug() << QString("In DecompressZLIB: %1").arg(Utils::ZLibErrorToString(result)).toLatin1();
|
||||
}
|
||||
return decompressedData;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // COMPRESSION_H
|
||||
410
compressor.h
Normal file
@ -0,0 +1,410 @@
|
||||
#ifndef COMPRESSOR_H
|
||||
#define COMPRESSOR_H
|
||||
|
||||
#include "utils.h"
|
||||
#include "QtZlib/zlib.h"
|
||||
#include "lzokay.hpp"
|
||||
#include "lzx.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <QByteArray>
|
||||
#include <QDebug>
|
||||
#include <QDataStream>
|
||||
#include <QVector>
|
||||
#include <algorithm>
|
||||
|
||||
typedef enum {
|
||||
EResult_LookbehindOverrun = -4,
|
||||
EResult_OutputOverrun = -3,
|
||||
EResult_InputOverrun = -2,
|
||||
EResult_Error = -1,
|
||||
EResult_Success = 0,
|
||||
EResult_InputNotConsumed = 1,
|
||||
} lzokay_EResult;
|
||||
|
||||
static_assert(EResult_LookbehindOverrun == lzokay_EResult(lzokay::EResult::LookbehindOverrun), "LookbehindOverrun mismatch");
|
||||
static_assert(EResult_OutputOverrun == lzokay_EResult(lzokay::EResult::OutputOverrun), "OutputOverrun mismatch");
|
||||
static_assert(EResult_InputOverrun == lzokay_EResult(lzokay::EResult::InputOverrun), "InputOverrun mismatch");
|
||||
static_assert(EResult_Error == lzokay_EResult(lzokay::EResult::Error), "Error mismatch");
|
||||
static_assert(EResult_Success == lzokay_EResult(lzokay::EResult::Success), "Success mismatch");
|
||||
static_assert(EResult_InputNotConsumed == lzokay_EResult(lzokay::EResult::InputNotConsumed), "InputNotConsumed mismatch");
|
||||
|
||||
class Compressor {
|
||||
public:
|
||||
static QByteArray DecompressZLIB(const QByteArray &compressedData) {
|
||||
if (compressedData.isEmpty())
|
||||
return QByteArray();
|
||||
|
||||
// Set up the inflate stream.
|
||||
z_stream strm;
|
||||
memset(&strm, 0, sizeof(strm));
|
||||
// The inflate() function needs a non-const pointer; this is safe as we never modify the input.
|
||||
strm.next_in = reinterpret_cast<Bytef*>(const_cast<char*>(compressedData.data()));
|
||||
strm.avail_in = static_cast<uInt>(compressedData.size());
|
||||
|
||||
// Use inflateInit(); if you want to support gzip streams, see note below.
|
||||
int ret = inflateInit(&strm);
|
||||
if (ret != Z_OK) {
|
||||
qWarning() << "inflateInit failed:" << zError(ret);
|
||||
return QByteArray();
|
||||
}
|
||||
|
||||
QByteArray outArray;
|
||||
char buffer[4096];
|
||||
|
||||
// Decompress until we reach the stream end.
|
||||
do {
|
||||
strm.next_out = reinterpret_cast<Bytef*>(buffer);
|
||||
strm.avail_out = sizeof(buffer);
|
||||
|
||||
ret = inflate(&strm, Z_NO_FLUSH);
|
||||
// Handle a special case: if inflate() returns Z_BUF_ERROR without
|
||||
// having produced any output and with no further input, then we break out.
|
||||
if (ret == Z_BUF_ERROR && strm.avail_in == 0) {
|
||||
break;
|
||||
}
|
||||
if (ret != Z_OK && ret != Z_STREAM_END) {
|
||||
qWarning() << "Error: ZLib inflate failed:" << zError(ret);
|
||||
inflateEnd(&strm);
|
||||
return QByteArray();
|
||||
}
|
||||
|
||||
// Calculate number of bytes produced in this iteration.
|
||||
int bytesProduced = sizeof(buffer) - strm.avail_out;
|
||||
if (bytesProduced > 0)
|
||||
outArray.append(buffer, bytesProduced);
|
||||
|
||||
} while (ret != Z_STREAM_END);
|
||||
|
||||
inflateEnd(&strm);
|
||||
return outArray;
|
||||
}
|
||||
|
||||
static QByteArray DecompressLZO(const QByteArray& input) {
|
||||
lzokay::EResult error;
|
||||
|
||||
// Ensure the input QByteArray is valid
|
||||
if (input.isEmpty()) {
|
||||
qDebug() << "Input QByteArray is empty.";
|
||||
return QByteArray();
|
||||
}
|
||||
|
||||
// Step 1: Cast QByteArray to uint8_t*
|
||||
const uint8_t *compressedData = reinterpret_cast<const uint8_t *>(input.constData());
|
||||
std::size_t compressedSize = static_cast<std::size_t>(input.size());
|
||||
|
||||
// Step 2: Allocate a sufficiently large decompression buffer
|
||||
// Use a large initial estimate if the decompressed size is unknown
|
||||
std::size_t initialBufferSize = compressedSize * 20; // Arbitrary multiplier for decompression
|
||||
std::unique_ptr<uint8_t[]> decompressed(new uint8_t[initialBufferSize]);
|
||||
|
||||
// Step 3: Attempt decompression
|
||||
std::size_t decompressedSize = 0;
|
||||
error = lzokay::decompress(
|
||||
compressedData, compressedSize, // Input data and size
|
||||
decompressed.get(), initialBufferSize, // Output buffer and initial size
|
||||
decompressedSize // Actual decompressed size
|
||||
);
|
||||
|
||||
// Step 4: Handle decompression errors
|
||||
if (error != lzokay::EResult::Success) {
|
||||
qDebug() << "Decompression failed with error code:" << static_cast<int>(error);
|
||||
return QByteArray();
|
||||
}
|
||||
|
||||
// Step 5: Return the decompressed data as a QByteArray
|
||||
return QByteArray(reinterpret_cast<const char *>(decompressed.get()), decompressedSize);
|
||||
}
|
||||
|
||||
static const int VECTOR_SIZE = 16; // 16 32-bit words
|
||||
static const int NUM_OF_BLOCKS_PER_CHUNK = 8192;
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Helper functions (assuming little–endian order)
|
||||
|
||||
static void Convert32BitTo8Bit(quint32 value, quint8* array) {
|
||||
array[0] = static_cast<quint8>(value >> 0);
|
||||
array[1] = static_cast<quint8>(value >> 8);
|
||||
array[2] = static_cast<quint8>(value >> 16);
|
||||
array[3] = static_cast<quint8>(value >> 24);
|
||||
}
|
||||
|
||||
static quint32 ConvertArrayTo32Bit(const QByteArray &array) {
|
||||
return ((static_cast<quint32>(static_cast<uchar>(array[0])) << 0) |
|
||||
(static_cast<quint32>(static_cast<uchar>(array[1])) << 8) |
|
||||
(static_cast<quint32>(static_cast<uchar>(array[2])) << 16) |
|
||||
(static_cast<quint32>(static_cast<uchar>(array[3])) << 24));
|
||||
}
|
||||
|
||||
static quint32 Rotate(quint32 value, quint32 numBits) {
|
||||
return (value << numBits) | (value >> (32 - numBits));
|
||||
}
|
||||
|
||||
// Build the IV table from a 0x20–byte feed. The table is 0xFB0 bytes.
|
||||
static QByteArray InitIVTable(const QByteArray &feed) {
|
||||
const int tableSize = 0xFB0;
|
||||
QByteArray table;
|
||||
table.resize(tableSize);
|
||||
int ptr = 0;
|
||||
for (int i = 0; i < 200; ++i) {
|
||||
for (int x = 0; x < 5; ++x) {
|
||||
if (static_cast<uchar>(feed.at(ptr)) == 0x00)
|
||||
ptr = 0;
|
||||
int base = i * 20 + x * 4;
|
||||
table[base] = feed.at(ptr);
|
||||
table[base + 1] = feed.at(ptr);
|
||||
table[base + 2] = feed.at(ptr);
|
||||
table[base + 3] = feed.at(ptr);
|
||||
++ptr;
|
||||
}
|
||||
}
|
||||
// Copy block numbers [1,0,0,0] into the last 16 bytes
|
||||
QByteArray oneBlock;
|
||||
oneBlock.append(char(1)); oneBlock.append(char(0)); oneBlock.append(char(0)); oneBlock.append(char(0));
|
||||
table.replace(0xFA0, 4, oneBlock);
|
||||
table.replace(0xFA4, 4, oneBlock);
|
||||
table.replace(0xFA8, 4, oneBlock);
|
||||
table.replace(0xFAC, 4, oneBlock);
|
||||
return table;
|
||||
}
|
||||
|
||||
// "unk" function as in the C# code.
|
||||
static int unk(quint64 arg1, quint8 arg2) {
|
||||
if (arg2 >= 0x40)
|
||||
return 0;
|
||||
return static_cast<int>(arg1 >> arg2);
|
||||
}
|
||||
|
||||
// Compute the IV for a given section index using the IV table.
|
||||
static QByteArray GetIV(const QByteArray &table, int index) {
|
||||
int num1 = 0xFA0 + index;
|
||||
int num2 = unk(0x51EB851FLL * num1, 0x20);
|
||||
int adjust = ((num2 >> 6) + (num2 >> 31));
|
||||
int startIndex = 20 * (num1 - 200 * adjust);
|
||||
// Return 8 bytes from that location.
|
||||
return table.mid(startIndex, 8);
|
||||
}
|
||||
|
||||
// Update the IV table given the section's SHA1 hash.
|
||||
static void UpdateIVTable(QByteArray &table, int index, const QByteArray §ionHash) {
|
||||
int blockNumIndex = index % 4;
|
||||
int baseOffset = 0xFA0 + blockNumIndex * 4;
|
||||
quint32 blockNumVal = (static_cast<uchar>(table.at(baseOffset)) ) |
|
||||
(static_cast<uchar>(table.at(baseOffset + 1)) << 8 ) |
|
||||
(static_cast<uchar>(table.at(baseOffset + 2)) << 16) |
|
||||
(static_cast<uchar>(table.at(baseOffset + 3)) << 24);
|
||||
int blockNum = blockNumVal * 4 + index;
|
||||
int num2 = unk(0x51EB851FLL * blockNum, 0x20);
|
||||
int adjust = ((num2 >> 6) + (num2 >> 31));
|
||||
int startIndex = 20 * (blockNum - 200 * adjust) + 1;
|
||||
int hashIndex = 0;
|
||||
for (int x = 0; x < 4; ++x) {
|
||||
table[startIndex - 1] = table.at(startIndex - 1) ^ sectionHash.at(hashIndex);
|
||||
table[startIndex] = table.at(startIndex) ^ sectionHash.at(hashIndex + 1);
|
||||
table[startIndex + 1] = table.at(startIndex + 1) ^ sectionHash.at(hashIndex + 2);
|
||||
table[startIndex + 2] = table.at(startIndex + 2) ^ sectionHash.at(hashIndex + 3);
|
||||
table[startIndex + 3] = table.at(startIndex + 3) ^ sectionHash.at(hashIndex + 4);
|
||||
startIndex += 5;
|
||||
hashIndex += 5;
|
||||
}
|
||||
}
|
||||
|
||||
static quint32 ToUInt32(const QByteArray &data, int offset) {
|
||||
// Converts 4 bytes (starting at offset) from data into a 32-bit unsigned integer (little-endian)
|
||||
return ((static_cast<quint32>(static_cast<uchar>(data[offset])) ) |
|
||||
(static_cast<quint32>(static_cast<uchar>(data[offset+1])) << 8 ) |
|
||||
(static_cast<quint32>(static_cast<uchar>(data[offset+2])) << 16) |
|
||||
(static_cast<quint32>(static_cast<uchar>(data[offset+3])) << 24));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Salsa20 decryption for one section.
|
||||
// This function resets the counter for each section.
|
||||
static QByteArray salsa20DecryptSection(const QByteArray §ionData, const QByteArray &key, const QByteArray &iv, int blockSize = 64)
|
||||
{
|
||||
// Choose the appropriate constant based on key length.
|
||||
QByteArray constants;
|
||||
if (key.size() == 32)
|
||||
constants = "expand 32-byte k";
|
||||
else if (key.size() == 16)
|
||||
constants = "expand 16-byte k";
|
||||
else {
|
||||
qWarning() << "Invalid key size:" << key.size() << "; expected 16 or 32 bytes.";
|
||||
return QByteArray();
|
||||
}
|
||||
|
||||
QVector<quint32> state(VECTOR_SIZE);
|
||||
|
||||
// Set state[0] using the first 4 bytes of the constant.
|
||||
state[0] = ConvertArrayTo32Bit(constants.mid(0, 4));
|
||||
|
||||
// state[1] through state[4] come from the first 16 bytes of the key.
|
||||
state[1] = ToUInt32(key, 0);
|
||||
state[2] = ToUInt32(key, 4);
|
||||
state[3] = ToUInt32(key, 8);
|
||||
state[4] = ToUInt32(key, 12);
|
||||
|
||||
// state[5] comes from the next 4 bytes of the constant.
|
||||
state[5] = ConvertArrayTo32Bit(constants.mid(4, 4));
|
||||
|
||||
// state[6] and state[7] come from the IV (which must be 8 bytes).
|
||||
state[6] = ConvertArrayTo32Bit(iv.mid(0, 4));
|
||||
state[7] = ConvertArrayTo32Bit(iv.mid(4, 4));
|
||||
|
||||
// state[8] and state[9] are the 64-bit block counter (start at 0).
|
||||
state[8] = 0;
|
||||
state[9] = 0;
|
||||
|
||||
// state[10] comes from the next 4 bytes of the constant.
|
||||
state[10] = ConvertArrayTo32Bit(constants.mid(8, 4));
|
||||
|
||||
// For state[11] through state[14]:
|
||||
// If the key is 32 bytes, use bytes 16..31; if 16 bytes, reuse the first 16 bytes.
|
||||
if (key.size() == 32) {
|
||||
state[11] = ToUInt32(key, 16);
|
||||
state[12] = ToUInt32(key, 20);
|
||||
state[13] = ToUInt32(key, 24);
|
||||
state[14] = ToUInt32(key, 28);
|
||||
} else { // key.size() == 16
|
||||
state[11] = ToUInt32(key, 0);
|
||||
state[12] = ToUInt32(key, 4);
|
||||
state[13] = ToUInt32(key, 8);
|
||||
state[14] = ToUInt32(key, 12);
|
||||
}
|
||||
|
||||
// state[15] comes from the last 4 bytes of the constant.
|
||||
state[15] = ConvertArrayTo32Bit(constants.mid(12, 4));
|
||||
|
||||
// Prepare the output buffer.
|
||||
QByteArray output(sectionData.size(), Qt::Uninitialized);
|
||||
int numBlocks = sectionData.size() / blockSize;
|
||||
int remainder = sectionData.size() % blockSize;
|
||||
|
||||
// Process each full block.
|
||||
for (int blockIndex = 0; blockIndex < numBlocks; ++blockIndex) {
|
||||
QVector<quint32> x = state; // make a copy of the current state for this block
|
||||
|
||||
// Run 20 rounds (10 iterations) of Salsa20.
|
||||
for (int round = 20; round > 0; round -= 2) {
|
||||
x[4] ^= Rotate(x[0] + x[12], 7);
|
||||
x[8] ^= Rotate(x[4] + x[0], 9);
|
||||
x[12] ^= Rotate(x[8] + x[4], 13);
|
||||
x[0] ^= Rotate(x[12] + x[8], 18);
|
||||
|
||||
x[9] ^= Rotate(x[5] + x[1], 7);
|
||||
x[13] ^= Rotate(x[9] + x[5], 9);
|
||||
x[1] ^= Rotate(x[13] + x[9], 13);
|
||||
x[5] ^= Rotate(x[1] + x[13], 18);
|
||||
|
||||
x[14] ^= Rotate(x[10] + x[6], 7);
|
||||
x[2] ^= Rotate(x[14] + x[10], 9);
|
||||
x[6] ^= Rotate(x[2] + x[14], 13);
|
||||
x[10] ^= Rotate(x[6] + x[2], 18);
|
||||
|
||||
x[3] ^= Rotate(x[15] + x[11], 7);
|
||||
x[7] ^= Rotate(x[3] + x[15], 9);
|
||||
x[11] ^= Rotate(x[7] + x[3], 13);
|
||||
x[15] ^= Rotate(x[11] + x[7], 18);
|
||||
|
||||
x[1] ^= Rotate(x[0] + x[3], 7);
|
||||
x[2] ^= Rotate(x[1] + x[0], 9);
|
||||
x[3] ^= Rotate(x[2] + x[1], 13);
|
||||
x[0] ^= Rotate(x[3] + x[2], 18);
|
||||
|
||||
x[6] ^= Rotate(x[5] + x[4], 7);
|
||||
x[7] ^= Rotate(x[6] + x[5], 9);
|
||||
x[4] ^= Rotate(x[7] + x[6], 13);
|
||||
x[5] ^= Rotate(x[4] + x[7], 18);
|
||||
|
||||
x[11] ^= Rotate(x[10] + x[9], 7);
|
||||
x[8] ^= Rotate(x[11] + x[10], 9);
|
||||
x[9] ^= Rotate(x[8] + x[11], 13);
|
||||
x[10] ^= Rotate(x[9] + x[8], 18);
|
||||
|
||||
x[12] ^= Rotate(x[15] + x[14], 7);
|
||||
x[13] ^= Rotate(x[12] + x[15], 9);
|
||||
x[14] ^= Rotate(x[13] + x[12], 13);
|
||||
x[15] ^= Rotate(x[14] + x[13], 18);
|
||||
}
|
||||
|
||||
// Produce the 64-byte keystream block by adding the original state.
|
||||
QVector<quint8> keyStreamBlock(blockSize);
|
||||
for (int i = 0; i < VECTOR_SIZE; ++i) {
|
||||
x[i] += state[i];
|
||||
Convert32BitTo8Bit(x[i], keyStreamBlock.data() + 4 * i);
|
||||
}
|
||||
|
||||
// XOR the keystream block with the corresponding block of sectionData.
|
||||
const uchar* inBlock = reinterpret_cast<const uchar*>(sectionData.constData()) + blockIndex * blockSize;
|
||||
uchar* outBlock = reinterpret_cast<uchar*>(output.data()) + blockIndex * blockSize;
|
||||
for (int j = 0; j < blockSize; ++j) {
|
||||
outBlock[j] = inBlock[j] ^ keyStreamBlock[j];
|
||||
}
|
||||
// Increment the 64-bit block counter.
|
||||
state[8]++;
|
||||
if (state[8] == 0)
|
||||
state[9]++;
|
||||
}
|
||||
|
||||
// Process any remaining bytes.
|
||||
if (remainder > 0) {
|
||||
QVector<quint32> x = state;
|
||||
for (int round = 20; round > 0; round -= 2) {
|
||||
x[4] ^= Rotate(x[0] + x[12], 7);
|
||||
x[8] ^= Rotate(x[4] + x[0], 9);
|
||||
x[12] ^= Rotate(x[8] + x[4], 13);
|
||||
x[0] ^= Rotate(x[12] + x[8], 18);
|
||||
|
||||
x[9] ^= Rotate(x[5] + x[1], 7);
|
||||
x[13] ^= Rotate(x[9] + x[5], 9);
|
||||
x[1] ^= Rotate(x[13] + x[9], 13);
|
||||
x[5] ^= Rotate(x[1] + x[13], 18);
|
||||
|
||||
x[14] ^= Rotate(x[10] + x[6], 7);
|
||||
x[2] ^= Rotate(x[14] + x[10], 9);
|
||||
x[6] ^= Rotate(x[2] + x[14], 13);
|
||||
x[10] ^= Rotate(x[6] + x[2], 18);
|
||||
|
||||
x[3] ^= Rotate(x[15] + x[11], 7);
|
||||
x[7] ^= Rotate(x[3] + x[15], 9);
|
||||
x[11] ^= Rotate(x[7] + x[3], 13);
|
||||
x[15] ^= Rotate(x[11] + x[7], 18);
|
||||
|
||||
x[1] ^= Rotate(x[0] + x[3], 7);
|
||||
x[2] ^= Rotate(x[1] + x[0], 9);
|
||||
x[3] ^= Rotate(x[2] + x[1], 13);
|
||||
x[0] ^= Rotate(x[3] + x[2], 18);
|
||||
|
||||
x[6] ^= Rotate(x[5] + x[4], 7);
|
||||
x[7] ^= Rotate(x[6] + x[5], 9);
|
||||
x[4] ^= Rotate(x[7] + x[6], 13);
|
||||
x[5] ^= Rotate(x[4] + x[7], 18);
|
||||
|
||||
x[11] ^= Rotate(x[10] + x[9], 7);
|
||||
x[8] ^= Rotate(x[11] + x[10], 9);
|
||||
x[9] ^= Rotate(x[8] + x[11], 13);
|
||||
x[10] ^= Rotate(x[9] + x[8], 18);
|
||||
|
||||
x[12] ^= Rotate(x[15] + x[14], 7);
|
||||
x[13] ^= Rotate(x[12] + x[15], 9);
|
||||
x[14] ^= Rotate(x[13] + x[12], 13);
|
||||
x[15] ^= Rotate(x[14] + x[13], 18);
|
||||
}
|
||||
QVector<quint8> keyStreamBlock(blockSize);
|
||||
for (int i = 0; i < VECTOR_SIZE; ++i) {
|
||||
x[i] += state[i];
|
||||
Convert32BitTo8Bit(x[i], keyStreamBlock.data() + 4 * i);
|
||||
}
|
||||
const uchar* inBlock = reinterpret_cast<const uchar*>(sectionData.constData()) + numBlocks * blockSize;
|
||||
uchar* outBlock = reinterpret_cast<uchar*>(output.data()) + numBlocks * blockSize;
|
||||
for (int j = 0; j < remainder; ++j)
|
||||
outBlock[j] = inBlock[j] ^ keyStreamBlock[j];
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif // COMPRESSOR_H
|
||||
19
d3dbsp_structs.h
Normal file
@ -0,0 +1,19 @@
|
||||
#ifndef D3DBSP_STRUCTS_H
|
||||
#define D3DBSP_STRUCTS_H
|
||||
|
||||
#include <QByteArray>
|
||||
|
||||
// Define Lump Structure
|
||||
struct Lump {
|
||||
QByteArray content;
|
||||
quint32 size = 0;
|
||||
bool isEmpty = true;
|
||||
};
|
||||
|
||||
// Lump Index Entry Structure
|
||||
struct LumpIndexEntry {
|
||||
quint32 type;
|
||||
quint32 length;
|
||||
};
|
||||
|
||||
#endif // D3DBSP_STRUCTS_H
|
||||
57
data/Data.qrc
Normal file
@ -0,0 +1,57 @@
|
||||
<RCC>
|
||||
<qresource prefix="/obj">
|
||||
<file>obj/defaultactor_LOD0.XMODEL_BIN</file>
|
||||
<file>obj/defaultactor_LOD0.XMODEL_EXPORT</file>
|
||||
<file>obj/defaultactor_LOD0.bin</file>
|
||||
<file>obj/defaultactor_LOD0.cast</file>
|
||||
<file>obj/defaultactor_LOD0.gltf</file>
|
||||
<file>obj/defaultactor_LOD0.ma</file>
|
||||
<file>obj/defaultactor_LOD0.mesh.ascii</file>
|
||||
<file>obj/defaultactor_LOD0.obj</file>
|
||||
<file>obj/defaultactor_LOD0.semodel</file>
|
||||
<file>obj/defaultactor_LOD0.smd</file>
|
||||
<file>obj/defaultactor_LOD0_BIND.mel</file>
|
||||
<file>obj/defaultactor_LOD0_cosmetics.mel</file>
|
||||
<file>obj/diffusemap.png</file>
|
||||
<file>obj/mtl_body_default_character.mtl</file>
|
||||
<file>obj/mtl_body_default_character_images.txt</file>
|
||||
<file>obj/normalmap.png</file>
|
||||
</qresource>
|
||||
<qresource prefix="/d3dbsp">
|
||||
<file>d3dbsp/asset_viewer.d3dbsp</file>
|
||||
<file>d3dbsp/barebones.d3dbsp</file>
|
||||
</qresource>
|
||||
<qresource prefix="/images">
|
||||
<file>images/XPlor.png</file>
|
||||
<file>images/copy.svg</file>
|
||||
<file>images/cut.svg</file>
|
||||
<file>images/multiple.png</file>
|
||||
<file>images/new_file.svg</file>
|
||||
<file>images/open_file.svg</file>
|
||||
<file>images/open_folder.svg</file>
|
||||
<file>images/paste.svg</file>
|
||||
<file>images/refresh.svg</file>
|
||||
<file>images/save.svg</file>
|
||||
</qresource>
|
||||
<qresource prefix="/icons">
|
||||
<file>icons/Icon_COD4.png</file>
|
||||
<file>icons/Icon_COD5.png</file>
|
||||
<file>icons/Icon_COD6.png</file>
|
||||
<file>icons/Icon_COD7.png</file>
|
||||
<file>icons/Icon_COD8.png</file>
|
||||
<file>icons/Icon_COD9.png</file>
|
||||
<file>icons/Icon_DDSFile.png</file>
|
||||
<file>icons/Icon_FastFile.png</file>
|
||||
<file>icons/Icon_IWIFile.png</file>
|
||||
<file>icons/Icon_PC.png</file>
|
||||
<file>icons/Icon_Playstation.png</file>
|
||||
<file>icons/Icon_Xbox.png</file>
|
||||
<file>icons/Icon_ZoneFile.png</file>
|
||||
<file>icons/Icon_GSCFile.png</file>
|
||||
<file>icons/Icon_StringFile.png</file>
|
||||
<file>icons/Icon_TechSetFile.png</file>
|
||||
<file>icons/Icon_WAVFile.png</file>
|
||||
<file>icons/Icon_MenuFile.png</file>
|
||||
<file>icons/Icon_Image.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
BIN
data/icons/Icon_COD4.png
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
BIN
data/icons/Icon_COD5.png
Normal file
|
After Width: | Height: | Size: 2.2 KiB |
BIN
data/icons/Icon_COD6.png
Normal file
|
After Width: | Height: | Size: 2.2 KiB |
BIN
data/icons/Icon_COD7.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
data/icons/Icon_COD8.png
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
data/icons/Icon_COD9.png
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
data/icons/Icon_DDSFile.png
Normal file
|
After Width: | Height: | Size: 2.2 KiB |
BIN
data/icons/Icon_FastFile.png
Normal file
|
After Width: | Height: | Size: 855 B |
BIN
data/icons/Icon_GSCFile.png
Normal file
|
After Width: | Height: | Size: 2.5 KiB |
BIN
data/icons/Icon_IWIFile.png
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
BIN
data/icons/Icon_Image.png
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
BIN
data/icons/Icon_MenuFile.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
data/icons/Icon_PC.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
data/icons/Icon_Playstation.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
data/icons/Icon_StringFile.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
data/icons/Icon_TechSetFile.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
data/icons/Icon_WAVFile.png
Normal file
|
After Width: | Height: | Size: 2.5 KiB |
BIN
data/icons/Icon_Xbox.png
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
data/icons/Icon_ZoneFile.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
8
dds_structs.h
Normal file
@ -0,0 +1,8 @@
|
||||
#ifndef DDS_STRUCTS_H
|
||||
#define DDS_STRUCTS_H
|
||||
|
||||
#include <qtypes.h>
|
||||
#include <QVector>
|
||||
|
||||
|
||||
#endif // DDS_STRUCTS_H
|
||||
345
ddsfile.cpp
Normal file
@ -0,0 +1,345 @@
|
||||
#include "ddsfile.h"
|
||||
#include "enums.h"
|
||||
#include "iwifile.h"
|
||||
|
||||
DDSPixelFormat DDSFile::CalculatePixelFormat(quint8 aIWIFormat) {
|
||||
DDSPixelFormat ddsPixelFormat = {};
|
||||
ddsPixelFormat.size = 16; // Fixed
|
||||
ddsPixelFormat.format = 0;
|
||||
|
||||
switch (aIWIFormat) {
|
||||
case IWI_FORMAT_ARGB32:
|
||||
ddsPixelFormat.flags = DDPF_RGB | DDPF_ALPHAPIXELS;
|
||||
ddsPixelFormat.rgbBitCount = 32;
|
||||
ddsPixelFormat.rBitMask = 0x00ff0000;
|
||||
ddsPixelFormat.gBitMask = 0x0000ff00;
|
||||
ddsPixelFormat.bBitMask = 0x000000ff;
|
||||
ddsPixelFormat.aBitMask = 0xff000000;
|
||||
break;
|
||||
case IWI_FORMAT_DXT1:
|
||||
ddsPixelFormat.flags = DDPF_FOURCC;
|
||||
ddsPixelFormat.format = 0x31545844;
|
||||
break;
|
||||
case IWI_FORMAT_DXT3:
|
||||
ddsPixelFormat.flags = DDPF_FOURCC;
|
||||
ddsPixelFormat.format = 0x33545844;
|
||||
break;
|
||||
case IWI_FORMAT_DXT5:
|
||||
ddsPixelFormat.flags = DDPF_FOURCC;
|
||||
ddsPixelFormat.format = 0x35545844;
|
||||
break;
|
||||
default:
|
||||
qDebug() << "Error: Invalid IWI format: " << aIWIFormat;
|
||||
return {};
|
||||
}
|
||||
return ddsPixelFormat;
|
||||
}
|
||||
|
||||
void DDSFile::SetupExportDirs() {
|
||||
QDir dir = QDir::currentPath();
|
||||
if (!dir.exists("exports/")) {
|
||||
dir.mkdir("exports/");
|
||||
}
|
||||
|
||||
if (!dir.exists("exports/iwi/")) {
|
||||
dir.mkdir("exports/iwi/");
|
||||
}
|
||||
if (!dir.exists("exports/dds/")) {
|
||||
dir.mkdir("exports/dds/");
|
||||
}
|
||||
if (!dir.exists("exports/png/")) {
|
||||
dir.mkdir("exports/png/");
|
||||
}
|
||||
if (!dir.exists("exports/jpg/")) {
|
||||
dir.mkdir("exports/jpg/");
|
||||
}
|
||||
}
|
||||
|
||||
DDSFile::DDSFile() :
|
||||
fileStem(),
|
||||
header(),
|
||||
mipmaps() {
|
||||
|
||||
}
|
||||
|
||||
QByteArray DDSFile::ReadDDSFile(const QString &aFilePath) {
|
||||
if (!aFilePath.endsWith(".dds", Qt::CaseInsensitive)) {
|
||||
qDebug() << "Error: Invalid filename " << aFilePath;
|
||||
return {};
|
||||
}
|
||||
|
||||
if (!QFile::exists(aFilePath)) {
|
||||
qDebug() << "Error: File does not exist!";
|
||||
return {};
|
||||
}
|
||||
|
||||
QFile file(aFilePath);
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
qDebug() << "Error: Failed to read DDS file.";
|
||||
return {};
|
||||
}
|
||||
|
||||
const QByteArray ddsData = file.readAll();
|
||||
file.close();
|
||||
return ddsData;
|
||||
}
|
||||
|
||||
DDSFile::DDSFile(const QString &aFilePath)
|
||||
: DDSFile(ReadDDSFile(aFilePath), aFilePath.split('.').first().split('/').last()) {
|
||||
}
|
||||
|
||||
DDSFile::DDSFile(const QByteArray aDDSData, const QString aFileStem) {
|
||||
QDataStream ddsIn(aDDSData);
|
||||
ddsIn.setByteOrder(QDataStream::LittleEndian);
|
||||
|
||||
DDSHeader ddsHeader;
|
||||
if (ddsIn.readRawData(reinterpret_cast<char*>(&ddsHeader), sizeof(DDSHeader)) != sizeof(DDSHeader)) {
|
||||
qDebug() << "Error: Failed to read DDSHeader from QByteArray!";
|
||||
return;
|
||||
}
|
||||
|
||||
fileStem = aFileStem;
|
||||
header = ddsHeader;
|
||||
|
||||
// Ensure DevIL is initialized once globally
|
||||
static bool devilInitialized = false;
|
||||
if (!devilInitialized) {
|
||||
ilInit();
|
||||
devilInitialized = true;
|
||||
}
|
||||
|
||||
// Generate and bind an image
|
||||
ILuint imageID;
|
||||
ilGenImages(1, &imageID);
|
||||
ilBindImage(imageID);
|
||||
|
||||
ilEnable(IL_ORIGIN_SET);
|
||||
ilOriginFunc(IL_ORIGIN_UPPER_LEFT);
|
||||
|
||||
// Load DDS file
|
||||
if (!ilLoadL(IL_DDS, aDDSData.constData(), aDDSData.size())) {
|
||||
ILuint devilError = ilGetError();
|
||||
qDebug() << "DevIL Error while loading DDS: " << devilError;
|
||||
ilDeleteImages(1, &imageID);
|
||||
return;
|
||||
}
|
||||
|
||||
// Get mipmap count
|
||||
ILint numMipmaps = ilGetInteger(IL_NUM_MIPMAPS);
|
||||
qDebug() << "Number of mipmaps: " << numMipmaps;
|
||||
|
||||
// Loop over all mipmap levels (0 is the base image)
|
||||
for (ILint level = 0; level <= numMipmaps; ++level) {
|
||||
ilBindImage(imageID);
|
||||
if (!ilActiveMipmap(level)) {
|
||||
qDebug() << "DevIL failed to activate mipmap level" << level;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get mipmap properties
|
||||
int width = ilGetInteger(IL_IMAGE_WIDTH);
|
||||
int height = ilGetInteger(IL_IMAGE_HEIGHT);
|
||||
int depth = ilGetInteger(IL_IMAGE_DEPTH);
|
||||
int format = ilGetInteger(IL_IMAGE_FORMAT);
|
||||
int bpp = 0;
|
||||
|
||||
switch (format) {
|
||||
case IL_RGB:
|
||||
bpp = 3;
|
||||
break;
|
||||
case IL_RGBA:
|
||||
bpp = 4;
|
||||
break;
|
||||
default:
|
||||
qDebug() << "Unsupported image format.";
|
||||
continue;
|
||||
}
|
||||
|
||||
int dataSize = width * height * depth * bpp;
|
||||
|
||||
ILubyte *data = ilGetData();
|
||||
if (!data) {
|
||||
qDebug() << "Error: DevIL returned null data for mipmap level" << level;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Create a mipmap structure
|
||||
DDSMipmap mipmap;
|
||||
mipmap.width = width;
|
||||
mipmap.height = height;
|
||||
mipmap.data = QByteArray(reinterpret_cast<const char*>(data), dataSize);
|
||||
mipmap.size = dataSize;
|
||||
|
||||
// Store in DDS file
|
||||
mipmaps.append(mipmap);
|
||||
}
|
||||
|
||||
ilDeleteImages(1, &imageID);
|
||||
}
|
||||
|
||||
DDSFile::DDSFile(const DDSFile &ddsFile) :
|
||||
fileStem(ddsFile.fileStem),
|
||||
header(ddsFile.header),
|
||||
mipmaps(ddsFile.mipmaps) {
|
||||
|
||||
}
|
||||
|
||||
DDSFile::DDSFile(const IWIFile &aIWIFile)
|
||||
: DDSFile(IWItoDDSData(aIWIFile), aIWIFile.fileStem) {
|
||||
}
|
||||
|
||||
QByteArray DDSFile::IWItoDDSData(const IWIFile &aIWIFile) {
|
||||
DDSHeader ddsHeader = {};
|
||||
ddsHeader.magic = 0x20534444; // 'DDS '
|
||||
ddsHeader.size = 124;
|
||||
ddsHeader.flags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT | DDSD_LINEARSIZE;
|
||||
ddsHeader.height = aIWIFile.info.Height;
|
||||
ddsHeader.width = aIWIFile.info.Width;
|
||||
ddsHeader.depth = 0;
|
||||
ddsHeader.mipMapCount = aIWIFile.mipmaps.size();
|
||||
|
||||
DDSPixelFormat ddsPixelFormat = CalculatePixelFormat(aIWIFile.info.Format);
|
||||
if (ddsPixelFormat.flags & DDPF_FOURCC) {
|
||||
ddsHeader.flags |= DDSD_LINEARSIZE;
|
||||
} else {
|
||||
ddsHeader.flags |= DDSD_PITCH;
|
||||
}
|
||||
ddsHeader.pixelFormat = ddsPixelFormat;
|
||||
|
||||
// Calculate pitch/linear size
|
||||
if (ddsPixelFormat.flags & DDPF_FOURCC) {
|
||||
int blockSize = (ddsPixelFormat.format == 0x31545844) ? 8 : 16;
|
||||
ddsHeader.pitchOrLinearSize = fmax(1, (ddsHeader.width + 3) / 4) * blockSize * (ddsHeader.height / 4);
|
||||
} else {
|
||||
ddsHeader.pitchOrLinearSize = ddsHeader.width * (ddsPixelFormat.rgbBitCount / 8);
|
||||
}
|
||||
|
||||
DDSCaps ddsCaps = {};
|
||||
ddsCaps.caps1 = DDSCAPS_TEXTURE;
|
||||
ddsCaps.caps2 = 0;
|
||||
ddsCaps.dDSX = 0;
|
||||
ddsCaps.reserved = 0;
|
||||
ddsHeader.caps = ddsCaps;
|
||||
|
||||
QByteArray ddsData;
|
||||
QDataStream out(&ddsData, QIODevice::WriteOnly);
|
||||
out.setByteOrder(QDataStream::LittleEndian);
|
||||
|
||||
// Write DDS header
|
||||
out.writeRawData(reinterpret_cast<const char*>(&ddsHeader), sizeof(DDSHeader));
|
||||
|
||||
for (auto mipmap : aIWIFile.mipmaps) {
|
||||
if (!mipmap.data.size()) { continue; }
|
||||
|
||||
// Write mipmap data
|
||||
out.writeRawData(reinterpret_cast<const char*>(mipmap.data.constData()), mipmap.data.size());
|
||||
}
|
||||
|
||||
return ddsData;
|
||||
}
|
||||
|
||||
DDSFile &DDSFile::operator=(const DDSFile &other) {
|
||||
if (this != &other) {
|
||||
fileStem = other.fileStem;
|
||||
header = other.header;
|
||||
mipmaps = other.mipmaps;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Write a DDS file from a DDSFile object
|
||||
bool DDSFile::SaveDDS() {
|
||||
SetupExportDirs();
|
||||
|
||||
QFile file("exports/dds/" + fileStem + ".dds");
|
||||
if (!file.open(QIODevice::WriteOnly)) {
|
||||
qDebug() << "Error: Unable to write DDS file" << fileStem + ".dds";
|
||||
return false;
|
||||
}
|
||||
|
||||
QDataStream out(&file);
|
||||
out.setByteOrder(QDataStream::LittleEndian);
|
||||
|
||||
// Write DDS Header
|
||||
out.writeRawData(reinterpret_cast<const char*>(&header), sizeof(DDSHeader));
|
||||
file.close();
|
||||
|
||||
qDebug() << "Successfully wrote DDS file: " << fileStem + ".dds";
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DDSFile::SaveIWI() {
|
||||
SetupExportDirs();
|
||||
|
||||
IWIFile iwiFile(*this);
|
||||
if (!iwiFile.SaveIWI()) {
|
||||
qDebug() << "Error: Unable to write IWI file" << fileStem + ".iwi";
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DDSFile::SavePNG() {
|
||||
SetupExportDirs();
|
||||
|
||||
int mipmapIndex = 1;
|
||||
for (const DDSMipmap &mipmap : mipmaps) {
|
||||
QString subFilePath = "exports/png/" + fileStem + ".png";
|
||||
if (mipmaps.size() > 1) {
|
||||
subFilePath = "exports/png/" + fileStem + QString("_%1").arg(mipmapIndex) + ".png";
|
||||
}
|
||||
|
||||
// Calculate bytes per line (stride)
|
||||
int bytesPerPixel = 4; // Assuming RGBA8888 (4 bytes per pixel)
|
||||
int bytesPerLine = mipmap.width * bytesPerPixel;
|
||||
|
||||
QImage image(reinterpret_cast<const uchar*>(mipmap.data.constData()),
|
||||
mipmap.width, mipmap.height, bytesPerLine, QImage::Format_RGBA8888);
|
||||
|
||||
if (image.isNull()) {
|
||||
qDebug() << "Error: Failed to create QImage for mipmap" << mipmapIndex;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!image.save(subFilePath)) {
|
||||
qDebug() << "Error: Unable to save PNG file" << subFilePath;
|
||||
return false;
|
||||
}
|
||||
|
||||
mipmapIndex++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DDSFile::SaveJPG() {
|
||||
SetupExportDirs();
|
||||
|
||||
int mipmapIndex = 1;
|
||||
for (const DDSMipmap &mipmap : mipmaps) {
|
||||
QString subFilePath = "exports/jpg/" + fileStem + ".jpg";
|
||||
if (mipmaps.size() > 1) {
|
||||
subFilePath = "exports/jpg/" + fileStem + QString("_%1").arg(mipmapIndex) + ".jpg";
|
||||
}
|
||||
|
||||
// Calculate bytes per line (stride)
|
||||
int bytesPerPixel = 4; // Assuming RGBA8888 (4 bytes per pixel)
|
||||
int bytesPerLine = mipmap.width * bytesPerPixel;
|
||||
|
||||
QImage image(reinterpret_cast<const uchar*>(mipmap.data.constData()),
|
||||
mipmap.width, mipmap.height, bytesPerLine, QImage::Format_RGBA8888);
|
||||
|
||||
if (image.isNull()) {
|
||||
qDebug() << "Error: Failed to create QImage for mipmap" << mipmapIndex;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!image.save(subFilePath, "JPG")) {
|
||||
qDebug() << "Error: Unable to save JPG file" << subFilePath;
|
||||
return false;
|
||||
}
|
||||
|
||||
mipmapIndex++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
84
ddsfile.h
Normal file
@ -0,0 +1,84 @@
|
||||
#ifndef DDSFILE_H
|
||||
#define DDSFILE_H
|
||||
|
||||
#include "enums.h"
|
||||
#include <QFile>
|
||||
#include <QByteArray>
|
||||
#include <QDataStream>
|
||||
#include <QtEndian>
|
||||
#include <QVector>
|
||||
#include <QDebug>
|
||||
#include <QImage>
|
||||
#include <DevILSDK/include/IL/il.h>
|
||||
|
||||
struct DDSPixelFormat {
|
||||
quint32 size;
|
||||
quint32 flags;
|
||||
quint32 format;
|
||||
quint32 rgbBitCount;
|
||||
quint32 rBitMask;
|
||||
quint32 gBitMask;
|
||||
quint32 bBitMask;
|
||||
quint32 aBitMask;
|
||||
};
|
||||
|
||||
struct DDSCaps {
|
||||
quint32 caps1;
|
||||
quint32 caps2;
|
||||
quint32 dDSX;
|
||||
quint32 reserved;
|
||||
};
|
||||
|
||||
struct DDSHeader {
|
||||
quint32 magic;
|
||||
quint32 size;
|
||||
quint32 flags;
|
||||
quint32 height;
|
||||
quint32 width;
|
||||
quint32 pitchOrLinearSize;
|
||||
quint32 depth;
|
||||
quint32 mipMapCount;
|
||||
quint32 reserved1[11];
|
||||
DDSPixelFormat pixelFormat;
|
||||
DDSCaps caps;
|
||||
quint32 reserved2;
|
||||
};
|
||||
|
||||
// Mipmap Structure
|
||||
struct DDSMipmap {
|
||||
quint32 size;
|
||||
quint32 width;
|
||||
quint32 height;
|
||||
QByteArray data;
|
||||
};
|
||||
|
||||
class IWIFile;
|
||||
|
||||
// DDS File Class
|
||||
class DDSFile {
|
||||
public:
|
||||
QString fileStem;
|
||||
DDSHeader header;
|
||||
QVector<DDSMipmap> mipmaps;
|
||||
|
||||
DDSFile();
|
||||
DDSFile(const QString &aFilePath);
|
||||
DDSFile(const IWIFile &aIWIFile);
|
||||
DDSFile(const QByteArray aDDSData, const QString aFileStem);
|
||||
DDSFile(const DDSFile &ddsFile);
|
||||
DDSFile& operator=(const DDSFile& other);
|
||||
|
||||
bool SaveDDS();
|
||||
bool SaveIWI();
|
||||
bool SavePNG();
|
||||
bool SaveJPG();
|
||||
|
||||
void SetupExportDirs();
|
||||
static DDSPixelFormat CalculatePixelFormat(quint8 aIWIFormat);
|
||||
|
||||
private:
|
||||
static QByteArray ReadDDSFile(const QString &aFilePath);
|
||||
QByteArray IWItoDDSData(const IWIFile &aIWIFile);
|
||||
};
|
||||
|
||||
#endif // DDSFILE_H
|
||||
182
ddsviewer.cpp
Normal file
@ -0,0 +1,182 @@
|
||||
#include "ddsviewer.h"
|
||||
#include "enums.h"
|
||||
#include "ui_ddsviewer.h"
|
||||
|
||||
DDSViewer::DDSViewer(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, ui(new Ui::DDSViewer)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
mDDSFile = nullptr;
|
||||
}
|
||||
|
||||
DDSViewer::~DDSViewer() {
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void DDSViewer::SetDDSFile(std::shared_ptr<DDSFile> aDDSFile) {
|
||||
mDDSFile.swap(aDDSFile);
|
||||
|
||||
ui->label_Title->setText(mDDSFile->fileStem + ".dds");
|
||||
|
||||
char magicData[5];
|
||||
magicData[0] = static_cast<char>(mDDSFile->header.magic & 0xFF);
|
||||
magicData[1] = static_cast<char>((mDDSFile->header.magic >> 8) & 0xFF);
|
||||
magicData[2] = static_cast<char>((mDDSFile->header.magic >> 16) & 0xFF);
|
||||
magicData[3] = static_cast<char>((mDDSFile->header.magic >> 24) & 0xFF);
|
||||
magicData[4] = '\0';
|
||||
|
||||
// If you’re using Qt and want a QString:
|
||||
QString magicStr = QString::fromLatin1(magicData);
|
||||
ui->lineEdit_Magic->setText(magicStr);
|
||||
ui->spinBox_Size->setValue(mDDSFile->header.size);
|
||||
|
||||
ui->checkBox_CapsValid->setChecked((mDDSFile->header.flags & DDSD_CAPS) != 0);
|
||||
ui->checkBox_HeightValid->setChecked((mDDSFile->header.flags & DDSD_HEIGHT) != 0);
|
||||
ui->checkBox_WidthValid->setChecked((mDDSFile->header.flags & DDSD_WIDTH) != 0);
|
||||
ui->checkBox_PitchValid->setChecked((mDDSFile->header.flags & DDSD_PITCH) != 0);
|
||||
ui->checkBox_PFValid->setChecked((mDDSFile->header.flags & DDSD_PIXELFORMAT) != 0);
|
||||
ui->checkBox_MipmapCountValid->setChecked((mDDSFile->header.flags & DDSD_MIPMAPCOUNT) != 0);
|
||||
ui->checkBox_LinearSizeValid->setChecked((mDDSFile->header.flags & DDSD_LINEARSIZE) != 0);
|
||||
ui->checkBox_DepthValid->setChecked((mDDSFile->header.flags & DDSD_DEPTH) != 0);
|
||||
|
||||
ui->spinBox_PLSize->setValue(mDDSFile->header.pitchOrLinearSize);
|
||||
ui->spinBox_Depth->setValue(mDDSFile->header.depth);
|
||||
ui->spinBox_Width->setValue(mDDSFile->header.width);
|
||||
ui->spinBox_Height->setValue(mDDSFile->header.height);
|
||||
ui->spinBox_MipmapCount->setValue(mDDSFile->header.mipMapCount);
|
||||
|
||||
ui->spinBox_Res1->setValue(mDDSFile->header.reserved1[0]);
|
||||
ui->spinBox_Res2->setValue(mDDSFile->header.reserved1[1]);
|
||||
ui->spinBox_Res3->setValue(mDDSFile->header.reserved1[2]);
|
||||
ui->spinBox_Res4->setValue(mDDSFile->header.reserved1[3]);
|
||||
ui->spinBox_Res5->setValue(mDDSFile->header.reserved1[4]);
|
||||
ui->spinBox_Res6->setValue(mDDSFile->header.reserved1[5]);
|
||||
ui->spinBox_Res7->setValue(mDDSFile->header.reserved1[6]);
|
||||
ui->spinBox_Res8->setValue(mDDSFile->header.reserved1[7]);
|
||||
ui->spinBox_Res9->setValue(mDDSFile->header.reserved1[8]);
|
||||
ui->spinBox_Res10->setValue(mDDSFile->header.reserved1[9]);
|
||||
ui->spinBox_Res11->setValue(mDDSFile->header.reserved1[10]);
|
||||
|
||||
ui->spinBox_Res12->setValue(mDDSFile->header.reserved2);
|
||||
|
||||
ui->spinBox_PF_Size->setValue(mDDSFile->header.pixelFormat.size);
|
||||
|
||||
ui->checkBox_PF_AlphaPxValid->setChecked((mDDSFile->header.pixelFormat.flags & DDPF_ALPHAPIXELS) != 0);
|
||||
ui->checkBox_PF_AlphaOnlyValid->setChecked((mDDSFile->header.pixelFormat.flags & DDPF_ALPHA) != 0);
|
||||
ui->checkBox_PF_FormatValid->setChecked((mDDSFile->header.pixelFormat.flags & DDPF_FOURCC) != 0);
|
||||
ui->checkBox_PF_RGBValid->setChecked((mDDSFile->header.pixelFormat.flags & DDPF_RGB) != 0);
|
||||
ui->checkBox_PF_YUVValid->setChecked((mDDSFile->header.pixelFormat.flags & DDPF_YUV) != 0);
|
||||
ui->checkBox_PF_LuminanceValid->setChecked((mDDSFile->header.pixelFormat.flags & DDPF_LUMINANCE) != 0);
|
||||
|
||||
QString formatStr = QString::number(mDDSFile->header.pixelFormat.format);
|
||||
switch (mDDSFile->header.pixelFormat.format) {
|
||||
case IWI_FORMAT_ARGB32:
|
||||
formatStr = "ARGB32";
|
||||
break;
|
||||
case IWI_FORMAT_RGB24:
|
||||
formatStr = "RGB24";
|
||||
break;
|
||||
case IWI_FORMAT_GA16:
|
||||
formatStr = "GA16";
|
||||
break;
|
||||
case IWI_FORMAT_A8:
|
||||
formatStr = "A8";
|
||||
break;
|
||||
case IWI_FORMAT_DXT1:
|
||||
formatStr = "DXT1";
|
||||
break;
|
||||
case IWI_FORMAT_DXT3:
|
||||
formatStr = "DXT3";
|
||||
break;
|
||||
case IWI_FORMAT_DXT5:
|
||||
formatStr = "DXT5";
|
||||
break;
|
||||
}
|
||||
ui->lineEdit_PF_Format->setText(formatStr);
|
||||
ui->spinBox_PF_RGBBitCount->setValue(mDDSFile->header.pixelFormat.rgbBitCount);
|
||||
ui->spinBox_RedBitCount->setValue(mDDSFile->header.pixelFormat.rBitMask);
|
||||
ui->spinBox_GreenBitCount->setValue(mDDSFile->header.pixelFormat.gBitMask);
|
||||
ui->spinBox_BlueBitCount->setValue(mDDSFile->header.pixelFormat.bBitMask);
|
||||
ui->spinBox_AlphaBitMask->setValue(mDDSFile->header.pixelFormat.aBitMask);
|
||||
|
||||
ui->checkBox_Caps1_TextureValid->setChecked((mDDSFile->header.caps.caps1 & DDSCAPS_TEXTURE) != 0);
|
||||
ui->checkBox_Caps1_ComplexValid->setChecked((mDDSFile->header.caps.caps1 & DDSCAPS_COMPLEX) != 0);
|
||||
ui->checkBox_Caps1_MipmapValid->setChecked((mDDSFile->header.caps.caps1 & DDSCAPS_MIPMAP) != 0);
|
||||
|
||||
ui->checkBox_Caps2_CubemapValid->setChecked((mDDSFile->header.caps.caps2 & DDSCAPS2_CUBEMAP) != 0);
|
||||
ui->checkBox_Caps2_CMPXValid->setChecked((mDDSFile->header.caps.caps2 & DDSCAPS2_CUBEMAP_POSITIVEX) != 0);
|
||||
ui->checkBox_Caps2_CMNXValid->setChecked((mDDSFile->header.caps.caps2 & DDSCAPS2_CUBEMAP_NEGATIVEX) != 0);
|
||||
ui->checkBox_Caps2_CMPYValid->setChecked((mDDSFile->header.caps.caps2 & DDSCAPS2_CUBEMAP_POSITIVEY) != 0);
|
||||
ui->checkBox_Caps2_CMNYValid->setChecked((mDDSFile->header.caps.caps2 & DDSCAPS2_CUBEMAP_NEGATIVEY) != 0);
|
||||
ui->checkBox_Caps2_CMPZValid->setChecked((mDDSFile->header.caps.caps2 & DDSCAPS2_CUBEMAP_POSITIVEZ) != 0);
|
||||
ui->checkBox_Caps2_CMNZValid->setChecked((mDDSFile->header.caps.caps2 & DDSCAPS2_CUBEMAP_NEGATIVEZ) != 0);
|
||||
ui->checkBox_Caps2_VolumeValid->setChecked((mDDSFile->header.caps.caps2 & DDSCAPS2_VOLUME) != 0);
|
||||
|
||||
ui->spinBox_Caps_DDSX->setValue(mDDSFile->header.caps.dDSX);
|
||||
ui->spinBox_Caps_Res->setValue(mDDSFile->header.caps.reserved);
|
||||
|
||||
ui->comboBox_Mipmap->clear();
|
||||
for (auto mipmap : mDDSFile->mipmaps) {
|
||||
ui->comboBox_Mipmap->addItem(QString("%1x%2").arg(mipmap.width).arg(mipmap.height));
|
||||
}
|
||||
|
||||
connect(ui->comboBox_Mipmap, &QComboBox::currentIndexChanged, this, &DDSViewer::MipmapIndexChanged);
|
||||
|
||||
if (!mDDSFile->mipmaps.empty()) {
|
||||
MipmapIndexChanged(0);
|
||||
}
|
||||
}
|
||||
|
||||
void DDSViewer::MipmapIndexChanged(int aMipmapIndex) {
|
||||
if (aMipmapIndex == -1) { return; }
|
||||
|
||||
auto mipmaps = mDDSFile->mipmaps;
|
||||
auto mipmap = mipmaps[aMipmapIndex];
|
||||
|
||||
ui->spinBox_MipmapSize->setValue(mipmap.size);
|
||||
ui->spinBox_MipmapWidth->setValue(mipmap.width);
|
||||
ui->spinBox_MipmapHeight->setValue(mipmap.height);
|
||||
|
||||
// Validate Data
|
||||
if (mipmap.size <= 0) {
|
||||
qDebug() << "Error: Mipmap data is empty!";
|
||||
return;
|
||||
}
|
||||
if (mipmap.width <= 0 || mipmap.height <= 0) {
|
||||
qDebug() << "Error: Invalid mipmap dimensions!";
|
||||
return;
|
||||
}
|
||||
|
||||
// Ensure data size matches expected size
|
||||
int bytesPerPixel = 4; // RGBA8888
|
||||
quint32 expectedSize = mipmap.width * mipmap.height * bytesPerPixel;
|
||||
if (mipmap.size < expectedSize) {
|
||||
qDebug() << "Error: Mipmap data size mismatch! Expected:" << expectedSize << ", Got:" << mipmap.size;
|
||||
return;
|
||||
}
|
||||
|
||||
// Create QImage
|
||||
const unsigned char* imageData = reinterpret_cast<const unsigned char*>(mipmap.data.constData());
|
||||
QImage image(reinterpret_cast<const uchar*>(imageData),
|
||||
mipmap.width, mipmap.height,
|
||||
mipmap.width * bytesPerPixel, // Stride
|
||||
QImage::Format_RGBA8888);
|
||||
|
||||
if (image.isNull()) {
|
||||
qDebug() << "Error: QImage creation failed!";
|
||||
return;
|
||||
}
|
||||
|
||||
// Convert to QPixmap
|
||||
QPixmap pixmap = QPixmap::fromImage(image);
|
||||
if (pixmap.isNull()) {
|
||||
qDebug() << "Error: QPixmap conversion failed!";
|
||||
return;
|
||||
}
|
||||
|
||||
// Scale and display
|
||||
pixmap = pixmap.scaled(ui->label_Image->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
ui->label_Image->setPixmap(pixmap);
|
||||
}
|
||||
|
||||
29
ddsviewer.h
Normal file
@ -0,0 +1,29 @@
|
||||
#ifndef DDSVIEWER_H
|
||||
#define DDSVIEWER_H
|
||||
|
||||
#include "ddsfile.h"
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui {
|
||||
class DDSViewer;
|
||||
}
|
||||
|
||||
class DDSViewer : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DDSViewer(QWidget *parent = nullptr);
|
||||
~DDSViewer();
|
||||
|
||||
void SetDDSFile(std::shared_ptr<DDSFile> aDDSFile);
|
||||
|
||||
private slots:
|
||||
void MipmapIndexChanged(int aMipmapIndex);
|
||||
|
||||
private:
|
||||
Ui::DDSViewer *ui;
|
||||
std::shared_ptr<DDSFile> mDDSFile;
|
||||
};
|
||||
|
||||
#endif // DDSVIEWER_H
|
||||
1712
ddsviewer.ui
Normal file
753
enums.h
@ -1,6 +1,83 @@
|
||||
#ifndef ENUMS_H
|
||||
#define ENUMS_H
|
||||
|
||||
#include <QString>
|
||||
|
||||
enum FF_PLATFORM {
|
||||
FF_PLATFORM_NONE = 0x00, // No platform
|
||||
FF_PLATFORM_XBOX = 0x01, // Xbox 360
|
||||
FF_PLATFORM_PS3 = 0x02, // Playstation 3
|
||||
FF_PLATFORM_PC = 0x03 // PC
|
||||
};
|
||||
|
||||
enum FF_GAME {
|
||||
FF_GAME_NONE = 0x00, // No game
|
||||
FF_GAME_COD4 = 0x01, // Modern Warware 1
|
||||
FF_GAME_COD5 = 0x02, // World at War
|
||||
FF_GAME_COD6 = 0x03, // Modern Warfare 2
|
||||
FF_GAME_COD7 = 0x04, // Black Ops 1
|
||||
FF_GAME_COD8 = 0x05, // Modern Warfare 3
|
||||
FF_GAME_COD9 = 0x06, // Black Ops 2
|
||||
};
|
||||
|
||||
enum IWI_VERSION {
|
||||
IWI_VERSION_COD2 = 0x05, // 05 CoD2
|
||||
IWI_VERSION_COD4 = 0x06, // 06 CoD4
|
||||
IWI_VERSION_COD5 = 0x06, // 06 CoD5
|
||||
IWI_VERSION_CODMW2 = 0x08, // 08 CoDMW2
|
||||
IWI_VERSION_CODMW3 = 0x08, // 08 CoDMW3
|
||||
IWI_VERSION_CODBO1 = 0x0D, // 13 CoDBO1
|
||||
IWI_VERSION_CODBO2 = 0x1B, // 27 CoDBO2
|
||||
};
|
||||
|
||||
enum IWI_FORMAT {
|
||||
// IWI Format
|
||||
IWI_FORMAT_ARGB32 = 0x01, // 01 ARGB32
|
||||
IWI_FORMAT_RGB24 = 0x02, // 02 RGB24
|
||||
IWI_FORMAT_GA16 = 0x03, // 03 GA16
|
||||
IWI_FORMAT_A8 = 0x04, // 04 A8
|
||||
IWI_FORMAT_DXT1 = 0x0B, // 11 DXT1
|
||||
IWI_FORMAT_DXT3 = 0x0C, // 12 DXT3
|
||||
IWI_FORMAT_DXT5 = 0x0D // 13 DXT5
|
||||
};
|
||||
|
||||
enum DDS_FLAGS {
|
||||
DDSD_CAPS = 0x1,
|
||||
DDSD_HEIGHT = 0x2,
|
||||
DDSD_WIDTH = 0x4,
|
||||
DDSD_PITCH = 0x8,
|
||||
DDSD_PIXELFORMAT = 0x1000,
|
||||
DDSD_MIPMAPCOUNT = 0x20000,
|
||||
DDSD_LINEARSIZE = 0x80000,
|
||||
DDSD_DEPTH = 0x800000
|
||||
};
|
||||
|
||||
enum DDS_PIXELFORMAT_FLAGS {
|
||||
DDPF_ALPHAPIXELS = 0x1,
|
||||
DDPF_ALPHA = 0x2,
|
||||
DDPF_FOURCC = 0x4,
|
||||
DDPF_RGB = 0x40,
|
||||
DDPF_YUV = 0x200,
|
||||
DDPF_LUMINANCE = 0x20000
|
||||
};
|
||||
|
||||
enum DDS_CAPS_FLAGS {
|
||||
DDSCAPS_COMPLEX = 0x8,
|
||||
DDSCAPS_MIPMAP = 0x400000,
|
||||
DDSCAPS_TEXTURE = 0x1000
|
||||
};
|
||||
|
||||
enum DDS_CAPS2_FLAGS {
|
||||
DDSCAPS2_CUBEMAP = 0x200, // Indicates a cubemap.
|
||||
DDSCAPS2_CUBEMAP_POSITIVEX = 0x400,
|
||||
DDSCAPS2_CUBEMAP_NEGATIVEX = 0x800,
|
||||
DDSCAPS2_CUBEMAP_POSITIVEY = 0x1000,
|
||||
DDSCAPS2_CUBEMAP_NEGATIVEY = 0x2000,
|
||||
DDSCAPS2_CUBEMAP_POSITIVEZ = 0x4000,
|
||||
DDSCAPS2_CUBEMAP_NEGATIVEZ = 0x8000,
|
||||
DDSCAPS2_VOLUME = 0x200000 // Indicates that the texture is a volume texture.
|
||||
};
|
||||
|
||||
enum LUMP_TYPE
|
||||
{
|
||||
LUMP_MATERIALS = 0x0,
|
||||
@ -117,4 +194,680 @@ enum FF_SIGNAGE {
|
||||
SIGNAGE_UNSIGNED = 0x02
|
||||
};
|
||||
|
||||
enum IMAGE_COMPRESSION {
|
||||
COMPRESSION_NONE = 0x00,
|
||||
COMPRESSION_DXT1 = 0x01,
|
||||
COMPRESSION_DXT3 = 0x02,
|
||||
COMPRESSION_DXT5 = 0x03
|
||||
};
|
||||
enum MENU_ITEM_TYPE {
|
||||
ITEM_TYPE_TEXT = 0, // simple text
|
||||
ITEM_TYPE_BUTTON = 1, // button, basically text with a border
|
||||
ITEM_TYPE_RADIOBUTTON = 2, // toggle button, may be grouped
|
||||
ITEM_TYPE_CHECKBOX = 3, // check box
|
||||
ITEM_TYPE_EDITFIELD = 4, // editable text, associated with a dvar
|
||||
ITEM_TYPE_COMBO = 5, // drop down list
|
||||
ITEM_TYPE_LISTBOX = 6, // scrollable list
|
||||
ITEM_TYPE_MODEL = 7, // model
|
||||
ITEM_TYPE_OWNERDRAW = 8, // owner draw, name specs what it is
|
||||
ITEM_TYPE_NUMERICFIELD = 9, // editable text, associated with a dvar
|
||||
ITEM_TYPE_SLIDER = 10, // mouse speed, volume, etc.
|
||||
ITEM_TYPE_YESNO = 11, // yes no dvar setting
|
||||
ITEM_TYPE_MULTI = 12, // multiple list setting, enumerated
|
||||
ITEM_TYPE_DVARENUM = 13, // multiple list setting, enumerated from a dvar
|
||||
ITEM_TYPE_BIND = 14, // bind
|
||||
ITEM_TYPE_MENUMODEL = 15, // special menu model
|
||||
ITEM_TYPE_VALIDFILEFIELD = 16, // text must be valid for use in a dos filename
|
||||
ITEM_TYPE_DECIMALFIELD = 17, // editable text, associated with a dvar, which allows decimal input
|
||||
ITEM_TYPE_UPREDITFIELD = 18, // editable text, associated with a dvar
|
||||
ITEM_TYPE_GAME_MESSAGE_WINDOW = 19, // game message window
|
||||
ITEM_TYPE_SCALEFORM = 20, // Flash movie for Scaleform GFx
|
||||
ITEM_TYPE_BIND2 = 21, // bind2
|
||||
};
|
||||
|
||||
enum MENU_ITEM_H_ALIGN {
|
||||
ITEM_ALIGN_LEFT = 0, // aligns left of text to left of containing rectangle
|
||||
ITEM_ALIGN_CENTER = 1, // aligns center of text to center of containing rectangle
|
||||
ITEM_ALIGN_RIGHT = 2, // aligns right of text to right of containing rectangle
|
||||
ITEM_ALIGN_X_MASK = 3,
|
||||
};
|
||||
|
||||
enum MENU_ITEM_V_ALIGN {
|
||||
ITEM_ALIGN_LEGACY = 0, // aligns bottom of text to top of containing rectangle
|
||||
ITEM_ALIGN_TOP = 4, // aligns top of text to top of containing rectangle
|
||||
ITEM_ALIGN_MIDDLE = 8, // aligns middle of text to middle of containing rectangle
|
||||
ITEM_ALIGN_BOTTOM = 12, // aligns bottom of text to bottom of containing rectangle
|
||||
ITEM_ALIGN_Y_MASK = 12,
|
||||
};
|
||||
|
||||
enum MENU_ITEM_ALIGN {
|
||||
ITEM_ALIGN_LEGACY_LEFT = 0,
|
||||
ITEM_ALIGN_LEGACY_CENTER = 1,
|
||||
ITEM_ALIGN_LEGACY_RIGHT = 2,
|
||||
ITEM_ALIGN_TOP_LEFT = 4,
|
||||
ITEM_ALIGN_TOP_CENTER = 5,
|
||||
ITEM_ALIGN_TOP_RIGHT = 6,
|
||||
ITEM_ALIGN_MIDDLE_LEFT = 8,
|
||||
ITEM_ALIGN_MIDDLE_CENTER = 9,
|
||||
ITEM_ALIGN_MIDDLE_RIGHT = 10,
|
||||
ITEM_ALIGN_BOTTOM_LEFT = 12,
|
||||
ITEM_ALIGN_BOTTOM_CENTER = 13,
|
||||
ITEM_ALIGN_BOTTOM_RIGHT = 14
|
||||
};
|
||||
|
||||
enum MENU_ITEM_TEXTSTYLE {
|
||||
ITEM_TEXTSTYLE_NORMAL = 0, // normal text
|
||||
ITEM_TEXTSTYLE_BLINK = 1, // fast blinking
|
||||
ITEM_TEXTSTYLE_SHADOWED = 3, // drop shadow ( need a color for this )
|
||||
ITEM_TEXTSTYLE_SHADOWEDMORE = 6, // drop shadow ( need a color for this )
|
||||
ITEM_TEXTSTYLE_MONOSPACE = 128
|
||||
};
|
||||
|
||||
enum MENU_WINDOW_BORDER {
|
||||
WINDOW_BORDER_NONE = 0, // no border
|
||||
WINDOW_BORDER_FULL = 1, // full border based on border color ( single pixel )
|
||||
WINDOW_BORDER_HORZ = 2, // horizontal borders only
|
||||
WINDOW_BORDER_VERT = 3, // vertical borders only
|
||||
WINDOW_BORDER_KCGRADIENT = 4, // horizontal border using the gradient bars
|
||||
WINDOW_BORDER_RAISED = 5, // darken the bottom and right sides of the border
|
||||
WINDOW_BORDER_SUNKEN = 6 // darken the top and left sides of the border
|
||||
};
|
||||
|
||||
enum MENU_WINDOW_STYLE {
|
||||
WINDOW_STYLE_EMPTY = 0, // no background
|
||||
WINDOW_STYLE_FILLED = 1, // filled with background color
|
||||
WINDOW_STYLE_GRADIENT = 2, // gradient bar based on background color
|
||||
WINDOW_STYLE_SHADER = 3, // shader based on background color
|
||||
WINDOW_STYLE_TEAMCOLOR = 4, // team color
|
||||
WINDOW_STYLE_DVAR_SHADER = 5, // draws the shader specified by the dvar
|
||||
WINDOW_STYLE_LOADBAR = 6, // shader based on background color
|
||||
};
|
||||
|
||||
enum MENU_MODE {
|
||||
MODE_BOTTOMUP_ALIGN_TOP = 0, // text appears on bottom of list and moves up to specified Y coordinate as old text fades out
|
||||
MODE_BOTTOMUP_ALIGN_BOTTOM = 1, // text appears on bottom of list and moves away from specified Y coordinate as new text pushes it up
|
||||
MODE_TOPDOWN_ALIGN_TOP = 2, // text appears on top of list and moves away from specified Y coordinate as new text pushes it down
|
||||
MODE_TOPDOWN_ALIGN_BOTTOM = 3 // text appears on top of list and moves down to specified Y coordinate as old text fades out
|
||||
};
|
||||
|
||||
enum MENU_BOOL {
|
||||
MENU_TRUE = 1,
|
||||
MENU_FALSE = 0
|
||||
};
|
||||
|
||||
enum MENU_ORIENTATION {
|
||||
HUD_VERTICAL = 0x00,
|
||||
HUD_HORIZONTAL = 0x01
|
||||
};
|
||||
|
||||
enum MENU_RANGETYPE {
|
||||
RANGETYPE_ABSOLUTE = 0,
|
||||
RANGETYPE_RELATIVE = 1
|
||||
};
|
||||
|
||||
// list box element types
|
||||
enum MENU_LIST_BOX {
|
||||
LISTBOX_TEXT = 0x00,
|
||||
LISTBOX_IMAGE = 0x01
|
||||
};
|
||||
|
||||
// list feeders
|
||||
enum MENU_FEEDERS {
|
||||
FEEDER_HEADS = 0x00, // model heads
|
||||
FEEDER_MAPS = 0x01, // text maps based on game type
|
||||
FEEDER_SERVERS = 0x02, // servers
|
||||
FEEDER_CLAN_MEMBERS = 0x03, // clan names
|
||||
FEEDER_ALLMAPS = 0x04, // all maps available, in graphic format
|
||||
FEEDER_REDTEAM_LIST = 0x05, // red team members
|
||||
FEEDER_BLUETEAM_LIST = 0x06, // blue team members
|
||||
FEEDER_PLAYER_LIST = 0x07, // players
|
||||
FEEDER_TEAM_LIST = 0x08, // team members for team voting
|
||||
FEEDER_MODS = 0x09, // team members for team voting
|
||||
FEEDER_DEMOS = 0x0a, // team members for team voting
|
||||
FEEDER_SCOREBOARD = 0x0b, // team members for team voting
|
||||
FEEDER_Q3HEADS = 0x0c, // model heads
|
||||
FEEDER_SERVERSTATUS = 0x0d, // server status
|
||||
FEEDER_FINDPLAYER = 0x0e, // find player
|
||||
FEEDER_CINEMATICS = 0x0f, // cinematics
|
||||
FEEDER_SAVEGAMES = 0x10, // savegames
|
||||
FEEDER_PICKSPAWN = 0x11, // pickspawn
|
||||
FEEDER_LOBBY_MEMBERS = 0x12, // list of players in your party
|
||||
FEEDER_LOBBY_MEMBERS_TALK = 0x13, // icon for whether they are speaking or not
|
||||
FEEDER_MUTELIST = 0x14, // list of musted players
|
||||
FEEDER_PLAYERSTALKING = 0x15, // list of players who are currently talking
|
||||
FEEDER_SPLITSCREENPLAYERS = 0x16, // list of all players who are playing splitscreen
|
||||
FEEDER_LOBBY_MEMBERS_READY = 0x17, // icon for whether they are ready or not
|
||||
FEEDER_PLAYER_PROFILES = 0x18, // player profiles
|
||||
FEEDER_PARTY_MEMBERS = 0x19, // list of players in your party
|
||||
FEEDER_PARTY_MEMBERS_TALK = 0x1a, // icon for whether they are speaking or not
|
||||
FEEDER_PARTY_MEMBERS_READY = 0x1b, // icon for whether they are ready or not
|
||||
FEEDER_PLAYLISTS = 0x1c, // list of all playlists
|
||||
FEEDER_GAMEMODES = 0x1d, // list of all game type modes, including any player custom modes
|
||||
FEEDER_CATEGORIES = 0x1e, // list of all categories
|
||||
FEEDER_LEADERBOARD = 0x1f, // list of rows for a leaderboard
|
||||
FEEDER_MYTEAM_MEMBERS = 0x20, // list of marine team members
|
||||
FEEDER_MYTEAM_MEMBERS_TALK = 0x21, // icon for whether they are speaking
|
||||
FEEDER_ENEMY_MEMBERS = 0x22, // list of opfor team members
|
||||
FEEDER_ENEMY_MEMBERS_TALK = 0x23, // icon for whether they are speaking
|
||||
FEEDER_LOBBY_MEMBERS_STAT = 0x24, // last round stats for lobby members
|
||||
FEEDER_MYTEAM_MEMBERS_STAT = 0x25, // last round stats for marine team members
|
||||
FEEDER_ENEMY_MEMBERS_STAT = 0x26, // last round stats for opfor team members
|
||||
FEEDER_ONLINEFRIENDS = 0x27, // list of your online friends
|
||||
FEEDER_LOBBY_MEMBERS_RANK = 0x28, // rank icon
|
||||
FEEDER_PARTY_MEMBERS_RANK = 0x29, // rank icon
|
||||
FEEDER_ENEMY_MEMBERS_RANK = 0x2a, // rank icon
|
||||
FEEDER_MYTEAM_MEMBERS_RANK = 0x2b, // rank icon
|
||||
FEEDER_TESTMAPS = 0x2c, // department test maps
|
||||
FEEDER_SYSTEMLINK_LOBBY_MEMBERS = 0x2d, // list of players in a system link lobby
|
||||
FEEDER_LOBBY_MEMBERS_CONTROLLER = 0x2e, // icon for controller quadrant for splitscreen
|
||||
FEEDER_PARTY_MEMBERS_CONTROLLER = 0x2f, // icon for controller quadrant for splitscreen
|
||||
FEEDER_MYTEAM_MEMBERS_SQUAD = 0x30, // squad icon
|
||||
FEEDER_ENEMY_MEMBERS_SQUAD = 0x31, // squad icon
|
||||
FEEDER_INGAME_SQUAD_MEMBERS = 0x32, // Squad members displayed in MP 'Pause' menu
|
||||
FEEDER_INGAME_SQUAD_MEMBERS_FULL = 0x33, // Squad members' name, rank, talk, leader displayed in PC MP 'Pause' menu
|
||||
FEEDER_INGAME_SQUAD_NAMES = 0x34, // Squad names displayed in MP 'Join Squad' menu
|
||||
FEEDER_INGAME_SQUAD_NAMES2 = 0x35, // Squad names displayed in MP 'Pause' menu
|
||||
FEEDER_INGAME_SQUAD_NAMES_FULL = 0x36, // Squad names, lock, invite displayed in PC MP 'Pause' menu
|
||||
FEEDER_CUSTOM_GAMETYPES = 0x37, // list of all the gametypes for custom matches
|
||||
FEEDER_INGAME_SQUAD_MEMBER_RANK = 0x38, // Squad members' rank displayed in MP 'Pause' menu
|
||||
FEEDER_INGAME_SQUAD_MEMBER_TALK = 0x39, // Squad members' talk icon displayed in MP 'Pause' menu
|
||||
FEEDER_INGAME_SQUAD_LOCKED = 0x3a, // Squad lock icon displayed in MP 'Pause' menu
|
||||
FEEDER_INGAME_SQUAD_MEMBER_INVITED = 0x3b, // Squad invite icon displayed in MP 'Pause' menu
|
||||
FEEDER_INGAME_SQUAD_INVITE = 0x3c, // Squad invite icon displayed in MP 'Join Squad' menu
|
||||
FEEDER_INGAME_SQUAD_LEADER = 0x3d, // Squad leader icon displayled in MP 'Pause' menu
|
||||
FEEDER_FRIENDS = 0x3e, // list of your friends
|
||||
FEEDER_PENDINGFRIENDS = 0x3f, // list of your pending friends
|
||||
FEEDER_INVITES = 0x40, // list of the game invites from your friends
|
||||
};
|
||||
|
||||
// display flags
|
||||
enum MENU_DISPLAY_FLAG {
|
||||
CG_SHOW_BLUE_TEAM_HAS_REDFLAG = 0x00000001,
|
||||
CG_SHOW_RED_TEAM_HAS_BLUEFLAG = 0x00000002,
|
||||
CG_SHOW_ANYTEAMGAME = 0x00000004,
|
||||
CG_SHOW_CTF = 0x00000020,
|
||||
CG_SHOW_OBELISK = 0x00000040,
|
||||
CG_SHOW_HEALTHCRITICAL = 0x00000080,
|
||||
CG_SHOW_SINGLEPLAYER = 0x00000100,
|
||||
CG_SHOW_TOURNAMENT = 0x00000200,
|
||||
CG_SHOW_DURINGINCOMINGVOICE = 0x00000400,
|
||||
CG_SHOW_IF_PLAYER_HAS_FLAG = 0x00000800,
|
||||
CG_SHOW_LANPLAYONLY = 0x00001000,
|
||||
CG_SHOW_MINED = 0x00002000,
|
||||
CG_SHOW_HEALTHOK = 0x00004000,
|
||||
CG_SHOW_TEAMINFO = 0x00008000,
|
||||
CG_SHOW_NOTEAMINFO = 0x00010000,
|
||||
CG_SHOW_OTHERTEAMHASFLAG = 0x00020000,
|
||||
CG_SHOW_YOURTEAMHASENEMYFLAG = 0x00040000,
|
||||
CG_SHOW_ANYNONTEAMGAME = 0x00080000,
|
||||
CG_SHOW_TEXTASINT = 0x00200000,
|
||||
CG_SHOW_HIGHLIGHTED = 0x00100000,
|
||||
CG_SHOW_NOT_V_CLEAR = 0x02000000,
|
||||
CG_SHOW_2DONLY = 0x10000000
|
||||
};
|
||||
|
||||
enum MENU_UI_FLAG{
|
||||
UI_SHOW_LEADER = 0x00000001,
|
||||
UI_SHOW_NOTLEADER = 0x00000002,
|
||||
UI_SHOW_FAVORITESERVERS = 0x00000004,
|
||||
UI_SHOW_ANYNONTEAMGAME = 0x00000008,
|
||||
UI_SHOW_ANYTEAMGAME = 0x00000010,
|
||||
UI_SHOW_NEWHIGHSCORE = 0x00000020,
|
||||
UI_SHOW_DEMOAVAILABLE = 0x00000040,
|
||||
UI_SHOW_NEWBESTTIME = 0x00000080,
|
||||
UI_SHOW_FFA = 0x00000100,
|
||||
UI_SHOW_NOTFFA = 0x00000200,
|
||||
UI_SHOW_NETANYNONTEAMGAME = 0x00000400,
|
||||
UI_SHOW_NETANYTEAMGAME = 0x00000800,
|
||||
UI_SHOW_NOTFAVORITESERVERS = 0x00001000
|
||||
};
|
||||
|
||||
// font types
|
||||
enum MENU_FONT_TYPE{
|
||||
UI_FONT_DEFAULT = 0, // auto-chose betwen big/reg/small
|
||||
UI_FONT_NORMAL = 1,
|
||||
UI_FONT_BIG = 2,
|
||||
UI_FONT_SMALL = 3,
|
||||
UI_FONT_BOLD = 4,
|
||||
UI_FONT_CONSOLE = 5,
|
||||
UI_FONT_OBJECTIVE = 6,
|
||||
UI_FONT_MAX = 6,
|
||||
};
|
||||
|
||||
// owner draw types
|
||||
// ideally these should be done outside of this file but
|
||||
// this makes it much easier for the macro expansion to
|
||||
// convert them for the designers ( from the .menu files )
|
||||
enum MENU_OWNER_DRAW_TYPE {
|
||||
CG_OWNERDRAW_BASE = 1,
|
||||
CG_PLAYER_AMMO_VALUE = 5,
|
||||
CG_PLAYER_AMMO_BACKDROP = 6,
|
||||
CG_PLAYER_HEAT_VALUE = 7,
|
||||
CG_PLAYER_STANCE = 20,
|
||||
CG_SPECTATORS = 60,
|
||||
CG_HOLD_BREATH_HINT = 71,
|
||||
CG_CURSORHINT = 72,
|
||||
CG_PLAYER_POWERUP = 73,
|
||||
CG_PLAYER_HOLDABLE = 74,
|
||||
CG_PLAYER_INVENTORY = 75,
|
||||
CG_CURSORHINT_STATUS = 78, // like 'health' bar when pointing at a func_explosive
|
||||
CG_PLAYER_BAR_HEALTH = 79,
|
||||
CG_MANTLE_HINT = 80,
|
||||
CG_PLAYER_WEAPON_NAME = 81,
|
||||
CG_PLAYER_WEAPON_NAME_BACK = 82,
|
||||
CG_CENTER_MESSAGE = 90, // for things like "You were killed by ..."
|
||||
CG_TANK_BODY_DIR = 95,
|
||||
CG_TANK_BARREL_DIR = 96,
|
||||
CG_DEADQUOTE = 97,
|
||||
CG_PLAYER_BAR_HEALTH_BACK = 98,
|
||||
CG_MISSION_OBJECTIVE_HEADER = 99,
|
||||
CG_MISSION_OBJECTIVE_LIST = 100,
|
||||
CG_MISSION_OBJECTIVE_BACKDROP = 101,
|
||||
CG_PAUSED_MENU_LINE = 102,
|
||||
CG_OFFHAND_WEAPON_ICON_FRAG = 103,
|
||||
CG_OFFHAND_WEAPON_ICON_SMOKEFLASH = 104,
|
||||
CG_OFFHAND_WEAPON_AMMO_FRAG = 105,
|
||||
CG_OFFHAND_WEAPON_AMMO_SMOKEFLASH = 106,
|
||||
CG_OFFHAND_WEAPON_NAME_FRAG = 107,
|
||||
CG_OFFHAND_WEAPON_NAME_SMOKEFLASH = 108,
|
||||
CG_OFFHAND_WEAPON_SELECT_FRAG = 109,
|
||||
CG_OFFHAND_WEAPON_SELECT_SMOKEFLASH = 110,
|
||||
CG_SAVING = 111,
|
||||
CG_PLAYER_LOW_HEALTH_OVERLAY = 112,
|
||||
CG_INVALID_CMD_HINT = 113,
|
||||
CG_PLAYER_SPRINT_METER = 114,
|
||||
CG_PLAYER_SPRINT_BACK = 115,
|
||||
CG_PLAYER_WEAPON_BACKGROUND = 116,
|
||||
CG_PLAYER_WEAPON_AMMO_CLIP_GRAPHIC = 117,
|
||||
CG_PLAYER_WEAPON_PRIMARY_ICON = 118,
|
||||
CG_PLAYER_WEAPON_AMMO_STOCK = 119,
|
||||
CG_PLAYER_WEAPON_LOW_AMMO_WARNING = 120,
|
||||
CG_BATTLE_COMPASS_MARKERS = 122,
|
||||
CG_BATTLE_FULLMAP_MARKERS = 123,
|
||||
CG_SUCCESSFUL_CMD_HINT = 130,
|
||||
CG_WAR_TEXT = 135,
|
||||
CG_PLAYER_COMPASS_TICKERTAPE = 145,
|
||||
CG_PLAYER_COMPASS_TICKERTAPE_NO_OBJ = 146,
|
||||
CG_PLAYER_COMPASS_DOGS = 147,
|
||||
CG_PLAYER_COMPASS_ARTILLERY_ICON = 148,
|
||||
CG_PLAYER_COMPASS_SQUAD_OBJECTIVE = 149,
|
||||
CG_PLAYER_COMPASS_PLAYER = 150,
|
||||
CG_PLAYER_COMPASS_BACK = 151,
|
||||
CG_PLAYER_COMPASS_POINTERS = 152,
|
||||
CG_PLAYER_COMPASS_ACTORS = 153,
|
||||
CG_PLAYER_COMPASS_TANKS = 154,
|
||||
CG_PLAYER_COMPASS_HELICOPTERS = 155,
|
||||
CG_PLAYER_COMPASS_PLANES = 156,
|
||||
CG_PLAYER_COMPASS_AUTOMOBILES = 157,
|
||||
CG_PLAYER_COMPASS_FRIENDS = 158,
|
||||
CG_PLAYER_COMPASS_MAP = 159,
|
||||
CG_PLAYER_COMPASS_NORTHCOORD = 160,
|
||||
CG_PLAYER_COMPASS_EASTCOORD = 161,
|
||||
CG_PLAYER_COMPASS_NCOORD_SCROLL = 162,
|
||||
CG_PLAYER_COMPASS_ECOORD_SCROLL = 163,
|
||||
CG_PLAYER_COMPASS_GOALDISTANCE = 164,
|
||||
CG_PLAYER_ACTIONSLOT_DPAD = 165,
|
||||
CG_PLAYER_ACTIONSLOT_1 = 166,
|
||||
CG_PLAYER_ACTIONSLOT_2 = 167,
|
||||
CG_PLAYER_ACTIONSLOT_3 = 168,
|
||||
CG_PLAYER_ACTIONSLOT_4 = 169,
|
||||
CG_PLAYER_COMPASS_ENEMIES = 170,
|
||||
CG_PLAYER_FULLMAP_DOGS = 176,
|
||||
CG_PLAYER_FULLMAP_VEHICLES = 177,
|
||||
CG_PLAYER_FULLMAP_ARTILLERY_ICON = 178,
|
||||
CG_PLAYER_FULLMAP_SQUAD_OBJECTIVE = 179,
|
||||
CG_PLAYER_FULLMAP_BACK = 180,
|
||||
CG_PLAYER_FULLMAP_MAP = 181,
|
||||
CG_PLAYER_FULLMAP_POINTERS = 182,
|
||||
CG_PLAYER_FULLMAP_PLAYER = 183,
|
||||
CG_PLAYER_FULLMAP_ACTORS = 184,
|
||||
CG_PLAYER_FULLMAP_FRIENDS = 185,
|
||||
CG_PLAYER_FULLMAP_LOCATION_SELECTOR = 186,
|
||||
CG_PLAYER_FULLMAP_BORDER = 187,
|
||||
CG_PLAYER_FULLMAP_ENEMIES = 188,
|
||||
CG_PLAYER_COMPASS = 189,
|
||||
CG_VEHICLE_RETICLE = 190,
|
||||
CG_HUD_TARGETS_VEHICLE = 191,
|
||||
CG_HUD_TARGETS_JAVELIN = 192,
|
||||
CG_TALKER1 = 193,
|
||||
CG_TALKER2 = 194,
|
||||
CG_TALKER3 = 195,
|
||||
CG_TALKER4 = 196,
|
||||
CG_FRIENDLYARROWS = 197,
|
||||
CG_FRIENDLYNAMES = 198,
|
||||
UI_OWNERDRAW_BASE = 200,
|
||||
UI_HANDICAP = 200,
|
||||
UI_EFFECTS = 201,
|
||||
UI_PLAYERMODEL = 202,
|
||||
UI_GAMETYPE = 205,
|
||||
UI_SKILL = 207,
|
||||
UI_NETSOURCE = 220,
|
||||
UI_NETFILTER = 222,
|
||||
UI_VOTE_KICK = 238,
|
||||
UI_NETGAMETYPE = 245,
|
||||
UI_SERVERREFRESHDATE = 247,
|
||||
UI_SERVERMOTD = 248,
|
||||
UI_GLINFO = 249,
|
||||
UI_KEYBINDSTATUS = 250,
|
||||
UI_JOINGAMETYPE = 253,
|
||||
UI_MAPPREVIEW = 254,
|
||||
UI_MENUMODEL = 257,
|
||||
UI_SAVEGAME_SHOT = 258,
|
||||
UI_SAVEGAMENAME = 262,
|
||||
UI_SAVEGAMEINFO = 263,
|
||||
UI_LOADPROFILING = 264,
|
||||
UI_RECORDLEVEL = 265,
|
||||
UI_AMITALKING = 266,
|
||||
UI_TALKER1 = 267,
|
||||
UI_TALKER2 = 268,
|
||||
UI_TALKER3 = 269,
|
||||
UI_TALKER4 = 270,
|
||||
UI_PARTYSTATUS = 271,
|
||||
UI_LOGGEDINUSER = 272,
|
||||
UI_RESERVEDSLOTS = 273,
|
||||
UI_PLAYLISTNAME = 274,
|
||||
UI_PLAYLISTDESCRIPTION = 275,
|
||||
UI_USERNAME = 276,
|
||||
UI_CINEMATIC = 277,
|
||||
UI_TOTALONLINE = 278,
|
||||
UI_CATEGORYNAME = 279,
|
||||
UI_CATEGORYDESCRIPTION = 280,
|
||||
UI_PLAYLISTICON = 281,
|
||||
UI_CATEGORYICON = 282,
|
||||
UI_GAMETYPE_MAPNAME = 283,
|
||||
CG_HUD_WAR_MOMENTUM_PROGRESS = 284,
|
||||
CG_HUD_WAR_MOMENTUM_MULTIPLIER = 285,
|
||||
CG_HUD_WAR_MOMENTUM_MULTIPLIER_DETAIL = 286,
|
||||
CG_HUD_WAR_MOMENTUM_MULTIPLIER_BLITZKRIEG = 287,
|
||||
CG_COMPETITIVE_MODE_SCORES = 288,
|
||||
UI_LOAD_STATUS_SCREEN = 289,
|
||||
UI_LEADERBOARD_GAMEMODE = 290,
|
||||
CG_PLAYER_ACTIONSLOT_BACK_1 = 290,
|
||||
CG_PLAYER_ACTIONSLOT_BACK_2 = 291,
|
||||
CG_PLAYER_ACTIONSLOT_BACK_3 = 292,
|
||||
CG_PLAYER_ACTIONSLOT_BACK_4 = 293,
|
||||
CG_PLAYER_ACTIONSLOT_ARROW_1 = 294,
|
||||
CG_PLAYER_ACTIONSLOT_ARROW_2 = 295,
|
||||
CG_PLAYER_ACTIONSLOT_ARROW_3 = 296,
|
||||
CG_PLAYER_ACTIONSLOT_ARROW_4 = 297,
|
||||
UI_DIFFICULTY_INFO = 298,
|
||||
UI_DIFFICULTY_ICON = 299,
|
||||
UI_LOBBY_CHAT = 300
|
||||
};
|
||||
|
||||
// Edge relative placement values for rect->h_align and rect->v_align
|
||||
enum MENU_H_ALIGNMENT {
|
||||
HORIZONTAL_ALIGN_SUBLEFT = 0, // left edge of a 4:3 screen (safe area not included)
|
||||
HORIZONTAL_ALIGN_LEFT = 1, // left viewable (safe area) edge
|
||||
HORIZONTAL_ALIGN_CENTER = 2, // center of the screen (reticle)
|
||||
HORIZONTAL_ALIGN_RIGHT = 3, // right viewable (safe area) edge
|
||||
HORIZONTAL_ALIGN_FULLSCREEN = 4, // disregards safe area
|
||||
HORIZONTAL_ALIGN_NOSCALE = 5, // uses exact parameters - neither adjusts for safe area nor scales for screen size
|
||||
HORIZONTAL_ALIGN_TO640 = 6, // scales a real-screen resolution x down into the 0 - 640 range
|
||||
HORIZONTAL_ALIGN_CENTER_SAFEAREA = 7, // center of the safearea
|
||||
HORIZONTAL_ALIGN_MAX = HORIZONTAL_ALIGN_CENTER_SAFEAREA,
|
||||
HORIZONTAL_ALIGN_DEFAULT = HORIZONTAL_ALIGN_SUBLEFT
|
||||
};
|
||||
|
||||
enum MENU_V_ALIGNMENT {
|
||||
VERTICAL_ALIGN_SUBTOP = 0, // top edge of the 4:3 screen (safe area not included)
|
||||
VERTICAL_ALIGN_TOP = 1, // top viewable (safe area) edge
|
||||
VERTICAL_ALIGN_CENTER = 2, // center of the screen (reticle)
|
||||
VERTICAL_ALIGN_BOTTOM = 3, // bottom viewable (safe area) edge
|
||||
VERTICAL_ALIGN_FULLSCREEN = 4, // disregards safe area
|
||||
VERTICAL_ALIGN_NOSCALE = 5, // uses exact parameters - neither adjusts for safe area nor scales for screen size
|
||||
VERTICAL_ALIGN_TO480 = 6, // scales a real-screen resolution y down into the 0 - 480 range
|
||||
VERTICAL_ALIGN_CENTER_SAFEAREA = 7, // center of the save area
|
||||
VERTICAL_ALIGN_MAX = VERTICAL_ALIGN_CENTER_SAFEAREA,
|
||||
VERTICAL_ALIGN_DEFAULT = VERTICAL_ALIGN_SUBTOP
|
||||
};
|
||||
|
||||
enum MENU_BUTTON {
|
||||
BUTTON_A = 1,
|
||||
BUTTON_B = 2,
|
||||
BUTTON_X = 3,
|
||||
BUTTON_Y = 4,
|
||||
BUTTON_LSHLDR = 5,
|
||||
BUTTON_RSHLDR = 6,
|
||||
BUTTON_START = 14,
|
||||
BUTTON_BACK = 15,
|
||||
BUTTON_LSTICK = 16,
|
||||
BUTTON_RSTICK = 17,
|
||||
BUTTON_LTRIG = 18,
|
||||
BUTTON_RTRIG = 19,
|
||||
DPAD_UP = 20,
|
||||
DPAD_DOWN = 21,
|
||||
DPAD_LEFT = 22,
|
||||
DPAD_RIGHT = 23,
|
||||
APAD_UP = 28,
|
||||
APAD_DOWN = 29,
|
||||
APAD_LEFT = 30,
|
||||
APAD_RIGHT = 31
|
||||
};
|
||||
|
||||
enum ASSET_TYPE {
|
||||
ASSET_UNKNOWN = 0,
|
||||
ASSET_ANIMATION = 4, // x_anim PARTIALLY VERIFIED
|
||||
ASSET_MODEL = 5, // xmodel PARTIALLY VERIFIED
|
||||
ASSET_MATERIAL = 6, // material VERIFIED
|
||||
ASSET_BIK_FILE = 7, // .bik file PARTIALLY VERIFIED
|
||||
ASSET_SOUND = 9, // loaded_sound VERIFIED
|
||||
ASSET_COLLISION_MAP = 12, // collision_map PARTIALLY VERIFIED
|
||||
ASSET_SHADER = 13, // shader PARTIALLY VERIFIED
|
||||
ASSET_D3DBSP_DUMP = 17, // d3dbsp dump VERIFIED
|
||||
ASSET_FONT = 20, // font PARTIALLY VERIFIED
|
||||
ASSET_MENU = 21, // menu_file VERIFIED
|
||||
ASSET_LOCAL_STRING = 23, // localized string VERIFIED
|
||||
ASSET_WEAPON = 24, // weapon VERIFIED
|
||||
ASSET_EFFECT = 26, // fx VERIFIED
|
||||
ASSET_RAW_FILE = 32, // raw_file VERIFIED
|
||||
ASSET_STRING_TABLE = 33 // string_table PARTIALLY VERIFIED
|
||||
};
|
||||
|
||||
enum SHADER_TYPE {
|
||||
SHADER_NONE = 0x00,
|
||||
SHADER_PIXEL = 0x01,
|
||||
SHADER_VERTEX = 0x02
|
||||
};
|
||||
|
||||
enum SHADER_OPCODE {
|
||||
OPCODE_Nop,
|
||||
OPCODE_Mov,
|
||||
OPCODE_Add,
|
||||
OPCODE_Sub,
|
||||
OPCODE_Mad,
|
||||
OPCODE_Mul,
|
||||
OPCODE_Rcp,
|
||||
OPCODE_Rsq,
|
||||
OPCODE_Dp3,
|
||||
OPCODE_Dp4,
|
||||
OPCODE_Min,
|
||||
OPCODE_Max,
|
||||
OPCODE_Slt,
|
||||
OPCODE_Sge,
|
||||
OPCODE_Exp,
|
||||
OPCODE_Log,
|
||||
OPCODE_Lit,
|
||||
OPCODE_Dst,
|
||||
OPCODE_Lrp,
|
||||
OPCODE_Frc,
|
||||
OPCODE_M4x4,
|
||||
OPCODE_M4x3,
|
||||
OPCODE_M3x4,
|
||||
OPCODE_M3x3,
|
||||
OPCODE_M3x2,
|
||||
OPCODE_Call,
|
||||
OPCODE_CallNZ,
|
||||
OPCODE_Loop,
|
||||
OPCODE_Ret,
|
||||
OPCODE_EndLoop,
|
||||
OPCODE_Label,
|
||||
OPCODE_Dcl,
|
||||
OPCODE_Pow,
|
||||
OPCODE_Crs,
|
||||
OPCODE_Sgn,
|
||||
OPCODE_Abs,
|
||||
OPCODE_Nrm,
|
||||
OPCODE_SinCos,
|
||||
OPCODE_Rep,
|
||||
OPCODE_EndRep,
|
||||
OPCODE_If,
|
||||
OPCODE_IfC,
|
||||
OPCODE_Else,
|
||||
OPCODE_Endif,
|
||||
OPCODE_Break,
|
||||
OPCODE_BreakC,
|
||||
OPCODE_MovA,
|
||||
OPCODE_DefB,
|
||||
OPCODE_DefI,
|
||||
OPCODE_TexCoord = 64,
|
||||
OPCODE_TexKill,
|
||||
OPCODE_Tex,
|
||||
OPCODE_TexBem,
|
||||
OPCODE_TexBeml,
|
||||
OPCODE_TexReg2AR,
|
||||
OPCODE_TexReg2GB,
|
||||
OPCODE_TeXM3x2Pad,
|
||||
OPCODE_TexM3x2Tex,
|
||||
OPCODE_TeXM3x3Pad,
|
||||
OPCODE_TexM3x3Tex,
|
||||
OPCODE_TexM3x3Diff,
|
||||
OPCODE_TexM3x3Spec,
|
||||
OPCODE_TexM3x3VSpec,
|
||||
OPCODE_ExpP,
|
||||
OPCODE_LogP,
|
||||
OPCODE_Cnd,
|
||||
OPCODE_Def,
|
||||
OPCODE_TexReg2RGB,
|
||||
OPCODE_TexDP3Tex,
|
||||
OPCODE_TexM3x2Depth,
|
||||
OPCODE_TexDP3,
|
||||
OPCODE_TexM3x3,
|
||||
OPCODE_TexDepth,
|
||||
OPCODE_Cmp,
|
||||
OPCODE_Bem,
|
||||
OPCODE_DP2Add,
|
||||
OPCODE_DSX,
|
||||
OPCODE_DSY,
|
||||
OPCODE_TexLDD,
|
||||
OPCODE_SetP,
|
||||
OPCODE_TexLDL,
|
||||
OPCODE_Breakp,
|
||||
OPCODE_Phase = 0xFFFD,
|
||||
OPCODE_Comment = 0xFFFE,
|
||||
OPCODE_End = 0xFFFF
|
||||
};
|
||||
|
||||
#define SECTION_TYPE_INFO 1
|
||||
#define SECTION_TYPE_DATA 2
|
||||
|
||||
#define IPAK_SECTION_ENTRY 1
|
||||
#define IPAK_SECTION_DATA 2
|
||||
#define IPAK_SECTION_METADATA 3
|
||||
|
||||
#define FORMAT_DXT1 0
|
||||
#define FORMAT_DXT3 1
|
||||
#define FORMAT_DXT5 2
|
||||
#define FORMAT_A8R8G8B8 3
|
||||
|
||||
// Change this depending on the platform
|
||||
// PC
|
||||
#define DEVMAP_LEVEL_FIRST "devmap intro_pac"
|
||||
#define DEVMAP "devmap"
|
||||
// Not PC
|
||||
// #define DEVMAP_LEVEL_FIRST "map intro_pac"
|
||||
// #define DEVMAP "map"
|
||||
|
||||
// Remove this to restore full frontend instead of limited EPD frontend
|
||||
#define COOP_EPD 0
|
||||
|
||||
// LDS - This enables a German SKU with Nazi Zombies enabled *SHOULD BE SET TO 0 IF NOT APPROVED*
|
||||
#define GERMAN_ZOMBIE_BUILD 0
|
||||
|
||||
#define DEVMAP_LEVEL_TRAINING "devmap training"
|
||||
#define LEVEL_FIRST "intro_pac"
|
||||
#define LEVEL_TRAINING "training"
|
||||
#define FIRST_PLAYABLE_CAMPAIGN_LEVEL "mak"
|
||||
#define FIRST_PLAYABLE_ZOMBIE_LEVEL "nazi_zombie_prototype"
|
||||
|
||||
// Size define for the hud compass
|
||||
// These are used for both the dynamic & non-dynamic compass drawing
|
||||
// If these are changed, the cgame should be recompiled
|
||||
#define COMPASS_SIZE 160
|
||||
#define MINIMAP_X 11.5
|
||||
#define MINIMAP_Y 5
|
||||
#define MINIMAP_W 89.5
|
||||
#define MINIMAP_H 89.5
|
||||
|
||||
#define COMPASS_SIZE_MP 125
|
||||
#define MINIMAP_X_MP 0
|
||||
#define MINIMAP_Y_MP 12
|
||||
#define MINIMAP_W_MP 102
|
||||
#define MINIMAP_H_MP 102
|
||||
|
||||
#define FULLSCREEN 0 0 640 480
|
||||
#define FULLSCREEN_WIDE -107 0 854 480
|
||||
|
||||
// PC
|
||||
#define ORIGIN_TITLE 30 34
|
||||
// Not PC
|
||||
// #define ORIGIN_TITLE 0 0
|
||||
|
||||
#define ORIGIN_TITLE_SS 104 120
|
||||
|
||||
#define FONTSCALE_SMALL 0.3095 //0.3750 // <-- COD4 // COD5 --> 0.30952//0.35897//0.24138 //14 pt //0.2900 //0.2750 // 18
|
||||
#define FONTSCALE_LOBBY 0.26 // <--Slate // 0.3010 <-- Slate Compressed // 0.3750 // <-- COD4 CONDUIT ITC small
|
||||
#define FONTSCALE_NORMAL 0.3810 //0.35897//0.4583
|
||||
#define FONTSCALE_BOLD 0.5476 //0.4583
|
||||
#define FONTSCALE_BIG 0.5476 //0.5833
|
||||
#define FONTSCALE_EXTRABIG 1 //1.0000
|
||||
|
||||
// new settings
|
||||
#define TEXTSIZE_SMALL FONTSCALE_SMALL
|
||||
#define TEXTSIZE_SMALL_SS (FONTSCALE_SMALL*2)
|
||||
#define TEXTSIZE_DEFAULT FONTSCALE_NORMAL
|
||||
#define TEXTSIZE_DEFAULT_SS (FONTSCALE_NORMAL*2)
|
||||
#define TEXTSIZE_TITLE FONTSCALE_BIG
|
||||
#define TEXTSIZE_TITLE_SS 1
|
||||
|
||||
#define TEXTSIZE_BOLD TEXTSIZE_DEFAULT
|
||||
#define TEXTSIZE_BIG TEXTSIZE_TITLE
|
||||
|
||||
//#define COLOR_TITLE 1 0.8 0.4 1
|
||||
#define COLOR_TITLE 1 1 1 1
|
||||
#define COLOR_HEADER 0.69 0.69 0.69 1
|
||||
#define COLOR_FOCUSED 0.95294 0.72156 0.21176 1 //1 0.788 0.129 1
|
||||
//#define COLOR_FOCUS_YELLOW 0.95294 0.72156 0.21176 1
|
||||
#define COLOR_UNFOCUSED 0.4823 0.4823 0.4823 1
|
||||
//#define COLOR_DISABLED 0.35 0.35 0.35 1
|
||||
#define COLOR_SAFEAREA 0 0 1 1
|
||||
|
||||
#define COLOR_INFO_YELLOW COLOR_FOCUSED//1 0.84706 0 1
|
||||
#define COLOR_TEXT 0.84313 0.84313 0.84313 1
|
||||
#define COLOR_DISABLED 0.34118 0.36863 0.37647 1
|
||||
#define COLOR_TITLEBAR 0.14510 0.16078 0.16862 0.3//1
|
||||
#define COLOR_RED_TEXT 0.69020 0.00784 0.00784 1
|
||||
|
||||
#define COLOR_FADEOUT 0.09412 0.09412 0.04912 0.65
|
||||
|
||||
#define COLOR_BODY_TEXT 0.62745 0.66667 0.67451 1
|
||||
|
||||
#define COLOR_USMC 0 0.0196 0.41
|
||||
#define COLOR_JPN 0.53 0.027 0.027
|
||||
#define COLOR_USSR 0.368 0.035 0.035
|
||||
#define COLOR_GER 0.937 0.9 0.607
|
||||
|
||||
#define DEFAULT_MP_CFG "default_mp.cfg"
|
||||
#define SPLITSCREEN_MP_CFG "default_splitscreen.cfg"
|
||||
#define SYSTEMLINK_MP_CFG "default_systemlink.cfg"
|
||||
#define XBOXLIVE_MP_CFG "default_xboxlive.cfg"
|
||||
|
||||
#define MAX_RANK int(tableLookup( "mp/rankTable.csv", 0, "maxrank", 1))
|
||||
#define MAX_PRESTIGE int(tableLookup( "mp/rankIconTable.csv", 0, "maxprestige", 1))
|
||||
|
||||
#define PRESTIGE_AVAIL (stat(2326) < MAX_PRESTIGE && stat(2301) == int(tableLookup("mp/rankTable.csv",0,MAX_RANK,7)))
|
||||
#define PRESTIGE_NEXT (stat(2326) < MAX_PRESTIGE && stat(252) == MAX_RANK)
|
||||
#define PRESTIGE_FINISH (stat(2326) == MAX_PRESTIGE)
|
||||
|
||||
#define CAN_RANK_UP (stat(252) < MAX_RANK || stat(2326) < MAX_PRESTIGE)
|
||||
#endif // ENUMS_H
|
||||
|
||||
374
fastfile.cpp
Normal file
@ -0,0 +1,374 @@
|
||||
#include "fastfile.h"
|
||||
#include "compressor.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QDebug>
|
||||
|
||||
FastFile::FastFile() :
|
||||
fileStem(),
|
||||
company(),
|
||||
fileType(),
|
||||
signage(),
|
||||
magic(),
|
||||
version() {
|
||||
}
|
||||
|
||||
FastFile::~FastFile() {
|
||||
|
||||
}
|
||||
|
||||
FastFile::FastFile(const FastFile &aFastFile) {
|
||||
fileStem = aFastFile.GetFileStem();
|
||||
company = aFastFile.GetCompany();
|
||||
fileType = aFastFile.GetFileType();
|
||||
signage = aFastFile.GetSignage();
|
||||
magic = aFastFile.GetMagic();
|
||||
version = aFastFile.GetVersion();
|
||||
zoneFile = aFastFile.zoneFile;
|
||||
game = aFastFile.GetGame();
|
||||
platform = aFastFile.GetPlatform();
|
||||
}
|
||||
|
||||
FastFile &FastFile::operator=(const FastFile &other) {
|
||||
if (this != &other) {
|
||||
fileStem = other.GetFileStem();
|
||||
company = other.GetCompany();
|
||||
fileType = other.GetFileType();
|
||||
signage = other.GetSignage();
|
||||
magic = other.GetMagic();
|
||||
version = other.GetVersion();
|
||||
zoneFile = other.zoneFile;
|
||||
game = other.GetGame();
|
||||
platform = other.GetPlatform();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool FastFile::Load(const QByteArray aData) {
|
||||
QByteArray decompressedData;
|
||||
|
||||
// Create a QDataStream on the input data.
|
||||
QDataStream fastFileStream(aData);
|
||||
fastFileStream.setByteOrder(QDataStream::LittleEndian);
|
||||
|
||||
// Parse header values.
|
||||
company = pParseFFCompany(&fastFileStream);
|
||||
fileType = pParseFFFileType(&fastFileStream);
|
||||
signage = pParseFFSignage(&fastFileStream);
|
||||
magic = pParseFFMagic(&fastFileStream);
|
||||
version = pParseFFVersion(&fastFileStream);
|
||||
platform = pCalculateFFPlatform();
|
||||
game = pCalculateFFGame();
|
||||
|
||||
if (game == "COD5") {
|
||||
// For COD5, simply decompress from offset 12.
|
||||
decompressedData = Compressor::DecompressZLIB(aData.mid(12));
|
||||
|
||||
QFile testFile("exports/" + fileStem.section('.', 0, 0) + ".zone");
|
||||
if(testFile.open(QIODevice::WriteOnly)) {
|
||||
testFile.write(decompressedData);
|
||||
testFile.close();
|
||||
}
|
||||
|
||||
zoneFile.Load(decompressedData, fileStem.section('.', 0, 0) + ".zone");
|
||||
}
|
||||
else if (game == "COD7" || game == "COD9") {
|
||||
// For COD7/COD9, use BigEndian.
|
||||
fastFileStream.setByteOrder(QDataStream::BigEndian);
|
||||
if (platform == "PC") {
|
||||
fastFileStream.setByteOrder(QDataStream::LittleEndian);
|
||||
}
|
||||
|
||||
// Select key based on game.
|
||||
QByteArray key;
|
||||
if (game == "COD7") {
|
||||
fastFileStream.skipRawData(4);
|
||||
if (platform == "360") {
|
||||
key = QByteArray::fromHex("1ac1d12d527c59b40eca619120ff8217ccff09cd16896f81b829c7f52793405d");
|
||||
} else if (platform == "PS3") {
|
||||
key = QByteArray::fromHex("46D3F997F29C9ACE175B0DAE3AB8C0C1B8E423E2E3BF7E3C311EA35245BF193A");
|
||||
// or
|
||||
// key = QByteArray::fromHex("0C99B3DDB8D6D0845D1147E470F28A8BF2AE69A8A9F534767B54E9180FF55370");
|
||||
}
|
||||
} else if (game == "COD9") {
|
||||
if (platform == "360") {
|
||||
key = QByteArray::fromHex("0E50F49F412317096038665622DD091332A209BA0A05A00E1377CEDB0A3CB1D3");
|
||||
} else if (platform == "PC") {
|
||||
key = QByteArray::fromHex("641D8A2FE31D3AA63622BBC9CE8587229D42B0F8ED9B924130BF88B65EDC50BE");
|
||||
}
|
||||
}
|
||||
|
||||
// Read the 8-byte magic.
|
||||
QByteArray fileMagic(8, Qt::Uninitialized);
|
||||
fastFileStream.readRawData(fileMagic.data(), 8);
|
||||
if (fileMagic != "PHEEBs71") {
|
||||
qWarning() << "Invalid fast file magic!";
|
||||
return false;
|
||||
}
|
||||
fastFileStream.skipRawData(4);
|
||||
|
||||
// Read IV table name (32 bytes).
|
||||
QByteArray fileName(32, Qt::Uninitialized);
|
||||
fastFileStream.readRawData(fileName.data(), 32);
|
||||
|
||||
// Build the IV table from the fileName.
|
||||
QByteArray ivTable = Compressor::InitIVTable(fileName);
|
||||
|
||||
// Skip the RSA signature (256 bytes).
|
||||
QByteArray rsaSignature(256, Qt::Uninitialized);
|
||||
fastFileStream.readRawData(rsaSignature.data(), 256);
|
||||
|
||||
// Now the stream should be positioned at 0x13C, where sections begin.
|
||||
int sectionIndex = 0;
|
||||
while (true) {
|
||||
qint32 sectionSize = 0;
|
||||
fastFileStream >> sectionSize;
|
||||
qDebug() << "Section index:" << sectionIndex << "Size:" << sectionSize
|
||||
<< "Pos:" << fastFileStream.device()->pos();
|
||||
if (sectionSize == 0)
|
||||
break;
|
||||
|
||||
// Read the section data.
|
||||
QByteArray sectionData;
|
||||
sectionData.resize(sectionSize);
|
||||
fastFileStream.readRawData(sectionData.data(), sectionSize);
|
||||
|
||||
// Compute the IV for this section.
|
||||
QByteArray iv = Compressor::GetIV(ivTable, sectionIndex);
|
||||
|
||||
// Decrypt the section using Salsa20.
|
||||
QByteArray decData = Compressor::salsa20DecryptSection(sectionData, key, iv);
|
||||
|
||||
// Compute SHA1 hash of the decrypted data.
|
||||
QByteArray sectionHash = QCryptographicHash::hash(decData, QCryptographicHash::Sha1);
|
||||
|
||||
// Update the IV table based on the section hash.
|
||||
Compressor::UpdateIVTable(ivTable, sectionIndex, sectionHash);
|
||||
|
||||
// Build a compressed data buffer by prepending the two-byte zlib header.
|
||||
QByteArray compressedData;
|
||||
compressedData.append(char(0x78));
|
||||
compressedData.append(char(0x01));
|
||||
compressedData.append(decData);
|
||||
|
||||
// For COD7, always decompress.
|
||||
// For COD9, conditionally use DEFLATE (set useDeflateForCOD9 as needed).
|
||||
if (game == "COD7") {
|
||||
decompressedData.append(Compressor::DecompressZLIB(compressedData));
|
||||
} else if (game == "COD9") {
|
||||
if (platform == "PC") {
|
||||
decompressedData.append(Compressor::DecompressZLIB(compressedData));
|
||||
} else if (platform == "360") {
|
||||
decompressedData.append(LZX::DecompressLZX(compressedData, compressedData.size()));
|
||||
}
|
||||
} else {
|
||||
// If not decompressing, append the compressed buffer as-is.
|
||||
decompressedData.append(compressedData);
|
||||
}
|
||||
|
||||
// Optionally write out test files for COD9.
|
||||
if (game == "COD9") {
|
||||
QFile testFile("exports/" + QString("%1.out").arg(sectionIndex));
|
||||
if(testFile.open(QIODevice::WriteOnly)) {
|
||||
testFile.write(decompressedData);
|
||||
testFile.close();
|
||||
}
|
||||
}
|
||||
|
||||
sectionIndex++;
|
||||
}
|
||||
|
||||
// For COD9, write out the complete decompressed zone for testing.
|
||||
if (false && game == "COD9") {
|
||||
QFile testFile("exports/test.zone");
|
||||
if(testFile.open(QIODevice::WriteOnly)) {
|
||||
testFile.write(decompressedData);
|
||||
testFile.close();
|
||||
}
|
||||
}
|
||||
|
||||
// Load the zone file with the decompressed data (using an Xbox platform flag).
|
||||
zoneFile.Load(decompressedData, fileStem.section('.', 0, 0) + ".zone", FF_PLATFORM_XBOX);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool FastFile::Load(const QString aFilePath) {
|
||||
if (aFilePath.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check fastfile can be read
|
||||
QFile *file = new QFile(aFilePath);
|
||||
if (!file->open(QIODevice::ReadOnly)) {
|
||||
qDebug() << QString("Error: Failed to open FastFile: %1!").arg(aFilePath);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Decompress fastfile and close
|
||||
const QString fastFileStem = aFilePath.section("/", -1, -1);
|
||||
fileStem = fastFileStem;
|
||||
if (!Load(file->readAll())) {
|
||||
qDebug() << "Error: Failed to load fastfile: " << fastFileStem;
|
||||
return false;
|
||||
}
|
||||
|
||||
file->close();
|
||||
|
||||
// Open zone file after decompressing ff and writing
|
||||
return true;
|
||||
}
|
||||
|
||||
QString FastFile::GetFileStem() const {
|
||||
return fileStem;
|
||||
}
|
||||
|
||||
FF_COMPANY FastFile::GetCompany() const {
|
||||
return company;
|
||||
}
|
||||
|
||||
FF_FILETYPE FastFile::GetFileType() const {
|
||||
return fileType;
|
||||
}
|
||||
|
||||
FF_SIGNAGE FastFile::GetSignage() const {
|
||||
return signage;
|
||||
}
|
||||
|
||||
QString FastFile::GetMagic() const {
|
||||
return magic;
|
||||
}
|
||||
|
||||
quint32 FastFile::GetVersion() const {
|
||||
return version;
|
||||
}
|
||||
|
||||
ZoneFile FastFile::GetZoneFile() const {
|
||||
return zoneFile;
|
||||
}
|
||||
|
||||
QString FastFile::GetGame() const {
|
||||
return game;
|
||||
}
|
||||
|
||||
QString FastFile::GetPlatform() const {
|
||||
return platform;
|
||||
}
|
||||
|
||||
FF_COMPANY FastFile::pParseFFCompany(QDataStream *afastFileStream) {
|
||||
// Check for null datastream ptr
|
||||
if (!afastFileStream) { return COMPANY_NONE; }
|
||||
// Parse company
|
||||
QByteArray companyData(2, Qt::Uninitialized);
|
||||
afastFileStream->readRawData(companyData.data(), 2);
|
||||
if (companyData == "IW") {
|
||||
qDebug() << "Company found: 'INFINITY_WARD'";
|
||||
return COMPANY_INFINITY_WARD;
|
||||
} else if (companyData == "TA") {
|
||||
qDebug() << "Company found: 'TREYARCH'";
|
||||
return COMPANY_TREYARCH;
|
||||
} else if (companyData == "Sl") {
|
||||
qDebug() << "Company found: 'SLEDGEHAMMER'";
|
||||
return COMPANY_SLEDGEHAMMER;
|
||||
} else if (companyData == "NX") {
|
||||
qDebug() << "Company found: 'NEVERSOFT'";
|
||||
return COMPANY_NEVERSOFT;
|
||||
} else {
|
||||
qDebug() << QString("Failed to find company, found '%1'!").arg(companyData);
|
||||
}
|
||||
return COMPANY_NONE;
|
||||
}
|
||||
|
||||
FF_FILETYPE FastFile::pParseFFFileType(QDataStream *afastFileStream) {
|
||||
// Parse filetype
|
||||
QByteArray fileTypeData(2, Qt::Uninitialized);
|
||||
afastFileStream->readRawData(fileTypeData.data(), 2);
|
||||
if (fileTypeData == "ff") {
|
||||
qDebug() << "File type found: 'FAST_FILE'";
|
||||
return FILETYPE_FAST_FILE;
|
||||
} else {
|
||||
qDebug() << "Failed to find file type!";
|
||||
}
|
||||
return FILETYPE_NONE;
|
||||
}
|
||||
|
||||
FF_SIGNAGE FastFile::pParseFFSignage(QDataStream *afastFileStream) {
|
||||
// Parse filetype
|
||||
QByteArray signedData(1, Qt::Uninitialized);
|
||||
afastFileStream->readRawData(signedData.data(), 1);
|
||||
if (signedData == "u") {
|
||||
qDebug() << "Found valid signage: Unsigned";
|
||||
return SIGNAGE_UNSIGNED;
|
||||
} else if (signedData == "0" || signedData == "x") {
|
||||
qDebug() << "Found valid signage: Signed";
|
||||
return SIGNAGE_SIGNED;
|
||||
} else {
|
||||
qDebug() << "Failed to determine signage of fastfile!";
|
||||
}
|
||||
return SIGNAGE_NONE;
|
||||
}
|
||||
|
||||
QString FastFile::pParseFFMagic(QDataStream *afastFileStream) {
|
||||
// Parse magic
|
||||
QByteArray magicData(3, Qt::Uninitialized);
|
||||
afastFileStream->readRawData(magicData.data(), 3);
|
||||
if (magicData == "100") {
|
||||
qDebug() << QString("Found valid magic: '%1'").arg(magicData);
|
||||
return magicData;
|
||||
} else {
|
||||
qDebug() << "Magic invalid!";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
quint32 FastFile::pParseFFVersion(QDataStream *afastFileStream) {
|
||||
// Parse version
|
||||
quint32 version;
|
||||
*afastFileStream >> version;
|
||||
qDebug() << QString("Found version: '%1'").arg(version);
|
||||
return version;
|
||||
}
|
||||
|
||||
QString FastFile::pCalculateFFPlatform() {
|
||||
QString result = "NONE";
|
||||
switch (version) {
|
||||
case 387: // PC World at War
|
||||
case 473: // PC Black Ops 1
|
||||
case 1: // PC Modern Warfare 3
|
||||
case 147: // PC Black Ops 2
|
||||
result = "PC";
|
||||
break;
|
||||
case 3640721408: // Xbox 360 Black Ops 1
|
||||
case 2449473536: // Xbox 360 Black Ops 2
|
||||
result = "360";
|
||||
break;
|
||||
}
|
||||
qDebug() << QString("Found platform: '%1'").arg(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
QString FastFile::pCalculateFFGame() {
|
||||
QString result = "NONE";
|
||||
switch (version) {
|
||||
case 387: // PC World at War
|
||||
result = "COD5";
|
||||
break;
|
||||
case 473: // PC Black Ops 1
|
||||
break;
|
||||
case 3640721408: // Xbox 360 Black Ops 1
|
||||
result = "COD7";
|
||||
break;
|
||||
case 1: // PC Modern Warfare 3
|
||||
result = "COD8";
|
||||
break;
|
||||
case 147: // PC Black Ops 2
|
||||
case 2449473536: // Xbox 360 Black Ops 2
|
||||
result = "COD9";
|
||||
break;
|
||||
}
|
||||
qDebug() << QString("Found game: '%1'").arg(result);
|
||||
return result;
|
||||
}
|
||||
51
fastfile.h
Normal file
@ -0,0 +1,51 @@
|
||||
#ifndef FASTFILE_H
|
||||
#define FASTFILE_H
|
||||
|
||||
#include "enums.h"
|
||||
#include "zonefile.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QCryptographicHash>
|
||||
|
||||
class FastFile
|
||||
{
|
||||
public:
|
||||
FastFile();
|
||||
~FastFile();
|
||||
FastFile(const FastFile &aFastFile);
|
||||
FastFile &operator=(const FastFile &other);
|
||||
|
||||
bool Load(const QString aFilePath);
|
||||
bool Load(const QByteArray aData);
|
||||
|
||||
QString GetFileStem() const;
|
||||
FF_COMPANY GetCompany() const;
|
||||
FF_FILETYPE GetFileType() const;
|
||||
FF_SIGNAGE GetSignage() const;
|
||||
QString GetMagic() const;
|
||||
quint32 GetVersion() const;
|
||||
ZoneFile GetZoneFile() const;
|
||||
QString GetGame() const;
|
||||
QString GetPlatform() const;
|
||||
|
||||
private:
|
||||
QString fileStem;
|
||||
FF_COMPANY company;
|
||||
FF_FILETYPE fileType;
|
||||
FF_SIGNAGE signage;
|
||||
QString magic;
|
||||
quint32 version;
|
||||
ZoneFile zoneFile;
|
||||
QString game;
|
||||
QString platform;
|
||||
|
||||
QString pCalculateFFGame();
|
||||
QString pCalculateFFPlatform();
|
||||
QString pParseFFMagic(QDataStream *afastFileStream);
|
||||
FF_SIGNAGE pParseFFSignage(QDataStream *afastFileStream);
|
||||
FF_FILETYPE pParseFFFileType(QDataStream *afastFileStream);
|
||||
FF_COMPANY pParseFFCompany(QDataStream *afastFileStream);
|
||||
quint32 pParseFFVersion(QDataStream *afastFileStream);
|
||||
};
|
||||
|
||||
#endif // FASTFILE_H
|
||||
27
fastfileviewer.cpp
Normal file
@ -0,0 +1,27 @@
|
||||
#include "fastfileviewer.h"
|
||||
#include "asset_structs.h"
|
||||
#include "ui_fastfileviewer.h"
|
||||
|
||||
FastFileViewer::FastFileViewer(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, ui(new Ui::FFViewer)
|
||||
, mFastFile(nullptr)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
FastFileViewer::~FastFileViewer()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void FastFileViewer::SetFastFile(std::shared_ptr<FastFile> aFastFile) {
|
||||
mFastFile.swap(aFastFile);
|
||||
|
||||
ui->label_Title->setText(mFastFile->GetFileStem());
|
||||
ui->comboBox_Company->setCurrentIndex(mFastFile->GetCompany());
|
||||
ui->comboBox_FileType->setCurrentIndex(mFastFile->GetFileType());
|
||||
ui->checkBox_Signed->setChecked(mFastFile->GetSignage() == SIGNAGE_SIGNED);
|
||||
ui->lineEdit_Magic->setText(mFastFile->GetMagic());
|
||||
ui->spinBox_Version->setValue(mFastFile->GetVersion());
|
||||
}
|
||||
26
fastfileviewer.h
Normal file
@ -0,0 +1,26 @@
|
||||
#ifndef FASTFILEVIEWER_H
|
||||
#define FASTFILEVIEWER_H
|
||||
|
||||
#include "asset_structs.h"
|
||||
#include "fastfile.h"
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui {
|
||||
class FFViewer;
|
||||
}
|
||||
|
||||
class FastFileViewer : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit FastFileViewer(QWidget *parent = nullptr);
|
||||
~FastFileViewer();
|
||||
|
||||
void SetFastFile(std::shared_ptr<FastFile> aFastFile);
|
||||
private:
|
||||
Ui::FFViewer *ui;
|
||||
std::shared_ptr<FastFile> mFastFile;
|
||||
};
|
||||
|
||||
#endif // FASTFILEVIEWER_H
|
||||
197
fastfileviewer.ui
Normal file
@ -0,0 +1,197 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>FFViewer</class>
|
||||
<widget class="QWidget" name="FFViewer">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>428</width>
|
||||
<height>459</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_Title">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Roboto</family>
|
||||
<pointsize>16</pointsize>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>FastFile 0</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>400</width>
|
||||
<height>400</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Roboto</family>
|
||||
<pointsize>9</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Header</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Company:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="comboBox_Company">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>None</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Infinity Ward</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Treyarch</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Sledgehammer</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Neversoft</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>File Type:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="comboBox_FileType">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>None</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>FastFile</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Signed:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QCheckBox" name="checkBox_Signed">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Is signed</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Magic:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit_Magic"/>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Version:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QSpinBox" name="spinBox_Version">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>10000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>1</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
103
ffparser.h
@ -1,103 +0,0 @@
|
||||
#ifndef FFPARSER_H
|
||||
#define FFPARSER_H
|
||||
|
||||
#include "enums.h"
|
||||
#include "structs.h"
|
||||
|
||||
#include <QDataStream>
|
||||
#include <QDebug>
|
||||
|
||||
class FastFileParser {
|
||||
public:
|
||||
static FF_COMPANY ParseFFCompany(QDataStream *afastFileStream) {
|
||||
// Check for null datastream ptr
|
||||
if (!afastFileStream) { return COMPANY_NONE; }
|
||||
// Parse company
|
||||
QByteArray companyData(2, Qt::Uninitialized);
|
||||
afastFileStream->readRawData(companyData.data(), 2);
|
||||
if (companyData == "IW") {
|
||||
qDebug() << "Company found: 'INFINITY_WARD'";
|
||||
return COMPANY_INFINITY_WARD;
|
||||
} else if (companyData == "TA") {
|
||||
qDebug() << "Company found: 'TREYARCH'";
|
||||
return COMPANY_TREYARCH;
|
||||
} else if (companyData == "Sl") {
|
||||
qDebug() << "Company found: 'SLEDGEHAMMER'";
|
||||
return COMPANY_SLEDGEHAMMER;
|
||||
} else if (companyData == "NX") {
|
||||
qDebug() << "Company found: 'NEVERSOFT'";
|
||||
return COMPANY_NEVERSOFT;
|
||||
} else {
|
||||
qDebug() << QString("Failed to find company, found '%1'!").arg(companyData);
|
||||
}
|
||||
return COMPANY_NONE;
|
||||
}
|
||||
|
||||
static FF_FILETYPE ParseFFFileType(QDataStream *afastFileStream) {
|
||||
// Parse filetype
|
||||
QByteArray fileTypeData(2, Qt::Uninitialized);
|
||||
afastFileStream->readRawData(fileTypeData.data(), 2);
|
||||
if (fileTypeData == "ff") {
|
||||
qDebug() << "File type found: 'FAST_FILE'";
|
||||
return FILETYPE_FAST_FILE;
|
||||
} else {
|
||||
qDebug() << "Failed to find file type!";
|
||||
}
|
||||
return FILETYPE_NONE;
|
||||
}
|
||||
|
||||
static FF_SIGNAGE ParseFFSignage(QDataStream *afastFileStream) {
|
||||
// Parse filetype
|
||||
QByteArray signedData(1, Qt::Uninitialized);
|
||||
afastFileStream->readRawData(signedData.data(), 1);
|
||||
if (signedData == "u") {
|
||||
qDebug() << "Found valid signage: Unsigned";
|
||||
return SIGNAGE_UNSIGNED;
|
||||
} else if (signedData == "0") {
|
||||
qDebug() << "Found valid signage: Signed";
|
||||
return SIGNAGE_SIGNED;
|
||||
} else {
|
||||
qDebug() << "Failed to determine signage of fastfile!";
|
||||
}
|
||||
return SIGNAGE_NONE;
|
||||
}
|
||||
|
||||
static QString ParseFFMagic(QDataStream *afastFileStream) {
|
||||
// Parse magic
|
||||
QByteArray magicData(3, Qt::Uninitialized);
|
||||
afastFileStream->readRawData(magicData.data(), 3);
|
||||
if (magicData == "100") {
|
||||
qDebug() << QString("Found valid magic: '%1'").arg(magicData);
|
||||
return magicData;
|
||||
} else {
|
||||
qDebug() << "Magic invalid!";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
static quint32 ParseFFVersion(QDataStream *afastFileStream) {
|
||||
// Parse version
|
||||
quint32 version;
|
||||
*afastFileStream >> version;
|
||||
qDebug() << "Version:" << version;
|
||||
if (version == 387) {
|
||||
qDebug() << QString("Found valid version: '%1'").arg(version);
|
||||
return 387;
|
||||
} else {
|
||||
qDebug() << "Version invalid!";
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static FastFile ParseFFHeader(QDataStream *afastFileStream) {
|
||||
FastFile fastFile;
|
||||
fastFile.company = ParseFFCompany(afastFileStream);
|
||||
fastFile.fileType = ParseFFFileType(afastFileStream);
|
||||
fastFile.signage = ParseFFSignage(afastFileStream);
|
||||
fastFile.magic = ParseFFMagic(afastFileStream);
|
||||
fastFile.version = ParseFFVersion(afastFileStream);
|
||||
return fastFile;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // FFPARSER_H
|
||||
28
imagewidget.cpp
Normal file
@ -0,0 +1,28 @@
|
||||
#include "imagewidget.h"
|
||||
#include "ui_imagewidget.h"
|
||||
|
||||
ImageWidget::ImageWidget(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, ui(new Ui::ImageWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
ImageWidget::~ImageWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void ImageWidget::SetImage(std::shared_ptr<Image> aImage)
|
||||
{
|
||||
mImage = aImage;
|
||||
|
||||
ui->lineEdit_Name->setText(aImage->name);
|
||||
ui->lineEdit_Role->setText(aImage->materialName);
|
||||
ui->comboBox_Compression->setCurrentIndex(aImage->compression);
|
||||
}
|
||||
|
||||
std::shared_ptr<Image> ImageWidget::GetImage()
|
||||
{
|
||||
return mImage;
|
||||
}
|
||||
32
imagewidget.h
Normal file
@ -0,0 +1,32 @@
|
||||
#ifndef IMAGEWIDGET_H
|
||||
#define IMAGEWIDGET_H
|
||||
|
||||
#include "enums.h"
|
||||
#include "dds_structs.h"
|
||||
#include "d3dbsp_structs.h"
|
||||
#include "asset_structs.h"
|
||||
#include "ipak_structs.h"
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui {
|
||||
class ImageWidget;
|
||||
}
|
||||
|
||||
class ImageWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ImageWidget(QWidget *parent = nullptr);
|
||||
~ImageWidget();
|
||||
|
||||
void SetImage(std::shared_ptr<Image> aImage);
|
||||
std::shared_ptr<Image> GetImage();
|
||||
|
||||
private:
|
||||
std::shared_ptr<Image> mImage;
|
||||
Ui::ImageWidget *ui;
|
||||
};
|
||||
|
||||
#endif // IMAGEWIDGET_H
|
||||
144
imagewidget.ui
Normal file
@ -0,0 +1,144 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ImageWidget</class>
|
||||
<widget class="QWidget" name="ImageWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>589</width>
|
||||
<height>422</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Image Role:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_Role"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_Name"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Compression:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_Compression">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>None</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>DXT1</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>DXT3</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>DXT5</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_Preview">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>250</width>
|
||||
<height>250</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>250</width>
|
||||
<height>250</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
167
ipak_structs.h
Normal file
@ -0,0 +1,167 @@
|
||||
#ifndef IPAK_STRUCTS_H
|
||||
#define IPAK_STRUCTS_H
|
||||
|
||||
#include <QDataStream>
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
|
||||
struct IPAKHeader
|
||||
{
|
||||
QString magic;
|
||||
quint32 magicInt;
|
||||
QString version;
|
||||
quint32 versionInt;
|
||||
quint32 size;
|
||||
quint32 sectionCount;
|
||||
QString platform;
|
||||
// Serial read method
|
||||
friend QDataStream &operator>>(QDataStream &in, IPAKHeader &data) {
|
||||
in.setByteOrder(QDataStream::LittleEndian);
|
||||
in >> data.magicInt;
|
||||
if (data.magicInt == 1262571593) {
|
||||
in.setByteOrder(QDataStream::BigEndian);
|
||||
data.platform = "Console";
|
||||
} else {
|
||||
data.platform = "PC";
|
||||
}
|
||||
in >> data.versionInt >> data.size >> data.sectionCount;
|
||||
// Format magic into string
|
||||
const char *magicChars = reinterpret_cast<const char *>(&data.magicInt);
|
||||
data.magic = QString::fromUtf8(magicChars, 4);
|
||||
|
||||
// Format version into hex
|
||||
data.version = QString::number(data.versionInt, 16).toUpper();
|
||||
return in;
|
||||
}
|
||||
// Serial write method
|
||||
friend QDataStream &operator<<(QDataStream &out, const IPAKHeader &data) {
|
||||
out.setByteOrder(QDataStream::LittleEndian);
|
||||
if (data.magicInt == 1262571593) {
|
||||
out.setByteOrder(QDataStream::BigEndian);
|
||||
}
|
||||
out << data.magicInt << data.version << data.size << data.sectionCount;
|
||||
return out;
|
||||
}
|
||||
};
|
||||
|
||||
struct IPAKSection
|
||||
{
|
||||
QString type;
|
||||
quint32 typeInt;
|
||||
quint32 offset;
|
||||
quint32 size;
|
||||
quint32 itemCount;
|
||||
// Serial read method
|
||||
friend QDataStream &operator>>(QDataStream &in, IPAKSection &data) {
|
||||
in >> data.typeInt >> data.offset >> data.size >> data.itemCount;
|
||||
// Format type into string
|
||||
if (data.typeInt == 1) {
|
||||
data.type = "Index";
|
||||
} else if (data.typeInt == 2) {
|
||||
data.type = "Data";
|
||||
} else {
|
||||
data.type = "Unknown";
|
||||
}
|
||||
return in;
|
||||
}
|
||||
// Serial write method
|
||||
friend QDataStream &operator<<(QDataStream &out, const IPAKSection &data) {
|
||||
out << data.typeInt << data.offset << data.size << data.itemCount;
|
||||
return out;
|
||||
}
|
||||
};
|
||||
|
||||
struct IPAKDataChunkCommand {
|
||||
quint32 size;
|
||||
bool compressed;
|
||||
// Serial read method
|
||||
friend QDataStream &operator>>(QDataStream &in, IPAKDataChunkCommand &data) {
|
||||
quint32 sizeAndCompression;
|
||||
in >> sizeAndCompression;
|
||||
|
||||
data.size = sizeAndCompression & 0x00FFFFFF;
|
||||
data.compressed = (sizeAndCompression >> 24) & 0x01;
|
||||
|
||||
return in;
|
||||
}
|
||||
// Serial write method
|
||||
friend QDataStream &operator<<(QDataStream &out, const IPAKDataChunkCommand &data) {
|
||||
quint32 sanitizedSize = data.size & 0x00FFFFFF;
|
||||
quint32 sanitizedCompressed = data.compressed & 0x01;
|
||||
quint32 sizeAndCompression = (sanitizedCompressed << 24) | sanitizedSize;
|
||||
|
||||
out << sizeAndCompression;
|
||||
return out;
|
||||
}
|
||||
};
|
||||
|
||||
struct IPAKDataChunkHeader
|
||||
{
|
||||
quint32 count;
|
||||
quint32 offset;
|
||||
QVector<IPAKDataChunkCommand> commands;
|
||||
// Serial read method
|
||||
friend QDataStream &operator>>(QDataStream &in, IPAKDataChunkHeader &data) {
|
||||
quint32 countAndOffset;
|
||||
in >> countAndOffset;
|
||||
data.count = (countAndOffset >> 24) & 0xFF;
|
||||
data.offset = countAndOffset & 0x00FFFFFF;
|
||||
return in;
|
||||
}
|
||||
// Serial write method
|
||||
friend QDataStream &operator<<(QDataStream &out, const IPAKDataChunkHeader &data) {
|
||||
quint32 count = data.count & 0xFF;
|
||||
quint32 offset = data.offset & 0x00FFFFFF;
|
||||
out << ((count << 24) | offset);
|
||||
return out;
|
||||
}
|
||||
};
|
||||
|
||||
struct IPAKIndexEntry
|
||||
{
|
||||
quint32 dataHash;
|
||||
quint32 nameHash;
|
||||
quint32 offset;
|
||||
quint32 size;
|
||||
// Serial read method
|
||||
friend QDataStream &operator>>(QDataStream &in, IPAKIndexEntry &data) {
|
||||
in >> data.dataHash >> data.nameHash >> data.offset >> data.size;
|
||||
return in;
|
||||
}
|
||||
// Serial write method
|
||||
friend QDataStream &operator<<(QDataStream &out, const IPAKIndexEntry &data) {
|
||||
out << data.dataHash << data.nameHash << data.offset << data.size;
|
||||
return out;
|
||||
}
|
||||
};
|
||||
|
||||
struct IPAKDataChunkMetaData
|
||||
{
|
||||
quint64 key;
|
||||
QString name;
|
||||
int format;
|
||||
int offset;
|
||||
int size;
|
||||
int width;
|
||||
int height;
|
||||
int levels;
|
||||
int mip;
|
||||
// Serial read method
|
||||
friend QDataStream &operator>>(QDataStream &in, IPAKDataChunkMetaData &data) {
|
||||
in >> data.key;
|
||||
in.readRawData(reinterpret_cast<char *>(data.name.data()), sizeof(60));
|
||||
in >> data.format >> data.offset >> data.size >> data.width
|
||||
>> data.height >> data.levels >> data.mip;
|
||||
return in;
|
||||
}
|
||||
// Serial write method
|
||||
friend QDataStream &operator<<(QDataStream &out, const IPAKDataChunkMetaData &data) {
|
||||
out << data.key;
|
||||
out.writeRawData(reinterpret_cast<const char *>(data.name.constData()), sizeof(60));
|
||||
out << data.format << data.offset << data.size << data.width
|
||||
<< data.height << data.levels << data.mip;
|
||||
return out;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // IPAK_STRUCTS_H
|
||||
292
iwifile.cpp
Normal file
@ -0,0 +1,292 @@
|
||||
#include "iwifile.h"
|
||||
#include "ddsfile.h"
|
||||
|
||||
IWIFile::IWIFile() :
|
||||
fileStem(),
|
||||
header(),
|
||||
info(),
|
||||
mipmaps() {
|
||||
|
||||
}
|
||||
|
||||
IWIFile::IWIFile(const QString &aFilePath) :
|
||||
fileStem(aFilePath.split('.').first().split('/').last()) {
|
||||
|
||||
QFile file(aFilePath);
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
qDebug() << "Error: Unable to open IWI file" << aFilePath;
|
||||
return;
|
||||
}
|
||||
|
||||
QDataStream in(&file);
|
||||
in.setByteOrder(QDataStream::LittleEndian);
|
||||
|
||||
// Read header
|
||||
in.readRawData(reinterpret_cast<char*>(&header), sizeof(IWIHeader));
|
||||
|
||||
if (!header.isSupported()) {
|
||||
qDebug() << "Error: Unsupported IWI version!";
|
||||
return;
|
||||
}
|
||||
|
||||
// Adjust seek position for MW2/MW3
|
||||
if (header.Version == 0x08) {
|
||||
file.seek(0x08);
|
||||
}
|
||||
|
||||
// Read info
|
||||
in.readRawData(reinterpret_cast<char*>(&info), sizeof(IWIInfo));
|
||||
|
||||
// Determine offset array size
|
||||
QVector<qint32> offsets((header.Version == 0x1B) ? 8 : 4);
|
||||
|
||||
if (header.Version == 0x0D || header.Version == 0x1B) {
|
||||
file.seek(header.Version == 0x1B ? 0x20 : 0x10);
|
||||
}
|
||||
|
||||
// Read offsets
|
||||
for (qint32 &offset : offsets) {
|
||||
in >> offset;
|
||||
}
|
||||
|
||||
// Compute mipmaps
|
||||
qint64 currentPos = file.pos();
|
||||
qint64 fileSize = file.size();
|
||||
QVector<quint64> positions = QVector<quint64>();
|
||||
|
||||
for (int i = 0; i < offsets.size(); i++) {
|
||||
IWIMipmap m;
|
||||
if (i == 0) {
|
||||
m.offset = offsets[i];
|
||||
m.size = fileSize - offsets[i];
|
||||
} else if (i == offsets.size() - 1) {
|
||||
m.offset = currentPos;
|
||||
m.size = offsets[i] - currentPos;
|
||||
} else {
|
||||
m.offset = offsets[i];
|
||||
m.size = offsets[i - 1] - offsets[i];
|
||||
}
|
||||
|
||||
quint64 pos = file.pos();
|
||||
|
||||
// Read mipmap
|
||||
file.seek(m.offset);
|
||||
m.data = file.read(m.size);
|
||||
|
||||
file.seek(pos);
|
||||
mipmaps.append(m);
|
||||
}
|
||||
|
||||
// Close file
|
||||
file.close();
|
||||
}
|
||||
|
||||
IWIFile::IWIFile(DDSFile &aDDSFile) {
|
||||
// Ensure the DDS file has mipmaps
|
||||
if (aDDSFile.mipmaps.isEmpty()) {
|
||||
qDebug() << "Error: No mipmaps found in DDS file!";
|
||||
return;
|
||||
}
|
||||
|
||||
// Create IWIFile object
|
||||
fileStem = aDDSFile.fileStem;
|
||||
|
||||
// Set header (Magic & Version)
|
||||
memcpy(header.Magic, "IWi", 3);
|
||||
header.Version = 0x06; // Default to CoD4/CoD5 version
|
||||
|
||||
// Set IWI Texture Info
|
||||
info.Format = static_cast<quint8>(aDDSFile.header.pixelFormat.format);
|
||||
info.Width = aDDSFile.header.width;
|
||||
info.Height = aDDSFile.header.height;
|
||||
info.Depth = 1; // Default depth for 2D textures
|
||||
info.Usage = 0; // No specific usage
|
||||
|
||||
// Convert DDS mipmaps to IWI mipmaps
|
||||
int offset = 28; // Standard offset start
|
||||
for (const auto& ddsMipmap : aDDSFile.mipmaps) {
|
||||
IWIMipmap iwiMipmap;
|
||||
iwiMipmap.offset = offset;
|
||||
iwiMipmap.size = ddsMipmap.data.size();
|
||||
iwiMipmap.data = ddsMipmap.data;
|
||||
|
||||
offset += iwiMipmap.size;
|
||||
mipmaps.append(iwiMipmap);
|
||||
}
|
||||
}
|
||||
|
||||
IWIFile::IWIFile(const IWIFile &iwiFile) {
|
||||
fileStem = iwiFile.fileStem;
|
||||
header = iwiFile.header;
|
||||
info = iwiFile.info;
|
||||
mipmaps = iwiFile.mipmaps;
|
||||
}
|
||||
|
||||
IWIFile &IWIFile::operator=(const IWIFile &other) {
|
||||
if (this != &other) {
|
||||
fileStem = other.fileStem;
|
||||
header = other.header;
|
||||
info = other.info;
|
||||
mipmaps = other.mipmaps;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
IWIFile::~IWIFile() {
|
||||
|
||||
}
|
||||
|
||||
void IWIFile::SetupExportDirs() {
|
||||
QDir dir = QDir::currentPath();
|
||||
if (!dir.exists("exports/")) {
|
||||
dir.mkdir("exports/");
|
||||
}
|
||||
|
||||
if (!dir.exists("exports/iwi/")) {
|
||||
dir.mkdir("exports/iwi/");
|
||||
}
|
||||
if (!dir.exists("exports/dds/")) {
|
||||
dir.mkdir("exports/dds/");
|
||||
}
|
||||
if (!dir.exists("exports/png/")) {
|
||||
dir.mkdir("exports/png/");
|
||||
}
|
||||
if (!dir.exists("exports/jpg/")) {
|
||||
dir.mkdir("exports/jpg/");
|
||||
}
|
||||
}
|
||||
|
||||
bool IWIFile::SaveIWI() {
|
||||
SetupExportDirs();
|
||||
QFile file("exports/iwi/" + fileStem + ".iwi");
|
||||
if (!file.open(QIODevice::WriteOnly)) {
|
||||
qDebug() << "Error: Unable to write IWI file " << fileStem + ".iwi";
|
||||
return false;
|
||||
}
|
||||
|
||||
QDataStream out(&file);
|
||||
out.setByteOrder(QDataStream::LittleEndian);
|
||||
|
||||
// Write IWI Header
|
||||
out.writeRawData(reinterpret_cast<const char*>(&header), sizeof(IWIHeader));
|
||||
|
||||
// Adjust seek position for MW2/MW3
|
||||
if (header.Version == 0x08) {
|
||||
file.seek(0x08);
|
||||
}
|
||||
|
||||
// Write IWI Texture Info
|
||||
out.writeRawData(reinterpret_cast<const char*>(&info), sizeof(IWIInfo));
|
||||
|
||||
// Determine number of mipmaps based on version
|
||||
QVector<qint32> offsets((header.Version == 0x1B) ? 8 : 4);
|
||||
qint32 currentOffset = file.pos() + (offsets.size() * sizeof(qint32));
|
||||
|
||||
// Compute offsets
|
||||
for (int i = 0; i < offsets.size(); i++) {
|
||||
offsets[i] = currentOffset;
|
||||
if (mipmaps.size() && i < mipmaps.size()) {
|
||||
currentOffset += mipmaps[i].size;
|
||||
}
|
||||
}
|
||||
|
||||
// Seek and write offsets
|
||||
if (header.Version == 0x0D || header.Version == 0x1B) {
|
||||
file.seek(header.Version == 0x1B ? 0x20 : 0x10);
|
||||
}
|
||||
|
||||
for (const qint32 &offset : offsets) {
|
||||
out << offset;
|
||||
}
|
||||
|
||||
for (auto mipmap : mipmaps) {
|
||||
file.seek(mipmap.offset);
|
||||
file.write(mipmap.data);
|
||||
}
|
||||
|
||||
file.close();
|
||||
|
||||
qDebug() << "Successfully wrote IWI file: " << fileStem + ".iwi";
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IWIFile::SaveDDS() {
|
||||
SetupExportDirs();
|
||||
QFile file("exports/dds/" + fileStem + ".dds");
|
||||
if (!file.open(QIODevice::WriteOnly)) {
|
||||
qDebug() << "Error: Unable to write DDS file " << fileStem + ".dds";
|
||||
return false;
|
||||
}
|
||||
|
||||
DDSHeader ddsHeader = {};
|
||||
ddsHeader.magic = 0x20534444; // 'DDS '
|
||||
ddsHeader.size = 124;
|
||||
ddsHeader.flags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT | DDSD_LINEARSIZE;
|
||||
ddsHeader.height = info.Height;
|
||||
ddsHeader.width = info.Width;
|
||||
ddsHeader.depth = 0;
|
||||
ddsHeader.mipMapCount = mipmaps.size();
|
||||
|
||||
DDSPixelFormat ddsPixelFormat = DDSFile::CalculatePixelFormat(info.Format);
|
||||
if (ddsPixelFormat.flags & DDPF_FOURCC) {
|
||||
ddsHeader.flags |= DDSD_LINEARSIZE;
|
||||
} else {
|
||||
ddsHeader.flags |= DDSD_PITCH;
|
||||
}
|
||||
ddsHeader.pixelFormat = ddsPixelFormat;
|
||||
|
||||
// Calculate pitch/linear size
|
||||
if (ddsPixelFormat.flags & DDPF_FOURCC) {
|
||||
int blockSize = (ddsPixelFormat.format == 0x31545844) ? 8 : 16;
|
||||
ddsHeader.pitchOrLinearSize = fmax(1, (ddsHeader.width + 3) / 4) * blockSize * (ddsHeader.height / 4);
|
||||
} else {
|
||||
ddsHeader.pitchOrLinearSize = ddsHeader.width * (ddsPixelFormat.rgbBitCount / 8);
|
||||
}
|
||||
|
||||
DDSCaps ddsCaps = {};
|
||||
ddsCaps.caps1 = DDSCAPS_TEXTURE;
|
||||
ddsCaps.caps2 = 0;
|
||||
ddsCaps.dDSX = 0;
|
||||
ddsCaps.reserved = 0;
|
||||
ddsHeader.caps = ddsCaps;
|
||||
|
||||
QDataStream out(&file);
|
||||
out.setByteOrder(QDataStream::LittleEndian);
|
||||
|
||||
// Write DDS header
|
||||
out.writeRawData(reinterpret_cast<const char*>(&ddsHeader), sizeof(DDSHeader));
|
||||
|
||||
for (auto mipmap : mipmaps) {
|
||||
if (!mipmap.data.size()) { continue; }
|
||||
|
||||
// Write mipmap data
|
||||
out.writeRawData(reinterpret_cast<const char*>(mipmap.data.constData()), mipmap.data.size());
|
||||
}
|
||||
file.close();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IWIFile::SavePNG() {
|
||||
DDSFile ddsFile(*this);
|
||||
if (!ddsFile.SavePNG()) {
|
||||
qDebug() << "Error: Failed to save PNG file: " << fileStem + ".png";
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IWIFile::SaveJPG() {
|
||||
DDSFile ddsFile(*this);
|
||||
if (!ddsFile.SavePNG()) {
|
||||
qDebug() << "Error: Failed to save JPG file: " << fileStem + ".jpg";
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check if the IWI version is supported
|
||||
bool IWIHeader::isSupported() const {
|
||||
return (Magic[0] == 'I' && Magic[1] == 'W' && Magic[2] == 'i') &&
|
||||
supportedVersions.contains(Version);
|
||||
}
|
||||
67
iwifile.h
Normal file
@ -0,0 +1,67 @@
|
||||
#ifndef IWIFILE_H
|
||||
#define IWIFILE_H
|
||||
|
||||
#include "qimage.h"
|
||||
#include <QFile>
|
||||
#include <QByteArray>
|
||||
#include <QDataStream>
|
||||
#include <QtEndian>
|
||||
#include <QVector>
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QApplication>
|
||||
|
||||
// Supported versions
|
||||
static const QVector<quint8> supportedVersions = {
|
||||
0x05, // CoD2
|
||||
0x06, // CoD4, CoD5
|
||||
0x08, // CoDMW2, CoDMW3
|
||||
0x0D, // CoDBO1
|
||||
0x1B // CoDBO2
|
||||
};
|
||||
|
||||
class DDSFile;
|
||||
|
||||
struct IWIHeader {
|
||||
char Magic[3];
|
||||
quint8 Version;
|
||||
|
||||
bool isSupported() const;
|
||||
};
|
||||
|
||||
struct IWIInfo {
|
||||
quint8 Format;
|
||||
quint8 Usage;
|
||||
quint16 Width;
|
||||
quint16 Height;
|
||||
quint16 Depth;
|
||||
};
|
||||
|
||||
struct IWIMipmap {
|
||||
qint32 offset;
|
||||
qint32 size;
|
||||
QByteArray data;
|
||||
};
|
||||
|
||||
class IWIFile {
|
||||
public:
|
||||
QString fileStem;
|
||||
IWIHeader header;
|
||||
IWIInfo info;
|
||||
QVector<IWIMipmap> mipmaps;
|
||||
|
||||
IWIFile();
|
||||
IWIFile(const QString &aFilePath);
|
||||
IWIFile(DDSFile &aDDSFile);
|
||||
IWIFile(const IWIFile &iwiFile);
|
||||
IWIFile& operator=(const IWIFile& other);
|
||||
~IWIFile();
|
||||
|
||||
bool SaveIWI();
|
||||
bool SaveDDS();
|
||||
bool SavePNG();
|
||||
bool SaveJPG();
|
||||
void SetupExportDirs();
|
||||
};
|
||||
|
||||
#endif // IWIFILE_H
|
||||
98
iwiviewer.cpp
Normal file
@ -0,0 +1,98 @@
|
||||
#include "iwiviewer.h"
|
||||
#include "enums.h"
|
||||
#include "ui_iwiviewer.h"
|
||||
|
||||
IWIViewer::IWIViewer(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, ui(new Ui::IWIViewer)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
IWIViewer::~IWIViewer()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void IWIViewer::SetIWIFile(std::shared_ptr<IWIFile> aIWIFile) {
|
||||
mIWIFile.swap(aIWIFile);
|
||||
|
||||
ui->label_Title->setText(mIWIFile->fileStem + ".iwi");
|
||||
|
||||
// If you’re using Qt and want a QString:
|
||||
QString magicStr = QString::fromLatin1(mIWIFile->header.Magic, 3);
|
||||
ui->lineEdit_Magic->setText(magicStr);
|
||||
|
||||
ui->spinBox_Version->setValue(mIWIFile->header.Version);
|
||||
ui->spinBox_Depth->setValue(mIWIFile->info.Depth);
|
||||
QString formatStr = "";
|
||||
switch (mIWIFile->info.Format) {
|
||||
case IWI_FORMAT_ARGB32:
|
||||
formatStr = "ARGB32";
|
||||
break;
|
||||
case IWI_FORMAT_RGB24:
|
||||
formatStr = "RGB24";
|
||||
break;
|
||||
case IWI_FORMAT_GA16:
|
||||
formatStr = "GA16";
|
||||
break;
|
||||
case IWI_FORMAT_A8:
|
||||
formatStr = "A8";
|
||||
break;
|
||||
case IWI_FORMAT_DXT1:
|
||||
formatStr = "DXT1";
|
||||
break;
|
||||
case IWI_FORMAT_DXT3:
|
||||
formatStr = "DXT3";
|
||||
break;
|
||||
case IWI_FORMAT_DXT5:
|
||||
formatStr = "DXT5";
|
||||
break;
|
||||
}
|
||||
ui->lineEdit_Format->setText(formatStr);
|
||||
ui->spinBox_Height->setValue(mIWIFile->info.Height);
|
||||
ui->spinBox_Width->setValue(mIWIFile->info.Width);
|
||||
ui->spinBox_Usage->setValue(mIWIFile->info.Usage);
|
||||
|
||||
ui->comboBox_Mipmap->clear();
|
||||
for (auto mipmap : mIWIFile->mipmaps) {
|
||||
ui->comboBox_Mipmap->addItem(QString::number(mipmap.offset));
|
||||
}
|
||||
|
||||
connect(ui->comboBox_Mipmap, &QComboBox::currentIndexChanged, this, &IWIViewer::MipmapIndexChanged);
|
||||
|
||||
if (!mIWIFile->mipmaps.empty()) {
|
||||
MipmapIndexChanged(0);
|
||||
}
|
||||
}
|
||||
|
||||
void IWIViewer::MipmapIndexChanged(int aMipmapIndex) {
|
||||
auto mipmaps = mIWIFile->mipmaps;
|
||||
|
||||
if (aMipmapIndex == -1) { return; }
|
||||
|
||||
auto mipmap = mipmaps[aMipmapIndex];
|
||||
ui->spinBox_MipmapSize->setValue(mipmap.size);
|
||||
ui->spinBox_MipmapOffset->setValue(mipmap.offset);
|
||||
|
||||
const unsigned char* imageData = reinterpret_cast<const unsigned char*>(mipmap.data.constData());
|
||||
QImage image(reinterpret_cast<const uchar*>(imageData),
|
||||
mIWIFile->info.Width, mIWIFile->info.Height,
|
||||
QImage::Format_RGBA8888);
|
||||
|
||||
if (image.isNull()) {
|
||||
qDebug() << "Error: QImage creation failed!";
|
||||
return;
|
||||
}
|
||||
|
||||
// Convert to QPixmap
|
||||
QPixmap pixmap = QPixmap::fromImage(image);
|
||||
if (pixmap.isNull()) {
|
||||
qDebug() << "Error: QPixmap conversion failed!";
|
||||
return;
|
||||
}
|
||||
|
||||
// Scale and display
|
||||
pixmap = pixmap.scaled(ui->label_Image->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
ui->label_Image->setPixmap(pixmap);
|
||||
}
|
||||
27
iwiviewer.h
Normal file
@ -0,0 +1,27 @@
|
||||
#ifndef IWIVIEWER_H
|
||||
#define IWIVIEWER_H
|
||||
|
||||
#include "iwifile.h"
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui {
|
||||
class IWIViewer;
|
||||
}
|
||||
|
||||
class IWIViewer : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit IWIViewer(QWidget *parent = nullptr);
|
||||
~IWIViewer();
|
||||
|
||||
void MipmapIndexChanged(int aMipmapIndex);
|
||||
|
||||
void SetIWIFile(std::shared_ptr<IWIFile> aIWIFile);
|
||||
private:
|
||||
Ui::IWIViewer *ui;
|
||||
std::shared_ptr<IWIFile> mIWIFile;
|
||||
};
|
||||
|
||||
#endif // IWIVIEWER_H
|
||||
548
iwiviewer.ui
Normal file
@ -0,0 +1,548 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>IWIViewer</class>
|
||||
<widget class="QWidget" name="IWIViewer">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1246</width>
|
||||
<height>909</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_9">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_Title">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Roboto</family>
|
||||
<pointsize>16</pointsize>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>IWI File 0</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_17">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Roboto</family>
|
||||
<pointsize>9</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Header</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout_4">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Roboto</family>
|
||||
<pointsize>9</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Magic:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit_Magic">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Roboto</family>
|
||||
<pointsize>9</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_26">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Roboto</family>
|
||||
<pointsize>9</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Version:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QSpinBox" name="spinBox_Version">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Roboto</family>
|
||||
<pointsize>9</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string> B</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>1000000000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_14">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Roboto</family>
|
||||
<pointsize>9</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Info</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_8">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_40">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_38">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Roboto</family>
|
||||
<pointsize>9</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Depth:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_Depth">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Roboto</family>
|
||||
<pointsize>9</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>1000000000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_41">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_35">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Roboto</family>
|
||||
<pointsize>9</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Format</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_Format">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Roboto</family>
|
||||
<pointsize>9</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_43">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_39">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Roboto</family>
|
||||
<pointsize>9</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Height:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_Height">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Roboto</family>
|
||||
<pointsize>9</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>1000000000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_44">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_40">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Roboto</family>
|
||||
<pointsize>9</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Width:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_Width">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Roboto</family>
|
||||
<pointsize>9</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>1000000000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_45">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_41">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Roboto</family>
|
||||
<pointsize>9</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Usage</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_Usage">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Roboto</family>
|
||||
<pointsize>9</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>1000000000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_21">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Roboto</family>
|
||||
<pointsize>9</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Mipmaps</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout_5">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_25">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Roboto</family>
|
||||
<pointsize>9</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_32">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Roboto</family>
|
||||
<pointsize>9</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Select Mipmap:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_Mipmap">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>60</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Roboto</family>
|
||||
<pointsize>9</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_5">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Roboto</family>
|
||||
<pointsize>9</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_55">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Roboto</family>
|
||||
<pointsize>9</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Size: </string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QSpinBox" name="spinBox_MipmapSize">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Roboto</family>
|
||||
<pointsize>9</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>1000000000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_56">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Roboto</family>
|
||||
<pointsize>9</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Offset:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QSpinBox" name="spinBox_MipmapOffset">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Roboto</family>
|
||||
<pointsize>9</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>1000000000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_6">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_26">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Roboto</family>
|
||||
<pointsize>9</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Preview</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_22">
|
||||
<item>
|
||||
<spacer name="verticalSpacer_11">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_Image">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>600</width>
|
||||
<height>600</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>600</width>
|
||||
<height>600</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Roboto</family>
|
||||
<pointsize>9</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">border: 2px solid white;</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignmentFlag::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_12">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_13">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>116</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
59
localstringviewer.cpp
Normal file
@ -0,0 +1,59 @@
|
||||
#include "localstringviewer.h"
|
||||
#include "ui_localstringviewer.h"
|
||||
|
||||
LocalStringViewer::LocalStringViewer(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, ui(new Ui::LocalStringViewer),
|
||||
mVersion(),
|
||||
mConfigPath(),
|
||||
mFileNotes() {
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->tableWidget_Strings->setColumnCount(2);
|
||||
ui->tableWidget_Strings->setColumnWidth(0, 200);
|
||||
ui->tableWidget_Strings->horizontalHeader()->setStretchLastSection(true);
|
||||
}
|
||||
|
||||
LocalStringViewer::~LocalStringViewer() {
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void LocalStringViewer::SetVersion(quint32 aVersion) {
|
||||
mVersion = aVersion;
|
||||
|
||||
ui->spinBox_Version->setValue(mVersion);
|
||||
}
|
||||
|
||||
void LocalStringViewer::SetConfigPath(const QString aConfigPath) {
|
||||
mConfigPath = aConfigPath;
|
||||
|
||||
ui->lineEdit_Config->setText(mConfigPath);
|
||||
}
|
||||
|
||||
void LocalStringViewer::SetFileNotes(const QString aFileNotes) {
|
||||
mFileNotes = aFileNotes;
|
||||
|
||||
ui->plainTextEdit_FileNotes->setPlainText(mFileNotes);
|
||||
}
|
||||
|
||||
void LocalStringViewer::AddLocalString(LocalString aLocalString) {
|
||||
mLocalStrings << aLocalString;
|
||||
|
||||
ui->tableWidget_Strings->setRowCount(mLocalStrings.size());
|
||||
|
||||
QTableWidgetItem *aliasItem = new QTableWidgetItem(aLocalString.alias);
|
||||
QTableWidgetItem *stringItem = new QTableWidgetItem(aLocalString.string);
|
||||
|
||||
ui->tableWidget_Strings->setItem(mLocalStrings.size() - 1, 0, aliasItem);
|
||||
ui->tableWidget_Strings->setItem(mLocalStrings.size() - 1, 1, stringItem);
|
||||
}
|
||||
|
||||
void LocalStringViewer::SetZoneFile(std::shared_ptr<ZoneFile> aZoneFile) {
|
||||
mLocalStrings.clear();
|
||||
ui->tableWidget_Strings->clear();
|
||||
|
||||
ui->label_Title->setText(aZoneFile->GetFileStem().section('.', 0, 0) + ".str");
|
||||
for (LocalString localStr : aZoneFile->GetAssetMap().localStrings) {
|
||||
AddLocalString(localStr);
|
||||
}
|
||||
}
|
||||
34
localstringviewer.h
Normal file
@ -0,0 +1,34 @@
|
||||
#ifndef LOCALSTRINGVIEWER_H
|
||||
#define LOCALSTRINGVIEWER_H
|
||||
|
||||
#include "asset_structs.h"
|
||||
#include "zonefile.h"
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui {
|
||||
class LocalStringViewer;
|
||||
}
|
||||
|
||||
class LocalStringViewer : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit LocalStringViewer(QWidget *parent = nullptr);
|
||||
~LocalStringViewer();
|
||||
|
||||
void SetVersion(quint32 aVersion);
|
||||
void SetConfigPath(const QString aConfigPath);
|
||||
void SetFileNotes(const QString aFileNotes);
|
||||
void AddLocalString(LocalString aLocalString);
|
||||
void SetZoneFile(std::shared_ptr<ZoneFile> aZoneFile);
|
||||
|
||||
private:
|
||||
Ui::LocalStringViewer *ui;
|
||||
quint32 mVersion;
|
||||
QString mConfigPath;
|
||||
QString mFileNotes;
|
||||
QVector<LocalString> mLocalStrings;
|
||||
};
|
||||
|
||||
#endif // LOCALSTRINGVIEWER_H
|
||||
194
localstringviewer.ui
Normal file
@ -0,0 +1,194 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>LocalStringViewer</class>
|
||||
<widget class="QWidget" name="LocalStringViewer">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>841</width>
|
||||
<height>457</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>841</width>
|
||||
<height>457</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_Title">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Roboto</family>
|
||||
<pointsize>16</pointsize>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>LocalString File 0</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>325</width>
|
||||
<height>398</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>325</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Roboto</family>
|
||||
<pointsize>9</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Header</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>File Notes:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignTop</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Version:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit_Config">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>C:\cod5\cod\cod5\bin\StringEd.cfg</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Config:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QToolButton" name="toolButton">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" colspan="2">
|
||||
<widget class="QSpinBox" name="spinBox_Version">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>10000</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1" colspan="2">
|
||||
<widget class="QPlainTextEdit" name="plainTextEdit_FileNotes">
|
||||
<property name="placeholderText">
|
||||
<string>Files notes...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="3">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>400</width>
|
||||
<height>400</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Roboto</family>
|
||||
<pointsize>9</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Entries</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QTableWidget" name="tableWidget_Strings">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
647
lzokay.cpp
Normal file
@ -0,0 +1,647 @@
|
||||
#include "lzokay.hpp"
|
||||
#include <cstring>
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
|
||||
/*
|
||||
* Based on documentation from the Linux sources: Documentation/lzo.txt
|
||||
* https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/lzo.txt
|
||||
*/
|
||||
|
||||
namespace lzokay {
|
||||
|
||||
#if _WIN32
|
||||
#define HOST_BIG_ENDIAN 0
|
||||
#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||
#define HOST_BIG_ENDIAN 1
|
||||
#else
|
||||
#define HOST_BIG_ENDIAN 0
|
||||
#endif
|
||||
|
||||
#if HOST_BIG_ENDIAN
|
||||
static uint16_t get_le16(const uint8_t* p) {
|
||||
uint16_t val = *reinterpret_cast<const uint16_t*>(p);
|
||||
#if __GNUC__
|
||||
return __builtin_bswap16(val);
|
||||
#elif _WIN32
|
||||
return _byteswap_ushort(val);
|
||||
#else
|
||||
return (val = (val << 8) | ((val >> 8) & 0xFF));
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
static uint16_t get_le16(const uint8_t* p) {
|
||||
return *reinterpret_cast<const uint16_t*>(p);
|
||||
}
|
||||
#endif
|
||||
|
||||
constexpr std::size_t Max255Count = std::size_t(~0) / 255 - 2;
|
||||
|
||||
#define NEEDS_IN(count) \
|
||||
if (inp + (count) > inp_end) { \
|
||||
dst_size = outp - dst; \
|
||||
return EResult::InputOverrun; \
|
||||
}
|
||||
|
||||
#define NEEDS_OUT(count) \
|
||||
if (outp + (count) > outp_end) { \
|
||||
dst_size = outp - dst; \
|
||||
return EResult::OutputOverrun; \
|
||||
}
|
||||
|
||||
#define CONSUME_ZERO_BYTE_LENGTH \
|
||||
std::size_t offset; \
|
||||
{ \
|
||||
const uint8_t *old_inp = inp; \
|
||||
while (*inp == 0) ++inp; \
|
||||
offset = inp - old_inp; \
|
||||
if (offset > Max255Count) { \
|
||||
dst_size = outp - dst; \
|
||||
return EResult::Error; \
|
||||
} \
|
||||
}
|
||||
|
||||
#define WRITE_ZERO_BYTE_LENGTH(length) \
|
||||
{ \
|
||||
std::size_t l; \
|
||||
for (l = length; l > 255; l -= 255) { *outp++ = 0; } \
|
||||
*outp++ = l; \
|
||||
}
|
||||
|
||||
constexpr uint32_t M1MaxOffset = 0x0400;
|
||||
constexpr uint32_t M2MaxOffset = 0x0800;
|
||||
constexpr uint32_t M3MaxOffset = 0x4000;
|
||||
constexpr uint32_t M4MaxOffset = 0xbfff;
|
||||
|
||||
constexpr uint32_t M1MinLen = 2;
|
||||
constexpr uint32_t M1MaxLen = 2;
|
||||
constexpr uint32_t M2MinLen = 3;
|
||||
constexpr uint32_t M2MaxLen = 8;
|
||||
constexpr uint32_t M3MinLen = 3;
|
||||
constexpr uint32_t M3MaxLen = 33;
|
||||
constexpr uint32_t M4MinLen = 3;
|
||||
constexpr uint32_t M4MaxLen = 9;
|
||||
|
||||
constexpr uint32_t M1Marker = 0x0;
|
||||
constexpr uint32_t M2Marker = 0x40;
|
||||
constexpr uint32_t M3Marker = 0x20;
|
||||
constexpr uint32_t M4Marker = 0x10;
|
||||
|
||||
constexpr uint32_t MaxMatchByLengthLen = 34; /* Max M3 len + 1 */
|
||||
|
||||
EResult decompress(const uint8_t* src, std::size_t src_size,
|
||||
uint8_t* dst, std::size_t init_dst_size,
|
||||
std::size_t& dst_size) {
|
||||
dst_size = init_dst_size;
|
||||
|
||||
if (src_size < 3) {
|
||||
dst_size = 0;
|
||||
return EResult::InputOverrun;
|
||||
}
|
||||
|
||||
const uint8_t* inp = src;
|
||||
const uint8_t* inp_end = src + src_size;
|
||||
uint8_t* outp = dst;
|
||||
uint8_t* outp_end = dst + dst_size;
|
||||
uint8_t* lbcur;
|
||||
std::size_t lblen;
|
||||
std::size_t state = 0;
|
||||
std::size_t nstate = 0;
|
||||
|
||||
/* First byte encoding */
|
||||
if (*inp >= 22) {
|
||||
/* 22..255 : copy literal string
|
||||
* length = (byte - 17) = 4..238
|
||||
* state = 4 [ don't copy extra literals ]
|
||||
* skip byte
|
||||
*/
|
||||
std::size_t len = *inp++ - uint8_t(17);
|
||||
NEEDS_IN(len)
|
||||
NEEDS_OUT(len)
|
||||
for (std::size_t i = 0; i < len; ++i)
|
||||
*outp++ = *inp++;
|
||||
state = 4;
|
||||
} else if (*inp >= 18) {
|
||||
/* 18..21 : copy 0..3 literals
|
||||
* state = (byte - 17) = 0..3 [ copy <state> literals ]
|
||||
* skip byte
|
||||
*/
|
||||
nstate = *inp++ - uint8_t(17);
|
||||
state = nstate;
|
||||
NEEDS_IN(nstate)
|
||||
NEEDS_OUT(nstate)
|
||||
for (std::size_t i = 0; i < nstate; ++i)
|
||||
*outp++ = *inp++;
|
||||
}
|
||||
/* 0..17 : follow regular instruction encoding, see below. It is worth
|
||||
* noting that codes 16 and 17 will represent a block copy from
|
||||
* the dictionary which is empty, and that they will always be
|
||||
* invalid at this place.
|
||||
*/
|
||||
|
||||
while (true) {
|
||||
NEEDS_IN(1)
|
||||
uint8_t inst = *inp++;
|
||||
if (inst & 0xC0) {
|
||||
/* [M2]
|
||||
* 1 L L D D D S S (128..255)
|
||||
* Copy 5-8 bytes from block within 2kB distance
|
||||
* state = S (copy S literals after this block)
|
||||
* length = 5 + L
|
||||
* Always followed by exactly one byte : H H H H H H H H
|
||||
* distance = (H << 3) + D + 1
|
||||
*
|
||||
* 0 1 L D D D S S (64..127)
|
||||
* Copy 3-4 bytes from block within 2kB distance
|
||||
* state = S (copy S literals after this block)
|
||||
* length = 3 + L
|
||||
* Always followed by exactly one byte : H H H H H H H H
|
||||
* distance = (H << 3) + D + 1
|
||||
*/
|
||||
NEEDS_IN(1)
|
||||
lbcur = outp - ((*inp++ << 3) + ((inst >> 2) & 0x7) + 1);
|
||||
lblen = std::size_t(inst >> 5) + 1;
|
||||
nstate = inst & uint8_t(0x3);
|
||||
} else if (inst & M3Marker) {
|
||||
/* [M3]
|
||||
* 0 0 1 L L L L L (32..63)
|
||||
* Copy of small block within 16kB distance (preferably less than 34B)
|
||||
* length = 2 + (L ?: 31 + (zero_bytes * 255) + non_zero_byte)
|
||||
* Always followed by exactly one LE16 : D D D D D D D D : D D D D D D S S
|
||||
* distance = D + 1
|
||||
* state = S (copy S literals after this block)
|
||||
*/
|
||||
lblen = std::size_t(inst & uint8_t(0x1f)) + 2;
|
||||
if (lblen == 2) {
|
||||
CONSUME_ZERO_BYTE_LENGTH
|
||||
NEEDS_IN(1)
|
||||
lblen += offset * 255 + 31 + *inp++;
|
||||
}
|
||||
NEEDS_IN(2)
|
||||
nstate = get_le16(inp);
|
||||
inp += 2;
|
||||
lbcur = outp - ((nstate >> 2) + 1);
|
||||
nstate &= 0x3;
|
||||
} else if (inst & M4Marker) {
|
||||
/* [M4]
|
||||
* 0 0 0 1 H L L L (16..31)
|
||||
* Copy of a block within 16..48kB distance (preferably less than 10B)
|
||||
* length = 2 + (L ?: 7 + (zero_bytes * 255) + non_zero_byte)
|
||||
* Always followed by exactly one LE16 : D D D D D D D D : D D D D D D S S
|
||||
* distance = 16384 + (H << 14) + D
|
||||
* state = S (copy S literals after this block)
|
||||
* End of stream is reached if distance == 16384
|
||||
*/
|
||||
lblen = std::size_t(inst & uint8_t(0x7)) + 2;
|
||||
if (lblen == 2) {
|
||||
CONSUME_ZERO_BYTE_LENGTH
|
||||
NEEDS_IN(1)
|
||||
lblen += offset * 255 + 7 + *inp++;
|
||||
}
|
||||
NEEDS_IN(2)
|
||||
nstate = get_le16(inp);
|
||||
inp += 2;
|
||||
lbcur = outp - (((inst & 0x8) << 11) + (nstate >> 2));
|
||||
nstate &= 0x3;
|
||||
if (lbcur == outp)
|
||||
break; /* Stream finished */
|
||||
lbcur -= 16384;
|
||||
} else {
|
||||
/* [M1] Depends on the number of literals copied by the last instruction. */
|
||||
if (state == 0) {
|
||||
/* If last instruction did not copy any literal (state == 0), this
|
||||
* encoding will be a copy of 4 or more literal, and must be interpreted
|
||||
* like this :
|
||||
*
|
||||
* 0 0 0 0 L L L L (0..15) : copy long literal string
|
||||
* length = 3 + (L ?: 15 + (zero_bytes * 255) + non_zero_byte)
|
||||
* state = 4 (no extra literals are copied)
|
||||
*/
|
||||
std::size_t len = inst + 3;
|
||||
if (len == 3) {
|
||||
CONSUME_ZERO_BYTE_LENGTH
|
||||
NEEDS_IN(1)
|
||||
len += offset * 255 + 15 + *inp++;
|
||||
}
|
||||
/* copy_literal_run */
|
||||
NEEDS_IN(len)
|
||||
NEEDS_OUT(len)
|
||||
for (std::size_t i = 0; i < len; ++i)
|
||||
*outp++ = *inp++;
|
||||
state = 4;
|
||||
continue;
|
||||
} else if (state != 4) {
|
||||
/* If last instruction used to copy between 1 to 3 literals (encoded in
|
||||
* the instruction's opcode or distance), the instruction is a copy of a
|
||||
* 2-byte block from the dictionary within a 1kB distance. It is worth
|
||||
* noting that this instruction provides little savings since it uses 2
|
||||
* bytes to encode a copy of 2 other bytes but it encodes the number of
|
||||
* following literals for free. It must be interpreted like this :
|
||||
*
|
||||
* 0 0 0 0 D D S S (0..15) : copy 2 bytes from <= 1kB distance
|
||||
* length = 2
|
||||
* state = S (copy S literals after this block)
|
||||
* Always followed by exactly one byte : H H H H H H H H
|
||||
* distance = (H << 2) + D + 1
|
||||
*/
|
||||
NEEDS_IN(1)
|
||||
nstate = inst & uint8_t(0x3);
|
||||
lbcur = outp - ((inst >> 2) + (*inp++ << 2) + 1);
|
||||
lblen = 2;
|
||||
} else {
|
||||
/* If last instruction used to copy 4 or more literals (as detected by
|
||||
* state == 4), the instruction becomes a copy of a 3-byte block from the
|
||||
* dictionary from a 2..3kB distance, and must be interpreted like this :
|
||||
*
|
||||
* 0 0 0 0 D D S S (0..15) : copy 3 bytes from 2..3 kB distance
|
||||
* length = 3
|
||||
* state = S (copy S literals after this block)
|
||||
* Always followed by exactly one byte : H H H H H H H H
|
||||
* distance = (H << 2) + D + 2049
|
||||
*/
|
||||
NEEDS_IN(1)
|
||||
nstate = inst & uint8_t(0x3);
|
||||
lbcur = outp - ((inst >> 2) + (*inp++ << 2) + 2049);
|
||||
lblen = 3;
|
||||
}
|
||||
}
|
||||
if (lbcur < dst) {
|
||||
dst_size = outp - dst;
|
||||
return EResult::LookbehindOverrun;
|
||||
}
|
||||
NEEDS_IN(nstate)
|
||||
NEEDS_OUT(lblen + nstate)
|
||||
/* Copy lookbehind */
|
||||
for (std::size_t i = 0; i < lblen; ++i)
|
||||
*outp++ = *lbcur++;
|
||||
state = nstate;
|
||||
/* Copy literal */
|
||||
for (std::size_t i = 0; i < nstate; ++i)
|
||||
*outp++ = *inp++;
|
||||
}
|
||||
|
||||
dst_size = outp - dst;
|
||||
if (lblen != 3) /* Ensure terminating M4 was encountered */
|
||||
return EResult::Error;
|
||||
if (inp == inp_end)
|
||||
return EResult::Success;
|
||||
else if (inp < inp_end)
|
||||
return EResult::InputNotConsumed;
|
||||
else
|
||||
return EResult::InputOverrun;
|
||||
}
|
||||
|
||||
struct State {
|
||||
const uint8_t* src;
|
||||
const uint8_t* src_end;
|
||||
const uint8_t* inp;
|
||||
uint32_t wind_sz;
|
||||
uint32_t wind_b;
|
||||
uint32_t wind_e;
|
||||
uint32_t cycle1_countdown;
|
||||
|
||||
const uint8_t* bufp;
|
||||
uint32_t buf_sz;
|
||||
|
||||
/* Access next input byte and advance both ends of circular buffer */
|
||||
void get_byte(uint8_t* buf) {
|
||||
if (inp >= src_end) {
|
||||
if (wind_sz > 0)
|
||||
--wind_sz;
|
||||
buf[wind_e] = 0;
|
||||
if (wind_e < DictBase::MaxMatchLen)
|
||||
buf[DictBase::BufSize + wind_e] = 0;
|
||||
} else {
|
||||
buf[wind_e] = *inp;
|
||||
if (wind_e < DictBase::MaxMatchLen)
|
||||
buf[DictBase::BufSize + wind_e] = *inp;
|
||||
++inp;
|
||||
}
|
||||
if (++wind_e == DictBase::BufSize)
|
||||
wind_e = 0;
|
||||
if (++wind_b == DictBase::BufSize)
|
||||
wind_b = 0;
|
||||
}
|
||||
|
||||
uint32_t pos2off(uint32_t pos) const {
|
||||
return wind_b > pos ? wind_b - pos : DictBase::BufSize - (pos - wind_b);
|
||||
}
|
||||
};
|
||||
|
||||
class DictImpl : public DictBase {
|
||||
public:
|
||||
struct Match3Impl : DictBase::Match3 {
|
||||
static uint32_t make_key(const uint8_t* data) {
|
||||
return ((0x9f5f * (((uint32_t(data[0]) << 5 ^ uint32_t(data[1])) << 5) ^ data[2])) >> 5) & 0x3fff;
|
||||
}
|
||||
|
||||
uint16_t get_head(uint32_t key) const {
|
||||
return (chain_sz[key] == 0) ? uint16_t(UINT16_MAX) : head[key];
|
||||
}
|
||||
|
||||
void init() {
|
||||
std::fill(std::begin(chain_sz), std::end(chain_sz), 0);
|
||||
}
|
||||
|
||||
void remove(uint32_t pos, const uint8_t* b) {
|
||||
--chain_sz[make_key(b + pos)];
|
||||
}
|
||||
|
||||
void advance(State& s, uint32_t& match_pos, uint32_t& match_count, const uint8_t* b) {
|
||||
uint32_t key = make_key(b + s.wind_b);
|
||||
match_pos = chain[s.wind_b] = get_head(key);
|
||||
match_count = chain_sz[key]++;
|
||||
if (match_count > DictBase::MaxMatchLen)
|
||||
match_count = DictBase::MaxMatchLen;
|
||||
head[key] = uint16_t(s.wind_b);
|
||||
}
|
||||
|
||||
void skip_advance(State& s, const uint8_t* b) {
|
||||
uint32_t key = make_key(b + s.wind_b);
|
||||
chain[s.wind_b] = get_head(key);
|
||||
head[key] = uint16_t(s.wind_b);
|
||||
best_len[s.wind_b] = uint16_t(DictBase::MaxMatchLen + 1);
|
||||
chain_sz[key]++;
|
||||
}
|
||||
};
|
||||
|
||||
struct Match2Impl : DictBase::Match2 {
|
||||
static uint32_t make_key(const uint8_t* data) {
|
||||
return uint32_t(data[0]) ^ (uint32_t(data[1]) << 8);
|
||||
}
|
||||
|
||||
void init() {
|
||||
std::fill(std::begin(head), std::end(head), UINT16_MAX);
|
||||
}
|
||||
|
||||
void add(uint16_t pos, const uint8_t* b) {
|
||||
head[make_key(b + pos)] = pos;
|
||||
}
|
||||
|
||||
void remove(uint32_t pos, const uint8_t* b) {
|
||||
uint16_t& p = head[make_key(b + pos)];
|
||||
if (p == pos)
|
||||
p = UINT16_MAX;
|
||||
}
|
||||
|
||||
bool search(State& s, uint32_t& lb_pos, uint32_t& lb_len,
|
||||
uint32_t best_pos[MaxMatchByLengthLen], const uint8_t* b) const {
|
||||
uint16_t pos = head[make_key(b + s.wind_b)];
|
||||
if (pos == UINT16_MAX)
|
||||
return false;
|
||||
if (best_pos[2] == 0)
|
||||
best_pos[2] = pos + 1;
|
||||
if (lb_len < 2) {
|
||||
lb_len = 2;
|
||||
lb_pos = pos;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
void init(State& s, const uint8_t* src, std::size_t src_size) {
|
||||
auto& match3 = static_cast<Match3Impl&>(_storage->match3);
|
||||
auto& match2 = static_cast<Match2Impl&>(_storage->match2);
|
||||
|
||||
s.cycle1_countdown = DictBase::MaxDist;
|
||||
match3.init();
|
||||
match2.init();
|
||||
|
||||
s.src = src;
|
||||
s.src_end = src + src_size;
|
||||
s.inp = src;
|
||||
s.wind_sz = uint32_t(std::min(src_size, std::size_t(MaxMatchLen)));
|
||||
s.wind_b = 0;
|
||||
s.wind_e = s.wind_sz;
|
||||
std::copy_n(s.inp, s.wind_sz, _storage->buffer);
|
||||
s.inp += s.wind_sz;
|
||||
|
||||
if (s.wind_e == DictBase::BufSize)
|
||||
s.wind_e = 0;
|
||||
|
||||
if (s.wind_sz < 3)
|
||||
std::fill_n(_storage->buffer + s.wind_b + s.wind_sz, 3, 0);
|
||||
}
|
||||
|
||||
void reset_next_input_entry(State& s, Match3Impl& match3, Match2Impl& match2) {
|
||||
/* Remove match from about-to-be-clobbered buffer entry */
|
||||
if (s.cycle1_countdown == 0) {
|
||||
match3.remove(s.wind_e, _storage->buffer);
|
||||
match2.remove(s.wind_e, _storage->buffer);
|
||||
} else {
|
||||
--s.cycle1_countdown;
|
||||
}
|
||||
}
|
||||
|
||||
void advance(State& s, uint32_t& lb_off, uint32_t& lb_len,
|
||||
uint32_t best_off[MaxMatchByLengthLen], bool skip) {
|
||||
auto& match3 = static_cast<Match3Impl&>(_storage->match3);
|
||||
auto& match2 = static_cast<Match2Impl&>(_storage->match2);
|
||||
|
||||
if (skip) {
|
||||
for (uint32_t i = 0; i < lb_len - 1; ++i) {
|
||||
reset_next_input_entry(s, match3, match2);
|
||||
match3.skip_advance(s, _storage->buffer);
|
||||
match2.add(uint16_t(s.wind_b), _storage->buffer);
|
||||
s.get_byte(_storage->buffer);
|
||||
}
|
||||
}
|
||||
|
||||
lb_len = 1;
|
||||
lb_off = 0;
|
||||
uint32_t lb_pos;
|
||||
|
||||
uint32_t best_pos[MaxMatchByLengthLen] = {};
|
||||
uint32_t match_pos, match_count;
|
||||
match3.advance(s, match_pos, match_count, _storage->buffer);
|
||||
|
||||
int best_char = _storage->buffer[s.wind_b];
|
||||
uint32_t best_len = lb_len;
|
||||
if (lb_len >= s.wind_sz) {
|
||||
if (s.wind_sz == 0)
|
||||
best_char = -1;
|
||||
lb_off = 0;
|
||||
match3.best_len[s.wind_b] = DictBase::MaxMatchLen + 1;
|
||||
} else {
|
||||
if (match2.search(s, lb_pos, lb_len, best_pos, _storage->buffer) && s.wind_sz >= 3) {
|
||||
for (uint32_t i = 0; i < match_count; ++i, match_pos = match3.chain[match_pos]) {
|
||||
auto ref_ptr = _storage->buffer + s.wind_b;
|
||||
auto match_ptr = _storage->buffer + match_pos;
|
||||
auto mismatch = std::mismatch(ref_ptr, ref_ptr + s.wind_sz, match_ptr);
|
||||
auto match_len = uint32_t(mismatch.first - ref_ptr);
|
||||
if (match_len < 2)
|
||||
continue;
|
||||
if (match_len < MaxMatchByLengthLen && best_pos[match_len] == 0)
|
||||
best_pos[match_len] = match_pos + 1;
|
||||
if (match_len > lb_len) {
|
||||
lb_len = match_len;
|
||||
lb_pos = match_pos;
|
||||
if (match_len == s.wind_sz || match_len > match3.best_len[match_pos])
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (lb_len > best_len)
|
||||
lb_off = s.pos2off(lb_pos);
|
||||
match3.best_len[s.wind_b] = uint16_t(lb_len);
|
||||
for (auto posit = std::begin(best_pos) + 2, offit = best_off + 2;
|
||||
posit != std::end(best_pos); ++posit, ++offit) {
|
||||
*offit = (*posit > 0) ? s.pos2off(*posit - 1) : 0;
|
||||
}
|
||||
}
|
||||
|
||||
reset_next_input_entry(s, match3, match2);
|
||||
|
||||
match2.add(uint16_t(s.wind_b), _storage->buffer);
|
||||
|
||||
s.get_byte(_storage->buffer);
|
||||
|
||||
if (best_char < 0) {
|
||||
s.buf_sz = 0;
|
||||
lb_len = 0;
|
||||
/* Signal exit */
|
||||
} else {
|
||||
s.buf_sz = s.wind_sz + 1;
|
||||
}
|
||||
s.bufp = s.inp - s.buf_sz;
|
||||
}
|
||||
};
|
||||
|
||||
static void find_better_match(const uint32_t best_off[MaxMatchByLengthLen], uint32_t& lb_len, uint32_t& lb_off) {
|
||||
if (lb_len <= M2MinLen || lb_off <= M2MaxOffset)
|
||||
return;
|
||||
if (lb_off > M2MaxOffset && lb_len >= M2MinLen + 1 && lb_len <= M2MaxLen + 1 &&
|
||||
best_off[lb_len - 1] != 0 && best_off[lb_len - 1] <= M2MaxOffset) {
|
||||
lb_len -= 1;
|
||||
lb_off = best_off[lb_len];
|
||||
} else if (lb_off > M3MaxOffset && lb_len >= M4MaxLen + 1 && lb_len <= M2MaxLen + 2 &&
|
||||
best_off[lb_len - 2] && best_off[lb_len] <= M2MaxOffset) {
|
||||
lb_len -= 2;
|
||||
lb_off = best_off[lb_len];
|
||||
} else if (lb_off > M3MaxOffset && lb_len >= M4MaxLen + 1 && lb_len <= M3MaxLen + 1 &&
|
||||
best_off[lb_len - 1] != 0 && best_off[lb_len - 2] <= M3MaxOffset) {
|
||||
lb_len -= 1;
|
||||
lb_off = best_off[lb_len];
|
||||
}
|
||||
}
|
||||
|
||||
static EResult encode_literal_run(uint8_t*& outp, const uint8_t* outp_end, const uint8_t* dst, std::size_t& dst_size,
|
||||
const uint8_t* lit_ptr, uint32_t lit_len) {
|
||||
if (outp == dst && lit_len <= 238) {
|
||||
NEEDS_OUT(1);
|
||||
*outp++ = uint8_t(17 + lit_len);
|
||||
} else if (lit_len <= 3) {
|
||||
outp[-2] = uint8_t(outp[-2] | lit_len);
|
||||
} else if (lit_len <= 18) {
|
||||
NEEDS_OUT(1);
|
||||
*outp++ = uint8_t(lit_len - 3);
|
||||
} else {
|
||||
NEEDS_OUT((lit_len - 18) / 255 + 2);
|
||||
*outp++ = 0;
|
||||
WRITE_ZERO_BYTE_LENGTH(lit_len - 18);
|
||||
}
|
||||
NEEDS_OUT(lit_len);
|
||||
outp = std::copy_n(lit_ptr, lit_len, outp);
|
||||
return EResult::Success;
|
||||
}
|
||||
|
||||
static EResult encode_lookback_match(uint8_t*& outp, const uint8_t* outp_end, const uint8_t* dst, std::size_t& dst_size,
|
||||
uint32_t lb_len, uint32_t lb_off, uint32_t last_lit_len) {
|
||||
if (lb_len == 2) {
|
||||
lb_off -= 1;
|
||||
NEEDS_OUT(2);
|
||||
*outp++ = uint8_t(M1Marker | ((lb_off & 0x3) << 2));
|
||||
*outp++ = uint8_t(lb_off >> 2);
|
||||
} else if (lb_len <= M2MaxLen && lb_off <= M2MaxOffset) {
|
||||
lb_off -= 1;
|
||||
NEEDS_OUT(2);
|
||||
*outp++ = uint8_t((lb_len - 1) << 5 | ((lb_off & 0x7) << 2));
|
||||
*outp++ = uint8_t(lb_off >> 3);
|
||||
} else if (lb_len == M2MinLen && lb_off <= M1MaxOffset + M2MaxOffset && last_lit_len >= 4) {
|
||||
lb_off -= 1 + M2MaxOffset;
|
||||
NEEDS_OUT(2);
|
||||
*outp++ = uint8_t(M1Marker | ((lb_off & 0x3) << 2));
|
||||
*outp++ = uint8_t(lb_off >> 2);
|
||||
} else if (lb_off <= M3MaxOffset) {
|
||||
lb_off -= 1;
|
||||
if (lb_len <= M3MaxLen) {
|
||||
NEEDS_OUT(1);
|
||||
*outp++ = uint8_t(M3Marker | (lb_len - 2));
|
||||
} else {
|
||||
lb_len -= M3MaxLen;
|
||||
NEEDS_OUT(lb_len / 255 + 2);
|
||||
*outp++ = uint8_t(M3Marker);
|
||||
WRITE_ZERO_BYTE_LENGTH(lb_len);
|
||||
}
|
||||
NEEDS_OUT(2);
|
||||
*outp++ = uint8_t(lb_off << 2);
|
||||
*outp++ = uint8_t(lb_off >> 6);
|
||||
} else {
|
||||
lb_off -= 0x4000;
|
||||
if (lb_len <= M4MaxLen) {
|
||||
NEEDS_OUT(1);
|
||||
*outp++ = uint8_t(M4Marker | ((lb_off & 0x4000) >> 11) | (lb_len - 2));
|
||||
} else {
|
||||
lb_len -= M4MaxLen;
|
||||
NEEDS_OUT(lb_len / 255 + 2);
|
||||
*outp++ = uint8_t(M4Marker | ((lb_off & 0x4000) >> 11));
|
||||
WRITE_ZERO_BYTE_LENGTH(lb_len);
|
||||
}
|
||||
NEEDS_OUT(2);
|
||||
*outp++ = uint8_t(lb_off << 2);
|
||||
*outp++ = uint8_t(lb_off >> 6);
|
||||
}
|
||||
return EResult::Success;
|
||||
}
|
||||
|
||||
EResult compress(const uint8_t* src, std::size_t src_size,
|
||||
uint8_t* dst, std::size_t init_dst_size,
|
||||
std::size_t& dst_size, DictBase& dict) {
|
||||
EResult err;
|
||||
State s;
|
||||
auto& d = static_cast<DictImpl&>(dict);
|
||||
dst_size = init_dst_size;
|
||||
uint8_t* outp = dst;
|
||||
uint8_t* outp_end = dst + dst_size;
|
||||
uint32_t lit_len = 0;
|
||||
uint32_t lb_off, lb_len;
|
||||
uint32_t best_off[MaxMatchByLengthLen];
|
||||
d.init(s, src, src_size);
|
||||
const uint8_t* lit_ptr = s.inp;
|
||||
d.advance(s, lb_off, lb_len, best_off, false);
|
||||
while (s.buf_sz > 0) {
|
||||
if (lit_len == 0)
|
||||
lit_ptr = s.bufp;
|
||||
if (lb_len < 2 || (lb_len == 2 && (lb_off > M1MaxOffset || lit_len == 0 || lit_len >= 4)) ||
|
||||
(lb_len == 2 && outp == dst) || (outp == dst && lit_len == 0)) {
|
||||
lb_len = 0;
|
||||
} else if (lb_len == M2MinLen && lb_off > M1MaxOffset + M2MaxOffset && lit_len >= 4) {
|
||||
lb_len = 0;
|
||||
}
|
||||
if (lb_len == 0) {
|
||||
++lit_len;
|
||||
d.advance(s, lb_off, lb_len, best_off, false);
|
||||
continue;
|
||||
}
|
||||
find_better_match(best_off, lb_len, lb_off);
|
||||
if ((err = encode_literal_run(outp, outp_end, dst, dst_size, lit_ptr, lit_len)) < EResult::Success)
|
||||
return err;
|
||||
if ((err = encode_lookback_match(outp, outp_end, dst, dst_size, lb_len, lb_off, lit_len)) < EResult::Success)
|
||||
return err;
|
||||
lit_len = 0;
|
||||
d.advance(s, lb_off, lb_len, best_off, true);
|
||||
}
|
||||
if ((err = encode_literal_run(outp, outp_end, dst, dst_size, lit_ptr, lit_len)) < EResult::Success)
|
||||
return err;
|
||||
|
||||
/* Terminating M4 */
|
||||
NEEDS_OUT(3);
|
||||
*outp++ = M4Marker | 1;
|
||||
*outp++ = 0;
|
||||
*outp++ = 0;
|
||||
|
||||
dst_size = outp - dst;
|
||||
return EResult::Success;
|
||||
}
|
||||
|
||||
}
|
||||
79
lzokay.hpp
Normal file
@ -0,0 +1,79 @@
|
||||
#pragma once
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
|
||||
namespace lzokay {
|
||||
|
||||
enum class EResult {
|
||||
LookbehindOverrun = -4,
|
||||
OutputOverrun = -3,
|
||||
InputOverrun = -2,
|
||||
Error = -1,
|
||||
Success = 0,
|
||||
InputNotConsumed = 1,
|
||||
};
|
||||
|
||||
class DictBase {
|
||||
protected:
|
||||
static constexpr uint32_t HashSize = 0x4000;
|
||||
static constexpr uint32_t MaxDist = 0xbfff;
|
||||
static constexpr uint32_t MaxMatchLen = 0x800;
|
||||
static constexpr uint32_t BufSize = MaxDist + MaxMatchLen;
|
||||
|
||||
/* List encoding of previous 3-byte data matches */
|
||||
struct Match3 {
|
||||
uint16_t head[HashSize]; /* key -> chain-head-pos */
|
||||
uint16_t chain_sz[HashSize]; /* key -> chain-size */
|
||||
uint16_t chain[BufSize]; /* chain-pos -> next-chain-pos */
|
||||
uint16_t best_len[BufSize]; /* chain-pos -> best-match-length */
|
||||
};
|
||||
/* Encoding of 2-byte data matches */
|
||||
struct Match2 {
|
||||
uint16_t head[1 << 16]; /* 2-byte-data -> head-pos */
|
||||
};
|
||||
|
||||
struct Data {
|
||||
Match3 match3;
|
||||
Match2 match2;
|
||||
|
||||
/* Circular buffer caching enough data to access the maximum lookback
|
||||
* distance of 48K + maximum match length of 2K. An additional 2K is
|
||||
* allocated so the start of the buffer may be replicated at the end,
|
||||
* therefore providing efficient circular access.
|
||||
*/
|
||||
uint8_t buffer[BufSize + MaxMatchLen];
|
||||
};
|
||||
using storage_type = Data;
|
||||
storage_type* _storage;
|
||||
DictBase() = default;
|
||||
friend struct State;
|
||||
friend EResult compress(const uint8_t* src, std::size_t src_size,
|
||||
uint8_t* dst, std::size_t& dst_size, DictBase& dict);
|
||||
};
|
||||
template <template<typename> class _Alloc = std::allocator>
|
||||
class Dict : public DictBase {
|
||||
_Alloc<DictBase::storage_type> _allocator;
|
||||
public:
|
||||
Dict() { _storage = _allocator.allocate(1); }
|
||||
~Dict() { _allocator.deallocate(_storage, 1); }
|
||||
};
|
||||
|
||||
EResult decompress(const uint8_t* src, std::size_t src_size,
|
||||
uint8_t* dst, std::size_t dst_size,
|
||||
std::size_t& out_size);
|
||||
EResult compress(const uint8_t* src, std::size_t src_size,
|
||||
uint8_t* dst, std::size_t dst_size,
|
||||
std::size_t& out_size, DictBase& dict);
|
||||
inline EResult compress(const uint8_t* src, std::size_t src_size,
|
||||
uint8_t* dst, std::size_t dst_size,
|
||||
std::size_t& out_size) {
|
||||
Dict<> dict;
|
||||
return compress(src, src_size, dst, dst_size, out_size, dict);
|
||||
}
|
||||
|
||||
constexpr std::size_t compress_worst_size(std::size_t s) {
|
||||
return s + s / 16 + 64 + 3;
|
||||
}
|
||||
|
||||
}
|
||||
120
lzx.h
Normal file
@ -0,0 +1,120 @@
|
||||
#ifndef LZX_H
|
||||
#define LZX_H
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QDebug>
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
namespace LZX {
|
||||
|
||||
/*!
|
||||
* \brief Decompresses LZX-compressed data.
|
||||
*
|
||||
* This function decodes a compressed QByteArray until there are no more
|
||||
* bits available. (In a real LZX stream there is an end-of-stream marker;
|
||||
* here we simply stop if a required field cannot be read.)
|
||||
*
|
||||
* \param compressedData The input LZX–compressed data.
|
||||
* \param windowBits The log₂ of the sliding window size (default 15 → 32K).
|
||||
* \return A QByteArray containing the decompressed data.
|
||||
*/
|
||||
static QByteArray DecompressLZX(const QByteArray &compressedData, uint32_t windowBits = 15)
|
||||
{
|
||||
if (compressedData.isEmpty())
|
||||
return QByteArray();
|
||||
|
||||
// Calculate sliding window size.
|
||||
const uint32_t windowSize = 1u << windowBits;
|
||||
std::vector<uint8_t> window(windowSize, 0);
|
||||
uint32_t windowPos = 0;
|
||||
|
||||
// Use a dynamic output buffer.
|
||||
QByteArray outArray;
|
||||
// Reserve an initial capacity.
|
||||
outArray.reserve(1024);
|
||||
|
||||
// --- Bitstream state ---
|
||||
const uint8_t *inData = reinterpret_cast<const uint8_t*>(compressedData.constData());
|
||||
size_t inSize = compressedData.size();
|
||||
size_t inPos = 0;
|
||||
uint32_t bitBuffer = 0;
|
||||
int bitsInBuffer = 0;
|
||||
|
||||
// Lambda: Ensure at least 'count' bits are available.
|
||||
auto ensureBits = [&](int count) -> bool {
|
||||
while (bitsInBuffer < count) {
|
||||
if (inPos < inSize) {
|
||||
bitBuffer = (bitBuffer << 8) | inData[inPos++];
|
||||
bitsInBuffer += 8;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
// Lambda: Get (and remove) 'count' bits from the bit buffer.
|
||||
auto getBits = [&](int count) -> uint32_t {
|
||||
if (!ensureBits(count))
|
||||
return 0;
|
||||
uint32_t result = (bitBuffer >> (bitsInBuffer - count)) & ((1u << count) - 1);
|
||||
bitsInBuffer -= count;
|
||||
return result;
|
||||
};
|
||||
|
||||
// --- Main decompression loop ---
|
||||
// In this simplified placeholder format:
|
||||
// - A flag bit of 1 means a literal byte follows (8 bits).
|
||||
// - A flag bit of 0 means a match follows: first 4 bits for match length (plus base 2)
|
||||
// then windowBits bits for the match offset (relative to the current sliding window).
|
||||
while (true) {
|
||||
// Try to read a flag bit; if not available, we assume the stream is complete.
|
||||
if (!ensureBits(1))
|
||||
break;
|
||||
uint32_t flag = getBits(1);
|
||||
if (flag == 1) {
|
||||
// Literal: next 8 bits form a literal byte.
|
||||
if (!ensureBits(8)) {
|
||||
qWarning() << "Unexpected end of input while reading literal.";
|
||||
break;
|
||||
}
|
||||
uint8_t literal = static_cast<uint8_t>(getBits(8));
|
||||
outArray.append(static_cast<char>(literal));
|
||||
// Update the sliding window.
|
||||
window[windowPos] = literal;
|
||||
windowPos = (windowPos + 1) % windowSize;
|
||||
} else {
|
||||
// Match: first read a 4-bit match length (with a base of 2).
|
||||
if (!ensureBits(4)) {
|
||||
qWarning() << "Unexpected end of input while reading match length.";
|
||||
break;
|
||||
}
|
||||
uint32_t matchLength = getBits(4) + 2;
|
||||
// Then read the match offset (fixed number of bits equals windowBits).
|
||||
if (!ensureBits(windowBits)) {
|
||||
qWarning() << "Unexpected end of input while reading match offset.";
|
||||
break;
|
||||
}
|
||||
uint32_t matchOffset = getBits(windowBits);
|
||||
// Compute the source position in the sliding window.
|
||||
uint32_t copyPos = (windowPos + windowSize - matchOffset) % windowSize;
|
||||
// Copy matchLength bytes from the sliding window.
|
||||
for (uint32_t i = 0; i < matchLength; i++) {
|
||||
uint8_t byte = window[(copyPos + i) % windowSize];
|
||||
outArray.append(static_cast<char>(byte));
|
||||
// Update the sliding window with the decompressed byte.
|
||||
window[windowPos] = byte;
|
||||
windowPos = (windowPos + 1) % windowSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return outArray;
|
||||
}
|
||||
|
||||
} // namespace LZX
|
||||
|
||||
#endif // LZX_H
|
||||
762
mainwindow.cpp
@ -1,25 +1,254 @@
|
||||
#include "mainwindow.h"
|
||||
#include "aboutdialog.h"
|
||||
#include "fastfile.h"
|
||||
#include "qheaderview.h"
|
||||
#include "techsetviewer.h"
|
||||
#include "ui_mainwindow.h"
|
||||
#include "compressor.h"
|
||||
#include "dds_structs.h"
|
||||
#include "iwifile.h"
|
||||
#include "ddsfile.h"
|
||||
|
||||
#include <qmath.h>
|
||||
|
||||
#include "DevILSDK/include/IL/il.h"
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
, ui(new Ui::MainWindow) {
|
||||
: QMainWindow(parent), ui(new Ui::MainWindow) {
|
||||
ui->setupUi(this);
|
||||
|
||||
setAcceptDrops(true);
|
||||
|
||||
mTypeMap = QMap<QString, int>();
|
||||
mTypeOrder = QStringList();
|
||||
mRawFileMap = QMap<QString, QString>();
|
||||
mTreeMap = QMap<QString, QTreeWidgetItem*>();
|
||||
mImageMap = QMap<QString, Image>();
|
||||
mTreeMap = QMap<QString, QTreeWidgetItem *>();
|
||||
mStrTableMap = QMap<QString, QVector<QPair<QString, QString>>>();
|
||||
mBSPVersion = 0;
|
||||
mDiskLumpCount = 0;
|
||||
mDiskLumpOrder = QVector<quint32>();
|
||||
mLumps = QMap<quint32, Lump>();
|
||||
mTreeWidget = new QTreeWidget();
|
||||
mRootItem = mTreeWidget->invisibleRootItem();
|
||||
mScriptEditor = new QPlainTextEdit();
|
||||
mModelViewer = new ModelViewer();
|
||||
mTreeWidget = new XTreeWidget(this);
|
||||
|
||||
//ModelViewer *mModelViewer = new ModelViewer(container);
|
||||
//mModelViewer->setAcceptDrops(false);
|
||||
|
||||
ui->tabWidget->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(ui->tabWidget, &QTabWidget::customContextMenuRequested, this, [this](const QPoint &pos) {
|
||||
if (pos.isNull())
|
||||
return;
|
||||
|
||||
int tabIndex = ui->tabWidget->tabBar()->tabAt(pos);
|
||||
QMenu *contextMenu = new QMenu(this);
|
||||
|
||||
QAction *closeAction = new QAction("Close");
|
||||
contextMenu->addAction(closeAction);
|
||||
connect(closeAction, &QAction::triggered, this, [this, &tabIndex](bool checked) {
|
||||
Q_UNUSED(checked);
|
||||
|
||||
ui->tabWidget->removeTab(tabIndex);
|
||||
});
|
||||
|
||||
QMenu *closeMultipleAction = new QMenu("Close Multiple Tabs");
|
||||
|
||||
QAction *closeAllAction = new QAction("Close All");
|
||||
closeMultipleAction->addAction(closeAllAction);
|
||||
connect(closeAllAction, &QAction::triggered, this, [this](bool checked) {
|
||||
Q_UNUSED(checked);
|
||||
|
||||
ui->tabWidget->clear();
|
||||
});
|
||||
|
||||
QAction *closeAllButAction = new QAction("Close All BUT This");
|
||||
closeMultipleAction->addAction(closeAllButAction);
|
||||
connect(closeAllButAction, &QAction::triggered, this, [this, &tabIndex](bool checked) {
|
||||
Q_UNUSED(checked);
|
||||
|
||||
for (int i = 0; i < ui->tabWidget->count(); i++) {
|
||||
if (i != tabIndex) {
|
||||
ui->tabWidget->removeTab(i);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
QAction *closeLeftAction = new QAction("Close All to the Left");
|
||||
closeMultipleAction->addAction(closeLeftAction);
|
||||
connect(closeLeftAction, &QAction::triggered, this, [this, &tabIndex](bool checked) {
|
||||
Q_UNUSED(checked);
|
||||
|
||||
for (int i = 0; i < tabIndex; i++) {
|
||||
ui->tabWidget->removeTab(i);
|
||||
}
|
||||
});
|
||||
|
||||
QAction *closeRightAction = new QAction("Close All to the Right");
|
||||
closeMultipleAction->addAction(closeRightAction);
|
||||
connect(closeRightAction, &QAction::triggered, this, [this, &tabIndex](bool checked) {
|
||||
Q_UNUSED(checked);
|
||||
|
||||
for (int i = tabIndex + 1; i < ui->tabWidget->count(); i++) {
|
||||
ui->tabWidget->removeTab(i);
|
||||
}
|
||||
});
|
||||
|
||||
contextMenu->addMenu(closeMultipleAction);
|
||||
|
||||
QPoint pt(pos);
|
||||
contextMenu->exec(ui->tabWidget->mapToGlobal(pt));
|
||||
|
||||
delete contextMenu;
|
||||
});
|
||||
|
||||
connect(ui->tabWidget, &QTabWidget::tabCloseRequested, this, [this](int index) {
|
||||
ui->tabWidget->removeTab(index);
|
||||
});
|
||||
|
||||
connect(mTreeWidget, &XTreeWidget::RawFileSelected, this, [this](std::shared_ptr<RawFile> rawFile) {
|
||||
QPlainTextEdit *scriptEditor = new QPlainTextEdit(this);
|
||||
scriptEditor->setAcceptDrops(false);
|
||||
|
||||
if (rawFile->contents.isEmpty()) {
|
||||
scriptEditor->setPlainText("EMPTY");
|
||||
} else {
|
||||
scriptEditor->setPlainText(rawFile->contents);
|
||||
}
|
||||
|
||||
QString fileStem = rawFile->path.split('/').last();
|
||||
for (int i = 0; i < ui->tabWidget->count(); i++) {
|
||||
if (ui->tabWidget->tabText(i) == fileStem) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ui->tabWidget->addTab(scriptEditor, fileStem);
|
||||
ui->tabWidget->setTabIcon(ui->tabWidget->count() - 1, QIcon(":/icons/icons/Icon_GSCFile.png"));
|
||||
ui->tabWidget->setCurrentIndex(ui->tabWidget->count() - 1);
|
||||
});
|
||||
|
||||
connect(mTreeWidget, &XTreeWidget::ImageSelected, this, [this](std::shared_ptr<Image> image) {
|
||||
ImageWidget *mImageWidget = new ImageWidget(this);
|
||||
mImageWidget->setAcceptDrops(false);
|
||||
mImageWidget->SetImage(image);
|
||||
|
||||
QString fileStem = image->materialName;
|
||||
for (int i = 0; i < ui->tabWidget->count(); i++) {
|
||||
if (ui->tabWidget->tabText(i) == fileStem) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ui->tabWidget->addTab(mImageWidget, fileStem);
|
||||
ui->tabWidget->setTabIcon(ui->tabWidget->count() - 1, QIcon(":/icons/icons/Icon_Image.png"));
|
||||
ui->tabWidget->setCurrentIndex(ui->tabWidget->count() - 1);
|
||||
});
|
||||
|
||||
connect(mTreeWidget, &XTreeWidget::MenuSelected, this, [this](std::shared_ptr<Menu> menu) {
|
||||
Q_UNUSED(menu);
|
||||
});
|
||||
|
||||
connect(mTreeWidget, &XTreeWidget::DDSFileSelected, this, [this](std::shared_ptr<DDSFile> ddsFile) {
|
||||
DDSViewer *ddsViewer = new DDSViewer(this);
|
||||
ddsViewer->setAcceptDrops(false);
|
||||
ddsViewer->SetDDSFile(ddsFile);
|
||||
|
||||
QString fileStem = ddsFile->fileStem + ".dds";
|
||||
for (int i = 0; i < ui->tabWidget->count(); i++) {
|
||||
if (ui->tabWidget->tabText(i) == fileStem) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ui->tabWidget->addTab(ddsViewer, fileStem);
|
||||
ui->tabWidget->setTabIcon(ui->tabWidget->count() - 1, QIcon(":/icons/icons/Icon_DDSFile.png"));
|
||||
ui->tabWidget->setCurrentIndex(ui->tabWidget->count() - 1);
|
||||
});
|
||||
|
||||
connect(mTreeWidget, &XTreeWidget::IWIFileSelected, this, [this](std::shared_ptr<IWIFile> iwiFile) {
|
||||
IWIViewer *iwiViewer = new IWIViewer(this);
|
||||
iwiViewer->setAcceptDrops(false);
|
||||
iwiViewer->SetIWIFile(iwiFile);
|
||||
|
||||
QString fileStem = iwiFile->fileStem + ".iwi";
|
||||
for (int i = 0; i < ui->tabWidget->count(); i++) {
|
||||
if (ui->tabWidget->tabText(i) == fileStem) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ui->tabWidget->addTab(iwiViewer, fileStem);
|
||||
ui->tabWidget->setTabIcon(ui->tabWidget->count() - 1, QIcon(":/icons/icons/Icon_IWIFile.png"));
|
||||
ui->tabWidget->setCurrentIndex(ui->tabWidget->count() - 1);
|
||||
});
|
||||
|
||||
connect(mTreeWidget, &XTreeWidget::FastFileSelected, this, [this](std::shared_ptr<FastFile> aFastFile) {
|
||||
FastFileViewer *fastFileViewer = new FastFileViewer(this);
|
||||
fastFileViewer->setAcceptDrops(false);
|
||||
fastFileViewer->SetFastFile(aFastFile);
|
||||
|
||||
QString fileStem = aFastFile->GetFileStem();
|
||||
for (int i = 0; i < ui->tabWidget->count(); i++) {
|
||||
if (ui->tabWidget->tabText(i) == fileStem) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ui->tabWidget->addTab(fastFileViewer, fileStem);
|
||||
ui->tabWidget->setTabIcon(ui->tabWidget->count() - 1, QIcon(":/icons/icons/Icon_FastFile.png"));
|
||||
ui->tabWidget->setCurrentIndex(ui->tabWidget->count() - 1);
|
||||
});
|
||||
|
||||
connect(mTreeWidget, &XTreeWidget::ZoneFileSelected, this, [this](std::shared_ptr<ZoneFile> aZoneFile) {
|
||||
ZoneFileViewer *zoneFileViewer = new ZoneFileViewer(this);
|
||||
zoneFileViewer->setAcceptDrops(false);
|
||||
zoneFileViewer->SetZoneFile(aZoneFile);
|
||||
|
||||
QString fileStem = aZoneFile->GetFileStem();
|
||||
for (int i = 0; i < ui->tabWidget->count(); i++) {
|
||||
if (ui->tabWidget->tabText(i) == fileStem) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ui->tabWidget->addTab(zoneFileViewer, fileStem);
|
||||
ui->tabWidget->setTabIcon(ui->tabWidget->count() - 1, QIcon(":/icons/icons/Icon_ZoneFile.png"));
|
||||
ui->tabWidget->setCurrentIndex(ui->tabWidget->count() - 1);
|
||||
});
|
||||
|
||||
connect(mTreeWidget, &XTreeWidget::LocalStringSelected, this, [this](std::shared_ptr<ZoneFile> aZoneFile) {
|
||||
LocalStringViewer *localStrViewer = new LocalStringViewer(this);
|
||||
localStrViewer->setAcceptDrops(false);
|
||||
localStrViewer->SetZoneFile(aZoneFile);
|
||||
|
||||
QString fileStem = aZoneFile->GetFileStem() + ".str";
|
||||
for (int i = 0; i < ui->tabWidget->count(); i++) {
|
||||
if (ui->tabWidget->tabText(i) == fileStem) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ui->tabWidget->addTab(localStrViewer, fileStem);
|
||||
ui->tabWidget->setTabIcon(ui->tabWidget->count() - 1, QIcon(":/icons/icons/Icon_String.png"));
|
||||
ui->tabWidget->setCurrentIndex(ui->tabWidget->count() - 1);
|
||||
});
|
||||
|
||||
connect(mTreeWidget, &XTreeWidget::TechSetSelected, this, [this](std::shared_ptr<TechSet> aTechSet) {
|
||||
|
||||
TechSetViewer *techSetViewer = new TechSetViewer(this);
|
||||
techSetViewer->setAcceptDrops(false);
|
||||
techSetViewer->SetTechSet(aTechSet);
|
||||
|
||||
QString fileStem = aTechSet->name;
|
||||
for (int i = 0; i < ui->tabWidget->count(); i++) {
|
||||
if (ui->tabWidget->tabText(i) == fileStem) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ui->tabWidget->addTab(techSetViewer, aTechSet->name);
|
||||
ui->tabWidget->setTabIcon(ui->tabWidget->count() - 1, QIcon(":/icons/icons/Icon_TechSetFile.png"));
|
||||
ui->tabWidget->setCurrentIndex(ui->tabWidget->count() - 1);
|
||||
});
|
||||
|
||||
// Connect Help > About dialog
|
||||
connect(ui->actionAbout, &QAction::triggered, this, [this](bool checked) {
|
||||
@ -31,35 +260,46 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
delete aboutDialog;
|
||||
});
|
||||
|
||||
connect(ui->actionOpen_Fast_File, &QAction::triggered, this, [this](bool checked) {
|
||||
connect(ui->actionOpen_Fast_File, &QAction::triggered, this,
|
||||
[this](bool checked) {
|
||||
Q_UNUSED(checked);
|
||||
OpenFastFile();
|
||||
});
|
||||
connect(ui->actionOpen_Zone_File, &QAction::triggered, this, [this](bool checked) {
|
||||
connect(ui->actionOpen_Zone_File, &QAction::triggered, this,
|
||||
[this](bool checked) {
|
||||
Q_UNUSED(checked);
|
||||
OpenZoneFile();
|
||||
});
|
||||
|
||||
|
||||
QDockWidget *treeDockWidget = new QDockWidget(this);
|
||||
mTreeWidget->header()->hide();
|
||||
treeDockWidget->setWidget(mTreeWidget);
|
||||
addDockWidget(Qt::LeftDockWidgetArea, treeDockWidget);
|
||||
|
||||
setCentralWidget(mScriptEditor);
|
||||
ui->toolBar->addAction(ui->actionNew_Fast_File);
|
||||
ui->toolBar->addAction(ui->actionNew_Zone_File);
|
||||
ui->toolBar->addAction(ui->actionOpen_Fast_File);
|
||||
ui->toolBar->addAction(ui->actionOpen_Zone_File);
|
||||
ui->toolBar->addAction(ui->actionOpen_Folder);
|
||||
ui->toolBar->addAction(ui->actionSave);
|
||||
ui->toolBar->addSeparator();
|
||||
ui->toolBar->addAction(ui->actionCut);
|
||||
ui->toolBar->addAction(ui->actionCopy);
|
||||
ui->toolBar->addAction(ui->actionPaste);
|
||||
ui->toolBar->addSeparator();
|
||||
|
||||
LoadFile_D3DBSP(":/d3dbsp/data/d3dbsp/barebones.d3dbsp");
|
||||
ui->toolBar->addSeparator();
|
||||
|
||||
ui->toolBar->addSeparator();
|
||||
ui->toolBar->addAction(ui->actionFind_2);
|
||||
|
||||
Reset();
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow() {
|
||||
delete ui;
|
||||
}
|
||||
MainWindow::~MainWindow() { delete ui; }
|
||||
|
||||
void MainWindow::Reset() {
|
||||
// Clear data tree
|
||||
mTreeWidget->clear();
|
||||
// mTreeWidget->clear();
|
||||
|
||||
// Reset class vars
|
||||
mTypeMap.clear();
|
||||
@ -78,66 +318,15 @@ void MainWindow::Reset() {
|
||||
and opens the selected file.
|
||||
*/
|
||||
bool MainWindow::OpenFastFile(const QString aFastFilePath) {
|
||||
if (aFastFilePath.isEmpty()) { return false; }
|
||||
|
||||
// Reset dialog before opening new file
|
||||
Reset();
|
||||
|
||||
// Add fast file as tree widget root
|
||||
const QString fastFileStem = aFastFilePath.split('/').last();
|
||||
QTreeWidgetItem *fastFileItem = new QTreeWidgetItem(mRootItem);
|
||||
fastFileItem->setText(0, fastFileStem);
|
||||
mRootItem = fastFileItem;
|
||||
|
||||
// Check fastfile can be read
|
||||
QFile *fastFileObj = new QFile(aFastFilePath);
|
||||
if (!fastFileObj->open(QIODevice::ReadOnly)) {
|
||||
QMessageBox::warning(this, "Warning!", QString("Failed to open FastFile: %1!")
|
||||
.arg(aFastFilePath));
|
||||
FastFile fastFile;
|
||||
if (!fastFile.Load(aFastFilePath)) {
|
||||
qDebug() << "Error: Failed to load fast file!";
|
||||
return false;
|
||||
}
|
||||
|
||||
// Decompress fastfile and close
|
||||
const QByteArray fastFileData = fastFileObj->readAll();
|
||||
const QByteArray decompressedData = Compressor::DecompressZLIB(fastFileData);
|
||||
|
||||
// Open zone file as little endian stream
|
||||
QDataStream fastFileStream(fastFileData);
|
||||
fastFileStream.setByteOrder(QDataStream::LittleEndian);
|
||||
|
||||
// Parse data from fast file header
|
||||
FastFile fastFile = FastFileParser::ParseFFHeader(&fastFileStream);
|
||||
|
||||
QTreeWidgetItem *metaDataItem = new QTreeWidgetItem(mRootItem);
|
||||
metaDataItem->setText(0, "Metadata");
|
||||
|
||||
QTreeWidgetItem *companyItem = new QTreeWidgetItem(metaDataItem);
|
||||
companyItem->setText(0, "Company: " + Utils::CompanyEnumToStr(fastFile.company));
|
||||
QTreeWidgetItem *fileTypeItem = new QTreeWidgetItem(metaDataItem);
|
||||
fileTypeItem->setText(0, "File Type: " + Utils::FileTypeEnumToStr(fastFile.fileType));
|
||||
QTreeWidgetItem *signageItem = new QTreeWidgetItem(metaDataItem);
|
||||
signageItem->setText(0, "Signage: " + Utils::SignageEnumToStr(fastFile.signage));
|
||||
QTreeWidgetItem *magicItem = new QTreeWidgetItem(metaDataItem);
|
||||
magicItem->setText(0, "Magic: " + fastFile.magic);
|
||||
QTreeWidgetItem *versionItem = new QTreeWidgetItem(metaDataItem);
|
||||
versionItem->setText(0, "Version: " + QString::number(fastFile.version));
|
||||
|
||||
const QString zoneFilePath = fastFileObj->fileName().replace(".ff", ".zone");
|
||||
fastFileObj->close();
|
||||
|
||||
// Check zone file is writeable
|
||||
QFile *zoneFile = new QFile(zoneFilePath);
|
||||
if (!zoneFile->open(QIODevice::ReadWrite)) {
|
||||
qDebug() << QString("Zone file could not be written to: '%1'").arg(zoneFilePath);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Write zone data
|
||||
zoneFile->write(decompressedData);
|
||||
zoneFile->close();
|
||||
mTreeWidget->AddFastFile(std::make_shared<FastFile>(fastFile));
|
||||
|
||||
// Open zone file after decompressing ff and writing
|
||||
return OpenZoneFile(zoneFilePath);
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -161,133 +350,15 @@ bool MainWindow::OpenFastFile() {
|
||||
Opens a file dialog in the steam folder,
|
||||
and opens the selected file.
|
||||
*/
|
||||
bool MainWindow::OpenZoneFile(const QString aZoneFilePath) {
|
||||
if (aZoneFilePath.isEmpty()) { return false; }
|
||||
bool MainWindow::OpenZoneFile(const QString aZoneFilePath, bool fromFF) {
|
||||
Q_UNUSED(fromFF);
|
||||
|
||||
// Reset dialog before opening new file
|
||||
//Reset();
|
||||
|
||||
//ui->lineEdit_ZoneFile->setText(zoneFilePath);
|
||||
|
||||
const QString zoneFileStem = aZoneFilePath.split('/').last();
|
||||
QTreeWidgetItem *zoneItem = new QTreeWidgetItem(mRootItem);
|
||||
zoneItem->setText(0, zoneFileStem);
|
||||
mRootItem = zoneItem;
|
||||
|
||||
//setWindowTitle(QString("FastFile Wizard - %1").arg(zoneFileStem));
|
||||
|
||||
// Check zone file can be read
|
||||
QFile *zoneFileObj = new QFile(aZoneFilePath);
|
||||
if (!zoneFileObj->open(QIODevice::ReadOnly)) {
|
||||
QMessageBox::warning(this, "Warning!", QString("%1 could not be read!.").arg(aZoneFilePath));
|
||||
ZoneFile zoneFile;
|
||||
if (!zoneFile.Load(aZoneFilePath)) {
|
||||
qDebug() << "Error: Failed to load zone file!";
|
||||
return false;
|
||||
}
|
||||
const QByteArray decompressedData = zoneFileObj->readAll();
|
||||
|
||||
// Open zone file as little endian stream
|
||||
QDataStream zoneFileStream(decompressedData);
|
||||
zoneFileStream.setByteOrder(QDataStream::LittleEndian);
|
||||
|
||||
// Parse data from zone file header
|
||||
ZoneFile zoneFile = ZoneFileParser::ParseZoneHeader(&zoneFileStream);
|
||||
|
||||
if (zoneFile.tagCount) {
|
||||
QTreeWidgetItem *tagsItem = new QTreeWidgetItem(mRootItem);
|
||||
tagsItem->setText(0, QString("Tags [%1]")
|
||||
.arg(zoneFile.tags.length()));
|
||||
foreach (const QString tag, zoneFile.tags) {
|
||||
QTreeWidgetItem *tagItem = new QTreeWidgetItem(tagsItem);
|
||||
tagItem->setText(0, tag);
|
||||
}
|
||||
}
|
||||
|
||||
QTreeWidgetItem *indexRecordsItem = new QTreeWidgetItem(mRootItem);
|
||||
QTreeWidgetItem *assetsItem = new QTreeWidgetItem(mRootItem);
|
||||
|
||||
mRootItem = indexRecordsItem;
|
||||
|
||||
int consecutiveCount = 1;
|
||||
QString lastRecord = "";
|
||||
zoneFile.records = ZoneFileParser::ParseZoneIndex(&zoneFileStream, zoneFile.recordCount);
|
||||
indexRecordsItem->setText(0, QString("Index Records [%1]")
|
||||
.arg(zoneFile.records.length()));
|
||||
|
||||
foreach (const QString record, zoneFile.records) {
|
||||
if (lastRecord.isEmpty()) {
|
||||
lastRecord = record;
|
||||
continue;
|
||||
} else if (lastRecord == record) {
|
||||
consecutiveCount++;
|
||||
continue;
|
||||
}
|
||||
QTreeWidgetItem *recordItem = new QTreeWidgetItem(mRootItem);
|
||||
recordItem->setText(0, QString("%1 [%2]")
|
||||
.arg(Utils::AssetTypeToString(lastRecord))
|
||||
.arg(consecutiveCount));
|
||||
lastRecord = record;
|
||||
consecutiveCount = 1;
|
||||
}
|
||||
|
||||
mRootItem = assetsItem;
|
||||
|
||||
// Parse current and consecutive assets
|
||||
AssetMap assetMap = ZoneFileParser::ParseAssets(&zoneFileStream, zoneFile.records);
|
||||
assetsItem->setText(0, QString("Assets"));
|
||||
|
||||
if (!assetMap.rawFiles.isEmpty()) {
|
||||
QTreeWidgetItem *rawFilesItem = new QTreeWidgetItem(mRootItem);
|
||||
foreach (const RawFile rawFile, assetMap.rawFiles) {
|
||||
QTreeWidgetItem *rawFileItem = new QTreeWidgetItem(rawFilesItem);
|
||||
rawFileItem->setText(0, rawFile.path);
|
||||
}
|
||||
rawFilesItem->setText(0, QString("Raw Files [%1]")
|
||||
.arg(assetMap.rawFiles.length()));
|
||||
}
|
||||
|
||||
if (!assetMap.localStrings.isEmpty()) {
|
||||
QTreeWidgetItem *localStrsItem = new QTreeWidgetItem(mRootItem);
|
||||
foreach (const LocalString localString, assetMap.localStrings) {
|
||||
QTreeWidgetItem *localStrItem = new QTreeWidgetItem(localStrsItem);
|
||||
localStrItem->setText(0, localString.string);
|
||||
}
|
||||
localStrsItem->setText(0, QString("Local Strings [%1]")
|
||||
.arg(assetMap.localStrings.length()));
|
||||
}
|
||||
|
||||
if (!assetMap.stringTables.isEmpty()) {
|
||||
QTreeWidgetItem *strTablesItem = new QTreeWidgetItem(mRootItem);
|
||||
foreach (const StringTable stringTable, assetMap.stringTables) {
|
||||
QTreeWidgetItem *strTableItem = new QTreeWidgetItem(strTablesItem);
|
||||
strTableItem->setText(0, stringTable.name);
|
||||
}
|
||||
strTablesItem->setText(0, QString("String Tables [%1]")
|
||||
.arg(assetMap.stringTables.length()));
|
||||
}
|
||||
|
||||
if (!assetMap.techSets.isEmpty()) {
|
||||
QTreeWidgetItem *techSetsItem = new QTreeWidgetItem(mRootItem);
|
||||
foreach (const TechSet techSet, assetMap.techSets) {
|
||||
QTreeWidgetItem *techSetItem = new QTreeWidgetItem(techSetsItem);
|
||||
techSetItem->setText(0, techSet.name);
|
||||
}
|
||||
techSetsItem->setText(0, QString("Tech Sets [%1]")
|
||||
.arg(assetMap.techSets.length()));
|
||||
}
|
||||
|
||||
if (!assetMap.animations.isEmpty()) {
|
||||
QTreeWidgetItem *animationsItem = new QTreeWidgetItem(mRootItem);
|
||||
animationsItem->setText(0, "Animations");
|
||||
foreach (const Animation animation, assetMap.animations) {
|
||||
QTreeWidgetItem *animationItem = new QTreeWidgetItem(animationsItem);
|
||||
animationItem->setText(0, animation.name);
|
||||
}
|
||||
animationsItem->setText(0, QString("Animations [%1]")
|
||||
.arg(assetMap.animations.length()));
|
||||
}
|
||||
|
||||
// Clean up zone file
|
||||
zoneFileObj->close();
|
||||
delete zoneFileObj;
|
||||
mTreeWidget->AddZoneFile(std::make_shared<ZoneFile>(zoneFile));
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -298,7 +369,6 @@ bool MainWindow::OpenZoneFile() {
|
||||
qDebug() << "Failed to open Zone file!";
|
||||
return false;
|
||||
}
|
||||
mRootItem = mTreeWidget->invisibleRootItem();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -328,7 +398,8 @@ int MainWindow::LoadFile_D3DBSP(const QString aFilePath) {
|
||||
mDiskLumpOrder.resize(mDiskLumpCount);
|
||||
|
||||
// Read Lump Index Entries
|
||||
quint32 lumpOffset = sizeof(quint32) * 3 + sizeof(LumpIndexEntry) * mDiskLumpCount;
|
||||
quint32 lumpOffset =
|
||||
sizeof(quint32) * 3 + sizeof(LumpIndexEntry) * mDiskLumpCount;
|
||||
|
||||
for (quint32 i = 0; i < mDiskLumpCount; i++) {
|
||||
LumpIndexEntry indexEntry;
|
||||
@ -341,7 +412,9 @@ int MainWindow::LoadFile_D3DBSP(const QString aFilePath) {
|
||||
lump.content.resize(indexEntry.length);
|
||||
lump.isEmpty = false;
|
||||
|
||||
qDebug() << "Lump Type:" << Utils::LumpTypeToString((LUMP_TYPE)indexEntry.type) << "Lump Size:" << indexEntry.length;
|
||||
qDebug() << "Lump Type:"
|
||||
<< Utils::LumpTypeToString((LUMP_TYPE)indexEntry.type)
|
||||
<< "Lump Size:" << indexEntry.length;
|
||||
|
||||
// Handle offsets and padding
|
||||
qint64 currentPos = file.pos();
|
||||
@ -355,3 +428,292 @@ int MainWindow::LoadFile_D3DBSP(const QString aFilePath) {
|
||||
return 0; // Success
|
||||
}
|
||||
|
||||
struct Command {
|
||||
quint32 size = 0;
|
||||
bool compressed = false;
|
||||
};
|
||||
quint32 DXT1 = 0x31545844; // 'DXT1'
|
||||
quint32 DXT3 = 0x33545844; // 'DXT3'
|
||||
quint32 DXT5 = 0x35545844; // 'DXT5'
|
||||
|
||||
int MainWindow::LoadFile_IWI(const QString aFilePath) {
|
||||
mTreeWidget->AddIWIFile(std::make_shared<IWIFile>(aFilePath));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int MainWindow::LoadFile_DDSFiles(const QStringList aFilePaths) {
|
||||
for (const QString &filePath : aFilePaths) {
|
||||
if (!filePath.endsWith(".dds", Qt::CaseInsensitive)) {
|
||||
qDebug() << "Error: Invalid filename " << filePath;
|
||||
return -1;
|
||||
}
|
||||
mTreeWidget->AddDDSFile(std::make_shared<DDSFile>(filePath));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int MainWindow::LoadFile_DDS(const QString aFilePath) {
|
||||
if (!aFilePath.endsWith(".dds", Qt::CaseInsensitive)) {
|
||||
qDebug() << "Error: Invalid filename " << aFilePath;
|
||||
return -1;
|
||||
}
|
||||
mTreeWidget->AddDDSFile(std::make_shared<DDSFile>(aFilePath));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int MainWindow::LoadFile_XSUB(const QString aFilePath) {
|
||||
QFile file(aFilePath);
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
qDebug() << "Error: Unable to open file" << aFilePath;
|
||||
return 1; // ERR_FILE_NOT_FOUND
|
||||
}
|
||||
|
||||
QDataStream stream(&file);
|
||||
stream.setByteOrder(QDataStream::LittleEndian);
|
||||
|
||||
QByteArray magic(4, Qt::Uninitialized);
|
||||
stream.readRawData(magic.data(), 4);
|
||||
if (magic != "KAPI") {
|
||||
qDebug() << "Wrong magic, invalid XSUB file!";
|
||||
return -1;
|
||||
}
|
||||
qDebug() << "Magic: " << magic;
|
||||
|
||||
stream.skipRawData(5 * 4);
|
||||
|
||||
quint32 fileSize;
|
||||
stream >> fileSize;
|
||||
qDebug() << "File Size: " << fileSize;
|
||||
|
||||
return 0; // Success
|
||||
}
|
||||
|
||||
int MainWindow::LoadFile_IPAK(const QString aFilePath) {
|
||||
QFile file(aFilePath);
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
qDebug() << "Error: Unable to open file" << aFilePath;
|
||||
return 1; // ERR_FILE_NOT_FOUND
|
||||
}
|
||||
|
||||
QDataStream stream(&file);
|
||||
stream.setByteOrder(QDataStream::BigEndian);
|
||||
|
||||
IPAKHeader header;
|
||||
stream >> header;
|
||||
|
||||
if (header.version == "50000") {
|
||||
if (header.magic == "KAPI") {
|
||||
stream.setByteOrder(QDataStream::LittleEndian);
|
||||
} else if (header.magic == "IPAK") {
|
||||
stream.setByteOrder(QDataStream::BigEndian);
|
||||
} else {
|
||||
qDebug() << "Invalid IPAK file!";
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
qDebug() << "Invalid IPAK file version!";
|
||||
return -1;
|
||||
}
|
||||
|
||||
qDebug() << "IPAK File " << "\n"
|
||||
<< "- Platform: " << header.platform << "\n"
|
||||
<< "- Magic: " << header.magic << "\n"
|
||||
<< "- Size: " << header.size << "\n"
|
||||
<< "- Version: " << header.version << "\n"
|
||||
<< "- Sections: " << header.sectionCount;
|
||||
|
||||
QDir outputFolder = QDir(QDir::currentPath() + "/output");
|
||||
outputFolder.remove(QDir::currentPath() + "/output");
|
||||
outputFolder.mkdir(QDir::currentPath() + "/output");
|
||||
|
||||
QVector<IPAKDataChunkMetaData> metas = QVector<IPAKDataChunkMetaData>();
|
||||
|
||||
QVector<IPAKIndexEntry> entries = QVector<IPAKIndexEntry>();
|
||||
QVector<IPAKSection> sections = QVector<IPAKSection>(header.sectionCount);
|
||||
for (uint i = 0; i < header.sectionCount; i++) {
|
||||
IPAKSection currentSection;
|
||||
stream >> currentSection;
|
||||
sections << currentSection;
|
||||
|
||||
qDebug() << " - IPAK Section " << i + 1 << "\n"
|
||||
<< " - Type: " << currentSection.type << " -> " << currentSection.typeInt << "\n"
|
||||
<< " - Offset: " << currentSection.offset << "\n"
|
||||
<< " - Item (IWI) Count: " << currentSection.itemCount << "\n"
|
||||
<< " - Size: " << currentSection.size;
|
||||
|
||||
qint64 sectionPos = stream.device()->pos();
|
||||
stream.device()->seek(currentSection.offset);
|
||||
|
||||
QString sectionType = currentSection.type;
|
||||
if (sectionType == "Data") {
|
||||
IPAKDataChunkHeader chunkHeader;
|
||||
stream >> chunkHeader;
|
||||
qDebug() << " - Chunk Header\n"
|
||||
<< " - Count: " << chunkHeader.count << "\n"
|
||||
<< " - Offset: " << chunkHeader.offset;
|
||||
|
||||
for (uint j = 0; j < 31; j++) {
|
||||
IPAKDataChunkCommand command;
|
||||
stream >> command;
|
||||
if (!command.size) { continue; }
|
||||
chunkHeader.commands << command;
|
||||
qDebug() << " - Command\n"
|
||||
<< " - Size: " << command.size << "\n"
|
||||
<< " - Compressed: " << command.compressed;
|
||||
|
||||
}
|
||||
for (uint j = 0; j < chunkHeader.count; j++) {
|
||||
auto command = chunkHeader.commands[j];
|
||||
|
||||
qDebug() << "Reading from " << stream.device()->pos();
|
||||
QByteArray data = stream.device()->read(command.size);
|
||||
qDebug() << " to " << stream.device()->pos();
|
||||
|
||||
QString outputFilePath = outputFolder.filePath(QString("%1.iwi").arg(j));
|
||||
if (command.compressed) {
|
||||
data = Compressor::DecompressLZO(data);
|
||||
}
|
||||
QFile outputFile(outputFilePath);
|
||||
if (!outputFile.open(QIODevice::WriteOnly)) {
|
||||
qDebug() << "Failed to extract IPAK file.";
|
||||
}
|
||||
qDebug() << " - File Name: " << outputFile.fileName();
|
||||
outputFile.write(data);
|
||||
outputFile.close();
|
||||
}
|
||||
|
||||
|
||||
qDebug() << stream.device()->pos();
|
||||
stream.skipRawData(sizeof(quint32) * (31 - chunkHeader.count));
|
||||
qDebug() << stream.device()->pos();
|
||||
} else if (sectionType == "Index") {
|
||||
for (uint j = 0; j < currentSection.itemCount; j++) {
|
||||
IPAKIndexEntry entry;
|
||||
stream >> entry;
|
||||
|
||||
if (entry.size == 0) { continue; }
|
||||
|
||||
entries << entry;
|
||||
|
||||
quint64 entryPos = stream.device()->pos();
|
||||
qDebug() << " - Index Entry " << j + 1 << "\n"
|
||||
<< " - Name Hash: " << entry.nameHash << "\n"
|
||||
<< " - Data Hash: " << entry.dataHash << "\n"
|
||||
<< " - Offset: " << entry.offset << "\n"
|
||||
<< " - Size: " << entry.size;
|
||||
|
||||
stream.device()->seek(entry.offset);
|
||||
|
||||
QByteArray sectionData(entry.size, Qt::Uninitialized);
|
||||
stream.readRawData(sectionData.data(), entry.size);
|
||||
|
||||
const QString entryKey = QString::number(entry.nameHash);
|
||||
QFile outputFile(outputFolder.filePath(QString("%1.dds").arg(entryKey)));
|
||||
if (!outputFile.open(QIODevice::WriteOnly)) {
|
||||
qDebug() << "Failed to extract IPAK file.";
|
||||
}
|
||||
qDebug() << " - File Name: " << outputFile.fileName();
|
||||
outputFile.write(sectionData);
|
||||
outputFile.close();
|
||||
|
||||
stream.device()->seek(entryPos);
|
||||
}
|
||||
}
|
||||
stream.device()->seek(sectionPos);
|
||||
qDebug() << stream.device()->pos();
|
||||
}
|
||||
|
||||
return 0; // Success
|
||||
}
|
||||
|
||||
void MainWindow::dragEnterEvent(QDragEnterEvent *event) {
|
||||
const QMimeData *mimeData = event->mimeData();
|
||||
bool goodDrag = true;
|
||||
if (mimeData->hasUrls()) {
|
||||
foreach (const QUrl url, mimeData->urls()) {
|
||||
if (!url.toString().contains(".ff") &&
|
||||
!url.toString().contains(".zone") &&
|
||||
!url.toString().contains(".ipak") &&
|
||||
!url.toString().contains(".d3dbsp") &&
|
||||
!url.toString().contains(".lzoin") &&
|
||||
!url.toString().contains(".xsub") &&
|
||||
!url.toString().contains(".iwi") &&
|
||||
!url.toString().contains(".dds")) {
|
||||
goodDrag = false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
goodDrag = false;
|
||||
}
|
||||
if (goodDrag) {
|
||||
event->acceptProposedAction();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::dragMoveEvent(QDragMoveEvent *event) {
|
||||
Q_UNUSED(event);
|
||||
}
|
||||
|
||||
void MainWindow::dragLeaveEvent(QDragLeaveEvent *event) {
|
||||
Q_UNUSED(event);
|
||||
}
|
||||
|
||||
void MainWindow::dropEvent(QDropEvent *event) {
|
||||
const QMimeData *mimeData = event->mimeData();
|
||||
if (mimeData->hasUrls()) {
|
||||
QStringList ddsPaths = QStringList();
|
||||
foreach (const QUrl url, mimeData->urls()) {
|
||||
const QString urlStr = url.toLocalFile();
|
||||
if (urlStr.contains(".zone")) {
|
||||
OpenZoneFile(urlStr);
|
||||
} else if (urlStr.contains(".ff")) {
|
||||
OpenFastFile(urlStr);
|
||||
} else if (urlStr.contains(".ipak")) {
|
||||
qDebug() << "LoadFile_IPAK Returned: " << LoadFile_IPAK(urlStr);
|
||||
} else if (urlStr.contains(".xsub")) {
|
||||
qDebug() << "LoadFile_XSUB Returned: " << LoadFile_XSUB(urlStr);
|
||||
} else if (urlStr.contains(".iwi")) {
|
||||
qDebug() << "LoadFile_IWI Returned: " << LoadFile_IWI(urlStr);
|
||||
} else if (urlStr.contains(".dds")) {
|
||||
if (mimeData->urls().size() == 1) {
|
||||
qDebug() << "LoadFile_DDS Returned: " << LoadFile_DDS(urlStr);
|
||||
} else {
|
||||
ddsPaths << urlStr;
|
||||
}
|
||||
} else if (urlStr.contains(".d3dbsp")) {
|
||||
LoadFile_D3DBSP(urlStr);
|
||||
} else if (urlStr.contains(".lzoin")) {
|
||||
QFile lzoFile(urlStr);
|
||||
if (!lzoFile.open(QIODevice::ReadOnly)) {
|
||||
qDebug() << "LZO: Failed to read file!";
|
||||
continue;
|
||||
}
|
||||
QByteArray data = Compressor::DecompressLZO(lzoFile.readAll());
|
||||
lzoFile.close();
|
||||
|
||||
if (data.isEmpty()) {
|
||||
qDebug() << "LZO: Decompressor gave empty result!";
|
||||
continue;
|
||||
}
|
||||
|
||||
QFile outputFile(url.toLocalFile().replace("lzoin", "lzoout"));
|
||||
if (!outputFile.open(QIODevice::WriteOnly)) {
|
||||
qDebug() << "LZO: Failed to write file!";
|
||||
continue;
|
||||
}
|
||||
outputFile.write(data);
|
||||
outputFile.close();
|
||||
} else {
|
||||
const QString ext = urlStr.split('.').last();
|
||||
ui->statusBar->showMessage(
|
||||
QString("Can't display dropped file! .%1").arg(ext));
|
||||
}
|
||||
}
|
||||
if (ddsPaths.size() > 1) {
|
||||
qDebug() << "LoadFile_DDSFiles Returned: " << LoadFile_DDSFiles(ddsPaths);
|
||||
}
|
||||
} else {
|
||||
ui->statusBar->showMessage("Can't display dropped data!");
|
||||
}
|
||||
}
|
||||
|
||||
40
mainwindow.h
@ -1,14 +1,18 @@
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include "enums.h"
|
||||
#include "structs.h"
|
||||
#include "utils.h"
|
||||
#include "aboutdialog.h"
|
||||
#include "compression.h"
|
||||
#include "ffparser.h"
|
||||
#include "zfparser.h"
|
||||
#include "d3dbsp_structs.h"
|
||||
#include "asset_structs.h"
|
||||
#include "ddsviewer.h"
|
||||
#include "fastfileviewer.h"
|
||||
#include "ipak_structs.h"
|
||||
#include "iwiviewer.h"
|
||||
#include "localstringviewer.h"
|
||||
#include "modelviewer.h"
|
||||
#include "imagewidget.h"
|
||||
#include "xtreewidget.h"
|
||||
#include "zonefileviewer.h"
|
||||
#include "techsetviewer.h"
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QFileDialog>
|
||||
@ -19,6 +23,7 @@
|
||||
#include <QTreeWidgetItem>
|
||||
#include <QDockWidget>
|
||||
#include <QPlainTextEdit>
|
||||
#include <QMimeData>
|
||||
#include <windows.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
@ -40,10 +45,21 @@ private slots:
|
||||
bool OpenFastFile(const QString aFastFilePath);
|
||||
bool OpenFastFile();
|
||||
|
||||
bool OpenZoneFile(const QString aZoneFilePath);
|
||||
bool OpenZoneFile(const QString aZoneFilePath, bool fromFF = false);
|
||||
bool OpenZoneFile();
|
||||
|
||||
int LoadFile_D3DBSP(const QString aFilePath);
|
||||
int LoadFile_IPAK(const QString aFilePath);
|
||||
int LoadFile_XSUB(const QString aFilePath);
|
||||
int LoadFile_IWI(const QString aFilePath);
|
||||
int LoadFile_DDS(const QString aFilePath);
|
||||
int LoadFile_DDSFiles(const QStringList aFilePaths);
|
||||
|
||||
protected:
|
||||
void dragEnterEvent(QDragEnterEvent *event) override;
|
||||
void dragMoveEvent(QDragMoveEvent *event) override;
|
||||
void dragLeaveEvent(QDragLeaveEvent *event) override;
|
||||
void dropEvent(QDropEvent *event) override;
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
@ -52,18 +68,14 @@ private:
|
||||
quint32 mTagCount;
|
||||
quint32 mRecordCount;
|
||||
QMap<QString, QString> mRawFileMap;
|
||||
QMap<QString, Image> mImageMap;
|
||||
QMap<QString, QTreeWidgetItem*> mTreeMap;
|
||||
QMap<QString, QVector<QPair<QString, QString>>> mStrTableMap;
|
||||
|
||||
QTreeWidget *mTreeWidget;
|
||||
QTreeWidgetItem *mRootItem;
|
||||
QPlainTextEdit *mScriptEditor;
|
||||
ModelViewer *mModelViewer;
|
||||
XTreeWidget *mTreeWidget;
|
||||
|
||||
quint32 mBSPVersion;
|
||||
quint32 mDiskLumpCount;
|
||||
QVector<quint32> mDiskLumpOrder;
|
||||
QMap<quint32, Lump> mLumps;
|
||||
|
||||
};
|
||||
#endif // MAINWINDOW_H
|
||||
|
||||
@ -25,7 +25,21 @@
|
||||
}</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout"/>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>-1</number>
|
||||
</property>
|
||||
<property name="tabsClosable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="movable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menuBar">
|
||||
<property name="geometry">
|
||||
@ -55,16 +69,8 @@
|
||||
<property name="icon">
|
||||
<iconset theme="QIcon::ThemeIcon::FolderNew"/>
|
||||
</property>
|
||||
<addaction name="actionFile"/>
|
||||
<addaction name="actionFolder"/>
|
||||
<addaction name="actionNew_File"/>
|
||||
<addaction name="actionNew_Fast_File_2"/>
|
||||
<addaction name="actionNew_Zone_File_2"/>
|
||||
<addaction name="actionFrom_Clipboard"/>
|
||||
<addaction name="actionMaterial"/>
|
||||
<addaction name="actionSound"/>
|
||||
</widget>
|
||||
<addaction name="actionNew"/>
|
||||
<addaction name="actionNew_File_2"/>
|
||||
<addaction name="actionNew_Fast_File"/>
|
||||
<addaction name="actionNew_Zone_File"/>
|
||||
<addaction name="separator"/>
|
||||
@ -103,7 +109,7 @@
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionFind_2"/>
|
||||
<addaction name="actionEdit_Value"/>
|
||||
<addaction name="actionEdit_as_SNBT"/>
|
||||
<addaction name="actionEdit_as_Hex"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="menuUndo_History"/>
|
||||
<addaction name="menuRedo_History"/>
|
||||
@ -132,7 +138,7 @@
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusBar"/>
|
||||
<action name="actionNew">
|
||||
<action name="actionNew_File_2">
|
||||
<property name="icon">
|
||||
<iconset theme="QIcon::ThemeIcon::DocumentNew"/>
|
||||
</property>
|
||||
@ -294,7 +300,7 @@
|
||||
<string>Edit Value</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionEdit_as_SNBT">
|
||||
<action name="actionEdit_as_Hex">
|
||||
<property name="text">
|
||||
<string>Edit as Hex</string>
|
||||
</property>
|
||||
|
||||
129
structs.h
@ -1,129 +0,0 @@
|
||||
#ifndef STRUCTS_H
|
||||
#define STRUCTS_H
|
||||
|
||||
#include "enums.h"
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QMap>
|
||||
|
||||
// Define Lump Structure
|
||||
struct Lump {
|
||||
QByteArray content;
|
||||
quint32 size = 0;
|
||||
bool isEmpty = true;
|
||||
};
|
||||
|
||||
// Lump Index Entry Structure
|
||||
struct LumpIndexEntry {
|
||||
quint32 type;
|
||||
quint32 length;
|
||||
};
|
||||
|
||||
struct LocalString {
|
||||
QString string;
|
||||
QString alias;
|
||||
};
|
||||
|
||||
struct RawFile {
|
||||
quint32 length;
|
||||
QString path;
|
||||
QString contents;
|
||||
};
|
||||
|
||||
struct TechSet {
|
||||
QString name;
|
||||
};
|
||||
|
||||
struct Animation {
|
||||
quint16 dataByteCount;
|
||||
quint16 dataShortCount;
|
||||
quint16 dataIntCount;
|
||||
quint16 randomDataByteCount;
|
||||
quint16 randomDataIntCount;
|
||||
quint16 numframes;
|
||||
bool isLooped;
|
||||
bool isDelta;
|
||||
quint8 noneRotatedBoneCount;
|
||||
quint8 twoDRotatedBoneCount;
|
||||
quint8 normalRotatedBoneCount;
|
||||
quint8 twoDStaticRotatedBoneCount;
|
||||
quint8 normalStaticRotatedBoneCount;
|
||||
quint8 normalTranslatedBoneCount;
|
||||
quint8 preciseTranslatedBoneCount;
|
||||
quint8 staticTranslatedBoneCount;
|
||||
quint8 noneTranslatedBoneCount;
|
||||
quint8 totalBoneCount;
|
||||
quint8 otherBoneCount1;
|
||||
quint8 otherBoneCount2;
|
||||
quint8 notifyCount;
|
||||
quint8 assetType;
|
||||
bool pad;
|
||||
unsigned int randomDataShortCount;
|
||||
unsigned int indexCount;
|
||||
float frameRate;
|
||||
float frequency;
|
||||
quint32 boneIDsPtr;
|
||||
quint32 dataBytePtr;
|
||||
quint32 dataShortPtr;
|
||||
quint32 dataIntPtr;
|
||||
quint32 randomDataShortPtr;
|
||||
quint32 randomDataBytePtr;
|
||||
quint32 randomDataIntPtr;
|
||||
quint32 longIndiciesPtr;
|
||||
quint32 notificationsPtr;
|
||||
quint32 deltaPartsPtr;
|
||||
QString name;
|
||||
};
|
||||
|
||||
struct StringTable {
|
||||
quint32 columnCount;
|
||||
quint32 rowCount;
|
||||
QString name;
|
||||
};
|
||||
|
||||
struct AssetMap {
|
||||
QVector<LocalString> localStrings;
|
||||
QVector<RawFile> rawFiles;
|
||||
//QVector<PhysPreset> phyPresets;
|
||||
//QVector<Model> models;
|
||||
//QVector<Material> rawFiles;
|
||||
//QVector<Shader> shaders;
|
||||
QVector<TechSet> techSets;
|
||||
//QVector<Image> images;
|
||||
//QVector<Sound> sounds;
|
||||
//QVector<CollisionMap> collMaps;
|
||||
//QVector<LightDefinition> lightDefs;
|
||||
//QVector<UiMap> uiMaps;
|
||||
//QVector<DriverGlobal> driverGlobals;
|
||||
//QVector<AiType> aiType;
|
||||
//QVector<Effect> effects;
|
||||
QVector<Animation> animations;
|
||||
QVector<StringTable> stringTables;
|
||||
//QVector<Menu> menus;
|
||||
//QVector<Weapon> weapons;
|
||||
//QVector<D3DBSP> d3dbspDumps;
|
||||
//QVector<SingleplayerMap> spMaps;
|
||||
};
|
||||
|
||||
struct ZoneFile {
|
||||
quint32 size;
|
||||
quint32 tagCount;
|
||||
QStringList tags;
|
||||
quint32 recordCount;
|
||||
QStringList records;
|
||||
AssetMap assetMap;
|
||||
};
|
||||
|
||||
struct FastFile {
|
||||
FF_COMPANY company;
|
||||
FF_FILETYPE fileType;
|
||||
FF_SIGNAGE signage;
|
||||
QString magic;
|
||||
quint32 version;
|
||||
|
||||
ZoneFile zoneFile;
|
||||
};
|
||||
|
||||
#endif // STRUCTS_H
|
||||
25
techsetviewer.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
#include "techsetviewer.h"
|
||||
#include "ui_techsetviewer.h"
|
||||
|
||||
TechSetViewer::TechSetViewer(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, ui(new Ui::TechSetViewer)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
TechSetViewer::~TechSetViewer()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void TechSetViewer::SetTechSet(std::shared_ptr<TechSet> aTechSet) {
|
||||
ui->listWidget_Ptrs->clear();
|
||||
ui->label_Title->setText(aTechSet->name);
|
||||
|
||||
int ptrIndex = 1;
|
||||
for (auto ptr : aTechSet->pointers) {
|
||||
ui->listWidget_Ptrs->addItem(QString("Pointer %1: %2").arg(ptrIndex).arg(ptr));
|
||||
ptrIndex++;
|
||||
}
|
||||
}
|
||||
25
techsetviewer.h
Normal file
@ -0,0 +1,25 @@
|
||||
#ifndef TECHSETVIEWER_H
|
||||
#define TECHSETVIEWER_H
|
||||
|
||||
#include "asset_structs.h"
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui {
|
||||
class TechSetViewer;
|
||||
}
|
||||
|
||||
class TechSetViewer : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TechSetViewer(QWidget *parent = nullptr);
|
||||
~TechSetViewer();
|
||||
|
||||
void SetTechSet(std::shared_ptr<TechSet> aTechSet);
|
||||
|
||||
private:
|
||||
Ui::TechSetViewer *ui;
|
||||
};
|
||||
|
||||
#endif // TECHSETVIEWER_H
|
||||