00001
00002
00003
00004 #include <math.h>
00005
00006 #include <ALL.H>
00007 #include <VGAFUN.H>
00008 #include <OVGA.H>
00009 #include <OINFO.H>
00010 #include <OICONRES.H>
00011 #include <OGAME.H>
00012 #include <OPIE.H>
00013
00014 #define PI_OVER180 1.74532925199433E-002
00015
00016
00021
00022 if( slotIconPtr )
00023 slot_icon_ptr = slotIconPtr;
00024 else
00025 slot_icon_ptr = icon_sys.read("PIESLOT1");
00026
00027 box_width = *((short*)slot_icon_ptr);
00028
00029 pie_radius = box_width/2-3;
00030
00031
00032
00033 int i=0;
00034 float curRadian;
00035
00036 curRadian = PI_OVER180 * 180;
00037
00038 for( i=0 ; i<MAX_DEGREE ; curRadian+=PI_OVER180, i++ ) {
00039 pie_point_table[i].x = (box_width>>1) + sin(curRadian) * pie_radius;
00040 pie_point_table[i].y = (box_width>>1) + cos(curRadian) * pie_radius;
00041
00042 if( i>=2 ) {
00043 if( pie_point_table[i-1].x == pie_point_table[i-2].x &&
00044 pie_point_table[i-1].y == pie_point_table[i-2].y &&
00045 pie_point_table[i].x - pie_point_table[i-2].x &&
00046 pie_point_table[i].y - pie_point_table[i-2].y ) {
00047 pie_point_table[i-1].x = pie_point_table[i].x;
00048 pie_point_table[i-1].y = pie_point_table[i-2].y;
00049 }
00050 }
00051 }
00052 }
00053
00054
00055
00056
00063
00064 if( backColor == -1 )
00065 backColor = V_BACKGROUND;
00066
00067 vga.init_image( box_width, box_width );
00068
00069 IMGputIcon( 0, 0, slot_icon_ptr );
00070
00071 last_degree= -1;
00072 }
00073
00074
00075
00076
00083
00084 err_if( sliceShare<0 || sliceShare>100 || sliceShare==infinite_number )
00085 err_here();
00086
00087 int i, lastX= -1, lastY = -1, pieCentre = box_width>>1;
00088
00089 float endDegree = last_degree + (float) MAX_DEGREE * sliceShare / 100;
00090 endDegree = min( endDegree, MAX_DEGREE-1 );
00091
00092
00093 PiePoint *curPoint = pie_point_table + (int)last_degree+1;
00094
00095
00096
00097 for( i=last_degree+1 ; i<=endDegree ; i++, curPoint++ ) {
00098 if( curPoint->x != lastX || curPoint->y != lastY ) {
00099 IMGline( pieCentre, pieCentre, curPoint->x, curPoint->y, sliceColor );
00100
00101 lastX = curPoint->x;
00102 lastY = curPoint->y;
00103 }
00104 }
00105
00106 last_degree = endDegree;
00107 }
00108
00109
00110
00111
00118
00119 if( last_degree < MAX_DEGREE-1 )
00120 draw_slice( 100L * (MAX_DEGREE - last_degree+1) / 360, V_WHITE );
00121
00122 vga.put_image( x, y );
00123 vga.deinit_image();
00124 }
00125
00126