Virtual U.org
Get Personal Training on VU Today
    
Top shadow
 
 register/help
User Name:

Password:

OGAMHALL.CPP Source File
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

OGAMHALL.CPP

Go to the documentation of this file.
00001 //Filename    : OGAMHALL.CPP
00002 //Description : Hall of Fame
00003 
00004 #include <OVGA.H>
00005 #include <OVGALOCK.H>
00006 #include <ODATE.H>
00007 #include <OSTR.H>
00008 #include <OSYS.H>
00009 #include <OFONT.H>
00010 #include <OMOUSE.H>
00011 #include <OIMGRES.H>
00012 #include <OGAME.H>
00013 #include <OGFILE.H>
00014 
00015 //------ Begin of function GameFileArray::disp_hall_of_fame -----//
00018 /*
00019   void GameFileArray::disp_hall_of_fame()
00020   {
00021   vga.disp_image_file("HALLFAME");
00022 
00023   //---------- display hall of fame records ------------//
00024 
00025   int i;
00026   int x=120, y=116;
00027 
00028   for( i=0 ; i<HALL_FAME_NUM ; i++, y+=76 )
00029   {
00030   hall_fame_array[i].disp_info( x, y, i+1 );
00031   }
00032 
00033   mouse.wait_press(60);         // 60 seconds to time out
00034 
00035   vga.finish_disp_image_file();
00036   }
00037 */
00038 //------- End of function GameFileArray::disp_hall_of_fame -----//
00039 
00040 //------ Begin of function HallFame::disp_info -------//
00047 void HallFame::disp_info(int x, int y, int pos) {
00048     if( !start_year )                               // no information
00049         return;
00050 
00051     //------------------------------------------------------//
00052     //
00053     // e.g. 1. [Image] King T Chan
00054     //            [     ] Score : 150    Population : 1000    Period : 1001-1030
00055     //
00056     //------------------------------------------------------//
00057 
00058     Font* fontPtr;
00059 
00060 #if( defined(GERMAN) || defined(FRENCH) || defined(SPANISH) )
00061     fontPtr = &font_hall;
00062 #else
00063     fontPtr = &font_std;
00064 #endif
00065 
00066     String str;
00067     int    y2 = y+17;
00068 
00069     //----------------------------------------//
00070 
00071     str  = pos;
00072     str += ".";
00073 
00074     fontPtr->put( x, y, str );
00075 
00076     x += 16;
00077 
00078     //----------------------------------------//
00079 
00080     str  = translate.process("King ");
00081     str += player_first_name;
00082     str += player_last_name;
00083 
00084     fontPtr->put( x, y, str );
00085 
00086     //----------------------------------------//
00087 
00088     str  = translate.process("Score : ");
00089     str += score;
00090 
00091     fontPtr->put( x, y2, str );
00092 
00093     //----------------------------------------//
00094 
00095     //str  = translate.process("Population : ");
00096     //str += population;
00097 
00098     //fontPtr->put( x+110, y2, str );
00099 
00100     //----------------------------------------//
00101 
00102 #if( defined(GERMAN) || defined(FRENCH) || defined(SPANISH) )
00103     x-=10;                                          // position adjustment for the German version
00104 #endif
00105 
00106     str  = translate.process("Period : ");
00107     str += m.num_to_str(start_year);                // without adding comma separators
00108     str += "-";
00109     str += m.num_to_str(end_year);
00110 
00111     fontPtr->put( x+260, y2, str );
00112 
00113     //----------------------------------------//
00114 
00115     //str  = translate.process("Difficulty : ");
00116     //str += difficulty_rating;
00117 
00118     fontPtr->put( x+420, y2, str );
00119 }
00120 
00121 //------- End of function HallFame::disp_info -------//
00122 
00123 //--------- Begin of function HallFame::record_data --------//
00127 void HallFame::record_data(int totalScore) {
00128 
00129     strncpy( school_name, player_school.school_name, PlayerSchool::SCHOOL_NAME_LEN);
00130     school_name[PlayerSchool::SCHOOL_NAME_LEN] = NULL;
00131 
00132     strncpy( player_first_name, player_school.player_first_name, PlayerSchool::FIRST_NAME_LEN );
00133     player_first_name[PlayerSchool::FIRST_NAME_LEN] = NULL;
00134 
00135     strncpy( player_last_name, player_school.player_last_name, PlayerSchool::LAST_NAME_LEN );
00136     player_last_name[PlayerSchool::LAST_NAME_LEN] = NULL;
00137 
00138     start_year = date.year(info.game_start_date);
00139     end_year   = info.game_year;
00140 
00141     score     = totalScore;                         // ultimate_game_score
00142     trust_score = (int) player_school.cur_game_score;
00143 
00144     scenario_id = player_school.scenario_id;
00145 }
00146 
00147 //----------- End of function HallFame::record_data ---------//
00148 
00149 //------ Begin of function GameFileArray::add_hall_of_fame -----//
00160 int GameFileArray::add_hall_of_fame(int totalScore) {
00161     //-------- insert the record -----------//
00162 
00163     if (totalScore <=0)
00164         return 0;
00165 
00166     //0301
00167     if( !has_read_hall_of_fame ) {                  // only read once, GameFileArray::init() is called every time the load/save game menu is brought up.
00168         read_hall_of_fame();
00169         has_read_hall_of_fame = 1;
00170     }
00171 
00172     int i;
00173 
00174     for( i=0 ; i<HALL_FAME_NUM ; i++ ) {
00175         if( totalScore > hall_fame_array[i].score ) {
00176             //---------- move and insert the data --------//
00177 
00178             if( i < HALL_FAME_NUM-1 ) {                 // it is not the last record
00179                 memmove( hall_fame_array+i+1, hall_fame_array+i,
00180                          sizeof(HallFame) * (HALL_FAME_NUM-i-1) );
00181             }
00182 
00183             //-------- record the hall of fame rcord ------//
00184 
00185             hall_fame_array[i].record_data(totalScore);
00186 
00187             //--------- display the hall of fame ----------//
00188 
00189             write_hall_of_fame();                       // must write hall of fame, because it also write the last saved game slot no.
00190 
00191             err_when(hall_fame_array[i].scenario_id  != player_school.scenario_id );
00192             game.hall_of_fame();
00193             return 1;
00194         }
00195     }
00196 
00197     return 0;
00198 }
00199 
00200 //------- End of function GameFileArray::add_hall_of_fame -----//

Generated on Fri Aug 23 01:37:43 2002 for VirtualU by doxygen1.2.17