Esempio n. 1
0
////////////////////////////////////////////////////////////////////////////////
// A helper function for loading an Allegro dat file where bitmaps are
// supposed to be stored.
MAS::Error MAS::Skin::LoadData(ALLEGRO_PATH *dir, ALLEGRO_CONFIG *config) {
   if (!dir || !al_is_path_present(dir) || !al_get_path_filename(dir)) {
      return Error(Error::SKIN_DAT);
   }

   // load the datafile
   int i;
   char tmp[256];
   const char *str;

   // Look for each bitmap inside and load it if it exists
   for (i=0; i<nBitmaps; i++) {
      al_set_path_filename(dir, bitmapName[i]);
	  al_set_path_extension(dir, ".png");
      const char *fullPath = al_path_cstr(dir, ALLEGRO_NATIVE_PATH_SEP);
      Bitmap bmp;
      if (bmp.Load(fullPath, Bitmap::MEMORY) == Error::NONE) {
         bmpList[i]->Set(bmp, true, MAS::Settings::useVideoMemory ? Bitmap::VIDEO : Bitmap::MEMORY);

         snprintf(tmp, 256, "%s_TCKX", bitmapName[i]);
         bmpList[i]->ThickX((str = al_get_config_value(config, "TILING", tmp)) ? strtol(str, NULL, 10) : -1);
         snprintf(tmp, 256, "%s_TCKY", bitmapName[i]);
         bmpList[i]->ThickY((str = al_get_config_value(config, "TILING", tmp)) ? strtol(str, NULL, 10) : -1);
      }
   }

   al_set_path_filename(dir, "");

   return Error(Error::NONE);
}
Esempio n. 2
0
File: path.c Progetto: trezker/allua
static int allua_Path_get_filename(lua_State * L)
{
   ALLUA_path path = allua_check_path(L, 1);

   lua_pushstring(L, al_get_path_filename(path));

   return 1;
}
Esempio n. 3
0
/* 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);
   }
}
Esempio n. 4
0
// standard paths not yet implemented
void init_standard_paths(void)
{


	settings.path_to_executable [0] = 0;

 if (settings.option [OPTION_STANDARD_PATHS] == STANDARD_PATHS_EXECUTABLE)
	{
// Unfortunately there does not seem to be any simple way to find the execution directory.
// We can only get the full path of the executable, including the file name.
// So we need to remove the file name from the end of the path:

  ALLEGRO_PATH* executable_path;
  executable_path = al_get_standard_path(ALLEGRO_EXENAME_PATH);

  if (executable_path == NULL)
		{
// may still be okay...
			fpr("\nFailed to get executable path. Attempting to run using relative paths...");
			return;
		}

  char filename [100]; // 100 should be plenty of room
  strncpy(filename, al_get_path_filename(executable_path), 95); // 95 should too
  int filename_length = strlen(filename);

//  const char* temp_path = al_path_cstr(executable_path, ALLEGRO_NATIVE_PATH_SEP); // this pointer should be valid until the path is modified
//  int temp_path_length = strlen(temp_path);
  char file_path [FILE_PATH_LENGTH];
  strncpy(file_path, al_path_cstr(executable_path, ALLEGRO_NATIVE_PATH_SEP), FILE_PATH_LENGTH - 5);
  int file_path_length = strlen(file_path);
  if (file_path_length >= FILE_PATH_LENGTH - 10)
  {
	  fpr("\nSorry, your file path (%s) is too long (%i characters; the maximum is %i).", file_path, file_path_length, FILE_PATH_LENGTH - 10);
			fpr("\nAttempting to run using relative paths...");
			return;
  }
  file_path [file_path_length - filename_length] = 0;

		strcpy(settings.path_to_executable, file_path);

  al_destroy_path(executable_path);

		return;
	}

 if (settings.option [OPTION_STANDARD_PATHS] == STANDARD_PATHS_VARIOUS)
	{



/*
  ALLEGRO_PATH* standard_path;

// PATH_TYPE_RESOURCES:
  standard_path = al_get_standard_path(ALLEGRO_RESOURCES_PATH);

  if (standard_path == NULL)
// may still be okay...
			fpr("\nFailed to get resources path. Attempting to run using relative path...");
			 else
				{
					  char temp_path [FILE_PATH_LENGTH];
       strncpy(temp_path, al_path_cstr(standard_path, ALLEGRO_NATIVE_PATH_SEP), FILE_PATH_LENGTH - 10);
       int temp_path_length = strlen(temp_path);
       if (temp_path_length >= FILE_PATH_LENGTH - 20)
							{
									  fpr("\nSorry, your resources path (%s) is too long (maximum %i).", temp_path, FILE_PATH_LENGTH - 20);
			        fpr("\nAttempting to run using relative path...");
							}
							 else
								{
									strcpy(settings.standard_path [PATH_TYPE_RESOURCES], temp_path;
								}
      al_destroy_path(standard_path);
				}
*/
	}




// settings.option [OPTION_STANDARD_PATHS] is probably STANDARD_PATHS_NONE


		return;

}