Add reset button rendering and refine highlighted button logic in machine_1

- Introduce `drawHighlightedResetButton` method for dynamically rendering the reset button with text overlay.
- Add `IMAGE_BUTTON_HIGHLIGHTED_BLUE` constant and update asset usage for reset button rendering.
- Refine highlighted button positioning with per-row spacing adjustments and configurable highlight states.
- Add `getNextButtonStepCount` method for tracking button steps during rendering.
This commit is contained in:
Jeppe Bundgaard
2026-01-28 15:56:50 +01:00
parent 3fcccd8e5a
commit f158fa7120
4 changed files with 59 additions and 3 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 456 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 324 KiB

After

Width:  |  Height:  |  Size: 256 KiB

@@ -56,5 +56,4 @@ class dynamicimages_asset implements dynamicimages_asset_i
{
return $this->height;
}
}
@@ -12,14 +12,26 @@ class machine_1 extends dynamicimages_image
const IMAGE_PANEL_BACKGROUND = 'machine_1_panel_background.png';
const IMAGE_WASH_PROGRAMS_THUMB = 'machine_1_wash_programs_thumb_standalone_transparent.png';
const IMAGE_WASH_PROGRAMS = 'machine_1_programs_wheel_transparent.png';
const IMAGE_BUTTON_HIGHLIGHTED = 'machine_1_button_highlighted_transparent.png';
const IMAGE_BUTTON_HIGHLIGHTED = 'machine_1_button_highlighted_blue.png'; // 'machine_1_button_highlighted_transparent.png';
const IMAGE_BUTTON_HIGHLIGHTED_BLUE = 'machine_1_button_highlighted_blue.png';
// Thumb
public int $thumb_position = 9; // 0-11 (default: 0 = up = 270 degrees)
public int $thumb_size = 1550; // height and width of the thumb
// Buttons
public int $button_highlight_size = 295; // size of the highlighted button
public int $button_rows = 4; // Number of rows (on top of each other)
public int $button_rows_spacing = 100; // Spacing between rows of buttons
public int $button_rows_spacing = 179; // Spacing between rows of buttons
public int $button_last_row_spacing_buffer = -23; // Extra spacing buffer for the last row (The last row has a smaller distance)
public int $button_columns = 3; // Number of columns (side by side)
public int $button_columns_spacing = 442; // Spacing between columns of buttons
public array $highlighted_buttons = [
// Array of button positions to highlight (0 indexed, left to right, top to bottom)
0, 2, 4, 7
];
// Reset button
public int $reset_button_highlight_size = 380; // size of the highlighted reset button
// Button counts
public int $button_counter = 0; // Is incremented every time a button is drawn
/**
* @throws \Exception
@@ -33,6 +45,7 @@ class machine_1 extends dynamicimages_image
new dynamicimages_asset(self::getAssetPath(self::IMAGE_WASH_PROGRAMS_THUMB)),
new dynamicimages_asset(self::getAssetPath(self::IMAGE_WASH_PROGRAMS)),
new dynamicimages_asset(self::getAssetPath(self::IMAGE_BUTTON_HIGHLIGHTED)),
new dynamicimages_asset(self::getAssetPath(self::IMAGE_BUTTON_HIGHLIGHTED_BLUE)),
]);
}
@@ -47,9 +60,35 @@ class machine_1 extends dynamicimages_image
$this->drawProgramWheel();
$this->drawThumb();
$this->drawHighlightedButtons();
$this->drawHighlightedResetButton();
//$this->drawAsset($this->getAsset(self::IMAGE_POWER_BUTTON), 0, 0);
}
/**
* @throws \Exception
*/
public function drawHighlightedResetButton(): void
{
$x = 1736; // X position for the reset button
$y = 599; // Y position for the reset button
$tmp = new dynamicimages_asset($this->getAssetPath(self::IMAGE_BUTTON_HIGHLIGHTED_BLUE));
$tmp->resize($this->reset_button_highlight_size, $this->reset_button_highlight_size);
$tmp->addTextOverlay('R', [
'font_size' => 180,
'font_color' => '#FFFFFF',
'font_path' => $this->getFontPath('OpenSans-Bold.ttf'),
'x_offset' => 0,
'y_offset' => 20,
'align' => 'center',
'valign' => 'center',
]);
$this->drawAsset($tmp, $x, $y);
// Free memory used by temporary asset image, if any
if (method_exists($tmp, 'clearMemoryImage')) {
$tmp->clearMemoryImage();
}
}
/**
* @throws \Exception
*/
@@ -60,8 +99,18 @@ class machine_1 extends dynamicimages_image
for ($row = 0; $row < $this->button_rows; $row++) {
for ($col = 0; $col < $this->button_columns; $col++) {
// If the current button position is not in the highlighted buttons array, skip it
$buttonIndex = $row * $this->button_columns + $col;
if (!in_array($buttonIndex, $this->highlighted_buttons, true)) {
continue;
}
// Calculate the position for the current button
$x = $startX + ($col * ($this->button_highlight_size + $this->button_columns_spacing));
$y = $startY + ($row * ($this->button_highlight_size + $this->button_rows_spacing));
// Last row adjustment
if ($row === $this->button_rows - 1) {
$y += $this->button_last_row_spacing_buffer;
}
$tmp = new dynamicimages_asset($this->getAssetPath(self::IMAGE_BUTTON_HIGHLIGHTED));
$tmp->resize($this->button_highlight_size, $this->button_highlight_size);
$this->drawAsset($tmp, $x, $y);
@@ -73,6 +122,14 @@ class machine_1 extends dynamicimages_image
}
}
/**
* @return int
*/
public function getNextButtonStepCount(): int
{
return $this->button_counter++;
}
/**
* @throws \Exception
*/