From b66d7c410d8414dc73c5e9ab8002b7fd6379f5b0 Mon Sep 17 00:00:00 2001 From: onpon4 Date: Thu, 2 Feb 2017 17:45:47 -0500 Subject: [PATCH] Made it so that the save and options sections work at 640x480. --- src/intermission.cpp | 38 ++++++++++++++++++++++---------------- src/save.cpp | 18 +++++++++--------- src/save.h | 2 +- 3 files changed, 32 insertions(+), 26 deletions(-) diff --git a/src/intermission.cpp b/src/intermission.cpp index 1273757..ad8934f 100644 --- a/src/intermission.cpp +++ b/src/intermission.cpp @@ -1153,7 +1153,7 @@ static void intermission_createMissionDetailSurface(SDL_Surface *comms, int miss engine.commsSection = 1; } -static void intermission_doComms(SDL_Surface *comms) +static void intermission_doComms(SDL_Surface *comms, int x, int y) { if ((engine.keyState[KEY_FIRE])) { @@ -1161,7 +1161,7 @@ static void intermission_doComms(SDL_Surface *comms) { for (int i = 0 ; i < 4 ; i++) { - if (game_collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, 170, 180 + (i * 60), 430, 50)) + if (game_collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, x, y + 110 + (i * 60), 430, 50)) { intermission_createMissionDetailSurface(comms, i); engine.keyState[KEY_FIRE] = 0; @@ -1170,7 +1170,7 @@ static void intermission_doComms(SDL_Surface *comms) } else { - if (game_collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, 170, 440, 160, 20)) + if (game_collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, x, y + 370, 160, 20)) { intermission_createCommsSurface(comms); engine.keyState[KEY_FIRE] = 0; @@ -1221,30 +1221,30 @@ static void intermission_createOptions(SDL_Surface *optionsSurface) gfx_renderString("FULLSCREEN", 30, 150, FONT_WHITE, 0, optionsSurface); } -static void intermission_doOptions(SDL_Surface *optionsSurface) +static void intermission_doOptions(SDL_Surface *optionsSurface, int x, int y) { if ((engine.keyState[KEY_FIRE])) { - if (game_collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, 417, 172, 45, 22)) + if (game_collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, x + 187, y + 42, 45, 22)) engine.useSound = 1; - if (game_collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, 478, 172, 45, 22)) + if (game_collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, x + 248, y + 42, 45, 22)) engine.useSound = 0; - if (game_collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, 417, 222, 45, 22)) + if (game_collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, x + 187, y + 92, 45, 22)) { engine.useMusic = 1; audio_playMusic("music/through_space.ogg", -1); } - if (game_collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, 478, 222, 45, 22)) + if (game_collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, x + 248, y + 92, 45, 22)) { engine.useMusic = 0; audio_haltMusic(); } - if (game_collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, 417, 272, 45, 22)) + if (game_collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, x + 187, y + 142, 45, 22)) { if (!engine.fullScreen) { @@ -1253,7 +1253,7 @@ static void intermission_doOptions(SDL_Surface *optionsSurface) } } - if (game_collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, 478, 272, 45, 22)) + if (game_collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, x + 248, y + 142, 45, 22)) { if (engine.fullScreen) { @@ -1566,8 +1566,10 @@ int intermission() break; case 3: - screen_blit(savesSurface, 200, 100); - saveSlot = save_showSlots(savesSurface, saveSlot); + x = screen->w / 2 - savesSurface->w / 2; + y = 50; + screen_blit(savesSurface, x, y); + saveSlot = save_showSlots(savesSurface, saveSlot, x, y); break; case 4: @@ -1575,13 +1577,17 @@ int intermission() break; case 5: - screen_blit(commsSurface, 170, 70); - intermission_doComms(commsSurface); + x = screen->w / 2 - commsSurface->w / 2; + y = 50; + screen_blit(commsSurface, x, y); + intermission_doComms(commsSurface, x, y); break; case 6: - screen_blit(optionsSurface, 230, 130); - intermission_doOptions(optionsSurface); + x = screen->w / 2 - optionsSurface->w / 2; + y = 50; + screen_blit(optionsSurface, x, y); + intermission_doOptions(optionsSurface, x, y); break; case 7: diff --git a/src/save.cpp b/src/save.cpp index 998ecc3..4b81af1 100644 --- a/src/save.cpp +++ b/src/save.cpp @@ -419,13 +419,13 @@ Displays the save slot available. For use with an interface that has the cursor enabled. It returns the index number of the slot clicked so that the function invoking it can perform a load or save on that slot. */ -int save_showSlots(SDL_Surface *savesSurface, int saveSlot) +int save_showSlots(SDL_Surface *savesSurface, int saveSlot, int x, int y) { int clickedSlot = -1; SDL_Rect r; - r.x = 201; - r.y = 115; + r.x = x + 1; + r.y = y + 15; r.w = 348; r.h = 25; @@ -442,19 +442,19 @@ int save_showSlots(SDL_Surface *savesSurface, int saveSlot) r.y += 30; } - if (game_collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, 215, - 365, 100, 25)) + if (game_collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, + x + 15, y + 265, 100, 25)) { save(saveSlot); save_createSurface(savesSurface, -10); } - if (game_collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, 335, - 365, 100, 25)) + if (game_collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, + x + 135, y + 265, 100, 25)) save_createSurface(savesSurface, -1); - if (game_collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, 453, - 365, 100, 25)) + if (game_collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, + x + 253, y + 265, 100, 25)) { char filename[PATH_MAX]; sprintf(filename, "%ssave%.2d.dat", engine.configDirectory, diff --git a/src/save.h b/src/save.h index 6b5d6c3..d6f33d6 100644 --- a/src/save.h +++ b/src/save.h @@ -29,6 +29,6 @@ int save_initSlots(); int save_load(int slot); void save(int slot); void save_createSurface(SDL_Surface *savesSurface, int clickedSlot); -int save_showSlots(SDL_Surface *savesSurface, int saveSlot); +int save_showSlots(SDL_Surface *savesSurface, int saveSlot, int x, int y); #endif