void drawGame(void) { if (state == STATE_LEAVE) return; if (isInvalid) { arduboy.clear(); if (state == STATE_ISSUES) { drawIssues(); } else if (state == STATE_RESULT) { drawResult(); } else { drawField(); if (state == STATE_PLAYING) { drawStrings(); drawCursor(); } if (blinkFrameFrames > 0 && blinkFlg) arduboy.drawRect(0, 0, WIDTH, HEIGHT, WHITE); } isInvalid = false; } if (state == STATE_MENU || state == STATE_RESULT) { drawMenuItems(false); arduboy.setRGBled(0, 0, 0); } else { if (state == STATE_OVER) drawOverAnimation(); arduboy.setRGBled(ledRGB[0] * vanishFlashFrames, ledRGB[1] * vanishFlashFrames, ledRGB[2] * vanishFlashFrames); } }
void StartingMenuScreen::menuItems(nk_context* ctx) { nk_layout_space_begin(ctx, NK_STATIC, 48, INT_MAX); { nk_layout_space_push(ctx, {125, 0, 390, 154}); { auto frame = mSmLogo->getCurrentFrame(); nk_image(ctx, frame.first->getNkImage(frame.second)); } if (drawMenuItems(ctx) == ActionResult::stopDrawing) return; nk_layout_space_push(ctx, {17, 442, 605, 21}); menuText(ctx, "Freeablo", MenuFontColor::silver, 16, NK_TEXT_ALIGN_LEFT); } nk_layout_space_end(ctx); }
void menuClass::displayMenu() { int menuPos = 0; //fill black background for (int yPlace = 1; yPlace < 14; yPlace++) { for (int xPlace = 1; xPlace < 19; xPlace++) { game_graphics->drawSprite(blackTile, 0, 0, xPlace * 32, yPlace * 32,32,32); } } drawBorder(18, 13); while (inMenu) { drawMenuItems(menuPos); game_graphics->endScene(); int tempNum = menuState(); if (tempNum != 3) //sloppy, I'm sure... but '3' represents a selection { menuPos += tempNum; if (menuPos < 0) {menuPos = (menuItemList.size() - 1);} else if (menuPos > (menuItemList.size() - 1)) {menuPos = 0;} } else if (tempNum == 3) { doMenuItem(menuPos); } } }
void Menu::draw() { simpleWindow::draw(); drawMenuItems(); }
//----------------------------------------------------------------------------- BYTE UserInterface::queryDialog(const char *title, bool save) { void *data = (save) ? gui_query_save : gui_query_confirm; char *dialogTitle = new char[strlen(title) + 5]; sprintf(dialogTitle, " %s ", title); ((GUI_MENU_ENTRY *) data)->text = (const char *) dialogTitle; BYTE *bkm_frameSave = new BYTE[frameLength]; memcpy(bkm_frameSave, defaultSurface->pixels, frameLength); GUI_MENU_ENTRY *bkm_data = cMenu_data; SDL_Rect *bkm_rect = new SDL_Rect(*cMenu_rect); int bkm_leftMargin = cMenu_leftMargin, bkm_count = cMenu_count, bkm_hilite = cMenu_hilite; menuStackLevel++; menuStack[menuStackLevel].type = GUI_TYPE_MENU; menuStack[menuStackLevel].data = data; menuStack[menuStackLevel].hilite = cMenu_hilite = (save) ? 2 : 1; drawMenu(data); bool change; DWORD nextTick; SDL_Event event; GUI_MENU_ENTRY *ptr; uiQueryState = GUI_QUERY_NONE; SDL_Delay(GPU_TIMER_INTERVAL); while (uiQueryState == GUI_QUERY_NONE) { nextTick = SDL_GetTicks() + CPU_TIMER_INTERVAL; while (SDL_PollEvent(&event)) { switch (event.type) { case SDL_KEYDOWN: ptr = &cMenu_data[cMenu_hilite + 1]; change = false; switch (event.key.keysym.sym) { case SDLK_ESCAPE: uiQueryState = GUI_QUERY_CANCEL; break; case SDLK_RETURN: case SDLK_KP_ENTER: uiQueryState = ptr->action; break; case SDLK_UP: if (cMenu_hilite > 0) { cMenu_hilite--; change = true; } break; case SDLK_DOWN: if (cMenu_hilite < (cMenu_count - 1)) { cMenu_hilite++; change = true; } break; default: break; } if (change) { drawMenuItems(); break; } for (ptr = &cMenu_data[1]; ptr->type != MENU_END; ptr++) { if (event.key.keysym.sym == ptr->key) { uiQueryState = ptr->action; break; } } break; case SDL_VIDEOEXPOSE: Emulator->RefreshDisplay(); break; default: break; } } // have a break, have a tick-tock... while (SDL_GetTicks() < nextTick) SDL_Delay(1); } memcpy(defaultSurface->pixels, bkm_frameSave, frameLength); needRelease = true; needRedraw = true; SDL_Delay(GPU_TIMER_INTERVAL); ((GUI_MENU_ENTRY *) data)->text = NULL; delete [] bkm_frameSave; delete [] dialogTitle; cMenu_rect->x = bkm_rect->x; cMenu_rect->y = bkm_rect->y; cMenu_rect->w = bkm_rect->w; cMenu_rect->h = bkm_rect->h; delete bkm_rect; cMenu_data = bkm_data; cMenu_leftMargin = bkm_leftMargin; cMenu_hilite = bkm_hilite; cMenu_count = bkm_count; menuStackLevel--; return uiQueryState; }