Exemplo n.º 1
0
GuiWidget* gui_radiogroup_create(
    GuiWidget *parent, int x, int y, int width, int height, int with_frame,
    void (*user_event_handler)(GuiWidget*,GuiEvent*),
    int item_count, char **items, int min, int max )
{
    int px, py, i, j, gap = 4;
    GuiWidget *widget = gui_widget_create( 
        parent, GUI_RADIOGROUP, x, y, width, height, 
        default_event_handler, user_event_handler );
    /* events */
    gui_widget_enable_event( widget, GUI_CLICKED );
    /* create surface, wallpaper and frame it */
    widget->surface = stk_surface_create( 
        SDL_SWSURFACE, width, height );
    SDL_SetColorKey( widget->surface, 0,0 );
    stk_surface_apply_wallpaper( widget->surface, 0,0,-1,-1,
        gui_theme->widget_wallpaper, -1 );
    if ( with_frame )
        widget->border = stk_surface_apply_frame(
            widget->surface, 0, 0, -1, -1, 
            gui_theme->widget_frame );
    /* size w/o border */
    widget->width -= 2 * widget->border;
    widget->height -= 2 * widget->border;
    /* various */
    widget->spec.radiogroup.size = item_count;
    widget->spec.radiogroup.min = min;
    widget->spec.radiogroup.max = max;
    widget->spec.radiogroup.single_check = -1;
    /* compute offset of single items */
    widget->spec.radiogroup.offset = 
        (height - 2 * widget->border) / 
        item_count;
    /* position of first checkbox */
    widget->spec.radiogroup.x = widget->border + gap;
    widget->spec.radiogroup.y = widget->border + 
        (widget->spec.radiogroup.offset - 
         gui_theme->checkbox_size) / 2;
    /* add empty checkboxes and labels */
    gui_theme->label_font->align = STK_FONT_ALIGN_CENTER_Y;
    px = widget->spec.radiogroup.x;
    py = widget->spec.radiogroup.y;
    for ( i = 0, j = 0; i < widget->spec.radiogroup.size; 
          i++, py += widget->spec.radiogroup.offset, j++ ) {
        stk_surface_blit( 
            gui_theme->checkbox, 0, 0,
            gui_theme->checkbox_size,
            gui_theme->checkbox_size,
            widget->surface, px, py );
        stk_font_write( gui_theme->label_font, 
            widget->surface, px + gui_theme->checkbox_size + gap,
            py + gui_theme->checkbox_size/2, -1, items[j] );
    }
    /* create empty checkers */
    widget->spec.radiogroup.checks = calloc( item_count, sizeof( int ) );
    if ( widget->spec.radiogroup.checks == 0 )
        GUI_ABORT( "Out Of Memory" );
    return widget;
}
Exemplo n.º 2
0
void close_pause_chat( void )
{
	gui_widget_hide( dlg_pauseroom );
	set_state( CS_PLAY );

	/* enable event filter */
	SDL_SetEventFilter( event_filter );
	gui_widget_enable_event( dlg_chatroom, GUI_TIME_PASSED );
}
Exemplo n.º 3
0
/*
====================================================================
Build the GUI and everything nescessary for the client chatroom.
client_create() installs client_delete() as exit function.
====================================================================
*/
void client_create( void )
{
#ifdef NETWORK_ENABLED
    GuiWidget *parent;
    SDL_Surface *surface;
    /* users, channels, games */
    client_data_create();
    /* CONNECT WINDOW */
    dlg_connect = gui_box_create( 0, -1,-1, 400, 224, 0, 0 );
    parent = dlg_connect;
    /* hint label */
    gui_label_create( 
        parent, 10, 10, parent->width - 20, 100, 1, 
        0, 4, 0, STK_FONT_ALIGN_LEFT, HINT_CONNECT );
    /* server edit */
    gui_label_create( 
        parent, 10, 120, 180, 20, 0, 
        0, 2, 0, STK_FONT_ALIGN_RIGHT, _("Server:") );
    edit_server = gui_edit_create(
        parent, parent->width - 190, 120, 180, 20,
        0, 2, 0, 22, config.server );
    /* user name */
    gui_label_create( 
        parent, 10, 150, 180, 20, 0, 
        0, 2, 0, STK_FONT_ALIGN_RIGHT, _("Username:"******"Connect") );
    gui_button_create(
        parent, parent->width/2 +20, 180, 
        140, 24, client_close_connect_window, 0,0,0,0,0, _("Cancel") );
    /* INFO */
    dlg_info = gui_box_create( 0, -1,-1, 300, 114, 0, 1 );
    label_info = gui_label_create( dlg_info, -1,10,276,60,0, 0,
        2, 0, STK_FONT_ALIGN_LEFT, _("no info") );
    gui_button_create( dlg_info, 
        -1, dlg_info->height - 34,
        100, 24, client_close_info, 0,0,0,0,0,
        _("Close") );
    /* CONFIRM */
    dlg_confirm = gui_box_create( 0, -1,-1, 300, 160, 0, 1 );
    label_confirm = gui_label_create( dlg_confirm, -1,10,276,110,0, 0,
        2, 0, STK_FONT_ALIGN_LEFT, _("no info") );
    gui_button_create( dlg_confirm, 
        dlg_confirm->width/2-110, dlg_confirm->height - 30,
        100, 20, client_confirm, 0,0,0,0,0,
        _("OK") );
    gui_button_create( dlg_confirm, 
        dlg_confirm->width/2+10, dlg_confirm->height - 30,
        100, 20, client_cancel, 0,0,0,0,0,
        _("Cancel") );
    /* CHATROOM */
    dlg_chatroom = gui_box_create( 0, 0,0,640,480, 
        client_recv_packet, 1 );
    gui_widget_enable_event( dlg_chatroom, GUI_TIME_PASSED );
    surface = gui_widget_get_surface( dlg_chatroom );
    stk_surface_apply_wallpaper( 
        surface, 0,0,-1,-1, cr_wallpaper, STK_OPAQUE );
    /* chat window */
    list_chatter = gui_list_create( dlg_chatroom, 0,0,470,444, NULL,
        0, 1, 14, 20, client_render_chatter, GUI_LIST_NO_SELECT );
    /* edit + send/whisper buttons */
    gui_button_create( dlg_chatroom, 330,448,60,24, 
        client_send_chatter, 0,0,0,0,0, _("Send") );
    gui_button_create( dlg_chatroom, 390,448,80,24, 
        client_whisper_chatter, 0,0,0,0,0, _("Whisper") );
    edit_chatter = gui_edit_create( dlg_chatroom, 0,448,327,24,
        client_send_chatter, 2, 0, MAX_CHATTER_SIZE, "" );
    gui_widget_enable_event( edit_chatter, GUI_KEY_RELEASED );
    gui_widget_set_default_key_widget( dlg_chatroom, edit_chatter );
    /* channel button + users in channel */
    label_channel = gui_label_create( dlg_chatroom, 
        474,0,142,18,1, NULL,
        2, 0, STK_FONT_ALIGN_CENTER_X, _("MAIN") );
    gui_button_create( dlg_chatroom, 616,0,18,18, 
        client_select_channel,
        0,0,0,0,0, _("C") );
    list_users = gui_list_create( dlg_chatroom, 
        474,20,160,142, client_handle_user_list,
        1, 1, 14, 20, client_render_user, 
        GUI_LIST_SINGLE_SELECT );
    /* levels label, levels, transfer button */
    gui_label_create( dlg_chatroom, 474,164,160,18,1, NULL,
        2, 0, STK_FONT_ALIGN_CENTER_X, _("Levelsets") );
    list_levels = gui_list_create( dlg_chatroom, 
        474,184,160,120, client_handle_levelset_list,
        1, 1, 14, 20, client_render_levelset, 
        GUI_LIST_SINGLE_SELECT );
    /* box with level settings */
    parent = gui_box_create( dlg_chatroom,
        474,306,160,94, NULL, 0 );
    gui_label_create( parent, 2,2,102,20,0, NULL,
        2, NULL, STK_FONT_ALIGN_LEFT, _("Difficulty:") );
    gui_spinbutton_create( parent, 102,2,50,20, 
        client_update_difficulty,
        1, 3, 1, config.mp_diff+1 );
    gui_label_create( parent, 2,2+22,102,20,0, NULL,
        2, NULL, STK_FONT_ALIGN_LEFT, _("Rounds:") );
    gui_spinbutton_create( parent, 102,2+22,50,20,
        client_update_rounds,
        1, 3, 1, config.mp_rounds );
    gui_label_create( parent, 2,2+44,102,20,0, NULL,
        2, NULL, STK_FONT_ALIGN_LEFT, _("Frags:") );
    gui_spinbutton_create( parent, 102,2+44,50,20, 
        client_update_frags,
        5, 30, 5, config.mp_frags );
    gui_label_create( parent, 2,2+66,102,20,0, NULL,
        2, NULL, STK_FONT_ALIGN_LEFT, _("Balls:") );
    gui_spinbutton_create( parent, 102,2+66,50,20,
        client_update_balls,
        1, 6, 1, config.mp_balls );
    /* challenge & disconnect */
    gui_button_create( dlg_chatroom, 
        474,402,160,20, client_challenge,
        0,0,0,0,0, _("Challenge") );
    gui_button_create( dlg_chatroom,
	474,dlg_chatroom->height-44,160,20,
	client_open_connect_window,
	0,0,0,0,0, _("Connect") );
    gui_button_create( dlg_chatroom, 
        534,dlg_chatroom->height-20,100,20, 
        client_quit,
        0,0,0,0,0, _("Quit") );
    gui_button_create( dlg_chatroom, 
        474,dlg_chatroom->height-20,50,20, 
        client_popup_help,
        0,0,0,0,0, _("Help") );
    /* CHANNELS selector */
    dlg_channels = gui_box_create( 0, -1,-1, 200, 244, NULL, 1 );
    list_channels = gui_list_create( dlg_channels, -1,10, 176,150, 
        client_handle_channel_list, 0, 1, 14, 20, 
        client_render_channel, GUI_LIST_SINGLE_SELECT );
    gui_label_create( dlg_channels, -1,160, 176,20,0, NULL,
        2, 0, STK_FONT_ALIGN_LEFT, _("Channel:") );
    edit_channel = gui_edit_create( dlg_channels, 
        -1,180, 176,20, NULL,
        2, 0, 12, "" );
    gui_widget_set_default_key_widget( dlg_channels, edit_channel );
    gui_edit_set_filter( edit_channel, GUI_EDIT_ALPHANUMERICAL2 );
    gui_button_create( dlg_channels, 
        dlg_channels->width/2-90,210,80,20, 
        client_enter_channel, 0,0,0,0,0, _("Enter") );
    gui_button_create( dlg_channels, 
        dlg_channels->width/2+10,210,80,20, 
        client_cancel_channel, 0,0,0,0,0, _("Cancel") );
    /* STATISTICS */
    dlg_stats = gui_box_create( 0, -1,-1,386,260, NULL, 1 );
    gui_label_create( dlg_stats, -1,10,360,20,1, NULL,
        0, 0, STK_FONT_ALIGN_CENTER_X, _("Statistics") );
    label_winner = gui_label_create( dlg_stats, 
        -1,40,360,16,0, NULL,
        0, 0, STK_FONT_ALIGN_CENTER_X, "..." );
    label_stats = gui_label_create( dlg_stats, 
        -1,62,360,150,0, NULL,
        0, 0, STK_FONT_ALIGN_LEFT, _("Awaiting stats...") );
    gui_button_create( dlg_stats, -1,220,160,20,
        client_close_stats, 0,0,0,0,0, _("Close") );
    /* PAUSEROOM */
    dlg_pauseroom = gui_box_create( 0, -1,-1,480,366, NULL, 1 );
    list_pausechatter = gui_list_create( 
        dlg_pauseroom, 0,0,470,300, NULL,
        0, 1, 14, 20, client_render_pause_chatter, 
        GUI_LIST_NO_SELECT );
    edit_pausechatter = gui_edit_create( 
        dlg_pauseroom, 0,303,470,24,
        client_send_pausechatter, 2, 0, MAX_CHATTER_SIZE, "" );
    gui_widget_enable_event( edit_pausechatter, GUI_KEY_RELEASED );
    gui_widget_set_default_key_widget( dlg_pauseroom, edit_pausechatter );
    gui_button_create( dlg_pauseroom, -1,334,100,20,
        client_close_pauseroom, 0,0,0,0,0, _("Close") );
    /* HELP */
    dlg_help = gui_box_create( 0, -1,-1,548,358, NULL, 1 );
    gui_label_create( dlg_help, -1,10,470,20,1, NULL,
        0, 0, STK_FONT_ALIGN_CENTER_X, _("Network Quick Help") );
    list_topic = gui_list_create( 
        dlg_help, 10,40,160,270, client_handle_topic_list,
        0, 1, 14, 20, client_render_topic,
        GUI_LIST_SINGLE_SELECT );
    list_help = gui_list_create( 
        dlg_help, 180,40,350,300, NULL,
        0, 1, 14, 20, client_render_help, 
        GUI_LIST_NO_SELECT );
    gui_button_create( dlg_help, 10,320,160,20, client_close_help,
        0,0,0,0,0, _("Close") );
    /* INITS */
    /* empty chatter */
    memset( chatter, 0, sizeof( chatter ) );
    /* update chatboxes */
    gui_list_update( list_chatter, CHAT_LINE_COUNT );
    gui_list_update( list_pausechatter, CHAT_LINE_COUNT );
    gui_list_goto( list_chatter, -1 );
    gui_list_goto( list_pausechatter, -1 );
    /* set help topics */
    gui_list_update( list_topic, client_topic_count );
    /* call client_delete at exit */
    atexit( client_delete );
#endif
}