aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorribet2007-10-15 08:11:48 +0000
committerribet2007-10-15 08:11:48 +0000
commit1daf0b8f47f6e8cb9acb3cb4c5f872767dee8402 (patch)
tree12e8c54ff4c685745e19b6e19736f500a89b061e /src
parentd8c4819220762f3f63780756353df537c215b06d (diff)
downloadmtc-1daf0b8f47f6e8cb9acb3cb4c5f872767dee8402.zip
mtc-1daf0b8f47f6e8cb9acb3cb4c5f872767dee8402.tar.gz
mtc-1daf0b8f47f6e8cb9acb3cb4c5f872767dee8402.tar.bz2
mtc-1daf0b8f47f6e8cb9acb3cb4c5f872767dee8402.tar.xz
Pour les rigolos qui font de l'antirecouvrement d'objets invisibles.
Diffstat (limited to 'src')
-rw-r--r--src/MTools/Comp/MAntiRecouvrementItem.pm12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/MTools/Comp/MAntiRecouvrementItem.pm b/src/MTools/Comp/MAntiRecouvrementItem.pm
index 625cefc..fa1509a 100644
--- a/src/MTools/Comp/MAntiRecouvrementItem.pm
+++ b/src/MTools/Comp/MAntiRecouvrementItem.pm
@@ -85,7 +85,7 @@ sub translate {
my ($self, $delta_x, $delta_y) = @_;
if ($self -> {__added})
{
- if ((abs ($delta_x) >= $self -> mget ('width') / 2) or (abs ($delta_y) >= $self -> mget ('height') / 2))
+ if ((abs ($delta_x) >= __max_of(2, $self -> mget ('width') / 2)) or (abs ($delta_y) >= __max_of(2, $self -> mget ('height') / 2)))
{
my ($mini_dx, $mini_dy) = (int ($delta_x / 2), int ($delta_y / 2));
$self -> translate ($mini_dx, $mini_dy);
@@ -164,6 +164,16 @@ sub __update_xy {
$self -> notify ('TRANSLATED', $delta_x, $delta_y);
}
+sub __max_of {
+ my (@values) = @_;
+ my $res = $values [0];
+ foreach (@values)
+ {
+ $res = $_ if ($_ >= $res);
+ }
+ return $res;
+}
+
sub scale {
my ($self, @params) = @_;
MTools::scale ($self, @params);