Public Types | |
enum | Slot { SLOT_CUSTOM = 0, SLOT_BODY = 1, SLOT_WHEEL = 2, SLOT_MAX = 3 } |
Public Member Functions | |
gCycleVisuals (gRealColor const &a_color) | |
~gCycleVisuals () | |
gTextureCycle * | LoadTextureSafe (Slot slot, bool wheel) |
bool | LoadTextures () |
bool | LoadModel (bool a_mpType, bool mpFolder) |
bool | LoadModel2 (bool mp) |
bool | LoadModel (bool mp) |
Static Public Member Functions | |
static rSurface * | LoadTextureSafe2 (Slot slot, int mp) |
static rModel * | LoadModelSafe (char const *filename) |
Public Attributes | |
rModel * | customModel |
rModel * | bodyModel |
rModel * | frontModel |
rModel * | rearModel |
gTextureCycle * | customTexture |
gTextureCycle * | bodyTexture |
gTextureCycle * | wheelTexture |
gRealColor | color |
bool | mpType |
int | mpPreference |
Definition at line 1926 of file gCycle.cpp.
enum gCycleVisuals::Slot |
Definition at line 1956 of file gCycle.cpp.
01956 { SLOT_CUSTOM=0, SLOT_BODY=1, SLOT_WHEEL=2, SLOT_MAX=3 };
gCycleVisuals::gCycleVisuals | ( | gRealColor const & | a_color | ) | [inline] |
Definition at line 1934 of file gCycle.cpp.
References gCycle::customModel, and gCycle::customTexture.
01935 { 01936 customModel = bodyModel = frontModel = rearModel = 0; 01937 customTexture = bodyTexture = wheelTexture = 0; 01938 01939 color = a_color; 01940 01941 mpType = false; 01942 mpPreference = 0; 01943 }
gCycleVisuals::~gCycleVisuals | ( | ) | [inline] |
Definition at line 1945 of file gCycle.cpp.
References gCycle::customModel, and gCycle::customTexture.
01946 { 01947 delete customModel; 01948 delete bodyModel; 01949 delete frontModel; 01950 delete rearModel; 01951 delete customTexture; 01952 delete bodyTexture; 01953 delete wheelTexture; 01954 }
Definition at line 1959 of file gCycle.cpp.
01960 { 01961 static std::auto_ptr<rSurface> cache[SLOT_MAX][2]; 01962 std::auto_ptr<rSurface> & surface = cache[slot][mp]; 01963 if ( surface.get() == NULL ) 01964 { 01965 static char const * names[SLOT_MAX]={"bike.png","cycle_body.png", "cycle_wheel.png"}; 01966 char const * name = names[slot]; 01967 01968 char const * folder = mp ? "moviepack" : "textures"; 01969 tString file = tString(folder) + tString("/") + tString( name ); 01970 01971 surface = std::auto_ptr<rSurface> ( tNEW( rSurface( file ) ) ); 01972 } 01973 01974 if ( surface->GetSurface() ) 01975 return surface.get(); 01976 else 01977 return NULL; 01978 }
gTextureCycle* gCycleVisuals::LoadTextureSafe | ( | Slot | slot, | |
bool | wheel | |||
) | [inline] |
Definition at line 1981 of file gCycle.cpp.
01982 { 01983 rSurface * surface = LoadTextureSafe2( slot, mpPreference ); 01984 if ( !surface ) 01985 surface = LoadTextureSafe2( slot, 1-mpPreference ); 01986 01987 if ( surface ) 01988 return tNEW( gTextureCycle )( *surface, color, 0, 0, wheel ); 01989 01990 return NULL; 01991 }
bool gCycleVisuals::LoadTextures | ( | ) | [inline] |
Definition at line 1994 of file gCycle.cpp.
References gCycle::customTexture.
01995 { 01996 if ( mpType ) 01997 { 01998 if ( !customTexture ) 01999 customTexture = LoadTextureSafe( SLOT_CUSTOM, false ); 02000 02001 return customTexture; 02002 } 02003 else 02004 { 02005 if ( !bodyTexture ) 02006 bodyTexture = LoadTextureSafe( SLOT_BODY, false ); 02007 if ( !wheelTexture ) 02008 wheelTexture = LoadTextureSafe( SLOT_WHEEL, true ); 02009 02010 return bodyTexture && wheelTexture; 02011 } 02012 }
static rModel* gCycleVisuals::LoadModelSafe | ( | char const * | filename | ) | [inline, static] |
Definition at line 2015 of file gCycle.cpp.
References tDirectories::Data(), in, and tNEW.
02016 { 02017 std::ifstream in; 02018 if ( tDirectories::Data().Open( in, filename ) ) 02019 { 02020 return tNEW(rModel( filename )); 02021 } 02022 return 0; 02023 }
bool gCycleVisuals::LoadModel | ( | bool | a_mpType, | |
bool | mpFolder | |||
) | [inline] |
Definition at line 2026 of file gCycle.cpp.
References gCycle::customModel.
Referenced by gCycle::MyInitAfterCreation().
02027 { 02028 mpType = a_mpType; 02029 char const * folder = mpFolder ? "moviepack" : "models"; 02030 02031 if ( mpType ) 02032 { 02033 tString base = tString(folder); 02034 base << "/cycle"; 02035 if (!customModel) customModel = LoadModelSafe( base + ".ASE" ); 02036 if (!customModel) customModel = LoadModelSafe( base + ".ase" ); 02037 02038 return customModel && LoadTextures(); 02039 } 02040 else 02041 { 02042 tString base = tString(folder) + "/cycle_"; 02043 02044 if (!bodyModel) bodyModel = LoadModelSafe( base + "body.mod" ); 02045 if (!frontModel) frontModel = LoadModelSafe( base + "front.mod" ); 02046 if (!rearModel) rearModel = LoadModelSafe( base + "rear.mod" ); 02047 02048 return bodyModel && frontModel && rearModel && LoadTextures(); 02049 } 02050 }
bool gCycleVisuals::LoadModel2 | ( | bool | mp | ) | [inline] |
bool gCycleVisuals::LoadModel | ( | bool | mp | ) | [inline] |
Definition at line 2060 of file gCycle.cpp.
02061 { 02062 mpPreference = mp ? 1 : 0; 02063 02064 // delegate to try loading both formats from both directories 02065 return LoadModel2( mp ) || LoadModel2( !mp ); 02066 }
Definition at line 1930 of file gCycle.cpp.
Definition at line 1932 of file gCycle.cpp.