Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Funny pause overlay #284

Merged
merged 2 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mods/dpr_main/scripts/data/actors/takodachi.lua
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ end
function actor:onWorldUpdate(chara)
if not Game.world.map.ina then return end
if Game.world.cutscene and Game.world.cutscene.id ~= "room1.wah" then return end
if chara.sprite.sprite ~= "takolyshit" then
if chara.sprite.sprite ~= "takolyshit" and not (PauseLib and PauseLib.paused) then
if not Game.world.map.ina:isPlaying() then
Game.world.map.ina:resume()
end
Expand Down
10 changes: 10 additions & 0 deletions sharedlibs/dp/lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"id": "dpcommon",
"default": true,
"dependencies": [
"pausebutton"
],
"optionalDependencies": [
"magical-glass"
]
}
13 changes: 13 additions & 0 deletions sharedlibs/dp/lib.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
local lib = {}

Registry.registerGlobal("DP", lib)
DP = lib

function lib:onPause()
if Game.tutorial then
PauseLib.paused = false
Assets.playSound("ui_cant_select",1.5)
end
end

return lib
53 changes: 53 additions & 0 deletions sharedlibs/dp/scripts/objects/PauseOverlay.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
local PauseOverlay, super = Class("PauseOverlay", "PauseOverlay")

function PauseOverlay:init()
super.init(self)
self.text:setText("Press "..Input.getText("pause").." to resume.")
self.rect = Rectangle(0,0,SCREEN_WIDTH,SCREEN_HEIGHT)
self.rect:setColor(COLORS.black(0))
self.rect:fadeTo(0.4,.3)
self.rect:setLayer(-99999)
self:addChild(self.rect)
self.header = Text("PAUSE",0,0,nil,nil,{auto_size = true})
self.header:setOrigin(.5,0)
self.header:setScale(2)
self.header:setPosition(310, 14)
self:addChild(self.header)
local advice = Utils.pick{
"DID YOU KNOW?\nThis menu is stolen from Deltaruined",
}
self.cooladvice = Text(advice,314,149,SCREEN_WIDTH/2,nil)
self:addChild(self.cooladvice)
end

function PauseOverlay:onAdd(parent)
super.onAdd(self, parent)
local msuics = nil
do
local ok, msuics_opts = pcall(modRequire, "scripts.jukebox_songs")
if not ok then
msuics_opts = {}
end
Utils.filterInPlace(msuics_opts, function (v) return Assets.getMusicPath(v.file) ~= nil end)
Utils.filterInPlace(msuics_opts, function (v) return v.file ~= Game:getActiveMusic().current end)
Utils.filterInPlace(msuics_opts, function (v) return (not v.flag) or (Game:getFlag(v.flag)) end)
msuics = Utils.pick(msuics_opts)
end
if msuics then
self.pause_music = self.pause_music or Music(msuics.file)
self.pause_music:play()
self.nowplaying = Text("Currently Playing:\n\""..(msuics.name).."\"\nBy "..msuics.composer.."\n"..msuics.origin)
self.nowplaying:setPosition(0,249)
self:addChild(self.nowplaying)
end
end

function PauseOverlay:close()
if self.pause_music then
self.pause_music:remove()
self.nowplaying:remove()
end
super.close(self)
end

return PauseOverlay
2 changes: 1 addition & 1 deletion sharedlibs/pausebutton/lib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ function PauseLib:setPaused(new)
self.paused = true
Kristal.callEvent("onPause")
if not self.paused then return end -- Allow suppressing pauses
self.overlay = Kristal.Stage:addChild(PauseOverlay())
---@type Music[]
self.paused_music = Music.getPlaying()
for _, mus in pairs(self.paused_music) do
mus:pause()
end
self.overlay = Kristal.Stage:addChild(PauseOverlay())
else
self.paused = false
for _, mus in pairs(self.paused_music) do
Expand Down