Skip to content

Popup buttons dialog

Hachem_Muche requested to merge Hachem_Muche/t-engine4:popupButtonsDialog into master
  • This adds a new dialog similar to the yes/no dialogs that presents a list of choices (up to 50) that are selected by individual buttons within the dialog frame.

Sample call sequence (with extra linefeeds!):

Dialog = require"engine.ui.Dialog"

choices = {{sel = "choice1", name=("Stay: here"):format()}, {sel = "choice2", name = "choice 2"}, {sel = "choice3", name = "I have to press a button for this?"}, {sel = "choice4", name = "Keep going"}, {sel = "choice5", name = "Ignore this Issue"},

{sel = 6, name = "Complain about this revoltin' development"},
{sel = 7, name = "Curse at the game"},
{sel = 8, name = "Try to sneak out", fct = function(sel) print("Selection", sel.sel, ":") print("I want out") end},
{sel = 9, name = "This is ridiculous and should be fixed, forever"},
{sel = 10, name = "hurry up. I'm waiting"},
{sel = 11, name = "No, thank you. I don't care for any Grey Poupon."},

{sel = 12, name = "My cat has bigger fleas than your orc."},
{sel = 13, name = "I wish to purchase some #CHOCOLATE#USED FOOD#LAST#."},
{sel = 14, name = "Continue as if nothing happened"},
{sel = 15, name = "Ignore the Problem"},
{sel = 16, name = "Report This Problem"},
{sel = 17, name = "Play Truth or Dare"},
{sel = 18, name = "Write your will"},
{sel = 20, name = "Admit to being an inferior player. :("},
{sel = 19, name = "Do NOT pass Go. Do NOT collect 200 zorkmids."},

}

--print("choices list:", choices) table.print(choices, "==") choice_handler = function(choice) print("selected choice", choice) table.print(choice, "__") print(("selected %s:%s"):format(choice.sel, choice.name)) if choice.sel == "choice2" then print("Picked the 2nd one") end end

text = "You have reached a cross-roads in your quest to become #LIGHT_RED#THE MOST POWERFUL BEING IN THE UNIVERSE#LAST#. Your choice here will raise up world leaders and bring great nations down. Carefully consider whether you should wield such power. \nYou may become an immortal beacon of power for all time to come. \nOr you might become someone's pet Wretchling. \nTake what action?"

--local text = "This is short"

dm=Dialog:multiButtonPopup("A #PINK#Momentous#LAST# Decision!", text, choices, nil, 800, choice_handler, false, #choices )

Merge request reports