示例#1
0
void idUserInterfaceManagerLocal::Init() {
	screenRect = idRectangle(0, 0, 640, 480);
	dc.Init();

	// TODO:  eviljoel:  Determine if the GUI patch will also work for the Demo and RoE
	// TODO:  eviljoel:  Make this look neater by using an array of CStrings
	idStrList* os2PrimaryPatchPaths = new idStrList( 1 );
	idStr* os2PrimaryPatch = new idStr( "guis/mainmenu-os2primary.guipatch" );
	os2PrimaryPatchPaths->Append( *os2PrimaryPatch );
	guiToPatchFilesMap.Set( "guis/mainmenu.gui", os2PrimaryPatchPaths );
}
示例#2
0
/*
================
rvGESelectionMgr::HitTest

Test to see if the given coordinate is within the selection rectangle and if it is
see what its over.
================
*/
rvGESelectionMgr::EHitTest rvGESelectionMgr::HitTest ( float x, float y )
{
	if ( !mSelections.Num ( ) )
	{
		return HT_NONE;
	}

	UpdateRectangle ( );

	// Inside the rectangle is moving
	if ( mRect.Contains ( x, y ) )
	{
		return mExpression?HT_SELECT:HT_MOVE;
	}

	if ( mExpression )
	{
		return HT_NONE;
	}

	// Check for top left sizing
	if ( idRectangle ( mRect.x - GUIED_GRABSIZE, mRect.y - GUIED_GRABSIZE, GUIED_GRABSIZE, GUIED_GRABSIZE ).Contains ( x, y ) )
	{
		return HT_SIZE_TOPLEFT;
	}

	// Check for left sizing
	if ( idRectangle ( mRect.x - GUIED_GRABSIZE, mRect.y + mRect.h / 2 - GUIED_GRABSIZE / 2, GUIED_GRABSIZE, GUIED_GRABSIZE ).Contains ( x, y ) )
	{
		return HT_SIZE_LEFT;
	}

	// Check for bottom left sizing
	if ( idRectangle ( mRect.x - GUIED_GRABSIZE, mRect.y + mRect.h, GUIED_GRABSIZE, GUIED_GRABSIZE ).Contains ( x, y ) )
	{
		return HT_SIZE_BOTTOMLEFT;
	}

	// Check for bottom sizing
	if ( idRectangle ( mRect.x + mRect.w / 2 - GUIED_GRABSIZE / 2, mRect.y + mRect.h, GUIED_GRABSIZE, GUIED_GRABSIZE ).Contains ( x, y ) )
	{
		return HT_SIZE_BOTTOM;
	}

	// Check for bottom right sizing
	if ( idRectangle ( mRect.x + mRect.w, mRect.y + mRect.h, GUIED_GRABSIZE, GUIED_GRABSIZE ).Contains ( x, y ) )
	{
		return HT_SIZE_BOTTOMRIGHT;
	}

	// Check for right sizing
	if ( idRectangle ( mRect.x + mRect.w, mRect.y + mRect.h / 2 - GUIED_GRABSIZE / 2, GUIED_GRABSIZE, GUIED_GRABSIZE ).Contains ( x, y ) )
	{
		return HT_SIZE_RIGHT;
	}

	// Check for top right sizing
	if ( idRectangle ( mRect.x + mRect.w, mRect.y - GUIED_GRABSIZE, GUIED_GRABSIZE, GUIED_GRABSIZE ).Contains ( x, y ) )
	{
		return HT_SIZE_TOPRIGHT;
	}

	// Check for top sizing
	if ( idRectangle ( mRect.x + mRect.w / 2 - GUIED_GRABSIZE / 2, mRect.y - GUIED_GRABSIZE, GUIED_GRABSIZE, GUIED_GRABSIZE ).Contains ( x, y ) )
	{
		return HT_SIZE_TOP;
	}

	return HT_NONE;
}
示例#3
0
void idUserInterfaceManagerLocal::Init() {
	screenRect = idRectangle(0, 0, 640, 480);
	dc.Init();
}
示例#4
0
bool idUserInterfaceLocal::InitFromFile( const char *qpath, bool rebuild, bool cache ) { 

	if ( !( qpath && *qpath ) ) { 
		// FIXME: Memory leak!!
		return false;
	}

	int sz = sizeof( idWindow );
	sz = sizeof( idSimpleWindow );
	loading = true;

	if ( rebuild ) {
		delete desktop;
		desktop = new idWindow( this );
	} else if ( desktop == NULL ) {
		desktop = new idWindow( this );
	}

	source = qpath;
	state.Set( "text", "Test Text!" );

	idParser src( LEXFL_NOFATALERRORS | LEXFL_NOSTRINGCONCAT | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_ALLOWBACKSLASHSTRINGCONCAT );

	//Load the timestamp so reload guis will work correctly
	fileSystem->ReadFile(qpath, NULL, &timeStamp);

	src.LoadFile( qpath );

	if ( src.IsLoaded() ) {
		idToken token;
		while( src.ReadToken( &token ) ) {
			if ( idStr::Icmp( token, "windowDef" ) == 0 ) {
				desktop->SetDC( &uiManagerLocal.dc );
				if ( desktop->Parse( &src, rebuild ) ) {
					desktop->SetFlag( WIN_DESKTOP );
					desktop->FixupParms();
				}
				continue;
			}
		}

		state.Set( "name", qpath );
	} else {
		desktop->SetDC( &uiManagerLocal.dc );
		desktop->SetFlag( WIN_DESKTOP );
		desktop->name = "Desktop";
		desktop->text = va( "Invalid GUI: %s", qpath );
		desktop->rect = idRectangle( 0.0f, 0.0f, 640.0f, 480.0f );
		desktop->drawRect = desktop->rect;
		desktop->foreColor = idVec4( 1.0f, 1.0f, 1.0f, 1.0f );
		desktop->backColor = idVec4( 0.0f, 0.0f, 0.0f, 1.0f );
		desktop->SetupFromState();
		common->Warning( "Couldn't load gui: '%s'", qpath );
	}

	interactive = desktop->Interactive();

	if ( uiManagerLocal.guis.Find( this ) == NULL ) {
		uiManagerLocal.guis.Append( this );
	}

	loading = false;

	return true; 
}
示例#5
0
bool idUserInterfaceLocal::InitFromFile( const char *qpath, bool rebuild, bool cache ) {
	if ( !( qpath && *qpath ) ) { 
		// FIXME: Memory leak!!
		return false;
	}


	idHashTable<idParser*> sourcePatchMap;
	InitPatchFiles( qpath, sourcePatchMap );

	loading = true;

	if ( rebuild ) {
		delete desktop;
		desktop = new idWindow( this );
	} else if ( desktop == NULL ) {
		desktop = new idWindow( this );
	}

	source = qpath;

	idParser src( LEXFL_NOFATALERRORS | LEXFL_NOSTRINGCONCAT | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_ALLOWBACKSLASHSTRINGCONCAT );

	//Load the timestamp so reload guis will work correctly
	fileSystem->ReadFile(qpath, NULL, &timeStamp);

	src.LoadFile( qpath );

	if ( src.IsLoaded() ) {
		idToken token;
		while( src.ReadToken( &token ) ) {
			if ( idStr::Icmp( token, "windowDef" ) == 0 ) {

				idParser* originalSource = NULL;

				// Read the window identifier
				idToken windowName;
				src.ExpectTokenType( TT_NAME, 0, &windowName );
				idParser* source = &src;

				// See if there is a patch for the whole Window
				idParser** sourcePatch;
				if ( sourcePatchMap.Get( windowName, &sourcePatch ) ) {

					// Save the current source
					originalSource = source;

					// Replace the current source with the source from the patch.
					source = *sourcePatch;

					// We already know this defines an idWindow, so don't bother to validate
					source->ExpectAnyToken( &token );

					// The root Window is hard coded as a windowDef.  Make sure the patch is for the same.
					if ( idStr::Icmp( token, "windowDef" ) == 0 ) {

						// Skip the rest of this Window and ignore it.
						// OPTIONAL:  We might want to go back later and and parse this for the window names so
						//   we can explicitly include text from some sections.  We'll implement this change is it
						//   is demanded.
						// Original file must be properly formatted.
						if ( originalSource->SkipBracedSection() ) {

							// Can't reuse source patches
							sourcePatchMap.Remove( windowName );

							source->ExpectTokenType( TT_NAME, 0, &windowName );
						}

					} else {
						common->Warning( "The root window must be a windowDef.  Ignoring patch for '%s'.", windowName.c_str() );
						(*sourcePatch)->UnreadToken( &token );
					}
				}

				desktop->SetDC( &uiManagerLocal.dc );
				if ( desktop->Parse( source, sourcePatchMap, windowName, rebuild ) ) {
					desktop->SetFlag( WIN_DESKTOP );
					desktop->FixupParms();
				}

				// The original source was saved off.  Restore it.
				if ( originalSource != NULL ) {

					// Can't reuse source patches
					delete source;

					source = originalSource;
				}
				continue;
			}
		}

		state.Set( "name", qpath );
	} else {
		desktop->SetDC( &uiManagerLocal.dc );
		desktop->SetFlag( WIN_DESKTOP );
		desktop->name = "Desktop";
		desktop->text = va( "Invalid GUI: %s", qpath );
		desktop->rect = idRectangle( 0.0f, 0.0f, 640.0f, 480.0f );
		desktop->drawRect = desktop->rect;
		desktop->foreColor = idVec4( 1.0f, 1.0f, 1.0f, 1.0f );
		desktop->backColor = idVec4( 0.0f, 0.0f, 0.0f, 1.0f );
		desktop->SetupFromState();
		common->Warning( "Couldn't load gui: '%s'", qpath );
	}

	interactive = desktop->Interactive();

	if ( uiManagerLocal.guis.Find( this ) == NULL ) {
		uiManagerLocal.guis.Append( this );
	}

	loading = false;

	DeletePatchData( sourcePatchMap );

	return true; 
}