Ejemplo n.º 1
0
    public SliderOption(string label, Func <int> getter, Action <int> setter, int minValue, int maxValue) :
        base(label)
    {
        _getter = getter;
        _setter = setter;

        _slider = new WidgetSlider(399, 9);
        _slider.SetMin(minValue);
        _slider.SetMax(maxValue);
        _slider.X = 178;
        _slider.Y = 2;
        Globals.UiManager.RemoveWindow(_slider); // Otherwise it'll show up as a top-level widget

        // Display the slider's min value to the left of the slider
        _minLabel   = new WidgetText(_slider.GetMin().ToString(), "options-label-muted");
        _minLabel.X = _slider.X - _minLabel.GetPreferredSize().Width - 5;
        _minLabel.SetCenterVertically(true);

        // Display the slider's max value to the left of the slider
        _maxLabel   = new WidgetText(_slider.GetMax().ToString(), "options-label-muted");
        _maxLabel.X = _slider.X + _slider.Width + 5;
        _maxLabel.SetCenterVertically(true);

        // Display the current value to the far right
        _valueLabel   = new WidgetText(_slider.GetValue().ToString(), "options-label");
        _valueLabel.X = _slider.X + _slider.Width + 40;
        _valueLabel.SetCenterVertically(true);
        _slider.SetValueChangeHandler(ValueChanged);
    }
Ejemplo n.º 2
0
    public LogbookKeyButton(LogbookKeyTranslations translations, Rectangle rect) : base(rect)
    {
        AddStyle("logbook-key-button");

        _translations = translations;

        _title           = new WidgetText();
        _title.Text      = " ";
        _title.X         = 5;
        _title.Y         = 2;
        _title.FixedSize = new Size(rect.Width, _title.GetPreferredSize().Height);
        AddContent(_title);

        var currentY = _title.GetPreferredSize().Height + 1;

        _acquiredLabel   = new WidgetText();
        _acquiredLabel.X = 5;
        _acquiredLabel.Y = currentY;
        AddContent(_acquiredLabel);

        var innerRectangle = new WidgetRectangle();

        innerRectangle.X         = 1;
        innerRectangle.Y         = 1;
        innerRectangle.FixedSize = new Size(rect.Width - 2, rect.Height - 2);
        innerRectangle.Pen       = new PackedLinearColorA(0xFF909090);
        AddContent(innerRectangle);

        _outerRectangle     = new WidgetRectangle();
        _outerRectangle.Pen = PackedLinearColorA.White;
        AddContent(_outerRectangle);
    }
Ejemplo n.º 3
0
    public AlignmentSystem()
    {
        var doc = WidgetDoc.Load("ui/pc_creation/alignment_ui.json");

        Container         = doc.GetRootContainer();
        Container.Visible = false;

        _partyAlignmentLabel = doc.GetTextContent("partyAlignmentLabel");

        _alignmentButtons = new Dictionary <Alignment, WidgetButton>
        {
            { Alignment.LAWFUL_GOOD, doc.GetButton("lawfulGood") },
            { Alignment.NEUTRAL_GOOD, doc.GetButton("neutralGood") },
            { Alignment.CHAOTIC_GOOD, doc.GetButton("chaoticGood") },
            { Alignment.LAWFUL_NEUTRAL, doc.GetButton("lawfulNeutral") },
            { Alignment.NEUTRAL, doc.GetButton("neutral") },
            { Alignment.CHAOTIC_NEUTRAL, doc.GetButton("chaoticNeutral") },
            { Alignment.LAWFUL_EVIL, doc.GetButton("lawfulEvil") },
            { Alignment.NEUTRAL_EVIL, doc.GetButton("neutralEvil") },
            { Alignment.CHAOTIC_EVIL, doc.GetButton("chaoticEvil") },
        };

        foreach (var(alignment, button) in _alignmentButtons)
        {
            button.OnMouseEnter += msg => ShowAlignmentHelp(alignment);
            button.OnMouseExit  += msg => UpdateDescriptionBox();
            button.SetClickHandler(() => SelectAlignment(alignment));
        }
    }
Ejemplo n.º 4
0
    public SkillButton(Rectangle rect) : base(rect)
    {
        _skillNameLabel   = new WidgetText("", "char-ui-skill-button");
        _skillNameLabel.X = 4;
        _skillNameLabel.Y = -1;
        AddContent(_skillNameLabel);

        // Rectangle surrounding the bonus
        var bonusBox = new WidgetRectangle();

        bonusBox.Pen       = new PackedLinearColorA(0xFF80A0C0);
        bonusBox.X         = rect.Width - 38;
        bonusBox.Y         = 1;
        bonusBox.FixedSize = new Size(30, rect.Height - 2);
        AddContent(bonusBox);

        _skillBonusLabel           = new WidgetText("", "char-ui-skill-button");
        _skillBonusLabel.X         = bonusBox.X;
        _skillBonusLabel.Y         = _skillNameLabel.Y;
        _skillBonusLabel.FixedSize = bonusBox.FixedSize;
        _skillBonusLabel.AddStyle("char-ui-skill-value");
        AddContent(_skillBonusLabel);

        SetClickHandler(ShowBonusDetails);
    }
