//creates the panel to selecet the players gui_control* menu_players_create() { int base = 100; int height = 80; gui_control *menu_panel = gui_panel_create(0, 0, WIN_W, WIN_H, NULL); //Load images // Player vs. Player, Player vs. AI, AI vs. Player, and AI vs. AI. gui_control *player_vs_player = gui_button_create((WIN_W -230)/2, base, "images/player_vs_player.png", &on_player_vs_player_click); gui_control *player_vs_ai = gui_button_create((WIN_W -230)/2, base + height, "images/player_vs_ai.png", &on_player_vs_ai_click ); gui_control *ai_vs_player = gui_button_create((WIN_W -230)/2, base + height * 2, "images/ai_vs_player.png", &on_ai_vs_player_click ); gui_control *ai_vs_ai = gui_button_create((WIN_W -230)/2, base + height * 3, "images/ai_vs_ai.png", &on_ai_vs_ai_click); gui_control *back = gui_button_create((WIN_W -230)/2, base + height * 4.5, "images/back.png", &on_back_click); gui_set_name(menu_panel, "players menu"); if (player_vs_player == NULL || player_vs_ai == NULL || ai_vs_player == NULL || ai_vs_ai == NULL) { printf("ERROR: failed to load image: '%s'\n", gui_last_error()); exit(1); } //add child controls to the window gui_child_add(menu_panel, player_vs_player); gui_child_add(menu_panel, player_vs_ai); gui_child_add(menu_panel, ai_vs_player); gui_child_add(menu_panel, ai_vs_ai); gui_child_add(menu_panel, back); return menu_panel; }
//creates the slot menu for saving and loading static gui_control* menu_create(int state) { gui_control *menu_panel = gui_panel_create(0, 0, WIN_W, WIN_H, NULL); gui_control *slot = NULL; gui_control *back = NULL; //Load images int base = 100; int height = 80; char fileName[100]; int i; for (i = 0; i < SLOTS; i++) { sprintf(fileName, "./saveload%d.data", i); //file not found if (state == LOAD_MODE && !file_exists(fileName)) { continue; } slot = gui_button_create((WIN_W -230)/2, base + i * height, "images/slot.png", &on_slot_click); slot->state.istate = i; if (slot == NULL) { printf("ERROR: failed to load image: '%s'\n", gui_last_error()); exit(1); } gui_child_add(menu_panel, slot); } back = gui_button_create((WIN_W -230)/2, base + i * height, "images/back.png", &on_back_click); gui_set_name(menu_panel, "save/load menu"); gui_child_add(menu_panel, back); menu_panel->state.istate = state; return menu_panel; }
/* ==================================================================== 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 }
void init_gngeo_gui(void) { // WIDGET *w,*button,*button2,*label; WIDGET *button,*pix; #ifdef __QNXNTO__ char* datadir = "app/native/media"; #else char* datadir = DATA_DIRECTORY; #endif unavail_shots=load_img(datadir,"noshots"); gui_init(304,224,datadir); gui_set_update(update_gngeo_gui); gui_set_resize(screen_resize); gui_set_destroy(gngeo_quit); /* first thing to create, because it contain the key focus list */ desktop=(WIDGET*)gui_frame_create(NULL,0,0,304,224,FRAME_SHADOW_OUT,NULL); //printf("CREATE game\n"); wid_game=init_game_gui(); //printf("CREATE setting\n"); wid_setting=init_setting_gui(); //printf("CREATE control\n"); wid_control=init_control_gui(); /* Main button */ button=(WIDGET*)gui_button_label_create(NULL,2,2,45,15,"Game"); gui_widget_add_keyfocus(desktop,button); button->pdata1=wid_game; GUI_BUTTON(button)->activate=change_panel; gui_container_add(GUI_CONTAINER(desktop),button); button=(WIDGET*)gui_button_label_create(NULL,49,2,45,15,"Setting"); gui_widget_add_keyfocus(desktop,button); button->pdata1=wid_setting; GUI_BUTTON(button)->activate=change_panel; gui_container_add(GUI_CONTAINER(desktop),button); button=(WIDGET*)gui_button_label_create(NULL,96,2,45,15,"Control"); gui_widget_add_keyfocus(desktop,button); button->pdata1=wid_control; GUI_BUTTON(button)->activate=change_panel; gui_container_add(GUI_CONTAINER(desktop),button); /* toggle fullscreen button */ button=(WIDGET*)gui_button_create(NULL,270,3,14,14); gui_widget_add_keyfocus(desktop,button); GUI_BUTTON(button)->activate=toggle_fullscreen; gui_container_add(GUI_CONTAINER(desktop),button); pix_full=load_img_rle(datadir,"fullscreen"); pix_win=load_img_rle(datadir,"window"); gpix_full=(WIDGET*)gui_gpix_create(NULL,1,1,12,12); if (!fullscreen) gui_gpix_set_pixmap((GPIX*)gpix_full,pix_full); else gui_gpix_set_pixmap((GPIX*)gpix_full,pix_win); gui_container_add(GUI_CONTAINER(button),gpix_full); /* quit button */ button=(WIDGET*)gui_button_create(NULL,286,3,14,14); gui_widget_add_keyfocus(desktop,button); GUI_BUTTON(button)->activate=quit_click; gui_container_add(GUI_CONTAINER(desktop),button); pix=(WIDGET*)gui_gpix_create(NULL,1,1,12,12); gui_gpix_set_pixmap((GPIX*)pix,load_img_rle(datadir,"close")); gui_container_add(GUI_CONTAINER(button),pix); desktop->map(desktop); //printf("ADD game\n"); gui_container_add(GUI_CONTAINER(desktop),wid_game); //printf("ADD setting\n"); gui_container_add(GUI_CONTAINER(desktop),wid_setting); //printf("ADD control\n"); gui_container_add(GUI_CONTAINER(desktop),wid_control); wid_game->map(wid_game); wid_setting->unmap(wid_setting); wid_control->unmap(wid_control); wid_current=wid_game; /* do not show progress bar for the moment */ ld_pbar->unmap(ld_pbar); ld_label->unmap(ld_label); //desktop=(WIDGET*)gui_frame_create(NULL,0,0,304,224,SHADOW_ETCHED_IN,"Game:"); }