changeset 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 9861568d87ac
children 6699a8b25535
files Makefile.gen dmengine.h dmsimple.c
diffstat 3 files changed, 37 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile.gen	Fri Apr 12 06:06:56 2013 +0300
+++ b/Makefile.gen	Fri Apr 12 07:35:10 2013 +0300
@@ -301,6 +301,10 @@
 	@echo " CC $+"
 	@$(CC) $(CFLAGS) -c -o $@ $< $(DM_CFLAGS)
 
+$(OBJPATH)dmsimple.o: $(DMLIB)dmsimple.c $(DMLIB)dmengine.h
+	@echo " CC $+"
+	@$(CC) $(CFLAGS) -c -o $@ $< $(DM_CFLAGS)
+
 $(OBJPATH)jssmod.o: $(DMLIB)jssmod.c $(DMLIB)jssmod.h $(DMLIB)jss.h
 	@echo " CC $+"
 	@$(CC) $(CFLAGS) -c -o $@ $< $(DM_CFLAGS)
--- a/dmengine.h	Fri Apr 12 06:06:56 2013 +0300
+++ b/dmengine.h	Fri Apr 12 07:35:10 2013 +0300
@@ -23,6 +23,12 @@
 #define DM_VSETUP_WIDTH  640
 #define DM_VSETUP_HEIGHT 480
 
+#define DM_VSETUP_MENU_XC     120
+#define DM_VSETUP_MENU_YC     200
+#define DM_VSETUP_MENU_WIDTH  400
+#define DM_VSETUP_MENU_HEIGHT 200
+
+
 // Video setup type
 #define DM_VSETUP_NONE   0x00  // No video setup, just set window/screen to what demo specifies
 #define DM_VSETUP_ASPECT 0x01  // Only modes that match the optVidAspect aspect ratio are ok
--- 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)