X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2Finit.cpp;h=3c333cc10d8d3ed632c712b57ad9fd174e55e5fb;hb=150bfd36d71cafa0213f083a333fd686d844966f;hp=10e7aeb4bef92c2b30c1bcfe57e85dae0c66aa5f;hpb=07982ad9c7965ca7d30b58bd610a4855b1fb5c6d;p=quix0rs-blobwars.git diff --git a/src/init.cpp b/src/init.cpp index 10e7aeb..3c333cc 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1,5 +1,6 @@ /* Copyright (C) 2004-2011 Parallel Realities +Copyright (C) 2011-2015 Perpendicular Dimensions This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -20,6 +21,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "init.h" +static bool displayLicense; + void checkForLicense() { if (!engine.loadData(_("data/license"))) @@ -80,7 +83,7 @@ void showLicense() graphics.updateScreen(); engine.getInput(); config.populate(); - if (engine.keyState[SDL_SCANCODE_SPACE]) + if (engine.userAccepts()) break; SDL_Delay(16); } @@ -252,18 +255,21 @@ int initMedalService(void *data) return 1; } +void initConfig() +{ + #if UNIX + setupUserHomeDirectory(); + #endif + + displayLicense = loadConfig(); +} + /* Chugg chugg chugg.... brrr... chugg chugg chugg...brrrrrr... chugg ch.. BRRRRRRRRRRRRRRRRRMMMMMMMMMMMMMMMMMMM!! Well, hopefully anyway! ;) */ void initSystem() { - #if UNIX - setupUserHomeDirectory(); - #endif - - bool displayLicense = loadConfig(); - long flags = SDL_INIT_VIDEO|SDL_INIT_JOYSTICK; if (engine.useAudio) @@ -280,14 +286,45 @@ void initSystem() graphics.screen = SDL_CreateRGBSurface(0, 640, 480, 32, 0xff0000, 0xff00, 0xff, 0xff000000); - graphics.window = SDL_CreateWindow("Blobwars: Metal Blob Solid", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, graphics.screen->w, graphics.screen->h, 0); - graphics.renderer = SDL_CreateRenderer(graphics.window, -1, 0); + if (graphics.screen == NULL) + { + printf("Couldn't set 640x480 video mode: %s\n", SDL_GetError()); + exit(1); + } + + // Increase the size of the window if we have large desktop resolutions + SDL_DisplayMode displayMode{0}; + SDL_GetDesktopDisplayMode(0, &displayMode); + int w = graphics.screen->w; + int h = graphics.screen->h; + while (displayMode.w > w * 2 && displayMode.h > h * 2) + { + w *= 2; + h *= 2; + } + + graphics.window = SDL_CreateWindow("Blobwars: Metal Blob Solid", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, w, h, SDL_WINDOW_RESIZABLE); + + if (graphics.window == NULL) + { + printf("Couldn't create %dx%d window: %s\n", w, h, SDL_GetError()); + exit(1); + } + + graphics.renderer = SDL_CreateRenderer(graphics.window, -1, SDL_RENDERER_PRESENTVSYNC); + + if (graphics.renderer == NULL) + { + printf("Couldn't create renderer: %s\n", SDL_GetError()); + exit(1); + } + SDL_RenderSetLogicalSize(graphics.renderer, graphics.screen->w, graphics.screen->h); graphics.texture = SDL_CreateTexture(graphics.renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, graphics.screen->w, graphics.screen->h); - if (graphics.window == NULL) + if (graphics.texture == NULL) { - printf("Couldn't set 640x480 video mode: %s\n", SDL_GetError()); + printf("Could not create %dx%d texture: %s\n", graphics.screen->w, graphics.screen->h, SDL_GetError()); exit(1); } @@ -349,26 +386,18 @@ void initSystem() debug(("Loading Fonts...\n")); #if USEPAK - - char tempPath[PATH_MAX]; - snprintf(tempPath, sizeof tempPath, "%sfont.ttf", engine.userHomeDirectory); - remove(tempPath); - if (!engine.unpack("data/vera.ttf", PAK_FONT)) { engine.reportFontFailure(); } #endif - debug(("Trying to load correct font pixel sizes using a really half arsed routine!\n")); - debug(("If it crashes then you'll know why!\n")); - - graphics.loadFont(0, "data/vera.ttf", 7); - graphics.loadFont(1, "data/vera.ttf", 9); - graphics.loadFont(2, "data/vera.ttf", 11); - graphics.loadFont(3, "data/vera.ttf", 13); - graphics.loadFont(4, "data/vera.ttf", 15); - + graphics.loadFont(0, "data/vera.ttf", 12); + graphics.loadFont(1, "data/vera.ttf", 15); + graphics.loadFont(2, "data/vera.ttf", 19); + graphics.loadFont(3, "data/vera.ttf", 23); + graphics.loadFont(4, "data/vera.ttf", 24); + debug(("Font sizes all loaded!!\n")); audio.loadSound(SND_CHEAT, "sound/Lock And Load!!!");