Chameleon

View chameleon-override_img_fix.patch

1Index: i386/boot2/gui.c
2===================================================================
3--- i386/boot2/gui.c(revision 2042)
4+++ i386/boot2/gui.c(working copy)
5@@ -286,15 +286,12 @@
6 uint16_theight;
7 uint8_t*imagedata;
8
9-if ((strlen(image) + strlen(theme_name) + 20 ) > sizeof(dirspec)) {
10+if ((strlen(image) + strlen(theme_name) + 20) > sizeof(dirspec))
11 return 1;
12-}
13-
14- if ((i = getImageIndexByName(image)) >= 0)
15- {
16- if (images[i].image == NULL) {
17- images[i].image = malloc(sizeof(pixmap_t));
18- }
19+if ((i = getImageIndexByName(image)) < 0)
20+return 1;
21+if (!images[i].image && !(images[i].image = malloc(sizeof(pixmap_t))))
22+return 1;
23 sprintf(dirspec, "/Extra/Themes/%s/%s.png", theme_name, image);
24 width = 0;
25 height = 0;
26@@ -323,43 +320,25 @@
27 flipRB(images[i].image);
28 return 0;
29 }
30-
31- return 0;
32 }
33 #endif
34- else if (alt_image != IMG_REQUIRED)
35+ else if (alt_image != IMG_REQUIRED && is_image_loaded(alt_image))
36 {
37-if (images[alt_image].image->pixels != NULL) {
38-
39-// Using the passed alternate image for non-mandatory images.
40-// We don't clone the already existing pixmap, but using its properties instead!
41-images[i].image->width = images[alt_image].image->width;
42-images[i].image->height = images[alt_image].image->height;
43-images[i].image->pixels = images[alt_image].image->pixels;
44-
45-} else {
46-
47-// Unable to load or to find the image, this image not vital anyway, reseting and returning success !!
48-
49-free(images[i].image);
50-images[i].image = NULL;
51-}
52-
53+ // Using the passed alternate image for non-mandatory images.
54+ // We don't clone the already existing pixmap, but using its properties instead!
55+ images[i].image->width = images[alt_image].image->width;
56+ images[i].image->height = images[alt_image].image->height;
57+ images[i].image->pixels = images[alt_image].image->pixels;
58 return 0;
59 }
60- else
61- {
62+
63+// If we got here it's an error
64 #ifndef CONFIG_EMBED_THEME
65- printf("ERROR: GUI: could not open '%s/%s.png'!\n", theme_name, image);
66-sleep(2);
67+printf("ERROR: GUI: could not open '%s/%s.png'!\n", theme_name, image);
68+sleep(2);
69 #endif
70-free(images[i].image);
71-images[i].image = NULL;
72-return 1;
73-
74- }
75-
76- }
77+free(images[i].image);
78+images[i].image = NULL;
79 return 1;
80 }
81
82@@ -372,29 +351,29 @@
83 LOADPNG(device_generic_o, iDeviceGeneric);
84 LOADPNG(device_hfsplus, iDeviceGeneric);
85 LOADPNG(device_hfsplus_o, iDeviceHFS);
86-LOADPNG(device_hfsplus_ml, iDeviceHFS_ML);
87-LOADPNG(device_hfsplus_ml_o, iDeviceHFS_ML_o);
88-LOADPNG(device_hfsplus_lion, iDeviceHFS_Lion);
89-LOADPNG(device_hfsplus_lion_o, iDeviceHFS_Lion_o);
90-LOADPNG(device_hfsplus_sl, iDeviceHFS_SL);
91-LOADPNG(device_hfsplus_sl_o, iDeviceHFS_SL_o);
92-LOADPNG(device_hfsplus_leo, iDeviceHFS_Leo);
93-LOADPNG(device_hfsplus_leo_o, iDeviceHFS_Leo_o);
94-LOADPNG(device_hfsplus_tiger, iDeviceHFS_Tiger);
95-LOADPNG(device_hfsplus_tiger_o, iDeviceHFS_Tiger_o);
96+LOADPNG(device_hfsplus_ml, iDeviceHFS);
97+LOADPNG(device_hfsplus_ml_o, iDeviceHFS_ML);
98+LOADPNG(device_hfsplus_lion, iDeviceHFS);
99+LOADPNG(device_hfsplus_lion_o, iDeviceHFS_Lion);
100+LOADPNG(device_hfsplus_sl, iDeviceHFS);
101+LOADPNG(device_hfsplus_sl_o, iDeviceHFS_SL);
102+LOADPNG(device_hfsplus_leo, iDeviceHFS);
103+LOADPNG(device_hfsplus_leo_o, iDeviceHFS_Leo);
104+LOADPNG(device_hfsplus_tiger, iDeviceHFS);
105+LOADPNG(device_hfsplus_tiger_o, iDeviceHFS_Tiger);
106
107 LOADPNG(device_hfsraid, iDeviceGeneric);
108 LOADPNG(device_hfsraid_o, iDeviceHFSRAID);
109-LOADPNG(device_hfsraid_ml, iDeviceHFSRAID_ML);
110-LOADPNG(device_hfsraid_ml_o, iDeviceHFSRAID_ML_o);
111-LOADPNG(device_hfsraid_lion, iDeviceHFSRAID_Lion);
112-LOADPNG(device_hfsraid_lion_o, iDeviceHFSRAID_Lion_o);
113-LOADPNG(device_hfsraid_sl, iDeviceHFSRAID_SL);
114-LOADPNG(device_hfsraid_sl_o, iDeviceHFSRAID_SL_o);
115-LOADPNG(device_hfsraid_leo, iDeviceHFSRAID_Leo);
116-LOADPNG(device_hfsraid_leo_o, iDeviceHFSRAID_Leo_o);
117-LOADPNG(device_hfsraid_tiger, iDeviceHFSRAID_Tiger);
118-LOADPNG(device_hfsraid_tiger_o, iDeviceHFSRAID_Tiger_o);
119+LOADPNG(device_hfsraid_ml, iDeviceHFSRAID);
120+LOADPNG(device_hfsraid_ml_o, iDeviceHFSRAID_ML);
121+LOADPNG(device_hfsraid_lion, iDeviceHFSRAID);
122+LOADPNG(device_hfsraid_lion_o, iDeviceHFSRAID_Lion);
123+LOADPNG(device_hfsraid_sl, iDeviceHFSRAID);
124+LOADPNG(device_hfsraid_sl_o, iDeviceHFSRAID_SL);
125+LOADPNG(device_hfsraid_leo, iDeviceHFSRAID);
126+LOADPNG(device_hfsraid_leo_o, iDeviceHFSRAID_Leo);
127+LOADPNG(device_hfsraid_tiger, iDeviceHFSRAID);
128+LOADPNG(device_hfsraid_tiger_o, iDeviceHFSRAID_Tiger);
129 LOADPNG(device_ext3, iDeviceGeneric);
130 LOADPNG(device_ext3_o, iDeviceEXT3);
131 LOADPNG(device_freebsd, iDeviceGeneric); /* FreeBSD/OpenBSD detection,nawcom's code by valv, Icon credits to blackosx */
132@@ -406,9 +385,9 @@
133 LOADPNG(device_fat, iDeviceGeneric);
134 LOADPNG(device_fat_o, iDeviceFAT);
135 LOADPNG(device_fat16, iDeviceFAT);
136-LOADPNG(device_fat16_o, iDeviceFAT_o);
137+LOADPNG(device_fat16_o, iDeviceFAT16);
138 LOADPNG(device_fat32, iDeviceFAT);
139-LOADPNG(device_fat32_o, iDeviceFAT_o);
140+LOADPNG(device_fat32_o, iDeviceFAT32);
141 LOADPNG(device_ntfs, iDeviceGeneric);
142 LOADPNG(device_ntfs_o, iDeviceNTFS);
143 LOADPNG(device_cdrom, iDeviceGeneric);
144@@ -898,91 +877,62 @@
145 if( diskIsCDROM(device) )
146 devicetype = iDeviceCDROM;// Use CDROM icon
147 else
148-{
149+{
150 switch (device->part_type)
151 {
152 case kPartitionTypeHFS:
153-{
154-
155-// Use HFS or HFSRAID icon depending on bvr flags.
156-if (device->flags & kBVFlagBooter)
157-{
158-
159-switch (device->OSVersion[3]) {
160-case '8':
161-devicetype = is_image_loaded(iDeviceHFSRAID_ML) ? iDeviceHFSRAID_ML : is_image_loaded(iDeviceHFSRAID) ? iDeviceHFSRAID : iDeviceGeneric;
162-break;
163-case '7':
164-devicetype = is_image_loaded(iDeviceHFSRAID_Lion) ? iDeviceHFSRAID_Lion : is_image_loaded(iDeviceHFSRAID) ? iDeviceHFSRAID : iDeviceGeneric;
165-break;
166-case '6':
167-devicetype = is_image_loaded(iDeviceHFSRAID_SL) ? iDeviceHFSRAID_SL : is_image_loaded(iDeviceHFSRAID) ? iDeviceHFSRAID : iDeviceGeneric;
168-break;
169-case '5':
170-devicetype = is_image_loaded(iDeviceHFSRAID_Leo) ? iDeviceHFSRAID_Leo : is_image_loaded(iDeviceHFSRAID) ? iDeviceHFSRAID : iDeviceGeneric;
171-break;
172-case '4':
173-devicetype = is_image_loaded(iDeviceHFSRAID_Tiger) ? iDeviceHFSRAID_Tiger : is_image_loaded(iDeviceHFSRAID) ? iDeviceHFSRAID : iDeviceGeneric;
174-break;
175-default:
176-devicetype = is_image_loaded(iDeviceHFSRAID) ? iDeviceHFSRAID : iDeviceGeneric;
177-break;
178-}
179-
180-} else {
181-
182-switch (device->OSVersion[3]) {
183-case '8':
184-devicetype = is_image_loaded(iDeviceHFS_ML) ? iDeviceHFS_ML : is_image_loaded(iDeviceHFS) ? iDeviceHFS : iDeviceGeneric;
185-break;
186-case '7':
187-devicetype = is_image_loaded(iDeviceHFS_Lion) ? iDeviceHFS_Lion : is_image_loaded(iDeviceHFS) ? iDeviceHFS : iDeviceGeneric;
188-break;
189-case '6':
190-devicetype = is_image_loaded(iDeviceHFS_SL) ? iDeviceHFS_SL : is_image_loaded(iDeviceHFS) ? iDeviceHFS : iDeviceGeneric;
191-break;
192-case '5':
193-devicetype = is_image_loaded(iDeviceHFS_Leo) ? iDeviceHFS_Leo : is_image_loaded(iDeviceHFS) ? iDeviceHFS : iDeviceGeneric;
194-break;
195-case '4':
196-devicetype = is_image_loaded(iDeviceHFS_Tiger) ? iDeviceHFS_Tiger : is_image_loaded(iDeviceHFS) ? iDeviceHFS : iDeviceGeneric;
197-break;
198-default:
199-devicetype = is_image_loaded(iDeviceHFS) ? iDeviceHFS : iDeviceGeneric;
200-break;
201-}
202-
203+{
204+// Use HFS or HFSRAID icon depending on bvr flags. Fallbacks are handled by alt_image above.
205+switch (device->OSVersion[3]) {
206+case '8':
207+devicetype = (device->flags & kBVFlagBooter ? iDeviceHFSRAID_ML : iDeviceHFS_ML);
208+break;
209+case '7':
210+devicetype = (device->flags & kBVFlagBooter ? iDeviceHFSRAID_Lion : iDeviceHFS_Lion);
211+break;
212+case '6':
213+devicetype = (device->flags & kBVFlagBooter ? iDeviceHFSRAID_SL : iDeviceHFS_SL);
214+break;
215+case '5':
216+devicetype = (device->flags & kBVFlagBooter ? iDeviceHFSRAID_Leo : iDeviceHFS_Leo);
217+break;
218+case '4':
219+devicetype = (device->flags & kBVFlagBooter ? iDeviceHFSRAID_Tiger : iDeviceHFS_Tiger);
220+break;
221+default:
222+devicetype = (device->flags & kBVFlagBooter ? iDeviceHFSRAID : iDeviceHFS);
223+break;
224 }
225
226 break;
227
228 }
229 case kPartitionTypeHPFS:
230-devicetype = is_image_loaded(iDeviceNTFS) ? iDeviceNTFS : iDeviceGeneric;// Use HPFS / NTFS icon
231+devicetype = iDeviceNTFS;// Use HPFS / NTFS icon
232 break;
233
234 case kPartitionTypeFAT16:
235-devicetype = is_image_loaded(iDeviceFAT16) ? iDeviceFAT16 : iDeviceGeneric;// Use FAT16 icon
236+devicetype = iDeviceFAT16;// Use FAT16 icon
237 break;
238
239 case kPartitionTypeFAT32:
240-devicetype = is_image_loaded(iDeviceFAT32) ? iDeviceFAT32 : iDeviceGeneric;// Use FAT32 icon
241+devicetype = iDeviceFAT32;// Use FAT32 icon
242 break;
243
244 case kPartitionTypeEXT3:
245-devicetype = is_image_loaded(iDeviceEXT3) ? iDeviceEXT3 : iDeviceGeneric;// Use EXT2/3 icon
246+devicetype = iDeviceEXT3;// Use EXT2/3 icon
247 break;
248
249 case kPartitionTypeFreeBSD: /* FreeBSD/OpenBSD detection,nawcom's code by valv, Icon credits to blackosx */
250-devicetype = is_image_loaded(iDeviceFreeBSD) ? iDeviceFreeBSD : iDeviceGeneric;// Use FreeBSD icon
251+devicetype = iDeviceFreeBSD;// Use FreeBSD icon
252 break;
253
254 case kPartitionTypeOpenBSD: /* FreeBSD/OpenBSD detection,nawcom's code by valv, Icon credits to blackosx */
255-devicetype = is_image_loaded(iDeviceOpenBSD) ? iDeviceOpenBSD : iDeviceGeneric;// Use OpenBSD icon
256+devicetype = iDeviceOpenBSD;// Use OpenBSD icon
257 break;
258
259 case kPartitionTypeBEFS: /* Haiku detection and Icon credits to scorpius */
260-devicetype = is_image_loaded(iDeviceBEFS) ? iDeviceBEFS : iDeviceGeneric;// Use BEFS / Haiku icon
261+devicetype = iDeviceBEFS;// Use BEFS / Haiku icon
262 break;
263
264 default:
265@@ -992,14 +942,14 @@
266 }
267
268 // Draw the selection image and use the next (device_*_o) image for the selected item.
269- if (isSelected)
270+if (isSelected)
271 {
272 blend(images[iSelection].image, buffer, centeredAt(images[iSelection].image, p));
273-devicetype++; // selec override image
274+devicetype++; // select override image
275 }
276
277 // draw icon
278-blend( images[devicetype].image, buffer, centeredAt( images[devicetype].image, p ));
279+blend(images[devicetype].image, buffer, centeredAt(images[devicetype].image, p));
280
281 p.y += (images[iSelection].image->height / 2) + font_console.chars[0]->height;
282
283

Archive Download this file

Attachment to issue 280

Created: 11 years 8 months ago by bltz