Example #1
0
int BEE::convert_window_coords(int& x, int& y) {
	if (get_current_room()->get_is_views_enabled()) {
		x -= get_current_room()->get_current_view()->view_x;
		y -= get_current_room()->get_current_view()->view_y;
	}
	return 0;
}
Example #2
0
/*
* BEE::get_mouse_position() - Return the mouse coordinates relative to the viewport
*/
std::pair<int,int> BEE::get_mouse_position() const {
	int mx, my;
	std::tie(mx, my) = get_mouse_global_position(); // Fetch the global coordinates into (mx, my)

	if (!get_current_room()->get_is_views_enabled()) { // If views are disabled, simply return the coordinates relative to the window
		return std::make_pair(mx, my); // Return the pair on success
	}

	ViewData* v = get_current_room()->get_current_view(); // Get the current view
	if ((v == nullptr)&&(get_current_room()->get_views().size() > 0)) { // If this function is called outside of view drawing then simply use the first view
		v = get_current_room()->get_views().begin()->second;
	}

	if (v != nullptr) { // If the view exists then adjust the coordinates
		mx -= v->port_x;
		my -= v->port_y;
	}

	return std::make_pair(mx, my); // Return the pair on success
}
Example #3
0
std::pair<int,int> BEE::get_mouse_position() {
	if (!get_current_room()->get_is_views_enabled()) {
		return get_mouse_global_position();
	}

	int mx, my;
	std::tie(mx, my) = get_mouse_global_position();
	ViewData* v = get_current_room()->get_current_view();

	if ((v == NULL)&&(get_current_room()->get_views().size() > 0)) {
		v = get_current_room()->get_views().begin()->second;
	}

	if (v != NULL) {
		mx -= v->port_x;
		my -= v->port_y;
	}

	return std::make_pair(mx, my);
}