Exemplo n.º 1
0
        public D2IngameActorInfoDisplayLogic(Widget widget, World world, WorldRenderer worldRenderer)
        {
            this.world         = world;
            this.worldRenderer = worldRenderer;

            var textColor = Color.FromArgb(71, 71, 55);

            panel = widget.GetOrNull <D2PanelWidget>("PANEL");

            label = widget.GetOrNull <LabelWidget>("NAME");
            if (label != null)
            {
                label.Align     = TextAlign.Center;
                label.TextColor = textColor;
                label.Font      = "MediumBold";
            }

            preview = widget.GetOrNull <D2SpriteWidget>("ICON");

            health = widget.GetOrNull <D2ProgressBarWidget>("HEALTH");

            dmgLabel = widget.GetOrNull <LabelWidget>("DMG");
            if (dmgLabel != null)
            {
                dmgLabel.Text      = "DMG";
                dmgLabel.Align     = TextAlign.Center;
                dmgLabel.TextColor = textColor;
                dmgLabel.Font      = "MediumBold";
            }

            title = widget.GetOrNull <LabelWidget>("TITLE");
            if (title != null)
            {
                title.Align     = TextAlign.Center;
                title.TextColor = textColor;
                title.Font      = "MediumBold";
            }

            separator = widget.GetOrNull <D2LineWidget>("SEPARATOR");

            line1a = widget.GetOrNull <LabelWidget>("LINE1A");
            if (line1a != null)
            {
                line1a.TextColor = textColor;
                line1a.Font      = "MediumBold";
            }

            line1b = widget.GetOrNull <LabelWidget>("LINE1B");
            if (line1b != null)
            {
                line1b.Align     = TextAlign.Right;
                line1b.TextColor = textColor;
                line1b.Font      = "MediumBold";
            }

            line2a = widget.GetOrNull <LabelWidget>("LINE2A");
            if (line2a != null)
            {
                line2a.TextColor = textColor;
                line2a.Font      = "MediumBold";
            }

            line2b = widget.GetOrNull <LabelWidget>("LINE2B");
            if (line2b != null)
            {
                line2b.Align     = TextAlign.Right;
                line2b.TextColor = textColor;
                line2b.Font      = "MediumBold";
            }
        }
Exemplo n.º 2
0
        public D2IngameActorLogic(Widget widget, World world, WorldRenderer worldRenderer)
        {
            this.world         = world;
            this.worldRenderer = worldRenderer;

            var textColor = Color.FromArgb(71, 71, 55);

            panel = widget.GetOrNull <D2PanelWidget>("PANEL");

            label = widget.GetOrNull <LabelWidget>("NAME");
            if (label != null)
            {
                label.Align     = TextAlign.Center;
                label.TextColor = textColor;
                label.Font      = "MediumBold";
            }

            preview = widget.GetOrNull <D2SpriteWidget>("ICON");

            health = widget.GetOrNull <D2ProgressBarWidget>("HEALTH");

            dmgLabel = widget.GetOrNull <LabelWidget>("DMG");
            if (dmgLabel != null)
            {
                dmgLabel.Text      = "DMG";
                dmgLabel.Align     = TextAlign.Center;
                dmgLabel.TextColor = textColor;
                dmgLabel.Font      = "MediumBold";
            }

            title = widget.GetOrNull <LabelWidget>("TITLE");
            if (title != null)
            {
                title.Align     = TextAlign.Center;
                title.TextColor = textColor;
                title.Font      = "MediumBold";
            }

            separator = widget.GetOrNull <D2LineWidget>("SEPARATOR");

            line1a = widget.GetOrNull <LabelWidget>("LINE1A");
            if (line1a != null)
            {
                line1a.TextColor = textColor;
                line1a.Font      = "MediumBold";
            }

            line1b = widget.GetOrNull <LabelWidget>("LINE1B");
            if (line1b != null)
            {
                line1b.Align     = TextAlign.Right;
                line1b.TextColor = textColor;
                line1b.Font      = "MediumBold";
            }

            line2a = widget.GetOrNull <LabelWidget>("LINE2A");
            if (line2a != null)
            {
                line2a.TextColor = textColor;
                line2a.Font      = "MediumBold";
            }

            line2b = widget.GetOrNull <LabelWidget>("LINE2B");
            if (line2b != null)
            {
                line2b.Align     = TextAlign.Right;
                line2b.TextColor = textColor;
                line2b.Font      = "MediumBold";
            }

            buttonsBackground = widget.GetOrNull <ColorBlockWidget>("BUTTONS_BACKGROUND");
            if (buttonsBackground != null)
            {
                buttonsBackground.Visible = false;
            }

            attackButton = widget.GetOrNull <D2ButtonWidget>("ATTACK");
            if (attackButton != null)
            {
                attackButton.Visible       = false;
                attackButton.IsHighlighted = () => IsForceModifiersActive(Modifiers.Ctrl) &&
                                             !(world.OrderGenerator is AttackMoveOrderGenerator);

                Action <bool> toggle = allowCancel =>
                {
                    if (attackButton.IsHighlighted())
                    {
                        world.CancelInputMode();
                    }
                    else
                    {
                        world.OrderGenerator = new ForceModifiersOrderGenerator(Modifiers.Ctrl, true);
                    }
                };

                attackButton.OnClick    = () => toggle(true);
                attackButton.OnKeyPress = _ => toggle(false);
            }

            moveButton = widget.GetOrNull <D2ButtonWidget>("MOVE");
            if (moveButton != null)
            {
                moveButton.Visible       = false;
                moveButton.IsHighlighted = () => !moveButton.IsDisabled() && IsForceModifiersActive(Modifiers.Alt);
                Action <bool> toggle = allowCancel =>
                {
                    if (moveButton.IsHighlighted())
                    {
                        world.CancelInputMode();
                    }
                    else
                    {
                        world.OrderGenerator = new ForceModifiersOrderGenerator(Modifiers.Alt, true);
                    }
                };

                moveButton.OnClick    = () => toggle(true);
                moveButton.OnKeyPress = _ => toggle(false);
            }

            retreatButton = widget.GetOrNull <D2ButtonWidget>("RETREAT");
            if (retreatButton != null)
            {
                retreatButton.Visible = false;

                retreatButton.OnClick = () =>
                {
                    PerformKeyboardOrderOnSelection(a => new Order("Stop", a, false));
                };

                retreatButton.OnKeyPress = ki => { retreatButton.OnClick(); };
            }

            guardButton = widget.GetOrNull <D2ButtonWidget>("GUARD");
            if (guardButton != null)
            {
                guardButton.Visible       = false;
                guardButton.IsHighlighted = () => world.OrderGenerator is GuardOrderGenerator;

                Action <bool> toggle = allowCancel =>
                {
                    if (guardButton.IsHighlighted())
                    {
                        if (allowCancel)
                        {
                            world.CancelInputMode();
                        }
                    }
                    else
                    {
                        world.OrderGenerator = new GuardOrderGenerator(selectedActors,
                                                                       "Guard", "guard", Game.Settings.Game.MouseButtonPreference.Action);
                    }
                };

                guardButton.OnClick    = () => toggle(true);
                guardButton.OnKeyPress = _ => toggle(false);
            }
        }