Merge pull request #537 from NQNStudios:screen-shift-keys
This makes it so arrow keys/numpad can control screen shift when it's available. When this preference is enabled, #482 will not be an issue (Fix #482). But the player will also miss out on cases where adjacent targeting would be a good thing. I haven't done anything smart to determine whether one mode or the other is better on a case-by-case basis.
This commit is contained in:
@@ -41,7 +41,13 @@
|
||||
<led name='slow' relative='pos pos-in' anchor='med' top='0' left='15'>Slow</led>
|
||||
<led name='snail' relative='pos pos-in' anchor='slow' top='0' left='15'>Quite Slow</led>
|
||||
</group>
|
||||
<text name='misc-head' size='large' relative='pos-in pos' anchor='spd-head' top='30' left='0' width='182' height='17'>Miscellaneous:</text>
|
||||
<text name='keyshift-head' size='large' relative='pos-in pos' anchor='spd-head' top='30' left='0' width='182' height='17'>When targeting, directional keys should:</text>
|
||||
<group name='keyshift-options'>
|
||||
<led name='target-adjacent' relative='pos-in pos' anchor='keyshift-head' top='4' left='15'>Select adjacent tiles</led>
|
||||
<led name='screen-shift' relative='pos pos-in' anchor='target-adjacent' top='0' left='15'>Move the screen</led>
|
||||
</group>
|
||||
<text name='keyshift-note' size='large' relative='pos-in pos' anchor='keyshift-head' top='20' left='15' width='300' height='17'>(Holding Shift while using directional keys will do the opposite.)</text>
|
||||
<text name='misc-head' size='large' relative='neg pos' anchor='keyshift-note' top='15' left='15' width='182' height='17'>Miscellaneous:</text>
|
||||
<led name='nosound' relative='pos-in pos' anchor='misc-head' top='6' left='15'>No Sounds</led>
|
||||
<led name='repeatdesc' relative='pos-in pos' rel-anchor='prev' top='10' left='0'>Show room descriptions more than once</led>
|
||||
<led name='easier' relative='pos-in pos' rel-anchor='prev' top='10' left='0'>Make game easier (monsters much weaker)</led>
|
||||
|
@@ -1283,6 +1283,9 @@ static void handle_party_death() {
|
||||
}
|
||||
|
||||
void screen_shift(int dx, int dy, bool& need_redraw) {
|
||||
if(abs(dx) + abs(dy) == 0)
|
||||
return;
|
||||
|
||||
if(recording){
|
||||
std::map<std::string,std::string> info;
|
||||
info["dx"] = boost::lexical_cast<std::string>(dx);
|
||||
@@ -1292,8 +1295,15 @@ void screen_shift(int dx, int dy, bool& need_redraw) {
|
||||
|
||||
center.x += dx;
|
||||
center.y += dy;
|
||||
}
|
||||
|
||||
need_redraw = true;
|
||||
// If configured to move the screen with arrow keys, do it and return true
|
||||
bool handle_screen_shift(location delta, bool& need_redraw) {
|
||||
if(scrollableModes.count(overall_mode) && get_bool_pref("DirectionalKeyScrolling", false) != kb.isShiftPressed()){
|
||||
screen_shift(delta.x, delta.y, need_redraw);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void handle_print_pc_hp(int which_pc, bool& need_reprint) {
|
||||
@@ -2267,6 +2277,13 @@ bool handle_keystroke(const sf::Event& event, cFramerateLimiter& fps_limiter){
|
||||
{120,185},{150,185},{180,185},
|
||||
{120,155},{150,155},{180,135}
|
||||
};
|
||||
// Screen shift deltas ordered to correspond with keypad keys
|
||||
location screen_shift_delta[10] = {
|
||||
{0,0},{-1,1},{0,1},{1,1},
|
||||
{-1,0},{0,0},{1,0},
|
||||
{-1,-1},{0,-1},{1,-1}
|
||||
};
|
||||
|
||||
Key talk_chars[9] = {Key::L,Key::N,Key::J,Key::B,Key::S,Key::R,Key::D,Key::G,Key::A};
|
||||
Key shop_chars[8] = {Key::A,Key::B,Key::C,Key::D,Key::E,Key::F,Key::G,Key::H};
|
||||
|
||||
@@ -2388,11 +2405,14 @@ bool handle_keystroke(const sf::Event& event, cFramerateLimiter& fps_limiter){
|
||||
chr2 = Key::Z;
|
||||
}
|
||||
else {
|
||||
pass_point = mainPtr.mapCoordsToPixel(terrain_click[i], mainView);
|
||||
pass_event.mouseButton.x = pass_point.x;
|
||||
pass_event.mouseButton.y = pass_point.y;
|
||||
are_done = handle_action(pass_event, fps_limiter);
|
||||
return are_done;
|
||||
if(!handle_screen_shift(screen_shift_delta[i], need_redraw)){
|
||||
// Directional keys simulate directional click
|
||||
pass_point = mainPtr.mapCoordsToPixel(terrain_click[i], mainView);
|
||||
pass_event.mouseButton.x = pass_point.x;
|
||||
pass_event.mouseButton.y = pass_point.y;
|
||||
are_done = handle_action(pass_event, fps_limiter);
|
||||
return are_done;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -64,6 +64,7 @@ void handle_rename_pc();
|
||||
void handle_begin_look(bool right_button, bool& need_redraw, bool& need_reprint);
|
||||
void handle_look(location destination, bool right_button, eKeyMod mods, bool& need_redraw, bool& need_reprint);
|
||||
void screen_shift(int dx, int dy, bool& need_redraw);
|
||||
bool handle_screen_shift(location delta, bool& need_redraw);
|
||||
void handle_rest(bool& need_redraw, bool& need_reprint);
|
||||
void handle_spellcast(eSkill which_type, bool& did_something, bool& need_redraw, bool& need_reprint, bool record = true);
|
||||
void handle_target_space(location destination, bool& did_something, bool& need_redraw, bool& need_reprint);
|
||||
|
@@ -1185,6 +1185,7 @@ static bool prefs_event_filter (cDialog& me, std::string id, eKeyMod) {
|
||||
else if(cur_display_mode == "br") set_pref("DisplayMode", 4);
|
||||
else if(cur_display_mode == "win") set_pref("DisplayMode", 5);
|
||||
set_pref("PlaySounds", dynamic_cast<cLed&>(me["nosound"]).getState() == led_off);
|
||||
set_pref("DirectionalKeyScrolling", dynamic_cast<cLed&>(me["screen-shift"]).getState() != led_off);
|
||||
set_pref("RepeatRoomDescriptions", dynamic_cast<cLed&>(me["repeatdesc"]).getState() != led_off);
|
||||
set_pref("ShowInstantHelp", dynamic_cast<cLed&>(me["nohelp"]).getState() == led_off);
|
||||
|
||||
@@ -1304,6 +1305,13 @@ void pick_preferences(bool record) {
|
||||
break;
|
||||
}
|
||||
|
||||
cLedGroup& keyshiftOptions = dynamic_cast<cLedGroup&>(prefsDlog["keyshift-options"]);
|
||||
if(get_bool_pref("DirectionalKeyScrolling", false)){
|
||||
keyshiftOptions.setSelected("screen-shift");
|
||||
}else{
|
||||
keyshiftOptions.setSelected("target-adjacent");
|
||||
}
|
||||
|
||||
cLedGroup& uiScale = dynamic_cast<cLedGroup&>(prefsDlog["scaleui"]);
|
||||
double ui_scale = get_ui_scale();
|
||||
if (ui_scale>0.95 && ui_scale<1.05) uiScale.setSelected("1");
|
||||
|
@@ -975,6 +975,18 @@ location terrain_click[8] = {
|
||||
{120,185}, // west
|
||||
{120,155}, // northwest
|
||||
};
|
||||
// Screen shift deltas ordered to correspond with eDirection
|
||||
// TODO screen_shift_delta is duplicated (with different ordering) in boe.actions.cpp
|
||||
location screen_shift_delta[8] = {
|
||||
{0,-1}, // north
|
||||
{1,-1}, // northeast
|
||||
{1,0}, // east
|
||||
{1,1}, // southeast
|
||||
{0,1}, // south
|
||||
{-1,1}, // southwest
|
||||
{-1,0}, // west
|
||||
{-1,-1}, // northwest
|
||||
};
|
||||
|
||||
static void fire_delayed_key(Key code) {
|
||||
bool isUpPressed = delayed_keys[Key::Up] > 0;
|
||||
@@ -1015,11 +1027,18 @@ static void fire_delayed_key(Key code) {
|
||||
}
|
||||
|
||||
if(dir != -1){
|
||||
sf::Event pass_event = {sf::Event::MouseButtonPressed};
|
||||
location pass_point = mainPtr.mapCoordsToPixel(terrain_click[dir], mainView);
|
||||
pass_event.mouseButton.x = pass_point.x;
|
||||
pass_event.mouseButton.y = pass_point.y;
|
||||
queue_fake_event(pass_event);
|
||||
bool need_redraw = false;
|
||||
if(handle_screen_shift(screen_shift_delta[dir], need_redraw)){
|
||||
if(need_redraw){
|
||||
draw_terrain();
|
||||
}
|
||||
}else{
|
||||
sf::Event pass_event = {sf::Event::MouseButtonPressed};
|
||||
location pass_point = mainPtr.mapCoordsToPixel(terrain_click[dir], mainView);
|
||||
pass_event.mouseButton.x = pass_point.x;
|
||||
pass_event.mouseButton.y = pass_point.y;
|
||||
queue_fake_event(pass_event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user