Compare commits

..

10 Commits

8 changed files with 455 additions and 407 deletions

View File

@ -230,7 +230,7 @@ init python:
hbox = [] hbox = []
overlay = [] overlay = []
action = [Return(["equip", self]), self.build_button] action = [Call("wardrobe_actions.equip", self, from_current=True), self.build_button]
unhovered = None unhovered = None
foreground = None foreground = None
hover_foreground = "#ffffff80" hover_foreground = "#ffffff80"
@ -323,11 +323,11 @@ init python:
return Transform(img, maxsize=maxsize, matrixcolor=SepiaMatrix(c, desat=average)*OpacityMatrix(c.alpha)) return Transform(img, maxsize=maxsize, matrixcolor=SepiaMatrix(c, desat=average)*OpacityMatrix(c.alpha))
except TypeError: except TypeError:
print(f"Item doesn't support colors but was supplied with a list; Try removing numbered files in its directory:\n{self.__repr__()}") print(f"Item doesn't support colors but was supplied with a list; Try removing numbered files in its directory:\n{self!r}")
d = At(Frame(Text("TypeErr", color="#ffff00"), tile=True), blink_repeat) d = At(Frame(Text("TypeErr", color="#ffff00"), tile=True), blink_repeat)
return Transform(AlphaMask(d, img)) return Transform(AlphaMask(d, img))
except IndexError: except IndexError:
print(f"Mismatched number of textures and colors; Try reducing number of supplied colours in item definition:\n{self.__repr__()}") print(f"Mismatched number of textures and colors; Try reducing number of supplied colours in item definition:\n{self!r}")
d = At(Frame(Text("IndxErr", color="#ff0000"), tile=True), blink_repeat) d = At(Frame(Text("IndxErr", color="#ff0000"), tile=True), blink_repeat)
return Transform(AlphaMask(d, img)) return Transform(AlphaMask(d, img))
@ -341,34 +341,13 @@ init python:
cp.start_replace(col) cp.start_replace(col)
cp.default_replace(dcol) cp.default_replace(dcol)
renpy.show_screen("colorpickerscreen", self) renpy.dynamic(
color_picker_n=n,
color_picker_item=self,
)
while True: call_screen_in_new_context("colorpickerscreen", self)
try:
action, value = ui.interact()
except:
print(f"{ui.interact()}")
break
if action == "layer":
n = value
col = self.color[value]
dcol = self.color_default[value]
cp.live_replace(col)
cp.start_replace(col)
cp.default_replace(dcol)
elif action == "released":
self.color[n] = value
self.is_stale()
elif action == "replace":
self.color[n] = value
cp.live_replace(value)
self.is_stale()
elif action == "finish":
break
renpy.hide_screen("colorpickerscreen")
elif isinstance(n, list): elif isinstance(n, list):
self.color = [Color( (tuple(x) if isinstance(x, list) else x) ) for x in n] self.color = [Color( (tuple(x) if isinstance(x, list) else x) ) for x in n]
self.is_stale() self.is_stale()

View File

@ -130,25 +130,25 @@ init python:
## One can manipulate the button actions using Button.action ## One can manipulate the button actions using Button.action
if subcat == "delete": if subcat == "delete":
action = Return(["deloutfit", self]) action = WardrobeDelOutfit(self)
elif subcat == "load": elif subcat == "load":
action = Return(["equip", self]) action = Call("wardrobe_actions.equip", self, from_current=True)
elif subcat == "save": elif subcat == "save":
action = Return(["addoutfit", self]) action = WardrobeAddOutfit(self)
# elif subcat == "import": # Imports are taken care of outside the class. # elif subcat == "import": # Imports are taken care of outside the class.
# action = Return(["import", self]) # action = WardrobeImport(self)
elif subcat == "export": elif subcat == "export":
action = Return(["export", self]) action = WardrobeExport(self)
elif subcat == "schedule": elif subcat == "schedule":
if not has_schedule and not is_inadequate: if not has_schedule and not is_inadequate:
action = Return(["schedule", self]) action = Call("wardrobe_actions.schedule", self, from_current=True)
alternate = Return(["schedule", self]) alternate = Call("wardrobe_actions.schedule", self, from_current=True)
foreground = "#00000040" foreground = "#00000040"
hover_foreground = "#80808040" hover_foreground = "#80808040"
selected_foreground = "#80808040" selected_foreground = "#80808040"
elif has_schedule: elif has_schedule:
action = Return(["schedule", self]) action = Call("wardrobe_actions.schedule", self, from_current=True)
alternate = Return(["schedule", self]) alternate = Call("wardrobe_actions.schedule", self, from_current=True)
# elif is_inadequate: # elif is_inadequate:
# foreground = "#b2000040" # foreground = "#b2000040"
# hover_foreground = "#CD5C5C40" # hover_foreground = "#CD5C5C40"
@ -286,4 +286,3 @@ init python:
if self.has_type(arg): if self.has_type(arg):
return True return True
return False return False

View File

@ -219,3 +219,10 @@ init python early:
if match: if match:
return int(match.group(1)) return int(match.group(1))
return float('inf') # Return a large number for non-numeric keys return float('inf') # Return a large number for non-numeric keys
def call_screen_in_new_context(sc_name, *args, **kwargs):
"""
Calls the `sc_name` screen in a new context, passing it *args and **kwargs.
Returns the value returned by the screen, if any.
"""
return renpy.call_in_new_context("call_screen", sc_name, *args, **kwargs)

View File

