74 lines
2.1 KiB
C++
74 lines
2.1 KiB
C++
/////////////////////////////////////////////////////////////////////
|
|
// Created by [Dennis Andersen] [2013]
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
#include "..\OResource.h"
|
|
#include "..\..\Utilities.h"
|
|
|
|
#include <fstream>
|
|
|
|
using namespace Oyster::Resource;
|
|
|
|
|
|
OResource* OResource::CustomLoader(const wchar_t filename[], CustomLoadFunction fnc)
|
|
{
|
|
<<<<<<< HEAD
|
|
CustomData &data = fnc(filename);
|
|
|
|
if(!data.loadedData) return 0;
|
|
if(!data.resourceUnloadFnc) return 0;
|
|
OHRESOURCE n = (OHRESOURCE)data.loadedData;
|
|
OResource *resource = new OResource(n, ResourceType_UNKNOWN, 0, 0, filename);
|
|
|
|
resource->customData = new CustomResourceData();
|
|
resource->customData->unloadingFunction = data.resourceUnloadFnc;
|
|
//resource->resourceData = (OHRESOURCE)data.loadedData;
|
|
=======
|
|
CustomData data;
|
|
memset(&data, 0, sizeof(CustomData));
|
|
|
|
fnc(filename, data);
|
|
|
|
if(!data.loadedData)
|
|
{
|
|
return 0;
|
|
}
|
|
if(!data.resourceUnloadFnc)
|
|
{
|
|
return 0;
|
|
}
|
|
/** For some wierd reason that i don't understand when trying to send data.loadedData directly as a
|
|
* parameter to OResource constructor, the value is changed when it arrives in the constructor.
|
|
* Doing it like this, storing in a temporary variable, the value stays correct. (What the fuck! I must be overloking something...)*/
|
|
//OHRESOURCE temp = data.loadedData;
|
|
OResource *resource = new OResource(data.loadedData, ResourceType_UNKNOWN, 0, 0, filename);
|
|
|
|
resource->customData = new CustomResourceData();
|
|
resource->customData->unloadingFunction = data.resourceUnloadFnc;
|
|
>>>>>>> d08644e8e1ecc56f4d9dfa6a9aa33df94d9e655a
|
|
resource->customData->loadingFunction = fnc;
|
|
|
|
return resource;
|
|
}
|
|
void OResource::CustomUnloader()
|
|
{
|
|
this->customData->unloadingFunction(this->resourceData);
|
|
}
|
|
OResource* OResource::CustomReloader()
|
|
{
|
|
CustomUnloader();
|
|
|
|
CustomData data;
|
|
memset(&data, 0, sizeof(CustomData));
|
|
|
|
this->customData->loadingFunction(this->resourceFilename.c_str(), data);
|
|
this->resourceData = (OHRESOURCE)data.loadedData;
|
|
|
|
if(data.resourceUnloadFnc)
|
|
{
|
|
this->customData->unloadingFunction = data.resourceUnloadFnc;
|
|
}
|
|
return this;
|
|
}
|
|
|