Addon: Added args for custom commands

This commit is contained in:
Artem30801
2020-08-17 15:58:53 +03:00
parent 76cdf9d227
commit 053095415a
3 changed files with 13 additions and 4 deletions

View File

@@ -121,6 +121,7 @@ class CustomDroneProperties(PropertyGroup):
default=False,
)
args: StringProperty(
name="Command arguments",
default="{}",
)

View File

@@ -21,7 +21,7 @@ class DroneCustomPropsActions(Operator):
drone = context.object.drone
item = drone.custom_props.add()
item.name = f"empty_action {len(drone.custom_props)}"
item.name = f"action_{len(drone.custom_props)}"
drone.active_index = len(drone.custom_props) - 1
self.report({'INFO'}, f"Item '{item.name}' added to {context.object.name}")

View File

@@ -6,7 +6,7 @@ class CustomDroneItems(UIList):
split = layout.split(factor=0.66, align=True)
split.prop(item, "name", text="", emboss=False)
row = split.row(align=True)
row.label(text="Active: ")
row.label(text="Active ")
checkbox = "CHECKBOX_HLT" if item.active else "CHECKBOX_DEHLT"
row.prop(item, "active", text="", emboss=False, icon=checkbox)
@@ -27,9 +27,9 @@ class DronePanel(Panel):
layout.use_property_split = True
layout.use_property_decorate = True
layout.enabled = context.object.drone.is_drone
layout.enabled = drone.is_drone
layout.prop(context.object.drone, "armed")
layout.prop(drone, "armed")
items = len(drone.custom_props)
rows = 3
@@ -52,3 +52,11 @@ class DronePanel(Panel):
sub.operator("clever_show.list_action", icon='TRIA_DOWN', text="").action = 'DOWN'
sub.enabled = items > 1
try:
item = drone.custom_props[drone.active_index]
except IndexError:
return
layout.prop(item, "args")