support preanims in anim subdir

This commit is contained in:
cidoku 2025-02-25 14:15:07 -03:00
parent 4af5217d76
commit b19b999ffa

View File

@ -122,6 +122,12 @@ def get_text_color(textcolor):
return QtGui.QColor(187, 187, 187) return QtGui.QColor(187, 187, 187)
return QtGui.QColor(0, 0, 0) return QtGui.QColor(0, 0, 0)
def test_path(paths):
for path in paths:
if exists(path):
return path
return False
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 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 # bucket 0 ("") is used for server's own bucket
@ -138,6 +144,7 @@ def download_thread(link, savepath):
print "download missing: %s" % link print "download missing: %s" % link
fp = urllib.urlopen(bucket+link) fp = urllib.urlopen(bucket+link)
if fp.getcode() == 200: if fp.getcode() == 200:
print savepath[:-1]
if not os.path.exists(savepath[:-1]): if not os.path.exists(savepath[:-1]):
os.makedirs(savepath[:-1]) os.makedirs(savepath[:-1])
@ -280,12 +287,6 @@ class AOCharMovie(QtGui.QLabel):
def set_flipped(self, flip): def set_flipped(self, flip):
self.m_flipped = flip self.m_flipped = flip
def test_path(self, paths):
for path in paths:
if exists(path):
return path
return False
def play(self, p_char, p_emote, emote_prefix, scaling = SCALING_AUTO): 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] == "/":
@ -305,10 +306,10 @@ class AOCharMovie(QtGui.QLabel):
p_char = p_char.lower() p_char = p_char.lower()
p_emote = p_emote.lower() p_emote = p_emote.lower()
original_path = self.test_path([AOpath+"characters/"+p_char+"/"+emote_prefix+p_emote+".gif", AOpath+"characters/"+p_char+"/"+emote_prefix+p_emote+".gif"]) original_path = test_path([AOpath+"characters/"+p_char+"/"+emote_prefix+p_emote+".gif", 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 = self.test_path([AOpath+"characters/"+p_char+"/"+emote_prefix+p_emote+".apng", AOpath+"characters/"+p_char+"/"+emote_prefix+"/"+p_emote+".apng"]) apng_path = test_path([AOpath+"characters/"+p_char+"/"+emote_prefix+p_emote+".apng", AOpath+"characters/"+p_char+"/"+emote_prefix+"/"+p_emote+".apng"])
webp_path = self.test_path([AOpath+"characters/"+p_char+"/"+emote_prefix+p_emote+".webp", AOpath+"characters/"+p_char+"/"+emote_prefix+"/"+p_emote+".webp"]) webp_path = test_path([AOpath+"characters/"+p_char+"/"+emote_prefix+p_emote+".webp", AOpath+"characters/"+p_char+"/"+emote_prefix+"/"+p_emote+".webp"])
placeholder_path = AO2XPpath+"themes/default/placeholder.gif" placeholder_path = AO2XPpath+"themes/default/placeholder.gif"
gif_path = "" gif_path = ""
@ -2097,7 +2098,7 @@ class gui(QtGui.QWidget):
packet = "" packet = ""
for f_emote in emotes_to_check: for f_emote in emotes_to_check:
packet += f_emote packet += f_emote
if ini.read_ini_bool("AO2XP.ini", "General", "network frame effects"): if ini.read_ini_bool("AO2XP.ini", "General", "network frame effects", True):
sfx_frames = "|".join(ini.read_ini_tags(AOpath+"characters/"+self.charname+"/char.ini", f_emote + f_effect)) sfx_frames = "|".join(ini.read_ini_tags(AOpath+"characters/"+self.charname+"/char.ini", f_emote + f_effect))
if sfx_frames: if sfx_frames:
packet += "|" + sfx_frames packet += "|" + sfx_frames
@ -2503,10 +2504,11 @@ class gui(QtGui.QWidget):
else: else:
preanim_duration = ao2_duration preanim_duration = ao2_duration
anim_to_find = AOpath+"characters/"+f_char+"/"+f_preanim+".gif" anim_to_find = test_path([AOpath+"characters/"+f_char+"/"+f_preanim+".gif", AOpath+"characters/"+f_char+"/anim/"+f_preanim+".gif"])
apng_to_find = AOpath+"characters/"+f_char+"/"+f_preanim+".apng" apng_to_find = test_path([AOpath+"characters/"+f_char+"/"+f_preanim+".apng", AOpath+"characters/"+f_char+"/anim/"+f_preanim+".apng"])
webp_to_find = AOpath+"characters/"+f_char+"/"+f_preanim+".webp" webp_to_find = test_path([AOpath+"characters/"+f_char+"/"+f_preanim+".webp", AOpath+"characters/"+f_char+"/anim/"+f_preanim+".webp"])
if (not exists(anim_to_find) and not exists(apng_to_find) and not exists(webp_to_find)) or preanim_duration < 0:
if (not anim_to_find and not apng_to_find and not webp_to_find) or preanim_duration < 0:
if noninterrupting: if noninterrupting:
self.anim_state = 4 self.anim_state = 4
else: else: