public void DrawItems() { if (!metaTarget) { EditorGUILayout.HelpBox("BerryStoreAssistant is missing", MessageType.Error); return; } main = (BerryStoreAssistant)metaTarget; Undo.RecordObject(main, ""); EditorGUILayout.BeginHorizontal(); GUILayout.Space(20); GUILayout.Label("Name", EditorStyles.centeredGreyMiniLabel, GUILayout.Width(80)); GUILayout.Label("ID", EditorStyles.centeredGreyMiniLabel, GUILayout.Width(60)); GUILayout.Label("Localiz. Name", EditorStyles.centeredGreyMiniLabel, GUILayout.Width(150)); GUILayout.Label("Localiz. Descipt.", EditorStyles.centeredGreyMiniLabel, GUILayout.Width(150)); EditorGUILayout.EndHorizontal(); foreach (BerryStoreAssistant.ItemInfo item in main.items) { EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("X", GUILayout.Width(20))) { main.items.Remove(item); break; } item.name = EditorGUILayout.TextField(item.name, GUILayout.Width(80)); item.id = EditorGUILayout.TextField(item.id, GUILayout.Width(60)); EditorGUILayout.LabelField(item.localization_name, GUILayout.Width(150)); EditorGUILayout.LabelField(item.localization_description, GUILayout.Width(150)); EditorGUILayout.EndHorizontal(); } EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Add", GUILayout.Width(60))) { main.items.Add(new BerryStoreAssistant.ItemInfo()); } if (GUILayout.Button("Edit Localization", GUILayout.Width(150))) { BerryPanel.CreateBerryPanel().EditLocalization("item_"); } EditorGUILayout.EndHorizontal(); }
public override void OnInspectorGUI() { if (!metaTarget) { EditorGUILayout.HelpBox("LocalizationAssistant is missing", MessageType.Error); return; } main = (LocalizationAssistant)metaTarget; Undo.RecordObject(main, "localization changings"); if (main.languages.Count == 0) { main.languages.Add(SystemLanguage.English); } EditorGUILayout.BeginVertical(EditorStyles.textArea, GUILayout.ExpandWidth(true)); main.use_system_language_by_default = GUILayout.Toggle(main.use_system_language_by_default, "Use system language by default"); if (!main.use_system_language_by_default) { List <string> languages = main.languages.Select(x => x.ToString()).ToList(); int id = languages.IndexOf(main.default_language.ToString()); if (id < 0) { id = 0; } id = EditorGUILayout.Popup("Default language", id, languages.ToArray()); main.default_language = (SystemLanguage)System.Enum.Parse(typeof(SystemLanguage), languages[id]); } EditorGUILayout.EndVertical(); EditorGUILayout.Space(); EditorGUILayout.BeginVertical(EditorStyles.textArea, GUILayout.ExpandWidth(true)); #region Languages list panel EditorGUILayout.BeginHorizontal(); GUILayout.Label("-", EditorStyles.centeredGreyMiniLabel, GUILayout.Width(20)); GUILayout.Label("Edit", EditorStyles.centeredGreyMiniLabel, GUILayout.Width(35)); GUILayout.Label("Name", EditorStyles.centeredGreyMiniLabel, GUILayout.Width(200)); EditorGUILayout.EndHorizontal(); foreach (SystemLanguage language in main.languages) { EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("X", GUILayout.Width(20))) { main.languages.Remove(language); break; } if (GUILayout.Button("Edit", GUILayout.Width(35))) { BerryPanel.CreateBerryPanel().EditLocalization(language); } EditorGUILayout.LabelField(language.ToString(), GUILayout.Width(200)); EditorGUILayout.EndHorizontal(); } #endregion EditorGUILayout.Space(); #region "Add new" panel EditorGUILayout.BeginHorizontal(); GUI.enabled = !main.languages.Contains(new_language); if (GUILayout.Button("Add", GUILayout.Width(40))) { main.languages.Add(new_language); } GUI.enabled = true; new_language = (SystemLanguage)EditorGUILayout.EnumPopup(new_language, GUILayout.Width(200)); EditorGUILayout.EndHorizontal(); #endregion EditorGUILayout.EndVertical(); }
void DrawCard(Issue issue) { Color color = GUI.backgroundColor; if (issue.isChecked || issue.isCached) { GUI.backgroundColor = Color.Lerp(color, (issue.isFixed || issue.isCached)? Color.green : Color.yellow, 0.3f); } if (issue.errors.Count > 0) { GUI.backgroundColor = Color.Lerp(color, Color.red, 0.3f); } EditorGUILayout.BeginVertical(EditorStyles.textArea, GUILayout.ExpandWidth(true)); GUI.backgroundColor = color; if (!string.IsNullOrEmpty(issue.alias)) { GUILayout.Label(string.Format("Alias: {0}", issue.alias), EditorStyles.boldLabel); } GUILayout.Label(string.Format("Issue #{0} ({1})", issue.number, issue.type), EditorStyles.boldLabel); EditorGUILayout.HelpBox(issue.desription, MessageType.None); List <string> messages = new List <string>(); if (issue.fixer != "" || issue.codefixes.Count > 0) { bool isLocked = !GUI.enabled; if (!isLocked) { messages.AddRange(issue.GetProblems()); if (messages.Count > 0) { GUI.enabled = false; } } if (!issue.isChecked) { if (GUILayout.Button("Check it", EditorStyles.miniButton, GUILayout.Width(80))) { issue.Check(); } } else if (!issue.isFixed) { messages.Add("Unfixed"); if (GUILayout.Button("Fix it", EditorStyles.miniButton, GUILayout.Width(80))) { issue.Fix(); } } else { messages.Add("Fixed"); } if (issue.isCached && !issue.isFixed) { messages.Add("Fixed (Cache)"); } if (messages.Count > 0) { GUILayout.Label(string.Join("\n", messages.ToArray()), EditorStyles.boldLabel); } GUI.enabled = !isLocked; } foreach (string error in issue.errors) { EditorGUILayout.HelpBox(error, MessageType.Error); } if (issue.filesReport.Count > 0) { if (GUILayout.Button("Report it", EditorStyles.miniButton, GUILayout.Width(80))) { new PrefVariable("ContactForm_Attachments").String = string.Join(";", issue.filesReport.ToArray()); new PrefVariable("ContactForm_AppealType").Int = (int)ContactForm.AppealType.BugReport; new PrefVariable("ContactForm_Subject").String = "Problem with Fixer"; new PrefVariable("ContactForm_Body").String = string.Format("Project: {0} v{1} ({2})\nFixer v{3}\nIssue #{4} ({5})\n{6}", project, project_version.ToString("F2"), sub, fixer_version.ToString("F2"), issue.number, issue.type, issue.desription); new PrefVariable("ContactForm_Log").String = string.Join("\n\n", issue.errors.ToArray()); BerryPanel panel = BerryPanel.CreateBerryPanel(); panel.editor = null; panel.editorTitle = "Contact"; } } EditorGUILayout.EndVertical(); }
public override void OnInspectorGUI() { if (EditorApplication.isCompiling) { StopDownloadIssues(); } if (downloader != null && !downloader.IsPlaying()) { downloader = null; } GUI.enabled = !EditorApplication.isCompiling && !EditorApplication.isPlaying; #region Toolbar 1 EditorGUILayout.BeginHorizontal(EditorStyles.toolbar); GUILayout.Label("Alias", EditorStyles.miniLabel); string _alias = EditorGUILayout.TextField(alias.String, EditorStyles.textField, GUILayout.Width(120)); if (_alias != alias.String) { alias.String = _alias; } GUILayout.FlexibleSpace(); if (!update_checked && GUILayout.Button("Check update", EditorStyles.toolbarButton, GUILayout.Width(90))) { EditorCoroutine.start(DownloadUpdate()); } if (!Berry.Contact.Contact.IsSending() && GUILayout.Button("Bug Report", EditorStyles.toolbarButton, GUILayout.Width(90))) { new PrefVariable("ContactForm_AppealType").Int = (int)ContactForm.AppealType.BugReport; BerryPanel panel = BerryPanel.CreateBerryPanel(); panel.editor = null; panel.editorTitle = "Contact"; } EditorGUILayout.EndHorizontal(); #endregion #region Info GUILayout.Label(string.Format("Project: {0} v{1} ({2}), Fixer Version: v{3}", project, project_version.ToString("F2"), sub, fixer_version.ToString("F2")), EditorStyles.centeredGreyMiniLabel); #endregion #region Update if (update_checked && new_fixer_version > 0) { if (new_fixer_version > fixer_version) { EditorGUILayout.HelpBox("Fixer v" + new_fixer_version.ToString("F2") + " is avaliable to install.", MessageType.Warning); if (GUILayout.Button("Install", EditorStyles.miniButton, GUILayout.Width(60))) { InstallUpdate(); } } else { EditorGUILayout.HelpBox("Last version of Fixer is installed.", MessageType.Info); } } #endregion #region Toolbar 2 EditorGUILayout.BeginHorizontal(EditorStyles.toolbar); status = (Status)EditorGUILayout.EnumPopup(status, EditorStyles.toolbarPopup, GUILayout.Width(100)); selected_type = EditorGUILayout.Popup(selected_type, issueTypes.ToArray(), EditorStyles.toolbarPopup, GUILayout.Width(100)); GUILayout.FlexibleSpace(); if (GUILayout.Button("Refresh", EditorStyles.toolbarButton, GUILayout.Width(60))) { DownloadIssues(); } if (GUILayout.Button("Check all", EditorStyles.toolbarButton, GUILayout.Width(73))) { foreach (List <Issue> list in Issue.all.Values) { foreach (Issue issue in list) { if (!issue.isChecked && issue.errors.Count == 0) { issue.Check(); } } } } EditorGUILayout.EndHorizontal(); #endregion if (downloader != null) { GUILayout.Label("Downloading...", EditorStyles.centeredGreyMiniLabel); } if (EditorApplication.isCompiling) { GUILayout.Label("Compiling...", EditorStyles.centeredGreyMiniLabel); } if (EditorApplication.isPlaying) { GUILayout.Label("Playing...", EditorStyles.centeredGreyMiniLabel); } bool visible; foreach (List <Issue> list in Issue.all.Values) { foreach (Issue issue in list) { visible = false; if (issueTypes.Count > 0 && issueTypes[selected_type] != issue.type && issueTypes[selected_type] != "All Types") { continue; } switch (status) { case Status.All: visible = true; break; case Status.Checked: visible = issue.isChecked && !issue.isFixed; break; case Status.Fixed: visible = issue.isFixed; break; case Status.Manual: visible = issue.fixer == "" && issue.codefixes.Count == 0; break; case Status.Problematic: visible = issue.errors.Count > 0; break; case Status.Unchecked: visible = !issue.isChecked; break; } if (!visible) { continue; } DrawCard(issue); } } GUI.enabled = true; }
public override void OnInspectorGUI() { Undo.RecordObject(main, "DinaLabel changes"); main.localized = EditorGUILayout.Toggle("Localized", main.localized); List <string> masks = new List <string>(); EditorGUILayout.BeginVertical(EditorStyles.textArea, GUILayout.Width(300)); EditorGUILayout.Space(); if (main.localized) { #region Localized settings if (!assistant) { EditorGUILayout.HelpBox("Localization Assistant is missing", MessageType.Error); } else { int id = LocalizationAssistantEditor.keys.IndexOf(main.key); if (id < 0) { id = 0; } EditorGUILayout.BeginHorizontal(); GUILayout.Label("key", GUILayout.Width(50)); id = EditorGUILayout.Popup(id, LocalizationAssistantEditor.keys_menu); EditorGUILayout.EndHorizontal(); main.key = LocalizationAssistantEditor.keys[id]; foreach (SystemLanguage language in assistant.languages) { EditorGUILayout.LabelField(language.ToString(), EditorStyles.miniLabel); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Edit", GUILayout.Width(40))) { BerryPanel.CreateBerryPanel().EditLocalization(language, main.key); } if (LocalizationAssistantEditor.content.ContainsKey(language) && (LocalizationAssistantEditor.content[language].ContainsKey(main.key))) { EditorGUILayout.HelpBox(LocalizationAssistantEditor.content[language][main.key], MessageType.None); masks.AddRange(GetMasks(LocalizationAssistantEditor.content[language][main.key])); } else { EditorGUILayout.HelpBox("", MessageType.None); } EditorGUILayout.EndHorizontal(); } } #endregion } else { #region Non localized settings main.text = EditorGUILayout.TextField("Text", main.text); masks.AddRange(GetMasks(main.text)); #endregion } EditorGUILayout.Space(); EditorGUILayout.EndVertical(); masks = masks.Distinct().ToList(); masks.Sort(); Dictionary <string, DinaLabel.Mask> _masks = main.masks.ToDictionary(x => x.key, x => x); foreach (string mask in masks) { if (!_masks.ContainsKey(mask)) { _masks.Add(mask, new DinaLabel.Mask(mask)); } } if (_masks.Count > 0) { main.update = EditorGUILayout.Toggle("Update", main.update); GUI.enabled = main.update; main.delay = EditorGUILayout.Slider("Delay", main.delay, 0.1f, 3f); GUI.enabled = true; } else { main.update = false; } #region Masks panel EditorGUILayout.BeginVertical(EditorStyles.textArea, GUILayout.MinWidth(300)); EditorGUILayout.BeginHorizontal(); GUILayout.Label("Key", EditorStyles.centeredGreyMiniLabel, GUILayout.Width(100)); GUILayout.Label("Value", EditorStyles.centeredGreyMiniLabel, GUILayout.Width(200)); EditorGUILayout.EndHorizontal(); foreach (string key in _masks.Keys.ToArray()) { if (!masks.Contains(key)) { _masks.Remove(key); } else { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(key, GUILayout.Width(100)); int id = mask_values.IndexOf(_masks[key].value); if (id < 0) { id = 0; } id = EditorGUILayout.Popup(id, mask_values.ToArray(), GUILayout.Width(200)); _masks[key].value = mask_values[id]; EditorGUILayout.EndHorizontal(); } } main.masks = _masks.Values.ToList(); EditorGUILayout.Space(); EditorGUILayout.EndVertical(); #endregion }