コード例 #1
0
 public NameValueDialog(NameValueObject obj, string type, NameValueTemplateCollection temCol)
 {
     InitializeComponent();
     temColl = temCol;
     NameValueCollection.SetNameValueObject(obj.nameValuePairs);
     loadTemplateListBox(temCol.List(type));
     loadNameListBox();
 }
コード例 #2
0
 public SpawnGen(WorldEditor appin, IWorldContainer parentin, int respawnTimein, uint numberOfSpawnsin, string templateNamein)
 {
     this.app            = appin;
     this.parent         = parentin;
     this.respawnTime    = respawnTimein;
     this.numSpawn       = numberOfSpawnsin;
     this.templateName   = templateNamein;
     this.nameValuePairs = new NameValueObject();
 }
コード例 #3
0
 public InteriorPath(IWorldContainer parentContainer, WorldEditor worldEditor, string meshName)
 {
     // initialize data members
     parent                = parentContainer;
     app                   = worldEditor;
     this.meshName         = meshName;
     points                = new PointCollection(this, worldEditor, true, worldEditor.Config.DisplayRegionPoints, worldEditor.Config.RegionPointMeshName, worldEditor.Config.RegionPointMaterial);
     nameValuePairs        = new NameValueObject();
     points.PointsChanged += new PointsChangedEventHandler(PointsChangedHandler);
     Changed              += new InSceneChangedEventHandler(app.SceneChangedHandler);
 }
コード例 #4
0
 public NameValueObject(NameValueObject nvo)
 {
     nameValuePairs = new Dictionary <string, valueItem>();
     foreach (string name in this.NameValuePairKeyList())
     {
         valueItem value = new valueItem();
         nvo.nameValuePairs.TryGetValue(name, out value);
         this.AddNameValuePair(name, value.value, value.enumList);
     }
     return;
 }
コード例 #5
0
        public Waypoint(XmlReader r, IWorldContainer parent, WorldEditor app)
        {
            this.parent   = parent;
            this.app      = app;
            this.children = new List <IWorldObject>();
            FromXml(r);

            if (nameValuePairs == null)
            {
                nameValuePairs = new NameValueObject();
            }
        }
コード例 #6
0
        public RoadObject(WorldEditor worldEditor, String objectName, IWorldContainer parentContainer, int halfWidth)
        {
            name     = objectName;
            parent   = parentContainer;
            app      = worldEditor;
            children = new List <IWorldObject>();

            this.HalfWidth      = halfWidth;
            this.nameValuePairs = new NameValueObject();

            points = null;
        }
コード例 #7
0
        public Waypoint(string name, IWorldContainer parent, WorldEditor app, Vector3 location, Vector3 rotation)
        {
            this.parent         = parent;
            this.app            = app;
            this.position       = location;
            this.name           = name;
            this.nameValuePairs = new NameValueObject();
            this.children       = new List <IWorldObject>();
            this.orientation    = new Quaternion(0, 0, 0, 0);
//            this.orientation = Quaternion.FromAngleAxis(defaultRot * MathUtil.RADIANS_PER_DEGREE, Vector3.UnitY);
            SetDirection(rotation.y, 90);
        }
コード例 #8
0
 public Waypoint(string name, IWorldContainer parent, WorldEditor app, Vector3 location, Quaternion orientation)
 {
     this.azimuth        = 0f;
     this.zenith         = 0f;
     this.name           = name;
     this.app            = app;
     this.orientation    = new Quaternion(orientation.w, orientation.x, orientation.y, orientation.z);
     this.position       = location;
     this.parent         = parent;
     this.nameValuePairs = new NameValueObject();
     this.children       = new List <IWorldObject>();
 }
コード例 #9
0
        public void FromXml(XmlReader r)
        {
            // first parse the attributes
            for (int i = 0; i < r.AttributeCount; i++)
            {
                r.MoveToAttribute(i);
                // set the field in this object based on the element we just read
                {
                    switch (r.Name)
                    {
                    case "TemplateName":
                        this.templateName = r.Value;
                        break;

                    case "RespawnTime":
                        this.respawnTime = int.Parse(r.Value);
                        break;

                    case "NumSpawns":
                        this.numSpawn = uint.Parse(r.Value);
                        break;

                    case "SpawnRadius":
                        this.spawnRadius = float.Parse(r.Value);
                        break;
                    }
                }
            }
            r.MoveToElement(); //Moves the reader back to the element node.
            if (!r.IsEmptyElement)
            {
                while (r.Read())
                {
                    if (r.NodeType == XmlNodeType.EndElement)
                    {
                        break;
                    }
                    if (r.NodeType == XmlNodeType.Whitespace)
                    {
                        continue;
                    }
                    if (r.NodeType == XmlNodeType.Element)
                    {
                        switch (r.Name)
                        {
                        case "NameValuePairs":
                            this.nameValuePairs = new NameValueObject(r);
                            break;
                        }
                    }
                }
            }
        }
コード例 #10
0
        public Dictionary <string, valueItem> CopyNameValueObject()
        {
            NameValueObject dest = new NameValueObject();

            foreach (string name in this.NameValuePairKeyList())
            {
                valueItem value = new valueItem();
                this.nameValuePairs.TryGetValue(name, out value);
                dest.AddNameValuePair(name, value.value, value.enumList);
            }
            return(dest.nameValuePairs);
        }
コード例 #11
0
        public Boundary(WorldEditor worldEditor, IWorldContainer parentContainer, string namein, int priority)
        {
            // initialize data members
            parent = parentContainer;
            app    = worldEditor;
            name   = namein;

            this.priority  = priority;
            nameValuePairs = new NameValueObject();
            children       = new List <IWorldObject>();
            points         = null;
            Changed       += new InSceneChangedEventHandler(app.SceneChangedHandler);
        }
コード例 #12
0
        public StaticObject(IWorldContainer parentContainer, WorldEditor worldEditor, XmlReader r)
        {
            parent = parentContainer;
            app    = worldEditor;

            children = new List <IWorldObject>();
            FromXml(r);

            if (nameValuePairs == null)
            {
                nameValuePairs = new NameValueObject();
            }
        }
コード例 #13
0
 public InteriorPath(WorldEditor worldEditor, IWorldContainer parentContainer, string meshName, InteriorPathContents path)
 {
     parent                = parentContainer;
     app                   = worldEditor;
     points                = new PointCollection(this, worldEditor, true, worldEditor.Config.DisplayRegionPoints, worldEditor.Config.RegionPointMeshName, worldEditor.Config.RegionPointMaterial);
     nameValuePairs        = new NameValueObject();
     points.PointsChanged += new PointsChangedEventHandler(PointsChangedHandler);
     Changed              += new InSceneChangedEventHandler(app.SceneChangedHandler);
     foreach (Vector3 position in path.Points)
     {
         int index;
         points.AddPoint(position, out index);
     }
 }
コード例 #14
0
        public RoadObject(String objectName, IWorldContainer parentContainer, WorldEditor worldEditor, int halfWidth)
        {
            name     = objectName;
            parent   = parentContainer;
            app      = worldEditor;
            children = new List <IWorldObject>();

            this.HalfWidth      = halfWidth;
            this.nameValuePairs = new NameValueObject();

            points = new PointCollection(this, app, false, true, app.Config.RoadPointMeshName, app.Config.RoadPointMaterial, MPPointType.Road);
            Add(points);
            points.PointsChanged += new PointsChangedEventHandler(PointsChangedHandler);
        }
コード例 #15
0
        public Boundary(IWorldContainer parentContainer, WorldEditor worldEditor, string namein, int priority)
        {
            // initialize data members
            parent = parentContainer;
            app    = worldEditor;
            name   = namein;

            this.priority  = priority;
            nameValuePairs = new NameValueObject();
            children       = new List <IWorldObject>();
            points         = new PointCollection(this, worldEditor, true, worldEditor.Config.DisplayRegionPoints, worldEditor.Config.RegionPointMeshName, worldEditor.Config.RegionPointMaterial, MPPointType.Boundary);
            Add(points);
            points.PointsChanged += new PointsChangedEventHandler(PointsChangedHandler);
            Changed += new InSceneChangedEventHandler(app.SceneChangedHandler);
        }
コード例 #16
0
        public Boundary(XmlReader r, IWorldContainer parentContainer, WorldEditor worldEditor)
        {
            // initialize data members
            parent = parentContainer;
            app    = worldEditor;

            children = new List <IWorldObject>();

            FromXml(r);

            if (nameValuePairs == null)
            {
                nameValuePairs = new NameValueObject();
            }
            Changed += new InSceneChangedEventHandler(app.SceneChangedHandler);
        }
