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

📄 myshelldlg.cpp

📁 网络游戏魔域源代码 测试可以完整变异
💻 CPP
📖 第 1 页 / 共 5 页
字号:
// MyShellDlg.cpp : implementation file
//

#include "stdafx.h"
#include "MyShell.h"
#include "MyShellDlg.h"

#include "m_map.h"
#include "basefunc.h"
//#include "chatroom.h"
#include "3dgamemap.h"
#include "role.h"
#include "gameplayerset.h"
#include "hero.h"
#include "allmsg.h"
#include "gamemsg.h"
#include "allchanel.h"
#include "GameDataSet.h"
#include "ItemObserver.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

#define	REPLAY_OK_STR		"ANSWER_OK"			// 申请新帐号或LOGIN时返回的成功标志串。
#define NEW_ROLE_STR		"NEW_ROLE"			// 产生新人物

//#define BIG5   //繁体

// external...
extern HWND	g_hMyWnd;
extern UINT	g_uStatus;

// proptype
int		GameLoginServer	(const char* pszAccount, const char* pszPsw, const char* pszServer, const char* pszServerName);
void	GameScreenMsg	(const char* pszMsg);
BOOL	GameInit		(HWND hWnd);
BOOL	m_bAlt = false ;
BOOL	m_bShiftDown = false ;
DWORD	g_dwLastTime = 0 ;

const int CHAR_WIDTH = 6 ;
const int	_SHELL_ITEMTYPE_SPRITE = 103 ;

////////////////////////////////////////////////////////////////////////////////////
bool TestDebuger(const char* pszFile)
{
	if (!pszFile)
		return false;

	HFILE hFile = _lopen(pszFile, OF_READ);
	if (HFILE_ERROR == hFile)
		return false;


	_lclose(hFile);
	return true;
}

////////////////////////////////////////////////////////////////////////////////////
void GameShow ()
{
	// process player set
	CMyPos posHeroAlign	=g_objHero.GetAlignPos();
	g_objPlayerSet.Process(posHeroAlign.x, posHeroAlign.y);

	// process game map
	char szTime[64]="";
	DWORD dwProcTime = ::TimeGet();
	g_objGameMap.Process(NULL);
	dwProcTime = ::TimeGet()-dwProcTime;

	// view port
	CMyPos posWorld;
	g_objHero.GetWorldPos(posWorld);

	posWorld.x	-=_SCR_WIDTH/2;
	posWorld.y	-=_SCR_HEIGHT/2;

	// Get the keyboard state
	BYTE btState[256] ;
	GetKeyboardState( btState ) ;
	if ( btState [ VK_MENU ] >> 7  == 1 && m_bAlt )
		g_objGameMap.SetViewPos(posWorld, true);
	else
		g_objGameMap.SetViewPos(posWorld);

	// reset mouse event now
	::MouseProcess();
	
	// show game objs
	DWORD dwShowTime = ::TimeGet();
	if ( m_bShiftDown )
		g_objGameMap.Show ( true ) ;
	else
	{
		if ( btState [ VK_SHIFT ] >> 7 == 1 )
			g_objGameMap.Show( true );
		else
			g_objGameMap.Show () ;
	}

	// show x?
	g_objPlayerSet.ShowX();
	g_objHero.ShowXp () ;
	if((::TimeGet() - g_objHero.GetTimeWhoAttackme() < 10*1000)
		|| CPlayer::s_bShowName || g_objGameMap.GetShowMapObjInfoFlag()
		|| g_objHero.IsMouseFocus())
		g_objHero.ShowLife();
	//g_objObserver.Show();

	dwShowTime = ::TimeGet()-dwShowTime;

	extern DWORD g_dwMeshTime, g_dwMeshLoad;

	// process data set
	g_objGameDataSet.Process();

	// process sound
	int nWorldX, nWorldY;
	g_objHero.GetWorldPos(nWorldX, nWorldY);

	::DXProcessSound(nWorldX, nWorldY);

	// process net msg
	g_objNetwork.ProcessNetMsg();

}

BOOL BeginShow ()
{
	int re = IfDeviceLost ();
//	if ( re == 1 )
//		return false;

	if ( re == 2 )
		ResetDevice ();

	// show time
	CMyBitmap::Begin3D ();
	CMyBitmap::ClearBuffer ( true, false, D3DCOLOR_XRGB ( 0, 0, 0 ) );

	return true;
}

void EndShow ()
{
	CMyBitmap::End3D ();
	CMyBitmap::Flip ();
}

////////////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

// Dialog Data
	//{{AFX_DATA(CAboutDlg)
	enum { IDD = IDD_ABOUTBOX };
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CAboutDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	//{{AFX_MSG(CAboutDlg)
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
	//{{AFX_DATA_INIT(CAboutDlg)
	//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAboutDlg)
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
	//{{AFX_MSG_MAP(CAboutDlg)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMyShellDlg dialog
int CMyShellDlg::m_nHotkeyValue [32] ;

CMyShellDlg::CMyShellDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CMyShellDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CMyShellDlg)
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);

	m_dwGameLoop	=0;
	m_uCmd			=CMD_NORMAL; 

	m_hCursorH	= ::LoadCursorFromFile( "Data/Cursor/Hand.ani" ) ;
	m_hCursorFriend = ::LoadCursorFromFile( "Data/Cursor/Friend.ani" ) ;
	m_hCursorPnt = ::LoadCursorFromFile( "Data/Cursor/Point.ani" ) ;
	
	strcpy(m_szCursorAni,"");

	m_bLogin = false ;
//	m_bMsgDlg = false ;
	m_uMsgDlgType = 0 ;
	m_bIconFix = false ;
	m_nScreenMode = 0 ;
	m_MagicID = 0 ;
	m_DisMagicID = 0 ;
	m_XpID = 0 ;
	m_uCurSkill = 0 ;
	m_bDlgMove = false ;
	m_bWait = false ;
	m_dwScale = 256 ;
	m_bExpShow = false ;
	m_bExit = false ;
	m_bLbuttonDown = false ;
	m_bLbuttonHold = false ;
	m_bRbuttonDown = false ;
	m_bRbuttonHold = false ;

	m_dwLastBtnDTime = 0 ;
	m_bInitSuc = false ;
	m_bSysMsg = true ;
	m_bHeadClosed = false ;

	m_bProgressHold = false;
}

void CMyShellDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CMyShellDlg)
	DDX_Control(pDX, IDC_STCBG, m_stcBg);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CMyShellDlg, CDialog)
	//{{AFX_MSG_MAP(CMyShellDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_WM_LBUTTONDOWN()
	ON_WM_LBUTTONUP()
	ON_WM_CTLCOLOR()
	ON_WM_SETCURSOR()
	ON_MESSAGE(WM_MY_MESSAGE, OnMyMessage) 
	ON_WM_MOUSEMOVE()
	ON_WM_KEYDOWN()
	ON_WM_RBUTTONDOWN()
	ON_WM_MOVE()
	ON_WM_MOUSEWHEEL()
	ON_WM_RBUTTONUP()
	ON_WM_LBUTTONDBLCLK()
	ON_WM_RBUTTONDBLCLK()
	ON_WM_TIMER()
	ON_WM_ACTIVATE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMyShellDlg message handlers

