Example #1
0
        public void RenderHint(UIHint hint)
        {
            Vector2?sizeBefore = null;

            if (LastHint != null)
            {
                sizeBefore = Size;
            }
            Caption = hint.Title + " (" + (HintNumber + 1) + " of " + Hints.Count + ")";
            Body    = hint.Body;

            if (hint != LastHint)
            {
                Icon.Texture?.Dispose();

                Icon.Texture = null;
                SetIcon(null, 0, 0);
                if (hint.Image != null && hint.Image != "")
                {
                    //try load the image for this hint
                    try
                    {
                        if (hint.Image.Length > 0 && hint.Image[0] == '@')
                        {
                            using (var strm = File.Open(Content.Content.Get().GetPath("uigraphics/hints/" + hint.Image.Substring(1)), FileMode.Open, FileAccess.Read, FileShare.Read))
                            {
                                var tex = ImageLoader.FromStream(GameFacade.GraphicsDevice, strm);
                                SetIcon(tex, tex.Width, tex.Height);
                            }
                        }
                        else
                        {
                            using (var strm = File.Open("Content/UI/hints/images/" + hint.Image, FileMode.Open, FileAccess.Read, FileShare.Read))
                            {
                                var tex = ImageLoader.FromStream(GameFacade.GraphicsDevice, strm);
                                SetIcon(tex, tex.Width, tex.Height);
                            }
                        }
                    }
                    catch (Exception)
                    {
                    }
                }
            }
            LastHint = hint;

            NextButton.Caption  = (HintNumber + 1 == Hints.Count) ? OKText : "Next";
            PrevButton.Disabled = HintNumber == 0;

            if (sizeBefore != null)
            {
                Position += (sizeBefore.Value - Size) / 2;
            }
            HideContainer.Y = PrevButton.Y + 5;
            HideContainer.AutoSize();
        }
Example #2
0
 public void ShowHint(UIHint hint)
 {
     if (HintAlert == null || HintAlert.Dead)
     {
         HintAlert = new UIHintAlert(hint);
         UIScreen.GlobalShowDialog(HintAlert, true);
     }
     else
     {
         HintAlert.AddHint(hint);
     }
 }
Example #3
0
        public UIHintAlert(UIHint hint) : base(new UIAlertOptions()
        {
            Title   = "Hint (0 of 0)",
            Width   = 700,
            Message = "",
            Buttons = new UIAlertButton[]
            {
                new UIAlertButton(UIAlertButtonType.Cancel, (btn) => { }, "Previous"),
                new UIAlertButton(UIAlertButtonType.OK, (btn) => { }),
            },
            AllowBB = true
        })
        {
            PrevButton = ButtonMap[UIAlertButtonType.Cancel];
            PrevButton.OnButtonClick += (btn) => HintAdvance(-1);

            NextButton = ButtonMap[UIAlertButtonType.OK];
            NextButton.OnButtonClick += (btn) => HintAdvance(1);
            OKText = NextButton.Caption;
            Hints  = new List <UIHint>()
            {
                hint
            };

            var formField = new UIHBoxContainer
            {
                X = 20
            };

            HideContainer = formField;
            Add(formField);

            var check = new UIButton(GetTexture(0x0000083600000001))
            {
                Tooltip = "Mark all hints as read. Hints added by future updates will still be shown."
            };

            check.OnButtonClick += x => {
                check.Selected = !check.Selected;
            };
            HideHintCheck = check;

            formField.Add(check);

            formField.Add(new UILabel
            {
                Caption = "Hide Hints"
            });

            Opacity = 1f;
            RenderHint();
        }
Example #4
0
        private void ComputeText(UIHint hint)
        {
            var msg = hint.Body;

            msg           = GameFacade.Emojis.EmojiToBB(msg);
            m_MessageText = TextRenderer.ComputeText(msg, new TextRendererOptions
            {
                Alignment        = TextAlignment.Left | TextAlignment.Top,
                MaxWidth         = 492,
                Position         = new Vector2(290, 65),
                Scale            = _Scale,
                TextStyle        = TextStyle.DefaultLabel,
                WordWrap         = true,
                TopLeftIconSpace = IconSpace,
                BBCode           = true
            }, this);
            ActiveHint  = hint;
            m_TextDirty = false;
        }
Example #5
0
        public void ShowHint(UIHint hint)
        {
            Icon.Texture?.Dispose();

            Icon.Texture = null;
            if (hint.Image != null && hint.Image != "")
            {
                //try load the image for this hint
                SetIcon(null, 0, 0);
                try
                {
                    if (hint.Image.Length > 0 && hint.Image[0] == '@')
                    {
                        using (var strm = File.Open(Content.Content.Get().GetPath("uigraphics/hints/" + hint.Image.Substring(1)), FileMode.Open, FileAccess.Read, FileShare.Read))
                        {
                            var tex = ImageLoader.FromStream(GameFacade.GraphicsDevice, strm);
                            SetIcon(tex, tex.Width, tex.Height);
                        }
                    }
                    else
                    {
                        using (var strm = File.Open("Content/UI/hints/images/" + hint.Image, FileMode.Open, FileAccess.Read, FileShare.Read))
                        {
                            var tex = ImageLoader.FromStream(GameFacade.GraphicsDevice, strm);
                            SetIcon(tex, tex.Width, tex.Height);
                        }
                    }
                }
                catch (Exception)
                {
                }
            }

            Title.Caption = hint.Title;
            ComputeText(hint);
        }
Example #6
0
 public void AddHint(UIHint hint)
 {
     Hints.Add(hint);
     //updates the buttons and title
     RenderHint();
 }