1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-11-23 21:07:17 +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 {
void change_default_key(int key, int val) {
char* t = multi::scfg.keyaction;
char* t = scfg_ads.keyaction;
t[key] = val;
#if CAP_CONFIG
set_saver_default(t[key]);
#endif
}
void set_default_keys() {
clear_config(scfg_ads);
change_default_key('s', 16 + 0);
change_default_key('a', 16 + 1);
change_default_key('w', 16 + 2);
@ -65,6 +63,7 @@ void set_default_keys() {
change_default_key('i', 16 + 9);
change_default_key('k', 16 + 10);
change_default_key('l', 16 + 11);
sconfig_savers(scfg_ads, "ads");
}
void restart() {
@ -132,8 +131,6 @@ void run_ads_game() {
}
void set_config() {
set_default_keys();
nohelp = true;
nomenukey = true;
no_find_player = true;
@ -266,5 +263,7 @@ auto hook1=
});
#endif
auto hook2 = addHook(hooks_configfile, 100, set_default_keys);
}
}

View File

@ -2,6 +2,8 @@ namespace hr {
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" };
void fire() {
@ -80,7 +82,7 @@ void fire() {
bool handleKey(int sym, int uni) {
if(cmode & sm::NORMAL) {
char* t = multi::scfg.keyaction;
char* t = scfg_ads.keyaction;
if(t[sym] >= 16 && t[sym] < 32) return true;
if(sym == 'v') pushScreen(game_menu);
if(sym == SDLK_ESCAPE) pushScreen(game_menu);
@ -139,7 +141,7 @@ ld read_movement() {
}
bool ads_turn(int idelta) {
multi::handleInput(idelta);
multi::handleInput(idelta, scfg_ads);
ld delta = idelta / 1000.;
if(!(cmode & sm::NORMAL)) return false;

View File

@ -181,7 +181,7 @@ void game_menu() {
dialog::add_action([] { current.T = Id; vctrV = Id; });
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
add_edit(effvolume);

View File

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

View File

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