void fill_in_stick(cv::Mat & Disp_map,cv::Mat & Occ_map){ int width = Disp_map.cols; int height = Disp_map.rows; cv::Mat fill_left(height,width,CV_8UC1,cv::Scalar::all(0)); cv::Mat fill_right(height,width,CV_8UC1,cv::Scalar::all(0)); Disp_map.copyTo(fill_left); Disp_map.copyTo(fill_right); cv::Mat cur_fill(height,1,CV_8UC1,cv::Scalar::all(Disp_K)); for(int i=0;i<width;i++){ for(int j=0;j<height;j++){ if(Occ_map.data[j*width+i]==255) fill_left.data[j*width+i] = cur_fill.data[j]; else cur_fill.data[j] = fill_left.data[j*width+i]; } } cur_fill.setTo(cv::Scalar::all(Disp_K)); for(int i=width-1;i>-1;i--){ for(int j=0;j<height;j++){ if(Occ_map.data[j*width+i]==255) fill_right.data[j*width+i] = cur_fill.data[j]; else cur_fill.data[j] = fill_right.data[j*width+i]; } } cv::Mat disp_view(height,width,CV_8UC1,cv::Scalar::all(0)); for(int i=0;i<width;i++){ for(int j=0;j<height;j++){ Disp_map.data[j*width+i] = min(fill_left.data[j*width+i],fill_right.data[j*width+i]); disp_view.data[j*width+i] = scale_K * Disp_map.data[j*width+i]; } } cv::namedWindow("disp",0); cv::imshow("disp",disp_view); cv::waitKey(); }
//-------- Begin of function Sys::set_view_mode --------// // // <int> viewMode - id. of the view mode. // [int] viewingNationRecno - which nation the player is viewing at with the reports. // (default: the player nation) // [int] viewingSpyRecno - >0 if the spy is viewing secret reports of other nations // void Sys::set_view_mode(int viewMode, int viewingNationRecno, int viewingSpyRecno) { if( view_mode == viewMode ) return; info.display_hot_key = 0; //---- if the player's kingdom has been destroyed ----// err_when( viewingNationRecno && nation_array.is_deleted(viewingNationRecno) ); if( nation_array.is_deleted(info.default_viewing_nation_recno) ) { if( viewMode != MODE_NORMAL && viewMode != MODE_RANK ) // other reports are not available except the normal and rank report return; } //---- a spy is exposed when he has finished viewing the secrets ----// if( info.viewing_spy_recno ) { if( !spy_array.is_deleted(info.viewing_spy_recno) ) { Spy* spyPtr = spy_array[info.viewing_spy_recno]; int needViewSecretSkill = spy_array.needed_view_secret_skill(info.viewing_spy_recno); int escapeChance = spyPtr->spy_skill - needViewSecretSkill; int killFlag = 0; if( escapeChance > 0 ) { if( m2.random( escapeChance/15 )==0 ) // use m2 instead of m to maintain mulitplayer sync killFlag = 1; } if( killFlag ) spyPtr->set_exposed(COMMAND_PLAYER); } info.viewing_spy_recno = 0; } //----------------------------------------------------// if( viewMode == MODE_NORMAL ) { info.viewing_nation_recno = info.default_viewing_nation_recno; } else { if( viewingNationRecno ) info.viewing_nation_recno = viewingNationRecno; else info.viewing_nation_recno = info.default_viewing_nation_recno; info.viewing_spy_recno = viewingSpyRecno; } view_mode = viewMode; disp_view_mode(); disp_view(); }
void Sys::disp_frame() { if( sys.signal_exit_flag ) return; if( option_menu.is_active() ) { // ##### begin Gilbert 3/11 ######// option_menu.disp(need_redraw_flag); // ##### end Gilbert 3/11 ######// blt_virtual_buf(); } else { // -------- re-draw the whole screen if needed, such as after task switching ---------// if( need_redraw_flag ) { info.disp_panel(); world.paint(); disp_button(); world.refresh(); disp_view(); if( in_game_menu.is_active() ) { vga.use_back(); in_game_menu.disp(); vga.use_front(); } vga_util.blt_buf(0,0, VGA_WIDTH-1, VGA_HEIGHT-1, 0); // ###### begin Gilbert 4/11 ######// disp_view_mode(); // ###### end Gilbert 4/11 ######// info.disp(); } else { update_view(); info.update(); } //--------- display the map and info area --------// disp_map(); blt_virtual_buf(); //---------- display help ----------// if( !remote.is_enable() ) // help is only available in a single player game as it has to pause the game help.disp(); } // ####### end Glbert 24/10 #######// anim_line.inc_phase(); // originally in Sys::process() need_redraw_flag = 0; }