Esempio n. 1
0
ubyte *AddPalette (ubyte *palette)
{
	tPaletteList	*plP;

if (!palette)
	return NULL;
if (FindPalette (palette))
	return gameData.render.pal.pCurPal;
if (!(plP = D2_ALLOC (sizeof (tPaletteList))))
	return NULL;
plP->pNextPal = gameData.render.pal.palettes;
gameData.render.pal.palettes = plP;
memcpy (plP->palette, palette, sizeof (tPalette));
gameData.render.pal.nPalettes++;
plP->nComputedColors = 0;
memset (plP->computedColors, 0xff, sizeof (plP->computedColors));
return gameData.render.pal.pCurPal = plP->palette;
}
Esempio n. 2
0
void ChangePalette(SCNHANDLE hPal) {
	SwapPalette(FindPalette(hBgPal), hPal);

	SetBackPal(hPal);
}
Esempio n. 3
0
/************************************************************************
**
** GetPaletteDefinition -
**  Query the database for the Dtstyle.paletteDirectories resource
**  Use Dtstyle default (Default) if not specified.
**  Search the directories for the palette in reverse order
**
************************************************************************/
struct _palette * 
GetPaletteDefinition( 
Display *dpy,
int     screen_number,
char    *palette)

{
    struct _palette *paletteDef;
    char *str_type_return;
    XrmValue value_return;
    XrmDatabase db;
    Boolean match = False;
    char *palettePath;
    char *path;
    char *p, *d;
    char *home;
    char dir[256];
                    

    if (FindPalette (palette, SYSTEM_PALETTE_DIR))
    {
       /* 
	* First look for palette in the system location
        */
        palettePath = (char *) SRV_MALLOC (strlen(SYSTEM_PALETTE_DIR) + 1 );
        strcpy(palettePath, SYSTEM_PALETTE_DIR);
        match = True;
    }
    else if (FindPalette (palette, CONFIG_PALETTE_DIR))
    {
       /* 
	* Next check the local config location
        */
        palettePath = (char *) SRV_MALLOC (strlen(CONFIG_PALETTE_DIR) + 1 );
        strcpy(palettePath, CONFIG_PALETTE_DIR);
        match = True;
    }
    else 
    {
	palettePath = NULL;
    }

    /*  Get Dtstyle.paletteDirectories value */
    db = XtDatabase(dpy);
    if (XrmGetResource (db, "dtstyle.paletteDirectories",
                            "Dtstyle.PaletteDirectories",
                            &str_type_return, &value_return))
    {
        /* Make Local Copy of string */
        path = (char *) SRV_MALLOC( value_return.size + 1 );
        strcpy (path, value_return.addr);
    }
    else 
    {
        path = NULL;
    }

    /* Look for palette in paletteDirectories */
    if (path != NULL)
    {
        /* Loop through paletteDirectories looking in each directory
         * till we find the palette file. Take first occurrance.
         * Copy directory name into dir.  Look for NULL or space 
         */

        p = path;
        while (*p != '\0')
        {
            d = dir;
            while (*p != ' ' && *p != '\0')
                *d++ = *p++;
            *d = '\0';
            if (FindPalette (palette, dir))
            {
                palettePath = (char *)SRV_REALLOC(palettePath, 
                                                strlen(SYSTEM_PALETTE_DIR) + 1);
                strcpy(palettePath, dir);
                match = True;
                break;
            }
        }
    }
        
    /* Look for palette in $HOME/.dt/palettes */
    /* If there is a duplicate, take it */

    if ((home=getenv(HOME)) == NULL)
      home="";
    path = (char *) SRV_REALLOC (path, 
        strlen(home) + strlen(USER_PALETTE_DIR) + 1);
    strcpy(path, home);
    strcat(path, USER_PALETTE_DIR);

    if (FindPalette (palette, path))
    {
        palettePath = (char *) SRV_REALLOC (palettePath, strlen(path) + 1 );
        strcpy(palettePath, path);
        match = True;
    }
    
    if (match)
    {
        /* Parse the data from the palette file */
        paletteDef = (struct _palette *) ReadPaletteFile(dpy, 
                                                         screen_number, 
                                                         palettePath,
                                                         palette);
    } 
    else /* default to system Default */
    {
        palettePath = (char *) SRV_REALLOC (palettePath,
                                            strlen(SYSTEM_PALETTE_DIR) + 1);
        strcpy(palettePath, SYSTEM_PALETTE_DIR);
        paletteDef = (struct _palette *)ReadPaletteFile(dpy, 
                                                        screen_number, 
                                                        palettePath,
                                                        DEFAULT_PALETTE);
    }

    if (path != NULL)
        SRV_FREE(path);
    if (palettePath != NULL)
        SRV_FREE(palettePath);

    return (paletteDef);

}