Settings.java
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: package xeij;
129:
130: import java.awt.*;
131: import java.awt.event.*;
132: import java.io.*;
133: import java.net.*;
134: import java.util.*;
135: import java.util.regex.*;
136: import java.util.zip.*;
137: import javax.swing.*;
138: import javax.swing.event.*;
139:
140: public class Settings {
141:
142:
143:
144: public static final String SGS_ACM_FRAME_KEY = "acm";
145: public static final String SGS_ATW_FRAME_KEY = "atw";
146: public static final String SGS_BFN_FRAME_KEY = "bfn";
147: public static final String SGS_BLG_FRAME_KEY = "blg";
148: public static final String SGS_DBP_FRAME_KEY = "dbp";
149: public static final String SGS_DDP_FRAME_KEY = "ddp";
150: public static final String SGS_DGT_FRAME_KEY = "dgt";
151: public static final String SGS_DMP_FRAME_KEY = "dmp";
152: public static final String SGS_DRP_FRAME_KEY = "drp";
153: public static final String SGS_FNT_FRAME_KEY = "fnt";
154: public static final String SGS_FRM_FRAME_KEY = "frm";
155: public static final String SGS_GRS_FRAME_KEY = "grs";
156: public static final String SGS_GSA_FRAME_KEY = "gsa";
157: public static final String SGS_KBS_FRAME_KEY = "kbs";
158: public static final String SGS_OLG_FRAME_KEY = "olg";
159: public static final String SGS_PAA_FRAME_KEY = "paa";
160: public static final String SGS_PFF_FRAME_KEY = "pff";
161: public static final String SGS_PFV_FRAME_KEY = "pfv";
162: public static final String SGS_PPI_FRAME_KEY = "ppi";
163: public static final String SGS_PRN_FRAME_KEY = "prn";
164: public static final String SGS_RBP_FRAME_KEY = "rbp";
165: public static final String SGS_RTL_FRAME_KEY = "rtl";
166: public static final String SGS_SMN_FRAME_KEY = "smn";
167: public static final String SGS_SMT_FRAME_KEY = "smt";
168: public static final String SGS_SPV_FRAME_KEY = "spv";
169: public static final String SGS_PLV_FRAME_KEY = "plv";
170: public static final String SGS_TRM_FRAME_KEY = "trm";
171: public static final String[] SGS_FRAME_KEYS = {
172: SGS_ACM_FRAME_KEY,
173: SGS_ATW_FRAME_KEY,
174: SGS_BFN_FRAME_KEY,
175: SGS_BLG_FRAME_KEY,
176: SGS_DBP_FRAME_KEY,
177: SGS_DDP_FRAME_KEY,
178: SGS_DGT_FRAME_KEY,
179: SGS_DMP_FRAME_KEY,
180: SGS_DRP_FRAME_KEY,
181: SGS_FNT_FRAME_KEY,
182: SGS_FRM_FRAME_KEY,
183: SGS_GRS_FRAME_KEY,
184: SGS_GSA_FRAME_KEY,
185: SGS_KBS_FRAME_KEY,
186: SGS_OLG_FRAME_KEY,
187: SGS_PAA_FRAME_KEY,
188: SGS_PFF_FRAME_KEY,
189: SGS_PFV_FRAME_KEY,
190: SGS_PPI_FRAME_KEY,
191: SGS_PRN_FRAME_KEY,
192: SGS_RBP_FRAME_KEY,
193: SGS_RTL_FRAME_KEY,
194: SGS_SMN_FRAME_KEY,
195: SGS_SMT_FRAME_KEY,
196: SGS_SPV_FRAME_KEY,
197: SGS_PLV_FRAME_KEY,
198: SGS_TRM_FRAME_KEY,
199: };
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211: public static final String SGS_DEFAULT_PARAMETERS = (
212:
213: "verbose;on;" +
214: "tinilog;off;" +
215:
216:
217: "saveonexit;on;" +
218: "xxxopen;on;" +
219: "config;;" +
220: "lang;en;" +
221: "home;;" +
222: "dir;;" +
223:
224: "hsb;240,240,240,70,50,30,0,50,100;" +
225: "hhssbb;none;" +
226: "fontsize;14;" +
227:
228: "keyboard;standard;" +
229: "hidekeyboard;on;" +
230: "keymapus;off;" +
231: "keymap;;" +
232: "zkeyboard;off;" +
233: "zkeymap;;" +
234:
235: "f11key;fullscreen;" +
236: "shiftf11key;maximized;" +
237: "ctrlf11key;donothing;" +
238: "altf11key;donothing;" +
239: "f12key;seamless;" +
240: "shiftf12key;donothing;" +
241: "ctrlf12key;donothing;" +
242: "altf12key;donothing;" +
243: "wheel;seamless;" +
244: "shiftwheel;donothing;" +
245: "ctrlwheel;donothing;" +
246: "altwheel;donothing;" +
247: "wheelup;trace1;" +
248: "shiftwheelup;trace10;" +
249: "ctrlwheelup;trace100;" +
250: "altwheelup;donothing;" +
251: "wheeldown;step1;" +
252: "shiftwheeldown;step10;" +
253: "ctrlwheeldown;step100;" +
254: "altwheeldown;return;" +
255: "button4;donothing;" +
256: "shiftbutton4;donothing;" +
257: "ctrlbutton4;donothing;" +
258: "altbutton4;donothing;" +
259: "button5;donothing;" +
260: "shiftbutton5;donothing;" +
261: "ctrlbutton5;donothing;" +
262: "altbutton5;donothing;" +
263: "mousewheel;;" +
264:
265: "gifwaitingtime;;" +
266: "gifrecordingtime;10;" +
267: "gifmagnification;100;" +
268: "gifinterpolation;bilinear;" +
269:
270: "flrenabled;off;" +
271: "flrpalette;on;" +
272: "flrcontrast;on;" +
273: "flrscreen;on;" +
274: "flrwavelength;20;" +
275: "flrlimit;13;" +
276: "flrdelay;20;" +
277: "flrinformed;off;" +
278:
279: "scaling;fitinwindow;" +
280: "fixedscale;100;" +
281: "aspectratio256x256;4:3;" +
282: "aspectratio384x256;4:3;" +
283: "aspectratio512x512;4:3;" +
284: "aspectratio640x480;4:3;" +
285: "aspectratio768x512;3:2;" +
286: "aspectratio1024x848;64:53;" +
287: "interpolation;bilinear;" +
288: "refreshrate;none;" +
289: "adjustvsync;off;" +
290: "roundedcornerratio;0;" +
291:
292: "usecanvas;on;" +
293: "rotation;0;" +
294:
295: "seamless;on;" +
296: "followscroll;on;" +
297: "ctrlright;off;" +
298: "edgeaccel;off;" +
299: "mousespeed;;" +
300: "hostspixelunits;off;" +
301:
302: "textcopyarea;display;" +
303: "textcopy;off;" +
304:
305: "model;Hybrid;" +
306: "mpu010;off;" +
307: "mpu;none;" +
308: "clock;none;" +
309: "mhz;200;" +
310: "util;off;" +
311: "ratio;100;" +
312: "waitcycles;on;" +
313:
314: "copro0;2;" +
315: "copro1;2;" +
316: "copro2;2;" +
317: "onchipfpu;7;" +
318:
319: "fefunc;on;" +
320: "rejectfloat;off;" +
321:
322: "himem68000;off;" +
323: "highmemory;;" +
324: "highmemorysave;off;" +
325: "highmemorydata;;" +
326: "highmemory060turbo;off;" +
327: "localmemory;128;" +
328: "localmemorysave;off;" +
329: "localmemorydata;;" +
330: "cutfc2pin;off;" +
331:
332: "memory;12;" +
333: "memorysave;on;" +
334: "memorydata;;" +
335:
336: "pastepipe;off;" +
337: "pipeencoding;sjis;" +
338:
339: "intermittent;0;" +
340: "stereoscopic;off;" +
341: "stereoscopicmethod;nakedeyecrossing;" +
342: "extendedgraphic;off;" +
343: "scanline;medium;" +
344: "dotclock;,,;" +
345: "eleventhbit;off;" +
346: "sphericalscrolling;off;" +
347: "r00bit0zero;off;" +
348:
349: "sprras;32;" +
350: "dblspr;off;" +
351: "numspr;128;" +
352: "sprbank;off;" +
353: "spr768x512;off;" +
354: "spr512bg1;off;" +
355: "sprrcscroll;off;" +
356: "sprfpm;off;" +
357:
358: "sound;on;" +
359: "volume;20;" +
360: "soundinterpolation;linear;" +
361:
362: "opmoutput;on;" +
363:
364: "pcmoutput;on;" +
365: "pcminterpolation;linear;" +
366: "pcmoscfreq;0;" +
367:
368:
369: "fdreadonly;off;" +
370: "fdappreboot;off;" +
371:
372:
373: "sareadonly;off;" +
374: "saappreboot;off;" +
375:
376:
377: "screadonly;off;" +
378: "scappreboot;off;" +
379:
380: "hcddebug;off;" +
381: "hcdconnect;off;" +
382: "hcdscsiid;6;" +
383: "hcdvolume;25;" +
384:
385:
386: "hfreadonly;off;" +
387: "hfappreboot;off;" +
388: "utf8warning;off;" +
389:
390: "joykey;on;" +
391: "joyauto;on;" +
392: "joyblock;on;" +
393: "normal2button1;;" +
394: "normal2button2;;" +
395: "megadrive3button1;;" +
396: "megadrive3button2;;" +
397: "megadrive6button1;;" +
398: "megadrive6button2;;" +
399: "cyberstickdigital1;;" +
400: "cyberstickdigital2;;" +
401: "cyberstickanalog1;;" +
402: "cyberstickanalog2;;" +
403: "shiromadokun1;;" +
404: "shiromadokun2;;" +
405: "joystick1;normal2button1;" +
406: "joystick2;normal2button2;" +
407: "xinput;off;" +
408:
409: "scsiex;off;" +
410:
411: "boot;default;" +
412: "keydly;-1;" +
413: "keyrep;-1;" +
414: "sram;none;" +
415: "sramdata;;" +
416: "sramsize;16;" +
417: "romdb;none;" +
418: "modifymemorysize;on;" +
419: "srambuserror;off;" +
420: "cache;none;" +
421: "stupsnd;none;" +
422:
423: "bankdata;;" +
424:
425: "rom;none;" +
426: "cgrom;none;" +
427: "rom30;none;" +
428: "scsiinrom;none;" +
429: "scsiexrom;none;" +
430: "iplrom;none;" +
431: "x68000logo;none;" +
432: "iplrom16style;7;" +
433: "iplrom256k;off;" +
434: "iplrom16;off;" +
435: "omusubi;off;" +
436:
437: "prnauto;off;" +
438: "prnpath;printer;" +
439: "prndipsw;;" +
440: "prnsize;A4;" +
441: "prnorientation;portrait;" +
442: "prntopmargin;11;" +
443: "prnleftmargin;14;" +
444: "prnrightmargin;14;" +
445: "prnbottommargin;11;" +
446: "prnrotation;;" +
447: "prndarkmode;off;" +
448: "prnonline;on;" +
449: "prnsinglecolor;;" +
450: "prnscalefactor;;" +
451:
452: "sccfreq;5000000;" +
453:
454: "spvbank;0;" +
455: "spvblock;-1;" +
456: "spvflip;-1;" +
457: "spvhex;off;" +
458: "spvscale;0;" +
459: "spvsize;-1;" +
460:
461: "plvarrgt;2;" +
462: "plvhex;off;" +
463: "plvscale;0;" +
464:
465: "rs232cconnection;Terminal+%E2%87%94+AUX;" +
466: "terminalsettings;19200/B8/PN/S1/RTS;" +
467: "additionalport;none;" +
468: "tcpiphost;0.0.0.0;" +
469: "tcpipport;54321;" +
470: "tcpiputf8;off;" +
471:
472: "pppaddress;192.168.10.1:192.168.10.2;" +
473: "pppdebug;off;" +
474: "pppdirect;off;" +
475: "ppplog;off;" +
476: "pppserver;off;" +
477:
478: "mercury;off;" +
479: "mercuryoe;on;" +
480:
481: "xt3dipsw;3;" +
482: "xt3memorykb;256;" +
483: "xt3memorydata;;" +
484: "xt3memorysave;off;"
485: );
486:
487: public static final String SGS_APPDATA_FOLDER = "XEiJ";
488: public static final String SGS_INI = "XEiJ.ini";
489:
490: public static final Pattern SGS_BOOT_DEVICE_PATTERN = Pattern.compile ("^(?:default|std|(?:fd|hd|sc|hf)\\d+|r[oa]m\\$[0-9A-Fa-f]+)$", Pattern.CASE_INSENSITIVE);
491:
492: public static String sgsAppDataRoamingFolder;
493: public static String sgsAppDataLocalFolder;
494: public static String sgsHomeDirectory;
495: public static String sgsCurrentDirectory;
496:
497: public static File sgsIniParentDirectory;
498: public static String sgsIniParentPath;
499: public static File sgsIniFile;
500: public static String sgsIniPath;
501:
502: public static boolean sgsSaveOnExit;
503: public static boolean sgsXxxOpen;
504: public static JCheckBoxMenuItem sgsSaveOnExitCheckBox;
505: public static String sgsSaveiconValue;
506: public static String sgsIrbbenchValue;
507:
508: public static HashMap<String,String> sgsDefaultMap;
509: public static HashMap<String,String> sgsStartMap;
510: public static HashMap<String,String> sgsCurrentMap;
511: public static HashMap<String,HashMap<String,String>> sgsRootMap;
512:
513: public static JMenu sgsMenu;
514:
515:
516:
517:
518:
519:
520: public static final Comparator<String> DictionaryComparator = new Comparator<String> () {
521: @Override public int compare (String s1, String s2) {
522: int l1 = s1.length ();
523: int l2 = s2.length ();
524: int b1, b2;
525: int e1, e2;
526: int f = 0;
527: compare:
528: {
529: for (b1 = 0, b2 = 0; b1 < l1 && b2 < l2; b1 = e1, b2 = e2) {
530: int c1, c2;
531:
532: e1 = b1;
533: c1 = s1.charAt (e1);
534: c1 = ('0' - 1) - c1 & c1 - ('9' + 1);
535: for (e1++; e1 < l1; e1++) {
536: c2 = s1.charAt (e1);
537: c2 = ('0' - 1) - c2 & c2 - ('9' + 1);
538: if ((c1 ^ c2) < 0) {
539: break;
540: }
541: c1 = c2;
542: }
543: e2 = b2;
544: c1 = s2.charAt (e2);
545: c1 = ('0' - 1) - c1 & c1 - ('9' + 1);
546: for (e2++; e2 < l2; e2++) {
547: c2 = s2.charAt (e2);
548: c2 = ('0' - 1) - c2 & c2 - ('9' + 1);
549: if ((c1 ^ c2) < 0) {
550: break;
551: }
552: c1 = c2;
553: }
554: c1 = s1.charAt (b1);
555: c2 = s2.charAt (b2);
556: if ((('0' - 1) - c1 & c1 - ('9' + 1) & ('0' - 1) - c2 & c2 - ('9' + 1)) < 0) {
557:
558: for (; b1 < e1 && s1.charAt (b1) == '0'; b1++) {
559: }
560: for (; b2 < e2 && s2.charAt (b2) == '0'; b2++) {
561: }
562:
563: f = (e1 - b1) - (e2 - b2);
564: if (f != 0) {
565: break compare;
566: }
567:
568: for (; b1 < e1 && b2 < e2; b1++, b2++) {
569: f = s1.charAt (b1) - s2.charAt (b2);
570: if (f != 0) {
571: break compare;
572: }
573: }
574: } else {
575:
576:
577: for (; b1 < e1 && b2 < e2; b1++, b2++) {
578: c1 = s1.charAt (b1);
579: c2 = s2.charAt (b2);
580: f = ((c1 + ((('A' - 1) - c1 & c1 - ('Z' + 1)) >> 31 & 'a' - 'A')) -
581: (c2 + ((('A' - 1) - c2 & c2 - ('Z' + 1)) >> 31 & 'a' - 'A')));
582: if (f != 0) {
583: break compare;
584: }
585: }
586: if (b1 < e1 || b2 < e2) {
587:
588:
589:
590:
591: f = (e1 - b1) - (e2 - b2);
592: break compare;
593: }
594: }
595: }
596: f = (l1 - b1) - (l2 - b2);
597:
598: if (f == 0) {
599: for (b1 = 0, b2 = 0; b1 < l1 && b2 < l2; b1++, b2++) {
600: f = s1.charAt (b1) - s2.charAt (b2);
601: if (f != 0) {
602: break compare;
603: }
604: }
605: }
606: }
607: return (f >> 31) - (-f >> 31);
608: }
609: };
610:
611:
612:
613: public static void sgsInit () {
614:
615: sgsAppDataRoamingFolder = null;
616: sgsAppDataLocalFolder = null;
617: sgsHomeDirectory = null;
618: sgsCurrentDirectory = null;
619:
620: sgsIniParentDirectory = null;
621: sgsIniParentPath = null;
622: sgsIniFile = null;
623: sgsIniPath = null;
624:
625: sgsSaveOnExit = true;
626: sgsSaveOnExitCheckBox = null;
627:
628: sgsSaveiconValue = null;
629: sgsIrbbenchValue = null;
630:
631:
632:
633:
634: sgsDefaultMap = new HashMap<String,String> ();
635: {
636: String[] a = SGS_DEFAULT_PARAMETERS.split (";");
637: for (int i = 0, l = a.length; i < l; i += 2) {
638: String key = a[i];
639: String value = i + 1 < l ? a[i + 1] : "";
640: sgsDefaultMap.put (key, value);
641: }
642: }
643:
644:
645:
646:
647:
648:
649:
650:
651: for (int i = 0; i < FDC.FDC_MAX_UNITS; i++) {
652: sgsDefaultMap.put ("fd" + i, "none");
653: }
654: for (int i = 0; i < 16; i++) {
655: sgsDefaultMap.put ("hd" + i, "none");
656: sgsDefaultMap.put ("sa" + i, "none");
657: sgsDefaultMap.put ("sc" + i, "none");
658: }
659: for (int i = 0; i < HFS.HFS_MAX_UNITS; i++) {
660: sgsDefaultMap.put ("hf" + i, "none");
661: }
662:
663: for (int i = 0; i < JFileChooser2.MAXIMUM_HISTORY_COUNT; i++) {
664: sgsDefaultMap.put ("fdhistory" + i, "none");
665: sgsDefaultMap.put ("sahistory" + i, "none");
666: sgsDefaultMap.put ("schistory" + i, "none");
667: sgsDefaultMap.put ("hfhistory" + i, "none");
668: }
669:
670: for (String key : SGS_FRAME_KEYS) {
671: sgsDefaultMap.put (key + "rect", "");
672: sgsDefaultMap.put (key + "stat", "normal");
673: sgsDefaultMap.put (key + "open", "off");
674: }
675:
676:
677:
678:
679: sgsStartMap = new HashMap<String,String> (sgsDefaultMap);
680:
681:
682: sgsStartMap.put ("hf0", sgsHomeDirectory != null ? sgsHomeDirectory : HFS.HFS_DUMMY_UNIT_NAME);
683:
684:
685: sgsStartMap.put ("lang", Multilingual.mlnLang);
686:
687: if (false) {
688:
689: System.out.println ("\n[System.getenv()]");
690: new TreeMap<String,String> (System.getenv ()).forEach ((k, v) -> System.out.println (k + " = " + v));
691: }
692: if (false) {
693:
694: System.out.println ("\n[System.getProperties()]");
695: TreeMap<String,String> m = new TreeMap<String,String> ();
696: System.getProperties ().forEach ((k, v) -> m.put (k.toString (), v.toString ()));
697: m.forEach ((k, v) -> System.out.println (k + " = " + v));
698: }
699:
700:
701: boolean isWindows = System.getProperty ("os.name").indexOf ("Windows") >= 0;
702: sgsAppDataRoamingFolder = isWindows ? System.getenv ("APPDATA") : null;
703: sgsAppDataLocalFolder = isWindows ? System.getenv ("LOCALAPPDATA") : null;
704:
705:
706: sgsHomeDirectory = System.getProperty ("user.home");
707:
708:
709: sgsCurrentDirectory = System.getProperty ("user.dir");
710:
711:
712: if (sgsAppDataRoamingFolder != null) {
713: sgsIniParentPath = new File (sgsAppDataRoamingFolder + File.separator + SGS_APPDATA_FOLDER).getAbsolutePath ();
714: sgsIniParentDirectory = new File (sgsIniParentPath);
715: sgsIniPath = sgsIniParentPath + File.separator + SGS_INI;
716: sgsIniFile = new File (sgsIniPath);
717: } else {
718: sgsIniParentPath = null;
719: sgsIniParentDirectory = null;
720: sgsIniPath = new File ((sgsHomeDirectory != null ? sgsHomeDirectory :
721: sgsCurrentDirectory != null ? sgsCurrentDirectory :
722: ".") + File.separator + SGS_INI).getAbsolutePath ();
723: sgsIniFile = new File (sgsIniPath);
724: }
725:
726:
727:
728:
729: sgsCurrentMap = new HashMap<String,String> (sgsStartMap);
730: sgsCurrentMap.put ("_", "");
731:
732:
733: sgsRootMap = new HashMap<String,HashMap<String,String>> ();
734: sgsRootMap.put ("", sgsCurrentMap);
735:
736:
737:
738: HashMap<String,String> argumentMap = new HashMap<String,String> ();
739: int fdNumber = 0;
740: int hdNumber = 0;
741: int scNumber = 0;
742: int hfNumber = 0;
743: for (int i = 0; i < XEiJ.prgArgs.length; i++) {
744: String key = null;
745: String value = XEiJ.prgArgs[i];
746: arg:
747: {
748: boolean boot = false;
749: if (value.startsWith ("-")) {
750:
751: int k = value.indexOf ('=', 1);
752: if (k >= 0) {
753: key = value.substring (1, k);
754: value = value.substring (k + 1);
755: } else {
756:
757: key = value.substring (1);
758: value = (i + 1 < XEiJ.prgArgs.length && !XEiJ.prgArgs[i + 1].startsWith ("-") ?
759: XEiJ.prgArgs[++i]
760: :
761: "1");
762: }
763: if (!key.equalsIgnoreCase ("boot")) {
764: break arg;
765: }
766: boot = true;
767: }
768:
769: if (SGS_BOOT_DEVICE_PATTERN.matcher (value).matches ()) {
770:
771: key = "boot";
772: break arg;
773: }
774: String valueWithoutColonR = value.endsWith (":R") ? value.substring (0, value.length () - 2) : value;
775: File file = new File (valueWithoutColonR);
776: if (file.isDirectory ()) {
777: key = "hf" + hfNumber++;
778: } else if (file.isFile ()) {
779:
780:
781: if (valueWithoutColonR.toUpperCase ().endsWith (".HDF")) {
782: key = "sa" + hdNumber++;
783: } else if (valueWithoutColonR.toUpperCase ().endsWith (".HDS")) {
784: key = "sc" + scNumber++;
785: } else if (FDMedia.fdmPathToMedia (valueWithoutColonR, null) != null) {
786: key = "fd" + fdNumber++;
787: } else if (HDMedia.hdmPathToMedia (valueWithoutColonR, null) != null) {
788: key = "sa" + hdNumber++;
789: } else {
790: key = "sc" + scNumber++;
791: }
792: } else {
793: String[] zipSplittedName = XEiJ.RSC_ZIP_SEPARATOR.split (valueWithoutColonR, 2);
794: if (zipSplittedName.length == 2 &&
795: new File (zipSplittedName[0]).isFile ()) {
796: if (FDMedia.fdmPathToMedia (valueWithoutColonR, null) != null) {
797: key = "fd" + fdNumber++;
798: } else if (HDMedia.hdmPathToMedia (valueWithoutColonR, null) != null) {
799: key = "sa" + hdNumber++;
800: } else {
801: System.out.println (Multilingual.mlnJapanese ? value + " は不明な起動デバイスです" :
802: value + " is unknown boot device");
803: continue;
804: }
805: } else {
806: System.out.println (Multilingual.mlnJapanese ? value + " は不明な起動デバイスです" :
807: value + " is unknown boot device");
808: continue;
809: }
810: }
811: if (boot) {
812: sgsPutParameter (argumentMap, "boot", key);
813: }
814: }
815:
816: switch (key) {
817: case "ini":
818: sgsIniParentPath = null;
819: sgsIniParentDirectory = null;
820: sgsIniPath = new File (value).getAbsolutePath ();
821: sgsIniFile = new File (sgsIniPath);
822: break;
823: case "saveicon":
824: sgsSaveiconValue = value;
825: break;
826: case "irbbench":
827: sgsIrbbenchValue = value;
828: break;
829: default:
830: sgsPutParameter (argumentMap, key, value);
831: }
832: }
833: System.out.println (Multilingual.mlnJapanese ? "設定ファイルは " + sgsIniPath + " です" :
834: "INI file is " + sgsIniPath);
835:
836:
837: sgsDecodeRootMap (sgsLoadIniFile ());
838:
839:
840: if (argumentMap.containsKey ("config")) {
841: String name = argumentMap.get ("config");
842: if (name.equals ("default")) {
843: sgsCurrentMap.clear ();
844: sgsCurrentMap = new HashMap<String,String> (sgsStartMap);
845: sgsCurrentMap.put ("_", "");
846: sgsRootMap.put ("", sgsCurrentMap);
847: } else if (name.length () != 0 &&
848: sgsRootMap.containsKey (name)) {
849: sgsCurrentMap.clear ();
850: sgsCurrentMap = new HashMap<String,String> (sgsRootMap.get (name));
851: sgsCurrentMap.put ("_", "");
852: sgsRootMap.put ("", sgsCurrentMap);
853: }
854: argumentMap.remove ("config");
855: }
856:
857:
858:
859: for (String key : argumentMap.keySet ()) {
860: sgsCurrentMap.put (key, argumentMap.get (key));
861: }
862:
863:
864: String paramLang = sgsCurrentMap.get ("lang").toLowerCase ();
865: Multilingual.mlnChange (paramLang.equals ("ja") ? "ja" : "en");
866: XEiJ.prgVerbose = sgsGetOnOff ("verbose");
867: XEiJ.prgTiniLog = sgsGetOnOff ("tinilog");
868:
869: sgsSaveOnExit = sgsGetOnOff ("saveonexit");
870: sgsXxxOpen = sgsGetOnOff ("xxxopen");
871:
872:
873:
874:
875:
876:
877:
878:
879:
880: if (CRTC.CRT_ENABLE_INTERMITTENT) {
881: CRTC.crtIntermittentInterval = XEiJ.fmtParseInt (sgsCurrentMap.get ("intermittent"), 0, 0, 4, 0);
882: }
883: if (CRTC.CRT_EXTENDED_GRAPHIC) {
884: CRTC.crtExtendedGraphicRequest = sgsGetOnOff ("extendedgraphic");
885: }
886:
887: SoundSource.sndPlayOn = sgsGetOnOff ("sound");
888: SoundSource.sndVolume = XEiJ.fmtParseInt (sgsCurrentMap.get ("volume"), 0, 0, SoundSource.SND_VOLUME_MAX, SoundSource.SND_VOLUME_DEFAULT);
889: {
890: String s = sgsCurrentMap.get ("soundinterpolation").toLowerCase ();
891: SoundSource.sndRateConverter = (s.equals ("thinning") ? SoundSource.SND_CHANNELS == 1 ? SoundSource.SNDRateConverter.THINNING_MONO : SoundSource.SNDRateConverter.THINNING_STEREO :
892: s.equals ("linear") ? SoundSource.SND_CHANNELS == 1 ? SoundSource.SNDRateConverter.LINEAR_MONO : SoundSource.SNDRateConverter.LINEAR_STEREO :
893: s.equals ("constant-area") ? SoundSource.SNDRateConverter.CONSTANT_AREA_STEREO_48000 :
894: s.equals ("linear-area") ? SoundSource.SNDRateConverter.LINEAR_AREA_STEREO_48000 :
895: SoundSource.SND_CHANNELS == 1 ? SoundSource.SNDRateConverter.LINEAR_MONO : SoundSource.SNDRateConverter.LINEAR_STEREO);
896: }
897:
898: OPM.opmOutputMask = sgsGetOnOff ("opmoutput") ? -1 : 0;
899:
900: {
901: ADPCM.pcmOutputOn = sgsGetOnOff ("pcmoutput");
902: String s = sgsCurrentMap.get ("pcminterpolation").toLowerCase ();
903: ADPCM.pcmInterpolationAlgorithm = (s.equals ("constant") ? ADPCM.PCM_INTERPOLATION_CONSTANT :
904: s.equals ("linear") ? ADPCM.PCM_INTERPOLATION_LINEAR :
905: s.equals ("hermite") ? ADPCM.PCM_INTERPOLATION_HERMITE :
906: ADPCM.PCM_INTERPOLATION_LINEAR);
907: ADPCM.pcmOSCFreqRequest = XEiJ.fmtParseInt (sgsCurrentMap.get ("pcmoscfreq"), 0, 0, 1, 0);
908: }
909:
910:
911:
912:
913:
914:
915:
916:
917:
918:
919:
920:
921:
922:
923:
924: for (String key : SGS_FRAME_KEYS) {
925:
926: int[] rect = sgsGetIntArray (key + "rect", 4, 0);
927:
928: String s = sgsGetString (key + "stat").toLowerCase ();
929: int state = (s.equals ("iconified") ? Frame.ICONIFIED :
930: s.equals ("maximized") ? Frame.MAXIMIZED_BOTH :
931: s.equals ("h-maximized") ? Frame.MAXIMIZED_HORIZ :
932: s.equals ("v-maximized") ? Frame.MAXIMIZED_VERT :
933: Frame.NORMAL);
934:
935: boolean opened = sgsXxxOpen && sgsGetOnOff (key + "open");
936: RestorableFrame.rfmSet (key, rect, state, opened);
937: }
938:
939: if (sgsIrbbenchValue != null) {
940: InstructionBenchmark.irbBench (sgsIrbbenchValue);
941: System.exit (0);
942: }
943:
944: }
945:
946:
947:
948: public static void sgsTini () {
949: if (sgsSaveOnExit) {
950: sgsSaveAllSettings ();
951: }
952: }
953:
954:
955:
956:
957:
958:
959: public static String sgsGetString (String key) {
960: return sgsGetString (key, "");
961: }
962: public static String sgsGetString (String key, String def) {
963: String value = sgsCurrentMap.get (key);
964: if (value == null) {
965: System.err.println ("sgsGetString: undefined key " + key);
966: return def;
967: }
968: value = value.trim ();
969: return value.equalsIgnoreCase ("none") || value.equals ("") ? def : value;
970: }
971:
972:
973:
974: public static void sgsPutString (String key, String value) {
975: if (!sgsCurrentMap.containsKey (key)) {
976: System.err.println ("sgsPutString: undefined key " + key);
977: return;
978: }
979: value = value.trim ();
980: sgsCurrentMap.put (key, value.length () == 0 ? "none" : value);
981: }
982:
983:
984:
985:
986:
987: public static boolean sgsGetOnOff (String key) {
988: return sgsGetOnOff (key, false);
989: }
990: public static boolean sgsGetOnOff (String key, boolean def) {
991: String value = sgsCurrentMap.get (key);
992: if (value == null) {
993: System.err.println ("sgsGetOnOff: undefined key " + key);
994: return false;
995: }
996: value = value.trim ();
997: return (value.equals ("0") ||
998: value.equalsIgnoreCase ("off") ||
999: value.equalsIgnoreCase ("no") ? false :
1000: value.equals ("1") ||
1001: value.equalsIgnoreCase ("on") ||
1002: value.equalsIgnoreCase ("yes") ? true :
1003: def);
1004: }
1005:
1006:
1007:
1008: public static void sgsPutOnOff (String key, boolean b) {
1009: if (!sgsCurrentMap.containsKey (key)) {
1010: System.err.println ("sgsPutOnOff: undefined key " + key);
1011: return;
1012: }
1013: sgsCurrentMap.put (key, b ? "on" : "off");
1014: }
1015:
1016:
1017:
1018:
1019:
1020: public static int sgsGetInt (String key) {
1021: return sgsGetInt (key, 0, Integer.MIN_VALUE, Integer.MAX_VALUE);
1022: }
1023: public static int sgsGetInt (String key, int i0) {
1024: return sgsGetInt (key, i0, Integer.MIN_VALUE, Integer.MAX_VALUE);
1025: }
1026: public static int sgsGetInt (String key, int i0, int min, int max) {
1027: String value = sgsCurrentMap.get (key);
1028: if (value == null) {
1029: System.err.println ("sgsGetInt: undefined key " + key);
1030: return i0;
1031: }
1032: value = value.trim ();
1033: if (value.length () != 0) {
1034: try {
1035: int i = Integer.parseInt (value, 10);
1036: if (min <= i && i <= max) {
1037: return i;
1038: }
1039: } catch (NumberFormatException nfe) {
1040: }
1041: }
1042: return i0;
1043: }
1044:
1045:
1046:
1047:
1048: public static void sgsPutInt (String key, int i) {
1049: sgsPutInt (key, i, 0);
1050: }
1051: public static void sgsPutInt (String key, int i, int i0) {
1052: if (!sgsCurrentMap.containsKey (key)) {
1053: System.err.println ("sgsPutInt: undefined key " + key);
1054: return;
1055: }
1056: sgsCurrentMap.put (key, i == i0 ? "" : String.valueOf (i));
1057: }
1058:
1059:
1060:
1061:
1062:
1063:
1064:
1065: public static int[] sgsGetIntArray (String key) {
1066: return sgsGetIntArray (key, -1, 0);
1067: }
1068: public static int[] sgsGetIntArray (String key, int n) {
1069: return sgsGetIntArray (key, n, 0);
1070: }
1071: public static int[] sgsGetIntArray (String key, int n, int v) {
1072: String value = sgsCurrentMap.get (key);
1073: if (value == null) {
1074: System.err.println ("sgsGetIntArray: undefined key " + key);
1075: value = "";
1076: }
1077: String[] sa = value.length () == 0 ? new String[0] : value.split (",");
1078: if (n < 0) {
1079: n = sa.length;
1080: }
1081: int[] ia = new int[n];
1082: Arrays.fill (ia, v);
1083: for (int i = 0; i < n && i < sa.length; i++) {
1084: String s = sa[i].trim ();
1085: if (s.length () != 0) {
1086: try {
1087: ia[i] = Integer.parseInt (s, 10);
1088: } catch (NumberFormatException nfe) {
1089: }
1090: }
1091: }
1092: return ia;
1093: }
1094:
1095:
1096:
1097:
1098: public static void sgsPutIntArray (String key, int[] ia) {
1099: sgsPutIntArray (key, ia, 0);
1100: }
1101: public static void sgsPutIntArray (String key, int[] ia, int v) {
1102: if (!sgsCurrentMap.containsKey (key)) {
1103: System.err.println ("sgsPutIntArray: undefined key " + key);
1104: return;
1105: }
1106: int n = ia.length;
1107: while (0 < n && ia[n - 1] == v) {
1108: n--;
1109: }
1110: StringBuilder sb = new StringBuilder ();
1111: for (int i = 0; i < n; i++) {
1112: if (i != 0) {
1113: sb.append (',');
1114: }
1115: if (ia[i] != v) {
1116: sb.append (ia[i]);
1117: }
1118: }
1119: sgsCurrentMap.put (key, sb.toString ());
1120: }
1121:
1122:
1123:
1124:
1125: public static byte[] sgsGetData (String key) {
1126: String value = sgsCurrentMap.get (key);
1127: if (value == null) {
1128: System.err.println ("sgsGetData: undefined key " + key);
1129: value = "";
1130: }
1131: if (value.length () == 0) {
1132: return new byte[0];
1133: }
1134: if (false) {
1135: return ByteArray.byaDecodeGzip (ByteArray.byaDecodeBase64 (value));
1136: } else {
1137:
1138: byte[] decoded;
1139: try {
1140: decoded = Base64.getDecoder ().decode (value);
1141: } catch (IllegalArgumentException iae) {
1142: iae.printStackTrace ();
1143: return new byte[0];
1144: }
1145:
1146: final int step = 1024 * 1024 * 10;
1147: int length = 0;
1148: int next = step;
1149: ByteArrayOutputStream baos = new ByteArrayOutputStream ();
1150: ByteArrayInputStream bais = new ByteArrayInputStream (decoded);
1151: try (GZIPInputStream gzipis = new GZIPInputStream (bais)) {
1152: byte[] temp = new byte[65536];
1153: for (;;) {
1154: int k = gzipis.read (temp, 0, temp.length);
1155: if (k < 0) {
1156: break;
1157: }
1158: if (0 < k) {
1159: baos.write (temp, 0, k);
1160: length += k;
1161: if (next <= length) {
1162: if (next == step) {
1163: System.out.print (key);
1164: }
1165: System.out.print (".");
1166: next += step;
1167: }
1168: }
1169: }
1170: if (step <= length) {
1171: if (next - step < length) {
1172: System.out.print (".");
1173: }
1174: System.out.println ();
1175: }
1176: } catch (IOException ioe) {
1177: ioe.printStackTrace ();
1178: return new byte[0];
1179: }
1180: return baos.toByteArray ();
1181: }
1182: }
1183:
1184:
1185:
1186:
1187:
1188:
1189: public static void sgsPutData (String key, byte[] array) {
1190: sgsPutData (key, array, 0, array.length);
1191: }
1192: public static void sgsPutData (String key, byte[] array, int offset, int length) {
1193: if (!sgsCurrentMap.containsKey (key)) {
1194: System.err.println ("sgsPutData: undefined key " + key);
1195: return;
1196: }
1197: boolean zero = true;
1198: for (int i = 0; i < length; i++) {
1199: if (array[offset + i] != 0) {
1200: zero = false;
1201: break;
1202: }
1203: }
1204: String value = "";
1205: if (!zero) {
1206: if (false) {
1207: value = ByteArray.byaEncodeBase64 (ByteArray.byaEncodeGzip (array, offset, length));
1208: } else {
1209: do {
1210:
1211: final int step = 1024 * 1024 * 10;
1212: if (step <= length) {
1213: System.out.print (key);
1214: }
1215: ByteArrayOutputStream baos = new ByteArrayOutputStream ();
1216: try (GZIPOutputStream gzipos = new GZIPOutputStream (baos)) {
1217: for (int i = 0; i < length; i += step) {
1218: gzipos.write (array, offset + i, Math.min (step, length - i));
1219: if (step <= length) {
1220: System.out.print (".");
1221: }
1222: }
1223: gzipos.flush ();
1224: } catch (IOException ioe) {
1225: ioe.printStackTrace ();
1226: break;
1227: }
1228: byte[] compressed = baos.toByteArray ();
1229: if (step <= length) {
1230: System.out.println ();
1231: }
1232:
1233: value = Base64.getEncoder ().encodeToString (compressed);
1234: } while (false);
1235: }
1236: }
1237: sgsCurrentMap.put (key, value);
1238: }
1239:
1240:
1241:
1242:
1243:
1244: public static void sgsMakeMenu () {
1245:
1246: ActionListener listener = new ActionListener () {
1247: @Override public void actionPerformed (ActionEvent ae) {
1248: Object source = ae.getSource ();
1249: String command = ae.getActionCommand ();
1250: switch (command) {
1251: case "Save settings on exit":
1252: sgsSaveOnExit = ((JCheckBoxMenuItem) ae.getSource ()).isSelected ();
1253: break;
1254: case "Restore windows that were open":
1255: sgsXxxOpen = ((JCheckBoxMenuItem) ae.getSource ()).isSelected ();
1256: break;
1257: case "Delete all settings":
1258: sgsDeleteAllSettings ();
1259: break;
1260: }
1261: }
1262: };
1263:
1264: sgsMenu = Multilingual.mlnText (
1265: ComponentFactory.createMenu (
1266: "Configuration file",
1267: sgsSaveOnExitCheckBox =
1268: Multilingual.mlnText (
1269: ComponentFactory.createCheckBoxMenuItem (sgsSaveOnExit, "Save settings on exit", listener),
1270: "ja", "終了時に設定を保存する"),
1271: Multilingual.mlnText (
1272: ComponentFactory.createCheckBoxMenuItem (sgsXxxOpen, "Restore windows that were open", listener),
1273: "ja", "開いていたウインドウを復元する"),
1274: ComponentFactory.createHorizontalSeparator (),
1275: Multilingual.mlnText (
1276: ComponentFactory.createMenuItem ("Delete all settings", listener),
1277: "ja", "すべての設定を消去する")
1278: ),
1279: "ja", "設定ファイル");
1280: }
1281:
1282:
1283:
1284: public static void sgsSaveAllSettings () {
1285:
1286: sgsCurrentMap.put ("lang", Multilingual.mlnLang);
1287:
1288: sgsCurrentMap.put ("verbose", XEiJ.prgVerbose ? "on" : "off");
1289: sgsPutOnOff ("tinilog", XEiJ.prgTiniLog);
1290:
1291: sgsCurrentMap.put ("saveonexit", sgsSaveOnExit ? "on" : "off");
1292: sgsCurrentMap.put ("xxxopen", sgsXxxOpen ? "on" : "off");
1293:
1294:
1295:
1296: sgsCurrentMap.put ("fefunc", FEFunction.fpkOn ? "on" : "off");
1297: sgsCurrentMap.put ("rejectfloat", FEFunction.fpkRejectFloatOn ? "on" : "off");
1298:
1299:
1300: sgsCurrentMap.put ("memory", String.valueOf (MainMemory.mmrMemorySizeRequest >>> 20));
1301: sgsCurrentMap.put ("memorysave", MainMemory.mmrMemorySaveOn ? "on" : "off");
1302: if (MainMemory.mmrMemorySaveOn) {
1303: if (false) {
1304: sgsCurrentMap.put ("memorydata", ByteArray.byaEncodeBase64 (ByteArray.byaEncodeGzip (MainMemory.mmrM8, 0x00000000, MainMemory.mmrMemorySizeCurrent)));
1305: } else {
1306: sgsPutData ("memorydata",
1307: Arrays.copyOf (MainMemory.mmrM8, MainMemory.mmrMemorySizeCurrent));
1308: }
1309: } else {
1310: sgsCurrentMap.put ("memorydata", "");
1311: }
1312:
1313: if (CRTC.CRT_ENABLE_INTERMITTENT) {
1314: sgsCurrentMap.put ("intermittent", String.valueOf (CRTC.crtIntermittentInterval));
1315: }
1316: if (CRTC.CRT_EXTENDED_GRAPHIC) {
1317: sgsCurrentMap.put ("extendedgraphic", CRTC.crtExtendedGraphicRequest ? "on" : "off");
1318: }
1319:
1320: sgsCurrentMap.put ("sound", SoundSource.sndPlayOn ? "on" : "off");
1321: sgsCurrentMap.put ("volume", String.valueOf (SoundSource.sndVolume));
1322: sgsCurrentMap.put ("soundinterpolation",
1323: SoundSource.sndRateConverter == (SoundSource.SND_CHANNELS == 1 ? SoundSource.SNDRateConverter.THINNING_MONO : SoundSource.SNDRateConverter.THINNING_STEREO) ? "thinning" :
1324: SoundSource.sndRateConverter == (SoundSource.SND_CHANNELS == 1 ? SoundSource.SNDRateConverter.LINEAR_MONO : SoundSource.SNDRateConverter.LINEAR_STEREO) ? "linear" :
1325: SoundSource.sndRateConverter == SoundSource.SNDRateConverter.CONSTANT_AREA_STEREO_48000 ? "constant-area" :
1326: SoundSource.sndRateConverter == SoundSource.SNDRateConverter.LINEAR_AREA_STEREO_48000 ? "linear-area" :
1327: "linear");
1328:
1329: sgsCurrentMap.put ("opmoutput", OPM.opmOutputMask != 0 ? "on" : "off");
1330:
1331: sgsCurrentMap.put ("pcmoutput", ADPCM.pcmOutputOn ? "on" : "off");
1332: sgsCurrentMap.put ("pcminterpolation",
1333: ADPCM.pcmInterpolationAlgorithm == ADPCM.PCM_INTERPOLATION_CONSTANT ? "constant" :
1334: ADPCM.pcmInterpolationAlgorithm == ADPCM.PCM_INTERPOLATION_LINEAR ? "linear" :
1335: ADPCM.pcmInterpolationAlgorithm == ADPCM.PCM_INTERPOLATION_HERMITE ? "hermite" :
1336: "linear");
1337: sgsCurrentMap.put ("pcmoscfreq", String.valueOf (ADPCM.pcmOSCFreqRequest));
1338:
1339:
1340:
1341:
1342:
1343:
1344:
1345: for (String key : SGS_FRAME_KEYS) {
1346:
1347: sgsPutIntArray (key + "rect", RestorableFrame.rfmGetRect (key), 0);
1348:
1349: int state = RestorableFrame.rfmGetState (key);
1350: sgsPutString (key + "stat",
1351: (state & Frame.ICONIFIED) == Frame.ICONIFIED ? "iconified" :
1352: (state & Frame.MAXIMIZED_BOTH) == Frame.MAXIMIZED_BOTH ? "maximized" :
1353: (state & Frame.MAXIMIZED_BOTH) == Frame.MAXIMIZED_HORIZ ? "h-maximized" :
1354: (state & Frame.MAXIMIZED_BOTH) == Frame.MAXIMIZED_VERT ? "v-maximized" :
1355: "normal");
1356:
1357: sgsPutOnOff (key + "open", sgsXxxOpen && RestorableFrame.rfmGetOpened (key));
1358: }
1359:
1360:
1361: sgsSaveIniFile (sgsEncodeRootMap ());
1362:
1363: }
1364:
1365:
1366:
1367: public static void sgsDecodeRootMap (String text) {
1368: sgsRootMap.clear ();
1369: sgsCurrentMap.clear ();
1370: sgsCurrentMap = new HashMap<String,String> (sgsStartMap);
1371: sgsCurrentMap.put ("_", "");
1372: sgsRootMap.put ("", sgsCurrentMap);
1373: HashMap<String,String> map = sgsCurrentMap;
1374: for (String line : text.split ("\n")) {
1375: line = line.trim ();
1376: if (line.length () == 0 ||
1377: line.startsWith ("#")) {
1378: continue;
1379: }
1380: int i = line.indexOf ('=');
1381: if (i < 0) {
1382: continue;
1383: }
1384: String key = line.substring (0, i).trim ().toLowerCase ();
1385: String value = line.substring (i + 1).trim ();
1386: if (key.equals ("_")) {
1387: if (sgsRootMap.containsKey (value)) {
1388: if (false) {
1389: map = null;
1390: } else {
1391: map = sgsRootMap.get (value);
1392: }
1393: } else {
1394: map = new HashMap<String,String> (sgsStartMap);
1395: map.put (key, value);
1396: sgsRootMap.put (value, map);
1397: }
1398: continue;
1399: }
1400: if (map == null) {
1401: continue;
1402: }
1403: sgsPutParameter (map, key, value);
1404: }
1405: }
1406:
1407:
1408:
1409: public static ArrayList<String> sgsEncodeRootMap () {
1410: ArrayList<String> strings = new ArrayList<String> ();
1411: String[] nameArray = sgsRootMap.keySet ().toArray (new String[0]);
1412: Arrays.sort (nameArray, DictionaryComparator);
1413: for (String name : nameArray) {
1414: HashMap<String,String> map = sgsRootMap.get (name);
1415: if (map != sgsCurrentMap) {
1416: strings.add ("\n");
1417: }
1418: String[] keyArray = map.keySet ().toArray (new String[0]);
1419: Arrays.sort (keyArray, DictionaryComparator);
1420: for (String key : keyArray) {
1421: String value = map.get (key);
1422: if (!(map == sgsCurrentMap && key.equals ("_")) &&
1423: !key.equals ("config") &&
1424: !value.equals (sgsStartMap.get (key))) {
1425: strings.add (key);
1426: strings.add ("=");
1427: strings.add (value);
1428: strings.add ("\n");
1429: }
1430: }
1431: }
1432: return strings;
1433: }
1434:
1435:
1436:
1437: public static void sgsDeleteAllSettings () {
1438: XEiJ.pnlExitFullScreen (true);
1439: if (JOptionPane.showConfirmDialog (
1440: XEiJ.frmFrame,
1441: Multilingual.mlnJapanese ? "すべての設定を消去しますか?" : "Do you want to delete all settings?",
1442: Multilingual.mlnJapanese ? "確認" : "Confirmation",
1443: JOptionPane.YES_NO_OPTION,
1444: JOptionPane.PLAIN_MESSAGE) == JOptionPane.YES_OPTION) {
1445: sgsDeleteIniFile ();
1446: sgsSaveOnExit = false;
1447: sgsSaveOnExitCheckBox.setSelected (sgsSaveOnExit);
1448: }
1449: }
1450:
1451:
1452:
1453:
1454:
1455: public static void sgsPutParameter (HashMap<String,String> map, String key, String value) {
1456: if (sgsDefaultMap.containsKey (key)) {
1457: String defaultValue = sgsDefaultMap.get (key);
1458: if (defaultValue.equals ("off") || defaultValue.equals ("on")) {
1459: value = (value.equals ("0") ||
1460: value.equalsIgnoreCase ("no") ||
1461: value.equalsIgnoreCase ("off") ? "off" : "on");
1462: }
1463: map.put (key, value);
1464: }
1465: }
1466:
1467:
1468:
1469:
1470:
1471: public static String sgsLoadIniFile () {
1472: return XEiJ.rscGetTextFile (sgsIniPath);
1473: }
1474:
1475:
1476:
1477: public static void sgsSaveIniFile (ArrayList<String> strings) {
1478: XEiJ.rscPutTextFile (sgsIniPath, strings);
1479: }
1480:
1481:
1482:
1483: public static void sgsDeleteIniFile () {
1484: if (sgsIniFile.isFile ()) {
1485: if (sgsIniFile.delete ()) {
1486: System.out.println (sgsIniPath + (Multilingual.mlnJapanese ? " を削除しました" : " was removed"));
1487: } else {
1488: System.out.println (sgsIniPath + (Multilingual.mlnJapanese ? " を削除できません" : " cannot be removed"));
1489: return;
1490: }
1491: }
1492: String bakPath = sgsIniPath + ".bak";
1493: File bakFile = new File (bakPath);
1494: if (bakFile.isFile ()) {
1495: if (bakFile.delete ()) {
1496: System.out.println (bakPath + (Multilingual.mlnJapanese ? " を削除しました" : " was removed"));
1497: } else {
1498: System.out.println (bakPath + (Multilingual.mlnJapanese ? " を削除できません" : " cannot be removed"));
1499: return;
1500: }
1501: }
1502: String tmpPath = sgsIniPath + ".tmp";
1503: File tmpFile = new File (tmpPath);
1504: if (tmpFile.isFile ()) {
1505: if (tmpFile.delete ()) {
1506: System.out.println (tmpPath + (Multilingual.mlnJapanese ? " を削除しました" : " was removed"));
1507: } else {
1508: System.out.println (tmpPath + (Multilingual.mlnJapanese ? " を削除できません" : " cannot be removed"));
1509: return;
1510: }
1511: }
1512: if (sgsIniParentDirectory != null &&
1513: sgsIniParentDirectory.isDirectory ()) {
1514: if (sgsIniParentDirectory.delete ()) {
1515: System.out.println (sgsIniParentPath + (Multilingual.mlnJapanese ? " を削除しました" : " was removed"));
1516: } else {
1517: System.out.println (sgsIniParentPath + (Multilingual.mlnJapanese ? " を削除できません" : " cannot be removed"));
1518: }
1519: }
1520: }
1521:
1522:
1523:
1524: }
1525:
1526:
1527: