Skip to content

Commit

Permalink
This is everything with the default way for tooltip and drag visual, …
Browse files Browse the repository at this point in the history
…no custom code
  • Loading branch information
SrujanLokhande committed Sep 24, 2024
1 parent 334c5f1 commit 358f414
Show file tree
Hide file tree
Showing 16 changed files with 15 additions and 482 deletions.
13 changes: 4 additions & 9 deletions .idea/.idea.InventorySystem/.idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 0 additions & 16 deletions Source/InventorySystem/DataStructure/DS_Line.h

This file was deleted.

15 changes: 0 additions & 15 deletions Source/InventorySystem/DataStructure/DS_Tile.h

This file was deleted.

67 changes: 0 additions & 67 deletions Source/InventorySystem/InventorySystemCharacter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,73 +400,6 @@ void AInventorySystemCharacter::WidgetInteractReleased()
WidgetInteractionComponent->ReleasePointerKey(EKeys::LeftMouseButton);
}

// void AInventorySystemCharacter::CreateUIWidgets()
// {
// if(ToolTipWidgetClass)
// {
// ToolTipWidget = CreateWidget<UInventoryTooltip>(GetWorld(), ToolTipWidgetClass);
// ToolTipWidget->AddToViewport(100);
// ToolTipWidget->IsInViewport() ? GEngine->AddOnScreenDebugMessage(-98, 5.0f, FColor::Black, TEXT("ToolTipWidgetCreated")) : GEngine->AddOnScreenDebugMessage(-98, 5.0f, FColor::Black, TEXT("TollTipWidget not created"));
// ToolTipWidget->SetVisibility(ESlateVisibility::Hidden);
//
// // this is not working so either creae in a similar way like the inetraction widget in the HUD class or add another
// // UWidgetComponent inisd e the Tabelt class and hide and show it based on the interaction
// // either of the avove ways
// }
//
// if(DragVisualClass)
// {
// DragVisualWidget = CreateWidget<UDragItemVisual>(GetWorld(), DragVisualClass);
// DragVisualWidget->AddToViewport(100);
// DragVisualWidget->IsInViewport() ? GEngine->AddOnScreenDebugMessage(-98, 5.0f, FColor::Black, TEXT("DragWidget Created")) : GEngine->AddOnScreenDebugMessage(-98, 5.0f, FColor::Black, TEXT("DragWidget not created"));
// DragVisualWidget->SetVisibility(ESlateVisibility::Hidden);
// }
// }
//
// void AInventorySystemCharacter::UpdateToolTipWidget(const FVector2D& ScreenPosition, UItemBase* ItemIn)
// {
// if(ToolTipWidget)
// {
// UInventoryTooltip* Tooltip = Cast<UInventoryTooltip>(ToolTipWidget);
// if(Tooltip)
// {
// Tooltip->UpdateToolTipContents(ItemIn);
// }
// Tooltip->SetPositionInViewport(ScreenPosition, false);
// ToolTipWidget->SetVisibility(ESlateVisibility::Visible);
// }
// }
//
// void AInventorySystemCharacter::UpdateDragVisualWidget(const FVector2D& ScreenPosition, UItemBase* ItemIn)
// {
// if(DragVisualWidget)
// {
// UDragItemVisual* DragVisual = Cast<UDragItemVisual>(DragVisualWidget);
// if(DragVisual)
// {
// DragVisual->UpdateToolTipContents(ItemIn);
// }
// DragVisual->SetPositionInViewport(ScreenPosition, false);
// DragVisualWidget->SetVisibility(ESlateVisibility::Visible);
// }
// }
//
// void AInventorySystemCharacter::HideToolTipWidget()
// {
// if (ToolTipWidget)
// {
// ToolTipWidget->SetVisibility(ESlateVisibility::Hidden);
// }
// }
//
// void AInventorySystemCharacter::HideDragVisualWidget()
// {
// if (DragVisualWidget)
// {
// DragVisualWidget->SetVisibility(ESlateVisibility::Hidden);
// }
// }

void AInventorySystemCharacter::DropItem(UItemBase* ItemToDrop, const int32 QuantityToDrop)
{
if(PlayerInventory->FindMatchingItem(ItemToDrop))
Expand Down
16 changes: 0 additions & 16 deletions Source/InventorySystem/InventorySystemCharacter.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,6 @@ class AInventorySystemCharacter : public ACharacter

void DropItem(UItemBase* ItemToDrop, const int32 QuantityToDrop);

// Inventory Tablet UI ToolTip and Drag Visual functions
// void UpdateToolTipWidget(const FVector2D& ScreenPosition, UItemBase* ItemIn);
// void UpdateDragVisualWidget(const FVector2D& ScreenPosition, UItemBase* ItemIn);
// void HideToolTipWidget();
// void HideDragVisualWidget();

protected:

//=============================================================================
Expand Down Expand Up @@ -152,16 +146,6 @@ class AInventorySystemCharacter : public ACharacter

UPROPERTY(EditDefaultsOnly, Category = "Character | Tablet")
TSubclassOf<ATablet> TabletClass;

// UPROPERTY()
// UInventoryTooltip* ToolTipWidget;
//
// UPROPERTY()
// UDragItemVisual* DragVisualWidget;
//
// UPROPERTY(EditDefaultsOnly, Category = "Tablet | UI")
// TSubclassOf<UInventoryTooltip> ToolTipWidgetClass;


float InteractionCheckFrequency;

Expand Down
87 changes: 0 additions & 87 deletions Source/InventorySystem/Private/Actors/Tablet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,94 +23,7 @@ ATablet::ATablet()
InventoryWidgetComponent->SetDrawAtDesiredSize(true);
InventoryWidgetComponent->SetWidgetSpace(EWidgetSpace::World);
InventoryWidgetComponent->SetCollisionEnabled(ECollisionEnabled::Type::NoCollision);

// DragVisualComponent = CreateDefaultSubobject<UWidgetComponent>(TEXT("Drag Visual Widget"));
// DragVisualComponent->SetupAttachment(RootComponent);
// //DragVisualComponent->SetVisibility(false);
// DragVisualComponent->SetDrawAtDesiredSize(true);
// DragVisualComponent->SetWidgetSpace(EWidgetSpace::World);
// DragVisualComponent->SetCollisionEnabled(ECollisionEnabled::Type::NoCollision);
}

// Called when the game starts or when spawned
// void ATablet::BeginPlay()
// {
// Super::BeginPlay();
//
// if (InventoryWidgetComponent)
// {
// MainMenuWidgetClass = Cast<UMainMenuWidget>(InventoryWidgetComponent->GetUserWidgetObject());
// if (MainMenuWidgetClass)
// {
// InventoryWidgetClass = MainMenuWidgetClass->GetInventoryWidgetClass();
// InventoryWidgetClass->SetTabletReference(this);
// UE_LOG(LogTemp, Log, TEXT("Tablet: InventoryWidget found and TabletReference set"));
// }
// else
// {
// UE_LOG(LogTemp, Error, TEXT("Tablet: Failed to cast UserWidget to InventoryWidget"));
// }
// }
//
// if (DragVisualComponent)
// {
// DragVisualClass = Cast<UDragItemVisual>(DragVisualComponent->GetUserWidgetObject());
// }
// }
//
// void ATablet::Tick(float DeltaSeconds)
// {
// Super::Tick(DeltaSeconds);
//
// if (DragVisualComponent->IsVisible())
// {
// UpdateDragVisualPosition();
// }
// }
//
// void ATablet::UpdateDragVisualPosition() const
// {
// if (APlayerController* PlayerController = UGameplayStatics::GetPlayerController(this, 0))
// {
// if (FVector2D MousePosition; PlayerController->GetMousePosition(MousePosition.X, MousePosition.Y))
// {
// FVector WorldDirection;
// if (FVector WorldPosition; UGameplayStatics::DeprojectScreenToWorld(PlayerController, MousePosition, WorldPosition, WorldDirection))
// {
// FVector Start = WorldPosition;
// FVector End = WorldPosition + WorldDirection * 1000.0f;
//
// FHitResult HitResult;
// FCollisionQueryParams QueryParams;
// QueryParams.AddIgnoredActor(this);
//
// if (GetWorld()->LineTraceSingleByChannel(HitResult, Start, End, ECC_Visibility, QueryParams))
// {
// DragVisualComponent->SetWorldLocation(HitResult.Location);
// DragVisualComponent->SetWorldRotation(HitResult.Normal.Rotation());
// }
// }
// }
// }
// }
//
// void ATablet::StartItemDrag(UItemBase* ItemToDrag)
// {
// if (DragVisualClass && ItemToDrag)
// {
// DragVisualClass->SetItemReference(ItemToDrag);
// DragVisualComponent->SetVisibility(true);
//
// }
// }
//
// void ATablet::EndItemDrag()
// {
// if (DragVisualComponent)
// {
// DragVisualComponent->SetVisibility(false);
// }
// }



Original file line number Diff line number Diff line change
Expand Up @@ -3,59 +3,5 @@

#include "UserInterface/Inventory/DragItemVisual.h"

#include "Components/Border.h"
#include "Components/Image.h"
#include "Components/TextBlock.h"

// void UDragItemVisual::NativeConstruct()
// {
// Super::NativeConstruct();
//
// SetVisibility(ESlateVisibility::HitTestInvisible);
// SetColorAndOpacity(FLinearColor(1, 1, 1, 1));
// }
//
// void UDragItemVisual::SetItemReference(UItemBase* ItemIn) const
// {
// if (ItemIn && IMG_ItemIcon)
// {
// IMG_ItemIcon->SetBrushFromTexture(ItemIn->AssetData.Icon);
//
// if (ItemBorder)
// {
// // Set border color based on item rarity
// switch (ItemIn->ItemRarity)
// {
// case EItemRarity::Common:
// ItemBorder->SetBrushColor(FLinearColor::White);
// break;
// case EItemRarity::Rare:
// ItemBorder->SetBrushColor(FLinearColor::Blue);
// break;
// case EItemRarity::Epic:
// ItemBorder->SetBrushColor(FLinearColor::Red);
// break;
// case EItemRarity::Legendary:
// ItemBorder->SetBrushColor(FLinearColor::Yellow);
// break;
// default:
// ItemBorder->SetBrushColor(FLinearColor::White);
// }
// }
//
// if (TXT_ItemQuantity)
// {
// if (ItemIn->NumericData.bIsStackable)
// {
// TXT_ItemQuantity->SetText(FText::AsNumber(ItemIn->ItemQuantity));
// TXT_ItemQuantity->SetVisibility(ESlateVisibility::Visible);
// }
// else
// {
// TXT_ItemQuantity->SetVisibility(ESlateVisibility::Collapsed);
// }
// }
// }
// }


Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ void UInventoryItemSlot::NativeOnInitialized()
if(ToolTipClass)
{
UInventoryTooltip* Tooltip = CreateWidget<UInventoryTooltip>(this, ToolTipClass);
Tooltip->InventorySlotBeingHovered = this;
//ToolTipUI->AddToViewport(10);
//ToolTipUI->SetVisibility(ESlateVisibility::Collapsed);
Tooltip->InventorySlotBeingHovered = this;
SetToolTip(Tooltip);
}
}
Expand Down Expand Up @@ -62,18 +60,6 @@ void UInventoryItemSlot::NativeConstruct()
}
}

// void UInventoryItemSlot::SetItemReference(UItemBase* Item)
// {
// ItemReference = Item;
// UpdateSlotVisual();
// }


// void UInventoryItemSlot::SetTabletReference(ATablet* Tablet)
// {
// TabletReference = Tablet;
// }

FReply UInventoryItemSlot::NativeOnMouseButtonDown(const FGeometry& InGeometry, const FPointerEvent& InMouseEvent)
{
FReply Reply = Super::NativeOnMouseButtonDown(InGeometry, InMouseEvent);
Expand Down Expand Up @@ -124,26 +110,9 @@ void UInventoryItemSlot::NativeOnDragDetected(const FGeometry& InGeometry, const
}
}

// void UInventoryItemSlot::NativeOnMouseEnter(const FGeometry& InGeometry, const FPointerEvent& InMouseEvent)
// {
// Super::NativeOnMouseEnter(InGeometry, InMouseEvent);
// OnMouseEnterDelegate.Broadcast(this);
// }

// void UInventoryItemSlot::NativeOnDragCancelled(const FDragDropEvent& InDragDropEvent, UDragDropOperation* InOperation)
// {
// Super::NativeOnDragCancelled(InDragDropEvent, InOperation);
//
// if (TabletReference)
// {
// TabletReference->EndItemDrag();
// }
// }

void UInventoryItemSlot::NativeOnMouseLeave(const FPointerEvent& InMouseEvent)
{
Super::NativeOnMouseLeave(InMouseEvent);
//OnMouseLeaveDelegate.Broadcast(this);
Super::NativeOnMouseLeave(InMouseEvent);
}

bool UInventoryItemSlot::NativeOnDrop(const FGeometry& InGeometry, const FDragDropEvent& InDragDropEvent,
Expand Down
Loading

0 comments on commit 358f414

Please sign in to comment.