Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
louiz’
batajelo
Commits
bf67ecf6
Commit
bf67ecf6
authored
Aug 21, 2015
by
louiz’
Browse files
Only select one entity on left click without doing a rectangular selection
parent
d6d87dcd
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/gui/camera/camera.cpp
View file @
bf67ecf6
...
...
@@ -157,7 +157,7 @@ void Camera::handle_right_click(const sf::Event& event)
if
(
ids
.
empty
())
return
;
const
Entity
*
entity_under_mouse
=
this
->
get_entity_under_mouse
();
if
(
entity_under_mouse
)
if
(
entity_under_mouse
&&
std
::
find
(
ids
.
begin
(),
ids
.
end
(),
entity_under_mouse
->
get_id
())
==
ids
.
end
()
)
this
->
game
->
action_follow
(
ids
,
entity_under_mouse
->
get_id
(),
queue
);
else
this
->
game
->
action_move
(
ids
,
pos
,
queue
);
...
...
@@ -200,7 +200,9 @@ void Camera::set_mouse_selection_to_selection()
// Only the manipulable entities are considered
std
::
vector
<
const
Entity
*>
entities_in_mouse_selection
;
for
(
const
auto
&
entity
:
this
->
world
().
entities
)
const
auto
sorted_entities
=
this
->
world
().
sorted_entities
();
for
(
const
auto
&
entity
:
sorted_entities
)
{
Location
*
location
=
entity
->
get
<
Location
>
();
Team
*
team
=
entity
->
get
<
Team
>
();
...
...
@@ -208,7 +210,13 @@ void Camera::set_mouse_selection_to_selection()
continue
;
if
(
this
->
mouse_selection
.
contains
(
mouse_pos
,
this
->
world_to_camera_position
(
location
->
position
())))
entities_in_mouse_selection
.
push_back
(
entity
.
get
());
{
entities_in_mouse_selection
.
push_back
(
entity
);
if
(
!
this
->
mouse_selection
.
is_rectangular_selection_ongoing
(
mouse_pos
))
// Only select one entity, because we are not doing a
// rectangular selection.
break
;
}
}
if
(
entities_in_mouse_selection
.
empty
())
...
...
src/gui/camera/mouse_selection.cpp
View file @
bf67ecf6
#include
<gui/camera/mouse_selection.hpp>
#include
<utils/math.hpp>
MouseSelection
::
MouseSelection
()
:
ongoing
(
false
)
...
...
@@ -19,7 +21,7 @@ void MouseSelection::end()
bool
MouseSelection
::
is_rectangular_selection_ongoing
(
const
sf
::
Vector2i
&
mouse_pos
)
const
{
return
this
->
ongoing
&&
this
->
start_pos
!=
mouse_pos
;
return
this
->
ongoing
&&
(
vect_distance
(
this
->
start_pos
,
mouse_pos
)
>
5
)
;
}
bool
MouseSelection
::
contains
(
const
sf
::
Vector2i
&
mouse_pos
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment