[Add] Loading screens!!! :D
This commit is contained in:
		
							parent
							
								
									c7e2a69d91
								
							
						
					
					
						commit
						d0b55f1d1b
					
				| @ -15,7 +15,7 @@ | ||||
| <location>Computer</location> | ||||
| <faction>Independent</faction> | ||||
| <faction>Empire</faction> | ||||
| <faction>Unkown6</faction> | ||||
| <faction>Unknown6</faction> | ||||
| </avail> | ||||
| </mission> | ||||
| <mission name="Empire Recruitment"> | ||||
| @ -36,7 +36,7 @@ | ||||
| <chance>350</chance> | ||||
| <location>Computer</location> | ||||
| <faction>Empire</faction> | ||||
| <faction>Unkown6</faction> | ||||
| <faction>Unknown6</faction> | ||||
| </avail> | ||||
| </mission> | ||||
| <mission name="Empire Scouting"> | ||||
|  | ||||
							
								
								
									
										
											BIN
										
									
								
								gfx/loading000.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								gfx/loading000.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 423 KiB | 
| @ -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); | ||||
|  | ||||
| @ -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. */ | ||||
|  | ||||
| @ -636,6 +636,9 @@ void gl_blitScale(const glTexture* texture, | ||||
|     glVertex2d(x, y); | ||||
| 
 | ||||
|     glTexCoord2d(tx+tw, ty); | ||||
|     glVertex2d(x+bw, y); | ||||
|      | ||||
|     glTexCoord2d(tx+tw, ty+th); | ||||
|     glVertex2d(x+bw, y+bh); | ||||
| 
 | ||||
|     glTexCoord2d(tx, ty+th); | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Allanis
						Allanis