예제 #1
0
CHeightmapObject::CHeightmapObject(IHashString *parentName, IHashString *name) :
		OBJECTTEMPLATE( CTerrainManager, CHeightmapObject, IObject, parentName, name)
{
	m_pManager = dynamic_cast<CTerrainManager*>(m_ToolBox->GetComponent(GetManagerName()));

	m_pHeightmapData = NULL;
	m_iWidth = 0;
	m_iHeight = 0;
}
void CQHStateMachineActionHandler::DeInit()
{
	IComponent *amanagerComponent = m_ToolBox->GetComponent( GetManagerName() );
	CQHStateMachineManager *amanager = static_cast<CQHStateMachineManager*>( amanagerComponent );
	CQHStateMachineEvent *parentEvent = amanager->GetEvent( GetParentName() );

	if( parentEvent != NULL )
	{
		parentEvent->RemoveActionHandler( this );
	}
}
예제 #3
0
	LRESULT WindowImplBase::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
	{
		// 调整窗口样式
		LONG styleValue = ::GetWindowLong(*this, GWL_STYLE);
		styleValue &= ~WS_CAPTION;
		::SetWindowLong(*this, GWL_STYLE, styleValue | WS_CLIPSIBLINGS | WS_CLIPCHILDREN);

		// 调整窗口尺寸
		RECT rcClient;
		::GetClientRect(*this, &rcClient);
		::SetWindowPos(*this, NULL, rcClient.left, rcClient.top, rcClient.right - rcClient.left, rcClient.bottom - rcClient.top, SWP_FRAMECHANGED);

		// 关联UI管理器
		m_pm.Init(m_hWnd, GetManagerName());
		// 注册PreMessage回调
		m_pm.AddPreMessageFilter(this);

		// 创建主窗口
		CControlUI* pRoot=NULL;
		CDialogBuilder builder;
		CDuiString sSkinType = GetSkinType();
		if (!sSkinType.IsEmpty()) {
			STRINGorID xml(_ttoi(GetSkinFile().GetData()));
			pRoot = builder.Create(xml, sSkinType, this, &m_pm);
		}
		else {
			pRoot = builder.Create(GetSkinFile().GetData(), (UINT)0, this, &m_pm);
		}

		if (pRoot == NULL) {
			CDuiString sError = _T("加载资源文件失败:");
			sError += GetSkinFile();
			MessageBox(NULL, sError, _T("Duilib") ,MB_OK|MB_ICONERROR);
			ExitProcess(1);
			return 0;
		}
		m_pm.AttachDialog(pRoot);
		// 添加Notify事件接口
		m_pm.AddNotifier(this);
		// 窗口初始化完毕
		InitWindow();
		return 0;
	}
void CQHStateMachineActionHandler::Serialize( IArchive &ar )
{
	if( ar.IsReading() )
	{
		float fVersion;
		StdString tempStr;
		ar.Read( fVersion, _T("version") );
		if( fVersion > m_fCurrentVersion )
		{
			LPCTSTR fmt = _T("%s(%d): Unsupported version (%f) of state machine action handler");
			m_ToolBox->Log( LOGERROR, fmt, __FILE__, __LINE__, fVersion );
			return;
		}
		ar.Read( tempStr, _T("name") );
		m_szName.Init( tempStr );
		ar.Read( tempStr, _T("actionName") );
		m_szActionName.Init( tempStr );

		IComponent *amanagerComponent = m_ToolBox->GetComponent( GetManagerName() );
		CQHStateMachineManager *amanager = static_cast<CQHStateMachineManager*>( amanagerComponent );
		CQHStateMachineEvent *aparentEvent = amanager->GetEvent( GetParentName() );
		if( aparentEvent != NULL )
		{
			aparentEvent->AddActionHandler( this );
		}
		else
		{
			m_ToolBox->Log( LOGERROR, _T("Could not find parent event %s for action handler %s."), GetParentName()->GetString(), GetName()->GetString() );
		}
	}
	else
	{
		ar.Write( m_fCurrentVersion, _T("version") );
		ar.Write( m_szName.GetString(), _T("name") );
		ar.Write( m_szActionName.GetString(), _T("actionName") );
	}
}
예제 #5
0
LRESULT WindowImplBase::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	LONG styleValue = ::GetWindowLong(*this, GWL_STYLE);
	styleValue &= ~WS_CAPTION;
	::SetWindowLong(*this, GWL_STYLE, styleValue | WS_CLIPSIBLINGS | WS_CLIPCHILDREN);

	RECT rcClient;
	::GetClientRect(*this, &rcClient);
	::SetWindowPos(*this, NULL, rcClient.left, rcClient.top, rcClient.right - rcClient.left, \
		rcClient.bottom - rcClient.top, SWP_FRAMECHANGED);

	// 关联UI管理器
	m_PaintManager.Init(m_hWnd, GetManagerName());
	m_PaintManager.AddPreMessageFilter(this);

	// 多语言接口
	CResourceManager::GetInstance()->SetTextQueryInterface(this);

	CDialogBuilder builder;
	if (m_PaintManager.GetResourcePath().IsEmpty())
	{	// 允许更灵活的资源路径定义
		CDuiString strResourcePath=m_PaintManager.GetInstancePath();
		strResourcePath += GetSkinFolder().GetData();
		m_PaintManager.SetResourcePath(strResourcePath.GetData());
	}

	switch(GetResourceType())
	{
	case UILIB_ZIP:
		m_PaintManager.SetResourceZip(GetZIPFileName().GetData(), true);
		break;
	case UILIB_ZIPRESOURCE:
		{
			HRSRC hResource = ::FindResource(m_PaintManager.GetResourceDll(), GetResourceID(), _T("ZIPRES"));
			if( hResource == NULL )
				return 0L;
			DWORD dwSize = 0;
			HGLOBAL hGlobal = ::LoadResource(m_PaintManager.GetResourceDll(), hResource);
			if( hGlobal == NULL ) 
			{
#if defined(WIN32) && !defined(UNDER_CE)
				::FreeResource(hResource);
#endif
				return 0L;
			}
			dwSize = ::SizeofResource(m_PaintManager.GetResourceDll(), hResource);
			if( dwSize == 0 )
				return 0L;

			m_PaintManager.SetResourceZip((LPBYTE)::LockResource(hGlobal), dwSize);

#if defined(WIN32) && !defined(UNDER_CE)
			::FreeResource(hResource);
#endif
		}
		break;
	}
	// 资源管理器接口
	InitResource();

	// 创建主窗口
	CControlUI* pRoot=NULL;
	if (GetResourceType() == UILIB_RESOURCE)
	{
		STRINGorID xml(_ttoi(GetSkinFile().GetData()));
		pRoot = builder.Create(xml, _T("xml"), this, &m_PaintManager);
	}
	else {
		pRoot = builder.Create(GetSkinFile().GetData(), (UINT)0, this, &m_PaintManager);
	}
 	ASSERT(pRoot);
	if (pRoot==NULL)
	{
		MessageBox(NULL,_T("加载资源文件失败"),_T("Duilib"),MB_OK|MB_ICONERROR);
		ExitProcess(1);
		return 0;
	}
	m_PaintManager.AttachDialog(pRoot);
	m_PaintManager.AddNotifier(this);

	InitWindow();
	return 0;
}
예제 #6
0
CSchemaItem::CSchemaItem( IHashString *parentName, IHashString *name ) :
	OBJECTTEMPLATE( CDatabaseManager, CSchemaItem, IObject, parentName, name ),
	m_hszCharType(_T("char")),
	m_hszUCharType(_T("unsigned char")),
	m_hszShortType(_T("short int")),
	m_hszUShortType(_T("unsigned short int")),
	m_hszLongType(_T("long int")),
	m_hszULongType(_T("unsigned long int")),
	m_hszFloatType(_T("float")),
	m_hszDoubleType(_T("double")),
	m_hszBoolType(_T("bool")),
	m_hszStringType(_T("string"))
{
	m_ToolBox = EngineGetToolBox();
	m_fVersion = 1.0f;
	m_hszLabel.Init(_T(""));
	m_hszType.Init(_T("char"));
	m_hszClass.Init(_T("edit"));

	m_DataReadFunctions[m_hszCharType.GetUniqueID()]	= &CSchemaItem::DBReadChar;
	m_DataReadFunctions[m_hszUCharType.GetUniqueID()]	= &CSchemaItem::DBReadUChar;
	m_DataReadFunctions[m_hszShortType.GetUniqueID()]	= &CSchemaItem::DBReadShort;
	m_DataReadFunctions[m_hszUShortType.GetUniqueID()]	= &CSchemaItem::DBReadUShort;
	m_DataReadFunctions[m_hszLongType.GetUniqueID()]	= &CSchemaItem::DBReadLong;
	m_DataReadFunctions[m_hszULongType.GetUniqueID()]	= &CSchemaItem::DBReadULong;
	m_DataReadFunctions[m_hszFloatType.GetUniqueID()]	= &CSchemaItem::DBReadFloat;
	m_DataReadFunctions[m_hszDoubleType.GetUniqueID()]	= &CSchemaItem::DBReadDouble;
	m_DataReadFunctions[m_hszBoolType.GetUniqueID()]	= &CSchemaItem::DBReadBool;
	m_DataReadFunctions[m_hszStringType.GetUniqueID()]	= &CSchemaItem::DBReadString;

	m_DataWriteFunctions[m_hszCharType.GetUniqueID()]	= &CSchemaItem::DBWriteChar;
	m_DataWriteFunctions[m_hszUCharType.GetUniqueID()]	= &CSchemaItem::DBWriteChar;
	m_DataWriteFunctions[m_hszShortType.GetUniqueID()]	= &CSchemaItem::DBWriteShort;
	m_DataWriteFunctions[m_hszUShortType.GetUniqueID()]	= &CSchemaItem::DBWriteShort;
	m_DataWriteFunctions[m_hszLongType.GetUniqueID()]	= &CSchemaItem::DBWriteLong;
	m_DataWriteFunctions[m_hszULongType.GetUniqueID()]	= &CSchemaItem::DBWriteLong;
	m_DataWriteFunctions[m_hszFloatType.GetUniqueID()]	= &CSchemaItem::DBWriteFloat;
	m_DataWriteFunctions[m_hszDoubleType.GetUniqueID()]	= &CSchemaItem::DBWriteFloat;
	m_DataWriteFunctions[m_hszBoolType.GetUniqueID()]	= &CSchemaItem::DBWriteBool;
	m_DataWriteFunctions[m_hszStringType.GetUniqueID()]	= &CSchemaItem::DBWriteString;

	CHashString hszEditorTypeInt( _T("int") );
	CHashString hszEditorTypeFloat( _T("float") );
	CHashString hszEditorTypeDouble( _T("double") );
	CHashString hszEditorTypeBool( _T("bool") );
	CHashString hszEditorTypeString( _T("string") );

	m_TypeIDtoEditorTypeIDMap[m_hszCharType.GetUniqueID()]		= hszEditorTypeString.GetUniqueID();
	m_TypeIDtoEditorTypeIDMap[m_hszUCharType.GetUniqueID()]		= hszEditorTypeString.GetUniqueID();
	m_TypeIDtoEditorTypeIDMap[m_hszShortType.GetUniqueID()]		= hszEditorTypeInt.GetUniqueID();
	m_TypeIDtoEditorTypeIDMap[m_hszUShortType.GetUniqueID()]	= hszEditorTypeInt.GetUniqueID();
	m_TypeIDtoEditorTypeIDMap[m_hszLongType.GetUniqueID()]		= hszEditorTypeInt.GetUniqueID();
	m_TypeIDtoEditorTypeIDMap[m_hszULongType.GetUniqueID()]		= hszEditorTypeInt.GetUniqueID();
	m_TypeIDtoEditorTypeIDMap[m_hszFloatType.GetUniqueID()]		= hszEditorTypeFloat.GetUniqueID();
	m_TypeIDtoEditorTypeIDMap[m_hszDoubleType.GetUniqueID()]	= hszEditorTypeDouble.GetUniqueID();
	m_TypeIDtoEditorTypeIDMap[m_hszBoolType.GetUniqueID()]		= hszEditorTypeBool.GetUniqueID();
	m_TypeIDtoEditorTypeIDMap[m_hszStringType.GetUniqueID()]	= hszEditorTypeString.GetUniqueID();

	if( parentName != NULL )
	{
		IComponent *amanagerComponent = m_ToolBox->GetComponent( GetManagerName() );
		CDatabaseManager *amanager = (CDatabaseManager*)( amanagerComponent );
		static CHashString CDSName( _T("CDatabaseSchema"));
		IDTOOBJECTMAP *objectMap = amanager->GetObjectMap( &CDSName );
		IDTOOBJECTMAP::iterator objectsIterator = objectMap->find(parentName->GetUniqueID());
		if( objectsIterator != objectMap->end() )
		{
			m_Schema = (CDatabaseSchema*)objectsIterator->second;
		}
		else
		{
			m_Schema = NULL;
			m_ToolBox->Log( LOGWARNING, _T("Invalid parent specified for schema item %s\n"), name->GetString() );
		}
	}
	else
	{
		m_Schema = NULL;
		m_ToolBox->Log( LOGWARNING, _T("No parent specified for schema item %s\n"), name->GetString() );
	}
}
예제 #7
0
CQHStateMachineManager *CQHState::GetManager()
{
	IComponent *amanagerComponent = m_ToolBox->GetComponent( GetManagerName() );
	CQHStateMachineManager *amanager = dynamic_cast<CQHStateMachineManager*>( amanagerComponent );
	return amanager;
}