Beispiel #1
0
void curses_del_wid(winid wid)
{
    nethack_wid *tmpwid;
    nethack_wid *widptr = nhwids;
    
    if (curses_is_menu(wid) || curses_is_text(wid))
    {
        curses_del_menu(wid);
    }
    
    while (widptr != NULL)
    {
        if (widptr->nhwid == wid)
        {
            if (widptr->prev_wid != NULL)
            {
                tmpwid = widptr->prev_wid;
                tmpwid->next_wid = widptr->next_wid;
            }
            else
            {
                nhwids = widptr->next_wid;   /* New head mode, or NULL */
            }
            if (widptr->next_wid != NULL)
            {
                tmpwid = widptr->next_wid;
                tmpwid->prev_wid = widptr->prev_wid;
            }
            free(widptr);
            break;
        }
        widptr = widptr->next_wid;
    }
}
Beispiel #2
0
void curses_del_nhwin(winid wid)
{
    nethack_window *tmpwin;
    nethack_window *winptr = nhwins;
    
    if (curses_is_menu(wid) || curses_is_text(wid))
    {
        curses_del_menu(wid);
    }
    
    while (winptr != NULL)
    {
        if (winptr->nhwin == wid)
        {
            if (winptr->prev_window != NULL)
            {
                tmpwin = winptr->prev_window;
                tmpwin->next_window = winptr->next_window;
            }
            else
            {
                nhwins = winptr->next_window;   /* New head mode, or NULL */
            }
            if (winptr->next_window != NULL)
            {
                tmpwin = winptr->next_window;
                tmpwin->prev_window = winptr->prev_window;
            }
            free(winptr);
            break;
        }
        winptr = winptr->next_window;
    }
}
Beispiel #3
0
/*  Create a window of type "type" which can be 
        NHW_MESSAGE     (top line)
        NHW_STATUS      (bottom lines)
        NHW_MAP         (main dungeon)
        NHW_MENU        (inventory or other "corner" windows)
        NHW_TEXT        (help/text, full screen paged window)
*/
winid curses_create_nhwindow(int type)
{
    winid wid = curses_get_wid(type);

    if (curses_is_menu(wid) || curses_is_text(wid))
    {
        curses_start_menu(wid);
        curses_add_wid(wid);
    }
    
    return wid;
}
Beispiel #4
0
void curses_del_nhwin(winid wid)
{
    if (curses_is_menu(wid) || curses_is_text(wid))
    {
        curses_del_menu(wid);
        return;
    }
    
    if (!is_main_window(wid))
    {
        panic("curses_del_nhwin: wid out of range. Not a main window.");
    }

    nhwins[wid].nhwin = -1;
}
Beispiel #5
0
/* -- Display the window on the screen.  If there is data
                   pending for output in that window, it should be sent.
                   If blocking is TRUE, display_nhwindow() will not
                   return until the data has been displayed on the screen,
                   and acknowledged by the user where appropriate.
                -- All calls are blocking in the tty window-port.
                -- Calling display_nhwindow(WIN_MESSAGE,???) will do a
                   --more--, if necessary, in the tty window-port.
*/
void curses_display_nhwindow(winid wid, boolean block)
{
    menu_item *selected = NULL;

    if ((wid == MAP_WIN) && block)
    {
      (void) curses_more();
    }

    if (curses_is_menu(wid) || curses_is_text(wid))
    {
        curses_end_menu(wid, "");
        curses_select_menu(wid, PICK_NONE, &selected);
        return;
    }

}
Beispiel #6
0
void curses_puts(winid wid, int attr, const char *text)
{
    anything *identifier;
    WINDOW *win = NULL;
    
    if (is_main_window(wid))
    {
        win = curses_get_nhwin(wid);
    }
        
    if (wid == MESSAGE_WIN)
    {
        curses_message_win_puts(text, FALSE);
        return;
    }
    
    if (wid == STATUS_WIN)
    {
        curses_update_stats(FALSE);  /* We will do the write ourselves */
        return;
    }
    
    if (curses_is_menu(wid) || curses_is_text(wid))
    {
        if (!curses_menu_exists(wid))
        {
            panic("curses_puts: Attempted write to nonexistant window!"); 
        }
        identifier = malloc(sizeof(anything));
        identifier->a_void = NULL;
        curses_add_nhmenu_item(wid, identifier, 0, 0, attr, text,
         FALSE);
    }
    else
    {
        waddstr(win, text);
        wrefresh(win);
    }
}