mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-11-23 05:12:05 +00:00
Merge fixup
This commit is contained in:
2
.github/workflows/check-formatting.yaml
vendored
2
.github/workflows/check-formatting.yaml
vendored
@@ -8,7 +8,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
|
||||
11
.github/workflows/ci.yaml
vendored
11
.github/workflows/ci.yaml
vendored
@@ -15,6 +15,9 @@ jobs:
|
||||
build_arch: [x86, x64]
|
||||
runs-on: ubuntu-latest
|
||||
container: ubuntu:24.04
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
steps:
|
||||
- name: Install g++ and multilib
|
||||
run: |
|
||||
@@ -26,7 +29,7 @@ jobs:
|
||||
update-alternatives --set g++ /usr/bin/g++-13
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
@@ -38,7 +41,9 @@ jobs:
|
||||
|
||||
- name: Build
|
||||
working-directory: ${{ github.workspace }}
|
||||
run: make -C build -j$(nproc) config=release_${{ matrix.build_arch }} all
|
||||
run: |
|
||||
make -C build -j$(nproc) config=release_${{ matrix.build_arch }} all
|
||||
chmod +x build/bin/Release_${{ matrix.build_arch }}/{ImageConverter,Unlinker,Linker}
|
||||
|
||||
- name: Test
|
||||
working-directory: ${{ github.workspace }}/build/lib/Release_${{ matrix.build_arch }}/tests
|
||||
@@ -63,7 +68,7 @@ jobs:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
|
||||
17
.github/workflows/release.yaml
vendored
17
.github/workflows/release.yaml
vendored
@@ -9,6 +9,9 @@ jobs:
|
||||
build-release-linux:
|
||||
runs-on: ubuntu-latest
|
||||
container: ubuntu:24.04
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
steps:
|
||||
- name: Install g++ and multilib
|
||||
run: |
|
||||
@@ -20,7 +23,7 @@ jobs:
|
||||
update-alternatives --set g++ /usr/bin/g++-13
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
@@ -28,11 +31,13 @@ jobs:
|
||||
working-directory: ${{ github.workspace }}
|
||||
env:
|
||||
PREMAKE_NO_PROMPT: 1
|
||||
run: ./generate.sh
|
||||
run: ./generate.sh --oat-version=${{ github.ref_name }}
|
||||
|
||||
- name: Build
|
||||
working-directory: ${{ github.workspace }}
|
||||
run: make -C build -j$(nproc) config=release_x86 all
|
||||
run: |
|
||||
make -C build -j$(nproc) config=release_x86 all
|
||||
chmod +x build/bin/Release_x86/{ImageConverter,Unlinker,Linker}
|
||||
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
@@ -45,7 +50,7 @@ jobs:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
@@ -56,7 +61,7 @@ jobs:
|
||||
working-directory: ${{ github.workspace }}
|
||||
env:
|
||||
PREMAKE_NO_PROMPT: 1
|
||||
run: ./generate.bat
|
||||
run: ./generate.bat --oat-version=${{ github.ref_name }}
|
||||
|
||||
- name: Build
|
||||
working-directory: ${{ github.workspace }}
|
||||
@@ -78,7 +83,7 @@ jobs:
|
||||
actions: read
|
||||
contents: write
|
||||
steps:
|
||||
- uses: actions/download-artifact@v4
|
||||
- uses: actions/download-artifact@v5
|
||||
- name: Zip artifacts
|
||||
run: |
|
||||
7z a oat-linux.tar ./oat-linux/*
|
||||
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,5 +1,5 @@
|
||||
local/
|
||||
build/
|
||||
/build/
|
||||
.vscode
|
||||
.idea
|
||||
user*.*
|
||||
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -19,3 +19,6 @@
|
||||
[submodule "thirdparty/lz4"]
|
||||
path = thirdparty/lz4
|
||||
url = https://github.com/lz4/lz4.git
|
||||
[submodule "thirdparty/webview"]
|
||||
path = thirdparty/webview
|
||||
url = https://github.com/Laupetin/webview.git
|
||||
|
||||
18
premake5.lua
18
premake5.lua
@@ -95,25 +95,32 @@ include "thirdparty/catch2.lua"
|
||||
include "thirdparty/eigen.lua"
|
||||
include "thirdparty/libtomcrypt.lua"
|
||||
include "thirdparty/libtommath.lua"
|
||||
include "thirdparty/lz4.lua"
|
||||
include "thirdparty/lzx.lua"
|
||||
include "thirdparty/json.lua"
|
||||
include "thirdparty/minilzo.lua"
|
||||
include "thirdparty/minizip.lua"
|
||||
include "thirdparty/salsa20.lua"
|
||||
include "thirdparty/webview.lua"
|
||||
include "thirdparty/zlib.lua"
|
||||
include "thirdparty/lz4.lua"
|
||||
|
||||
-- ThirdParty group: All projects that are external dependencies
|
||||
group "ThirdParty"
|
||||
catch2:project()
|
||||
eigen:project()
|
||||
libtommath:project()
|
||||
libtomcrypt:project()
|
||||
libtommath:project()
|
||||
lz4:project()
|
||||
lzx:project()
|
||||
json:project()
|
||||
minilzo:project()
|
||||
minizip:project()
|
||||
salsa20:project()
|
||||
zlib:project()
|
||||
lz4:project()
|
||||
|
||||
if _OPTIONS["modman"] then
|
||||
webview:project()
|
||||
end
|
||||
group ""
|
||||
|
||||
-- ========================
|
||||
@@ -123,6 +130,7 @@ include "src/Common.lua"
|
||||
include "src/Cryptography.lua"
|
||||
include "src/ImageConverter.lua"
|
||||
include "src/Linker.lua"
|
||||
include "src/ModMan.lua"
|
||||
include "src/Parser.lua"
|
||||
include "src/RawTemplater.lua"
|
||||
include "src/Unlinker.lua"
|
||||
@@ -170,6 +178,10 @@ group "Tools"
|
||||
Linker:project()
|
||||
Unlinker:project()
|
||||
ImageConverter:project()
|
||||
|
||||
if _OPTIONS["modman"] then
|
||||
ModMan:project()
|
||||
end
|
||||
group ""
|
||||
|
||||
group "Raw"
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "GameLanguage.h"
|
||||
|
||||
#include <type_traits>
|
||||
#include <vector>
|
||||
|
||||
class Zone;
|
||||
|
||||
enum class GameId
|
||||
{
|
||||
IW3,
|
||||
@@ -17,6 +16,22 @@ enum class GameId
|
||||
COUNT
|
||||
};
|
||||
|
||||
// The full uppercase names are macros in the standard lib
|
||||
// So unfortunately not usable as values in the enum
|
||||
enum class GameEndianness
|
||||
{
|
||||
/* Little endian */
|
||||
LE,
|
||||
/* Big endian */
|
||||
BE
|
||||
};
|
||||
|
||||
enum class GameWordSize
|
||||
{
|
||||
ARCH_32,
|
||||
ARCH_64
|
||||
};
|
||||
|
||||
static constexpr const char* GameId_Names[]{
|
||||
"IW3",
|
||||
"IW4",
|
||||
@@ -39,9 +54,6 @@ public:
|
||||
[[nodiscard]] virtual GameId GetId() const = 0;
|
||||
[[nodiscard]] virtual const std::string& GetFullName() const = 0;
|
||||
[[nodiscard]] virtual const std::string& GetShortName() const = 0;
|
||||
virtual void AddZone(Zone* zone) = 0;
|
||||
virtual void RemoveZone(Zone* zone) = 0;
|
||||
[[nodiscard]] virtual const std::vector<Zone*>& GetZones() const = 0;
|
||||
[[nodiscard]] virtual const std::vector<GameLanguagePrefix>& GetLanguagePrefixes() const = 0;
|
||||
|
||||
static IGame* GetGameById(GameId gameId);
|
||||
|
||||
@@ -21,6 +21,11 @@ namespace IW3
|
||||
return result;
|
||||
}
|
||||
|
||||
static constexpr uint32_t R_HashString(const char* string)
|
||||
{
|
||||
return R_HashString(string, 0u);
|
||||
}
|
||||
|
||||
static PackedTexCoords Vec2PackTexCoords(const float (&in)[2]);
|
||||
static PackedUnitVec Vec3PackUnitVec(const float (&in)[3]);
|
||||
static GfxColor Vec4PackGfxColor(const float (&in)[4]);
|
||||
|
||||
@@ -21,24 +21,6 @@ const std::string& Game::GetShortName() const
|
||||
return shortName;
|
||||
}
|
||||
|
||||
void Game::AddZone(Zone* zone)
|
||||
{
|
||||
m_zones.push_back(zone);
|
||||
}
|
||||
|
||||
void Game::RemoveZone(Zone* zone)
|
||||
{
|
||||
const auto foundEntry = std::ranges::find(m_zones, zone);
|
||||
|
||||
if (foundEntry != m_zones.end())
|
||||
m_zones.erase(foundEntry);
|
||||
}
|
||||
|
||||
const std::vector<Zone*>& Game::GetZones() const
|
||||
{
|
||||
return m_zones;
|
||||
}
|
||||
|
||||
const std::vector<GameLanguagePrefix>& Game::GetLanguagePrefixes() const
|
||||
{
|
||||
static std::vector<GameLanguagePrefix> prefixes;
|
||||
|
||||
@@ -9,12 +9,6 @@ namespace IW3
|
||||
[[nodiscard]] GameId GetId() const override;
|
||||
[[nodiscard]] const std::string& GetFullName() const override;
|
||||
[[nodiscard]] const std::string& GetShortName() const override;
|
||||
void AddZone(Zone* zone) override;
|
||||
void RemoveZone(Zone* zone) override;
|
||||
[[nodiscard]] const std::vector<Zone*>& GetZones() const override;
|
||||
[[nodiscard]] const std::vector<GameLanguagePrefix>& GetLanguagePrefixes() const override;
|
||||
|
||||
private:
|
||||
std::vector<Zone*> m_zones;
|
||||
};
|
||||
} // namespace IW3
|
||||
|
||||
@@ -97,6 +97,8 @@ namespace IW3
|
||||
struct RawFile;
|
||||
struct StringTable;
|
||||
|
||||
typedef unsigned short ScriptString;
|
||||
|
||||
union XAssetHeader
|
||||
{
|
||||
// XModelPieces *xmodelPieces; // NOT AN ASSET
|
||||
@@ -215,7 +217,7 @@ namespace IW3
|
||||
|
||||
struct XAnimNotifyInfo
|
||||
{
|
||||
uint16_t name;
|
||||
ScriptString name;
|
||||
float time;
|
||||
};
|
||||
|
||||
@@ -309,7 +311,7 @@ namespace IW3
|
||||
unsigned int indexCount;
|
||||
float framerate;
|
||||
float frequency;
|
||||
uint16_t* names;
|
||||
ScriptString* names;
|
||||
char* dataByte;
|
||||
int16_t* dataShort;
|
||||
int* dataInt;
|
||||
@@ -329,8 +331,8 @@ namespace IW3
|
||||
|
||||
struct DObjAnimMat
|
||||
{
|
||||
float quat[4];
|
||||
float trans[3];
|
||||
vec4_t quat;
|
||||
vec3_t trans;
|
||||
float transWeight;
|
||||
};
|
||||
|
||||
@@ -390,7 +392,7 @@ namespace IW3
|
||||
|
||||
struct type_align(16) GfxPackedVertex
|
||||
{
|
||||
float xyz[3];
|
||||
vec3_t xyz;
|
||||
float binormalSign;
|
||||
GfxColor color;
|
||||
PackedTexCoords texCoord;
|
||||
@@ -404,7 +406,12 @@ namespace IW3
|
||||
uint16_t* vertsBlend;
|
||||
};
|
||||
|
||||
typedef tdef_align32(16) uint16_t r_index16_t;
|
||||
struct XSurfaceTri
|
||||
{
|
||||
uint16_t i[3];
|
||||
};
|
||||
|
||||
typedef tdef_align32(16) XSurfaceTri XSurfaceTri16;
|
||||
|
||||
struct XSurface
|
||||
{
|
||||
@@ -415,7 +422,7 @@ namespace IW3
|
||||
char zoneHandle;
|
||||
uint16_t baseTriIndex;
|
||||
uint16_t baseVertIndex;
|
||||
r_index16_t (*triIndices)[3];
|
||||
XSurfaceTri16* triIndices;
|
||||
XSurfaceVertexInfo vertInfo;
|
||||
GfxPackedVertex* verts0;
|
||||
unsigned int vertListCount;
|
||||
@@ -455,8 +462,8 @@ namespace IW3
|
||||
|
||||
struct XBoneInfo
|
||||
{
|
||||
float bounds[2][3];
|
||||
float offset[3];
|
||||
vec3_t bounds[2];
|
||||
vec3_t offset;
|
||||
float radiusSquared;
|
||||
};
|
||||
|
||||
@@ -520,6 +527,11 @@ namespace IW3
|
||||
char pad;
|
||||
};
|
||||
|
||||
struct XModelQuat
|
||||
{
|
||||
int16_t v[4];
|
||||
};
|
||||
|
||||
struct XModel
|
||||
{
|
||||
const char* name;
|
||||
@@ -527,11 +539,11 @@ namespace IW3
|
||||
unsigned char numRootBones;
|
||||
unsigned char numsurfs;
|
||||
char lodRampType;
|
||||
uint16_t* boneNames;
|
||||
char* parentList;
|
||||
int16_t (*quats)[4];
|
||||
float (*trans)[4];
|
||||
char* partClassification;
|
||||
ScriptString* boneNames;
|
||||
unsigned char* parentList;
|
||||
XModelQuat* quats;
|
||||
float* trans;
|
||||
unsigned char* partClassification;
|
||||
DObjAnimMat* baseMat;
|
||||
XSurface* surfs;
|
||||
Material** materialHandles;
|
||||
@@ -541,10 +553,10 @@ namespace IW3
|
||||
int contents;
|
||||
XBoneInfo* boneInfo;
|
||||
float radius;
|
||||
float mins[3];
|
||||
float maxs[3];
|
||||
vec3_t mins;
|
||||
vec3_t maxs;
|
||||
uint16_t numLods;
|
||||
uint16_t collLod;
|
||||
int16_t collLod;
|
||||
XModelStreamInfo streamInfo;
|
||||
int memUsage;
|
||||
char flags;
|
||||
@@ -566,7 +578,8 @@ namespace IW3
|
||||
GFXS_BLEND_INVDESTALPHA = 0x8,
|
||||
GFXS_BLEND_DESTCOLOR = 0x9,
|
||||
GFXS_BLEND_INVDESTCOLOR = 0xA,
|
||||
GFXS_BLEND_MASK = 0xF,
|
||||
|
||||
GFXS_BLEND_COUNT
|
||||
};
|
||||
|
||||
enum GfxBlendOp
|
||||
@@ -577,7 +590,40 @@ namespace IW3
|
||||
GFXS_BLENDOP_REVSUBTRACT = 0x3,
|
||||
GFXS_BLENDOP_MIN = 0x4,
|
||||
GFXS_BLENDOP_MAX = 0x5,
|
||||
GFXS_BLENDOP_MASK = 0x7,
|
||||
|
||||
GFXS_BLENDOP_COUNT
|
||||
};
|
||||
|
||||
enum GfxAlphaTest_e
|
||||
{
|
||||
GFXS_ALPHA_TEST_GT_0 = 1,
|
||||
GFXS_ALPHA_TEST_LT_128 = 2,
|
||||
GFXS_ALPHA_TEST_GE_128 = 3,
|
||||
|
||||
GFXS_ALPHA_TEST_COUNT
|
||||
};
|
||||
|
||||
enum GfxCullFace_e
|
||||
{
|
||||
GFXS_CULL_NONE = 1,
|
||||
GFXS_CULL_BACK = 2,
|
||||
GFXS_CULL_FRONT = 3,
|
||||
};
|
||||
|
||||
enum GfxDepthTest_e
|
||||
{
|
||||
GFXS_DEPTHTEST_ALWAYS = 0,
|
||||
GFXS_DEPTHTEST_LESS = 1,
|
||||
GFXS_DEPTHTEST_EQUAL = 2,
|
||||
GFXS_DEPTHTEST_LESSEQUAL = 3
|
||||
};
|
||||
|
||||
enum GfxPolygonOffset_e
|
||||
{
|
||||
GFXS_POLYGON_OFFSET_0 = 0,
|
||||
GFXS_POLYGON_OFFSET_1 = 1,
|
||||
GFXS_POLYGON_OFFSET_2 = 2,
|
||||
GFXS_POLYGON_OFFSET_SHADOWMAP = 3
|
||||
};
|
||||
|
||||
enum GfxStencilOp
|
||||
@@ -589,10 +635,19 @@ namespace IW3
|
||||
GFXS_STENCILOP_DECRSAT = 0x4,
|
||||
GFXS_STENCILOP_INVERT = 0x5,
|
||||
GFXS_STENCILOP_INCR = 0x6,
|
||||
GFXS_STENCILOP_DECR = 0x7,
|
||||
GFXS_STENCILOP_DECR = 0x7
|
||||
};
|
||||
|
||||
GFXS_STENCILOP_COUNT,
|
||||
GFXS_STENCILOP_MASK = 0x7
|
||||
enum GfxStencilFunc
|
||||
{
|
||||
GFXS_STENCILFUNC_NEVER = 0x0,
|
||||
GFXS_STENCILFUNC_LESS = 0x1,
|
||||
GFXS_STENCILFUNC_EQUAL = 0x2,
|
||||
GFXS_STENCILFUNC_LESSEQUAL = 0x3,
|
||||
GFXS_STENCILFUNC_GREATER = 0x4,
|
||||
GFXS_STENCILFUNC_NOTEQUAL = 0x5,
|
||||
GFXS_STENCILFUNC_GREATEREQUAL = 0x6,
|
||||
GFXS_STENCILFUNC_ALWAYS = 0x7
|
||||
};
|
||||
|
||||
enum GfxStateBitsEnum : unsigned int
|
||||
@@ -613,10 +668,10 @@ namespace IW3
|
||||
GFXS0_ATEST_GE_128 = 0x3000,
|
||||
GFXS0_ATEST_MASK = 0x3000,
|
||||
|
||||
GFXS0_CULL_SHIFT = 0xE,
|
||||
GFXS0_CULL_NONE = 0x4000,
|
||||
GFXS0_CULL_BACK = 0x8000,
|
||||
GFXS0_CULL_FRONT = 0xC000,
|
||||
GFXS0_CULL_SHIFT = 0xE,
|
||||
GFXS0_CULL_MASK = 0xC000,
|
||||
|
||||
GFXS0_SRCBLEND_ALPHA_SHIFT = 0x10,
|
||||
@@ -638,18 +693,18 @@ namespace IW3
|
||||
GFXS1_DEPTHWRITE = 0x1,
|
||||
|
||||
GFXS1_DEPTHTEST_DISABLE = 0x2,
|
||||
GFXS1_DEPTHTEST_SHIFT = 0x2,
|
||||
GFXS1_DEPTHTEST_ALWAYS = 0x0,
|
||||
GFXS1_DEPTHTEST_LESS = 0x4,
|
||||
GFXS1_DEPTHTEST_EQUAL = 0x8,
|
||||
GFXS1_DEPTHTEST_LESSEQUAL = 0xC,
|
||||
GFXS1_DEPTHTEST_SHIFT = 0x2,
|
||||
GFXS1_DEPTHTEST_MASK = 0xC,
|
||||
|
||||
GFXS1_POLYGON_OFFSET_SHIFT = 0x4,
|
||||
GFXS1_POLYGON_OFFSET_0 = 0x0,
|
||||
GFXS1_POLYGON_OFFSET_1 = 0x10,
|
||||
GFXS1_POLYGON_OFFSET_2 = 0x20,
|
||||
GFXS1_POLYGON_OFFSET_SHADOWMAP = 0x30,
|
||||
GFXS1_POLYGON_OFFSET_SHIFT = 0x4,
|
||||
GFXS1_POLYGON_OFFSET_MASK = 0x30,
|
||||
|
||||
GFXS1_STENCIL_FRONT_ENABLE = 0x40,
|
||||
@@ -672,16 +727,61 @@ namespace IW3
|
||||
GFXS1_STENCILOP_FRONTBACK_MASK = 0x1FF1FF00,
|
||||
};
|
||||
|
||||
struct GfxStateBitsLoadBitsStructured
|
||||
{
|
||||
// Byte 0
|
||||
unsigned int srcBlendRgb : 4; // 0-3
|
||||
unsigned int dstBlendRgb : 4; // 4-7
|
||||
unsigned int blendOpRgb : 3; // 8-10
|
||||
unsigned int alphaTestDisabled : 1; // 11
|
||||
unsigned int alphaTest : 2; // 12-13
|
||||
unsigned int cullFace : 2; // 14-15
|
||||
unsigned int srcBlendAlpha : 4; // 16-19
|
||||
unsigned int dstBlendAlpha : 4; // 20-23
|
||||
unsigned int blendOpAlpha : 3; // 24-26
|
||||
unsigned int colorWriteRgb : 1; // 27
|
||||
unsigned int colorWriteAlpha : 1; // 28
|
||||
unsigned int unused1 : 2; // 29-30
|
||||
unsigned int polymodeLine : 1; // 31
|
||||
|
||||
// Byte 1
|
||||
unsigned int depthWrite : 1; // 0
|
||||
unsigned int depthTestDisabled : 1; // 1
|
||||
unsigned int depthTest : 2; // 2-3
|
||||
unsigned int polygonOffset : 2; // 4-5
|
||||
unsigned int stencilFrontEnabled : 1; // 6
|
||||
unsigned int stencilBackEnabled : 1; // 7
|
||||
unsigned int stencilFrontPass : 3; // 8-10
|
||||
unsigned int stencilFrontFail : 3; // 11-13
|
||||
unsigned int stencilFrontZFail : 3; // 14-16
|
||||
unsigned int stencilFrontFunc : 3; // 17-19
|
||||
unsigned int stencilBackPass : 3; // 20-22
|
||||
unsigned int stencilBackFail : 3; // 23-25
|
||||
unsigned int stencilBackZFail : 3; // 26-28
|
||||
unsigned int stencilBackFunc : 3; // 29-31
|
||||
};
|
||||
|
||||
union GfxStateBitsLoadBits
|
||||
{
|
||||
unsigned int raw[2];
|
||||
GfxStateBitsLoadBitsStructured structured;
|
||||
};
|
||||
|
||||
#ifndef __zonecodegenerator
|
||||
static_assert(sizeof(GfxStateBitsLoadBits) == 8);
|
||||
static_assert(sizeof(GfxStateBitsLoadBitsStructured) == 8);
|
||||
#endif
|
||||
|
||||
struct GfxStateBits
|
||||
{
|
||||
unsigned int loadBits[2];
|
||||
GfxStateBitsLoadBits loadBits;
|
||||
};
|
||||
|
||||
struct type_align(16) MaterialConstantDef
|
||||
{
|
||||
unsigned int nameHash;
|
||||
char name[12];
|
||||
float literal[4];
|
||||
vec4_t literal;
|
||||
};
|
||||
|
||||
struct complex_s
|
||||
@@ -718,6 +818,26 @@ namespace IW3
|
||||
water_t* water;
|
||||
};
|
||||
|
||||
enum TextureFilter
|
||||
{
|
||||
TEXTURE_FILTER_DISABLED = 0x0,
|
||||
TEXTURE_FILTER_NEAREST = 0x1,
|
||||
TEXTURE_FILTER_LINEAR = 0x2,
|
||||
TEXTURE_FILTER_ANISO2X = 0x3,
|
||||
TEXTURE_FILTER_ANISO4X = 0x4,
|
||||
|
||||
TEXTURE_FILTER_COUNT
|
||||
};
|
||||
|
||||
enum SamplerStateBitsMipMap_e
|
||||
{
|
||||
SAMPLER_MIPMAP_ENUM_DISABLED,
|
||||
SAMPLER_MIPMAP_ENUM_NEAREST,
|
||||
SAMPLER_MIPMAP_ENUM_LINEAR,
|
||||
|
||||
SAMPLER_MIPMAP_ENUM_COUNT
|
||||
};
|
||||
|
||||
enum SamplerStateBits_e
|
||||
{
|
||||
SAMPLER_FILTER_SHIFT = 0x0,
|
||||
@@ -743,12 +863,25 @@ namespace IW3
|
||||
SAMPLER_CLAMP_MASK = 0xE0,
|
||||
};
|
||||
|
||||
struct MaterialTextureDefSamplerState
|
||||
{
|
||||
unsigned char filter : 3;
|
||||
unsigned char mipMap : 2;
|
||||
unsigned char clampU : 1;
|
||||
unsigned char clampV : 1;
|
||||
unsigned char clampW : 1;
|
||||
};
|
||||
|
||||
#ifndef __zonecodegenerator
|
||||
static_assert(sizeof(MaterialTextureDefSamplerState) == 1u);
|
||||
#endif
|
||||
|
||||
struct MaterialTextureDef
|
||||
{
|
||||
unsigned int nameHash;
|
||||
char nameStart;
|
||||
char nameEnd;
|
||||
unsigned char samplerState; // SamplerStateBits_e
|
||||
MaterialTextureDefSamplerState samplerState; // SamplerStateBits_e
|
||||
unsigned char semantic; // TextureSemantic
|
||||
MaterialTextureDefInfo u;
|
||||
};
|
||||
@@ -842,8 +975,9 @@ namespace IW3
|
||||
CAMERA_REGION_LIT = 0x0,
|
||||
CAMERA_REGION_DECAL = 0x1,
|
||||
CAMERA_REGION_EMISSIVE = 0x2,
|
||||
CAMERA_REGION_COUNT = 0x3,
|
||||
CAMERA_REGION_NONE = 0x3,
|
||||
|
||||
CAMERA_REGION_COUNT,
|
||||
CAMERA_REGION_NONE = CAMERA_REGION_COUNT,
|
||||
};
|
||||
|
||||
enum MaterialStateFlags
|
||||
@@ -2799,6 +2933,30 @@ namespace IW3
|
||||
MISSILE_GUIDANCE_COUNT = 0x4,
|
||||
};
|
||||
|
||||
enum hitLocation_t
|
||||
{
|
||||
HITLOC_NONE = 0x0,
|
||||
HITLOC_HELMET = 0x1,
|
||||
HITLOC_HEAD = 0x2,
|
||||
HITLOC_NECK = 0x3,
|
||||
HITLOC_TORSO_UPR = 0x4,
|
||||
HITLOC_TORSO_LWR = 0x5,
|
||||
HITLOC_R_ARM_UPR = 0x6,
|
||||
HITLOC_L_ARM_UPR = 0x7,
|
||||
HITLOC_R_ARM_LWR = 0x8,
|
||||
HITLOC_L_ARM_LWR = 0x9,
|
||||
HITLOC_R_HAND = 0xA,
|
||||
HITLOC_L_HAND = 0xB,
|
||||
HITLOC_R_LEG_UPR = 0xC,
|
||||
HITLOC_L_LEG_UPR = 0xD,
|
||||
HITLOC_R_LEG_LWR = 0xE,
|
||||
HITLOC_L_LEG_LWR = 0xF,
|
||||
HITLOC_R_FOOT = 0x10,
|
||||
HITLOC_L_FOOT = 0x11,
|
||||
|
||||
HITLOC_COUNT,
|
||||
};
|
||||
|
||||
struct snd_alias_list_name
|
||||
{
|
||||
const char* soundName;
|
||||
|
||||
@@ -21,24 +21,6 @@ const std::string& Game::GetShortName() const
|
||||
return shortName;
|
||||
}
|
||||
|
||||
void Game::AddZone(Zone* zone)
|
||||
{
|
||||
m_zones.push_back(zone);
|
||||
}
|
||||
|
||||
void Game::RemoveZone(Zone* zone)
|
||||
{
|
||||
const auto foundEntry = std::ranges::find(m_zones, zone);
|
||||
|
||||
if (foundEntry != m_zones.end())
|
||||
m_zones.erase(foundEntry);
|
||||
}
|
||||
|
||||
const std::vector<Zone*>& Game::GetZones() const
|
||||
{
|
||||
return m_zones;
|
||||
}
|
||||
|
||||
const std::vector<GameLanguagePrefix>& Game::GetLanguagePrefixes() const
|
||||
{
|
||||
static std::vector<GameLanguagePrefix> prefixes;
|
||||
|
||||
@@ -9,12 +9,6 @@ namespace IW4
|
||||
[[nodiscard]] GameId GetId() const override;
|
||||
[[nodiscard]] const std::string& GetFullName() const override;
|
||||
[[nodiscard]] const std::string& GetShortName() const override;
|
||||
void AddZone(Zone* zone) override;
|
||||
void RemoveZone(Zone* zone) override;
|
||||
[[nodiscard]] const std::vector<Zone*>& GetZones() const override;
|
||||
[[nodiscard]] const std::vector<GameLanguagePrefix>& GetLanguagePrefixes() const override;
|
||||
|
||||
private:
|
||||
std::vector<Zone*> m_zones;
|
||||
};
|
||||
} // namespace IW4
|
||||
|
||||
@@ -113,6 +113,8 @@ namespace IW4
|
||||
struct VehicleDef;
|
||||
struct AddonMapEnts;
|
||||
|
||||
typedef unsigned short ScriptString;
|
||||
|
||||
union XAssetHeader
|
||||
{
|
||||
PhysPreset* physPreset;
|
||||
@@ -239,8 +241,8 @@ namespace IW4
|
||||
|
||||
struct Bounds
|
||||
{
|
||||
float midPoint[3];
|
||||
float halfSize[3];
|
||||
vec3_t midPoint;
|
||||
vec3_t halfSize;
|
||||
};
|
||||
|
||||
struct cplane_s
|
||||
@@ -325,7 +327,7 @@ namespace IW4
|
||||
|
||||
struct XAnimNotifyInfo
|
||||
{
|
||||
uint16_t name;
|
||||
ScriptString name;
|
||||
float time;
|
||||
};
|
||||
|
||||
@@ -448,7 +450,7 @@ namespace IW4
|
||||
unsigned int indexCount;
|
||||
float framerate;
|
||||
float frequency;
|
||||
uint16_t* names;
|
||||
ScriptString* names;
|
||||
char* dataByte;
|
||||
int16_t* dataShort;
|
||||
int* dataInt;
|
||||
@@ -491,7 +493,7 @@ namespace IW4
|
||||
|
||||
struct type_align(16) GfxPackedVertex
|
||||
{
|
||||
float xyz[3];
|
||||
vec3_t xyz;
|
||||
float binormalSign;
|
||||
GfxColor color;
|
||||
PackedTexCoords texCoord;
|
||||
@@ -536,7 +538,12 @@ namespace IW4
|
||||
XSurfaceCollisionTree* collisionTree;
|
||||
};
|
||||
|
||||
typedef tdef_align32(16) uint16_t r_index16_t;
|
||||
struct XSurfaceTri
|
||||
{
|
||||
uint16_t i[3];
|
||||
};
|
||||
|
||||
typedef tdef_align32(16) XSurfaceTri XSurfaceTri16;
|
||||
|
||||
struct XSurface
|
||||
{
|
||||
@@ -547,7 +554,7 @@ namespace IW4
|
||||
char zoneHandle;
|
||||
uint16_t baseTriIndex;
|
||||
uint16_t baseVertIndex;
|
||||
r_index16_t (*triIndices)[3];
|
||||
XSurfaceTri16* triIndices;
|
||||
XSurfaceVertexInfo vertInfo;
|
||||
GfxPackedVertex* verts0;
|
||||
unsigned int vertListCount;
|
||||
@@ -602,11 +609,16 @@ namespace IW4
|
||||
|
||||
struct DObjAnimMat
|
||||
{
|
||||
float quat[4];
|
||||
float trans[3];
|
||||
vec4_t quat;
|
||||
vec3_t trans;
|
||||
float transWeight;
|
||||
};
|
||||
|
||||
struct XModelQuat
|
||||
{
|
||||
int16_t v[4];
|
||||
};
|
||||
|
||||
struct XModel
|
||||
{
|
||||
const char* name;
|
||||
@@ -616,17 +628,17 @@ namespace IW4
|
||||
char lodRampType;
|
||||
float scale;
|
||||
unsigned int noScalePartBits[6];
|
||||
uint16_t* boneNames;
|
||||
ScriptString* boneNames;
|
||||
unsigned char* parentList;
|
||||
int16_t (*quats)[4];
|
||||
float (*trans)[3];
|
||||
XModelQuat* quats;
|
||||
float* trans;
|
||||
unsigned char* partClassification;
|
||||
DObjAnimMat* baseMat;
|
||||
Material** materialHandles;
|
||||
XModelLodInfo lodInfo[4];
|
||||
char maxLoadedLod;
|
||||
unsigned char numLods;
|
||||
unsigned char collLod;
|
||||
char collLod;
|
||||
char flags;
|
||||
XModelCollSurf_s* collSurfs;
|
||||
int numCollSurfs;
|
||||
|
||||
@@ -21,24 +21,6 @@ const std::string& Game::GetShortName() const
|
||||
return shortName;
|
||||
}
|
||||
|
||||
void Game::AddZone(Zone* zone)
|
||||
{
|
||||
m_zones.push_back(zone);
|
||||
}
|
||||
|
||||
void Game::RemoveZone(Zone* zone)
|
||||
{
|
||||
const auto foundEntry = std::ranges::find(m_zones, zone);
|
||||
|
||||
if (foundEntry != m_zones.end())
|
||||
m_zones.erase(foundEntry);
|
||||
}
|
||||
|
||||
const std::vector<Zone*>& Game::GetZones() const
|
||||
{
|
||||
return m_zones;
|
||||
}
|
||||
|
||||
const std::vector<GameLanguagePrefix>& Game::GetLanguagePrefixes() const
|
||||
{
|
||||
static std::vector<GameLanguagePrefix> prefixes;
|
||||
|
||||
@@ -9,12 +9,6 @@ namespace IW5
|
||||
[[nodiscard]] GameId GetId() const override;
|
||||
[[nodiscard]] const std::string& GetFullName() const override;
|
||||
[[nodiscard]] const std::string& GetShortName() const override;
|
||||
void AddZone(Zone* zone) override;
|
||||
void RemoveZone(Zone* zone) override;
|
||||
[[nodiscard]] const std::vector<Zone*>& GetZones() const override;
|
||||
[[nodiscard]] const std::vector<GameLanguagePrefix>& GetLanguagePrefixes() const override;
|
||||
|
||||
private:
|
||||
std::vector<Zone*> m_zones;
|
||||
};
|
||||
} // namespace IW5
|
||||
|
||||
@@ -11,6 +11,21 @@ namespace T5
|
||||
static int Com_HashString(const char* str);
|
||||
static int Com_HashString(const char* str, int len);
|
||||
|
||||
static constexpr uint32_t R_HashString(const char* str, uint32_t hash)
|
||||
{
|
||||
for (const auto* pos = str; *pos; pos++)
|
||||
{
|
||||
hash = 33 * hash ^ (*pos | 0x20);
|
||||
}
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
static constexpr uint32_t R_HashString(const char* string)
|
||||
{
|
||||
return R_HashString(string, 0u);
|
||||
}
|
||||
|
||||
static PackedTexCoords Vec2PackTexCoords(const float (&in)[2]);
|
||||
static PackedUnitVec Vec3PackUnitVec(const float (&in)[3]);
|
||||
static GfxColor Vec4PackGfxColor(const float (&in)[4]);
|
||||
|
||||
@@ -21,24 +21,6 @@ const std::string& Game::GetShortName() const
|
||||
return shortName;
|
||||
}
|
||||
|
||||
void Game::AddZone(Zone* zone)
|
||||
{
|
||||
m_zones.push_back(zone);
|
||||
}
|
||||
|
||||
void Game::RemoveZone(Zone* zone)
|
||||
{
|
||||
const auto foundEntry = std::ranges::find(m_zones, zone);
|
||||
|
||||
if (foundEntry != m_zones.end())
|
||||
m_zones.erase(foundEntry);
|
||||
}
|
||||
|
||||
const std::vector<Zone*>& Game::GetZones() const
|
||||
{
|
||||
return m_zones;
|
||||
}
|
||||
|
||||
const std::vector<GameLanguagePrefix>& Game::GetLanguagePrefixes() const
|
||||
{
|
||||
static std::vector<GameLanguagePrefix> prefixes{
|
||||
|
||||
@@ -9,12 +9,6 @@ namespace T5
|
||||
[[nodiscard]] GameId GetId() const override;
|
||||
[[nodiscard]] const std::string& GetFullName() const override;
|
||||
[[nodiscard]] const std::string& GetShortName() const override;
|
||||
void AddZone(Zone* zone) override;
|
||||
void RemoveZone(Zone* zone) override;
|
||||
[[nodiscard]] const std::vector<Zone*>& GetZones() const override;
|
||||
[[nodiscard]] const std::vector<GameLanguagePrefix>& GetLanguagePrefixes() const override;
|
||||
|
||||
private:
|
||||
std::vector<Zone*> m_zones;
|
||||
};
|
||||
} // namespace T5
|
||||
|
||||
@@ -540,6 +540,15 @@ namespace T5
|
||||
XSurfaceCollisionTree* collisionTree;
|
||||
};
|
||||
|
||||
enum XSurfaceFlag
|
||||
{
|
||||
XSURFACE_FLAG_QUANTIZED = 0x1,
|
||||
XSURFACE_FLAG_SKINNED = 0x2,
|
||||
XSURFACE_FLAG_CONSTANT_COLOR = 0x4,
|
||||
XSURFACE_FLAG_DEFORMED = 0x80,
|
||||
XSURFACE_FLAG_STREAMED = 0x8000,
|
||||
};
|
||||
|
||||
struct XSurfaceTri
|
||||
{
|
||||
uint16_t i[3];
|
||||
@@ -739,14 +748,30 @@ namespace T5
|
||||
gcc_align32(8) uint64_t packed;
|
||||
};
|
||||
|
||||
enum MaterialGameFlags
|
||||
{
|
||||
MTL_GAMEFLAG_1 = 0x1,
|
||||
MTL_GAMEFLAG_2 = 0x2,
|
||||
MTL_GAMEFLAG_4 = 0x4,
|
||||
MTL_GAMEFLAG_8 = 0x8,
|
||||
MTL_GAMEFLAG_10 = 0x10,
|
||||
MTL_GAMEFLAG_20 = 0x20,
|
||||
|
||||
// Probably, seems to be this in T5
|
||||
MTL_GAMEFLAG_CASTS_SHADOW = 0x40,
|
||||
MTL_GAMEFLAG_80 = 0x80,
|
||||
MTL_GAMEFLAG_100 = 0x100,
|
||||
MTL_GAMEFLAG_200 = 0x200,
|
||||
};
|
||||
|
||||
struct MaterialInfo
|
||||
{
|
||||
const char* name;
|
||||
unsigned int gameFlags;
|
||||
char pad;
|
||||
char sortKey;
|
||||
char textureAtlasRowCount;
|
||||
char textureAtlasColumnCount;
|
||||
unsigned char sortKey;
|
||||
unsigned char textureAtlasRowCount;
|
||||
unsigned char textureAtlasColumnCount;
|
||||
GfxDrawSurf drawSurf;
|
||||
unsigned int surfaceTypeBits;
|
||||
unsigned int layeredSurfaceTypes;
|
||||
@@ -787,14 +812,47 @@ namespace T5
|
||||
water_t* water;
|
||||
};
|
||||
|
||||
enum TextureFilter
|
||||
{
|
||||
TEXTURE_FILTER_DISABLED = 0x0,
|
||||
TEXTURE_FILTER_NEAREST = 0x1,
|
||||
TEXTURE_FILTER_LINEAR = 0x2,
|
||||
TEXTURE_FILTER_ANISO2X = 0x3,
|
||||
TEXTURE_FILTER_ANISO4X = 0x4,
|
||||
|
||||
TEXTURE_FILTER_COUNT
|
||||
};
|
||||
|
||||
enum SamplerStateBitsMipMap_e
|
||||
{
|
||||
SAMPLER_MIPMAP_ENUM_DISABLED,
|
||||
SAMPLER_MIPMAP_ENUM_NEAREST,
|
||||
SAMPLER_MIPMAP_ENUM_LINEAR,
|
||||
|
||||
SAMPLER_MIPMAP_ENUM_COUNT
|
||||
};
|
||||
|
||||
struct MaterialTextureDefSamplerState
|
||||
{
|
||||
unsigned char filter : 3;
|
||||
unsigned char mipMap : 2;
|
||||
unsigned char clampU : 1;
|
||||
unsigned char clampV : 1;
|
||||
unsigned char clampW : 1;
|
||||
};
|
||||
|
||||
#ifndef __zonecodegenerator
|
||||
static_assert(sizeof(MaterialTextureDefSamplerState) == 1u);
|
||||
#endif
|
||||
|
||||
struct MaterialTextureDef
|
||||
{
|
||||
unsigned int nameHash;
|
||||
char nameStart;
|
||||
char nameEnd;
|
||||
char samplerState;
|
||||
MaterialTextureDefSamplerState samplerState;
|
||||
unsigned char semantic; // TextureSemantic
|
||||
char isMatureContent;
|
||||
bool isMatureContent;
|
||||
char pad[3];
|
||||
MaterialTextureDefInfo u;
|
||||
};
|
||||
@@ -803,7 +861,96 @@ namespace T5
|
||||
{
|
||||
unsigned int nameHash;
|
||||
char name[12];
|
||||
float literal[4];
|
||||
vec4_t literal;
|
||||
};
|
||||
|
||||
enum GfxBlend : unsigned int
|
||||
{
|
||||
GFXS_BLEND_DISABLED = 0x0,
|
||||
GFXS_BLEND_ZERO = 0x1,
|
||||
GFXS_BLEND_ONE = 0x2,
|
||||
GFXS_BLEND_SRCCOLOR = 0x3,
|
||||
GFXS_BLEND_INVSRCCOLOR = 0x4,
|
||||
GFXS_BLEND_SRCALPHA = 0x5,
|
||||
GFXS_BLEND_INVSRCALPHA = 0x6,
|
||||
GFXS_BLEND_DESTALPHA = 0x7,
|
||||
GFXS_BLEND_INVDESTALPHA = 0x8,
|
||||
GFXS_BLEND_DESTCOLOR = 0x9,
|
||||
GFXS_BLEND_INVDESTCOLOR = 0xA,
|
||||
GFXS_BLEND_MASK = 0xF,
|
||||
};
|
||||
|
||||
enum GfxBlendOp : unsigned int
|
||||
{
|
||||
GFXS_BLENDOP_DISABLED = 0x0,
|
||||
GFXS_BLENDOP_ADD = 0x1,
|
||||
GFXS_BLENDOP_SUBTRACT = 0x2,
|
||||
GFXS_BLENDOP_REVSUBTRACT = 0x3,
|
||||
GFXS_BLENDOP_MIN = 0x4,
|
||||
GFXS_BLENDOP_MAX = 0x5,
|
||||
GFXS_BLENDOP_MASK = 0x7,
|
||||
};
|
||||
|
||||
enum GfxAlphaTest_e
|
||||
{
|
||||
GFXS_ALPHA_TEST_GT_0 = 1,
|
||||
GFXS_ALPHA_TEST_GE_255 = 2,
|
||||
GFXS_ALPHA_TEST_GE_128 = 3,
|
||||
|
||||
GFXS_ALPHA_TEST_COUNT
|
||||
};
|
||||
|
||||
enum GfxCullFace_e
|
||||
{
|
||||
GFXS_CULL_NONE = 1,
|
||||
GFXS_CULL_BACK = 2,
|
||||
GFXS_CULL_FRONT = 3,
|
||||
};
|
||||
|
||||
enum GfxDepthTest_e
|
||||
{
|
||||
GFXS_DEPTHTEST_ALWAYS = 0,
|
||||
GFXS_DEPTHTEST_LESS = 1,
|
||||
GFXS_DEPTHTEST_EQUAL = 2,
|
||||
GFXS_DEPTHTEST_LESSEQUAL = 3
|
||||
};
|
||||
|
||||
enum GfxPolygonOffset_e
|
||||
{
|
||||
GFXS_POLYGON_OFFSET_0 = 0,
|
||||
GFXS_POLYGON_OFFSET_1 = 1,
|
||||
GFXS_POLYGON_OFFSET_2 = 2,
|
||||
GFXS_POLYGON_OFFSET_SHADOWMAP = 3
|
||||
};
|
||||
|
||||
enum GfxStencilOp : unsigned int
|
||||
{
|
||||
GFXS_STENCILOP_KEEP = 0x0,
|
||||
GFXS_STENCILOP_ZERO = 0x1,
|
||||
GFXS_STENCILOP_REPLACE = 0x2,
|
||||
GFXS_STENCILOP_INCRSAT = 0x3,
|
||||
GFXS_STENCILOP_DECRSAT = 0x4,
|
||||
GFXS_STENCILOP_INVERT = 0x5,
|
||||
GFXS_STENCILOP_INCR = 0x6,
|
||||
GFXS_STENCILOP_DECR = 0x7,
|
||||
|
||||
GFXS_STENCILOP_COUNT,
|
||||
GFXS_STENCILOP_MASK = 0x7
|
||||
};
|
||||
|
||||
enum GfxStencilFunc : unsigned int
|
||||
{
|
||||
GFXS_STENCILFUNC_NEVER = 0x0,
|
||||
GFXS_STENCILFUNC_LESS = 0x1,
|
||||
GFXS_STENCILFUNC_EQUAL = 0x2,
|
||||
GFXS_STENCILFUNC_LESSEQUAL = 0x3,
|
||||
GFXS_STENCILFUNC_GREATER = 0x4,
|
||||
GFXS_STENCILFUNC_NOTEQUAL = 0x5,
|
||||
GFXS_STENCILFUNC_GREATEREQUAL = 0x6,
|
||||
GFXS_STENCILFUNC_ALWAYS = 0x7,
|
||||
|
||||
GFXS_STENCILFUNC_COUNT,
|
||||
GFXS_STENCILFUNC_MASK = 0x7
|
||||
};
|
||||
|
||||
enum GfxStateBitsEnum : unsigned int
|
||||
@@ -868,9 +1015,64 @@ namespace T5
|
||||
GFXS1_STENCILOP_FRONTBACK_MASK = 0x1FF1FF00,
|
||||
};
|
||||
|
||||
struct GfxStateBitsLoadBitsStructured
|
||||
{
|
||||
// Byte 0
|
||||
unsigned int srcBlendRgb : 4; // 0-3
|
||||
unsigned int dstBlendRgb : 4; // 4-7
|
||||
unsigned int blendOpRgb : 3; // 8-10
|
||||
unsigned int alphaTestDisabled : 1; // 11
|
||||
unsigned int alphaTest : 2; // 12-13
|
||||
unsigned int cullFace : 2; // 14-15
|
||||
unsigned int srcBlendAlpha : 4; // 16-19
|
||||
unsigned int dstBlendAlpha : 4; // 20-23
|
||||
unsigned int blendOpAlpha : 3; // 24-26
|
||||
unsigned int colorWriteRgb : 1; // 27
|
||||
unsigned int colorWriteAlpha : 1; // 28
|
||||
unsigned int unused0 : 2; // 29-30
|
||||
unsigned int polymodeLine : 1; // 31
|
||||
|
||||
// Byte 1
|
||||
unsigned int depthWrite : 1; // 0
|
||||
unsigned int depthTestDisabled : 1; // 1
|
||||
unsigned int depthTest : 2; // 2-3
|
||||
unsigned int polygonOffset : 2; // 4-5
|
||||
unsigned int stencilFrontEnabled : 1; // 6
|
||||
unsigned int stencilBackEnabled : 1; // 7
|
||||
unsigned int stencilFrontPass : 3; // 8-10
|
||||
unsigned int stencilFrontFail : 3; // 11-13
|
||||
unsigned int stencilFrontZFail : 3; // 14-16
|
||||
unsigned int stencilFrontFunc : 3; // 17-19
|
||||
unsigned int stencilBackPass : 3; // 20-22
|
||||
unsigned int stencilBackFail : 3; // 23-25
|
||||
unsigned int stencilBackZFail : 3; // 26-28
|
||||
unsigned int stencilBackFunc : 3; // 29-31
|
||||
};
|
||||
|
||||
union GfxStateBitsLoadBits
|
||||
{
|
||||
unsigned int raw[2];
|
||||
GfxStateBitsLoadBitsStructured structured;
|
||||
};
|
||||
|
||||
#ifndef __zonecodegenerator
|
||||
static_assert(sizeof(GfxStateBitsLoadBits) == 8);
|
||||
static_assert(sizeof(GfxStateBitsLoadBitsStructured) == 8);
|
||||
#endif
|
||||
|
||||
struct GfxStateBits
|
||||
{
|
||||
unsigned int loadBits[2];
|
||||
GfxStateBitsLoadBits loadBits;
|
||||
};
|
||||
|
||||
enum GfxCameraRegionType
|
||||
{
|
||||
CAMERA_REGION_LIT = 0x0,
|
||||
CAMERA_REGION_DECAL = 0x1,
|
||||
CAMERA_REGION_EMISSIVE = 0x2,
|
||||
|
||||
CAMERA_REGION_COUNT,
|
||||
CAMERA_REGION_NONE = CAMERA_REGION_COUNT,
|
||||
};
|
||||
|
||||
struct Material
|
||||
@@ -880,8 +1082,8 @@ namespace T5
|
||||
unsigned char textureCount;
|
||||
unsigned char constantCount;
|
||||
unsigned char stateBitsCount;
|
||||
char stateFlags;
|
||||
char cameraRegion;
|
||||
unsigned char stateFlags;
|
||||
unsigned char cameraRegion;
|
||||
unsigned char maxStreamedMips;
|
||||
MaterialTechniqueSet* techniqueSet;
|
||||
MaterialTextureDef* textureTable;
|
||||
|
||||
@@ -21,24 +21,6 @@ const std::string& Game::GetShortName() const
|
||||
return shortName;
|
||||
}
|
||||
|
||||
void Game::AddZone(Zone* zone)
|
||||
{
|
||||
m_zones.push_back(zone);
|
||||
}
|
||||
|
||||
void Game::RemoveZone(Zone* zone)
|
||||
{
|
||||
const auto foundEntry = std::ranges::find(m_zones, zone);
|
||||
|
||||
if (foundEntry != m_zones.end())
|
||||
m_zones.erase(foundEntry);
|
||||
}
|
||||
|
||||
const std::vector<Zone*>& Game::GetZones() const
|
||||
{
|
||||
return m_zones;
|
||||
}
|
||||
|
||||
const std::vector<GameLanguagePrefix>& Game::GetLanguagePrefixes() const
|
||||
{
|
||||
static std::vector<GameLanguagePrefix> prefixes{
|
||||
|
||||
@@ -9,12 +9,6 @@ namespace T6
|
||||
[[nodiscard]] GameId GetId() const override;
|
||||
[[nodiscard]] const std::string& GetFullName() const override;
|
||||
[[nodiscard]] const std::string& GetShortName() const override;
|
||||
void AddZone(Zone* zone) override;
|
||||
void RemoveZone(Zone* zone) override;
|
||||
[[nodiscard]] const std::vector<Zone*>& GetZones() const override;
|
||||
[[nodiscard]] const std::vector<GameLanguagePrefix>& GetLanguagePrefixes() const override;
|
||||
|
||||
private:
|
||||
std::vector<Zone*> m_zones;
|
||||
};
|
||||
} // namespace T6
|
||||
|
||||
@@ -700,6 +700,8 @@ namespace T6
|
||||
MTL_GAMEFLAG_400 = 0x400,
|
||||
MTL_GAMEFLAG_800 = 0x800,
|
||||
MTL_GAMEFLAG_1000 = 0x1000,
|
||||
MTL_GAMEFLAG_2000 = 0x2000,
|
||||
MTL_GAMEFLAG_4000 = 0x4000,
|
||||
};
|
||||
|
||||
struct type_align32(8) MaterialInfo
|
||||
@@ -2765,6 +2767,14 @@ namespace T6
|
||||
float transWeight;
|
||||
};
|
||||
|
||||
enum XSurfaceFlag
|
||||
{
|
||||
XSURFACE_FLAG_QUANTIZED = 0x1,
|
||||
XSURFACE_FLAG_SKINNED = 0x2,
|
||||
XSURFACE_FLAG_CONSTANT_COLOR = 0x4,
|
||||
XSURFACE_FLAG_DEFORMED = 0x80,
|
||||
};
|
||||
|
||||
struct XSurfaceVertexInfo
|
||||
{
|
||||
int16_t vertCount[4];
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "Image/IwiWriter8.h"
|
||||
#include "Image/Texture.h"
|
||||
#include "ImageConverterArgs.h"
|
||||
#include "Utils/Logging/Log.h"
|
||||
#include "Utils/StringUtils.h"
|
||||
|
||||
#include <assert.h>
|
||||
@@ -61,7 +62,7 @@ namespace image_converter
|
||||
else if (extension == EXTENSION_DDS)
|
||||
ConvertDds(filePath);
|
||||
else
|
||||
std::cerr << std::format("Unsupported extension {}\n", extension);
|
||||
con::error("Unsupported extension {}", extension);
|
||||
}
|
||||
|
||||
bool ConvertIwi(const fs::path& iwiPath)
|
||||
@@ -69,7 +70,7 @@ namespace image_converter
|
||||
std::ifstream file(iwiPath, std::ios::in | std::ios::binary);
|
||||
if (!file.is_open())
|
||||
{
|
||||
std::cerr << std::format("Failed to open input file {}\n", iwiPath.string());
|
||||
con::error("Failed to open input file {}", iwiPath.string());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -83,7 +84,7 @@ namespace image_converter
|
||||
std::ofstream outFile(outPath, std::ios::out | std::ios::binary);
|
||||
if (!outFile.is_open())
|
||||
{
|
||||
std::cerr << std::format("Failed to open output file {}\n", outPath.string());
|
||||
con::error("Failed to open output file {}", outPath.string());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -96,7 +97,7 @@ namespace image_converter
|
||||
std::ifstream file(ddsPath, std::ios::in | std::ios::binary);
|
||||
if (!file.is_open())
|
||||
{
|
||||
std::cerr << std::format("Failed to open input file {}\n", ddsPath.string());
|
||||
con::error("Failed to open input file {}", ddsPath.string());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -113,7 +114,7 @@ namespace image_converter
|
||||
std::ofstream outFile(outPath, std::ios::out | std::ios::binary);
|
||||
if (!outFile.is_open())
|
||||
{
|
||||
std::cerr << std::format("Failed to open output file {}\n", outPath.string());
|
||||
con::error("Failed to open output file {}", outPath.string());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -154,12 +155,12 @@ namespace image_converter
|
||||
|
||||
bool ShowGameTui()
|
||||
{
|
||||
std::cout << "Select the game to convert to:\n";
|
||||
std::cout << " 1 - Call Of Duty 4: Modern Warfare (IW3)\n";
|
||||
std::cout << " 2 - Call Of Duty: Modern Warfare 2 (IW4)\n";
|
||||
std::cout << " 3 - Call Of Duty: Modern Warfare 3 (IW5)\n";
|
||||
std::cout << " 4 - Call Of Duty: Black Ops (T5)\n";
|
||||
std::cout << " 5 - Call Of Duty: Black Ops 2 (T6)\n";
|
||||
con::info("Select the game to convert to:");
|
||||
con::info(" 1 - Call Of Duty 4: Modern Warfare (IW3)");
|
||||
con::info(" 2 - Call Of Duty: Modern Warfare 2 (IW4)");
|
||||
con::info(" 3 - Call Of Duty: Modern Warfare 3 (IW5)");
|
||||
con::info(" 4 - Call Of Duty: Black Ops (T5)");
|
||||
con::info(" 5 - Call Of Duty: Black Ops 2 (T6)");
|
||||
|
||||
unsigned num;
|
||||
std::cin >> num;
|
||||
@@ -182,7 +183,7 @@ namespace image_converter
|
||||
m_game_to_convert_to = Game::T6;
|
||||
break;
|
||||
default:
|
||||
std::cerr << "Invalid input\n";
|
||||
con::error("Invalid input");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "GitVersion.h"
|
||||
#include "Utils/Arguments/UsageInformation.h"
|
||||
#include "Utils/Logging/Log.h"
|
||||
|
||||
#include <format>
|
||||
#include <iostream>
|
||||
@@ -28,6 +29,12 @@ const CommandLineOption* const OPTION_VERBOSE =
|
||||
.WithDescription("Outputs a lot more and more detailed messages.")
|
||||
.Build();
|
||||
|
||||
const CommandLineOption* const OPTION_NO_COLOR =
|
||||
CommandLineOption::Builder::Create()
|
||||
.WithLongName("no-color")
|
||||
.WithDescription("Disables colored terminal output.")
|
||||
.Build();
|
||||
|
||||
constexpr auto CATEGORY_GAME = "Game";
|
||||
|
||||
const CommandLineOption* const OPTION_GAME_IW3 =
|
||||
@@ -70,6 +77,7 @@ const CommandLineOption* const COMMAND_LINE_OPTIONS[]{
|
||||
OPTION_HELP,
|
||||
OPTION_VERSION,
|
||||
OPTION_VERBOSE,
|
||||
OPTION_NO_COLOR,
|
||||
OPTION_GAME_IW3,
|
||||
OPTION_GAME_IW4,
|
||||
OPTION_GAME_IW5,
|
||||
@@ -78,8 +86,7 @@ const CommandLineOption* const COMMAND_LINE_OPTIONS[]{
|
||||
};
|
||||
|
||||
ImageConverterArgs::ImageConverterArgs()
|
||||
: m_verbose(false),
|
||||
m_game_to_convert_to(image_converter::Game::UNKNOWN),
|
||||
: m_game_to_convert_to(image_converter::Game::UNKNOWN),
|
||||
m_argument_parser(COMMAND_LINE_OPTIONS, std::extent_v<decltype(COMMAND_LINE_OPTIONS)>)
|
||||
{
|
||||
}
|
||||
@@ -101,12 +108,7 @@ void ImageConverterArgs::PrintUsage()
|
||||
|
||||
void ImageConverterArgs::PrintVersion()
|
||||
{
|
||||
std::cout << std::format("OpenAssetTools ImageConverter {}\n", GIT_VERSION);
|
||||
}
|
||||
|
||||
void ImageConverterArgs::SetVerbose(const bool isVerbose)
|
||||
{
|
||||
m_verbose = isVerbose;
|
||||
con::info("OpenAssetTools ImageConverter {}", GIT_VERSION);
|
||||
}
|
||||
|
||||
bool ImageConverterArgs::ParseArgs(const int argc, const char** argv, bool& shouldContinue)
|
||||
@@ -143,7 +145,13 @@ bool ImageConverterArgs::ParseArgs(const int argc, const char** argv, bool& shou
|
||||
}
|
||||
|
||||
// -v; --verbose
|
||||
SetVerbose(m_argument_parser.IsOptionSpecified(OPTION_VERBOSE));
|
||||
if (m_argument_parser.IsOptionSpecified(OPTION_VERBOSE))
|
||||
con::globalLogLevel = con::LogLevel::DEBUG;
|
||||
else
|
||||
con::globalLogLevel = con::LogLevel::INFO;
|
||||
|
||||
// --no-color
|
||||
con::globalUseColor = !m_argument_parser.IsOptionSpecified(OPTION_NO_COLOR);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ public:
|
||||
ImageConverterArgs();
|
||||
bool ParseArgs(int argc, const char** argv, bool& shouldContinue);
|
||||
|
||||
bool m_verbose;
|
||||
std::vector<std::string> m_files_to_convert;
|
||||
image_converter::Game m_game_to_convert_to;
|
||||
|
||||
@@ -36,7 +35,5 @@ private:
|
||||
static void PrintUsage();
|
||||
static void PrintVersion();
|
||||
|
||||
void SetVerbose(bool isVerbose);
|
||||
|
||||
ArgumentParser m_argument_parser;
|
||||
};
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "ObjWriting.h"
|
||||
#include "SearchPath/OutputPathFilesystem.h"
|
||||
#include "SearchPath/SearchPaths.h"
|
||||
#include "Utils/Logging/Log.h"
|
||||
#include "Utils/ObjFileStream.h"
|
||||
#include "Zone/AssetList/AssetList.h"
|
||||
#include "Zone/AssetList/AssetListReader.h"
|
||||
@@ -165,7 +166,7 @@ class LinkerImpl final : public Linker
|
||||
if (!definitionStream.IsOpen())
|
||||
{
|
||||
if (logMissing)
|
||||
std::cerr << std::format("Could not find zone definition file for target \"{}\".\n", targetName);
|
||||
con::error("Could not find zone definition file for target \"{}\".", targetName);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -175,7 +176,7 @@ class LinkerImpl final : public Linker
|
||||
|
||||
if (!zoneDefinition)
|
||||
{
|
||||
std::cerr << std::format("Failed to read zone definition file for target \"{}\".\n", targetName);
|
||||
con::error("Failed to read zone definition file for target \"{}\".", targetName);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -225,7 +226,7 @@ class LinkerImpl final : public Linker
|
||||
|
||||
if (!ReadIgnoreEntries(paths, ignore, context.m_definition->m_game, context.m_ignored_assets))
|
||||
{
|
||||
std::cerr << std::format("Failed to read asset listing for ignoring assets of project \"{}\".\n", ignore);
|
||||
con::error("Failed to read asset listing for ignoring assets of project \"{}\".", ignore);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -239,7 +240,7 @@ class LinkerImpl final : public Linker
|
||||
const auto gdtFile = gdtSearchPath->Open(std::format("{}.gdt", gdtName));
|
||||
if (!gdtFile.IsOpen())
|
||||
{
|
||||
std::cerr << std::format("Failed to open file for gdt \"{}\"\n", gdtName);
|
||||
con::error("Failed to open file for gdt \"{}\"", gdtName);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -247,7 +248,7 @@ class LinkerImpl final : public Linker
|
||||
auto gdt = std::make_unique<Gdt>();
|
||||
if (!gdtReader.Read(*gdt))
|
||||
{
|
||||
std::cerr << std::format("Failed to read gdt file \"{}\"\n", gdtName);
|
||||
con::error("Failed to read gdt file \"{}\"", gdtName);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -274,19 +275,19 @@ class LinkerImpl final : public Linker
|
||||
const auto stream = outPath.Open(std::format("{}.ff", zone.m_name));
|
||||
if (!stream)
|
||||
{
|
||||
std::cerr << std::format("Failed to open file for zone: {}\n", zone.m_name);
|
||||
con::error("Failed to open file for zone: {}", zone.m_name);
|
||||
return false;
|
||||
}
|
||||
|
||||
std::cout << std::format("Building zone \"{}\"\n", zone.m_name);
|
||||
con::info("Building zone \"{}\"", zone.m_name);
|
||||
|
||||
if (!ZoneWriting::WriteZone(*stream, zone))
|
||||
{
|
||||
std::cerr << "Writing zone failed.\n";
|
||||
con::error("Writing zone failed.");
|
||||
return false;
|
||||
}
|
||||
|
||||
std::cout << std::format("Created zone \"{}\"\n", zone.m_name);
|
||||
con::info("Created zone \"{}\"", zone.m_name);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -339,7 +340,7 @@ class LinkerImpl final : public Linker
|
||||
if (alreadyBuiltTargets.find(referencedTarget) == alreadyBuiltTargets.end())
|
||||
{
|
||||
targetsToBuild.emplace_back(referencedTarget);
|
||||
std::cout << std::format("Building referenced target \"{}\"\n", referencedTarget);
|
||||
con::info("Building referenced target \"{}\"", referencedTarget);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -354,7 +355,7 @@ class LinkerImpl final : public Linker
|
||||
{
|
||||
if (!fs::is_regular_file(zonePath))
|
||||
{
|
||||
std::cerr << std::format("Could not find zone file to load \"{}\".\n", zonePath);
|
||||
con::error("Could not find zone file to load \"{}\".", zonePath);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -366,14 +367,11 @@ class LinkerImpl final : public Linker
|
||||
auto zone = ZoneLoading::LoadZone(zonePath);
|
||||
if (!zone)
|
||||
{
|
||||
std::cerr << std::format("Failed to load zone \"{}\".\n", zonePath);
|
||||
con::error("Failed to load zone \"{}\".", zonePath);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_args.m_verbose)
|
||||
{
|
||||
std::cout << std::format("Load zone \"{}\"\n", zone->m_name);
|
||||
}
|
||||
con::debug("Load zone \"{}\"", zone->m_name);
|
||||
|
||||
m_loaded_zones.emplace_back(std::move(zone));
|
||||
}
|
||||
@@ -390,8 +388,7 @@ class LinkerImpl final : public Linker
|
||||
|
||||
loadedZone.reset();
|
||||
|
||||
if (m_args.m_verbose)
|
||||
std::cout << std::format("Unloaded zone \"{}\"\n", zoneName);
|
||||
con::debug("Unloaded zone \"{}\"", zoneName);
|
||||
}
|
||||
m_loaded_zones.clear();
|
||||
}
|
||||
@@ -406,7 +403,7 @@ class LinkerImpl final : public Linker
|
||||
}
|
||||
else if (projectSpecifier.find_first_of('/', targetNameSeparatorIndex + 1) != std::string::npos)
|
||||
{
|
||||
std::cerr << std::format("Project specifier cannot have more than one target name: \"{}\"\n", projectSpecifier);
|
||||
con::error("Project specifier cannot have more than one target name: \"{}\"", projectSpecifier);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
@@ -417,13 +414,13 @@ class LinkerImpl final : public Linker
|
||||
|
||||
if (projectName.empty())
|
||||
{
|
||||
std::cerr << std::format("Project name cannot be empty: \"{}\"\n", projectSpecifier);
|
||||
con::error("Project name cannot be empty: \"{}\"", projectSpecifier);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (targetName.empty())
|
||||
{
|
||||
std::cerr << std::format("Target name cannot be empty: \"{}\"\n", projectSpecifier);
|
||||
con::error("Target name cannot be empty: \"{}\"", projectSpecifier);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "ObjWriting.h"
|
||||
#include "Utils/Arguments/UsageInformation.h"
|
||||
#include "Utils/FileUtils.h"
|
||||
#include "Utils/Logging/Log.h"
|
||||
#include "Utils/PathUtils.h"
|
||||
|
||||
#include <filesystem>
|
||||
@@ -35,6 +36,12 @@ const CommandLineOption* const OPTION_VERBOSE =
|
||||
.WithDescription("Outputs a lot more and more detailed messages.")
|
||||
.Build();
|
||||
|
||||
const CommandLineOption* const OPTION_NO_COLOR =
|
||||
CommandLineOption::Builder::Create()
|
||||
.WithLongName("no-color")
|
||||
.WithDescription("Disables colored terminal output.")
|
||||
.Build();
|
||||
|
||||
const CommandLineOption* const OPTION_BASE_FOLDER =
|
||||
CommandLineOption::Builder::Create()
|
||||
.WithShortName("b")
|
||||
@@ -115,6 +122,7 @@ const CommandLineOption* const COMMAND_LINE_OPTIONS[]{
|
||||
OPTION_HELP,
|
||||
OPTION_VERSION,
|
||||
OPTION_VERBOSE,
|
||||
OPTION_NO_COLOR,
|
||||
OPTION_BASE_FOLDER,
|
||||
OPTION_OUTPUT_FOLDER,
|
||||
OPTION_ADD_ASSET_SEARCH_PATH,
|
||||
@@ -128,8 +136,7 @@ const CommandLineOption* const COMMAND_LINE_OPTIONS[]{
|
||||
};
|
||||
|
||||
LinkerArgs::LinkerArgs()
|
||||
: m_verbose(false),
|
||||
m_argument_parser(COMMAND_LINE_OPTIONS, std::extent_v<decltype(COMMAND_LINE_OPTIONS)>)
|
||||
: m_argument_parser(COMMAND_LINE_OPTIONS, std::extent_v<decltype(COMMAND_LINE_OPTIONS)>)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -150,7 +157,7 @@ void LinkerArgs::PrintUsage() const
|
||||
|
||||
void LinkerArgs::PrintVersion()
|
||||
{
|
||||
std::cout << std::format("OpenAssetTools Linker {}\n", GIT_VERSION);
|
||||
con::info("OpenAssetTools Linker {}", GIT_VERSION);
|
||||
}
|
||||
|
||||
void LinkerArgs::SetBinFolder()
|
||||
@@ -159,13 +166,6 @@ void LinkerArgs::SetBinFolder()
|
||||
m_bin_folder = path.parent_path().string();
|
||||
}
|
||||
|
||||
void LinkerArgs::SetVerbose(const bool isVerbose)
|
||||
{
|
||||
m_verbose = isVerbose;
|
||||
ObjLoading::Configuration.Verbose = isVerbose;
|
||||
ObjWriting::Configuration.Verbose = isVerbose;
|
||||
}
|
||||
|
||||
bool LinkerArgs::ParseArgs(const int argc, const char** argv, bool& shouldContinue)
|
||||
{
|
||||
shouldContinue = true;
|
||||
@@ -202,7 +202,13 @@ bool LinkerArgs::ParseArgs(const int argc, const char** argv, bool& shouldContin
|
||||
}
|
||||
|
||||
// -v; --verbose
|
||||
SetVerbose(m_argument_parser.IsOptionSpecified(OPTION_VERBOSE));
|
||||
if (m_argument_parser.IsOptionSpecified(OPTION_VERBOSE))
|
||||
con::globalLogLevel = con::LogLevel::DEBUG;
|
||||
else
|
||||
con::globalLogLevel = con::LogLevel::INFO;
|
||||
|
||||
// --no-color
|
||||
con::globalUseColor = !m_argument_parser.IsOptionSpecified(OPTION_NO_COLOR);
|
||||
|
||||
// b; --base-folder
|
||||
if (m_argument_parser.IsOptionSpecified(OPTION_BASE_FOLDER))
|
||||
|
||||
@@ -17,8 +17,6 @@ public:
|
||||
LinkerArgs();
|
||||
bool ParseArgs(int argc, const char** argv, bool& shouldContinue);
|
||||
|
||||
bool m_verbose;
|
||||
|
||||
std::vector<std::string> m_zones_to_load;
|
||||
std::vector<std::string> m_project_specifiers_to_build;
|
||||
|
||||
@@ -38,7 +36,6 @@ private:
|
||||
static void PrintVersion();
|
||||
|
||||
void SetBinFolder();
|
||||
void SetVerbose(bool isVerbose);
|
||||
|
||||
ArgumentParser m_argument_parser;
|
||||
};
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "SearchPath/IWD.h"
|
||||
#include "SearchPath/SearchPathFilesystem.h"
|
||||
#include "SearchPath/SearchPaths.h"
|
||||
#include "Utils/Logging/Log.h"
|
||||
#include "Utils/StringUtils.h"
|
||||
|
||||
#include <cassert>
|
||||
@@ -241,11 +242,11 @@ namespace
|
||||
|
||||
if (!fs::is_directory(path))
|
||||
{
|
||||
std::cout << std::format("Adding {} search path (Not found): {}\n", m_type_name, path);
|
||||
con::debug("Adding {} search path (Not found): {}", m_type_name, path);
|
||||
return false;
|
||||
}
|
||||
|
||||
std::cout << std::format("Adding {} search path: {}\n", m_type_name, path);
|
||||
con::debug("Adding {} search path: {}", m_type_name, path);
|
||||
searchPaths.CommitSearchPath(std::make_unique<SearchPathFilesystem>(path));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace
|
||||
{
|
||||
std::unique_ptr<Zone> CreateZone(const ZoneCreationContext& context, const GameId gameId)
|
||||
{
|
||||
return std::make_unique<Zone>(context.m_definition->m_name, 0, IGame::GetGameById(gameId));
|
||||
return std::make_unique<Zone>(context.m_definition->m_name, 0, gameId);
|
||||
}
|
||||
|
||||
std::vector<Gdt*> CreateGdtList(const ZoneCreationContext& context)
|
||||
|
||||
56
src/ModMan.lua
Normal file
56
src/ModMan.lua
Normal file
@@ -0,0 +1,56 @@
|
||||
ModMan = {}
|
||||
|
||||
function ModMan:include(includes)
|
||||
if includes:handle(self:name()) then
|
||||
includedirs {
|
||||
path.join(ProjectFolder(), "ModMan")
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
function ModMan:link(links)
|
||||
|
||||
end
|
||||
|
||||
function ModMan:use()
|
||||
dependson(self:name())
|
||||
end
|
||||
|
||||
function ModMan:name()
|
||||
return "ModMan"
|
||||
end
|
||||
|
||||
function ModMan:project()
|
||||
local folder = ProjectFolder()
|
||||
local includes = Includes:create()
|
||||
local links = Links:create()
|
||||
|
||||
project(self:name())
|
||||
targetdir(TargetDirectoryBin)
|
||||
location "%{wks.location}/src/%{prj.name}"
|
||||
kind "WindowedApp"
|
||||
language "C++"
|
||||
|
||||
files {
|
||||
path.join(folder, "ModMan/**.h"),
|
||||
path.join(folder, "ModMan/**.cpp")
|
||||
}
|
||||
|
||||
includedirs {
|
||||
"%{wks.location}/src/ModMan"
|
||||
}
|
||||
|
||||
filter { "system:linux", "action:gmake" }
|
||||
buildoptions { "`pkg-config --cflags gtk4 webkitgtk-6.0`" }
|
||||
linkoptions { "`pkg-config --libs gtk4 webkitgtk-6.0`" }
|
||||
filter {}
|
||||
|
||||
self:include(includes)
|
||||
Utils:include(includes)
|
||||
json:include(includes)
|
||||
webview:include(includes)
|
||||
|
||||
links:linkto(Utils)
|
||||
links:linkto(webview)
|
||||
links:linkall()
|
||||
end
|
||||
41
src/ModMan/README.md
Normal file
41
src/ModMan/README.md
Normal file
@@ -0,0 +1,41 @@
|
||||
# ModMan
|
||||
|
||||
ModMan is the experimental GUI for OpenAssetTools.
|
||||
|
||||
## How do I test it
|
||||
|
||||
Currently ModMan is not compiled by default.
|
||||
To enable it, you have to generate with the appropriate premake5 flag:
|
||||
|
||||
```shell
|
||||
# On Windows
|
||||
./generate.bat --modman
|
||||
|
||||
# On Linux
|
||||
./generate.sh --modman
|
||||
```
|
||||
|
||||
**Before** building the C++ solution, the ui has to be built.
|
||||
This will require NodeJS to be installed on your machine.
|
||||
|
||||
```shell
|
||||
# Download dependencies
|
||||
npm --prefix src/ModManUi install
|
||||
|
||||
# Build frontend
|
||||
npm --prefix src/ModManUi run build
|
||||
|
||||
# Optional: Dev Server for UI development
|
||||
npm --prefix src/ModManUi run dev
|
||||
```
|
||||
|
||||
## How does it work
|
||||
|
||||
ModMan uses [`webview`](https://github.com/Laupetin/webview) for providing a web frontend as a native application.
|
||||
Unlike frameworks like Electron this does not ship a browser engine alongside it, but instead relies on browser APIs of your OS.
|
||||
On Windows, this makes use of [WebView2](https://learn.microsoft.com/en-us/microsoft-edge/webview2), on Linux it uses [WebKitGTK](https://webkitgtk.org).
|
||||
|
||||
This adds the following dependencies:
|
||||
* **Windows**: An up-to-date OS with at the very least Windows10. The WebView2 library for development is downloaded by premake.
|
||||
* **Linux**: Developing and using ModMan requires the following dependencies to be installed: `gtk4 webkitgtk-6.0`
|
||||
|
||||
187
src/ModMan/Web/Edge/AssetHandlerEdge.cpp
Normal file
187
src/ModMan/Web/Edge/AssetHandlerEdge.cpp
Normal file
@@ -0,0 +1,187 @@
|
||||
#include "AssetHandlerEdge.h"
|
||||
|
||||
#if defined(WEBVIEW_PLATFORM_WINDOWS) && defined(WEBVIEW_EDGE)
|
||||
|
||||
#include "Web/UiAssets.h"
|
||||
|
||||
#include <Windows.h>
|
||||
#include <format>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <webview/detail/backends/win32_edge.hh>
|
||||
#include <wrl/event.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
constexpr auto LOCALHOST_PREFIX = "http://localhost:";
|
||||
|
||||
std::unordered_map<std::string, UiFile> assetLookup;
|
||||
|
||||
std::string WideStringToString(const std::wstring& wideString)
|
||||
{
|
||||
if (wideString.empty())
|
||||
return "";
|
||||
|
||||
const auto sizeNeeded = WideCharToMultiByte(CP_UTF8, 0, wideString.data(), static_cast<int>(wideString.size()), nullptr, 0, nullptr, nullptr);
|
||||
if (sizeNeeded <= 0)
|
||||
throw std::runtime_error(std::format("WideCharToMultiByte() failed: {}", sizeNeeded));
|
||||
|
||||
std::string result(sizeNeeded, 0);
|
||||
WideCharToMultiByte(CP_UTF8, 0, wideString.data(), static_cast<int>(wideString.size()), result.data(), sizeNeeded, nullptr, nullptr);
|
||||
return result;
|
||||
}
|
||||
|
||||
std::wstring StringToWideString(const std::string& string)
|
||||
{
|
||||
if (string.empty())
|
||||
return L"";
|
||||
|
||||
const auto sizeNeeded = MultiByteToWideChar(CP_UTF8, 0, string.data(), static_cast<int>(string.size()), nullptr, 0);
|
||||
if (sizeNeeded <= 0)
|
||||
throw std::runtime_error(std::format("MultiByteToWideChar() failed: {}", sizeNeeded));
|
||||
|
||||
std::wstring result(sizeNeeded, 0);
|
||||
MultiByteToWideChar(CP_UTF8, 0, string.data(), static_cast<int>(string.size()), result.data(), sizeNeeded);
|
||||
return result;
|
||||
}
|
||||
|
||||
std::wstring HeadersForAssetName(const std::string& assetName, const size_t contentLength)
|
||||
{
|
||||
std::wstringstream wss;
|
||||
|
||||
wss << std::format(L"Content-Length: {}\n", contentLength);
|
||||
wss << L"Content-Type: " << StringToWideString(ui::GetMimeTypeForFileName(assetName));
|
||||
|
||||
return wss.str();
|
||||
}
|
||||
|
||||
HRESULT HandleResourceRequested(ICoreWebView2_22* core22, IUnknown* args)
|
||||
{
|
||||
Microsoft::WRL::ComPtr<ICoreWebView2WebResourceRequestedEventArgs2> webResourceRequestArgs;
|
||||
if (SUCCEEDED(args->QueryInterface(IID_PPV_ARGS(&webResourceRequestArgs))))
|
||||
{
|
||||
COREWEBVIEW2_WEB_RESOURCE_REQUEST_SOURCE_KINDS requestSourceKind = COREWEBVIEW2_WEB_RESOURCE_REQUEST_SOURCE_KINDS_ALL;
|
||||
if (!SUCCEEDED(webResourceRequestArgs->get_RequestedSourceKind(&requestSourceKind)))
|
||||
{
|
||||
std::cerr << "Failed to get requested source kind\n";
|
||||
return S_FALSE;
|
||||
}
|
||||
|
||||
Microsoft::WRL::ComPtr<ICoreWebView2WebResourceRequest> request;
|
||||
if (!SUCCEEDED(webResourceRequestArgs->get_Request(&request)))
|
||||
{
|
||||
std::cerr << "Failed to get request\n";
|
||||
return S_FALSE;
|
||||
}
|
||||
|
||||
LPWSTR wUri;
|
||||
if (!SUCCEEDED(request->get_Uri(&wUri)))
|
||||
{
|
||||
std::cerr << "Failed to get uri\n";
|
||||
return S_FALSE;
|
||||
}
|
||||
|
||||
Microsoft::WRL::ComPtr<ICoreWebView2Environment> environment;
|
||||
if (!SUCCEEDED(core22->get_Environment(&environment)))
|
||||
{
|
||||
std::cerr << "Failed to get environment\n";
|
||||
return S_FALSE;
|
||||
}
|
||||
|
||||
Microsoft::WRL::ComPtr<ICoreWebView2WebResourceResponse> response;
|
||||
|
||||
const auto uri = WideStringToString(wUri);
|
||||
bool fileFound = false;
|
||||
|
||||
#ifdef _DEBUG
|
||||
// Allow dev server access
|
||||
if (uri.starts_with(LOCALHOST_PREFIX))
|
||||
return S_OK;
|
||||
#endif
|
||||
|
||||
if (uri.starts_with(edge::URL_PREFIX))
|
||||
{
|
||||
const auto asset = uri.substr(std::char_traits<char>::length(edge::URL_PREFIX) - 1);
|
||||
|
||||
const auto foundUiFile = assetLookup.find(asset);
|
||||
if (foundUiFile != assetLookup.end())
|
||||
{
|
||||
const Microsoft::WRL::ComPtr<IStream> responseStream =
|
||||
SHCreateMemStream(static_cast<const BYTE*>(foundUiFile->second.data), foundUiFile->second.dataSize);
|
||||
|
||||
const auto headers = HeadersForAssetName(asset, foundUiFile->second.dataSize);
|
||||
if (!SUCCEEDED(environment->CreateWebResourceResponse(responseStream.Get(), 200, L"OK", headers.data(), &response)))
|
||||
{
|
||||
std::cerr << "Failed to create web resource\n";
|
||||
return S_FALSE;
|
||||
}
|
||||
|
||||
fileFound = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!fileFound)
|
||||
{
|
||||
if (!SUCCEEDED(environment->CreateWebResourceResponse(nullptr, 404, L"Not found", L"", &response)))
|
||||
{
|
||||
std::cerr << "Failed to create web resource\n";
|
||||
return S_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!SUCCEEDED(webResourceRequestArgs->put_Response(response.Get())))
|
||||
{
|
||||
std::cerr << "Failed to put response\n";
|
||||
return S_FALSE;
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
return S_FALSE;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace edge
|
||||
{
|
||||
void InstallCustomProtocolHandler(webview::webview& wv)
|
||||
{
|
||||
assetLookup = ui::BuildUiFileLookup();
|
||||
|
||||
const auto controller = static_cast<ICoreWebView2Controller*>(wv.browser_controller().value());
|
||||
Microsoft::WRL::ComPtr<ICoreWebView2> core;
|
||||
if (!SUCCEEDED(controller->get_CoreWebView2(&core)))
|
||||
{
|
||||
std::cerr << "Failed to get webview\n";
|
||||
return;
|
||||
}
|
||||
|
||||
Microsoft::WRL::ComPtr<ICoreWebView2_22> core22;
|
||||
if (!SUCCEEDED(core->QueryInterface(IID_PPV_ARGS(&core22))))
|
||||
{
|
||||
std::cerr << "Failed to get core22\n";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!SUCCEEDED(core22->AddWebResourceRequestedFilterWithRequestSourceKinds(
|
||||
L"*", COREWEBVIEW2_WEB_RESOURCE_CONTEXT_ALL, COREWEBVIEW2_WEB_RESOURCE_REQUEST_SOURCE_KINDS_ALL)))
|
||||
{
|
||||
std::cerr << "Failed to install request filter\n";
|
||||
return;
|
||||
}
|
||||
|
||||
EventRegistrationToken token;
|
||||
if (!SUCCEEDED(core->add_WebResourceRequested(Microsoft::WRL::Callback<ICoreWebView2WebResourceRequestedEventHandler>(
|
||||
[core22](ICoreWebView2* sender, IUnknown* args) -> HRESULT
|
||||
{
|
||||
return HandleResourceRequested(core22.Get(), args);
|
||||
})
|
||||
.Get(),
|
||||
&token)))
|
||||
{
|
||||
std::cerr << "Failed to add resource requested filter\n";
|
||||
}
|
||||
}
|
||||
} // namespace edge
|
||||
|
||||
#endif
|
||||
16
src/ModMan/Web/Edge/AssetHandlerEdge.h
Normal file
16
src/ModMan/Web/Edge/AssetHandlerEdge.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include <webview/macros.h>
|
||||
|
||||
#if defined(WEBVIEW_PLATFORM_WINDOWS) && defined(WEBVIEW_EDGE)
|
||||
|
||||
#include "Web/WebViewLib.h"
|
||||
|
||||
namespace edge
|
||||
{
|
||||
constexpr auto URL_PREFIX = "http://modman.local/";
|
||||
|
||||
void InstallCustomProtocolHandler(webview::webview& wv);
|
||||
} // namespace edge
|
||||
|
||||
#endif
|
||||
51
src/ModMan/Web/Gtk/AssetHandlerGtk.cpp
Normal file
51
src/ModMan/Web/Gtk/AssetHandlerGtk.cpp
Normal file
@@ -0,0 +1,51 @@
|
||||
#include "AssetHandlerGtk.h"
|
||||
|
||||
#if defined(WEBVIEW_PLATFORM_LINUX) && defined(WEBVIEW_GTK)
|
||||
|
||||
#include "Web/UiAssets.h"
|
||||
|
||||
#include <format>
|
||||
#include <iostream>
|
||||
|
||||
namespace
|
||||
{
|
||||
std::unordered_map<std::string, UiFile> assetLookup;
|
||||
|
||||
void ModManUriSchemeRequestCb(WebKitURISchemeRequest* request, gpointer user_data)
|
||||
{
|
||||
const gchar* asset = webkit_uri_scheme_request_get_path(request);
|
||||
|
||||
const auto foundUiFile = assetLookup.find(asset);
|
||||
if (foundUiFile != assetLookup.end())
|
||||
{
|
||||
gsize stream_length = foundUiFile->second.dataSize;
|
||||
GInputStream* stream = g_memory_input_stream_new_from_data(foundUiFile->second.data, foundUiFile->second.dataSize, nullptr);
|
||||
|
||||
webkit_uri_scheme_request_finish(request, stream, stream_length, ui::GetMimeTypeForFileName(foundUiFile->second.filename));
|
||||
g_object_unref(stream);
|
||||
}
|
||||
else
|
||||
{
|
||||
GError* error = g_error_new(G_SPAWN_ERROR, 123, "Could not find %s.", asset);
|
||||
webkit_uri_scheme_request_finish_error(request, error);
|
||||
g_error_free(error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace gtk
|
||||
{
|
||||
void InstallCustomProtocolHandler(webview::webview& wv)
|
||||
{
|
||||
const auto widget = static_cast<GtkWidget*>(wv.browser_controller().value());
|
||||
const auto webView = WEBKIT_WEB_VIEW(widget);
|
||||
const auto context = webkit_web_view_get_context(webView);
|
||||
|
||||
assetLookup = ui::BuildUiFileLookup();
|
||||
|
||||
webkit_web_context_register_uri_scheme(context, "modman", ModManUriSchemeRequestCb, NULL, nullptr);
|
||||
}
|
||||
} // namespace gtk
|
||||
|
||||
#endif
|
||||
16
src/ModMan/Web/Gtk/AssetHandlerGtk.h
Normal file
16
src/ModMan/Web/Gtk/AssetHandlerGtk.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include <webview/macros.h>
|
||||
|
||||
#if defined(WEBVIEW_PLATFORM_LINUX) && defined(WEBVIEW_GTK)
|
||||
|
||||
#include "Web/WebViewLib.h"
|
||||
|
||||
namespace gtk
|
||||
{
|
||||
constexpr auto URL_PREFIX = "modman://localhost/";
|
||||
|
||||
void InstallCustomProtocolHandler(webview::webview& wv);
|
||||
} // namespace gtk
|
||||
|
||||
#endif
|
||||
34
src/ModMan/Web/UiAssets.cpp
Normal file
34
src/ModMan/Web/UiAssets.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
#include "UiAssets.h"
|
||||
|
||||
#include <format>
|
||||
|
||||
namespace ui
|
||||
{
|
||||
std::unordered_map<std::string, UiFile> BuildUiFileLookup()
|
||||
{
|
||||
std::unordered_map<std::string, UiFile> result;
|
||||
|
||||
for (const auto& asset : MOD_MAN_UI_FILES)
|
||||
{
|
||||
result.emplace(std::format("/{}", asset.filename), asset);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
const char* GetMimeTypeForFileName(const std::string& fileName)
|
||||
{
|
||||
const char* mimeType;
|
||||
|
||||
if (fileName.ends_with(".html"))
|
||||
mimeType = "text/html";
|
||||
else if (fileName.ends_with(".js"))
|
||||
mimeType = "text/javascript";
|
||||
else if (fileName.ends_with(".css"))
|
||||
mimeType = "text/css";
|
||||
else
|
||||
mimeType = "application/octet-stream";
|
||||
|
||||
return mimeType;
|
||||
}
|
||||
} // namespace ui
|
||||
12
src/ModMan/Web/UiAssets.h
Normal file
12
src/ModMan/Web/UiAssets.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include "Web/ViteAssets.h"
|
||||
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace ui
|
||||
{
|
||||
std::unordered_map<std::string, UiFile> BuildUiFileLookup();
|
||||
const char* GetMimeTypeForFileName(const std::string& fileName);
|
||||
} // namespace ui
|
||||
142
src/ModMan/Web/UiCommunication.h
Normal file
142
src/ModMan/Web/UiCommunication.h
Normal file
@@ -0,0 +1,142 @@
|
||||
#pragma once
|
||||
|
||||
#include "Utils/Logging/Log.h"
|
||||
#include "WebViewLib.h"
|
||||
|
||||
#pragma warning(push, 0)
|
||||
#include <nlohmann/json.hpp>
|
||||
#pragma warning(pop)
|
||||
|
||||
namespace ui
|
||||
{
|
||||
inline void Bind(webview::webview& wv, const std::string& name, std::function<void()> fn)
|
||||
{
|
||||
wv.bind(name,
|
||||
[fn](const std::string& req) -> std::string
|
||||
{
|
||||
fn();
|
||||
return "";
|
||||
});
|
||||
}
|
||||
|
||||
template<typename TInput> void Bind(webview::webview& wv, const std::string& name, std::function<void(TInput)> fn)
|
||||
{
|
||||
wv.bind(name,
|
||||
[fn](const std::string& req) -> std::string
|
||||
{
|
||||
TInput param;
|
||||
try
|
||||
{
|
||||
const auto json = nlohmann::json::parse(req);
|
||||
if (!json.is_array())
|
||||
{
|
||||
con::error("Webview params are not an array: {}", req);
|
||||
return "";
|
||||
}
|
||||
param = json.at(0).get<TInput>();
|
||||
}
|
||||
catch (const nlohmann::json::exception& e)
|
||||
{
|
||||
con::error("Failed to parse json of webview call: {}", e.what());
|
||||
return "";
|
||||
}
|
||||
|
||||
fn(std::move(param));
|
||||
|
||||
return "";
|
||||
});
|
||||
}
|
||||
|
||||
template<typename TReturn> void BindRetOnly(webview::webview& wv, const std::string& name, std::function<TReturn()> fn)
|
||||
{
|
||||
wv.bind(name,
|
||||
[fn](const std::string& req) -> std::string
|
||||
{
|
||||
auto result = fn();
|
||||
|
||||
return nlohmann::json(result).dump();
|
||||
});
|
||||
}
|
||||
|
||||
template<typename TInput, typename TReturn> void Bind(webview::webview& wv, const std::string& name, std::function<TReturn(TInput)> fn)
|
||||
{
|
||||
wv.bind(name,
|
||||
[fn](const std::string& req) -> std::string
|
||||
{
|
||||
TInput param;
|
||||
try
|
||||
{
|
||||
const auto json = nlohmann::json::parse(req);
|
||||
if (!json.is_array())
|
||||
{
|
||||
con::error("Webview params are not an array: {}", req);
|
||||
return "";
|
||||
}
|
||||
param = json.at(0).get<TInput>();
|
||||
}
|
||||
catch (const nlohmann::json::exception& e)
|
||||
{
|
||||
con::error("Failed to parse json of webview call: {}", e.what());
|
||||
return "";
|
||||
}
|
||||
|
||||
auto result = fn(std::move(param));
|
||||
|
||||
return nlohmann::json(result).dump();
|
||||
});
|
||||
}
|
||||
|
||||
inline void BindAsync(webview::webview& wv, const std::string& name, std::function<void(const std::string& id)> fn)
|
||||
{
|
||||
wv.bind(
|
||||
name,
|
||||
[fn](const std::string& id, const std::string& req, void* /* arg */)
|
||||
{
|
||||
fn(id);
|
||||
},
|
||||
nullptr);
|
||||
}
|
||||
|
||||
template<typename TInput> void BindAsync(webview::webview& wv, const std::string& name, std::function<void(const std::string& id, TInput)> fn)
|
||||
{
|
||||
wv.bind(
|
||||
name,
|
||||
[fn](const std::string& id, const std::string& req, void* /* arg */)
|
||||
{
|
||||
TInput param;
|
||||
try
|
||||
{
|
||||
const auto json = nlohmann::json::parse(req);
|
||||
if (!json.is_array())
|
||||
{
|
||||
con::error("Webview params are not an array: {}", req);
|
||||
return "";
|
||||
}
|
||||
param = json.at(0).get<TInput>();
|
||||
}
|
||||
catch (const nlohmann::json::exception& e)
|
||||
{
|
||||
con::error("Failed to parse json of webview call: {}", e.what());
|
||||
return "";
|
||||
}
|
||||
|
||||
fn(id, std::move(param));
|
||||
},
|
||||
nullptr);
|
||||
}
|
||||
|
||||
template<typename TPayload> void PromiseResolve(webview::webview& wv, const std::string& id, const TPayload& payload)
|
||||
{
|
||||
wv.resolve(id, 0, nlohmann::json(payload).dump());
|
||||
}
|
||||
|
||||
template<typename TPayload> void PromiseReject(webview::webview& wv, const std::string& id, const TPayload& payload)
|
||||
{
|
||||
wv.resolve(id, 1, nlohmann::json(payload).dump());
|
||||
}
|
||||
|
||||
template<typename TPayload> void Notify(webview::webview& wv, const std::string& eventKey, const TPayload& payload)
|
||||
{
|
||||
wv.notify(eventKey, nlohmann::json(payload).dump());
|
||||
}
|
||||
} // namespace ui
|
||||
20
src/ModMan/Web/WebViewLib.h
Normal file
20
src/ModMan/Web/WebViewLib.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push, 0)
|
||||
#else
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
|
||||
#include <webview/webview.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#else
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
#ifdef ERROR
|
||||
#undef ERROR
|
||||
#endif
|
||||
140
src/ModMan/main.cpp
Normal file
140
src/ModMan/main.cpp
Normal file
@@ -0,0 +1,140 @@
|
||||
#include "GitVersion.h"
|
||||
#include "Web/Edge/AssetHandlerEdge.h"
|
||||
#include "Web/Gtk/AssetHandlerGtk.h"
|
||||
#include "Web/UiCommunication.h"
|
||||
#include "Web/ViteAssets.h"
|
||||
#include "Web/WebViewLib.h"
|
||||
|
||||
#include <chrono>
|
||||
#include <format>
|
||||
#include <iostream>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
|
||||
using namespace std::string_literals;
|
||||
|
||||
namespace
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
std::optional<webview::webview> devToolWindow;
|
||||
|
||||
void RunDevToolsWindow()
|
||||
{
|
||||
con::debug("Creating dev tools window");
|
||||
|
||||
try
|
||||
{
|
||||
auto& newWindow = devToolWindow.emplace(false, nullptr);
|
||||
newWindow.set_title("Devtools");
|
||||
newWindow.set_size(640, 480, WEBVIEW_HINT_NONE);
|
||||
newWindow.set_size(480, 320, WEBVIEW_HINT_MIN);
|
||||
newWindow.navigate(std::format("http://localhost:{}/__devtools__/", VITE_DEV_SERVER_PORT));
|
||||
}
|
||||
catch (const webview::exception& e)
|
||||
{
|
||||
std::cerr << e.what() << '\n';
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
int RunMainWindow()
|
||||
{
|
||||
con::debug("Creating main window");
|
||||
|
||||
try
|
||||
{
|
||||
webview::webview w(
|
||||
#ifdef _DEBUG
|
||||
true,
|
||||
#else
|
||||
false,
|
||||
#endif
|
||||
nullptr);
|
||||
w.set_title("OpenAssetTools ModMan");
|
||||
w.set_size(1280, 640, WEBVIEW_HINT_NONE);
|
||||
w.set_size(480, 320, WEBVIEW_HINT_MIN);
|
||||
|
||||
// A binding that counts up or down and immediately returns the new value.
|
||||
ui::Bind<std::string, std::string>(w,
|
||||
"greet",
|
||||
[&w](std::string name) -> std::string
|
||||
{
|
||||
ui::Notify(w, "greeting", name);
|
||||
return std::format("Hello from C++ {}!", name);
|
||||
});
|
||||
|
||||
// A binding that counts up or down and immediately returns the new value.
|
||||
ui::Bind(w,
|
||||
"debug",
|
||||
[]()
|
||||
{
|
||||
con::info("Debug");
|
||||
});
|
||||
|
||||
// A binding that creates a new thread and returns the result at a later time.
|
||||
ui::BindAsync(w,
|
||||
"compute",
|
||||
[&](const std::string& id)
|
||||
{
|
||||
// Create a thread and forget about it for the sake of simplicity.
|
||||
std::thread(
|
||||
[&, id]
|
||||
{
|
||||
// Simulate load.
|
||||
std::this_thread::sleep_for(std::chrono::seconds(5));
|
||||
ui::PromiseResolve(w, id, 42);
|
||||
})
|
||||
.detach();
|
||||
});
|
||||
|
||||
#if defined(WEBVIEW_PLATFORM_WINDOWS) && defined(WEBVIEW_EDGE)
|
||||
edge::InstallCustomProtocolHandler(w);
|
||||
constexpr auto urlPrefix = edge::URL_PREFIX;
|
||||
#elif defined(WEBVIEW_PLATFORM_LINUX) && defined(WEBVIEW_GTK)
|
||||
gtk::InstallCustomProtocolHandler(w);
|
||||
constexpr auto urlPrefix = gtk::URL_PREFIX;
|
||||
#else
|
||||
#error Unsupported platform
|
||||
#endif
|
||||
|
||||
#ifdef _DEBUG
|
||||
w.navigate(VITE_DEV_SERVER ? std::format("http://localhost:{}", VITE_DEV_SERVER_PORT) : std::format("{}index.html", urlPrefix));
|
||||
|
||||
if (VITE_DEV_SERVER)
|
||||
{
|
||||
w.dispatch(
|
||||
[]
|
||||
{
|
||||
RunDevToolsWindow();
|
||||
});
|
||||
}
|
||||
#else
|
||||
w.navigate(std::format("{}index.html", urlPrefix));
|
||||
#endif
|
||||
w.run();
|
||||
}
|
||||
catch (const webview::exception& e)
|
||||
{
|
||||
std::cerr << e.what() << '\n';
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
#ifdef _WIN32
|
||||
int WINAPI WinMain(HINSTANCE /*hInst*/, HINSTANCE /*hPrevInst*/, LPSTR /*lpCmdLine*/, int /*nCmdShow*/)
|
||||
{
|
||||
#else
|
||||
int main()
|
||||
{
|
||||
#endif
|
||||
|
||||
con::info("Starting ModMan " GIT_VERSION);
|
||||
|
||||
const auto result = RunMainWindow();
|
||||
|
||||
return result;
|
||||
}
|
||||
24
src/ModManUi/.gitignore
vendored
Normal file
24
src/ModManUi/.gitignore
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
lerna-debug.log*
|
||||
|
||||
node_modules
|
||||
dist
|
||||
dist-ssr
|
||||
*.local
|
||||
|
||||
# Editor directories and files
|
||||
.vscode/*
|
||||
!.vscode/extensions.json
|
||||
.idea
|
||||
.DS_Store
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
1
src/ModManUi/.prettierignore
Normal file
1
src/ModManUi/.prettierignore
Normal file
@@ -0,0 +1 @@
|
||||
src-tauri
|
||||
4
src/ModManUi/.prettierrc.json
Normal file
4
src/ModManUi/.prettierrc.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/prettierrc",
|
||||
"printWidth": 100
|
||||
}
|
||||
171
src/ModManUi/build/HeaderTransformationPlugin.ts
Normal file
171
src/ModManUi/build/HeaderTransformationPlugin.ts
Normal file
@@ -0,0 +1,171 @@
|
||||
import type { Plugin } from "vite";
|
||||
import type { OutputAsset, OutputChunk } from "rollup";
|
||||
import path from "node:path";
|
||||
import fs from "node:fs";
|
||||
|
||||
type MinimalOutputAsset = Pick<OutputAsset, "type" | "fileName" | "source">;
|
||||
type MinimalOutputChunk = Pick<OutputChunk, "type" | "fileName" | "code">;
|
||||
type MinimalOutputBundle = Record<string, MinimalOutputAsset | MinimalOutputChunk>;
|
||||
|
||||
function createVarName(fileName: string) {
|
||||
return fileName.replaceAll(".", "_").toUpperCase();
|
||||
}
|
||||
|
||||
function transformAsset(asset: MinimalOutputAsset) {
|
||||
const varName = createVarName(asset.fileName);
|
||||
|
||||
let bytes: string;
|
||||
if (typeof asset.source === "string") {
|
||||
bytes = [...asset.source].map((v) => String(v.charCodeAt(0))).join(",");
|
||||
} else {
|
||||
bytes = [...asset.source].map((v) => String(v)).join(",");
|
||||
}
|
||||
|
||||
return `constexpr const unsigned char ${varName}[] {${bytes}};
|
||||
`;
|
||||
}
|
||||
|
||||
function transformChunk(chunk: MinimalOutputChunk) {
|
||||
const varName = createVarName(chunk.fileName);
|
||||
const bytes = [...chunk.code].map((v) => String(v.charCodeAt(0))).join(",");
|
||||
|
||||
return `constexpr const unsigned char ${varName}[] {${bytes}};
|
||||
`;
|
||||
}
|
||||
|
||||
function writeHeader(
|
||||
bundle: MinimalOutputBundle,
|
||||
outputDir?: string,
|
||||
options?: HeaderTransformationPluginOptions,
|
||||
devServerPort?: number,
|
||||
) {
|
||||
const outputPath = options?.outputPath ?? path.join(outputDir ?? "dist", "ViteAssets.h");
|
||||
const outputPathParentDir = path.dirname(outputPath);
|
||||
|
||||
fs.mkdirSync(outputPathParentDir, { recursive: true });
|
||||
|
||||
const fd = fs.openSync(outputPath, "w");
|
||||
const includeFileEnumeration = options?.includeFileEnumeration ?? true;
|
||||
|
||||
fs.writeSync(
|
||||
fd,
|
||||
`#pragma once
|
||||
|
||||
`,
|
||||
);
|
||||
|
||||
if (includeFileEnumeration) {
|
||||
fs.writeSync(
|
||||
fd,
|
||||
`#include <cstdlib>
|
||||
#include <type_traits>
|
||||
|
||||
`,
|
||||
);
|
||||
}
|
||||
|
||||
fs.writeSync(
|
||||
fd,
|
||||
`constexpr auto VITE_DEV_SERVER = ${devServerPort ? "true" : "false"};
|
||||
constexpr auto VITE_DEV_SERVER_PORT = ${devServerPort ? String(devServerPort) : "-1"};
|
||||
`,
|
||||
);
|
||||
|
||||
for (const curBundle of Object.values(bundle)) {
|
||||
if (curBundle.type === "asset") {
|
||||
fs.writeSync(fd, transformAsset(curBundle));
|
||||
} else {
|
||||
fs.writeSync(fd, transformChunk(curBundle));
|
||||
}
|
||||
}
|
||||
|
||||
if (includeFileEnumeration) {
|
||||
fs.writeSync(
|
||||
fd,
|
||||
`
|
||||
struct UiFile
|
||||
{
|
||||
const char* filename;
|
||||
const void* data;
|
||||
const size_t dataSize;
|
||||
};
|
||||
|
||||
static inline const UiFile MOD_MAN_UI_FILES[] {
|
||||
`,
|
||||
);
|
||||
|
||||
let index = 0;
|
||||
for (const curBundle of Object.values(bundle)) {
|
||||
const fileName = curBundle.fileName;
|
||||
const varName = createVarName(fileName);
|
||||
|
||||
let prefix = " ";
|
||||
if (index > 0) {
|
||||
prefix = `,
|
||||
`;
|
||||
}
|
||||
|
||||
fs.writeSync(
|
||||
fd,
|
||||
`${prefix}{ "${fileName}", ${varName}, std::extent_v<decltype(${varName})> }`,
|
||||
);
|
||||
index++;
|
||||
}
|
||||
|
||||
fs.writeSync(
|
||||
fd,
|
||||
`
|
||||
};
|
||||
`,
|
||||
);
|
||||
|
||||
fs.closeSync(fd);
|
||||
}
|
||||
}
|
||||
|
||||
export interface HeaderTransformationPluginOptions {
|
||||
outputPath?: string;
|
||||
includeFileEnumeration?: boolean;
|
||||
}
|
||||
|
||||
export default function headerTransformationPlugin(
|
||||
options?: HeaderTransformationPluginOptions,
|
||||
): Plugin {
|
||||
let writeServerActive = false;
|
||||
let writeBundleActive = false;
|
||||
|
||||
return {
|
||||
name: "vite-plugin-header-transformation",
|
||||
enforce: "post",
|
||||
config(_userOptions, env) {
|
||||
if (env.command === "serve") {
|
||||
writeServerActive = true;
|
||||
} else {
|
||||
writeBundleActive = true;
|
||||
}
|
||||
},
|
||||
configureServer(server) {
|
||||
if (!writeServerActive) {
|
||||
return;
|
||||
}
|
||||
server.httpServer?.once("listening", () => {
|
||||
writeHeader(
|
||||
{
|
||||
// We need at least one array entry for MSVC
|
||||
dummyfile: { type: "chunk", fileName: "dummyfile", code: "dummy" },
|
||||
},
|
||||
server.config.build.outDir,
|
||||
options,
|
||||
server.config.server.port,
|
||||
);
|
||||
});
|
||||
},
|
||||
writeBundle(outputOptions, bundle) {
|
||||
if (!writeBundleActive) {
|
||||
return;
|
||||
}
|
||||
|
||||
writeHeader(bundle, outputOptions.dir, options);
|
||||
},
|
||||
};
|
||||
}
|
||||
1
src/ModManUi/env.d.ts
vendored
Normal file
1
src/ModManUi/env.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/// <reference types="vite/client" />
|
||||
28
src/ModManUi/eslint.config.ts
Normal file
28
src/ModManUi/eslint.config.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { globalIgnores } from "eslint/config";
|
||||
import { defineConfigWithVueTs, vueTsConfigs } from "@vue/eslint-config-typescript";
|
||||
import pluginVue from "eslint-plugin-vue";
|
||||
import pluginVitest from "@vitest/eslint-plugin";
|
||||
import skipFormatting from "@vue/eslint-config-prettier/skip-formatting";
|
||||
|
||||
// To allow more languages other than `ts` in `.vue` files, uncomment the following lines:
|
||||
// import { configureVueProject } from '@vue/eslint-config-typescript'
|
||||
// configureVueProject({ scriptLangs: ['ts', 'tsx'] })
|
||||
// More info at https://github.com/vuejs/eslint-config-typescript/#advanced-setup
|
||||
|
||||
export default defineConfigWithVueTs(
|
||||
{
|
||||
name: "app/files-to-lint",
|
||||
files: ["**/*.{ts,mts,tsx,vue}"],
|
||||
},
|
||||
|
||||
globalIgnores(["**/dist/**", "**/dist-ssr/**", "**/coverage/**"]),
|
||||
|
||||
pluginVue.configs["flat/essential"],
|
||||
vueTsConfigs.recommended,
|
||||
|
||||
{
|
||||
...pluginVitest.configs.recommended,
|
||||
files: ["src/**/__tests__/*"],
|
||||
},
|
||||
skipFormatting,
|
||||
);
|
||||
13
src/ModManUi/index.html
Normal file
13
src/ModManUi/index.html
Normal file
@@ -0,0 +1,13 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" href="/favicon.ico" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Tauri + Vue + Typescript App</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="module" src="/src/main.ts"></script>
|
||||
</body>
|
||||
</html>
|
||||
7100
src/ModManUi/package-lock.json
generated
Normal file
7100
src/ModManUi/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
42
src/ModManUi/package.json
Normal file
42
src/ModManUi/package.json
Normal file
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"name": "openassettools",
|
||||
"private": true,
|
||||
"version": "0.1.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "run-p type-check \"build-only {@}\" --",
|
||||
"preview": "vite preview",
|
||||
"build-only": "vite build",
|
||||
"type-check": "vue-tsc --build",
|
||||
"lint": "eslint . --fix",
|
||||
"format": "prettier --write **/*.{js,ts,vue,html,json,yml,yaml,md}"
|
||||
},
|
||||
"dependencies": {
|
||||
"pinia": "3.0.3",
|
||||
"vue": "3.5.22"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tsconfig/node22": "^22.0.2",
|
||||
"@types/jsdom": "^21.1.7",
|
||||
"@types/node": "^22.18.6",
|
||||
"@vitejs/plugin-vue": "6.0.1",
|
||||
"@vitest/eslint-plugin": "^1.3.13",
|
||||
"@vue/eslint-config-prettier": "^10.2.0",
|
||||
"@vue/eslint-config-typescript": "^14.6.0",
|
||||
"@vue/test-utils": "^2.4.6",
|
||||
"@vue/tsconfig": "^0.8.1",
|
||||
"eslint": "^9.33.0",
|
||||
"eslint-plugin-vue": "~10.4.0",
|
||||
"jiti": "^2.5.1",
|
||||
"jsdom": "^27.0.0",
|
||||
"npm-run-all2": "^8.0.4",
|
||||
"prettier": "3.6.2",
|
||||
"sass": "1.93.2",
|
||||
"typescript": "~5.9.3",
|
||||
"vite": "7.1.7",
|
||||
"vite-plugin-vue-devtools": "^8.0.2",
|
||||
"vitest": "^3.2.4",
|
||||
"vue-tsc": "3.1.0"
|
||||
}
|
||||
}
|
||||
BIN
src/ModManUi/public/favicon.ico
Normal file
BIN
src/ModManUi/public/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
44
src/ModManUi/src/App.vue
Normal file
44
src/ModManUi/src/App.vue
Normal file
@@ -0,0 +1,44 @@
|
||||
<script setup lang="ts">
|
||||
import { onUnmounted, ref } from "vue";
|
||||
import { webviewBinds, webviewAddEventListener, webviewRemoveEventListener } from "./native";
|
||||
|
||||
const greetMsg = ref("");
|
||||
const lastPersonGreeted = ref("");
|
||||
const name = ref("");
|
||||
|
||||
async function greet() {
|
||||
greetMsg.value = await webviewBinds.greet(name.value);
|
||||
}
|
||||
|
||||
function onPersonGreeted(person: string) {
|
||||
lastPersonGreeted.value = person;
|
||||
}
|
||||
|
||||
webviewAddEventListener("greeting", onPersonGreeted);
|
||||
|
||||
onUnmounted(() => webviewRemoveEventListener("greeting", onPersonGreeted));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<main class="container">
|
||||
<h1>Welcome to ModMan</h1>
|
||||
<small>Nothing to see here yet, this is mainly for testing</small>
|
||||
|
||||
<form class="row" @submit.prevent="greet">
|
||||
<input id="greet-input" v-model="name" placeholder="Enter a name..." autocomplete="off" />
|
||||
<button type="submit">Greet</button>
|
||||
</form>
|
||||
<p>{{ greetMsg }}</p>
|
||||
<p>The last person greeted is: {{ lastPersonGreeted }}</p>
|
||||
</main>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.logo.vite:hover {
|
||||
filter: drop-shadow(0 0 2em #747bff);
|
||||
}
|
||||
|
||||
.logo.vue:hover {
|
||||
filter: drop-shadow(0 0 2em #249b73);
|
||||
}
|
||||
</style>
|
||||
109
src/ModManUi/src/main.scss
Normal file
109
src/ModManUi/src/main.scss
Normal file
@@ -0,0 +1,109 @@
|
||||
:root {
|
||||
font-family: Inter, Avenir, Helvetica, Arial, sans-serif;
|
||||
font-size: 16px;
|
||||
line-height: 24px;
|
||||
font-weight: 400;
|
||||
|
||||
color: #0f0f0f;
|
||||
background-color: #f6f6f6;
|
||||
|
||||
font-synthesis: none;
|
||||
text-rendering: optimizeLegibility;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
-webkit-text-size-adjust: 100%;
|
||||
}
|
||||
|
||||
.container {
|
||||
margin: 0;
|
||||
padding-top: 10vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.logo {
|
||||
height: 6em;
|
||||
padding: 1.5em;
|
||||
will-change: filter;
|
||||
transition: 0.75s;
|
||||
}
|
||||
|
||||
.logo.tauri:hover {
|
||||
filter: drop-shadow(0 0 2em #24c8db);
|
||||
}
|
||||
|
||||
.row {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
a {
|
||||
font-weight: 500;
|
||||
color: #646cff;
|
||||
text-decoration: inherit;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
color: #535bf2;
|
||||
}
|
||||
|
||||
h1 {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
input,
|
||||
button {
|
||||
border-radius: 8px;
|
||||
border: 1px solid transparent;
|
||||
padding: 0.6em 1.2em;
|
||||
font-size: 1em;
|
||||
font-weight: 500;
|
||||
font-family: inherit;
|
||||
color: #0f0f0f;
|
||||
background-color: #ffffff;
|
||||
transition: border-color 0.25s;
|
||||
box-shadow: 0 2px 2px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
button {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
border-color: #396cd8;
|
||||
}
|
||||
button:active {
|
||||
border-color: #396cd8;
|
||||
background-color: #e8e8e8;
|
||||
}
|
||||
|
||||
input,
|
||||
button {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
#greet-input {
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
:root {
|
||||
color: #f6f6f6;
|
||||
background-color: #2f2f2f;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
color: #24c8db;
|
||||
}
|
||||
|
||||
input,
|
||||
button {
|
||||
color: #ffffff;
|
||||
background-color: #0f0f0f98;
|
||||
}
|
||||
button:active {
|
||||
background-color: #0f0f0f69;
|
||||
}
|
||||
}
|
||||
13
src/ModManUi/src/main.ts
Normal file
13
src/ModManUi/src/main.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import "../public/favicon.ico";
|
||||
import "./main.scss";
|
||||
|
||||
import { createApp } from "vue";
|
||||
import { createPinia } from "pinia";
|
||||
|
||||
import App from "./App.vue";
|
||||
|
||||
const app = createApp(App);
|
||||
|
||||
app.use(createPinia());
|
||||
|
||||
app.mount("#app");
|
||||
25
src/ModManUi/src/native.ts
Normal file
25
src/ModManUi/src/native.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
export interface NativeMethods {
|
||||
greet: (name: string) => Promise<string>;
|
||||
}
|
||||
|
||||
interface NativeEventMap {
|
||||
greeting: string;
|
||||
}
|
||||
|
||||
type WebViewExtensions = {
|
||||
webviewBinds: NativeMethods;
|
||||
webviewAddEventListener<K extends keyof NativeEventMap>(
|
||||
eventKey: K,
|
||||
callback: (payload: NativeEventMap[K]) => void,
|
||||
): void;
|
||||
webviewRemoveEventListener<K extends keyof NativeEventMap>(
|
||||
eventKey: K,
|
||||
callback: (payload: NativeEventMap[K]) => void,
|
||||
): boolean;
|
||||
};
|
||||
|
||||
const windowWithWebViewExtensions = window as typeof window & WebViewExtensions;
|
||||
|
||||
export const webviewBinds = windowWithWebViewExtensions.webviewBinds;
|
||||
export const webviewAddEventListener = windowWithWebViewExtensions.webviewAddEventListener;
|
||||
export const webviewRemoveEventListener = windowWithWebViewExtensions.webviewRemoveEventListener;
|
||||
12
src/ModManUi/src/stores/counter.ts
Normal file
12
src/ModManUi/src/stores/counter.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { ref, computed } from "vue";
|
||||
import { defineStore } from "pinia";
|
||||
|
||||
export const useCounterStore = defineStore("counter", () => {
|
||||
const count = ref(0);
|
||||
const doubleCount = computed(() => count.value * 2);
|
||||
function increment() {
|
||||
count.value++;
|
||||
}
|
||||
|
||||
return { count, doubleCount, increment };
|
||||
});
|
||||
12
src/ModManUi/tsconfig.app.json
Normal file
12
src/ModManUi/tsconfig.app.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"extends": "@vue/tsconfig/tsconfig.dom.json",
|
||||
"include": ["env.d.ts", "src/**/*", "src/**/*.vue"],
|
||||
"exclude": ["src/**/__tests__/*"],
|
||||
"compilerOptions": {
|
||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
|
||||
|
||||
"paths": {
|
||||
"@/*": ["./src/*"]
|
||||
}
|
||||
}
|
||||
}
|
||||
14
src/ModManUi/tsconfig.json
Normal file
14
src/ModManUi/tsconfig.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"files": [],
|
||||
"references": [
|
||||
{
|
||||
"path": "./tsconfig.node.json"
|
||||
},
|
||||
{
|
||||
"path": "./tsconfig.app.json"
|
||||
},
|
||||
{
|
||||
"path": "./tsconfig.vitest.json"
|
||||
}
|
||||
]
|
||||
}
|
||||
20
src/ModManUi/tsconfig.node.json
Normal file
20
src/ModManUi/tsconfig.node.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"extends": "@tsconfig/node22/tsconfig.json",
|
||||
"include": [
|
||||
"vite.config.*",
|
||||
"vitest.config.*",
|
||||
"cypress.config.*",
|
||||
"nightwatch.conf.*",
|
||||
"playwright.config.*",
|
||||
"eslint.config.*",
|
||||
"build/**/*"
|
||||
],
|
||||
"compilerOptions": {
|
||||
"noEmit": true,
|
||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
|
||||
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "Bundler",
|
||||
"types": ["node"]
|
||||
}
|
||||
}
|
||||
11
src/ModManUi/tsconfig.vitest.json
Normal file
11
src/ModManUi/tsconfig.vitest.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"extends": "./tsconfig.app.json",
|
||||
"include": ["src/**/__tests__/*", "env.d.ts"],
|
||||
"exclude": [],
|
||||
"compilerOptions": {
|
||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.vitest.tsbuildinfo",
|
||||
|
||||
"lib": [],
|
||||
"types": ["node", "jsdom"]
|
||||
}
|
||||
}
|
||||
35
src/ModManUi/vite.config.ts
Normal file
35
src/ModManUi/vite.config.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { fileURLToPath, URL } from "node:url";
|
||||
|
||||
import { defineConfig } from "vite";
|
||||
import vue from "@vitejs/plugin-vue";
|
||||
import vueDevTools from "vite-plugin-vue-devtools";
|
||||
import headerTransformationPlugin from "./build/HeaderTransformationPlugin";
|
||||
|
||||
// https://vite.dev/config/
|
||||
export default defineConfig({
|
||||
build: {
|
||||
copyPublicDir: false,
|
||||
emptyOutDir: true,
|
||||
rollupOptions: {
|
||||
output: {
|
||||
assetFileNames: "[name][extname]",
|
||||
entryFileNames: "[name].js",
|
||||
chunkFileNames: "[name].js",
|
||||
},
|
||||
},
|
||||
},
|
||||
plugins: [
|
||||
vue(),
|
||||
vueDevTools(),
|
||||
headerTransformationPlugin({
|
||||
outputPath: fileURLToPath(
|
||||
new URL("../../build/src/ModMan/Web/ViteAssets.h", import.meta.url),
|
||||
),
|
||||
}),
|
||||
],
|
||||
resolve: {
|
||||
alias: {
|
||||
"@": fileURLToPath(new URL("./src", import.meta.url)),
|
||||
},
|
||||
},
|
||||
});
|
||||
13
src/ModManUi/vitest.config.ts
Normal file
13
src/ModManUi/vitest.config.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { mergeConfig, defineConfig } from "vitest/config";
|
||||
import viteConfig from "./vite.config";
|
||||
|
||||
export default mergeConfig(
|
||||
viteConfig,
|
||||
defineConfig({
|
||||
test: {
|
||||
environment: "jsdom",
|
||||
root: fileURLToPath(new URL("./", import.meta.url)),
|
||||
},
|
||||
}),
|
||||
);
|
||||
@@ -54,4 +54,5 @@ function ObjCommon:project()
|
||||
|
||||
self:include(includes)
|
||||
Utils:include(includes)
|
||||
eigen:include(includes)
|
||||
end
|
||||
|
||||
23
src/ObjCommon/FontIcon/FontIconCommon.cpp
Normal file
23
src/ObjCommon/FontIcon/FontIconCommon.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#include "FontIconCommon.h"
|
||||
|
||||
#include "Utils/StringUtils.h"
|
||||
|
||||
#include <filesystem>
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
namespace font_icon
|
||||
{
|
||||
std::string GetJsonFileNameForAssetName(const std::string& assetName)
|
||||
{
|
||||
std::string originalFileName(assetName);
|
||||
utils::MakeStringLowerCase(originalFileName);
|
||||
if (originalFileName.ends_with(".csv"))
|
||||
{
|
||||
fs::path p(assetName);
|
||||
p.replace_extension(".json");
|
||||
return p.string();
|
||||
}
|
||||
|
||||
return assetName;
|
||||
}
|
||||
} // namespace font_icon
|
||||
8
src/ObjCommon/FontIcon/FontIconCommon.h
Normal file
8
src/ObjCommon/FontIcon/FontIconCommon.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace font_icon
|
||||
{
|
||||
std::string GetJsonFileNameForAssetName(const std::string& assetName);
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Json/JsonCommon.h"
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
class JsonXModelLod
|
||||
{
|
||||
public:
|
||||
std::string file;
|
||||
float distance;
|
||||
};
|
||||
|
||||
NLOHMANN_DEFINE_TYPE_EXTENSION(JsonXModelLod, file, distance);
|
||||
|
||||
class JsonXModel
|
||||
{
|
||||
public:
|
||||
std::vector<JsonXModelLod> lods;
|
||||
std::optional<int> collLod;
|
||||
std::optional<std::string> physPreset;
|
||||
std::optional<std::string> physCollmap;
|
||||
uint8_t flags;
|
||||
};
|
||||
|
||||
NLOHMANN_DEFINE_TYPE_EXTENSION(JsonXModel, lods, collLod, physPreset, physCollmap, flags);
|
||||
} // namespace IW5
|
||||
@@ -1,32 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Game/IW5/IW5.h"
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
inline const char* HITLOC_NAMES[]{
|
||||
// clang-format off
|
||||
"none",
|
||||
"helmet",
|
||||
"head",
|
||||
"neck",
|
||||
"torso_upper",
|
||||
"torso_lower",
|
||||
"right_arm_upper",
|
||||
"left_arm_upper",
|
||||
"right_arm_lower",
|
||||
"left_arm_lower",
|
||||
"right_hand",
|
||||
"left_hand",
|
||||
"right_leg_upper",
|
||||
"left_leg_upper",
|
||||
"right_leg_lower",
|
||||
"left_leg_lower",
|
||||
"right_foot",
|
||||
"left_foot",
|
||||
"gun",
|
||||
"shield",
|
||||
// clang-format on
|
||||
};
|
||||
static_assert(std::extent_v<decltype(HITLOC_NAMES)> == HITLOC_COUNT);
|
||||
} // namespace IW5
|
||||
@@ -1,31 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Json/JsonCommon.h"
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace T5
|
||||
{
|
||||
class JsonXModelLod
|
||||
{
|
||||
public:
|
||||
std::string file;
|
||||
float distance;
|
||||
};
|
||||
|
||||
NLOHMANN_DEFINE_TYPE_EXTENSION(JsonXModelLod, file, distance);
|
||||
|
||||
class JsonXModel
|
||||
{
|
||||
public:
|
||||
std::vector<JsonXModelLod> lods;
|
||||
std::optional<int> collLod;
|
||||
std::optional<std::string> physPreset;
|
||||
std::optional<std::string> physConstraints;
|
||||
unsigned flags;
|
||||
};
|
||||
|
||||
NLOHMANN_DEFINE_TYPE_EXTENSION(JsonXModel, lods, collLod, physPreset, physConstraints, flags);
|
||||
} // namespace T5
|
||||
@@ -1,31 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Game/T5/T5.h"
|
||||
|
||||
namespace T5
|
||||
{
|
||||
inline const char* HITLOC_NAMES[]{
|
||||
// clang-format off
|
||||
"none",
|
||||
"helmet",
|
||||
"head",
|
||||
"neck",
|
||||
"torso_upper",
|
||||
"torso_lower",
|
||||
"right_arm_upper",
|
||||
"left_arm_upper",
|
||||
"right_arm_lower",
|
||||
"left_arm_lower",
|
||||
"right_hand",
|
||||
"left_hand",
|
||||
"right_leg_upper",
|
||||
"left_leg_upper",
|
||||
"right_leg_lower",
|
||||
"left_leg_lower",
|
||||
"right_foot",
|
||||
"left_foot",
|
||||
"gun",
|
||||
// clang-format on
|
||||
};
|
||||
static_assert(std::extent_v<decltype(HITLOC_NAMES)> == HITLOC_COUNT);
|
||||
} // namespace T5
|
||||
33
src/ObjCommon/Game/T6/FontIcon/JsonFontIconT6.h
Normal file
33
src/ObjCommon/Game/T6/FontIcon/JsonFontIconT6.h
Normal file
@@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
|
||||
#include "Json/JsonCommon.h"
|
||||
#include "Json/JsonExtension.h"
|
||||
#include <memory>
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace T6
|
||||
{
|
||||
class JsonFontIconEntry
|
||||
{
|
||||
public:
|
||||
std::string name;
|
||||
std::string material;
|
||||
unsigned size;
|
||||
std::optional<JsonVec2> scale;
|
||||
std::vector<std::string> aliases;
|
||||
std::optional<std::vector<unsigned>> aliasHashes;
|
||||
};
|
||||
|
||||
NLOHMANN_DEFINE_TYPE_EXTENSION(JsonFontIconEntry, name, material, size, scale, aliases, aliasHashes);
|
||||
|
||||
class JsonFontIcon
|
||||
{
|
||||
public:
|
||||
std::vector<JsonFontIconEntry> entries;
|
||||
};
|
||||
|
||||
NLOHMANN_DEFINE_TYPE_EXTENSION(JsonFontIcon, entries);
|
||||
} // namespace T6
|
||||
@@ -1,33 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Json/JsonCommon.h"
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace T6
|
||||
{
|
||||
class JsonXModelLod
|
||||
{
|
||||
public:
|
||||
std::string file;
|
||||
float distance;
|
||||
};
|
||||
|
||||
NLOHMANN_DEFINE_TYPE_EXTENSION(JsonXModelLod, file, distance);
|
||||
|
||||
class JsonXModel
|
||||
{
|
||||
public:
|
||||
std::vector<JsonXModelLod> lods;
|
||||
std::optional<int> collLod;
|
||||
std::optional<std::string> physPreset;
|
||||
std::optional<std::string> physConstraints;
|
||||
unsigned flags;
|
||||
JsonVec3 lightingOriginOffset;
|
||||
float lightingOriginRange;
|
||||
};
|
||||
|
||||
NLOHMANN_DEFINE_TYPE_EXTENSION(JsonXModel, lods, collLod, physPreset, physConstraints, flags, lightingOriginOffset, lightingOriginRange);
|
||||
} // namespace T6
|
||||
@@ -1,33 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Game/T6/T6.h"
|
||||
|
||||
namespace T6
|
||||
{
|
||||
inline const char* HITLOC_NAMES[]{
|
||||
// clang-format off
|
||||
"none",
|
||||
"helmet",
|
||||
"head",
|
||||
"neck",
|
||||
"torso_upper",
|
||||
"torso_middle",
|
||||
"torso_lower",
|
||||
"right_arm_upper",
|
||||
"left_arm_upper",
|
||||
"right_arm_lower",
|
||||
"left_arm_lower",
|
||||
"right_hand",
|
||||
"left_hand",
|
||||
"right_leg_upper",
|
||||
"left_leg_upper",
|
||||
"right_leg_lower",
|
||||
"left_leg_lower",
|
||||
"right_foot",
|
||||
"left_foot",
|
||||
"gun",
|
||||
"shield",
|
||||
// clang-format on
|
||||
};
|
||||
static_assert(std::extent_v<decltype(HITLOC_NAMES)> == HITLOC_COUNT);
|
||||
} // namespace T6
|
||||
15
src/ObjCommon/Image/ImageCommon.cpp
Normal file
15
src/ObjCommon/Image/ImageCommon.cpp
Normal file
@@ -0,0 +1,15 @@
|
||||
#include "ImageCommon.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <format>
|
||||
|
||||
namespace image
|
||||
{
|
||||
std::string GetFileNameForAsset(std::string assetName, const std::string& extension)
|
||||
{
|
||||
std::string cleanAssetName(std::move(assetName));
|
||||
std::ranges::replace(cleanAssetName, '*', '_');
|
||||
|
||||
return std::format("images/{}{}", cleanAssetName, extension);
|
||||
}
|
||||
} // namespace image
|
||||
8
src/ObjCommon/Image/ImageCommon.h
Normal file
8
src/ObjCommon/Image/ImageCommon.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace image
|
||||
{
|
||||
std::string GetFileNameForAsset(std::string assetName, const std::string& extension);
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "InfoString.h"
|
||||
|
||||
#include "Utils/Logging/Log.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
@@ -172,13 +174,13 @@ bool InfoString::FromStream(const std::string& prefix, std::istream& stream)
|
||||
std::string readPrefix;
|
||||
if (!infoStream.NextField(readPrefix))
|
||||
{
|
||||
std::cerr << "Invalid info string: Empty\n";
|
||||
con::error("Invalid info string: Empty");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (prefix != readPrefix)
|
||||
{
|
||||
std::cerr << "Invalid info string: Prefix \"" << readPrefix << "\" did not match expected prefix \"" << prefix << "\"\n";
|
||||
con::error("Invalid info string: Prefix \"{}\" did not match expected prefix \"{}\"", readPrefix, prefix);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -188,9 +190,9 @@ bool InfoString::FromStream(const std::string& prefix, std::istream& stream)
|
||||
if (key.empty())
|
||||
{
|
||||
if (m_keys_by_insertion.empty())
|
||||
std::cerr << "Invalid info string: Got empty key at the start of the info string\n";
|
||||
con::error("Invalid info string: Got empty key at the start of the info string");
|
||||
else
|
||||
std::cerr << "Invalid info string: Got empty key after key \"" << m_keys_by_insertion[m_keys_by_insertion.size() - 1] << "\"\n";
|
||||
con::error("Invalid info string: Got empty key after key \"{}\"", m_keys_by_insertion[m_keys_by_insertion.size() - 1]);
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -198,7 +200,7 @@ bool InfoString::FromStream(const std::string& prefix, std::istream& stream)
|
||||
std::string value;
|
||||
if (!infoStream.NextField(value))
|
||||
{
|
||||
std::cerr << "Invalid info string: Unexpected eof, no value for key \"" << key << "\"\n";
|
||||
con::error("Invalid info string: Unexpected eof, no value for key \"{}\"", key);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
11
src/ObjCommon/Leaderboard/LeaderboardCommon.cpp
Normal file
11
src/ObjCommon/Leaderboard/LeaderboardCommon.cpp
Normal file
@@ -0,0 +1,11 @@
|
||||
#include "LeaderboardCommon.h"
|
||||
|
||||
#include <format>
|
||||
|
||||
namespace leaderboard
|
||||
{
|
||||
std::string GetJsonFileNameForAsset(const std::string& assetName)
|
||||
{
|
||||
return std::format("leaderboards/{}.json", assetName);
|
||||
}
|
||||
} // namespace leaderboard
|
||||
8
src/ObjCommon/Leaderboard/LeaderboardCommon.h
Normal file
8
src/ObjCommon/Leaderboard/LeaderboardCommon.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace leaderboard
|
||||
{
|
||||
std::string GetJsonFileNameForAsset(const std::string& assetName);
|
||||
}
|
||||
11
src/ObjCommon/LightDef/LightDefCommon.cpp
Normal file
11
src/ObjCommon/LightDef/LightDefCommon.cpp
Normal file
@@ -0,0 +1,11 @@
|
||||
#include "LightDefCommon.h"
|
||||
|
||||
#include <format>
|
||||
|
||||
namespace light_def
|
||||
{
|
||||
std::string GetFileNameForAsset(const std::string& assetName)
|
||||
{
|
||||
return std::format("lights/{}", assetName);
|
||||
}
|
||||
} // namespace light_def
|
||||
8
src/ObjCommon/LightDef/LightDefCommon.h
Normal file
8
src/ObjCommon/LightDef/LightDefCommon.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace light_def
|
||||
{
|
||||
std::string GetFileNameForAsset(const std::string& assetName);
|
||||
}
|
||||
@@ -1,13 +1,19 @@
|
||||
#options GAME (IW4, IW5, T6)
|
||||
#options GAME (IW3, IW4, IW5, T5, T6)
|
||||
|
||||
#filename "Game/" + GAME + "/Material/JsonMaterial" + GAME + ".h"
|
||||
|
||||
#if GAME == "IW4"
|
||||
#if GAME == "IW3"
|
||||
#define FEATURE_IW3
|
||||
#define HAS_WATER
|
||||
#elif GAME == "IW4"
|
||||
#define FEATURE_IW4
|
||||
#define HAS_WATER
|
||||
#elif GAME == "IW5"
|
||||
#define FEATURE_IW5
|
||||
#define HAS_WATER
|
||||
#elif GAME == "T5"
|
||||
#define FEATURE_T5
|
||||
#define HAS_WATER
|
||||
#elif GAME == "T6"
|
||||
#define FEATURE_T6
|
||||
#endif
|
||||
@@ -75,8 +81,10 @@ namespace GAME
|
||||
INVALID,
|
||||
DISABLED,
|
||||
GT0,
|
||||
#if defined(FEATURE_IW4) || defined(FEATURE_IW5)
|
||||
#if defined(FEATURE_IW3) || defined(FEATURE_IW4) || defined(FEATURE_IW5)
|
||||
LT128,
|
||||
#elif defined(FEATURE_T5)
|
||||
GE255,
|
||||
#endif
|
||||
GE128
|
||||
};
|
||||
@@ -85,8 +93,10 @@ namespace GAME
|
||||
{JsonAlphaTest::INVALID, nullptr },
|
||||
{JsonAlphaTest::DISABLED, "disabled"},
|
||||
{JsonAlphaTest::GT0, "gt0" },
|
||||
#if defined(FEATURE_IW4) || defined(FEATURE_IW5)
|
||||
#if defined(FEATURE_IW3) || defined(FEATURE_IW4) || defined(FEATURE_IW5)
|
||||
{JsonAlphaTest::LT128, "lt128" },
|
||||
#elif defined(FEATURE_T5)
|
||||
{JsonAlphaTest::GE255, "ge255" },
|
||||
#endif
|
||||
{JsonAlphaTest::GE128, "ge128" }
|
||||
});
|
||||
@@ -208,7 +218,7 @@ namespace GAME
|
||||
std::optional<std::string> name;
|
||||
std::optional<std::string> nameFragment;
|
||||
std::optional<unsigned> nameHash;
|
||||
std::vector<float> literal;
|
||||
std::array<float, 4> literal;
|
||||
};
|
||||
|
||||
inline void to_json(nlohmann::json& out, const JsonConstant& in)
|
||||
@@ -315,35 +325,31 @@ namespace GAME
|
||||
#endif
|
||||
|
||||
NLOHMANN_JSON_SERIALIZE_ENUM(TextureSemantic, {
|
||||
#if defined(FEATURE_IW4) || defined(FEATURE_IW5)
|
||||
{TS_2D, "2D" },
|
||||
{TS_FUNCTION, "function" },
|
||||
{TS_COLOR_MAP, "colorMap" },
|
||||
#if defined(FEATURE_IW3) || defined(FEATURE_T5) || defined(FEATURE_T6)
|
||||
{TS_UNUSED_1, "unused1" },
|
||||
#else
|
||||
{TS_DETAIL_MAP, "detailMap" },
|
||||
#endif
|
||||
{TS_UNUSED_2, "unused2" },
|
||||
{TS_NORMAL_MAP, "normalMap" },
|
||||
{TS_UNUSED_3, "unused3" },
|
||||
{TS_UNUSED_4, "unused4" },
|
||||
{TS_SPECULAR_MAP, "specularMap" },
|
||||
{TS_UNUSED_5, "unused5" },
|
||||
#ifdef FEATURE_T6
|
||||
{TS_OCCLUSION_MAP, "occlusionMap" },
|
||||
#endif
|
||||
{TS_UNUSED_6, "unused6" },
|
||||
#if defined(FEATURE_IW3) || defined(FEATURE_IW4) || defined(FEATURE_IW5) || defined(FEATURE_T5)
|
||||
{TS_WATER_MAP, "waterMap" },
|
||||
#endif
|
||||
#ifdef FEATURE_IW5
|
||||
{TS_DISPLACEMENT_MAP, "displacementMap"},
|
||||
#endif
|
||||
#elif defined(FEATURE_T6)
|
||||
{TS_2D, "2D" },
|
||||
{TS_FUNCTION, "function" },
|
||||
{TS_COLOR_MAP, "colorMap" },
|
||||
{TS_UNUSED_1, "unused1" },
|
||||
{TS_UNUSED_2, "unused2" },
|
||||
{TS_NORMAL_MAP, "normalMap" },
|
||||
{TS_UNUSED_3, "unused3" },
|
||||
{TS_UNUSED_4, "unused4" },
|
||||
{TS_SPECULAR_MAP, "specularMap" },
|
||||
{TS_UNUSED_5, "unused5" },
|
||||
{TS_OCCLUSION_MAP, "occlusionMap"},
|
||||
{TS_UNUSED_6, "unused6" },
|
||||
#if defined(FEATURE_T5) || defined(FEATURE_T6)
|
||||
{TS_COLOR0_MAP, "color0Map" },
|
||||
{TS_COLOR1_MAP, "color1Map" },
|
||||
{TS_COLOR2_MAP, "color2Map" },
|
||||
@@ -372,7 +378,7 @@ namespace GAME
|
||||
std::optional<std::string> nameStart;
|
||||
std::optional<std::string> nameEnd;
|
||||
TextureSemantic semantic;
|
||||
#ifdef FEATURE_T6
|
||||
#if defined(FEATURE_T5) || defined(FEATURE_T6)
|
||||
bool isMatureContent;
|
||||
#endif
|
||||
JsonSamplerState samplerState;
|
||||
@@ -396,7 +402,7 @@ namespace GAME
|
||||
}
|
||||
|
||||
out["semantic"] = in.semantic;
|
||||
#ifdef FEATURE_T6
|
||||
#if defined(FEATURE_T5) || defined(FEATURE_T6)
|
||||
out["isMatureContent"] = in.isMatureContent;
|
||||
#endif
|
||||
out["samplerState"] = in.samplerState;
|
||||
@@ -413,7 +419,7 @@ namespace GAME
|
||||
optional_from_json(in, "nameStart", out.nameStart);
|
||||
optional_from_json(in, "nameEnd", out.nameEnd);
|
||||
in.at("semantic").get_to(out.semantic);
|
||||
#ifdef FEATURE_T6
|
||||
#if defined(FEATURE_T5) || defined(FEATURE_T6)
|
||||
in.at("isMatureContent").get_to(out.isMatureContent);
|
||||
#endif
|
||||
in.at("samplerState").get_to(out.samplerState);
|
||||
@@ -437,36 +443,43 @@ namespace GAME
|
||||
);
|
||||
|
||||
NLOHMANN_JSON_SERIALIZE_ENUM(MaterialGameFlags, {
|
||||
#if defined(FEATURE_IW4) || defined(FEATURE_IW5)
|
||||
{MTL_GAMEFLAG_1, "1" },
|
||||
{MTL_GAMEFLAG_2, "2" },
|
||||
{MTL_GAMEFLAG_4, "4" },
|
||||
{MTL_GAMEFLAG_8, "8" },
|
||||
{MTL_GAMEFLAG_10, "10" },
|
||||
{MTL_GAMEFLAG_20, "20" },
|
||||
{MTL_GAMEFLAG_40, "40" },
|
||||
{MTL_GAMEFLAG_80, "80" },
|
||||
#elif defined(FEATURE_T6)
|
||||
{MTL_GAMEFLAG_1, "1" },
|
||||
{MTL_GAMEFLAG_2, "2" },
|
||||
#ifdef FEATURE_T6
|
||||
{MTL_GAMEFLAG_NO_MARKS, "NO_MARKS" },
|
||||
{MTL_GAMEFLAG_NO_MARKS, "4" },
|
||||
#else
|
||||
{MTL_GAMEFLAG_4, "4" },
|
||||
#endif
|
||||
{MTL_GAMEFLAG_8, "8" },
|
||||
{MTL_GAMEFLAG_10, "10" },
|
||||
{MTL_GAMEFLAG_20, "20" },
|
||||
#if defined(FEATURE_IW3) || defined(FEATURE_T5) || defined(FEATURE_T6)
|
||||
{MTL_GAMEFLAG_CASTS_SHADOW, "CASTS_SHADOW"},
|
||||
{MTL_GAMEFLAG_CASTS_SHADOW, "40" },
|
||||
#else
|
||||
{MTL_GAMEFLAG_40, "40" },
|
||||
#endif
|
||||
{MTL_GAMEFLAG_80, "80" },
|
||||
#if defined(FEATURE_T5) || defined(FEATURE_T6)
|
||||
{MTL_GAMEFLAG_100, "100" },
|
||||
{MTL_GAMEFLAG_200, "200" },
|
||||
#if defined(FEATURE_T6)
|
||||
{MTL_GAMEFLAG_400, "400" },
|
||||
{MTL_GAMEFLAG_800, "800" },
|
||||
{MTL_GAMEFLAG_1000, "1000" },
|
||||
{MTL_GAMEFLAG_2000, "2000" },
|
||||
{MTL_GAMEFLAG_4000, "4000" },
|
||||
#endif
|
||||
#endif
|
||||
});
|
||||
|
||||
NLOHMANN_JSON_SERIALIZE_ENUM(GfxCameraRegionType, {
|
||||
#if defined(FEATURE_IW4) || defined(FEATURE_IW5)
|
||||
#if defined(FEATURE_IW3) || defined(FEATURE_T5)
|
||||
{CAMERA_REGION_LIT, "lit" },
|
||||
{CAMERA_REGION_DECAL, "decal" },
|
||||
{CAMERA_REGION_EMISSIVE, "emissive" },
|
||||
#elif defined(FEATURE_IW4) || defined(FEATURE_IW5)
|
||||
{CAMERA_REGION_LIT_OPAQUE, "litOpaque" },
|
||||
{CAMERA_REGION_LIT_TRANS, "litTrans" },
|
||||
{CAMERA_REGION_EMISSIVE, "emissive" },
|
||||
@@ -474,7 +487,6 @@ namespace GAME
|
||||
#ifdef FEATURE_IW5
|
||||
{CAMERA_REGION_LIGHT_MAP_OPAQUE, "lightMapOpaque"},
|
||||
#endif
|
||||
{CAMERA_REGION_NONE, "none" },
|
||||
#elif defined(FEATURE_T6)
|
||||
{CAMERA_REGION_LIT_OPAQUE, "litOpaque" },
|
||||
{CAMERA_REGION_LIT_TRANS, "litTrans" },
|
||||
@@ -486,20 +498,20 @@ namespace GAME
|
||||
{CAMERA_REGION_DEPTH_HACK, "depthHack" },
|
||||
{CAMERA_REGION_UNUSED, "unused" },
|
||||
{CAMERA_REGION_SONAR, "sonar" },
|
||||
{CAMERA_REGION_NONE, "none" },
|
||||
#endif
|
||||
{CAMERA_REGION_NONE, "none" },
|
||||
});
|
||||
|
||||
class JsonMaterial
|
||||
{
|
||||
public:
|
||||
#ifdef FEATURE_T6
|
||||
#if defined(FEATURE_T5) || defined(FEATURE_T6)
|
||||
unsigned layeredSurfaceTypes;
|
||||
unsigned hashIndex;
|
||||
#if defined(FEATURE_T6)
|
||||
unsigned surfaceFlags;
|
||||
unsigned contents;
|
||||
uint8_t probeMipBits;
|
||||
std::optional<std::string> thermalMaterial;
|
||||
#endif
|
||||
#endif
|
||||
std::vector<MaterialGameFlags> gameFlags;
|
||||
unsigned sortKey;
|
||||
@@ -516,13 +528,13 @@ namespace GAME
|
||||
|
||||
NLOHMANN_DEFINE_TYPE_EXTENSION(
|
||||
JsonMaterial,
|
||||
#ifdef FEATURE_T6
|
||||
#if defined(FEATURE_T5) || defined(FEATURE_T6)
|
||||
layeredSurfaceTypes,
|
||||
hashIndex,
|
||||
#if defined(FEATURE_T6)
|
||||
surfaceFlags,
|
||||
contents,
|
||||
probeMipBits,
|
||||
thermalMaterial,
|
||||
#endif
|
||||
#endif
|
||||
gameFlags,
|
||||
sortKey,
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "GdtStream.h"
|
||||
|
||||
#include "Utils/Logging/Log.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
@@ -14,7 +16,7 @@ public:
|
||||
|
||||
void GdtReader::PrintError(const std::string& message) const
|
||||
{
|
||||
std::cout << "GDT Error at line " << m_line << ": " << message << "\n";
|
||||
con::error("GDT Error at line {}: {}", m_line, message);
|
||||
}
|
||||
|
||||
int GdtReader::PeekChar()
|
||||
|
||||
11
src/ObjCommon/PhysCollmap/PhysCollmapCommon.cpp
Normal file
11
src/ObjCommon/PhysCollmap/PhysCollmapCommon.cpp
Normal file
@@ -0,0 +1,11 @@
|
||||
#include "PhysCollmapCommon.h"
|
||||
|
||||
#include <format>
|
||||
|
||||
namespace phys_collmap
|
||||
{
|
||||
std::string GetFileNameForAssetName(const std::string& assetName)
|
||||
{
|
||||
return std::format("phys_collmaps/{}.map", assetName);
|
||||
}
|
||||
} // namespace phys_collmap
|
||||
8
src/ObjCommon/PhysCollmap/PhysCollmapCommon.h
Normal file
8
src/ObjCommon/PhysCollmap/PhysCollmapCommon.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace phys_collmap
|
||||
{
|
||||
std::string GetFileNameForAssetName(const std::string& assetName);
|
||||
}
|
||||
11
src/ObjCommon/PhysConstraints/PhysConstraintsCommon.cpp
Normal file
11
src/ObjCommon/PhysConstraints/PhysConstraintsCommon.cpp
Normal file
@@ -0,0 +1,11 @@
|
||||
#include "PhysConstraintsCommon.h"
|
||||
|
||||
#include <format>
|
||||
|
||||
namespace phys_constraints
|
||||
{
|
||||
std::string GetFileNameForAssetName(const std::string& assetName)
|
||||
{
|
||||
return std::format("physconstraints/{}", assetName);
|
||||
}
|
||||
} // namespace phys_constraints
|
||||
8
src/ObjCommon/PhysConstraints/PhysConstraintsCommon.h
Normal file
8
src/ObjCommon/PhysConstraints/PhysConstraintsCommon.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace phys_constraints
|
||||
{
|
||||
std::string GetFileNameForAssetName(const std::string& assetName);
|
||||
}
|
||||
11
src/ObjCommon/PhysPreset/PhysPresetCommon.cpp
Normal file
11
src/ObjCommon/PhysPreset/PhysPresetCommon.cpp
Normal file
@@ -0,0 +1,11 @@
|
||||
#include "PhysPresetCommon.h"
|
||||
|
||||
#include <format>
|
||||
|
||||
namespace phys_preset
|
||||
{
|
||||
std::string GetFileNameForAssetName(const std::string& assetName)
|
||||
{
|
||||
return std::format("physic/{}", assetName);
|
||||
}
|
||||
} // namespace phys_preset
|
||||
8
src/ObjCommon/PhysPreset/PhysPresetCommon.h
Normal file
8
src/ObjCommon/PhysPreset/PhysPresetCommon.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace phys_preset
|
||||
{
|
||||
std::string GetFileNameForAssetName(const std::string& assetName);
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "OutputPathFilesystem.h"
|
||||
|
||||
#include "Utils/Logging/Log.h"
|
||||
|
||||
#include <format>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
@@ -24,14 +26,14 @@ std::unique_ptr<std::ostream> OutputPathFilesystem::Open(const std::string& file
|
||||
fs::create_directories(containingDirectory, ec);
|
||||
if (ec)
|
||||
{
|
||||
std::cerr << std::format("Failed to create folder '{}' when try to open file '{}'\n", containingDirectory.string(), fileName);
|
||||
con::error("Failed to create folder '{}' when try to open file '{}'", containingDirectory.string(), fileName);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::ofstream stream(fullNewPath, std::ios::binary | std::ios::out);
|
||||
if (!stream.is_open())
|
||||
{
|
||||
std::cerr << std::format("Failed to open file '{}'\n", fileName);
|
||||
con::error("Failed to open file '{}'", fileName);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "SearchPathFilesystem.h"
|
||||
|
||||
#include "Utils/Logging/Log.h"
|
||||
#include "Utils/ObjFileStream.h"
|
||||
|
||||
#include <filesystem>
|
||||
@@ -59,6 +60,6 @@ void SearchPathFilesystem::Find(const SearchPathSearchOptions& options, const st
|
||||
}
|
||||
catch (std::filesystem::filesystem_error& e)
|
||||
{
|
||||
std::cerr << std::format("Directory Iterator threw error when trying to find files: \"{}\"\n", e.what());
|
||||
con::error("Directory Iterator threw error when trying to find files: \"{}\"", e.what());
|
||||
}
|
||||
}
|
||||
|
||||
16
src/ObjCommon/Shader/ShaderCommon.cpp
Normal file
16
src/ObjCommon/Shader/ShaderCommon.cpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#include "ShaderCommon.h"
|
||||
|
||||
#include <format>
|
||||
|
||||
namespace shader
|
||||
{
|
||||
std::string GetFileNameForPixelShaderAssetName(const std::string& assetName)
|
||||
{
|
||||
return std::format("shader_bin/ps_{}.cso", assetName);
|
||||
}
|
||||
|
||||
std::string GetFileNameForVertexShaderAssetName(const std::string& assetName)
|
||||
{
|
||||
return std::format("shader_bin/vs_{}.cso", assetName);
|
||||
}
|
||||
} // namespace shader
|
||||
9
src/ObjCommon/Shader/ShaderCommon.h
Normal file
9
src/ObjCommon/Shader/ShaderCommon.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace shader
|
||||
{
|
||||
std::string GetFileNameForPixelShaderAssetName(const std::string& assetName);
|
||||
std::string GetFileNameForVertexShaderAssetName(const std::string& assetName);
|
||||
} // namespace shader
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "Utils/ClassUtils.h"
|
||||
#include "Utils/Endianness.h"
|
||||
#include "Utils/FileUtils.h"
|
||||
#include "Utils/Logging/Log.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
@@ -232,7 +233,7 @@ namespace flac
|
||||
}
|
||||
catch (const FlacReadingException& e)
|
||||
{
|
||||
std::cerr << e.what() << "\n";
|
||||
con::error(e.what());
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
11
src/ObjCommon/Sound/SoundCurveCommon.cpp
Normal file
11
src/ObjCommon/Sound/SoundCurveCommon.cpp
Normal file
@@ -0,0 +1,11 @@
|
||||
#include "SoundCurveCommon.h"
|
||||
|
||||
#include <format>
|
||||
|
||||
namespace sound_curve
|
||||
{
|
||||
std::string GetFileNameForAssetName(const std::string& assetName)
|
||||
{
|
||||
return std::format("soundaliases/{}.vfcurve", assetName);
|
||||
}
|
||||
} // namespace sound_curve
|
||||
8
src/ObjCommon/Sound/SoundCurveCommon.h
Normal file
8
src/ObjCommon/Sound/SoundCurveCommon.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace sound_curve
|
||||
{
|
||||
std::string GetFileNameForAssetName(const std::string& assetName);
|
||||
}
|
||||
21
src/ObjCommon/Techset/TechsetCommon.cpp
Normal file
21
src/ObjCommon/Techset/TechsetCommon.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#include "TechsetCommon.h"
|
||||
|
||||
#include <format>
|
||||
|
||||
namespace techset
|
||||
{
|
||||
std::string GetFileNameForStateMapName(const std::string& stateMapName)
|
||||
{
|
||||
return std::format("statemaps/{}.sm", stateMapName);
|
||||
}
|
||||
|
||||
std::string GetFileNameForTechniqueName(const std::string& assetName)
|
||||
{
|
||||
return std::format("techniques/{}.tech", assetName);
|
||||
}
|
||||
|
||||
std::string GetFileNameForTechsetName(const std::string& assetName)
|
||||
{
|
||||
return std::format("techsets/{}.techset", assetName);
|
||||
}
|
||||
} // namespace techset
|
||||
10
src/ObjCommon/Techset/TechsetCommon.h
Normal file
10
src/ObjCommon/Techset/TechsetCommon.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace techset
|
||||
{
|
||||
std::string GetFileNameForStateMapName(const std::string& stateMapName);
|
||||
std::string GetFileNameForTechniqueName(const std::string& assetName);
|
||||
std::string GetFileNameForTechsetName(const std::string& assetName);
|
||||
} // namespace techset
|
||||
11
src/ObjCommon/Tracer/TracerCommon.cpp
Normal file
11
src/ObjCommon/Tracer/TracerCommon.cpp
Normal file
@@ -0,0 +1,11 @@
|
||||
#include "TracerCommon.h"
|
||||
|
||||
#include <format>
|
||||
|
||||
namespace tracer
|
||||
{
|
||||
std::string GetFileNameForAssetName(const std::string& assetName)
|
||||
{
|
||||
return std::format("tracer/{}", assetName);
|
||||
}
|
||||
} // namespace tracer
|
||||
8
src/ObjCommon/Tracer/TracerCommon.h
Normal file
8
src/ObjCommon/Tracer/TracerCommon.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace tracer
|
||||
{
|
||||
std::string GetFileNameForAssetName(const std::string& assetName);
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user