Mercurial > hg > dmlib
diff dmsimple.c @ 597:8a9361179a1a
More work on the video setup screen.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 12 Apr 2013 07:35:10 +0300 |
parents | 695a623eed63 |
children | 71539fc4ba5a |
line wrap: on
line diff
--- a/dmsimple.c Fri Apr 12 06:06:56 2013 +0300 +++ b/dmsimple.c Fri Apr 12 07:35:10 2013 +0300 @@ -167,11 +167,12 @@ int engineVideoSetup() { - DMBitmapFont *font = NULL; + DMBitmapFont *menuFont = NULL; DMResource *file = NULL; SDL_Surface *menuBgImage = NULL; int result, menuState = -1, nmenuList, menuChoice = 0; DMScaledBlitFunc menuBgBlit; + char menuStr[128]; // Compute a list of valid modes @@ -210,7 +211,7 @@ if (file == NULL) file = dmf_create_memio(NULL, "SetupFont", engineSetupFont, sizeof(engineSetupFont)); - result = dmLoadBitmapFont(file, &font); + result = dmLoadBitmapFont(file, &menuFont); dmf_close(file); if (result != DMERR_OK) { @@ -219,7 +220,10 @@ goto out; } + SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); menuBgBlit = dmGetScaledBlitFunc(menuBgImage->format, engine.screen->format, DMD_NONE); + int menuEntryHeight = menuFont->height + 1, + menuHeight = DM_VSETUP_MENU_HEIGHT / menuEntryHeight; // Enter the main loop of the menu menuState = 0; @@ -272,6 +276,27 @@ dmClearSurface(engine.screen, dmMapRGB(engine.screen, 0,0,0)); menuBgBlit(menuBgImage, 0, 0, engine.screen->w, engine.screen->h, engine.screen); + // XXX/TODO: Some hardcoded bits here ... + int entry, yc = 0; + nmenuList = 5; + + dmFillRect(engine.screen, + DM_VSETUP_MENU_XC, + DM_VSETUP_MENU_YC + (menuChoice * menuEntryHeight), + DM_VSETUP_MENU_XC + DM_VSETUP_MENU_WIDTH, + DM_VSETUP_MENU_YC + (menuChoice * menuEntryHeight) + menuEntryHeight + 2, + dmMapRGBA(engine.screen, 255, 255, 255, 100)); + + for (entry = 0; entry < nmenuList && entry < menuHeight; entry++) + { + snprintf(menuStr, sizeof(menuStr), "SUPERMEGA %d", menuHeight); + dmDrawBMTextConst( + engine.screen, menuFont, DMD_TRANSPARENT, + DM_VSETUP_MENU_XC + 2, + DM_VSETUP_MENU_YC + 2 + entry * menuEntryHeight, + menuStr); + } + // Flip screen if (SDL_MUSTLOCK(engine.screen) != 0)