SHADE_Y3/SHADE_Managed/src/Assets/FontAsset.cxx

70 lines
2.6 KiB
C++
Raw Normal View History

/************************************************************************************//*!
\file Font.cxx
\author Tng Kah Wei, kahwei.tng, 390009620
\par email: kahwei.tng\@digipen.edu
\date Oct 28, 2022
\brief Contains the implementation of the functions of the managed Font class.
Note: This file is written in C++17/CLI.
Copyright (C) 2022 DigiPen Institute of Technology.
Reproduction or disclosure of this file or its contents without the prior written consent
of DigiPen Institute of Technology is prohibited.
*//*************************************************************************************/
// Precompiled Headers
#include "SHpch.h"
// Primary Header
#include "FontAsset.hxx"
// External Dependencies
#include "Resource/SHResourceManagerInterface.h"
2022-11-22 15:37:01 +08:00
// Project Headers
#include "Utility/Convert.hxx"
namespace SHADE
{
/*---------------------------------------------------------------------------------*/
2022-11-22 15:37:01 +08:00
/* Properties */
/*---------------------------------------------------------------------------------*/
Handle<SHFont> FontAsset::NativeObject::get()
2022-11-22 15:37:01 +08:00
try
{
return SHResourceManagerInterface::LoadOrGetFont(asset.NativeAssetID);
2022-11-22 15:37:01 +08:00
}
catch (const BadHandleCastException&)
{
return Handle<SHFont>();
}
AssetID FontAsset::NativeAssetID::get()
2022-11-22 15:37:01 +08:00
{
return asset.NativeAssetID;
}
/*---------------------------------------------------------------------------------*/
/* Constructors/Destructor */
/*---------------------------------------------------------------------------------*/
FontAsset::FontAsset(AssetID fontId)
: asset { fontId }
{}
2022-11-22 15:37:01 +08:00
/*---------------------------------------------------------------------------------*/
/* Operator Overloads */
/*---------------------------------------------------------------------------------*/
FontAsset::operator bool(FontAsset asset)
2022-11-22 15:37:01 +08:00
{
return asset.asset;
2022-11-22 15:37:01 +08:00
}
/*---------------------------------------------------------------------------------*/
/* Conversion Operators */
/*---------------------------------------------------------------------------------*/
FontAsset::operator Asset(FontAsset nativeAsset)
2022-11-22 15:37:01 +08:00
{
return nativeAsset.asset;
}
FontAsset::operator FontAsset(Asset asset)
2022-11-22 15:37:01 +08:00
{
return FontAsset(asset.NativeAssetID);
2022-11-22 15:37:01 +08:00
}
}