2 Copyright (c)2006-2007 - Brett Lajzer
4 See LICENSE for license information.
15 void print_usage(string progname
){
16 cerr
<< "USAGE: " << progname
<< " [dir] | [-h|--help]\n";
17 cerr
<< " dir - directory where game data is\n";
18 cerr
<< " -h --help - displays this usage info\n\n";
21 //configuration loader
22 //loads config into lua, retrieves values and leaves them there
23 SDL_Surface
*load_config(lua_State
*L
, string pname
){
24 if(luaL_loadfile(L
, "scripts/config.lua") || lua_pcall(L
,0,0,0)){
25 cerr
<< "Cannot load configuration script!\n" << "Error: " <<lua_tostring(L
, -1) << "\n";
30 //put the config values on the stack
31 lua_getglobal(L
, "s_fullscreen");
32 lua_getglobal(L
, "s_width");
33 lua_getglobal(L
, "s_height");
34 lua_getglobal(L
, "s_depth");
35 lua_getglobal(L
, "s_gamename");
37 //check values for proper type
38 if(!lua_isnumber(L
,-5)){
39 cerr
<< "Config Error: "<< "'s_fullscreen' should be a number\n";
42 if(!lua_isnumber(L
,-4)){
43 cerr
<< "Config Error: "<< "'s_width' should be a number\n";
46 if(!lua_isnumber(L
,-3)){
47 cerr
<< "Config Error: "<< "'s_height' should be a number\n";
50 if(!lua_isnumber(L
,-2)){
51 cerr
<< "Config Error: "<< "'s_depth' should be a number\n";
54 if(!lua_isstring(L
,-1)){
55 cerr
<< "Config Error: "<< "'s_gamename' should be a string\n";
59 //set caption and return the surface
60 SDL_WM_SetCaption(lua_tostring(L
,-1), lua_tostring(L
, -1));
62 SDL_Surface
*temp
= SDL_SetVideoMode(lua_tointeger(L
, -4), lua_tointeger(L
, -3), lua_tointeger(L
, -2), SDL_HWSURFACE
| (lua_tointeger(L
,-5)? SDL_FULLSCREEN
: 0));
63 for(int i
=0; i
< 5; i
++){lua_pop(L
,-1);}
67 //function for clearing out the image store
69 map
<string
, SDL_Surface
*>::iterator im
= image_store
.begin();
71 for(; im
!= image_store
.end(); im
++){
72 SDL_FreeSurface(im
->second
);