|
| 1 | +// All rights reserved Dominik Morse 2024 |
| 2 | + |
| 3 | +#include "InteractionSystemTutorialPage.h" |
| 4 | + |
| 5 | +#include "ContentBrowserModule.h" |
| 6 | +#include "IContentBrowserSingleton.h" |
| 7 | +#include "Widgets/Text/SRichTextBlock.h" |
| 8 | +#include "Widgets/Layout/SScrollBox.h" |
| 9 | +#include "Widgets/Layout/SBorder.h" |
| 10 | +#include "Widgets/Images/SImage.h" |
| 11 | +#include "Widgets/Layout/SBox.h" |
| 12 | +#include "Modules/ModuleManager.h" |
| 13 | +#include "ISettingsModule.h" |
| 14 | + |
| 15 | +void OpenSettingsPage(const FString& SettingsCategory) |
| 16 | +{ |
| 17 | + ISettingsModule& SettingsModule = FModuleManager::LoadModuleChecked<ISettingsModule>("Settings"); |
| 18 | + |
| 19 | + if (SettingsCategory == "Mountea") |
| 20 | + { |
| 21 | + SettingsModule.ShowViewer("Project", TEXT("Mountea Framework"), TEXT("Mountea Interaction System")); |
| 22 | + } |
| 23 | + else if (SettingsCategory == "Collision") |
| 24 | + { |
| 25 | + SettingsModule.ShowViewer("Project", TEXT("Engine"), TEXT("Collision")); |
| 26 | + } |
| 27 | +} |
| 28 | + |
| 29 | +void OpenContentBrowserFolder(const FString& FolderName) |
| 30 | +{ |
| 31 | + FString PluginContentPath = TEXT("/ActorInteractionPlugin/") + FolderName; |
| 32 | + |
| 33 | + FContentBrowserModule& ContentBrowserModule = FModuleManager::LoadModuleChecked<FContentBrowserModule>("ContentBrowser"); |
| 34 | + ContentBrowserModule.Get().SyncBrowserToFolders({ FolderName }); |
| 35 | +} |
| 36 | + |
| 37 | +void SInteractionSystemTutorialPage::Construct(const FArguments& InArgs) |
| 38 | +{ |
| 39 | + FString arrowEmoji = TEXT("➡"); |
| 40 | + FString bookEmoji = TEXT("📖"); |
| 41 | + FString sparkleEmoji = TEXT("✨"); |
| 42 | + FString folderEmoji = TEXT("📂"); |
| 43 | + |
| 44 | + FString TitleMessage = FString(R"(<LargeText>Before You Start</>)"); |
| 45 | + |
| 46 | + FString IntroMessage = FString(R"( |
| 47 | +Before you start creating any super complex interactions, there are a few steps that must be done. |
| 48 | +In order to make everything work, you should set up default values and collision channels. |
| 49 | +So let's start with those annoying configurations before so we can focus on interactions later. |
| 50 | +)"); |
| 51 | + |
| 52 | + FString CollisionMessage = FString(R"(<RichTextBlock.BoldHighlight>Collision Channels</> |
| 53 | +
|
| 54 | +Interaction System can simply work out of the box with collision channels Engine contains by default, but it is much safer to use custom ones. |
| 55 | +This way you also have much finer control over your interactable objects. |
| 56 | +
|
| 57 | +)") + arrowEmoji + FString(R"( Open <RichTextBlock.Italic>Project Settings</> and open <RichTextBlock.Italic>Collision</> category. |
| 58 | +Here you need to create collision channels for your needs. |
| 59 | +
|
| 60 | +)") + sparkleEmoji + FString(R"( You can quickly open the settings here: <a id="settings" href="Collision">Open Collision Settings</> |
| 61 | +)") + bookEmoji + FString(R"( Detailed guide here: <a id="browser" href="https://github.com/Mountea-Framework/MounteaInteractionSystem/wiki/How-to-Setup-Interaction#collision-channels-">Collision Channels Setup</> |
| 62 | +)"); |
| 63 | + |
| 64 | + FString InteractionMessage = FString(R"(<RichTextBlock.BoldHighlight>Interaction Defaults</> |
| 65 | +
|
| 66 | +)") + arrowEmoji + FString(R"( Open <RichTextBlock.Italic>Project Settings</> and open <RichTextBlock.Italic>Mountea Interaction System</> category. |
| 67 | +<RichTextBlock.BoldHighlight>Default Interaction System Config</> must <RichTextBlock.BoldHighlight>not</> be empty! |
| 68 | +
|
| 69 | +)") + sparkleEmoji + FString(R"( You can quickly open the settings here: <a id="settings" href="Mountea">Open Mountea Interaction System Settings</> |
| 70 | +)") + bookEmoji + FString(R"( Detailed guide on Wiki page: <a id="browser" href="https://github.com/Mountea-Framework/MounteaInteractionSystem/wiki/How-to-Setup-Interaction#interaction-defaults-">Interaction Defaults Setup</> |
| 71 | +)") + folderEmoji + FString(R"( Default Config File is located here: <a id="folder" href="/ActorInteractionPlugin/Config">Open Default Config Folder</> |
| 72 | +)"); |
| 73 | + |
| 74 | + FString ExampleFolderMessage = FString(R"( |
| 75 | +<RichTextBlock.BoldHighlight>Example Content</> |
| 76 | +
|
| 77 | +The Mountea Interaction System includes example assets to help you get started. |
| 78 | +)") + folderEmoji + FString(R"( Open the example assets folder: <a id="folder" href="/ActorInteractionPlugin/Example">Open Example Folder</> |
| 79 | +)"); |
| 80 | + |
| 81 | + ChildSlot |
| 82 | + [ |
| 83 | + SNew(SBorder) |
| 84 | + .Padding(10) |
| 85 | + [ |
| 86 | + SNew(SScrollBox) |
| 87 | + |
| 88 | + // Title |
| 89 | + + SScrollBox::Slot() |
| 90 | + .Padding(10) |
| 91 | + [ |
| 92 | + SNew(SRichTextBlock) |
| 93 | + .Text(FText::FromString(TitleMessage)) |
| 94 | + .DecoratorStyleSet(&FCoreStyle::Get()) |
| 95 | + .AutoWrapText(true) |
| 96 | + + SRichTextBlock::HyperlinkDecorator(TEXT("browser"), FSlateHyperlinkRun::FOnClick::CreateLambda([](const FSlateHyperlinkRun::FMetadata& Metadata) |
| 97 | + { |
| 98 | + const FString* URL = Metadata.Find(TEXT("href")); |
| 99 | + if (URL) { FPlatformProcess::LaunchURL(**URL, nullptr, nullptr); } |
| 100 | + })) |
| 101 | + + SRichTextBlock::HyperlinkDecorator(TEXT("settings"), FSlateHyperlinkRun::FOnClick::CreateLambda([](const FSlateHyperlinkRun::FMetadata& Metadata) |
| 102 | + { |
| 103 | + const FString* Category = Metadata.Find(TEXT("href")); |
| 104 | + if (Category) { OpenSettingsPage(*Category); } |
| 105 | + })) |
| 106 | + ] |
| 107 | + |
| 108 | + // Intro |
| 109 | + + SScrollBox::Slot() |
| 110 | + .Padding(10) |
| 111 | + [ |
| 112 | + SNew(SRichTextBlock) |
| 113 | + .Text(FText::FromString(IntroMessage)) |
| 114 | + .DecoratorStyleSet(&FCoreStyle::Get()) |
| 115 | + .AutoWrapText(true) |
| 116 | + ] |
| 117 | + |
| 118 | + // Image Divider |
| 119 | + + SScrollBox::Slot() |
| 120 | + .Padding(FMargin(0, 5, 0, 5)) |
| 121 | + [ |
| 122 | + SNew(SBox) |
| 123 | + .HeightOverride(2) |
| 124 | + [ |
| 125 | + SNew(SImage) |
| 126 | + .Image(FCoreStyle::Get().GetBrush("WhiteBrush")) |
| 127 | + .ColorAndOpacity(FLinearColor(1, 1, 1, 0.3)) |
| 128 | + ] |
| 129 | + ] |
| 130 | + |
| 131 | + // Collision Channels |
| 132 | + + SScrollBox::Slot() |
| 133 | + .Padding(10) |
| 134 | + [ |
| 135 | + SNew(SRichTextBlock) |
| 136 | + .Text(FText::FromString(CollisionMessage)) |
| 137 | + .DecoratorStyleSet(&FCoreStyle::Get()) |
| 138 | + .AutoWrapText(true) |
| 139 | + + SRichTextBlock::HyperlinkDecorator(TEXT("browser"), FSlateHyperlinkRun::FOnClick::CreateLambda([](const FSlateHyperlinkRun::FMetadata& Metadata) |
| 140 | + { |
| 141 | + const FString* URL = Metadata.Find(TEXT("href")); |
| 142 | + if (URL) { FPlatformProcess::LaunchURL(**URL, nullptr, nullptr); } |
| 143 | + })) |
| 144 | + + SRichTextBlock::HyperlinkDecorator(TEXT("settings"), FSlateHyperlinkRun::FOnClick::CreateLambda([](const FSlateHyperlinkRun::FMetadata& Metadata) |
| 145 | + { |
| 146 | + const FString* Category = Metadata.Find(TEXT("href")); |
| 147 | + if (Category) { OpenSettingsPage(*Category); } |
| 148 | + })) |
| 149 | + ] |
| 150 | + |
| 151 | + // Image Divider |
| 152 | + + SScrollBox::Slot() |
| 153 | + .Padding(FMargin(0, 5, 0, 5)) |
| 154 | + [ |
| 155 | + SNew(SBox) |
| 156 | + .HeightOverride(2) |
| 157 | + [ |
| 158 | + SNew(SImage) |
| 159 | + .Image(FCoreStyle::Get().GetBrush("WhiteBrush")) |
| 160 | + .ColorAndOpacity(FLinearColor(1, 1, 1, 0.3)) |
| 161 | + ] |
| 162 | + ] |
| 163 | + |
| 164 | + // Interaction Defaults |
| 165 | + + SScrollBox::Slot() |
| 166 | + .Padding(10) |
| 167 | + [ |
| 168 | + SNew(SRichTextBlock) |
| 169 | + .Text(FText::FromString(InteractionMessage)) |
| 170 | + .DecoratorStyleSet(&FCoreStyle::Get()) |
| 171 | + .AutoWrapText(true) |
| 172 | + + SRichTextBlock::HyperlinkDecorator(TEXT("browser"), FSlateHyperlinkRun::FOnClick::CreateLambda([](const FSlateHyperlinkRun::FMetadata& Metadata) |
| 173 | + { |
| 174 | + const FString* URL = Metadata.Find(TEXT("href")); |
| 175 | + if (URL) { FPlatformProcess::LaunchURL(**URL, nullptr, nullptr); } |
| 176 | + })) |
| 177 | + + SRichTextBlock::HyperlinkDecorator(TEXT("settings"), FSlateHyperlinkRun::FOnClick::CreateLambda([](const FSlateHyperlinkRun::FMetadata& Metadata) |
| 178 | + { |
| 179 | + const FString* Category = Metadata.Find(TEXT("href")); |
| 180 | + if (Category) { OpenSettingsPage(*Category); } |
| 181 | + })) |
| 182 | + + SRichTextBlock::HyperlinkDecorator(TEXT("folder"), FSlateHyperlinkRun::FOnClick::CreateLambda([](const FSlateHyperlinkRun::FMetadata& Metadata) |
| 183 | + { |
| 184 | + const FString* FolderName = Metadata.Find(TEXT("href")); |
| 185 | + if (FolderName) |
| 186 | + { |
| 187 | + OpenContentBrowserFolder(*FolderName); |
| 188 | + } |
| 189 | + })) |
| 190 | + ] |
| 191 | + |
| 192 | + // Image Divider |
| 193 | + + SScrollBox::Slot() |
| 194 | + .Padding(FMargin(0, 5, 0, 5)) |
| 195 | + [ |
| 196 | + SNew(SBox) |
| 197 | + .HeightOverride(2) |
| 198 | + [ |
| 199 | + SNew(SImage) |
| 200 | + .Image(FCoreStyle::Get().GetBrush("WhiteBrush")) |
| 201 | + .ColorAndOpacity(FLinearColor(1, 1, 1, 0.3)) |
| 202 | + ] |
| 203 | + ] |
| 204 | + |
| 205 | + // Example Folder |
| 206 | + + SScrollBox::Slot() |
| 207 | + .Padding(10) |
| 208 | + [ |
| 209 | + SNew(SRichTextBlock) |
| 210 | + .Text(FText::FromString(ExampleFolderMessage)) |
| 211 | + .DecoratorStyleSet(&FCoreStyle::Get()) |
| 212 | + .AutoWrapText(true) |
| 213 | + + SRichTextBlock::HyperlinkDecorator(TEXT("browser"), FSlateHyperlinkRun::FOnClick::CreateLambda([](const FSlateHyperlinkRun::FMetadata& Metadata) |
| 214 | + { |
| 215 | + const FString* URL = Metadata.Find(TEXT("href")); |
| 216 | + if (URL) { FPlatformProcess::LaunchURL(**URL, nullptr, nullptr); } |
| 217 | + })) |
| 218 | + + SRichTextBlock::HyperlinkDecorator(TEXT("folder"), FSlateHyperlinkRun::FOnClick::CreateLambda([](const FSlateHyperlinkRun::FMetadata& Metadata) |
| 219 | + { |
| 220 | + const FString* FolderName = Metadata.Find(TEXT("href")); |
| 221 | + if (FolderName) |
| 222 | + { |
| 223 | + OpenContentBrowserFolder(*FolderName); |
| 224 | + } |
| 225 | + })) |
| 226 | + ] |
| 227 | + ] |
| 228 | + ]; |
| 229 | +} |
0 commit comments