review apply

This commit is contained in:
Oleg Petruny 2025-07-16 12:12:43 +02:00
parent 107e750d02
commit c76281f672
47 changed files with 163 additions and 95 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -55,6 +55,17 @@ int32 UCommonFunctions::StringIndexInTextArray(const TArray<FText>& array, const
return -1;
}
int32 UCommonFunctions::SubstringCount(const FString& in, const FString& substr)
{
int32 result = 0;
int32 i = -1;
while((i = in.Find(substr, ESearchCase::Type::CaseSensitive, ESearchDir::Type::FromStart, i + 1)) != INDEX_NONE)
++result;
return result;
}
void UCommonFunctions::DestroyActorRecursively(AActor* actor)
{
TArray<AActor*> childs;

View File

@ -53,6 +53,8 @@ public:
UFUNCTION(BlueprintPure)
static int32 StringIndexInTextArray(const TArray<FText>& array, const FString& value);
UFUNCTION(BlueprintPure)
static int32 SubstringCount(const FString& in, const FString& substr);
/** Recursively destroy actor and all its childs (the default Destroy doesn't have consistent behavior) */
UFUNCTION(BlueprintCallable, Category = Actor)

View File

@ -116,11 +116,7 @@ void UGraphicsSettingsHelper::CenterWindowPosition(UCustomGameSettings* settings
return;
FIntPoint position;
if(GetDisplayMode(settings) == EDisplayMode::Fullscreen)
{
position = { 0, 0 };
}
else
if(GetDisplayMode(settings) == EDisplayMode::Windowed)
{
auto monitors = GetAvailableMonitors();
int32 monitorId = GetMonitorId(settings);
@ -132,6 +128,10 @@ void UGraphicsSettingsHelper::CenterWindowPosition(UCustomGameSettings* settings
FIntPoint window = GetResolution(settings);
position = { offset + (monitor.X - window.X) / 2, (monitor.Y - window.Y) / 2 };
}
else
{
position = { 0, 0 };
}
SetWindowPosition(settings, position);
}

View File

@ -61,4 +61,6 @@ void AMinigame::EndPlay(const EEndPlayReason::Type EndPlayReason)
{
if(instance == this)
instance = nullptr;
Super::EndPlay(EndPlayReason);
}

View File

@ -348,30 +348,7 @@ void APlayerBase::ShowJournal()
void APlayerBase::ShowMenu()
{
if(auto WM = AMainGameModeBase::GetWidgetsManager())
{
if(GetWorld()->IsPaused())
{
WM->HideMainMenu();
if(auto PC = ACustomPlayerController::Get())
{
PC->SetShowMouseCursor(false);
PC->SetInputMode(FInputModeGameOnly{});
}
UnlockPlayer(FPlayerLock::All());
UGameplayStatics::SetGamePaused(GetWorld(), false);
}
else
{
WM->ShowMainMenu();
if(auto PC = ACustomPlayerController::Get())
{
PC->SetShowMouseCursor(true);
PC->SetInputMode(FInputModeGameAndUI{});
}
LockPlayer(FPlayerLock::All());
UGameplayStatics::SetGamePaused(GetWorld(), true);
}
}
WM->MenuCall();
}
FPlayerLock FPlayerLock::All()

View File

@ -9,6 +9,11 @@
#include "MainMenuButtonWidget.h"
#include "Widgets/WidgetsManager.h"
namespace
{
constexpr float userCallDelaySeconds = 0.1f;
}
bool UMainMenuWidget::Initialize()
{
//FWidgetAnimationDynamicEvent closeFinished;
@ -18,6 +23,25 @@ bool UMainMenuWidget::Initialize()
return UUserWidget::Initialize();
}
void UMainMenuWidget::UserCall()
{
float time = GetWorld()->GetRealTimeSeconds();
if(time - userCallTimeStamp < userCallDelaySeconds)
return;
userCallTimeStamp = time;
if(Visibility == ESlateVisibility::Hidden)
{
if(auto GM = AMainGameModeBase::Get())
if(auto WM = GM->GetWidgetsManager())
WM->ShowMainMenu(true);
}
else
{
OnUserCall();
}
}
void UMainMenuWidget::Show(bool fast)
{
SetVisibility(ESlateVisibility::Visible);

View File

@ -18,6 +18,9 @@ class UMainMenuWidget : public UUserWidget
public:
virtual bool Initialize() override;
void UserCall();
UFUNCTION(BlueprintImplementableEvent)
void OnUserCall();
UFUNCTION(BlueprintCallable)
void Show(bool fast = true);
UFUNCTION(BlueprintCallable)
@ -38,4 +41,7 @@ public:
protected:
UFUNCTION()
void Closed();
private:
float userCallTimeStamp = 0;
};

View File

@ -11,6 +11,7 @@
#include "CustomGameInstance.h"
#include "CustomGameSettings.h"
#include "CustomPlayerController.h"
#include "Interactable/Interactable.h"
#include "Interactable/Modificators/InteractableModificator.h"
#include "Interactable/Modificators/InventoryInteractableModificator.h"
@ -165,8 +166,24 @@ void UWidgetsManager::RemoveOverlayWidget(UUserWidget* widget)
void UWidgetsManager::MenuCall()
{
mainMenuWidget->UserCall();
}
void UWidgetsManager::ShowMainMenu(bool pause)
{
if(auto PC = ACustomPlayerController::Get())
{
PC->SetShowMouseCursor(true);
PC->SetInputMode(FInputModeGameAndUI{});
}
if(auto p = APlayerBase::Get())
{
p->LockPlayer(FPlayerLock::All());
}
UGameplayStatics::SetGamePaused(GetWorld(), true);
mainMenuWidget->Show(pause);
HideJournal();
HideCheatMenu();
@ -174,6 +191,17 @@ void UWidgetsManager::ShowMainMenu(bool pause)
void UWidgetsManager::HideMainMenu()
{
if(auto PC = ACustomPlayerController::Get())
{
PC->SetShowMouseCursor(false);
PC->SetInputMode(FInputModeGameOnly{});
}
if(auto p = APlayerBase::Get())
{
p->UnlockPlayer(FPlayerLock::All());
}
UGameplayStatics::SetGamePaused(GetWorld(), false);
mainMenuWidget->Hide();
}

View File

@ -32,7 +32,10 @@ public:
UFUNCTION(BlueprintCallable, Category = WidgetsManager)
void RemoveOverlayWidget(class UUserWidget* widget);
void MenuCall();
UFUNCTION(BlueprintCallable, Category = WidgetsManager)
void ShowMainMenu(bool pause = true);
UFUNCTION(BlueprintCallable, Category = WidgetsManager)
void HideMainMenu();
UFUNCTION(BlueprintCallable, Category = WidgetsManager)