load os icons for legacy

Signed-off-by: Sergey Isakov <isakov-sl@bk.ru>
This commit is contained in:
Sergey Isakov 2020-04-06 00:14:27 +03:00
parent 1f2832897e
commit 2971779ddf
6 changed files with 27 additions and 11 deletions

View File

@ -173,9 +173,9 @@ BOOLEAN AddLegacyEntry(IN CONST CHAR16 *FullTitle, IN CONST CHAR16 *LoaderTitle,
if (Image) { if (Image) {
Entry->Image = *Image; Entry->Image = *Image;
} else { } else {
Entry->Image = ThemeX.GetIcon(XString().takeValueFrom(Volume->LegacyOS->IconName)); Entry->Image = ThemeX.LoadOSIcon(Volume->LegacyOS->IconName);
if (Entry->Image.isEmpty()) { if (Entry->Image.isEmpty()) {
Entry->Image = ThemeX.GetIcon("vol_internal"_XS); //we have no legacy.png Entry->Image = ThemeX.GetIcon("os_win"_XS); //we have no legacy.png
} }
} }
#else #else

View File

@ -653,7 +653,7 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST CHAR16 *LoaderPath,
case OSTYPE_OTHER: case OSTYPE_OTHER:
case OSTYPE_EFI: case OSTYPE_EFI:
OSIconName = L"clover"; OSIconName = L"clover";
ShortcutLetter = 'U'; ShortcutLetter = 'E';
Entry->LoaderType = OSTYPE_OTHER; Entry->LoaderType = OSTYPE_OTHER;
break; break;
default: default:

View File

@ -478,7 +478,7 @@ EFI_STATUS XTheme::ParseSVGXTheme(CONST CHAR8* buffer)
if (i == BUILTIN_ICON_BANNER) { //exclude "logo" as it done other way if (i == BUILTIN_ICON_BANNER) { //exclude "logo" as it done other way
continue; continue;
} }
Icon* NewIcon = new Icon(i); //initialize with embedded but further replace by loaded Icon* NewIcon = new Icon(i, false); //initialize without embedded
/*Status = */ParseSVGXIcon(mainParser, i, NewIcon->Name, Scale, &NewIcon->Image); /*Status = */ParseSVGXIcon(mainParser, i, NewIcon->Name, Scale, &NewIcon->Image);
// DBG("parse %s status %s\n", NewIcon->Name.c_str(), strerror(Status)); // DBG("parse %s status %s\n", NewIcon->Name.c_str(), strerror(Status));
/*Status = */ParseSVGXIcon(mainParser, i, NewIcon->Name + "_night"_XS, Scale, &NewIcon->ImageNight); /*Status = */ParseSVGXIcon(mainParser, i, NewIcon->Name + "_night"_XS, Scale, &NewIcon->ImageNight);

View File

