Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
is_unfolded[iden], visible = imgui.collapsing_header("Show List"+iden, True)
if is_unfolded[iden]:
new_md = copy.copy(metadata)
if new_md:
new_md["is_list"] = False
changes = {}
changed = False
for i, (lab, val) in enumerate(v):
change = draw_eav_value(DB, ent, att, val, new_md)
if change:
changed = True
changes[i] = (lab, change[2])
if changed:
return (ent, att, [changes[i] if i in changes else (v[i][0], v[i][1]) for i in range(0,len(v))])
elif (metadata and metadata["type"] == 0) or (not metadata and v in DB.entities):
changed, new_entity = imgui.combo(
iden, DB.entities.index(v), DB.entities
)
if changed:
return (ent, att, DB.entities[new_entity])
elif (metadata and metadata["type"] == 2) or (not metadata and isinstance(v, int)):
changed, new_value = imgui.input_int(iden, v)
if changed:
return (ent, att, new_value)
elif (metadata and metadata["type"] == 3) or (not metadata and isinstance(v, float)):
changed, new_value = imgui.input_float(iden, v)
if changed:
return (ent, att, new_value)
elif (metadata and metadata["type"] == 1) or (not metadata and isinstance(v, str)):
changed, new_value = imgui.input_text(
iden,
v,
def draw_imgui_query_box(DB, monospace_font):
global query_language, query_value, query_result, query_binds, data_entity, data_attr, data_type, data_value, query_error, new_query_result
imgui.begin("Query...", False)
imgui.push_item_width(100)
clicked, query_language = imgui.combo(
"##query-language", query_language, ["S-Expr", "NL"]
)
imgui.pop_item_width()
imgui.same_line()
if query_language == 0:
imgui.push_font(monospace_font)
changed, query_value = imgui.input_text(
'##query-box',
query_value,
256,
imgui.INPUT_TEXT_ENTER_RETURNS_TRUE
)
if query_language == 0:
imgui.pop_font()
if query_binds == {}:
def draw_data_popup(DB, constant=False):
global data_entity, data_attr, data_type, data_value, query_error
if imgui.begin_popup("new-data"):
if not constant:
changed, data_entity = imgui.combo(
"Entity##data-entity", data_entity, DB.entities
)
changed, data_attr = imgui.input_text(
'Attribute##data-attr',
data_attr,
256,
)
data_attr = data_attr.lower().replace(" ", "_").replace("-", "_")
changed, data_type = imgui.combo(
"Value Type##data-type", data_type, DB.type_name
)
if changed and (data_type == 2 or data_type == 3 or data_type == 0):
data_value = 0
elif changed and data_type == 1:
data_value = ""
if data_type == 0:
)
changed, data_attr = imgui.input_text(
'Attribute##data-attr',
data_attr,
256,
)
data_attr = data_attr.lower().replace(" ", "_").replace("-", "_")
changed, data_type = imgui.combo(
"Value Type##data-type", data_type, DB.type_name
)
if changed and (data_type == 2 or data_type == 3 or data_type == 0):
data_value = 0
elif changed and data_type == 1:
data_value = ""
if data_type == 0:
changed, data_value = imgui.combo(
"Value##data-value-entity",
data_value,
DB.entities
)
elif data_type == 1:
changed, data_value = imgui.input_text(
'Value##data-value-string',
data_value,
256,
imgui.INPUT_TEXT_ENTER_RETURNS_TRUE
)
elif data_type == 2:
changed, data_value = imgui.input_int(
'Value##data-value-int',
data_value
)
def draw_data_popup(DB, constant=False):
global data_entity, data_attr, data_type, data_value, query_error
if imgui.begin_popup("new-data"):
if not constant:
changed, data_entity = imgui.combo(
"Entity##data-entity", data_entity, DB.entities
)
changed, data_attr = imgui.input_text(
'Attribute##data-attr',
data_attr,
256,
)
data_attr = data_attr.lower().replace(" ", "_").replace("-", "_")
changed, data_type = imgui.combo(
"Value Type##data-type", data_type, DB.type_name
)
if changed and (data_type == 2 or data_type == 3 or data_type == 0):
data_value = 0
elif changed and data_type == 1:
data_value = ""
if data_type == 0:
changed, data_value = imgui.combo(
"Value##data-value-entity",
data_value,
DB.entities
)
elif data_type == 1:
changed, data_value = imgui.input_text(
'Value##data-value-string',
data_value,
rule_args[i] = rule_args[i].title().replace(" ", "")
arg_changed = changed or arg_changed
imgui.same_line()
imgui.pop_font()
if imgui.button("+##new" + name):
rule_args.append("NewArgument")
arg_changed = True
imgui.same_line()
if imgui.button("-##del" + name):
if len(rule_args) != 0:
del rule_args[-1]
arg_changed = True
imgui.same_line()
clicked, rule_lang = imgui.combo(
"##lang-" + name,
rule_lang,
["S-Expr", "NL"]
)
imgui.pop_item_width()
if rule_lang == 0:
imgui.push_font(monospaced_font)
changed, rule_text = imgui.input_text_multiline(
'##body-' + name,
rule_text,
2056,
500,
300,
)
if rule_lang == 0:
imgui.pop_font()
_, opened = imgui.begin("Database Attribute Editor", True)
SHOW_VARS['METADATA'] = SHOW_VARS['METADATA'] and opened
for attr, metadata in DB.attribute_metadata.items():
attr_expanded[attr], _ = imgui.collapsing_header(attr, True)
if not attr_expanded[attr]:
continue
imgui.indent()
changed, metadata["description"] = imgui.input_text_multiline(
'Description##desc-' + attr,
metadata["description"],
2056,
500,
300,
)
clicked, metadata["type"] = imgui.combo(
"Attribute Type##type-"+attr,
metadata["type"],
DB.type_name
)
clicked, metadata["is_list"] = imgui.checkbox("Is List", bool(metadata.get("is_list")))
if metadata["type"] == 2:
imgui.text("Leave -1s to allow an arbitrary string.")
changed, metadata["num_limits"] = imgui.input_int2('Int Limits##'+attr, *metadata["num_limits"])
elif metadata["type"] == 3:
imgui.text("Leave -1s to allow an arbitrary string.")
changed, metadata["num_limits"] = imgui.input_float2('Float Limits##'+attr, *metadata["num_limits"])
elif metadata["type"] == 1:
imgui.text("Leave blank to allow an arbitrary string.")
changed, strings = imgui.input_text(