Changeset 657
- Timestamp:
- May 15, 2011, 6:22:17 AM (11 years ago)
- Location:
- abuse/trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
abuse/trunk/TODO
r656 r657 56 56 REFACTOR 57 57 -------- 58 game_to_mouse : utiliser vec2i 58 game_to_mouse : utiliser vec2i, ftile_on btile_on 59 59 console::draw_char : pareil 60 60 VolumeWindow::draw_vol plus grand !! 61 61 62 dlastx, dlasty, x, y (apparemment des membres de object) 63 last_demo_mx, last_demo_my 64 get_fg ? 65 snap_x() snap_y() 66 scatter_line, ascatter_line 67 -
abuse/trunk/src/clisp.cpp
r656 r657 906 906 case 49 : 907 907 { 908 int32_t x=lnumber_value(CAR(args)->Eval()); args=CDR(args); 909 int32_t y=lnumber_value(CAR(args)->Eval()); args=CDR(args); 910 911 int32_t rx,ry; 912 the_game->mouse_to_game(x,y,rx,ry); 913 void *ret=NULL; 914 { 915 PtrRef r1(ret); 916 push_onto_list(LNumber::Create(ry),ret); 917 push_onto_list(LNumber::Create(rx),ret); 908 int x = lnumber_value(CAR(args)->Eval()); args = CDR(args); 909 int y = lnumber_value(CAR(args)->Eval()); args = CDR(args); 910 911 vec2i pos = the_game->MouseToGame(vec2i(x, y)); 912 void *ret = NULL; 913 { 914 PtrRef r1(ret); 915 push_onto_list(LNumber::Create(pos.y), ret); 916 push_onto_list(LNumber::Create(pos.x), ret); 918 917 } 919 918 return ret; … … 921 920 case 50 : 922 921 { 923 int32_t x=lnumber_value(CAR(args)->Eval()); args=CDR(args); 924 int32_t y=lnumber_value(CAR(args)->Eval()); args=CDR(args); 925 926 int32_t rx,ry; 927 the_game->game_to_mouse(x,y,current_view,rx,ry); 928 void *ret=NULL; 929 { 930 PtrRef r1(ret); 931 push_onto_list(LNumber::Create(ry),ret); 932 push_onto_list(LNumber::Create(rx),ret); 922 int x = lnumber_value(CAR(args)->Eval()); args=CDR(args); 923 int y = lnumber_value(CAR(args)->Eval()); args=CDR(args); 924 925 vec2i pos = the_game->GameToMouse(vec2i(x, y), current_view); 926 void *ret = NULL; 927 { 928 PtrRef r1(ret); 929 push_onto_list(LNumber::Create(pos.y), ret); 930 push_onto_list(LNumber::Create(pos.x), ret); 933 931 } 934 932 return ret; … … 1287 1285 case 92 : 1288 1286 { 1289 int32_t cx1,x1=lnumber_value(CAR(args)); args=lcdr(args);1290 int32_t cy1,y1=lnumber_value(CAR(args)); args=lcdr(args);1291 int32_t cx2,x2=lnumber_value(CAR(args)); args=lcdr(args);1292 int32_t cy2,y2=lnumber_value(CAR(args)); args=lcdr(args);1293 int32_t c =lnumber_value(CAR(args));1294 the_game->game_to_mouse(x1,y1,current_view,cx1,cy1);1295 the_game->game_to_mouse(x2,y2,current_view,cx2,cy2);1296 main_screen->Line( vec2i(cx1, cy1), vec2i(cx2, cy2), c);1287 int32_t x1 = lnumber_value(CAR(args)); args = lcdr(args); 1288 int32_t y1 = lnumber_value(CAR(args)); args = lcdr(args); 1289 int32_t x2 = lnumber_value(CAR(args)); args = lcdr(args); 1290 int32_t y2 = lnumber_value(CAR(args)); args = lcdr(args); 1291 int32_t c = lnumber_value(CAR(args)); 1292 vec2i pos1 = the_game->GameToMouse(vec2i(x1, y1), current_view); 1293 vec2i pos2 = the_game->GameToMouse(vec2i(x2, y2), current_view); 1294 main_screen->Line(pos1, pos2, c); 1297 1295 return 1; 1298 1296 } break; … … 1964 1962 case 234 : 1965 1963 { 1966 int32_t cx1,x1=lnumber_value(CAR(args)); args=lcdr(args);1967 int32_t cy1,y1=lnumber_value(CAR(args)); args=lcdr(args);1968 int32_t cx2,x2=lnumber_value(CAR(args)); args=lcdr(args);1969 int32_t cy2,y2=lnumber_value(CAR(args)); args=lcdr(args);1970 int32_t c =lnumber_value(CAR(args)); args=lcdr(args);1971 int32_t s =lnumber_value(CAR(args));1972 the_game->game_to_mouse(x1,y1,current_view,cx1,cy1);1973 the_game->game_to_mouse(x2,y2,current_view,cx2,cy2);1974 scatter_line( cx1,cy1,cx2,cy2,c,s);1964 int32_t x1 = lnumber_value(CAR(args)); args = lcdr(args); 1965 int32_t y1 = lnumber_value(CAR(args)); args = lcdr(args); 1966 int32_t x2 = lnumber_value(CAR(args)); args = lcdr(args); 1967 int32_t y2 = lnumber_value(CAR(args)); args = lcdr(args); 1968 int32_t c = lnumber_value(CAR(args)); args = lcdr(args); 1969 int32_t s = lnumber_value(CAR(args)); 1970 vec2i pos1 = the_game->GameToMouse(vec2i(x1, y1), current_view); 1971 vec2i pos2 = the_game->GameToMouse(vec2i(x2, y2), current_view); 1972 scatter_line(pos1.x, pos1.y, pos2.x, pos2.y, c, s); 1975 1973 return 1; 1976 1974 … … 2016 2014 case 244 : 2017 2015 { 2018 int32_t cx1,x1=lnumber_value(CAR(args)); args=lcdr(args);2019 int32_t cy1,y1=lnumber_value(CAR(args)); args=lcdr(args);2020 int32_t cx2,x2=lnumber_value(CAR(args)); args=lcdr(args);2021 int32_t cy2,y2=lnumber_value(CAR(args)); args=lcdr(args);2022 int32_t c1 =lnumber_value(CAR(args)); args=lcdr(args);2023 int32_t c2 =lnumber_value(CAR(args)); args=lcdr(args);2024 int32_t s =lnumber_value(CAR(args));2025 the_game->game_to_mouse(x1,y1,current_view,cx1,cy1);2026 the_game->game_to_mouse(x2,y2,current_view,cx2,cy2);2027 ascatter_line( cx1,cy1,cx2,cy2,c1,c2,s);2016 int32_t x1 = lnumber_value(CAR(args)); args = lcdr(args); 2017 int32_t y1 = lnumber_value(CAR(args)); args = lcdr(args); 2018 int32_t x2 = lnumber_value(CAR(args)); args = lcdr(args); 2019 int32_t y2 = lnumber_value(CAR(args)); args = lcdr(args); 2020 int32_t c1 = lnumber_value(CAR(args)); args = lcdr(args); 2021 int32_t c2 = lnumber_value(CAR(args)); args = lcdr(args); 2022 int32_t s = lnumber_value(CAR(args)); 2023 vec2i pos1 = the_game->GameToMouse(vec2i(x1, y1), current_view); 2024 vec2i pos2 = the_game->GameToMouse(vec2i(x2, y2), current_view); 2025 ascatter_line(pos1.x, pos1.y, pos2.x, pos2.y, c1, c2, s); 2028 2026 return 1; 2029 2027 -
abuse/trunk/src/demo.cpp
r656 r657 120 120 if (get_packet(buf,size)) // get starting inputs 121 121 { 122 process_packet_commands(buf,size); 123 int32_t mx,my; 124 the_game->game_to_mouse(player_list->pointer_x,player_list->pointer_y,player_list,mx,my); 125 wm->SetMousePos((small_render ? 2 : 1) * vec2i(mx, my)); 122 process_packet_commands(buf, size); 123 vec2i mouse = the_game->GameToMouse(vec2i(player_list->pointer_x, 124 player_list->pointer_y), 125 player_list); 126 wm->SetMousePos((small_render ? 2 : 1) * mouse); 126 127 } 127 128 else -
abuse/trunk/src/dev.cpp
r656 r657 491 491 if (link_object) 492 492 { 493 int32_t rx1,ry1; 494 the_game->game_to_mouse(link_object->x,link_object->y,v,rx1,ry1); 495 main_screen->Line(vec2i(rx1, ry1), vec2i(dlastx, dlasty), yellow); 493 vec2i pos = the_game->GameToMouse(vec2i(link_object->x, link_object->y), v); 494 main_screen->Line(pos, vec2i(dlastx, dlasty), yellow); 496 495 } 497 496 498 497 if (selected_light) 499 498 { 500 image *i=cache.img(light_buttons[0]); 501 int l=i->Size().x/2,h=i->Size().y/2; 502 int32_t rx1,ry1; 503 the_game->game_to_mouse(selected_light->x,selected_light->y,v,rx1,ry1); 504 main_screen->Rectangle(vec2i(rx1 - l, ry1 - h), vec2i(rx1 + l, ry1 + h), 499 image *im = cache.img(light_buttons[0]); 500 vec2i pos = the_game->GameToMouse(vec2i(selected_light->x, selected_light->y), v); 501 main_screen->Rectangle(pos - im->Size() / 2, pos + im->Size() / 2, 505 502 wm->bright_color()); 506 503 } … … 510 507 for (o=current_level->first_object(); o; o=o->next) 511 508 { 512 the_game->game_to_mouse(o->x,o->y,current_view,x1,y1);509 vec2i pos = the_game->GameToMouse(vec2i(o->x, o->y), current_view); 513 510 char *nm=object_names[o->otype]; 514 console_font->put_string(main_screen, x1-strlen(nm)*console_font->width()/2,y1+2,nm);511 console_font->put_string(main_screen, pos.x - strlen(nm) * console_font->width() / 2, pos.y + 2, nm); 515 512 } 516 513 … … 520 517 for (o=current_level->first_object(); o; o=o->next) 521 518 { 522 the_game->game_to_mouse(o->x,o->y,current_view,x1,y1);519 vec2i pos1 = the_game->GameToMouse(vec2i(o->x, o->y), current_view); 523 520 524 521 int i=0; … … 526 523 { 527 524 game_object *other=o->get_object(i); 528 the_game->game_to_mouse(other->x,other->y,current_view,x2,y2);529 main_screen->Line( vec2i(x1, y1), vec2i(x2, y2), wm->bright_color());525 vec2i pos2 = the_game->GameToMouse(vec2i(other->x, other->y), current_view); 526 main_screen->Line(pos1, pos2, wm->bright_color()); 530 527 } 531 528 … … 533 530 { 534 531 light_source *l=o->get_light(i); 535 the_game->game_to_mouse(l->x,l->y,current_view,x2,y2);536 main_screen->Line( vec2i(x1, y1), vec2i(x2, y2), light_connection_color);532 vec2i pos2 = the_game->GameToMouse(vec2i(l->x, l->y), current_view); 533 main_screen->Line(pos1, pos2, light_connection_color); 537 534 } 538 535 … … 543 540 { 544 541 selected_object->picture_space(x1,y1,x2,y2); 545 int32_t rx1,ry1,rx2,ry2; 546 the_game->game_to_mouse(x1,y1,v,rx1,ry1); 547 the_game->game_to_mouse(x2,y2,v,rx2,ry2); 548 main_screen->Rectangle(vec2i(rx1, ry1), vec2i(rx2, ry2), 549 wm->bright_color()); 550 551 the_game->game_to_mouse(selected_object->x,selected_object->y,current_view,x1,y1); 542 vec2i pos1 = the_game->GameToMouse(vec2i(x1, y1), v); 543 vec2i pos2 = the_game->GameToMouse(vec2i(x2, y2), v); 544 main_screen->Rectangle(pos1, pos2, wm->bright_color()); 545 546 pos1 = the_game->GameToMouse(vec2i(selected_object->x, selected_object->y), current_view); 552 547 for (int i=0; i<selected_object->total_objects(); i++) 553 548 { 554 game_object *other=selected_object->get_object(i); 555 the_game->game_to_mouse(other->x,other->y,current_view,x2,y2); 556 main_screen->Line(vec2i(x1, y1), vec2i(x2, y2), light_connection_color); 557 } 558 } 559 560 549 game_object *other = selected_object->get_object(i); 550 pos2 = the_game->GameToMouse(vec2i(other->x, other->y), current_view); 551 main_screen->Line(pos1, pos2, light_connection_color); 552 } 553 } 561 554 } 562 555 } … … 1053 1046 if (!strcmp(fword,"unchop")) 1054 1047 { 1055 int32_t rx,ry; 1056 the_game->btile_on(dlastx,dlasty,rx,ry); 1057 if (rx>=0 && ry>=0) 1048 vec2i tile = the_game->GetBgTile(vec2i(dlastx, dlasty)); 1049 if (tile.x>=0 && tile.y>=0) 1058 1050 { 1059 1051 if (sscanf(command,"%s%d%d",fword,&l,&h)==3) … … 1064 1056 for (y=0,i=cur_bg; y<h; y++) 1065 1057 for (x=0; x<l; x++) 1066 the_game->put_bg( rx+x,ry+y,i++);1058 the_game->put_bg(tile.x+x,tile.y+y,i++); 1067 1059 dprintf("%dx%d\n",l,h); 1068 1060 } else dprintf(symbol_str("unchop1")); … … 1175 1167 if (t>=0) // did we find it? 1176 1168 { 1177 int32_t rx,ry; 1178 the_game->mouse_to_game(dlastx,dlasty,rx,ry); 1179 edit_object=create(t,rx,ry); 1169 vec2i pos = the_game->MouseToGame(vec2i(dlastx, dlasty)); 1170 edit_object=create(t, pos.x, pos.y); 1180 1171 current_level->add_object(edit_object); 1181 1172 the_game->need_refresh(); … … 1220 1211 if (!strcmp(fword,"fg_select")) 1221 1212 { 1222 int32_t x,y;1223 the_game->ftile_on(dlastx,dlasty,x,y);1224 if (x>=0 && y>=0 && x<current_level->foreground_width() &&1225 y<current_level->foreground_height())1226 { 1227 cur_fg=current_level->get_fg( x,y);1213 vec2i tile = the_game->GetFgTile(vec2i(dlastx, dlasty)); 1214 if (tile.x >= 0 && tile.y >= 0 && 1215 tile.x < current_level->foreground_width() && 1216 tile.y < current_level->foreground_height()) 1217 { 1218 cur_fg=current_level->get_fg(tile.x, tile.y); 1228 1219 if (forew) 1229 1220 ((tile_picker *)forew->read(DEV_FG_PICKER))->recenter(forew->m_surf); … … 1234 1225 if (!strcmp(fword,"toggle_fg_raise")) 1235 1226 { 1236 int32_t x,y;1237 the_game->ftile_on(dlastx,dlasty,x,y);1238 if (x>=0 && y>=0 && x<current_level->foreground_width() &&1239 y<current_level->foreground_height())1240 current_level->fg_set_raised( x,y,!current_level->fg_raised(x,y));1227 vec2i tile = the_game->GetFgTile(vec2i(dlastx, dlasty)); 1228 if (tile.x >= 0 && tile.y >= 0 && 1229 tile.x < current_level->foreground_width() && 1230 tile.y < current_level->foreground_height()) 1231 current_level->fg_set_raised(tile.x, tile.y,!current_level->fg_raised(tile.x,tile.y)); 1241 1232 } 1242 1233 … … 1523 1514 if (ev.type==EV_MOUSE_BUTTON && ev.mouse_button) 1524 1515 { 1525 int32_t gx,gy; 1526 the_game->mouse_to_game(last_demo_mx,last_demo_my,gx,gy); 1516 vec2i pos = the_game->MouseToGame(vec2i(last_demo_mx, last_demo_my)); 1527 1517 if (!current_level) return ; 1528 current_area=current_level->area_list=new area_controller( gx,gy,1518 current_area=current_level->area_list=new area_controller(pos.x, pos.y, 1529 1519 the_game->ftile_width(), 1530 1520 the_game->ftile_height(), … … 1564 1554 { 1565 1555 int32_t mx=last_demo_mx,my=last_demo_my; 1566 view *v =the_game->view_in(mx,my);1556 view *v = the_game->GetView(vec2i(mx, my)); 1567 1557 for (area_controller *a=current_level->area_list; a; a=a->next) 1568 1558 { 1569 int32_t x1,y1,x2,y2; 1570 the_game->game_to_mouse(a->x,a->y,v,x1,y1); 1571 the_game->game_to_mouse(a->x+a->w,a->y+a->h,v,x2,y2); 1572 if (abs(x1-mx)<2 && abs(y1-my)<2) 1573 { find=a; find_top=1; } 1574 else if (abs(x2-mx)<2 && abs(y2-my)<2) 1575 { find=a; find_top=0; } 1559 vec2i pos1 = the_game->GameToMouse(vec2i(a->x, a->y), v); 1560 vec2i pos2 = the_game->GameToMouse(vec2i(a->x + a->w, a->y + a->h), v); 1561 if (abs(pos1.x - mx) < 2 && abs(pos1.y - my) < 2) 1562 { find = a; find_top = 1; } 1563 else if (abs(pos2.x - mx) < 2 && abs(pos2.y - my) < 2) 1564 { find = a; find_top = 0; } 1576 1565 } 1577 1566 … … 1697 1686 if (ev.type==EV_MOUSE_MOVE) 1698 1687 { 1699 the_game->mouse_to_game(last_demo_mx,last_demo_my,edit_object->x,edit_object->y);1700 edit_object->x =snap_x(edit_object->x);1701 edit_object->y =snap_y(edit_object->y);1688 vec2i pos = the_game->MouseToGame(vec2i(last_demo_mx, last_demo_my)); 1689 edit_object->x = snap_x(pos.x); 1690 edit_object->y = snap_y(pos.y); 1702 1691 the_game->need_refresh(); 1703 1692 } … … 1725 1714 if (ev.type==EV_MOUSE_MOVE) 1726 1715 { 1727 the_game->mouse_to_game(last_demo_mx,last_demo_my,edit_light->x,edit_light->y);1728 edit_light->x =snap_x(edit_light->x);1729 edit_light->y =snap_y(edit_light->y);1716 vec2i pos = the_game->MouseToGame(vec2i(last_demo_mx, last_demo_my)); 1717 edit_light->x = snap_x(pos.x); 1718 edit_light->y = snap_y(pos.y); 1730 1719 1731 1720 edit_light->calc_range(); … … 1807 1796 if (current_area) 1808 1797 { 1809 int32_t gx,gy; 1810 the_game->mouse_to_game(last_demo_mx,last_demo_my,gx,gy); 1811 if (gx>current_area->x && gy>current_area->y) 1812 { 1813 if (gx-current_area->x!=current_area->w || gy-current_area->y!=current_area->h) 1798 vec2i pos = the_game->MouseToGame(vec2i(last_demo_mx, last_demo_my)); 1799 if (pos.x>current_area->x && pos.y>current_area->y) 1800 { 1801 if (pos.x-current_area->x!=current_area->w || pos.y-current_area->y!=current_area->h) 1814 1802 { 1815 1803 the_game->need_refresh(); 1816 current_area->w= gx-current_area->x;1817 current_area->h= gy-current_area->y;1804 current_area->w=pos.x-current_area->x; 1805 current_area->h=pos.y-current_area->y; 1818 1806 } 1819 1807 } … … 1830 1818 if (current_area) 1831 1819 { 1832 int32_t gx,gy; 1833 the_game->mouse_to_game(last_demo_mx,last_demo_my,gx,gy); 1834 if (gx<current_area->x+current_area->w && gy<current_area->y+current_area->h) 1835 { 1836 if (gx!=current_area->x || gy!=current_area->y) 1820 vec2i pos = the_game->MouseToGame(vec2i(last_demo_mx, last_demo_my)); 1821 if (pos.x<current_area->x+current_area->w && pos.y<current_area->y+current_area->h) 1822 { 1823 if (pos.x!=current_area->x || pos.y!=current_area->y) 1837 1824 { 1838 1825 the_game->need_refresh(); 1839 current_area->x= gx;1840 current_area->y= gy;1826 current_area->x=pos.x; 1827 current_area->y=pos.y; 1841 1828 } 1842 1829 } … … 1857 1844 if (ev.window==NULL) 1858 1845 { 1859 int32_t rx,ry; 1860 the_game->mouse_to_game(last_demo_mx,last_demo_my,rx,ry); 1846 vec2i pos = the_game->MouseToGame(vec2i(last_demo_mx, last_demo_my)); 1861 1847 1862 1848 if (!(dev & MAP_MODE)) 1863 1849 { 1864 1850 if (dev&DRAW_PEOPLE_LAYER) 1865 selected_object=current_level->find_object( rx,ry);1851 selected_object=current_level->find_object(pos.x, pos.y); 1866 1852 light_source *old_light=selected_light; 1867 if (selected_object) 1868 selected_light=NULL; 1869 else 1870 selected_light=find_light(rx,ry); 1853 selected_light = selected_object ? NULL : find_light(pos.x, pos.y); 1871 1854 if (selected_light!=old_light) 1872 1855 the_game->need_refresh(); … … 1875 1858 if (edit_mode==ID_DMODE_DRAW) 1876 1859 { 1860 // FIXME: there is a bug here, the two if conditionals are the same 1877 1861 if (ev.mouse_button==1 && !selected_object && !selected_light) 1878 1862 { 1879 int32_t xs,ys; 1880 the_game->ftile_on(last_demo_mx,last_demo_my,xs,ys); 1881 if (xs>=0 && ys>=0 && xs<current_level->foreground_width() && 1882 ys<current_level->foreground_height()) 1883 current_level->put_fg(xs,ys,raise_all ? make_above_tile(cur_fg) : cur_fg); 1863 vec2i tile = the_game->GetFgTile(vec2i(last_demo_mx, last_demo_my)); 1864 if (tile.x>=0 && tile.y>=0 && tile.x<current_level->foreground_width() && 1865 tile.y<current_level->foreground_height()) 1866 current_level->put_fg(tile.x,tile.y,raise_all ? make_above_tile(cur_fg) : cur_fg); 1884 1867 the_game->need_refresh(); 1885 1868 } else if (ev.mouse_button==1 && !selected_object && !selected_light) 1886 1869 { 1887 int32_t xs,ys; 1888 the_game->btile_on(last_demo_mx,last_demo_my,xs,ys); 1889 if (xs>=0 && ys>=0 && xs<current_level->background_width() && 1890 ys<current_level->background_height()) 1891 current_level->put_bg(xs,ys,cur_fg); 1870 vec2i tile = the_game->GetBgTile(vec2i(last_demo_mx, last_demo_my)); 1871 if (tile.x>=0 && tile.y>=0 && tile.x<current_level->background_width() && 1872 tile.y<current_level->background_height()) 1873 current_level->put_bg(tile.x,tile.y,cur_fg); 1892 1874 the_game->need_refresh(); 1893 1875 } … … 1971 1953 if ((dev & DRAW_FG_LAYER) && ev.mouse_button==1) 1972 1954 { 1973 the_game->ftile_on(last_demo_mx,last_demo_my,x,y);1974 if ( x>=0 && y>=0 &&x<current_level->foreground_width() &&1975 y<current_level->foreground_height())1976 the_game->put_fg( x,y,raise_all ? make_above_tile(cur_fg) : cur_fg);1955 vec2i tile = the_game->GetFgTile(vec2i(last_demo_mx, last_demo_my)); 1956 if (tile.x>=0 && tile.y>=0 && tile.x<current_level->foreground_width() && 1957 tile.y<current_level->foreground_height()) 1958 the_game->put_fg(tile.x,tile.y,raise_all ? make_above_tile(cur_fg) : cur_fg); 1977 1959 } 1978 1960 if ((dev & DRAW_BG_LAYER) && ev.mouse_button==2) 1979 1961 { 1980 the_game->btile_on(last_demo_mx,last_demo_my,x,y);1981 if ( x>=0 && y>=0 &&x<current_level->background_width() &&1982 y<current_level->background_height())1983 the_game->put_bg( x,y,cur_bg);1962 vec2i tile = the_game->GetBgTile(vec2i(last_demo_mx, last_demo_my)); 1963 if (tile.x>=0 && tile.y>=0 && tile.x<current_level->background_width() && 1964 tile.y<current_level->background_height()) 1965 the_game->put_bg(tile.x,tile.y,cur_bg); 1984 1966 } 1985 1967 } … … 2503 2485 case DEV_LIGHT9 : 2504 2486 { 2505 int32_t lx,ly; 2506 the_game->mouse_to_game(last_demo_mx,last_demo_my,lx,ly); 2507 lx=snap_x(lx); 2508 ly=snap_y(ly); 2509 edit_light=add_light_source(ev.message.id-DEV_LIGHT0,lx,ly, 2510 atoi(lightw->read(DEV_LIGHTR1)), 2511 atoi(lightw->read(DEV_LIGHTR2)), 2512 atoi(lightw->read(DEV_LIGHTW)), 2513 atoi(lightw->read(DEV_LIGHTH))); 2487 vec2i pos = the_game->MouseToGame(vec2i(last_demo_mx, last_demo_my)); 2488 edit_light = add_light_source(ev.message.id - DEV_LIGHT0, 2489 snap_x(pos.x), snap_y(pos.y), 2490 atoi(lightw->read(DEV_LIGHTR1)), 2491 atoi(lightw->read(DEV_LIGHTR2)), 2492 atoi(lightw->read(DEV_LIGHTW)), 2493 atoi(lightw->read(DEV_LIGHTH))); 2514 2494 state=DEV_MOVE_LIGHT; 2515 2495 } break; … … 2752 2732 if (ev.window==NULL || ev.window==forew) 2753 2733 { 2754 the_game->ftile_on(last_demo_mx,last_demo_my,x,y);2755 fg_fill(cur_fg, x,y,NULL);2734 vec2i tile = the_game->GetFgTile(vec2i(last_demo_mx, last_demo_my)); 2735 fg_fill(cur_fg, tile.x, tile.y, NULL); 2756 2736 } 2757 2737 } break; … … 2838 2818 case 'w' : 2839 2819 { 2840 int32_t rx,ry; 2841 the_game->mouse_to_game(dlastx,dlasty,rx,ry); 2842 char msg[100]; sprintf(msg,symbol_str("mouse_at"),rx,ry); 2820 vec2i pos = the_game->MouseToGame(vec2i(dlastx, dlasty)); 2821 char msg[100]; sprintf(msg, symbol_str("mouse_at"), pos.x, pos.y); 2843 2822 the_game->show_help(msg); 2844 2823 the_game->need_refresh(); … … 2860 2839 if (current_level && player_list && player_list->focus) 2861 2840 { 2862 int32_t rx,ry; 2863 the_game->mouse_to_game(dlastx,dlasty,rx,ry); 2864 player_list->focus->x=rx; 2865 player_list->focus->y=ry; 2841 vec2i pos = the_game->MouseToGame(vec2i(dlastx, dlasty)); 2842 player_list->focus->x = pos.x; 2843 player_list->focus->y = pos.y; 2866 2844 do_command("center",ev); 2867 2845 the_game->need_refresh(); … … 2870 2848 case 'z' : do_command("clear_weapons",ev); break; 2871 2849 case 'Z' : if (dev&EDIT_MODE) 2872 { view *v =the_game->view_in(last_demo_mx,last_demo_my);2850 { view *v = the_game->GetView(vec2i(last_demo_mx, last_demo_my)); 2873 2851 if (v) 2874 2852 { … … 3124 3102 case ' ' : 3125 3103 { 3126 int32_t x s,ys,xx,yy;3127 the_game->ftile_on(me->x,me->y,xs,ys);3128 3129 for (xx= xs; xx<xs+w; xx++)3104 int32_t xx, yy; 3105 vec2i tile = the_game->GetFgTile(vec2i(me->x, me->y)); 3106 3107 for (xx=tile.x; xx<tile.x+w; xx++) 3130 3108 { 3131 for (yy= ys; yy<ys+h; yy++)3109 for (yy=tile.y; yy<tile.y+h; yy++) 3132 3110 { 3133 3111 if (xx>=0 && yy>=0 && xx<current_level->foreground_width() && 3134 3112 yy<current_level->foreground_height()) 3135 the_game->put_fg(xx,yy,raise_all ? make_above_tile(pat[xx- xs+(yy-ys)*w]) : pat[xx-xs+(yy-ys)*w] );3113 the_game->put_fg(xx,yy,raise_all ? make_above_tile(pat[xx-tile.x+(yy-tile.y)*w]) : pat[xx-tile.x+(yy-tile.y)*w] ); 3136 3114 } 3137 3115 } … … 3139 3117 case 't' : 3140 3118 { 3141 int32_t xs,ys; 3142 the_game->ftile_on(me->x,me->y,xs,ys); 3143 dev_cont->fg_fill(-1,xs,ys,this); 3119 vec2i tile = the_game->GetFgTile(vec2i(me->x, me->y)); 3120 dev_cont->fg_fill(-1, tile.x, tile.y, this); 3144 3121 } break; 3145 3122 -
abuse/trunk/src/game.cpp
r656 r657 260 260 } 261 261 262 view *Game:: view_in(int mousex, int mousey)262 view *Game::GetView(vec2i pos) 263 263 { 264 264 for(view *f = first_view; f; f = f->next) 265 if(f->drawable() && mousex >= f->cx1 && mousey >= f->cy1266 && mousex <= f->cx2 && mousey <= f->cy2)265 if(f->drawable() && pos.x >= f->cx1 && pos.y >= f->cy1 266 && pos.x <= f->cx2 && pos.y <= f->cy2) 267 267 return f; 268 268 return NULL; … … 274 274 } 275 275 276 void Game::ftile_on(int screenx, int screeny, int32_t &x, int32_t &y) 277 { 278 mouse_to_game(screenx, screeny, x, y); 279 x /= ftile_width(); 280 y /= ftile_height(); 281 } 282 283 void Game::btile_on(int screenx, int screeny, int32_t &x, int32_t &y) 284 { 285 view *f = view_in(screenx, screeny); 286 if(f) 287 { 288 x = ((int32_t)screenx - (int32_t)f->cx1 289 + f->xoff() * bg_xmul / bg_xdiv) / (int32_t)b_wid; 290 y = ((int32_t)screeny - (int32_t)f->cy1 291 + f->yoff() * bg_ymul / bg_ydiv) / (int32_t)b_hi; 292 } 276 vec2i Game::GetFgTile(vec2i pos) 277 { 278 return MouseToGame(pos) / vec2i(ftile_width(), ftile_height()); 279 } 280 281 vec2i Game::GetBgTile(vec2i pos) 282 { 283 view *f = GetView(pos); 284 if(!f) 285 return vec2i(-1, -1); 286 287 return vec2i((pos.x - f->cx1 + f->xoff() * bg_xmul / bg_xdiv) / b_wid, 288 (pos.y - f->cy1 + f->yoff() * bg_ymul / bg_ydiv) / b_hi); 289 } 290 291 vec2i Game::MouseToGame(vec2i pos, view *v) 292 { 293 if (!v) 294 v = GetView(pos); 295 if (!v) 296 v = player_list; // if not in a view use the first one 297 if (!v) 298 return vec2i(-1, -1); 299 300 if(dev & MAP_MODE) 301 return vec2i((pos.x - v->cx1) * ftile_width() 302 / AUTOTILE_WIDTH + map_xoff * ftile_width(), 303 (pos.y - v->cy1) * ftile_height() 304 / AUTOTILE_HEIGHT + map_yoff * ftile_height()); 305 306 return pos - vec2i(v->cx1 - v->xoff(), v->cy1 - v->yoff()); 307 } 308 309 vec2i Game::GameToMouse(vec2i pos, view *v) 310 { 311 if (!(dev & MAP_MODE)) 312 return pos + vec2i(v->cx1 - v->xoff(), v->cy1 - v->yoff()); 313 314 vec2i tmp; 315 316 if (dev & EDIT_MODE) 317 tmp = vec2i(map_xoff, map_yoff); 318 else if(v->focus) 319 tmp = vec2i(v->focus->x / ftile_width() 320 - (v->cx2 - v->cx1) / AUTOTILE_WIDTH / 2, 321 v->focus->y / ftile_height() 322 - (v->cy2 - v->cy1) / AUTOTILE_HEIGHT / 2); 293 323 else 294 { 295 x = -1; 296 y = -1; 297 } 298 } 299 300 void Game::mouse_to_game(int32_t x, int32_t y, 301 int32_t &gamex, int32_t &gamey, view *f) 302 { 303 if(!f) 304 f = view_in(x, y); 305 if(!f) 306 f = player_list; // if not in a view use the first one 307 308 if(f) 309 { 310 if(dev & MAP_MODE) 311 { 312 gamex = (x - (int32_t)f->cx1) * ftile_width() / AUTOTILE_WIDTH + map_xoff * ftile_width(); 313 gamey = (y - (int32_t)f->cy1) * ftile_height() / AUTOTILE_HEIGHT + map_yoff * ftile_height(); 314 } 315 else 316 { 317 gamex = x - (int32_t)f->cx1 + f->xoff(); 318 gamey = y - (int32_t)f->cy1 + f->yoff(); 319 } 320 } 321 } 322 323 void Game::game_to_mouse(int32_t gamex, int32_t gamey, view *which, 324 int32_t &x, int32_t &y) 325 { 326 if(!(dev & MAP_MODE)) 327 { 328 x = gamex - which->xoff() + which->cx1; 329 y = gamey - which->yoff() + which->cy1; 330 return; 331 } 332 333 int32_t x1, y1; 334 335 if(dev & EDIT_MODE) 336 { 337 x1 = map_xoff; 338 y1 = map_yoff; 339 } 340 else 341 { 342 if(which->focus) 343 { 344 x1 = which->focus->x / ftile_width() 345 - (which->cx2 - which->cx1) / AUTOTILE_WIDTH / 2; 346 y1 = which->focus->y / ftile_height() 347 - (which->cy2 - which->cy1) / AUTOTILE_HEIGHT / 2; 348 } 349 else 350 x1 = y1 = 0; 351 } 352 353 if(x1 < 0) 354 x1 = 0; 355 if(y1 < 0) 356 y1 = 0; 357 358 x = gamex * AUTOTILE_WIDTH / ftile_width() 359 - x1 * AUTOTILE_WIDTH + which->cx1; 360 if(x1 > 0) 361 x -= (which->focus->x * AUTOTILE_WIDTH / ftile_width()) 362 % AUTOTILE_WIDTH; 363 364 y = gamey * AUTOTILE_HEIGHT / ftile_height() 365 - y1 * AUTOTILE_HEIGHT + which->cy1; 366 if(y1 > 0) 367 y -= (which->focus->y * AUTOTILE_HEIGHT / ftile_height()) 368 % AUTOTILE_HEIGHT; 324 tmp = vec2i(0, 0); 325 326 tmp.x = Max(tmp.x, 0); 327 tmp.y = Max(tmp.y, 0); 328 329 vec2i ret(pos.x * AUTOTILE_WIDTH / ftile_width() 330 - tmp.x * AUTOTILE_WIDTH + v->cx1, 331 pos.y * AUTOTILE_HEIGHT / ftile_height() 332 - tmp.y * AUTOTILE_HEIGHT + v->cy1); 333 if (tmp.x > 0) 334 ret.x -= (v->focus->x * AUTOTILE_WIDTH / ftile_width()) 335 % AUTOTILE_WIDTH; 336 if(tmp.y > 0) 337 ret.y -= (v->focus->y * AUTOTILE_HEIGHT / ftile_height()) 338 % AUTOTILE_HEIGHT; 339 340 return ret; 369 341 } 370 342 -
abuse/trunk/src/game.h
r643 r657 63 63 class Game 64 64 { 65 public: 66 Game(int argc, char **argv); 67 ~Game(); 68 65 69 private: 66 70 JCFont *fnt; … … 89 93 int state,zoom; 90 94 91 Game(int argc, char **argv);92 ~Game();93 94 95 void step(); 95 96 void show_help(char const *st); … … 106 107 return cache.foret(foretiles[x]); } 107 108 108 void ftile_on(int screenx, int screeny, int32_t &x, int32_t &y);109 void btile_on(int screenx, int screeny, int32_t &x, int32_t &y);109 vec2i GetFgTile(vec2i pos); 110 vec2i GetBgTile(vec2i pos); 110 111 void toggle_delay(); 111 112 void set_delay(int on) { no_delay=!on; } 112 113 void pan(int xv, int yv); 113 114 114 void mouse_to_game(int32_t x, int32_t y, int32_t &gamex, int32_t &gamey, view *v=NULL);115 void game_to_mouse(int32_t gamex, int32_t gamey, view *which, int32_t &x, int32_t &y);116 view *view_in(int mousex, int mousey);115 vec2i MouseToGame(vec2i pos, view *v = NULL); 116 vec2i GameToMouse(vec2i pos, view *v); 117 view *GetView(vec2i pos); 117 118 118 119 int calc_speed(); -
abuse/trunk/src/level.cpp
r655 r657 785 785 void level::draw_areas(view *v) 786 786 { 787 int32_t sx1,sy1,sx2,sy2; 788 area_controller *a=area_list; 789 for (; a; a=a->next) 790 { 791 int c1,c2; 792 if (a->active) 793 { 794 c1=morph_sel_frame_color; 795 c2=wm->bright_color(); 796 } else 797 { 798 c2=morph_sel_frame_color; 799 c1=wm->bright_color(); 800 } 801 802 the_game->game_to_mouse(a->x,a->y,v,sx1,sy1); 803 the_game->game_to_mouse(a->x+a->w,a->y+a->h,v,sx2,sy2); 804 main_screen->Rectangle(vec2i(sx1, sy1), vec2i(sx2, sy2), c1); 805 main_screen->Bar(vec2i(sx1 - 1, sy1 - 1), vec2i(sx1 + 1, sy1 + 1), c2); 806 main_screen->Bar(vec2i(sx2 - 1, sy2 - 1), vec2i(sx2 + 1, sy2 + 1), c2); 807 } 787 for (area_controller *a = area_list; a; a = a->next) 788 { 789 int c1 = a->active ? morph_sel_frame_color : wm->bright_color(); 790 int c2 = a->active ? wm->bright_color() : morph_sel_frame_color; 791 792 vec2i pos1 = the_game->GameToMouse(vec2i(a->x, a->y), v); 793 vec2i pos2 = the_game->GameToMouse(vec2i(a->x + a->w, a->y + a->h), v); 794 main_screen->Rectangle(pos1, pos2, c1); 795 main_screen->Bar(pos1 - vec2i(1, 1), pos1 + vec2i(1, 1), c2); 796 main_screen->Bar(pos2 - vec2i(1, 1), pos2 + vec2i(1, 1), c2); 797 } 808 798 } 809 799 -
abuse/trunk/src/morpher.cpp
r643 r657 22 22 void morph_char::draw(game_object *who, view *v) 23 23 { 24 if (fleft)25 {26 int32_t rx,ry;27 the_game->game_to_mouse(who->x-(cx>>16),who->y-(cy>>16),v,rx,ry);28 mor->show(main_screen,rx,ry,color_table,pal,1000);29 cx+=dcx;30 cy+=dcy;31 fleft--;32 }24 if (fleft) 25 { 26 vec2i pos = the_game->GameToMouse(vec2i(who->x - (cx >> 16), 27 who->y - (cy >> 16)), v); 28 mor->show(main_screen, pos.x, pos.x, color_table, pal, 1000); 29 cx += dcx; 30 cy += dcy; 31 fleft--; 32 } 33 33 } 34 34 -
abuse/trunk/src/objects.cpp
r643 r657 378 378 void game_object::draw_above(view *v) 379 379 { 380 int32_t x1, y1,x2,y2,sy1,sy2,sx,i;380 int32_t x1, y1, x2, y2; 381 381 picture_space(x1,y1,x2,y2); 382 382 383 the_game->game_to_mouse(x1,y1,v,sx,sy2); 384 if (sy2>=v->cy1) 385 { 386 int32_t draw_to=y1-(sy2-v->cy1),tmp=x; 387 current_level->foreground_intersect(x,y1,tmp,draw_to); 388 the_game->game_to_mouse(x1,draw_to,v,i,sy1); // calculate sy1 389 390 sy1 = Max(v->cy1, sy1); 391 sy2 = Min(v->cy2, sy2); 392 TransImage *p=picture(); 393 394 for (i=sy1; i<=sy2; i++) 395 p->PutScanLine(main_screen,vec2i(sx,i),0); 383 vec2i pos1 = the_game->GameToMouse(vec2i(x1, y1), v); 384 if (pos1.y >= v->cy1) 385 { 386 int32_t draw_to = y1 - (pos1.y - v->cy1), tmp = x; 387 current_level->foreground_intersect(x, y1, tmp, draw_to); 388 // calculate pos2.y 389 vec2i pos2 = the_game->GameToMouse(vec2i(x1, draw_to), v); 390 391 pos2.y = Max(v->cy1, pos2.y); 392 pos1.y = Min(v->cy2, pos1.y); 393 TransImage *p = picture(); 394 395 for (int i = pos2.y; i <= pos1.y; i++) 396 p->PutScanLine(main_screen, vec2i(pos1.x, i), 0); 396 397 } 397 398 } -
abuse/trunk/src/view.cpp
r651 r657 341 341 { 342 342 int sug_x,sug_y,sug_b1,sug_b2,sug_b3,sug_b4; 343 int32_t sug_px,sug_py;343 vec2i sug_p(0, 0); 344 344 345 345 // NOTE:(AK) I have commented this out so we don't use the lisp … … 384 384 if( focus ) 385 385 { 386 the_game->mouse_to_game( last_demo_mx, last_demo_my, sug_px, sug_py, this);387 if( last_demo_mbut & 1)386 sug_p = the_game->MouseToGame(vec2i(last_demo_mx, last_demo_my)); 387 if(last_demo_mbut & 1) 388 388 sug_b2 = 1; 389 if( last_demo_mbut & 2)389 if(last_demo_mbut & 2) 390 390 sug_b1 = 1; 391 391 } 392 else393 sug_px = sug_py = 0;394 392 } 395 393 … … 439 437 mflags |= 128; 440 438 441 base->packet.write_uint8( mflags);442 base->packet.write_uint16((uint16_t) ((int16_t)sug_px));443 base->packet.write_uint16((uint16_t) ((int16_t)sug_py));439 base->packet.write_uint8(mflags); 440 base->packet.write_uint16((uint16_t)sug_p.x); 441 base->packet.write_uint16((uint16_t)sug_p.y); 444 442 } 445 443
Note: See TracChangeset
for help on using the changeset viewer.