const { LitElement, html, css } = require('lit') const { commonCss, displayScreen, isMobile } = require('./components/common') class OptionsScreen extends LitElement { static get styles () { return css` ${commonCss} .title { top: 4px; } main { display: flex; flex-direction: column; position: absolute; top: calc(100% / 6 - 6px); left: 50%; width: 310px; gap: 4px 0; place-items: center; place-content: center; transform: translate(-50%); } .wrapper { display: flex; flex-direction: row; width: 100%; gap: 0 10px; height: 20px; } ` } static get properties () { return { isInsideWorld: { type: Boolean }, mouseSensitivityX: { type: Number }, mouseSensitivityY: { type: Number }, chatWidth: { type: Number }, chatHeight: { type: Number }, chatScale: { type: Number }, sound: { type: Number }, renderDistance: { type: Number }, fov: { type: Number }, guiScale: { type: Number } } } constructor () { super() this.isInsideWorld = false const getValue = (item, defaultValue, convertFn) => window.localStorage.getItem(item) ? convertFn(window.localStorage.getItem(item)) : defaultValue this.mouseSensitivityX = getValue('mouseSensX', 50, (v) => Math.floor(Number(v) * 10000)) this.mouseSensitivityY = getValue('mouseSensY', 50, (v) => Math.floor(Number(v) * 10000)) this.chatWidth = getValue('chatWidth', 320, (v) => Number(v)) this.chatHeight = getValue('chatHeight', 180, (v) => Number(v)) this.chatScale = getValue('chatScale', 100, (v) => Number(v)) this.sound = getValue('sound', 50, (v) => Number(v)) this.renderDistance = getValue('renderDistance', 6, (v) => Number(v)) this.fov = getValue('fov', 75, (v) => Number(v)) this.guiScale = getValue('guiScale', 3, (v) => Number(v)) this.forceMobileControls = getValue('forceMobileControls', false, (v) => v === 'true') document.documentElement.style.setProperty('--chatScale', `${this.chatScale / 100}`) document.documentElement.style.setProperty('--chatWidth', `${this.chatWidth}px`) document.documentElement.style.setProperty('--chatHeight', `${this.chatHeight}px`) document.documentElement.style.setProperty('--guiScale', `${this.guiScale}`) } render () { return html`

Options

{ this.mouseSensitivityX = Number(e.target.value) window.localStorage.setItem('mouseSensX', this.mouseSensitivityX * 0.0001) }}> { this.mouseSensitivityY = Number(e.target.value) window.localStorage.setItem('mouseSensY', this.mouseSensitivityY * 0.0001) }}>
{ this.chatWidth = Number(e.target.value) window.localStorage.setItem('chatWidth', `${this.chatWidth}`) document.documentElement.style.setProperty('--chatWidth', `${this.chatWidth}px`) }}> { this.chatHeight = Number(e.target.value) window.localStorage.setItem('chatHeight', `${this.chatHeight}`) document.documentElement.style.setProperty('--chatHeight', `${this.chatHeight}px`) }}>
{ this.chatScale = Number(e.target.value) window.localStorage.setItem('chatScale', `${this.chatScale}`) document.documentElement.style.setProperty('--chatScale', `${this.chatScale / 100}`) }}> { this.sound = Number(e.target.value) window.localStorage.setItem('sound', `${this.sound}`) }}>
displayScreen(this, document.getElementById('keybinds-screen'))}> { this.guiScale = Number(e.target.value) window.localStorage.setItem('guiScale', `${this.guiScale}`) document.documentElement.style.setProperty('--guiScale', `${this.guiScale}`) }}>
${this.isInsideWorld ? '' : html`
{ this.renderDistance = Number(e.target.value) window.localStorage.setItem('renderDistance', `${this.renderDistance}`) }}> { this.fov = Number(e.target.value) window.localStorage.setItem('fov', `${this.fov}`) this.dispatchEvent(new window.CustomEvent('fov_changed', { fov: this.fov })) }}>
`}
{ this.forceMobileControls = !this.forceMobileControls window.localStorage.setItem('forceMobileControls', `${this.forceMobileControls}`) if (this.forceMobileControls || isMobile()) { document.getElementById('hud').showMobileControls(true) } else { document.getElementById('hud').showMobileControls(false) } this.requestUpdate() } }>
displayScreen(this, document.getElementById(this.isInsideWorld ? 'pause-screen' : 'title-screen'))}>
` } } window.customElements.define('pmui-optionsscreen', OptionsScreen)