Skip to content

Commit

Permalink
Use parameter options in Javascript use of standard operators use fun…
Browse files Browse the repository at this point in the history
…ctions
  • Loading branch information
AlexandreSi committed Dec 19, 2022
1 parent ca88959 commit 0de933d
Show file tree
Hide file tree
Showing 8 changed files with 559 additions and 187 deletions.
39 changes: 28 additions & 11 deletions Extensions/BBText/JsExtension.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,23 +216,28 @@ module.exports = {
gdObject
.addAction(
`Set${property.functionName}`,
property.paramLabel,
property.instructionLabel,
property.actionDescription,
property.actionSentence,
'',
property.iconPath,
property.iconPath
)
.addParameter('object', objectName, objectName, false)
.useStandardOperatorParameters(parameterType)
.useStandardOperatorParameters(
parameterType,
gd.ParameterOptions.makeNewOptions().setDescription(
property.paramLabel
)
)
.getCodeExtraInformation()
.setFunctionName(`set${property.functionName}`)
.setGetter(`get${property.functionName}`);
} else {
gdObject
.addAction(
`Set${property.functionName}`,
property.paramLabel,
property.instructionLabel,
property.actionDescription,
property.actionSentence,
'',
Expand Down Expand Up @@ -260,22 +265,27 @@ module.exports = {
gdObject
.addCondition(
`Is${property.functionName}`,
property.paramLabel,
property.instructionLabel,
property.conditionDescription,
property.conditionSentence,
'',
property.iconPath,
property.iconPath
)
.addParameter('object', objectName, objectName, false)
.useStandardRelationalOperatorParameters(parameterType)
.useStandardRelationalOperatorParameters(
parameterType,
gd.ParameterOptions.makeNewOptions().setDescription(
property.paramLabel
)
)
.getCodeExtraInformation()
.setFunctionName(`get${property.functionName}`);
} else if (parameterType === 'yesorno') {
gdObject
.addCondition(
`Is${property.functionName}`,
property.paramLabel,
property.instructionLabel,
property.conditionDescription,
property.conditionSentence,
'',
Expand All @@ -294,7 +304,8 @@ module.exports = {
functionName: 'BBText',
iconPath: 'res/actions/text24_black.png',
type: 'string',
paramLabel: _('BBCode text'),
instructionLabel: _('BBCode text'),
paramLabel: _('Text'),
conditionDescription: _('Compare the value of the BBCode text.'),
conditionSentence: _('the BBCode text'),
actionDescription: _('Set BBCode text'),
Expand All @@ -306,7 +317,8 @@ module.exports = {
functionName: 'Color',
iconPath: 'res/actions/color24.png',
type: 'color',
paramLabel: _('Color'),
instructionLabel: _('Color'),
paramLabel: _('Color (R;G;B)'),
conditionDescription: '', // No conditions for a "color" property
conditionSentence: '', // No conditions for a "color" property
actionDescription: _('Set base color'),
Expand All @@ -318,7 +330,8 @@ module.exports = {
functionName: 'Opacity',
iconPath: 'res/actions/opacity24.png',
type: 'number',
paramLabel: _('Opacity'),
instructionLabel: _('Opacity'),
paramLabel: _('Opacity (0-255)'),
conditionDescription: _(
'Compare the value of the base opacity of the text.'
),
Expand All @@ -332,6 +345,7 @@ module.exports = {
functionName: 'FontSize',
iconPath: 'res/actions/characterSize24.png',
type: 'number',
instructionLabel: _('Font size'),
paramLabel: _('Font size'),
conditionDescription: _('Compare the base font size of the text.'),
conditionSentence: _('the base font size'),
Expand All @@ -344,6 +358,7 @@ module.exports = {
functionName: 'FontFamily',
iconPath: 'res/actions/font24.png',
type: 'string',
instructionLabel: _('Font family'),
paramLabel: _('Font family'),
conditionDescription: _('Compare the value of font family'),
conditionSentence: _('the base font family'),
Expand All @@ -356,6 +371,7 @@ module.exports = {
functionName: 'Alignment',
iconPath: 'res/actions/textAlign24.png',
type: 'stringWithSelector',
instructionLabel: _('Alignment'),
paramLabel: _('Alignment'),
options: ['left', 'right', 'center'],
conditionDescription: _('Check the current text alignment.'),
Expand All @@ -369,6 +385,7 @@ module.exports = {
functionName: 'WordWrap',
iconPath: 'res/actions/scaleWidth24_black.png',
type: 'boolean',
instructionLabel: _('Word wrap'),
paramLabel: _('Word wrap'),
conditionDescription: _('Check if word wrap is enabled.'),
conditionSentence: _('Word wrap is enabled'),
Expand All @@ -381,6 +398,7 @@ module.exports = {
functionName: 'WrappingWidth',
iconPath: 'res/actions/scaleWidth24_black.png',
type: 'number',
instructionLabel: _('Wrapping width'),
paramLabel: _('Wrapping width'),
conditionDescription: _(
'Compare the width, in pixels, after which the text is wrapped on next line.'
Expand Down Expand Up @@ -510,8 +528,7 @@ module.exports = {
* This is called to update the PIXI object on the scene editor
*/
RenderedBBTextInstance.prototype.update = function () {
const properties = this._associatedObjectConfiguration
.getProperties();
const properties = this._associatedObjectConfiguration.getProperties();

const rawText = properties.get('text').getValue();
if (rawText !== this._pixiObject.text) {
Expand Down
29 changes: 22 additions & 7 deletions Extensions/BitmapText/JsExtension.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ module.exports = {
'res/conditions/text24_black.png'
)
.addParameter('object', _('Bitmap text'), 'BitmapTextObject', false)
.useStandardParameters('string')
.useStandardParameters('string', gd.ParameterOptions.makeNewOptions())
.setFunctionName('setText')
.setGetter('getText');

Expand All @@ -202,7 +202,12 @@ module.exports = {
'res/conditions/opacity24.png'
)
.addParameter('object', _('Bitmap text'), 'BitmapTextObject', false)
.useStandardParameters('number')
.useStandardParameters(
'number',
gd.ParameterOptions.makeNewOptions().setDescription(
_('Opacity (0-255)')
)
)
.setFunctionName('setOpacity')
.setGetter('getOpacity');

Expand All @@ -217,7 +222,7 @@ module.exports = {
'res/conditions/characterSize24.png'
)
.addParameter('object', _('Bitmap text'), 'BitmapTextObject', false)
.useStandardParameters('number')
.useStandardParameters('number', gd.ParameterOptions.makeNewOptions())
.setFunctionName('getFontSize');

object
Expand All @@ -232,7 +237,12 @@ module.exports = {
)
.addParameter('object', _('Bitmap text'), 'BitmapTextObject', false)
.useStandardParameters('number')
.setFunctionName('setScale')
.setFunctionName(
'setScale',
gd.ParameterOptions.makeNewOptions().setDescription(
_('Scale (1 by default)')
)
)
.setGetter('getScale');

object
Expand All @@ -246,7 +256,7 @@ module.exports = {
'res/conditions/font24.png'
)
.addParameter('object', _('Bitmap text'), 'BitmapTextObject', false)
.useStandardParameters('string')
.useStandardParameters('string', gd.ParameterOptions.makeNewOptions())
.setFunctionName('getFontName');

object
Expand Down Expand Up @@ -304,7 +314,12 @@ module.exports = {
'res/actions/textAlign24.png'
)
.addParameter('object', _('Bitmap text'), 'BitmapTextObject', false)
.useStandardParameters('string')
.useStandardParameters(
'string',
gd.ParameterOptions.makeNewOptions().setDescription(
_('Alignment ("left", "right" or "center")')
)
)
.setFunctionName('getAlignment');

object
Expand Down Expand Up @@ -367,7 +382,7 @@ module.exports = {
'res/actions/scaleWidth24_black.png'
)
.addParameter('object', _('Bitmap text'), 'BitmapTextObject', false)
.useStandardParameters('number')
.useStandardParameters('number', gd.ParameterOptions.makeNewOptions())
.setFunctionName('setWrappingWidth')
.setGetter('getWrappingWidth');

Expand Down
Loading

0 comments on commit 0de933d

Please sign in to comment.