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

fix: Fixed the SML Item tooltip. #304

Merged
merged 1 commit into from
Nov 8, 2024
Merged
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
6 changes: 5 additions & 1 deletion Mods/SML/Source/SML/Private/Tooltip/ItemTooltipSubsystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "Patching/BlueprintHookHelper.h"
#include "Patching/BlueprintHookManager.h"
#include "Components/TextBlock.h"
#include "Components/VerticalBox.h"
#include "Components/PanelWidget.h"
#include "Engine/Engine.h"
#include "Engine/GameInstance.h"
Expand All @@ -18,11 +19,14 @@ void UItemTooltipSubsystem::ApplyItemOverridesToTooltip(UWidget* TooltipWidget,
FObjectProperty* DescriptionWidgetProperty = CastField<FObjectProperty>(TooltipWidgetClass->FindPropertyByName(TEXT("mDescription")));
check(TitleWidgetProperty && DescriptionWidgetProperty);


//Retrieve references to some stuff
UTextBlock* NameBlock = Cast<UTextBlock>(TitleWidgetProperty->GetObjectPropertyValue_InContainer(TooltipWidget));
UTextBlock* DescriptionBlock = Cast<UTextBlock>(DescriptionWidgetProperty->GetObjectPropertyValue_InContainer(TooltipWidget));
//Retrieve parent panel, it will hold name, description and recipe blocks
UPanelWidget* ParentPanel = NameBlock->GetParent();
UVerticalBox* VerticalBoxPanel = Cast<UVerticalBox>(DescriptionBlock->GetParent());
check(VerticalBoxPanel);

//Spawn custom widget in parent panel and add it
UItemStackContextWidget* ContextWidget = NewObject<UItemStackContextWidget>(ParentPanel);
Expand All @@ -38,7 +42,7 @@ void UItemTooltipSubsystem::ApplyItemOverridesToTooltip(UWidget* TooltipWidget,
//Append custom widgets to description
TArray<UWidget*> Widgets = CreateDescriptionWidgets(OwningPlayer, InventoryStack);
for (UWidget* Widget : Widgets) {
ParentPanel->AddChild(Widget);
VerticalBoxPanel->AddChild(Widget);
}
}

Expand Down
Loading