bug fixes

This commit is contained in:
Oleg Petruny 2024-08-09 14:39:21 +02:00
parent c2ada5cb47
commit 449d943948
19 changed files with 140 additions and 8 deletions

Binary file not shown.

Binary file not shown.

View File

@ -28,7 +28,7 @@ UClass* UContentLoader::MountAndRegisterPak(FString pakFilePath)
TArray<FString> content;
FString mountPoint = GetPakMountContentPath(pakFilePath, content);
//RegisterMountPoint("/Game/", mountPoint);
RegisterMountPoint(mountPath, mountPoint);
GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Yellow, FString::Printf(TEXT("ContentLoader: Pak '%s' contains %d items"), *FPaths::GetCleanFilename(pakFilePath), content.Num()));
UE_LOG(LogTemp, Log, TEXT("ContentLoader: Pak '%s' contains %d items"), *FPaths::GetCleanFilename(pakFilePath), content.Num());
@ -48,10 +48,13 @@ UClass* UContentLoader::MountAndRegisterPak(FString pakFilePath)
void UContentLoader::BeginDestroy()
{
while(mountedFiles.Num() > 0)
UnmountPak(*mountedFiles.begin());
if(mountedFiles.Num() > 0)
{
while(mountedFiles.Num() > 0)
UnmountPak(*mountedFiles.begin());
FPlatformFileManager::Get().RemovePlatformFile(GetPakPlatformFile());
FPlatformFileManager::Get().RemovePlatformFile(GetPakPlatformFile());
}
UObject::BeginDestroy();
}
@ -202,10 +205,10 @@ FString UContentLoader::GetPakMountContentPath(const FString& pakFilePath, TArra
UClass* UContentLoader::LoadPakObjClassReference(const FString& pakContentPath)
{
FString assetName = FString::Printf(TEXT("/Game/%s.%s_C"), *FPaths::GetBaseFilename(pakContentPath, false), *FPaths::GetBaseFilename(pakContentPath, true));
FString assetName = FString::Printf(TEXT("%s/%s.%s_C"), mountPath, *FPaths::GetBaseFilename(pakContentPath, false), *FPaths::GetBaseFilename(pakContentPath, true));
GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Yellow, FString::Printf(TEXT("ContentLoader: Loading '%s' class"), *assetName));
UE_LOG(LogTemp, Log, TEXT("ContentLoader: Loading '%s' class"), *assetName);
return StaticLoadClass(UObject::StaticClass(), nullptr, *assetName);
return nullptr;//StaticLoadClass(UObject::StaticClass(), nullptr, *assetName);
}

View File

