コード例 #1
0
        private void ConvertToYMap(MapEditorMap map)
        {
            _currentYMap = new YMap();

            foreach (var mapObject in map.Objects)
            {
                var model = HashMap.GetModelName(mapObject.Hash);
                if (string.IsNullOrEmpty(model))
                {
                    model = "0x" + mapObject.Hash.ToString("x");
                }

                var position = mapObject.Position;
                switch (mapObject.Type)
                {
                case MapObjectTypes.Vehicle:
                    CreateCarGenerator(model, position, mapObject.Quaternion, CarGenScale);
                    break;

                case MapObjectTypes.Prop:
                    CreateEntity(model, position, mapObject.Quaternion, mapObject.Dynamic || mapObject.Door);
                    break;
                }
            }

            CalcExtents();
            RefreshView();
        }
コード例 #2
0
ファイル: YMapExporter.cs プロジェクト: asm512/me2ymap
        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!");
            }
        }