User Confirmation

Usage

This package provides a widget that allows you to present the user with a message and a number of options. You can act upon the resposne of the user when they respond.
The widget supports both cursor and analog navigation.
This package supports any number of options, including scrolling support with both controller and mouse.
Usage:
Simple confirm:
function MyScript:LocalConfirmBeforeGoing()
  self:GetEntity().userConfirmationScript:LocalConfirm("Are you sure you want to continue?", function(response)
    if response then 
      self:DoSomethingWhenTheyConfirm()
    end
  )
end

Advanced usage:
function MyScript:LocalAskUser()
  local options = {
    { name = "Apple", value = "apple" },
    { name = "Orange", value = "orange" },
    { name = "Banana", value = "banana" }
  }
  self:GetEntity().userConfirmationScript:Prompt("Which fruit do you want?", options, function(response)
    if response == "apple" then
      self:ReceiveOrange()
    elseif response == "orange" then
      self:ReceiveOrange()
    elseif response == "banana" then
      self:ReceiveBanana()
    end
  )
end

Look and feel:


Caveats:
If you’re displaying this in response to a user interacting with another widget, the other widget will still receive user input.
As a work around, you should set a flag on the widget to disable input, and add appropriate code to act on this flag, when the confirmation dialog is open.
For example:
function MyScript:DoSomething()
  self.widget.js.data.disabled = true
  self:GetEntity().userConfirmationScript:LocalConfirm("Are you sure?", function(response) 
    self.widget.js.data.disabled = false
  end)
end

then in your widget, just don’t run interactive functions if the flag is set.
DryCereal Games
Games Packages Crayta