puzzlesolver: add an option to draw dots instead of arrows

This commit is contained in:
Lotto
2018-02-23 23:47:03 +01:00
parent f6a0f48601
commit 31af43e9be
2 changed files with 82 additions and 39 deletions

View File

@@ -55,4 +55,14 @@ public interface PuzzleSolverConfig extends Config
{ {
return true; return true;
} }
@ConfigItem(
keyName = "drawDots",
name = "Draw dots instead of arrows",
description = "Draw dots increasing in size instead of arrows for the solution"
)
default boolean drawDots()
{
return false;
}
} }

View File

@@ -26,6 +26,7 @@
*/ */
package net.runelite.client.plugins.puzzlesolver; package net.runelite.client.plugins.puzzlesolver;
import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.FontMetrics; import java.awt.FontMetrics;
import java.awt.Graphics2D; import java.awt.Graphics2D;
@@ -70,6 +71,7 @@ public class PuzzleSolverOverlay extends Overlay
private static final int INFO_BOX_BOTTOM_BORDER = 2; private static final int INFO_BOX_BOTTOM_BORDER = 2;
private static final int PUZZLE_TILE_SIZE = 39; private static final int PUZZLE_TILE_SIZE = 39;
private static final int DOT_MARKER_SIZE = 16;
private static final int BLANK_TILE_VALUE = -1; private static final int BLANK_TILE_VALUE = -1;
private static final int DIMENSION = 5; private static final int DIMENSION = 5;
@@ -208,6 +210,36 @@ public class PuzzleSolverOverlay extends Overlay
} }
if (config.displaySolution()) if (config.displaySolution())
{
if (config.drawDots())
{
graphics.setColor(Color.YELLOW);
// Display the next 4 steps
for (int j = 1; j < 5; j++)
{
Integer futureMove = solver.getStep(solver.getPosition() + j);
if (futureMove == null)
{
break;
}
int blankX = futureMove % DIMENSION;
int blankY = futureMove / DIMENSION;
int markerSize = DOT_MARKER_SIZE - j * 3;
int x = puzzleBoxLocation.getX() + blankX * PUZZLE_TILE_SIZE
+ PUZZLE_TILE_SIZE / 2 - markerSize / 2;
int y = puzzleBoxLocation.getY() + blankY * PUZZLE_TILE_SIZE
+ PUZZLE_TILE_SIZE / 2 - markerSize / 2;
graphics.fillOval(x, y, markerSize, markerSize);
}
}
else
{ {
// Find the current blank tile position // Find the current blank tile position
Integer currentMove = solver.getStep(solver.getPosition()); Integer currentMove = solver.getStep(solver.getPosition());
@@ -265,6 +297,7 @@ public class PuzzleSolverOverlay extends Overlay
} }
} }
} }
}
// Draw info box // Draw info box
if (infoString != null) if (infoString != null)