Skip to content

Commit

Permalink
feat: add a way to change size of touch buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
zardoy committed Sep 25, 2023
1 parent 8c7b6f6 commit 3ca17f1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/menus/advanced_options_screen.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
const { html, css, LitElement } = require('lit')
const { commonCss, openURL } = require('./components/common')
const { hideCurrentModal } = require('../globalState')
const { toNumber, getScreenRefreshRate } = require('../utils')
const { getScreenRefreshRate } = require('../utils')
const { subscribe } = require('valtio')
const { options } = require('../optionsStorage')

Expand Down Expand Up @@ -74,6 +74,11 @@ class AdvancedOptionsScreen extends LitElement {
this.requestUpdate()
}}></pmui-button>
</div>
<div class="wrapper">
<pmui-slider pmui-width="150px" pmui-label="Touch Buttons Size" pmui-value="${options.touchButtonsSize}" pmui-type="%" pmui-min="20" pmui-max="100" @input=${(e) => {
options.touchButtonsSize = +e.target.value
}}></pmui-slider>
</div>
<pmui-button pmui-width="200px" pmui-label="Done" @pmui-click=${() => hideCurrentModal()}></pmui-button>
</main>
Expand Down
1 change: 1 addition & 0 deletions src/optionsStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const defaultOptions = {
fov: 75,
guiScale: 3,
autoRequestCompletions: true,
touchButtonsSize: 40,

frameLimit: false as number | false,
alwaysBackupWorldBeforeLoading: undefined as boolean | undefined | null,
Expand Down
10 changes: 9 additions & 1 deletion src/reactUi.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import { renderToDom } from '@zardoy/react-util'
import { LeftTouchArea, RightTouchArea, useUsingTouch, useInterfaceState } from '@dimaka/interface'
import { css } from '@emotion/css'
import { activeModalStack, isGameActive, miscUiState } from './globalState'
import { isProbablyIphone } from './menus/components/common'
// import DeathScreen from './react/DeathScreen'
import { useSnapshot } from 'valtio'
import { contro } from './controls'
import { QRCodeSVG } from 'qrcode.react'
import { createPortal } from 'react-dom'
import { options, watchValue } from './optionsStorage'

// todo
useInterfaceState.setState({
Expand Down Expand Up @@ -40,6 +40,14 @@ useInterfaceState.setState({
}
})

watchValue(options, (o) => {
useInterfaceState.setState({
uiCustomization: {
touchButtonSize: o.touchButtonsSize,
},
})
})

const TouchControls = () => {
// todo setting
const usingTouch = useUsingTouch()
Expand Down

0 comments on commit 3ca17f1

Please sign in to comment.