-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
111 lines (104 loc) · 5.97 KB
/
Program.cs
File metadata and controls
111 lines (104 loc) · 5.97 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
using Newtonsoft.Json.Linq;
using System;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Text;
using System.IO;
using System.Windows.Forms;
namespace QMM
{
internal static class Program
{
[STAThread]
static void Main()
{
string fontName = "Azonix";
if (IsFontInstalled(fontName))
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
LoadSettingsFromJson();
Application.Run(new MainForm());
}
else
{
Process.Start(fontName + ".ttf");
MessageBox.Show("Please install the Azonix font.", "Font Missing!", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
}
static bool IsFontInstalled(string fontName)
{
using (InstalledFontCollection fontsCollection = new InstalledFontCollection())
{
foreach (FontFamily fontFamily in fontsCollection.Families)
{
if (fontFamily.Name.Equals(fontName, StringComparison.OrdinalIgnoreCase))
{
return true;
}
}
}
return false;
}
static void LoadSettingsFromJson()
{
try
{
string jsonFilePath = "settings.json";
if (!File.Exists(jsonFilePath))
{
// Create a new JSON object with default settings
JObject defaultSettings = new JObject(
new JProperty("ButtonColor", ColorTranslator.ToHtml(Properties.Settings.Default.ButtonColor)),
new JProperty("BGPrimary", ColorTranslator.ToHtml(Properties.Settings.Default.BGPrimary)),
new JProperty("BGSecondary", ColorTranslator.ToHtml(Properties.Settings.Default.BGSecondary)),
new JProperty("BGTertiary", ColorTranslator.ToHtml(Properties.Settings.Default.BGTertiary)),
new JProperty("DetailColor", ColorTranslator.ToHtml(Properties.Settings.Default.DetailColor)),
new JProperty("DetailActive", ColorTranslator.ToHtml(Properties.Settings.Default.DetailActive)),
new JProperty("TextColor", ColorTranslator.ToHtml(Properties.Settings.Default.TextColor)),
new JProperty("PlaceholderColor", ColorTranslator.ToHtml(Properties.Settings.Default.PlaceholderColor)),
new JProperty("SuccessColor", ColorTranslator.ToHtml(Properties.Settings.Default.SuccessColor)),
new JProperty("WarningColor", ColorTranslator.ToHtml(Properties.Settings.Default.WarningColor)),
new JProperty("NotifColor", ColorTranslator.ToHtml(Properties.Settings.Default.NotifColor)),
new JProperty("GameDir", Properties.Settings.Default.GameDir),
new JProperty("UserDataDir", Properties.Settings.Default.UserDataDir),
new JProperty("RoundedControls", Properties.Settings.Default.RoundedControls),
new JProperty("FormShadows", Properties.Settings.Default.FormShadows),
new JProperty("ToolTips", Properties.Settings.Default.ToolTips),
new JProperty("BorderRadius", Properties.Settings.Default.BorderRadius)
);
// Write the default settings to the JSON file
File.WriteAllText(jsonFilePath, defaultSettings.ToString());
}
// Load settings from the JSON file
string json = File.ReadAllText(jsonFilePath);
JObject jObject = JObject.Parse(json);
// Update each setting in Properties.Settings.Default
Properties.Settings.Default.ButtonColor = ColorTranslator.FromHtml((string)jObject["ButtonColor"]);
Properties.Settings.Default.BGPrimary = ColorTranslator.FromHtml((string)jObject["BGPrimary"]);
Properties.Settings.Default.BGSecondary = ColorTranslator.FromHtml((string)jObject["BGSecondary"]);
Properties.Settings.Default.BGTertiary = ColorTranslator.FromHtml((string)jObject["BGTertiary"]);
Properties.Settings.Default.DetailColor = ColorTranslator.FromHtml((string)jObject["DetailColor"]);
Properties.Settings.Default.DetailActive = ColorTranslator.FromHtml((string)jObject["DetailActive"]);
Properties.Settings.Default.TextColor = ColorTranslator.FromHtml((string)jObject["TextColor"]);
Properties.Settings.Default.PlaceholderColor = ColorTranslator.FromHtml((string)jObject["PlaceholderColor"]);
Properties.Settings.Default.SuccessColor = ColorTranslator.FromHtml((string)jObject["SuccessColor"]);
Properties.Settings.Default.WarningColor = ColorTranslator.FromHtml((string)jObject["WarningColor"]);
Properties.Settings.Default.NotifColor = ColorTranslator.FromHtml((string)jObject["NotifColor"]);
Properties.Settings.Default.GameDir = (string)jObject["GameDir"];
Properties.Settings.Default.UserDataDir = (string)jObject["UserDataDir"];
Properties.Settings.Default.RoundedControls = (bool)jObject["RoundedControls"];
Properties.Settings.Default.FormShadows = (bool)jObject["FormShadows"];
Properties.Settings.Default.ToolTips = (bool)jObject["ToolTips"];
Properties.Settings.Default.BorderRadius = (int)jObject["BorderRadius"];
// Save changes to Properties.Settings.Default
Properties.Settings.Default.Save();
}
catch (Exception ex)
{
Console.WriteLine("Error loading settings from JSON: " + ex.Message);
}
}
}
}