home · contact · privacy
Made draw_info_win() use new center_offset () for scrolling.
[plomrogue] / src / draw_wins.c
index 197b7c383aa4f467d594535ef3790c70822e4306..fcdda055ac024de1faa93b4ec4c5aa36c3c51508 100644 (file)
@@ -104,21 +104,15 @@ extern void draw_map_win (struct Win * win) {
 extern void draw_info_win (struct Win * win) {
 // Draw info window by appending win->data integer value to "Turn: " display.
   struct World * world = (struct World *) win->data;
-  uint16_t count = world->turn;
   char text[100];
-  snprintf(text, 100, "Turn: %d", count);
+  snprintf(text, 100, "Turn: %d\nHitpoints: %d", world->turn, world->player->hitpoints);
   draw_with_linebreaks(win, text, 0); }
 
 extern void draw_keys_win (struct Win * win) {
 // Draw keybindings window.
   struct World * world = (struct World *) win->data;
-  uint16_t offset = 0, y, x;
-  if (world->keyswindata->max >= win->frame.size.y) {
-    if (world->keyswindata->select > win->frame.size.y / 2) {
-      if (world->keyswindata->select < (world->keyswindata->max - (win->frame.size.y / 2)))
-        offset = world->keyswindata->select - (win->frame.size.y / 2);
-      else
-        offset = world->keyswindata->max - win->frame.size.y + 1; } }
+  uint16_t offset, y, x;
+  offset = center_offset (world->keyswindata->select, world->keyswindata->max, win->frame.size.y - 1);
   uint8_t keydescwidth = 9 + 1; // max length assured by get_keyname() + \0
   char * keydesc = malloc(keydescwidth), * keyname;
   attr_t attri;