1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-11-27 14:37:16 +00:00

used separate keyconfigs in bringris, nilrider and ads

This commit is contained in:
Zeno Rogue 2023-08-06 11:51:43 +02:00
parent 34574ad050
commit dfb3626568
5 changed files with 27 additions and 27 deletions

View File

@ -45,14 +45,12 @@ namespace hr {
namespace ads_game { namespace ads_game {
void change_default_key(int key, int val) { void change_default_key(int key, int val) {
char* t = multi::scfg.keyaction; char* t = scfg_ads.keyaction;
t[key] = val; t[key] = val;
#if CAP_CONFIG
set_saver_default(t[key]);
#endif
} }
void set_default_keys() { void set_default_keys() {
clear_config(scfg_ads);
change_default_key('s', 16 + 0); change_default_key('s', 16 + 0);
change_default_key('a', 16 + 1); change_default_key('a', 16 + 1);
change_default_key('w', 16 + 2); change_default_key('w', 16 + 2);
@ -65,6 +63,7 @@ void set_default_keys() {
change_default_key('i', 16 + 9); change_default_key('i', 16 + 9);
change_default_key('k', 16 + 10); change_default_key('k', 16 + 10);
change_default_key('l', 16 + 11); change_default_key('l', 16 + 11);
sconfig_savers(scfg_ads, "ads");
} }
void restart() { void restart() {
@ -132,8 +131,6 @@ void run_ads_game() {
} }
void set_config() { void set_config() {
set_default_keys();
nohelp = true; nohelp = true;
nomenukey = true; nomenukey = true;
no_find_player = true; no_find_player = true;
@ -266,5 +263,7 @@ auto hook1=
}); });
#endif #endif
auto hook2 = addHook(hooks_configfile, 100, set_default_keys);
} }
} }

View File

