Reimplement wardrobe's color picker using last (csinc)
This commit is contained in:
parent
a9bf2a637e
commit
0712f0e251
@ -323,11 +323,11 @@ init python:
|
||||
return Transform(img, maxsize=maxsize, matrixcolor=SepiaMatrix(c, desat=average)*OpacityMatrix(c.alpha))
|
||||
|
||||
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)
|
||||
return Transform(AlphaMask(d, img))
|
||||
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)
|
||||
return Transform(AlphaMask(d, img))
|
||||
|
||||
@ -341,34 +341,13 @@ init python:
|
||||
cp.start_replace(col)
|
||||
cp.default_replace(dcol)
|
||||
|
||||
renpy.show_screen("colorpickerscreen", self)
|
||||
renpy.dynamic(
|
||||
color_picker_n=n,
|
||||
color_picker_item=self,
|
||||
)
|
||||
|
||||
while True:
|
||||
try:
|
||||
action, value = ui.interact()
|
||||
except:
|
||||
print(f"{ui.interact()}")
|
||||
break
|
||||
call_screen_in_new_context("colorpickerscreen", self)
|
||||
|
||||
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):
|
||||
self.color = [Color( (tuple(x) if isinstance(x, list) else x) ) for x in n]
|
||||
self.is_stale()
|
||||
|
@ -144,7 +144,8 @@ init python:
|
||||
self.unfocus()
|
||||
self.apply()
|
||||
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]:
|
||||
# Dragged
|
||||
@ -393,6 +394,33 @@ init python:
|
||||
|
||||
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.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)
|
||||
background col
|
||||
foreground "cp_borders"
|
||||
action Return(["layer", i])
|
||||
alternate Return(["replace", col])
|
||||
action __Layer(i)
|
||||
alternate __Replace(col)
|
||||
text str(i+1) style "colorpicker_innertext"
|
||||
|
||||
hbox:
|
||||
@ -461,13 +489,13 @@ screen colorpickerscreen(item=None):
|
||||
button:
|
||||
xysize (32, 32)
|
||||
background cp.start_color
|
||||
action Return(["replace", cp.start_color])
|
||||
action __Replace(cp.start_color)
|
||||
text "Old" style "colorpicker_innertext" size 8
|
||||
frame:
|
||||
button:
|
||||
xysize (32, 32)
|
||||
background cp.default_color
|
||||
action Return(["replace", cp.default_color])
|
||||
action __Replace(cp.default_color)
|
||||
text "Org" style "colorpicker_innertext" size 8
|
||||
|
||||
label "Swatches"
|
||||
@ -481,7 +509,7 @@ screen colorpickerscreen(item=None):
|
||||
button:
|
||||
xysize (12, 12)
|
||||
background col
|
||||
action Return(["replace", col])
|
||||
action __Replace(col)
|
||||
alternate Function(cp.add_favorite, i, cp.live_color)
|
||||
|
||||
label "History"
|
||||
@ -495,7 +523,7 @@ screen colorpickerscreen(item=None):
|
||||
button:
|
||||
xysize (12, 12)
|
||||
background col
|
||||
action Return(["replace", col])
|
||||
action __Replace(col)
|
||||
|
||||
hbox:
|
||||
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)]
|
||||
|
||||
textbutton "Finish":
|
||||
action Return(["finish", cp.live_color])
|
||||
action Return()
|
||||
keysym ["K_ESCAPE", "K_RETURN"]
|
||||
|
||||
if config.developer:
|
||||
|
@ -55,9 +55,7 @@ init python:
|
||||
if not settings.get("multithreading"):
|
||||
return icon
|
||||
|
||||
lock = bool(DollThread._count)
|
||||
|
||||
return gray_tint(icon) if lock else icon
|
||||
return gray_tint(icon) if DollThread._count else icon
|
||||
|
||||
def randomise_wardrobe_color(cloth):
|
||||
|
||||
@ -672,7 +670,7 @@ screen wardrobe_menu(xx, yy):
|
||||
background lock_wardrobe_icon(icon)
|
||||
activate_sound "sounds/scroll.ogg"
|
||||
tooltip category
|
||||
sensitive (not bool(DollThread._count))
|
||||
sensitive (not DollThread._count)
|
||||
action Call("wardrobe_actions.category", category, from_current=True)
|
||||
if current_category == category:
|
||||
xoffset icon_xoffset
|
||||
@ -689,7 +687,7 @@ screen wardrobe_menu(xx, yy):
|
||||
xysize (72, 72)
|
||||
background lock_wardrobe_icon(Fixed(icon_bg, Transform("interface/wardrobe/icons/categories/outfits.webp", zoom=0.45, anchor=(0.5, 0.5), align=(0.5, 0.5)), icon_frame))
|
||||
tooltip "Outfits Manager"
|
||||
sensitive (not bool(DollThread._count))
|
||||
sensitive (not DollThread._count)
|
||||
action Call("wardrobe_actions.category", "outfit", from_current=True)
|
||||
if current_category == "outfits":
|
||||
yoffset icon_yoffset
|
||||
@ -808,7 +806,7 @@ screen wardrobe_menuitem(xx, yy):
|
||||
selected_background Transform(icon, size=(72, 72), fit="contain", )
|
||||
selected (subcategory == current_subcategory)
|
||||
tooltip subcategory
|
||||
sensitive (not bool(DollThread._count))
|
||||
sensitive (not DollThread._count)
|
||||
action Call("wardrobe_actions.subcategory", subcategory, from_current=True)
|
||||
|
||||
# # Item icons
|
||||
@ -865,7 +863,7 @@ screen wardrobe_outfit_menuitem(xx, yy):
|
||||
background Transform(icon, alpha=0.65, xsize=72, fit="contain")
|
||||
selected_background Transform(icon, xsize=72, fit="contain")
|
||||
selected (subcategory == current_subcategory)
|
||||
sensitive (not bool(DollThread._count))
|
||||
sensitive (not DollThread._count)
|
||||
tooltip subcategory
|
||||
action action
|
||||
|
||||
@ -892,7 +890,7 @@ screen wardrobe_outfit_menuitem(xx, yy):
|
||||
insensitive_background "#0000001A"
|
||||
idle_background "#00000033"
|
||||
text_align (0.5, 0.5)
|
||||
sensitive (not bool(DollThread._count))
|
||||
sensitive (not DollThread._count)
|
||||
action WardrobeAddOutfit(None)
|
||||
|
||||
if current_subcategory == "import":
|
||||
|
Loading…
Reference in New Issue
Block a user