////////////////

        public UIObjective(Objective objective) : base(UITheme.Vanilla, false)
        {
            this.Objective = objective;

            this.Width.Set(0f, 1f);
            this.Height.Set(80f, 0f);

            //

            this.TitleElem           = new UIThemedText(this.Theme, false, this.Objective.Title, true, 1.1f);
            this.TitleElem.TextColor = Color.Yellow;
            this.TitleElem.Width.Set(0f, 1f);
            this.Append(this.TitleElem);

            this.DescriptionElem           = new UIThemedText(this.Theme, false, this.Objective.Description, true, 0.8f);
            this.DescriptionElem.TextColor = Color.White;
            this.DescriptionElem.Top.Set(24f, 0f);
            this.DescriptionElem.Width.Set(0f, 1f);
            this.Append(this.DescriptionElem);

            //

            if (this.Objective.IsImportant)
            {
                this.BackgroundColor = new Color(64, 64, 48);
                this.BorderColor     = new Color(96, 96, 64);
            }
        }
Example #2
0
        ////////////////

        private void InitializeTitle(UIElement container, string title, bool isNewLine, ref float yOffset)
        {
            var textElem = new UIThemedText(UITheme.Vanilla, false, title);

            textElem.Top.Set(yOffset, 0f);

            if (isNewLine)
            {
                yOffset += 28f;
            }

            container.Append((UIElement)textElem);
        }
Example #3
0
        public override void InitializeComponents()
        {
            float yOffset = 0f;

            // UI Header
            var textElem = new UIThemedText(UITheme.Vanilla, false, "Adjust Hologram", 1f, true);

            this.InnerContainer.Append((UIElement)textElem);

            yOffset += 50f;

            this.InitializeTabButtons(ref yOffset);

            this.TabStartInnerHeight = yOffset;

            //

            this.InitializeTabContainers(yOffset, out this.MainTabContainer, out this.ColorTabContainer, out this.ShaderTabContainer);

            this.InitializeMainTab(this.MainTabContainer);
            this.InitializeColorTab(this.ColorTabContainer);
            this.InitializeShadersTab(this.ShaderTabContainer);

            this.MainTabHeight   = this.MainTabContainer.Height.Pixels;
            this.ColorTabHeight  = this.ColorTabContainer.Height.Pixels;
            this.ShaderTabHeight = this.ShaderTabContainer.Height.Pixels;

            yOffset += this.MainTabHeight;

            // Apply button
            this.ApplyButton = new UITextPanelButton(UITheme.Vanilla, "Apply");
            this.ApplyButton.Top.Set(-22f, 1f);
            this.ApplyButton.Left.Set(-52f, 1f);
            this.ApplyButton.OnClick += (_, __) => {
                this.Close();
                this.ApplySettingsToCurrentItem();
            };
            this.InnerContainer.Append((UIElement)this.ApplyButton);

            yOffset += this.ApplyButton.GetOuterDimensions().Height;

            //

            this.FullDialogHeight = yOffset + 24f;

            //

            this.SwitchTab(HologramUITab.Main);
        }
Example #4
0
        public DialogueChoices(
            string dialogue,
            Texture2D portrait,
            int height,
            IList <string> choices,
            Action <string> onChoice)
        {
            if (Main.netMode == NetmodeID.Server)
            {
                return;
            }

            var singleton = ModContent.GetInstance <DialogueChoices>();

            this.DialogueElem = singleton.DialogueElem;
            this.PortraitElem = singleton.PortraitElem;
            this.TextElem     = singleton.TextElem;

            this.TextElem.SetText(dialogue);
            this.PortraitElem.SetImage(portrait);
            this.DialogueElem.Height.Set(height, 0f);

            int i = 0;

            foreach (string choice in choices)
            {
                string thisChoice = choice;
                var    choiceElem = new UITextPanelButton(UITheme.Vanilla, thisChoice);
                choiceElem.Left.Set(i * 96f, 0f);
                choiceElem.Top.Set(-40f, 1f);
                choiceElem.Width.Set(96f, 0f);
                choiceElem.OnClick += (_, __) => {
                    onChoice(thisChoice);
                };
                this.DialogueElem.AppendThemed(choiceElem);

                this.ChoiceButtons.Add(choiceElem);
                i++;
            }

            this.DialogueElem.Recalculate();
            this.DialogueElem.Show();
            this.DialogueElem.Recalculate();
        }
