Skip to content

Commit

Permalink
Button can display icon
Browse files Browse the repository at this point in the history
  • Loading branch information
rexrainbow committed Oct 10, 2023
1 parent b443efa commit a8b6fa9
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
7 changes: 6 additions & 1 deletion examples/ui-tweaker/buttons.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ class Demo extends Phaser.Scene {
.addButton({
title: 'Button A',

label: 'Button A',
// label: 'Button A',
label: {
text: 'Button A',
icon: 'settings',
iconSize: 20
},
callback: function () {
print.text += 'Click Button A\n';
}
Expand Down
3 changes: 3 additions & 0 deletions templates/ui/simplelabel/SimpleLabel.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ declare namespace SimpleLabel {

interface ICreatorsConfig extends BuildLabelConfig.ICreators {
}

interface IResetDisplayContentConfig extends Label.IResetDisplayContentConfig {
}
}

declare class SimpleLabel extends Label {
Expand Down
13 changes: 7 additions & 6 deletions templates/ui/tweaker/Tweaker.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ declare namespace Tweaker {
}
}

interface IOptionConfig extends SimpleLabel.IResetDisplayContentConfig {
value: any
}

interface IConfig extends Sizer.IConfig {
styles: {
itemWidth?: number,
Expand Down Expand Up @@ -143,10 +147,7 @@ declare namespace Tweaker {
min?: number, max?: number,

// list, buttons
options?: {
text: string,
value: any
}[],
options?: IOptionConfig[],

format: (value?: any) => string,

Expand Down Expand Up @@ -176,7 +177,7 @@ declare namespace Tweaker {

title: string,

label: string,
label: string | SimpleLabel.IResetDisplayContentConfig,
callback: (bindingTarget: Object) => void,

key?: string,
Expand All @@ -192,7 +193,7 @@ declare namespace Tweaker {
title: string,

buttons: {
label: string,
label: string | SimpleLabel.IResetDisplayContentConfig,
callback: (bindingTarget: Object) => void,
}[],

Expand Down
4 changes: 1 addition & 3 deletions templates/ui/tweaker/builders/CreateButtons.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ var CreateButtons = function (scene, config, style) {
buttons.push(button);

var buttonConfig = buttonsConfig[i];
button.resetDisplayContent({
text: buttonConfig.label
})
button.resetDisplayContent(buttonConfig.label);
button.callback = buttonConfig.callback;
}

Expand Down

0 comments on commit a8b6fa9

Please sign in to comment.