예제 #1
0
/* Function: al_shutdown_native_dialog_addon
 */
void al_shutdown_native_dialog_addon(void)
{
   if (inited_addon) {
      al_destroy_user_event_source(al_get_default_menu_event_source());
      _al_shutdown_native_dialog_addon();
      inited_addon = false;
   }
}
예제 #2
0
bool Framework::initialize(std::string config_filename)
{
   if (initialized) return initialized;

   if (!al_init()) std::cerr << "al_init() failed" << std::endl;

   ALLEGRO_PATH *resource_path = al_get_standard_path(ALLEGRO_RESOURCES_PATH);
   al_change_directory(al_path_cstr(resource_path, ALLEGRO_NATIVE_PATH_SEP));
   al_destroy_path(resource_path);

   if (!al_install_mouse()) std::cerr << "al_install_mouse() failed" << std::endl;
   if (!al_install_keyboard()) std::cerr << "al_install_keyboard() failed" << std::endl;
   if (!al_install_joystick()) std::cerr << "al_install_joystick() failed" << std::endl;
   if (!al_install_audio()) std::cerr << "al_install_audio() failed" << std::endl;

   if (!al_init_native_dialog_addon()) std::cerr << "al_init_native_dialog_addon() failed" << std::endl;
   if (!al_init_primitives_addon()) std::cerr << "al_init_primitives_addon() failed" << std::endl;
   if (!al_init_image_addon()) std::cerr << "al_init_image_addon() failed" << std::endl;
   if (!al_init_font_addon()) std::cerr << "al_init_font_addon() failed" << std::endl;
   if (!al_init_ttf_addon()) std::cerr << "al_init_ttf_addon() failed" << std::endl;
   if (!al_init_acodec_addon()) std::cerr << "al_init_acodec_addon() failed" << std::endl;

   if (!al_reserve_samples(32)) std::cerr << "al_reserve_samples() failed" << std::endl;

   srand(time(NULL));

   primary_timer = al_create_timer(ALLEGRO_BPS_TO_SECS(60));

   al_set_new_bitmap_flags(ALLEGRO_MIN_LINEAR | ALLEGRO_MAG_LINEAR);
   //	al_set_new_bitmap_flags(ALLEGRO_MIN_LINEAR | ALLEGRO_MAG_LINEAR | ALLEGRO_MIPMAP);

   builtin_font = al_create_builtin_font();

   event_queue = al_create_event_queue();
   al_register_event_source(event_queue, al_get_keyboard_event_source());
   al_register_event_source(event_queue, al_get_mouse_event_source());
   al_register_event_source(event_queue, al_get_joystick_event_source());
   al_register_event_source(event_queue, al_get_timer_event_source(primary_timer));
   al_register_event_source(event_queue, al_get_joystick_event_source());
   al_register_event_source(event_queue, al_get_default_menu_event_source());

   if (al_get_num_joysticks()) joystick = al_get_joystick(0); // make this better eventually
   else std::cerr << "no joystick(s) detected" << std::endl;

   instance = new Framework(config_filename);

   Attributes::create_datatype_definition(
      AllegroColorAttributeDatatype::IDENTIFIER,
      AllegroColorAttributeDatatype::to_val_func,
      AllegroColorAttributeDatatype::to_str_func
   );

   initialized = true;

   return true;
}
예제 #3
0
/* Function: al_init_native_dialog_addon
 */
bool al_init_native_dialog_addon(void)
{
   if (!inited_addon) {
      if (!_al_init_native_dialog_addon()) {
         ALLEGRO_ERROR("_al_init_native_dialog_addon failed.\n");
         return false;
      }
      inited_addon = true;
      al_init_user_event_source(al_get_default_menu_event_source());
      _al_add_exit_func(al_shutdown_native_dialog_addon,
         "al_shutdown_native_dialog_addon");
   }
   return true;
}
예제 #4
0
파일: menu.c 프로젝트: allefant/allegro5
/* Each platform implementation must call this when a menu has been clicked.
 * The display parameter should be sent if at all possible! If it isn't sent,
 * and the user is using non-unique ids, it won't know which display actually
 * triggered the menu click.
 */
bool _al_emit_menu_event(ALLEGRO_DISPLAY *display, uint16_t unique_id)
{
   ALLEGRO_EVENT event;
   _AL_MENU_ID *menu_id = NULL;
   ALLEGRO_EVENT_SOURCE *source = al_get_default_menu_event_source();

   /* try to find the menu that triggered the event */
   menu_id = _al_find_parent_menu_by_id(display, unique_id);

   if (menu_id->id == 0)
      return false;

   if (menu_id) {
      /* A menu was found associated with the id. See if it has an
       * event source associated with it, and adjust "source" accordingly. */
      ALLEGRO_MENU *m = menu_id->menu;
      while (true) {
         if (m->is_event_source) {
            source = &m->es;
            break;
         }
         
         if (!m->parent)
            break;

         /* m->parent is of type MENU_ITEM,
          *   which always has a parent of type MENU */
         ASSERT(m->parent->parent);
         m = m->parent->parent;
      }
   }

   event.user.type = ALLEGRO_EVENT_MENU_CLICK;
   event.user.data1 = menu_id->id;
   event.user.data2 = (intptr_t) display;
   event.user.data3 = (intptr_t) menu_id->menu;
      
   al_emit_user_event(source, &event, NULL);

   return true;
}
예제 #5
0
bool t3f_attach_menu(ALLEGRO_MENU * mp)
{
    al_register_event_source(t3f_queue, al_get_default_menu_event_source());
    al_set_display_menu(t3f_display, mp);
    return true;
}