+
+
+
+extern void draw_log_win(struct Win * win)
+{
+ struct World * world = (struct World *) win->data;
+ draw_text_from_bottom(win, world->log);
+}
+
+
+
+extern void draw_map_win(struct Win * win)
+{
+ struct World * world = (struct World *) win->data;
+ struct Map * map = world->map;
+ struct Player * player = world->player;
+ char * cells = map->cells;
+ uint16_t width_map_av = map->size.x - map->offset.x;
+ uint16_t height_map_av = map->size.y - map->offset.y;
+ uint16_t x, y, z;
+ for (y = 0; y < win->frame.size.y; y++)
+ {
+ z = map->offset.x + (map->offset.y + y) * (map->size.x);
+ for (x = 0; x < win->frame.size.x; x++)
+ {
+ if (y < height_map_av && x < width_map_av)
+ {
+ mvwaddch(win->frame.curses_win, y, x, cells[z]);
+ z++;
+ }
+ }
+ }
+ draw_map_objects (world, (struct MapObj *) world->item, map, win);
+ draw_map_objects (world, (struct MapObj *) world->monster, map, win);
+ if ( player->pos.y >= map->offset.y
+ && player->pos.y < map->offset.y + win->frame.size.y
+ && player->pos.x >= map->offset.x
+ && player->pos.x < map->offset.x + win->frame.size.x)
+ {
+ mvwaddch(win->frame.curses_win,
+ player->pos.y - map->offset.y, player->pos.x - map->offset.x,
+ '@');
+ }
+}
+
+
+
+extern void draw_info_win(struct Win * win)
+{
+ struct World * world = (struct World *) win->data;
+ char * dsc_turn = "Turn: ";
+ char * dsc_hitpoints = "\nHitpoints: ";
+ char * dsc_score = "\nScore: ";
+ uint16_t maxl = strlen(dsc_turn) + strlen(dsc_hitpoints) + strlen(dsc_score)
+ + 10 + 5 + 10; /* max strlens of numbers to be used */
+ char text[maxl + 1];
+ sprintf(text, "%s%d%s%d%s%d",
+ dsc_turn, world->turn,
+ dsc_hitpoints, world->player->hitpoints,
+ dsc_score, world->score);
+ draw_with_linebreaks(win, text, 0);
+}
+
+
+
+extern void draw_keys_win(struct Win * win)
+{
+ char * err_hint = "Trouble with draw_scroll_hint() in draw_keys_win().";
+ struct World * world = (struct World *) win->data;
+ uint16_t n_keybs = get_n_of_keybs(world);
+ uint16_t offset = center_offset(world->keyswindata->select, n_keybs - 1,
+ win->frame.size.y - 1);
+
+ uint8_t keydescwidth = 9 + 1; /* get_name_to_keycode()'s max length + \0 */
+ char keydesc[keydescwidth];
+
+ uint16_t y, x;
+ for (y = 0; y <= n_keybs - 1 && y < win->frame.size.y; y++)
+ {
+
+ if (0 == y && offset > 0)
+ {
+ exit_err(draw_scroll_hint(&win->frame, y, offset + 1, '^'),
+ world, err_hint);
+ continue;
+ }
+ else if (win->frame.size.y == y + 1
+ && 0 < (n_keybs - 1)
+ - (win->frame.size.y + offset - 1))
+ {
+ exit_err(draw_scroll_hint(&win->frame, y,
+ (n_keybs - 1)
+ - (offset + win->frame.size.y) + 2,
+ 'v'),
+ world, err_hint);
+ continue;
+ }
+
+ attr_t attri = 0;
+ if (y == world->keyswindata->select - offset)
+ {
+ attri = A_REVERSE;
+ if (1 == world->keyswindata->edit)
+ {
+ attri = attri | A_BLINK;
+ }
+ }
+
+ struct KeyBinding * kb_p = get_keyb_of_n(world, y + offset);
+ char * keyname = get_name_to_keycode(world, kb_p->key);
+ snprintf(keydesc, keydescwidth, "%-9s", keyname);
+ free(keyname);
+ char * cmd_dsc = get_command_longdsc(world, kb_p->name);
+ for (x = 0; x < win->frame.size.x; x++)
+ {
+ if (x < strlen(keydesc))
+ {
+ mvwaddch(win->frame.curses_win, y, x, keydesc[x] | attri);
+ }
+ else if ( strlen(keydesc) < x
+ && x < strlen(cmd_dsc) + strlen(keydesc) + 1)
+ {
+ mvwaddch(win->frame.curses_win, y, x,
+ cmd_dsc[x - strlen(keydesc) - 1] | attri);
+ }
+ else
+ {
+ mvwaddch(win->frame.curses_win, y, x, ' ' | attri);
+ }
+ }
+ }
+}
+
+
+
+extern void draw_winconf(struct Win * win)
+{
+ struct World * world = (struct World *) win->data;
+ struct WinConf * wcp = get_winconf_by_win(world, win);
+ char * title = "Window configuration:\n";
+ char * h_d = "\nWidth to save: ";
+ char * h_pos = " (height in cells)";
+ char * h_neg = " (negative diff: cells to maximum height)";
+ char * w_d = "\n\nHeight to save: ";
+ char * w_pos = " (width in cells)";
+ char * w_neg = " (negative diff: cells to maximum width)";
+ char * h_t = h_pos;
+ char * w_t = w_pos;
+ if (1 == wcp->height_type)
+ {
+ h_t = h_neg;
+ }
+ if (1 == wcp->width_type)
+ {
+ w_t = w_neg;
+ }
+ uint16_t maxl = strlen(title)
+ + strlen(h_t) + strlen(h_d) + 6
+ + strlen(w_t) + strlen(w_d) + 6 + 1;
+ char text[maxl + 1];
+ sprintf(text, "%s%s%d%s%s%d%s", title, h_d, wcp->height, h_t,
+ w_d, wcp->width, w_t);
+ draw_with_linebreaks(win, text, 0);
+}