pause_menu.lua 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. if UiContainer == nil then UiContainer = {} end
  2. UiContainer.PauseMenu = {
  3. position = 1,
  4. position_total = 2,
  5. on_start = function( self )
  6. return 0
  7. end,
  8. on_button = function( self, button, event )
  9. if ui_manager:get_widget( "PauseMenu" ):is_visible() == true then
  10. local menu_cursor = ui_manager:get_widget( "PauseMenu.Menu.Cursor" )
  11. if button == "Enter" and event == "Press" then
  12. audio_manager:play_sound("Cursor")
  13. script:request_end_sync( Script.UI, "PauseMenu", "hide", 0 )
  14. if self.position == 1 then
  15. script:request_end_sync( Script.UI, "BeginMenu", "show", 0 )
  16. map( "empty" )
  17. FFVII.MenuSettings.pause_available = false
  18. else
  19. FFVII.MenuSettings.available = true
  20. end
  21. elseif button == "Escape" and event == "Press" then
  22. audio_manager:play_sound("Back")
  23. script:request_end_sync( Script.UI, "PauseMenu", "hide", 0 )
  24. FFVII.MenuSettings.available = true
  25. elseif button == "Right" then
  26. audio_manager:play_sound("Cursor")
  27. self.position = self.position + 1
  28. if self.position > self.position_total then
  29. self.position = 1;
  30. end
  31. menu_cursor:set_default_animation( "Position" .. self.position )
  32. elseif button == "Left" then
  33. audio_manager:play_sound("Cursor")
  34. self.position = self.position - 1
  35. if self.position <= 0 then
  36. self.position = self.position_total;
  37. end
  38. menu_cursor:set_default_animation( "Position" .. self.position )
  39. end
  40. elseif FFVII.MenuSettings.pause_available == true then
  41. if button == "Enter" and event == "Press" then
  42. audio_manager:play_sound("Cursor")
  43. FFVII.MenuSettings.available = false
  44. script:request_end_sync( Script.UI, "PauseMenu", "show", 0 )
  45. end
  46. end
  47. return 0
  48. end,
  49. show = function( self )
  50. entity_manager:set_paused( true )
  51. ui_manager:get_widget( "PauseMenu" ):set_visible( true )
  52. return 0;
  53. end,
  54. hide = function( self )
  55. ui_manager:get_widget( "PauseMenu" ):set_visible( false )
  56. entity_manager:set_paused( false )
  57. return 0;
  58. end,
  59. }