コード例 #1
0
    private void HandleNormalKeyStateChange(IGameViewport viewport, MessageKeyStateChangeArgs args)
    {
        if (args.down)
        {
            return;
        }

        var leader = GameSystems.Party.GetConsciousLeader();

        if (leader != null)
        {
            if (GameSystems.D20.Hotkeys.IsReservedHotkey(args.key))
            {
                if (Tig.Keyboard.IsKeyPressed(VirtualKey.VK_LCONTROL) ||
                    Tig.Keyboard.IsKeyPressed(VirtualKey.VK_RCONTROL))
                {
                    // trying to assign hotkey to reserved hotkey
                    GameSystems.D20.Hotkeys.HotkeyReservedPopup(args.key);
                    return;
                }
            }
            else if (GameSystems.D20.Hotkeys.IsNormalNonreservedHotkey(args.key))
            {
                if (Tig.Keyboard.IsKeyPressed(VirtualKey.VK_LCONTROL) ||
                    Tig.Keyboard.IsKeyPressed(VirtualKey.VK_RCONTROL))
                {
                    // assign hotkey
                    var leaderLoc = leader.GetLocationFull();
                    var screenPos = viewport.WorldToScreen(leaderLoc.ToInches3D());

                    UiSystems.RadialMenu.Spawn(viewport, (int)screenPos.X, (int)screenPos.Y);
                    UiSystems.RadialMenu.HandleKeyMessage(args);
                    return;
                }

                GameSystems.D20.Actions.TurnBasedStatusInit(leader);
                leader = GameSystems.Party.GetConsciousLeader(); // in case the leader changes somehow...
                Logger.Info("Intgame: Resetting sequence.");
                GameSystems.D20.Actions.CurSeqReset(leader);

                GameSystems.D20.Actions.GlobD20ActnInit();
                if (GameSystems.D20.Hotkeys.RadmenuHotkeySthg(GameSystems.Party.GetConsciousLeader(), args.key))
                {
                    GameSystems.D20.Actions.ActionAddToSeq();
                    GameSystems.D20.Actions.sequencePerform();
                    PlayVoiceConfirmationSound(leader);
                    GameSystems.D20.RadialMenu.ClearActiveRadialMenu();
                    return;
                }
            }
        }

        UiSystems.KeyManager.InputState = 0;
        UiSystems.KeyManager.HandleKeyEvent(args);
    }
コード例 #2
0
    private void RenderDebugInfo(IGameViewport gameViewport, PartSys sys)
    {
        var screenPos    = gameViewport.WorldToScreen(sys.WorldPos);
        var screenX      = screenPos.X;
        var screenY      = screenPos.Y;
        var screenBounds = sys.GetScreenBounds();

        var left   = screenX + screenBounds.left * gameViewport.Zoom;
        var top    = screenY + screenBounds.top * gameViewport.Zoom;
        var right  = screenX + screenBounds.right * gameViewport.Zoom;
        var bottom = screenY + screenBounds.bottom * gameViewport.Zoom;

        var color = new PackedLinearColorA(0, 0, 255, 255);

        Span <Line2d> lines = stackalloc Line2d[4]
        {
            new Line2d(new Vector2(left, top), new Vector2(right, top), color),
            new Line2d(new Vector2(right, top), new Vector2(right, bottom), color),
            new Line2d(new Vector2(right, bottom), new Vector2(left, bottom), color),
            new Line2d(new Vector2(left, bottom), new Vector2(left, top), color)
        };

        _shapeRenderer2d.DrawLines(lines);

        var textEngine = Tig.RenderingDevice.TextEngine;

        var text = $"{sys.GetSpec().GetName()}";

        var style   = Globals.UiStyles.GetComputed("default");
        var metrics = textEngine.MeasureText(style, text, (int)(right - left), (int)(bottom - top));

        textEngine.RenderText(
            new RectangleF(
                (left + right - metrics.width) / 2f,
                (top + bottom - metrics.height) / 2f,
                (int)(right - left),
                (int)(bottom - top)
                ),
            style,
            text
            );
    }
}
コード例 #3
0
    public void Render(IGameViewport viewport, LocAndOffsets location, ITexture texture)
    {
        var screenPos = viewport.WorldToScreen(location.ToInches3D());

        var contentRect = texture.GetContentRect();
        var renderArgs  = new Render2dArgs
        {
            srcRect  = contentRect,
            flags    = Render2dFlag.BUFFERTEXTURE,
            destRect = new Rectangle(
                (int)(screenPos.X - contentRect.Width / 2),
                (int)(screenPos.Y - contentRect.Height / 2),
                contentRect.Width,
                contentRect.Height
                ),
            customTexture = texture
        };

        Tig.ShapeRenderer2d.DrawRectangle(ref renderArgs);
    }
