take optional os icons

Signed-off-by: Sergey Isakov <isakov-sl@bk.ru>
This commit is contained in:
Sergey Isakov 2020-04-05 18:54:10 +03:00
parent 7b173d7f08
commit 4d9c1efd0c
4 changed files with 33 additions and 1 deletions

View File

@ -762,7 +762,9 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST CHAR16 *LoaderPath,
Entry->Image = *Image;
} else {
// Entry->Image = ThemeX.GetIcon("unknown"); //no such icon
Entry->Image = ThemeX.GetIcon("vol_internal"_XS);
//TODO now we have OSIconName = L"moja,mac"
// Entry->Image = ThemeX.GetIcon("vol_internal"_XS);
Entry->Image = ThemeX.LoadOSIcon(OSIconName);
}
// Load DriveImage
if (DriveImage) {

View File

@ -2660,6 +2660,7 @@ VOID REFIT_MENU_SCREEN::DrawMainMenuEntry(REFIT_ABSTRACT_MENU_ENTRY *Entry, BOOL
}
//this should be inited by the Theme
if (MainImage.isEmpty()) {
DBG(" why MainImage is empty?\n");
if (!IsEmbeddedTheme()) {
MainImage = ThemeX.GetIcon("os_mac"_XS);
}

View File

@ -193,6 +193,7 @@ void XTheme::Init()
//}
static XImage NullIcon;
static XImage DummyIcon;
const XImage& XTheme::GetIcon(const XString& Name) const
{
@ -225,6 +226,33 @@ const XImage& XTheme::GetIcon(INTN Id) const
}
return NullIcon;
}
const XImage& XTheme::LoadOSIcon(const CHAR16* OSIconName)
{
// input value can be L"win", L"ubuntu,linux", L"moja,mac" set by GetOSIconName (OSVersion)
XString Full = XString().takeValueFrom(OSIconName);
XString First;
XString Second;
const XImage *ReturnImage;
UINTN Comma = Full.IdxOf(',');
UINTN Size = Full.size();
if (Comma != MAX_XSIZE) { //Comma
First = "os_"_XS + Full.SubString(0, Comma);
ReturnImage = &GetIcon(First);
if (!ReturnImage->isEmpty()) return *ReturnImage;
//else search second name
Second = "os_"_XS + Full.SubString(Comma+1, Size - Comma - 1);
ReturnImage = &GetIcon(Second);
if (!ReturnImage->isEmpty()) return *ReturnImage;
} else {
ReturnImage = &GetIcon("os_"_XS + Full);
if (!ReturnImage->isEmpty()) return *ReturnImage;
}
// else something
if (DummyIcon.isEmpty()) //initialize once per session
DummyIcon.DummyImage(MainEntriesSize);
return DummyIcon;
}
//
//void XTheme::AddIcon(Icon& NewIcon)
//{

View File

@ -117,6 +117,7 @@ public:
// const XImage& GetIcon(const CHAR16* Name);
const XImage& GetIcon(const XString& Name) const; //get by name
const XImage& GetIcon(INTN Id) const; //get by id
const XImage& LoadOSIcon(const CHAR16* OSIconName); //TODO make XString provider
// void AddIcon(Icon& NewIcon); //return EFI_STATUS?
void FillByEmbedded();