00001 /* 00002 * $Id: Resource.cpp,v 1.10 2002/08/06 06:10:26 virtualcasino Exp $ 00003 */ 00004 #include<Resource.h> 00005 #include<SDL.h> 00006 #include<SDL_image.h> 00007 00008 00009 00010 char *fnames[] ={ 00011 "../images/backgrounds/back.png", 00012 "../images/gui/buttons/button-up.png", 00013 "../images/gui/buttons/button-lit.png", 00014 "../images/gui/buttons/button-down.png", 00015 "../images/gui/buttons/button-up-left.png", 00016 "../images/gui/buttons/button-up-right.png", 00017 "../images/gui/buttons/button-up-middle.png", 00018 "../images/gui/buttons/button-lit-left.png", 00019 "../images/gui/buttons/button-lit-right.png", 00020 "../images/gui/buttons/button-lit-middle.png", 00021 "../images/gui/buttons/button-down-left.png", 00022 "../images/gui/buttons/button-down-right.png", 00023 "../images/gui/buttons/button-down-middle.png", 00024 "../images/gui/window/template-top-left.png", 00025 "../images/gui/window/template-top-right.png", 00026 "../images/gui/window/template-top-caption.png", 00027 "../images/gui/window/template-bottom-left.png", 00028 "../images/gui/window/template-bottom-right.png", 00029 "../images/gui/window/template-bottom-middle.png", 00030 "../images/gui/window/template-middle-left-middle.png", 00031 "../images/gui/window/template-middle-left-top.png", 00032 "../images/gui/window/template-middle-left-bottom.png", 00033 "../images/gui/window/template-middle-right-middle.png", 00034 "../images/gui/window/template-middle-right-top.png", 00035 "../images/gui/window/template-middle-right-bottom.png", 00036 "../images/backgrounds/splash.png", 00037 }; 00038 00039 char *fontfiles[] = { 00040 "../fonts/BlackWolf.ttf", 00041 "../fonts/BlackWolf.ttf", 00042 "../fonts/BlackWolf.ttf", 00043 "../fonts/BlackWolf.ttf", 00044 "../fonts/BlackWolf.ttf", 00045 "../fonts/BOOMBOX.ttf", 00046 "../fonts/ALIEE___.ttf", 00047 "../fonts/ALIEE___.ttf", 00048 "../fonts/ALIEEB__.ttf", 00049 "../fonts/ALIEEI__.ttf", 00050 "../fonts/ALIEEBI_.ttf", 00051 //"../fonts/.ttf", 00052 }; 00053 00054 extern SDL_Surface *Screen; 00055 Font *SystemFont; 00056 SDL_Surface *bRes[NUM_RESOURCES]; 00057 00058 00059 bool loadResources(){ 00060 int i; 00061 float p; 00062 char buf[128]; 00063 SDL_Surface *surf; 00064 SDL_Rect src, dest; 00065 //Load true type fonts 00066 //using namespace clawsoft; 00067 SystemFont = new clawsoft::Font[NUM_FONTS]; 00068 src.x = 0; 00069 src.y = 0; 00070 for(i = 0; i < NUM_FONTS; i++){ 00071 if(i == MINI_FONT){ 00072 SystemFont[i].load(fontfiles[i], 12); 00073 } 00074 else{ 00075 SystemFont[i].load(fontfiles[i], 18); 00076 } 00077 SystemFont[i].setStyle(TTF_STYLE_NORMAL); 00078 SystemFont[i].setColor(173, 255, 0); 00079 p = 50.0 * (i + 1.0) / (float)NUM_FONTS; 00080 sprintf(buf, "Cargando %3.0f%%", p); 00081 if(i > 0){ 00082 SDL_FillRect(Screen, &dest, 0); 00083 SDL_UpdateRect(Screen, dest.x, dest.y, dest.w, dest.h); 00084 } 00085 surf = SystemFont[PROGRESS_FONT].render(buf); 00086 src.w = surf->w; 00087 src.h = surf->h; 00088 00089 dest.x = (Screen->w - src.w) / 2; 00090 dest.y = (Screen->h - src.h) / 2; 00091 00092 dest.w = src.w; 00093 dest.h = src.h; 00094 SDL_BlitSurface(surf, &src, Screen, &dest); 00095 SDL_UpdateRect(Screen, dest.x, dest.y, dest.w, dest.h); 00096 SDL_FreeSurface(surf); 00097 SDL_Delay(10); 00098 } 00099 //Load Images 00100 for(i = 0; i < NUM_RESOURCES; i++){ 00101 bRes[i] = IMG_Load(fnames[i]); 00102 SDL_FillRect(Screen, &dest, 0); 00103 SDL_UpdateRect(Screen, dest.x, dest.y, dest.w, dest.h); 00104 p = 50.0 + 50.0 * (i + 1.0) / (float)NUM_RESOURCES; 00105 if(bRes[i] == 0){ 00106 fprintf(stderr, "Unable to load: %s\n", fnames[i]); 00107 sprintf(buf, "Unable to load %s", fnames[i]); 00108 } 00109 else{ 00110 printf("%d/%d\t%s loaded\n", i + 1, NUM_RESOURCES, fnames[i]); 00111 sprintf(buf, "Cargando %3.0f%%", p); 00112 } 00113 surf = SystemFont[PROGRESS_FONT].render(buf); 00114 src.w = surf->w; 00115 src.h = surf->h; 00116 00117 dest.x = (Screen->w - src.w) / 2; 00118 dest.y = (Screen->h - src.h) / 2; 00119 00120 dest.w = src.w; 00121 dest.h = src.h; 00122 SDL_BlitSurface(surf, &src, Screen, &dest); 00123 SDL_UpdateRect(Screen, dest.x, dest.y, dest.w, dest.h); 00124 SDL_FreeSurface(surf); 00125 if(bRes[i] == 0) 00126 SDL_Delay(500); 00127 SDL_Delay(10); 00128 } 00129 return true; 00130 }
Powered by: