コード例 #1
0
ファイル: basemenu.cpp プロジェクト: DavidKnight247/xash3d
static void UI_LoadBackgroundMapList( void )
{
	if( !g_engfuncs.pfnFileExists( "scripts/chapterbackgrounds.txt", TRUE ))
		return;

	char *afile = (char *)LOAD_FILE( "scripts/chapterbackgrounds.txt", NULL );
	char *pfile = afile;
	char token[1024];

	uiStatic.bgmapcount = 0;

	if( !afile )
	{
		Con_Printf( "UI_LoadBackgroundMapList: chapterbackgrounds.txt not found\n" );
		return;
	}

	while(( pfile = COM_ParseFile( pfile, token )) != NULL )
	{
		// skip the numbers (old format list)
		if( isdigit( token[0] )) continue;

		strncpy( uiStatic.bgmaps[uiStatic.bgmapcount], token, sizeof( uiStatic.bgmaps[0] ));
		if( ++uiStatic.bgmapcount > UI_MAX_BGMAPS )
			break; // list is full
	}

	FREE_FILE( afile );
}
コード例 #2
0
/*
=================
UI_CreateGame_GetMapsList
=================
*/
static void UI_CreateGame_GetMapsList( void )
{
	char *afile;

	if( !CHECK_MAP_LIST( FALSE ) || (afile = (char *)LOAD_FILE( "maps.lst", NULL )) == NULL )
	{
		uiCreateGame.done.generic.flags |= QMF_GRAYED;
		uiCreateGame.mapsList.itemNames = (const char **)uiCreateGame.mapsDescriptionPtr;
		Con_Printf( "Cmd_GetMapsList: can't open maps.lst\n" );
		return;
	}

	char *pfile = afile;
	char token[1024];
	int numMaps = 0;
	
	while(( pfile = COM_ParseFile( pfile, token )) != NULL )
	{
		if( numMaps >= UI_MAXGAMES ) break;
		StringConcat( uiCreateGame.mapName[numMaps], token, sizeof( uiCreateGame.mapName[0] ));
		StringConcat( uiCreateGame.mapsDescription[numMaps], token, MAPNAME_LENGTH );
		StringConcat( uiCreateGame.mapsDescription[numMaps], uiEmptyString, MAPNAME_LENGTH );
		if(( pfile = COM_ParseFile( pfile, token )) == NULL ) break; // unexpected end of file
		StringConcat( uiCreateGame.mapsDescription[numMaps], token, TITLE_LENGTH );
		StringConcat( uiCreateGame.mapsDescription[numMaps], uiEmptyString, TITLE_LENGTH );
		uiCreateGame.mapsDescriptionPtr[numMaps] = uiCreateGame.mapsDescription[numMaps];
		numMaps++;
	}

	if( !numMaps ) uiCreateGame.done.generic.flags |= QMF_GRAYED;

	for( ; numMaps < UI_MAXGAMES; numMaps++ ) uiCreateGame.mapsDescriptionPtr[numMaps] = NULL;
	uiCreateGame.mapsList.itemNames = (const char **)uiCreateGame.mapsDescriptionPtr;
	FREE_FILE( afile );
}
コード例 #3
0
ファイル: basemenu.cpp プロジェクト: DavidKnight247/xash3d
void UI_ApplyCustomColors( void )
{
	char *afile = (char *)LOAD_FILE( "gfx/shell/colors.lst", NULL );
	char *pfile = afile;
	char token[1024];

	if( !afile )
	{
		// not error, not warning, just notify
		Con_Printf( "UI_SetColors: colors.lst not found\n" );
		return;
	}

	while(( pfile = COM_ParseFile( pfile, token )) != NULL )
	{
		if( !stricmp( token, "HELP_COLOR" ))
		{
			UI_ParseColor( pfile, &uiColorHelp );
		}
		else if( !stricmp( token, "PROMPT_BG_COLOR" ))
		{
			UI_ParseColor( pfile, &uiPromptBgColor );
		}
		else if( !stricmp( token, "PROMPT_TEXT_COLOR" ))
		{
			UI_ParseColor( pfile, &uiPromptTextColor );
		}
		else if( !stricmp( token, "PROMPT_FOCUS_COLOR" ))
		{
			UI_ParseColor( pfile, &uiPromptFocusColor );
		}
		else if( !stricmp( token, "INPUT_TEXT_COLOR" ))
		{
			UI_ParseColor( pfile, &uiInputTextColor );
		}
		else if( !stricmp( token, "INPUT_BG_COLOR" ))
		{
			UI_ParseColor( pfile, &uiInputBgColor );
		}
		else if( !stricmp( token, "INPUT_FG_COLOR" ))
		{
			UI_ParseColor( pfile, &uiInputFgColor );
		}
		else if( !stricmp( token, "CON_TEXT_COLOR" ))
		{
			UI_ParseColor( pfile, &uiColorConsole );
		}
	}

	int	r, g, b;

	UnpackRGB( r, g, b, uiColorConsole );
	ConsoleSetColor( r, g, b );

	FREE_FILE( afile );
}
コード例 #4
0
ファイル: codegen.c プロジェクト: jdelgadoalfonso/gputils
static void
codegen_load_file(tree *symbol, struct variable *var)
{
  int offset;
  int element_size;

  if ((symbol->tag == node_symbol) && (SYM_OFST(symbol))) {
    /* access an array */
    element_size = type_size(var->type->prim);

    if ((var) && (var->type) && (var->type->tag == type_array)) {
      if (can_evaluate(SYM_OFST(symbol), false)) {
        /* direct access */
        offset = analyze_check_array(symbol, var) * element_size;
        if (is_far(var)) {
          LOAD_FILE(var->name, codegen_size, offset, true);
        } else {
          LOAD_FILE(var->name, codegen_size, offset, false);
        }
      } else {
        codegen_indirect(SYM_OFST(symbol), var, element_size, false);
        if (is_far(var)) {
          LOAD_INDIRECT(var->name, codegen_size, 0, true);
        } else {
          LOAD_INDIRECT(var->name, codegen_size, 0, false);
        }
      }
    } else {
      analyze_error(symbol, "symbol %s is not an array",
                    SYM_NAME(symbol));
    }
  } else {
    if (is_far(var)) {
      LOAD_FILE(var->name, codegen_size, 0, true);
    } else {
      LOAD_FILE(var->name, codegen_size, 0, false);
    }
  }

  return;
}
コード例 #5
0
ファイル: codegen.c プロジェクト: jdelgadoalfonso/gputils
static void
gen_binop_expr(enum node_op op, tree *p0, tree *p1)
{
  char *reg1 = NULL;
  char *reg2 = NULL;
  struct variable *var;

  gen_expr(p1);

  if (p0->tag == node_call) {
    reg1 = codegen_get_temp(codegen_size);
    STORE_FILE(reg1, codegen_size, 0, false);
    analyze_call(p0, true, codegen_size);    
    CODEGEN(op, codegen_size, false, 0, reg1);
  } else if (p0->tag == node_constant) {
    CODEGEN(op, codegen_size, true, p0->value.constant, NULL);
  } else if (p0->tag == node_symbol) { 
    var = get_global(SYM_NAME(p0));
    if (var->tag == sym_const) {
      CODEGEN(op, codegen_size, true, var->value, NULL);
    } else if (SYM_OFST(p0)) {
      /* it is a complex expression, so save temp data */
      reg1 = codegen_get_temp(codegen_size);
      reg2 = codegen_get_temp(codegen_size);
      STORE_FILE(reg1, codegen_size, 0, false);
      codegen_load_file(p0, var);
      STORE_FILE(reg2, codegen_size, 0, false);
      LOAD_FILE(reg1, codegen_size, 0, false);
      CODEGEN(op, codegen_size, false, 0, reg2);
    } else {
      CODEGEN(op, codegen_size, false, 0, var->name);
    }
  } else {
    /* it is a complex expression so save temp data */
    reg1 = codegen_get_temp(codegen_size);
    STORE_FILE(reg1, codegen_size, 0, false);
    gen_expr(p0);
    CODEGEN(op, codegen_size, false, 0, reg1);
  }

  if (reg1)
    free(reg1);
  if (reg2)
    free(reg2);

}
コード例 #6
0
static void UI_Controls_ResetKeysList( void )
{
	char *afile = (char *)LOAD_FILE( "gfx/shell/kb_def.lst", NULL );
	char *pfile = afile;
	char token[1024];

	if( !afile )
	{
		Con_Printf( "UI_Parse_KeysList: kb_act.lst not found\n" );
		return;
	}

	while(( pfile = COM_ParseFile( pfile, token )) != NULL )
	{
		char	key[32];

		strncpy( key, token, sizeof( key ));

		pfile = COM_ParseFile( pfile, token );
		if( !pfile ) break;	// technically an error

		char	cmd[128];

		if( key[0] == '\\' && key[1] == '\\' )
		{
			key[0] = '\\';
			key[1] = '\0';
		}

		UI_UnbindCommand( token );

		sprintf( cmd, "bind \"%s\" \"%s\"\n", key, token );
		CLIENT_COMMAND( TRUE, cmd );
	}

	FREE_FILE( afile );
	UI_Controls_RestartMenu ();
}
コード例 #7
0
static void UI_Controls_ParseKeysList( void )
{
	char *afile = (char *)LOAD_FILE( "gfx/shell/kb_act.lst", NULL );
	char *pfile = afile;
	char token[1024];
	int i = 0;

	if( !afile )
	{
		for( ; i < MAX_KEYS; i++ ) uiControls.keysDescriptionPtr[i] = NULL;
		uiControls.keysList.itemNames = (const char **)uiControls.keysDescriptionPtr;
	
		Con_Printf( "UI_Parse_KeysList: kb_act.lst not found\n" );
		return;
	}

	while(( pfile = COM_ParseFile( pfile, token )) != NULL )
	{
		char	str[128];

		if( !stricmp( token, "blank" ))
		{
			// seperator
			pfile = COM_ParseFile( pfile, token );
			if( !pfile ) break;	// technically an error

			sprintf( str, "^6%s^7", token );	// enable uiPromptTextColor
			StringConcat( uiControls.keysDescription[i], str, strlen( str ) + 1 );
			StringConcat( uiControls.keysDescription[i], uiEmptyString, 256 );	// empty
			uiControls.keysDescriptionPtr[i] = uiControls.keysDescription[i];
			strcpy( uiControls.keysBind[i], "" );
			strcpy( uiControls.firstKey[i], "" );
			strcpy( uiControls.secondKey[i], "" );
			i++;
		}
		else
		{
			// key definition
			int	keys[2];

			UI_Controls_GetKeyBindings( token, keys );
			strncpy( uiControls.keysBind[i], token, sizeof( uiControls.keysBind[i] ));

			pfile = COM_ParseFile( pfile, token );
			if( !pfile ) break; // technically an error

			sprintf( str, "^6%s^7", token );	// enable uiPromptTextColor

			if( keys[0] == -1 ) strcpy( uiControls.firstKey[i], "" );
			else strncpy( uiControls.firstKey[i], KEY_KeynumToString( keys[0] ), sizeof( uiControls.firstKey[i] ));

			if( keys[1] == -1 ) strcpy( uiControls.secondKey[i], "" ); 
			else strncpy( uiControls.secondKey[i], KEY_KeynumToString( keys[1] ), sizeof( uiControls.secondKey[i] ));

			StringConcat( uiControls.keysDescription[i], str, CMD_LENGTH );
			StringConcat( uiControls.keysDescription[i], uiEmptyString, CMD_LENGTH );

			// HACKHACK this color should be get from kb_keys.lst
			if( !strnicmp( uiControls.firstKey[i], "MOUSE", 5 ))
				sprintf( str, "^5%s^7", uiControls.firstKey[i] );	// cyan
			else sprintf( str, "^3%s^7", uiControls.firstKey[i] );	// yellow
			StringConcat( uiControls.keysDescription[i], str, KEY1_LENGTH );
			StringConcat( uiControls.keysDescription[i], uiEmptyString, KEY1_LENGTH );

			// HACKHACK this color should be get from kb_keys.lst
			if( !strnicmp( uiControls.secondKey[i], "MOUSE", 5 ))
				sprintf( str, "^5%s^7", uiControls.secondKey[i] );// cyan
			else sprintf( str, "^3%s^7", uiControls.secondKey[i] );	// yellow

			StringConcat( uiControls.keysDescription[i], str, KEY2_LENGTH );
			StringConcat( uiControls.keysDescription[i], uiEmptyString, KEY2_LENGTH );
			uiControls.keysDescriptionPtr[i] = uiControls.keysDescription[i];
			i++;
		}
	}

	FREE_FILE( afile );

	for( ; i < MAX_KEYS; i++ ) uiControls.keysDescriptionPtr[i] = NULL;
	uiControls.keysList.itemNames = (const char **)uiControls.keysDescriptionPtr;
}
コード例 #8
0
ファイル: menu_btns.cpp プロジェクト: Xash3DLinux/xash3dlinux
/*
=================
UI_LoadBmpButtons
=================
*/
void UI_LoadBmpButtons( void )
{
	memset( uiStatic.buttonsPics, 0, sizeof( uiStatic.buttonsPics ));

	int bmp_len_holder;
	byte *bmp_buffer = LOAD_FILE( ART_BUTTONS_MAIN, &bmp_len_holder );

	if( !bmp_buffer || !bmp_len_holder )
	{
		Con_Printf( "UI_LoadBmpButtons: btns_main.bmp not found\n" );
		return;
	}

	BITMAPINFOHEADER *pInfoHdr;
	bmphdr_t *pHdr;

	pInfoHdr =(BITMAPINFOHEADER *)&bmp_buffer[sizeof(bmphdr_t)];
	pHdr = (bmphdr_t*)bmp_buffer;

	BITMAPINFOHEADER CuttedDibHdr;
	bmphdr_t CuttedHdr;

	memcpy( &CuttedHdr, pHdr, sizeof( bmphdr_t ));
	memcpy( &CuttedDibHdr, pInfoHdr, pInfoHdr->biSize );

	int pallete_sz = pHdr->bmp_offset - sizeof( bmphdr_t ) - pInfoHdr->biSize;

	uiStatic.buttons_height = ( pInfoHdr->biBitCount == 4 ) ? 80 : 78; // bugstompers issues
	uiStatic.buttons_width = pInfoHdr->biWidth - 3; // make some offset

	int stride = (pInfoHdr->biWidth * pInfoHdr->biBitCount / 8);
	int cutted_img_sz = ((stride + 3 ) & ~3) * uiStatic.buttons_height;
	int CuttedBmpSize = sizeof( bmphdr_t ) + pInfoHdr->biSize + pallete_sz + cutted_img_sz;
	byte *img_data = &bmp_buffer[bmp_len_holder-cutted_img_sz];

	if ( pInfoHdr->biBitCount <= 8 )
	{
		byte* pallete=&bmp_buffer[sizeof( bmphdr_t ) + pInfoHdr->biSize];
		byte* firstpixel_col=&pallete[img_data[0]*4];
		firstpixel_col[0]=firstpixel_col[1]=firstpixel_col[2]=0;
	}

	CuttedDibHdr.biHeight = 78;	//uiStatic.buttons_height;
	CuttedHdr.filesz = CuttedBmpSize;
	CuttedDibHdr.biSizeImage = CuttedBmpSize - CuttedHdr.bmp_offset;

	char fname[256];
	byte *raw_img_buff = (byte *)MALLOC( sizeof( bmphdr_t ) + pInfoHdr->biSize + pallete_sz + cutted_img_sz );

	// determine buttons count by image height...
//	int pic_count = ( pInfoHdr->biHeight == 5538 ) ? PC_BUTTONCOUNT : PC_BUTTONCOUNT - 2;
	int pic_count = ( pInfoHdr->biHeight / 78 );
	
	for( int i = 0; i < pic_count; i++ )
	{
		sprintf( fname, "#btns_%d.bmp", i );

		int offset = 0;
		memcpy( &raw_img_buff[offset], &CuttedHdr, sizeof( bmphdr_t ));
		offset += sizeof( bmphdr_t );

		memcpy( &raw_img_buff[offset], &CuttedDibHdr, CuttedDibHdr.biSize );
		offset += CuttedDibHdr.biSize;

		if( CuttedDibHdr.biBitCount <= 8 )
		{
 			memcpy( &raw_img_buff[offset], &bmp_buffer[offset], pallete_sz );
 			offset += pallete_sz;
		}
		
		memcpy( &raw_img_buff[offset], img_data, cutted_img_sz );

		// upload image into viedo memory
		uiStatic.buttonsPics[i] = PIC_Load( fname, raw_img_buff, CuttedBmpSize );

		img_data -= cutted_img_sz;
	}

	FREE( raw_img_buff );
	FREE_FILE( bmp_buffer );
}
コード例 #9
0
/*
=================
UI_Credits_Init
=================
*/
static void UI_Credits_Init( void )
{
	uiCredits.menu.drawFunc = UI_Credits_DrawFunc;
	uiCredits.menu.keyFunc = UI_Credits_KeyFunc;

	if( !uiCredits.buffer )
	{
		int	count;
		char	*p;

		// load credits if needed
		uiCredits.buffer = (char *)LOAD_FILE( UI_CREDITS_PATH, &count );
		if( count )
		{
			if( uiCredits.buffer[count - 1] != '\n' && uiCredits.buffer[count - 1] != '\r' )
			{
				char *tmp = (char *)MALLOC( count + 2 );
				memcpy( tmp, uiCredits.buffer, count ); 
				FREE_FILE( uiCredits.buffer );
				uiCredits.buffer = tmp; 
				strncpy( uiCredits.buffer + count, "\r", 1 ); // add terminator
				count += 2; // added "\r\0"
                    	}
			p = uiCredits.buffer;

			// convert customs credits to 'ideal' strings array
			for ( uiCredits.numLines = 0; uiCredits.numLines < UI_CREDITS_MAXLINES; uiCredits.numLines++ )
			{
				uiCredits.index[uiCredits.numLines] = p;
				while ( *p != '\r' && *p != '\n' )
				{
					p++;
					if ( --count == 0 )
						break;
				}

				if ( *p == '\r' )
				{
					*p++ = 0;
					if( --count == 0 ) break;
				}

				*p++ = 0;
				if( --count == 0 ) break;
			}
			uiCredits.index[++uiCredits.numLines] = 0;
			uiCredits.credits = (const char **)uiCredits.index;
		}
		else
		{
			// use built-in credits
			uiCredits.credits =  uiCreditsDefault;
			uiCredits.numLines = ( sizeof( uiCreditsDefault ) / sizeof( uiCreditsDefault[0] )) - 1; // skip term
		}
	}

	// run credits
	uiCredits.startTime = (gpGlobals->time * 1000) + 500; // make half-seconds delay
	uiCredits.showTime = bound( 1000, strlen( uiCredits.credits[uiCredits.numLines - 1]) * 1000, 10000 );
	uiCredits.fadeTime = 0; // will be determined later
	uiCredits.active = true;
}
コード例 #10
0
ファイル: aurora.cpp プロジェクト: a1batross/Xash3D_ancient
ParticleSystem::ParticleSystem( int iEntIndex, char *szFilename )
{
	int iParticles = 100; // default

	m_iEntIndex = iEntIndex;
	m_pNextSystem = NULL;
	m_pFirstType = NULL;

	if ( !c_bCosTableInit )
	{
		for ( int i = 0; i < 360 + 90; i++ )
		{
			c_fCosTable[i] = cos( i * M_PI / 180.0 );
		}
		c_bCosTableInit = true;
	}

	const char *memFile;
	const char *szFile = (char *)LOAD_FILE( szFilename, NULL );
	char *szToken;

	if( !szFile )
	{
		ALERT( at_error, "particle %s not found.\n", szFilename );
		return;
	}
	else
	{
		memFile = szFile;		
		szToken = COM_ParseToken( &szFile );

		while ( szToken )
		{
			if ( !stricmp( szToken, "particles" ) )
			{
				szToken = COM_ParseToken( &szFile );
				iParticles = atof(szToken);
			}
			else if ( !stricmp( szToken, "maintype" ) )
			{
				szToken = COM_ParseToken( &szFile );
				m_pMainType = AddPlaceholderType(szToken);
			}
			else if ( !stricmp( szToken, "attachment" ) )
			{
				szToken = COM_ParseToken( &szFile );
				m_iEntAttachment = atof(szToken);
			}
			else if ( !stricmp( szToken, "killcondition" ) )
			{
				szToken = COM_ParseToken( &szFile );
				if ( !stricmp( szToken, "empty" ) )
				{
					m_iKillCondition = CONTENTS_EMPTY;
				}
				else if ( !stricmp( szToken, "water" ) )
				{
					m_iKillCondition = CONTENTS_WATER;
				}
				else if ( !stricmp( szToken, "solid" ) )
				{
					m_iKillCondition = CONTENTS_SOLID;
				}
			}
			else if ( !stricmp( szToken, "{" ) )
			{
				// parse new type
				this->ParseType( &szFile ); // parses the type, moves the file pointer
			}

			szToken = COM_ParseToken( &szFile );
		}
	}
		
	FREE_FILE( (void *)memFile );
	AllocateParticles( iParticles );
}
コード例 #11
0
ファイル: menu_btns.cpp プロジェクト: Fograin/hl-subsmod-ex
/*
=================
UI_LoadBmpButtons
=================
*/
void UI_LoadBmpButtons( void )
{
	memset( uiStatic.buttonsPics, 0, sizeof( uiStatic.buttonsPics ));

	int bmp_filesize;
	byte *bmp_buffer = LOAD_FILE( ART_BUTTONS_MAIN, &bmp_filesize );

	if( !bmp_buffer || !bmp_filesize )
	{
		Con_Printf( "UI_LoadBmpButtons: btns_main.bmp not found\n" );
		return;
	}

	BITMAPFILEHEADER *pFileHdr = (BITMAPFILEHEADER *)bmp_buffer;
	BITMAPINFOHEADER *pInfoHdr = (BITMAPINFOHEADER *)&bmp_buffer[sizeof( BITMAPFILEHEADER )];

	BITMAPINFOHEADER NewInfoHdr;
	BITMAPFILEHEADER NewFileHdr;

	if( pInfoHdr->biBitCount == 8 && pInfoHdr->biClrUsed == 0 )
		pInfoHdr->biClrUsed = 256; // all colors used

	memcpy( &NewFileHdr, pFileHdr, sizeof( BITMAPFILEHEADER ));
	memcpy( &NewInfoHdr, pInfoHdr, sizeof( BITMAPINFOHEADER ));

	byte *palette = bmp_buffer + sizeof( BITMAPFILEHEADER ) + sizeof( BITMAPINFOHEADER );
	int palette_sz = pInfoHdr->biClrUsed * sizeof( RGBQUAD );
	uiStatic.buttons_width = pInfoHdr->biWidth;
	uiStatic.buttons_height = 78;	// fixed height

	// determine buttons count by image height...
	int pic_count = ( pInfoHdr->biHeight / uiStatic.buttons_height );

	int cutted_img_sz = ( pInfoHdr->biWidth * uiStatic.buttons_height * ( pInfoHdr->biBitCount >> 3 ));
	int CuttedBmpSize = sizeof( BITMAPFILEHEADER ) + sizeof( BITMAPINFOHEADER ) + palette_sz + cutted_img_sz;
	byte *img_data = &bmp_buffer[pFileHdr->bfOffBits + cutted_img_sz * ( pic_count - 1 )];

	NewFileHdr.bfSize = CuttedBmpSize;
	NewFileHdr.bfOffBits = sizeof( BITMAPFILEHEADER ) + sizeof( BITMAPINFOHEADER ) + palette_sz;
	NewInfoHdr.biHeight = uiStatic.buttons_height;
	NewInfoHdr.biSizeImage = cutted_img_sz;

	char fname[256];
	byte *raw_img_buff = (byte *)MALLOC( CuttedBmpSize );

	for( int i = 0; i < pic_count; i++ )
	{
		sprintf( fname, "#btns_%d.bmp", i );

		int offset = 0;
		memcpy( &raw_img_buff[offset], &NewFileHdr, sizeof( BITMAPFILEHEADER ));
		offset += sizeof( BITMAPFILEHEADER );

		memcpy( &raw_img_buff[offset], &NewInfoHdr, NewInfoHdr.biSize );
		offset += NewInfoHdr.biSize;

		if( NewInfoHdr.biBitCount <= 8 )
		{
 			memcpy( &raw_img_buff[offset], palette, palette_sz );
 			offset += palette_sz;
		}
		
		memcpy( &raw_img_buff[offset], img_data, cutted_img_sz );

		// upload image into video memory
		uiStatic.buttonsPics[i] = PIC_Load( fname, raw_img_buff, CuttedBmpSize );

		img_data -= cutted_img_sz;
	}

	FREE( raw_img_buff );
	FREE_FILE( bmp_buffer );
}