Commit bdb1ef57 authored by figment's avatar figment

Add BGSM,BGEM

Add FO4 Shader Improvements
parent dffe0224
......@@ -700,7 +700,6 @@
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(ProjectDir)Sheets\Max_Version_2016.props" />
<Import Project="$(ProjectDir)Sheets\Max_System_$(Platform).props" />
<Import Project="Sheets\max_compat.props" />
<Import Project="$(ProjectDir)Sheets\Debug_Settings.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release - Max 2012|x64'" Label="PropertySheets">
......@@ -1243,6 +1242,7 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="..\MtlUtils\MtlDefine.h" />
<ClInclude Include="..\NifCommon\AnimKey.h" />
<ClInclude Include="..\NifCommon\AppSettings.h" />
<ClInclude Include="..\NifCommon\Hyperlinks.h" />
......@@ -1509,12 +1509,14 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release - Max 9|x64'">true</ExcludedFromBuild>
</CustomBuild>
<ClInclude Include="..\NifProps\iNifProps.h" />
<ClInclude Include="..\NifProps\MaterialFile.h" />
<ClInclude Include="..\NifProps\NifProps.h" />
<ClInclude Include="..\NifProps\NifStrings.h" />
<ClInclude Include="..\NifProps\resource.h" />
<ClInclude Include="..\NifProps\Shader\shaderutil.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\MtlUtils\mtlutil.cpp" />
<ClCompile Include="..\NifCommon\AnimKey.cpp" />
<ClCompile Include="..\NifCommon\AppSettings.cpp" />
<ClCompile Include="..\NifCommon\Hyperlinks.cpp" />
......@@ -1745,8 +1747,11 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release - Max 9|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release - Max 9|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\NifProps\MaterialFile.cpp" />
<ClCompile Include="..\NifProps\Modifier\BSDismemberSkin.cpp" />
<ClCompile Include="..\NifProps\Modifier\BSSubIndexModifier.cpp" />
<ClCompile Include="..\NifProps\nifProps.cpp" />
<ClCompile Include="..\NifProps\Shader\FO4Shader.cpp" />
<ClCompile Include="..\NifProps\Shader\NifShader.cpp" />
<ClCompile Include="..\NifProps\Shader\shaderutil.cpp" />
</ItemGroup>
......@@ -1754,7 +1759,11 @@
<Image Include="..\NifProps\Modifier\AddDel16.bmp" />
<Image Include="..\NifProps\Modifier\AddDelMask16.bmp" />
<Image Include="..\NifProps\Modifier\bmp00003.bmp" />
<Image Include="..\NifProps\Modifier\Lock16.bmp" />
<Image Include="..\NifProps\Modifier\LockMask16.bmp" />
<Image Include="..\NifProps\Modifier\selmask.bmp" />
<Image Include="Modifier\Lock16.bmp" />
<Image Include="Modifier\LockMask16.bmp" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\NifExport\NifExport.rc" />
......
......@@ -76,6 +76,9 @@
<Filter Include="NifImport\Resource Files">
<UniqueIdentifier>{2fd033b1-38b9-4254-93b7-e866d370a32e}</UniqueIdentifier>
</Filter>
<Filter Include="MtlUtils">
<UniqueIdentifier>{c9ecfbd7-8249-4069-9706-4d03a80dba4f}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\NifProps\iNifProps.h">
......@@ -192,6 +195,12 @@
<ClInclude Include="..\NifImport\NIFImporter.h">
<Filter>NifImport\Importer</Filter>
</ClInclude>
<ClInclude Include="..\MtlUtils\MtlDefine.h">
<Filter>MtlUtils</Filter>
</ClInclude>
<ClInclude Include="..\NifProps\MaterialFile.h">
<Filter>NifProps\Core</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\NifProps\nifProps.cpp">
......@@ -347,6 +356,18 @@
<ClCompile Include="..\NifImport\ImportParticles.cpp">
<Filter>NifImport\Importer</Filter>
</ClCompile>
<ClCompile Include="..\NifProps\Modifier\BSSubIndexModifier.cpp">
<Filter>NifProps\Modifier</Filter>
</ClCompile>
<ClCompile Include="..\MtlUtils\mtlutil.cpp">
<Filter>MtlUtils</Filter>
</ClCompile>
<ClCompile Include="..\NifProps\Shader\FO4Shader.cpp">
<Filter>NifProps\Shader</Filter>
</ClCompile>
<ClCompile Include="..\NifProps\MaterialFile.cpp">
<Filter>NifProps\Core</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Image Include="..\NifProps\Modifier\AddDel16.bmp">
......@@ -361,6 +382,18 @@
<Image Include="..\NifProps\Modifier\bmp00003.bmp">
<Filter>NifProps\Resources</Filter>
</Image>
<Image Include="..\NifProps\Modifier\LockMask16.bmp">
<Filter>NifProps\Resources</Filter>
</Image>
<Image Include="Modifier\Lock16.bmp">
<Filter>NifProps\Resources</Filter>
</Image>
<Image Include="..\NifProps\Modifier\Lock16.bmp">
<Filter>NifProps\Resources</Filter>
</Image>
<Image Include="Modifier\LockMask16.bmp">
<Filter>NifProps\Resources</Filter>
</Image>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\NifProps\NifProps.rc">
......
......@@ -13,7 +13,7 @@
</ClCompile>
<Link>
<AdditionalLibraryDirectories>$(ProjectDir)..\..\niflib\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>niflib_static_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>niflib_static_$(NifBuildType)_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup />
......
......@@ -86,4 +86,72 @@ MaxNifTools uses Havok
NifMagic uses WildMagic 4.7. WildMagic 4.7 is open source and is covered
by the GNU Lesser General Public License (LGPL).
\ No newline at end of file
======================================================================
This software uses RapidJSON. All of RapidJSON's code can be found under
NifCommon/rapidjson and the above license does not apply to that
part of the code. The original RapidJSON code can be downloaded from
https://github.com/miloyip/rapidjson
RapidJSON falls under the following license:
Tencent is pleased to support the open source community by making RapidJSON available.
Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.
If you have downloaded a copy of the RapidJSON binary from Tencent, please note that the RapidJSON binary is licensed under the MIT License.
If you have downloaded a copy of the RapidJSON source code from Tencent, please note that RapidJSON source code is licensed under the MIT License, except for the third-party components listed below which are subject to different license terms. Your integration of RapidJSON into your own projects may require compliance with the MIT License, as well as the other licenses applicable to the third-party components included within RapidJSON. To avoid the problematic JSON license in your own projects, it's sufficient to exclude the bin/jsonchecker/ directory, as it's the only code under the JSON license.
A copy of the MIT License is included in this file.
Other dependencies and licenses:
Open Source Software Licensed Under the BSD License:
--------------------------------------------------------------------
The msinttypes r29
Copyright (c) 2006-2013 Alexander Chemeris
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Open Source Software Licensed Under the JSON License:
--------------------------------------------------------------------
json.org
Copyright (c) 2002 JSON.org
All Rights Reserved.
JSON_checker
Copyright (c) 2002 JSON.org
All Rights Reserved.
Terms of the JSON License:
---------------------------------------------------
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
The Software shall be used for Good, not Evil.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Terms of the MIT License:
--------------------------------------------------------------------
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
......@@ -476,6 +476,7 @@ InstallPath=[HKLM\SOFTWARE\Bethesda Softworks\Fallout 4]=@"Installed Path"
RootPath=${InstallPath}Data
ExtractFolder=$(RootPath)
MeshRootPath=${ExtractFolder}
MaterialRootPath=${ExtractFolder}
TextureRootPath=${ExtractFolder}
UseSkeleton=1
Skeleton=${MeshRootPath}\Meshes\actors\character\character assets\skeleton.nif
......@@ -484,6 +485,7 @@ RootPaths=${RootPath};${MeshRootPath};${TextureRootPath}\Textures
TextureRootPaths=${RootPath};${TextureRootPath}\Textures;${TextureRootPath}\
TextureExtensions=.dds;
TextureSearchPaths=${RootPath}\Textures;${TextureRootPath}\Textures;${TextureRootPath}
MaterialPaths=${RootPath};${MaterialRootPath}\Materials;${MaterialRootPath}
SupportPrnStrings=1
Rotate90Degrees=NPC Head
SkeletonCheck=NPC*
......
/**********************************************************************
*<
FILE: MtlDefine.h
DESCRIPTION: Material Definition
HISTORY:
*> Copyright (c) 2015, All Rights Reserved.
**********************************************************************/
typedef struct MaterialHeader
{
char Signature[4];
uint32_t Version;
} MaterialHeader;
enum AlphaBlendModeType
{
ABMT_Unknown = 0,
ABMT_None,
ABMT_Standard,
ABMT_Additive,
ABMT_Multiplicative,
};
enum AlphaBlendFunc : uint32_t {
ABF_ONE = 0,
ABF_ZERO = 1,
ABF_SRC_COLOR = 2,
ABF_ONE_MINUS_SRC_COLOR = 3,
ABF_DST_COLOR = 4,
ABF_ONE_MINUS_DST_COLOR = 5,
ABF_SRC_ALPHA = 6,
ABF_ONE_MINUS_SRC_ALPHA = 7,
ABF_DST_ALPHA = 8,
ABF_ONE_MINUS_DST_ALPHA = 9,
ABF_SRC_ALPHA_SATURATE = 10
};
typedef struct BaseMaterial
{
bool TileU;
bool TileV;
float UOffset;
float VOffset;
float UScale;
float VScale;
float Alpha;
AlphaBlendModeType AlphaBlendMode;
bool BlendState;
AlphaBlendFunc BlendFunc1;
AlphaBlendFunc BlendFunc2;
::byte AlphaTestRef;
bool AlphaTest;
bool ZBufferWrite;
bool ZBufferTest;
bool ScreenSpaceReflections;
bool WetnessControlScreenSpaceReflections;
bool Decal;
bool TwoSided;
bool DecalNoFade;
bool NonOccluder;
bool Refraction;
bool RefractionFalloff;
float RefractionPower;
bool EnvironmentMapping;
float EnvironmentMappingMaskScale;
bool GrayscaleToPaletteColor;
} BaseMaterial;
typedef struct BGSMFile : BaseMaterial
{
tstring DiffuseTexture;
tstring NormalTexture;
tstring SmoothSpecTexture;
tstring GreyscaleTexture;
tstring EnvmapTexture;
tstring GlowTexture;
tstring InnerLayerTexture;
tstring WrinklesTexture;
tstring DisplacementTexture;
bool EnableEditorAlphaRef;
bool RimLighting;
float RimPower;
float BackLightPower;
bool SubsurfaceLighting;
float SubsurfaceLightingRolloff;
bool SpecularEnabled;
Niflib::Color3 SpecularColor;
float SpecularMult;
float Smoothness;
float FresnelPower;
float WetnessControlSpecScale;
float WetnessControlSpecPowerScale;
float WetnessControlSpecMinvar;
float WetnessControlEnvMapScale;
float WetnessControlFresnelPower;
float WetnessControlMetalness;
tstring RootMaterialPath;
bool AnisoLighting;
bool EmitEnabled;
Niflib::Color3 EmittanceColor;// if( EmitEnabled)
float EmittanceMult;
bool ModelSpaceNormals;
bool ExternalEmittance;
bool BackLighting;
bool ReceiveShadows;
bool HideSecret;
bool CastShadows;
bool DissolveFade;
bool AssumeShadowmask;
bool Glowmap;
bool EnvironmentMappingWindow;
bool EnvironmentMappingEye;
bool Hair;
Niflib::Color3 HairTintColor;
bool Tree;
bool Facegen;
bool SkinTint;
bool Tessellate;
float DisplacementTextureBias;
float DisplacementTextureScale;
float TessellationPNScale;
float TessellationBaseFactor;
float TessellationFadeDistance;
float GrayscaleToPaletteScale;
bool SkewSpecularAlpha; // (header.Version >= 1)
} BGSMFile;
typedef struct BGEMFile : BaseMaterial {
tstring BaseTexture;
tstring GrayscaleTexture;
tstring EnvmapTexture;
tstring NormalTexture;
tstring EnvmapMaskTexture;
bool BloodEnabled;
bool EffectLightingEnabled;
bool FalloffEnabled;
bool FalloffColorEnabled;
bool GrayscaleToPaletteAlpha;
bool SoftEnabled;
Niflib::Color3 BaseColor;
float BaseColorScale; // 1.0f
float FalloffStartAngle;
float FalloffStopAngle;
float FalloffStartOpacity;
float FalloffStopOpacity;
float LightingInfluence; // 1.0f
::byte EnvmapMinLOD;
float SoftDepth; // 100.0f
} BGEMFile;
extern bool InitialzeBGSM(BGSMFile& bgsm);
extern bool ReadBGSMFile(const tstring& filename, BGSMFile& bgsm);
extern bool InitialzeBGEM(BGEMFile& bgem);
extern bool ReadBGEMFile(const tstring& filename, BGEMFile& bgem);
extern AlphaBlendModeType ConvertAlphaBlendMode(bool BlendState, AlphaBlendFunc BlendFunc1, AlphaBlendFunc BlendFunc2);
extern void ConvertAlphaBlendMode(AlphaBlendModeType type, bool& BlendState, AlphaBlendFunc& BlendFunc1, AlphaBlendFunc& BlendFunc2);
This diff is collapsed.
......@@ -56,6 +56,7 @@ void AppSettings::ReadSettings(tstring iniFile)
searchPaths = TokenizeString(GetSetting<tstring>(TEXT("TextureSearchPaths")).c_str(), TEXT(";"));
extensions = TokenizeString(GetSetting<tstring>(TEXT("TextureExtensions")).c_str(), TEXT(";"));
textureRootPaths = TokenizeString(GetSetting<tstring>(TEXT("TextureRootPaths")).c_str(), TEXT(";"));
materialRootPaths = TokenizeString(GetSetting<tstring>(TEXT("MaterialPaths")).c_str(), TEXT(";"));
Skeleton = GetSetting<tstring>(TEXT("Skeleton"));
useSkeleton = GetSetting<bool>(TEXT("UseSkeleton"), useSkeleton);
......@@ -87,7 +88,15 @@ void AppSettings::WriteSettings(Interface *gi)
}
tstring AppSettings::FindImage(const tstring& fname) {
void AppSettings::CacheImages()
{
if (!parsedImages) {
FindImages(imgTable, rootPath, searchPaths, extensions);
parsedImages = true;
}
}
tstring AppSettings::FindImage(const tstring& fname) const {
TCHAR buffer[MAX_PATH];
// Simply check for fully qualified path
......@@ -97,7 +106,7 @@ tstring AppSettings::FindImage(const tstring& fname) {
}
// Test if its relative and in one of the specified root paths
for (tstringlist::iterator itr = textureRootPaths.begin(), end = textureRootPaths.end(); itr != end; ++itr) {
for (tstringlist::const_iterator itr = textureRootPaths.begin(), end = textureRootPaths.end(); itr != end; ++itr) {
PathCombine(buffer, itr->c_str(), fname.c_str());
if (-1 != _taccess(buffer, 0)) {
return tstring(buffer);
......@@ -105,15 +114,12 @@ tstring AppSettings::FindImage(const tstring& fname) {
}
// Hit the directories to find out whats out there
if (!parsedImages) {
FindImages(imgTable, rootPath, searchPaths, extensions);
parsedImages = true;
}
const_cast<AppSettings*>(this)->CacheImages();
// Search my filename for our texture
_tcscpy(buffer, PathFindFileName(fname.c_str()));
PathRemoveExtension(buffer);
NameValueCollection::iterator nmitr = imgTable.find(buffer);
NameValueCollection::const_iterator nmitr = imgTable.find(buffer);
if (nmitr != imgTable.end()) {
if (!rootPath.empty()) {
_tcscpy(buffer, rootPath.c_str());
......@@ -127,16 +133,58 @@ tstring AppSettings::FindImage(const tstring& fname) {
return fname;
}
tstring AppSettings::FindMaterial(const tstring& fname) const {
TCHAR buffer[MAX_PATH];
// Simply check for fully qualified path
if (!PathIsRelative(fname.c_str())) {
if (-1 != _taccess(fname.c_str(), 0))
return fname;
}
// Test if its relative and in one of the specified root paths
for (tstringlist::const_iterator itr = materialRootPaths.begin(), end = materialRootPaths.end(); itr != end; ++itr) {
PathCombine(buffer, itr->c_str(), fname.c_str());
if (-1 != _taccess(buffer, 0)) {
return tstring(buffer);
}
}
return fname;
}
bool AppSettings::FindFile(const tstring& fname, tstring& resolved_name) const
{
TCHAR buffer[MAX_PATH];
// Simply check for fully qualified path
if (!PathIsRelative(fname.c_str())) {
if (-1 != _taccess(fname.c_str(), 0)) {
resolved_name = fname;
return true;
}
}
// Test if its relative and in one of the specified root paths
for (tstringlist::const_iterator itr = rootPaths.begin(), end = rootPaths.end(); itr != end; ++itr) {
PathCombine(buffer, itr->c_str(), fname.c_str());
if (-1 != _taccess(buffer, 0)) {
resolved_name = tstring(buffer);
return true;
}
}
resolved_name = fname;
return false;
}
// Check whether the given file is a child of the root paths
bool AppSettings::IsFileInRootPaths(const tstring& fname)
bool AppSettings::IsFileInRootPaths(const tstring& fname) const
{
TCHAR root[MAX_PATH];
TCHAR file[MAX_PATH];
GetFullPathName(fname.c_str(), _countof(file), file, nullptr);
PathMakePretty(file);
for (tstringlist::iterator itr = rootPaths.begin(), end = rootPaths.end(); itr != end; ++itr) {
for (tstringlist::const_iterator itr = rootPaths.begin(), end = rootPaths.end(); itr != end; ++itr) {
GetFullPathName((*itr).c_str(), _countof(root), root, nullptr);
PathAddBackslash(root);
PathMakePretty(root);
......@@ -150,12 +198,12 @@ bool AppSettings::IsFileInRootPaths(const tstring& fname)
}
// Return the Relative Texture Path for filename or empty
tstring AppSettings::GetRelativeTexPath(const tstring& fname, const tstring& prefix)
tstring AppSettings::GetRelativeTexPath(const tstring& fname, const tstring& prefix) const
{
return GetRelativeTexPath(fname.c_str(), prefix.c_str());
}
tstring AppSettings::GetRelativeTexPath(LPCTSTR fname, LPCTSTR prefix)
tstring AppSettings::GetRelativeTexPath(LPCTSTR fname, LPCTSTR prefix) const
{
TCHAR buffer[MAX_PATH];
if (textureUseFullPath == 1) // full path name
......@@ -174,7 +222,7 @@ tstring AppSettings::GetRelativeTexPath(LPCTSTR fname, LPCTSTR prefix)
GetFullPathName(fname, _countof(file), file, nullptr);
PathMakePretty(file);
for (tstringlist::iterator itr = textureRootPaths.begin(), end = textureRootPaths.end(); itr != end; ++itr) {
for (tstringlist::const_iterator itr = textureRootPaths.begin(), end = textureRootPaths.end(); itr != end; ++itr) {
GetFullPathName((*itr).c_str(), _countof(root), root, nullptr);
PathAddBackslash(root);
PathMakePretty(root);
......@@ -187,7 +235,7 @@ tstring AppSettings::GetRelativeTexPath(LPCTSTR fname, LPCTSTR prefix)
}
else // Test if its relative to one of the specified root paths just return the texture
{
for (tstringlist::iterator itr = textureRootPaths.begin(), end = textureRootPaths.end(); itr != end; ++itr) {
for (tstringlist::const_iterator itr = textureRootPaths.begin(), end = textureRootPaths.end(); itr != end; ++itr) {
PathCombine(buffer, itr->c_str(), fname);
if (-1 != _taccess(buffer, 0)) {
return fname;
......
......@@ -37,6 +37,7 @@ public:
tstringlist textureRootPaths;
tstringlist rootPaths;
tstringlist extensions;
tstringlist materialRootPaths;
tstring Skeleton;
bool useSkeleton;
tstringlist skeletonSearchPaths;
......@@ -58,14 +59,17 @@ public:
static void Initialize(Interface *gi);
void ReadSettings(tstring iniFile);
void WriteSettings(Interface *gi);
tstring FindImage(const tstring& fname);
bool FindFile(const tstring& fname, tstring& resolved_name) const;
void CacheImages();
tstring FindImage(const tstring& fname) const;
tstring FindMaterial(const tstring& fname) const;
// Check whether the given file is a child of the root paths
bool IsFileInRootPaths(const tstring& fname);
bool IsFileInRootPaths(const tstring& fname) const;
// Return the Relative Texture Path for filename or empty
tstring GetRelativeTexPath(const tstring& fname, const tstring& prefix);
tstring GetRelativeTexPath(LPCTSTR fname, LPCTSTR prefix);
tstring GetRelativeTexPath(const tstring& fname, const tstring& prefix) const;
tstring GetRelativeTexPath(LPCTSTR fname, LPCTSTR prefix) const;
template<typename T>
inline T GetSetting(tstring setting){
......
......@@ -50,7 +50,7 @@ TSTR FormatText(const char* format, ...)
va_start(args, format);
#ifdef UNICODE
size_t Size = _vscprintf(format, args)+1;
text.Resize(Size);
text.Resize(int(Size));
LPSTR buffer = static_cast<LPSTR>(alloca(Size*sizeof(char)));
_vsnprintf(buffer, Size, format, args);
mbstowcs(DataForWrite(text), buffer, Size);
......@@ -86,7 +86,7 @@ TSTR FormatText(const wchar_t* format, ...)
return TSTR(W2T(buffer));
}
size_t Size = _vscwprintf(format, args);
text.Resize(Size);
text.Resize(int(Size));
nChars = _vsnwprintf(DataForWrite(text), Size, format, args);
#endif
va_end(args);
......@@ -356,6 +356,61 @@ NameValueCollectionW ReadIniSection(LPCWSTR Section, LPCWSTR iniFileName)
}
return map;
}
// Parse and ini file section and return the results as s NameValueCollection.
bool ReadIniSectionAsList(LPCSTR Section, LPCSTR iniFileName, NameValueListA& map)
{
DWORD len = 2048 * sizeof(char);
LPSTR buf = (LPSTR)calloc(len + 2, 1);
while (nullptr != buf) {
DWORD rlen = GetPrivateProfileSectionA(Section, buf, len, iniFileName);
if (rlen != (len - 2)) break;
len += 2;
buf = (LPSTR)realloc(buf, len);
}
if (nullptr == buf)
return false;
for (LPSTR line = buf, next = line + strlen(line) + 1; *line; line = next, next = line + strlen(line) + 1) {
Trim(line);
if (line[0] == ';' || line[0] == 0)
continue;
if (LPSTR equals = strchr(line, '=')) {
*equals++ = 0;
Trim(line), Trim(equals);
map.push_back(KeyValuePairA(line, equals));
}
}
return true;
}
bool ReadIniSectionAsList(LPCWSTR Section, LPCWSTR iniFileName, NameValueListW& map)
{
DWORD len = 2048 * sizeof(wchar_t);
LPWSTR buf = (LPWSTR)calloc(len + 2, 1);
while (nullptr != buf) {
DWORD rlen = GetPrivateProfileSectionW(Section, buf, len, iniFileName);
if (rlen != (len - 2)) break;
len += 2;
buf = (LPWSTR)realloc(buf, len*sizeof(wchar_t));
}
if (nullptr == buf)
return false;
for (LPWSTR line = buf, next = line + wcslen(line) + 1; *line; line = next, next = line + wcslen(line) + 1) {
Trim(line);
if (line[0] == ';' || line[0] == 0)