WIP standardize mouse position translation
This commit is contained in:
@@ -77,6 +77,9 @@ extern std::string save_talk_str1, save_talk_str2;
|
||||
extern cDrawableManager drawable_mgr;
|
||||
extern void close_map(bool record = false);
|
||||
|
||||
extern location mouse_window_coords();
|
||||
extern bool mouse_to_terrain_coords(location& out_loc, bool relative);
|
||||
|
||||
rectangle menuBarRect;
|
||||
Region originalGrayRgn, newGrayRgn, underBarRgn;
|
||||
sf::View mainView;
|
||||
@@ -507,14 +510,12 @@ bool arrow_button_click(rectangle button_rect, cFramerateLimiter* fps_limiter) {
|
||||
while(pollEvent(mainPtr(), e)){
|
||||
if(e.type == sf::Event::MouseButtonReleased){
|
||||
done = true;
|
||||
location clickPos(e.mouseButton.x, e.mouseButton.y);
|
||||
clickPos = mainPtr().mapPixelToCoords(clickPos);
|
||||
location clickPos = mouse_window_coords();
|
||||
clicked = button_rect.contains(clickPos);
|
||||
depressed = false;
|
||||
break;
|
||||
} else if(e.type == sf::Event::MouseMoved){
|
||||
location toPos(e.mouseMove.x, e.mouseMove.y);
|
||||
toPos = mainPtr().mapPixelToCoords(toPos);
|
||||
location toPos = mouse_window_coords();
|
||||
depressed = button_rect.contains(toPos);
|
||||
}
|
||||
}
|
||||
@@ -608,7 +609,7 @@ void redraw_screen(int refresh) {
|
||||
draw_targets(center);
|
||||
if(overall_mode != MODE_STARTUP) {
|
||||
if(!is_out())
|
||||
draw_targeting_line(sf::Mouse::getPosition(mainPtr()));
|
||||
draw_targeting_line();
|
||||
refresh_stat_areas(0);
|
||||
}
|
||||
done_btn->draw();
|
||||
@@ -616,6 +617,8 @@ void redraw_screen(int refresh) {
|
||||
|
||||
drawable_mgr.draw_all();
|
||||
|
||||
extern location get_cur_direction();
|
||||
get_cur_direction();
|
||||
mainPtr().display();
|
||||
}
|
||||
|
||||
@@ -1648,26 +1651,20 @@ void erase_spot(short i,short j) {
|
||||
|
||||
}
|
||||
|
||||
void draw_targeting_line(location where_curs) {
|
||||
void draw_targeting_line() {
|
||||
location which_space,store_loc;
|
||||
rectangle target_rect;
|
||||
location from_loc;
|
||||
rectangle on_screen_terrain_area = win_to_rects[WINRECT_TERVIEW];
|
||||
on_screen_terrain_area.inset(13, 13);
|
||||
|
||||
where_curs = mainPtr().mapPixelToCoords(where_curs, mainView);
|
||||
|
||||
location where_curs = mouse_window_coords();
|
||||
|
||||
if(overall_mode >= MODE_COMBAT)
|
||||
from_loc = univ.current_pc().combat_pos;
|
||||
else from_loc = univ.party.town_loc;
|
||||
if((overall_mode == MODE_SPELL_TARGET) || (overall_mode == MODE_FIRING) || (overall_mode == MODE_THROWING) || (overall_mode == MODE_FANCY_TARGET)
|
||||
|| ((overall_mode == MODE_TOWN_TARGET) && (current_pat[4][4] != 0))) {
|
||||
|
||||
if(where_curs.in(on_screen_terrain_area)) {
|
||||
// && (point_onscreen(center,univ.party[current_pc].combat_pos))){
|
||||
which_space.x = center.x + (where_curs.x - 37) / 28 - 4;
|
||||
which_space.y = center.y + (where_curs.y - 25) / 36 - 4;
|
||||
|
||||
if(mouse_to_terrain_coords(which_space, false)) {
|
||||
int xBound = (short) (from_loc.x - center.x + 4);
|
||||
int yBound = (short) (from_loc.y - center.y + 4);
|
||||
xBound = (xBound * 28) + 46;
|
||||
|
Reference in New Issue
Block a user