コード例 #4
0
    public static void RenderAnimGoals(IGameViewport viewport, GameObject obj)
    {
        RenderCurrentGoalPath(viewport, obj);

        var worldLocAboveHead = obj.GetLocationFull().ToInches3D(obj.GetRenderHeight());

        var topOfObjectInUi = viewport.WorldToScreen(worldLocAboveHead);

        var renderer2d = Tig.ShapeRenderer2d;

        var textEngine = Tig.RenderingDevice.TextEngine;

        var slotIdsPerLine = new List <int>();
        var lines          = new List <TextLayout>();

        var style = Globals.UiStyles.StyleResolver.Resolve(
            new[] { Globals.UiStyles.Get("default-button-text") }
            );

        var overallHeight = 0f;

        foreach (var slot in GameSystems.Anim.EnumerateSlots(obj))
        {
            for (int i = 0; i <= slot.currentGoal; i++)
            {
                var stackEntry = slot.goals[i];
                var goalName   = stackEntry.goalType.ToString();
                var text       = i == slot.currentGoal ? $"{goalName} ({slot.currentState})" : goalName;

                slotIdsPerLine.Add(slotIdsPerLine.Count);
                var layout = textEngine.CreateTextLayout(style, text, 120, 500);
                overallHeight += layout.OverallHeight + 1;
                lines.Add(layout);
            }
        }

        var x = (int)(topOfObjectInUi.X - 60);
        var y = topOfObjectInUi.Y - overallHeight;

        // Render the object name above the goal list
        if (ShowObjectNames)
        {
            var protoNum    = obj.ProtoId;
            var displayName = GameSystems.MapObject.GetDisplayName(obj);

            var paragraph = new Paragraph();
            paragraph.LocalStyles.DropShadowColor = PackedLinearColorA.Black;
            var nameStyle = new StyleDefinition {
                FontWeight = FontWeight.Bold
            };
            paragraph.AppendContent(displayName, nameStyle);
            paragraph.AppendContent($" #{protoNum}");

            using var layout = textEngine.CreateTextLayout(paragraph, 0, 0);

            textEngine.RenderTextLayout(
                x + 60 - layout.OverallWidth / 2,
                y - layout.OverallHeight - 2,
                layout
                );
        }

        // Draw in reverse because the stack is actually ordered the other way around
        var prevSlotIdx = -1;

        for (var i = lines.Count - 1; i >= 0; i--)
        {
            using var layout = lines[i];
            var slotIdx = slotIdsPerLine[i];
            renderer2d.DrawRectangle(
                x,
                y,
                120.0f,
                layout.OverallHeight,
                null,
                new PackedLinearColorA(127, 127, 127, 127)
                );

            // When starting rendering info about a new slot, draw a border at the top
            // and draw the slot idx on the left, outside of the text box
            if (slotIdx != prevSlotIdx)
            {
                prevSlotIdx = slotIdx;
                RenderSlotHeader(x, y, slotIdx, style, layout.OverallHeight);
            }

            textEngine.RenderTextLayout(x, y, layout);

            y += layout.OverallHeight + 1;
        }
    }