Create objects for tracking audio devices
This commit is contained in:
@@ -37,20 +37,34 @@ var AudioFileList = []db.AudioFile{
|
|||||||
|
|
||||||
const triangleSize = float32(16)
|
const triangleSize = float32(16)
|
||||||
|
|
||||||
|
type AudioDevice struct {
|
||||||
|
Label string
|
||||||
|
ID int
|
||||||
|
}
|
||||||
|
|
||||||
type AudioOptions struct {
|
type AudioOptions struct {
|
||||||
|
// Page Attributes
|
||||||
Base
|
Base
|
||||||
font *fontManager.FontEntry
|
font *fontManager.FontEntry
|
||||||
textShader *shaderManager.Shader
|
textShader *shaderManager.Shader
|
||||||
solidShader *shaderManager.Shader
|
solidShader *shaderManager.Shader
|
||||||
title StringItem
|
CfgPtr *db.AppConfig
|
||||||
prompt StringItem
|
|
||||||
|
// Page Textures
|
||||||
|
title StringItem
|
||||||
|
prompt StringItem
|
||||||
|
|
||||||
|
// Layout
|
||||||
verticalMargin int32
|
verticalMargin int32
|
||||||
ItemScale float32
|
ItemScale float32
|
||||||
CfgPtr *db.AppConfig
|
|
||||||
|
|
||||||
// Audio toggle
|
// Audio toggle
|
||||||
AudioStatusToggle StringItem
|
AudioStatusToggle StringItem
|
||||||
|
|
||||||
|
// Audio Devices
|
||||||
|
AudioDevices []AudioDevice
|
||||||
|
AudioDeviceTextures []StringItem
|
||||||
|
|
||||||
// Volume row
|
// Volume row
|
||||||
VolumeLabel StringItem
|
VolumeLabel StringItem
|
||||||
volumePercent StringItem
|
volumePercent StringItem
|
||||||
@@ -187,6 +201,29 @@ func (p *AudioOptions) CreateAudioStatusItem() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ── Audio Output Devices ──────────────────────────────────────────────────────
|
||||||
|
func (p *AudioOptions) GetAudioDevices() error {
|
||||||
|
numAudioDevices := sdl.GetNumAudioDevices(false)
|
||||||
|
if numAudioDevices == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
var audioDevices = make([]AudioDevice, numAudioDevices)
|
||||||
|
for i := range numAudioDevices {
|
||||||
|
audioDevice := sdl.GetAudioDeviceName(i, false)
|
||||||
|
audioDevices = append(audioDevices, AudioDevice{Label: audioDevice, ID: i})
|
||||||
|
}
|
||||||
|
p.AudioDevices = audioDevices
|
||||||
|
|
||||||
|
for i := range audioDevices {
|
||||||
|
newAudioDeviceStringItem, err := NewStringItem(p.AudioDevices[i].Label, p.font, colors.White)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
p.AudioDeviceTextures = append(p.AudioDeviceTextures, newAudioDeviceStringItem)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// ── Volume ────────────────────────────────────────────────────────────────────
|
// ── Volume ────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
func (p *AudioOptions) CreateVolumePercentItem() error {
|
func (p *AudioOptions) CreateVolumePercentItem() error {
|
||||||
@@ -335,7 +372,7 @@ func (p *AudioOptions) renderVolumeBar() error {
|
|||||||
{{bx, by}, {bw, thickness}},
|
{{bx, by}, {bw, thickness}},
|
||||||
{{bx, by + bh - thickness}, {bw, thickness}},
|
{{bx, by + bh - thickness}, {bw, thickness}},
|
||||||
{{bx, by}, {thickness, bh}},
|
{{bx, by}, {thickness, bh}},
|
||||||
{{bx + bw - thickness}, {thickness, bh}},
|
{{bx + bw - thickness, by}, {thickness, bh}},
|
||||||
}
|
}
|
||||||
for _, r := range outlineRects {
|
for _, r := range outlineRects {
|
||||||
if err := p.RenderSolidColorQuad(p.solidShader, r[0], r[1], colors.Green); err != nil {
|
if err := p.RenderSolidColorQuad(p.solidShader, r[0], r[1], colors.Green); err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user