#include <allegro.h>
#include "mouse.h"
#include "data\indexes.h"

BITMAP *pointersBMP;

int mouse_init() {
  DATAFILE *images = load_datafile("data/images.dat");
  pointersBMP = (BITMAP*)images[POINTERS].dat;
  return 0;
}

void mouse_setCursor(int num) {
	BITMAP *cursorBMP;

  set_mouse_sprite_focus(0,0);

  // hand
	if (num == MOUSE_HAND) {
		cursorBMP = create_bitmap(14,11);
		blit(pointersBMP, cursorBMP, 0, 0, 0, 0, cursorBMP->w, cursorBMP->h);
	}
	// cross
	else if (num == MOUSE_DENIED) {
		cursorBMP = create_bitmap(12,11);
		blit(pointersBMP, cursorBMP, 15, 0, 0, 0, cursorBMP->w, cursorBMP->h);
	}
	// crosshair
	else if (num == MOUSE_CROSSHAIR) {
		cursorBMP = create_bitmap(13, 13);
		blit(pointersBMP, cursorBMP, 28, 0, 0, 0, cursorBMP->w, cursorBMP->h);
		set_mouse_sprite_focus(6,6);
	}
	// green arrow
	else if (num == MOUSE_GREENARROW) {
		cursorBMP = create_bitmap(12,12);
		blit(pointersBMP, cursorBMP, 42,0,0,0,cursorBMP->w,cursorBMP->h);
	}
	set_mouse_sprite(cursorBMP);
	show_mouse(screen);
}

void mouse_destroy() {
  destroy_bitmap(pointersBMP);
}