Ejemplo n.º 5
0
    public StatsValue(
        Func <GameObject, InlineElement> valueSupplier,
        Rectangle rect,
        StatsUiTexture downImage,
        StatsUiTexture hoverImage,
        StatsUiParams uiParams) : base(rect)
    {
        _downImage     = new WidgetImage(uiParams.TexturePaths[downImage]);
        _hoverImage    = new WidgetImage(uiParams.TexturePaths[hoverImage]);
        _valueSupplier = valueSupplier;

        _label = new WidgetText("", "char-ui-stat-value");
        SetWidgetMsgHandler(msg =>
        {
            if (msg.widgetEventType == TigMsgWidgetEvent.Exited)
            {
                UiSystems.CharSheet.Help.ClearHelpText();
                return(true);
            }

            return(false);
        });

        TooltipText = UiSystems.Tooltip.GetString(6044);
    }
    public CharUiMainWidget(CharUiParams uiParams) : base(uiParams.CharUiMainWindow)
    {
        _normalBackground  = new WidgetImage("art/interface/char_ui/main_window.img");
        _ironmanBackground = new WidgetImage("art/interface/char_ui/ironman_main_window.img");
        SetSize(_normalBackground.GetPreferredSize());

        _translation = Tig.FS.ReadMesFile("mes/0_char_ui_text.mes");
        var pcCreationMes = Tig.FS.ReadMesFile("mes/pc_creation.mes");

        var rerollsLabel = pcCreationMes[10001];

        _pointBuyLabel = pcCreationMes[10015];

        var attributeModeStyle = new TigTextStyle(new ColorRect(new PackedLinearColorA(0xFF5A7390)));

        attributeModeStyle.kerning  = 1;
        attributeModeStyle.tracking = 3;

        var attributeCountStyle = attributeModeStyle.Copy();

        attributeCountStyle.textColor = new ColorRect(PackedLinearColorA.White);

        _attributeRollModeLabel  = new WidgetText(rerollsLabel, "char-ui-attribute-mode");
        _attributeRollCountLabel = new WidgetText("", "char-ui-attribute-rerolls");
    }
Ejemplo n.º 7
0
    public KnownSpellButton(Rectangle rect,
                            bool spellOpposesAlignment,
                            SpellStoreData spell) : base(rect)
    {
        _spellOpposesAlignment = spellOpposesAlignment;
        _spell = spell;

        var spellName = GameSystems.Spell.GetSpellName(spell.spellEnum);

        if (GameSystems.Spell.IsDomainSpell(spell.classCode))
        {
            var domainName = GameSystems.Spell.GetSpellDomainName(spell.classCode);
            spellName += " (" + domainName + ")";
        }

        var style = spellOpposesAlignment ? "char-spell-grey" : "char-spell-body";

        _nameLabel = new WidgetText(spellName, style);
        AddContent(_nameLabel);

        OnMouseEnter += ShowSpellHelp;
        OnMouseExit  += HideSpellHelp;

        if (spellOpposesAlignment)
        {
            TooltipText = "#{char_ui_spells:12}";
        }
        else
        {
            TooltipText   = GameSystems.Spell.GetSpellName(_spell.spellEnum);
            OnRightClick += (x, y) => OnMemorizeSpell?.Invoke(_spell, null);
        }
    }
Ejemplo n.º 8
0
    public AlertUi()
    {
        var doc = WidgetDoc.Load("ui/alert_ui.json");

        _mainWindow         = doc.GetRootContainer();
        _mainWindow.ZIndex  = 99800;
        _mainWindow.Name    = "alert_main_window";
        _mainWindow.Visible = false;

        _titleLabel = doc.GetTextContent("title");

        _okButton      = doc.GetButton("alert_ok_button");
        _okButton.Name = "alert_ok_button";
        _okButton.SetClickHandler(OkButtonClicked);
        _mainWindow.Add(_okButton);

        ScrollBoxSettings settings = new ScrollBoxSettings();

        settings.TextArea        = new Rectangle(6, 16, 287, 208);
        settings.ScrollBarPos    = new Point(297, 1);
        settings.ScrollBarHeight = 224;
        settings.Indent          = 7;
        settings.Font            = PredefinedFont.ARIAL_10;

        _scrollBox        = new ScrollBox(new Rectangle(20, 36, 310, 226), settings);
        _scrollBox.ZIndex = 99950;
        _scrollBox.Name   = "scrollbox_main_window";
        _mainWindow.Add(_scrollBox);
    }
Ejemplo n.º 9
0
    public StatsLabel(
        Stat stat,
        string helpTopic,
        Rectangle rect,
        StatsUiTexture downImage,
        StatsUiTexture hoverImage,
        StatsUiParams uiParams) : base(rect)
    {
        _stat       = stat;
        _downImage  = new WidgetImage(uiParams.TexturePaths[downImage]);
        _hoverImage = new WidgetImage(uiParams.TexturePaths[hoverImage]);

        var statName = GetStatName(uiParams, stat);

        _label = new WidgetText(statName, "char-ui-stat-label");
        SetWidgetMsgHandler(msg =>
        {
            if (msg.widgetEventType == TigMsgWidgetEvent.Exited)
            {
                UiSystems.CharSheet.Help.ClearHelpText();
                return(true);
            }

            return(false);
        });
        if (helpTopic != null)
        {
            SetClickHandler(() => { GameSystems.Help.ShowTopic(helpTopic); });
        }
    }
 public AbilityScoreModifierWidget(Size size, Func <int> assignedValueGetter)
 {
     _assignedValueGetter = assignedValueGetter;
     SetSize(size);
     AddContent(new WidgetRectangle
     {
         Pen = new PackedLinearColorA(0xFF43586E)
     });
     _label = new WidgetText("", LabelStyle);
     AddContent(_label);
 }
