UI Components

Three UI helper classes provide button rendering, gauge bars, and menu navigation. All are considered tentatively complete (needs testing) in the current codebase.

CButton

Header: include/button.hpp
Implementation: src/button.cpp
Status: Done

CButton handles rendering and hit-testing for UI buttons. Up to MAXBUTTON (40) buttons can be active on screen simultaneously. Button sprites are drawn from channel CHBUTTON using button.blp (40×40 px per button sprite).

Key aspects

  • Each button has a position, sprite icon index, and enabled/pressed state
  • Hit-test checks whether a mouse click falls within a button's 40×40 bounding rect
  • Pressed/hover states use different icon indices from the sprite sheet
  • Used by CEvent to drive menu and in-game UI interactions
// Sprite dimensions
#define DIMBUTTONX  40
#define DIMBUTTONY  40
#define MAXBUTTON   40

CJauge

Header: include/jauge.hpp
Implementation: src/jauge.cpp
Status: Done

CJauge renders gauge/progress bars used for lives, health, or other metered values. Up to 2 gauge slots (jaugeHide[2], jaugeLevel[2]) are tracked in the game state.

Key aspects

  • Gauge sprites drawn from channel CHJAUGE using jauge.blp
  • Always loaded from IMAGE08/ regardless of color depth setting (no IMAGE16 counterpart)
  • Gauge dimensions: 124×22 px (DIMJAUGEX × DIMJAUGEY)
  • Visibility and type per slot tracked in DescSave::jaugeHide[] and jaugeType[]
// Sprite dimensions
#define DIMJAUGEX  124
#define DIMJAUGEY   22

CMenu

Header: include/menu.hpp
Implementation: src/menu.cpp
Status: Done

CMenu renders menus and handles keyboard/mouse navigation within them. Background screens are drawn from screen*.blp files in IMAGE08/ or IMAGE16/.

Key aspects

  • Draws full-screen background images for menu screens
  • Delegates button hit-testing to CButton
  • Transitions between menu states via WM_PHASE_* messages dispatched through CEvent

Text Rendering

Free Eggbert uses bitmap font rendering rather than system fonts. Two font sizes are available, each with its own channel:

FontChannelSprite fileCell size
Normal text CHTEXT text.blp 16×16 px (DIMTEXTX × DIMTEXTY)
Small text CHLITTLE littletxt.blp 16×12 px (DIMLITTLEX × DIMLITTLEY)

Text drawing is handled by CPixmap using the appropriate channel.