COMMAND to_wk_keywin
DESCRIPTION 'window keybinding keys'
+
+COMMAND to_autofocus
+DESCRIPTION 'toggle auto map center'
KEY 260 map_l
KEY 261 map_r
KEY 46 map_c
+KEY 70 to_autofocus
WINDOW 0
NAME 'Global keys'
KEY 46 map_c
KEY 68 drop
KEY 117 use
+KEY 70 to_autofocus
KEYBINDINGS 'wingeom'
KEY 258 shift_f
KEY 46 map_c
KEY 68 drop
KEY 117 use
+KEY 70 to_autofocus
KEYBINDINGS 'wingeom'
KEY 258 shift_f
KEY 46 map_c
KEY 68 drop
KEY 117 use
+KEY 70 to_autofocus
KEYBINDINGS 'wingeom'
KEY 258 shift_f
KEY 46 map_c
KEY 68 drop
KEY 117 use
+KEY 70 to_autofocus
KEYBINDINGS 'wingeom'
KEY 258 shift_f
#include "keybindings.h" /* get_command_to_keycode(), get_keycode_to_command(),
* mod_selected_keyb(), move_keyb_selection()
*/
-#include "map.h" /* for map_scroll(), map_center() */
+#include "map.h" /* for map_scroll(), map_center(), toggle_autofocus() */
#include "wincontrol.h" /* shift_active_win(), resize_active_win(),
* toggle_win_size_type(), toggle_window(),
* cycle_active_win(), scroll_v_screen(),
static uint8_t try_client_commands(struct Command * command)
{
return ( try_0args(command, "map_c", map_center)
+ || try_0args(command, "to_autofocus", toggle_autofocus)
|| try_1args(command, "map_u", map_scroll, '8')
|| try_1args(command, "map_d", map_scroll, '2')
|| try_1args(command, "map_r", map_scroll, '6')
* out file wasn't read for supposedly not having changed since a last
* read_world() call.
*
- * map_center() is triggered by the first successful read_world() or on turn 1,
- * so the client focuses the map window on the player on client and world start.
+ * map_center() is triggered by either, the first successful read_world() (thus
+ * on client start), or on turn 1 (thus on world start).
*/
static uint8_t read_world();
world.halfdelay = 1; /* Ensures read_world() is only called 10 */
halfdelay(world.halfdelay); /* times a second during user inactivity. */
uint8_t change_in_client = 0;
+ uint16_t last_focused_turn = world.turn;
time_t last_server_answer_time = time(0);
while (1)
{
world.winch = 0;
change_in_client++;
}
- if (read_world() || change_in_client)
+ if (change_in_client || read_world())
{
+ if (world.turn != last_focused_turn && world.focus_each_turn)
+ {
+ last_focused_turn = world.turn;
+ map_center();
+ }
draw_all_wins();
}
change_in_client = 0;
* loop ends regularly (due to the user sending a quit command), return an
* appropriate quit message to write to stdout when the client winds down. Call
* reset_windows() on receiving a SIGWINCH. Abort on assumed server death if the
- * server's out file does not get updated, even on PING requests.
+ * server's out file does not get updated, even on PING requests. Re-focus map
+ * view on player if world.focus_each_turn is set.
*/
extern char * io_loop();
keypad(world.winDB.t_screen, TRUE);
init_command_db(); /* The command DB needs to be initialized before */
load_interface_conf(); /* the interface, whose keybindings depend on it. */
+ world.focus_each_turn = 1;
/* Set handler for terminal window resizing. */
struct sigaction act;
win_map->center.y = world.player_pos.y;
win_map->center.x = world.player_pos.x * 2;
}
+
+
+
+extern void toggle_autofocus()
+{
+ world.focus_each_turn = world.focus_each_turn ? 0 : 1;
+}
/* Center map window on player (even if it is non-visible). */
extern void map_center();
-
+/* Toggle world.focus_each_turn (auto-centering of map on player each turn). */
+extern void toggle_autofocus();
#endif
uint8_t player_inventory_select; /* index of selected item in inventory */
uint8_t player_lifepoints; /* how alive the player is */
uint8_t winch; /* if set, SIGWINCH was registered; trigger reset_windows()*/
+ uint8_t focus_each_turn; /* if !0, re-focus map on player each new turn */
};