OSDN Git Service

ゴミデーターを削除
[marathon/ShapeFusion.git] / DefaultNames.cpp
1 /*
2  * This file is part of ShapeFusion (Copyright 2000 Tito Dal Canton)
3  *
4  * ShapeFusion is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * ShapeFusion is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with ShapeFusion; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17 */
18
19 #include "DefaultNames.h"
20
21 #include <wx/textfile.h>
22 #include <wx/tokenzr.h>
23 #include <wx/stdpaths.h>
24
25 static const wxString alienNames[] = {
26         _("Marine"),
27         _("Minor Tick"),
28         _("Major Tick"),
29         _("Kamikaze Tick"),
30         _("Minor S'pht"),
31         _("Major S'pht"),
32         _("Minor Invisible S'pht"),
33         _("Major Invisible S'pht"),
34         _("Minor Pfhor"),
35         _("Major Pfhor"),
36         _("Minor Projectile Pfhor"),
37         _("Major Projectile Pfhor"),
38         _("Green Bob"),
39         _("Blue Bob"),
40         _("Security Bob"),
41         _("Assimilated Bob"),
42         _("Minor Drone"),
43         _("Major Drone"),
44         _("Big Minor Drone"),
45         _("Big Angry Drone"),
46         _("Possessed Drone"),
47         _("Minor Cyborg"),
48         _("Major Cyborg"),
49         _("Minor Flame Cyborg"),
50         _("Major Flame Cyborg"),
51         _("Minor Enforcer"),
52         _("Major Enforcer"),
53         _("Minor Hunter"),
54         _("Major Hunter"),
55         _("Minor Trooper"),
56         _("Major Trooper"),
57         _("Mother of All Cyborgs"),
58         _("Mother of All Hunters"),
59         _("Sewage F'lickta"),
60         _("Water F'lickta"),
61         _("Lava F'lickta"),
62         _("Minor S'pht'Kr"),
63         _("Major S'pht'Kr"),
64         _("Minor Juggernaut"),
65         _("Major Juggernaut"),
66         _("Tiny P'fhor"),
67         _("Tiny Bob"),
68         _("Tiny Flick'ta"),
69         _("Green VacBob"),
70         _("Blue VacBob"),
71         _("Security VacBob"),
72         _("Assimilated VacBob"),
73 };
74
75 static const wxString collectionNames[] = {
76         _("Interface"),
77         _("Weapons in Hand"),
78         _("Juggernaut"),
79         _("Tick"),
80         _("Explosion Effects"),
81         _("Hunter"),
82         _("Marine"),
83         _("Items"),
84         _("Trooper"),
85         _("Pfhor fighter"),
86         _("S'pht'Kr"),
87         _("F'lickta"),
88         _("Bob"),
89         _("VacBob (Inf only)"),
90         _("Enforcer"),
91         _("Drone"),
92         _("S'pht"),
93         _("Walls 1 (Water)"),
94         _("Walls 2 (Lava)"),
95         _("Walls 3 (Sewage)"),
96         _("Walls 4 (Jjaro)"),
97         _("Walls 5 (Pfhor)"),
98         _("Scenery 1 (Water)"),
99         _("Scenery 2 (Lava)"),
100         _("Scenery 3 (Sewage)"),
101         _("Scenery 4 (Jjaro)"),
102         _("Scenery 5 (Pfhor)"),
103         _("Landscape 1 (Day)"),
104         _("Landscape 2 (Night)"),
105         _("Landscape 3 (Moon)"),
106         _("Landscape 4 (Space)"),
107         _("Cyborg"),
108 };
109
110 static const wxString classNames[] = {
111         _("Marine"),
112         _("Bob"),
113         _("Marathon Drone"),
114         _("Possessed Drone"),
115         _("S'pht'Kr"),
116         _("Pfhor Fighter"),
117         _("Pfhor Trooper"),
118         _("Hunter"),
119         _("Enforcer"),
120         _("Juggernaut"),
121         _("Drone"),
122         _("S'pht"),
123         _("Cyborg"),
124         _("Assimilated Bob"),
125         _("Tick"),
126         _("F'lickta"),
127 };
128
129 static const wxString damageNames[] = {
130         _("Explosion"),
131         _("Electrical Staff"),
132         _("Projectile"),
133         _("Absorbed"),
134         _("Flame"),
135         _("Claws"),
136         _("Alien Projectile"),
137         _("Hulk Slap"),
138         _("Compiler Bolt"),
139         _("Fusion Bolt"),
140         _("Hunter Bolt"),
141         _("Fist"),
142         _("Teleporter"),
143         _("S'pht'Kr Bolt"),
144         _("Flick'ta Claws"),
145         _("Flick'ta Projectile"),
146         _("Crushing"),
147         _("Lava"),
148         _("Suffocation"),
149         _("Goo"),
150         _("Energy Drain"),
151         _("Oxygen Drain"),
152         _("Drone Bolt"),
153         _("Shotgun"),
154 };
155
156 static const wxString effectNames[] = {
157         _("Missile Explosion"),
158         _("Missile Contrail"),
159         _("Grenade Explosion"),
160         _("Grenade Contrail"),
161         _("Bullet Ricochet"),
162         _("Alien Weapon Impact"),
163         _("Flamethrower Burst"),
164         _("Pfhor Hit"),
165         _("Marine Hit"),
166         _("Bob Hit"),
167         _("Assimilated Bob Hit"),
168         _("Enforcer Hit"),
169         _("S'pht Bolt Impact"),
170         _("Seeking S'pht Bolt Impact"),
171         _("S'pht Bolt Contrail"),
172         _("Staff-Bolt Impact"),
173         _("Staff Impact"),
174         _("Hunter Bolt Impact"),
175         _("Hunter Hit"),
176         _("Plasma Impact"),
177         _("Plasma Overload Impact"),
178         _("Plasma Contrail"),
179         _("Fist Impact"),
180         _("S'pht'Kr Bolt Impact"),
181         _("Major S'pht'Kr Bolt Impact"),
182         _("S'pht'Kr Hit"),
183         _("Trooper Hit"),
184         _("Lamp Breaking 1"),
185         _("Lamp Breaking 2"),
186         _("Lamp Breaking 3"),
187         _("Lamp Breaking 4"),
188         _("Clank (melee hit)"),
189         _("Teleport In"),
190         _("Teleport Out"),
191         _("Small Water Splash"),
192         _("Medium Water Splash"),
193         _("Large Water Splash"),
194         _("Large Water Emergence"),
195         _("Small Lava Splash"),
196         _("Medium Lava Splash"),
197         _("Large Lava Splash"),
198         _("Large Lava Emergence"),
199         _("Small Sewage Splash"),
200         _("Medium Sewage Splash"),
201         _("Large Sewage Splash"),
202         _("Large Sewage Emergence"),
203         _("Small Goo Splash"),
204         _("Medium Goo Splash"),
205         _("Large Goo Splash"),
206         _("Large Goo Emergence"),
207         _("Drone Bolt Impact"),
208         _("Fast Drone Bolt Impact"),
209         _("Possessed Drone Bolt Impact"),
210         _("Drone Hit"),
211         _("Cyborg Grenade Detonation"),
212         _("Cyborg Hit"),
213         _("Fusion Dispersal"),
214         _("Major Fusion Dispersal"),
215         _("Overloaded Fusion Dispersal"),
216         _("F'lickta Hit"),
217         _("F'lickta Glob Impact"),
218         _("Water Flick'ta Hit"),
219         _("Lava Flick'ta Hit"),
220         _("Flick'ta Lava Glob Impact"),
221         _("Flick'ta Claw Impact"),
222         _("Juggernaut Hit"),
223         _("Juggernaut Missile Contrail"),
224         _("Small Special Splash"),
225         _("Medium Special Splash"),
226         _("Large Special Splash"),
227         _("Special Emergence"),
228         _("VacBob Hit"),
229         _("Assimilated VacBob Hit"),
230 };
231
232 static const wxString itemNames[] = {
233         _("Fist"),
234         _("Magnum Pistol"),
235         _("Magnum Magazine"),
236         _("Plasma Pistol"),
237         _("Plasma Battery"),
238         _("Assault Rifle"),
239         _("Assault Rifle Clip"),
240         _("Grenade Clip"),
241         _("Missile Launcher"),
242         _("Missile Launcher Clip"),
243         _("Invisibility Powerup"),
244         _("Invincibility Powerup"),
245         _("Infravision Powerup"),
246         _("Alien Weapon"),
247         _("Alien Weapon Magazine"),
248         _("Flamethrower"),
249         _("Flamethrower Canister"),
250         _("Extravision Powerup"),
251         _("Oxygen Powerup"),
252         _("Energy Powerup"),
253         _("Double Energy Powerup"),
254         _("Triple Energy Powerup"),
255         _("Shotgun"),
256         _("Shotgun Magazine"),
257         _("S'pht Door Key"),
258         _("Uplink Chip"),
259         _("Light Blue Ball"),
260         _("The Ball"),
261         _("Violet Ball"),
262         _("Yellow Ball"),
263         _("Brown Ball"),
264         _("Orange Ball"),
265         _("Blue Ball"),
266         _("Green Ball"),
267         _("SMG"),
268         _("SMG Ammo"),
269 };
270
271 static const wxString soundNames[] = {
272         _("Startup"),
273         _("Teleport In"),
274         _("Teleport Out"),
275         _("Crunch"),
276         _("Creak (Inf only)"),
277         _("Absorbed"),
278         _("Unused 1"),
279         _("Oxygen Warning"),
280         _("Suffocation"),
281         _("Energy Refuel"),
282         _("Oxygen Refuel"),
283         _("Can't Toggle Switch"),
284         _("Switch On"),
285         _("Switch Off"),
286         _("Puzzle Switch"),
287         _("Chip Insertion"),
288         _("Pattern Buffer"),
289         _("Destroy Control Panel"),
290         _("Adjust Volume"),
291         _("Got Powerup"),
292         _("Got Item"),
293         _("Bullet Ricochet"),
294         _("Metallic Ricochet"),
295         _("Empty Gun"),
296         _("S'pht Door Opening"),
297         _("S'pht Door Closing"),
298         _("S'pht Door Obstructed"),
299         _("S'pht Platform Starting"),
300         _("S'pht Platform Stopping"),
301         _("Loon"),
302         _("SMG firing (Inf only)"),
303         _("SMG reloading (Inf only)"),
304         _("Heavy S'pht Platform Starting"),
305         _("Heavy S'pht Platform Stopping"),
306         _("Fist Hitting"),
307         _("Magnum Firing"),
308         _("Magnum Reloading"),
309         _("Assault Rifle Firing"),
310         _("Grenade Launcher Firing"),
311         _("Grenade Exploding"),
312         _("Grenade Flyby"),
313         _("Fusion Firing"),
314         _("Fusion Exploding"),
315         _("Fusion Flyby"),
316         _("Fusion Charging"),
317         _("Rocket Expoding"),
318         _("Rocket Flyby"),
319         _("Rocket Firing"),
320         _("Flamethrower"),
321         _("Body Falling"),
322         _("Body Exploding"),
323         _("Bullet Hitting Flesh"),
324         _("Fighter Activate"),
325         _("Fighter Wail"),
326         _("Fighter Scream"),
327         _("Fighter Chatter"),
328         _("Fighter Attack"),
329         _("Fighter Projectile Hit"),
330         _("Fighter Projectile Flyby"),
331         _("S'pht Attack"),
332         _("S'pht Death"),
333         _("S'pht Hit"),
334         _("S'pht Projectile Flyby"),
335         _("S'pht Projectile Hit"),
336         _("Cyborg Moving"),
337         _("Cyborg Attack"),
338         _("Cyborg Hit"),
339         _("Cyborg Death"),
340         _("Cyborg Projectile Bounce"),
341         _("Cyborg Projectile Hit"),
342         _("Unused 2"),
343         _("Drone Activate"),
344         _("Drone Start Attack"),
345         _("Drone Attack"),
346         _("Drone Dying"),
347         _("Drone Death"),
348         _("Drone Projectile Hit"),
349         _("Drone Projectile Flyby"),
350         _("Human Wail"),
351         _("Human Scream"),
352         _("Human Hit"),
353         _("Human Chatter"),
354         _("Assimilated Human Chatter"),
355         _("Human Trash Talk"),
356         _("Human Apology"),
357         _("Human Activation"),
358         _("Human Clear"),
359         _("Human Stop Shooting Me You Bastard"),
360         _("Human Area Secure"),
361         _("Kill The Player!"),
362         _("Water"),
363         _("Sewage"),
364         _("Lava"),
365         _("Goo"),
366         _("Under Stuff"),
367         _("Wind"),
368         _("Waterfall"),
369         _("Siren"),
370         _("Fan"),
371         _("S'pht Door"),
372         _("S'pht Platform"),
373         _("Alien Harmonics (Inf only)"),
374         _("Heavy S'pht Platform"),
375         _("Light Machinery"),
376         _("Heavy Machinery"),
377         _("Transformer"),
378         _("Sparking Transformer"),
379         _("Water Drip"),
380         _("Walking in Water"),
381         _("Exit Water"),
382         _("Enter Water"),
383         _("Small Water Splash"),
384         _("Medium Water Splash (unused)"),
385         _("Large Water Splash"),
386         _("Walking in Lava (unused)"),
387         _("Exit Lava"),
388         _("Enter Lava"),
389         _("Small Lava Splash"),
390         _("Medium Lava Splash (unused)"),
391         _("Large Lava Splash"),
392         _("Walking in Sewage (unused)"),
393         _("Exit Sewage"),
394         _("Enter Sewage"),
395         _("Small Sewage Splash"),
396         _("Medium Sewage Splash (unused)"),
397         _("Large Sewage Splash"),
398         _("Walking in Goo (unused)"),
399         _("Exit Goo (unused)"),
400         _("Enter Goo (unused)"),
401         _("Small Goo Splash (unused)"),
402         _("Medium Goo Splash (unused)"),
403         _("Large Goo Splash (unused)"),
404         _("Major Fusion Firing"),
405         _("Major Fusion Charged"),
406         _("Assault Rifle Reloading"),
407         _("Assault Rifle Shell Casings"),
408         _("Shotgun Firing"),
409         _("Shotgun Reloading"),
410         _("Ball Bounce"),
411         _("You Are It"),
412         _("Got The Ball"),
413         _("Computer Login"),
414         _("Computer Logout"),
415         _("Computer Page"),
416         _("Heavy S'pht Door"),
417         _("Heavy S'pht Door Opening"),
418         _("Heavy S'pht Door Closing"),
419         _("Heavy S'pht Door Open"),
420         _("Heavy S'pht Door Closed"),
421         _("Heavy S'pht Door Obstructed"),
422         _("Hunter Activate (unused)"),
423         _("Hunter Attack"),
424         _("Hunter Dying (unused)"),
425         _("Hunter Landing"),
426         _("Hunter Exploding"),
427         _("Hunter Projectile Hit"),
428         _("Hunter Projectile Flyby"),
429         _("Enforcer Activate"),
430         _("Enforcer Attack"),
431         _("Enforcer Projectile Hit"),
432         _("Enforcer Projctile Flyby"),
433         _("F'lickta Melee Attack"),
434         _("F'lickta Melee Attack Hit"),
435         _("F'lickta Projectile Attack"),
436         _("F'lickta Sewage Attack Hit"),
437         _("F'lickta Sewage Flyby"),
438         _("F'lickta Lava Attack Hit"),
439         _("F'lickta Lava Flyby"),
440         _("F'lickta Dying"),
441         _("Machine Binder"),
442         _("Machine Bookpress"),
443         _("Machine Puncher"),
444         _("Electric"),
445         _("Alarm"),
446         _("Night Wind"),
447         _("Surface Explosion"),
448         _("Underground Explosion"),
449         _("S'pht'Kr Attack"),
450         _("S'pht'Kr Hit"),
451         _("S'pht'Kr Flyby"),
452         _("S'pht'Kr Being Hit"),
453         _("S'pht'Kr Exploding"),
454         _("Tick Chatter"),
455         _("Tick Falling"),
456         _("Tick Flapping"),
457         _("Tick Exploding"),
458         _("Lamp Exploding"),
459         _("Pfhor Platform Start"),
460         _("Pfhor Platform Stop"),
461         _("Pfhor Platform"),
462         _("Pfhor Door Opening"),
463         _("Pfhor Door Closing"),
464         _("Pfhor Door Obstructed"),
465         _("Pfhor Door"),
466         _("Pfhor Switch Off"),
467         _("Pfhor Switch On"),
468         _("Juggernaut Firing"),
469         _("Juggernaut Warning"),
470         _("Juggernaut Exploding"),
471         _("Juggernaut Preparing to Fire"),
472         _("Enforcer Exploding"),
473         _("Alien Noise 1"),
474         _("Alien Noise 2"),
475         _("VacBob Wail"),
476         _("VacBob Scream"),
477         _("VacBob Hit"),
478         _("VacBob Chatter"),
479         _("Assimilated VacBob Chatter"),
480         _("VacBob Trash Talk"),
481         _("VacBob Apology"),
482         _("VacBob Activation"),
483         _("VacBob Clear"),
484         _("VacBob Stop Shooting Me You Bastard"),
485         _("VacBob Area Secure"),
486         _("VacBob Kill The Player"),
487 };
488
489 static const wxString shotNames[] = {
490         _("Missile"),
491         _("Grenade"),
492         _("Pistol Bullet"),
493         _("Assault Rifle Bullet"),
494         _("Shotgun Shot"),
495         _("Pfhor Staff"),
496         _("Pfhor Projectile"),
497         _("Flamethrower"),
498         _("S'pht Bolt"),
499         _("Seeking S'pht Bolt"),
500         _("Alien Weapon Blast"),
501         _("Fusion Bolt"),
502         _("Fusion Overload Bolt"),
503         _("Hunter Bolt"),
504         _("Fist Punch"),
505         _("unused 1"),
506         _("unused 2"),
507         _("Missile 2"),
508         _("Trooper Machine Gun"),
509         _("Trooper Grenade"),
510         _("S'pht'Kr Bolt"),
511         _("Major S'pht'Kr Bolt"),
512         _("Juggernaut Missile"),
513         _("Energy Drain"),
514         _("Major Energy Drain"),
515         _("Oxygen Drain"),
516         _("Drone Bolt"),
517         _("Fast Drone Bolt"),
518         _("Possessed Drone Bolt"),
519         _("Bouncing Grenade"),
520         _("Seeking Grenade"),
521         _("Ball"),
522         _("Fusion Media Backblast"),
523         _("Fusion Overload Media Backblast"),
524         _("Fusion Overload Self-Destruct"),
525         _("Flick'ta Claw"),
526         _("Flick'ta Glob"),
527         _("Flick'ta Lava Glob"),
528         _("SMG Bullet"),
529 };
530
531 static const wxString weaponNames[] = {
532         _("Fist"),
533         _("Pistol"),
534         _("Plasma Pistol"),
535         _("Assault Rifle"),
536         _("Missile Launcher"),
537         _("Flamethrower"),
538         _("Alien Weapon"),
539         _("Shotgun"),
540         _("The Ball"),
541         _("SMG")
542 };
543
544 DefaultNames* DefaultNames::mInstance;
545
546 DefaultNames::DefaultNames() 
547 {
548         for (int i = 0; i < 47; ++i) {
549                 mMap[wxT("alien")][i] = alienNames[i];
550         }
551
552         for (int i = 0; i < 16; ++i) {
553                 mMap[wxT("class")][i] = classNames[i];
554         }
555
556         for (int i = 0; i < 32; ++i) {
557                 mMap[wxT("collection")][i] = collectionNames[i];
558         }
559         
560         for (int i = 0; i < 24; ++i) {
561                 mMap[wxT("damage")][i] = damageNames[i];
562         }
563
564         for (int i = 0; i < 73; ++i) {
565                 mMap[wxT("effect")][i] = effectNames[i];
566         }
567
568         for (int i = 0; i < 36; ++i) {
569                 mMap[wxT("item")][i] = itemNames[i];
570         }
571
572         for (int i = 0; i < 215; ++i) {
573                 mMap[wxT("sound")][i] = soundNames[i];
574         }
575
576         for (int i = 0; i < 39; ++i) {
577                 mMap[wxT("shot")][i] = shotNames[i];
578         }
579
580         for (int i = 0; i < 10; ++i) {
581                 mMap[wxT("weapon")][i] = weaponNames[i];
582         }
583
584         wxTextFile namesFile(wxStandardPaths::Get().GetResourcesDir() + wxT("/DefaultNames.txt"));
585         
586         if (namesFile.Exists()) {
587                 if (namesFile.Open()) {
588                         for (wxString str = namesFile.GetFirstLine(); !namesFile.Eof(); str = namesFile.GetNextLine()) {
589                                 str.Trim(true);
590                                 str.Trim(false);
591
592                                 if (str[0] == '#') {
593                                         continue;
594                                 }
595
596                                 // parse into three tokens
597                                 wxStringTokenizer tokenizer(str);
598                                 if (tokenizer.CountTokens() >= 3) {
599                                         wxString key = tokenizer.GetNextToken();
600                                         wxString indexStr = tokenizer.GetNextToken();
601                                         wxString value = tokenizer.GetString();
602                                         
603                                         long index = 0;
604                                         if (!indexStr.ToLong(&index)) {
605                                                 continue;
606                                         }
607
608                                         mMap[key][index] = value;
609                                 }
610                         }
611                         
612                         namesFile.Close();
613                 }
614         }
615 }
616
617 wxString DefaultNames::Get(const wxString& set, int index)
618 {
619         std::map<wxString, std::map<int, wxString> >::const_iterator it = mMap.find(set);
620         if (it != mMap.end()) {
621                 std::map<int, wxString>::const_iterator kvp = it->second.find(index);
622                 if (kvp != it->second.end()) {
623                         return kvp->second;
624                 }
625         }
626
627         if (index == -1) {
628                 return _("None");
629         } else {
630                 return set + wxString::Format(wxT(" %i"), index);
631         }
632 }
633
634 std::vector<wxString> DefaultNames::GetArray(const wxString& set)
635 {
636         std::vector<wxString> v;
637
638         int size = mMap[set].rbegin()->first + 1;
639         if (size > 0) {
640                 v.resize(size);
641                 
642                 for (int i = 0; i < size; ++i) {
643                         v[i] = GetName(set, i);
644                 }
645         }
646
647         return v;
648 }