private void CreateMoneyLabels(StatsUiParams uiParams)
 {
     Container.Add(new StatsCurrencyLabel(uiParams, MoneyType.Platinum));
     Container.Add(new StatsCurrencyLabel(uiParams, MoneyType.Gold));
     Container.Add(new StatsCurrencyLabel(uiParams, MoneyType.Silver));
     Container.Add(new StatsCurrencyLabel(uiParams, MoneyType.Copper));
 }
    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);
    }
 private void CreateXpAndLevelLabels(StatsUiParams uiParams)
 {
     Container.Add(new StatsLabel(Stat.experience,
                                  "TAG_EXPERIENCE_AND_LEVELS",
                                  uiParams.XpLabel,
                                  StatsUiTexture.ButtonEXPClick,
                                  StatsUiTexture.ButtonEXPHover,
                                  uiParams
                                  ));
     Container.Add(new StatsValue(
                       obj => GetStatValue(obj, Stat.experience),
                       uiParams.XpValue,
                       StatsUiTexture.ButtonEXPOutputClick,
                       StatsUiTexture.ButtonEXPOutputHover,
                       uiParams
                       ));
     Container.Add(new StatsLabel(Stat.level,
                                  "TAG_EXPERIENCE_AND_LEVELS",
                                  uiParams.LevelLabel,
                                  StatsUiTexture.ButtonLevelClick,
                                  StatsUiTexture.ButtonLevelHover,
                                  uiParams
                                  ));
     Container.Add(new StatsValue(
                       obj => GetStatValue(obj, Stat.level),
                       uiParams.LevelValue,
                       StatsUiTexture.ButtonLevelOutputClick,
                       StatsUiTexture.ButtonLevelOutputHover,
                       uiParams
                       ));
 }
    public CharSheetStatsUi(Rectangle mainWindowRectangle)
    {
        Stub.TODO();

        var uiParams = new StatsUiParams(
            mainWindowRectangle,
            Tig.FS.ReadMesFile("art/interface/char_ui/char_stats_ui/1_char_stats_ui.mes"),
            Tig.FS.ReadMesFile("art/interface/char_ui/char_stats_ui/1_char_stats_ui_textures.mes"),
            Tig.FS.ReadMesFile("mes/1_char_stats_ui_text.mes")
            );

        Container         = new WidgetContainer(uiParams.MainWindow);
        Container.Visible = false;

        CreateMoneyLabels(uiParams);

        CreateXpAndLevelLabels(uiParams);

        CreateAbilityScoreLabels(uiParams);

        CreateDefensiveLabels(uiParams);

        CreateSavingThrowLabels(uiParams);

        CreatePhysicalAppearanceLabels(uiParams);

        CreateCombatLabels(uiParams);
    }
    private void CreateSavingThrowLabels(StatsUiParams uiParams)
    {
        void AddWidgets(Stat stat, string helpTopic, Rectangle labelRect, Rectangle valueRect)
        {
            Container.Add(new StatsLabel(stat,
                                         helpTopic,
                                         labelRect,
                                         StatsUiTexture.ButtonFORTClick,
                                         StatsUiTexture.ButtonFORTHover,
                                         uiParams
                                         ));
            var valueWidget = new StatsValue(
                obj => GetStatModifierText(obj, stat),
                valueRect,
                StatsUiTexture.ButtonFORTOutputClick,
                StatsUiTexture.ButtonFORTOutputHover,
                uiParams
                );

            valueWidget.SetClickHandler(() => ShowSavingThrowHelp(stat));
            Container.Add(valueWidget);
        }

        AddWidgets(Stat.save_fortitude, "TAG_FORTITUDE", uiParams.FortLabel, uiParams.FortValue);
        AddWidgets(Stat.save_reflexes, "TAG_REFLEX", uiParams.RefLabel, uiParams.RefValue);
        AddWidgets(Stat.save_willpower, "TAG_WILL", uiParams.WillLabel, uiParams.WillValue);
    }
    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 StatsValue(
     Func <GameObject, string> valueSupplier,
     Rectangle rect,
     StatsUiTexture downImage,
     StatsUiTexture hoverImage,
     StatsUiParams uiParams) : this(obj => new SimpleInlineElement(valueSupplier(obj)),
                                    rect,
                                    downImage,
                                    hoverImage,
                                    uiParams)
 {
 }
 private static string GetStatName(StatsUiParams uiParams, Stat stat)
 {
     if (stat == Stat.initiative_bonus || stat == Stat.movement_speed)
     {
         return(GameSystems.Stat.GetStatName(stat));
     }
     else if (stat == Stat.melee_attack_bonus)
     {
         return(uiParams.PrimaryAtkLabelText);
     }
     else if (stat == Stat.ranged_attack_bonus)
     {
         return(uiParams.SecondaryAtkLabelText);
     }
     else
     {
         return(GameSystems.Stat.GetStatShortName(stat));
     }
 }
示例#9
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);
    }
    private void CreateDefensiveLabels(StatsUiParams uiParams)
    {
        Container.Add(new StatsLabel(Stat.hp_current,
                                     "TAG_HIT_POINTS",
                                     uiParams.HpLabel,
                                     StatsUiTexture.ButtonHPClick,
                                     StatsUiTexture.ButtonHPHover,
                                     uiParams
                                     ));
        var hpValue = new StatsValue(
            GetHitPointsText,
            uiParams.HpValue,
            StatsUiTexture.ButtonHPOutputClick,
            StatsUiTexture.ButtonHPOutputHover,
            uiParams
            );

        hpValue.SetClickHandler(() => GameSystems.Help.ShowTopic("TAG_HIT_POINTS"));
        hpValue.TooltipText = null;
        Container.Add(hpValue);

        Container.Add(new StatsLabel(Stat.ac,
                                     "TAG_ARMOR_CLASS",
                                     uiParams.AcLabel,
                                     StatsUiTexture.ButtonHPClick,
                                     StatsUiTexture.ButtonHPHover,
                                     uiParams
                                     ));
        var acValue = new StatsValue(
            obj => GetStatValue(obj, Stat.ac),
            uiParams.AcValue,
            StatsUiTexture.ButtonHPOutputClick,
            StatsUiTexture.ButtonHPOutputHover,
            uiParams
            );

        acValue.SetClickHandler(ShowArmorClassHelp);
        Container.Add(acValue);
    }
    private void CreatePhysicalAppearanceLabels(StatsUiParams uiParams)
    {
        Container.Add(new StatsLabel(Stat.height,
                                     null,
                                     uiParams.HeightLabel,
                                     StatsUiTexture.ButtonHTClick,
                                     StatsUiTexture.ButtonHTHover,
                                     uiParams
                                     ));
        var heightValue = new StatsValue(
            GetHeightText,
            uiParams.HeightValue,
            StatsUiTexture.ButtonHTOutputClick,
            StatsUiTexture.ButtonHTOutputHover,
            uiParams
            );

        heightValue.TooltipText = null;
        Container.Add(heightValue);

        Container.Add(new StatsLabel(Stat.weight,
                                     null,
                                     uiParams.WeightLabel,
                                     StatsUiTexture.ButtonHTClick,
                                     StatsUiTexture.ButtonHTHover,
                                     uiParams
                                     ));
        var weightValue = new StatsValue(
            obj => GetStatValue(obj, Stat.weight),
            uiParams.WeightValue,
            StatsUiTexture.ButtonHTOutputClick,
            StatsUiTexture.ButtonHTOutputHover,
            uiParams
            );

        weightValue.TooltipText = null;
        Container.Add(weightValue);
    }
    private void CreateAbilityScoreLabels(StatsUiParams uiParams)
    {
        void AddLabel(Stat stat, string helpTopic, Rectangle rectangle)
        {
            Container.Add(new StatsLabel(stat,
                                         helpTopic,
                                         rectangle,
                                         StatsUiTexture.ButtonSTRClick,
                                         StatsUiTexture.ButtonSTRHover,
                                         uiParams
                                         ));
        }

        void AddScore(Stat stat, Rectangle rectangle)
        {
            var widget = new StatsValue(
                obj => GetAbilityScoreValue(obj, stat),
                rectangle,
                StatsUiTexture.ButtonLevelOutputClick,
                StatsUiTexture.ButtonLevelOutputHover,
                uiParams
                );

            widget.SetClickHandler(() => ShowAbilityScoreHelp(stat));
            Container.Add(widget);
        }

        void AddModifier(Stat stat, Rectangle rectangle)
        {
            var widget = new StatsValue(
                obj => GetStatModifierText(obj, stat),
                rectangle,
                StatsUiTexture.ButtonLevelOutputClick,
                StatsUiTexture.ButtonLevelOutputHover,
                uiParams
                );

            widget.TooltipText = null;
            widget.SetClickHandler(() => { GameSystems.Help.ShowTopic("TAG_ABILITY_MODIFIERS"); });
            Container.Add(widget);
        }

        AddLabel(Stat.strength, "TAG_STRENGTH", uiParams.StrLabel);
        AddScore(Stat.strength, uiParams.StrValue);
        AddModifier(Stat.str_mod, uiParams.StrBonusValue);

        AddLabel(Stat.dexterity, "TAG_DEXTERITY", uiParams.DexLabel);
        AddScore(Stat.dexterity, uiParams.DexValue);
        AddModifier(Stat.dex_mod, uiParams.DexBonusValue);

        AddLabel(Stat.constitution, "TAG_CONSTITUTION", uiParams.ConLabel);
        AddScore(Stat.constitution, uiParams.ConValue);
        AddModifier(Stat.con_mod, uiParams.ConBonusValue);

        AddLabel(Stat.intelligence, "TAG_INTELLIGENCE", uiParams.IntLabel);
        AddScore(Stat.intelligence, uiParams.IntValue);
        AddModifier(Stat.int_mod, uiParams.IntBonusValue);

        AddLabel(Stat.wisdom, "TAG_WISDOM", uiParams.WisLabel);
        AddScore(Stat.wisdom, uiParams.WisValue);
        AddModifier(Stat.wis_mod, uiParams.WisBonusValue);

        AddLabel(Stat.charisma, "TAG_CHARISMA", uiParams.ChaLabel);
        AddScore(Stat.charisma, uiParams.ChaValue);
        AddModifier(Stat.cha_mod, uiParams.ChaBonusValue);
    }
    private void CreateCombatLabels(StatsUiParams uiParams)
    {
        Container.Add(new StatsLabel(Stat.initiative_bonus,
                                     "TAG_INITIATIVE",
                                     uiParams.InitLabel,
                                     StatsUiTexture.ButtonInitiativeClick,
                                     StatsUiTexture.ButtonInitiativeHover,
                                     uiParams
                                     ));
        var initValue = new StatsValue(
            obj => GetStatModifierText(obj, Stat.initiative_bonus),
            uiParams.InitValue,
            StatsUiTexture.ButtonInitiativeOutputClick,
            StatsUiTexture.ButtonInitiativeOutputHover,
            uiParams
            );

        initValue.SetClickHandler(ShowInitiativeBonusHelp);
        Container.Add(initValue);

        Container.Add(new StatsLabel(Stat.movement_speed,
                                     "TAG_MOVEMENT_RATE",
                                     uiParams.SpeedLabel,
                                     StatsUiTexture.ButtonInitiativeClick,
                                     StatsUiTexture.ButtonInitiativeHover,
                                     uiParams
                                     ));
        var speedValue = new StatsValue(
            GetMovementSpeedText,
            uiParams.SpeedValue,
            StatsUiTexture.ButtonInitiativeOutputClick,
            StatsUiTexture.ButtonInitiativeOutputHover,
            uiParams
            );

        speedValue.SetClickHandler(() => GameSystems.Help.ShowTopic("TAG_MOVEMENT_RATE"));
        speedValue.TooltipText = null;
        Container.Add(speedValue);


        // Primary Weapon Attack Bonus
        Container.Add(new StatsLabel(Stat.melee_attack_bonus,
                                     "TAG_COMBAT",
                                     uiParams.PrimaryAtkLabel,
                                     StatsUiTexture.ButtonInitiativeClick,
                                     StatsUiTexture.ButtonInitiativeHover,
                                     uiParams
                                     ));
        var primaryAtkValue = new StatsValue(
            GetPrimaryWeaponAttackBonus,
            uiParams.PrimaryAtkValue,
            StatsUiTexture.ButtonInitiativeOutputClick,
            StatsUiTexture.ButtonInitiativeOutputHover,
            uiParams
            );

        primaryAtkValue.SetClickHandler(ShowPrimaryWeaponAttackBonusHelp);
        Container.Add(primaryAtkValue);

        // Secondary Weapon Attack Bonus
        Container.Add(new StatsLabel(Stat.ranged_attack_bonus,
                                     "TAG_COMBAT",
                                     uiParams.SecondaryAtkLabel,
                                     StatsUiTexture.ButtonInitiativeClick,
                                     StatsUiTexture.ButtonInitiativeHover,
                                     uiParams
                                     ));
        var secondaryAtkValue = new StatsValue(
            GetSecondaryWeaponAttackBonus,
            uiParams.SecondaryAtkValue,
            StatsUiTexture.ButtonInitiativeOutputClick,
            StatsUiTexture.ButtonInitiativeOutputHover,
            uiParams
            );

        secondaryAtkValue.SetClickHandler(ShowSecondaryWeaponAttackBonusHelp);
        Container.Add(secondaryAtkValue);
    }