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

Conflicts:
	Code/Dokumentation/LevelLoader.uxf
	Code/Game/GameLogic/GameLogic.vcxproj
This commit is contained in:
Sam Mario Svensson 2014-01-24 10:42:19 +01:00
commit 3c1d66e3f8
9 changed files with 389 additions and 212 deletions

View File

@ -2,22 +2,21 @@
<diagram program="umlet" version="12.0">
<zoom_level>8</zoom_level>
<element>
<type>com.umlet.element.Class</type>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>624</x>
<y>208</y>
<w>80</w>
<h>24</h>
<x>640</x>
<y>256</y>
<w>40</w>
<h>168</h>
</coordinates>
<panel_attributes>LevelLoader
</panel_attributes>
<additional_attributes/>
<panel_attributes>lt=&lt;&lt;.</panel_attributes>
<additional_attributes>24;24;24;152</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>840</x>
<y>208</y>
<y>256</y>
<w>88</w>
<h>168</h>
</coordinates>
@ -25,150 +24,11 @@
&lt;Uses</panel_attributes>
<additional_attributes>24;24;24;64;72;64;72;152</additional_attributes>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>928</x>
<y>560</y>
<w>200</w>
<h>120</h>
</coordinates>
<panel_attributes>Collection of functions
&lt;&lt;lots of functions&gt;&gt;
--
functions for creating the right structs</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>440</x>
<y>88</y>
<w>128</w>
<h>40</h>
</coordinates>
<panel_attributes>GameLogic
&lt;&lt;Erik&gt;&gt;</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>680</x>
<y>176</y>
<w>152</w>
<h>56</h>
</coordinates>
<panel_attributes>lt=-
m1=1..1
m2=1..1
Uses&gt;</panel_attributes>
<additional_attributes>24;40;136;40</additional_attributes>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>800</x>
<y>360</y>
<w>208</w>
<h>136</h>
</coordinates>
<panel_attributes>&lt;&lt;Interface&gt;&gt;
Loader
--
Functions:
wchar* LoadFile(string fileName);
//Model* LoadHitBoxes(string modelName);
//Model* LoadHitBoxes(int modelID);
-
Privates:</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>344</x>
<y>208</y>
<w>40</w>
<h>168</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;.</panel_attributes>
<additional_attributes>24;24;24;152</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>768</x>
<y>576</y>
<w>176</w>
<h>56</h>
</coordinates>
<panel_attributes>lt=-
m1=1..1
m2=1..1
Uses&gt;</panel_attributes>
<additional_attributes>24;40;160;40</additional_attributes>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>816</x>
<y>192</y>
<w>128</w>
<h>40</h>
</coordinates>
<panel_attributes>Resource Loader
&lt;&lt;Dennis&gt;&gt;&lt;&lt;Singleton&gt;</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>768</x>
<y>472</y>
<w>136</w>
<h>104</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes>
<additional_attributes>120;24;120;88;24;88</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>384</x>
<y>176</y>
<w>256</w>
<h>56</h>
</coordinates>
<panel_attributes>lt=-&gt;&gt;&gt;&gt;
m1=1..1
m2=1..1
&lt;Knows about</panel_attributes>
<additional_attributes>240;40;24;40</additional_attributes>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>256</x>
<y>360</y>
<w>232</w>
<h>104</h>
</coordinates>
<panel_attributes>Defines.h
&lt;&lt;Header file&gt;&gt;
--
Enum ObjectType(static, dynamic, specials);
.
Struct static;
Struct dynamic;
Struct specials</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>560</x>
<y>360</y>
<y>408</y>
<w>232</w>
<h>136</h>
</coordinates>
@ -184,69 +44,34 @@ Privates:
</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>640</x>
<y>208</y>
<w>40</w>
<h>168</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;.</panel_attributes>
<additional_attributes>24;24;24;152</additional_attributes>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>328</x>
<y>208</y>
<w>80</w>
<h>24</h>
<x>440</x>
<y>136</y>
<w>128</w>
<h>40</h>
</coordinates>
<panel_attributes>Defines</panel_attributes>
<panel_attributes>GameLogic
&lt;&lt;Erik&gt;&gt;</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Package</type>
<coordinates>
<x>248</x>
<y>320</y>
<w>248</w>
<h>160</h>
<x>552</x>
<y>368</y>
<w>584</w>
<h>368</h>
</coordinates>
<panel_attributes>Defines</panel_attributes>
<panel_attributes>LevelLoader</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>544</x>
<y>64</y>
<w>136</w>
<h>160</h>
</coordinates>
<panel_attributes>lt=lt=-&gt;&gt;&gt;&gt;
m1=1..1
m2=1..1
Uses&gt;</panel_attributes>
<additional_attributes>24;40;80;40;120;40;120;144</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>656</x>
<y>472</y>
<w>40</w>
<h>88</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes>
<additional_attributes>24;72;24;24</additional_attributes>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>560</x>
<y>544</y>
<y>592</y>
<w>232</w>
<h>136</h>
</coordinates>
@ -263,15 +88,190 @@ const int FileVersion;
</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>928</x>
<y>608</y>
<w>200</w>
<h>120</h>
</coordinates>
<panel_attributes>Collection of functions
&lt;&lt;lots of functions&gt;&gt;
--
functions for creating the right structs</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>768</x>
<y>520</y>
<w>136</w>
<h>104</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes>
<additional_attributes>120;24;120;88;24;88</additional_attributes>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>800</x>
<y>408</y>
<w>208</w>
<h>136</h>
</coordinates>
<panel_attributes>&lt;&lt;Interface&gt;&gt;
Loader
--
Functions:
wchar* LoadFile(string fileName);
//Model* LoadHitBoxes(string modelName);
//Model* LoadHitBoxes(int modelID);
-
Privates:</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>656</x>
<y>520</y>
<w>40</w>
<h>88</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;&lt;&lt;-</panel_attributes>
<additional_attributes>24;72;24;24</additional_attributes>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>328</x>
<y>256</y>
<w>80</w>
<h>24</h>
</coordinates>
<panel_attributes>Defines</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>680</x>
<y>224</y>
<w>152</w>
<h>56</h>
</coordinates>
<panel_attributes>lt=-
m1=1..1
m2=1..1
Uses&gt;</panel_attributes>
<additional_attributes>24;40;136;40</additional_attributes>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>624</x>
<y>256</y>
<w>80</w>
<h>24</h>
</coordinates>
<panel_attributes>LevelLoader
</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>344</x>
<y>256</y>
<w>40</w>
<h>168</h>
</coordinates>
<panel_attributes>lt=&lt;&lt;.</panel_attributes>
<additional_attributes>24;24;24;152</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>384</x>
<y>224</y>
<w>256</w>
<h>56</h>
</coordinates>
<panel_attributes>lt=-&gt;&gt;&gt;&gt;
m1=1..1
m2=1..1
&lt;Knows about</panel_attributes>
<additional_attributes>240;40;24;40</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>544</x>
<y>112</y>
<w>136</w>
<h>160</h>
</coordinates>
<panel_attributes>lt=lt=-&gt;&gt;&gt;&gt;
m1=1..1
m2=1..1
Uses&gt;</panel_attributes>
<additional_attributes>24;40;80;40;120;40;120;144</additional_attributes>
</element>
<element>
<type>com.umlet.element.Relation</type>
<coordinates>
<x>768</x>
<y>624</y>
<w>176</w>
<h>56</h>
</coordinates>
<panel_attributes>lt=-
m1=1..1
m2=1..1
Uses&gt;</panel_attributes>
<additional_attributes>24;40;160;40</additional_attributes>
</element>
<element>
<type>com.umlet.element.Package</type>
<coordinates>
<x>552</x>
<y>320</y>
<w>584</w>
<h>368</h>
<x>248</x>
<y>368</y>
<w>248</w>
<h>160</h>
</coordinates>
<panel_attributes>LevelLoader</panel_attributes>
<panel_attributes>Defines</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>256</x>
<y>408</y>
<w>232</w>
<h>104</h>
</coordinates>
<panel_attributes>Defines.h
&lt;&lt;Header file&gt;&gt;
--
Enum ObjectType(static, dynamic, specials);
.
Struct static;
Struct dynamic;
Struct specials</panel_attributes>
<additional_attributes/>
</element>
<element>
<type>com.umlet.element.Class</type>
<coordinates>
<x>816</x>
<y>240</y>
<w>128</w>
<h>40</h>
</coordinates>
<panel_attributes>Resource Loader
&lt;&lt;Dennis&gt;&gt;&lt;&lt;Singleton&gt;</panel_attributes>
<additional_attributes/>
</element>
</diagram>

