X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=putt%2Fmain.c;h=217fe7bf04c347ff39f40e31bc815c7a75b7fd78;hb=a4674d61b952522a752dea8362d16e8a46d02d85;hp=b458b6b52f0916a818091e893e3a34727d08a092;hpb=0f17528baaf530edc2b7b5d0f5f616d0c39f8dc7;p=neverball diff --git a/putt/main.c b/putt/main.c index b458b6b..217fe7b 100644 --- a/putt/main.c +++ b/putt/main.c @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 2003 Robert Kooima * * NEVERPUTT is free software; you can redistribute it and/or modify @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -47,7 +48,7 @@ #include "st_conf.h" #include "st_all.h" -#define TITLE _("Neverputt") +#define TITLE "Neverputt" /*---------------------------------------------------------------------------*/ @@ -56,7 +57,7 @@ static int shot(void) static char filename[MAXSTR]; static int num = 0; - sprintf(filename, "screen%02d.bmp", num++); + sprintf(filename, "screen%02d.png", num++); image_snap(filename); @@ -96,52 +97,44 @@ static int loop(void) if (e.type == SDL_QUIT) return 0; - if (e.type == SDL_KEYDOWN && e.key.keysym.sym == SDLK_SPACE) - config_tgl_pause(); - - if (!config_get_pause()) - switch (e.type) + switch (e.type) + { + case SDL_MOUSEMOTION: + st_point(+e.motion.x, + -e.motion.y + config_get_d(CONFIG_HEIGHT), + +e.motion.xrel, + -e.motion.yrel); + break; + + case SDL_MOUSEBUTTONDOWN: + d = st_click((e.button.button == SDL_BUTTON_LEFT) ? -1 : 1, 1); + break; + + case SDL_MOUSEBUTTONUP: + d = st_click((e.button.button == SDL_BUTTON_LEFT) ? -1 : 1, 0); + break; + + case SDL_KEYDOWN: + switch (e.key.keysym.sym) { - case SDL_MOUSEMOTION: - st_point(+e.motion.x, -#ifdef __APPLE__ - +e.motion.y, -#else - -e.motion.y + config_get_d(CONFIG_HEIGHT), -#endif - +e.motion.xrel, - -e.motion.yrel); - break; - - case SDL_MOUSEBUTTONDOWN: - d = st_click((e.button.button == SDL_BUTTON_LEFT) ? -1 : 1, 1); - break; - - case SDL_MOUSEBUTTONUP: - d = st_click((e.button.button == SDL_BUTTON_LEFT) ? -1 : 1, 0); - break; + case SDLK_F10: d = shot(); break; + case SDLK_F9: config_tgl_d(CONFIG_FPS); break; + case SDLK_F8: config_tgl_d(CONFIG_NICE); break; + case SDLK_F7: toggle_wire(); break; - case SDL_KEYDOWN: - switch (e.key.keysym.sym) - { - case SDLK_F10: d = shot(); break; - case SDLK_F9: config_tgl_d(CONFIG_FPS); break; - case SDLK_F8: config_tgl_d(CONFIG_NICE); break; - case SDLK_F7: toggle_wire(); break; - - default: - d = st_keybd(e.key.keysym.sym, 1); - } - break; + default: + d = st_keybd(e.key.keysym.sym, 1); + } + break; - case SDL_ACTIVEEVENT: - if (e.active.state == SDL_APPINPUTFOCUS) - { - if (e.active.gain == 0) - config_set_pause(); - } - break; + case SDL_ACTIVEEVENT: + if (e.active.state == SDL_APPINPUTFOCUS) + { + if (e.active.gain == 0) + goto_pause(&st_over, 0); } + break; + } } return d; } @@ -149,7 +142,8 @@ static int loop(void) int main(int argc, char *argv[]) { int camera = 0; - + SDL_Surface *icon; + srand((int) time(NULL)); language_init("neverball", CONFIG_LOCALE); @@ -163,10 +157,6 @@ int main(int argc, char *argv[]) config_init(); config_load(); - /* Initialize the language. */ - - language_set(language_from_code(config_simple_get_s(CONFIG_LANG))); - /* Cache Neverball's camera setting. */ camera = config_get_d(CONFIG_CAMERA); @@ -200,6 +190,14 @@ int main(int argc, char *argv[]) SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); + icon = IMG_Load(config_data("icon/neverputt.png")); + + if (icon) + { + SDL_WM_SetIcon(icon, NULL); + SDL_FreeSurface(icon); + } + /* Initialize the video. */ if (config_mode(config_get_d(CONFIG_FULLSCREEN), @@ -208,7 +206,7 @@ int main(int argc, char *argv[]) { int t1, t0 = SDL_GetTicks(); - SDL_WM_SetCaption(TITLE, TITLE); + SDL_WM_SetCaption(TITLE, TITLE); /* Run the main game loop. */ @@ -218,16 +216,8 @@ int main(int argc, char *argv[]) while (loop()) if ((t1 = SDL_GetTicks()) > t0) { - if (config_get_pause()) - { - st_paint(); - gui_blank(); - } - else - { - st_timer((t1 - t0) / 1000.f); - st_paint(); - } + st_timer((t1 - t0) / 1000.f); + st_paint(); SDL_GL_SwapBuffers(); t0 = t1;