From 5b520f3cbd562987790851911529f232213b9a9c Mon Sep 17 00:00:00 2001 From: Miepee Date: Wed, 31 Aug 2022 20:43:36 +0200 Subject: [PATCH] Put colors into seperate class --- .../AM2RLauncher/MainForm/LauncherColors.cs | 23 +++ .../AM2RLauncher/MainForm/MainForm.Events.cs | 8 +- .../MainForm/MainForm.StateMachine.cs | 10 +- .../AM2RLauncher/MainForm/MainForm.UI.cs | 174 ++++++++---------- 4 files changed, 111 insertions(+), 104 deletions(-) create mode 100644 AM2RLauncher/AM2RLauncher/MainForm/LauncherColors.cs diff --git a/AM2RLauncher/AM2RLauncher/MainForm/LauncherColors.cs b/AM2RLauncher/AM2RLauncher/MainForm/LauncherColors.cs new file mode 100644 index 0000000..886a628 --- /dev/null +++ b/AM2RLauncher/AM2RLauncher/MainForm/LauncherColors.cs @@ -0,0 +1,23 @@ +using AM2RLauncherLib; +using Eto.Drawing; + +namespace AM2RLauncher; + +public static class LauncherColors +{ + // Colors + /// The main green color. + public static readonly Color Green = Color.FromArgb(142, 188, 35); + /// The warning red color. + public static readonly Color Red = Color.FromArgb(188, 10, 35); + /// The main inactive color. + public static readonly Color Inactive = Color.FromArgb(109, 109, 109); + /// The black background color without alpha value. + public static readonly Color BGNoAlpha = Color.FromArgb(10, 10, 10); + /// The black background color. + // XORG can't display alpha anyway, and Wayland breaks with it. + // TODO: that sounds like an Eto issue. investigate, try to open eto issue. + public static readonly Color BG = OS.IsLinux ? Color.FromArgb(10, 10, 10) : Color.FromArgb(10, 10, 10, 80); + /// The lighter green color on hover. + public static readonly Color BGHover = Color.FromArgb(17, 28, 13); +} \ No newline at end of file diff --git a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Events.cs b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Events.cs index e3f6b40..77a5b66 100644 --- a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Events.cs +++ b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Events.cs @@ -41,13 +41,13 @@ public partial class MainForm : Form // Safety check if ((modSettingsProfileDropDown == null) || (modSettingsProfileDropDown.Items.Count != 0)) return; addModButton.Enabled = false; - settingsProfileLabel.TextColor = colorInactive; + settingsProfileLabel.TextColor = LauncherColors.Inactive; modSettingsProfileDropDown.Enabled = false; profileButton.Enabled = false; saveButton.Enabled = false; updateModButton.Enabled = false; deleteModButton.Enabled = false; - profileNotesTextArea.TextColor = colorInactive; + profileNotesTextArea.TextColor = LauncherColors.Inactive; } /// @@ -778,7 +778,7 @@ public partial class MainForm : Form deleteModButton.ToolTip = null; updateModButton.Enabled = false; updateModButton.ToolTip = null; - profileNotesTextArea.TextColor = colorInactive; + profileNotesTextArea.TextColor = LauncherColors.Inactive; } else { @@ -795,7 +795,7 @@ public partial class MainForm : Form profileButton.ToolTip = HelperMethods.GetText(Text.OpenProfileFolderToolTip, profileName); saveButton.Enabled = true; saveButton.ToolTip = HelperMethods.GetText(Text.OpenSaveFolderToolTip, profileName); - profileNotesTextArea.TextColor = colorGreen; + profileNotesTextArea.TextColor = LauncherColors.Green; profileNotesTextArea.Text = Text.ProfileNotes + "\n" + profileList[modSettingsProfileDropDown.SelectedIndex].ProfileNotes; } diff --git a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.StateMachine.cs b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.StateMachine.cs index 577cbb6..cc21b96 100644 --- a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.StateMachine.cs +++ b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.StateMachine.cs @@ -152,7 +152,7 @@ public partial class MainForm } if (apkButtonState == ApkButtonState.Creating) profileDropDown.Enabled = false; - Color col = profileDropDown.Enabled ? colorGreen : colorInactive; + Color col = profileDropDown.Enabled ? LauncherColors.Green : LauncherColors.Inactive; if (OS.IsWindows) profileDropDown.TextColor = col; @@ -185,7 +185,7 @@ public partial class MainForm string selectedProfileName = modSettingsProfileDropDown.Items[modSettingsProfileDropDown.SelectedIndex].Text; - settingsProfileLabel.TextColor = colorGreen; + settingsProfileLabel.TextColor = LauncherColors.Green; modSettingsProfileDropDown.Enabled = enabled; desktopShortcutButton.Enabled = enabled; profileButton.Enabled = enabled; @@ -206,7 +206,7 @@ public partial class MainForm - Color col = enabled ? colorGreen : colorInactive; + Color col = enabled ? LauncherColors.Green : LauncherColors.Inactive; if (OS.IsWindows) modSettingsProfileDropDown.TextColor = col; @@ -400,7 +400,7 @@ public partial class MainForm // Not sure why the dropdown menu needs this hack, but the textBox does not. //TODO: eto feature request if (OS.IsWindows) - mirrorDropDown.TextColor = mirrorDropDown.Enabled ? colorGreen : colorInactive; - mirrorLabel.TextColor = !enabled ? colorGreen : colorInactive; + mirrorDropDown.TextColor = mirrorDropDown.Enabled ? LauncherColors.Green : LauncherColors.Inactive; + mirrorLabel.TextColor = !enabled ? LauncherColors.Green : LauncherColors.Inactive; } } \ No newline at end of file diff --git a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.UI.cs b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.UI.cs index 3546ffc..adbca02 100644 --- a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.UI.cs +++ b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.UI.cs @@ -164,7 +164,7 @@ public partial class MainForm : Form log.Info($"Start the launcher with Size: {ClientSize.Width}, {ClientSize.Height}"); if (Boolean.Parse(ReadFromConfig("IsMaximized"))) Maximize(); - Drawable drawable = new Drawable { BackgroundColor = colorBGNoAlpha }; + Drawable drawable = new Drawable { BackgroundColor = LauncherColors.BGNoAlpha }; // Drawable paint event drawable.Paint += DrawablePaintEvent; @@ -180,21 +180,21 @@ public partial class MainForm : Form // PLAY button playButton = new ColorButton { - BackgroundColorHover = colorBGHover, + BackgroundColorHover = LauncherColors.BGHover, Height = 40, Width = 250, - TextColor = colorGreen, - TextColorDisabled = colorInactive, - BackgroundColor = colorBG, - FrameColor = colorGreen, - FrameColorDisabled = colorInactive + TextColor = LauncherColors.Green, + TextColorDisabled = LauncherColors.Inactive, + BackgroundColor = LauncherColors.BG, + FrameColor = LauncherColors.Green, + FrameColorDisabled = LauncherColors.Inactive }; centerInterface.AddRow(playButton); //TODO: consider making the spacers global? // 2px spacer between playButton and apkButton (Windows only) - if (OS.IsWindows) centerInterface.AddRow(new Label { BackgroundColor = colorBG, Height = 2 }); + if (OS.IsWindows) centerInterface.AddRow(new Label { BackgroundColor = LauncherColors.BG, Height = 2 }); // APK button apkButton = new ColorButton @@ -202,10 +202,10 @@ public partial class MainForm : Form Text = Text.CreateAPK, Height = 40, Width = 250, - TextColor = colorGreen, - BackgroundColor = colorBG, - FrameColor = colorGreen, - BackgroundColorHover = colorBGHover + TextColor = LauncherColors.Green, + BackgroundColor = LauncherColors.BG, + FrameColor = LauncherColors.Green, + BackgroundColorHover = LauncherColors.BGHover }; centerInterface.AddRow(apkButton); @@ -217,30 +217,30 @@ public partial class MainForm : Form }; // 4px spacer between APK button and progressBar (Windows only) - if (OS.IsWindows) centerInterface.AddRow(new Label { BackgroundColor = colorBG, Height = 4 }); + if (OS.IsWindows) centerInterface.AddRow(new Label { BackgroundColor = LauncherColors.BG, Height = 4 }); centerInterface.AddRow(progressBar); progressLabel = new Label { - BackgroundColor = colorBG, + BackgroundColor = LauncherColors.BG, Height = 15, Text = "", - TextColor = colorGreen, + TextColor = LauncherColors.Green, Visible = false }; centerInterface.AddRow(progressLabel); // 3px spacer between progressBar and profile label (Windows only) - if (OS.IsWindows) centerInterface.AddRow(new Label { BackgroundColor = colorBG, Height = 3 }); + if (OS.IsWindows) centerInterface.AddRow(new Label { BackgroundColor = LauncherColors.BG, Height = 3 }); profileLabel = new Label { - BackgroundColor = colorBG, + BackgroundColor = LauncherColors.BG, Height = 15, Text = Text.CurrentProfile, - TextColor = colorGreen + TextColor = LauncherColors.Green }; centerInterface.AddRow(profileLabel); @@ -252,8 +252,8 @@ public partial class MainForm : Form // Mac gets a default BackgroundColor because it looks waaaaaaay better. profileDropDown = new DropDown { - TextColor = colorGreen, - BackgroundColor = OS.IsWindows ? colorBGNoAlpha : new Color() + TextColor = LauncherColors.Green, + BackgroundColor = OS.IsWindows ? LauncherColors.BGNoAlpha : new Color() }; // In order to not have conflicting theming, we just always respect the users theme for dropdown on GTK. if (OS.IsLinux) @@ -266,18 +266,18 @@ public partial class MainForm : Form // Profiles label profileAuthorLabel = new Label { - BackgroundColor = colorBG, + BackgroundColor = LauncherColors.BG, Height = 16, - TextColor = colorGreen + TextColor = LauncherColors.Green }; centerInterface.AddRow(profileAuthorLabel); profileVersionLabel = new Label { - BackgroundColor = colorBG, + BackgroundColor = LauncherColors.BG, Height = 16, - TextColor = colorGreen + TextColor = LauncherColors.Green }; centerInterface.AddRow(profileVersionLabel); @@ -285,11 +285,11 @@ public partial class MainForm : Form saveWarningLabel = new Label { Visible = false, - BackgroundColor = colorBG, + BackgroundColor = LauncherColors.BG, Width = 20, Height = 55, Text = Text.SaveLocationWarning, - TextColor = colorRed + TextColor = LauncherColors.Red }; centerInterface.AddRow(saveWarningLabel); @@ -333,7 +333,7 @@ public partial class MainForm : Form Label versionLabel = new Label { Text = $"v{VERSION}{(isThisRunningFromWine ? "-WINE" : "")}", - Width = 48, TextAlignment = TextAlignment.Right, TextColor = colorGreen, + Width = 48, TextAlignment = TextAlignment.Right, TextColor = LauncherColors.Green, Font = new Font(SystemFont.Default, 12) }; @@ -348,7 +348,7 @@ public partial class MainForm : Form mainLayout.AddSpace(); // Yes, I'm hard-coding this string. Linux users can english. - mainLayout.AddColumn(versionLabel, isThisRunningFromWine ? new Label { Text = "Unsupported", TextColor = colorRed, TextAlignment = TextAlignment.Right } : null); + mainLayout.AddColumn(versionLabel, isThisRunningFromWine ? new Label { Text = "Unsupported", TextColor = LauncherColors.Red, TextAlignment = TextAlignment.Right } : null); drawable.Content = mainLayout; @@ -360,7 +360,7 @@ public partial class MainForm : Form // [MAIN PAGE] TabPage mainPage = new TabPage { - BackgroundColor = colorBGNoAlpha, + BackgroundColor = LauncherColors.BGNoAlpha, Text = Text.PlayTab, Content = drawable }; @@ -377,13 +377,13 @@ public partial class MainForm : Form Label changelogNoConnectionLabel = new Label { Text = Text.NoInternetConnection, - TextColor = colorGreen, + TextColor = LauncherColors.Green, TextAlignment = TextAlignment.Center }; TabPage changelogPage = new TabPage { - BackgroundColor = colorBGNoAlpha, + BackgroundColor = LauncherColors.BGNoAlpha, Text = Text.ChangelogTab, Content = new TableLayout @@ -410,14 +410,14 @@ public partial class MainForm : Form Label newsNoConnectionLabel = new Label { Text = Text.NoInternetConnection, - TextColor = colorGreen, + TextColor = LauncherColors.Green, TextAlignment = TextAlignment.Center }; TabPage newsPage = new TabPage { Text = Text.NewsTab, - BackgroundColor = colorBGNoAlpha, + BackgroundColor = LauncherColors.BGNoAlpha, Content = new TableLayout { @@ -462,7 +462,7 @@ public partial class MainForm : Form Label languageLabel = new Label { Text = Text.LanguageNotice, - TextColor = colorGreen + TextColor = LauncherColors.Green }; // Language DropDown menu @@ -483,8 +483,8 @@ public partial class MainForm : Form languageDropDown = new DropDown { - TextColor = colorGreen, - BackgroundColor = OS.IsWindows ? colorBGNoAlpha : new Color() + TextColor = LauncherColors.Green, + BackgroundColor = OS.IsWindows ? LauncherColors.BGNoAlpha : new Color() }; if (OS.IsLinux) languageDropDown = new DropDown(); @@ -508,7 +508,7 @@ public partial class MainForm : Form { Checked = Boolean.Parse(ReadFromConfig("AutoUpdateAM2R")), Text = Text.AutoUpdateAM2R, - TextColor = colorGreen + TextColor = LauncherColors.Green }; // autoUpdateLauncher checkbox @@ -516,7 +516,7 @@ public partial class MainForm : Form { Checked = Boolean.Parse(ReadFromConfig("AutoUpdateLauncher")), Text = Text.AutoUpdateLauncher, - TextColor = colorGreen + TextColor = LauncherColors.Green }; // HQ music, PC @@ -524,7 +524,7 @@ public partial class MainForm : Form { Checked = Boolean.Parse(ReadFromConfig("MusicHQPC")), Text = Text.HighQualityPC, - TextColor = colorGreen + TextColor = LauncherColors.Green }; // HQ music, Android @@ -532,7 +532,7 @@ public partial class MainForm : Form { Checked = Boolean.Parse(ReadFromConfig("MusicHQAndroid")), Text = Text.HighQualityAndroid, - TextColor = colorGreen + TextColor = LauncherColors.Green }; // Create game debug logs @@ -540,20 +540,20 @@ public partial class MainForm : Form { Checked = Boolean.Parse(ReadFromConfig("ProfileDebugLog")), Text = Text.ProfileDebugCheckBox, - TextColor = colorGreen + TextColor = LauncherColors.Green }; // Mirror list mirrorLabel = new Label { Text = Text.DownloadSource, - TextColor = colorGreen + TextColor = LauncherColors.Green }; mirrorDropDown = new DropDown { - TextColor = colorGreen, - BackgroundColor = OS.IsWindows ? colorBGNoAlpha : new Color() + TextColor = LauncherColors.Green, + BackgroundColor = OS.IsWindows ? LauncherColors.BGNoAlpha : new Color() }; if (OS.IsLinux) mirrorDropDown = new DropDown(); @@ -570,14 +570,14 @@ public partial class MainForm : Form { Checked = Boolean.Parse(ReadFromConfig("CustomMirrorEnabled")), Text = Text.CustomMirrorCheck, - TextColor = colorGreen + TextColor = LauncherColors.Green }; customMirrorTextBox = new TextBox { Text = ReadFromConfig("CustomMirrorText"), - BackgroundColor = colorBGNoAlpha, - TextColor = colorGreen + BackgroundColor = LauncherColors.BGNoAlpha, + TextColor = LauncherColors.Green }; EnableMirrorControlsAccordingly(); @@ -608,7 +608,7 @@ public partial class MainForm : Form TabPage settingsPage = new TabPage { - BackgroundColor = colorBGNoAlpha, + BackgroundColor = LauncherColors.BGNoAlpha, Content = settingsLayout, Text = Text.LauncherSettingsTab }; @@ -626,10 +626,10 @@ public partial class MainForm : Form Font = smallButtonFont, Height = 30, Width = 275, - TextColor = colorGreen, - BackgroundColor = colorBG, - FrameColor = colorGreen, - BackgroundColorHover = colorBGHover + TextColor = LauncherColors.Green, + BackgroundColor = LauncherColors.BG, + FrameColor = LauncherColors.Green, + BackgroundColorHover = LauncherColors.BGHover }; Label modSpacer = new Label @@ -640,14 +640,14 @@ public partial class MainForm : Form settingsProfileLabel = new Label { Text = Text.CurrentProfile, - TextColor = colorGreen, + TextColor = LauncherColors.Green, Width = 275 }; modSettingsProfileDropDown = new DropDown { - TextColor = colorGreen, - BackgroundColor = OS.IsWindows ? colorBGNoAlpha : new Color() + TextColor = LauncherColors.Green, + BackgroundColor = OS.IsWindows ? LauncherColors.BGNoAlpha : new Color() }; // In order to not have conflicting theming, we just always respect the users theme for dropdown on GTK. @@ -664,10 +664,10 @@ public partial class MainForm : Form Font = smallButtonFont, Height = 30, Width = 275, - TextColor = colorGreen, - BackgroundColor = colorBG, - FrameColor = colorGreen, - BackgroundColorHover = colorBGHover + TextColor = LauncherColors.Green, + BackgroundColor = LauncherColors.BG, + FrameColor = LauncherColors.Green, + BackgroundColorHover = LauncherColors.BGHover }; profileButton = new ColorButton @@ -676,10 +676,10 @@ public partial class MainForm : Form Font = smallButtonFont, Height = 30, Width = 275, - TextColor = colorGreen, - BackgroundColor = colorBG, - FrameColor = colorGreen, - BackgroundColorHover = colorBGHover + TextColor = LauncherColors.Green, + BackgroundColor = LauncherColors.BG, + FrameColor = LauncherColors.Green, + BackgroundColorHover = LauncherColors.BGHover }; saveButton = new ColorButton @@ -688,10 +688,10 @@ public partial class MainForm : Form Font = smallButtonFont, Height = 30, Width = 275, - TextColor = colorGreen, - BackgroundColor = colorBG, - FrameColor = colorGreen, - BackgroundColorHover = colorBGHover + TextColor = LauncherColors.Green, + BackgroundColor = LauncherColors.BG, + FrameColor = LauncherColors.Green, + BackgroundColorHover = LauncherColors.BGHover }; updateModButton = new ColorButton @@ -700,10 +700,10 @@ public partial class MainForm : Form Font = smallButtonFont, Height = 30, Width = 275, - TextColor = colorGreen, - BackgroundColor = colorBG, - FrameColor = colorGreen, - BackgroundColorHover = colorBGHover + TextColor = LauncherColors.Green, + BackgroundColor = LauncherColors.BG, + FrameColor = LauncherColors.Green, + BackgroundColorHover = LauncherColors.BGHover }; deleteModButton = new ColorButton @@ -712,17 +712,17 @@ public partial class MainForm : Form Font = smallButtonFont, Height = 30, Width = 275, - TextColor = colorGreen, - BackgroundColor = colorBG, - FrameColor = colorGreen, - BackgroundColorHover = colorBGHover + TextColor = LauncherColors.Green, + BackgroundColor = LauncherColors.BG, + FrameColor = LauncherColors.Green, + BackgroundColorHover = LauncherColors.BGHover }; profileNotesTextArea = new TextArea { ReadOnly = true, - BackgroundColor = colorBGNoAlpha, - TextColor = colorInactive, + BackgroundColor = LauncherColors.BGNoAlpha, + TextColor = LauncherColors.Inactive, SpellCheck = false, Width = 275, Height = 150 @@ -735,7 +735,7 @@ public partial class MainForm : Form TabPage modSettingsPage = new TabPage { - BackgroundColor = colorBGNoAlpha, + BackgroundColor = LauncherColors.BGNoAlpha, Content = modSettingsLayout, Text = Text.ModSettingsTab }; @@ -812,23 +812,7 @@ public partial class MainForm : Form /// The planet Background. private readonly Bitmap formBG = new Bitmap(Resources.bgCentered); - - // Colors - /// The main green color. - private readonly Color colorGreen = Color.FromArgb(142, 188, 35); - /// The warning red color. - private readonly Color colorRed = Color.FromArgb(188, 10, 35); - /// The main inactive color. - private readonly Color colorInactive = Color.FromArgb(109, 109, 109); - /// The black background color without alpha value. - private readonly Color colorBGNoAlpha = Color.FromArgb(10, 10, 10); - /// The black background color. - // XORG can't display alpha anyway, and Wayland breaks with it. - // TODO: that sounds like an Eto issue. investigate, try to open eto issue. - private readonly Color colorBG = OS.IsLinux ? Color.FromArgb(10, 10, 10) : Color.FromArgb(10, 10, 10, 80); - /// The lighter green color on hover. - private readonly Color colorBGHover = Color.FromArgb(17, 28, 13); - + // Mirror lists /// of mirror s, used for actually working with mirrors. private readonly List mirrorList;