VOID OptionMenuCustomBootPartition(VOID) { ULONG_PTR SectionId; CHAR SectionName[100]; CHAR BootDriveString[20]; CHAR BootPartitionString[20]; TIMEINFO* TimeInfo; OperatingSystemItem OperatingSystem; RtlZeroMemory(SectionName, sizeof(SectionName)); RtlZeroMemory(BootDriveString, sizeof(BootDriveString)); RtlZeroMemory(BootPartitionString, sizeof(BootPartitionString)); if (!UiEditBox(BootDrivePrompt, BootDriveString, 20)) { return; } if (!UiEditBox(BootPartitionPrompt, BootPartitionString, 20)) { return; } // Generate a unique section name TimeInfo = ArcGetTime(); sprintf(SectionName, "CustomBootPartition%u%u%u%u%u%u", TimeInfo->Year, TimeInfo->Day, TimeInfo->Month, TimeInfo->Hour, TimeInfo->Minute, TimeInfo->Second); // Add the section if (!IniAddSection(SectionName, &SectionId)) { return; } // Add the BootType if (!IniAddSettingValueToSection(SectionId, "BootType", "Partition")) { return; } // Add the BootDrive if (!IniAddSettingValueToSection(SectionId, "BootDrive", BootDriveString)) { return; } // Add the BootPartition if (!IniAddSettingValueToSection(SectionId, "BootPartition", BootPartitionString)) { return; } UiMessageBox(CustomBootPrompt); OperatingSystem.SystemPartition = SectionName; OperatingSystem.LoadIdentifier = NULL; OperatingSystem.OsLoadOptions = NULL; // LoadAndBootPartition(&OperatingSystem, 0); LoadOperatingSystem(&OperatingSystem); }
ULONG ArcGetRelativeTime(VOID) { TIMEINFO* TimeInfo; ULONG ret; TimeInfo = ArcGetTime(); ret = ((TimeInfo->Hour * 24) + TimeInfo->Minute) * 60 + TimeInfo->Second; return ret; }
BOOLEAN UiDisplayMenu(IN PCSTR MenuHeader, IN PCSTR MenuFooter, IN BOOLEAN ShowBootOptions, IN PCSTR MenuItemList[], IN ULONG MenuItemCount, IN ULONG DefaultMenuItem, IN LONG MenuTimeOut, OUT PULONG SelectedMenuItem, IN BOOLEAN CanEscape, IN UiMenuKeyPressFilterCallback KeyPressFilter) { UI_MENU_INFO MenuInformation; ULONG LastClockSecond; ULONG CurrentClockSecond; ULONG KeyPress; /* Check if there's no timeout */ if (!MenuTimeOut) { /* Return the default selected item */ if (SelectedMenuItem) *SelectedMenuItem = DefaultMenuItem; return TRUE; } /* Setup the MENU_INFO structure */ MenuInformation.MenuHeader = MenuHeader; MenuInformation.MenuFooter = MenuFooter; MenuInformation.ShowBootOptions = ShowBootOptions; MenuInformation.MenuItemList = MenuItemList; MenuInformation.MenuItemCount = MenuItemCount; MenuInformation.MenuTimeRemaining = MenuTimeOut; MenuInformation.SelectedMenuItem = DefaultMenuItem; /* Calculate the size of the menu box */ UiCalcMenuBoxSize(&MenuInformation); /* Draw the menu */ UiDrawMenu(&MenuInformation); /* Get the current second of time */ LastClockSecond = ArcGetTime()->Second; /* Process keys */ while (TRUE) { /* Process key presses */ KeyPress = UiProcessMenuKeyboardEvent(&MenuInformation, KeyPressFilter); /* Check for ENTER or ESC */ if (KeyPress == KEY_ENTER) break; if (CanEscape && KeyPress == KEY_ESC) return FALSE; /* Check if there is a countdown */ if (MenuInformation.MenuTimeRemaining > 0) { /* Get the updated time, seconds only */ CurrentClockSecond = ArcGetTime()->Second; /* Check if more then a second has now elapsed */ if (CurrentClockSecond != LastClockSecond) { /* Update the time information */ LastClockSecond = CurrentClockSecond; MenuInformation.MenuTimeRemaining--; /* Update the menu */ UiDrawMenuBox(&MenuInformation); } } else if (MenuInformation.MenuTimeRemaining == 0) { /* A time out occurred, exit this loop and return default OS */ break; } } /* Return the selected item */ if (SelectedMenuItem) *SelectedMenuItem = MenuInformation.SelectedMenuItem; return TRUE; }
BOOLEAN TuiDisplayMenu(PCSTR MenuHeader, PCSTR MenuFooter, BOOLEAN ShowBootOptions, PCSTR MenuItemList[], ULONG MenuItemCount, ULONG DefaultMenuItem, LONG MenuTimeOut, ULONG* SelectedMenuItem, BOOLEAN CanEscape, UiMenuKeyPressFilterCallback KeyPressFilter) { UI_MENU_INFO MenuInformation; ULONG LastClockSecond; ULONG CurrentClockSecond; ULONG KeyPress; // // Check if there's no timeout if (!MenuTimeOut) { // // Return the default selected item // if (SelectedMenuItem) *SelectedMenuItem = DefaultMenuItem; return TRUE; } // // Setup the MENU_INFO structure // MenuInformation.MenuHeader = MenuHeader; MenuInformation.MenuFooter = MenuFooter; MenuInformation.ShowBootOptions = ShowBootOptions; MenuInformation.MenuItemList = MenuItemList; MenuInformation.MenuItemCount = MenuItemCount; MenuInformation.MenuTimeRemaining = MenuTimeOut; MenuInformation.SelectedMenuItem = DefaultMenuItem; // // Calculate the size of the menu box // TuiCalcMenuBoxSize(&MenuInformation); // // Draw the menu // UiVtbl.DrawMenu(&MenuInformation); // // Get the current second of time // LastClockSecond = ArcGetTime()->Second; // // Process keys // while (TRUE) { // // Process key presses // KeyPress = TuiProcessMenuKeyboardEvent(&MenuInformation, KeyPressFilter); // // Check for ENTER or ESC // if (KeyPress == KEY_ENTER) break; if (CanEscape && KeyPress == KEY_ESC) return FALSE; // // Update the date & time // TuiUpdateDateTime(); VideoCopyOffScreenBufferToVRAM(); // // Check if there is a countdown // if (MenuInformation.MenuTimeRemaining > 0) { // // Get the updated time, seconds only // CurrentClockSecond = ArcGetTime()->Second; // // Check if more then a second has now elapsed // if (CurrentClockSecond != LastClockSecond) { // // Update the time information // LastClockSecond = CurrentClockSecond; MenuInformation.MenuTimeRemaining--; // // Update the menu // TuiDrawMenuBox(&MenuInformation); VideoCopyOffScreenBufferToVRAM(); } } else if (MenuInformation.MenuTimeRemaining == 0) { // // A time out occurred, exit this loop and return default OS // break; } MachHwIdle(); } // // Return the selected item // if (SelectedMenuItem) *SelectedMenuItem = MenuInformation.SelectedMenuItem; return TRUE; }
VOID OptionMenuCustomBootReactOS(VOID) { ULONG_PTR SectionId; CHAR SectionName[100]; CHAR BootDriveString[20]; CHAR BootPartitionString[20]; CHAR ReactOSSystemPath[200]; CHAR ReactOSARCPath[200]; CHAR ReactOSOptions[200]; TIMEINFO* TimeInfo; OperatingSystemItem OperatingSystem; RtlZeroMemory(SectionName, sizeof(SectionName)); RtlZeroMemory(BootDriveString, sizeof(BootDriveString)); RtlZeroMemory(BootPartitionString, sizeof(BootPartitionString)); RtlZeroMemory(ReactOSSystemPath, sizeof(ReactOSSystemPath)); RtlZeroMemory(ReactOSOptions, sizeof(ReactOSOptions)); if (!UiEditBox(BootDrivePrompt, BootDriveString, 20)) return; if (!UiEditBox(BootPartitionPrompt, BootPartitionString, 20)) return; if (!UiEditBox(ReactOSSystemPathPrompt, ReactOSSystemPath, 200)) return; if (!UiEditBox(ReactOSOptionsPrompt, ReactOSOptions, 200)) return; /* Generate a unique section name */ TimeInfo = ArcGetTime(); sprintf(SectionName, "CustomReactOS%u%u%u%u%u%u", TimeInfo->Year, TimeInfo->Day, TimeInfo->Month, TimeInfo->Hour, TimeInfo->Minute, TimeInfo->Second); /* Add the section */ if (!IniAddSection(SectionName, &SectionId)) return; /* Add the BootType */ if (!IniAddSettingValueToSection(SectionId, "BootType", "Windows2003")) return; /* Construct the ReactOS ARC system path */ ConstructArcPath(ReactOSARCPath, ReactOSSystemPath, DriveMapGetBiosDriveNumber(BootDriveString), atoi(BootPartitionString)); /* Add the system path */ if (!IniAddSettingValueToSection(SectionId, "SystemPath", ReactOSARCPath)) return; /* Add the CommandLine */ if (!IniAddSettingValueToSection(SectionId, "Options", ReactOSOptions)) return; UiMessageBox(CustomBootPrompt); OperatingSystem.SystemPartition = SectionName; OperatingSystem.LoadIdentifier = NULL; OperatingSystem.OsLoadOptions = NULL; // ReactOSOptions // LoadAndBootWindows(&OperatingSystem, _WIN32_WINNT_WS03); LoadOperatingSystem(&OperatingSystem); }
VOID OptionMenuCustomBootLinux(VOID) { ULONG_PTR SectionId; CHAR SectionName[100]; CHAR BootDriveString[20]; CHAR BootPartitionString[20]; CHAR LinuxKernelString[200]; CHAR LinuxInitrdString[200]; CHAR LinuxCommandLineString[200]; TIMEINFO* TimeInfo; OperatingSystemItem OperatingSystem; RtlZeroMemory(SectionName, sizeof(SectionName)); RtlZeroMemory(BootDriveString, sizeof(BootDriveString)); RtlZeroMemory(BootPartitionString, sizeof(BootPartitionString)); RtlZeroMemory(LinuxKernelString, sizeof(LinuxKernelString)); RtlZeroMemory(LinuxInitrdString, sizeof(LinuxInitrdString)); RtlZeroMemory(LinuxCommandLineString, sizeof(LinuxCommandLineString)); if (!UiEditBox(BootDrivePrompt, BootDriveString, 20)) return; if (!UiEditBox(BootPartitionPrompt, BootPartitionString, 20)) return; if (!UiEditBox(LinuxKernelPrompt, LinuxKernelString, 200)) return; if (!UiEditBox(LinuxInitrdPrompt, LinuxInitrdString, 200)) return; if (!UiEditBox(LinuxCommandLinePrompt, LinuxCommandLineString, 200)) return; /* Generate a unique section name */ TimeInfo = ArcGetTime(); sprintf(SectionName, "CustomLinux%u%u%u%u%u%u", TimeInfo->Year, TimeInfo->Day, TimeInfo->Month, TimeInfo->Hour, TimeInfo->Minute, TimeInfo->Second); /* Add the section */ if (!IniAddSection(SectionName, &SectionId)) return; /* Add the BootType */ if (!IniAddSettingValueToSection(SectionId, "BootType", "Linux")) return; /* Add the BootDrive */ if (!IniAddSettingValueToSection(SectionId, "BootDrive", BootDriveString)) return; /* Add the BootPartition */ if (!IniAddSettingValueToSection(SectionId, "BootPartition", BootPartitionString)) return; /* Add the Kernel */ if (!IniAddSettingValueToSection(SectionId, "Kernel", LinuxKernelString)) return; /* Add the Initrd */ if (strlen(LinuxInitrdString) > 0) { if (!IniAddSettingValueToSection(SectionId, "Initrd", LinuxInitrdString)) return; } /* Add the CommandLine */ if (!IniAddSettingValueToSection(SectionId, "CommandLine", LinuxCommandLineString)) return; UiMessageBox(CustomBootPrompt); OperatingSystem.SystemPartition = SectionName; OperatingSystem.LoadIdentifier = "Custom Linux Setup"; OperatingSystem.OsLoadOptions = NULL; // LoadAndBootLinux(&OperatingSystem, 0); LoadOperatingSystem(&OperatingSystem); }
VOID TuiUpdateDateTime(VOID) { TIMEINFO* TimeInfo; char DateString[40]; CHAR TimeString[40]; CHAR TempString[20]; BOOLEAN PMHour = FALSE; /* Don't draw the time if this has been disabled */ if (!UiDrawTime) return; TimeInfo = ArcGetTime(); if (TimeInfo->Year < 1 || 9999 < TimeInfo->Year || TimeInfo->Month < 1 || 12 < TimeInfo->Month || TimeInfo->Day < 1 || 31 < TimeInfo->Day || 23 < TimeInfo->Hour || 59 < TimeInfo->Minute || 59 < TimeInfo->Second) { /* This happens on QEmu sometimes. We just skip updating */ return; } // Get the month name strcpy(DateString, UiMonthNames[TimeInfo->Month - 1]); // Get the day _itoa(TimeInfo->Day, TempString, 10); // Get the day postfix if (1 == TimeInfo->Day || 21 == TimeInfo->Day || 31 == TimeInfo->Day) { strcat(TempString, "st"); } else if (2 == TimeInfo->Day || 22 == TimeInfo->Day) { strcat(TempString, "nd"); } else if (3 == TimeInfo->Day || 23 == TimeInfo->Day) { strcat(TempString, "rd"); } else { strcat(TempString, "th"); } // Add the day to the date strcat(DateString, TempString); strcat(DateString, " "); // Get the year and add it to the date _itoa(TimeInfo->Year, TempString, 10); strcat(DateString, TempString); // Draw the date TuiDrawText(UiScreenWidth-strlen(DateString)-2, 1, DateString, ATTR(UiTitleBoxFgColor, UiTitleBoxBgColor)); // Get the hour and change from 24-hour mode to 12-hour if (TimeInfo->Hour > 12) { TimeInfo->Hour -= 12; PMHour = TRUE; } if (TimeInfo->Hour == 0) { TimeInfo->Hour = 12; } _itoa(TimeInfo->Hour, TempString, 10); strcpy(TimeString, " "); strcat(TimeString, TempString); strcat(TimeString, ":"); _itoa(TimeInfo->Minute, TempString, 10); if (TimeInfo->Minute < 10) { strcat(TimeString, "0"); } strcat(TimeString, TempString); strcat(TimeString, ":"); _itoa(TimeInfo->Second, TempString, 10); if (TimeInfo->Second < 10) { strcat(TimeString, "0"); } strcat(TimeString, TempString); if (PMHour) { strcat(TimeString, " PM"); } else { strcat(TimeString, " AM"); } // Draw the time TuiDrawText(UiScreenWidth-strlen(TimeString)-2, 2, TimeString, ATTR(UiTitleBoxFgColor, UiTitleBoxBgColor)); }