@ -67,7 +67,7 @@ CONST CHAR8* IconsNames[] = {
"vol_optical", "vol_optical",
"vol_firewire", "vol_firewire",
"vol_clover" , "vol_clover" ,
"vol_internal_hfs" , "vol_internal_hfs" , //18
"vol_internal_apfs", "vol_internal_apfs",
"vol_internal_ntfs", "vol_internal_ntfs",
"vol_internal_ext3" , "vol_internal_ext3" ,
@ -227,6 +227,11 @@ const XImage& XTheme::GetIcon(INTN Id) const
return NullIcon; return NullIcon;
} }
//const XImage& XTheme::LoadOSIcon(const XString& OSIconName)
//{
// return LoadOSIcon(XString().takeValueFrom(OSIconName));
//}
const XImage& XTheme::LoadOSIcon(const CHAR16* OSIconName) const XImage& XTheme::LoadOSIcon(const CHAR16* OSIconName)
{ {
// input value can be L"win", L"ubuntu,linux", L"moja,mac" set by GetOSIconName (OSVersion) // input value can be L"win", L"ubuntu,linux", L"moja,mac" set by GetOSIconName (OSVersion)
@ -236,16 +241,20 @@ const XImage& XTheme::LoadOSIcon(const CHAR16* OSIconName)
const XImage *ReturnImage; const XImage *ReturnImage;
UINTN Comma = Full.IdxOf(','); UINTN Comma = Full.IdxOf(',');
UINTN Size = Full.size(); UINTN Size = Full.size();
// DBG("IconName=%ls comma=%lld size=%lld\n", OSIconName, Comma, Size);
if (Comma != MAX_XSIZE) { //Comma if (Comma != MAX_XSIZE) { //Comma
First = "os_"_XS + Full.SubString(0, Comma); First = "os_"_XS + Full.SubString(0, Comma);
ReturnImage = &GetIcon(First); ReturnImage = &GetIcon(First);
// DBG(" first=%s\n", First.c_str());
if (!ReturnImage->isEmpty()) return *ReturnImage; if (!ReturnImage->isEmpty()) return *ReturnImage;
//else search second name //else search second name
Second = "os_"_XS + Full.SubString(Comma+1, Size - Comma - 1); Second = "os_"_XS + Full.SubString(Comma+1, Size - Comma - 1);
ReturnImage = &GetIcon(Second); ReturnImage = &GetIcon(Second);
// DBG(" Second=%s\n", Second.c_str());
if (!ReturnImage->isEmpty()) return *ReturnImage; if (!ReturnImage->isEmpty()) return *ReturnImage;
} else { } else {
ReturnImage = &GetIcon("os_"_XS + Full); ReturnImage = &GetIcon("os_"_XS + Full);
// DBG(" Full=%s\n", Full.c_str());
if (!ReturnImage->isEmpty()) return *ReturnImage; if (!ReturnImage->isEmpty()) return *ReturnImage;
} }
// else something // else something
@ -269,14 +278,20 @@ const XImage& XTheme::LoadOSIcon(const CHAR16* OSIconName)
ImageNight.FromPNG(ACCESS_EMB_DATA(dark), ACCESS_EMB_SIZE(dark)); \ ImageNight.FromPNG(ACCESS_EMB_DATA(dark), ACCESS_EMB_SIZE(dark)); \
} }
Icon::Icon(INTN Index) : Image(0), ImageNight(0) Icon::Icon(INTN Index, bool TakeEmbedded) : Image(0), ImageNight(0)
{ {
Id = Index; Id = Index;
Name.setEmpty(); Name.setEmpty();
if (Index >= BUILTIN_ICON_FUNC_ABOUT && Index <= BUILTIN_CHECKBOX_CHECKED) { if (Index >= BUILTIN_ICON_FUNC_ABOUT && Index <= BUILTIN_CHECKBOX_CHECKED) {
Name.takeValueFrom(IconsNames[Index]); Name.takeValueFrom(IconsNames[Index]);
} }
if (TakeEmbedded) {
GetEmbedded();
}
}
void Icon::GetEmbedded()
{
switch (Id) { switch (Id) {
case BUILTIN_ICON_FUNC_ABOUT: case BUILTIN_ICON_FUNC_ABOUT:
DEC_BUILTIN_ICON2(BUILTIN_ICON_FUNC_ABOUT, emb_func_about, emb_dark_func_about) DEC_BUILTIN_ICON2(BUILTIN_ICON_FUNC_ABOUT, emb_func_about, emb_dark_func_about)
@ -374,7 +389,7 @@ void XTheme::FillByEmbedded()
{ {
Icons.Empty(); Icons.Empty();
for (INTN i = 0; i < BUILTIN_ICON_COUNT; ++i) { //this is embedded icon count for (INTN i = 0; i < BUILTIN_ICON_COUNT; ++i) { //this is embedded icon count
Icon* NewIcon = new Icon(i); Icon* NewIcon = new Icon(i, true);
Icons.AddReference(NewIcon, true); Icons.AddReference(NewIcon, true);
} }
//and buttons //and buttons
@ -671,7 +686,7 @@ void XTheme::FillByDir() //assume ThemeDir is defined by InitTheme() procedure
{ {
Icons.Empty(); Icons.Empty();
for (INTN i = 0; i <= BUILTIN_CHECKBOX_CHECKED; ++i) { for (INTN i = 0; i <= BUILTIN_CHECKBOX_CHECKED; ++i) {
Icon* NewIcon = new Icon(i); //initialize with embedded but further replace by loaded Icon* NewIcon = new Icon(i); //initialize without embedded
NewIcon->Image.LoadXImage(ThemeDir, IconsNames[i]); NewIcon->Image.LoadXImage(ThemeDir, IconsNames[i]);
NewIcon->ImageNight.LoadXImage(ThemeDir, SWPrintf("%s_night", IconsNames[i])); NewIcon->ImageNight.LoadXImage(ThemeDir, SWPrintf("%s_night", IconsNames[i]));
Icons.AddReference(NewIcon, true); Icons.AddReference(NewIcon, true);

View File

@ -19,12 +19,13 @@ public:
XImage Image; XImage Image;
XImage ImageNight; XImage ImageNight;
Icon(INTN Id); Icon(INTN Id, bool Embedded = false);
~Icon(); ~Icon();
// Default are not valid, as usual. We delete them. If needed, proper ones can be created // Default are not valid, as usual. We delete them. If needed, proper ones can be created
Icon(const Icon&) = delete; Icon(const Icon&) = delete;
Icon& operator=(const Icon&) = delete; Icon& operator=(const Icon&) = delete;
void GetEmbedded();
}; };
class XTheme class XTheme

View File

@ -1683,7 +1683,7 @@ VOID SetVariablesFromNvram()
} }
// For the moment only arg -s must be ignored // For the moment only arg -s must be ignored
if (AsciiStrCmp(arg, "-s") == 0) { if (AsciiStrCmp(arg, "-s") == 0) {
DBG("...ignoring arg:%s\n", arg); DBG("...ignoring arg:%s\n", arg);
continue; continue;
} }
if (!AsciiStrStr(gSettings.BootArgs, arg)) { if (!AsciiStrStr(gSettings.BootArgs, arg)) {
@ -1691,7 +1691,7 @@ VOID SetVariablesFromNvram()
DBG("...adding arg:%s\n", arg); DBG("...adding arg:%s\n", arg);
len = iStrLen(gSettings.BootArgs, 256); len = iStrLen(gSettings.BootArgs, 256);
if (len + index2 > 256) { if (len + index2 > 256) {
DBG("boot-args overflow... bytes=%llu+%llu\n", len, index2); DBG("boot-args overflow... bytes=%llu+%llu\n", len, index2);
break; break;
} }
gSettings.BootArgs[len++] = 0x20; gSettings.BootArgs[len++] = 0x20;