Skip to main content

Intentionpicker

Based on game build 714014 | Last updated: 2026-03-08

Overview

IntentionPicker is a UI widget that presents a horizontal row of buttons representing server intention options (Social, Cooperative, Competitive, Madness), each associated with a configurable description string. It supports keyboard navigation (left/right arrow keys), focus management, and optional "ANY" selection. The widget is designed for use in server browser or settings UIs where players configure their intended gameplay style.

Usage example

local IntentionPicker = require "widgets/redux/intentionpicker"

local picker = IntentionPicker(
STRINGS.UI.INTENTION.TITLE,
{
SOCIAL = STRINGS.UI.INTENTION.SOCIAL_DESC,
COOPERATIVE = STRINGS.UI.INTENTION.COOP_DESC,
COMPETITIVE = STRINGS.UI.INTENTION.COMPETITIVE_DESC,
MADNESS = STRINGS.UI.INTENTION.MADNESS_DESC,
ANY = STRINGS.UI.INTENTION.ANY_DESC,
},
true -- allow ANY option
)

picker:SetCallback(function(intention)
print("Selected intention:", intention)
end)

picker:SetFocus(MOVE_RIGHT)

Dependencies & tags

Components used: None identified
Tags: None identified

Properties

PropertyTypeDefault ValueDescription
buttonstable of ImageButton{}Array of intention option buttons.
anybuttonImageButtonnilOptional "ANY" button (present only if allowany is true).
headertextTextnilTitle text widget.
descriptionTextnilDescription text widget that updates on button focus.
cbfunctionnilCallback function set via :SetCallback().
next_focusImageButtonnilTemporary focus target used by :SetSelected().

Main functions

SetCallback(cb)

  • Description: Registers a callback function to be invoked when any button is clicked.
  • Parameters: cb (function) - function to call with the selected intention value as its argument.
  • Returns: Nothing.

SetSelected(intention)

  • Description: Sets the focus to the button matching the given intention value.
  • Parameters: intention (string) - one of INTENTIONS.* constants (e.g., "SOCIAL", "COMPETITIVE").
  • Returns: Nothing.
  • Error states: If no matching button is found, no focus change occurs.

SetFocus(direction)

  • Description: Sets initial focus to a button based on direction, unless next_focus is already set (e.g., after SetSelected).
  • Parameters: direction (number) - MOVE_LEFT or MOVE_RIGHT; ignored if next_focus is non-nil.
  • Returns: Nothing.
  • Error states: No-op if the button array is empty.

Events & listeners

  • Listens to: None identified
  • Pushes: None identified