ludic migrate state packages <every example program> packages/ludic.lab/example/plate.ludic 1804 vars into 126 states, 64 into lets; 23498 edits in 460 files Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
62 lines
2.4 KiB
Text
62 lines
2.4 KiB
Text
# system.ludic - the camera as a system: the roll and what has been photographed in its own save
|
|
# section, by key. The best per subject follows from the frames, as a buyer would judge them.
|
|
export function photo_config(base_st: mut BaseState, photo_st: mut PhotoState, max: int) -> void {
|
|
photo_st.pht_max = Math.max(max, 1)
|
|
photo_reset(base_st, photo_st)
|
|
}
|
|
|
|
export function photo_reset(base_st: mut BaseState, photo_st: mut PhotoState) -> void {
|
|
pht_blank(photo_st)
|
|
photo_st.pht_species_shot = 0
|
|
photo_st.pht_legend_shot = 0
|
|
photo_st.pht_cover = -1
|
|
photo_st.pht_page = 0
|
|
photo_frame_begin(photo_st)
|
|
q_clear(base_st, photo_facts(base_st, photo_st))
|
|
}
|
|
|
|
export function photo_save(photo_st: PhotoState) -> Val {
|
|
let v = Value.object()
|
|
let l = Value.list()
|
|
for i in 0 .. photo_st.pht_n {
|
|
let o = Value.object()
|
|
sv_put_int(o, "day", photo_st.pht_day[i])
|
|
sv_put_float(o, "hour", photo_st.pht_hour[i])
|
|
sv_put_int(o, "mask", photo_st.pht_mask[i])
|
|
sv_put_int(o, "legend", photo_st.pht_legend[i])
|
|
sv_put_bool(o, "sold", photo_st.pht_sold[i] != 0)
|
|
sv_put_str(o, "tags", photo_st.pht_tags[i])
|
|
sv_put_str(o, "file", photo_st.pht_file[i])
|
|
sv_put_int(o, "grade", photo_st.pht_grade[i])
|
|
sv_put_int(o, "why", photo_st.pht_why[i])
|
|
Value.add(l, o)
|
|
}
|
|
Value.put(v, "frames", l)
|
|
sv_put_int(v, "shot", photo_st.pht_species_shot)
|
|
sv_put_int(v, "legend_shot", photo_st.pht_legend_shot)
|
|
sv_put_int(v, "cover", photo_st.pht_cover)
|
|
sv_put_int(v, "sort", photo_st.pht_sort)
|
|
return v
|
|
}
|
|
|
|
export function photo_load(base_st: mut BaseState, photo_st: mut PhotoState, v: Val, version: int) -> void {
|
|
photo_reset(base_st, photo_st)
|
|
if Value.has(v, "frames") != 0 {
|
|
let l = Value.get(v, "frames")
|
|
for i in 0 .. Value.count(l) {
|
|
let o = Value.at(l, i)
|
|
photo_add(photo_st, sv_int(o, "day", 1), sv_float(o, "hour", 0.0), sv_int(o, "mask", 0), sv_int(o, "legend", 0), sv_bool(o, "sold", false), sv_str(o, "tags", ""), sv_str(o, "file", ""), sv_int(o, "grade", 40), sv_int(o, "why", PHOTO_WHY_NONE))
|
|
}
|
|
}
|
|
photo_record_set(photo_st, photo_st.pht_species_shot | sv_int(v, "shot", 0), sv_int(v, "legend_shot", 0))
|
|
photo_st.pht_cover = sv_int(v, "cover", -1)
|
|
photo_sort_set(photo_st, sv_int(v, "sort", PHOTO_NEWEST))
|
|
}
|
|
|
|
export function photo_system() -> System {
|
|
let s = system_new("photo", PH_COMMIT)
|
|
s.reset = fn photo_reset
|
|
s.save = fn photo_save
|
|
s.load = fn photo_load
|
|
return s
|
|
}
|