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

📄 mirgui.cpp

📁 传奇挂机源代码 自动练级功能
💻 CPP
字号:
// MirGui.cpp : Defines the entry point for the application.
//

#include "stdafx.h"
#include "resource.h"
#include "mirgroup.h"
#include <windowsx.h>
#include <stdio.h>
#include "mirgame.h"
#include "mirminimap.h"
#include "mirgamemap.h"
#define MAX_LOADSTRING	100
#define MAX_LOGLINES	100

#define	MINIMAP_WIDTH	120
#define	MINIMAP_HEIGHT	120

#define	MINIMAP_DISPLAYX	636
#define	MINIMAP_DISPLAYY	17

// Global Variables:
HINSTANCE hInst;								// current instance
HWND		g_hSysLog = NULL;
HWND		g_hChatLog = NULL;
HWND		g_hMainDlg = NULL;
CMirGame	mirgame;

CMirMiniMap	*	pMiniMap;
CMirGameMap *	pGameMap;

int minimap_x = 325;
int minimap_y = 267;
LRESULT CALLBACK MirGuiDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);


VOID CALLBACK TimerProc2(

    HWND hwnd,	// handle of window for timer messages 
    UINT uMsg,	// WM_TIMER message
    UINT idEvent,	// timer identifier
    DWORD dwTime 	// current system time
   )
{
	int dirbits=0;
	char	tmpStr[200];
	int bs = 0;
	if( GetKeyState( VK_UP ) & 0x80 )
	{
		minimap_y --;
		dirbits |= 1;
		//mirgame.LogChat( "(%d,%d)", minimap_x, minimap_y );
	}
	if( GetKeyState( VK_RETURN ) & 0x80 && GetKeyState( VK_CONTROL ) & 0x80 )
	{
		if( GetFocus() == GetDlgItem( g_hMainDlg, ED_CHAT ))
		{
			GetDlgItemText( g_hMainDlg, ED_CHAT, tmpStr, 200 );
			SetDlgItemText( g_hMainDlg, ED_CHAT, "" );
			bs = strlen( tmpStr );

			if( bs > 0 )
			{
				if( tmpStr[bs-2]== 0x0d && tmpStr[bs-1] == 0x0a )
					tmpStr[bs-2] = '\0';

				mirgame.Say( tmpStr );
			}
		}
	}
	if( GetKeyState( VK_DOWN ) & 0x80 )
	{
		dirbits |= 4;
		minimap_y ++;
		//mirgame.LogChat( "(%d,%d)", minimap_x, minimap_y );
	}
	if( GetKeyState( VK_LEFT ) & 0x80 )
	{
		dirbits |= 8;
		
		minimap_x --;
		//mirgame.LogChat( "(%d,%d)", minimap_x, minimap_y );
	}
	if( GetKeyState( VK_RIGHT ) & 0x80 )
	{
		dirbits |= 2;
		
		minimap_x ++;
		//mirgame.LogChat( "(%d,%d)", minimap_x, minimap_y );
	}
	switch( dirbits )
	{
	case	1:
		dirbits = 0;
		break;
	case	2:
		dirbits = 2;
		break;
	case	4:
		dirbits = 4;
		break;
	case	8:
		dirbits = 6;
		break;
	case	3:
		dirbits = 1;
		break;
	case	6:
		dirbits = 3;
		break;
	case	12:
		dirbits = 5;
		break;
	case	9:
		dirbits = 7;
		break;
	default:
		dirbits = 9;
	}
	//mirgame.Run( dirbits );
}

VOID CALLBACK TimerProc(

    HWND hwnd,	// handle of window for timer messages 
    UINT uMsg,	// WM_TIMER message
    UINT idEvent,	// timer identifier
    DWORD dwTime 	// current system time
   )
{
	HDC hdc;

	hdc = GetDC( g_hMainDlg );
	pMiniMap->Draw( hdc, 635, 15, 120, 120 );
	pGameMap->Draw( hdc, 420, 20 );
	ReleaseDC( g_hMainDlg, hdc );
	return ;
}


int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
//	minimap.InitMiniMap( "d:/mmap.wix", "d:/mmap.wil" );
//	minimap.SetMMap( 160 );
	SetTimer( 0, 0, 10, TimerProc );
	SetTimer( 0, 0, 10, TimerProc2 );

	pGameMap = mirgame.GetGameMap();
	pMiniMap = mirgame.GetMiniMap();
	DialogBox(hInst, (LPCTSTR)IDD_MIRGUIDLG,GetDesktopWindow(), (DLGPROC)MirGuiDlgProc);
	

	return 0;
}

