sub
new {
my
(
$pkg
,
$Dimensions
,
$Material
,
$Value
,
$length
,
$parent
) =
@_
;
my
$self
=
bless
{
'x'
=>
$Dimensions
->[0],
'y'
=>
$Dimensions
->[1],
'w'
=>
$Dimensions
->[2],
'h'
=>
$Dimensions
->[3],
mO
=>
undef
,
mCP
=>
undef
,
mmn
=>
$Material
,
mma
=>
$Material
,
value
=>
''
,
length
=> 0,
},
$pkg
;
my
$ma
= Ogre::MaterialManager->getSingletonPtr->getByName(
$self
->{mmn} .
".active"
);
$self
->{mma} .=
".active"
if
defined
$ma
;
$self
->{mO} =
$parent
->{mGUI}->createOverlay(
$parent
->{mO}->getName .
"t"
.
$parent
->{mGUI}{tc},
[
$self
->{
'x'
},
$self
->{
'y'
}],
[
$self
->{
'w'
},
$self
->{
'h'
}],
$Material
,
''
, 0);
$parent
->{mGUI}{tc}++;
$self
->{mCP} =
$parent
->{mGUI}->createOverlay(
$self
->{mO}->getName .
"c"
,
[4, (
$self
->{
'h'
} -
$parent
->{mGUI}{mFontSize} / 2)],
[
$self
->{
'w'
},
$self
->{
'h'
}],
''
,
$Value
, 0);
$parent
->{mO}->addChild(
$self
->{mO});
$self
->{mO}->show();
$self
->{mO}->addChild(
$self
->{mCP});
$self
->{mCP}->show();
return
$self
;
}
sub
getValue {
$_
[0]->{value} }
sub
setValue {
my
(
$self
,
$v
) =
@_
;
$self
->{value} =
$v
;
$self
->{mCP}->setCaption(
$v
);
}
sub
in {
my
(
$self
,
$mx
,
$my
,
$px
,
$py
) =
@_
;
return
!(
$mx
>=
$self
->{
'x'
} +
$px
&&
$my
>=
$self
->{
'y'
} +
$py
)
|| !(
$mx
<=
$self
->{
'x'
} +
$px
+
$self
->{
'w'
} &&
$my
<=
$self
->{
'y'
} +
$py
+
$self
->{
'h'
});
}
1;