@ -2,6 +2,8 @@ namespace hr {
namespace ads_game { namespace ads_game {
multi::config scfg_ads;
vector<string> move_names = { "acc down", "acc left", "acc up", "acc right", "fire", "pause", "display times", "switch spin", "menu", "[paused] future", "(paused] past", "[paused] move switch" }; vector<string> move_names = { "acc down", "acc left", "acc up", "acc right", "fire", "pause", "display times", "switch spin", "menu", "[paused] future", "(paused] past", "[paused] move switch" };
void fire() { void fire() {
@ -80,7 +82,7 @@ void fire() {
bool handleKey(int sym, int uni) { bool handleKey(int sym, int uni) {
if(cmode & sm::NORMAL) { if(cmode & sm::NORMAL) {
char* t = multi::scfg.keyaction; char* t = scfg_ads.keyaction;
if(t[sym] >= 16 && t[sym] < 32) return true; if(t[sym] >= 16 && t[sym] < 32) return true;
if(sym == 'v') pushScreen(game_menu); if(sym == 'v') pushScreen(game_menu);
if(sym == SDLK_ESCAPE) pushScreen(game_menu); if(sym == SDLK_ESCAPE) pushScreen(game_menu);
@ -139,7 +141,7 @@ ld read_movement() {
} }
bool ads_turn(int idelta) { bool ads_turn(int idelta) {
multi::handleInput(idelta); multi::handleInput(idelta, scfg_ads);
ld delta = idelta / 1000.; ld delta = idelta / 1000.;
if(!(cmode & sm::NORMAL)) return false; if(!(cmode & sm::NORMAL)) return false;

View File

@ -181,7 +181,7 @@ void game_menu() {
dialog::add_action([] { current.T = Id; vctrV = Id; }); dialog::add_action([] { current.T = Id; vctrV = Id; });
dialog::addItem("configure keys", 'k'); dialog::addItem("configure keys", 'k');
dialog::add_action_push(multi::get_key_configurer(1, move_names, "Relative Hell keys")); dialog::add_action_push(multi::get_key_configurer(1, move_names, "Relative Hell keys", scfg_ads));
#if CAP_AUDIO #if CAP_AUDIO
add_edit(effvolume); add_edit(effvolume);

View File

@ -61,6 +61,8 @@ namespace subquotient {
namespace bringris { namespace bringris {
multi::config scfg_bringris;
struct bgeometry { struct bgeometry {
string name; string name;
string cap; string cap;
@ -1346,7 +1348,7 @@ void settings_menu() {
dialog::addItem("visuals & Virtual Reality", 'v'); dialog::addItem("visuals & Virtual Reality", 'v');
dialog::add_action_push(visual_menu); dialog::add_action_push(visual_menu);
dialog::addItem("configure keys", 'k'); dialog::addItem("configure keys", 'k');
dialog::add_action_push(multi::get_key_configurer(1, move_names, "Bringris keys")); dialog::add_action_push(multi::get_key_configurer(1, move_names, "Bringris keys", scfg_bringris));
#if CAP_AUDIO #if CAP_AUDIO
add_edit(effvolume); add_edit(effvolume);
@ -1612,7 +1614,7 @@ void run() {
explore = false; explore = false;
if(state == tsFalling && !paused) { if(state == tsFalling && !paused) {
multi::handleInput(0); multi::handleInput(0, scfg_bringris);
bool consumed = false; bool consumed = false;
for(int i=0; i<bmLast; i++) for(int i=0; i<bmLast; i++)
if(multi::actionspressed[16+i] && !multi::lactionpressed[16+i]) { if(multi::actionspressed[16+i] && !multi::lactionpressed[16+i]) {
@ -2038,16 +2040,12 @@ int args() {
} }
void change_default_key(int key, int val) { void change_default_key(int key, int val) {
char* t = multi::scfg.keyaction; char* t = scfg_bringris.keyaction;
t[key] = val; t[key] = val;
set_saver_default(t[key]);
} }
void default_config() { void default_config() {
for(int i=0; i<512; i++) clear_config(scfg_bringris);
if(multi::scfg.keyaction[i] >= 16 && multi::scfg.keyaction[i] < 32)
change_default_key(i, 0);
change_default_key('s', 16 + 0); change_default_key('s', 16 + 0);
change_default_key('a', 16 + 1); change_default_key('a', 16 + 1);
change_default_key('w', 16 + 2); change_default_key('w', 16 + 2);
@ -2057,6 +2055,7 @@ void default_config() {
change_default_key(' ', 16 + 6); change_default_key(' ', 16 + 6);
change_default_key('\r',16 + 7); change_default_key('\r',16 + 7);
change_default_key('p', 16 + 8); change_default_key('p', 16 + 8);
sconfig_savers(scfg_bringris, "bringris");
addsaver(bgeom, "bringris-geometry"); addsaver(bgeom, "bringris-geometry");
addsaver(use_raycaster, "bringris-ray"); addsaver(use_raycaster, "bringris-ray");

View File

@ -39,6 +39,8 @@
namespace nilrider { namespace nilrider {
multi::config scfg_nilrider;
/** is the game paused? */ /** is the game paused? */
bool paused = false; bool paused = false;
@ -83,7 +85,7 @@ void sync_music(eLand l) {
bool turn(int delta) { bool turn(int delta) {
if(planning_mode && !view_replay) return false; if(planning_mode && !view_replay) return false;
multi::get_actions(); multi::get_actions(scfg_nilrider);
auto& a = multi::actionspressed; auto& a = multi::actionspressed;
auto& la = multi::lactionpressed; auto& la = multi::lactionpressed;
@ -246,7 +248,7 @@ void run() {
dialog::add_key_action(PSEUDOKEY_SIM, toggle_replay); dialog::add_key_action(PSEUDOKEY_SIM, toggle_replay);
dialog::display(); dialog::display();
char* t = multi::scfg.keyaction; char* t = scfg_nilrider.keyaction;
for(int i=1; i<512; i++) { for(int i=1; i<512; i++) {
auto& ka = dialog::key_actions; auto& ka = dialog::key_actions;
if(t[i] == 16+5) ka[i] = ka[PSEUDOKEY_PAUSE]; if(t[i] == 16+5) ka[i] = ka[PSEUDOKEY_PAUSE];
@ -363,7 +365,7 @@ void settings() {
dialog::addItem("projection", 'P'); dialog::addItem("projection", 'P');
dialog::add_action_push(nil_projection); dialog::add_action_push(nil_projection);
dialog::addItem("configure keys", 'k'); dialog::addItem("configure keys", 'k');
dialog::add_action_push(multi::get_key_configurer(1, move_names, "Nilrider keys")); dialog::add_action_push(multi::get_key_configurer(1, move_names, "Nilrider keys", scfg_nilrider));
#if CAP_AUDIO #if CAP_AUDIO
add_edit(effvolume); add_edit(effvolume);
@ -540,17 +542,13 @@ void main_menu() {
bool on; bool on;
void change_default_key(int key, int val) { void change_default_key(int key, int val) {
char* t = multi::scfg.keyaction; char* t = scfg_nilrider.keyaction;
t[key] = val; t[key] = val;
#if CAP_CONFIG
set_saver_default(t[key]);
#endif
} }
void nilrider_keys() { void nilrider_keys() {
for(int i=0; i<512; i++) clear_config(scfg_nilrider);
if(multi::scfg.keyaction[i] >= 16 && multi::scfg.keyaction[i] < 32)
change_default_key(i, 0);
change_default_key('s', 16 + 0); change_default_key('s', 16 + 0);
change_default_key('a', 16 + 1); change_default_key('a', 16 + 1);
change_default_key('w', 16 + 2); change_default_key('w', 16 + 2);
@ -564,6 +562,8 @@ void nilrider_keys() {
change_default_key('b', 16 + 6); change_default_key('b', 16 + 6);
change_default_key('r', 16 + 7); change_default_key('r', 16 + 7);
change_default_key('v', 16 + 8); change_default_key('v', 16 + 8);
sconfig_savers(scfg_nilrider, "nilrider");
} }
bool nilrider_music(eLand& l) { bool nilrider_music(eLand& l) {