DWORD	ThreadProc( PVOID * p )
{
	return mirgame.EnterGame( 1 );
}
LRESULT CALLBACK MirGuiDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
	DWORD	idcmd;
	static	int		AreaId = 0;
	static	int		ServerId = 0;
	static	int		xofs = 0,yofs = 0;
	static	BOOL	bMouseDown = FALSE;
	static	POINT	pt;
	static	RECT	rcWindow;
	char	tmpStr[200];
	char	servername[64];
	char	serverip[64];
	char	Account[64];
	char	Password[64];
	DWORD	pid;
	switch (message)
	{
		case WM_INITDIALOG:

			//SetWindowRgn( hDlg, h, FALSE );
			g_hMainDlg = hDlg;
			g_hSysLog = GetDlgItem( hDlg, LB_SYSLOG );
			g_hChatLog = GetDlgItem( hDlg, LB_CHATLOG );
			mirgame.InitLogSystem( g_hSysLog, g_hChatLog, MAX_LOGLINES );
			SetGroupFile( "group.dat" );
			SetAreaList( GetDlgItem( hDlg, CB_AREA ));
			SetServerCaptionList( GetDlgItem( hDlg, CB_SERVER ), 0 );
			//SetWindowLong( hDlg, GWL_ID, 0 );
			GetWindowRect( hDlg, &rcWindow );
			mirgame.LogChat( "%d, %d - %d, %d", rcWindow.left, rcWindow.top, rcWindow.right ,rcWindow.bottom );
			return TRUE;
		case	WM_PAINT:

			break;
		case	WM_LBUTTONDOWN:
			break;
		case	WM_LBUTTONUP:
			break;
		case	WM_MOUSEMOVE:
			break;
		case WM_CLOSE:
			EndDialog(hDlg, LOWORD(wParam));
			return TRUE;
			break;
		case WM_COMMAND:
			idcmd = LOWORD( wParam );
			switch( idcmd )
			{
			case	CB_SERVER:
				ServerId = ComboBox_GetCurSel(GetDlgItem( hDlg, CB_SERVER));
				break;
			case	CB_AREA:
				AreaId = ComboBox_GetCurSel(GetDlgItem( hDlg, CB_AREA));
				SetServerCaptionList( GetDlgItem( hDlg, CB_SERVER ), AreaId );
				ServerId = ComboBox_GetCurSel(GetDlgItem( hDlg, CB_SERVER));
				break;
			case	BT_CONNECT:
				GetServerName( AreaId, ServerId, servername );
				GetIpAddress( AreaId, serverip );
				sprintf( tmpStr, "%s:%s", servername, serverip );
				if( !mirgame.OpenGateServer( serverip ) )
					break;
				GetDlgItemText( hDlg, ED_ACCOUNT, Account, 64 );
				GetDlgItemText( hDlg, ED_PASSWORD,	Password, 64 );
				//if( strlen( Account ) > 0 && strlen( Password ) > 4 )
				{
					if( mirgame.Login( Account, Password ) )
					{
						//mirgame.LogSystem( servername );
					    if( mirgame.EnterServer( servername ))
						{
							if( mirgame.EnterSelCharServer() )
							{
								CreateThread( NULL, 1024 * 1024 * 1, (LPTHREAD_START_ROUTINE)ThreadProc, 0, 0, &pid );
								//mirgame.EnterGame( 0 );
							}
						}
					}
				}

				//MessageBox( 0, tmpStr, 0, 0 );
				//LogToList( GetDlgItem( hDlg, LB_SYSLOG ), tmpStr );
//				LogSystem( tmpStr );

				//ComboBox_GetCurSel( GetDlgItem(hDlg, CB_SERVER ))
				break;
			case	BT_DISCONNECT:
				mirgame.Logout();
				break;
			case	BT_SEND:
				GetDlgItemText( hDlg, ED_CHAT, tmpStr, 200 );
				if( strlen( tmpStr ) > 0 )
					mirgame.Say( tmpStr );
				break;
			}
			break;
	}
    return FALSE;
}
LRESULT CALLBACK MirGuiDlgProc2(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
//	DWORD	idcmd;

	switch (message)
	{
		case WM_INITDIALOG:
			return TRUE;
		case WM_CLOSE:
			EndDialog(hDlg, LOWORD(wParam));
			return TRUE;
			break;
		case WM_COMMAND:
			break;
	}
    return FALSE;
}

⌨️ 快捷键说明

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