feat(ui-calculator): input validation, load caps, ceil display, modernization layout
- custom load capped at cargo capacity (error when exceeded); full load shows the cargo capacity; zero cargo pins load to empty and disables the toggle - per-input red border + tooltip for every invalid value (blocks, techs, load, MAT, modernization target); no value may be negative; locking a speed is disabled when drive is zero - display every computed number (results + goal-seek back-solved input) rounded up to 3 decimals via a shared pkg/calc Ceil3 bridged to wasm; engine keeps its own round-to-nearest util.Fixed* - modernization total upgrade cost spans two columns (single line) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -86,6 +86,7 @@ func main() {
|
||||
"shieldsForDefence": js.FuncOf(shieldsForDefence),
|
||||
"cargoForEmptyMass": js.FuncOf(cargoForEmptyMass),
|
||||
"loadForFullMass": js.FuncOf(loadForFullMass),
|
||||
"ceil3": js.FuncOf(ceil3),
|
||||
}))
|
||||
|
||||
// Block forever so the Go runtime stays alive while JS keeps calling
|
||||
@@ -420,6 +421,15 @@ func loadForFullMass(_ js.Value, args []js.Value) any {
|
||||
return js.ValueOf(v)
|
||||
}
|
||||
|
||||
// ceil3 bridges `calc.Ceil3`. Input `{ value }`, output a JS number
|
||||
// rounded up to three decimal places.
|
||||
func ceil3(_ js.Value, args []js.Value) any {
|
||||
if len(args) != 1 {
|
||||
return js.Null()
|
||||
}
|
||||
return js.ValueOf(calc.Ceil3(args[0].Get("value").Float()))
|
||||
}
|
||||
|
||||
// copyBytesFromJS materialises a JS Uint8Array (or any indexable
|
||||
// byte-shaped value) into a Go byte slice. We avoid `js.CopyBytesToGo`
|
||||
// because TinyGo's implementation panics on values it does not
|
||||
|
||||
Reference in New Issue
Block a user