mirror of
https://github.com/CloverHackyColor/CloverBootloader.git
synced 2024-11-10 09:40:53 +01:00
refactor ThemesList as XStringWArray and rename to ThemeNameArray.
This commit is contained in:
parent
e7d14cc70e
commit
da29292e22
@ -95,8 +95,7 @@ UINT8 *gLanMmio[4]; // their MMIO regions
|
||||
UINT8 gLanMac[4][6]; // their MAC addresses
|
||||
UINTN nLanPaths; // number of LAN pathes
|
||||
|
||||
UINTN ThemesNum = 0;
|
||||
CONST CHAR16 *ThemesList[100]; //no more then 100 themes?
|
||||
XStringWArray ThemeNameArray;
|
||||
UINTN ConfigsNum;
|
||||
CHAR16 *ConfigsList[20];
|
||||
UINTN DsdtsNum = 0;
|
||||
@ -2416,9 +2415,9 @@ GetEarlyUserSettings (
|
||||
GlobalConfig.Theme.takeValueFrom(Prop->getString()->stringValue());
|
||||
DBG("Default theme: %ls\n", GlobalConfig.Theme.wc_str());
|
||||
OldChosenTheme = 0xFFFF; //default for embedded
|
||||
for (UINTN i = 0; i < ThemesNum; i++) {
|
||||
for (UINTN i = 0; i < ThemeNameArray.size(); i++) {
|
||||
//now comparison is case sensitive
|
||||
if (StriCmp(GlobalConfig.Theme.wc_str(), ThemesList[i]) == 0) {
|
||||
if ( GlobalConfig.Theme.equalIC(ThemeNameArray[i]) ) {
|
||||
OldChosenTheme = i;
|
||||
break;
|
||||
}
|
||||
@ -3159,7 +3158,7 @@ GetListOfThemes ()
|
||||
|
||||
DbgHeader("GetListOfThemes");
|
||||
|
||||
ThemesNum = 0;
|
||||
ThemeNameArray.setEmpty();
|
||||
DirIterOpen(SelfRootDir, L"\\EFI\\CLOVER\\themes", &DirIter);
|
||||
while (DirIterNext(&DirIter, 1, L"*", &DirEntry)) {
|
||||
if (DirEntry->FileName[0] == '.') {
|
||||
@ -3167,7 +3166,7 @@ GetListOfThemes ()
|
||||
continue;
|
||||
}
|
||||
//DBG("Found theme directory: %ls", DirEntry->FileName);
|
||||
DBG("- [%02llu]: %ls", ThemesNum, DirEntry->FileName);
|
||||
DBG("- [%02zuu]: %ls", ThemeNameArray.size(), DirEntry->FileName);
|
||||
ThemeTestPath = SWPrintf("EFI\\CLOVER\\themes\\%ls", DirEntry->FileName);
|
||||
Status = SelfRootDir->Open(SelfRootDir, &ThemeTestDir, ThemeTestPath.wc_str(), EFI_FILE_MODE_READ, 0);
|
||||
if (!EFI_ERROR(Status)) {
|
||||
@ -3185,7 +3184,7 @@ GetListOfThemes ()
|
||||
(StriCmp(DirEntry->FileName, L"random") == 0)) {
|
||||
ThemePtr = NULL;
|
||||
} else {
|
||||
ThemesList[ThemesNum++] = (CHAR16*)AllocateCopyPool(StrSize(DirEntry->FileName), DirEntry->FileName);
|
||||
ThemeNameArray.Add(DirEntry->FileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3688,12 +3687,12 @@ InitTheme(BOOLEAN UseThemeDefinedInNVRam)
|
||||
*/
|
||||
ThemeX.FontImage.setEmpty();
|
||||
|
||||
Rnd = (ThemesNum != 0) ? Now.Second % ThemesNum : 0;
|
||||
Rnd = (ThemeNameArray.size() != 0) ? Now.Second % ThemeNameArray.size() : 0;
|
||||
|
||||
// DBG("...done\n");
|
||||
ThemeX.GetThemeTagSettings(NULL);
|
||||
|
||||
if (ThemesNum > 0 &&
|
||||
if (ThemeNameArray.size() > 0 &&
|
||||
(GlobalConfig.Theme.isEmpty() || StriCmp(GlobalConfig.Theme.wc_str(), L"embedded") != 0)) {
|
||||
// Try special theme first
|
||||
XStringW TestTheme;
|
||||
@ -3725,7 +3724,7 @@ InitTheme(BOOLEAN UseThemeDefinedInNVRam)
|
||||
goto finish;
|
||||
}
|
||||
if (AsciiStrCmp(ChosenTheme, "random") == 0) {
|
||||
ThemeDict = ThemeX.LoadTheme(XStringW(ThemesList[Rnd]));
|
||||
ThemeDict = ThemeX.LoadTheme(XStringW(ThemeNameArray[Rnd]));
|
||||
goto finish;
|
||||
}
|
||||
|
||||
@ -3752,11 +3751,11 @@ InitTheme(BOOLEAN UseThemeDefinedInNVRam)
|
||||
// Try to get theme from settings
|
||||
if (ThemeDict == NULL) {
|
||||
if (GlobalConfig.Theme.isEmpty()) {
|
||||
DBG("no default theme, get random theme %ls\n", ThemesList[Rnd]);
|
||||
ThemeDict = ThemeX.LoadTheme(XStringW(ThemesList[Rnd]));
|
||||
DBG("no default theme, get random theme %ls\n", ThemeNameArray[Rnd].wc_str());
|
||||
ThemeDict = ThemeX.LoadTheme(XStringW(ThemeNameArray[Rnd]));
|
||||
} else {
|
||||
if (StriCmp(GlobalConfig.Theme.wc_str(), L"random") == 0) {
|
||||
ThemeDict = ThemeX.LoadTheme(XStringW(ThemesList[Rnd]));
|
||||
ThemeDict = ThemeX.LoadTheme(XStringW(ThemeNameArray[Rnd]));
|
||||
} else {
|
||||
ThemeDict = ThemeX.LoadTheme(GlobalConfig.Theme);
|
||||
if (ThemeDict == NULL) {
|
||||
@ -3818,8 +3817,8 @@ finish:
|
||||
}
|
||||
|
||||
}
|
||||
for (i = 0; i < ThemesNum; i++) {
|
||||
if ( ThemeX.Theme.equalIC(ThemesList[i]) ) {
|
||||
for (i = 0; i < ThemeNameArray.size(); i++) {
|
||||
if ( ThemeX.Theme.equalIC(ThemeNameArray[i]) ) {
|
||||
OldChosenTheme = i;
|
||||
break;
|
||||
}
|
||||
|
@ -725,11 +725,10 @@ RT_VARIABLES() : Name(), VarGuid{0} {};
|
||||
extern XObjArray<RT_VARIABLES> BlockRtVariableArray;
|
||||
extern XObjArray<HDA_OUTPUTS> AudioList;
|
||||
|
||||
extern CONST CHAR16* ThemesList[100]; //no more then 100 themes?
|
||||
extern XStringWArray ThemeNameArray;
|
||||
extern CHAR16* ConfigsList[20];
|
||||
extern CHAR16* DsdtsList[20];
|
||||
extern UINTN DsdtsNum;
|
||||
extern UINTN ThemesNum;
|
||||
extern UINTN ConfigsNum;
|
||||
//extern INTN ScrollButtonsHeight;
|
||||
//extern INTN ScrollBarDecorationsHeight;
|
||||
|
@ -125,8 +125,6 @@ extern VOID HelpRefit(VOID);
|
||||
extern VOID AboutRefit(VOID);
|
||||
//extern BOOLEAN BooterPatch(IN UINT8 *BooterData, IN UINT64 BooterSize, LOADER_ENTRY *Entry);
|
||||
|
||||
extern UINTN ThemesNum;
|
||||
extern CONST CHAR16 *ThemesList[];
|
||||
extern UINTN ConfigsNum;
|
||||
extern CHAR16 *ConfigsList[];
|
||||
extern UINTN DsdtsNum;
|
||||
@ -612,12 +610,6 @@ VOID LOADER_ENTRY::StartLoader()
|
||||
}
|
||||
|
||||
//Free memory
|
||||
for (i = 0; i < ThemesNum; i++) {
|
||||
if (ThemesList[i]) {
|
||||
FreePool(ThemesList[i]);
|
||||
ThemesList[i] = NULL;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < ConfigsNum; i++) {
|
||||
if (ConfigsList[i]) {
|
||||
FreePool(ConfigsList[i]);
|
||||
|
@ -501,7 +501,7 @@ VOID ApplyInputs(VOID)
|
||||
if (OldChosenTheme == 0xFFFF) {
|
||||
GlobalConfig.Theme = L"embedded"_XSW;
|
||||
} else {
|
||||
GlobalConfig.Theme.takeValueFrom(ThemesList[OldChosenTheme]);
|
||||
GlobalConfig.Theme.takeValueFrom(ThemeNameArray[OldChosenTheme]);
|
||||
}
|
||||
|
||||
//will change theme after ESC
|
||||
@ -2356,9 +2356,9 @@ REFIT_ABSTRACT_MENU_ENTRY* SubMenuThemes()
|
||||
//add embedded
|
||||
SubScreen->AddMenuItemSwitch(3, "embedded", FALSE);
|
||||
|
||||
for (i = 0; i < ThemesNum; i++) {
|
||||
for (i = 0; i < ThemeNameArray.size(); i++) {
|
||||
InputBootArgs = new REFIT_MENU_SWITCH;
|
||||
InputBootArgs->Title.takeValueFrom(ThemesList[i]);
|
||||
InputBootArgs->Title.takeValueFrom(ThemeNameArray[i]);
|
||||
// InputBootArgs->Tag = TAG_SWITCH_OLD;
|
||||
InputBootArgs->Row = i + 1;
|
||||
InputBootArgs->Item = &InputItems[3];
|
||||
|
Loading…
Reference in New Issue
Block a user