//------------ Begin of function Tutor::get_intro -------------// // // <int> tutorId - id. of the tutorial // // return: <char*> return the introduction text of the tutorial. // char* Tutor::get_intro(int tutorId) { //------- get the tutor msgs from the resource file -------// int dataSize; File* filePtr = res_tutor_intro.get_file( tutor[tutorId]->code, dataSize); if( !filePtr ) // if error getting the tutor resource { err_here(); return NULL; } //------ Open the file and allocate buffer -----// FileTxt fileTxt( filePtr, dataSize ); // initialize fileTxt with an existing file stream if( dataSize > tutor_intro_buf_size ) { tutor_intro_buf = mem_resize( tutor_intro_buf, dataSize ); // allocate a buffer larger than we need for the largest size possible tutor_intro_buf_size = dataSize; } // #### begin Gilbert 23/9 #######// fileTxt.read_paragraph(tutor_intro_buf, tutor_intro_buf_size); // #### end Gilbert 23/9 #######// return tutor_intro_buf; }
void ImportBillItemMeasuresTXT::importMeasures() { if( !m_d->fileName.isEmpty() ){ QFile fileTxt( m_d->fileName ); if(fileTxt.open(QIODevice::ReadOnly | QIODevice::Text)){ QTextStream in( &fileTxt ); int insPosEff = m_d->insertPosition; while( !in.atEnd() ){ m_d->measuresModel->insertRows( insPosEff, 1 ); QString fieldSep = m_d->fieldsSeparator.at( m_d->ui->fieldsSeparatorComboBox->currentIndex()).first; QStringList line = in.readLine().split( fieldSep ); for( int i=0; i < m_d->fieldComboBoxList.size(); ++i ){ if( i >= line.size() ){ break; } // commento if( m_d->fieldComboBoxList.at(i)->currentIndex() == 1 ){ m_d->measuresModel->measure(insPosEff)->setComment( line.at(i)); } // misura if( m_d->fieldComboBoxList.at(i)->currentIndex() == 2 ){ QString form = line.at(i); form.remove( m_d->ui->thousandSeparatorLineEdit->text() ); form.replace( m_d->ui->decimalSeparatorLineEdit->text(), m_d->parser->decimalSeparator() ); m_d->measuresModel->measure(insPosEff)->setFormula( form ); } } insPosEff++; } } } accept(); }
//----- Begin of function GoalConfig::read_goal_task --------// //! //! GOALTASK.RES format: //! //! 1: TASK_RISE_PERFORMANCE_RATING //! ------------------------------- //! Years Lower: 4 //! Years Upper: 6 //! Goal Lower: 30 //! Goal Upper: 40 //! Bonus : 100 //! void GoalConfig::read_goal_task() { FileTxt fileTxt( DIR_RES"GOALTASK.RES" ); while( !fileTxt.is_eof() ) { int taskId = (int) fileTxt.get_num(); if( taskId < 1 || taskId > SCENARIO_COUNT ) continue; //-------------------------------------// fileTxt.next_line(); fileTxt.next_line(); GoalTask* goalTask = goal_task_array+taskId-1; //--- read task time limits ------// fileTxt.get_token(); // bypass "Year" fileTxt.get_token(); // bypass "Lower" goalTask->years_lower = (short) fileTxt.get_num(); fileTxt.next_line(); fileTxt.get_token(); // bypass "Year" fileTxt.get_token(); // bypass "Upper" goalTask->years_upper = (short) fileTxt.get_num(); fileTxt.next_line(); //--- read task values ------// fileTxt.get_token(); // bypass "Value" fileTxt.get_token(); // bypass "Lower" goalTask->value_lower = (short) fileTxt.get_num(); fileTxt.next_line(); fileTxt.get_token(); // bypass "Value" fileTxt.get_token(); // bypass "Upper" goalTask->value_upper = (short) fileTxt.get_num(); fileTxt.next_line(); //-------- read bonus ---------// fileTxt.get_token(); // bypass "Bonus" goalTask->bonus = (short) fileTxt.get_num(); fileTxt.next_line(); //------- if all scenario settings have been read -----// if( taskId == TASK_COUNT ) break; } }
void ImportBillItemMeasuresTXT::editFileName() { QString fileName = QFileDialog::getOpenFileName( this, trUtf8("Apri file TXT"), ".", trUtf8("Documento di testo (*.txt)")); if( !(fileName.isEmpty()) ){ QFile fileTxt( fileName ); if(fileTxt.open(QIODevice::ReadOnly | QIODevice::Text)){ m_d->fileName = fileName; m_d->ui->fileNameLineEdit->setText( m_d->fileName ); QTextStream in( &fileTxt ); m_d->ui->filePreviewTextEdit->clear(); while( !in.atEnd() ){ m_d->ui->filePreviewTextEdit->appendPlainText( in.readLine() ); } m_d->ui->filePreviewTextEdit->moveCursor( QTextCursor::Start ); } } }
//----- Begin of function GoalConfig::read_goal_scen --------// //! //! GOALSCEN.RES format: //! //! 1: Balance The Budget //! --------------------- //! Gold Years: 9 //! Silver Years: 6 //! Bronze Years: 3 //! Gold value: 0, 30, 50 //! Silver value: 9000, 50, 100 //! Bronze value: 1000, 20, 300 //! void GoalConfig::read_goal_scen() { FileTxt fileTxt( DIR_RES"GOALSCEN.RES" ); while( !fileTxt.is_eof() ) { int scenId = (int) fileTxt.get_num(); if( scenId < 1 || scenId > SCENARIO_COUNT ) continue; //-------------------------------------// fileTxt.next_line(); fileTxt.next_line(); GoalScen* goalScen = goal_scen_array+scenId-1; //--- read scenario objective time limits ------// for( int i=0 ; i<3 ; i++ ) { fileTxt.get_token(); // bypass "Gold" fileTxt.get_token(); // bypass "Years:" goalScen->goal_year[i] = (short) fileTxt.get_num(); fileTxt.next_line(); } //--- read scenario objective variables ------// for( int i=0 ; i<3 ; i++ ) { fileTxt.get_token(); // bypass "Gold" fileTxt.get_token(); // bypass "Value:" goalScen->goal_value[i] = (float) fileTxt.get_num(); fileTxt.next_line(); } //------- if all scenario settings have been read -----// if( scenId == SCENARIO_COUNT ) break; } }
//---------- Begin of function Game::select_scenario ----------// // // Select a scenario. // // <int> scenCount - no. of available scenarios. // <char**> scenFileNameArray - an array of <char*> pointing to the file name of the // available scenarios. // // return : <int> >0 - id. of the scenario selected. // 0 - cancel // int Game::select_scenario(int scenCount, ScenInfo* scenInfoArray) { char* scenFileName; char pictName[20]; char textName[20]; char* pathName; if( scenCount==0 ) { box.msg( "Scenario files not found." ); return 0; } //-------------------------------------// // ##### begin Gilbert 4/11 ########// // stop any music music.stop(); // ##### end Gilbert 4/11 ########// int menuX1 = TUTOR_MENU_X1; int menuY1 = TUTOR_MENU_Y1; mouse_cursor.set_icon(CURSOR_NORMAL); power.win_opened = 1; int minRecno = 1; int browseRecno = minRecno; //--------------------------------------// Button3D scrollUp, scrollDown, startButton, cancelButton; int retFlag = 0; int refreshFlag = TUOPTION_ALL; scrollUp.create(menuX1+SCROLL_X1,menuY1+SCROLL_Y1-17, "SV-UP-U", "SV-UP-D", 1, 0); scrollDown.create(menuX1+SCROLL_X1,menuY1+SCROLL_Y2+1, "SV-DW-U", "SV-DW-D", 1, 0); // ###### begin Gilbert 1/11 ########// // startButton.create(menuX1+170, menuY1+529, "START-U", "START-D",1, 0); // cancelButton.create(menuX1+465, menuY1+529, "CANCEL-U", "CANCEL-D", 1, 0); startButton.create(menuX1+373, menuY1+529, "START-U", "START-D",1, 0); cancelButton.create(menuX1+548, menuY1+529, "CANCEL-U", "CANCEL-D", 1, 0); // ###### end Gilbert 1/11 ########// SlideVBar scrollBar; scrollBar.init_scroll(menuX1+SCROLL_X1, menuY1+SCROLL_Y1, menuX1+SCROLL_X2, menuY1+SCROLL_Y2, MAX_BROWSE_DISP_REC, disp_scroll_bar_func); scrollBar.set(minRecno, scenCount, minRecno); scrollBar.set_view_recno(browseRecno - MAX_BROWSE_DISP_REC/2); Button3D textScrollUp, textScrollDown; textScrollUp.create(menuX1+TEXT_SCROLL_X1, menuY1+TEXT_SCROLL_Y1-17, "SV-UP-U", "SV-UP-D", 1, 0); textScrollDown.create(menuX1+TEXT_SCROLL_X1,menuY1+TEXT_SCROLL_Y2+1, "SV-DW-U", "SV-DW-D", 1, 0); VLenQueue textBuffer; *(textBuffer.reserve(1)) = '\0'; Font &textFont = font_std; const int TEXT_LINE_SPACE = 4; const int ESTIMATED_LINE_IN_TEXT_AREA = (TEXT_AREA_Y2 - TEXT_AREA_Y1 + 1) / (textFont.font_height + TEXT_LINE_SPACE); SlideVBar textScrollBar; textScrollBar.init_scroll(menuX1+TEXT_SCROLL_X1, menuY1+TEXT_SCROLL_Y1, menuX1+TEXT_SCROLL_X2, menuY1+TEXT_SCROLL_Y2, ESTIMATED_LINE_IN_TEXT_AREA, disp_scroll_bar_func); // ###### begin Gilbert 1/11 ########// GetA playerNameField; playerNameField.init( menuX1+NAME_FIELD_X1, menuY1+NAME_FIELD_Y1, menuX1+NAME_FIELD_X2, config.player_name, config.PLAYER_NAME_LEN, &font_san, 0, 1); // ###### end Gilbert 1/11 ########// #ifdef TU_USE_BACKUP_SURFACE // create temporary surface Blob browseArea[MAX_BROWSE_DISP_REC]; Blob scrollArea; Blob textArea; Blob textScrollArea; // ##### begin Gilbert 1/11 #######// Blob nameFieldArea; // ##### end Gilbert 1/11 #######// #endif while(1) { //---------- yield --------// sys.yield(); mouse.get_event(); // --------- display ----------// if( refreshFlag ) { #ifndef TU_USE_BACKUP_SURFACE refreshFlag = TUOPTION_ALL; #endif scenFileName = scenInfoArray[browseRecno-1].file_name; m.change_file_ext( pictName, scenFileName, "SCP" ); m.change_file_ext( textName, scenFileName, "SCT" ); pathName = DIR_SCENARIO_PATH(scenInfoArray[browseRecno-1].dir_id); err_when( ! *pathName ); if( refreshFlag & TUOPTION_PAGE ) { mouse.hide_area(menuX1, menuY1, menuX1+TUTOR_MENU_WIDTH, menuY1+TUTOR_MENU_HEIGHT); image_interface.put_front( menuX1, menuY1, "SCENARIO" ); #ifdef TU_USE_BACKUP_SURFACE // capture into browseArea, scrollArea, textArea for( int j = 0; j < MAX_BROWSE_DISP_REC; ++j) { browseArea[j].resize(2*sizeof(short) + BROWSE_REC_WIDTH*BROWSE_REC_HEIGHT); vga_front.read_bitmap( menuX1+BROWSE_X1, menuY1+BROWSE_Y1 + j*BROWSE_REC_HEIGHT, menuX1+BROWSE_X2, menuY1+BROWSE_Y1 + j*BROWSE_REC_HEIGHT+BROWSE_REC_HEIGHT-1, browseArea[j].ptr); } scrollArea.resize(2*sizeof(short)+(SCROLL_X2-SCROLL_X1+1)*(SCROLL_Y2-SCROLL_Y1+1)); vga_front.read_bitmap(menuX1+SCROLL_X1,menuY1+SCROLL_Y1,menuX1+SCROLL_X2,menuY1+SCROLL_Y2, scrollArea.ptr); textArea.resize(2*sizeof(short)+TEXT_AREA_WIDTH*TEXT_AREA_HEIGHT); vga_front.read_bitmap(menuX1+TEXT_AREA_X1, menuY1+TEXT_AREA_Y1, menuX1+TEXT_AREA_X2, menuY1+TEXT_AREA_Y2, textArea.ptr); textScrollArea.resize( 2*sizeof(short)+ (TEXT_SCROLL_X2-TEXT_SCROLL_X1+1)*(TEXT_SCROLL_Y2-TEXT_SCROLL_Y1+1)); vga_front.read_bitmap(menuX1+TEXT_SCROLL_X1, menuY1+TEXT_SCROLL_Y1, menuX1+TEXT_SCROLL_X2, menuY1+TEXT_SCROLL_Y2, textScrollArea.ptr); // ###### begin Gilbert 1/11 ########// nameFieldArea.resize( 2*sizeof(short) + (playerNameField.x_limit-playerNameField.x+1)*playerNameField.height()); vga_front.read_bitmap(playerNameField.x, playerNameField.y, playerNameField.x_limit, playerNameField.y+playerNameField.height()-1, nameFieldArea.ptr); playerNameField.back_ground_bitmap = nameFieldArea.ptr; // ###### end Gilbert 1/11 ########// #endif scrollUp.paint(); scrollDown.paint(); startButton.paint(); cancelButton.paint(); textScrollUp.paint(); textScrollDown.paint(); mouse.show_area(); } if( refreshFlag & TUOPTION_PIC_AREA ) { String str; str = pathName; str += pictName; if( browseRecno && m.is_file_exist(str) ) { File pictFile; pictFile.file_open(str); vga_front.put_large_bitmap(menuX1+21,menuY1+19, &pictFile); pictFile.file_close(); } else { // draw the background #ifdef TU_USE_BACKUP_SURFACE // copy from ? #endif } } if( refreshFlag & TUOPTION_TEXT_BUFFER ) { // load text buffer String str; str = pathName; str += textName; if( browseRecno && m.is_file_exist(str) ) { File textFile; int dataSize; textFile.file_open(str); // ##### patch begin Gilbert 2/2 ####// dataSize = textFile.file_size(); FileTxt fileTxt( &textFile, dataSize ); // initialize fileTxt with an existing file stream fileTxt.next_line(); // skip the title lines fileTxt.next_line(); fileTxt.next_line(); fileTxt.next_line(); textBuffer.clear(); fileTxt.read_paragraph(textBuffer.reserve(dataSize+8), dataSize); // ##### end begin Gilbert 2/2 ####// int dispLines; // no. of lines can be displayed on the area int totalLines; // total no. of lines of the text textFont.count_line( menuX1+TEXT_AREA_X1, menuY1+TEXT_AREA_Y1, menuX1+TEXT_AREA_X2, menuY1+TEXT_AREA_Y2, textBuffer.queue_buf, TEXT_LINE_SPACE, dispLines, totalLines ); // textScrollBar.view_size = dispLines; textScrollBar.set(1, totalLines ,1); refreshFlag |= TUOPTION_TEXT_SCROLL; } } if( refreshFlag & TUOPTION_TEXT_AREA ) { #ifdef TU_USE_BACKUP_SURFACE // copy from back buffer vga_front.put_bitmap(menuX1+TEXT_AREA_X1, menuY1+TEXT_AREA_Y1, textArea.ptr); #endif textFont.put_paragraph(menuX1+TEXT_AREA_X1, menuY1+TEXT_AREA_Y1, menuX1+TEXT_AREA_X2, menuY1+TEXT_AREA_Y2, textBuffer.queue_buf, TEXT_LINE_SPACE, textScrollBar.view_recno ); // 4 - space between lines } if( refreshFlag & TUOPTION_TEXT_SCROLL ) { #ifdef TU_USE_BACKUP_SURFACE vga_front.put_bitmap(menuX1+TEXT_SCROLL_X1, menuY1+TEXT_SCROLL_Y1, textScrollArea.ptr); #endif // display scroll bar textScrollBar.paint(); } if( refreshFlag & TUOPTION_SCROLL ) { #ifdef TU_USE_BACKUP_SURFACE // copy from back buffer vga_front.put_bitmap(menuX1+SCROLL_X1, menuY1+SCROLL_Y1, scrollArea.ptr); #endif // display scroll bar scrollBar.paint(); } if( refreshFlag & TUOPTION_ALL_BROWSE ) { int rec, slot; for( slot = 0; slot < scrollBar.view_size; ++slot) { int browseSlotX1 = menuX1+BROWSE_X1; int browseSlotY1 = menuY1+BROWSE_Y1+slot*BROWSE_REC_HEIGHT; int browseSlotX2 = menuX1+BROWSE_X2; int browseSlotY2 = menuY1+BROWSE_Y1+(slot+1)*BROWSE_REC_HEIGHT-1; rec = scrollBar.view_recno + slot; if( refreshFlag & TUOPTION_BROWSE(slot) ) { #ifdef TU_USE_BACKUP_SURFACE vga_front.put_bitmap(browseSlotX1, browseSlotY1, browseArea[rec%MAX_BROWSE_DISP_REC].ptr); #endif if( rec >= 1 && rec <= scenCount ) { int textX = font_bible.put(browseSlotX1+TEXT_OFFSET_X, browseSlotY1+TEXT_OFFSET_Y, m.format(rec), 0, browseSlotX2 ); //----- display the scenario name -----// textX = font_bible.put(textX, browseSlotY1+TEXT_OFFSET_Y, ". ", 0, browseSlotX2 ); textX = font_bible.put(textX, browseSlotY1+TEXT_OFFSET_Y, scenInfoArray[rec-1].scen_name, 0, browseSlotX2 ); //---- display the scenario difficulty and bonus points ----// String str(translate.process("Difficulty: ")); str += scenInfoArray[rec-1].goal_difficulty; font_bible.put(browseSlotX1+TEXT_OFFSET_X+400, browseSlotY1+TEXT_OFFSET_Y, str, 0, browseSlotX2 ); str = translate.process("Score Bonus: "); str += scenInfoArray[rec-1].goal_score_bonus; font_bible.put(browseSlotX1+TEXT_OFFSET_X+530, browseSlotY1+TEXT_OFFSET_Y, str, 0, browseSlotX2 ); //--------------------------------------// if( rec == browseRecno ) { vga_front.adjust_brightness(browseSlotX1, browseSlotY1, browseSlotX2, browseSlotY2, -2); //vga_front.put_bitmap_trans_decompress( menuX1+BROWSE_X1, menuY1+BROWSE_Y1+slot*BROWSE_REC_HEIGHT, // image_button.read("LS-DWN")); } } } } } // ###### begin Gilbert 1/11 #######// if( refreshFlag & TUOPTION_NAME_FIELD ) playerNameField.paint(); // ###### end Gilbert 1/11 #######// refreshFlag = 0; } sys.blt_virtual_buf(); if( scrollBar.detect() == 1) { refreshFlag |= TUOPTION_SCROLL | TUOPTION_ALL_BROWSE; } else if( scrollUp.detect() ) { // click on scroll up int oldValue = scrollBar.view_recno; if( oldValue != scrollBar.set_view_recno(oldValue-1) ) refreshFlag |= TUOPTION_ALL_BROWSE | TUOPTION_SCROLL; } else if( scrollDown.detect() ) { // click on scroll down int oldValue = scrollBar.view_recno; if( oldValue != scrollBar.set_view_recno(oldValue+1) ) refreshFlag |= TUOPTION_ALL_BROWSE | TUOPTION_SCROLL; } else if( textScrollBar.detect() == 1 ) { refreshFlag |= TUOPTION_TEXT_SCROLL | TUOPTION_TEXT_AREA; } else if( textScrollUp.detect() ) { // click on scroll up int oldValue = textScrollBar.view_recno; if( oldValue != textScrollBar.set_view_recno(oldValue-1) ) refreshFlag |= TUOPTION_TEXT_SCROLL | TUOPTION_TEXT_AREA; } else if( textScrollDown.detect() ) { // click on scroll down int oldValue = textScrollBar.view_recno; if( oldValue != textScrollBar.set_view_recno(oldValue+1) ) refreshFlag |= TUOPTION_TEXT_SCROLL | TUOPTION_TEXT_AREA; } else if( mouse.double_click( menuX1+BROWSE_X1, menuY1+BROWSE_Y1, menuX1+BROWSE_X1+BROWSE_REC_WIDTH-1, menuY1+BROWSE_Y1+ BROWSE_REC_HEIGHT*MAX_BROWSE_DISP_REC -1) ) { // double click on game slot int oldValue = browseRecno; int newValue = scrollBar.view_recno + (mouse.click_y(0) - BROWSE_Y1 - menuY1) / BROWSE_REC_HEIGHT; if( newValue <= scenCount && newValue == oldValue ) { browseRecno = newValue; retFlag = newValue; break; } } else if( mouse.single_click( menuX1+BROWSE_X1, menuY1+BROWSE_Y1, menuX1+BROWSE_X1+BROWSE_REC_WIDTH-1, menuY1+BROWSE_Y1+ BROWSE_REC_HEIGHT*MAX_BROWSE_DISP_REC -1) ) { // click on game slot int oldValue = browseRecno; int newValue = scrollBar.view_recno + (mouse.click_y(0) - BROWSE_Y1 - menuY1) / BROWSE_REC_HEIGHT; if( newValue <= scenCount ) { if( oldValue != newValue ) { browseRecno = newValue; refreshFlag |= TUOPTION_BROWSE(newValue-scrollBar.view_recno) | TUOPTION_TEXT_BUFFER | TUOPTION_TEXT_AREA | TUOPTION_PIC_AREA; if( oldValue-scrollBar.view_recno >= 0 && oldValue-scrollBar.view_recno < MAX_BROWSE_DISP_REC) refreshFlag |= TUOPTION_BROWSE(oldValue-scrollBar.view_recno); } } } // ######## begin Gilbert 1/11 #########// else if( playerNameField.detect() ) { // load button refreshFlag = TUOPTION_NAME_FIELD; } // ######## end Gilbert 1/11 #########// else if( cancelButton.detect(KEY_ESC) || mouse.any_click(RIGHT_BUTTON) > 0) // also when ESC key is pressed or right button { // cancel button or escape key refreshFlag = TUOPTION_ALL; retFlag = 0; break; // break while(1) } else if( startButton.detect() ) { // load button refreshFlag = TUOPTION_ALL; retFlag = browseRecno; break; } } power.win_opened = 0; return retFlag; }
//------- Begin of function Help::load ----------// // // <char*> helpFileName = name of the help file. // void Help::load(char* helpFileName) { //------ Open the file and allocate buffer -----// FileTxt fileTxt( helpFileName ); int dataSize = fileTxt.file_size(); if( dataSize > help_text_buf_size ) { help_text_buf = mem_resize( help_text_buf, dataSize ); // allocate a buffer larger than we need for the largest size possible help_text_buf_size = dataSize; } //-------- read in help info one by one --------// HelpInfo* iptr = help_info_array; char* textPtr = help_text_buf; int readLen, totalReadLen=0; // total length of text read into the help_text_buf int loopCount=0; char* tokenStr; help_info_count=0; first_help_by_help_code = first_help_by_area = -1; last_help_by_help_code = last_help_by_area = 0; while( !fileTxt.is_eof() ) { err_when( loopCount++ > 10000 ); tokenStr = fileTxt.get_token(0); // don't advance the pointer if( !tokenStr ) break; // ##### begin Gilbert 9/9 ######// iptr->help_code[0] = NULL; // to identitfy search help text by help_code or coordinate // ##### end Gilbert 9/9 ######// //--------- if it's a help code ----------// if( tokenStr[0] >= 'A' && tokenStr[0] <= 'Z' ) { strncpy( iptr->help_code, tokenStr, iptr->HELP_CODE_LEN ); iptr->help_code[iptr->HELP_CODE_LEN] = NULL; // ###### begin Gilbert 9/9 #######// if( first_help_by_help_code == -1) first_help_by_help_code = help_info_count; last_help_by_help_code = help_info_count+1; // record one after last // ###### end Gilbert 9/9 #######// } //------ if it's a help area position ------// else if( tokenStr[0] >= '0' && tokenStr[0] <= '9' ) { iptr->area_x1 = (short) fileTxt.get_num(); iptr->area_y1 = (short) fileTxt.get_num(); iptr->area_x2 = (short) fileTxt.get_num(); iptr->area_y2 = (short) fileTxt.get_num(); // skip the 1024x768 numbers fileTxt.get_num(); fileTxt.get_num(); fileTxt.get_num(); fileTxt.get_num(); iptr->monster_human_interface = (short) fileTxt.get_num();// 0 when display for both interfaces // 1 when display only for monster interface // 2 when display only for human interface // ###### begin Gilbert 15/9 #######// if( first_help_by_area == -1) first_help_by_area = help_info_count; last_help_by_area = help_info_count+1; // record one after last // ###### end Gilbert 15/9 #######// } else err_here(); //---------- next line -----------// fileTxt.next_line(); if( fileTxt.is_eof() ) break; //--------------------------------------------// // get help title //--------------------------------------------// fileTxt.read_line( iptr->help_title, iptr->HELP_TITLE_LEN ); //---------------------------------------------------------// // get help description //---------------------------------------------------------// readLen = fileTxt.read_paragraph(textPtr, help_text_buf_size-totalReadLen); iptr->help_text_ptr = textPtr; iptr->help_text_len = readLen; textPtr += readLen; totalReadLen += readLen; err_when( totalReadLen>help_text_buf_size ); //----------- next help block -------------// fileTxt.next_line(); // pass the page break line help_info_count++; iptr++; err_when( help_info_count >= MAX_HELP_INFO ); } if( first_help_by_help_code == -1 ) first_help_by_help_code = 0; if( first_help_by_area == -1 ) first_help_by_area = 0; err_when( last_help_by_help_code > help_info_count ); err_when( last_help_by_area > help_info_count ); }
//------------ Begin of function Tutor::load -------------// // // <int> tutorId - id. of the tutorial // void Tutor::load(int tutorId) { cur_tutor_id = tutorId; //------- get the tutor msgs from the resource file -------// int dataSize; File* filePtr = res_tutor_text.get_file( tutor[tutorId]->code, dataSize); if( !filePtr ) // if error getting the tutor resource { err_here(); return; } //------ Open the file and allocate buffer -----// FileTxt fileTxt( filePtr, dataSize ); // initialize fileTxt with an existing file stream if( dataSize > tutor_text_buf_size ) { tutor_text_buf = mem_resize( tutor_text_buf, dataSize ); // allocate a buffer larger than we need for the largest size possible tutor_text_buf_size = dataSize; } //-------- read in tutor info one by one --------// TutorTextBlock* tutorTextBlock = text_block_array; char* textPtr = tutor_text_buf; int readLen, totalReadLen=0; // total length of text read into the tutor_text_buf int loopCount=0; char* tokenStr; text_block_count=0; fileTxt.next_line(); // by pass the first two lines of file description fileTxt.next_line(); while( !fileTxt.is_eof() ) { err_when( loopCount++ > 10000 ); tokenStr = fileTxt.get_token(0); // don't advance the pointer if( !tokenStr ) break; //------ read in the display button code of the tutorial segment -------// if( strcmpi( tokenStr, "Button" ) == 0 ) { fileTxt.get_token(1); // advance the pointer tokenStr = fileTxt.get_token(1); strncpy( tutorTextBlock->button_code, tokenStr, tutorTextBlock->BUTTON_CODE_LEN ); tutorTextBlock->button_code[tutorTextBlock->BUTTON_CODE_LEN] = '\0'; } else { tutorTextBlock->button_code[0] = '\0'; } //------- read in the tutorial text -------// readLen = fileTxt.read_paragraph(textPtr, tutor_text_buf_size-totalReadLen); tutorTextBlock->text_ptr = textPtr; tutorTextBlock->text_len = readLen; textPtr += readLen; totalReadLen += readLen; err_when( totalReadLen>tutor_text_buf_size ); //----------- next tutor block -------------// fileTxt.next_line(); // pass the page break line text_block_count++; tutorTextBlock++; err_when( text_block_count >= MAX_TUTOR_TEXT_BLOCK ); } cur_text_block_id = 1; last_text_block_id = 0; }