mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-12-01 02:04:51 +00:00
Add Rivers view to the studio
- Show hydrology features as colored labels with a water legend - Reuse the Swing studio's rivers icon and key colors - Show the no-hydrology empty state - List only views the V4 bridge serves
This commit is contained in:
1 parent
86ce2856e8
commit
aafbb879df
9 files changed
+39
-5
No files matched your search
@@ -3,7 +3,8 @@
|
|||||||
import type { BlockLook } from '../scene/blockLooks'
|
import type { BlockLook } from '../scene/blockLooks'
|
||||||
import type { CoverLook } from '../scene/coverLooks'
|
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 {
|
export interface MapLabel {
|
||||||
kind: LabelKind
|
kind: LabelKind
|
||||||
@@ -236,6 +237,8 @@ export interface WorldInfo {
|
|||||||
fluidHeight: number
|
fluidHeight: number
|
||||||
tileSize: number
|
tileSize: number
|
||||||
hasPlayers: boolean
|
hasPlayers: boolean
|
||||||
|
/** Whether the dimension plans water; without it the river view has nothing to show. */
|
||||||
|
hydrology: boolean
|
||||||
views: ViewInfo[]
|
views: ViewInfo[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ export type IdeIconName =
|
|||||||
| 'views/palettes'
|
| 'views/palettes'
|
||||||
| 'views/procedural'
|
| 'views/procedural'
|
||||||
| 'views/regions'
|
| 'views/regions'
|
||||||
|
| 'views/rivers'
|
||||||
| 'views/saved-world'
|
| 'views/saved-world'
|
||||||
| 'views/world-3d'
|
| 'views/world-3d'
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="M2 5.5C3.5 4.2 5 4.2 6.5 5.5C8 6.8 9.5 6.8 11 5.5C12.5 4.2 13.25 4.2 14 4.6" stroke="#6C707E" stroke-linecap="round"/>
|
||||||
|
<path d="M2 10.5C3.5 9.2 5 9.2 6.5 10.5C8 11.8 9.5 11.8 11 10.5C12.5 9.2 13.25 9.2 14 9.6" stroke="#6C707E" stroke-linecap="round"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 364 B |
@@ -0,0 +1,4 @@
|
|||||||
|
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="M2 5.5C3.5 4.2 5 4.2 6.5 5.5C8 6.8 9.5 6.8 11 5.5C12.5 4.2 13.25 4.2 14 4.6" stroke="#CED0D6" stroke-linecap="round"/>
|
||||||
|
<path d="M2 10.5C3.5 9.2 5 9.2 6.5 10.5C8 11.8 9.5 11.8 11 10.5C12.5 9.2 13.25 9.2 14 9.6" stroke="#CED0D6" stroke-linecap="round"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 364 B |
@@ -44,7 +44,7 @@ export function countShares(tiles: PlacedTile[], area: WorldArea): Share[] {
|
|||||||
for (let pixelZ = firstZ; pixelZ < endZ; pixelZ += stride) {
|
for (let pixelZ = firstZ; pixelZ < endZ; pixelZ += stride) {
|
||||||
for (let pixelX = firstX; pixelX < endX; pixelX += stride) {
|
for (let pixelX = firstX; pixelX < endX; pixelX += stride) {
|
||||||
const subject = subjectAt(tile, gridIndex(tile, pixelX, pixelZ))
|
const subject = subjectAt(tile, gridIndex(tile, pixelX, pixelZ))
|
||||||
if (subject === null) {
|
if (subject === null || isDryGround(subject.subject)) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
const id = `${subject.subject.kind}:${subject.subject.key}`
|
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 {
|
function subjectAt(tile: MapTile, cell: number): { subject: Highlight; color: number } | null {
|
||||||
const index = tile.subjects[cell]
|
const index = tile.subjects[cell]
|
||||||
if (index === NO_LABEL) {
|
if (index === NO_LABEL) {
|
||||||
|
|||||||
@@ -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. */
|
/** What a highlight picks out: a biome or region by key, or a height band in the 3D world's legend. */
|
||||||
export interface Highlight {
|
export interface Highlight {
|
||||||
kind: 'BIOME' | 'REGION' | 'HEIGHT'
|
kind: 'BIOME' | 'REGION' | 'WATER' | 'HEIGHT'
|
||||||
key: string
|
key: string
|
||||||
name: string
|
name: string
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import type { MapHover, MapLabel, Marker, ModuleViewInfo, PickDisplay, ServerUsa
|
|||||||
import type { Share } from '../map/census'
|
import type { Share } from '../map/census'
|
||||||
import type { MapController, MapStatus, MapToggles } from '../map/MapController'
|
import type { MapController, MapStatus, MapToggles } from '../map/MapController'
|
||||||
import type { Highlight } from '../map/tileStyle'
|
import type { Highlight } from '../map/tileStyle'
|
||||||
|
import { IdeIcon } from '@/components/IdeIcon'
|
||||||
import { HelpDialog } from './HelpDialog'
|
import { HelpDialog } from './HelpDialog'
|
||||||
import { HoverCard } from './HoverCard'
|
import { HoverCard } from './HoverCard'
|
||||||
import { Legend } from './Legend'
|
import { Legend } from './Legend'
|
||||||
@@ -73,7 +74,7 @@ export function MapStudio({ client, world, theme, onDisconnect }: MapStudioProps
|
|||||||
const sceneViews = useModuleViews(loadSceneViews, packRevision)
|
const sceneViews = useModuleViews(loadSceneViews, packRevision)
|
||||||
const patternViews = useModuleViews(loadPatternViews, packRevision)
|
const patternViews = useModuleViews(loadPatternViews, packRevision)
|
||||||
const views = useMemo(
|
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]
|
[world.views, patternViews, sceneViews]
|
||||||
)
|
)
|
||||||
const sceneView = sceneViews.find((candidate) => candidate.id === viewId) ?? null
|
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 && (
|
{pointer !== null && hover !== null && (
|
||||||
<HoverCard hover={hover} point={pointer} viewId={viewId} previewing={layer.preview !== null} detailed={detailed} minY={world.minY} />
|
<HoverCard hover={hover} point={pointer} viewId={viewId} previewing={layer.preview !== null} detailed={detailed} minY={world.minY} />
|
||||||
)}
|
)}
|
||||||
|
{viewId === 'rivers' && !world.hydrology && (
|
||||||
|
<div className="absolute inset-0 flex items-center justify-center bg-card">
|
||||||
|
<div className="text-center">
|
||||||
|
<IdeIcon name="views/rivers" className="mx-auto mb-3 size-10" />
|
||||||
|
<p className="font-medium">No rivers planned</p>
|
||||||
|
<p className="mt-1 text-secondary-text">Enable hydrology in</p>
|
||||||
|
<p className="font-mono text-[11.5px] text-secondary-text">dimensions/{world.dimension}.json</p>
|
||||||
|
<p className="mt-1 text-muted-foreground">They appear here once the pack reloads.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
{!connected && (
|
{!connected && (
|
||||||
<div className="absolute inset-0 flex items-center justify-center bg-background/70">
|
<div className="absolute inset-0 flex items-center justify-center bg-background/70">
|
||||||
<div className="rounded-xl border border-overlay-border bg-card p-5 text-center shadow-lg">
|
<div className="rounded-xl border border-overlay-border bg-card p-5 text-center shadow-lg">
|
||||||
@@ -339,7 +351,7 @@ const APP_VIEW_IDS = new Set([WORLD_3D.id, SAVED_WORLD.id, NOISE.id])
|
|||||||
|
|
||||||
function withAppViews(serverViews: ViewInfo[]): ViewInfo[] {
|
function withAppViews(serverViews: ViewInfo[]): ViewInfo[] {
|
||||||
const afterRegions = serverViews.findIndex((candidate) => candidate.id === 'regions') + 1
|
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 {
|
function asViewInfo(view: ModuleViewInfo): ViewInfo {
|
||||||
@@ -378,6 +390,9 @@ function legendTitle(layer: MapLayerQuery): string {
|
|||||||
if (layer.view === 'regions' && layer.preview === null) {
|
if (layer.view === 'regions' && layer.preview === null) {
|
||||||
return 'Regions on screen'
|
return 'Regions on screen'
|
||||||
}
|
}
|
||||||
|
if (layer.view === 'rivers') {
|
||||||
|
return 'Water on screen'
|
||||||
|
}
|
||||||
return 'Biomes on screen'
|
return 'Biomes on screen'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import { useKeyText } from './useBindings'
|
|||||||
const VIEW_ICONS: Record<string, IdeIconName> = {
|
const VIEW_ICONS: Record<string, IdeIconName> = {
|
||||||
biomes: 'views/biomes',
|
biomes: 'views/biomes',
|
||||||
regions: 'views/regions',
|
regions: 'views/regions',
|
||||||
|
rivers: 'views/rivers',
|
||||||
world3d: 'views/world-3d',
|
world3d: 'views/world-3d',
|
||||||
savedWorld: 'views/saved-world',
|
savedWorld: 'views/saved-world',
|
||||||
'iris:terrain/palettes': 'views/palettes',
|
'iris:terrain/palettes': 'views/palettes',
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ export const SHORTCUTS: ShortcutDefinition[] = [
|
|||||||
const VIEW_KEYS: Record<string, Chord> = {
|
const VIEW_KEYS: Record<string, Chord> = {
|
||||||
biomes: '1',
|
biomes: '1',
|
||||||
regions: '2',
|
regions: '2',
|
||||||
|
rivers: '3',
|
||||||
world3d: '4',
|
world3d: '4',
|
||||||
'iris:terrain/palettes': 'p',
|
'iris:terrain/palettes': 'p',
|
||||||
'iris:objects': 'o',
|
'iris:objects': 'o',
|
||||||
|
|||||||
Reference in new issue
Block a user