Skip to content

Commit

Permalink
refactor(sqlite): normalize and remove gear table
Browse files Browse the repository at this point in the history
  • Loading branch information
DorielRivalet committed Dec 24, 2022
1 parent b25cc4f commit 129e174
Show file tree
Hide file tree
Showing 6 changed files with 224 additions and 118 deletions.
3 changes: 3 additions & 0 deletions MHFZ_Overlay/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,9 @@
<setting name="PlayerAttackGraphY" serializeAs="String">
<value>0</value>
</setting>
<setting name="EnableQuestLogging" serializeAs="String">
<value>True</value>
</setting>
</MHFZ_Overlay.Settings>
</userSettings>
</configuration>
27 changes: 25 additions & 2 deletions MHFZ_Overlay/ConfigWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using CsvHelper;
using MHFZ_Overlay.Core.Class;
using Newtonsoft.Json;
using Octokit;
using System;
Expand Down Expand Up @@ -2924,7 +2925,7 @@ private void ExportUserSettings_Click(object sender, RoutedEventArgs e)
Settings s = (Settings)Application.Current.TryFindResource("Settings");

// Create a dictionary to store the user settings
Dictionary<string, string> settings = new Dictionary<string, string>();
Dictionary<string, Setting> settings = new Dictionary<string, Setting>();

// Get a list of the user settings properties sorted alphabetically by name
List<System.Configuration.SettingsProperty> sortedSettings = s.Properties.Cast<System.Configuration.SettingsProperty>().OrderBy(setting => setting.Name).ToList();
Expand All @@ -2933,8 +2934,30 @@ private void ExportUserSettings_Click(object sender, RoutedEventArgs e)
foreach (System.Configuration.SettingsProperty setting in sortedSettings)
{
string settingName = setting.Name;
string settingDefaultValue = setting.DefaultValue.ToString();
string settingPropertyType = setting.PropertyType.ToString();
string settingIsReadOnly = setting.IsReadOnly.ToString();
string settingProvider = setting.Provider.ToString();
string settingProviderApplicationName = setting.Provider.ApplicationName;
string settingProviderDescription = setting.Provider.Description;
string settingProviderName = setting.Provider.Name;
string settingValue = s[settingName].ToString();
settings.Add(settingName, settingValue);

// Create a new Setting object and set its properties
Setting settingObject = new Setting
{
Value = settingValue,
DefaultValue = settingDefaultValue,
PropertyType = settingPropertyType,
IsReadOnly = settingIsReadOnly,
Provider = settingProvider,
ProviderName = settingProviderName,
ProviderApplicationName = settingProviderApplicationName,
ProviderDescription = settingProviderDescription
};

// Add the key and Setting object to the dictionary
settings.Add(settingName, settingObject);
}

// Serialize the dictionary to a JSON string
Expand Down
Loading

0 comments on commit 129e174

Please sign in to comment.