Skip to content

Commit

Permalink
Make ThemeX a pointer.
Browse files Browse the repository at this point in the history
  • Loading branch information
jief committed Nov 6, 2023
1 parent 88a2a69 commit 45795cc
Show file tree
Hide file tree
Showing 24 changed files with 566 additions and 357 deletions.
176 changes: 158 additions & 18 deletions Xcode/CloverX64/CloverX64.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1120"
LastUpgradeVersion = "1410"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1410"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9AC77EC324176BF2005CDD5C"
BuildableName = "libCloverX64.a"
BlueprintName = "CloverX64"
ReferencedContainer = "container:CloverX64.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9AC77EC324176BF2005CDD5C"
BuildableName = "libCloverX64.a"
BlueprintName = "CloverX64"
ReferencedContainer = "container:CloverX64.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
12 changes: 6 additions & 6 deletions rEFIt_UEFI/Platform/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,19 +411,19 @@ void afterGetUserSettings(SETTINGS_DATA& settingsData)

for ( size_t idx = 0 ; idx < settingsData.GUI.CustomLegacySettings.size() ; ++idx ) {
const CUSTOM_LEGACY_ENTRY_SETTINGS& CustomLegacySettings = settingsData.GUI.CustomLegacySettings[idx];
CUSTOM_LEGACY_ENTRY* entry = new CUSTOM_LEGACY_ENTRY(CustomLegacySettings, ThemeX.getThemeDir());
CUSTOM_LEGACY_ENTRY* entry = new CUSTOM_LEGACY_ENTRY(CustomLegacySettings, ThemeX->getThemeDir());
GlobalConfig.CustomLegacyEntries.AddReference(entry, true);
}

for ( size_t idx = 0 ; idx < settingsData.GUI.CustomToolSettings.size() ; ++idx ) {
const CUSTOM_TOOL_ENTRY_SETTINGS& CustomToolSettings = settingsData.GUI.CustomToolSettings[idx];
CUSTOM_TOOL_ENTRY* entry = new CUSTOM_TOOL_ENTRY(CustomToolSettings, ThemeX.getThemeDir());
CUSTOM_TOOL_ENTRY* entry = new CUSTOM_TOOL_ENTRY(CustomToolSettings, ThemeX->getThemeDir());
GlobalConfig.CustomToolsEntries.AddReference(entry, true);
}

if ( settingsData.GUI.Theme.notEmpty() )
{
ThemeX.Theme.takeValueFrom(settingsData.GUI.Theme);
ThemeX->Theme.takeValueFrom(settingsData.GUI.Theme);
DBG("Default theme: %ls\n", settingsData.GUI.Theme.wc_str());

OldChosenTheme = 0xFFFF; //default for embedded
Expand All @@ -442,12 +442,12 @@ void afterGetUserSettings(SETTINGS_DATA& settingsData)
INT32 NowHour = Now.Hour + settingsData.GUI.Timezone;
if (NowHour < 0 ) NowHour += 24;
if (NowHour >= 24 ) NowHour -= 24;
ThemeX.Daylight = (NowHour > 8) && (NowHour < 20);
ThemeX->Daylight = (NowHour > 8) && (NowHour < 20);
} else {
ThemeX.Daylight = true;
ThemeX->Daylight = true;
}

ThemeX.DarkEmbedded = settingsData.GUI.getDarkEmbedded(ThemeX.Daylight);
ThemeX->DarkEmbedded = settingsData.GUI.getDarkEmbedded(ThemeX->Daylight);

if ( settingsData.GUI.languageCode == english ) {
GlobalConfig.Codepage = 0xC0;
Expand Down
2 changes: 1 addition & 1 deletion rEFIt_UEFI/entry_scan/bootscreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ EFI_STATUS InitBootScreen(IN LOADER_ENTRY *Entry)
case CUSTOM_BOOT_THEME:
// TODO: Custom boot theme
DBG("Custom boot is using theme logo\n");
ThemeX.ClearScreen();
ThemeX->ClearScreen();
return EFI_SUCCESS;

case CUSTOM_BOOT_USER:
Expand Down
4 changes: 2 additions & 2 deletions rEFIt_UEFI/entry_scan/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ const XIcon& ScanVolumeDefaultIcon(REFIT_VOLUME *Volume, IN UINT8 OSType, const
break;
}
// DBG("asked IconNum = %llu Volume->DiskKind=%d OSType=%d\n", IconNum, Volume->DiskKind, OSType);
IconX = &ThemeX.GetIcon(IconNum); //asked IconNum = BUILTIN_ICON_VOL_INTERNAL_HFS, got day icon
IconX = &ThemeX->GetIcon(IconNum); //asked IconNum = BUILTIN_ICON_VOL_INTERNAL_HFS, got day icon
if (IconX->Image.isEmpty()) {
DBG("asked Icon %s not found, took internal\n", IconsNames[IconNum]);
IconX = &ThemeX.GetIcon(BUILTIN_ICON_VOL_INTERNAL); //including embedded which is really present
IconX = &ThemeX->GetIcon(BUILTIN_ICON_VOL_INTERNAL); //including embedded which is really present
}

return *IconX;
Expand Down
18 changes: 9 additions & 9 deletions rEFIt_UEFI/entry_scan/legacy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ DBG(" Volume->LegacyOS->Name=%ls\n", Volume->LegacyOS->Name.wc_str());
if ( FullTitle.notEmpty() ) {
Entry->Title = FullTitle;
} else {
if (ThemeX.BootCampStyle) {
if (ThemeX->BootCampStyle) {
Entry->Title = LTitle;
} else {
Entry->Title.SWPrintf("Boot %ls from %ls", LoaderTitle.wc_str(), VolDesc.wc_str());
Expand All @@ -128,9 +128,9 @@ DBG(" Volume->LegacyOS->Name=%ls\n", Volume->LegacyOS->Name.wc_str());
if ( Image && !Image->isEmpty() ) {
Entry->Image = *Image;
} else {
Entry->Image = ThemeX.LoadOSIcon(Volume->LegacyOS->IconName);
Entry->Image = ThemeX->LoadOSIcon(Volume->LegacyOS->IconName);
if (Entry->Image.Image.isEmpty()) {
Entry->Image = ThemeX.GetIcon("os_win"_XS8); //we have no legacy.png
Entry->Image = ThemeX->GetIcon("os_win"_XS8); //we have no legacy.png
}
}

Expand All @@ -144,11 +144,11 @@ DBG(" Volume->LegacyOS->Name=%ls\n", Volume->LegacyOS->Name.wc_str());
Entry->AtClick = ActionSelect;
Entry->AtDoubleClick = ActionEnter;
Entry->AtRightClick = ActionDetails;
if (ThemeX.HideBadges & HDBADGES_SHOW) {
if (ThemeX.HideBadges & HDBADGES_SWAP) { //will be scaled later
Entry->BadgeImage.Image = XImage(Entry->DriveImage.Image, 0); //ThemeX.BadgeScale/16.f); //0 accepted
if (ThemeX->HideBadges & HDBADGES_SHOW) {
if (ThemeX->HideBadges & HDBADGES_SWAP) { //will be scaled later
Entry->BadgeImage.Image = XImage(Entry->DriveImage.Image, 0); //ThemeX->BadgeScale/16.f); //0 accepted
} else {
Entry->BadgeImage.Image = XImage(Entry->Image.Image, 0); //ThemeX.BadgeScale/16.f);
Entry->BadgeImage.Image = XImage(Entry->Image.Image, 0); //ThemeX->BadgeScale/16.f);
}
}
Entry->Volume = Volume;
Expand Down Expand Up @@ -374,13 +374,13 @@ void AddCustomLegacy(void)
// Change to custom image if needed
MainIcon = Custom.Image;
if (MainIcon.Image.isEmpty()) {
MainIcon.Image.LoadXImage(&ThemeX.getThemeDir(), Custom.settings.ImagePath);
MainIcon.Image.LoadXImage(&ThemeX->getThemeDir(), Custom.settings.ImagePath);
}

// Change to custom drive image if needed
DriveIcon = Custom.DriveImage;
if (DriveIcon.Image.isEmpty()) {
DriveIcon.Image.LoadXImage(&ThemeX.getThemeDir(), Custom.settings.DriveImagePath);
DriveIcon.Image.LoadXImage(&ThemeX->getThemeDir(), Custom.settings.DriveImagePath);
}
// Create a legacy entry for this volume
DBG("\n");
Expand Down
26 changes: 13 additions & 13 deletions rEFIt_UEFI/entry_scan/loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1133,7 +1133,7 @@ if ( Entry->APFSTargetUUID.Data1 == 0x99999999 ) {
}
}

XBool BootCampStyle = ThemeX.BootCampStyle;
XBool BootCampStyle = ThemeX->BootCampStyle;

if ( Entry->Title.isEmpty() && Entry->DisplayedVolName.isEmpty() ) {
XStringW BasenameXW = XStringW(Basename(Volume->DevicePathString.wc_str()));
Expand Down Expand Up @@ -1186,7 +1186,7 @@ if ( Entry->APFSTargetUUID.Data1 == 0x99999999 ) {
} else if (Image) {
Entry->Image = *Image; //copy image from temporary storage
} else {
Entry->Image = ThemeX.LoadOSIcon(OSIconName);
Entry->Image = ThemeX->LoadOSIcon(OSIconName);
}
// DBG("Load DriveImage\n");
// Load DriveImage
Expand All @@ -1196,9 +1196,9 @@ if ( Entry->APFSTargetUUID.Data1 == 0x99999999 ) {
} else {
Entry->DriveImage = ScanVolumeDefaultIcon(Volume, Entry->LoaderType, Volume->DevicePath);
}
// DBG("HideBadges=%llu Volume=%ls ", ThemeX.HideBadges, Volume->VolName);
if (ThemeX.HideBadges & HDBADGES_SHOW) {
if (ThemeX.HideBadges & HDBADGES_SWAP) {
// DBG("HideBadges=%llu Volume=%ls ", ThemeX->HideBadges, Volume->VolName);
if (ThemeX->HideBadges & HDBADGES_SHOW) {
if (ThemeX->HideBadges & HDBADGES_SWAP) {
Entry->BadgeImage.Image = XImage(Entry->DriveImage.Image, 0);
DBG("%sShow badge as Drive.\n", indent);
} else {
Expand Down Expand Up @@ -1485,10 +1485,10 @@ STATIC void LinuxScan(REFIT_VOLUME *Volume, UINT8 KernelScan, UINT8 Type, XStrin
LoaderTitle.upperAscii();
LoaderTitle += OSName.subString(1, OSName.length()) + L" Linux"_XSW;
// Very few linux icons exist in IconNames, but these few may be preloaded, so check that first
XIcon ImageX = ThemeX.GetIcon(L"os_"_XSW + OSName); //will the image be destroyed or rewritten by next image after the cycle end?
XIcon ImageX = ThemeX->GetIcon(L"os_"_XSW + OSName); //will the image be destroyed or rewritten by next image after the cycle end?
if (ImageX.isEmpty()) {
// no preloaded icon, try to load from dir
ImageX.LoadXImage(&ThemeX.getThemeDir(), L"os_"_XSW + OSName);
ImageX.LoadXImage(&ThemeX->getThemeDir(), L"os_"_XSW + OSName);
}
if (CustomPath) {
*CustomPath = File;
Expand All @@ -1509,9 +1509,9 @@ STATIC void LinuxScan(REFIT_VOLUME *Volume, UINT8 KernelScan, UINT8 Type, XStrin
if (FileExists(Volume->RootDir, LinuxEntryData[Index].Path)) {
XStringW OSIconName = XStringW().takeValueFrom(LinuxEntryData[Index].Icon);
OSIconName = OSIconName.subString(0, OSIconName.indexOf(','));
XIcon ImageX = ThemeX.GetIcon(L"os_"_XSW + OSIconName);
XIcon ImageX = ThemeX->GetIcon(L"os_"_XSW + OSIconName);
if (ImageX.isEmpty()) {
ImageX.LoadXImage(&ThemeX.getThemeDir(), L"os_"_XSW + OSIconName);
ImageX.LoadXImage(&ThemeX->getThemeDir(), L"os_"_XSW + OSIconName);
}
if (CustomPath) {
*CustomPath = LinuxEntryData[Index].Path;
Expand Down Expand Up @@ -1930,7 +1930,7 @@ void ScanLoader(void)
if (aFound && (aFound == aIndex)) {
XIcon ImageX;
XStringW IconXSW = XStringW().takeValueFrom(AndroidEntryData[Index].Icon);
ImageX.LoadXImage(&ThemeX.getThemeDir(), (L"os_"_XSW + IconXSW.subString(0, IconXSW.indexOf(','))).wc_str());
ImageX.LoadXImage(&ThemeX->getThemeDir(), (L"os_"_XSW + IconXSW.subString(0, IconXSW.indexOf(','))).wc_str());
AddLoaderEntry(AndroidEntryData[Index].Path, NullXString8Array, L""_XSW, XStringW().takeValueFrom(AndroidEntryData[Index].Title), Volume,
(ImageX.isEmpty() ? NULL : &ImageX), OSTYPE_LIN, OSFLAG_NODEFAULTARGS);
}
Expand Down Expand Up @@ -2475,9 +2475,9 @@ STATIC void AddCustomEntry(IN UINTN CustomIndex,

// Change to custom image if needed
if (Image.isEmpty() && Custom.settings.dgetImagePath().notEmpty()) {
Image.LoadXImage(&ThemeX.getThemeDir(), Custom.settings.dgetImagePath());
Image.LoadXImage(&ThemeX->getThemeDir(), Custom.settings.dgetImagePath());
if (Image.isEmpty()) {
Image.LoadXImage(&ThemeX.getThemeDir(), L"os_"_XSW + Custom.settings.dgetImagePath());
Image.LoadXImage(&ThemeX->getThemeDir(), L"os_"_XSW + Custom.settings.dgetImagePath());
if (Image.isEmpty()) {
Image.LoadXImage(&self.getCloverDir(), Custom.settings.dgetImagePath());
if (Image.isEmpty()) {
Expand All @@ -2492,7 +2492,7 @@ STATIC void AddCustomEntry(IN UINTN CustomIndex,

// Change to custom drive image if needed
if (DriveImage.isEmpty() && Custom.settings.dgetDriveImagePath().notEmpty()) {
DriveImage.LoadXImage(&ThemeX.getThemeDir(), Custom.settings.dgetDriveImagePath());
DriveImage.LoadXImage(&ThemeX->getThemeDir(), Custom.settings.dgetDriveImagePath());
if (DriveImage.isEmpty()) {
DriveImage.LoadXImage(&self.getCloverDir(), Custom.settings.dgetImagePath());
if (DriveImage.isEmpty()) {
Expand Down
6 changes: 3 additions & 3 deletions rEFIt_UEFI/entry_scan/securemenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ void AddSecureBootTool(void)
// Entry = new REFIT_MENU_ENTRY_SECURE_BOOT;
// Entry->Title.SWPrintf("Clover Secure Boot Configuration");
//// Entry->Tag = TAG_SECURE_BOOT_CONFIG;
// Entry->Image = ThemeX.GetIcon(BUILTIN_ICON_FUNC_SECURE_BOOT_CONFIG);
// Entry->Image = ThemeX->GetIcon(BUILTIN_ICON_FUNC_SECURE_BOOT_CONFIG);
//
// } else {
// Entry = new REFIT_MENU_ENTRY_SECURE_BOOT_CONFIG;
// Entry->Title.SWPrintf("Enable Clover Secure Boot");
//// Entry->Tag = TAG_SECURE_BOOT;
// Entry->Image = ThemeX.GetIcon(BUILTIN_ICON_FUNC_SECURE_BOOT);
// Entry->Image = ThemeX->GetIcon(BUILTIN_ICON_FUNC_SECURE_BOOT);
// }

//----- not done yet ----------
Expand Down Expand Up @@ -137,7 +137,7 @@ UINTN QuerySecureBootUser(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath)
if (gThemeNeedInit) {
UINTN Size = 0;
InitTheme((CHAR8*)GetNvramVariable(L"Clover.Theme", gEfiAppleBootGuid, NULL, &Size));
ThemeX.ClearScreen();
ThemeX->ClearScreen();
gThemeNeedInit = false;
}
gGuiIsReady = true;
Expand Down
14 changes: 7 additions & 7 deletions rEFIt_UEFI/entry_scan/tool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ STATIC void AddCloverEntry(IN CONST XStringW& LoaderPath, IN CONST CHAR16 *Loade
// Entry->Tag = TAG_CLOVER;
Entry->Row = 1;
Entry->ShortcutLetter = 'C';
Entry->Image = ThemeX.GetIcon(BUILTIN_ICON_FUNC_CLOVER);
Entry->Image = ThemeX->GetIcon(BUILTIN_ICON_FUNC_CLOVER);
Entry->Volume = Volume;
Entry->LoaderPath = LoaderPath;
Entry->VolName = Volume->VolName;
Expand Down Expand Up @@ -195,13 +195,13 @@ void ScanTool(void)
UINTN VolumeIndex;
REFIT_VOLUME *Volume;
void *Interface;
if (ThemeX.HideUIFlags & HIDEUI_FLAG_TOOLS)
if (ThemeX->HideUIFlags & HIDEUI_FLAG_TOOLS)
return;

// DBG("Scanning for tools...\n");
if (!(ThemeX.HideUIFlags & HIDEUI_FLAG_SHELL)) {
if (!AddToolEntry(SWPrintf("%ls\\tools\\Shell64U.efi", self.getCloverDirFullPath().wc_str()), NULL, L"UEFI Shell 64", SelfVolume, ThemeX.GetIcon(BUILTIN_ICON_TOOL_SHELL), 'S', NullXString8Array)) {
AddToolEntry(SWPrintf("%ls\\tools\\Shell64.efi", self.getCloverDirFullPath().wc_str()), NULL, L"EFI Shell 64", SelfVolume, ThemeX.GetIcon(BUILTIN_ICON_TOOL_SHELL), 'S', NullXString8Array);
if (!(ThemeX->HideUIFlags & HIDEUI_FLAG_SHELL)) {
if (!AddToolEntry(SWPrintf("%ls\\tools\\Shell64U.efi", self.getCloverDirFullPath().wc_str()), NULL, L"UEFI Shell 64", SelfVolume, ThemeX->GetIcon(BUILTIN_ICON_TOOL_SHELL), 'S', NullXString8Array)) {
AddToolEntry(SWPrintf("%ls\\tools\\Shell64.efi", self.getCloverDirFullPath().wc_str()), NULL, L"EFI Shell 64", SelfVolume, ThemeX->GetIcon(BUILTIN_ICON_TOOL_SHELL), 'S', NullXString8Array);
}
}

Expand Down Expand Up @@ -304,11 +304,11 @@ void AddCustomTool(void)
// Change to custom image if needed
Image = Custom.Image;
if (Image.isEmpty() && Custom.settings.ImagePath.notEmpty()) {
Image.LoadXImage(&ThemeX.getThemeDir(), Custom.settings.ImagePath);
Image.LoadXImage(&ThemeX->getThemeDir(), Custom.settings.ImagePath);
}
DBG("match!\n");
if (Image.isEmpty()) {
AddToolEntry(Custom.settings.Path, Custom.settings.FullTitle.wc_str(), Custom.settings.Title.wc_str(), Volume, ThemeX.GetIcon(BUILTIN_ICON_TOOL_SHELL), Custom.settings.Hotkey, Custom.getLoadOptions());
AddToolEntry(Custom.settings.Path, Custom.settings.FullTitle.wc_str(), Custom.settings.Title.wc_str(), Volume, ThemeX->GetIcon(BUILTIN_ICON_TOOL_SHELL), Custom.settings.Hotkey, Custom.getLoadOptions());
} else {
// Create a legacy entry for this volume
AddToolEntry(Custom.settings.Path, Custom.settings.FullTitle.wc_str(), Custom.settings.Title.wc_str(), Volume, Image, Custom.settings.Hotkey, Custom.getLoadOptions());
Expand Down
Loading

0 comments on commit 45795cc

Please sign in to comment.