mwg API
    Preparing search index...

    Class MessageLog

    A player-facing message pane: each message is its own block, coloured by its level, and the oldest blocks fall away once the wrapped lines pass maxLines. The classic roguelike "you hit the rat" strip; a Toast is transient and a Logger is for developers, this is neither.

    import { MessageLog } from '@datamoc/mwg/two-d/ui';

    const log = new MessageLog({ wrapWidth: 200, maxLines: 4 });
    log.add('You find a dewdrop.', 'positive');
    log.add('You are starving.', 'negative');
    console.log(log.entryCount); // 2

    Hierarchy

    • Container
      • MessageLog
    Index
    • get contentHeight(): number

      the drawn height of every block together, so a caller can sit the log on an edge

      Returns number

    • The newest count entries as plain { text, level } records, oldest first - the readback for automated checks and secondary displays, without scraping rendered children. Entries the wrapped-line budget already dropped are gone, so what "last" means is bounded by entryCount: a count past that returns everything retained, and a count of 0 (or negative) returns []. The records are copies; mutating them cannot corrupt the log. (There is no snapshot() on this widget, so there is nothing further to include.)

      Parameters

      • count: number

      Returns MessageLogEntry[]