コード例 #1
0
char* GetDataFilePath(char* filename) {

	char *result = 0;

	if (al_filename_exists(filename)) {
		return strdup(filename);
	}

	char origfn[255] = "data/";
	strcat(origfn, filename);

	if (al_filename_exists(origfn)) {
		return strdup(origfn);
	}

	void TestPath(char* subpath) {
		ALLEGRO_PATH *tail = al_create_path(filename);
		ALLEGRO_PATH *path = al_get_standard_path(ALLEGRO_RESOURCES_PATH);
		ALLEGRO_PATH *data = al_create_path(subpath);
		al_join_paths(path, data);
		al_join_paths(path, tail);
		//printf("Testing for %s\n", al_path_cstr(path, ALLEGRO_NATIVE_PATH_SEP));
		if (al_filename_exists(al_path_cstr(path, ALLEGRO_NATIVE_PATH_SEP))) {
			result = strdup(al_path_cstr(path, ALLEGRO_NATIVE_PATH_SEP));
		}
		al_destroy_path(tail);
		al_destroy_path(data);
		al_destroy_path(path);
	}
コード例 #2
0
static ALLEGRO_PATH *follow_symlinks(ALLEGRO_PATH *path)
{
   for (;;) {
      const char *path_str = al_path_cstr(path, '/');
      char buf[PATH_MAX];
      int len;

      len = readlink(path_str, buf, sizeof(buf) - 1);
      if (len <= 0)
         break;
      buf[len] = '\0';
      al_destroy_path(path);
      path = al_create_path(buf);
   }

   /* Make absolute path. */
   {
      const char *cwd = al_get_current_directory();
      ALLEGRO_PATH *cwd_path = al_create_path_for_directory(cwd);
      if (al_rebase_path(cwd_path, path))
         al_make_path_canonical(path);
      al_destroy_path(cwd_path);
      al_free((void *) cwd);
   }

   return path;
}
コード例 #3
0
bool Message::Init()
{
	ALLEGRO_PATH * pPath = al_get_standard_path(ALLEGRO_RESOURCES_PATH);
	al_append_path_component(pPath, "graphics");
    al_append_path_component(pPath, "Avatar");

    for (int i=0;i<7;i++)
	{
		char szFileName[255];
		sprintf(szFileName,"av%03d.png",i);
		al_set_path_filename(pPath,szFileName);
        ALLEGRO_BITMAP * pBitmap = al_load_bitmap(al_path_cstr(pPath,ALLEGRO_NATIVE_PATH_SEP));
	    if (pBitmap!=NULL)
	    {
	        g_lstAvatar.push_back(pBitmap);
	    }
	    else
	    {
            al_destroy_path(pPath);
            return false;
	    }
	}

	al_destroy_path(pPath);
	return true;
}
コード例 #4
0
ファイル: config.c プロジェクト: Lodus/SuperDerpy
void InitConfig(void) {
	ALLEGRO_PATH *path = al_get_standard_path(ALLEGRO_USER_SETTINGS_PATH);
	ALLEGRO_PATH *data = al_create_path("SuperDerpy.ini");
	al_join_paths(path, data);
	config = al_load_config_file(al_path_cstr(path, ALLEGRO_NATIVE_PATH_SEP));
	if (!config) config=al_create_config();
	al_destroy_path(path);
	al_destroy_path(data);
}
コード例 #5
0
ファイル: config.c プロジェクト: Lodus/SuperDerpy
void DeinitConfig(void) {
	ALLEGRO_PATH *path = al_get_standard_path(ALLEGRO_USER_SETTINGS_PATH);
	ALLEGRO_PATH *data = al_create_path("SuperDerpy.ini");
	al_make_directory(al_path_cstr(path, ALLEGRO_NATIVE_PATH_SEP));
	al_join_paths(path, data);
	al_save_config_file(al_path_cstr(path, ALLEGRO_NATIVE_PATH_SEP), config);
	al_destroy_path(path);
	al_destroy_path(data);
	al_destroy_config(config);
}
コード例 #6
0
ファイル: config.c プロジェクト: dos1/libsuperderpy
SYMBOL_EXPORT void DeinitConfig(struct Game* game) {
	const ALLEGRO_FILE_INTERFACE* iface = al_get_new_file_interface();
	al_set_standard_file_interface();
	ALLEGRO_PATH* path = al_get_standard_path(ALLEGRO_USER_SETTINGS_PATH);
	ALLEGRO_PATH* data = al_create_path("SuperDerpy.ini");
	al_make_directory(al_path_cstr(path, ALLEGRO_NATIVE_PATH_SEP));
	al_join_paths(path, data);
	al_save_config_file(al_path_cstr(path, ALLEGRO_NATIVE_PATH_SEP), game->_priv.config);
	al_destroy_path(path);
	al_destroy_path(data);
	al_destroy_config(game->_priv.config);
	al_set_new_file_interface(iface);
}
コード例 #7
0
ファイル: wsystem.c プロジェクト: BorisCarvajal/allegro5
/*
 * Calling LoadLibrary with a relative file name is a security risk:
 * see e.g. Microsoft Security Advisory (2269637)
 * "Insecure Library Loading Could Allow Remote Code Execution"
 */
HMODULE _al_win_safe_load_library(const char *filename)
{
    ALLEGRO_PATH *path1 = NULL;
    ALLEGRO_PATH *path2 = NULL;
    char buf[MAX_PATH];
    const char *other_dirs[3];
    HMODULE lib = NULL;
    bool msvc_only = false;

    /* MSVC only: if the executable is in the build configuration directory,
     * which is also just under the current directory, then also try to load the
     * library from the current directory.  This leads to less surprises when
     * running example programs.
     */
#if defined(ALLEGRO_MSVC)
    msvc_only = true;
#endif

    /* Try to load the library from the directory containing the running
     * executable, the Windows system directories, or directories on the PATH.
     * Do NOT try to load the library from the current directory.
     */

    if (al_is_system_installed()) {
        path1 = al_get_standard_path(ALLEGRO_RESOURCES_PATH);
    }
    else if (GetModuleFileName(NULL, buf, sizeof(buf)) < sizeof(buf)) {
        path1 = al_create_path(buf);
    }
    if (msvc_only) {
        path2 = maybe_parent_dir(path1);
    }

    other_dirs[0] = path1 ? al_path_cstr(path1, '\\') : NULL;
    other_dirs[1] = path2 ? al_path_cstr(path2, '\\') : NULL;
    other_dirs[2] = NULL; /* sentinel */

    _al_sane_strncpy(buf, filename, sizeof(buf));
    if (PathFindOnPath(buf, other_dirs)) {
        ALLEGRO_DEBUG("PathFindOnPath found: %s\n", buf);
        lib = load_library_at_path(buf);
    }
    else {
        ALLEGRO_WARN("PathFindOnPath failed to find %s\n", filename);
    }

    al_destroy_path(path1);
    al_destroy_path(path2);

    return lib;
}
コード例 #8
0
ファイル: system.c プロジェクト: liballeg/allegro5
static void read_allegro_cfg(void)
{
   /* We assume that the stdio file interface is in effect. */

   ALLEGRO_PATH *path;
   ALLEGRO_CONFIG *temp;

   if (!sys_config)
      sys_config = al_create_config();

#if defined(ALLEGRO_UNIX) && !defined(ALLEGRO_IPHONE)
   temp = al_load_config_file("/etc/allegro5rc");
   if (temp) {
      al_merge_config_into(sys_config, temp);
      al_destroy_config(temp);
   }

   path = _al_unix_get_path(ALLEGRO_USER_HOME_PATH);
   if (path) {
      al_set_path_filename(path, "allegro5rc");
      temp = al_load_config_file(al_path_cstr(path, '/'));
      if (temp) {
         al_merge_config_into(sys_config, temp);
         al_destroy_config(temp);
      }
      al_set_path_filename(path, ".allegro5rc");
      temp = al_load_config_file(al_path_cstr(path, '/'));
      if (temp) {
         al_merge_config_into(sys_config, temp);
         al_destroy_config(temp);
      }
      al_destroy_path(path);
   }
#endif

   path = early_get_exename_path();
   if (path) {
      al_set_path_filename(path, "allegro5.cfg");
      temp = al_load_config_file(al_path_cstr(path, ALLEGRO_NATIVE_PATH_SEP));
      if (temp) {
         al_merge_config_into(sys_config, temp);
         al_destroy_config(temp);
      }
      al_destroy_path(path);
   }
   /* Reconfigure logging in case something changed. */
   _al_configure_logging();
}
コード例 #9
0
ファイル: GUI.cpp プロジェクト: BorisCarvajal/allegro5
static void read_scores(void)
{
   ALLEGRO_PATH *fn = userResourcePath();

   if (al_make_directory(al_path_cstr(fn, ALLEGRO_NATIVE_PATH_SEP))) {
      al_set_path_filename(fn, "scores.cfg");
      ALLEGRO_CONFIG *cfg = al_load_config_file(al_path_cstr(fn, ALLEGRO_NATIVE_PATH_SEP));
      if (cfg) {
         for (int i = 0; i < NUM_SCORES; i++) {
            char name[]  = {'n', (char)('0'+i), '\0'};
            char score[] = {'s', (char)('0'+i), '\0'};
            const char *v;

            v = al_get_config_value(cfg, "scores", name);
            if (v && strlen(v) <= 3) {
               strcpy(highScores[i].name, v);
            }
            v = al_get_config_value(cfg, "scores", score);
            if (v) {
               highScores[i].score = atoi(v);
            }
         }

         al_destroy_config(cfg);
      }
   }

   al_destroy_path(fn);
}
コード例 #10
0
ファイル: path.c プロジェクト: sesc4mt/mvcdecoder
/* Function: al_make_path_absolute
 */
bool al_make_path_absolute(ALLEGRO_PATH *path)
{
   ALLEGRO_PATH *cwd_path;
   int i;

   ASSERT(path);

   if (path_is_absolute(path)) {
      return true;
   }

   cwd_path = al_get_current_directory();
   if (!cwd_path)
      return false;

   al_set_path_drive(path, al_get_path_drive(cwd_path));

   for (i = al_get_path_num_components(cwd_path) - 1; i >= 0; i--) {
      al_insert_path_component(path, 0, al_get_path_component(cwd_path, i));
   }

   al_destroy_path(cwd_path);

   return true;
}
コード例 #11
0
ファイル: path.c プロジェクト: sesc4mt/mvcdecoder
/* Function: al_create_path
 */
ALLEGRO_PATH *al_create_path(const char *str)
{
   ALLEGRO_PATH *path;

   path = _AL_MALLOC(sizeof(ALLEGRO_PATH));
   if (!path)
      return NULL;

   path->drive = al_ustr_new("");
   path->filename = al_ustr_new("");
   _al_vector_init(&path->segments, sizeof(ALLEGRO_USTR *));
   path->basename = al_ustr_new("");
   path->full_string = al_ustr_new("");

   if (str != NULL) {
      ALLEGRO_USTR *copy = al_ustr_new(str);
      replace_backslashes(copy);

      if (!parse_path_string(copy, path)) {
         al_destroy_path(path);
         path = NULL;
      }

      al_ustr_free(copy);
   }

   return path;
}
コード例 #12
0
ファイル: windowspc.cpp プロジェクト: pmprog/ROTMenu
bool Windows::LoadProfile()
{
#ifdef WIN32
	char szPath[MAX_PATH];
	ALLEGRO_PATH* alPath;
	bool res;

	if( al_filename_exists( "c4a-prof" ) )
		return ParseProfileFile( "c4a-prof" );

	if( SHGetFolderPathA( 0, CSIDL_PERSONAL, 0, 0, (char*)&szPath ) == S_OK )
	{
		alPath = al_create_path( (char*)&szPath );
		al_append_path_component( alPath, "c4a-prof" );

		if( al_filename_exists( al_path_cstr( alPath, '/' ) ) )
			res = ParseProfileFile( (char*)al_path_cstr( alPath, '/' ) );

		al_destroy_path( alPath );
		return res;
	}
	return false;

#else
	return false;
#endif
}
コード例 #13
0
ファイル: Game.cpp プロジェクト: dradtke/battlechess
const char* getResource(const char* fmt, ...)
{
   va_list ap;
   static char res[512];
   static ALLEGRO_PATH *dir;
   static ALLEGRO_PATH *path;

   va_start(ap, fmt);
   memset(res, 0, 512);
   snprintf(res, 511, fmt, ap);

   if (!dir) {
      dir = al_get_standard_path(ALLEGRO_RESOURCES_PATH);
#ifdef ALLEGRO_MSVC
      {
         /* Hack to cope automatically with MSVC workspaces. */
         const char *last = al_get_path_component(dir, -1);
         if (0 == strcmp(last, "Debug")
            || 0 == strcmp(last, "RelWithDebInfo")
            || 0 == strcmp(last, "Release")
            || 0 == strcmp(last, "Profile")) {
            al_remove_path_component(dir, -1);
         }
      }
#endif
      al_append_path_component(dir, "data");
   }

   if (path)
      al_destroy_path(path);

   path = al_create_path(res);
   al_rebase_path(dir, path);
   return al_path_cstr(path, '/');
}
コード例 #14
0
ファイル: main.c プロジェクト: beoran/eruta
/* Testing function for al_get_standard_path */
void puts_standard_path(int path, char * name) {
  ALLEGRO_PATH * testpath;
  testpath =  al_get_standard_path(path);
  puts(name);
  puts(al_path_cstr(testpath, ALLEGRO_NATIVE_PATH_SEP));
  al_destroy_path(testpath);
}
コード例 #15
0
ファイル: xdisplay.c プロジェクト: billyquith/allegro5
static void xdpy_set_window_title_default(ALLEGRO_DISPLAY *display, const char *title)
{
   ALLEGRO_SYSTEM_XGLX *system = (ALLEGRO_SYSTEM_XGLX *)al_get_system_driver();
   ALLEGRO_DISPLAY_XGLX *glx = (ALLEGRO_DISPLAY_XGLX *)display;

   {
      Atom WM_NAME = XInternAtom(system->x11display, "WM_NAME", False);
      Atom _NET_WM_NAME = XInternAtom(system->x11display, "_NET_WM_NAME", False);
      char *list[1] = { (char *) title };
      XTextProperty property;

      Xutf8TextListToTextProperty(system->x11display, list, 1, XUTF8StringStyle,
         &property);
      XSetTextProperty(system->x11display, glx->window, &property, WM_NAME);
      XSetTextProperty(system->x11display, glx->window, &property, _NET_WM_NAME);
      XSetTextProperty(system->x11display, glx->window, &property, XA_WM_NAME);
      XFree(property.value);
   }
   {
      XClassHint *hint = XAllocClassHint();
      if (hint) {
         ALLEGRO_PATH *exepath = al_get_standard_path(ALLEGRO_EXENAME_PATH);
         // hint doesn't use a const char*, so we use strdup to create a non const string
         hint->res_name = strdup(al_get_path_basename(exepath));
         hint->res_class = strdup(al_get_path_basename(exepath));
         XSetClassHint(system->x11display, glx->window, hint);
         free(hint->res_name);
         free(hint->res_class);
         XFree(hint);
         al_destroy_path(exepath);
      }
   }
}
コード例 #16
0
ファイル: SaveSlots.cpp プロジェクト: EdwinMartens/star_trek
SlotManager::SlotManager(bool a_blLoading,  ALLEGRO_PATH * a_pSearchpath,void (* a_pCallBack)(string))

{
    m_ColorInner     = al_map_rgb(0,0,0);
    m_ColorOuter     = al_map_rgb(100,100,255);
    m_ColorHighlight = al_map_rgb(0,0,255);
    m_pActiveSlot    = NULL;
    m_blLoading      = a_blLoading;
    m_pCallBack      = a_pCallBack;
    m_nIndex         = 1;

    if (a_pSearchpath!=NULL)
    {
        ALLEGRO_FS_ENTRY * pDir = al_create_fs_entry(al_path_cstr(a_pSearchpath,ALLEGRO_NATIVE_PATH_SEP));
        if (al_open_directory(pDir))
        {
            ALLEGRO_FS_ENTRY * pFile;
            while (pFile = al_read_directory(pDir))
            {
                ALLEGRO_PATH * pPath = al_create_path(al_get_fs_entry_name(pFile));

                AddSlot(al_get_path_basename(pPath));

                al_destroy_path(pPath);
                al_destroy_fs_entry(pFile);
            }
        }
        al_destroy_fs_entry(pDir);
    }

    if (!a_blLoading)
    {
        AddSlot("NEW SAVE...");
    }
}
コード例 #17
0
ファイル: video.c プロジェクト: fatcerberus/allegro5
/* Function: al_open_video
 */
ALLEGRO_VIDEO *al_open_video(char const *filename)
{
   ALLEGRO_VIDEO *video;
   const char *extension = filename + strlen(filename) - 1;

   while ((extension >= filename) && (*extension != '.'))
      extension--;
   video = al_calloc(1, sizeof *video);
   
   video->vtable = find_handler(extension);

   if (video->vtable == NULL) {
      ALLEGRO_ERROR("No handler for video extension %s - "
         "therefore not trying to load %s.\n", extension, filename);
      al_free(video);
      return NULL;
   }
   
   video->filename = al_create_path(filename);
   video->playing = true;

   if (!video->vtable->open_video(video)) {
      ALLEGRO_ERROR("Could not open %s.\n", filename);
      al_destroy_path(video->filename);
      al_free(video);
      return NULL;
   }
   
   al_init_user_event_source(&video->es);
   video->es_inited = true;
   
   return video;
}
コード例 #18
0
/** Creates filedialog and returns filepath(s) on succes, empty string on failure.*/
void cbeFileDialog(CBEnchanted * cb) {
	int mode = cb->popValue().getInt();
	string patterns = cb->popValue().toString().getRef();
#ifdef _WIN32
	string title = cb->popValue().toString().getRef();
#else
	string title = cb->popValue().toString().getUtf8Encoded();
#endif
	ALLEGRO_PATH * path = cb->popValue().toString().getPath();

	ALLEGRO_FILECHOOSER * fC = al_create_native_file_dialog(al_path_cstr(path, ALLEGRO_NATIVE_PATH_SEP), title.c_str(), patterns.c_str(), mode);
	al_destroy_path(path);

	if(fC == NULL) {
		cb->errors->createError("Can't create FileDialog!");
		cb->pushValue(0);
		return;
	}
	bool retVal = al_show_native_file_dialog(cb->gfxInterface->getWindow(), fC);

	if(retVal) {
		string filePaths = "";
		for(int count = 0; count < al_get_native_file_dialog_count(fC); count++) {
			filePaths += string(al_get_native_file_dialog_path(fC, count)) + string("|");
		}
		cb->pushValue(filePaths.substr(0, filePaths.length()-1));
	} else {
		cb->pushValue(string(""));
	}

	al_destroy_native_file_dialog(fC);

}
コード例 #19
0
ファイル: c_tile.cpp プロジェクト: DFHack/isoworld
s_sprite c_tile::get_from_ini(ALLEGRO_CONFIG *config, const char * section, ALLEGRO_PATH * base_path)
{
    s_sprite temp;

    const char * buffer_file = al_get_config_value(config, section, "image_file");
    if(!buffer_file)
    {
        temp.index = -1;
        return temp;
    }
    ALLEGRO_PATH * imagepath = al_create_path(buffer_file);
    al_rebase_path(base_path, imagepath);
    temp.index = imagelist.load_image(al_path_cstr(imagepath, ALLEGRO_NATIVE_PATH_SEP));

    temp.x = get_config_int(config, section, "x");
    temp.y = get_config_int(config, section, "y");

    temp.width = get_config_int(config, section, "width");
    temp.height = get_config_int(config, section, "height");

    temp.origin_x = get_config_int(config, section, "origin_x");
    temp.origin_y = get_config_int(config, section, "origin_y");

    temp.origin_x = 0 - temp.origin_x;
    temp.origin_y = 0 - temp.origin_y;

    temp.palette_number = get_config_int(config, section, "palette_index");

    temp.column_height = get_config_int(config, section, "column_height");

    const char * color_selection = al_get_config_value(config, section, "color_source");
    if(color_selection)
        temp.color_by = get_color_selector(color_selection);

    const char * pal_source = al_get_config_value(config, section, "palette_source");
    if(pal_source)
        temp.color_source = get_color_source(pal_source);

    const char * color = al_get_config_value(config, section, "color_html");
    if(color)
        temp.color = color_html(color);

    const char * off = al_get_config_value(config, section, "offset_type");
    if(off)
        temp.offset_type = get_offset_type(off);

    const char * neigh = al_get_config_value(config, section, "border_terrain");
    if(neigh)
        temp.border_terrain = get_terrain_type(neigh);

    const char * neighbobj = al_get_config_value(config, section, "border_structure");
    if(neighbobj)
        temp.border_structure = get_structure_type(neighbobj);

    temp.offset_amount = get_config_int(config, section, "offset_amount");

    al_destroy_path(imagepath);
    return temp;
}
コード例 #20
0
static void fs_apk_destroy_entry(ALLEGRO_FS_ENTRY *fse)
{
   ALLEGRO_FS_ENTRY_APK *e = (ALLEGRO_FS_ENTRY_APK *)fse;
   if (e->is_dir_open)
      fs_apk_close_directory(fse);
   al_destroy_path(e->path);
   al_free(e);
}
コード例 #21
0
ファイル: system.c プロジェクト: ptitSeb/allegro51-pandora
/* Function: al_set_exe_name
 */
void al_set_exe_name(char const *path)
{
   ASSERT(active_sysdrv);
   if (active_sysdrv->user_exe_path) {
      al_destroy_path(active_sysdrv->user_exe_path);
   }
   active_sysdrv->user_exe_path = al_create_path(path);
}
コード例 #22
0
void SoundInterface::functionLoadSound(void) {
	ALLEGRO_PATH *path = cb->popValue().getString().getPath();
	const char *cpath = al_path_cstr(path, ALLEGRO_NATIVE_PATH_SEP);

	CBSound *snd = new CBSound;
	if(!snd->loadSound(cpath)){
		cb->errors->createError("LoadSound() failed!", "Failed to load file \"" + string(cpath) + "\"");
		cb->pushValue(0);
		al_destroy_path(path);
		return;
	}
	al_destroy_path(path);

	int32_t id = nextSampleId();
	sounds[id] = snd;
	cb->pushValue(id);
}
コード例 #23
0
void ObjectInterface::functionLoadObject(void) {
	cb->popValue(); //Rotation...
	ALLEGRO_PATH *path = cb->popValue().getString().getPath();
	const char *cpath = al_path_cstr(path, ALLEGRO_NATIVE_PATH_SEP);
	CBObject *obj = new CBObject;
	if (!obj->load(cpath)) {
		cb->errors->createError("LoadObject() failed!", "Failed to load file \"" + string(cpath) + "\"");
		cb->pushValue(0);
		al_destroy_path(path);
		return;
	}
	al_destroy_path(path);
	addToDrawOrder(obj);
	int32_t id = nextObjectId();
	objectMap[id] = obj;
	obj->setID(id);
	cb->pushValue(id);
}
コード例 #24
0
ファイル: framework.cpp プロジェクト: MarkOates/allegro_flare
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;
}
コード例 #25
0
/* Function: al_destroy_native_file_dialog
 */
