--- kipmind.old/src/mastermind.cpp +++ kipmind/src/mastermind.cpp @@ -15,6 +15,9 @@ * ***************************************************************************/ +#include +#include + #include "mastermind.h" // Globals :o @@ -142,18 +145,32 @@ // Set graphics mode set_color_depth(8); - if(conf.fullscreen == true) - set_gfx_mode(GFX_AUTODETECT_FULLSCREEN, SCREENW, SCREENH, 0, 0); - else - set_gfx_mode(GFX_AUTODETECT_WINDOWED, SCREENW, SCREENH, 0, 0); + + if ((conf.fullscreen == true) && 0) + { + int h = SCREENH; + struct stat sbuf; + if (stat ("/etc/sysconfig/ISNVIDIA", &sbuf) == 0) h++; + set_gfx_mode (GFX_AUTODETECT_FULLSCREEN, SCREENW, h, 0, 0); + } + else + { + set_gfx_mode (GFX_AUTODETECT_WINDOWED, SCREENW, SCREENH, 0, 0); + } + + set_window_title ("Mastermind"); // Load data // First get the absolute path to avoid segfault when not launched with the right working directory char buf[512]; +#ifdef NOTDEF get_executable_name(buf, 512); char *exe = get_filename(buf); uszprintf(buf, strlen(buf)-strlen(exe), "%s", buf); uszprintf(buf, 512, "%s/mm.dat", buf); +#else + strcpy (buf, "__META_PREFIX__/program/mm.dat"); +#endif // Then call load_datafile() with the absolute path data = load_datafile(buf); @@ -228,10 +245,19 @@ void Game::save_options() { char buf[512]; + +#ifdef NOTDEF get_executable_name(buf, 512); char *exe = get_filename(buf); uszprintf(buf, strlen(buf)-strlen(exe), "%s", buf); uszprintf(buf, 512, "%s/prefs.dat", buf); +#else + char *cp = getenv ("HOME"); + if (cp == NULL) exit (1); + uszprintf (buf, 512, "mkdir -p %s/.config/kipmind", cp); + system (buf); + uszprintf (buf, 512, "%s/.config/kipmind/kipmind.dat", cp); +#endif std::ofstream os(buf, std::ios::binary); os.write(reinterpret_cast(&conf), sizeof(Config)); @@ -244,10 +270,17 @@ void Game::read_options() { char buf[512]; + +#ifdef NOTDEF get_executable_name(buf, 512); char *exe = get_filename(buf); uszprintf(buf, strlen(buf)-strlen(exe), "%s", buf); uszprintf(buf, 512, "%s/prefs.dat", buf); +#else + char *cp = getenv ("HOME"); + if (cp == NULL) exit (1); + uszprintf (buf, 512, "%s/.config/kipmind/kipmind.dat", cp); +#endif std::ifstream is; @@ -257,7 +290,7 @@ if(!is.is_open()) { save_options(); - is.open("prefs.dat"); + is.open ("kipmind.dat"); } // If the file is still not readable, contiune with default values @@ -751,8 +784,12 @@ if(dialog[6].flags == D_SELECTED && !conf.fullscreen) { + int h = SCREENH; + struct stat sbuf; + if (stat ("/etc/sysconfig/ISNVIDIA", &sbuf) == 0) h++; + conf.fullscreen = true; - set_gfx_mode(GFX_AUTODETECT_FULLSCREEN, SCREENW, SCREENH, 0, 0); + set_gfx_mode (GFX_AUTODETECT_FULLSCREEN, SCREENW, h, 0, 0); set_palette((RGB*)data[MMD_PALETTE].dat); set_mouse_sprite(NULL); show_mouse(screen);