Repository navigation
Expand file tree
/
Copy pathMTLPopup.cpp
More file actions
217 lines (191 loc) · 5.92 KB
/
Copy pathMTLPopup.cpp
File metadata and controls
217 lines (191 loc) · 5.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
#include "MTLPopup.h"
#include "MTLPopupConfig.h"
#include "EditorStyleSet.h"
#include "Widgets/Layout/SScrollBox.h"
#include "Widgets/Text/SRichTextBlock.h"
#include "SWebBrowser.h"
#include "Interfaces/IPluginManager.h"
void MTLPopup::OnBrowserLinkClicked(const FSlateHyperlinkRun::FMetadata& Metadata)
{
const FString* URL = Metadata.Find(TEXT("href"));
if (URL)
{
FPlatformProcess::LaunchURL(**URL, nullptr, nullptr);
}
}
void MTLPopup::Register()
{
const FString PluginDirectory = IPluginManager::Get().FindPlugin(TEXT("MounteaToolsLibrary"))->GetBaseDir();
const FString UpdatedConfigFile = PluginDirectory + "/Config/UpdateConfig.ini";
const FString CurrentPluginVersion = "1.0";
UMTLPopupConfig* MTLPopupConfig = GetMutableDefault<UMTLPopupConfig>();
if (FPaths::FileExists(UpdatedConfigFile))
{
MTLPopupConfig->LoadConfig(nullptr, *UpdatedConfigFile);
}
else
{
MTLPopupConfig->SaveConfig(CPF_Config, *UpdatedConfigFile);
}
if (MTLPopupConfig->PluginVersionUpdate != CurrentPluginVersion)
{
MTLPopupConfig->PluginVersionUpdate = CurrentPluginVersion;
MTLPopupConfig->SaveConfig(CPF_Config, *UpdatedConfigFile);
FCoreDelegates::OnPostEngineInit.AddLambda([]()
{
OpenMTLPopup();
});
}
}
void MTLPopup::OpenMTLPopup()
{
if (!FSlateApplication::Get().CanDisplayWindows())
{
return;
}
const TSharedRef<SBorder> WindowContent = SNew(SBorder)
.BorderImage(FCoreStyle::Get().GetBrush("ToolPanel.GroupBorder"))
.Padding(FMargin(8.0f, 8.0f));
TSharedPtr<SWindow> Window = SNew(SWindow)
.AutoCenter(EAutoCenter::PreferredWorkArea)
.SupportsMaximize(false)
.SupportsMinimize(false)
.SizingRule(ESizingRule::FixedSize)
.ClientSize(FVector2D(800, 600))
.Title(FText::FromString("Mountea Tools Library"))
.IsTopmostWindow(true)
[
WindowContent
];
const FSlateFontInfo HeadingFont = FCoreStyle::GetDefaultFontStyle("Regular", 24);
const FSlateFontInfo ContentFont = FCoreStyle::GetDefaultFontStyle("Regular", 12);
const TSharedRef<SVerticalBox> InnerContent = SNew(SVerticalBox)
// Default settings example
+ SVerticalBox::Slot()
.AutoHeight()
.Padding(10)
[
SNew(STextBlock)
.Font(HeadingFont)
.Text(FText::FromString("Mountea Tools Library v1.0"))
.Justification(ETextJustify::Center)
]
+ SVerticalBox::Slot()
.FillHeight(1.0)
.Padding(10)
[
SNew(SBorder)
.Padding(10)
.BorderImage(FAppStyle::GetBrush("ToolPanel.DarkGroupBorder"))
[
SNew(SScrollBox)
+ SScrollBox::Slot()
[
SNew(SRichTextBlock)
.Text(FText::FromString(R"(
<LargeText>Hello and thank you for using Mountea Tools Library!</>
First thing first, if you've been enjoying using it, it would mean a lot if you could just drop <a id="browser" href="https://bit.ly/AIntP_UE4Marketplace">a small review on the marketplace page</> :).
I also made a paid <a id="browser" href="https://bit.ly/ModularSwordsPack_UE4Marketplace">Modular Sword Pack</>. It's a simple yet powerful tool that allows creating thousands upon thousands of unique swords with a simple click, now with a free upgrade of Modular Scabbard System!
But let's keep it short, here are the cool new features (and bugfixes) of version 1.0!
<LargeText>Version 1.0</>
<RichTextBlock.Bold>Features</>
* Add new Interactor Component Base Class implementing <RichTextBlock.Italic>IMounteaInteractorInterface</>
<RichTextBlock.Bold>Bugfixes</>
* Fix missed descriptions
* Add <RichTextBlock.Bold>DEPRECATED</> to old Component Classes
)"))
.TextStyle(FAppStyle::Get(), "NormalText")
.DecoratorStyleSet(&FAppStyle::Get())
.AutoWrapText(true)
+ SRichTextBlock::HyperlinkDecorator(TEXT("browser"), FSlateHyperlinkRun::FOnClick::CreateStatic(&OnBrowserLinkClicked))
]
]
]
+ SVerticalBox::Slot()
.AutoHeight()
.Padding(10)
[
SNew(SHorizontalBox)
+ SHorizontalBox::Slot().FillWidth(1.0f)
[
SNew(SButton)
.Text(FText::FromString("Leave a review <3"))
.HAlign(HAlign_Center)
.OnClicked_Lambda([]()
{
const FString URL = "https://bit.ly/AIntP_UE4Marketplace";
FPlatformProcess::LaunchURL(*URL, nullptr, nullptr);
return FReply::Handled();
})
]
+ SHorizontalBox::Slot().AutoWidth()
[
SNew(SSpacer)
.Size(FVector2D(20, 10))
]
+ SHorizontalBox::Slot().FillWidth(1.0f)
[
SNew(SButton)
.Text(FText::FromString("Support our work"))
.HAlign(HAlign_Center)
.OnClicked_Lambda([]()
{
const FString URL = "https://bit.ly/AIntP_GitHubDonate";
FPlatformProcess::LaunchURL(*URL, nullptr, nullptr);
return FReply::Handled();
})
]
+ SHorizontalBox::Slot().AutoWidth()
[
SNew(SSpacer)
.Size(FVector2D(20, 10))
]
+ SHorizontalBox::Slot().FillWidth(1.0f)
[
SNew(SButton)
.Text(FText::FromString("Join support Discord"))
.HAlign(HAlign_Center)
.OnClicked_Lambda([]()
{
const FString URL = "https://discord.gg/2vXWEEN";
FPlatformProcess::LaunchURL(*URL, nullptr, nullptr);
return FReply::Handled();
})
]
+ SHorizontalBox::Slot().AutoWidth()
[
SNew(SSpacer)
.Size(FVector2D(20, 10))
]
+ SHorizontalBox::Slot().FillWidth(1.0f)
[
SNew(SButton)
.Text(FText::FromString("Unreal Bucket"))
.HAlign(HAlign_Center)
.OnClicked_Lambda([Window]()
{
const FString URL = "https://www.unrealengine.com/marketplace/en-US/product/3ce48046720d4a66b4f804b0d135a820";
FPlatformProcess::LaunchURL(*URL, nullptr, nullptr);
return FReply::Handled();
})
]
+ SHorizontalBox::Slot().AutoWidth()
[
SNew(SSpacer)
.Size(FVector2D(20, 10))
]
+ SHorizontalBox::Slot().FillWidth(1.0f)
[
SNew(SButton)
.Text(FText::FromString("Close window"))
.HAlign(HAlign_Center)
.OnClicked_Lambda([Window]()
{
Window->RequestDestroyWindow();
return FReply::Handled();
})
]
];
WindowContent->SetContent(InnerContent);
Window = FSlateApplication::Get().AddWindow(Window.ToSharedRef());
}