Ejemplo n.º 11
0
    public CharSheetSkillsUi()
    {
        var detailsDoc = WidgetDoc.Load("ui/char_skills.json");

        Container = detailsDoc.GetRootContainer();
        Container.SetMouseMsgHandler(msg =>
        {
            // Forward mouse wheel messages to the scrollbar
            if ((msg.flags & MouseEventFlag.ScrollWheelChange) != 0)
            {
                _scrollbar.HandleMouseMessage(msg);
            }

            return(true);
        });
        Container.Name    = "char_skills_ui_main_window";
        Container.Visible = false;

        _skillRanks     = detailsDoc.GetTextContent("skill-ranks-label");
        _attributeBonus = detailsDoc.GetTextContent("skill-attribute-bonus-label");
        _attributeType  = detailsDoc.GetTextContent("skill-attribute-type-label");
        _miscBonus      = detailsDoc.GetTextContent("skill-misc-bonus-label");
        _total          = detailsDoc.GetTextContent("skill-total-label");
        HideSkillDetails();

        for (var i = 0; i < 20; i++)
        {
            var button = new SkillButton(new Rectangle(1, 1 + 13 * i, 156, 13));
            button.OnMouseEnter += _ => ShowSkillDetails(button);
            button.OnMouseExit  += _ => HideSkillDetails();
            button.SetMouseMsgHandler(msg =>
            {
                if ((msg.flags & MouseEventFlag.ScrollWheelChange) != 0)
                {
                    return(_scrollbar.HandleMouseMessage(msg));
                }

                return(false);
            });
            Container.Add(button);
            _skillButtons[i] = button;
        }

        if (VisibleSkills.Length > _skillButtons.Length)
        {
            _scrollbar = new WidgetScrollBar(new Rectangle(160, -4, 13, 267));
            _scrollbar.SetMin(0);
            _scrollbar.Max = VisibleSkills.Length - _skillButtons.Length;
            Container.Add(_scrollbar);
            _scrollbar.SetValueChangeHandler((value) => UpdateSkillButtons());
        }

        UpdateSkillButtons();
    }
Ejemplo n.º 12
0
        protected DialogWindow(string title, string text, string yesText, string noText)
            : base(WindowFlags.CustomAnim | WindowFlags.Blackout)
        {
            m_panel = new WidgetWindow(WidgetManager.GetStyle("dialog_window"));
            Vector2 size = m_panel.Size;

            m_text           = new WidgetText();
            m_text.Text      = text;
            m_text.Size      = new Vector2(size.X, 0);
            m_text.MaxWidth  = size.X - 40;
            m_text.FontSize *= 1.25f;
            m_text.TextAlign = WidgetAlign.VerticalCenter | WidgetAlign.HorizontalCenter;
            m_text.Relayout();
            size            = m_panel.Size = m_panel.Size + new Vector2(0, m_text.Size.Y - 80);
            m_text.Position = new Vector2(0, size.Y / 2 - m_text.Size.Y / 2);
            m_panel.AddChild(m_text);

            Size = size;

            if (!string.IsNullOrEmpty(noText))
            {
                m_noButton      = new WidgetButton(noText);
                m_noButton.Size = new Vector2(128, 48);

                m_noButton.Position = new Vector2(size.X * 2 / 3 - (m_noButton.Size.X) / 2, size.Y - m_noButton.Size.Y - 25);
                m_noButton.OnPress += delegate { HandleButtonPress(1); };
                m_panel.AddChild(m_noButton);
            }

            m_yesButton          = new WidgetButton(yesText);
            m_yesButton.Size     = new Vector2(128, 48);
            m_yesButton.Position = new Vector2(m_noButton == null ? size.X / 2 - (m_yesButton.Size.X) / 2 : size.X / 3 - m_yesButton.Size.X * 0.25f, size.Y - m_yesButton.Size.Y - 25);
            m_yesButton.OnPress += delegate { HandleButtonPress(0); };
            m_panel.AddChild(m_yesButton);

            m_closeButton              = new WidgetButton(WidgetManager.GetStyle("image_button"), "");
            m_closeButton.Size         = new Vector2(40, 40);
            m_closeButton.Image        = "close_icon";
            m_closeButton.ImagePadding = new Margin(10, 10, 10, 10);
            m_closeButton.Position     = new Vector2(size.X - m_closeButton.Size.X, 0);
            m_closeButton.OnPress     += delegate { HandleButtonPress(2); };
            m_panel.AddChild(m_closeButton);

            m_title           = new WidgetLabel();
            m_title.Text      = title;
            m_title.Size      = new Vector2(size.X, 50);
            m_title.Position  = new Vector2(0, 20);
            m_title.FontSize *= 1.5f;
            m_title.TextAlign = WidgetAlign.Top | WidgetAlign.HorizontalCenter;
            m_panel.AddChild(m_title);

            AddChild(m_panel);
        }
Ejemplo n.º 13
0
    public CharUiClassLevel()
    {
        AddContent(_text = new WidgetText());

        var translations = Tig.FS.ReadMesFile("mes/0_char_ui_text.mes");

        _textSeparator = ' ' + translations[1600] + ' ';
        _textLevel     = translations[1590];
        _textNpc       = '(' + translations[1610] + ')';

        AddStyle("char-ui-dialog-title");
    }
    public LogbookKeyAcquiredPopup(LogbookKeyTranslations translations)
    {
        var doc = WidgetDoc.Load("ui/key_acquired_popup.json");

        _window = doc.GetRootContainer();

        doc.GetTextContent("title").Text = translations.NotificationPopupTitle;

        var textContainer = doc.GetContainer("textContainer");

        var text = new WidgetText();

        text.FixedWidth = 237;
        text.Text       = translations.NotificationPopupText;
        textContainer.AddContent(text);

        var prompt = new WidgetText();

        prompt.FixedWidth = 237;
        prompt.Text       = translations.NotificationPopupPrompt;
        prompt.Y          = text.GetPreferredSize().Height + 13;
        textContainer.AddContent(prompt);

        // Created @ 0x1019727c
        // _window.OnHandleMessage += 0x101f5850;
        // _window.OnBeforeRender += 0x10196a10;
        _window.ZIndex  = 100051;
        _window.Name    = "logbook_ui_keys_key_entry_window";
        _window.Visible = false;

        // Created @ 0x10197385
        var acceptButton = doc.GetButton("accept");

        // logbook_ui_key_entry_accept_butn1.OnHandleMessage += 0x10197070;
        // logbook_ui_key_entry_accept_butn1.OnBeforeRender += 0x10196d70;
        acceptButton.Text = translations.NotificationPopupYes;
        acceptButton.Name = "logbook_ui_key_entry_accept_butn";
        acceptButton.SetClickHandler(() =>
        {
            OnChangeNotificationSetting?.Invoke(false);
            Hide();
        });

        // Created @ 0x101974c2
        var declineButton = doc.GetButton("decline");

        // logbook_ui_key_entry_decline_butn1.OnHandleMessage += 0x10197070;
        // logbook_ui_key_entry_decline_butn1.OnBeforeRender += 0x10196d70;
        declineButton.Text = translations.NotificationPopupNo;
        declineButton.Name = "logbook_ui_key_entry_decline_butn";
        declineButton.SetClickHandler(Hide);
    }
