From 3e6baf4e21f7bcb05a05e829a762e0339b2501e7 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sun, 3 Dec 2017 19:51:45 +0100 Subject: [PATCH] improvements to start menu: can be called from main menu; resets all special modes; selecting shmup allows you to configure keys immediately --- config.cpp | 47 ++++++++++++++++++++++++++++++++++------------- hyper.h | 1 + menus.cpp | 16 ++++++++++++---- 3 files changed, 47 insertions(+), 17 deletions(-) diff --git a/config.cpp b/config.cpp index 7fd97c26..b77dde95 100644 --- a/config.cpp +++ b/config.cpp @@ -4,6 +4,9 @@ videopar vid; +#define DEFAULT_WALLMODE ISMOBILE ? 3 : 5 +#define DEFAULT_MONMODE ISMOBILE ? 2 : 4 + #if ISANDROID #define ANDROID_SETTINGS settingsChanged = true; #else @@ -236,8 +239,8 @@ void initConfig() { addsaver(vid.yshift, "Y shift", 0); addsaver(vid.camera_angle, "camera angle", 0); addsaver(vid.ballproj, "ballproj", 1); - addsaver(vid.monmode, "monster display mode", ISMOBILE ? 2 : 4); - addsaver(vid.wallmode, "wall display mode", ISMOBILE ? 3 : 5); + addsaver(vid.monmode, "monster display mode", DEFAULT_MONMODE); + addsaver(vid.wallmode, "wall display mode", DEFAULT_WALLMODE); addsaver(geom3::depth, "3D depth"); addsaver(geom3::camera, "3D camera level"); @@ -317,21 +320,39 @@ void initConfig() { #endif } -void resetModes() { +bool inSpecialMode() { + return chaosmode || nontruncated || peace::on || tour::on || + yendor::on || tactic::on || randomPatternsMode || + geometry != gNormal || pmodel != mdDisk || vid.alpha != 1 || vid.scale != 1 || + rug::rugged || vid.monmode != DEFAULT_MONMODE || + vid.wallmode != DEFAULT_WALLMODE; + } + +void resetModes(char leave = 'c') { popAllGames(); firstland = laIce; vid.scfg.players = 1; - if(shmup::on) restartGame('s'); - if(inv::on) restartGame('i'); - if(chaosmode) restartGame('C'); - if(nontruncated) restartGame('7'); - if(peace::on) restartGame('P'); + if(shmup::on != (leave == 's')) restartGame('s'); + if(inv::on != (leave == 'i')) restartGame('i'); + if(chaosmode != (leave == 'C')) restartGame('C'); + if(nontruncated != (leave == '7')) restartGame('7'); + if(peace::on != (leave == 'P')) restartGame('P'); #if CAP_TOUR - if(tour::on) restartGame('T'); + if(tour::on != (leave == 'T')) restartGame('T'); #endif - if(yendor::on) restartGame('y'); - if(tactic::on) restartGame('t'); - if(randomPatternsMode) restartGame('r'); - if(geometry != gNormal) { targetgeometry = gNormal; restartGame('g'); } + if(yendor::on != (leave == 'y')) restartGame('y'); + if(tactic::on != (leave == 't')) restartGame('t'); + if(randomPatternsMode != (leave == 'r')) restartGame('r'); + + if(geometry != gNormal && leave != 'g') { + targetgeometry = gNormal; + restartGame('g'); + } + + pmodel = mdDisk; vid.alpha = 1; vid.scale = 1; + if(rug::rugged) rug::close(); + + vid.monmode = DEFAULT_MONMODE; + vid.wallmode = DEFAULT_WALLMODE; } #if CAP_CONFIG diff --git a/hyper.h b/hyper.h index eced3d4c..bd687a83 100644 --- a/hyper.h +++ b/hyper.h @@ -2279,3 +2279,4 @@ ld realradius(); void sdltogl(SDL_Surface *txt, struct glfont_t& f, int ch); void glcolor2(int color); +void showStartMenu(); diff --git a/menus.cpp b/menus.cpp index ab9cfede..a3f0dc76 100644 --- a/menus.cpp +++ b/menus.cpp @@ -210,6 +210,8 @@ void showMainMenu() { dialog::addItem(XLAT("cheats"), 'c'); else dialog::addBreak(100); dialog::addItem(XLAT("restart game"), 'r'); dialog::lastItem().keycaption += " / F5"; + + dialog::addItem(XLAT(inSpecialMode() ? "reset special modes" : "back to the start menu"), 'R'); string q; #if ISMOBILE==1 @@ -259,10 +261,12 @@ void showMainMenu() { else if(sym == 'g') pushScreen(showGraphConfig); else if(sym == 'd') pushScreen(showDisplayMode); else if(sym == 'm') pushScreen(showChangeMode); + else if(uni == 'R') + popScreenAll(), pushScreen(showStartMenu); #if CAP_SAVE else if(sym == 't') scores::load(); #endif - else if(sym == 'r' || sym == SDLK_F5) { + else if(uni == 'r' || sym == SDLK_F5) { restartGame(); } else if(sym == 'q' || sym == SDLK_F10) { @@ -629,15 +633,18 @@ void showStartMenu() { if(uni == 'o') uni = 'i'; if(uni == 'c' || uni == 'i' || uni == 's') { popScreenAll(); - if(inv::on != (uni == 'i')) restartGame('i'); - if(shmup::on != (uni == 's')) restartGame('s'); + resetModes(uni); clearMessages(); welcomeMessage(); stampbase = ticks; + if(uni == 's') { + multi::shmupcfg = shmup::on; + pushScreen(multi::showShmupConfig); + } } else if(uni == 'z') { popScreenAll(); - resetModes(); + resetModes('g'); stampbase = ticks; if(!sphere) { specialland = laHalloween; @@ -650,6 +657,7 @@ void showStartMenu() { #if CAP_TOUR else if(uni == 't') { popScreenAll(); + resetModes('c'); tour::start(); } #endif