Skip to content

Commit

Permalink
😴 Sleepy Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
wobbier committed Aug 17, 2024
1 parent e58c9a8 commit 10af8c0
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 5 deletions.
10 changes: 10 additions & 0 deletions Modules/Dementia/Source/Mathf.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,14 @@ namespace Mathf
const float bestRatio = std::min( inSizeConstraints.x / inSize.x, inSizeConstraints.y / inSize.y );
return { inSize.x * bestRatio, inSize.y * bestRatio };
}

inline float Min( float x, float y )
{
return std::min( x, y );
}

inline float Max( float x, float y )
{
return std::max( x, y );
}
}
2 changes: 2 additions & 0 deletions Modules/Dementia/Source/Types/AssetType.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ namespace {
return "Level";
case AssetType::Shader:
return "Shader";
case AssetType::ShaderGraph:
return "ShaderGraph";
case AssetType::Prefab:
return "Prefab";
case AssetType::UI:
Expand Down
5 changes: 3 additions & 2 deletions Modules/Moonlight/Source/Device/FrameBuffer.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "FrameBuffer.h"
#include <CLog.h>
#include "Mathf.h"

Moonlight::FrameBuffer::FrameBuffer( uint32_t width, uint32_t height )
: Width( width )
Expand All @@ -20,8 +21,8 @@ void Moonlight::FrameBuffer::Resize( Vector2 newSize )
{
CLog::Log( CLog::LogType::Warning, "[TODO] Trying to resize frame buffer." );

Width = newSize.x;
Height = newSize.y;
Width = Mathf::Max( newSize.x, 1.f );
Height = Mathf::Max( newSize.y, 1.f );
ReCreate( m_resetFlags );
}

Expand Down
12 changes: 12 additions & 0 deletions Source/Components/UI/BasicUIView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ void BasicUIView::OnDOMReady( ultralight::View* caller,
GlobalWindow["PlaySound"] = BindJSCallback( &BasicUIView::PlaySound );
GlobalWindow["LoadScene"] = BindJSCallback( &BasicUIView::LoadScene );
GlobalWindow["Quit"] = BindJSCallback( &BasicUIView::Quit );
GlobalWindow["AreToolsEnabled"] = BindJSCallbackWithRetval( &BasicUIView::AreToolsEnabled );

OnUILoad( GlobalWindow, caller );
}
Expand Down Expand Up @@ -102,6 +103,7 @@ void BasicUIView::PlaySound( const ultralight::JSObject& thisObject, const ultra
evt.Fire();
}


void BasicUIView::LoadScene( const ultralight::JSObject& thisObject, const ultralight::JSArgs& args )
{
SharedPtr<LoadSceneEvent> evt = MakeShared<LoadSceneEvent>();
Expand All @@ -116,6 +118,16 @@ void BasicUIView::Quit( const ultralight::JSObject& thisObject, const ultralight
{
GetEngine().Quit();
}

ultralight::JSValue BasicUIView::AreToolsEnabled( const ultralight::JSObject& thisObject, const ultralight::JSArgs& args )
{
#if USING( ME_TOOLS )
return ultralight::JSValue( true );
#else
return ultralight::JSValue( false );
#endif
}

#endif

#if USING( ME_EDITOR )
Expand Down
1 change: 1 addition & 0 deletions Source/Components/UI/BasicUIView.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class BasicUIView
void PlaySound( const ultralight::JSObject& thisObject, const ultralight::JSArgs& args );
void LoadScene( const ultralight::JSObject& thisObject, const ultralight::JSArgs& args );
void Quit( const ultralight::JSObject& thisObject, const ultralight::JSArgs& args );
ultralight::JSValue AreToolsEnabled( const ultralight::JSObject& thisObject, const ultralight::JSArgs& args );
#endif

private:
Expand Down
6 changes: 3 additions & 3 deletions Source/Cores/UI/UICore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ void UICore::Update( const UpdateContext& inUpdateContext )
{
InitUIView( view );
}

view.OnUpdate();
}
#if USING( ME_UI )
Expand Down Expand Up @@ -341,8 +341,8 @@ void UICore::OnResize( const Vector2& NewSize )
bgfx::destroy( m_uiTexture );
}

m_uiTexture = bgfx::createTexture2D( static_cast<uint16_t>( NewSize.x )
, static_cast<uint16_t>( Mathf::Abs( NewSize.y ) )
m_uiTexture = bgfx::createTexture2D( static_cast<uint16_t>( Mathf::Max( NewSize.x, 1.f ) )
, static_cast<uint16_t>( Mathf::Abs( Mathf::Max( NewSize.y, 1.f ) ) )
, false
, 1
, bgfx::TextureFormat::BGRA8
Expand Down

0 comments on commit 10af8c0

Please sign in to comment.