diff --git a/multi.cpp b/multi.cpp index e23a7471..43100a3e 100644 --- a/multi.cpp +++ b/multi.cpp @@ -25,7 +25,7 @@ EX namespace multi { }; #endif - EX config scfg; + EX config scfg_default; EX charstyle scs[MAXPLAYER]; EX bool split_screen; @@ -168,7 +168,7 @@ EX int centerplayer = -1; char* axeconfigs[24]; int numaxeconfigs; int* dzconfigs[24]; -string listkeys(int id) { +string listkeys(config& scfg, int id) { #if CAP_SDL string lk = ""; for(int i=0; i<512; i++) @@ -236,8 +236,9 @@ struct key_configurer { vector& shmupcmdtable; string caption; int setwhat; + config *which_config; - key_configurer(int sc, vector& sct, const string& caption) : sc(sc), shmupcmdtable(sct), caption(caption), setwhat(0) { + key_configurer(int sc, vector& sct, const string& caption, config& w) : sc(sc), shmupcmdtable(sct), caption(caption), setwhat(0), which_config(&w) { } void operator() () { @@ -247,7 +248,7 @@ struct key_configurer { getcstat = ' '; for(int i=0; i1 && i == (setwhat&15) ? '?' : 0) : 'a'+i); else dialog::addBreak(100); @@ -264,7 +265,7 @@ struct key_configurer { if(!setwhat) dialog::handleNavigation(sym, uni); if(sym) { if(setwhat) { - scfg.keyaction[sym] = setwhat; + which_config->keyaction[sym] = setwhat; setwhat = 0; } else if(uni >= 'a' && uni < 'a' + isize(shmupcmdtable) && shmupcmdtable[uni-'a'][0]) @@ -282,7 +283,7 @@ struct key_configurer { int joyid = ev.jbutton.which; int button = ev.jbutton.button; if(joyid < 8 && button < 32) - scfg.joyaction[joyid][button] = setwhat; + which_config->joyaction[joyid][button] = setwhat; setwhat = 0; return true; } @@ -297,7 +298,7 @@ struct key_configurer { if(ev.jhat.value == SDL_HAT_LEFT) dir = 3; printf("%d %d %d\n", joyid, hat, dir); if(joyid < 8 && hat < 4 && dir < 4) { - scfg.hataction[joyid][hat][dir] = setwhat; + which_config->hataction[joyid][hat][dir] = setwhat; setwhat = 0; return true; } @@ -309,7 +310,11 @@ struct key_configurer { }; EX reaction_t get_key_configurer(int sc, vector& sct, string caption) { - return key_configurer(sc, sct, caption); + return key_configurer(sc, sct, caption, scfg_default); + } + +EX reaction_t get_key_configurer(int sc, vector& sct, string caption, config &cfg) { + return key_configurer(sc, sct, caption, cfg); } EX reaction_t get_key_configurer(int sc, vector& sct) { @@ -320,8 +325,9 @@ EX reaction_t get_key_configurer(int sc, vector& sct) { sc == 5 ? XLAT("configure player 4") : sc == 6 ? XLAT("configure player 5") : sc == 7 ? XLAT("configure player 6") : - sc == 8 ? XLAT("configure player 7") : "" - ); + sc == 8 ? XLAT("configure player 7") : "", + scfg_default + ); } #if CAP_SDLJOY @@ -329,7 +335,8 @@ struct joy_configurer { bool shmupcfg, racecfg; int playercfg; - joy_configurer(int playercfg) : playercfg(playercfg) {} + config& scfg; + joy_configurer(int playercfg, config& scfg) : playercfg(playercfg), scfg(scfg) {} void operator() () { dialog::init(); @@ -486,7 +493,7 @@ struct shmup_configurer { else if(uni == '6') pushScreen(get_key_configurer(7, cmdlist)); else if(uni == '7') pushScreen(get_key_configurer(8, cmdlist)); #if CAP_SDLJOY - else if(uni == 'j') pushScreen(joy_configurer(players)); + else if(uni == 'j') pushScreen(joy_configurer(players, scfg_default)); #endif else if(uni == 'a') multi::alwaysuse = !multi::alwaysuse; #if CAP_SDLJOY @@ -577,6 +584,7 @@ void pressaction(int id) { } EX bool notremapped(int sym) { + auto& scfg = scfg_default; int k = scfg.keyaction[sym]; if(k == 0) return true; k /= 16; @@ -584,7 +592,31 @@ EX bool notremapped(int sym) { return k > multi::players; } +EX void sconfig_savers(config& scfg, string prefix) { + // unfortunately we cannot use key names here because SDL is not yet initialized + for(int i=0; i<512; i++) + addsaver(scfg.keyaction[i], prefix + string("key:")+its(i)); + + for(int i=0; ieditable("auto-adjust dual-focus projections", 'f'); addsaver(alwaysuse, "use configured keys"); - // unfortunately we cannot use key names here because SDL is not yet initialized - for(int i=0; i<512; i++) - addsaver(scfg.keyaction[i], string("key:")+its(i)); - for(int i=0; i