Example #1
0
component* menu_connect_create(scene *s) {
    connect_menu_data *local = malloc(sizeof(connect_menu_data));
    memset(local, 0, sizeof(connect_menu_data));
    local->s = s;

    // Text config
    text_settings tconf;
    text_defaults(&tconf);
    tconf.font = FONT_BIG;
    tconf.halign = TEXT_CENTER;
    tconf.cforeground = color_create(0, 121, 0, 255);

    component* menu = menu_create(11);
    menu_attach(menu, label_create(&tconf, "CONNECT TO SERVER"));
    menu_attach(menu, filler_create());

    local->addr_input = textinput_create(&tconf, "Host/IP", settings_get()->net.net_connect_ip);
    local->connect_button = textbutton_create(&tconf, "CONNECT", COM_ENABLED, menu_connect_start, s);
    local->cancel_button = textbutton_create(&tconf, "CANCEL", COM_ENABLED, menu_connect_cancel, s);
    widget_set_id(local->connect_button, NETWORK_CONNECT_IP_BUTTON_ID);
    menu_attach(menu, local->addr_input);
    menu_attach(menu, local->connect_button);
    menu_attach(menu, local->cancel_button);

    menu_set_userdata(menu, local);
    menu_set_free_cb(menu, menu_connect_free);
    menu_set_tick_cb(menu, menu_connect_tick);

    return menu;
}
Example #2
0
component* menu_audio_create(scene *s) {
    // Menu userdata
    audio_menu_data *local = malloc(sizeof(audio_menu_data));
    memset(local, 0, sizeof(audio_menu_data));
    local->old_audio_settings = settings_get()->sound;

    // Text config
    text_settings tconf;
    text_defaults(&tconf);
    tconf.font = FONT_BIG;
    tconf.halign = TEXT_CENTER;
    tconf.cforeground = color_create(0, 121, 0, 255);

    // Create menu and its header
    component* menu = menu_create(11);
    menu_attach(menu, label_create(&tconf, "AUDIO"));
    menu_attach(menu, filler_create());
    menu_attach(menu, textslider_create_bind(&tconf, "SOUND", 10, 1, menu_audio_sound_slide, NULL, &settings_get()->sound.sound_vol));
    menu_attach(menu, textslider_create_bind(&tconf, "MUSIC", 10, 1, menu_audio_music_slide, NULL, &settings_get()->sound.music_vol));
    menu_attach(menu, textselector_create_bind_opts(&tconf, "MONO", NULL, NULL, &settings_get()->sound.music_mono, mono_opts, 2));

    local->lib_selector = textselector_create(&tconf, "PLAYBACK:", menu_audio_library_toggled, local);
    module_source *sources = music_get_module_sources();
    for(int i = 0; sources[i].name != 0; i++) {
        textselector_add_option(local->lib_selector, sources[i].name);
        if(sources[i].id == settings_get()->sound.music_library) {
            textselector_set_pos(local->lib_selector, i);
        }
    }
    menu_attach(menu, local->lib_selector);

    local->freq_selector = textselector_create(&tconf, "FREQUENCY:", menu_audio_freq_toggled, local);
    menu_audio_reset_freqs(local, 1);
    menu_attach(menu, local->freq_selector);

    local->resampler_selector = textselector_create(&tconf, "RESAMPLE:", menu_audio_resampler_toggled, local);
    menu_audio_reset_resamplers(local, 1);
    menu_attach(menu, local->resampler_selector);

    menu_attach(menu, textbutton_create(&tconf, "DONE", COM_ENABLED, menu_audio_done, local));

    // Userdata & free function for it
    menu_set_userdata(menu, local);
    menu_set_free_cb(menu, menu_audio_free);
    return menu;
}
Example #3
0
component* menu_listen_create(scene *s) {
    listen_menu_data *local = malloc(sizeof(listen_menu_data));
    s->gs->role = ROLE_SERVER;
    local->s = s;

    // Form address (host)
    ENetAddress address;
    address.host = ENET_HOST_ANY;
    address.port = settings_get()->net.net_listen_port;

    // Set up host
    local->host = enet_host_create(&address, 1, 2, 0, 0);
    if(local->host == NULL) {
        DEBUG("Failed to initialize ENet server");
        free(local);
        return NULL;
    }
    enet_socket_set_option(local->host->socket, ENET_SOCKOPT_REUSEADDR, 1);

    // Text config
    text_settings tconf;
    text_defaults(&tconf);
    tconf.font = FONT_BIG;
    tconf.halign = TEXT_CENTER;
    tconf.cforeground = color_create(0, 121, 0, 255);

    // Create the menu
    component* menu = menu_create(11);
    menu_attach(menu, label_create(&tconf, "START SERVER"));
    menu_attach(menu, filler_create());
    menu_attach(menu, label_create(&tconf, "Waiting ..."));
    menu_attach(menu, filler_create());
    local->cancel_button = textbutton_create(&tconf, "CANCEL", COM_ENABLED, menu_listen_cancel, s);
    menu_attach(menu, local->cancel_button);

    menu_set_userdata(menu, local);
    menu_set_free_cb(menu, menu_listen_free);
    menu_set_tick_cb(menu, menu_listen_tick);
    return menu;
}
Example #4
0
component* menu_video_confirm_create(scene *s, settings_video *old_settings) {
    video_menu_confirm_data *local = malloc(sizeof(video_menu_confirm_data));
    memset(local, 0, sizeof(video_menu_confirm_data));
    local->video_accept_secs = 20;
    local->old_video_settings = old_settings;
    time(&local->video_accept_timer);

    // Text config
    text_settings tconf;
    text_defaults(&tconf);
    tconf.font = FONT_BIG;
    tconf.halign = TEXT_CENTER;
    tconf.cforeground = color_create(0, 121, 0, 255);

    component* menu = menu_create(11);
    menu_attach(menu, label_create(&tconf, "ACCEPT RESOLUTION?"));
    menu_attach(menu, filler_create());
    local->timeout_label = label_create(&tconf, "");
    menu_attach(menu, local->timeout_label);
    menu_attach(menu, filler_create());
    menu_attach(menu, textbutton_create(&tconf, "OK", COM_ENABLED, video_confirm_ok_clicked, local));
    menu_attach(menu, textbutton_create(&tconf, "CANCEL", COM_ENABLED, video_confirm_cancel_clicked, local));

    menu_set_userdata(menu, local);
    menu_set_free_cb(menu, menu_video_confirm_free);
    menu_set_tick_cb(menu, menu_video_confirm_tick);

    menu_video_confirm_update(menu);
    return menu;
}
Example #5
0
component* menu_gameplay_create(scene *s) {
    const char* fightmode_opts[] = {"NORMAL","HYPER"};
    const char* hazard_opts[] = {"OFF","ON"};

    // Text config
    text_settings tconf;
    text_defaults(&tconf);
    tconf.font = FONT_BIG;
    tconf.halign = TEXT_CENTER;
    tconf.cforeground = color_create(0, 121, 0, 255);

    component* menu = menu_create(11);
    menu_attach(menu, label_create(&tconf, "GAMEPLAY"));
    menu_attach(menu, filler_create());
    menu_attach(menu, textslider_create_bind(&tconf, "SPEED", 10, 1, menu_gameplay_speed_slide, s, &settings_get()->gameplay.speed));
    menu_attach(menu, textselector_create_bind_opts(&tconf, "FIGHT MODE", NULL, NULL, &settings_get()->gameplay.fight_mode, fightmode_opts, 2));
    menu_attach(menu, textslider_create_bind(&tconf, "POWER 1", 8, 0, NULL, NULL, &settings_get()->gameplay.power1));
    menu_attach(menu, textslider_create_bind(&tconf, "POWER 2", 8, 0, NULL, NULL, &settings_get()->gameplay.power2));
    menu_attach(menu, textselector_create_bind_opts(&tconf, "HAZARDS", NULL, NULL, &settings_get()->gameplay.hazards_on, hazard_opts, 2));
    menu_attach(menu, textselector_create_bind_opts(&tconf, "CPU:", NULL, NULL, &settings_get()->gameplay.difficulty, ai_difficulty_names, NUMBER_OF_AI_DIFFICULTY_TYPES));
    menu_attach(menu, textselector_create_bind_opts(&tconf, "", NULL, NULL, &settings_get()->gameplay.rounds, round_type_names, NUMBER_OF_ROUND_TYPES));
    menu_attach(menu, textbutton_create(&tconf, "DONE", COM_ENABLED, menu_gameplay_done, NULL));
    return menu;
}
Example #6
0
/* MAIN()
 * ================================================================
 */
