Compare commits

..

5 Commits

Author SHA1 Message Date
15b15b9085 Remove mutable in signature and pop todo 2023-11-17 03:52:56 +01:00
3fef941366 Remove dependency 2023-11-17 03:52:39 +01:00
6b2766e668 Better pass kwargs
this is not py2 anymore
2023-11-17 03:46:34 +01:00
2f2a9b985b Don't use protected variable name 2023-11-17 03:46:18 +01:00
d132436843 Use scene statement instead of equivalent 2023-11-17 03:41:56 +01:00
3 changed files with 11 additions and 16 deletions

View File

@ -12,14 +12,14 @@ screen color_picker(color, alpha, title, pos_xy, color_default):
default hue = 0
default sat = 0
default val = 0
default _alpha = 0 # Avoid name conflict with 'alpha' screen variable in other active screens
default alpha_ = 0 # Avoid name conflict with 'alpha' screen variable in other active screens
default edit_mode = False
default preview_old = Solid(rgba)
$ preview_new = Solid(rgba)
$ gradient_map = SVGradientButton(
color_picker_clicked,
Fixed(
Color( tuple( x * 255 for x in colorsys.hsv_to_rgb(1 - hue, 1, 1) ) ),
Color(hsv=(1-hue, 1, 1)),
Frame("interface/color_picker/saturation_value_gradient.webp")
),
xysize=(255, 255),
@ -213,7 +213,7 @@ screen color_picker(color, alpha, title, pos_xy, color_default):
Transform(alpha_gradient_image, matrixcolor=ColorizeMatrix(rgba, rgba)))
bar:
xysize (255, 30)
value ScreenVariableValue("_alpha", range=1.0, action=Function(color_picker_update_rgba))
value ScreenVariableValue("alpha_", range=1.0, action=Function(color_picker_update_rgba))
base_bar icon_frame
thumb Image(gui.format("interface/color_picker/{}/cursor_v.webp"), xalign=0.5)
thumb_offset 0
@ -234,11 +234,9 @@ define hue_gradient_image = HueSlider()
init -1 python:
def color_picker(color=[0,0,0,0], alpha=True, title="Pick a colour", pos_xy=(240, 130), color_default=None):
# TODO: Remove external dependencies and utilise built-in Color class instead.
def color_picker(color=(0,0,0,0), alpha=True, title="Pick a colour", pos_xy=(240, 130), color_default=None):
global picking_color
picking_color = color # Color object (list) to be updated live
picking_color = list(color) # Color object (list) to be updated live
start_color = list(color) # Keep a copy
renpy.show_screen("color_picker", tuple(color), alpha, title, pos_xy, color_default)
@ -305,19 +303,19 @@ init -1 python:
def color_picker_update_hsva():
scope = renpy.get_screen("color_picker").scope
(r, g, b, a) = scope["rgba"]
(h, s, v) = colorsys.rgb_to_hsv(r / 255.0, g / 255.0, b / 255.0)
(h, s, v) = Color((r, g, b)).hsv
scope["hue"] = 1 - h
scope["sat"] = s
scope["val"] = v
scope["_alpha"] = a / 255.0
scope["alpha_"] = a / 255.0
def color_picker_update_rgba():
scope = renpy.get_screen("color_picker").scope
(r, g, b) = colorsys.hsv_to_rgb(1 - scope["hue"], scope["sat"], scope["val"])
(r, g, b) = Color(hsv=(1 - scope["hue"], scope["sat"], scope["val"])).rgb
r = int(r * 255)
g = int(g * 255)
b = int(b * 255)
a = int(scope["_alpha"] * 255)
a = int(scope["alpha_"] * 255)
scope["rgba"] = (r, g, b, a)
update_picking_color(scope["rgba"])
renpy.restart_interaction()
@ -428,9 +426,7 @@ init -1 python:
class SVGradientButton(ImageButton):
def __init__(self, on_click, idle_image, *args, **kwargs):
kwargs['sensitive'] = True
kwargs['action'] = NullAction()
super(SVGradientButton, self).__init__(idle_image, *args, **kwargs)
super(SVGradientButton, self).__init__(idle_image, *args, sensitive=True, action=NullAction(), **kwargs)
self.width = 0
self.height = 0
self.on_click = on_click

View File

@ -61,7 +61,7 @@ label credits:
if not _menu:
play music "music/Only 115 (Electro Loop)_125 BPM.ogg" fadein 1 fadeout 1 if_changed
$ renpy.scene("screens")
scene onlayer screens
show screen credits(credits_text)
with dissolve

View File

@ -5,7 +5,6 @@ init python early:
import math
import random
import pygame
import colorsys
import fnmatch
import posixpath
import re