void al_destroy_native_file_dialog(ALLEGRO_FILECHOOSER *dialog)
{
   ALLEGRO_NATIVE_DIALOG *fd = (ALLEGRO_NATIVE_DIALOG *)dialog;
   size_t i;

   if (!fd)
      return;

   _al_unregister_destructor(_al_dtor_list, fd);

   al_ustr_free(fd->title);
   al_destroy_path(fd->fc_initial_path);
   for (i = 0; i < fd->fc_path_count; i++) {
      al_destroy_path(fd->fc_paths[i]);
   }
   al_free(fd->fc_paths);
   al_ustr_free(fd->fc_patterns);
   al_free(fd);
}
コード例 #26
0
ファイル: ex_get_path.c プロジェクト: BorisCarvajal/allegro5
static void show_path(int id, const char *label)
{
   ALLEGRO_PATH *path;
   const char *path_str;

   path = al_get_standard_path(id);
   path_str = (path) ? al_path_cstr(path, ALLEGRO_NATIVE_PATH_SEP) : "<none>";
   log_printf("%s: %s\n", label, path_str);
   al_destroy_path(path);
}
コード例 #27
0
/* Function: al_close_video
 */
void al_close_video(ALLEGRO_VIDEO *video)
{
   if (video) {
      video->vtable->close_video(video);
      if (video->es_inited) {
         al_destroy_user_event_source(&video->es);
      }
      al_destroy_path(video->filename);
      al_free(video);
   }
}
コード例 #28
0
ファイル: map.cpp プロジェクト: faod/ld33
Tileset::Tileset(const char* filename)
{
    ALLEGRO_PATH *path;

    path = al_get_standard_path(ALLEGRO_RESOURCES_PATH);
    al_append_path_component(path, RESOURCES_DIR);
    al_set_path_filename(path, filename);
    spritesheet_ = al_load_bitmap(al_path_cstr(path, ALLEGRO_NATIVE_PATH_SEP));

    al_destroy_path(path);
}
コード例 #29
0
ファイル: path.c プロジェクト: trezker/allua
/* GC and meta
 * */
static int allua_Path_gc(lua_State * L)
{
   struct ALLUA_path_s *pi = (struct ALLUA_path_s *)lua_touserdata(L, 1);
   if (pi->gc_allowed) {
      ALLUA_path im = pi->path;
      printf("goodbye path (%p)\n", (void *)im);
      if (im)
         al_destroy_path(im);
   }
   return 0;
}
コード例 #30
0
ファイル: system.c プロジェクト: ptitSeb/allegro51-pandora
/* Function: al_set_app_name
 */
void al_set_app_name(const char *app_name)
{
   if (app_name) {
      _al_sane_strncpy(_al_app_name, app_name, sizeof(_al_app_name));
   }
   else {
      ALLEGRO_PATH *path;
      path = al_get_standard_path(ALLEGRO_EXENAME_PATH);
      _al_sane_strncpy(_al_app_name, al_get_path_filename(path), sizeof(_al_app_name));
      al_destroy_path(path);
   }
}