Correct olc update options, add local display to menudebug command

This commit is contained in:
Griatch 2018-08-25 23:46:05 +02:00
parent a51b711831
commit f1f70730fb
2 changed files with 28 additions and 13 deletions

View file

@ -2027,14 +2027,14 @@ def node_apply_diff(caller, **kwargs):
sep=" |r->|n ", new='', change=inst))
options.append(_keep_option(key, prototype,
base_obj, obj_prototype, diff, update_objects, back_node))
options.extend(
[{"key": ("|wu|Wpdate {} objects".format(len(update_objects)), "update", "u"),
"desc": "Update {} objects".format(len(update_objects)),
"goto": (_apply_diff, {"prototype": prototype, "objects": update_objects,
"back_node": back_node, "diff": diff, "base_obj": base_obj})},
{"key": ("|wr|Weset changes", "reset", "r"),
"goto": ("node_apply_diff", {"prototype": prototype, "back_node": back_node,
"objects": update_objects})}])
options.extend(
[{"key": ("|wu|Wpdate {} objects".format(len(update_objects)), "update", "u"),
"desc": "Update {} objects".format(len(update_objects)),
"goto": (_apply_diff, {"prototype": prototype, "objects": update_objects,
"back_node": back_node, "diff": diff, "base_obj": base_obj})},
{"key": ("|wr|Weset changes", "reset", "r"),
"goto": ("node_apply_diff", {"prototype": prototype, "back_node": back_node,
"objects": update_objects})}])
if ichanges < 1:
text = ["Analyzed a random sample object (out of {}) - "

View file

@ -866,19 +866,34 @@ class EvMenu(object):
props = {prop: value for prop, value in all_props if prop not in all_methods and
prop not in all_builtins and not prop.endswith("__")}
local = {key: var for key, var in locals().items()
if key not in all_props and not key.endswith("__")}
if arg:
if arg in props:
debugtxt = " |y* {}:|n\n{}".format(arg, props[arg])
elif arg in local:
debugtxt = " |y* {}:|n\n{}".format(arg, local[arg])
elif arg == 'full':
debugtxt = ("|yMENU DEBUG full ... |n\n" + "\n".join(props) +
debugtxt = ("|yMENU DEBUG full ... |n\n" + "\n".join(
"|y *|n {}: {}".format(key, val)
for key, val in sorted(props.items())) +
"\n |yLOCAL VARS:|n\n" + "\n".join(
"|y *|n {}: {}".format(key, val)
for key, val in sorted(local.items())) +
"\n |y... END MENU DEBUG|n")
else:
debugtxt = "|yUsage: menudebug full|<name of property>|n"
else:
debugtxt = "|yMENU DEBUG properties:|n\n" + "\n".join("|y *|n {}: {}".format(
prop, crop(to_str(value, force_string=True), width=50))
for prop, value in sorted(props.items()))
debugtxt += "\n|y... END MENU DEBUG (use menudebug <name> for full value)|n"
debugtxt = ("|yMENU DEBUG properties ... |n\n" + "\n".join(
"|y *|n {}: {}".format(
key, crop(to_str(val, force_string=True), width=50))
for key, val in sorted(props.items())) +
"\n |yLOCAL VARS:|n\n" + "\n".join(
"|y *|n {}: {}".format(
key, crop(to_str(val, force_string=True), width=50))
for key, val in sorted(local.items())) +
"\n |y... END MENU DEBUG|n")
self.caller.msg(debugtxt)
def parse_input(self, raw_string):