Namespace ST for global vars
This commit is contained in:
parent
61ada33ee1
commit
7d8bcec025
@ -51,15 +51,6 @@ class TResourceManager
|
||||
{
|
||||
protected:
|
||||
public:
|
||||
std::string PathToResources;
|
||||
|
||||
boost::thread::id MainThreadId;
|
||||
|
||||
//std::vector<boost::function<void()>> MainThreadAsyncFunctionArr;
|
||||
|
||||
//boost::mutex FuncListMutex;
|
||||
//std::list<TFuncToPerform> MainThreadSyncFunctionList;
|
||||
|
||||
TTextureListClass TexList;
|
||||
TModelManager ModelManager;
|
||||
TFlexModelManager FlexModelManager;
|
||||
|
@ -26,6 +26,13 @@ WINDOWS AND ANDROID
|
||||
namespace SE
|
||||
{
|
||||
|
||||
namespace ST
|
||||
{
|
||||
|
||||
extern std::string PathToResources;
|
||||
|
||||
}
|
||||
|
||||
bool findString(char* in, char* list);
|
||||
//utility for opengl extensions parsing. Not safe
|
||||
|
||||
@ -243,7 +250,7 @@ std::string GetFilePath(const std::string& filename);
|
||||
|
||||
//Special for IOS, because Foundation.h conflicts with sq_plus.h
|
||||
|
||||
// Obviously, this returns ResourceManager->PathToResources
|
||||
// Obviously, this returns ST::PathToResources
|
||||
|
||||
std::string GetPathToResources();
|
||||
#endif
|
||||
|
@ -9,8 +9,13 @@
|
||||
namespace SE
|
||||
{
|
||||
|
||||
namespace ST
|
||||
{
|
||||
extern boost::asio::io_service MainThreadIoService;
|
||||
|
||||
extern boost::thread::id MainThreadId;
|
||||
}
|
||||
|
||||
#ifndef UTILS_ENGINE
|
||||
|
||||
struct TFuncToPerform
|
||||
|
@ -10,34 +10,7 @@ namespace SE
|
||||
template<typename RETURNTYPE>
|
||||
RETURNTYPE PerformInMainThread(boost::function<RETURNTYPE()> f)
|
||||
{
|
||||
/*
|
||||
if (boost::this_thread::get_id() == ResourceManager->MainThreadId)
|
||||
{
|
||||
return f();
|
||||
}
|
||||
else
|
||||
{
|
||||
RETURNTYPE result;
|
||||
|
||||
boost::mutex ServiceLock;
|
||||
|
||||
ServiceLock.lock();
|
||||
|
||||
boost::function<void()> cover_f = [&result, &ServiceLock, f]()
|
||||
{
|
||||
result = f();
|
||||
ServiceLock.unlock();
|
||||
};
|
||||
|
||||
MainThreadIoService.post(cover_f);
|
||||
|
||||
ServiceLock.lock();
|
||||
ServiceLock.unlock();
|
||||
|
||||
return result;
|
||||
}*/
|
||||
|
||||
if (boost::this_thread::get_id() == ResourceManager->MainThreadId)
|
||||
if (boost::this_thread::get_id() == ST::MainThreadId)
|
||||
{
|
||||
return f();
|
||||
}
|
||||
@ -56,7 +29,7 @@ namespace SE
|
||||
|
||||
serviceLock.lock();
|
||||
|
||||
MainThreadIoService.post(func);
|
||||
ST::MainThreadIoService.post(func);
|
||||
|
||||
serviceLock.lock();
|
||||
serviceLock.unlock();
|
||||
|
@ -155,7 +155,7 @@ bool TAnimList::LoadBoneSystemFromFileBn1(const std::string& fileName)
|
||||
int i;
|
||||
|
||||
cardinal fSize;
|
||||
boost::shared_array<cardinal> fileData = CreateMemFromFile<cardinal>(ResourceManager->PathToResources+fileName,fSize);
|
||||
boost::shared_array<cardinal> fileData = CreateMemFromFile<cardinal>(ST::PathToResources+fileName,fSize);
|
||||
|
||||
|
||||
|
||||
@ -238,7 +238,7 @@ bool TAnimList::LoadBoneSystemFromFileBn2(const std::string& fileName)
|
||||
int i;
|
||||
|
||||
cardinal fSize;
|
||||
boost::shared_array<cardinal> fileData = CreateMemFromFile<cardinal>(ResourceManager->PathToResources+fileName,fSize);
|
||||
boost::shared_array<cardinal> fileData = CreateMemFromFile<cardinal>(ST::PathToResources+fileName,fSize);
|
||||
|
||||
if (fileData == NULL)
|
||||
throw ErrorFileNotLoaded(fileName);
|
||||
@ -330,7 +330,7 @@ bool TAnimList::LoadAnimSequenceFromFileAn1(const std::string& fileName)
|
||||
if (AnimSequenceMap.count(shortFileName) == 0)
|
||||
{
|
||||
TAnimSequence animSeqience;
|
||||
if (animSeqience.LoadFromFileAn1(ResourceManager->PathToResources+fileName))
|
||||
if (animSeqience.LoadFromFileAn1(ST::PathToResources+fileName))
|
||||
{
|
||||
AnimSequenceMap[shortFileName] = animSeqience;
|
||||
return true;
|
||||
|
@ -52,7 +52,7 @@ void TFontManager::AddFont(const std::string& fontName, const std::string& bitma
|
||||
|
||||
cardinal byteCount;
|
||||
|
||||
boost::shared_array<char> charmapFileArr = boost::shared_array<char>(CreateMemFromFile<char>(ResourceManager->PathToResources+charmapFile, byteCount));
|
||||
boost::shared_array<char> charmapFileArr = boost::shared_array<char>(CreateMemFromFile<char>(ST::PathToResources+charmapFile, byteCount));
|
||||
|
||||
//Need to rewrite this code :(
|
||||
|
||||
|
@ -333,13 +333,13 @@ bool TModelManager::AddLiteModel(const std::string& filename, const std::string&
|
||||
if (LiteModelMap.count(modelName) != 0)
|
||||
return true;
|
||||
|
||||
boost::shared_array<byte> fileArr = CreateMemFromFile<byte>((ResourceManager->PathToResources + filename), fileSize);
|
||||
boost::shared_array<byte> fileArr = CreateMemFromFile<byte>((ST::PathToResources + filename), fileSize);
|
||||
|
||||
if (!(fileArr[0] == 'L' && fileArr[1] == 'M' && fileArr[2] == 0 && fileArr[3] == 1))
|
||||
throw ErrorFileNotCorrect(filename);
|
||||
|
||||
|
||||
LiteModelMap[modelName].SetPathToResource(GetFilePath(ResourceManager->PathToResources + filename));
|
||||
LiteModelMap[modelName].SetPathToResource(GetFilePath(ST::PathToResources + filename));
|
||||
|
||||
bool result = LiteModelMap[modelName].LoadModel(fileArr, fileSize);
|
||||
|
||||
|
@ -25,36 +25,13 @@ TResourceManager* ResourceManager;
|
||||
void TResourceManager::Update(cardinal timer)
|
||||
{
|
||||
|
||||
//FuncListMutex.lock();
|
||||
|
||||
SoundManager.Update(timer);
|
||||
|
||||
GUIManager.Update(timer);
|
||||
/*
|
||||
if (MainThreadAsyncFunctionArr.size() != 0)
|
||||
{
|
||||
MainThreadAsyncFunctionArr[0]();
|
||||
|
||||
MainThreadAsyncFunctionArr.erase(MainThreadAsyncFunctionArr.begin());
|
||||
}
|
||||
ST::MainThreadIoService.run();
|
||||
|
||||
auto itr = MainThreadSyncFunctionList.begin();
|
||||
|
||||
while (itr != MainThreadSyncFunctionList.end() && itr->Executed)
|
||||
{
|
||||
itr++;
|
||||
}
|
||||
|
||||
if (itr != MainThreadSyncFunctionList.end())
|
||||
{
|
||||
itr->Func();
|
||||
itr->Executed = true;
|
||||
itr->LockerPtr->unlock();
|
||||
}
|
||||
|
||||
FuncListMutex.unlock();*/
|
||||
MainThreadIoService.run();
|
||||
MainThreadIoService.reset();
|
||||
ST::MainThreadIoService.reset();
|
||||
}
|
||||
|
||||
TResourceManager::~TResourceManager()
|
||||
@ -77,7 +54,7 @@ TApplicationAncestor::~TApplicationAncestor()
|
||||
|
||||
void TApplicationAncestor::OuterInit(int screenWidth, int screenHeight, float matrixWidth, float matrixHeight)
|
||||
{
|
||||
ResourceManager->MainThreadId = boost::this_thread::get_id();
|
||||
ST::MainThreadId = boost::this_thread::get_id();
|
||||
|
||||
ResourceManager->ScriptManager.BindBasicFunctions();
|
||||
|
||||
|
@ -202,7 +202,7 @@ void TShaderManager::Serialize(boost::property_tree::ptree& propertyTree)
|
||||
bool TShaderManager::AddShader(const std::string& shaderName, const std::string& vertexFileName, const std::string& fragmentFileName)
|
||||
{
|
||||
|
||||
std::string pathToResources = ResourceManager->PathToResources;
|
||||
std::string pathToResources = ST::PathToResources;
|
||||
|
||||
if (ShaderList.count(shaderName) > 0)
|
||||
{
|
||||
|
@ -238,7 +238,7 @@ bool TSimpleLandClass::LoadFromFile(const std::string& filename)
|
||||
{
|
||||
|
||||
cardinal dwordCount;
|
||||
boost::shared_array<cardinal> fileArr = CreateMemFromFile<cardinal>((ResourceManager->PathToResources + filename).c_str(), dwordCount);
|
||||
boost::shared_array<cardinal> fileArr = CreateMemFromFile<cardinal>((ST::PathToResources + filename).c_str(), dwordCount);
|
||||
|
||||
if ((((char*)&fileArr[0])[0]!='L')||
|
||||
(((char*)&fileArr[0])[1]!='S')||
|
||||
|
@ -735,7 +735,7 @@ cardinal TTextureListClass::AddTexture(const std::string& fileName)
|
||||
|
||||
cardinal TTextureListClass::AddTexture(const std::string& fileName, std::string texName)
|
||||
{
|
||||
std::string fullFileName = ResourceManager->PathToResources + fileName;
|
||||
std::string fullFileName = ST::PathToResources + fileName;
|
||||
|
||||
return AddTextureDirectly(fullFileName, texName);
|
||||
}
|
||||
@ -758,12 +758,12 @@ cardinal TTextureListClass::AddTextureFromUserdata(const std::string& fileName,
|
||||
cardinal TTextureListClass::AddCubemapTexture(std::string filename[6])
|
||||
{
|
||||
|
||||
filename[0] = ResourceManager->PathToResources + filename[0];
|
||||
filename[1] = ResourceManager->PathToResources + filename[1];
|
||||
filename[2] = ResourceManager->PathToResources + filename[2];
|
||||
filename[3] = ResourceManager->PathToResources + filename[3];
|
||||
filename[4] = ResourceManager->PathToResources + filename[4];
|
||||
filename[5] = ResourceManager->PathToResources + filename[5];
|
||||
filename[0] = ST::PathToResources + filename[0];
|
||||
filename[1] = ST::PathToResources + filename[1];
|
||||
filename[2] = ST::PathToResources + filename[2];
|
||||
filename[3] = ST::PathToResources + filename[3];
|
||||
filename[4] = ST::PathToResources + filename[4];
|
||||
filename[5] = ST::PathToResources + filename[5];
|
||||
|
||||
std::string texname = GetFileName(filename[0]);
|
||||
std::string texext;
|
||||
|
@ -9,6 +9,13 @@
|
||||
namespace SE
|
||||
{
|
||||
|
||||
namespace ST
|
||||
{
|
||||
|
||||
std::string PathToResources;
|
||||
|
||||
}
|
||||
|
||||
bool findString(char* in, char* list)
|
||||
{
|
||||
int thisLength = strlen(in);
|
||||
@ -82,7 +89,7 @@ std::string GetFilePathUserData(const std::string& filename)
|
||||
//Special for IOS -> Foundation.h conflicts with sq_plus.h
|
||||
std::string GetPathToResources()
|
||||
{
|
||||
return ResourceManager->PathToResources;
|
||||
return ST::PathToResources;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -56,7 +56,7 @@ boost::property_tree::ptree::iterator ReplaceIncludeFile(boost::property_tree::p
|
||||
#ifdef UTILS_ENGINE
|
||||
xmlFileArr = CreateMemFromFile<char>(fileName, xmlFileSize);
|
||||
#else
|
||||
xmlFileArr = CreateMemFromFile<char>(ResourceManager->PathToResources + fileName, xmlFileSize);
|
||||
xmlFileArr = CreateMemFromFile<char>(ST::PathToResources + fileName, xmlFileSize);
|
||||
#endif
|
||||
|
||||
std::string xmlString = std::string(&xmlFileArr[0], &xmlFileArr[xmlFileSize]);
|
||||
@ -150,7 +150,7 @@ std::shared_ptr<boost::property_tree::ptree> FileToPropertyTree(const std::strin
|
||||
#ifdef UTILS_ENGINE
|
||||
boost::shared_array<char> file = CreateMemFromFile<char>(fileName, byteCount);
|
||||
#else
|
||||
boost::shared_array<char> file = CreateMemFromFile<char>(ResourceManager->PathToResources + fileName, byteCount);
|
||||
boost::shared_array<char> file = CreateMemFromFile<char>(ST::PathToResources + fileName, byteCount);
|
||||
#endif
|
||||
|
||||
return FileToPropertyTree(file, byteCount, replaceMap);
|
||||
|
@ -3,12 +3,16 @@
|
||||
namespace SE
|
||||
{
|
||||
|
||||
namespace ST
|
||||
{
|
||||
boost::asio::io_service MainThreadIoService;
|
||||
|
||||
boost::thread::id MainThreadId;
|
||||
}
|
||||
#ifndef UTILS_ENGINE
|
||||
void AssertIfInMainThread()
|
||||
{
|
||||
if (boost::this_thread::get_id() != ResourceManager->MainThreadId)
|
||||
if (boost::this_thread::get_id() != ST::MainThreadId)
|
||||
{
|
||||
throw ErrorToLog("ERROR! AssertIfInMainThread - assert failed!");
|
||||
}
|
||||
@ -16,16 +20,16 @@ namespace SE
|
||||
|
||||
void TryUpdateMainThreadId()
|
||||
{
|
||||
if (boost::this_thread::get_id() != ResourceManager->MainThreadId)
|
||||
if (boost::this_thread::get_id() != ST::MainThreadId)
|
||||
{
|
||||
ResourceManager->MainThreadId = boost::this_thread::get_id();
|
||||
ST::MainThreadId = boost::this_thread::get_id();
|
||||
}
|
||||
}
|
||||
|
||||
void PerformInMainThreadAsync(boost::function<void()> f)
|
||||
{
|
||||
|
||||
if (boost::this_thread::get_id() == ResourceManager->MainThreadId)
|
||||
if (boost::this_thread::get_id() == ST::MainThreadId)
|
||||
{
|
||||
f();
|
||||
}
|
||||
@ -43,7 +47,7 @@ namespace SE
|
||||
|
||||
|
||||
serviceLock.lock();
|
||||
MainThreadIoService.post(func);
|
||||
ST::MainThreadIoService.post(func);
|
||||
|
||||
serviceLock.lock();
|
||||
serviceLock.unlock();
|
||||
|
Loading…
Reference in New Issue
Block a user