Skip to content

Commit

Permalink
Editor: support generating parameter list for object interaction events
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-mogilko committed Jul 21, 2023
1 parent 225e210 commit 39494ff
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 10 deletions.
3 changes: 2 additions & 1 deletion Editor/AGS.Types/Character.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ static Character()
"$$02 character","$$03 character","Use inventory on character",
"Any click on character", "$$05 character","$$08 character",
"$$09 character"},
new string[] { "Look", "Interact", "Talk", "UseInv", "AnyClick", "PickUp", "Mode8", "Mode9" });
new string[] { "Look", "Interact", "Talk", "UseInv", "AnyClick", "PickUp", "Mode8", "Mode9" },
"Character *c, CursorMode mode");
}

public Character()
Expand Down
18 changes: 17 additions & 1 deletion Editor/AGS.Types/InteractionSchema.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,22 @@ public class InteractionSchema
{
private string[] _eventNames;
private string[] _functionSuffixes;
private string[] _functionParameterLists;

public InteractionSchema(string[] eventNames, string[] functionSuffixes)
public InteractionSchema(string[] eventNames, string[] functionSuffixes, string functionParameterList)
{
_eventNames = eventNames;
_functionSuffixes = functionSuffixes;
_functionParameterLists = new string[eventNames.Length];
for (int i = 0; i < eventNames.Length; ++i)
_functionParameterLists[i] = functionParameterList;
}

public InteractionSchema(string[] eventNames, string[] functionSuffixes, string[] functionParameterLists)
{
_eventNames = eventNames;
_functionSuffixes = functionSuffixes;
_functionParameterLists = functionParameterLists;
}

public string[] EventNames
Expand All @@ -24,5 +35,10 @@ public string[] FunctionSuffixes
{
get { return _functionSuffixes; }
}

public string[] FunctionParameterLists
{
get { return _functionParameterLists; }
}
}
}
5 changes: 5 additions & 0 deletions Editor/AGS.Types/Interactions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ public string[] FunctionSuffixes
get { return _schema.FunctionSuffixes; }
}

public string[] FunctionParameterLists
{
get { return _schema.FunctionParameterLists; }
}

public string[] DisplayNames
{
get { return _schema.EventNames; }
Expand Down
3 changes: 2 additions & 1 deletion Editor/AGS.Types/InventoryItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ static InventoryItem()
_interactionSchema = new InteractionSchema(new string[] { "$$01 inventory item",
"$$02 inventory item", "$$03 inventory item", "Use inventory on this item",
"Other click on inventory item" },
new string[] { "Look", "Interact", "Talk", "UseInv", "OtherClick" });
new string[] { "Look", "Interact", "Talk", "UseInv", "OtherClick" },
"InventoryItem *i, CursorMode mode");
}

public InventoryItem()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ public class InteractionPropertyDescriptor : PropertyDescriptor
private Type _componentType;
private int _eventIndex;

public InteractionPropertyDescriptor(object component, int eventIndex, string eventName, string displayName)
public InteractionPropertyDescriptor(object component, int eventIndex, string eventName, string displayName,
string parameterList)
:
base(eventName, new Attribute[]{new DisplayNameAttribute(displayName),
new EditorAttribute(typeof(ScriptFunctionUIEditor), typeof(System.Drawing.Design.UITypeEditor)),
new CategoryAttribute("Events"),
new DefaultValueAttribute(string.Empty),
new ScriptFunctionParametersAttribute(string.Empty)})
new ScriptFunctionParametersAttribute(parameterList)})
{
_componentType = component.GetType();
_eventIndex = eventIndex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContex
if (eventName.IndexOf("$$") < 0)
{
// Only add the event if the cursor mode exists
propList.Add(new InteractionPropertyDescriptor(component, i, interactions.FunctionSuffixes[i], eventName));
propList.Add(new InteractionPropertyDescriptor(component, i,
interactions.FunctionSuffixes[i], eventName, interactions.FunctionParameterLists[i]));
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion Editor/AGS.Types/Room.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ static Room()
"Leaves room after fade-out"
},
new string[] { "LeaveLeft", "LeaveRight", "LeaveBottom", "LeaveTop",
"FirstLoad", EVENT_SUFFIX_ROOM_LOAD, "RepExec", "AfterFadeIn", "Leave", "Unload" });
"FirstLoad", EVENT_SUFFIX_ROOM_LOAD, "RepExec", "AfterFadeIn", "Leave", "Unload" },
"");
}

public Room(int roomNumber) : base(roomNumber)
Expand Down
3 changes: 2 additions & 1 deletion Editor/AGS.Types/RoomHotspot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ static RoomHotspot()
"$$01 hotspot","$$02 hotspot","Use inventory on hotspot",
"$$03 hotspot", "Any click on hotspot","Mouse moves over hotspot",
"$$05 hotspot", "$$08 hotspot", "$$09 hotspot"},
new string[] { "WalkOn", "Look", "Interact", "UseInv", "Talk", "AnyClick", "MouseMove", "PickUp", "Mode8", "Mode9" });
new string[] { "WalkOn", "Look", "Interact", "UseInv", "Talk", "AnyClick", "MouseMove", "PickUp", "Mode8", "Mode9" },
"Hotspot *h, CursorMode mode");
}

public RoomHotspot(IChangeNotification changeNotifier)
Expand Down
3 changes: 2 additions & 1 deletion Editor/AGS.Types/RoomObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ static RoomObject()
"$$02 object", "$$03 object", "Use inventory on object",
"Any click on object",
"$$05 object", "$$08 object", "$$09 object"},
new string[] { "Look", "Interact", "Talk", "UseInv", "AnyClick", "PickUp", "Mode8", "Mode9" });
new string[] { "Look", "Interact", "Talk", "UseInv", "AnyClick", "PickUp", "Mode8", "Mode9" },
"Object *o, CursorMode mode");
}

public RoomObject(IChangeNotification changeNotifier)
Expand Down
3 changes: 2 additions & 1 deletion Editor/AGS.Types/RoomRegion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ static RoomRegion()
"While standing on region",
"Walks onto region",
"Walks off region"},
new string[] { "Standing", "WalksOnto", "WalksOff" });
new string[] { "Standing", "WalksOnto", "WalksOff" },
"Region *r");
}

[Description("The ID number of the region")]
Expand Down

0 comments on commit 39494ff

Please sign in to comment.