Skip to content

Commit

Permalink
[#1203] fix an exception when destroying a UITextButton
Browse files Browse the repository at this point in the history
- UITextButton `backgroundColor` and `hoverColor` properties are now deprecated in favor of `hoverOffColor` and `hoverOnColor`
- bump version to 15.13 due to API changes
  • Loading branch information
obiot committed Oct 7, 2023
1 parent 3793ec7 commit caef3bb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# Changelog

## [15.12.1] (melonJS 2) - _2023-09-xx_
## [15.13.0] (melonJS 2) - _2023-09-xx_

### Changed
- UI: UITextButton `backgroundColor` and `hoverColor` properties are now deprecated in favor of `hoverOffColor` and `hoverOnColor`

### Fixed
UI - fix duplicated text rendering in UITextButton
- UI: fix duplicated text rendering in UITextButton
- UI: fix an exception when destroying a UITextButton

## [15.12.0] (melonJS 2) - _2023-09-23_

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "melonjs",
"version": "15.12.1",
"version": "15.13.0",
"description": "melonJS Game Engine",
"homepage": "http://www.melonjs.org/",
"type": "module",
Expand Down
16 changes: 9 additions & 7 deletions src/renderable/ui/uitextbutton.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export default class UITextButton extends UIBaseElement {
* @param {number} [settings.size=1] - The scale factor of the BitmapText
* @param {string} [settings.text] - The text to display
* @param {string} [settings.bindKey] - The key to bind the action to (default: none)
* @param {string} [settings.backgroundColor="#00aa0080"] - The css value of a background color
* @param {string} [settings.hoverColor="#00ff00ff"] - The css value of a color to be used if the pointer hovers over the button
* @param {string} [settings.hoverOffColor="#00aa0080"] - The css value of a color to be used if the pointer is not hovering over the button
* @param {string} [settings.hoverOnColor="#00ff00ff"] - The css value of a color to be used if the pointer hovers over the button
* @param {string} [settings.borderStrokeColor="#000000"] - The css value of a color to be used to draw the border
* @param {string} [settings.fillStyle] - The css value of a tint color to be used to tint the BitmapText
* @param {string} [settings.textAlign="center"] - horizontal text alignment
Expand Down Expand Up @@ -60,16 +60,18 @@ export default class UITextButton extends UIBaseElement {
this.bindKey = settings.bindKey || -1;

/**
* The css value of a background color
* The css value of a color to be used if the pointer is nothovering over the button
* @type {string}
*/
this.backgroundColor = settings.backgroundColor || "#00aa0080";
// keep settings.backgroundColor for backward compatibility
this.hoverOffColor = settings.hoverOffColor || settings.backgroundColor || "#00aa0080";

/**
* The css value of a color to be used if the pointer hovers over the button
* @type {string}
*/
this.hoverColor = settings.hoverColor || "#00ff00ff";
// keep settings.hoverColor for backward compatibility
this.hoverOnColor = settings.hoverOnColor || settings.hoverColor || "#00ff00ff";

/**
* The css value of a color to be used to draw the border
Expand Down Expand Up @@ -124,9 +126,9 @@ export default class UITextButton extends UIBaseElement {

draw(renderer) {
if (this.hover === true) {
renderer.setColor(this.hoverColor);
renderer.setColor(this.hoverOnColor);
} else {
renderer.setColor(this.backgroundColor);
renderer.setColor(this.hoverOffColor);
}
renderer.fill(this.border);
renderer.setColor(this.borderStrokeColor);
Expand Down

0 comments on commit caef3bb

Please sign in to comment.