Esempio n. 1
0
static bool
output_header_helper (enum prop_type_t type)
{
    char *buffer;
    int size;
    char temp_buffer[16];

    if (!get_header_string_and_size (&header, type, &buffer, &size))
    {
        DEBUGF ("output_header_helper called with invalid prop type!!\n");
        return false;
    }

    if (rb->strlen (buffer))
    {
        rb->snprintf (temp_buffer, sizeof (temp_buffer), "%s[",
                      prop_names[type]);

        write_file (sgf_fd, temp_buffer, rb->strlen (temp_buffer));

        write_file (sgf_fd, buffer, rb->strlen (buffer));

        rb->strcpy (temp_buffer, "]");

        write_file (sgf_fd, temp_buffer, rb->strlen (temp_buffer));

        return true;
    }

    return false;
}
Esempio n. 2
0
static void
do_gameinfo_menu (void)
{
    MENUITEM_STRINGLIST (gameinfo_menu, "Game Info", NULL,
                         "Basic Info",
                         "Time Limit",
                         "Overtime",
                         "Result",
                         "Handicap",
                         "Komi",
                         "Ruleset",
                         "Black Player",
                         "Black Rank",
                         "Black Team",
                         "White Player",
                         "White Rank",
                         "White Team",
                         "Date",
                         "Event",
                         "Place",
                         "Round",
                         "Done");
    /* IMPORTANT:
     *
     * if you edit this string list, make sure you keep
     * menu_selection_to_prop function in line with it!! (see the bottom
     * of this file).
     */

    int new_ruleset = 0;

    char *gameinfo_string;
    int gameinfo_string_size;

    bool done = false;
    int selection = 0;

    while (!done)
    {
        selection = rb->do_menu (&gameinfo_menu, &selection, NULL, false);

        switch (selection)
        {
        case GINFO_OVERTIME:
        case GINFO_RESULT:
        case GINFO_BLACK_PLAYER:
        case GINFO_BLACK_RANK:
        case GINFO_BLACK_TEAM:
        case GINFO_WHITE_PLAYER:
        case GINFO_WHITE_RANK:
        case GINFO_WHITE_TEAM:
        case GINFO_DATE:
        case GINFO_EVENT:
        case GINFO_PLACE:
        case GINFO_ROUND:
            if (!get_header_string_and_size (&header,
                                             menu_selection_to_prop
                                             (selection), &gameinfo_string,
                                             &gameinfo_string_size))
            {
                rb->splash (3 * HZ, "Couldn't get header string");
                break;
            }

            rb->kbd_input (gameinfo_string, gameinfo_string_size);
            sanitize_string (gameinfo_string);
            set_game_modified();
            break;

            /* these need special handling in some way, so they are
               separate */

        case GINFO_BASIC_INFO:
            metadata_summary();
            break;

        case GINFO_TIME_LIMIT:
            rb->set_int ("Time Limit", "", UNIT_INT, &header.time_limit,
                         NULL, 60, 0, 24 * 60 * 60, &time_formatter);
            set_game_modified();
            break;

        case GINFO_HANDICAP:
            rb->splashf (0, "%d stones.  Start a new game to set handicap",
                         header.handicap);
            rb->action_userabort(TIMEOUT_BLOCK);
            break;

        case GINFO_KOMI:
            rb->set_int ("Komi", "moku", UNIT_INT, &header.komi, NULL,
                         1, -300, 300, &komi_formatter);
            set_game_modified();
            break;

        case GINFO_RULESET:
            new_ruleset = 0;
            rb->set_int ("Ruleset", "", UNIT_INT, &new_ruleset, NULL,
                         1, 0, NUM_RULESETS - 1, &ruleset_formatter);

            rb->strcpy (header.ruleset, ruleset_names[new_ruleset]);
            set_game_modified();
            break;

        case GINFO_DONE:
        case GO_TO_ROOT:
        case GO_TO_PREVIOUS:
        case MENU_ATTACHED_USB:
        default:
            done = true;
            break;
        };
    }
}