Compare commits

..

28 Commits

Author SHA1 Message Date
4de4788b16 Actually do not forgive wrong warper names 2024-04-06 00:50:50 +02:00
96767c63ae Fix 2024-04-06 00:49:33 +02:00
1a70aff3bc Unnecessary module 2024-04-06 00:46:04 +02:00
5f742d4525 Simplify following turning states.dolls into a dict 2024-04-06 00:42:27 +02:00
e88fda5a2c Use the cds version 2024-04-05 23:38:31 +02:00
6b6ad56af4 Update existing code 2024-04-05 23:29:37 +02:00
0f80487dfc Remove the register function 2024-04-05 23:28:11 +02:00
42d2a17a6a Move the static values to a defined constant
That way it's not saved and it can be upgraded from version to version
2024-04-05 23:26:55 +02:00
0d8e91b5a5 Stop using mutable default values for parameters 2024-04-05 23:21:20 +02:00
314f971609 Allow poses to be passed to the constructor, and update test script
One problem : it still should not go into a defaulted object
2024-04-05 23:21:01 +02:00
ec27f91904 Fix lint and prediction 2024-04-05 00:20:21 +02:00
e129921bc0 Take the doll parameter 2024-04-04 23:34:35 +02:00
94b5ea15a5 Better parsing 2024-04-04 23:25:15 +02:00
923384eb37 Fix test labels 2024-04-04 23:17:00 +02:00
c2d8c394a1 Fix cds 2024-04-04 23:15:35 +02:00
9befd927a8 fix 2024-04-04 22:58:41 +02:00
e9ec437d1c Eliminate more uses of eval 2024-04-04 22:55:15 +02:00
dfd7972752 Avoid using a weak name link 2024-04-04 22:51:02 +02:00
1e8f1ebfb8 Use a dict to store the dolls
the existing variable was a set, all the existing use cases still work (contains tests, iteration, turning into lists...)
2024-04-04 22:50:01 +02:00
878cec8c76 Simplify some 2024-04-04 22:37:33 +02:00
b49129ad1f Avoid evals and release name constraint
Name resemblances between two variables should be for the developers' benefit only. If there is a link between data, it should be apparent.
2024-04-04 22:36:46 +02:00
34547cb0ad Use an instance storage dict
to avoid main store pollution and evals
2024-04-04 22:34:27 +02:00
caa4cd0b2c Works without the screens
tested on a save
2024-04-03 01:47:02 +02:00
cd63abd27b nitwit 2024-04-03 01:42:36 +02:00
c0bc1cd69f Avoid using screens for chibis
Not exactly sure what to do with the screens for saves compat tbh, should be fine either way and maybe removing the definitions will work
2024-04-03 01:33:13 +02:00
00eda2aae5 Simpler syntax 2024-04-03 01:03:54 +02:00
ae5ff121d9 Moar lint 2024-04-03 01:03:46 +02:00
2525bea67d Move the file again 2024-04-03 00:50:26 +02:00
8 changed files with 130 additions and 174 deletions

View File

@ -73,30 +73,42 @@ python early hide:
class chibi: class chibi:
@staticmethod @staticmethod
def parse(l): def parse(l):
who = l.simple_expression() who = l.require(l.name)
action = l.simple_expression() action = l.require(l.name)
arguments = l.arguments() # may be None
l.expect_eol()
return (who, action) return (who, action, arguments)
def execute(self): def execute(self):
print(f"{self}") print(self)
who, action = self who, action, arguments = self
func = eval(f"{who}_chibi.{action}") chibi = DollChibi.instances[who]
method = getattr(chibi, action)
if arguments is None:
args, kwargs = (), {}
else:
args, kwargs = arguments.evaluate()
method(*args, **kwargs)
# print(f"Execution: {who} {action}") # print(f"Execution: {who} {action}")
def lint(self): def lint(self):
who, action = self who, action, arguments = self
try:
chibi = eval(f"{who}_chibi") if who not in DollChibi.instances:
except Exception:
renpy.error(f"Character chibi not defined: {who}") renpy.error(f"Character chibi not defined: {who}")
def predict(self): chibi = DollChibi.instances[who]
who, action = self
chibi = eval(f"{who}_chibi") if not hasattr(chibi, action):
doll = eval(f"{who}") renpy.error(f"Chibi action not defined: {who} {action}")
def predict(self):
who, action, arguments = self
chibi = DollChibi.instances[who]
doll = states.dolls[who]
layers = ( layers = (
l[0] for pose in chibi.poses.keys() l[0] for pose in chibi.poses.keys()
@ -142,6 +154,23 @@ python early hide:
return {"blocks": blocks} return {"blocks": blocks}
def lint(self):
any_true = False
for block, weight, condition in self["blocks"]:
if not isinstance(weight, (int, float)):
renpy.error(f"Weight must be a number, not {weight!r}")
if condition == "True":
any_true = True
else:
try:
eval(condition)
except Exception:
renpy.error(f"Condition could not be evaluated: {condition!r}")
if not any_true:
renpy.error("All blocks have a condition, which will raise an exception if all conditions are False at the same time at runtime")
def next(self): def next(self):
blocks = [(block, weight) for block, weight, condition in self["blocks"] if eval(condition)] blocks = [(block, weight) for block, weight, condition in self["blocks"] if eval(condition)]
total_weight = sum(weight for _, weight in blocks) total_weight = sum(weight for _, weight in blocks)

View File

@ -2115,7 +2115,7 @@ label gryffindor_match_return:
hoo "Oh, look at the time. I think I better get going--" ("open", "shocked", "shocked", "R") hoo "Oh, look at the time. I think I better get going--" ("open", "shocked", "shocked", "R")
#hooch sprints out the office sound #hooch sprints out the office sound
$ hooch_chibi.hide() chibi hooch hide
play sound "sounds/run_03.ogg" play sound "sounds/run_03.ogg"
pause 1.0 pause 1.0
play sound "sounds/door.ogg" play sound "sounds/door.ogg"

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -16,9 +16,4 @@ init python:
char.set_face(mouth="base", eyes="base", eyebrows="base", pupils="mid", cheeks="none", tears="none") char.set_face(mouth="base", eyes="base", eyebrows="base", pupils="mid", cheeks="none", tears="none")
def chibi_init(): config.start_callbacks.append(wardrobe_init)
# TODO: Perhaps it could be automated?
hooch_chibi.register("stand", 1, (600, 800))
hooch_chibi.register("walk", 8, (600, 800))
config.start_callbacks.extend([wardrobe_init, chibi_init])

View File

@ -1,3 +1,5 @@
define states.dolls = {}
init python: init python:
class Doll(DollMethods): class Doll(DollMethods):
# 0 - 50 = Skin/Body Layers # 0 - 50 = Skin/Body Layers
@ -77,15 +79,11 @@ init python:
self.build_image() self.build_image()
# Add doll name to global doll states store states.dolls[name] = self
try:
renpy.store.states.dolls.add(name)
except AttributeError:
renpy.store.states.dolls = {name}
def generate_hash(self): def generate_hash(self):
clothes_hash = str([x[0]._hash for x in self.states.values() if istype(x[0], (DollCloth, DollClothDynamic, DollMakeup)) and x[2]]) clothes_hash = str([x[0]._hash for x in self.states.values() if istype(x[0], (DollCloth, DollClothDynamic, DollMakeup)) and x[2]])
salt = str( [self.name, self.pose, str(self.body._hash), str(self.face._hash), str(self.cum._hash), clothes_hash] ) salt = str([self.name, self.pose, str(self.body._hash), str(self.face._hash), str(self.cum._hash), clothes_hash])
return hash(salt) return hash(salt)
def show(self, force=False, ignore_skipping=False): def show(self, force=False, ignore_skipping=False):

View File

@ -34,63 +34,6 @@ init python:
gl_FragColor = vec4(mix(gl_FragColor.xyz, gl_FragColor.xyz * ctemp2rgb(ctemp), u_strength), 1.0); gl_FragColor = vec4(mix(gl_FragColor.xyz, gl_FragColor.xyz * ctemp2rgb(ctemp), u_strength), 1.0);
""") """)
renpy.register_shader("pixelatemaskshader", variables="""
uniform sampler2D tex0;
uniform sampler2D tex1;
uniform vec2 res0;
uniform float u_step;
uniform float u_lod_bias;
attribute vec2 a_tex_coord;
varying vec2 v_tex_coord;
""", vertex_600="""
v_tex_coord = a_tex_coord;
""", fragment_functions="""
vec2 CalculateNewUV(vec2 uv, vec2 size, float step) {
float dx = (step / size.x);
float dy = (step / size.y);
return vec2(dx*(floor(uv.x/dx) + 0.5), dy*(floor(uv.y/dy) + 0.5));
}
vec4 PixelateMask(sampler2D source, float alpha, vec2 size, vec2 uv, float step, float lod) {
if (alpha > 0.0) {
vec2 new_uv = CalculateNewUV(uv, size, step);
vec4 old = vec4(texture2D(source, uv, lod).rgb, 1.0);
vec4 new = vec4(texture2D(source, new_uv, lod).rgb, 1.0);
return mix(old, new, alpha);
}
return texture2D(source, uv, lod);
}
""", fragment_600="""
float alpha = texture2D(tex1, v_tex_coord).a;
gl_FragColor = PixelateMask(tex0, alpha, res0, v_tex_coord, u_step, u_lod_bias);
""")
class PixelateMask(renpy.Displayable, NoRollback):
def __init__(self, child, mask, step=1.0, **kwargs):
super().__init__(**kwargs)
self.child = renpy.displayable(child)
self.mask = renpy.displayable(mask)
self.step = step
def render(self, width, height, st, at):
child = renpy.display.render.render(self.child, width, height, st, at)
mask = renpy.display.render.render(self.mask, width, height, st, at)
rv = renpy.display.render.Render(width, height)
if renpy.display.render.models:
rv.mesh = True
rv.add_shader("pixelatemaskshader")
rv.add_uniform("u_step", self.step)
rv.blit(child, (0, 0))
rv.blit(mask, (0, 0))
renpy.redraw(self, 0)
return rv
transform color_temperature(factor=1.0, strength=1.0): transform color_temperature(factor=1.0, strength=1.0):
mesh True mesh True
shader "color_temperature_shader" shader "color_temperature_shader"

View File

@ -23,7 +23,7 @@ init -1 python:
def get_character_object(key): def get_character_object(key):
__check_exists(key) __check_exists(key)
return getattr(store, key) return states.dolls[key]
def get_character_outfit(key, typ="default"): def get_character_outfit(key, typ="default"):
__check_exists(key) __check_exists(key)