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

Password:

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

OFIRMDRW.CPP

Go to the documentation of this file.
00001 //Filename    : OFIRMDRW.CPP
00002 //Description : Firm drawing routines
00003 //owner         : ho
00004 
00005 #include <OVGA.H>
00006 #include <OWORLD.H>
00007 #include <OSTR.H>
00008 #include <OFONT.H>
00009 #include <OFIRMRES.H>
00010 #include <OFIRM.H>
00011 #include <OIFACE.H>
00012 
00013 //--------- Begin of function Firm::draw ----------//
00017 void Firm::draw(Matrix* matrixPtr) {
00018     FirmInfo* firmInfo = firm_res[firm_id];
00019 
00020     //-------- check if the firm is within the view area --------//
00021 
00022     int zoomLevel = matrixPtr->zoom_level;
00023     int bmpWidth  = firmInfo->bitmap_width[zoomLevel];
00024     int bmpHeight = firmInfo->bitmap_height[zoomLevel];
00025     char* bmpPtr  = firmInfo->bitmap_ptr[zoomLevel];
00026 
00027     int x1 = abs_rect[zoomLevel].x1 - matrixPtr->abs_top_x;
00028 
00029     // out of the view area, not even a slight part of it appears in the view area
00030     if( x1 <= -bmpWidth || x1 >= matrixPtr->win_width )
00031         return;
00032 
00033     int y1 = abs_rect[zoomLevel].y1 - matrixPtr->abs_top_y;
00034 
00035     if( y1 <= -bmpHeight || y1 >= matrixPtr->win_height )
00036         return;
00037 
00038     int x2 = abs_rect[zoomLevel].x2 - matrixPtr->abs_top_x;
00039     int y2 = abs_rect[zoomLevel].y2 - matrixPtr->abs_top_y;
00040 
00041     if( x2 < 0 || y2 < 0 )
00042         return;
00043 
00044     //------ get the color remap table -------//
00045 
00046     // don't highlight building
00047     short* colorRemapTable = firm_res.get_color_remap_table( is_selected() );
00048 
00049     //---- only portion of the sprite is inside the view area ------//
00050 
00051     if( x1 < 0 || x2 >= matrixPtr->win_width || y1 < 0 || y2 >= matrixPtr->win_height ) {
00052         vga_back.put_bitmap_area_trans_remap_decompress( x1+matrixPtr->win_x1, y1+matrixPtr->win_y1, bmpPtr,
00053                                                          max(0,x1)-x1, max(0,y1)-y1, min(matrixPtr->win_width-1,x2)-x1, min(matrixPtr->win_height-1,y2)-y1, colorRemapTable );
00054         //              if(is_selected())
00055         //              {
00056         //                      user_interface.brighten(max(0,x1+matrixPtr->win_x1), max(0,y1)+matrixPtr->win_y1,
00057         //                              min(matrixPtr->win_width-1,x2)+matrixPtr->win_x1, min(matrixPtr->win_height-1,y2)+matrixPtr->win_y1);
00058         //              }
00059     }
00060 
00061     //---- the whole sprite is inside the view area ------//
00062 
00063     else {
00064         vga_back.put_bitmap_trans_remap_decompress( x1+matrixPtr->win_x1, y1+matrixPtr->win_y1, bmpPtr, colorRemapTable );
00065         //              if(is_selected())
00066         //              {
00067         //                      user_interface.brighten(x1+matrixPtr->win_x1,y1+matrixPtr->win_y1,x2+matrixPtr->win_x1,y2+matrixPtr->win_y1);
00068         //              }
00069     }
00070 
00071 }
00072 
00073 //--------- End of function Firm::draw -----------//

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