Ejemplo n.º 15
0
    public CharSheetHelpUi()
    {
        var widgetDoc = WidgetDoc.Load("ui/char_help.json");

        _scrollView = (WidgetScrollView)widgetDoc.TakeRootWidget();

        _textContainer = new WidgetContainer(0, 0,
                                             _scrollView.GetInnerWidth(), _scrollView.GetInnerHeight());
        _textLabel = new WidgetText();
        _textContainer.AddContent(_textLabel);
        _scrollView.Add(_textContainer);
        _scrollView.AddStyle("char-help-text");
    }
Ejemplo n.º 16
0
        // Screen_Loading
        public Screen_Loading()
            : base("Loading")
        {
            int   numIcons = 10;
            float gap      = -40.0f;

            for (int i = 0; i < numIcons; ++i)
            {
                float  rot = (MathHelper.TwoPi / numIcons) * i;
                Matrix m   = Matrix.CreateRotationZ(rot);

                WidgetGraphic icon = new WidgetGraphic();
                icon.Position = new Vector3(0.0f, gap, 0.0f);
                Vector3.Transform(ref icon.Position, ref m, out icon.Position);
                icon.Position += new Vector3(_UI.SXM, _UI.SYM - 50.0f, 0.0f);
                icon.Size      = new Vector3(12.0f, 12.0f, 0.0f);
                icon.Align     = E_Align.MiddleCentre;
                icon.ColorBase = Color.Orange;
                icon.AddTexture("null", 0.0f, 0.0f, 1.0f, 1.0f);
                icon.Rotation.Z = MathHelper.ToDegrees(rot);
                Add(icon);

                Timeline iconT = new Timeline("", true, (1.0f / numIcons) * i, 0.5f, E_TimerType.Bounce, E_RestType.None);
                iconT.AddEffect(new TimelineEffect_Alpha(0.0f, -1.0f, E_LerpType.SmoothStep));
                iconT.AddEffect(new TimelineEffect_ScaleX(0.0f, 0.5f, E_LerpType.SmoothStep));
                iconT.AddEffect(new TimelineEffect_ScaleY(0.0f, 0.5f, E_LerpType.SmoothStep));
                icon.AddTimeline(iconT);

                Timeline iconT2 = new Timeline("start", false, 0.0f, 0.25f, E_TimerType.Stop, E_RestType.Start);
                iconT2.AddEffect(new TimelineEffect_Alpha(-1.0f, 0.0f, E_LerpType.SmoothStep));
                icon.AddTimeline(iconT2);
            }

            WidgetText text = new WidgetText();

            text.Position  = new Vector3(_UI.SXM, _UI.SYM + 25.0f, 0.0f);
            text.Size      = new Vector3(0.0f, 60.0f, 0.0f);
            text.Align     = E_Align.TopCentre;
            text.FontStyle = _UI.Store_FontStyle.Get("Default").Copy();
            text.FontStyle.TrackingPercentage = 0.1875f;
            text.String    = "LOADING";
            text.ColorBase = Color.Orange;
            text.AddFontEffect(new FontEffect_ColorLerp(0.03125f, 1.5f, 3.0f, Color.White, E_LerpType.BounceOnceSmooth));
            text.AddFontEffect(new FontEffect_Scale(0.03125f, 0.75f, 3.0f, 1.0f, 1.5f, 1.0f, 2.0f, E_LerpType.BounceOnceSmooth));
            Add(text);

            Timeline textT2 = new Timeline("start", false, 0.0f, 0.25f, E_TimerType.Stop, E_RestType.Start);

            textT2.AddEffect(new TimelineEffect_Alpha(-1.0f, 0.0f, E_LerpType.SmoothStep));
            text.AddTimeline(textT2);
        }
    public StatBlockAbilityScore(Stat ability)
    {
        var doc = WidgetDoc.Load("ui/pc_creation/stat_block_ability_score.json");

        Container = doc.GetRootContainer();

        _caption        = doc.GetTextContent("caption");
        _caption.Text   = GameSystems.Stat.GetStatShortName(ability);
        _captionBg      = doc.GetContent("activeCaptionBg");
        _modifierLabel  = doc.GetTextContent("modifierLabel");
        _modifierBorder = doc.GetContent("activeModifierBorder");
        _valueLabel     = doc.GetTextContent("valueLabel");
        _valueBorder    = doc.GetContent("activeValueBorder");
    }
Ejemplo n.º 18
0
    public TextEntryUi()
    {
        var doc = WidgetDoc.Load("ui/text_entry_ui.json");

        _dialog         = doc.GetRootContainer();
        _dialog.Visible = false;
        _dialog.SetKeyStateChangeHandler(HandleShortcut);
        _dialog.OnHandleMessage += HandleMessage;

        _okButton = doc.GetButton("okButton");
        _okButton.SetClickHandler(Confirm);
        _cancelButton = doc.GetButton("cancelButton");
        _cancelButton.SetClickHandler(Cancel);
        _titleLabel        = doc.GetTextContent("titleLabel");
        _currentInputLabel = doc.GetTextContent("currentInputLabel");
    }
Ejemplo n.º 19
0
    public HeightSystem()
    {
        var doc = WidgetDoc.Load("ui/pc_creation/height_ui.json");

        Container         = doc.GetRootContainer();
        Container.Visible = false;

        _minHeightLabel     = doc.GetTextContent("minHeightLabel");
        _maxHeightLabel     = doc.GetTextContent("maxHeightLabel");
        _currentHeightLabel = doc.GetTextContent("currentHeightLabel");

        _slider = new HeightSlider();
        _slider.SetPos(doc.GetContainer("sliderContainer").GetPos());
        Container.Add(_slider);
        _slider.OnValueChanged += (newValue) => { UpdateModelScale(); };
    }
Ejemplo n.º 20
0
    public SaveGameSlotButton(Rectangle rect) : base(rect)
    {
        _borderImage = new WidgetImage(BorderImagePath);
        AddContent(_borderImage);

        _screenshot           = new WidgetImage();
        _screenshot.X         = 2;
        _screenshot.Y         = 2;
        _screenshot.FixedSize = new Size(64, 48);
        AddContent(_screenshot);

        _label           = new WidgetText("", "loadGameSlot");
        _label.X         = 67;
        _label.Y         = 2;
        _label.FixedSize = new Size(268, 48);
        AddContent(_label);
    }
Ejemplo n.º 21
0
    public StatsCurrencyLabel(StatsUiParams uiParams, MoneyType moneyType)
    {
        Rectangle rect;

        switch (moneyType)
        {
        case MoneyType.Copper:
            rect           = uiParams.CopperButton;
            _tooltipSuffix = UiSystems.Tooltip.GetString(1704);
            break;

        case MoneyType.Silver:
            rect           = uiParams.SilverButton;
            _tooltipSuffix = UiSystems.Tooltip.GetString(1703);
            break;

        case MoneyType.Gold:
            rect           = uiParams.GoldButton;
            _tooltipSuffix = UiSystems.Tooltip.GetString(1702);
            break;

        case MoneyType.Platinum:
            rect           = uiParams.PlatinumButton;
            _tooltipSuffix = UiSystems.Tooltip.GetString(1701);
            break;

        default:
            throw new ArgumentOutOfRangeException(nameof(moneyType), moneyType, null);
        }

        SetPos(rect.Location);
        Y = Y - 1; // This is hardcoded in the render-function in ToEE
        SetSize(rect.Size);

        MoneyType = moneyType;

        _label = new WidgetText(_currentText, "char-ui-stat-money");
        AddContent(_label);
        SetClickHandler(OnClick);
    }
Ejemplo n.º 22
0
        // Screen_Start
        public Screen_Start()
            : base("Start")
        {
            WidgetGraphic logo = new WidgetGraphic();

            logo.Position  = new Vector3(_UI.SXM, _UI.SYM, 0.0f);
            logo.Size      = new Vector3(_UI.SY / 3.0f, _UI.SY / 3.0f, 0.0f);
            logo.Align     = E_Align.BottomCentre;
            logo.ColorBase = new SpriteColors(Color.Orange, Color.Orange, Color.Black, Color.Black);
            logo.AddTexture("null", 0.0f, 0.0f, 1.0f, 1.0f);
            Add(logo);

            if (!_G.UI.SS_FromMainMenu)
            {
                Timeline logoT = new Timeline("start", false, 0.0f, 0.25f, E_TimerType.Stop, E_RestType.None);
                logoT.AddEffect(new TimelineEffect_Alpha(-1.0f, 0.0f, E_LerpType.SmoothStep));
                logo.AddTimeline(logoT);
            }

            _G.UI.SS_FromMainMenu = false;

            WidgetText text = new WidgetText();

            text.Position  = new Vector3(_UI.SXM, _UI.SYM + 150.0f, 0.0f);
            text.Size      = new Vector3(0.0f, 60.0f, 0.0f);
            text.Align     = E_Align.MiddleCentre;
            text.FontStyle = _UI.Store_FontStyle.Get("Default").Copy();
            text.FontStyle.TrackingPercentage = 0.1875f;
            text.String    = "PRESS START BUTTON";
            text.ColorBase = Color.Orange;
            text.AddFontEffect(new FontEffect_ColorLerp(0.03125f, 1.5f, 3.0f, Color.White, E_LerpType.BounceOnceSmooth));
            text.AddFontEffect(new FontEffect_Scale(0.03125f, 0.75f, 3.0f, 1.0f, 1.5f, 1.0f, 2.0f, E_LerpType.BounceOnceSmooth));
            Add(text);

            Timeline textT = new Timeline("start", false, 0.0f, 0.25f, E_TimerType.Stop, E_RestType.Start);

            textT.AddEffect(new TimelineEffect_Alpha(-1.0f, 0.0f, E_LerpType.SmoothStep));
            text.AddTimeline(textT);
        }
Ejemplo n.º 23
0
    public WidgetTabButton(string label, WidgetTabStyle style)
    {
        _style   = style;
        sndClick = WidgetButtonStyle.DefaultUpSound;
        sndDown  = WidgetButtonStyle.DefaultDownSound;

        if (style == WidgetTabStyle.Large)
        {
            _normalLeft    = new WidgetImage("art/interface/logbook_ui/Tab-Left.tga");
            _normalBg      = new WidgetImage("art/interface/logbook_ui/Tab-Tiled.tga");
            _normalRight   = new WidgetImage("art/interface/logbook_ui/Tab-Right.tga");
            _selectedLeft  = new WidgetImage("art/interface/logbook_ui/Tab-Left-Selected.tga");
            _selectedBg    = new WidgetImage("art/interface/logbook_ui/Tab-Tiled-Selected.tga");
            _selectedRight = new WidgetImage("art/interface/logbook_ui/Tab-Right-Selected.tga");

            _label = new WidgetText(label, LargeLabelStyle);
        }
        else
        {
            _normalLeft    = new WidgetImage("ui/tabs/tab-small-left.tga");
            _normalBg      = new WidgetImage("ui/tabs/tab-small-middle.tga");
            _normalRight   = new WidgetImage("ui/tabs/tab-small-right.tga");
            _selectedLeft  = new WidgetImage("ui/tabs/tab-small-active-left.tga");
            _selectedBg    = new WidgetImage("ui/tabs/tab-small-active-middle.tga");
            _selectedRight = new WidgetImage("ui/tabs/tab-small-active-right.tga");

            _label = new WidgetText(label, SmallLabelStyle);
        }

        // Layout the content items
        LayoutContent(_selectedLeft, _selectedBg, _selectedRight, _label);
        var size = LayoutContent(_normalLeft, _normalBg, _normalRight, _label);

        SetSize(size);

        UpdateSelectedState();
    }
