00001
00002
00003
00004 #include <KEY.H>
00005 #include <OVGA.H>
00006 #include <OSYS.H>
00007 #include <OCONFIG.H>
00008 #include <OMOUSE.H>
00009 #include <OMATRIX.H>
00010 #include <OWORLD.H>
00011 #include <OFIRM.H>
00012 #include <OFIRMRES.H>
00013 #include <COLCODE.H>
00014 #include <OLOG.H>
00015
00016
00017
00018 ZoomMatrix::ZoomMatrix() {
00019 next_scroll_time = 0;
00020 }
00021
00022
00023
00024
00025
00026 void ZoomMatrix::draw_all() {
00027 Matrix::draw_all();
00028 }
00029
00030
00031
00032
00033
00034 void ZoomMatrix::draw_update() {
00035
00036 }
00037
00038
00039
00040 #if(GAME_VERSION>=200)
00041 void ZoomMatrix::draw_text() {
00042
00043
00044 if( config.disp_building_label ) {
00045
00046
00047 for( int firmRecno = 1; firmRecno <= firm_array.size(); ++firmRecno ) {
00048 if( firm_array.is_deleted(firmRecno) )
00049 continue;
00050 Firm *firmPtr = firm_array[firmRecno];
00051 if( firmPtr->name_on_map() ) {
00052 put_center_text( (firmPtr->abs_rect[zoom_level].x1+firmPtr->abs_rect[zoom_level].x2)/2,
00053 (firmPtr->abs_rect[zoom_level].y1+firmPtr->abs_rect[zoom_level].y2)/2,
00054 firmPtr->name_on_map() );
00055 }
00056 }
00057 }
00058 }
00059 #endif
00060
00061
00062
00063 int ZoomMatrix::detect() {
00064 if( detect_scroll() )
00065 return 1;
00066
00067 return detect_select();
00068 }
00069
00070
00071
00072
00077
00078
00079 if( next_scroll_time && m.get_time() < next_scroll_time )
00080 return 0;
00081
00082 int rc=0;
00083
00084
00085
00086 if( mouse.cur_x == mouse.bound_x1 || mouse.key_code==KEY_LEFT ) {
00087 world.map_matrix.scroll(-1,0);
00088 rc = 1;
00089 }
00090
00091
00092
00093 if( mouse.cur_x == mouse.bound_x2 || mouse.key_code==KEY_RIGHT ) {
00094 world.map_matrix.scroll(1,0);
00095 rc = 1;
00096 }
00097
00098
00099
00100 if( mouse.cur_y == mouse.bound_y1 || mouse.key_code==KEY_UP ) {
00101 world.map_matrix.scroll(0,-1);
00102 rc = 1;
00103 }
00104
00105
00106
00107 if( mouse.cur_y == mouse.bound_y2 || mouse.key_code==KEY_DOWN ) {
00108 world.map_matrix.scroll(0,1);
00109 rc = 1;
00110 }
00111
00112
00113
00114
00115
00116
00117
00118
00119 if( rc )
00120 next_scroll_time = m.get_time() + 500/(config.scroll_speed+1);
00121
00122 return rc;
00123 }
00124
00125
00126
00127
00128
00129 int ZoomMatrix::detect_select() {
00130 int absClickX = abs_top_x + (mouse.cur_x-win_x1);
00131 int absClickY = abs_top_y + (mouse.cur_y-win_y1);
00132
00133 firm_array.touched_recno = 0;
00134
00135
00136 int i,j,dispCount = disp_sort_array.size();
00137
00138 for( i=dispCount ;i>=1; i-- ) {
00139 DisplaySort* displaySortPtr = (DisplaySort*) disp_sort_array.get(i);
00140
00141
00142
00143 if(displaySortPtr->object_type!=OBJECT_FIRM)
00144 continue;
00145
00146 j=displaySortPtr->object_recno;
00147
00148 Firm *firmPtr;
00149 if( firm_array.is_deleted(j) )
00150 continue;
00151
00152 firmPtr = firm_array[j];
00153
00154
00155 if( firmPtr->abs_rect[zoom_level].is_inside( absClickX, absClickY ) ) {
00156
00157
00158 FirmInfo* firmInfo = firm_res[firmPtr->firm_id];
00159
00160
00161
00162 char* bmpPtr = firmInfo->bitmap_ptr[zoom_level];
00163
00164
00165 int cur_x = absClickX - firmPtr->abs_rect[zoom_level].x1;
00166
00167 int cur_y = absClickY - firmPtr->abs_rect[zoom_level].y1;
00168
00169
00170
00171
00172
00173
00174
00175
00176 if(IMGgetTransDecompress(bmpPtr,cur_x,cur_y)==TRANSPARENT_CODE)
00177 continue;
00178
00179
00180 firm_array.touched_recno = j;
00181
00182 firm_array.touched_frame_count = sys.frame_count;
00183
00184
00185
00186 int rc=mouse.any_click( win_x1,win_y1,win_x2,win_y2, LEFT_BUTTON );
00187
00188 if( rc==1 ) {
00189 firm_array.select_firm(j);
00190 sys.redraw_all_flag = 1;
00191 return 1;
00192 }
00193
00194
00195
00196 else if( rc==2 ) {
00197 firm_array[j]->double_click_firm();
00198 return 1;
00199 }
00200 return 0;
00201 }
00202 }
00203
00204 return 0;
00205 }
00206
00207