@ -152,3 +152,8 @@ label end_of_content():
nar "All stats have been maxed out. You can now use all of the wardrobe options." nar "All stats have been maxed out. You can now use all of the wardrobe options."
return return
label call_screen(sc_name, *args, **kwargs):
# call call_screen("name", *args, **kwargs) <=> call screen name(*args, **kwargs)
call screen expression sc_name pass (*args, **kwargs)
return _return

View File

@ -144,7 +144,8 @@ init python:
self.unfocus() self.unfocus()
self.apply() self.apply()
renpy.restart_interaction() renpy.restart_interaction()
return ["released", self.controller.live_color] __released(self.controller.live_color)
raise renpy.IgnoreEvent
if ev.type == pygame.MOUSEMOTION and ev.buttons[0]: if ev.type == pygame.MOUSEMOTION and ev.buttons[0]:
# Dragged # Dragged
@ -393,6 +394,33 @@ init python:
cp = ColorPicker() cp = ColorPicker()
class __Layer(Action):
def __init__(self, value):
self.value = value
def __call__(self):
global color_picker_n
color_picker_n = self.value
col = color_picker_item.color[color_picker_n]
dcol = color_picker_item.color_default[color_picker_n]
cp.live_replace(col)
cp.start_replace(col)
cp.default_replace(dcol)
def __released(value):
color_picker_item.color[color_picker_n] = value
color_picker_item.is_stale()
class __Replace(Action):
def __init__(self, value):
self.value = value
def __call__(self):
color_picker_item.color[color_picker_n] = self.value
cp.live_replace(self.value)
color_picker_item.is_stale()
default colorpicker.history = [] default colorpicker.history = []
default colorpicker.favorites = [Color((167, 77, 42)), Color((237, 179, 14)), Color((89, 116, 194)), Color((216, 163, 10)), Color((58, 115, 75)), Color((205, 205, 206)), Color((251, 198, 10)), Color((51, 43, 54))] + ([Color((255, 255, 255))] * 22) default colorpicker.favorites = [Color((167, 77, 42)), Color((237, 179, 14)), Color((89, 116, 194)), Color((216, 163, 10)), Color((58, 115, 75)), Color((205, 205, 206)), Color((251, 198, 10)), Color((51, 43, 54))] + ([Color((255, 255, 255))] * 22)
@ -426,8 +454,8 @@ screen colorpickerscreen(item=None):
xysize (32, 32) xysize (32, 32)
background col background col
foreground "cp_borders" foreground "cp_borders"
action Return(["layer", i]) action __Layer(i)
alternate Return(["replace", col]) alternate __Replace(col)
text str(i+1) style "colorpicker_innertext" text str(i+1) style "colorpicker_innertext"
hbox: hbox:
@ -461,13 +489,13 @@ screen colorpickerscreen(item=None):
button: button:
xysize (32, 32) xysize (32, 32)
background cp.start_color background cp.start_color
action Return(["replace", cp.start_color]) action __Replace(cp.start_color)
text "Old" style "colorpicker_innertext" size 8 text "Old" style "colorpicker_innertext" size 8
frame: frame:
button: button:
xysize (32, 32) xysize (32, 32)
background cp.default_color background cp.default_color
action Return(["replace", cp.default_color]) action __Replace(cp.default_color)
text "Org" style "colorpicker_innertext" size 8 text "Org" style "colorpicker_innertext" size 8
label "Swatches" label "Swatches"
@ -481,7 +509,7 @@ screen colorpickerscreen(item=None):
button: button:
xysize (12, 12) xysize (12, 12)
background col background col
action Return(["replace", col]) action __Replace(col)
alternate Function(cp.add_favorite, i, cp.live_color) alternate Function(cp.add_favorite, i, cp.live_color)
label "History" label "History"
@ -495,7 +523,7 @@ screen colorpickerscreen(item=None):
button: button:
xysize (12, 12) xysize (12, 12)
background col background col
action Return(["replace", col]) action __Replace(col)
hbox: hbox:
align (1.0, 1.0) align (1.0, 1.0)
@ -505,7 +533,7 @@ screen colorpickerscreen(item=None):
action [Function(item.reset_color), Function(cp.live_replace, cp.default_color)] action [Function(item.reset_color), Function(cp.live_replace, cp.default_color)]
textbutton "Finish": textbutton "Finish":
action Return(["finish", cp.live_color]) action Return()
keysym ["K_ESCAPE", "K_RETURN"] keysym ["K_ESCAPE", "K_RETURN"]
if config.developer: if config.developer:

View File

@ -178,7 +178,7 @@ init -1 python:
def build_button(rp): def build_button(rp):
style = "wardrobe_button" style = "wardrobe_button"
child = Fixed(Transform(rp, xsize=96, fit="contain", yalign=1.0, yoffset=-6), Frame(gui.format("interface/frames/{}/iconframe.webp"), 6, 6), xysize=(96, 168)) child = Fixed(Transform(rp, xsize=96, fit="contain", yalign=1.0, yoffset=-6), Frame(gui.format("interface/frames/{}/iconframe.webp"), 6, 6), xysize=(96, 168))
action = Return(["import", rp]) action = WardrobeImport(rp)
hover_foreground = "#ffffff80" hover_foreground = "#ffffff80"
return Button(child=child, action=action, hover_foreground=hover_foreground, style=style) return Button(child=child, action=action, hover_foreground=hover_foreground, style=style)

View File

@ -70,4 +70,7 @@ init python:
renpy.suspend_rollback(False) renpy.suspend_rollback(False)
renpy.block_rollback() renpy.block_rollback()
renpy.call_in_new_context(get_character_response(states.active_girl, what), arg) renpy.call_in_new_context(get_character_response(states.active_girl, what), arg)
_skipping = False
renpy.suspend_rollback(True)
renpy.block_rollback()
return return

File diff suppressed because it is too large Load Diff