mirror of
https://github.com/CloverHackyColor/CloverBootloader.git
synced 2024-11-23 11:35:19 +01:00
Correct theme Daylight, DarkEmbedded, some other theme issues
This commit is contained in:
parent
ea2cb13808
commit
f86e36a7e5
@ -121,7 +121,6 @@ BOOLEAN SetTable132 = FALSE;
|
||||
|
||||
//EG_PIXEL SelectionBackgroundPixel = { 0xef, 0xef, 0xef, 0xff }; //define in lib.h
|
||||
const INTN BCSMargin = 11;
|
||||
BOOLEAN DayLight;
|
||||
|
||||
//
|
||||
DRIVERS_FLAGS gDriversFlags; //the initializer is not needed for global variables
|
||||
@ -190,7 +189,7 @@ REFIT_CONFIG GlobalConfig = {
|
||||
FALSE, // BOOLEAN CustomIcons;
|
||||
ICON_FORMAT_DEF, // INTN IconFormat;
|
||||
FALSE, // BOOLEAN NoEarlyProgress;
|
||||
0, // INT32 Timezone;
|
||||
0xFF, // INT32 Timezone; / 0xFF - not set
|
||||
FALSE, // BOOLEAN ShowOptimus;
|
||||
0xC0, // INTN Codepage;
|
||||
0xC0, // INTN CodepageSize; //extended latin
|
||||
@ -2668,7 +2667,7 @@ GetEarlyUserSettings (
|
||||
INT32 NowHour = Now.Hour + GlobalConfig.Timezone;
|
||||
if (NowHour < 0 ) NowHour += 24;
|
||||
if (NowHour >= 24 ) NowHour -= 24;
|
||||
DayLight = (NowHour > 8) && (NowHour < 20);
|
||||
ThemeX.Daylight = (NowHour > 8) && (NowHour < 20);
|
||||
|
||||
Prop = GetProperty (DictPointer, "Theme");
|
||||
if (Prop != NULL) {
|
||||
@ -2694,8 +2693,8 @@ GetEarlyUserSettings (
|
||||
ThemeX.DarkEmbedded = FALSE;
|
||||
ThemeX.Font = FONT_ALFA;
|
||||
} else if (AsciiStriCmp (Prop->string, "DayTime") == 0) {
|
||||
ThemeX.DarkEmbedded = !DayLight;
|
||||
ThemeX.Font = DayLight?FONT_ALFA:FONT_GRAY;
|
||||
ThemeX.DarkEmbedded = !ThemeX.Daylight;
|
||||
ThemeX.Font = ThemeX.Daylight?FONT_ALFA:FONT_GRAY;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2710,8 +2709,8 @@ GetEarlyUserSettings (
|
||||
ThemeX.DarkEmbedded = FALSE;
|
||||
ThemeX.Font = FONT_ALFA;
|
||||
} else if (AsciiStriCmp (Prop->string, "Daytime") == 0) {
|
||||
ThemeX.DarkEmbedded = !DayLight;
|
||||
ThemeX.Font = DayLight?FONT_ALFA:FONT_GRAY;
|
||||
ThemeX.DarkEmbedded = !ThemeX.Daylight;
|
||||
ThemeX.Font = ThemeX.Daylight?FONT_ALFA:FONT_GRAY;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3861,16 +3860,27 @@ InitTheme(BOOLEAN UseThemeDefinedInNVRam, EFI_TIME *Time)
|
||||
CHAR8 *ChosenTheme = NULL;
|
||||
CHAR16 *TestTheme = NULL;
|
||||
UINTN Rnd;
|
||||
|
||||
DbgHeader("InitXTheme");
|
||||
ThemeX.Init();
|
||||
|
||||
if (DayLight) {
|
||||
DBG("use daylight theme\n");
|
||||
EFI_TIME Now;
|
||||
|
||||
//initialize Daylight when we know timezone
|
||||
if (GlobalConfig.Timezone != 0xFF) { // 0xFF:default=timezone not set
|
||||
gRT->GetTime(&Now, NULL);
|
||||
INT32 NowHour = Now.Hour + GlobalConfig.Timezone;
|
||||
if (NowHour < 0 ) NowHour += 24;
|
||||
if (NowHour >= 24 ) NowHour -= 24;
|
||||
ThemeX.Daylight = (NowHour > 8) && (NowHour < 20);
|
||||
} else {
|
||||
ThemeX.Daylight = TRUE; // when timezone is not set
|
||||
}
|
||||
if (ThemeX.Daylight) {
|
||||
DBG("use Daylight theme\n");
|
||||
} else {
|
||||
DBG("use night theme\n");
|
||||
}
|
||||
|
||||
DbgHeader("InitXTheme");
|
||||
ThemeX.Init();
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
// DBG("validate %d face\n", i);
|
||||
textFace[i].valid = FALSE;
|
||||
@ -3996,7 +4006,13 @@ InitTheme(BOOLEAN UseThemeDefinedInNVRam, EFI_TIME *Time)
|
||||
finish:
|
||||
if (!ThemeDict) { // No theme could be loaded, use embedded
|
||||
DBG (" using embedded theme\n");
|
||||
ThemeX.Init();
|
||||
if (ThemeX.DarkEmbedded) { // when using embedded, set Daylight according to darkembedded
|
||||
ThemeX.Daylight = FALSE;
|
||||
} else {
|
||||
ThemeX.Daylight = TRUE;
|
||||
}
|
||||
|
||||
ThemeX.FillByEmbedded();
|
||||
OldChosenTheme = 0xFFFF;
|
||||
if (ThemePath != NULL) {
|
||||
FreePool (ThemePath);
|
||||
@ -4030,7 +4046,7 @@ finish:
|
||||
}
|
||||
FreeTag(ThemeDict);
|
||||
|
||||
if (!DayLight) {
|
||||
if (!ThemeX.Daylight) {
|
||||
Status = StartupSoundPlay(ThemeX.ThemeDir, L"sound_night.wav");
|
||||
if (EFI_ERROR(Status)) {
|
||||
Status = StartupSoundPlay(ThemeX.ThemeDir, L"sound.wav");
|
||||
|
@ -34,7 +34,6 @@
|
||||
#include "Settings.h"
|
||||
#include "Nvram.h"
|
||||
|
||||
extern BOOLEAN DayLight;
|
||||
extern UINTN AudioNum;
|
||||
extern HDA_OUTPUTS AudioList[20];
|
||||
extern UINT8 EmbeddedSound[];
|
||||
|
@ -49,8 +49,6 @@ extern void DumpFloat2 (CONST char* s, float* t, int N);
|
||||
|
||||
extern UINTN NumFrames;
|
||||
extern UINTN FrameTime;
|
||||
extern BOOLEAN DayLight;
|
||||
|
||||
|
||||
textFaces textFace[4]; //0-help 1-message 2-menu 3-test, far future it will be infinite list with id
|
||||
|
||||
@ -272,7 +270,7 @@ EFI_STATUS XTheme::ParseSVGXTheme(CONST CHAR8* buffer)
|
||||
BigBack.setEmpty();
|
||||
}
|
||||
Status = EFI_NOT_FOUND;
|
||||
if (!DayLight) {
|
||||
if (!ThemeX.Daylight) {
|
||||
Status = ParseSVGXIcon(BUILTIN_ICON_BACKGROUND, "Background_night"_XS, &BigBack);
|
||||
}
|
||||
if (EFI_ERROR(Status)) {
|
||||
@ -282,7 +280,7 @@ EFI_STATUS XTheme::ParseSVGXTheme(CONST CHAR8* buffer)
|
||||
// --- Make Banner
|
||||
Banner.setEmpty(); //for the case of theme switch
|
||||
Status = EFI_NOT_FOUND;
|
||||
if (!DayLight) {
|
||||
if (!ThemeX.Daylight) {
|
||||
Status = ParseSVGXIcon(BUILTIN_ICON_BANNER, "Banner_night"_XS, &Banner);
|
||||
}
|
||||
if (EFI_ERROR(Status)) {
|
||||
@ -327,7 +325,7 @@ EFI_STATUS XTheme::ParseSVGXTheme(CONST CHAR8* buffer)
|
||||
|
||||
//selection for bootcamp style
|
||||
Status = EFI_NOT_FOUND;
|
||||
if (!DayLight) {
|
||||
if (!ThemeX.Daylight) {
|
||||
Status = ParseSVGXIcon(BUILTIN_ICON_SELECTION, "selection_indicator_night"_XS, &SelectionImages[4]);
|
||||
}
|
||||
if (EFI_ERROR(Status)) {
|
||||
|
@ -220,8 +220,8 @@ void XTheme::Init()
|
||||
SelectionColor = 0x80808080;
|
||||
SelectionBackgroundPixel = { 0xef, 0xef, 0xef, 0xff };
|
||||
FontFileName.setEmpty();
|
||||
Theme.takeValueFrom("embedded");
|
||||
embedded = true;
|
||||
// Theme.takeValueFrom("embedded");
|
||||
embedded = false;
|
||||
BannerFileName.setEmpty();
|
||||
SelectionSmallFileName.setEmpty();
|
||||
SelectionBigFileName.setEmpty();
|
||||
@ -254,13 +254,13 @@ void XTheme::Init()
|
||||
// IconFormat = ICON_FORMAT_DEF;
|
||||
Proportional = FALSE;
|
||||
// ShowOptimus = FALSE;
|
||||
DarkEmbedded = FALSE; //looks like redundant, we always check Night or Daylight
|
||||
// DarkEmbedded = FALSE; //looks like redundant, we always check Night or Daylight
|
||||
TypeSVG = FALSE;
|
||||
// Codepage = 0xC0; //this is for PNG theme
|
||||
// CodepageSize = 0xC0; // INTN CodepageSize; //extended latin
|
||||
Scale = 1.0f;
|
||||
CentreShift = 0.0f;
|
||||
Daylight = true;
|
||||
// Daylight = true;
|
||||
LayoutHeight = 376;
|
||||
LayoutBannerOffset = 64; //default value if not set
|
||||
LayoutButtonOffset = 0; //default value if not set
|
||||
@ -419,23 +419,25 @@ const XImage& XTheme::LoadOSIcon(const XString& Full)
|
||||
|
||||
void XTheme::FillByEmbedded()
|
||||
{
|
||||
embedded = true;
|
||||
Theme.takeValueFrom("embedded");
|
||||
SelectionColor = 0xA0A0A080;
|
||||
SelectionBackgroundPixel = { 0xa0, 0xa0, 0xa0, 0x80 };
|
||||
|
||||
Icons.Empty();
|
||||
for (INTN i = 0; i < BUILTIN_ICON_COUNT; ++i) { //this is embedded icon count
|
||||
Icon* NewIcon = new Icon(i, true);
|
||||
Icons.AddReference(NewIcon, true);
|
||||
}
|
||||
|
||||
Background = XImage(UGAWidth, UGAHeight);
|
||||
if (DarkEmbedded) {
|
||||
Background.Fill(DarkEmbeddedBackgroundPixel);
|
||||
} else {
|
||||
Background.Fill(StdBackgroundPixel);
|
||||
}
|
||||
BigBack.setEmpty();
|
||||
Background = XImage(UGAWidth, UGAHeight);
|
||||
|
||||
if (Daylight) {
|
||||
Background.Fill(StdBackgroundPixel);
|
||||
Banner.FromPNG(ACCESS_EMB_DATA(emb_logo), emb_logo_size);
|
||||
} else {
|
||||
Background.Fill(DarkEmbeddedBackgroundPixel);
|
||||
Banner.FromPNG(ACCESS_EMB_DATA(emb_dark_logo), emb_dark_logo_size);
|
||||
}
|
||||
|
||||
|
@ -106,8 +106,6 @@ int nsvg__shapesBound(NSVGshape *shapes, float* bounds);
|
||||
void takeXformBounds(NSVGshape *shape, float *xform, float *bounds);
|
||||
void nsvg__deleteShapes(NSVGshape* shape);
|
||||
|
||||
extern BOOLEAN DayLight;
|
||||
|
||||
void DumpFloat2 (CONST char* s, float* t, int N)
|
||||
{
|
||||
#if DEBUG_SVG
|
||||
@ -2917,8 +2915,8 @@ static void nsvg__parseText(NSVGparser* p, const char** dict)
|
||||
DBG("set message->font=%s color=%X size=%f as in MessageRow\n", fontSVG->fontFamily, text->fontColor, text->fontSize);
|
||||
}
|
||||
break;
|
||||
} else if (!DayLight && strcmp(group->id, "MessageRow_night") == 0) {
|
||||
//replace daylight settings
|
||||
} else if (!ThemeX.Daylight && strcmp(group->id, "MessageRow_night") == 0) {
|
||||
//replace ThemeX.Daylight settings
|
||||
p->font = fontSVG;
|
||||
p->fontSize = text->fontSize;
|
||||
p->fontColor = text->fontColor;
|
||||
@ -2937,7 +2935,7 @@ static void nsvg__parseText(NSVGparser* p, const char** dict)
|
||||
DBG("set menu->font=%s color=%X size=%f as in MenuRows\n", fontSVG->fontFamily, text->fontColor, text->fontSize);
|
||||
}
|
||||
break;
|
||||
} else if (!DayLight && strcmp(group->id, "MenuRows_night") == 0) {
|
||||
} else if (!ThemeX.Daylight && strcmp(group->id, "MenuRows_night") == 0) {
|
||||
textFace[2].font = fontSVG;
|
||||
textFace[2].size = (INTN)text->fontSize;
|
||||
textFace[2].color = text->fontColor;
|
||||
@ -2952,7 +2950,7 @@ static void nsvg__parseText(NSVGparser* p, const char** dict)
|
||||
DBG("set help->font=%s color=%X size=%f as in HelpRows\n", fontSVG->fontFamily, text->fontColor, text->fontSize);
|
||||
}
|
||||
break;
|
||||
} else if (!DayLight && strstr(group->id, "HelpRows_night") != NULL) {
|
||||
} else if (!ThemeX.Daylight && strstr(group->id, "HelpRows_night") != NULL) {
|
||||
textFace[0].font = fontSVG;
|
||||
textFace[0].size = (INTN)text->fontSize;
|
||||
textFace[0].color = text->fontColor;
|
||||
@ -3518,12 +3516,12 @@ void XTheme::parseTheme(void* parser, const char** dict)
|
||||
BadgeScale = getIntegerDict(dict[i + 1]);
|
||||
} else if (strcmp(dict[i], "SelectionColor") == 0) {
|
||||
Color = getIntegerDict(dict[i + 1]);
|
||||
if (DayLight) {
|
||||
if (ThemeX.Daylight) {
|
||||
SelectionColor = Color;
|
||||
}
|
||||
} else if (strcmp(dict[i], "SelectionColor_night") == 0) {
|
||||
found = TRUE;
|
||||
if (!DayLight) {
|
||||
if (!ThemeX.Daylight) {
|
||||
SelectionColor = getIntegerDict(dict[i + 1]);
|
||||
}
|
||||
} else if (strcmp(dict[i], "VerticalLayout") == 0) {
|
||||
|
@ -158,7 +158,8 @@ void XTheme::LoadFontImage(IN BOOLEAN UseEmbedded, IN INTN Rows, IN INTN Cols)
|
||||
(PixelPtr->Red == FirstPixel.Red)
|
||||
) {
|
||||
PixelPtr->Reserved = 0; //if a pixel has same color as first pixel then it will be transparent
|
||||
} else if (ThemeX.DarkEmbedded) {
|
||||
//} else if (ThemeX.DarkEmbedded) {
|
||||
} else if (!ThemeX.Daylight) {
|
||||
*PixelPtr = SemiWhitePixel; //special case to change a text to semi white, not blue pixels
|
||||
}
|
||||
FontPtr[Ypos + x] = *PixelPtr++; //not (x, YPos) !!!
|
||||
|
@ -2163,7 +2163,7 @@ RefitMain (IN EFI_HANDLE ImageHandle,
|
||||
GetListOfConfigs();
|
||||
}
|
||||
|
||||
ThemeX.FillByEmbedded(); //init XTheme before EarlyUserSettings
|
||||
// ThemeX.FillByEmbedded(); //init XTheme before EarlyUserSettings
|
||||
|
||||
for (i=0; i<2; i++) {
|
||||
if (gConfigDict[i]) {
|
||||
@ -2418,7 +2418,6 @@ RefitMain (IN EFI_HANDLE ImageHandle,
|
||||
gThemeNeedInit = FALSE;
|
||||
} else if (gThemeChanged) {
|
||||
DBG("change theme\n");
|
||||
ThemeX.FillByEmbedded();
|
||||
InitTheme(FALSE, NULL);
|
||||
OptionMenu.FreeMenu();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user