Добавлен ofeerist,
опубликован
Алгоритмы, Наработки и Способности
Способ реализации:
vJass
Тип:
Наработка
Версия Warcraft:
1.26, 1.27a, 1.27b, 1.28f
Плеер плейлистов на фреймах.
Упрощает перемещение по плейлисту и красиво показывает длительность трека с помощью слайдера.
Функционал
- Имеет возможность останавливать и возобновлять воспроизведения треков.
- Имеет две кнопки, "<" и ">", отвечают за ручное перемещение по плейлисту.
- При окончании трека, автоматически включается следующий в плейлисте.
- Показывает название текущего трека.
- Не имеет возможности перемещаться по треку, отсутствует рабочий геттер получения значение слайдера.
- Имеет возможность останавливать и возобновлять воспроизведения треков.
- Имеет две кнопки, "<" и ">", отвечают за ручное перемещение по плейлисту.
- При окончании трека, автоматически включается следующий в плейлисте.
- Показывает название текущего трека.
- Не имеет возможности перемещаться по треку, отсутствует рабочий геттер получения значение слайдера.
Требования
- Уверенное пользование jass.
- Мемхак анрайза. (>1.3)
- pjass для работы мемхака. (Закинуть в JNGP/jasshelper)
- Уверенное пользование jass.
- Мемхак анрайза. (>1.3)
- pjass для работы мемхака. (Закинуть в JNGP/jasshelper)
Использование
1. Скачиваем пример.
2. Копируем папку триггеров Radio и кидаем к себе в карту.
3. Экспортируем text.fdf, uitoc.toc и кидаем к себе в карту.
4. Настраиваем это дело.
5. Радуемся. (optional)
1. Скачиваем пример.
2. Копируем папку триггеров Radio и кидаем к себе в карту.
3. Экспортируем text.fdf, uitoc.toc и кидаем к себе в карту.
4. Настраиваем это дело.
5. Радуемся. (optional)
Код
- Кастомный чат используется как основа, уже 5-ый раз.
- К радостью некоторых, я не использовал выставление фреймов по абсолютной точке.
- Это означает, что теперь возможно переместить только фрейм бэкдропа и всё навесное переместится вместе с ним.
- Кастомный чат используется как основа, уже 5-ый раз.
- К радостью некоторых, я не использовал выставление фреймов по абсолютной точке.
- Это означает, что теперь возможно переместить только фрейм бэкдропа и всё навесное переместится вместе с ним.
Init
globals
integer RadioBackdrop
integer Slider
integer Prev
integer Next
integer Pause
integer MusicName
string array MusicPathes
string array MusicNames
integer array MusicDurations
integer MaxTracks
integer Current = 0
integer CurrentTime = 0
boolean Paused = true
endglobals
function InitMusicPathes takes nothing returns nothing
set MusicNames[0] = "Comradeship"
set MusicPathes[0] = "Sound\\Music\\mp3Music\\Comradeship.mp3"
set MusicDurations[0] = GetSoundFileDuration(MusicPathes[0])
set MusicNames[1] = "War2Intro"
set MusicPathes[1] = "Sound\\Music\\mp3Music\\War2IntroMusic.mp3"
set MusicDurations[1] = GetSoundFileDuration(MusicPathes[1])
set MaxTracks = 1
endfunction
function Trig_Init_Actions takes nothing returns nothing
local integer i = 0
call LoadTOCFile("uitoc.toc")
call InitMusicPathes()
set RadioBackdrop = CreateFrame("ChatHistoryBackdrop", pGameUI, 0)
call SetFrameSize(RadioBackdrop, .17, .08)
call SetFrameAbsolutePoint(RadioBackdrop, 4, .4, .2)
// GetFrameValue(Slider) > crit
set Slider = CreateFrame("Slider", RadioBackdrop, 1)
call SetFrameSize(Slider, .15, .01)
call SetFrameMinMaxValue(Slider, 0, MusicDurations[Current])
call SetFramePoint(Slider, 4, RadioBackdrop, 4, 0, 0)
set Prev = CreateFrame("ButtonChat", RadioBackdrop, 2)
call SetFrameSize(Prev, .05, .025)
call SetFrameText(Prev, "<")
call SetFramePoint(Prev, 4, RadioBackdrop, 4, -.057, -.023)
set Next = CreateFrame("ButtonChat", RadioBackdrop, 3)
call SetFrameSize(Next, .05, .025)
call SetFrameText(Next, ">")
call SetFramePoint(Next, 4, RadioBackdrop, 4, .057, -.023)
set Pause = CreateFrame("ButtonChat", RadioBackdrop, 4)
call SetFrameSize(Pause, .05, .025)
call SetFrameText(Pause, "||>")
call SetFramePoint(Pause, 4, RadioBackdrop, 4, 0, -.023)
set MusicName = CreateFrame("ChatText1", RadioBackdrop, 5)
call SetFrameText(MusicName, MusicNames[Current])
call SetFramePoint(MusicName, 4, RadioBackdrop, 4, -.050, .023)
endfunction
//===========================================================================
function InitTrig_Init takes nothing returns nothing
set gg_trg_Init = CreateTrigger( )
call TriggerRegisterTimerEventSingle( gg_trg_Init, 0.05 )
call TriggerAddAction( gg_trg_Init, function Trig_Init_Actions )
endfunction
MouseEvent
globals
boolean KeySpan
real TempCurTime = 0
endglobals
function PlayNextTrack takes nothing returns nothing
set Current = Current + 1
if Current > MaxTracks then
set Current = 0
endif
set CurrentTime = 0
call SetFrameMinMaxValue(Slider, 0, MusicDurations[Current])
call PlayMusicEx(MusicPathes[Current], CurrentTime, 1)
call SetFrameText(MusicName, MusicNames[Current])
endfunction
function PlayPrevTrack takes nothing returns nothing
set Current = Current - 1
if Current < 0 then
set Current = MaxTracks
endif
set CurrentTime = 0
call SetFrameMinMaxValue(Slider, 0, MusicDurations[Current])
call PlayMusicEx(MusicPathes[Current], CurrentTime, 1)
call SetFrameText(MusicName, MusicNames[Current])
endfunction
function Trig_MouseEvent_Actions takes nothing returns nothing
local integer i = 0
local integer layer = FindCLayerUnderCursor()
loop
exitwhen i == 2
if GetLocalPlayer() == Player(i) then
if layer == Pause and Paused and KeySpan and IsKeyPressed(0x01) then
set Paused = false
call SetFrameText(Pause, "|| ||")
call PlayMusicEx(MusicPathes[Current], CurrentTime, 1)
elseif layer == Pause and not Paused and KeySpan and IsKeyPressed(0x01) then
set Paused = true
call SetFrameText(Pause, "||>")
call StopMusic(false)
endif
if layer == Prev and KeySpan and IsKeyPressed(0x01) then
set Paused = false
call SetFrameText(Pause, "|| ||")
call PlayPrevTrack()
endif
if layer == Next and KeySpan and IsKeyPressed(0x01) then
set Paused = false
call SetFrameText(Pause, "|| ||")
call PlayNextTrack()
endif
if IsKeyPressed(0x01) then
set KeySpan = false
else
set KeySpan = true
endif
if not Paused then
set CurrentTime = CurrentTime + 100
endif
if CurrentTime >= MusicDurations[Current] then
call PlayNextTrack()
endif
call SetFrameValue(Slider, CurrentTime)
endif
set i = i + 1
endloop
endfunction
//===========================================================================
function InitTrig_MouseEvent takes nothing returns nothing
set gg_trg_MouseEvent = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( gg_trg_MouseEvent, 0.10 )
call TriggerAddAction( gg_trg_MouseEvent, function Trig_MouseEvent_Actions )
endfunction
v 1.1
- Добавлен расширенный функционал: регулировка громкости, случайный трек, остановка воспроизведения.
Скачать.
Код
Код
Init
globals
integer RadioBackdrop
integer Slider
integer Prev
integer Next
integer Pause
integer MusicName
integer Extra
integer ExtraBackdrop
integer Volume
integer VolumeUp
integer VolumeDown
integer RndTrack
integer Stop
string array MusicPathes
string array MusicNames
integer array MusicDurations
integer MaxTracks
integer Current = 0
integer CurrentTime = 0
boolean Paused = true
endglobals
function InitMusicPathes takes nothing returns nothing
set MusicNames[0] = "Comradeship"
set MusicPathes[0] = "Sound\\Music\\mp3Music\\Comradeship.mp3"
set MusicDurations[0] = GetSoundFileDuration(MusicPathes[0])
set MusicNames[1] = "War2Intro"
set MusicPathes[1] = "Sound\\Music\\mp3Music\\War2IntroMusic.mp3"
set MusicDurations[1] = GetSoundFileDuration(MusicPathes[1])
set MaxTracks = 1
endfunction
function Trig_Init_Actions takes nothing returns nothing
local integer i = 0
call LoadTOCFile("uitoc.toc")
call InitMusicPathes()
set RadioBackdrop = CreateFrame("ChatHistoryBackdrop", pGameUI, 0)
call SetFrameSize(RadioBackdrop, .17, .08) // .17
call SetFrameAbsolutePoint(RadioBackdrop, 4, .4, .2)
// GetFrameValue(Slider) > crit
set Slider = CreateFrame("Slider", RadioBackdrop, 1)
call SetFrameSize(Slider, .15, .01)
call SetFrameMinMaxValue(Slider, 0, MusicDurations[Current])
call SetFramePoint(Slider, 4, RadioBackdrop, 4, 0, 0)
set Prev = CreateFrame("ButtonChat", RadioBackdrop, 2)
call SetFrameSize(Prev, .05, .025)
call SetFrameText(Prev, "<")
call SetFramePoint(Prev, 4, RadioBackdrop, 4, -.057, -.023)
set Next = CreateFrame("ButtonChat", RadioBackdrop, 3)
call SetFrameSize(Next, .05, .025)
call SetFrameText(Next, ">")
call SetFramePoint(Next, 4, RadioBackdrop, 4, .057, -.023)
set Pause = CreateFrame("ButtonChat", RadioBackdrop, 4)
call SetFrameSize(Pause, .05, .025)
call SetFrameText(Pause, "||>")
call SetFramePoint(Pause, 4, RadioBackdrop, 4, 0, -.023)
set MusicName = CreateFrame("ChatText1", RadioBackdrop, 5)
call SetFrameText(MusicName, MusicNames[Current])
call SetFramePoint(MusicName, 4, RadioBackdrop, 4, -.050, .023)
set Extra = CreateFrame("ButtonChat", RadioBackdrop, 6)
call SetFrameSize(Extra, .025, .025)
call SetFrameText(Extra, "~")
call SetFramePoint(Extra, 4, RadioBackdrop, 4, .07, .023)
set ExtraBackdrop = CreateFrame("ChatHistoryBackdrop", RadioBackdrop, 7)
call SetFrameSize(ExtraBackdrop, .08, .08)
call SetFramePoint(ExtraBackdrop, 4, RadioBackdrop, 4, .13, 0)
call SetFrameAlpha(ExtraBackdrop, 0)
call HideFrame(ExtraBackdrop)
set Volume = CreateFrame("ChatText1", ExtraBackdrop, 7)
call SetFrameText(Volume, "100%")
call SetFramePoint(Volume, 4, ExtraBackdrop, 4, .025, .025)
set VolumeUp = CreateFrame("ButtonChat", ExtraBackdrop, 8)
call SetFrameSize(VolumeUp, .025, .025)
call SetFrameText(VolumeUp, "+")
call SetFramePoint(VolumeUp, 4, ExtraBackdrop, 4, -.02, .023)
set VolumeDown = CreateFrame("ButtonChat", ExtraBackdrop, 9)
call SetFrameSize(VolumeDown, .025, .025)
call SetFrameText(VolumeDown, "-")
call SetFramePoint(VolumeDown, 4, ExtraBackdrop, 4, 0, .023)
set RndTrack = CreateFrame("ButtonChat", ExtraBackdrop, 10)
call SetFrameSize(RndTrack, .045, .025)
call SetFrameText(RndTrack, "rnd")
call SetFramePoint(RndTrack, 4, ExtraBackdrop, 4, -.01, 0)
set Stop = CreateFrame("ButtonChat", ExtraBackdrop, 11)
call SetFrameSize(Stop, .045, .025)
call SetFrameText(Stop, "stop")
call SetFramePoint(Stop, 4, ExtraBackdrop, 4, -.01, -.023)
endfunction
//===========================================================================
function InitTrig_Init takes nothing returns nothing
set gg_trg_Init = CreateTrigger( )
call TriggerRegisterTimerEventSingle( gg_trg_Init, 0.05 )
call TriggerAddAction( gg_trg_Init, function Trig_Init_Actions )
endfunction
MouseEvent
globals
boolean KeySpan
real TempCurTime = 0
integer VolumeValue = 100
endglobals
function PlayNextTrack takes nothing returns nothing
set Current = Current + 1
if Current > MaxTracks then
set Current = 0
endif
set CurrentTime = 0
call SetFrameMinMaxValue(Slider, 0, MusicDurations[Current])
call PlayMusicEx(MusicPathes[Current], CurrentTime, 1)
call SetFrameText(MusicName, MusicNames[Current])
endfunction
function PlayPrevTrack takes nothing returns nothing
set Current = Current - 1
if Current < 0 then
set Current = MaxTracks
endif
set CurrentTime = 0
call SetFrameMinMaxValue(Slider, 0, MusicDurations[Current])
call PlayMusicEx(MusicPathes[Current], CurrentTime, 1)
call SetFrameText(MusicName, MusicNames[Current])
endfunction
function PlayRndTrack takes nothing returns nothing
set Current = GetRandomInt(0, MaxTracks)
set CurrentTime = 0
call SetFrameMinMaxValue(Slider, 0, MusicDurations[Current])
call PlayMusicEx(MusicPathes[Current], CurrentTime, 1)
call SetFrameText(MusicName, MusicNames[Current])
endfunction
function Trig_MouseEvent_Actions takes nothing returns nothing
local integer i = 0
local integer layer = FindCLayerUnderCursor()
loop
exitwhen i == 2
if GetLocalPlayer() == Player(i) then
if layer == Pause and Paused and KeySpan and IsKeyPressed(0x01) then
set Paused = false
call SetFrameText(Pause, "|| ||")
call PlayMusicEx(MusicPathes[Current], CurrentTime, 1)
elseif layer == Pause and not Paused and KeySpan and IsKeyPressed(0x01) then
set Paused = true
call SetFrameText(Pause, "||>")
call StopMusic(false)
endif
if layer == Prev and KeySpan and IsKeyPressed(0x01) then
set Paused = false
call SetFrameText(Pause, "|| ||")
call PlayPrevTrack()
endif
if layer == Next and KeySpan and IsKeyPressed(0x01) then
set Paused = false
call SetFrameText(Pause, "|| ||")
call PlayNextTrack()
endif
if layer == Extra and KeySpan and IsKeyPressed(0x01) then
if GetFrameAlpha(ExtraBackdrop) == 0 then
call SetFrameAlpha(ExtraBackdrop, 255)
call ShowFrame(ExtraBackdrop)
else
call SetFrameAlpha(ExtraBackdrop, 0)
call HideFrame(ExtraBackdrop)
endif
endif
if layer == VolumeUp and KeySpan and IsKeyPressed(0x01) then
if VolumeValue != 100 then
set VolumeValue = VolumeValue + 5
endif
endif
if layer == VolumeDown and KeySpan and IsKeyPressed(0x01) then
if VolumeValue != 0 then
set VolumeValue = VolumeValue - 5
endif
endif
if layer == RndTrack and KeySpan and IsKeyPressed(0x01) then
set Paused = false
call PlayRndTrack()
endif
if layer == Stop and KeySpan and IsKeyPressed(0x01) then
set Current = 0
set CurrentTime = 0
call SetFrameMinMaxValue(Slider, 0, MusicDurations[Current])
call SetFrameText(MusicName, MusicNames[Current])
set Paused = true
call SetFrameText(Pause, "||>")
call StopMusic(false)
endif
if IsKeyPressed(0x01) then
set KeySpan = false
else
set KeySpan = true
endif
if not Paused then
set CurrentTime = CurrentTime + 100
endif
if CurrentTime >= MusicDurations[Current] then
call PlayNextTrack()
endif
call SetFrameText(Volume, I2S(VolumeValue) + "%")
call SetMusicVolumeBJ(VolumeValue)
call SetFrameValue(Slider, CurrentTime)
endif
set i = i + 1
endloop
endfunction
//===========================================================================
function InitTrig_MouseEvent takes nothing returns nothing
set gg_trg_MouseEvent = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( gg_trg_MouseEvent, 0.10 )
call TriggerAddAction( gg_trg_MouseEvent, function Trig_MouseEvent_Actions )
endfunction
`
ОЖИДАНИЕ РЕКЛАМЫ...
Чтобы оставить комментарий, пожалуйста, войдите на сайт.
Требуется:
Кнопка стоп
Регулировка громкости +/-
Случайный трек.
Есть пауза.
Остальные два пункта очень просто добавить.
15 минут и будет расширенный функционал.