GE Lua Documentation

Press F to search!

debugOnUpdate

Definition


-- @/lua/ge/extensions/gameplay/missions/missionScreen.lua:1050
M.debugOnUpdate = function(dt)
  im = im or ui_imgui
  if im then
    if not M.savedLayouts then
      M.discoverLayouts()
    end
    im.Begin("Mission Start Screen History")
    local layouts = {}
    arrayConcat(layouts, M.uiLayoutHistory)
    arrayConcat(layouts, M.savedLayouts)
    if im.Button("Discover Layouts") then
      M.discoverLayouts()
    end
    if im.Button("Exit Screen") then
      guihooks.trigger('ChangeState', 'freeroam')
    end
    if im.Button("Clear History") then
      M.uiLayoutHistory = {}
    end
    im.Separator()
    -- Table header
    if im.BeginTable("LayoutsTable", 4, bit.bor(im.TableFlags_Resizable, im.TableFlags_ScrollY)) then
      im.TableSetupColumn("Date")
      im.TableSetupColumn("file")
      im.TableSetupColumn("Header Name")
      im.TableSetupColumn("Actions")
      im.TableHeadersRow()
      local layoutsChanged = false
      -- Table rows
      for i, layout in ipairs(layouts) do
        im.PushID1("layout:"..i)
        im.TableNextRow()

        -- View Layout column
        im.TableNextColumn()
        local header = "# " .. i
        header = header .. " (" .. (layout.recordedAtFormatted or "Unknown") .. ")"
        if im.Button(header) then
          M.testLayout = layout
          guihooks.trigger('ChangeState', 'freeroam')
          guihooks.trigger('ChangeState', {state = 'mission-control', params = { mode = "test"}})
        end

        -- File column
        im.TableNextColumn()
        im.Text(layout.fileName or "(Not saved as file)")

        -- Header Name column
        im.TableNextColumn()
        local headerName = "N/A"
        if layout.header and layout.header.header then
          headerName = translateLanguage(layout.header.header, layout.header.header, true)
        end
        headerName = headerName .. " (" .. (layout.mode or "N/A") .. ")"
        im.Text(headerName)

        -- Actions column
        im.TableNextColumn()
        -- Show either Save or Delete button based on whether the layout is saved
        if layout.isSaved then
          if im.Button("Delete") then
            -- Find the file path
            local filePath = layout.filePath
            -- Delete the file
            if FS:fileExists(filePath) then
              FS:removeFile(filePath)
              layoutsChanged = true

            end
          end
        else
          if im.Button("Save") then
            jsonWriteFile("/gameplay/testing/missionScreen_"..layout.recordedAt..".json", layout, true)
            layoutsChanged = true
          end
        end
        im.PopID()
      end

      if layoutsChanged then
        M.discoverLayouts()
      end
      im.EndTable()
    end
    im.End()
  end
end

Callers