diff --git a/rEFIt_UEFI/Platform/Settings.cpp b/rEFIt_UEFI/Platform/Settings.cpp index c5346989b..09bc8e143 100644 --- a/rEFIt_UEFI/Platform/Settings.cpp +++ b/rEFIt_UEFI/Platform/Settings.cpp @@ -122,7 +122,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 @@ -192,7 +191,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 @@ -2670,7 +2669,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) { @@ -2696,8 +2695,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; } } } @@ -2712,8 +2711,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; } } } @@ -3863,16 +3862,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; @@ -3998,7 +4008,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); @@ -4032,7 +4048,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"); diff --git a/rEFIt_UEFI/Platform/StartupSound.cpp b/rEFIt_UEFI/Platform/StartupSound.cpp index d79e49727..d52787bf9 100644 --- a/rEFIt_UEFI/Platform/StartupSound.cpp +++ b/rEFIt_UEFI/Platform/StartupSound.cpp @@ -34,7 +34,6 @@ #include "Settings.h" #include "Nvram.h" -extern BOOLEAN DayLight; extern UINTN AudioNum; extern HDA_OUTPUTS AudioList[20]; extern UINT8 EmbeddedSound[]; diff --git a/rEFIt_UEFI/libeg/VectorGraphics.cpp b/rEFIt_UEFI/libeg/VectorGraphics.cpp index 89acb04b7..7d81bea1a 100755 --- a/rEFIt_UEFI/libeg/VectorGraphics.cpp +++ b/rEFIt_UEFI/libeg/VectorGraphics.cpp @@ -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)) { diff --git a/rEFIt_UEFI/libeg/XTheme.cpp b/rEFIt_UEFI/libeg/XTheme.cpp index d63dfa1e6..2f327c9c3 100644 --- a/rEFIt_UEFI/libeg/XTheme.cpp +++ b/rEFIt_UEFI/libeg/XTheme.cpp @@ -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); } diff --git a/rEFIt_UEFI/libeg/nanosvg.cpp b/rEFIt_UEFI/libeg/nanosvg.cpp index b55cea6d3..e64c8895e 100644 --- a/rEFIt_UEFI/libeg/nanosvg.cpp +++ b/rEFIt_UEFI/libeg/nanosvg.cpp @@ -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) { diff --git a/rEFIt_UEFI/libeg/text.cpp b/rEFIt_UEFI/libeg/text.cpp index 4ea309e51..f6a0b35ce 100644 --- a/rEFIt_UEFI/libeg/text.cpp +++ b/rEFIt_UEFI/libeg/text.cpp @@ -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) !!! diff --git a/rEFIt_UEFI/refit/main.cpp b/rEFIt_UEFI/refit/main.cpp index 9f6834b09..1d04abcc1 100644 --- a/rEFIt_UEFI/refit/main.cpp +++ b/rEFIt_UEFI/refit/main.cpp @@ -2162,7 +2162,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]) { @@ -2417,7 +2417,6 @@ RefitMain (IN EFI_HANDLE ImageHandle, gThemeNeedInit = FALSE; } else if (gThemeChanged) { DBG("change theme\n"); - ThemeX.FillByEmbedded(); InitTheme(FALSE, NULL); OptionMenu.FreeMenu(); }