Renamed SHTextRenderer and to SHTextRenderable and added C# interface #239
|
@ -33,6 +33,8 @@ project "SHADE_Managed"
|
||||||
"%{IncludeDir.imgui}",
|
"%{IncludeDir.imgui}",
|
||||||
"%{IncludeDir.imguizmo}",
|
"%{IncludeDir.imguizmo}",
|
||||||
"%{IncludeDir.imnodes}",
|
"%{IncludeDir.imnodes}",
|
||||||
|
"%{IncludeDir.msdf_atlas_gen}",
|
||||||
|
"%{IncludeDir.msdfgen}",
|
||||||
"%{IncludeDir.yamlcpp}",
|
"%{IncludeDir.yamlcpp}",
|
||||||
"%{IncludeDir.SDL}\\include",
|
"%{IncludeDir.SDL}\\include",
|
||||||
"%{IncludeDir.RTTR}/include",
|
"%{IncludeDir.RTTR}/include",
|
||||||
|
@ -53,6 +55,8 @@ project "SHADE_Managed"
|
||||||
links
|
links
|
||||||
{
|
{
|
||||||
"yaml-cpp",
|
"yaml-cpp",
|
||||||
|
"msdfgen",
|
||||||
|
"msdf-atlas-gen",
|
||||||
"imgui",
|
"imgui",
|
||||||
"SDL2.lib",
|
"SDL2.lib",
|
||||||
"SDL2main.lib",
|
"SDL2main.lib",
|
||||||
|
@ -89,6 +93,8 @@ project "SHADE_Managed"
|
||||||
dependson
|
dependson
|
||||||
{
|
{
|
||||||
"yaml-cpp",
|
"yaml-cpp",
|
||||||
|
"msdfgen",
|
||||||
|
"msdf-atlas-gen",
|
||||||
"imgui",
|
"imgui",
|
||||||
"SHADE_Engine"
|
"SHADE_Engine"
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
/************************************************************************************//*!
|
||||||
|
\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 "Font.hxx"
|
||||||
|
|
||||||
|
namespace SHADE
|
||||||
|
{
|
||||||
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
/* Explicit Template Instantiation */
|
||||||
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
template ref class NativeAsset<SHFont>;
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
/* Constructors/Destructor */
|
||||||
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
Font::Font(Handle<SHFont> font)
|
||||||
|
: NativeAsset<SHFont> { font }
|
||||||
|
{}
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
/************************************************************************************//*!
|
||||||
|
\file Font.hxx
|
||||||
|
\author Tng Kah Wei, kahwei.tng, 390009620
|
||||||
|
\par email: kahwei.tng\@digipen.edu
|
||||||
|
\date Oct 28, 2022
|
||||||
|
\brief Contains the definition 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.
|
||||||
|
*//*************************************************************************************/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
// External Dependencies
|
||||||
|
#include "Resource/SHHandle.h"
|
||||||
|
#include "Graphics/MiddleEnd/TextRendering/SHFont.h"
|
||||||
|
// Project Includes
|
||||||
|
#include "NativeAsset.hxx"
|
||||||
|
#include "Engine/GenericHandle.hxx"
|
||||||
|
|
||||||
|
namespace SHADE
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Managed counterpart of the native Font object that can be fed to TextRenderables
|
||||||
|
/// for rendering.
|
||||||
|
/// </summary>
|
||||||
|
public ref class Font : public NativeAsset<SHFont>
|
||||||
|
{
|
||||||
|
internal:
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
/* Constructors/Destructor */
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor for the Font.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="font">Handle to the font object.</param>
|
||||||
|
Font(Handle<SHFont> font);
|
||||||
|
};
|
||||||
|
}
|
|
@ -16,6 +16,7 @@ of DigiPen Institute of Technology is prohibited.
|
||||||
|
|
||||||
// Primary Include
|
// Primary Include
|
||||||
#include "NativeAsset.hxx"
|
#include "NativeAsset.hxx"
|
||||||
|
#include "Utility/Convert.hxx"
|
||||||
|
|
||||||
namespace SHADE
|
namespace SHADE
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
/************************************************************************************//*!
|
||||||
|
\file TextRenderable.cxx
|
||||||
|
\author Tng Kah Wei, kahwei.tng, 390009620
|
||||||
|
\par email: kahwei.tng\@digipen.edu
|
||||||
|
\date Oct 28, 2022
|
||||||
|
\brief Contains the definition of the functions of the managed TextRenderable
|
||||||
|
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 "TextRenderable.hxx"
|
||||||
|
#include "Assets/NativeAsset.hxx"
|
||||||
|
#include "Utility/Convert.hxx"
|
||||||
|
|
||||||
|
namespace SHADE
|
||||||
|
{
|
||||||
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
/* Constructors */
|
||||||
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
TextRenderable::TextRenderable(Entity entity)
|
||||||
|
: Component(entity)
|
||||||
|
{}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
/* Properties */
|
||||||
|
/*---------------------------------------------------------------------------------*/
|
||||||
|
System::String^ TextRenderable::Text::get()
|
||||||
|
{
|
||||||
|
return Convert::ToCLI(GetNativeComponent()->GetText());
|
||||||
|
}
|
||||||
|
void TextRenderable::Text::set(System::String^ value)
|
||||||
|
{
|
||||||
|
GetNativeComponent()->SetText(Convert::ToNative(value));
|
||||||
|
}
|
||||||
|
SHADE::Font^ TextRenderable::Font::get()
|
||||||
|
{
|
||||||
|
return gcnew SHADE::Font(GetNativeComponent()->GetFont());
|
||||||
|
}
|
||||||
|
void TextRenderable::Font::set(SHADE::Font^ value)
|
||||||
|
{
|
||||||
|
if (value == nullptr)
|
||||||
|
{
|
||||||
|
GetNativeComponent()->SetFont(Handle<SHFont>());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GetNativeComponent()->SetFont(Handle<SHFont>(Convert::ToNative(value->NativeObjectHandle)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,65 @@
|
||||||
|
/************************************************************************************//*!
|
||||||
|
\file TextRenderable.hxx
|
||||||
|
\author Tng Kah Wei, kahwei.tng, 390009620
|
||||||
|
\par email: kahwei.tng\@digipen.edu
|
||||||
|
\date Nov 21, 2022
|
||||||
|
\brief Contains the definition of the managed TextRenderable class with the
|
||||||
|
declaration of functions for working with it.
|
||||||
|
|
||||||
|
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.
|
||||||
|
*//*************************************************************************************/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
// External Dependencies
|
||||||
|
#include "Graphics/MiddleEnd/TextRendering/SHTextRenderableComponent.h"
|
||||||
|
// Project Includes
|
||||||
|
#include "Components/Component.hxx"
|
||||||
|
#include "Math/Vector3.hxx"
|
||||||
|
#include "Math/Quaternion.hxx"
|
||||||
|
#include "Assets/Font.hxx"
|
||||||
|
|
||||||
|
namespace SHADE
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// CLR version of the SHADE Engine's SHTextRenderableComponent.
|
||||||
|
/// </summary>
|
||||||
|
public ref class TextRenderable : public Component<SHTextRenderableComponent>
|
||||||
|
{
|
||||||
|
internal:
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
/* Constructors */
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
/// <summary>
|
||||||
|
/// Constructs a TextRenderable Component that represents a native TextRenderable
|
||||||
|
/// component tied to the specified Entity.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity">Entity that this Component will be tied to.</param>
|
||||||
|
TextRenderable(Entity entity);
|
||||||
|
|
||||||
|
public:
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
/* Properties */
|
||||||
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
/// <summary>
|
||||||
|
/// Text to render using this TextRenderable.
|
||||||
|
/// </summary>
|
||||||
|
property System::String^ Text
|
||||||
|
{
|
||||||
|
System::String^ get();
|
||||||
|
void set(System::String^ value);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Font to use to render using this TextRenderable.
|
||||||
|
/// </summary>
|
||||||
|
property SHADE::Font^ Font
|
||||||
|
{
|
||||||
|
SHADE::Font^ get();
|
||||||
|
void set(SHADE::Font^ value);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
@ -89,6 +89,8 @@ namespace SHADE
|
||||||
/*---------------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------------*/
|
||||||
std::string Convert::ToNative(System::String^ str)
|
std::string Convert::ToNative(System::String^ str)
|
||||||
{
|
{
|
||||||
|
if (str == nullptr)
|
||||||
|
return "";
|
||||||
return msclr::interop::marshal_as<std::string>(str);
|
return msclr::interop::marshal_as<std::string>(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue