๐
2025-09-18
GAB_ShowWidget_WhenInputPressed// ์ด๋น๋ฆฌํฐ์์ PushContentToLayerForPlayer ์ฌ์ฉ
// AfterPush์์ ์์ ฏ ๋นํ์ฑํ ์ด๋ฒคํธ ๋ฐ์ธ๋ฉ
W_LyraGameMenuDT_UniversalActionsIs Back Handler๋ง ์ฒดํฌIs Back Action Displayed in Action Bar๋ ์ฒดํฌ โ Escape Menu์ ์์ ฏ ์ถ๊ฐ// Event Construct์์ ์ฒ๋ฆฌ (์์ ฏ์ด ๋งค๋ฒ ์๋ก ์์ฑ๋๋ฏ๋ก)
void UInventoryWidget::NativeConstruct()
{
Super::NativeConstruct();
// ์ ์ฒด ์์ดํ
๊ฐ์ ธ์ค๊ธฐ
RefreshInventoryGrid();
}
void RefreshInventoryGrid()
{
// ์ฅ์ฐฉ ์ค์ด ์๋ ์์ดํ
๋ง ํ์
for (const auto& Item : AllItems)
{
if (!Item.bIsEquipped)
{
InventoryTileView->AddItem(Item);
}
}
}
bool bIsEquipped ๋ณ์ ์ถ๊ฐ// UDragDropOperation ์์ ํด๋์ค ๊ตฌํ
class UItemDragDropOperation : public UDragDropOperation
{
UPROPERTY()
FInventoryItem ItemData;
UPROPERTY()
ESlotType SourceSlotType;
};
// ๋๋๊ทธ ๊ฐ์ง
FReply OnMouseButtonDown() override
{
return FReply::Handled().DetectDrag(SharedThis(this), EKeys::LeftMouseButton);
}
// ๋๋๊ทธ ์์
void OnDragDetected(const FPointerEvent& PointerEvent, UDragDropOperation*& Operation) override
{
UItemDragDropOperation* DragOp = NewObject<UItemDragDropOperation>();
DragOp->ItemData = MyItemData;
Operation = DragOp;
}
// ๋๋กญ ์ฒ๋ฆฌ
bool OnDrop(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent, UDragDropOperation* Operation) override
{
// ๋๋กญ ๋ก์ง ์ฒ๋ฆฌ
return true;
}
// ์คํฌ ์ฌ๋กฏ๊ณผ ์ ์ฌํ ๊ตฌ์กฐ
class UEquipmentSlotWidget : public UUserWidget
{
UPROPERTY(EditAnywhere, BlueprintReadOnly)
EEquipmentSlotType SlotType; // Helmet, Armor, Weapon ๋ฑ
UPROPERTY()
FInventoryItem CurrentEquippedItem;
};
UENUM(BlueprintType)
enum class EEquipmentSlotType : uint8
{
None,
Helmet,
Armor,
MainHand,
OffHand,
// ...
};
sequenceDiagram
participant I as ์ธ๋ฒคํ ๋ฆฌ UI
participant E as ์ฅ๋น์ฐฝ UI
participant EC as Equipment Component
participant Other as ๊ธฐํ UI๋ค
I->>E: 1. ๋๋๊ทธ ์ค ๋๋กญ
E->>E: 2. ์ฅ๋น ๋ณ๊ฒฝ ์ด๋ฒคํธ ๋ธ๋ก๋์บ์คํธ
E->>EC: 3. Equipment Component๊ฐ ์ด๋ฒคํธ ์์
EC->>EC: 4. ์ค์ ์ฅ์ฐฉ ์ฒ๋ฆฌ
EC->>Other: 5. ์ฅ๋น ๋ณ๊ฒฝ ์๋ฃ ๋ธ๋ก๋์บ์คํธ
Other->>I: 6. ์ธ๋ฒคํ ๋ฆฌ UI ๊ฐฑ์
Other->>E: 7. ์ฅ๋น์ฐฝ UI ๊ฐฑ์
Other->>Other: 8. ์คํฏ UI ๊ฐฑ์
// 1. ๋๋๊ทธ ์ค ๋๋กญ ์๋ฃ ์
bool UEquipmentSlotWidget::OnDrop(UDragDropOperation* Operation)
{
// 2. ์ฅ๋น ๋ณ๊ฒฝ ์์ฒญ ์ด๋ฒคํธ ๋ธ๋ก๋์บ์คํธ
OnEquipmentChangeRequested.Broadcast(ItemData, MySlotType);
return true;
}
// 3. Equipment Component์์ ์ด๋ฒคํธ ์์
void UEquipmentComponent::HandleEquipmentChangeRequest(const FInventoryItem& Item, EEquipmentSlotType SlotType)
{
// 4. ์ค์ ์ฅ์ฐฉ ์ฒ๋ฆฌ
EquipItem(Item, SlotType);
// 5. ์ฅ๋น ๋ณ๊ฒฝ ์๋ฃ ๋ธ๋ก๋์บ์คํธ
OnEquipmentChanged.Broadcast(SlotType, Item);
}
// 6-8. ๊ฐ UI๋ค์์ ๊ฐฑ์ ์ฒ๋ฆฌ
void UInventoryWidget::OnEquipmentChanged()
{
RefreshInventoryGrid(); // ์ฅ์ฐฉ๋ ์์ดํ
ํํฐ๋ง
}
void UEquipmentScreenWidget::OnEquipmentChanged()
{
RefreshEquipmentSlots(); // ์ฅ๋น ์ฌ๋กฏ ์
๋ฐ์ดํธ
}
void UStatsWidget::OnEquipmentChanged()
{
UpdateCharacterStats(); // ์คํฏ ์ฌ๊ณ์ฐ
}
NativeConstruct์์ ์ด๊ธฐํCommonUI์ Universal Actions ๊ฐ์ ์ธ๋ฆฌ์ผ์ ๊ธฐ๋ณธ ์์คํ
๋ค์ด ์๊ฐ๋ณด๋ค ๊ฐ๋ ฅํ๋ค๋ ๊ฑธ
๊นจ๋ฌ์๋ค. ์ง์ ๊ตฌํํ๋ ค๊ณ ํ๋ ESC ์ฒ๋ฆฌ๋ ๋ ์ด์ด ๊ด๋ฆฌ ๊ฐ์ ๊ฒ๋ค์ด ์ด๋ฏธ ์ ๋ง๋ค์ด์ง
์์คํ
์ผ๋ก ์ ๊ณต๋๊ณ ์์๋ค. ๋ผ์ด๋ผ ํ๋ก์ ํธ๋ฅผ ๋ ์์ธํ ๋ฏ์ด๋ด์ผ๊ฒ ๋ค.