コード例 #1
0
        // Selected event changes.
        private void listBoxEvents_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listBoxEvents.SelectedIndex >= 0)
            {
                // An event was selected.
                objectEvent = objectEvents[listBoxEvents.SelectedIndex];
                panelEventProperties.Visible = true;

                // Name and description.
                labelEventName.Text        = "Event: " + objectEvent.Name;
                labelEventDescription.Text = objectEvent.Description;

                // Referenced script combo box.
                if (objectEvent.ReferencedScript != null)
                {
                    comboBoxScript.Text = objectEvent.ReferencedScript.Name;
                }
                else
                {
                    comboBoxScript.Text = "";
                }

                // Radio buttons.
                if (objectEvent.RadioButtonIndex == RedioButtonIndex.None)
                {
                    radioButtonEventNone.Checked = true;
                }
                else if (objectEvent.RadioButtonIndex == RedioButtonIndex.CustomCode)
                {
                    radioButtonEventCustomCode.Checked = true;
                }
                else if (objectEvent.RadioButtonIndex == RedioButtonIndex.Script)
                {
                    radioButtonEventScript.Checked = true;
                }
            }
            else
            {
                // No event is selected.
                panelEventProperties.Visible = false;
            }
        }
コード例 #2
0
        public void ApplyChanges()
        {
            EditorControl.NeedsRecompiling = true;

            for (int i = 0; i < objectEvents.Count; i++)
            {
                InternalObjectEvent objEvent = objectEvents[i];

                // Check if we need to generate the custom script.
                if (objEvent.RadioButtonIndex == RedioButtonIndex.CustomCode && !objEvent.CustomScriptExists)
                {
                    EditorControl.GenerateInternalScript(objEvent.CustomScript);
                    Console.WriteLine("Generated internal script with name '" + objEvent.CustomScript.Name + "'");
                }

                // Check if we need to remove the hidden custom script.
                if (objEvent.RadioButtonIndex != RedioButtonIndex.CustomCode && objEvent.CustomScript != null && objEvent.CustomScriptExists)
                {
                    EditorControl.World.RemoveScript(objEvent.CustomScript);
                    Console.WriteLine("Removed internal script with name '" + objEvent.CustomScript.Name + "'");
                }

                // Determine the value for the script property.
                string propValue = "";
                if (objEvent.RadioButtonIndex == RedioButtonIndex.CustomCode)
                {
                    propValue = objEvent.CustomScript.Name;
                }
                else if (objEvent.RadioButtonIndex == RedioButtonIndex.Script)
                {
                    propValue = objEvent.ReferencedScript.Name;
                }

                // Set the property.
                Console.WriteLine("Setting property '" + objEvent.Id + "' to the value '" + propValue + "'");
                objectEditor.PropertyObject.Properties.Set(objEvent.Id, propValue);
            }
        }
コード例 #3
0
        // Selected event changes.
        private void listBoxEvents_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listBoxEvents.SelectedIndex >= 0) {
                // An event was selected.
                objectEvent = objectEvents[listBoxEvents.SelectedIndex];
                panelEventProperties.Visible	= true;

                // Name and description.
                labelEventName.Text			= "Event: " + objectEvent.Name;
                labelEventDescription.Text	= objectEvent.Description;

                // Referenced script combo box.
                if (objectEvent.ReferencedScript != null)
                    comboBoxScript.Text = objectEvent.ReferencedScript.Name;
                else
                    comboBoxScript.Text = "";

                // Radio buttons.
                if (objectEvent.RadioButtonIndex == RedioButtonIndex.None)
                    radioButtonEventNone.Checked = true;
                else if (objectEvent.RadioButtonIndex == RedioButtonIndex.CustomCode)
                    radioButtonEventCustomCode.Checked = true;
                else if (objectEvent.RadioButtonIndex == RedioButtonIndex.Script)
                    radioButtonEventScript.Checked = true;
            }
            else {
                // No event is selected.
                panelEventProperties.Visible = false;
            }
        }
