コード例 #1
0
ファイル: gamepal.c プロジェクト: paud/d2x-xl
//------------------------------------------------------------------------------
//load a palette by name. returns 1 if new palette loaded, else 0
//if nUsedForLevel is set, load pig, etc.
//if bNoScreenChange is set, the current screen does not get remapped,
//and the hardware palette does not get changed
ubyte *LoadPalette (char *pszPaletteName, char *pszLevelName, int nUsedForLevel, 
						  int bNoScreenChange, int bForce)
{
	char	szPigName[FILENAME_LEN];
	ubyte *palette = NULL;

	//special hack to tell that palette system about a pig that's been loaded elsewhere
if (nUsedForLevel == -2) {
	strncpy (szLastPalettePig, pszPaletteName, sizeof (szLastPalettePig));
	return lastPalette;
	}
if (!pszPaletteName)
	pszPaletteName = szLastPalettePig;
if (!*pszPaletteName)
	pszPaletteName = "groupa.256";
if (nUsedForLevel && stricmp (szLastPalettePig, pszPaletteName) != 0) {
	if (gameStates.app.bD1Mission)
		strcpy (szPigName, "groupa.pig");
	else {
		_splitpath (pszPaletteName, NULL, NULL, szPigName, NULL);
		strcat (szPigName, ".pig");
		PiggyInitPigFile (szPigName);
		}
//if not editor, load pig first so small install message can come
//up in old palette.  If editor version, we must load the pig after
//the palette is loaded so we can remap new textures.
#ifdef EDITOR
	piggy_new_pigfile(szPigName);
#endif
	}
if (bForce || pszLevelName || stricmp(szLastPaletteLoaded, pszPaletteName)) {
	strncpy (szLastPaletteLoaded, pszPaletteName, sizeof (szLastPaletteLoaded));
	palette = GrUsePaletteTable (pszPaletteName, pszLevelName);
	if (!gameStates.render.bPaletteFadedOut && !bNoScreenChange)
		GrPaletteStepLoad (NULL);
	//RemapFontsAndMenus (0);
	gameData.hud.msgs [0].nColor = -1;
	LoadBackgroundBitmap();
	}
if (nUsedForLevel && stricmp(szLastPalettePig,pszPaletteName) != 0) {
	strncpy(szLastPalettePig,pszPaletteName,sizeof(szLastPalettePig));
#ifdef EDITOR
	piggy_new_pigfile(szPigName);
#endif
	TexMergeFlush();
	RLECacheFlush();
	}
return palette;
}
コード例 #2
0
ファイル: gamepal.c プロジェクト: gameplayer22/d2x-1
//load a palette by name. returns 1 if new palette loaded, else 0
//if used_for_level is set, load pig, etc.
//if no_change_screen is set, the current screen does not get remapped,
//and the hardware palette does not get changed
int load_palette(char *name,int used_for_level,int no_change_screen)
{
	char pigname[FILENAME_LEN];
	ubyte old_pal[256*3];

	//special hack to tell that palette system about a pig that's been loaded elsewhere
	if (used_for_level == -2) {
		strncpy(last_palette_loaded_pig,name,sizeof(last_palette_loaded_pig));
		return 1;
	}

	if (name==NULL)
		name = last_palette_loaded_pig;

	if (used_for_level && stricmp(last_palette_loaded_pig,name) != 0) {

		_splitpath(name,NULL,NULL,pigname,NULL);
		strcat(pigname,".pig");
		//if not editor, load pig first so small install message can come
		//up in old palette.  If editor version, we must load the pig after
		//the palette is loaded so we can remap new textures.
		#ifndef EDITOR
		piggy_new_pigfile(pigname);
		#endif
	}

	if (stricmp(last_palette_loaded,name) != 0) {

		memcpy(old_pal,gr_palette,sizeof(old_pal));

		strncpy(last_palette_loaded,name,sizeof(last_palette_loaded));

		gr_use_palette_table(name);

		if (Function_mode == FMODE_GAME && !no_change_screen)
			gr_remap_bitmap_good( &grd_curscreen->sc_canvas.cv_bitmap, old_pal, -1, -1 );

#if defined(POLY_ACC)
        if (bg.bmp && bg.bmp->bm_type == BM_LINEAR)
#else
        if (bg.bmp)
#endif
            gr_remap_bitmap_good( bg.bmp, old_pal, -1, -1 );

		if (!gr_palette_faded_out && !no_change_screen)
			gr_palette_load(gr_palette);

		remap_fonts_and_menus(0);

		Color_0_31_0 = -1;		//for gauges
		HUD_color = -1;

		load_background_bitmap();

		g3_remap_interp_colors();
	}


	if (used_for_level && stricmp(last_palette_loaded_pig,name) != 0) {

		strncpy(last_palette_loaded_pig,name,sizeof(last_palette_loaded_pig));

		#ifdef EDITOR
		piggy_new_pigfile(pigname);
		#endif

		texmerge_flush();
		rle_cache_flush();
	}

	return 1;
}