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

📄 gamelayoutersinksection.cpp

📁 游戏框架
💻 CPP
字号:
// ***************************************************************
//  GameLayouterSinkSection   version:  1.0
//  -------------------------------------------------------------
//	File Name:	GameLayouterSinkSection.cpp
//	Created:	2007/07/18
//	Modified:	2007/07/18   17:50
//	Author:		William.Liang
//  Msn:		lwq49@msn.com
//  Email:		lwq49@21cn.com, lwq49@msn.com
//	Description:
//
//	Purpose:	
//  -------------------------------------------------------------
//  license:
//
//  The contents of this file are subject to the Mozilla Public
//  License Version 1.1 (the "License"); you may not use this file
//  except in compliance with the License. You may obtain a copy
//  of the License at http://www.mozilla.org/MPL/ Software dis-
//  tributed under the License is distributed on an "AS IS" 
//  basis, WITHOUT WARRANTY OF ANY KIND, either express or im-
//  plied. See the License for the specific language governing
//  rights and limitations under the License.
//
//  The Initial Developer of the Original Code is William.Liang .
//  Copyright (C) 2007 - All Rights Reserved.
// ***************************************************************
#include "StdAfx.h"
#include ".\GameFrameDlg.h"
#include ".\ResourceLib.h"
#include ".\gamelayoutersinksection.h"

//************************************
// <p>Description: 构造函数</p>
//************************************
CGameLayouterSinkSection::CGameLayouterSinkSection(void)
{
}

//************************************
// <p>Description: 析构函数</p>
//************************************
CGameLayouterSinkSection::~CGameLayouterSinkSection(void)
{
}

