diff --git a/xtldr2/includes/bootman.h b/xtldr2/includes/bootman.h index b1173d8..c08f963 100644 --- a/xtldr2/includes/bootman.h +++ b/xtldr2/includes/bootman.h @@ -216,6 +216,17 @@ BlpDissectVolumeArcPath(IN PCHAR SystemPath, OUT PULONG DriveNumber, OUT PULONG PartNumber); +XTCDECL +VOID +BlpDrawBootMenu(OUT PXTBL_DIALOG_HANDLE Handle); + +XTCDECL +VOID +BlpDrawBootMenuEntry(IN PXTBL_DIALOG_HANDLE Handle, + IN PWCHAR MenuEntry, + IN UINT Position, + IN BOOLEAN Highlighted); + XTCDECL VOID BlpDrawDialogBox(IN OUT PXTBL_DIALOG_HANDLE Handle, diff --git a/xtldr2/textui.c b/xtldr2/textui.c index 7fbf35d..a1aa660 100644 --- a/xtldr2/textui.c +++ b/xtldr2/textui.c @@ -308,6 +308,117 @@ BlpDetermineDialogBoxSize(IN OUT PXTBL_DIALOG_HANDLE Handle, Handle->Height = Height; } +/** + * Draws a text UI-based boot menu. + * + * @param Handle + * Supplies a pointer to the boot menu handle. + * + * @return This routine does not return any value. + * + * @since XT 1.0 + */ +XTCDECL +VOID +BlpDrawBootMenu(OUT PXTBL_DIALOG_HANDLE Handle) +{ + /* Query console screen resolution */ + BlQueryConsoleMode(&Handle->ResX, &Handle->ResY); + + /* Set boot menu parameters */ + Handle->Attributes = 0; + Handle->DialogColor = EFI_TEXT_BGCOLOR_BLACK; + Handle->TextColor = EFI_TEXT_FGCOLOR_LIGHTGRAY; + Handle->PosX = 3; + Handle->PosY = 3; + Handle->Width = Handle->ResX - 6; + Handle->Height = Handle->ResY - 10; + + /* Clear screen and disable cursor */ + BlSetConsoleAttributes(Handle->DialogColor | Handle->TextColor); + BlClearConsoleScreen(); + BlDisableConsoleCursor(); + + /* Check if debugging enabled */ + if(DEBUG) + { + /* Print debug version of XTLDR banner */ + BlSetCursorPosition((Handle->ResX - 44) / 2, 1); + BlConsolePrint(L"XTLDR Boot Loader v%d.%d (%s-%s)\n", + XTLDR_VERSION_MAJOR, XTLDR_VERSION_MINOR, XTOS_VERSION_DATE, XTOS_VERSION_HASH); + } + else + { + /* Print standard XTLDR banner */ + BlSetCursorPosition((Handle->ResX - 22) / 2, 1); + BlConsolePrint(L"XTLDR Boot Loader v%d.%d\n", XTLDR_VERSION_MAJOR, XTLDR_VERSION_MINOR); + } + + /* Draw empty dialog box for boot menu */ + BlpDrawDialogBox(Handle, NULL, NULL); + + /* Print help message below the boot menu */ + BlSetCursorPosition(0, Handle->PosY + Handle->Height); + BlSetConsoleAttributes(EFI_TEXT_BGCOLOR_BLACK | EFI_TEXT_FGCOLOR_LIGHTGRAY); + BlConsolePrint(L" Use cursors to change the selection. Press ENTER key to boot the chosen\n" + " Operating System, 'e' to edit it before booting or 's' for XTLDR shell.\n" + " Additional help available after pressing F1 key."); +} + +/** + * Draws boot menu entry at the specified position. + * + * @param Handle + * Supplies a pointer to the boot menu handle. + * + * @param MenuEntry + * Supplies a pointer to the buffer containing a menu entry name. + * + * @param Position + * Specifies entry position on the list in the boot menu. + * + * @param Highlighted + * Specifies whether this entry should be highlighted or not. + * + * @return This routine does not return any value. + * + * @since XT 1.0 + */ +XTCDECL +VOID +BlpDrawBootMenuEntry(IN PXTBL_DIALOG_HANDLE Handle, + IN PWCHAR MenuEntry, + IN UINT Position, + IN BOOLEAN Highlighted) +{ + UINT Index; + + /* Check whether this entry should be highlighted */ + if(Highlighted) + { + /* Highlight this entry */ + BlSetConsoleAttributes(EFI_TEXT_BGCOLOR_LIGHTGRAY | EFI_TEXT_FGCOLOR_BLACK); + } + else + { + /* Set default colors */ + BlSetConsoleAttributes(EFI_TEXT_BGCOLOR_BLACK | EFI_TEXT_FGCOLOR_LIGHTGRAY); + } + + /* Move cursor to the right position */ + BlSetCursorPosition(5, 4 + Position); + + /* Clear menu entry */ + for(Index = 0; Index < Handle->Width - 4; Index++) + { + BlConsolePrint(L" "); + } + + /* Print menu entry */ + BlSetCursorPosition(5, 4 + Position); + BlConsolePrint(L"%S\n", MenuEntry); +} + /** * Draws dialog box with caption and message. *