Welcome to mirror list, hosted at ThFree Co, Russian Federation.

AppTypeCollection.cs « Apps - github.com/ClusterM/hakchi2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a2a7166d80c9b3a7092be7448d0818414a865c23 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
using com.clusterrr.hakchi_gui.Properties;
using System;
using System.Drawing;
using System.Text.RegularExpressions;

namespace com.clusterrr.hakchi_gui
{
    static class AppTypeCollection
    {
        //public delegate NesMiniApplication 

        public class AppInfo
        {
            public Type Class;
            public string[] Extensions;
            public string[] DefaultApps;
            public char Prefix;
            public Image DefaultCover;
        }

        public static AppInfo[] ApplicationTypes = new AppInfo[]
        {
            new AppInfo
            {
                Class = typeof(NesGame),
                Extensions = new string[] {".nes"},
                DefaultApps = new string[] { "/bin/nes", "/bin/clover-kachikachi-wr", "/usr/bin/clover-kachikachi" },
                Prefix = 'H',
                DefaultCover = Resources.blank_nes
            },
            new AppInfo
            {
                Class = typeof(NesUGame),
                Extensions = new string[] {".unf", ".unif", ".nes" },
                DefaultApps = new string[] {"/bin/nes"},
                Prefix = 'I',
                DefaultCover = Resources.blank_jp
            },
            new AppInfo
            {
                Class = typeof(FdsGame),
                Extensions = new string[] {".fds"},
                DefaultApps = new string[] { "/bin/nes", "/bin/clover-kachikachi-wr", "/usr/bin/clover-kachikachi" },
                Prefix = 'D',
                DefaultCover = Resources.blank_fds
            },
            new AppInfo
            {
                Class = typeof(SnesGame),
                Extensions = new string[] { ".sfc", ".smc", ".sfrom" },
                DefaultApps = new string[] { "/bin/snes", "/bin/clover-canoe-shvc-wr", "/usr/bin/clover-canoe-shvc" },
                Prefix = 'U',
                DefaultCover = Resources.blank_snes_us
            },
            new AppInfo
            {
                Class = typeof(N64Game),
                Extensions = new string[] { ".n64", ".z64", ".v64" },
                DefaultApps = new string[] {"/bin/n64"},
                Prefix = '6',
                DefaultCover = Resources.blank_n64
            },
            new AppInfo
            {
                Class = typeof(SmsGame),
                Extensions = new string[] { ".sms" },
                DefaultApps = new string[] {"/bin/sms"},
                Prefix = 'M',
                DefaultCover = Resources.blank_sms
            },
            new AppInfo
            {
                Class = typeof(GenesisGame),
                Extensions = new string[] { ".gen", ".md", ".smd" },
                DefaultApps = new string[] {"/bin/md"},
                Prefix = 'G',
                DefaultCover = Resources.blank_genesis
            },
            new AppInfo
            {
                Class = typeof(Sega32XGame),
                Extensions = new string[] { ".32x" },
                DefaultApps = new string[] {"/bin/32x"},
                Prefix = '3',
                DefaultCover = Resources.blank_32x
            },
            new AppInfo
            {
                Class = typeof(GbGame),
                Extensions = new string[] { ".gb" },
                DefaultApps = new string[] {"/bin/gb"},
                Prefix = 'B',
                DefaultCover = Resources.blank_gb
            },
            new AppInfo
            {
                Class = typeof(GbcGame),
                Extensions = new string[] {".gbc"},
                DefaultApps = new string[] {"/bin/gbc"},
                Prefix = 'C',
                DefaultCover = Resources.blank_gbc
            },
            new AppInfo
            {
                Class = typeof(GbaGame),
                Extensions = new string[] {".gba"},
                DefaultApps = new string[] {"/bin/gba"},
                Prefix = 'A',
                DefaultCover = Resources.blank_gba
            },
            new AppInfo
            {
                Class = typeof(PceGame),
                Extensions = new string[] {".pce"},
                DefaultApps = new string[] {"/bin/pce"},
                Prefix = 'E',
                DefaultCover = Resources.blank_pce
            },
            new AppInfo
            {
                Class = typeof(GameGearGame),
                Extensions = new string[] {".gg"},
                DefaultApps = new string[] {"/bin/gg"},
                Prefix = 'R',
                DefaultCover = Resources.blank_gg
            },
            new AppInfo
            {
                Class = typeof(GameGearGame),
                Extensions = new string[] {".a26"},
                DefaultApps = new string[] {"/bin/a26"},
                Prefix = 'T',
                DefaultCover = Resources.blank_2600
            },
            new AppInfo
            {
                Class = typeof(GameGearGame),
                Extensions = new string[] {},
                DefaultApps = new string[] {"/bin/fba", "/bin/mame", "/bin/cps2", "/bin/neogeo" },
                Prefix = 'X',
                DefaultCover = Resources.blank_arcade
            },
        };

        public static AppInfo GetAppByExtension(string extension)
        {
            foreach (var app in ApplicationTypes)
                if (Array.IndexOf(app.Extensions, extension) >= 0)
                    return app;
            return null;
        }

        public static AppInfo GetAppByExec(string exec)
        {
            exec = Regex.Replace(exec, "['\\\"]|(\\.7z)", " ")+" ";
            foreach (var app in ApplicationTypes)
                foreach (var cmd in app.DefaultApps)
                    if (exec.StartsWith(cmd + " "))
                    {
                        if (app.Extensions.Length == 0)
                            return app;
                        foreach (var ext in app.Extensions)
                        {
                            if (exec.Contains(ext + " "))
                                return app;
                        }
                    }
            return null;
        }
    }
}