示例#1
0
文件: main.c 项目: purchae/xtc
static void main_loop(void) {

	key_type key;
	int processed;

	while (current_mode != QUIT_MODE) {
		key = uppercase_key(read_key());
		switch(current_mode) {
			case DIR_TREE_MODE: processed = dir_window_process_key(key); break;
			case FILE_LIST_MODE: processed = file_window_process_key(key); break;
			default: processed = FALSE;
		}
		/* process global keys */
		if (!processed) switch (key) {
			case      'Q': if (confirm_quit()) current_mode = QUIT_MODE; break; /* quit */
			case F_KEY(2): config_screen_main();                         break; /* configuration */
			case ALT_KEY('S'): file_window_change_sort_order();          break; /* change sort order of file window */
			case ALT_KEY('F'): file_window_change_display_format();      break;
			case          'F': file_window_set_filespec();               break; /* set filespec */
		}
	}

}
示例#2
0
文件: sgame.c 项目: grrk-bzzt/kqlives
/*! \brief Display system menu
 *
 * This is the system menu that is invoked from within the game.
 * From here you can save, load, configure a couple of options or
 * exit the game altogether.
 * \date 20040229 PH added 'Save anytime' facility when cheat mode is ON
 *
 * \returns 0 if cancelled or nothing happened, 1 otherwise
 */
