refactoring menu entries

Signed-off-by: Sergey Isakov <isakov-sl@bk.ru>
This commit is contained in:
Sergey Isakov 2020-04-03 23:00:42 +03:00
parent ed196e10c8
commit 8b5ec83c6a
20 changed files with 933 additions and 319 deletions

View File

@ -15825,6 +15825,7 @@
knownRegions = (
English,
en,
Base,
);
mainGroup = 2C7949DA1A0AA7F700D845B0;
productRefGroup = 2C7949DA1A0AA7F700D845B0;

View File

@ -809,16 +809,26 @@ typedef struct CUSTOM_LOADER_ENTRY CUSTOM_LOADER_ENTRY;
struct CUSTOM_LOADER_ENTRY {
CUSTOM_LOADER_ENTRY *Next;
CUSTOM_LOADER_ENTRY *SubEntries;
#if USE_XTHEME
XImage Image;
XImage DriveImage;
#else
EG_IMAGE *Image;
EG_IMAGE *DriveImage;
CONST CHAR16 *ImagePath;
CONST CHAR16 *DriveImagePath;
CONST CHAR16 *Volume;
CONST CHAR16 *Path;
CONST CHAR16 *Options;
CONST CHAR16 *FullTitle;
CONST CHAR16 *Title;
CONST CHAR16 *Settings;
#endif
CONST CHAR16 *ImagePath;
CONST CHAR16 *DriveImagePath;
CONST CHAR16 *Volume;
CONST CHAR16 *Path;
CONST CHAR16 *Options;
#if USE_XTHEME
XStringW FullTitle;
XStringW Title;
#else
CONST CHAR16 *FullTitle;
CONST CHAR16 *Title;
#endif
CONST CHAR16 *Settings;
CHAR16 Hotkey;
BOOLEAN CommonSettings;
UINT8 Flags;
@ -837,14 +847,24 @@ struct CUSTOM_LOADER_ENTRY {
typedef struct CUSTOM_LEGACY_ENTRY CUSTOM_LEGACY_ENTRY;
struct CUSTOM_LEGACY_ENTRY {
CUSTOM_LEGACY_ENTRY *Next;
EG_IMAGE *Image;
EG_IMAGE *DriveImage;
CONST CHAR16 *ImagePath;
CONST CHAR16 *DriveImagePath;
CONST CHAR16 *Volume;
CONST CHAR16 *FullTitle;
CONST CHAR16 *Title;
CUSTOM_LEGACY_ENTRY *Next;
#if USE_XTHEME
XImage Image;
XImage DriveImage;
#else
EG_IMAGE *Image;
EG_IMAGE *DriveImage;
#endif
CONST CHAR16 *ImagePath;
CONST CHAR16 *DriveImagePath;
CONST CHAR16 *Volume;
#if USE_XTHEME
XStringW FullTitle;
XStringW Title;
#else
CONST CHAR16 *FullTitle;
CONST CHAR16 *Title;
#endif
CHAR16 Hotkey;
UINT8 Flags;
UINT8 Type;
@ -854,13 +874,22 @@ struct CUSTOM_LEGACY_ENTRY {
typedef struct CUSTOM_TOOL_ENTRY CUSTOM_TOOL_ENTRY;
struct CUSTOM_TOOL_ENTRY {
CUSTOM_TOOL_ENTRY *Next;
#if USE_XTHEME
XImage Image;
#else
EG_IMAGE *Image;
#endif
CHAR16 *ImagePath;
CHAR16 *Volume;
CHAR16 *Path;
CHAR16 *Options;
CHAR16 *FullTitle;
CHAR16 *Title;
#if USE_XTHEME
XStringW FullTitle;
XStringW Title;
#else
CONST CHAR16 *FullTitle;
CONST CHAR16 *Title;
#endif
CHAR16 Hotkey;
UINT8 Flags;
UINT8 VolumeType;

View File

@ -104,11 +104,12 @@ BOOLEAN DayLight;
extern MEM_STRUCTURE gRAM;
extern BOOLEAN NeedPMfix;
#if !USE_XTHEME
extern INTN ScrollWidth;
extern INTN ScrollButtonsHeight;
extern INTN ScrollBarDecorationsHeight;
extern INTN ScrollScrollDecorationsHeight;
#endif
extern EFI_AUDIO_IO_PROTOCOL *AudioIo;
//extern INTN OldChosenAudio;
/*
@ -988,11 +989,11 @@ CUSTOM_LOADER_ENTRY
}
if (Entry->FullTitle != NULL) {
DuplicateEntry->FullTitle = EfiStrDuplicate (Entry->FullTitle);
DuplicateEntry->FullTitle = Entry->FullTitle;
}
if (Entry->Title != NULL) {
DuplicateEntry->Title = EfiStrDuplicate (Entry->Title);
DuplicateEntry->Title = Entry->Title;
}
if (Entry->ImagePath != NULL) {
@ -1019,9 +1020,7 @@ CUSTOM_LOADER_ENTRY
DuplicateEntry->KernelScan = Entry->KernelScan;
DuplicateEntry->CustomBoot = Entry->CustomBoot;
DuplicateEntry->CustomLogo = Entry->CustomLogo;
CopyKernelAndKextPatches ((KERNEL_AND_KEXT_PATCHES *)(((UINTN)DuplicateEntry) + OFFSET_OF(CUSTOM_LOADER_ENTRY, KernelAndKextPatches)),
(KERNEL_AND_KEXT_PATCHES *)(((UINTN)Entry) + OFFSET_OF(CUSTOM_LOADER_ENTRY, KernelAndKextPatches)));
CopyKernelAndKextPatches (&DuplicateEntry->KernelAndKextPatches, &Entry->KernelAndKextPatches);
}
return DuplicateEntry;
@ -1949,6 +1948,48 @@ FillinCustomEntry (
Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_NODEFAULTARGS);
}
}
#if USE_XTHEME
Prop = GetProperty (DictPointer, "Title");
if (Prop != NULL && (Prop->type == kTagTypeString)) {
Entry->Title.takeValueFrom(Prop->string);
}
Prop = GetProperty (DictPointer, "FullTitle");
if (Prop != NULL && (Prop->type == kTagTypeString)) {
Entry->FullTitle.takeValueFrom(Prop->string);
}
Prop = GetProperty (DictPointer, "Image");
if (Prop != NULL) {
if (Entry->ImagePath) {
FreePool (Entry->ImagePath);
Entry->ImagePath = NULL;
}
Entry->Image.LoadXImage(ThemeX.ThemeDir, Prop->string);
} else {
UINTN DataLen = 0;
UINT8 *TmpData = GetDataSetting (DictPointer, "ImageData", &DataLen);
if (TmpData) {
Entry->Image.FromPNG(TmpData, DataLen);
FreePool(TmpData);
}
}
Prop = GetProperty (DictPointer, "DriveImage");
if (Prop != NULL) {
if (Entry->DriveImagePath != NULL) {
FreePool (Entry->DriveImagePath);
Entry->DriveImagePath = NULL;
}
Entry->DriveImage.LoadXImage(ThemeX.ThemeDir, Prop->string);
} else {
UINTN DataLen = 0;
UINT8 *TmpData = GetDataSetting (DictPointer, "ImageData", &DataLen);
if (TmpData) {
Entry->DriveImage.FromPNG(TmpData, DataLen);
FreePool(TmpData);
}
}
#else
Prop = GetProperty (DictPointer, "Title");
if (Prop != NULL && (Prop->type == kTagTypeString)) {
@ -1963,7 +2004,6 @@ FillinCustomEntry (
Entry->Title = PoolPrint (L"%a", Prop->string);
}
Prop = GetProperty (DictPointer, "FullTitle");
if (Prop != NULL && (Prop->type == kTagTypeString)) {
if (Entry->FullTitle) {
@ -1989,27 +2029,11 @@ FillinCustomEntry (
Entry->ImagePath = PoolPrint (L"%a", Prop->string);
}
} else {
Prop = GetProperty (DictPointer, "ImageData");
if (Prop != NULL) {
if (Entry->Image) {
egFreeImage (Entry->Image);
Entry->Image = NULL;
}
if (Entry->ImagePath) {
FreePool (Entry->ImagePath);
Entry->ImagePath = NULL;
}
if (Prop->type == kTagTypeString) {
UINT32 len = (UINT32)(AsciiStrLen (Prop->string) >> 1);
if (len > 0) {
UINT8 *data = (UINT8 *)AllocateZeroPool (len);
if (data) {
Entry->Image = egDecodePNG(data, hex2bin (Prop->string, data, len), TRUE);
}
}
} else if (Prop->type == kTagTypeData) {
Entry->Image = egDecodePNG (Prop->data, Prop->dataLen, TRUE);
}
UINTN DataLen = 0;
UINT8 *TmpData = GetDataSetting (DictPointer, "ImageData", &DataLen);
if (TmpData) {
Entry->Image = egDecodePNG (TmpData, DataLen, TRUE);
FreePool(TmpData);
}
}
@ -2029,32 +2053,14 @@ FillinCustomEntry (
Entry->DriveImagePath = PoolPrint (L"%a", Prop->string);
}
} else {
Prop = GetProperty (DictPointer, "DriveImageData");
if (Prop != NULL) {
if (Entry->DriveImage) {
egFreeImage (Entry->DriveImage);
Entry->Image = NULL;
}
if (Entry->DriveImagePath != NULL) {
FreePool (Entry->DriveImagePath);
Entry->DriveImagePath = NULL;
}
if (Prop->type == kTagTypeString) {
UINT32 len = (UINT32)(AsciiStrLen (Prop->string) >> 1);
if (len > 0) {
UINT8 *data = (UINT8 *)AllocateZeroPool (len);
if (data) {
Entry->DriveImage = egDecodePNG (data, hex2bin (Prop->string, data, len), TRUE);
}
}
} else if (Prop->type == kTagTypeData) {
Entry->DriveImage = egDecodePNG (Prop->data, Prop->dataLen, TRUE);
}
UINTN DataLen = 0;
UINT8 *TmpData = GetDataSetting (DictPointer, "DriveImageData", &DataLen);
if (TmpData) {
Entry->DriveImage = egDecodePNG (TmpData, DataLen, TRUE);
FreePool(TmpData);
}
}
#endif
Prop = GetProperty (DictPointer, "Hotkey");
if (Prop != NULL && (Prop->type == kTagTypeString) && Prop->string) {
Entry->Hotkey = *(Prop->string);
@ -2170,6 +2176,25 @@ FillinCustomEntry (
if (Entry->Options == NULL && OSTYPE_IS_WINDOWS(Entry->Type)) {
Entry->Options = L"-s -h";
}
#if USE_XTHEME
if (Entry->Title.isEmpty()) {
if (OSTYPE_IS_OSX_RECOVERY (Entry->Type)) {
Entry->Title = L"Recovery"_XSW;
} else if (OSTYPE_IS_OSX_INSTALLER (Entry->Type)) {
Entry->Title = L"Install macOS"_XSW;
}
}
if (Entry->Image.isEmpty() && (Entry->ImagePath == NULL)) {
if (OSTYPE_IS_OSX_RECOVERY (Entry->Type)) {
Entry->ImagePath = L"mac";
}
}
if (Entry->DriveImage.isEmpty() && (Entry->DriveImagePath == NULL)) {
if (OSTYPE_IS_OSX_RECOVERY (Entry->Type)) {
Entry->DriveImagePath = L"recovery";
}
}
#else
if (Entry->Title == NULL) {
if (OSTYPE_IS_OSX_RECOVERY (Entry->Type)) {
@ -2188,7 +2213,7 @@ FillinCustomEntry (
Entry->DriveImagePath = L"recovery";
}
}
#endif
// OS Specific flags
if (OSTYPE_IS_OSX(Entry->Type) || OSTYPE_IS_OSX_RECOVERY (Entry->Type) || OSTYPE_IS_OSX_INSTALLER (Entry->Type)) {
@ -2239,8 +2264,10 @@ FillinCustomEntry (
// KernelAndKextPatches
if (!SubEntry) { // CopyKernelAndKextPatches already in: DuplicateCustomEntry if SubEntry == TRUE
//DBG ("Copying global patch settings\n");
CopyKernelAndKextPatches ((KERNEL_AND_KEXT_PATCHES *)(((UINTN)Entry) + OFFSET_OF(CUSTOM_LOADER_ENTRY, KernelAndKextPatches)),
(KERNEL_AND_KEXT_PATCHES *)(((UINTN)&gSettings) + OFFSET_OF(SETTINGS_DATA, KernelAndKextPatches)));
// CopyKernelAndKextPatches ((KERNEL_AND_KEXT_PATCHES *)(((UINTN)Entry) + OFFSET_OF(CUSTOM_LOADER_ENTRY, KernelAndKextPatches)),
// (KERNEL_AND_KEXT_PATCHES *)(((UINTN)&gSettings) + OFFSET_OF(SETTINGS_DATA, KernelAndKextPatches)));
CopyKernelAndKextPatches(&Entry->KernelAndKextPatches, &gSettings.KernelAndKextPatches);
//#ifdef DUMP_KERNEL_KEXT_PATCHES
// DumpKernelAndKextPatches ((KERNEL_AND_KEXT_PATCHES *)(((UINTN)Entry) + OFFSET_OF(CUSTOM_LOADER_ENTRY, KernelAndKextPatches)));
@ -2304,6 +2331,104 @@ FillinCustomEntry (
}
return TRUE;
}
#if USE_XTHEME
BOOLEAN
FillingCustomLegacy (
IN OUT CUSTOM_LEGACY_ENTRY *Entry,
TagPtr DictPointer
)
{
TagPtr Prop;
if ((Entry == NULL) || (DictPointer == NULL)) {
return FALSE;
}
Prop = GetProperty (DictPointer, "Disabled");
if (IsPropertyTrue (Prop)) {
return FALSE;
}
Prop = GetProperty (DictPointer, "Volume");
if (Prop != NULL && (Prop->type == kTagTypeString)) {
if (Entry->Volume != NULL) {
FreePool (Entry->Volume);
}
Entry->Volume = PoolPrint (L"%a", Prop->string);
}
Prop = GetProperty (DictPointer, "FullTitle");
if (Prop != NULL && (Prop->type == kTagTypeString)) {
Entry->FullTitle.takeValueFrom(Prop->string);
}
Prop = GetProperty (DictPointer, "Title");
if (Prop != NULL && (Prop->type == kTagTypeString)) {
Entry->Title.takeValueFrom(Prop->string);
}
Prop = GetProperty (DictPointer, "Image");
if (Prop != NULL) {
if (Prop->type == kTagTypeString) {
Entry->Image.LoadXImage(ThemeX.ThemeDir, Prop->string);
}
} else {
UINTN DataLen = 0;
UINT8 *TmpData = GetDataSetting (DictPointer, "ImageData", &DataLen);
if (TmpData) {
Entry->Image.FromPNG(TmpData, DataLen);
FreePool(TmpData);
}
}
Prop = GetProperty (DictPointer, "DriveImage");
if (Prop != NULL) {
if (Prop->type == kTagTypeString) {
Entry->Image.LoadXImage(ThemeX.ThemeDir, Prop->string);
}
} else {
UINTN DataLen = 0;
UINT8 *TmpData = GetDataSetting (DictPointer, "DriveImageData", &DataLen);
if (TmpData) {
Entry->DriveImage.FromPNG(TmpData, DataLen);
FreePool(TmpData);
}
}
Prop = GetProperty (DictPointer, "Hotkey");
if (Prop != NULL && (Prop->type == kTagTypeString) && Prop->string) {
Entry->Hotkey = *(Prop->string);
}
// Hidden Property, Values:
// - No (show the entry)
// - Yes (hide the entry but can be show with F3)
// - Always (always hide the entry)
Prop = GetProperty (DictPointer, "Hidden");
if (Prop != NULL) {
if ((Prop->type == kTagTypeString) &&
(AsciiStriCmp (Prop->string, "Always") == 0)) {
Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_DISABLED);
} else if (IsPropertyTrue (Prop)) {
Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_HIDDEN);
} else {
Entry->Flags = OSFLAG_UNSET(Entry->Flags, OSFLAG_HIDDEN);
}
}
Prop = GetProperty (DictPointer, "Type");
if (Prop != NULL && (Prop->type == kTagTypeString)) {
if (AsciiStriCmp (Prop->string, "Windows") == 0) {
Entry->Type = OSTYPE_WIN;
} else if (AsciiStriCmp (Prop->string, "Linux") == 0) {
Entry->Type = OSTYPE_LIN;
} else {
Entry->Type = OSTYPE_OTHER;
}
}
Entry->VolumeType = GetVolumeType(DictPointer);
return TRUE;
}
#else
STATIC
BOOLEAN
@ -2364,24 +2489,11 @@ FillinCustomLegacy (
Entry->ImagePath = PoolPrint (L"%a", Prop->string);
}
} else {
Prop = GetProperty (DictPointer, "ImageData");
if (Prop != NULL) {
if (Entry->Image != NULL) {
egFreeImage (Entry->Image);
Entry->Image = NULL;
}
if (Prop->type == kTagTypeString) {
UINT32 Len = (UINT32)(AsciiStrLen (Prop->string) >> 1);
if (Len > 0) {
UINT8 *Data = (UINT8 *)AllocateZeroPool (Len);
if (Data != NULL) {
Entry->Image = egDecodePNG (Data, hex2bin (Prop->string, Data, Len), TRUE);
}
}
} else if (Prop->type == kTagTypeData) {
Entry->Image = egDecodePNG (Prop->data, Prop->dataLen, TRUE);
}
UINTN DataLen = 0;
UINT8 *TmpData = GetDataSetting (DictPointer, "ImageData", &DataLen);
if (TmpData) {
Entry->Image = egDecodePNG (TmpData, DataLen, TRUE);
FreePool(TmpData);
}
}
@ -2401,29 +2513,11 @@ FillinCustomLegacy (
Entry->DriveImagePath = PoolPrint (L"%a", Prop->string);
}
} else {
Prop = GetProperty (DictPointer, "DriveImageData");
if (Prop != NULL) {
if (Entry->DriveImage != NULL) {
egFreeImage (Entry->DriveImage);
Entry->Image = NULL;
}
if (Entry->DriveImagePath != NULL) {
FreePool (Entry->DriveImagePath);
Entry->DriveImagePath = NULL;
}
if (Prop->type == kTagTypeString) {
UINT32 len = (UINT32)(AsciiStrLen (Prop->string) >> 1);
if (len > 0) {
UINT8 *data = (UINT8 *)AllocateZeroPool (len);
if (data) {
Entry->DriveImage = egDecodePNG (data, hex2bin (Prop->string, data, len), TRUE);
}
}
} else if (Prop->type == kTagTypeData) {
Entry->DriveImage = egDecodePNG (Prop->data, Prop->dataLen, TRUE);
}
UINTN DataLen = 0;
UINT8 *TmpData = GetDataSetting (DictPointer, "DriveImageData", &DataLen);
if (TmpData) {
Entry->DriveImage = egDecodePNG (TmpData, DataLen, TRUE);
FreePool(TmpData);
}
}
@ -2462,6 +2556,102 @@ FillinCustomLegacy (
Entry->VolumeType = GetVolumeType(DictPointer);
return TRUE;
}
#endif
#if USE_XTHEME
BOOLEAN
FillingCustomTool (IN OUT CUSTOM_TOOL_ENTRY *Entry, TagPtr DictPointer)
{
TagPtr Prop;
if ((Entry == NULL) || (DictPointer == NULL)) {
return FALSE;
}
Prop = GetProperty (DictPointer, "Disabled");
if (IsPropertyTrue (Prop)) {
return FALSE;
}
Prop = GetProperty (DictPointer, "Volume");
if (Prop != NULL && (Prop->type == kTagTypeString)) {
if (Entry->Volume) {
FreePool (Entry->Volume);
}
Entry->Volume = PoolPrint (L"%a", Prop->string);
}
Prop = GetProperty (DictPointer, "Path");
if (Prop != NULL && (Prop->type == kTagTypeString)) {
if (Entry->Path != NULL) {
FreePool (Entry->Path);
}
Entry->Path = PoolPrint (L"%a", Prop->string);
}
Prop = GetProperty (DictPointer, "Arguments");
if (Prop != NULL && (Prop->type == kTagTypeString)) {
if (Entry->Options != NULL) {
FreePool (Entry->Options);
} else {
Entry->Options = PoolPrint (L"%a", Prop->string);
}
}
Prop = GetProperty (DictPointer, "FullTitle");
if (Prop != NULL && (Prop->type == kTagTypeString)) {
Entry->FullTitle.takeValueFrom(Prop->string);
}
Prop = GetProperty (DictPointer, "Title");
if (Prop != NULL && (Prop->type == kTagTypeString)) {
Entry->Title.takeValueFrom(Prop->string);
}
Prop = GetProperty (DictPointer, "Image");
if (Prop != NULL) {
if (Entry->ImagePath != NULL) {
FreePool (Entry->ImagePath);
Entry->ImagePath = NULL;
}
if (Prop->type == kTagTypeString) {
Entry->ImagePath = PoolPrint (L"%a", Prop->string);
}
Entry->Image.LoadXImage(ThemeX.ThemeDir, Entry->ImagePath);
} else {
UINTN DataLen = 0;
UINT8 *TmpData = GetDataSetting (DictPointer, "ImageData", &DataLen);
if (TmpData) {
Entry->Image.FromPNG(TmpData, DataLen);
FreePool(TmpData);
}
}
Prop = GetProperty (DictPointer, "Hotkey");
if (Prop != NULL && (Prop->type == kTagTypeString) && Prop->string) {
Entry->Hotkey = *(Prop->string);
}
// Hidden Property, Values:
// - No (show the entry)
// - Yes (hide the entry but can be show with F3)
// - Always (always hide the entry)
Prop = GetProperty (DictPointer, "Hidden");
if (Prop != NULL) {
if ((Prop->type == kTagTypeString) &&
(AsciiStriCmp (Prop->string, "Always") == 0)) {
Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_DISABLED);
} else if (IsPropertyTrue (Prop)) {
Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_HIDDEN);
} else {
Entry->Flags = OSFLAG_UNSET(Entry->Flags, OSFLAG_HIDDEN);
}
}
Entry->VolumeType = GetVolumeType(DictPointer);
return TRUE;
}
#else
STATIC
BOOLEAN
@ -2539,26 +2729,13 @@ FillinCustomTool (
Entry->ImagePath = PoolPrint (L"%a", Prop->string);
}
} else {
Prop = GetProperty (DictPointer, "ImageData");
if (Prop != NULL) {
if (Entry->Image != NULL) {
egFreeImage (Entry->Image);
Entry->Image = NULL;
}
if (Prop->type == kTagTypeString) {
UINT32 Len = (UINT32)(AsciiStrLen (Prop->string) >> 1);
if (Len > 0) {
UINT8 *data = (UINT8 *)AllocateZeroPool (Len);
if (data != NULL) {
Entry->Image = egDecodePNG (data, hex2bin (Prop->string, data, Len), TRUE);
}
}
} else if (Prop->type == kTagTypeData) {
Entry->Image = egDecodePNG (Prop->data, Prop->dataLen, TRUE);
}
UINTN DataLen = 0;
UINT8 *TmpData = GetDataSetting (DictPointer, "ImageData", &DataLen);
if (TmpData) {
Entry->Image = egDecodePNG (TmpData, DataLen, TRUE);
}
}
Prop = GetProperty (DictPointer, "Hotkey");
if (Prop != NULL && (Prop->type == kTagTypeString) && Prop->string) {
Entry->Hotkey = *(Prop->string);
@ -2584,7 +2761,7 @@ FillinCustomTool (
return TRUE;
}
#endif
// EDID reworked by Sherlocks
VOID
GetEDIDSettings(TagPtr DictPointer)
@ -3237,7 +3414,7 @@ GetEarlyUserSettings (
Dict2 = GetProperty (Prop, "DoubleClickTime");
if (Dict2 != NULL) {
gSettings.DoubleClickTime = (UINT64)GetPropertyInteger (Dict2, 0);
gSettings.DoubleClickTime = (UINT64)GetPropertyInteger (Dict2, 500);
}
}
// hide by name/uuid
@ -3372,9 +3549,15 @@ GetEarlyUserSettings (
Entry = (CUSTOM_LEGACY_ENTRY *)AllocateZeroPool (sizeof(CUSTOM_LEGACY_ENTRY));
if (Entry) {
// Fill it in
#if USE_XTHEME
if (!FillingCustomLegacy(Entry, Dict3) || !AddCustomLegacyEntry (Entry)) {
FreePool (Entry);
}
#else
if (!FillinCustomLegacy(Entry, Dict3) || !AddCustomLegacyEntry (Entry)) {
FreePool (Entry);
}
#endif
}
}
}
@ -3399,9 +3582,15 @@ GetEarlyUserSettings (
Entry = (CUSTOM_TOOL_ENTRY *)AllocateZeroPool (sizeof(CUSTOM_TOOL_ENTRY));
if (Entry) {
// Fill it in
#if USE_XTHEME
if (!FillingCustomTool(Entry, Dict3) || !AddCustomToolEntry (Entry)) {
FreePool (Entry);
}
#else
if (!FillinCustomTool(Entry, Dict3) || !AddCustomToolEntry (Entry)) {
FreePool (Entry);
}
#endif
}
}
}
@ -4744,8 +4933,13 @@ GetThemeTagSettings (
#endif
TagPtr
LoadTheme (const CHAR16 *TestTheme)
#if USE_XTHEME
void* XTheme::LoadTheme (const CHAR16 *TestTheme)
#else
TagPtr LoadTheme (const CHAR16 *TestTheme)
#endif
{
EFI_STATUS Status = EFI_UNSUPPORTED;
TagPtr ThemeDict = NULL;
@ -4761,31 +4955,34 @@ LoadTheme (const CHAR16 *TestTheme)
} else {
ThemePath = PoolPrint(L"EFI\\CLOVER\\themes\\%s", TestTheme);
}
DBG("look for %ls\n", ThemePath);
if (ThemePath != NULL) {
if (ThemeDir != NULL) {
ThemeDir->Close (ThemeDir);
ThemeDir = NULL;
}
//why this???
Status = SelfRootDir->Open(SelfRootDir, &ThemeDir, ThemePath, EFI_FILE_MODE_READ, 0);
if (EFI_ERROR (Status)) {
if (ThemeDir != NULL) {
ThemeDir->Close (ThemeDir);
ThemeDir = NULL;
}
FreePool (ThemePath);
ThemePath = PoolPrint(L"EFI\\CLOVER\\themes\\%s", TestTheme);
Status = SelfRootDir->Open(SelfRootDir, &ThemeDir, ThemePath, EFI_FILE_MODE_READ, 0);
}
if (!EFI_ERROR (Status)) {
Status = egLoadFile(ThemeDir, CONFIG_THEME_SVG, (UINT8**)&ThemePtr, &Size);
if (!EFI_ERROR(Status) && (ThemePtr != NULL) && (Size != 0)) {
#if USE_XTHEME
Status = ThemeX.ParseSVGXTheme((const CHAR8*)ThemePtr);
#else
Status = ParseSVGTheme((const CHAR8*)ThemePtr, &ThemeDict);
#endif
Status = ParseSVGXTheme((const CHAR8*)ThemePtr);
if (EFI_ERROR(Status)) {
ThemeDict = NULL;
} else {
ThemeDict = (__typeof__(ThemeDict))AllocateZeroPool(sizeof(TagStruct));
ThemeDict->type = kTagTypeNone;
}
#else
Status = ParseSVGTheme((const CHAR8*)ThemePtr, &ThemeDict);
#endif
if (ThemeDict == NULL) {
DBG("svg file %ls not parsed\n", CONFIG_THEME_SVG);
} else {
@ -4811,7 +5008,11 @@ LoadTheme (const CHAR16 *TestTheme)
if (ThemePtr != NULL) {
FreePool (ThemePtr);
}
#if USE_XTHEME
return (void*)ThemeDict;
#else
return ThemeDict;
#endif
}
#if USE_XTHEME
@ -4892,7 +5093,7 @@ InitTheme(BOOLEAN UseThemeDefinedInNVRam, EFI_TIME *Time)
}
if (TestTheme != NULL) {
ThemeDict = LoadTheme (TestTheme);
ThemeDict = (TagPtr)ThemeX.LoadTheme (TestTheme);
if (ThemeDict != NULL) {
DBG ("special theme %ls found and %ls parsed\n", TestTheme, CONFIG_THEME_FILENAME);
// ThemeX.Theme.takeValueFrom(TestTheme);
@ -4916,13 +5117,13 @@ InitTheme(BOOLEAN UseThemeDefinedInNVRam, EFI_TIME *Time)
goto finish;
}
if (AsciiStrCmp (ChosenTheme, "random") == 0) {
ThemeDict = LoadTheme (ThemesList[Rnd]);
ThemeDict = (TagPtr)ThemeX.LoadTheme (ThemesList[Rnd]);
goto finish;
}
TestTheme = PoolPrint (L"%a", ChosenTheme);
if (TestTheme != NULL) {
ThemeDict = LoadTheme (TestTheme);
ThemeDict = (TagPtr)ThemeX.LoadTheme (TestTheme);
if (ThemeDict != NULL) {
DBG ("theme %s defined in NVRAM found and %ls parsed\n", ChosenTheme, CONFIG_THEME_FILENAME);
// ThemeX.Theme.takeValueFrom(TestTheme);
@ -4949,16 +5150,16 @@ InitTheme(BOOLEAN UseThemeDefinedInNVRam, EFI_TIME *Time)
if (!GlobalConfig.Theme) {
if (Time != NULL) {
DBG ("no default theme, get random theme %ls\n", ThemesList[Rnd]);
ThemeDict = LoadTheme (ThemesList[Rnd]);
ThemeDict = (TagPtr)ThemeX.LoadTheme(ThemesList[Rnd]);
} else {
DBG ("no default theme, get first theme %ls\n", ThemesList[0]);
ThemeDict = LoadTheme (ThemesList[0]);
ThemeDict = (TagPtr)ThemeX.LoadTheme(ThemesList[0]);
}
} else {
if (StriCmp(GlobalConfig.Theme, L"random") == 0) {
ThemeDict = LoadTheme (ThemesList[Rnd]);
ThemeDict = (TagPtr)ThemeX.LoadTheme(ThemesList[Rnd]);
} else {
ThemeDict = LoadTheme (GlobalConfig.Theme);
ThemeDict = (TagPtr)ThemeX.LoadTheme(GlobalConfig.Theme);
if (ThemeDict == NULL) {
DBG ("GlobalConfig: %ls not found, get embedded theme\n", GlobalConfig.Theme);
} else {
@ -4979,16 +5180,16 @@ finish:
ThemePath = NULL;
}
if (ThemeDir != NULL) {
ThemeDir->Close (ThemeDir);
ThemeDir = NULL;
if (ThemeX.ThemeDir != NULL) {
ThemeX.ThemeDir->Close(ThemeX.ThemeDir);
ThemeX.ThemeDir = NULL;
}
// ThemeX.GetThemeTagSettings(NULL); already done
//fill some fields
ThemeX.Font = FONT_ALFA; //to be inverted later. At start we have FONT_GRAY
ThemeX.embedded = true;
Status = StartupSoundPlay(ThemeDir, NULL);
Status = StartupSoundPlay(ThemeX.ThemeDir, NULL);
} else { // theme loaded successfully
ThemeX.embedded = false;
ThemeX.Theme.takeValueFrom(GlobalConfig.Theme);
@ -5007,12 +5208,12 @@ finish:
FreeTag(ThemeDict);
if (!DayLight) {
Status = StartupSoundPlay(ThemeDir, L"sound_night.wav");
Status = StartupSoundPlay(ThemeX.ThemeDir, L"sound_night.wav");
if (EFI_ERROR(Status)) {
Status = StartupSoundPlay(ThemeDir, L"sound.wav");
Status = StartupSoundPlay(ThemeX.ThemeDir, L"sound.wav");
}
} else {
Status = StartupSoundPlay(ThemeDir, L"sound.wav");
Status = StartupSoundPlay(ThemeX.ThemeDir, L"sound.wav");
}
}

View File

@ -50,7 +50,14 @@
#endif
//the function is not in the class and deals always with MainMenu
#if USE_XTHEME
//I made args as pointers to have an ability to call with NULL
BOOLEAN AddLegacyEntry(IN const XStringW* FullTitle, IN const XStringW* LoaderTitle, IN REFIT_VOLUME *Volume, IN const XImage* Image, IN const XImage* DriveImage, IN CHAR16 Hotkey, IN BOOLEAN CustomEntry)
#else
BOOLEAN AddLegacyEntry(IN CONST CHAR16 *FullTitle, IN CONST CHAR16 *LoaderTitle, IN REFIT_VOLUME *Volume, IN EG_IMAGE *Image, IN EG_IMAGE *DriveImage, IN CHAR16 Hotkey, IN BOOLEAN CustomEntry)
#endif
{
LEGACY_ENTRY *Entry, *SubEntry;
REFIT_MENU_SCREEN *SubScreen;
@ -103,6 +110,19 @@ BOOLEAN AddLegacyEntry(IN CONST CHAR16 *FullTitle, IN CONST CHAR16 *LoaderTitle,
Custom = Custom->Next;
}
}
#if USE_XTHEME
XStringW LTitle;
if (!LoaderTitle) {
if (Volume->LegacyOS->Name != NULL) {
LTitle.takeValueFrom(Volume->LegacyOS->Name);
if (Volume->LegacyOS->Name[0] == 'W' || Volume->LegacyOS->Name[0] == 'L')
ShortcutLetter = Volume->LegacyOS->Name[0];
} else
LTitle = L"Legacy OS"_XSW;
} else
LTitle = *LoaderTitle;
#else
if (LoaderTitle == NULL) {
if (Volume->LegacyOS->Name != NULL) {
LoaderTitle = Volume->LegacyOS->Name;
@ -112,32 +132,38 @@ BOOLEAN AddLegacyEntry(IN CONST CHAR16 *FullTitle, IN CONST CHAR16 *LoaderTitle,
LoaderTitle = EfiStrDuplicate( L"Legacy OS");
// DBG("LoaderTitle=%ls\n", LoaderTitle);
}
#endif
if (Volume->VolName != NULL)
VolDesc = Volume->VolName;
else
VolDesc = (Volume->DiskKind == DISK_KIND_OPTICAL) ? L"CD" : L"HD";
//DBG("VolDesc=%ls\n", VolDesc);
// prepare the menu entry
// Entry = (__typeof__(Entry))AllocateZeroPool(sizeof(LEGACY_ENTRY));
Entry = new LEGACY_ENTRY();
#if USE_XTHEME
if (FullTitle) {
Entry->Title = *FullTitle;
} else {
if (ThemeX.BootCampStyle) {
Entry->Title = LTitle;
} else {
Entry->Title = L"Boot "_XSW + *LoaderTitle + L" from "_XSW + VolDesc;
// Entry->Title.SWPrintf("Boot %ls from %ls", LoaderTitle->wc_str(), VolDesc);
}
}
#else
if (FullTitle) {
Entry->Title.takeValueFrom(FullTitle);
} else {
#if USE_XTHEME
if (ThemeX.BootCampStyle) {
Entry->Title.takeValueFrom(LoaderTitle);
} else {
Entry->Title.SWPrintf("Boot %ls from %ls", LoaderTitle, VolDesc);
}
#else
if (GlobalConfig.BootCampStyle) {
Entry->Title.takeValueFrom(LoaderTitle);
} else {
Entry->Title.SWPrintf("Boot %ls from %ls", LoaderTitle, VolDesc);
}
}
#endif
}
// DBG("Title=%ls\n", Entry->Title);
// Entry->Tag = TAG_LEGACY;
Entry->Row = 0;
@ -145,17 +171,12 @@ BOOLEAN AddLegacyEntry(IN CONST CHAR16 *FullTitle, IN CONST CHAR16 *LoaderTitle,
#if USE_XTHEME
if (Image) {
Entry->Image.FromEGImage(Image);
Entry->Image = *Image;
} else {
// UINTN Size = StrLen(Volume->LegacyOS->IconName) + 1;
// CHAR8 *IconName = (__typeof__(IconName))AllocateZeroPool(Size);
// UnicodeStrToAsciiStrS(Volume->LegacyOS->IconName, IconName, Size - 1);
//
// Entry->Image = ThemeX.GetIcon(IconName);
//
// FreePool(IconName);
Entry->Image = ThemeX.GetIcon(XString().takeValueFrom(Volume->LegacyOS->IconName));
if (Entry->Image.isEmpty()) {
Entry->Image = ThemeX.GetIcon("vol_internal"); //we have no legacy.png
}
}
#else
if (Image) {
@ -166,7 +187,12 @@ BOOLEAN AddLegacyEntry(IN CONST CHAR16 *FullTitle, IN CONST CHAR16 *LoaderTitle,
#endif
// DBG("IconName=%ls\n", Volume->LegacyOS->IconName);
Entry->DriveImage = (DriveImage != NULL) ? DriveImage : ScanVolumeDefaultIcon(Volume, Volume->LegacyOS->Type, Volume->DevicePath);
#if USE_XTHEME
Entry->DriveImage = (DriveImage != NULL) ? *DriveImage : ScanVolumeDefaultIcon(Volume, Volume->LegacyOS->Type, Volume->DevicePath);
#else
Entry->DriveImage = (DriveImage != NULL) ? DriveImage : ScanVolumeDefaultIcon(Volume, Volume->LegacyOS->Type, Volume->DevicePath);
#endif
// DBG("HideBadges=%d Volume=%ls\n", GlobalConfig.HideBadges, Volume->VolName);
// DBG("Title=%ls OSName=%ls OSIconName=%ls\n", LoaderTitle, Volume->OSName, Volume->OSIconName);
//actions
@ -176,9 +202,9 @@ BOOLEAN AddLegacyEntry(IN CONST CHAR16 *FullTitle, IN CONST CHAR16 *LoaderTitle,
#if USE_XTHEME
if (ThemeX.HideBadges & HDBADGES_SHOW) {
if (ThemeX.HideBadges & HDBADGES_SWAP) {
Entry->BadgeImage = egCopyScaledImage(Entry->DriveImage, ThemeX.BadgeScale);
Entry->BadgeImage = XImage(Entry->DriveImage, ThemeX.BadgeScale/16.f);
} else {
Entry->BadgeImage = egCopyScaledImage((Entry->Image).ToEGImage(), ThemeX.BadgeScale);
Entry->BadgeImage = XImage(Entry->Image, ThemeX.BadgeScale/16.f);
}
}
#else
@ -197,7 +223,8 @@ BOOLEAN AddLegacyEntry(IN CONST CHAR16 *FullTitle, IN CONST CHAR16 *LoaderTitle,
// SubScreen = (__typeof__(SubScreen))AllocateZeroPool(sizeof(REFIT_MENU_SCREEN));
SubScreen = new REFIT_MENU_SCREEN();
#if USE_XTHEME
SubScreen->Title.SWPrintf("Boot Options for %ls on %ls", LoaderTitle, VolDesc);
SubScreen->Title = L"Boot Options for "_XSW + *LoaderTitle + L" on "_XSW + VolDesc;
// SubScreen->Title.SWPrintf("Boot Options for %ls on %ls", LoaderTitle, VolDesc);
#else
SubScreen->Title = PoolPrint(L"Boot Options for %s on %s", LoaderTitle, VolDesc);
#endif
@ -206,7 +233,11 @@ BOOLEAN AddLegacyEntry(IN CONST CHAR16 *FullTitle, IN CONST CHAR16 *LoaderTitle,
// default entry
// SubEntry = (__typeof__(SubEntry))AllocateZeroPool(sizeof(LEGACY_ENTRY));
SubEntry = new LEGACY_ENTRY();
#if USE_XTHEME
SubEntry->Title = L"Boot "_XSW + *LoaderTitle;
#else
SubEntry->Title.SWPrintf("Boot %ls", LoaderTitle);
#endif
// SubEntry->Tag = TAG_LEGACY;
SubEntry->Volume = Entry->Volume;
SubEntry->DevicePathString = Entry->DevicePathString;
@ -307,7 +338,12 @@ VOID AddCustomLegacy(VOID)
BOOLEAN ShowVolume, HideIfOthersFound;
REFIT_VOLUME *Volume;
CUSTOM_LEGACY_ENTRY *Custom;
#if USE_XTHEME
XImage Image;
XImage DriveImage;
#else
EG_IMAGE *Image, *DriveImage;
#endif
UINTN i = 0;
// DBG("Custom legacy start\n");
@ -408,6 +444,12 @@ VOID AddCustomLegacy(VOID)
}
// Change to custom image if needed
Image = Custom->Image;
#if USE_XTHEME
if (Image.isEmpty()) {
Image.LoadXImage(ThemeX.ThemeDir, Custom->ImagePath);
}
#else
if ((Image == NULL) && Custom->ImagePath) {
Image = egLoadImage(Volume->RootDir, Custom->ImagePath, TRUE);
if (Image == NULL) {
@ -417,22 +459,25 @@ VOID AddCustomLegacy(VOID)
if (Image == NULL) {
Image = egLoadImage(SelfRootDir, Custom->ImagePath, TRUE);
if (Image == NULL) {
#if USE_XTHEME
XImage ImageX;
ImageX.LoadXImage(ThemeDir, "unknown");
Image = ImageX.ToEGImage();
#else
Image = LoadOSIcon(Custom->ImagePath, L"unknown", 128, FALSE, FALSE);
#endif
}
}
}
}
}
#endif
// Change to custom drive image if needed
DriveImage = Custom->DriveImage;
#if USE_XTHEME
if (DriveImage.isEmpty()) {
DriveImage.LoadXImage(ThemeX.ThemeDir, Custom->DriveImagePath);
}
// Create a legacy entry for this volume
if (AddLegacyEntry(&Custom->FullTitle, &Custom->Title, Volume, &Image, &DriveImage, Custom->Hotkey, TRUE))
{
DBG("match!\n");
}
#else
if ((DriveImage == NULL) && Custom->DriveImagePath) {
DriveImage = egLoadImage(Volume->RootDir, Custom->DriveImagePath, TRUE);
if (DriveImage == NULL) {
@ -453,6 +498,7 @@ VOID AddCustomLegacy(VOID)
{
DBG("match!\n");
}
#endif
}
}
//DBG("Custom legacy end\n");

View File

@ -407,11 +407,11 @@ STATIC EFI_STATUS GetOSXVolumeName(LOADER_ENTRY *Entry)
#if USE_XTHEME
STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST CHAR16 *LoaderPath,
IN CONST CHAR16 *LoaderOptions,
IN CONST CHAR16 *FullTitle,
IN CONST CHAR16 *LoaderTitle,
IN CONST XStringW& FullTitle,
IN CONST XStringW& LoaderTitle,
IN REFIT_VOLUME *Volume,
IN EG_IMAGE *Image,
IN EG_IMAGE *DriveImage,
IN XImage *Image,
IN XImage *DriveImage,
IN UINT8 OSType,
IN UINT8 Flags,
IN CHAR16 Hotkey,
@ -444,9 +444,8 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST CHAR16 *LoaderPath,
CONST CHAR16 *LoaderDevicePathString;
CONST CHAR16 *FilePathAsString;
CONST CHAR16 *OSIconName;
//CHAR16 IconFileName[256]; Sothor - Unused?
CHAR16 ShortcutLetter;
LOADER_ENTRY *Entry;
CHAR16 ShortcutLetter;
LOADER_ENTRY *Entry;
CONST CHAR8 *indent = " ";
// Check parameters are valid
@ -538,7 +537,7 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST CHAR16 *LoaderPath,
if (volume_match == -1 || volume_type_match == -1 || path_match == -1 || type_match == -1 ) {
UINTN add_comma = 0;
DBG ("%sNot match custom entry %llu: ", indent, CustomIndex);
DBG ("%sNot match custom entry %llu: ", indent, CustomIndex);
if (volume_match != 0) {
DBG("Volume: %ls", volume_match == 1 ? L"match" : L"not match");
add_comma++;
@ -563,7 +562,7 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST CHAR16 *LoaderPath,
DBG("\n");
} else {
// Custom entry match
DBG("%sSkipped because matching custom entry %llu!\n", indent, CustomIndex);
DBG("%sSkipped because matching custom entry %llu!\n", indent, CustomIndex);
FreePool(LoaderDevicePathString);
return NULL;
}
@ -664,23 +663,65 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST CHAR16 *LoaderPath,
break;
}
#if USE_XTHEME
Entry->Title = FullTitle;
if (Entry->Title.isEmpty() && Volume->VolLabel != NULL) {
if (Volume->VolLabel[0] == L'#') {
Entry->Title.SWPrintf("Boot %ls from %ls", (!LoaderTitle.isEmpty()) ? LoaderTitle.wc_str() : Basename(LoaderPath), Volume->VolLabel+1);
}else{
Entry->Title.SWPrintf("Boot %ls from %ls", (!LoaderTitle.isEmpty()) ? LoaderTitle.wc_str() : Basename(LoaderPath), Volume->VolLabel);
}
}
BOOLEAN BootCampStyle = ThemeX.BootCampStyle;
#else
if (FullTitle) {
Entry->Title.takeValueFrom(FullTitle);
}
if ( Entry->Title.isEmpty() && Volume->VolLabel != NULL ) {
if ( Volume->VolLabel[0] == L'#' ) {
Entry->Title.SWPrintf("Boot %ls from %ls", (LoaderTitle != NULL) ? LoaderTitle : Basename(LoaderPath), Volume->VolLabel+1);
Entry->Title.SWPrintf("Boot %ls from %ls", (LoaderTitle != NULL) ? LoaderTitle : Basename(LoaderPath), Volume->VolLabel+1);
}else{
Entry->Title.SWPrintf("Boot %ls from %ls", (LoaderTitle != NULL) ? LoaderTitle : Basename(LoaderPath), Volume->VolLabel);
Entry->Title.SWPrintf("Boot %ls from %ls", (LoaderTitle != NULL) ? LoaderTitle : Basename(LoaderPath), Volume->VolLabel);
}
}
#if USE_XTHEME
BOOLEAN BootCampStyle = ThemeX.BootCampStyle;
#else
BOOLEAN BootCampStyle = GlobalConfig.BootCampStyle;
#endif
#if USE_XTHEME
if ( Entry->Title.isEmpty() && ((Entry->VolName == NULL) || (StrLen(Entry->VolName) == 0)) ) {
//DBG("encounter Entry->VolName ==%ls and StrLen(Entry->VolName) ==%d\n",Entry->VolName, StrLen(Entry->VolName));
if (BootCampStyle) {
if (!LoaderTitle.isEmpty()) {
Entry->Title = LoaderTitle;
} else {
Entry->Title.takeValueFrom(Basename(Volume->DevicePathString));
}
} else {
Entry->Title.SWPrintf("Boot %ls from %ls", (!LoaderTitle.isEmpty()) ? LoaderTitle.wc_str() : Basename(LoaderPath),
Basename(Volume->DevicePathString));
}
}
if ( Entry->Title.isEmpty() ) {
//DBG("encounter LoaderTitle ==%ls and Entry->VolName ==%ls\n", LoaderTitle, Entry->VolName);
if (BootCampStyle) {
if ((StriCmp(LoaderTitle.wc_str(), L"macOS") == 0) || (StriCmp(LoaderTitle.wc_str(), L"Recovery") == 0)) {
Entry->Title.takeValueFrom(Entry->VolName);
} else {
if (!LoaderTitle.isEmpty()) {
Entry->Title = LoaderTitle;
} else {
Entry->Title.takeValueFrom(Basename(LoaderPath));
}
}
} else {
Entry->Title.SWPrintf("Boot %ls from %ls", (!LoaderTitle.isEmpty()) ? LoaderTitle.wc_str() : Basename(LoaderPath),
Entry->VolName);
}
}
#else
if ( Entry->Title.isEmpty() && ((Entry->VolName == NULL) || (StrLen(Entry->VolName) == 0)) ) {
//DBG("encounter Entry->VolName ==%ls and StrLen(Entry->VolName) ==%d\n",Entry->VolName, StrLen(Entry->VolName));
if (BootCampStyle) {
@ -703,6 +744,7 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST CHAR16 *LoaderPath,
Entry->VolName);
}
}
#endif
//DBG("Entry->Title =%ls\n", Entry->Title);
// just an example that UI can show hibernated volume to the user
// should be better to show it on entry image
@ -718,11 +760,18 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST CHAR16 *LoaderPath,
Entry->Image.LoadIcns(Volume->RootDir, L"\\.VolumeIcon.icns", 128);
DBG("using VolumeIcon.icns image from Volume\n");
} else if (Image) {
Entry->Image.FromEGImage(Image);
Entry->Image = *Image;
} else {
// Entry->Image = ThemeX.GetIcon("unknown"); //no such icon
Entry->Image = ThemeX.GetIcon("vol_internal");
}
// Load DriveImage
if (DriveImage) {
Entry->DriveImage = *DriveImage;
} else {
//TODO ->
Entry->DriveImage.FromEGImage(ScanVolumeDefaultIcon(Volume, Entry->LoaderType, Volume->DevicePath));
}
#else
if (GlobalConfig.CustomIcons && FileExists(Volume->RootDir, L"\\.VolumeIcon.icns")){
Entry->Image = LoadIcns(Volume->RootDir, L"\\.VolumeIcon.icns", 128);
@ -732,19 +781,21 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST CHAR16 *LoaderPath,
} else {
Entry->Image = LoadOSIcon(OSIconName, L"unknown", 128, FALSE, TRUE);
}
#endif
// Load DriveImage
Entry->DriveImage = (DriveImage != NULL) ? DriveImage : ScanVolumeDefaultIcon(Volume, Entry->LoaderType, Volume->DevicePath);
#endif
// DBG("HideBadges=%d Volume=%ls ", GlobalConfig.HideBadges, Volume->VolName);
#if USE_XTHEME
if (ThemeX.HideBadges & HDBADGES_SHOW) {
if (ThemeX.HideBadges & HDBADGES_SWAP) {
Entry->BadgeImage = egCopyScaledImage(Entry->DriveImage, ThemeX.BadgeScale);
// Entry->BadgeImage = egCopyScaledImage(Entry->DriveImage, ThemeX.BadgeScale);
Entry->BadgeImage = XImage(Entry->DriveImage, ThemeX.BadgeScale/16.f);
// DBG(" Show badge as Drive.");
} else {
Entry->BadgeImage = egCopyScaledImage((Entry->Image).ToEGImage(), ThemeX.BadgeScale);
Entry->BadgeImage = XImage(Entry->Image, ThemeX.BadgeScale/16.f);
// Entry->BadgeImage = egCopyScaledImage((Entry->Image).ToEGImage(), ThemeX.BadgeScale);
// DBG(" Show badge as OSImage.");
}
}
@ -1022,11 +1073,17 @@ STATIC VOID AddDefaultMenu(IN LOADER_ENTRY *Entry)
Entry->SubScreen = SubScreen;
// DBG(" Added '%ls': OSType='%d', OSVersion='%s'\n", Entry->Title, Entry->LoaderType, Entry->OSVersion);
}
#if USE_XTHEME
BOOLEAN AddLoaderEntry(IN CONST CHAR16 *LoaderPath, IN CONST CHAR16 *LoaderOptions,
IN CONST XStringW& LoaderTitle,
IN REFIT_VOLUME *Volume, IN XImage *Image,
IN UINT8 OSType, IN UINT8 Flags)
#else
STATIC BOOLEAN AddLoaderEntry(IN CONST CHAR16 *LoaderPath, IN CONST CHAR16 *LoaderOptions,
IN CONST CHAR16 *LoaderTitle,
IN REFIT_VOLUME *Volume, IN EG_IMAGE *Image,
IN UINT8 OSType, IN UINT8 Flags)
#endif
{
LOADER_ENTRY *Entry;
INTN HVi;
@ -1054,7 +1111,7 @@ STATIC BOOLEAN AddLoaderEntry(IN CONST CHAR16 *LoaderPath, IN CONST CHAR16 *Load
}
}
#if USE_XTHEME
Entry = CreateLoaderEntry(LoaderPath, LoaderOptions, NULL, LoaderTitle, Volume, Image, NULL, OSType, Flags, 0, MenuBackgroundPixel, CUSTOM_BOOT_DISABLED, NULL, NULL, FALSE);
Entry = CreateLoaderEntry(LoaderPath, LoaderOptions, L""_XSW, LoaderTitle, Volume, Image, NULL, OSType, Flags, 0, MenuBackgroundPixel, CUSTOM_BOOT_DISABLED, NULL, NULL, FALSE);
#else
Entry = CreateLoaderEntry(LoaderPath, LoaderOptions, NULL, LoaderTitle, Volume, Image, NULL, OSType, Flags, 0, NULL, CUSTOM_BOOT_DISABLED, NULL, NULL, FALSE);
#endif
@ -1093,9 +1150,9 @@ CHAR16 APFSInstallBootPath[67] = L"\\00000000-0000-0000-0000-000000000000\\com.
VOID AddPRSEntry(REFIT_VOLUME *Volume)
{
INTN WhatBoot = 0;
// CONST INTN Paper = 1;
// CONST INTN Rock = 2;
// CONST INTN Scissor = 4;
//CONST INTN Paper = 1;
//CONST INTN Rock = 2;
//CONST INTN Scissor = 4;
WhatBoot |= FileExists(Volume->RootDir, RockBoot)?Rock:0;
WhatBoot |= FileExists(Volume->RootDir, PaperBoot)?Paper:0;
@ -1103,16 +1160,31 @@ VOID AddPRSEntry(REFIT_VOLUME *Volume)
switch (WhatBoot) {
case Paper:
case (Paper | Rock):
#if USE_XTHEME
AddLoaderEntry(PaperBoot, L""_XSW, L"macOS InstallP"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0);
#else
AddLoaderEntry(PaperBoot, NULL, L"macOS InstallP", Volume, NULL, OSTYPE_OSX_INSTALLER, 0);
#endif
break;
case Scissor:
case (Paper | Scissor):
#if USE_XTHEME
AddLoaderEntry(ScissorBoot, L""_XSW, L"macOS InstallS"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0);
#else
AddLoaderEntry(ScissorBoot, NULL, L"macOS InstallS", Volume, NULL, OSTYPE_OSX_INSTALLER, 0);
#endif
break;
case Rock:
case (Rock | Scissor):
case (Rock | Scissor | Paper):
#if USE_XTHEME
AddLoaderEntry(RockBoot, L""_XSW, L"macOS InstallR"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0);
#else
AddLoaderEntry(RockBoot, NULL, L"macOS InstallR", Volume, NULL, OSTYPE_OSX_INSTALLER, 0);
#endif
break;
default:
@ -1165,13 +1237,40 @@ VOID ScanLoader(VOID)
if (FileExists(Volume->RootDir, L"\\Install OS X Mavericks.app") ||
FileExists(Volume->RootDir, L"\\Install OS X Yosemite.app") ||
FileExists(Volume->RootDir, L"\\Install OS X El Capitan.app")) {
#if USE_XTHEME
AddLoaderEntry(L"\\.IABootFiles\\boot.efi", L""_XSW, L"OS X Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.9 - 10.11
#else
AddLoaderEntry(L"\\.IABootFiles\\boot.efi", NULL, L"OS X Install", Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.9 - 10.11
#endif
} else {
#if USE_XTHEME
AddLoaderEntry(L"\\.IABootFiles\\boot.efi", L""_XSW, L"macOS Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.12 - 10.13.3
#else
AddLoaderEntry(L"\\.IABootFiles\\boot.efi", NULL, L"macOS Install", Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.12 - 10.13.3
#endif
}
} else if (FileExists(Volume->RootDir, L"\\.IAPhysicalMedia") && FileExists(Volume->RootDir, MACOSX_LOADER_PATH)) {
#if USE_XTHEME
AddLoaderEntry(MACOSX_LOADER_PATH, L""_XSW, L"macOS Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.13.4+
#else
AddLoaderEntry(MACOSX_LOADER_PATH, NULL, L"macOS Install", Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.13.4+
#endif
}
#if USE_XTHEME
// 2nd stage - InstallESD/AppStore/startosinstall/Fusion Drive
AddLoaderEntry(L"\\Mac OS X Install Data\\boot.efi", L""_XSW, L"Mac OS X Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.7
AddLoaderEntry(L"\\OS X Install Data\\boot.efi", L""_XSW, L"OS X Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.8 - 10.11
AddLoaderEntry(L"\\macOS Install Data\\boot.efi", L""_XSW, L"macOS Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.12 - 10.12.3
AddLoaderEntry(L"\\macOS Install Data\\Locked Files\\Boot Files\\boot.efi", L""_XSW, L"macOS Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.12.4+
AddPRSEntry(Volume); // 10.12+
// Netinstall
AddLoaderEntry(L"\\NetInstall macOS High Sierra.nbi\\i386\\booter", L""_XSW, L"macOS Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0);
#else
// 2nd stage - InstallESD/AppStore/startosinstall/Fusion Drive
AddLoaderEntry(L"\\Mac OS X Install Data\\boot.efi", NULL, L"Mac OS X Install", Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.7
AddLoaderEntry(L"\\OS X Install Data\\boot.efi", NULL, L"OS X Install", Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.8 - 10.11
@ -1181,9 +1280,52 @@ VOID ScanLoader(VOID)
// Netinstall
AddLoaderEntry(L"\\NetInstall macOS High Sierra.nbi\\i386\\booter", NULL, L"macOS Install", Volume, NULL, OSTYPE_OSX_INSTALLER, 0);
#endif
// Use standard location for boot.efi, according to the install files is present
// That file indentifies a DVD/ESD/BaseSystem/Fusion Drive Install Media, so when present, check standard path to avoid entry duplication
#if USE_XTHEME
if (FileExists(Volume->RootDir, MACOSX_LOADER_PATH)) {
if (FileExists(Volume->RootDir, L"\\System\\Installation\\CDIS\\Mac OS X Installer.app")) {
// InstallDVD/BaseSystem
AddLoaderEntry(MACOSX_LOADER_PATH, L""_XSW, L"Mac OS X Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.6/10.7
} else if (FileExists(Volume->RootDir, L"\\System\\Installation\\CDIS\\OS X Installer.app")) {
// BaseSystem
AddLoaderEntry(MACOSX_LOADER_PATH, L""_XSW, L"OS X Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.8 - 10.11
} else if (FileExists(Volume->RootDir, L"\\System\\Installation\\CDIS\\macOS Installer.app")) {
// BaseSystem
AddLoaderEntry(MACOSX_LOADER_PATH, L""_XSW, L"macOS Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.12+
} else if (FileExists(Volume->RootDir, L"\\BaseSystem.dmg") && FileExists(Volume->RootDir, L"\\mach_kernel")) {
// InstallESD
if (FileExists(Volume->RootDir, L"\\MacOSX_Media_Background.png")) {
AddLoaderEntry(MACOSX_LOADER_PATH, L""_XSW, L"Mac OS X Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.7
} else {
AddLoaderEntry(MACOSX_LOADER_PATH, L""_XSW, L"OS X Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.8
}
} else if (FileExists(Volume->RootDir, L"\\com.apple.boot.R\\System\\Library\\PrelinkedKernels\\prelinkedkernel") ||
FileExists(Volume->RootDir, L"\\com.apple.boot.P\\System\\Library\\PrelinkedKernels\\prelinkedkernel") ||
FileExists(Volume->RootDir, L"\\com.apple.boot.S\\System\\Library\\PrelinkedKernels\\prelinkedkernel")) {
if (StriStr(Volume->VolName, L"Recovery") != NULL) {
// FileVault of HFS+
// TODO: need info for 10.11 and lower
AddLoaderEntry(MACOSX_LOADER_PATH, L""_XSW, L"macOS FileVault"_XSW, Volume, NULL, OSTYPE_OSX, 0); // 10.12+
} else {
// Fusion Drive
AddLoaderEntry(MACOSX_LOADER_PATH, L""_XSW, L"OS X Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.11
}
} else if (!FileExists(Volume->RootDir, L"\\.IAPhysicalMedia")) {
// Installed
if (EFI_ERROR(GetRootUUID(Volume)) || isFirstRootUUID(Volume)) {
if (!FileExists(Volume->RootDir, L"\\System\\Library\\CoreServices\\NotificationCenter.app") && !FileExists(Volume->RootDir, L"\\System\\Library\\CoreServices\\Siri.app")) {
AddLoaderEntry(MACOSX_LOADER_PATH, L""_XSW, L"Mac OS X"_XSW, Volume, NULL, OSTYPE_OSX, 0); // 10.6 - 10.7
} else if (FileExists(Volume->RootDir, L"\\System\\Library\\CoreServices\\NotificationCenter.app") && !FileExists(Volume->RootDir, L"\\System\\Library\\CoreServices\\Siri.app")) {
AddLoaderEntry(MACOSX_LOADER_PATH, L""_XSW, L"OS X"_XSW, Volume, NULL, OSTYPE_OSX, 0); // 10.8 - 10.11
} else {
AddLoaderEntry(MACOSX_LOADER_PATH, L""_XSW, L"macOS"_XSW, Volume, NULL, OSTYPE_OSX, 0); // 10.12+
}
}
}
}
#else
if (FileExists(Volume->RootDir, MACOSX_LOADER_PATH)) {
if (FileExists(Volume->RootDir, L"\\System\\Installation\\CDIS\\Mac OS X Installer.app")) {
// InstallDVD/BaseSystem
@ -1225,7 +1367,7 @@ VOID ScanLoader(VOID)
}
}
}
#endif
/* APFS Container support.
* s.mtr 2017
*/
@ -1237,16 +1379,45 @@ VOID ScanLoader(VOID)
StrnCpy(APFSFVBootPath + 1, CurrentUUID, 36);
StrnCpy(APFSRecBootPath + 1, CurrentUUID, 36);
StrnCpy(APFSInstallBootPath + 1, CurrentUUID, 36);
#if USE_XTHEME
//Try to add FileVault entry
AddLoaderEntry(APFSFVBootPath, L""_XSW, L"FileVault Prebooter"_XSW, Volume, NULL, OSTYPE_OSX, 0);
//Try to add Recovery APFS entry
AddLoaderEntry(APFSRecBootPath, L""_XSW, L"Recovery"_XSW, Volume, NULL, OSTYPE_RECOVERY, 0);
//Try to add macOS install entry
AddLoaderEntry(APFSInstallBootPath, L""_XSW, L"macOS Install Prebooter"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0);
#else
//Try to add FileVault entry
AddLoaderEntry(APFSFVBootPath, NULL, L"FileVault Prebooter", Volume, NULL, OSTYPE_OSX, 0);
//Try to add Recovery APFS entry
AddLoaderEntry(APFSRecBootPath, NULL, L"Recovery", Volume, NULL, OSTYPE_RECOVERY, 0);
//Try to add macOS install entry
AddLoaderEntry(APFSInstallBootPath, NULL, L"macOS Install Prebooter", Volume, NULL, OSTYPE_OSX_INSTALLER, 0);
#endif
FreePool(CurrentUUID);
}
}
#if USE_XTHEME
// check for Mac OS X Recovery Boot
AddLoaderEntry(L"\\com.apple.recovery.boot\\boot.efi", L""_XSW, L"Recovery"_XSW, Volume, NULL, OSTYPE_RECOVERY, 0);
// Sometimes, on some systems (HP UEFI, if Win is installed first)
// it is needed to get rid of bootmgfw.efi to allow starting of
// Clover as /efi/boot/bootx64.efi from HD. We can do that by renaming
// bootmgfw.efi to bootmgfw-orig.efi
AddLoaderEntry(L"\\EFI\\microsoft\\Boot\\bootmgfw-orig.efi", L""_XSW, L"Microsoft EFI"_XSW, Volume, NULL, OSTYPE_WINEFI, 0);
// check for Microsoft boot loader/menu
// If there is bootmgfw-orig.efi, then do not check for bootmgfw.efi
// since on some systems this will actually be CloverX64.efi
// renamed to bootmgfw.efi
AddLoaderEntry(L"\\EFI\\microsoft\\Boot\\bootmgfw.efi", L""_XSW, L"Microsoft EFI Boot"_XSW, Volume, NULL, OSTYPE_WINEFI, 0);
// check for Microsoft boot loader/menu. This entry is redundant so excluded
// AddLoaderEntry(L"\\bootmgr.efi", L"", L"Microsoft EFI mgrboot", Volume, NULL, OSTYPE_WINEFI, 0);
// check for Microsoft boot loader/menu on CDROM
if (!AddLoaderEntry(L"\\EFI\\MICROSOFT\\BOOT\\cdboot.efi", L""_XSW, L"Microsoft EFI cdboot"_XSW, Volume, NULL, OSTYPE_WINEFI, 0)) {
AddLoaderEntry(L"\\EFI\\MICROSOF\\BOOT\\CDBOOT.EFI", L""_XSW, L"Microsoft EFI CDBOOT"_XSW, Volume, NULL, OSTYPE_WINEFI, 0);
}
#else
// check for Mac OS X Recovery Boot
AddLoaderEntry(L"\\com.apple.recovery.boot\\boot.efi", NULL, L"Recovery", Volume, NULL, OSTYPE_RECOVERY, 0);
@ -1266,7 +1437,7 @@ VOID ScanLoader(VOID)
if (!AddLoaderEntry(L"\\EFI\\MICROSOFT\\BOOT\\cdboot.efi", L"", L"Microsoft EFI cdboot", Volume, NULL, OSTYPE_WINEFI, 0)) {
AddLoaderEntry(L"\\EFI\\MICROSOF\\BOOT\\CDBOOT.EFI", L"", L"Microsoft EFI CDBOOT", Volume, NULL, OSTYPE_WINEFI, 0);
}
#endif
#if defined(ANDX86)
if (TRUE) { //gSettings.AndroidScan
// check for Android loaders
@ -1280,9 +1451,9 @@ VOID ScanLoader(VOID)
if (aFound && (aFound == aIndex)) {
#if USE_XTHEME
XImage ImageX;
ImageX.LoadXImage(ThemeDir, AndroidEntryData[Index].Icon);
AddLoaderEntry(AndroidEntryData[Index].Path, L"", AndroidEntryData[Index].Title, Volume,
ImageX.ToEGImage(), OSTYPE_LIN, OSFLAG_NODEFAULTARGS);
ImageX.LoadXImage(ThemeX.ThemeDir, AndroidEntryData[Index].Icon);
AddLoaderEntry(AndroidEntryData[Index].Path, L""_XSW, XStringW().takeValueFrom(AndroidEntryData[Index].Title), Volume,
&ImageX, OSTYPE_LIN, OSFLAG_NODEFAULTARGS);
#else
AddLoaderEntry(AndroidEntryData[Index].Path, L"", AndroidEntryData[Index].Title, Volume,
LoadOSIcon(AndroidEntryData[Index].Icon, L"unknown", 128, FALSE, TRUE), OSTYPE_LIN, OSFLAG_NODEFAULTARGS);
@ -1298,9 +1469,9 @@ VOID ScanLoader(VOID)
for (Index = 0; Index < LinuxEntryDataCount; ++Index) {
#if USE_XTHEME
XImage ImageX;
ImageX.LoadXImage(ThemeDir, LinuxEntryData[Index].Icon);
AddLoaderEntry(LinuxEntryData[Index].Path, L"", LinuxEntryData[Index].Title, Volume,
ImageX.ToEGImage(), OSTYPE_LIN, OSFLAG_NODEFAULTARGS);
ImageX.LoadXImage(ThemeX.ThemeDir, LinuxEntryData[Index].Icon);
AddLoaderEntry(LinuxEntryData[Index].Path, L""_XSW, XStringW().takeValueFrom(LinuxEntryData[Index].Title), Volume,
&ImageX, OSTYPE_LIN, OSFLAG_NODEFAULTARGS);
#else
AddLoaderEntry(LinuxEntryData[Index].Path, L"", LinuxEntryData[Index].Title, Volume,
LoadOSIcon(LinuxEntryData[Index].Icon, L"unknown", 128, FALSE, TRUE), OSTYPE_LIN, OSFLAG_NODEFAULTARGS);
@ -1337,7 +1508,13 @@ VOID ScanLoader(VOID)
if (Path != NULL) {
Options = LinuxKernelOptions(Iter.DirHandle, Basename(Path) + StrLen(LINUX_LOADER_PATH), PartUUID, NULL);
// Add the entry
#if USE_XTHEME
AddLoaderEntry(Path, (Options == NULL) ? LINUX_DEFAULT_OPTIONS : XStringW().takeValueFrom(Options), L""_XSW, Volume, NULL, OSTYPE_LINEFI, OSFLAG_NODEFAULTARGS);
#else
AddLoaderEntry(Path, (Options == NULL) ? LINUX_DEFAULT_OPTIONS : Options, NULL, Volume, NULL, OSTYPE_LINEFI, OSFLAG_NODEFAULTARGS);
#endif
if (Options != NULL) {
FreePool(Options);
}
@ -1370,7 +1547,12 @@ VOID ScanLoader(VOID)
if (Path != NULL) {
Options = LinuxKernelOptions(Iter.DirHandle, Basename(Path) + StrLen(LINUX_LOADER_PATH), PartUUID, NULL);
// Add the entry
#if USE_XTHEME
AddLoaderEntry(Path, (Options == NULL) ? LINUX_DEFAULT_OPTIONS : XStringW().takeValueFrom(Options), L""_XSW, Volume, NULL, OSTYPE_LINEFI, OSFLAG_NODEFAULTARGS);
#else
AddLoaderEntry(Path, (Options == NULL) ? LINUX_DEFAULT_OPTIONS : Options, NULL, Volume, NULL, OSTYPE_LINEFI, OSFLAG_NODEFAULTARGS);
#endif
if (Options != NULL) {
FreePool(Options);
}
@ -1400,7 +1582,11 @@ VOID ScanLoader(VOID)
if (Path != NULL) {
Options = LinuxKernelOptions(Iter.DirHandle, Basename(Path) + StrLen(LINUX_LOADER_PATH), PartUUID, NULL);
// Add the entry
#if USE_XTHEME
AddLoaderEntry(Path, (Options == NULL) ? LINUX_DEFAULT_OPTIONS : XStringW().takeValueFrom(Options), L""_XSW, Volume, NULL, OSTYPE_LINEFI, OSFLAG_NODEFAULTARGS);
#else
AddLoaderEntry(Path, (Options == NULL) ? LINUX_DEFAULT_OPTIONS : Options, NULL, Volume, NULL, OSTYPE_LINEFI, OSFLAG_NODEFAULTARGS);
#endif
if (Options != NULL) {
FreePool(Options);
}
@ -1430,7 +1616,11 @@ VOID ScanLoader(VOID)
if (Path != NULL) {
Options = LinuxKernelOptions(Iter.DirHandle, Basename(Path) + StrLen(LINUX_LOADER_PATH), PartUUID, NULL);
// Add the entry
#if USE_XTHEME
AddLoaderEntry(Path, (Options == NULL) ? LINUX_DEFAULT_OPTIONS : XStringW().takeValueFrom(Options), L""_XSW, Volume, NULL, OSTYPE_LINEFI, OSFLAG_NODEFAULTARGS);
#else
AddLoaderEntry(Path, (Options == NULL) ? LINUX_DEFAULT_OPTIONS : Options, NULL, Volume, NULL, OSTYPE_LINEFI, OSFLAG_NODEFAULTARGS);
#endif
if (Options != NULL) {
FreePool(Options);
}
@ -1464,7 +1654,11 @@ VOID ScanLoader(VOID)
if (Path != NULL) {
Options = LinuxKernelOptions(Iter.DirHandle, Basename(Path) + StrLen(LINUX_LOADER_PATH), PartUUID, NULL);
// Add the entry
#if USE_XTHEME
AddLoaderEntry(Path, (Options == NULL) ? LINUX_DEFAULT_OPTIONS : XStringW().takeValueFrom(Options), L""_XSW, Volume, NULL, OSTYPE_LINEFI, OSFLAG_NODEFAULTARGS);
#else
AddLoaderEntry(Path, (Options == NULL) ? LINUX_DEFAULT_OPTIONS : Options, NULL, Volume, NULL, OSTYPE_LINEFI, OSFLAG_NODEFAULTARGS);
#endif
if (Options != NULL) {
FreePool(Options);
}
@ -1497,8 +1691,11 @@ VOID ScanLoader(VOID)
}
if (Path != NULL) {
Options = LinuxKernelOptions(Iter.DirHandle, Basename(Path) + StrLen(LINUX_LOADER_PATH), PartUUID, NULL);
// Add the entry
#if USE_XTHEME
AddLoaderEntry(Path, (Options == NULL) ? LINUX_DEFAULT_OPTIONS : XStringW().takeValueFrom(Options), L""_XSW, Volume, NULL, OSTYPE_LINEFI, OSFLAG_NODEFAULTARGS);
#else
AddLoaderEntry(Path, (Options == NULL) ? LINUX_DEFAULT_OPTIONS : Options, NULL, Volume, NULL, OSTYPE_LINEFI, OSFLAG_NODEFAULTARGS);
#endif
if (Options != NULL) {
FreePool(Options);
}
@ -1516,7 +1713,11 @@ VOID ScanLoader(VOID)
if (Path != NULL) {
Options = LinuxKernelOptions(Iter.DirHandle, Basename(Path) + StrLen(LINUX_LOADER_PATH), PartUUID, NULL);
// Add the entry
#if USE_XTHEME
AddLoaderEntry(Path, (Options == NULL) ? LINUX_DEFAULT_OPTIONS : XStringW().takeValueFrom(Options), L""_XSW, Volume, NULL, OSTYPE_LINEFI, OSFLAG_NODEFAULTARGS);
#else
AddLoaderEntry(Path, (Options == NULL) ? LINUX_DEFAULT_OPTIONS : Options, NULL, Volume, NULL, OSTYPE_LINEFI, OSFLAG_NODEFAULTARGS);
#endif
if (Options != NULL) {
FreePool(Options);
}
@ -1539,7 +1740,20 @@ VOID ScanLoader(VOID)
DirIterClose(&Iter);
}
} //if linux scan
#if USE_XTHEME
// DBG("search for optical UEFI\n");
if (Volume->DiskKind == DISK_KIND_OPTICAL) {
AddLoaderEntry(BOOT_LOADER_PATH, L""_XSW, L"UEFI optical"_XSW, Volume, NULL, OSTYPE_OTHER, 0);
}
// DBG("search for internal UEFI\n");
if (Volume->DiskKind == DISK_KIND_INTERNAL) {
AddLoaderEntry(BOOT_LOADER_PATH, L""_XSW, L"UEFI internal"_XSW, Volume, NULL, OSTYPE_OTHER, OSFLAG_HIDDEN);
}
// DBG("search for external UEFI\n");
if (Volume->DiskKind == DISK_KIND_EXTERNAL) {
AddLoaderEntry(BOOT_LOADER_PATH, L""_XSW, L"UEFI external"_XSW, Volume, NULL, OSTYPE_OTHER, OSFLAG_HIDDEN);
}
#else
// DBG("search for optical UEFI\n");
if (Volume->DiskKind == DISK_KIND_OPTICAL) {
AddLoaderEntry(BOOT_LOADER_PATH, L"", L"UEFI optical", Volume, NULL, OSTYPE_OTHER, 0);
@ -1552,12 +1766,13 @@ VOID ScanLoader(VOID)
if (Volume->DiskKind == DISK_KIND_EXTERNAL) {
AddLoaderEntry(BOOT_LOADER_PATH, L"", L"UEFI external", Volume, NULL, OSTYPE_OTHER, OSFLAG_HIDDEN);
}
#endif
}
}
STATIC VOID AddCustomEntry(IN UINTN CustomIndex,
IN CONST CHAR16 *CustomPath,
IN CONST CHAR16 *CustomPath,
IN CUSTOM_LOADER_ENTRY *Custom,
IN REFIT_MENU_SCREEN *SubMenu)
{
@ -1574,23 +1789,34 @@ STATIC VOID AddCustomEntry(IN UINTN CustomIndex,
}
if (FindCustomPath && (Custom->Type != OSTYPE_LINEFI)) {
DBG("Custom %lsentry %llu skipped because it didn't have a ", IsSubEntry ? L"sub " : L"", CustomIndex);
if (Custom->Type == 0) {
DBG("Type.\n");
} else {
DBG("Path.\n");
}
// DBG("Custom %lsentry %llu skipped because it didn't have a ", IsSubEntry ? L"sub " : L"", CustomIndex);
// if (Custom->Type == 0) {
// DBG("Type.\n");
// } else {
// DBG("Path.\n");
// }
return;
}
if (OSFLAG_ISSET(Custom->Flags, OSFLAG_DISABLED)) {
DBG("Custom %lsentry %llu skipped because it is disabled.\n", IsSubEntry ? L"sub " : L"", CustomIndex);
// DBG("Custom %lsentry %llu skipped because it is disabled.\n", IsSubEntry ? L"sub " : L"", CustomIndex);
return;
}
if (!gSettings.ShowHiddenEntries && OSFLAG_ISSET(Custom->Flags, OSFLAG_HIDDEN)) {
DBG("Custom %lsentry %llu skipped because it is hidden.\n", IsSubEntry ? L"sub " : L"", CustomIndex);
// DBG("Custom %lsentry %llu skipped because it is hidden.\n", IsSubEntry ? L"sub " : L"", CustomIndex);
return;
}
#if 0 //if someone want to debug this
#if USE_XTHEME
DBG("Custom %lsentry %llu ", IsSubEntry ? L"sub " : L"", CustomIndex);
// if (Custom->Title) {
DBG("Title:\"%ls\" ", Custom->Title.wc_str());
// }
// if (Custom->FullTitle) {
DBG("FullTitle:\"%ls\" ", Custom->FullTitle.wc_str());
// }
#else
DBG("Custom %lsentry %llu ", IsSubEntry ? L"sub " : L"", CustomIndex);
if (Custom->Title) {
@ -1599,6 +1825,8 @@ STATIC VOID AddCustomEntry(IN UINTN CustomIndex,
if (Custom->FullTitle) {
DBG("FullTitle:\"%ls\" ", Custom->FullTitle);
}
#endif
if (CustomPath) {
DBG("Path:\"%ls\" ", CustomPath);
}
@ -1611,11 +1839,18 @@ STATIC VOID AddCustomEntry(IN UINTN CustomIndex,
} else {
DBG("all volumes\n");
}
#endif
for (VolumeIndex = 0; VolumeIndex < Volumes.size(); ++VolumeIndex) {
CUSTOM_LOADER_ENTRY *CustomSubEntry;
LOADER_ENTRY *Entry = NULL;
#if USE_XTHEME
XImage Image; // = new XImage;
XImage DriveImage;
#else
EG_IMAGE *Image, *DriveImage;
#endif
EFI_GUID *Guid = NULL;
UINT64 VolumeSize;
@ -1834,31 +2069,37 @@ STATIC VOID AddCustomEntry(IN UINTN CustomIndex,
}
// Change to custom image if needed
Image = Custom->Image;
if ((Image == NULL) && Custom->ImagePath) {
Image = egLoadImage(Volume->RootDir, Custom->ImagePath, TRUE);
if (Image == NULL) {
Image = egLoadImage(ThemeDir, Custom->ImagePath, TRUE);
if (Image == NULL) {
Image = egLoadImage(SelfDir, Custom->ImagePath, TRUE);
if (Image == NULL) {
Image = egLoadImage(SelfRootDir, Custom->ImagePath, TRUE);
if (Image == NULL) {
#if USE_XTHEME
XImage ImageX;
ImageX.LoadXImage(ThemeDir, Custom->ImagePath);
Image = ImageX.ToEGImage();
if (Image.isEmpty() && Custom->ImagePath) {
Image.LoadXImage(ThemeX.ThemeDir, Custom->ImagePath);
}
#else
Image = LoadOSIcon(Custom->ImagePath, L"unknown", 128, FALSE, FALSE);
#endif
}
}
if ((Image == NULL) && Custom->ImagePath) {
Image = egLoadImage(Volume->RootDir, Custom->ImagePath, TRUE);
if (Image == NULL) {
Image = egLoadImage(ThemeDir, Custom->ImagePath, TRUE);
if (Image == NULL) {
Image = egLoadImage(SelfDir, Custom->ImagePath, TRUE);
if (Image == NULL) {
Image = egLoadImage(SelfRootDir, Custom->ImagePath, TRUE);
if (Image == NULL) {
Image = LoadOSIcon(Custom->ImagePath, L"unknown", 128, FALSE, FALSE);
}
}
}
}
}
#endif
// Change to custom drive image if needed
DriveImage = Custom->DriveImage;
#if USE_XTHEME
if (DriveImage.isEmpty() && Custom->DriveImagePath) {
Image.LoadXImage(ThemeX.ThemeDir, Custom->DriveImagePath);
}
#else
if ((DriveImage == NULL) && Custom->DriveImagePath) {
DriveImage = egLoadImage(Volume->RootDir, Custom->DriveImagePath, TRUE);
if (DriveImage == NULL) {
@ -1868,17 +2109,14 @@ STATIC VOID AddCustomEntry(IN UINTN CustomIndex,
if (DriveImage == NULL) {
DriveImage = egLoadImage(SelfRootDir, Custom->DriveImagePath, TRUE);
if (DriveImage == NULL) {
#if USE_XTHEME
XImage DriveImageX = ThemeX.GetIcon(Custom->DriveImagePath);
DriveImage = DriveImageX.ToEGImage();
#else
DriveImage = LoadBuiltinIcon(Custom->DriveImagePath);
#endif
}
}
}
}
}
#endif
do
{
// Search for linux kernels
@ -2033,7 +2271,13 @@ STATIC VOID AddCustomEntry(IN UINTN CustomIndex,
}
DBG("match!\n");
// Create an entry for this volume
#if USE_XTHEME
Entry = CreateLoaderEntry(CustomPath, CustomOptions, Custom->FullTitle, Custom->Title, Volume, &Image, &DriveImage, Custom->Type, Custom->Flags, Custom->Hotkey, Custom->BootBgColor, Custom->CustomBoot, Custom->CustomLogo, /*(KERNEL_AND_KEXT_PATCHES *)(((UINTN)Custom) + OFFSET_OF(CUSTOM_LOADER_ENTRY, KernelAndKextPatches))*/ NULL, TRUE);
#else
Entry = CreateLoaderEntry(CustomPath, CustomOptions, Custom->FullTitle, Custom->Title, Volume, Image, DriveImage, Custom->Type, Custom->Flags, Custom->Hotkey, Custom->BootBgColor, Custom->CustomBoot, Custom->CustomLogo, /*(KERNEL_AND_KEXT_PATCHES *)(((UINTN)Custom) + OFFSET_OF(CUSTOM_LOADER_ENTRY, KernelAndKextPatches))*/ NULL, TRUE);
#endif
if (Entry != NULL) {
DBG("Custom settings: %ls.plist will %s be applied\n",
Custom->Settings, Custom->CommonSettings?"not":"");

View File

@ -279,7 +279,11 @@ VOID AddCustomTool(VOID)
UINTN VolumeIndex;
REFIT_VOLUME *Volume;
CUSTOM_TOOL_ENTRY *Custom;
#if USE_XTHEME
XImage Image;
#else
EG_IMAGE *Image;
#endif
UINTN i = 0;
// DBG("Custom tool start\n");
@ -349,6 +353,11 @@ VOID AddCustomTool(VOID)
}
// Change to custom image if needed
Image = Custom->Image;
#if USE_XTHEME
if (Image.isEmpty() && Custom->ImagePath) {
Image.LoadXImage(ThemeX.ThemeDir, Custom->ImagePath);
}
#else
if ((Image == NULL) && Custom->ImagePath) {
Image = egLoadImage(Volume->RootDir, Custom->ImagePath, TRUE);
if (Image == NULL) {
@ -361,14 +370,14 @@ VOID AddCustomTool(VOID)
}
}
}
#endif
#if USE_XTHEME
if (Image == NULL) {
if (Image.isEmpty()) {
AddToolEntry(Custom->Path, Custom->FullTitle, Custom->Title, Volume, ThemeX.GetIcon(BUILTIN_ICON_TOOL_SHELL), Custom->Hotkey, Custom->Options);
} else {
// Create a legacy entry for this volume
XImage ImageX;
ImageX.FromEGImage(Image);
AddToolEntry(Custom->Path, Custom->FullTitle, Custom->Title, Volume, ImageX, Custom->Hotkey, Custom->Options);
AddToolEntry(Custom->Path, Custom->FullTitle, Custom->Title, Volume, Image, Custom->Hotkey, Custom->Options);
}
#else
if (Image == NULL) {

View File

@ -112,9 +112,13 @@ class REFIT_ABSTRACT_MENU_ENTRY
ACTION AtMouseOver;
REFIT_MENU_SCREEN *SubScreen;
#if USE_XTHEME
virtual XImage* getDriveImage() { return nullptr; };
virtual XImage* getBadgeImage() { return nullptr; };
#else
virtual EG_IMAGE* getDriveImage() const { return nullptr; };
virtual EG_IMAGE* getBadgeImage() const { return nullptr; };
#endif
virtual REFIT_SIMPLE_MENU_ENTRY_TAG* getREFIT_SIMPLE_MENU_ENTRY_TAG() { return nullptr; };
virtual REFIT_MENU_SWITCH* getREFIT_MENU_SWITCH() { return nullptr; };
@ -135,6 +139,27 @@ class REFIT_ABSTRACT_MENU_ENTRY
virtual REFIT_MENU_ENTRY_ITEM_ABSTRACT* getREFIT_MENU_ITEM_IEM_ABSTRACT() { return nullptr; };
virtual REFIT_MENU_ITEM_BOOTNUM* getREFIT_MENU_ITEM_BOOTNUM() { return nullptr; };
#if USE_XTHEME
REFIT_ABSTRACT_MENU_ENTRY() : Row(0), ShortcutDigit(0), ShortcutLetter(0), Image(), AtClick(ActionNone), AtDoubleClick(ActionNone), AtRightClick(ActionNone), AtMouseOver(ActionNone), SubScreen(NULL)
{};
REFIT_ABSTRACT_MENU_ENTRY(const XStringW& Title_) : Title(Title_), Row(0), ShortcutDigit(0), ShortcutLetter(0), Image(), AtClick(ActionNone), AtDoubleClick(ActionNone), AtRightClick(ActionNone), AtMouseOver(ActionNone), SubScreen(NULL)
{};
REFIT_ABSTRACT_MENU_ENTRY(const XStringW& Title_, ACTION AtClick_) : Title(Title_), Row(0), ShortcutDigit(0), ShortcutLetter(0), Image(), AtClick(AtClick_), AtDoubleClick(ActionNone), AtRightClick(ActionNone), AtMouseOver(ActionNone), SubScreen(NULL)
{};
REFIT_ABSTRACT_MENU_ENTRY(const XStringW& Title_, UINTN Row_, CHAR16 ShortcutDigit_, CHAR16 ShortcutLetter_, ACTION AtClick_)
: Title(Title_), Row(Row_), ShortcutDigit(ShortcutDigit_), ShortcutLetter(ShortcutLetter_), Image(), AtClick(AtClick_), AtDoubleClick(ActionNone), AtRightClick(ActionNone), AtMouseOver(ActionNone), SubScreen(NULL)
{};
REFIT_ABSTRACT_MENU_ENTRY(const XStringW& Title_, UINTN Row_,
CHAR16 ShortcutDigit_, CHAR16 ShortcutLetter_, const XImage& Image_,
EG_RECT Place_, ACTION AtClick_, ACTION AtDoubleClick_, ACTION AtRightClick_, ACTION AtMouseOver_,
REFIT_MENU_SCREEN *SubScreen_)
: Title(Title_), Row(Row_), ShortcutDigit(ShortcutDigit_), ShortcutLetter(ShortcutLetter_),
Image(Image_), Place(Place_),
AtClick(AtClick_), AtDoubleClick(AtDoubleClick_), AtRightClick(AtRightClick_), AtMouseOver(AtMouseOver_),
SubScreen(SubScreen_) {};
#else
REFIT_ABSTRACT_MENU_ENTRY() : Row(0), ShortcutDigit(0), ShortcutLetter(0), Image(NULL), AtClick(ActionNone), AtDoubleClick(ActionNone), AtRightClick(ActionNone), AtMouseOver(ActionNone), SubScreen(NULL)
{};
REFIT_ABSTRACT_MENU_ENTRY(const XStringW& Title_) : Title(Title_), Row(0), ShortcutDigit(0), ShortcutLetter(0), Image(NULL), AtClick(ActionNone), AtDoubleClick(ActionNone), AtRightClick(ActionNone), AtMouseOver(ActionNone), SubScreen(NULL)
@ -152,7 +177,7 @@ class REFIT_ABSTRACT_MENU_ENTRY
Image(Image_), Place(Place_),
AtClick(AtClick_), AtDoubleClick(AtDoubleClick_), AtRightClick(AtRightClick_), AtMouseOver(AtMouseOver_),
SubScreen(SubScreen_) {};
#endif
virtual ~REFIT_ABSTRACT_MENU_ENTRY() {}; // virtual destructor : this is vital
};
@ -267,15 +292,28 @@ class REFIT_ABSTRACT_MENU_ENTRY
CONST CHAR16 *DevicePathString;
CONST CHAR16 *LoadOptions; //moved here for compatibility with legacy
CONST CHAR16 *LoaderPath;
#if USE_XTHEME
XImage DriveImage;
XImage BadgeImage;
REFIT_MENU_ITEM_ABSTRACT_ENTRY_LOADER()
: REFIT_ABSTRACT_MENU_ENTRY(), DevicePathString(0), LoadOptions(0), LoaderPath(0), DriveImage(), BadgeImage()
{}
virtual XImage* getDriveImage() { return &DriveImage; };
virtual XImage* getBadgeImage() { return &BadgeImage; };
#else
EG_IMAGE *DriveImage;
EG_IMAGE *BadgeImage;
REFIT_MENU_ITEM_ABSTRACT_ENTRY_LOADER()
: REFIT_ABSTRACT_MENU_ENTRY(), DevicePathString(0), LoadOptions(0), LoaderPath(0), DriveImage(0), BadgeImage(0)
{}
virtual EG_IMAGE* getDriveImage() const { return DriveImage; };
virtual EG_IMAGE* getBadgeImage() const { return BadgeImage; };
REFIT_MENU_ITEM_ABSTRACT_ENTRY_LOADER()
: REFIT_ABSTRACT_MENU_ENTRY(), DevicePathString(0), LoadOptions(0), LoaderPath(0), DriveImage(0), BadgeImage(0)
{}
virtual EG_IMAGE* getDriveImage() const { return DriveImage; };
virtual EG_IMAGE* getBadgeImage() const { return BadgeImage; };
#endif
virtual REFIT_MENU_ITEM_ABSTRACT_ENTRY_LOADER* getREFIT_MENU_ITEM_ABSTRACT_ENTRY_LOADER() { return this; };
};

View File

@ -415,7 +415,8 @@ EFI_STATUS XTheme::ParseSVGXTheme(CONST CHAR8* buffer)
{
EFI_STATUS Status;
NSVGimage *SVGimage;
// NSVGrasterizer *rast = nsvgCreateRasterizer();
Icons.Empty();
// --- Parse theme.svg --- low case
mainParser = nsvgParse((CHAR8*)buffer, 72, 1.f); //the buffer will be modified, it is how nanosvg works
@ -472,8 +473,7 @@ EFI_STATUS XTheme::ParseSVGXTheme(CONST CHAR8* buffer)
// --- Make other icons
Icons.Empty();
for (INTN i = BUILTIN_ICON_FUNC_ABOUT; i < BUILTIN_CHECKBOX_CHECKED; ++i) {
for (INTN i = BUILTIN_ICON_FUNC_ABOUT; i <= BUILTIN_CHECKBOX_CHECKED; ++i) {
if (i == BUILTIN_ICON_BANNER) {
continue;
}
@ -486,9 +486,6 @@ EFI_STATUS XTheme::ParseSVGXTheme(CONST CHAR8* buffer)
//selections
SelectionImages[0] = GetIcon(BUILTIN_SELECTION_BIG);
SelectionImages[2] = GetIcon(BUILTIN_SELECTION_SMALL);
//for (int i=0 ; i<6 ; i++ ) {
//SelectionImages[i].Draw(i*200, 0);
//}
//selection for bootcamp style
Status = EFI_NOT_FOUND;
@ -498,7 +495,10 @@ EFI_STATUS XTheme::ParseSVGXTheme(CONST CHAR8* buffer)
if (EFI_ERROR(Status)) {
Status = ParseSVGXIcon(mainParser, BUILTIN_ICON_SELECTION, "selection_indicator"_XS, Scale, &SelectionImages[4]);
}
//for (int i=0 ; i<6 ; i+=2 ) {
//SelectionImages[i].Draw(i*100, 0);
//}
//banner animation
GUI_ANIME *Anime = (__typeof__(Anime))AllocateZeroPool (sizeof(GUI_ANIME));
Anime->ID = 1; //main screen

View File

@ -226,6 +226,7 @@ void XImage::FillArea(const EFI_GRAPHICS_OUTPUT_BLT_PIXEL& Color, EG_RECT& Rect)
}
}
//sizes remain as were assumed input image is large enough?
void XImage::CopyScaled(const XImage& Image, float scale)
{
UINTN SrcWidth = Image.GetWidth();
@ -632,7 +633,7 @@ void XImage::EnsureImageSize(IN UINTN NewWidth, IN UINTN NewHeight, IN CONST EFI
XImage NewImage(NewWidth, NewHeight);
NewImage.Fill(Color);
NewImage.Compose(0, 0, (*this), true);
NewImage.Compose(0, 0, (*this), false); //should keep existing opacity
setSizeInPixels(NewWidth, NewHeight); //include reallocate but loose data
CopyMem(&PixelData[0], &NewImage.PixelData[0], GetSizeInBytes());
//we have to copy pixels twice? because we can't return newimage instead of this
@ -676,6 +677,18 @@ void XImage::CopyRect(const XImage& Image, INTN XPos, INTN YPos)
}
}
void XImage::CopyRect(const XImage& Image, const EG_RECT& OwnPlace, const EG_RECT& InputRect)
{
INTN Dx = OwnPlace.XPos - InputRect.XPos;
INTN Dy = OwnPlace.YPos - InputRect.YPos;
for (INTN y = OwnPlace.YPos; y < (INTN)Height && (y - Dy) < (INTN)Image.GetHeight(); ++y) {
for (INTN x = OwnPlace.XPos; x < (INTN)Width && (x - Dx) < (INTN)Image.GetWidth(); ++x) {
PixelData[y * Width + x] = Image.GetPixel(x - Dx, y - Dy);
}
}
}
EG_IMAGE* XImage::ToEGImage()
{
if (isEmpty()) {

View File

@ -54,7 +54,7 @@ public:
XImage();
XImage(UINTN W, UINTN H);
XImage(EG_IMAGE* egImage);
XImage(const XImage& Image, float scale); //the constructor can accept 0 scale as 1.f
XImage(const XImage& Image, float scale = 0.f); //the constructor can accept 0 scale as 1.f
~XImage();
XImage& operator= (const XImage& other);
@ -86,6 +86,7 @@ public:
void FillArea(const EFI_GRAPHICS_OUTPUT_BLT_PIXEL& Color, EG_RECT& Rect);
void CopyScaled(const XImage& Image, float scale);
void CopyRect(const XImage& Image, INTN X, INTN Y);
void CopyRect(const XImage& Image, const EG_RECT& OwnPlace, const EG_RECT& InputRect);
void Compose(INTN PosX, INTN PosY, const XImage& TopImage, bool Lowest); //instead of compose we often can Back.Draw(...) + Top.Draw(...)
void FlipRB();
EFI_STATUS FromPNG(const UINT8 * Data, UINTN Lenght);

View File

@ -381,7 +381,6 @@ void XTheme::ClearScreen() //and restore background and banner
// DBG("banner position old style\n");
}
}
}
}
@ -390,16 +389,16 @@ void XTheme::ClearScreen() //and restore background and banner
// Resolution changed
Background.setEmpty();
}
if (Background.isEmpty()) {
Background = XImage(UGAWidth, UGAHeight);
Background.Fill(BlueBackgroundPixel);
Background.Fill(BlueBackgroundPixel); //blue opaque. May be better to set black opaque?
}
// now we are sure Background has UGA sizes
if (!BigBack.isEmpty()) {
switch (BackgroundScale) {
case imScale:
// DBG("back copy scaled\n");
Background.CopyScaled(BigBack, Scale);
Background = XImage(BigBack, Scale);
break;
case imCrop:
{
@ -424,12 +423,14 @@ void XTheme::ClearScreen() //and restore background and banner
y2 = (-y) >> 1;
y = UGAHeight;
}
const EG_RECT BackRect = EG_RECT(x1, y1, x, y);
const EG_RECT BigRect = EG_RECT(x2, y2, x, y);
//the function can be in XImage class
egRawCopy((EG_PIXEL*)Background.GetPixelPtr(x1, y1),
(EG_PIXEL*)BigBack.GetPixelPtr(x2, y2),
x, y, Background.GetWidth(), BigBack.GetWidth());
// egRawCopy((EG_PIXEL*)Background.GetPixelPtr(x1, y1),
// (EG_PIXEL*)BigBack.GetPixelPtr(x2, y2),
// x, y, Background.GetWidth(), BigBack.GetWidth());
// DBG("crop to x,y: %lld, %lld\n", x, y);
// Background.CopyRect(BigBack, x, y);
Background.CopyRect(BigBack, BackRect, BigRect);
// DBG("back copy cropped\n");
break;
}
@ -454,12 +455,17 @@ void XTheme::ClearScreen() //and restore background and banner
break;
}
}
//join Banner and Background for menu drawing
if (!Banner.isEmpty()) {
Background.Compose(BannerPlace.XPos, BannerPlace.YPos, Banner, true);
}
Background.DrawWithoutCompose(0, 0, UGAWidth, UGAHeight);
// Background.Draw(0,0,0,true);
//then draw banner
if (!Banner.isEmpty()) {
Banner.Draw(BannerPlace.XPos, BannerPlace.YPos, Scale);
}
// if (!Banner.isEmpty()) {
// Banner.Draw(BannerPlace.XPos, BannerPlace.YPos, Scale);
// }
}
@ -588,6 +594,7 @@ void XTheme::InitSelection() //for PNG theme
Buttons[3].FromPNG(ACCESS_EMB_DATA(emb_checkbox_checked), ACCESS_EMB_SIZE(emb_checkbox_checked));
}
} else {
//SVG theme already parsed all icons
Buttons[0] = GetIcon("radio_button");
Buttons[1] = GetIcon("radio_button_selected");
Buttons[2] = GetIcon("checkbox");

View File

@ -121,10 +121,11 @@ public:
// void AddIcon(Icon& NewIcon); //return EFI_STATUS?
void FillByEmbedded();
void FillByDir();
EFI_STATUS GetThemeTagSettings (void* DictPointer);
EFI_STATUS GetThemeTagSettings(void* DictPointer);
void parseTheme(void* p, const char** dict); //in nano project
EFI_STATUS ParseSVGXTheme(CONST CHAR8* buffer); // in VectorTheme
EFI_STATUS ParseSVGXIcon(void *p, INTN Id, const XString& IconNameX, float Scale, XImage* Image);
void* LoadTheme(const CHAR16 *TestTheme); //return TagPtr why?
//screen operations
void ClearScreen();

View File

@ -414,6 +414,7 @@ public:
INTN Height;
EG_RECT() : XPos(0), YPos(0), Width(0), Height(0) {};
EG_RECT(INTN x, INTN y, INTN w, INTN h) { XPos = x; YPos = y; Width = w; Height = h; }
EG_RECT(const EG_RECT& other) { XPos = other.XPos; YPos = other.YPos; Width = other.Width; Height = other.Height; }
const EG_RECT& operator = (const EG_RECT& other) { XPos = other.XPos; YPos = other.YPos; Width = other.Width; Height = other.Height; return *this; }
bool operator == (const EG_RECT& other) { return XPos == other.XPos && YPos == other.YPos && Width == other.Width && Height == other.Height; }

View File

@ -2872,7 +2872,12 @@ static void nsvg__parseText(NSVGparser* p, const char** dict)
NSVGparser *p1 = NULL;
EFI_STATUS Status;
DBG("required font %s not found, try to load external\n", text->fontFace->fontFamily);
#if USE_XTHEME
Status = egLoadFile(ThemeX.ThemeDir, PoolPrint(L"%a.svg", text->fontFace->fontFamily), &FileData, &FileDataLength);
#else
Status = egLoadFile(ThemeDir, PoolPrint(L"%a.svg", text->fontFace->fontFamily), &FileData, &FileDataLength);
#endif
DBG("font %s loaded status=%s\n", text->fontFace->fontFamily, strerror(Status));
if (!EFI_ERROR(Status)) {
p1 = nsvgParse((CHAR8*)FileData, 72, 1.0f); //later we will free parser p1

View File

@ -106,7 +106,7 @@ EG_IMAGE * egLoadFontImage(IN BOOLEAN UseEmbedded, IN INTN Rows, IN INTN Cols)
} else {
#if USE_XTHEME
if (!ThemeX.TypeSVG) {
NewImage = egLoadImage(ThemeDir, isKorean ? L"FontKorean.png" : ThemeX.FontFileName.data(), TRUE);
NewImage = egLoadImage(ThemeX.ThemeDir, isKorean ? L"FontKorean.png" : ThemeX.FontFileName.data(), TRUE);
MsgLog("Loading font from ThemeDir: %s\n", NewImage ? "Success" : "Error");
} else {
MsgLog("Using SVG font\n");
@ -146,9 +146,9 @@ EG_IMAGE * egLoadFontImage(IN BOOLEAN UseEmbedded, IN INTN Rows, IN INTN Cols)
}
ImageWidth = NewImage->Width;
DBG("ImageWidth=%lld\n", ImageWidth);
// DBG("ImageWidth=%lld\n", ImageWidth);
ImageHeight = NewImage->Height;
DBG("ImageHeight=%lld\n", ImageHeight);
// DBG("ImageHeight=%lld\n", ImageHeight);
PixelPtr = NewImage->PixelData;
NewFontImage = egCreateImage(ImageWidth * Rows, ImageHeight / Rows, TRUE);

View File

@ -61,9 +61,10 @@ EFI_DEVICE_PATH *SelfFullDevicePath;
#if USE_XTHEME
XTheme ThemeX;
#endif
EFI_FILE *ThemeDir = NULL;
#else
EFI_FILE *ThemeDir = NULL; //it is XTheme member
#endif
CHAR16 *ThemePath;
BOOLEAN gThemeChanged = FALSE;
//BOOLEAN gBootArgsChanged = FALSE;
@ -243,12 +244,19 @@ VOID UninitRefitLib(VOID)
OEMDir->Close(OEMDir);
OEMDir = NULL;
}
#if USE_XTHEME
if (ThemeX.ThemeDir != NULL) {
ThemeX.ThemeDir->Close(ThemeX.ThemeDir);
ThemeX.ThemeDir = NULL;
}
#else
if (ThemeDir != NULL) {
ThemeDir->Close(ThemeDir);
ThemeDir = NULL;
}
#endif
if (SelfRootDir != NULL) {
SelfRootDir->Close(SelfRootDir);
SelfRootDir = NULL;
@ -301,7 +309,13 @@ EFI_STATUS ReinitSelfLib(VOID)
return EFI_NOT_FOUND;
}
SelfDeviceHandle = NewSelfHandle;
#if USE_XTHEME
/*Status = */SelfRootDir->Open(SelfRootDir, &ThemeX.ThemeDir, ThemePath, EFI_FILE_MODE_READ, 0);
#else
/*Status = */SelfRootDir->Open(SelfRootDir, &ThemeDir, ThemePath, EFI_FILE_MODE_READ, 0);
#endif
/*Status = */SelfRootDir->Open(SelfRootDir, &OEMDir, OEMPath, EFI_FILE_MODE_READ, 0);
Status = SelfRootDir->Open(SelfRootDir, &SelfDir, SelfDirPath, EFI_FILE_MODE_READ, 0);
CheckFatalError(Status, L"while reopening our installation directory");
@ -322,7 +336,11 @@ EFI_STATUS FinishInitRefitLib(VOID)
return EFI_LOAD_ERROR;
}
}
#if USE_XTHEME
/*Status = */SelfRootDir->Open(SelfRootDir, &ThemeX.ThemeDir, ThemePath, EFI_FILE_MODE_READ, 0);
#else
/*Status = */SelfRootDir->Open(SelfRootDir, &ThemeDir, ThemePath, EFI_FILE_MODE_READ, 0);
#endif
/*Status = */SelfRootDir->Open(SelfRootDir, &OEMDir, OEMPath, EFI_FILE_MODE_READ, 0);
Status = SelfRootDir->Open(SelfRootDir, &SelfDir, SelfDirPath, EFI_FILE_MODE_READ, 0);
CheckFatalError(Status, L"while opening our installation directory");
@ -332,9 +350,9 @@ EFI_STATUS FinishInitRefitLib(VOID)
BOOLEAN IsEmbeddedTheme()
{
if (ThemeX.embedded) {
ThemeDir = NULL;
ThemeX.ThemeDir = NULL;
}
return ThemeDir == NULL;
return ThemeX.ThemeDir == NULL;
}
#else
BOOLEAN IsEmbeddedTheme()

View File

@ -408,7 +408,9 @@ extern EFI_FILE *SelfDir;
extern CHAR16 *SelfDirPath;
extern EFI_DEVICE_PATH *SelfDevicePath;
extern EFI_DEVICE_PATH *SelfFullDevicePath;
#if !USE_XTHEME
extern EFI_FILE *ThemeDir;
#endif
extern CHAR16 *ThemePath;
extern EFI_FILE *OEMDir;
extern CHAR16 *OEMPath;
@ -423,11 +425,14 @@ extern XObjArray<REFIT_VOLUME> Volumes;
#endif
//extern UINTN VolumesCount;
#if !USE_XTHEME
extern EG_IMAGE *Banner;
extern EG_IMAGE *BigBack;
extern EG_IMAGE *FontImage;
extern EG_IMAGE *SelectionImages[];
extern EG_IMAGE *Buttons[];
#endif
extern EG_IMAGE *FontImage; //not yet converted to XImage
extern BOOLEAN gThemeChanged;
//extern BOOLEAN gBootArgsChanged;
extern BOOLEAN gBootChanged;

View File

@ -1030,7 +1030,7 @@ static VOID StartLegacy(IN LEGACY_ENTRY *Entry)
egClearScreen(&MenuBackgroundPixel);
BeginExternalScreen(TRUE/*, L"Booting Legacy OS"*/);
XImage BootLogoX;
BootLogoX.LoadXImage(ThemeDir, Entry->Volume->LegacyOS->IconName);
BootLogoX.LoadXImage(ThemeX.ThemeDir, Entry->Volume->LegacyOS->IconName);
BootLogoX.Draw((UGAWidth - BootLogoX.GetWidth()) >> 1,
(UGAHeight - BootLogoX.GetHeight()) >> 1);
#else

View File

@ -4445,27 +4445,22 @@ VOID REFIT_MENU_SCREEN::GraphicsMenuStyle(IN UINTN Function, IN CONST CHAR16 *Pa
VOID DrawMainMenuEntry(REFIT_ABSTRACT_MENU_ENTRY *Entry, BOOLEAN selected, INTN XPos, INTN YPos)
{
XImage MainImage(0,0);
XImage BadgeImage(0,0);
bool NewImageCreated = false;
INTN MainSize = ThemeX.MainEntriesSize;
XImage MainImage(MainSize, MainSize);
XImage* BadgeImage;
if (Entry->Row == 0 && Entry->getDriveImage() && !(ThemeX.HideBadges & HDBADGES_SWAP)) {
MainImage.FromEGImage(Entry->getDriveImage()); //EG_IMAGE
MainImage = *Entry->getDriveImage();
} else {
// MainImage.FromEGImage(Entry->Image);
MainImage = Entry->Image; //XImage
}
//this should be inited by the Theme
if (MainImage.isEmpty()) {
if (!IsEmbeddedTheme()) {
// MainImage = egLoadIcon(ThemeDir, GetIconsExt(L"icons\\os_mac", L"icns"), Scale << 3);
MainImage = ThemeX.GetIcon("os_mac");
}
if (MainImage.isEmpty()) {
MainImage.DummyImage(ThemeX.MainEntriesSize);
}
if (!MainImage.isEmpty()) {
NewImageCreated = true;
MainImage.DummyImage(MainSize);
}
}
INTN CompWidth = (Entry->Row == 0) ? ThemeX.row0TileSize : ThemeX.row1TileSize;
@ -4479,7 +4474,7 @@ VOID DrawMainMenuEntry(REFIT_ABSTRACT_MENU_ENTRY *Entry, BOOLEAN selected, INTN
}
if (Entry->Row == 0) {
BadgeImage.FromEGImage(Entry->getBadgeImage());
BadgeImage = Entry->getBadgeImage();
} //else null
XImage TopImage = ThemeX.SelectionImages[((Entry->Row == 0) ? 0 : 2) + (selected ? 0 : 1)];
@ -4501,37 +4496,37 @@ VOID DrawMainMenuEntry(REFIT_ABSTRACT_MENU_ENTRY *Entry, BOOLEAN selected, INTN
}
// place the badge image
if (!BadgeImage.isEmpty() &&
((INTN)BadgeImage.GetWidth() + 8) < CompWidth &&
((INTN)BadgeImage.GetHeight() + 8) < CompHeight) {
if (BadgeImage &&
((INTN)BadgeImage->GetWidth() + 8) < CompWidth &&
((INTN)BadgeImage->GetHeight() + 8) < CompHeight) {
// Check for user badge x offset from theme.plist
if (ThemeX.BadgeOffsetX != 0xFFFF) {
// Check if value is between 0 and ( width of the main icon - width of badge )
if (ThemeX.BadgeOffsetX < 0 || ThemeX.BadgeOffsetX > (CompWidth - (INTN)BadgeImage.GetWidth())) {
if (ThemeX.BadgeOffsetX < 0 || ThemeX.BadgeOffsetX > (CompWidth - (INTN)BadgeImage->GetWidth())) {
DBG("User offset X %lld is out of range\n", ThemeX.BadgeOffsetX);
ThemeX.BadgeOffsetX = CompWidth - 8 - BadgeImage.GetWidth();
ThemeX.BadgeOffsetX = CompWidth - 8 - BadgeImage->GetWidth();
DBG(" corrected to default %lld\n", ThemeX.BadgeOffsetX);
}
OffsetX += ThemeX.BadgeOffsetX;
} else {
// Set default position
OffsetX += CompWidth - 8 - BadgeImage.GetWidth();
OffsetX += CompWidth - 8 - BadgeImage->GetWidth();
}
// Check for user badge y offset from theme.plist
if (ThemeX.BadgeOffsetY != 0xFFFF) {
// Check if value is between 0 and ( height of the main icon - height of badge )
if (ThemeX.BadgeOffsetY < 0 || ThemeX.BadgeOffsetY > (CompHeight - (INTN)BadgeImage.GetHeight())) {
if (ThemeX.BadgeOffsetY < 0 || ThemeX.BadgeOffsetY > (CompHeight - (INTN)BadgeImage->GetHeight())) {
DBG("User offset Y %lld is out of range\n",ThemeX.BadgeOffsetY);
ThemeX.BadgeOffsetY = CompHeight - 8 - BadgeImage.GetHeight();
ThemeX.BadgeOffsetY = CompHeight - 8 - BadgeImage->GetHeight();
DBG(" corrected to default %lld\n", ThemeX.BadgeOffsetY);
}
OffsetY += ThemeX.BadgeOffsetY;
} else {
// Set default position
OffsetY += CompHeight - 8 - BadgeImage.GetHeight();
OffsetY += CompHeight - 8 - BadgeImage->GetHeight();
}
Back.Compose(OffsetX, OffsetY, BadgeImage, false);
Back.Compose(OffsetX, OffsetY, *BadgeImage, false);
}
if(ThemeX.SelectionOnTop) {

View File

@ -1039,7 +1039,7 @@ VOID REFIT_MENU_SCREEN::InitAnime()
// DBG("frame %d loaded\n", i);
} else {
UnicodeSPrint(FileName, 512, L"%s\\%s_%03d.png", Path, Path, i);
p = egLoadImage(ThemeDir, FileName, TRUE);
p = egLoadImage(ThemeX.ThemeDir, FileName, TRUE);
}
if (!p) {
p = Last;