mirror of
https://github.com/CloverHackyColor/CloverBootloader.git
synced 2025-01-13 19:31:28 +01:00
Enhance Linux Scan and some other GUI corrections
This commit is contained in:
parent
469750c6e6
commit
0847234281
@ -124,6 +124,7 @@ template <size_t _Np> struct XStringAbstract__is_char_st<wchar_t[_Np]>
|
|||||||
|
|
||||||
|
|
||||||
#define asciiToLower(ch) (((ch >= L'A') && (ch <= L'Z')) ? ((ch - L'A') + L'a') : ch)
|
#define asciiToLower(ch) (((ch >= L'A') && (ch <= L'Z')) ? ((ch - L'A') + L'a') : ch)
|
||||||
|
#define asciiToUpper(ch) (((ch >= L'a') && (ch <= L'z')) ? ((ch - L'a') + L'A') : ch)
|
||||||
|
|
||||||
template<typename S, typename O>
|
template<typename S, typename O>
|
||||||
int XStringAbstract__compare(const S* src, const O* other, bool ignoreCase)
|
int XStringAbstract__compare(const S* src, const O* other, bool ignoreCase)
|
||||||
@ -547,6 +548,15 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void upperAscii()
|
||||||
|
{
|
||||||
|
T* s = m_data;
|
||||||
|
while ( *s ) {
|
||||||
|
*s = asciiToUpper(*s);
|
||||||
|
s++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void trim()
|
void trim()
|
||||||
{
|
{
|
||||||
T* start = 0;
|
T* start = 0;
|
||||||
|
@ -85,6 +85,24 @@ typedef struct LINUX_PATH_DATA
|
|||||||
CONST CHAR8 *Issue;
|
CONST CHAR8 *Issue;
|
||||||
} LINUX_PATH_DATA;
|
} LINUX_PATH_DATA;
|
||||||
|
|
||||||
|
typedef struct LINUX_ICON_DATA
|
||||||
|
{
|
||||||
|
CONST CHAR16 *DirectoryName;
|
||||||
|
CONST CHAR16 *IconName;
|
||||||
|
} LINUX_ICON_MAPPING;
|
||||||
|
|
||||||
|
STATIC LINUX_ICON_DATA LinuxIconMapping[] = {
|
||||||
|
{ L"LinuxMint", L"mint" },
|
||||||
|
{ L"arch_grub", L"arch" },
|
||||||
|
{ L"opensuse", L"suse" },
|
||||||
|
{ L"ORACLE", L"solaris" },
|
||||||
|
{ L"elementary", L"eos" },
|
||||||
|
{ L"pclinuxos", L"pclinux" },
|
||||||
|
{ L"mx18", L"mx" },
|
||||||
|
{ L"mx19", L"mx" }
|
||||||
|
};
|
||||||
|
STATIC CONST UINTN LinuxIconMappingCount = (sizeof(LinuxIconMapping) / sizeof(LINUX_ICON_DATA));
|
||||||
|
|
||||||
STATIC LINUX_PATH_DATA LinuxEntryData[] = {
|
STATIC LINUX_PATH_DATA LinuxEntryData[] = {
|
||||||
#if defined(MDE_CPU_X64)
|
#if defined(MDE_CPU_X64)
|
||||||
//comment out all common names
|
//comment out all common names
|
||||||
@ -147,8 +165,6 @@ STATIC LINUX_PATH_DATA LinuxEntryData[] = {
|
|||||||
#endif
|
#endif
|
||||||
{ L"\\EFI\\SuSe\\elilo.efi", L"OpenSuse EFI boot menu", L"suse,linux" },
|
{ L"\\EFI\\SuSe\\elilo.efi", L"OpenSuse EFI boot menu", L"suse,linux" },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
STATIC CONST UINTN LinuxEntryDataCount = (sizeof(LinuxEntryData) / sizeof(LINUX_PATH_DATA));
|
STATIC CONST UINTN LinuxEntryDataCount = (sizeof(LinuxEntryData) / sizeof(LINUX_PATH_DATA));
|
||||||
|
|
||||||
#if defined(ANDX86)
|
#if defined(ANDX86)
|
||||||
@ -1254,15 +1270,24 @@ VOID ScanLoader(VOID)
|
|||||||
//DBG("Skip dot entries: %ls\n", DirEntry->FileName);
|
//DBG("Skip dot entries: %ls\n", DirEntry->FileName);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
XString OSName = SPrintf("%ls", DirEntry->FileName); //this is folder name "ubuntu"
|
|
||||||
XStringW File = SWPrintf("EFI\\%ls\\grubx64.efi", DirEntry->FileName);
|
XStringW File = SWPrintf("EFI\\%ls\\grubx64.efi", DirEntry->FileName);
|
||||||
|
XStringW OSName = SPrintf("%ls", DirEntry->FileName); // this is folder name, for example "ubuntu"
|
||||||
|
OSName.lowerAscii(); // lowercase for icon name
|
||||||
if (FileExists(Volume->RootDir, File.wc_str())) {
|
if (FileExists(Volume->RootDir, File.wc_str())) {
|
||||||
XStringW LoaderTitle = SWPrintf("%s OS EFI boot menu", OSName.c_str());
|
// check if nonstandard icon mapping is needed
|
||||||
XString IconXS = OSName + ",linux"_XS;
|
for (Index = 0; Index < LinuxIconMappingCount; ++Index) {
|
||||||
IconXS.lowerAscii(); //to avoid misconception
|
if (StrCmp(OSName.wc_str(),LinuxIconMapping[Index].DirectoryName) == 0) {
|
||||||
DBG(" found entry %s\n", IconXS.c_str());
|
OSName = XStringW().takeValueFrom(LinuxIconMapping[Index].IconName);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DBG(" found entry %ls,linux\n", OSName.wc_str());
|
||||||
|
XStringW LoaderTitle = OSName.subString(0,1); // capitalize first letter for title
|
||||||
|
LoaderTitle.upperAscii();
|
||||||
|
LoaderTitle += OSName.subString(1, OSName.length()) + L" Linux"_XSW;
|
||||||
XImage ImageX; //will the image be destroyed or rewritten by next image after the cycle end?
|
XImage ImageX; //will the image be destroyed or rewritten by next image after the cycle end?
|
||||||
ImageX = ThemeX.LoadOSIcon(IconXS);
|
// load from directory, as we don't have linux icons preloaded
|
||||||
|
ImageX.LoadXImage(ThemeX.ThemeDir, (L"os_"_XSW + OSName).wc_str());
|
||||||
AddLoaderEntry(File.wc_str(), ""_XS, LoaderTitle, Volume,
|
AddLoaderEntry(File.wc_str(), ""_XS, LoaderTitle, Volume,
|
||||||
(ImageX.isEmpty() ? NULL : &ImageX), OSTYPE_LINEFI, OSFLAG_NODEFAULTARGS);
|
(ImageX.isEmpty() ? NULL : &ImageX), OSTYPE_LINEFI, OSFLAG_NODEFAULTARGS);
|
||||||
} //anyway continue search other entries
|
} //anyway continue search other entries
|
||||||
@ -1275,7 +1300,7 @@ VOID ScanLoader(VOID)
|
|||||||
XStringW IconXSW = XStringW().takeValueFrom(LinuxEntryData[Index].Icon);
|
XStringW IconXSW = XStringW().takeValueFrom(LinuxEntryData[Index].Icon);
|
||||||
ImageX.LoadXImage(ThemeX.ThemeDir, (L"os_"_XSW + IconXSW.subString(0, IconXSW.indexOf(','))).wc_str());
|
ImageX.LoadXImage(ThemeX.ThemeDir, (L"os_"_XSW + IconXSW.subString(0, IconXSW.indexOf(','))).wc_str());
|
||||||
AddLoaderEntry(LinuxEntryData[Index].Path, ""_XS, XStringW().takeValueFrom(LinuxEntryData[Index].Title), Volume,
|
AddLoaderEntry(LinuxEntryData[Index].Path, ""_XS, XStringW().takeValueFrom(LinuxEntryData[Index].Title), Volume,
|
||||||
(ImageX.isEmpty() ? NULL : &ImageX), OSTYPE_LIN, OSFLAG_NODEFAULTARGS);
|
(ImageX.isEmpty() ? NULL : &ImageX), OSTYPE_LINEFI, OSFLAG_NODEFAULTARGS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// check for linux kernels
|
// check for linux kernels
|
||||||
|
@ -1380,24 +1380,22 @@ VOID REFIT_MENU_SCREEN::DrawBCSText(IN CONST CHAR16 *Text, IN INTN XPos, IN INTN
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// INTN TextLen = StrLen(Text);
|
|
||||||
|
|
||||||
// number of chars to be drawn on the screen
|
// number of chars to be drawn on the screen
|
||||||
INTN MaxTextLen = 13;
|
UINTN MaxTextLen = 15;
|
||||||
// INTN EllipsisLen = 2;
|
|
||||||
|
|
||||||
|
|
||||||
// some optimization
|
// some optimization
|
||||||
if (ThemeX.TileXSpace >= 25) {
|
if (ThemeX.TileXSpace >= 25) {
|
||||||
MaxTextLen = ThemeX.TileXSpace / 5 + 9;
|
MaxTextLen = ThemeX.TileXSpace / 5 + 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
// MaxTextLen += EllipsisLen;
|
|
||||||
XStringW BCSTextX;
|
XStringW BCSTextX;
|
||||||
|
if (StrLen(Text) <= MaxTextLen) { // if the text exceeds the given limit
|
||||||
BCSTextX.StrnCpy(Text, MaxTextLen);
|
BCSTextX.StrnCpy(Text, MaxTextLen);
|
||||||
|
} else {
|
||||||
|
BCSTextX.StrnCpy(Text, MaxTextLen - 2); // EllipsisLen=2
|
||||||
BCSTextX += L"..";
|
BCSTextX += L"..";
|
||||||
|
}
|
||||||
DrawTextXY(BCSTextX, XPos, YPos, XAlign);
|
DrawTextXY(BCSTextX, XPos, YPos, XAlign);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID REFIT_MENU_SCREEN::DrawMenuText(IN XStringW& Text, IN INTN SelectedWidth, IN INTN XPos, IN INTN YPos, IN UINTN Cursor)
|
VOID REFIT_MENU_SCREEN::DrawMenuText(IN XStringW& Text, IN INTN SelectedWidth, IN INTN XPos, IN INTN YPos, IN UINTN Cursor)
|
||||||
|
Loading…
Reference in New Issue
Block a user