Exemple #1
0
        /// <summary>
        /// Creates the actual image that shows the checkbox graphically.
        /// </summary>
        /// <param name="checkbox">The parent object to add the image.</param>
        /// <param name="color">The color style for the box border.</param>
        /// <param name="actualSize">The actual check mark size, which will be updated if it
        /// is 0x0 to the default size.</param>
        /// <returns>The image reference to the checkmark image itself.</returns>
        private Image CreateCheckImage(GameObject checkbox, ColorStyleSetting color,
                                       ref Vector2 actualSize)
        {
            // Checkbox border (grr rule of only one Graphics per GO...)
            var checkBorder = PUIElements.CreateUI(checkbox, "CheckBorder");
            var borderImg   = checkBorder.AddComponent <Image>();

            borderImg.sprite = PUITuning.Images.CheckBorder;
            borderImg.color  = color.activeColor;
            borderImg.type   = Image.Type.Sliced;
            // Checkbox foreground
            var imageChild = PUIElements.CreateUI(checkbox, "CheckMark", true, PUIAnchoring.
                                                  Center, PUIAnchoring.Center);
            var checkImage = imageChild.AddComponent <Image>();

            checkImage.sprite         = PUITuning.Images.Checked;
            checkImage.preserveAspect = true;
            // Determine the checkbox size
            if (actualSize.x <= 0.0f || actualSize.y <= 0.0f)
            {
                var rt = imageChild.rectTransform();
                actualSize.x = LayoutUtility.GetPreferredWidth(rt);
                actualSize.y = LayoutUtility.GetPreferredHeight(rt);
            }
            imageChild.SetUISize(CheckSize, false);
            return(checkImage);
        }
Exemple #2
0
 internal DialogButton(string key, string text, string tooltip,
                       ColorStyleSetting backColor, TextStyleSetting foreColor)
 {
     this.backColor = backColor;
     this.key       = key;
     this.text      = text;
     this.tooltip   = tooltip;
     textColor      = foreColor;
 }
 static ModUpdateHandler()
 {
     COLOR_OUTDATED = ScriptableObject.CreateInstance <ColorStyleSetting>();
     COLOR_OUTDATED.inactiveColor = new Color(0.753f, 0.0f, 0.0f);
     COLOR_OUTDATED.activeColor   = new Color(1.0f, 0.0f, 0.0f);
     COLOR_OUTDATED.hoverColor    = new Color(1.0f, 0.0f, 0.0f);
     // Should be unreachable
     COLOR_OUTDATED.disabledColor          = COLOR_OUTDATED.disabledActiveColor =
         COLOR_OUTDATED.disabledhoverColor = new Color(0.706f, 0.549f, 0.549f);
     COLOR_UPDATED = ScriptableObject.CreateInstance <ColorStyleSetting>();
     COLOR_UPDATED.inactiveColor          = new Color(0.0f, 0.753f, 0.0f);
     COLOR_UPDATED.activeColor            = new Color(0.0f, 1.0f, 0.0f);
     COLOR_UPDATED.hoverColor             = new Color(0.0f, 1.0f, 0.0f);
     COLOR_UPDATED.disabledColor          = COLOR_UPDATED.disabledActiveColor =
         COLOR_UPDATED.disabledhoverColor = new Color(0.549f, 0.706f, 0.549f);
     Instance = new ModUpdateHandler();
 }
Exemple #4
0
 public static void OnLoad()
 {
     FinishBlock                     = null;
     FinishColor                     = ScriptableObject.CreateInstance <ColorStyleSetting>();
     FinishColor.activeColor         = new Color(0.6f, 1.0f, 0.6f, 1.0f);
     FinishColor.inactiveColor       = new Color(0.286f, 1.0f, 0.286f, 1.0f);
     FinishColor.disabledColor       = new Color(0.4f, 0.416f, 0.4f, 1.0f);
     FinishColor.disabledActiveColor = new Color(0.588f, 0.625f, 0.588f, 1.0f);
     FinishColor.hoverColor          = new Color(0.6f, 1.0f, 0.6f, 1.0f);
     FinishColor.disabledhoverColor  = new Color(0.46f, 0.5f, 0.46f, 1.0f);
     FinishTask = null;
     Work       = null;
     PUtil.InitLibrary();
     LocString.CreateLocStringKeys(typeof(FinishTasksStrings.DUPLICANTS));
     LocString.CreateLocStringKeys(typeof(FinishTasksStrings.UI));
     PLocalization.Register();
 }
Exemple #5
0
        private static KButton MakeModsButton(KButton buttonPrefab, GameObject buttonParent,
                                              ColorStyleSetting colorStyle)
        {
            var button = Util.KInstantiateUI <KButton>(buttonPrefab.gameObject,
                                                       buttonParent, true);

            button.onClick += Mods;
            var image = button.GetComponent <KImage>();

            image.colorStyleSetting = colorStyle;
            image.ApplyColorStyleSetting();
            var text = button.GetComponentInChildren <LocText>();

            text.text     = "MODS [!]";
            text.fontSize = 14.0f;
            return(button);
        }
 public override void OnLoad(Harmony harmony)
 {
     base.OnLoad(harmony);
     FinishBlock                     = null;
     FinishColor                     = ScriptableObject.CreateInstance <ColorStyleSetting>();
     FinishColor.activeColor         = new Color(0.8f, 0.6f, 1.0f, 1.0f);
     FinishColor.inactiveColor       = new Color(0.5f, 0.286f, 1.0f, 1.0f);
     FinishColor.disabledColor       = new Color(0.4f, 0.4f, 0.416f, 1.0f);
     FinishColor.disabledActiveColor = new Color(0.6f, 0.588f, 0.625f, 1.0f);
     FinishColor.hoverColor          = FinishColor.activeColor;
     FinishColor.disabledhoverColor  = new Color(0.48f, 0.46f, 0.5f, 1.0f);
     FinishTask = null;
     Work       = null;
     PUtil.InitLibrary();
     LocString.CreateLocStringKeys(typeof(FinishTasksStrings.DUPLICANTS));
     LocString.CreateLocStringKeys(typeof(FinishTasksStrings.UI));
     new PLocalization().Register();
     new PVersionCheck().Register(this, new SteamVersionChecker());
 }
Exemple #7
0
        /// <summary>
        /// Generates the checkbox image states.
        /// </summary>
        /// <param name="imageColor">The color style for the checked icon.</param>
        /// <returns>The states for this checkbox.</returns>
        private static ToggleState[] GenerateStates(ColorStyleSetting imageColor)
        {
            // Structs sadly do not work well with detours
            var sps = new StatePresentationSetting()
            {
                color          = imageColor.activeColor, use_color_on_hover = true,
                color_on_hover = imageColor.hoverColor, image_target = null,
                name           = "Partial"
            };

            return(new ToggleState[] {
                new ToggleState()
                {
                    // Unchecked
                    color = PUITuning.Colors.Transparent, color_on_hover = PUITuning.Colors.
                                                                           Transparent, sprite = null, use_color_on_hover = false,
                    additional_display_settings = new StatePresentationSetting[] {
                        new StatePresentationSetting()
                        {
                            color = imageColor.activeColor, use_color_on_hover = false,
                            image_target = null, name = "Unchecked"
                        }
                    }
                },
                new ToggleState()
                {
                    // Checked
                    color = imageColor.activeColor, color_on_hover = imageColor.hoverColor,
                    sprite = PUITuning.Images.Checked, use_color_on_hover = true,
                    additional_display_settings = new StatePresentationSetting[] { sps }
                },
                new ToggleState()
                {
                    // Partial
                    color = imageColor.activeColor, color_on_hover = imageColor.hoverColor,
                    sprite = PUITuning.Images.Partial, use_color_on_hover = true,
                    additional_display_settings = new StatePresentationSetting[] { sps }
                }
            });
        }
Exemple #8
0
        /// <summary>
        /// Builds a row selection prefab object for this combo box.
        /// </summary>
        /// <param name="style">The text style for the entries.</param>
        /// <param name="entryColor">The color for the entry backgrounds.</param>
        /// <returns>A template for each row in the dropdown.</returns>
        private GameObject BuildRowPrefab(TextStyleSetting style, ColorStyleSetting entryColor)
        {
            var im        = ItemMargin;
            var rowPrefab = PUIElements.CreateUI(null, "RowEntry");
            // Background of the entry
            var bgImage = rowPrefab.AddComponent <KImage>();

            UIDetours.COLOR_STYLE_SETTING.Set(bgImage, entryColor);
            UIDetours.APPLY_COLOR_STYLE.Invoke(bgImage);
            // Checkmark for the front of the entry
            var isSelected = PUIElements.CreateUI(rowPrefab, "Selected");
            var fgImage    = isSelected.AddComponent <Image>();

            fgImage.color          = style.textColor;
            fgImage.preserveAspect = true;
            fgImage.sprite         = PUITuning.Images.Checked;
            // Button for the entry to select it
            var entryButton = rowPrefab.AddComponent <KButton>();

            PButton.SetupButton(entryButton, bgImage);
            UIDetours.FG_IMAGE.Set(entryButton, fgImage);
            // Tooltip for the entry
            rowPrefab.AddComponent <ToolTip>();
            // Text for the entry
            var textContainer = PUIElements.CreateUI(rowPrefab, "Text");

            PUIElements.AddLocText(textContainer, style).SetText(" ");
            // Configure the entire layout in 1 statement! (jk this is awful)
            var group = rowPrefab.AddComponent <RelativeLayoutGroup>();

            group.AnchorYAxis(isSelected).OverrideSize(isSelected, CheckSize).SetLeftEdge(
                isSelected, fraction: 0.0f).SetMargin(isSelected, im).AnchorYAxis(
                textContainer).SetLeftEdge(textContainer, toRight: isSelected).SetRightEdge(
                textContainer, 1.0f).SetMargin(textContainer, new RectOffset(0, im.right,
                                                                             im.top, im.bottom)).LockLayout();
            rowPrefab.SetActive(false);
            return(rowPrefab);
        }
Exemple #9
0
 /// <summary>
 /// Adds a button to the dialog.
 /// </summary>
 /// <param name="key">The key to report if this button is selected.</param>
 /// <param name="text">The button text.</param>
 /// <param name="tooltip">The tooltip to display on the button (optional)</param>
 /// <param name="backColor">The background color to use for the button. If null or
 /// omitted, the last button will be pink and all others will be blue.</param>
 /// <param name="foreColor">The foreground color to use for the button. If null or
 /// omitted, white text with the default game UI font will be used.</param>
 /// <returns>This dialog for call chaining.</returns>
 public PDialog AddButton(string key, string text, string tooltip = null,
                          ColorStyleSetting backColor             = null, TextStyleSetting foreColor = null)
 {
     buttons.Add(new DialogButton(key, text, tooltip, backColor, foreColor));
     return(this);
 }
 public void SetColorStyle(ColorStyleSetting style)
 {
     colorStyleSetting = style;
     RefreshColorStyle();
     ResetColor();
 }
Exemple #11
0
 internal static void Postfix(KButton ___buttonPrefab, GameObject ___buttonParent,
                              ColorStyleSetting ___normalButtonStyle)
 {
     MakeModsButton(___buttonPrefab, ___buttonParent, ___normalButtonStyle);
 }