the great unicodification

This commit is contained in:
cidoku 2025-02-13 00:31:36 -03:00
parent 2cae4b194d
commit 7381c911e5
4 changed files with 640 additions and 612 deletions

View File

@ -90,7 +90,7 @@ class AOwebSocket(object):
return 0, totals
def send(self, data):
return self.sock.send(str(data))
return self.sock.send(unicode(data))
def close(self):
self.sock.close()

View File

@ -257,6 +257,8 @@ class AOCharMovie(QtGui.QLabel):
self.pillow_frames = []
self.pillow_frame = 0
p_char = p_char.decode('utf-8')
original_path = AOpath+"characters/"+p_char+"/"+emote_prefix+p_emote+".gif"
alt_path = AOpath+"characters/"+p_char+"/"+p_emote+".png"
apng_path = AOpath+"characters/"+p_char+"/"+emote_prefix+p_emote+".apng"
@ -474,6 +476,8 @@ class AOMovie(QtGui.QLabel):
gif_path = p_image
pillow_modes = {".gif": 0, ".apng": 1, ".webp": 2}
p_image = unicode(p_image)
if not exists(gif_path):
pathlist = [
get_img_suffix(AO2XPpath+"themes/default/"+p_image+"_bubble"),
@ -1289,20 +1293,20 @@ class gui(QtGui.QWidget):
self.selectedemote = 0
self.current_emote_page = 0
# TESTTEST
print type(charname)
print type(AOpath + 'characters/' + charname + '/char.ini')
effectslist = ini.get_effects(charname)
self.effectdropdown.setVisible(bool(effectslist))
if effectslist:
effectslist.insert(0, "No effect")
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.posdropdown.setCurrentIndex(self.posdropdown.findText(self.charside))
self.setJudgeButtons()
for emoteind in range(1, ini.read_ini_int(AOpath+"characters/"+self.charname+"/char.ini", "emotions", "number") + 1):
if emoteind == 1:
suffix = 'on'
@ -1354,9 +1358,15 @@ class gui(QtGui.QWidget):
for n_emote in range(emotes_on_page):
n_real_emote = n_emote + self.current_emote_page * self.max_emotes_on_page
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:
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()
def iniswap_index_change(self, ind):
@ -1452,9 +1462,14 @@ class gui(QtGui.QWidget):
for button in self.emotebuttons:
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.setPixmap(QtGui.QPixmap(button.path + '_on.png'))
image = QtGui.QPixmap(button.path + '_on.png')
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):
self.mychatcolor = ind
@ -1581,7 +1596,7 @@ class gui(QtGui.QWidget):
msg += emote[1]+"#" #pre-anim
msg += self.charname+"#"
msg += emote[2]+"#" #anim
msg += text+"#"
msg += text.decode('utf-8')+"#"
msg += self.charside+"#"
msg += emote[4]+"#" #sfx
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] == ""
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
del self.msgqueue[0]
self.msgqueueList.takeItem(0)
@ -1877,7 +1892,7 @@ class gui(QtGui.QWidget):
self.effectview.stop()
if not self.m_chatmessage[SHOWNAME]:
self.name.setText(self.m_chatmessage[CHARNAME])
self.name.setText(self.m_chatmessage[CHARNAME].decode("utf-8"))
else:
self.name.setText(self.m_chatmessage[SHOWNAME].decode("utf-8"))

20
ini.py
View File

@ -1,11 +1,14 @@
from ConfigParser import ConfigParser
from PyQt4.QtCore import QString
from PyQt4.QtCore import QString, QByteArray
from os.path import exists
def read_ini(file, section, value, default=""):
if isinstance(file, str) or isinstance(file, QString):
conf = ConfigParser()
conf.read(str(file))
conf.read(unicode(file, "utf-8"))
elif isinstance(file, unicode):
conf = ConfigParser()
conf.read(file)
else:
conf = file
@ -20,7 +23,10 @@ def read_ini(file, section, value, default=""):
def read_ini_bool(file, section, value, default=False):
if isinstance(file, str) or isinstance(file, QString):
conf = ConfigParser()
conf.read(str(file))
conf.read(unicode(file, "utf-8"))
elif isinstance(file, unicode):
conf = ConfigParser()
conf.read(file)
else:
conf = file
@ -35,7 +41,10 @@ def read_ini_bool(file, section, value, default=False):
def read_ini_int(file, section, value, default=0):
if isinstance(file, str) or isinstance(file, QString):
conf = ConfigParser()
conf.read(str(file))
conf.read(unicode(file, "utf-8"))
elif isinstance(file, unicode):
conf = ConfigParser()
conf.read(file)
else:
conf = file
@ -73,6 +82,9 @@ def read_ini_tags(file, target_tag):
if isinstance(file, str) or isinstance(file, QString):
conf = ConfigParser()
conf.read(str(file))
elif isinstance(file, unicode):
conf = ConfigParser()
conf.read(file)
else:
conf = file

View File

@ -545,7 +545,8 @@ class AOServerInfo(QtCore.QThread):
continue
del network[0]
gotChars = True
charlist = [ [char.split('&')[0], 0, "male"] for char in network ]
charlist = [ [char.split('&')[0].decode('utf-8'), 0, "male"] for char in network ]
self.setConnectProgress.emit('Requesting music list (%d)...' % maxmusic)
self.tcp.send('RM#%')
print '[client]', 'received characters (%d)' % len(charlist)