2007-08-21 16:48:18 +03:00
|
|
|
#include "stdafx.h"
|
|
|
|
#include "CCursorHandler.h"
|
|
|
|
#include "SDL.h"
|
2008-08-01 21:13:33 +03:00
|
|
|
#include "SDL_Extensions.h"
|
2007-08-21 16:48:18 +03:00
|
|
|
#include "CGameInfo.h"
|
2008-08-01 21:13:33 +03:00
|
|
|
#include "hch/CDefHandler.h"
|
2007-08-21 16:48:18 +03:00
|
|
|
|
|
|
|
extern SDL_Surface * screen;
|
|
|
|
|
|
|
|
void CCursorHandler::initCursor()
|
|
|
|
{
|
2008-08-01 21:13:33 +03:00
|
|
|
mode = number = xpos = ypos = 0;
|
|
|
|
help = CSDL_Ext::newSurface(32,32);
|
|
|
|
cursors.push_back(CDefHandler::giveDef("CRADVNTR.DEF"));
|
|
|
|
cursors.push_back(CDefHandler::giveDef("CRCOMBAT.DEF"));
|
|
|
|
cursors.push_back(CDefHandler::giveDef("CRDEFLT.DEF"));
|
|
|
|
cursors.push_back(CDefHandler::giveDef("CRSPELL.DEF"));
|
|
|
|
SDL_ShowCursor(SDL_DISABLE);
|
2007-08-21 16:48:18 +03:00
|
|
|
}
|
|
|
|
|
2008-09-25 17:09:31 +03:00
|
|
|
void CCursorHandler::changeGraphic(const int & type, const int & no)
|
2007-08-21 16:48:18 +03:00
|
|
|
{
|
2008-08-01 21:13:33 +03:00
|
|
|
mode = type;
|
|
|
|
number = no;
|
2007-08-21 16:48:18 +03:00
|
|
|
}
|
|
|
|
|
2008-09-25 17:09:31 +03:00
|
|
|
void CCursorHandler::cursorMove(const int & x, const int & y)
|
2007-08-21 16:48:18 +03:00
|
|
|
{
|
2008-08-01 21:13:33 +03:00
|
|
|
xpos = x;
|
|
|
|
ypos = y;
|
2007-08-21 16:48:18 +03:00
|
|
|
}
|
2008-08-01 21:13:33 +03:00
|
|
|
void CCursorHandler::draw1()
|
2007-08-21 16:48:18 +03:00
|
|
|
{
|
2008-08-07 03:38:44 +03:00
|
|
|
if(!Show) return;
|
2008-08-28 20:36:34 +03:00
|
|
|
int x = xpos, y = ypos;
|
2008-10-17 20:43:25 +03:00
|
|
|
if((mode==1 && number!=6) || mode ==3)
|
2008-08-07 03:38:44 +03:00
|
|
|
{
|
2008-08-28 20:36:34 +03:00
|
|
|
x-=16;
|
|
|
|
y-=16;
|
2008-08-07 03:38:44 +03:00
|
|
|
}
|
2008-08-28 20:36:34 +03:00
|
|
|
else if(mode==0 && number>0)
|
|
|
|
{
|
|
|
|
x-=12;
|
|
|
|
y-=10;
|
|
|
|
}
|
2008-12-21 21:17:35 +02:00
|
|
|
SDL_BlitSurface(screen, &genRect(32,32,x,y), help, &genRect(32,32,0,0));
|
2008-08-28 20:36:34 +03:00
|
|
|
blitAt(cursors[mode]->ourImages[number].bitmap,x,y);
|
2007-08-21 16:48:18 +03:00
|
|
|
}
|
2008-08-01 21:13:33 +03:00
|
|
|
void CCursorHandler::draw2()
|
2007-08-21 16:48:18 +03:00
|
|
|
{
|
2008-08-07 03:38:44 +03:00
|
|
|
if(!Show) return;
|
2008-08-28 20:36:34 +03:00
|
|
|
int x = xpos, y = ypos;
|
2008-12-23 15:59:03 +02:00
|
|
|
if((mode==1 && number!=6) || mode == 3)
|
2008-08-28 20:36:34 +03:00
|
|
|
{
|
|
|
|
x-=16;
|
|
|
|
y-=16;
|
|
|
|
}
|
|
|
|
else if(mode==0 && number>0)
|
|
|
|
{
|
|
|
|
x-=12;
|
|
|
|
y-=10;
|
|
|
|
}
|
|
|
|
blitAt(help,x,y);
|
2008-08-02 18:08:03 +03:00
|
|
|
}
|