Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
SpriteandClaude Sonnet 5.5 committed 2026-11-23 01:08:53 +00:00
1 parent dccbfd7d86
commit 17f81c60c8
20 files changed
+636 -447

No files matched your search

+7 -13
View File
@@ -24,7 +24,7 @@ pub fn save_json(home : Array[@grid.Slot]) -> String {
///|
/// Read a saved layout; `None` if the text is not one. Slots without a name are
/// dropped, and no more than `home_cap` are kept.
pub fn load_json(text : String, next_key : Ref[Int]) -> Array[@grid.Slot]? {
pub fn load_json(text : String, next_key : Ref[Int32]) -> Array[@grid.Slot]? {
guard @jsonx.parse(text) is Some(j) else { return None }
guard @jsonx.get(j, "slots") is Some(Array(_)) else { return None }
let out : Array[@grid.Slot] = []
@@ -52,7 +52,7 @@ pub fn load_json(text : String, next_key : Ref[Int]) -> Array[@grid.Slot]? {
}
///|
fn take_key(next_key : Ref[Int]) -> Int {
fn take_key(next_key : Ref[Int32]) -> Int32 {
let k = next_key.val
next_key.val = k + 1
k
@@ -63,14 +63,11 @@ fn take_key(next_key : Ref[Int]) -> Int {
/// `ultra.home.{kind,str,wid,h,w,cx,cy}.i` (all strings; kind 1 is a widget, `h` its
/// height in px, `cx`/`cy` the pinned cell). `text` is those keys as a JSON object. Widget
/// heights in px become whole rows.
pub fn legacy_import(text : String, next_key : Ref[Int]) -> Array[@grid.Slot] {
pub fn legacy_import(text : String, next_key : Ref[Int32]) -> Array[@grid.Slot] {
guard @jsonx.parse(text) is Some(kv) else { return [] }
fn num(k : String, i : Int, d : Int) -> Int {
fn num(k : String, i : Int32, d : Int32) -> Int32 {
match @jsonx.get(kv, "ultra.home.\{k}.\{i}") {
Some(String(s)) =>
try @string.parse_int(s) catch {
_ => d
}
Some(String(s)) => @string.parse_int(s) catch { _ => d }
Some(Number(n, ..)) => n.to_int()
_ => d
}
@@ -105,12 +102,9 @@ pub fn legacy_import(text : String, next_key : Ref[Int]) -> Array[@grid.Slot] {
}
///|
fn num2(kv : Json, key : String) -> Int {
fn num2(kv : Json, key : String) -> Int32 {
match @jsonx.get(kv, key) {
Some(String(s)) =>
try @string.parse_int(s) catch {
_ => 0
}
Some(String(s)) => @string.parse_int(s) catch { _ => 0 }
Some(Number(n, ..)) => n.to_int()
_ => 0
}