src/window.c
changeset 0 acc07f1f4b1e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/window.c	Mon Jan 29 20:22:01 2007 +0000
     1.3 @@ -0,0 +1,78 @@
     1.4 +/*
     1.5 + * $Id: window.c,v 1.5 2004/12/30 09:07:47 ali Exp $
     1.6 + * Copyright (C) 2007 J. Ali Harlow
     1.7 + * Min Hack may be freely redistributed.  See license for details. 
     1.8 + */
     1.9 +
    1.10 +#include <stdlib.h>
    1.11 +#include <stdio.h>
    1.12 +#include <string.h>
    1.13 +#include "minhack.h"
    1.14 +
    1.15 +int message_win=-1;
    1.16 +int map_win=-1;
    1.17 +
    1.18 +int minhack_create_nhwindow(int type)
    1.19 +{
    1.20 +    int window;
    1.21 +    for(window=0;window<no_windows;window++)
    1.22 +	if (!windows[window].in_use)
    1.23 +	    break;
    1.24 +    if (window==no_windows)
    1.25 +	windows=realloc(windows,++no_windows*sizeof(*windows));
    1.26 +    windows[window].in_use=nhproxy_true;
    1.27 +    windows[window].type=type;
    1.28 +    windows[window].menu=NULL;
    1.29 +    switch(type)
    1.30 +    {
    1.31 +	case NHPROXY_EXT_NHW_MESSAGE:
    1.32 +	    windows[window].win=newwin(1,0,0,0);
    1.33 +	    if (message_win<0)
    1.34 +		message_win=window;
    1.35 +	    break;
    1.36 +	case NHPROXY_EXT_NHW_STATUS:
    1.37 +	    windows[window].win=newwin(2,0,LINES-2,0);
    1.38 +	    break;
    1.39 +	case NHPROXY_EXT_NHW_MAP:
    1.40 +	    if (map_win<0)
    1.41 +		map_win=window;
    1.42 +	    /* Fall through */
    1.43 +	case NHPROXY_EXT_NHW_MENU:
    1.44 +	case NHPROXY_EXT_NHW_TEXT:
    1.45 +	    windows[window].win=NULL;
    1.46 +	    break;
    1.47 +    }
    1.48 +    return window;
    1.49 +}
    1.50 +
    1.51 +void minhack_clear_nhwindow(int window, int rows, int cols, int layers)
    1.52 +{
    1.53 +    if (windows[window].type==NHPROXY_EXT_NHW_MAP)
    1.54 +    {
    1.55 +	if (windows[window].win)
    1.56 +	    delwin(windows[window].win);
    1.57 +	windows[window].win=newwin(rows,cols,1,0);
    1.58 +    }
    1.59 +    else
    1.60 +	werase(windows[window].win);
    1.61 +}
    1.62 +
    1.63 +void minhack_display_nhwindow(int window, nhproxy_bool_t blocking)
    1.64 +{
    1.65 +    wrefresh(windows[window].win);
    1.66 +}
    1.67 +
    1.68 +void minhack_destroy_nhwindow(int window)
    1.69 +{
    1.70 +    minhack_free_menu(window);
    1.71 +    if (windows[window].win)
    1.72 +    {
    1.73 +	delwin(windows[window].win);
    1.74 +	windows[window].win=NULL;
    1.75 +    }
    1.76 +    if (window==message_win)
    1.77 +	message_win=-1;
    1.78 +    else if (window==map_win)
    1.79 +	map_win=-1;
    1.80 +    windows[window].in_use=nhproxy_false;
    1.81 +}