2023-03-27 06:03:10 +00:00
|
|
|
# frozen_string_literal: true
|
2023-03-08 03:06:29 +00:00
|
|
|
|
2023-03-27 06:03:10 +00:00
|
|
|
# This is the pause menu, triggered by a button press when the player wants a
|
|
|
|
# break from gameplay.
|
|
|
|
class PauseMenu < MenuScene
|
|
|
|
def initialize(args, opts = {})
|
|
|
|
menu_options = [
|
|
|
|
{
|
|
|
|
key: :resume,
|
|
|
|
on_select: ->(args) { Scene.pop(args) }
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: :settings,
|
2023-04-11 06:26:39 +00:00
|
|
|
on_select: ->(args) { Scene.push(args, :settings, reset: true, reset_on_pop: true) }
|
2023-03-27 06:03:10 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
key: :return_to_main_menu,
|
2023-04-11 06:26:39 +00:00
|
|
|
on_select: ->(args) { Scene.switch(args, :main_menu, reset: true) }
|
2023-03-27 06:03:10 +00:00
|
|
|
}
|
|
|
|
]
|
2023-03-08 03:06:29 +00:00
|
|
|
|
2023-03-27 06:03:10 +00:00
|
|
|
if args.gtk.platform?(:desktop)
|
|
|
|
menu_options << {
|
|
|
|
key: :quit,
|
|
|
|
on_select: ->(args) { args.gtk.request_quit }
|
|
|
|
}
|
|
|
|
end
|
2023-03-08 03:06:29 +00:00
|
|
|
|
2023-04-11 06:26:39 +00:00
|
|
|
super args, opts, :paused, menu_options
|
2023-03-27 06:03:10 +00:00
|
|
|
end
|
2023-03-21 02:40:53 +00:00
|
|
|
|
2023-03-27 06:03:10 +00:00
|
|
|
# called every tick of the game loop
|
|
|
|
def tick(args)
|
|
|
|
super
|
2023-05-07 23:35:52 +00:00
|
|
|
Music.pause(args) unless Music.stopped?(args) || Music.paused?(args)
|
2023-03-08 03:06:29 +00:00
|
|
|
end
|
|
|
|
end
|