diff --git a/studio/src/renderer/src/bridge/types.ts b/studio/src/renderer/src/bridge/types.ts index fd440af25..c1a8c6e3a 100644 --- a/studio/src/renderer/src/bridge/types.ts +++ b/studio/src/renderer/src/bridge/types.ts @@ -3,7 +3,8 @@ import type { BlockLook } from '../scene/blockLooks' import type { CoverLook } from '../scene/coverLooks' -export type LabelKind = 'BIOME' | 'REGION' +/** WATER is a hydrology feature in the river view, such as a stream or a lake. */ +export type LabelKind = 'BIOME' | 'REGION' | 'WATER' export interface MapLabel { kind: LabelKind @@ -236,6 +237,8 @@ export interface WorldInfo { fluidHeight: number tileSize: number hasPlayers: boolean + /** Whether the dimension plans water; without it the river view has nothing to show. */ + hydrology: boolean views: ViewInfo[] } diff --git a/studio/src/renderer/src/components/IdeIcon.tsx b/studio/src/renderer/src/components/IdeIcon.tsx index beaa821e8..3fe42edd7 100644 --- a/studio/src/renderer/src/components/IdeIcon.tsx +++ b/studio/src/renderer/src/components/IdeIcon.tsx @@ -41,6 +41,7 @@ export type IdeIconName = | 'views/palettes' | 'views/procedural' | 'views/regions' + | 'views/rivers' | 'views/saved-world' | 'views/world-3d' diff --git a/studio/src/renderer/src/icons/views/rivers.svg b/studio/src/renderer/src/icons/views/rivers.svg new file mode 100644 index 000000000..a38c67edb --- /dev/null +++ b/studio/src/renderer/src/icons/views/rivers.svg @@ -0,0 +1,4 @@ + + + + diff --git a/studio/src/renderer/src/icons/views/rivers_dark.svg b/studio/src/renderer/src/icons/views/rivers_dark.svg new file mode 100644 index 000000000..5ca99ca0e --- /dev/null +++ b/studio/src/renderer/src/icons/views/rivers_dark.svg @@ -0,0 +1,4 @@ + + + + diff --git a/studio/src/renderer/src/map/census.ts b/studio/src/renderer/src/map/census.ts index 7a00c1a7b..f4e436142 100644 --- a/studio/src/renderer/src/map/census.ts +++ b/studio/src/renderer/src/map/census.ts @@ -44,7 +44,7 @@ export function countShares(tiles: PlacedTile[], area: WorldArea): Share[] { for (let pixelZ = firstZ; pixelZ < endZ; pixelZ += stride) { for (let pixelX = firstX; pixelX < endX; pixelX += stride) { const subject = subjectAt(tile, gridIndex(tile, pixelX, pixelZ)) - if (subject === null) { + if (subject === null || isDryGround(subject.subject)) { continue } const id = `${subject.subject.kind}:${subject.subject.key}` @@ -75,6 +75,11 @@ export function heightBandShares(heights: readonly number[], seaLevel: number): }) } +/** The river view's label for ground without water, which the legend does not list. */ +function isDryGround(subject: Highlight): boolean { + return subject.kind === 'WATER' && subject.key === 'dry' +} + function subjectAt(tile: MapTile, cell: number): { subject: Highlight; color: number } | null { const index = tile.subjects[cell] if (index === NO_LABEL) { diff --git a/studio/src/renderer/src/map/tileStyle.ts b/studio/src/renderer/src/map/tileStyle.ts index 229f4a60a..fd1503d2a 100644 --- a/studio/src/renderer/src/map/tileStyle.ts +++ b/studio/src/renderer/src/map/tileStyle.ts @@ -7,7 +7,7 @@ const WATER_OVER_GROUND = 0.65 /** What a highlight picks out: a biome or region by key, or a height band in the 3D world's legend. */ export interface Highlight { - kind: 'BIOME' | 'REGION' | 'HEIGHT' + kind: 'BIOME' | 'REGION' | 'WATER' | 'HEIGHT' key: string name: string } diff --git a/studio/src/renderer/src/studio/MapStudio.tsx b/studio/src/renderer/src/studio/MapStudio.tsx index ec7682bfd..21de9f47a 100644 --- a/studio/src/renderer/src/studio/MapStudio.tsx +++ b/studio/src/renderer/src/studio/MapStudio.tsx @@ -5,6 +5,7 @@ import type { MapHover, MapLabel, Marker, ModuleViewInfo, PickDisplay, ServerUsa import type { Share } from '../map/census' import type { MapController, MapStatus, MapToggles } from '../map/MapController' import type { Highlight } from '../map/tileStyle' +import { IdeIcon } from '@/components/IdeIcon' import { HelpDialog } from './HelpDialog' import { HoverCard } from './HoverCard' import { Legend } from './Legend' @@ -73,7 +74,7 @@ export function MapStudio({ client, world, theme, onDisconnect }: MapStudioProps const sceneViews = useModuleViews(loadSceneViews, packRevision) const patternViews = useModuleViews(loadPatternViews, packRevision) const views = useMemo( - () => [...withAppViews(world.views), ...patternViews.map(asViewInfo), ...sceneViews.map(asViewInfo), NOISE], + () => [...withAppViews(world.views), ...patternViews.map(asViewInfo), ...sceneViews.map(asViewInfo)], [world.views, patternViews, sceneViews] ) const sceneView = sceneViews.find((candidate) => candidate.id === viewId) ?? null @@ -270,6 +271,17 @@ export function MapStudio({ client, world, theme, onDisconnect }: MapStudioProps {pointer !== null && hover !== null && ( )} + {viewId === 'rivers' && !world.hydrology && ( +
+
+ +

No rivers planned

+

Enable hydrology in

+

dimensions/{world.dimension}.json

+

They appear here once the pack reloads.

+
+
+ )} {!connected && (
@@ -339,7 +351,7 @@ const APP_VIEW_IDS = new Set([WORLD_3D.id, SAVED_WORLD.id, NOISE.id]) function withAppViews(serverViews: ViewInfo[]): ViewInfo[] { const afterRegions = serverViews.findIndex((candidate) => candidate.id === 'regions') + 1 - return [...serverViews.slice(0, afterRegions), WORLD_3D, SAVED_WORLD, ...serverViews.slice(afterRegions)] + return [...serverViews.slice(0, afterRegions), WORLD_3D, ...serverViews.slice(afterRegions)] } function asViewInfo(view: ModuleViewInfo): ViewInfo { @@ -378,6 +390,9 @@ function legendTitle(layer: MapLayerQuery): string { if (layer.view === 'regions' && layer.preview === null) { return 'Regions on screen' } + if (layer.view === 'rivers') { + return 'Water on screen' + } return 'Biomes on screen' } diff --git a/studio/src/renderer/src/studio/ViewList.tsx b/studio/src/renderer/src/studio/ViewList.tsx index 6b7f3becc..8cb8e6c6c 100644 --- a/studio/src/renderer/src/studio/ViewList.tsx +++ b/studio/src/renderer/src/studio/ViewList.tsx @@ -11,6 +11,7 @@ import { useKeyText } from './useBindings' const VIEW_ICONS: Record = { biomes: 'views/biomes', regions: 'views/regions', + rivers: 'views/rivers', world3d: 'views/world-3d', savedWorld: 'views/saved-world', 'iris:terrain/palettes': 'views/palettes', diff --git a/studio/src/renderer/src/studio/shortcuts.ts b/studio/src/renderer/src/studio/shortcuts.ts index 29c6e3f32..0c8669d66 100644 --- a/studio/src/renderer/src/studio/shortcuts.ts +++ b/studio/src/renderer/src/studio/shortcuts.ts @@ -70,6 +70,7 @@ export const SHORTCUTS: ShortcutDefinition[] = [ const VIEW_KEYS: Record = { biomes: '1', regions: '2', + rivers: '3', world3d: '4', 'iris:terrain/palettes': 'p', 'iris:objects': 'o',