forked from Mirrors/openclonk
EditorBase: Publish some properties
parent
d2fd1d740e
commit
d3ede324be
|
@ -11,24 +11,26 @@ local EditorProp_PlayerColor = { Type = "color", AsyncGet = "GetColor", Set = "S
|
|||
local EditorProp_Name = { Type = "string", AsyncGet = "GetName", Set = "SetName" };
|
||||
local Plane = 1;
|
||||
|
||||
local CountedID, IDList, AnyDef, IDSet, PlayerNumber, TeamID, PlayerMask;
|
||||
|
||||
local DefinitionPriority=100; // Call this definition early to allow EditorProp initialization
|
||||
func Definition(def)
|
||||
{
|
||||
// Property delegate types
|
||||
def.CountedID = { Type = "proplist", Display = "{{count}}x{{id}}", DefaultValue = { count=1, id=nil }, Elements = {
|
||||
CountedID = { Type = "proplist", Display = "{{count}}x{{id}}", DefaultValue = { count=1, id=nil }, Elements = {
|
||||
Name = "$IDListEntry$",
|
||||
EditorProp_count = { Type = "int", Min = 1 },
|
||||
EditorProp_id = { Type = "def" } } };
|
||||
def.IDList = { Name = "ID list", Type = "array", Display = 3, Elements = def.CountedID };
|
||||
def.AnyDef = { Type = "def" };
|
||||
def.IDSet = { Name = "ID set", Type = "array", Display = 5, Elements = def.AnyDef };
|
||||
def.PlayerNumber = { Type="int" };
|
||||
def.TeamID = { Type="int" };
|
||||
def.PlayerMask = { Name="$PlayerMask$", Type="enum", OptionKey="Option", Options = [
|
||||
IDList = { Name = "ID list", Type = "array", Display = 3, Elements = CountedID };
|
||||
AnyDef = { Type = "def" };
|
||||
IDSet = { Name = "ID set", Type = "array", Display = 5, Elements = AnyDef };
|
||||
PlayerNumber = { Type="int" };
|
||||
TeamID = { Type="int" };
|
||||
PlayerMask = { Name="$PlayerMask$", Type="enum", OptionKey="Option", Options = [
|
||||
{ Name="$None$" },
|
||||
{ Name="$All$", Value={ Option="all" } },
|
||||
{ Name="$Specific$", Value={ Option="number" }, ValueKey="Data", Delegate=def.PlayerNumber },
|
||||
{ Name="$Team$", Value={ Option="team" }, ValueKey="Data", Delegate=def.TeamID },
|
||||
{ Name="$Specific$", Value={ Option="number" }, ValueKey="Data", Delegate=PlayerNumber },
|
||||
{ Name="$Team$", Value={ Option="team" }, ValueKey="Data", Delegate=TeamID },
|
||||
] };
|
||||
return true;
|
||||
}
|
||||
|
@ -45,6 +47,19 @@ public func EvaluatePlayerMask(proplist mask, int player)
|
|||
return false;
|
||||
}
|
||||
|
||||
// Evaluate player mask to list of players
|
||||
public func EvaluatePlayers(proplist mask)
|
||||
{
|
||||
if (!mask) return [];
|
||||
var result = [], n=0;
|
||||
for (var i = 0; i < GetPlayerCount(C4PT_User); ++i)
|
||||
{
|
||||
var plr = GetPlayerByIndex(i, C4PT_User);
|
||||
if (EvaluatePlayerMask(mask, plr)) result[n++] = plr;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// Return an ID-List EditorProp with only IDs available that meet the condition
|
||||
public func GetConditionalIDList(string condition, string name, proplist default_id)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue