static gg_dialog_t *create_current_tiles_dialog()
{
    gg_widget_t *dialog;
    gg_widget_t *hbox;
    gg_widget_t *widget;
    gg_widget_t *vbox;

    hbox = gg_hbox_create(0);

    slots[0] = gg_image_create(get_tile_tex(get_tile_slot(0)));
    widget = gg_action_create(slots[0]);
    gg_action_set_callback(GG_ACTION(widget), open_selector, (int*)0);
    gg_container_append(GG_CONTAINER(hbox), widget);

    slots[1] = gg_image_create(get_tile_tex(get_tile_slot(1)));
    widget = gg_action_create(slots[1]);
    gg_action_set_callback(GG_ACTION(widget), open_selector, (int*)1);
    gg_container_append(GG_CONTAINER(hbox), widget);

    slots[2] = gg_image_create(get_tile_tex(get_tile_slot(2)));
    widget = gg_action_create(slots[2]);
    gg_action_set_callback(GG_ACTION(widget), open_selector, (int*)2);
    gg_container_append(GG_CONTAINER(hbox), widget);
 
    vbox = gg_vbox_create(0);
    gg_container_append(GG_CONTAINER(vbox), hbox);

    widget = gg_option_create();
    gg_option_append_label(GG_OPTION(widget), "PL", 0.5f, 0.0f);
    gg_option_append_label(GG_OPTION(widget), "FG", 0.5f, 0.0f);
    gg_option_append_label(GG_OPTION(widget), "Obs", 0.5f, 0.0f);

    gg_option_set_callback(GG_OPTION(widget), edit_layer_changed, NULL);
    gg_container_append(GG_CONTAINER(vbox), widget);

    dialog = gg_dialog_create(vbox, "Tiles", CURRENT_TILES_DIALOG);
    gg_dialog_set_position(GG_DIALOG(dialog), 510, 375, 0.0f, 0.0f);
    gg_dialog_set_style(GG_DIALOG(dialog), get_menu_style() );

    return GG_DIALOG(dialog);
}
Example #2
0
gg_dialog_t *dialog_saveload_create(gg_dialog_t *parent, int saving)
{
    gg_widget_t *dialog;
    gg_widget_t *rootvbox = gg_vbox_create(0);
    gg_widget_t *vbox = gg_vbox_create(0);
    gg_widget_t *hbox = gg_vbox_create(0);
    gg_widget_t *hboxtemp;
    gg_widget_t *widget;
    char temp[80];
    char whiteis[80], blackis[80];
    int i=0,j=0;
    int padding=0;

    change_saving=saving;

    if ( !changing_slot )
        saveload_selected=0;

    /*DBG_LOG( "dialog opened with saveselected of %i", saveload_selected );*/

    /* Right side.. */
    if (!changing_slot)
    {
#ifdef _arch_dreamcast
        dc_restore_savegames();
#endif
        for ( i=0; i<SAVEGAME_SLOTS; i++ )
            load_save_xml( i );
    }

    if ( get_slots() & (1 << saveload_selected) )
    {
        gg_widget_t *board_box = gg_vbox_create(0);

        sprintf( temp, "Saved: %s", get_time_save(saveload_selected) );
        widget = gg_label_create(temp);
        gg_container_append(GG_CONTAINER(vbox), widget);

        switch ( get_config_save(saveload_selected)->player[WHITE] )
        {
        case PLAYER_ENGINE:
            sprintf( whiteis, "CPU" );
            break;
        case PLAYER_UI:
            sprintf( whiteis, "Human" );
            break;
        default:
            /* Whoops */
            sprintf( whiteis, "Oh no.." );
            break;
        }

        switch ( get_config_save(saveload_selected)->player[BLACK] )
        {
        case PLAYER_ENGINE:
            sprintf( blackis, "CPU" );
            break;
        case PLAYER_UI:
            sprintf( blackis, "Human" );
            break;
        default:
            /* Whoops */
            sprintf( blackis, "Oh no.." );
            break;
        }

        sprintf( temp, "%s vs %s", whiteis, blackis );
        widget = gg_label_create(temp);
        gg_container_append(GG_CONTAINER(vbox), widget);

        sprintf( temp, "Difficulty: %s",
            get_config_save(saveload_selected)->difficulty ? "Normal" : "Easy" );
        widget = gg_label_create(temp);
        gg_container_append(GG_CONTAINER(vbox), widget);

        sprintf( temp, "Level: %i",
            get_config_save(saveload_selected)->cpu_level );
        widget = gg_label_create(temp);
        gg_container_append(GG_CONTAINER(vbox), widget);

        widget = gg_label_create(" ");
        gg_container_append(GG_CONTAINER(vbox), widget);

        /* create board.. */

        for ( i=7; i>=0; i-- )
        {
            gg_widget_t *hboxtemp2;
            gg_colour_t col_white =
                {
                    1.0f, 1.0f, 1.0f, 1.0f
                };
            /*gg_colour_t col_grey =
                {
                    0.3f, 0.3f, 0.3f, 1.0f
                };*/
            hboxtemp = gg_hbox_create(0);
            hboxtemp2 = gg_hbox_create(0);
            gg_set_requested_size(hboxtemp2, 20, 20);
            gg_container_append(GG_CONTAINER(hboxtemp), hboxtemp2);

            for ( j=0; j<8; j++ )
            {
                gg_colour_t col_green = {0.5, 0.6, 0.5, 1.0};
                gg_colour_t col_yellow = {0.8, 0.7, 0.4, 1.0};
                gg_colour_t front, *back;
                int square = get_saved_board(saveload_selected)->square[i * 8 + j];

                sprintf(temp, "%c", xmlsquaretofont(square));
                widget = gg_label_create( temp );
                gg_set_requested_size(widget, 20, 20);
                gg_align_set_alignment(GG_ALIGN(widget), 0.5, 0.5);

                if (COLOUR(square) == WHITE)
                    front = col_white;
                else
                    front = *get_col(COL_BLACK);

                if ((i + j) % 2 == 0)
                    back = &col_green;
                else
                    back = &col_yellow;

                /* FIXME Hack to turn off shadow */
                front.a = 2.0f;

                gg_label_set_colour(GG_LABEL(widget), &front, back);
                gg_container_append(GG_CONTAINER(hboxtemp), widget);
            }
            gg_container_append(GG_CONTAINER(board_box), hboxtemp);
        }
        gg_container_append(GG_CONTAINER(vbox), board_box);
    }
    else
    {
        sprintf( temp, "Empty slot" );
        widget = gg_label_create(temp);
        gg_container_append(GG_CONTAINER(vbox), widget);

        for ( i=0; i<12; i++ )
        {
            widget = gg_label_create(" ");
            gg_container_append(GG_CONTAINER(vbox), widget);
        }
    }
    gg_set_requested_size(vbox, 201, 0);
    gg_container_append(GG_CONTAINER(hbox), gg_frame_create(vbox));

    /* left side */
    vbox = gg_vbox_create(0);
    /* padding.. */
    for ( i=0; i<padding; i++ )
    {
        widget = gg_label_create(" ");
        gg_container_append(GG_CONTAINER(vbox), widget);
    }

    widget = gg_option_create();
    for ( i=0; i<SAVEGAME_SLOTS; i++ )
    {
        sprintf( temp, "Save slot: %i", i+1 );
        gg_option_append_label(GG_OPTION(widget), temp, 0.5f, 0.0f);
    }
    gg_widget_subscribe_signal_name(widget, widget->id, "option_changed", 
        dialog_saveload_change, widget);
    gg_container_append(GG_CONTAINER(vbox), widget);

    if ( changing_slot )
        gg_option_set_selected(GG_OPTION(widget), saveload_selected);

    if ( saving )
    {
        widget = gg_action_create_with_label("Save Game", 0.5f, 0.0f);
        gg_widget_subscribe_signal_name(widget, widget->id, "action_pressed", 
            dialog_savegame_save, vbox);
    }
    else
    {
        widget = gg_action_create_with_label("Load Game", 0.5f, 0.0f);
        gg_widget_subscribe_signal_name(widget, widget->id, "action_pressed", 
            dialog_loadgame_load, vbox);
    }
    gg_container_append(GG_CONTAINER(vbox), widget);

    widget = gg_action_create_with_label("Cancel", 0.5f, 0.0f);
    gg_widget_subscribe_signal_name(widget, widget->id, "action_pressed", 
        dialog_close_cb, NULL);
    gg_container_append(GG_CONTAINER(vbox), widget);

    /*for ( i=0; i<SAVEGAME_SLOTS; i++ )
    {
        sprintf( temp, "%i:  ", i );
        widget = gg_action_create_with_label(temp, 0.0f, 0.0f);

        gg_action_set_callback(GG_ACTION(widget), dialog_saveload_change, vbox);

        gg_container_append(GG_CONTAINER(vbox), widget);
    }*/

    gg_container_append(GG_CONTAINER(hbox), vbox );

    if ( changing_slot )
        gg_vbox_set_selected(vbox, padding );

    /* Dialog stuff */
    gg_container_append(GG_CONTAINER(rootvbox), hbox);
    dialog = gg_dialog_create(rootvbox, NULL, parent, GG_DIALOG_AUTOHIDE_PARENT);

    if ( saving )
        gg_dialog_set_style(GG_DIALOG(dialog), get_ingame_style());
    else
        gg_dialog_set_style(GG_DIALOG(dialog), get_menu_style());

    return GG_DIALOG(dialog);
}