home · contact · privacy
Split roguelike.(c|h) into main.(c|h) and misc.(c|h).
[plomrogue] / src / draw_wins.c
index 197b7c383aa4f467d594535ef3790c70822e4306..dd96c36e71002212765dd4e2f37ce04e790a3950 100644 (file)
@@ -4,9 +4,11 @@
 #include <string.h>
 #include <ncurses.h>
 #include "windows.h"
-#include "roguelike.h"
+#include "misc.h"
 #include "keybindings.h"
 #include "objects_on_map.h"
+#include "map.h"
+#include "main.h"
 
 static void draw_map_objects (void *, struct Map *, struct Win *);
 
@@ -104,21 +106,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;