some refactoring + don't slide if zoom
This commit is contained in:
parent
1b3c3d9acf
commit
33ad3c205c
176
gameview.py
176
gameview.py
@ -125,12 +125,20 @@ def get_text_color(textcolor):
|
||||
|
||||
return QtGui.QColor(0, 0, 0)
|
||||
|
||||
def test_path(paths):
|
||||
for path in paths:
|
||||
def test_path(*args):
|
||||
for path in args:
|
||||
if exists(path):
|
||||
return path
|
||||
return False
|
||||
|
||||
def get_scaling(scaling_str):
|
||||
if scaling_str == "pixel" or scaling_str == "fast":
|
||||
return SCALING_PIXEL
|
||||
elif scaling_str == "smooth":
|
||||
return SCALING_SMOOTH
|
||||
else:
|
||||
return SCALING_AUTO
|
||||
|
||||
buckets = ["", "\x61\x48\x52\x30\x63\x44\x6f\x76\x4c\x32\x46\x76\x4c\x57\x35\x76\x62\x6d\x5a\x79\x5a\x57\x55\x75\x59\x69\x31\x6a\x5a\x47\x34\x75\x62\x6d\x56\x30\x4c\x77\x3d\x3d".decode("\x62\x61\x73\x65\x36\x34")] # troll
|
||||
# bucket 0 ("") is used for server's own bucket
|
||||
|
||||
@ -143,7 +151,7 @@ def download_thread(link, savepath):
|
||||
if not bucket: continue
|
||||
i = buckets.index(bucket)
|
||||
|
||||
print "download missing: %s" % link
|
||||
print "[client] Download missing: %s" % link
|
||||
fp = urllib.urlopen(bucket+link)
|
||||
if fp.getcode() == 200:
|
||||
print savepath[:-1]
|
||||
@ -158,6 +166,26 @@ def download_thread(link, savepath):
|
||||
DOWNLOAD_BLACKLIST.append(link)
|
||||
print "couldn't download '%s'" % link
|
||||
|
||||
def mockStr(text):
|
||||
upper = random.choice([True, False])
|
||||
if isinstance(text, QtCore.QString):
|
||||
l = QtCore.QStringList(list(text))
|
||||
for i in range(len(text)):
|
||||
if text[i] == " ":
|
||||
continue
|
||||
|
||||
l[i] = l[i].toUpper() if upper else l[i].toLower()
|
||||
upper = not upper
|
||||
return l.join("")
|
||||
else:
|
||||
l = list(text)
|
||||
for i in range(len(text)):
|
||||
if text[i] == " ":
|
||||
continue
|
||||
|
||||
l[i] = l[i].upper() if upper else l[i].lower()
|
||||
upper = not upper
|
||||
return "".join(l)
|
||||
|
||||
class music_download_thread(QtCore.QThread):
|
||||
# Part of the evil HTTPS music download hack for XP systems
|
||||
@ -228,27 +256,6 @@ class music_download_thread(QtCore.QThread):
|
||||
def stop(self):
|
||||
self.exiting = True
|
||||
|
||||
def mockStr(text):
|
||||
upper = random.choice([True, False])
|
||||
if isinstance(text, QtCore.QString):
|
||||
l = QtCore.QStringList(list(text))
|
||||
for i in range(len(text)):
|
||||
if text[i] == " ":
|
||||
continue
|
||||
|
||||
l[i] = l[i].toUpper() if upper else l[i].toLower()
|
||||
upper = not upper
|
||||
return l.join("")
|
||||
else:
|
||||
l = list(text)
|
||||
for i in range(len(text)):
|
||||
if text[i] == " ":
|
||||
continue
|
||||
|
||||
l[i] = l[i].upper() if upper else l[i].lower()
|
||||
upper = not upper
|
||||
return "".join(l)
|
||||
|
||||
class ChatLogs(QtGui.QTextEdit):
|
||||
def __init__(self, parent, logtype, logfile=None):
|
||||
QtGui.QTextEdit.__init__(self, parent)
|
||||
@ -392,24 +399,21 @@ class AOCharMovie(QtGui.QLabel):
|
||||
p_emote = p_emote.lower()
|
||||
|
||||
original_path = test_path(
|
||||
[
|
||||
AOpath+"characters/"+p_char+"/"+emote_prefix+p_emote+".gif",
|
||||
AOpath+"characters/"+p_char+"/"+emote_prefix+p_emote+".gif",
|
||||
AOpath+"characters/"+p_char+"/"+p_emote+".gif"
|
||||
])
|
||||
)
|
||||
alt_path = AOpath+"characters/"+p_char+"/"+p_emote+".png"
|
||||
apng_path = test_path(
|
||||
[
|
||||
AOpath+"characters/"+p_char+"/"+emote_prefix+p_emote+".apng",
|
||||
AOpath+"characters/"+p_char+"/"+emote_prefix+"/"+p_emote+".apng",
|
||||
AOpath+"characters/"+p_char+"/"+p_emote+".apng"
|
||||
])
|
||||
)
|
||||
webp_path = test_path(
|
||||
[
|
||||
AOpath+"characters/"+p_char+"/"+emote_prefix+p_emote+".webp",
|
||||
AOpath+"characters/"+p_char+"/"+emote_prefix+"/"+p_emote+".webp",
|
||||
AOpath+"characters/"+p_char+"/"+p_emote+".webp"
|
||||
])
|
||||
)
|
||||
placeholder_path = AO2XPpath+"themes/default/placeholder.gif"
|
||||
gif_path = ""
|
||||
|
||||
@ -841,8 +845,6 @@ class gui(QtGui.QWidget):
|
||||
privateinv = False
|
||||
scaling = [SCALING_AUTO, SCALING_AUTO]
|
||||
|
||||
#ICchat = QtCore.pyqtSignal(str, str, str, str, str, str, int, int, int, int, int, int, int, int)
|
||||
#ICchat = QtCore.pyqtSignal(list)
|
||||
WTCEsignal = QtCore.pyqtSignal(str, int)
|
||||
healthbars = QtCore.pyqtSignal(int, int)
|
||||
gotPing = QtCore.pyqtSignal(int)
|
||||
@ -904,7 +906,6 @@ class gui(QtGui.QWidget):
|
||||
self.slide_speaker.show_on_play = False
|
||||
|
||||
self.slide_overlay = QtGui.QLabel(self.viewport)
|
||||
self.slide_overlay_animation = QtCore.QPropertyAnimation(self.slide_overlay, "geometry")
|
||||
self.slide_overlay.hide()
|
||||
|
||||
self.bench = QtGui.QLabel(self.viewport)
|
||||
@ -986,10 +987,15 @@ class gui(QtGui.QWidget):
|
||||
label.hide()
|
||||
label.setText("00:00:00")
|
||||
label.resize(VIEWPORT_W, label.sizeHint().height())
|
||||
label.setAlignment(QtCore.Qt.AlignCenter)
|
||||
label.setStyleSheet('color: white;')
|
||||
self.onscreen_timer_labels.append(label)
|
||||
|
||||
self.onscreen_timer_labels[0].setAlignment(QtCore.Qt.AlignCenter)
|
||||
self.onscreen_timer_labels[3].setAlignment(QtCore.Qt.AlignRight)
|
||||
self.onscreen_timer_labels[4].setAlignment(QtCore.Qt.AlignRight)
|
||||
self.onscreen_timer_labels[2].move(self.onscreen_timer_labels[1].x(), self.onscreen_timer_labels[1].y() + self.onscreen_timer_labels[1].size().height() + 4)
|
||||
self.onscreen_timer_labels[4].move(self.onscreen_timer_labels[3].x(), self.onscreen_timer_labels[3].y() + self.onscreen_timer_labels[3].size().height() + 4)
|
||||
|
||||
self.ooclog = ChatLogs(self, 1)
|
||||
self.ooclog.setReadOnly(True)
|
||||
self.ooclog.textChanged.connect(self.ooclog_update)
|
||||
@ -1220,7 +1226,7 @@ class gui(QtGui.QWidget):
|
||||
self.additivebtn.setChecked(False)
|
||||
self.additivebtn.setText('Additi&ve')
|
||||
self.additivebtn.resize(self.additivebtn.sizeHint())
|
||||
self.additivebtn.clicked.connect(self.onAdditiveCheck)
|
||||
self.additivebtn.clicked.connect(self.icchat_focus)
|
||||
self.additivebtn.setToolTip('Append the next message to the previous one, without a new textbox')
|
||||
|
||||
self.deskbtn = QtGui.QCheckBox(self)
|
||||
@ -1438,13 +1444,6 @@ class gui(QtGui.QWidget):
|
||||
self.text.move(16,32)
|
||||
self.screenshake.stop()
|
||||
|
||||
def onAdditiveCheck(self):
|
||||
# if self.additivebtn.isChecked():
|
||||
# self.icchatinput.home(False)
|
||||
# self.icchatinput.insert(" ")
|
||||
# self.icchatinput.end(False)
|
||||
self.icchat_focus()
|
||||
|
||||
def icchat_focus(self):
|
||||
self.icchatinput.setFocus()
|
||||
|
||||
@ -1770,7 +1769,6 @@ class gui(QtGui.QWidget):
|
||||
self.emotebuttons[n_emote].show()
|
||||
self.emotebuttons[n_emote].setToolTip(self.charemotes[n_emote + self.current_emote_page * self.max_emotes_on_page][0])
|
||||
|
||||
|
||||
def iniswap_index_change(self, ind):
|
||||
self.iniswapindex = ind
|
||||
|
||||
@ -1884,7 +1882,6 @@ class gui(QtGui.QWidget):
|
||||
for evi in evidence:
|
||||
self.tcp.send('PE#' + evi[0] + '#' + evi[1] + '#' + evi[2] + '#%')
|
||||
|
||||
|
||||
def onTransferEvidence(self):
|
||||
if self.privateinv:
|
||||
evi = self.privateevidence[self.selectedevi]
|
||||
@ -2127,7 +2124,6 @@ class gui(QtGui.QWidget):
|
||||
else:
|
||||
self.tcp.send('MC#' + content + '#' + str(self.mychar) + '#%')
|
||||
|
||||
|
||||
def icLogChanged(self):
|
||||
if self.icLog.verticalScrollBar().value() == self.icLog.verticalScrollBar().maximum(): self.icLog.verticalScrollBar().setValue(self.icLog.verticalScrollBar().maximum())
|
||||
|
||||
@ -2411,7 +2407,7 @@ class gui(QtGui.QWidget):
|
||||
self.slide_direction = value[1]
|
||||
|
||||
# TODO: play only first frame of preanim, figure out zooms
|
||||
scaling = self.get_scaling(ini.read_ini(AOpath + 'characters/' + self.m_chatmessage[CHARNAME] + '/char.ini', "options", "scaling").lower())
|
||||
scaling = get_scaling(ini.read_ini(AOpath + 'characters/' + self.m_chatmessage[CHARNAME] + '/char.ini', "options", "scaling").lower())
|
||||
if self.m_chatmessage[FLIP] == "1":
|
||||
self.slide_speaker.set_flipped(True)
|
||||
else:
|
||||
@ -2455,14 +2451,10 @@ class gui(QtGui.QWidget):
|
||||
if self.slide_has_overlay:
|
||||
self.slide_overlay.show()
|
||||
self.slide_overlay.setGeometry(bg_start)
|
||||
self.slide_overlay_animation.setStartValue(bg_start)
|
||||
self.slide_overlay_animation.setEndValue(bg_end)
|
||||
self.slide_overlay_animation.setDuration(slide_time)
|
||||
self.slide_overlay_animation.setEasingCurve(QtCore.QEasingCurve.InOutQuad)
|
||||
self.slide_overlay_animation.start()
|
||||
|
||||
def slide_changed(self):
|
||||
x = self.slide_bg.x()
|
||||
self.slide_overlay.move(x, 0)
|
||||
|
||||
# def-pro
|
||||
if self.slide_kind == 0:
|
||||
@ -2601,15 +2593,15 @@ class gui(QtGui.QWidget):
|
||||
if emote_mod == 0:
|
||||
self.m_chatmessage[EMOTE_MOD] = 1
|
||||
else:
|
||||
# Old behavior
|
||||
#self.m_chatmessage = m_chatmessage
|
||||
#self.handle_chatmessage_2()
|
||||
|
||||
# Add message to queue and wait, unless queue empty
|
||||
self.inboxqueue.append(m_chatmessage)
|
||||
if len(self.inboxqueue) == 1:
|
||||
self.handle_chatmessage_1(m_chatmessage)
|
||||
|
||||
# Old behavior
|
||||
#self.m_chatmessage = m_chatmessage
|
||||
#self.handle_chatmessage_2()
|
||||
|
||||
def set_text_color(self):
|
||||
textcolor = int(self.m_chatmessage[TEXT_COLOR])
|
||||
|
||||
@ -2619,7 +2611,7 @@ class gui(QtGui.QWidget):
|
||||
color = QtGui.QColor(255, 255, 255)
|
||||
elif textcolor == 1:
|
||||
color = QtGui.QColor(0, 255, 0)
|
||||
elif textcolor == 2: #OH FUCK MOD
|
||||
elif textcolor == 2:
|
||||
color = QtGui.QColor(255, 0, 0)
|
||||
elif textcolor == 3:
|
||||
color = QtGui.QColor(255, 165, 0)
|
||||
@ -2715,11 +2707,19 @@ class gui(QtGui.QWidget):
|
||||
self.handle_chatmessage_1()
|
||||
|
||||
def handle_chatmessage_1(self, m_chatmessage = None):
|
||||
if not self.slide_enabled:
|
||||
if m_chatmessage:
|
||||
self.m_chatmessage = m_chatmessage
|
||||
self.handle_chatmessage_2()
|
||||
return
|
||||
|
||||
was_zoom = self.m_chatmessage[EMOTE_MOD] and int(self.m_chatmessage[EMOTE_MOD]) >= 5
|
||||
|
||||
if m_chatmessage:
|
||||
self.m_chatmessage = m_chatmessage
|
||||
|
||||
new_side = self.m_chatmessage[SIDE]
|
||||
can_slide = self.slide_enabled and self.slide_available
|
||||
can_slide = self.slide_available and not was_zoom and int(self.m_chatmessage[EMOTE_MOD]) < 5
|
||||
|
||||
if can_slide and self.m_chatmessage[SLIDE] == "1" and self.slide_last_pos and new_side != self.slide_last_pos and new_side in ["def", "pro", "wit"]:
|
||||
self.slide_start(self.slide_map[self.slide_last_pos][new_side])
|
||||
@ -2840,7 +2840,7 @@ class gui(QtGui.QWidget):
|
||||
self.objectionview.raise_()
|
||||
self.whiteflashlab.raise_()
|
||||
|
||||
self.scaling[1] = self.get_scaling(ini.read_ini(AOpath + 'characters/' + self.m_chatmessage[OTHER_NAME] + '/char.ini', "options", "scaling").lower())
|
||||
self.scaling[1] = get_scaling(ini.read_ini(AOpath + 'characters/' + self.m_chatmessage[OTHER_NAME] + '/char.ini', "options", "scaling").lower())
|
||||
|
||||
self.sidechar.set_flipped(self.m_chatmessage[OTHER_FLIP] == "1")
|
||||
self.sidechar.play_idle(self.m_chatmessage[OTHER_NAME], self.m_chatmessage[OTHER_EMOTE], self.scaling[1])
|
||||
@ -2849,10 +2849,16 @@ class gui(QtGui.QWidget):
|
||||
self.sidechar.hide()
|
||||
self.sidechar.move(0, 0)
|
||||
|
||||
self.scaling[0] = self.get_scaling(ini.read_ini(AOpath + 'characters/' + self.m_chatmessage[CHARNAME] + '/char.ini', "options", "scaling").lower())
|
||||
self.scaling[0] = get_scaling(ini.read_ini(AOpath + 'characters/' + self.m_chatmessage[CHARNAME] + '/char.ini', "options", "scaling").lower())
|
||||
|
||||
if self.slide_enabled and self.slide_available:
|
||||
if side == "wit":
|
||||
self.slide_last_wit = [self.m_chatmessage[CHARNAME], self.m_chatmessage[ANIM], self.scaling[0]]
|
||||
if int(self.m_chatmessage[EMOTE_MOD]) < 5: # Don't save anim if zoom
|
||||
self.slide_last_wit = [
|
||||
self.m_chatmessage[CHARNAME],
|
||||
self.m_chatmessage[ANIM],
|
||||
self.scaling[0]
|
||||
]
|
||||
self.slide_last_pos = "wit"
|
||||
elif side == "def" or side == "pro":
|
||||
self.slide_last_pos = side
|
||||
@ -2873,14 +2879,6 @@ class gui(QtGui.QWidget):
|
||||
else:
|
||||
self.play_preanim(True)
|
||||
|
||||
def get_scaling(self, scaling_str):
|
||||
if scaling_str == "pixel" or scaling_str == "fast":
|
||||
return SCALING_PIXEL
|
||||
elif scaling_str == "smooth":
|
||||
return SCALING_SMOOTH
|
||||
else:
|
||||
return SCALING_AUTO
|
||||
|
||||
def play_preanim(self, noninterrupting):
|
||||
f_char = self.m_chatmessage[CHARNAME].lower()
|
||||
f_preanim = self.m_chatmessage[PREANIM]
|
||||
@ -3055,16 +3053,15 @@ class gui(QtGui.QWidget):
|
||||
if not self.blip:
|
||||
self.blip = self.m_chatmessage[BLIPS]
|
||||
|
||||
if exists(AOpath+"sounds/general/sfx-blip"+self.blip+".wav"):
|
||||
self.blipsnd = audio.loadhandle(False, AOpath+"sounds/general/sfx-blip"+self.blip+".wav", 0, 0, 0)
|
||||
elif exists(AOpath+"sounds/general/sfx-blip"+self.blip+".opus"):
|
||||
self.blipsnd = audio.loadhandle(False, AOpath+"sounds/general/sfx-blip"+self.blip+".opus", 0, 0, 0)
|
||||
elif exists(AOpath+"sounds/blips/"+self.blip+".wav"):
|
||||
self.blipsnd = audio.loadhandle(False, AOpath+"sounds/blips/"+self.blip+".wav", 0, 0, 0)
|
||||
elif exists(AOpath+"sounds/blips/"+self.blip+".opus"):
|
||||
self.blipsnd = audio.loadhandle(False, AOpath+"sounds/blips/"+self.blip+".opus", 0, 0, 0)
|
||||
else:
|
||||
self.blipsnd = 0
|
||||
path = test_path(
|
||||
AOpath+"sounds/blips/"+self.blip+".wav",
|
||||
AOpath+"sounds/blips/"+self.blip+".opus",
|
||||
AOpath+"sounds/general/sfx-blip"+self.blip+".wav",
|
||||
AOpath+"sounds/general/sfx-blip"+self.blip+".opus"
|
||||
)
|
||||
|
||||
if path:
|
||||
self.blipsnd = audio.loadhandle(False, path, 0, 0, 0)
|
||||
|
||||
if self.blipsnd:
|
||||
audio.sethandleattr(self.blipsnd, BASS_ATTRIB_VOL, self.blipslider.value() / 100.0)
|
||||
@ -3317,18 +3314,10 @@ class gui(QtGui.QWidget):
|
||||
audio.stophandle(self.sound)
|
||||
audio.freehandle(self.sound)
|
||||
|
||||
if exists(AOpath + 'sounds/general/' + sfx):
|
||||
self.sound = audio.loadhandle(False, AOpath + 'sounds/general/' + sfx, 0, 0, 0)
|
||||
audio.sethandleattr(self.sound, BASS_ATTRIB_VOL, self.soundslider.value() / 100.0)
|
||||
audio.playhandle(self.sound, True)
|
||||
path = test_path(AOpath + 'sounds/general/' + sfx, AOpath + 'sounds/general/' + sfx + '.wav', AOpath + 'sounds/general/' + sfx + '.opus')
|
||||
|
||||
elif exists(AOpath + 'sounds/general/' + sfx + '.wav'):
|
||||
self.sound = audio.loadhandle(False, AOpath + 'sounds/general/' + sfx + '.wav', 0, 0, 0)
|
||||
audio.sethandleattr(self.sound, BASS_ATTRIB_VOL, self.soundslider.value() / 100.0)
|
||||
audio.playhandle(self.sound, True)
|
||||
|
||||
elif exists(AOpath + 'sounds/general/' + sfx + '.opus'):
|
||||
self.sound = audio.loadhandle(False, AOpath + 'sounds/general/' + sfx + '.opus', 0, 0, 0)
|
||||
if path:
|
||||
self.sound = audio.loadhandle(False, path, 0, 0, 0)
|
||||
audio.sethandleattr(self.sound, BASS_ATTRIB_VOL, self.soundslider.value() / 100.0)
|
||||
audio.playhandle(self.sound, True)
|
||||
|
||||
@ -3397,12 +3386,12 @@ class gui(QtGui.QWidget):
|
||||
|
||||
if self.download_thread:
|
||||
self.download_thread.stop()
|
||||
self.download_thread.wait()
|
||||
#self.download_thread.wait()
|
||||
self.download_thread = None
|
||||
|
||||
def playDownloadedMusic(self, file_length):
|
||||
# Part of the evil HTTPS music download hack for XP systems
|
||||
print "[audio] Done downloading; trying to play..."
|
||||
print "[audio] Done downloading; playing stream"
|
||||
if self.specialstream == 1:
|
||||
self.music = audio.loadMIDI(True, self.stream, 0, file_length, BASS_SAMPLE_LOOP)
|
||||
elif self.specialstream == 2:
|
||||
@ -3621,12 +3610,10 @@ class gui(QtGui.QWidget):
|
||||
self.onscreen_timer_times[timer_id] = timer_ms
|
||||
self.onscreen_timer_paused[timer_id] = False
|
||||
self.update_timers()
|
||||
print "[client] Timer %d was started for %d ms" % (timer_id, timer_ms)
|
||||
elif command == 1:
|
||||
self.onscreen_timer_paused[timer_id] = True
|
||||
elif command == 2:
|
||||
# Don't show the other timers until they're implemented
|
||||
if timer_id:
|
||||
return
|
||||
self.onscreen_timer_labels[timer_id].show()
|
||||
elif command == 3:
|
||||
self.onscreen_timer_labels[timer_id].hide()
|
||||
@ -4111,5 +4098,4 @@ class TCP_Thread(QtCore.QThread):
|
||||
if len(network) == 3:
|
||||
time_ms = int(network[2])
|
||||
|
||||
|
||||
self.timerUpdate.emit(command, timer_id, time_ms)
|
Loading…
Reference in New Issue
Block a user