Skip to content

Commit

Permalink
allow user to add properties into ActionEditor as desired
Browse files Browse the repository at this point in the history
  • Loading branch information
kyouryuukunn committed Apr 2, 2022
1 parent 2fee633 commit 1e14a21
Show file tree
Hide file tree
Showing 4 changed files with 158 additions and 36 deletions.
61 changes: 45 additions & 16 deletions ActionEditor.rpy
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ init -1598 python in _viewers:
if time >= scene_start and time < checkpoint:
start = cs[i-1]
goal = cs[i]
if p != "child":
if p != "child" :
if checkpoint != pre_checkpoint:
if goal[2].startswith("warper_generator"):
warper = renpy.python.py_eval(goal[2])
Expand All @@ -669,7 +669,7 @@ init -1598 python in _viewers:
else:
g = 1.
default = get_default(p, camera)
if goal[0] is not None:
if goal[0] is not None or p in boolean_props + any_props:
if start[0] is None:
start_v = default
else:
Expand All @@ -681,6 +681,8 @@ init -1598 python in _viewers:
knots = [start_v] + knots + [goal[0]]
if knots:
v = renpy.atl.interpolate_spline(g, knots)
elif p in boolean_props + any_props:
v = renpy.atl.interpolate(g, start[0], goal[0], renpy.atl.PROPERTIES[p])
else:
v = g*(goal[0]-start_v)+start_v
if isinstance(goal[0], int) and p not in force_float:
Expand Down Expand Up @@ -928,11 +930,11 @@ init -1598 python in _viewers:
state = camera_state_org[scene_num]
if key in all_keyframes[scene_num]:
return get_value(key, scene_num=scene_num)
elif prop in state and state[prop] is not None:
if prop == "child":
return state[prop][0], None
else:
return state[prop]
elif (prop in state and state[prop] is not None) or (prop in boolean_props + any_props):
if prop == "child":
return state[prop][0], None
else:
return state[prop]
elif default:
return get_default(prop, not isinstance(key, tuple))
else:
Expand Down Expand Up @@ -1147,12 +1149,29 @@ init -1598 python in _viewers:
return


def edit_any(key, time=None):
if time is None:
time = current_time
value = get_value(key, time)
if isinstance(value, str):
value = "'" + value + "'"
value = renpy.invoke_in_new_context(renpy.call_screen, "_input_screen", default=value)
if value:
try:
value = renpy.python.py_eval(value)
except:
renpy.notify(_("Please type a valid data"))
return
set_keyframe(key, value, time=time)
change_time(current_time)


def toggle_boolean_property(key):
if isinstance(key, tuple):
tag, layer, prop = key
value_org = get_image_state(layer)[tag][prop]
else:
value_org = camera_state_org[key]
value_org = camera_state_org[current_scene][key]
value = get_value(key, scene_keyframes[current_scene][1], True)
#assume default is False
if value == value_org or (not value and not value_org):
Expand Down Expand Up @@ -1254,7 +1273,7 @@ init -1598 python in _viewers:
else:
g = 1.
default_vault = get_default(prop, not isinstance(key, tuple))
if goal[0] is not None:
if goal[0] is not None or prop in boolean_props + any_props:
if start[0] is None:
start_v = default_vault
else:
Expand All @@ -1266,6 +1285,8 @@ init -1598 python in _viewers:
knots = [start_v] + knots + [goal[0]]
if knots:
v = renpy.atl.interpolate_spline(g, knots)
elif prop in boolean_props + any_props:
v = renpy.atl.interpolate(g, start[0], goal[0], renpy.atl.PROPERTIES[prop])
else:
v = g*(goal[0]-start_v)+start_v
if isinstance(goal[0], int) and prop not in force_float:
Expand Down Expand Up @@ -2035,9 +2056,13 @@ show %s""" % child
delay = get_transition_delay(tran)
if delay + scene_start > animation_time:
animation_time = delay + scene_start
for cs in all_keyframes[s].values():
for key, cs in all_keyframes[s].items():
if isinstance(key, tuple):
prop = key[2]
else:
prop = key
for (v, t, w) in cs:
if isinstance(v, tuple):
if prop == "child":
delay = get_transition_delay(v[1])
t += delay
if t > animation_time:
Expand All @@ -2063,9 +2088,13 @@ show %s""" % child
(tran, scene_start, _) = scene_keyframes[scene_num]
delay = get_transition_delay(tran)
animation_time = delay + scene_start
for cs in all_keyframes[scene_num].values():
for key, cs in all_keyframes[scene_num].items():
if isinstance(key, tuple):
prop = key[2]
else:
prop = key
for (v, t, w) in cs:
if isinstance(v, tuple):
if prop == "child":
delay = get_transition_delay(v[1])
t += delay
if t > animation_time:
Expand Down Expand Up @@ -2121,13 +2150,13 @@ show %s""" % child


def sort_props(keyframes):
return [(p, keyframes[p]) for p in sort_ref_list if p in keyframes]
return [(p, keyframes[p]) for p in sort_order_list if p in keyframes]


def put_prop_togetter(keyframes, layer=None, tag=None):
#時間軸とx, yを纏める キーフレームが一つのみのものは含めない
sorted_list = []
for p in sort_ref_list:
for p in sort_order_list:
if p in keyframes:
sorted_list.append((p, keyframes[p]))
result = []
Expand Down Expand Up @@ -2163,7 +2192,7 @@ show %s""" % child
if persistent._one_line_one_prop:
result_dict = {k:v for same_time_set in result for (k, v) in same_time_set}
result.clear()
for p in sort_ref_list:
for p in sort_order_list:
if p in result_dict:
result.append([(p, result_dict[p])])
return result
Expand Down
12 changes: 10 additions & 2 deletions ActionEditor_config.rpy
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,16 @@ init -1600 python in _viewers:
#crop doesn't work when perspective True and rotate change the pos of image when perspective is not True
not_used_by_default = ("rotate", "cropX", "cropY", "cropW", "cropH", "xpan", "ypan")
boolean_props = ["zzoom"]
any_props = []
exclusive = (
({"xpos", "ypos"}, {"xalignaround", "yalignaround", "radius", "angle"}),
({"xtile", "ytile"}, {"xpan", "ypan"}),
)
xygroup = {"pos": ("xpos", "ypos"), "anchor": ("xanchor", "yanchor"), "offset": ("xoffset", "yoffset")}

sort_ref_list = (
#The order of properties in clipboard data.
#この順番でクリップボードデータが出力されます
sort_order_list = (
"pos",
"anchor",
"offset",
Expand Down Expand Up @@ -133,6 +136,9 @@ init -1600 python in _viewers:
)

init 1600 python in _viewers:
#The properties used in image tag tab
#画像タブに表示されるプロパティー
#(property name, default value)
transform_props = (
("child", (None, None)),
("xpos", 0),
Expand Down Expand Up @@ -179,7 +185,9 @@ init 1600 python in _viewers:
("ytile", 1),
)

#perspetve competes crop
#The properties used in camera tab
#カメラタブに表示されるプロパティー
#(property name, default value)
camera_props = (
("xpos", 0.),
("ypos", 0.),
Expand Down
Loading

0 comments on commit 1e14a21

Please sign in to comment.