new progress bar function

This commit is contained in:
lopar 2018-12-28 01:13:46 +02:00
parent e2b1cf63bc
commit 9ce5aac842

View File

@ -702,18 +702,18 @@ function setHP($hp, $maxhp)
/** /**
* @param $hp * @param $current
* @param $maxhp * @param $maximum
*/ */
function setHP2($hp, $maxhp) function showProgressBar($current, $maximum, $line_color = 'limegreen', $bg_color = 'silver')
{ {
$bar = round($hp / $maxhp * 100); $bar = round($current / $maximum * 100);
$output = <<<HTML $output = <<<HTML
<div style="width: 100%; height: 16px; background: silver; overflow: hidden; border-radius: 3px;"> <div style="width: 100%; height: 16px; background: $bg_color; overflow: hidden; border-radius: 3px;">
<div style="height: 16px; background: limegreen; border-radius: 3px; width: $bar%;"></div> <div style="height: 16px; background: $line_color; border-radius: 3px; width: $bar%;"></div>
</div> </div>
<div style="width: 100%; height: 16px; font-size: 14px; text-align: center; margin-top: -16px;"> <div style="width: 100%; height: 16px; font-size: 14px; text-align: center; margin-top: -16px;">
$hp / $maxhp $current / $maximum
</div> </div>
HTML; HTML;
return $output; return $output;
@ -953,7 +953,7 @@ HTML;
if (!empty($user['klan'])) $r .= "<img src='/i/klan/" . ClanImage($user['klan']) . ".gif' > "; if (!empty($user['klan'])) $r .= "<img src='/i/klan/" . ClanImage($user['klan']) . ".gif' > ";
$r .= '</div>'; $r .= '</div>';
$r .= setHP2($user['hp'], $user['maxhp']); $r .= showProgressBar($user['hp'], $user['maxhp']);
$r .= "<table style='width: 100%; text-align: center;'>"; $r .= "<table style='width: 100%; text-align: center;'>";
$r .= '<tr><td width=62 valign=top><table width=100%><tr><td>'; $r .= '<tr><td width=62 valign=top><table width=100%><tr><td>';