feat(packages): ludic.minimap - a map's logic: the explored fog over a grid of cells round an origin (revealed within a reach, a version for rebaking, explored as a share of the land over a core square, the grid as text for an older save), the player's marks (a cap, a symbol, a colour, the day, a name; the open one and the followed one, rubbing out, the last symbol reused, the nearest for a compass) and the view (world to window and back, zoom in steps and about a point, a drag, pick and place, the camp, you, a focus that never pulls back out, a scale bar, bounds); the world through a port; seen and marks in its own save section by key
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
fe9d28bf4e
commit
73a376ac6c
13 changed files with 830 additions and 0 deletions
68
packages/ludic.minimap/pin_edit.ludic
Normal file
68
packages/ludic.minimap/pin_edit.ludic
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
# pin_edit.ludic - changing a mark: its name, symbol and colour, rubbing it out, which one is open
|
||||
# and which followed, and whether the map is waiting for a place to drop the next
|
||||
export function minimap_pin_remove(i: int) -> void {
|
||||
if i < 0 or i >= minimap_pin_count() { return }
|
||||
let rest = new []MinimapPin
|
||||
for k in 0 .. len(mm_pins) { if k != i { push(rest, mm_pins[k]) } }
|
||||
mm_pins = rest
|
||||
if mm_open == i { mm_open = -1 } else if mm_open > i { mm_open -= 1 }
|
||||
if mm_followed == i { mm_followed = -1 } else if mm_followed > i { mm_followed -= 1 }
|
||||
}
|
||||
|
||||
export function minimap_pin_set_label(i: int, s: string) -> void { if i >= 0 and i < minimap_pin_count() { mm_pins[i].label = s } }
|
||||
|
||||
# the symbol chosen is the one the next mark takes
|
||||
export function minimap_pin_set_icon(i: int, k: int) -> void {
|
||||
if i < 0 or i >= minimap_pin_count() { return }
|
||||
mm_pins[i].icon = Math.clamp(k, 0, mm_symbols - 1)
|
||||
mm_last = mm_pins[i].icon
|
||||
}
|
||||
|
||||
export function minimap_pin_set_colour(i: int, k: int) -> void { if i >= 0 and i < minimap_pin_count() { mm_pins[i].colour = Math.clamp(k, 0, mm_colours - 1) } }
|
||||
|
||||
export function minimap_pin_last_icon() -> int { return mm_last }
|
||||
|
||||
# the mark the map's legend has open, -1 none
|
||||
export function minimap_pin_open() -> int {
|
||||
if mm_open >= minimap_pin_count() { mm_open = -1 }
|
||||
return mm_open
|
||||
}
|
||||
|
||||
export function minimap_pin_select(i: int) -> void {
|
||||
mm_open = -1
|
||||
if i >= 0 and i < minimap_pin_count() { mm_open = i }
|
||||
}
|
||||
|
||||
# the mark the compass carries, -1 none
|
||||
export function minimap_pin_followed() -> int {
|
||||
if mm_followed >= minimap_pin_count() { mm_followed = -1 }
|
||||
return mm_followed
|
||||
}
|
||||
|
||||
export function minimap_pin_follow(i: int) -> void {
|
||||
mm_followed = -1
|
||||
if i >= 0 and i < minimap_pin_count() { mm_followed = i }
|
||||
}
|
||||
|
||||
# follow the open mark, or stop following it
|
||||
export function minimap_pin_follow_toggle() -> void {
|
||||
let i = minimap_pin_open()
|
||||
if i < 0 { return }
|
||||
if mm_followed == i { mm_followed = -1 } else { mm_followed = i }
|
||||
}
|
||||
|
||||
export function minimap_placing() -> bool { return mm_placing }
|
||||
|
||||
# the next press on the map drops a mark; asked again, it does not
|
||||
export function minimap_place_toggle() -> void {
|
||||
mm_placing = not mm_placing
|
||||
mm_open = -1
|
||||
}
|
||||
|
||||
# the press that drops it, at a point on the window: the new mark is open, -1 if there was no room
|
||||
export function minimap_place(rx: float, ry: float, label: string) -> int {
|
||||
mm_placing = false
|
||||
let i = minimap_pin_add(minimap_wx(rx), minimap_wz(ry), mm_last, label)
|
||||
if i >= 0 { mm_open = i }
|
||||
return i
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue