oomek / attractplus

Attract-Mode Plus
GNU General Public License v3.0
46 stars 16 forks source link

attractplus-kms "incomplete" layout reload after returning from game #32

Closed zpaolo11x closed 1 year ago

zpaolo11x commented 1 year ago

When getting back from a game in attractplus-kms, the layout is reloaded, but the reload is not "complete" because no StartLayout is triggered.

Sample code:

local gamename = fe.add_text("[title]",0,0,200,10)
local test = "LOAD"

fe.add_transition_callback(this,"on_transition")

function on_transition (ttype,var,ttime){
   if (ttype == Transition.StartLayout){
      test = "START"
      print ("A: "test+"\n")
   }
   if (ttype == Transition.ToGame){
      test = "TOGAME"
      print ("B: "test+"\n")
   }
   if (ttype == Transition.FromGame){
      print ("C: "test+"\n")
   }
   return false
}

Expected behavior: test is set to "LOAD" at layout load, then to "START" when StartLayout is triggered. In non-KMS environment when the game ends the code prints "TOGAME". Under KMS when the game ends the layout restarts, but no StartLayout is triggered, "FromGame" is triggered instead, so the output is "LOAD" because the code in the StartLayout portion is not executed.

Can be an issue for a layout that uses a global variable and change its value during StartLayout, that will cause issues if at the layout reload StartLayout is not re-triggered.

oomek commented 1 year ago

Is it still an issue?

zpaolo11x commented 1 year ago

No sorry I forgot to give feedback, the issue can be closed