From 8b1866fff245c1296cab7113c584141db0b722d2 Mon Sep 17 00:00:00 2001 From: ASNiVOR Date: Fri, 20 Jan 2017 12:15:42 +0000 Subject: [PATCH] Completed config tooltip implementation --- MedLaunch/Classes/ConfigToolTips.cs | 370 +++ MedLaunch/Classes/HtmlToXaml/CssStylesheet.cs | 252 ++ MedLaunch/Classes/HtmlToXaml/HtmlCSSParser.cs | 841 +++++ .../Classes/HtmlToXaml/HtmlLexicalAnalyzer.cs | 744 +++++ MedLaunch/Classes/HtmlToXaml/HtmlParser.cs | 483 +++ MedLaunch/Classes/HtmlToXaml/HtmlSchema.cs | 730 +++++ .../Classes/HtmlToXaml/HtmlToXamlConverter.cs | 2753 +++++++++++++++++ MedLaunch/Classes/HtmlToXaml/HtmlTokenType.cs | 25 + .../VisualHandlers/ConfigsVisualHandler.cs | 8 +- MedLaunch/Data/System/ToolTips.json | 2318 ++++++++++++++ MedLaunch/MainWindow.xaml | 256 +- MedLaunch/MainWindow.xaml.cs | 27 +- MedLaunch/MedLaunch.csproj | 11 + MedLaunch/Models/GlobalSettings.cs | 12 +- MedLaunch/Properties/AssemblyInfo.cs | 4 +- 15 files changed, 8592 insertions(+), 242 deletions(-) create mode 100644 MedLaunch/Classes/ConfigToolTips.cs create mode 100644 MedLaunch/Classes/HtmlToXaml/CssStylesheet.cs create mode 100644 MedLaunch/Classes/HtmlToXaml/HtmlCSSParser.cs create mode 100644 MedLaunch/Classes/HtmlToXaml/HtmlLexicalAnalyzer.cs create mode 100644 MedLaunch/Classes/HtmlToXaml/HtmlParser.cs create mode 100644 MedLaunch/Classes/HtmlToXaml/HtmlSchema.cs create mode 100644 MedLaunch/Classes/HtmlToXaml/HtmlToXamlConverter.cs create mode 100644 MedLaunch/Classes/HtmlToXaml/HtmlTokenType.cs create mode 100644 MedLaunch/Data/System/ToolTips.json diff --git a/MedLaunch/Classes/ConfigToolTips.cs b/MedLaunch/Classes/ConfigToolTips.cs new file mode 100644 index 0000000..667fb46 --- /dev/null +++ b/MedLaunch/Classes/ConfigToolTips.cs @@ -0,0 +1,370 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Text; +using System.Threading.Tasks; +using HtmlAgilityPack; +using Newtonsoft.Json; +using System.IO; +using System.Windows.Controls; +using System.Windows; +using Xceed.Wpf.Toolkit; +using MahApps.Metro.Controls; +using MedLaunch.Classes.HtmlToXaml; + +namespace MedLaunch.Classes +{ + public class ConfigToolTips + { + /// + /// 1 = set tooltips + /// 2 = unset tooltips + /// + /// + public static void SetToolTips(int SetOrUnset) + { + + // get all config controls + MainWindow mw = Application.Current.Windows.OfType().FirstOrDefault(); + // find the root grid + Grid RootGrid = (Grid)mw.FindName("RootGrid"); + UIHandler ui = UIHandler.GetChildren(RootGrid); + + UIHandler u = new UIHandler(); + u.Buttons = ui.Buttons.Where(a => a.Name.StartsWith("cfg_") || a.Name.StartsWith("cfglbl_")).ToList() ?? new List + + + + + + + diff --git a/MedLaunch/MainWindow.xaml.cs b/MedLaunch/MainWindow.xaml.cs index 2c1e4b8..b60d142 100644 --- a/MedLaunch/MainWindow.xaml.cs +++ b/MedLaunch/MainWindow.xaml.cs @@ -150,7 +150,7 @@ public MainWindow() // load globalsettings for front page GlobalSettings.LoadGlobalSettings(chkEnableNetplay, chkEnableSnes_faust, chkEnablePce_fast, gui_zoom_combo, chkMinToTaskbar, chkHideSidebar, chkAllowBanners, chkAllowBoxart, chkAllowScreenshots, chkAllowFanart, chkPreferGenesis, chkAllowManuals, chkAllowMedia, chkSecondaryScraperBackup, - rbGDB, rbMoby, slScreenshotsPerHost, slFanrtsPerHost, chkAllowUpdateCheck, chkBackupMednafenConfig, chkSaveSysConfigs, comboImageTooltipSize, chkLoadConfigsOnStart, + rbGDB, rbMoby, slScreenshotsPerHost, slFanrtsPerHost, chkAllowUpdateCheck, chkBackupMednafenConfig, chkSaveSysConfigs, comboImageTooltipSize, chkLoadConfigsOnStart, chkEnableConfigToolTips, chkshowGLYear, chkshowGLESRB, chkshowGLCoop, chkshowGLDeveloper, chkshowGLPublisher, chkshowGLPlayers); //gui_zoom.Value = Convert.ToDouble(gui_zoom_combo.SelectedValue); GlobalSettings gs = GlobalSettings.GetGlobals(); @@ -326,6 +326,12 @@ public MainWindow() btnReLink.Visibility = Visibility.Collapsed; + // enable tooltips if neccesary + if (gs.enableConfigToolTips == true) + { + ConfigToolTips.SetToolTips(1); + } + } private MetroWindow colorSchemeChanger; @@ -1457,6 +1463,16 @@ private void chkLoadConfigsOnStart_Unchecked(object sender, RoutedEventArgs e) GlobalSettings.UpdateImportConfigsOnStart(chkLoadConfigsOnStart); } + private void chkEnableConfigToolTips_Checked(object sender, RoutedEventArgs e) + { + GlobalSettings.UpdateEnableConfigToolTips(chkEnableConfigToolTips); + } + + private void chkEnableConfigToolTips_Unchecked(object sender, RoutedEventArgs e) + { + GlobalSettings.UpdateEnableConfigToolTips(chkEnableConfigToolTips); + } + @@ -4057,6 +4073,15 @@ public static string CalculateCombo(List chkboxes) } + private void btnGenerateToolTips_Click(object sender, RoutedEventArgs e) + { + var r = ConfigToolTips.GetDocumentationStrings(); + } + + private void btnPopToolTips_Click(object sender, RoutedEventArgs e) + { + ConfigToolTips.SetToolTips(1); + } } /* public class SliderIgnoreDelta : Slider diff --git a/MedLaunch/MedLaunch.csproj b/MedLaunch/MedLaunch.csproj index 00f7589..817c534 100644 --- a/MedLaunch/MedLaunch.csproj +++ b/MedLaunch/MedLaunch.csproj @@ -237,8 +237,16 @@ + + + + + + + + @@ -493,6 +501,9 @@ + + PreserveNewest + Always diff --git a/MedLaunch/Models/GlobalSettings.cs b/MedLaunch/Models/GlobalSettings.cs index 1b675bf..b22aca7 100644 --- a/MedLaunch/Models/GlobalSettings.cs +++ b/MedLaunch/Models/GlobalSettings.cs @@ -27,6 +27,7 @@ public class GlobalSettings public DateTime? gdbLastUpdated { get; set; } // last time platformgames were synced from thegamesdb.net public bool? backupMednafenConfig { get; set; } // auto create a backup on the mednafen config when MedLaunch is first opened public bool? saveSystemConfigs { get; set; } // auto save system.cfg in root of Mednafen directory before game is launched + public bool? enableConfigToolTips { get; set; } // enable tooltip popups on Mednafen config controls // games library expander states public bool glGameStats { get; set; } @@ -113,6 +114,7 @@ public static GlobalSettings GetGlobalDefaults() saveSystemConfigs = true, imageToolTipPercentage = 0.9, importConfigsOnStart = false, + enableConfigToolTips = true, showGLCoop = true, showGLDeveloper = true, @@ -207,7 +209,7 @@ public static void SetGlobals(GlobalSettings gs) public static void LoadGlobalSettings(CheckBox EnableNetplay, CheckBox EnableSnes_Faust, CheckBox EnablePce_Fast, ComboBox GuiZoom, CheckBox MinToTaskBar, CheckBox HideSidebar, CheckBox chkAllowBanners, CheckBox chkAllowBoxart, CheckBox chkAllowScreenshots, CheckBox chkAllowFanart, CheckBox chkPreferGenesis, CheckBox chkAllowManuals, CheckBox chkAllowMedia, CheckBox chkSecondaryScraperBackup, RadioButton rbGDB, RadioButton rbMoby, Slider slScreenshotsPerHost, Slider slFanrtsPerHost, - CheckBox chkAllowUpdateCheck, CheckBox chkBackupMednafenConfig, CheckBox chkSaveSysConfigs, ComboBox comboImageTooltipSize, CheckBox chkLoadConfigsOnStart, + CheckBox chkAllowUpdateCheck, CheckBox chkBackupMednafenConfig, CheckBox chkSaveSysConfigs, ComboBox comboImageTooltipSize, CheckBox chkLoadConfigsOnStart, CheckBox chkEnableConfigToolTips, CheckBox chkshowGLYear, CheckBox chkshowGLESRB, CheckBox chkshowGLCoop, CheckBox chkshowGLDeveloper, CheckBox chkshowGLPublisher, CheckBox chkshowGLPlayers) { GlobalSettings gs = GetGlobals(); @@ -225,6 +227,7 @@ public static void LoadGlobalSettings(CheckBox EnableNetplay, CheckBox EnableSne chkSaveSysConfigs.IsChecked = gs.saveSystemConfigs; chkLoadConfigsOnStart.IsChecked = gs.importConfigsOnStart; + chkEnableConfigToolTips.IsChecked = gs.enableConfigToolTips; comboImageTooltipSize.SelectedValue = gs.imageToolTipPercentage; @@ -395,6 +398,13 @@ public static void UpdateCheckUpdatesOnStart(CheckBox chkAllowUpdateCheck) SetGlobals(gs); } + public static void UpdateEnableConfigToolTips(CheckBox chkEnableConfigToolTips) + { + GlobalSettings gs = GetGlobals(); + gs.enableConfigToolTips = chkEnableConfigToolTips.IsChecked; + SetGlobals(gs); + } + // scraping options public static void UpdateAllowBanners(CheckBox chkAllowBanners) { diff --git a/MedLaunch/Properties/AssemblyInfo.cs b/MedLaunch/Properties/AssemblyInfo.cs index abef441..71735b3 100644 --- a/MedLaunch/Properties/AssemblyInfo.cs +++ b/MedLaunch/Properties/AssemblyInfo.cs @@ -51,5 +51,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.3.4.1")] -[assembly: AssemblyFileVersion("0.3.4.1")] +[assembly: AssemblyVersion("0.3.5.0")] +[assembly: AssemblyFileVersion("0.3.5.0")]