Merge branch 'GameLogic' of https://github.com/dean11/Danbias into GameLogic

This commit is contained in:
lindaandersson 2014-02-10 16:29:04 +01:00
commit f473136ae1
5 changed files with 63 additions and 18 deletions

View File

@ -17,7 +17,14 @@ struct LevelLoader::PrivData
LevelLoader::LevelLoader() LevelLoader::LevelLoader()
: pData(new PrivData) : pData(new PrivData)
{ {
pData->folderPath = "Standard path"; //standard path
pData->folderPath = "";
}
LevelLoader::LevelLoader(std::string folderPath)
: pData(new PrivData)
{
pData->folderPath = folderPath;
} }
LevelLoader::~LevelLoader() LevelLoader::~LevelLoader()
@ -26,10 +33,20 @@ LevelLoader::~LevelLoader()
std::vector<Utility::DynamicMemory::SmartPointer<ObjectTypeHeader>> LevelLoader::LoadLevel(std::string fileName) std::vector<Utility::DynamicMemory::SmartPointer<ObjectTypeHeader>> LevelLoader::LoadLevel(std::string fileName)
{ {
return pData->parser.Parse(fileName); return pData->parser.Parse(pData->folderPath + fileName);
} }
LevelMetaData LevelLoader::LoadLevelHeader(std::string fileName) LevelMetaData LevelLoader::LoadLevelHeader(std::string fileName)
{ {
return pData->parser.ParseHeader(fileName); return pData->parser.ParseHeader(pData->folderPath + fileName);
}
std::string LevelLoader::GetFolderPath()
{
return this->pData->folderPath;
}
void LevelLoader::SetFolderPath(std::string folderPath)
{
} }

View File

@ -17,11 +17,15 @@ namespace GameLogic
public: public:
LevelLoader(); LevelLoader();
/***********************************************************
* Lets you set the standard folderpath for the levels
********************************************************/
LevelLoader(std::string folderPath);
~LevelLoader(); ~LevelLoader();
/******************************************************** /********************************************************
* Loads the level and objects from file. * Loads the level and objects from file.
* @param fileName: Path to the level-file that you want to load. * @param fileName: Path/name to the level-file that you want to load.
* @return: Returns all structs with objects and information about the level. * @return: Returns all structs with objects and information about the level.
********************************************************/ ********************************************************/
std::vector<Utility::DynamicMemory::SmartPointer<ObjectTypeHeader>> LoadLevel(std::string fileName); std::vector<Utility::DynamicMemory::SmartPointer<ObjectTypeHeader>> LoadLevel(std::string fileName);
@ -33,6 +37,16 @@ namespace GameLogic
********************************************************/ ********************************************************/
LevelMetaData LoadLevelHeader(std::string fileName); //. LevelMetaData LoadLevelHeader(std::string fileName); //.
/***********************************************************
* @return: Returns the current standard folder path
********************************************************/
std::string GetFolderPath();
/***********************************************************
* Sets the standard folder path
********************************************************/
void SetFolderPath(std::string folderPath);
private: private:
struct PrivData; struct PrivData;
Utility::DynamicMemory::SmartPointer<PrivData> pData; Utility::DynamicMemory::SmartPointer<PrivData> pData;

View File

@ -13,7 +13,7 @@ using namespace Utility::DynamicMemory;
LevelParser::LevelParser() LevelParser::LevelParser()
{ {
formatVersion.formatVersionMajor = 2; formatVersion.formatVersionMajor = 3;
formatVersion.formatVersionMinor = 0; formatVersion.formatVersionMinor = 0;
} }
@ -71,7 +71,6 @@ std::vector<SmartPointer<ObjectTypeHeader>> LevelParser::Parse(std::string filen
{ {
//These three does not have any specail variables at this time. //These three does not have any specail variables at this time.
//There for they are using the same 'parser'. //There for they are using the same 'parser'.
case ObjectSpecialType_World:
case ObjectSpecialType_Building: case ObjectSpecialType_Building:
case ObjectSpecialType_Damaging: case ObjectSpecialType_Damaging:
case ObjectSpecialType_Explosive: case ObjectSpecialType_Explosive:
@ -113,17 +112,26 @@ std::vector<SmartPointer<ObjectTypeHeader>> LevelParser::Parse(std::string filen
break; break;
} }
case ObjectSpecialType_SpawnPoint:
case ObjectSpecialType_World:
{ {
SpawnPointAttributes* header = new SpawnPointAttributes; WorldAttributes* header = new WorldAttributes;
ParseObject(&buffer[counter], *header, counter); ParseObject(&buffer[counter], *header, counter);
ParseObject(&buffer[counter], header->spawnPosition, 12); ParseObject(&buffer[counter], &header->worldSize, 8);
objects.push_back(header); objects.push_back(header);
break; break;
} }
case ObjectSpecialType_Sky:
{
SkyAttributes* header = new SkyAttributes;
ParseObject(&buffer[counter], *header, counter);
ParseObject(&buffer[counter], &header->skySize, 4);
objects.push_back(header);
break;
}
default: default:
//Couldn't find specialType //Couldn't find specialType
break; break;
@ -240,9 +248,6 @@ LevelMetaData LevelParser::ParseHeader(std::string filename)
case ObjectSpecialType_Portal: case ObjectSpecialType_Portal:
counter += sizeof(12); counter += sizeof(12);
break; break;
case ObjectSpecialType_SpawnPoint:
counter += sizeof(12);
break;
default: default:
break; break;
} }

View File

@ -32,7 +32,7 @@ namespace GameLogic
ObjectSpecialType_JumpPad, ObjectSpecialType_JumpPad,
ObjectSpecialType_BoostPad, ObjectSpecialType_BoostPad,
ObjectSpecialType_Portal, ObjectSpecialType_Portal,
ObjectSpecialType_SpawnPoint, ObjectSpecialType_Sky,
ObjectSpecialType_Count, ObjectSpecialType_Count,
ObjectSpecialType_Unknown = -1 ObjectSpecialType_Unknown = -1
@ -134,7 +134,7 @@ namespace GameLogic
namespace LevelLoaderInternal namespace LevelLoaderInternal
{ {
const FormatVersion boundingVolumeVersion(1, 0); const FormatVersion boundingVolumeVersion(2, 0);
struct BoundingVolumeBase struct BoundingVolumeBase
{ {
@ -224,11 +224,19 @@ namespace GameLogic
float destination[3]; float destination[3];
}; };
struct SpawnPointAttributes : public ObjectHeader struct WorldAttributes : public ObjectHeader
{ {
float spawnPosition[3]; float worldSize;
float atmoSphereSize;
}; };
struct SkyAttributes : public ObjectHeader
{
float skySize;
};
/************************************ /************************************
Lights Lights
*************************************/ *************************************/

View File

@ -16,6 +16,7 @@ namespace GameLogic
{ {
namespace LevelFileLoader namespace LevelFileLoader
{ {
//can parse any struct without strings or char[]
void ParseObject(char* buffer, void *header, int size) void ParseObject(char* buffer, void *header, int size)
{ {
memcpy(header, buffer, size); memcpy(header, buffer, size);