00001
00002
00003
00004 #include <All.h>
00005 #include <OVGA.H>
00006 #include <OSYS.H>
00007 #include <OSTR.h>
00008 #include <OMISC.h>
00009 #include <OGAMESET.H>
00010 #include <OPLANT.h>
00011
00012
00013
00014 #define PLANT_DB "PLANT"
00015
00016
00018
00019 init_flag=0;
00020 }
00021
00022
00023
00024
00026
00027 PlantRes::~PlantRes() {
00028 deinit();
00029 }
00030
00031
00032
00033
00035
00036 if ( init_flag )
00037 return;
00038
00039
00040
00041 load_info();
00042
00043
00044
00045 load_res( ZOOM_SMALL , "PLANT", "S" );
00046 load_res( ZOOM_MEDIUM, "PLANT", "M" );
00047 load_res( ZOOM_LARGE , "PLANT", "L" );
00048
00049
00050
00051 init_flag=1;
00052 }
00053
00054
00055
00056
00058
00059 if( init_flag ) {
00060 for( int i=0 ; i<MAX_ZOOM_LEVEL ; i++ )
00061 res_bitmap[i].deinit();
00062
00063 mem_del(info_array);
00064
00065 init_flag=0;
00066 }
00067 }
00068
00069
00070
00071
00075
00076 PlantRec *plantRec;
00077 PlantInfo *plantInfo;
00078 int i;
00079 Database *dbPlant = game_set.open_db(PLANT_DB);
00080
00081 plant_count = (short) dbPlant->rec_count();
00082 info_array = (PlantInfo*) mem_add( sizeof(PlantInfo)*plant_count );
00083
00084
00085
00086 memset( info_array, 0, sizeof(PlantInfo) * plant_count );
00087
00088 for( i=0 ; i<plant_count ; i++ ) {
00089 plantRec = (PlantRec*) dbPlant->read(i+1);
00090 plantInfo = info_array+i;
00091
00092 m.rtrim_fld( plantInfo->file_name, plantRec->file_name, plantRec->FILE_NAME_LEN );
00093 }
00094 }
00095
00096
00097
00098
00100
00101
00102
00103 String str2;
00104
00105 str2 = DIR_RES;
00106 str2 += namePrefix;
00107 str2 += "_";
00108 str2 += nameSuffix;
00109
00110 str2 += ".RES";
00111
00112 res_bitmap[zoomLevel].init( str2, 1 );
00113
00114
00115
00116 char* bmpPtr;
00117
00118 for( int i=0 ; i<plant_count ; i++ ) {
00119 bmpPtr = res_bitmap[zoomLevel].read( info_array[i].file_name );
00120
00121 info_array[i].bitmap_ptr[zoomLevel] = bmpPtr;
00122 }
00123 }
00124
00125
00126
00127
00128
00129 PlantInfo* PlantRes::operator[](int plantId) {
00130 err_if( plantId<1 || plantId>plant_count )
00131 err_now( "PlantRes::operator[]" );
00132
00133 return info_array+plantId-1;
00134 }
00135
00136