Example #1
0
        private void DrawProgressBarDirectX(GameOverlay.Drawing.Graphics g, GameOverlay.Drawing.SolidBrush bgBrush, GameOverlay.Drawing.SolidBrush foreBrush, float x, float y, float width, float height, float value, float maximum = 100)
        {
            // Draw BG.
            g.DrawRectangle(bgBrush, x, y, x + width, y + height, 3f);

            // Draw FG.
            GameOverlay.Drawing.Rectangle foreRect = new GameOverlay.Drawing.Rectangle(
                x,
                y,
                x + ((width * value / maximum)),
                y + (height)
                );
            g.FillRectangle(foreBrush, foreRect);
        }
Example #2
0
        public MainUI()
        {
            InitializeComponent();

            // Set titlebar.
            this.Text += string.Format(" {0}", Program.srtVersion);

            this.ContextMenu = Program.contextMenu;
            this.playerHealthStatus.ContextMenu = Program.contextMenu;
            this.statisticsPanel.ContextMenu    = Program.contextMenu;
            this.inventoryPanel.ContextMenu     = Program.contextMenu;

            //GDI+
            this.playerHealthStatus.Paint += this.playerHealthStatus_Paint;
            this.statisticsPanel.Paint    += this.statisticsPanel_Paint;
            this.inventoryPanel.Paint     += this.inventoryPanel_Paint;

            // DirectX
            if (Program.programSpecialOptions.Flags.HasFlag(ProgramFlags.DirectXOverlay))
            {
                overlay = new DXOverlay(Program.gameWindowHandle);
                overlay.Initialize((GameOverlay.Windows.OverlayWindow w, GameOverlay.Drawing.Graphics g) =>
                {
                    font       = g.CreateFont("Consolas", 8, true);
                    redBrush   = g.CreateSolidBrush(255, 0, 0);
                    whiteBrush = g.CreateSolidBrush(255, 255, 255);
                    greyBrush  = g.CreateSolidBrush(150, 150, 150);
                    blackBrush = g.CreateSolidBrush(0, 0, 0);

                    backBrushDirectX = g.CreateSolidBrush(60, 60, 60);
                    foreBrushDirectX = g.CreateSolidBrush(100, 0, 0);
                });
                overlay.Run(statisticsPanelDirectX_Paint, CancellationToken.None);
            }

            if (Program.programSpecialOptions.Flags.HasFlag(ProgramFlags.NoTitleBar))
            {
                this.FormBorderStyle = FormBorderStyle.None;
            }

            if (Program.programSpecialOptions.Flags.HasFlag(ProgramFlags.Transparent))
            {
                this.TransparencyKey = Color.Black;
            }

            // Only run the following code if we're rendering inventory.
            if (!Program.programSpecialOptions.Flags.HasFlag(ProgramFlags.NoInventory))
            {
                GameMemory.GenerateImages();

                // Create a black slot image for when side-pack is not equipped.
                inventoryError = new Bitmap(Program.INV_SLOT_WIDTH, Program.INV_SLOT_HEIGHT, PixelFormat.Format32bppPArgb);
                using (Graphics grp = Graphics.FromImage(inventoryError))
                {
                    grp.FillRectangle(new SolidBrush(Color.FromArgb(255, 0, 0, 0)), 0, 0, inventoryError.Width, inventoryError.Height);
                    grp.DrawLine(new Pen(Color.FromArgb(150, 255, 0, 0), 3), 0, 0, inventoryError.Width, inventoryError.Height);
                    grp.DrawLine(new Pen(Color.FromArgb(150, 255, 0, 0), 3), inventoryError.Width, 0, 0, inventoryError.Height);
                }

                // Set the width and height of the inventory display so it matches the maximum items and the scaling size of those items.
                this.inventoryPanel.Width  = Program.INV_SLOT_WIDTH * 4;
                this.inventoryPanel.Height = Program.INV_SLOT_HEIGHT * 5;

                // Adjust main form width as well.
                this.Width = this.statisticsPanel.Width + 24 + this.inventoryPanel.Width;

                // Only adjust form height if its greater than 461. We don't want it to go below this size.
                if (41 + this.inventoryPanel.Height > 461)
                {
                    this.Height = 41 + this.inventoryPanel.Height;
                }
            }
            else
            {
                // Disable rendering of the inventory panel.
                this.inventoryPanel.Visible = false;

                // Adjust main form width as well.
                this.Width = this.statisticsPanel.Width + 2;
            }

            lastPtrUpdate  = DateTime.UtcNow.Ticks;
            lastFullUIDraw = DateTime.UtcNow.Ticks;
        }