2016-02-29 15:42:46 +01:00
|
|
|
/*
|
|
|
|
Copyright (C) 2015-2016 Parallel Realities
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2016-03-03 17:16:12 +01:00
|
|
|
#include "resources.h"
|
2016-02-29 15:42:46 +01:00
|
|
|
|
|
|
|
char **backgrounds;
|
|
|
|
char **planets;
|
2016-03-03 17:16:12 +01:00
|
|
|
char **musicFiles;
|
2016-02-29 15:42:46 +01:00
|
|
|
int numBackgrounds;
|
|
|
|
int numPlanets;
|
2016-03-03 17:16:12 +01:00
|
|
|
int numMusicFiles;
|
2016-02-29 15:42:46 +01:00
|
|
|
|
2016-03-03 17:16:12 +01:00
|
|
|
void initResources(void)
|
2016-02-29 15:42:46 +01:00
|
|
|
{
|
|
|
|
char **filenames;
|
|
|
|
int i;
|
2016-03-04 15:29:50 +01:00
|
|
|
|
2016-03-03 17:16:12 +01:00
|
|
|
numBackgrounds = numPlanets = numMusicFiles = 0;
|
2016-03-04 15:29:50 +01:00
|
|
|
|
|
|
|
filenames = getFileList("gfx/backgrounds", &numBackgrounds);
|
2016-02-29 15:42:46 +01:00
|
|
|
backgrounds = malloc(sizeof(char*) * numBackgrounds);
|
2016-03-04 15:29:50 +01:00
|
|
|
|
2016-02-29 15:42:46 +01:00
|
|
|
for (i = 0 ; i < numBackgrounds ; i++)
|
|
|
|
{
|
|
|
|
backgrounds[i] = malloc(sizeof(char) * MAX_FILENAME_LENGTH);
|
|
|
|
sprintf(backgrounds[i], "gfx/backgrounds/%s", filenames[i]);
|
2016-03-04 15:29:50 +01:00
|
|
|
|
2016-03-04 23:11:13 +01:00
|
|
|
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "Adding AUTO %s", filenames[i]);
|
|
|
|
|
2016-02-29 15:42:46 +01:00
|
|
|
free(filenames[i]);
|
|
|
|
}
|
2016-03-04 15:29:50 +01:00
|
|
|
|
2016-02-29 15:42:46 +01:00
|
|
|
free(filenames);
|
2016-03-04 15:29:50 +01:00
|
|
|
|
|
|
|
filenames = getFileList("gfx/planets", &numPlanets);
|
2016-02-29 15:42:46 +01:00
|
|
|
planets = malloc(sizeof(char*) * numPlanets);
|
2016-03-04 15:29:50 +01:00
|
|
|
|
2016-02-29 15:42:46 +01:00
|
|
|
for (i = 0 ; i < numPlanets ; i++)
|
|
|
|
{
|
|
|
|
planets[i] = malloc(sizeof(char) * MAX_FILENAME_LENGTH);
|
|
|
|
sprintf(planets[i], "gfx/planets/%s", filenames[i]);
|
2016-03-04 23:11:13 +01:00
|
|
|
|
|
|
|
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "Adding AUTO %s", filenames[i]);
|
|
|
|
|
2016-02-29 15:42:46 +01:00
|
|
|
free(filenames[i]);
|
|
|
|
}
|
2016-03-04 15:29:50 +01:00
|
|
|
|
2016-02-29 15:42:46 +01:00
|
|
|
free(filenames);
|
2016-03-04 15:29:50 +01:00
|
|
|
|
|
|
|
filenames = getFileList("music/battle/", &numMusicFiles);
|
|
|
|
|
2016-03-03 17:16:12 +01:00
|
|
|
musicFiles = malloc(sizeof(char*) * numMusicFiles);
|
2016-03-04 15:29:50 +01:00
|
|
|
|
2016-03-03 17:16:12 +01:00
|
|
|
for (i = 0 ; i < numMusicFiles ; i++)
|
2016-02-29 15:42:46 +01:00
|
|
|
{
|
2016-03-03 17:16:12 +01:00
|
|
|
musicFiles[i] = malloc(sizeof(char) * MAX_FILENAME_LENGTH);
|
|
|
|
sprintf(musicFiles[i], "music/battle/%s", filenames[i]);
|
2016-03-04 23:11:13 +01:00
|
|
|
|
|
|
|
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "Adding AUTO %s", filenames[i]);
|
|
|
|
|
2016-03-03 17:16:12 +01:00
|
|
|
free(filenames[i]);
|
2016-02-29 15:42:46 +01:00
|
|
|
}
|
2016-03-04 15:29:50 +01:00
|
|
|
|
2016-03-03 17:16:12 +01:00
|
|
|
free(filenames);
|
2016-02-29 15:42:46 +01:00
|
|
|
}
|
|
|
|
|
2016-02-29 17:00:32 +01:00
|
|
|
char *getBackgroundTextureName(int i)
|
2016-02-29 15:42:46 +01:00
|
|
|
{
|
|
|
|
return backgrounds[i % numBackgrounds];
|
|
|
|
}
|
|
|
|
|
2016-02-29 17:00:32 +01:00
|
|
|
char *getPlanetTextureName(int i)
|
2016-02-29 15:42:46 +01:00
|
|
|
{
|
|
|
|
return planets[i % numPlanets];
|
|
|
|
}
|
|
|
|
|
2016-03-03 17:16:12 +01:00
|
|
|
char *getMusicFilename(int i)
|
|
|
|
{
|
|
|
|
return musicFiles[i % numMusicFiles];
|
|
|
|
}
|
|
|
|
|
|
|
|
void destroyResources(void)
|
2016-02-29 15:42:46 +01:00
|
|
|
{
|
|
|
|
free(backgrounds);
|
|
|
|
free(planets);
|
2016-03-03 17:16:12 +01:00
|
|
|
free(musicFiles);
|
2016-02-29 15:42:46 +01:00
|
|
|
}
|