コード例 #17
0
        protected void FromXml(XmlReader r)
        {
            // first parse the attributes
            for (int i = 0; i < r.AttributeCount; i++)
            {
                r.MoveToAttribute(i);

                // set the field in this object based on the element we just read
                switch (r.Name)
                {
                case "mesh":
                    this.meshName = r.Value;
                    break;
                }
            }
            r.MoveToElement(); //Moves the reader back to the element node.

            while (r.Read())
            {
                if (r.NodeType == XmlNodeType.EndElement)
                {
                    break;
                }
                if (r.NodeType == XmlNodeType.Element)
                {
                    switch (r.Name)
                    {
                    case "PointCollection":
                        if (!r.IsEmptyElement)
                        {
                            this.points           = new PointCollection(this, app, true, app.Config.DisplayRegionPoints, this.app.Config.RegionPointMeshName, this.app.Config.RegionPointMaterial, r);
                            points.PointsChanged += new PointsChangedEventHandler(PointsChangedHandler);
                        }
                        break;

                    case "NameValuePairs":
                        this.nameValuePairs = new NameValueObject(r);
                        break;
                    }
                }
            }
            if (points == null)
            {
                this.points           = new PointCollection(this, app, true, app.Config.DisplayRegionPoints, this.app.Config.RegionPointMeshName, this.app.Config.RegionPointMaterial);
                points.PointsChanged += new PointsChangedEventHandler(PointsChangedHandler);
            }
        }
コード例 #18
0
        public StaticObject(String objectName, IWorldContainer parentContainer, WorldEditor worldEditor, string meshName, Vector3 position, Vector3 scale, Vector3 rotation)
        {
            name   = objectName;
            parent = parentContainer;
            app    = worldEditor;

            children = new List <IWorldObject>();
            this.SetDirection(rotation.y, 90f);
            this.scale          = scale;
            this.location       = position;
            this.meshName       = meshName;
            this.nameValuePairs = new NameValueObject();
            this.terrainOffset  = 0f;


            displayObject = null;

            subMeshes = new SubMeshCollection(meshName);
        }
コード例 #19
0
        protected void FromXml(XmlReader r)
        {
            while (r.Read())
            {
                if (r.NodeType == XmlNodeType.EndElement)
                {
                    break;
                }
                if (r.NodeType == XmlNodeType.Element)
                {
                    switch (r.Name)
                    {
                    case "PointCollection":
                        while (r.Read())
                        {
                            // look for the start of an element
                            if (r.NodeType == XmlNodeType.Element)
                            {
                                string elementName = r.Name;
                                switch (elementName)
                                {
                                case "Point":
                                    points.Add(XmlHelperClass.ParseVectorAttributes(r));
                                    break;
                                }
                            }
                            else if (r.NodeType == XmlNodeType.EndElement)
                            {
                                break;
                            }
                        }
                        r.MoveToElement();                         //Moves the reader back to the element node.
                        break;

                    case "NameValuePairs":
                        this.nameValuePairs = new NameValueObject(r);
                        break;
                    }
                }
            }
        }
コード例 #20
0
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (context != null &&
                context.Instance != null &&
                provider != null)
            {
                IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

                if (edSvc != null)
                {
                    NameValueObject nvc = value as NameValueObject;
                    if (nvc != null)
                    {
                        NameValueDialog nameValueEditor = new NameValueDialog(nvc, type, nvt);

                        do
                        {
                            DialogResult dlgRes = edSvc.ShowDialog(nameValueEditor);
                            if (dlgRes == DialogResult.OK)
                            {
                                return(nameValueEditor.NameValueCollection);
                            }
                            if (MessageBox.Show("Closing this window will remove all the changes made.",
                                                "Close Window?",
                                                MessageBoxButtons.OKCancel) == DialogResult.Cancel)
                            {
                                exit = false;
                            }
                            else
                            {
                                exit = true;
                            }
                        } while (!exit);
                    }
                }
            }

            return(value);
        }
