Ejemplo n.º 1
0
/*
================
VGui_Startup

Load vgui_support library and call VGui_Startup
================
*/
void VGui_Startup( int width, int height )
{
	if(!vgui.initialized)
	{
		void (*F) (vguiapi_t *);
		lib = Com_LoadLibrary(host.vguiloader, false);
		if(!lib)
			MsgDev(D_ERROR, "Failed to load vgui_support library!\n");
		else
		{
			F = Com_GetProcAddress(lib, "InitAPI");
			if(F)
			{
				F(&vgui);
				vgui.initialized = true;
			}
			else
				MsgDev(D_ERROR, "Failed to find vgui_support library entry point!\n");
		}
		VGUI_InitCursors();
	}
	if (vgui.initialized)
	{
		//host.mouse_visible = true;
		vgui.Startup(width, height);
	}
}
Ejemplo n.º 2
0
/*
================
VGui_Shutdown

Unload vgui_support library and call VGui_Shutdown
================
*/
void VGui_Shutdown( void )
{
	if( vgui.Shutdown) 
		vgui.Shutdown();
	if(lib)
		Com_FreeLibrary(lib);
	vgui.initialized = false;
}
Ejemplo n.º 3
0
void VGUI_SurfaceWndProc( Xash_Event *event )
{
#ifdef XASH_SDL
/* When false returned, event passed to engine, else only to vgui*/
/* NOTE: this disabled because VGUI shows its cursor on engine start*/
	if( !vgui.initialized )
		return /*false*/;

	switch( event->type )
	{
	/*case :
		VGUI_ActivateCurrentCursor();
		break;*/
	case SDL_MOUSEMOTION:
		vgui.MouseMove(event->motion.x, event->motion.y);
		//return false;
		break;
	case SDL_MOUSEBUTTONDOWN:
		//if(event->button.clicks == 1)
		vgui.Mouse(MA_PRESSED, VGUI_MapMouseButton(event->button.button));
	//	else
	//	vgui.Mouse(MA_DOUBLE, VGUI_MapMouseButton(event->button.button));
		//return true;
		break;
	case SDL_MOUSEBUTTONUP:
		vgui.Mouse(MA_RELEASED, VGUI_MapMouseButton(event->button.button));
		//return true;
		break;
	case SDL_MOUSEWHEEL:
		vgui.Mouse(MA_WHEEL, event->wheel.y);
		//return true;
		break;
	case SDL_KEYDOWN:
		if(!( event->key.keysym.sym & ( 1 << 30 )))
			vgui.Key( KA_PRESSED, VGUI_MapKey( event->key.keysym.sym ));
		vgui.Key( KA_TYPED, VGUI_MapKey( event->key.keysym.sym ));
		//return false;
		break;
	case SDL_KEYUP:
		vgui.Key( KA_RELEASED, VGUI_MapKey( event->key.keysym.sym ) );
		//return false;
		break;
	}
	
#endif
	//return false;
}
Ejemplo n.º 4
0
void *VGui_GetPanel()
{
	if( vgui.initialized )
		return vgui.GetPanel();
	return NULL;
}
Ejemplo n.º 5
0
void VGui_Paint()
{
	if(vgui.initialized)
		vgui.Paint();
}
Ejemplo n.º 6
0
/*
================
VGui_Startup

Load vgui_support library and call VGui_Startup
================
*/
void VGui_Startup( int width, int height )
{
	static qboolean failed = false;
	if( failed )
		return;
	if(!vgui.initialized)
	{
		void (*F) ( vguiapi_t * );
		char vguiloader[256];
		char vguilib[256];

		Com_ResetLibraryError();

		// hack: load vgui with correct path first if specified.
		// it will be reused while resolving vgui support and client deps
		if( Sys_GetParmFromCmdLine( "-vguilib", vguilib ) )
		{
			if( Q_strstr( vguilib, ".dll") )
				Q_strncpy( vguiloader, "vgui_support.dll", 256 );
			else
				Q_strncpy( vguiloader, VGUI_SUPPORT_DLL, 256 );
			if( !Com_LoadLibrary( vguilib, false ) )
				MsgDev( D_WARN, "VGUI preloading failed. Default library will be used!\n");
		}

		if( !Sys_GetParmFromCmdLine( "-vguiloader", vguiloader ) )
			Q_strncpy( vguiloader, VGUI_SUPPORT_DLL, 256 );

		lib = Com_LoadLibrary( vguiloader, false );
		if(!lib)
			MsgDev( D_ERROR, "Failed to load vgui_support library: %s", Com_GetLibraryError() );
		else
		{
			F = Com_GetProcAddress( lib, "InitAPI" );
			if( F )
			{
				F( &vgui );
				vgui.initialized = true;
				VGUI_InitCursors();
			}
			else
				MsgDev( D_ERROR, "Failed to find vgui_support library entry point!\n" );
		}

	}

	// vgui may crash if it cannot find font
	if( width <= 320 )
		width = 320;
	else if( width <= 400 )
		width = 400;
	else if( width <= 512 )
		width = 512;
	else if( width <= 640 )
		width = 640;
	else if( width <= 800 )
		width = 800;
	else if( width <= 1024 )
		width = 1024;
	else if( width <= 1152 )
		width = 1152;
	else if( width <= 1280 )
		width = 1280;
	else //if( width <= 1600 )
		width = 1600;


	if( vgui.initialized )
	{
		//host.mouse_visible = true;
		vgui.Startup( width, height );
	}
	else failed = true;
}