View Single Post
02/14/16, 04:30 AM   #1
Ayantir
 
Ayantir's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 1,019
A gamepad dialog

Hello,

To create a gamepad dialog, here's how to :


First your Keyboard dialog : ex :


Lua Code:
  1. --define new dialog
  2. local lowMemoryDialog = {
  3.     title = { text = GetString(NOTYOU_LUADIALOG_TITLE) },
  4.     mainText = { text = GetString(NOTYOU_LUADIALOG_TEXT) },
  5.     buttons = {
  6.         [1] = {
  7.             text = SI_DIALOG_YES,
  8.             callback = function(dialog)
  9.                 SetCVar("LuaMemoryLimitMB", tostring(dialog.data.newLimit))
  10.                 ReloadUI("ingame")
  11.             end,
  12.         },
  13.         [2] =  { text = SI_DIALOG_NO }
  14.     }
  15. }
  16.    
  17. ZO_Dialogs_RegisterCustomDialog("LUA_LOW_MEMORY", lowMemoryDialog)


This one will be called thanks to :

Lua Code:
  1. ZO_Dialogs_ShowDialog("LUA_LOW_MEMORY", { newLimit = newLimit }, { mainTextParams = { currentLimit, newLimit } } )

"LUA_LOW_MEMORY" is the name (it is in ESO_Dialogs table.
{ newLimit = newLimit } is the data . newLimit = xxxx refers to dialog.data.newLimit in the dialog, xxx will be sent as value.
{ mainTextParams = { currentLimit, newLimit } } is the params for the mainText string. currentLimit will go in my <<1>> and newLimit in my <<2>> (mainTextParams is zo_strformat()'ed !)






So now, this code don't work for gamepad !


To simply make it gamepad compliant, you'll need to change 2 little things :


First, in your dialog definition, you'll need to add the gamepadInfo data :
The simpliest one is :

gamepadInfo = { dialogType = GAMEPAD_DIALOGS.BASIC },

You can look at GAMEPAD_DIALOGS table to see which other values of dialogType are accepted.

There is also others values acceepted in gamepadInfo , like
Lua Code:
  1. allowShowOnNextScene = true,
  2. allowRightStickPassThrough = true,

It will become :

Lua Code:
  1. local lowMemoryDialog = {
  2.     gamepadInfo = { dialogType = GAMEPAD_DIALOGS.BASIC },
  3.     title = { text = GetString(NOTYOU_LUADIALOG_TITLE) },
  4.     mainText = { text = GetString(NOTYOU_LUADIALOG_TEXT) },
  5.     buttons = {
  6.         [1] = {
  7.             text = SI_DIALOG_YES,
  8.             callback = function(dialog)
  9.                 SetCVar("LuaMemoryLimitMB", tostring(dialog.data.newLimit))
  10.                 ReloadUI("ingame")
  11.             end,
  12.         },
  13.         [2] =  { text = SI_DIALOG_NO }
  14.     }
  15. }
  16.    
  17. ZO_Dialogs_RegisterCustomDialog("LUA_LOW_MEMORY", lowMemoryDialog)


Then, the call itself will be modified for :

Lua Code:
  1. ZO_Dialogs_ShowGamepadDialog("LUA_LOW_MEMORY", { newLimit = newLimit }, { mainTextParams = { currentLimit, newLimit } } )

And it works !

  Reply With Quote