diff --git a/src/admin-toolkit-ui/VideoControl.tsx b/src/admin-toolkit-ui/VideoControl.tsx index 8eb8bb8a..f40d29f4 100644 --- a/src/admin-toolkit-ui/VideoControl.tsx +++ b/src/admin-toolkit-ui/VideoControl.tsx @@ -6,6 +6,7 @@ import { getExplorerComponents } from '../components' import { Button } from './Button' import { CONTENT_URL } from './constants' import { State } from './types' +import { getScaleUIFactor } from '../ui' // Constants const ICONS = { @@ -17,20 +18,6 @@ const ICONS = { VOLUME_PLUS_BUTTON: `${CONTENT_URL}/admin_toolkit/assets/icons/video-control-volume-plus-button.png`, } as const -const UI_STYLES = { - BUTTON_TRANSFORM: { - margin: '0 16px 0 0', - minWidth: 69, - alignItems: 'center', - justifyContent: 'center', - padding: '0px 0px 0px 0px', - } as const, - ICON_TRANSFORM: { - width: 35, - height: 35, - } as const, -} as const - const DROPDOWN_BACKGROUND = `${CONTENT_URL}/admin_toolkit/backgrounds/dropdown-background.png` const VOLUME_STEP = 0.1 @@ -42,17 +29,7 @@ const COLORS = { GRAY: Color4.create(160 / 255, 155 / 255, 168 / 255, 1), } as const -const VOLUME_STYLES = { - CONTAINER: { - flexDirection: 'column', - } as const, - HEADER: { - margin: '0 0 10px 0', - } as const, - CONTROLS: { - flexDirection: 'row', - } as const, -} as const +let videoPlayersInitialized = false // Types interface VideoPlayerControls { @@ -124,6 +101,10 @@ function updateVideoPlayerProps( property: K, value: NonNullable, ) { + const { VideoControlState } = getComponents(engine) + const videoControlState = VideoControlState.getMutable( + state.adminToolkitUiEntity, + ) const { VideoPlayer } = getExplorerComponents(engine) const videoControl = getAdminToolkitVideoControl(engine) const linkAllVideoPlayers = @@ -183,6 +164,20 @@ function updateVideoSourceProperty( } } +function initVideoPlayers(engine: IEngine) { + const { NetworkEntity } = getExplorerComponents(engine) + const videoPlayers = getVideoPlayers(engine) + + for (const player of videoPlayers) { + const networkEntity = NetworkEntity.getOrNull(player.entity as Entity) + if (!networkEntity) { + NetworkEntity.create(player.entity as Entity) + } + } + + videoPlayersInitialized = true +} + // Components function VideoPlayerSelector({ engine, @@ -192,18 +187,27 @@ function VideoPlayerSelector({ state: State }) { const videoPlayers = getVideoPlayers(engine) + const scaleFactor = getScaleUIFactor(engine) if (videoPlayers.length <= 1) return null if (videoPlayers.length > 4) { return ( - + player.customName)} selectedIndex={state.videoControl.selectedVideoPlayer ?? 0} onChange={(idx) => (state.videoControl.selectedVideoPlayer = idx)} textAlign="middle-left" - uiTransform={{ margin: { right: 8 }, minWidth: 150 }} + uiTransform={{ + margin: { right: 8 * scaleFactor }, + minWidth: 150 * scaleFactor, + }} uiBackground={{ color: Color4.White() }} />