Example #5
0
        ////

        private void InitializeCoinInput(
            string hint,
            Color color,
            Func <int, bool> valueFunc,
            ref float xOffset,
            ref float yOffset)
        {
            var titleElem = new UIThemedText(this.Theme, false, hint);

            titleElem.Left.Set(xOffset, 0f);
            titleElem.Top.Set(yOffset, 0f);
            this.AppendThemed(titleElem);

            var inputElem = new UITextInputAreaPanel(this.Theme, "", 2);

            inputElem.Left.Set(xOffset, 0f);
            inputElem.Top.Set(yOffset + 28f, 0f);
            inputElem.Width.Set(96f, 0f);
            inputElem.Height.Pixels = 36f;
            //inputElem.SetPadding( 0f );
            inputElem.HAlign = 0f;
            inputElem.SetTextDirect("0");
            inputElem.TextColor        = color;
            inputElem.OnPreTextChange += strBuild => {
                string str = strBuild.ToString();
                if (str == "")
                {
                    return(true);
                }
                return(this.ProcessCoinInput(str, valueFunc, out string _));
            };
            inputElem.OnUnfocus += () => {
                if (!this.ProcessCoinInput(inputElem.Text, valueFunc, out string output))
                {
                    inputElem.SetTextDirect(output);
                }
            };
            this.AppendThemed(inputElem);
            this.Components.Add(inputElem);

            xOffset += 128f;
        }
Example #6
0
        ////////////////

        public override void OnInitialize()
        {
            var   logic   = PDYBWorld.PirateLogic;
            float xOffset = 8f;
            float yOffset = 0f;

            this.InitializeCoinInput(
                "Platinum coins",
                MiscHelpers.PlatinumCoinColor,
                v => this.SetValue(v, ItemID.PlatinumCoin),
                ref xOffset,
                ref yOffset);
            this.InitializeCoinInput(
                "Gold coins",
                MiscHelpers.GoldCoinColor,
                v => this.SetValue(v, ItemID.GoldCoin),
                ref xOffset,
                ref yOffset);
            this.InitializeCoinInput(
                "Silver coins",
                MiscHelpers.SilverCoinColor,
                v => this.SetValue(v, ItemID.SilverCoin),
                ref xOffset,
                ref yOffset);
            this.InitializeCoinInput(
                "Copper coins",
                MiscHelpers.CopperCoinColor,
                v => this.SetValue(v, ItemID.CopperCoin),
                ref xOffset,
                ref yOffset);

            yOffset += 72f;

            this.OfferButtonElem = new UITextPanelButton(this.Theme, "Test Offer");
            this.OfferButtonElem.Left.Set(8f, 0f);
            this.OfferButtonElem.Top.Set(yOffset, 0f);
            this.OfferButtonElem.OnClick += (_, __) => {
                foreach (var toggleable in this.Components)
                {
                    var input = toggleable as UITextInputAreaPanel;
                    if (input?.HasFocus ?? false)
                    {
                        input.Unfocus();
                    }
                }
                this.MakeOffer();
            };

            string unit  = PirateLogic.GetHighestCoinTypeOfGivenDemand(logic.ComputedDemand, out bool tensOf);
            string range = tensOf ? "10-99" : "0-10";

            var titleElem = new UIThemedText(this.Theme, false, "Pirate hints at " + range + " " + unit);

            titleElem.Left.Set(-256f, 1f);
            titleElem.Top.Set(yOffset, 0f);
            this.AppendThemed(titleElem);

            this.AppendThemed(this.OfferButtonElem);
            this.Components.Add(this.OfferButtonElem);

            this.Close();
        }