Beispiel #1
0
int main(int argc, char **argv)
{
    winstart();

    /* get dir of executable */
    winpath(dir);

    /* get story file */
    if (!winargs(argc, argv, buf))
        winbrowsefile(buf);

    if (!strlen(buf))
        return TRUE;

    /* run story file */
    return rungame(dir, buf);
}
Beispiel #2
0
static void
mainmenu(void)
{
    int menuresult[1];
    int n = 1, logoheight, i;
    const char *const *copybanner = nh_get_copyright_banner();
    const char **nhlogo;
    char verstr[32];
    nh_bool first = TRUE;

    snprintf(verstr, ARRAY_SIZE(verstr), "Version %d.%d.%d", VERSION_MAJOR, VERSION_MINOR,
            PATCHLEVEL);

#if defined(NETCLIENT)
    if (ui_flags.connection_only) {
        netgame();
        return;
    }
#endif

    load_keymap(); /* netgame() assumes the keymap isn't loaded */

    while (n >= 0) {
        if (COLS >= 100) {
            nhlogo = nhlogo_large;
            logoheight = sizeof (nhlogo_large) / sizeof (nhlogo_large[0]);
        } else {
            nhlogo = nhlogo_small;
            logoheight = sizeof (nhlogo_small) / sizeof (nhlogo_small[0]);
        }
        wclear(basewin);
        wattron(basewin, A_BOLD | COLOR_PAIR(4));
        for (i = 0; i < logoheight; i++) {
            wmove(basewin, i, (COLS - strlen(nhlogo[0])) / 2);
            if (nhlogo[i])
                waddstr(basewin, nhlogo[i]);
        }
        wattroff(basewin, A_BOLD | COLOR_PAIR(4));
        mvwaddstr(basewin, LINES - 3, 0, copybanner[0]);
        mvwaddstr(basewin, LINES - 2, 0, copybanner[1]);
        mvwaddstr(basewin, LINES - 1, 0, copybanner[2]);
        mvwaddstr(basewin, LINES - 4, COLS - strlen(verstr), verstr);
        wnoutrefresh(basewin);

        if (first) {
            network_motd();
            first = FALSE;
        }

        menuresult[0] = EXITGAME;       /* default action */
        if (!override_hackdir)
            curses_display_menu_core(
                STATIC_MENULIST(mainmenu_items), NULL, PICK_ONE,
                menuresult, curses_menu_callback,
                0, logoheight - 1, COLS, LINES - 3, FALSE, NULL, FALSE);
        else
            curses_display_menu_core(
                STATIC_MENULIST(mainmenu_items_noclient), NULL, PICK_ONE,
                menuresult, curses_menu_callback,
                0, logoheight - 1, COLS, LINES - 3, FALSE, NULL, FALSE);

        if (*menuresult == CURSES_MENU_CANCELLED && !ui_flags.done_hup)
            continue;

        switch (menuresult[0]) {
        case NEWGAME:
            rungame(FALSE);
            break;

        case LOAD:
            loadgame();
            break;

        case REPLAY:
            replay();
            break;

        case OPTIONS:
            display_options(TRUE);
            break;

#if defined(NETCLIENT)
        case NETWORK:
            free_keymap(); /* don't use the local keymap for server play */
            netgame();
            load_keymap();
            break;
#endif

        case TOPTEN:
            show_topten(NULL, -1, FALSE, FALSE);
            break;

        case EXITGAME:
        case CURSES_MENU_CANCELLED: /* in case of hangup */
            n = -1;     /* simulate menu cancel */
            break;
        }
    }

    free_keymap();
}