X-Git-Url: https://plomlompom.com/repos/index.html?a=blobdiff_plain;f=roguelike.c;h=9b858f3f1c872268d3d7bfa226b61ac232218515;hb=d2f20fe7cf821fb761353e8f63eaebb5bf4cbd9e;hp=894fa59095a6c071c6b2b08ccb17b5f0763dffed;hpb=20473b02ae7964d25bbe0e2aaf56b64ce5c67ddc;p=plomrogue
diff --git a/roguelike.c b/roguelike.c
index 894fa59..9b858f3 100644
--- a/roguelike.c
+++ b/roguelike.c
@@ -67,16 +67,23 @@ void save_game(struct World * world) {
void toggle_window (struct WinMeta * win_meta, struct Win * win) {
// Toggle display of window win.
- if (0 != win->curses)
+ if (0 != win->frame.curses_win)
suspend_window(win_meta, win);
else
append_window(win_meta, win); }
+void scroll_pad (struct WinMeta * win_meta, char dir) {
+// Try to scroll pad left or right.
+ if ('+' == dir)
+ reset_pad_offset(win_meta, win_meta->pad_offset + 1);
+ else if ('-' == dir)
+ reset_pad_offset(win_meta, win_meta->pad_offset - 1); }
+
void growshrink_active_window (struct WinMeta * win_meta, char change) {
// Grow or shrink active window horizontally or vertically by one cell size.
if (0 != win_meta->active) {
- uint16_t height = win_meta->active->height;
- uint16_t width = win_meta->active->width;
+ uint16_t height = win_meta->active->frame.size.y;
+ uint16_t width = win_meta->active->frame.size.x;
if (change == '-')
height--;
else if (change == '+')
@@ -109,9 +116,9 @@ struct Map init_map () {
curpos = y * map.width + x;
if ('~' == map.cells[curpos] &&
( (curpos >= map.width && '.' == map.cells[curpos - map.width])
- || (curpos < map.width * (map.height - 1) && '.' == map.cells[curpos + map.width])
- || (curpos > 0 && '.' == map.cells[curpos - 1] && curpos % map.width != 0)
- || (curpos < (map.width * map.height) && '.' == map.cells[curpos + 1] && (curpos + 1) % map.width != 0)))
+ || (curpos < map.width * (map.height-1) && '.' == map.cells[curpos + map.width])
+ || (curpos > 0 && curpos % map.width != 0 && '.' == map.cells[curpos-1])
+ || (curpos < (map.width * map.height) && (curpos+1) % map.width != 0 && '.' == map.cells[curpos+1])))
map.cells[y * map.width + x] = '.'; }
return map; }
@@ -338,17 +345,17 @@ int main (int argc, char *argv[]) {
struct Win win_map = init_window(&win_meta, "Map", &world, draw_map_win);
struct Win win_info = init_window(&win_meta, "Info", &world, draw_info_win);
struct Win win_log = init_window(&win_meta, "Log", &world, draw_log_win);
- win_keys.width = 29;
- win_map.width = win_meta.width - win_keys.width - win_log.width - 2;
- win_info.height = 1;
- win_log.height = win_meta.height - 3;
+ win_keys.frame.size.x = 29;
+ win_map.frame.size.x = win_meta.pad.size.x - win_keys.frame.size.x - win_log.frame.size.x - 2;
+ win_info.frame.size.y = 1;
+ win_log.frame.size.y = win_meta.pad.size.y - 3;
toggle_window(&win_meta, &win_keys);
toggle_window(&win_meta, &win_map);
toggle_window(&win_meta, &win_info);
toggle_window(&win_meta, &win_log);
int key;
- unsigned char quit_called;
+ unsigned char quit_called = 0;
if (0 == world.interactive) {
unsigned char still_reading_file = 1;
int action;