2022-11-21 20:58:47 +08:00
|
|
|
/************************************************************************************//*!
|
|
|
|
\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
|
2022-11-22 16:51:07 +08:00
|
|
|
#include "FontAsset.hxx"
|
|
|
|
// External Dependencies
|
|
|
|
#include "Resource/SHResourceManagerInterface.h"
|
2022-11-22 15:37:01 +08:00
|
|
|
// Project Headers
|
|
|
|
#include "Utility/Convert.hxx"
|
2022-11-21 20:58:47 +08:00
|
|
|
|
|
|
|
namespace SHADE
|
|
|
|
{
|
|
|
|
/*---------------------------------------------------------------------------------*/
|
2022-11-22 15:37:01 +08:00
|
|
|
/* Properties */
|
2022-11-21 20:58:47 +08:00
|
|
|
/*---------------------------------------------------------------------------------*/
|
2022-11-22 16:51:07 +08:00
|
|
|
Handle<SHFont> FontAsset::NativeObject::get()
|
2022-11-22 15:37:01 +08:00
|
|
|
try
|
|
|
|
{
|
2022-11-22 16:51:07 +08:00
|
|
|
return SHResourceManagerInterface::LoadOrGetFont(asset.NativeAssetID);
|
2022-11-22 15:37:01 +08:00
|
|
|
}
|
|
|
|
catch (const BadHandleCastException&)
|
|
|
|
{
|
|
|
|
return Handle<SHFont>();
|
|
|
|
}
|
2022-11-22 16:51:07 +08:00
|
|
|
AssetID FontAsset::NativeAssetID::get()
|
2022-11-22 15:37:01 +08:00
|
|
|
{
|
|
|
|
return asset.NativeAssetID;
|
|
|
|
}
|
2022-11-21 20:58:47 +08:00
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------------*/
|
|
|
|
/* Constructors/Destructor */
|
|
|
|
/*---------------------------------------------------------------------------------*/
|
2022-11-22 16:51:07 +08:00
|
|
|
FontAsset::FontAsset(AssetID fontId)
|
|
|
|
: asset { fontId }
|
2022-11-21 20:58:47 +08:00
|
|
|
{}
|
2022-11-22 15:37:01 +08:00
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------------*/
|
|
|
|
/* Operator Overloads */
|
|
|
|
/*---------------------------------------------------------------------------------*/
|
2022-11-22 16:51:07 +08:00
|
|
|
FontAsset::operator bool(FontAsset asset)
|
2022-11-22 15:37:01 +08:00
|
|
|
{
|
2022-11-22 17:48:01 +08:00
|
|
|
return asset.asset;
|
2022-11-22 15:37:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------------*/
|
|
|
|
/* Conversion Operators */
|
|
|
|
/*---------------------------------------------------------------------------------*/
|
2022-11-22 16:51:07 +08:00
|
|
|
FontAsset::operator Asset(FontAsset nativeAsset)
|
2022-11-22 15:37:01 +08:00
|
|
|
{
|
|
|
|
return nativeAsset.asset;
|
|
|
|
}
|
|
|
|
|
2022-11-22 16:51:07 +08:00
|
|
|
FontAsset::operator FontAsset(Asset asset)
|
2022-11-22 15:37:01 +08:00
|
|
|
{
|
2022-11-22 16:51:07 +08:00
|
|
|
return FontAsset(asset.NativeAssetID);
|
2022-11-22 15:37:01 +08:00
|
|
|
}
|
2022-11-21 20:58:47 +08:00
|
|
|
}
|