|
|
|
|
/******************************************************************************
|
|
|
|
|
* File - tile_set.h
|
|
|
|
|
* Author - Joey Pollack
|
|
|
|
|
* Date - 2022/02/16 (y/m/d)
|
|
|
|
|
* Mod Date - 2022/02/16 (y/m/d)
|
|
|
|
|
* Description - Manage a tile set for map making
|
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
|
|
#ifndef TILE_SET_H_
|
|
|
|
|
#define TILE_SET_H_
|
|
|
|
|
|
|
|
|
|
#include "editor_asset.h"
|
|
|
|
|
#include <core/types.h>
|
|
|
|
|
#include <filesystem>
|
|
|
|
|
|
|
|
|
|
namespace lunarium { class Texture; class Renderer2D; }
|
|
|
|
|
|
|
|
|
|
namespace lunarium { namespace editor
|
|
|
|
|
{
|
|
|
|
|
class TileSet : public EditorAsset
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
TileSet();
|
|
|
|
|
|
|
|
|
|
// Load the raw asset file from the internal location
|
|
|
|
|
OpRes LoadRawFile();
|
|
|
|
|
OpRes Serialize(nlohmann::ordered_json& node);
|
|
|
|
|
OpRes Deserialize(nlohmann::ordered_json& node);
|
|
|
|
|
bool IsValidNode(nlohmann::ordered_json& node);
|
|
|
|
|
nlohmann::ordered_json AsJSON();
|
|
|
|
|
void DrawProperties();
|
|
|
|
|
|
|
|
|
|
void SetTileSetID(int id);
|
|
|
|
|
int GetTileSetID() const;
|
|
|
|
|
|
|
|
|
|
void SetImage(lunarium::Texture* image);
|
|
|
|
|
void SetTileSize(Sizei size);
|
|
|
|
|
|
|
|
|
|
lunarium::Texture* GetImage();
|
|
|
|
|
Sizei GetTileSize();
|
|
|
|
|
Rectangle GetTileRect(Vec2i index);
|
|
|
|
|
|
|
|
|
|
void Render(lunarium::Renderer2D* g);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
lunarium::Texture* mSetImage;
|
|
|
|
|
Sizei mTileSize; // in pixels, must be a square power of 2
|
|
|
|
|
Sizei mNumTiles;
|
|
|
|
|
int mTileSetID;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
|
|
#endif // TILE_SET_H_
|