1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
8 * $Id: skin_tokens.c 24526 2010-02-05 23:58:53Z jdgordon $
10 * Copyright (C) 2010 Jonathan Gordon
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
28 #include "skin_buffer.h"
29 #include "wps_internals.h"
30 #include "skin_engine.h"
32 #if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1))
34 static struct skin_backdrop
{
35 char name
[MAX_FILENAME
+1];
37 enum screen_type screen
;
38 } backdrops
[SKINNABLE_SCREENS_COUNT
*NB_SCREENS
];
40 void skin_backdrop_init(void)
43 for(i
=0;i
<SKINNABLE_SCREENS_COUNT
*NB_SCREENS
;i
++)
45 backdrops
[i
].name
[0] = '\0';
46 backdrops
[i
].buffer
= NULL
;
50 /* load a backdrop into the skin buffer.
51 * reuse buffers if the file is already loaded */
52 char* skin_backdrop_load(char* backdrop
, char *bmpdir
, enum screen_type screen
)
55 struct skin_backdrop
*bdrop
= NULL
;
56 char filename
[MAX_PATH
];
59 #if defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)
60 if (screen
== SCREEN_REMOTE
)
61 buf_size
= REMOTE_LCD_BACKDROP_BYTES
;
64 buf_size
= LCD_BACKDROP_BYTES
;
66 if (backdrop
[0] == '-')
69 if (screen
== SCREEN_REMOTE
)
71 return NULL
; /* remotes don't have a backdrop setting (yet!) */
76 char settings_bdrop
= global_settings
.backdrop_file
[0];
77 if (settings_bdrop
== '\0' || settings_bdrop
== '-')
79 return NULL
; /* backdrop setting not set */
81 snprintf(filename
, sizeof(filename
), "%s/%s.bmp",
82 BACKDROP_DIR
, global_settings
.backdrop_file
);
87 get_image_filename(backdrop
, bmpdir
, filename
, sizeof(filename
));
90 for(i
=0;i
<SKINNABLE_SCREENS_COUNT
*NB_SCREENS
;i
++)
92 if (!strcmp(backdrops
[i
].name
, backdrop
) && backdrops
[i
].screen
== screen
)
94 return backdrops
[i
].buffer
;
96 else if (backdrops
[i
].buffer
== NULL
)
98 bdrop
= &backdrops
[i
];
102 return NULL
; /* too many backdrops loaded */
104 bdrop
->buffer
= skin_buffer_alloc(buf_size
);
107 loaded
= screens
[screen
].backdrop_load(filename
, bdrop
->buffer
);
108 bdrop
->screen
= screen
;
109 strlcpy(bdrop
->name
, backdrop
, MAX_FILENAME
+1);
110 bdrop
->name
[MAX_FILENAME
] = '\0';
112 return loaded
? bdrop
->buffer
: NULL
;
116 void skin_backdrop_init(void)