Skip to content
Snippets Groups Projects
Commit 4633478c authored by Barnabás Czémán's avatar Barnabás Czémán
Browse files

settings.set -> settings.ini

parent f37624c1
No related branches found
No related tags found
No related merge requests found
......@@ -48,6 +48,7 @@
<Add option="-lSDL_gfx" />
<Add option="-lSDL_image" />
<Add option="-lSDL_ttf" />
<Add option="-liniparser" />
</Linker>
<Unit filename="button.c">
<Option compilerVar="CC" />
......
......@@ -4,7 +4,7 @@ HEADERS = button.h colors.h enums.h field.h game.h highscore.h init.h input.h la
CC = gcc
CFLAGS = -O2 `sdl-config --cflags`
LDFLAGS = -lm `sdl-config --libs` -lSDL_ttf -lSDL_gfx -lSDL_image -lSDL_mixer
LDFLAGS = -lm `sdl-config --libs` -lSDL_ttf -lSDL_gfx -lSDL_image -lSDL_mixer -liniparser
.PHONY: all clean
......
......@@ -14,18 +14,23 @@
You should have received a copy of the GNU General Public License
along with Minesweeper2D. If not, see <http://www.gnu.org/licenses/>.*/
#include "settings.h"
#include "iniparser.h"
#include <assert.h>
void loadSettings(Settings* settings){
FILE* fp;
fp=fopen("settings.set","rt");
if(fp==NULL){
printf("[Error]Cannot load settings!");
exit(1);
dictionary* data = iniparser_load("settings.ini");
if(data == NULL){
fprintf(stderr, "[ERROR] Cannot load settings.");
assert(-1);
}else{
fscanf(fp,"RESOLUTION: %d x %d\n",&settings->resolution.width,&settings->resolution.height);
fscanf(fp,"COLORDEPTH: %d\n",&settings->mode.bpp);
fscanf(fp,"ORIENTATION: %x\n",&settings->mode.state);
settings->resolution.width = iniparser_getint(data, "Resolution:width", 600);
settings->resolution.height = iniparser_getint(data, "Resolution:height", 600);
settings->mode.bpp = iniparser_getint(data, "Mode:depth", 32);
settings->mode.state = iniparser_getint(data, "Mode:state", WINDOWED);
}
fclose(fp);
iniparser_freedict(data);
}
[Resolution]
width = 800
heigh = 600
[Mode]
depth = 32
state = 0x10000000
\ No newline at end of file
RESOLUTION: 800 x 600
COLORDEPTH: 32
ORIENTATION: 0x10000000
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment