mirror of
https://github.com/JannisX11/blockbench.git
synced 2024-11-21 01:13:37 +08:00
Introduce enum property type
This commit is contained in:
parent
4ad48f2254
commit
23b0ef330e
@ -546,7 +546,7 @@ class Keyframe {
|
||||
new Property(Keyframe, 'number', 'time')
|
||||
new Property(Keyframe, 'number', 'color', {default: -1})
|
||||
new Property(Keyframe, 'boolean', 'uniform', {condition: keyframe => keyframe.channel == 'scale', default: settings.uniform_keyframe.value})
|
||||
new Property(Keyframe, 'string', 'interpolation', {default: 'linear'})
|
||||
new Property(Keyframe, 'enum', 'interpolation', {default: 'linear'})
|
||||
new Property(Keyframe, 'boolean', 'bezier_linked', {default: true})
|
||||
new Property(Keyframe, 'vector', 'bezier_left_time', {default: [-0.1, -0.1, -0.1]});
|
||||
new Property(Keyframe, 'vector', 'bezier_left_value');
|
||||
|
@ -52,7 +52,7 @@ class CubeFace extends Face {
|
||||
}
|
||||
new Property(CubeFace, 'number', 'rotation', {default: 0});
|
||||
new Property(CubeFace, 'number', 'tint', {default: -1});
|
||||
new Property(CubeFace, 'string', 'cullface', )//{merge_validation: (val) => (UVEditor.cube_faces.includes(val) || val == '')});
|
||||
new Property(CubeFace, 'enum', 'cullface', {values: ['', 'north', 'south', 'west', 'east', 'up', 'down']});
|
||||
new Property(CubeFace, 'string', 'material_name');
|
||||
new Property(CubeFace, 'boolean', 'enabled', {default: true});
|
||||
|
||||
|
@ -14,6 +14,7 @@ class Property {
|
||||
} else {
|
||||
switch (this.type) {
|
||||
case 'string': this.default = ''; break;
|
||||
case 'enum': this.default = options.values?.[0] || ''; break;
|
||||
case 'molang': this.default = '0'; break;
|
||||
case 'number': this.default = 0; break;
|
||||
case 'boolean': this.default = false; break;
|
||||
@ -25,6 +26,7 @@ class Property {
|
||||
}
|
||||
switch (this.type) {
|
||||
case 'string': this.isString = true; break;
|
||||
case 'enum': this.isEnum = true; break;
|
||||
case 'molang': this.isMolang = true; break;
|
||||
case 'number': this.isNumber = true; break;
|
||||
case 'boolean': this.isBoolean = true; break;
|
||||
@ -44,6 +46,9 @@ class Property {
|
||||
}
|
||||
})
|
||||
}
|
||||
if (this.isEnum) {
|
||||
this.enum_values = options.values;
|
||||
}
|
||||
|
||||
if (typeof options.merge == 'function') this.merge = options.merge;
|
||||
if (typeof options.reset == 'function') this.reset = options.reset;
|
||||
@ -72,6 +77,9 @@ class Property {
|
||||
if (this.isString) {
|
||||
Merge.string(instance, data, this.name, this.merge_validation)
|
||||
}
|
||||
else if (this.isEnum) {
|
||||
Merge.string(instance, data, this.name, val => (!this.enum_values || this.enum_values.includes(val)));
|
||||
}
|
||||
else if (this.isNumber) {
|
||||
Merge.number(instance, data, this.name)
|
||||
}
|
||||
|
@ -1614,11 +1614,11 @@ class Texture {
|
||||
new Property(Texture, 'string', 'namespace')
|
||||
new Property(Texture, 'string', 'id')
|
||||
new Property(Texture, 'boolean', 'particle')
|
||||
new Property(Texture, 'string', 'render_mode', {default: 'default'})
|
||||
new Property(Texture, 'string', 'render_sides', {default: 'auto'})
|
||||
new Property(Texture, 'enum', 'render_mode', {default: 'default'})
|
||||
new Property(Texture, 'enum', 'render_sides', {default: 'auto'})
|
||||
|
||||
new Property(Texture, 'number', 'frame_time', {default: 1})
|
||||
new Property(Texture, 'string', 'frame_order_type', {default: 'loop'})
|
||||
new Property(Texture, 'enum', 'frame_order_type', {default: 'loop', values: ['custom', 'loop', 'backwards', 'back_and_forth']})
|
||||
new Property(Texture, 'string', 'frame_order')
|
||||
new Property(Texture, 'boolean', 'frame_interpolate')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user