TModLoader v1.4.4.9
TModLoader source code documentation
Loading...
Searching...
No Matches

◆ OnActivate()

override void Terraria.ModLoader.UI.UIModPacks.OnActivate ( )
inlinevirtual

Reimplemented from Terraria.UI.UIElement.

Definition at line 256 of file UIModPacks.cs.

257 {
258 _cts = new CancellationTokenSource();
261 Task.Run(delegate
262 {
263 Directory.CreateDirectory(ModPacksDirectory);
264 string[] directories = Directory.GetDirectories(ModPacksDirectory, "*", SearchOption.TopDirectoryOnly);
265 string[] files = Directory.GetFiles(ModPacksDirectory, "*.json", SearchOption.TopDirectoryOnly);
267 foreach (string current in files.Concat(directories))
268 {
269 try
270 {
271 if (!IsValidModpackName(Path.GetFileNameWithoutExtension(current)))
272 {
273 throw new Exception();
274 }
275 if (Directory.Exists(current))
276 {
277 ModPacksToAdd.Add(LoadModernModPack(current));
278 }
279 else
280 {
281 ModPacksToAdd.Add(LoadLegacyModPack(current));
282 }
283 }
284 catch
285 {
286 UIAutoScaleTextTextPanel<string> item = new UIAutoScaleTextTextPanel<string>(Language.GetTextValue("tModLoader.ModPackMalformed", Path.GetFileName(current)))
287 {
288 Width =
289 {
290 Percent = 1f
291 },
292 Height =
293 {
294 Pixels = 50f,
295 Percent = 0f
296 }
297 };
298 ModPacksToAdd.Add(item);
299 }
300 }
301 Main.QueueMainThreadAction(delegate
302 {
305 });
306 });
307 }
virtual void AddRange(IEnumerable< UIElement > items)
Definition UIList.cs:222
static string GetTextValue(string key)
Retrieves the text value for a specified localization key. The text returned will be for the currentl...
Definition Language.cs:35
Contains methods to access or retrieve localization values. The Localization Guideteaches more about ...
Definition Language.cs:12
CancellationTokenSource _cts
Definition UIModPacks.cs:36
UIModPackItem LoadModernModPack(string folderPath)
static bool IsValidModpackName(string name)
UILoaderAnimatedImage _uiLoader
Definition UIModPacks.cs:32
UIModPackItem LoadLegacyModPack(string jsonPath)
StyleDimension Height
Definition UIElement.cs:29
void Append(UIElement element)
Definition UIElement.cs:194
StyleDimension Width
Definition UIElement.cs:27
void RemoveChild(UIElement child)
Definition UIElement.cs:210

References Terraria.ModLoader.UI.UIModPacks._cts, Terraria.ModLoader.UI.UIModPacks._modPacks, Terraria.ModLoader.UI.UIModPacks._scrollPanel, Terraria.ModLoader.UI.UIModPacks._uiLoader, Terraria.GameContent.UI.Elements.UIList.AddRange(), Terraria.UI.UIElement.Append(), Terraria.GameContent.UI.Elements.UIList.Clear(), Terraria.Localization.Language.GetTextValue(), Terraria.UI.UIElement.Height, Terraria.ModLoader.UI.UIModPacks.IsValidModpackName(), Terraria.ModLoader.UI.UIModPacks.LoadLegacyModPack(), Terraria.ModLoader.UI.UIModPacks.LoadModernModPack(), Terraria.ModLoader.UI.UIModPacks.ModPacksDirectory, Terraria.Main.QueueMainThreadAction(), Terraria.UI.UIElement.RemoveChild(), and Terraria.UI.UIElement.Width.

+ Here is the call graph for this function: