diff --git a/dat/mission.xml b/dat/mission.xml index ad1ce1f..1ab9418 100644 --- a/dat/mission.xml +++ b/dat/mission.xml @@ -15,7 +15,7 @@ Computer Independent Empire -Unkown6 +Unknown6 @@ -36,7 +36,7 @@ 350 Computer Empire -Unkown6 +Unknown6 diff --git a/gfx/loading000.png b/gfx/loading000.png new file mode 100644 index 0000000..e6de87c Binary files /dev/null and b/gfx/loading000.png differ diff --git a/src/font.c b/src/font.c index f5e5b27..0835b37 100644 --- a/src/font.c +++ b/src/font.c @@ -295,7 +295,7 @@ int gl_printHeight(const glFont* ft_font, const int width, char txt[1024]; /* Holds the string. */ va_list ap; int p, i, n, len, lastspace; - double x, y; + double y; if(ft_font == NULL) ft_font = &gl_defFont; @@ -306,7 +306,6 @@ int gl_printHeight(const glFont* ft_font, const int width, vsprintf(txt, fmt, ap); va_end(ap); } - x = 0.; y = 0.; len = (int) strlen(txt); diff --git a/src/lephisto.c b/src/lephisto.c index 88e480c..ad5ad73 100644 --- a/src/lephisto.c +++ b/src/lephisto.c @@ -44,6 +44,8 @@ #define FONT_SIZE 12 #define FONT_SIZE_SMALL 10 +#define LEPHISTO_INIT_DELAY 3000 /* Minimum amount of time to wait with loading screen. */ + static int quit = 0; /* Primary loop. */ unsigned int gtime = 0; /* Calculate FPS and movement. */ static char version[VERSION_LEN]; @@ -58,6 +60,7 @@ int indjoystick = -1; char* namjoystick = NULL; /* Prototypes. */ +static void load_screen(void); static void load_all(void); static void unload_all(void); void main_loop(void); @@ -122,6 +125,8 @@ int main(int argc, char** argv) { exit(EXIT_FAILURE); } window_caption(); + load_screen(); + gtime = SDL_GetTicks(); /* OpenAL sound. */ if(nosound) @@ -165,8 +170,12 @@ int main(int argc, char** argv) { /* Data loading. */ load_all(); + /* Start menu. */ menu_main(); + /* Force a minimum delay with loading screen. */ + if((SDL_GetTicks() - gtime) < LEPHISTO_INIT_DELAY) + SDL_Delay(LEPHISTO_INIT_DELAY - (SDL_GetTicks() - gtime)); gtime = SDL_GetTicks(); /* Init the time. */ /* Main loop. */ @@ -214,7 +223,49 @@ int main(int argc, char** argv) { } /** - * Load all the data, makes main() simpler. + * @brief Display a loading screen. + */ +void load_screen(void) { + int i; + glTexture* tex; + char file_path[PATH_MAX]; + char** files; + uint32_t nfiles; + size_t len; + int nload; + + /* Count the loading screens. */ + files = pack_listfiles(data, &nfiles); + len = strlen("../gfx/loading"); + nload = 0; + for(i = 0; i < (int)nfiles; i++) + if(strncmp(files[i], "../gfx/loading", len)==0) { + nload++; + free(files[i]); + } + free(files); + + /* Must have loading screens. */ + if(nload == 0) { + WARN("No loading screens found!"); + return; + } + + /* Load the texture. */ + snprintf(file_path, PATH_MAX, "../gfx/loading%03d.png", RNG(0, nload-1)); + tex = gl_newImage(file_path); + + /* Draw once, won't be redrawn. */ + glClear(GL_COLOR_BUFFER_BIT); + gl_blitScale(tex, 0., 0., SCREEN_W, SCREEN_H, NULL); + SDL_GL_SwapBuffers(); + + /* Free the textures. */ + gl_freeTexture(tex); +} + +/** + * @brief Load all the data, makes main() simpler. */ void load_all(void) { /* Ordering of these is very important as they are interdependent. */ diff --git a/src/opengl.c b/src/opengl.c index a035af1..70ea6c7 100644 --- a/src/opengl.c +++ b/src/opengl.c @@ -636,8 +636,11 @@ void gl_blitScale(const glTexture* texture, glVertex2d(x, y); glTexCoord2d(tx+tw, ty); - glVertex2d(x+bw, y+bh); + glVertex2d(x+bw, y); + glTexCoord2d(tx+tw, ty+th); + glVertex2d(x+bw, y+bh); + glTexCoord2d(tx, ty+th); glVertex2d(x, y+bh); glEnd();