initial linux support (check for lowercase dirs)
This commit is contained in:
parent
448dbeb63e
commit
a524e0d3ca
5
AO2XP.py
5
AO2XP.py
@ -95,6 +95,11 @@ if not debugmode:
|
||||
|
||||
import gameview, mainmenu, options
|
||||
|
||||
# This hides stupid useless QT warnings
|
||||
def handler(msg_type, msg_string):
|
||||
pass
|
||||
QtCore.qInstallMsgHandler(handler)
|
||||
|
||||
audio.init()
|
||||
shit = gamewindow()
|
||||
shit.show()
|
||||
|
19
audio.py
19
audio.py
@ -34,9 +34,11 @@ Returns string with dll name if it's missing, empty if all DLLs are in place
|
||||
one = os.path.exists(os.path.abspath(dllf))
|
||||
two = os.path.exists(os.path.abspath(opus))
|
||||
three = os.path.exists(os.path.abspath(flac))
|
||||
four = os.path.exists(os.path.abspath(midi))
|
||||
if not one: return dllf
|
||||
if not two: return two
|
||||
if not three: return three
|
||||
if not four: return four
|
||||
return ""
|
||||
|
||||
|
||||
@ -54,12 +56,19 @@ Initialize BASS and the opus plugin
|
||||
import pybass as dll
|
||||
import pybass.pybassmidi as bassmidi
|
||||
|
||||
dll.BASS_Init(ini.read_ini_int("AO2XP.ini", "Audio", "device", -1), freq, 0, 0, 0)
|
||||
dll.BASS_PluginLoad(os.path.abspath(opus), 0)
|
||||
dll.BASS_PluginLoad(os.path.abspath(flac), 0)
|
||||
dll.BASS_PluginLoad(os.path.abspath(midi), 0)
|
||||
if not dll.BASS_Init(ini.read_ini_int("AO2XP.ini", "Audio", "device", -1), freq, 0, 0, 0):
|
||||
print "[audio] Audio library could not be initialized. Error", self.getbasserror()
|
||||
if not dll.BASS_PluginLoad(os.path.abspath(opus), 0):
|
||||
print "[audio] Opus plugin failed to load. Error", self.getbasserror()
|
||||
if not dll.BASS_PluginLoad(os.path.abspath(flac), 0):
|
||||
print "[audio] FLAC plugin failed to load. Error", self.getbasserror()
|
||||
if not dll.BASS_PluginLoad(os.path.abspath(midi), 0):
|
||||
print "[audio] MIDI plugin failed to load. Error", self.getbasserror()
|
||||
|
||||
dll.BASS_SetConfigPtr(bassmidi.BASS_CONFIG_MIDI_DEFFONT, "gm.sf2");
|
||||
if os.path.exists(os.path.abspath("gm.sf2")):
|
||||
dll.BASS_SetConfigPtr(bassmidi.BASS_CONFIG_MIDI_DEFFONT, "gm.sf2");
|
||||
else:
|
||||
print "[audio] Soundfont not fount. MIDI files will not play."
|
||||
|
||||
def free():
|
||||
"""
|
||||
|
@ -9,7 +9,7 @@ AO2XPpath = "AO2XPbase/"
|
||||
|
||||
def get_option(section, value, default=""):
|
||||
tempini = ConfigParser()
|
||||
tempini.read("ao2xp.ini")
|
||||
tempini.read("AO2XP.ini")
|
||||
return ini.read_ini(tempini, section, value, default)
|
||||
|
||||
class CharIcon(QtGui.QLabel):
|
||||
@ -111,10 +111,11 @@ class charselect(QtGui.QWidget):
|
||||
else:
|
||||
self.prevpage.hide()
|
||||
|
||||
if exists(AOpath+"characters/"+self.charlist[ind][0]+"/char_icon.png"): # AO2
|
||||
self.setBtnImage.emit(AOpath+"characters/"+self.charlist[ind][0]+"/char_icon.png", i)
|
||||
elif exists(AOpath+"misc/demothings/"+self.charlist[ind][0]+"_char_icon.png"): # AO 1.7.5/1.8
|
||||
self.setBtnImage.emit(AOpath+"misc/demothings/"+self.charlist[ind][0]+"_char_icon.png", i)
|
||||
char = self.charlist[ind][0].lower()
|
||||
if exists(AOpath+"characters/"+ char +"/char_icon.png"): # AO2
|
||||
self.setBtnImage.emit(AOpath+"characters/"+ char +"/char_icon.png", i)
|
||||
elif exists(AOpath+"misc/demothings/"+ char +"_char_icon.png"): # AO 1.7.5/1.8
|
||||
self.setBtnImage.emit(AOpath+"misc/demothings/"+ char +"_char_icon.png", i)
|
||||
else:
|
||||
self.setBtnImage.emit("placeholder.png", i)
|
||||
|
||||
|
68
gameview.py
68
gameview.py
@ -80,7 +80,7 @@ def encode_ao_str(text):
|
||||
|
||||
def get_char_ini(char, section, value, default=""):
|
||||
tempini = ConfigParser()
|
||||
with open(AOpath + 'characters/' + char + '/char.ini', 'r') as file:
|
||||
with open(AOpath + 'characters/' + char.lower() + '/char.ini', 'r') as file:
|
||||
for line in file:
|
||||
try:
|
||||
tempini.readfp(file)
|
||||
@ -261,7 +261,7 @@ class AOCharMovie(QtGui.QLabel):
|
||||
self.pillow_frames = []
|
||||
self.pillow_frame = 0
|
||||
|
||||
p_char = p_char.decode('utf-8')
|
||||
p_char = p_char.lower().decode('utf-8')
|
||||
|
||||
original_path = AOpath+"characters/"+p_char+"/"+emote_prefix+p_emote+".gif"
|
||||
alt_path = AOpath+"characters/"+p_char+"/"+p_emote+".png"
|
||||
@ -335,6 +335,7 @@ class AOCharMovie(QtGui.QLabel):
|
||||
self.show()
|
||||
|
||||
def play_pre(self, p_char, p_emote, duration):
|
||||
p_char = p_char.lower()
|
||||
gif_path = AOpath+"characters/"+p_char+"/"+p_emote+".gif"
|
||||
apng_path = AOpath+"characters/"+p_char+"/"+p_emote+".apng"
|
||||
webp_path = AOpath+"characters/"+p_char+"/"+p_emote+".webp"
|
||||
@ -381,6 +382,7 @@ class AOCharMovie(QtGui.QLabel):
|
||||
self.play(p_char, p_emote, "")
|
||||
|
||||
def play_talking(self, p_char, p_emote):
|
||||
p_char = p_char.lower()
|
||||
gif_path = AOpath + 'characters/' + p_char + '/(b)' + p_emote + '.gif'
|
||||
|
||||
self.m_movie.stop()
|
||||
@ -394,6 +396,7 @@ class AOCharMovie(QtGui.QLabel):
|
||||
self.play(p_char, p_emote, '(b)')
|
||||
|
||||
def play_idle(self, p_char, p_emote):
|
||||
p_char = p_char.lower()
|
||||
gif_path = AOpath + 'characters/' + p_char + '/(a)' + p_emote + '.gif'
|
||||
|
||||
self.m_movie.stop()
|
||||
@ -1349,9 +1352,9 @@ class gui(QtGui.QWidget):
|
||||
effectslist.insert(0, "No effect")
|
||||
self.effectdropdown.addItems(effectslist)
|
||||
|
||||
charname = unicode(charname)
|
||||
charname = unicode(charname.toLower())
|
||||
|
||||
self.charname = unicode(ini.read_ini(AOpath + 'characters/' + charname + '/char.ini', "options", "name", charname), "utf-8")
|
||||
self.charname = ini.read_ini(AOpath + 'characters/' + charname + '/char.ini', "options", "name", charname).decode('utf-8').lower()
|
||||
self.charside = ini.read_ini(AOpath + 'characters/' + charname + '/char.ini', "options", "side", "def")
|
||||
|
||||
self.posdropdown.setCurrentIndex(self.posdropdown.findText(self.charside))
|
||||
@ -1683,7 +1686,7 @@ class gui(QtGui.QWidget):
|
||||
msg += "chat#"
|
||||
|
||||
msg += emote[1]+"#" #pre-anim
|
||||
msg += self.charname+"#"
|
||||
msg += self.charname.title()+"#"
|
||||
msg += emote[2]+"#" #anim
|
||||
msg += text.decode('utf-8')+"#"
|
||||
msg += self.charside+"#"
|
||||
@ -1884,8 +1887,8 @@ class gui(QtGui.QWidget):
|
||||
|
||||
if objection_mod <= 4 and objection_mod >= 1:
|
||||
objections = ["holdit", "objection", "takethat", "custom_objections/"+custom_objection if custom_objection != "custom" else "custom"]
|
||||
self.objectionview.play(objections[objection_mod-1], f_char)
|
||||
self.playObjectionSnd(f_char, objection_mod)
|
||||
self.objectionview.play(objections[objection_mod-1], f_char.lower())
|
||||
self.playObjectionSnd(f_char.lower(), objection_mod)
|
||||
|
||||
emote_mod = int(self.m_chatmessage[EMOTE_MOD])
|
||||
if emote_mod == 0:
|
||||
@ -2484,8 +2487,8 @@ class gui(QtGui.QWidget):
|
||||
else:
|
||||
self.objectsnd = None
|
||||
if ini.read_ini_bool("AO2XP.ini", "General", "download sounds", True):
|
||||
thread.start_new_thread(download_thread, ("base/characters/"+charname.lower()+"/"+objecting.lower()+".wav", AOpath+"characters/"+charname.lower()+"/"+objecting.lower()+".wav"))
|
||||
thread.start_new_thread(download_thread, ("base/characters/"+charname.lower()+"/"+objecting.lower()+".opus", AOpath+"characters/"+charname.lower()+"/"+objecting.lower()+".wav"))
|
||||
thread.start_new_thread(download_thread, ("base/characters/"+charname+"/"+objecting+".wav", AOpath+"characters/"+charname+"/"+objecting.lower()+".wav"))
|
||||
thread.start_new_thread(download_thread, ("base/characters/"+charname+"/"+objecting+".opus", AOpath+"characters/"+charname+"/"+objecting.lower()+".wav"))
|
||||
|
||||
if exists(AOpath + 'sounds/general/sfx-objection.opus'):
|
||||
self.objectsnd = audio.loadhandle(False, AOpath + 'sounds/general/sfx-objection.opus', 0, 0, 0)
|
||||
@ -2524,24 +2527,18 @@ class gui(QtGui.QWidget):
|
||||
audio.playhandle(self.sound, True)
|
||||
|
||||
def playMusic(self, mus):
|
||||
if mus == "~stop.mp3":
|
||||
self.stopMusic()
|
||||
return
|
||||
|
||||
if not mus.endswith(".mp3") and "===MUSIC START===.mp3" in self.musiclist: #vidya workaround
|
||||
mus += ".mp3"
|
||||
|
||||
# if self.music:
|
||||
# if audio.handleisactive(self.music):
|
||||
# audio.stophandle(self.music)
|
||||
# audio.freehandle(self.music)
|
||||
# if self.stream:
|
||||
# self.stream = None
|
||||
|
||||
# if self.download_thread:
|
||||
# self.download_thread.terminate() # Live dangerously
|
||||
# self.download_thread = None
|
||||
musl = mus.lower()
|
||||
|
||||
self.stopMusic()
|
||||
|
||||
if exists(AOpath + 'sounds/music/' + mus):
|
||||
self.music = audio.loadhandle(False, AOpath + 'sounds/music/' + mus, 0, 0, BASS_SAMPLE_LOOP)
|
||||
if exists(AOpath + 'sounds/music/' + musl):
|
||||
self.music = audio.loadhandle(False, AOpath + 'sounds/music/' + musl, 0, 0, BASS_SAMPLE_LOOP)
|
||||
audio.sethandleattr(self.music, BASS_ATTRIB_VOL, self.musicslider.value() / 100.0)
|
||||
audio.playhandle(self.music, True)
|
||||
|
||||
@ -2549,12 +2546,12 @@ class gui(QtGui.QWidget):
|
||||
if mus.lower().startswith("http"):
|
||||
#self.music = audio.loadURLhandle(mus, 0, BASS_STREAM_BLOCK | BASS_SAMPLE_LOOP)
|
||||
self.music = audio.loadURLhandle(mus, 0, BASS_SAMPLE_LOOP)
|
||||
print "[audio] Trying to play", mus.lower()
|
||||
print "[audio] Trying to play", mus
|
||||
else:
|
||||
for bucket in buckets:
|
||||
if not bucket: continue
|
||||
print "[audio] Music stream:", bucket+'base/sounds/music/' + mus.lower()
|
||||
self.music = audio.loadURLhandle(bucket+'base/sounds/music/' + mus.lower(), 0, BASS_STREAM_BLOCK | BASS_SAMPLE_LOOP)
|
||||
print "[audio] Music stream:", bucket+'base/sounds/music/' + mus
|
||||
self.music = audio.loadURLhandle(bucket+'base/sounds/music/' + musl, 0, BASS_STREAM_BLOCK | BASS_SAMPLE_LOOP)
|
||||
if self.music: break
|
||||
|
||||
if self.music:
|
||||
@ -2563,7 +2560,6 @@ class gui(QtGui.QWidget):
|
||||
else:
|
||||
print "[audio] Couldn't play music. Error", audio.getbasserror()
|
||||
# Here comes the evil HTTPS hack for XP systems, but it also allows us to download and play modules and midis, because, why not?
|
||||
musl = mus.lower()
|
||||
musext = os.path.splitext(basename(musl))[-1]
|
||||
if musext in ['.mid', '.midi']:
|
||||
self.specialstream = 1
|
||||
@ -2657,7 +2653,7 @@ class gui(QtGui.QWidget):
|
||||
self.healthbars.emit(hp[0], hp[1])
|
||||
|
||||
for char in self.charlist:
|
||||
if not exists(AOpath + 'characters/' + char[0] + '/char.ini'):
|
||||
if not exists(AOpath + 'characters/' + char[0].lower() + '/char.ini'):
|
||||
continue
|
||||
char[2] = get_char_ini(char[0], "options", "gender", "male")
|
||||
|
||||
@ -2691,10 +2687,15 @@ class gui(QtGui.QWidget):
|
||||
song = song.replace("<and>","&").decode('utf-8')
|
||||
songitem = QtGui.QListWidgetItem()
|
||||
songitem.setText(song)
|
||||
if exists(AOpath + 'sounds/music/' + song):
|
||||
try:
|
||||
if not song.endswith("mp3") and not song.endswith("opus") :
|
||||
print song
|
||||
except:
|
||||
pass
|
||||
if exists(AOpath + 'sounds/music/' + song.lower()):
|
||||
songitem.setBackgroundColor(QtGui.QColor(128, 255, 128))
|
||||
else:
|
||||
songitem.setBackgroundColor(QtGui.QColor(255, 128, 128))
|
||||
#else:
|
||||
#songitem.setBackgroundColor(QtGui.QColor(255, 128, 128))
|
||||
self.musicitems.addItem(songitem)
|
||||
|
||||
for pid in playerlist:
|
||||
@ -3039,7 +3040,7 @@ class TCP_Thread(QtCore.QThread):
|
||||
self.send_attempts += 1
|
||||
if self.send_attempts >= self.max_attempts:
|
||||
self.send_attempts = 0
|
||||
print "[warning] message discarded"
|
||||
#print "[warning] message discarded"
|
||||
del self.parent.msgqueue[0]
|
||||
self.parent.msgqueueList.takeItem(0)
|
||||
continue
|
||||
@ -3074,14 +3075,13 @@ class TCP_Thread(QtCore.QThread):
|
||||
|
||||
if len(network) > 3 and network[3]:
|
||||
name += " ("+network[3].decode("utf-8")+")"
|
||||
#self.parent.icLog.append('[%d:%.2d] %s changed the music to %s' % (t[3], t[4], name, music))
|
||||
self.IC_Log.emit('[%d:%.2d] %s changed the music to %s' % (t[3], t[4], name, music))
|
||||
else:
|
||||
self.IC_Log.emit('[%d:%.2d] the music was changed to %s' % (t[3], t[4], music))
|
||||
self.IC_Log.emit('[%d:%.2d] The music was changed to %s' % (t[3], t[4], music))
|
||||
self.parent.playMusic(music)
|
||||
|
||||
elif header == 'BN':
|
||||
self.newBackground.emit(network[1])
|
||||
self.newBackground.emit(network[1].lower())
|
||||
|
||||
elif header == 'CT':
|
||||
name = decode_ao_str(network[1].decode('utf-8'))
|
||||
|
Loading…
Reference in New Issue
Block a user