コード例 #4
0
        public void SetupObject(IPropertyObject propertyObject)
        {
            // Create a list of all event properties.
            List<Property> eventProperties = new List<Property>();
            foreach (Property property in propertyObject.Properties.GetAllProperties()) {
                PropertyDocumentation doc = property.GetDocumentation();
                if (doc != null && doc.EditorType == "script")
                    eventProperties.Add(property);
            }

            objectEvents.Clear();
            listBoxEvents.Items.Clear();

            IEventObject eventObject = objectEditor.PropertyObject as IEventObject;

            if (eventObject != null) {
                foreach (KeyValuePair<string, ObjectEvent> entry in eventObject.Events.Events) {
                    listBoxEvents.Items.Add(entry.Value.ReadableName);

                    Property property = objectEditor.PropertyObject.Properties.GetProperty(entry.Value.Name, true);

                    InternalObjectEvent objEvent = new InternalObjectEvent();
                    objEvent.Property			= property;
                    objEvent.Id					= entry.Value.Name;
                    objEvent.Name				= entry.Value.ReadableName;
                    objEvent.Description		= entry.Value.Description;
                    objEvent.CustomScriptExists	= false;
                    objEvent.Event				= entry.Value;

                    if (property != null) {
                        string scriptName = property.StringValue;
                        Script script = null;
                        if (scriptName.Length > 0)
                            script = EditorControl.World.GetScript(scriptName);

                        if (script == null) {
                            objEvent.RadioButtonIndex	= RedioButtonIndex.None;
                            objEvent.CustomScript		= null;
                            objEvent.ReferencedScript	= null;
                        }
                        else if (script.IsHidden) {
                            objEvent.RadioButtonIndex	= RedioButtonIndex.CustomCode;
                            objEvent.CustomScript		= script;
                            objEvent.ReferencedScript	= null;
                            objEvent.CustomScriptExists	= true;
                        }
                        else {
                            objEvent.RadioButtonIndex	= RedioButtonIndex.Script;
                            objEvent.CustomScript		= null;
                            objEvent.ReferencedScript	= script;
                        }
                    }
                    else {
                            objEvent.RadioButtonIndex	= RedioButtonIndex.None;
                            objEvent.CustomScript		= null;
                            objEvent.ReferencedScript	= null;
                    }

                    objectEvents.Add(objEvent);
                }
            }
            else {
                for (int i = 0; i < eventProperties.Count; i++) {
                    Property property = eventProperties[i];
                    PropertyDocumentation doc = property.GetRootDocumentation();
                    string name = (doc != null ? doc.ReadableName : property.Name);
                    listBoxEvents.Items.Add(name);

                    InternalObjectEvent objEvent = new InternalObjectEvent();
                    objEvent.Property			= property;
                    objEvent.Id				= property.Name;
                    objEvent.Name				= (doc != null ? doc.ReadableName : property.Name);
                    objEvent.Description		= (doc != null ? doc.Description : "");
                    objEvent.CustomScriptExists	= false;
                    objEvent.Event				= null;
                    if (objectEditor.PropertyObject is IEventObject)
                        objEvent.Event = ((IEventObject) objectEditor.PropertyObject).Events.GetEvent(property.Name);

                    string scriptName = property.StringValue;
                    Script script = null;
                    if (scriptName.Length > 0)
                        script = EditorControl.World.GetScript(scriptName);

                    if (script == null) {
                        objEvent.RadioButtonIndex	= RedioButtonIndex.None;
                        objEvent.CustomScript		= null;
                        objEvent.ReferencedScript	= null;
                    }
                    else if (script.IsHidden) {
                        objEvent.RadioButtonIndex	= RedioButtonIndex.CustomCode;
                        objEvent.CustomScript		= script;
                        objEvent.ReferencedScript	= null;
                        objEvent.CustomScriptExists	= true;
                    }
                    else {
                        objEvent.RadioButtonIndex	= RedioButtonIndex.Script;
                        objEvent.CustomScript		= null;
                        objEvent.ReferencedScript	= script;
                    }

                    objectEvents.Add(objEvent);
                }
            }

            if (listBoxEvents.Items.Count > 0) {
                listBoxEvents.SelectedIndex = 0;
                objectEvent = objectEvents[0];
            }
            else {
                listBoxEvents.SelectedIndex = -1;
                objectEvent = null;
            }
        }
