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
|
|
|
}
|
|
|
|
|
|
|
|
void CCursorHandler::changeGraphic(int type, int no)
|
|
|
|
{
|
2008-08-01 21:13:33 +03:00
|
|
|
mode = type;
|
|
|
|
number = no;
|
2007-08-21 16:48:18 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCursorHandler::cursorMove(int x, int y)
|
|
|
|
{
|
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;
|
|
|
|
if(mode==1)
|
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;
|
|
|
|
}
|
|
|
|
SDL_BlitSurface(screen,&genRect(32,32,x,y),help,&genRect(32,32,0,0));
|
|
|
|
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;
|
|
|
|
if(mode==1)
|
|
|
|
{
|
|
|
|
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
|
|
|
}
|