Make ILyShine an AZ::Interface (#6923)
* Move ILyShine instance out of legacy code Signed-off-by: abrmich <abrmich@amazon.com> * Remove last remaining reference of gEnv->pLyShine Signed-off-by: abrmich <abrmich@amazon.com> * Make m_lyShine a unique pointer Signed-off-by: abrmich <abrmich@amazon.com>
This commit is contained in:
@@ -614,7 +614,6 @@ struct SSystemGlobalEnvironment
|
||||
ISystem* pSystem = nullptr;
|
||||
ILog* pLog;
|
||||
IMovieSystem* pMovieSystem;
|
||||
ILyShine* pLyShine;
|
||||
SharedEnvironmentInstance* pSharedEnvironment;
|
||||
|
||||
#if defined(AZ_RESTRICTED_PLATFORM)
|
||||
|
||||
@@ -64,7 +64,7 @@ void CommandCanvasPropertiesChange::Recreate(bool isUndo)
|
||||
// Create a new canvas from the XML and release the old canvas, use the new entity context for
|
||||
// the new canvas
|
||||
const AZStd::string& xml = isUndo ? m_undoXml : m_redoXml;
|
||||
gEnv->pLyShine->ReloadCanvasFromXml(xml, newEntityContext);
|
||||
AZ::Interface<ILyShine>::Get()->ReloadCanvasFromXml(xml, newEntityContext);
|
||||
|
||||
// Tell the editor window to use the new entity context
|
||||
m_editorWindow->ReplaceEntityContext(newEntityContext);
|
||||
|
||||
@@ -315,7 +315,7 @@ EditorWindow::~EditorWindow()
|
||||
// unload the preview mode canvas if it exists (e.g. if we close the editor window while in preview mode)
|
||||
if (m_previewModeCanvasEntityId.IsValid())
|
||||
{
|
||||
gEnv->pLyShine->ReleaseCanvas(m_previewModeCanvasEntityId, false);
|
||||
AZ::Interface<ILyShine>::Get()->ReleaseCanvas(m_previewModeCanvasEntityId, false);
|
||||
}
|
||||
|
||||
delete m_sliceLibraryTree;
|
||||
@@ -564,7 +564,7 @@ bool EditorWindow::OnPreWarning(const char* /*window*/, const char* /*fileName*/
|
||||
|
||||
void EditorWindow::DestroyCanvas(const UiCanvasMetadata& canvasMetadata)
|
||||
{
|
||||
gEnv->pLyShine->ReleaseCanvas(canvasMetadata.m_canvasEntityId, true);
|
||||
AZ::Interface<ILyShine>::Get()->ReleaseCanvas(canvasMetadata.m_canvasEntityId, true);
|
||||
}
|
||||
|
||||
bool EditorWindow::IsCanvasTabMetadataValidForTabIndex(int index)
|
||||
@@ -950,14 +950,14 @@ bool EditorWindow::LoadCanvas(const QString& canvasFilename, bool autoLoad, bool
|
||||
bool errorsOnLoad = false;
|
||||
if (canvasFilename.isEmpty())
|
||||
{
|
||||
canvasEntityId = gEnv->pLyShine->CreateCanvasInEditor(entityContext);
|
||||
canvasEntityId = AZ::Interface<ILyShine>::Get()->CreateCanvasInEditor(entityContext);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Collect errors and warnings during the canvas load
|
||||
AZ::Debug::TraceMessageBus::Handler::BusConnect();
|
||||
|
||||
canvasEntityId = gEnv->pLyShine->LoadCanvasInEditor(assetIdPathname.c_str(), sourceAssetPathName.c_str(), entityContext);
|
||||
canvasEntityId = AZ::Interface<ILyShine>::Get()->LoadCanvasInEditor(assetIdPathname.c_str(), sourceAssetPathName.c_str(), entityContext);
|
||||
|
||||
// Stop receiving error and warning events
|
||||
AZ::Debug::TraceMessageBus::Handler::BusDisconnect();
|
||||
@@ -1603,7 +1603,7 @@ void EditorWindow::ToggleEditorMode()
|
||||
EBUS_EVENT_RESULT(entity, AZ::ComponentApplicationBus, FindEntity, m_previewModeCanvasEntityId);
|
||||
if (entity)
|
||||
{
|
||||
gEnv->pLyShine->ReleaseCanvas(m_previewModeCanvasEntityId, false);
|
||||
AZ::Interface<ILyShine>::Get()->ReleaseCanvas(m_previewModeCanvasEntityId, false);
|
||||
}
|
||||
m_previewModeCanvasEntityId.SetInvalid();
|
||||
}
|
||||
|
||||
@@ -211,9 +211,9 @@ namespace LyShineEditor
|
||||
void LyShineEditorSystemComponent::OnStopPlayInEditor()
|
||||
{
|
||||
// reset UI system
|
||||
if (gEnv->pLyShine)
|
||||
if (AZ::Interface<ILyShine>::Get())
|
||||
{
|
||||
gEnv->pLyShine->Reset();
|
||||
AZ::Interface<ILyShine>::Get()->Reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
#include "SpriteBorderEditorCommon.h"
|
||||
|
||||
#include <AzCore/Interface/Interface.h>
|
||||
#include <QMessageBox>
|
||||
#include <QApplication>
|
||||
#include <Util/PathUtil.h>
|
||||
@@ -35,7 +36,7 @@ SpriteBorderEditor::SpriteBorderEditor(const char* path, QWidget* parent)
|
||||
setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::MSWindowsFixedSizeDialogHint);
|
||||
|
||||
// Make sure the sprite can load and be displayed before continuing
|
||||
m_sprite = gEnv->pLyShine->LoadSprite(m_spritePath.toLatin1().constData());
|
||||
m_sprite = AZ::Interface<ILyShine>::Get()->LoadSprite(m_spritePath.toLatin1().constData());
|
||||
QString fullPath = Path::GamePathToFullPath(m_sprite->GetTexturePathname().c_str());
|
||||
const bool imageWontLoad = !m_sprite || QPixmap(fullPath).isNull();
|
||||
if (imageWontLoad)
|
||||
|
||||
@@ -181,7 +181,7 @@ namespace
|
||||
EBUS_EVENT_ID_RESULT(handled, canvasEntityId, UiCanvasBus, HandleInputEvent, inputSnapshot, viewportPos, activeModifierKeys);
|
||||
|
||||
// Execute events that have been queued during the input event handler
|
||||
gEnv->pLyShine->ExecuteQueuedEvents();
|
||||
AZ::Interface<ILyShine>::Get()->ExecuteQueuedEvents();
|
||||
|
||||
return handled;
|
||||
}
|
||||
@@ -192,7 +192,7 @@ namespace
|
||||
EBUS_EVENT_ID_RESULT(handled, canvasEntityId, UiCanvasBus, HandleTextEvent, textUTF8);
|
||||
|
||||
// Execute events that have been queued during the input event handler
|
||||
gEnv->pLyShine->ExecuteQueuedEvents();
|
||||
AZ::Interface<ILyShine>::Get()->ExecuteQueuedEvents();
|
||||
|
||||
return handled;
|
||||
}
|
||||
@@ -265,7 +265,7 @@ ViewportWidget::~ViewportWidget()
|
||||
|
||||
// Notify LyShine that this is no longer a valid UiRenderer.
|
||||
// Only one viewport/renderer is currently supported in the UI Editor
|
||||
CLyShine* lyShine = static_cast<CLyShine*>(gEnv->pLyShine);
|
||||
CLyShine* lyShine = static_cast<CLyShine*>(AZ::Interface<ILyShine>::Get());
|
||||
lyShine->SetUiRendererForEditor(nullptr);
|
||||
}
|
||||
|
||||
@@ -276,7 +276,7 @@ void ViewportWidget::InitUiRenderer()
|
||||
// Notify LyShine that this is the UiRenderer to be used for rendering
|
||||
// UI canvases that are loaded in the UI Editor.
|
||||
// Only one viewport/renderer is currently supported in the UI Editor
|
||||
CLyShine* lyShine = static_cast<CLyShine*>(gEnv->pLyShine);
|
||||
CLyShine* lyShine = static_cast<CLyShine*>(AZ::Interface<ILyShine>::Get());
|
||||
lyShine->SetUiRendererForEditor(m_uiRenderer);
|
||||
|
||||
m_draw2d = AZStd::make_shared<CDraw2d>(GetViewportContext());
|
||||
@@ -1123,7 +1123,7 @@ void ViewportWidget::UpdatePreviewMode(float deltaTime)
|
||||
EBUS_EVENT_ID(canvasEntityId, UiEditorCanvasBus, UpdateCanvasInEditorViewport, deltaTime, true);
|
||||
|
||||
// Execute events that have been queued during the canvas update
|
||||
gEnv->pLyShine->ExecuteQueuedEvents();
|
||||
AZ::Interface<ILyShine>::Get()->ExecuteQueuedEvents();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -473,9 +473,9 @@ public: // static member functions
|
||||
//! Helper to get the default IDraw2d interface
|
||||
static IDraw2d* GetDefaultDraw2d()
|
||||
{
|
||||
if (gEnv && gEnv->pLyShine) // [LYSHINE_ATOM_TODO][GHI #3569] Remove LyShine global interface pointer from legacy global environment
|
||||
if (AZ::Interface<ILyShine>::Get())
|
||||
{
|
||||
IDraw2d* draw2d = gEnv->pLyShine->GetDraw2d();
|
||||
IDraw2d* draw2d = AZ::Interface<ILyShine>::Get()->GetDraw2d();
|
||||
return reinterpret_cast<IDraw2d*>(draw2d);
|
||||
}
|
||||
|
||||
@@ -485,9 +485,9 @@ public: // static member functions
|
||||
//! Helper to load a texture
|
||||
static AZ::Data::Instance<AZ::RPI::Image> LoadTexture(const AZStd::string& pathName)
|
||||
{
|
||||
if (gEnv && gEnv->pLyShine) // [LYSHINE_ATOM_TODO][GHI #3569] Remove LyShine global interface pointer from legacy global environment
|
||||
if (AZ::Interface<ILyShine>::Get())
|
||||
{
|
||||
return gEnv->pLyShine->LoadTexture(pathName);
|
||||
return AZ::Interface<ILyShine>::Get()->LoadTexture(pathName);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
|
||||
@@ -38,7 +38,10 @@ namespace AZ::RPI
|
||||
class ILyShine
|
||||
{
|
||||
public:
|
||||
virtual ~ILyShine(){}
|
||||
AZ_RTTI(ILyShine, "{652ED9D7-0782-44E8-BCE7-65DD38C90907}");
|
||||
|
||||
ILyShine() = default;
|
||||
virtual ~ILyShine() = default;
|
||||
|
||||
//! Delete this object
|
||||
virtual void Release() = 0;
|
||||
|
||||
@@ -124,7 +124,7 @@ AllocateConstIntCVar(CLyShine, CV_ui_RunUnitTestsOnStartup);
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
CLyShine::CLyShine([[maybe_unused]] ISystem* system)
|
||||
CLyShine::CLyShine()
|
||||
: AzFramework::InputChannelEventListener(AzFramework::InputChannelEventListener::GetPriorityUI())
|
||||
, AzFramework::InputTextEventListener(AzFramework::InputTextEventListener::GetPriorityUI())
|
||||
, m_draw2d(new CDraw2d)
|
||||
@@ -386,8 +386,8 @@ void CLyShine::Update(float deltaTimeInSeconds)
|
||||
}
|
||||
|
||||
// Tell the UI system the size of the viewport we are rendering to - this drives the
|
||||
// canvas size for full screen UI canvases. It needs to be set before either pLyShine->Update or
|
||||
// pLyShine->Render are called. It must match the viewport size that the input system is using.
|
||||
// canvas size for full screen UI canvases. It needs to be set before either lyShine->Update or
|
||||
// lyShine->Render are called. It must match the viewport size that the input system is using.
|
||||
SetViewportSize(m_uiRenderer->GetViewportSize());
|
||||
|
||||
// Guard against nested updates. This can occur if a canvas update below triggers the load screen component's
|
||||
@@ -708,10 +708,10 @@ void CLyShine::RenderUiCursor()
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void CLyShine::DebugReportDrawCalls(IConsoleCmdArgs* cmdArgs)
|
||||
{
|
||||
if (gEnv->pLyShine)
|
||||
if (AZ::Interface<ILyShine>::Get())
|
||||
{
|
||||
// We want to use an internal-only non-static function so downcast to CLyShine
|
||||
CLyShine* pLyShine = static_cast<CLyShine*>(gEnv->pLyShine);
|
||||
CLyShine* lyShine = static_cast<CLyShine*>(AZ::Interface<ILyShine>::Get());
|
||||
|
||||
// There is an optional parameter which is a name to include in the output filename
|
||||
AZStd::string name;
|
||||
@@ -721,7 +721,7 @@ void CLyShine::DebugReportDrawCalls(IConsoleCmdArgs* cmdArgs)
|
||||
}
|
||||
|
||||
// Use the canvas manager to access all the loaded canvases
|
||||
pLyShine->m_uiCanvasManager->DebugReportDrawCalls(name);
|
||||
lyShine->m_uiCanvasManager->DebugReportDrawCalls(name);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -742,7 +742,7 @@ void CLyShine::RunUnitTests(IConsoleCmdArgs* cmdArgs)
|
||||
return;
|
||||
}
|
||||
|
||||
CLyShine* lyShine = static_cast<CLyShine*>(gEnv->pLyShine);
|
||||
CLyShine* lyShine = static_cast<CLyShine*>(AZ::Interface<ILyShine>::Get());
|
||||
AZ_Assert(lyShine, "Attempting to run unit-tests prior to LyShine initialization!");
|
||||
|
||||
TextMarkup::UnitTest(cmdArgs);
|
||||
|
||||
@@ -48,7 +48,7 @@ class CLyShine
|
||||
public:
|
||||
|
||||
//! Create the LyShine object, the given system pointer is stored internally
|
||||
CLyShine(ISystem* system);
|
||||
CLyShine();
|
||||
|
||||
// ILyShine
|
||||
|
||||
|
||||
@@ -997,7 +997,7 @@ static AZ::Entity* CreateButton(const char* name, bool atRoot, AZ::EntityId pare
|
||||
EBUS_EVENT_ID(buttonId, UiInteractableStatesBus, SetStateAlpha, UiInteractableStatesInterface::StatePressed, buttonId, pressedColor.GetA());
|
||||
|
||||
AZStd::string pathname = "Textures/Basic/Button_Sliced_Normal.sprite";
|
||||
ISprite* sprite = gEnv->pLyShine->LoadSprite(pathname);
|
||||
ISprite* sprite = AZ::Interface<ILyShine>::Get()->LoadSprite(pathname);
|
||||
|
||||
EBUS_EVENT_ID(buttonId, UiImageBus, SetSprite, sprite);
|
||||
EBUS_EVENT_ID(buttonId, UiImageBus, SetImageType, UiImageInterface::ImageType::Sliced);
|
||||
@@ -1096,7 +1096,7 @@ static AZ::Entity* CreateTextInput(const char* name, bool atRoot, AZ::EntityId p
|
||||
EBUS_EVENT_ID(textInputId, UiInteractableStatesBus, SetStateAlpha, UiInteractableStatesInterface::StatePressed, textInputId, pressedColor.GetA());
|
||||
|
||||
AZStd::string pathname = "Textures/Basic/Button_Sliced_Normal.sprite";
|
||||
ISprite* sprite = gEnv->pLyShine->LoadSprite(pathname);
|
||||
ISprite* sprite = AZ::Interface<ILyShine>::Get()->LoadSprite(pathname);
|
||||
|
||||
EBUS_EVENT_ID(textInputId, UiImageBus, SetSprite, sprite);
|
||||
EBUS_EVENT_ID(textInputId, UiImageBus, SetImageType, UiImageInterface::ImageType::Sliced);
|
||||
@@ -1192,7 +1192,7 @@ static void DestroyTestCanvas()
|
||||
delete g_testActionListener2;
|
||||
g_testActionListener2 = nullptr;
|
||||
|
||||
gEnv->pLyShine->ReleaseCanvas(g_testCanvasId, false);
|
||||
AZ::Interface<ILyShine>::Get()->ReleaseCanvas(g_testCanvasId, false);
|
||||
g_testCanvasId.SetInvalid();
|
||||
}
|
||||
}
|
||||
@@ -1216,7 +1216,7 @@ static void TestCanvasCreate ([[maybe_unused]] IConsoleCmdArgs* Cmd)
|
||||
DestroyTestCanvas();
|
||||
|
||||
// test creation of canvas and some simple elements
|
||||
AZ::EntityId canvasEntityId = gEnv->pLyShine->CreateCanvas();
|
||||
AZ::EntityId canvasEntityId = AZ::Interface<ILyShine>::Get()->CreateCanvas();
|
||||
UiCanvasInterface* canvas = UiCanvasBus::FindFirstHandler(canvasEntityId);
|
||||
if (!canvas)
|
||||
{
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
#include <AzCore/Serialization/SerializeContext.h>
|
||||
#include <AzCore/Component/ComponentApplicationBus.h>
|
||||
#include <AzCore/Interface/Interface.h>
|
||||
#include <LyShine/Bus/UiCanvasBus.h>
|
||||
#include <LyShine/Animation/IUiAnimation.h>
|
||||
|
||||
@@ -63,7 +64,7 @@ namespace LyShine
|
||||
AZ_ErrorOnce(nullptr, false, "NotifyGameLoadStart needs to be removed/ported to use Atom");
|
||||
return false;
|
||||
#if 0
|
||||
if (!gEnv || gEnv->pRenderer || !gEnv->pLyShine)
|
||||
if (!gEnv || gEnv->pRenderer || !AZ::Interface<ILyShine>::Get())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -103,7 +104,7 @@ namespace LyShine
|
||||
return false;
|
||||
//TODO: gEnv->pRenderer is always null, fix the logic below
|
||||
#if 0
|
||||
if (!gEnv || gEnv->pRenderer || !gEnv->pLyShine)
|
||||
if (!gEnv || gEnv->pRenderer || !AZ::Interface<ILyShine>::Get())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -140,22 +141,22 @@ namespace LyShine
|
||||
void LyShineLoadScreenComponent::UpdateAndRender([[maybe_unused]] float deltaTimeInSeconds)
|
||||
{
|
||||
AZ_Assert(m_isPlaying, "LyShineLoadScreenComponent should not be connected to LoadScreenUpdateNotificationBus while not playing");
|
||||
AZ_ErrorOnce(nullptr, m_isPlaying && gEnv && gEnv->pLyShine, "UpdateAndRender needs to be removed/ported to use Atom");
|
||||
AZ_ErrorOnce(nullptr, m_isPlaying && AZ::Interface<ILyShine>::Get(), "UpdateAndRender needs to be removed/ported to use Atom");
|
||||
|
||||
//TODO: gEnv->pRenderer is always null, fix the logic below
|
||||
#if 0
|
||||
if (m_isPlaying && gEnv && gEnv->pLyShine && gEnv->pRenderer)
|
||||
if (m_isPlaying && gEnv && AZ::Interface<ILyShine>::Get() && gEnv->pRenderer)
|
||||
{
|
||||
AZ_Assert(GetCurrentThreadId() == gEnv->mMainThreadId, "UpdateAndRender should only be called from the main thread");
|
||||
|
||||
// update the animation system
|
||||
gEnv->pLyShine->Update(deltaTimeInSeconds);
|
||||
AZ::Interface<ILyShine>::Get()->Update(deltaTimeInSeconds);
|
||||
|
||||
// Render.
|
||||
gEnv->pRenderer->SetViewport(0, 0, gEnv->pRenderer->GetOverlayWidth(), gEnv->pRenderer->GetOverlayHeight());
|
||||
|
||||
gEnv->pRenderer->BeginFrame();
|
||||
gEnv->pLyShine->Render();
|
||||
AZ::Interface<ILyShine>::Get()->Render();
|
||||
gEnv->pRenderer->EndFrame();
|
||||
}
|
||||
#endif
|
||||
@@ -177,7 +178,7 @@ namespace LyShine
|
||||
|
||||
m_isPlaying = false;
|
||||
|
||||
if (gEnv && gEnv->pLyShine)
|
||||
if (AZ::Interface<ILyShine>::Get())
|
||||
{
|
||||
AZ::Entity* canvasEntity = nullptr;
|
||||
|
||||
@@ -187,8 +188,8 @@ namespace LyShine
|
||||
EBUS_EVENT_RESULT(canvasEntity, AZ::ComponentApplicationBus, FindEntity, m_gameCanvasEntityId);
|
||||
if (canvasEntity)
|
||||
{
|
||||
gEnv->pLyShine->ReleaseCanvas(m_gameCanvasEntityId, false);
|
||||
gEnv->pLyShine->OnLoadScreenUnloaded();
|
||||
AZ::Interface<ILyShine>::Get()->ReleaseCanvas(m_gameCanvasEntityId, false);
|
||||
AZ::Interface<ILyShine>::Get()->OnLoadScreenUnloaded();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,8 +199,8 @@ namespace LyShine
|
||||
EBUS_EVENT_RESULT(canvasEntity, AZ::ComponentApplicationBus, FindEntity, m_levelCanvasEntityId);
|
||||
if (canvasEntity)
|
||||
{
|
||||
gEnv->pLyShine->ReleaseCanvas(m_levelCanvasEntityId, false);
|
||||
gEnv->pLyShine->OnLoadScreenUnloaded();
|
||||
AZ::Interface<ILyShine>::Get()->ReleaseCanvas(m_levelCanvasEntityId, false);
|
||||
AZ::Interface<ILyShine>::Get()->OnLoadScreenUnloaded();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -234,7 +235,7 @@ namespace LyShine
|
||||
return AZ::EntityId();
|
||||
}
|
||||
|
||||
AZ::EntityId canvasId = gEnv->pLyShine->LoadCanvas(path);
|
||||
AZ::EntityId canvasId = AZ::Interface<ILyShine>::Get()->LoadCanvas(path);
|
||||
AZ_Warning("LoadScreenComponent", canvasId.IsValid(), "Can't load canvas: %s", path.c_str());
|
||||
if (!canvasId.IsValid())
|
||||
{
|
||||
|
||||
@@ -384,16 +384,16 @@ namespace LyShine
|
||||
// When module is linked statically, we'll share the application's gEnv pointer.
|
||||
gEnv = system.GetGlobalEnvironment();
|
||||
#endif
|
||||
m_pLyShine = new CLyShine(gEnv->pSystem);
|
||||
gEnv->pLyShine = m_pLyShine;
|
||||
m_lyShine = AZStd::make_unique<CLyShine>();
|
||||
AZ::Interface<ILyShine>::Register(m_lyShine.get());
|
||||
|
||||
system.GetILevelSystem()->AddListener(this);
|
||||
|
||||
BroadcastCursorImagePathname();
|
||||
|
||||
if (gEnv->pLyShine)
|
||||
if (AZ::Interface<ILyShine>::Get())
|
||||
{
|
||||
gEnv->pLyShine->PostInit();
|
||||
AZ::Interface<ILyShine>::Get()->PostInit();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -402,18 +402,20 @@ namespace LyShine
|
||||
{
|
||||
system.GetILevelSystem()->RemoveListener(this);
|
||||
|
||||
gEnv->pLyShine = nullptr;
|
||||
delete m_pLyShine;
|
||||
m_pLyShine = nullptr;
|
||||
if (m_lyShine)
|
||||
{
|
||||
AZ::Interface<ILyShine>::Unregister(m_lyShine.get());
|
||||
m_lyShine.reset();
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
void LyShineSystemComponent::OnUnloadComplete([[maybe_unused]] const char* levelName)
|
||||
{
|
||||
// Perform level unload procedures for the LyShine UI system
|
||||
if (gEnv && gEnv->pLyShine)
|
||||
if (AZ::Interface<ILyShine>::Get())
|
||||
{
|
||||
gEnv->pLyShine->OnLevelUnload();
|
||||
AZ::Interface<ILyShine>::Get()->OnLevelUnload();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ namespace LyShine
|
||||
|
||||
protected: // data
|
||||
|
||||
CLyShine* m_pLyShine = nullptr;
|
||||
AZStd::unique_ptr<ILyShine> m_lyShine;
|
||||
|
||||
AzFramework::SimpleAssetReference<LmbrCentral::TextureAsset> m_cursorImagePathname;
|
||||
|
||||
|
||||
@@ -114,7 +114,7 @@ AZ::EntityId UiCanvasLuaProxy::LoadCanvas(const char* canvasFilename)
|
||||
CryWarning(VALIDATOR_MODULE_SYSTEM, VALIDATOR_WARNING,
|
||||
"UiCanvasLuaProxy:LoadCanvas is deprecated. Please use UiCanvasManagerBus:LoadCanvas instead\n");
|
||||
|
||||
return gEnv->pLyShine->LoadCanvas(canvasFilename);
|
||||
return AZ::Interface<ILyShine>::Get()->LoadCanvas(canvasFilename);
|
||||
}
|
||||
|
||||
void UiCanvasLuaProxy::UnloadCanvas(AZ::EntityId canvasEntityId)
|
||||
@@ -130,7 +130,7 @@ void UiCanvasLuaProxy::UnloadCanvas(AZ::EntityId canvasEntityId)
|
||||
UiCanvasComponent* canvasComponent = canvasEntity->FindComponent<UiCanvasComponent>();
|
||||
if (canvasComponent)
|
||||
{
|
||||
gEnv->pLyShine->ReleaseCanvas(canvasEntityId, false);
|
||||
AZ::Interface<ILyShine>::Get()->ReleaseCanvas(canvasEntityId, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -254,9 +254,9 @@ namespace
|
||||
|
||||
UiRenderer* GetUiRendererForGame()
|
||||
{
|
||||
if (gEnv && gEnv->pLyShine)
|
||||
if (AZ::Interface<ILyShine>::Get())
|
||||
{
|
||||
CLyShine* lyShine = static_cast<CLyShine*>(gEnv->pLyShine);
|
||||
CLyShine* lyShine = static_cast<CLyShine*>(AZ::Interface<ILyShine>::Get());
|
||||
return lyShine->GetUiRenderer();
|
||||
}
|
||||
return nullptr;
|
||||
@@ -264,9 +264,9 @@ namespace
|
||||
|
||||
UiRenderer* GetUiRendererForEditor()
|
||||
{
|
||||
if (gEnv && gEnv->pLyShine)
|
||||
if (AZ::Interface<ILyShine>::Get())
|
||||
{
|
||||
CLyShine* lyShine = static_cast<CLyShine*>(gEnv->pLyShine);
|
||||
CLyShine* lyShine = static_cast<CLyShine*>(AZ::Interface<ILyShine>::Get());
|
||||
return lyShine->GetUiRendererForEditor();
|
||||
}
|
||||
return nullptr;
|
||||
|
||||
@@ -588,7 +588,7 @@ void UiImageComponent::SetSpritePathname(AZStd::string spritePath)
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
bool UiImageComponent::SetSpritePathnameIfExists(AZStd::string spritePath)
|
||||
{
|
||||
if (gEnv->pLyShine->DoesSpriteTextureAssetExist(spritePath))
|
||||
if (AZ::Interface<ILyShine>::Get()->DoesSpriteTextureAssetExist(spritePath))
|
||||
{
|
||||
SetSpritePathname(spritePath);
|
||||
return true;
|
||||
@@ -1179,7 +1179,7 @@ void UiImageComponent::Init()
|
||||
// If this is called from RC.exe for example these pointers will not be set. In that case
|
||||
// we only need to be able to load, init and save the component. It will never be
|
||||
// activated.
|
||||
if (!(gEnv && gEnv->pLyShine))
|
||||
if (!AZ::Interface<ILyShine>::Get())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -1192,14 +1192,14 @@ void UiImageComponent::Init()
|
||||
{
|
||||
if (!m_spritePathname.GetAssetPath().empty())
|
||||
{
|
||||
m_sprite = gEnv->pLyShine->LoadSprite(m_spritePathname.GetAssetPath().c_str());
|
||||
m_sprite = AZ::Interface<ILyShine>::Get()->LoadSprite(m_spritePathname.GetAssetPath().c_str());
|
||||
}
|
||||
}
|
||||
else if (m_spriteType == UiImageInterface::SpriteType::RenderTarget)
|
||||
{
|
||||
if (!m_renderTargetName.empty())
|
||||
{
|
||||
m_sprite = gEnv->pLyShine->CreateSprite(m_renderTargetName.c_str());
|
||||
m_sprite = AZ::Interface<ILyShine>::Get()->CreateSprite(m_renderTargetName.c_str());
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -2527,7 +2527,7 @@ void UiImageComponent::OnSpritePathnameChange()
|
||||
if (!m_spritePathname.GetAssetPath().empty())
|
||||
{
|
||||
// Load the new texture.
|
||||
newSprite = gEnv->pLyShine->LoadSprite(m_spritePathname.GetAssetPath().c_str());
|
||||
newSprite = AZ::Interface<ILyShine>::Get()->LoadSprite(m_spritePathname.GetAssetPath().c_str());
|
||||
}
|
||||
|
||||
// if listening for notifications from a current sprite then disconnect
|
||||
@@ -2557,7 +2557,7 @@ void UiImageComponent::OnSpriteRenderTargetNameChange()
|
||||
|
||||
if (!m_renderTargetName.empty())
|
||||
{
|
||||
newSprite = gEnv->pLyShine->CreateSprite(m_renderTargetName.c_str());
|
||||
newSprite = AZ::Interface<ILyShine>::Get()->CreateSprite(m_renderTargetName.c_str());
|
||||
}
|
||||
|
||||
SAFE_RELEASE(m_sprite);
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace
|
||||
spriteList.reserve(imageList.size());
|
||||
for (auto& textureAssetRef : imageList)
|
||||
{
|
||||
ISprite* sprite = gEnv->pLyShine->LoadSprite(textureAssetRef.GetAssetPath().c_str());
|
||||
ISprite* sprite = AZ::Interface<ILyShine>::Get()->LoadSprite(textureAssetRef.GetAssetPath().c_str());
|
||||
if (sprite)
|
||||
{
|
||||
spriteList.push_back(sprite);
|
||||
@@ -383,7 +383,7 @@ void UiImageSequenceComponent::Init()
|
||||
// If this is called from RC.exe for example these pointers will not be set. In that case
|
||||
// we only need to be able to load, init and save the component. It will never be
|
||||
// activated.
|
||||
if (!(gEnv && gEnv->pLyShine))
|
||||
if (!AZ::Interface<ILyShine>::Get())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -274,7 +274,7 @@ UiInteractableStateSprite::UiInteractableStateSprite(AZ::EntityId target, const
|
||||
|
||||
if (!m_spritePathname.GetAssetPath().empty())
|
||||
{
|
||||
m_sprite = gEnv->pLyShine->LoadSprite(m_spritePathname.GetAssetPath().c_str());
|
||||
m_sprite = AZ::Interface<ILyShine>::Get()->LoadSprite(m_spritePathname.GetAssetPath().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -297,7 +297,7 @@ void UiInteractableStateSprite::Init(AZ::EntityId interactableEntityId)
|
||||
// If this is called from RC.exe for example these pointers will not be set. In that case
|
||||
// we only need to be able to load, init and save the component. It will never be
|
||||
// activated.
|
||||
if (!(gEnv && gEnv->pLyShine))
|
||||
if (!AZ::Interface<ILyShine>::Get())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -306,7 +306,7 @@ void UiInteractableStateSprite::Init(AZ::EntityId interactableEntityId)
|
||||
// are not loaded then load them
|
||||
if (!m_sprite && !m_spritePathname.GetAssetPath().empty())
|
||||
{
|
||||
m_sprite = gEnv->pLyShine->LoadSprite(m_spritePathname.GetAssetPath().c_str());
|
||||
m_sprite = AZ::Interface<ILyShine>::Get()->LoadSprite(m_spritePathname.GetAssetPath().c_str());
|
||||
}
|
||||
|
||||
if (!m_sprite)
|
||||
@@ -366,7 +366,7 @@ void UiInteractableStateSprite::OnSpritePathnameChange()
|
||||
if (!m_spritePathname.GetAssetPath().empty())
|
||||
{
|
||||
// Load the new texture.
|
||||
newSprite = gEnv->pLyShine->LoadSprite(m_spritePathname.GetAssetPath().c_str());
|
||||
newSprite = AZ::Interface<ILyShine>::Get()->LoadSprite(m_spritePathname.GetAssetPath().c_str());
|
||||
}
|
||||
|
||||
SAFE_RELEASE(m_sprite);
|
||||
|
||||
@@ -1429,14 +1429,14 @@ void UiParticleEmitterComponent::Init()
|
||||
// If this is called from RC.exe for example these pointers will not be set. In that case
|
||||
// we only need to be able to load, init and save the component. It will never be
|
||||
// activated.
|
||||
if (!(gEnv && gEnv->pLyShine))
|
||||
if (!AZ::Interface<ILyShine>::Get())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_sprite && !m_spritePathname.GetAssetPath().empty())
|
||||
{
|
||||
m_sprite = gEnv->pLyShine->LoadSprite(m_spritePathname.GetAssetPath().c_str());
|
||||
m_sprite = AZ::Interface<ILyShine>::Get()->LoadSprite(m_spritePathname.GetAssetPath().c_str());
|
||||
}
|
||||
|
||||
m_currentAspectRatio = m_particleSize.GetX() / m_particleSize.GetY();
|
||||
@@ -1927,7 +1927,7 @@ void UiParticleEmitterComponent::OnSpritePathnameChange()
|
||||
if (!m_spritePathname.GetAssetPath().empty())
|
||||
{
|
||||
// Load the new texture.
|
||||
newSprite = gEnv->pLyShine->LoadSprite(m_spritePathname.GetAssetPath().c_str());
|
||||
newSprite = AZ::Interface<ILyShine>::Get()->LoadSprite(m_spritePathname.GetAssetPath().c_str());
|
||||
}
|
||||
|
||||
SAFE_RELEASE(m_sprite);
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "UiCanvasAssetRefComponent.h"
|
||||
#include <AzCore/Serialization/SerializeContext.h>
|
||||
#include <AzCore/Serialization/EditContext.h>
|
||||
#include <AzCore/Interface/Interface.h>
|
||||
#include <AzCore/RTTI/BehaviorContext.h>
|
||||
#include <LyShine/Bus/UiCanvasBus.h>
|
||||
#include <LyShine/LyShineBus.h>
|
||||
@@ -106,11 +107,11 @@ AZ::EntityId UiCanvasAssetRefComponent::LoadCanvas()
|
||||
// Check if we already have a referenced UI canvas, if so release it
|
||||
if (m_canvasEntityId.IsValid())
|
||||
{
|
||||
gEnv->pLyShine->ReleaseCanvasDeferred(m_canvasEntityId);
|
||||
AZ::Interface<ILyShine>::Get()->ReleaseCanvasDeferred(m_canvasEntityId);
|
||||
m_canvasEntityId.SetInvalid();
|
||||
}
|
||||
|
||||
m_canvasEntityId = gEnv->pLyShine->LoadCanvas(canvasPath.c_str());
|
||||
m_canvasEntityId = AZ::Interface<ILyShine>::Get()->LoadCanvas(canvasPath.c_str());
|
||||
|
||||
EBUS_EVENT_ID(GetEntityId(), UiCanvasAssetRefNotificationBus, OnCanvasLoadedIntoEntity, m_canvasEntityId);
|
||||
EBUS_EVENT_ID(GetEntityId(), UiCanvasRefNotificationBus, OnCanvasRefChanged, GetEntityId(), m_canvasEntityId);
|
||||
@@ -124,7 +125,7 @@ void UiCanvasAssetRefComponent::UnloadCanvas()
|
||||
{
|
||||
if (m_canvasEntityId.IsValid())
|
||||
{
|
||||
gEnv->pLyShine->ReleaseCanvasDeferred(m_canvasEntityId);
|
||||
AZ::Interface<ILyShine>::Get()->ReleaseCanvasDeferred(m_canvasEntityId);
|
||||
m_canvasEntityId.SetInvalid();
|
||||
|
||||
EBUS_EVENT_ID(GetEntityId(), UiCanvasRefNotificationBus, OnCanvasRefChanged, GetEntityId(), m_canvasEntityId);
|
||||
@@ -243,7 +244,7 @@ void UiCanvasAssetRefComponent::Deactivate()
|
||||
{
|
||||
if (m_canvasEntityId.IsValid())
|
||||
{
|
||||
gEnv->pLyShine->ReleaseCanvasDeferred(m_canvasEntityId);
|
||||
AZ::Interface<ILyShine>::Get()->ReleaseCanvasDeferred(m_canvasEntityId);
|
||||
m_canvasEntityId.SetInvalid();
|
||||
}
|
||||
|
||||
|
||||
@@ -144,7 +144,6 @@ namespace UnitTest
|
||||
SSystemGlobalEnvironment env;
|
||||
SSystemGlobalEnvironment* prevEnv = gEnv;
|
||||
gEnv = &env;
|
||||
gEnv->pLyShine = nullptr;
|
||||
|
||||
auto [uiCanvasComponent, uiTooltipDisplayComponent, uiTooltipComponent] = CreateUiCanvasWithTooltip();
|
||||
uiTooltipDisplayComponent->SetTriggerMode(UiTooltipDisplayInterface::TriggerMode::OnHover);
|
||||
@@ -170,7 +169,6 @@ namespace UnitTest
|
||||
SSystemGlobalEnvironment env;
|
||||
SSystemGlobalEnvironment* prevEnv = gEnv;
|
||||
gEnv = &env;
|
||||
gEnv->pLyShine = nullptr;
|
||||
|
||||
auto [uiCanvasComponent, uiTooltipDisplayComponent, uiTooltipComponent] = CreateUiCanvasWithTooltip();
|
||||
uiTooltipDisplayComponent->SetTriggerMode(UiTooltipDisplayInterface::TriggerMode::OnHover);
|
||||
@@ -194,7 +192,6 @@ namespace UnitTest
|
||||
SSystemGlobalEnvironment env;
|
||||
SSystemGlobalEnvironment* prevEnv = gEnv;
|
||||
gEnv = &env;
|
||||
gEnv->pLyShine = nullptr;
|
||||
|
||||
auto [uiCanvasComponent, uiTooltipDisplayComponent, uiTooltipComponent] = CreateUiCanvasWithTooltip();
|
||||
uiTooltipDisplayComponent->SetTriggerMode(UiTooltipDisplayInterface::TriggerMode::OnPress);
|
||||
@@ -218,7 +215,6 @@ namespace UnitTest
|
||||
SSystemGlobalEnvironment env;
|
||||
SSystemGlobalEnvironment* prevEnv = gEnv;
|
||||
gEnv = &env;
|
||||
gEnv->pLyShine = nullptr;
|
||||
|
||||
auto [uiCanvasComponent, uiTooltipDisplayComponent, uiTooltipComponent] = CreateUiCanvasWithTooltip();
|
||||
uiTooltipDisplayComponent->SetTriggerMode(UiTooltipDisplayInterface::TriggerMode::OnPress);
|
||||
@@ -242,7 +238,6 @@ namespace UnitTest
|
||||
SSystemGlobalEnvironment env;
|
||||
SSystemGlobalEnvironment* prevEnv = gEnv;
|
||||
gEnv = &env;
|
||||
gEnv->pLyShine = nullptr;
|
||||
|
||||
auto [uiCanvasComponent, uiTooltipDisplayComponent, uiTooltipComponent] = CreateUiCanvasWithTooltip();
|
||||
uiTooltipDisplayComponent->SetTriggerMode(UiTooltipDisplayInterface::TriggerMode::OnClick);
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace LyShineExamples
|
||||
// Remove the existing example canvas if it exists
|
||||
DestroyCanvas();
|
||||
|
||||
AZ::EntityId canvasEntityId = gEnv->pLyShine->CreateCanvas();
|
||||
AZ::EntityId canvasEntityId = AZ::Interface<ILyShine>::Get()->CreateCanvas();
|
||||
if (!canvasEntityId.IsValid())
|
||||
{
|
||||
return;
|
||||
@@ -90,7 +90,7 @@ namespace LyShineExamples
|
||||
|
||||
m_healthBar.SetInvalid();
|
||||
|
||||
gEnv->pLyShine->ReleaseCanvas(m_canvasId, false);
|
||||
AZ::Interface<ILyShine>::Get()->ReleaseCanvas(m_canvasId, false);
|
||||
m_canvasId.SetInvalid();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -284,7 +284,7 @@ namespace LyShineExamples
|
||||
// If this is called from RC.exe for example these pointers will not be set. In that case
|
||||
// we only need to be able to load, init and save the component. It will never be
|
||||
// activated.
|
||||
if (!(gEnv && gEnv->pLyShine))
|
||||
if (!AZ::Interface<ILyShine>::Get())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -294,7 +294,7 @@ namespace LyShineExamples
|
||||
{
|
||||
if (!m_spritePathname.GetAssetPath().empty())
|
||||
{
|
||||
m_sprite = gEnv->pLyShine->LoadSprite(m_spritePathname.GetAssetPath().c_str());
|
||||
m_sprite = AZ::Interface<ILyShine>::Get()->LoadSprite(m_spritePathname.GetAssetPath().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -399,7 +399,7 @@ namespace LyShineExamples
|
||||
if (!m_spritePathname.GetAssetPath().empty())
|
||||
{
|
||||
// Load the new texture.
|
||||
newSprite = gEnv->pLyShine->LoadSprite(m_spritePathname.GetAssetPath().c_str());
|
||||
newSprite = AZ::Interface<ILyShine>::Get()->LoadSprite(m_spritePathname.GetAssetPath().c_str());
|
||||
}
|
||||
|
||||
SAFE_RELEASE(m_sprite);
|
||||
|
||||
@@ -127,21 +127,21 @@ namespace MessagePopup
|
||||
switch (_buttons)
|
||||
{
|
||||
case EPopupButtons::EPopupButtons_NoButtons:
|
||||
canvasEntityId = gEnv->pLyShine->LoadCanvas("@products@/ui/canvases/defaultmessagepopup.uicanvas");
|
||||
canvasEntityId = AZ::Interface<ILyShine>::Get()->LoadCanvas("@products@/ui/canvases/defaultmessagepopup.uicanvas");
|
||||
break;
|
||||
case EPopupButtons::EPopupButtons_Confirm:
|
||||
canvasEntityId = gEnv->pLyShine->LoadCanvas("@products@/ui/canvases/defaultmessagepopup_confirm.uicanvas");
|
||||
canvasEntityId = AZ::Interface<ILyShine>::Get()->LoadCanvas("@products@/ui/canvases/defaultmessagepopup_confirm.uicanvas");
|
||||
isNavigationSupported = true;
|
||||
break;
|
||||
case EPopupButtons::EPopupButtons_YesNo:
|
||||
canvasEntityId = gEnv->pLyShine->LoadCanvas("@products@/ui/canvases/defaultmessagepopup_yesno.uicanvas");
|
||||
canvasEntityId = AZ::Interface<ILyShine>::Get()->LoadCanvas("@products@/ui/canvases/defaultmessagepopup_yesno.uicanvas");
|
||||
isNavigationSupported = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (_kind == EPopupKind_Toaster)
|
||||
{
|
||||
canvasEntityId = gEnv->pLyShine->LoadCanvas("@products@/ui/canvases/toaster.uicanvas");
|
||||
canvasEntityId = AZ::Interface<ILyShine>::Get()->LoadCanvas("@products@/ui/canvases/toaster.uicanvas");
|
||||
}
|
||||
|
||||
if (canvasEntityId.IsValid())
|
||||
@@ -183,7 +183,7 @@ namespace MessagePopup
|
||||
{
|
||||
// get the canvas ID in the clientdata
|
||||
LyShine::CanvasId canvasId = *((LyShine::CanvasId*)&_popupInfo.m_clientData);
|
||||
AZ::EntityId canvasEntityId = gEnv->pLyShine->FindCanvasById(canvasId);
|
||||
AZ::EntityId canvasEntityId = AZ::Interface<ILyShine>::Get()->FindCanvasById(canvasId);
|
||||
if (canvasEntityId.IsValid())
|
||||
{
|
||||
// Hide the cursor if it was shown in LyShineMessagePopup::OnShowPopup
|
||||
@@ -197,7 +197,7 @@ namespace MessagePopup
|
||||
// Disable the popup
|
||||
EBUS_EVENT_ID(canvasEntityId, UiCanvasBus, SetEnabled, false);
|
||||
|
||||
gEnv->pLyShine->ReleaseCanvas(canvasEntityId, false);
|
||||
AZ::Interface<ILyShine>::Get()->ReleaseCanvas(canvasEntityId, false);
|
||||
|
||||
UiCanvasNotificationBus::MultiHandler::BusDisconnect(canvasEntityId);
|
||||
m_activePopupIdsByCanvasId.erase(canvasEntityId);
|
||||
|
||||
Reference in New Issue
Block a user