View File

@ -187,6 +187,8 @@
<ClInclude Include="LevelLoader.h" />
<ClInclude Include="Loader.h" />
<ClInclude Include="Object.h" />
<ClInclude Include="ObjectDefines.h" />
<ClInclude Include="LevelParser.h" />
<ClInclude Include="Player.h" />
<ClInclude Include="StaticObject.h" />
<ClInclude Include="Team.h" />
@ -206,6 +208,7 @@
<ClCompile Include="Level.cpp" />
<ClCompile Include="LevelLoader.cpp" />
<ClCompile Include="Loader.cpp" />
<ClCompile Include="LevelParser.cpp" />
<ClCompile Include="Object.cpp" />
<ClCompile Include="Player.cpp" />
<ClCompile Include="StaticObject.cpp" />

View File

@ -4,14 +4,15 @@
#include "LevelLoader.h"
using namespace GameLogic;
using namespace GameLogic::LevelLoader;
using namespace GameLogic::LevelFileLoader;
std::vector<ObjectTypeHeader> LevelLoader::LoadLevel(std::string fileName)
{
Parser->parse(fileName);
return parser->Parse(fileName);
}
std::vector<ObjectTypeHeader> LevelLoader::LoadLevelHeader(std::string fileName)
ObjectTypeHeader LevelLoader::LoadLevelHeader(std::string fileName)
{
parser->parseHeader(fileName);
return parser->ParseHeader(fileName);
}

