示例#1
0
 /// <summary>
 /// Handler for when UMM's settings GUI is hidden.
 /// </summary>
 internal void OnHideGUI()
 {
     if (Settings.IsEnabled)
     {
         Tweak.OnHideGUI();
     }
 }
示例#2
0
        /// <summary>
        /// Handler for adding this tweak's settings GUI to UMM's settings GUI.
        /// </summary>
        internal void OnGUI()
        {
            // Draw header
            GUILayout.BeginHorizontal();
            bool newIsExpanded = GUILayout.Toggle(
                Settings.IsExpanded,
                Settings.IsEnabled ? (Settings.IsExpanded ? "◢" : "▶") : "",
                new GUIStyle()
            {
                fixedWidth = 10,
                normal     = new GUIStyleState()
                {
                    textColor = Color.white
                },
                fontSize = 15,
                margin   = new RectOffset(4, 2, 6, 6),
            });
            bool newIsEnabled = GUILayout.Toggle(
                Settings.IsEnabled,
                Tweak.Name,
                new GUIStyle(GUI.skin.toggle)
            {
                fontStyle = GlobalSettings.Language == LanguageEnum.KOREAN
                        ? FontStyle.Normal
                        : FontStyle.Bold,
                font = GlobalSettings.Language == LanguageEnum.KOREAN
                        ? TweakAssets.KoreanBoldFont
                        : null,
                margin = new RectOffset(0, 4, 4, 4),
            });

            GUILayout.Label("-");
            GUILayout.Label(
                Tweak.Description,
                new GUIStyle(GUI.skin.label)
            {
                fontStyle = FontStyle.Italic
            });
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            // Handle enable/disable change
            if (newIsEnabled != Settings.IsEnabled)
            {
                Settings.IsEnabled = newIsEnabled;
                if (newIsEnabled)
                {
                    EnableTweak();
                    newIsExpanded = true;
                }
                else
                {
                    DisableTweak();
                }
            }

            // Handle expand/collapse change
            if (newIsExpanded != Settings.IsExpanded)
            {
                Settings.IsExpanded = newIsExpanded;
                if (!newIsExpanded)
                {
                    Tweak.OnHideGUI();
                }
            }

            // Draw custom options
            if (Settings.IsExpanded && Settings.IsEnabled)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Space(24f);
                GUILayout.BeginVertical();
                Tweak.OnSettingsGUI();
                GUILayout.EndVertical();
                GUILayout.EndHorizontal();
                GUILayout.Space(12f);
            }
        }