@ -50,6 +50,14 @@ UCustomGameInstanceBase* UCustomGameInstanceBase::GetGameInstance()
return instance;
}
UContentLoader* UCustomGameInstanceBase::GetContentLoader()
{
if(auto GI = GetGameInstance())
return GI->contentLoader;
return nullptr;
}
void UCustomGameInstanceBase::ApplyMouseSettings()
{
if(auto gameSettings = UCustomGameUserSettings::GetCustomGameUserSettings())

View File

@ -19,6 +19,9 @@ public:
UFUNCTION(BlueprintPure)
static UCustomGameInstanceBase* GetGameInstance();
UFUNCTION(BlueprintPure)
static class UContentLoader* GetContentLoader();
UFUNCTION(BlueprintCallable, Category = Settings)
void ApplyMouseSettings();

View File

@ -0,0 +1,64 @@
// Oleg Petruny proprietary.
#include "AdvanceButton.h"
#include "Components/ButtonSlot.h"
//FReply SAdvanceButton::OnMouseMove(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
//{
// if(!hitboxTexture)
// return SButton::OnMouseMove(MyGeometry, MouseEvent);
//
// FVector2D locPos = MyGeometry.AbsoluteToLocal(MouseEvent.GetScreenSpacePosition());
// locPos /= MyGeometry.GetLocalSize();
// int width = hitboxTexture->GetPlatformData()->SizeX;
// locPos.X *= width;
// locPos.Y *= hitboxTexture->GetPlatformData()->SizeY;
// long pixelIndex = (locPos.Y * width) + locPos.X;
//
// FColor* imageData = static_cast<FColor*>((hitboxTexture->GetPlatformData()->Mips[0]).BulkData.Lock(LOCK_READ_ONLY));
// bool hovered = imageData && imageData[pixelIndex].A <= hitboxTextureAlphaThreshold;
// hitboxTexture->GetPlatformData()->Mips[0].BulkData.Unlock();
//
// if(hovered != bIsHovered)
// {
// bIsHovered = hovered;
// if(bIsHovered)
// SButton::OnMouseEnter(MyGeometry, MouseEvent);
// else
// SButton::OnMouseLeave(MouseEvent);
// }
//
// return SButton::OnMouseMove(MyGeometry, MouseEvent);
//}
//
//void UAdvanceButton::SynchronizeProperties()
//{
// Super::SynchronizeProperties();
// (static_cast<SAdvanceButton*>(MyButton.Get()))->hitboxTexture = hitboxTexture;
// (static_cast<SAdvanceButton*>(MyButton.Get()))->hitboxTextureAlphaThreshold = hitboxTextureAlphaThreshold;
//}
//
//TSharedRef<SWidget> UAdvanceButton::RebuildWidget()
//{
// TSharedPtr<SAdvanceButton> advanceButton = SNew(SAdvanceButton)
// .OnClicked(BIND_UOBJECT_DELEGATE(FOnClicked, SlateHandleClicked))
// .OnPressed(BIND_UOBJECT_DELEGATE(FSimpleDelegate, SlateHandlePressed))
// .OnReleased(BIND_UOBJECT_DELEGATE(FSimpleDelegate, SlateHandleReleased))
// .OnHovered_UObject(this, &ThisClass::SlateHandleHovered)
// .OnUnhovered_UObject(this, &ThisClass::SlateHandleUnhovered)
// .ButtonStyle(&WidgetStyle)
// .ClickMethod(ClickMethod)
// .TouchMethod(TouchMethod)
// .IsFocusable(IsFocusable);
//
// advanceButton->hitboxTexture = hitboxTexture;
// advanceButton->hitboxTextureAlphaThreshold = hitboxTextureAlphaThreshold;
// MyButton = advanceButton;
//
// if(GetChildrenCount() > 0)
// Cast<UButtonSlot>(GetContentSlot())->BuildSlot(MyButton.ToSharedRef());
//
// return MyButton.ToSharedRef();
//}

View File

@ -0,0 +1,51 @@
// Oleg Petruny proprietary.
#pragma once
#include "Components/Button.h"
#include "AdvanceButton.generated.h"
class SAdvanceButton : public SButton
{
public:
//virtual FReply OnMouseButtonDown(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override
//{
// if(!bIsHovered) return FReply::Unhandled();
// return SButton::OnMouseButtonDown(MyGeometry, MouseEvent);
//}
//virtual FReply OnMouseButtonDoubleClick(const FGeometry& InMyGeometry, const FPointerEvent& InMouseEvent) override
//{
// if(!bIsHovered) return FReply::Unhandled();
// return SButton::OnMouseButtonDoubleClick(InMyGeometry, InMouseEvent);
//}
//virtual FReply OnMouseMove(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override;
//virtual void OnMouseEnter(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent) override
//{
// if(hitboxTexture) return;
// return SButton::OnMouseEnter(MyGeometry, MouseEvent);
//}
//virtual TSharedPtr<IToolTip> GetToolTip() override
//{
// return (bIsHovered ? SWidget::GetToolTip() : nullptr);
//}
//
//UTexture2D* hitboxTexture = nullptr;
//uint8 hitboxTextureAlphaThreshold = 0;
};
UCLASS()
class UAdvanceButton : public UButton
{
GENERATED_BODY()
//
//public:
// virtual void SynchronizeProperties() override;
// virtual TSharedRef<SWidget> RebuildWidget() override;
//
// UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "AdvanceButton")
// UTexture2D* hitboxTexture = nullptr;
//
// UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "AdvanceButton", meta = (ClampMin = "0.0", ClampMax = "255.0", UIMin = "0.0", UIMax = "255.0"))
// int hitboxTextureAlphaThreshold = 0;
};

View File

@ -17,7 +17,7 @@ void UInteractableHintWidgetManager::Append(const UInteractableModificator* modi
{
FScopeLock Lock(&hintsLock);
if(!modificator)
if(!IsValid(modificator))
{
hints->SetVisibility(ESlateVisibility::Visible);
return;
@ -57,7 +57,7 @@ void UInteractableHintWidgetManager::Remove(const UInteractableModificator* modi
{
FScopeLock Lock(&hintsLock);
if(!modificator)
if(!IsValid(modificator))
{
hints->SetVisibility(ESlateVisibility::Hidden);
return;