mirror of
https://github.com/Novetus/Novetus_src.git
synced 2025-01-31 09:41:33 +02:00
less buggy JSON implementation
This commit is contained in:
parent
f4c5110d0b
commit
1e9a73e8a3
@ -648,10 +648,10 @@ class CharacterCustomizationShared
|
||||
{
|
||||
using (var ofd = new OpenFileDialog())
|
||||
{
|
||||
ofd.Filter = "Novetus config_customization files (*.ini)|*.ini";
|
||||
ofd.Filter = "Novetus config_customization files (*.json)|*.json";
|
||||
ofd.FilterIndex = 1;
|
||||
ofd.FileName = "config_customization.ini";
|
||||
ofd.Title = "Load config_customization.ini";
|
||||
ofd.FileName = "config_customization.json";
|
||||
ofd.Title = "Load config_customization.json";
|
||||
if (ofd.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
//FileManagement.Customization(ofd.FileName, false);
|
||||
|
@ -2,8 +2,10 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.Remoting;
|
||||
|
||||
namespace Novetus.Core
|
||||
{
|
||||
@ -59,20 +61,17 @@ namespace Novetus.Core
|
||||
|
||||
public void JsonCreateFile(string Section, Dictionary<string, string> contents)
|
||||
{
|
||||
obj = new JObject(
|
||||
new JProperty(Section,
|
||||
new JArray(from key in contents.Keys
|
||||
select new JObject(
|
||||
new JProperty(key, contents[key])))));
|
||||
JObject o = new JObject();
|
||||
obj.Add(new JProperty(Section, new JObject(o)));
|
||||
|
||||
contents.Keys.ForEach(k => JsonWriteValue(Section, k, contents[k]));
|
||||
|
||||
JsonSave();
|
||||
}
|
||||
|
||||
public void JsonWriteValue(string Section, string Key, string Value)
|
||||
{
|
||||
JsonReload();
|
||||
|
||||
var node = obj.SelectToken(Section + "[0]") as JObject;
|
||||
var node = obj.SelectToken(Section) as JObject;
|
||||
if (node != null)
|
||||
{
|
||||
bool found = false;
|
||||
|
@ -227,6 +227,15 @@ namespace Novetus.Core
|
||||
EnableMenuItem(GetSystemMenu(form.Handle, false), 0xF060, 0);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IEnumerable Extensions
|
||||
public static void ForEach<T>(this IEnumerable<T> source, Action<T> action)
|
||||
{
|
||||
foreach (T item in source)
|
||||
action(item);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -148,6 +148,7 @@ namespace Novetus.Core
|
||||
public void SaveSetting(string section, string name, string value)
|
||||
{
|
||||
SaveSettingEvent();
|
||||
JSON.JsonReload();
|
||||
JSON.JsonWriteValue(section, name, value);
|
||||
}
|
||||
|
||||
@ -869,7 +870,7 @@ namespace Novetus.Core
|
||||
catch (Exception ex)
|
||||
{
|
||||
Util.LogExceptions(ex);
|
||||
ReadInfoFile(infopath, termspath, exepath);
|
||||
//ReadInfoFile(infopath, termspath, exepath);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -111,8 +111,8 @@ namespace Novetus.Core
|
||||
#endregion
|
||||
|
||||
#region File Names
|
||||
public static readonly string ConfigName = "config.ini";
|
||||
public static string ConfigNameCustomization = "config_customization.ini";
|
||||
public static readonly string ConfigName = "config.json";
|
||||
public static string ConfigNameCustomization = "config_customization.json";
|
||||
public static readonly string InfoName = "info.ini";
|
||||
public static readonly string ScriptName = "CSMPFunctions";
|
||||
public static readonly string ScriptGenName = "CSMPBoot";
|
||||
|
Loading…
Reference in New Issue
Block a user