Linux build fixes
|
@ -33,10 +33,16 @@ CMakeLists.txt.user
|
|||
*.qmlproject.user
|
||||
*.qmlproject.user.*
|
||||
|
||||
#Intellij IDEA
|
||||
.idea/PrimeWorldEditor.iml
|
||||
.idea/misc.xml
|
||||
.idea/modules.xml
|
||||
.idea/vcs.xml
|
||||
.idea/workspace.xml
|
||||
|
||||
#Dew
|
||||
.dew/*
|
||||
|
||||
# PrimeWorldEditor files
|
||||
bin/*
|
||||
bin-debug/*
|
||||
build/*
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
<component name="ProjectCodeStyleConfiguration">
|
||||
<code_scheme name="Project" version="173">
|
||||
<Objective-C>
|
||||
<option name="NAMESPACE_BRACE_PLACEMENT" value="2" />
|
||||
<option name="FUNCTION_BRACE_PLACEMENT" value="2" />
|
||||
<option name="BLOCK_BRACE_PLACEMENT" value="2" />
|
||||
</Objective-C>
|
||||
<codeStyleSettings language="ObjectiveC">
|
||||
<option name="BRACE_STYLE" value="2" />
|
||||
<option name="CLASS_BRACE_STYLE" value="2" />
|
||||
</codeStyleSettings>
|
||||
</code_scheme>
|
||||
</component>
|
|
@ -0,0 +1,5 @@
|
|||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
|
||||
</state>
|
||||
</component>
|
|
@ -1,19 +1,17 @@
|
|||
cmake_minimum_required(VERSION 3.12)
|
||||
set(MACOSX_DEPLOYMENT_TARGET 10.10)
|
||||
|
||||
project(PrimeWorldEditor CXX)
|
||||
|
||||
include(./dew.cmake)
|
||||
integrate_dew()
|
||||
|
||||
include(cmake/generate_product_version.cmake)
|
||||
|
||||
# Set where the binary files will be built. The program will not execute from
|
||||
# here. You must run "make install" to install these to the proper location
|
||||
# as defined above.
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Binaries)
|
||||
|
||||
if (WIN32)
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_SOURCE_DIR}/bin-debug)
|
||||
endif()
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||
|
||||
add_subdirectory(src/Core)
|
||||
add_subdirectory(src/Editor)
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
#pragma once
|
||||
|
||||
#ifndef PRODUCT_VERSION_MAJOR
|
||||
#define PRODUCT_VERSION_MAJOR @PRODUCT_VERSION_MAJOR@
|
||||
#endif
|
||||
|
||||
#ifndef PRODUCT_VERSION_MINOR
|
||||
#define PRODUCT_VERSION_MINOR @PRODUCT_VERSION_MINOR@
|
||||
#endif
|
||||
|
||||
#ifndef PRODUCT_VERSION_PATCH
|
||||
#define PRODUCT_VERSION_PATCH @PRODUCT_VERSION_PATCH@
|
||||
#endif
|
||||
|
||||
#ifndef PRODUCT_VERSION_BUILD
|
||||
#define PRODUCT_VERSION_BUILD @PRODUCT_VERSION_REVISION@
|
||||
#endif
|
||||
|
||||
#ifndef FILE_VERSION_MAJOR
|
||||
#define FILE_VERSION_MAJOR @PRODUCT_VERSION_MAJOR@
|
||||
#endif
|
||||
|
||||
#ifndef FILE_VERSION_MINOR
|
||||
#define FILE_VERSION_MINOR @PRODUCT_VERSION_MINOR@
|
||||
#endif
|
||||
|
||||
#ifndef FILE_VERSION_PATCH
|
||||
#define FILE_VERSION_PATCH @PRODUCT_VERSION_PATCH@
|
||||
#endif
|
||||
|
||||
#ifndef FILE_VERSION_BUILD
|
||||
#define FILE_VERSION_BUILD @PRODUCT_VERSION_REVISION@
|
||||
#endif
|
||||
|
||||
#ifndef __TO_STRING
|
||||
#define __TO_STRING_IMPL(x) #x
|
||||
#define __TO_STRING(x) __TO_STRING_IMPL(x)
|
||||
#endif
|
||||
|
||||
#define PRODUCT_VERSION_MAJOR_MINOR_STR __TO_STRING(PRODUCT_VERSION_MAJOR) "." __TO_STRING(PRODUCT_VERSION_MINOR)
|
||||
#define PRODUCT_VERSION_MAJOR_MINOR_PATCH_STR PRODUCT_VERSION_MAJOR_MINOR_STR "." __TO_STRING(PRODUCT_VERSION_PATCH)
|
||||
#define PRODUCT_VERSION_FULL_STR PRODUCT_VERSION_MAJOR_MINOR_PATCH_STR "." __TO_STRING(PRODUCT_VERSION_BUILD)
|
||||
#define PRODUCT_VERSION_RESOURCE PRODUCT_VERSION_MAJOR,PRODUCT_VERSION_MINOR,PRODUCT_VERSION_PATCH,PRODUCT_VERSION_BUILD
|
||||
#define PRODUCT_VERSION_RESOURCE_STR PRODUCT_VERSION_FULL_STR "\0"
|
||||
|
||||
#define FILE_VERSION_MAJOR_MINOR_STR __TO_STRING(FILE_VERSION_MAJOR) "." __TO_STRING(FILE_VERSION_MINOR)
|
||||
#define FILE_VERSION_MAJOR_MINOR_PATCH_STR FILE_VERSION_MAJOR_MINOR_STR "." __TO_STRING(FILE_VERSION_PATCH)
|
||||
#define FILE_VERSION_FULL_STR FILE_VERSION_MAJOR_MINOR_PATCH_STR "." __TO_STRING(FILE_VERSION_BUILD)
|
||||
#define FILE_VERSION_RESOURCE FILE_VERSION_MAJOR,FILE_VERSION_MINOR,FILE_VERSION_PATCH,FILE_VERSION_BUILD
|
||||
#define FILE_VERSION_RESOURCE_STR FILE_VERSION_FULL_STR "\0"
|
||||
|
||||
#ifndef PRODUCT_ICON
|
||||
#define PRODUCT_ICON "@PRODUCT_ICON@"
|
||||
#endif
|
||||
|
||||
#ifndef PRODUCT_COMMENTS
|
||||
#define PRODUCT_COMMENTS "@PRODUCT_COMMENTS@\0"
|
||||
#endif
|
||||
|
||||
#ifndef PRODUCT_COMPANY_NAME
|
||||
#define PRODUCT_COMPANY_NAME "@PRODUCT_COMPANY_NAME@\0"
|
||||
#endif
|
||||
|
||||
#ifndef PRODUCT_COMPANY_COPYRIGHT
|
||||
#define PRODUCT_COMPANY_COPYRIGHT "@PRODUCT_COMPANY_COPYRIGHT@\0"
|
||||
#endif
|
||||
|
||||
#ifndef PRODUCT_FILE_DESCRIPTION
|
||||
#define PRODUCT_FILE_DESCRIPTION "@PRODUCT_FILE_DESCRIPTION@\0"
|
||||
#endif
|
||||
|
||||
#ifndef PRODUCT_INTERNAL_NAME
|
||||
#define PRODUCT_INTERNAL_NAME "@PRODUCT_NAME@\0"
|
||||
#endif
|
||||
|
||||
#ifndef PRODUCT_ORIGINAL_FILENAME
|
||||
#define PRODUCT_ORIGINAL_FILENAME "@PRODUCT_ORIGINAL_FILENAME@\0"
|
||||
#endif
|
||||
|
||||
#ifndef PRODUCT_BUNDLE
|
||||
#define PRODUCT_BUNDLE "@PRODUCT_BUNDLE@\0"
|
||||
#endif
|
|
@ -0,0 +1,40 @@
|
|||
#include "VersionInfo.h"
|
||||
#include "winres.h"
|
||||
|
||||
IDI_ICON1 ICON PRODUCT_ICON
|
||||
|
||||
LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION FILE_VERSION_RESOURCE
|
||||
PRODUCTVERSION PRODUCT_VERSION_RESOURCE
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS 0x4L
|
||||
FILETYPE 0x1L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "041904b0"
|
||||
BEGIN
|
||||
VALUE "Comments", PRODUCT_COMMENTS
|
||||
VALUE "CompanyName", PRODUCT_COMPANY_NAME
|
||||
VALUE "FileDescription", PRODUCT_FILE_DESCRIPTION
|
||||
VALUE "FileVersion", FILE_VERSION_RESOURCE_STR
|
||||
VALUE "InternalName", PRODUCT_INTERNAL_NAME
|
||||
VALUE "LegalCopyright", PRODUCT_COMPANY_COPYRIGHT
|
||||
VALUE "OriginalFilename", PRODUCT_ORIGINAL_FILENAME
|
||||
VALUE "ProductName", PRODUCT_BUNDLE
|
||||
VALUE "ProductVersion", PRODUCT_VERSION_RESOURCE_STR
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x419, 1200
|
||||
END
|
||||
END
|
|
@ -0,0 +1,107 @@
|
|||
include (CMakeParseArguments)
|
||||
|
||||
set (GenerateProductVersionCurrentDir ${CMAKE_CURRENT_LIST_DIR})
|
||||
|
||||
# generate_product_version() function
|
||||
#
|
||||
# This function uses VersionInfo.in template file and VersionResource.rc file
|
||||
# to generate WIN32 resource with version information and general resource strings.
|
||||
#
|
||||
# Usage:
|
||||
# generate_product_version(
|
||||
# SomeOutputResourceVariable
|
||||
# NAME MyGreatProject
|
||||
# ICON ${PATH_TO_APP_ICON}
|
||||
# VERSION_MAJOR 2
|
||||
# VERSION_MINOR 3
|
||||
# VERSION_PATH ${BUILD_COUNTER}
|
||||
# VERSION_REVISION ${BUILD_REVISION}
|
||||
# )
|
||||
# where BUILD_COUNTER and BUILD_REVISION could be values from your CI server.
|
||||
#
|
||||
# You can use generated resource for your executable targets:
|
||||
# add_executable(target-name ${target-files} ${SomeOutputResourceVariable})
|
||||
#
|
||||
# You can specify resource strings in arguments:
|
||||
# NAME - name of executable (no defaults, ex: Microsoft Word)
|
||||
# BUNDLE - bundle (${NAME} is default, ex: Microsoft Office)
|
||||
# ICON - path to application icon (${CMAKE_SOURCE_DIR}/product.ico by default)
|
||||
# VERSION_MAJOR - 1 is default
|
||||
# VERSION_MINOR - 0 is default
|
||||
# VERSION_PATCH - 0 is default
|
||||
# VERSION_REVISION - 0 is default
|
||||
# COMPANY_NAME - your company name (no defaults)
|
||||
# COMPANY_COPYRIGHT - ${COMPANY_NAME} (C) Copyright ${CURRENT_YEAR} is default
|
||||
# COMMENTS - ${NAME} v${VERSION_MAJOR}.${VERSION_MINOR} is default
|
||||
# ORIGINAL_FILENAME - ${NAME} is default
|
||||
# INTERNAL_NAME - ${NAME} is default
|
||||
# FILE_DESCRIPTION - ${NAME} is default
|
||||
function(generate_product_version outfiles)
|
||||
set (options)
|
||||
set (oneValueArgs
|
||||
NAME
|
||||
BUNDLE
|
||||
ICON
|
||||
VERSION_MAJOR
|
||||
VERSION_MINOR
|
||||
VERSION_PATCH
|
||||
VERSION_REVISION
|
||||
COMPANY_NAME
|
||||
COMPANY_COPYRIGHT
|
||||
COMMENTS
|
||||
ORIGINAL_FILENAME
|
||||
INTERNAL_NAME
|
||||
FILE_DESCRIPTION)
|
||||
set (multiValueArgs)
|
||||
cmake_parse_arguments(PRODUCT "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
if (NOT PRODUCT_BUNDLE OR "${PRODUCT_BUNDLE}" STREQUAL "")
|
||||
set(PRODUCT_BUNDLE "${PRODUCT_NAME}")
|
||||
endif()
|
||||
if (NOT PRODUCT_ICON OR "${PRODUCT_ICON}" STREQUAL "")
|
||||
set(PRODUCT_ICON "${CMAKE_SOURCE_DIR}/product.ico")
|
||||
endif()
|
||||
|
||||
if (NOT PRODUCT_VERSION_MAJOR EQUAL 0 AND (NOT PRODUCT_VERSION_MAJOR OR "${PRODUCT_VERSION_MAJOR}" STREQUAL ""))
|
||||
set(PRODUCT_VERSION_MAJOR 1)
|
||||
endif()
|
||||
if (NOT PRODUCT_VERSION_MINOR EQUAL 0 AND (NOT PRODUCT_VERSION_MINOR OR "${PRODUCT_VERSION_MINOR}" STREQUAL ""))
|
||||
set(PRODUCT_VERSION_MINOR 0)
|
||||
endif()
|
||||
if (NOT PRODUCT_VERSION_PATCH EQUAL 0 AND (NOT PRODUCT_VERSION_PATCH OR "${PRODUCT_VERSION_PATCH}" STREQUAL ""))
|
||||
set(PRODUCT_VERSION_PATCH 0)
|
||||
endif()
|
||||
if (NOT PRODUCT_VERSION_REVISION EQUAL 0 AND (NOT PRODUCT_VERSION_REVISION OR "${PRODUCT_VERSION_REVISION}" STREQUAL ""))
|
||||
set(PRODUCT_VERSION_REVISION 0)
|
||||
endif()
|
||||
|
||||
if (NOT PRODUCT_COMPANY_COPYRIGHT OR "${PRODUCT_COMPANY_COPYRIGHT}" STREQUAL "")
|
||||
string(TIMESTAMP PRODUCT_CURRENT_YEAR "%Y")
|
||||
set(PRODUCT_COMPANY_COPYRIGHT "${PRODUCT_COMPANY_NAME} (C) Copyright ${PRODUCT_CURRENT_YEAR}")
|
||||
endif()
|
||||
if (NOT PRODUCT_COMMENTS OR "${PRODUCT_COMMENTS}" STREQUAL "")
|
||||
set(PRODUCT_COMMENTS "${PRODUCT_NAME} v${PRODUCT_VERSION_MAJOR}.${PRODUCT_VERSION_MINOR}")
|
||||
endif()
|
||||
if (NOT PRODUCT_ORIGINAL_FILENAME OR "${PRODUCT_ORIGINAL_FILENAME}" STREQUAL "")
|
||||
set(PRODUCT_ORIGINAL_FILENAME "${PRODUCT_NAME}")
|
||||
endif()
|
||||
if (NOT PRODUCT_INTERNAL_NAME OR "${PRODUCT_INTERNAL_NAME}" STREQUAL "")
|
||||
set(PRODUCT_INTERNAL_NAME "${PRODUCT_NAME}")
|
||||
endif()
|
||||
if (NOT PRODUCT_FILE_DESCRIPTION OR "${PRODUCT_FILE_DESCRIPTION}" STREQUAL "")
|
||||
set(PRODUCT_FILE_DESCRIPTION "${PRODUCT_NAME}")
|
||||
endif()
|
||||
|
||||
set (_VersionInfoFile ${CMAKE_CURRENT_BINARY_DIR}/VersionInfo.h)
|
||||
set (_VersionResourceFile ${CMAKE_CURRENT_BINARY_DIR}/VersionResource.rc)
|
||||
configure_file(
|
||||
${GenerateProductVersionCurrentDir}/VersionInfo.in
|
||||
${_VersionInfoFile}
|
||||
@ONLY)
|
||||
configure_file(
|
||||
${GenerateProductVersionCurrentDir}/VersionResource.rc
|
||||
${_VersionResourceFile}
|
||||
COPYONLY)
|
||||
list(APPEND ${outfiles} ${_VersionInfoFile} ${_VersionResourceFile})
|
||||
set (${outfiles} ${${outfiles}} PARENT_SCOPE)
|
||||
endfunction()
|
|
@ -17,7 +17,7 @@ function(integrate_dew)
|
|||
return()
|
||||
endif()
|
||||
|
||||
if (${CMAKE_BUILD_TYPE} STREQUAL Debug)
|
||||
if ("${CMAKE_BUILD_TYPE}" STREQUAL Debug)
|
||||
set(dew_cmake_prefix_suffix debug)
|
||||
else()
|
||||
set(dew_cmake_prefix_suffix release)
|
||||
|
|
11
dewfile.json
|
@ -12,12 +12,13 @@
|
|||
"url": "https://github.com/jackoalan/assimp",
|
||||
"type": "git",
|
||||
"head": "static-lib-export",
|
||||
"ref": "2c16b2f6c517006367a558c06075584bbd230367",
|
||||
"ref": "d048bccad1ea3f72906da2d970b30f187db91f33",
|
||||
"dependson": [
|
||||
"zlib"
|
||||
],
|
||||
"cmake_defines": {
|
||||
"ASSIMP_BUILD_ZLIB": "OFF",
|
||||
"ASSIMP_BUILD_MINIZIP": "ON",
|
||||
"ASSIMP_BUILD_ASSIMP_TOOLS": "OFF"
|
||||
}
|
||||
},
|
||||
|
@ -26,21 +27,21 @@
|
|||
"url": "https://github.com/AxioDL/nod",
|
||||
"type": "git",
|
||||
"head": "master",
|
||||
"ref": "4dd0375cae9557a1881d56f722e20557075a9d93"
|
||||
"ref": "a1284ae06586b958f36b8ecaba29390835ed2820"
|
||||
},
|
||||
{
|
||||
"name": "CodeGen",
|
||||
"url": "https://github.com/jackoalan/CodeGen",
|
||||
"type": "git",
|
||||
"head": "cmake",
|
||||
"ref": "94dc9ac32986f14a734c3523dd85d50ae50f7128"
|
||||
"ref": "7a71e4866a60c5bf49e6d8f26717726d939c2aaf"
|
||||
},
|
||||
{
|
||||
"name": "LibCommon",
|
||||
"url": "https://github.com/jackoalan/LibCommon",
|
||||
"type": "git",
|
||||
"head": "dew",
|
||||
"ref": "4c780619259a31168e6a8ce6e7018b2ea640b3af"
|
||||
"ref": "f5c22715fbeb451a167ec3494f9d40ad53866029"
|
||||
},
|
||||
{
|
||||
"name": "lzo",
|
||||
|
@ -64,4 +65,4 @@
|
|||
"ref": "c483646db00a6a9ac3a8e93f7c490aecb589979d"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,10 @@ find_package(logvisor CONFIG REQUIRED)
|
|||
find_package(lzokay CONFIG REQUIRED)
|
||||
find_package(OpenGL REQUIRED)
|
||||
find_package(assimp CONFIG REQUIRED)
|
||||
find_package(zlib REQUIRED)
|
||||
find_package(ZLIB REQUIRED)
|
||||
|
||||
# AssImp's cmake config is pretty awful. It doesn't include necesary libraries. Hopefully this can be fixed later.
|
||||
find_library(IIRXML_LIBRARY NAMES IrrXMLd IrrXML)
|
||||
|
||||
include(codegen)
|
||||
|
||||
|
@ -41,6 +44,7 @@ target_link_libraries(
|
|||
OpenGL::GL
|
||||
codegen::codegen
|
||||
assimp::assimp
|
||||
${IIRXML_LIBRARY}
|
||||
${ZLIB_LIBRARY}
|
||||
)
|
||||
|
||||
|
|
|
@ -182,7 +182,7 @@ void CAssetNameMap::PostLoadValidate()
|
|||
|
||||
for (auto Iter = Dupes.begin(); Iter != Dupes.end(); Iter++)
|
||||
{
|
||||
warnf("\t%s", Iter->FullPath());
|
||||
warnf("\t%s", *Iter->FullPath());
|
||||
}
|
||||
|
||||
mMap.clear();
|
||||
|
@ -195,7 +195,7 @@ TString CAssetNameMap::DefaultNameMapPath(EIDLength IDLength)
|
|||
{
|
||||
ASSERT(IDLength != kInvalidIDLength);
|
||||
TString Suffix = (IDLength == k32Bit ? "32" : "64");
|
||||
return gkAssetMapPath + Suffix + "." + gkAssetMapExt;
|
||||
return gDataDir + gkAssetMapPath + Suffix + "." + gkAssetMapExt;
|
||||
}
|
||||
|
||||
TString CAssetNameMap::DefaultNameMapPath(EGame Game)
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include <map>
|
||||
#include <memory>
|
||||
|
||||
const TString gkAssetMapPath = "../resources/gameinfo/AssetNameMap";
|
||||
const TString gkAssetMapPath = "resources/gameinfo/AssetNameMap";
|
||||
const TString gkAssetMapExt = "xml";
|
||||
|
||||
class CAssetNameMap
|
||||
|
|
|
@ -19,6 +19,12 @@
|
|||
#define USE_ASSET_NAME_MAP 1
|
||||
#define EXPORT_COOKED 1
|
||||
|
||||
#if NOD_UCS2
|
||||
static nod::SystemStringView TStringToNodString(const TString& string) { return ToWChar(string); }
|
||||
#else
|
||||
static nod::SystemStringView TStringToNodString(const TString& string) { return *string; }
|
||||
#endif
|
||||
|
||||
CGameExporter::CGameExporter(EDiscType DiscType, EGame Game, bool FrontEnd, ERegion Region, const TString& rkGameName, const TString& rkGameID, float BuildVersion)
|
||||
: mGame(Game)
|
||||
, mRegion(Region)
|
||||
|
@ -198,16 +204,16 @@ bool CGameExporter::ExtractDiscData()
|
|||
if (IsWii)
|
||||
{
|
||||
// Extract crypto files
|
||||
if (!pDataPartition->extractCryptoFiles(ToWChar(AbsDiscDir), Context))
|
||||
if (!pDataPartition->extractCryptoFiles(TStringToNodString(AbsDiscDir), Context))
|
||||
return false;
|
||||
|
||||
// Extract disc header files
|
||||
if (!mpDisc->extractDiscHeaderFiles(ToWChar(AbsDiscDir), Context))
|
||||
if (!mpDisc->extractDiscHeaderFiles(TStringToNodString(AbsDiscDir), Context))
|
||||
return false;
|
||||
}
|
||||
|
||||
// Extract system files
|
||||
if (!pDataPartition->extractSysFiles(ToWChar(AbsDiscDir), Context))
|
||||
if (!pDataPartition->extractSysFiles(TStringToNodString(AbsDiscDir), Context))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
@ -226,7 +232,7 @@ bool CGameExporter::ExtractDiscNodeRecursive(const nod::Node *pkNode, const TStr
|
|||
if (Iter->getKind() == nod::Node::Kind::File)
|
||||
{
|
||||
TString FilePath = rkDir + Iter->getName().data();
|
||||
bool Success = Iter->extractToDirectory(ToWChar(rkDir), rkContext);
|
||||
bool Success = Iter->extractToDirectory(TStringToNodString(rkDir), rkContext);
|
||||
if (!Success) return false;
|
||||
|
||||
if (FilePath.GetFileExtension().CaseInsensitiveCompare("pak"))
|
||||
|
|
|
@ -63,6 +63,7 @@ class CGameExporter
|
|||
// Progress
|
||||
IProgressNotifier *mpProgress;
|
||||
|
||||
public:
|
||||
enum EExportStep
|
||||
{
|
||||
eES_ExtractDisc,
|
||||
|
@ -72,7 +73,6 @@ class CGameExporter
|
|||
eES_NumSteps
|
||||
};
|
||||
|
||||
public:
|
||||
CGameExporter(EDiscType DiscType, EGame Game, bool FrontEnd, ERegion Region, const TString& rkGameName, const TString& rkGameID, float BuildVersion);
|
||||
bool Export(nod::DiscBase *pDisc, const TString& rkOutputDir, CAssetNameMap *pNameMap, CGameInfo *pGameInfo, IProgressNotifier *pProgress);
|
||||
void LoadResource(const CAssetID& rkID, std::vector<uint8>& rBuffer);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "CGameInfo.h"
|
||||
#include "CResourceStore.h"
|
||||
#include <Common/FileUtil.h>
|
||||
|
||||
bool CGameInfo::LoadGameInfo(EGame Game)
|
||||
|
@ -83,5 +84,5 @@ TString CGameInfo::GetDefaultGameInfoPath(EGame Game)
|
|||
return "";
|
||||
|
||||
TString GameName = GetGameShortName(Game);
|
||||
return TString::Format("%s/GameInfo%s.%s", *gkGameInfoDir, *GameName, *gkGameInfoExt);
|
||||
return TString::Format("%s/%s/GameInfo%s.%s", *gDataDir, *gkGameInfoDir, *GameName, *gkGameInfoExt);
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include <Common/Serialization/XML.h>
|
||||
#include <map>
|
||||
|
||||
const TString gkGameInfoDir = "../resources/gameinfo";
|
||||
const TString gkGameInfoDir = "resources/gameinfo";
|
||||
const TString gkGameInfoExt = "xml";
|
||||
|
||||
//@todo merge this class into CGameTemplate
|
||||
|
|
|
@ -5,6 +5,12 @@
|
|||
#include <Common/Serialization/XML.h>
|
||||
#include <nod/nod.hpp>
|
||||
|
||||
#if NOD_UCS2
|
||||
static nod::SystemStringView TStringToNodString(const TString& string) { return ToWChar(string); }
|
||||
#else
|
||||
static nod::SystemStringView TStringToNodString(const TString& string) { return *string; }
|
||||
#endif
|
||||
|
||||
CGameProject::~CGameProject()
|
||||
{
|
||||
if (mpResourceStore)
|
||||
|
@ -88,13 +94,13 @@ bool CGameProject::BuildISO(const TString& rkIsoPath, IProgressNotifier *pProgre
|
|||
|
||||
if (!IsWiiBuild())
|
||||
{
|
||||
nod::DiscBuilderGCN Builder(ToWChar(rkIsoPath), ProgressCallback);
|
||||
return Builder.buildFromDirectory(ToWChar(DiscRoot)) == nod::EBuildResult::Success;
|
||||
nod::DiscBuilderGCN Builder(TStringToNodString(rkIsoPath), ProgressCallback);
|
||||
return Builder.buildFromDirectory(TStringToNodString(DiscRoot)) == nod::EBuildResult::Success;
|
||||
}
|
||||
else
|
||||
{
|
||||
nod::DiscBuilderWii Builder(ToWChar(rkIsoPath), IsTrilogy(), ProgressCallback);
|
||||
return Builder.buildFromDirectory(ToWChar(DiscRoot)) == nod::EBuildResult::Success;
|
||||
nod::DiscBuilderWii Builder(TStringToNodString(rkIsoPath), IsTrilogy(), ProgressCallback);
|
||||
return Builder.buildFromDirectory(TStringToNodString(DiscRoot)) == nod::EBuildResult::Success;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -113,8 +119,8 @@ bool CGameProject::MergeISO(const TString& rkIsoPath, nod::DiscWii *pOriginalIso
|
|||
|
||||
TString DiscRoot = DiscFilesystemRoot(false);
|
||||
|
||||
nod::DiscMergerWii Merger(ToWChar(rkIsoPath), *pOriginalIso, IsTrilogy(), ProgressCallback);
|
||||
return Merger.mergeFromDirectory(ToWChar(DiscRoot)) == nod::EBuildResult::Success;
|
||||
nod::DiscMergerWii Merger(TStringToNodString(rkIsoPath), *pOriginalIso, IsTrilogy(), ProgressCallback);
|
||||
return Merger.mergeFromDirectory(TStringToNodString(DiscRoot)) == nod::EBuildResult::Success;
|
||||
}
|
||||
|
||||
void CGameProject::GetWorldList(std::list<CAssetID>& rOut) const
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <tinyxml2.h>
|
||||
|
||||
using namespace tinyxml2;
|
||||
TString gDataDir;
|
||||
CResourceStore *gpResourceStore = nullptr;
|
||||
CResourceStore *gpEditorStore = nullptr;
|
||||
|
||||
|
@ -607,6 +608,19 @@ bool CResourceStore::DeleteResourceEntry(CResourceEntry *pEntry)
|
|||
return true;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
static int wrap_fopen(FILE** pFile, const char *filename, const char *mode)
|
||||
{
|
||||
return fopen_s(pFile, filename, mode);
|
||||
}
|
||||
#else
|
||||
static int wrap_fopen(FILE** pFile, const char *filename, const char *mode)
|
||||
{
|
||||
*pFile = fopen(filename, mode);
|
||||
return *pFile == nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
void CResourceStore::ImportNamesFromPakContentsTxt(const TString& rkTxtPath, bool UnnamedOnly)
|
||||
{
|
||||
// Read file contents -first- then move assets -after-; this
|
||||
|
@ -615,7 +629,7 @@ void CResourceStore::ImportNamesFromPakContentsTxt(const TString& rkTxtPath, boo
|
|||
// todo: move to CAssetNameMap?
|
||||
std::map<CResourceEntry*, TString> PathMap;
|
||||
FILE *pContentsFile;
|
||||
fopen_s(&pContentsFile, *rkTxtPath, "r");
|
||||
wrap_fopen(&pContentsFile, *rkTxtPath, "r");
|
||||
|
||||
if (!pContentsFile)
|
||||
{
|
||||
|
|
|
@ -93,6 +93,7 @@ public:
|
|||
inline bool IsEditorStore() const { return mpProj == nullptr; }
|
||||
};
|
||||
|
||||
extern TString gDataDir;
|
||||
extern CResourceStore *gpResourceStore;
|
||||
extern CResourceStore *gpEditorStore;
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ TString CVirtualDirectory::FullPath() const
|
|||
if (IsRoot())
|
||||
return "";
|
||||
else
|
||||
return (mpParent ? mpParent->FullPath() + mName : mName) + '/';
|
||||
return (mpParent ? mpParent->FullPath() + mName : static_cast<TString::BaseClass>(mName)) + '/';
|
||||
}
|
||||
|
||||
TString CVirtualDirectory::AbsolutePath() const
|
||||
|
@ -89,7 +89,7 @@ CVirtualDirectory* CVirtualDirectory::GetRoot()
|
|||
CVirtualDirectory* CVirtualDirectory::FindChildDirectory(const TString& rkName, bool AllowCreate)
|
||||
{
|
||||
uint32 SlashIdx = rkName.IndexOf("\\/");
|
||||
TString DirName = (SlashIdx == -1 ? rkName : rkName.SubString(0, SlashIdx));
|
||||
TString DirName = (SlashIdx == -1 ? static_cast<TString::BaseClass>(rkName) : rkName.SubString(0, SlashIdx));
|
||||
|
||||
for (uint32 iSub = 0; iSub < mSubdirectories.size(); iSub++)
|
||||
{
|
||||
|
@ -173,7 +173,7 @@ bool CVirtualDirectory::AddChild(const TString &rkPath, CResourceEntry *pEntry)
|
|||
else if (IsValidDirectoryPath(rkPath))
|
||||
{
|
||||
uint32 SlashIdx = rkPath.IndexOf("\\/");
|
||||
TString DirName = (SlashIdx == -1 ? rkPath : rkPath.SubString(0, SlashIdx));
|
||||
TString DirName = (SlashIdx == -1 ? static_cast<TString::BaseClass>(rkPath) : rkPath.SubString(0, SlashIdx));
|
||||
TString Remaining = (SlashIdx == -1 ? "" : rkPath.SubString(SlashIdx + 1, rkPath.Size() - SlashIdx));
|
||||
|
||||
// Check if this subdirectory already exists
|
||||
|
@ -286,7 +286,7 @@ void CVirtualDirectory::SortSubdirectories()
|
|||
|
||||
bool CVirtualDirectory::Rename(const TString& rkNewName)
|
||||
{
|
||||
debugf("MOVING DIRECTORY: %s --> %s", *FullPath(), *mpParent->FullPath() + rkNewName + '/');
|
||||
debugf("MOVING DIRECTORY: %s --> %s", *FullPath(), *(mpParent->FullPath() + rkNewName + '/'));
|
||||
|
||||
if (!IsRoot())
|
||||
{
|
||||
|
|
|
@ -12,7 +12,7 @@ class CRenderbuffer
|
|||
bool mInitialized;
|
||||
|
||||
public:
|
||||
CRenderbuffer::CRenderbuffer()
|
||||
CRenderbuffer()
|
||||
: mWidth(0)
|
||||
, mHeight(0)
|
||||
, mEnableMultisampling(false)
|
||||
|
@ -20,7 +20,7 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
CRenderbuffer::CRenderbuffer(uint Width, uint Height)
|
||||
CRenderbuffer(uint Width, uint Height)
|
||||
: mWidth(Width)
|
||||
, mHeight(Height)
|
||||
, mEnableMultisampling(false)
|
||||
|
@ -28,20 +28,20 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
CRenderbuffer::~CRenderbuffer()
|
||||
~CRenderbuffer()
|
||||
{
|
||||
if (mInitialized)
|
||||
glDeleteRenderbuffers(1, &mRenderbuffer);
|
||||
}
|
||||
|
||||
void CRenderbuffer::Init()
|
||||
void Init()
|
||||
{
|
||||
mInitialized = true;
|
||||
glGenRenderbuffers(1, &mRenderbuffer);
|
||||
InitStorage();
|
||||
}
|
||||
|
||||
inline void CRenderbuffer::Resize(uint Width, uint Height)
|
||||
inline void Resize(uint Width, uint Height)
|
||||
{
|
||||
mWidth = Width;
|
||||
mHeight = Height;
|
||||
|
@ -50,13 +50,13 @@ public:
|
|||
InitStorage();
|
||||
}
|
||||
|
||||
inline void CRenderbuffer::Bind()
|
||||
inline void Bind()
|
||||
{
|
||||
if (!mInitialized) Init();
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, mRenderbuffer);
|
||||
}
|
||||
|
||||
inline void CRenderbuffer::Unbind()
|
||||
inline void Unbind()
|
||||
{
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, 0);
|
||||
}
|
||||
|
|
|
@ -216,8 +216,8 @@ void CShader::SetCurrent()
|
|||
// ************ STATIC ************
|
||||
CShader* CShader::FromResourceFile(const TString& rkShaderName)
|
||||
{
|
||||
TString VertexShaderFilename = "../resources/shaders/" + rkShaderName + ".vs";
|
||||
TString PixelShaderFilename = "../resources/shaders/" + rkShaderName + ".ps";
|
||||
TString VertexShaderFilename = gDataDir + "resources/shaders/" + rkShaderName + ".vs";
|
||||
TString PixelShaderFilename = gDataDir + "resources/shaders/" + rkShaderName + ".ps";
|
||||
TString VertexShaderText, PixelShaderText;
|
||||
|
||||
if (!FileUtil::LoadFileToString(VertexShaderFilename, VertexShaderText))
|
||||
|
|
|
@ -6,18 +6,18 @@
|
|||
#include <iostream>
|
||||
|
||||
// ************ MEMBER INITIALIZATION ************
|
||||
CVertexBuffer CDrawUtil::mGridVertices;
|
||||
std::optional<CVertexBuffer> CDrawUtil::mGridVertices;
|
||||
CIndexBuffer CDrawUtil::mGridIndices;
|
||||
|
||||
CDynamicVertexBuffer CDrawUtil::mSquareVertices;
|
||||
std::optional<CDynamicVertexBuffer> CDrawUtil::mSquareVertices;
|
||||
CIndexBuffer CDrawUtil::mSquareIndices;
|
||||
|
||||
CDynamicVertexBuffer CDrawUtil::mLineVertices;
|
||||
std::optional<CDynamicVertexBuffer> CDrawUtil::mLineVertices;
|
||||
CIndexBuffer CDrawUtil::mLineIndices;
|
||||
|
||||
TResPtr<CModel> CDrawUtil::mpCubeModel;
|
||||
|
||||
CVertexBuffer CDrawUtil::mWireCubeVertices;
|
||||
std::optional<CVertexBuffer> CDrawUtil::mWireCubeVertices;
|
||||
CIndexBuffer CDrawUtil::mWireCubeIndices;
|
||||
|
||||
TResPtr<CModel> CDrawUtil::mpSphereModel;
|
||||
|
@ -45,7 +45,7 @@ void CDrawUtil::DrawGrid(CColor LineColor, CColor BoldLineColor)
|
|||
{
|
||||
Init();
|
||||
|
||||
mGridVertices.Bind();
|
||||
mGridVertices->Bind();
|
||||
|
||||
CGraphics::sMVPBlock.ModelMatrix = CMatrix4f::skIdentity;
|
||||
CGraphics::UpdateMVPBlock();
|
||||
|
@ -88,13 +88,13 @@ void CDrawUtil::DrawSquare(const float *pTexCoords)
|
|||
for (uint32 iTex = 0; iTex < 8; iTex++)
|
||||
{
|
||||
EVertexAttribute TexAttrib = (EVertexAttribute) ((uint) (EVertexAttribute::Tex0) << iTex);
|
||||
mSquareVertices.BufferAttrib(TexAttrib, pTexCoords);
|
||||
mSquareVertices->BufferAttrib(TexAttrib, pTexCoords);
|
||||
}
|
||||
|
||||
// Draw
|
||||
mSquareVertices.Bind();
|
||||
mSquareVertices->Bind();
|
||||
mSquareIndices.DrawElements();
|
||||
mSquareVertices.Unbind();
|
||||
mSquareVertices->Unbind();
|
||||
}
|
||||
|
||||
void CDrawUtil::DrawLine(const CVector3f& PointA, const CVector3f& PointB)
|
||||
|
@ -114,13 +114,13 @@ void CDrawUtil::DrawLine(const CVector3f& PointA, const CVector3f& PointB, const
|
|||
|
||||
// Copy vec3s into an array to ensure they are adjacent in memory
|
||||
CVector3f Points[2] = { PointA, PointB };
|
||||
mLineVertices.BufferAttrib(EVertexAttribute::Position, Points);
|
||||
mLineVertices->BufferAttrib(EVertexAttribute::Position, Points);
|
||||
|
||||
// Draw
|
||||
UseColorShader(LineColor);
|
||||
mLineVertices.Bind();
|
||||
mLineVertices->Bind();
|
||||
mLineIndices.DrawElements();
|
||||
mLineVertices.Unbind();
|
||||
mLineVertices->Unbind();
|
||||
}
|
||||
|
||||
void CDrawUtil::DrawLine(const CVector2f& PointA, const CVector2f& PointB, const CColor& LineColor)
|
||||
|
@ -161,9 +161,9 @@ void CDrawUtil::DrawWireCube()
|
|||
{
|
||||
Init();
|
||||
glLineWidth(1.f);
|
||||
mWireCubeVertices.Bind();
|
||||
mWireCubeVertices->Bind();
|
||||
mWireCubeIndices.DrawElements();
|
||||
mWireCubeVertices.Unbind();
|
||||
mWireCubeVertices->Unbind();
|
||||
}
|
||||
|
||||
void CDrawUtil::DrawWireCube(const CAABox& kAABox, const CColor& kColor)
|
||||
|
@ -413,22 +413,23 @@ void CDrawUtil::InitGrid()
|
|||
int MinIdx = (kGridSize - 1) / -2;
|
||||
int MaxIdx = (kGridSize - 1) / 2;
|
||||
|
||||
mGridVertices.SetVertexDesc(EVertexAttribute::Position);
|
||||
mGridVertices.Reserve(kGridSize * 4);
|
||||
mGridVertices.emplace();
|
||||
mGridVertices->SetVertexDesc(EVertexAttribute::Position);
|
||||
mGridVertices->Reserve(kGridSize * 4);
|
||||
|
||||
for (int32 i = MinIdx; i <= MaxIdx; i++)
|
||||
{
|
||||
if (i == 0) continue;
|
||||
mGridVertices.AddVertex(CVector3f(MinIdx * kGridSpacing, i * kGridSpacing, 0.0f));
|
||||
mGridVertices.AddVertex(CVector3f(MaxIdx * kGridSpacing, i * kGridSpacing, 0.0f));
|
||||
mGridVertices.AddVertex(CVector3f(i * kGridSpacing, MinIdx * kGridSpacing, 0.0f));
|
||||
mGridVertices.AddVertex(CVector3f(i * kGridSpacing, MaxIdx * kGridSpacing, 0.0f));
|
||||
mGridVertices->AddVertex(CVector3f(MinIdx * kGridSpacing, i * kGridSpacing, 0.0f));
|
||||
mGridVertices->AddVertex(CVector3f(MaxIdx * kGridSpacing, i * kGridSpacing, 0.0f));
|
||||
mGridVertices->AddVertex(CVector3f(i * kGridSpacing, MinIdx * kGridSpacing, 0.0f));
|
||||
mGridVertices->AddVertex(CVector3f(i * kGridSpacing, MaxIdx * kGridSpacing, 0.0f));
|
||||
}
|
||||
|
||||
mGridVertices.AddVertex(CVector3f(MinIdx * kGridSpacing, 0, 0.0f));
|
||||
mGridVertices.AddVertex(CVector3f(MaxIdx * kGridSpacing, 0, 0.0f));
|
||||
mGridVertices.AddVertex(CVector3f(0, MinIdx * kGridSpacing, 0.0f));
|
||||
mGridVertices.AddVertex(CVector3f(0, MaxIdx * kGridSpacing, 0.0f));
|
||||
mGridVertices->AddVertex(CVector3f(MinIdx * kGridSpacing, 0, 0.0f));
|
||||
mGridVertices->AddVertex(CVector3f(MaxIdx * kGridSpacing, 0, 0.0f));
|
||||
mGridVertices->AddVertex(CVector3f(0, MinIdx * kGridSpacing, 0.0f));
|
||||
mGridVertices->AddVertex(CVector3f(0, MaxIdx * kGridSpacing, 0.0f));
|
||||
|
||||
int NumIndices = kGridSize * 4;
|
||||
mGridIndices.Reserve(NumIndices);
|
||||
|
@ -439,17 +440,18 @@ void CDrawUtil::InitGrid()
|
|||
void CDrawUtil::InitSquare()
|
||||
{
|
||||
debugf("Creating square");
|
||||
mSquareVertices.SetActiveAttribs(EVertexAttribute::Position |
|
||||
EVertexAttribute::Normal |
|
||||
EVertexAttribute::Tex0 |
|
||||
EVertexAttribute::Tex1 |
|
||||
EVertexAttribute::Tex2 |
|
||||
EVertexAttribute::Tex3 |
|
||||
EVertexAttribute::Tex4 |
|
||||
EVertexAttribute::Tex5 |
|
||||
EVertexAttribute::Tex6 |
|
||||
EVertexAttribute::Tex7 );
|
||||
mSquareVertices.SetVertexCount(4);
|
||||
mSquareVertices.emplace();
|
||||
mSquareVertices->SetActiveAttribs(EVertexAttribute::Position |
|
||||
EVertexAttribute::Normal |
|
||||
EVertexAttribute::Tex0 |
|
||||
EVertexAttribute::Tex1 |
|
||||
EVertexAttribute::Tex2 |
|
||||
EVertexAttribute::Tex3 |
|
||||
EVertexAttribute::Tex4 |
|
||||
EVertexAttribute::Tex5 |
|
||||
EVertexAttribute::Tex6 |
|
||||
EVertexAttribute::Tex7 );
|
||||
mSquareVertices->SetVertexCount(4);
|
||||
|
||||
CVector3f SquareVertices[] = {
|
||||
CVector3f(-1.f, 1.f, 0.f),
|
||||
|
@ -472,13 +474,13 @@ void CDrawUtil::InitSquare()
|
|||
CVector2f(0.f, 0.f)
|
||||
};
|
||||
|
||||
mSquareVertices.BufferAttrib(EVertexAttribute::Position, SquareVertices);
|
||||
mSquareVertices.BufferAttrib(EVertexAttribute::Normal, SquareNormals);
|
||||
mSquareVertices->BufferAttrib(EVertexAttribute::Position, SquareVertices);
|
||||
mSquareVertices->BufferAttrib(EVertexAttribute::Normal, SquareNormals);
|
||||
|
||||
for (uint32 iTex = 0; iTex < 8; iTex++)
|
||||
{
|
||||
EVertexAttribute Attrib = (EVertexAttribute) (EVertexAttribute::Tex0 << iTex);
|
||||
mSquareVertices.BufferAttrib(Attrib, SquareTexCoords);
|
||||
mSquareVertices->BufferAttrib(Attrib, SquareTexCoords);
|
||||
}
|
||||
|
||||
mSquareIndices.Reserve(4);
|
||||
|
@ -492,8 +494,9 @@ void CDrawUtil::InitSquare()
|
|||
void CDrawUtil::InitLine()
|
||||
{
|
||||
debugf("Creating line");
|
||||
mLineVertices.SetActiveAttribs(EVertexAttribute::Position);
|
||||
mLineVertices.SetVertexCount(2);
|
||||
mLineVertices.emplace();
|
||||
mLineVertices->SetActiveAttribs(EVertexAttribute::Position);
|
||||
mLineVertices->SetVertexCount(2);
|
||||
|
||||
mLineIndices.Reserve(2);
|
||||
mLineIndices.SetPrimitiveType(GL_LINES);
|
||||
|
@ -510,16 +513,17 @@ void CDrawUtil::InitCube()
|
|||
void CDrawUtil::InitWireCube()
|
||||
{
|
||||
debugf("Creating wire cube");
|
||||
mWireCubeVertices.SetVertexDesc(EVertexAttribute::Position);
|
||||
mWireCubeVertices.Reserve(8);
|
||||
mWireCubeVertices.AddVertex(CVector3f(-0.5f, -0.5f, -0.5f));
|
||||
mWireCubeVertices.AddVertex(CVector3f(-0.5f, 0.5f, -0.5f));
|
||||
mWireCubeVertices.AddVertex(CVector3f( 0.5f, 0.5f, -0.5f));
|
||||
mWireCubeVertices.AddVertex(CVector3f( 0.5f, -0.5f, -0.5f));
|
||||
mWireCubeVertices.AddVertex(CVector3f(-0.5f, -0.5f, 0.5f));
|
||||
mWireCubeVertices.AddVertex(CVector3f( 0.5f, -0.5f, 0.5f));
|
||||
mWireCubeVertices.AddVertex(CVector3f( 0.5f, 0.5f, 0.5f));
|
||||
mWireCubeVertices.AddVertex(CVector3f(-0.5f, 0.5f, 0.5f));
|
||||
mWireCubeVertices.emplace();
|
||||
mWireCubeVertices->SetVertexDesc(EVertexAttribute::Position);
|
||||
mWireCubeVertices->Reserve(8);
|
||||
mWireCubeVertices->AddVertex(CVector3f(-0.5f, -0.5f, -0.5f));
|
||||
mWireCubeVertices->AddVertex(CVector3f(-0.5f, 0.5f, -0.5f));
|
||||
mWireCubeVertices->AddVertex(CVector3f( 0.5f, 0.5f, -0.5f));
|
||||
mWireCubeVertices->AddVertex(CVector3f( 0.5f, -0.5f, -0.5f));
|
||||
mWireCubeVertices->AddVertex(CVector3f(-0.5f, -0.5f, 0.5f));
|
||||
mWireCubeVertices->AddVertex(CVector3f( 0.5f, -0.5f, 0.5f));
|
||||
mWireCubeVertices->AddVertex(CVector3f( 0.5f, 0.5f, 0.5f));
|
||||
mWireCubeVertices->AddVertex(CVector3f(-0.5f, 0.5f, 0.5f));
|
||||
|
||||
uint16 Indices[] = {
|
||||
0, 1,
|
||||
|
@ -585,6 +589,10 @@ void CDrawUtil::Shutdown()
|
|||
if (mDrawUtilInitialized)
|
||||
{
|
||||
debugf("Shutting down");
|
||||
mGridVertices = std::nullopt;
|
||||
mSquareVertices = std::nullopt;
|
||||
mLineVertices = std::nullopt;
|
||||
mWireCubeVertices = std::nullopt;
|
||||
delete mpColorShader;
|
||||
delete mpColorShaderLighting;
|
||||
delete mpTextureShader;
|
||||
|
|
|
@ -4,9 +4,11 @@
|
|||
#include "Core/OpenGL/CVertexBuffer.h"
|
||||
#include "Core/OpenGL/CDynamicVertexBuffer.h"
|
||||
#include "Core/OpenGL/CIndexBuffer.h"
|
||||
#include "Core/Resource/model/CModel.h"
|
||||
#include "Core/Resource/Model/CModel.h"
|
||||
#include "Core/Resource/CLight.h"
|
||||
|
||||
#include <optional>
|
||||
|
||||
/**
|
||||
* @todo there are a LOT of problems with how this is implemented; trying to
|
||||
* use CDrawUtil in a lot of places in the codebase just plain doesn't work
|
||||
|
@ -17,22 +19,22 @@
|
|||
class CDrawUtil
|
||||
{
|
||||
// 7x7 Grid
|
||||
static CVertexBuffer mGridVertices;
|
||||
static std::optional<CVertexBuffer> mGridVertices;
|
||||
static CIndexBuffer mGridIndices;
|
||||
|
||||
// Square
|
||||
static CDynamicVertexBuffer mSquareVertices;
|
||||
static std::optional<CDynamicVertexBuffer> mSquareVertices;
|
||||
static CIndexBuffer mSquareIndices;
|
||||
|
||||
// Line
|
||||
static CDynamicVertexBuffer mLineVertices;
|
||||
static std::optional<CDynamicVertexBuffer> mLineVertices;
|
||||
static CIndexBuffer mLineIndices;
|
||||
|
||||
// Cube
|
||||
static TResPtr<CModel> mpCubeModel;
|
||||
|
||||
// Wire Cube
|
||||
static CVertexBuffer mWireCubeVertices;
|
||||
static std::optional<CVertexBuffer> mWireCubeVertices;
|
||||
static CIndexBuffer mWireCubeIndices;
|
||||
|
||||
// Sphere
|
||||
|
|
|
@ -26,9 +26,9 @@ const CColor CGraphics::skDefaultAmbientColor = CColor(0.5f, 0.5f, 0.5f, 1.f);
|
|||
CColor CGraphics::sAreaAmbientColor = CColor::skBlack;
|
||||
float CGraphics::sWorldLightMultiplier;
|
||||
CLight CGraphics::sDefaultDirectionalLights[3] = {
|
||||
*CLight::BuildDirectional(CVector3f(0), CVector3f (0.f, -0.866025f, -0.5f), CColor(0.3f, 0.3f, 0.3f, 1.f)),
|
||||
*CLight::BuildDirectional(CVector3f(0), CVector3f(-0.75f, 0.433013f, -0.5f), CColor(0.3f, 0.3f, 0.3f, 1.f)),
|
||||
*CLight::BuildDirectional(CVector3f(0), CVector3f( 0.75f, 0.433013f, -0.5f), CColor(0.3f, 0.3f, 0.3f, 1.f))
|
||||
CLight::BuildDirectional(CVector3f(0), CVector3f (0.f, -0.866025f, -0.5f), CColor(0.3f, 0.3f, 0.3f, 1.f)),
|
||||
CLight::BuildDirectional(CVector3f(0), CVector3f(-0.75f, 0.433013f, -0.5f), CColor(0.3f, 0.3f, 0.3f, 1.f)),
|
||||
CLight::BuildDirectional(CVector3f(0), CVector3f( 0.75f, 0.433013f, -0.5f), CColor(0.3f, 0.3f, 0.3f, 1.f))
|
||||
};
|
||||
|
||||
// ************ FUNCTIONS ************
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
#include <Common/Math/CTransform4f.h>
|
||||
#include <Common/Math/MathUtil.h>
|
||||
|
||||
#include <cfloat>
|
||||
|
||||
CAnimation::CAnimation(CResourceEntry *pEntry /*= 0*/)
|
||||
: CResource(pEntry)
|
||||
, mDuration(0.f)
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
#include <Common/Macros.h>
|
||||
#include <Common/Math/MathUtil.h>
|
||||
|
||||
#include <cfloat>
|
||||
|
||||
// ************ CBone ************
|
||||
CBone::CBone(CSkeleton *pSkel)
|
||||
: mpSkeleton(pSkel)
|
||||
|
|
|
@ -21,10 +21,6 @@ CGameArea::~CGameArea()
|
|||
|
||||
for (uint32 iSCLY = 0; iSCLY < mScriptLayers.size(); iSCLY++)
|
||||
delete mScriptLayers[iSCLY];
|
||||
|
||||
for (uint32 iLyr = 0; iLyr < mLightLayers.size(); iLyr++)
|
||||
for (uint32 iLight = 0; iLight < mLightLayers[iLyr].size(); iLight++)
|
||||
delete mLightLayers[iLyr][iLight];
|
||||
}
|
||||
|
||||
CDependencyTree* CGameArea::BuildDependencyTree() const
|
||||
|
|
|
@ -53,7 +53,7 @@ class CGameArea : public CResource
|
|||
// Collision
|
||||
std::unique_ptr<CCollisionMeshGroup> mpCollision;
|
||||
// Lights
|
||||
std::vector<std::vector<CLight*>> mLightLayers;
|
||||
std::vector<std::vector<CLight>> mLightLayers;
|
||||
// Path Mesh
|
||||
CAssetID mPathID;
|
||||
// Portal Area
|
||||
|
@ -98,7 +98,7 @@ public:
|
|||
inline CScriptLayer* ScriptLayer(uint32 Index) const { return mScriptLayers[Index]; }
|
||||
inline uint32 NumLightLayers() const { return mLightLayers.size(); }
|
||||
inline uint32 NumLights(uint32 LayerIndex) const { return (LayerIndex < mLightLayers.size() ? mLightLayers[LayerIndex].size() : 0); }
|
||||
inline CLight* Light(uint32 LayerIndex, uint32 LightIndex) const { return mLightLayers[LayerIndex][LightIndex]; }
|
||||
inline CLight* Light(uint32 LayerIndex, uint32 LightIndex) { return &mLightLayers[LayerIndex][LightIndex]; }
|
||||
inline CAssetID PathID() const { return mPathID; }
|
||||
inline CPoiToWorld* PoiToWorldMap() const { return mpPoiToWorldMap; }
|
||||
inline CAssetID PortalAreaID() const { return mPortalAreaID; }
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include "Core/Render/CDrawUtil.h"
|
||||
#include "Core/Render/CRenderer.h"
|
||||
|
||||
CDynamicVertexBuffer CFont::smGlyphVertices;
|
||||
std::optional<CDynamicVertexBuffer> CFont::smGlyphVertices;
|
||||
CIndexBuffer CFont::smGlyphIndices;
|
||||
bool CFont::smBuffersInitialized = false;
|
||||
|
||||
|
@ -43,7 +43,7 @@ CVector2f CFont::RenderString(const TString& rkString, CRenderer* /*pRenderer*/,
|
|||
GLuint ColorLoc = pTextShader->GetUniformLocation("FontColor");
|
||||
GLuint LayerLoc = pTextShader->GetUniformLocation("RGBALayer");
|
||||
mpFontTexture->Bind(0);
|
||||
smGlyphVertices.Bind();
|
||||
smGlyphVertices->Bind();
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
||||
// Initialize some more stuff before we start the character loop
|
||||
|
@ -116,7 +116,7 @@ CVector2f CFont::RenderString(const TString& rkString, CRenderer* /*pRenderer*/,
|
|||
|
||||
// Load shader uniforms, buffer texture
|
||||
glUniformMatrix4fv(ModelMtxLoc, 1, GL_FALSE, (GLfloat*) &GlyphTransform);
|
||||
smGlyphVertices.BufferAttrib(EVertexAttribute::Tex0, &pGlyph->TexCoords);
|
||||
smGlyphVertices->BufferAttrib(EVertexAttribute::Tex0, &pGlyph->TexCoords);
|
||||
|
||||
// Draw fill
|
||||
glUniform1i(LayerLoc, GlyphLayer);
|
||||
|
@ -148,8 +148,9 @@ CVector2f CFont::RenderString(const TString& rkString, CRenderer* /*pRenderer*/,
|
|||
|
||||
void CFont::InitBuffers()
|
||||
{
|
||||
smGlyphVertices.SetActiveAttribs(EVertexAttribute::Position | EVertexAttribute::Tex0);
|
||||
smGlyphVertices.SetVertexCount(4);
|
||||
smGlyphVertices.emplace();
|
||||
smGlyphVertices->SetActiveAttribs(EVertexAttribute::Position | EVertexAttribute::Tex0);
|
||||
smGlyphVertices->SetVertexCount(4);
|
||||
|
||||
CVector3f Vertices[4] = {
|
||||
CVector3f( 0.f, 0.f, 0.f),
|
||||
|
@ -157,7 +158,7 @@ void CFont::InitBuffers()
|
|||
CVector3f( 0.f, -2.f, 0.f),
|
||||
CVector3f( 2.f, -2.f, 0.f)
|
||||
};
|
||||
smGlyphVertices.BufferAttrib(EVertexAttribute::Position, Vertices);
|
||||
smGlyphVertices->BufferAttrib(EVertexAttribute::Position, Vertices);
|
||||
|
||||
CVector2f TexCoords[4] = {
|
||||
CVector2f(0.f, 0.f),
|
||||
|
@ -165,7 +166,7 @@ void CFont::InitBuffers()
|
|||
CVector2f(0.f, 1.f),
|
||||
CVector2f(1.f, 1.f)
|
||||
};
|
||||
smGlyphVertices.BufferAttrib(EVertexAttribute::Tex0, TexCoords);
|
||||
smGlyphVertices->BufferAttrib(EVertexAttribute::Tex0, TexCoords);
|
||||
|
||||
smGlyphIndices.Reserve(4);
|
||||
smGlyphIndices.AddIndex(0);
|
||||
|
@ -176,3 +177,12 @@ void CFont::InitBuffers()
|
|||
|
||||
smBuffersInitialized = true;
|
||||
}
|
||||
|
||||
void CFont::ShutdownBuffers()
|
||||
{
|
||||
if (smBuffersInitialized)
|
||||
{
|
||||
smGlyphVertices = std::nullopt;
|
||||
smBuffersInitialized = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "Core/OpenGL/CIndexBuffer.h"
|
||||
#include <Common/BasicTypes.h>
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
|
@ -20,9 +21,9 @@ class CFont : public CResource
|
|||
{
|
||||
DECLARE_RESOURCE_TYPE(Font)
|
||||
friend class CFontLoader;
|
||||
static CDynamicVertexBuffer smGlyphVertices; // This is the vertex buffer used to draw glyphs. It has two attributes - Pos and Tex0. Tex0 should be updated for each glyph.
|
||||
static CIndexBuffer smGlyphIndices; // This is the index buffer used to draw glyphs. It uses a triangle strip.
|
||||
static bool smBuffersInitialized; // This bool indicates whether the vertex/index buffer have been initialized. Checked at the start of RenderString().
|
||||
static std::optional<CDynamicVertexBuffer> smGlyphVertices; // This is the vertex buffer used to draw glyphs. It has two attributes - Pos and Tex0. Tex0 should be updated for each glyph.
|
||||
static CIndexBuffer smGlyphIndices; // This is the index buffer used to draw glyphs. It uses a triangle strip.
|
||||
static bool smBuffersInitialized; // This bool indicates whether the vertex/index buffer have been initialized. Checked at the start of RenderString().
|
||||
|
||||
uint32 mUnknown; // Value at offset 0x8. Not sure what this is. Including for experimentation purposes.
|
||||
uint32 mLineHeight; // Height of each line, in points
|
||||
|
@ -70,7 +71,8 @@ public:
|
|||
inline TString FontName() const { return mFontName; }
|
||||
inline CTexture* Texture() const { return mpFontTexture; }
|
||||
private:
|
||||
void InitBuffers();
|
||||
static void InitBuffers();
|
||||
static void ShutdownBuffers();
|
||||
};
|
||||
|
||||
#endif // CFONT_H
|
||||
|
|
|
@ -216,56 +216,56 @@ void CLight::Load() const
|
|||
}
|
||||
|
||||
// ************ STATIC ************
|
||||
CLight* CLight::BuildLocalAmbient(const CVector3f& rkPosition, const CColor& rkColor)
|
||||
CLight CLight::BuildLocalAmbient(const CVector3f& rkPosition, const CColor& rkColor)
|
||||
{
|
||||
CLight *pLight = new CLight;
|
||||
pLight->mType = ELightType::LocalAmbient;
|
||||
pLight->mPosition = rkPosition;
|
||||
pLight->mDirection = skDefaultLightDir;
|
||||
pLight->mColor = rkColor;
|
||||
pLight->mSpotCutoff = 0.f;
|
||||
CLight pLight;
|
||||
pLight.mType = ELightType::LocalAmbient;
|
||||
pLight.mPosition = rkPosition;
|
||||
pLight.mDirection = skDefaultLightDir;
|
||||
pLight.mColor = rkColor;
|
||||
pLight.mSpotCutoff = 0.f;
|
||||
return pLight;
|
||||
}
|
||||
|
||||
CLight* CLight::BuildDirectional(const CVector3f& rkPosition, const CVector3f& rkDirection, const CColor& rkColor)
|
||||
CLight CLight::BuildDirectional(const CVector3f& rkPosition, const CVector3f& rkDirection, const CColor& rkColor)
|
||||
{
|
||||
CLight *pLight = new CLight;
|
||||
pLight->mType = ELightType::Directional;
|
||||
pLight->mPosition = rkPosition;
|
||||
pLight->mDirection = rkDirection;
|
||||
pLight->mColor = rkColor;
|
||||
pLight->mSpotCutoff = 0.f;
|
||||
CLight pLight;
|
||||
pLight.mType = ELightType::Directional;
|
||||
pLight.mPosition = rkPosition;
|
||||
pLight.mDirection = rkDirection;
|
||||
pLight.mColor = rkColor;
|
||||
pLight.mSpotCutoff = 0.f;
|
||||
return pLight;
|
||||
}
|
||||
|
||||
CLight* CLight::BuildSpot(const CVector3f& rkPosition, const CVector3f& rkDirection, const CColor& rkColor, float Cutoff)
|
||||
CLight CLight::BuildSpot(const CVector3f& rkPosition, const CVector3f& rkDirection, const CColor& rkColor, float Cutoff)
|
||||
{
|
||||
CLight *pLight = new CLight;
|
||||
pLight->mType = ELightType::Spot;
|
||||
pLight->mPosition = rkPosition;
|
||||
pLight->mDirection = -rkDirection.Normalized();
|
||||
pLight->mColor = rkColor;
|
||||
pLight->mSpotCutoff = Cutoff * 0.5f;
|
||||
pLight->mAngleAttenCoefficients = pLight->CalculateSpotAngleAtten();
|
||||
CLight pLight;
|
||||
pLight.mType = ELightType::Spot;
|
||||
pLight.mPosition = rkPosition;
|
||||
pLight.mDirection = -rkDirection.Normalized();
|
||||
pLight.mColor = rkColor;
|
||||
pLight.mSpotCutoff = Cutoff * 0.5f;
|
||||
pLight.mAngleAttenCoefficients = pLight.CalculateSpotAngleAtten();
|
||||
return pLight;
|
||||
}
|
||||
|
||||
CLight* CLight::BuildCustom(const CVector3f& rkPosition, const CVector3f& rkDirection, const CColor& rkColor,
|
||||
float DistAttenA, float DistAttenB, float DistAttenC,
|
||||
float AngleAttenA, float AngleAttenB, float AngleAttenC)
|
||||
CLight CLight::BuildCustom(const CVector3f& rkPosition, const CVector3f& rkDirection, const CColor& rkColor,
|
||||
float DistAttenA, float DistAttenB, float DistAttenC,
|
||||
float AngleAttenA, float AngleAttenB, float AngleAttenC)
|
||||
{
|
||||
CLight *pLight = new CLight;
|
||||
pLight->mType = ELightType::Custom;
|
||||
pLight->mPosition = rkPosition;
|
||||
pLight->mDirection = rkDirection;
|
||||
pLight->mColor = rkColor;
|
||||
pLight->mSpotCutoff = 0.f;
|
||||
pLight->mDistAttenCoefficients.X = DistAttenA;
|
||||
pLight->mDistAttenCoefficients.Y = DistAttenB;
|
||||
pLight->mDistAttenCoefficients.Z = DistAttenC;
|
||||
pLight->mAngleAttenCoefficients.X = AngleAttenA;
|
||||
pLight->mAngleAttenCoefficients.Y = AngleAttenB;
|
||||
pLight->mAngleAttenCoefficients.Z = AngleAttenC * AngleAttenC;
|
||||
CLight pLight;
|
||||
pLight.mType = ELightType::Custom;
|
||||
pLight.mPosition = rkPosition;
|
||||
pLight.mDirection = rkDirection;
|
||||
pLight.mColor = rkColor;
|
||||
pLight.mSpotCutoff = 0.f;
|
||||
pLight.mDistAttenCoefficients.X = DistAttenA;
|
||||
pLight.mDistAttenCoefficients.Y = DistAttenB;
|
||||
pLight.mDistAttenCoefficients.Z = DistAttenC;
|
||||
pLight.mAngleAttenCoefficients.X = AngleAttenA;
|
||||
pLight.mAngleAttenCoefficients.Y = AngleAttenB;
|
||||
pLight.mAngleAttenCoefficients.Z = AngleAttenC * AngleAttenC;
|
||||
return pLight;
|
||||
}
|
||||
|
||||
|
|
|
@ -69,10 +69,10 @@ public:
|
|||
void Load() const;
|
||||
|
||||
// Static
|
||||
static CLight* BuildLocalAmbient(const CVector3f& rkPosition, const CColor& rkColor);
|
||||
static CLight* BuildDirectional(const CVector3f& rkPosition, const CVector3f& rkDirection, const CColor& rkColor);
|
||||
static CLight* BuildSpot(const CVector3f& rkPosition, const CVector3f& rkDirection, const CColor& rkColor, float Cutoff);
|
||||
static CLight* BuildCustom(const CVector3f& rkPosition, const CVector3f& rkDirection, const CColor& rkColor,
|
||||
static CLight BuildLocalAmbient(const CVector3f& rkPosition, const CColor& rkColor);
|
||||
static CLight BuildDirectional(const CVector3f& rkPosition, const CVector3f& rkDirection, const CColor& rkColor);
|
||||
static CLight BuildSpot(const CVector3f& rkPosition, const CVector3f& rkDirection, const CColor& rkColor, float Cutoff);
|
||||
static CLight BuildCustom(const CVector3f& rkPosition, const CVector3f& rkDirection, const CColor& rkColor,
|
||||
float DistAttenA, float DistAttenB, float DistAttenC,
|
||||
float AngleAttenA, float AngleAttenB, float AngleAttenC);
|
||||
|
||||
|
|
|
@ -40,11 +40,13 @@ class CMaterial
|
|||
friend class CMaterialLoader;
|
||||
friend class CMaterialCooker;
|
||||
|
||||
public:
|
||||
enum class EShaderStatus
|
||||
{
|
||||
NoShader, ShaderExists, ShaderFailed
|
||||
};
|
||||
|
||||
private:
|
||||
// Statics
|
||||
static uint64 sCurrentMaterial; // The hash for the currently bound material
|
||||
static CColor sCurrentTint; // The tint for the currently bound material
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include <Common/Macros.h>
|
||||
#include <algorithm>
|
||||
|
||||
std::unordered_map<EResourceType, CResTypeInfo*> CResTypeInfo::smTypeMap;
|
||||
std::unordered_map<EResourceType, std::unique_ptr<CResTypeInfo>> CResTypeInfo::smTypeMap;
|
||||
|
||||
CResTypeInfo::CResTypeInfo(EResourceType Type, const TString& rkTypeName, const TString& rkRetroExtension)
|
||||
: mType(Type)
|
||||
|
@ -15,7 +15,7 @@ CResTypeInfo::CResTypeInfo(EResourceType Type, const TString& rkTypeName, const
|
|||
#if !PUBLIC_RELEASE
|
||||
ASSERT(smTypeMap.find(Type) == smTypeMap.end());
|
||||
#endif
|
||||
smTypeMap[Type] = this;
|
||||
smTypeMap[Type] = std::unique_ptr<CResTypeInfo>(this);
|
||||
}
|
||||
|
||||
bool CResTypeInfo::IsInGame(EGame Game) const
|
||||
|
@ -48,7 +48,7 @@ void CResTypeInfo::GetAllTypesInGame(EGame Game, std::list<CResTypeInfo*>& rOut)
|
|||
{
|
||||
for (auto Iter = smTypeMap.begin(); Iter != smTypeMap.end(); Iter++)
|
||||
{
|
||||
CResTypeInfo *pType = Iter->second;
|
||||
CResTypeInfo *pType = Iter->second.get();
|
||||
|
||||
if (pType->IsInGame(Game))
|
||||
rOut.push_back(pType);
|
||||
|
@ -78,7 +78,7 @@ CResTypeInfo* CResTypeInfo::TypeForCookedExtension(EGame Game, CFourCC Ext)
|
|||
// Not cached - do a slow lookup
|
||||
for (auto Iter = smTypeMap.begin(); Iter != smTypeMap.end(); Iter++)
|
||||
{
|
||||
CResTypeInfo *pType = Iter->second;
|
||||
CResTypeInfo *pType = Iter->second.get();
|
||||
|
||||
if (pType->CookedExtension(Game) == Ext)
|
||||
{
|
||||
|
@ -98,6 +98,12 @@ CResTypeInfo* CResTypeInfo::TypeForCookedExtension(EGame Game, CFourCC Ext)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
CResTypeInfo* CResTypeInfo::FindTypeInfo(EResourceType Type)
|
||||
{
|
||||
auto Iter = smTypeMap.find(Type);
|
||||
return (Iter == smTypeMap.end() ? nullptr : Iter->second.get());
|
||||
}
|
||||
|
||||
// ************ SERIALIZATION ************
|
||||
void Serialize(IArchive& rArc, CResTypeInfo*& rpType)
|
||||
{
|
||||
|
|
|
@ -25,11 +25,12 @@ class CResTypeInfo
|
|||
bool mCanHaveDependencies;
|
||||
bool mCanBeCreated;
|
||||
|
||||
static std::unordered_map<EResourceType, CResTypeInfo*> smTypeMap;
|
||||
static std::unordered_map<EResourceType, std::unique_ptr<CResTypeInfo>> smTypeMap;
|
||||
|
||||
// Private Methods
|
||||
CResTypeInfo(EResourceType Type, const TString& rkTypeName, const TString& rkRetroExtension);
|
||||
~CResTypeInfo() {}
|
||||
~CResTypeInfo() = default;
|
||||
friend class std::default_delete<CResTypeInfo>;
|
||||
|
||||
// Public Methods
|
||||
public:
|
||||
|
@ -47,11 +48,7 @@ public:
|
|||
static void GetAllTypesInGame(EGame Game, std::list<CResTypeInfo*>& rOut);
|
||||
static CResTypeInfo* TypeForCookedExtension(EGame, CFourCC Ext);
|
||||
|
||||
inline static CResTypeInfo* FindTypeInfo(EResourceType Type)
|
||||
{
|
||||
auto Iter = smTypeMap.find(Type);
|
||||
return (Iter == smTypeMap.end() ? nullptr : Iter->second);
|
||||
}
|
||||
static CResTypeInfo* FindTypeInfo(EResourceType Type);
|
||||
|
||||
private:
|
||||
// Creation
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "CTexture.h"
|
||||
#include <cmath>
|
||||
|
||||
CTexture::CTexture(CResourceEntry *pEntry /*= 0*/)
|
||||
: CResource(pEntry)
|
||||
|
@ -143,7 +144,7 @@ float CTexture::ReadTexelAlpha(const CVector2f& rkTexCoord)
|
|||
// todo: support texel formats other than DXT1
|
||||
// DXT1 is definitely the most complicated one anyway; try reusing CTextureDecoder functions for other formats
|
||||
uint32 TexelX = (uint32) ((mWidth - 1) * rkTexCoord.X);
|
||||
uint32 TexelY = (uint32) ((mHeight - 1) * (1.f - fmodf(rkTexCoord.Y, 1.f)));
|
||||
uint32 TexelY = (uint32) ((mHeight - 1) * (1.f - std::fmod(rkTexCoord.Y, 1.f)));
|
||||
|
||||
if (mTexelFormat == ETexelFormat::DXT1 && mBufferExists)
|
||||
{
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "CCollisionRenderData.h"
|
||||
#include <Core/Render/CDrawUtil.h>
|
||||
#include <algorithm>
|
||||
|
||||
/** Build from collision data */
|
||||
void CCollisionRenderData::BuildRenderData(const SCollisionIndexData& kIndexData)
|
||||
|
|
|
@ -99,6 +99,7 @@ enum class EUVAnimMode
|
|||
ConvolutedModeA = 0x7,
|
||||
ConvolutedModeB = 0x8,
|
||||
SimpleMode = 0xA,
|
||||
Eleven = 0xB,
|
||||
NoUVAnim = -1
|
||||
};
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include <Common/CFourCC.h>
|
||||
|
||||
#include <cfloat>
|
||||
#include <iostream>
|
||||
|
||||
CAreaLoader::CAreaLoader()
|
||||
|
@ -151,7 +152,7 @@ void CAreaLoader::ReadSCLYPrime()
|
|||
CFourCC SCGN = mpMREA->ReadFourCC();
|
||||
|
||||
if (SCGN != FOURCC('SCGN'))
|
||||
errorf("%s [0x%X]: Invalid SCGN magic: %s", *mpMREA->GetSourceString(), mpMREA->Tell() - 4, SCGN.ToString());
|
||||
errorf("%s [0x%X]: Invalid SCGN magic: %s", *mpMREA->GetSourceString(), mpMREA->Tell() - 4, *SCGN.ToString());
|
||||
|
||||
else
|
||||
{
|
||||
|
@ -191,7 +192,7 @@ void CAreaLoader::ReadLightsPrime()
|
|||
mpMREA->Seek(0x4, SEEK_CUR);
|
||||
|
||||
// Relevant data is read - now we process and form a CLight out of it
|
||||
CLight *pLight;
|
||||
CLight pLight;
|
||||
|
||||
CColor LightColor = CColor(Color.X, Color.Y, Color.Z, 0.f);
|
||||
if (Multiplier < FLT_EPSILON)
|
||||
|
@ -225,7 +226,7 @@ void CAreaLoader::ReadLightsPrime()
|
|||
float DistAttenA = (FalloffType == 0) ? (2.f / Multiplier) : 0.f;
|
||||
float DistAttenB = (FalloffType == 1) ? (250.f / Multiplier) : 0.f;
|
||||
float DistAttenC = (FalloffType == 2) ? (25000.f / Multiplier) : 0.f;
|
||||
pLight->SetDistAtten(DistAttenA, DistAttenB, DistAttenC);
|
||||
pLight.SetDistAtten(DistAttenA, DistAttenB, DistAttenC);
|
||||
}
|
||||
|
||||
// Custom
|
||||
|
@ -240,7 +241,7 @@ void CAreaLoader::ReadLightsPrime()
|
|||
1.f, 0.f, 0.f);
|
||||
}
|
||||
|
||||
pLight->SetLayer(iLyr);
|
||||
pLight.SetLayer(iLyr);
|
||||
mpArea->mLightLayers[iLyr][iLight] = pLight;
|
||||
}
|
||||
}
|
||||
|
@ -493,7 +494,7 @@ void CAreaLoader::ReadLightsCorruption()
|
|||
mpMREA->Seek(0x18, SEEK_CUR);
|
||||
|
||||
// Relevant data is read - now we process and form a CLight out of it
|
||||
CLight *pLight;
|
||||
CLight pLight;
|
||||
|
||||
if (Multiplier < FLT_EPSILON)
|
||||
Multiplier = FLT_EPSILON;
|
||||
|
@ -518,7 +519,7 @@ void CAreaLoader::ReadLightsCorruption()
|
|||
float DistAttenA = (FalloffType == 0) ? (2.f / Multiplier) : 0.f;
|
||||
float DistAttenB = (FalloffType == 1) ? (250.f / Multiplier) : 0.f;
|
||||
float DistAttenC = (FalloffType == 2) ? (25000.f / Multiplier) : 0.f;
|
||||
pLight->SetDistAtten(DistAttenA, DistAttenB, DistAttenC);
|
||||
pLight.SetDistAtten(DistAttenA, DistAttenB, DistAttenC);
|
||||
}
|
||||
|
||||
// Custom
|
||||
|
@ -533,7 +534,7 @@ void CAreaLoader::ReadLightsCorruption()
|
|||
1.f, 0.f, 0.f);
|
||||
}
|
||||
|
||||
pLight->SetLayer(iLayer);
|
||||
pLight.SetLayer(iLayer);
|
||||
mpArea->mLightLayers[iLayer][iLight] = pLight;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -379,28 +379,28 @@ CMaterial* CMaterialLoader::ReadCorruptionMaterial()
|
|||
|
||||
switch (pPass->mAnimMode)
|
||||
{
|
||||
case 3: // Rotation
|
||||
case 7: // ???
|
||||
case EUVAnimMode::UVRotation: // Rotation
|
||||
case EUVAnimMode::ConvolutedModeA: // ???
|
||||
pPass->mAnimParams[0] = mpFile->ReadFloat();
|
||||
pPass->mAnimParams[1] = mpFile->ReadFloat();
|
||||
break;
|
||||
case 2: // UV Scroll
|
||||
case 4: // U Scroll
|
||||
case 5: // V Scroll
|
||||
case EUVAnimMode::UVScroll: // UV Scroll
|
||||
case EUVAnimMode::HFilmstrip: // U Scroll
|
||||
case EUVAnimMode::VFilmstrip: // V Scroll
|
||||
pPass->mAnimParams[0] = mpFile->ReadFloat();
|
||||
pPass->mAnimParams[1] = mpFile->ReadFloat();
|
||||
pPass->mAnimParams[2] = mpFile->ReadFloat();
|
||||
pPass->mAnimParams[3] = mpFile->ReadFloat();
|
||||
break;
|
||||
case 0: // Inverse ModelView Matrix
|
||||
case 1: // Inverse ModelView Matrix Translated
|
||||
case 6: // Model Matrix
|
||||
case 10: // Yet-to-be-named
|
||||
case EUVAnimMode::InverseMV: // Inverse ModelView Matrix
|
||||
case EUVAnimMode::InverseMVTranslated: // Inverse ModelView Matrix Translated
|
||||
case EUVAnimMode::ModelMatrix: // Model Matrix
|
||||
case EUVAnimMode::SimpleMode: // Yet-to-be-named
|
||||
break;
|
||||
|
||||
// Unknown/unsupported animation type
|
||||
case 8:
|
||||
case 11:
|
||||
case EUVAnimMode::ConvolutedModeB:
|
||||
case EUVAnimMode::Eleven:
|
||||
break;
|
||||
default:
|
||||
errorf("%s [0x%X]: Unsupported animation mode encountered: %d", *mpFile->GetSourceString(), mpFile->Tell() - 8, pPass->mAnimMode);
|
||||
|
|
|
@ -111,19 +111,6 @@ EGame CScriptTemplate::Game() const
|
|||
return mpGame->Game();
|
||||
}
|
||||
|
||||
// ************ PROPERTY FETCHING ************
|
||||
template<class PropType>
|
||||
PropType* TFetchProperty(CStructProperty* pProperties, const TIDString& rkID)
|
||||
{
|
||||
if (rkID.IsEmpty()) return nullptr;
|
||||
IProperty *pProp = pProperties->ChildByIDString(rkID);
|
||||
|
||||
if (pProp && (pProp->Type() == PropEnum))
|
||||
return static_cast<PropType*>(pProp)->ValuePtr();
|
||||
else
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
EVolumeShape CScriptTemplate::VolumeShape(CScriptObject *pObj)
|
||||
{
|
||||
if (pObj->Template() != this)
|
||||
|
|
|
@ -52,7 +52,6 @@ public:
|
|||
ScaleEnabled, ScaleDisabled, ScaleVolume
|
||||
};
|
||||
|
||||
private:
|
||||
struct SEditorAsset
|
||||
{
|
||||
enum class EAssetType {
|
||||
|
@ -75,6 +74,7 @@ private:
|
|||
}
|
||||
};
|
||||
|
||||
private:
|
||||
std::vector<TString> mModules;
|
||||
std::unique_ptr<CStructProperty> mpProperties;
|
||||
std::vector<SEditorAsset> mAssets;
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace NGameList
|
|||
{
|
||||
|
||||
/** Path for the templates directory */
|
||||
const TString gkTemplatesDir = "../templates/";
|
||||
const TString gkTemplatesDir = "templates/";
|
||||
|
||||
/** Path to the game list file */
|
||||
const TString gkGameListPath = gkTemplatesDir + "GameList.xml";
|
||||
|
@ -33,7 +33,7 @@ struct SGameInfo
|
|||
}
|
||||
}
|
||||
};
|
||||
SGameInfo gGameList[EGame::Max];
|
||||
SGameInfo gGameList[int(EGame::Max)];
|
||||
|
||||
/** Whether the game list has been loaded */
|
||||
bool gLoadedGameList = false;
|
||||
|
@ -88,7 +88,7 @@ void LoadGameList()
|
|||
ASSERT(!gLoadedGameList);
|
||||
debugf("Loading game list");
|
||||
|
||||
CXMLReader Reader(gkGameListPath);
|
||||
CXMLReader Reader(gDataDir + gkGameListPath);
|
||||
ASSERT(Reader.IsValid());
|
||||
|
||||
SerializeGameList(Reader);
|
||||
|
@ -101,7 +101,7 @@ void SaveGameList()
|
|||
ASSERT(gLoadedGameList);
|
||||
debugf("Saving game list");
|
||||
|
||||
CXMLWriter Writer(gkGameListPath, "GameList");
|
||||
CXMLWriter Writer(gDataDir + gkGameListPath, "GameList");
|
||||
ASSERT(Writer.IsValid());
|
||||
|
||||
SerializeGameList(Writer);
|
||||
|
@ -151,7 +151,7 @@ CGameTemplate* GetGameTemplate(EGame Game)
|
|||
// Load the game template, if it hasn't been loaded yet.
|
||||
if (!GameInfo.pTemplate && !GameInfo.Name.IsEmpty())
|
||||
{
|
||||
TString GamePath = gkTemplatesDir + GameInfo.TemplatePath;
|
||||
TString GamePath = gDataDir + gkTemplatesDir + GameInfo.TemplatePath;
|
||||
GameInfo.pTemplate = std::make_unique<CGameTemplate>();
|
||||
GameInfo.pTemplate->Load(GamePath);
|
||||
}
|
||||
|
|
|
@ -8,8 +8,8 @@ namespace NPropertyMap
|
|||
{
|
||||
|
||||
/** Path to the property map file */
|
||||
const char* gpkLegacyMapPath = "../templates/PropertyMapLegacy.xml";
|
||||
const char* gpkMapPath = "../templates/PropertyMap.xml";
|
||||
const char* gpkLegacyMapPath = "templates/PropertyMapLegacy.xml";
|
||||
const char* gpkMapPath = "templates/PropertyMap.xml";
|
||||
|
||||
/** Whether to do name lookups from the legacy map */
|
||||
const bool gkUseLegacyMapForNameLookups = false;
|
||||
|
@ -150,13 +150,13 @@ void LoadMap()
|
|||
|
||||
if ( gkUseLegacyMapForNameLookups )
|
||||
{
|
||||
CXMLReader Reader(gpkLegacyMapPath);
|
||||
CXMLReader Reader(gDataDir + gpkLegacyMapPath);
|
||||
ASSERT(Reader.IsValid());
|
||||
Reader << SerialParameter("PropertyMap", gLegacyNameMap, SH_HexDisplay);
|
||||
}
|
||||
else
|
||||
{
|
||||
CXMLReader Reader(gpkMapPath);
|
||||
CXMLReader Reader(gDataDir + gpkMapPath);
|
||||
ASSERT(Reader.IsValid());
|
||||
Reader << SerialParameter("PropertyMap", gNameMap, SH_HexDisplay);
|
||||
|
||||
|
@ -198,7 +198,7 @@ void SaveMap(bool Force /*= false*/)
|
|||
{
|
||||
if( gkUseLegacyMapForUpdates )
|
||||
{
|
||||
CXMLWriter Writer(gpkLegacyMapPath, "PropertyMap");
|
||||
CXMLWriter Writer(gDataDir + gpkLegacyMapPath, "PropertyMap");
|
||||
ASSERT(Writer.IsValid());
|
||||
Writer << SerialParameter("PropertyMap", gLegacyNameMap, SH_HexDisplay);
|
||||
}
|
||||
|
@ -219,7 +219,7 @@ void SaveMap(bool Force /*= false*/)
|
|||
}
|
||||
|
||||
// Perform the actual save
|
||||
CXMLWriter Writer(gpkMapPath, "PropertyMap");
|
||||
CXMLWriter Writer(gDataDir + gpkMapPath, "PropertyMap");
|
||||
ASSERT(Writer.IsValid());
|
||||
Writer << SerialParameter("PropertyMap", gNameMap, SH_HexDisplay);
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ class CAssetProperty : public TSerializeableTypedProperty<CAssetID, EPropertyTyp
|
|||
CResTypeFilter mTypeFilter;
|
||||
|
||||
protected:
|
||||
CAssetProperty::CAssetProperty(EGame Game)
|
||||
CAssetProperty(EGame Game)
|
||||
: TSerializeableTypedProperty(Game)
|
||||
{
|
||||
mDefaultValue = CAssetID::InvalidID( mGame );
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
template<EPropertyType TypeEnum>
|
||||
class TEnumPropertyBase : public TSerializeableTypedProperty<int32, TypeEnum>
|
||||
{
|
||||
using base = TSerializeableTypedProperty<int32, TypeEnum>;
|
||||
friend class IProperty;
|
||||
|
||||
struct SEnumValue
|
||||
|
@ -47,17 +48,17 @@ class TEnumPropertyBase : public TSerializeableTypedProperty<int32, TypeEnum>
|
|||
protected:
|
||||
/** Constructor */
|
||||
TEnumPropertyBase(EGame Game)
|
||||
: TSerializeableTypedProperty(Game)
|
||||
: base(Game)
|
||||
, mOverrideTypeName(false)
|
||||
{}
|
||||
|
||||
public:
|
||||
virtual const char* HashableTypeName() const
|
||||
{
|
||||
if (mpArchetype)
|
||||
return mpArchetype->HashableTypeName();
|
||||
if (base::mpArchetype)
|
||||
return base::mpArchetype->HashableTypeName();
|
||||
else if (mOverrideTypeName)
|
||||
return *mName;
|
||||
return *base::mName;
|
||||
else if (TypeEnum == EPropertyType::Enum)
|
||||
return "enum";
|
||||
else
|
||||
|
@ -67,15 +68,15 @@ public:
|
|||
virtual void Serialize(IArchive& rArc)
|
||||
{
|
||||
// Skip TSerializeableTypedProperty, serialize default value ourselves so we can set SH_HexDisplay
|
||||
TTypedProperty::Serialize(rArc);
|
||||
TTypedProperty<int32, TypeEnum>::Serialize(rArc);
|
||||
|
||||
// Serialize default value
|
||||
TEnumPropertyBase* pArchetype = static_cast<TEnumPropertyBase*>(mpArchetype);
|
||||
TEnumPropertyBase* pArchetype = static_cast<TEnumPropertyBase*>(base::mpArchetype);
|
||||
uint32 DefaultValueFlags = SH_Optional | (TypeEnum == EPropertyType::Enum ? SH_HexDisplay : 0);
|
||||
rArc << SerialParameter("DefaultValue", mDefaultValue, DefaultValueFlags, pArchetype ? pArchetype->mDefaultValue : 0);
|
||||
rArc << SerialParameter("DefaultValue", base::mDefaultValue, DefaultValueFlags, pArchetype ? pArchetype->mDefaultValue : 0);
|
||||
|
||||
// Only serialize type name override for root archetypes.
|
||||
if (!mpArchetype)
|
||||
if (!base::mpArchetype)
|
||||
{
|
||||
rArc << SerialParameter("OverrideTypeName", mOverrideTypeName, SH_Optional, false);
|
||||
}
|
||||
|
@ -88,19 +89,19 @@ public:
|
|||
|
||||
virtual void SerializeValue(void* pData, IArchive& Arc) const
|
||||
{
|
||||
Arc.SerializePrimitive( (uint32&) ValueRef(pData), 0 );
|
||||
Arc.SerializePrimitive( (uint32&) base::ValueRef(pData), 0 );
|
||||
}
|
||||
|
||||
virtual void InitFromArchetype(IProperty* pOther)
|
||||
{
|
||||
TTypedProperty::InitFromArchetype(pOther);
|
||||
base::InitFromArchetype(pOther);
|
||||
TEnumPropertyBase* pOtherEnum = static_cast<TEnumPropertyBase*>(pOther);
|
||||
mValues = pOtherEnum->mValues;
|
||||
}
|
||||
|
||||
virtual TString ValueAsString(void* pData) const
|
||||
{
|
||||
return TString::FromInt32( Value(pData), 0, 10 );
|
||||
return TString::FromInt32( base::Value(pData), 0, 10 );
|
||||
}
|
||||
|
||||
void AddValue(TString ValueName, uint32 ValueID)
|
||||
|
@ -137,21 +138,21 @@ public:
|
|||
bool HasValidValue(void* pPropertyData)
|
||||
{
|
||||
if (mValues.empty()) return true;
|
||||
int ID = ValueRef(pPropertyData);
|
||||
int ID = base::ValueRef(pPropertyData);
|
||||
uint32 Index = ValueIndex(ID);
|
||||
return Index >= 0 && Index < mValues.size();
|
||||
}
|
||||
|
||||
bool OverridesTypeName() const
|
||||
{
|
||||
return mpArchetype ? TPropCast<TEnumPropertyBase>(mpArchetype)->OverridesTypeName() : mOverrideTypeName;
|
||||
return base::mpArchetype ? TPropCast<TEnumPropertyBase>(base::mpArchetype)->OverridesTypeName() : mOverrideTypeName;
|
||||
}
|
||||
|
||||
void SetOverrideTypeName(bool Override)
|
||||
{
|
||||
if (mpArchetype)
|
||||
if (base::mpArchetype)
|
||||
{
|
||||
TEnumPropertyBase* pArchetype = TPropCast<TEnumPropertyBase>(RootArchetype());
|
||||
TEnumPropertyBase* pArchetype = TPropCast<TEnumPropertyBase>(base::RootArchetype());
|
||||
pArchetype->SetOverrideTypeName(Override);
|
||||
}
|
||||
else
|
||||
|
@ -159,7 +160,7 @@ public:
|
|||
if (mOverrideTypeName != Override)
|
||||
{
|
||||
mOverrideTypeName = Override;
|
||||
MarkDirty();
|
||||
base::MarkDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ void CPropertyNameGenerator::Warmup()
|
|||
mWords.clear();
|
||||
|
||||
// Load the word list from the file
|
||||
FILE* pListFile = fopen("../resources/WordList.txt", "r");
|
||||
FILE* pListFile = fopen(*(gDataDir + "resources/WordList.txt"), "r");
|
||||
ASSERT(pListFile);
|
||||
|
||||
while (!feof(pListFile))
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
#include "Core/Resource/Script/NGameList.h"
|
||||
#include "Core/Resource/Script/NPropertyMap.h"
|
||||
|
||||
#include <cfloat>
|
||||
|
||||
/** IProperty */
|
||||
IProperty::IProperty(EGame Game)
|
||||
: mpParent( nullptr )
|
||||
|
@ -311,7 +313,7 @@ TString IProperty::GetTemplateFileName()
|
|||
pTemplateRoot = pTemplateRoot->RootParent();
|
||||
|
||||
// Now that we have the base property of our template, we can return the file path.
|
||||
static const uint32 kChopAmount = strlen("../templates/");
|
||||
static const uint32 kChopAmount = strlen(*(gDataDir + "templates/"));
|
||||
|
||||
if (pTemplateRoot->ScriptTemplate())
|
||||
{
|
||||
|
|
|
@ -419,29 +419,30 @@ public:
|
|||
template<typename PropType, EPropertyType PropEnum>
|
||||
class TSerializeableTypedProperty : public TTypedProperty<PropType, PropEnum>
|
||||
{
|
||||
using base = TTypedProperty<PropType, PropEnum>;
|
||||
protected:
|
||||
TSerializeableTypedProperty(EGame Game)
|
||||
: TTypedProperty(Game)
|
||||
: base(Game)
|
||||
{}
|
||||
|
||||
public:
|
||||
virtual void Serialize(IArchive& rArc)
|
||||
{
|
||||
TTypedProperty::Serialize(rArc);
|
||||
TSerializeableTypedProperty* pArchetype = static_cast<TSerializeableTypedProperty*>(mpArchetype);
|
||||
base::Serialize(rArc);
|
||||
TSerializeableTypedProperty* pArchetype = static_cast<TSerializeableTypedProperty*>(base::mpArchetype);
|
||||
|
||||
// Determine if default value should be serialized as optional.
|
||||
// All MP1 properties should be optional. For MP2 and on, we set optional
|
||||
// on property types that don't have default values in the game executable.
|
||||
bool MakeOptional = false;
|
||||
|
||||
if (Game() <= EGame::Prime || pArchetype != nullptr)
|
||||
if (base::Game() <= EGame::Prime || pArchetype != nullptr)
|
||||
{
|
||||
MakeOptional = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (Type())
|
||||
switch (base::Type())
|
||||
{
|
||||
case EPropertyType::String:
|
||||
case EPropertyType::Asset:
|
||||
|
@ -457,17 +458,18 @@ public:
|
|||
|
||||
// Branch here to avoid constructing a default value if we don't need to.
|
||||
if (MakeOptional)
|
||||
rArc << SerialParameter("DefaultValue", mDefaultValue, SH_Optional, pArchetype ? pArchetype->mDefaultValue : GetSerializationDefaultValue());
|
||||
rArc << SerialParameter("DefaultValue", base::mDefaultValue, SH_Optional,
|
||||
pArchetype ? pArchetype->mDefaultValue : GetSerializationDefaultValue());
|
||||
else
|
||||
rArc << SerialParameter("DefaultValue", mDefaultValue);
|
||||
rArc << SerialParameter("DefaultValue", base::mDefaultValue);
|
||||
}
|
||||
|
||||
virtual bool ShouldSerialize() const
|
||||
{
|
||||
TTypedProperty* pArchetype = static_cast<TTypedProperty*>(mpArchetype);
|
||||
base* pArchetype = static_cast<base*>(base::mpArchetype);
|
||||
|
||||
return TTypedProperty::ShouldSerialize() ||
|
||||
!(mDefaultValue == pArchetype->DefaultValue());
|
||||
return base::ShouldSerialize() ||
|
||||
!(base::mDefaultValue == pArchetype->DefaultValue());
|
||||
}
|
||||
|
||||
/** Return default value for serialization - can be customized per type */
|
||||
|
@ -480,6 +482,7 @@ public:
|
|||
template<typename PropType, EPropertyType PropEnum>
|
||||
class TNumericalProperty : public TSerializeableTypedProperty<PropType, PropEnum>
|
||||
{
|
||||
using base = TSerializeableTypedProperty<PropType, PropEnum>;
|
||||
friend class IProperty;
|
||||
friend class CTemplateLoader;
|
||||
|
||||
|
@ -488,7 +491,7 @@ protected:
|
|||
PropType mMaxValue;
|
||||
|
||||
TNumericalProperty(EGame Game)
|
||||
: TSerializeableTypedProperty(Game)
|
||||
: base(Game)
|
||||
, mMinValue( -1 )
|
||||
, mMaxValue( -1 )
|
||||
{}
|
||||
|
@ -496,8 +499,8 @@ protected:
|
|||
public:
|
||||
virtual void Serialize(IArchive& rArc)
|
||||
{
|
||||
TSerializeableTypedProperty::Serialize(rArc);
|
||||
TNumericalProperty* pArchetype = static_cast<TNumericalProperty*>(mpArchetype);
|
||||
base::Serialize(rArc);
|
||||
TNumericalProperty* pArchetype = static_cast<TNumericalProperty*>(base::mpArchetype);
|
||||
|
||||
rArc << SerialParameter("Min", mMinValue, SH_Optional, pArchetype ? pArchetype->mMinValue : (PropType) -1)
|
||||
<< SerialParameter("Max", mMaxValue, SH_Optional, pArchetype ? pArchetype->mMaxValue : (PropType) -1);
|
||||
|
@ -505,15 +508,15 @@ public:
|
|||
|
||||
virtual bool ShouldSerialize() const
|
||||
{
|
||||
TNumericalProperty* pArchetype = static_cast<TNumericalProperty*>(mpArchetype);
|
||||
return TSerializeableTypedProperty::ShouldSerialize() ||
|
||||
TNumericalProperty* pArchetype = static_cast<TNumericalProperty*>(base::mpArchetype);
|
||||
return base::ShouldSerialize() ||
|
||||
mMinValue != pArchetype->mMinValue ||
|
||||
mMaxValue != pArchetype->mMaxValue;
|
||||
}
|
||||
|
||||
virtual void InitFromArchetype(IProperty* pOther)
|
||||
{
|
||||
TSerializeableTypedProperty::InitFromArchetype(pOther);
|
||||
base::InitFromArchetype(pOther);
|
||||
TNumericalProperty* pCastOther = static_cast<TNumericalProperty*>(pOther);
|
||||
mMinValue = pCastOther->mMinValue;
|
||||
mMaxValue = pCastOther->mMaxValue;
|
||||
|
@ -521,11 +524,11 @@ public:
|
|||
|
||||
virtual void PropertyValueChanged(void* pPropertyData)
|
||||
{
|
||||
TSerializeableTypedProperty::PropertyValueChanged(pPropertyData);
|
||||
base::PropertyValueChanged(pPropertyData);
|
||||
|
||||
if (mMinValue >= 0 && mMaxValue >= 0)
|
||||
{
|
||||
PropType& rValue = ValueRef(pPropertyData);
|
||||
PropType& rValue = base::ValueRef(pPropertyData);
|
||||
rValue = Math::Clamp(mMinValue, mMaxValue, rValue);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include "CVectorProperty.h"
|
||||
|
||||
/** TPropertyRef: Embeds a reference to a property on a specific object */
|
||||
template<class PropertyClass, typename ValueType = PropertyClass::ValueType>
|
||||
template<class PropertyClass, typename ValueType = typename PropertyClass::ValueType>
|
||||
class TPropertyRef
|
||||
{
|
||||
/** Property data being referenced */
|
||||
|
@ -96,17 +96,18 @@ typedef TPropertyRef<CArrayProperty> CArrayRef;
|
|||
template<typename ValueType>
|
||||
class TEnumRef : public TPropertyRef<CEnumProperty, ValueType>
|
||||
{
|
||||
using base = TPropertyRef<CEnumProperty, ValueType>;
|
||||
public:
|
||||
TEnumRef()
|
||||
: TPropertyRef()
|
||||
: base()
|
||||
{}
|
||||
|
||||
TEnumRef(void* pInData, IProperty* pInProperty)
|
||||
: TPropertyRef(pInData, pInProperty)
|
||||
: base(pInData, pInProperty)
|
||||
{}
|
||||
|
||||
TEnumRef(void* pInData, CEnumProperty* pInProperty)
|
||||
: TPropertyRef(pInData, pInProperty)
|
||||
: base(pInData, pInProperty)
|
||||
{}
|
||||
};
|
||||
|
||||
|
|
|
@ -27,12 +27,12 @@ class CScriptNode : public CSceneNode
|
|||
|
||||
CLightParameters *mpLightParameters;
|
||||
|
||||
public:
|
||||
enum class EGameModeVisibility
|
||||
{
|
||||
Visible, NotVisible, Untested
|
||||
} mGameModeVisibility;
|
||||
|
||||
public:
|
||||
CScriptNode(CScene *pScene, uint32 NodeID, CSceneNode *pParent = 0, CScriptObject *pObject = 0);
|
||||
ENodeType NodeType();
|
||||
void PostLoad();
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
class CDamageableTriggerExtra : public CScriptExtra
|
||||
{
|
||||
public:
|
||||
// Render fluid planes for doors in MP1
|
||||
enum class ERenderSide
|
||||
{
|
||||
|
@ -17,6 +18,7 @@ class CDamageableTriggerExtra : public CScriptExtra
|
|||
Down = 0x20
|
||||
};
|
||||
|
||||
private:
|
||||
CVectorRef mPlaneSize;
|
||||
TEnumRef<ERenderSide> mRenderSide;
|
||||
CAssetRef mTextureAssets[3];
|
||||
|
|
|
@ -37,7 +37,6 @@ CEditorApplication::~CEditorApplication()
|
|||
{
|
||||
NDolphinIntegration::KillQuickplay();
|
||||
delete mpWorldEditor;
|
||||
delete mpProjectDialog;
|
||||
}
|
||||
|
||||
void CEditorApplication::InitEditor()
|
||||
|
@ -346,6 +345,7 @@ void CEditorApplication::OnEditorClose()
|
|||
|
||||
if (pEditor == mpWorldEditor)
|
||||
{
|
||||
mpWorldEditor->deleteLater();
|
||||
mpWorldEditor = nullptr;
|
||||
quit();
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ CExportGameDialog::CExportGameDialog(const QString& rkIsoPath, const QString& rk
|
|||
mpUI->setupUi(this);
|
||||
|
||||
// Set up disc
|
||||
mpDisc = nod::OpenDiscFromImage(TO_WCHAR(rkIsoPath)).release();
|
||||
mpDisc = nod::OpenDiscFromImage(QStringToNodString(rkIsoPath)).release();
|
||||
|
||||
if (ValidateGame())
|
||||
{
|
||||
|
|
|
@ -226,7 +226,7 @@ void CGeneratePropertyNamesDialog::OnTreeItemDoubleClicked(QTreeWidgetItem* pIte
|
|||
if (Text.endsWith(".xml"))
|
||||
{
|
||||
TString TStrText = TO_TSTRING(Text);
|
||||
TString DirPath = "../templates/" + TStrText.GetFileDirectory();
|
||||
TString DirPath = gDataDir + "templates/" + TStrText.GetFileDirectory();
|
||||
TString AbsPath = FileUtil::MakeAbsolute(DirPath) + TStrText.GetFileName();
|
||||
UICommon::OpenInExternalApplication( TO_QSTRING(AbsPath) );
|
||||
}
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
cmake_minimum_required(VERSION 3.12)
|
||||
|
||||
# TODO: These should be drive by CI if CI ever becomes a thing for PWE.
|
||||
set(PWE_APP_NAME "Prime World Editor")
|
||||
|
||||
# obtain revision info from git
|
||||
find_package(Git)
|
||||
if(GIT_FOUND)
|
||||
|
@ -49,6 +52,7 @@ project(pwe_editor LANGUAGES CXX VERSION ${PWE_VERSION_STRING})
|
|||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
|
||||
if (WIN32)
|
||||
set(QT_PLATFORM_COMPONENTS WinExtras)
|
||||
|
@ -56,10 +60,6 @@ if (WIN32)
|
|||
endif()
|
||||
|
||||
find_package(Qt5 COMPONENTS Core Widgets ${QT_PLATFORM_COMPONENTS} REQUIRED)
|
||||
find_package(assimp CONFIG REQUIRED)
|
||||
|
||||
# AssImp's cmake config is pretty awful. It doesn't include necesary libraries. Hopefully this can be fixed later.
|
||||
find_library(IIRXML_LIBRARY NAMES IrrXMLd IrrXML)
|
||||
|
||||
file(GLOB_RECURSE source_files
|
||||
"*.cpp"
|
||||
|
@ -67,9 +67,39 @@ file(GLOB_RECURSE source_files
|
|||
"*.hpp"
|
||||
)
|
||||
|
||||
add_executable(pwe_editor ${source_files})
|
||||
string(TIMESTAMP CURRENT_YEAR "%Y")
|
||||
|
||||
set_target_properties(pwe_editor PROPERTIES OUTPUT_NAME PrimeWorldEditor DEBUG_POSTFIX -debug)
|
||||
if (WIN32)
|
||||
generate_product_version(rc_file NAME ${PWE_APP_NAME}
|
||||
ICON ${CMAKE_CURRENT_SOURCE_DIR}/icons/win/AppIcon.ico
|
||||
VERSION_MAJOR ${pwe_editor_VERSION_MAJOR} VERSION_MINOR ${pwe_editor_VERSION_MINOR}
|
||||
VERSION_PATCH ${pwe_editor_VERSION_PATCH} VERSION_REVISION ${pwe_editor_VERSION_TWEAK}
|
||||
COMPANY_NAME "Aruki" COMMENTS "${PWE_APP_NAME} ${PWE_WC_DESCRIBE}"
|
||||
ORIGINAL_FILENAME "PrimeWorldEditor")
|
||||
set(PLAT_SRCS ${rc_file} icons/win/PrimeWorldEditor.manifest)
|
||||
elseif (APPLE)
|
||||
set_source_files_properties(icons/mac/mainicon.icns PROPERTIES
|
||||
MACOSX_PACKAGE_LOCATION Resources)
|
||||
configure_file(icons/mac/Info.plist.in "${CMAKE_CURRENT_BINARY_DIR}/Info.plist" @ONLY)
|
||||
file(GLOB_RECURSE RES_SOURCES ${CMAKE_SOURCE_DIR}/resources/* ${CMAKE_SOURCE_DIR}/templates/*)
|
||||
foreach(src ${RES_SOURCES})
|
||||
file(RELATIVE_PATH relsrc ${CMAKE_SOURCE_DIR} ${src})
|
||||
get_filename_component(reldir ${relsrc} DIRECTORY)
|
||||
set_source_files_properties(${src} PROPERTIES MACOSX_PACKAGE_LOCATION Resources/${reldir})
|
||||
endforeach()
|
||||
set(PLAT_SRCS icons/mac/mainicon.icns ${RES_SOURCES})
|
||||
else()
|
||||
configure_file(icons/freedesktop/metainfo/PrimeWorldEditor.appdata.xml.in
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/PrimeWorldEditor.appdata.xml" @ONLY)
|
||||
#install(FILES "${CMAKE_CURRENT_BINARY_DIR}/PrimeWorldEditor.appdata.xml" DESTINATION share/metainfo)
|
||||
install(DIRECTORY icons/freedesktop/applications icons/freedesktop/icons DESTINATION share)
|
||||
endif()
|
||||
|
||||
add_executable(pwe_editor MACOSX_BUNDLE ${source_files} Icons.qrc ${PLAT_SRCS})
|
||||
|
||||
set_target_properties(pwe_editor PROPERTIES OUTPUT_NAME PrimeWorldEditor DEBUG_POSTFIX -debug
|
||||
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_BINARY_DIR}/Info.plist"
|
||||
MACOSX_BUNDLE_BUNDLE_NAME "PrimeWorldEditor")
|
||||
|
||||
target_compile_features(pwe_editor PRIVATE cxx_std_17)
|
||||
|
||||
|
@ -78,12 +108,8 @@ target_link_libraries(
|
|||
pwe_core
|
||||
Qt5::Widgets
|
||||
${QT_PLATFORM_COMPONENTS_LIBS}
|
||||
${IIRXML_LIBRARY}
|
||||
)
|
||||
|
||||
# TODO: These should be drive by CI if CI ever becomes a thing for PWE.
|
||||
set(PWE_APP_NAME "Prime World Editor")
|
||||
|
||||
target_compile_definitions(
|
||||
pwe_editor
|
||||
PRIVATE
|
||||
|
@ -102,11 +128,42 @@ if (WIN32)
|
|||
message(FATAL_ERROR "Unable to find windeployqt")
|
||||
endif()
|
||||
|
||||
# run windeployqt to gather necessary .dlls
|
||||
# run windeployqt to gather necessary qt libraries and plugins
|
||||
add_custom_command(TARGET pwe_editor POST_BUILD COMMAND ${WINDEPLOYQT_PROGRAM} ARGS
|
||||
--no-angle --no-opengl-sw $<TARGET_FILE:pwe_editor>)
|
||||
|
||||
# copy bin directory of dew prefix
|
||||
add_custom_command(TARGET pwe_editor POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy_directory
|
||||
"${DEW_CMAKE_PREFIX_PATH}/bin" $<TARGET_FILE_DIR:pwe_editor>)
|
||||
elseif (APPLE)
|
||||
find_program(MACDEPLOYQT_PROGRAM macdeployqt PATHS $ENV{QTDIR}/bin/)
|
||||
if(MACDEPLOYQT_PROGRAM)
|
||||
message(STATUS "Found ${MACDEPLOYQT_PROGRAM}")
|
||||
else()
|
||||
message(FATAL_ERROR "Unable to find macdeployqt")
|
||||
endif()
|
||||
|
||||
# run macdeployqt to gather necessary qt libraries and plugins
|
||||
add_custom_command(TARGET pwe_editor POST_BUILD COMMAND ${MACDEPLOYQT_PROGRAM} ARGS $<TARGET_FILE:pwe_editor>)
|
||||
else()
|
||||
target_compile_definitions(
|
||||
pwe_editor
|
||||
PRIVATE
|
||||
"PWE_DATADIR=\"${CMAKE_INSTALL_PREFIX}/share/PrimeWorldEditor\""
|
||||
)
|
||||
|
||||
install(TARGETS pwe_editor)
|
||||
set(USER_PERMISSIONS DIRECTORY_PERMISSIONS
|
||||
OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_WRITE WORLD_EXECUTE
|
||||
FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ GROUP_WRITE WORLD_READ WORLD_WRITE)
|
||||
install(DIRECTORY "${CMAKE_SOURCE_DIR}/resources" DESTINATION share/PrimeWorldEditor ${USER_PERMISSIONS})
|
||||
install(DIRECTORY "${CMAKE_SOURCE_DIR}/templates" DESTINATION share/PrimeWorldEditor ${USER_PERMISSIONS})
|
||||
endif()
|
||||
|
||||
if (NOT APPLE)
|
||||
add_custom_command(TARGET pwe_editor POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy_directory
|
||||
"${CMAKE_SOURCE_DIR}/resources" "${CMAKE_BINARY_DIR}/resources")
|
||||
|
||||
add_custom_command(TARGET pwe_editor POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy_directory
|
||||
"${CMAKE_SOURCE_DIR}/templates" "${CMAKE_BINARY_DIR}/templates")
|
||||
endif()
|
||||
|
|
|
@ -165,7 +165,7 @@ void CProjectSettingsDialog::BuildISO()
|
|||
|
||||
// Verify this ISO matches the original
|
||||
bool IsWii;
|
||||
pBaseDisc = nod::OpenDiscFromImage(TO_WCHAR(SourceIsoPath), IsWii);
|
||||
pBaseDisc = nod::OpenDiscFromImage(QStringToNodString(SourceIsoPath), IsWii);
|
||||
|
||||
if (!pBaseDisc || !IsWii)
|
||||
{
|
||||
|
|
|
@ -25,7 +25,8 @@ CSceneViewport::CSceneViewport(QWidget *pParent)
|
|||
|
||||
mpRenderer = new CRenderer();
|
||||
mpRenderer->SetClearColor(CColor::skBlack);
|
||||
mpRenderer->SetViewportSize(width(), height());
|
||||
qreal pixelRatio = devicePixelRatioF();
|
||||
mpRenderer->SetViewportSize(width() * pixelRatio, height() * pixelRatio);
|
||||
|
||||
mViewInfo.pScene = mpScene;
|
||||
mViewInfo.pRenderer = mpRenderer;
|
||||
|
@ -207,7 +208,7 @@ void CSceneViewport::CreateContextMenu()
|
|||
mpPlayFromHereSeparator = new QAction(this);
|
||||
mpPlayFromHereSeparator->setSeparator(true);
|
||||
|
||||
mpPlayFromHereAction = new QAction("Play from here");
|
||||
mpPlayFromHereAction = new QAction("Play from here", this);
|
||||
connect(mpPlayFromHereAction, SIGNAL(triggered()), this, SLOT(OnPlayFromHere()));
|
||||
|
||||
QList<QAction*> Actions;
|
||||
|
@ -395,7 +396,8 @@ void CSceneViewport::ContextMenu(QContextMenuEvent *pEvent)
|
|||
|
||||
void CSceneViewport::OnResize()
|
||||
{
|
||||
mpRenderer->SetViewportSize(width(), height());
|
||||
qreal pixelRatio = devicePixelRatioF();
|
||||
mpRenderer->SetViewportSize(width() * pixelRatio, height() * pixelRatio);
|
||||
}
|
||||
|
||||
void CSceneViewport::OnMouseClick(QMouseEvent *pEvent)
|
||||
|
|
|
@ -66,6 +66,8 @@ CCollisionEditor::CCollisionEditor(CCollisionMeshGroup* pCollisionMesh, QWidget*
|
|||
SET_WINDOWTITLE_APPVARS(WindowTitle);
|
||||
}
|
||||
|
||||
CCollisionEditor::~CCollisionEditor() {}
|
||||
|
||||
CCollisionEditorViewport* CCollisionEditor::Viewport() const
|
||||
{
|
||||
return mpUI->Viewport;
|
||||
|
|
|
@ -28,6 +28,7 @@ class CCollisionEditor : public IEditor
|
|||
public:
|
||||
/** Constructor/destructor */
|
||||
explicit CCollisionEditor(CCollisionMeshGroup* pCollisionMesh, QWidget* pParent = 0);
|
||||
virtual ~CCollisionEditor();
|
||||
virtual CCollisionEditorViewport* Viewport() const override;
|
||||
|
||||
public slots:
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
<file>icons/SelectMode.png</file>
|
||||
<file>icons/POI Important.png</file>
|
||||
<file>icons/POI Normal.png</file>
|
||||
<file>icons/AppIcon.ico</file>
|
||||
<file>icons/win/AppIcon.ico</file>
|
||||
<file>icons/New.png</file>
|
||||
<file>icons/Open.png</file>
|
||||
<file>icons/Redo.png</file>
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
#include <Common/TString.h>
|
||||
#include <Core/Render/CDrawUtil.h>
|
||||
#include <Core/Render/CRenderer.h>
|
||||
#include <Core/Resource/cooker/CTextureEncoder.h>
|
||||
#include <Core/Resource/factory/CModelLoader.h>
|
||||
#include <Core/Resource/factory/CMaterialLoader.h>
|
||||
#include <Core/Resource/factory/CTextureDecoder.h>
|
||||
#include <Core/Resource/Cooker/CTextureEncoder.h>
|
||||
#include <Core/Resource/Factory/CModelLoader.h>
|
||||
#include <Core/Resource/Factory/CMaterialLoader.h>
|
||||
#include <Core/Resource/Factory/CTextureDecoder.h>
|
||||
#include <Core/Scene/CScene.h>
|
||||
|
||||
#include <iostream>
|
||||
|
|
|
@ -56,7 +56,7 @@ EQuickplayLaunchResult LaunchQuickplay(QWidget* pParentWidget,
|
|||
debugf("Launching quickplay...");
|
||||
|
||||
// Check if quickplay is supported for this project
|
||||
TString QuickplayDir = "../resources/quickplay" / ::GetGameShortName(pProject->Game());
|
||||
TString QuickplayDir = gDataDir + "resources/quickplay" / ::GetGameShortName(pProject->Game());
|
||||
TString BuildString = "v" + TString::FromFloat(pProject->BuildVersion());
|
||||
TString RelFile = QuickplayDir / BuildString + ".rel";
|
||||
TString PatchFile = QuickplayDir / BuildString + ".bin";
|
||||
|
@ -203,7 +203,7 @@ EQuickplayLaunchResult LaunchQuickplay(QWidget* pParentWidget,
|
|||
bool IsQuickplaySupported(CGameProject* pProject)
|
||||
{
|
||||
// Quickplay is supported if there is a quickplay module & patch in the resources folder
|
||||
TString QuickplayDir = "../resources/quickplay" / ::GetGameShortName(pProject->Game());
|
||||
TString QuickplayDir = gDataDir + "resources/quickplay" / ::GetGameShortName(pProject->Game());
|
||||
TString BuildString = "v" + TString::FromFloat(pProject->BuildVersion());
|
||||
TString RelFile = QuickplayDir / BuildString + ".rel";
|
||||
TString PatchFile = QuickplayDir / BuildString + ".bin";
|
||||
|
|
|
@ -989,7 +989,7 @@ void CResourceBrowser::ImportAssetNameMap()
|
|||
|
||||
void CResourceBrowser::ExportAssetNames()
|
||||
{
|
||||
QString OutFile = UICommon::SaveFileDialog(this, "Export asset name map", "*.xml", "../resources/gameinfo/");
|
||||
QString OutFile = UICommon::SaveFileDialog(this, "Export asset name map", "*.xml", *(gDataDir + "resources/gameinfo/"));
|
||||
if (OutFile.isEmpty()) return;
|
||||
TString OutFileStr = TO_TSTRING(OutFile);
|
||||
|
||||
|
|
|
@ -138,13 +138,13 @@ void CResourceTableContextMenu::OpenInExplorer()
|
|||
if (mpClickedEntry)
|
||||
{
|
||||
QString Path = TO_QSTRING( mpClickedEntry->CookedAssetPath() );
|
||||
UICommon::OpenContainingFolder(Path);
|
||||
UICommon::OpenContainingFolder(nullptr, Path);
|
||||
}
|
||||
else
|
||||
{
|
||||
TString BasePath = mpBrowser->CurrentStore()->ResourcesDir();
|
||||
QString Path = TO_QSTRING( BasePath + mpClickedDirectory->FullPath() );
|
||||
UICommon::OpenContainingFolder(Path);
|
||||
UICommon::OpenContainingFolder(nullptr, Path);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,14 +13,48 @@ QWindow* FindWidgetWindowHandle(QWidget *pWidget)
|
|||
return pWidget ? pWidget->windowHandle() : nullptr;
|
||||
}
|
||||
|
||||
void OpenContainingFolder(const QString& rkPath)
|
||||
void OpenContainingFolder(QWidget* parent, const QString& pathIn)
|
||||
{
|
||||
#if WIN32
|
||||
QStringList Args;
|
||||
Args << "/select," << QDir::toNativeSeparators(rkPath);
|
||||
QProcess::startDetached("explorer", Args);
|
||||
const QFileInfo fileInfo(pathIn);
|
||||
// Mac, Windows support folder or file.
|
||||
#if defined(Q_OS_WIN)
|
||||
QString paths = QProcessEnvironment::systemEnvironment().value(QStringLiteral("Path"));
|
||||
QString explorer;
|
||||
for (QString path : paths.split(QStringLiteral(";")))
|
||||
{
|
||||
QFileInfo finfo(QDir(path), QStringLiteral("explorer.exe"));
|
||||
if (finfo.exists())
|
||||
{
|
||||
explorer = finfo.filePath();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (explorer.isEmpty())
|
||||
{
|
||||
QMessageBox::warning(parent, MainWindow::tr("Launching Windows Explorer Failed"),
|
||||
MainWindow::tr("Could not find explorer.exe in path to launch Windows Explorer."));
|
||||
return;
|
||||
}
|
||||
QStringList param;
|
||||
if (!fileInfo.isDir())
|
||||
param += QLatin1String("/select,");
|
||||
param += QDir::toNativeSeparators(fileInfo.canonicalFilePath());
|
||||
QProcess::startDetached(explorer, param);
|
||||
#elif defined(Q_OS_MAC)
|
||||
QStringList scriptArgs;
|
||||
scriptArgs << QLatin1String("-e")
|
||||
<< QString::fromLatin1("tell application \"Finder\" to reveal POSIX file \"%1\"")
|
||||
.arg(fileInfo.canonicalFilePath());
|
||||
QProcess::execute(QLatin1String("/usr/bin/osascript"), scriptArgs);
|
||||
scriptArgs.clear();
|
||||
scriptArgs << QLatin1String("-e") << QLatin1String("tell application \"Finder\" to activate");
|
||||
QProcess::execute(QLatin1String("/usr/bin/osascript"), scriptArgs);
|
||||
#else
|
||||
#error OpenContainingFolder() not implemented!
|
||||
// we cannot select a file here, because no file browser really supports it...
|
||||
const QString folder = fileInfo.isDir() ? fileInfo.absoluteFilePath() : fileInfo.filePath();
|
||||
QProcess browserProc;
|
||||
const QString browserArgs = QStringLiteral("xdg-open \"%1\"").arg(QFileInfo(folder).path());
|
||||
browserProc.startDetached(browserArgs);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -38,12 +38,20 @@
|
|||
//@todo This name isn't ideal, too similar to ToWChar and so might cause confusion
|
||||
#define TO_WCHAR(Str) ToWChar( UICommon::ToT16String(Str) )
|
||||
|
||||
#include <nod/Util.hpp>
|
||||
|
||||
#if NOD_UCS2
|
||||
#define QStringToNodString(string) TO_WCHAR(string)
|
||||
#else
|
||||
#define QStringToNodString(string) string.toUtf8().data()
|
||||
#endif
|
||||
|
||||
namespace UICommon
|
||||
{
|
||||
|
||||
// Utility
|
||||
QWindow* FindWidgetWindowHandle(QWidget* pWidget);
|
||||
void OpenContainingFolder(const QString& rkPath);
|
||||
void OpenContainingFolder(QWidget* parent, const QString& pathIn);
|
||||
bool OpenInExternalApplication(const QString& rkPath);
|
||||
|
||||
// Searches the widget's ancestry tree to find an ancestor of type ObjectT.
|
||||
|
|
|
@ -19,7 +19,7 @@ public:
|
|||
explicit TEnumComboBox(QWidget* pParent = 0)
|
||||
: QComboBox(pParent)
|
||||
{
|
||||
for (TEnumReflection<EnumT>::CIterator It; It; ++It)
|
||||
for (typename TEnumReflection<EnumT>::CIterator It; It; ++It)
|
||||
{
|
||||
if (It.Value() != TEnumReflection<EnumT>::ErrorValue())
|
||||
{
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
[Desktop Entry]
|
||||
Name=Prime World Editor
|
||||
GenericName=Game Data Editor
|
||||
Comment=Edit world assets from games by Retro Studios
|
||||
Exec=PrimeWorldEditor
|
||||
Icon=PrimeWorldEditor
|
||||
Terminal=false
|
||||
Type=Application
|
||||
Categories=Development;
|
After Width: | Height: | Size: 126 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 8.0 KiB |
After Width: | Height: | Size: 46 KiB |
After Width: | Height: | Size: 7.5 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 87 KiB |
After Width: | Height: | Size: 17 KiB |
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Copyright @CURRENT_YEAR@ Aruki -->
|
||||
<component type="desktop-application">
|
||||
<id>com.Aruki.PrimeWorldEditor</id>
|
||||
<metadata_license>FSFAP</metadata_license>
|
||||
<project_license>MIT</project_license>
|
||||
<name>Prime World Editor</name>
|
||||
<summary>Edit world assets from games by Retro Studios</summary>
|
||||
|
||||
<launchable type="desktop-id">PrimeWorldEditor.desktop</launchable>
|
||||
|
||||
<url type="homepage">http://github.com/arukibree/PrimeWorldEditor</url>
|
||||
|
||||
<provides>
|
||||
<binary>PrimeWorldEditor</binary>
|
||||
</provides>
|
||||
|
||||
<releases>
|
||||
<release version="@pwe_editor_VERSION@" />
|
||||
</releases>
|
||||
</component>
|
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>PrimeWorldEditor</string>
|
||||
<key>CFBundleGetInfoString</key>
|
||||
<string>@METADATA_VERSION_STRING@</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>@METADATA_VERSION_STRING@</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>@CURRENT_YEAR@ Aruki</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>mainicon.icns</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.aruki.PrimeWorldEditor</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>@PWE_APP_NAME@</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>@METADATA_VERSION_STRING@</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string>NSApplication</string>
|
||||
<key>NSHighResolutionCapable</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
Before Width: | Height: | Size: 92 KiB After Width: | Height: | Size: 92 KiB |
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
|
||||
<description>Prime World Editor</description>
|
||||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
||||
<application>
|
||||
<!-- Windows 10 -->
|
||||
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
|
||||
<!-- Windows 8.1 -->
|
||||
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
|
||||
<!-- Windows Vista -->
|
||||
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
|
||||
<!-- Windows 7 -->
|
||||
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
|
||||
<!-- Windows 8 -->
|
||||
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
|
||||
</application>
|
||||
</compatibility>
|
||||
<asmv3:application>
|
||||
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
|
||||
<dpiAware>true/PM</dpiAware>
|
||||
</asmv3:windowsSettings>
|
||||
</asmv3:application>
|
||||
</assembly>
|
|
@ -23,6 +23,47 @@ void QtLogRedirect(QtMsgType Type, const QMessageLogContext& /*rkContext*/, cons
|
|||
}
|
||||
}
|
||||
|
||||
static TString LocateDataDirectory()
|
||||
{
|
||||
#if !defined(_WIN32) && !defined(__APPLE__)
|
||||
#ifdef PWE_DATADIR
|
||||
{
|
||||
/* This is for build-configured root */
|
||||
TString dir = FileUtil::MakeAbsolute(PWE_DATADIR);
|
||||
debugf("Checking '%s' for resources", *dir);
|
||||
if (FileUtil::IsDirectory(dir + "resources"))
|
||||
return dir;
|
||||
}
|
||||
#endif
|
||||
{
|
||||
/* This is for locating appimage root */
|
||||
TString dir = FileUtil::MakeAbsolute(TString(QCoreApplication::applicationDirPath().toUtf8().data()) + "/../share/PrimeWorldEditor");
|
||||
debugf("Checking '%s' for resources", *dir);
|
||||
if (FileUtil::IsDirectory(dir + "resources"))
|
||||
return dir;
|
||||
}
|
||||
#endif
|
||||
{
|
||||
/* This is for locating build directory root */
|
||||
TString dir = FileUtil::MakeAbsolute(TString(QCoreApplication::applicationDirPath().toUtf8().data()) + "/..");
|
||||
debugf("Checking '%s' for resources", *dir);
|
||||
if (FileUtil::IsDirectory(dir + "resources"))
|
||||
return dir;
|
||||
}
|
||||
TString dir = FileUtil::MakeAbsolute("..");
|
||||
warnf("Falling back to '%s' for resources", *dir);
|
||||
return dir;
|
||||
}
|
||||
|
||||
static TString LocateLogPath()
|
||||
{
|
||||
#ifndef _WIN32
|
||||
return TString(getenv("HOME")) + "/.primeworldeditor.log";
|
||||
#else
|
||||
return "primeworldeditor.log";
|
||||
#endif
|
||||
}
|
||||
|
||||
class CMain
|
||||
{
|
||||
public:
|
||||
|
@ -35,7 +76,7 @@ public:
|
|||
App.setApplicationName( APP_NAME );
|
||||
App.setApplicationVersion( APP_VERSION );
|
||||
App.setOrganizationName("Aruki");
|
||||
App.setWindowIcon(QIcon(":/icons/AppIcon.ico"));
|
||||
App.setWindowIcon(QIcon(":/icons/win/AppIcon.ico"));
|
||||
|
||||
// Create UI relay
|
||||
CUIRelay UIRelay(&App);
|
||||
|
@ -46,12 +87,15 @@ public:
|
|||
SetupPalette();
|
||||
|
||||
// Init log
|
||||
bool Initialized = NLog::InitLog("primeworldeditor.log");
|
||||
bool Initialized = NLog::InitLog(LocateLogPath());
|
||||
if (!Initialized) UICommon::ErrorMsg(0, "Couldn't open log file. Logging will not work for this session.");
|
||||
qInstallMessageHandler(QtLogRedirect);
|
||||
|
||||
// Locate data directory
|
||||
gDataDir = LocateDataDirectory();
|
||||
|
||||
// Create editor resource store
|
||||
gpEditorStore = new CResourceStore("../resources/");
|
||||
gpEditorStore = new CResourceStore(gDataDir + "resources/");
|
||||
|
||||
if (!gpEditorStore->DatabasePathExists())
|
||||
{
|
||||
|
|