diff --git a/Gems/GameStateSamples/Code/CMakeLists.txt b/Gems/GameStateSamples/Code/CMakeLists.txt index 5d1d180de0..a07bef6a06 100644 --- a/Gems/GameStateSamples/Code/CMakeLists.txt +++ b/Gems/GameStateSamples/Code/CMakeLists.txt @@ -21,7 +21,7 @@ ly_add_target( INTERFACE Gem::GameState Gem::LocalUser - Gem::LyShine.Static + Gem::LyShine.Clients.API Gem::SaveData.Static Gem::MessagePopup.Static Legacy::CryCommon diff --git a/Gems/LyShine/Code/CMakeLists.txt b/Gems/LyShine/Code/CMakeLists.txt index 4f2c4e90a7..2b550b0e36 100644 --- a/Gems/LyShine/Code/CMakeLists.txt +++ b/Gems/LyShine/Code/CMakeLists.txt @@ -58,10 +58,13 @@ ly_add_target( # by default, load the above "Gem::LyShine" module in Client and Server applications: ly_create_alias(NAME LyShine.Clients NAMESPACE Gem TARGETS Gem::LyShine) ly_create_alias(NAME LyShine.Servers NAMESPACE Gem TARGETS Gem::LyShine) +# create an alias for other gems to depend on an LyShine public API (may be converted to a target in the future): +ly_create_alias(NAME LyShine.Clients.API NAMESPACE Gem TARGETS Gem::LyShine.Clients) +ly_create_alias(NAME LyShine.Servers.API NAMESPACE Gem TARGETS Gem::LyShine.Servers) if (PAL_TRAIT_BUILD_HOST_TOOLS) ly_add_target( - NAME LyShine.Editor.Static STATIC + NAME LyShine.Tools.Static STATIC NAMESPACE Gem AUTOMOC AUTOUIC @@ -73,7 +76,6 @@ if (PAL_TRAIT_BUILD_HOST_TOOLS) . Source Editor - PUBLIC Include BUILD_DEPENDENCIES PRIVATE @@ -100,7 +102,7 @@ if (PAL_TRAIT_BUILD_HOST_TOOLS) ) ly_add_target( - NAME LyShine.Editor GEM_MODULE + NAME LyShine.Tools GEM_MODULE NAMESPACE Gem FILES_CMAKE lyshine_common_module_files.cmake @@ -112,18 +114,18 @@ if (PAL_TRAIT_BUILD_HOST_TOOLS) . Source Editor - PUBLIC Include BUILD_DEPENDENCIES PRIVATE Legacy::CryCommon AZ::AzToolsFramework - Gem::LyShine.Editor.Static + Gem::LyShine.Tools.Static Gem::LmbrCentral.Editor Gem::TextureAtlas.Editor RUNTIME_DEPENDENCIES Gem::LmbrCentral.Editor Gem::TextureAtlas.Editor + Gem::UiBasics.Tools ) # by naming this target LyShine.Builders it ensures that it is loaded @@ -179,10 +181,9 @@ if (PAL_TRAIT_BUILD_HOST_TOOLS) Gem::LyShine.Builders.Static Gem::LmbrCentral.Editor Gem::TextureAtlas.Editor + RUNTIME_DEPENDENCIES + Gem::UiBasics.Builders ) - - # by default, load the above "Gem::LyShine.Editor" module in dev tools: - ly_create_alias(NAME LyShine.Tools NAMESPACE Gem TARGETS Gem::LyShine.Editor) endif() ################################################################################ @@ -241,7 +242,7 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED) AZ::AzTest Legacy::CryCommon AZ::AssetBuilderSDK - Gem::LyShine.Editor.Static + Gem::LyShine.Tools.Static Gem::LyShine.Builders.Static Gem::LmbrCentral.Editor Gem::TextureAtlas diff --git a/Gems/LyShine/Code/Editor/GuideHelpers.cpp b/Gems/LyShine/Code/Editor/GuideHelpers.cpp index eb5966568e..b6d7acc57a 100644 --- a/Gems/LyShine/Code/Editor/GuideHelpers.cpp +++ b/Gems/LyShine/Code/Editor/GuideHelpers.cpp @@ -173,7 +173,7 @@ namespace GuideHelpers // the line is drawn as the inverse of the background color AZ::Color guideColor(1.0f, 1.0f, 1.0f, 1.0f); - CDraw2d::RenderState renderState; + IDraw2d::RenderState renderState; renderState.m_blendState.m_blendSource = AZ::RHI::BlendFactor::ColorDestInverse; renderState.m_blendState.m_blendDest = AZ::RHI::BlendFactor::Zero; diff --git a/Gems/LyShine/Code/Editor/ViewportCanvasBackground.cpp b/Gems/LyShine/Code/Editor/ViewportCanvasBackground.cpp index 668c4e8024..b1961de0a1 100644 --- a/Gems/LyShine/Code/Editor/ViewportCanvasBackground.cpp +++ b/Gems/LyShine/Code/Editor/ViewportCanvasBackground.cpp @@ -50,7 +50,7 @@ void ViewportCanvasBackground::Draw(Draw2dHelper& draw2d, const AZ::Vector2& can // now draw the same as Stretched but with UV's adjusted const AZ::Vector2 uvs[4] = { AZ::Vector2(0, 0), AZ::Vector2(uvScale.GetX(), 0), AZ::Vector2(uvScale.GetX(), uvScale.GetY()), AZ::Vector2(0, uvScale.GetY()) }; AZ::Color colorWhite(1.0f, 1.0f, 1.0f, 1.0f); - CDraw2d::VertexPosColUV verts[4]; + IDraw2d::VertexPosColUV verts[4]; for (int i = 0; i < 4; ++i) { verts[i].position = positions[i]; diff --git a/Gems/LyShine/Code/Editor/ViewportDragInteraction.h b/Gems/LyShine/Code/Editor/ViewportDragInteraction.h index 3b26b66308..6b48fc0133 100644 --- a/Gems/LyShine/Code/Editor/ViewportDragInteraction.h +++ b/Gems/LyShine/Code/Editor/ViewportDragInteraction.h @@ -8,7 +8,7 @@ #pragma once #include -#include +#include //! Abstract base class for drag interactions in the UI Editor viewport window. class ViewportDragInteraction diff --git a/Gems/LyShine/Code/Editor/ViewportHelpers.h b/Gems/LyShine/Code/Editor/ViewportHelpers.h index 8068f4af65..f2722fb6b8 100644 --- a/Gems/LyShine/Code/Editor/ViewportHelpers.h +++ b/Gems/LyShine/Code/Editor/ViewportHelpers.h @@ -7,7 +7,7 @@ */ #pragma once -#include +#include namespace ViewportHelpers { diff --git a/Gems/LyShine/Code/Editor/ViewportIcon.cpp b/Gems/LyShine/Code/Editor/ViewportIcon.cpp index 3f0fdfaba0..33f2f40ffe 100644 --- a/Gems/LyShine/Code/Editor/ViewportIcon.cpp +++ b/Gems/LyShine/Code/Editor/ViewportIcon.cpp @@ -6,7 +6,7 @@ * */ #include "EditorCommon.h" -#include +#include #include #include @@ -15,7 +15,7 @@ float ViewportIcon::m_dpiScaleFactor = 1.0f; ViewportIcon::ViewportIcon(const char* textureFilename) { - m_image = CDraw2d::LoadTexture(textureFilename); + m_image = Draw2dHelper::LoadTexture(textureFilename); } ViewportIcon::~ViewportIcon() @@ -48,7 +48,7 @@ void ViewportIcon::DrawImageAligned(Draw2dHelper& draw2d, AZ::Vector2& pivot, fl opacity); } -void ViewportIcon::DrawImageTiled(Draw2dHelper& draw2d, CDraw2d::VertexPosColUV* verts) +void ViewportIcon::DrawImageTiled(Draw2dHelper& draw2d, IDraw2d::VertexPosColUV* verts) { // Use default blending and rounding modes IDraw2d::Rounding rounding = IDraw2d::Rounding::Nearest; @@ -63,7 +63,7 @@ void ViewportIcon::DrawAxisAlignedBoundingBox(Draw2dHelper& draw2d, AZ::Vector2 float endTexCoordU = fabsf((bound1.GetX() - bound0.GetX()) * pixelLengthForDottedLineTexture); float endTexCoordV = fabsf((bound1.GetY() - bound0.GetY()) * pixelLengthForDottedLineTexture); - CDraw2d::VertexPosColUV verts[2]; + IDraw2d::VertexPosColUV verts[2]; { verts[0].color = dottedColor; verts[1].color = dottedColor; @@ -158,7 +158,7 @@ void ViewportIcon::Draw(Draw2dHelper& draw2d, AZ::Vector2 anchorPos, const AZ::M AZ::Matrix4x4 moveFromPivotSpaceMat = AZ::Matrix4x4::CreateTranslation(pivot3); AZ::Matrix4x4 newTransform = transform * moveFromPivotSpaceMat * rotMat * moveToPivotSpaceMat; - CDraw2d::VertexPosColUV verts[4]; + IDraw2d::VertexPosColUV verts[4]; // points are a clockwise quad static const AZ::Vector2 uvs[4] = { AZ::Vector2(0.0f, 0.0f), AZ::Vector2(1.0f, 0.0f), AZ::Vector2(1.0f, 1.0f), AZ::Vector2(0.0f, 1.0f) @@ -251,7 +251,7 @@ void ViewportIcon::DrawDistanceLine(Draw2dHelper& draw2d, AZ::Vector2 start, AZ: const float pixelLengthForDottedLineTexture = 8.0f; float endTexCoordU = length / pixelLengthForDottedLineTexture; - CDraw2d::VertexPosColUV verts[2]; + IDraw2d::VertexPosColUV verts[2]; verts[0].position = start; verts[0].color = dottedColor; diff --git a/Gems/LyShine/Code/Editor/ViewportIcon.h b/Gems/LyShine/Code/Editor/ViewportIcon.h index f815b244e9..fadd829bcf 100644 --- a/Gems/LyShine/Code/Editor/ViewportIcon.h +++ b/Gems/LyShine/Code/Editor/ViewportIcon.h @@ -20,7 +20,7 @@ public: void DrawImageAligned(Draw2dHelper& draw2d, AZ::Vector2& pivot, float opacity); - void DrawImageTiled(Draw2dHelper& draw2d, CDraw2d::VertexPosColUV* verts); + void DrawImageTiled(Draw2dHelper& draw2d, IDraw2d::VertexPosColUV* verts); void Draw(Draw2dHelper& draw2d, AZ::Vector2 anchorPos, const AZ::Matrix4x4& transform, float iconRot = 0.0f, AZ::Color color = AZ::Color(1.0f, 1.0f, 1.0f, 1.0f)) const; diff --git a/Gems/LyShine/Code/Editor/ViewportWidget.cpp b/Gems/LyShine/Code/Editor/ViewportWidget.cpp index 993f57aeeb..b481e9cbf1 100644 --- a/Gems/LyShine/Code/Editor/ViewportWidget.cpp +++ b/Gems/LyShine/Code/Editor/ViewportWidget.cpp @@ -16,7 +16,6 @@ #include #include -#include #include "LyShine.h" #include "UiRenderer.h" @@ -27,6 +26,7 @@ #include "RulerWidget.h" #include "CanvasHelpers.h" #include "AssetDropHelpers.h" +#include "Draw2d.h" #include "QtHelpers.h" #include diff --git a/Gems/LyShine/Code/Include/LyShine/IDraw2d.h b/Gems/LyShine/Code/Include/LyShine/IDraw2d.h index 620b8c23c9..77dc5ac601 100644 --- a/Gems/LyShine/Code/Include/LyShine/IDraw2d.h +++ b/Gems/LyShine/Code/Include/LyShine/IDraw2d.h @@ -482,6 +482,50 @@ public: // static member functions return nullptr; } + //! Helper to load a texture + static AZ::Data::Instance LoadTexture(const AZStd::string& pathName) + { + if (gEnv && gEnv->pLyShine) // [LYSHINE_ATOM_TODO][GHI #3569] Remove LyShine global interface pointer from legacy global environment + { + return gEnv->pLyShine->LoadTexture(pathName); + } + + return nullptr; + } + + //! Given a position and size and an alignment return the top left corner of the aligned quad + static AZ::Vector2 Align(AZ::Vector2 position, AZ::Vector2 size, IDraw2d::HAlign horizontalAlignment, IDraw2d::VAlign verticalAlignment) + { + AZ::Vector2 result = AZ::Vector2::CreateZero(); + switch (horizontalAlignment) + { + case IDraw2d::HAlign::Left: + result.SetX(position.GetX()); + break; + case IDraw2d::HAlign::Center: + result.SetX(position.GetX() - size.GetX() * 0.5f); + break; + case IDraw2d::HAlign::Right: + result.SetX(position.GetX() - size.GetX()); + break; + } + + switch (verticalAlignment) + { + case IDraw2d::VAlign::Top: + result.SetY(position.GetY()); + break; + case IDraw2d::VAlign::Center: + result.SetY(position.GetY() - size.GetY() * 0.5f); + break; + case IDraw2d::VAlign::Bottom: + result.SetY(position.GetY() - size.GetY()); + break; + } + + return result; + } + //! Round the X and Y coordinates of a point using the given rounding policy template static T RoundXY(T value, IDraw2d::Rounding roundingType) diff --git a/Gems/LyShine/Code/Include/LyShine/ILyShine.h b/Gems/LyShine/Code/Include/LyShine/ILyShine.h index 7832497d8c..71ca6ec074 100644 --- a/Gems/LyShine/Code/Include/LyShine/ILyShine.h +++ b/Gems/LyShine/Code/Include/LyShine/ILyShine.h @@ -9,12 +9,18 @@ #include #include +#include class IDraw2d; class ISprite; struct IUiAnimationSystem; class UiEntityContext; +namespace AZ::RPI +{ + class Image; +} + // The following ifdef block is the standard way of creating macros which make exporting // from a DLL simpler. All files within this DLL are compiled with the LYSHINE_EXPORTS // symbol defined in the StdAfx.h. this symbol should not be defined on any project @@ -82,6 +88,9 @@ public: //! Check if a sprite's texture asset exists. The .sprite sidecar file is optional and is not checked virtual bool DoesSpriteTextureAssetExist(const AZStd::string& pathname) = 0; + //! Load an image asset by texture pathname + virtual AZ::Data::Instance LoadTexture(const AZStd::string& pathName) = 0; + //! Perform post-initialization (script system will be available) virtual void PostInit() = 0; diff --git a/Gems/LyShine/Code/Source/Draw2d.cpp b/Gems/LyShine/Code/Source/Draw2d.cpp index 2838ed4877..ff8c7f1c6d 100644 --- a/Gems/LyShine/Code/Source/Draw2d.cpp +++ b/Gems/LyShine/Code/Source/Draw2d.cpp @@ -6,7 +6,7 @@ * */ -#include +#include "Draw2d.h" #include #include "LyShinePassDataBus.h" @@ -215,7 +215,7 @@ void CDraw2d::DrawImageAligned(AZ::Data::Instance image, AZ::Vec HAlign horizontalAlignment, VAlign verticalAlignment, float opacity, float rotation, const AZ::Vector2* minMaxTexCoords, ImageOptions* imageOptions) { - AZ::Vector2 alignedPosition = Align(position, size, horizontalAlignment, verticalAlignment); + AZ::Vector2 alignedPosition = Draw2dHelper::Align(position, size, horizontalAlignment, verticalAlignment); DrawImage(image, alignedPosition, size, opacity, rotation, &position, minMaxTexCoords, imageOptions); } @@ -524,40 +524,6 @@ void CDraw2d::SetSortKey(int64_t key) // PUBLIC STATIC FUNCTIONS //////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////// -AZ::Vector2 CDraw2d::Align(AZ::Vector2 position, AZ::Vector2 size, - HAlign horizontalAlignment, VAlign verticalAlignment) -{ - AZ::Vector2 result = AZ::Vector2::CreateZero(); - switch (horizontalAlignment) - { - case HAlign::Left: - result.SetX(position.GetX()); - break; - case HAlign::Center: - result.SetX(position.GetX() - size.GetX() * 0.5f); - break; - case HAlign::Right: - result.SetX(position.GetX() - size.GetX()); - break; - } - - switch (verticalAlignment) - { - case VAlign::Top: - result.SetY(position.GetY()); - break; - case VAlign::Center: - result.SetY(position.GetY() - size.GetY() * 0.5f); - break; - case VAlign::Bottom: - result.SetY(position.GetY() - size.GetY()); - break; - } - - return result; -} - //////////////////////////////////////////////////////////////////////////////////////////////////// AZ::Data::Instance CDraw2d::LoadTexture(const AZStd::string& pathName) { diff --git a/Gems/LyShine/Code/Include/LyShine/Draw2d.h b/Gems/LyShine/Code/Source/Draw2d.h similarity index 98% rename from Gems/LyShine/Code/Include/LyShine/Draw2d.h rename to Gems/LyShine/Code/Source/Draw2d.h index d138f41b03..6d400c6b55 100644 --- a/Gems/LyShine/Code/Include/LyShine/Draw2d.h +++ b/Gems/LyShine/Code/Source/Draw2d.h @@ -180,9 +180,6 @@ private: public: // static member functions - //! Given a position and size and an alignment return the top left corner of the aligned quad - static AZ::Vector2 Align(AZ::Vector2 position, AZ::Vector2 size, HAlign horizontalAlignment, VAlign verticalAlignment); - //! Helper to load a texture static AZ::Data::Instance LoadTexture(const AZStd::string& pathName); diff --git a/Gems/LyShine/Code/Source/LyShine.cpp b/Gems/LyShine/Code/Source/LyShine.cpp index 683d72f4ab..5a704329ef 100644 --- a/Gems/LyShine/Code/Source/LyShine.cpp +++ b/Gems/LyShine/Code/Source/LyShine.cpp @@ -43,11 +43,11 @@ #include "Sprite.h" #include "UiSerialize.h" #include "UiRenderer.h" +#include "Draw2d.h" #include #include #include -#include #if defined(LYSHINE_INTERNAL_UNIT_TEST) #include "TextMarkup.h" @@ -355,6 +355,12 @@ bool CLyShine::DoesSpriteTextureAssetExist(const AZStd::string& pathname) return CSprite::DoesSpriteTextureAssetExist(pathname); } +//////////////////////////////////////////////////////////////////////////////////////////////////// +AZ::Data::Instance CLyShine::LoadTexture(const AZStd::string& pathname) +{ + return CDraw2d::LoadTexture(pathname); +} + //////////////////////////////////////////////////////////////////////////////////////////////////// void CLyShine::PostInit() { @@ -691,7 +697,7 @@ void CLyShine::RenderUiCursor() AZ::RHI::Size cursorSize = m_uiCursorTexture->GetDescriptor().m_size; const AZ::Vector2 dimensions(aznumeric_cast(cursorSize.m_width), aznumeric_cast(cursorSize.m_height)); - CDraw2d::ImageOptions imageOptions; + IDraw2d::ImageOptions imageOptions; imageOptions.m_clamp = true; const float opacity = 1.0f; const float rotation = 0.0f; diff --git a/Gems/LyShine/Code/Source/LyShine.h b/Gems/LyShine/Code/Source/LyShine.h index 82f902a9f8..eab52258c1 100644 --- a/Gems/LyShine/Code/Source/LyShine.h +++ b/Gems/LyShine/Code/Source/LyShine.h @@ -72,6 +72,7 @@ public: ISprite* LoadSprite(const AZStd::string& pathname) override; ISprite* CreateSprite(const AZStd::string& renderTargetName) override; bool DoesSpriteTextureAssetExist(const AZStd::string& pathname) override; + AZ::Data::Instance LoadTexture(const AZStd::string& pathname) override; void PostInit() override; diff --git a/Gems/LyShine/Code/Source/LyShineDebug.cpp b/Gems/LyShine/Code/Source/LyShineDebug.cpp index bb57e70857..7e99652f45 100644 --- a/Gems/LyShine/Code/Source/LyShineDebug.cpp +++ b/Gems/LyShine/Code/Source/LyShineDebug.cpp @@ -7,7 +7,7 @@ */ #include "LyShineDebug.h" #include "IConsole.h" -#include +#include #include @@ -377,7 +377,7 @@ static void DebugDrawColoredBox(AZ::Vector2 pos, AZ::Vector2 size, AZ::Color col { IDraw2d* draw2d = Draw2dHelper::GetDefaultDraw2d(); - CDraw2d::ImageOptions imageOptions = draw2d->GetDefaultImageOptions(); + IDraw2d::ImageOptions imageOptions = draw2d->GetDefaultImageOptions(); imageOptions.color = color.GetAsVector3(); auto whiteTexture = AZ::RPI::ImageSystemInterface::Get()->GetSystemImage(AZ::RPI::SystemImage::White); draw2d->DrawImageAligned(whiteTexture, pos, size, horizontalAlignment, verticalAlignment, @@ -392,7 +392,7 @@ static void DebugDrawStringWithSizeBox(AZStd::string_view font, unsigned int eff { IDraw2d* draw2d = Draw2dHelper::GetDefaultDraw2d(); - CDraw2d::TextOptions textOptions = draw2d->GetDefaultTextOptions(); + IDraw2d::TextOptions textOptions = draw2d->GetDefaultTextOptions(); if (!font.empty()) { textOptions.fontName = font; @@ -618,7 +618,7 @@ static AZ::Vector2 DebugDrawFontColorTestBox(AZ::Vector2 pos, const char* string float pointSize = 32.0f; const float spacing = 6.0f; - CDraw2d::TextOptions textOptions = draw2d->GetDefaultTextOptions(); + IDraw2d::TextOptions textOptions = draw2d->GetDefaultTextOptions(); textOptions.effectIndex = 1; // no drop shadow baked in textOptions.color = color; @@ -742,7 +742,7 @@ static void DebugDraw2dImageColor() AZ::Data::Instance texture = GetMonoAlphaTestTexture(); - CDraw2d::ImageOptions imageOptions = draw2d->GetDefaultImageOptions(); + IDraw2d::ImageOptions imageOptions = draw2d->GetDefaultImageOptions(); draw2d->DrawText( "Testing image colors, image is black and white, top row is opacity=1, bottom row is opacity = 0.5", @@ -780,7 +780,7 @@ static void DebugDraw2dImageBlendMode() AZ::Data::Instance texture = GetColorAlphaTestTexture(); - CDraw2d::ImageOptions imageOptions = draw2d->GetDefaultImageOptions(); + IDraw2d::ImageOptions imageOptions = draw2d->GetDefaultImageOptions(); draw2d->DrawText("Testing blend modes, src blend changes across x-axis, dst blend changes across y axis", AZ::Vector2(20, 20), 16); @@ -801,7 +801,7 @@ static void DebugDraw2dImageBlendMode() AZ::Vector2 pos(xStart + xSpacing * srcIndex, yStart + ySpacing * dstIndex); // first draw a background with varying color and alpha - CDraw2d::VertexPosColUV verts[4] = + IDraw2d::VertexPosColUV verts[4] = { { // top left AZ::Vector2(pos.GetX(), pos.GetY()), @@ -828,7 +828,7 @@ static void DebugDraw2dImageBlendMode() // Draw the image with this color - CDraw2d::RenderState renderState; + IDraw2d::RenderState renderState; renderState.m_blendState.m_blendSource = g_srcBlendModes[srcIndex]; renderState.m_blendState.m_blendDest = g_dstBlendModes[dstIndex]; draw2d->DrawImage(texture, pos, size, 1.0f, 0.0f, 0, 0, &imageOptions); @@ -845,7 +845,7 @@ static void DebugDraw2dImageUVs() AZ::Data::Instance texture = GetColorTestTexture(); - CDraw2d::ImageOptions imageOptions = draw2d->GetDefaultImageOptions(); + IDraw2d::ImageOptions imageOptions = draw2d->GetDefaultImageOptions(); draw2d->DrawText( "Testing DrawImage with minMaxTexCoords. Full image, top left quadrant, middle section, full flipped", @@ -894,7 +894,7 @@ static void DebugDraw2dImagePixelRounding() AZ::Data::Instance texture = GetColorTestTexture(); - CDraw2d::ImageOptions imageOptions = draw2d->GetDefaultImageOptions(); + IDraw2d::ImageOptions imageOptions = draw2d->GetDefaultImageOptions(); draw2d->DrawText("Testing DrawImage pixel rounding options", AZ::Vector2(20, 20), 16); @@ -933,7 +933,7 @@ static void DebugDraw2dLineBasic() { IDraw2d* draw2d = Draw2dHelper::GetDefaultDraw2d(); - CDraw2d::ImageOptions imageOptions = draw2d->GetDefaultImageOptions(); + IDraw2d::ImageOptions imageOptions = draw2d->GetDefaultImageOptions(); draw2d->DrawText("Testing DrawLine", AZ::Vector2(20, 20), 16); diff --git a/Gems/LyShine/Code/Source/UiCanvasComponent.cpp b/Gems/LyShine/Code/Source/UiCanvasComponent.cpp index 0a21f92119..ea6e3681a3 100644 --- a/Gems/LyShine/Code/Source/UiCanvasComponent.cpp +++ b/Gems/LyShine/Code/Source/UiCanvasComponent.cpp @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include diff --git a/Gems/LyShine/Code/Source/UiCanvasManager.cpp b/Gems/LyShine/Code/Source/UiCanvasManager.cpp index 70646246f0..fc373f17f6 100644 --- a/Gems/LyShine/Code/Source/UiCanvasManager.cpp +++ b/Gems/LyShine/Code/Source/UiCanvasManager.cpp @@ -6,7 +6,7 @@ * */ #include "UiCanvasManager.h" -#include +#include #include "UiCanvasFileObject.h" #include "UiCanvasComponent.h" @@ -1020,7 +1020,7 @@ void UiCanvasManager::DebugDisplayCanvasData(int setting) const // local function to write a line of text (with a background rect) and increment Y offset AZStd::function WriteLine = [&](const char* buffer, const AZ::Vector3& color) { - CDraw2d::TextOptions textOptions = draw2d->GetDefaultTextOptions(); + IDraw2d::TextOptions textOptions = draw2d->GetDefaultTextOptions(); textOptions.color = color; AZ::Vector2 textSize = draw2d->GetTextSize(buffer, fontSize, &textOptions); AZ::Vector2 rectTopLeft = AZ::Vector2(xOffset - 2, yOffset); @@ -1174,7 +1174,7 @@ void UiCanvasManager::DebugDisplayDrawCallData() const // local function to write a line of text (with a background rect) and increment Y offset AZStd::function WriteLine = [&](const char* buffer, const AZ::Vector3& color) { - CDraw2d::TextOptions textOptions = draw2d->GetDefaultTextOptions(); + IDraw2d::TextOptions textOptions = draw2d->GetDefaultTextOptions(); textOptions.color = color; AZ::Vector2 textSize = draw2d->GetTextSize(buffer, fontSize, &textOptions); AZ::Vector2 rectTopLeft = AZ::Vector2(xOffset - 2, yOffset); diff --git a/Gems/LyShine/Code/Source/UiFaderComponent.cpp b/Gems/LyShine/Code/Source/UiFaderComponent.cpp index e1f5153e99..e84e5162b5 100644 --- a/Gems/LyShine/Code/Source/UiFaderComponent.cpp +++ b/Gems/LyShine/Code/Source/UiFaderComponent.cpp @@ -7,7 +7,7 @@ */ #include "UiFaderComponent.h" #include "RenderGraph.h" -#include +#include #include #include diff --git a/Gems/LyShine/Code/Source/UiImageComponent.cpp b/Gems/LyShine/Code/Source/UiImageComponent.cpp index baf210a629..a8b4210d6b 100644 --- a/Gems/LyShine/Code/Source/UiImageComponent.cpp +++ b/Gems/LyShine/Code/Source/UiImageComponent.cpp @@ -13,7 +13,7 @@ #include #include -#include +#include #include #include #include diff --git a/Gems/LyShine/Code/Source/UiImageSequenceComponent.cpp b/Gems/LyShine/Code/Source/UiImageSequenceComponent.cpp index 4e7d22d96a..3559dc6306 100644 --- a/Gems/LyShine/Code/Source/UiImageSequenceComponent.cpp +++ b/Gems/LyShine/Code/Source/UiImageSequenceComponent.cpp @@ -9,7 +9,7 @@ #include "Sprite.h" #include "RenderGraph.h" -#include +#include #include #include #include diff --git a/Gems/LyShine/Code/Source/UiMaskComponent.cpp b/Gems/LyShine/Code/Source/UiMaskComponent.cpp index 09975d1351..67ba8ee0fb 100644 --- a/Gems/LyShine/Code/Source/UiMaskComponent.cpp +++ b/Gems/LyShine/Code/Source/UiMaskComponent.cpp @@ -6,7 +6,7 @@ * */ #include "UiMaskComponent.h" -#include +#include #include #include diff --git a/Gems/LyShine/Code/Source/UiRenderer.cpp b/Gems/LyShine/Code/Source/UiRenderer.cpp index 3b835dec92..a9c56ece90 100644 --- a/Gems/LyShine/Code/Source/UiRenderer.cpp +++ b/Gems/LyShine/Code/Source/UiRenderer.cpp @@ -20,7 +20,7 @@ #include #include -#include +#include //////////////////////////////////////////////////////////////////////////////////////////////////// // PUBLIC MEMBER FUNCTIONS @@ -449,7 +449,7 @@ void UiRenderer::DebugDisplayTextureData(int recordingOption) // local function to write a line of text (with a background rect) and increment Y offset AZStd::function WriteLine = [&](const char* buffer, const AZ::Vector3& color) { - CDraw2d::TextOptions textOptions = draw2d->GetDefaultTextOptions(); + IDraw2d::TextOptions textOptions = draw2d->GetDefaultTextOptions(); textOptions.color = color; AZ::Vector2 textSize = draw2d->GetTextSize(buffer, fontSize, &textOptions); AZ::Vector2 rectTopLeft = AZ::Vector2(xOffset - 2, yOffset); diff --git a/Gems/LyShine/Code/Source/UiTextComponent.cpp b/Gems/LyShine/Code/Source/UiTextComponent.cpp index 01cfd49e99..aa0235470a 100644 --- a/Gems/LyShine/Code/Source/UiTextComponent.cpp +++ b/Gems/LyShine/Code/Source/UiTextComponent.cpp @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include @@ -1105,7 +1105,7 @@ UiTextComponent::InlineImage::InlineImage(const AZStd::string& texturePathname, else { // Load the texture - m_texture = CDraw2d::LoadTexture(m_filepath); + m_texture = Draw2dHelper::LoadTexture(m_filepath); if (m_texture) { AZ::RHI::Size size = m_texture->GetDescriptor().m_size; @@ -1157,7 +1157,7 @@ bool UiTextComponent::InlineImage::OnAtlasUnloaded(const TextureAtlasNamespace:: else { // Load the texture - m_texture = CDraw2d::LoadTexture(m_filepath); + m_texture = Draw2dHelper::LoadTexture(m_filepath); } return true; } @@ -2675,7 +2675,7 @@ void UiTextComponent::GetClickableTextRects(UiClickableTextInterface::ClickableT } else { - alignedPosition = CDraw2d::Align(pos, drawBatchLine.lineSize, m_textHAlignment, IDraw2d::VAlign::Top); // y is already aligned + alignedPosition = Draw2dHelper::Align(pos, drawBatchLine.lineSize, m_textHAlignment, IDraw2d::VAlign::Top); // y is already aligned } alignedPosition.SetY(alignedPosition.GetY() + newlinePosYIncrement); @@ -4043,7 +4043,7 @@ void UiTextComponent::RenderDrawBatchLines( } else { - alignedPosition = CDraw2d::Align(pos, drawBatchLine.lineSize, m_textHAlignment, IDraw2d::VAlign::Top); // y is already aligned + alignedPosition = Draw2dHelper::Align(pos, drawBatchLine.lineSize, m_textHAlignment, IDraw2d::VAlign::Top); // y is already aligned } alignedPosition.SetY(alignedPosition.GetY() + newlinePosYIncrement); diff --git a/Gems/LyShine/Code/lyshine_static_files.cmake b/Gems/LyShine/Code/lyshine_static_files.cmake index 1adbe1b796..925658e756 100644 --- a/Gems/LyShine/Code/lyshine_static_files.cmake +++ b/Gems/LyShine/Code/lyshine_static_files.cmake @@ -7,8 +7,6 @@ # set(FILES - Source/Draw2d.cpp - Include/LyShine/Draw2d.h Include/LyShine/IDraw2d.h Include/LyShine/IRenderGraph.h Include/LyShine/ISprite.h @@ -88,6 +86,8 @@ set(FILES Include/LyShine/Bus/World/UiCanvasOnMeshBus.h Include/LyShine/Bus/World/UiCanvasRefBus.h Include/LyShine/Bus/Tools/UiSystemToolsBus.h + Source/Draw2d.cpp + Source/Draw2d.h Source/LyShine.cpp Source/LyShine.h Source/LyShinePassDataBus.h diff --git a/Gems/LyShine/gem.json b/Gems/LyShine/gem.json index f3c3fc2c67..8dcac6404a 100644 --- a/Gems/LyShine/gem.json +++ b/Gems/LyShine/gem.json @@ -24,6 +24,7 @@ "Atom_Bootstrap", "AtomFont", "TextureAtlas", - "AtomToolsFramework" + "AtomToolsFramework", + "UiBasics" ] } diff --git a/Gems/LyShineExamples/Code/CMakeLists.txt b/Gems/LyShineExamples/Code/CMakeLists.txt index 6e8f53d5cd..40032d6342 100644 --- a/Gems/LyShineExamples/Code/CMakeLists.txt +++ b/Gems/LyShineExamples/Code/CMakeLists.txt @@ -21,7 +21,7 @@ ly_add_target( Gem::LmbrCentral PUBLIC Legacy::CryCommon - Gem::LyShine.Static + Gem::LyShine.Clients.API ) ly_add_target( @@ -42,7 +42,7 @@ ly_add_target( # if enabled, LyShineExamples is used by all kinds of applications, however, the dependency to LmbrCentral is different # per application type -ly_create_alias(NAME LyShineExamples.Builders NAMESPACE Gem TARGETS Gem::LyShineExamples Gem::LmbrCentral.Editor) +ly_create_alias(NAME LyShineExamples.Builders NAMESPACE Gem TARGETS Gem::LyShineExamples Gem::UiBasics.Builders Gem::LmbrCentral.Editor) ly_create_alias(NAME LyShineExamples.Tools NAMESPACE Gem TARGETS Gem::LyShineExamples Gem::LmbrCentral.Editor) ly_create_alias(NAME LyShineExamples.Clients NAMESPACE Gem TARGETS Gem::LyShineExamples Gem::LmbrCentral) ly_create_alias(NAME LyShineExamples.Servers NAMESPACE Gem TARGETS Gem::LyShineExamples Gem::LmbrCentral) diff --git a/Gems/LyShineExamples/Code/Source/UiCustomImageComponent.cpp b/Gems/LyShineExamples/Code/Source/UiCustomImageComponent.cpp index 542e18b98c..e8b0e4370a 100644 --- a/Gems/LyShineExamples/Code/Source/UiCustomImageComponent.cpp +++ b/Gems/LyShineExamples/Code/Source/UiCustomImageComponent.cpp @@ -14,7 +14,7 @@ #include #include -#include +#include #include #include #include diff --git a/Gems/MessagePopup/Code/CMakeLists.txt b/Gems/MessagePopup/Code/CMakeLists.txt index 51ec1a3bd1..2ed9c71632 100644 --- a/Gems/MessagePopup/Code/CMakeLists.txt +++ b/Gems/MessagePopup/Code/CMakeLists.txt @@ -19,7 +19,7 @@ ly_add_target( BUILD_DEPENDENCIES PUBLIC Legacy::CryCommon - Gem::LyShine + Gem::LyShine.Clients.API ) ly_add_target( @@ -39,4 +39,4 @@ ly_add_target( # MessagePopup is used only in client applications ly_create_alias(NAME MessagePopup.Clients NAMESPACE Gem TARGETS Gem::MessagePopup) - +ly_create_alias(NAME MessagePopup.Builders NAMESPACE Gem TARGETS Gem::UiBasics.Builders) diff --git a/Gems/UiBasics/CMakeLists.txt b/Gems/UiBasics/CMakeLists.txt index 8d71bd08c7..9c3cf01d26 100644 --- a/Gems/UiBasics/CMakeLists.txt +++ b/Gems/UiBasics/CMakeLists.txt @@ -9,4 +9,5 @@ # This will export its "SourcePaths" to the generated "cmake_dependencies..assetbuilder.setreg" if(PAL_TRAIT_BUILD_HOST_TOOLS) ly_create_alias(NAME UiBasics.Builders NAMESPACE Gem) + ly_create_alias(NAME UiBasics.Tools NAMESPACE Gem) endif() diff --git a/Gems/VirtualGamepad/Code/CMakeLists.txt b/Gems/VirtualGamepad/Code/CMakeLists.txt index d32834633f..6700004a30 100644 --- a/Gems/VirtualGamepad/Code/CMakeLists.txt +++ b/Gems/VirtualGamepad/Code/CMakeLists.txt @@ -21,7 +21,7 @@ ly_add_target( AZ::AzCore AZ::AzFramework Legacy::CryCommon - Gem::LyShine + Gem::LyShine.Clients.API ) ly_add_target( @@ -42,4 +42,4 @@ ly_add_target( # the virtual gamepad is needed everywhere except servers: ly_create_alias(NAME VirtualGamepad.Clients NAMESPACE Gem TARGETS Gem::VirtualGamepad) ly_create_alias(NAME VirtualGamepad.Tools NAMESPACE Gem TARGETS Gem::VirtualGamepad) -ly_create_alias(NAME VirtualGamepad.Builders NAMESPACE Gem TARGETS Gem::VirtualGamepad) +ly_create_alias(NAME VirtualGamepad.Builders NAMESPACE Gem TARGETS Gem::VirtualGamepad Gem::UiBasics.Builders)