| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237 | 
							- #include "stdafx.h"
 
- #include "CCursorHandler.h"
 
- #include "SDL.h"
 
- #include "SDL_thread.h"
 
- #include "CGameInfo.h"
 
- #include "SDL_framerate.h"
 
- #include "hch/CLodHandler.h"
 
- extern SDL_Surface * screen;
 
- /* Creates a new mouse cursor from an XPM */
 
- /* XPM */
 
- static const char *arrow[] = { //no cursor mode
 
-   /* width height num_colors chars_per_pixel */
 
-   "    32    32        3            1",
 
-   /* colors */
 
-   "X c #000000",
 
-   ". c #ffffff",
 
-   "  c None",
 
-   /* pixels */
 
-   "                                ",
 
-   "                                ",
 
-   "                                ",
 
-   "                                ",
 
-   "                                ",
 
-   "                                ",
 
-   "                                ",
 
-   "                                ",
 
-   "                                ",
 
-   "                                ",
 
-   "                                ",
 
-   "                                ",
 
-   "                                ",
 
-   "                                ",
 
-   "                                ",
 
-   "                                ",
 
-   "                                ",
 
-   "                                ",
 
-   "                                ",
 
-   "                                ",
 
-   "                                ",
 
-   "                                ",
 
-   "                                ",
 
-   "                                ",
 
-   "                                ",
 
-   "                                ",
 
-   "                                ",
 
-   "                                ",
 
-   "                                ",
 
-   "                                ",
 
-   "                                ",
 
-   "                                ",
 
-   "0,0"
 
- };
 
- /* XPM */
 
- static const char *arrow2[] = { //normal cursor
 
-   /* width height num_colors chars_per_pixel */
 
-   "    32    32        3            1",
 
-   /* colors */
 
-   "X c #000000",
 
-   ". c #ffffff",
 
-   "  c None",
 
-   /* pixels */
 
-   "X                               ",
 
-   "XX                              ",
 
-   "X.X                             ",
 
-   "X..X                            ",
 
-   "X...X                           ",
 
-   "X....X                          ",
 
-   "X.....X                         ",
 
-   "X......X                        ",
 
-   "X.......X                       ",
 
-   "X........X                      ",
 
-   "X.....XXXXX                     ",
 
-   "X..X..X                         ",
 
-   "X.X X..X                        ",
 
-   "XX  X..X                        ",
 
-   "X    X..X                       ",
 
-   "     X..X                       ",
 
-   "      X..X                      ",
 
-   "      X..X                      ",
 
-   "       XX                       ",
 
-   "                                ",
 
-   "                                ",
 
-   "                                ",
 
-   "                                ",
 
-   "                                ",
 
-   "                                ",
 
-   "                                ",
 
-   "                                ",
 
-   "                                ",
 
-   "                                ",
 
-   "                                ",
 
-   "                                ",
 
-   "                                ",
 
-   "0,0"
 
- };
 
- static SDL_Cursor *init_system_cursor(const char *image[])
 
- {
 
-   int i, row, col;
 
-   Uint8 data[4*32];
 
-   Uint8 mask[4*32];
 
-   int hot_x, hot_y;
 
-   i = -1;
 
-   for ( row=0; row<32; ++row ) {
 
-     for ( col=0; col<32; ++col ) {
 
-       if ( col % 8 ) {
 
-         data[i] <<= 1;
 
-         mask[i] <<= 1;
 
-       } else {
 
-         ++i;
 
-         data[i] = mask[i] = 0;
 
-       }
 
-       switch (image[4+row][col]) {
 
-         case 'X':
 
-           data[i] |= 0x01;
 
-           //k[i] |= 0x01;
 
-           break;
 
-         case '.':
 
-           mask[i] |= 0x01;
 
-           break;
 
-         case ' ':
 
-           break;
 
-       }
 
-     }
 
-   }
 
-   sscanf(image[4+row], "%d,%d", &hot_x, &hot_y);
 
-   return SDL_CreateCursor(data, mask, 32, 32, hot_x, hot_y);
 
- }
 
- //int cursorHandlerFunc(void * cursorHandler)
 
- //{
 
- //	FPSmanager * cursorFramerateKeeper = new FPSmanager;
 
- //	SDL_initFramerate(cursorFramerateKeeper);
 
- //	SDL_setFramerate(cursorFramerateKeeper, 200);
 
- //
 
- //	CCursorHandler * ch = (CCursorHandler *) cursorHandler;
 
- //	while(true)
 
- //	{
 
- //		if(ch->xbef!=-1 && ch->ybef!=-1) //restore surface under cursor
 
- //		{
 
- //			blitAtWR(ch->behindCur, ch->xbef, ch->ybef);
 
- //		}
 
- //		ch->xbef = ch->xpos;
 
- //		ch->ybef = ch->ypos;
 
- //		//prepare part of surface to restore
 
- //		SDL_BlitSurface(screen, &genRect(32, 32, ch->xpos, ch->ypos), ch->behindCur, NULL);
 
- //		CSDL_Ext::update(ch->behindCur);
 
- //
 
- //		//blit cursor
 
- //		if(ch->curVisible)
 
- //		{
 
- //			switch(ch->mode)
 
- //			{
 
- //			case 0:
 
- //				{
 
- //					break;
 
- //				}
 
- //			case 1:
 
- //				{
 
- //					break;
 
- //				}
 
- //			case 2:
 
- //				{
 
- //					blitAtWR(ch->deflt->ourImages[ch->number].bitmap, ch->xpos, ch->ypos);
 
- //					break;
 
- //				}
 
- //			}
 
- //		}
 
- //		SDL_framerateDelay(cursorFramerateKeeper);
 
- //		//SDL_Delay(5); //to avoid great usage of CPU
 
- //	}
 
- //	return 0;
 
- //}
 
- void CCursorHandler::initCursor()
 
- {
 
- //#if SDL_BYTEORDER == SDL_BIG_ENDIAN
 
- //    int rmask = 0xff000000;
 
- //    int gmask = 0x00ff0000;
 
- //    int bmask = 0x0000ff00;
 
- //    int amask = 0x000000ff;
 
- //#else
 
- //    int rmask = 0x000000ff;
 
- //    int gmask = 0x0000ff00;
 
- //    int bmask = 0x00ff0000;
 
- //    int amask = 0xff000000;
 
- //#endif
 
- //	curVisible = true;
 
- //	xpos = ypos = 0;
 
- //	behindCur = SDL_CreateRGBSurface(SDL_SWSURFACE, 32, 32, 32, rmask, gmask, bmask, amask);
 
- //	xbef = ybef = 0;
 
- //	adventure = CDefHandler::giveDef("CRADVNTR.DEF");
 
- //	combat = CDefHandler::giveDef("CRCOMBAT.DEF");
 
- //	deflt = CDefHandler::giveDef("CRDEFLT.DEF");
 
- //	spell = CDefHandler::giveDef("CRSPELL.DEF");
 
- //	//SDL_SetCursor(init_system_cursor(arrow));
 
- //	//SDL_Thread * myth = SDL_CreateThread(&cursorHandlerFunc, this);
 
- }
 
- void CCursorHandler::changeGraphic(int type, int no)
 
- {
 
- 	//mode = type;
 
- 	//number = no;
 
- }
 
- void CCursorHandler::cursorMove(int x, int y)
 
- {
 
- 	//xbef = xpos;
 
- 	//ybef = ypos;
 
- 	//xpos = x;
 
- 	//ypos = y;
 
- }
 
- void CCursorHandler::hardwareCursor()
 
- {
 
- 	//curVisible = false;
 
- 	//SDL_SetCursor(init_system_cursor(arrow2));
 
- }
 
- void CCursorHandler::hideCursor()
 
- {
 
- 	//curVisible = false;
 
- 	//SDL_SetCursor(init_system_cursor(arrow));
 
- }
 
- void CCursorHandler::showGraphicCursor()
 
- {
 
- 	//curVisible = true;
 
- 	//SDL_SetCursor(init_system_cursor(arrow));
 
- 	//changeGraphic(0, 0);
 
- }
 
 
  |