Skip to content

Commit

Permalink
value list with a list of key values
Browse files Browse the repository at this point in the history
  • Loading branch information
kleber-jg committed Sep 28, 2021
1 parent 904aca6 commit 2cf023a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
8 changes: 1 addition & 7 deletions src/core/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,7 @@ class EditorClass {
// Sprite
{ name: 'key', typeHint: 'string' },
{ name: 'frameName', label: 'frame', typeHint: 'string' },
{
name: 'blendMode', typeHint: 'valueList', values: [
{ value: 0, label: 'NONE' },
{ value: 1, label: 'ADD' },
{ value: 2, label: 'MULTIPLY' },
]
},
{ name: 'blendMode', typeHint: 'valueList', values: Phaser.blendModes },
{ name: 'tint', typeHint: 'color' },

// Text
Expand Down
2 changes: 1 addition & 1 deletion src/data/inspector-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export type InspectableType = 'string' | 'text' | 'number' | 'boolean' | 'point'
export interface InspectorPropertyModel {
name: string;
typeHint: InspectableType;
values?: { value: any, label: string }[];
values?: { value: any, label: string }[] | Object;
data?: any;
label?: string;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ export class ValueListPropertyEditor extends PropertyEditor<any> {
const select = this.select = document.createElement('select');
select.id = fieldId;

(prop.values || []).forEach(v => {
let values: { value: any, label: string }[];
if (!prop.values) prop.values = [];
values = Array.isArray(prop.values)
? prop.values
: Object.keys(prop.values).map((label, value) => ({ value, label }));

values.forEach(v => {
const option = document.createElement('option');
option.value = v.value;
option.innerHTML = v.label;
Expand Down

0 comments on commit 2cf023a

Please sign in to comment.