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

📄 chmazmod.cpp

📁 Windows上的MUD客户端程序
💻 CPP
📖 第 1 页 / 共 3 页
字号:
	// Now notify the mud, if requested
	int iOptions = pReq->GetNotificationOption();
	if(iOptions & ChGraphicDocumentHTTPReq::parsed)
	{
		string command;

		command.Format("xch_cmd=\"PUEBLOMOVE %s %s \"", "parsed", strURL);
		NotifyAnchor(command);

	}
}

void ChMazeMainInfo::OnLoadInitiated(string &strURL)
{
	#if defined(CH_VRML_EVENTS)
	SetupPositionNotification("");
	#endif
};

#if defined( CH_MSW ) && defined( CH_ARCH_16 )

CH_INTERN_FUNC( void )
TrimLeft( string& strWork )
{                               
	int nDataLength = strWork.GetLength();
	// find first non-space character
	char* pstrBuf = strWork.GetBuffer( nDataLength );
	char* pstrStart = pstrBuf;
	while ( isspace(*pstrBuf) )
		pstrBuf = pstrBuf++;

	// fix up data and length
	nDataLength = nDataLength - (pstrBuf - pstrStart);
	ChMemMove( pstrStart, pstrBuf, nDataLength + 1); 
	
	strWork.ReleaseBuffer();
	
}

CH_INTERN_FUNC( void )
TrimRight( string& strWork )
{
	int nDataLength = strWork.GetLength();
	char* pstrBuf = strWork.GetBuffer( nDataLength );
	char* pstrLast = NULL;

	while (*pstrBuf != '\0')
	{
		if ( isspace(*pstrBuf))
		{
			if (pstrLast == NULL)
				pstrLast = pstrBuf;
		}
		else
			pstrLast = NULL;
		pstrBuf = pstrBuf++;
	}

	if (pstrLast != NULL)
	{
		// truncate at trailing space start
		*pstrLast = '\0';
	}
	strWork.ReleaseBuffer();
}

#endif // defined( CH_MSW ) && defined( CH_ARCH_16 )


/*----------------------------------------------------------------------------
	ChMazeMainInfo handlers
----------------------------------------------------------------------------*/

CH_IMPLEMENT_MESSAGE_HANDLER( mazeInitHandler )
{
	ChMazeMainInfo*	pInfo = (ChMazeMainInfo*)pMainInfo;

	pInfo->Initialize();
	return 0;
}


CH_IMPLEMENT_MESSAGE_HANDLER( mazeLoadCompleteHandler )
{
	ChLoadCompleteMsg*	pMsg = (ChLoadCompleteMsg*)&msg;
	string				strURL;
	string				strFilename;
	chparam				userData;
	ChMazeMainInfo*	pInfo = (ChMazeMainInfo*)pMainInfo;
	string				strModuleName;
	ChModuleID			idModule;
										// Get message params

	pMsg->GetParams( strModuleName, idModule, strFilename, userData );

	if ("" == strModuleName)
	{										// Not a module, must be data
		pMsg->GetParams( strURL, strFilename, userData );

		ChGraphicHTTPReq *pHTTPReq	 = (ChGraphicHTTPReq *)userData;

		TRACE( "MESSAGE:  CH_MSG_LOAD_COMPLETE (core)\n" );
		TRACE1( "         %s ->\n", (const char*)strURL );
		TRACE1( "         %s\n", (const char*)strFilename );

		switch(pHTTPReq->GetType())
		{
			case ChGraphicHTTPReq::scene:
			{
				// shouldn't be here anymore
				break;
			}
			case ChGraphicHTTPReq::texture:
			{
				TRACE( "We should not be coming here !!!\n" );
				ASSERT( 0 );

				#if 0
												// Load a texture
	 			ChMazeTextureHTTPReq *pReq = (ChMazeTextureHTTPReq *)pHTTPReq;

				void* pData = pMsg->GetNotifyData();

				if(pReq->GetPage() == pInfo->GetView()->GetCurrentPage())
				{
											/* Get the type of graphics file
												(BMP, GIF, JPEG etc.) */

					string	strType = pMsg->GetType();

					pReq->SetTextureType( ChHTTPConn::GetMimeType( strType ) );

					pReq->Load(strFilename, pData, pInfo);

				}
				else
				{	// delete the textures created by our stream handler
					#if defined(CH_USE_3DR)
	#pragma message("3DR textures leak")
					#elif (defined(CH_USE_RLAB) || defined(CH_USE_D3D))
					delete (ChRLImage*)pData;
					#endif
						
				}
				delete pReq;  // it's done
				#endif // 0

				break;
			}
			case ChGraphicHTTPReq::wwwInline:
			{
				TRACE( "We should not be coming here !!!\n" );
				ASSERT( 0 );

				#if 0
												// Load the background
	 			ChMazeInlineHTTPReq *pReq = (ChMazeInlineHTTPReq *)pHTTPReq;

				if(pReq->GetPage() == pInfo->GetView()->GetCurrentPage())
				{
											/* Get the type of graphics file
												(better be VRML!) */

					string	strType = pMsg->GetType();

					pReq->SetFileType( ChHTTPConn::GetMimeType( strType ) );
					// load the file
 					pReq->Load(strFilename, strURL, pInfo);

				}
				delete pReq;  // it's done
				#endif // 0

				break;
			}
			default:
				break;
		}
	}

	return 0;
}


CH_IMPLEMENT_MESSAGE_HANDLER( mazeLoadErrorHandler )
{
	ChLoadErrorMsg*		pMsg = (ChLoadErrorMsg*)&msg;
	string				strModuleName;
	ChModuleID			idModule;
	string				strURL;
	string				strError;
	chint32				lError;
	chparam				userData;
	ChMazeMainInfo*		pInfo = (ChMazeMainInfo*)pMainInfo;

	pMsg->GetParams( strModuleName, idModule, strURL, lError, userData, strError );
	ChGraphicHTTPReq *pHTTPReq	 = (ChGraphicHTTPReq *)userData;

	// Send to trace window

	ChGraphicHTTPReq::type eType = pHTTPReq->GetType();

	string strType;
	if(eType == ChGraphicHTTPReq::texture)
	{
		strType = "texture file ";

	}
	else if(eType == ChGraphicHTTPReq::wwwInline)
	{
		strType = "WWWInline ";
		((ChQvWWWInlineRenderData*)(((ChMazeInlineHTTPReq*)pHTTPReq)->GetInlineNode()->GetRenderData()))->SetReq(0);
	}

	string strMsg;
	if(strError.IsEmpty())
	{
		strMsg.Format("URL load for %s%s failed: Error number %ld\n", LPCTSTR(strType), LPCTSTR(strURL), lError);
	}
	else
	{
		strMsg.Format("URL load for %s%s failed: %s\n", LPCTSTR(strType), LPCTSTR(strURL), LPCTSTR(strError));
	}																	 
	pInfo->GetCore()->Trace( strMsg, ChCore::traceErrors, true );
											// Clean up
	if (pInfo->GetLeafDependent() == pHTTPReq)
	{
		pInfo->SetLeafDependent( 0 );
	}
	delete pHTTPReq;
	return 0;
}


CH_IMPLEMENT_MESSAGE_HANDLER( mazeLoadSceneHandler )
{
	ChMazeMainInfo*	pInfo = (ChMazeMainInfo*)pMainInfo;
	ChSceneMsg *pMsg = (ChSceneMsg *)&msg;

	string strURL, strFilename, strType;
	bool	boolNew;
	chparam data;
	pInfo->SetupPositionNotification("");		// New scene, reset notification
	pMsg->GetParams(strURL, strFilename, strType, boolNew, data);

	//if(!strFilename.IsEmpty())
	{
								 		// Load a file of vrml
		pInfo->GetView()->LoadScene( strURL, strFilename, data );
	}
	return 0;
}

CH_IMPLEMENT_MESSAGE_HANDLER( mazeImageHookHandler )
{
	ChMazeMainInfo*	pInfo = (ChMazeMainInfo*)pMainInfo;

	ChInlineMsg *pMsg = (ChInlineMsg *)&msg;
	string strArgs;
	pMsg->GetParams(strArgs);
				  //xch_graph="load" href="http://www.chaco.com/pueblo/0.6/ChAnim/msw32/pueblo.wrl>"
				  // xch_module="load" xch_module_name="Chaco VRML Module" xch_module_name_base="ChGraphx">
				//	  xch_graph="load" href="http://www.chaco.com/pueblo/0.6/ChAnim/msw32/pueblo.wrl>
				//	  xch_graph="light 1 .5">
	string strValue;
											// Respond to hooked img messages

	if (ChHtmlWnd::GetHTMLAttribute( strArgs, CH_GRAPH_CMD, strValue ) ||
		ChHtmlWnd::GetHTMLAttribute( strArgs, CH_GRAPH_CMD_NODE, strValue ) ||
		ChHtmlWnd::GetHTMLAttribute( strArgs, CH_EVENT_NOTIFY, strValue ))
	{								// Do it
		pInfo->DoCommand( strArgs );
	}

	return 0;
}


#if !defined( CH_PUEBLO_PLUGIN )

CH_IMPLEMENT_MESSAGE_HANDLER( mazeGetPageCountHandler )
{
	ChMazeMainInfo*		pInfo = (ChMazeMainInfo*)pMainInfo;
	ChGetPageCountMsg*	pMsg = (ChGetPageCountMsg*)&msg;
	ChPageType			type;
	int					iPageCount;

	pMsg->GetParams( type );

	switch( type )
	{
		case pagePreferences:
		{
			iPageCount = 1;
			break;
		}

		default:
		{
			iPageCount = 0;
			break;
		}
	}

	return iPageCount;
}