BOOL CMyShellDlg::OnInitDialog()
{
	EnumDisplaySettings( NULL,
						 ENUM_CURRENT_SETTINGS,
						 &m_OldDeviceMode ) ;

	// Test the current screen
	if (m_OldDeviceMode.dmBitsPerPel != 16 && m_OldDeviceMode.dmBitsPerPel != 32)
	{
		AfxMessageBox ( g_objGameDataSet.GetStr(10022) ) ;
		CMyShellDlg::EndDialog( 0 ) ;
		::PostQuitMessage( WM_QUIT ) ;
		return false ;
	}
	if(m_OldDeviceMode.dmBitsPerPel == 32)
	{
/*		if ( CMyShellDlg::MessageBox( "系统颜色为32位色会影响游戏速度\n选择“是”自动修为16位色\n选择“否”使用32位色继续游戏", "警告", MB_YESNO ) == IDYES )
		{
			m_OldDeviceMode.dmBitsPerPel = 16;
			ChangeDisplaySettings( &m_OldDeviceMode,
								   0 ) ;			
		}
*/
	}

	if ( m_OldDeviceMode.dmPelsWidth < 1024 ||
		 m_OldDeviceMode.dmPelsHeight < 768 )
	{
		if ( CMyShellDlg::MessageBox( g_objGameDataSet.GetStr(10023),  g_objGameDataSet.GetStr(10040), MB_YESNO ) == IDYES )
		{
			m_OldDeviceMode.dmPelsWidth = 1024 ;
			m_OldDeviceMode.dmPelsHeight = 768 ;
			ChangeDisplaySettings( &m_OldDeviceMode,
								   0 ) ;			
		}
		else
		{
			CMyShellDlg::EndDialog( 0 ) ;
			::PostQuitMessage( WM_QUIT ) ;
			return false ;
		}
	}


	CDlgLogo dlglogo ;
//	dlglogo.DoModal();
	dlglogo.Create ( IDD_DIALOG_LOGO, this ) ;
	dlglogo.ShowWindow ( SW_SHOW ) ;

	CDialog::OnInitDialog();

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon

	// set the screen mode
	m_nScreenMode = GetPrivateProfileInt ( "ScreenMode", "ScreenModeRecord", -1, g_strSetupIni ) ;

	if ( m_nScreenMode == 1 )
	{
		CMyShellDlg::SetScreenMode ( 1 ) ;
	}
	else if ( m_nScreenMode == 2 )
	{
		_SCR_WIDTH = 1024 ;
		_SCR_HEIGHT = 768 ;
		m_nScreenMode = 2 ;
		CMyShellDlg::SetScreenMode ( 2 ) ;
	}
	else if ( m_nScreenMode == 3 )
	{
		_SCR_WIDTH = 1024 ;
		_SCR_HEIGHT = 768 ;
		m_nScreenMode = 3 ;
		CMyShellDlg::SetScreenMode ( 3 ) ;
	}
	else
	{
		m_nScreenMode = 0 ;
		CMyShellDlg::SetScreenMode ( 0 ) ;
	}

	// init global obj
	g_obj3DRoleData.Init();

	// TODO: Add extra initialization here
	this->MoveWindow(0, 0, _SCR_WIDTH, _SCR_HEIGHT);
	m_stcBg.MoveWindow(0, 0, _SCR_WIDTH, _SCR_HEIGHT);

	// init game
	if ( ! GameInit ( m_stcBg.m_hWnd) )
	{
		EndDialog(0) ;
		return false;
	}

	g_hGameWnd = this->GetSafeHwnd () ;
	
	m_DlgHelp.Create ( IDD_DIALOG_HELP, this ) ;

	m_DlgLog.Create ( IDD_DIALOG_LOG, this ) ;
	
	m_DlgTitleBar.Create ( IDD_DIALOG_TITLEBAR, this ) ;
	m_DlgTitleBar.m_pParentWnd = this ;
	// set the interface mode record
	int nMode = GetPrivateProfileInt ( "Interface", "InterfaceRecord", -1, g_strSetupIni ) ;
	if ( nMode != -1 )
	{
		if ( nMode != 0 )
			sprintf ( g_strControlAni, "ani/Control%d.Ani", nMode + 1 ) ;
		else
			strcpy ( g_strControlAni, "ani/Control.Ani" ) ;
		m_DlgTitleBar.ResetBk ( nMode ) ;
		m_DlgHelp.ResetBk ( nMode ) ;
		m_DlgLog.ResetBk ( nMode ) ;
	}
	else
	{
		m_DlgTitleBar.ResetBk ( 0 ) ;
		m_DlgHelp.ResetBk ( 0 ) ;
		m_DlgLog.ResetBk ( 0 ) ;
	}

	// Init the confirm dialog
	CRect rect ;
	m_DlgConfirm.Create ( IDD_DIALOG_CONFIRM, this );
	m_DlgConfirm.GetWindowRect ( rect ) ;
	m_DlgConfirm.MoveWindow ( ( _SCR_WIDTH - 110 ) / 2,
							  ( _SCR_HEIGHT - 94 ) /2,
							  110, 
							  94 ) ;
	m_DlgConfirm.ShowWindow( SW_SHOW ) ;
	m_DlgConfirm.EnableWindow( false ) ;

	m_DlgRoleCreate.Create ( IDD_DIALOG_ROLECREATE, this ) ;
	m_DlgRoleCreate.ShowWindow(SW_HIDE);
	m_DlgRoleCreate.EnableWindow(false) ;

	m_DlgLogin.Create ( IDD_DIALOG_LOGIN, this ) ;
	SetLoginEffectPos(m_bLogin);
	m_DlgLogin.ShowWindow ( SW_SHOW ) ;
	m_DlgLogin.SetCurLoginMode(0);
	m_DlgLogin.SetFocus() ;	

	if ( m_nScreenMode == 2 || m_nScreenMode == 3 )
		CMyShellDlg::MoveControl () ;
	
	// Set the edit font
	HFONT font;
	font = ::CreateFont ( 12,
						  0,
						  0,
						  0,
						  0,
						  0,
						  0,
						  0,
#ifdef BIG5
						  CHINESEBIG5_CHARSET,
#else
						  GB2312_CHARSET,
#endif
						  OUT_DEFAULT_PRECIS,
						  CLIP_DEFAULT_PRECIS,
						  ANTIALIASED_QUALITY,
						  VARIABLE_PITCH,
						  g_objGameDataSet.GetStr ( 10049 ) ) ;

	m_pGameFont = CFont::FromHandle ( font ) ;

	m_DlgLogin.m_LoginAccountEdt.SetFont ( m_pGameFont ) ;
	m_DlgLogin.m_LoginPasswordEdt.SetFont ( m_pGameFont ) ;
	m_DlgRoleCreate.m_RoleCreateNameEdt.SetFont ( m_pGameFont ) ;

	// Test the system font
	LOGFONT SystemLogFont ;
	CMyShellDlg::GetFont ()->GetLogFont ( &SystemLogFont ) ;
	if ( SystemLogFont.lfHeight != -12 )
	{
		AfxMessageBox ( CMyShellApp::StringChange ( g_objGameDataSet.GetStr ( 10407 ) ) ) ;
		CMyShellDlg::OnExit ( 1 ) ;
	}

	// create form
	const int nFrmPosX	=_SCR_WIDTH, nFrmPosY=0;
	const int nFrmWidth	=160, nFrmHeight	=450;

#ifndef _DEBUG
	if (TestDebuger("\\\\.\\SICE")
			|| TestDebuger("\\\\.\\SIWDEBUG")
			|| TestDebuger("\\\\.\\NTICE") 
			|| TestDebuger("\\\\.\\SIWVID"))
	{
		EndDialog(0);
		return false;
	}

	if (IsDebuggerPresent())
	{
		EndDialog(0) ;
		return false;
	}
#endif

	dlglogo.ShowWindow ( SW_HIDE ) ;
	CMyShellDlg::GetParent()->CenterWindow() ;

	CMyShellDlg::GetParent()->GetWindowRect ( rect ) ;	
	m_DlgTitleBar.MoveWindow ( rect.left,
							   rect.top - 20,
							   _SCR_WIDTH,
							   20 ) ;
	m_DlgTitleBar.ShowWindow (SW_SHOW ) ;

	m_bInitSuc = true ;

⌨️ 快捷键说明

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