mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 04:08:01 +00:00
Support drawing path connecting opponent positions
This commit is contained in:
@@ -115,15 +115,36 @@ public class ConquestMapScreen extends FScreen {
|
||||
}
|
||||
|
||||
//draw path with opponents
|
||||
float x0, y0, prevX = x + w / 2, prevY = y + h;
|
||||
float gridSize = h / rows;
|
||||
float iconSize = gridSize * 0.5f;
|
||||
float iconOffset = (gridSize - iconSize) / 2;
|
||||
float lineThickness = iconSize / 4;
|
||||
float dx = (w - h * cols / rows) / 2; //center grid
|
||||
FCollectionView<ConquestOpponent> opponents = region.getOpponents();
|
||||
|
||||
//draw line path
|
||||
for (int i = 0; i < opponents.size(); i++) {
|
||||
GridPosition pos = path[i];
|
||||
float x0 = x + gridSize * pos.col + dx + iconOffset;
|
||||
float y0 = y + gridSize * pos.row + iconOffset;
|
||||
x0 = x + gridSize * pos.col + dx + gridSize / 2;
|
||||
y0 = y + gridSize * pos.row + gridSize / 2;
|
||||
if (i > 0 || index < model.getCurrentPlane().getRegions().size() - 1) { //extend path from previous region if any
|
||||
g.drawLine(lineThickness, Color.WHITE, x0, y0, prevX, prevY);
|
||||
}
|
||||
prevX = x0;
|
||||
prevY = y0;
|
||||
}
|
||||
|
||||
//extend path to next region if not topmost region
|
||||
if (index > 0) {
|
||||
g.drawLine(lineThickness, Color.WHITE, prevX, prevY, prevX, y);
|
||||
}
|
||||
|
||||
//draw icons for stops along path for opponents
|
||||
for (int i = 0; i < opponents.size(); i++) {
|
||||
GridPosition pos = path[i];
|
||||
x0 = x + gridSize * pos.col + dx + iconOffset;
|
||||
y0 = y + gridSize * pos.row + iconOffset;
|
||||
g.drawImage((FImage)opponents.get(i).getMapIcon(), x0, y0, iconSize, iconSize);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user