1
0
mirror of https://github.com/ScrelliCopter/tmx2gba.git synced 2025-02-21 03:29:25 +11:00
This commit is contained in:
2022-09-07 02:34:09 +10:00
parent 6c2cca3fd5
commit a5ac1d9bfe
12 changed files with 470 additions and 735 deletions

48
src/tmxreader.hpp Normal file
View File

@@ -0,0 +1,48 @@
#ifndef TMXREADER_H
#define TMXREADER_H
#include <istream>
#include <vector>
#include <string>
#include <cstdint>
#include <rapidxml/rapidxml.hpp>
class TmxTileset;
class TmxLayer;
class TmxObject;
class TmxReader
{
public:
TmxReader() = default;
~TmxReader();
void Open(std::istream& aIn);
constexpr int GetWidth() const { return mWidth; }
constexpr int GetHeight() const { return mHeight; }
inline const TmxLayer* GetLayer(size_t aId) const { return mLayers.at(aId); }
const TmxLayer* GetLayer(const std::string& aName) const;
inline std::size_t GetLayerCount() const { return mLayers.size(); }
inline const TmxObject* GetObject(size_t aId) const { return mObjects.at(aId); }
inline size_t GetObjectCount() const { return mObjects.size(); }
uint32_t LidFromGid(uint32_t aGid);
private:
static bool DecodeMap(uint32_t* aOut, size_t aOutSize, const std::string& aStrIn);
void ReadTileset(rapidxml::xml_node<>* aXNode);
void ReadLayer(rapidxml::xml_node<>* aXNode);
void ReadObjects(rapidxml::xml_node<>* aXNode);
int mWidth, mHeight;
std::vector<TmxTileset*> mTilesets;
std::vector<TmxLayer*> mLayers;
std::vector<TmxObject*> mObjects;
std::vector<uint32_t> mGidTable;
};
#endif//TMXREADER_H