local imgui = require('imgui')
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
local directIni = 'SliderVolume.ini'
local inicfg = require("inicfg")
local ini = inicfg.load({main={volume=50}},directIni)
inicfg.save(ini, directIni)
local volume = imgui.ImInt(ini.main.volume)
local window = imgui.ImBool(false)
local as_action = require('moonloader').audiostream_state
local file = 'music.mp3'
function main()
while not isSampAvailable() do wait(200) end
imgui.Process = false
window.v = true --show window on start
while true do
wait(0)
imgui.Process = window.v
end
end
function imgui.OnDrawFrame()
if window.v then
local resX, resY = getScreenResolution()
local sizeX, sizeY = 400, 250 -- WINDOW SIZE
imgui.SetNextWindowPos(imgui.ImVec2(resX / 2 - sizeX / 2, resY / 2 - sizeY / 2), imgui.Cond.FirstUseEver)
imgui.SetNextWindowSize(imgui.ImVec2(sizeX, sizeY), imgui.Cond.FirstUseEver)
imgui.Begin('Window Title', window)
if imgui.Button(file, imgui.ImVec2(325, 25)) then
if music ~= nil then setAudioStreamState(music, as_action.STOP) music = nil end
music = loadAudioStream('moonloader/config/MP3Player/'..file)
setAudioStreamState(music, as_action.PLAY)
end
if imgui.SliderInt("##volume", volume, 0, 100) then
if music ~= nil then setAudioStreamVolume(music, volume.v / 100) end
ini.main.volume=volume.v
inicfg.save(ini, directIni)
end
imgui.End()
end
end