Skip to content

ui: Add reusable classic-style popup foundation#1940

Open
DevOpsOfChaos wants to merge 1 commit into
Return-To-The-Roots:masterfrom
DevOpsOfChaos:sidequest/generic-popup-foundation
Open

ui: Add reusable classic-style popup foundation#1940
DevOpsOfChaos wants to merge 1 commit into
Return-To-The-Roots:masterfrom
DevOpsOfChaos:sidequest/generic-popup-foundation

Conversation

@DevOpsOfChaos
Copy link
Copy Markdown
Contributor

@DevOpsOfChaos DevOpsOfChaos commented May 3, 2026

Summary

This extends the existing iwMsgbox implementation into a reusable classic-style popup foundation.

The goal is to support future warning/confirmation/info dialogs without adding one-off popup implementations.

This PR adds:

  • configurable message box buttons
  • custom button labels
  • explicit result mapping
  • default button handling for Enter
  • cancel result handling for Escape/custom close
  • optional message box icons
  • visible internal demo popups in dskTest
  • UI regression coverage for custom buttons and Escape handling

Motivation

Some future UI flows need stronger user-facing warnings, confirmations, or information dialogs. Examples include advanced addon settings that may affect gameplay heavily, map validation warnings, informational map details, and small accept/cancel confirmation flows.

Instead of adding a special-case warning popup for one addon, this PR makes the existing message box more reusable while preserving the classic in-game UI style.

This keeps the foundation generic so future dialog use cases do not need separate one-off popup implementations.

Related future use cases

This PR does not close any of these issues by itself, but it provides reusable groundwork for UI flows that are related to existing requests or discussions:

The intent here is only to provide a reusable foundation, not to implement those specific flows in this PR.

Implementation details

This PR extends the existing iwMsgbox instead of introducing a parallel popup system.

It reuses existing classic UI elements:

  • IngameWindow
  • existing message box background/resource styling
  • existing question/warning icons
  • ctrlMultiline
  • classic text buttons

New configuration types:

  • MsgboxConfig
  • MsgboxButtonConfig

Supported behavior:

  • 1 to 3 custom buttons
  • custom button labels
  • custom MsgboxResult values
  • configurable default button
  • configurable cancel result
  • optional icon
  • Escape handling for custom-close message boxes

WindowManager was adjusted so custom-close windows can handle Escape through their own close/cancel behavior instead of being forcibly closed.

Demo / screenshots

This PR adds internal demo buttons to dskTest:

  • Warning popup
  • Confirm popup
warning-popup confirm-popup

Manual demo path:

  1. Run s25client
  2. Open the internal test screen by double-clicking the version text in the main menu
  3. Click Warning popup or Confirm popup

Example usage

WINDOWMANAGER.Show(std::make_unique<iwMsgbox>(
  "Confirm", "Do you want to continue?", this,
  MsgboxConfig{
    {{"Yes", MsgboxResult::Yes, TextureColor::Green2},
     {"No", MsgboxResult::No, TextureColor::Red1}},
    0, // Enter/default button
    1  // Escape/cancel button
  },
  MsgboxIcon::QuestionRed, msgboxId));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant