70
80
testplayPhilename = argv[2];
83
if (strcmp(argv[1], "-t") == 0)
86
if ((strcmp(argv[1], "-d") == 0) && (argc == 3))
88
settings.forcedDir = argv[2];
74
// create a game directory
95
// create a game directory
76
string dir = Settings::getDefaultDirectory ();
77
mkdir(dir.c_str(), S_IRUSR | S_IWUSR | S_IXUSR);
97
string dir = Settings::getDefaultDirectory ();
98
mkdir(dir.c_str(), S_IRUSR | S_IWUSR | S_IXUSR);
79
_mkdir(Settings::getDefaultDirectory().c_str());
100
wchar_t wd[PATH_MAX];
101
MultiByteToWideChar(CP_UTF8, 0, Settings::getDefaultDirectory().c_str(), -1, wd, MAX_PATH);
82
// load default settings for things we might not ask too quickly about
83
settings.get("mouseSensivity", "5");
84
settings.get("musicVolume", "80");
85
settings.get("sfxVolume", "80");
105
// load default settings for things we might not ask too quickly about
106
settings.get("mouseSensivity", "5");
107
settings.get("keyboardSensivity", "5");
108
settings.get("musicVolume", "80");
109
settings.get("sfxVolume", "80");
110
settings.get("disableSpeedup", "FALSE");
90
112
if (SDL_Init(SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_TIMER) < 0)
92
printf("Could not initialize SDL:%s\n", SDL_GetError());
114
sprintf(err, "Could not initialize SDL:%s\n", SDL_GetError());
98
Uint32 fullscreen_flag = 0;
100
if (settings.getb("fullscreen", false))
101
fullscreen_flag = SDL_FULLSCREEN;
103
const SDL_VideoInfo *vi = SDL_GetVideoInfo();
104
uint bpp = vi->vfmt->BitsPerPixel;
109
SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 4 );
110
SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 4 );
111
SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 4 );
112
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );
113
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
118
SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 8 );
119
SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8 );
120
SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 8 );
122
Uint32 fullscreen_flag = 0;
124
if (settings.getb("fullscreen", false))
125
fullscreen_flag = SDL_FULLSCREEN;
127
const SDL_VideoInfo *vi = SDL_GetVideoInfo();
128
uint bpp = vi->vfmt->BitsPerPixel;
133
SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 4 );
134
SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 4 );
135
SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 4 );
136
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );
137
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
142
SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 8 );
143
SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8 );
144
SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 8 );
121
145
// SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 8 );
122
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );
123
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
127
cout << "This program requires at least 16bit display" << endl;
131
screenModes=SDL_ListModes(NULL, SDL_OPENGL | SDL_FULLSCREEN|SDL_HWSURFACE);
132
string res = settings.get("resolution", "640x480");
134
int vmx = atoi(res.c_str());
135
int vmy = atoi(res.substr(res.find_first_of("x") + 1).c_str());
137
screen = SDL_SetVideoMode(vmx, vmy, bpp, SDL_OPENGL | fullscreen_flag);
141
printf("%s \n", SDL_GetError());
145
SDL_WM_SetCaption("Zaz", NULL);
147
glColor3f(1.0, 0, 1.0);
148
font = new FTTextureFont(settings.getCFilename ("FreeSans.ttf"));
153
font2 = new FTPixmapFont(settings.getCFilename ("FreeMonoBold.ttf"));
157
font3 = new FTTextureFont(settings.getCFilename ("font1.ttf"));
146
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );
147
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
151
ERR("This program requires at least 16bit display");
155
screenModes=SDL_ListModes(NULL, SDL_OPENGL | SDL_FULLSCREEN|SDL_HWSURFACE);
157
string res = settings.get("resolution", "640x480");
159
int vmx = atoi(res.c_str());
160
int vmy = atoi(res.substr(res.find_first_of("x") + 1).c_str());
162
screen = SDL_SetVideoMode(vmx, vmy, bpp, SDL_OPENGL | fullscreen_flag);
166
// fallback to a safe resolution
167
screen = SDL_SetVideoMode(640, 480, bpp, SDL_OPENGL);
168
cout << "Falling back to 640x480 resolution" << endl;
171
sprintf(err, "%s \n", SDL_GetError());
176
// if fallback worked, let's save the changes
177
settings.setb("fullscreen", false);
178
settings.set("resolution", "640x480");
181
SDL_WM_SetCaption("Zaz", NULL);
183
glColor3f(1.0, 0, 1.0);
184
font = new FTTextureFont(settings.getCFilename ("FreeSans.ttf"));
186
ERR("Could not open FreeSans.ttf [" + settings.getFilename ("FreeSans.ttf") + "]");
188
font3 = new FTTextureFont(settings.getCFilename ("font1.ttf"));
190
ERR("Could not open font1.ttf [" + settings.getFilename ("font1.ttf") + "]");
192
font4 = new FTTextureFont(settings.getCFilename ("FreeMonoBold.ttf"));
194
ERR("Could not open FreeMonoBold.ttf [" + settings.getFilename ("FreeMonoBold.ttf") + "]");
201
profile = Profile(settings.get("last_profile", ""));
202
settings.set("last_profile", profile.getName());
169
207
if (testplayPhilename != 0)
171
Level level(settings.getCFilename(testplayPhilename));
172
Game game(&settings, screen, level, 0, 3, 5);
209
cout << "Testing:" << testplayPhilename << endl;
210
Level level(testplayPhilename, true);
211
Game game(screen, level, 0, 3, 5);
177
cout << "Must give a level to play" << endl;
216
ERR("Must give a level to play");
188
228
editorPhilename = defPhn;
191
Level level(editorPhilename);
192
Editor ed(&settings, screen, level);
232
Level level(editorPhilename, true);
233
Editor ed(screen, level);
196
if (!editor && !testplay)
198
MainMenu m(&settings, screen);
251
str << "0:::0:0:0:0:000:000/n";
252
s.Export("phbx.ogv", str, 1);
259
if (!editor && !testplay && !tests)
205
cout << e.file << ":" << e.line << ":" << e.msg << endl;
277
ss << e.file << ":" << e.line << ":" << e.msg;
279
const char caption[] = "Zaz exception";
281
int l1 = MultiByteToWideChar(CP_UTF8, 0, ss.str().c_str(), -1, 0, 0);
284
int l2 = MultiByteToWideChar(CP_UTF8, 0, caption, -1, 0, 0);
287
MultiByteToWideChar(CP_UTF8, 0, ss.str().c_str(), -1, wmsg, l1);
288
MultiByteToWideChar(CP_UTF8, 0, caption, -1, wcap, l2);
290
MessageBoxW(0, wmsg, wcap, MB_OK | MB_ICONERROR);
292
cout << ss.str() << endl;
300
delete Scenes::mixer;