CH_IMPLEMENT_MESSAGE_HANDLER( mazeGetPagesHandler )
{
	ChMazeMainInfo*		pInfo = (ChMazeMainInfo*)pMainInfo;
	ChGetPagesMsg*		pMsg = (ChGetPagesMsg*)&msg;
	ChPageType			type;
	chint16				sCount;
	chparam*			pPages;

	pMsg->GetParams( type, sCount, pPages );

	switch( type )
	{
		case pagePreferences:
		{
			ASSERT( 1 == sCount );

			#if defined( CH_MSW )
			{
				ChVrmlSettings *pSettings = pInfo->GetSettings();

				#if (defined(CH_USE_RLAB) || defined(CH_USE_D3D))
				ChMazeRlabPrefPage*		pPage;
				pPage = new ChMazeRlabPrefPage;
				ASSERT( pPage );

				pPage->SetInitialPreferences( 	pSettings->GetAsciiTextQuality(),
												pSettings->GetCollisionAlarm(),
												pSettings->GetMoveVector(),
												pSettings->GetHeadlightBrightness() );

				#else

				ChMazePrefPage*		pPage;
				pPage = new ChMazePrefPage;
				ASSERT( pPage );

				pPage->SetInitialPreferences( pSettings->GetRenderQuality(),
												pSettings->GetMoveRenderQuality(),
												pSettings->GetMoveVector(),
												pSettings->GetScaleTextures(),
												pSettings->GetHeadlightBrightness() );
				#endif

				pPages[0] = (chparam)pPage;
			}
			#endif
			break;
		}

		default:
		{
			break;
		}
	}

	return 0;
}


CH_IMPLEMENT_MESSAGE_HANDLER( mazeGetPageDataHandler )
{
	ChMazeMainInfo*		pInfo = (ChMazeMainInfo*)pMainInfo;
	ChGetPageDataMsg*	pMsg = (ChGetPageDataMsg*)&msg;
	ChPageType			type;
	chint16				sCount;
	chparam*			pPages;

	pMsg->GetParams( type, sCount, pPages );

	switch( type )
	{
		case pagePreferences:
		{
			ASSERT( 1 == sCount );

			#if defined( CH_MSW )
			{
				if (pPages[0])
				{
					#if (defined(CH_USE_RLAB) || defined(CH_USE_D3D))
					ChMazeRlabPrefPage*	pPage = (ChMazeRlabPrefPage*)pPages[0];
					#else
					ChMazePrefPage*	pPage = (ChMazePrefPage*)pPages[0];
					#endif

					pPage->OnCommit();
											/*  Update your render level */

					pInfo->UpdatePreferences( pPage->GetMovingVector(),
												pPage->GetScaleTextures(),
												pPage->GetRenderLevel(),
												pPage->GetMoveRenderLevel(),
												pPage->GetHeadlightBrightness(),
												#if (defined(CH_USE_RLAB) || defined(CH_USE_D3D))
												pPage->GetAsciiTextQuality(),
												pPage->GetCollisionAlarm()
												#else
												1
												#endif
												 );
				}
			}
			#endif	// defined( CH_MSW )
			break;
		}

		default:
		{
			break;
		}
	}

	return 0;
}


CH_IMPLEMENT_MESSAGE_HANDLER( mazeReleasePagesHandler )
{
	ChReleasePagesMsg*	pMsg = (ChReleasePagesMsg*)&msg;
	ChPageType			type;
	chint16				sCount;
	chparam*			pPages;

	pMsg->GetParams( type, sCount, pPages );

	switch( type )
	{
		case pagePreferences:
		{
			ASSERT( 1 == sCount );

			#if defined( CH_MSW )
			{
				if (pPages[0])
				{
					ChMazePrefPage*	pPage = (ChMazePrefPage*)pPages[0];

					delete pPage;
				}
			}
			#endif	// defined( CH_MSW )
			break;
		}

		default:
		{
			break;
		}
	}

	return 0;
}


CH_IMPLEMENT_MESSAGE_HANDLER( mazePlayGraphicHandler )
{
	ChMazeMainInfo*		pInfo = (ChMazeMainInfo*)pMainInfo;
	ChPlayGraphicMsg*		pMsg = (ChPlayGraphicMsg*)&msg;
	chuint32				luId = 0;
	bool					boolPlay = true;
	ChPlayGraphicMsg::type	when;

	pMsg->GetParams( luId, boolPlay, when );
	// Ignores everything but boolPlay
	if (!luId)
	{
		pInfo->GetView()->GetRenderContext()->Animate( boolPlay );
		if(boolPlay) pInfo->GetView()->GetRenderContext()->SetDirty();	// won't start unless dirty
	}

	return 0;
}
#endif // #if !defined( CH_PUEBLO_PLUGIN )



/*----------------------------------------------------------------------------
	Chaco menu handlers
----------------------------------------------------------------------------*/

CH_IMPLEMENT_MESSAGE_HANDLER( graphicsViewMenuHandler )
{
	chparam		retVal = 0;

	return retVal;
}

⌨️ 快捷键说明

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