コード例 #21
0
        protected void FromXml(XmlReader r)
        {
            // first parse the attributes
            for (int i = 0; i < r.AttributeCount; i++)
            {
                r.MoveToAttribute(i);

                // set the field in this object based on the element we just read
                switch (r.Name)
                {
                case "Name":
                    this.name = r.Value;
                    break;

                case "Priority":
                    this.priority = int.Parse(r.Value);
                    break;
                }
            }
            r.MoveToElement(); //Moves the reader back to the element node.

            while (r.Read())
            {
                if (r.NodeType == XmlNodeType.EndElement)
                {
                    break;
                }
                if (r.NodeType == XmlNodeType.Element)
                {
                    switch (r.Name)
                    {
                    case "PointCollection":
                        if (!r.IsEmptyElement)
                        {
                            this.points = new PointCollection(this, app, true, app.Config.DisplayRegionPoints, this.app.Config.RegionPointMeshName, this.app.Config.RegionPointMaterial, MPPointType.Boundary, r);
                            Add(points);
                            points.PointsChanged += new PointsChangedEventHandler(PointsChangedHandler);
                        }
                        break;

                    case "NameValuePairs":
                        this.nameValuePairs = new NameValueObject(r);
                        break;

                    case "Forest":
                        Forest forest = new Forest(r, this, app);
                        Add(forest);
                        break;

                    case "Fog":
                        Fog fog = new Fog(r, this, app);
                        Add(fog);
                        break;

                    case "Water":
                        Water water = new Water(r, this, app);
                        Add(water);
                        break;

                    case "Sound":
                        Sound sound = new Sound(r, (IWorldContainer)this, app);
                        Add(sound);
                        break;

                    case "Grass":
                        Grass grass = new Grass(r, this, app);
                        Add(grass);
                        break;

                    case "SpawnGen":
                        SpawnGen mob = new SpawnGen(r, app, this);
                        Add(mob);
                        break;

                    case "AmbientLight":
                        AmbientLight ambientLight = new AmbientLight(app, this, r);
                        Add(ambientLight);
                        break;

                    case "DirectionalLight":
                        DirectionalLight directionalLight = new DirectionalLight(app, this, r);
                        Add(directionalLight);
                        break;
                    }
                }
            }
            if (points == null)
            {
                this.points = new PointCollection(this, app, true, app.Config.DisplayRegionPoints, this.app.Config.RegionPointMeshName, this.app.Config.RegionPointMaterial, MPPointType.Boundary);
                Add(points);
                points.PointsChanged += new PointsChangedEventHandler(PointsChangedHandler);
            }
        }
コード例 #22
0
        protected void FromXml(XmlReader r)
        {
            // first parse the attributes

            bool adjustHeightFound = false;

            for (int i = 0; i < r.AttributeCount; i++)
            {
                r.MoveToAttribute(i);

                // set the field in this object based on the element we just read
                switch (r.Name)
                {
                case "Name":
                    this.name = r.Value;
                    break;

                //case "Sound":
                //    this.soundAssetName = r.Value;
                //    break;
                case "TerrainOffset":
                    offsetFound   = true;
                    terrainOffset = float.Parse(r.Value);
                    break;

                case "AllowHeightAdjustment":
                    adjustHeightFound = true;
                    if (String.Equals(r.Value.ToLower(), "false"))
                    {
                        allowAdjustHeightOffTerrain = false;
                    }
                    break;

                case "Azimuth":
                    azimuth = float.Parse(r.Value);
                    break;

                case "Zenith":
                    zenith = float.Parse(r.Value);
                    break;

                case "WorldViewSelect":
                    worldViewSelectable = bool.Parse(r.Value);
                    break;
                }
            }
//            this.nameValuePairs = new NameValueObject();
            r.Read();
            do
            {
                if (r.NodeType == XmlNodeType.Whitespace)
                {
                    continue;
                }
                if (r.NodeType == XmlNodeType.Element)
                {
                    switch (r.Name)
                    {
                    case "Position":
                        this.position = XmlHelperClass.ParseVectorAttributes(r);
                        break;

                    case "Orientation":
                        orientation = XmlHelperClass.ParseQuaternion(r);
                        break;

                    case "NameValuePairs":
                        this.nameValuePairs = new NameValueObject(r);
                        break;

                    case "ParticleEffect":
                        ParticleEffect particle = new ParticleEffect(r, this, app);
                        Add(particle);
                        break;

                    case "SpawnGen":
                        SpawnGen mob = new SpawnGen(r, app, this);
                        Add(mob);
                        break;

                    case "Sound":
                        Sound sound = new Sound(r, this, app);
                        Add(sound);
                        break;

                    case "Color":
                        Color = XmlHelperClass.ParseColorAttributes(r);
                        break;
                    }
                }
                else if (r.NodeType == XmlNodeType.EndElement)
                {
                    break;
                }
            } while (r.Read());
            if (!adjustHeightFound)
            {
                allowAdjustHeightOffTerrain = true;
            }
            if (!offsetFound)
            {
                terrainOffset = this.Position.y - app.GetTerrainHeight(position.x, position.z);
            }

            if (orientation != null && disp != null)
            {
                disp.SetOrientation(orientation);
                foreach (IWorldObject obj in children)
                {
                    if (obj is ParticleEffect)
                    {
                        (obj as ParticleEffect).Orientation = this.orientation;
                    }
                }
            }
        }
コード例 #23
0
        protected void FromXml(XmlReader r)
        {
            bool adjustHeightFound = false;
            bool offsetFound       = false;
            bool pRFound           = false;

            // first parse name and mesh, which are attributes
            for (int i = 0; i < r.AttributeCount; i++)
            {
                r.MoveToAttribute(i);

                // set the field in this object based on the element we just read
                switch (r.Name)
                {
                case "Name":
                    this.name = r.Value;
                    break;

                case "Mesh":
                    this.meshName = r.Value;
                    break;

                case "Sound":
                    string filename = r.Value;
                    if (!String.Equals(filename, ""))
                    {
                        ICommandFactory ret = new AddSoundCommandFactory(app, this, r.Value);
                        ICommand        com = ret.CreateCommand();
                        com.Execute();
                    }
                    break;

                case "TerrainOffset":
                    terrainOffset = float.Parse(r.Value);
                    offsetFound   = true;
                    break;

                case "AllowHeightAdjustment":
                    if (String.Equals(r.Value.ToLower(), "false"))
                    {
                        allowAdjustHeightOffTerrain = false;
                    }
                    break;

                case "AcceptObjectPlacement":
                    acceptObjectPlacement = bool.Parse(r.Value);
                    break;

                case "PerceptionRadius":
                    pRFound          = true;
                    perceptionRadius = float.Parse(r.Value);
                    break;

                case "CastShadows":
                    castShadows = bool.Parse(r.Value);
                    break;

                case "ReceiveShadows":
                    receiveShadows = bool.Parse(r.Value);
                    break;

                case "Azimuth":
                    azimuth = float.Parse(r.Value);
                    break;

                case "Zenith":
                    zenith = float.Parse(r.Value);
                    break;

                case "WorldViewSelect":
                    worldViewSelectable = bool.Parse(r.Value);
                    break;

                case "Targetable":
                    targetable = bool.Parse(r.Value);
                    break;
                }
            }
            r.MoveToElement(); //Moves the reader back to the element node.

            // now parse the sub-elements
            while (r.Read())
            {
                // look for the start of an element
                if (r.NodeType == XmlNodeType.Element)
                {
                    // parse that element
                    // save the name of the element
                    string elementName = r.Name;
                    switch (elementName)
                    {
                    case "Position":
                        location = XmlHelperClass.ParseVectorAttributes(r);
                        break;

                    case "Scale":
                        scale = XmlHelperClass.ParseVectorAttributes(r);
                        break;

                    case "Rotation":
                        Vector3 rotation = XmlHelperClass.ParseVectorAttributes(r);
                        // force rotation to be between -180 and 180
                        while (rotation.y < -180)
                        {
                            rotation.y += 360;
                        }
                        while (rotation.y > 180)
                        {
                            rotation.y -= 360;
                        }
                        SetDirection(rotation.y, 90f);
                        break;

                    case "Orientation":
                        orientation = XmlHelperClass.ParseQuaternion(r);
                        break;

                    case "SubMeshes":
                        subMeshes = new SubMeshCollection(r);
                        if (!subMeshes.CheckValid(app, meshName))
                        {
                            app.AddPopupMessage(string.Format("Some submesh names in {0} changed.  Submesh display and material parameters for this object were reset.", meshName));

                            // if the check fails, then reset the subMeshes from the mesh
                            subMeshes = new SubMeshCollection(meshName);
                        }
                        break;

                    case "NameValuePairs":
                        nameValuePairs = new NameValueObject(r);
                        break;

                    case "ParticleEffect":
                        ParticleEffect particle = new ParticleEffect(r, this, app);
                        Add(particle);
                        break;

                    case "PathData":
                        pathData      = new PathData(r);
                        locationDirty = pathData.Version != pathData.CodeVersion;
                        break;

                    case "Sound":
                        Sound sound = new Sound(r, this, app);
                        Add(sound);
                        break;
                    }
                }
                else if (r.NodeType == XmlNodeType.EndElement)
                {
                    break;
                }
            }
            if (!adjustHeightFound)
            {
                allowAdjustHeightOffTerrain = true;
            }
            if (!offsetFound)
            {
                terrainOffset = location.y - app.GetTerrainHeight(location.x, location.z);
            }
            if (!pRFound && nameValuePairs != null)
            {
                valueItem value = nameValuePairs.LookUp("perceptionRadius");
                if (value != null && ValidityHelperClass.isFloat(value.value))
                {
                    perceptionRadius = float.Parse(value.value);
                }
            }
            return;
        }