2013-11-26 21:51:40 +01:00
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
// Created by [Dennis Andersen] [2013]
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
2013-11-26 10:55:51 +01:00
|
|
|
|
|
|
|
#include "..\OResource.h"
|
|
|
|
#include "..\..\Utilities.h"
|
|
|
|
|
|
|
|
#include <fstream>
|
|
|
|
|
|
|
|
using namespace Oyster::Resource;
|
|
|
|
|
|
|
|
|
|
|
|
OResource* OResource::CustomLoader(const wchar_t filename[], CustomLoadFunction fnc)
|
|
|
|
{
|
2013-11-26 12:09:38 +01:00
|
|
|
const CustomData &data = fnc(filename);
|
2013-11-26 10:55:51 +01:00
|
|
|
|
|
|
|
if(!data.loadedData) return 0;
|
|
|
|
if(!data.resourceUnloadFnc) return 0;
|
|
|
|
|
|
|
|
OResource *resource = new OResource((OHRESOURCE)data.loadedData, ResourceType_UNKNOWN, 0, 0, filename);
|
|
|
|
|
|
|
|
resource->customData = new CustomResourceData();
|
|
|
|
resource->customData->unloadingFunction = data.resourceUnloadFnc;
|
|
|
|
resource->resourceData = (OHRESOURCE)data.loadedData;
|
|
|
|
resource->customData->loadingFunction = fnc;
|
|
|
|
|
|
|
|
return resource;
|
|
|
|
}
|
|
|
|
void OResource::CustomUnloader()
|
|
|
|
{
|
|
|
|
this->customData->unloadingFunction((void*)this->resourceData);
|
|
|
|
}
|
|
|
|
OResource* OResource::CustomReloader()
|
|
|
|
{
|
|
|
|
CustomUnloader();
|
|
|
|
|
2013-11-26 12:09:38 +01:00
|
|
|
const CustomData &data = this->customData->loadingFunction(this->resourceFilename.c_str());
|
2013-11-26 10:55:51 +01:00
|
|
|
this->resourceData = (OHRESOURCE)data.loadedData;
|
|
|
|
|
|
|
|
if(data.resourceUnloadFnc)
|
|
|
|
this->customData->unloadingFunction = data.resourceUnloadFnc;
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|