Skip to content
This repository has been archived by the owner on Aug 29, 2020. It is now read-only.

Commit

Permalink
Fix xOptionsMenu for ASYS.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hoikas committed Sep 23, 2019
1 parent 7d44eae commit 4baa20d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
4 changes: 2 additions & 2 deletions Python/xIniAudio.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,9 @@ def SetAudioMode(init, device, eax):

print device
if entryDev:
entryDev.setValue(0, "\"" + device + "\"")
entryDev.setValue(0, "\"" + device.encode("utf-8") + "\"")
else:
gIniFile.addEntry("Audio.SetDeviceName \"" + device + "\"")
gIniFile.addEntry("Audio.SetDeviceName \"" + device.encode("utf-8") + "\"")

if eax:
val = kBeTrue
Expand Down
33 changes: 17 additions & 16 deletions Python/xOptionsMenu.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
kDemoMovieName = "avi/UruPreview.webm"
gPreviewStarted = 0
prevAudioDeviceName = None
gAudioDevices = ()

# =====================================
# Aspect Ratios
Expand Down Expand Up @@ -1244,15 +1245,15 @@ def OnGUINotify(self,id,control,event):
if self.restartAudio:
audio = ptAudioControl()
audioField = ptGUIControlKnob(AudioSettingsDlg.dialog.getControlFromTag(kAudioModeID))
audModeNum = audio.getNumAudioDevices() - 1
audModeNum = len(gAudioDevices) - 1
curSelection = round(audioField.getValue() * audModeNum)
intCurSelection = int(curSelection)

#Enable EAX Support
EAXcheckbox = ptGUIControlCheckBox(AudioSettingsDlg.dialog.getControlFromTag(kAudioModeCBID03))
audio.useEAXAcceleration(EAXcheckbox.isChecked())

audio.setDeviceName(audio.getAudioDeviceName(intCurSelection), 1)
audio.setPlaybackDevice(gAudioDevices[intCurSelection], 1)
self.WriteAudioControls()

elif event == kAction or event == kValueChanged:
Expand Down Expand Up @@ -1310,23 +1311,20 @@ def OnGUINotify(self,id,control,event):
self.restartAudio = 1
audio = ptAudioControl()
#~ print "Number of Audio Devices: %d" % (audio.getNumAudioDevices())
audModeNum = audio.getNumAudioDevices() - 1
audModeNum = len(gAudioDevices) - 1
curSelection = round(control.getValue() * audModeNum)
intCurSelection = int(curSelection)
control.setValue(curSelection/audModeNum)

audioDeviceName = audio.getAudioDeviceName(intCurSelection)

audioDeviceName = gAudioDevices[intCurSelection]
audioModeCtrlTextBox = ptGUIControlTextBox(AudioSettingsDlg.dialog.getControlFromTag(kAudioModeTextID))
curText = audioModeCtrlTextBox.getString()
if curText != audio.getAudioDeviceName(intCurSelection):
audioModeCtrlTextBox.setString(audioDeviceName)
audioModeCtrlTextBox.setStringW(audio.getFriendlyDeviceName(audioDeviceName))

if audioDeviceName != prevAudioDeviceName: #Only update the EAX checkbox when the mouse has been let up...
print "Audio Device Name changed!"
prevAudioDeviceName = audioDeviceName
EAXcheckbox = ptGUIControlCheckBox(AudioSettingsDlg.dialog.getControlFromTag(kAudioModeCBID03))
if not audio.supportsEAX(audioDeviceName):
if not audio.isEAXSupported():
print "Disabling EAX checkbox"
#Disable EAX checkbox
EAXcheckbox.disable()
Expand Down Expand Up @@ -1670,7 +1668,7 @@ def WriteAudioControls(self):

EAXcheckbox = ptGUIControlCheckBox(AudioSettingsDlg.dialog.getControlFromTag(kAudioModeCBID03))

xIniAudio.SetAudioMode( true, audio.getDeviceName(), EAXcheckbox.isChecked() )
xIniAudio.SetAudioMode( true, audio.getPlaybackDevice(), EAXcheckbox.isChecked() )
#xIniAudio.SetAudioMode( audio.isEnabled(), audio.getDeviceName(), EAXcheckbox.isChecked() )
#xIniAudio.SetAudioMode( audio.isEnabled(), audio.getDeviceName(), audio.isUsingEAXAcceleration() )
#xIniAudio.SetMicLevel( audio.getMicLevel() )
Expand All @@ -1679,11 +1677,14 @@ def WriteAudioControls(self):
xIniAudio.WriteIni()

def InitAudioControlsGUI(self):
global gAudioDevices
global prevAudioDeviceName

xIniAudio.ReadIni()
audio = ptAudioControl()

gAudioDevices = audio.getPlaybackDevices()

audioField = ptGUIControlKnob(AudioSettingsDlg.dialog.getControlFromTag(kAudioNumberOfSoundsSliderTag))
audioField.setValue( audio.getPriorityCutoff() )

Expand Down Expand Up @@ -1714,21 +1715,21 @@ def InitAudioControlsGUI(self):
respDisableItems.run(self.key, state="enableEAX")

audioField = ptGUIControlKnob(AudioSettingsDlg.dialog.getControlFromTag(kAudioModeID))
numAudioDevices = audio.getNumAudioDevices() - 1.0
numAudioDevices = len(gAudioDevices) - 1.0

if numAudioDevices > 0:
for num in range(audio.getNumAudioDevices()):
if audio.getAudioDeviceName(num) == audio.getDeviceName():
if not audio.supportsEAX(audio.getDeviceName()):
for num, device in enumerate(gAudioDevices):
if gAudioDevices[num] == audio.getPlaybackDevice():
if not audio.isEAXSupported():
EAXcheckbox.disable()
respDisableItems.run(self.key, state="disableEAX")
EAXcheckbox.setChecked(false)
ptGUIControlTextBox(AudioSettingsDlg.dialog.getControlFromTag(kAudioModeEAXTextID)).setForeColor(ptColor(0.839, 0.785, 0.695, 1))

audioField.setValue(num/numAudioDevices)
audioModeCtrlTextBox = ptGUIControlTextBox(AudioSettingsDlg.dialog.getControlFromTag(kAudioModeTextID))
audioDeviceName = prevAudioDeviceName = audio.getAudioDeviceName(num)
audioModeCtrlTextBox.setString(audioDeviceName)
audioDeviceName = prevAudioDeviceName = audio.getPlaybackDevice()
audioModeCtrlTextBox.setStringW(audio.getFriendlyDeviceName(device))
else:
EAXcheckbox.disable()
respDisableItems.run(self.key, state="disableEAX")
Expand Down

0 comments on commit 4baa20d

Please sign in to comment.