Doll performance and bug fixes
* Implemented threading and lazyloading for the main doll * Added global rebuild method for the dolls * Updated save compatibility patch * Fixed wardrobe categories showing locked items
This commit is contained in:
parent
b21dbb6cbf
commit
4b1b01eb09
@ -74,3 +74,11 @@ init -1 python:
|
|||||||
stale = curr_hash != self._hash
|
stale = curr_hash != self._hash
|
||||||
self._hash = curr_hash
|
self._hash = curr_hash
|
||||||
return stale
|
return stale
|
||||||
|
|
||||||
|
def DollRebuild():
|
||||||
|
for i in states.dolls:
|
||||||
|
doll = getattr(store, i)
|
||||||
|
doll.build_image()
|
||||||
|
|
||||||
|
config.after_load_callbacks.append(DollRebuild)
|
||||||
|
# end_skip_callbacks.append(DollRebuild)
|
@ -60,6 +60,7 @@ init python:
|
|||||||
self.pose = "default"
|
self.pose = "default"
|
||||||
self.emote = Null()
|
self.emote = Null()
|
||||||
self._hash = None
|
self._hash = None
|
||||||
|
self._sprite = DefaultQueue()
|
||||||
|
|
||||||
# Image properties
|
# Image properties
|
||||||
self.zorder = 15
|
self.zorder = 15
|
||||||
@ -103,7 +104,7 @@ init python:
|
|||||||
renpy.hide(name=self.tag, layer=self.layer)
|
renpy.hide(name=self.tag, layer=self.layer)
|
||||||
|
|
||||||
@functools.cache
|
@functools.cache
|
||||||
def build_image(self, hash):
|
def _build_image(self, hash):
|
||||||
from itertools import chain
|
from itertools import chain
|
||||||
|
|
||||||
# Note: Bodyparts are a part of 'self.states' now.
|
# Note: Bodyparts are a part of 'self.states' now.
|
||||||
@ -140,13 +141,30 @@ init python:
|
|||||||
|
|
||||||
return Fixed(*sprites, self.emote, fit_first=True)
|
return Fixed(*sprites, self.emote, fit_first=True)
|
||||||
|
|
||||||
|
def build_image(self):
|
||||||
|
|
||||||
|
def _func(self, hash):
|
||||||
|
result = self._build_image(hash)
|
||||||
|
self._sprite.put(result)
|
||||||
|
|
||||||
|
thread = DollThread(target=_func, args=(self, self._hash))
|
||||||
|
thread.start()
|
||||||
|
|
||||||
|
def _image(self, st, at):
|
||||||
|
return self._sprite.get_with_default(None), None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def image(self):
|
def image(self):
|
||||||
|
|
||||||
if not renpy.is_skipping() and self.is_stale():
|
if not renpy.is_skipping() and self.is_stale():
|
||||||
|
self.build_image()
|
||||||
|
|
||||||
if renpy.showing(get_character_tag(self.name), layer=self.layer):
|
if renpy.showing(get_character_tag(self.name), layer=self.layer):
|
||||||
self.show()
|
self.show()
|
||||||
|
elif renpy.in_rollback():
|
||||||
|
self.build_image()
|
||||||
|
|
||||||
return self.build_image(self._hash)
|
return DynamicDisplayable(self._image)
|
||||||
|
|
||||||
def equip(self, obj, remove_old=True):
|
def equip(self, obj, remove_old=True):
|
||||||
"""Takes DollCloth or DollOutfit object to equip."""
|
"""Takes DollCloth or DollOutfit object to equip."""
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
init -1 python:
|
init -5 python:
|
||||||
|
|
||||||
start_skip_callbacks = []
|
start_skip_callbacks = []
|
||||||
end_skip_callbacks = []
|
end_skip_callbacks = []
|
||||||
@ -23,6 +23,3 @@ init -1 python:
|
|||||||
c()
|
c()
|
||||||
|
|
||||||
config.interact_callbacks.append(SkipCallbacksHandler())
|
config.interact_callbacks.append(SkipCallbacksHandler())
|
||||||
|
|
||||||
#end_skip_callbacks.append(rebuild_dolls)
|
|
||||||
|
|
||||||
|
@ -101,9 +101,9 @@ init python:
|
|||||||
|
|
||||||
if current < 1.452:
|
if current < 1.452:
|
||||||
|
|
||||||
|
|
||||||
for i in states.dolls:
|
for i in states.dolls:
|
||||||
doll = getattr(store, i)
|
doll = getattr(store, i)
|
||||||
|
doll._sprite = DefaultQueue()
|
||||||
|
|
||||||
for j in doll.wardrobe_list:
|
for j in doll.wardrobe_list:
|
||||||
# Add new button handler for clothes
|
# Add new button handler for clothes
|
||||||
|
@ -91,6 +91,20 @@ init python:
|
|||||||
thread = DollThread(target=_func, args=(cloth,), interval=0.05)
|
thread = DollThread(target=_func, args=(cloth,), interval=0.05)
|
||||||
thread.start()
|
thread.start()
|
||||||
|
|
||||||
|
@functools.cache # Cache resets on wardrobe exit
|
||||||
|
def set_wardrobe_categories(current_category):
|
||||||
|
category_items = OrderedDict(
|
||||||
|
sorted(
|
||||||
|
[
|
||||||
|
(subcat, [item for item in items if item.unlocked])
|
||||||
|
for subcat, items in wardrobe_subcategories.get(current_category, {}).items()
|
||||||
|
],
|
||||||
|
key=lambda x: wardrobe_subcategories_sorted.get(x[0], 0),
|
||||||
|
reverse=True
|
||||||
|
)
|
||||||
|
)
|
||||||
|
return category_items
|
||||||
|
|
||||||
style loading_text:
|
style loading_text:
|
||||||
color "#ffffff"
|
color "#ffffff"
|
||||||
size 64
|
size 64
|
||||||
@ -217,7 +231,7 @@ label wardrobe_menu():
|
|||||||
|
|
||||||
# Defaults
|
# Defaults
|
||||||
current_category = "head"
|
current_category = "head"
|
||||||
category_items = OrderedDict(sorted(iter(list(wardrobe_subcategories.get(current_category, {}).items())), key=lambda x: wardrobe_subcategories_sorted.get(x[0], 0), reverse=True))
|
category_items = set_wardrobe_categories(current_category)
|
||||||
current_subcategory = list(category_items.keys())[0] if category_items else ""
|
current_subcategory = list(category_items.keys())[0] if category_items else ""
|
||||||
current_item = char_active.get_equipped_wardrobe_item(category_items, current_subcategory)
|
current_item = char_active.get_equipped_wardrobe_item(category_items, current_subcategory)
|
||||||
last_track = renpy.music.get_playing()
|
last_track = renpy.music.get_playing()
|
||||||
@ -251,7 +265,7 @@ label wardrobe_menu():
|
|||||||
if wardrobe_check_category(_choice[1]):
|
if wardrobe_check_category(_choice[1]):
|
||||||
$ current_category = _choice[1]
|
$ current_category = _choice[1]
|
||||||
|
|
||||||
$ category_items = OrderedDict(sorted(iter(wardrobe_subcategories.get(current_category, {}).items()), key=lambda x: wardrobe_subcategories_sorted.get(x[0], 0), reverse=True))
|
$ category_items = set_wardrobe_categories(current_category)
|
||||||
$ current_subcategory = list(category_items.keys())[0] if category_items else ""
|
$ current_subcategory = list(category_items.keys())[0] if category_items else ""
|
||||||
|
|
||||||
if current_category == "outfits":
|
if current_category == "outfits":
|
||||||
@ -566,10 +580,13 @@ label wardrobe_menu():
|
|||||||
renpy.music.play(last_track)
|
renpy.music.play(last_track)
|
||||||
|
|
||||||
DollThread.stop_all()
|
DollThread.stop_all()
|
||||||
|
set_wardrobe_categories.cache_clear()
|
||||||
|
char_active.build_image()
|
||||||
|
|
||||||
enable_game_menu()
|
enable_game_menu()
|
||||||
renpy.return_statement()
|
renpy.return_statement()
|
||||||
|
|
||||||
|
$ char_active.build_image()
|
||||||
|
|
||||||
jump .after_init
|
jump .after_init
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user