-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGlobals.cs
120 lines (107 loc) · 5.24 KB
/
Globals.cs
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
using System;
using System.Collections.Generic;
using System.Globalization;
using MangaDex_Library;
using System.Runtime.InteropServices;
using MsBox.Avalonia.Enums;
using MsBox.Avalonia;
using System.Diagnostics;
using Avalonia.Threading;
namespace Manga_Manager
{
internal class Manga
{
public string Title = string.Empty;
public string Description = string.Empty;
public string Path = string.Empty;
public decimal FileLastChapter = 0M;
public decimal OnlineLastChapter = 0M;
public DateOnly LastChecked = new DateOnly(69, 1, 1);
public string OngoingStatus = "Unknown";
public bool CheckInBulk = false;
public string ID = string.Empty;
public string ContentRating = "Unknown";
public List<string> Tags = new List<string>();
}
internal static class Globals
{
static Globals()
{
foreach (CultureInfo culture in CultureInfo.GetCultures(CultureTypes.AllCultures))
if (languageDictionary.ContainsValue(culture.TwoLetterISOLanguageName) == false)
languageDictionary[culture.EnglishName] = culture.TwoLetterISOLanguageName;
languageDictionary["Simplified Chinese"] = "zh";
languageDictionary["Traditional Chinese"] = "zh-hk";
languageDictionary["Brazilian Portugese"] = "pt-br";
languageDictionary["Castilian Spanish"] = "es";
languageDictionary["Latin American Spanish"] = "es-la";
languageDictionary["Romanized Japanese"] = "ja-ro";
languageDictionary["Romanized Korean"] = "ko-ro";
languageDictionary["Romanized Chinese"] = "zh-ro";
MDLGetData.ApiRequestFailed += MDLGetData_ApiRequestFailed;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
MDLParameters.SetUserAgent("Manga Library Manager for Windows by (github) ErisLoona");
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
MDLParameters.SetUserAgent("Manga Library Manager for OSX by (github) ErisLoona");
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
MDLParameters.SetUserAgent("Manga Library Manager for Linux by (github) ErisLoona");
else
MDLParameters.SetUserAgent("Manga Library Manager by (github) ErisLoona");
}
internal static void MDLGetData_ApiRequestFailed(object sender, EventArgs e)
{
Dispatcher.UIThread.Post(async () => await MessageBoxManager.GetMessageBoxStandard("API error", "An error occurred while trying to contact the MangaDex API.\nPlease double-check the Manga link and try again later.", ButtonEnum.Ok).ShowAsync());
MDLGetData.ForceReset();
apiError = true;
}
internal static async void OpenLink(string link)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
Process.Start(new ProcessStartInfo(link) { UseShellExecute = true });
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
Process.Start(new ProcessStartInfo("open", new string[] { link }));
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
Process.Start(new ProcessStartInfo("xdg-open", new string[] { link }));
else
await MessageBoxManager.GetMessageBoxStandard("Unknown OS", $"Couldn't identify your OS, what are you running? Open the link yourself lol:\n{link}", ButtonEnum.Ok).ShowAsync();
}
internal static bool ValidateLink(string link)
{
try
{
if(link.StartsWith("https://mangadex.org/title/") == false || link.Split('/')[4] == string.Empty)
return false;
}
catch
{
return false;
}
return true;
}
internal static class Filters
{
public static List<string> IncludedContentRatings = ["Safe", "Suggestive", "Erotica", "Pornographic"];
public static bool OnlyShowMangasWithUpdates = false;
public static bool InclusionModeIsAnd = true;
public static bool ExclusionModeIsAnd = false;
public static List<string> IncludedTags = new List<string>();
public static List<string> ExcludedTags = new List<string>();
public static bool Active()
{
return !(IncludedContentRatings.Count == 4 && OnlyShowMangasWithUpdates == false && IncludedTags.Count == 0 && ExcludedTags.Count == 0);
}
}
#region Variables
internal static List<Manga> mangaList = new List<Manga>();
#region Settings Globals
internal static string selectedLanguage = "en";
internal static bool noWarning = false, checkUpdates = false, hideJsonFile = false;
internal static int downloaderLastUsedFormat = 0;
#endregion
internal static Dictionary<string, string> languageDictionary = new Dictionary<string, string>();
internal static Dictionary<string, int> tagsUsage = new Dictionary<string, int>();
internal static int passIndex = 0;
internal static bool apiError = false;
#endregion
}
}