Example_map_startup_window.lua 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. --[[
  2. Shows a GUI window with info about the default example scene.
  3. Pauses physics simulation while the window is showing.
  4. ]]--
  5. function init ()
  6. -- Create needed variables
  7. create(Types.Conditional, 'continueButtonPressed')
  8. create(Types.Conditional, 'continueButtonHovered')
  9. showWindow = true
  10. simulationActive = false
  11. -- CONTINUE button settings
  12. continueButtonSizeX = 350.0
  13. continueButtonSizeY = 64.0
  14. -- Title text shown at the top of the window, with increased font size
  15. titleBodyText = {}
  16. titleBodyText[1] = 'An example scene made out of simple assets,'
  17. titleBodyText[2] = 'showing different types of objects and components'
  18. titleBodyTextSize = 2
  19. -- Body text shown in the middle of the window
  20. mainBodyText = {}
  21. mainBodyText[1] = 'Scene contains:'
  22. mainBodyText[2] = 'PBR shading using Cook-Torrance BRDF'
  23. mainBodyText[3] = 'PBR bloom with lens dirt'
  24. mainBodyText[4] = 'Luminance histogram with auto exposure compensation'
  25. mainBodyText[5] = 'Cascaded shadow mapping with PCF filtering'
  26. mainBodyText[6] = 'Horizon-based ambient occlusion mapping'
  27. mainBodyText[7] = 'Dynamic points lights with emissive mapping'
  28. mainBodyText[8] = 'Sky and fog using Mie and Rayleigh atmospheric light scattering'
  29. mainBodyText[9] = 'HDR rendering with Uchimura tone-mapping'
  30. mainBodyText[10] = 'Rigid body objects for collision detection'
  31. mainBodyText[11] = 'Ambient sound based on day-night cycle'
  32. mainBodyText[12] = ''
  33. mainBodyText[13] = 'Controls:'
  34. mainBodyText[14] = '[W] - move forward'
  35. mainBodyText[15] = '[A] - strafe left'
  36. mainBodyText[16] = '[S] - move backward'
  37. mainBodyText[17] = '[D] - strafe right'
  38. mainBodyText[18] = '[C] - move upward'
  39. mainBodyText[19] = '[SPACE] - move downward'
  40. mainBodyText[20] = '[F9] - toggle fullscreen'
  41. mainBodyText[21] = '[F11] - toggle v-sync'
  42. mainBodyText[22] = '[ESC] - go back to main-menu'
  43. mainBodyTextSize = 22
  44. -- Pause physics simulation while this GUI window is showing
  45. sendData(SystemType.Physics, DataType.DataType_SimulationActive, false)
  46. -- Make sure the mouse is released, so the buttons can be pressed
  47. setMouseCapture(false)
  48. ErrHandlerLoc.logErrorCode(ErrorCode.Initialize_success, getLuaFilename())
  49. end
  50. function update (p_deltaTime)
  51. if showWindow then
  52. -- Set font
  53. GUI.PushFont(ImGuiFont.AboutWindow)
  54. -- Set GUI colors
  55. GUI.PushStyleColor(ImGuiCol.WindowBg, 0.102, 0.102, 0.102, 0.9)
  56. -- Set the GUI window to be fullscreen
  57. GUI.SetNextWindowPos(0, 0)
  58. GUI.SetNextWindowSizeFullscreen()
  59. -- BEGIN WINDOW
  60. GUI.Begin('##ExampleMapInfo', bitwiseOr(ImGuiWindowFlags.NoTitleBar, ImGuiWindowFlags.NoResize, ImGuiWindowFlags.NoCollapse, ImGuiWindowFlags.NoMove))
  61. screenSize = GUI.GetScreenSize()
  62. -- Increase the font size for the title text
  63. GUI.SetWindowFontScale(2.0)
  64. -- Draw title text
  65. for i = 1, titleBodyTextSize do
  66. GUI.TextCenterAligned(titleBodyText[i])
  67. end
  68. -- Go back to the regular font size
  69. GUI.NewLine()
  70. GUI.SetWindowFontScale(1.0)
  71. -- Draw main body text
  72. for i = 1, mainBodyTextSize do
  73. GUI.TextCenterAligned(mainBodyText[i])
  74. end
  75. -- Set the CONTINUE button colors and style
  76. if continueButtonHovered:isChecked() then
  77. GUI.PushStyleColor(ImGuiCol.Text, 0.102, 0.102, 0.102, 1.0)
  78. else
  79. GUI.PushStyleColor(ImGuiCol.Text, 0.588, 0.773, 0.29, 1.0)
  80. end
  81. GUI.PushStyleColor(ImGuiCol.Button, 0.0, 0.0, 0.0, 0.0)
  82. GUI.PushStyleColor(ImGuiCol.ButtonHovered, 0.588, 0.773, 0.29, 1.0)
  83. GUI.PushStyleVar(ImGuiStyleVar.FrameRounding, 20.0)
  84. GUI.PushStyleVar(ImGuiStyleVar.ButtonTextAlign, 0.5, 0.5)
  85. -- Increase the font size for the CONTINUE button
  86. GUI.SetWindowFontScale(2.0)
  87. -- Set the CONTINUE button position to be centered at the bottom of the screen
  88. GUI.SetCursorPosX((screenSize.x - continueButtonSizeX) * 0.5)
  89. GUI.SetCursorPosY(screenSize.y - continueButtonSizeY - 10.0)
  90. -- Draw the CONTINUE button
  91. GUI.Button('Continue', continueButtonSizeX, continueButtonSizeY, continueButtonPressed)
  92. GUI.IsItemHovered(continueButtonHovered)
  93. GUI.PopStyleColor(3) -- Text, Button, ButtonHovered
  94. GUI.PopStyleVar(2) -- FrameRounding, ButtonTextAlign
  95. GUI.SetWindowFontScale(1.0)
  96. -- END WINDOW
  97. GUI.End()
  98. -- Return to the previous font
  99. GUI.PopFont()
  100. GUI.PopStyleColor() -- WindowBg
  101. -- If the CONTINUE button was pressed, stop showing this window
  102. if continueButtonPressed:isChecked() then
  103. showWindow = false
  104. simulationActive = true
  105. continueButtonPressed:uncheck()
  106. setMouseCapture(true)
  107. -- Unpause the physics simulation
  108. sendData(SystemType.Physics, DataType.DataType_SimulationActive, true)
  109. end
  110. end
  111. end