コード例 #5
0
        public void SetupObject(IPropertyObject propertyObject)
        {
            // Create a list of all event properties.
            List <Property> eventProperties = new List <Property>();

            foreach (Property property in propertyObject.Properties.GetAllProperties())
            {
                PropertyDocumentation doc = property.GetDocumentation();
                if (doc != null && doc.EditorType == "script")
                {
                    eventProperties.Add(property);
                }
            }

            objectEvents.Clear();
            listBoxEvents.Items.Clear();

            IEventObject eventObject = objectEditor.PropertyObject as IEventObject;

            if (eventObject != null)
            {
                foreach (KeyValuePair <string, ObjectEvent> entry in eventObject.Events.Events)
                {
                    listBoxEvents.Items.Add(entry.Value.ReadableName);

                    Property property = objectEditor.PropertyObject.Properties.GetProperty(entry.Value.Name, true);

                    InternalObjectEvent objEvent = new InternalObjectEvent();
                    objEvent.Property           = property;
                    objEvent.Id                 = entry.Value.Name;
                    objEvent.Name               = entry.Value.ReadableName;
                    objEvent.Description        = entry.Value.Description;
                    objEvent.CustomScriptExists = false;
                    objEvent.Event              = entry.Value;

                    if (property != null)
                    {
                        string scriptName = property.StringValue;
                        Script script     = null;
                        if (scriptName.Length > 0)
                        {
                            script = EditorControl.World.GetScript(scriptName);
                        }

                        if (script == null)
                        {
                            objEvent.RadioButtonIndex = RedioButtonIndex.None;
                            objEvent.CustomScript     = null;
                            objEvent.ReferencedScript = null;
                        }
                        else if (script.IsHidden)
                        {
                            objEvent.RadioButtonIndex   = RedioButtonIndex.CustomCode;
                            objEvent.CustomScript       = script;
                            objEvent.ReferencedScript   = null;
                            objEvent.CustomScriptExists = true;
                        }
                        else
                        {
                            objEvent.RadioButtonIndex = RedioButtonIndex.Script;
                            objEvent.CustomScript     = null;
                            objEvent.ReferencedScript = script;
                        }
                    }
                    else
                    {
                        objEvent.RadioButtonIndex = RedioButtonIndex.None;
                        objEvent.CustomScript     = null;
                        objEvent.ReferencedScript = null;
                    }

                    objectEvents.Add(objEvent);
                }
            }
            else
            {
                for (int i = 0; i < eventProperties.Count; i++)
                {
                    Property property         = eventProperties[i];
                    PropertyDocumentation doc = property.GetRootDocumentation();
                    string name = (doc != null ? doc.ReadableName : property.Name);
                    listBoxEvents.Items.Add(name);

                    InternalObjectEvent objEvent = new InternalObjectEvent();
                    objEvent.Property           = property;
                    objEvent.Id                 = property.Name;
                    objEvent.Name               = (doc != null ? doc.ReadableName : property.Name);
                    objEvent.Description        = (doc != null ? doc.Description : "");
                    objEvent.CustomScriptExists = false;
                    objEvent.Event              = null;
                    if (objectEditor.PropertyObject is IEventObject)
                    {
                        objEvent.Event = ((IEventObject)objectEditor.PropertyObject).Events.GetEvent(property.Name);
                    }

                    string scriptName = property.StringValue;
                    Script script     = null;
                    if (scriptName.Length > 0)
                    {
                        script = EditorControl.World.GetScript(scriptName);
                    }

                    if (script == null)
                    {
                        objEvent.RadioButtonIndex = RedioButtonIndex.None;
                        objEvent.CustomScript     = null;
                        objEvent.ReferencedScript = null;
                    }
                    else if (script.IsHidden)
                    {
                        objEvent.RadioButtonIndex   = RedioButtonIndex.CustomCode;
                        objEvent.CustomScript       = script;
                        objEvent.ReferencedScript   = null;
                        objEvent.CustomScriptExists = true;
                    }
                    else
                    {
                        objEvent.RadioButtonIndex = RedioButtonIndex.Script;
                        objEvent.CustomScript     = null;
                        objEvent.ReferencedScript = script;
                    }

                    objectEvents.Add(objEvent);
                }
            }

            if (listBoxEvents.Items.Count > 0)
            {
                listBoxEvents.SelectedIndex = 0;
                objectEvent = objectEvents[0];
            }
            else
            {
                listBoxEvents.SelectedIndex = -1;
                objectEvent = null;
            }
        }