{
// log.debug(".paint()");
super.paintComponent(g);
Graphics2D g2d = (Graphics2D) g;
Game game = Manager.getGame();
GameBoard b = game.getBoard();
Options opt = Manager.getOptions();
int maxMoves = opt.getNumberOfMoves();
int mrXPos = detYOffset+pixPerDetective*opt.getNumberOfDetectives()+10;
int y = 0;
if(b.getDetectives()!=null && game.getState() != Game.NO_GAME) {
if(startGameButton!=null && startGameButton.isVisible()) startGameButton.setVisible(false);
g2d.drawString("Current turn: "+game.getCurrentMove()+" of "+maxMoves, 10, 20);
g2d.drawString(""+game.getStateText(), 10, 40);
g2d.drawString("Detective positions:", 10, detYOffset-20);
g2d.drawLine(10, detYOffset-18, 120, detYOffset-18);
int activeDet = game.getActiveDetectiveIndex();
for(int i=0;i<opt.getNumberOfDetectives();i++) {
if(i==activeDet) {
g2d.setColor(Color.CYAN);
g2d.fillRect(18, detYOffset-12+pixPerDetective*i, 100, 15);
}
Detective d = b.getDetectives()[i];
g2d.setColor(Color.BLACK);
if(d.isStranded()) {
g2d.setColor(Color.RED);
}
g2d.drawString("Detective "+(i+1)+": "+d.getPosition().getPosition(), 20, detYOffset+pixPerDetective*i);
g2d.setColor(Detective.getColor(i));
g2d.fillOval(5, detYOffset-9+pixPerDetective*i, 10, 10);
g2d.setColor(Move.getColor(TAXI));
g2d.drawString(""+d.getTaxiTickets()+"x T", 20, detYOffset+pixPerDetective*i+20);
g2d.setColor(Move.getColor(BUS));
g2d.drawString(""+d.getBusTickets()+"x B", 60, detYOffset+pixPerDetective*i+20);
g2d.setColor(Move.getColor(UG));
g2d.drawString(""+d.getUndergroundTickets()+"x U", 100, detYOffset+pixPerDetective*i+20);
}
if(Manager.getOptions().isCheat() || game.isCheckPoint()) {
g2d.setColor(Color.BLACK);
g2d.drawString("MrX: "+b.getMrX().getPosition().getPosition(), 20, mrXPos);
g2d.fillOval(5, mrXPos-9, 10, 10);
}
// here goes the movement history of MrX
y = mrXPos + 20;
int maxY = y;
int x = 10;
Move[] mrXmoves = b.getMrX().getPrevPos();
for(int i=0;i<=maxMoves;i++) {
g2d.setColor(Color.BLACK);
if(i>=game.getCurrentMove()) {
g2d.setColor(Color.GRAY);
g2d.drawRect(x, y, 30, 15);
}
if(game.isCheckPoint(i+1)) {
g2d.setColor(new Color(120,200,255));
g2d.fillRect(x, y, 30, 15);
}
if(i==game.getCurrentMove()-1 && game.getState() == Game.MOVE_MRX) {
g2d.setColor(Color.RED);
g2d.drawRect(x, y, 30, 15);
}
if((i+1)<mrXmoves.length) {
g2d.setColor(Move.getColor(mrXmoves[i+1].getType()));
if(opt.isCheat() || game.isCheckPoint()) {
g2d.drawString(""+mrXmoves[i+1].getNode(), x+3, y+12);
}
else {
g2d.drawString(""+mrXmoves[i+1].toStringTicket(), x+3, y+12);
}
}
else if((i+1)==mrXmoves.length && game.getState() == Game.MOVE_MRX) {
g2d.drawString("???", x+3, y+12);
}
else {
g2d.drawString(""+(i+1), x+3, y+12);
}
y += 18;
if(i%((maxMoves/3)+1)==((maxMoves/3))) {
x += 35;
y = mrXPos + 20;
}
if(y>maxY) maxY = y;
}
y = maxY;
}
else {
if(startGameButton!=null && !startGameButton.isVisible()) startGameButton.setVisible(true);
startGameButton.repaint();
g2d.drawString("no game yet", 10, 75);
}
// Minimap
if(y==0) {
y = this.getHeight()-MINIMAP_Y-55;
}
else {
y+=30;
}
MapPanel mp = (MapPanel)PanelRepository.get(PanelRepository.MAP_PANEL);
g2d.drawImage(mp.getMiniImage(MINIMAP_X, MINIMAP_Y), 3, y, null);
int x = 3+Math.min(MINIMAP_X-1, (int) (mp.getOffset().x*mp.getMiniImageZoom(MINIMAP_X, MINIMAP_Y)));
int y2 = y+Math.min(MINIMAP_Y-1, (int) (mp.getOffset().y*mp.getMiniImageZoom(MINIMAP_X, MINIMAP_Y)));
int w = Math.min(MINIMAP_X, (int)(mp.getWidth()*mp.getMiniImageZoom(MINIMAP_X, MINIMAP_Y)*(1.0/mp.getZoom())));
int h = Math.min(MINIMAP_Y, (int)(mp.getHeight()*mp.getMiniImageZoom(MINIMAP_X, MINIMAP_Y)*(1.0/mp.getZoom())));
g2d.drawRect(x, y2, w, h);
g2d.drawString("Time: "+game.getGameTime(), 10, this.getHeight()-40);
g2d.drawString("Zoom: "+mp.getZoomInfo(), 10, this.getHeight()-25);
g2d.drawString("mem: "+Runtime.getRuntime().totalMemory()/1024+"k", 10, this.getHeight()-10);
g2d.dispose();
}