示例#1
0
        private void ConvertToYMap(SpoonerPlacements spoonerPlacements)
        {
            _currentYMap = new YMap();

            foreach (var placement in spoonerPlacements.Placements)
            {
                var model = placement.HashName;
                if (string.IsNullOrEmpty(model))
                {
                    model = placement.ModelHash;
                }

                var position = placement.PositionRotation.GetPosition();
                var rotation = placement.PositionRotation.GetQuaternion();
                switch (placement.Type)
                {
                case 2:
                    CreateCarGenerator(model, position, rotation, CarGenScale);
                    break;

                case 3:
                    CreateEntity(model, position, rotation, placement.Dynamic, false);
                    break;
                }
            }

            CalcExtents();
            RefreshView();
        }
示例#2
0
        private void OpenFile(string _filePath)
        {
            if (_filePath.EndsWith(".ymap.xml"))
            {
                using (var reader = XmlReader.Create(_filePath))
                {
                    var s = new XmlSerializer(typeof(YMap));
                    _currentYMap = (YMap)s.Deserialize(reader);
                    reader.Close();
                    RefreshView();
                    Text = @"ME2YM - " + Path.GetFileName(_filePath);
                }
            }
            else if (_filePath.EndsWith(".xml"))
            {
                MapEditorMap      map        = null;
                SpoonerPlacements spoonerMap = null;

                var reader = XmlReader.Create(_filePath);
                try
                {
                    var s = new XmlSerializer(typeof(MapEditorMap));
                    map = (MapEditorMap)s.Deserialize(reader);
                }
                catch
                {
                    try
                    {
                        var s = new XmlSerializer(typeof(SpoonerPlacements));
                        spoonerMap = (SpoonerPlacements)s.Deserialize(reader);
                        Text       = @"ME2YM - " + Path.GetFileName(_filePath);
                    }
                    catch { /* ignored */ }
                }
                reader.Close();

                if (map == null && spoonerMap == null)
                {
                    MessageBox.Show(@"Failed to read file.");
                    return;
                }

                if (map != null)
                {
                    ConvertToYMap(map);
                }
                else
                {
                    ConvertToYMap(spoonerMap);
                }
            }
            else
            {
                MessageBox.Show(@"This is not a valid type!");
            }
        }
示例#3
0
        private void OpenToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var o = new OpenFileDialog
            {
                Filter =
                    @"Map Editor files (*.xml)|*.xml|Menyoo Spooner files (*.xml)|*.xml|YMap files (*.ymap.xml)|*.ymap.xml"
            };

            if (o.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            if (o.FileName.EndsWith(".ymap.xml"))
            {
                using (var reader = XmlReader.Create(o.FileName))
                {
                    var s = new XmlSerializer(typeof(YMap));
                    _currentYMap = (YMap)s.Deserialize(reader);
                    reader.Close();
                    RefreshView();
                    Text = @"ME2YM - " + Path.GetFileName(o.FileName);
                }
            }
            else if (o.FileName.EndsWith(".xml"))
            {
                MapEditorMap      map        = null;
                SpoonerPlacements spoonerMap = null;

                var reader = XmlReader.Create(o.FileName);
                try
                {
                    var s = new XmlSerializer(typeof(MapEditorMap));
                    map = (MapEditorMap)s.Deserialize(reader);
                }
                catch
                {
                    try
                    {
                        var s = new XmlSerializer(typeof(SpoonerPlacements));
                        spoonerMap = (SpoonerPlacements)s.Deserialize(reader);
                        Text       = @"ME2YM - " + Path.GetFileName(o.FileName);
                    }
                    catch { /* ignored */ }
                }
                reader.Close();

                if (map == null && spoonerMap == null)
                {
                    MessageBox.Show(@"Failed to read file.");
                    return;
                }

                if (map != null)
                {
                    ConvertToYMap(map);
                }
                else
                {
                    ConvertToYMap(spoonerMap);
                }
            }
            else
            {
                MessageBox.Show(@"This is not a valid type!");
            }
        }