REPENTOGON icon indicating copy to clipboard operation
REPENTOGON copied to clipboard

[Suggestion] Add an example mod for GenericPrompt class

Open BadPig03 opened this issue 1 year ago • 1 comments

The usage of the GenericPrompt class might require some small hints :)

BadPig03 avatar Aug 09 '24 03:08 BadPig03

Here is a small example on how to use it. Something like this should be added to the docs:

local myPrompt = GenericPrompt()
myPrompt:Initialize()
myPrompt:SetText("Some test text")

local wasPromptDisplayed = false

function mod:myRenderFunction(_)
  myPrompt:Render()
end 
mod:AddCallback(ModCallbacks.MC_POST_RENDER, mod.myRenderFunction)

function mod:myUpdateFunction(_) 
  myPrompt:Update(true) -- true = Process user inputs
  if wasPromptDisplayed and not myPrompt:IsActive() then -- prompt was closed by user 
    print("User selected option: "..myPrompt:GetSubmittedSelection()) 
    wasPromptDisplayed = false 
  end
  if Input.IsButtonTriggered(Keyboard.KEY_MINUS, 0)  then -- on Pressing minus button will open prompt 
    myPrompt:Show() 
    wasPromptDisplayed = true 
  end 
end 
mod:AddCallback(ModCallbacks.MC_POST_UPDATE, mod.myUpdateFunction)

wofsauge avatar Aug 12 '24 22:08 wofsauge

Thanks for your example! :)

BadPig03 avatar Aug 15 '24 13:08 BadPig03