diff --git a/Code/Dokumentation/LevelLoader.uxf b/Code/Dokumentation/LevelLoader.uxf index 6cfb9c29..90dcb0f7 100644 --- a/Code/Dokumentation/LevelLoader.uxf +++ b/Code/Dokumentation/LevelLoader.uxf @@ -2,22 +2,21 @@ 8 - com.umlet.element.Class + com.umlet.element.Relation - 624 - 208 - 80 - 24 + 640 + 256 + 40 + 168 - LevelLoader - - + lt=<<. + 24;24;24;152 com.umlet.element.Relation 840 - 208 + 256 88 168 @@ -25,150 +24,11 @@ <Uses 24;24;24;64;72;64;72;152 - - com.umlet.element.Class - - 928 - 560 - 200 - 120 - - Collection of functions -<<lots of functions>> --- -functions for creating the right structs - - - - com.umlet.element.Class - - 440 - 88 - 128 - 40 - - GameLogic -<<Erik>> - - - - com.umlet.element.Relation - - 680 - 176 - 152 - 56 - - lt=- -m1=1..1 -m2=1..1 -Uses> - 24;40;136;40 - - - com.umlet.element.Class - - 800 - 360 - 208 - 136 - - <<Interface>> -Loader --- -Functions: -wchar* LoadFile(string fileName); -//Model* LoadHitBoxes(string modelName); -//Model* LoadHitBoxes(int modelID); -- -Privates: - - - - com.umlet.element.Relation - - 344 - 208 - 40 - 168 - - lt=<<. - 24;24;24;152 - - - com.umlet.element.Relation - - 768 - 576 - 176 - 56 - - lt=- -m1=1..1 -m2=1..1 -Uses> - 24;40;160;40 - - - com.umlet.element.Class - - 816 - 192 - 128 - 40 - - Resource Loader -<<Dennis>><<Singleton> - - - - com.umlet.element.Relation - - 768 - 472 - 136 - 104 - - lt=<<<<- - 120;24;120;88;24;88 - - - com.umlet.element.Relation - - 384 - 176 - 256 - 56 - - lt=->>>> -m1=1..1 -m2=1..1 -<Knows about - 240;40;24;40 - - - com.umlet.element.Class - - 256 - 360 - 232 - 104 - - Defines.h -<<Header file>> --- -Enum ObjectType(static, dynamic, specials); -. -Struct static; -Struct dynamic; -Struct specials - - com.umlet.element.Class 560 - 360 + 408 232 136 @@ -184,69 +44,34 @@ Privates: - - com.umlet.element.Relation - - 640 - 208 - 40 - 168 - - lt=<<. - 24;24;24;152 - com.umlet.element.Class - 328 - 208 - 80 - 24 + 440 + 136 + 128 + 40 - Defines + GameLogic +<<Erik>> com.umlet.element.Package - 248 - 320 - 248 - 160 + 552 + 368 + 584 + 368 - Defines + LevelLoader - - com.umlet.element.Relation - - 544 - 64 - 136 - 160 - - lt=lt=->>>> -m1=1..1 -m2=1..1 -Uses> - 24;40;80;40;120;40;120;144 - - - com.umlet.element.Relation - - 656 - 472 - 40 - 88 - - lt=<<<<- - 24;72;24;24 - com.umlet.element.Class 560 - 544 + 592 232 136 @@ -263,15 +88,190 @@ const int FileVersion; + + com.umlet.element.Class + + 928 + 608 + 200 + 120 + + Collection of functions +<<lots of functions>> +-- +functions for creating the right structs + + + + com.umlet.element.Relation + + 768 + 520 + 136 + 104 + + lt=<<<<- + 120;24;120;88;24;88 + + + com.umlet.element.Class + + 800 + 408 + 208 + 136 + + <<Interface>> +Loader +-- +Functions: +wchar* LoadFile(string fileName); +//Model* LoadHitBoxes(string modelName); +//Model* LoadHitBoxes(int modelID); +- +Privates: + + + + com.umlet.element.Relation + + 656 + 520 + 40 + 88 + + lt=<<<<- + 24;72;24;24 + + + com.umlet.element.Class + + 328 + 256 + 80 + 24 + + Defines + + + + com.umlet.element.Relation + + 680 + 224 + 152 + 56 + + lt=- +m1=1..1 +m2=1..1 +Uses> + 24;40;136;40 + + + com.umlet.element.Class + + 624 + 256 + 80 + 24 + + LevelLoader + + + + + com.umlet.element.Relation + + 344 + 256 + 40 + 168 + + lt=<<. + 24;24;24;152 + + + com.umlet.element.Relation + + 384 + 224 + 256 + 56 + + lt=->>>> +m1=1..1 +m2=1..1 +<Knows about + 240;40;24;40 + + + com.umlet.element.Relation + + 544 + 112 + 136 + 160 + + lt=lt=->>>> +m1=1..1 +m2=1..1 +Uses> + 24;40;80;40;120;40;120;144 + + + com.umlet.element.Relation + + 768 + 624 + 176 + 56 + + lt=- +m1=1..1 +m2=1..1 +Uses> + 24;40;160;40 + com.umlet.element.Package - 552 - 320 - 584 - 368 + 248 + 368 + 248 + 160 - LevelLoader + Defines + + + + com.umlet.element.Class + + 256 + 408 + 232 + 104 + + Defines.h +<<Header file>> +-- +Enum ObjectType(static, dynamic, specials); +. +Struct static; +Struct dynamic; +Struct specials + + + + com.umlet.element.Class + + 816 + 240 + 128 + 40 + + Resource Loader +<<Dennis>><<Singleton> diff --git a/Code/Game/GameLogic/GameLogic.vcxproj b/Code/Game/GameLogic/GameLogic.vcxproj index bfa96d35..ba7603a7 100644 --- a/Code/Game/GameLogic/GameLogic.vcxproj +++ b/Code/Game/GameLogic/GameLogic.vcxproj @@ -187,6 +187,8 @@ + + @@ -206,6 +208,7 @@ + diff --git a/Code/Game/GameLogic/LevelLoader.cpp b/Code/Game/GameLogic/LevelLoader.cpp index 0e302d37..3827251a 100644 --- a/Code/Game/GameLogic/LevelLoader.cpp +++ b/Code/Game/GameLogic/LevelLoader.cpp @@ -4,14 +4,15 @@ #include "LevelLoader.h" using namespace GameLogic; -using namespace GameLogic::LevelLoader; +using namespace GameLogic::LevelFileLoader; + std::vector LevelLoader::LoadLevel(std::string fileName) { - Parser->parse(fileName); + return parser->Parse(fileName); } -std::vector LevelLoader::LoadLevelHeader(std::string fileName) +ObjectTypeHeader LevelLoader::LoadLevelHeader(std::string fileName) { - parser->parseHeader(fileName); + return parser->ParseHeader(fileName); } \ No newline at end of file diff --git a/Code/Game/GameLogic/LevelLoader.h b/Code/Game/GameLogic/LevelLoader.h index c33cd09b..ed7aab4d 100644 --- a/Code/Game/GameLogic/LevelLoader.h +++ b/Code/Game/GameLogic/LevelLoader.h @@ -5,6 +5,7 @@ #ifndef LEVELLOADER_H #define LEVELLOADER_H +#include #include #include #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 LoadLevel(std::string fileName); //loads the level and objects from file - std::vector 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; }; } diff --git a/Code/Game/GameLogic/LevelParser.cpp b/Code/Game/GameLogic/LevelParser.cpp new file mode 100644 index 00000000..1f6a9398 --- /dev/null +++ b/Code/Game/GameLogic/LevelParser.cpp @@ -0,0 +1,82 @@ +#include "LevelParser.h" + +using namespace GameLogic; +using namespace ::LevelFileLoader; + +LevelParser::LevelParser() +{ +} + +LevelParser::~LevelParser() +{ +} + +// +std::vector LevelParser::Parse(std::string filename) +{ + //Read entire level file. + + std::vector 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; +} \ No newline at end of file diff --git a/Code/Game/GameLogic/LevelParser.h b/Code/Game/GameLogic/LevelParser.h new file mode 100644 index 00000000..bcb9cb31 --- /dev/null +++ b/Code/Game/GameLogic/LevelParser.h @@ -0,0 +1,51 @@ +#ifndef LEVEL_PARSER_H +#define LEVEL_PARSER_H + +#include +#include +#include "ObjectDefines.h" + +namespace GameLogic +{ + namespace LevelFileLoader + { + class LevelParser + { + public: + LevelParser(); + ~LevelParser(); + + // + std::vector 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 \ No newline at end of file diff --git a/Code/Game/GameLogic/Loader.cpp b/Code/Game/GameLogic/Loader.cpp index 3cc68c50..ec537765 100644 --- a/Code/Game/GameLogic/Loader.cpp +++ b/Code/Game/GameLogic/Loader.cpp @@ -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); } \ No newline at end of file diff --git a/Code/Game/GameLogic/Loader.h b/Code/Game/GameLogic/Loader.h index 0d0a662f..72d53854 100644 --- a/Code/Game/GameLogic/Loader.h +++ b/Code/Game/GameLogic/Loader.h @@ -10,7 +10,7 @@ namespace GameLogic { - namespace LevelLoader + namespace LevelFileLoader { class Loader { diff --git a/Code/Game/GameLogic/ObjectDefines.h b/Code/Game/GameLogic/ObjectDefines.h new file mode 100644 index 00000000..eae1b0c9 --- /dev/null +++ b/Code/Game/GameLogic/ObjectDefines.h @@ -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 \ No newline at end of file