improve unicode handling of ic text
This commit is contained in:
parent
e393c1d2f1
commit
d81ef084c4
68
gameview.py
68
gameview.py
@ -1193,20 +1193,20 @@ class gui(QtGui.QWidget):
|
|||||||
self.nointerruptbtn = QtGui.QCheckBox(self)
|
self.nointerruptbtn = QtGui.QCheckBox(self)
|
||||||
self.nointerruptbtn.setChecked(False)
|
self.nointerruptbtn.setChecked(False)
|
||||||
self.nointerruptbtn.stateChanged.connect(self.icchat_focus)
|
self.nointerruptbtn.stateChanged.connect(self.icchat_focus)
|
||||||
self.nointerruptbtn.setText('No Interrupt')
|
self.nointerruptbtn.setText('&No interrupt')
|
||||||
self.nointerruptbtn.setToolTip("Show the next message immediately, ignoring animations")
|
self.nointerruptbtn.setToolTip("Show the next message immediately, ignoring animations")
|
||||||
|
|
||||||
# AO 2.8
|
# AO 2.8
|
||||||
self.additivebtn = QtGui.QCheckBox(self)
|
self.additivebtn = QtGui.QCheckBox(self)
|
||||||
self.additivebtn.setChecked(False)
|
self.additivebtn.setChecked(False)
|
||||||
self.additivebtn.setText('Additive')
|
self.additivebtn.setText('Additi&ve')
|
||||||
self.additivebtn.resize(self.additivebtn.sizeHint())
|
self.additivebtn.resize(self.additivebtn.sizeHint())
|
||||||
self.additivebtn.clicked.connect(self.onAdditiveCheck)
|
self.additivebtn.clicked.connect(self.onAdditiveCheck)
|
||||||
self.additivebtn.setToolTip('Append the next message to the previous one, without a new textbox')
|
self.additivebtn.setToolTip('Append the next message to the previous one, without a new textbox')
|
||||||
|
|
||||||
self.deskbtn = QtGui.QCheckBox(self)
|
self.deskbtn = QtGui.QCheckBox(self)
|
||||||
self.deskbtn.setChecked(True)
|
self.deskbtn.setChecked(True)
|
||||||
self.deskbtn.setText('Desk')
|
self.deskbtn.setText('&Desk')
|
||||||
self.deskbtn.stateChanged.connect(self.icchat_focus)
|
self.deskbtn.stateChanged.connect(self.icchat_focus)
|
||||||
self.deskbtn.resize(self.nointerruptbtn.sizeHint())
|
self.deskbtn.resize(self.nointerruptbtn.sizeHint())
|
||||||
self.deskbtn.setToolTip('Show or hide the desk in front of your character')
|
self.deskbtn.setToolTip('Show or hide the desk in front of your character')
|
||||||
@ -1402,10 +1402,10 @@ class gui(QtGui.QWidget):
|
|||||||
self.screenshake.stop()
|
self.screenshake.stop()
|
||||||
|
|
||||||
def onAdditiveCheck(self):
|
def onAdditiveCheck(self):
|
||||||
if self.additivebtn.isChecked():
|
# if self.additivebtn.isChecked():
|
||||||
self.icchatinput.home(False)
|
# self.icchatinput.home(False)
|
||||||
self.icchatinput.insert(" ")
|
# self.icchatinput.insert(" ")
|
||||||
self.icchatinput.end(False)
|
# self.icchatinput.end(False)
|
||||||
self.icchat_focus()
|
self.icchat_focus()
|
||||||
|
|
||||||
def icchat_focus(self):
|
def icchat_focus(self):
|
||||||
@ -1923,14 +1923,14 @@ class gui(QtGui.QWidget):
|
|||||||
self.changeEvidence(0, 0)
|
self.changeEvidence(0, 0)
|
||||||
|
|
||||||
def onClick_callMod(self):
|
def onClick_callMod(self):
|
||||||
# self.do_slide()
|
self.do_slide()
|
||||||
|
|
||||||
if "modcall_reason" in self.features:
|
# if "modcall_reason" in self.features:
|
||||||
reason, ok = QtGui.QInputDialog.getText(self, "Call a moderator", "Enter your reason.")
|
# reason, ok = QtGui.QInputDialog.getText(self, "Call a moderator", "Enter your reason.")
|
||||||
if ok and reason:
|
# if ok and reason:
|
||||||
self.tcp.send("ZZ#"+reason.toUtf8()+"#%")
|
# self.tcp.send("ZZ#"+reason.toUtf8()+"#%")
|
||||||
else:
|
# else:
|
||||||
self.tcp.send("ZZ#%")
|
# self.tcp.send("ZZ#%")
|
||||||
|
|
||||||
def onClick_changeChar(self):
|
def onClick_changeChar(self):
|
||||||
#self.tcp.send('RD#%')
|
#self.tcp.send('RD#%')
|
||||||
@ -2139,22 +2139,26 @@ class gui(QtGui.QWidget):
|
|||||||
self.oocinput.clear()
|
self.oocinput.clear()
|
||||||
|
|
||||||
def onICreturn(self):
|
def onICreturn(self):
|
||||||
text = str(self.icchatinput.text().toUtf8()).replace('#', '<num>').replace('%', '<percent>').replace('&', '<and>').replace('$', '<dollar>')#.replace('/n', '\n')
|
text = unicode(self.icchatinput.text()).replace('#', '<num>').replace('%', '<percent>').replace('&', '<and>').replace('$', '<dollar>')#.replace('/n', '\n')
|
||||||
|
|
||||||
if self.mocktext.isChecked():
|
if text:
|
||||||
text = mockStr(text)
|
if self.mocktext.isChecked():
|
||||||
if self.autocaps.isChecked():
|
text = mockStr(text)
|
||||||
l = list(text)
|
if self.autocaps.isChecked():
|
||||||
l[0] = l[0].upper()
|
l = list(text)
|
||||||
last = [".", "?", "!", "<", ">", ")", "]"]
|
if l[0] == " " and len(l) > 1:
|
||||||
if not l[-1] in last:
|
l[1] = l[1].upper()
|
||||||
l.append(".")
|
else:
|
||||||
text = "".join(l).replace(" i ", " I ").replace("i'm", "I'm").replace("it's", "It's")
|
l[0] = l[0].upper()
|
||||||
if self.spacebartext.isChecked():
|
last = [".", "?", "!", "<", ">", ")", "]"]
|
||||||
l = list(text)
|
if not l[-1] in last:
|
||||||
for i in range(1, len(l)+len(l)-1, 2):
|
l.append(".")
|
||||||
l.insert(i, " ")
|
text = "".join(l).replace(" i ", " I ").replace("i'm", "I'm").replace("it's", "It's")
|
||||||
text = "".join(l)
|
if self.spacebartext.isChecked():
|
||||||
|
l = list(text)
|
||||||
|
for i in range(1, len(l)+len(l)-1, 2):
|
||||||
|
l.insert(i, " ")
|
||||||
|
text = "".join(l)
|
||||||
|
|
||||||
emote = self.charemotes[self.selectedemote]
|
emote = self.charemotes[self.selectedemote]
|
||||||
|
|
||||||
@ -2189,14 +2193,14 @@ class gui(QtGui.QWidget):
|
|||||||
else:
|
else:
|
||||||
modifier = 2
|
modifier = 2
|
||||||
|
|
||||||
msg = "MS#"
|
msg = u"MS#"
|
||||||
|
|
||||||
# Visible desk modifier
|
# Visible desk modifier
|
||||||
if "deskmod" in self.features:
|
if "deskmod" in self.features:
|
||||||
if emote[3] == '5': # Zoom forcibly hides the desk
|
if emote[3] == '5': # Zoom forcibly hides the desk
|
||||||
msg += "0#"
|
msg += "0#"
|
||||||
elif emote[7]: # Respect deskmod if found
|
elif emote[7]: # Respect deskmod if found
|
||||||
msg += "%s#" % emote[7]
|
msg += "%s#" % str(emote[7])
|
||||||
else:
|
else:
|
||||||
msg += "%d#" % self.deskbtn.isChecked()
|
msg += "%d#" % self.deskbtn.isChecked()
|
||||||
else:
|
else:
|
||||||
@ -2205,7 +2209,7 @@ class gui(QtGui.QWidget):
|
|||||||
msg += emote[1]+"#" #pre-anim
|
msg += emote[1]+"#" #pre-anim
|
||||||
msg += self.charname.title()+"#"
|
msg += self.charname.title()+"#"
|
||||||
msg += emote[2]+"#" #anim
|
msg += emote[2]+"#" #anim
|
||||||
msg += text.decode('utf-8')+"#"
|
msg += text+"#"
|
||||||
msg += self.charside+"#"
|
msg += self.charside+"#"
|
||||||
msg += emote[4]+"#" #sfx
|
msg += emote[4]+"#" #sfx
|
||||||
msg += str(modifier)+"#" #emote modifier
|
msg += str(modifier)+"#" #emote modifier
|
||||||
|
Loading…
Reference in New Issue
Block a user