Files
windroost/p2_godot_sample/scripts/number_display.gd
T
wushenghua 2765468525 feat: standalone endless expedition page (replaces modal)
The endless mode UI was a transient modal -- poor for an idle game the player
watches. Now a persistent PAGE_ENDLESS (like growth/map):
- number_display.py/.gd: readable BigValue text (1.23K/1.50M/2.15e190),
  NUMDISP_PARITY_PASS 5 cases -- big numbers no longer raw encoded strings.
- game_root: skyport "Endless Expedition" opens PAGE_ENDLESS with live status
  (zone/level/essence/rebuild), gold/dps, advance/auto/upgrade actions, and a
  recent-zone log showing clear times + boss flags. Offline report shown inline;
  modal path kept for actions but page is the primary surface.
- endless_page_ui_test PASS: page renders, entry works, advance drives engine.
- P2_CHECKS_PASS 105 gates, identity preserved (story mode untouched).

Endless idle now has a proper home surface. Owner gates (human/device/release)
open. prototype/ untracked.
2026-11-19 22:29:06 +08:00

27 lines
994 B
GDScript

class_name NumberDisplay
extends RefCounted
## GDScript mirror of tools/fullgame/number_display.gd. Readable BigValue text.
const SUFFIXES := ["", "K", "M", "B", "T", "q", "Q", "s", "S", "o", "n",
"d", "ud", "du", "td", "qd", "Qd", "sd", "Sd", "od", "nd"]
static func format_number(value, precision: int = 2) -> String:
var mant: float = float(value.mantissa)
var expo: float = float(value.exponent)
if not is_finite(mant) or not is_finite(expo):
return "?"
var f: float = mant * pow(10.0, expo)
if is_finite(f) and absf(f) < 1.7976931348623157e308:
var exp_ok: bool = expo == floor(expo)
var exp: int = int(expo)
if exp_ok and exp >= 0 and exp < 3 * SUFFIXES.size():
var group: int = exp / 3
var scaled: float = mant * pow(10.0, float(exp - group * 3))
return "%.*f%s" % [precision, scaled, str(SUFFIXES[group])]
if exp_ok and exp >= 0:
return "%.*fe%d" % [precision, mant, exp]
return "%.*f" % [precision, f]
return "%.*fe%d" % [precision, mant, int(expo)]