private VObject ReadObject(VdfReader reader) { VObject result = new VObject(); if (!reader.ReadToken()) { throw new VdfException("Incomplete VDF data."); } while (!(reader.CurrentState == VdfReader.State.Object && reader.Value == VdfStructure.ObjectEnd.ToString())) { if (reader.CurrentState == VdfReader.State.Comment) { result.Add(VValue.CreateComment(reader.Value)); } else { result.Add(ReadProperty(reader)); } if (!reader.ReadToken()) { throw new VdfException("Incomplete VDF data."); } } return(result); }
static public VProperty InsertProxyIntoMaterial(dynamic Material, string parameter, List <string[]> proxyParameterArray) { VObject proxy = new VObject(); foreach (string[] proxyParameter in proxyParameterArray) { if (String.IsNullOrEmpty(proxyParameter[0]) || String.IsNullOrEmpty(proxyParameter[1])) { continue; } proxy.Add(proxyParameter[0], new VValue(proxyParameter[1])); } string proxyKeyName = CaseInsensitiveProxyCheck(Material); if (proxyKeyName == null) { proxyKeyName = "Proxies"; VObject proxies = new VObject(); Material.Value[proxyKeyName] = proxies; } if (Material.Value[proxyKeyName].ContainsKey(parameter)) { Material.Value[proxyKeyName].Add(new VProperty(parameter, proxy)); } else { Material.Value[proxyKeyName][parameter] = proxy; } return(Material); }
public override object ConstructObject() { var vobj = new VObject(); int i = CurrObj; foreach (var k in Inputs.Keys) { vobj.Add(k, Inputs[k][i]); } return(vobj); }
public static VObject ToVdf(this JArray arr) { VObject resultObj = new VObject(); for (int index = 0; index < arr.Count; index++) { resultObj.Add(index.ToString(), arr[index].ToVdf()); } return(resultObj); }
public static VObject ToVdf(this JObject obj) { VObject resultObj = new VObject(); foreach (JToken tok in obj.Children()) { resultObj.Add((VProperty)tok.ToVdf()); } return(resultObj); }
public List <SteamLaunchableModSource> GetSourceMods() { // source mods List <SteamLaunchableModSource> SourceMods = new List <SteamLaunchableModSource>(); { string sourceMods = SteamProcessInfo.GetSourceModPath(); if (Directory.Exists(sourceMods)) { Directory.GetDirectories(sourceMods) .Where(dr => File.Exists(Path.Combine(dr, "gameinfo.txt"))) .ToList().ForEach(dr => { VObject rootObj = new VObject(); rootObj.Add(VdfConvert.Deserialize(File.ReadAllText(Path.Combine(dr, "gameinfo.txt")))); VObject GameInfoObj = (VObject)rootObj["GameInfo"]; VObject FileSystemObj = (VObject)GameInfoObj["FileSystem"]; VToken appID = FileSystemObj["SteamAppId"]; UInt32 appIdCheck = 0; if (!UInt32.TryParse(appID.ToString(), out appIdCheck)) { return; } if (appIdCheck == 0) { return; } string AppInstallDir = SteamApps.GetAppInstallDir(appIdCheck); if (!string.IsNullOrWhiteSpace(AppInstallDir)) { SteamLaunchableModSource mod = SteamLaunchableModSource.Make(appIdCheck, dr, rootObj); if (mod != null) { SourceMods.Add(mod); } } }); } } return(SourceMods); }
private static int XmlToVdf(string xmlFile, string vdfFile) { try { Dictionary <string, Achievement> achievements = new Dictionary <string, Achievement>(); string language = null; string achId = ""; // Read the XML and get the achievements XmlReader xml = XmlReader.Create(xmlFile); while (xml.Read()) { if (xml.NodeType != XmlNodeType.Element) { continue; } if (language == null) { xml.MoveToAttribute("language"); language = xml.Value; } else { if (xml.HasAttributes) { xml.MoveToAttribute("key"); achId = xml.Value; achievements.Add(achId, new Achievement()); } else { string name = xml.Name; string value = xml.ReadString(); if (name == "name") { achievements[achId].Name = value; } else { achievements[achId].Description = value; } } } } // Now write everything in the VDF VProperty root = new VProperty(); root.Key = "lang"; VObject obj = new VObject(); obj.Add("Language", new VValue(language)); VObject tokens = new VObject(); foreach (var ach in achievements) { tokens.Add(ach.Key + "_NAME", new VValue(ach.Value.Name)); tokens.Add(ach.Key + "_DESC", new VValue(ach.Value.Description)); } obj.Add("Tokens", tokens); VProperty propTokens = new VProperty() { Key = "Tokens", Value = new VValue(tokens) }; root.Value = obj; string result = VdfConvert.Serialize(root); File.WriteAllText(vdfFile, result); return(0); } catch (Exception e) { Console.WriteLine(e); return(1); } }