示例#1
0
Err			menu(t_info *info)
{
  preload_menu(info);
  load_menu(info);
  info->exit = 0;
  info->menu_over = 0;
  while (!info->exit)
    {
      SDL_Delay(10);
      while (SDL_PollEvent(&(info->mysdl.event)))
	{
	  if (info->mysdl.event.type == SDL_MOUSEMOTION)
	    menu_mousemotion(info, info->mysdl.event);
	  else if (info->mysdl.event.type == SDL_MOUSEBUTTONDOWN)
	    menu_mousebutton(info, info->mysdl.event);
	  else if (info->mysdl.event.type == SDL_KEYDOWN)
	    menu_key(info, info->mysdl.event);
	  else if (info->mysdl.event.type == SDL_VIDEORESIZE)
	    {
	      resize_window(info, info->mysdl.event.resize.w,
			    info->mysdl.event.resize.h);
	      update_menu(info);
	    }
	  else if (info->mysdl.event.type == SDL_QUIT)
	    info->exit = 1;
	    break;
	}
    }
  free_menu(info);
  SDL_Quit();
  return (0);
}
示例#2
0
void		window(char *file)
{
	int	loop;
	unsigned int	framelimit;

	framelimit = 0;
	loop = 0;
	game.file = file;
	if (init_all() == 0 && game.map != NULL)
	{
		load_audio();
		//load_intro();
		while (loop == 0)
		{
			loop = get_input_menu();
			load_menu();
			while (loop == 1)
			{
				loop = get_input_game();
				load_game();
				framelimit = delay(framelimit);
			}
			framelimit = delay(framelimit);
		}
	}
	exit_game();
}
示例#3
0
static void inbox_received_callback(DictionaryIterator *iterator, void *context) {
  dict_write_begin(&items_iter, items_buffer, ITEMS_BUFFER_SIZE);
  Tuple *t = dict_read_first(iterator);
  while(t != NULL) {
    dict_write_cstring(&items_iter, (int) t->key, (char*) t->value->cstring);
    t = dict_read_next(iterator);
  }
  int items_size = dict_write_end(&items_iter);
  load_menu();
}
示例#4
0
文件: game.c 项目: ricardoleitee/LCOM
int game() {

	int menu = 0;

	load_cards();
	load_menu();

	if ((irq_set = keyboard_subscribe_int()) == 1) {
		vg_exit();
		return 1;
	}

	while (menu == 0) {
		if (keyboard_int_handler(irq_set) == 0) {
			if (scancode == 0x82) {
				menu = 1;
				vg_fill(0xff);
				vg_draw("/usr/src/drivers/proj/images/image_nivel3.mg", 64, 167,
						428, 36);
				vg_draw_all(&d1, 134, 180);
				vg_draw("/usr/src/drivers/proj/images/image_selected.mg",
						d1.cards[0]->height, d1.cards[0]->width, d1.posx[0],
						d1.posy[0]);
			} else {
				if (scancode == 0x83) {
					vg_exit();
					return 0;
				}
			}
		}
	}

	while (game_over == 0) {
		if (keyboard_int_handler(irq_set) == 0) {
			game_handling(&d1);
		}
	}

	if (keyboard_unsubscribe_int() != 0) {
		return 1;
	}

	sleep(5);
	vg_exit();
	return 0;
}
//Menu algoritmos sequenciais
void load_vectors (void)
{
	do
	{
		printf("\n\t../Vectors \n");
		printf("\nPlease choose one of the following options:\n");
		printf("_____________________________________________________\n\n");

		printf("1.-----------------------------------------------------\n");
		printf("2.-----------------------------------------------------\n");
		printf("3.-----------------------------------------------------\n");
		printf("4.-----------------------------------------------------\n");
		printf("5.-----------------------------------------------------\n");
		printf("6. Return\n");
		printf("7. Exit\n");

		printf("_____________________________________________________\n\n");
		printf("\t\tEnter Choice: ");
		scanf("%u", &choice);

		system("clear");

		 switch(choice)
		{
			case 1: first();
				break;
			case 2: second();
				break;
			case 3: third();
				break;
			case 4: fourth();
				break;
			case 5: fifth();
				break;
			case 6: load_menu();
				break;
			case 7: printf("\nQuitting program!\n");
				exit(FLAG);
				break;
			default: printf("\nInvalid choice!\n");
				break;
		}
	} while (choice != 11);
}
 void load_alg_loop (void)
{
	do
	{
		printf("\n\tLoop algorithms \n");
		printf("\nPlease choose one of the following options:\n");

		printf("___________________________________________\n\n");
		printf("1. Loop algorithms - For\n");
		printf("2. Loop algorithms - While\n");
		printf("3. Loop algorithms - Do While\n");
		printf("4. Return\n");
		printf("5. Exit\n");

		printf("___________________________________________\n\n");
		printf("\t\tEnter Choice: ");
		scanf("%u", &choice);

		system("clear");

		switch (choice)
		{
			case 1: load_alg_loop_for();
				break;
			case 2: load_alg_loop_while();
				break;
			case 3: load_alg_loop_do_while();
				break;
			case 4: load_menu();
				break;
			case 5: printf("\nQuitting program!\n");
				exit(FLAG);
				break;
			default: printf("\nInvalid choice!\n");
				break;
		}
	} while (choice != 5);
}
示例#7
0
void initialize (int *argc, char **argv[], char ***envp)
{
    char    buf[512], *p;
    char    inifile[MAX_PATH], ifile[MAX_PATH];
    time_t     t1;
    struct tm  tm1;
#ifdef __MINGW32__
    WSADATA wsa;
#endif

    //putenv ("TZ=GMT0");
    //tzset ();

    // first we need to initialize FLY variables
    fly_initialize ();
    fl_opt.appname = "nftp";

    if (fl_opt.has_console)
        fprintf (stderr, "\nNFTP - Version%sof %s, %s"
                 "\nCopyright (C) Sergey Ayukov 1994--2000.\n\n",
                 NFTP_VERSION, __DATE__, __TIME__);

    fly_process_args (argc, argv, envp);

    // checking command-line arguments
    check_args (*argc, *argv);

    // find where our config files are
    determine_paths ((*argv)[0]);

    // delete old temporary files
    clear_tmp ();

    // loading configuration files
    init_config ();

    // initilialize debug subsystem if specified
    if (options.debug)
    {
        sprintf (buf, /*sizeof(buf),*/ "%s/debug", paths.user_libpath);
        mkdir1 (buf, 0700);
        sprintf (buf, /*sizeof(buf),*/ "%s/debug/nftp.dbg.%u", paths.user_libpath, (int)getpid ());
        dbfile = fopen (buf, "w");
        tools_debug = dbfile;
    }

    if (options.log_cc)
    {
        sprintf (buf, /*sizeof(buf),*/ "%s/CC", paths.user_libpath);
        mkdir1 (buf, 0700);
        t1 = time (NULL);
        tm1 = *localtime (&t1);
        sprintf (buf, "CC/%04d-%02d-%02d.%02d:%02d:%02d.log",
                 tm1.tm_year+1900, tm1.tm_mon, tm1.tm_mday,
                 tm1.tm_hour, tm1.tm_min, tm1.tm_sec);
        p = str_sjoin (paths.user_libpath, buf);
        cc_log = fopen (p, "w");
        if (cc_log == NULL) options.log_cc = FALSE;
        free (p);
    }

    // load language-specific things
    nls_init (paths.system_libpath, paths.user_libpath);
    load_menu ();

    // check for correct NFTP.INI version
    strcpy (buf, NFTP_VERSION);
    str_strip2 (buf, " ");
    //if (str_numchars (buf, '.') > 1)  *(strrchr (buf, '.')) = '\0';
    if (strcmp (options.version, buf) != 0)
    {
        // looking for nftp.i file in user dir, then in system dir
        strcpy (ifile, paths.user_libpath);
        str_cats (ifile, "nftp.i");
        if (access (ifile, R_OK) != 0)
        {
            strcpy (ifile, paths.system_libpath);
            str_cats (ifile, "nftp.i");
            if (access (ifile, R_OK) != 0)
                fly_error (MSG(M_INI_CANT_FIND_NFTP_I),
                        paths.user_libpath, paths.system_libpath);
        }
        strcpy (inifile, paths.user_libpath);
        str_cats (inifile, "nftp.ini");
        update_inifile (inifile, ifile);
        GetProfileOptions (inifile);
    }

    config_fly ();

#ifdef __MINGW32__
    WSAStartup (MAKEWORD(1,1), &wsa);
#endif
}
//Menu algorithmos condicionais
void load_alg_conditional(void)
{
	do
	{
		printf("\n\t../Conditional Algorithms \n");
		printf("\nPlease choose one of the following options:\n");

		printf("______________________________________________________\n\n");
		printf("1.------------------------------------------------------\n");
		printf("2.------------------------------------------------------\n");
		printf("3.------------------------------------------------------\n");
		printf("4.------------------------------------------------------\n");
		printf("5.------------------------------------------------------\n");
		printf("6.------------------------------------------------------\n");
		printf("7.------------------------------------------------------\n");
		printf("8.------------------------------------------------------\n");
		printf("9.------------------------------------------------------\n");
		printf("10.-----------------------------------------------------\n");
		printf("11.-----------------------------------------------------\n");
		printf("12.Return...\n");
		printf("13.Exit\n");

		printf("_____________________________________________________\n\n");
		printf("\t\tEnter Choice: ");
		scanf("%u", &choice);

		system("clear");

		 switch(choice)
		{
			case 1: first();
				break;
			case 2: second();
				break;
			case 3: third();
				break;
			case 4: fourth();
				break;
			case 5: fifth();
				break;
			case 6: sixth();
				break;
			case 7: seventh();
				break;
			case 8: eighth();
				break;
			case 9: ninth();
				break;
			case 10: tenth();
				break;
			case 11: eleventh();
				break;
			case 12: load_menu();
				break;
			case 13: printf("\n Quitting program!\n");
				exit(FLAG);
				break;
			default: printf("\n Invalid choice!\n");
				break;
		}
	} while (choice != 8);
}
示例#9
0
文件: main.c 项目: roca5461/lager_v02
int main() {

    load_menu();
    return 0;

}
示例#10
0
void menu_setup(void) {
    cgc_memset(&todays_menu, '\0', sizeof(Menu));
    load_menu(&todays_menu);
}
示例#11
0
void graphicsMenu(world * gameWorld, char *server_ip)
{
    int in_menu = 1;
    int mouse_pressed = 0;
    int menu_choice = 0;

    //fps
    struct timer_t2 fps;

    printf("Before trying to load the menu in load manu\n");
    init_draw();
    //load menu
    if ( load_menu("menu/main_menu_background.png",
              "menu/play_inactiv.png",
              "menu/options_inactiv.png",
              "menu/editor_inactiv.png",
              "menu/exit_inactiv.png",
              "menu/back_inactiv.png",
              SCREEN_WIDTH,
              SCREEN_HEIGHT)
        == -1)
    {
        clean_up();
        printf("couldn't read texture, quitting\n");
        exit(-3);
    }
    load_level();

    printf("After load menu\n");

    //wait for user to continue or exit
    while( in_menu != 0 )
    {
        //Start the frame timer
        timer_start(&fps);
        //While there are events to handle
        while( SDL_PollEvent( &event ) )
        {

            if( event.type == SDL_QUIT )
            {
                //exit
                clean_up();
                exit(0);
            }

            if (mouse_pressed != 1)
            {
                mouse_over_menu(event.button.x, event.button.y);
            }

            if( event.type == SDL_MOUSEBUTTONDOWN)
            {
                switch(event.button.button)
                {
                    case SDL_BUTTON_LEFT:
                        mouse_pressed = mouse_down_menu(event.button.x, event.button.y);
                        break;
                }
            }

            //is mousebuttom being pressed
            if( event.type == SDL_MOUSEBUTTONUP)
            {
                switch(event.button.button)
                {
                    case SDL_BUTTON_LEFT:
                        menu_choice = press_menu(event.button.x, event.button.y);
                        break;
                }
            }
        }
        //draw menu
        drawMenu(SCREEN_WIDTH, SCREEN_HEIGHT);

        switch(menu_choice)
        {
            case 1:
                printf("quitting menu, trying to play\n");
                in_menu = 0;
                drawLoadScr(SCREEN_WIDTH, SCREEN_HEIGHT);
                break;
            case 2:
                menu_choice = 0;
                options(server_ip);
                break;
            case 3:
                menu_choice = 0;
                editor(gameWorld);
                break;
            case 4:
                clean_up();
                exit(0);
                break;
            default:
                break;
        }

        if( timer_get_ticks(&fps) < 1000 / FRAMES_PER_SECOND )
        {
            //delay the as much time as we need to get desired frames per second
            SDL_Delay( ( 1000 / FRAMES_PER_SECOND ) - timer_get_ticks(&fps) );
        }
    }
}
示例#12
0
void load_current_menu(){
    load_menu(current_menu);	
}
示例#13
0
void load_main_menu(ClickRecognizerRef recognizer, void *context){
	last_menu = current_menu;
	load_menu(MAIN_MENU);
}
示例#14
0
文件: ui.cpp 项目: JUX84/3tXc4
void play_menu ( uint8_t height , uint8_t width , uint8_t alignWinSize , uint8_t alignWinTotal , uint8_t AI_prof ) { // play game menu

	int32_t Key;
	uint8_t row , col;
	uint8_t selected ( 1 );

	while ( true ) {

		getmaxyx ( stdscr , row , col );

		if ( selected < 1 )
			selected = 1;

		if ( selected > 3 )
			selected = 3;

		clear ();

		attron ( A_BOLD );

		mvprintw ( row / 4 , ( col - STR_PLAY_MENU.length () + 1 ) / 2 , STR_PLAY_MENU.c_str () );

		mvprintw ( ( row / 2 ) + ( ( selected - 1 ) * 2 ) , 5 * col / 20 , STR_ARROW_RIGHT.c_str () );
		mvprintw ( ( row / 2 ) + ( ( selected - 1 ) * 2 ) , 15 * col / 20 , STR_ARROW_LEFT.c_str () );

		mvprintw ( 2 , 2 , STR_HELP.c_str () );

		attroff ( A_BOLD );

		mvprintw ( row / 2 , ( col - STR_1N1.length () + 1 ) / 2 , STR_1N1.c_str () );
		mvprintw ( ( row / 2 ) + 2 , ( col - STR_1NAI.length () + 1 ) / 2 , STR_1NAI.c_str () );
		mvprintw ( ( row / 2 ) + 4 , ( col - STR_LOAD.length () + 1 ) / 2 , STR_LOAD.c_str () );

		refresh();

		Key = getch ();

		if ( Key == KEY_DOWN )
			selected += 1;

		if ( Key == KEY_UP )
			selected -= 1;

		if ( Key == ENTER ) {

			if ( selected == 1 ) {

				grid *G = new grid ();
				play ( G , height , width , alignWinSize , alignWinTotal , false , AI_prof );
			}

			if ( selected == 2 ) {

				grid *G = new grid ();
				play ( G, height , width , alignWinSize , alignWinTotal , true , AI_prof );
			}

			if ( selected == 3 )
				load_menu ();

			break;
		}

		if ( Key == KEY_V ) {

			grid *G = new grid ();
			play ( G , height , width , alignWinSize , alignWinTotal , false , AI_prof );
		}

		if ( Key == KEY_A ) {

			grid *G = new grid ();
			play ( G , height , width , alignWinSize , alignWinTotal , true , AI_prof );
		}

		if ( Key == KEY_L )
			load_menu ();

		if ( Key == ESC )
			return;
	}
}
示例#15
0
void initialize (int *argc, char **argv[], char ***envp)
{
    char    buf[512];
    char    inifile[MAX_PATH], ifile[MAX_PATH];
#ifdef __MINGW32__    
    WSADATA wsa;
#endif

    //putenv ("TZ=GMT0");
    //tzset ();
    
    // first we need to initialize FLY variables
    fly_initialize ();
    fl_opt.appname = "nftp";
    
    if (fl_opt.has_console)
        fprintf (stderr, "\nNFTP - Version%sof %s, %s"
                 "\nCopyright (C) Sergey Ayukov 1994-2003.\n\n",
                 NFTP_VERSION, __DATE__, __TIME__);

    fly_process_args (argc, argv, envp);
    
    // checking command-line arguments
    check_args (*argc, *argv);
    
    // find where our config files are
    determine_paths ((*argv)[0]);

    // delete old temporary files
    clear_tmp ();
    
    // loading configuration files
    init_config ();

    // initilialize debug subsystem if specified
    if (options.debug)
    {
        snprintf1 (buf, sizeof(buf), "%s/debug", paths.user_libpath);
#ifdef __WIN32__        
        mkdir (buf);
#else
        mkdir (buf, 0700);
#endif
        snprintf1 (buf, sizeof(buf), "%s/debug/nftp.dbg.%u", paths.user_libpath, (int)getpid ());
        dbfile = fopen (buf, "w");
        tools_debug = dbfile;
    }

    // load language-specific things
    /*nls_init (paths.system_libpath, paths.user_libpath);*/
    load_menu ();

    // check for correct NFTP.INI version
    strcpy (buf, NFTP_VERSION);
    str_strip2 (buf, " ");
    //if (str_numchars (buf, '.') > 1)  *(strrchr (buf, '.')) = '\0';
    if (strcmp (options.version, buf) != 0)
    {
        // looking for nftp.i file in user dir, then in system dir
        strcpy (ifile, paths.user_libpath);
        str_cats (ifile, "nftp.i");
        if (access (ifile, R_OK) != 0)
        {
            strcpy (ifile, paths.system_libpath);
            str_cats (ifile, "nftp.i");
            if (access (ifile, R_OK) != 0)
                fly_error (M("Cannot find nftp.i to update nftp.ini\n"
                             "neither in '%s' nor in '%s'!"),
                           paths.user_libpath, paths.system_libpath);
        }
        strcpy (inifile, paths.user_libpath);
        str_cats (inifile, "nftp.ini");
        // ask user and update ini file
        //if (fl_opt.has_console) // otherwise it's too annoying
        //{
        //    fprintf (stderr, M("Your current config file, %s, has version %s.\n"
        //         "NFTP executable version number is %s."),
        //         inifile, options.version, buf);
        //    fprintf (stderr, M(
        //            "Going to update   '%s'\n"
        //            "from              '%s'.\n"
        //            "Proceed? [Ynq]", inifile, ifile);
        //    fgets (buf, sizeof(buf), stdin);
        //    switch (buf[0])
        //    {
        //    case 'Q': case 'q': exit (0);
        //    case 'N': case 'n': break;
        //    case 'Y': case 'y': default:
        //        update_inifile (inifile, ifile);
        //    }
        //}
        //else
        //{
            update_inifile (inifile, ifile);
        //}
        GetProfileOptions (inifile);
    }
    
    config_fly ();

#ifdef __MINGW32__    
    WSAStartup (MAKEWORD(1,1), &wsa);
#endif
}
示例#16
0
int main(int argc, char** argv)
{
    load_menu();
    return 0;
}