public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value == null) { return(false); } return(ExtMethods.PathIsEftServerBase(value.ToString()) && ExtMethods.ServerHaveProfiles(value.ToString())); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value == null) { return(Visibility.Visible); } return(ExtMethods.PathIsEftServerBase(value.ToString()) ? Visibility.Collapsed : Visibility.Visible); }
public static MainData Load() { if (!Directory.Exists(LangPath)) { Directory.CreateDirectory(LangPath); } if (!File.Exists(Path.Combine(LangPath, "en.json"))) { File.WriteAllText(Path.Combine(LangPath, "en.json"), JsonConvert.SerializeObject(EN, Formatting.Indented)); } if (!File.Exists(Path.Combine(LangPath, "ru.json"))) { File.WriteAllText(Path.Combine(LangPath, "ru.json"), JsonConvert.SerializeObject(RU, Formatting.Indented)); } if (!File.Exists(Path.Combine(LangPath, "fr.json"))) { File.WriteAllText(Path.Combine(LangPath, "fr.json"), JsonConvert.SerializeObject(FR, Formatting.Indented)); } if (!File.Exists(Path.Combine(LangPath, "ge.json"))) { File.WriteAllText(Path.Combine(LangPath, "ge.json"), JsonConvert.SerializeObject(GE, Formatting.Indented)); } PEOptions eOptions = CreateOptions(); if (string.IsNullOrEmpty(eOptions.Language)) { eOptions.Language = "en"; } Dictionary <string, string> Locale = JsonConvert.DeserializeObject <Dictionary <string, string> >(File.ReadAllText(Path.Combine(LangPath, eOptions.Language + ".json"))); Dictionary <string, string> Eth = new Dictionary <string, string>(); switch (eOptions.Language) { case "en": Eth = EN; break; case "ge": Eth = GE; break; case "ru": Eth = RU; break; case "fr": Eth = FR; break; } bool needReSave = false; foreach (var lc in Eth) { if (!Locale.ContainsKey(lc.Key)) { Locale.Add(lc.Key, lc.Value); needReSave = true; } } if (needReSave) { File.WriteAllText(Path.Combine(LangPath, $"{eOptions.Language}.json"), JsonConvert.SerializeObject(Locale, Formatting.Indented)); } MainData lang = new MainData { locale = Locale, options = eOptions, characterInventory = new CharacterInventory { Rubles = 0, Euros = 0, Dollars = 0 } }; if (!string.IsNullOrEmpty(eOptions.EftServerPath) && !ExtMethods.PathIsEftServerBase(eOptions.EftServerPath)) { eOptions.EftServerPath = null; } if (!string.IsNullOrEmpty(eOptions.DefaultProfile) && !string.IsNullOrEmpty(eOptions.EftServerPath) && !File.Exists(Path.Combine(eOptions.EftServerPath, "user\\profiles", eOptions.DefaultProfile, "character.json"))) { eOptions.DefaultProfile = null; } if (!string.IsNullOrEmpty(eOptions.EftServerPath) && ExtMethods.ServerHaveProfiles(eOptions.EftServerPath)) { lang.Profiles = Directory.GetDirectories(eOptions.EftServerPath + "\\user\\profiles").Select(x => Path.GetFileName(x)).ToList(); if (lang.Profiles.Count > 0 && (string.IsNullOrEmpty(eOptions.DefaultProfile) || !lang.Profiles.Contains(eOptions.DefaultProfile))) { eOptions.DefaultProfile = lang.Profiles.FirstOrDefault(); } } if (!string.IsNullOrEmpty(eOptions.EftServerPath) && !string.IsNullOrEmpty(eOptions.DefaultProfile)) { var Pr = JsonConvert.DeserializeObject <Character>(File.ReadAllText(Path.Combine(eOptions.EftServerPath, "user\\profiles", eOptions.DefaultProfile, "character.json"))); lang.Character = Pr; var storage = JsonConvert.DeserializeObject <Storage>(File.ReadAllText(Path.Combine(eOptions.EftServerPath, "user\\profiles", eOptions.DefaultProfile, "storage.json"))); // get user/profiles/ID/storage.data.suites to get the profile suites if (storage.data.Suites.Length > 0) { lang.Character.Suits = storage.data.Suites.ToList(); } //if (Pr.suits != null && Pr.suits.Count() > 0) lang.Character.Suits = Pr.suits.ToList(); } if (lang.Character != null && lang.Character.Info != null && lang.Character.Inventory != null && lang.Character.TraderStandings != null && lang.Character.Skills != null) { lang.ProfileHash = JsonConvert.SerializeObject(lang.Character).ToString().GetHashCode(); } return(lang); }