1+ import { isCurrentFormat } from '../blueprintFormat'
12import VanillaItemDisplayElementPanel from '../components/vanillaItemDisplayElementPanel.svelte'
3+ import { PACKAGE } from '../constants'
4+ import { VanillaItemDisplay } from '../outliner/vanillaItemDisplay'
25import { injectSvelteCompomponentMod } from '../util/injectSvelteComponent'
6+ import { translate } from '../util/translation'
37
48injectSvelteCompomponentMod ( {
59 component : VanillaItemDisplayElementPanel ,
@@ -8,3 +12,51 @@ injectSvelteCompomponentMod({
812 return document . querySelector ( '#panel_element' )
913 } ,
1014} )
15+
16+ export const ITEM_DISPLAY_ITEM_DISPLAY_SELECT = new BarSelect (
17+ `${ PACKAGE . name } :itemDisplayAlignmentSelect` ,
18+ {
19+ name : translate ( 'tool.item_display.item_display.title' ) ,
20+ icon : 'format_align_left' ,
21+ description : translate ( 'tool.item_display.item_display.description' ) ,
22+ condition : ( ) => isCurrentFormat ( ) && ! ! VanillaItemDisplay . selected . length ,
23+ options : {
24+ none : translate ( 'tool.item_display.item_display.options.none' ) ,
25+ thirdperson_lefthand : translate (
26+ 'tool.item_display.item_display.options.thirdperson_lefthand'
27+ ) ,
28+ thirdperson_righthand : translate (
29+ 'tool.item_display.item_display.options.thirdperson_righthand'
30+ ) ,
31+ firstperson_lefthand : translate (
32+ 'tool.item_display.item_display.options.firstperson_lefthand'
33+ ) ,
34+ firstperson_righthand : translate (
35+ 'tool.item_display.item_display.options.firstperson_righthand'
36+ ) ,
37+ head : translate ( 'tool.item_display.item_display.options.head' ) ,
38+ gui : translate ( 'tool.item_display.item_display.options.gui' ) ,
39+ ground : translate ( 'tool.item_display.item_display.options.ground' ) ,
40+ fixed : translate ( 'tool.item_display.item_display.options.fixed' ) ,
41+ } ,
42+ }
43+ )
44+ ITEM_DISPLAY_ITEM_DISPLAY_SELECT . get = function ( ) {
45+ const selected = VanillaItemDisplay . selected [ 0 ]
46+ if ( ! selected ) return 'left'
47+ return selected . itemDisplay
48+ }
49+ ITEM_DISPLAY_ITEM_DISPLAY_SELECT . set = function ( this : BarSelect < string > , value : string ) {
50+ const selected = VanillaItemDisplay . selected [ 0 ]
51+ if ( ! selected ) return this
52+ this . value = value
53+ const name = this . getNameFor ( value )
54+ this . nodes . forEach ( node => {
55+ $ ( node ) . find ( 'bb-select' ) . text ( name )
56+ } )
57+ if ( ! this . nodes . includes ( this . node ) ) {
58+ $ ( this . node ) . find ( 'bb-select' ) . text ( name )
59+ }
60+ selected . itemDisplay = value
61+ return this
62+ }
0 commit comments