Skip to content

Commit 9628185

Browse files
committed
Compat: Improve status module formatting
Always display percentages with two decimal places
1 parent 6f1185a commit 9628185

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

classes/class.Compat.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,7 @@ public static function printStatusModule() : void
627627
foreach ($a_status as $id => $status)
628628
{
629629
$percentage = round(($game_scount["nostatus"][$id]/$game_scount["nostatus"][0]) * 100, 2, PHP_ROUND_HALF_UP);
630+
$percentage = sprintf("%.2f", $percentage);
630631

631632
// Initialise current status parent div
632633
$html_div_main = new HTMLDiv("compat-status-main");
@@ -637,8 +638,10 @@ public static function printStatusModule() : void
637638

638639
// Status, percentage, description
639640
$html_div_text = new HTMLDiv("compat-status-text");
640-
$html_div_text->add_content("<p style='color:#{$status['color']}'><strong>{$status['name']}");
641-
$html_div_text->add_content(" ({$percentage}%):</strong></p>&nbsp;&nbsp;{$status['desc']}");
641+
$html_div_text->add_content("<span style='color:#{$status['color']}'>");
642+
$html_div_text->add_content("<strong>{$status['name']} ({$percentage}%): </strong>");
643+
$html_div_text->add_content("</span>");
644+
$html_div_text->add_content($status['desc']);
642645
$html_div_main->add_content($html_div_text->to_string());
643646

644647
// Progress bar

classes/class.History.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,10 @@ public static function printStatusModule() : void
347347

348348
// Status, description
349349
$html_div_text = new HTMLDiv("compat-status-text");
350-
$html_div_text->add_content("<p style='color:#{$status['color']}'><strong>{$status['name']}:</strong></p>&nbsp;&nbsp;{$status['desc']}");
350+
$html_div_text->add_content("<span style='color:#{$status['color']}'>");
351+
$html_div_text->add_content("<strong>{$status['name']}: </strong>");
352+
$html_div_text->add_content("</span>");
353+
$html_div_text->add_content($status['desc']);
351354
$html_div_main->add_content($html_div_text->to_string());
352355

353356
// Add current status parent div to the root div

0 commit comments

Comments
 (0)