#pragma once
-extern ULONG UiScreenWidth; // Screen Width
-extern ULONG UiScreenHeight; // Screen Height
-
-extern UCHAR UiStatusBarFgColor; // Status bar foreground color
-extern UCHAR UiStatusBarBgColor; // Status bar background color
-extern UCHAR UiBackdropFgColor; // Backdrop foreground color
-extern UCHAR UiBackdropBgColor; // Backdrop background color
-extern UCHAR UiBackdropFillStyle; // Backdrop fill style
-extern UCHAR UiTitleBoxFgColor; // Title box foreground color
-extern UCHAR UiTitleBoxBgColor; // Title box background color
-extern UCHAR UiMessageBoxFgColor; // Message box foreground color
-extern UCHAR UiMessageBoxBgColor; // Message box background color
-extern UCHAR UiMenuFgColor; // Menu foreground color
-extern UCHAR UiMenuBgColor; // Menu background color
-extern UCHAR UiTextColor; // Normal text color
-extern UCHAR UiSelectedTextColor; // Selected text color
-extern UCHAR UiSelectedTextBgColor; // Selected text background color
-extern UCHAR UiEditBoxTextColor; // Edit box text color
-extern UCHAR UiEditBoxBgColor; // Edit box text background color
-
-extern CHAR UiTitleBoxTitleText[260]; // Title box's title text
-
-extern BOOLEAN UiUseSpecialEffects; // Tells us if we should use fade effects
-extern BOOLEAN UiCenterMenu;
-extern BOOLEAN UiMenuBox;
-extern CHAR UiTimeText[];
-extern BOOLEAN UiDrawTime;
+extern ULONG UiScreenWidth; // Screen Width
+extern ULONG UiScreenHeight; // Screen Height
+
+extern UCHAR UiStatusBarFgColor; // Status bar foreground color
+extern UCHAR UiStatusBarBgColor; // Status bar background color
+extern UCHAR UiBackdropFgColor; // Backdrop foreground color
+extern UCHAR UiBackdropBgColor; // Backdrop background color
+extern UCHAR UiBackdropFillStyle; // Backdrop fill style
+extern UCHAR UiTitleBoxFgColor; // Title box foreground color
+extern UCHAR UiTitleBoxBgColor; // Title box background color
+extern UCHAR UiMessageBoxFgColor; // Message box foreground color
+extern UCHAR UiMessageBoxBgColor; // Message box background color
+extern UCHAR UiMenuFgColor; // Menu foreground color
+extern UCHAR UiMenuBgColor; // Menu background color
+extern UCHAR UiTextColor; // Normal text color
+extern UCHAR UiSelectedTextColor; // Selected text color
+extern UCHAR UiSelectedTextBgColor; // Selected text background color
+extern UCHAR UiEditBoxTextColor; // Edit box text color
+extern UCHAR UiEditBoxBgColor; // Edit box text background color
+
+extern BOOLEAN UiShowTime; // Whether to draw the time
+extern BOOLEAN UiMenuBox; // Whether to draw a box around the menu
+extern BOOLEAN UiCenterMenu; // Whether to use a centered or left-aligned menu
+extern BOOLEAN UiUseSpecialEffects; // Whether to use fade effects
+
+extern CHAR UiTitleBoxTitleText[260]; // Title box's title text
+extern CHAR UiTimeText[260];
extern const PCSTR UiMonthNames[12];
return FALSE;
}
+ /* Load default settings with "Full" TUI Theme */
+
+ UiStatusBarFgColor = COLOR_BLACK;
+ UiStatusBarBgColor = COLOR_CYAN;
+ UiBackdropFgColor = COLOR_WHITE;
+ UiBackdropBgColor = COLOR_BLUE;
+ UiBackdropFillStyle = MEDIUM_FILL;
+ UiTitleBoxFgColor = COLOR_WHITE;
+ UiTitleBoxBgColor = COLOR_RED;
+ UiMessageBoxFgColor = COLOR_WHITE;
+ UiMessageBoxBgColor = COLOR_BLUE;
+ UiMenuFgColor = COLOR_WHITE;
+ UiMenuBgColor = COLOR_BLUE;
+ UiTextColor = COLOR_YELLOW;
+ UiSelectedTextColor = COLOR_BLACK;
+ UiSelectedTextBgColor = COLOR_GRAY;
+ UiEditBoxTextColor = COLOR_WHITE;
+ UiEditBoxBgColor = COLOR_BLACK;
+
+ UiShowTime = TRUE;
+ UiMenuBox = TRUE;
+ UiCenterMenu = TRUE;
+ UiUseSpecialEffects = FALSE;
+
+ // TODO: Have a boolean to show/hide title box?
+ RtlStringCbCopyA(UiTitleBoxTitleText, sizeof(UiTitleBoxTitleText),
+ "Boot Menu");
+
+ RtlStringCbCopyA(UiTimeText, sizeof(UiTimeText),
+ "[Time Remaining: %d]");
+
return TRUE;
}
VOID TuiDrawBackdrop(VOID)
{
- //
- // Fill in the background (excluding title box & status bar)
- //
+ /* Fill in the background (excluding title box & status bar) */
TuiFillArea(0,
- TUI_TITLE_BOX_CHAR_HEIGHT,
- UiScreenWidth - 1,
- UiScreenHeight - 2,
- UiBackdropFillStyle,
- ATTR(UiBackdropFgColor, UiBackdropBgColor));
+ TUI_TITLE_BOX_CHAR_HEIGHT,
+ UiScreenWidth - 1,
+ UiScreenHeight - 2,
+ UiBackdropFillStyle,
+ ATTR(UiBackdropFgColor, UiBackdropBgColor));
- //
- // Draw the title box
- //
+ /* Draw the title box */
TuiDrawBox(0,
- 0,
- UiScreenWidth - 1,
- TUI_TITLE_BOX_CHAR_HEIGHT - 1,
- D_VERT,
- D_HORZ,
- TRUE,
- FALSE,
- ATTR(UiTitleBoxFgColor, UiTitleBoxBgColor));
-
- //
- // Draw version text
- //
+ 0,
+ UiScreenWidth - 1,
+ TUI_TITLE_BOX_CHAR_HEIGHT - 1,
+ D_VERT,
+ D_HORZ,
+ TRUE,
+ FALSE,
+ ATTR(UiTitleBoxFgColor, UiTitleBoxBgColor));
+
+ /* Draw version text */
TuiDrawText(2,
- 1,
- FrLdrVersionString,
- ATTR(UiTitleBoxFgColor, UiTitleBoxBgColor));
+ 1,
+ FrLdrVersionString,
+ ATTR(UiTitleBoxFgColor, UiTitleBoxBgColor));
- //
- // Draw copyright
- //
+ /* Draw copyright */
TuiDrawText(2,
- 2,
- BY_AUTHOR,
- ATTR(UiTitleBoxFgColor, UiTitleBoxBgColor));
+ 2,
+ BY_AUTHOR,
+ ATTR(UiTitleBoxFgColor, UiTitleBoxBgColor));
TuiDrawText(2,
- 3,
- AUTHOR_EMAIL,
- ATTR(UiTitleBoxFgColor, UiTitleBoxBgColor));
+ 3,
+ AUTHOR_EMAIL,
+ ATTR(UiTitleBoxFgColor, UiTitleBoxBgColor));
- //
- // Draw help text
- //
- TuiDrawText(UiScreenWidth - 16, 3, /*"F1 for Help"*/"F8 for Options", ATTR(UiTitleBoxFgColor, UiTitleBoxBgColor));
+ /* Draw help text */
+ TuiDrawText(UiScreenWidth - 16, 3,
+ /*"F1 for Help"*/ "F8 for Options",
+ ATTR(UiTitleBoxFgColor, UiTitleBoxBgColor));
- //
- // Draw title text
- //
+ /* Draw title text */
TuiDrawText((UiScreenWidth - (ULONG)strlen(UiTitleBoxTitleText)) / 2,
- 2,
- UiTitleBoxTitleText,
- ATTR(UiTitleBoxFgColor, UiTitleBoxBgColor));
+ 2,
+ UiTitleBoxTitleText,
+ ATTR(UiTitleBoxFgColor, UiTitleBoxBgColor));
- //
- // Update the date & time
- //
+ /* Update the date & time */
TuiUpdateDateTime();
-
VideoCopyOffScreenBufferToVRAM();
}
CHAR Buffer[40];
/* Don't draw the time if this has been disabled */
- if (!UiDrawTime) return;
+ if (!UiShowTime) return;
TimeInfo = ArcGetTime();
if (TimeInfo->Year < 1 || 9999 < TimeInfo->Year ||
if (_stricmp(ColorText, "Default") == 0)
return MachDefaultTextColor;
- for (i = 0; i < sizeof(Colors)/sizeof(Colors[0]); ++i)
+ for (i = 0; i < RTL_NUMBER_OF(Colors); ++i)
{
if (_stricmp(ColorText, Colors[i].ColorName) == 0)
return Colors[i].ColorValue;
UCHAR FillStyleValue;
} FillStyles[] =
{
+ {"None" , ' '},
{"Light" , LIGHT_FILL },
{"Medium", MEDIUM_FILL},
{"Dark" , DARK_FILL },
};
ULONG i;
- for (i = 0; i < sizeof(FillStyles)/sizeof(FillStyles[0]); ++i)
+ for (i = 0; i < RTL_NUMBER_OF(FillStyles); ++i)
{
if (_stricmp(FillStyleText, FillStyles[i].FillStyleName) == 0)
return FillStyles[i].FillStyleValue;
#ifndef _M_ARM
-#define TAG_UI_TEXT 'xTiU'
-
-ULONG UiScreenWidth; // Screen Width
-ULONG UiScreenHeight; // Screen Height
-
-UCHAR UiStatusBarFgColor = COLOR_BLACK; // Status bar foreground color
-UCHAR UiStatusBarBgColor = COLOR_CYAN; // Status bar background color
-UCHAR UiBackdropFgColor = COLOR_WHITE; // Backdrop foreground color
-UCHAR UiBackdropBgColor = COLOR_BLUE; // Backdrop background color
-UCHAR UiBackdropFillStyle = MEDIUM_FILL; // Backdrop fill style
-UCHAR UiTitleBoxFgColor = COLOR_WHITE; // Title box foreground color
-UCHAR UiTitleBoxBgColor = COLOR_RED; // Title box background color
-UCHAR UiMessageBoxFgColor = COLOR_WHITE; // Message box foreground color
-UCHAR UiMessageBoxBgColor = COLOR_BLUE; // Message box background color
-UCHAR UiMenuFgColor = COLOR_WHITE; // Menu foreground color
-UCHAR UiMenuBgColor = COLOR_BLUE; // Menu background color
-UCHAR UiTextColor = COLOR_YELLOW; // Normal text color
-UCHAR UiSelectedTextColor = COLOR_BLACK; // Selected text color
-UCHAR UiSelectedTextBgColor = COLOR_GRAY; // Selected text background color
-UCHAR UiEditBoxTextColor = COLOR_WHITE; // Edit box text color
-UCHAR UiEditBoxBgColor = COLOR_BLACK; // Edit box text background color
+UCHAR UiStatusBarFgColor; // Status bar foreground color
+UCHAR UiStatusBarBgColor; // Status bar background color
+UCHAR UiBackdropFgColor; // Backdrop foreground color
+UCHAR UiBackdropBgColor; // Backdrop background color
+UCHAR UiBackdropFillStyle; // Backdrop fill style
+UCHAR UiTitleBoxFgColor; // Title box foreground color
+UCHAR UiTitleBoxBgColor; // Title box background color
+UCHAR UiMessageBoxFgColor; // Message box foreground color
+UCHAR UiMessageBoxBgColor; // Message box background color
+UCHAR UiMenuFgColor; // Menu foreground color
+UCHAR UiMenuBgColor; // Menu background color
+UCHAR UiTextColor; // Normal text color
+UCHAR UiSelectedTextColor; // Selected text color
+UCHAR UiSelectedTextBgColor; // Selected text background color
+UCHAR UiEditBoxTextColor; // Edit box text color
+UCHAR UiEditBoxBgColor; // Edit box text background color
+
+BOOLEAN UiShowTime; // Whether to draw the time
+BOOLEAN UiMenuBox; // Whether to draw a box around the menu
+BOOLEAN UiCenterMenu; // Whether to use a centered or left-aligned menu
+BOOLEAN UiUseSpecialEffects; // Whether to use fade effects
CHAR UiTitleBoxTitleText[260] = "Boot Menu"; // Title box's title text
-
-BOOLEAN UiUseSpecialEffects = FALSE; // Tells us if we should use fade effects
-BOOLEAN UiDrawTime = TRUE; // Tells us if we should draw the time
-BOOLEAN UiCenterMenu = TRUE; // Tells us if we should use a centered or left-aligned menu
-BOOLEAN UiMenuBox = TRUE; // Tells us if we should draw a box around the menu
-CHAR UiTimeText[260] = "[Time Remaining: %d]";
+CHAR UiTimeText[260] = "[Time Remaining: %d]";
const PCSTR UiMonthNames[12] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" };
+#define TAG_UI_TEXT 'xTiU'
+
+ULONG UiScreenWidth; // Screen Width
+ULONG UiScreenHeight; // Screen Height
+
#endif // _M_ARM
/*
/* Select the UI */
if ((SectionId != 0) && IniReadSettingByName(SectionId, "MinimalUI", SettingText, sizeof(SettingText)))
{
- UiMinimal = (_stricmp(SettingText, "Yes") == 0 && strlen(SettingText) == 3);
+ UiMinimal = (_stricmp(SettingText, "Yes") == 0);
}
if (UiDisplayMode == VideoGraphicsMode)
else // if (UiDisplayMode == VideoTextMode)
UiVtbl = (UiMinimal ? MiniTuiVtbl : TuiVtbl);
+ /* Load the UI and initialize its default settings */
if (!UiVtbl.Initialize())
{
MachVideoSetDisplayMode(NULL, FALSE);
return FALSE;
}
- /* Load the settings */
+ /* Load the user UI settings */
if (SectionId != 0)
{
static const struct
{
PCSTR SettingName;
PVOID SettingVar;
+ SIZE_T SettingSize OPTIONAL; // Must be non-zero only for text buffers.
UCHAR SettingType; // 0: Text, 1: Yes/No, 2: Color, 3: Fill style
} Settings[] =
{
- {"TitleText", &UiTitleBoxTitleText, 0},
- {"TimeText" , &UiTimeText , 0},
-
- {"SpecialEffects", &UiUseSpecialEffects, 1},
- {"ShowTime" , &UiDrawTime , 1},
- {"MenuBox" , &UiMenuBox , 1},
- {"CenterMenu" , &UiCenterMenu , 1},
-
- {"BackdropColor" , &UiBackdropBgColor , 2},
- {"BackdropTextColor" , &UiBackdropFgColor , 2},
- {"StatusBarColor" , &UiStatusBarBgColor , 2},
- {"StatusBarTextColor" , &UiStatusBarFgColor , 2},
- {"TitleBoxColor" , &UiTitleBoxBgColor , 2},
- {"TitleBoxTextColor" , &UiTitleBoxFgColor , 2},
- {"MessageBoxColor" , &UiMessageBoxBgColor , 2},
- {"MessageBoxTextColor", &UiMessageBoxFgColor , 2},
- {"MenuColor" , &UiMenuBgColor , 2},
- {"MenuTextColor" , &UiMenuFgColor , 2},
- {"TextColor" , &UiTextColor , 2},
- {"SelectedColor" , &UiSelectedTextBgColor, 2},
- {"SelectedTextColor" , &UiSelectedTextColor , 2},
- {"EditBoxColor" , &UiEditBoxBgColor , 2},
- {"EditBoxTextColor" , &UiEditBoxTextColor , 2},
-
- {"BackdropFillStyle", &UiBackdropFillStyle, 3},
+ {"TitleText", &UiTitleBoxTitleText, sizeof(UiTitleBoxTitleText), 0},
+ {"TimeText" , &UiTimeText, sizeof(UiTimeText), 0},
+
+ {"ShowTime" , &UiShowTime , 0, 1},
+ {"MenuBox" , &UiMenuBox , 0, 1},
+ {"CenterMenu" , &UiCenterMenu , 0, 1},
+ {"SpecialEffects", &UiUseSpecialEffects, 0, 1},
+
+ {"BackdropColor" , &UiBackdropBgColor , 0, 2},
+ {"BackdropTextColor" , &UiBackdropFgColor , 0, 2},
+ {"StatusBarColor" , &UiStatusBarBgColor , 0, 2},
+ {"StatusBarTextColor" , &UiStatusBarFgColor , 0, 2},
+ {"TitleBoxColor" , &UiTitleBoxBgColor , 0, 2},
+ {"TitleBoxTextColor" , &UiTitleBoxFgColor , 0, 2},
+ {"MessageBoxColor" , &UiMessageBoxBgColor , 0, 2},
+ {"MessageBoxTextColor", &UiMessageBoxFgColor , 0, 2},
+ {"MenuColor" , &UiMenuBgColor , 0, 2},
+ {"MenuTextColor" , &UiMenuFgColor , 0, 2},
+ {"TextColor" , &UiTextColor , 0, 2},
+ {"SelectedColor" , &UiSelectedTextBgColor, 0, 2},
+ {"SelectedTextColor" , &UiSelectedTextColor , 0, 2},
+ {"EditBoxColor" , &UiEditBoxBgColor , 0, 2},
+ {"EditBoxTextColor" , &UiEditBoxTextColor , 0, 2},
+
+ {"BackdropFillStyle", &UiBackdropFillStyle, 0, 3},
};
ULONG i;
- for (i = 0; i < sizeof(Settings)/sizeof(Settings[0]); ++i)
+ for (i = 0; i < RTL_NUMBER_OF(Settings); ++i)
{
if (!IniReadSettingByName(SectionId, Settings[i].SettingName, SettingText, sizeof(SettingText)))
continue;
switch (Settings[i].SettingType)
{
case 0: // Text
- strcpy((PCHAR)Settings[i].SettingVar, SettingText);
+ RtlStringCbCopyA((PCHAR)Settings[i].SettingVar,
+ Settings[i].SettingSize, SettingText);
break;
case 1: // Yes/No
- *(PBOOLEAN)Settings[i].SettingVar = (_stricmp(SettingText, "Yes") == 0 && strlen(SettingText) == 3);
+ *(PBOOLEAN)Settings[i].SettingVar = (_stricmp(SettingText, "Yes") == 0);
break;
case 2: // Color
*(PUCHAR)Settings[i].SettingVar = UiTextToColor(SettingText);