Switched everything over from std::string to TString (farewell StringUtil!)
This commit is contained in:
parent
53408ffac9
commit
367cb6c3d8
|
@ -11,7 +11,7 @@ CFourCC::CFourCC(const char *src)
|
||||||
*this = src;
|
*this = src;
|
||||||
}
|
}
|
||||||
|
|
||||||
CFourCC::CFourCC(const std::string& src)
|
CFourCC::CFourCC(const TString& src)
|
||||||
{
|
{
|
||||||
*this = src;
|
*this = src;
|
||||||
}
|
}
|
||||||
|
@ -37,9 +37,9 @@ u32 CFourCC::ToLong() const
|
||||||
return mFourCC[0] << 24 | mFourCC[1] << 16 | mFourCC[2] << 8 | mFourCC[3];
|
return mFourCC[0] << 24 | mFourCC[1] << 16 | mFourCC[2] << 8 | mFourCC[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CFourCC::ToString() const
|
TString CFourCC::ToString() const
|
||||||
{
|
{
|
||||||
return std::string(mFourCC, 4);
|
return TString(mFourCC, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
CFourCC CFourCC::ToUpper() const
|
CFourCC CFourCC::ToUpper() const
|
||||||
|
@ -64,9 +64,9 @@ CFourCC& CFourCC::operator=(const char *src)
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
CFourCC& CFourCC::operator=(const std::string& src)
|
CFourCC& CFourCC::operator=(const TString& src)
|
||||||
{
|
{
|
||||||
memcpy(&mFourCC[0], src.c_str(), 4);
|
memcpy(&mFourCC[0], src.CString(), 4);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
#define CFOURCC_H
|
#define CFOURCC_H
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
#include "TString.h"
|
||||||
#include <FileIO/CInputStream.h>
|
#include <FileIO/CInputStream.h>
|
||||||
#include <FileIO/COutputStream.h>
|
#include <FileIO/COutputStream.h>
|
||||||
#include <string>
|
|
||||||
|
|
||||||
class CFourCC
|
class CFourCC
|
||||||
{
|
{
|
||||||
|
@ -13,19 +13,19 @@ public:
|
||||||
// Constructors
|
// Constructors
|
||||||
CFourCC();
|
CFourCC();
|
||||||
CFourCC(const char *src);
|
CFourCC(const char *src);
|
||||||
CFourCC(const std::string& src);
|
CFourCC(const TString& src);
|
||||||
CFourCC(u32 src);
|
CFourCC(u32 src);
|
||||||
CFourCC(CInputStream& src);
|
CFourCC(CInputStream& src);
|
||||||
|
|
||||||
// Functionality
|
// Functionality
|
||||||
void Write(COutputStream& Output);
|
void Write(COutputStream& Output);
|
||||||
u32 ToLong() const;
|
u32 ToLong() const;
|
||||||
std::string ToString() const;
|
TString ToString() const;
|
||||||
CFourCC ToUpper() const;
|
CFourCC ToUpper() const;
|
||||||
|
|
||||||
// Operators
|
// Operators
|
||||||
CFourCC& operator=(const char *src);
|
CFourCC& operator=(const char *src);
|
||||||
CFourCC& operator=(const std::string& src);
|
CFourCC& operator=(const TString& src);
|
||||||
CFourCC& operator=(u32 src);
|
CFourCC& operator=(u32 src);
|
||||||
bool operator==(const CFourCC& other) const;
|
bool operator==(const CFourCC& other) const;
|
||||||
bool operator!=(const CFourCC& other) const;
|
bool operator!=(const CFourCC& other) const;
|
||||||
|
|
|
@ -66,7 +66,7 @@ void CHashFNV1A::HashFloat(const float& v)
|
||||||
HashData(&v, 4);
|
HashData(&v, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHashFNV1A::HashString(const std::string& v)
|
void CHashFNV1A::HashString(const TString& v)
|
||||||
{
|
{
|
||||||
HashData(v.data(), v.size());
|
HashData(v.Data(), v.Size());
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#define CHASHFNV1A_H
|
#define CHASHFNV1A_H
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include <string>
|
#include "TString.h"
|
||||||
|
|
||||||
class CHashFNV1A
|
class CHashFNV1A
|
||||||
{
|
{
|
||||||
|
@ -30,7 +30,7 @@ public:
|
||||||
void HashShort(const u16& v);
|
void HashShort(const u16& v);
|
||||||
void HashLong(const u32& v);
|
void HashLong(const u32& v);
|
||||||
void HashFloat(const float& v);
|
void HashFloat(const float& v);
|
||||||
void HashString(const std::string& v);
|
void HashString(const TString& v);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CHASHFNV1A_H
|
#endif // CHASHFNV1A_H
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "CUniqueID.h"
|
#include "CUniqueID.h"
|
||||||
#include <Common/StringUtil.h>
|
#include <Common/TString.h>
|
||||||
|
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <random>
|
#include <random>
|
||||||
|
@ -81,26 +81,28 @@ u64 CUniqueID::ToLongLong() const
|
||||||
return *((u64*) &mID[8]);
|
return *((u64*) &mID[8]);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CUniqueID::ToString() const
|
TString CUniqueID::ToString() const
|
||||||
{
|
{
|
||||||
std::stringstream Ret;
|
|
||||||
Ret << std::hex << std::setfill('0');
|
|
||||||
|
|
||||||
switch (mLength)
|
switch (mLength)
|
||||||
{
|
{
|
||||||
case e32Bit:
|
case e32Bit:
|
||||||
Ret << std::setw(8) << ToLong();
|
return TString::FromInt32(ToLong(), 8);
|
||||||
break;
|
|
||||||
case e64Bit:
|
case e64Bit:
|
||||||
Ret << std::setw(16) << ToLongLong();
|
return TString::FromInt64(ToLongLong(), 16);
|
||||||
break;
|
|
||||||
case e128Bit:
|
case e128Bit:
|
||||||
|
// todo: TString should have a "FromInt128" function
|
||||||
|
std::stringstream Ret;
|
||||||
|
Ret << std::hex << std::setfill('0');
|
||||||
|
|
||||||
for (u32 i = 0; i < 16; i++)
|
for (u32 i = 0; i < 16; i++)
|
||||||
Ret << std::setw(2) << (u32) mID[i];
|
Ret << std::setw(2) << (u32) mID[i];
|
||||||
break;
|
|
||||||
|
return Ret.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
return Ret.str();
|
return "INVALID ID LENGTH";
|
||||||
}
|
}
|
||||||
|
|
||||||
void CUniqueID::Reverse()
|
void CUniqueID::Reverse()
|
||||||
|
@ -223,21 +225,20 @@ bool CUniqueID::operator!=(u64 Other) const
|
||||||
}
|
}
|
||||||
|
|
||||||
// ************ STATIC ************
|
// ************ STATIC ************
|
||||||
CUniqueID CUniqueID::FromString(std::string String)
|
CUniqueID CUniqueID::FromString(const TString& String)
|
||||||
{
|
{
|
||||||
// If the input is a hex ID in string form, then preserve it... otherwise, generate an ID by hashing the string
|
// If the input is a hex ID in string form, then preserve it... otherwise, generate an ID by hashing the string
|
||||||
std::string Name = StringUtil::GetFileName(String);
|
TString Name = String.GetFileName(false);
|
||||||
if (Name.back() == '\0') Name.pop_back();
|
u32 NameLength = Name.Length();
|
||||||
u32 NameLength = Name.length();
|
|
||||||
|
|
||||||
if (StringUtil::IsHexString(Name))
|
if (Name.IsHexString())
|
||||||
{
|
{
|
||||||
if (NameLength == 8)
|
if (NameLength == 8)
|
||||||
{
|
{
|
||||||
CUniqueID ID;
|
CUniqueID ID;
|
||||||
ID.mLength = e32Bit;
|
ID.mLength = e32Bit;
|
||||||
|
|
||||||
u32 LongID = StringUtil::ToInt32(Name);
|
u32 LongID = Name.ToInt32();
|
||||||
|
|
||||||
if (SystemEndianness == LittleEndian)
|
if (SystemEndianness == LittleEndian)
|
||||||
memcpy(ID.mID, &LongID, 4);
|
memcpy(ID.mID, &LongID, 4);
|
||||||
|
@ -252,7 +253,7 @@ CUniqueID CUniqueID::FromString(std::string String)
|
||||||
CUniqueID ID;
|
CUniqueID ID;
|
||||||
ID.mLength = e64Bit;
|
ID.mLength = e64Bit;
|
||||||
|
|
||||||
u64 LongID = StringUtil::ToInt64(Name);
|
u64 LongID = Name.ToInt64();
|
||||||
|
|
||||||
if (SystemEndianness == LittleEndian)
|
if (SystemEndianness == LittleEndian)
|
||||||
memcpy(ID.mID, &LongID, 8);
|
memcpy(ID.mID, &LongID, 8);
|
||||||
|
@ -266,12 +267,12 @@ CUniqueID CUniqueID::FromString(std::string String)
|
||||||
{
|
{
|
||||||
CUniqueID ID;
|
CUniqueID ID;
|
||||||
ID.mLength = e128Bit;
|
ID.mLength = e128Bit;
|
||||||
StringUtil::ToInt128(Name, (char*) ID.mID);
|
Name.ToInt128((char*) ID.mID);
|
||||||
return ID;
|
return ID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return CUniqueID( (u64) StringUtil::Hash64(String) );
|
return CUniqueID(String.Hash64());
|
||||||
}
|
}
|
||||||
|
|
||||||
CUniqueID CUniqueID::FromData(void *pData, EUIDLength Length)
|
CUniqueID CUniqueID::FromData(void *pData, EUIDLength Length)
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define CUNIQUEID_H
|
#define CUNIQUEID_H
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
#include "TString.h"
|
||||||
#include <FileIO/FileIO.h>
|
#include <FileIO/FileIO.h>
|
||||||
|
|
||||||
enum EUIDLength
|
enum EUIDLength
|
||||||
|
@ -25,7 +26,7 @@ public:
|
||||||
CUniqueID(CInputStream& Input, EUIDLength Length);
|
CUniqueID(CInputStream& Input, EUIDLength Length);
|
||||||
u32 ToLong() const;
|
u32 ToLong() const;
|
||||||
u64 ToLongLong() const;
|
u64 ToLongLong() const;
|
||||||
std::string ToString() const;
|
TString ToString() const;
|
||||||
void Reverse();
|
void Reverse();
|
||||||
EUIDLength Length() const;
|
EUIDLength Length() const;
|
||||||
void SetLength(EUIDLength Length);
|
void SetLength(EUIDLength Length);
|
||||||
|
@ -44,7 +45,7 @@ public:
|
||||||
bool operator!=(u64 Other) const;
|
bool operator!=(u64 Other) const;
|
||||||
|
|
||||||
// Static
|
// Static
|
||||||
static CUniqueID FromString(std::string String);
|
static CUniqueID FromString(const TString& String);
|
||||||
static CUniqueID FromData(void *pData, EUIDLength Length);
|
static CUniqueID FromData(void *pData, EUIDLength Length);
|
||||||
static CUniqueID RandomID();
|
static CUniqueID RandomID();
|
||||||
|
|
||||||
|
|
|
@ -1,312 +0,0 @@
|
||||||
#include <string>
|
|
||||||
#include <sstream>
|
|
||||||
#include <iomanip>
|
|
||||||
#include <vector>
|
|
||||||
#include "StringUtil.h"
|
|
||||||
|
|
||||||
#include <FileIO/IOUtil.h> // For SwapBytes
|
|
||||||
|
|
||||||
namespace StringUtil
|
|
||||||
{
|
|
||||||
std::string GetFileDirectory(std::string path)
|
|
||||||
{
|
|
||||||
size_t endpath = path.find_last_of("\\/");
|
|
||||||
return path.substr(0, endpath + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string GetFileName(std::string path)
|
|
||||||
{
|
|
||||||
size_t endpath = path.find_last_of("\\/") + 1;
|
|
||||||
size_t endname = path.find_last_of(".");
|
|
||||||
return path.substr(endpath, endname - endpath);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string GetFileNameWithExtension(std::string path)
|
|
||||||
{
|
|
||||||
size_t endpath = path.find_last_of("\\/");
|
|
||||||
return path.substr(endpath + 1, path.size() - endpath);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string GetPathWithoutExtension(std::string path)
|
|
||||||
{
|
|
||||||
size_t endname = path.find_last_of(".");
|
|
||||||
return path.substr(0, endname);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string GetExtension(std::string path)
|
|
||||||
{
|
|
||||||
size_t endname = path.find_last_of(".");
|
|
||||||
return path.substr(endname + 1, path.size() - endname);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string ToUpper(std::string str)
|
|
||||||
{
|
|
||||||
for (unsigned int i = 0; i < str.length(); i++)
|
|
||||||
{
|
|
||||||
if ((str[i] >= 0x61) && (str[i] <= 0x7A))
|
|
||||||
str[i] -= 0x20;
|
|
||||||
}
|
|
||||||
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string ToLower(std::string str)
|
|
||||||
{
|
|
||||||
for (unsigned int i = 0; i < str.length(); i++)
|
|
||||||
{
|
|
||||||
if ((str[i] >= 0x41) && (str[i] <= 0x5A))
|
|
||||||
str[i] += 0x20;
|
|
||||||
}
|
|
||||||
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string ToHexString(unsigned char num, bool addPrefix, bool uppercase, int width)
|
|
||||||
{
|
|
||||||
return ToHexString((unsigned long) num, addPrefix, uppercase, width);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string ToHexString(unsigned short num, bool addPrefix, bool uppercase, int width)
|
|
||||||
{
|
|
||||||
return ToHexString((unsigned long) num, addPrefix, uppercase, width);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string ToHexString(unsigned long num, bool addPrefix, bool uppercase, int width)
|
|
||||||
{
|
|
||||||
std::stringstream stream;
|
|
||||||
stream << std::hex << std::setw(width) << std::setfill('0') << num;
|
|
||||||
|
|
||||||
std::string str = stream.str();
|
|
||||||
if (uppercase) str = ToUpper(str);
|
|
||||||
if (addPrefix) str = std::string("0x") + str;
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
long Hash32(std::string str)
|
|
||||||
{
|
|
||||||
unsigned long hash = 0;
|
|
||||||
|
|
||||||
for (unsigned int c = 0; c < str.size(); c++) {
|
|
||||||
hash += str[c];
|
|
||||||
hash *= 101;
|
|
||||||
}
|
|
||||||
|
|
||||||
return hash;
|
|
||||||
}
|
|
||||||
|
|
||||||
long long Hash64(std::string str)
|
|
||||||
{
|
|
||||||
unsigned long long hash = 0;
|
|
||||||
|
|
||||||
for (unsigned int c = 0; c < str.size(); c++) {
|
|
||||||
hash += str[c];
|
|
||||||
hash *= 101;
|
|
||||||
}
|
|
||||||
|
|
||||||
return hash;
|
|
||||||
}
|
|
||||||
|
|
||||||
long ToInt32(std::string str) {
|
|
||||||
return std::stoul(str, nullptr, 16);
|
|
||||||
}
|
|
||||||
|
|
||||||
long long ToInt64(std::string str) {
|
|
||||||
return std::stoull(str, nullptr, 16);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ToInt128(std::string str, char *out) {
|
|
||||||
long long Part1 = std::stoull(str.substr(0, 16), nullptr, 16);
|
|
||||||
long long Part2 = std::stoull(str.substr(16, 16), nullptr, 16);
|
|
||||||
|
|
||||||
if (IOUtil::SystemEndianness == IOUtil::LittleEndian)
|
|
||||||
{
|
|
||||||
IOUtil::SwapBytes(Part1);
|
|
||||||
IOUtil::SwapBytes(Part2);
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy(out, &Part1, 8);
|
|
||||||
memcpy(out + 8, &Part2, 8);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string ToString(unsigned long v)
|
|
||||||
{
|
|
||||||
std::stringstream sstream;
|
|
||||||
sstream << std::hex << std::setw(8) << std::setfill('0') << v << std::dec;
|
|
||||||
return sstream.str();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string ToString(unsigned long long v)
|
|
||||||
{
|
|
||||||
std::stringstream sstream;
|
|
||||||
sstream << std::hex << std::setw(16) << std::setfill('0') << v << std::dec;
|
|
||||||
return sstream.str();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IsHexString(std::string str, bool requirePrefix, long width)
|
|
||||||
{
|
|
||||||
str = GetFileName(str);
|
|
||||||
|
|
||||||
if (requirePrefix && (str.substr(0, 2) != "0x"))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if ((width == -1) && (str.substr(0, 2) == "0x"))
|
|
||||||
str = str.substr(2, str.size() - 2);
|
|
||||||
|
|
||||||
if (width == -1)
|
|
||||||
width = str.size();
|
|
||||||
|
|
||||||
if ((str.size() == width + 2) && (str.substr(0, 2) == "0x"))
|
|
||||||
str = str.substr(2, width);
|
|
||||||
|
|
||||||
if (str.size() != width) return false;
|
|
||||||
|
|
||||||
for (int c = 0; c < width; c++)
|
|
||||||
{
|
|
||||||
char chr = str[c];
|
|
||||||
if (!((chr >= '0') && (chr <= '9')) &&
|
|
||||||
!((chr >= 'a') && (chr <= 'f')) &&
|
|
||||||
!((chr >= 'A') && (chr <= 'F')))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string AppendSlash(std::string str)
|
|
||||||
{
|
|
||||||
char a = str.back();
|
|
||||||
char b = str[str.length() - 1];
|
|
||||||
|
|
||||||
if (a == 0)
|
|
||||||
{
|
|
||||||
if ((b != '/') && (b != '\\'))
|
|
||||||
{
|
|
||||||
str.back() = '/';
|
|
||||||
str.push_back(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
else if ((a != '/') && (b != '\\'))
|
|
||||||
str.push_back('/');
|
|
||||||
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::wstring UTF8to16(std::string str)
|
|
||||||
{
|
|
||||||
const char *cstr = str.c_str();
|
|
||||||
std::vector<int> CodePoints;
|
|
||||||
|
|
||||||
// Step 1: decode UTF-8 code points
|
|
||||||
while (cstr[0])
|
|
||||||
{
|
|
||||||
int CodePoint;
|
|
||||||
|
|
||||||
// One byte
|
|
||||||
if ((cstr[0] & 0x80) == 0)
|
|
||||||
{
|
|
||||||
CodePoint = cstr[0] & 0x7FFFFFFF;
|
|
||||||
cstr++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Two bytes
|
|
||||||
else if ((cstr[0] & 0xE0) == 0xC0)
|
|
||||||
{
|
|
||||||
CodePoint = (((cstr[0] & 0x1F) << 6) |
|
|
||||||
(cstr[1] & 0x3F));
|
|
||||||
cstr += 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Three bytes
|
|
||||||
else if ((cstr[0] & 0xF0) == 0xE0)
|
|
||||||
{
|
|
||||||
CodePoint = (((cstr[0] & 0xF) << 12) |
|
|
||||||
((cstr[1] & 0x3F) << 6) |
|
|
||||||
(cstr[2] & 0x3F));
|
|
||||||
cstr += 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Four bytes
|
|
||||||
else if ((cstr[0] & 0xF8) == 0xF0)
|
|
||||||
{
|
|
||||||
CodePoint = (((cstr[0] & 0x7) << 18) |
|
|
||||||
((cstr[1] & 0x3F) << 12) |
|
|
||||||
((cstr[2] & 0x3F) << 6) |
|
|
||||||
(cstr[3] & 0x3F));
|
|
||||||
cstr += 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Five bytes
|
|
||||||
else if ((cstr[0] & 0xFC) == 0xF8)
|
|
||||||
{
|
|
||||||
CodePoint = (((cstr[0] & 0x3) << 24) |
|
|
||||||
((cstr[1] & 0x3F) << 18) |
|
|
||||||
((cstr[2] & 0x3F) << 12) |
|
|
||||||
((cstr[3] & 0x3F) << 6) |
|
|
||||||
(cstr[4] & 0x3F));
|
|
||||||
cstr += 5;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Six bytes
|
|
||||||
else if ((cstr[0] & 0xFE) == 0xFC)
|
|
||||||
{
|
|
||||||
CodePoint = (((cstr[0] & 0x1) << 30) |
|
|
||||||
((cstr[1] & 0x3F) << 24) |
|
|
||||||
((cstr[2] & 0x3F) << 18) |
|
|
||||||
((cstr[3] & 0x3F) << 12) |
|
|
||||||
((cstr[4] & 0x3F) << 6) |
|
|
||||||
(cstr[5] & 0x3F));
|
|
||||||
cstr += 6;
|
|
||||||
}
|
|
||||||
|
|
||||||
CodePoints.push_back(CodePoint);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Step 2: encode as UTF-16
|
|
||||||
std::wstring out;
|
|
||||||
out.reserve(CodePoints.size());
|
|
||||||
|
|
||||||
for (int c = 0; c < CodePoints.size(); c++)
|
|
||||||
{
|
|
||||||
// todo: support all code points
|
|
||||||
if (((CodePoints[c] >= 0) && (CodePoints[c] <= 0xD7FF)) ||
|
|
||||||
((CodePoints[c] >= 0xE000) && (CodePoints[c] <= 0xFFFF)))
|
|
||||||
{
|
|
||||||
out.push_back(CodePoints[c] & 0xFFFF);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
CStringList Tokenize(const std::string& str, const char *pTokens)
|
|
||||||
{
|
|
||||||
CStringList out;
|
|
||||||
int lastSplit = 0;
|
|
||||||
|
|
||||||
// Iterate over all characters in the input string
|
|
||||||
for (int iChr = 0; iChr < str.length(); iChr++)
|
|
||||||
{
|
|
||||||
// Check whether this character is one of the user-provided tokens
|
|
||||||
for (int iTok = 0; true; iTok++)
|
|
||||||
{
|
|
||||||
if (!pTokens[iTok]) break;
|
|
||||||
|
|
||||||
if (str[iChr] == pTokens[iTok])
|
|
||||||
{
|
|
||||||
// Token found - split string
|
|
||||||
if (iChr > lastSplit)
|
|
||||||
out.push_back(str.substr(lastSplit, iChr - lastSplit));
|
|
||||||
|
|
||||||
lastSplit = iChr + 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add final string
|
|
||||||
if (lastSplit != str.length())
|
|
||||||
out.push_back(str.substr(lastSplit, str.length() - lastSplit));
|
|
||||||
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,34 +0,0 @@
|
||||||
#ifndef STRINGUTIL_H
|
|
||||||
#define STRINGUTIL_H
|
|
||||||
|
|
||||||
#include <list>
|
|
||||||
#include <string>
|
|
||||||
typedef std::list<std::string> CStringList;
|
|
||||||
|
|
||||||
namespace StringUtil
|
|
||||||
{
|
|
||||||
std::string GetFileDirectory(std::string path);
|
|
||||||
std::string GetFileName(std::string path);
|
|
||||||
std::string GetFileNameWithExtension(std::string path);
|
|
||||||
std::string GetPathWithoutExtension(std::string path);
|
|
||||||
std::string GetExtension(std::string path);
|
|
||||||
std::string ToUpper(std::string str);
|
|
||||||
std::string ToLower(std::string str);
|
|
||||||
std::string ToHexString(unsigned char num, bool addPrefix = true, bool uppercase = false, int width = 0);
|
|
||||||
std::string ToHexString(unsigned short num, bool addPrefix = true, bool uppercase = false, int width = 0);
|
|
||||||
std::string ToHexString(unsigned long num, bool addPrefix = true, bool uppercase = false, int width = 0);
|
|
||||||
long Hash32(std::string str);
|
|
||||||
long long Hash64(std::string str);
|
|
||||||
long ToInt32(std::string str);
|
|
||||||
long long ToInt64(std::string str);
|
|
||||||
void ToInt128(std::string str, char *out);
|
|
||||||
std::string ToString(unsigned long ID);
|
|
||||||
std::string ToString(unsigned long long ID);
|
|
||||||
bool IsHexString(std::string str, bool requirePrefix = false, long width = -1);
|
|
||||||
std::string AppendSlash(std::string str);
|
|
||||||
CStringList Tokenize(const std::string& str, const char *pTokens);
|
|
||||||
|
|
||||||
std::wstring UTF8to16(std::string str);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // STRINGUTIL_H
|
|
|
@ -7,6 +7,11 @@ TString::TString(const wchar_t* pkText)
|
||||||
*this = TWideString(pkText).ToUTF8();
|
*this = TWideString(pkText).ToUTF8();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TString::TString(const std::wstring& rkText)
|
||||||
|
{
|
||||||
|
*this = TWideString(rkText).ToUTF8();
|
||||||
|
}
|
||||||
|
|
||||||
TString::TString(const TWideString& rkText)
|
TString::TString(const TWideString& rkText)
|
||||||
{
|
{
|
||||||
*this = rkText.ToUTF8();
|
*this = rkText.ToUTF8();
|
||||||
|
@ -94,6 +99,11 @@ TWideString::TWideString(const char* pkText)
|
||||||
*this = TString(pkText).ToUTF16();
|
*this = TString(pkText).ToUTF16();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TWideString::TWideString(const std::string& rkText)
|
||||||
|
{
|
||||||
|
*this = TString(rkText).ToUTF16();
|
||||||
|
}
|
||||||
|
|
||||||
TWideString::TWideString(const TString& rkText)
|
TWideString::TWideString(const TString& rkText)
|
||||||
{
|
{
|
||||||
*this = rkText.ToUTF16();
|
*this = rkText.ToUTF16();
|
||||||
|
|
249
Common/TString.h
249
Common/TString.h
|
@ -34,10 +34,11 @@ template<class CharType>
|
||||||
class TBasicString
|
class TBasicString
|
||||||
{
|
{
|
||||||
typedef TBasicString<CharType> _TString;
|
typedef TBasicString<CharType> _TString;
|
||||||
|
typedef std::basic_string<CharType> _TStdString;
|
||||||
typedef std::list<_TString> _TStringList;
|
typedef std::list<_TString> _TStringList;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::basic_string<CharType> mInternalString;
|
_TStdString mInternalString;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructors
|
// Constructors
|
||||||
|
@ -61,17 +62,32 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
TBasicString(const std::basic_string<CharType>& rkText)
|
TBasicString(const CharType* pkText, u32 length)
|
||||||
|
: mInternalString(pkText, length)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
TBasicString(const _TStdString& rkText)
|
||||||
: mInternalString(rkText)
|
: mInternalString(rkText)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Forward declares of some static functions that are handy for internal use
|
||||||
|
//static bool CompareCStrings(const CharType*, const CharType*);
|
||||||
|
//static u32 CStringLength(const CharType*);
|
||||||
|
//static bool IsWhitespace(CharType);
|
||||||
|
|
||||||
// Data Accessors
|
// Data Accessors
|
||||||
inline const CharType* CString() const
|
inline const CharType* CString() const
|
||||||
{
|
{
|
||||||
return mInternalString.c_str();
|
return mInternalString.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline const CharType* Data() const
|
||||||
|
{
|
||||||
|
return mInternalString.data();
|
||||||
|
}
|
||||||
|
|
||||||
inline CharType At(u32 pos) const
|
inline CharType At(u32 pos) const
|
||||||
{
|
{
|
||||||
#if _DEBUG
|
#if _DEBUG
|
||||||
|
@ -103,12 +119,22 @@ public:
|
||||||
|
|
||||||
inline u32 IndexOf(const CharType* pkCharacters) const
|
inline u32 IndexOf(const CharType* pkCharacters) const
|
||||||
{
|
{
|
||||||
return (u32) mInternalString.find_first_of(pkCharacters);
|
size_t pos = mInternalString.find_first_of(pkCharacters);
|
||||||
|
|
||||||
|
if (pos == _TStdString::npos)
|
||||||
|
return -1;
|
||||||
|
else
|
||||||
|
return (u32) pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline u32 LastIndexOf(const CharType* pkCharacters) const
|
inline u32 LastIndexOf(const CharType* pkCharacters) const
|
||||||
{
|
{
|
||||||
return (u32) mInternalString.find_last_of(pkCharacters);
|
size_t pos = mInternalString.find_last_of(pkCharacters);
|
||||||
|
|
||||||
|
if (pos == _TStdString::npos)
|
||||||
|
return -1;
|
||||||
|
else
|
||||||
|
return (u32) pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Modify String
|
// Modify String
|
||||||
|
@ -206,7 +232,6 @@ public:
|
||||||
|
|
||||||
_TString Trimmed() const
|
_TString Trimmed() const
|
||||||
{
|
{
|
||||||
static bool _TString::IsWhitespace(CharType);
|
|
||||||
int start, end;
|
int start, end;
|
||||||
|
|
||||||
for (u32 iChar = 0; iChar < Size(); iChar++)
|
for (u32 iChar = 0; iChar < Size(); iChar++)
|
||||||
|
@ -271,12 +296,12 @@ public:
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline u32 ToInt32(int base = 10) const
|
inline u32 ToInt32(int base = 16) const
|
||||||
{
|
{
|
||||||
return std::stoul(mInternalString, nullptr, base);
|
return std::stoul(mInternalString, nullptr, base);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline u64 ToInt64(int base = 10) const
|
inline u64 ToInt64(int base = 16) const
|
||||||
{
|
{
|
||||||
return std::stoull(mInternalString, nullptr, base);
|
return std::stoull(mInternalString, nullptr, base);
|
||||||
}
|
}
|
||||||
|
@ -297,6 +322,11 @@ public:
|
||||||
memcpy(pOut + 8, &part2, 8);
|
memcpy(pOut + 8, &part2, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline _TStdString ToStdString() const
|
||||||
|
{
|
||||||
|
return mInternalString;
|
||||||
|
}
|
||||||
|
|
||||||
_TStringList Split(const CharType* pkTokens) const
|
_TStringList Split(const CharType* pkTokens) const
|
||||||
{
|
{
|
||||||
_TStringList out;
|
_TStringList out;
|
||||||
|
@ -342,6 +372,11 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check String
|
// Check String
|
||||||
|
bool IsEmpty() const
|
||||||
|
{
|
||||||
|
return (Size() == 0);
|
||||||
|
}
|
||||||
|
|
||||||
bool StartsWith(const _TString& str) const
|
bool StartsWith(const _TString& str) const
|
||||||
{
|
{
|
||||||
if (Size() < str.Size())
|
if (Size() < str.Size())
|
||||||
|
@ -484,9 +519,24 @@ public:
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline CharType& operator[](int pos)
|
||||||
|
{
|
||||||
|
return mInternalString[pos];
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const CharType& operator[](int pos) const
|
||||||
|
{
|
||||||
|
return mInternalString[pos];
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const CharType* operator*() const
|
||||||
|
{
|
||||||
|
return CString();
|
||||||
|
}
|
||||||
|
|
||||||
_TString operator+(const CharType* pkOther) const
|
_TString operator+(const CharType* pkOther) const
|
||||||
{
|
{
|
||||||
size_t len = strlen(pkOther);
|
u32 len = CStringLength(pkOther);
|
||||||
|
|
||||||
_TString out(len + Size());
|
_TString out(len + Size());
|
||||||
memcpy(&out[0], mInternalString.data(), Size() * sizeof(CharType));
|
memcpy(&out[0], mInternalString.data(), Size() * sizeof(CharType));
|
||||||
|
@ -511,7 +561,7 @@ public:
|
||||||
|
|
||||||
inline friend _TString operator+(const CharType* pkLeft, const _TString& rkRight)
|
inline friend _TString operator+(const CharType* pkLeft, const _TString& rkRight)
|
||||||
{
|
{
|
||||||
size_t len = strlen(pkLeft);
|
u32 len = CStringLength(pkLeft);
|
||||||
|
|
||||||
_TString out(len + rkRight.Size());
|
_TString out(len + rkRight.Size());
|
||||||
memcpy(&out[0], pkLeft, len * sizeof(CharType));
|
memcpy(&out[0], pkLeft, len * sizeof(CharType));
|
||||||
|
@ -519,19 +569,32 @@ public:
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline CharType& operator[](int pos)
|
inline friend _TString operator+(const _TStdString& rkLeft, const _TString& rkRight)
|
||||||
{
|
{
|
||||||
return mInternalString[pos];
|
_TString out(rkLeft.size() + rkRight.Size());
|
||||||
}
|
memcpy(&out[0], rkLeft.data(), rkLeft.size() * sizeof(CharType));
|
||||||
|
memcpy(&out[rkLeft.size()], rkRight.Data(), rkRight.Size() * sizeof(CharType));
|
||||||
inline const CharType& operator[](int pos) const
|
return out;
|
||||||
{
|
|
||||||
return mInternalString[pos];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool operator==(const CharType *pkText) const
|
inline bool operator==(const CharType *pkText) const
|
||||||
{
|
{
|
||||||
return strcmp(pkText, mInternalString.data()) == 0;
|
return CompareCStrings(pkText, CString());
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool operator==(const _TString& rkOther) const
|
||||||
|
{
|
||||||
|
return (mInternalString == rkOther.mInternalString);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline friend bool operator==(const CharType *pkText, const _TString& rkString)
|
||||||
|
{
|
||||||
|
return (rkString == pkText);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline friend bool operator==(const _TStdString& rkStringA, const _TString& rkStringB)
|
||||||
|
{
|
||||||
|
return (rkStringB == rkStringA);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool operator!=(const CharType *pkText) const
|
inline bool operator!=(const CharType *pkText) const
|
||||||
|
@ -539,50 +602,125 @@ public:
|
||||||
return (!(*this == pkText));
|
return (!(*this == pkText));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool operator==(const _TString& rkOther) const
|
|
||||||
{
|
|
||||||
return (strcmp(mInternalString.data(), rkOther.mInternalString.data()) == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool operator!=(const _TString& rkOther) const
|
inline bool operator!=(const _TString& rkOther) const
|
||||||
{
|
{
|
||||||
return (!(*this == rkOther));
|
return (!(*this == rkOther));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline friend bool operator==(const CharType *pText, const _TString& rkString)
|
inline friend bool operator!=(const CharType *pkText, const _TString& rkString)
|
||||||
{
|
{
|
||||||
return (rkString == pText);
|
return (rkString != pkText);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline friend bool operator!=(const CharType *pText, const _TString& rkString)
|
inline friend bool operator!=(const _TStdString& rkStringA, const _TString& rkStringB)
|
||||||
{
|
{
|
||||||
return (rkString != pText);
|
return (rkStringB != rkStringA);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline friend std::ostream& operator<<(std::ostream& rLeft, const _TString& rkRight)
|
inline bool operator<(const CharType* pkText) const
|
||||||
{
|
{
|
||||||
rLeft << rkRight.mInternalString;
|
return (mInternalString < pkText);
|
||||||
return rLeft;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline friend std::istream& operator>>(std::istream& rLeft, const _TString& rkRight)
|
inline bool operator<(const _TString& rkOther) const
|
||||||
{
|
{
|
||||||
rLeft >> rkRight.mInternalString;
|
return (mInternalString < rkOther.mInternalString);
|
||||||
return rLeft;
|
}
|
||||||
|
|
||||||
|
inline friend bool operator<(const CharType* pkText, const _TString& rkString)
|
||||||
|
{
|
||||||
|
return (rkString > pkText);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline friend bool operator<(const _TStdString& rkStringA, const _TString& rkStringB)
|
||||||
|
{
|
||||||
|
return (rkStringB > rkStringA);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool operator<=(const CharType* pkText) const
|
||||||
|
{
|
||||||
|
return (mInternalString <= pkText);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool operator<=(const _TString& rkOther) const
|
||||||
|
{
|
||||||
|
return (mInternalString <= rkOther.mInternalString);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline friend bool operator<=(const CharType* pkText, const _TString& rkString)
|
||||||
|
{
|
||||||
|
return (rkString >= pkText);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline friend bool operator<=(const _TStdString& rkStringA, const _TString& rkStringB)
|
||||||
|
{
|
||||||
|
return (rkStringB >= rkStringA);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool operator>(const CharType* pkText) const
|
||||||
|
{
|
||||||
|
return (mInternalString > pkText);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool operator>(const _TString& rkOther) const
|
||||||
|
{
|
||||||
|
return (mInternalString > rkOther.mInternalString);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline friend bool operator>(const CharType* pkText, const _TString& rkString)
|
||||||
|
{
|
||||||
|
return (rkString < pkText);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline friend bool operator>(const _TStdString& rkStringA, const _TString& rkStringB)
|
||||||
|
{
|
||||||
|
return (rkStringB < rkStringA);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool operator>=(const CharType* pkText) const
|
||||||
|
{
|
||||||
|
return (mInternalString >= pkText);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool operator>=(const _TString& rkOther) const
|
||||||
|
{
|
||||||
|
return (mInternalString >= rkOther.mInternalString);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline friend bool operator>=(const CharType* pkText, const _TString& rkString)
|
||||||
|
{
|
||||||
|
return (rkString <= pkText);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline friend bool operator>=(const _TStdString& rkStringA, const _TString& rkStringB)
|
||||||
|
{
|
||||||
|
return (rkStringB <= rkStringA);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline friend std::ostream& operator<<(std::ostream& rStream, const _TString& rkString)
|
||||||
|
{
|
||||||
|
rStream << rkString.mInternalString;
|
||||||
|
return rStream;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline friend std::istream& operator>>(std::istream& rStream, const _TString& rkString)
|
||||||
|
{
|
||||||
|
rStream >> rkString.mInternalString;
|
||||||
|
return rStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Static
|
// Static
|
||||||
static TBasicString<CharType> FromInt32(u32 value, int base = 10)
|
static TBasicString<CharType> FromInt32(u32 value, int width = 0, int base = 16)
|
||||||
{
|
{
|
||||||
std::basic_stringstream<CharType> sstream;
|
std::basic_stringstream<CharType> sstream;
|
||||||
sstream << std::setbase(base) << value;
|
sstream << std::setbase(base) << std::setw(width) << std::setfill('0') << value;
|
||||||
return sstream.str();
|
return sstream.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
static TBasicString<CharType> FromInt64(u64 value, int base = 10)
|
static TBasicString<CharType> FromInt64(u64 value, int width = 0, int base = 16)
|
||||||
{
|
{
|
||||||
std::basic_stringstream<CharType> sstream;
|
std::basic_stringstream<CharType> sstream;
|
||||||
sstream << std::setbase(base) << value;
|
sstream << std::setbase(base) << std::setw(width) << std::setfill('0') << value;
|
||||||
return sstream.str();
|
return sstream.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -607,6 +745,31 @@ public:
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool CompareCStrings(const CharType* pkA, const CharType* pkB)
|
||||||
|
{
|
||||||
|
// Replacement for strcmp so we can compare any CharType
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
if (*pkA != *pkB) return false;
|
||||||
|
if ((*pkA == 0) || (*pkB == 0)) return true;
|
||||||
|
pkA++;
|
||||||
|
pkB++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static u32 CStringLength(const CharType* pkStr)
|
||||||
|
{
|
||||||
|
// Replacement for strlen so we can measure any CharType
|
||||||
|
u32 out = 0;
|
||||||
|
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
if (*pkStr == 0) return out;
|
||||||
|
out++;
|
||||||
|
pkStr++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static bool IsWhitespace(CharType c)
|
static bool IsWhitespace(CharType c)
|
||||||
{
|
{
|
||||||
return ( (c == '\t') ||
|
return ( (c == '\t') ||
|
||||||
|
@ -626,16 +789,13 @@ public:
|
||||||
TString(size_t size) : TBasicString<char>(size) {}
|
TString(size_t size) : TBasicString<char>(size) {}
|
||||||
TString(size_t size, char fill) : TBasicString<char>(size, fill) {}
|
TString(size_t size, char fill) : TBasicString<char>(size, fill) {}
|
||||||
TString(const char* pkText) : TBasicString<char>(pkText) {}
|
TString(const char* pkText) : TBasicString<char>(pkText) {}
|
||||||
|
TString(const char* pkText, u32 length) : TBasicString<char>(pkText, length) {}
|
||||||
TString(const std::string& rkText) : TBasicString<char>(rkText) {}
|
TString(const std::string& rkText) : TBasicString<char>(rkText) {}
|
||||||
TString(const TBasicString<char>& rkStr) : TBasicString<char>(rkStr) {}
|
TString(const TBasicString<char>& rkStr) : TBasicString<char>(rkStr) {}
|
||||||
TString(const wchar_t* pkText);
|
TString(const wchar_t* pkText);
|
||||||
|
TString(const std::wstring& rkText);
|
||||||
TString(const class TWideString& rkText);
|
TString(const class TWideString& rkText);
|
||||||
|
|
||||||
inline std::string ToStdString()
|
|
||||||
{
|
|
||||||
return mInternalString;
|
|
||||||
}
|
|
||||||
|
|
||||||
class TWideString ToUTF16() const;
|
class TWideString ToUTF16() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -647,16 +807,13 @@ public:
|
||||||
TWideString(u32 size) : TBasicString<wchar_t>(size) {}
|
TWideString(u32 size) : TBasicString<wchar_t>(size) {}
|
||||||
TWideString(u32 size, wchar_t fill) : TBasicString<wchar_t>(size, fill) {}
|
TWideString(u32 size, wchar_t fill) : TBasicString<wchar_t>(size, fill) {}
|
||||||
TWideString(const wchar_t* pkText) : TBasicString<wchar_t>(pkText) {}
|
TWideString(const wchar_t* pkText) : TBasicString<wchar_t>(pkText) {}
|
||||||
|
TWideString(const wchar_t* pkText, u32 length) : TBasicString<wchar_t>(pkText, length) {}
|
||||||
TWideString(const std::wstring& rkText) : TBasicString<wchar_t>(rkText) {}
|
TWideString(const std::wstring& rkText) : TBasicString<wchar_t>(rkText) {}
|
||||||
TWideString(const TBasicString<wchar_t>& rkStr) : TBasicString<wchar_t>(rkStr) {}
|
TWideString(const TBasicString<wchar_t>& rkStr) : TBasicString<wchar_t>(rkStr) {}
|
||||||
TWideString(const char* pkText);
|
TWideString(const char* pkText);
|
||||||
|
TWideString(const std::string& rkText);
|
||||||
TWideString(const TString& rkText);
|
TWideString(const TString& rkText);
|
||||||
|
|
||||||
inline std::wstring ToStdWString()
|
|
||||||
{
|
|
||||||
return mInternalString;
|
|
||||||
}
|
|
||||||
|
|
||||||
class TString ToUTF8() const;
|
class TString ToUTF8() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "CResCache.h"
|
#include "CResCache.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
#include <Common/StringUtil.h>
|
#include <Common/TString.h>
|
||||||
#include <FileIO/FileIO.h>
|
#include <FileIO/FileIO.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -54,17 +54,17 @@ void CResCache::Clean()
|
||||||
Log::Write(std::to_string(mResourceCache.size()) + " resources loaded");
|
Log::Write(std::to_string(mResourceCache.size()) + " resources loaded");
|
||||||
}
|
}
|
||||||
|
|
||||||
void CResCache::SetFolder(std::string path)
|
void CResCache::SetFolder(TString path)
|
||||||
{
|
{
|
||||||
StringUtil::AppendSlash(path);
|
path.EnsureEndsWith("/");
|
||||||
mResSource.Path = path;
|
mResSource.Path = path;
|
||||||
mResSource.Source = SResSource::Folder;
|
mResSource.Source = SResSource::Folder;
|
||||||
Log::Write("Set resource folder: " + path);
|
Log::Write("Set resource folder: " + path);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CResCache::SetPak(std::string path)
|
void CResCache::SetPak(const TString& path)
|
||||||
{
|
{
|
||||||
CFileInStream *pakfile = new CFileInStream(path, IOUtil::BigEndian);
|
CFileInStream *pakfile = new CFileInStream(path.ToStdString(), IOUtil::BigEndian);
|
||||||
if (!pakfile->IsValid())
|
if (!pakfile->IsValid())
|
||||||
{
|
{
|
||||||
Log::Error("Couldn't load pak file: " + path);
|
Log::Error("Couldn't load pak file: " + path);
|
||||||
|
@ -89,7 +89,7 @@ SResSource CResCache::GetResSource()
|
||||||
return mResSource;
|
return mResSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CResCache::GetSourcePath()
|
TString CResCache::GetSourcePath()
|
||||||
{
|
{
|
||||||
return mResSource.Path;
|
return mResSource.Path;
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ CResource* CResCache::GetResource(CUniqueID ResID, CFourCC type)
|
||||||
return got->second;
|
return got->second;
|
||||||
|
|
||||||
std::vector<u8> *pBuffer = nullptr;
|
std::vector<u8> *pBuffer = nullptr;
|
||||||
std::string Source;
|
TString Source;
|
||||||
|
|
||||||
// Load from pak
|
// Load from pak
|
||||||
if (mResSource.Source == SResSource::PakFile)
|
if (mResSource.Source == SResSource::PakFile)
|
||||||
|
@ -116,17 +116,12 @@ CResource* CResCache::GetResource(CUniqueID ResID, CFourCC type)
|
||||||
// Load from folder
|
// Load from folder
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Source = mResSource.Path + StringUtil::ToString(ResID.ToLong()) + "." + type.ToString();
|
Source = mResSource.Path + ResID.ToString() + "." + type.ToString();
|
||||||
CFileInStream file(Source, IOUtil::BigEndian);
|
CFileInStream file(Source.ToStdString(), IOUtil::BigEndian);
|
||||||
if (!file.IsValid())
|
if (!file.IsValid())
|
||||||
{
|
{
|
||||||
Source = mResSource.Path + StringUtil::ToString(ResID.ToLongLong()) + "." + type.ToString();
|
Log::Error("Couldn't open resource: " + ResID.ToString() + "." + type.ToString());
|
||||||
file.Open(Source, IOUtil::BigEndian);
|
return nullptr;
|
||||||
if (!file.IsValid())
|
|
||||||
{
|
|
||||||
Log::Error("Couldn't open resource: " + ResID.ToString() + "." + type.ToString());
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pBuffer = new std::vector<u8>;
|
pBuffer = new std::vector<u8>;
|
||||||
|
@ -137,7 +132,7 @@ CResource* CResCache::GetResource(CUniqueID ResID, CFourCC type)
|
||||||
|
|
||||||
// Load resource
|
// Load resource
|
||||||
CMemoryInStream mem(pBuffer->data(), pBuffer->size(), IOUtil::BigEndian);
|
CMemoryInStream mem(pBuffer->data(), pBuffer->size(), IOUtil::BigEndian);
|
||||||
mem.SetSourceString(StringUtil::GetFileNameWithExtension(Source));
|
mem.SetSourceString(*Source.GetFileName());
|
||||||
CResource *Res = nullptr;
|
CResource *Res = nullptr;
|
||||||
bool SupportedFormat = true;
|
bool SupportedFormat = true;
|
||||||
|
|
||||||
|
@ -167,17 +162,17 @@ CResource* CResCache::GetResource(CUniqueID ResID, CFourCC type)
|
||||||
return Res;
|
return Res;
|
||||||
}
|
}
|
||||||
|
|
||||||
CResource* CResCache::GetResource(std::string ResPath)
|
CResource* CResCache::GetResource(const TString& ResPath)
|
||||||
{
|
{
|
||||||
// Since this function takes a string argument it always loads directly from a file - no pak
|
// Since this function takes a string argument it always loads directly from a file - no pak
|
||||||
CUniqueID ResID = StringUtil::Hash64(ResPath);
|
CUniqueID ResID = ResPath.Hash64();
|
||||||
|
|
||||||
auto got = mResourceCache.find(ResID.ToLongLong());
|
auto got = mResourceCache.find(ResID.ToLongLong());
|
||||||
|
|
||||||
if (got != mResourceCache.end())
|
if (got != mResourceCache.end())
|
||||||
return got->second;
|
return got->second;
|
||||||
|
|
||||||
CFileInStream file(ResPath, IOUtil::BigEndian);
|
CFileInStream file(ResPath.ToStdString(), IOUtil::BigEndian);
|
||||||
if (!file.IsValid())
|
if (!file.IsValid())
|
||||||
{
|
{
|
||||||
Log::Error("Couldn't open resource: " + ResPath);
|
Log::Error("Couldn't open resource: " + ResPath);
|
||||||
|
@ -187,11 +182,11 @@ CResource* CResCache::GetResource(std::string ResPath)
|
||||||
// Save old ResSource to restore later
|
// Save old ResSource to restore later
|
||||||
const SResSource OldSource = mResSource;
|
const SResSource OldSource = mResSource;
|
||||||
mResSource.Source = SResSource::Folder;
|
mResSource.Source = SResSource::Folder;
|
||||||
mResSource.Path = StringUtil::GetFileDirectory(ResPath);
|
mResSource.Path = ResPath.GetFileDirectory();
|
||||||
|
|
||||||
// Load resource
|
// Load resource
|
||||||
CResource *Res = nullptr;
|
CResource *Res = nullptr;
|
||||||
CFourCC type = StringUtil::ToUpper( StringUtil::GetExtension(ResPath) ).c_str();
|
CFourCC type = ResPath.GetFileExtension().ToUpper();
|
||||||
bool SupportedFormat = true;
|
bool SupportedFormat = true;
|
||||||
|
|
||||||
if (type == "CMDL") Res = CModelLoader::LoadCMDL(file);
|
if (type == "CMDL") Res = CModelLoader::LoadCMDL(file);
|
||||||
|
@ -208,7 +203,7 @@ CResource* CResCache::GetResource(std::string ResPath)
|
||||||
if (!Res) Res = new CResource(); // Default for unsupported formats
|
if (!Res) Res = new CResource(); // Default for unsupported formats
|
||||||
|
|
||||||
// Add to cache and cleanup
|
// Add to cache and cleanup
|
||||||
Res->mID = ResPath.c_str();
|
Res->mID = *ResPath;
|
||||||
Res->mResSource = ResPath;
|
Res->mResSource = ResPath;
|
||||||
mResourceCache[ResID.ToLongLong()] = Res;
|
mResourceCache[ResID.ToLongLong()] = Res;
|
||||||
mResSource = OldSource;
|
mResSource = OldSource;
|
||||||
|
|
|
@ -2,13 +2,14 @@
|
||||||
#define CRESCACHE_H
|
#define CRESCACHE_H
|
||||||
|
|
||||||
#include <Common/types.h>
|
#include <Common/types.h>
|
||||||
|
#include <Common/TString.h>
|
||||||
#include <Resource/CPakFile.h>
|
#include <Resource/CPakFile.h>
|
||||||
#include <Resource/CResource.h>
|
#include <Resource/CResource.h>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
struct SResSource
|
struct SResSource
|
||||||
{
|
{
|
||||||
std::string Path;
|
TString Path;
|
||||||
enum {
|
enum {
|
||||||
Folder, PakFile
|
Folder, PakFile
|
||||||
} Source;
|
} Source;
|
||||||
|
@ -24,13 +25,13 @@ public:
|
||||||
CResCache();
|
CResCache();
|
||||||
~CResCache();
|
~CResCache();
|
||||||
void Clean();
|
void Clean();
|
||||||
void SetFolder(std::string path);
|
void SetFolder(TString path);
|
||||||
void SetPak(std::string path);
|
void SetPak(const TString& path);
|
||||||
void SetResSource(SResSource& ResSource);
|
void SetResSource(SResSource& ResSource);
|
||||||
SResSource GetResSource();
|
SResSource GetResSource();
|
||||||
std::string GetSourcePath();
|
TString GetSourcePath();
|
||||||
CResource* GetResource(CUniqueID ResID, CFourCC type);
|
CResource* GetResource(CUniqueID ResID, CFourCC type);
|
||||||
CResource* GetResource(std::string res);
|
CResource* GetResource(const TString& ResPath);
|
||||||
void CacheResource(CResource *pRes);
|
void CacheResource(CResource *pRes);
|
||||||
void DeleteResource(CUniqueID ResID);
|
void DeleteResource(CUniqueID ResID);
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
#include <Common/CRay.h>
|
#include <Common/CRay.h>
|
||||||
#include <Common/CRayCollisionTester.h>
|
#include <Common/CRayCollisionTester.h>
|
||||||
#include <Common/StringUtil.h>
|
#include <Common/TString.h>
|
||||||
#include <Core/CGraphics.h>
|
#include <Core/CGraphics.h>
|
||||||
#include <Core/CResCache.h>
|
#include <Core/CResCache.h>
|
||||||
#include <FileIO/CFileInStream.h>
|
#include <FileIO/CFileInStream.h>
|
||||||
|
|
|
@ -13,9 +13,9 @@ class IRenderable
|
||||||
public:
|
public:
|
||||||
IRenderable() {}
|
IRenderable() {}
|
||||||
virtual ~IRenderable() {}
|
virtual ~IRenderable() {}
|
||||||
virtual void AddToRenderer(CRenderer *pRenderer, const CFrustumPlanes& frustum) = 0;
|
virtual void AddToRenderer(CRenderer* pRenderer, const CFrustumPlanes& frustum) = 0;
|
||||||
virtual void Draw(ERenderOptions options) {}
|
virtual void Draw(ERenderOptions /*options*/) {}
|
||||||
virtual void DrawAsset(ERenderOptions options, u32 asset) {}
|
virtual void DrawAsset(ERenderOptions /*options*/, u32 /*asset*/) {}
|
||||||
virtual void DrawSelection() {}
|
virtual void DrawSelection() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
34
Core/Log.cpp
34
Core/Log.cpp
|
@ -1,18 +1,16 @@
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <Common/TString.h>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <Common/StringUtil.h>
|
|
||||||
|
|
||||||
namespace Log
|
namespace Log
|
||||||
{
|
{
|
||||||
|
|
||||||
static const std::string gskLogFilename = "primeworldeditor.log";
|
static const TString gskLogFilename = "primeworldeditor.log";
|
||||||
FILE *gpLogFile = fopen(gskLogFilename.c_str(), "w");
|
FILE *gpLogFile = fopen(*gskLogFilename, "w");
|
||||||
|
|
||||||
void Write(const std::string& message)
|
void Write(const TString& message)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (gpLogFile)
|
if (gpLogFile)
|
||||||
{
|
{
|
||||||
time_t RawTime;
|
time_t RawTime;
|
||||||
|
@ -22,12 +20,12 @@ void Write(const std::string& message)
|
||||||
char Buffer[80];
|
char Buffer[80];
|
||||||
strftime(Buffer, 80, "[%H:%M:%S]", pTimeInfo);
|
strftime(Buffer, 80, "[%H:%M:%S]", pTimeInfo);
|
||||||
|
|
||||||
fprintf(gpLogFile, "%s %s\n", Buffer, message.c_str());
|
fprintf(gpLogFile, "%s %s\n", Buffer, *message);
|
||||||
fflush(gpLogFile);
|
fflush(gpLogFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Error(const std::string& message)
|
void Error(const TString& message)
|
||||||
{
|
{
|
||||||
Write("ERROR: " + message);
|
Write("ERROR: " + message);
|
||||||
|
|
||||||
|
@ -36,7 +34,7 @@ void Error(const std::string& message)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Warning(const std::string& message)
|
void Warning(const TString& message)
|
||||||
{
|
{
|
||||||
Write("Warning: " + message);
|
Write("Warning: " + message);
|
||||||
|
|
||||||
|
@ -45,34 +43,34 @@ void Warning(const std::string& message)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileWrite(const std::string& filename, const std::string& message)
|
void FileWrite(const TString& filename, const TString& message)
|
||||||
{
|
{
|
||||||
Write(filename + " : " + message);
|
Write(filename + " : " + message);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileWrite(const std::string& filename, unsigned long offset, const std::string& message)
|
void FileWrite(const TString& filename, unsigned long offset, const TString& message)
|
||||||
{
|
{
|
||||||
Write(filename + " : " + StringUtil::ToHexString(offset) + " - " + message);
|
Write(filename + " : " + TString::HexString(offset) + " - " + message);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileError(const std::string& filename, const std::string& message)
|
void FileError(const TString& filename, const TString& message)
|
||||||
{
|
{
|
||||||
Error(filename + " : " + message);
|
Error(filename + " : " + message);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileError(const std::string &filename, unsigned long offset, const std::string &message)
|
void FileError(const TString& filename, unsigned long offset, const TString& message)
|
||||||
{
|
{
|
||||||
Error(filename + " : " + StringUtil::ToHexString(offset) + " - " + message);
|
Error(filename + " : " + TString::HexString(offset) + " - " + message);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileWarning(const std::string& filename, const std::string& message)
|
void FileWarning(const TString& filename, const TString& message)
|
||||||
{
|
{
|
||||||
Warning(filename + " : " + message);
|
Warning(filename + " : " + message);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileWarning(const std::string& filename, unsigned long offset, const std::string& message)
|
void FileWarning(const TString& filename, unsigned long offset, const TString& message)
|
||||||
{
|
{
|
||||||
Warning(filename + " : " + StringUtil::ToHexString(offset) + " - " + message);
|
Warning(filename + " : " + TString::HexString(offset) + " - " + message);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
20
Core/Log.h
20
Core/Log.h
|
@ -1,20 +1,20 @@
|
||||||
#ifndef INFO
|
#ifndef INFO
|
||||||
#define INFO
|
#define INFO
|
||||||
|
|
||||||
#include <string>
|
#include <Common/TString.h>
|
||||||
|
|
||||||
namespace Log
|
namespace Log
|
||||||
{
|
{
|
||||||
|
|
||||||
void Write(const std::string& message);
|
void Write(const TString& message);
|
||||||
void Error(const std::string& message);
|
void Error(const TString& message);
|
||||||
void Warning(const std::string& message);
|
void Warning(const TString& message);
|
||||||
void FileWrite(const std::string& filename, const std::string& message);
|
void FileWrite(const TString& filename, const TString& message);
|
||||||
void FileWrite(const std::string& filename, unsigned long offset, const std::string& message);
|
void FileWrite(const TString& filename, unsigned long offset, const TString& message);
|
||||||
void FileError(const std::string& filename, const std::string& message);
|
void FileError(const TString& filename, const TString& message);
|
||||||
void FileError(const std::string& filename, unsigned long offset, const std::string& message);
|
void FileError(const TString& filename, unsigned long offset, const TString& message);
|
||||||
void FileWarning(const std::string& filename, const std::string& message);
|
void FileWarning(const TString& filename, const TString& message);
|
||||||
void FileWarning(const std::string& filename, unsigned long offset, const std::string& message);
|
void FileWarning(const TString& filename, unsigned long offset, const TString& message);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ bool CShader::CompileVertexSource(const char* kpSource)
|
||||||
|
|
||||||
if (CompileStatus == GL_FALSE)
|
if (CompileStatus == GL_FALSE)
|
||||||
{
|
{
|
||||||
std::string Out = "dump/BadVS_" + std::to_string(gFailedCompileCount) + ".txt";
|
TString Out = "dump/BadVS_" + std::to_string(gFailedCompileCount) + ".txt";
|
||||||
std::cout << "ERROR: Unable to compile vertex shader; dumped to " << Out << "\n";
|
std::cout << "ERROR: Unable to compile vertex shader; dumped to " << Out << "\n";
|
||||||
DumpShaderSource(mVertexShader, Out);
|
DumpShaderSource(mVertexShader, Out);
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ bool CShader::CompileVertexSource(const char* kpSource)
|
||||||
// Debug dump
|
// Debug dump
|
||||||
else if (gDebugDumpShaders == true)
|
else if (gDebugDumpShaders == true)
|
||||||
{
|
{
|
||||||
std::string Out = "dump/VS_" + std::to_string(gSuccessfulCompileCount) + ".txt";
|
TString Out = "dump/VS_" + TString::FromInt64(gSuccessfulCompileCount, 8, 10) + ".txt";
|
||||||
std::cout << "Debug shader dumping enabled; dumped to " << Out << "\n";
|
std::cout << "Debug shader dumping enabled; dumped to " << Out << "\n";
|
||||||
DumpShaderSource(mVertexShader, Out);
|
DumpShaderSource(mVertexShader, Out);
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ bool CShader::CompilePixelSource(const char* kpSource)
|
||||||
|
|
||||||
if (CompileStatus == GL_FALSE)
|
if (CompileStatus == GL_FALSE)
|
||||||
{
|
{
|
||||||
std::string Out = "dump/BadPS_" + std::to_string(gFailedCompileCount) + ".txt";
|
TString Out = "dump/BadPS_" + TString::FromInt64(gFailedCompileCount, 8, 10) + ".txt";
|
||||||
std::cout << "ERROR: Unable to compile pixel shader; dumped to " << Out << "\n";
|
std::cout << "ERROR: Unable to compile pixel shader; dumped to " << Out << "\n";
|
||||||
DumpShaderSource(mPixelShader, Out);
|
DumpShaderSource(mPixelShader, Out);
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ bool CShader::CompilePixelSource(const char* kpSource)
|
||||||
// Debug dump
|
// Debug dump
|
||||||
else if (gDebugDumpShaders == true)
|
else if (gDebugDumpShaders == true)
|
||||||
{
|
{
|
||||||
std::string Out = "dump/PS_" + std::to_string(gSuccessfulCompileCount) + ".txt";
|
TString Out = "dump/PS_" + TString::FromInt64(gSuccessfulCompileCount, 8, 10) + ".txt";
|
||||||
std::cout << "Debug shader dumping enabled; dumped to " << Out << "\n";
|
std::cout << "Debug shader dumping enabled; dumped to " << Out << "\n";
|
||||||
DumpShaderSource(mPixelShader, Out);
|
DumpShaderSource(mPixelShader, Out);
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ bool CShader::LinkShaders()
|
||||||
|
|
||||||
if (LinkStatus == GL_FALSE)
|
if (LinkStatus == GL_FALSE)
|
||||||
{
|
{
|
||||||
std::string Out = "dump/BadLink_" + std::to_string(gFailedCompileCount) + ".txt";
|
TString Out = "dump/BadLink_" + TString::FromInt64(gFailedCompileCount, 8, 10) + ".txt";
|
||||||
std::cout << "ERROR: Unable to link shaders. Dumped error log to " << Out << "\n";
|
std::cout << "ERROR: Unable to link shaders. Dumped error log to " << Out << "\n";
|
||||||
|
|
||||||
GLint LogLen;
|
GLint LogLen;
|
||||||
|
@ -140,7 +140,7 @@ bool CShader::LinkShaders()
|
||||||
glGetProgramInfoLog(mProgram, LogLen, NULL, InfoLog);
|
glGetProgramInfoLog(mProgram, LogLen, NULL, InfoLog);
|
||||||
|
|
||||||
std::ofstream LinkOut;
|
std::ofstream LinkOut;
|
||||||
LinkOut.open(Out.c_str());
|
LinkOut.open(*Out);
|
||||||
|
|
||||||
if (LogLen > 0)
|
if (LogLen > 0)
|
||||||
LinkOut << InfoLog;
|
LinkOut << InfoLog;
|
||||||
|
@ -197,12 +197,12 @@ void CShader::SetCurrent()
|
||||||
}
|
}
|
||||||
|
|
||||||
// ************ STATIC ************
|
// ************ STATIC ************
|
||||||
CShader* CShader::FromResourceFile(std::string ShaderName)
|
CShader* CShader::FromResourceFile(const TString& ShaderName)
|
||||||
{
|
{
|
||||||
std::string VertexShaderFilename = "../resources/shaders/" + ShaderName + ".vs";
|
TString VertexShaderFilename = "../resources/shaders/" + ShaderName + ".vs";
|
||||||
std::string PixelShaderFilename = "../resources/shaders/" + ShaderName + ".ps";
|
TString PixelShaderFilename = "../resources/shaders/" + ShaderName + ".ps";
|
||||||
CTextInStream VertexShaderFile(VertexShaderFilename);
|
CTextInStream VertexShaderFile(VertexShaderFilename.ToStdString());
|
||||||
CTextInStream PixelShaderFile(PixelShaderFilename);
|
CTextInStream PixelShaderFile(PixelShaderFilename.ToStdString());
|
||||||
|
|
||||||
if (!VertexShaderFile.IsValid())
|
if (!VertexShaderFile.IsValid())
|
||||||
std::cout << "Error: Couldn't load vertex shader file for " << ShaderName << "\n";
|
std::cout << "Error: Couldn't load vertex shader file for " << ShaderName << "\n";
|
||||||
|
@ -236,7 +236,7 @@ void CShader::KillCachedShader()
|
||||||
}
|
}
|
||||||
|
|
||||||
// ************ PRIVATE ************
|
// ************ PRIVATE ************
|
||||||
void CShader::DumpShaderSource(GLuint Shader, std::string Out)
|
void CShader::DumpShaderSource(GLuint Shader, const TString& Out)
|
||||||
{
|
{
|
||||||
GLint SourceLen;
|
GLint SourceLen;
|
||||||
glGetShaderiv(Shader, GL_SHADER_SOURCE_LENGTH, &SourceLen);
|
glGetShaderiv(Shader, GL_SHADER_SOURCE_LENGTH, &SourceLen);
|
||||||
|
@ -249,7 +249,7 @@ void CShader::DumpShaderSource(GLuint Shader, std::string Out)
|
||||||
glGetShaderInfoLog(Shader, LogLen, NULL, InfoLog);
|
glGetShaderInfoLog(Shader, LogLen, NULL, InfoLog);
|
||||||
|
|
||||||
std::ofstream ShaderOut;
|
std::ofstream ShaderOut;
|
||||||
ShaderOut.open(Out.c_str());
|
ShaderOut.open(*Out);
|
||||||
|
|
||||||
if (SourceLen > 0)
|
if (SourceLen > 0)
|
||||||
ShaderOut << Source;
|
ShaderOut << Source;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#define CSHADER_H
|
#define CSHADER_H
|
||||||
|
|
||||||
#include <gl/glew.h>
|
#include <gl/glew.h>
|
||||||
#include <string>
|
#include <Common/TString.h>
|
||||||
|
|
||||||
class CShader
|
class CShader
|
||||||
{
|
{
|
||||||
|
@ -29,17 +29,17 @@ public:
|
||||||
bool LinkShaders();
|
bool LinkShaders();
|
||||||
bool IsValidProgram();
|
bool IsValidProgram();
|
||||||
GLuint GetProgramID();
|
GLuint GetProgramID();
|
||||||
GLuint GetUniformLocation(const char* Uniform);
|
GLuint GetUniformLocation(const char* kpUniform);
|
||||||
GLuint GetUniformBlockIndex(const char* UniformBlock);
|
GLuint GetUniformBlockIndex(const char* kpUniformBlock);
|
||||||
void SetCurrent();
|
void SetCurrent();
|
||||||
|
|
||||||
// Static
|
// Static
|
||||||
static CShader* FromResourceFile(std::string ShaderName);
|
static CShader* FromResourceFile(const TString& ShaderName);
|
||||||
static CShader* CurrentShader();
|
static CShader* CurrentShader();
|
||||||
static void KillCachedShader();
|
static void KillCachedShader();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void DumpShaderSource(GLuint Shader, std::string Out);
|
void DumpShaderSource(GLuint Shader, const TString& Out);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CSHADER_H
|
#endif // CSHADER_H
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include <gl/glew.h>
|
#include <gl/glew.h>
|
||||||
#include "CShaderGenerator.h"
|
#include "CShaderGenerator.h"
|
||||||
|
|
||||||
const std::string gkCoordSrc[] = {
|
const TString gkCoordSrc[] = {
|
||||||
"RawPosition.xyz",
|
"RawPosition.xyz",
|
||||||
"RawNormal.xyz",
|
"RawNormal.xyz",
|
||||||
"0.0, 0.0, 0.0",
|
"0.0, 0.0, 0.0",
|
||||||
|
@ -19,7 +19,7 @@ const std::string gkCoordSrc[] = {
|
||||||
"RawTex7.xy, 1.0"
|
"RawTex7.xy, 1.0"
|
||||||
};
|
};
|
||||||
|
|
||||||
const std::string gkRasSel[] = {
|
const TString gkRasSel[] = {
|
||||||
"vec4(COLOR0A0.rgb, 1.0)",
|
"vec4(COLOR0A0.rgb, 1.0)",
|
||||||
"vec4(COLOR1A1.rgb, 1.0)",
|
"vec4(COLOR1A1.rgb, 1.0)",
|
||||||
"vec4(0.0, 0.0, 0.0, COLOR0A0.a)",
|
"vec4(0.0, 0.0, 0.0, COLOR0A0.a)",
|
||||||
|
@ -29,7 +29,7 @@ const std::string gkRasSel[] = {
|
||||||
"vec4(0.0, 0.0, 0.0, 0.0)"
|
"vec4(0.0, 0.0, 0.0, 0.0)"
|
||||||
};
|
};
|
||||||
|
|
||||||
const std::string gkKonstColor[] = {
|
const TString gkKonstColor[] = {
|
||||||
"1.0, 1.0, 1.0",
|
"1.0, 1.0, 1.0",
|
||||||
"0.875, 0.875, 0.875",
|
"0.875, 0.875, 0.875",
|
||||||
"0.75, 0.75, 0.75",
|
"0.75, 0.75, 0.75",
|
||||||
|
@ -64,7 +64,7 @@ const std::string gkKonstColor[] = {
|
||||||
"KonstColors[3].aaa"
|
"KonstColors[3].aaa"
|
||||||
};
|
};
|
||||||
|
|
||||||
const std::string gkKonstAlpha[] = {
|
const TString gkKonstAlpha[] = {
|
||||||
"1.0",
|
"1.0",
|
||||||
"0.875",
|
"0.875",
|
||||||
"0.75",
|
"0.75",
|
||||||
|
@ -99,7 +99,7 @@ const std::string gkKonstAlpha[] = {
|
||||||
"KonstColors[3].a"
|
"KonstColors[3].a"
|
||||||
};
|
};
|
||||||
|
|
||||||
const std::string gkTevColor[] = {
|
const TString gkTevColor[] = {
|
||||||
"Prev.rgb",
|
"Prev.rgb",
|
||||||
"Prev.aaa",
|
"Prev.aaa",
|
||||||
"C0.rgb",
|
"C0.rgb",
|
||||||
|
@ -118,7 +118,7 @@ const std::string gkTevColor[] = {
|
||||||
"0.0, 0.0, 0.0"
|
"0.0, 0.0, 0.0"
|
||||||
};
|
};
|
||||||
|
|
||||||
const std::string gkTevAlpha[] = {
|
const TString gkTevAlpha[] = {
|
||||||
"Prev.a",
|
"Prev.a",
|
||||||
"C0.a",
|
"C0.a",
|
||||||
"C1.a",
|
"C1.a",
|
||||||
|
@ -129,7 +129,7 @@ const std::string gkTevAlpha[] = {
|
||||||
"0.0"
|
"0.0"
|
||||||
};
|
};
|
||||||
|
|
||||||
const std::string gkTevRigid[] = {
|
const TString gkTevRigid[] = {
|
||||||
"Prev",
|
"Prev",
|
||||||
"C0",
|
"C0",
|
||||||
"C1",
|
"C1",
|
||||||
|
|
|
@ -26,7 +26,7 @@ SOURCES += \
|
||||||
Common/CVector2f.cpp \
|
Common/CVector2f.cpp \
|
||||||
Common/CVector3f.cpp \
|
Common/CVector3f.cpp \
|
||||||
Common/CVector4f.cpp \
|
Common/CVector4f.cpp \
|
||||||
Common/StringUtil.cpp \
|
Common/TString.cpp \
|
||||||
Core/main.cpp \
|
Core/main.cpp \
|
||||||
Core/CSceneManager.cpp \
|
Core/CSceneManager.cpp \
|
||||||
Core/CRenderer.cpp \
|
Core/CRenderer.cpp \
|
||||||
|
@ -168,7 +168,7 @@ HEADERS += \
|
||||||
Common/CVector2f.h \
|
Common/CVector2f.h \
|
||||||
Common/CVector3f.h \
|
Common/CVector3f.h \
|
||||||
Common/CVector4f.h \
|
Common/CVector4f.h \
|
||||||
Common/StringUtil.h \
|
Common/TString.h \
|
||||||
Common/types.h \
|
Common/types.h \
|
||||||
Core/CCamera.h \
|
Core/CCamera.h \
|
||||||
Core/CRenderer.h \
|
Core/CRenderer.h \
|
||||||
|
|
|
@ -19,7 +19,7 @@ u32 CAnimSet::getNodeCount()
|
||||||
return nodes.size();
|
return nodes.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CAnimSet::getNodeName(u32 node)
|
TString CAnimSet::getNodeName(u32 node)
|
||||||
{
|
{
|
||||||
if (node >= nodes.size())
|
if (node >= nodes.size())
|
||||||
return nodes[0].name;
|
return nodes[0].name;
|
||||||
|
|
|
@ -14,7 +14,7 @@ class CAnimSet : public CResource
|
||||||
|
|
||||||
struct SNode
|
struct SNode
|
||||||
{
|
{
|
||||||
std::string name;
|
TString name;
|
||||||
CModel *model;
|
CModel *model;
|
||||||
u32 skinID;
|
u32 skinID;
|
||||||
u32 skelID;
|
u32 skelID;
|
||||||
|
@ -30,7 +30,7 @@ public:
|
||||||
EResType Type();
|
EResType Type();
|
||||||
|
|
||||||
u32 getNodeCount();
|
u32 getNodeCount();
|
||||||
std::string getNodeName(u32 node);
|
TString getNodeName(u32 node);
|
||||||
CModel* getNodeModel(u32 node);
|
CModel* getNodeModel(u32 node);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ CAnimationParameters::CAnimationParameters(CInputStream& SCLY, EGame game)
|
||||||
else if (mUnknown1 != 0x80)
|
else if (mUnknown1 != 0x80)
|
||||||
{
|
{
|
||||||
Log::FileError(SCLY.GetSourceString(), offset,
|
Log::FileError(SCLY.GetSourceString(), offset,
|
||||||
"Unexpected AnimationParameters byte: " + StringUtil::ToHexString(mUnknown1, true, true, 2) + " (property " + StringUtil::ToHexString(propID, true, true, 8) + ")");
|
"Unexpected AnimationParameters byte: " + TString::HexString(mUnknown1, true, true, 2) + " (property " + TString::HexString(propID, true, true, 8) + ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ inline float PtsToFloat(s32 pt)
|
||||||
return 0.00208333f * pt;
|
return 0.00208333f * pt;
|
||||||
}
|
}
|
||||||
|
|
||||||
CVector2f CFont::RenderString(std::string String, CRenderer *pRenderer, float,
|
CVector2f CFont::RenderString(const TString& String, CRenderer *pRenderer, float,
|
||||||
CVector2f, CColor FillColor, CColor StrokeColor, u32 FontSize)
|
CVector2f, CColor FillColor, CColor StrokeColor, u32 FontSize)
|
||||||
{
|
{
|
||||||
// Not using parameter 3 (float - AspectRatio)
|
// Not using parameter 3 (float - AspectRatio)
|
||||||
|
@ -58,7 +58,7 @@ CVector2f CFont::RenderString(std::string String, CRenderer *pRenderer, float,
|
||||||
if (FontSize == CFONT_DEFAULT_SIZE) Scale = 1.f;
|
if (FontSize == CFONT_DEFAULT_SIZE) Scale = 1.f;
|
||||||
else Scale = (float) FontSize / (mDefaultSize != 0 ? mDefaultSize : 18);
|
else Scale = (float) FontSize / (mDefaultSize != 0 ? mDefaultSize : 18);
|
||||||
|
|
||||||
for (u32 iChar = 0; iChar < String.length(); iChar++)
|
for (u32 iChar = 0; iChar < String.Length(); iChar++)
|
||||||
{
|
{
|
||||||
// Get character, check for newline
|
// Get character, check for newline
|
||||||
char Char = String[iChar];
|
char Char = String[iChar];
|
||||||
|
|
|
@ -28,7 +28,7 @@ class CFont : public CResource
|
||||||
u32 mLineMargin; // Gap between lines, in points - this is added to the line height
|
u32 mLineMargin; // Gap between lines, in points - this is added to the line height
|
||||||
u32 mVerticalOffset; // In points. This is used to reposition glyphs after the per-glyph vertical offset is applied
|
u32 mVerticalOffset; // In points. This is used to reposition glyphs after the per-glyph vertical offset is applied
|
||||||
u32 mDefaultSize; // In points.
|
u32 mDefaultSize; // In points.
|
||||||
std::string mFontName; // Self-explanatory
|
TString mFontName; // Self-explanatory
|
||||||
CTexture *mpFontTexture; // The texture used by this font
|
CTexture *mpFontTexture; // The texture used by this font
|
||||||
CToken mTextureToken; // Token for the font
|
CToken mTextureToken; // Token for the font
|
||||||
u32 mTextureFormat; // Indicates which layers on the texture are for what - multiple glyph layers or fill/stroke
|
u32 mTextureFormat; // Indicates which layers on the texture are for what - multiple glyph layers or fill/stroke
|
||||||
|
@ -62,7 +62,7 @@ public:
|
||||||
~CFont();
|
~CFont();
|
||||||
EResType Type();
|
EResType Type();
|
||||||
CResource* MakeCopy(CResCache *pCopyCache);
|
CResource* MakeCopy(CResCache *pCopyCache);
|
||||||
CVector2f RenderString(std::string String, CRenderer *pRenderer, float AspectRatio,
|
CVector2f RenderString(const TString& String, CRenderer *pRenderer, float AspectRatio,
|
||||||
CVector2f Position = CVector2f(0,0),
|
CVector2f Position = CVector2f(0,0),
|
||||||
CColor FillColor = CColor::skWhite, CColor StrokeColor = CColor::skBlack,
|
CColor FillColor = CColor::skWhite, CColor StrokeColor = CColor::skBlack,
|
||||||
u32 FontSize = CFONT_DEFAULT_SIZE);
|
u32 FontSize = CFONT_DEFAULT_SIZE);
|
||||||
|
|
|
@ -217,7 +217,7 @@ void CMaterial::Update()
|
||||||
}
|
}
|
||||||
|
|
||||||
// ************ GETTERS ************
|
// ************ GETTERS ************
|
||||||
std::string CMaterial::Name() const
|
TString CMaterial::Name() const
|
||||||
{
|
{
|
||||||
return mName;
|
return mName;
|
||||||
}
|
}
|
||||||
|
@ -283,7 +283,7 @@ CMaterialPass* CMaterial::Pass(u32 PassIndex) const
|
||||||
|
|
||||||
|
|
||||||
// ************ SETTERS ************
|
// ************ SETTERS ************
|
||||||
void CMaterial::SetName(const std::string& name)
|
void CMaterial::SetName(const TString& name)
|
||||||
{
|
{
|
||||||
mName = name;
|
mName = name;
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ private:
|
||||||
static CColor sCurrentTint; // The tint for the currently bound material
|
static CColor sCurrentTint; // The tint for the currently bound material
|
||||||
|
|
||||||
// Members
|
// Members
|
||||||
std::string mName; // Name of the material
|
TString mName; // Name of the material
|
||||||
CShader *mpShader; // This material's generated shader. Created with GenerateShader().
|
CShader *mpShader; // This material's generated shader. Created with GenerateShader().
|
||||||
EShaderStatus mShaderStatus; // A status variable so that PWE won't crash if a shader fails to compile.
|
EShaderStatus mShaderStatus; // A status variable so that PWE won't crash if a shader fails to compile.
|
||||||
u64 mParametersHash; // A hash of all the parameters that can identify this TEV setup.
|
u64 mParametersHash; // A hash of all the parameters that can identify this TEV setup.
|
||||||
|
@ -82,7 +82,7 @@ public:
|
||||||
void Update();
|
void Update();
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
std::string Name() const;
|
TString Name() const;
|
||||||
EGame Version() const;
|
EGame Version() const;
|
||||||
EMaterialOptions Options() const;
|
EMaterialOptions Options() const;
|
||||||
EVertexDescription VtxDesc() const;
|
EVertexDescription VtxDesc() const;
|
||||||
|
@ -97,7 +97,7 @@ public:
|
||||||
CMaterialPass* Pass(u32 PassIndex) const;
|
CMaterialPass* Pass(u32 PassIndex) const;
|
||||||
|
|
||||||
// Setters
|
// Setters
|
||||||
void SetName(const std::string& name);
|
void SetName(const TString& name);
|
||||||
void SetOptions(EMaterialOptions Options);
|
void SetOptions(EMaterialOptions Options);
|
||||||
void SetVertexDescription(EVertexDescription desc);
|
void SetVertexDescription(EVertexDescription desc);
|
||||||
void SetBlendMode(GLenum SrcFac, GLenum DstFac);
|
void SetBlendMode(GLenum SrcFac, GLenum DstFac);
|
||||||
|
|
|
@ -300,7 +300,7 @@ void CMaterialPass::SetEnabled(bool Enabled)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ************ STATIC ************
|
// ************ STATIC ************
|
||||||
std::string CMaterialPass::PassTypeName(CFourCC Type)
|
TString CMaterialPass::PassTypeName(CFourCC Type)
|
||||||
{
|
{
|
||||||
if (Type == "CUST") return "Custom";
|
if (Type == "CUST") return "Custom";
|
||||||
if (Type == "DIFF") return "Light";
|
if (Type == "DIFF") return "Light";
|
||||||
|
|
|
@ -69,7 +69,7 @@ public:
|
||||||
return mPassType;
|
return mPassType;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::string NamedType() const {
|
inline TString NamedType() const {
|
||||||
return PassTypeName(mPassType);
|
return PassTypeName(mPassType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
// Static
|
// Static
|
||||||
static std::string PassTypeName(CFourCC Type);
|
static TString PassTypeName(CFourCC Type);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CMATERIALPASS_H
|
#endif // CMATERIALPASS_H
|
||||||
|
|
|
@ -34,14 +34,14 @@ CMaterial* CMaterialSet::MaterialByIndex(u32 index)
|
||||||
return mMaterials[index];
|
return mMaterials[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
CMaterial* CMaterialSet::MaterialByName(const std::string &name)
|
CMaterial* CMaterialSet::MaterialByName(const TString& name)
|
||||||
{
|
{
|
||||||
for (auto it = mMaterials.begin(); it != mMaterials.end(); it++)
|
for (auto it = mMaterials.begin(); it != mMaterials.end(); it++)
|
||||||
if ((*it)->Name() == name) return *it;
|
if ((*it)->Name() == name) return *it;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 CMaterialSet::MaterialIndexByName(const std::string& name)
|
u32 CMaterialSet::MaterialIndexByName(const TString& name)
|
||||||
{
|
{
|
||||||
for (u32 iMat = 0; iMat < mMaterials.size(); iMat++)
|
for (u32 iMat = 0; iMat < mMaterials.size(); iMat++)
|
||||||
if (mMaterials[iMat]->Name() == name) return iMat;
|
if (mMaterials[iMat]->Name() == name) return iMat;
|
||||||
|
|
|
@ -19,8 +19,8 @@ public:
|
||||||
CMaterialSet* Clone();
|
CMaterialSet* Clone();
|
||||||
u32 NumMaterials();
|
u32 NumMaterials();
|
||||||
CMaterial* MaterialByIndex(u32 index);
|
CMaterial* MaterialByIndex(u32 index);
|
||||||
CMaterial* MaterialByName(const std::string& name);
|
CMaterial* MaterialByName(const TString& name);
|
||||||
u32 MaterialIndexByName(const std::string& name);
|
u32 MaterialIndexByName(const TString& name);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CMATERIALSET_H
|
#endif // CMATERIALSET_H
|
||||||
|
|
|
@ -16,12 +16,12 @@ EResType CResource::Type()
|
||||||
return eResource;
|
return eResource;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CResource::Source()
|
TString CResource::Source()
|
||||||
{
|
{
|
||||||
return StringUtil::GetFileNameWithExtension(mResSource);
|
return mResSource.GetFileName();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CResource::FullSource()
|
TString CResource::FullSource()
|
||||||
{
|
{
|
||||||
return mResSource;
|
return mResSource;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include <Common/CFourCC.h>
|
#include <Common/CFourCC.h>
|
||||||
#include <Common/CUniqueID.h>
|
#include <Common/CUniqueID.h>
|
||||||
#include <Common/types.h>
|
#include <Common/types.h>
|
||||||
#include <Common/StringUtil.h>
|
#include <Common/TString.h>
|
||||||
|
|
||||||
class CResCache;
|
class CResCache;
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ class CResource
|
||||||
{
|
{
|
||||||
friend class CResCache;
|
friend class CResCache;
|
||||||
|
|
||||||
std::string mResSource;
|
TString mResSource;
|
||||||
CUniqueID mID;
|
CUniqueID mID;
|
||||||
int mRefCount;
|
int mRefCount;
|
||||||
|
|
||||||
|
@ -21,8 +21,8 @@ public:
|
||||||
CResource();
|
CResource();
|
||||||
virtual ~CResource();
|
virtual ~CResource();
|
||||||
virtual EResType Type();
|
virtual EResType Type();
|
||||||
std::string Source();
|
TString Source();
|
||||||
std::string FullSource();
|
TString FullSource();
|
||||||
CUniqueID ResID();
|
CUniqueID ResID();
|
||||||
void Lock();
|
void Lock();
|
||||||
void Release();
|
void Release();
|
||||||
|
|
|
@ -35,7 +35,7 @@ CFourCC CStringTable::GetLangTag(u32 Index)
|
||||||
return mLangTables[Index].Language;
|
return mLangTables[Index].Language;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::wstring CStringTable::GetString(CFourCC Lang, u32 StringIndex)
|
TWideString CStringTable::GetString(CFourCC Lang, u32 StringIndex)
|
||||||
{
|
{
|
||||||
for (u32 iLang = 0; iLang < GetLangCount(); iLang++)
|
for (u32 iLang = 0; iLang < GetLangCount(); iLang++)
|
||||||
{
|
{
|
||||||
|
@ -46,12 +46,12 @@ std::wstring CStringTable::GetString(CFourCC Lang, u32 StringIndex)
|
||||||
return std::wstring();
|
return std::wstring();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::wstring CStringTable::GetString(u32 LangIndex, u32 StringIndex)
|
TWideString CStringTable::GetString(u32 LangIndex, u32 StringIndex)
|
||||||
{
|
{
|
||||||
return mLangTables[LangIndex].Strings[StringIndex];
|
return mLangTables[LangIndex].Strings[StringIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CStringTable::GetStringName(u32 StringIndex)
|
TString CStringTable::GetStringName(u32 StringIndex)
|
||||||
{
|
{
|
||||||
return mStringNames[StringIndex];
|
return mStringNames[StringIndex];
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,13 +11,13 @@ class CStringTable : public CResource
|
||||||
{
|
{
|
||||||
friend class CStringLoader;
|
friend class CStringLoader;
|
||||||
|
|
||||||
std::vector<std::string> mStringNames;
|
std::vector<TString> mStringNames;
|
||||||
u32 mNumStrings;
|
u32 mNumStrings;
|
||||||
|
|
||||||
struct SLangTable
|
struct SLangTable
|
||||||
{
|
{
|
||||||
CFourCC Language;
|
CFourCC Language;
|
||||||
std::vector<std::wstring> Strings;
|
std::vector<TWideString> Strings;
|
||||||
};
|
};
|
||||||
std::vector<SLangTable> mLangTables;
|
std::vector<SLangTable> mLangTables;
|
||||||
|
|
||||||
|
@ -31,9 +31,9 @@ public:
|
||||||
u32 GetStringCount();
|
u32 GetStringCount();
|
||||||
u32 GetLangCount();
|
u32 GetLangCount();
|
||||||
CFourCC GetLangTag(u32 Index);
|
CFourCC GetLangTag(u32 Index);
|
||||||
std::wstring GetString(CFourCC Lang, u32 StringIndex);
|
TWideString GetString(CFourCC Lang, u32 StringIndex);
|
||||||
std::wstring GetString(u32 LangIndex, u32 StringIndex);
|
TWideString GetString(u32 LangIndex, u32 StringIndex);
|
||||||
std::string GetStringName(u32 StringIndex);
|
TString GetStringName(u32 StringIndex);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CSTRINGTABLE_H
|
#endif // CSTRINGTABLE_H
|
||||||
|
|
|
@ -90,7 +90,7 @@ u32 CWorld::GetAreaAttachedID(u32 AreaIndex, u32 AttachedIndex)
|
||||||
return (u32) mAreas[AreaIndex].AttachedAreaIDs[AttachedIndex];
|
return (u32) mAreas[AreaIndex].AttachedAreaIDs[AttachedIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CWorld::GetAreaInternalName(u32 AreaIndex)
|
TString CWorld::GetAreaInternalName(u32 AreaIndex)
|
||||||
{
|
{
|
||||||
return mAreas[AreaIndex].InternalName;
|
return mAreas[AreaIndex].InternalName;
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ class CWorld : public CResource
|
||||||
|
|
||||||
struct SArea
|
struct SArea
|
||||||
{
|
{
|
||||||
std::string InternalName;
|
TString InternalName;
|
||||||
CStringTable *pAreaName;
|
CStringTable *pAreaName;
|
||||||
CTransform4f Transform;
|
CTransform4f Transform;
|
||||||
CAABox AetherBox;
|
CAABox AetherBox;
|
||||||
|
@ -53,7 +53,7 @@ class CWorld : public CResource
|
||||||
|
|
||||||
std::vector<u16> AttachedAreaIDs;
|
std::vector<u16> AttachedAreaIDs;
|
||||||
std::vector<SDependency> Dependencies;
|
std::vector<SDependency> Dependencies;
|
||||||
std::vector<std::string> RelFilenames;
|
std::vector<TString> RelFilenames;
|
||||||
std::vector<u32> RelOffsets;
|
std::vector<u32> RelOffsets;
|
||||||
u32 CommonDependenciesStart;
|
u32 CommonDependenciesStart;
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ class CWorld : public CResource
|
||||||
|
|
||||||
struct SLayer
|
struct SLayer
|
||||||
{
|
{
|
||||||
std::string LayerName;
|
TString LayerName;
|
||||||
bool EnabledByDefault;
|
bool EnabledByDefault;
|
||||||
u8 LayerID[16];
|
u8 LayerID[16];
|
||||||
u32 LayerDependenciesStart; // Offset into Dependencies vector
|
u32 LayerDependenciesStart; // Offset into Dependencies vector
|
||||||
|
@ -100,7 +100,7 @@ public:
|
||||||
u64 GetAreaResourceID(u32 AreaIndex);
|
u64 GetAreaResourceID(u32 AreaIndex);
|
||||||
u32 GetAreaAttachedCount(u32 AreaIndex);
|
u32 GetAreaAttachedCount(u32 AreaIndex);
|
||||||
u32 GetAreaAttachedID(u32 AreaIndex, u32 AttachedIndex);
|
u32 GetAreaAttachedID(u32 AreaIndex, u32 AttachedIndex);
|
||||||
std::string GetAreaInternalName(u32 AreaIndex);
|
TString GetAreaInternalName(u32 AreaIndex);
|
||||||
CStringTable* GetAreaName(u32 AreaIndex);
|
CStringTable* GetAreaName(u32 AreaIndex);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
struct SNamedResource
|
struct SNamedResource
|
||||||
{
|
{
|
||||||
CFourCC resType;
|
CFourCC resType;
|
||||||
std::string resName;
|
TString resName;
|
||||||
u64 resID;
|
u64 resID;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,8 @@ void CTemplateWriter::SaveAllTemplates()
|
||||||
{
|
{
|
||||||
// Create directory
|
// Create directory
|
||||||
std::list<CMasterTemplate*> masterList = CMasterTemplate::GetMasterList();
|
std::list<CMasterTemplate*> masterList = CMasterTemplate::GetMasterList();
|
||||||
std::string out = "../templates/";
|
TString out = "../templates/";
|
||||||
boost::filesystem::create_directory(out);
|
boost::filesystem::create_directory(out.ToStdString());
|
||||||
|
|
||||||
// Resave master templates
|
// Resave master templates
|
||||||
for (auto it = masterList.begin(); it != masterList.end(); it++)
|
for (auto it = masterList.begin(); it != masterList.end(); it++)
|
||||||
|
@ -37,14 +37,14 @@ void CTemplateWriter::SaveAllTemplates()
|
||||||
XMLElement *pGame = gameList.NewElement("game");
|
XMLElement *pGame = gameList.NewElement("game");
|
||||||
|
|
||||||
XMLElement *pGameName = gameList.NewElement("name");
|
XMLElement *pGameName = gameList.NewElement("name");
|
||||||
pGameName->SetText(pMaster->mGameName.c_str());
|
pGameName->SetText(*pMaster->mGameName);
|
||||||
|
|
||||||
XMLElement *pWorldVersion = gameList.NewElement("mlvl");
|
XMLElement *pWorldVersion = gameList.NewElement("mlvl");
|
||||||
u32 versionNumber = CWorldCooker::GetMLVLVersion(pMaster->GetGame());
|
u32 versionNumber = CWorldCooker::GetMLVLVersion(pMaster->GetGame());
|
||||||
pWorldVersion->SetText(StringUtil::ToHexString(versionNumber, true, true, 2).c_str());
|
pWorldVersion->SetText(*TString::HexString(versionNumber, true, true, 2));
|
||||||
|
|
||||||
XMLElement *pTempPath = gameList.NewElement("master");
|
XMLElement *pTempPath = gameList.NewElement("master");
|
||||||
pTempPath->SetText(pMaster->mSourceFile.c_str());
|
pTempPath->SetText(*pMaster->mSourceFile);
|
||||||
|
|
||||||
pGame->LinkEndChild(pGameName);
|
pGame->LinkEndChild(pGameName);
|
||||||
pGame->LinkEndChild(pWorldVersion);
|
pGame->LinkEndChild(pWorldVersion);
|
||||||
|
@ -52,15 +52,15 @@ void CTemplateWriter::SaveAllTemplates()
|
||||||
pBase->LinkEndChild(pGame);
|
pBase->LinkEndChild(pGame);
|
||||||
}
|
}
|
||||||
|
|
||||||
gameList.SaveFile((out + "GameList.xml").c_str());
|
gameList.SaveFile(*(out + "GameList.xml"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTemplateWriter::SaveGameTemplates(CMasterTemplate *pMaster, const std::string& dir)
|
void CTemplateWriter::SaveGameTemplates(CMasterTemplate *pMaster, const TString& dir)
|
||||||
{
|
{
|
||||||
// Create directory
|
// Create directory
|
||||||
std::string outFile = dir + pMaster->mSourceFile;
|
TString outFile = dir + pMaster->mSourceFile;
|
||||||
std::string outDir = StringUtil::GetFileDirectory(outFile);
|
TString outDir = outFile.GetFileDirectory();
|
||||||
boost::filesystem::create_directory(outDir);
|
boost::filesystem::create_directory(outDir.ToStdString());
|
||||||
|
|
||||||
// Resave script templates
|
// Resave script templates
|
||||||
for (auto it = pMaster->mTemplates.begin(); it != pMaster->mTemplates.end(); it++)
|
for (auto it = pMaster->mTemplates.begin(); it != pMaster->mTemplates.end(); it++)
|
||||||
|
@ -92,44 +92,44 @@ void CTemplateWriter::SaveGameTemplates(CMasterTemplate *pMaster, const std::str
|
||||||
|
|
||||||
for (auto it = pMaster->mTemplates.begin(); it != pMaster->mTemplates.end(); it++)
|
for (auto it = pMaster->mTemplates.begin(); it != pMaster->mTemplates.end(); it++)
|
||||||
{
|
{
|
||||||
std::string objID;
|
TString objID;
|
||||||
u32 intID = (it->second)->ObjectID();
|
u32 intID = (it->second)->ObjectID();
|
||||||
if (intID <= 0xFF) objID = StringUtil::ToHexString(intID, true, true, 2);
|
if (intID <= 0xFF) objID = TString::HexString(intID, true, true, 2);
|
||||||
else objID = CFourCC(intID).ToString();
|
else objID = CFourCC(intID).ToString();
|
||||||
|
|
||||||
XMLElement *pObj = master.NewElement("object");
|
XMLElement *pObj = master.NewElement("object");
|
||||||
pObj->SetAttribute("ID", objID.c_str());
|
pObj->SetAttribute("ID", *objID);
|
||||||
pObj->SetAttribute("template", (it->second)->mSourceFile.c_str());
|
pObj->SetAttribute("template", *(it->second)->mSourceFile);
|
||||||
pObjects->LinkEndChild(pObj);
|
pObjects->LinkEndChild(pObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write script states/messages
|
// Write script states/messages
|
||||||
std::map<u32, std::string> *pMaps[2] = { &pMaster->mStates, &pMaster->mMessages };
|
std::map<u32, TString> *pMaps[2] = { &pMaster->mStates, &pMaster->mMessages };
|
||||||
std::string types[2] = { "state", "message" };
|
TString types[2] = { "state", "message" };
|
||||||
|
|
||||||
for (u32 iScr = 0; iScr < 2; iScr++)
|
for (u32 iScr = 0; iScr < 2; iScr++)
|
||||||
{
|
{
|
||||||
XMLElement *pElem = master.NewElement((types[iScr] + "s").c_str());
|
XMLElement *pElem = master.NewElement(*(types[iScr] + "s"));
|
||||||
pBase->LinkEndChild(pElem);
|
pBase->LinkEndChild(pElem);
|
||||||
|
|
||||||
for (auto it = pMaps[iScr]->begin(); it != pMaps[iScr]->end(); it++)
|
for (auto it = pMaps[iScr]->begin(); it != pMaps[iScr]->end(); it++)
|
||||||
{
|
{
|
||||||
std::string ID;
|
TString ID;
|
||||||
if (it->first <= 0xFF) ID = StringUtil::ToHexString(it->first, true, true, 2);
|
if (it->first <= 0xFF) ID = TString::HexString(it->first, true, true, 2);
|
||||||
else ID = CFourCC(it->first).ToString();
|
else ID = CFourCC(it->first).ToString();
|
||||||
|
|
||||||
XMLElement *pSubElem = master.NewElement(types[iScr].c_str());
|
XMLElement *pSubElem = master.NewElement(*types[iScr]);
|
||||||
pSubElem->SetAttribute("ID", ID.c_str());
|
pSubElem->SetAttribute("ID", *ID);
|
||||||
pSubElem->SetAttribute("name", (it->second).c_str());
|
pSubElem->SetAttribute("name", *(it->second));
|
||||||
pElem->LinkEndChild(pSubElem);
|
pElem->LinkEndChild(pSubElem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save file
|
// Save file
|
||||||
master.SaveFile(outFile.c_str());
|
master.SaveFile(*outFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTemplateWriter::SavePropertyList(CMasterTemplate *pMaster, const std::string& dir)
|
void CTemplateWriter::SavePropertyList(CMasterTemplate *pMaster, const TString& dir)
|
||||||
{
|
{
|
||||||
// Create XML
|
// Create XML
|
||||||
XMLDocument list;
|
XMLDocument list;
|
||||||
|
@ -151,13 +151,13 @@ void CTemplateWriter::SavePropertyList(CMasterTemplate *pMaster, const std::stri
|
||||||
CStructTemplate *pStructTemp = static_cast<CStructTemplate*>(pTemp);
|
CStructTemplate *pStructTemp = static_cast<CStructTemplate*>(pTemp);
|
||||||
|
|
||||||
XMLElement *pElem = list.NewElement("struct");
|
XMLElement *pElem = list.NewElement("struct");
|
||||||
pElem->SetAttribute("ID", StringUtil::ToHexString(pTemp->PropertyID(), true, true, 8).c_str());
|
pElem->SetAttribute("ID", *TString::HexString(pTemp->PropertyID(), true, true, 8));
|
||||||
pElem->SetAttribute("name", pTemp->Name().c_str());
|
pElem->SetAttribute("name", *pTemp->Name());
|
||||||
|
|
||||||
if (!pStructTemp->mSourceFile.empty())
|
if (!pStructTemp->mSourceFile.IsEmpty())
|
||||||
{
|
{
|
||||||
SaveStructTemplate(pStructTemp, pMaster, dir);
|
SaveStructTemplate(pStructTemp, pMaster, dir);
|
||||||
pElem->SetAttribute("template", pStructTemp->mSourceFile.c_str());
|
pElem->SetAttribute("template", *pStructTemp->mSourceFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
pBase->LinkEndChild(pElem);
|
pBase->LinkEndChild(pElem);
|
||||||
|
@ -166,17 +166,17 @@ void CTemplateWriter::SavePropertyList(CMasterTemplate *pMaster, const std::stri
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
XMLElement *pElem = list.NewElement("property");
|
XMLElement *pElem = list.NewElement("property");
|
||||||
pElem->SetAttribute("ID", StringUtil::ToHexString(pTemp->PropertyID(), true, true, 8).c_str());
|
pElem->SetAttribute("ID", *TString::HexString(pTemp->PropertyID(), true, true, 8));
|
||||||
pElem->SetAttribute("name", pTemp->Name().c_str());
|
pElem->SetAttribute("name", *pTemp->Name());
|
||||||
pElem->SetAttribute("type", PropEnumToPropString(pTemp->Type()).c_str());
|
pElem->SetAttribute("type", *PropEnumToPropString(pTemp->Type()));
|
||||||
|
|
||||||
if (pTemp->Type() == eFileProperty)
|
if (pTemp->Type() == eFileProperty)
|
||||||
{
|
{
|
||||||
// Construct extension list string
|
// Construct extension list string
|
||||||
CFileTemplate *pFileProp = static_cast<CFileTemplate*>(pTemp);
|
CFileTemplate *pFileProp = static_cast<CFileTemplate*>(pTemp);
|
||||||
const CStringList& extensions = pFileProp->Extensions();
|
const TStringList& extensions = pFileProp->Extensions();
|
||||||
|
|
||||||
std::string strList = "";
|
TString strList = "";
|
||||||
|
|
||||||
for (auto it = extensions.begin(); it != extensions.end();)
|
for (auto it = extensions.begin(); it != extensions.end();)
|
||||||
{
|
{
|
||||||
|
@ -185,22 +185,22 @@ void CTemplateWriter::SavePropertyList(CMasterTemplate *pMaster, const std::stri
|
||||||
if (it != extensions.end()) strList += ",";
|
if (it != extensions.end()) strList += ",";
|
||||||
}
|
}
|
||||||
|
|
||||||
pElem->SetAttribute("ext", strList.c_str());
|
pElem->SetAttribute("ext", *strList);
|
||||||
}
|
}
|
||||||
|
|
||||||
pBase->LinkEndChild(pElem);
|
pBase->LinkEndChild(pElem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
list.SaveFile((dir + "Properties.xml").c_str());
|
list.SaveFile(*(dir + "Properties.xml"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTemplateWriter::SaveScriptTemplate(CScriptTemplate *pTemp, const std::string& dir)
|
void CTemplateWriter::SaveScriptTemplate(CScriptTemplate *pTemp, const TString& dir)
|
||||||
{
|
{
|
||||||
// Create directory
|
// Create directory
|
||||||
std::string outFile = dir + pTemp->mSourceFile;
|
TString outFile = dir + pTemp->mSourceFile;
|
||||||
std::string outDir = StringUtil::GetFileDirectory(outFile);
|
TString outDir = outFile.GetFileDirectory();
|
||||||
boost::filesystem::create_directory(outDir);
|
boost::filesystem::create_directory(*outDir);
|
||||||
|
|
||||||
// Create new document
|
// Create new document
|
||||||
XMLDocument scriptXML;
|
XMLDocument scriptXML;
|
||||||
|
@ -215,14 +215,14 @@ void CTemplateWriter::SaveScriptTemplate(CScriptTemplate *pTemp, const std::stri
|
||||||
|
|
||||||
// Write object name
|
// Write object name
|
||||||
XMLElement *pName = scriptXML.NewElement("name");
|
XMLElement *pName = scriptXML.NewElement("name");
|
||||||
pName->SetText(pTemp->TemplateName().c_str());
|
pName->SetText(*pTemp->TemplateName());
|
||||||
pBase->LinkEndChild(pName);
|
pBase->LinkEndChild(pName);
|
||||||
|
|
||||||
// Write properties
|
// Write properties
|
||||||
for (auto it = pTemp->mPropertySets.begin(); it != pTemp->mPropertySets.end(); it++)
|
for (auto it = pTemp->mPropertySets.begin(); it != pTemp->mPropertySets.end(); it++)
|
||||||
{
|
{
|
||||||
XMLElement *pProperties = scriptXML.NewElement("properties");
|
XMLElement *pProperties = scriptXML.NewElement("properties");
|
||||||
pProperties->SetAttribute("version", it->SetName.c_str());
|
pProperties->SetAttribute("version", *it->SetName);
|
||||||
SaveProperties(&scriptXML, pProperties, it->pBaseStruct, pTemp->MasterTemplate(), dir);
|
SaveProperties(&scriptXML, pProperties, it->pBaseStruct, pTemp->MasterTemplate(), dir);
|
||||||
pBase->LinkEndChild(pProperties);
|
pBase->LinkEndChild(pProperties);
|
||||||
}
|
}
|
||||||
|
@ -235,7 +235,7 @@ void CTemplateWriter::SaveScriptTemplate(CScriptTemplate *pTemp, const std::stri
|
||||||
XMLElement *pEditorProperties = scriptXML.NewElement("properties");
|
XMLElement *pEditorProperties = scriptXML.NewElement("properties");
|
||||||
pEditor->LinkEndChild(pEditorProperties);
|
pEditor->LinkEndChild(pEditorProperties);
|
||||||
|
|
||||||
std::string propNames[6] = {
|
TString propNames[6] = {
|
||||||
"InstanceName", "Position", "Rotation",
|
"InstanceName", "Position", "Rotation",
|
||||||
"Scale", "Active", "LightParameters"
|
"Scale", "Active", "LightParameters"
|
||||||
};
|
};
|
||||||
|
@ -247,11 +247,11 @@ void CTemplateWriter::SaveScriptTemplate(CScriptTemplate *pTemp, const std::stri
|
||||||
|
|
||||||
for (u32 iProp = 0; iProp < 6; iProp++)
|
for (u32 iProp = 0; iProp < 6; iProp++)
|
||||||
{
|
{
|
||||||
if (!pPropStrings[iProp]->empty())
|
if (!pPropStrings[iProp]->IsEmpty())
|
||||||
{
|
{
|
||||||
XMLElement *pProperty = scriptXML.NewElement("property");
|
XMLElement *pProperty = scriptXML.NewElement("property");
|
||||||
pProperty->SetAttribute("name", propNames[iProp].c_str());
|
pProperty->SetAttribute("name", *propNames[iProp]);
|
||||||
pProperty->SetAttribute("ID", pPropStrings[iProp]->c_str());
|
pProperty->SetAttribute("ID", **pPropStrings[iProp]);
|
||||||
pEditorProperties->LinkEndChild(pProperty);
|
pEditorProperties->LinkEndChild(pProperty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -262,8 +262,8 @@ void CTemplateWriter::SaveScriptTemplate(CScriptTemplate *pTemp, const std::stri
|
||||||
|
|
||||||
for (auto it = pTemp->mAssets.begin(); it != pTemp->mAssets.end(); it++)
|
for (auto it = pTemp->mAssets.begin(); it != pTemp->mAssets.end(); it++)
|
||||||
{
|
{
|
||||||
std::string source = (it->AssetSource == CScriptTemplate::SEditorAsset::eFile ? "file" : "property");
|
TString source = (it->AssetSource == CScriptTemplate::SEditorAsset::eFile ? "file" : "property");
|
||||||
std::string type;
|
TString type;
|
||||||
|
|
||||||
switch (it->AssetType)
|
switch (it->AssetType)
|
||||||
{
|
{
|
||||||
|
@ -275,10 +275,10 @@ void CTemplateWriter::SaveScriptTemplate(CScriptTemplate *pTemp, const std::stri
|
||||||
s32 force = -1;
|
s32 force = -1;
|
||||||
if (it->AssetSource == CScriptTemplate::SEditorAsset::eAnimParams) force = it->ForceNodeIndex;
|
if (it->AssetSource == CScriptTemplate::SEditorAsset::eAnimParams) force = it->ForceNodeIndex;
|
||||||
|
|
||||||
XMLElement *pAsset = scriptXML.NewElement(type.c_str());
|
XMLElement *pAsset = scriptXML.NewElement(*type);
|
||||||
pAsset->SetAttribute("source", source.c_str());
|
pAsset->SetAttribute("source", *source);
|
||||||
if (force >= 0) pAsset->SetAttribute("force", std::to_string(force).c_str());
|
if (force >= 0) pAsset->SetAttribute("force", std::to_string(force).c_str());
|
||||||
pAsset->SetText(it->AssetLocation.c_str());
|
pAsset->SetText(*it->AssetLocation);
|
||||||
pAssets->LinkEndChild(pAsset);
|
pAssets->LinkEndChild(pAsset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -302,7 +302,7 @@ void CTemplateWriter::SaveScriptTemplate(CScriptTemplate *pTemp, const std::stri
|
||||||
pEditor->LinkEndChild(pVolume);
|
pEditor->LinkEndChild(pVolume);
|
||||||
|
|
||||||
// Enum -> String conversion lambda to avoid redundant code
|
// Enum -> String conversion lambda to avoid redundant code
|
||||||
auto GetVolumeString = [](EVolumeShape shape) -> std::string
|
auto GetVolumeString = [](EVolumeShape shape) -> TString
|
||||||
{
|
{
|
||||||
switch (shape)
|
switch (shape)
|
||||||
{
|
{
|
||||||
|
@ -316,11 +316,11 @@ void CTemplateWriter::SaveScriptTemplate(CScriptTemplate *pTemp, const std::stri
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pVolume->SetAttribute("shape", GetVolumeString(pTemp->mVolumeShape).c_str());
|
pVolume->SetAttribute("shape", *GetVolumeString(pTemp->mVolumeShape));
|
||||||
|
|
||||||
if (pTemp->mVolumeShape == eConditionalShape)
|
if (pTemp->mVolumeShape == eConditionalShape)
|
||||||
{
|
{
|
||||||
pVolume->SetAttribute("propertyID", pTemp->mVolumeConditionIDString.c_str());
|
pVolume->SetAttribute("propertyID", *pTemp->mVolumeConditionIDString);
|
||||||
|
|
||||||
// Find conditional test property
|
// Find conditional test property
|
||||||
CPropertyTemplate *pProp;
|
CPropertyTemplate *pProp;
|
||||||
|
@ -335,32 +335,32 @@ void CTemplateWriter::SaveScriptTemplate(CScriptTemplate *pTemp, const std::stri
|
||||||
for (auto it = pTemp->mVolumeConditions.begin(); it != pTemp->mVolumeConditions.end(); it++)
|
for (auto it = pTemp->mVolumeConditions.begin(); it != pTemp->mVolumeConditions.end(); it++)
|
||||||
{
|
{
|
||||||
// Value should be an integer, or a boolean condition?
|
// Value should be an integer, or a boolean condition?
|
||||||
std::string strVal;
|
TString strVal;
|
||||||
|
|
||||||
if (pProp->Type() == eBoolProperty)
|
if (pProp->Type() == eBoolProperty)
|
||||||
strVal = (it->Value == 1 ? "true" : "false");
|
strVal = (it->Value == 1 ? "true" : "false");
|
||||||
else
|
else
|
||||||
strVal = StringUtil::ToHexString((u32) it->Value, true, true, (it->Value > 0xFF ? 8 : 2));
|
strVal = TString::HexString((u32) it->Value, true, true, (it->Value > 0xFF ? 8 : 2));
|
||||||
|
|
||||||
XMLElement *pCondition = scriptXML.NewElement("condition");
|
XMLElement *pCondition = scriptXML.NewElement("condition");
|
||||||
pCondition->SetAttribute("value", strVal.c_str());
|
pCondition->SetAttribute("value", *strVal);
|
||||||
pCondition->SetAttribute("shape", GetVolumeString(it->Shape).c_str());
|
pCondition->SetAttribute("shape", *GetVolumeString(it->Shape));
|
||||||
pVolume->LinkEndChild(pCondition);
|
pVolume->LinkEndChild(pCondition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write to file
|
// Write to file
|
||||||
scriptXML.SaveFile(outFile.c_str());
|
scriptXML.SaveFile(*outFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTemplateWriter::SaveStructTemplate(CStructTemplate *pTemp, CMasterTemplate *pMaster, const std::string& dir)
|
void CTemplateWriter::SaveStructTemplate(CStructTemplate *pTemp, CMasterTemplate *pMaster, const TString& dir)
|
||||||
{
|
{
|
||||||
// Create directory
|
// Create directory
|
||||||
std::string outFile = dir + pTemp->mSourceFile;
|
TString outFile = dir + pTemp->mSourceFile;
|
||||||
std::string outDir = StringUtil::GetFileDirectory(outFile);
|
TString outDir = outFile.GetFileDirectory();
|
||||||
std::string name = StringUtil::GetFileName(pTemp->mSourceFile);
|
TString name = pTemp->mSourceFile.GetFileName();
|
||||||
boost::filesystem::create_directory(outDir);
|
boost::filesystem::create_directory(outDir.ToStdString());
|
||||||
|
|
||||||
// Create new document and write struct properties to it
|
// Create new document and write struct properties to it
|
||||||
XMLDocument structXML;
|
XMLDocument structXML;
|
||||||
|
@ -369,21 +369,21 @@ void CTemplateWriter::SaveStructTemplate(CStructTemplate *pTemp, CMasterTemplate
|
||||||
structXML.LinkEndChild(pDecl);
|
structXML.LinkEndChild(pDecl);
|
||||||
|
|
||||||
XMLElement *pBase = structXML.NewElement("struct");
|
XMLElement *pBase = structXML.NewElement("struct");
|
||||||
pBase->SetAttribute("name", name.c_str());
|
pBase->SetAttribute("name", *name);
|
||||||
pBase->SetAttribute("type", (pTemp->IsSingleProperty() ? "single" : "multi"));
|
pBase->SetAttribute("type", (pTemp->IsSingleProperty() ? "single" : "multi"));
|
||||||
SaveProperties(&structXML, pBase, pTemp, pMaster, dir);
|
SaveProperties(&structXML, pBase, pTemp, pMaster, dir);
|
||||||
structXML.LinkEndChild(pBase);
|
structXML.LinkEndChild(pBase);
|
||||||
|
|
||||||
structXML.SaveFile(outFile.c_str());
|
structXML.SaveFile(*outFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTemplateWriter::SaveEnumTemplate(CEnumTemplate *pTemp, const std::string& dir)
|
void CTemplateWriter::SaveEnumTemplate(CEnumTemplate *pTemp, const TString& dir)
|
||||||
{
|
{
|
||||||
// Create directory
|
// Create directory
|
||||||
std::string outFile = dir + pTemp->mSourceFile;
|
TString outFile = dir + pTemp->mSourceFile;
|
||||||
std::string outDir = StringUtil::GetFileDirectory(outFile);
|
TString outDir = outFile.GetFileDirectory();
|
||||||
std::string name = StringUtil::GetFileName(pTemp->mSourceFile);
|
TString name = pTemp->mSourceFile.GetFileName(false);
|
||||||
boost::filesystem::create_directory(outDir);
|
boost::filesystem::create_directory(*outDir);
|
||||||
|
|
||||||
// Create new document and write enumerators to it
|
// Create new document and write enumerators to it
|
||||||
XMLDocument enumXML;
|
XMLDocument enumXML;
|
||||||
|
@ -392,20 +392,20 @@ void CTemplateWriter::SaveEnumTemplate(CEnumTemplate *pTemp, const std::string&
|
||||||
enumXML.LinkEndChild(pDecl);
|
enumXML.LinkEndChild(pDecl);
|
||||||
|
|
||||||
XMLElement *pBase = enumXML.NewElement("enum");
|
XMLElement *pBase = enumXML.NewElement("enum");
|
||||||
pBase->SetName("name", name.c_str());
|
pBase->SetName("name", *name);
|
||||||
SaveEnumerators(&enumXML, pBase, pTemp);
|
SaveEnumerators(&enumXML, pBase, pTemp);
|
||||||
enumXML.LinkEndChild(pBase);
|
enumXML.LinkEndChild(pBase);
|
||||||
|
|
||||||
enumXML.SaveFile(outFile.c_str());
|
enumXML.SaveFile(*outFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTemplateWriter::SaveBitfieldTemplate(CBitfieldTemplate *pTemp, const std::string& dir)
|
void CTemplateWriter::SaveBitfieldTemplate(CBitfieldTemplate *pTemp, const TString& dir)
|
||||||
{
|
{
|
||||||
// Create directory
|
// Create directory
|
||||||
std::string outFile = dir + pTemp->mSourceFile;
|
TString outFile = dir + pTemp->mSourceFile;
|
||||||
std::string outDir = StringUtil::GetFileDirectory(outFile);
|
TString outDir = outFile.GetFileDirectory();
|
||||||
std::string name = StringUtil::GetFileName(pTemp->mSourceFile);
|
TString name = pTemp->mSourceFile.GetFileName();
|
||||||
boost::filesystem::create_directory(outDir);
|
boost::filesystem::create_directory(*outDir);
|
||||||
|
|
||||||
// Create new document and write enumerators to it
|
// Create new document and write enumerators to it
|
||||||
XMLDocument bitfieldXML;
|
XMLDocument bitfieldXML;
|
||||||
|
@ -414,47 +414,47 @@ void CTemplateWriter::SaveBitfieldTemplate(CBitfieldTemplate *pTemp, const std::
|
||||||
bitfieldXML.LinkEndChild(pDecl);
|
bitfieldXML.LinkEndChild(pDecl);
|
||||||
|
|
||||||
XMLElement *pBase = bitfieldXML.NewElement("bitfield");
|
XMLElement *pBase = bitfieldXML.NewElement("bitfield");
|
||||||
pBase->SetName("name", name.c_str());
|
pBase->SetName("name", *name);
|
||||||
SaveBitFlags(&bitfieldXML, pBase, pTemp);
|
SaveBitFlags(&bitfieldXML, pBase, pTemp);
|
||||||
bitfieldXML.LinkEndChild(pBase);
|
bitfieldXML.LinkEndChild(pBase);
|
||||||
|
|
||||||
bitfieldXML.SaveFile(outFile.c_str());
|
bitfieldXML.SaveFile(*outFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTemplateWriter::SaveProperties(XMLDocument *pDoc, XMLElement *pParent, CStructTemplate *pTemp, CMasterTemplate *pMaster, const std::string& dir)
|
void CTemplateWriter::SaveProperties(XMLDocument *pDoc, XMLElement *pParent, CStructTemplate *pTemp, CMasterTemplate *pMaster, const TString& dir)
|
||||||
{
|
{
|
||||||
for (u32 iProp = 0; iProp < pTemp->Count(); iProp++)
|
for (u32 iProp = 0; iProp < pTemp->Count(); iProp++)
|
||||||
{
|
{
|
||||||
CPropertyTemplate *pProp = pTemp->PropertyByIndex(iProp);
|
CPropertyTemplate *pProp = pTemp->PropertyByIndex(iProp);
|
||||||
u32 propID = (pProp->PropertyID() == 0xFFFFFFFF ? iProp : pProp->PropertyID());
|
u32 propID = (pProp->PropertyID() == 0xFFFFFFFF ? iProp : pProp->PropertyID());
|
||||||
std::string strID = StringUtil::ToHexString(propID, true, true, (propID > 0xFF ? 8 : 2));
|
TString strID = TString::HexString(propID, true, true, (propID > 0xFF ? 8 : 2));
|
||||||
|
|
||||||
if (pProp->Type() == eStructProperty)
|
if (pProp->Type() == eStructProperty)
|
||||||
{
|
{
|
||||||
CStructTemplate *pStructTemp = static_cast<CStructTemplate*>(pProp);
|
CStructTemplate *pStructTemp = static_cast<CStructTemplate*>(pProp);
|
||||||
bool isExternal = (!pStructTemp->mSourceFile.empty());
|
bool isExternal = (!pStructTemp->mSourceFile.IsEmpty());
|
||||||
|
|
||||||
XMLElement *pElem = pDoc->NewElement("struct");
|
XMLElement *pElem = pDoc->NewElement("struct");
|
||||||
pElem->SetAttribute("ID", strID.c_str());
|
pElem->SetAttribute("ID", *strID);
|
||||||
|
|
||||||
if ((!pMaster->HasPropertyList()) || (pProp->PropertyID() == -1) || pTemp->IsSingleProperty())
|
if ((!pMaster->HasPropertyList()) || (pProp->PropertyID() == -1) || pTemp->IsSingleProperty())
|
||||||
{
|
{
|
||||||
pElem->SetAttribute("name", pProp->Name().c_str());
|
pElem->SetAttribute("name", *pProp->Name());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isExternal) {
|
if (!isExternal) {
|
||||||
std::string type = pStructTemp->IsSingleProperty() ? "single" : "multi";
|
TString type = pStructTemp->IsSingleProperty() ? "single" : "multi";
|
||||||
pElem->SetAttribute("type", type.c_str());
|
pElem->SetAttribute("type", *type);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only save properties if this is a multi struct, or if there is no master property list
|
// Only save properties if this is a multi struct, or if there is no master property list
|
||||||
if (!pMaster->HasPropertyList() || !pStructTemp->IsSingleProperty())
|
if (!pMaster->HasPropertyList() || !pStructTemp->IsSingleProperty())
|
||||||
{
|
{
|
||||||
// Embed struct or save to external XML?
|
// Embed struct or save to external XML?
|
||||||
if (!pStructTemp->mSourceFile.empty())
|
if (!pStructTemp->mSourceFile.IsEmpty())
|
||||||
{
|
{
|
||||||
SaveStructTemplate(pStructTemp, pMaster, dir);
|
SaveStructTemplate(pStructTemp, pMaster, dir);
|
||||||
pElem->SetAttribute("template", pStructTemp->mSourceFile.c_str());
|
pElem->SetAttribute("template", *pStructTemp->mSourceFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
|
@ -469,18 +469,18 @@ void CTemplateWriter::SaveProperties(XMLDocument *pDoc, XMLElement *pParent, CSt
|
||||||
else if (pProp->Type() == eEnumProperty)
|
else if (pProp->Type() == eEnumProperty)
|
||||||
{
|
{
|
||||||
CEnumTemplate *pEnumTemp = static_cast<CEnumTemplate*>(pProp);
|
CEnumTemplate *pEnumTemp = static_cast<CEnumTemplate*>(pProp);
|
||||||
bool isExternal = (!pEnumTemp->mSourceFile.empty());
|
bool isExternal = (!pEnumTemp->mSourceFile.IsEmpty());
|
||||||
|
|
||||||
XMLElement *pElem = pDoc->NewElement("enum");
|
XMLElement *pElem = pDoc->NewElement("enum");
|
||||||
pElem->SetAttribute("ID", strID.c_str());
|
pElem->SetAttribute("ID", *strID);
|
||||||
|
|
||||||
if ((!pMaster->HasPropertyList()) || (pProp->PropertyID() == -1))
|
if ((!pMaster->HasPropertyList()) || (pProp->PropertyID() == -1))
|
||||||
pElem->SetAttribute("name", pProp->Name().c_str());
|
pElem->SetAttribute("name", *pProp->Name());
|
||||||
|
|
||||||
if (isExternal)
|
if (isExternal)
|
||||||
{
|
{
|
||||||
SaveEnumTemplate(pEnumTemp, dir);
|
SaveEnumTemplate(pEnumTemp, dir);
|
||||||
pElem->SetAttribute("template", pEnumTemp->mSourceFile.c_str());
|
pElem->SetAttribute("template", *pEnumTemp->mSourceFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
|
@ -493,18 +493,18 @@ void CTemplateWriter::SaveProperties(XMLDocument *pDoc, XMLElement *pParent, CSt
|
||||||
else if (pProp->Type() == eBitfieldProperty)
|
else if (pProp->Type() == eBitfieldProperty)
|
||||||
{
|
{
|
||||||
CBitfieldTemplate *pBitfieldTemp = static_cast<CBitfieldTemplate*>(pProp);
|
CBitfieldTemplate *pBitfieldTemp = static_cast<CBitfieldTemplate*>(pProp);
|
||||||
bool isExternal = (!pBitfieldTemp->mSourceFile.empty());
|
bool isExternal = (!pBitfieldTemp->mSourceFile.IsEmpty());
|
||||||
|
|
||||||
XMLElement *pElem = pDoc->NewElement("bitfield");
|
XMLElement *pElem = pDoc->NewElement("bitfield");
|
||||||
pElem->SetAttribute("ID", strID.c_str());
|
pElem->SetAttribute("ID", *strID);
|
||||||
|
|
||||||
if ((!pMaster->HasPropertyList()) || (pProp->PropertyID() == -1))
|
if ((!pMaster->HasPropertyList()) || (pProp->PropertyID() == -1))
|
||||||
pElem->SetAttribute("name", pProp->Name().c_str());
|
pElem->SetAttribute("name", *pProp->Name());
|
||||||
|
|
||||||
if (isExternal)
|
if (isExternal)
|
||||||
{
|
{
|
||||||
SaveBitfieldTemplate(pBitfieldTemp, dir);
|
SaveBitfieldTemplate(pBitfieldTemp, dir);
|
||||||
pElem->SetAttribute("template", pBitfieldTemp->mSourceFile.c_str());
|
pElem->SetAttribute("template", *pBitfieldTemp->mSourceFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
|
@ -517,20 +517,20 @@ void CTemplateWriter::SaveProperties(XMLDocument *pDoc, XMLElement *pParent, CSt
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
XMLElement *pElem = pDoc->NewElement("property");
|
XMLElement *pElem = pDoc->NewElement("property");
|
||||||
pElem->SetAttribute("ID", strID.c_str());
|
pElem->SetAttribute("ID", *strID);
|
||||||
|
|
||||||
if ((!pMaster->HasPropertyList()) || (pProp->PropertyID() == -1) || pTemp->IsSingleProperty())
|
if ((!pMaster->HasPropertyList()) || (pProp->PropertyID() == -1) || pTemp->IsSingleProperty())
|
||||||
{
|
{
|
||||||
pElem->SetAttribute("name", pProp->Name().c_str());
|
pElem->SetAttribute("name", *pProp->Name());
|
||||||
pElem->SetAttribute("type", PropEnumToPropString(pProp->Type()).c_str());
|
pElem->SetAttribute("type", *PropEnumToPropString(pProp->Type()));
|
||||||
|
|
||||||
if (pProp->Type() == eFileProperty)
|
if (pProp->Type() == eFileProperty)
|
||||||
{
|
{
|
||||||
// Construct extension list string
|
// Construct extension list string
|
||||||
CFileTemplate *pFileProp = static_cast<CFileTemplate*>(pProp);
|
CFileTemplate *pFileProp = static_cast<CFileTemplate*>(pProp);
|
||||||
const CStringList& extensions = pFileProp->Extensions();
|
const TStringList& extensions = pFileProp->Extensions();
|
||||||
|
|
||||||
std::string strList = "";
|
TString strList = "";
|
||||||
|
|
||||||
for (auto it = extensions.begin(); it != extensions.end();)
|
for (auto it = extensions.begin(); it != extensions.end();)
|
||||||
{
|
{
|
||||||
|
@ -539,7 +539,7 @@ void CTemplateWriter::SaveProperties(XMLDocument *pDoc, XMLElement *pParent, CSt
|
||||||
if (it != extensions.end()) strList += ",";
|
if (it != extensions.end()) strList += ",";
|
||||||
}
|
}
|
||||||
|
|
||||||
pElem->SetAttribute("ext", strList.c_str());
|
pElem->SetAttribute("ext", *strList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -553,8 +553,8 @@ void CTemplateWriter::SaveEnumerators(XMLDocument *pDoc, XMLElement *pParent, CE
|
||||||
for (u32 iEnum = 0; iEnum < pTemp->NumEnumerators(); iEnum++)
|
for (u32 iEnum = 0; iEnum < pTemp->NumEnumerators(); iEnum++)
|
||||||
{
|
{
|
||||||
XMLElement *pElem = pDoc->NewElement("enumerator");
|
XMLElement *pElem = pDoc->NewElement("enumerator");
|
||||||
pElem->SetAttribute("ID", StringUtil::ToHexString(pTemp->EnumeratorID(iEnum), true, true, 8).c_str());
|
pElem->SetAttribute("ID", *TString::HexString(pTemp->EnumeratorID(iEnum), true, true, 8));
|
||||||
pElem->SetAttribute("name", pTemp->EnumeratorName(iEnum).c_str());
|
pElem->SetAttribute("name", *pTemp->EnumeratorName(iEnum));
|
||||||
pParent->LinkEndChild(pElem);
|
pParent->LinkEndChild(pElem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -564,8 +564,8 @@ void CTemplateWriter::SaveBitFlags(tinyxml2::XMLDocument *pDoc, tinyxml2::XMLEle
|
||||||
for (u32 iFlag = 0; iFlag < pTemp->NumFlags(); iFlag++)
|
for (u32 iFlag = 0; iFlag < pTemp->NumFlags(); iFlag++)
|
||||||
{
|
{
|
||||||
XMLElement *pElem = pDoc->NewElement("bitflag");
|
XMLElement *pElem = pDoc->NewElement("bitflag");
|
||||||
pElem->SetAttribute("mask", StringUtil::ToHexString(pTemp->FlagMask(iFlag), true, true, 8).c_str());
|
pElem->SetAttribute("mask", *TString::HexString(pTemp->FlagMask(iFlag), true, true, 8));
|
||||||
pElem->SetAttribute("name", pTemp->FlagName(iFlag).c_str());
|
pElem->SetAttribute("name", *pTemp->FlagName(iFlag));
|
||||||
pParent->LinkEndChild(pElem);
|
pParent->LinkEndChild(pElem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,13 +10,13 @@ class CTemplateWriter
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void SaveAllTemplates();
|
static void SaveAllTemplates();
|
||||||
static void SaveGameTemplates(CMasterTemplate *pMaster, const std::string& dir);
|
static void SaveGameTemplates(CMasterTemplate *pMaster, const TString& dir);
|
||||||
static void SavePropertyList(CMasterTemplate *pMaster, const std::string& dir);
|
static void SavePropertyList(CMasterTemplate *pMaster, const TString& dir);
|
||||||
static void SaveScriptTemplate(CScriptTemplate *pTemp, const std::string& dir);
|
static void SaveScriptTemplate(CScriptTemplate *pTemp, const TString& dir);
|
||||||
static void SaveStructTemplate(CStructTemplate *pTemp, CMasterTemplate *pMaster, const std::string& dir);
|
static void SaveStructTemplate(CStructTemplate *pTemp, CMasterTemplate *pMaster, const TString& dir);
|
||||||
static void SaveEnumTemplate(CEnumTemplate *pTemp, const std::string& dir);
|
static void SaveEnumTemplate(CEnumTemplate *pTemp, const TString& dir);
|
||||||
static void SaveBitfieldTemplate(CBitfieldTemplate *pTemp, const std::string& dir);
|
static void SaveBitfieldTemplate(CBitfieldTemplate *pTemp, const TString& dir);
|
||||||
static void SaveProperties(tinyxml2::XMLDocument *pDoc, tinyxml2::XMLElement *pParent, CStructTemplate *pTemp, CMasterTemplate *pMaster, const std::string& dir);
|
static void SaveProperties(tinyxml2::XMLDocument *pDoc, tinyxml2::XMLElement *pParent, CStructTemplate *pTemp, CMasterTemplate *pMaster, const TString& dir);
|
||||||
static void SaveEnumerators(tinyxml2::XMLDocument *pDoc, tinyxml2::XMLElement *pParent, CEnumTemplate *pTemp);
|
static void SaveEnumerators(tinyxml2::XMLDocument *pDoc, tinyxml2::XMLElement *pParent, CEnumTemplate *pTemp);
|
||||||
static void SaveBitFlags(tinyxml2::XMLDocument *pDoc, tinyxml2::XMLElement *pParent, CBitfieldTemplate *pTemp);
|
static void SaveBitFlags(tinyxml2::XMLDocument *pDoc, tinyxml2::XMLElement *pParent, CBitfieldTemplate *pTemp);
|
||||||
};
|
};
|
||||||
|
|
|
@ -82,7 +82,7 @@ CAnimSet* CAnimSetLoader::LoadANCS(CInputStream& ANCS)
|
||||||
u32 magic = ANCS.ReadLong();
|
u32 magic = ANCS.ReadLong();
|
||||||
if (magic != 0x00010001)
|
if (magic != 0x00010001)
|
||||||
{
|
{
|
||||||
Log::FileError(ANCS.GetSourceString(), "Invalid ANCS magic: " + StringUtil::ToHexString(magic));
|
Log::FileError(ANCS.GetSourceString(), "Invalid ANCS magic: " + TString::HexString(magic));
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,6 +194,6 @@ CAnimSet* CAnimSetLoader::LoadCHAR(CInputStream &CHAR)
|
||||||
return loader.LoadReturnsCHAR(CHAR);
|
return loader.LoadReturnsCHAR(CHAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
Log::FileError(CHAR.GetSourceString(), "CHAR has invalid first byte: " + StringUtil::ToHexString(check));
|
Log::FileError(CHAR.GetSourceString(), "CHAR has invalid first byte: " + TString::HexString(check));
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -475,9 +475,9 @@ void CAreaLoader::Decompress()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Source = mpMREA->GetSourceString();
|
TString Source = mpMREA->GetSourceString();
|
||||||
mpMREA = new CMemoryInStream(mDecmpBuffer, mTotalDecmpSize, IOUtil::BigEndian);
|
mpMREA = new CMemoryInStream(mDecmpBuffer, mTotalDecmpSize, IOUtil::BigEndian);
|
||||||
mpMREA->SetSourceString(Source);
|
mpMREA->SetSourceString(Source.ToStdString());
|
||||||
mBlockMgr->SetInputStream(mpMREA);
|
mBlockMgr->SetInputStream(mpMREA);
|
||||||
mHasDecompressedBuffer = true;
|
mHasDecompressedBuffer = true;
|
||||||
}
|
}
|
||||||
|
@ -549,7 +549,7 @@ CGameArea* CAreaLoader::LoadMREA(CInputStream& MREA)
|
||||||
u32 deadbeef = MREA.ReadLong();
|
u32 deadbeef = MREA.ReadLong();
|
||||||
if (deadbeef != 0xdeadbeef)
|
if (deadbeef != 0xdeadbeef)
|
||||||
{
|
{
|
||||||
Log::FileError(MREA.GetSourceString(), "Invalid MREA magic: " + StringUtil::ToHexString(deadbeef));
|
Log::FileError(MREA.GetSourceString(), "Invalid MREA magic: " + TString::HexString(deadbeef));
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -592,7 +592,7 @@ CGameArea* CAreaLoader::LoadMREA(CInputStream& MREA)
|
||||||
if (Loader.mVersion == eCorruption) Loader.ReadLightsCorruption();
|
if (Loader.mVersion == eCorruption) Loader.ReadLightsCorruption();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Log::FileError(MREA.GetSourceString(), "Unsupported MREA version: " + StringUtil::ToHexString(version));
|
Log::FileError(MREA.GetSourceString(), "Unsupported MREA version: " + TString::HexString(version));
|
||||||
delete Loader.mpArea;
|
delete Loader.mpArea;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,7 +140,7 @@ CCollisionMeshGroup* CCollisionLoader::LoadAreaCollision(CInputStream& MREA)
|
||||||
u32 deafbabe = MREA.ReadLong();
|
u32 deafbabe = MREA.ReadLong();
|
||||||
if (deafbabe != 0xDEAFBABE)
|
if (deafbabe != 0xDEAFBABE)
|
||||||
{
|
{
|
||||||
Log::FileError(MREA.GetSourceString(), MREA.Tell() - 4, "Invalid collision magic: " + StringUtil::ToHexString(deafbabe));
|
Log::FileError(MREA.GetSourceString(), MREA.Tell() - 4, "Invalid collision magic: " + TString::HexString(deafbabe));
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,7 +177,7 @@ CCollisionMeshGroup* CCollisionLoader::LoadDCLN(CInputStream &DCLN)
|
||||||
|
|
||||||
if (deafbabe != 0xDEAFBABE)
|
if (deafbabe != 0xDEAFBABE)
|
||||||
{
|
{
|
||||||
Log::FileError(DCLN.GetSourceString(), DCLN.Tell() - 4, "Invalid collision magic: " + StringUtil::ToHexString(deafbabe));
|
Log::FileError(DCLN.GetSourceString(), DCLN.Tell() - 4, "Invalid collision magic: " + TString::HexString(deafbabe));
|
||||||
delete loader.mpGroup;
|
delete loader.mpGroup;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,7 +88,7 @@ CFont* CFontLoader::LoadFONT(CInputStream& FONT)
|
||||||
CFourCC Magic(FONT);
|
CFourCC Magic(FONT);
|
||||||
if (Magic != "FONT")
|
if (Magic != "FONT")
|
||||||
{
|
{
|
||||||
Log::FileError(FONT.GetSourceString(), "Invalid FONT magic: " + StringUtil::ToHexString((u32) Magic.ToLong()));
|
Log::FileError(FONT.GetSourceString(), "Invalid FONT magic: " + TString::HexString((u32) Magic.ToLong()));
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ CFont* CFontLoader::LoadFONT(CInputStream& FONT)
|
||||||
EGame Version = GetFormatVersion(FileVersion);
|
EGame Version = GetFormatVersion(FileVersion);
|
||||||
if (Version == eUnknownVersion)
|
if (Version == eUnknownVersion)
|
||||||
{
|
{
|
||||||
Log::FileError(FONT.GetSourceString(), "Unsupported FONT version: " + StringUtil::ToHexString(FileVersion));
|
Log::FileError(FONT.GetSourceString(), "Unsupported FONT version: " + TString::HexString(FileVersion));
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ void CMaterialLoader::ReadPrimeMatSet()
|
||||||
{
|
{
|
||||||
mpSet->mMaterials[iMat] = ReadPrimeMaterial();
|
mpSet->mMaterials[iMat] = ReadPrimeMaterial();
|
||||||
mpSet->mMaterials[iMat]->mVersion = mVersion;
|
mpSet->mMaterials[iMat]->mVersion = mVersion;
|
||||||
mpSet->mMaterials[iMat]->mName = std::string("Material #") + std::to_string(iMat + 1);
|
mpSet->mMaterials[iMat]->mName = TString("Material #") + std::to_string(iMat + 1);
|
||||||
mpFile->Seek(matsStart + offsets[iMat], SEEK_SET);
|
mpFile->Seek(matsStart + offsets[iMat], SEEK_SET);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -189,7 +189,7 @@ CMaterial* CMaterialLoader::ReadPrimeMaterial()
|
||||||
case 6: // Model Matrix
|
case 6: // Model Matrix
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Log::FileError(mpFile->GetSourceString(), mpFile->Tell() - 4, "Unsupported animation mode encountered: " + StringUtil::ToHexString((u32) Anims[iAnim].Mode));
|
Log::FileError(mpFile->GetSourceString(), mpFile->Tell() - 4, "Unsupported animation mode encountered: " + TString::HexString((u32) Anims[iAnim].Mode));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -240,7 +240,7 @@ void CMaterialLoader::ReadCorruptionMatSet()
|
||||||
u32 Next = mpFile->Tell() + Size;
|
u32 Next = mpFile->Tell() + Size;
|
||||||
mpSet->mMaterials[iMat] = ReadCorruptionMaterial();
|
mpSet->mMaterials[iMat] = ReadCorruptionMaterial();
|
||||||
mpSet->mMaterials[iMat]->mVersion = mVersion;
|
mpSet->mMaterials[iMat]->mVersion = mVersion;
|
||||||
mpSet->mMaterials[iMat]->mName = std::string("Material #") + std::to_string(iMat + 1);
|
mpSet->mMaterials[iMat]->mName = TString("Material #") + std::to_string(iMat + 1);
|
||||||
mpFile->Seek(Next, SEEK_SET);
|
mpFile->Seek(Next, SEEK_SET);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -378,7 +378,7 @@ CMaterial* CMaterialLoader::ReadCorruptionMaterial()
|
||||||
case 10: // Yet-to-be-named
|
case 10: // Yet-to-be-named
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Log::FileError(mpFile->GetSourceString(), mpFile->Tell() - 8, "Unsupported animation mode encountered: " + StringUtil::ToHexString((u32) pPass->mAnimMode));
|
Log::FileError(mpFile->GetSourceString(), mpFile->Tell() - 8, "Unsupported animation mode encountered: " + TString::HexString((u32) pPass->mAnimMode));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -432,7 +432,7 @@ CModel* CModelLoader::LoadCMDL(CInputStream& CMDL)
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log::FileError(CMDL.GetSourceString(), "Invalid CMDL magic: " + StringUtil::ToHexString(Magic));
|
Log::FileError(CMDL.GetSourceString(), "Invalid CMDL magic: " + TString::HexString(Magic));
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -441,7 +441,7 @@ CModel* CModelLoader::LoadCMDL(CInputStream& CMDL)
|
||||||
|
|
||||||
if (Loader.mVersion == eUnknownVersion)
|
if (Loader.mVersion == eUnknownVersion)
|
||||||
{
|
{
|
||||||
Log::FileError(CMDL.GetSourceString(), "Unsupported CMDL version: " + StringUtil::ToHexString(Magic));
|
Log::FileError(CMDL.GetSourceString(), "Unsupported CMDL version: " + TString::HexString(Magic));
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ CScan* CScanLoader::LoadScanMP2(CInputStream& SCAN)
|
||||||
|
|
||||||
u32 BasePropID = SCAN.ReadLong();
|
u32 BasePropID = SCAN.ReadLong();
|
||||||
if (BasePropID != 0xFFFFFFFF) {
|
if (BasePropID != 0xFFFFFFFF) {
|
||||||
Log::FileError(SCAN.GetSourceString(), SCAN.Tell() - 4, "Invalid base proprty ID: " + StringUtil::ToHexString(BasePropID));
|
Log::FileError(SCAN.GetSourceString(), SCAN.Tell() - 4, "Invalid base proprty ID: " + TString::HexString(BasePropID));
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ CScan* CScanLoader::LoadScanMP2(CInputStream& SCAN)
|
||||||
LoadParamsMP3(SCAN);
|
LoadParamsMP3(SCAN);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Log::FileError(SCAN.GetSourceString(), SCAN.Tell() - 2, "Invalid SNFO property count: " + StringUtil::ToHexString(NumProperties));
|
Log::FileError(SCAN.GetSourceString(), SCAN.Tell() - 2, "Invalid SNFO property count: " + TString::HexString(NumProperties));
|
||||||
delete mpScan;
|
delete mpScan;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -164,13 +164,13 @@ CScan* CScanLoader::LoadSCAN(CInputStream &SCAN)
|
||||||
|
|
||||||
if (magic != 0x0BADBEEF)
|
if (magic != 0x0BADBEEF)
|
||||||
{
|
{
|
||||||
Log::FileError(SCAN.GetSourceString(), "Invalid SCAN magic: " + StringUtil::ToHexString(magic));
|
Log::FileError(SCAN.GetSourceString(), "Invalid SCAN magic: " + TString::HexString(magic));
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fileVersion != 5)
|
if (fileVersion != 5)
|
||||||
{
|
{
|
||||||
Log::FileError(SCAN.GetSourceString(), "Unsupported SCAN version: " + StringUtil::ToHexString(fileVersion));
|
Log::FileError(SCAN.GetSourceString(), "Unsupported SCAN version: " + TString::HexString(fileVersion));
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@ CPropertyStruct* CScriptLoader::LoadStructMP1(CInputStream& SCLY, CStructTemplat
|
||||||
mask |= pBitfieldTemp->FlagMask(iMask);
|
mask |= pBitfieldTemp->FlagMask(iMask);
|
||||||
|
|
||||||
u32 check = v & ~mask;
|
u32 check = v & ~mask;
|
||||||
if (check != 0) Log::FileWarning(SCLY.GetSourceString(), SCLY.Tell() - 4, "Bitfield property \"" + pBitfieldTemp->Name() + "\" in struct \"" + pTemp->Name() + "\" has flags set that aren't in the template: " + StringUtil::ToHexString(check, true, true, 8));
|
if (check != 0) Log::FileWarning(SCLY.GetSourceString(), SCLY.Tell() - 4, "Bitfield property \"" + pBitfieldTemp->Name() + "\" in struct \"" + pTemp->Name() + "\" has flags set that aren't in the template: " + TString::HexString(check, true, true, 8));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ CPropertyStruct* CScriptLoader::LoadStructMP1(CInputStream& SCLY, CStructTemplat
|
||||||
CEnumTemplate *pEnumTemp = static_cast<CEnumTemplate*>(pPropTmp);
|
CEnumTemplate *pEnumTemp = static_cast<CEnumTemplate*>(pPropTmp);
|
||||||
u32 ID = SCLY.ReadLong();
|
u32 ID = SCLY.ReadLong();
|
||||||
u32 index = pEnumTemp->EnumeratorIndex(ID);
|
u32 index = pEnumTemp->EnumeratorIndex(ID);
|
||||||
if (index == -1) Log::FileError(SCLY.GetSourceString(), SCLY.Tell() - 4, "Enum property \"" + pEnumTemp->Name() + "\" in struct \"" + pTemp->Name() + "\" has invalid enumerator value: " + StringUtil::ToHexString(ID, true, true, 8));
|
if (index == -1) Log::FileError(SCLY.GetSourceString(), SCLY.Tell() - 4, "Enum property \"" + pEnumTemp->Name() + "\" in struct \"" + pTemp->Name() + "\" has invalid enumerator value: " + TString::HexString(ID, true, true, 8));
|
||||||
pProp = new CEnumProperty(index);
|
pProp = new CEnumProperty(index);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ CPropertyStruct* CScriptLoader::LoadStructMP1(CInputStream& SCLY, CStructTemplat
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case eStringProperty: {
|
case eStringProperty: {
|
||||||
std::string v = SCLY.ReadString();
|
TString v = SCLY.ReadString();
|
||||||
pProp = new CStringProperty(v);
|
pProp = new CStringProperty(v);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -104,13 +104,13 @@ CPropertyStruct* CScriptLoader::LoadStructMP1(CInputStream& SCLY, CStructTemplat
|
||||||
}
|
}
|
||||||
case eFileProperty: {
|
case eFileProperty: {
|
||||||
u32 ResID = SCLY.ReadLong();
|
u32 ResID = SCLY.ReadLong();
|
||||||
const CStringList& Extensions = static_cast<CFileTemplate*>(pPropTmp)->Extensions();
|
const TStringList& Extensions = static_cast<CFileTemplate*>(pPropTmp)->Extensions();
|
||||||
|
|
||||||
CResource *pRes = nullptr;
|
CResource *pRes = nullptr;
|
||||||
|
|
||||||
for (auto it = Extensions.begin(); it != Extensions.end(); it++)
|
for (auto it = Extensions.begin(); it != Extensions.end(); it++)
|
||||||
{
|
{
|
||||||
const std::string& ext = *it;
|
const TString& ext = *it;
|
||||||
if ((ext != "MREA") && (ext != "MLVL")) // Let's avoid recursion please
|
if ((ext != "MREA") && (ext != "MLVL")) // Let's avoid recursion please
|
||||||
pRes = gResCache.GetResource(ResID, ext);
|
pRes = gResCache.GetResource(ResID, ext);
|
||||||
|
|
||||||
|
@ -155,7 +155,7 @@ CScriptObject* CScriptLoader::LoadObjectMP1(CInputStream& SCLY)
|
||||||
if (!pTemp)
|
if (!pTemp)
|
||||||
{
|
{
|
||||||
// No valid template for this object; can't load
|
// No valid template for this object; can't load
|
||||||
Log::FileError(SCLY.GetSourceString(), objStart, "Invalid object ID encountered: " + StringUtil::ToHexString(type));
|
Log::FileError(SCLY.GetSourceString(), objStart, "Invalid object ID encountered: " + TString::HexString(type));
|
||||||
SCLY.Seek(end, SEEK_SET);
|
SCLY.Seek(end, SEEK_SET);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -181,7 +181,7 @@ CScriptObject* CScriptLoader::LoadObjectMP1(CInputStream& SCLY)
|
||||||
CStructTemplate *pBase = pTemp->BaseStructByCount(count);
|
CStructTemplate *pBase = pTemp->BaseStructByCount(count);
|
||||||
|
|
||||||
if (!pBase) {
|
if (!pBase) {
|
||||||
Log::Error(pTemp->TemplateName() + " template doesn't match file property count (" + StringUtil::ToString(count) + ")");
|
Log::Error(pTemp->TemplateName() + " template doesn't match file property count (" + TString::FromInt32(count) + ")");
|
||||||
pBase = pTemp->BaseStructByIndex(0);
|
pBase = pTemp->BaseStructByIndex(0);
|
||||||
}
|
}
|
||||||
mpObj->mpProperties = LoadStructMP1(SCLY, pBase);
|
mpObj->mpProperties = LoadStructMP1(SCLY, pBase);
|
||||||
|
@ -257,7 +257,7 @@ void CScriptLoader::LoadStructMP2(CInputStream& SCLY, CPropertyStruct *pStruct,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pPropTemp)
|
if (!pPropTemp)
|
||||||
Log::FileError(SCLY.GetSourceString(), propertyStart, "Can't find template for property " + StringUtil::ToHexString(propertyID) + " - skipping");
|
Log::FileError(SCLY.GetSourceString(), propertyStart, "Can't find template for property " + TString::HexString(propertyID) + " - skipping");
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -299,7 +299,7 @@ void CScriptLoader::LoadStructMP2(CInputStream& SCLY, CPropertyStruct *pStruct,
|
||||||
mask |= pBitfieldTemp->FlagMask(iMask);
|
mask |= pBitfieldTemp->FlagMask(iMask);
|
||||||
|
|
||||||
u32 check = pBitfieldCast->Get() & ~mask;
|
u32 check = pBitfieldCast->Get() & ~mask;
|
||||||
if (check != 0) Log::FileWarning(SCLY.GetSourceString(), SCLY.Tell() - 4, "Bitfield property \"" + pBitfieldTemp->Name() + "\" in struct \"" + pTemp->Name() + "\" has flags set that aren't in the template: " + StringUtil::ToHexString(check, true, true, 8));
|
if (check != 0) Log::FileWarning(SCLY.GetSourceString(), SCLY.Tell() - 4, "Bitfield property \"" + pBitfieldTemp->Name() + "\" in struct \"" + pTemp->Name() + "\" has flags set that aren't in the template: " + TString::HexString(check, true, true, 8));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -309,7 +309,7 @@ void CScriptLoader::LoadStructMP2(CInputStream& SCLY, CPropertyStruct *pStruct,
|
||||||
CEnumTemplate *pEnumTemp = static_cast<CEnumTemplate*>(pPropTemp);
|
CEnumTemplate *pEnumTemp = static_cast<CEnumTemplate*>(pPropTemp);
|
||||||
u32 ID = SCLY.ReadLong();
|
u32 ID = SCLY.ReadLong();
|
||||||
u32 index = pEnumTemp->EnumeratorIndex(ID);
|
u32 index = pEnumTemp->EnumeratorIndex(ID);
|
||||||
if (index == -1) Log::FileError(SCLY.GetSourceString(), SCLY.Tell() - 4, "Enum property \"" + pEnumTemp->Name() + "\" in struct \"" + pTemp->Name() + "\" has invalid enumerator value: " + StringUtil::ToHexString(ID, true, true, 8));
|
if (index == -1) Log::FileError(SCLY.GetSourceString(), SCLY.Tell() - 4, "Enum property \"" + pEnumTemp->Name() + "\" in struct \"" + pTemp->Name() + "\" has invalid enumerator value: " + TString::HexString(ID, true, true, 8));
|
||||||
pEnumCast->Set(index);
|
pEnumCast->Set(index);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -343,7 +343,7 @@ void CScriptLoader::LoadStructMP2(CInputStream& SCLY, CPropertyStruct *pStruct,
|
||||||
CFileProperty *pFileCast = static_cast<CFileProperty*>(pProp);
|
CFileProperty *pFileCast = static_cast<CFileProperty*>(pProp);
|
||||||
|
|
||||||
CUniqueID ResID = (mVersion < eCorruptionProto ? SCLY.ReadLong() : SCLY.ReadLongLong());
|
CUniqueID ResID = (mVersion < eCorruptionProto ? SCLY.ReadLong() : SCLY.ReadLongLong());
|
||||||
const CStringList& Extensions = static_cast<CFileTemplate*>(pPropTemp)->Extensions();
|
const TStringList& Extensions = static_cast<CFileTemplate*>(pPropTemp)->Extensions();
|
||||||
|
|
||||||
CResource *pRes = nullptr;
|
CResource *pRes = nullptr;
|
||||||
|
|
||||||
|
@ -356,7 +356,7 @@ void CScriptLoader::LoadStructMP2(CInputStream& SCLY, CPropertyStruct *pStruct,
|
||||||
{
|
{
|
||||||
for (auto it = Extensions.begin(); it != Extensions.end(); it++)
|
for (auto it = Extensions.begin(); it != Extensions.end(); it++)
|
||||||
{
|
{
|
||||||
const std::string& ext = *it;
|
const TString& ext = *it;
|
||||||
|
|
||||||
if ((ext != "MREA") && (ext != "MLVL")) {
|
if ((ext != "MREA") && (ext != "MLVL")) {
|
||||||
pRes = gResCache.GetResource(ResID, ext);
|
pRes = gResCache.GetResource(ResID, ext);
|
||||||
|
@ -371,13 +371,13 @@ void CScriptLoader::LoadStructMP2(CInputStream& SCLY, CPropertyStruct *pStruct,
|
||||||
// Property may have an incorrect extension listed - print error
|
// Property may have an incorrect extension listed - print error
|
||||||
if ((!pRes) && (CUniqueID(ResID).IsValid()) && (!hasIgnoredExt))
|
if ((!pRes) && (CUniqueID(ResID).IsValid()) && (!hasIgnoredExt))
|
||||||
{
|
{
|
||||||
std::string ExtList;
|
TString ExtList;
|
||||||
for (auto it = Extensions.begin(); it != Extensions.end(); it++)
|
for (auto it = Extensions.begin(); it != Extensions.end(); it++)
|
||||||
{
|
{
|
||||||
if (it != Extensions.begin()) ExtList += "/";
|
if (it != Extensions.begin()) ExtList += "/";
|
||||||
ExtList += *it;
|
ExtList += *it;
|
||||||
}
|
}
|
||||||
Log::FileWarning(SCLY.GetSourceString(), "Incorrect resource type? " + ExtList + " " + StringUtil::ToHexString(propertyID));
|
Log::FileWarning(SCLY.GetSourceString(), "Incorrect resource type? " + ExtList + " " + TString::HexString(propertyID));
|
||||||
}
|
}
|
||||||
|
|
||||||
pFileCast->Set(pRes);
|
pFileCast->Set(pRes);
|
||||||
|
@ -474,7 +474,7 @@ CScriptLayer* CScriptLoader::LoadLayerMP2(CInputStream& SCLY)
|
||||||
else if (SCLY_Magic == "SCGN") SCLY.Seek(0x2, SEEK_CUR);
|
else if (SCLY_Magic == "SCGN") SCLY.Seek(0x2, SEEK_CUR);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log::FileError(SCLY.GetSourceString(), SCLY.Tell() - 4, "Invalid script layer magic: " + StringUtil::ToHexString((u32) SCLY_Magic.ToLong()));
|
Log::FileError(SCLY.GetSourceString(), SCLY.Tell() - 4, "Invalid script layer magic: " + TString::HexString((u32) SCLY_Magic.ToLong()));
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -121,7 +121,7 @@ void CStringLoader::LoadCorruptionSTRG(CInputStream& STRG)
|
||||||
STRG.Seek(StringsStart + LangOffsets[iLang][iStr], SEEK_SET);
|
STRG.Seek(StringsStart + LangOffsets[iLang][iStr], SEEK_SET);
|
||||||
STRG.Seek(0x4, SEEK_CUR); // Skipping string size
|
STRG.Seek(0x4, SEEK_CUR); // Skipping string size
|
||||||
|
|
||||||
pLang->Strings[iStr] = StringUtil::UTF8to16(STRG.ReadString());
|
pLang->Strings[iStr] = STRG.ReadString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -180,7 +180,7 @@ CStringTable* CStringLoader::LoadSTRG(CInputStream& STRG)
|
||||||
|
|
||||||
if (Version != ePrimeDemo)
|
if (Version != ePrimeDemo)
|
||||||
{
|
{
|
||||||
Log::FileError(STRG.GetSourceString(), "Invalid STRG magic: " + StringUtil::ToHexString(Magic));
|
Log::FileError(STRG.GetSourceString(), "Invalid STRG magic: " + TString::HexString(Magic));
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -192,7 +192,7 @@ CStringTable* CStringLoader::LoadSTRG(CInputStream& STRG)
|
||||||
|
|
||||||
if (FileVersion == eUnknownVersion)
|
if (FileVersion == eUnknownVersion)
|
||||||
{
|
{
|
||||||
Log::FileError(STRG.GetSourceString(), "Unsupported STRG version: " + StringUtil::ToHexString(FileVersion));
|
Log::FileError(STRG.GetSourceString(), "Unsupported STRG version: " + TString::HexString(FileVersion));
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#include "CWorldLoader.h"
|
#include "CWorldLoader.h"
|
||||||
#include <Core/Log.h>
|
#include <Core/Log.h>
|
||||||
|
|
||||||
void CTemplateLoader::LoadBitFlags(tinyxml2::XMLElement *pElem, CBitfieldTemplate *pTemp, const std::string& templateName)
|
void CTemplateLoader::LoadBitFlags(tinyxml2::XMLElement *pElem, CBitfieldTemplate *pTemp, const TString& templateName)
|
||||||
{
|
{
|
||||||
tinyxml2::XMLElement *pChild = pElem->FirstChildElement("bitflag");
|
tinyxml2::XMLElement *pChild = pElem->FirstChildElement("bitflag");
|
||||||
|
|
||||||
|
@ -12,11 +12,11 @@ void CTemplateLoader::LoadBitFlags(tinyxml2::XMLElement *pElem, CBitfieldTemplat
|
||||||
const char *kpName = pChild->Attribute("name");
|
const char *kpName = pChild->Attribute("name");
|
||||||
|
|
||||||
if (kpMask && kpName)
|
if (kpMask && kpName)
|
||||||
pTemp->mBitFlags.push_back(CBitfieldTemplate::SBitFlag(kpName, StringUtil::ToInt32(kpMask)));
|
pTemp->mBitFlags.push_back(CBitfieldTemplate::SBitFlag(kpName, TString(kpMask).ToInt32()));
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::string LogErrorBase = "Couldn't parse bit flag in " + templateName + "; ";
|
TString LogErrorBase = "Couldn't parse bit flag in " + templateName + "; ";
|
||||||
|
|
||||||
if (!kpMask && kpName) Log::Error(LogErrorBase + "no mask (" + kpName + ")");
|
if (!kpMask && kpName) Log::Error(LogErrorBase + "no mask (" + kpName + ")");
|
||||||
else if (kpMask && !kpName) Log::Error(LogErrorBase + "no name (mask " + kpMask + ")");
|
else if (kpMask && !kpName) Log::Error(LogErrorBase + "no name (mask " + kpMask + ")");
|
||||||
|
@ -27,7 +27,7 @@ void CTemplateLoader::LoadBitFlags(tinyxml2::XMLElement *pElem, CBitfieldTemplat
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTemplateLoader::LoadEnumerators(tinyxml2::XMLElement *pElem, CEnumTemplate *pTemp, const std::string& templateName)
|
void CTemplateLoader::LoadEnumerators(tinyxml2::XMLElement *pElem, CEnumTemplate *pTemp, const TString& templateName)
|
||||||
{
|
{
|
||||||
tinyxml2::XMLElement *pChild = pElem->FirstChildElement("enumerator");
|
tinyxml2::XMLElement *pChild = pElem->FirstChildElement("enumerator");
|
||||||
|
|
||||||
|
@ -37,11 +37,11 @@ void CTemplateLoader::LoadEnumerators(tinyxml2::XMLElement *pElem, CEnumTemplate
|
||||||
const char *kpName = pChild->Attribute("name");
|
const char *kpName = pChild->Attribute("name");
|
||||||
|
|
||||||
if (kpID && kpName)
|
if (kpID && kpName)
|
||||||
pTemp->mEnumerators.push_back(CEnumTemplate::SEnumerator(kpName, StringUtil::ToInt32(kpID)));
|
pTemp->mEnumerators.push_back(CEnumTemplate::SEnumerator(kpName, TString(kpID).ToInt32()));
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::string LogErrorBase = "Couldn't parse enumerator in " + templateName + "; ";
|
TString LogErrorBase = "Couldn't parse enumerator in " + templateName + "; ";
|
||||||
|
|
||||||
if (!kpID && kpName) Log::Error(LogErrorBase + "no valid ID (" + kpName + ")");
|
if (!kpID && kpName) Log::Error(LogErrorBase + "no valid ID (" + kpName + ")");
|
||||||
else if (kpID && !kpName) Log::Error(LogErrorBase + "no valid name (ID " + kpID + ")");
|
else if (kpID && !kpName) Log::Error(LogErrorBase + "no valid name (ID " + kpID + ")");
|
||||||
|
@ -52,7 +52,7 @@ void CTemplateLoader::LoadEnumerators(tinyxml2::XMLElement *pElem, CEnumTemplate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTemplateLoader::LoadStructProperties(tinyxml2::XMLElement *pElem, CStructTemplate *pTemp, const std::string& templateName)
|
void CTemplateLoader::LoadStructProperties(tinyxml2::XMLElement *pElem, CStructTemplate *pTemp, const TString& templateName)
|
||||||
{
|
{
|
||||||
tinyxml2::XMLElement *pChild = pElem->FirstChildElement();
|
tinyxml2::XMLElement *pChild = pElem->FirstChildElement();
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ void CTemplateLoader::LoadStructProperties(tinyxml2::XMLElement *pElem, CStructT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CPropertyTemplate* CTemplateLoader::LoadPropertyTemplate(tinyxml2::XMLElement *pElem, const std::string& templateName)
|
CPropertyTemplate* CTemplateLoader::LoadPropertyTemplate(tinyxml2::XMLElement *pElem, const TString& templateName)
|
||||||
{
|
{
|
||||||
const char *kpIDStr = pElem->Attribute("ID");
|
const char *kpIDStr = pElem->Attribute("ID");
|
||||||
const char *kpNameStr = pElem->Attribute("name");
|
const char *kpNameStr = pElem->Attribute("name");
|
||||||
|
@ -76,9 +76,9 @@ CPropertyTemplate* CTemplateLoader::LoadPropertyTemplate(tinyxml2::XMLElement *p
|
||||||
const char *kpTemplateStr = pElem->Attribute("template");
|
const char *kpTemplateStr = pElem->Attribute("template");
|
||||||
|
|
||||||
// Get ID + name, find source template if it exists
|
// Get ID + name, find source template if it exists
|
||||||
u32 ID = StringUtil::ToInt32(kpIDStr);
|
u32 ID = TString(kpIDStr).ToInt32();
|
||||||
CPropertyTemplate *pSource = nullptr;
|
CPropertyTemplate *pSource = nullptr;
|
||||||
std::string name;
|
TString name;
|
||||||
|
|
||||||
if (mpMaster->HasPropertyList())
|
if (mpMaster->HasPropertyList())
|
||||||
pSource = mpMaster->GetProperty(ID);
|
pSource = mpMaster->GetProperty(ID);
|
||||||
|
@ -88,7 +88,7 @@ CPropertyTemplate* CTemplateLoader::LoadPropertyTemplate(tinyxml2::XMLElement *p
|
||||||
else if (pSource)
|
else if (pSource)
|
||||||
name = pSource->Name();
|
name = pSource->Name();
|
||||||
else
|
else
|
||||||
name = StringUtil::ToHexString(ID);
|
name = TString::HexString(ID);
|
||||||
|
|
||||||
// Load Property
|
// Load Property
|
||||||
if (strcmp(pElem->Name(), "property") == 0)
|
if (strcmp(pElem->Name(), "property") == 0)
|
||||||
|
@ -105,9 +105,9 @@ CPropertyTemplate* CTemplateLoader::LoadPropertyTemplate(tinyxml2::XMLElement *p
|
||||||
// File property
|
// File property
|
||||||
if (type == eFileProperty)
|
if (type == eFileProperty)
|
||||||
{
|
{
|
||||||
CStringList extensions;
|
TStringList extensions;
|
||||||
if (kpExtensionsStr)
|
if (kpExtensionsStr)
|
||||||
extensions = StringUtil::Tokenize(kpExtensionsStr, ",");
|
extensions = TString(kpExtensionsStr).Split(",");
|
||||||
else if (pSource)
|
else if (pSource)
|
||||||
extensions = static_cast<CFileTemplate*>(pSource)->Extensions();
|
extensions = static_cast<CFileTemplate*>(pSource)->Extensions();
|
||||||
|
|
||||||
|
@ -138,10 +138,10 @@ CPropertyTemplate* CTemplateLoader::LoadPropertyTemplate(tinyxml2::XMLElement *p
|
||||||
// Template
|
// Template
|
||||||
else if (kpTemplateStr)
|
else if (kpTemplateStr)
|
||||||
{
|
{
|
||||||
std::string tempPath = mMasterDir + kpTemplateStr;
|
TString tempPath = mMasterDir + kpTemplateStr;
|
||||||
|
|
||||||
tinyxml2::XMLDocument structXML;
|
tinyxml2::XMLDocument structXML;
|
||||||
structXML.LoadFile(tempPath.c_str());
|
structXML.LoadFile(*tempPath);
|
||||||
|
|
||||||
if (structXML.Error())
|
if (structXML.Error())
|
||||||
Log::Error("Couldn't open struct XML: " + mMasterDir + kpTemplateStr);
|
Log::Error("Couldn't open struct XML: " + mMasterDir + kpTemplateStr);
|
||||||
|
@ -179,7 +179,7 @@ CPropertyTemplate* CTemplateLoader::LoadPropertyTemplate(tinyxml2::XMLElement *p
|
||||||
pStruct->mIsSingleProperty = static_cast<CStructTemplate*>(pSource)->IsSingleProperty();
|
pStruct->mIsSingleProperty = static_cast<CStructTemplate*>(pSource)->IsSingleProperty();
|
||||||
|
|
||||||
// Name
|
// Name
|
||||||
if (!name.empty())
|
if (!name.IsEmpty())
|
||||||
pStruct->mPropName = name;
|
pStruct->mPropName = name;
|
||||||
|
|
||||||
return pStruct;
|
return pStruct;
|
||||||
|
@ -200,10 +200,10 @@ CPropertyTemplate* CTemplateLoader::LoadPropertyTemplate(tinyxml2::XMLElement *p
|
||||||
// Template
|
// Template
|
||||||
else if (kpTemplateStr)
|
else if (kpTemplateStr)
|
||||||
{
|
{
|
||||||
std::string tempPath = mMasterDir + kpTemplateStr;
|
TString tempPath = mMasterDir + kpTemplateStr;
|
||||||
|
|
||||||
tinyxml2::XMLDocument enumXML;
|
tinyxml2::XMLDocument enumXML;
|
||||||
enumXML.LoadFile(tempPath.c_str());
|
enumXML.LoadFile(*tempPath);
|
||||||
|
|
||||||
if (enumXML.Error())
|
if (enumXML.Error())
|
||||||
Log::Error("Couldn't open enum XML: " + mMasterDir + kpTemplateStr);
|
Log::Error("Couldn't open enum XML: " + mMasterDir + kpTemplateStr);
|
||||||
|
@ -221,7 +221,7 @@ CPropertyTemplate* CTemplateLoader::LoadPropertyTemplate(tinyxml2::XMLElement *p
|
||||||
}
|
}
|
||||||
|
|
||||||
// Name
|
// Name
|
||||||
if (!name.empty())
|
if (!name.IsEmpty())
|
||||||
pEnum->mPropName = name;
|
pEnum->mPropName = name;
|
||||||
|
|
||||||
return pEnum;
|
return pEnum;
|
||||||
|
@ -240,10 +240,10 @@ CPropertyTemplate* CTemplateLoader::LoadPropertyTemplate(tinyxml2::XMLElement *p
|
||||||
// Template
|
// Template
|
||||||
else if (kpTemplateStr)
|
else if (kpTemplateStr)
|
||||||
{
|
{
|
||||||
std::string tempPath = mMasterDir + kpTemplateStr;
|
TString tempPath = mMasterDir + kpTemplateStr;
|
||||||
|
|
||||||
tinyxml2::XMLDocument bitfieldXML;
|
tinyxml2::XMLDocument bitfieldXML;
|
||||||
bitfieldXML.LoadFile(tempPath.c_str());
|
bitfieldXML.LoadFile(*tempPath);
|
||||||
|
|
||||||
if (bitfieldXML.Error())
|
if (bitfieldXML.Error())
|
||||||
Log::Error("Couldn't open bitfield XML: " + mMasterDir + kpTemplateStr);
|
Log::Error("Couldn't open bitfield XML: " + mMasterDir + kpTemplateStr);
|
||||||
|
@ -261,7 +261,7 @@ CPropertyTemplate* CTemplateLoader::LoadPropertyTemplate(tinyxml2::XMLElement *p
|
||||||
}
|
}
|
||||||
|
|
||||||
// Name
|
// Name
|
||||||
if (!name.empty())
|
if (!name.IsEmpty())
|
||||||
pBitfield->mPropName = name;
|
pBitfield->mPropName = name;
|
||||||
|
|
||||||
return pBitfield;
|
return pBitfield;
|
||||||
|
@ -270,7 +270,7 @@ CPropertyTemplate* CTemplateLoader::LoadPropertyTemplate(tinyxml2::XMLElement *p
|
||||||
}
|
}
|
||||||
|
|
||||||
// ************ SCRIPT OBJECT ************
|
// ************ SCRIPT OBJECT ************
|
||||||
CScriptTemplate* CTemplateLoader::LoadScriptTemplate(tinyxml2::XMLDocument *pDoc, const std::string& templateName, u32 objectID)
|
CScriptTemplate* CTemplateLoader::LoadScriptTemplate(tinyxml2::XMLDocument *pDoc, const TString& templateName, u32 objectID)
|
||||||
{
|
{
|
||||||
CScriptTemplate *pScript = new CScriptTemplate(mpMaster);
|
CScriptTemplate *pScript = new CScriptTemplate(mpMaster);
|
||||||
pScript->mObjectID = objectID;
|
pScript->mObjectID = objectID;
|
||||||
|
@ -372,7 +372,7 @@ CScriptTemplate* CTemplateLoader::LoadScriptTemplate(tinyxml2::XMLDocument *pDoc
|
||||||
|
|
||||||
const char *kpForce = pAsset->Attribute("force");
|
const char *kpForce = pAsset->Attribute("force");
|
||||||
if (kpForce)
|
if (kpForce)
|
||||||
asset.ForceNodeIndex = StringUtil::ToInt32(kpForce);
|
asset.ForceNodeIndex = TString(kpForce).ToInt32();
|
||||||
else
|
else
|
||||||
asset.ForceNodeIndex = -1;
|
asset.ForceNodeIndex = -1;
|
||||||
|
|
||||||
|
@ -459,7 +459,7 @@ CScriptTemplate* CTemplateLoader::LoadScriptTemplate(tinyxml2::XMLDocument *pDoc
|
||||||
else if (strcmp(kpConditionValue, "false") == 0)
|
else if (strcmp(kpConditionValue, "false") == 0)
|
||||||
condition.Value = 0;
|
condition.Value = 0;
|
||||||
else
|
else
|
||||||
condition.Value = StringUtil::ToInt32(kpConditionValue);
|
condition.Value = TString(kpConditionValue).ToInt32();
|
||||||
|
|
||||||
pScript->mVolumeConditions.push_back(condition);
|
pScript->mVolumeConditions.push_back(condition);
|
||||||
}
|
}
|
||||||
|
@ -478,7 +478,7 @@ CScriptTemplate* CTemplateLoader::LoadScriptTemplate(tinyxml2::XMLDocument *pDoc
|
||||||
void CTemplateLoader::LoadMasterTemplate(tinyxml2::XMLDocument *pDoc)
|
void CTemplateLoader::LoadMasterTemplate(tinyxml2::XMLDocument *pDoc)
|
||||||
{
|
{
|
||||||
tinyxml2::XMLElement *pRoot = pDoc->FirstChildElement("MasterTemplate");
|
tinyxml2::XMLElement *pRoot = pDoc->FirstChildElement("MasterTemplate");
|
||||||
mpMaster->mVersion = StringUtil::ToInt32(pRoot->Attribute("version"));
|
mpMaster->mVersion = TString(pRoot->Attribute("version")).ToInt32();
|
||||||
|
|
||||||
tinyxml2::XMLElement *pElem = pRoot->FirstChildElement();
|
tinyxml2::XMLElement *pElem = pRoot->FirstChildElement();
|
||||||
|
|
||||||
|
@ -487,10 +487,10 @@ void CTemplateLoader::LoadMasterTemplate(tinyxml2::XMLDocument *pDoc)
|
||||||
// Properties
|
// Properties
|
||||||
if (strcmp(pElem->Name(), "properties") == 0)
|
if (strcmp(pElem->Name(), "properties") == 0)
|
||||||
{
|
{
|
||||||
std::string propListPath = mMasterDir + pElem->GetText();
|
TString propListPath = mMasterDir + pElem->GetText();
|
||||||
|
|
||||||
tinyxml2::XMLDocument propListXML;
|
tinyxml2::XMLDocument propListXML;
|
||||||
propListXML.LoadFile(propListPath.c_str());
|
propListXML.LoadFile(*propListPath);
|
||||||
|
|
||||||
if (propListXML.Error())
|
if (propListXML.Error())
|
||||||
Log::Error("Couldn't open property list: " + propListPath);
|
Log::Error("Couldn't open property list: " + propListPath);
|
||||||
|
@ -507,20 +507,20 @@ void CTemplateLoader::LoadMasterTemplate(tinyxml2::XMLDocument *pDoc)
|
||||||
while (pObj)
|
while (pObj)
|
||||||
{
|
{
|
||||||
// ID can either be a hex number or an ASCII fourCC
|
// ID can either be a hex number or an ASCII fourCC
|
||||||
std::string strID = pObj->Attribute("ID");
|
TString strID = pObj->Attribute("ID");
|
||||||
u32 ID;
|
u32 ID;
|
||||||
|
|
||||||
if (StringUtil::IsHexString(strID, true))
|
if (strID.IsHexString(true))
|
||||||
ID = StringUtil::ToInt32(strID);
|
ID = strID.ToInt32();
|
||||||
else
|
else
|
||||||
ID = CFourCC(strID).ToLong();
|
ID = CFourCC(strID).ToLong();
|
||||||
|
|
||||||
// Load up the object
|
// Load up the object
|
||||||
std::string templateName = pObj->Attribute("template");
|
TString templateName = pObj->Attribute("template");
|
||||||
std::string templatePath = mMasterDir + templateName;
|
TString templatePath = mMasterDir + templateName;
|
||||||
|
|
||||||
tinyxml2::XMLDocument scriptXML;
|
tinyxml2::XMLDocument scriptXML;
|
||||||
scriptXML.LoadFile(templatePath.c_str());
|
scriptXML.LoadFile(*templatePath);
|
||||||
|
|
||||||
if (scriptXML.Error())
|
if (scriptXML.Error())
|
||||||
Log::Error("Couldn't open script template: " + templatePath);
|
Log::Error("Couldn't open script template: " + templatePath);
|
||||||
|
@ -547,15 +547,15 @@ void CTemplateLoader::LoadMasterTemplate(tinyxml2::XMLDocument *pDoc)
|
||||||
|
|
||||||
while (pState)
|
while (pState)
|
||||||
{
|
{
|
||||||
std::string strID = pState->Attribute("ID");
|
TString strID = pState->Attribute("ID");
|
||||||
u32 stateID;
|
u32 stateID;
|
||||||
|
|
||||||
if (StringUtil::IsHexString(strID, true))
|
if (strID.IsHexString(true))
|
||||||
stateID = StringUtil::ToInt32(strID);
|
stateID = strID.ToInt32();
|
||||||
else
|
else
|
||||||
stateID = CFourCC(strID).ToLong();
|
stateID = CFourCC(strID).ToLong();
|
||||||
|
|
||||||
std::string stateName = pState->Attribute("name");
|
TString stateName = pState->Attribute("name");
|
||||||
mpMaster->mStates[stateID] = stateName;
|
mpMaster->mStates[stateID] = stateName;
|
||||||
pState = pState->NextSiblingElement("state");
|
pState = pState->NextSiblingElement("state");
|
||||||
}
|
}
|
||||||
|
@ -568,15 +568,15 @@ void CTemplateLoader::LoadMasterTemplate(tinyxml2::XMLDocument *pDoc)
|
||||||
|
|
||||||
while (pMessage)
|
while (pMessage)
|
||||||
{
|
{
|
||||||
std::string strID = pMessage->Attribute("ID");
|
TString strID = pMessage->Attribute("ID");
|
||||||
u32 messageID;
|
u32 messageID;
|
||||||
|
|
||||||
if (StringUtil::IsHexString(strID, true))
|
if (strID.IsHexString(true))
|
||||||
messageID = StringUtil::ToInt32(strID);
|
messageID = strID.ToInt32();
|
||||||
else
|
else
|
||||||
messageID = CFourCC(strID).ToLong();
|
messageID = CFourCC(strID).ToLong();
|
||||||
|
|
||||||
std::string messageName = pMessage->Attribute("name");
|
TString messageName = pMessage->Attribute("name");
|
||||||
mpMaster->mMessages[messageID] = messageName;
|
mpMaster->mMessages[messageID] = messageName;
|
||||||
pMessage = pMessage->NextSiblingElement("message");
|
pMessage = pMessage->NextSiblingElement("message");
|
||||||
}
|
}
|
||||||
|
@ -586,7 +586,7 @@ void CTemplateLoader::LoadMasterTemplate(tinyxml2::XMLDocument *pDoc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTemplateLoader::LoadPropertyList(tinyxml2::XMLDocument *pDoc, const std::string& listName)
|
void CTemplateLoader::LoadPropertyList(tinyxml2::XMLDocument *pDoc, const TString& listName)
|
||||||
{
|
{
|
||||||
tinyxml2::XMLElement *pElem = pDoc->FirstChildElement()->FirstChildElement();
|
tinyxml2::XMLElement *pElem = pDoc->FirstChildElement()->FirstChildElement();
|
||||||
|
|
||||||
|
@ -622,11 +622,11 @@ CMasterTemplate* CTemplateLoader::LoadGame(tinyxml2::XMLNode *pNode)
|
||||||
|
|
||||||
else if (strcmp(pGameElem->Name(), "master") == 0)
|
else if (strcmp(pGameElem->Name(), "master") == 0)
|
||||||
{
|
{
|
||||||
std::string MasterPath = mTemplatesDir + pGameElem->GetText();
|
TString MasterPath = mTemplatesDir + pGameElem->GetText();
|
||||||
mMasterDir = StringUtil::GetFileDirectory(MasterPath);
|
mMasterDir = MasterPath.GetFileDirectory();
|
||||||
|
|
||||||
tinyxml2::XMLDocument MasterXML;
|
tinyxml2::XMLDocument MasterXML;
|
||||||
MasterXML.LoadFile(MasterPath.c_str());
|
MasterXML.LoadFile(*MasterPath);
|
||||||
|
|
||||||
if (MasterXML.Error())
|
if (MasterXML.Error())
|
||||||
{
|
{
|
||||||
|
@ -649,13 +649,13 @@ CMasterTemplate* CTemplateLoader::LoadGame(tinyxml2::XMLNode *pNode)
|
||||||
// ************ PUBLIC ************
|
// ************ PUBLIC ************
|
||||||
void CTemplateLoader::LoadGameList()
|
void CTemplateLoader::LoadGameList()
|
||||||
{
|
{
|
||||||
static const std::string skTemplatesDir = "../templates/";
|
static const TString skTemplatesDir = "../templates/";
|
||||||
static const std::string skGameListPath = skTemplatesDir + "GameList.xml";
|
static const TString skGameListPath = skTemplatesDir + "GameList.xml";
|
||||||
Log::Write("Loading game list");
|
Log::Write("Loading game list");
|
||||||
|
|
||||||
// Load Game List XML
|
// Load Game List XML
|
||||||
tinyxml2::XMLDocument GameListXML;
|
tinyxml2::XMLDocument GameListXML;
|
||||||
GameListXML.LoadFile(skGameListPath.c_str());
|
GameListXML.LoadFile(*skGameListPath);
|
||||||
|
|
||||||
if (GameListXML.Error())
|
if (GameListXML.Error())
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,24 +8,24 @@
|
||||||
class CTemplateLoader
|
class CTemplateLoader
|
||||||
{
|
{
|
||||||
CMasterTemplate *mpMaster;
|
CMasterTemplate *mpMaster;
|
||||||
std::string mTemplatesDir;
|
TString mTemplatesDir;
|
||||||
std::string mMasterDir;
|
TString mMasterDir;
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
CTemplateLoader(const std::string& templatesDir) : mTemplatesDir(templatesDir) {}
|
CTemplateLoader(const TString& templatesDir) : mTemplatesDir(templatesDir) {}
|
||||||
|
|
||||||
// Load Property
|
// Load Property
|
||||||
void LoadBitFlags(tinyxml2::XMLElement *pElem, CBitfieldTemplate *pTemp, const std::string& templateName);
|
void LoadBitFlags(tinyxml2::XMLElement *pElem, CBitfieldTemplate *pTemp, const TString& templateName);
|
||||||
void LoadEnumerators(tinyxml2::XMLElement *pElem, CEnumTemplate *pTemp, const std::string& templateName);
|
void LoadEnumerators(tinyxml2::XMLElement *pElem, CEnumTemplate *pTemp, const TString& templateName);
|
||||||
void LoadStructProperties(tinyxml2::XMLElement *pElem, CStructTemplate *pTemp, const std::string& templateName);
|
void LoadStructProperties(tinyxml2::XMLElement *pElem, CStructTemplate *pTemp, const TString& templateName);
|
||||||
CPropertyTemplate* LoadPropertyTemplate(tinyxml2::XMLElement *pElem, const std::string& templateName);
|
CPropertyTemplate* LoadPropertyTemplate(tinyxml2::XMLElement *pElem, const TString& templateName);
|
||||||
|
|
||||||
// Load Script Object
|
// Load Script Object
|
||||||
CScriptTemplate* LoadScriptTemplate(tinyxml2::XMLDocument *pDoc, const std::string& templateName, u32 objectID);
|
CScriptTemplate* LoadScriptTemplate(tinyxml2::XMLDocument *pDoc, const TString& templateName, u32 objectID);
|
||||||
|
|
||||||
// Load Master
|
// Load Master
|
||||||
void LoadMasterTemplate(tinyxml2::XMLDocument *pDoc);
|
void LoadMasterTemplate(tinyxml2::XMLDocument *pDoc);
|
||||||
void LoadPropertyList(tinyxml2::XMLDocument *pDoc, const std::string& listName);
|
void LoadPropertyList(tinyxml2::XMLDocument *pDoc, const TString& listName);
|
||||||
CMasterTemplate* LoadGame(tinyxml2::XMLNode *pNode);
|
CMasterTemplate* LoadGame(tinyxml2::XMLNode *pNode);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -157,7 +157,7 @@ void CTextureDecoder::ReadDDS(CInputStream& DDS)
|
||||||
CFourCC Magic(DDS);
|
CFourCC Magic(DDS);
|
||||||
if (Magic != "DDS ")
|
if (Magic != "DDS ")
|
||||||
{
|
{
|
||||||
Log::FileError(DDS.GetSourceString(), "Invalid DDS magic: " + StringUtil::ToHexString((u32) Magic.ToLong()));
|
Log::FileError(DDS.GetSourceString(), "Invalid DDS magic: " + TString::HexString((u32) Magic.ToLong()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -300,7 +300,7 @@ CWorld* CWorldLoader::LoadMLVL(CInputStream& MLVL)
|
||||||
u32 Magic = MLVL.ReadLong();
|
u32 Magic = MLVL.ReadLong();
|
||||||
if (Magic != 0xDEAFBABE)
|
if (Magic != 0xDEAFBABE)
|
||||||
{
|
{
|
||||||
Log::FileError(MLVL.GetSourceString(), "Invalid MLVL magic: " + StringUtil::ToHexString(Magic));
|
Log::FileError(MLVL.GetSourceString(), "Invalid MLVL magic: " + TString::HexString(Magic));
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -308,7 +308,7 @@ CWorld* CWorldLoader::LoadMLVL(CInputStream& MLVL)
|
||||||
EGame Version = GetFormatVersion(FileVersion);
|
EGame Version = GetFormatVersion(FileVersion);
|
||||||
if (Version == eUnknownVersion)
|
if (Version == eUnknownVersion)
|
||||||
{
|
{
|
||||||
Log::FileError(MLVL.GetSourceString(), "Unsupported MLVL version: " + StringUtil::ToHexString(FileVersion));
|
Log::FileError(MLVL.GetSourceString(), "Unsupported MLVL version: " + TString::HexString(FileVersion));
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ CScriptTemplate* CMasterTemplate::TemplateByIndex(u32 Index)
|
||||||
return (std::next(it, Index))->second;
|
return (std::next(it, Index))->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CMasterTemplate::StateByID(u32 StateID)
|
TString CMasterTemplate::StateByID(u32 StateID)
|
||||||
{
|
{
|
||||||
auto it = mStates.find(StateID);
|
auto it = mStates.find(StateID);
|
||||||
|
|
||||||
|
@ -51,18 +51,18 @@ std::string CMasterTemplate::StateByID(u32 StateID)
|
||||||
return "Invalid";
|
return "Invalid";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CMasterTemplate::StateByID(const CFourCC& State)
|
TString CMasterTemplate::StateByID(const CFourCC& State)
|
||||||
{
|
{
|
||||||
return StateByID(State.ToLong());
|
return StateByID(State.ToLong());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CMasterTemplate::StateByIndex(u32 Index)
|
TString CMasterTemplate::StateByIndex(u32 Index)
|
||||||
{
|
{
|
||||||
auto it = mStates.begin();
|
auto it = mStates.begin();
|
||||||
return (std::next(it, Index))->second;
|
return (std::next(it, Index))->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CMasterTemplate::MessageByID(u32 MessageID)
|
TString CMasterTemplate::MessageByID(u32 MessageID)
|
||||||
{
|
{
|
||||||
auto it = mMessages.find(MessageID);
|
auto it = mMessages.find(MessageID);
|
||||||
|
|
||||||
|
@ -72,12 +72,12 @@ std::string CMasterTemplate::MessageByID(u32 MessageID)
|
||||||
return "Invalid";
|
return "Invalid";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CMasterTemplate::MessageByID(const CFourCC& MessageID)
|
TString CMasterTemplate::MessageByID(const CFourCC& MessageID)
|
||||||
{
|
{
|
||||||
return MessageByID(MessageID.ToLong());
|
return MessageByID(MessageID.ToLong());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CMasterTemplate::MessageByIndex(u32 Index)
|
TString CMasterTemplate::MessageByIndex(u32 Index)
|
||||||
{
|
{
|
||||||
auto it = mMessages.begin();
|
auto it = mMessages.begin();
|
||||||
return (std::next(it, Index))->second;
|
return (std::next(it, Index))->second;
|
||||||
|
|
|
@ -13,14 +13,14 @@ class CMasterTemplate
|
||||||
friend class CTemplateWriter;
|
friend class CTemplateWriter;
|
||||||
|
|
||||||
EGame mGame;
|
EGame mGame;
|
||||||
std::string mGameName;
|
TString mGameName;
|
||||||
std::string mSourceFile;
|
TString mSourceFile;
|
||||||
u32 mVersion;
|
u32 mVersion;
|
||||||
bool mFullyLoaded;
|
bool mFullyLoaded;
|
||||||
|
|
||||||
std::map<u32, CScriptTemplate*> mTemplates;
|
std::map<u32, CScriptTemplate*> mTemplates;
|
||||||
std::map<u32, std::string> mStates;
|
std::map<u32, TString> mStates;
|
||||||
std::map<u32, std::string> mMessages;
|
std::map<u32, TString> mMessages;
|
||||||
|
|
||||||
bool mHasPropList;
|
bool mHasPropList;
|
||||||
std::map<u32, CPropertyTemplate*> mPropertyList;
|
std::map<u32, CPropertyTemplate*> mPropertyList;
|
||||||
|
@ -38,12 +38,12 @@ public:
|
||||||
CScriptTemplate* TemplateByID(u32 ObjectID);
|
CScriptTemplate* TemplateByID(u32 ObjectID);
|
||||||
CScriptTemplate* TemplateByID(const CFourCC& ObjectID);
|
CScriptTemplate* TemplateByID(const CFourCC& ObjectID);
|
||||||
CScriptTemplate* TemplateByIndex(u32 Index);
|
CScriptTemplate* TemplateByIndex(u32 Index);
|
||||||
std::string StateByID(u32 StateID);
|
TString StateByID(u32 StateID);
|
||||||
std::string StateByID(const CFourCC& StateID);
|
TString StateByID(const CFourCC& StateID);
|
||||||
std::string StateByIndex(u32 Index);
|
TString StateByIndex(u32 Index);
|
||||||
std::string MessageByID(u32 MessageID);
|
TString MessageByID(u32 MessageID);
|
||||||
std::string MessageByID(const CFourCC& MessageID);
|
TString MessageByID(const CFourCC& MessageID);
|
||||||
std::string MessageByIndex(u32 Index);
|
TString MessageByIndex(u32 Index);
|
||||||
CPropertyTemplate* GetProperty(u32 PropertyID);
|
CPropertyTemplate* GetProperty(u32 PropertyID);
|
||||||
bool HasPropertyList();
|
bool HasPropertyList();
|
||||||
bool IsLoadedSuccessfully();
|
bool IsLoadedSuccessfully();
|
||||||
|
|
|
@ -25,17 +25,16 @@ CPropertyBase* CPropertyStruct::PropertyByID(u32 ID)
|
||||||
CPropertyBase* CPropertyStruct::PropertyByIDString(const TIDString& str)
|
CPropertyBase* CPropertyStruct::PropertyByIDString(const TIDString& str)
|
||||||
{
|
{
|
||||||
// Resolve namespace
|
// Resolve namespace
|
||||||
std::string::size_type nsStart = str.find_first_of(":");
|
u32 nsStart = str.IndexOf(":");
|
||||||
std::string::size_type propStart = nsStart + 1;
|
|
||||||
|
|
||||||
// String has namespace; the requested property is within a struct
|
// String has namespace; the requested property is within a struct
|
||||||
if (nsStart != std::string::npos)
|
if (nsStart != -1)
|
||||||
{
|
{
|
||||||
std::string strStructID = str.substr(0, nsStart);
|
TString strStructID = str.Truncate(nsStart);
|
||||||
if (!StringUtil::IsHexString(strStructID)) return nullptr;
|
if (!strStructID.IsHexString()) return nullptr;
|
||||||
|
|
||||||
u32 structID = StringUtil::ToInt32(strStructID);
|
u32 structID = strStructID.ToInt32();
|
||||||
std::string propName = str.substr(propStart, str.length() - propStart);
|
TString propName = str.ChopFront(nsStart + 1);
|
||||||
|
|
||||||
CPropertyStruct *pStruct = StructByID(structID);
|
CPropertyStruct *pStruct = StructByID(structID);
|
||||||
if (!pStruct) return nullptr;
|
if (!pStruct) return nullptr;
|
||||||
|
@ -45,8 +44,8 @@ CPropertyBase* CPropertyStruct::PropertyByIDString(const TIDString& str)
|
||||||
// No namespace; fetch the property from this struct
|
// No namespace; fetch the property from this struct
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (StringUtil::IsHexString(str))
|
if (str.IsHexString())
|
||||||
return PropertyByID(StringUtil::ToInt32(str));
|
return PropertyByID(str.ToInt32());
|
||||||
else
|
else
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,13 +12,13 @@
|
||||||
#include "EPropertyType.h"
|
#include "EPropertyType.h"
|
||||||
#include <Common/CColor.h>
|
#include <Common/CColor.h>
|
||||||
#include <Common/CVector3f.h>
|
#include <Common/CVector3f.h>
|
||||||
|
#include <Common/TString.h>
|
||||||
#include <Core/CToken.h>
|
#include <Core/CToken.h>
|
||||||
#include <string>
|
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
class CScriptTemplate;
|
class CScriptTemplate;
|
||||||
|
|
||||||
typedef std::string TIDString;
|
typedef TString TIDString;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CPropertyBase is the base class, containing just some virtual function definitions
|
* CPropertyBase is the base class, containing just some virtual function definitions
|
||||||
|
@ -34,7 +34,7 @@ public:
|
||||||
inline virtual EPropertyType Type() = 0;
|
inline virtual EPropertyType Type() = 0;
|
||||||
inline CPropertyTemplate *Template() { return mpTemplate; }
|
inline CPropertyTemplate *Template() { return mpTemplate; }
|
||||||
inline void SetTemplate(CPropertyTemplate *_tmp) { mpTemplate = _tmp; }
|
inline void SetTemplate(CPropertyTemplate *_tmp) { mpTemplate = _tmp; }
|
||||||
inline std::string Name() { return mpTemplate->Name(); }
|
inline TString Name() { return mpTemplate->Name(); }
|
||||||
inline u32 ID() { return mpTemplate->PropertyID(); }
|
inline u32 ID() { return mpTemplate->PropertyID(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ typedef __CProperty<long, eLongProperty> CLongProperty;
|
||||||
typedef __CProperty<long, eEnumProperty> CEnumProperty;
|
typedef __CProperty<long, eEnumProperty> CEnumProperty;
|
||||||
typedef __CProperty<long, eBitfieldProperty> CBitfieldProperty;
|
typedef __CProperty<long, eBitfieldProperty> CBitfieldProperty;
|
||||||
typedef __CProperty<float, eFloatProperty> CFloatProperty;
|
typedef __CProperty<float, eFloatProperty> CFloatProperty;
|
||||||
typedef __CProperty<std::string, eStringProperty> CStringProperty;
|
typedef __CProperty<TString, eStringProperty> CStringProperty;
|
||||||
typedef __CProperty<CVector3f, eVector3Property> CVector3Property;
|
typedef __CProperty<CVector3f, eVector3Property> CVector3Property;
|
||||||
typedef __CProperty<CColor, eColorProperty> CColorProperty;
|
typedef __CProperty<CColor, eColorProperty> CColorProperty;
|
||||||
typedef __CProperty<CResource*, eFileProperty> CFileProperty;
|
typedef __CProperty<CResource*, eFileProperty> CFileProperty;
|
||||||
|
@ -101,7 +101,7 @@ public:
|
||||||
mToken = CToken(v);
|
mToken = CToken(v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const CStringList& AllowedExtensions()
|
const TStringList& AllowedExtensions()
|
||||||
{
|
{
|
||||||
return static_cast<CFileTemplate*>(Template())->Extensions();
|
return static_cast<CFileTemplate*>(Template())->Extensions();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "CPropertyTemplate.h"
|
#include "CPropertyTemplate.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
EPropertyType PropStringToPropEnum(std::string prop)
|
EPropertyType PropStringToPropEnum(const TString& prop)
|
||||||
{
|
{
|
||||||
if (prop == "bool") return eBoolProperty;
|
if (prop == "bool") return eBoolProperty;
|
||||||
if (prop == "byte") return eByteProperty;
|
if (prop == "byte") return eByteProperty;
|
||||||
|
@ -21,7 +21,7 @@ EPropertyType PropStringToPropEnum(std::string prop)
|
||||||
return eInvalidProperty;
|
return eInvalidProperty;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string PropEnumToPropString(EPropertyType prop)
|
TString PropEnumToPropString(EPropertyType prop)
|
||||||
{
|
{
|
||||||
switch (prop)
|
switch (prop)
|
||||||
{
|
{
|
||||||
|
@ -96,20 +96,20 @@ CPropertyTemplate* CStructTemplate::PropertyByID(u32 ID)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
CPropertyTemplate* CStructTemplate::PropertyByIDString(const std::string& str)
|
CPropertyTemplate* CStructTemplate::PropertyByIDString(const TIDString& str)
|
||||||
{
|
{
|
||||||
// Resolve namespace
|
// Resolve namespace
|
||||||
std::string::size_type nsStart = str.find_first_of("::");
|
u32 nsStart = str.IndexOf(":");
|
||||||
std::string::size_type propStart = nsStart + 2;
|
u32 propStart = nsStart + 1;
|
||||||
|
|
||||||
// String has namespace; the requested property is within a struct
|
// String has namespace; the requested property is within a struct
|
||||||
if (nsStart != std::string::npos)
|
if (nsStart != -1)
|
||||||
{
|
{
|
||||||
std::string strStructID = str.substr(0, nsStart);
|
TString strStructID = str.SubString(0, nsStart);
|
||||||
if (!StringUtil::IsHexString(strStructID)) return nullptr;
|
if (!strStructID.IsHexString()) return nullptr;
|
||||||
|
|
||||||
u32 structID = StringUtil::ToInt32(strStructID);
|
u32 structID = strStructID.ToInt32();
|
||||||
std::string propName = str.substr(propStart, str.length() - propStart);
|
TString propName = str.SubString(propStart, str.Length() - propStart);
|
||||||
|
|
||||||
CStructTemplate *pStruct = StructByID(structID);
|
CStructTemplate *pStruct = StructByID(structID);
|
||||||
if (!pStruct) return nullptr;
|
if (!pStruct) return nullptr;
|
||||||
|
@ -120,8 +120,8 @@ CPropertyTemplate* CStructTemplate::PropertyByIDString(const std::string& str)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// ID string lookup
|
// ID string lookup
|
||||||
if (StringUtil::IsHexString(str))
|
if (str.IsHexString())
|
||||||
return PropertyByID(std::stoul(str, 0, 16));
|
return PropertyByID(str.ToInt32());
|
||||||
else
|
else
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -147,7 +147,7 @@ CStructTemplate* CStructTemplate::StructByID(u32 ID)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
CStructTemplate* CStructTemplate::StructByIDString(const std::string& str)
|
CStructTemplate* CStructTemplate::StructByIDString(const TString& str)
|
||||||
{
|
{
|
||||||
CPropertyTemplate *pProp = PropertyByIDString(str);
|
CPropertyTemplate *pProp = PropertyByIDString(str);
|
||||||
|
|
||||||
|
@ -158,7 +158,7 @@ CStructTemplate* CStructTemplate::StructByIDString(const std::string& str)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ************ DEBUG ************
|
// ************ DEBUG ************
|
||||||
void CStructTemplate::DebugPrintProperties(std::string base)
|
void CStructTemplate::DebugPrintProperties(TString base)
|
||||||
{
|
{
|
||||||
base = base + Name() + "::";
|
base = base + Name() + "::";
|
||||||
for (auto it = mProperties.begin(); it != mProperties.end(); it++)
|
for (auto it = mProperties.begin(); it != mProperties.end(); it++)
|
||||||
|
|
|
@ -2,11 +2,12 @@
|
||||||
#define CPROPERTYTEMPLATE
|
#define CPROPERTYTEMPLATE
|
||||||
|
|
||||||
#include "EPropertyType.h"
|
#include "EPropertyType.h"
|
||||||
#include <Common/StringUtil.h>
|
#include <Common/TString.h>
|
||||||
#include <Common/types.h>
|
#include <Common/types.h>
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
typedef TString TIDString;
|
||||||
|
|
||||||
class CPropertyTemplate
|
class CPropertyTemplate
|
||||||
{
|
{
|
||||||
friend class CTemplateLoader;
|
friend class CTemplateLoader;
|
||||||
|
@ -14,7 +15,7 @@ class CPropertyTemplate
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
EPropertyType mPropType;
|
EPropertyType mPropType;
|
||||||
std::string mPropName;
|
TString mPropName;
|
||||||
u32 mPropID;
|
u32 mPropID;
|
||||||
public:
|
public:
|
||||||
CPropertyTemplate(u32 ID)
|
CPropertyTemplate(u32 ID)
|
||||||
|
@ -22,7 +23,7 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
CPropertyTemplate(EPropertyType type, std::string name, u32 ID)
|
CPropertyTemplate(EPropertyType type, TString name, u32 ID)
|
||||||
: mPropType(type),
|
: mPropType(type),
|
||||||
mPropName(name),
|
mPropName(name),
|
||||||
mPropID(ID)
|
mPropID(ID)
|
||||||
|
@ -34,7 +35,7 @@ public:
|
||||||
return mPropType;
|
return mPropType;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::string Name() const
|
inline TString Name() const
|
||||||
{
|
{
|
||||||
return mPropName;
|
return mPropName;
|
||||||
}
|
}
|
||||||
|
@ -44,7 +45,7 @@ public:
|
||||||
return mPropID;
|
return mPropID;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void SetName(const std::string& Name)
|
inline void SetName(const TString& Name)
|
||||||
{
|
{
|
||||||
mPropName = Name;
|
mPropName = Name;
|
||||||
}
|
}
|
||||||
|
@ -55,11 +56,11 @@ class CFileTemplate : public CPropertyTemplate
|
||||||
friend class CTemplateLoader;
|
friend class CTemplateLoader;
|
||||||
friend class CTemplateWriter;
|
friend class CTemplateWriter;
|
||||||
|
|
||||||
CStringList mAcceptedExtensions;
|
TStringList mAcceptedExtensions;
|
||||||
public:
|
public:
|
||||||
CFileTemplate(u32 ID) : CPropertyTemplate(ID) { mPropType = eFileProperty; }
|
CFileTemplate(u32 ID) : CPropertyTemplate(ID) { mPropType = eFileProperty; }
|
||||||
|
|
||||||
CFileTemplate(const std::string& name, u32 ID, const CStringList& extensions)
|
CFileTemplate(const TString& name, u32 ID, const TStringList& extensions)
|
||||||
: CPropertyTemplate(ID)
|
: CPropertyTemplate(ID)
|
||||||
{
|
{
|
||||||
mPropType = eFileProperty;
|
mPropType = eFileProperty;
|
||||||
|
@ -72,7 +73,7 @@ public:
|
||||||
return eFileProperty;
|
return eFileProperty;
|
||||||
}
|
}
|
||||||
|
|
||||||
const CStringList& Extensions() const
|
const TStringList& Extensions() const
|
||||||
{
|
{
|
||||||
return mAcceptedExtensions;
|
return mAcceptedExtensions;
|
||||||
}
|
}
|
||||||
|
@ -85,14 +86,14 @@ class CEnumTemplate : public CPropertyTemplate
|
||||||
|
|
||||||
struct SEnumerator
|
struct SEnumerator
|
||||||
{
|
{
|
||||||
std::string Name;
|
TString Name;
|
||||||
u32 ID;
|
u32 ID;
|
||||||
|
|
||||||
SEnumerator(const std::string& _name, u32 _ID)
|
SEnumerator(const TString& _name, u32 _ID)
|
||||||
: Name(_name), ID(_ID) {}
|
: Name(_name), ID(_ID) {}
|
||||||
};
|
};
|
||||||
std::vector<SEnumerator> mEnumerators;
|
std::vector<SEnumerator> mEnumerators;
|
||||||
std::string mSourceFile;
|
TString mSourceFile;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CEnumTemplate(u32 ID)
|
CEnumTemplate(u32 ID)
|
||||||
|
@ -101,7 +102,7 @@ public:
|
||||||
mPropType = eEnumProperty;
|
mPropType = eEnumProperty;
|
||||||
}
|
}
|
||||||
|
|
||||||
CEnumTemplate(const std::string& name, u32 ID)
|
CEnumTemplate(const TString& name, u32 ID)
|
||||||
: CPropertyTemplate(eEnumProperty, name, ID)
|
: CPropertyTemplate(eEnumProperty, name, ID)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
@ -133,7 +134,7 @@ public:
|
||||||
else return -1;
|
else return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string EnumeratorName(u32 enumIndex)
|
TString EnumeratorName(u32 enumIndex)
|
||||||
{
|
{
|
||||||
if (mEnumerators.size() > enumIndex)
|
if (mEnumerators.size() > enumIndex)
|
||||||
return mEnumerators[enumIndex].Name;
|
return mEnumerators[enumIndex].Name;
|
||||||
|
@ -149,14 +150,14 @@ class CBitfieldTemplate : public CPropertyTemplate
|
||||||
|
|
||||||
struct SBitFlag
|
struct SBitFlag
|
||||||
{
|
{
|
||||||
std::string Name;
|
TString Name;
|
||||||
u32 Mask;
|
u32 Mask;
|
||||||
|
|
||||||
SBitFlag(const std::string& _name, u32 _mask)
|
SBitFlag(const TString& _name, u32 _mask)
|
||||||
: Name(_name), Mask(_mask) {}
|
: Name(_name), Mask(_mask) {}
|
||||||
};
|
};
|
||||||
std::vector<SBitFlag> mBitFlags;
|
std::vector<SBitFlag> mBitFlags;
|
||||||
std::string mSourceFile;
|
TString mSourceFile;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CBitfieldTemplate(u32 ID)
|
CBitfieldTemplate(u32 ID)
|
||||||
|
@ -165,7 +166,7 @@ public:
|
||||||
mPropType = eBitfieldProperty;
|
mPropType = eBitfieldProperty;
|
||||||
}
|
}
|
||||||
|
|
||||||
CBitfieldTemplate(const std::string& name, u32 ID)
|
CBitfieldTemplate(const TString& name, u32 ID)
|
||||||
: CPropertyTemplate(eBitfieldProperty, name, ID)
|
: CPropertyTemplate(eBitfieldProperty, name, ID)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
@ -179,7 +180,7 @@ public:
|
||||||
return mBitFlags.size();
|
return mBitFlags.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string FlagName(u32 index)
|
TString FlagName(u32 index)
|
||||||
{
|
{
|
||||||
return mBitFlags[index].Name;
|
return mBitFlags[index].Name;
|
||||||
}
|
}
|
||||||
|
@ -197,7 +198,7 @@ class CStructTemplate : public CPropertyTemplate
|
||||||
|
|
||||||
bool mIsSingleProperty;
|
bool mIsSingleProperty;
|
||||||
std::vector<CPropertyTemplate*> mProperties;
|
std::vector<CPropertyTemplate*> mProperties;
|
||||||
std::string mSourceFile;
|
TString mSourceFile;
|
||||||
public:
|
public:
|
||||||
CStructTemplate();
|
CStructTemplate();
|
||||||
~CStructTemplate();
|
~CStructTemplate();
|
||||||
|
@ -207,11 +208,11 @@ public:
|
||||||
u32 Count() const;
|
u32 Count() const;
|
||||||
CPropertyTemplate* PropertyByIndex(u32 index);
|
CPropertyTemplate* PropertyByIndex(u32 index);
|
||||||
CPropertyTemplate* PropertyByID(u32 ID);
|
CPropertyTemplate* PropertyByID(u32 ID);
|
||||||
CPropertyTemplate* PropertyByIDString(const std::string& str);
|
CPropertyTemplate* PropertyByIDString(const TIDString& str);
|
||||||
CStructTemplate* StructByIndex(u32 index);
|
CStructTemplate* StructByIndex(u32 index);
|
||||||
CStructTemplate* StructByID(u32 ID);
|
CStructTemplate* StructByID(u32 ID);
|
||||||
CStructTemplate* StructByIDString(const std::string& str);
|
CStructTemplate* StructByIDString(const TIDString& str);
|
||||||
void DebugPrintProperties(std::string base);
|
void DebugPrintProperties(TString base);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CPROPERTYTEMPLATE
|
#endif // CPROPERTYTEMPLATE
|
||||||
|
|
|
@ -44,7 +44,7 @@ void CScriptLayer::Reserve(u32 amount)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ************* GETTERS *************
|
// ************* GETTERS *************
|
||||||
std::string CScriptLayer::Name()
|
TString CScriptLayer::Name()
|
||||||
{
|
{
|
||||||
return mLayerName;
|
return mLayerName;
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ CScriptObject* CScriptLayer::ObjectByID(u32 ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ************* SETTERS *************
|
// ************* SETTERS *************
|
||||||
void CScriptLayer::SetName(std::string name)
|
void CScriptLayer::SetName(const TString& name)
|
||||||
{
|
{
|
||||||
mLayerName = name;
|
mLayerName = name;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
class CScriptLayer
|
class CScriptLayer
|
||||||
{
|
{
|
||||||
std::string mLayerName;
|
TString mLayerName;
|
||||||
bool mActive;
|
bool mActive;
|
||||||
bool mVisible;
|
bool mVisible;
|
||||||
std::vector<CScriptObject*> mObjects;
|
std::vector<CScriptObject*> mObjects;
|
||||||
|
@ -23,14 +23,14 @@ public:
|
||||||
void Reserve(u32 amount);
|
void Reserve(u32 amount);
|
||||||
|
|
||||||
// Getters and Setters
|
// Getters and Setters
|
||||||
std::string Name();
|
TString Name();
|
||||||
bool IsActive();
|
bool IsActive();
|
||||||
bool IsVisible();
|
bool IsVisible();
|
||||||
u32 GetNumObjects();
|
u32 GetNumObjects();
|
||||||
CScriptObject* ObjectByIndex(u32 index);
|
CScriptObject* ObjectByIndex(u32 index);
|
||||||
CScriptObject* ObjectByID(u32 ID);
|
CScriptObject* ObjectByID(u32 ID);
|
||||||
|
|
||||||
void SetName(std::string name);
|
void SetName(const TString& name);
|
||||||
void SetActive(bool active);
|
void SetActive(bool active);
|
||||||
void SetVisible(bool visible);
|
void SetVisible(bool visible);
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ CPropertyBase* CScriptObject::PropertyByIndex(u32 index) const
|
||||||
return mpProperties->PropertyByIndex(index);
|
return mpProperties->PropertyByIndex(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
CPropertyBase* CScriptObject::PropertyByIDString(std::string str) const
|
CPropertyBase* CScriptObject::PropertyByIDString(const TString& str) const
|
||||||
{
|
{
|
||||||
return mpProperties->PropertyByIDString(str);
|
return mpProperties->PropertyByIDString(str);
|
||||||
}
|
}
|
||||||
|
@ -123,7 +123,7 @@ const SLink& CScriptObject::OutLink(u32 index) const
|
||||||
return mOutConnections[index];
|
return mOutConnections[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CScriptObject::InstanceName() const
|
TString CScriptObject::InstanceName() const
|
||||||
{
|
{
|
||||||
if (mpInstanceName)
|
if (mpInstanceName)
|
||||||
return mpInstanceName->Get();
|
return mpInstanceName->Get();
|
||||||
|
@ -178,7 +178,7 @@ void CScriptObject::SetScale(const CVector3f& newScale)
|
||||||
if (mpScale) mpScale->Set(newScale);
|
if (mpScale) mpScale->Set(newScale);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CScriptObject::SetName(const std::string& newName)
|
void CScriptObject::SetName(const TString& newName)
|
||||||
{
|
{
|
||||||
if (mpInstanceName) mpInstanceName->Set(newName);
|
if (mpInstanceName) mpInstanceName->Set(newName);
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ public:
|
||||||
CPropertyStruct* Properties() const;
|
CPropertyStruct* Properties() const;
|
||||||
u32 NumProperties() const;
|
u32 NumProperties() const;
|
||||||
CPropertyBase* PropertyByIndex(u32 index) const;
|
CPropertyBase* PropertyByIndex(u32 index) const;
|
||||||
CPropertyBase* PropertyByIDString(std::string str) const;
|
CPropertyBase* PropertyByIDString(const TIDString& str) const;
|
||||||
u32 ObjectTypeID() const;
|
u32 ObjectTypeID() const;
|
||||||
u32 InstanceID() const;
|
u32 InstanceID() const;
|
||||||
u32 NumInLinks() const;
|
u32 NumInLinks() const;
|
||||||
|
@ -64,12 +64,12 @@ public:
|
||||||
CVector3f Position() const;
|
CVector3f Position() const;
|
||||||
CVector3f Rotation() const;
|
CVector3f Rotation() const;
|
||||||
CVector3f Scale() const;
|
CVector3f Scale() const;
|
||||||
std::string InstanceName() const;
|
TString InstanceName() const;
|
||||||
bool IsActive() const;
|
bool IsActive() const;
|
||||||
void SetPosition(const CVector3f& newPos);
|
void SetPosition(const CVector3f& newPos);
|
||||||
void SetRotation(const CVector3f& newRot);
|
void SetRotation(const CVector3f& newRot);
|
||||||
void SetScale(const CVector3f& newScale);
|
void SetScale(const CVector3f& newScale);
|
||||||
void SetName(const std::string& newName);
|
void SetName(const TString& newName);
|
||||||
void SetActive(bool isActive);
|
void SetActive(bool isActive);
|
||||||
CPropertyStruct* LightParameters() const;
|
CPropertyStruct* LightParameters() const;
|
||||||
CModel* GetDisplayModel() const;
|
CModel* GetDisplayModel() const;
|
||||||
|
|
|
@ -25,7 +25,7 @@ CMasterTemplate* CScriptTemplate::MasterTemplate()
|
||||||
return mpMaster;
|
return mpMaster;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CScriptTemplate::TemplateName(s32 propCount) const
|
TString CScriptTemplate::TemplateName(s32 propCount) const
|
||||||
{
|
{
|
||||||
// Return original name if there is only one property set
|
// Return original name if there is only one property set
|
||||||
// or if caller doesn't want to distinguish between sets
|
// or if caller doesn't want to distinguish between sets
|
||||||
|
@ -40,7 +40,7 @@ std::string CScriptTemplate::TemplateName(s32 propCount) const
|
||||||
return mTemplateName + " (Invalid)";
|
return mTemplateName + " (Invalid)";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CScriptTemplate::PropertySetNameByCount(s32 propCount) const
|
TString CScriptTemplate::PropertySetNameByCount(s32 propCount) const
|
||||||
{
|
{
|
||||||
for (auto it = mPropertySets.begin(); it != mPropertySets.end(); it++)
|
for (auto it = mPropertySets.begin(); it != mPropertySets.end(); it++)
|
||||||
if (it->pBaseStruct->Count() == propCount)
|
if (it->pBaseStruct->Count() == propCount)
|
||||||
|
@ -49,7 +49,7 @@ std::string CScriptTemplate::PropertySetNameByCount(s32 propCount) const
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CScriptTemplate::PropertySetNameByIndex(u32 index) const
|
TString CScriptTemplate::PropertySetNameByIndex(u32 index) const
|
||||||
{
|
{
|
||||||
if (index < NumPropertySets())
|
if (index < NumPropertySets())
|
||||||
return mPropertySets[index].SetName;
|
return mPropertySets[index].SetName;
|
||||||
|
@ -97,7 +97,7 @@ void CScriptTemplate::DebugPrintProperties(int propCount)
|
||||||
template<typename t, EPropertyType propType>
|
template<typename t, EPropertyType propType>
|
||||||
t TFetchProperty(CPropertyStruct *pProperties, const TIDString& ID)
|
t TFetchProperty(CPropertyStruct *pProperties, const TIDString& ID)
|
||||||
{
|
{
|
||||||
if (ID.empty()) return nullptr;
|
if (ID.IsEmpty()) return nullptr;
|
||||||
CPropertyBase *pProp = pProperties->PropertyByIDString(ID);
|
CPropertyBase *pProp = pProperties->PropertyByIDString(ID);
|
||||||
|
|
||||||
if (pProp && (pProp->Type() == propType))
|
if (pProp && (pProp->Type() == propType))
|
||||||
|
@ -173,7 +173,7 @@ EVolumeShape CScriptTemplate::VolumeShape(CScriptObject *pObj)
|
||||||
return it->Shape;
|
return it->Shape;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log::Error(TemplateName() + " instance " + StringUtil::ToHexString(pObj->InstanceID(), true, true, 8) + " has unexpected volume shape value of " + StringUtil::ToHexString((u32) v, true, true));
|
Log::Error(TemplateName() + " instance " + TString::HexString(pObj->InstanceID(), true, true, 8) + " has unexpected volume shape value of " + TString::HexString((u32) v, true, true));
|
||||||
return eInvalidShape;
|
return eInvalidShape;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,7 +219,7 @@ CModel* CScriptTemplate::FindDisplayModel(CPropertyStruct *pProperties)
|
||||||
// File
|
// File
|
||||||
if (it->AssetSource == SEditorAsset::eFile)
|
if (it->AssetSource == SEditorAsset::eFile)
|
||||||
{
|
{
|
||||||
std::string path = "../resources/" + it->AssetLocation;
|
TString path = "../resources/" + it->AssetLocation;
|
||||||
pRes = gResCache.GetResource(path);
|
pRes = gResCache.GetResource(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,7 +258,7 @@ CCollisionMeshGroup* CScriptTemplate::FindCollision(CPropertyStruct *pProperties
|
||||||
// File
|
// File
|
||||||
if (it->AssetSource == SEditorAsset::eFile)
|
if (it->AssetSource == SEditorAsset::eFile)
|
||||||
{
|
{
|
||||||
std::string path = "../resources/" + it->AssetLocation;
|
TString path = "../resources/" + it->AssetLocation;
|
||||||
pRes = gResCache.GetResource(path);
|
pRes = gResCache.GetResource(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -284,7 +284,7 @@ CCollisionMeshGroup* CScriptTemplate::FindCollision(CPropertyStruct *pProperties
|
||||||
|
|
||||||
bool CScriptTemplate::HasPosition()
|
bool CScriptTemplate::HasPosition()
|
||||||
{
|
{
|
||||||
return (!mPositionIDString.empty());
|
return (!mPositionIDString.IsEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
// ************ OBJECT TRACKING ************
|
// ************ OBJECT TRACKING ************
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
class CMasterTemplate;
|
class CMasterTemplate;
|
||||||
class CScriptObject;
|
class CScriptObject;
|
||||||
|
|
||||||
typedef std::string TIDString;
|
typedef TString TIDString;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CScriptTemplate is a class that encases the data contained in one of the XML templates.
|
* CScriptTemplate is a class that encases the data contained in one of the XML templates.
|
||||||
|
@ -41,7 +41,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct SPropertySet {
|
struct SPropertySet {
|
||||||
std::string SetName;
|
TString SetName;
|
||||||
CStructTemplate *pBaseStruct;
|
CStructTemplate *pBaseStruct;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -64,8 +64,8 @@ private:
|
||||||
std::list<CScriptObject*> mObjectList;
|
std::list<CScriptObject*> mObjectList;
|
||||||
ERotationType mRotationType;
|
ERotationType mRotationType;
|
||||||
EScaleType mScaleType;
|
EScaleType mScaleType;
|
||||||
std::string mTemplateName;
|
TString mTemplateName;
|
||||||
std::string mSourceFile;
|
TString mSourceFile;
|
||||||
u32 mObjectID;
|
u32 mObjectID;
|
||||||
bool mVisible;
|
bool mVisible;
|
||||||
|
|
||||||
|
@ -93,9 +93,9 @@ public:
|
||||||
~CScriptTemplate();
|
~CScriptTemplate();
|
||||||
|
|
||||||
CMasterTemplate* MasterTemplate();
|
CMasterTemplate* MasterTemplate();
|
||||||
std::string TemplateName(s32 propCount = -1) const;
|
TString TemplateName(s32 propCount = -1) const;
|
||||||
std::string PropertySetNameByCount(s32 propCount) const;
|
TString PropertySetNameByCount(s32 propCount) const;
|
||||||
std::string PropertySetNameByIndex(u32 index) const;
|
TString PropertySetNameByIndex(u32 index) const;
|
||||||
u32 NumPropertySets() const;
|
u32 NumPropertySets() const;
|
||||||
ERotationType RotationType() const;
|
ERotationType RotationType() const;
|
||||||
EScaleType ScaleType() const;
|
EScaleType ScaleType() const;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef EPROPERTYTYPE
|
#ifndef EPROPERTYTYPE
|
||||||
#define EPROPERTYTYPE
|
#define EPROPERTYTYPE
|
||||||
|
|
||||||
#include <string>
|
#include <Common/TString.h>
|
||||||
|
|
||||||
enum EPropertyType
|
enum EPropertyType
|
||||||
{
|
{
|
||||||
|
@ -24,8 +24,8 @@ enum EPropertyType
|
||||||
};
|
};
|
||||||
|
|
||||||
// functions defined in CScriptTemplate.cpp
|
// functions defined in CScriptTemplate.cpp
|
||||||
EPropertyType PropStringToPropEnum(std::string prop);
|
EPropertyType PropStringToPropEnum(const TString& prop);
|
||||||
std::string PropEnumToPropString(EPropertyType prop);
|
TString PropEnumToPropString(EPropertyType prop);
|
||||||
|
|
||||||
#endif // EPROPERTYTYPE
|
#endif // EPROPERTYTYPE
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ CSceneNode::~CSceneNode()
|
||||||
}
|
}
|
||||||
|
|
||||||
// ************ VIRTUAL ************
|
// ************ VIRTUAL ************
|
||||||
std::string CSceneNode::PrefixedName() const
|
TString CSceneNode::PrefixedName() const
|
||||||
{
|
{
|
||||||
return Name();
|
return Name();
|
||||||
}
|
}
|
||||||
|
@ -287,7 +287,7 @@ const CTransform4f& CSceneNode::Transform()
|
||||||
}
|
}
|
||||||
|
|
||||||
// ************ GETTERS ************
|
// ************ GETTERS ************
|
||||||
std::string CSceneNode::Name() const
|
TString CSceneNode::Name() const
|
||||||
{
|
{
|
||||||
return mName;
|
return mName;
|
||||||
}
|
}
|
||||||
|
@ -399,7 +399,7 @@ bool CSceneNode::InheritsScale() const
|
||||||
}
|
}
|
||||||
|
|
||||||
// ************ SETTERS ************
|
// ************ SETTERS ************
|
||||||
void CSceneNode::SetName(const std::string& Name)
|
void CSceneNode::SetName(const TString& Name)
|
||||||
{
|
{
|
||||||
mName = Name;
|
mName = Name;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ private:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static u32 smNumNodes;
|
static u32 smNumNodes;
|
||||||
std::string mName;
|
TString mName;
|
||||||
CSceneNode *mpParent;
|
CSceneNode *mpParent;
|
||||||
CSceneManager *mpScene;
|
CSceneManager *mpScene;
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ public:
|
||||||
explicit CSceneNode(CSceneManager *pScene, CSceneNode *pParent = 0);
|
explicit CSceneNode(CSceneManager *pScene, CSceneNode *pParent = 0);
|
||||||
virtual ~CSceneNode();
|
virtual ~CSceneNode();
|
||||||
virtual ENodeType NodeType() = 0;
|
virtual ENodeType NodeType() = 0;
|
||||||
virtual std::string PrefixedName() const;
|
virtual TString PrefixedName() const;
|
||||||
virtual void Draw(ERenderOptions options) = 0;
|
virtual void Draw(ERenderOptions options) = 0;
|
||||||
virtual void DrawAsset(ERenderOptions options, u32 asset) = 0;
|
virtual void DrawAsset(ERenderOptions options, u32 asset) = 0;
|
||||||
virtual void DrawSelection();
|
virtual void DrawSelection();
|
||||||
|
@ -80,7 +80,7 @@ public:
|
||||||
const CTransform4f& Transform();
|
const CTransform4f& Transform();
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
std::string Name() const;
|
TString Name() const;
|
||||||
CSceneNode* Parent() const;
|
CSceneNode* Parent() const;
|
||||||
CSceneManager* Scene();
|
CSceneManager* Scene();
|
||||||
CVector3f LocalPosition() const;
|
CVector3f LocalPosition() const;
|
||||||
|
@ -100,7 +100,7 @@ public:
|
||||||
bool InheritsScale() const;
|
bool InheritsScale() const;
|
||||||
|
|
||||||
// Setters
|
// Setters
|
||||||
void SetName(const std::string& Name);
|
void SetName(const TString& Name);
|
||||||
void SetPosition(const CVector3f& position);
|
void SetPosition(const CVector3f& position);
|
||||||
void SetRotation(const CQuaternion& rotation);
|
void SetRotation(const CQuaternion& rotation);
|
||||||
void SetRotation(const CVector3f& rotEuler);
|
void SetRotation(const CVector3f& rotEuler);
|
||||||
|
|
|
@ -92,7 +92,7 @@ ENodeType CScriptNode::NodeType()
|
||||||
return eScriptNode;
|
return eScriptNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CScriptNode::PrefixedName() const
|
TString CScriptNode::PrefixedName() const
|
||||||
{
|
{
|
||||||
return "[" + mpInstance->Template()->TemplateName() + "] " + mpInstance->InstanceName();
|
return "[" + mpInstance->Template()->TemplateName() + "] " + mpInstance->InstanceName();
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ class CScriptNode : public CSceneNode
|
||||||
public:
|
public:
|
||||||
CScriptNode(CSceneManager *pScene, CSceneNode *pParent = 0, CScriptObject *pObject = 0);
|
CScriptNode(CSceneManager *pScene, CSceneNode *pParent = 0, CScriptObject *pObject = 0);
|
||||||
ENodeType NodeType();
|
ENodeType NodeType();
|
||||||
std::string PrefixedName() const;
|
TString PrefixedName() const;
|
||||||
void AddToRenderer(CRenderer *pRenderer, const CFrustumPlanes& frustum);
|
void AddToRenderer(CRenderer *pRenderer, const CFrustumPlanes& frustum);
|
||||||
void Draw(ERenderOptions Options);
|
void Draw(ERenderOptions Options);
|
||||||
void DrawAsset(ERenderOptions Options, u32 Asset);
|
void DrawAsset(ERenderOptions Options, u32 Asset);
|
||||||
|
|
|
@ -68,10 +68,10 @@ public slots:
|
||||||
protected slots:
|
protected slots:
|
||||||
virtual void CheckUserInput() {}
|
virtual void CheckUserInput() {}
|
||||||
virtual void Paint() {}
|
virtual void Paint() {}
|
||||||
virtual void ContextMenu(QContextMenuEvent *pEvent) {}
|
virtual void ContextMenu(QContextMenuEvent* /*pEvent*/) {}
|
||||||
virtual void OnResize() {}
|
virtual void OnResize() {}
|
||||||
virtual void OnMouseClick(QMouseEvent *pEvent) {}
|
virtual void OnMouseClick(QMouseEvent* /*pEvent*/) {}
|
||||||
virtual void OnMouseRelease(QMouseEvent *pEvent) {}
|
virtual void OnMouseRelease(QMouseEvent* /*pEvent*/) {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ProcessInput(double DeltaTime);
|
void ProcessInput(double DeltaTime);
|
||||||
|
|
|
@ -4,8 +4,9 @@
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
|
#include "UICommon.h"
|
||||||
#include "WResourceSelector.h"
|
#include "WResourceSelector.h"
|
||||||
#include <Common/StringUtil.h>
|
#include <Common/TString.h>
|
||||||
#include <Core/CDrawUtil.h>
|
#include <Core/CDrawUtil.h>
|
||||||
#include <Core/CRenderer.h>
|
#include <Core/CRenderer.h>
|
||||||
#include <Core/CSceneManager.h>
|
#include <Core/CSceneManager.h>
|
||||||
|
@ -176,8 +177,8 @@ void CModelEditorWindow::SetActiveModel(CModel *pModel)
|
||||||
|
|
||||||
for (u32 iMat = 0; iMat < numMats; iMat++)
|
for (u32 iMat = 0; iMat < numMats; iMat++)
|
||||||
{
|
{
|
||||||
std::string matName = pModel->GetMaterialByIndex(0, iMat)->Name();
|
TString matName = pModel->GetMaterialByIndex(0, iMat)->Name();
|
||||||
ui->MatSelectionComboBox->addItem(QString::fromStdString(matName));
|
ui->MatSelectionComboBox->addItem(TO_QSTRING(matName));
|
||||||
}
|
}
|
||||||
|
|
||||||
ui->MatSelectionComboBox->setCurrentIndex(0);
|
ui->MatSelectionComboBox->setCurrentIndex(0);
|
||||||
|
@ -223,7 +224,7 @@ void CModelEditorWindow::SetActiveMaterial(int MatIndex)
|
||||||
ui->DestBlendComboBox->setCurrentIndex(DstFac);
|
ui->DestBlendComboBox->setCurrentIndex(DstFac);
|
||||||
|
|
||||||
if (Settings & CMaterial::eIndStage)
|
if (Settings & CMaterial::eIndStage)
|
||||||
ui->IndTextureResSelector->SetText(QString::fromStdString(mpCurrentMat->IndTexture()->FullSource()));
|
ui->IndTextureResSelector->SetText(TO_QSTRING(mpCurrentMat->IndTexture()->FullSource()));
|
||||||
else
|
else
|
||||||
ui->IndTextureResSelector->SetText("");
|
ui->IndTextureResSelector->SetText("");
|
||||||
|
|
||||||
|
@ -250,7 +251,7 @@ void CModelEditorWindow::SetActiveMaterial(int MatIndex)
|
||||||
{
|
{
|
||||||
CMaterialPass *pPass = mpCurrentMat->Pass(iPass);
|
CMaterialPass *pPass = mpCurrentMat->Pass(iPass);
|
||||||
|
|
||||||
QTableWidgetItem *pItemA = new QTableWidgetItem("Pass #" + QString::number(iPass + 1) + ": " + QString::fromStdString(pPass->NamedType()));
|
QTableWidgetItem *pItemA = new QTableWidgetItem("Pass #" + QString::number(iPass + 1) + ": " + TO_QSTRING(pPass->NamedType()));
|
||||||
QTableWidgetItem *pItemB = new QTableWidgetItem();
|
QTableWidgetItem *pItemB = new QTableWidgetItem();
|
||||||
|
|
||||||
if (pPass->IsEnabled())
|
if (pPass->IsEnabled())
|
||||||
|
@ -307,7 +308,7 @@ void CModelEditorWindow::SetActivePass(int PassIndex)
|
||||||
|
|
||||||
CTexture *pPassTex = mpCurrentPass->Texture();
|
CTexture *pPassTex = mpCurrentPass->Texture();
|
||||||
if (pPassTex)
|
if (pPassTex)
|
||||||
ui->PassTextureResSelector->SetText(QString::fromStdString(pPassTex->FullSource()));
|
ui->PassTextureResSelector->SetText(TO_QSTRING(pPassTex->FullSource()));
|
||||||
else
|
else
|
||||||
ui->PassTextureResSelector->SetText("");
|
ui->PassTextureResSelector->SetText("");
|
||||||
|
|
||||||
|
@ -683,13 +684,14 @@ void CModelEditorWindow::UpdateAnimParamUI(int Mode)
|
||||||
|
|
||||||
void CModelEditorWindow::on_actionConvert_to_DDS_triggered()
|
void CModelEditorWindow::on_actionConvert_to_DDS_triggered()
|
||||||
{
|
{
|
||||||
QString TexFilename = QFileDialog::getOpenFileName(this, "Retro Texture (*.TXTR)", "", "*.TXTR");
|
QString Input = QFileDialog::getOpenFileName(this, "Retro Texture (*.TXTR)", "", "*.TXTR");
|
||||||
if (TexFilename.isEmpty()) return;
|
if (Input.isEmpty()) return;
|
||||||
|
|
||||||
CTexture *Tex = (CTexture*) gResCache.GetResource(TexFilename.toStdString());
|
TString TexFilename = Input.toStdString();
|
||||||
std::string OutName = StringUtil::GetPathWithoutExtension(TexFilename.toStdString()) + ".dds";
|
CTexture *Tex = (CTexture*) gResCache.GetResource(TexFilename);
|
||||||
|
TString OutName = TexFilename.GetFilePathWithoutExtension() + ".dds";
|
||||||
|
|
||||||
CFileOutStream Out(OutName, IOUtil::LittleEndian);
|
CFileOutStream Out(OutName.ToStdString(), IOUtil::LittleEndian);
|
||||||
if (!Out.IsValid()) QMessageBox::warning(this, "Error", "Couldn't open output DDS!");
|
if (!Out.IsValid()) QMessageBox::warning(this, "Error", "Couldn't open output DDS!");
|
||||||
|
|
||||||
else
|
else
|
||||||
|
@ -709,8 +711,8 @@ void CModelEditorWindow::on_actionOpen_triggered()
|
||||||
if (pModel)
|
if (pModel)
|
||||||
{
|
{
|
||||||
SetActiveModel(pModel);
|
SetActiveModel(pModel);
|
||||||
setWindowTitle("Prime World Editor - Model Editor: " + QString::fromStdString(pModel->Source()));
|
setWindowTitle("Prime World Editor - Model Editor: " + TO_QSTRING(pModel->Source()));
|
||||||
mOutputFilename = QString::fromStdString(pModel->FullSource());
|
mOutputFilename = TO_QSTRING(pModel->FullSource());
|
||||||
}
|
}
|
||||||
|
|
||||||
gResCache.Clean();
|
gResCache.Clean();
|
||||||
|
@ -802,6 +804,6 @@ void CModelEditorWindow::on_actionSave_as_triggered()
|
||||||
mOutputFilename = filename;
|
mOutputFilename = filename;
|
||||||
on_actionSave_triggered();
|
on_actionSave_triggered();
|
||||||
|
|
||||||
std::string name = StringUtil::GetFileNameWithExtension(filename.toStdString());
|
TString name = TString(filename.toStdString());
|
||||||
setWindowTitle("Prime World Editor - Model Editor: " + QString::fromStdString(name));
|
setWindowTitle("Prime World Editor - Model Editor: " + TO_QSTRING(name));
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include "CModelEditorWindow.h"
|
#include "CModelEditorWindow.h"
|
||||||
#include "CWorldEditor.h"
|
#include "CWorldEditor.h"
|
||||||
|
#include "UICommon.h"
|
||||||
#include <Core/CResCache.h>
|
#include <Core/CResCache.h>
|
||||||
|
|
||||||
CStartWindow::CStartWindow(QWidget *parent) :
|
CStartWindow::CStartWindow(QWidget *parent) :
|
||||||
|
@ -30,7 +31,7 @@ void CStartWindow::on_actionOpen_MLVL_triggered()
|
||||||
QString WorldFile = QFileDialog::getOpenFileName(this, "Open MLVL", "", "Metroid Prime World (*.MLVL)");
|
QString WorldFile = QFileDialog::getOpenFileName(this, "Open MLVL", "", "Metroid Prime World (*.MLVL)");
|
||||||
if (WorldFile.isEmpty()) return;
|
if (WorldFile.isEmpty()) return;
|
||||||
|
|
||||||
gResCache.SetFolder(StringUtil::GetFileDirectory(WorldFile.toStdString()));
|
gResCache.SetFolder(TString(WorldFile.toStdString()).GetFileDirectory());
|
||||||
mpWorld = (CWorld*) gResCache.GetResource(WorldFile.toStdString());
|
mpWorld = (CWorld*) gResCache.GetResource(WorldFile.toStdString());
|
||||||
mWorldToken = CToken(mpWorld);
|
mWorldToken = CToken(mpWorld);
|
||||||
mpWorldEditor->close();
|
mpWorldEditor->close();
|
||||||
|
@ -44,9 +45,9 @@ void CStartWindow::FillWorldUI()
|
||||||
CStringTable *pWorldName = mpWorld->GetWorldName();
|
CStringTable *pWorldName = mpWorld->GetWorldName();
|
||||||
if (pWorldName)
|
if (pWorldName)
|
||||||
{
|
{
|
||||||
std::wstring WorldName = pWorldName->GetString("ENGL", 0);
|
TWideString WorldName = pWorldName->GetString("ENGL", 0);
|
||||||
ui->WorldNameLabel->setText( QString("<font size=5><b>") + QString::fromStdWString(WorldName) + QString("</b></font>") );
|
ui->WorldNameLabel->setText( QString("<font size=5><b>") + TO_QSTRING(WorldName) + QString("</b></font>") );
|
||||||
ui->WorldNameSTRGLineEdit->setText( QString::fromStdString(pWorldName->Source()) );
|
ui->WorldNameSTRGLineEdit->setText(TO_QSTRING(pWorldName->Source()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -56,25 +57,25 @@ void CStartWindow::FillWorldUI()
|
||||||
|
|
||||||
CStringTable *pDarkWorldName = mpWorld->GetDarkWorldName();
|
CStringTable *pDarkWorldName = mpWorld->GetDarkWorldName();
|
||||||
if (pDarkWorldName)
|
if (pDarkWorldName)
|
||||||
ui->DarkWorldNameSTRGLineEdit->setText( QString::fromStdString(pDarkWorldName->Source()) );
|
ui->DarkWorldNameSTRGLineEdit->setText(TO_QSTRING(pDarkWorldName->Source()));
|
||||||
else
|
else
|
||||||
ui->DarkWorldNameSTRGLineEdit->clear();
|
ui->DarkWorldNameSTRGLineEdit->clear();
|
||||||
|
|
||||||
CModel *pDefaultSkybox = mpWorld->GetDefaultSkybox();
|
CModel *pDefaultSkybox = mpWorld->GetDefaultSkybox();
|
||||||
if (pDefaultSkybox)
|
if (pDefaultSkybox)
|
||||||
ui->DefaultSkyboxCMDLLineEdit->setText( QString::fromStdString(pDefaultSkybox->Source()) );
|
ui->DefaultSkyboxCMDLLineEdit->setText(TO_QSTRING(pDefaultSkybox->Source()));
|
||||||
else
|
else
|
||||||
ui->DefaultSkyboxCMDLLineEdit->clear();
|
ui->DefaultSkyboxCMDLLineEdit->clear();
|
||||||
|
|
||||||
CResource *pSaveWorld = mpWorld->GetSaveWorld();
|
CResource *pSaveWorld = mpWorld->GetSaveWorld();
|
||||||
if (pSaveWorld)
|
if (pSaveWorld)
|
||||||
ui->WorldSAVWLineEdit->setText( QString::fromStdString(pSaveWorld->Source()) );
|
ui->WorldSAVWLineEdit->setText(TO_QSTRING(pSaveWorld->Source()));
|
||||||
else
|
else
|
||||||
ui->WorldSAVWLineEdit->clear();
|
ui->WorldSAVWLineEdit->clear();
|
||||||
|
|
||||||
CResource *pMapWorld = mpWorld->GetMapWorld();
|
CResource *pMapWorld = mpWorld->GetMapWorld();
|
||||||
if (pMapWorld)
|
if (pMapWorld)
|
||||||
ui->WorldMAPWLineEdit->setText( QString::fromStdString(pMapWorld->Source()) );
|
ui->WorldMAPWLineEdit->setText(TO_QSTRING(pMapWorld->Source()));
|
||||||
else
|
else
|
||||||
ui->WorldMAPWLineEdit->clear();
|
ui->WorldMAPWLineEdit->clear();
|
||||||
|
|
||||||
|
@ -86,7 +87,7 @@ void CStartWindow::FillWorldUI()
|
||||||
for (u32 iArea = 0; iArea < NumAreas; iArea++)
|
for (u32 iArea = 0; iArea < NumAreas; iArea++)
|
||||||
{
|
{
|
||||||
CStringTable *pAreaName = mpWorld->GetAreaName(iArea);
|
CStringTable *pAreaName = mpWorld->GetAreaName(iArea);
|
||||||
QString AreaName = (pAreaName != nullptr) ? QString::fromStdWString(pAreaName->GetString("ENGL", 0)) : QString("!!") + QString::fromStdString(mpWorld->GetAreaInternalName(iArea));
|
QString AreaName = (pAreaName != nullptr) ? TO_QSTRING(pAreaName->GetString("ENGL", 0)) : QString("!!") + TO_QSTRING(mpWorld->GetAreaInternalName(iArea));
|
||||||
ui->AreaSelectComboBox->addItem(AreaName);
|
ui->AreaSelectComboBox->addItem(AreaName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,22 +103,22 @@ void CStartWindow::FillAreaUI()
|
||||||
ui->AreaSelectComboBox->setCurrentIndex(mSelectedAreaIndex);
|
ui->AreaSelectComboBox->setCurrentIndex(mSelectedAreaIndex);
|
||||||
ui->AreaSelectComboBox->blockSignals(false);
|
ui->AreaSelectComboBox->blockSignals(false);
|
||||||
|
|
||||||
ui->AreaNameLineEdit->setText( QString::fromStdString(mpWorld->GetAreaInternalName(mSelectedAreaIndex)));
|
ui->AreaNameLineEdit->setText(TO_QSTRING(mpWorld->GetAreaInternalName(mSelectedAreaIndex)));
|
||||||
|
|
||||||
CStringTable *pAreaName = mpWorld->GetAreaName(mSelectedAreaIndex);
|
CStringTable *pAreaName = mpWorld->GetAreaName(mSelectedAreaIndex);
|
||||||
if (pAreaName)
|
if (pAreaName)
|
||||||
ui->AreaNameSTRGLineEdit->setText( QString::fromStdString( pAreaName->Source() ));
|
ui->AreaNameSTRGLineEdit->setText(TO_QSTRING(pAreaName->Source()));
|
||||||
else
|
else
|
||||||
ui->AreaNameSTRGLineEdit->clear();
|
ui->AreaNameSTRGLineEdit->clear();
|
||||||
|
|
||||||
u64 MREA = mpWorld->GetAreaResourceID(mSelectedAreaIndex);
|
u64 MREA = mpWorld->GetAreaResourceID(mSelectedAreaIndex);
|
||||||
std::string MREAStr;
|
TString MREAStr;
|
||||||
if (MREA & 0xFFFFFFFF00000000)
|
if (MREA & 0xFFFFFFFF00000000)
|
||||||
MREAStr = StringUtil::ToString(MREA);
|
MREAStr = TString::FromInt64(MREA, 16);
|
||||||
else
|
else
|
||||||
MREAStr = StringUtil::ToString( (u32) MREA );
|
MREAStr = TString::FromInt32(MREA, 8);
|
||||||
|
|
||||||
ui->AreaMREALineEdit->setText(QString::fromStdString(MREAStr) + QString(".MREA") );
|
ui->AreaMREALineEdit->setText(TO_QSTRING(MREAStr) + QString(".MREA"));
|
||||||
|
|
||||||
u32 NumAttachedAreas = mpWorld->GetAreaAttachedCount(mSelectedAreaIndex);
|
u32 NumAttachedAreas = mpWorld->GetAreaAttachedCount(mSelectedAreaIndex);
|
||||||
ui->AttachedAreasList->clear();
|
ui->AttachedAreasList->clear();
|
||||||
|
@ -130,9 +131,9 @@ void CStartWindow::FillAreaUI()
|
||||||
QString AttachedStr;
|
QString AttachedStr;
|
||||||
|
|
||||||
if (AttachedAreaSTRG)
|
if (AttachedAreaSTRG)
|
||||||
AttachedStr = QString::fromStdWString(AttachedAreaSTRG->GetString("ENGL", 0) );
|
AttachedStr = TO_QSTRING(AttachedAreaSTRG->GetString("ENGL", 0));
|
||||||
else
|
else
|
||||||
AttachedStr = QString("!!") + QString::fromStdString(mpWorld->GetAreaInternalName(AttachedAreaIndex));
|
AttachedStr = QString("!!") + TO_QSTRING(mpWorld->GetAreaInternalName(AttachedAreaIndex));
|
||||||
|
|
||||||
ui->AttachedAreasList->addItem(AttachedStr);
|
ui->AttachedAreasList->addItem(AttachedStr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include "WDraggableSpinBox.h"
|
#include "WDraggableSpinBox.h"
|
||||||
#include "WVectorEditor.h"
|
#include "WVectorEditor.h"
|
||||||
#include "undo/UndoCommands.h"
|
#include "undo/UndoCommands.h"
|
||||||
|
#include "UICommon.h"
|
||||||
|
|
||||||
#include "WorldEditor/CLayerEditor.h"
|
#include "WorldEditor/CLayerEditor.h"
|
||||||
#include "WorldEditor/WModifyTab.h"
|
#include "WorldEditor/WModifyTab.h"
|
||||||
|
@ -164,7 +165,7 @@ void CWorldEditor::UpdateStatusBar()
|
||||||
CSceneNode *pHoverNode = ui->MainViewport->HoverNode();
|
CSceneNode *pHoverNode = ui->MainViewport->HoverNode();
|
||||||
|
|
||||||
if (pHoverNode && (pHoverNode->NodeType() != eStaticNode))
|
if (pHoverNode && (pHoverNode->NodeType() != eStaticNode))
|
||||||
StatusText = QString::fromStdString(pHoverNode->Name());
|
StatusText = TO_QSTRING(pHoverNode->Name());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,7 +182,7 @@ void CWorldEditor::UpdateSelectionUI()
|
||||||
QString SelectionText;
|
QString SelectionText;
|
||||||
|
|
||||||
if (mSelection.size() == 1)
|
if (mSelection.size() == 1)
|
||||||
SelectionText = QString::fromStdString(mSelection.front()->Name());
|
SelectionText = TO_QSTRING(mSelection.front()->Name());
|
||||||
else if (mSelection.size() > 1)
|
else if (mSelection.size() > 1)
|
||||||
SelectionText = QString("%1 objects selected").arg(mSelection.size());
|
SelectionText = QString("%1 objects selected").arg(mSelection.size());
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
#include <Core/CResCache.h>
|
#include <Core/CResCache.h>
|
||||||
#include <Core/CSceneManager.h>
|
#include <Core/CSceneManager.h>
|
||||||
#include <FileIO/FileIO.h>
|
#include <FileIO/FileIO.h>
|
||||||
#include <Common/StringUtil.h>
|
#include <Common/TString.h>
|
||||||
#include <Core/CGraphics.h>
|
#include <Core/CGraphics.h>
|
||||||
#include <gtc/matrix_transform.hpp>
|
#include <gtc/matrix_transform.hpp>
|
||||||
#include "CBasicViewport.h"
|
#include "CBasicViewport.h"
|
||||||
|
@ -206,8 +206,8 @@ void CWorldEditorWindow::setupInstanceViewLayers()
|
||||||
for (u32 o = 0; o < object_count; o++) {
|
for (u32 o = 0; o < object_count; o++) {
|
||||||
|
|
||||||
PrimeObject object = m->getObject(l, o);
|
PrimeObject object = m->getObject(l, o);
|
||||||
std::string name = object.getStringProperty("Name");
|
TString name = object.getStringProperty("Name");
|
||||||
if (name.empty()) name = "[no name]";
|
if (name.IsEmpty()) name = "[no name]";
|
||||||
|
|
||||||
QTreeWidgetItem* obj = new QTreeWidgetItem;
|
QTreeWidgetItem* obj = new QTreeWidgetItem;
|
||||||
obj->setText(0, QString::fromStdString(name));
|
obj->setText(0, QString::fromStdString(name));
|
||||||
|
|
|
@ -3,11 +3,37 @@
|
||||||
|
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <Common/TString.h>
|
||||||
|
|
||||||
|
#define TO_QSTRING(str) UICommon::ToQString(str)
|
||||||
|
#define TO_TSTRING(str) UICommon::ToTString(str)
|
||||||
|
#define TO_TWIDESTRING(str) UICommon::ToTWideSTring(str)
|
||||||
|
|
||||||
namespace UICommon
|
namespace UICommon
|
||||||
{
|
{
|
||||||
extern QMap<QString,QString> FilterMap;
|
extern QMap<QString,QString> FilterMap;
|
||||||
QString ExtensionFilterString(const QString& extension);
|
QString ExtensionFilterString(const QString& extension);
|
||||||
|
|
||||||
|
// TString/TWideString <-> QString
|
||||||
|
inline QString ToQString(const TString& str)
|
||||||
|
{
|
||||||
|
return QString::fromStdString(str.ToStdString());
|
||||||
|
}
|
||||||
|
|
||||||
|
inline QString ToQString(const TWideString& str)
|
||||||
|
{
|
||||||
|
return QString::fromStdWString(str.ToStdString());
|
||||||
|
}
|
||||||
|
|
||||||
|
inline TString ToTString(const QString& str)
|
||||||
|
{
|
||||||
|
return TString(str.toStdString());
|
||||||
|
}
|
||||||
|
|
||||||
|
inline TWideString ToTWideString(const QString& str)
|
||||||
|
{
|
||||||
|
return TWideString(str.toStdWString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // UICOMMON
|
#endif // UICOMMON
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
#include "WAnimParamsEditor.h"
|
#include "WAnimParamsEditor.h"
|
||||||
|
|
||||||
|
#include "UICommon.h"
|
||||||
#include <Core/CResCache.h>
|
#include <Core/CResCache.h>
|
||||||
#include <Resource/CAnimSet.h>
|
#include <Resource/CAnimSet.h>
|
||||||
|
|
||||||
|
@ -139,7 +141,7 @@ void WAnimParamsEditor::SetupUI()
|
||||||
|
|
||||||
if (pSet)
|
if (pSet)
|
||||||
for (u32 iChar = 0; iChar < pSet->getNodeCount(); iChar++)
|
for (u32 iChar = 0; iChar < pSet->getNodeCount(); iChar++)
|
||||||
mpCharComboBox->addItem(QString::fromStdString(pSet->getNodeName(iChar)));
|
mpCharComboBox->addItem(TO_QSTRING(pSet->getNodeName(iChar)));
|
||||||
|
|
||||||
mpCharComboBox->setCurrentIndex(mParams.CharacterIndex());
|
mpCharComboBox->setCurrentIndex(mParams.CharacterIndex());
|
||||||
mpLabels[1] = new QLabel("Character", this);
|
mpLabels[1] = new QLabel("Character", this);
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "WPropertyEditor.h"
|
#include "WPropertyEditor.h"
|
||||||
|
#include "UICommon.h"
|
||||||
#include "WDraggableSpinBox.h"
|
#include "WDraggableSpinBox.h"
|
||||||
#include "WIntegralSpinBox.h"
|
#include "WIntegralSpinBox.h"
|
||||||
#include "WResourceSelector.h"
|
#include "WResourceSelector.h"
|
||||||
|
@ -71,8 +72,8 @@ void WPropertyEditor::CreateEditor()
|
||||||
delete mUI.EditorWidget;
|
delete mUI.EditorWidget;
|
||||||
|
|
||||||
// Set name
|
// Set name
|
||||||
mUI.PropertyName->setText(QString::fromStdString(mpProperty->Name()));
|
mUI.PropertyName->setText(TO_QSTRING(mpProperty->Name()));
|
||||||
mUI.PropertyName->setToolTip(QString::fromStdString(mpProperty->Name()));
|
mUI.PropertyName->setToolTip(TO_QSTRING(mpProperty->Name()));
|
||||||
|
|
||||||
// Set editor widget
|
// Set editor widget
|
||||||
switch (mpProperty->Type())
|
switch (mpProperty->Type())
|
||||||
|
@ -144,8 +145,8 @@ void WPropertyEditor::CreateEditor()
|
||||||
|
|
||||||
for (u32 iEnum = 0; iEnum < pTemplate->NumEnumerators(); iEnum++)
|
for (u32 iEnum = 0; iEnum < pTemplate->NumEnumerators(); iEnum++)
|
||||||
{
|
{
|
||||||
std::string name = pTemplate->EnumeratorName(iEnum);
|
TString name = pTemplate->EnumeratorName(iEnum);
|
||||||
pComboBox->addItem(QString::fromStdString(name));
|
pComboBox->addItem(TO_QSTRING(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 index = pEnumCast->Get();
|
u32 index = pEnumCast->Get();
|
||||||
|
@ -168,15 +169,15 @@ void WPropertyEditor::CreateEditor()
|
||||||
QVBoxLayout *pBitfieldLayout = new QVBoxLayout(pGroupBox);
|
QVBoxLayout *pBitfieldLayout = new QVBoxLayout(pGroupBox);
|
||||||
pBitfieldLayout->setContentsMargins(5,5,5,5);
|
pBitfieldLayout->setContentsMargins(5,5,5,5);
|
||||||
pGroupBox->setLayout(pBitfieldLayout);
|
pGroupBox->setLayout(pBitfieldLayout);
|
||||||
pGroupBox->setTitle(QString::fromStdString(pBitfieldCast->Name()));
|
pGroupBox->setTitle(TO_QSTRING(pBitfieldCast->Name()));
|
||||||
mUI.PropertyName->hide();
|
mUI.PropertyName->hide();
|
||||||
|
|
||||||
for (u32 iFlag = 0; iFlag < pTemplate->NumFlags(); iFlag++)
|
for (u32 iFlag = 0; iFlag < pTemplate->NumFlags(); iFlag++)
|
||||||
{
|
{
|
||||||
std::string flagName = pTemplate->FlagName(iFlag);
|
TString flagName = pTemplate->FlagName(iFlag);
|
||||||
long mask = pTemplate->FlagMask(iFlag);
|
long mask = pTemplate->FlagMask(iFlag);
|
||||||
|
|
||||||
QCheckBox *pCheckBox = new QCheckBox(QString::fromStdString(flagName), pGroupBox);
|
QCheckBox *pCheckBox = new QCheckBox(TO_QSTRING(flagName), pGroupBox);
|
||||||
pCheckBox->setChecked((value & mask) != 0);
|
pCheckBox->setChecked((value & mask) != 0);
|
||||||
pBitfieldLayout->addWidget(pCheckBox);
|
pBitfieldLayout->addWidget(pCheckBox);
|
||||||
}
|
}
|
||||||
|
@ -206,7 +207,7 @@ void WPropertyEditor::CreateEditor()
|
||||||
CStringProperty *pStringCast = static_cast<CStringProperty*>(mpProperty);
|
CStringProperty *pStringCast = static_cast<CStringProperty*>(mpProperty);
|
||||||
QLineEdit *pLineEdit = new QLineEdit(this);
|
QLineEdit *pLineEdit = new QLineEdit(this);
|
||||||
|
|
||||||
pLineEdit->setText(QString::fromStdString(pStringCast->Get()));
|
pLineEdit->setText(TO_QSTRING(pStringCast->Get()));
|
||||||
pLineEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
pLineEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||||
//pLineEdit->setCursorPosition(0);
|
//pLineEdit->setCursorPosition(0);
|
||||||
|
|
||||||
|
@ -226,7 +227,7 @@ void WPropertyEditor::CreateEditor()
|
||||||
pGroupLayout->setContentsMargins(0,0,0,0);
|
pGroupLayout->setContentsMargins(0,0,0,0);
|
||||||
pGroupBox->setLayout(pGroupLayout);
|
pGroupBox->setLayout(pGroupLayout);
|
||||||
|
|
||||||
pGroupBox->setTitle(QString::fromStdString(mpProperty->Name()));
|
pGroupBox->setTitle(TO_QSTRING(mpProperty->Name()));
|
||||||
pVectorEditor->SetValue(pVector3Cast->Get());
|
pVectorEditor->SetValue(pVector3Cast->Get());
|
||||||
pVectorEditor->SetOrientation(Qt::Vertical);
|
pVectorEditor->SetOrientation(Qt::Vertical);
|
||||||
mUI.PropertyName->hide();
|
mUI.PropertyName->hide();
|
||||||
|
@ -272,7 +273,7 @@ void WPropertyEditor::CreateEditor()
|
||||||
QVBoxLayout *pStructLayout = new QVBoxLayout(pGroupBox);
|
QVBoxLayout *pStructLayout = new QVBoxLayout(pGroupBox);
|
||||||
pStructLayout->setContentsMargins(5,5,5,5);
|
pStructLayout->setContentsMargins(5,5,5,5);
|
||||||
pGroupBox->setLayout(pStructLayout);
|
pGroupBox->setLayout(pStructLayout);
|
||||||
pGroupBox->setTitle(QString::fromStdString(pStructCast->Name()));
|
pGroupBox->setTitle(TO_QSTRING(pStructCast->Name()));
|
||||||
mUI.PropertyName->hide();
|
mUI.PropertyName->hide();
|
||||||
|
|
||||||
for (u32 p = 0; p < pStructCast->Count(); p++)
|
for (u32 p = 0; p < pStructCast->Count(); p++)
|
||||||
|
@ -292,7 +293,7 @@ void WPropertyEditor::CreateEditor()
|
||||||
CAnimationParameters params = pAnimCast->Get();
|
CAnimationParameters params = pAnimCast->Get();
|
||||||
|
|
||||||
WAnimParamsEditor *pEditor = new WAnimParamsEditor(params, this);
|
WAnimParamsEditor *pEditor = new WAnimParamsEditor(params, this);
|
||||||
pEditor->SetTitle(QString::fromStdString(pAnimCast->Name()));
|
pEditor->SetTitle(TO_QSTRING(pAnimCast->Name()));
|
||||||
|
|
||||||
mUI.PropertyName->hide();
|
mUI.PropertyName->hide();
|
||||||
mUI.EditorWidget = pEditor;
|
mUI.EditorWidget = pEditor;
|
||||||
|
@ -400,7 +401,7 @@ void WPropertyEditor::UpdateEditor()
|
||||||
{
|
{
|
||||||
CStringProperty *pStringCast = static_cast<CStringProperty*>(mpProperty);
|
CStringProperty *pStringCast = static_cast<CStringProperty*>(mpProperty);
|
||||||
QLineEdit *pLineEdit = static_cast<QLineEdit*>(mUI.EditorWidget);
|
QLineEdit *pLineEdit = static_cast<QLineEdit*>(mUI.EditorWidget);
|
||||||
pLineEdit->setText(QString::fromStdString(pStringCast->Get()));
|
pLineEdit->setText(TO_QSTRING(pStringCast->Get()));
|
||||||
pLineEdit->setCursorPosition(0);
|
pLineEdit->setCursorPosition(0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -470,8 +471,8 @@ void WPropertyEditor::UpdateEditor()
|
||||||
|
|
||||||
void WPropertyEditor::CreateLabelText()
|
void WPropertyEditor::CreateLabelText()
|
||||||
{
|
{
|
||||||
mUI.PropertyName->setText(QString::fromStdString(mpProperty->Name()));
|
mUI.PropertyName->setText(TO_QSTRING(mpProperty->Name()));
|
||||||
QFontMetrics metrics(mUI.PropertyName->font());
|
QFontMetrics metrics(mUI.PropertyName->font());
|
||||||
QString text = metrics.elidedText(QString::fromStdString(mpProperty->Name()), Qt::ElideRight, mUI.PropertyName->width());
|
QString text = metrics.elidedText(TO_QSTRING(mpProperty->Name()), Qt::ElideRight, mUI.PropertyName->width());
|
||||||
mUI.PropertyName->setText(text);
|
mUI.PropertyName->setText(text);
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,7 +105,7 @@ bool WResourceSelector::IsSupportedExtension(const QString& extension)
|
||||||
|
|
||||||
bool WResourceSelector::HasSupportedExtension(CResource* pRes)
|
bool WResourceSelector::HasSupportedExtension(CResource* pRes)
|
||||||
{
|
{
|
||||||
return IsSupportedExtension( QString::fromStdString( StringUtil::GetExtension(pRes->FullSource()) ) );
|
return IsSupportedExtension(TO_QSTRING(pRes->FullSource().GetFileExtension()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ************ GETTERS ************
|
// ************ GETTERS ************
|
||||||
|
@ -139,7 +139,7 @@ void WResourceSelector::SetResource(CResource *pRes)
|
||||||
if (pRes)
|
if (pRes)
|
||||||
{
|
{
|
||||||
mResourceValid = HasSupportedExtension(pRes);
|
mResourceValid = HasSupportedExtension(pRes);
|
||||||
mUI.LineEdit->setText(QString::fromStdString(pRes->FullSource()));
|
mUI.LineEdit->setText(TO_QSTRING(pRes->FullSource()));
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
|
@ -154,15 +154,15 @@ void WResourceSelector::SetResource(CResource *pRes)
|
||||||
|
|
||||||
void WResourceSelector::SetAllowedExtensions(const QString& extension)
|
void WResourceSelector::SetAllowedExtensions(const QString& extension)
|
||||||
{
|
{
|
||||||
CStringList list = StringUtil::Tokenize(extension.toStdString(), ",");
|
TStringList list = TString(extension.toStdString()).Split(",");
|
||||||
SetAllowedExtensions(list);
|
SetAllowedExtensions(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WResourceSelector::SetAllowedExtensions(const CStringList& extensions)
|
void WResourceSelector::SetAllowedExtensions(const TStringList& extensions)
|
||||||
{
|
{
|
||||||
mSupportedExtensions.clear();
|
mSupportedExtensions.clear();
|
||||||
for (auto it = extensions.begin(); it != extensions.end(); it++)
|
for (auto it = extensions.begin(); it != extensions.end(); it++)
|
||||||
mSupportedExtensions << QString::fromStdString(*it);
|
mSupportedExtensions << TO_QSTRING(*it);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WResourceSelector::SetText(const QString& ResPath)
|
void WResourceSelector::SetText(const QString& ResPath)
|
||||||
|
@ -263,10 +263,10 @@ void WResourceSelector::LoadResource(const QString& ResPath)
|
||||||
mpResource = nullptr;
|
mpResource = nullptr;
|
||||||
mResToken.Unlock();
|
mResToken.Unlock();
|
||||||
|
|
||||||
std::string pathStr = ResPath.toStdString();
|
TString pathStr = ResPath.toStdString();
|
||||||
std::string ext = StringUtil::GetExtension(pathStr);
|
TString ext = pathStr.GetFileExtension();
|
||||||
|
|
||||||
if (IsSupportedExtension( QString::fromStdString(ext) ))
|
if (IsSupportedExtension(TO_QSTRING(ext)))
|
||||||
{
|
{
|
||||||
if ((ext != "MREA") && (ext != "MLVL"))
|
if ((ext != "MREA") && (ext != "MLVL"))
|
||||||
{
|
{
|
||||||
|
|
|
@ -66,7 +66,7 @@ public:
|
||||||
void SetResource(CResource *pRes);
|
void SetResource(CResource *pRes);
|
||||||
void SetAllowedExtensions(const QString& extension);
|
void SetAllowedExtensions(const QString& extension);
|
||||||
void SetAllowedExtensions(const QStringList& extensions);
|
void SetAllowedExtensions(const QStringList& extensions);
|
||||||
void SetAllowedExtensions(const CStringList& extensions);
|
void SetAllowedExtensions(const TStringList& extensions);
|
||||||
void SetText(const QString& ResPath);
|
void SetText(const QString& ResPath);
|
||||||
void SetEditButtonEnabled(bool Enabled);
|
void SetEditButtonEnabled(bool Enabled);
|
||||||
void SetExportButtonEnabled(bool Enabled);
|
void SetExportButtonEnabled(bool Enabled);
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "WStringPreviewPanel.h"
|
#include "WStringPreviewPanel.h"
|
||||||
|
#include "UICommon.h"
|
||||||
#include <QFontMetrics>
|
#include <QFontMetrics>
|
||||||
#include <QTextLayout>
|
#include <QTextLayout>
|
||||||
#include <Resource/CStringTable.h>
|
#include <Resource/CStringTable.h>
|
||||||
|
@ -38,7 +39,7 @@ void WStringPreviewPanel::SetResource(CResource *pRes)
|
||||||
|
|
||||||
for (u32 iStr = 0; iStr < pString->GetStringCount(); iStr++)
|
for (u32 iStr = 0; iStr < pString->GetStringCount(); iStr++)
|
||||||
{
|
{
|
||||||
QString text = QString::fromStdWString(pString->GetString("ENGL", iStr));
|
QString text = TO_QSTRING(pString->GetString("ENGL", iStr));
|
||||||
QLabel *pLabel = new QLabel(text, this);
|
QLabel *pLabel = new QLabel(text, this);
|
||||||
pLabel->setWordWrap(true);
|
pLabel->setWordWrap(true);
|
||||||
pLabel->setFrameStyle(QFrame::Plain | QFrame::Box);
|
pLabel->setFrameStyle(QFrame::Plain | QFrame::Box);
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#include "WTexturePreviewPanel.h"
|
#include "WTexturePreviewPanel.h"
|
||||||
#include "ui_WTexturePreviewPanel.h"
|
#include "ui_WTexturePreviewPanel.h"
|
||||||
|
|
||||||
|
#include "UICommon.h"
|
||||||
#include "WTextureGLWidget.h"
|
#include "WTextureGLWidget.h"
|
||||||
|
|
||||||
WTexturePreviewPanel::WTexturePreviewPanel(QWidget *parent, CTexture *pTexture) :
|
WTexturePreviewPanel::WTexturePreviewPanel(QWidget *parent, CTexture *pTexture) :
|
||||||
|
@ -27,8 +29,8 @@ void WTexturePreviewPanel::SetResource(CResource *pRes)
|
||||||
|
|
||||||
if (pTexture)
|
if (pTexture)
|
||||||
{
|
{
|
||||||
std::string Name = StringUtil::GetFileNameWithExtension(pTexture->Source());
|
TString Name = pTexture->Source();
|
||||||
ui->TextureNameLabel->setText( QString::fromStdString(Name) );
|
ui->TextureNameLabel->setText( TO_QSTRING(Name) );
|
||||||
|
|
||||||
QString TexInfo;
|
QString TexInfo;
|
||||||
TexInfo += QString::number(pTexture->Width()) + "x" + QString::number(pTexture->Height());
|
TexInfo += QString::number(pTexture->Width()) + "x" + QString::number(pTexture->Height());
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "CLayerEditor.h"
|
#include "CLayerEditor.h"
|
||||||
#include "ui_CLayerEditor.h"
|
#include "ui_CLayerEditor.h"
|
||||||
|
#include "../UICommon.h"
|
||||||
|
|
||||||
CLayerEditor::CLayerEditor(QWidget *parent) :
|
CLayerEditor::CLayerEditor(QWidget *parent) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
|
@ -38,7 +39,7 @@ void CLayerEditor::SetCurrentIndex(int index)
|
||||||
QModelIndex ModelIndex = mpModel->index(index);
|
QModelIndex ModelIndex = mpModel->index(index);
|
||||||
mpCurrentLayer = mpModel->Layer(ModelIndex);
|
mpCurrentLayer = mpModel->Layer(ModelIndex);
|
||||||
|
|
||||||
ui->NameLineEdit->setText(QString::fromStdString(mpCurrentLayer->Name()));
|
ui->NameLineEdit->setText(TO_QSTRING(mpCurrentLayer->Name()));
|
||||||
ui->ActiveCheckBox->setChecked(mpCurrentLayer->IsActive());
|
ui->ActiveCheckBox->setChecked(mpCurrentLayer->IsActive());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "CLayerModel.h"
|
#include "CLayerModel.h"
|
||||||
|
#include "../UICommon.h"
|
||||||
|
|
||||||
CLayerModel::CLayerModel(QObject *pParent) : QAbstractListModel(pParent)
|
CLayerModel::CLayerModel(QObject *pParent) : QAbstractListModel(pParent)
|
||||||
{
|
{
|
||||||
|
@ -20,7 +21,7 @@ int CLayerModel::rowCount(const QModelIndex &parent) const
|
||||||
QVariant CLayerModel::data(const QModelIndex &index, int role) const
|
QVariant CLayerModel::data(const QModelIndex &index, int role) const
|
||||||
{
|
{
|
||||||
if (mpArea && (role == Qt::DisplayRole) && (index.row() < rowCount(QModelIndex())))
|
if (mpArea && (role == Qt::DisplayRole) && (index.row() < rowCount(QModelIndex())))
|
||||||
return QString::fromStdString(Layer(index)->Name());
|
return TO_QSTRING(Layer(index)->Name());
|
||||||
|
|
||||||
return QVariant::Invalid;
|
return QVariant::Invalid;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "CLinkModel.h"
|
#include "CLinkModel.h"
|
||||||
|
#include "../UICommon.h"
|
||||||
#include <Resource/CGameArea.h>
|
#include <Resource/CGameArea.h>
|
||||||
#include <Resource/script/CMasterTemplate.h>
|
#include <Resource/script/CMasterTemplate.h>
|
||||||
|
|
||||||
|
@ -54,8 +55,8 @@ QVariant CLinkModel::data(const QModelIndex &index, int role) const
|
||||||
CScriptObject *pTargetObj = mpObject->Area()->GetInstanceByID(link.ObjectID);
|
CScriptObject *pTargetObj = mpObject->Area()->GetInstanceByID(link.ObjectID);
|
||||||
|
|
||||||
if (pTargetObj) {
|
if (pTargetObj) {
|
||||||
QString ObjType = QString("[%1] ").arg(QString::fromStdString(pTargetObj->Template()->TemplateName()));
|
QString ObjType = QString("[%1] ").arg(UICommon::ToQString(pTargetObj->Template()->TemplateName()));
|
||||||
return ObjType + QString::fromStdString(pTargetObj->InstanceName());
|
return ObjType + UICommon::ToQString(pTargetObj->InstanceName());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
QString strID = QString::number(link.ObjectID, 16);
|
QString strID = QString::number(link.ObjectID, 16);
|
||||||
|
@ -66,14 +67,14 @@ QVariant CLinkModel::data(const QModelIndex &index, int role) const
|
||||||
|
|
||||||
case 1: // Column 1 - State
|
case 1: // Column 1 - State
|
||||||
{
|
{
|
||||||
std::string StateName = mpObject->MasterTemplate()->StateByID(link.State);
|
TString StateName = mpObject->MasterTemplate()->StateByID(link.State);
|
||||||
return QString::fromStdString(StateName);
|
return UICommon::ToQString(StateName);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 2: // Column 2 - Message
|
case 2: // Column 2 - Message
|
||||||
{
|
{
|
||||||
std::string MessageName = mpObject->MasterTemplate()->MessageByID(link.Message);
|
TString MessageName = mpObject->MasterTemplate()->MessageByID(link.Message);
|
||||||
return QString::fromStdString(MessageName);
|
return UICommon::ToQString(MessageName);
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "CTypesInstanceModel.h"
|
#include "CTypesInstanceModel.h"
|
||||||
|
#include "../UICommon.h"
|
||||||
#include <Scene/CScriptNode.h>
|
#include <Scene/CScriptNode.h>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
|
@ -219,9 +220,9 @@ QVariant CTypesInstanceModel::data(const QModelIndex &index, int role) const
|
||||||
{
|
{
|
||||||
if (index.column() == 0) {
|
if (index.column() == 0) {
|
||||||
if (mModelType == eLayers)
|
if (mModelType == eLayers)
|
||||||
return QString::fromStdString(mpEditor->ActiveArea()->GetScriptLayer(index.row())->Name());
|
return TO_QSTRING(mpEditor->ActiveArea()->GetScriptLayer(index.row())->Name());
|
||||||
else
|
else
|
||||||
return QString::fromStdString(mTemplateList[index.row()]->TemplateName());
|
return TO_QSTRING(mTemplateList[index.row()]->TemplateName());
|
||||||
}
|
}
|
||||||
// todo: show/hide button in column 2
|
// todo: show/hide button in column 2
|
||||||
else
|
else
|
||||||
|
@ -235,14 +236,14 @@ QVariant CTypesInstanceModel::data(const QModelIndex &index, int role) const
|
||||||
CScriptObject *pObj = static_cast<CScriptObject*>(index.internalPointer());
|
CScriptObject *pObj = static_cast<CScriptObject*>(index.internalPointer());
|
||||||
|
|
||||||
if (index.column() == 0)
|
if (index.column() == 0)
|
||||||
return QString::fromStdString(pObj->InstanceName());
|
return TO_QSTRING(pObj->InstanceName());
|
||||||
|
|
||||||
else if (index.column() == 1)
|
else if (index.column() == 1)
|
||||||
{
|
{
|
||||||
if (mModelType == eLayers)
|
if (mModelType == eLayers)
|
||||||
return QString::fromStdString(pObj->Template()->TemplateName());
|
return TO_QSTRING(pObj->Template()->TemplateName());
|
||||||
else if (mModelType == eTypes)
|
else if (mModelType == eTypes)
|
||||||
return QString::fromStdString(pObj->Layer()->Name());
|
return TO_QSTRING(pObj->Layer()->Name());
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue