A Demo Project for the UnrealEngineSDK
Loading...
Searching...
No Matches
DialogueBrowserUtilities.h
Go to the documentation of this file.
1// Copyright Csaba Molnar, Daniel Butum. All Rights Reserved.
2#pragma once
3
4#include "CoreMinimal.h"
5
8
9enum class EDialogueBrowserSortOption : uint8
10{
11 Name = 0,
13};
14
16{
17
18public:
20 : Option(InOption), Name(InName) {}
21
22 FName GetFName() const { return Name; }
23 FText GetFText() const { return FText::FromName(Name); }
24 FString GetFString() const { return Name.ToString(); }
25
27
28public:
30
31 // The name of the option.
32 FName Name;
33
34 // TODO add ascending descending
35};
36
38{
39public:
40 // Compare two FDialogueBrowserTreeNode
42 const TSharedPtr<FDialogueBrowserTreeNode>& FirstNode,
43 const TSharedPtr<FDialogueBrowserTreeNode> SecondNode
44 )
45 {
46 check(FirstNode.IsValid());
47 check(SecondNode.IsValid());
48 return *FirstNode == *SecondNode;
49 }
50
51 // Predicate that sorts participants by dialogue number references, in descending order.
53 FName FirstParticipant,
54 FName SecondParticipant,
55 const TMap<FName, TSharedPtr<FDialogueBrowserTreeParticipantProperties>>& ParticipantsProperties
56 )
57 {
58 int32 FirstNum = 0;
59 int32 SecondNum = 0;
60
61 const TSharedPtr<FDialogueBrowserTreeParticipantProperties>* FirstPtr =
62 ParticipantsProperties.Find(FirstParticipant);
63 if (FirstPtr)
64 {
65 FirstNum = (*FirstPtr)->GetDialogues().Num();
66 }
67 const TSharedPtr<FDialogueBrowserTreeParticipantProperties>* SecondPtr =
68 ParticipantsProperties.Find(SecondParticipant);
69 if (SecondPtr)
70 {
71 SecondNum = (*SecondPtr)->GetDialogues().Num();
72 }
73
74 return FirstNum > SecondNum;
75 }
76};
EDialogueBrowserSortOption
static bool PredicateSortByDialoguesNumDescending(FName FirstParticipant, FName SecondParticipant, const TMap< FName, TSharedPtr< FDialogueBrowserTreeParticipantProperties > > &ParticipantsProperties)
static bool PredicateCompareDialogueTreeNode(const TSharedPtr< FDialogueBrowserTreeNode > &FirstNode, const TSharedPtr< FDialogueBrowserTreeNode > SecondNode)
FDialogueBrowserSortOption(EDialogueBrowserSortOption InOption, FName InName)
EDialogueBrowserSortOption Option