Show the pack in the title bar and drop the empty pick panel

- Name the pack and its version in the title bar instead of the world folder
- Send the dimension's version with the world info
- Show the pick inspector only when the server measured something
- Fall back to the heights legend in the 3D view while there is no measurement
- Remove the Biomes/Noise/Both switch until tiles carry pick noise
This commit is contained in:
piexel committed 2026-11-25 18:15:56 +01:00
1 parent 60e7d255cc
commit d6aef12f6d
6 files changed
+20 -52

No files matched your search

+2
View File
@@ -305,6 +305,8 @@ export interface WorldInfo {
world: string
dimension: string
dimensionName: string
/** The dimension's `version`; absent from a server that does not send it. */
packVersion?: number
seed: string
minY: number
height: number
+4 -10
View File
@@ -1,6 +1,6 @@
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
import type { BridgeClient, MapLayerQuery, WorldRect } from '../bridge/BridgeClient'
import type { MapHover, MapLabel, Marker, ModuleViewInfo, PickDisplay, ServerUsage, ViewInfo, WorldInfo } from '../bridge/types'
import type { MapHover, MapLabel, Marker, ModuleViewInfo, ServerUsage, ViewInfo, WorldInfo } from '../bridge/types'
import type { Share } from '../map/census'
import type { MapController, MapStatus, MapToggles } from '../map/MapController'
import type { Highlight } from '../map/tileStyle'
@@ -9,7 +9,7 @@ import { HelpDialog } from './HelpDialog'
import { HoverCard } from './HoverCard'
import { Legend } from './Legend'
import { MapCanvas, type CanvasPoint } from './MapCanvas'
import { PickInspector } from './PickInspector'
import { PickInspector, hasPickSections } from './PickInspector'
import { RegionPreviewList } from './RegionPreviewList'
import { ImageMapStudio } from './ImageMapStudio'
import { NoiseStudio } from './NoiseStudio'
@@ -65,7 +65,6 @@ export function MapStudio({ client, world, theme, onDisconnect }: MapStudioProps
const [notice, setNotice] = useState<string | null>(null)
const [connected, setConnected] = useState(true)
const [preview, setPreview] = useState<string | null>(null)
const [pickDisplay, setPickDisplay] = useState<PickDisplay>('picks')
const [area, setArea] = useState<WorldRect | null>(null)
const [packRevision, setPackRevision] = useState(0)
const [sceneSummary, setSceneSummary] = useState<string | null>(null)
@@ -100,7 +99,6 @@ export function MapStudio({ client, world, theme, onDisconnect }: MapStudioProps
}, [notice])
useEffect(() => controller.current?.setView(layer.view, layer.preview), [layer])
useEffect(() => controller.current?.setPickDisplay(pickDisplay), [pickDisplay])
useEffect(() => controller.current?.setToggles(toggles), [toggles])
useEffect(() => controller.current?.setHighlight(highlight), [highlight])
useEffect(() => controller.current?.setMarkers(players, toggles.entities ? entities : []), [players, entities, toggles.entities])
@@ -300,13 +298,9 @@ export function MapStudio({ client, world, theme, onDisconnect }: MapStudioProps
)}
</ViewIsland>
<div className="flex w-[250px] shrink-0 flex-col gap-1.5">
{inspectsPicks && (
{inspectsPicks && hasPickSections(inspection) && (
<Panel className="min-h-0 flex-[7]">
<PickInspector
title={previewName ?? view.label}
inspection={inspection}
display={{ picksLabel: viewId === 'regions' && layer.preview === null ? 'Regions' : 'Biomes', value: pickDisplay, onChange: setPickDisplay }}
/>
<PickInspector title={previewName ?? view.label} inspection={inspection} />
</Panel>
)}
<Panel className="min-h-0 flex-[3]">
@@ -1,17 +1,13 @@
import { useState } from 'react'
import { ScrollArea } from '@/components/ui/scroll-area'
import { ToggleGroup, ToggleGroupItem } from '@/components/ui/toggle-group'
import type { PickDisplay, PickInspection, PickSection } from '../bridge/types'
import type { PickInspection, PickSection } from '../bridge/types'
import { Glyph } from './Glyph'
import { hexColor } from './colors'
import { NoiseChart, percent } from './NoiseChart'
/** How the map draws the picks, for a view that recolours its tiles. */
export interface PickDisplayChoice {
/** What the map shows when it draws the picks: "Regions" or "Biomes". */
picksLabel: string
value: PickDisplay
onChange(display: PickDisplay): void
/** Whether a measurement has anything to chart; a server that does not measure picks answers with no sections. */
export function hasPickSections(inspection: PickInspection | null): inspection is PickInspection {
return inspection !== null && inspection.sections.length > 0
}
interface PickInspectorProps {
@@ -19,40 +15,15 @@ interface PickInspectorProps {
title: string
/** The latest measurement of the view; null until the first one arrives. */
inspection: PickInspection | null
/** Absent in a view that draws no map tiles, such as the 3D world. */
display?: PickDisplayChoice
}
/**
* How noise picks the regions or biomes in view, measured against what is in view, with a switch for how the map
* draws the picks.
*/
export function PickInspector({ title, inspection, display }: PickInspectorProps): React.JSX.Element {
/** How noise picks the regions or biomes in view, measured against what is in view. */
export function PickInspector({ title, inspection }: PickInspectorProps): React.JSX.Element {
return (
<section className="flex min-h-0 flex-1 flex-col">
<header className="px-4 pt-2.5 pb-2.5">
<h2 className="truncate text-[13px] font-semibold">{title}</h2>
<p className="truncate text-[11.5px] text-secondary-text">{inspection?.detail ?? 'Measuring what is in view…'}</p>
{display !== undefined && (
<ToggleGroup
type="single"
variant="outline"
size="sm"
className="mt-2 w-full"
value={display.value}
onValueChange={(value) => value !== '' && display.onChange(value as PickDisplay)}
>
<ToggleGroupItem value="picks">
{display.picksLabel}
</ToggleGroupItem>
<ToggleGroupItem value="noise">
Noise
</ToggleGroupItem>
<ToggleGroupItem value="both">
Both
</ToggleGroupItem>
</ToggleGroup>
)}
</header>
<ScrollArea className="min-h-0 flex-1 border-t">
<div className="px-4 pb-2">{inspection !== null && <Sections sections={inspection.sections} />}</div>
@@ -18,17 +18,17 @@ interface StudioToolbarProps {
onDisconnect(): void
}
/** The window's bar: the world the studio is connected to, which leads back to the world list, and the studio's own buttons. */
/** The window's bar: the pack the studio is connected to, which leads back to the world list, and the studio's own buttons. */
export function StudioToolbar({ world, onHelp, onSettings, onDisconnect }: StudioToolbarProps): React.JSX.Element {
return (
<header className="flex h-10 shrink-0 items-center gap-1 px-1.5">
<IconHint hint="Back to the world list">
<Button variant="ghost" size="sm" className="h-[30px] max-w-[50%] gap-2 px-2 font-semibold" onClick={onDisconnect}>
<span className="flex size-5 shrink-0 items-center justify-center rounded-[5px] bg-primary text-[11px] font-semibold text-primary-foreground uppercase">
{world.world.charAt(0)}
{world.dimensionName.charAt(0)}
</span>
<span className="truncate">{world.world}</span>
<span className="truncate font-normal text-secondary-text">{world.dimensionName}</span>
<span className="truncate">{world.dimensionName}</span>
{world.packVersion !== undefined && <span className="shrink-0 font-normal text-secondary-text tabular-nums">v{world.packVersion}</span>}
<Glyph glyph="chevronDown" />
</Button>
</IconHint>
@@ -13,7 +13,7 @@ import { TerrainMeshWorkers } from '../scene/terrainMeshWorkers'
import { focusAround, type TerrainStyle } from '../scene/terrainStream'
import { TILE_COLUMNS } from '../scene/terrainTiles'
import { Legend } from './Legend'
import { PickInspector } from './PickInspector'
import { PickInspector, hasPickSections } from './PickInspector'
import { SceneViewport } from './SceneViewport'
import { usePickInspection } from './usePickInspection'
import { useSpotActions } from './useSpotActions'
@@ -162,7 +162,7 @@ export function WorldStudio3D({ title, client, world, mapArea, packRevision, onS
<Panel className="w-[250px]">
{showsCaves ? (
<Legend title="Caves by height" shares={caveShares} emptyText={caves.status === null ? 'No caves here' : 'Generating the caves…'} className="flex-1" />
) : inspectsPicks ? (
) : inspectsPicks && hasPickSections(inspection) ? (
<PickInspector title={coloring === 'regions' ? 'Regions' : 'Biomes'} inspection={inspection} />
) : (
<Legend title="Heights in view" shares={heightShares} emptyText="Looking at the ground…" className="flex-1" />