From 6b603bc644f8d855dc6cbb85b9a6dbb3403c2b48 Mon Sep 17 00:00:00 2001 From: ymber Date: Thu, 2 Apr 2020 17:52:12 +0100 Subject: [PATCH 1/3] Update embark-profile-name tweak --- plugins/tweak/tweaks/embark-profile-name.h | 27 +++++++++++----------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/plugins/tweak/tweaks/embark-profile-name.h b/plugins/tweak/tweaks/embark-profile-name.h index aa151588e..f9cb45f4b 100644 --- a/plugins/tweak/tweaks/embark-profile-name.h +++ b/plugins/tweak/tweaks/embark-profile-name.h @@ -1,22 +1,21 @@ #include "df/viewscreen_setupdwarfgamest.h" -using namespace DFHack; + struct embark_profile_name_hook : df::viewscreen_setupdwarfgamest { typedef df::viewscreen_setupdwarfgamest interpose_base; - DEFINE_VMETHOD_INTERPOSE(void, feed, (std::set *input)) - { + + DEFINE_VMETHOD_INTERPOSE( void, feed, ( std::set *input ) ) { int ch = -1; - for (auto it = input->begin(); ch == -1 && it != input->end(); ++it) - ch = Screen::keyToChar(*it); - if (in_save_profile && ch >= 32 && ch <= 126) - { - profile_name.push_back((char)ch); + for( auto it = input->begin(); ch == -1 && it != input->end(); ++it ) { + ch = Screen::keyToChar( *it ); } - else - { - if (input->count(df::interface_key::LEAVESCREEN)) - input->insert(df::interface_key::SETUPGAME_SAVE_PROFILE_ABORT); - INTERPOSE_NEXT(feed)(input); + // Intercept all printable characters except space. + // If space is intercepted the shift-space abort key will not work. + if( in_save_profile && ch >= 33 && ch <= 126 ) { + profile_name.push_back( ( char )ch ); + } else { + INTERPOSE_NEXT( feed )( input ); } } }; -IMPLEMENT_VMETHOD_INTERPOSE(embark_profile_name_hook, feed); + +IMPLEMENT_VMETHOD_INTERPOSE( embark_profile_name_hook, feed ); From 5d032b3d9c4cbd69c1a5ea79ca54e58f40336c92 Mon Sep 17 00:00:00 2001 From: ymber Date: Sat, 4 Apr 2020 11:12:51 +0100 Subject: [PATCH 2/3] Restore esc abort key --- plugins/tweak/tweaks/embark-profile-name.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/tweak/tweaks/embark-profile-name.h b/plugins/tweak/tweaks/embark-profile-name.h index f9cb45f4b..74501a7e0 100644 --- a/plugins/tweak/tweaks/embark-profile-name.h +++ b/plugins/tweak/tweaks/embark-profile-name.h @@ -13,6 +13,9 @@ struct embark_profile_name_hook : df::viewscreen_setupdwarfgamest { if( in_save_profile && ch >= 33 && ch <= 126 ) { profile_name.push_back( ( char )ch ); } else { + if( input->count( df::interface_key::LEAVESCREEN ) ) { + input->insert( df::interface_key::SETUPGAME_SAVE_PROFILE_ABORT ); + } INTERPOSE_NEXT( feed )( input ); } } From 9b813aab4902a3dbd2b8148ebd4fe7f32b4957a7 Mon Sep 17 00:00:00 2001 From: ymber Date: Sat, 4 Apr 2020 11:17:10 +0100 Subject: [PATCH 3/3] Restore style --- plugins/tweak/tweaks/embark-profile-name.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/plugins/tweak/tweaks/embark-profile-name.h b/plugins/tweak/tweaks/embark-profile-name.h index 74501a7e0..28ca73ded 100644 --- a/plugins/tweak/tweaks/embark-profile-name.h +++ b/plugins/tweak/tweaks/embark-profile-name.h @@ -3,22 +3,22 @@ struct embark_profile_name_hook : df::viewscreen_setupdwarfgamest { typedef df::viewscreen_setupdwarfgamest interpose_base; - DEFINE_VMETHOD_INTERPOSE( void, feed, ( std::set *input ) ) { + DEFINE_VMETHOD_INTERPOSE(void, feed, (std::set *input)) { int ch = -1; - for( auto it = input->begin(); ch == -1 && it != input->end(); ++it ) { - ch = Screen::keyToChar( *it ); + for (auto it = input->begin(); ch == -1 && it != input->end(); ++it) { + ch = Screen::keyToChar(*it); } // Intercept all printable characters except space. // If space is intercepted the shift-space abort key will not work. - if( in_save_profile && ch >= 33 && ch <= 126 ) { - profile_name.push_back( ( char )ch ); + if (in_save_profile && ch >= 33 && ch <= 126) { + profile_name.push_back((char)ch); } else { - if( input->count( df::interface_key::LEAVESCREEN ) ) { - input->insert( df::interface_key::SETUPGAME_SAVE_PROFILE_ABORT ); + if (input->count(df::interface_key::LEAVESCREEN)) { + input->insert(df::interface_key::SETUPGAME_SAVE_PROFILE_ABORT); } - INTERPOSE_NEXT( feed )( input ); + INTERPOSE_NEXT(feed)(input); } } }; -IMPLEMENT_VMETHOD_INTERPOSE( embark_profile_name_hook, feed ); +IMPLEMENT_VMETHOD_INTERPOSE(embark_profile_name_hook, feed);