home
·
contact
·
privacy
projects
/
plomrogue
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
b4e81c0
)
Client: Add auto-center of map on player each new turn (can be toggled).
author
Christian Heller
<c.heller@plomlompom.de>
Tue, 8 Jul 2014 02:38:02 +0000
(
04:38
+0200)
committer
Christian Heller
<c.heller@plomlompom.de>
Tue, 8 Jul 2014 02:38:02 +0000
(
04:38
+0200)
13 files changed:
confclient/commands
patch
|
blob
|
history
confclient/interface_conf
patch
|
blob
|
history
confclient/single_wins/info
patch
|
blob
|
history
confclient/single_wins/inventory
patch
|
blob
|
history
confclient/single_wins/log
patch
|
blob
|
history
confclient/single_wins/map
patch
|
blob
|
history
src/client/control.c
patch
|
blob
|
history
src/client/io.c
patch
|
blob
|
history
src/client/io.h
patch
|
blob
|
history
src/client/main.c
patch
|
blob
|
history
src/client/map.c
patch
|
blob
|
history
src/client/map.h
patch
|
blob
|
history
src/client/world.h
patch
|
blob
|
history
diff --git
a/confclient/commands
b/confclient/commands
index 7cfa785ced11320c5c46e3fcdd5c03007a715b2b..e4efa8a4b832a681f2a3cd1229a748c8d074b31e 100644
(file)
--- a/
confclient/commands
+++ b/
confclient/commands
@@
-179,3
+179,6
@@
DESCRIPTION 'window geometry keys'
COMMAND to_wk_keywin
DESCRIPTION 'window keybinding keys'
COMMAND to_wk_keywin
DESCRIPTION 'window keybinding keys'
+
+COMMAND to_autofocus
+DESCRIPTION 'toggle auto map center'
diff --git
a/confclient/interface_conf
b/confclient/interface_conf
index 156aa4edbcec7eb5cf020469ae414c7e349610f9..8a4a36fd910339937311035872a2dcb295f2af55 100644
(file)
--- a/
confclient/interface_conf
+++ b/
confclient/interface_conf
@@
-100,6
+100,7
@@
KEY 258 map_d
KEY 260 map_l
KEY 261 map_r
KEY 46 map_c
KEY 260 map_l
KEY 261 map_r
KEY 46 map_c
+KEY 70 to_autofocus
WINDOW 0
NAME 'Global keys'
WINDOW 0
NAME 'Global keys'
diff --git
a/confclient/single_wins/info
b/confclient/single_wins/info
index 45c9457b7e26ea9f1917011882ab9c2702f268f1..80343ef125e7345a7cd30eb46f7d8acc6cfc632b 100644
(file)
--- a/
confclient/single_wins/info
+++ b/
confclient/single_wins/info
@@
-26,6
+26,7
@@
KEY 119 move_w
KEY 46 map_c
KEY 68 drop
KEY 117 use
KEY 46 map_c
KEY 68 drop
KEY 117 use
+KEY 70 to_autofocus
KEYBINDINGS 'wingeom'
KEY 258 shift_f
KEYBINDINGS 'wingeom'
KEY 258 shift_f
diff --git
a/confclient/single_wins/inventory
b/confclient/single_wins/inventory
index 8e774fbaadc432208b12c96d353b120a4de8cba1..c9e893093226adc2532e6d1f8ce6ba374c583b49 100644
(file)
--- a/
confclient/single_wins/inventory
+++ b/
confclient/single_wins/inventory
@@
-26,6
+26,7
@@
KEY 119 move_w
KEY 46 map_c
KEY 68 drop
KEY 117 use
KEY 46 map_c
KEY 68 drop
KEY 117 use
+KEY 70 to_autofocus
KEYBINDINGS 'wingeom'
KEY 258 shift_f
KEYBINDINGS 'wingeom'
KEY 258 shift_f
diff --git
a/confclient/single_wins/log
b/confclient/single_wins/log
index 52429b9c6bfd9a5f15ce4ef8be64d8ec76eb48b5..9944687a2a9846e272c60bafc59692733ac96250 100644
(file)
--- a/
confclient/single_wins/log
+++ b/
confclient/single_wins/log
@@
-26,6
+26,7
@@
KEY 119 move_w
KEY 46 map_c
KEY 68 drop
KEY 117 use
KEY 46 map_c
KEY 68 drop
KEY 117 use
+KEY 70 to_autofocus
KEYBINDINGS 'wingeom'
KEY 258 shift_f
KEYBINDINGS 'wingeom'
KEY 258 shift_f
diff --git
a/confclient/single_wins/map
b/confclient/single_wins/map
index bc639554e00944c189c93250517ff6f7d7e1d0a3..d3a48bbdd94d2b04700e2ce0fa9071b293ab80d5 100644
(file)
--- a/
confclient/single_wins/map
+++ b/
confclient/single_wins/map
@@
-26,6
+26,7
@@
KEY 119 move_w
KEY 46 map_c
KEY 68 drop
KEY 117 use
KEY 46 map_c
KEY 68 drop
KEY 117 use
+KEY 70 to_autofocus
KEYBINDINGS 'wingeom'
KEY 258 shift_f
KEYBINDINGS 'wingeom'
KEY 258 shift_f
diff --git
a/src/client/control.c
b/src/client/control.c
index d5d8d9e7935441848a57ccb9011a97509dee6854..43041eaef820b02ad60f938211cb45ffd2d9f853 100644
(file)
--- a/
src/client/control.c
+++ b/
src/client/control.c
@@
-10,7
+10,7
@@
#include "keybindings.h" /* get_command_to_keycode(), get_keycode_to_command(),
* mod_selected_keyb(), move_keyb_selection()
*/
#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(),
#include "wincontrol.h" /* shift_active_win(), resize_active_win(),
* toggle_win_size_type(), toggle_window(),
* cycle_active_win(), scroll_v_screen(),
@@
-107,6
+107,7
@@
static uint8_t try_2args(struct Command * command, char * match,
static uint8_t try_client_commands(struct Command * command)
{
return ( try_0args(command, "map_c", map_center)
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')
|| try_1args(command, "map_u", map_scroll, '8')
|| try_1args(command, "map_d", map_scroll, '2')
|| try_1args(command, "map_r", map_scroll, '6')
diff --git
a/src/client/io.c
b/src/client/io.c
index e3047234311aa19f4aaa5a154fc240b6e55525af..31387f26d8466aeade7e293d2be5d06b0937aad2 100644
(file)
--- a/
src/client/io.c
+++ b/
src/client/io.c
@@
-68,8
+68,8
@@
static FILE * changed_worldstate_file(char * path);
* out file wasn't read for supposedly not having changed since a last
* read_world() call.
*
* 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();
*/
static uint8_t read_world();
@@
-281,6
+281,7
@@
extern char * io_loop()
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;
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)
{
time_t last_server_answer_time = time(0);
while (1)
{
@@
-292,8
+293,13
@@
extern char * io_loop()
world.winch = 0;
change_in_client++;
}
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;
draw_all_wins();
}
change_in_client = 0;
diff --git
a/src/client/io.h
b/src/client/io.h
index 4db04cf2594753769161b6881ad082a0ca13c0d9..072a2174de0ea07077b3cc2809be2f741bdf540d 100644
(file)
--- a/
src/client/io.h
+++ b/
src/client/io.h
@@
-25,7
+25,8
@@
extern void send(char * msg);
* 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
* 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();
*/
extern char * io_loop();
diff --git
a/src/client/main.c
b/src/client/main.c
index 1821e57f9205007d596f286e794cb0eba1896892..f2051a41ddb10956903887653aa798569fee48e3 100644
(file)
--- a/
src/client/main.c
+++ b/
src/client/main.c
@@
-52,6
+52,7
@@
int main(int argc, char * argv[])
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. */
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;
/* Set handler for terminal window resizing. */
struct sigaction act;
diff --git
a/src/client/map.c
b/src/client/map.c
index 7c2dcc384590df51b3dcfa46c9bcb577a6755e27..2a1d66f300a90d02eb09a0d9752b16dbbadfff38 100644
(file)
--- a/
src/client/map.c
+++ b/
src/client/map.c
@@
-45,3
+45,10
@@
extern void map_center()
win_map->center.y = world.player_pos.y;
win_map->center.x = world.player_pos.x * 2;
}
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;
+}
diff --git
a/src/client/map.h
b/src/client/map.h
index 6cef27edf91801864d138797d2935013c073afdb..f8c6c9f361816ffb0620ab50c089ba495755a958 100644
(file)
--- a/
src/client/map.h
+++ b/
src/client/map.h
@@
-14,6
+14,7
@@
extern void map_scroll(char d);
/* Center map window on player (even if it is non-visible). */
extern void map_center();
/* 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
#endif
diff --git
a/src/client/world.h
b/src/client/world.h
index 8d490c85d9bd359c4330e492a88d8e8420df7627..5d5017317991abb586d4548ffad9ba234a360b46 100644
(file)
--- a/
src/client/world.h
+++ b/
src/client/world.h
@@
-38,6
+38,7
@@
struct World
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 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 */
};
};