⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mousecursor.cpp

📁 网络游戏龙族 完整的登陆器 C++ 源代码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
	int sy = g_pointMouseY + CurMouseCursorSpotY - s->oy;
	int ex = sx + s->xl;
	int ey = sy + s->yl;
		
	if( sx < PmcSx ) PmcSx = sx;
	if( sy < PmcSy ) PmcSy = sy;
	if( ex > PmcEx ) PmcEx = ex;
	if( ey > PmcEy ) PmcEy = ey;
		
	if( PmcSx < 0 ) PmcSx = 0;
	if( PmcSy < 0 ) PmcSy = 0;
	if( PmcEx > SCREEN_WIDTH -1) PmcEx = SCREEN_WIDTH-1;
	if( PmcEy > SCREEN_HEIGHT-1) PmcEy = SCREEN_HEIGHT-1;

#ifdef _DEBUG	
	if( (PmcEx-PmcSx+1)*(PmcEy-PmcSy+1) >= MAX_MOUSE_AREA_BUF_SIZE )
		Error( "Mouse MgBuf is Too Small..\n %d %d %d %d",  PmcSx, PmcSy,  PmcEx, PmcEy );
#endif	

	GetImageBox( MgBuf, g_DestBackBuf, PmcSx, PmcSy,  PmcEx, PmcEy );

	if( SMenu[MN_LODING].bActive != TRUE )  // 拳搁 Loading且锭绰 嘛瘤 臼绰促.
	{	
		PutCompressedImage( g_pointMouseX + CurMouseCursorSpotX, g_pointMouseY + CurMouseCursorSpotY, s );
		int ttx = g_pointMouseX + Mapx, tty = g_pointMouseY + Mapy;

		static int to, tcolor=0, ccolor=0;
		
		if( to ) 
		{
			tcolor += 20;  if( tcolor >= 250  ) { tcolor = 250; to = !to;  }
		}
		else 
		{
			tcolor -= 20;  if( tcolor <= 150  ) { to = !to; }
		}
		ccolor = RGB16( tcolor, tcolor, tcolor );

		Line( ttx-2, tty, ttx+3, tty, ccolor );
		Line( ttx, tty-2, ttx, tty+3, ccolor );

		withSkillItem();
	}

//-------
	if( tool_MouseCursorBlock )
	{
		PutCompressedImage( 320 + CurMouseCursorSpotX, 240 + CurMouseCursorSpotY, s );
		int ttx = 320 + Mapx, 
			tty = 240 + Mapy;
		Line( ttx-5, tty, ttx+5, tty, 0xffff );
		Line( ttx, tty-5, ttx, tty+5, 0xffff );
	}
//-------
	CurMouseCursorFrameCounter();
}
/*
{		
	if( MouseCursorOnOff == false ) return;// 扁贱矫傈吝.
//	if( SMenu[MN_LOGO_START].bActive==true ) return;
	if( SMenu[MN_LODING].bActive ==true )return;  // 拳搁 Loading且锭绰 嘛瘤 臼绰促.
	PmcSx = SCREEN_WIDTH;
	PmcSy = SCREEN_HEIGHT;
	PmcEx = PmcEy = 0;
	Spr *s;

	switch(CurMouseCursorNo)
	{
	case 1://sa
		{
			s = GetSprOfMenu(CURSOR_DEFAULT_IMG	,0);
			FieldTypeNomalPut(0,0,g_pointMouseX,g_pointMouseY,0,CURSOR_DEFAULT_IMG);
	//CURSOR_CLICK_IMG				10024
	//		s = FieldTypeNomalPut(int mx, int my, int x,int y,int nImageNumber, int type);
		}break;
	default :
		{
			s = &mc[ CurMouseCursorNo-1][ CurMouseCursorAni];
		}break;
	}

	const int sx = g_pointMouseX + CurMouseCursorSpotX - s->ox;
	const int sy = g_pointMouseY + CurMouseCursorSpotY - s->oy;
	const int ex = sx + s->xl;
	const int ey = sy + s->yl;
		
	if( sx < PmcSx ) PmcSx = sx;
	if( sy < PmcSy ) PmcSy = sy;
	if( ex > PmcEx ) PmcEx = ex;
	if( ey > PmcEy ) PmcEy = ey;
		
	if( PmcSx < 0 ) PmcSx = 0;
	if( PmcSy < 0 ) PmcSy = 0;
	if( PmcEx > SCREEN_WIDTH -1) PmcEx = SCREEN_WIDTH-1;
	if( PmcEy > SCREEN_HEIGHT-1) PmcEy = SCREEN_HEIGHT-1;

#ifdef _DEBUG	
	if( (PmcEx-PmcSx+1)*(PmcEy-PmcSy+1) >= MAX_MOUSE_AREA_BUF_SIZE )
	{
		Error( "Mouse MgBuf is Too Small..\n %d %d %d %d",  PmcSx, PmcSy,  PmcEx, PmcEy );
	}
	Hprint2(100,120, g_DestBackBuf,"付快胶 %d,%d",CurMouseCursorNo,CurMouseCursorAni);
#endif	

//	GetImageBox( MgBuf, g_DestBackBuf, PmcSx, PmcSy,  PmcEx, PmcEy );
	switch(CurMouseCursorNo)
	{
	case 1:
		break;
	default:
		{
			PutCompressedImage( g_pointMouseX + CurMouseCursorSpotX, g_pointMouseY + CurMouseCursorSpotY, s );//付快胶 目辑 弊覆 嘛绰镑
		}
	}
	
	//努腐器牢飘 扼牢 弊府绰 镑
	{
	const int ClickPointX = g_pointMouseX + Mapx;
	const int ClickPointY = g_pointMouseY + Mapy;
	static char cRelayColor = 0;//static 捞促
	cRelayColor+=16;
	const unsigned char ucTempColor= abs(cRelayColor);
	const WORD wColor = ConvertColor(ucTempColor,ucTempColor,ucTempColor);
	Line( ClickPointX-2,ClickPointY,	ClickPointX+3,	ClickPointY,	wColor );
	Line( ClickPointX,	ClickPointY-2,	ClickPointX,	ClickPointY+3,	wColor );
	}

	withSkillItem();
	
	if( tool_MouseCursorBlock )
	{
		PutCompressedImage( 320 + CurMouseCursorSpotX, 240 + CurMouseCursorSpotY, s );
		int ttx = 320 + Mapx, 
			tty = 240 + Mapy;
		Line( ttx-5, tty, ttx+5, tty, 0xffff );
		Line( ttx, tty-5, ttx, tty+5, 0xffff );
	}
	CurMouseCursorFrameCounter();
}
*/
/*
void CursorDisplay_Sub( int *newflag )
{			
	int sx, sy, ex, ey;
	char *t;
	static int oldx, oldy;


	if( MouseCursorOnOff == false ) return;// 扁贱矫傈吝.

//	if( SMenu[MN_LOGO_START_SAMSUNG].bActive==TRUE ) return;
	if( SMenu[MN_LOGO_START].bActive==true ) return;

	
	if( oldx == g_pointMouseX && oldy == g_pointMouseY ) return;
	oldx = g_pointMouseX, oldy = g_pointMouseY;

	t = g_DestBackBuf;
	WORD twdxsize = wDxSize;
	DWORD tddxsize = dDxSize;
	wDxSize = wSurDxSize;
	dDxSize = dSurDxSize;

	g_DestBackBuf = GetSurfacePointer( g_DirectDrawInfo.lpDirectDrawSurfacePrimary );
	if( *newflag == 1 )
	{	
		PutImageBox( MgBuf, g_DestBackBuf, PmcSx, PmcSy,  PmcEx, PmcEy );
	}	
	PmcSx = SCREEN_WIDTH;
	PmcSy = SCREEN_HEIGHT;
	PmcEx = PmcEy = 0;
	
	Spr *s = &mc[ CurMouseCursorNo-1][ CurMouseCursorAni]; 
	sx = g_pointMouseX + CurMouseCursorSpotX - s->ox;
	sy = g_pointMouseY + CurMouseCursorSpotY - s->oy;
	ex = sx + s->xl;
	ey = sy + s->yl;
	
	if( sx < PmcSx ) PmcSx = sx;
	if( sy < PmcSy ) PmcSy = sy;
	if( ex > PmcEx ) PmcEx = ex;
	if( ey > PmcEy ) PmcEy = ey;

	if( PmcSx < 0 ) PmcSx = 0;
	if( PmcSy < 0 ) PmcSy = 0;
	if( PmcEx > SCREEN_WIDTH -1) PmcEx = SCREEN_WIDTH-1;
	if( PmcEy > SCREEN_HEIGHT-1) PmcEy = SCREEN_HEIGHT-1;

	if( (PmcEx-PmcSx+1)*(PmcEy-PmcSy+1) >= MAX_MOUSE_AREA_BUF_SIZE )
		Error( "Mouse MgBuf is Too Small..\n %d %d %d %d",  PmcSx, PmcSy,  PmcEx, PmcEy );

	GetImageBox( MgBuf, g_DestBackBuf, PmcSx, PmcSy,  PmcEx, PmcEy );

	*newflag = 1;	

	if( SMenu[MN_LODING].bActive != TRUE )  // 拳搁 Loading且锭绰 嘛瘤 臼绰促.
	{	
		PutCompressedImage( g_pointMouseX + CurMouseCursorSpotX, g_pointMouseY + CurMouseCursorSpotY, s );
		withSkillItem();
	}	

	wDxSize = twdxsize;
	dDxSize = tddxsize;

	g_DestBackBuf = t;
}
*/
/*
int CursorDisplay( int *newflag )
{
//	MSG msg;
	int c=0;

	if( SysInfo.dx == 0 ) return 1;

//  while( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) !=0 )
//  {	
//		if( msg.message == WM_QUIT ) 
//		{	
//			QuitFlag = SWD_QUIT;
//			return 0;
//		}
//		TranslateMessage(&msg);
//		DispatchMessage(&msg);
//	}	




	if( c == 0 ) CursorDisplay_Sub( newflag );

	return 1;
}
*/
void FreeMouseCursor ( void )
{	
	if( McBuf ) GlobalFree( McBuf );
	McBuf = NULL;
}
void LoadMouseCursor( char *filename )
{		
	FILE *fp;
	char  temp[ FILENAME_MAX];
	short no;
	DWORD sysfilelength, size;
	DWORD nOff = 0;
	int   i,j;

	FreeMouseCursor ();
		
	sprintf( temp, "./data/%s", filename );
		
	fp = Fopen( temp, "rb" );
	if( fp == NULL ) return;
		
	fread( &no, 2,1, fp);
	fseek( fp, no * 4, SEEK_CUR );  // 坷橇悸 胶诺
	sysfilelength = _filelength( _fileno( fp) ) - no * 4 * 2 - 2;
			
	MemAlloc(McBuf, sysfilelength );
		
	for( i = 0 ;i < no / 20  ; i ++) // MAX_MOUSE_CURSOR
	{	
		for( j = 0 ; j < 20 ; j ++)
		{
			if( nOff >= sysfilelength )
				Error("mouse cursor Sprite file size too big" );

			fread( &size, 4,1, fp);
			
			fread( &mc[i][j].xl, sizeof( short ), 1, fp);
			fread( &mc[i][j].yl, sizeof( short ), 1, fp);
			fread( &mc[i][j].ox, sizeof( short ), 1, fp);
			fread( &mc[i][j].oy, sizeof( short ), 1, fp);
			fread( &mc[i][j].size, sizeof( unsigned int ), 1, fp);
			
			fread( McBuf + nOff, mc[i][j].size,1 ,fp);
			mc[i][j].img = (char *)McBuf + nOff;

			convert565to555( &mc[i][j]);
			nOff += size;

		}	
	}	
	fclose(fp);
}

//-------------------------------------------------------------------
//-------------------------------------------------------------------
//-------------------------------------------------------------------
//-------------------------------------------------------------------
//-------------------------------------------------------------------

void DeleteSkillCursor( LPSKILLCURSOR tt )
{		
	LPSKILLCURSOR  t = g_SkillCursor;

	while( t != NULL )
	{		
		if( t == tt )
		{	
			if( t->ch == Hero ) 
			{
				MouseCursorOnOff = true;
			}

			if( t == g_SkillCursor )
			{	
				t = g_SkillCursor->next;
				MemFree( g_SkillCursor );
		
				g_SkillCursor = t;
				if( t != NULL )	g_SkillCursor->prev = NULL;
				
				return;
			}
			else 
			{
				if ( t->prev != NULL )
					t->prev->next = t->next;
	
				if( t->next != NULL )
					t->next->prev = t->prev;
	
				
   				MemFree( t );
				return;
			}
		}
		t = t->next;
	}		
}	
LPSKILLCURSOR AddSkillCursor( LPCHARACTER ch, int skillno, int cursorno, int x, int y, int repeat )
{
	LPSKILLCURSOR temp = NULL, t;
	cursorno /= 10;
	if( cursorno == 0 ) return NULL;
	
	//-----------------------------------
	
	if( ch == Hero ) MouseCursorOnOff = false;
	
	MemAlloc( temp, sizeof( SKILLCURSOR ));
	
	temp->ch		= ch;
	temp->skillno	= skillno;
	temp->cursorno	= cursorno-1;
	temp->x			= x;
	temp->y			= y;
	temp->curframe	= cursorani[cursorno-1].start;
	temp->repeat	= repeat;
	temp->endtime   = g_curr_time + repeat;
	
	
	temp->prev = NULL;
	temp->next = NULL;
	
	
	
	if( g_SkillCursor == NULL )
	{	
		g_SkillCursor		= temp;
	}	
	else
	{	
		t					= g_SkillCursor;
		g_SkillCursor		= temp;
		g_SkillCursor->next	= t;
		t->prev				= g_SkillCursor;
	}		
	
	return g_SkillCursor;
}	
	
