moe-garage
Use when editing the 14th_ua MoE Calculator's HANGAR percentile-bar widget — its garage mount/hook, the MoEVM/MarkTickVM data channel, the engine read, or the MoECalculator.js/.css DOM, render branche
SKILL.md.claude/skills/moe-garage/SKILL.md
GitHubMoE Calculator — garage widget (feature)
The hangar percentile bar. Reusable patterns are in wotmod:gameface-widget (front-end)
and wotmod:architecture (Python layering + references/game-api.md); this skill is the
concrete wiring. All paths under src/res/.
Data flow (game → widget)
- Mount —
gui/mods/mod_moe_calculator.py::_install()patchesHangarVehicleParamsPresenter._onLoading(a hangar sub-view). Every mount it re-arms listeners thenbridge.attach()+bridge.push()— re-arming is required because the post-battle hangar teardown drops ouronChangeddelegate. Idempotent (_moe_calculator_patched). - Inject —
bridge/gameface_bridge.py::attach()callsopenwg_gameface.gf_mod_injectwithWIDGET_NAME="MoECalculator", stylesMoECalculator.css, moduleMoECalculator.js, and adds theDATA_PROP="moeData"property. Five re-armed listeners: vehicle, loadout, lobby-state, stats, settings. - Read —
adapter/engine_adapter.py::build_snapshot()readsg_currentVehicle+ dossierMARK_ON_GUN_RECORD(.getValue()=marks 0–3,.getDamageRating()=percentile float, nation) andmovingAvgDamage; caches the career baseline intobaseline_cache. - Build —
domain/builder.py::build_model()— three ticks atMARK_PERCENTS=(65,85,95), fill = clamped percentile,end_damage_requiredfrom threshold key100.bar_visible()gates. Widget presence is also gated bymod_settings.garage_enabled()(default ON); seemoe-settings. - Push —
bridge/view_models.py::MoEVM(see slots below).
Lifecycle guard: attach() caches _active=(host_vm, rvm) and nothing clears it (no
view-destroy hook is wired). Session-persistent listeners — the moe_wgapi ready hook and
IItemsCache.onSyncCompleted — can fire AFTER battle entry tears the hangar down, so refresh()
early-returns via _host_alive() (lobby state machine present) instead of pushing into the dead
VM. _arm uses getattr(holder, attr, None) so a renamed WG event degrades quietly. A full
_active teardown + the re-injection observer-stacking question stay open (TASKS/garage-bridge-lifecycle.md).
VM slots (bridge/view_models.py) — HAND-NUMBERED, JS reads by name
MoEVM— readproperties=/commands=off its__init__inview_models.py(the 12 read slots below are only the v1 set; later slots are APPENDED afterlabels— the drag/position channel, therevpush counter, thetrendJSON — plus asetPositioncommand). Indices: 0visible, 1nation, 2marks, 3curPercent(Real), 4curAvgDamage, 5fill(Real), 6hasData, 7carouselRows, 8carouselSmall, 9ticks(Array ofMarkTickVM), 10endDamageRequired, 11labels(JSON string for the tooltip).MarkTickVM—properties=4: 0percent, 1markCount, 2damageRequired, 3reached. (Noiconslot — the widget draws a flat glyph; the old nation-art URL was removed.)curPercent/fillmust be Real — see the Wulf-decimals rule inwotmod:architecture.
Front-end (MoECalculator.js / .css)
ModelObserver("MoECalculator")readsmodel.moeData.#moe-rootbuilt once byensureRoot():.moe-head>.moe-cur(.moe-cur-dmg + .moe-cur-icon)and.moe-body>.moe-trackholding.moe-fill .moe-split .moe-split-label(50%) .moe-end .moe-end-label .moe-cur-marker .moe-cur-pct .moe-ticks.- Bar axis (
barX): piecewisePCT_STOPS=[0,65,85,95,100]→BAR_STOPS=[0,25,50,75,100](equal quarters — same convention as the Damage Efficiency bar'sEFFICIENCY_BAR_STOPS, seemoe-progress). The tooltip's weekly-MoE trend chart's Y axis reusesbarXdirectly (the oldaxisPoswas collapsed into it in v5.1.0) — there is no separate copy of the constants to keep in lockstep. - Render branches (
render): nomoeData→ hidden;visible===false→ hidden; otherwise shown. New tank genuinely reads0/0%(synchronous dossier read, not the async table) — explicit zeros, not a "—" placeholder. Percent viapctTextis floored to 2 decimals (never rounds up past a threshold). Carousel classesmoe-rows2/moe-smalltoggled fromdata.carouselRows/carouselSmall. - Ticks use the flat glyph
img://…/library/marksOnGun/mark_%d.png(ignorestk.icon— nation decals mush at tick size); damage requirement printed below each (blank when unknown). - Localization:
labelsarrives as a JSON bundle;L(key)is missing-key-safe; JS hardcodes no English (mirrored contract withadapter/i18n.py). applyWidgetScale()(onwhenReady+resize) sets#moe-root'stransform: scale(k)so the widget height matches WG's viewport-driven bottom-bar slot boxes;k = 1 + GROWTH·(vp/scale − SIZE_REF)/SIZE_REF(SIZE_REF=1080,GROWTH=0.625). See the CSS-notes anchor/height bullets for the full rem-vs-vh reasoning.posW/posHare NOT the widget's width/height — they are the viewport size (window.innerWidth/innerHeight) captured at pin time, stored only to rescale the widget's position proportionally when the resolution/UI-scale changes. They are internal (written only viasetPosition), never user-facing controls — the v1.4.0 drag-to-reposition feature moves the widget only (Ctrl+drag + X/Y position steppers), it does NOT resize it.
CSS notes (MoECalculator.css)
- No
var(--color-*)(Gameface drops the whole declaration on an unresolved var); most sizing inrem(1rem == interfaceScale px); fontPFDINMax; white fill#ede6d9(band/zone colours were removed — plain white bar). - Anchor (bottom-right). X pure rem (
right:46rem); width315rem. Y is acalc(B rem + V vh)BLEND (V=18.33vh; B per carousel state —.moe-rows2=104, single-row=77.5,.moe-small=61rem), NOT pure rem and NOT a fixed-px term. Why: WG's Auto interfaceScale is power-of-two gated (x2 only when width≥2560 AND height≥1536;gui/shared/utils/graphics.py), so 1080p & 1440p are both x1 while 4K is x2 — and 4K is exactly 2× 1080p, making those two points degenerate (pure rem, pure vh, and every blend agree there). The carousel top the bar clears is neither pure-scale nor pure-viewport: pure rem sits too LOW at 1440p, pure vh too HIGH. The blend reproduces 1080p/4K exactly and was pinned live at 1440p (the only non-degenerate point) on the 2-row carousel (302/368/604px). Do NOT collapse Y to a single unit or re-add a fixed+140pxterm — that+140pxhybrid was the resolution-scaling bug. Retune: change V, re-solveB = px_1080 − V·10.8. - Widget height tracks WG's bottom-bar slot boxes (crew/equip/directive/ammo/consumables — Flash, viewport-driven, so the rem widget is too short at non-4K). Fixed in
MoECalculator.jsviatransform: scale(k)on#moe-root, origin bottom-right (preserves the anchor):k = 1 + GROWTH·(vp/scale − SIZE_REF)/SIZE_REFwithSIZE_REF=1080,GROWTH=0.625→ 1.0× at 1080p/4K, ~1.208× at 1440p; recomputed from liveinnerHeight+ root font-size onresize. - Calibration tooling:
tools/dev/probe_resolutions.py(video-mode +interfaceScale.getScaleOptions()table) and a temporary on-screen JS diagnostic div (logscomputed bottom+ rendered rect +1rempx). GOTCHA: a 2-row carousel makes#moe-root.moe-rows2win, so base-#moe-rootbottomprobes are silently OVERRIDDEN — always confirm which carousel-state rule is live before probing. - Track uses WG
img://progressbar textures;card_border.pngis aborder-imageand MUST be a bare-siblingurl(card_border.png)(img:///data:silently fail forborder-image).
Hover tooltip — SHIPPED (native award-tooltip clone)
TOOLTIP_ENABLED = true. On hover (400ms intent delay) a body-level position:fixed
#moe-tooltip reproduces the client's Marks-of-Excellence award tooltip (Vehicle stats →
Awards), keyed by mark count 0..3: nation mark art (marksOnGun 180×180) top-right + title +
current-ratio line (percentile in white) + description + divider + 5-bullet condition. Text is
the client's own strings via the labels bundle (adapter/i18n.py).
Built in the shared .wg-tooltip / .wg-tip-* vocabulary — the SAME classes as the sibling
wgmod-research-progress tooltip (both render identically), but a STANDALONE copy scoped to
#moe-tooltip (no shared file). Recipe: the wotmod:gameface-widget skill's "Native tooltip
recipe". MoE-local classes: .wg-tip-icon-mark/.wg-tip-main-mark, .wg-tip-icon-unearned,
.moe-tip-ratio/.moe-tip-descr, .moe-tip-hi, .moe-tip-empty.
Engine gotchas baked into the CSS/JS (see the file comments):
- No inline formatting in this Gameface build (any element child drops to its own line,
displayhas no effect) → the white-% ratio line is aflex-wraprow of one span PER WORD (ratioHtml), the%word =.moe-tip-hi; word spacing viamargin-right, notgap. - Mark icon box uses the glyph's real aspect (64×46,
background-size:100% auto+ center) to crop the 180×180 source's ~25/27px transparent bands, so it aligns with the title. - Description is a full-width paragraph OUTSIDE
.wg-tip-main(the icon's reserved column would otherwise narrow it). - Frame = 9-slice via
border-image-source: url('img://…background_with_border.png')— the LONGHAND resolvesimg://where theborder-imageshorthand fails;tooltip_bg.pngbundled as fallback.
Assets (bare siblings of the JS/CSS)
card_border.png (border-image), tooltip_bg.png / tooltip_divider.png (tooltip skin). Fonts for this feature: engine PFDINMax (no bundled TTF; the bundled MoEBattle.ttf is the battle overlay's).