private SelectCategoryDescription([NotNull] string name, string description, string filter, string icon, double order) { Name = ContentUtils.Translate(name); Description = ContentUtils.Translate(description); Filter = filter ?? @"*"; Order = order; Icon = ContentUtils.GetIcon(icon ?? name + @".png", _type).Get(); Source = _source; }
public DisplayInputParams(JToken token) { switch (token) { case JArray tokenArray: _take = tokenArray.Count; _test = x => true; _name = x => x >= 0 && x < tokenArray.Count ? ContentUtils.Translate(tokenArray[x]?.ToString()) : null; break; case JObject tokenObject: _take = int.MaxValue; _test = x => tokenObject[x.ToInvariantString()] != null; _name = x => ContentUtils.Translate(tokenObject[x.ToInvariantString()]?.ToString()); break; default: _take = token?.Type == JTokenType.Integer ? (int)token : int.MaxValue; _test = x => true; _name = x => null; break; } }
public static bool Get([NotNull] string guid, out string displayName, out DisplayInputParams axes, out DisplayInputParams buttons, out DisplayInputParams povs) { var file = FilesStorage.Instance.GetContentFile(ContentCategory.Controllers, $"{guid}.json"); if (file.Exists) { try { var jData = JsonExtension.Parse(File.ReadAllText(file.Filename)); displayName = ContentUtils.Translate(jData.GetStringValueOnly("name")); axes = new DisplayInputParams(jData["axis"] ?? jData["axes"] ?? jData["axles"]); buttons = new DisplayInputParams(jData["buttons"]); povs = new DisplayInputParams(jData["pov"] ?? jData["povs"] ?? jData["pointOfViews"]); return(true); } catch (Exception e) { Logging.Warning(e); } } displayName = null; axes = null; buttons = null; povs = null; return(false); }
private OriginIconDescription([NotNull] string name, string authorFilter, string icon) { Name = ContentUtils.Translate(name); Icon = ContentUtils.GetIcon(icon ?? name + @".png", ContentCategory.OriginIcons, 16); _filter = Filter.Create(StringTester.Instance, authorFilter); }