View File

@ -5,6 +5,7 @@
#ifndef LEVELLOADER_H
#define LEVELLOADER_H
#include <string>
#include <vector>
#include <Vector.h>
#include "ObjectDefines.h"
@ -16,13 +17,13 @@ namespace GameLogic
{
public:
LevelLoader(){this->parser = new Parser()};
~LevelLoader(){};
LevelLoader(){this->parser = new GameLogic::LevelFileLoader::LevelParser(); }
~LevelLoader(){}
std::vector<ObjectTypeHeader> LoadLevel(std::string fileName); //loads the level and objects from file
std::vector<ObjectTypeHeader> LoadLevelHeader(std::string fileName); //just for fast access for the meta information about the level.
ObjectTypeHeader LoadLevelHeader(std::string fileName); //just for fast access for the meta information about the level.
private:
LevelParser parser;
GameLogic::LevelFileLoader::LevelParser *parser;
};
}

View File

@ -0,0 +1,82 @@
#include "LevelParser.h"
using namespace GameLogic;
using namespace ::LevelFileLoader;
LevelParser::LevelParser()
{
}
LevelParser::~LevelParser()
{
}
//
std::vector<ObjectTypeHeader> LevelParser::Parse(std::string filename)
{
//Read entire level file.
std::vector<ObjectTypeHeader> objects;
unsigned int counter = 0;
unsigned int stringSize = 0;
while(counter < stringSize)
{
//Get typeID
int typeID = 0;
switch(typeID)
{
case TypeID_LevelHeader:
//Call function
counter += LevelHeaderSize;
break;
case TypeID_Object:
//Call function
counter += ObjectHeaderSize;
break;
default:
//Couldn't find typeID. FAIL!!!!!!
break;
}
}
return objects;
}
//
ObjectTypeHeader LevelParser::ParseHeader(std::string filename)
{
//Read entire level file.
//Find the header in the returned string.
unsigned int counter = 0;
unsigned int stringSize = 0;
ObjectTypeHeader header;
header.typeID = ObjectType_Level;
while(counter < stringSize)
{
int typeID = 0;
switch(typeID)
{
case TypeID_LevelHeader:
//Call function
break;
case TypeID_Object:
//Call function
counter += ObjectHeaderSize;
break;
default:
//Couldn't find typeID. FAIL!!!!!!
break;
}
}
return header;
}

View File

@ -0,0 +1,51 @@
#ifndef LEVEL_PARSER_H
#define LEVEL_PARSER_H
#include <string>
#include <vector>
#include "ObjectDefines.h"
namespace GameLogic
{
namespace LevelFileLoader
{
class LevelParser
{
public:
LevelParser();
~LevelParser();
//
std::vector<ObjectTypeHeader> Parse(std::string filename);
//
ObjectTypeHeader ParseHeader(std::string filename);
private:
static const int TypeHeaderSize = 4; //Including the TypeID
static const int ObjectHeaderSize = 10; //Including modelID, textureID, position, rotation, scale.
static const int LevelHeaderSize = 10; //Including Format version, Name, Map version etc.
static const int FormatVersionMajor = 1;
static const int FormatVersionMinor = 0;
/*************************************
Question
*************************************/
//Could we use the IDs in "ObjectDefines.h" or do we have to use our own???
enum TypeID
{
TypeID_LevelHeader,
TypeID_Player,
TypeID_Object,
TypeID_NUM_OF_TYPES,
ObjectType_Unknown = -1,
};
};
}
}
#endif

View File

@ -4,7 +4,7 @@
#include "Loader.h"
using namespace GameLogic::LevelLoader;
using namespace GameLogic::LevelFileLoader;
using namespace Oyster::Resource;
using namespace std;
@ -14,5 +14,5 @@ char* Loader::LoadFile(std::string fileName)
std::wstring temp(fileName.begin(), fileName.end());
//convert from wstring to wchar then loads the file
return OysterResource::LoadResource(temp.c_str(), Oyster::Resource::ResourceType::ResourceType_Byte_Raw, -1 , false);
return (char*)OysterResource::LoadResource(temp.c_str(), Oyster::Resource::ResourceType::ResourceType_Byte_Raw, -1 , false);
}

View File

@ -10,7 +10,7 @@
namespace GameLogic
{
namespace LevelLoader
namespace LevelFileLoader
{
class Loader
{

View File

@ -0,0 +1,39 @@
#ifndef OBJECT_DEFINES_H
#define OBJECT_DEFINES_H
namespace GameLogic
{
enum ObjectType
{
ObjectType_Level,
ObjectType_Static,
ObjectType_Dynamic,
ObjectType_NUM_OF_TYPES,
ObjectType_Unknown = -1,
};
struct ObjectTypeHeader
{
ObjectType typeID;
};
struct ObjectHeader : public ObjectTypeHeader
{
//Model,
//Texture
//Position
float position[3];
//Rotation
float rotation[3];
//Scale
float scale[3];
};
}
#endif