1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-26 22:57:00 +02:00
vcmi/CCursorHandler.cpp
Michał W. Urbańczyk 7722d058f0 Fixed issues reported by Zamolxis:
* dismiss Hero works blocked in the castles
* the backpack scrollable arrows aren't available (yellow, clickable) even when backpack is empty.
* added missing info texts for buttons in hero window (and added functionality of enable tactic formations button)
* can select (single click) and enter castle (double click) from the map. Same for hero.
* Hero gets automatically selected after End Turn 
* Hero is automatically selected when exiting town
* In Garrison or Hero army: units are selected when we first click on them
Fixed (at least partially) also a problem with disappearing path
2008-08-28 17:36:34 +00:00

65 lines
1.2 KiB
C++

#include "stdafx.h"
#include "CCursorHandler.h"
#include "SDL.h"
#include "SDL_Extensions.h"
#include "CGameInfo.h"
#include "hch/CDefHandler.h"
extern SDL_Surface * screen;
void CCursorHandler::initCursor()
{
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);
}
void CCursorHandler::changeGraphic(int type, int no)
{
mode = type;
number = no;
}
void CCursorHandler::cursorMove(int x, int y)
{
xpos = x;
ypos = y;
}
void CCursorHandler::draw1()
{
if(!Show) return;
int x = xpos, y = ypos;
if(mode==1)
{
x-=16;
y-=16;
}
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);
}
void CCursorHandler::draw2()
{
if(!Show) return;
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);
}