Skip to content

Commit

Permalink
exp: add engine sounds list tool
Browse files Browse the repository at this point in the history
  • Loading branch information
alexey-lysiuk committed Nov 12, 2024
1 parent 3f2c66c commit c71c805
Showing 1 changed file with 78 additions and 0 deletions.
78 changes: 78 additions & 0 deletions Misc/qs_pak/scripts/expmode_engine.lua
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,80 @@ function expmode.engine.textureviewer()
textureviewer_onshow, textureviewer_onhide)
end

local function sounds_searchcompare(entry, string)
return entry.name:lower():find(string, 1, true)
or entry.size:find(string, 1, true)
end

local function sounds_onupdate(self)
local title = self.title
local visible, opened = imBegin(title, true)

if visible and opened then
local searchmodified = searchbar(self)
local entries = updatesearch(self, sounds_searchcompare, searchmodified)

if imBeginTable(title, 4, defaultTableFlags) then
imTableSetupScrollFreeze(0, 1)
imTableSetupColumn('Index', imTableColumnWidthFixed)
imTableSetupColumn('Name')
imTableSetupColumn('Size', imTableColumnWidthFixed)
imTableHeadersRow()

for _, entry in ipairs(entries) do
imTableNextRow()
imTableNextColumn()
imText(entry.index)
imTableNextColumn()
imText(entry.name)
imTableNextColumn()
imText(entry.size)
end

imEndTable()
end
end

imEnd()

return opened
end

local function sounds_onshow(self)
local entries = {}

for i, sound in ipairs(sounds) do
local soundsize = sound.size
local entry =
{
index = tostring(i),
name = sound.name,
size = soundsize and tostring(soundsize) or '<not loaded>',
}
insert(entries, entry)
end

self.entries = entries

updatesearch(self, sounds_searchcompare, true)
return true
end

local function sounds_onhide(self)
resetsearch(self)
self.entries = nil
return true
end

function expmode.engine.sounds()
return expmode.window('Sounds', sounds_onupdate,
function (self)
self:setconstraints()
self:setsize(imVec2(480, 0))
end,
sounds_onshow, sounds_onhide)
end

local function GhostAndExit(enable)
player.ghost(enable)
expmode.exit()
Expand Down Expand Up @@ -452,6 +526,10 @@ expmode.addaction(function ()

imSeparator()

if imMenuItem('Sounds\u{85}') then
expmode.engine.sounds()
end

if imMenuItem('Stop All Sounds') then
sounds.stopall()
end
Expand Down

0 comments on commit c71c805

Please sign in to comment.