public AICChange(string title, AICCollection coll, bool enabledDefault = false, bool isIntern = false) : base(title, ChangeType.AIC, enabledDefault, false) { this.NoLocalization = true; this.collection = coll; this.intern = isIntern; string descrIdent = title + isIntern; // set localized description, if it's empty seek a non-empty description var header = collection.Header; string descr = header.DescrByIndex(Localization.LanguageIndex); if (string.IsNullOrWhiteSpace(descr)) { foreach (int index in Localization.IndexLoadOrder) { descr = header.DescrByIndex(index); if (!string.IsNullOrWhiteSpace(descr)) { break; } } } this.headerKey = descrIdent + "_descr"; Localization.Add(headerKey, descr); this.Add(new DefaultHeader(descrIdent, true)); }
public void OnGUI() { key = EditorGUILayout.TextField("Key:", key); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Value:", GUILayout.MaxWidth(50)); EditorStyles.textArea.wordWrap = true; value = EditorGUILayout.TextArea(value, EditorStyles.textArea, GUILayout.ExpandHeight(true), GUILayout.Width(400)); EditorGUILayout.EndHorizontal(); if (Localization.GetLocalizedValue(key) == key) { if (GUILayout.Button("Add")) { Localization.Add(key, value); Close(); } } else { if (GUILayout.Button("Edit")) { if (EditorUtility.DisplayDialog($"Edit key '{key}'", $"This will edit '{key}' from the localization", "Sure", "Cancel")) { Localization.Edit(key, value); Close(); } } } minSize = new Vector2(460, 250); maxSize = minSize; }
public void TestClilocAsParameter() { Localization.Add("enu", 500002, "This tests ~1_NUMBER~ as parameters."); Localization.Add("enu", 500003, "clilocs"); string numericFormatter = Localization.Format(500002, "enu", $"{500003:#}"); string stringParam = Localization.Format(500002, "enu", $"{"#500003"}"); Assert.Equal("This tests clilocs as parameters.", numericFormatter); Assert.Equal("This tests clilocs as parameters.", stringParam); }
public AICChange(string title, AICCollection coll, bool enabledDefault = false, bool isIntern = false) : base(title, ChangeType.AIC, enabledDefault, false) { this.NoLocalization = true; this.collection = coll; this.intern = isIntern; string descrIdent = title + isIntern; string descr = collection.Header.DescrByIndex(Localization.LanguageIndex); this.headerKey = descrIdent + "_descr"; Localization.Add(headerKey, descr); this.Add(new DefaultHeader(descrIdent, true)); }
public override void InitUI() { string descr = GetLocalizedDescription(this.TitleIdent); descr = descr == String.Empty ? this.TitleIdent.Substring(4) : descr; Localization.Add(this.TitleIdent + "_descr", descr); base.InitUI(); this.titleBox.Background = new SolidColorBrush(Colors.White); if (!this.resFolder.StartsWith("UCP.AIV")) { ((TextBlock)this.titleBox.Content).Text = this.TitleIdent.Substring(4); } this.IsChecked = selectedChange.Equals(this.TitleIdent); this.titleBox.IsChecked = selectedChange.Equals(this.TitleIdent); if (this.IsChecked) { activeChange = this; } }
public override void InitUI() { Localization.Add(this.TitleIdent + "_descr", this.description); base.InitUI(); if (this.IsChecked) { activeChange = this; } ((TextBlock)this.titleBox.Content).Text = this.TitleIdent.Substring(4).StartsWith("UCP.") ? this.TitleIdent.Substring(4).Replace("UCP.", "") : this.TitleIdent.Substring(4); if (this.IsValid == false) { ((TextBlock)this.titleBox.Content).TextDecorations = TextDecorations.Strikethrough; this.titleBox.IsEnabled = false; this.titleBox.ToolTip = this.description; ((TextBlock)this.titleBox.Content).Foreground = new SolidColorBrush(Color.FromRgb(255, 0, 0)); } else { this.titleBox.IsChecked = selectedChange.Equals(this.TitleIdent); } this.titleBox.Background = this.TitleIdent.Substring(4).StartsWith("UCP.") ? new SolidColorBrush(Colors.White) : new SolidColorBrush(Colors.Bisque); if (this.TitleIdent.Substring(4).StartsWith("UCP.")) { Button exportButton = new Button() { //Width = 40, Height = 20, Content = Localization.Get("ui_aicexport"), HorizontalAlignment = HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Bottom, Margin = new Thickness(0, 0, 5, 5), }; exportButton.Click += (s, e) => this.ExportFile(); grid.Height += 15; this.grid.Children.Add(exportButton); } }
public override void InitUI() { Localization.Add(this.TitleIdent.Substring(4) + "_descr", this.description); base.InitUI(); if (this.IsChecked) { activeChange = this; } ((TextBlock)this.titleBox.Content).Text = this.TitleIdent.Substring(4); if (this.IsValid == false) { ((TextBlock)this.titleBox.Content).TextDecorations = TextDecorations.Strikethrough; this.titleBox.IsEnabled = false; this.titleBox.ToolTip = this.description; ((TextBlock)this.titleBox.Content).Foreground = new SolidColorBrush(Color.FromRgb(255, 0, 0)); } else { this.titleBox.IsChecked = selectedChange.Equals(this.TitleIdent); } }
string GetString(string name, CultureInfo cultureInfo = null) { if (name == null) { throw new ArgumentNullException(nameof(name)); } if (cultureInfo == null) { cultureInfo = CultureInfo.CurrentUICulture; } var item = Localization.FirstOrDefault(x => x.Key == name); string value = name; if (item == null) { Localization.Add(new JsonLocalizationFormat { Key = name, Values = new Dictionary <string, string> { { cultureInfo.Name, name } } }); SaveItems(); } else { if (item.Values.TryGetValue(cultureInfo.Name, out value)) { return(value); } item.Values[cultureInfo.Name] = name; SaveItems(); } return(value); }
/// <summary> /// Initialize the UI of the Change including titleBox (checkbox), titleBox.Content (AIC title), saving localized description. /// The titleBox object for built-in AICs is coloured white (unlike beige for user-loaded) /// Built-in AICs have an export option available /// </summary> public override void InitUI() { string descr = GetLocalizedDescription(this.collection); descr = descr == String.Empty ? this.TitleIdent : descr; Localization.Add(this.TitleIdent + "_descr", descr); this.titleBox = new CheckBox() { Content = new TextBlock() // Define title of AIC { Text = internalAIC.Contains(this.TitleIdent.Substring(4)) ? this.TitleIdent.Substring(4).Replace("UCP.", "") : this.TitleIdent.Substring(4), TextDecorations = this.GetTitle().EndsWith(".aic") ? TextDecorations.Strikethrough : null, TextWrapping = TextWrapping.Wrap, Margin = new Thickness(0, -1, 0, 0), FontSize = 14, Width = 400, }, IsChecked = currentSelection.ContainsValue(this.TitleIdent), IsEnabled = !this.GetTitle().EndsWith(".aic"), Background = internalAIC.Contains(this.TitleIdent.Substring(4)) ? new SolidColorBrush(Colors.White) : new SolidColorBrush(Colors.Bisque) }; TreeViewItem tvi = new TreeViewItem() { IsExpanded = false, Focusable = false, Header = titleBox, MinHeight = 22, }; // Add custom handlers for tracking selected AIC files and AI Character definitions to use titleBox.Checked += TitleBox_Checked; titleBox.Unchecked += TitleBox_Unchecked; grid = new Grid() { Background = new SolidColorBrush(Color.FromArgb(150, 200, 200, 200)), Width = 420, Margin = new Thickness(-18, 5, -1, -1), Focusable = false, }; FillGrid(grid); tvi.Items.Add(grid); tvi.Items.Add(null); // spacing Grid panel = new Grid(); panel.Children.Add(tvi); panel.Margin = new Thickness(-20, 0, 0, 0); // Render warning with option to convert outdated .aic files to the newer JSON format if (this.GetTitle().EndsWith(".aic")) { Button infoButton = new Button() { ToolTip = Localization.Get("ui_aicoldversion"), Width = 17, Height = 17, Content = "!", FontSize = 10, FontWeight = FontWeights.Bold, HorizontalAlignment = HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Top, Margin = new Thickness(0, 0, 45, 0), Background = new SolidColorBrush(Color.FromRgb(246, 53, 53)), }; infoButton.Click += (s, e) => { MessageBoxResult result = MessageBox.Show(Localization.Get("ui_aicofferconvert"), Localization.Get("ui_aicconvertprompt"), MessageBoxButton.YesNo, MessageBoxImage.Question); switch (result) { case MessageBoxResult.Yes: ConvertAIC(); break; default: break; } }; panel.Children.Add(infoButton); } else { // Create warning button for indicating AIC conflicts - only visible when conflicts are present this.conflict = new Button() { ToolTip = Localization.Get("ui_aicconflict"), Width = 17, Height = 17, Content = "!", FontSize = 10, FontWeight = FontWeights.Bold, HorizontalAlignment = HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Top, Margin = new Thickness(0, 0, 45, 0), Background = new SolidColorBrush(Color.FromRgb(255, 255, 0)), Visibility = Visibility.Hidden }; panel.Children.Add(conflict); } // Add export button for built-in AICs if (internalAIC.Contains(this.TitleIdent.Substring(4))) { Button exportButton = new Button() { //Width = 40, Height = 20, Content = Localization.Get("ui_aicexport"), HorizontalAlignment = HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Bottom, Margin = new Thickness(0, 0, 5, 5), ToolTip = Localization.Get("ui_aichint"), }; exportButton.Click += (s, e) => this.ExportFile(); grid.Height += 15; this.grid.Children.Add(exportButton); } this.uiElement = panel; }