UNPKG

@minecraft/creator-tools

Version:

Minecraft Creator Tools command line and libraries.

1 lines 3.58 kB
"use strict";(self.webpackChunkmctools_app=self.webpackChunkmctools_app||[]).push([[572],{17572:(t,e,i)=>{i.d(e,{default:()=>p});var s=i(74848),o=i(96540),d=i(65099),r=i(40267),l=i(11064),a=i(11872),h=i(74239);class n extends o.Component{_lastFileEdited;_lastFolderEdited;constructor(t){super(t),this._handleMcworldLoaded=this._handleMcworldLoaded.bind(this),this.state={fileToEdit:this.props.file,folderToEdit:this.props.folder}}static getDerivedStateFromProps(t,e){return null==e&&t.file?e={fileToEdit:t.file,folderToEdit:void 0}:null==e&&t.folder?e={fileToEdit:void 0,folderToEdit:t.folder}:t.folder&&t.folder!==e.folderToEdit?(e.folderToEdit=t.folder,e):t.file&&t.file!==e.fileToEdit?(e.fileToEdit=t.file,e):null}componentDidUpdate(t,e){this._updateManagerOnFile()}async _updateManagerOnFolder(){void 0!==this.state&&void 0!==this.state.folderToEdit&&this.state.folderToEdit!==this._lastFolderEdited&&(this._lastFolderEdited=this.state.folderToEdit,d.A.ensureMCWorldOnFolder(this.state.folderToEdit,this.props.project,this._handleMcworldLoaded),await r.A.ensureFormLoaded("world","mcworld_properties"))}async _updateManagerOnFile(){void 0!==this.state&&void 0!==this.state.fileToEdit&&this.state.fileToEdit!==this._lastFileEdited&&this.state.fileToEdit&&(this._lastFileEdited=this.state.fileToEdit,d.A.ensureOnFile(this.state.fileToEdit,this.props.project,this._handleMcworldLoaded),await r.A.ensureFormLoaded("world","mcworld_properties"))}_handleMcworldLoaded(t,e){this.forceUpdate()}async persist(){if(void 0!==this.state&&null!=this.state.fileToEdit){const t=this.state.fileToEdit;if(void 0!==t.manager&&t.manager instanceof d.A){const e=t.manager;return await e.saveToFile(),!0}}return!1}render(){const t="calc(100vh - "+this.props.heightOffset+"px)";if(null===r.A.uxCatalog||null===this.state)return(0,s.jsx)("div",{children:this.props.intl.formatMessage({id:"project_editor.mc_world.loading"})});if(this.props.file&&(null===this.state||null===this.state.fileToEdit||void 0===this.state.fileToEdit||void 0===this.state.fileToEdit.manager||null===r.A.uxCatalog))return this.state.fileToEdit&&void 0===this.state.fileToEdit.manager&&this._updateManagerOnFile(),(0,s.jsx)("div",{children:this.props.intl.formatMessage({id:"project_editor.mc_world.loading"})});if(this.props.folder&&(null===this.state||null===this.state.folderToEdit||void 0===this.state.folderToEdit||void 0===this.state.folderToEdit.manager||null===r.A.uxCatalog))return this.state.folderToEdit&&void 0===this.state.folderToEdit.manager&&this._updateManagerOnFolder(),(0,s.jsx)("div",{children:this.props.intl.formatMessage({id:"project_editor.mc_world.loading"})});let e;if(void 0!==this.props.setActivePersistable&&this.props.setActivePersistable(this),this.state.fileToEdit&&(e=this.state.fileToEdit.manager),this.state.folderToEdit&&(e=this.state.folderToEdit.manager),!e)return(0,s.jsx)("div",{children:this.props.intl.formatMessage({id:"project_editor.mc_world.loading"})});let i=(0,s.jsx)(s.Fragment,{});if(this.props.displayProps){const t=r.A.getForm("world","mcworld_properties");t&&(i=(0,s.jsx)("div",{className:"mcwe-props",children:(0,s.jsx)(a.A,{readOnly:!1,theme:this.props.theme,project:this.props.project,lookupProvider:this.props.project,definition:t,getsetPropertyObject:e})}))}return(0,s.jsxs)("div",{className:"mcwe-area",style:{height:t,minHeight:t,maxHeight:t},children:[(0,s.jsx)("div",{className:"mcwe-map",children:(0,s.jsx)(l.default,{creatorTools:this.props.creatorTools,project:this.props.project,world:e,heightOffset:this.props.heightOffset})}),i]})}}const p=(0,h.g)(n)}}]);