예제 #1
0
        private void btnExport_Click(object sender, EventArgs e)
        {
            if (SelectedRemap == null)
            {
                return;
            }

            var newSkin = new SvgSkin();

            newSkin.Load(_skin.Path);
            newSkin.ApplyRemap(SelectedRemap);

            sfd.FileName = $@"{Path.GetFileNameWithoutExtension(_skin.Path)}_{SelectedRemap.Name}.svg";
            if (sfd.ShowDialog() == DialogResult.OK)
            {
                newSkin.SvgDocument.Write(sfd.FileName);
            }
        }
예제 #2
0
 public static void LoadSkins()
 {
     foreach (string svgPath in Directory.GetFiles("./skins", "*.svg"))
     {
         var svg = new SvgSkin();
         svg.Load(svgPath);
         Skins.Add(svg);
     }
     foreach (string padpyghtDir in Directory.GetDirectories("./skins"))
     {
         foreach (string iniPath in Directory.GetFiles(padpyghtDir, "*.ini"))
         {
             var pp = new PadpyghtSkin();
             pp.Load(iniPath);
             if (pp.LoadResult == SkinLoadResult.Ok)
             {
                 Skins.Add(pp);
             }
         }
     }
 }
예제 #3
0
        public static void LoadSkins()
        {
            foreach (var dir in SkinFolders)
            {
                if (!Directory.Exists(dir.Path))
                {
                    continue;
                }

                if ((dir.Types & SkinType.Svg) != 0)
                {
                    foreach (string svgPath in Directory.GetFiles(dir.Path, "*.svg"))
                    {
                        var svg = new SvgSkin();
                        svg.Load(svgPath);
                        if (svg.LoadResult == SkinLoadResult.Ok)
                        {
                            Skins.Add(svg);
                            var b = new BindingList <ColorRemap>();
                            foreach (var map in svg.EmbeddedRemaps)
                            {
                                b.Add(map);
                            }
                            AvailableRemaps[svg.Path] = b;
                            SelectedRemaps[svg]       = null;
                        }
                    }
                }

                if ((dir.Types & SkinType.PadPyght) != 0)
                {
                    foreach (string padpyghtDir in Directory.GetDirectories(dir.Path))
                    {
                        foreach (string iniPath in Directory.GetFiles(padpyghtDir, "*.ini"))
                        {
                            var pp = new PadpyghtSkin();
                            pp.Load(iniPath);
                            if (pp.LoadResult == SkinLoadResult.Ok)
                            {
                                Skins.Add(pp);
                            }
                        }
                    }
                }

                if ((dir.Types & SkinType.NintendoSpy) != 0)
                {
                    foreach (string nspyDir in Directory.GetDirectories(dir.Path))
                    {
                        foreach (string xmlPath in Directory.GetFiles(nspyDir, "skin.xml"))
                        {
                            var pp = new NintendoSpySkin();
                            pp.Load(xmlPath);
                            if (pp.LoadResult == SkinLoadResult.Ok)
                            {
                                Skins.Add(pp);
                            }
                        }
                    }
                }
            }
        }
예제 #4
0
        public SkinRemapperForm(string path, ColorRemap remap) : this()
        {
            _skin = new SvgSkin();
            _skin.Load(path);
            Remap = remap;
            remap.ApplyToSkin(this._skin);

            var highlightElems = _skin.Buttons.Where(b => b.Pressed != null).Select(b => b.Pressed)
                                 .Union(_skin.Sticks.Where(s => s.Pressed != null).Select(s => s.Pressed));

            var nonHighlightElems = _skin.Buttons.Where(b => b.Element != null).Select(b => b.Element)
                                    .Union(_skin.Sticks.Where(s => s.Element != null).Select(s => s.Element))
                                    .Union(_skin.Triggers.Where(t => t.Element != null).Select(t => t.Element));

            // split remap groups into highlight/non-highlight/base categories
            foreach (var group in remap.Groups)
            {
                var grpHl    = new GroupedSvgElems(group.Fill, group.Stroke);
                var grpNonHl = new GroupedSvgElems(group.Fill, group.Stroke);
                var grpBase  = new GroupedSvgElems(group.Fill, group.Stroke);

                foreach (var elem in group)
                {
                    bool hl    = GroupContains(elem, highlightElems);
                    bool nonHl = GroupContains(elem, nonHighlightElems);
                    if (hl)
                    {
                        grpHl.Add(elem);
                    }
                    if (nonHl)
                    {
                        grpNonHl.Add(elem);
                    }
                    if (!hl && !nonHl)
                    {
                        grpBase.Add(elem);
                    }
                }

                if (grpNonHl.Count == 0 && grpBase.Count == 0)
                {
                    // this is entirely a HL group
                    _highlights.Add(group);
                }
                else if (grpHl.Count == 0 && grpBase.Count == 0)
                {
                    // this is entirely a non-HL group
                    _nonHighlights.Add(group);
                }
                else if (grpHl.Count == 0 && grpNonHl.Count == 0)
                {
                    _base.Add(group);
                }
                else
                {
                    // split up
                    if (grpHl.Any())
                    {
                        _highlights.Add(grpHl);
                    }
                    if (grpNonHl.Any())
                    {
                        _nonHighlights.Add(grpNonHl);
                    }
                    if (grpBase.Any())
                    {
                        _base.Add(grpBase);
                    }
                }
            }

            tbSkinName.DataBindings.Add("Text", Remap, "Name");
            lbGroups.DisplayMember = nameof(GroupedSvgElems.Name);
            PopulateListbox();
        }