Qt Editor: Move EditorActions from EditorAction_* to a proplist EditorAction.*

qteditor
Sven Eberhardt 2016-07-14 00:17:53 -04:00
parent 656aa303f9
commit d605bab0be
5 changed files with 15 additions and 8 deletions

View File

@ -670,7 +670,8 @@ public func Definition(def)
} } );
UserAction->AddEvaluator("Object", nil, "$NPC$", "npc", [def, def.EvalObj_NPC]);
// Clonks can create a dialogue
Clonk.EditorAction_Dialogue = { Name="$Dialogue$", Command="SetDialogue(GetName(), true, true)", Select=true };
if (!Clonk.EditorActions) Clonk.EditorActions = {};
Clonk.EditorActions.Dialogue = { Name="$Dialogue$", Command="SetDialogue(GetName(), true, true)", Select=true };
// Dialogue EditorProps
if (!def.EditorProps) def.EditorProps = {};
def.EditorProps.user_dialogue = { Name="$Dialogue$", Type="enum", OptionKey="Option", Options = [ { Name="$NoDialogue$" }, new UserAction.EvaluatorDefs.sequence { Group=nil } ] };

View File

@ -178,8 +178,11 @@ local ActMap = {
},
};
local EditorActions = {
OpenDoor = { Name = "$DoorUp$", Command = "OpenDoor()" },
CloseDoor = { Name = "$DoorDown$", Command = "CloseDoor()" }
};
local Name = "$Name$";
local EditorAction_OpenDoor = { Name="$DoorUp$", Command="OpenDoor()" };
local EditorAction_CloseDoor = { Name="$DoorDown$", Command="CloseDoor()" };
local Plane = 200;
local Components = {Rock = 6};

View File

@ -942,16 +942,17 @@ void C4ConsoleGUIState::UpdateActionObject(C4Object *new_action_object)
ui.objectActionPanel->itemAt(i)->widget()->deleteLater();
}
// Create new buttons
// Actions are defined as locals prefixed EditorAction_ containing proplists
// Actions are defined as properties in a local proplist called EditorActions
if (!new_action_object) return;
const char *editor_action_prefix = "EditorAction_";
auto new_properties = new_action_object->GetSortedProperties(editor_action_prefix, &::ScriptEngine);
C4PropList *editor_actions_list = new_action_object->GetPropertyPropList(P_EditorActions);
if (!editor_actions_list) return;
auto new_properties = editor_actions_list->GetSortedProperties(nullptr);
int row = 0, column = 0;
for (C4String *action_def_id : new_properties)
{
// Get action definition proplist
C4Value action_def_val;
if (!new_action_object->GetPropertyByS(action_def_id, &action_def_val))
if (!editor_actions_list->GetPropertyByS(action_def_id, &action_def_val))
{
// property disappeared (cannot happen)
continue;
@ -967,7 +968,7 @@ void C4ConsoleGUIState::UpdateActionObject(C4Object *new_action_object)
if (!action_name)
{
// Fallback to identifier for unnamed actions
action_name = ::Strings.RegString(action_def_id->GetCStr() + strlen(editor_action_prefix));
action_name = action_def_id;
}
// Script command to execute
C4RefCntPointer<C4String> script_command = action_def->GetPropertyStr(P_Command);

View File

@ -273,6 +273,7 @@ C4StringTable::C4StringTable()
P[P_EditOnSelection] = "EditOnSelection";
P[P_EditorProps] = "EditorProps";
P[P_DefaultEditorProp] = "DefaultEditorProp";
P[P_EditorActions] = "EditorActions";
P[P_CopyDefault] = "CopyDefault";
P[P_Display] = "Display";
P[P_DefaultValue] = "DefaultValue";

View File

@ -497,6 +497,7 @@ enum C4PropertyName
P_EditOnSelection,
P_EditorProps,
P_DefaultEditorProp,
P_EditorActions,
P_CopyDefault,
P_Display,
P_DefaultValue,