Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade unreal engine 5.2 #37

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Source/FairyGUI/FairyGUI.Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,6 @@ public FairyGUI(ReadOnlyTargetRules Target) : base(Target)
);
}
}



5 changes: 4 additions & 1 deletion Source/FairyGUI/Private/FairyApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,10 @@ void UFairyApplication::PlaySound(const FString& URL, float VolumnScale)
if (SoundItem.IsValid())
{
SoundItem->Load();
FSlateApplication::Get().PlaySound(*SoundItem->Sound);
if (SoundItem->Sound.IsValid())
{
FSlateApplication::Get().PlaySound(*SoundItem->Sound);
}
}
}

Expand Down
8 changes: 6 additions & 2 deletions Source/FairyGUI/Private/UI/GComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@ UGComponent::UGComponent() :
{
DisplayObject = RootContainer = SNew(SContainer).GObject(this);
DisplayObject->SetOpaque(false);

Container = SNew(SContainer);
Container->SetOpaque(false);
RootContainer->AddChild(Container.ToSharedRef());

if (IsInGameThread())
{
RootContainer->AddChild(Container.ToSharedRef());
}
}

UGComponent::~UGComponent()
Expand Down
8 changes: 4 additions & 4 deletions Source/FairyGUI/Private/UI/GList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@ void UGList::ScrollToView(int32 Index, bool bAnimation, bool bSetFirst)
verifyf(Index >= 0 && Index < VirtualItems.Num(), TEXT("Invalid child index"));

if (bLoop)
Index = FMath::FloorToFloat(FirstIndex / NumItems) * NumItems + Index;
Index = FMath::FloorToFloat(static_cast<float>(FirstIndex) / NumItems) * NumItems + Index;

FBox2D rect;
FItemInfo& ii = VirtualItems[Index];
Expand Down Expand Up @@ -1072,19 +1072,19 @@ FVector2D UGList::GetSnappingPosition(const FVector2D& InPoint)
FVector2D ret = InPoint;
if (Layout == EListLayoutType::SingleColumn || Layout == EListLayoutType::FlowHorizontal)
{
int32 index = GetIndexOnPos1(ret.Y, false);
int32 index = GetIndexOnPos1(reinterpret_cast<float&>(ret.Y), false);
if (index < VirtualItems.Num() && InPoint.Y - ret.Y > VirtualItems[index].Size.Y / 2 && index < RealNumItems)
ret.Y += VirtualItems[index].Size.Y + LineGap;
}
else if (Layout == EListLayoutType::SingleRow || Layout == EListLayoutType::FlowVertical)
{
int32 index = GetIndexOnPos2(ret.X, false);
int32 index = GetIndexOnPos2(reinterpret_cast<float&>(ret.X), false);
if (index < VirtualItems.Num() && InPoint.X - ret.X > VirtualItems[index].Size.X / 2 && index < RealNumItems)
ret.X += VirtualItems[index].Size.X + ColumnGap;
}
else
{
int32 index = GetIndexOnPos3(ret.X, false);
int32 index = GetIndexOnPos3(reinterpret_cast<float&>(ret.X), false);
if (index < VirtualItems.Num() && InPoint.X - ret.X > VirtualItems[index].Size.X / 2 && index < RealNumItems)
ret.X += VirtualItems[index].Size.X + ColumnGap;
}
Expand Down
8 changes: 4 additions & 4 deletions Source/FairyGUI/Private/Widgets/BitmapFontRun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,24 +79,24 @@ FVector2D FBitmapFontRun::GetLocationAt(const TSharedRef< ILayoutBlock >& Block,
return Block->GetLocationOffset();
}

int32 FBitmapFontRun::OnPaint(const FPaintArgs& Args, const FTextLayout::FLineView& Line, const TSharedRef< ILayoutBlock >& Block, const FTextBlockStyle& DefaultStyle, const FGeometry& AllottedGeometry, const FSlateRect& MyCullingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled) const
int32 FBitmapFontRun::OnPaint(const FPaintArgs& PaintArgs, const FTextArgs& TextArgs, const FGeometry& AllottedGeometry, const FSlateRect& MyCullingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled) const
{
if (Glyph == nullptr)
return LayerId;

// The block size and offset values are pre-scaled, so we need to account for that when converting the block offsets into paint geometry
const float InverseScale = Inverse(AllottedGeometry.Scale);

FLinearColor FinalColorAndOpacity;
if (Font->bCanTint)
FinalColorAndOpacity = InWidgetStyle.GetColorAndOpacityTint() * DefaultStyle.ColorAndOpacity.GetSpecifiedColor();
FinalColorAndOpacity = InWidgetStyle.GetColorAndOpacityTint() * TextArgs.DefaultStyle.ColorAndOpacity.GetSpecifiedColor();
else
FinalColorAndOpacity = InWidgetStyle.GetColorAndOpacityTint();
const ESlateDrawEffect DrawEffects = bParentEnabled ? ESlateDrawEffect::None : ESlateDrawEffect::DisabledEffect;
FSlateDrawElement::MakeBox(
OutDrawElements,
++LayerId,
AllottedGeometry.ToPaintGeometry(Glyph->Size, FSlateLayoutTransform(TransformPoint(InverseScale, Block->GetLocationOffset()) + Glyph->Offset)),
AllottedGeometry.ToPaintGeometry(Glyph->Size, FSlateLayoutTransform(TransformPoint(InverseScale, TextArgs.Block->GetLocationOffset()) + Glyph->Offset)),
&Brush,
DrawEffects,
FinalColorAndOpacity
Expand Down
7 changes: 4 additions & 3 deletions Source/FairyGUI/Private/Widgets/LoaderRun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,12 @@ FVector2D FLoaderRun::GetLocationAt(const TSharedRef< ILayoutBlock >& Block, int
return Block->GetLocationOffset();
}

int32 FLoaderRun::OnPaint(const FPaintArgs& Args, const FTextLayout::FLineView& Line, const TSharedRef< ILayoutBlock >& Block, const FTextBlockStyle& DefaultStyle, const FGeometry& AllottedGeometry, const FSlateRect& MyCullingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled) const
int32 FLoaderRun::OnPaint(const FPaintArgs& PaintArgs, const FTextArgs& TextArgs, const FGeometry& AllottedGeometry, const FSlateRect& MyCullingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled) const
{

const float InverseScale = Inverse(AllottedGeometry.Scale);
const FGeometry WidgetGeometry = AllottedGeometry.MakeChild(TransformVector(InverseScale, Block->GetSize()), FSlateLayoutTransform(TransformPoint(InverseScale, Block->GetLocationOffset())));
return Children[0]->Paint(Args, WidgetGeometry, MyCullingRect, OutDrawElements, LayerId, InWidgetStyle, bParentEnabled);
const FGeometry WidgetGeometry = AllottedGeometry.MakeChild(TransformVector(InverseScale, TextArgs.Block->GetSize()), FSlateLayoutTransform(TransformPoint(InverseScale, TextArgs.Block->GetLocationOffset())));
return Children[0]->Paint(PaintArgs, WidgetGeometry, MyCullingRect, OutDrawElements, LayerId, InWidgetStyle, bParentEnabled);
}

TSharedRef< ILayoutBlock > FLoaderRun::CreateBlock(int32 BeginIndex, int32 EndIndex, FVector2D Size, const FLayoutBlockTextContext& TextContext, const TSharedPtr< IRunRenderer >& Renderer)
Expand Down
6 changes: 3 additions & 3 deletions Source/FairyGUI/Private/Widgets/Mesh/PolygonMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@ void FPolygonMesh::DrawOutline(FVertexHelper& Helper)
int32 start = k - numVertices;
for (int32 i = 0; i < numVertices; i++)
{
const FVector2D& p0 = Helper.Vertices[start + i].Position;
const FVector2D& p0 = FVector2D(Helper.Vertices[start + i].Position);
FVector2D p1;
if (i < numVertices - 1)
p1 = Helper.Vertices[start + i + 1].Position;
p1 = FVector2D(Helper.Vertices[start + i + 1].Position);
else
p1 = Helper.Vertices[start].Position;
p1 = FVector2D(Helper.Vertices[start].Position);

FVector2D widthVector(p1.Y - p0.Y, p0.X - p1.X);
widthVector.Normalize();
Expand Down
6 changes: 3 additions & 3 deletions Source/FairyGUI/Private/Widgets/Mesh/VertexHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void FVertexHelper::AddVertex(const FVector2D& Position, const FColor& Color)
void FVertexHelper::AddVertex(const FVector2D& Position, const FColor& Color, const FVector2D& TexCoords)
{
FSlateVertex Vertex;
Vertex.Position = Position;
Vertex.Position = FVector2f(Position);
Vertex.Color = Color;
Vertex.TexCoords[0] = TexCoords.X;
Vertex.TexCoords[1] = TexCoords.Y;
Expand Down Expand Up @@ -117,8 +117,8 @@ const FVector2D& FVertexHelper::GetPosition(int32 Index)
{
if (Index < 0)
Index = Vertices.Num() + Index;

return Vertices[Index].Position;
return *new FVector2D(Vertices[Index].Position);
}

FVector2D FVertexHelper::GetUVAtPosition(const FVector2D& Position, bool bUsePercent)
Expand Down
4 changes: 2 additions & 2 deletions Source/FairyGUI/Private/Widgets/NGraphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void FNGraphics::Paint(const FGeometry& AllottedGeometry,
int32 VerticeLength = Vertices.Num();
for (int32 i = 0; i < VerticeLength; i++)
{
Vertices[i].Position = AllottedGeometry.LocalToAbsolute(PositionsBackup[i]);
Vertices[i].Position =FVector2f(AllottedGeometry.LocalToAbsolute(PositionsBackup[i]));
}

FSlateDrawElement::MakeCustomVerts(OutDrawElements, LayerId, ResourceHandle, Vertices, Triangles, nullptr, 0, 0, DrawEffects);
Expand Down Expand Up @@ -157,7 +157,7 @@ void FNGraphics::UpdateMeshNow()
AlphaBackup[i] = Vertex.Color.A;
Vertex.Color.A = (uint8)FMath::Clamp<int32>(FMath::TruncToInt(Vertex.Color.A * UsingAlpha), 0, 255),

PositionsBackup[i] = Vertex.Position;
PositionsBackup[i] = FVector2D(Vertex.Position);
}

Vertices += Helper.Vertices;
Expand Down
4 changes: 2 additions & 2 deletions Source/FairyGUI/Private/Widgets/NTexture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ UNTexture* UNTexture::GetWhiteTexture()
if (WhiteTexture == nullptr)
{
UTexture2D* NativeTexture = UTexture2D::CreateTransient(2, 2);
uint8* MipData = (uint8*)NativeTexture->PlatformData->Mips[0].BulkData.Lock(LOCK_READ_WRITE);
uint8* MipData = (uint8*)NativeTexture->GetPlatformData()->Mips[0].BulkData.Lock(LOCK_READ_WRITE);
for (int32 i = 0; i < 16; i++)
*(MipData + i) = 255;
NativeTexture->PlatformData->Mips[0].BulkData.Unlock();
NativeTexture->GetPlatformData()->Mips[0].BulkData.Unlock();
#if WITH_EDITORONLY_DATA
NativeTexture->CompressionNone = true;
NativeTexture->MipGenSettings = TMGS_NoMipmaps;
Expand Down
35 changes: 25 additions & 10 deletions Source/FairyGUI/Private/Widgets/SContainer.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,34 @@

#include "Widgets/SContainer.h"
#include "FairyApplication.h"
#include "UI/GComponent.h"
#include "UI/GObject.h"

SContainer::SContainer() :
Children(this)
SContainer::FSlot::FSlot(const TSharedRef<SWidget>& InWidget)
: TSlotBase<FSlot>(InWidget)
{
}

SContainer::FSlot::FSlot(const FChildren& InParent)
{

}

void SContainer::FSlot::Construct(const FChildren& SlotOwner, FSlotArguments&& InArg)
{
TSlotBase<FSlot>::Construct(SlotOwner, MoveTemp(InArg));
}

SContainer::SContainer()
:Children(this)
{
bCanSupportFocus = false;
}

void SContainer::Construct(const SContainer::FArguments& InArgs)
{
SDisplayObject::Construct(SDisplayObject::FArguments().GObject(InArgs._GObject));
Children.AddSlots(MoveTemp(const_cast<TArray<FSlot::FSlotArguments>&>(InArgs._Slots)));
}

void SContainer::AddChild(const TSharedRef<SWidget>& SlotWidget)
Expand All @@ -29,14 +46,12 @@ void SContainer::AddChildAt(const TSharedRef<SWidget>& SlotWidget, int32 Index)
else
{
verifyf(!SlotWidget->GetParentWidget().IsValid(), TEXT("Cant add a child has parent"));

FSlotBase& NewSlot = *new FSlotBase();
if (Index == Count)
Children.Add(&NewSlot);
else
Children.Insert(&NewSlot, Index);
NewSlot.AttachWidget(SlotWidget);


if (Index == Count)
AddSlot(SlotWidget);
else
InsertSlot(SlotWidget,Index);

UGObject* OnStageObj = SDisplayObject::GetWidgetGObjectIfOnStage(AsShared());
if (OnStageObj != nullptr)
{
Expand Down
18 changes: 14 additions & 4 deletions Source/FairyGUI/Private/Widgets/SDisplayObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "UI/GObject.h"

bool SDisplayObject::bMindVisibleOnly = false;
FNoChildren SDisplayObject::NoChildrenInstance;
FName SDisplayObject::SDisplayObjectTag("SDisplayObjectTag");

SDisplayObject::SDisplayObject() :
Expand All @@ -29,7 +28,12 @@ const FVector2D& SDisplayObject::GetPosition() const
if (!GetRenderTransform().IsSet())
return FVector2D::ZeroVector;
else
return GetRenderTransform()->GetTranslation();
{
FVector2D& fv = *new FVector2D() ;
fv = GetRenderTransform()->GetTranslation();
return fv;
}

}

void SDisplayObject::SetPosition(const FVector2D& InPosition)
Expand Down Expand Up @@ -108,13 +112,14 @@ void SDisplayObject::SetInteractable(bool bInInteractable)

void SDisplayObject::UpdateVisibilityFlags()
{

bool HitTestFlag = bInteractable && bTouchable;
if (!bVisible)
SetVisibility(EVisibility::Collapsed);
else if (!HitTestFlag)
SetVisibility(EVisibility::HitTestInvisible);
else if (GObject.IsValid() && GObject->GetHitArea() != nullptr)
Visibility.BindRaw(this, &SDisplayObject::GetVisibilityFlags);
SetVisibility(TAttribute<EVisibility>(this, &SDisplayObject::GetVisibilityFlags));
else if (!bOpaque)
SetVisibility(EVisibility::SelfHitTestInvisible);
else
Expand Down Expand Up @@ -157,7 +162,7 @@ FVector2D SDisplayObject::ComputeDesiredSize(float) const

FChildren* SDisplayObject::GetChildren()
{
return &NoChildrenInstance;
return &FNoChildren::NoChildrenInstance;
}

void SDisplayObject::OnArrangeChildren(const FGeometry& AllottedGeometry, FArrangedChildren& ArrangedChildren) const
Expand Down Expand Up @@ -228,6 +233,11 @@ FReply SDisplayObject::OnMouseWheel(const FGeometry& MyGeometry, const FPointerE
return FReply::Unhandled();
}

void SDisplayObject::SetVisibility(TAttribute<EVisibility> InVisibility)
{
SWidget::SetVisibility(InVisibility);
}

bool SDisplayObject::IsWidgetOnStage(const TSharedPtr<SWidget>& InWidget)
{
TSharedPtr<SWidget> Ptr = InWidget;
Expand Down
4 changes: 3 additions & 1 deletion Source/FairyGUI/Public/Event/EventContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ class FAIRYGUI_API UEventContext : public UObject
UFUNCTION(BlueprintCallable, Category = "FairyGUI")
const FVector2D& GetPointerPosition() const
{
return PointerEvent->GetScreenSpacePosition();
achedPointerPosition = PointerEvent->GetScreenSpacePosition();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

最前面漏了一个大写字母C

return CachedPointerPosition;
}

UFUNCTION(BlueprintCallable, Category = "FairyGUI")
Expand Down Expand Up @@ -135,6 +136,7 @@ class FAIRYGUI_API UEventContext : public UObject
bool bDefaultPrevented;
bool bIsMouseCaptor;
FPointerEvent* PointerEvent;
mutable FVector2D CachedPointerPosition;
FKeyEvent* KeyEvent;
int32 ClickCount;
FNVariant Data;
Expand Down
5 changes: 5 additions & 0 deletions Source/FairyGUI/Public/UI/GObjectPool.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ class FGObjectPool : public FGCObject

virtual void AddReferencedObjects(FReferenceCollector& Collector) override;

virtual FString GetReferencerName() const override
{
return TEXT("FGObjectPool");
};

private:
TMap<FString, TArray<UGObject*>> Pool;
};
5 changes: 5 additions & 0 deletions Source/FairyGUI/Public/UI/PackageItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ class FAIRYGUI_API FPackageItem : public FGCObject, public TSharedFromThis<FPack

virtual void AddReferencedObjects(FReferenceCollector& Collector) override;

virtual FString GetReferencerName() const override
{
return TEXT("FPackageItem");
};

public:
UUIPackage* Owner;

Expand Down
5 changes: 5 additions & 0 deletions Source/FairyGUI/Public/Widgets/BitmapFont.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,10 @@ struct FAIRYGUI_API FBitmapFont : public FGCObject

UNTexture* Texture;

virtual FString GetReferencerName() const override
{
return TEXT("BitmapFont");
};

virtual void AddReferencedObjects(FReferenceCollector& Collector) override;
};
4 changes: 2 additions & 2 deletions Source/FairyGUI/Public/Widgets/BitmapFontRun.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ class FAIRYGUI_API FBitmapFontRun : public ISlateRun, public TSharedFromThis< FB

virtual TSharedRef< ILayoutBlock > CreateBlock(int32 StartIndex, int32 EndIndex, FVector2D Size, const FLayoutBlockTextContext& TextContext, const TSharedPtr< IRunRenderer >& Renderer) override;

virtual int32 OnPaint(const FPaintArgs& Args, const FTextLayout::FLineView& Line, const TSharedRef< ILayoutBlock >& Block, const FTextBlockStyle& DefaultStyle, const FGeometry& AllottedGeometry, const FSlateRect& MyCullingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled) const override;

virtual int32 OnPaint(const FPaintArgs& PaintArgs, const FTextArgs& TextArgs, const FGeometry& AllottedGeometry, const FSlateRect& MyCullingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled) const override;
virtual const TArray< TSharedRef<SWidget> >& GetChildren() override;

virtual void ArrangeChildren(const TSharedRef< ILayoutBlock >& Block, const FGeometry& AllottedGeometry, FArrangedChildren& ArrangedChildren) const override;
Expand Down
7 changes: 6 additions & 1 deletion Source/FairyGUI/Public/Widgets/LoaderRun.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class FAIRYGUI_API FLoaderRun : public ISlateRun, public TSharedFromThis< FLoade

virtual TSharedRef< ILayoutBlock > CreateBlock(int32 StartIndex, int32 EndIndex, FVector2D Size, const FLayoutBlockTextContext& TextContext, const TSharedPtr< IRunRenderer >& Renderer) override;

virtual int32 OnPaint(const FPaintArgs& Args, const FTextLayout::FLineView& Line, const TSharedRef< ILayoutBlock >& Block, const FTextBlockStyle& DefaultStyle, const FGeometry& AllottedGeometry, const FSlateRect& MyCullingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled) const override;
virtual int32 OnPaint(const FPaintArgs& PaintArgs, const FTextArgs& TextArgs, const FGeometry& AllottedGeometry, const FSlateRect& MyCullingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled) const override;

virtual const TArray< TSharedRef<SWidget> >& GetChildren() override;

Expand All @@ -55,6 +55,11 @@ class FAIRYGUI_API FLoaderRun : public ISlateRun, public TSharedFromThis< FLoade

virtual void AddReferencedObjects(FReferenceCollector& Collector) override;

virtual FString GetReferencerName() const override
{
return TEXT("FLoaderRun");
};

protected:
FLoaderRun(UFairyApplication* App, const FHTMLElement& HTMLElement, const TSharedRef< const FString >& InText, const FTextRange& InRange);

Expand Down
5 changes: 5 additions & 0 deletions Source/FairyGUI/Public/Widgets/NGraphics.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ class FAIRYGUI_API FNGraphics : public FGCObject

virtual void AddReferencedObjects(FReferenceCollector& Collector) override;

virtual FString GetReferencerName() const override
{
return TEXT("FNGraphics");
};

private:
void UpdateMeshNow();

Expand Down
Loading