///
/// The graphics manager
///

#ifndef __GRAPHICS_MANAGER_H__
#define __GRAPHICS_MANAGER_H__

#ifdef CYGWIN
#include <ncurses/curses.h>
#else
#include <curses.h>
#endif

#include "Manager.h"
#include "Position.h"
#include "Frame.h"

class GraphicsManager : public Manager {

 private:
  GraphicsManager (GraphicsManager const&); /// don't allow copy
  void operator=(GraphicsManager const&);   /// don't allow assignment
  GraphicsManager();		            /// private since a singleton

 protected:
  WINDOW *win1, *win2;		/// two window buffers for drawing
  WINDOW *curr_win;		/// current buffer
  int window_horiz;		/// max window width
  int window_vert;		/// max window height

 public:
  ~GraphicsManager();

  /// Get the one and only instance of the GraphicsManager.
  static GraphicsManager &getInstance();

  /// Convert world position to screen position (based on the view).
  Position worldToScreen(Position world_pos);

  /// Get terminal ready for text-based display.
  /// Return 0 if ok, else negative number.
  int startUp();

  /// Revert back to normal terminal display.
  void shutDown();

  /// Render frame.
  /// Return 0 if ok, else -1.
  int swapBuffers();

  /// Put a character at screen location (x,y).
  /// Note: top-left coordinate is (0.0).
  /// Return 0 if ok, else -1.
  int drawCh(Position world_pos, char ch);

  /// Draw a single sprite frame at screen location (x,y).
  /// Centered true if frame centered at (x,y).
  /// Note: top-left coordinate is (0,0).
  /// Return 0 if ok, else -1.
  int drawFrame(Position world_pos, Frame frame, bool centered);

  /// Return display's horizontal maximum.
  int getHorizontal();

  /// Return display's vertical maximum.
  int getVertical();

};

#endif //__GRAPHICS_MANAGER_H__