int system_menu (void)
{
   int stop = 0, ptr = 0;
   char save_str[10];
   int text_color = FNORMAL;

   strcpy (save_str, _("Save  "));

   if (cansave == 0) {
      text_color = FDARK;
#ifdef KQ_CHEATS
      if (cheat) {
         strcpy (save_str, _("[Save]"));
         text_color = FNORMAL;
      }
#endif /* KQ_CHEATS */
   }

   while (!stop) {
      check_animation ();
      drawmap ();
      menubox (double_buffer, xofs, yofs, 8, 4, BLUE);

      print_font (double_buffer, 16 + xofs, 8 + yofs, save_str, text_color);
      print_font (double_buffer, 16 + xofs, 16 + yofs, _("Load"), FNORMAL);
      print_font (double_buffer, 16 + xofs, 24 + yofs, _("Config"), FNORMAL);
      print_font (double_buffer, 16 + xofs, 32 + yofs, _("Exit"), FNORMAL);

      draw_sprite (double_buffer, menuptr, 0 + xofs, ptr * 8 + 8 + yofs);
      blit2screen (xofs, yofs);
      readcontrols ();


      // TT:
      // When pressed, 'up' or 'down' == 1.  Otherwise, they equal 0.  So:
      //    ptr = ptr - up + down;
      // will correctly modify the pointer, but with less code.
      if (up || down) {
         ptr = ptr + up - down;
         if (ptr < 0)
            ptr = 3;
         else if (ptr > 3)
            ptr = 0;
         play_effect (SND_CLICK, 128);
         unpress ();
      }

      if (balt) {
         unpress ();

         if (ptr == 0) {
            // Pointer is over the SAVE option
#ifdef KQ_CHEATS
            if (cansave == 1 || cheat)
#else
            if (cansave == 1)
#endif /* KQ_CHEATS */
            {
               saveload (1);
               stop = 1;
            } else
               play_effect (SND_BAD, 128);
         }

         if (ptr == 1) {
            if (saveload (0) != 0)
               stop = 1;
         }

         if (ptr == 2)
            config_menu ();

         if (ptr == 3)
            return confirm_quit ();
      }

      if (bctrl) {
         stop = 1;
         unpress ();
      }
   }

   return 0;
}
示例#3
0
/* Callback for the bar operations */
static gboolean
item_event_bar (GooCanvasItem  *item,
		GooCanvasItem  *target,
		GdkEventButton *event,
		GComprisBarFlags flag)
{
  GcomprisBoard *gcomprisBoard = gc_board_get_current();

  if(_hidden)
    return(FALSE);

  bar_reset_sound_id();
  gc_sound_play_ogg ("sounds/bleep.wav", NULL);

  switch (flag)
    {
    case GC_BAR_LEVEL:
      {
        current_level++;
        if(gcomprisBoard && current_level > gcomprisBoard->maxlevel)
          current_level=1;

        /* Set the level */
        if(gcomprisBoard && gcomprisBoard->plugin->set_level != NULL)
          gcomprisBoard->plugin->set_level(current_level);

        gc_bar_play_level_voice(current_level);
      }
      break;
    case GC_BAR_LEVEL_DOWN:
      {
        /* Decrease the level */
        current_level--;
        if(current_level < 1)
          current_level = gcomprisBoard->maxlevel;

        /* Set the level */
        if(gcomprisBoard && gcomprisBoard->plugin->set_level != NULL)
          gcomprisBoard->plugin->set_level(current_level);

        gc_bar_play_level_voice(current_level);
      }
      break;
    case GC_BAR_HOME:
      {
        bar_hide (TRUE);
        gc_board_stop();
      }
      break;
    case GC_BAR_HELP:
      {
        gc_help_start(gcomprisBoard);
      }
      break;
    case GC_BAR_REPEAT_ICON:
    case GC_BAR_REPEAT:
      {
        if(gcomprisBoard && gcomprisBoard->plugin->repeat != NULL)
          {
            gcomprisBoard->plugin->repeat();
          }
      }
      break;
    case GC_BAR_CONFIG:
      {
        if(gcomprisBoard && gcomprisBoard->plugin->config_start != NULL)
          {
            gcomprisBoard->plugin->config_start(gcomprisBoard,
                                                gc_profile_get_current());
          }
      }
      break;
    case GC_BAR_ABOUT:
      {
        gc_about_start();
      }
      break;
    case GC_BAR_EXIT:
      {
        GcomprisProperties *properties = gc_prop_get();

        if(strlen(properties->root_menu) == 1)
          gc_confirm_box( _("GCompris confirmation"),
                          _("Are you sure you want to quit?"),
                          _("Yes, I am sure!"),
                          _("No, I want to keep going"),
                          (ConfirmCallBack) confirm_quit);
        else
          confirm_quit(TRUE);
      }
      break;
    default:
      break;
    }
  return TRUE;
}
示例#4
0
文件: menu.c 项目: spippolatore/abuse
void main_menu()
{
  int y=yres/2-210;
  ico_button *list=make_conditional_buttons(xres-51,y);
  list=make_default_buttons(xres-51,y,list);


  input_manager *inm=new input_manager(screen,eh,list);
  inm->allow_no_selections();
  inm->clear_current();

  time_marker old_time;

  screen->add_dirty(0,0,xres-1,yres-1);

  int eoff=0,coff=0;
  event ev;
 
#ifdef __MAC__
	int command = 0;
#endif

  int state=0,stop_menu=0;
  time_marker start;
  eh->flush_screen(); 
  do
  {
    time_marker new_time;

    if (eh->event_waiting())
    {
      do { eh->get_event(ev); } while (ev.type==EV_MOUSE_MOVE && eh->event_waiting()); 
      inm->handle_event(ev,NULL,eh);

#ifdef __MAC__
      if ((ev.type==EV_KEY || ev.type==EV_KEYRELEASE) && ev.key==JK_COMMAND)
      	command = (ev.type == EV_KEY);
      if (ev.type==EV_KEY && ev.key=='q' && command)
        eh->push_event(new event(ID_QUIT,NULL));
#else
      if (ev.type==EV_KEY && ev.key==JK_ESC)
        eh->push_event(new event(ID_QUIT,NULL));
#endif

      menu_handler(ev,inm);
      start.get_time();
      
      eh->flush_screen();
    }

    if (new_time.diff_time(&start)>22)
    {
      if (volume_window)
        start.get_time();
      else
      {
				if (!current_demo)
				{
				  void *d=make_find_symbol("demos");
				  if (DEFINEDP(symbol_value(d)))
				  current_demo=symbol_value(d);
				}
				if (current_demo)
				{
				  demo_man.set_state(demo_manager::PLAYING,lstring_value(CAR(current_demo)));
				  stop_menu=1;
				  current_demo=CDR(current_demo);
				}
      }
    }

    if (volume_window) stop_menu=0;  // can't exit with colume window open
    else if (main_net_cfg && main_net_cfg->restart_state()) stop_menu=1;
    else if (the_game->state==RUN_STATE) stop_menu=1;
    else if (ev.type==EV_MESSAGE)
    {
      if (ev.message.id==ID_START_GAME || ev.message.id==ID_RETURN) stop_menu=1;
      else if (ev.message.id==ID_QUIT)
      {
#ifdef __MAC__
				stop_menu=1;
#else
				if (confirm_quit()) 
					stop_menu=1;
				else 
				{ 
					ev.type=EV_SPURIOUS;
					start.get_time(); 
				}
#endif
      }
    }

  } while (!stop_menu);

  delete inm;


  if (ev.type==EV_MESSAGE && ev.message.id==ID_QUIT)   // propogate the quit message
    the_game->end_session();
}
示例#5
0
void
com_quit(wordlist *wl)
{
    int exitcode = EXIT_NORMAL;

    bool noask =
        (wl  &&  wl->wl_word  &&  1 == sscanf(wl->wl_word, "%d", &exitcode)) ||
        (wl  &&  wl->wl_word  &&  cieq(wl->wl_word, "noask"))  ||
        cp_getvar("noaskquit", CP_BOOL, NULL);

    /* update screen and reset terminal */
    gr_clean();
    cp_ccon(FALSE);

    /* Make sure the guy really wants to quit. */
    if (!ft_nutmeg)
        if (!noask && !confirm_quit())
            return;

    /* start to clean up the mess */

#ifdef SHARED_MODULE
    {
        wordlist all = { "all", NULL, NULL };
        wordlist star = { "*", NULL, NULL };

//      com_remcirc(NULL);
        com_destroy(&all);
        com_unalias(&star);
        com_undefine(&star);

        cp_remvar("history");
        cp_remvar("noglob");
        cp_remvar("brief");
        cp_remvar("sourcepath");
        cp_remvar("program");
        cp_remvar("prompt");
    }
#endif

#ifdef EXPERIMENTAL_CODE
    /* Destroy CKT when quit. Add by Gong Ding, [email protected] */
    if (!ft_nutmeg) {
        struct circ *cc;
        for (cc = ft_circuits; cc; cc = cc->ci_next)
            if (SIMinfo.deleteCircuit)
                SIMinfo.deleteCircuit(cc->ci_ckt);
    }
#endif

#ifdef SHARED_MODULE
    /* Destroy CKT when quit. */
    if (!ft_nutmeg) {
        while(ft_curckt)
            com_remcirc(NULL);
    }
#endif

    DevSwitch(NULL);
    DevSwitch(NULL);

    /* then go away */

#ifdef SHARED_MODULE
    cp_destroy_keywords();
    destroy_ivars();
#endif

    byemesg();
#ifdef SHARED_MODULE
    destroy_const_plot();
    spice_destroy_devices();
#endif
#ifdef SHARED_MODULE
    /* add 1000 to notify that we exit from 'quit' */
    controlled_exit(1000 + exitcode);
#else
    exit(exitcode);
#endif
}