mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 16:25:36 +00:00
Give every studio view an island header that holds its tools
This commit is contained in:
1 parent
4bdac458c0
commit
6cf5d7131b
14 files changed
+241
-182
No files matched your search
@@ -26,6 +26,7 @@ export type IdeIconName =
|
||||
| 'settings'
|
||||
| 'stopWatch'
|
||||
| 'symlink'
|
||||
| 'theme'
|
||||
| 'undo'
|
||||
| 'user'
|
||||
| 'web'
|
||||
|
||||
@@ -2,3 +2,4 @@ The icons in this folder and its subfolders come from the IntelliJ Platform (htt
|
||||
platform/icons/src/expui, Copyright 2000-2023 JetBrains s.r.o. and contributors,
|
||||
used under the Apache License 2.0 (LICENSE-APACHE-2.0.txt).
|
||||
memory.svg is profileMemory.svg with its profiling badge removed.
|
||||
theme.svg is the studio's own, drawn to match.
|
||||
@@ -0,0 +1,4 @@
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<circle cx="8" cy="8" r="6" stroke="#6C707E"/>
|
||||
<path d="M8 2.5C11.0376 2.5 13.5 4.96243 13.5 8C13.5 11.0376 11.0376 13.5 8 13.5V2.5Z" fill="#6C707E"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 254 B |
@@ -0,0 +1,4 @@
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<circle cx="8" cy="8" r="6" stroke="#CED0D6"/>
|
||||
<path d="M8 2.5C11.0376 2.5 13.5 4.96243 13.5 8C13.5 11.0376 11.0376 13.5 8 13.5V2.5Z" fill="#CED0D6"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 254 B |
@@ -18,9 +18,9 @@ import { SceneStudio } from './SceneStudio'
|
||||
import { WorldStudio3D } from './WorldStudio3D'
|
||||
import { isTypingInto, shortcutRows, viewOfShortcutId, windowShortcutFor, type ShortcutAction } from './shortcuts'
|
||||
import { ShortcutSettings } from './ShortcutSettings'
|
||||
import { Panel, SidebarPanel, SidebarSlot } from './Sidebar'
|
||||
import { Panel, SidebarPanel, SidebarSlot, ViewIsland } from './Sidebar'
|
||||
import { StatusBar } from './StatusBar'
|
||||
import { StudioToolbar } from './StudioToolbar'
|
||||
import { MapTools, StudioToolbar } from './StudioToolbar'
|
||||
import { useBindings } from './useBindings'
|
||||
import { usePickInspection } from './usePickInspection'
|
||||
import { ViewList } from './ViewList'
|
||||
@@ -213,20 +213,7 @@ export function MapStudio({ client, world, theme, onDisconnect }: MapStudioProps
|
||||
|
||||
return (
|
||||
<div className="flex h-full flex-col bg-background">
|
||||
<StudioToolbar
|
||||
title={view.label}
|
||||
world={world}
|
||||
toggles={toggles}
|
||||
hasPlayers={world.hasPlayers}
|
||||
mapTools={showsMap}
|
||||
theme={theme}
|
||||
onToggle={toggle}
|
||||
onRefresh={() => runShortcut('refresh')}
|
||||
onResetZoom={() => runShortcut('resetZoom')}
|
||||
onHelp={() => setHelpOpen(true)}
|
||||
onSettings={() => setSettingsOpen(true)}
|
||||
onDisconnect={onDisconnect}
|
||||
/>
|
||||
<StudioToolbar world={world} theme={theme} onHelp={() => setHelpOpen(true)} onSettings={() => setSettingsOpen(true)} onDisconnect={onDisconnect} />
|
||||
<SidebarSlot.Provider value={sidebarSlot}>
|
||||
<div className="flex min-h-0 flex-1 gap-1.5 p-1.5">
|
||||
<ViewList views={views} current={viewId} onSelect={selectView} slotRef={setSidebarSlot} />
|
||||
@@ -240,14 +227,25 @@ export function MapStudio({ client, world, theme, onDisconnect }: MapStudioProps
|
||||
) : patternView !== null ? (
|
||||
<PatternStudio client={client} view={patternView} packRevision={packRevision} onSummary={setSceneSummary} tell={tell} />
|
||||
) : viewId === WORLD_3D.id ? (
|
||||
<WorldStudio3D client={client} world={world} mapArea={area} packRevision={packRevision} onSummary={setSceneSummary} tell={tell} />
|
||||
<WorldStudio3D title={view.label} client={client} world={world} mapArea={area} packRevision={packRevision} onSummary={setSceneSummary} tell={tell} />
|
||||
) : viewId === SAVED_WORLD.id ? (
|
||||
<SavedWorldStudio client={client} world={world} onSummary={setSceneSummary} onProgress={setSceneProgress} tell={tell} />
|
||||
<SavedWorldStudio title={view.label} client={client} world={world} onSummary={setSceneSummary} onProgress={setSceneProgress} tell={tell} />
|
||||
) : viewId === NOISE.id ? (
|
||||
<NoiseStudio client={client} packRevision={packRevision} onSummary={setSceneSummary} tell={tell} />
|
||||
<NoiseStudio title={view.label} client={client} packRevision={packRevision} onSummary={setSceneSummary} tell={tell} />
|
||||
) : (
|
||||
<>
|
||||
<div className="relative min-w-0 flex-1 overflow-hidden rounded-lg">
|
||||
<ViewIsland
|
||||
title={previewName === null ? view.label : `${view.label} · ${previewName}`}
|
||||
tools={
|
||||
<MapTools
|
||||
toggles={toggles}
|
||||
hasPlayers={world.hasPlayers}
|
||||
onToggle={toggle}
|
||||
onRefresh={() => runShortcut('refresh')}
|
||||
onResetZoom={() => runShortcut('resetZoom')}
|
||||
/>
|
||||
}
|
||||
>
|
||||
<MapCanvas
|
||||
client={client}
|
||||
world={world}
|
||||
@@ -278,7 +276,7 @@ export function MapStudio({ client, world, theme, onDisconnect }: MapStudioProps
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</ViewIsland>
|
||||
<div className="flex w-[250px] shrink-0 flex-col gap-1.5">
|
||||
{inspectsPicks && (
|
||||
<Panel className="min-h-0 flex-[7]">
|
||||
|
||||
@@ -15,7 +15,8 @@ import { focusAround, type TerrainStyle } from '../scene/terrainStream'
|
||||
import { hexColor } from './colors'
|
||||
import { SceneViewport } from './SceneViewport'
|
||||
import { TiledCanvas } from './TiledCanvas'
|
||||
import { Panel, SidebarPanel } from './Sidebar'
|
||||
import { Separator } from '@/components/ui/separator'
|
||||
import { HEADER_CHOICE, Panel, SidebarPanel, ViewIsland } from './Sidebar'
|
||||
import { useLongPending, useTerrainStream } from './useTerrainStream'
|
||||
|
||||
type NoiseDisplay = 'flat' | 'terrain'
|
||||
@@ -30,10 +31,10 @@ const TALLEST_RELIEF_BLOCKS = 4064
|
||||
const DEFAULT_RELIEF_BLOCKS = 64
|
||||
const RELIEF_STEPS = 1000
|
||||
const SWATCH_STEPS = 24
|
||||
const TOGGLE_ITEM = 'h-7 px-3 text-[12px] data-[state=on]:bg-selection data-[state=on]:text-foreground'
|
||||
const PILL = 'pointer-events-none absolute rounded-md border border-overlay-border bg-card px-3 py-1.5 text-[12px] text-secondary-text'
|
||||
|
||||
interface NoiseStudioProps {
|
||||
title: string
|
||||
client: BridgeClient
|
||||
packRevision: number
|
||||
onSummary(summary: string | null): void
|
||||
@@ -41,7 +42,7 @@ interface NoiseStudioProps {
|
||||
}
|
||||
|
||||
/** The pack's noise and the built-in styles, from above or as terrain (v3e's noise explorer). */
|
||||
export function NoiseStudio({ client, packRevision, onSummary, tell }: NoiseStudioProps): React.JSX.Element {
|
||||
export function NoiseStudio({ title, client, packRevision, onSummary, tell }: NoiseStudioProps): React.JSX.Element {
|
||||
const sources = useNoiseSources(client, packRevision, tell)
|
||||
const [chosenId, setChosenId] = useState<string | null>(null)
|
||||
const source = sources.find((candidate) => candidate.id === chosenId) ?? sources[0] ?? null
|
||||
@@ -84,7 +85,28 @@ export function NoiseStudio({ client, packRevision, onSummary, tell }: NoiseStud
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="relative min-w-0 flex-1 overflow-hidden rounded-lg">
|
||||
<ViewIsland
|
||||
title={source === null ? title : `${title} · ${source.name}`}
|
||||
tools={
|
||||
<>
|
||||
{display === 'terrain' && source?.blockRange === null && <ReliefControl blocks={reliefBlocks} onChange={setReliefBlocks} />}
|
||||
{display === 'flat' && (
|
||||
<Button variant="ghost" size="icon-sm" className="size-7" title="Back to 0, 0" onClick={() => controllerRef.current?.resetView()}>
|
||||
<IdeIcon name="reset" />
|
||||
</Button>
|
||||
)}
|
||||
<Separator orientation="vertical" className="mx-1 h-4!" />
|
||||
<ToggleGroup type="single" size="sm" className="gap-0.5" value={display} onValueChange={(value) => value !== '' && showAs(value as NoiseDisplay)}>
|
||||
<ToggleGroupItem value="flat" className={HEADER_CHOICE} title="The noise from above, coloured by value">
|
||||
2D
|
||||
</ToggleGroupItem>
|
||||
<ToggleGroupItem value="terrain" className={HEADER_CHOICE} title="The noise as terrain">
|
||||
3D
|
||||
</ToggleGroupItem>
|
||||
</ToggleGroup>
|
||||
</>
|
||||
}
|
||||
>
|
||||
<TiledCanvas
|
||||
create={createView}
|
||||
viewRef={controllerRef}
|
||||
@@ -93,24 +115,8 @@ export function NoiseStudio({ client, packRevision, onSummary, tell }: NoiseStud
|
||||
{display === 'terrain' && source !== null && terrainFraming !== null && (
|
||||
<NoiseTerrainView client={client} source={source} seed={seed} revision={packRevision} framing={terrainFraming} scale={scale} reliefBlocks={reliefBlocks} tell={tell} />
|
||||
)}
|
||||
<div className="absolute top-3 left-3 flex items-center gap-2">
|
||||
<ToggleGroup type="single" variant="outline" size="sm" className="bg-card" value={display} onValueChange={(value) => value !== '' && showAs(value as NoiseDisplay)}>
|
||||
<ToggleGroupItem value="flat" className={TOGGLE_ITEM} title="The noise from above, coloured by value">
|
||||
2D
|
||||
</ToggleGroupItem>
|
||||
<ToggleGroupItem value="terrain" className={TOGGLE_ITEM} title="The noise as terrain">
|
||||
3D
|
||||
</ToggleGroupItem>
|
||||
</ToggleGroup>
|
||||
{display === 'flat' && (
|
||||
<Button variant="outline" size="icon-sm" className="bg-card" title="Back to 0, 0" onClick={() => controllerRef.current?.resetView()}>
|
||||
<IdeIcon name="reset" />
|
||||
</Button>
|
||||
)}
|
||||
{display === 'terrain' && source?.blockRange === null && <ReliefControl blocks={reliefBlocks} onChange={setReliefBlocks} />}
|
||||
</div>
|
||||
{display === 'flat' && status !== null && source !== null && <div className={cn(PILL, 'right-3 bottom-3 tabular-nums')}>{readout(status, source)}</div>}
|
||||
</div>
|
||||
</ViewIsland>
|
||||
<SidebarPanel className="flex-1">
|
||||
<header className="px-4 pt-2.5 pb-2.5">
|
||||
<h2 className="text-[13px] font-semibold">Noise</h2>
|
||||
@@ -261,7 +267,7 @@ function ReliefControl({ blocks, onChange }: { blocks: number; onChange(blocks:
|
||||
const span = Math.log(TALLEST_RELIEF_BLOCKS) - Math.log(LOWEST_RELIEF_BLOCKS)
|
||||
const step = Math.round(((Math.log(blocks) - Math.log(LOWEST_RELIEF_BLOCKS)) / span) * RELIEF_STEPS)
|
||||
return (
|
||||
<label className="flex h-8 items-center gap-2 rounded-md border bg-card px-3 text-[12px] text-secondary-text" title="How many blocks the highest noise rises above the lowest">
|
||||
<label className="flex h-7 items-center gap-2 px-2 text-[12px] text-secondary-text" title="How many blocks the highest noise rises above the lowest">
|
||||
Relief
|
||||
<input
|
||||
type="range"
|
||||
|
||||
@@ -11,7 +11,7 @@ import { BlockModels } from '../scene/blockModels'
|
||||
import { BridgeAssets } from '../scene/BridgeAssets'
|
||||
import { BlockIcon } from './BlockIcon'
|
||||
import { EntryBrowser } from './EntryBrowser'
|
||||
import { Panel, SidebarPanel } from './Sidebar'
|
||||
import { Panel, SidebarPanel, Stepper, ViewIsland } from './Sidebar'
|
||||
import { TiledCanvas } from './TiledCanvas'
|
||||
|
||||
const DEFAULT_NAMESPACE_PREFIX = 'minecraft:'
|
||||
@@ -62,28 +62,22 @@ export function PatternStudio({ client, view, packRevision, onSummary, tell }: P
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="relative min-w-0 flex-1 overflow-hidden rounded-lg">
|
||||
<ViewIsland
|
||||
title={entry === null ? view.label : `${view.label} · ${entry.name}`}
|
||||
tools={
|
||||
<>
|
||||
{entry !== null && entry.depths > 1 && (
|
||||
<Stepper label={`Depth ${depth + 1} of ${entry.depths}`} backHint="Higher" onHint="Deeper" onBack={() => chooseDepth(depth - 1)} onOn={() => chooseDepth(depth + 1)} />
|
||||
)}
|
||||
<Button variant="ghost" size="icon-sm" className="size-7" title="Back to 0, 0" onClick={() => viewRef.current?.resetView()}>
|
||||
<IdeIcon name="reset" />
|
||||
</Button>
|
||||
</>
|
||||
}
|
||||
>
|
||||
<TiledCanvas create={createView} viewRef={viewRef} className="absolute inset-0 size-full cursor-grab active:cursor-grabbing" />
|
||||
<div className="absolute top-3 left-3 flex items-center gap-1 rounded-md border border-overlay-border bg-card p-1 text-[12px] tabular-nums">
|
||||
{entry !== null && entry.depths > 1 && (
|
||||
<>
|
||||
<Button variant="ghost" size="icon-sm" title="Higher" onClick={() => chooseDepth(depth - 1)}>
|
||||
<IdeIcon name="chevronLeft" />
|
||||
</Button>
|
||||
<span className="px-1">
|
||||
Depth {depth + 1} of {entry.depths}
|
||||
</span>
|
||||
<Button variant="ghost" size="icon-sm" title="Deeper" onClick={() => chooseDepth(depth + 1)}>
|
||||
<IdeIcon name="chevronRight" />
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
<Button variant="ghost" size="icon-sm" title="Back to 0, 0" onClick={() => viewRef.current?.resetView()}>
|
||||
<IdeIcon name="reset" />
|
||||
</Button>
|
||||
</div>
|
||||
{status !== null && entry !== null && <div className={cn(PILL, 'right-3 bottom-3 tabular-nums')}>{readout(status)}</div>}
|
||||
</div>
|
||||
</ViewIsland>
|
||||
<SidebarPanel className="flex-1">
|
||||
<EntryBrowser className="flex-1" title={view.label} entries={entries} current={entry?.key ?? null} onSelect={(key) => setChosen({ key, depth: 0 })} />
|
||||
</SidebarPanel>
|
||||
|
||||
@@ -16,16 +16,17 @@ import { savedTileSource, type SavedLayer } from '../scene/savedTileSource'
|
||||
import { TerrainAtlas } from '../scene/terrainAtlas'
|
||||
import { focusAround, type TerrainStyle } from '../scene/terrainStream'
|
||||
import { SceneViewport } from './SceneViewport'
|
||||
import { SidebarPanel } from './Sidebar'
|
||||
import { Separator } from '@/components/ui/separator'
|
||||
import { HEADER_CHOICE, SidebarPanel, ViewIsland } from './Sidebar'
|
||||
import { useTerrainStream } from './useTerrainStream'
|
||||
|
||||
const NUMBER = new Intl.NumberFormat('en-US')
|
||||
// Saved tiles are read at up to 16 blocks a pixel, which is level 4.
|
||||
const COARSEST_SAVED_LEVEL = 4
|
||||
const COLORING_ITEM = 'h-7 px-3 text-[12px] data-[state=on]:bg-selection data-[state=on]:text-foreground'
|
||||
const PILL = 'pointer-events-none absolute top-3 left-1/2 -translate-x-1/2 rounded-md border border-overlay-border bg-card px-3 py-1.5 text-[12px] text-secondary-text'
|
||||
|
||||
interface SavedWorldStudioProps {
|
||||
title: string
|
||||
client: BridgeClient
|
||||
/** The studio's own world, whose saved copy is chosen first. */
|
||||
world: WorldInfo
|
||||
@@ -36,7 +37,7 @@ interface SavedWorldStudioProps {
|
||||
}
|
||||
|
||||
/** A world as its region files hold it, in 3D, around the region nearest its origin (v3e's saved world explorer). */
|
||||
export function SavedWorldStudio({ client, world, onSummary, onProgress, tell }: SavedWorldStudioProps): React.JSX.Element {
|
||||
export function SavedWorldStudio({ title, client, world, onSummary, onProgress, tell }: SavedWorldStudioProps): React.JSX.Element {
|
||||
const worlds = useSavedWorlds(client, tell)
|
||||
const [chosenId, setChosenId] = useState<string | null>(null)
|
||||
const chosen = worlds.find((candidate) => candidate.id === chosenId) ?? ownWorldAmong(worlds, world) ?? worlds[0] ?? null
|
||||
@@ -86,34 +87,32 @@ export function SavedWorldStudio({ client, world, onSummary, onProgress, tell }:
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="relative min-w-0 flex-1 overflow-hidden rounded-lg">
|
||||
<ViewIsland
|
||||
title={chosen === null ? title : `${title} · ${chosen.name}`}
|
||||
tools={
|
||||
<>
|
||||
<ToggleGroup type="single" size="sm" className="gap-0.5" value={coloring} onValueChange={(value) => value !== '' && setColoring(value as SavedTerrainColoring)}>
|
||||
<ToggleGroupItem value="biomes" className={HEADER_CHOICE}>
|
||||
Biomes
|
||||
</ToggleGroupItem>
|
||||
<ToggleGroupItem value="blocks" className={HEADER_CHOICE}>
|
||||
Blocks
|
||||
</ToggleGroupItem>
|
||||
<ToggleGroupItem value="height" className={HEADER_CHOICE}>
|
||||
Height
|
||||
</ToggleGroupItem>
|
||||
</ToggleGroup>
|
||||
<Separator orientation="vertical" className="mx-1 h-4!" />
|
||||
<Button variant="ghost" size="icon-sm" className="size-7" title="Read again" disabled={reading} onClick={() => setReadings((count) => count + 1)}>
|
||||
<IdeIcon name="refresh" />
|
||||
</Button>
|
||||
</>
|
||||
}
|
||||
>
|
||||
<SceneViewport content={content} framing={content} />
|
||||
<div className="absolute top-3 left-3 flex items-center gap-2">
|
||||
<ToggleGroup
|
||||
type="single"
|
||||
variant="outline"
|
||||
size="sm"
|
||||
className="bg-card"
|
||||
value={coloring}
|
||||
onValueChange={(value) => value !== '' && setColoring(value as SavedTerrainColoring)}
|
||||
>
|
||||
<ToggleGroupItem value="biomes" className={COLORING_ITEM}>
|
||||
Biomes
|
||||
</ToggleGroupItem>
|
||||
<ToggleGroupItem value="blocks" className={COLORING_ITEM}>
|
||||
Blocks
|
||||
</ToggleGroupItem>
|
||||
<ToggleGroupItem value="height" className={COLORING_ITEM}>
|
||||
Height
|
||||
</ToggleGroupItem>
|
||||
</ToggleGroup>
|
||||
<Button variant="outline" size="icon-sm" className="bg-card" title="Read again" disabled={reading} onClick={() => setReadings((count) => count + 1)}>
|
||||
<IdeIcon name="refresh" />
|
||||
</Button>
|
||||
</div>
|
||||
{reading && chosen !== null && <div className={PILL}>Reading {chosen.name}</div>}
|
||||
{!reading && chosen !== null && start === null && <div className={PILL}>Nothing finished is saved in {chosen.name}</div>}
|
||||
</div>
|
||||
</ViewIsland>
|
||||
<SidebarPanel className="flex-1">
|
||||
<header className="px-4 pt-2.5 pb-2.5">
|
||||
<h2 className="text-[13px] font-semibold">Saved worlds</h2>
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { IdeIcon } from '@/components/IdeIcon'
|
||||
import { useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { ScrollArea } from '@/components/ui/scroll-area'
|
||||
@@ -22,7 +21,7 @@ import { EntryBrowser } from './EntryBrowser'
|
||||
import { useEntryFiles } from './EntryFileDialogs'
|
||||
import { NodeInspector } from './NodeInspector'
|
||||
import { NodePane } from './NodePane'
|
||||
import { Panel, SidebarPanel } from './Sidebar'
|
||||
import { Panel, SidebarPanel, Stepper, ViewIsland } from './Sidebar'
|
||||
import { SceneViewport, type PickedSurface } from './SceneViewport'
|
||||
|
||||
const NUMBER = new Intl.NumberFormat('en-US')
|
||||
@@ -119,6 +118,7 @@ export function SceneStudio({ client, view, packRevision, onSummary, tell }: Sce
|
||||
</SidebarPanel>
|
||||
<div className="flex min-w-0 flex-1 flex-col gap-1.5">
|
||||
<SceneArea
|
||||
title={view.label}
|
||||
entry={entry}
|
||||
variant={variant}
|
||||
shown={shown}
|
||||
@@ -151,6 +151,8 @@ export function SceneStudio({ client, view, packRevision, onSummary, tell }: Sce
|
||||
}
|
||||
|
||||
interface SceneAreaProps {
|
||||
/** What the island is called while no entry is chosen. */
|
||||
title: string
|
||||
entry: SceneEntry | null
|
||||
variant: number
|
||||
shown: ShownScene | null
|
||||
@@ -161,29 +163,31 @@ interface SceneAreaProps {
|
||||
onPick?(picked: PickedSurface): void
|
||||
}
|
||||
|
||||
function SceneArea({ entry, variant, shown, status, onVariant, onPick }: SceneAreaProps): React.JSX.Element {
|
||||
function SceneArea({ title, entry, variant, shown, status, onVariant, onPick }: SceneAreaProps): React.JSX.Element {
|
||||
return (
|
||||
<div className="relative min-h-0 flex-[11] overflow-hidden rounded-lg">
|
||||
<ViewIsland
|
||||
className="flex-[11]"
|
||||
title={entry === null ? title : entry.name}
|
||||
tools={
|
||||
entry !== null &&
|
||||
entry.variants > 1 && (
|
||||
<Stepper
|
||||
label={`Variant ${variant + 1} of ${entry.variants}`}
|
||||
backHint="Previous variant"
|
||||
onHint="Next variant"
|
||||
onBack={() => onVariant(variant - 1)}
|
||||
onOn={() => onVariant(variant + 1)}
|
||||
/>
|
||||
)
|
||||
}
|
||||
>
|
||||
<SceneViewport content={shown?.mesh.content ?? null} framing={shown?.scene} onPick={onPick} />
|
||||
{entry !== null && entry.variants > 1 && (
|
||||
<div className="absolute top-3 left-3 flex items-center gap-1 rounded-md border border-overlay-border bg-card p-1 text-[12px] tabular-nums">
|
||||
<Button variant="ghost" size="icon-sm" title="Previous variant" onClick={() => onVariant(variant - 1)}>
|
||||
<IdeIcon name="chevronLeft" />
|
||||
</Button>
|
||||
<span className="px-1">
|
||||
Variant {variant + 1} of {entry.variants}
|
||||
</span>
|
||||
<Button variant="ghost" size="icon-sm" title="Next variant" onClick={() => onVariant(variant + 1)}>
|
||||
<IdeIcon name="chevronRight" />
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
{status !== null && (
|
||||
<div className="pointer-events-none absolute top-3 left-1/2 -translate-x-1/2 rounded-md border border-overlay-border bg-card px-3 py-1.5 text-[12px] text-secondary-text">
|
||||
{status}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</ViewIsland>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { createContext, useContext } from 'react'
|
||||
import { createPortal } from 'react-dom'
|
||||
import { IdeIcon } from '@/components/IdeIcon'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
/** Where a view puts its own lists: under the views in the left island, as in v3e. */
|
||||
@@ -14,6 +16,55 @@ export function SidebarPanel({ className, children }: { className?: string; chil
|
||||
return createPortal(<section className={cn('flex min-h-0 flex-col overflow-hidden', className)}>{children}</section>, slot)
|
||||
}
|
||||
|
||||
/** One choice of a switch in an island's header: plain until chosen, like the header's other buttons. */
|
||||
export const HEADER_CHOICE = 'h-7 flex-none rounded-md! px-2.5 text-[12.5px] font-normal hover:bg-accent hover:text-foreground data-[state=on]:bg-selection data-[state=on]:text-foreground'
|
||||
|
||||
interface StepperProps {
|
||||
/** Where the steps are now: "Variant 2 of 5". */
|
||||
label: string
|
||||
backHint: string
|
||||
onHint: string
|
||||
onBack(): void
|
||||
onOn(): void
|
||||
}
|
||||
|
||||
/** Steps through numbered things from an island's header. */
|
||||
export function Stepper({ label, backHint, onHint, onBack, onOn }: StepperProps): React.JSX.Element {
|
||||
return (
|
||||
<span className="flex items-center text-[12px] text-secondary-text tabular-nums">
|
||||
<Button variant="ghost" size="icon-sm" className="size-7" title={backHint} onClick={onBack}>
|
||||
<IdeIcon name="chevronLeft" />
|
||||
</Button>
|
||||
<span className="px-1">{label}</span>
|
||||
<Button variant="ghost" size="icon-sm" className="size-7" title={onHint} onClick={onOn}>
|
||||
<IdeIcon name="chevronRight" />
|
||||
</Button>
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
||||
interface ViewIslandProps {
|
||||
title: string
|
||||
/** The view's own buttons, at the right of its header. */
|
||||
tools?: React.ReactNode
|
||||
className?: string
|
||||
children: React.ReactNode
|
||||
}
|
||||
|
||||
/** The island a view draws in, under a header with the view's name and its tools, as an IntelliJ tool window has. */
|
||||
export function ViewIsland({ title, tools, className, children }: ViewIslandProps): React.JSX.Element {
|
||||
return (
|
||||
<section className={cn('flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden rounded-lg bg-card', className)}>
|
||||
<header className="flex h-9 shrink-0 items-center gap-1 pr-1.5 pl-3">
|
||||
<h2 className="truncate text-[13px] font-semibold">{title}</h2>
|
||||
<span className="flex-1" />
|
||||
{tools}
|
||||
</header>
|
||||
<div className="relative min-h-0 flex-1 overflow-hidden">{children}</div>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
/** A card in the shell: the panels sit apart on the window background instead of sharing borders. */
|
||||
export function Panel({ className, children }: { className?: string; children: React.ReactNode }): React.JSX.Element {
|
||||
return <aside className={cn('flex shrink-0 flex-col overflow-hidden rounded-lg bg-card', className)}>{children}</aside>
|
||||
|
||||
@@ -12,82 +12,82 @@ import type { ShortcutAction } from './shortcuts'
|
||||
import { useKeyText } from './useBindings'
|
||||
|
||||
interface StudioToolbarProps {
|
||||
title: string
|
||||
world: WorldInfo
|
||||
toggles: StudioToggles
|
||||
hasPlayers: boolean
|
||||
/** Whether the map's buttons apply: a scene view has no map to redraw, zoom or overlay. */
|
||||
mapTools: boolean
|
||||
theme: { choice: ThemeChoice; next: () => void }
|
||||
onToggle(name: keyof StudioToggles): void
|
||||
onRefresh(): void
|
||||
onResetZoom(): void
|
||||
onHelp(): void
|
||||
onSettings(): void
|
||||
onDisconnect(): void
|
||||
}
|
||||
|
||||
const THEME_NAMES: Record<ThemeChoice, string> = { system: 'Theme: system', light: 'Theme: light', dark: 'Theme: dark' }
|
||||
const TEXT_BUTTON = "h-7 gap-1.5 px-2 text-[12.5px] font-normal [&_svg:not([class*='size-'])]:size-3.5"
|
||||
|
||||
export function StudioToolbar(props: StudioToolbarProps): React.JSX.Element {
|
||||
/** The window's bar: the world the studio is connected to, which leads back to the world list, and the studio's own buttons. */
|
||||
export function StudioToolbar({ world, theme, onHelp, onSettings, onDisconnect }: StudioToolbarProps): React.JSX.Element {
|
||||
return (
|
||||
<header className="flex h-10 shrink-0 items-center gap-1 px-2">
|
||||
<span className="px-1.5 pr-3 text-[14px] font-semibold">{props.title}</span>
|
||||
{props.mapTools && <MapTools {...props} />}
|
||||
|
||||
<div className="flex-1" />
|
||||
<span className="truncate px-2 text-[12px] text-secondary-text" title={`${props.world.dimensionName} · seed ${props.world.seed}`}>
|
||||
{props.world.world}
|
||||
</span>
|
||||
<IconHint hint={THEME_NAMES[props.theme.choice]}>
|
||||
<Button variant="ghost" size="sm" className={TEXT_BUTTON} onClick={props.theme.next}>
|
||||
Theme
|
||||
<IconHint hint="Back to the world list">
|
||||
<Button variant="ghost" size="sm" className="h-7 max-w-[50%] gap-2 px-1.5 text-[13px] font-medium" 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)}
|
||||
</span>
|
||||
<span className="truncate">{world.world}</span>
|
||||
<span className="truncate font-normal text-secondary-text">{world.dimensionName}</span>
|
||||
<IdeIcon name="chevronRight" className="size-3.5 rotate-90" />
|
||||
</Button>
|
||||
</IconHint>
|
||||
<ToolButton action="help" hint="Show every mouse and key shortcut" onClick={props.onHelp}>
|
||||
<div className="flex-1" />
|
||||
<IconHint hint={THEME_NAMES[theme.choice]}>
|
||||
<Button variant="ghost" size="icon-sm" onClick={theme.next}>
|
||||
<IdeIcon name="theme" />
|
||||
</Button>
|
||||
</IconHint>
|
||||
<ToolButton action="help" hint="Show every mouse and key shortcut" onClick={onHelp}>
|
||||
<IdeIcon name="help" />
|
||||
</ToolButton>
|
||||
<IconHint hint="Change the studio's keys">
|
||||
<Button variant="ghost" size="icon-sm" onClick={props.onSettings}>
|
||||
<Button variant="ghost" size="icon-sm" onClick={onSettings}>
|
||||
<IdeIcon name="settings" />
|
||||
</Button>
|
||||
</IconHint>
|
||||
<IconHint hint="Back to the world list">
|
||||
<Button variant="ghost" size="icon-sm" onClick={props.onDisconnect}>
|
||||
<IdeIcon name="exit" />
|
||||
</Button>
|
||||
</IconHint>
|
||||
</header>
|
||||
)
|
||||
}
|
||||
|
||||
function MapTools(props: StudioToolbarProps): React.JSX.Element {
|
||||
const { toggles, onToggle } = props
|
||||
interface MapToolsProps {
|
||||
toggles: StudioToggles
|
||||
hasPlayers: boolean
|
||||
onToggle(name: keyof StudioToggles): void
|
||||
onRefresh(): void
|
||||
onResetZoom(): void
|
||||
}
|
||||
|
||||
/** The map's own buttons, for the header of its island. */
|
||||
export function MapTools({ toggles, hasPlayers, onToggle, onRefresh, onResetZoom }: MapToolsProps): React.JSX.Element {
|
||||
return (
|
||||
<>
|
||||
<ToolButton action="refresh" hint="Redraw the map with the latest pack files" onClick={props.onRefresh}>
|
||||
<IdeIcon name="refresh" />
|
||||
</ToolButton>
|
||||
<ToolButton action="resetZoom" hint="Go back to the default zoom" onClick={props.onResetZoom}>
|
||||
<IdeIcon name="zoomIn" />
|
||||
</ToolButton>
|
||||
<ToolToggle action="grid" hint="Show chunk and region borders" pressed={toggles.grid} onPressed={() => onToggle('grid')}>
|
||||
<IdeIcon name="grid" className="size-3.5" /> Grid
|
||||
</ToolToggle>
|
||||
<ToolToggle action="entities" hint="Show mobs and other entities" pressed={toggles.entities} disabled={!props.hasPlayers} onPressed={() => onToggle('entities')}>
|
||||
<IdeIcon name="user" className="size-3.5" /> Entities
|
||||
</ToolToggle>
|
||||
<ToolToggle action="follow" hint="Keep your player in the middle" pressed={toggles.follow} disabled={!props.hasPlayers} onPressed={() => onToggle('follow')}>
|
||||
<IdeIcon name="locate" className="size-3.5" /> Follow
|
||||
</ToolToggle>
|
||||
<Separator orientation="vertical" className="mx-1 h-5! bg-input" />
|
||||
<ToolToggle action="shading" hint="Shade hills and valleys" pressed={toggles.shading} onPressed={() => onToggle('shading')}>
|
||||
<IdeIcon name="views/height" className="size-3.5" /> Shading
|
||||
</ToolToggle>
|
||||
<ToolToggle action="borders" hint="Outline the regions on every view" pressed={toggles.regionBorders} onPressed={() => onToggle('regionBorders')}>
|
||||
<IdeIcon name="views/regions" className="size-3.5" /> Borders
|
||||
</ToolToggle>
|
||||
<ToolToggle action="shading" hint="Shade hills and valleys" pressed={toggles.shading} onPressed={() => onToggle('shading')}>
|
||||
<IdeIcon name="views/height" className="size-3.5" /> Shading
|
||||
</ToolToggle>
|
||||
<Separator orientation="vertical" className="mx-1 h-4!" />
|
||||
<ToolToggle action="entities" hint="Show mobs and other entities" pressed={toggles.entities} disabled={!hasPlayers} onPressed={() => onToggle('entities')}>
|
||||
<IdeIcon name="user" className="size-3.5" /> Entities
|
||||
</ToolToggle>
|
||||
<ToolToggle action="follow" hint="Keep your player in the middle" pressed={toggles.follow} disabled={!hasPlayers} onPressed={() => onToggle('follow')}>
|
||||
<IdeIcon name="locate" className="size-3.5" /> Follow
|
||||
</ToolToggle>
|
||||
<Separator orientation="vertical" className="mx-1 h-4!" />
|
||||
<ToolButton action="resetZoom" hint="Go back to the default zoom" onClick={onResetZoom}>
|
||||
<IdeIcon name="zoomIn" />
|
||||
</ToolButton>
|
||||
<ToolButton action="refresh" hint="Redraw the map with the latest pack files" onClick={onRefresh}>
|
||||
<IdeIcon name="refresh" />
|
||||
</ToolButton>
|
||||
</>
|
||||
)
|
||||
}
|
||||
@@ -108,7 +108,7 @@ function ToolButton({ action, hint, onClick, children }: { action: ShortcutActio
|
||||
const keyText = useKeyText()
|
||||
return (
|
||||
<IconHint hint={hint} keyText={keyText(action)}>
|
||||
<Button variant="ghost" size="icon-sm" onClick={onClick}>
|
||||
<Button variant="ghost" size="icon-sm" className="size-7" onClick={onClick}>
|
||||
{children}
|
||||
</Button>
|
||||
</IconHint>
|
||||
@@ -134,7 +134,7 @@ function ToolToggle({ action, hint, pressed, disabled, onPressed, children }: To
|
||||
pressed={pressed}
|
||||
disabled={disabled}
|
||||
onPressedChange={onPressed}
|
||||
className="h-7 gap-1.5 px-2 text-[12.5px] font-normal data-[state=on]:bg-selection data-[state=on]:text-foreground [&_svg:not([class*='size-'])]:size-3.5"
|
||||
className="h-7 gap-1.5 px-2 text-[12.5px] font-normal hover:bg-accent hover:text-foreground data-[state=on]:bg-selection data-[state=on]:text-foreground [&_svg:not([class*='size-'])]:size-3.5"
|
||||
>
|
||||
{children}
|
||||
</Toggle>
|
||||
|
||||
@@ -37,7 +37,7 @@ export function ViewList({ views, current, onSelect, slotRef }: ViewListProps):
|
||||
<nav className="flex shrink-0 flex-col gap-2 overflow-y-auto p-1.5">
|
||||
{groups.map((group) => (
|
||||
<section key={group}>
|
||||
<h2 className="px-2 pt-1 pb-1 text-[10.5px] font-semibold tracking-wider text-muted-foreground uppercase">{group}</h2>
|
||||
<h2 className="px-2 pt-1 pb-1 text-[11px] font-semibold text-muted-foreground">{group}</h2>
|
||||
{views
|
||||
.filter((view) => view.groupLabel === group)
|
||||
.map((view) => (
|
||||
|
||||
@@ -12,7 +12,7 @@ import { Legend } from './Legend'
|
||||
import { PickInspector } from './PickInspector'
|
||||
import { SceneViewport } from './SceneViewport'
|
||||
import { usePickInspection } from './usePickInspection'
|
||||
import { Panel } from './Sidebar'
|
||||
import { HEADER_CHOICE, Panel, ViewIsland } from './Sidebar'
|
||||
import { useGroundInView, useLongPending, useTerrainStream } from './useTerrainStream'
|
||||
|
||||
const NUMBER = new Intl.NumberFormat('en-US')
|
||||
@@ -20,9 +20,9 @@ const NUMBER = new Intl.NumberFormat('en-US')
|
||||
const COARSEST_LEVEL = 12
|
||||
const BLOCKS_ABOVE_FLUID_IN_FOCUS = 96
|
||||
const BLOCKS_BELOW_FLUID_IN_FOCUS = 32
|
||||
const COLORING_ITEM = 'h-7 px-3 text-[12px] data-[state=on]:bg-selection data-[state=on]:text-foreground'
|
||||
|
||||
interface WorldStudio3DProps {
|
||||
title: string
|
||||
client: BridgeClient
|
||||
world: WorldInfo
|
||||
/** Where the map last looked; the terrain opens around its middle, or around the world's centre. */
|
||||
@@ -36,7 +36,7 @@ interface WorldStudio3DProps {
|
||||
* The terrain around where the map looked, in 3D and without an edge, coloured by biome, region or height, beside how
|
||||
* the noise picks the biomes or regions the camera sees, or how much of that ground lies at each height (v3e's 3D world view).
|
||||
*/
|
||||
export function WorldStudio3D({ client, world, mapArea, packRevision, onSummary, tell }: WorldStudio3DProps): React.JSX.Element {
|
||||
export function WorldStudio3D({ title, client, world, mapArea, packRevision, onSummary, tell }: WorldStudio3DProps): React.JSX.Element {
|
||||
const [coloring, setColoring] = useState<MapTerrainColoring>('biomes')
|
||||
const centre = useMemo(() => centreOf(mapArea), [mapArea])
|
||||
const source = useMemo(() => mapTileSource(client, TILE_COLUMNS), [client])
|
||||
@@ -69,32 +69,29 @@ export function WorldStudio3D({ client, world, mapArea, packRevision, onSummary,
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="relative min-w-0 flex-1 overflow-hidden rounded-lg">
|
||||
<ViewIsland
|
||||
title={title}
|
||||
tools={
|
||||
<ToggleGroup type="single" size="sm" className="gap-0.5" value={coloring} onValueChange={(value) => value !== '' && setColoring(value as MapTerrainColoring)}>
|
||||
<ToggleGroupItem value="biomes" className={HEADER_CHOICE}>
|
||||
Biomes
|
||||
</ToggleGroupItem>
|
||||
<ToggleGroupItem value="regions" className={HEADER_CHOICE}>
|
||||
Regions
|
||||
</ToggleGroupItem>
|
||||
<ToggleGroupItem value="height" className={HEADER_CHOICE}>
|
||||
Height
|
||||
</ToggleGroupItem>
|
||||
</ToggleGroup>
|
||||
}
|
||||
>
|
||||
<SceneViewport content={content} framing={content} />
|
||||
<ToggleGroup
|
||||
type="single"
|
||||
variant="outline"
|
||||
size="sm"
|
||||
className="absolute top-3 left-3 bg-card"
|
||||
value={coloring}
|
||||
onValueChange={(value) => value !== '' && setColoring(value as MapTerrainColoring)}
|
||||
>
|
||||
<ToggleGroupItem value="biomes" className={COLORING_ITEM}>
|
||||
Biomes
|
||||
</ToggleGroupItem>
|
||||
<ToggleGroupItem value="regions" className={COLORING_ITEM}>
|
||||
Regions
|
||||
</ToggleGroupItem>
|
||||
<ToggleGroupItem value="height" className={COLORING_ITEM}>
|
||||
Height
|
||||
</ToggleGroupItem>
|
||||
</ToggleGroup>
|
||||
{sampling && (
|
||||
<div className="pointer-events-none absolute top-3 left-1/2 -translate-x-1/2 rounded-md border border-overlay-border bg-card px-3 py-1.5 text-[12px] text-secondary-text">
|
||||
Sampling the terrain
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</ViewIsland>
|
||||
<Panel className="w-[250px]">
|
||||
{inspectsPicks ? (
|
||||
<PickInspector title={coloring === 'regions' ? 'Regions' : 'Biomes'} inspection={inspection} />
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
--secondary: #393b40;
|
||||
--secondary-foreground: #dfe1e5;
|
||||
--muted: #2b2d30;
|
||||
--muted-foreground: #6f737a;
|
||||
--muted-foreground: #868a91;
|
||||
--secondary-text: #9da0a8;
|
||||
--accent: #393b40;
|
||||
--accent-foreground: #dfe1e5;
|
||||
|
||||
Reference in new issue
Block a user