Skip to content

Commit

Permalink
Fix: Update BBText hitboxes when text changes (#6385)
Browse files Browse the repository at this point in the history
- Also: Deprecate current font family setting action that uses a string as input and create a new action that uses a selector instead.
  • Loading branch information
AlexandreSi authored Feb 27, 2024
1 parent e345b27 commit 6945409
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
18 changes: 18 additions & 0 deletions Extensions/BBText/JsExtension.js
Original file line number Diff line number Diff line change
Expand Up @@ -436,13 +436,31 @@ module.exports = {

addSettersAndGettersToObject(object, setterAndGetterProperties, 'BBText');

object
.addAction(
`SetFontFamily2`,
_('Font family'),
_('Set font family'),
_('Set the font of _PARAM0_ to _PARAM1_'),
'',
'res/actions/font24.png',
'res/actions/font24.png'
)
.addParameter('object', 'BBText', 'BBText', false)
.addParameter('fontResource', _('Font family'), '', false)
.getCodeExtraInformation()
.setFunctionName(`setFontFamily`);

const actions = object.getAllActions();
const conditions = object.getAllConditions();
const expressions = object.getAllExpressions();

actions.get('BBText::SetOpacity').setHidden();
conditions.get('BBText::IsOpacity').setHidden();
expressions.get('GetOpacity').setHidden();
// Action deprecated because it's using the `string` type instead of the more
// user-friendly `fontResource` type.
actions.get('BBText::SetFontFamily').setHidden();

return extension;
},
Expand Down
1 change: 1 addition & 0 deletions Extensions/BBText/bbtextruntimeobject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ namespace gdjs {
setBBText(text): void {
this._text = text;
this._renderer.updateText();
this.invalidateHitboxes();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Extensions/TextInput/JsExtension.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ module.exports = {
'res/actions/font24.png',
'res/actions/font.png'
)
.addParameter('object', _('Bitmap text'), 'TextInputObject', false)
.addParameter('object', _('Text input'), 'TextInputObject', false)
.addParameter('fontResource', _('Font resource name'), '', false)
.getCodeExtraInformation()
.setFunctionName('setFontResourceName');
Expand Down

0 comments on commit 6945409

Please sign in to comment.