// -*- c++ -*-
#ifndef _MAPDISPLAY_H
#define _MAPDISPLAY_H

#include "display.h"

class Unit;
class World;

class MapDisplay : public WDisplay {
public:
  MapDisplay();
  MapDisplay(World *W, Player *p);
  virtual ~MapDisplay();

  void SetWorld(World *W);
  void SetPlayer(Player *p) {player = p;}

  void Update();
  virtual void ShowPlayerInfo();
  virtual void ShowPieceInfo(Unit *u);

  virtual void ShowPiece(MapCoord c, ulong id);
  virtual void ColorMainMap(MapCoord c, int col);

  void GetEvent(EventType event, int x, int y, char *data);
  virtual void DisplayMessage(char *mesg, int color) = 0;

  int Visible(MapCoord c);

  void EnableCursor(MapCoord c, ulong id);
  void DisableCursor();
  void DisplayCursor();

protected:
  World *w;
  int maxX, maxY;

  MapCoord topleft; // top left corner of the screen

  MapCoord cursor;
  // -1 if no cursor, 0 if cursor state is inverted
  // 1 is cursor state is piece shown
  int cursorOn;

  ScreenCoord TranslateScreen(MapCoord world);
  MapCoord TranslateWorld(ScreenCoord screen);

  Unit *cursorUnit;
  friend void DisplayCursor(int);

  virtual void Setup();
  void CreateButtons();
  void CreateMenus();

  void ScrollUp();
  void ScrollDown();
  void ScrollLeft();
  void ScrollRight();

  void Center(MapCoord c);

  virtual void BlitMap(int x1, int y1, int w, int h, int x2, int y2) = 0;
};

// should be hooked into the timer otherwise no cursor will showup
void DisplayCursor(int);

#endif