Ejemplo n.º 24
0
    public DialogResponseButton(Rectangle rect, string numberText, string text, DialogSkill skillUsed) : base(rect)
    {
        AddStyle("dialog-ui-text");

        _skillUsed = skillUsed;

        _label            = new WidgetText(text, NormalStyle);
        _label.X          = 36;
        _label.FixedWidth = 559;
        AddContent(_label);

        _numberLabel   = new WidgetText(numberText, NormalStyle);
        _numberLabel.X = 17;
        AddContent(_numberLabel);

        if (skillUsed != DialogSkill.None)
        {
            var icon = new WidgetImage(GetSkillTexture(skillUsed));
            icon.FixedSize = new Size(15, 15);
            icon.X         = 2;
            icon.Y         = 1;
            AddContent(icon);
        }
    }
Ejemplo n.º 25
0
    public void RenderObjectTooltip(IGameViewport viewport, GameObject obj, GameObject observer = null)
    {
        var content = UiSystems.Tooltip.GetObjectDescriptionContent(obj, observer);

        if (content != null)
        {
            using var tooltipLabel = new WidgetText(content, "default-tooltip");
            tooltipLabel.SetBounds(new Rectangle(0, 0, 300, 300));

            var size = tooltipLabel.GetPreferredSize();

            var objRect = GameSystems.MapObject.GetObjectRect(viewport, obj);
            var extents = new Rectangle(
                objRect.X + (objRect.Width - size.Width) / 2,
                objRect.Y - size.Height,
                size.Width,
                size.Height
                );
            UiSystems.Tooltip.ClampTooltipToScreen(ref extents);

            tooltipLabel.SetBounds(extents);
            tooltipLabel.Render();
        }
    }
Ejemplo n.º 26
0
    public KnownSpellsList(Rectangle rectangle, GameObject critter, int classCode) : base(rectangle)
    {
        var spellsKnown  = critter.GetSpellArray(obj_f.critter_spells_known_idx);
        var domainSpells = GameSystems.Spell.IsDomainSpell(classCode);

        // Try scrolling one spell per scrollbar-tick
        var buttonHeight = 10;
        var currentY     = 0;

        for (var level = 0; level <= 9; level++)
        {
            var headerAdded = false;

            foreach (var spell in spellsKnown)
            {
                if (domainSpells != GameSystems.Spell.IsDomainSpell(spell.classCode) ||
                    !domainSpells && spell.classCode != classCode ||
                    spell.spellLevel != level)
                {
                    continue;
                }

                if (!headerAdded)
                {
                    var levelHeader = new WidgetText($"#{{char_ui_spells:3}} {level}", "char-spell-level");
                    levelHeader.Y = currentY;
                    currentY     += levelHeader.GetPreferredSize().Height;
                    AddContent(levelHeader);
                    headerAdded = true;
                }

                var spellOpposesAlignment =
                    GameSystems.Spell.SpellOpposesAlignment(critter, spell.classCode, spell.spellEnum);
                var spellButton = new KnownSpellButton(
                    new Rectangle(8, currentY, Width - 8, 12),
                    spellOpposesAlignment,
                    spell
                    );
                spellButton.Y = currentY;
                spellButton.OnMemorizeSpell += (spell, button) => OnMemorizeSpell?.Invoke(spell, button);
                currentY += spellButton.Height;
                Add(spellButton);

                buttonHeight = Math.Max(buttonHeight, spellButton.Height);
            }
        }

        var overscroll = currentY - Height;

        if (overscroll > 0)
        {
            var lines = (int)MathF.Ceiling(overscroll / (float)buttonHeight);

            _scrollbar        = new WidgetScrollBar();
            _scrollbar.X      = Width - _scrollbar.Width;
            _scrollbar.Height = Height;

            // Clip existing items that overlap the scrollbar
            foreach (var widgetBase in GetChildren())
            {
                if (widgetBase.X + widgetBase.Width >= _scrollbar.X)
                {
                    var remainingWidth = Math.Max(0, _scrollbar.X - widgetBase.X);
                    widgetBase.Width = remainingWidth;
                }
            }

            _scrollbar.SetMin(0);
            _scrollbar.Max = lines;
            _scrollbar.SetValueChangeHandler(value =>
            {
                SetScrollOffsetY(value * buttonHeight);
                _scrollbar.Y = value * buttonHeight; // Horrible fakery, moving the scrollbar along
            });
            Add(_scrollbar);
        }
    }
Ejemplo n.º 27
0
 public WidgetButton()
 {
     _label = new WidgetText {
         Parent = this
     };
 }
Ejemplo n.º 28
0
 public WidgetDynamicLabel(Func <InlineElement?> contentSupplier)
 {
     _text = new WidgetText();
     AddContent(_text);
     _contentSupplier = contentSupplier;
 }
Ejemplo n.º 29
0
        // Screen_MainMenu
        public Screen_MainMenu()
            : base("MainMenu")
        {
            WidgetGraphic logo = new WidgetGraphic();

            logo.Position  = new Vector3(_UI.SXM, _UI.SYM - 65.0f, 0.0f);
            logo.Size      = new Vector3(_UI.SY / 3.0f, _UI.SY / 3.0f, 0.0f);
            logo.Align     = E_Align.BottomCentre;
            logo.ColorBase = new SpriteColors(Color.Orange, Color.Orange, Color.Black, Color.Black);
            logo.AddTexture("null", 0.0f, 0.0f, 1.0f, 1.0f);
            Add(logo);

            Timeline logoT = new Timeline("end_fade", false, 0.0f, 0.25f, E_TimerType.Stop, E_RestType.Start);

            logoT.AddEffect(new TimelineEffect_Alpha(0.0f, -1.0f, E_LerpType.SmoothStep));
            logo.AddTimeline(logoT);

            Timeline logoT2 = new Timeline("end_move", false, 0.25f, 0.25f, E_TimerType.Stop, E_RestType.None);

            logoT2.AddEffect(new TimelineEffect_PositionY(0.0f, 65.0f, E_LerpType.SmoothStep));
            logo.AddTimeline(logoT2);

            if (_G.UI.MM_FromStartScreen)
            {
                logo.Position = new Vector3(_UI.SXM, _UI.SYM, 0.0f);

                Timeline logoT3 = new Timeline("start", false, 0.0f, 0.25f, E_TimerType.Stop, E_RestType.None);
                logoT3.AddEffect(new TimelineEffect_PositionY(0.0f, -65.0f, E_LerpType.SmoothStep));
                logo.AddTimeline(logoT3);
            }
            else
            if (_G.UI.MM_FromLevelSelect)
            {
                Timeline logoT4 = new Timeline("start", false, 0.25f, 0.25f, E_TimerType.Stop, E_RestType.None);
                logoT4.AddEffect(new TimelineEffect_Alpha(-1.0f, 0.0f, E_LerpType.SmoothStep));
                logo.AddTimeline(logoT4);
            }

            _G.UI.MM_FromStartScreen = false;
            _G.UI.MM_FromLevelSelect = false;

            Logo = logo;

            WidgetMenuScroll menu = new WidgetMenuScroll(E_MenuType.Vertical);

            menu.Position = new Vector3(_UI.SXM, _UI.SYM + 25.0f, 0.0f);
            menu.Padding  = 75.0f;
            menu.Alpha    = 0.0f;
            Add(menu);

            Timeline menuT = new Timeline("start", false, 0.25f, 0.25f, E_TimerType.Stop, E_RestType.None);

            menuT.AddEffect(new TimelineEffect_Alpha(0.0f, 1.0f, E_LerpType.SmoothStep));
            menu.AddTimeline(menuT);

            Timeline menuT2 = new Timeline("end", false, 0.0f, 0.25f, E_TimerType.Stop, E_RestType.None);

            menuT2.AddEffect(new TimelineEffect_Alpha(0.0f, -1.0f, E_LerpType.SmoothStep));
            menu.AddTimeline(menuT2);

            Menu = menu;

            for (int i = 0; i < Options.Length; ++i)
            {
                WidgetMenuNode node = new WidgetMenuNode(i);
                node.Parent(Menu);
                Add(node);

                Timeline nodeT = new Timeline("selected", false, 0.0f, 0.25f, E_TimerType.Stop, E_RestType.Start);
                nodeT.AddEffect(new TimelineEffect_ScaleX(0.0f, 0.125f, E_LerpType.SmoothStep));
                nodeT.AddEffect(new TimelineEffect_ScaleY(0.0f, 0.125f, E_LerpType.SmoothStep));

                Timeline nodeT2 = new Timeline("selected", false, 0.0f, 0.5f, E_TimerType.Bounce, E_RestType.Start);
                nodeT2.AddEffect(new TimelineEffect_Intensity(0.0f, 0.75f, E_LerpType.SmoothStep));

                node.AddTimeline(nodeT);
                node.AddTimeline(nodeT2);

                WidgetText text = new WidgetText();
                text.Size          = new Vector3(0.0f, 50.0f, 0.0f);
                text.Align         = E_Align.MiddleCentre;
                text.FontStyleName = "Default";
                text.String        = Options[i];
                text.Parent(node);
                text.ParentAttach = E_Align.MiddleCentre;
                text.ColorBase    = Color.Orange;
                Add(text);

                WidgetGraphic icon = new WidgetGraphic();
                icon.Layer    = 1;
                icon.Position = new Vector3(-10.0f, 0.0f, 0.0f);
                icon.Size     = new Vector3(60.0f, 60.0f, 0.0f);
                icon.AddTexture(TextureNames[i], 0.0f, 0.0f, 1.0f, 1.0f);
                icon.Alpha = 0;
                icon.Parent(text);
                icon.ColorBase = Color.White;

                if ((i & 1) == 0)
                {
                    icon.Align        = E_Align.MiddleRight;
                    icon.ParentAttach = E_Align.MiddleLeft;
                }
                else
                {
                    icon.Align        = E_Align.MiddleLeft;
                    icon.ParentAttach = E_Align.MiddleRight;
                    icon.Position    *= -1.0f;
                }

                Add(icon);

                Timeline iconT = new Timeline("selected", false, 0.0f, 0.25f, E_TimerType.Stop, E_RestType.Start);
                iconT.AddEffect(new TimelineEffect_Alpha(0.0f, 1.0f, E_LerpType.SmoothStep));
                icon.AddTimeline(iconT);
            }
        }
