change type of scanvolumedefault

Signed-off-by: Sergey Isakov <isakov-sl@bk.ru>
This commit is contained in:
Sergey Isakov 2020-04-05 21:56:36 +03:00
parent f1c72d752e
commit c12f59a551
6 changed files with 27 additions and 18 deletions

View File

@ -94,11 +94,15 @@ EG_IMAGE *LoadBuiltinIcon(IN CONST CHAR16 *IconName)
return NULL; return NULL;
} }
#if USE_XTHEME
const XImage& ScanVolumeDefaultIcon(REFIT_VOLUME *Volume, IN UINT8 OSType, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath)
#else
EG_IMAGE* ScanVolumeDefaultIcon(REFIT_VOLUME *Volume, IN UINT8 OSType, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath) //IN UINT8 DiskKind) EG_IMAGE* ScanVolumeDefaultIcon(REFIT_VOLUME *Volume, IN UINT8 OSType, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath) //IN UINT8 DiskKind)
#endif
{ {
UINTN IconNum = 0; UINTN IconNum = 0;
#if USE_XTHEME #if USE_XTHEME
XImage IconX; const XImage* IconX;
#endif #endif
// default volume icon based on disk kind // default volume icon based on disk kind
switch (Volume->DiskKind) { switch (Volume->DiskKind) {
@ -134,24 +138,27 @@ EG_IMAGE* ScanVolumeDefaultIcon(REFIT_VOLUME *Volume, IN UINT8 OSType, IN EFI_DE
break; break;
} }
#if USE_XTHEME #if USE_XTHEME
IconX = ThemeX.GetIcon(IconNum); IconX = &ThemeX.GetIcon(IconNum);
if (IconX->isEmpty()) {
IconX = &ThemeX.GetIcon(BUILTIN_ICON_VOL_INTERNAL);
}
break; break;
case DISK_KIND_EXTERNAL: case DISK_KIND_EXTERNAL:
IconX = ThemeX.GetIcon(BUILTIN_ICON_VOL_EXTERNAL); IconX = &ThemeX.GetIcon(BUILTIN_ICON_VOL_EXTERNAL);
break; break;
case DISK_KIND_OPTICAL: case DISK_KIND_OPTICAL:
IconX = ThemeX.GetIcon(BUILTIN_ICON_VOL_OPTICAL); IconX = &ThemeX.GetIcon(BUILTIN_ICON_VOL_OPTICAL);
break; break;
case DISK_KIND_FIREWIRE: case DISK_KIND_FIREWIRE:
IconX = ThemeX.GetIcon(BUILTIN_ICON_VOL_FIREWIRE); IconX = &ThemeX.GetIcon(BUILTIN_ICON_VOL_FIREWIRE);
break; break;
case DISK_KIND_BOOTER: case DISK_KIND_BOOTER:
IconX = ThemeX.GetIcon(BUILTIN_ICON_VOL_BOOTER); IconX = &ThemeX.GetIcon(BUILTIN_ICON_VOL_BOOTER);
break; break;
default: default:
return NULL; break;
} }
return IconX.ToEGImage(); return *IconX;
#else #else
return BuiltinIcon(IconNum); return BuiltinIcon(IconNum);
case DISK_KIND_EXTERNAL: case DISK_KIND_EXTERNAL:

View File

@ -46,8 +46,12 @@ extern REFIT_MENU_SCREEN MainMenu;
extern XObjArray<REFIT_VOLUME> Volumes; extern XObjArray<REFIT_VOLUME> Volumes;
// common // common
#if USE_XTHEME
const XImage& ScanVolumeDefaultIcon(REFIT_VOLUME *Volume, IN UINT8 OSType, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath);
#else
EG_IMAGE *LoadBuiltinIcon(IN CONST CHAR16 *IconName); EG_IMAGE *LoadBuiltinIcon(IN CONST CHAR16 *IconName);
EG_IMAGE * ScanVolumeDefaultIcon(REFIT_VOLUME *Volume, IN UINT8 OSType, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath); EG_IMAGE * ScanVolumeDefaultIcon(REFIT_VOLUME *Volume, IN UINT8 OSType, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath);
#endif
/* /*
INTN StrniCmp(IN CHAR16 *Str1, INTN StrniCmp(IN CHAR16 *Str1,
IN CHAR16 *Str2, IN CHAR16 *Str2,

View File

@ -761,17 +761,13 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST CHAR16 *LoaderPath,
} else if (Image) { } else if (Image) {
Entry->Image = *Image; Entry->Image = *Image;
} else { } else {
// Entry->Image = ThemeX.GetIcon("unknown"); //no such icon
//TODO now we have OSIconName = L"moja,mac"
// Entry->Image = ThemeX.GetIcon("vol_internal"_XS);
Entry->Image = ThemeX.LoadOSIcon(OSIconName); Entry->Image = ThemeX.LoadOSIcon(OSIconName);
} }
// Load DriveImage // Load DriveImage
if (DriveImage) { if (DriveImage) {
Entry->DriveImage = *DriveImage; Entry->DriveImage = *DriveImage;
} else { } else {
//TODO -> Entry->DriveImage = ScanVolumeDefaultIcon(Volume, Entry->LoaderType, Volume->DevicePath);
Entry->DriveImage.FromEGImage(ScanVolumeDefaultIcon(Volume, Entry->LoaderType, Volume->DevicePath));
} }
#else #else
if (GlobalConfig.CustomIcons && FileExists(Volume->RootDir, L"\\.VolumeIcon.icns")){ if (GlobalConfig.CustomIcons && FileExists(Volume->RootDir, L"\\.VolumeIcon.icns")){

View File

@ -1579,7 +1579,7 @@ VOID REFIT_MENU_SCREEN::DrawBCSText(IN CONST CHAR16 *Text, IN INTN XPos, IN INTN
} }
// MaxTextLen += EllipsisLen; // MaxTextLen += EllipsisLen;
XStringW BCSTextX(MaxTextLen); XStringW BCSTextX;
BCSTextX.StrnCpy(Text, MaxTextLen); BCSTextX.StrnCpy(Text, MaxTextLen);
BCSTextX += L".."; BCSTextX += L"..";
DrawTextXY(BCSTextX, XPos, YPos, XAlign); DrawTextXY(BCSTextX, XPos, YPos, XAlign);

View File

@ -194,6 +194,7 @@
Platform/Net.cpp Platform/Net.cpp
Platform/sound.cpp Platform/sound.cpp
Platform/StartupSound.cpp Platform/StartupSound.cpp
Platform/StartupSound.h
Platform/sse3_patcher.h Platform/sse3_patcher.h
Platform/sse3_5_patcher.h Platform/sse3_5_patcher.h
Version.h Version.h

View File

@ -414,6 +414,7 @@ VOID FreeList(IN OUT VOID ***ListPtr, IN OUT UINTN *ElementCount)
// firmware device path discovery // firmware device path discovery
// //
//looks like not used anywhere
static UINT8 LegacyLoaderMediaPathData[] = { static UINT8 LegacyLoaderMediaPathData[] = {
0x04, 0x06, 0x14, 0x00, 0xEB, 0x85, 0x05, 0x2B, 0x04, 0x06, 0x14, 0x00, 0xEB, 0x85, 0x05, 0x2B,
0xB8, 0xD8, 0xA9, 0x49, 0x8B, 0x8C, 0xE2, 0x1B, 0xB8, 0xD8, 0xA9, 0x49, 0x8B, 0x8C, 0xE2, 0x1B,
@ -650,7 +651,7 @@ static VOID ScanVolumeBootcode(IN OUT REFIT_VOLUME *Volume, OUT BOOLEAN *Bootabl
*((UINT16 *)(SectorBuffer + 510)) == 0xaa55) || *((UINT16 *)(SectorBuffer + 510)) == 0xaa55) ||
FindMem(SectorBuffer, 2048, "Starting the BTX loader", 23) >= 0) { FindMem(SectorBuffer, 2048, "Starting the BTX loader", 23) >= 0) {
Volume->HasBootCode = TRUE; Volume->HasBootCode = TRUE;
Volume->LegacyOS->IconName = L"freebsd"; Volume->LegacyOS->IconName = L"freebsd,linux";
Volume->LegacyOS->Name = L"FreeBSD"; Volume->LegacyOS->Name = L"FreeBSD";
Volume->LegacyOS->Type = OSTYPE_VAR; Volume->LegacyOS->Type = OSTYPE_VAR;
Volume->BootType = BOOTING_BY_PBR; Volume->BootType = BOOTING_BY_PBR;
@ -659,7 +660,7 @@ static VOID ScanVolumeBootcode(IN OUT REFIT_VOLUME *Volume, OUT BOOLEAN *Bootabl
} else if (FindMem(SectorBuffer, 512, "!Loading", 8) >= 0 || } else if (FindMem(SectorBuffer, 512, "!Loading", 8) >= 0 ||
FindMem(SectorBuffer, 2048, "/cdboot\0/CDBOOT\0", 16) >= 0) { FindMem(SectorBuffer, 2048, "/cdboot\0/CDBOOT\0", 16) >= 0) {
Volume->HasBootCode = TRUE; Volume->HasBootCode = TRUE;
Volume->LegacyOS->IconName = L"openbsd"; Volume->LegacyOS->IconName = L"openbsd,linux";
Volume->LegacyOS->Name = L"OpenBSD"; Volume->LegacyOS->Name = L"OpenBSD";
Volume->LegacyOS->Type = OSTYPE_VAR; Volume->LegacyOS->Type = OSTYPE_VAR;
Volume->BootType = BOOTING_BY_PBR; Volume->BootType = BOOTING_BY_PBR;
@ -667,7 +668,7 @@ static VOID ScanVolumeBootcode(IN OUT REFIT_VOLUME *Volume, OUT BOOLEAN *Bootabl
} else if (FindMem(SectorBuffer, 512, "Not a bootxx image", 18) >= 0 || } else if (FindMem(SectorBuffer, 512, "Not a bootxx image", 18) >= 0 ||
*((UINT32 *)(SectorBuffer + 1028)) == 0x7886b6d1) { *((UINT32 *)(SectorBuffer + 1028)) == 0x7886b6d1) {
Volume->HasBootCode = TRUE; Volume->HasBootCode = TRUE;
Volume->LegacyOS->IconName = L"netbsd"; Volume->LegacyOS->IconName = L"netbsd,linux";
Volume->LegacyOS->Name = L"NetBSD"; Volume->LegacyOS->Name = L"NetBSD";
Volume->LegacyOS->Type = OSTYPE_VAR; Volume->LegacyOS->Type = OSTYPE_VAR;
Volume->BootType = BOOTING_BY_PBR; Volume->BootType = BOOTING_BY_PBR;
@ -690,7 +691,7 @@ static VOID ScanVolumeBootcode(IN OUT REFIT_VOLUME *Volume, OUT BOOLEAN *Bootabl
} else if (FindMem(SectorBuffer, 512, "CPUBOOT SYS", 11) >= 0 || } else if (FindMem(SectorBuffer, 512, "CPUBOOT SYS", 11) >= 0 ||
FindMem(SectorBuffer, 512, "KERNEL SYS", 11) >= 0) { FindMem(SectorBuffer, 512, "KERNEL SYS", 11) >= 0) {
Volume->HasBootCode = TRUE; Volume->HasBootCode = TRUE;
Volume->LegacyOS->IconName = L"freedos"; Volume->LegacyOS->IconName = L"freedos,win";
Volume->LegacyOS->Name = L"FreeDOS"; Volume->LegacyOS->Name = L"FreeDOS";
Volume->LegacyOS->Type = OSTYPE_VAR; Volume->LegacyOS->Type = OSTYPE_VAR;
Volume->BootType = BOOTING_BY_PBR; Volume->BootType = BOOTING_BY_PBR;