mirror of
https://github.com/CloverHackyColor/CloverBootloader.git
synced 2024-12-24 16:27:42 +01:00
load os icons for legacy
Signed-off-by: Sergey Isakov <isakov-sl@bk.ru>
This commit is contained in:
parent
1f2832897e
commit
2971779ddf
@ -173,9 +173,9 @@ BOOLEAN AddLegacyEntry(IN CONST CHAR16 *FullTitle, IN CONST CHAR16 *LoaderTitle,
|
||||
if (Image) {
|
||||
Entry->Image = *Image;
|
||||
} else {
|
||||
Entry->Image = ThemeX.GetIcon(XString().takeValueFrom(Volume->LegacyOS->IconName));
|
||||
Entry->Image = ThemeX.LoadOSIcon(Volume->LegacyOS->IconName);
|
||||
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
|
||||
|
@ -653,7 +653,7 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST CHAR16 *LoaderPath,
|
||||
case OSTYPE_OTHER:
|
||||
case OSTYPE_EFI:
|
||||
OSIconName = L"clover";
|
||||
ShortcutLetter = 'U';
|
||||
ShortcutLetter = 'E';
|
||||
Entry->LoaderType = OSTYPE_OTHER;
|
||||
break;
|
||||
default:
|
||||
|
@ -478,7 +478,7 @@ EFI_STATUS XTheme::ParseSVGXTheme(CONST CHAR8* buffer)
|
||||
if (i == BUILTIN_ICON_BANNER) { //exclude "logo" as it done other way
|
||||
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);
|
||||
// DBG("parse %s status %s\n", NewIcon->Name.c_str(), strerror(Status));
|
||||
/*Status = */ParseSVGXIcon(mainParser, i, NewIcon->Name + "_night"_XS, Scale, &NewIcon->ImageNight);
|
||||
|
@ -67,7 +67,7 @@ CONST CHAR8* IconsNames[] = {
|
||||
"vol_optical",
|
||||
"vol_firewire",
|
||||
"vol_clover" ,
|
||||
"vol_internal_hfs" ,
|
||||
"vol_internal_hfs" , //18
|
||||
"vol_internal_apfs",
|
||||
"vol_internal_ntfs",
|
||||
"vol_internal_ext3" ,
|
||||
@ -227,6 +227,11 @@ const XImage& XTheme::GetIcon(INTN Id) const
|
||||
return NullIcon;
|
||||
}
|
||||
|
||||
//const XImage& XTheme::LoadOSIcon(const XString& OSIconName)
|
||||
//{
|
||||
// return LoadOSIcon(XString().takeValueFrom(OSIconName));
|
||||
//}
|
||||
|
||||
const XImage& XTheme::LoadOSIcon(const CHAR16* OSIconName)
|
||||
{
|
||||
// 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;
|
||||
UINTN Comma = Full.IdxOf(',');
|
||||
UINTN Size = Full.size();
|
||||
// DBG("IconName=%ls comma=%lld size=%lld\n", OSIconName, Comma, Size);
|
||||
if (Comma != MAX_XSIZE) { //Comma
|
||||
First = "os_"_XS + Full.SubString(0, Comma);
|
||||
ReturnImage = &GetIcon(First);
|
||||
// DBG(" first=%s\n", First.c_str());
|
||||
if (!ReturnImage->isEmpty()) return *ReturnImage;
|
||||
//else search second name
|
||||
Second = "os_"_XS + Full.SubString(Comma+1, Size - Comma - 1);
|
||||
ReturnImage = &GetIcon(Second);
|
||||
// DBG(" Second=%s\n", Second.c_str());
|
||||
if (!ReturnImage->isEmpty()) return *ReturnImage;
|
||||
} else {
|
||||
ReturnImage = &GetIcon("os_"_XS + Full);
|
||||
// DBG(" Full=%s\n", Full.c_str());
|
||||
if (!ReturnImage->isEmpty()) return *ReturnImage;
|
||||
}
|
||||
// else something
|
||||
@ -269,14 +278,20 @@ const XImage& XTheme::LoadOSIcon(const CHAR16* OSIconName)
|
||||
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;
|
||||
Name.setEmpty();
|
||||
if (Index >= BUILTIN_ICON_FUNC_ABOUT && Index <= BUILTIN_CHECKBOX_CHECKED) {
|
||||
Name.takeValueFrom(IconsNames[Index]);
|
||||
}
|
||||
if (TakeEmbedded) {
|
||||
GetEmbedded();
|
||||
}
|
||||
}
|
||||
|
||||
void Icon::GetEmbedded()
|
||||
{
|
||||
switch (Id) {
|
||||
case BUILTIN_ICON_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();
|
||||
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);
|
||||
}
|
||||
//and buttons
|
||||
@ -671,7 +686,7 @@ void XTheme::FillByDir() //assume ThemeDir is defined by InitTheme() procedure
|
||||
{
|
||||
Icons.Empty();
|
||||
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->ImageNight.LoadXImage(ThemeDir, SWPrintf("%s_night", IconsNames[i]));
|
||||
Icons.AddReference(NewIcon, true);
|
||||
|
@ -19,12 +19,13 @@ public:
|
||||
XImage Image;
|
||||
XImage ImageNight;
|
||||
|
||||
Icon(INTN Id);
|
||||
Icon(INTN Id, bool Embedded = false);
|
||||
~Icon();
|
||||
|
||||
// Default are not valid, as usual. We delete them. If needed, proper ones can be created
|
||||
Icon(const Icon&) = delete;
|
||||
Icon& operator=(const Icon&) = delete;
|
||||
void GetEmbedded();
|
||||
};
|
||||
|
||||
class XTheme
|
||||
|
Loading…
Reference in New Issue
Block a user