Ejemplo n.º 30
0
        // Screen_Options
        public Screen_Options()
            : base("Options")
        {
            WidgetGraphic logo = new WidgetGraphic();

            logo.Position  = new Vector3(_UI.SXM, _UI.SYM - 65.0f, 0.0f);
            logo.Size      = new Vector3(_UI.SY / 3.0f, _UI.SY / 3.0f, 0.0f);
            logo.Align     = E_Align.BottomCentre;
            logo.ColorBase = new SpriteColors(Color.Orange, Color.Orange, Color.Black, Color.Black);
            logo.AddTexture("null", 0.0f, 0.0f, 1.0f, 1.0f);
            Add(logo);

            WidgetMenuScroll menu = new WidgetMenuScroll(E_MenuType.Vertical);

            menu.Position = new Vector3(_UI.SXM, _UI.SYM + 25.0f + 37.5f, 0.0f);
            menu.Padding  = 75.0f;
            menu.Alpha    = 0.0f;

            Timeline menuT = new Timeline("start", false, 0.25f, 0.25f, E_TimerType.Stop, E_RestType.None);

            menuT.AddEffect(new TimelineEffect_Alpha(0.0f, 1.0f, E_LerpType.SmoothStep));
            menu.AddTimeline(menuT);

            Timeline menuT2 = new Timeline("end", false, 0.0f, 0.25f, E_TimerType.Stop, E_RestType.None);

            menuT2.AddEffect(new TimelineEffect_Alpha(0.0f, -1.0f, E_LerpType.SmoothStep));
            menu.AddTimeline(menuT2);

            Add(menu);

            // music volume
            WidgetMenuNode node0 = new WidgetMenuNode(0);

            Add(node0);
            node0.Parent(menu);

            Timeline nodeT = new Timeline("selected", false, 0.0f, 0.25f, E_TimerType.Stop, E_RestType.Start);

            nodeT.AddEffect(new TimelineEffect_ScaleX(0.0f, 0.125f, E_LerpType.SmoothStep));
            nodeT.AddEffect(new TimelineEffect_ScaleY(0.0f, 0.125f, E_LerpType.SmoothStep));

            Timeline nodeT2 = new Timeline("selected", false, 0.0f, 0.5f, E_TimerType.Bounce, E_RestType.Start);

            nodeT2.AddEffect(new TimelineEffect_Intensity(0.0f, 0.75f, E_LerpType.SmoothStep));

            node0.AddTimeline(nodeT);
            node0.AddTimeline(nodeT2);

            WidgetText text0 = new WidgetText();

            text0.Size          = new Vector3(0.0f, 50.0f, 0.0f);
            text0.Align         = E_Align.MiddleCentre;
            text0.FontStyleName = "Default";
            text0.String        = "MUSIC VOLUME";
            text0.Align         = E_Align.MiddleRight;
            text0.Parent(node0);
            text0.ParentAttach = E_Align.MiddleCentre;
            text0.ColorBase    = Color.Orange;
            Add(text0);

            WidgetMenuSwitch menuSwitch0 = new WidgetMenuSwitch(E_MenuType.Horizontal);

            menuSwitch0.Position = new Vector3(80.0f, 0.0f, 0.0f);
            menuSwitch0.Parent(node0);
            menuSwitch0.ParentAttach     = E_Align.MiddleCentre;
            menuSwitch0.DeactivateArrows = false;
            Add(menuSwitch0);

            Timeline timelineArrow_Selected = new Timeline("selected", false, 0.0f, 0.25f, E_TimerType.Stop, E_RestType.Start);

            timelineArrow_Selected.AddEffect(new TimelineEffect_Alpha(0.0f, 1.0f, E_LerpType.SmoothStep));

            Timeline timelineArrow_Nudge = new Timeline("nudge", false, 0.0f, 0.25f, E_TimerType.Stop, E_RestType.None);

            timelineArrow_Nudge.AddEffect(new TimelineEffect_ScaleX(0.0f, 0.25f, E_LerpType.BounceOnceSmooth));
            timelineArrow_Nudge.AddEffect(new TimelineEffect_ScaleY(0.0f, 0.25f, E_LerpType.BounceOnceSmooth));

            WidgetGraphic arrow = new WidgetGraphic();

            arrow.Size               = new Vector3(15.0f, 30.0f, 0.0f);
            arrow.ColorBase          = Color.Orange;
            arrow.Alpha              = 0.0f;
            arrow.Align              = E_Align.MiddleCentre;
            arrow.RenderState.Effect = (int)E_Effect.IntensityAsAlpha_PMA;
            arrow.FlagClear(E_WidgetFlag.InheritIntensity);
            arrow.AddTimeline(timelineArrow_Selected.Copy());
            arrow.AddTimeline(timelineArrow_Nudge.Copy());
            arrow.ParentAttach = E_Align.MiddleCentre;

            WidgetGraphic arrowLeft = (WidgetGraphic)arrow.Copy();

            arrowLeft.Name       = "arrow_decrease";
            arrowLeft.Position   = new Vector3(-50.0f, 0.0f, 0.0f);
            arrowLeft.Rotation.Z = 180.0f;
            arrowLeft.AddTexture("null", 0.5f, 0.0f, 0.5f, 1.0f);
            arrowLeft.Parent(menuSwitch0);
            Add(arrowLeft);

            WidgetGraphic arrowRight = (WidgetGraphic)arrow.Copy();

            arrowRight.Name     = "arrow_increase";
            arrowRight.Position = new Vector3(50.0f, 0.0f, 0.0f);
            arrowRight.AddTexture("null", 0.5f, 0.0f, 0.5f, 1.0f);
            arrowRight.Parent(menuSwitch0);
            Add(arrowRight);

            menuSwitch0.ArrowDecrease = arrowLeft;
            menuSwitch0.ArrowIncrease = arrowRight;

            for (int i = 0; i < 11; ++i)
            {
                WidgetMenuNode node = new WidgetMenuNode(i);
                node.Parent(menuSwitch0);
                Add(node);

                WidgetText text = new WidgetText();
                text.Size          = new Vector3(0.0f, 50.0f, 0.0f);
                text.String        = "" + i;
                text.FontStyleName = "Default";
                text.Align         = E_Align.MiddleCentre;
                text.ColorBase     = Color.Orange;
                text.Parent(node);
                text.ParentAttach = E_Align.MiddleCentre;
                Add(text);
            }

            // sfx volume
            WidgetMenuNode node1 = (WidgetMenuNode)node0.Copy();

            node1.Value = 1;
            Add(node1);
            node1.Parent(menu);

            WidgetText text1 = (WidgetText)text0.Copy();

            text1.String = "SFX VOLUME";
            text1.Parent(node1);
            Add(text1);

            WidgetMenuSwitch menuSwitch1 = (WidgetMenuSwitch)menuSwitch0.CopyAndAdd(this);

            menuSwitch1.ArrowDecrease = menuSwitch1.FindChild("arrow_decrease");
            menuSwitch1.ArrowIncrease = menuSwitch1.FindChild("arrow_increase");
            menuSwitch1.Parent(node1);

            MenuSwitch0 = menuSwitch0;
            MenuSwitch1 = menuSwitch1;
        }