added more initwarning checks

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@1972 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
Lee Salzman
2008-05-14 21:51:43 +00:00
parent a550830379
commit 85fd0b8563
4 changed files with 45 additions and 25 deletions
+26 -18
View File
@@ -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<argc; i++)
{
char *a = &argv[i][2];
@@ -473,7 +479,7 @@ int main(int argc, char **argv)
}
else conoutf("unknown commandline argument");
}
initing = false;
initing = NOT_INITING;
initlog("sdl");
int par = 0;
@@ -563,12 +569,14 @@ int main(int argc, char **argv)
gzclose(f);
}
initing = INIT_LOAD;
if(!execfile("config/saved.cfg"))
{
exec("config/defaults.cfg");
firstrun = true;
}
execfile("config/autoexec.cfg");
initing = NOT_INITING;
initlog("models");
preload_playermodels();
+2 -2
View File
@@ -750,9 +750,9 @@ void *applymenu = NULL;
static vector<const char *> 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");
+14 -2
View File
@@ -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
{
+3 -3
View File
@@ -7,9 +7,9 @@ Texture *notexture = NULL;
hashtable<char *, Texture> 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)
{