//************************************
// <p>Description: 回调处理方法</p>
// <p>Parameters:  </p>
// <p>    _CString szNodeName</p>
// <p>    _CString szParentName</p>
// <p>    LPVOID lpParam</p>
//
// <p>Returns:   void</p>
//************************************
void CGameLayouterSinkSection::Processer(_CString szNodeName, _CString szParentName, LPVOID lpParam){
	_CStringList*		pList = NULL;

	if(szNodeName == "Section"){
		//检查上层的结构格式
		if(m_pIGameLayouter->ValidNodePath("Sections")){
			//加载资源
			pList	= ((_CStringList*)lpParam);

			_CString		szID = pList->GetBy("ID");
			WORD		wSection = (int)szID;

			m_pCurrentSection = m_lpFMHandles->pGameBody->GetSection(wSection);
			goto Push_Node_Stack;
		}
	}

	if(szNodeName == "View"){
		//上层的Section不能为空
		if(m_pCurrentSection==NULL)
			goto Push_Node_Stack;

		//检查上层的结构格式
		if(m_pIGameLayouter->ValidNodePath("Sections.Section")){
			//加载资源
			pList	= ((_CStringList*)lpParam);

			m_pCurrentView = m_pCurrentSection->GetGameView();
			if(m_pCurrentView==NULL)
				goto Push_Node_Stack;

			_POINT	piPoint;
			_SIZE	siSize;
			piPoint.x = (float)pList->GetBy("Left");
			piPoint.y = (float)pList->GetBy("Top");
			siSize.cx = (float)pList->GetBy("Width");
			siSize.cy = (float)pList->GetBy("Height");
			if(siSize.cx==0) siSize.cx = m_fScreenWidth;		//设为默认窗口大小
			if(siSize.cy==0) siSize.cy = m_fScreenHeight;

			//设置视图的位置及大小
			m_pCurrentView->MoveTo(piPoint);

			goto Push_Node_Stack;
		}
	}

	if(szNodeName == "Scene"){
		//上层的Section和View不能为空
		if(m_pCurrentSection==NULL || m_pCurrentView==NULL)
			goto Push_Node_Stack;

		//检查上层的结构格式
		if(m_pIGameLayouter->ValidNodePath("Section.Scenes")){
			//加载资源
			pList	= ((_CStringList*)lpParam);

			_CString		szName	= pList->GetBy("Name");
			if(szName.IsNull() || szName=="")	szName = "default";

			//检测场景是否建立
			m_pCurrentScene = m_pCurrentView->GetBy(szName);
			if(m_pCurrentScene==NULL)
				m_pCurrentScene = m_pCurrentView->Create(szName);

			_POINT	piPoint;
			_SIZE	siSize;
			bool	bFlag;

			piPoint.x = (float)pList->GetBy("Left");
			piPoint.y = (float)pList->GetBy("Top");
			siSize.cx = (float)pList->GetBy("Width");
			siSize.cy = (float)pList->GetBy("Height");
			bFlag = (bool)pList->GetBy("Visabled");

			if(siSize.cx==0) siSize.cx = m_fScreenWidth;		//设为默认窗口大小
			if(siSize.cy==0) siSize.cy = m_fScreenHeight;

			m_pCurrentScene->MoveTo(piPoint);
			//m_pCurrentScene->SetSize(siSize);
			m_pCurrentScene->SetVisabled(bFlag);

			goto Push_Node_Stack;
		}
	}

	if(szNodeName == "Layer"){
		//上层的Section,View和Layer不能为空
		if(m_pCurrentSection==NULL || m_pCurrentView==NULL || m_pCurrentScene==NULL)
			goto Push_Node_Stack;

		//检查上层的结构格式
		if(m_pIGameLayouter->ValidNodePath("Section.Scenes.Scene")){
			//加载资源
			pList	= ((_CStringList*)lpParam);

			_CString		szName	= pList->GetBy("Name");
			if(szName.IsNull() || szName=="")	szName = "default";

			//检测层是否建立
			m_pCurrentLayer = m_pCurrentScene->GetBy(szName);
			if(m_pCurrentLayer==NULL)
				m_pCurrentLayer = m_pCurrentScene->Create(szName);

			_POINT	piPoint;
			_SIZE	siSize;
			bool	bVisabledFlag;
			bool	bDisabledFlag;
			piPoint.x = (float)pList->GetBy("Left");
			piPoint.y = (float)pList->GetBy("Top");
			siSize.cx = (float)pList->GetBy("Width");
			siSize.cy = (float)pList->GetBy("Height");
			bVisabledFlag = (bool)pList->GetBy("Visabled");
			if(pList->GetBy("Disabled").IsNull())
				bDisabledFlag = true;
			else
				bDisabledFlag = (bool)pList->GetBy("Disabled");

			if(siSize.cx==0) siSize.cx = m_fScreenWidth;		//设为默认窗口大小
			if(siSize.cy==0) siSize.cy = m_fScreenHeight;

			m_pCurrentLayer->MoveTo(piPoint);
			//m_pCurrentScene->SetSize(siSize);
			m_pCurrentLayer->SetVisabled(bVisabledFlag);
			m_pCurrentLayer->SetDisabled(bDisabledFlag);

			goto Push_Node_Stack;
		}
	}

Push_Node_Stack:
	return;
}

//************************************
// <p>Description: 设置上级接口</p>
// <p>Parameters:  </p>
// <p>    IGameLayouter * pIGameLayouter</p>
// <p>    LPFRAMEMANAGERHANDLE pFMHandles</p>
//
// <p>Returns:   void</p>
//************************************
void CGameLayouterSinkSection::SetGameLayouter(IGameLayouter*	pIGameLayouter, LPFRAMEMANAGERHANDLE pFMHandles){
	m_pIGameLayouter	= pIGameLayouter;
	m_lpFMHandles		= pFMHandles;

	//返回屏幕大小
	GAMEFRAMESETTING*	pGameFrameSetting = m_lpFMHandles->pGameFrameDlg->GetGameFrameSetting();
	m_fScreenWidth		= (float)pGameFrameSetting->wScreenWidth;
	m_fScreenHeight		= (float)pGameFrameSetting->wScreenHeight;
}

//************************************
// <p>Description: 接口查询</p>
// <p>Parameters:  </p>
// <p>    const IID & Guid</p>
// <p>    DWORD dwQueryVer</p>
//
// <p>Returns:   void *</p>
//************************************
void * CGameLayouterSinkSection::QueryInterface(const IID & Guid, DWORD dwQueryVer){
	QUERYINTERFACE(IGameLayouterSink,Guid,dwQueryVer);
	QUERYINTERFACE_IUNKNOWNEX(IGameLayouterSink,Guid,dwQueryVer);
	return NULL;
}

⌨️ 快捷键说明

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