diff --git a/rEFIt_UEFI/cpp_foundation/XArray.h b/rEFIt_UEFI/cpp_foundation/XArray.h index 5de08b3ab..7d88b97b4 100755 --- a/rEFIt_UEFI/cpp_foundation/XArray.h +++ b/rEFIt_UEFI/cpp_foundation/XArray.h @@ -102,7 +102,7 @@ class XArray bool isEmpty() const { return size() == 0; } xsize IdxOf(TYPE& e) const; - bool ExistIn(TYPE& e) const { return IdxOf(e) != MAX_XSIZE; } + bool ExistIn(TYPE& e) const { return IdxOf(e) != MAX_XSIZE; } //logically it should be named as Contains(e) }; //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx diff --git a/rEFIt_UEFI/cpp_foundation/XStringWP.cpp b/rEFIt_UEFI/cpp_foundation/XStringWP.cpp index d3185990c..176c1e5ff 100755 --- a/rEFIt_UEFI/cpp_foundation/XStringWP.cpp +++ b/rEFIt_UEFI/cpp_foundation/XStringWP.cpp @@ -32,17 +32,19 @@ XStringWP::XStringWP(const wchar_t *S) { if ( !S ) { - DebugLog(2, "XStringWP(const wchar_t *S) called with NULL. Use setEmpty()\n"); - panic(); - } -DBG("Constructor(const wchar_t *S) : %ls, StrLen(S)=%d\n", S, StrLen(S)); - Init(wcslen(S)); - StrCpy(S); +// DebugLog(2, "XStringWP(const wchar_t *S) called with NULL. Use setEmpty()\n"); +// panic(); + Init(0); + } else { + DBG("Constructor(const wchar_t *S) : %ls, StrLen(S)=%d\n", S, StrLen(S)); + Init(wcslen(S)); + StrCpy(S); + } } XStringWP::XStringWP(const char* S) { -DBG("Constructor(const char* S)\n"); + DBG("Constructor(const char* S)\n"); xsize newLen = StrLenInWChar(S); Init(newLen); utf8ToWChar(m_data, m_allocatedSize+1, S); // m_size doesn't count the NULL terminator diff --git a/rEFIt_UEFI/entry_scan/common.cpp b/rEFIt_UEFI/entry_scan/common.cpp index f2637d72f..43f9047dd 100644 --- a/rEFIt_UEFI/entry_scan/common.cpp +++ b/rEFIt_UEFI/entry_scan/common.cpp @@ -180,10 +180,11 @@ CHAR16 *AddLoadOption(IN CONST CHAR16 *LoadOptions, IN CONST CHAR16 *LoadOption) return EfiStrDuplicate(LoadOption); } // If there is no option or it is already present duplicate original + // with XStringW it will be replaced by if (LoadOptions.ExistIn(LoadOption)) else if ((LoadOption == NULL) || StrStr(LoadOptions, LoadOption)) return EfiStrDuplicate(LoadOptions); // Otherwise add option - return PoolPrint(L"%s %s", LoadOptions, LoadOption); + return PoolPrint(L"%s %s", LoadOptions, LoadOption); //LoadOptions + LoadOption } CHAR16 *RemoveLoadOption(IN CONST CHAR16 *LoadOptions, IN CONST CHAR16 *LoadOption) diff --git a/rEFIt_UEFI/entry_scan/tool.cpp b/rEFIt_UEFI/entry_scan/tool.cpp index 142985a9a..5fe4ee44d 100644 --- a/rEFIt_UEFI/entry_scan/tool.cpp +++ b/rEFIt_UEFI/entry_scan/tool.cpp @@ -363,10 +363,12 @@ VOID AddCustomTool(VOID) } #if USE_XTHEME if (Image == NULL) { - AddToolEntry(Custom->Path, Custom->FullTitle, Custom->Title, ThemeX.GetIcon(BUILTIN_ICON_TOOL_SHELL), Custom->Hotkey, Custom->Options); + AddToolEntry(Custom->Path, Custom->FullTitle, Custom->Title, Volume, ThemeX.GetIcon(BUILTIN_ICON_TOOL_SHELL), Custom->Hotkey, Custom->Options); } else { // Create a legacy entry for this volume - AddToolEntry(Custom->Path, Custom->FullTitle, Custom->Title, Volume, XImage().FromEGImage(Image), Custom->Hotkey, Custom->Options); + XImage ImageX; + ImageX.FromEGImage(Image); + AddToolEntry(Custom->Path, Custom->FullTitle, Custom->Title, Volume, ImageX, Custom->Hotkey, Custom->Options); } #else if (Image == NULL) { diff --git a/rEFIt_UEFI/libeg/XImage.cpp b/rEFIt_UEFI/libeg/XImage.cpp index c1d680b54..8279f4162 100644 --- a/rEFIt_UEFI/libeg/XImage.cpp +++ b/rEFIt_UEFI/libeg/XImage.cpp @@ -541,6 +541,11 @@ EFI_STATUS XImage::LoadXImage(EFI_FILE *BaseDir, const char* IconName) { return LoadXImage(BaseDir, XStringWP(IconName)); } + +EFI_STATUS XImage::LoadXImage(EFI_FILE *BaseDir, const wchar_t* LIconName) +{ + return LoadXImage(BaseDir, XStringWP(LIconName)); +} //dont call this procedure for SVG theme BaseDir == NULL? EFI_STATUS XImage::LoadXImage(EFI_FILE *BaseDir, const XStringW& IconName) { diff --git a/rEFIt_UEFI/libeg/XImage.h b/rEFIt_UEFI/libeg/XImage.h index 7025795a5..215985b30 100644 --- a/rEFIt_UEFI/libeg/XImage.h +++ b/rEFIt_UEFI/libeg/XImage.h @@ -101,6 +101,7 @@ public: //I changed the name because LoadImage is too widely used // will be used instead of old egLoadImage EFI_STATUS LoadXImage(EFI_FILE *Dir, const XStringW& FileName); //for example LoadImage(ThemeDir, L"icons\\" + Name); + EFI_STATUS LoadXImage(EFI_FILE *Dir, const wchar_t* LIconName); EFI_STATUS LoadXImage(EFI_FILE *Dir, const char* IconName); EFI_STATUS LoadIcns(IN EFI_FILE *Dir, IN CONST CHAR16 *FileName, IN UINTN PixelSize); void EnsureImageSize(IN UINTN Width, IN UINTN Height, IN CONST EFI_GRAPHICS_OUTPUT_BLT_PIXEL& Color); diff --git a/rEFIt_UEFI/libeg/XTheme.cpp b/rEFIt_UEFI/libeg/XTheme.cpp index 75e88b061..e4af68f66 100644 --- a/rEFIt_UEFI/libeg/XTheme.cpp +++ b/rEFIt_UEFI/libeg/XTheme.cpp @@ -175,6 +175,11 @@ const XImage& XTheme::GetIcon(const char* Name) return GetIcon(XString().takeValueFrom(Name)); } +const XImage& XTheme::GetIcon(const CHAR16* Name) +{ + return GetIcon(XString().takeValueFrom(Name)); +} + static XImage NullIcon; const XImage& XTheme::GetIcon(const XString& Name) diff --git a/rEFIt_UEFI/libeg/XTheme.h b/rEFIt_UEFI/libeg/XTheme.h index 614c325e5..f5a99bfb9 100644 --- a/rEFIt_UEFI/libeg/XTheme.h +++ b/rEFIt_UEFI/libeg/XTheme.h @@ -105,6 +105,7 @@ public: //fill the theme const XImage& GetIcon(const XString& Name); //get by name const XImage& GetIcon(const char* Name); + const XImage& GetIcon(const CHAR16* Name); const XImage& GetIcon(INTN Id); //get by id void AddIcon(Icon& NewIcon); //return EFI_STATUS? diff --git a/rEFIt_UEFI/libeg/libeg.h b/rEFIt_UEFI/libeg/libeg.h index 42b380686..ed03a3e61 100755 --- a/rEFIt_UEFI/libeg/libeg.h +++ b/rEFIt_UEFI/libeg/libeg.h @@ -38,7 +38,7 @@ #define __LIBEG_LIBEG_H__ #ifndef USE_XTHEME -#define USE_XTHEME 0 +#define USE_XTHEME 1 #endif #ifdef __cplusplus diff --git a/rEFIt_UEFI/refit/main.cpp b/rEFIt_UEFI/refit/main.cpp index d80a907aa..ff93a824d 100644 --- a/rEFIt_UEFI/refit/main.cpp +++ b/rEFIt_UEFI/refit/main.cpp @@ -1004,9 +1004,6 @@ static VOID StartLoader(IN LOADER_ENTRY *Entry) static VOID StartLegacy(IN LEGACY_ENTRY *Entry) { EFI_STATUS Status = EFI_UNSUPPORTED; - EG_IMAGE *BootLogoImage; -// UINTN ErrorInStep = 0; -// EFI_DEVICE_PATH *DiscoveredPathList[MAX_DISCOVERED_PATHS]; // Unload EmuVariable before booting legacy. // This is not needed in most cases, but it seems to interfere with legacy OS @@ -1032,7 +1029,7 @@ static VOID StartLegacy(IN LEGACY_ENTRY *Entry) BootLogoX.Draw((UGAWidth - BootLogoX.GetWidth()) >> 1, (UGAHeight - BootLogoX.GetHeight()) >> 1); #else - BootLogoImage = LoadOSIcon(Entry->Volume->LegacyOS->IconName, L"legacy", 128, TRUE, TRUE); + EG_IMAGE *BootLogoImage = LoadOSIcon(Entry->Volume->LegacyOS->IconName, L"legacy", 128, TRUE, TRUE); if (BootLogoImage != NULL) { BltImageAlpha(BootLogoImage, (UGAWidth - BootLogoImage->Width) >> 1, diff --git a/rEFIt_UEFI/refit/menu.cpp b/rEFIt_UEFI/refit/menu.cpp index ea81e1188..9555d42a2 100644 --- a/rEFIt_UEFI/refit/menu.cpp +++ b/rEFIt_UEFI/refit/menu.cpp @@ -3795,14 +3795,14 @@ VOID REFIT_MENU_SCREEN::GraphicsMenuStyle(IN UINTN Function, IN CONST CHAR16 *Pa //clovy//PlaceCentre1 = (TextHeight - (INTN)(Buttons[2]->Height * GlobalConfig.Scale)) / 2; //clovy//PlaceCentre = (PlaceCentre>0)?PlaceCentre:0; //clovy//PlaceCentre1 = (TextHeight - (INTN)(Buttons[0]->Height * GlobalConfig.Scale)) / 2; - PlaceCentre = (INTN)((TextHeight - (INTN)(Buttons[2]->Height)) * ThemeX.Scale / 2); - PlaceCentre1 = (INTN)((TextHeight - (INTN)(Buttons[0]->Height)) * ThemeX.Scale / 2); + PlaceCentre = (INTN)((TextHeight - (INTN)(ThemeX.Buttons[2].GetHeight())) * ThemeX.Scale / 2); + PlaceCentre1 = (INTN)((TextHeight - (INTN)(ThemeX.Buttons[0].GetHeight())) * ThemeX.Scale / 2); // clovy if (ThemeX.TypeSVG) ctrlX = EntriesPosX; else ctrlX = EntriesPosX + (INTN)(TEXT_XMARGIN * ThemeX.Scale); - ctrlTextX = ctrlX + Buttons[0]->Width + (INTN)(TEXT_XMARGIN * ThemeX.Scale / 2); + ctrlTextX = ctrlX + ThemeX.Buttons[0].GetWidth() + (INTN)(TEXT_XMARGIN * ThemeX.Scale / 2); ctrlY = Entry->Place.YPos + PlaceCentre; if ( Entry->getREFIT_INPUT_DIALOG() ) {