respect scaling in char.ini and default for smooth scaling for big sprites
This commit is contained in:
parent
f73b3422d1
commit
3f44b65c60
74
gameview.py
74
gameview.py
@ -65,6 +65,10 @@ C_GRAY = 8
|
|||||||
C_RAINBOW = 9
|
C_RAINBOW = 9
|
||||||
C_BLACK = 10
|
C_BLACK = 10
|
||||||
|
|
||||||
|
SCALING_AUTO = 0
|
||||||
|
SCALING_PIXEL = 1
|
||||||
|
SCALING_SMOOTH = 2
|
||||||
|
|
||||||
DOWNLOAD_BLACKLIST = []
|
DOWNLOAD_BLACKLIST = []
|
||||||
|
|
||||||
VIEWPORT_W = 256*2
|
VIEWPORT_W = 256*2
|
||||||
@ -83,12 +87,6 @@ def encode_ao_str(text):
|
|||||||
|
|
||||||
def get_char_ini(char, section, value, default=""):
|
def get_char_ini(char, section, value, default=""):
|
||||||
tempini = ConfigParser()
|
tempini = ConfigParser()
|
||||||
# with open(AOpath + 'characters/' + char.lower() + '/char.ini', 'r') as file:
|
|
||||||
# for line in file:
|
|
||||||
# try:
|
|
||||||
# tempini.readfp(file)
|
|
||||||
# except:
|
|
||||||
# pass
|
|
||||||
return ini.read_ini(AOpath + 'characters/' + char.lower() + '/char.ini', section, value, default)
|
return ini.read_ini(AOpath + 'characters/' + char.lower() + '/char.ini', section, value, default)
|
||||||
|
|
||||||
def get_option(section, value, default=""):
|
def get_option(section, value, default=""):
|
||||||
@ -237,6 +235,7 @@ class AOCharMovie(QtGui.QLabel):
|
|||||||
self.time_mod = 62
|
self.time_mod = 62
|
||||||
self.play_once = True
|
self.play_once = True
|
||||||
self.m_flipped = False
|
self.m_flipped = False
|
||||||
|
self.scaling = SCALING_AUTO
|
||||||
|
|
||||||
self.m_movie = QtGui.QMovie()
|
self.m_movie = QtGui.QMovie()
|
||||||
|
|
||||||
@ -260,7 +259,7 @@ class AOCharMovie(QtGui.QLabel):
|
|||||||
def set_flipped(self, flip):
|
def set_flipped(self, flip):
|
||||||
self.m_flipped = flip
|
self.m_flipped = flip
|
||||||
|
|
||||||
def play(self, p_char, p_emote, emote_prefix):
|
def play(self, p_char, p_emote, emote_prefix, scaling = SCALING_AUTO):
|
||||||
if p_emote[0] == "/" or p_emote[0] == "/":
|
if p_emote[0] == "/" or p_emote[0] == "/":
|
||||||
p_emote = p_emote[1:]
|
p_emote = p_emote[1:]
|
||||||
elif "../../characters" in p_emote:
|
elif "../../characters" in p_emote:
|
||||||
@ -274,6 +273,8 @@ class AOCharMovie(QtGui.QLabel):
|
|||||||
self.pillow_frames = []
|
self.pillow_frames = []
|
||||||
self.pillow_frame = 0
|
self.pillow_frame = 0
|
||||||
|
|
||||||
|
self.scaling = scaling
|
||||||
|
|
||||||
p_char = p_char.lower().decode('utf-8')
|
p_char = p_char.lower().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"
|
||||||
@ -347,7 +348,7 @@ class AOCharMovie(QtGui.QLabel):
|
|||||||
|
|
||||||
self.show()
|
self.show()
|
||||||
|
|
||||||
def play_pre(self, p_char, p_emote, duration):
|
def play_pre(self, p_char, p_emote, duration, scaling = SCALING_AUTO):
|
||||||
p_char = p_char.lower()
|
p_char = p_char.lower()
|
||||||
gif_path = AOpath+"characters/"+p_char+"/"+p_emote+".gif"
|
gif_path = AOpath+"characters/"+p_char+"/"+p_emote+".gif"
|
||||||
apng_path = AOpath+"characters/"+p_char+"/"+p_emote+".apng"
|
apng_path = AOpath+"characters/"+p_char+"/"+p_emote+".apng"
|
||||||
@ -392,9 +393,9 @@ class AOCharMovie(QtGui.QLabel):
|
|||||||
|
|
||||||
self.m_movie.setSpeed(int(percentage_modifier))
|
self.m_movie.setSpeed(int(percentage_modifier))
|
||||||
self.pillow_speed = percentage_modifier / 100.
|
self.pillow_speed = percentage_modifier / 100.
|
||||||
self.play(p_char, p_emote, "")
|
self.play(p_char, p_emote, "", scaling)
|
||||||
|
|
||||||
def play_talking(self, p_char, p_emote):
|
def play_talking(self, p_char, p_emote, scaling = SCALING_AUTO):
|
||||||
p_char = p_char.lower()
|
p_char = p_char.lower()
|
||||||
gif_path = AOpath + 'characters/' + p_char + '/(b)' + p_emote + '.gif'
|
gif_path = AOpath + 'characters/' + p_char + '/(b)' + p_emote + '.gif'
|
||||||
|
|
||||||
@ -406,9 +407,9 @@ class AOCharMovie(QtGui.QLabel):
|
|||||||
self.play_once = False
|
self.play_once = False
|
||||||
self.m_movie.setSpeed(100)
|
self.m_movie.setSpeed(100)
|
||||||
self.pillow_speed = 1
|
self.pillow_speed = 1
|
||||||
self.play(p_char, p_emote, '(b)')
|
self.play(p_char, p_emote, '(b)', scaling)
|
||||||
|
|
||||||
def play_idle(self, p_char, p_emote):
|
def play_idle(self, p_char, p_emote, scaling = SCALING_AUTO):
|
||||||
p_char = p_char.lower()
|
p_char = p_char.lower()
|
||||||
gif_path = AOpath + 'characters/' + p_char + '/(a)' + p_emote + '.gif'
|
gif_path = AOpath + 'characters/' + p_char + '/(a)' + p_emote + '.gif'
|
||||||
|
|
||||||
@ -420,18 +421,28 @@ class AOCharMovie(QtGui.QLabel):
|
|||||||
self.play_once = False
|
self.play_once = False
|
||||||
self.m_movie.setSpeed(100)
|
self.m_movie.setSpeed(100)
|
||||||
self.pillow_speed = 1
|
self.pillow_speed = 1
|
||||||
self.play(p_char, p_emote, '(a)')
|
self.play(p_char, p_emote, '(a)', scaling)
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
self.m_movie.stop()
|
self.m_movie.stop()
|
||||||
self.preanim_timer.stop()
|
self.preanim_timer.stop()
|
||||||
self.hide()
|
self.hide()
|
||||||
|
|
||||||
|
def get_transform(self, smooth_condition=True):
|
||||||
|
if self.scaling == SCALING_PIXEL:
|
||||||
|
return QtCore.Qt.FastTransformation
|
||||||
|
elif self.scaling == SCALING_SMOOTH:
|
||||||
|
return QtCore.Qt.SmoothTransformation
|
||||||
|
elif smooth_condition:
|
||||||
|
return QtCore.Qt.SmoothTransformation
|
||||||
|
else:
|
||||||
|
return QtCore.Qt.FastTransformation
|
||||||
|
|
||||||
@QtCore.pyqtSlot(int)
|
@QtCore.pyqtSlot(int)
|
||||||
def frame_change(self, n_frame):
|
def frame_change(self, n_frame):
|
||||||
f_img = self.m_movie.currentImage().mirrored(self.m_flipped, False)
|
f_img = self.m_movie.currentImage().mirrored(self.m_flipped, False)
|
||||||
if not f_img.isNull() and (f_img.size().width() != VIEWPORT_W or f_img.size().height() != VIEWPORT_H):
|
if not f_img.isNull():
|
||||||
f_img = f_img.scaled(VIEWPORT_W, VIEWPORT_H, QtCore.Qt.KeepAspectRatioByExpanding, QtCore.Qt.FastTransformation)
|
f_img = f_img.scaled(VIEWPORT_W, VIEWPORT_H, QtCore.Qt.KeepAspectRatioByExpanding, self.get_transform(f_img.size().height() > VIEWPORT_H))
|
||||||
|
|
||||||
f_pixmap = QtGui.QPixmap.fromImage(f_img)
|
f_pixmap = QtGui.QPixmap.fromImage(f_img)
|
||||||
self.setPixmap(f_pixmap)
|
self.setPixmap(f_pixmap)
|
||||||
@ -457,8 +468,8 @@ class AOCharMovie(QtGui.QLabel):
|
|||||||
|
|
||||||
def set_pillow_frame(self):
|
def set_pillow_frame(self):
|
||||||
f_img = self.pillow_frames[self.pillow_frame][0].mirrored(self.m_flipped, False)
|
f_img = self.pillow_frames[self.pillow_frame][0].mirrored(self.m_flipped, False)
|
||||||
if not f_img.isNull() and (f_img.size().width() != VIEWPORT_W or f_img.size().height() != VIEWPORT_H):
|
if not f_img.isNull():
|
||||||
f_img = f_img.scaled(VIEWPORT_W, VIEWPORT_H, QtCore.Qt.KeepAspectRatioByExpanding, QtCore.Qt.FastTransformation)
|
f_img = f_img.scaled(VIEWPORT_W, VIEWPORT_H, QtCore.Qt.KeepAspectRatioByExpanding, self.get_transform(f_img.size().height() > VIEWPORT_H))
|
||||||
|
|
||||||
f_pixmap = QtGui.QPixmap.fromImage(f_img)
|
f_pixmap = QtGui.QPixmap.fromImage(f_img)
|
||||||
self.setPixmap(f_pixmap)
|
self.setPixmap(f_pixmap)
|
||||||
@ -689,6 +700,7 @@ class gui(QtGui.QWidget):
|
|||||||
charid = -1
|
charid = -1
|
||||||
login = False
|
login = False
|
||||||
privateinv = False
|
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(str, str, str, str, str, str, int, int, int, int, int, int, int, int)
|
||||||
#ICchat = QtCore.pyqtSignal(list)
|
#ICchat = QtCore.pyqtSignal(list)
|
||||||
@ -2338,13 +2350,17 @@ class gui(QtGui.QWidget):
|
|||||||
self.effectview.raise_()
|
self.effectview.raise_()
|
||||||
self.objectionview.raise_()
|
self.objectionview.raise_()
|
||||||
self.whiteflashlab.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.sidechar.set_flipped(self.m_chatmessage[OTHER_FLIP] == "1")
|
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.sidechar.play_idle(self.m_chatmessage[OTHER_NAME], self.m_chatmessage[OTHER_EMOTE], self.scaling[1])
|
||||||
|
|
||||||
else:
|
else:
|
||||||
self.sidechar.hide()
|
self.sidechar.hide()
|
||||||
self.sidechar.move(0, 0)
|
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())
|
||||||
|
|
||||||
if (emote_mod == 1 or emote_mod == 2 or emote_mod == 6) and self.m_chatmessage[PREANIM] != "-":
|
if (emote_mod == 1 or emote_mod == 2 or emote_mod == 6) and self.m_chatmessage[PREANIM] != "-":
|
||||||
# sfx_delay = int(self.m_chatmessage[SFX_DELAY]) * 60
|
# sfx_delay = int(self.m_chatmessage[SFX_DELAY]) * 60
|
||||||
@ -2358,7 +2374,15 @@ class gui(QtGui.QWidget):
|
|||||||
self.handle_chatmessage_3()
|
self.handle_chatmessage_3()
|
||||||
else:
|
else:
|
||||||
self.play_preanim(True)
|
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):
|
def play_preanim(self, noninterrupting):
|
||||||
f_char = self.m_chatmessage[CHARNAME]
|
f_char = self.m_chatmessage[CHARNAME]
|
||||||
f_preanim = self.m_chatmessage[PREANIM]
|
f_preanim = self.m_chatmessage[PREANIM]
|
||||||
@ -2383,7 +2407,7 @@ class gui(QtGui.QWidget):
|
|||||||
self.anim_state = 1
|
self.anim_state = 1
|
||||||
self.preanim_done()
|
self.preanim_done()
|
||||||
|
|
||||||
self.char.play_pre(f_char, f_preanim, preanim_duration)
|
self.char.play_pre(f_char, f_preanim, preanim_duration, self.scaling[0])
|
||||||
if noninterrupting:
|
if noninterrupting:
|
||||||
self.anim_state = 4
|
self.anim_state = 4
|
||||||
else:
|
else:
|
||||||
@ -2456,10 +2480,10 @@ class gui(QtGui.QWidget):
|
|||||||
f_emote = self.m_chatmessage[ANIM]
|
f_emote = self.m_chatmessage[ANIM]
|
||||||
|
|
||||||
if f_anim_state == 2:
|
if f_anim_state == 2:
|
||||||
self.char.play_talking(f_char, f_emote)
|
self.char.play_talking(f_char, f_emote, self.scaling[0])
|
||||||
self.anim_state = 2
|
self.anim_state = 2
|
||||||
else:
|
else:
|
||||||
self.char.play_idle(f_char, f_emote)
|
self.char.play_idle(f_char, f_emote, self.scaling[0])
|
||||||
self.anim_state = 3
|
self.anim_state = 3
|
||||||
|
|
||||||
if exists(AOpath+"callwords.ini"):
|
if exists(AOpath+"callwords.ini"):
|
||||||
@ -2564,7 +2588,7 @@ class gui(QtGui.QWidget):
|
|||||||
self.text_state = 2
|
self.text_state = 2
|
||||||
if self.anim_state != 4:
|
if self.anim_state != 4:
|
||||||
self.anim_state = 3
|
self.anim_state = 3
|
||||||
self.char.play_idle(self.m_chatmessage[CHARNAME], self.m_chatmessage[ANIM])
|
self.char.play_idle(self.m_chatmessage[CHARNAME], self.m_chatmessage[ANIM], self.scaling[0])
|
||||||
else:
|
else:
|
||||||
f_character2 = f_message[self.tick_pos]
|
f_character2 = f_message[self.tick_pos]
|
||||||
f_character = QtCore.QString(f_character2)
|
f_character = QtCore.QString(f_character2)
|
||||||
@ -2609,7 +2633,7 @@ class gui(QtGui.QWidget):
|
|||||||
if not self.entire_message_is_blue and self.anim_state != 4:
|
if not self.entire_message_is_blue and self.anim_state != 4:
|
||||||
f_char = self.m_chatmessage[CHARNAME]
|
f_char = self.m_chatmessage[CHARNAME]
|
||||||
f_emote = self.m_chatmessage[ANIM]
|
f_emote = self.m_chatmessage[ANIM]
|
||||||
self.char.play_idle(f_char, f_emote)
|
self.char.play_idle(f_char, f_emote, self.scaling[0])
|
||||||
|
|
||||||
elif f_character == ")" and not self.next_character_is_not_special and self.inline_color_stack:
|
elif f_character == ")" and not self.next_character_is_not_special and self.inline_color_stack:
|
||||||
if self.inline_color_stack[-1] == INLINE_BLUE:
|
if self.inline_color_stack[-1] == INLINE_BLUE:
|
||||||
@ -2625,7 +2649,7 @@ class gui(QtGui.QWidget):
|
|||||||
if self.inline_blue_depth == 0 and self.anim_state != 4 and not (self.tick_pos+1 >= len(f_message)):
|
if self.inline_blue_depth == 0 and self.anim_state != 4 and not (self.tick_pos+1 >= len(f_message)):
|
||||||
f_char = self.m_chatmessage[CHARNAME]
|
f_char = self.m_chatmessage[CHARNAME]
|
||||||
f_emote = self.m_chatmessage[ANIM]
|
f_emote = self.m_chatmessage[ANIM]
|
||||||
self.char.play_talking(f_char, f_emote)
|
self.char.play_talking(f_char, f_emote, self.scaling[0])
|
||||||
else:
|
else:
|
||||||
self.next_character_is_not_special = True
|
self.next_character_is_not_special = True
|
||||||
self.tick_pos -= 1
|
self.tick_pos -= 1
|
||||||
|
@ -626,7 +626,7 @@ class AOServerInfo(QtCore.QThread):
|
|||||||
type = int(network[0])
|
type = int(network[0])
|
||||||
areas[type] = [network[i] for i in range(1, len(network))]
|
areas[type] = [network[i] for i in range(1, len(network))]
|
||||||
areas_len = len(areas[type])
|
areas_len = len(areas[type])
|
||||||
print '[client]', 'the server has %d areas' % areas_len
|
print '[client]', 'The server has %d areas' % areas_len
|
||||||
for i in range(areas_len):
|
for i in range(areas_len):
|
||||||
areas[4].append(musiclist[0])
|
areas[4].append(musiclist[0])
|
||||||
del musiclist[0]
|
del musiclist[0]
|
||||||
|
Loading…
Reference in New Issue
Block a user