From 85fd0b8563936f1e5fad678df8857d43f805f4f7 Mon Sep 17 00:00:00 2001 From: Lee Salzman Date: Wed, 14 May 2008 21:51:43 +0000 Subject: [PATCH] added more initwarning checks git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@1972 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/main.cpp | 44 +++++++++++++++++++++++++----------------- source/src/menus.cpp | 4 ++-- source/src/protos.h | 16 +++++++++++++-- source/src/texture.cpp | 6 +++--- 4 files changed, 45 insertions(+), 25 deletions(-) diff --git a/source/src/main.cpp b/source/src/main.cpp index a40bba8a..9efbb160 100644 --- a/source/src/main.cpp +++ b/source/src/main.cpp @@ -59,37 +59,43 @@ void fatal(const char *s, ...) // failure exit SDL_Surface *screen = NULL; -static bool initing = false, restoredinits = false; -bool initwarning(const char *desc) +static int initing = NOT_INITING; +static bool restoredinits = false; + +bool initwarning(const char *desc, int level, int type) { - if(!initing) + if(initing < level) { - if(!restoredinits) conoutf("\f3Please start AssaultCube with the --init command-line option to persist this setting"); - addchange(desc); + addchange(desc, type); + return true; } - return !initing; + return false; } -VAR(scr_w, 0, 1024, 10000); -VAR(scr_h, 0, 768, 10000); -VAR(colorbits, 0, 0, 32); -VAR(depthbits, 0, 0, 32); -VAR(fsaa, -1, -1, 16); -VAR(vsync, -1, -1, 1); +VARF(scr_w, 320, 1024, 10000, initwarning("screen resolution")); +VARF(scr_h, 200, 768, 10000, initwarning("screen resolution")); +VARF(colorbits, 0, 0, 32, initwarning("color depth")); +VARF(depthbits, 0, 0, 32, initwarning("depth-buffer precision")); +VARF(fsaa, -1, -1, 16, initwarning("anti-aliasing")); +VARF(vsync, -1, -1, 1, initwarning("vertical sync")); -#if defined(WIN32) || defined(__APPLE__) -VARF(fullscreen, 0, 0, 1, initwarning("fullscreen")); -#else void setfullscreen(bool enable) { if(!screen) return; +#if defined(WIN32) || defined(__APPLE__) + initwarning(enable ? "fullscreen" : "windowed"); +#else if(enable == !(screen->flags&SDL_FULLSCREEN)) { SDL_WM_ToggleFullScreen(screen); SDL_WM_GrabInput((screen->flags&SDL_FULLSCREEN) ? SDL_GRAB_ON : SDL_GRAB_OFF); } +#endif } +#ifdef _DEBUG +VARF(fullscreen, 0, 0, 1, setfullscreen(fullscreen!=0)); +#else VARF(fullscreen, 0, 1, 1, setfullscreen(fullscreen!=0)); #endif @@ -143,7 +149,7 @@ COMMAND(quit, ARG_NONE); void screenres(int w, int h) { #if !defined(WIN32) && !defined(__APPLE__) - if(initing) + if(initing >= INIT_RESET) { #endif scr_w = w; @@ -422,7 +428,7 @@ int main(int argc, char **argv) #define initlog(s) puts("init: " s) - initing = true; + initing = INIT_RESET; for(int i = 1; i needsapply; VARP(applydialog, 0, 1, 1); -void addchange(const char *desc) +void addchange(const char *desc, int type) { - if(!applydialog) return; + if(!applydialog || type!=CHANGE_GFX) return; loopv(needsapply) if(!strcmp(needsapply[i], desc)) return; needsapply.add(desc); showmenu("apply"); diff --git a/source/src/protos.h b/source/src/protos.h index f736bdf0..5a40f2b1 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -85,7 +85,7 @@ extern void rendermenumdl(); extern void menuset(void *m); extern void menuselect(void *menu, int sel); extern void showmenu(const char *name); -extern void addchange(const char *desc); +extern void addchange(const char *desc, int type); extern void refreshapplymenu(void *menu, bool init); struct mitem @@ -361,9 +361,21 @@ extern int isoccluded(float vx, float vy, float cx, float cy, float csize); extern SDL_Surface *screen; extern void keyrepeat(bool on); -extern bool initwarning(const char *desc); extern bool firstrun; +enum +{ + NOT_INITING = 0, + INIT_LOAD, + INIT_RESET +}; +enum +{ + CHANGE_GFX = 1<<0, + CHANGE_SOUND = 1<<1 +}; +extern bool initwarning(const char *desc, int level = INIT_RESET, int type = CHANGE_GFX); + // rendertext struct font { diff --git a/source/src/texture.cpp b/source/src/texture.cpp index d69d8beb..6b314953 100644 --- a/source/src/texture.cpp +++ b/source/src/texture.cpp @@ -7,9 +7,9 @@ Texture *notexture = NULL; hashtable textures; VAR(hwtexsize, 1, 0, 0); -VARP(maxtexsize, 0, 0, 4096); -VARP(trilinear, 0, 1, 1); -VARP(bilinear, 0, 1, 1); +VARFP(maxtexsize, 0, 0, 1<<12, initwarning("texture quality", INIT_LOAD)); +VARFP(trilinear, 0, 1, 1, initwarning("texture filtering", INIT_LOAD)); +VARFP(bilinear, 0, 1, 1, initwarning("texture filtering", INIT_LOAD)); void createtexture(int tnum, int w, int h, void *pixels, int clamp, bool mipmap, GLenum format) {