the great unicodification
This commit is contained in:
parent
2cae4b194d
commit
7381c911e5
@ -90,7 +90,7 @@ class AOwebSocket(object):
|
|||||||
return 0, totals
|
return 0, totals
|
||||||
|
|
||||||
def send(self, data):
|
def send(self, data):
|
||||||
return self.sock.send(str(data))
|
return self.sock.send(unicode(data))
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
self.sock.close()
|
self.sock.close()
|
||||||
|
41
gameview.py
41
gameview.py
@ -257,6 +257,8 @@ class AOCharMovie(QtGui.QLabel):
|
|||||||
self.pillow_frames = []
|
self.pillow_frames = []
|
||||||
self.pillow_frame = 0
|
self.pillow_frame = 0
|
||||||
|
|
||||||
|
p_char = p_char.decode('utf-8')
|
||||||
|
|
||||||
original_path = AOpath+"characters/"+p_char+"/"+emote_prefix+p_emote+".gif"
|
original_path = AOpath+"characters/"+p_char+"/"+emote_prefix+p_emote+".gif"
|
||||||
alt_path = AOpath+"characters/"+p_char+"/"+p_emote+".png"
|
alt_path = AOpath+"characters/"+p_char+"/"+p_emote+".png"
|
||||||
apng_path = AOpath+"characters/"+p_char+"/"+emote_prefix+p_emote+".apng"
|
apng_path = AOpath+"characters/"+p_char+"/"+emote_prefix+p_emote+".apng"
|
||||||
@ -474,6 +476,8 @@ class AOMovie(QtGui.QLabel):
|
|||||||
gif_path = p_image
|
gif_path = p_image
|
||||||
pillow_modes = {".gif": 0, ".apng": 1, ".webp": 2}
|
pillow_modes = {".gif": 0, ".apng": 1, ".webp": 2}
|
||||||
|
|
||||||
|
p_image = unicode(p_image)
|
||||||
|
|
||||||
if not exists(gif_path):
|
if not exists(gif_path):
|
||||||
pathlist = [
|
pathlist = [
|
||||||
get_img_suffix(AO2XPpath+"themes/default/"+p_image+"_bubble"),
|
get_img_suffix(AO2XPpath+"themes/default/"+p_image+"_bubble"),
|
||||||
@ -1289,20 +1293,20 @@ class gui(QtGui.QWidget):
|
|||||||
self.selectedemote = 0
|
self.selectedemote = 0
|
||||||
self.current_emote_page = 0
|
self.current_emote_page = 0
|
||||||
|
|
||||||
# TESTTEST
|
|
||||||
print type(charname)
|
|
||||||
print type(AOpath + 'characters/' + charname + '/char.ini')
|
|
||||||
|
|
||||||
effectslist = ini.get_effects(charname)
|
effectslist = ini.get_effects(charname)
|
||||||
self.effectdropdown.setVisible(bool(effectslist))
|
self.effectdropdown.setVisible(bool(effectslist))
|
||||||
if effectslist:
|
if effectslist:
|
||||||
effectslist.insert(0, "No effect")
|
effectslist.insert(0, "No effect")
|
||||||
self.effectdropdown.addItems(effectslist)
|
self.effectdropdown.addItems(effectslist)
|
||||||
|
|
||||||
self.charname = ini.read_ini(AOpath + 'characters/' + charname + '/char.ini', "options", "name", charname)
|
charname = unicode(charname)
|
||||||
|
|
||||||
|
self.charname = unicode(ini.read_ini(AOpath + 'characters/' + charname + '/char.ini', "options", "name", charname), "utf-8")
|
||||||
self.charside = ini.read_ini(AOpath + 'characters/' + charname + '/char.ini', "options", "side", "def")
|
self.charside = ini.read_ini(AOpath + 'characters/' + charname + '/char.ini', "options", "side", "def")
|
||||||
|
|
||||||
self.posdropdown.setCurrentIndex(self.posdropdown.findText(self.charside))
|
self.posdropdown.setCurrentIndex(self.posdropdown.findText(self.charside))
|
||||||
self.setJudgeButtons()
|
self.setJudgeButtons()
|
||||||
|
|
||||||
for emoteind in range(1, ini.read_ini_int(AOpath+"characters/"+self.charname+"/char.ini", "emotions", "number") + 1):
|
for emoteind in range(1, ini.read_ini_int(AOpath+"characters/"+self.charname+"/char.ini", "emotions", "number") + 1):
|
||||||
if emoteind == 1:
|
if emoteind == 1:
|
||||||
suffix = 'on'
|
suffix = 'on'
|
||||||
@ -1354,9 +1358,15 @@ class gui(QtGui.QWidget):
|
|||||||
for n_emote in range(emotes_on_page):
|
for n_emote in range(emotes_on_page):
|
||||||
n_real_emote = n_emote + self.current_emote_page * self.max_emotes_on_page
|
n_real_emote = n_emote + self.current_emote_page * self.max_emotes_on_page
|
||||||
if n_real_emote == self.selectedemote:
|
if n_real_emote == self.selectedemote:
|
||||||
self.emotebuttons[n_emote].setPixmap(QtGui.QPixmap(AOpath + 'characters/' + self.charname + '/emotions/button' + str(n_real_emote + 1) + '_on.png'))
|
image = QtGui.QPixmap(AOpath + 'characters/' + self.charname + '/emotions/button' + str(n_real_emote + 1) + '_on.png')
|
||||||
else:
|
else:
|
||||||
self.emotebuttons[n_emote].setPixmap(QtGui.QPixmap(AOpath + 'characters/' + self.charname + '/emotions/button' + str(n_real_emote + 1) + '_off.png'))
|
image = QtGui.QPixmap(AOpath + 'characters/' + self.charname + '/emotions/button' + str(n_real_emote + 1) + '_off.png')
|
||||||
|
|
||||||
|
if image.width() > 40:
|
||||||
|
self.emotebuttons[n_emote].setPixmap(image.scaled(40, 40, QtCore.Qt.IgnoreAspectRatio, QtCore.Qt.FastTransformation))
|
||||||
|
else:
|
||||||
|
self.emotebuttons[n_emote].setPixmap(image)
|
||||||
|
|
||||||
self.emotebuttons[n_emote].show()
|
self.emotebuttons[n_emote].show()
|
||||||
|
|
||||||
def iniswap_index_change(self, ind):
|
def iniswap_index_change(self, ind):
|
||||||
@ -1452,9 +1462,14 @@ class gui(QtGui.QWidget):
|
|||||||
for button in self.emotebuttons:
|
for button in self.emotebuttons:
|
||||||
if button.emoteid == ind:
|
if button.emoteid == ind:
|
||||||
button.path = AOpath + 'characters/' + self.charname + '/emotions/button' + str(button.emoteid + self.current_emote_page * self.max_emotes_on_page + 1)
|
button.path = AOpath + 'characters/' + self.charname + '/emotions/button' + str(button.emoteid + self.current_emote_page * self.max_emotes_on_page + 1)
|
||||||
button.setPixmap(QtGui.QPixmap(button.path + '_on.png'))
|
image = QtGui.QPixmap(button.path + '_on.png')
|
||||||
else:
|
else:
|
||||||
button.setPixmap(QtGui.QPixmap(AOpath + 'characters/' + self.charname + '/emotions/button' + str(button.emoteid + self.current_emote_page * self.max_emotes_on_page + 1) + '_off.png'))
|
image = QtGui.QPixmap(AOpath + 'characters/' + self.charname + '/emotions/button' + str(button.emoteid + self.current_emote_page * self.max_emotes_on_page + 1) + '_off.png')
|
||||||
|
|
||||||
|
if image.width() > 40:
|
||||||
|
button.setPixmap(image.scaled(40, 40, QtCore.Qt.IgnoreAspectRatio, QtCore.Qt.FastTransformation))
|
||||||
|
else:
|
||||||
|
button.setPixmap(image)
|
||||||
|
|
||||||
def setChatColor(self, ind):
|
def setChatColor(self, ind):
|
||||||
self.mychatcolor = ind
|
self.mychatcolor = ind
|
||||||
@ -1581,7 +1596,7 @@ class gui(QtGui.QWidget):
|
|||||||
msg += emote[1]+"#" #pre-anim
|
msg += emote[1]+"#" #pre-anim
|
||||||
msg += self.charname+"#"
|
msg += self.charname+"#"
|
||||||
msg += emote[2]+"#" #anim
|
msg += emote[2]+"#" #anim
|
||||||
msg += text+"#"
|
msg += text.decode('utf-8')+"#"
|
||||||
msg += self.charside+"#"
|
msg += self.charside+"#"
|
||||||
msg += emote[4]+"#" #sfx
|
msg += emote[4]+"#" #sfx
|
||||||
msg += str(modifier)+"#" #emote modifier
|
msg += str(modifier)+"#" #emote modifier
|
||||||
@ -1734,7 +1749,7 @@ class gui(QtGui.QWidget):
|
|||||||
self.chatmessage_is_empty = self.m_chatmessage[CHATMSG] == " " or self.m_chatmessage[CHATMSG] == ""
|
self.chatmessage_is_empty = self.m_chatmessage[CHATMSG] == " " or self.m_chatmessage[CHATMSG] == ""
|
||||||
|
|
||||||
if self.msgqueue:
|
if self.msgqueue:
|
||||||
chatmsgcomp = str(self.msgqueue[0].split('#')[5]).decode('utf-8').replace('<dollar>', '$').replace('<percent>', '%').replace('<and>', '&').replace('<num>', '#')
|
chatmsgcomp = (self.msgqueue[0].split('#')[5]).replace('<dollar>', '$').replace('<percent>', '%').replace('<and>', '&').replace('<num>', '#')
|
||||||
if (chatmsgcomp == '>' or chatmsgcomp == '<') or (f_char_id == self.mychar and self.m_chatmessage[CHATMSG] == chatmsgcomp): # our message showed up
|
if (chatmsgcomp == '>' or chatmsgcomp == '<') or (f_char_id == self.mychar and self.m_chatmessage[CHATMSG] == chatmsgcomp): # our message showed up
|
||||||
del self.msgqueue[0]
|
del self.msgqueue[0]
|
||||||
self.msgqueueList.takeItem(0)
|
self.msgqueueList.takeItem(0)
|
||||||
@ -1877,7 +1892,7 @@ class gui(QtGui.QWidget):
|
|||||||
self.effectview.stop()
|
self.effectview.stop()
|
||||||
|
|
||||||
if not self.m_chatmessage[SHOWNAME]:
|
if not self.m_chatmessage[SHOWNAME]:
|
||||||
self.name.setText(self.m_chatmessage[CHARNAME])
|
self.name.setText(self.m_chatmessage[CHARNAME].decode("utf-8"))
|
||||||
else:
|
else:
|
||||||
self.name.setText(self.m_chatmessage[SHOWNAME].decode("utf-8"))
|
self.name.setText(self.m_chatmessage[SHOWNAME].decode("utf-8"))
|
||||||
|
|
||||||
|
92
ini.py
92
ini.py
@ -1,51 +1,60 @@
|
|||||||
from ConfigParser import ConfigParser
|
from ConfigParser import ConfigParser
|
||||||
from PyQt4.QtCore import QString
|
from PyQt4.QtCore import QString, QByteArray
|
||||||
from os.path import exists
|
from os.path import exists
|
||||||
|
|
||||||
def read_ini(file, section, value, default=""):
|
def read_ini(file, section, value, default=""):
|
||||||
if isinstance(file, str) or isinstance(file, QString):
|
if isinstance(file, str) or isinstance(file, QString):
|
||||||
conf = ConfigParser()
|
conf = ConfigParser()
|
||||||
conf.read(str(file))
|
conf.read(unicode(file, "utf-8"))
|
||||||
else:
|
elif isinstance(file, unicode):
|
||||||
conf = file
|
conf = ConfigParser()
|
||||||
|
conf.read(file)
|
||||||
values = conf.sections()
|
else:
|
||||||
for val in values:
|
conf = file
|
||||||
if val.lower() == section.lower():
|
|
||||||
for c in conf.options(val):
|
values = conf.sections()
|
||||||
if c.lower() == value.lower():
|
for val in values:
|
||||||
return conf.get(val, c)
|
if val.lower() == section.lower():
|
||||||
return default
|
for c in conf.options(val):
|
||||||
|
if c.lower() == value.lower():
|
||||||
|
return conf.get(val, c)
|
||||||
|
return default
|
||||||
|
|
||||||
def read_ini_bool(file, section, value, default=False):
|
def read_ini_bool(file, section, value, default=False):
|
||||||
if isinstance(file, str) or isinstance(file, QString):
|
if isinstance(file, str) or isinstance(file, QString):
|
||||||
conf = ConfigParser()
|
conf = ConfigParser()
|
||||||
conf.read(str(file))
|
conf.read(unicode(file, "utf-8"))
|
||||||
else:
|
elif isinstance(file, unicode):
|
||||||
conf = file
|
conf = ConfigParser()
|
||||||
|
conf.read(file)
|
||||||
values = conf.sections()
|
else:
|
||||||
for val in values:
|
conf = file
|
||||||
if val.lower() == section.lower():
|
|
||||||
for c in conf.options(val):
|
values = conf.sections()
|
||||||
if c.lower() == value.lower():
|
for val in values:
|
||||||
return conf.getboolean(val, c)
|
if val.lower() == section.lower():
|
||||||
return default
|
for c in conf.options(val):
|
||||||
|
if c.lower() == value.lower():
|
||||||
|
return conf.getboolean(val, c)
|
||||||
|
return default
|
||||||
|
|
||||||
def read_ini_int(file, section, value, default=0):
|
def read_ini_int(file, section, value, default=0):
|
||||||
if isinstance(file, str) or isinstance(file, QString):
|
if isinstance(file, str) or isinstance(file, QString):
|
||||||
conf = ConfigParser()
|
conf = ConfigParser()
|
||||||
conf.read(str(file))
|
conf.read(unicode(file, "utf-8"))
|
||||||
else:
|
elif isinstance(file, unicode):
|
||||||
conf = file
|
conf = ConfigParser()
|
||||||
|
conf.read(file)
|
||||||
values = conf.sections()
|
else:
|
||||||
for val in values:
|
conf = file
|
||||||
if val.lower() == section.lower():
|
|
||||||
for c in conf.options(val):
|
values = conf.sections()
|
||||||
if c.lower() == value.lower():
|
for val in values:
|
||||||
return conf.getint(val, c)
|
if val.lower() == section.lower():
|
||||||
return default
|
for c in conf.options(val):
|
||||||
|
if c.lower() == value.lower():
|
||||||
|
return conf.getint(val, c)
|
||||||
|
return default
|
||||||
|
|
||||||
def read_sectionless_ini(file, search, default=""):
|
def read_sectionless_ini(file, search, default=""):
|
||||||
if isinstance(file, QString): file = str(file)
|
if isinstance(file, QString): file = str(file)
|
||||||
@ -73,6 +82,9 @@ def read_ini_tags(file, target_tag):
|
|||||||
if isinstance(file, str) or isinstance(file, QString):
|
if isinstance(file, str) or isinstance(file, QString):
|
||||||
conf = ConfigParser()
|
conf = ConfigParser()
|
||||||
conf.read(str(file))
|
conf.read(str(file))
|
||||||
|
elif isinstance(file, unicode):
|
||||||
|
conf = ConfigParser()
|
||||||
|
conf.read(file)
|
||||||
else:
|
else:
|
||||||
conf = file
|
conf = file
|
||||||
|
|
||||||
|
1117
mainmenu.py
1117
mainmenu.py
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user