private TextLabel GetKeyLabel(Section section, Key key, int height) { TextLabel textLabel = new TextLabel(); textLabel.Text = ModSettingsData.FormattedName(mod.TryLocalize("Settings", section.Name, key.Name, "Name") ?? key.Name); textLabel.ShadowColor = Color.clear; textLabel.TextScale = textScale; textLabel.HorizontalAlignment = HorizontalAlignment.None; textLabel.Position = new Vector2(x, y + (float)(height - textLabel.TextHeight) / 2); textLabel.ToolTip = defaultToolTip; textLabel.ToolTipText = mod.TryLocalize("Settings", section.Name, key.Name, "Description") ?? key.Description; return textLabel; }
private TextLabel GetKeyLabel(Key key, int height) { TextLabel textLabel = new TextLabel(); textLabel.Text = ModSettingsData.FormattedName(key.Name); textLabel.ShadowColor = Color.clear; textLabel.TextScale = textScale; textLabel.HorizontalAlignment = HorizontalAlignment.None; textLabel.Position = new Vector2(x, y + (float)(height - textLabel.TextHeight) / 2); textLabel.ToolTip = defaultToolTip; textLabel.ToolTipText = key.Description; return(textLabel); }
private void AddSectionTitleLabel(Section section) { Panel background = new Panel(); background.Position = new Vector2(x, y - 0.5f); background.Size = new Vector2(columnWidth, 6.5f); AddAtNextPosition((int)background.Size.y, background); TextLabel textLabel = new TextLabel(DaggerfallUI.Instance.Font4); textLabel.Text = ModSettingsData.FormattedName(mod.TryLocalize("Settings", section.Name, "Name") ?? section.Name); textLabel.TextColor = section.IsAdvanced ? sectionTitleAdvColor : sectionTitleColor; textLabel.ShadowColor = section.IsAdvanced ? sectionTitleAdvShadow : sectionTitleShadow; textLabel.TextScale = 0.9f; textLabel.Position = new Vector2(0, 0.5f); textLabel.HorizontalAlignment = HorizontalAlignment.Center; background.Components.Add(textLabel); }
private void Keys_DrawElementCallback(Rect rect, int index, bool isActive, bool isFocused) { int line = 0; Section section = data.Sections[currentSection]; Key key = section[index]; if (!sectionExpanded[currentSection]) { EditorGUI.LabelField(LineRect(rect), ModSettingsData.FormattedName(key.Name)); SetKeySize(currentSection, index, lineHeight); return; } if (IsPreset) { using (new EditorGUI.DisabledScope(!CurrentPreset[section.Name])) { CurrentPreset[section.Name, key.Name] = EditorGUI.ToggleLeft(LineRect(rect, line++), key.Name, CurrentPreset[section.Name, key.Name]); EditorGUI.LabelField(LineRect(rect, line++), key.Description); } } else { key.Name = EditorGUI.TextField(LineRect(rect, line++), "Name", key.Name); key.Description = EditorGUI.TextField(LineRect(rect, line++), "Description", key.Description); } using (new EditorGUI.DisabledScope(IsPreset)) data.SetType(currentSection, index, ref key, (KeyType)EditorGUI.EnumPopup(LineRect(rect, line++), "UI Control", key.KeyType)); using (new EditorGUI.DisabledScope(IsPreset && !CurrentPreset[section.Name])) { rect.y += lineHeight * 3; int lines = key.OnEditorWindow( rect, (subrect, label, rects) => GUILayoutHelper.Horizontal(subrect, label, rects), (subrect, linesPerItem, rects) => GUILayoutHelper.Vertical(subrect, linesPerItem, rects), cache); SetKeySize(currentSection, index, (lines + 4) * lineHeight); } }
private void AddSectionTitleLabel(Section section) { Panel background = new Panel(); background.Position = new Vector2(x, y - 0.5f); background.Size = new Vector2(columnWidth, 6.5f); background.BackgroundColor = section.IsAdvanced ? backgroundTitleAdvColor : backgroundTitleColor; background.Outline.Enabled = true; background.Outline.Sides = Sides.Bottom; background.Outline.Color = section.IsAdvanced ? resetButtonColor : saveButtonColor; background.Outline.Thickness = 1; AddAtNextPosition((int)background.Size.y, background); TextLabel textLabel = new TextLabel(DaggerfallUI.Instance.Font5); textLabel.Text = ModSettingsData.FormattedName(mod.TryLocalize("Settings", section.Name, "Name") ?? section.Name); textLabel.TextColor = sectionTitleColor; textLabel.ShadowColor = sectionTitleShadow; textLabel.TextScale = 0.9f; textLabel.Position = new Vector2(0, 0.5f); textLabel.HorizontalAlignment = HorizontalAlignment.Center; background.Components.Add(textLabel); }
private void Keys_DrawHeaderCallback(Rect rect) { Section section = data.Sections[currentSection]; var style = new GUIStyle(EditorStyles.foldout); if (section.IsAdvanced) { style.normal.textColor = Color.red; } if (IsPreset) { var toggleRect = new Rect(rect.x, rect.y, EditorGUIUtility.singleLineHeight, EditorGUIUtility.singleLineHeight); CurrentPreset[section.Name] = EditorGUI.Toggle(toggleRect, CurrentPreset[section.Name]); rect.x += toggleRect.width; } if (!sectionExpanded.ContainsKey(currentSection)) { sectionExpanded.Add(currentSection, false); } sectionExpanded[currentSection] = EditorGUI.Foldout(LineRect(rect), sectionExpanded[currentSection], ModSettingsData.FormattedName(section.Name), style); }