예제 #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
        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();
        }
예제 #3
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!");
            }
        }
예제 #4
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!");
            }
        }
예제 #5
0
 private void NewToolStripMenuItem_Click(object sender, EventArgs e)
 {
     _currentYMap = new YMap();
     Text         = @"ME2YM";
     RefreshView();
 }