Implement CDS

* Implemented chibi related CDS
* Implemented chibi image prediction
This commit is contained in:
LoafyLemon 2023-02-21 02:53:16 +00:00
parent 30ef2ce652
commit 25a3a7c015
2 changed files with 55 additions and 9 deletions

45
game/scripts/cds.rpy Normal file
View File

@ -0,0 +1,45 @@
python early:
def parse_chibi(lexer):
who = lexer.simple_expression()
action = lexer.simple_expression()
return (who, action)
def execute_chibi(parsed_object):
print(f"{parsed_object}")
who, action = parsed_object
func = eval(f"{who[:3]}_chibi_new.{action}")
print(f"Execution: {who} {action}")
def lint_chibi(parsed_object):
who, action = parsed_object
try:
chibi = eval(f"{who[:3]}_chibi_new") # TODO: Update naming once testing is done
except Exception:
renpy.error(f"Character chibi not defined: {who}")
def predict_chibi(parsed_object):
who, action = parsed_object
chibi = eval(f"{who[:3]}_chibi_new")
doll = eval(f"{who}")
layers = (
l[0] for pose, i in chibi.poses.items()
for j in range(i)
for k in doll.states.values() if k[0] and k[2]
for l in k[0].get_layers(k[0]._hash, subpath=posixpath.join("chibi", pose, str(j))).values()
)
return layers
renpy.register_statement(
name="chibi",
parse=parse_chibi,
execute=execute_chibi,
lint=lint_chibi,
predict=predict_chibi,
)
define config.debug_prediction = True

View File

@ -6,6 +6,7 @@ init 5 python:
super(DollChibi, self).__init__(**properties)
self.name = name
self.tag = name + "_chibi"
self.pose = pose
self.idle = "stand"
self.layer = layer
@ -298,7 +299,7 @@ init 5 python:
# TODO: Using zorders is suboptimal and expensive, using 3D staging would be preferable.
zpos = self.zorder + (1.0 / (self.pos[1] / config.screen_height))
renpy.change_zorder(self.layer, self.name, zpos)
renpy.change_zorder(self.layer, self.tag, zpos)
return 0
def show(self, transform, at_list, layer, zorder):
@ -308,11 +309,11 @@ init 5 python:
image = At(self, transform) # IMPORTANT: Enable perspective and gl_depth for 3D staging
if not renpy.is_init_phase():
renpy.show(name=self.name, what=image, at_list=at_list, layer=layer, zorder=zorder)
renpy.show(name=self.tag, what=image, at_list=at_list, layer=layer, zorder=zorder)
def hide(self):
if not renpy.is_init_phase():
renpy.hide(name=self.name)
renpy.hide(name=self.tag)
def update(self):
self.build_animation()
@ -329,22 +330,22 @@ default cho_chibi_new = DollChibi(name="cho", doll=cho)
default ton_chibi_new = DollChibi(name="tonks", doll=tonks)
label chibitest:
$ ton_chibi_new.register_pose("stand", 1)
$ ton_chibi_new.register_pose("walk", 8)
chibi tonks register_pose ("stand", 1)
chibi tonks register_pose ("walk", 8)
"Rollback block"
$ renpy.block_rollback()
"repeat 3"
$ ton_chibi_new.move(path=[(500, 421), (650, 521), (800, 421)], repeat=3)
chibi tonks move (path=[(500, 421), (650, 521), (800, 421)], repeat=3)
"loop"
$ ton_chibi_new.move(path=[(500, 421), (650, 521), (800, 421)], loop=True)
chibi tonks move (path=[(500, 421), (650, 521), (800, 421)], loop=True)
"doll synchronisation"
$ ton_chibi_new.move(path=[(500, 421), (650, 521), (800, 421)], loop=True, pause=False)
chibi tonks move (path=[(500, 421), (650, 521), (800, 421)], loop=True, pause=False)
ton "Default" ("base", "base", "base", "mid", hair="default")
ton "Angry" ("angry", "narrow", "angry", "mid", hair="angry")
ton "Scared" ("scream", "wide", "worried", "mid", hair="scared")
"End"
$ ton_chibi_new.hide()
hide tonks_chibi
hide tonks_main
jump main_room_menu