VOID
main( VOID )
{
	OBJECT  *tree;
	WORD    i;
	WORD    button;
	GRECT   box;
	GRECT   xrect;
        WORD    tempx;

        GRECT   rect;
        MRETS   mk;
	
        WORD    ptitle, pitem, pmenu;
	OBJECT  *ptree;
        BOOLEAN flag;
	BOOLEAN done;
	WORD    dummy;

        WORD	xvalue;

        
	appl_init();

	phys_handle = graf_handle( &gl_wchar, &gl_hchar, &gl_wbox, &gl_hbox );

        graf_mouse( ARROW, 0L );
        
        rsrc_load( "TEST.RSC" );

        rsrc_gaddr( 0, MENU1, &ad_tree );
	rsrc_gaddr( 0, BIGBOX, &ad_box );
        rsrc_gaddr( 0, COUNTRY, &ad_country );
	rsrc_gaddr( 0, OTHER, &ad_other );
        rsrc_gaddr( 0, MENUBAR, &ad_menubar );
	rsrc_gaddr( 0, TREE6, &ad_extra );

	ad_other[ ROOT ].ob_x = ad_other[ ROOT ].ob_y = 0;
#if 0
	/* test setting delay and height variables */
	TData.Delay  = 100L;
	TData.Drag   = 10000L;
	TData.Delay  = 250L;
	TData.Speed  = 0L;
	TData.Height = 16;
	menu_settings( 1, &TData );
#endif

	/* test attaching submenus */
	Menu.mn_tree   = ad_country;
	Menu.mn_menu   = ROOT;
        Menu.mn_item   = Cur2;
	Menu.mn_scroll = TRUE;
	menu_attach( 1, ad_tree, DELETE, &Menu );

	Menu.mn_tree   = ad_other;
	Menu.mn_menu   = DISNEY;
        Menu.mn_item   = MICKEY;
	Menu.mn_scroll = FALSE;
	menu_attach( 1, ad_tree, FLOPPY, &Menu );

	Menu.mn_tree   = ad_other;
	Menu.mn_menu   = MODEM;
        Menu.mn_item   = Cur3;
	Menu.mn_scroll = FALSE;
        menu_attach( 1, ad_country, 5, &Menu );

	Menu.mn_tree   = ad_other;
	Menu.mn_menu   = DISNEY;
        Menu.mn_item   = MICKEY;
	Menu.mn_scroll = FALSE;
        menu_attach( 1, ad_country, 1, &Menu );

	Menu.mn_tree   = ad_other;
	Menu.mn_menu   = DISNEY;
        Menu.mn_item   = MICKEY;
	Menu.mn_scroll = FALSE;
	menu_attach( 1, ad_country, ARKANSAS, &Menu );

	Menu.mn_tree   = ad_other;
	Menu.mn_menu   = QUOTES;
        Menu.mn_item   = Cur4;
	Menu.mn_scroll = FALSE;
	menu_attach( 1, ad_other, 5, &Menu );

	Menu.mn_tree   = ad_country;
	Menu.mn_menu   = ROOT;
        Menu.mn_item   = Cur2;
	Menu.mn_scroll = TRUE;
	menu_attach( 1, ad_menubar, PASTE, &Menu );

	Menu.mn_tree   = ad_country;
	Menu.mn_menu   = ROOT;
        Menu.mn_item   = Cur2;
	Menu.mn_scroll = TRUE;
	menu_attach( 1, ad_menubar, FNEW, &Menu );

        menu_icheck( ad_tree, Cur1, 1 );
	menu_icheck( ad_country, Cur2, 1 );
	menu_icheck( ad_other, Cur3, 1 );
	menu_icheck( ad_other, Cur4, 1 );
	menu_icheck( ad_other, Cur5, 1 );

	ActiveTree( ad_box );

        form_center( ad_box, &rect.g_x, &rect.g_y, &rect.g_w, &rect.g_h );

	ObX( ROOT ) = rect.g_x;
        xrect = ObRect( TITLE1 );
        objc_offset( ad_box, TITLE1, &xrect.g_x, &xrect.g_y );
	tempx = xrect.g_x;
        xrect.g_x = (( xrect.g_x + 7 )/8 ) * 8;
	rect.g_x = rect.g_x + ( xrect.g_x - tempx );
	ObX( ROOT ) = rect.g_x;
	rect.g_x -= 3;

	form_dial( FMD_START, rect.g_x, rect.g_y, rect.g_w, rect.g_h,
			      rect.g_x, rect.g_y, rect.g_w, rect.g_h );
	objc_draw( ad_box, ROOT, MAX_DEPTH, rect.g_x, rect.g_y,
					    rect.g_w, rect.g_h );

        do
        {
	  ActiveTree( ad_box );
          button = form_do( ad_box, 0L );

	  switch( button )
	  {
	    case TITLE1:
			 box = ObRect( TITLE1 );
			 objc_offset( ad_box, TITLE1, &box.g_x, &box.g_y );
			 
			 Menu.mn_tree   = ad_tree;
			 Menu.mn_menu   = ROOT;
			 Menu.mn_item   = Cur1;
			 Menu.mn_scroll = FALSE;
			 flag = menu_popup( &Menu, box.g_x, box.g_y, &MData );
			 if( flag )
			   MenuCheck( MData.mn_tree,
				      MData.mn_menu, 
				      MData.mn_item );
			 break;

            case TITLE2:
			 box = ObRect( TITLE2 );
			 objc_offset( ad_box, TITLE2, &box.g_x, &box.g_y );

			 Menu.mn_tree   = ad_country;
			 Menu.mn_menu   = ROOT;
			 Menu.mn_item   = Cur2;
			 Menu.mn_scroll = TRUE;
			 flag = menu_popup( &Menu, box.g_x, box.g_y, &MData );
			 if( flag )
			   MenuCheck( MData.mn_tree,
				      MData.mn_menu,
				      MData.mn_item );
			 break;

            case TITLE3:
			 box = ObRect( TITLE3 );
			 objc_offset( ad_box, TITLE3, &box.g_x, &box.g_y );

			 Menu.mn_tree   = ad_other;
			 Menu.mn_menu   = MODEM;
			 Menu.mn_item   = Cur3;
			 Menu.mn_scroll = FALSE;
			 flag = menu_popup( &Menu, box.g_x, box.g_y, &MData );
			 if( flag )
			   MenuCheck( MData.mn_tree,
				      MData.mn_menu,
				      MData.mn_item );
			 break;

            case TITLE4:
			 box = ObRect( TITLE4 );
			 objc_offset( ad_box, TITLE4, &box.g_x, &box.g_y );

			 Menu.mn_tree   = ad_other;
			 Menu.mn_menu   = QUOTES;
			 Menu.mn_item   = Cur4;
			 Menu.mn_scroll = FALSE;
			 flag = menu_popup( &Menu, box.g_x, box.g_y, &MData );
			 if( flag )
			   MenuCheck( MData.mn_tree,
				      MData.mn_menu,
				      MData.mn_item );
			 break;

            default:
			break;
          }

        }while( button != XEXIT );

	form_dial( FMD_FINISH, rect.g_x, rect.g_y, rect.g_w, rect.g_h,
			       rect.g_x, rect.g_y, rect.g_w, rect.g_h );

        evnt_button( 1, 1, 0, &dummy, &dummy, &dummy, &dummy );



       /* display menubar stuff here */
        ActiveTree( ad_menubar );
        menu_bar( ad_menubar, TRUE );

        
	do
	{
	    evnt_mesag( msg );
	    if( msg[0] == MN_SELECTED )
	    {
		/* msg[7] is the parent of FQUIT - which the user can't know */
		ptr = &msg[5];
		if( ( *ptr == ad_menubar ) &&
                    ( msg[4] == FQUIT )
		  )
                {
		  button = form_alert( 1, "[1][ |  EXIT PROGRAM? ][OK|Cancel]");
		  if( button == 1 )
		    done = TRUE;
                }  
		else
		    MenuCheck( *ptr, msg[7], msg[4] );
		menu_tnormal( ad_menubar, msg[3], TRUE );
            }	
	}while( !done );
        menu_bar( ad_menubar, FALSE );

        rsrc_free();
	graf_mouse( ARROW, 0L );
	appl_exit();
}