|
1 | 1 | import type { Alignment } from '@aj/blockbench-additions/outliner-elements/textDisplay'
|
2 | 2 | import { translate } from '@aj/util/translation'
|
3 |
| -import { NbtByte, NbtCompound, NbtFloat, NbtInt, NbtString, NbtTag } from 'deepslate/lib/nbt' |
| 3 | +import { NbtByte, NbtCompound, NbtFloat, NbtInt, NbtString } from 'deepslate/lib/nbt' |
4 | 4 | import { SerializableConfig } from './serializableConfig'
|
5 | 5 | export type { Serialized } from './serializableConfig'
|
6 | 6 |
|
7 | 7 | @SerializableConfig.decorate
|
8 | 8 | export class CommonDisplayConfig extends SerializableConfig<CommonDisplayConfig> {
|
| 9 | + @SerializableConfig.configurePropertyDisplay({ |
| 10 | + get displayName() { |
| 11 | + return translate('config.common.options.billboard') |
| 12 | + }, |
| 13 | + displayMode: 'select', |
| 14 | + options: ['fixed', 'vertical', 'horizontal', 'center'], |
| 15 | + }) |
9 | 16 | billboard?: BillboardMode = 'fixed'
|
| 17 | + |
| 18 | + @SerializableConfig.configurePropertyDisplay({ |
| 19 | + get displayName() { |
| 20 | + return translate('config.common.options.overrideBrightness') |
| 21 | + }, |
| 22 | + displayMode: 'checkbox', |
| 23 | + }) |
10 | 24 | overrideBrightness? = false
|
11 |
| - brightnessOverride? = 0 |
| 25 | + |
| 26 | + @SerializableConfig.configurePropertyDisplay({ |
| 27 | + get displayName() { |
| 28 | + return translate('config.common.options.brightness') |
| 29 | + }, |
| 30 | + displayMode: 'slider', |
| 31 | + min: 0, |
| 32 | + max: 15, |
| 33 | + step: 1, |
| 34 | + }) |
| 35 | + brightness? = 0 |
| 36 | + |
| 37 | + @SerializableConfig.configurePropertyDisplay({ |
| 38 | + get displayName() { |
| 39 | + return translate('config.common.options.glowing') |
| 40 | + }, |
| 41 | + displayMode: 'checkbox', |
| 42 | + }) |
12 | 43 | glowing? = false
|
| 44 | + |
| 45 | + @SerializableConfig.configurePropertyDisplay({ |
| 46 | + get displayName() { |
| 47 | + return translate('config.common.options.overrideGlowColor') |
| 48 | + }, |
| 49 | + displayMode: 'checkbox', |
| 50 | + }) |
13 | 51 | overrideGlowColor? = false
|
| 52 | + |
| 53 | + @SerializableConfig.configurePropertyDisplay({ |
| 54 | + get displayName() { |
| 55 | + return translate('config.common.options.glowColor') |
| 56 | + }, |
| 57 | + displayMode: 'color', |
| 58 | + }) |
14 | 59 | glowColor? = '#ffffff'
|
15 |
| - inheritSettings? = false |
| 60 | + |
| 61 | + @SerializableConfig.configurePropertyDisplay({ |
| 62 | + get displayName() { |
| 63 | + return translate('config.common.options.invisible') |
| 64 | + }, |
| 65 | + displayMode: 'checkbox', |
| 66 | + }) |
16 | 67 | invisible? = false
|
17 |
| - nbt? = '' |
| 68 | + |
| 69 | + @SerializableConfig.configurePropertyDisplay({ |
| 70 | + get displayName() { |
| 71 | + return translate('config.common.options.shadowRadius') |
| 72 | + }, |
| 73 | + displayMode: 'number', |
| 74 | + min: 0, |
| 75 | + max: 64, |
| 76 | + step: 0.1, |
| 77 | + }) |
18 | 78 | shadowRadius? = 0
|
| 79 | + |
| 80 | + @SerializableConfig.configurePropertyDisplay({ |
| 81 | + get displayName() { |
| 82 | + return translate('config.common.options.shadowStrength') |
| 83 | + }, |
| 84 | + displayMode: 'number', |
| 85 | + min: 0, |
| 86 | + max: 1, |
| 87 | + step: 0.1, |
| 88 | + }) |
19 | 89 | shadowStrength? = 1
|
20 |
| - useNBT? = false |
21 | 90 |
|
22 |
| - public toNBT(compound: NbtCompound = new NbtCompound()): NbtCompound { |
23 |
| - if (this.useNBT && this.nbt?.length) { |
24 |
| - const newData = NbtTag.fromString(this.nbt) as NbtCompound |
25 |
| - for (const key of newData.keys()) { |
26 |
| - compound.set(key, newData.get(key)!) |
27 |
| - } |
28 |
| - return compound |
29 |
| - } |
| 91 | + @SerializableConfig.configurePropertyDisplay({ |
| 92 | + get displayName() { |
| 93 | + return translate('config.common.options.onSummonCommands') |
| 94 | + }, |
| 95 | + displayMode: 'code_editor', |
| 96 | + syntax: 'mc-build', |
| 97 | + }) |
| 98 | + onSummonCommands? = '' |
30 | 99 |
|
| 100 | + public toNBT(compound: NbtCompound = new NbtCompound()): NbtCompound { |
31 | 101 | if (this.billboard) {
|
32 | 102 | compound.set('billboard', new NbtString(this.billboard))
|
33 | 103 | }
|
34 | 104 |
|
35 |
| - if (this.overrideBrightness && this.brightnessOverride != undefined) { |
| 105 | + if (this.overrideBrightness && this.brightness != undefined) { |
36 | 106 | compound.set(
|
37 | 107 | 'brightness',
|
38 | 108 | new NbtCompound()
|
39 |
| - .set('block', new NbtFloat(this.brightnessOverride)) |
40 |
| - .set('sky', new NbtFloat(this.brightnessOverride)) |
| 109 | + .set('block', new NbtFloat(this.brightness)) |
| 110 | + .set('sky', new NbtFloat(this.brightness)) |
41 | 111 | )
|
42 | 112 | }
|
43 | 113 |
|
@@ -176,13 +246,10 @@ export class TextDisplayConfig extends SerializableConfig<TextDisplayConfig> {
|
176 | 246 | displayMode: 'code_editor',
|
177 | 247 | syntax: 'json',
|
178 | 248 | })
|
179 |
| - textComponent?: string |
| 249 | + textComponent? = '' |
180 | 250 |
|
181 | 251 | public toNBT(compound = new NbtCompound()) {
|
182 | 252 | console.error('toNBT not implemented for TextDisplayConfig!')
|
183 | 253 | return compound
|
184 | 254 | }
|
185 | 255 | }
|
186 |
| - |
187 |
| -const TEST = new TextDisplayConfig() |
188 |
| -console.log(TEST, TEST.getPropertyDescription('alignment')) |
|
0 commit comments