bool StopDoingSkillCursor( LPCHARACTER ch )
{	
	LPSKILLCURSOR t, temp;
	
	t = g_SkillCursor;
	while( t != NULL )
	{		
		if( t->ch == ch )
		{
			temp = t->next; 
			DeleteSkillCursor( t ); 
			t = temp; 
			continue; 
		}	
		t = t->next;
	}			
	return false;
}	
	
	
	
bool IsDoingSkillCursor( LPCHARACTER ch )
{	
	LPSKILLCURSOR t;
	
	t = g_SkillCursor;
	while( t != NULL )
	{		
		if( t->ch == ch )
		{
			return true;
		}	
			
		t = t->next;
	}			
	return false;
}	
	
	
	
	
void OutputSkillCursor( void )
{	
	LPSKILLCURSOR t, temp;
	LPORDERTABLE o;
	
	t = g_SkillCursor;
	while( t != NULL )
	{		
		if( t->curframe >= cursorani[ t->cursorno].end ) 
		{	
			t->repeat--;
			if( t->repeat <= 0 ) 
//			if( g_curr_time > t->endtime )
			{
				temp = t->next; 
				DeleteSkillCursor( t ); 
				t = temp; 
				continue; 
			}
			else
			{
				t->curframe = cursorani[t->cursorno].start;
			}
		}	
			
		t->sp = &mc[ t->cursorno ][ t->curframe ];
			
		if( t->curframe == cursorani[t->cursorno].start )
		{
			if( SkillTable[ t->skillno].Effect_wave1 )
			{
				PlayListAutoSounds( SkillTable[ t->skillno].Effect_wave1, 0, 0, 0 );
			}
		}
		
		
		if( BoxAndDotCrash( Mapx, Mapy, GAME_SCREEN_XSIZE, GAME_SCREEN_YSIZE, t->x, t->y ) )
		{		
			o = &g_OrderInfo.order[ g_OrderInfo.count ];
					
			o->wType		= SPRITETYPE_SKILLCURSOR;
			o->x			= t->x + cursorani[t->cursorno].offx;
			o->y			= t->y + cursorani[t->cursorno].offy;
			o->height		= 0;
			o->offset		= t->y + cursorani[t->cursorno].offy;
			o->lpvData		= (LPVOID)t;
			o->show			= 1;
			o->sort			= 1;
			g_OrderInfo.count++;
		}	
		
		t->curframe ++;
		t = t->next;
	}		
}		
	
/////////////////////////////////////////////////////////////////////////////////////////
	
static int		HEAD, TAIL;
	
void ClearQueue( void )
{	
	HEAD = TAIL = 0;
}
	
int queuein( t_queue *n )
{	
	if( (TAIL+1) %  MAX_MQUEUE != HEAD )
	{	
		memcpy( &aQueue[TAIL], n, sizeof( t_queue ) );
		TAIL ++;
		TAIL = TAIL % MAX_MQUEUE ;
		return 1;
	}	
	return 0;
}	

int queueout( t_queue *n)
{		
	if( TAIL != HEAD )
	{	
		memcpy( n, &aQueue[HEAD], sizeof( t_queue ) );
		HEAD ++;
		HEAD = HEAD % MAX_MQUEUE;
		return 1;
	}	
		
	n = NULL;
	return 0;
}	
	
	
	
	
	
	
	
	
	
		

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -