Adds SpriteRendererComponent and Image asset to the editor
parent
d2608b4851
commit
c901fe6f9b
@ -0,0 +1,73 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
* File - image.cpp
|
||||||
|
* Author - Joey Pollack
|
||||||
|
* Date - 2022/11/28 (y/m/d)
|
||||||
|
* Mod Date - 2022/11/28 (y/m/d)
|
||||||
|
* Description - The editor warpper for an Image asset
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#include "image.h"
|
||||||
|
#include <renderer/texture.h>
|
||||||
|
#include <utils/logger.h>
|
||||||
|
#include <editor/editor_helpers.h>
|
||||||
|
|
||||||
|
namespace lunarium { namespace editor {
|
||||||
|
|
||||||
|
Image::Image()
|
||||||
|
: EditorAsset(AssetType::EATYPE_IMAGE), mpImage(nullptr)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
lunarium::Texture* Image::GetImage() const
|
||||||
|
{
|
||||||
|
return mpImage;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Image::DrawProperties()
|
||||||
|
{
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
// SERIALIZATION
|
||||||
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
OpRes Image::LoadRawFile()
|
||||||
|
{
|
||||||
|
mpImage = FileLoaders::LoadImage(mAssetDir / GetFileLocation());
|
||||||
|
mpImage->FlipVertically();
|
||||||
|
if (!mpImage)
|
||||||
|
{
|
||||||
|
return OpRes::Fail("Could not load image file: %s", GetFileLocation().string().c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
return OpRes::OK();
|
||||||
|
}
|
||||||
|
|
||||||
|
OpRes Image::Serialize(nlohmann::ordered_json& node)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
return OpRes::OK();
|
||||||
|
}
|
||||||
|
|
||||||
|
OpRes Image::Deserialize(nlohmann::ordered_json& node)
|
||||||
|
{
|
||||||
|
LoadRawFile();
|
||||||
|
return OpRes::OK();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Image::IsValidNode(nlohmann::ordered_json& node)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
nlohmann::ordered_json Image::AsJSON()
|
||||||
|
{
|
||||||
|
return nlohmann::ordered_json();
|
||||||
|
}
|
||||||
|
|
||||||
|
}}
|
||||||
@ -0,0 +1,46 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
* File - image.h
|
||||||
|
* Author - Joey Pollack
|
||||||
|
* Date - 2022/11/28 (y/m/d)
|
||||||
|
* Mod Date - 2022/11/28 (y/m/d)
|
||||||
|
* Description - The editor warpper for an Image asset
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#ifndef LUNARIUM_EDITOR_TEXTURE_H_
|
||||||
|
#define LUNARIUM_EDITOR_TEXTURE_H_
|
||||||
|
|
||||||
|
|
||||||
|
#include "editor_asset.h"
|
||||||
|
#include <utils/uuid.h>
|
||||||
|
|
||||||
|
namespace lunarium
|
||||||
|
{
|
||||||
|
class Texture;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace lunarium { namespace editor {
|
||||||
|
|
||||||
|
class Image : public EditorAsset
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Image();
|
||||||
|
~Image();
|
||||||
|
|
||||||
|
[[nodiscard]] virtual OpRes LoadRawFile();
|
||||||
|
[[nodiscard]] virtual OpRes Serialize(nlohmann::ordered_json& node);
|
||||||
|
[[nodiscard]] virtual OpRes Deserialize(nlohmann::ordered_json& node);
|
||||||
|
[[nodiscord]] virtual bool IsValidNode(nlohmann::ordered_json& node);
|
||||||
|
[[nodiscard]] virtual nlohmann::ordered_json AsJSON();
|
||||||
|
|
||||||
|
bool DrawProperties();
|
||||||
|
|
||||||
|
lunarium::Texture* GetImage() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
lunarium::Texture* mpImage;
|
||||||
|
};
|
||||||
|
|
||||||
|
}}
|
||||||
|
|
||||||
|
|
||||||
|
#endif // LUNARIUM_EDITOR_TEXTURE_H_
|
||||||
Loading…
Reference in New Issue