()
| 453 | public static int FRAME_RATE = 1000 / 30; |
| 454 | |
| 455 | public void redrawMemoryView() { |
| 456 | if (cheatEngine == null) { |
| 457 | return; |
| 458 | } |
| 459 | Emulator.whileSuspended(c-> { |
| 460 | if (animationTimer == null) { |
| 461 | animationTimer = new ScheduledThreadPoolExecutor(1); |
| 462 | } |
| 463 | |
| 464 | if (animationFuture != null) { |
| 465 | animationFuture.cancel(false); |
| 466 | } |
| 467 | |
| 468 | cheatEngine.initMemoryView(); |
| 469 | int pixelsPerBlock = 16 * MEMORY_BOX_TOTAL_SIZE; |
| 470 | memoryViewColumns = (int) (memoryViewPane.getWidth() / pixelsPerBlock) * 16; |
| 471 | memoryViewRows = ((cheatEngine.getEndAddress() - cheatEngine.getStartAddress()) / memoryViewColumns) + 1; |
| 472 | double canvasHeight = memoryViewRows * MEMORY_BOX_TOTAL_SIZE * drawScale; |
| 473 | |
| 474 | memoryViewContents.setPrefHeight(canvasHeight); |
| 475 | memoryViewCanvas.setHeight(canvasHeight); |
| 476 | GraphicsContext context = memoryViewCanvas.getGraphicsContext2D(); |
| 477 | context.setFill(Color.rgb(40, 40, 40)); |
| 478 | context.fillRect(0, 0, memoryViewCanvas.getWidth(), memoryViewCanvas.getHeight()); |
| 479 | for (int addr = cheatEngine.getStartAddress(); addr <= cheatEngine.getEndAddress(); addr++) { |
| 480 | int col = (addr - cheatEngine.getStartAddress()) % memoryViewColumns; |
| 481 | int row = (addr - cheatEngine.getStartAddress()) / memoryViewColumns; |
| 482 | MemoryCell cell = cheatEngine.getMemoryCell(addr); |
| 483 | cell.setRect( |
| 484 | (int) (col * MEMORY_BOX_TOTAL_SIZE * drawScale), |
| 485 | (int) (row * MEMORY_BOX_TOTAL_SIZE * drawScale), |
| 486 | (int) (MEMORY_BOX_SIZE * drawScale), |
| 487 | (int) (MEMORY_BOX_SIZE * drawScale)); |
| 488 | redrawNodes.put(cell.address, cell); |
| 489 | } |
| 490 | MemoryCell.setListener((javafx.beans.value.ObservableValue<? extends jace.cheat.MemoryCell> prop, jace.cheat.MemoryCell oldCell, jace.cheat.MemoryCell newCell) -> { |
| 491 | redrawNodes.put(newCell.address, newCell); |
| 492 | }); |
| 493 | |
| 494 | setZoom(1/drawScale); |
| 495 | animationFuture = animationTimer.scheduleAtFixedRate(this::processMemoryViewUpdates, FRAME_RATE, FRAME_RATE, TimeUnit.MILLISECONDS); |
| 496 | }); |
| 497 | } |
| 498 | |
| 499 | private void changeZoom(double amount) { |
| 500 | if (memoryViewCanvas != null) { |
no test coverage detected