EFI_STATUS SettingsMenuShow ( VOID ) { MENU_ENTRY *Entry; MENU_OPTION* Menu; // create menu Menu = MenuCreate(); Menu->Title = AsciiStrDup("Settings"); Menu->BackCallback = SettingsMenuBackCallback; // file explorer Entry = MenuCreateEntry(); Entry->Name = AsciiStrDup("Show File Explorer"); Entry->ShowToggle = TRUE; Entry->ToggleEnabled = SettingBoolGet("ui-show-file-explorer"); Entry->HideBootMessage = TRUE; Entry->Callback = ShowFileExplorerCallback; MenuAddEntry(Menu, Entry); MenuStackPush(Menu); return EFI_SUCCESS; }
menu_t *MenuCreateOptionSeed(const char *name, unsigned int *seed) { menu_t *menu = MenuCreate(name, MENU_TYPE_SET_OPTION_SEED); menu->u.option.uHook.seed = seed; menu->u.option.displayStyle = MENU_OPTION_DISPLAY_STYLE_INT; return menu; }
menu_t *MenuCreateVoidFunc( const char *name, void (*func)(void *), void *data) { menu_t *menu = MenuCreate(name, MENU_TYPE_VOID_FUNC); menu->u.option.uHook.voidFunc.func = func; menu->u.option.uHook.voidFunc.data = data; menu->u.option.displayStyle = MENU_OPTION_DISPLAY_STYLE_NONE; return menu; }
menu_t *MenuCreateOptionChangeControl( const char *name, input_device_e *device0, input_device_e *device1) { menu_t *menu = MenuCreate(name, MENU_TYPE_SET_OPTION_CHANGE_CONTROL); menu->u.option.uHook.changeControl.device0 = device0; menu->u.option.uHook.changeControl.device1 = device1; menu->u.option.displayStyle = MENU_OPTION_DISPLAY_STYLE_INT_TO_STR_FUNC; menu->u.option.uFunc.intToStr = InputDeviceStr; return menu; }
void WinMenuMenu(UltimateContext *TheWin,int x, int y) { int a; Menu *men,*wsmen; MenuItem *item; short useTitle = (TheScreen.desktop.flags & UDESubMenuTitles); if(!(men = TheWin->title.name ? MenuCreate(TheWin->title.name) : MenuCreate(NULL))) { SeeYa(1,"FATAL: out of memory!"); } if(TheScreen.desktop.WorkSpaces > 1) { AppendMenuItem(men, _("Sticky window"), &sticky,\ (TheWin->WorkSpace==-1) ? I_SWITCH_ON: I_SWITCH_OFF); wsmen = MenuCreate((TheWin->title.name && useTitle) ? TheWin->title.name : NULL); if(!wsmen) SeeYa(1,"FATAL: out of memory!"); for (a=0; a<TheScreen.desktop.WorkSpaces; a++) if (a != TheScreen.desktop.ActiveWorkSpace) AppendMenuItem (wsmen, TheScreen.WorkSpace[a], &wsprocs[a], I_SELECT); AppendMenuItem (men, _("Move to WorkSpace"), wsmen, I_SUBMENU); } /* AppendMenuItem(men,TheScreen.Texts.WinMenuMenu.AlwaysOnTop,NULL,I_SELECT);*/ if((item=StartMenu(men,x,y,True,NULL))){ if((item->type==I_SELECT)||(SWITCHTYPE(item->type))){ Procs *pr; if((pr=item->data)){ HandlerTable p; p=pr->Proc; p(TheWin,pr->arg); } } } DestroyMenu(men); }
menu_t *MenuCreateCustom( const char *name, MenuDisplayFunc displayFunc, MenuInputFunc inputFunc, void *data) { menu_t *menu = MenuCreate(name, MENU_TYPE_CUSTOM); menu->u.customData.displayFunc = displayFunc; menu->u.customData.inputFunc = inputFunc; menu->u.customData.data = data; return menu; }
menu_t *MenuCreateOptionFunc( const char *name, void(*toggleFunc)(void), int(*getFunc)(void), menu_option_display_style_e style) { menu_t *menu = MenuCreate(name, MENU_TYPE_VOID_FUNC_VOID); menu->u.option.uHook.toggleFuncs.toggle = toggleFunc; menu->u.option.uHook.toggleFuncs.get = getFunc; menu->u.option.displayStyle = style; return menu; }
menu_t *MenuCreateOptionUpDownFunc( const char *name, void(*upFunc)(void), void(*downFunc)(void), menu_option_display_style_e style, char *(*strFunc)(void)) { menu_t *menu = MenuCreate(name, MENU_TYPE_SET_OPTION_UP_DOWN_VOID_FUNC_VOID); menu->u.option.uHook.upDownFuncs.upFunc = upFunc; menu->u.option.uHook.upDownFuncs.downFunc = downFunc; menu->u.option.displayStyle = style; menu->u.option.uFunc.str = strFunc; return menu; }
menu_t *MenuCreateCustom( const char *name, void (*displayFunc)(GraphicsDevice *, Vec2i, Vec2i, void *), int (*inputFunc)(int, void *), void *data) { menu_t *menu = MenuCreate(name, MENU_TYPE_CUSTOM); menu->u.customData.displayFunc = displayFunc; menu->u.customData.inputFunc = inputFunc; menu->u.customData.data = data; return menu; }
EFI_STATUS SettingsMenuShow ( VOID ) { MENU_ENTRY *Entry; MENU_OPTION* Menu; // create menu Menu = MenuCreate(); Menu->Title = AsciiStrDup("Settings"); Menu->BackCallback = SettingsMenuBackCallback; // UEFI options Entry = MenuCreateEntry(); Entry->Name = AsciiStrDup("Show UEFI boot options"); Entry->ShowToggle = TRUE; Entry->ToggleEnabled = SettingBoolGet("ui-show-uefi-options"); Entry->HideBootMessage = TRUE; Entry->Callback = ShowUEFIOptionsCallback; MenuAddEntry(Menu, Entry); // file explorer Entry = MenuCreateEntry(); Entry->Name = AsciiStrDup("Show File Explorer"); Entry->ShowToggle = TRUE; Entry->ToggleEnabled = SettingBoolGet("ui-show-file-explorer"); Entry->HideBootMessage = TRUE; Entry->Callback = ShowFileExplorerCallback; MenuAddEntry(Menu, Entry); // fastboot Entry = MenuCreateEntry(); Entry->Name = AsciiStrDup("Show Fastboot"); Entry->ShowToggle = TRUE; Entry->ToggleEnabled = SettingBoolGet("ui-show-fastboot"); Entry->HideBootMessage = TRUE; Entry->Callback = ShowFastbootCallback; MenuAddEntry(Menu, Entry); // fastboot Entry = MenuCreateEntry(); Entry->Name = AsciiStrDup("Force selinux to permissive"); Entry->ShowToggle = TRUE; Entry->ToggleEnabled = SettingBoolGet("boot-force-permissive"); Entry->HideBootMessage = TRUE; Entry->Callback = ShowPermissiveCallback; MenuAddEntry(Menu, Entry); MenuStackPush(Menu); return EFI_SUCCESS; }
void WinMenuMenu(UltimateContext *TheWin,int x, int y) { int a; Menu *men,*wsmen; MenuItem *item; short useTitle = (settings.global_settings->LayoutFlags & SUBMENU_TITLES); if(!(men = TheWin->title.name ? MenuCreate(TheWin->title.name) : MenuCreate(""))) SeeYa(1,"FATAL: out of memory!"); if(NUMBER_OF_WORKSPACES > 1) { AppendMenuItem(men, _("Sticky window"), &sticky,\ (TheWin->WorkSpace == -1) ? I_SWITCH_ON : I_SWITCH_OFF); wsmen = MenuCreate((TheWin->title.name && useTitle) ? TheWin->title.name : NULL); if(!wsmen) SeeYa(1,"FATAL: out of memory!"); for (a=0; a < NUMBER_OF_WORKSPACES; a++) AppendMenuItem (wsmen, settings.workspace_settings[a]->Name, &wsprocs[a], I_SELECT); AppendMenuItem (men, _("Move to WorkSpace"), wsmen, I_SUBMENU); } /* AppendMenuItem(men,TheScreen.Texts.WinMenuMenu.AlwaysOnTop,NULL,I_SELECT);*/ if(item=StartMenu(men,x,y,True,NULL)){ if((item->type==I_SELECT)||(SWITCHTYPE(item->type))){ Procs *pr; if(pr=item->data){ HandlerTable p; p=pr->Proc; p(TheWin,pr->arg); } } } DestroyMenu(men); }
menu_t *MenuCreateNormal( const char *name, const char *title, menu_type_e type, int displayItems) { menu_t *menu = MenuCreate(name, type); strcpy(menu->u.normal.title, title); menu->u.normal.displayItems = displayItems; menu->u.normal.changeKeyMenu = NULL; menu->u.normal.index = 0; menu->u.normal.scroll = 0; menu->u.normal.quitMenuIndex = -1; menu->u.normal.subMenus = NULL; menu->u.normal.numSubMenus = 0; return menu; }
menu_t *MenuCreateNormal( const char *name, const char *title, menu_type_e type, int displayItems) { menu_t *menu = MenuCreate(name, type); strcpy(menu->u.normal.title, title); menu->u.normal.isSubmenusAlt = false; menu->u.normal.displayItems = displayItems; menu->u.normal.changeKeyMenu = NULL; menu->u.normal.index = 0; menu->u.normal.scroll = 0; menu->u.normal.maxItems = 0; menu->u.normal.align = MENU_ALIGN_LEFT; menu->u.normal.quitMenuIndex = -1; CArrayInit(&menu->u.normal.subMenus, sizeof(menu_t)); return menu; }
menu_t *MenuCreateOptionRangeGetSet( const char *name, int(*getFunc)(void), void(*setFunc)(int), int low, int high, int increment, menu_option_display_style_e style, void (*func)(void)) { menu_t *menu = MenuCreate(name, MENU_TYPE_SET_OPTION_RANGE_GET_SET); menu->u.option.uHook.optionRangeGetSet.getFunc = getFunc; menu->u.option.uHook.optionRangeGetSet.setFunc = setFunc; menu->u.option.uHook.optionRangeGetSet.low = low; menu->u.option.uHook.optionRangeGetSet.high = high; menu->u.option.uHook.optionRangeGetSet.increment = increment; menu->u.option.displayStyle = style; // TODO: refactor saving of function based on style if (style == MENU_OPTION_DISPLAY_STYLE_INT_TO_STR_FUNC) { menu->u.option.uFunc.intToStr = (const char *(*)(int))func; } return menu; }
menu_t *MenuCreateOptionRange( const char *name, int *config, int low, int high, int increment, menu_option_display_style_e style, void (*func)(void)) { menu_t *menu = MenuCreate(name, MENU_TYPE_SET_OPTION_RANGE); menu->u.option.uHook.optionRange.option = config; menu->u.option.uHook.optionRange.low = low; menu->u.option.uHook.optionRange.high = high; menu->u.option.uHook.optionRange.increment = increment; menu->u.option.displayStyle = style; if (style == MENU_OPTION_DISPLAY_STYLE_STR_FUNC) { menu->u.option.uFunc.str = (char *(*)(void))func; } else if (style == MENU_OPTION_DISPLAY_STYLE_INT_TO_STR_FUNC) { menu->u.option.uFunc.intToStr = (const char *(*)(int))func; } return menu; }
menu_t *MenuCreateReturn(const char *name, int returnCode) { menu_t *menu = MenuCreate(name, MENU_TYPE_RETURN); menu->u.returnCode = returnCode; return menu; }
menu_t *MenuCreateBack(const char *name) { return MenuCreate(name, MENU_TYPE_BACK); }
menu_t *MenuCreateSeparator(const char *name) { menu_t *menu = MenuCreate(name, MENU_TYPE_BASIC); menu->isDisabled = 1; return menu; }
INT32 main ( IN INT32 Argc, IN CHAR8 **Argv ) { EFI_STATUS Status; MENU_ENTRY *Entry; // get LKAPi mLKApi = GetLKApi(); // init fastboot #if defined (MDE_CPU_ARM) FastbootCommandsAdd(); #endif // init libboot libboot_init(); Status = gBS->LocateProtocol ( &gEfiDevicePathToTextProtocolGuid, NULL, (VOID **)&gEfiDevicePathToTextProtocol ); if (EFI_ERROR (Status)) { return -1; } Status = gBS->LocateProtocol ( &gEfiDevicePathFromTextProtocolGuid, NULL, (VOID **)&gEfiDevicePathFromTextProtocol ); if (EFI_ERROR (Status)) { return -1; } // set default values if(!UtilVariableExists(L"multiboot-debuglevel", &gEFIDroidVariableGuid)) UtilSetEFIDroidVariable("multiboot-debuglevel", "4"); if(!UtilVariableExists(L"fastboot-enable-boot-patch", &gEFIDroidVariableGuid)) UtilSetEFIDroidVariable("fastboot-enable-boot-patch", "1"); if(!UtilVariableExists(L"ui-show-file-explorer", &gEFIDroidVariableGuid)) SettingBoolSet("ui-show-file-explorer", FALSE); if(!UtilVariableExists(L"ui-show-uefi-options", &gEFIDroidVariableGuid)) SettingBoolSet("ui-show-uefi-options", FALSE); if(!UtilVariableExists(L"ui-show-fastboot", &gEFIDroidVariableGuid)) SettingBoolSet("ui-show-fastboot", TRUE); if(!UtilVariableExists(L"boot-force-permissive", &gEFIDroidVariableGuid)) SettingBoolSet("boot-force-permissive", FALSE); // init UI Status = MenuInit(); if (EFI_ERROR (Status)) { #if defined (MDE_CPU_ARM) FastbootInit(); #endif return -1; } // create menus mBootMenuMain = MenuCreate(); mPowerMenu = MenuCreate(); mPowerMenu->BackCallback = PowerMenuBackCallback; mPowerMenu->HideBackIcon = TRUE; #if defined (MDE_CPU_ARM) mFastbootMenu = MenuCreate(); mFastbootMenu->Title = AsciiStrDup("Please Select OS"); mFastbootMenu->BackCallback = FastbootBackCallback; #endif mBootMenuMain->Title = AsciiStrDup("Please Select OS"); mBootMenuMain->ActionIcon = libaroma_stream_ramdisk("icons/ic_settings_black_24dp.png"); mBootMenuMain->ActionCallback = MainMenuActionCallback; mBootMenuMain->ItemFlags = MENU_ITEM_FLAG_SEPARATOR_ALIGN_TEXT; #if defined (MDE_CPU_ARM) // add android options AndroidLocatorInit(); AndroidLocatorAddItems(); #endif // add default EFI options AddEfiBootOptions(); // GROUP: Tools Entry = MenuCreateGroupEntry(); Entry->Name = AsciiStrDup("Tools"); MenuAddEntry(mBootMenuMain, Entry); // add file explorer option Entry = MenuCreateEntry(); Entry->Icon = libaroma_stream_ramdisk("icons/fileexplorer.png"); Entry->Name = AsciiStrDup("File Explorer"); Entry->Callback = FileExplorerCallback; Entry->HideBootMessage = TRUE; Entry->Update = FileExplorerUpdate; MenuAddEntry(mBootMenuMain, Entry); #if defined (MDE_CPU_ARM) // add fastboot option Entry = MenuCreateEntry(); Entry->Icon = libaroma_stream_ramdisk("icons/android.png"); Entry->Name = AsciiStrDup("Fastboot"); Entry->Callback = FastbootCallback; Entry->HideBootMessage = TRUE; Entry->Update = FastbootMenuEntryUpdate; MenuAddEntry(mBootMenuMain, Entry); #endif // add reboot option Entry = MenuCreateEntry(); Entry->Icon = libaroma_stream_ramdisk("icons/reboot.png"); Entry->Name = AsciiStrDup("Reboot"); Entry->Callback = RebootCallback; Entry->Private = NULL; Entry->LongPressCallback = RebootLongPressCallback; MenuAddEntry(mBootMenuMain, Entry); Entry = MenuCreateEntry(); Entry->Icon = libaroma_stream_ramdisk("icons/power_off.png"); Entry->Name = AsciiStrDup("Power Off"); Entry->Callback = PowerOffCallback; MenuAddEntry(mPowerMenu, Entry); Entry = MenuCreateEntry(); Entry->Icon = libaroma_stream_ramdisk("icons/reboot.png"); Entry->Name = AsciiStrDup("Reboot"); Entry->Callback = RebootCallback; Entry->Private = NULL; MenuAddEntry(mPowerMenu, Entry); Entry = MenuCreateEntry(); Entry->Icon = libaroma_stream_ramdisk("icons/reboot_recovery.png"); Entry->Name = AsciiStrDup("Reboot to Recovery"); Entry->Callback = RebootCallback; Entry->Private = UnicodeStrDup(L"recovery"); MenuAddEntry(mPowerMenu, Entry); Entry = MenuCreateEntry(); Entry->Icon = libaroma_stream_ramdisk("icons/reboot_bootloader.png"); Entry->Name = AsciiStrDup("Reboot to Bootloader"); Entry->Callback = RebootCallback; Entry->Private = UnicodeStrDup(L"bootloader"); MenuAddEntry(mPowerMenu, Entry); Entry = MenuCreateEntry(); Entry->Icon = libaroma_stream_ramdisk("icons/download_mode.png"); Entry->Name = AsciiStrDup("Enter Download Mode"); Entry->Callback = RebootCallback; Entry->Private = UnicodeStrDup(L"download"); MenuAddEntry(mPowerMenu, Entry); // show previous boot error CHAR8* EFIDroidErrorStr = UtilGetEFIDroidVariable("EFIDroidErrorStr"); if (EFIDroidErrorStr != NULL) { MenuShowMessage("Previous boot failed", EFIDroidErrorStr); // delete variable UtilSetEFIDroidVariable("EFIDroidErrorStr", NULL); // backup variable UtilSetEFIDroidVariable("EFIDroidErrorStrPrev", EFIDroidErrorStr); // free pool FreePool(EFIDroidErrorStr); } // get last boot entry LAST_BOOT_ENTRY* LastBootEntry = UtilGetEFIDroidDataVariable(L"LastBootEntry"); if(LastBootEntry) UtilSetEFIDroidDataVariable(L"LastBootEntry", NULL, 0); #if defined (MDE_CPU_ARM) // run recovery mode handler if (mLKApi) { if(!AsciiStrCmp(mLKApi->platform_get_uefi_bootpart(), "recovery") || mLKApi->platform_get_uefi_bootmode()==LKAPI_UEFI_BM_RECOVERY) { AndroidLocatorHandleRecoveryMode(LastBootEntry); } } #endif // free last boot entry if(LastBootEntry) FreePool(LastBootEntry); // clear the watchdog timer gBS->SetWatchdogTimer (0, 0, 0, NULL); // first boot? UINTN* LastBootVersion = UtilGetEFIDroidDataVariable(L"last-boot-version"); if(LastBootVersion==NULL) { UINTN NewValue = 1; UtilSetEFIDroidDataVariable(L"last-boot-version", &NewValue, sizeof(NewValue)); MenuShowTutorial(); } // show main menu MenuStackPush(mBootMenuMain); MenuEnter (0, TRUE); MenuDeInit(); return 0; }
menu_t *MenuCreateSeparator(const char *name) { return MenuCreate(name, MENU_TYPE_SEPARATOR); }
void WeaponMenuCreate( WeaponMenu *menu, int numPlayers, int player, const int playerUID, EventHandlers *handlers, GraphicsDevice *graphics) { MenuSystem *ms = &menu->ms; WeaponMenuData *data = &menu->data; Vec2i pos, size; int w = graphics->cachedConfig.Res.x; int h = graphics->cachedConfig.Res.y; data->display.PlayerUID = playerUID; data->display.currentMenu = &ms->current; data->display.Dir = DIRECTION_DOWN; data->PlayerUID = playerUID; switch (numPlayers) { case 1: // Single menu, entire screen pos = Vec2iNew(w / 2, 0); size = Vec2iNew(w / 2, h); break; case 2: // Two menus, side by side pos = Vec2iNew(player * w / 2 + w / 4, 0); size = Vec2iNew(w / 4, h); break; case 3: case 4: // Four corners pos = Vec2iNew((player & 1) * w / 2 + w / 4, (player / 2) * h / 2); size = Vec2iNew(w / 4, h / 2); break; default: CASSERT(false, "not implemented"); pos = Vec2iNew(w / 2, 0); size = Vec2iNew(w / 2, h); break; } MenuSystemInit(ms, handlers, graphics, pos, size); ms->align = MENU_ALIGN_LEFT; ms->root = ms->current = MenuCreateNormal( "", "", MENU_TYPE_NORMAL, 0); ms->root->u.normal.maxItems = 11; const CArray *weapons = &gMission.Weapons; for (int i = 0; i < (int)weapons->size; i++) { const GunDescription **g = CArrayGet(weapons, i); menu_t *gunMenu; if ((*g)->Description != NULL) { // Gun description menu gunMenu = MenuCreateNormal((*g)->name, "", MENU_TYPE_NORMAL, 0); char *buf; CMALLOC(buf, strlen((*g)->Description) * 2); FontSplitLines((*g)->Description, buf, size.x * 5 / 6); MenuAddSubmenu(gunMenu, MenuCreateBack(buf)); CFREE(buf); gunMenu->u.normal.isSubmenusAlt = true; MenuSetCustomDisplay(gunMenu, DisplayDescriptionGunIcon, *g); } else { gunMenu = MenuCreate((*g)->name, MENU_TYPE_BASIC); } MenuAddSubmenu(ms->root, gunMenu); } MenuSetPostInputFunc(ms->root, WeaponSelect, &data->display); // Disable menu items where the player already has the weapon PlayerData *pData = PlayerDataGetByUID(playerUID); for (int i = 0; i < pData->weaponCount; i++) { for (int j = 0; j < (int)weapons->size; j++) { const GunDescription **g = CArrayGet(weapons, j); if (pData->weapons[i] == *g) { MenuDisableSubmenu(ms->root, j); } } } MenuAddSubmenu(ms->root, MenuCreateSeparator("")); MenuAddSubmenu( ms->root, MenuCreateNormal("(End)", "", MENU_TYPE_NORMAL, 0)); // Select "(End)" ms->root->u.normal.index = (int)ms->root->u.normal.subMenus.size - 1; // Disable "Done" if no weapons selected if (pData->weaponCount == 0) { MenuDisableSubmenu(ms->root, (int)ms->root->u.normal.subMenus.size - 1); } MenuSetCustomDisplay(ms->root, DisplayGunIcon, NULL); MenuSystemAddCustomDisplay(ms, MenuDisplayPlayer, &data->display); MenuSystemAddCustomDisplay(ms, DisplayEquippedWeapons, data); MenuSystemAddCustomDisplay( ms, MenuDisplayPlayerControls, &data->PlayerUID); }