SETTINGS_DATA refactoring.

This commit is contained in:
jief666 2021-03-19 23:32:42 +03:00
parent 0098f0b1ee
commit 2a029bd298
17 changed files with 396 additions and 454 deletions

View File

@ -533,6 +533,8 @@
<string>arg2</string>
<key>FullTitle</key>
<string>title1</string>
<key>Settings</key>
<string>settingsSub</string>
<key>SubEntries</key>
<array>
<dict>

View File

@ -286,7 +286,7 @@ SetVariablesForOSX(LOADER_ENTRY *Entry)
// note: some gEfiAppleBootGuid vars present in nvram.plist are already set by PutNvramPlistToRtVars()
// we should think how to handle those vars from nvram.plist and ones set here from gSettings
if ((gFirmwareClover && gDriversFlags.EmuVariableLoaded) || gSettings.KbdPrevLang) {
if ((gFirmwareClover && gDriversFlags.EmuVariableLoaded) || gSettings.GUI.KbdPrevLang) {
// using AddNvramVariable content instead of calling the function to do LangLen calculation only when necessary
// Do not mess with prev-lang:kbd on UEFI systems without NVRAM emulation; it's OS X's business
KbdPrevLang = L"prev-lang:kbd";

View File

@ -74,7 +74,6 @@ CHAR16 *IconFormat = NULL;
TagDict* gConfigDict[NUM_OF_CONFIGS] = {NULL, NULL, NULL};
SETTINGS_DATA gSettings;
LANGUAGES gLanguage;
GFX_PROPERTIES gGraphics[4]; //no more then 4 graphics cards
HDA_PROPERTIES gAudios[4]; //no more then 4 Audio Controllers
//SLOT_DEVICE Arpt;
@ -562,41 +561,15 @@ LoadUserSettings (
STATIC BOOLEAN AddCustomLoaderEntry(IN CUSTOM_LOADER_ENTRY *Entry)
{
if (Entry == NULL) {
return FALSE;
}
if (gSettings.CustomEntries) {
CUSTOM_LOADER_ENTRY *Entries = gSettings.CustomEntries;
while (Entries->Next != NULL) {
Entries = Entries->Next;
}
Entries->Next = Entry;
} else {
gSettings.CustomEntries = Entry;
}
if (Entry == NULL) return FALSE;
gSettings.GUI.CustomEntries.AddReference(Entry, true);
return TRUE;
}
STATIC BOOLEAN AddCustomLegacyEntry (IN CUSTOM_LEGACY_ENTRY *Entry)
{
if (Entry == NULL) {
return FALSE;
}
if (gSettings.CustomLegacy != NULL) {
CUSTOM_LEGACY_ENTRY *Entries = gSettings.CustomLegacy;
while (Entries->Next != NULL) {
Entries = Entries->Next;
}
Entries->Next = Entry;
} else {
gSettings.CustomLegacy = Entry;
}
if (Entry == NULL) return FALSE;
gSettings.GUI.CustomLegacy.AddReference(Entry, true);
return TRUE;
}
STATIC
@ -605,21 +578,8 @@ AddCustomToolEntry (
IN CUSTOM_TOOL_ENTRY *Entry
)
{
if (Entry == NULL) {
return FALSE;
}
if (gSettings.CustomTool) {
CUSTOM_TOOL_ENTRY *Entries = gSettings.CustomTool;
while (Entries->Next != NULL) {
Entries = Entries->Next;
}
Entries->Next = Entry;
} else {
gSettings.CustomTool = Entry;
}
if (Entry == NULL) return FALSE;
gSettings.GUI.CustomTool.AddReference(Entry, true);
return TRUE;
}
@ -629,22 +589,8 @@ AddCustomSubEntry (
IN OUT CUSTOM_LOADER_ENTRY *Entry,
IN CUSTOM_LOADER_ENTRY *SubEntry)
{
if ((Entry == NULL) || (SubEntry == NULL)) {
return FALSE;
}
if (Entry->SubEntries != NULL) {
CUSTOM_LOADER_ENTRY *Entries = Entry->SubEntries;
while (Entries->Next != NULL) {
Entries = Entries->Next;
}
Entries->Next = SubEntry;
} else {
Entry->SubEntries = SubEntry;
}
if ((Entry == NULL) || (SubEntry == NULL)) return FALSE;
Entry->SubEntries.AddReference(Entry, true);
return TRUE;
}
@ -2421,18 +2367,18 @@ EFI_STATUS GetEarlyUserSettings (
Prop = GUIDict->propertyForKey("EmbeddedThemeType");
if (Prop && (Prop->isString()) && Prop->getString()->stringValue().notEmpty()) {
if (Prop->getString()->stringValue().equalIC("Dark")) {
ThemeX.DarkEmbedded = TRUE;
gSettings.GUI.DarkEmbedded = TRUE;
//ThemeX.Font = FONT_GRAY;
} else if (Prop->getString()->stringValue().equalIC("Light")) {
ThemeX.DarkEmbedded = FALSE;
gSettings.GUI.DarkEmbedded = FALSE;
//ThemeX.Font = FONT_ALFA;
} else if (Prop->getString()->stringValue().equalIC("Daytime")) {
ThemeX.DarkEmbedded = !ThemeX.Daylight;
gSettings.GUI.DarkEmbedded = !ThemeX.Daylight;
//ThemeX.Font = ThemeX.Daylight?FONT_ALFA:FONT_GRAY;
}
}
Prop = GUIDict->propertyForKey("PlayAsync"); //PlayAsync
gSettings.PlayAsync = IsPropertyNotNullAndTrue(Prop);
gSettings.GUI.PlayAsync = IsPropertyNotNullAndTrue(Prop);
// CustomIcons
Prop = GUIDict->propertyForKey("CustomIcons");
@ -2450,7 +2396,7 @@ EFI_STATUS GetEarlyUserSettings (
}
Prop = GUIDict->propertyForKey("ProvideConsoleGop");
gSettings.ProvideConsoleGop = !IsPropertyNotNullAndFalse(Prop); //default is true
gSettings.GUI.ProvideConsoleGop = !IsPropertyNotNullAndFalse(Prop); //default is true
Prop = GUIDict->propertyForKey("ConsoleMode");
if (Prop != NULL) {
@ -2476,47 +2422,47 @@ EFI_STATUS GetEarlyUserSettings (
if (Prop != NULL) {
gSettings.Language = Prop->getString()->stringValue();
if ( Prop->getString()->stringValue().contains("en") ) {
gLanguage = english;
gSettings.GUI.gLanguage = english;
gSettings.GUI.Codepage = 0xC0;
gSettings.GUI.CodepageSize = 0;
} else if ( Prop->getString()->stringValue().contains("ru")) {
gLanguage = russian;
gSettings.GUI.gLanguage = russian;
gSettings.GUI.Codepage = 0x410;
gSettings.GUI.CodepageSize = 0x40;
} else if ( Prop->getString()->stringValue().contains("ua")) {
gLanguage = ukrainian;
gSettings.GUI.gLanguage = ukrainian;
gSettings.GUI.Codepage = 0x400;
gSettings.GUI.CodepageSize = 0x60;
} else if ( Prop->getString()->stringValue().contains("fr")) {
gLanguage = french; //default is extended latin
gSettings.GUI.gLanguage = french; //default is extended latin
} else if ( Prop->getString()->stringValue().contains("it")) {
gLanguage = italian;
gSettings.GUI.gLanguage = italian;
} else if ( Prop->getString()->stringValue().contains("es")) {
gLanguage = spanish;
gSettings.GUI.gLanguage = spanish;
} else if ( Prop->getString()->stringValue().contains("pt")) {
gLanguage = portuguese;
gSettings.GUI.gLanguage = portuguese;
} else if ( Prop->getString()->stringValue().contains("br")) {
gLanguage = brasil;
gSettings.GUI.gLanguage = brasil;
} else if ( Prop->getString()->stringValue().contains("de")) {
gLanguage = german;
gSettings.GUI.gLanguage = german;
} else if ( Prop->getString()->stringValue().contains("nl")) {
gLanguage = dutch;
gSettings.GUI.gLanguage = dutch;
} else if ( Prop->getString()->stringValue().contains("pl")) {
gLanguage = polish;
gSettings.GUI.gLanguage = polish;
} else if ( Prop->getString()->stringValue().contains("cz")) {
gLanguage = czech;
gSettings.GUI.gLanguage = czech;
} else if ( Prop->getString()->stringValue().contains("hr")) {
gLanguage = croatian;
gSettings.GUI.gLanguage = croatian;
} else if ( Prop->getString()->stringValue().contains("id")) {
gLanguage = indonesian;
gSettings.GUI.gLanguage = indonesian;
} else if ( Prop->getString()->stringValue().contains("zh_CN")) {
gLanguage = chinese;
gSettings.GUI.gLanguage = chinese;
gSettings.GUI.Codepage = 0x3400;
gSettings.GUI.CodepageSize = 0x19C0;
} else if ( Prop->getString()->stringValue().contains("ro")) {
gLanguage = romanian;
gSettings.GUI.gLanguage = romanian;
} else if ( Prop->getString()->stringValue().contains("ko")) {
gLanguage = korean;
gSettings.GUI.gLanguage = korean;
gSettings.GUI.Codepage = 0x1100;
gSettings.GUI.CodepageSize = 0x100;
}
@ -2525,7 +2471,7 @@ EFI_STATUS GetEarlyUserSettings (
// if (settingsData.Language != NULL) { // settingsData.Language != NULL cannot be false because settingsData.Language is dclared as CHAR8 Language[16]; Must we replace by settingsData.Language[0] != NULL
Prop = GUIDict->propertyForKey("KbdPrevLang");
if (Prop != NULL) {
gSettings.KbdPrevLang = IsPropertyNotNullAndTrue(Prop);
gSettings.GUI.KbdPrevLang = IsPropertyNotNullAndTrue(Prop);
}
// }
@ -2533,23 +2479,23 @@ EFI_STATUS GetEarlyUserSettings (
if (MouseDict != NULL) {
const TagStruct* prop = MouseDict->propertyForKey("Speed");
if (prop != NULL) {
gSettings.PointerSpeed = (INT32)GetPropertyAsInteger(prop, 0);
gSettings.PointerEnabled = (gSettings.PointerSpeed != 0);
gSettings.GUI.Mouse.PointerSpeed = (INT32)GetPropertyAsInteger(prop, 0);
gSettings.GUI.Mouse.PointerEnabled = (gSettings.GUI.Mouse.PointerSpeed != 0);
}
//but we can disable mouse even if there was positive speed
prop = MouseDict->propertyForKey("Enabled");
if (IsPropertyNotNullAndFalse(prop)) {
gSettings.PointerEnabled = FALSE;
gSettings.GUI.Mouse.PointerEnabled = FALSE;
}
prop = MouseDict->propertyForKey("Mirror");
if (IsPropertyNotNullAndTrue(prop)) {
gSettings.PointerMirror = TRUE;
gSettings.GUI.Mouse.PointerMirror = TRUE;
}
prop = MouseDict->propertyForKey("DoubleClickTime");
if (prop != NULL) {
gSettings.DoubleClickTime = (UINT64)GetPropertyAsInteger(prop, 500);
gSettings.GUI.Mouse.DoubleClickTime = (UINT64)GetPropertyAsInteger(prop, 500);
}
}
// hide by name/uuid. Array of string
@ -2558,7 +2504,7 @@ EFI_STATUS GetEarlyUserSettings (
INTN i;
INTN Count = HideArray->arrayContent().size();
if (Count > 0) {
gSettings.HVHideStrings.setEmpty();
gSettings.GUI.HVHideStrings.setEmpty();
for (i = 0; i < Count; i++) {
const TagStruct* prop2 = &HideArray->arrayContent()[i];
if ( !prop2->isString()) {
@ -2566,60 +2512,60 @@ EFI_STATUS GetEarlyUserSettings (
continue;
}
if ( prop2->getString()->stringValue().notEmpty() ) {
gSettings.HVHideStrings.Add(prop2->getString()->stringValue());
gSettings.GUI.HVHideStrings.Add(prop2->getString()->stringValue());
DBG("Hiding entries with string %s\n", prop2->getString()->stringValue().c_str());
}
}
}
}
gSettings.LinuxScan = TRUE;
gSettings.GUI.Scan.LinuxScan = TRUE;
// Disable loader scan
Prop = GUIDict->propertyForKey("Scan");
if (Prop != NULL) {
if (IsPropertyNotNullAndFalse(Prop)) {
gSettings.DisableEntryScan = TRUE;
gSettings.DisableToolScan = TRUE;
gSettings.GUI.NoLegacy = TRUE;
gSettings.GUI.Scan.DisableEntryScan = TRUE;
gSettings.GUI.Scan.DisableToolScan = TRUE;
gSettings.GUI.Scan.NoLegacy = TRUE;
} else if (Prop->isDict()) {
const TagStruct* prop2 = Prop->getDict()->propertyForKey("Entries");
if (IsPropertyNotNullAndFalse(prop2)) {
gSettings.DisableEntryScan = TRUE;
gSettings.GUI.Scan.DisableEntryScan = TRUE;
}
prop2 = Prop->getDict()->propertyForKey("Tool");
if (IsPropertyNotNullAndFalse(prop2)) {
gSettings.DisableToolScan = TRUE;
gSettings.GUI.Scan.DisableToolScan = TRUE;
}
prop2 = Prop->getDict()->propertyForKey("Linux");
gSettings.LinuxScan = !IsPropertyNotNullAndFalse(prop2);
gSettings.GUI.Scan.LinuxScan = !IsPropertyNotNullAndFalse(prop2);
prop2 = Prop->getDict()->propertyForKey("Legacy");
if (prop2 != NULL) {
if (prop2->isFalse()) {
gSettings.GUI.NoLegacy = TRUE;
gSettings.GUI.Scan.NoLegacy = TRUE;
} else if ((prop2->isString()) && prop2->getString()->stringValue().notEmpty() ) {
if ((prop2->getString()->stringValue()[0] == 'N') || (prop2->getString()->stringValue()[0] == 'n')) {
gSettings.GUI.NoLegacy = TRUE;
gSettings.GUI.Scan.NoLegacy = TRUE;
} else if ((prop2->getString()->stringValue()[0] == 'F') || (prop2->getString()->stringValue()[0] == 'f')) {
gSettings.GUI.LegacyFirst = TRUE;
gSettings.GUI.Scan.LegacyFirst = TRUE;
}
}
}
prop2 = Prop->getDict()->propertyForKey("Kernel");
if (prop2 != NULL) {
if (prop2->isFalse()) {
gSettings.KernelScan = KERNEL_SCAN_NONE;
gSettings.GUI.Scan.KernelScan = KERNEL_SCAN_NONE;
} else if ((prop2->isString()) && prop2->getString()->stringValue().notEmpty() ) {
if ((prop2->getString()->stringValue()[0] == 'N') || (prop2->getString()->stringValue()[0] == 'n')) {
gSettings.KernelScan = ( prop2->getString()->stringValue().length() > 1 && (prop2->getString()->stringValue()[1] == 'E' || prop2->getString()->stringValue()[1] == 'e') ) ? KERNEL_SCAN_NEWEST : KERNEL_SCAN_NONE;
gSettings.GUI.Scan.KernelScan = ( prop2->getString()->stringValue().length() > 1 && (prop2->getString()->stringValue()[1] == 'E' || prop2->getString()->stringValue()[1] == 'e') ) ? KERNEL_SCAN_NEWEST : KERNEL_SCAN_NONE;
} else if ((prop2->getString()->stringValue()[0] == 'O') || (prop2->getString()->stringValue()[0] == 'o')) {
gSettings.KernelScan = KERNEL_SCAN_OLDEST;
gSettings.GUI.Scan.KernelScan = KERNEL_SCAN_OLDEST;
} else if ((prop2->getString()->stringValue()[0] == 'F') || (prop2->getString()->stringValue()[0] == 'f')) {
gSettings.KernelScan = KERNEL_SCAN_FIRST;
gSettings.GUI.Scan.KernelScan = KERNEL_SCAN_FIRST;
} else if ((prop2->getString()->stringValue()[0] == 'L') || (prop2->getString()->stringValue()[0] == 'l')) {
gSettings.KernelScan = KERNEL_SCAN_LAST;
gSettings.GUI.Scan.KernelScan = KERNEL_SCAN_LAST;
} else if ((prop2->getString()->stringValue()[0] == 'M') || (prop2->getString()->stringValue()[0] == 'm')) {
gSettings.KernelScan = KERNEL_SCAN_MOSTRECENT;
gSettings.GUI.Scan.KernelScan = KERNEL_SCAN_MOSTRECENT;
} else if ((prop2->getString()->stringValue()[0] == 'E') || (prop2->getString()->stringValue()[0] == 'e')) {
gSettings.KernelScan = KERNEL_SCAN_EARLIEST;
gSettings.GUI.Scan.KernelScan = KERNEL_SCAN_EARLIEST;
}
}
}

View File

@ -32,6 +32,28 @@
#define QUIRK_OS bit(14)
#define QUIRK_PERM bit(15)
typedef enum {
english = 0, //en
russian, //ru
french, //fr
german, //de
dutch, //nl
italian, //it
spanish, //es
portuguese, //pt
brasil, //br
polish, //pl
ukrainian, //ua
croatian, //hr
czech, //cs
indonesian, //id
korean, //ko
chinese, //cn
romanian //ro
//something else? add, please
} LANGUAGES;
//// SysVariables
//typedef struct SYSVARIABLES SYSVARIABLES;
//struct SYSVARIABLES
@ -131,87 +153,81 @@ public:
class CUSTOM_LOADER_ENTRY
{
public:
CUSTOM_LOADER_ENTRY *Next;
CUSTOM_LOADER_ENTRY *SubEntries;
XObjArray<CUSTOM_LOADER_ENTRY> SubEntries = XObjArray<CUSTOM_LOADER_ENTRY>();
XIcon Image = XIcon();
XIcon DriveImage = XIcon();
XStringW ImagePath;
XStringW DriveImagePath;
XStringW Volume;
XStringW Path;
XString8Array LoadOptions;
XStringW ImagePath = XStringW();
XStringW DriveImagePath = XStringW();
XStringW Volume = XStringW();
XStringW Path = XStringW();
XString8Array LoadOptions = XString8Array();
XStringW FullTitle;
XStringW Title;
XStringW Settings;
CHAR16 Hotkey;
BOOLEAN CommonSettings;
UINT8 Flags;
bool Hidden;
UINT8 Type;
UINT8 VolumeType;
UINT8 KernelScan;
UINT8 CustomBoot;
XStringW FullTitle = XStringW();
XStringW Title = XStringW();
XStringW Settings = XStringW();
CHAR16 Hotkey = 0;
BOOLEAN CommonSettings = 0;
UINT8 Flags = 0;
bool Hidden = 0;
UINT8 Type = 0;
UINT8 VolumeType = 0;
UINT8 KernelScan = 0;
UINT8 CustomBoot = 0;
XImage CustomLogo = XImage();
EFI_GRAPHICS_OUTPUT_BLT_PIXEL BootBgColor = EFI_GRAPHICS_OUTPUT_BLT_PIXEL({0,0,0,0});
KERNEL_AND_KEXT_PATCHES KernelAndKextPatches;
KERNEL_AND_KEXT_PATCHES KernelAndKextPatches = KERNEL_AND_KEXT_PATCHES();
CUSTOM_LOADER_ENTRY() : Next(0), SubEntries(0), ImagePath(), DriveImagePath(), Volume(), Path(), LoadOptions(),
FullTitle(), Title(), Settings(), Hotkey(0), CommonSettings(0), Flags(0), Hidden(0), Type(0), VolumeType(0),
KernelScan(0), CustomBoot(0), KernelAndKextPatches()
{ }
// Not sure if default are valid. Delete them. If needed, proper ones can be created
CUSTOM_LOADER_ENTRY(const CUSTOM_LOADER_ENTRY&) = delete;
CUSTOM_LOADER_ENTRY& operator=(const CUSTOM_LOADER_ENTRY&) = delete;
// CUSTOM_LOADER_ENTRY() {}
//
// // Not sure if default are valid. Delete them. If needed, proper ones can be created
// CUSTOM_LOADER_ENTRY(const CUSTOM_LOADER_ENTRY&) = delete;
// CUSTOM_LOADER_ENTRY& operator=(const CUSTOM_LOADER_ENTRY&) = delete;
};
class CUSTOM_LEGACY_ENTRY
{
public:
CUSTOM_LEGACY_ENTRY* Next;
XIcon Image = XIcon();
XIcon DriveImage = XIcon();
XStringW ImagePath;
XStringW DriveImagePath;
XStringW Volume;
XStringW FullTitle;
XStringW Title;
CHAR16 Hotkey;
UINT8 Flags;
bool Hidden;
UINT8 Type;
UINT8 VolumeType;
XStringW ImagePath = XStringW();
XStringW DriveImagePath = XStringW();
XStringW Volume = XStringW();
XStringW FullTitle = XStringW();
XStringW Title = XStringW();
CHAR16 Hotkey = 0;
UINT8 Flags = 0;
bool Hidden = 0;
UINT8 Type = 0;
UINT8 VolumeType = 0;
CUSTOM_LEGACY_ENTRY() : Next(0), ImagePath(), DriveImagePath(), Volume(), FullTitle(), Title(), Hotkey(0), Flags(0), Hidden(0), Type(0), VolumeType(0) { }
// Not sure if default are valid. Delete them. If needed, proper ones can be created
CUSTOM_LEGACY_ENTRY(const CUSTOM_LEGACY_ENTRY&) = delete;
CUSTOM_LEGACY_ENTRY& operator=(const CUSTOM_LEGACY_ENTRY&) = delete;
// CUSTOM_LEGACY_ENTRY() {}
//
// // Not sure if default are valid. Delete them. If needed, proper ones can be created
// CUSTOM_LEGACY_ENTRY(const CUSTOM_LEGACY_ENTRY&) = delete;
// CUSTOM_LEGACY_ENTRY& operator=(const CUSTOM_LEGACY_ENTRY&) = delete;
};
class CUSTOM_TOOL_ENTRY
{
public:
CUSTOM_TOOL_ENTRY *Next;
XIcon Image = XIcon();
XStringW ImagePath;
XStringW Volume;
XStringW Path;
XString8Array LoadOptions;
XStringW FullTitle;
XStringW Title;
CHAR16 Hotkey;
UINT8 Flags;
bool Hidden;
UINT8 VolumeType;
XStringW ImagePath = XStringW();
XStringW Volume = XStringW();
XStringW Path = XStringW();
XString8Array LoadOptions = XString8Array();
XStringW FullTitle = XStringW();
XStringW Title = XStringW();
CHAR16 Hotkey = 0;
UINT8 Flags = 0;
bool Hidden = 0;
UINT8 VolumeType = 0;
CUSTOM_TOOL_ENTRY() : Next(0), ImagePath(), Volume(), Path(), LoadOptions(), FullTitle(), Title(), Hotkey(0), Flags(0), Hidden(0), VolumeType(0) { }
// Not sure if default are valid. Delete them. If needed, proper ones can be created
CUSTOM_TOOL_ENTRY(const CUSTOM_TOOL_ENTRY&) = delete;
CUSTOM_TOOL_ENTRY& operator=(const CUSTOM_TOOL_ENTRY&) = delete;
// CUSTOM_TOOL_ENTRY() {}
//
// // Not sure if default are valid. Delete them. If needed, proper ones can be created
// CUSTOM_TOOL_ENTRY(const CUSTOM_TOOL_ENTRY&) = delete;
// CUSTOM_TOOL_ENTRY& operator=(const CUSTOM_TOOL_ENTRY&) = delete;
};
class DEV_PROPERTY
@ -376,15 +392,39 @@ public:
public:
INT32 Timezone = 0xFF;
XStringW Theme = XStringW();
bool DarkEmbedded = 0;
bool PlayAsync = 0;
bool CustomIcons = false;
bool TextOnly = false;
bool ShowOptimus = false;
XStringW ScreenResolution = XStringW();
bool ProvideConsoleGop = 0;
INTN ConsoleMode = 0;
LANGUAGES gLanguage = english;
INTN Codepage = 0xC0;
INTN CodepageSize = 0xC0;
bool LegacyFirst = false;
bool NoLegacy = false;
BOOLEAN KbdPrevLang = 0;
class MouseClass {
public:
INTN PointerSpeed = 0;
BOOLEAN PointerEnabled = 0;
UINT64 DoubleClickTime = 0;
BOOLEAN PointerMirror = 0;
} Mouse = MouseClass();
XString8Array HVHideStrings = XString8Array();
class ScanClass {
public:
BOOLEAN DisableEntryScan = 0;
BOOLEAN DisableToolScan = 0;
UINT8 KernelScan = 0;
BOOLEAN LinuxScan = 0;
bool LegacyFirst = false;
bool NoLegacy = false;
} Scan = ScanClass();
XObjArray<CUSTOM_LOADER_ENTRY> CustomEntries = XObjArray<CUSTOM_LOADER_ENTRY>();
XObjArray<CUSTOM_LEGACY_ENTRY> CustomLegacy = XObjArray<CUSTOM_LEGACY_ENTRY>();
XObjArray<CUSTOM_TOOL_ENTRY> CustomTool = XObjArray<CUSTOM_TOOL_ENTRY>();
} GUI = GUIClass();
class CPUClass {
@ -586,7 +626,6 @@ public:
//SkyLake
//Volumes hiding
XString8Array HVHideStrings;
// KernelAndKextPatches
KERNEL_AND_KEXT_PATCHES KernelAndKextPatches;
@ -596,14 +635,9 @@ public:
XString8 AirportBridgeDeviceName;
// Pre-language
BOOLEAN KbdPrevLang;
//Pointer
BOOLEAN PointerEnabled;
UINT8 pad28[7];
INTN PointerSpeed;
UINT64 DoubleClickTime;
BOOLEAN PointerMirror;
// UINT8 pad7[6];
UINT8 pad29[6];
@ -636,7 +670,6 @@ public:
//other devices
BOOLEAN ForceHPET;
BOOLEAN ResetHDA;
BOOLEAN PlayAsync;
UINT8 pad32[2];
UINT32 DisableFunctions;
@ -660,14 +693,7 @@ public:
UINT8 pad34[3];
// Custom entries
BOOLEAN DisableEntryScan;
BOOLEAN DisableToolScan;
UINT8 KernelScan;
BOOLEAN LinuxScan;
UINT8 pad35[3];
CUSTOM_LOADER_ENTRY *CustomEntries;
CUSTOM_LEGACY_ENTRY *CustomLegacy;
CUSTOM_TOOL_ENTRY *CustomTool;
//Add custom properties
UINTN NrAddProperties;
@ -707,7 +733,6 @@ public:
OC_BOOTER_QUIRKS ocBooterQuirks;
XObjArray<MMIOWhiteList> mmioWhiteListArray;
BOOLEAN ProvideConsoleGop;
SETTINGS_DATA() : VendorName(), RomVersion(), EfiVersion(), ReleaseDate(), ManufactureName(), ProductName(), VersionNr(), SerialNr(), SmUUID(),
@ -724,14 +749,13 @@ public:
NvidiaNoEFI(0), NvidiaSingle(0), VRAM(0), Dcfg{0}, NVCAP{0}, BootDisplay(0), NvidiaWeb(0), pad41{0}, DualLink(0),
IgPlatform(0), HDAInjection(0),
HDALayoutId(0), USBInjection(0), USBFixOwnership(0), InjectClockID(0), HighCurrent(0), NameEH00(0), NameXH00(0), LANInjection(0), HDMIInjection(0),
HVHideStrings(), KernelAndKextPatches(), KextPatchesAllowed(0),
KernelPatchesAllowed(0), AirportBridgeDeviceName(), KbdPrevLang(0), PointerEnabled(0), PointerSpeed(0), DoubleClickTime(0), PointerMirror(0),
KernelAndKextPatches(), KextPatchesAllowed(0),
KernelPatchesAllowed(0), AirportBridgeDeviceName(),
RefCLK(0), RtMLB(), RtROM(), CsrActiveConfig(0), BooterConfig(0), BooterCfgStr(),
ConfigName{0}, /*MainConfigName(0),*/ /*BlackListCount(0),*/ DisabledDriverArray(), RPlt{0}, RBr{0}, EPCI{0}, REV{0}, ForceHPET(0), ResetHDA(0), PlayAsync(0), DisableFunctions(0), SlpWak(0), UseIntelHDMI(0),
AFGLowPowerState(0), DisableEntryScan(0), DisableToolScan(0), KernelScan(0), LinuxScan(0), CustomEntries(0),
CustomLegacy(0), CustomTool(0), NrAddProperties(0), AddProperties(0), BlockKexts{0},
ConfigName{0}, /*MainConfigName(0),*/ /*BlackListCount(0),*/ DisabledDriverArray(), RPlt{0}, RBr{0}, EPCI{0}, REV{0}, ForceHPET(0), ResetHDA(0), DisableFunctions(0), SlpWak(0), UseIntelHDMI(0),
AFGLowPowerState(0), NrAddProperties(0), AddProperties(0), BlockKexts{0},
IntelMaxValue(0), OptionsBits(0), FlagsBits(0), UIScale(0), EFILoginHiDPI(0), flagstate{0},
ArbProperties(0), QuirksMask(0), MaxSlide(0), ocBooterQuirks{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, mmioWhiteListArray(), ProvideConsoleGop(0)
ArbProperties(0), QuirksMask(0), MaxSlide(0), ocBooterQuirks{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, mmioWhiteListArray()
{};
SETTINGS_DATA(const SETTINGS_DATA& other) = delete; // Can be defined if needed
const SETTINGS_DATA& operator = ( const SETTINGS_DATA & ) = delete; // Can be defined if needed
@ -757,27 +781,6 @@ public:
//#pragma GCC diagnostic ignored "-Wpadded"
typedef enum {
english = 0, //en
russian, //ru
french, //fr
german, //de
dutch, //nl
italian, //it
spanish, //es
portuguese, //pt
brasil, //br
polish, //pl
ukrainian, //ua
croatian, //hr
czech, //cs
indonesian, //id
korean, //ko
chinese, //cn
romanian //ro
//something else? add, please
} LANGUAGES;
typedef struct _DRIVERS_FLAGS {
BOOLEAN EmuVariableLoaded;
BOOLEAN VideoLoaded;
@ -876,7 +879,6 @@ extern UINTN NGFX;
extern UINTN NHDA;
//extern UINT16 gCPUtype;
extern SETTINGS_DATA gSettings;
extern LANGUAGES gLanguage;
extern BOOLEAN gFirmwareClover;
extern DRIVERS_FLAGS gDriversFlags;
extern SLOT_DEVICE SlotDevices[];

View File

@ -216,7 +216,7 @@ StartupSoundPlay(const EFI_FILE* Dir, CONST CHAR16* SoundFile)
}
// DBG("playback set\n");
// Start playback.
if (gSettings.PlayAsync) {
if (gSettings.GUI.PlayAsync) {
Status = AudioIo->StartPlaybackAsync(AudioIo, WaveData.Samples, WaveData.SamplesLength, 0, NULL, NULL);
// DBG("async started, status=%s\n", efiStrError(Status));
} else {
@ -236,7 +236,7 @@ DONE_ERROR:
// DBG("free sound\n");
FreePool(FileData);
}
if (!gSettings.PlayAsync && WaveData.Samples) {
if (!gSettings.GUI.PlayAsync && WaveData.Samples) {
//dont free sound when async play
// here we have memory leak with WaveData.Samples
// and we can't free memory up to stop AsyncPlay

View File

@ -145,26 +145,25 @@ BOOLEAN AddLegacyEntry(IN const XStringW& FullTitle, IN const XStringW& LoaderTi
// If this isn't a custom entry make sure it's not hidden by a custom entry
if (!CustomEntry) {
CUSTOM_LEGACY_ENTRY *Custom = gSettings.CustomLegacy;
while (Custom) {
if ( OSFLAG_ISSET(Custom->Flags, OSFLAG_DISABLED) || Custom->Hidden ) {
if (Custom->Volume.notEmpty()) {
if ( !Volume->DevicePathString.contains(Custom->Volume) && !Volume->VolName.contains(Custom->Volume) ) {
if (Custom->Type != 0) {
if (Custom->Type == Volume->LegacyOS->Type) {
for (size_t CustomIndex = 0 ; CustomIndex < gSettings.GUI.CustomLegacy.size() ; ++CustomIndex ) {
CUSTOM_LEGACY_ENTRY& Custom = gSettings.GUI.CustomLegacy[CustomIndex];
if ( OSFLAG_ISSET(Custom.Flags, OSFLAG_DISABLED) || Custom.Hidden ) {
if (Custom.Volume.notEmpty()) {
if ( !Volume->DevicePathString.contains(Custom.Volume) && !Volume->VolName.contains(Custom.Volume) ) {
if (Custom.Type != 0) {
if (Custom.Type == Volume->LegacyOS->Type) {
Entry->Hidden = true;
}
} else {
Entry->Hidden = true;
}
}
} else if (Custom->Type != 0) {
if (Custom->Type == Volume->LegacyOS->Type) {
} else if (Custom.Type != 0) {
if (Custom.Type == Volume->LegacyOS->Type) {
Entry->Hidden = true;
}
}
}
Custom = Custom->Next;
}
}
@ -279,28 +278,27 @@ void AddCustomLegacy(void)
UINTN VolumeIndex, VolumeIndex2;
BOOLEAN ShowVolume, HideIfOthersFound;
REFIT_VOLUME *Volume;
CUSTOM_LEGACY_ENTRY *Custom;
XIcon MainIcon;
XIcon DriveIcon;
UINTN i = 0;
// DBG("Custom legacy start\n");
if (gSettings.CustomLegacy) {
if (gSettings.GUI.CustomLegacy.notEmpty()) {
DbgHeader("AddCustomLegacy");
}
// Traverse the custom entries
for (Custom = gSettings.CustomLegacy; Custom; ++i, Custom = Custom->Next) {
if (OSFLAG_ISSET(Custom->Flags, OSFLAG_DISABLED)) {
DBG("Custom legacy %llu skipped because it is disabled.\n", i);
for (size_t i = 0 ; i < gSettings.GUI.CustomLegacy.size() ; ++i ) {
CUSTOM_LEGACY_ENTRY& Custom = gSettings.GUI.CustomLegacy[i];
if (OSFLAG_ISSET(Custom.Flags, OSFLAG_DISABLED)) {
DBG("Custom legacy %zu skipped because it is disabled.\n", i);
continue;
}
// if (!gSettings.ShowHiddenEntries && OSFLAG_ISSET(Custom->Flags, OSFLAG_HIDDEN)) {
// if (!gSettings.ShowHiddenEntries && OSFLAG_ISSET(Custom.Flags, OSFLAG_HIDDEN)) {
// DBG("Custom legacy %llu skipped because it is hidden.\n", i);
// continue;
// }
if (Custom->Volume.notEmpty()) {
DBG("Custom legacy %llu matching \"%ls\" ...\n", i, Custom->Volume.wc_str());
if (Custom.Volume.notEmpty()) {
DBG("Custom legacy %zu matching \"%ls\" ...\n", i, Custom.Volume.wc_str());
}
for (VolumeIndex = 0; VolumeIndex < Volumes.size(); ++VolumeIndex) {
Volume = &Volumes[VolumeIndex];
@ -314,8 +312,8 @@ void AddCustomLegacy(void)
continue;
}
if (Custom->VolumeType != 0) {
if (((1ull<<Volume->DiskKind) & Custom->VolumeType) == 0) {
if (Custom.VolumeType != 0) {
if (((1ull<<Volume->DiskKind) & Custom.VolumeType) == 0) {
DBG("skipped because media is ignored\n");
continue;
}
@ -359,34 +357,34 @@ void AddCustomLegacy(void)
}
// Check for exact volume matches
if (Custom->Volume.notEmpty()) {
if ((StrStr(Volume->DevicePathString.wc_str(), Custom->Volume.wc_str()) == NULL) &&
((Volume->VolName.isEmpty()) || (StrStr(Volume->VolName.wc_str(), Custom->Volume.wc_str()) == NULL))) {
if (Custom.Volume.notEmpty()) {
if ((StrStr(Volume->DevicePathString.wc_str(), Custom.Volume.wc_str()) == NULL) &&
((Volume->VolName.isEmpty()) || (StrStr(Volume->VolName.wc_str(), Custom.Volume.wc_str()) == NULL))) {
DBG("skipped\n");
continue;
}
// Check if the volume should be of certain os type
if ((Custom->Type != 0) && (Custom->Type != Volume->LegacyOS->Type)) {
if ((Custom.Type != 0) && (Custom.Type != Volume->LegacyOS->Type)) {
DBG("skipped because wrong type\n");
continue;
}
} else if ((Custom->Type != 0) && (Custom->Type != Volume->LegacyOS->Type)) {
} else if ((Custom.Type != 0) && (Custom.Type != Volume->LegacyOS->Type)) {
DBG("skipped because wrong type\n");
continue;
}
// Change to custom image if needed
MainIcon = Custom->Image;
MainIcon = Custom.Image;
if (MainIcon.Image.isEmpty()) {
MainIcon.Image.LoadXImage(&ThemeX.getThemeDir(), Custom->ImagePath);
MainIcon.Image.LoadXImage(&ThemeX.getThemeDir(), Custom.ImagePath);
}
// Change to custom drive image if needed
DriveIcon = Custom->DriveImage;
DriveIcon = Custom.DriveImage;
if (DriveIcon.Image.isEmpty()) {
DriveIcon.Image.LoadXImage(&ThemeX.getThemeDir(), Custom->DriveImagePath);
DriveIcon.Image.LoadXImage(&ThemeX.getThemeDir(), Custom.DriveImagePath);
}
// Create a legacy entry for this volume
if (AddLegacyEntry(Custom->FullTitle, Custom->Title, Volume, &MainIcon, &DriveIcon, Custom->Hotkey, TRUE))
if (AddLegacyEntry(Custom.FullTitle, Custom.Title, Volume, &MainIcon, &DriveIcon, Custom.Hotkey, TRUE))
{
DBG("match!\n");
}

View File

@ -459,7 +459,7 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST XStringW& LoaderPath,
IN CHAR16 Hotkey,
EFI_GRAPHICS_OUTPUT_BLT_PIXEL BootBgColor,
IN UINT8 CustomBoot,
IN XImage *CustomLogo,
IN const XImage& CustomLogo,
IN const KERNEL_AND_KEXT_PATCHES* Patches,
IN BOOLEAN CustomEntry)
{
@ -498,9 +498,6 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST XStringW& LoaderPath,
Entry = new LOADER_ENTRY();
if (!CustomEntry) {
CUSTOM_LOADER_ENTRY *Custom;
UINTN CustomIndex = 0;
// Ignore this loader if it's device path is already present in another loader
for (UINTN i = 0; i < MainMenu.Entries.size(); ++i) {
REFIT_ABSTRACT_MENU_ENTRY& MainEntry = MainMenu.Entries[i];
@ -513,10 +510,10 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST XStringW& LoaderPath,
}
}
// If this isn't a custom entry make sure it's not hidden by a custom entry
Custom = gSettings.CustomEntries;
while (Custom) {
for (size_t CustomIndex = 0 ; CustomIndex < gSettings.GUI.CustomEntries.size() ; ++CustomIndex ) {
CUSTOM_LOADER_ENTRY& Custom = gSettings.GUI.CustomEntries[CustomIndex];
// Check if the custom entry is hidden or disabled
if ( OSFLAG_ISSET(Custom->Flags, OSFLAG_DISABLED) || Custom->Hidden ) {
if ( OSFLAG_ISSET(Custom.Flags, OSFLAG_DISABLED) || Custom.Hidden ) {
INTN volume_match=0;
INTN volume_type_match=0;
@ -524,33 +521,33 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST XStringW& LoaderPath,
INTN type_match=0;
// Check if volume match
if (Custom->Volume.notEmpty()) {
if (Custom.Volume.notEmpty()) {
// Check if the string matches the volume
volume_match =
((StrStr(Volume->DevicePathString.wc_str(), Custom->Volume.wc_str()) != NULL) ||
((Volume->VolName.notEmpty()) && (StrStr(Volume->VolName.wc_str(), Custom->Volume.wc_str()) != NULL))) ? 1 : -1;
((StrStr(Volume->DevicePathString.wc_str(), Custom.Volume.wc_str()) != NULL) ||
((Volume->VolName.notEmpty()) && (StrStr(Volume->VolName.wc_str(), Custom.Volume.wc_str()) != NULL))) ? 1 : -1;
}
// Check if the volume_type match
if (Custom->VolumeType != 0) {
volume_type_match = (((1ull<<Volume->DiskKind) & Custom->VolumeType) != 0) ? 1 : -1;
if (Custom.VolumeType != 0) {
volume_type_match = (((1ull<<Volume->DiskKind) & Custom.VolumeType) != 0) ? 1 : -1;
}
// Check if the path match
if (Custom->Path.notEmpty()) {
if (Custom.Path.notEmpty()) {
// Check if the loader path match
path_match = (Custom->Path.equalIC(LoaderPath)) ? 1 : -1;
path_match = (Custom.Path.equalIC(LoaderPath)) ? 1 : -1;
}
// Check if the type match
if (Custom->Type != 0) {
type_match = OSTYPE_COMPARE(Custom->Type, OSType) ? 1 : -1;
if (Custom.Type != 0) {
type_match = OSTYPE_COMPARE(Custom.Type, OSType) ? 1 : -1;
}
if (volume_match == -1 || volume_type_match == -1 || path_match == -1 || type_match == -1 ) {
UINTN add_comma = 0;
DBG("%sNot match custom entry %llu: ", indent, CustomIndex);
DBG("%sNot match custom entry %zu: ", indent, CustomIndex);
if (volume_match != 0) {
DBG("Volume: %ls", volume_match == 1 ? L"match" : L"not match");
add_comma++;
@ -575,12 +572,10 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST XStringW& LoaderPath,
DBG("\n");
} else {
// Custom entry match
DBG("%sHidden because matching custom entry %llu!\n", indent, CustomIndex);
DBG("%sHidden because matching custom entry %zu!\n", indent, CustomIndex);
Entry->Hidden = true;
}
}
Custom = Custom->Next;
++CustomIndex;
}
}
Entry->Row = 0;
@ -613,9 +608,7 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST XStringW& LoaderPath,
Entry->AtDoubleClick = ActionEnter;
Entry->AtRightClick = ActionDetails;
Entry->CustomBoot = CustomBoot;
if (CustomLogo != nullptr) {
Entry->CustomLogo = *CustomLogo; //else empty ximage already constructed
}
Entry->CustomLogo = CustomLogo; //could be an empty image
Entry->LoaderType = OSType;
Entry->BuildVersion.setEmpty();
@ -1041,14 +1034,14 @@ LOADER_ENTRY* AddLoaderEntry(IN CONST XStringW& LoaderPath, IN CONST XString8Arr
//don't add hided entries
// if (!gSettings.ShowHiddenEntries) {
// for (HVi = 0; HVi < gSettings.HVCount; HVi++) {
// if ( LoaderPath.containsIC(gSettings.HVHideStrings[HVi]) ) {
// if ( LoaderPath.containsIC(gSettings.GUI.HVHideStrings[HVi]) ) {
// DBG(" hiding entry: %ls\n", LoaderPath.s());
// return NULL;
// }
// }
// }
Entry = CreateLoaderEntry(LoaderPath, LoaderOptions, FullTitle, LoaderTitle, Volume, Image, NULL, OSType, Flags, 0, MenuBackgroundPixel, CUSTOM_BOOT_DISABLED, NULL, NULL, FALSE);
Entry = CreateLoaderEntry(LoaderPath, LoaderOptions, FullTitle, LoaderTitle, Volume, Image, NULL, OSType, Flags, 0, MenuBackgroundPixel, CUSTOM_BOOT_DISABLED, NullXImage, NULL, FALSE);
if (Entry != NULL) {
if ((Entry->LoaderType == OSTYPE_OSX) ||
(Entry->LoaderType == OSTYPE_OSX_INSTALLER ) ||
@ -1068,8 +1061,8 @@ LOADER_ENTRY* AddLoaderEntry(IN CONST XStringW& LoaderPath, IN CONST XString8Arr
DBG(" hiding entry because volume is hidden: %ls\n", LoaderPath.s());
Entry->Hidden = true;
}else{
for (size_t HVi = 0; HVi < gSettings.HVHideStrings.size(); HVi++) {
if ( LoaderPath.containsIC(gSettings.HVHideStrings[HVi]) ) {
for (size_t HVi = 0; HVi < gSettings.GUI.HVHideStrings.size(); HVi++) {
if ( LoaderPath.containsIC(gSettings.GUI.HVHideStrings[HVi]) ) {
DBG(" hiding entry: %ls\n", LoaderPath.s());
Entry->Hidden = true;
}
@ -1503,8 +1496,8 @@ void ScanLoader(void)
}
#endif
if (gSettings.LinuxScan) {
LinuxScan(Volume, gSettings.KernelScan, 0, NULL, NULL);
if (gSettings.GUI.Scan.LinuxScan) {
LinuxScan(Volume, gSettings.GUI.Scan.KernelScan, 0, NULL, NULL);
}
// DBG("search for optical UEFI\n");
@ -1822,10 +1815,11 @@ void ScanLoader(void)
}
STATIC void AddCustomEntry(IN UINTN CustomIndex,
IN XStringW CustomPath,
IN CUSTOM_LOADER_ENTRY *Custom,
IN REFIT_MENU_SCREEN *SubMenu)
STATIC void AddCustomEntry(IN UINTN CustomIndex,
IN const XStringW& _CustomPath,
IN const CUSTOM_LOADER_ENTRY& Custom,
IN const XStringW& DefaultEntrySettings,
IN REFIT_MENU_SCREEN *SubMenu)
{
UINTN VolumeIndex;
REFIT_VOLUME *Volume;
@ -1833,15 +1827,13 @@ STATIC void AddCustomEntry(IN UINTN CustomIndex,
REFIT_DIR_ITER *Iter = &SIter;
CHAR16 PartUUID[40];
BOOLEAN IsSubEntry = (SubMenu != NULL);
XStringW CustomPath = _CustomPath;
BOOLEAN FindCustomPath = (CustomPath.isEmpty());
if (Custom == NULL) {
return;
}
if (FindCustomPath && (Custom->Type != OSTYPE_LINEFI) && (Custom->Type != OSTYPE_LIN)) {
if (FindCustomPath && (Custom.Type != OSTYPE_LINEFI) && (Custom.Type != OSTYPE_LIN)) {
// DBG("Custom %lsentry %llu skipped because it didn't have a ", IsSubEntry ? L"sub " : L"", CustomIndex);
// if (Custom->Type == 0) {
// if (Custom.Type == 0) {
// DBG("Type.\n");
// } else {
// DBG("Path.\n");
@ -1849,43 +1841,42 @@ STATIC void AddCustomEntry(IN UINTN CustomIndex,
return;
}
if (OSFLAG_ISSET(Custom->Flags, OSFLAG_DISABLED)) {
if (OSFLAG_ISSET(Custom.Flags, OSFLAG_DISABLED)) {
// DBG("Custom %lsentry %llu skipped because it is disabled.\n", IsSubEntry ? L"sub " : L"", CustomIndex);
return;
}
// if (!gSettings.ShowHiddenEntries && OSFLAG_ISSET(Custom->Flags, OSFLAG_HIDDEN)) {
// if (!gSettings.ShowHiddenEntries && OSFLAG_ISSET(Custom.Flags, OSFLAG_HIDDEN)) {
// DBG("Custom %lsentry %llu skipped because it is hidden.\n", IsSubEntry ? L"sub " : L"", CustomIndex);
// return;
// }
#if 0 //if someone want to debug this
DBG("Custom %lsentry %llu ", IsSubEntry ? L"sub " : L"", CustomIndex);
// if (Custom->Title) {
DBG("Title:\"%ls\" ", Custom->Title.wc_str());
// if (Custom.Title) {
DBG("Title:\"%ls\" ", Custom.Title.wc_str());
// }
// if (Custom->FullTitle) {
DBG("FullTitle:\"%ls\" ", Custom->FullTitle.wc_str());
// if (Custom.FullTitle) {
DBG("FullTitle:\"%ls\" ", Custom.FullTitle.wc_str());
// }
if (CustomPath) {
DBG("Path:\"%ls\" ", CustomPath);
}
if (Custom->Options != NULL) {
DBG("Options:\"%ls\" ", Custom->Options);
if (Custom.Options != NULL) {
DBG("Options:\"%ls\" ", Custom.Options);
}
DBG("Type:%d Flags:0x%hhX matching ", Custom->Type, Custom->Flags);
if (Custom->Volume) {
DBG("Volume:\"%ls\"\n", Custom->Volume);
DBG("Type:%d Flags:0x%hhX matching ", Custom.Type, Custom.Flags);
if (Custom.Volume) {
DBG("Volume:\"%ls\"\n", Custom.Volume);
} else {
DBG("all volumes\n");
}
#endif
for (VolumeIndex = 0; VolumeIndex < Volumes.size(); ++VolumeIndex) {
CUSTOM_LOADER_ENTRY *CustomSubEntry;
LOADER_ENTRY *Entry = NULL;
XIcon Image = Custom->Image;
XIcon DriveImage = Custom->DriveImage;
XIcon Image = Custom.Image;
XIcon DriveImage = Custom.DriveImage;
EFI_GUID *Guid = NULL;
UINT64 VolumeSize;
@ -1906,7 +1897,7 @@ STATIC void AddCustomEntry(IN UINTN CustomIndex,
continue;
}
if (Custom->VolumeType != 0 && ((1<<Volume->DiskKind) & Custom->VolumeType) == 0) {
if (Custom.VolumeType != 0 && ((1<<Volume->DiskKind) & Custom.VolumeType) == 0) {
DBG("skipped because media is ignored\n");
continue;
}
@ -1924,9 +1915,9 @@ STATIC void AddCustomEntry(IN UINTN CustomIndex,
// Check for exact volume matches (devicepath / volumelabel)
if (Custom->Volume.notEmpty()) {
if ((StrStr(Volume->DevicePathString.wc_str(), Custom->Volume.wc_str()) == NULL) &&
((Volume->VolName.isEmpty()) || (StrStr(Volume->VolName.wc_str(), Custom->Volume.wc_str()) == NULL))) {
if (Custom.Volume.notEmpty()) {
if ((StrStr(Volume->DevicePathString.wc_str(), Custom.Volume.wc_str()) == NULL) &&
((Volume->VolName.isEmpty()) || (StrStr(Volume->VolName.wc_str(), Custom.Volume.wc_str()) == NULL))) {
bool CustomEntryFound = false;
//..\VenMedia(BE74FCF7-0B7C-49F3-9147-01F4042E6842,E97E25EA28F4DF46AAD44CC3F12E28D3)
EFI_DEVICE_PATH *MediaPath = Clover_FindDevicePathNodeWithType(Volume->DevicePath, MEDIA_DEVICE_PATH, MEDIA_VENDOR_DP);
@ -1934,11 +1925,11 @@ STATIC void AddCustomEntry(IN UINTN CustomIndex,
EFI_GUID *MediaPathGuid = (EFI_GUID *)&((VENDOR_DEVICE_PATH_WITH_DATA*)MediaPath)->VendorDefinedData;
XStringW MediaPathGuidStr = GuidLEToXStringW(*MediaPathGuid);
// DBG(" checking '%ls'\n", MediaPathGuidStr.wc_str());
if (StrStr(Custom->Volume.wc_str(), MediaPathGuidStr.wc_str())) {
DBG(" - found entry for volume '%ls', '%ls'\n", Custom->Volume.wc_str(), MediaPathGuidStr.wc_str());
if (StrStr(Custom.Volume.wc_str(), MediaPathGuidStr.wc_str())) {
DBG(" - found entry for volume '%ls', '%ls'\n", Custom.Volume.wc_str(), MediaPathGuidStr.wc_str());
CustomEntryFound = true;
} else {
DBG(" - search volume '%ls', but MediaPath '%ls' \n", Custom->Volume.wc_str(), MediaPathGuidStr.wc_str());
DBG(" - search volume '%ls', but MediaPath '%ls' \n", Custom.Volume.wc_str(), MediaPathGuidStr.wc_str());
}
}
if (!CustomEntryFound) {
@ -1960,10 +1951,10 @@ STATIC void AddCustomEntry(IN UINTN CustomIndex,
StrToLower(PartUUID);
// search for standard/nonstandard linux uefi paths, and all kernel scan options that != KERNEL_SCAN_ALL
if (Custom->Type == OSTYPE_LIN || Custom->KernelScan != KERNEL_SCAN_ALL) {
LinuxScan(Volume, Custom->KernelScan, Custom->Type, &CustomPath, &Image);
if (Custom.Type == OSTYPE_LIN || Custom.KernelScan != KERNEL_SCAN_ALL) {
LinuxScan(Volume, Custom.KernelScan, Custom.Type, &CustomPath, &Image);
}
if (Custom->Type == OSTYPE_LINEFI) {
if (Custom.Type == OSTYPE_LINEFI) {
// Open the boot directory to determine linux loadoptions when found item, or kernels when KERNEL_SCAN_ALL
DirIterOpen(Volume->RootDir, LINUX_BOOT_PATH, Iter);
}
@ -1973,16 +1964,16 @@ STATIC void AddCustomEntry(IN UINTN CustomIndex,
}
// Change to custom image if needed
if (Image.isEmpty() && Custom->ImagePath.notEmpty()) {
Image.LoadXImage(&ThemeX.getThemeDir(), Custom->ImagePath);
if (Image.isEmpty() && Custom.ImagePath.notEmpty()) {
Image.LoadXImage(&ThemeX.getThemeDir(), Custom.ImagePath);
if (Image.isEmpty()) {
Image.LoadXImage(&ThemeX.getThemeDir(), L"os_"_XSW + Custom->ImagePath);
Image.LoadXImage(&ThemeX.getThemeDir(), L"os_"_XSW + Custom.ImagePath);
if (Image.isEmpty()) {
Image.LoadXImage(&self.getCloverDir(), Custom->ImagePath);
Image.LoadXImage(&self.getCloverDir(), Custom.ImagePath);
if (Image.isEmpty()) {
Image.LoadXImage(&self.getSelfVolumeRootDir(), Custom->ImagePath);
Image.LoadXImage(&self.getSelfVolumeRootDir(), Custom.ImagePath);
if (Image.isEmpty()) {
Image.LoadXImage(Volume->RootDir, Custom->ImagePath);
Image.LoadXImage(Volume->RootDir, Custom.ImagePath);
}
}
}
@ -1990,24 +1981,24 @@ STATIC void AddCustomEntry(IN UINTN CustomIndex,
}
// Change to custom drive image if needed
if (DriveImage.isEmpty() && Custom->DriveImagePath.notEmpty()) {
DriveImage.LoadXImage(&ThemeX.getThemeDir(), Custom->DriveImagePath);
if (DriveImage.isEmpty() && Custom.DriveImagePath.notEmpty()) {
DriveImage.LoadXImage(&ThemeX.getThemeDir(), Custom.DriveImagePath);
if (DriveImage.isEmpty()) {
DriveImage.LoadXImage(&self.getCloverDir(), Custom->ImagePath);
DriveImage.LoadXImage(&self.getCloverDir(), Custom.ImagePath);
if (DriveImage.isEmpty()) {
DriveImage.LoadXImage(&self.getSelfVolumeRootDir(), Custom->ImagePath);
DriveImage.LoadXImage(&self.getSelfVolumeRootDir(), Custom.ImagePath);
if (DriveImage.isEmpty()) {
DriveImage.LoadXImage(Volume->RootDir, Custom->ImagePath);
DriveImage.LoadXImage(Volume->RootDir, Custom.ImagePath);
}
}
}
}
do { // when not scanning for kernels, this loop will execute only once
XString8Array CustomOptions = Custom->LoadOptions;
XString8Array CustomOptions = Custom.LoadOptions;
// for LINEFI with option KERNEL_SCAN_ALL, use this loop to search for kernels
if (FindCustomPath && Custom->Type == OSTYPE_LINEFI && Custom->KernelScan == KERNEL_SCAN_ALL) {
if (FindCustomPath && Custom.Type == OSTYPE_LINEFI && Custom.KernelScan == KERNEL_SCAN_ALL) {
EFI_FILE_INFO *FileInfo = NULL;
// Get the next kernel path or stop looking
if (!DirIterNext(Iter, 2, LINUX_LOADER_SEARCH_PATH, &FileInfo) || (FileInfo == NULL)) {
@ -2026,130 +2017,131 @@ STATIC void AddCustomEntry(IN UINTN CustomIndex,
break;
}
UINT8 newCustomFlags = Custom.Flags;
// Check to make sure if we should update linux custom options or not
if (FindCustomPath && Custom->Type == OSTYPE_LINEFI && OSFLAG_ISUNSET(Custom->Flags, OSFLAG_NODEFAULTARGS)) {
if (FindCustomPath && Custom.Type == OSTYPE_LINEFI && OSFLAG_ISUNSET(Custom.Flags, OSFLAG_NODEFAULTARGS)) {
// Find the init ram image and select root
CustomOptions = LinuxKernelOptions(Iter->DirHandle, Basename(CustomPath.wc_str()) + LINUX_LOADER_PATH.length(), PartUUID, Custom->LoadOptions);
Custom->Flags = OSFLAG_SET(Custom->Flags, OSFLAG_NODEFAULTARGS);
CustomOptions = LinuxKernelOptions(Iter->DirHandle, Basename(CustomPath.wc_str()) + LINUX_LOADER_PATH.length(), PartUUID, Custom.LoadOptions);
newCustomFlags = OSFLAG_SET(Custom.Flags, OSFLAG_NODEFAULTARGS);
}
// Check to make sure that this entry is not hidden or disabled by another custom entry
if (!IsSubEntry) {
CUSTOM_LOADER_ENTRY *Ptr;
UINTN i = 0;
BOOLEAN BetterMatch = FALSE;
for (Ptr = gSettings.CustomEntries; Ptr != NULL; ++i, Ptr = Ptr->Next) {
for (size_t i = 0 ; i < gSettings.GUI.CustomEntries.size() ; ++i ) {
CUSTOM_LOADER_ENTRY* Ptr = &gSettings.GUI.CustomEntries[i];
// Don't match against this custom
if (Ptr == Custom) {
if (Ptr == &Custom) {
continue;
}
// Can only match the same types
if (Custom->Type != Ptr->Type) {
if (Custom.Type != Ptr->Type) {
continue;
}
// Check if the volume string matches
if (Custom->Volume != Ptr->Volume) {
if (Custom.Volume != Ptr->Volume) {
if (Ptr->Volume.isEmpty()) {
// Less precise volume match
if (Custom->Path != Ptr->Path) {
if (Custom.Path != Ptr->Path) {
// Better path match
BetterMatch = ((Ptr->Path.notEmpty()) && CustomPath.equal(Ptr->Path) &&
((Custom->VolumeType == Ptr->VolumeType) ||
((1ull<<Volume->DiskKind) & Custom->VolumeType) != 0));
((Custom.VolumeType == Ptr->VolumeType) ||
((1ull<<Volume->DiskKind) & Custom.VolumeType) != 0));
}
} else if ((StrStr(Volume->DevicePathString.wc_str(), Custom->Volume.wc_str()) == NULL) &&
((Volume->VolName.isEmpty()) || (StrStr(Volume->VolName.wc_str(), Custom->Volume.wc_str()) == NULL))) {
if (Custom->Volume.isEmpty()) {
} else if ((StrStr(Volume->DevicePathString.wc_str(), Custom.Volume.wc_str()) == NULL) &&
((Volume->VolName.isEmpty()) || (StrStr(Volume->VolName.wc_str(), Custom.Volume.wc_str()) == NULL))) {
if (Custom.Volume.isEmpty()) {
// More precise volume match
if (Custom->Path != Ptr->Path) {
if (Custom.Path != Ptr->Path) {
// Better path match
BetterMatch = ((Ptr->Path.notEmpty()) && CustomPath.equal(Ptr->Path) &&
((Custom->VolumeType == Ptr->VolumeType) ||
((1ull<<Volume->DiskKind) & Custom->VolumeType) != 0));
} else if (Custom->VolumeType != Ptr->VolumeType) {
((Custom.VolumeType == Ptr->VolumeType) ||
((1ull<<Volume->DiskKind) & Custom.VolumeType) != 0));
} else if (Custom.VolumeType != Ptr->VolumeType) {
// More precise volume type match
BetterMatch = ((Custom->VolumeType == 0) &&
((1ull<<Volume->DiskKind) & Custom->VolumeType) != 0);
BetterMatch = ((Custom.VolumeType == 0) &&
((1ull<<Volume->DiskKind) & Custom.VolumeType) != 0);
} else {
// Better match
BetterMatch = TRUE;
}
// Duplicate volume match
} else if (Custom->Path != Ptr->Path) {
} else if (Custom.Path != Ptr->Path) {
// Better path match
BetterMatch = ((Ptr->Path.notEmpty()) && CustomPath.equal(Ptr->Path) &&
((Custom->VolumeType == Ptr->VolumeType) ||
((1ull<<Volume->DiskKind) & Custom->VolumeType) != 0));
((Custom.VolumeType == Ptr->VolumeType) ||
((1ull<<Volume->DiskKind) & Custom.VolumeType) != 0));
// Duplicate path match
} else if (Custom->VolumeType != Ptr->VolumeType) {
} else if (Custom.VolumeType != Ptr->VolumeType) {
// More precise volume type match
BetterMatch = ((Custom->VolumeType == 0) &&
((1ull<<Volume->DiskKind) & Custom->VolumeType) != 0);
BetterMatch = ((Custom.VolumeType == 0) &&
((1ull<<Volume->DiskKind) & Custom.VolumeType) != 0);
} else {
// Duplicate entry
BetterMatch = (i <= CustomIndex);
}
}
// Duplicate volume match
} else if (Custom->Path != Ptr->Path) {
} else if (Custom.Path != Ptr->Path) {
if (Ptr->Path.isEmpty()) {
// Less precise path match
BetterMatch = ((Custom->VolumeType != Ptr->VolumeType) &&
((1ull<<Volume->DiskKind) & Custom->VolumeType) != 0);
BetterMatch = ((Custom.VolumeType != Ptr->VolumeType) &&
((1ull<<Volume->DiskKind) & Custom.VolumeType) != 0);
} else if (CustomPath.equal(Ptr->Path)) {
if (Custom->Path.isEmpty()) {
if (Custom.Path.isEmpty()) {
// More precise path and volume type match
BetterMatch = ((Custom->VolumeType == Ptr->VolumeType) ||
((1ull<<Volume->DiskKind) & Custom->VolumeType) != 0);
} else if (Custom->VolumeType != Ptr->VolumeType) {
BetterMatch = ((Custom.VolumeType == Ptr->VolumeType) ||
((1ull<<Volume->DiskKind) & Custom.VolumeType) != 0);
} else if (Custom.VolumeType != Ptr->VolumeType) {
// More precise volume type match
BetterMatch = ((Custom->VolumeType == 0) &&
((1ull<<Volume->DiskKind) & Custom->VolumeType) != 0);
BetterMatch = ((Custom.VolumeType == 0) &&
((1ull<<Volume->DiskKind) & Custom.VolumeType) != 0);
} else {
// Duplicate entry
BetterMatch = (i <= CustomIndex);
}
}
// Duplicate path match
} else if (Custom->VolumeType != Ptr->VolumeType) {
} else if (Custom.VolumeType != Ptr->VolumeType) {
// More precise volume type match
BetterMatch = ((Custom->VolumeType == 0) &&
((1ull<<Volume->DiskKind) & Custom->VolumeType) != 0);
BetterMatch = ((Custom.VolumeType == 0) &&
((1ull<<Volume->DiskKind) & Custom.VolumeType) != 0);
} else {
// Duplicate entry
BetterMatch = (i <= CustomIndex);
}
if (BetterMatch) {
DBG("skipped because custom entry %zu is a better match and will produce a duplicate entry\n", i);
break;
}
}
if (BetterMatch) {
DBG("skipped because custom entry %llu is a better match and will produce a duplicate entry\n", i);
continue;
}
}
DBG("match!\n");
// Create an entry for this volume
Entry = CreateLoaderEntry(CustomPath, CustomOptions, Custom->FullTitle, Custom->Title, Volume,
Entry = CreateLoaderEntry(CustomPath, CustomOptions, Custom.FullTitle, Custom.Title, Volume,
(Image.isEmpty() ? NULL : &Image), (DriveImage.isEmpty() ? NULL : &DriveImage),
Custom->Type, Custom->Flags, Custom->Hotkey, Custom->BootBgColor, Custom->CustomBoot, &Custom->CustomLogo,
Custom.Type, newCustomFlags, Custom.Hotkey, Custom.BootBgColor, Custom.CustomBoot, Custom.CustomLogo,
/*(KERNEL_AND_KEXT_PATCHES *)(((UINTN)Custom) + OFFSET_OF(CUSTOM_LOADER_ENTRY, KernelAndKextPatches))*/ NULL, TRUE);
if (Entry != NULL) {
DBG("Custom settings: %ls.plist will %s be applied\n", Custom->Settings.wc_str(), Custom->CommonSettings?"not":"");
if (!Custom->CommonSettings) {
Entry->Settings = Custom->Settings;
DBG("Custom settings: %ls.plist will %s be applied\n", Custom.Settings.wc_str(), Custom.CommonSettings?"not":"");
if (!Custom.CommonSettings) {
Entry->Settings = DefaultEntrySettings;
}
if (OSFLAG_ISUNSET(Custom->Flags, OSFLAG_NODEFAULTMENU)) {
if (OSFLAG_ISUNSET(newCustomFlags, OSFLAG_NODEFAULTMENU)) {
Entry->AddDefaultMenu();
} else if (Custom->SubEntries != NULL) {
} else if (Custom.SubEntries.notEmpty()) {
UINTN CustomSubIndex = 0;
// Add subscreen
REFIT_MENU_SCREEN *SubScreen = new REFIT_MENU_SCREEN;
if (SubScreen) {
SubScreen->Title.SWPrintf("Boot Options for %ls on %ls", (Custom->Title.notEmpty()) ? Custom->Title.wc_str() : CustomPath.wc_str(), Entry->DisplayedVolName.wc_str());
SubScreen->Title.SWPrintf("Boot Options for %ls on %ls", (Custom.Title.notEmpty()) ? Custom.Title.wc_str() : CustomPath.wc_str(), Entry->DisplayedVolName.wc_str());
SubScreen->TitleImage = Entry->Image;
SubScreen->ID = Custom->Type + 20;
SubScreen->ID = Custom.Type + 20;
SubScreen->GetAnime();
VolumeSize = RShiftU64(MultU64x32(Volume->BlockIO->Media->LastBlock, Volume->BlockIO->Media->BlockSize), 20);
SubScreen->AddMenuInfoLine_f("Volume size: %lldMb", VolumeSize);
@ -2159,11 +2151,13 @@ STATIC void AddCustomEntry(IN UINTN CustomIndex,
}
SubScreen->AddMenuInfoLine_f("Options: %s", Entry->LoadOptions.ConcatAll(" "_XS8).c_str());
DBG("Create sub entries\n");
for (CustomSubEntry = Custom->SubEntries; CustomSubEntry; CustomSubEntry = CustomSubEntry->Next) {
if ( CustomSubEntry->Settings.isEmpty() ) {
CustomSubEntry->Settings = Custom->Settings;
for (size_t CustomSubEntryIndex = 0 ; CustomSubEntryIndex < Custom.SubEntries.size() ; ++CustomSubEntryIndex ) {
const CUSTOM_LOADER_ENTRY& CustomSubEntry = Custom.SubEntries[CustomSubEntryIndex];
if ( CustomSubEntry.Settings.isEmpty() ) {
AddCustomEntry(CustomSubIndex++, (CustomSubEntry.Path.notEmpty()) ? CustomSubEntry.Path : CustomPath, CustomSubEntry, Custom.Settings, SubScreen);
}else{
AddCustomEntry(CustomSubIndex++, (CustomSubEntry.Path.notEmpty()) ? CustomSubEntry.Path : CustomPath, CustomSubEntry, CustomSubEntry.Settings, SubScreen);
}
AddCustomEntry(CustomSubIndex++, (CustomSubEntry->Path.notEmpty()) ? CustomSubEntry->Path : CustomPath, CustomSubEntry, SubScreen);
}
SubScreen->AddMenuEntry(&MenuEntryReturn, true);
Entry->SubScreen = SubScreen;
@ -2173,13 +2167,13 @@ STATIC void AddCustomEntry(IN UINTN CustomIndex,
SubMenu->AddMenuEntry(Entry, true);
else
MainMenu.AddMenuEntry(Entry, true);
DBG(" hiding entry because Custom->Hidden: %ls\n", Entry->LoaderPath.s());
Entry->Hidden = Custom->Hidden;
DBG(" hiding entry because Custom.Hidden: %ls\n", Entry->LoaderPath.s());
Entry->Hidden = Custom.Hidden;
}
} while (FindCustomPath && Custom->Type == OSTYPE_LINEFI && Custom->KernelScan == KERNEL_SCAN_ALL); // repeat loop only for kernel scanning
} while (FindCustomPath && Custom.Type == OSTYPE_LINEFI && Custom.KernelScan == KERNEL_SCAN_ALL); // repeat loop only for kernel scanning
// Close the kernel boot directory
if (FindCustomPath && Custom->Type == OSTYPE_LINEFI) {
if (FindCustomPath && Custom.Type == OSTYPE_LINEFI) {
DirIterClose(Iter);
}
}
@ -2189,43 +2183,39 @@ STATIC void AddCustomEntry(IN UINTN CustomIndex,
// Add custom entries
void AddCustomEntries(void)
{
CUSTOM_LOADER_ENTRY *Custom;
UINTN i = 0;
if (!gSettings.CustomEntries) {
return;
}
if (!gSettings.GUI.CustomEntries.isEmpty()) return;
//DBG("Custom entries start\n");
DbgHeader("AddCustomEntries");
// Traverse the custom entries
for (Custom = gSettings.CustomEntries; Custom; ++i, Custom = Custom->Next) {
if ((Custom->Path.isEmpty()) && (Custom->Type != 0)) {
if (OSTYPE_IS_OSX(Custom->Type)) {
AddCustomEntry(i, MACOSX_LOADER_PATH, Custom, NULL);
} else if (OSTYPE_IS_OSX_RECOVERY(Custom->Type)) {
AddCustomEntry(i, L"\\com.apple.recovery.boot\\boot.efi"_XSW, Custom, NULL);
} else if (OSTYPE_IS_OSX_INSTALLER(Custom->Type)) {
for (size_t i = 0 ; i < gSettings.GUI.CustomEntries.size(); ++i) {
CUSTOM_LOADER_ENTRY& Custom = gSettings.GUI.CustomEntries[i];
if ((Custom.Path.isEmpty()) && (Custom.Type != 0)) {
if (OSTYPE_IS_OSX(Custom.Type)) {
AddCustomEntry(i, MACOSX_LOADER_PATH, Custom, Custom.Settings, NULL);
} else if (OSTYPE_IS_OSX_RECOVERY(Custom.Type)) {
AddCustomEntry(i, L"\\com.apple.recovery.boot\\boot.efi"_XSW, Custom, Custom.Settings, NULL);
} else if (OSTYPE_IS_OSX_INSTALLER(Custom.Type)) {
UINTN Index = 0;
while (Index < OSXInstallerPathsCount) {
AddCustomEntry(i, OSXInstallerPaths[Index++], Custom, NULL);
AddCustomEntry(i, OSXInstallerPaths[Index++], Custom, Custom.Settings, NULL);
}
} else if (OSTYPE_IS_WINDOWS(Custom->Type)) {
AddCustomEntry(i, L"\\EFI\\Microsoft\\Boot\\bootmgfw.efi"_XSW, Custom, NULL);
} else if (OSTYPE_IS_LINUX(Custom->Type)) {
} else if (OSTYPE_IS_WINDOWS(Custom.Type)) {
AddCustomEntry(i, L"\\EFI\\Microsoft\\Boot\\bootmgfw.efi"_XSW, Custom, Custom.Settings, NULL);
} else if (OSTYPE_IS_LINUX(Custom.Type)) {
#if defined(ANDX86)
for (UINTN Index = 0; Index < AndroidEntryDataCount; ++Index) {
AddCustomEntry(i, AndroidEntryData[Index].Path, Custom, NULL);
AddCustomEntry(i, AndroidEntryData[Index].Path, Custom, Custom.Settings, NULL);
}
#endif
AddCustomEntry(i, NullXStringW, Custom, NULL);
} else if (Custom->Type == OSTYPE_LINEFI) {
AddCustomEntry(i, NullXStringW, Custom, NULL);
AddCustomEntry(i, NullXStringW, Custom, Custom.Settings, NULL);
} else if (Custom.Type == OSTYPE_LINEFI) {
AddCustomEntry(i, NullXStringW, Custom, Custom.Settings, NULL);
} else {
AddCustomEntry(i, BOOT_LOADER_PATH, Custom, NULL);
AddCustomEntry(i, BOOT_LOADER_PATH, Custom, Custom.Settings, NULL);
}
} else {
AddCustomEntry(i, Custom->Path, Custom, NULL);
AddCustomEntry(i, Custom.Path, Custom, Custom.Settings, NULL);
}
}
//DBG("Custom entries finish\n");

View File

@ -240,25 +240,24 @@ void AddCustomTool(void)
{
UINTN VolumeIndex;
REFIT_VOLUME *Volume;
CUSTOM_TOOL_ENTRY *Custom;
XIcon Image;
UINTN i = 0;
// DBG("Custom tool start\n");
DbgHeader("AddCustomTool");
// Traverse the custom entries
for (Custom = gSettings.CustomTool; Custom; ++i, Custom = Custom->Next) {
if (OSFLAG_ISSET(Custom->Flags, OSFLAG_DISABLED)) {
for (size_t i = 0 ; i < gSettings.GUI.CustomTool.size(); ++i) {
CUSTOM_TOOL_ENTRY& Custom = gSettings.GUI.CustomTool[i];
if (OSFLAG_ISSET(Custom.Flags, OSFLAG_DISABLED)) {
DBG("Custom tool %llu skipped because it is disabled.\n", i);
continue;
}
// if (!gSettings.ShowHiddenEntries && OSFLAG_ISSET(Custom->Flags, OSFLAG_HIDDEN)) {
// if (!gSettings.ShowHiddenEntries && OSFLAG_ISSET(Custom.Flags, OSFLAG_HIDDEN)) {
// DBG("Custom tool %llu skipped because it is hidden.\n", i);
// continue;
// }
if (Custom->Volume.notEmpty()) {
DBG("Custom tool %llu matching \"%ls\" ...\n", i, Custom->Volume);
if (Custom.Volume.notEmpty()) {
DBG("Custom tool %llu matching \"%ls\" ...\n", i, Custom.Volume);
}
for (VolumeIndex = 0; VolumeIndex < Volumes.size(); ++VolumeIndex) {
Volume = &Volumes[VolumeIndex];
@ -278,8 +277,8 @@ void AddCustomTool(void)
continue;
}
if (Custom->VolumeType != 0) {
if (((1ull<<Volume->DiskKind) & Custom->VolumeType) == 0) {
if (Custom.VolumeType != 0) {
if (((1ull<<Volume->DiskKind) & Custom.VolumeType) == 0) {
DBG("skipped because media is ignored\n");
continue;
}
@ -291,28 +290,28 @@ void AddCustomTool(void)
}
// Check for exact volume matches
if (Custom->Volume.notEmpty()) {
if ((StrStr(Volume->DevicePathString.wc_str(), Custom->Volume.wc_str()) == NULL) &&
((Volume->VolName.isEmpty()) || (StrStr(Volume->VolName.wc_str(), Custom->Volume.wc_str()) == NULL))) {
if (Custom.Volume.notEmpty()) {
if ((StrStr(Volume->DevicePathString.wc_str(), Custom.Volume.wc_str()) == NULL) &&
((Volume->VolName.isEmpty()) || (StrStr(Volume->VolName.wc_str(), Custom.Volume.wc_str()) == NULL))) {
DBG("skipped\n");
continue;
}
}
// Check the tool exists on the volume
if (!FileExists(Volume->RootDir, Custom->Path)) {
if (!FileExists(Volume->RootDir, Custom.Path)) {
DBG("skipped because path does not exist\n");
continue;
}
// Change to custom image if needed
Image = Custom->Image;
if (Image.isEmpty() && Custom->ImagePath.notEmpty()) {
Image.LoadXImage(&ThemeX.getThemeDir(), Custom->ImagePath);
Image = Custom.Image;
if (Image.isEmpty() && Custom.ImagePath.notEmpty()) {
Image.LoadXImage(&ThemeX.getThemeDir(), Custom.ImagePath);
}
if (Image.isEmpty()) {
AddToolEntry(Custom->Path, Custom->FullTitle.wc_str(), Custom->Title.wc_str(), Volume, ThemeX.GetIcon(BUILTIN_ICON_TOOL_SHELL), Custom->Hotkey, Custom->LoadOptions);
AddToolEntry(Custom.Path, Custom.FullTitle.wc_str(), Custom.Title.wc_str(), Volume, ThemeX.GetIcon(BUILTIN_ICON_TOOL_SHELL), Custom.Hotkey, Custom.LoadOptions);
} else {
// Create a legacy entry for this volume
AddToolEntry(Custom->Path, Custom->FullTitle.wc_str(), Custom->Title.wc_str(), Volume, Image, Custom->Hotkey, Custom->LoadOptions);
AddToolEntry(Custom.Path, Custom.FullTitle.wc_str(), Custom.Title.wc_str(), Volume, Image, Custom.Hotkey, Custom.LoadOptions);
}
DBG("match!\n");
// break; // break scan volumes, continue scan entries -- why?

View File

@ -723,7 +723,7 @@ EFI_STATUS REFIT_MENU_SCREEN::WaitForInputEventPoll(UINTN TimeoutDefault)
break;
}
UpdateFilm();
if (gSettings.PlayAsync) {
if (gSettings.GUI.PlayAsync) {
CheckSyncSound(false);
}
TimeoutRemain--;

View File

@ -19,6 +19,7 @@
#endif
EFI_GRAPHICS_OUTPUT_BLT_PIXEL NullColor = {0,0,0,0};
XImage NullXImage;
XImage::XImage(UINTN W, UINTN H) : Width(0), Height(0), PixelData() // initialisation of Width and Height and , PixelData() to avoid warning with -Weffc++

View File

@ -112,6 +112,8 @@ protected:
};
extern XImage NullXImage;
class IndexedImage
{
public:

View File

@ -42,7 +42,7 @@ EFI_STATUS XPointer::MouseBirth()
{
EFI_STATUS Status = EFI_UNSUPPORTED;
if (!gSettings.PointerEnabled) {
if (!gSettings.GUI.Mouse.PointerEnabled) {
return EFI_SUCCESS;
}
@ -68,7 +68,7 @@ EFI_STATUS XPointer::MouseBirth()
}
MouseEvent = NoEvents;
SimplePointerProtocol = NULL;
gSettings.PointerEnabled = FALSE;
gSettings.GUI.Mouse.PointerEnabled = FALSE;
return Status;
}
@ -145,7 +145,7 @@ void XPointer::UpdatePointer(bool isDaylight) // cannot be called daylight becau
MouseEvent = RightMouseDown;
else if (State.LeftButton && !tmpState.LeftButton) { //release left
// time for double click 500ms into menu
if (TimeDiff(LastClickTime, Now) < gSettings.DoubleClickTime)
if (TimeDiff(LastClickTime, Now) < gSettings.GUI.Mouse.DoubleClickTime)
MouseEvent = DoubleClick;
else
MouseEvent = LeftClick;
@ -165,8 +165,8 @@ void XPointer::UpdatePointer(bool isDaylight) // cannot be called daylight becau
CopyMem(&State, &tmpState, sizeof(State));
CurrentMode = SimplePointerProtocol->Mode;
ScreenRelX = (UGAWidth * State.RelativeMovementX * gSettings.PointerSpeed / (INTN)CurrentMode->ResolutionX) >> 10;
if (gSettings.PointerMirror) {
ScreenRelX = (UGAWidth * State.RelativeMovementX * gSettings.GUI.Mouse.PointerSpeed / (INTN)CurrentMode->ResolutionX) >> 10;
if (gSettings.GUI.Mouse.PointerMirror) {
newPlace.XPos -= ScreenRelX;
}
else {
@ -176,7 +176,7 @@ void XPointer::UpdatePointer(bool isDaylight) // cannot be called daylight becau
if (newPlace.XPos > UGAWidth - 1) newPlace.XPos = UGAWidth - 1;
// YPosPrev = newPlace.YPos;
ScreenRelY = (UGAHeight * State.RelativeMovementY * gSettings.PointerSpeed / (INTN)CurrentMode->ResolutionY) >> 10;
ScreenRelY = (UGAHeight * State.RelativeMovementY * gSettings.GUI.Mouse.PointerSpeed / (INTN)CurrentMode->ResolutionY) >> 10;
newPlace.YPos += ScreenRelY;
if (newPlace.YPos < 0) newPlace.YPos = 0;
if (newPlace.YPos > UGAHeight - 1) newPlace.YPos = UGAHeight - 1;

View File

@ -94,7 +94,7 @@ void XTheme::LoadFontImage(IN BOOLEAN UseEmbedded, IN INTN Rows, IN INTN Cols)
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *PixelPtr;
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *FontPtr;
EFI_GRAPHICS_OUTPUT_BLT_PIXEL FirstPixel;
BOOLEAN isKorean = (gLanguage == korean);
BOOLEAN isKorean = (gSettings.GUI.gLanguage == korean);
XStringW fontFilePath;
const XStringW& commonFontDir = L"font"_XSW;
@ -108,7 +108,7 @@ void XTheme::LoadFontImage(IN BOOLEAN UseEmbedded, IN INTN Rows, IN INTN Cols)
CharWidth = 22; //standard for korean
} else {
MsgLog("...using english\n");
gLanguage = english;
gSettings.GUI.gLanguage = english;
}
}
@ -308,7 +308,7 @@ INTN XTheme::RenderText(IN const XStringW& Text, OUT XImage* CompImage_ptr,
for (UINTN i = 0; i < TextLength && c0 != 0; i++) {
UINT16 c = Text.wc_str()[i]; //including UTF8 -> UTF16 conversion
DBG("initial char to render 0x%hx\n", c); //good
if (gLanguage != korean) { //russian Codepage = 0x410
if (gSettings.GUI.gLanguage != korean) { //russian Codepage = 0x410
if (c >= 0x410 && c < 0x450) {
//we have russian raster fonts with chars at 0xC0
c -= 0x350;

View File

@ -305,6 +305,7 @@
cpp_foundation/XToolsCommon.h
# cpp_foundation/XUINTN.cpp
# cpp_foundation/XUINTN.h
cpp_lib/undefinable.h
cpp_unit_test/all_tests.h
cpp_unit_test/all_tests.cpp
# cpp_unit_test/config-test.h

View File

@ -998,9 +998,9 @@ void ScanVolumes(void)
Status = ScanVolume(Volume);
if (!EFI_ERROR(Status)) {
Volumes.AddReference(Volume, false);
for (size_t HVi = 0; HVi < gSettings.HVHideStrings.size(); HVi++) {
if ( Volume->DevicePathString.containsIC(gSettings.HVHideStrings[HVi]) ||
Volume->VolName.containsIC(gSettings.HVHideStrings[HVi])
for (size_t HVi = 0; HVi < gSettings.GUI.HVHideStrings.size(); HVi++) {
if ( Volume->DevicePathString.containsIC(gSettings.GUI.HVHideStrings[HVi]) ||
Volume->VolName.containsIC(gSettings.GUI.HVHideStrings[HVi])
) {
Volume->Hidden = TRUE;
DBG(" hiding this volume\n");

View File

@ -1127,7 +1127,7 @@ void LOADER_ENTRY::StartLoader()
#ifndef USE_OC_SECTION_PlatformInfo
mOpenCoreConfiguration.Kernel.Quirks.CustomSmbiosGuid = gSettings.KernelAndKextPatches.KPDELLSMBIOS;
#endif
mOpenCoreConfiguration.Uefi.Output.ProvideConsoleGop = gSettings.ProvideConsoleGop;
mOpenCoreConfiguration.Uefi.Output.ProvideConsoleGop = gSettings.GUI.ProvideConsoleGop;
OC_STRING_ASSIGN(mOpenCoreConfiguration.Uefi.Output.Resolution, XString8(gSettings.GUI.ScreenResolution).c_str());
@ -2626,6 +2626,7 @@ void afterGetUserSettings(const SETTINGS_DATA& gSettings)
}
}
ThemeX.DarkEmbedded = gSettings.GUI.DarkEmbedded;
}
#pragma GCC diagnostic pop
@ -2843,9 +2844,9 @@ RefitMain (IN EFI_HANDLE ImageHandle,
!gConfigDict[1] ? L"": (ConfName.notEmpty() ? ConfName.wc_str() : L"Load Options"));
//gSettings.MainConfigName.takeValueFrom(gSettings.ConfigName);
gSettings.PointerEnabled = TRUE;
gSettings.PointerSpeed = 2;
gSettings.DoubleClickTime = 500; //TODO - make it constant as nobody change it
gSettings.GUI.Mouse.PointerEnabled = TRUE;
gSettings.GUI.Mouse.PointerSpeed = 2;
gSettings.GUI.Mouse.DoubleClickTime = 500; //TODO - make it constant as nobody change it
#ifdef ENABLE_SECURE_BOOT
InitializeSecureBoot();
@ -3204,9 +3205,9 @@ RefitMain (IN EFI_HANDLE ImageHandle,
FillInputs(TRUE);
// scan for loaders and tools, add then to the menu
if (gSettings.GUI.LegacyFirst){
if (gSettings.GUI.Scan.LegacyFirst){
AddCustomLegacy();
if (!gSettings.GUI.NoLegacy) {
if (!gSettings.GUI.Scan.NoLegacy) {
ScanLegacy();
}
}
@ -3215,16 +3216,16 @@ RefitMain (IN EFI_HANDLE ImageHandle,
// Add custom entries
AddCustomEntries();
if (gSettings.DisableEntryScan) {
if (gSettings.GUI.Scan.DisableEntryScan) {
DBG("Entry scan disabled\n");
} else {
ScanLoader();
}
if (!GlobalConfig.isFastBoot()) {
if (!gSettings.GUI.LegacyFirst) {
if (!gSettings.GUI.Scan.LegacyFirst) {
AddCustomLegacy();
if (!gSettings.GUI.NoLegacy) {
if (!gSettings.GUI.Scan.NoLegacy) {
ScanLegacy();
}
}
@ -3232,7 +3233,7 @@ RefitMain (IN EFI_HANDLE ImageHandle,
// fixed other menu entries
if (!(ThemeX.HideUIFlags & HIDEUI_FLAG_TOOLS)) {
AddCustomTool();
if (!gSettings.DisableToolScan) {
if (!gSettings.GUI.Scan.DisableToolScan) {
ScanTool();
#ifdef ENABLE_SECURE_BOOT
// Check for secure boot setup mode

View File

@ -317,11 +317,11 @@ void FillInputs(BOOLEAN New)
InputItems[InputItemsCount++].IValue = gSettings.FlagsBits;
InputItems[InputItemsCount].ItemType = Decimal; //70
InputItems[InputItemsCount++].SValue.SWPrintf("%02lld", gSettings.PointerSpeed);
InputItems[InputItemsCount++].SValue.SWPrintf("%02lld", gSettings.GUI.Mouse.PointerSpeed);
InputItems[InputItemsCount].ItemType = Decimal; //71
InputItems[InputItemsCount++].SValue.SWPrintf("%04llu", gSettings.DoubleClickTime);
InputItems[InputItemsCount++].SValue.SWPrintf("%04llu", gSettings.GUI.Mouse.DoubleClickTime);
InputItems[InputItemsCount].ItemType = BoolValue; //72
InputItems[InputItemsCount++].BValue = gSettings.PointerMirror;
InputItems[InputItemsCount++].BValue = gSettings.GUI.Mouse.PointerMirror;
//reserve for mouse and continue
@ -443,7 +443,7 @@ void FillInputs(BOOLEAN New)
InputItems[InputItemsCount].ItemType = Decimal; //122
InputItems[InputItemsCount++].SValue.SWPrintf("%04lld", gSettings.MaxSlide);
InputItems[InputItemsCount].ItemType = BoolValue; //123
InputItems[InputItemsCount++].BValue = gSettings.ProvideConsoleGop;
InputItems[InputItemsCount++].BValue = gSettings.GUI.ProvideConsoleGop;
@ -762,20 +762,20 @@ void ApplyInputs(void)
if (InputItems[i].SValue[0] == '-') {
Minus = 1;
}
gSettings.PointerSpeed = StrDecimalToUintn(InputItems[i].SValue.data(Minus));
gSettings.GUI.Mouse.PointerSpeed = StrDecimalToUintn(InputItems[i].SValue.data(Minus));
if (Minus) {
gSettings.PointerSpeed = -gSettings.PointerSpeed;
gSettings.GUI.Mouse.PointerSpeed = -gSettings.GUI.Mouse.PointerSpeed;
}
// DBG("Pointer Speed=%d\n", gSettings.PointerSpeed);
}
i++; //71
if (InputItems[i].Valid) {
gSettings.DoubleClickTime = StrDecimalToUintn(InputItems[i].SValue.wc_str());
gSettings.GUI.Mouse.DoubleClickTime = StrDecimalToUintn(InputItems[i].SValue.wc_str());
// DBG("DoubleClickTime=%d ms\n", gSettings.DoubleClickTime);
}
i++; //72
if (InputItems[i].Valid) {
gSettings.PointerMirror = InputItems[i].BValue;
gSettings.GUI.Mouse.PointerMirror = InputItems[i].BValue;
}
@ -1068,8 +1068,8 @@ void ApplyInputs(void)
}
i++; //123
if (InputItems[i].Valid) {
gSettings.ProvideConsoleGop = InputItems[i].BValue;
DBG("applied ConsoleGopEnable=%s\n", gSettings.ProvideConsoleGop ? "Y" : "N" );
gSettings.GUI.ProvideConsoleGop = InputItems[i].BValue;
DBG("applied ConsoleGopEnable=%s\n", gSettings.GUI.ProvideConsoleGop ? "Y" : "N" );
}
@ -1145,7 +1145,7 @@ void HelpRefit(void)
//else {
// HelpMenu.TitleImage.setEmpty();
//}
switch (gLanguage)
switch (gSettings.GUI.gLanguage)
{
case russian:
HelpMenu.AddMenuInfo_f("ESC - Выход из подменю, обновление главного меню");