public void ReceiveData(object gameMemory) { gameMemoryRE3 = (GameMemoryRE3)gameMemory; try { if (gameMemoryRE3.Player.CurrentHP != previousHealth) { previousHealth = gameMemoryRE3.Player.CurrentHP; // Draw health. if (gameMemoryRE3.Player.CurrentHP > 1200 || gameMemoryRE3.Player.CurrentHP <= 0) // Dead? { healthBrush = Brushes.Red; healthX = 82f; currentHP = "DEAD"; this.playerHealthStatus.ThreadSafeSetHealthImage(Properties.Resources.EMPTY, "EMPTY"); } else if (gameMemoryRE3.Player.CurrentHP >= 801) // Fine (Green) { healthBrush = Brushes.LawnGreen; healthX = 15f; currentHP = gameMemoryRE3.Player.CurrentHP.ToString(); this.playerHealthStatus.ThreadSafeSetHealthImage(Properties.Resources.FINE, "FINE"); } else if (gameMemoryRE3.Player.CurrentHP <= 800 && gameMemoryRE3.Player.CurrentHP >= 361) // Caution (Yellow) { healthBrush = Brushes.Goldenrod; healthX = 15f; currentHP = gameMemoryRE3.Player.CurrentHP.ToString(); this.playerHealthStatus.ThreadSafeSetHealthImage(Properties.Resources.CAUTION_YELLOW, "CAUTION_YELLOW"); } else if (gameMemoryRE3.Player.CurrentHP <= 360) // Danger (Red) { healthBrush = Brushes.Red; healthX = 15f; currentHP = gameMemoryRE3.Player.CurrentHP.ToString(); this.playerHealthStatus.ThreadSafeSetHealthImage(Properties.Resources.DANGER, "DANGER"); } this.playerHealthStatus.Invalidate(); } if (!Program.config.NoInventory) { if (!gameMemoryRE3.PlayerInventory.SequenceEqual(previousInventory)) { this.inventoryPanel.Invalidate(); } } // Always draw this as these are simple text draws and contains the IGT/frame count. this.statisticsPanel.Invalidate(); } catch (Exception ex) { Debug.WriteLine("[{0}] {1}\r\n{2}", ex.GetType().ToString(), ex.Message, ex.StackTrace); } }
public void ReceiveData(object gameMemory) { gameMemoryRE3 = (GameMemoryRE3)gameMemory; try { if (Program.programSpecialOptions.Flags.HasFlag(ProgramFlags.AlwaysOnTop)) { bool hasFocus; if (this.InvokeRequired) { hasFocus = PInvoke.HasActiveFocus((IntPtr)this.Invoke(new Func <IntPtr>(() => this.Handle))); } else { hasFocus = PInvoke.HasActiveFocus(this.Handle); } if (!hasFocus) { if (this.InvokeRequired) { this.Invoke(new Action(() => this.TopMost = true)); } else { this.TopMost = true; } } } // Only draw occasionally, not as often as the stats panel. if (DateTime.UtcNow.Ticks - lastFullUIDraw >= FULL_UI_DRAW_TICKS) { // Update the last drawn time. lastFullUIDraw = DateTime.UtcNow.Ticks; // Only draw these periodically to reduce CPU usage. this.playerHealthStatus.Invalidate(); if (!Program.programSpecialOptions.Flags.HasFlag(ProgramFlags.NoInventory)) { this.inventoryPanel.Invalidate(); } } // Always draw this as these are simple text draws and contains the IGT/frame count. this.statisticsPanel.Invalidate(); } catch (Exception ex) { Debug.WriteLine("[{0}] {1}\r\n{2}", ex.GetType().ToString(), ex.Message, ex.StackTrace); } }