From 1ddff1ad3be164da64f578d8fb27294e9926dba3 Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Sun, 15 May 2011 20:40:08 +0100 Subject: [PATCH] Runtime fullscreen toggle TODO: Fix bug that prevents from closing the window after a fullscreen toggle --- includes/defines.h | 1 + src/interface.c | 20 ++++++++++++++++---- src/main.c | 3 ++- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/includes/defines.h b/includes/defines.h index b756869c6..10745b53f 100644 --- a/includes/defines.h +++ b/includes/defines.h @@ -206,4 +206,5 @@ void sdl_seticon(void); void play_sound(char *file); void start_grav_async(void); void stop_grav_async(void); +void set_scale(int scale, int kiosk); #endif diff --git a/src/interface.c b/src/interface.c index 802176367..3bef348b8 100644 --- a/src/interface.c +++ b/src/interface.c @@ -4559,12 +4559,13 @@ void decorations_ui(pixel *vid_buf,pixel *decorations,int *bsx,int *bsy) void simulation_ui(pixel * vid_buf) { int xsize = 300; - int ysize = 114; + int ysize = 140; int x0=(XRES-xsize)/2,y0=(YRES-MENUSIZE-ysize)/2,b=1,bq,mx,my; - int new_scale; + int new_scale, new_kiosk; ui_checkbox cb; ui_checkbox cb2; ui_checkbox cb3; + ui_checkbox cb4; cb.x = x0+xsize-16; cb.y = y0+23; @@ -4580,6 +4581,11 @@ void simulation_ui(pixel * vid_buf) cb3.y = y0+77; cb3.focus = 0; cb3.checked = (sdl_scale==2)?1:0; + + cb4.x = x0+xsize-16; + cb4.y = y0+103; + cb4.focus = 0; + cb4.checked = (kiosk_enable==1)?1:0; while (!sdl_poll()) { @@ -4610,6 +4616,9 @@ void simulation_ui(pixel * vid_buf) drawtext(vid_buf, x0+8, y0+80, "Large window", 255, 255, 255, 255); drawtext(vid_buf, x0+12+textwidth("Large window"), y0+80, "Double window size for small screens", 255, 255, 255, 180); //drawtext(vid_buf, x0+12, y0+68, "May also cause slow performance on older computers", 255, 255, 255, 180); + + drawtext(vid_buf, x0+8, y0+106, "Fullscreen", 255, 255, 255, 255); + drawtext(vid_buf, x0+12+textwidth("Fullscreen"), y0+106, "Fill the entire screen", 255, 255, 255, 180); //TODO: Options for Air and Normal gravity //Maybe save/load defaults too. @@ -4620,10 +4629,12 @@ void simulation_ui(pixel * vid_buf) ui_checkbox_draw(vid_buf, &cb); ui_checkbox_draw(vid_buf, &cb2); ui_checkbox_draw(vid_buf, &cb3); + ui_checkbox_draw(vid_buf, &cb4); sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE)); ui_checkbox_process(mx, my, b, bq, &cb); ui_checkbox_process(mx, my, b, bq, &cb2); ui_checkbox_process(mx, my, b, bq, &cb3); + ui_checkbox_process(mx, my, b, bq, &cb4); if (b && !bq && mx>=x0 && mx=y0+ysize-16 && my<=y0+ysize) break; @@ -4636,8 +4647,9 @@ void simulation_ui(pixel * vid_buf) legacy_enable = !cb.checked; new_scale = (cb3.checked)?2:1; - if(new_scale!=sdl_scale) - set_scale(new_scale); + new_kiosk = (cb4.checked)?1:0; + if(new_scale!=sdl_scale || new_kiosk!=kiosk_enable) + set_scale(new_scale, new_kiosk); if(ngrav_enable != cb2.checked) { if(cb2.checked) diff --git a/src/main.c b/src/main.c index 9328814e1..fcaf65bd5 100644 --- a/src/main.c +++ b/src/main.c @@ -1230,8 +1230,9 @@ char my_uri[] = "http://" SERVER "/Update.api?Action=Download&Architecture=" #endif ; -void set_scale(int scale){ +void set_scale(int scale, int kiosk){ sdl_scale = scale; + kiosk_enable = kiosk; sdl_open(); return; }