Level 2 #12

Merged
oleg.petruny merged 14 commits from Level2 into master 2025-04-25 21:17:42 +00:00
17 changed files with 61 additions and 19 deletions
Showing only changes of commit a7dcb72a2f - Show all commits

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -19,6 +19,15 @@ bool UCommonFunctions::IsNonGameObject(UObject* object)
return false;
}
bool UCommonFunctions::InEditor()
{
#if WITH_EDITOR
return true;
#else
return false;
#endif
}
FText UCommonFunctions::GetKeyDisplayName(FKey key)
{
if(key == EKeys::MouseWheelAxis)
@ -186,6 +195,11 @@ bool UCommonFunctions::ColorEquals(const FColor a, const FColor b)
return a == b;
}
bool UCommonFunctions::FloatIsZero(const float a)
{
return a > -UE_KINDA_SMALL_NUMBER && a < UE_KINDA_SMALL_NUMBER;
}
uint8& UCommonFunctions::ByteIncerement(uint8& var)
{
return ++var;

View File

@ -40,6 +40,9 @@ public:
/** Returns true if the object is UE class template (used for copy/archetype/meta system but not on the level) */
UFUNCTION(BlueprintPure)
static bool IsNonGameObject(class UObject* object);
/** Returns true if the game is in the editor */
UFUNCTION(BlueprintPure)
static bool InEditor();
/** "Overload" of the built-in keys translator (to not build own engine copy) */
UFUNCTION(BlueprintPure)
@ -97,6 +100,8 @@ public:
UFUNCTION(BlueprintCallable, Category = "Byte|Operators", meta = (DisplayName = "Increment", CompactNodeTitle = "++"))
static UPARAM(ref) uint8& ByteIncerement(UPARAM(ref) uint8& var);
UFUNCTION(BlueprintPure, Category = "Float|Operators", meta = (DisplayName = "IsZero", CompactNodeTitle = "== 0"))
static bool FloatIsZero(const float a);
UFUNCTION(BlueprintPure, Category = String)

View File

@ -18,7 +18,7 @@ TSet<TSoftObjectPtr<UInputMappingContext>> ACustomPlayerController::contextsBefo
void ACustomPlayerController::AppendInputContext(TSoftObjectPtr<class UInputMappingContext> context)
{
if(!context.IsValid() || contexts.Contains(context) || contextsBeforeInit.Contains(context))
if(context.IsNull() || contexts.Contains(context) || contextsBeforeInit.Contains(context))
return;
if(!UCustomGameInstance::Get()) //game settings not initialized yet

View File

@ -67,14 +67,17 @@ void UCutsceneManager::SkipSequence()
sequencePlayer->GoToEndAndStop();
}
void UCutsceneManager::ClearQueue()
void UCutsceneManager::Clear()
{
FScopeLock lock1(&sequencesLock);
FScopeLock lock2(&callbacksLock);
if(sequencePlayer)
sequencePlayer->OnStop.Clear();
if(!nextSequences.IsEmpty())
nextSequences.Empty();
if(!endCallbacks.IsEmpty())
endCallbacks.Empty();
holding = false;
}
void UCutsceneManager::LockCallback(bool lock)

View File

@ -23,7 +23,7 @@ public:
void SkipSequence();
UFUNCTION(BlueprintCallable)
void ClearQueue();
void Clear();
UFUNCTION(BlueprintCallable)
void LockCallback(bool lock);

View File

@ -303,8 +303,12 @@ TArray<FIntPoint> UGraphicsSettingsHelper::FilterResolutionsViaAspectRatio(const
TArray<FIntPoint> result;
for(FIntPoint i : resolutions)
if(i.X % aspectRatio.X == 0 && i.Y % aspectRatio.Y == 0)
{
float resRatio = static_cast<float>(i.X) / i.Y;
float aspRatio = static_cast<float>(aspectRatio.X) / aspectRatio.Y;
if(UCommonFunctions::FloatIsZero(resRatio - aspRatio))
result.Add(i);
}
return MoveTemp(result);
}
@ -395,10 +399,7 @@ TArray<FIntPoint> UGraphicsSettingsHelper::GetAvailableAspectRatiousOfMonitor(co
TSet<FIntPoint> aspects;
for(auto& i : resolutions)
{
aspects.Add(GetAspectRatioFromResolution(i));
UE_LOG(LogTemp, Log, TEXT("%dx%d = %dx%d"), i.X, i.Y, GetAspectRatioFromResolution(i).X, GetAspectRatioFromResolution(i).Y);
}
aspects.Add(GetAspectRatioFromResolution(GetResolution(nullptr)));
TArray<FIntPoint> result = aspects.Array();

View File

@ -37,7 +37,7 @@ void AMainGameModeBase::StartPlay()
void AMainGameModeBase::EndPlay(const EEndPlayReason::Type EndPlayReason)
{
cutsceneManager->LockCallback(true);
//cutsceneManager->ClearQueue(); // condition race segfault?
cutsceneManager->Clear();
leadLevel.Reset();
widgetsManager.Reset();
cutsceneManager.Reset();

View File

@ -0,0 +1,8 @@
#include "CutsceneSkipWidget.h"
void UCutsceneSkipWidget::SetVisibility(ESlateVisibility InVisibility)
{
if(InVisibility == ESlateVisibility::Hidden)
RunAnimation(EInputAnimatedWidgetAnimation::Reset);
Super::SetVisibility(InVisibility);
}

View File

@ -15,6 +15,8 @@ class UCutsceneSkipWidget : public UResolutionResponsiveWidget, public IInputAni
GENERATED_BODY()
public:
virtual void SetVisibility(ESlateVisibility InVisibility) override;
FSkipCutsceneDelegate skipCutsceneDelegate;
UPROPERTY(meta = (BindWidget))

View File

@ -9,6 +9,7 @@
UENUM(BlueprintType)
enum class EInputAnimatedWidgetAnimation : uint8
{
Reset,
Click,
Hold,
Unhold,
@ -27,6 +28,8 @@ class IInputAnimatedWidgetInterface
GENERATED_BODY()
public:
UFUNCTION(BlueprintImplementableEvent, BlueprintCallable, Category = "InputAnimatedWidget")
void OnReset();
UFUNCTION(BlueprintImplementableEvent, BlueprintCallable, Category = "InputAnimatedWidget")
void OnClick();
UFUNCTION(BlueprintImplementableEvent, BlueprintCallable, Category = "InputAnimatedWidget")
@ -43,6 +46,9 @@ public:
{
switch(animation)
{
case EInputAnimatedWidgetAnimation::Reset:
Execute_OnReset(this->_getUObject());
break;
case EInputAnimatedWidgetAnimation::Click:
Execute_OnClick(this->_getUObject());
break;

View File

@ -22,7 +22,7 @@ void UInteractableHintWidgetManager::Append(const UInteractableModificator* modi
return;
}
if(hintsMap.Contains(modificator) || !modificator->GetMappingContext().IsValid())
if(hintsMap.Contains(modificator) || modificator->GetMappingContext().IsNull())
return;
const auto& mappings = modificator->GetMappingContext().LoadSynchronous()->GetMappings();