|
| 1 | +function GetPluginSettings() |
| 2 | +{ |
| 3 | + return { |
| 4 | + "name": "Random Array2", |
| 5 | + "id": "rA2", |
| 6 | + "version": "1.2", |
| 7 | + "description": "Give you an array with random numbers.", |
| 8 | + "author": "Joe7", |
| 9 | + "help url": "http://dev.liebhard.net/", |
| 10 | + "category": "Data & Storage", |
| 11 | + "type": "object", // not in layout |
| 12 | + "rotatable": false, |
| 13 | + "flags": 0 |
| 14 | + }; |
| 15 | +}; |
| 16 | + |
| 17 | +////////////////////////////////////////////////////////////// |
| 18 | +// Conditions |
| 19 | +AddNumberParam("Index", "Index of the array value to compare.", "0"); |
| 20 | +AddCmpParam("Comparison", "How to compare the value."); |
| 21 | +AddAnyTypeParam("Value", "The value to compare the array value to.", "0"); |
| 22 | +AddCondition(0, 0, "Compare at ", "Array", "Value at <b>{0}</b> {1} <b>{2}</b>", "Compare the value at an specified position in the array.", "CompareX"); |
| 23 | + |
| 24 | + |
| 25 | + |
| 26 | +////////////////////////////////////////////////////////////// |
| 27 | +// Actions |
| 28 | +AddAction(0, 0, "New scramble", "Array", "New scramble", "Get new random Numbers.", "NewScramble"); |
| 29 | +AddNumberParam("Size", "Set a new size for the array.", "10"); |
| 30 | +AddAction(1, 0, "New size", "Array", "Set size to <b>{0}</b>.", "New size", "NewSize"); |
| 31 | +AddNumberParam("Start", "Set a new Start for the array.", "1"); |
| 32 | +AddAction(2, 0, "New Start", "Array", "Set Start to <b>{0}</b>.", "New Start", "NewStart"); |
| 33 | + |
| 34 | + |
| 35 | +////////////////////////////////////////////////////////////// |
| 36 | +// Expressions |
| 37 | +AddNumberParam("Index", "The index of the array value to get.", "0"); |
| 38 | +AddExpression(0, ef_return_number, "Get value at", "Array", "At", "Get a value at a certain position from the array."); |
| 39 | + |
| 40 | +AddExpression(1, ef_return_number, "Get width", "Array", "Width", "Get the number of elements of the array."); |
| 41 | + |
| 42 | +AddExpression(2, ef_return_number, "Get start", "Array", "StartValue", "Get the startvalue."); |
| 43 | + |
| 44 | +ACESDone(); |
| 45 | + |
| 46 | +// Property grid properties for this plugin |
| 47 | +var property_list = [ |
| 48 | + new cr.Property(ept_integer, "Width", 10, "Initial number of elements."), |
| 49 | + |
| 50 | + new cr.Property(ept_integer, "StartValue", 1, "Initial start number for random."), |
| 51 | + ]; |
| 52 | + |
| 53 | +// Called by IDE when a new object type is to be created |
| 54 | +function CreateIDEObjectType() |
| 55 | +{ |
| 56 | + return new IDEObjectType(); |
| 57 | +} |
| 58 | + |
| 59 | +// Class representing an object type in the IDE |
| 60 | +function IDEObjectType() |
| 61 | +{ |
| 62 | + assert2(this instanceof arguments.callee, "Constructor called as a function"); |
| 63 | +} |
| 64 | + |
| 65 | +// Called by IDE when a new object instance of this type is to be created |
| 66 | +IDEObjectType.prototype.CreateInstance = function(instance) |
| 67 | +{ |
| 68 | + return new IDEInstance(instance, this); |
| 69 | +} |
| 70 | + |
| 71 | +// Class representing an individual instance of an object in the IDE |
| 72 | +function IDEInstance(instance, type) |
| 73 | +{ |
| 74 | + assert2(this instanceof arguments.callee, "Constructor called as a function"); |
| 75 | + |
| 76 | + // Save the constructor parameters |
| 77 | + this.instance = instance; |
| 78 | + this.type = type; |
| 79 | + |
| 80 | + // Set the default property values from the property table |
| 81 | + this.properties = {}; |
| 82 | + |
| 83 | + for (var i = 0; i < property_list.length; i++) |
| 84 | + this.properties[property_list[i].name] = property_list[i].initial_value; |
| 85 | +} |
| 86 | + |
| 87 | +// Called by the IDE after all initialization on this instance has been completed |
| 88 | +IDEInstance.prototype.OnCreate = function() |
| 89 | +{ |
| 90 | +} |
| 91 | + |
| 92 | +// Called by the IDE after a property has been changed |
| 93 | +IDEInstance.prototype.OnPropertyChanged = function(property_name) |
| 94 | +{ |
| 95 | + if (this.properties["Width"] < 1) |
| 96 | + this.properties["Width"] = 1; |
| 97 | + |
| 98 | + if (this.properties["Height"] < 1) |
| 99 | + this.properties["Height"] = 1; |
| 100 | + |
| 101 | + if (this.properties["Depth"] < 1) |
| 102 | + this.properties["Depth"] = 1; |
| 103 | +} |
| 104 | + |
| 105 | +// Called by the IDE to draw this instance in the editor |
| 106 | +IDEInstance.prototype.Draw = function(renderer) |
| 107 | +{ |
| 108 | +} |
| 109 | + |
| 110 | +// Called by the IDE when the renderer has been released (ie. editor closed) |
| 111 | +// All handles to renderer-created resources (fonts, textures etc) must be dropped. |
| 112 | +// Don't worry about releasing them - the renderer will free them - just null out references. |
| 113 | +IDEInstance.prototype.OnRendererReleased = function() |
| 114 | +{ |
| 115 | +} |
0 commit comments