PageRenderTime 60ms CodeModel.GetById 9ms RepoModel.GetById 0ms app.codeStats 1ms

/cwxeditor_src/cwx/editor/gui/dwt/settingsdialog.d

https://bitbucket.org/k4nagatsuki/cwxeditor
D | 3195 lines | 3083 code | 106 blank | 6 comment | 400 complexity | d1722b509d8bfadc6ca58aed0450e4d7 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /// ?????????????????
  2. module cwx.editor.gui.dwt.settingsdialog;
  3. import cwx.background;
  4. import cwx.utils;
  5. import cwx.xml;
  6. import cwx.summary;
  7. import cwx.skin;
  8. import cwx.graphics;
  9. import cwx.structs;
  10. import cwx.menu;
  11. import cwx.variables;
  12. import cwx.cab;
  13. import cwx.script;
  14. import cwx.props;
  15. import cwx.features;
  16. import cwx.types;
  17. import cwx.editor.gui.sound;
  18. import cwx.editor.gui.dwt.dprops;
  19. import cwx.editor.gui.dwt.properties;
  20. import cwx.editor.gui.dwt.dutils;
  21. import cwx.editor.gui.dwt.dskin;
  22. import cwx.editor.gui.dwt.centerlayout;
  23. import cwx.editor.gui.dwt.absdialog;
  24. import cwx.editor.gui.dwt.splitpane;
  25. import cwx.editor.gui.dwt.commons;
  26. import cwx.editor.gui.dwt.areaview;
  27. import cwx.editor.gui.dwt.areaviewutils;
  28. import cwx.editor.gui.dwt.xmlbytestransfer;
  29. import cwx.editor.gui.dwt.dockingfolder;
  30. import cwx.editor.gui.dwt.customtext;
  31. import cwx.editor.gui.dwt.undo;
  32. import cwx.editor.gui.dwt.dmenu;
  33. import cwx.editor.gui.dwt.customtable;
  34. import cwx.editor.gui.dwt.loader;
  35. import cwx.editor.gui.dwt.scripterrordialog;
  36. import cwx.editor.gui.dwt.incsearch;
  37. import std.path;
  38. import std.file;
  39. import std.string;
  40. import std.functional;
  41. import std.traits;
  42. import std.array;
  43. import std.ascii;
  44. import std.exception;
  45. import std.algorithm : iota;
  46. import org.eclipse.swt.all;
  47. import java.lang.all;
  48. enum BackupType {
  49. Time = 0,
  50. Edit = 1,
  51. }
  52. class SettingsDialog : AbsDialog {
  53. private:
  54. Commons _comm;
  55. Props _prop;
  56. Summary _summ;
  57. DockingFolderCTC _dock;
  58. void delegate() _sendReloadProps;
  59. CTabItem _tabB;
  60. Text _enginePath;
  61. Button _refEnginePath;
  62. Button _findEnginePath;
  63. Text _tempDir;
  64. Text _backupDir;
  65. Button _backupEnabled;
  66. Button _backupIntervalTypeTime;
  67. Button _backupIntervalTypeEdit;
  68. Spinner _backupIntervalTime;
  69. Spinner _backupIntervalEdit;
  70. Spinner _backupCount;
  71. Button _backupRefAuthor;
  72. Button _autoSave;
  73. Button _backupArchived;
  74. Button _backupRef;
  75. Button _backupDirOpen;
  76. Text _backupBeforeSaveDir;
  77. Button _backupBeforeSaveEnabled;
  78. Button _backupBeforeSaveRef;
  79. Button _backupBeforeSaveDirOpen;
  80. Text _author;
  81. Text _wallpaper;
  82. Combo _wallpaperStyle;
  83. int[int] _wallpaperStyleTbl;
  84. int[int] _wallpaperStyleTbl2;
  85. Button _clearHist;
  86. Spinner _histMax;
  87. Button _clearSHist;
  88. Spinner _sHistMax;
  89. Spinner _undoMaxMainView;
  90. Spinner _undoMaxEvent;
  91. Spinner _undoMaxReplace;
  92. Spinner _undoMaxEtc;
  93. CTabFolder _tabf;
  94. CTabItem _tabS;
  95. BgImageS[] _bgImagesDefault;
  96. ToolsPane!BgImageSetting _bgStgs;
  97. Text _keyCodes;
  98. CTabItem _tabT;
  99. ToolsPane!OuterTool _tools;
  100. ToolsPane!ClassicEngine _cEngines;
  101. CTabItem _tabC;
  102. ToolsPane!ScTemplate _scTempls;
  103. ToolsPane!EvTemplate _evTempls;
  104. CTabItem _tabE;
  105. Combo _language;
  106. string[int] _msgsTableIndex;
  107. string[string] _msgsTableFile;
  108. Text _ignorePaths;
  109. TableItem _singleWindow = null;
  110. TableItem _showAreaDirTree;
  111. TableItem _showSummaryInAreaTable;
  112. TableItem _clickIsOpenEvent;
  113. TableItem _smoothingCard;
  114. TableItem _showImagePreview;
  115. TableItem _editTriggerTypeIsQuick;
  116. TableItem _classicStyleTree;
  117. TableItem _adjustContentName;
  118. TableItem _radarStyleParams;
  119. TableItem _showEventTreeMark;
  120. TableItem _showCardListHeader;
  121. TableItem _showCardListTitle;
  122. TableItem _showSkillCardLevel;
  123. TableItem _ignoreEmptyStart;
  124. TableItem _expandXMLs;
  125. TableItem _contentsFloat;
  126. TableItem _contentsAutoHide;
  127. TableItem _comboListVisible;
  128. TableItem _xmlCopy;
  129. TableItem _showSpNature;
  130. TableItem _saveInnerImagePath;
  131. TableItem _linkCard;
  132. TableItem _traceDirectories;
  133. TableItem _logicalSort;
  134. TableItem _copyDesc;
  135. TableItem _refCardsAtEditBgImage;
  136. TableItem _floatMessagePreview;
  137. TableItem _addNewClassicEngine;
  138. TableItem _doubleIO;
  139. TableItem _switchTabWheel;
  140. TableItem _closeTabWithMiddleClick;
  141. TableItem _openTabAtRightOfCurrentTab;
  142. TableItem _reconstruction;
  143. TableItem _openLastScenario;
  144. TableItem _showVariableValuesInEventText;
  145. TableItem _cautionBeforeReplace;
  146. TableItem _saveNeedChanged;
  147. TableItem _applyDialogsBeforeSave;
  148. TableItem _useNamesAfterStandard;
  149. TableItem _selectVariableWithTree;
  150. TableItem _autoUpdateJpy1File;
  151. TableItem _straightEventTreeView;
  152. TableItem _gentleAngleEventTree;
  153. TableItem _forceIndentBranchContent;
  154. TableItem _showTerminalMark;
  155. TableItem _clickIconIsStartEdit;
  156. Combo _targetVersion;
  157. int[string] _targetVersionTbl;
  158. string[int] _targetVersionTbl2;
  159. Combo _soundPlayType;
  160. int[int] _soundPlayTypeTbl;
  161. int[int] _soundPlayTypeTbl2;
  162. Spinner _bgmVolume;
  163. Combo _soundEffectPlayType;
  164. int[int] _soundEffectPlayTypeTbl;
  165. int[int] _soundEffectPlayTypeTbl2;
  166. Spinner _seVolume;
  167. Combo _dialogStatus;
  168. int[int] _dialogStatusTbl;
  169. int[int] _dialogStatusTbl2;
  170. Text _savedSound;
  171. Text _mnemonic;
  172. HotKeyField _hotkey;
  173. Table _menu;
  174. Button _menuApply;
  175. Button _menuDel;
  176. class SMenuData {
  177. MenuID id;
  178. string mnemonic;
  179. string hotkey;
  180. }
  181. IncSearch _menuIncSearch;
  182. void menuIncSearch() { mixin(S_TRACE);
  183. _menuIncSearch.startIncSearch();
  184. }
  185. class RefE : SelectionAdapter, ModifyListener {
  186. override void widgetSelected(SelectionEvent e) { mixin(S_TRACE);
  187. refreshEnabled();
  188. }
  189. override void modifyText(ModifyEvent e) { mixin(S_TRACE);
  190. refreshEnabled();
  191. }
  192. }
  193. string dropEngine(string[] files) { mixin(S_TRACE);
  194. if (!files.length) return "";
  195. string file = files[0];
  196. if (cfnmatch(baseName(file), _prop.var.etc.engine)) { mixin(S_TRACE);
  197. return file;
  198. } else { mixin(S_TRACE);
  199. return "";
  200. }
  201. }
  202. const SYSTEM_SOUND_EXT = [
  203. ".aiff", // AIFF
  204. ".mid", ".midi", // MIDI
  205. ".mod", ".s3m", ".xm", ".it", ".mt2", ".669", ".med", // MOD
  206. ".ogg", ".ogv", ".oga", ".ogx", // Ogg
  207. ".voc", // VOC
  208. ".wav" // WAV/RIFF
  209. ];
  210. string dropSysSound(string[] files) { mixin(S_TRACE);
  211. if (!files.length) return "";
  212. foreach (file; files) { mixin(S_TRACE);
  213. string ext = .toLower(.extension(file));
  214. if (.contains!("a == b", string, string)(SYSTEM_SOUND_EXT, ext)) { mixin(S_TRACE);
  215. return file;
  216. }
  217. }
  218. return "";
  219. }
  220. const WALLPAPER_EXT = [".bmp", ".ico", ".icon", ".jpg", ".jpeg", ".gif", ".png", ".tif", ".tiff"];
  221. string dropWallpaper(string[] files) { mixin(S_TRACE);
  222. if (!files.length) return "";
  223. foreach (file; files) { mixin(S_TRACE);
  224. if (.contains!("a == b", string, string)(WALLPAPER_EXT, .toLower(.extension(file)))) { mixin(S_TRACE);
  225. return file;
  226. }
  227. }
  228. return "";
  229. }
  230. void selectEngine() { mixin(S_TRACE);
  231. selectFile(_enginePath, [_prop.var.etc.engine], [_prop.var.etc.engine],
  232. _prop.var.etc.engine, .tryFormat(_prop.msgs.dlgTitEnginePath, _prop.var.etc.engine),
  233. _prop.var.etc.enginePath);
  234. }
  235. void selectSysSound(Text widget) { mixin(S_TRACE);
  236. string[] extArr;
  237. foreach (sse; SYSTEM_SOUND_EXT) { mixin(S_TRACE);
  238. extArr ~= "*." ~ sse;
  239. }
  240. string exts = std.string.join(extArr, ";");
  241. selectFile(widget, [.tryFormat(_prop.msgs.playableSounds, exts)], [exts],
  242. baseName(widget.getText()), _prop.msgs.dlgTitSystemSound,
  243. widget.getText());
  244. }
  245. void selectTemp() { mixin(S_TRACE);
  246. selectDir(_prop, _tempDir, _prop.msgs.tempDir, _prop.msgs.tempDirDesc, _prop.tempPath);
  247. }
  248. void selectBackup() { mixin(S_TRACE);
  249. selectDir(_prop, _backupDir, _prop.msgs.backupDir, _prop.msgs.backupDirDesc, _prop.backupPath);
  250. }
  251. void selectBackupBeforeSave() { mixin(S_TRACE);
  252. selectDir(_prop, _backupBeforeSaveDir, _prop.msgs.backupBeforeSaveDir, _prop.msgs.backupBeforeSaveDirDesc, _prop.backupBeforeSavePath);
  253. }
  254. void selectWallpaper() { mixin(S_TRACE);
  255. string[] filterName = [_prop.msgs.filterWallpaper, _prop.msgs.filterAll];
  256. string[] filter = [
  257. "*" ~ std.string.join(WALLPAPER_EXT.dup, ";*"),
  258. "*"
  259. ];
  260. selectFile(_wallpaper, filterName, filter, _prop.var.etc.wallpaper, _prop.msgs.dlgTitWallpaper, getcwd());
  261. }
  262. class SelEngine : SelectionAdapter {
  263. override void widgetSelected(SelectionEvent e) {selectEngine();}
  264. }
  265. class SelTemp : SelectionAdapter {
  266. override void widgetSelected(SelectionEvent e) {selectTemp();}
  267. }
  268. class SelBackup : SelectionAdapter {
  269. override void widgetSelected(SelectionEvent e) {selectBackup();}
  270. }
  271. class SelBackupBeforeSave : SelectionAdapter {
  272. override void widgetSelected(SelectionEvent e) {selectBackupBeforeSave();}
  273. }
  274. class SelWallpaper : SelectionAdapter {
  275. override void widgetSelected(SelectionEvent e) {selectWallpaper();}
  276. }
  277. class SelSysSound : SelectionAdapter {
  278. private Text _text;
  279. this (Text text) { mixin(S_TRACE);
  280. _text = text;
  281. }
  282. override void widgetSelected(SelectionEvent e) { mixin(S_TRACE);
  283. selectSysSound(_text);
  284. }
  285. }
  286. void refHistories() { mixin(S_TRACE);
  287. _clearHist.setEnabled(_prop.var.etc.openHistories.length > 0);
  288. }
  289. void refSearchHistories() { mixin(S_TRACE);
  290. _clearSHist.setEnabled(_prop.var.etc.searchHistories.length || _prop.var.etc.replaceHistories.length);
  291. }
  292. class ClearHist : SelectionAdapter {
  293. override void widgetSelected(SelectionEvent e) { mixin(S_TRACE);
  294. auto dlg = new MessageBox(_histMax.getShell(), SWT.ICON_QUESTION | SWT.OK | SWT.CANCEL);
  295. dlg.setText(_prop.msgs.dlgTitQuestion);
  296. dlg.setMessage(_prop.msgs.dlgMsgHistoryClear);
  297. if (SWT.OK == dlg.open()) { mixin(S_TRACE);
  298. _prop.var.etc.openHistories = [];
  299. _comm.refHistories.call();
  300. _prop.var.save(_dock);
  301. _sendReloadProps();
  302. }
  303. }
  304. }
  305. class ClearSHist : SelectionAdapter {
  306. override void widgetSelected(SelectionEvent e) { mixin(S_TRACE);
  307. auto dlg = new MessageBox(_sHistMax.getShell(), SWT.ICON_QUESTION | SWT.OK | SWT.CANCEL);
  308. dlg.setText(_prop.msgs.dlgTitQuestion);
  309. dlg.setMessage(_prop.msgs.dlgMsgSearchHistoryClear);
  310. if (SWT.OK == dlg.open()) { mixin(S_TRACE);
  311. _prop.var.etc.searchHistories = [];
  312. _prop.var.etc.replaceHistories = [];
  313. _prop.var.etc.grepDirHistories = [];
  314. _comm.refSearchHistories.call();
  315. _prop.var.save(_dock);
  316. _sendReloadProps();
  317. }
  318. }
  319. }
  320. void construct1(CTabFolder tabf) { mixin(S_TRACE);
  321. auto comp = new Composite(tabf, SWT.NONE);
  322. comp.setLayout(new GridLayout(1, false));
  323. _tabB = new CTabItem(tabf, SWT.NONE);
  324. _tabB.setText(_prop.msgs.baseSettings);
  325. _tabB.setControl(comp);
  326. { mixin(S_TRACE);
  327. auto comp2 = new Composite(comp, SWT.NONE);
  328. comp2.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  329. comp2.setLayout(zeroMarginGridLayout(2, false));
  330. { mixin(S_TRACE);
  331. auto grp = new Group(comp2, SWT.NONE);
  332. grp.setLayoutData(new GridData(GridData.FILL_BOTH));
  333. grp.setLayout(new GridLayout(3, false));
  334. grp.setText(.tryFormat(_prop.msgs.enginePath, _prop.var.etc.engine));
  335. _enginePath = new Text(grp, SWT.BORDER);
  336. createTextMenu!Text(_comm, _prop, _enginePath, &catchMod);
  337. _enginePath.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  338. mod(_enginePath);
  339. _refEnginePath = new Button(grp, SWT.PUSH);
  340. _refEnginePath.setText(_prop.msgs.reference);
  341. _refEnginePath.addSelectionListener(new SelEngine);
  342. createOpenButton(_comm, grp, &_enginePath.getText, false);
  343. _findEnginePath = new Button(grp, SWT.CHECK);
  344. mod(_findEnginePath);
  345. _findEnginePath.setText(_prop.msgs.findEnginePath);
  346. auto gd = new GridData;
  347. gd.horizontalSpan = 3;
  348. _findEnginePath.setLayoutData(gd);
  349. setupDropFile(grp, _enginePath, &dropEngine);
  350. .listener(_enginePath, SWT.Modify, { mixin(S_TRACE);
  351. _findEnginePath.setEnabled(0 == _enginePath.getText().length);
  352. });
  353. .listener(_findEnginePath, SWT.Selection, { mixin(S_TRACE);
  354. _enginePath.setEnabled(!_findEnginePath.getSelection());
  355. _refEnginePath.setEnabled(!_findEnginePath.getSelection());
  356. });
  357. }
  358. { mixin(S_TRACE);
  359. auto grp = new Group(comp2, SWT.NONE);
  360. grp.setLayoutData(new GridData(GridData.FILL_VERTICAL));
  361. grp.setText(_prop.msgs.languageSetting);
  362. grp.setLayout(new GridLayout(1, true));
  363. string defLocale;
  364. auto msgsTable = _prop.parent.msgsTable(_prop.var.etc.languageDir, _msgsTableFile, defLocale);
  365. _language = new Combo(grp, SWT.READ_ONLY | SWT.DROP_DOWN | SWT.BORDER);
  366. mod(_language);
  367. _language.setVisibleItemCount(_prop.var.etc.comboVisibleItemCount);
  368. _language.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  369. _language.add(_prop.msgs.languageSystem);
  370. _language.select(0);
  371. string curLocale = _prop.msgs.locale;
  372. foreach (locale; msgsTable.keys.sort) { mixin(S_TRACE);
  373. _language.add(msgsTable[locale].localeName);
  374. int index = _language.getItemCount() - 1;
  375. _msgsTableIndex[index] = locale;
  376. if (!_prop.var.etc.useSystemLanguage && 0 == icmp(curLocale, locale)) { mixin(S_TRACE);
  377. _language.select(index);
  378. }
  379. }
  380. auto l = new Label(grp, SWT.NONE);
  381. l.setText(_prop.msgs.languageCaution);
  382. }
  383. }
  384. { mixin(S_TRACE);
  385. auto grp = new Group(comp, SWT.NONE);
  386. grp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  387. grp.setLayout(new GridLayout(3, false));
  388. grp.setText(_prop.msgs.tempDir);
  389. _tempDir = new Text(grp, SWT.BORDER);
  390. createTextMenu!Text(_comm, _prop, _tempDir, &catchMod);
  391. _tempDir.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  392. mod(_tempDir);
  393. auto refr = new Button(grp, SWT.PUSH);
  394. refr.setText(_prop.msgs.reference);
  395. refr.addSelectionListener(new SelTemp);
  396. createOpenButton(_comm, grp, &_tempDir.getText, true);
  397. setupDropFile(grp, _tempDir, toDelegate(&dropDir));
  398. }
  399. { mixin(S_TRACE);
  400. auto grp = new Group(comp, SWT.NONE);
  401. grp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  402. grp.setText(_prop.msgs.backupDir);
  403. auto gl = new GridLayout(3, false);
  404. gl.horizontalSpacing = 10;
  405. grp.setLayout(gl);
  406. { mixin(S_TRACE);
  407. _backupEnabled = new Button(grp, SWT.CHECK);
  408. _backupEnabled.setText(_prop.msgs.backupEnabled);
  409. mod(_backupEnabled);
  410. _backupEnabled.addSelectionListener(_refe);
  411. }
  412. { mixin(S_TRACE);
  413. auto comp2 = new Composite(grp, SWT.NONE);
  414. comp2.setLayoutData(new GridData(GridData.FILL_VERTICAL));
  415. comp2.setLayout(zeroMarginGridLayout(6, false));
  416. _backupIntervalTypeTime = new Button(comp2, SWT.RADIO);
  417. _backupIntervalTypeTime.setText(_prop.msgs.backupIntervalTime);
  418. _backupIntervalTime = new Spinner(comp2, SWT.BORDER);
  419. initSpinner(_backupIntervalTime);
  420. _backupIntervalTime.setMinimum(1);
  421. _backupIntervalTime.setMaximum(99);
  422. mod(_backupIntervalTime);
  423. auto l2 = new Label(comp2, SWT.CENTER);
  424. l2.setText(_prop.msgs.minute);
  425. _backupIntervalTypeTime.addSelectionListener(_refe);
  426. _backupIntervalTypeEdit = new Button(comp2, SWT.RADIO);
  427. _backupIntervalTypeEdit.setText(_prop.msgs.backupIntervalEdit);
  428. _backupIntervalEdit = new Spinner(comp2, SWT.BORDER);
  429. initSpinner(_backupIntervalEdit);
  430. _backupIntervalEdit.setMinimum(1);
  431. _backupIntervalEdit.setMaximum(9999);
  432. mod(_backupIntervalEdit);
  433. auto l3 = new Label(comp2, SWT.CENTER);
  434. l3.setText(_prop.msgs.count);
  435. _backupIntervalTypeEdit.addSelectionListener(_refe);
  436. }
  437. { mixin(S_TRACE);
  438. auto comp2 = new Composite(grp, SWT.NONE);
  439. comp2.setLayoutData(new GridData(GridData.FILL_VERTICAL));
  440. comp2.setLayout(zeroMarginGridLayout(2, false));
  441. auto l = new Label(comp2, SWT.CENTER);
  442. l.setText(_prop.msgs.backupCount);
  443. _backupCount = new Spinner(comp2, SWT.BORDER);
  444. initSpinner(_backupCount);
  445. _backupCount.setMinimum(0);
  446. _backupCount.setMaximum(99);
  447. mod(_backupCount);
  448. }
  449. { mixin(S_TRACE);
  450. auto comp2 = new Composite(grp, SWT.NONE);
  451. auto gd = new GridData(GridData.FILL_HORIZONTAL);
  452. gd.horizontalSpan = 3;
  453. comp2.setLayoutData(gd);
  454. comp2.setLayout(zeroMarginGridLayout(4, false));
  455. auto l = new Label(comp2, SWT.NONE);
  456. l.setText(_prop.msgs.backupPath);
  457. _backupDir = new Text(comp2, SWT.BORDER);
  458. createTextMenu!Text(_comm, _prop, _backupDir, &catchMod);
  459. _backupDir.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  460. mod(_backupDir);
  461. _backupRef = new Button(comp2, SWT.PUSH);
  462. _backupRef.setText(_prop.msgs.reference);
  463. _backupRef.addSelectionListener(new SelBackup);
  464. _backupDirOpen = createOpenButton(_comm, comp2, &_backupDir.getText, true);
  465. setupDropFile(grp, _backupDir, toDelegate(&dropDir));
  466. }
  467. { mixin(S_TRACE);
  468. auto comp2 = new Composite(grp, SWT.NONE);
  469. auto gd = new GridData(GridData.FILL_HORIZONTAL);
  470. gd.horizontalSpan = 3;
  471. comp2.setLayoutData(gd);
  472. comp2.setLayout(zeroMarginGridLayout(3, false));
  473. _backupRefAuthor = new Button(comp2, SWT.CHECK);
  474. _backupRefAuthor.setText(_prop.msgs.backupRefAuthor);
  475. mod(_backupRefAuthor);
  476. _backupRefAuthor.addSelectionListener(_refe);
  477. _autoSave = new Button(comp2, SWT.CHECK);
  478. _autoSave.setText(_prop.msgs.autoSave);
  479. mod(_autoSave);
  480. _autoSave.addSelectionListener(_refe);
  481. _backupArchived = new Button(comp2, SWT.CHECK);
  482. _backupArchived.setText(_prop.msgs.backupArchived);
  483. mod(_backupArchived);
  484. _backupArchived.addSelectionListener(_refe);
  485. }
  486. }
  487. { mixin(S_TRACE);
  488. auto grp = new Group(comp, SWT.NONE);
  489. grp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  490. grp.setText(_prop.msgs.backupBeforeSaveDir);
  491. grp.setLayout(new GridLayout(1, false));
  492. { mixin(S_TRACE);
  493. _backupBeforeSaveEnabled = new Button(grp, SWT.CHECK);
  494. _backupBeforeSaveEnabled.setText(_prop.msgs.backupBeforeSaveEnabled);
  495. mod(_backupBeforeSaveEnabled);
  496. _backupBeforeSaveEnabled.addSelectionListener(_refe);
  497. }
  498. { mixin(S_TRACE);
  499. auto comp2 = new Composite(grp, SWT.NONE);
  500. auto gd = new GridData(GridData.FILL_HORIZONTAL);
  501. gd.horizontalSpan = 3;
  502. comp2.setLayoutData(gd);
  503. comp2.setLayout(zeroMarginGridLayout(4, false));
  504. auto l = new Label(comp2, SWT.NONE);
  505. l.setText(_prop.msgs.backupBeforeSavePath);
  506. _backupBeforeSaveDir = new Text(comp2, SWT.BORDER);
  507. createTextMenu!Text(_comm, _prop, _backupBeforeSaveDir, &catchMod);
  508. _backupBeforeSaveDir.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  509. mod(_backupBeforeSaveDir);
  510. _backupBeforeSaveRef = new Button(comp2, SWT.PUSH);
  511. _backupBeforeSaveRef.setText(_prop.msgs.reference);
  512. _backupBeforeSaveRef.addSelectionListener(new SelBackupBeforeSave);
  513. _backupBeforeSaveDirOpen = createOpenButton(_comm, comp2, &_backupBeforeSaveDir.getText, true);
  514. setupDropFile(grp, _backupBeforeSaveDir, toDelegate(&dropDir));
  515. }
  516. }
  517. { mixin(S_TRACE);
  518. auto comp2 = new Composite(comp, SWT.NONE);
  519. comp2.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  520. comp2.setLayout(zeroMarginGridLayout(2, false));
  521. { mixin(S_TRACE);
  522. auto comp3 = new Composite(comp2, SWT.NONE);
  523. comp3.setLayoutData(new GridData(GridData.FILL_BOTH));
  524. comp3.setLayout(zeroMarginGridLayout(1, false));
  525. { mixin(S_TRACE);
  526. auto grp = new Group(comp3, SWT.NONE);
  527. grp.setLayoutData(new GridData(GridData.FILL_BOTH));
  528. auto cl = new CenterLayout;
  529. cl.fillHorizontal = true;
  530. grp.setLayout(cl);
  531. grp.setText(_prop.msgs.scenarioAuthor);
  532. _author = new Text(grp, SWT.BORDER);
  533. createTextMenu!Text(_comm, _prop, _author, &catchMod);
  534. mod(_author);
  535. }
  536. { mixin(S_TRACE);
  537. auto grp = new Group(comp3, SWT.NONE);
  538. grp.setLayoutData(new GridData(GridData.FILL_BOTH));
  539. grp.setLayout(new GridLayout(1, true));
  540. grp.setText(_prop.msgs.wallpaper);
  541. { mixin(S_TRACE);
  542. auto comp4 = new Composite(grp, SWT.NONE);
  543. comp4.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  544. comp4.setLayout(zeroMarginGridLayout(3, false));
  545. _wallpaper = new Text(comp4, SWT.BORDER);
  546. createTextMenu!Text(_comm, _prop, _wallpaper, &catchMod);
  547. _wallpaper.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  548. mod(_wallpaper);
  549. auto refr = new Button(comp4, SWT.PUSH);
  550. refr.setText(_prop.msgs.reference);
  551. refr.addSelectionListener(new SelWallpaper);
  552. createOpenButton(_comm, comp4, &_wallpaper.getText, false);
  553. }
  554. { mixin(S_TRACE);
  555. auto comp4 = new Composite(grp, SWT.NONE);
  556. comp4.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  557. comp4.setLayout(zeroMarginGridLayout(2, false));
  558. int[] styles;
  559. string[] names;
  560. foreach (s; [WallpaperStyle.Center, WallpaperStyle.Tile, WallpaperStyle.ExpandFull, WallpaperStyle.Expand]) { mixin(S_TRACE);
  561. styles ~= cast(int) s;
  562. names ~= _prop.msgs.wallpaperStyleName(s);
  563. }
  564. _wallpaperStyle = createEnumC(comp4, _prop.msgs.wallpaperStyle, styles, names, _wallpaperStyleTbl, _wallpaperStyleTbl2);
  565. }
  566. setupDropFile(grp, _wallpaper, &dropWallpaper);
  567. }
  568. { mixin(S_TRACE);
  569. auto grp = new Group(comp3, SWT.NONE);
  570. grp.setLayoutData(new GridData(GridData.FILL_BOTH));
  571. grp.setText(_prop.msgs.systemSounds);
  572. grp.setLayout(new GridLayout(7, false));
  573. auto l = new Label(grp, SWT.NONE);
  574. l.setText(_prop.msgs.soundSaved);
  575. _savedSound = new Text(grp, SWT.BORDER);
  576. createTextMenu!Text(_comm, _prop, _savedSound, &catchMod);
  577. _savedSound.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  578. mod(_savedSound);
  579. auto refr = new Button(grp, SWT.PUSH);
  580. refr.setText(_prop.msgs.reference);
  581. refr.addSelectionListener(new SelSysSound(_savedSound));
  582. createOpenButton(_comm, grp, &_savedSound.getText, false);
  583. setupDropFile(grp, _savedSound, &dropSysSound);
  584. auto sep = new Label(grp, SWT.SEPARATOR);
  585. auto sgd = new GridData(GridData.FILL_VERTICAL);
  586. sgd.heightHint = 0;
  587. sep.setLayoutData(sgd);
  588. auto play = new Button(grp, SWT.PUSH);
  589. play.setToolTipText(_prop.msgs.menuText(MenuID.PlaySE));
  590. play.setImage(_prop.images.menu(MenuID.PlaySE));
  591. .listener(play, SWT.Selection, { mixin(S_TRACE);
  592. string file = _savedSound.getText();
  593. if (file.length && .exists(file)) { mixin(S_TRACE);
  594. playSE(file, SOUND_TYPE_SDL);
  595. }
  596. });
  597. auto stop = new Button(grp, SWT.PUSH);
  598. stop.setToolTipText(_prop.msgs.menuText(MenuID.StopSE));
  599. stop.setImage(_prop.images.menu(MenuID.StopSE));
  600. .listener(stop, SWT.Selection, { mixin(S_TRACE);
  601. stopSE();
  602. });
  603. }
  604. }
  605. { mixin(S_TRACE);
  606. auto comp3 = new Composite(comp2, SWT.NONE);
  607. comp3.setLayout(zeroMarginGridLayout(1, true));
  608. comp3.setLayoutData(new GridData(GridData.FILL_VERTICAL));
  609. { mixin(S_TRACE);
  610. auto grp = new Group(comp3, SWT.NONE);
  611. grp.setText(_prop.msgs.historiesSettings);
  612. grp.setLayoutData(new GridData(GridData.FILL_BOTH));
  613. grp.setLayout(new GridLayout(3, false));
  614. { mixin(S_TRACE);
  615. auto lComp = new Composite(grp, SWT.NONE);
  616. auto cl = new CenterLayout(SWT.HORIZONTAL | SWT.VERTICAL, 0);
  617. cl.fillHorizontal = true;
  618. lComp.setLayout(cl);
  619. lComp.setLayoutData(new GridData(GridData.FILL_BOTH));
  620. auto l = new Label(lComp, SWT.NONE);
  621. l.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  622. l.setText(_prop.msgs.openHistoryMax);
  623. _histMax = new Spinner(grp, SWT.BORDER);
  624. initSpinner(_histMax);
  625. _histMax.setMinimum(0);
  626. _histMax.setMaximum(99);
  627. mod(_histMax);
  628. _clearHist = new Button(grp, SWT.PUSH);
  629. _clearHist.setEnabled(_prop.var.etc.openHistories.length > 0);
  630. _clearHist.setText(_prop.msgs.openHistoryClear);
  631. _clearHist.addSelectionListener(new ClearHist);
  632. }
  633. { mixin(S_TRACE);
  634. auto lComp = new Composite(grp, SWT.NONE);
  635. auto cl = new CenterLayout(SWT.HORIZONTAL | SWT.VERTICAL, 0);
  636. cl.fillHorizontal = true;
  637. lComp.setLayout(cl);
  638. lComp.setLayoutData(new GridData(GridData.FILL_BOTH));
  639. auto l = new Label(lComp, SWT.NONE);
  640. l.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  641. l.setText(_prop.msgs.searchHistoryMax);
  642. _sHistMax = new Spinner(grp, SWT.BORDER);
  643. initSpinner(_sHistMax);
  644. _sHistMax.setMinimum(0);
  645. _sHistMax.setMaximum(99);
  646. mod(_sHistMax);
  647. _clearSHist = new Button(grp, SWT.PUSH);
  648. _clearSHist.setEnabled(_prop.var.etc.searchHistories.length || _prop.var.etc.grepDirHistories.length);
  649. _clearSHist.setText(_prop.msgs.searchHistoryClear);
  650. _clearSHist.addSelectionListener(new ClearSHist);
  651. }
  652. }
  653. { mixin(S_TRACE);
  654. auto grp = new Group(comp3, SWT.NONE);
  655. grp.setText(_prop.msgs.undoMax);
  656. grp.setLayoutData(new GridData(GridData.FILL_BOTH));
  657. grp.setLayout(new GridLayout(2, false));
  658. Spinner createUndoMax(string title) { mixin(S_TRACE);
  659. auto l = new Label(grp, SWT.NONE);
  660. l.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  661. l.setText(title);
  662. auto spn = new Spinner(grp, SWT.BORDER);
  663. initSpinner(spn);
  664. mod(spn);
  665. spn.setMaximum(_prop.var.etc.undoMaxLimit);
  666. spn.setMinimum(0);
  667. return spn;
  668. }
  669. _undoMaxMainView = createUndoMax(_prop.msgs.undoMaxMainView);
  670. _undoMaxEvent = createUndoMax(_prop.msgs.undoMaxEvent);
  671. _undoMaxReplace = createUndoMax(_prop.msgs.undoMaxReplace);
  672. _undoMaxEtc = createUndoMax(_prop.msgs.undoMaxEtc);
  673. }
  674. }
  675. }
  676. }
  677. class DefBgSetting : SelectionAdapter {
  678. private DefBgImgDialog _dlg = null;
  679. override void widgetSelected(SelectionEvent e) { mixin(S_TRACE);
  680. if (_dlg) { mixin(S_TRACE);
  681. _dlg.active();
  682. return;
  683. }
  684. _dlg = new DefBgImgDialog(_comm, _prop, getShell(), _bgImagesDefault);
  685. _dlg.appliedEvent ~= { mixin(S_TRACE);
  686. _bgImagesDefault = _dlg.backs;
  687. applyEnabled();
  688. };
  689. _dlg.closeEvent ~= { mixin(S_TRACE);
  690. _dlg = null;
  691. };
  692. _dlg.open();
  693. }
  694. }
  695. class DBgImgStg : DisposeListener {
  696. override void widgetDisposed(DisposeEvent e) { mixin(S_TRACE);
  697. auto ws = (cast(SplitPane) e.widget).getWeights();
  698. _prop.var.etc.bgImageSettingsSashL = ws[0];
  699. _prop.var.etc.bgImageSettingsSashR = ws[1];
  700. }
  701. }
  702. class DBgImgKeyCodeSash : DisposeListener {
  703. override void widgetDisposed(DisposeEvent e) { mixin(S_TRACE);
  704. auto ws = (cast(SplitPane) e.widget).getWeights();
  705. _prop.var.etc.bgImageKeyCodeSashL = ws[0];
  706. _prop.var.etc.bgImageKeyCodeSashR = ws[1];
  707. }
  708. }
  709. void construct2(CTabFolder tabf) { mixin(S_TRACE);
  710. auto comp = new Composite(tabf, SWT.NONE);
  711. _tabS = new CTabItem(tabf, SWT.NONE);
  712. _tabS.setText(_prop.msgs.bgImageAndKeyCode);
  713. _tabS.setControl(comp);
  714. comp.setLayout(new GridLayout(1, true));
  715. auto sash = new SplitPane(comp, SWT.HORIZONTAL);
  716. sash.setLayoutData(new GridData(GridData.FILL_BOTH));
  717. auto back = new Composite(sash, SWT.NONE);
  718. back.setLayout(zeroMarginGridLayout(1, true));
  719. { mixin(S_TRACE);
  720. auto grp = new Group(back, SWT.NONE);
  721. grp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  722. auto cl = new CenterLayout;
  723. cl.fillHorizontal = true;
  724. grp.setLayout(cl);
  725. grp.setText(_prop.msgs.bgImagesDefault);
  726. auto defBtn = new Button(grp, SWT.PUSH);
  727. defBtn.setText(_prop.msgs.setBgImagesDefault);
  728. defBtn.addSelectionListener(new DefBgSetting);
  729. }
  730. { mixin(S_TRACE);
  731. _bgStgs = new ToolsPane!BgImageSetting(_comm, (b) { ignoreMod = b; }, &catchMod, &applyEnabled, back, SWT.NONE);
  732. _bgStgs.setLayoutData(new GridData(GridData.FILL_BOTH));
  733. }
  734. { mixin(S_TRACE);
  735. auto grp = new Group(sash, SWT.NONE);
  736. grp.setLayoutData(new GridData(GridData.FILL_BOTH));
  737. grp.setLayout(new GridLayout(1, false));
  738. grp.setText(_prop.msgs.standardKeyCode);
  739. _keyCodes = new Text(grp, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL);
  740. createTextMenu!Text(_comm, _prop, _keyCodes, &catchMod);
  741. mod(_keyCodes);
  742. auto gd = new GridData(GridData.FILL_BOTH);
  743. gd.widthHint = _prop.var.etc.keyCodeWidth;
  744. gd.heightHint = 0;
  745. _keyCodes.setLayoutData(gd);
  746. }
  747. sash.setWeights([_prop.var.etc.bgImageKeyCodeSashL, _prop.var.etc.bgImageKeyCodeSashR]);
  748. sash.addDisposeListener(new DBgImgKeyCodeSash);
  749. }
  750. void construct3(CTabFolder tabf) { mixin(S_TRACE);
  751. auto comp = new Composite(tabf, SWT.NONE);
  752. comp.setLayout(new GridLayout(1, false));
  753. _tabT = new CTabItem(tabf, SWT.NONE);
  754. _tabT.setText(_prop.msgs.templates);
  755. _tabT.setControl(comp);
  756. auto sash = new SplitPane(comp, SWT.VERTICAL);
  757. sash.setLayoutData(new GridData(GridData.FILL_BOTH));
  758. _evTempls = new ToolsPane!EvTemplate(_comm, (b) { ignoreMod = b; }, &catchMod, &applyEnabled, sash, SWT.NONE);
  759. _evTempls.setLayoutData(new GridData(GridData.FILL_BOTH));
  760. _scTempls = new ToolsPane!ScTemplate(_comm, (b) { ignoreMod = b; }, &catchMod, &applyEnabled, sash, SWT.NONE);
  761. _scTempls.setLayoutData(new GridData(GridData.FILL_BOTH));
  762. sash.setWeights([_prop.var.etc.templatesSashL, _prop.var.etc.templatesSashR]);
  763. listener(sash, SWT.Dispose, { mixin(S_TRACE);
  764. auto ws = sash.getWeights();
  765. _prop.var.etc.templatesSashL = ws[0];
  766. _prop.var.etc.templatesSashR = ws[1];
  767. });
  768. }
  769. void construct4(CTabFolder tabf) { mixin(S_TRACE);
  770. auto comp = new Composite(tabf, SWT.NONE);
  771. comp.setLayout(new GridLayout(1, false));
  772. _tabC = new CTabItem(tabf, SWT.NONE);
  773. _tabC.setText(_prop.msgs.outerToolsAndClassicEngines);
  774. _tabC.setControl(comp);
  775. auto sash = new SplitPane(comp, SWT.VERTICAL);
  776. sash.setLayoutData(new GridData(GridData.FILL_BOTH));
  777. _tools = new ToolsPane!OuterTool(_comm, (b) { ignoreMod = b; }, &catchMod, &applyEnabled, sash, SWT.NONE);
  778. _tools.setLayoutData(new GridData(GridData.FILL_BOTH));
  779. _cEngines = new ToolsPane!ClassicEngine(_comm, (b) { ignoreMod = b; }, &catchMod, &applyEnabled, sash, SWT.NONE);
  780. _cEngines.setLayoutData(new GridData(GridData.FILL_BOTH));
  781. .listener(_tabf, SWT.Selection, { mixin(S_TRACE);
  782. if (_tabf.getSelection() !is _tabT && _cEngines.ceNameWin.getVisible()) { mixin(S_TRACE);
  783. _cEngines.ceNameWin.setVisible(false);
  784. _cEngines.features.setSelection(false);
  785. }
  786. });
  787. sash.setWeights([_prop.var.etc.toolsClassicEnginesSashL, _prop.var.etc.toolsClassicEnginesSashR]);
  788. listener(sash, SWT.Dispose, { mixin(S_TRACE);
  789. auto ws = sash.getWeights();
  790. _prop.var.etc.toolsClassicEnginesSashL = ws[0];
  791. _prop.var.etc.toolsClassicEnginesSashR = ws[1];
  792. });
  793. }
  794. Combo createEnumC(I)(Composite grp, string title, in I[] values, in string[] names, ref int[I] tblA, ref I[int] tblB, int hSpan = 1) { mixin(S_TRACE);
  795. assert (values.length == names.length);
  796. auto l = new Label(grp, SWT.NONE);
  797. l.setText(title);
  798. auto combo = new Combo(grp, SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY);
  799. mod(combo);
  800. auto gd = new GridData(GridData.FILL_HORIZONTAL);
  801. gd.horizontalSpan = hSpan;
  802. combo.setLayoutData(gd);
  803. combo.setVisibleItemCount(_prop.var.etc.comboVisibleItemCount);
  804. foreach (i, val; values) { mixin(S_TRACE);
  805. tblA[val] = i;
  806. tblB[i] = val;
  807. combo.add(names[i]);
  808. }
  809. return combo;
  810. }
  811. class DMISash : DisposeListener {
  812. override void widgetDisposed(DisposeEvent e) { mixin(S_TRACE);
  813. auto ws = (cast(SplitPane) e.widget).getWeights();
  814. _prop.var.etc.ignoreMenuSashL = ws[0];
  815. _prop.var.etc.ignoreMenuSashR = ws[1];
  816. }
  817. }
  818. void selectMenu() { mixin(S_TRACE);
  819. ignoreMod = true;
  820. scope (exit) ignoreMod = false;
  821. auto i = _menu.getSelectionIndex();
  822. if (-1 == i) return;
  823. auto itm = _menu.getItem(i);
  824. auto data = cast(SMenuData) itm.getData();
  825. _mnemonic.setText(data.mnemonic);
  826. _hotkey.accelerator = data.hotkey;
  827. _menuApply.setEnabled(false);
  828. _menuDel.setEnabled(_mnemonic.getText().length || _hotkey.widget.getText().length);
  829. }
  830. void applyMenu() { mixin(S_TRACE);
  831. ignoreMod = true;
  832. scope (exit) ignoreMod = false;
  833. auto i = _menu.getSelectionIndex();
  834. assert (i != -1);
  835. auto itm = _menu.getItem(i);
  836. auto data = cast(SMenuData) itm.getData();
  837. data.mnemonic = _mnemonic.getText();
  838. data.hotkey = _hotkey.acceleratorText;
  839. itm.setText(MenuProps.buildMenuSample(_prop.parent, data.id, data.mnemonic, data.hotkey));
  840. _menuApply.setEnabled(false);
  841. applyEnabled();
  842. }
  843. void refreshMenu() { mixin(S_TRACE);
  844. auto selID = MenuID.None;
  845. int selIndex = _menu.getSelectionIndex();
  846. if (-1 != selIndex) { mixin(S_TRACE);
  847. selID = (cast(SMenuData) _menu.getItem(selIndex).getData()).id;
  848. }
  849. _menu.removeAll();
  850. foreach (id; EnumMembers!MenuID) { mixin(S_TRACE);
  851. if (id == MenuID.None) continue;
  852. if (isNoKeyBindMenu(id)) continue;
  853. string name = _prop.var.menu.buildMenuSample(_prop.parent, id);
  854. if (!_menuIncSearch.match(name)) continue;
  855. auto itm = new TableItem(_menu, SWT.NONE);
  856. itm.setText(name);
  857. itm.setImage(_prop.images.menu(id));
  858. auto data = new SMenuData();
  859. data.id = id;
  860. data.mnemonic = _prop.var.menu.mnemonic(id);
  861. data.hotkey = _prop.var.menu.hotkey(id);
  862. itm.setData(data);
  863. if (id == selID) { mixin(S_TRACE);
  864. _menu.select(_menu.getItemCount() - 1);
  865. }
  866. }
  867. if (-1 == _menu.getSelectionIndex()) _menu.select(0);
  868. _menu.showSelection();
  869. selectMenu();
  870. }
  871. class SelectMenu : SelectionAdapter {
  872. override void widgetSelected(SelectionEvent e) { mixin(S_TRACE);
  873. selectMenu();
  874. }
  875. }
  876. class ModMenu : ModifyListener {
  877. override void modifyText(ModifyEvent e) { mixin(S_TRACE);
  878. if (ignoreMod) return;
  879. _menuApply.setEnabled(true);
  880. _menuDel.setEnabled(_mnemonic.getText().length || _hotkey.widget.getText().length);
  881. }
  882. }
  883. class DelMenuAccel : SelectionAdapter {
  884. override void widgetSelected(SelectionEvent e) { mixin(S_TRACE);
  885. ignoreMod = true;
  886. scope (exit) ignoreMod = false;
  887. _mnemonic.setText("");
  888. _hotkey.widget.setText("");
  889. applyMenu();
  890. _menuDel.setEnabled(false);
  891. }
  892. }
  893. class ApplyMenu : SelectionAdapter {
  894. override void widgetSelected(SelectionEvent e) { mixin(S_TRACE);
  895. applyMenu();
  896. }
  897. }
  898. class SelBoolTable : SelectionAdapter {
  899. override void widgetSelected(SelectionEvent e) { mixin(S_TRACE);
  900. if (e.detail != SWT.CHECK) return;
  901. applyEnabled();
  902. if (e.item is _contentsFloat && _contentsFloat.getChecked()) { mixin(S_TRACE);
  903. _contentsAutoHide.setChecked(false);
  904. }
  905. if (e.item is _contentsAutoHide && _contentsAutoHide.getChecked()) { mixin(S_TRACE);
  906. _contentsFloat.setChecked(false);
  907. }
  908. }
  909. }
  910. void construct5(CTabFolder tabf) { mixin(S_TRACE);
  911. auto comp = new Composite(tabf, SWT.NONE);
  912. _tabE = new CTabItem(tabf, SWT.NONE);
  913. _tabE.setText(_prop.msgs.etcSettings);
  914. _tabE.setControl(comp);
  915. comp.setLayout(new GridLayout(2, false));
  916. { mixin(S_TRACE);
  917. auto grp = new Group(comp, SWT.NONE);
  918. grp.setLayoutData(new GridData(GridData.FILL_VERTICAL));
  919. grp.setText(_prop.msgs.etcSettingsTitle);
  920. grp.setLayout(new GridLayout(5, false));
  921. auto boolTable = new Table(grp, SWT.BORDER | SWT.FULL_SELECTION | SWT.CHECK);
  922. new FullTableColumn(boolTable, SWT.NONE);
  923. boolTable.addSelectionListener(new SelBoolTable);
  924. auto tgd = new GridData(GridData.FILL_BOTH);
  925. tgd.horizontalSpan = 5;
  926. tgd.heightHint = 0;
  927. boolTable.setLayoutData(tgd);
  928. TableItem createB(string text) { mixin(S_TRACE);
  929. auto itm = new TableItem(boolTable, SWT.NONE);
  930. itm.setText(text);
  931. return itm;
  932. }
  933. if (!_comm.singleWindowMode(_prop)) { mixin(S_TRACE);
  934. _singleWindow = createB(_prop.msgs.singleWindow);
  935. }
  936. _showAreaDirTree = createB(_prop.msgs.showAreaDirTree);
  937. _showSummaryInAreaTable = createB(_prop.msgs.showSummaryInAreaTable);
  938. _clickIsOpenEvent = createB(_prop.msgs.clickIsOpenEvent);
  939. _smoothingCard = createB(_prop.msgs.smoothingCard);
  940. _showImagePreview = createB(_prop.msgs.showImagePreview);
  941. _editTriggerTypeIsQuick = createB(_prop.msgs.editTriggerTypeIsQuick);
  942. _classicStyleTree = createB(_prop.msgs.classicStyleTree);
  943. _adjustContentName = createB(_prop.msgs.adjustContentName);
  944. _radarStyleParams = createB(_prop.msgs.radarStyleParams);
  945. _showEventTreeMark = createB(_prop.msgs.showEventTreeMark);
  946. _showCardListHeader = createB(_prop.msgs.showCardListHeader);
  947. _showCardListTitle = createB(_prop.msgs.showCardListTitle);
  948. _showSkillCardLevel = createB(_prop.msgs.showSkillCardLevel);
  949. _ignoreEmptyStart = createB(_prop.msgs.ignoreEmptyStart);
  950. _expandXMLs = createB(_prop.msgs.expandXMLs);
  951. _contentsFloat = createB(_prop.msgs.contentsFloat);
  952. _contentsAutoHide = createB(_prop.msgs.contentsAutoHide);
  953. _comboListVisible = createB(_prop.msgs.comboListVisible);
  954. _xmlCopy = createB(_prop.msgs.xmlCopy);
  955. _showSpNature = createB(_prop.msgs.showSpNature);
  956. _saveInnerImagePath = createB(_prop.msgs.saveInnerImagePath);
  957. _linkCard = createB(_prop.msgs.linkCard);
  958. _traceDirectories = createB(_prop.msgs.traceDirectories);
  959. _logicalSort = createB(_prop.msgs.logicalSort);
  960. _copyDesc = createB(_prop.msgs.copyDesc);
  961. _refCardsAtEditBgImage = createB(_prop.msgs.refCardsAtEditBgImage);
  962. _floatMessagePreview = createB(_prop.msgs.floatMessagePreview);
  963. _addNewClassicEngine = createB(_prop.msgs.addNewClassicEngine);
  964. _doubleIO = createB(_prop.msgs.doubleIO);
  965. _switchTabWheel = createB(_prop.msgs.switchTabWheel);
  966. _closeTabWithMiddleClick = createB(_prop.msgs.closeTabWithMiddleClick);
  967. _openTabAtRightOfCurrentTab = createB(_prop.msgs.openTabAtRightOfCurrentTab);
  968. _reconstruction = createB(_prop.msgs.reconstruction);
  969. _openLastScenario = createB(_prop.msgs.openLastScenario);
  970. _showVariableValuesInEventText = createB(_prop.msgs.showVariableValuesInEventText);
  971. _cautionBeforeReplace = createB(_prop.msgs.cautionBeforeReplace);
  972. _saveNeedChanged = createB(_prop.msgs.saveNeedChanged);
  973. _applyDialogsBeforeSave = createB(_prop.msgs.applyDialogsBeforeSave);
  974. _useNamesAfterStandard = createB(_prop.msgs.useNamesAfterStandard);
  975. _selectVariableWithTree = createB(_prop.msgs.selectVariableWithTree);
  976. _autoUpdateJpy1File = createB(_prop.msgs.autoUpdateJpy1File);
  977. _straightEventTreeView = createB(_prop.msgs.straightEventTreeView);
  978. _gentleAngleEventTree = createB(_prop.msgs.gentleAngleEventTree);
  979. _forceIndentBranchContent = createB(_prop.msgs.forceIndentBranchContent);
  980. _showTerminalMark = createB(_prop.msgs.showTerminalMark);
  981. _clickIconIsStartEdit = createB(_prop.msgs.clickIconIsStartEdit);
  982. auto sep = new Label(grp, SWT.SEPARATOR | SWT.HORIZONTAL);
  983. auto sepgd = new GridData(GridData.FILL_HORIZONTAL);
  984. sepgd.horizontalSpan = 5;
  985. sep.setLayoutData(sepgd);
  986. immutable string[] targetVersionVals = [
  987. "CardWirthPy",
  988. // FIXME: CardWirth 1.60
  989. /+ "1.60",
  990. +/ "1.50",
  991. "1.30",
  992. "1.29",
  993. "1.28",
  994. ];
  995. string[] targetVersionNames = [
  996. _prop.msgs.cardWirthPy.value,
  997. ] ~ std.algorithm.map!((s) => .tryFormat(_prop.msgs.cardWirthWithVersion, s))(targetVersionVals[1..$]).array();
  998. _targetVersion = createEnumC(grp, _prop.msgs.targetVersion, targetVersionVals, targetVersionNames, _targetVersionTbl, _targetVersionTbl2, 4);
  999. auto dummy2 = new Composite(grp, SWT.NONE);
  1000. auto dgd2 = new GridData(GridData.FILL_HORIZONTAL);
  1001. dgd2.widthHint = 0;
  1002. dgd2.heightHint = 0;
  1003. dummy2.setLayoutData(dgd2);
  1004. auto tvHint = new Label(grp, SWT.NONE);
  1005. tvHint.setText(_prop.msgs.targetVersionHint);
  1006. auto tvHintGD = new GridData(GridData.FILL_HORIZONTAL);
  1007. tvHintGD.horizontalSpan = 4;
  1008. tvHint.setLayoutData(tvHintGD);
  1009. version (Windows) {
  1010. immutable int[] soundPlayTypeVals = [
  1011. SOUND_TYPE_AUTO,
  1012. SOUND_TYPE_SDL,
  1013. SOUND_TYPE_MCI,
  1014. SOUND_TYPE_APP
  1015. ];
  1016. immutable string[] soundPlayTypeNames = [
  1017. _prop.msgs.soundPlayTypeDef,
  1018. _prop.msgs.soundPlayTypeSDL,
  1019. _prop.msgs.soundPlayTypeMCI,
  1020. _prop.msgs.soundPlayTypeApp
  1021. ];
  1022. } else { mixin(S_TRACE);
  1023. immutable int[] soundPlayTypeVals = [
  1024. SOUND_TYPE_AUTO,
  1025. SOUND_TYPE_SDL,
  1026. SOUND_TYPE_APP
  1027. ];
  1028. immutable string[] soundPlayTypeNames = [
  1029. _prop.msgs.soundPlayTypeDef,
  1030. _prop.msgs.soundPlayTypeSDL,
  1031. _prop.msgs.soundPlayTypeApp
  1032. ];
  1033. }
  1034. Spinner createVolume() { mixin(S_TRACE);
  1035. auto l1 = new Label(grp, SWT.CENTER);
  1036. l1.setText(_prop.msgs.soundVolume);
  1037. auto spn = new Spinner(grp, SWT.BORDER);
  1038. initSpinner(spn);
  1039. spn.setMinimum(0);
  1040. spn.setMaximum(100);
  1041. mod(spn);
  1042. auto l2 = new Label(grp, SWT.CENTER);
  1043. l2.setText(_prop.msgs.soundVolumePer);
  1044. return spn;
  1045. }
  1046. _soundPlayType = createEnumC(grp, _prop.msgs.soundPlayType, soundPlayTypeVals, soundPlayTypeNames, _soundPlayTypeTbl, _soundPlayTypeTbl2);
  1047. _bgmVolume = createVolume();
  1048. string sameBGM = _prop.msgs.soundPlaySameBGM;
  1049. _soundEffectPlayType = createEnumC(grp, _prop.msgs.soundEffectPlayType, [SOUND_TYPE_SAME_BGM] ~ soundPlayTypeVals, sameBGM ~ soundPlayTypeNames, _soundEffectPlayTypeTbl, _soundEffectPlayTypeTbl2);
  1050. _seVolume = createVolume();
  1051. auto dummy = new Composite(grp, SWT.NONE);
  1052. auto dgd = new GridData(GridData.FILL_HORIZONTAL);
  1053. dgd.widthHint = 0;
  1054. dgd.heightHint = 0;
  1055. dummy.setLayoutData(dgd);
  1056. auto volc = new Label(grp, SWT.NONE);
  1057. volc.setText(_prop.msgs.soundCaution);
  1058. auto volcgd = new GridData(GridData.FILL_HORIZONTAL);
  1059. volcgd.horizontalSpan = 4;
  1060. volc.setLayoutData(volcgd);
  1061. _dialogStatus = createEnumC(grp, _prop.msgs.dialogStatus, [
  1062. cast(int) DialogStatus.Top,
  1063. cast(int) DialogStatus.Under,
  1064. cast(int) DialogStatus.UnderWithCoupon,
  1065. ], [
  1066. _prop.msgs.dialogStatusName(DialogStatus.Top),
  1067. _prop.msgs.dialogStatusName(DialogStatus.Under),
  1068. _prop.msgs.dialogStatusName(DialogStatus.UnderWithCoupon),
  1069. ], _dialogStatusTbl, _dialogStatusTbl2, 4);
  1070. }
  1071. { mixin(S_TRACE);
  1072. auto sash = new SplitPane(comp, SWT.VERTICAL);
  1073. sash.setLayoutData(new GridData(GridData.FILL_BOTH));
  1074. { mixin(S_TRACE);
  1075. auto grp = new Group(sash, SWT.NONE);
  1076. grp.setText(_prop.msgs.keyBind);
  1077. grp.setLayout(new GridLayout(4, false));
  1078. auto l1 = new Label(grp, SWT.NONE);
  1079. l1.setText(_prop.msgs.mnemonic);
  1080. _mnemonic = mnemonicText(grp, SWT.BORDER);
  1081. createTextMenu!Text(_comm, _prop, _mnemonic, &catchMod);
  1082. _mnemonic.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  1083. _mnemonic.addModifyListener(new ModMenu);
  1084. _menuApply = new Button(grp, SWT.PUSH);
  1085. _menuApply.setText(_prop.msgs.apply);
  1086. _menuApply.addSelectionListener(new ApplyMenu);
  1087. _menuDel = new Button(grp, SWT.PUSH);
  1088. _menuDel.setText(_prop.msgs.del);
  1089. _menuDel.addSelectionListener(new DelMenuAccel);
  1090. auto l2 = new Label(grp, SWT.NONE);
  1091. l2.setText(_prop.msgs.hotkey);
  1092. _hotkey = new HotKeyField(grp, SWT.BORDER);
  1093. createTextMenu!Text(_comm, _prop, _hotkey.widget, &catchMod);
  1094. auto hgd = new GridData(GridData.FILL_HORIZONTAL);
  1095. hgd.horizontalSpan = 3;
  1096. _hotkey.widget.setLayoutData(hgd);
  1097. _hotkey.widget.addModifyListener(new ModMenu);
  1098. _menu = new Table(grp, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL | SWT.FULL_SELECTION);
  1099. auto mgd = new GridData(GridData.FILL_BOTH);
  1100. mgd.horizontalSpan = 4;
  1101. mgd.heightHint = _prop.var.etc.menuSettingsHeight;
  1102. _menu.setLayoutData(mgd);
  1103. new FullTableColumn(_menu, SWT.NONE);
  1104. _menu.addSelectionListener(new SelectMenu);
  1105. _menuIncSearch = new IncSearch(_comm, _menu);
  1106. _menuIncSearch.modEvent ~= &refreshMenu;
  1107. auto menu = new Menu(_menu.getShell(), SWT.POP_UP);
  1108. createMenuItem(_comm, menu, MenuID.IncSearch, &menuIncSearch, null);
  1109. _menu.setMenu(menu);
  1110. refreshMenu();
  1111. grp.setTabList([_menuApply, _menuDel, _menu]);
  1112. }
  1113. { mixin(S_TRACE);
  1114. auto grp = new Group(sash, SWT.NONE);
  1115. grp.setText(_prop.msgs.ignorePaths);
  1116. grp.setLayout(new GridLayout(1, false));
  1117. _ignorePaths = new Text(grp, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL);
  1118. createTextMenu!Text(_comm, _prop, _ignorePaths, &catchMod);
  1119. mod(_ignorePaths);
  1120. auto gdp = new GridData(GridData.FILL_BOTH);
  1121. gdp.widthHint = _prop.var.etc.ignorePathsWidth;
  1122. gdp.heightHint = 0;
  1123. _ignorePaths.setLayoutData(gdp);
  1124. }
  1125. sash.setWeights([_prop.var.etc.ignoreMenuSashL, _prop.var.etc.ignoreMenuSashR]);
  1126. sash.addDisposeListener(new DMISash);
  1127. }
  1128. }
  1129. private RefE _refe;
  1130. private void refreshScenario(Summary summ) { mixin(S_TRACE);
  1131. _summ = summ;
  1132. }
  1133. private void refreshEnabled() { mixin(S_TRACE);
  1134. _backupDir.setEnabled(_backupEnabled.getSelection());
  1135. _backupIntervalTypeTime.setEnabled(_backupEnabled.getSelection());
  1136. _backupIntervalTypeEdit.setEnabled(_backupEnabled.getSelection());
  1137. _backupIntervalTime.setEnabled(_backupEnabled.getSelection() && _backupIntervalTypeTime.getSelection());
  1138. _backupIntervalEdit.setEnabled(_backupEnabled.getSelection() && _backupIntervalTypeEdit.getSelection());
  1139. _backupCount.setEnabled(_backupEnabled.getSelection());
  1140. _backupRef.setEnabled(_backupEnabled.getSelection());
  1141. _backupRefAuthor.setEnabled(_backupEnabled.getSelection());
  1142. _autoSave.setEnabled(_backupEnabled.getSelection());
  1143. _backupArchived.setEnabled(_backupEnabled.getSelection());
  1144. _backupBeforeSaveDir.setEnabled(_backupBeforeSaveEnabled.getSelection());
  1145. _backupBeforeSaveRef.setEnabled(_backupBeforeSaveEnabled.getSelection());
  1146. }
  1147. void refEngineEnabled() { mixin(S_TRACE);
  1148. _findEnginePath.setEnabled(0 == _enginePath.getText().length);
  1149. _enginePath.setEnabled(!_findEnginePath.getSelection() || _enginePath.getText().length);
  1150. _refEnginePath.setEnabled(_enginePath.getEnabled());
  1151. }
  1152. public:
  1153. this (Commons comm, Props prop, Shell shell, DockingFolderCTC dock, Summary summ, void delegate() sendReloadProps) { mixin(S_TRACE);
  1154. super(prop, shell, false, prop.msgs.dlgTitSettings, prop.images.menu(MenuID.Settings), true, prop.var.settingsDlg, true);
  1155. _comm = comm;
  1156. _prop = prop;
  1157. _dock = dock;
  1158. _summ = summ;
  1159. _sendReloadProps = sendReloadProps;
  1160. }
  1161. protected:
  1162. override void setup(Composite area) { mixin(S_TRACE);
  1163. area.setLayout(windowGridLayout(1, true));
  1164. _comm.refScenario.add(&refreshScenario);
  1165. _comm.refHistories.add(&refHistories);
  1166. _comm.refSearchHistories.add(&refSearchHistories);
  1167. area.addDisposeListener(new class DisposeListener {
  1168. override void widgetDisposed(DisposeEvent e) { mixin(S_TRACE);
  1169. _comm.refScenario.remove(&refreshScenario);
  1170. _comm.refHistories.remove(&refHistories);
  1171. _comm.refSearchHistories.remove(&refSearchHistories);
  1172. }
  1173. });
  1174. _tabf = new CTabFolder(area, SWT.BORDER);
  1175. _tabf.setLayoutData(new GridData(GridData.FILL_BOTH));
  1176. _refe = new RefE;
  1177. construct1(_tabf);
  1178. construct2(_tabf);
  1179. construct3(_tabf);
  1180. construct4(_tabf);
  1181. construct5(_tabf);
  1182. _bgStgs.setup(_prop.var.etc.bgImageSettings, _prop.var.etc.bgImageSettingsSashL.value, _prop.var.etc.bgImageSettingsSashR.value);
  1183. _cEngines.setup(_prop.var.etc.classicEngines, _prop.var.etc.classicEnginesSashL.value, _prop.var.etc.classicEnginesSashR.value);
  1184. _tools.setup(_prop.var.etc.outerTools, _prop.var.etc.outerToolsSashL.value, _prop.var.etc.outerToolsSashR.value);
  1185. _scTempls.setup(_prop.var.etc.scenarioTemplates, _prop.var.etc.scenarioTemplatesSashL.value, _prop.var.etc.scenarioTemplatesSashR.value);
  1186. _evTempls.setup(_prop.var.etc.eventTemplates, _prop.var.etc.eventTemplatesSashL.value, _prop.var.etc.eventTemplatesSashR.value);
  1187. _tools.setShortcutWeights(_prop.var.etc.outerToolShortcutSashL.value, _prop.var.etc.outerToolShortcutSashR.value);
  1188. _cEngines.setShortcutWeights(_prop.var.etc.classicEngineShortcutSashL.value, _prop.var.etc.classicEngineShortcutSashR.value);
  1189. _evTempls.setShortcutWeights(_prop.var.etc.eventTemplateShortcutSashL.value, _prop.var.etc.eventTemplateShortcutSashR.value);
  1190. _enginePath.setText(_prop.var.etc.enginePath);
  1191. _findEnginePath.setSelection(_prop.var.etc.findEnginePath);
  1192. refEngineEnabled();
  1193. _tempDir.setText(_prop.var.etc.tempPath);
  1194. _backupDir.setText(_prop.var.etc.backupPath);
  1195. _backupEnabled.setSelection(_prop.var.etc.backupEnabled);
  1196. _backupIntervalTypeTime.setSelection(_prop.var.etc.backupIntervalType != BackupType.Edit);
  1197. _backupIntervalTypeEdit.setSelection(_prop.var.etc.backupIntervalType == BackupType.Edit);
  1198. _backupIntervalTime.setSelection(_prop.var.etc.backupInterval);
  1199. _backupIntervalEdit.setSelection(_prop.var.etc.backupIntervalEdit);
  1200. _backupCount.setSelection(_prop.var.etc.backupCount);
  1201. _backupRefAuthor.setSelection(_prop.var.etc.backupRefAuthor);
  1202. _autoSave.setSelection(_prop.var.etc.autoSave);
  1203. _backupArchived.setSelection(_prop.var.etc.backupArchived);
  1204. _backupBeforeSaveDir.setText(_prop.var.etc.backupBeforeSavePath);
  1205. _backupBeforeSaveEnabled.setSelection(_prop.var.etc.backupBeforeSaveEnabled);
  1206. _author.setText(_prop.var.etc.defaultAuthor);
  1207. _wallpaper.setText(_prop.var.etc.wallpaper);
  1208. auto wsp = _prop.var.etc.wallpaperStyle in _wallpaperStyleTbl;
  1209. if (wsp) { mixin(S_TRACE);
  1210. _wallpaperStyle.select(*wsp);
  1211. } else { mixin(S_TRACE);
  1212. _wallpaperStyle.select(WallpaperStyle.Tile);
  1213. }
  1214. _histMax.setSelection(_prop.var.etc.historyMax);
  1215. _sHistMax.setSelection(_prop.var.etc.searchHistoryMax);
  1216. _undoMaxMainView.setSelection(_prop.var.etc.undoMaxMainView);
  1217. _undoMaxEvent.setSelection(_prop.var.etc.undoMaxEvent);
  1218. _undoMaxReplace.setSelection(_prop.var.etc.undoMaxReplace);
  1219. _undoMaxEtc.setSelection(_prop.var.etc.undoMaxEtc);
  1220. string ipbuf = "";
  1221. foreach (path; _prop.var.etc.ignorePaths) { mixin(S_TRACE);
  1222. ipbuf ~= path ~ "\n";
  1223. }
  1224. _ignorePaths.setText(ipbuf);
  1225. _showAreaDirTree.setChecked(_prop.var.etc.showAreaDirTree);
  1226. _showSummaryInAreaTable.setChecked(_prop.var.etc.showSummaryInAreaTable);
  1227. _clickIsOpenEvent.setChecked(_prop.var.etc.clickIsOpenEvent);
  1228. _expandXMLs.setChecked(_prop.var.etc.expandXMLs);
  1229. _smoothingCard.setChecked(_prop.var.etc.smoothingCard);
  1230. _showImagePreview.setChecked(_prop.var.etc.showImagePreview);
  1231. _editTriggerTypeIsQuick.setChecked(_prop.var.etc.editTriggerType is EditTrigger.Quick);
  1232. _classicStyleTree.setChecked(_prop.var.etc.classicStyleTree);
  1233. _adjustContentName.setChecked(_prop.var.etc.adjustContentName);
  1234. _radarStyleParams.setChecked(_prop.var.etc.radarStyleParams);
  1235. _showEventTreeMark.setChecked(_prop.var.etc.showEventTreeMark);
  1236. _showCardListHeader.setChecked(_prop.var.etc.showCardListHeader);
  1237. _showCardListTitle.setChecked(_prop.var.etc.showCardListTitle);
  1238. _showSkillCardLevel.setChecked(_prop.var.etc.showSkillCardLevel);
  1239. _ignoreEmptyStart.setChecked(_prop.var.etc.ignoreEmptyStart);
  1240. if (_singleWindow) { mixin(S_TRACE);
  1241. _singleWindow.setChecked(_prop.var.etc.singleWindow);
  1242. }
  1243. _contentsFloat.setChecked(_prop.var.etc.contentsFloat);
  1244. _contentsAutoHide.setChecked(_prop.var.etc.contentsAutoHide);
  1245. _comboListVisible.setChecked(_prop.var.etc.comboListVisible);
  1246. _xmlCopy.setChecked(_prop.var.etc.xmlCopy);
  1247. _showSpNature.setChecked(_prop.var.etc.showSpNature);
  1248. _saveInnerImagePath.setChecked(_prop.var.etc.saveInnerImagePath);
  1249. _linkCard.setChecked(_prop.var.etc.linkCard);
  1250. _traceDirectories.setChecked(_prop.var.etc.traceDirectories);
  1251. _logicalSort.setChecked(_prop.var.etc.logicalSort);
  1252. _copyDesc.setChecked(_prop.var.etc.copyDesc);
  1253. _refCardsAtEditBgImage.setChecked(_prop.var.etc.refCardsAtEditBgImage);
  1254. _floatMessagePreview.setChecked(_prop.var.etc.floatMessagePreview);
  1255. _addNewClassicEngine.setChecked(_prop.var.etc.addNewClassicEngine);
  1256. _doubleIO.setChecked(_prop.var.etc.doubleIO);
  1257. _switchTabWheel.setChecked(_prop.var.etc.switchTabWheel);
  1258. _closeTabWithMiddleClick.setChecked(_prop.var.etc.closeTabWithMiddleClick);
  1259. _openTabAtRightOfCurrentTab.setChecked(_prop.var.etc.openTabAtRightOfCurrentTab);
  1260. _reconstruction.setChecked(_prop.var.etc.reconstruction);
  1261. _openLastScenario.setChecked(_prop.var.etc.openLastScenario);
  1262. _showVariableValuesInEventText.setChecked(_prop.var.etc.showVariableValuesInEventText);
  1263. _cautionBeforeReplace.setChecked(_prop.var.etc.cautionBeforeReplace);
  1264. _saveNeedChanged.setChecked(_prop.var.etc.saveNeedChanged);
  1265. _applyDialogsBeforeSave.setChecked(_prop.var.etc.applyDialogsBeforeSave);
  1266. _useNamesAfterStandard.setChecked(_prop.var.etc.useNamesAfterStandard);
  1267. _selectVariableWithTree.setChecked(_prop.var.etc.selectVariableWithTree);
  1268. _autoUpdateJpy1File.setChecked(_prop.var.etc.autoUpdateJpy1File);
  1269. _straightEventTreeView.setChecked(_prop.var.etc.straightEventTreeView);
  1270. _gentleAngleEventTree.setChecked(_prop.var.etc.gentleAngleEventTree);
  1271. _forceIndentBranchContent.setChecked(_prop.var.etc.forceIndentBranchContent);
  1272. _showTerminalMark.setChecked(_prop.var.etc.showTerminalMark);
  1273. _clickIconIsStartEdit.setChecked(_prop.var.etc.clickIconIsStartEdit);
  1274. auto tVer = _prop.var.etc.targetVersion in _targetVersionTbl;
  1275. if (tVer) { mixin(S_TRACE);
  1276. _targetVersion.select(*tVer);
  1277. } else { mixin(S_TRACE);
  1278. _targetVersion.select(0);
  1279. }
  1280. auto sptp = _prop.var.etc.soundPlayType in _soundPlayTypeTbl;
  1281. if (sptp) { mixin(S_TRACE);
  1282. _soundPlayType.select(*sptp);
  1283. } else { mixin(S_TRACE);
  1284. _soundPlayType.select(0);
  1285. }
  1286. _bgmVolume.setSelection(_prop.var.etc.bgmVolume);
  1287. auto septp = _prop.var.etc.soundEffectPlayType in _soundEffectPlayTypeTbl;
  1288. if (septp) { mixin(S_TRACE);
  1289. _soundEffectPlayType.select(*septp);
  1290. } else { mixin(S_TRACE);
  1291. _soundEffectPlayType.select(0);
  1292. }
  1293. _seVolume.setSelection(_prop.var.etc.seVolume);
  1294. auto dsp = _prop.var.etc.dialogStatus in _dialogStatusTbl;
  1295. if (dsp) { mixin(S_TRACE);
  1296. _dialogStatus.select(*dsp);
  1297. } else { mixin(S_TRACE);
  1298. _dialogStatus.select(DialogStatus.Top);
  1299. }
  1300. _savedSound.setText(_prop.var.etc.savedSound);
  1301. _bgImagesDefault = _prop.var.etc.bgImagesDefault.dup;
  1302. string buf = "";
  1303. foreach (kc; _prop.var.etc.standardKeyCodes) { mixin(S_TRACE);
  1304. buf ~= kc ~ "\n";
  1305. }
  1306. _keyCodes.setText(buf);
  1307. refreshEnabled();
  1308. }
  1309. override bool apply() { mixin(S_TRACE);
  1310. void err(CTabItem tab, Text t, string msg) { mixin(S_TRACE);
  1311. auto dlg = new MessageBox(t.getShell(), SWT.ICON_WARNING | SWT.OK);
  1312. dlg.setText(_prop.msgs.dlgTitWarning);
  1313. dlg.setMessage(msg);
  1314. dlg.open();
  1315. tab.getParent().setSelection(tab);
  1316. t.setFocus();
  1317. }
  1318. string engine;
  1319. try { mixin(S_TRACE);
  1320. engine = _enginePath.getText();
  1321. } catch { mixin(S_TRACE);
  1322. err(_tabB, _enginePath, .tryFormat(_prop.msgs.errorEnginePath, _prop.var.etc.engine));
  1323. return false;
  1324. }
  1325. if (engine.length) { mixin(S_TRACE);
  1326. if (!.exists(engine) || .isDir(engine)) { mixin(S_TRACE);
  1327. err(_tabB, _enginePath, .tryFormat(_prop.msgs.errorEnginePath, _prop.var.etc.engine));
  1328. return false;
  1329. }
  1330. }
  1331. string temp;
  1332. try { mixin(S_TRACE);
  1333. temp = _tempDir.getText();
  1334. } catch { mixin(S_TRACE);
  1335. err(_tabB, _tempDir, _prop.msgs.errorTempPath);
  1336. return false;
  1337. }
  1338. string backup;
  1339. try { mixin(S_TRACE);
  1340. backup = _backupDir.getText();
  1341. } catch { mixin(S_TRACE);
  1342. err(_tabB, _backupDir, _prop.msgs.errorBackupPath);
  1343. return false;
  1344. }
  1345. string backupBeforeSave;
  1346. try { mixin(S_TRACE);
  1347. backupBeforeSave = _backupBeforeSaveDir.getText();
  1348. } catch { mixin(S_TRACE);
  1349. err(_tabB, _backupBeforeSaveDir, _prop.msgs.errorBackupBeforeSavePath);
  1350. return false;
  1351. }
  1352. string[] noApplyNames;
  1353. if (_bgStgs.noApply) noApplyNames ~= _bgStgs.boxName;
  1354. if (_tools.noApply) noApplyNames ~= _tools.boxName;
  1355. if (_cEngines.noApply) noApplyNames ~= _cEngines.boxName;
  1356. if (_scTempls.noApply) noApplyNames ~= _scTempls.boxName;
  1357. if (_evTempls.noApply) noApplyNames ~= _evTempls.boxName;
  1358. if (noApplyNames.length) { mixin(S_TRACE);
  1359. auto dlg = new MessageBox(getShell(), SWT.YES | SWT.NO | SWT.ICON_QUESTION);
  1360. dlg.setText(_prop.msgs.dlgTitQuestion);
  1361. if (1 < noApplyNames.length) { mixin(S_TRACE);
  1362. dlg.setMessage(.tryFormat(_prop.msgs.dlgMsgExistsNoApplySettings, std.string.join(noApplyNames, ", ")));
  1363. } else { mixin(S_TRACE);
  1364. dlg.setMessage(.tryFormat(_prop.msgs.dlgMsgExistsNoApplySettingsSingle, noApplyNames[0]));
  1365. }
  1366. if (SWT.YES != dlg.open()) return false;
  1367. }
  1368. auto oldStgs = OldSettings(_prop);
  1369. scope (exit) {
  1370. oldStgs.raiseEvent(_comm);
  1371. }
  1372. _prop.var.etc.enginePath = engine;
  1373. _prop.var.etc.findEnginePath = _findEnginePath.getSelection();
  1374. if (_language.getSelectionIndex() <= 0) { mixin(S_TRACE);
  1375. _prop.var.etc.languageFile = "";
  1376. _prop.var.etc.useSystemLanguage = true;
  1377. } else { mixin(S_TRACE);
  1378. _prop.var.etc.languageFile = _msgsTableFile[_msgsTableIndex[_language.getSelectionIndex()]];
  1379. _prop.var.etc.useSystemLanguage = false;
  1380. }
  1381. _prop.var.etc.tempPath = temp;
  1382. _prop.var.etc.backupPath = backup;
  1383. _prop.var.etc.backupEnabled = _backupEnabled.getSelection();
  1384. if (_backupIntervalTypeEdit.getSelection()) { mixin(S_TRACE);
  1385. _prop.var.etc.backupIntervalType = cast(int)BackupType.Edit;
  1386. } else { mixin(S_TRACE);
  1387. _prop.var.etc.backupIntervalType = cast(int)BackupType.Time;
  1388. }
  1389. _prop.var.etc.backupInterval = _backupIntervalTime.getSelection();
  1390. _prop.var.etc.backupIntervalEdit = _backupIntervalEdit.getSelection();
  1391. _prop.var.etc.backupCount = _backupCount.getSelection();
  1392. _prop.var.etc.backupRefAuthor = _backupRefAuthor.getSelection();
  1393. _prop.var.etc.autoSave = _autoSave.getSelection();
  1394. _prop.var.etc.backupArchived = _backupArchived.getSelection();
  1395. _prop.var.etc.backupBeforeSavePath = backupBeforeSave;
  1396. _prop.var.etc.backupBeforeSaveEnabled = _backupBeforeSaveEnabled.getSelection();
  1397. _prop.var.etc.defaultAuthor = _author.getText();
  1398. _prop.var.etc.wallpaper = _wallpaper.getText();
  1399. _prop.var.etc.wallpaperStyle = cast(WallpaperStyle) _wallpaperStyleTbl2[_wallpaperStyle.getSelectionIndex()];
  1400. _prop.var.etc.historyMax = _histMax.getSelection();
  1401. _prop.var.etc.searchHistoryMax = _sHistMax.getSelection();
  1402. _prop.var.etc.undoMaxMainView = _undoMaxMainView.getSelection();
  1403. _prop.var.etc.undoMaxEvent = _undoMaxEvent.getSelection();
  1404. _prop.var.etc.undoMaxReplace = _undoMaxReplace.getSelection();
  1405. _prop.var.etc.undoMaxEtc = _undoMaxEtc.getSelection();
  1406. string[] ipLines = splitLines!string(_ignorePaths.getText());
  1407. if (ipLines.length > 0) { mixin(S_TRACE);
  1408. int i;
  1409. for (i = ipLines.length - 1; i >= 0 && ipLines[i].length == 0; i--) { mixin(S_TRACE);
  1410. ;
  1411. }
  1412. _prop.var.etc.ignorePaths = ipLines[0 .. i + 1];
  1413. } else { mixin(S_TRACE);
  1414. _prop.var.etc.ignorePaths = [];
  1415. }
  1416. if (_singleWindow) { mixin(S_TRACE);
  1417. _prop.var.etc.singleWindow = _singleWindow.getChecked();
  1418. }
  1419. _prop.var.etc.showAreaDirTree = _showAreaDirTree.getChecked();
  1420. _prop.var.etc.showSummaryInAreaTable = _showSummaryInAreaTable.getChecked();
  1421. _prop.var.etc.clickIsOpenEvent = _clickIsOpenEvent.getChecked();
  1422. _prop.var.etc.smoothingCard = _smoothingCard.getChecked();
  1423. _prop.var.etc.showImagePreview = _showImagePreview.getChecked();
  1424. _prop.var.etc.editTriggerType = _editTriggerTypeIsQuick.getChecked() ? EditTrigger.Quick : EditTrigger.Slow;
  1425. _prop.var.etc.classicStyleTree = _classicStyleTree.getChecked();
  1426. _prop.var.etc.adjustContentName = _adjustContentName.getChecked();
  1427. _prop.var.etc.radarStyleParams = _radarStyleParams.getChecked();
  1428. _prop.var.etc.showEventTreeMark = _showEventTreeMark.getChecked();
  1429. _prop.var.etc.showCardListHeader = _showCardListHeader.getChecked();
  1430. _prop.var.etc.showCardListTitle = _showCardListTitle.getChecked();
  1431. _prop.var.etc.showSkillCardLevel = _showSkillCardLevel.getChecked();
  1432. _prop.var.etc.ignoreEmptyStart = _ignoreEmptyStart.getChecked();
  1433. _prop.var.etc.expandXMLs = _expandXMLs.getChecked();
  1434. _prop.var.etc.xmlCopy = _xmlCopy.getChecked();
  1435. _prop.var.etc.showSpNature = _showSpNature.getChecked();
  1436. _prop.var.etc.saveInnerImagePath = _saveInnerImagePath.getChecked();
  1437. _prop.var.etc.linkCard = _linkCard.getChecked();
  1438. _prop.var.etc.traceDirectories = _traceDirectories.getChecked();
  1439. _prop.var.etc.logicalSort = _logicalSort.getChecked();
  1440. _prop.var.etc.copyDesc = _copyDesc.getChecked();
  1441. _prop.var.etc.refCardsAtEditBgImage = _refCardsAtEditBgImage.getChecked();
  1442. _prop.var.etc.floatMessagePreview = _floatMessagePreview.getChecked();
  1443. _prop.var.etc.addNewClassicEngine = _addNewClassicEngine.getChecked();
  1444. _prop.var.etc.doubleIO = _doubleIO.getChecked();
  1445. _prop.var.etc.switchTabWheel = _switchTabWheel.getChecked();
  1446. _prop.var.etc.closeTabWithMiddleClick = _closeTabWithMiddleClick.getChecked();
  1447. _prop.var.etc.openTabAtRightOfCurrentTab = _openTabAtRightOfCurrentTab.getChecked();
  1448. _prop.var.etc.reconstruction = _reconstruction.getChecked();
  1449. _prop.var.etc.openLastScenario = _openLastScenario.getChecked();
  1450. _prop.var.etc.showVariableValuesInEventText = _showVariableValuesInEventText.getChecked();
  1451. _prop.var.etc.cautionBeforeReplace = _cautionBeforeReplace.getChecked();
  1452. _prop.var.etc.saveNeedChanged = _saveNeedChanged.getChecked();
  1453. _prop.var.etc.applyDialogsBeforeSave = _applyDialogsBeforeSave.getChecked();
  1454. _prop.var.etc.useNamesAfterStandard = _useNamesAfterStandard.getChecked();
  1455. _prop.var.etc.selectVariableWithTree = _selectVariableWithTree.getChecked();
  1456. _prop.var.etc.autoUpdateJpy1File = _autoUpdateJpy1File.getChecked();
  1457. _prop.var.etc.straightEventTreeView = _straightEventTreeView.getChecked();
  1458. _prop.var.etc.gentleAngleEventTree = _gentleAngleEventTree.getChecked();
  1459. _prop.var.etc.forceIndentBranchContent = _forceIndentBranchContent.getChecked();
  1460. _prop.var.etc.showTerminalMark = _showTerminalMark.getChecked();
  1461. _prop.var.etc.clickIconIsStartEdit = _clickIconIsStartEdit.getChecked();
  1462. _prop.var.etc.contentsFloat = _contentsFloat.getChecked();
  1463. _prop.var.etc.contentsAutoHide = _contentsAutoHide.getChecked();
  1464. _prop.var.etc.comboListVisible = _comboListVisible.getChecked();
  1465. _prop.var.etc.soundPlayType = _soundPlayTypeTbl2[_soundPlayType.getSelectionIndex()];
  1466. _prop.var.etc.targetVersion = _targetVersionTbl2[_targetVersion.getSelectionIndex()];
  1467. _prop.var.etc.bgmVolume = _bgmVolume.getSelection();
  1468. _prop.var.etc.soundEffectPlayType = _soundEffectPlayTypeTbl2[_soundEffectPlayType.getSelectionIndex()];
  1469. _prop.var.etc.seVolume = _seVolume.getSelection();
  1470. _prop.var.etc.dialogStatus = cast(DialogStatus) _dialogStatusTbl2[_dialogStatus.getSelectionIndex()];
  1471. _prop.var.etc.savedSound = _savedSound.getText();
  1472. if (_prop.var.etc.historyMax < _prop.var.etc.openHistories.length) { mixin(S_TRACE);
  1473. _prop.var.etc.openHistories
  1474. = _prop.var.etc.openHistories[0 .. _prop.var.etc.historyMax].dup;
  1475. }
  1476. if (_prop.var.etc.searchHistoryMax < _prop.var.etc.searchHistories.length) { mixin(S_TRACE);
  1477. _prop.var.etc.searchHistories
  1478. = _prop.var.etc.searchHistories[0 .. _prop.var.etc.searchHistoryMax].dup;
  1479. }
  1480. if (_prop.var.etc.searchHistoryMax < _prop.var.etc.grepDirHistories.length) { mixin(S_TRACE);
  1481. _prop.var.etc.grepDirHistories
  1482. = _prop.var.etc.grepDirHistories[0 .. _prop.var.etc.searchHistoryMax].dup;
  1483. }
  1484. _prop.var.etc.bgImageSettings = _bgStgs.array;
  1485. _prop.var.etc.bgImagesDefault = _bgImagesDefault;
  1486. string[] lines = splitLines!string(_keyCodes.getText());
  1487. if (lines.length > 0) { mixin(S_TRACE);
  1488. int i;
  1489. for (i = lines.length - 1; i >= 0 && lines[i].length == 0; i--) { mixin(S_TRACE);
  1490. ;
  1491. }
  1492. _prop.var.etc.standardKeyCodes = lines[0 .. i + 1];
  1493. } else { mixin(S_TRACE);
  1494. _prop.var.etc.standardKeyCodes = [];
  1495. }
  1496. _prop.var.etc.outerTools = _tools.array;
  1497. _prop.var.etc.classicEngines = _cEngines.array;
  1498. _prop.var.etc.eventTemplates = _evTempls.array;
  1499. _prop.var.etc.scenarioTemplates = _scTempls.array;
  1500. foreach (itm; _menu.getItems()) { mixin(S_TRACE);
  1501. auto data = cast(SMenuData) itm.getData();
  1502. _prop.var.menu.mnemonic(data.id, data.mnemonic);
  1503. _prop.var.menu.hotkey(data.id, data.hotkey);
  1504. }
  1505. if (_summ && findCWPy(_prop, _summ.useTemp ? _summ.zipName : _summ.scenarioPath)) { mixin(S_TRACE);
  1506. _enginePath.setText(_prop.var.etc.enginePath);
  1507. _findEnginePath.setSelection(_prop.var.etc.findEnginePath);
  1508. refEngineEnabled();
  1509. }
  1510. _prop.var.save(_dock);
  1511. _sendReloadProps();
  1512. return true;
  1513. }
  1514. }
  1515. struct OldSettings {
  1516. Props prop;
  1517. string targetVersion;
  1518. string oldEnginePath;
  1519. bool findEnginePath;
  1520. string oldWallpaper;
  1521. int oldWallpaperStyle;
  1522. const string[] oldKeyCodes;
  1523. const OuterTool[] tools;
  1524. const ClassicEngine[] cEngines;
  1525. const EvTemplate[] eventTemplates;
  1526. const string[] oldIgnorePaths;
  1527. bool oldSmoothingCard;
  1528. bool oldLogicalSort;
  1529. const OpenHistory[] oldOpenHistories;
  1530. const string[] oldSearchHistories;
  1531. const string[] oldReplaceHistories;
  1532. const string[] oldGrepDirHistories;
  1533. int oldUndoMaxMainView;
  1534. int oldUndoMaxEvent;
  1535. int oldUndoMaxReplace;
  1536. int oldUndoMaxEtc;
  1537. int oldDialogStatus;
  1538. string[MenuID] oldMnemonic;
  1539. string[MenuID] oldHotkey;
  1540. bool floatMessagePreview;
  1541. int bgmVolume;
  1542. int seVolume;
  1543. int soundPlayType;
  1544. int soundEffectPlayType;
  1545. bool showEventTreeMark;
  1546. bool showCardListHeader;
  1547. bool showCardListTitle;
  1548. bool showSkillCardLevel;
  1549. bool ignoreEmptyStart;
  1550. bool classicStyleTree;
  1551. bool radarStyleParams;
  1552. bool showSpNature;
  1553. bool showVariableValuesInEventText;
  1554. bool useNamesAfterStandard;
  1555. bool selectVariableWithTree;
  1556. bool straightEventTreeView;
  1557. bool gentleAngleEventTree;
  1558. bool forceIndentBranchContent;
  1559. bool showTerminalMark;
  1560. bool showSummaryInAreaTable;
  1561. bool showAreaDirTree;
  1562. bool contentsFloat;
  1563. bool contentsAutoHide;
  1564. this (Props prop) { mixin(S_TRACE);
  1565. this.prop = prop;
  1566. this.targetVersion = prop.var.etc.targetVersion;
  1567. this.oldEnginePath = prop.var.etc.enginePath;
  1568. this.oldWallpaper = prop.var.etc.wallpaper;
  1569. this.oldWallpaperStyle = prop.var.etc.wallpaperStyle;
  1570. this.oldKeyCodes = prop.var.etc.standardKeyCodes;
  1571. this.tools = prop.var.etc.outerTools;
  1572. this.cEngines = prop.var.etc.classicEngines;
  1573. this.eventTemplates = prop.var.etc.eventTemplates;
  1574. this.oldIgnorePaths = prop.var.etc.ignorePaths;
  1575. this.oldSmoothingCard = prop.var.etc.smoothingCard;
  1576. this.oldLogicalSort = prop.var.etc.logicalSort;
  1577. this.oldOpenHistories = prop.var.etc.openHistories;
  1578. this.oldSearchHistories = prop.var.etc.searchHistories;
  1579. this.oldGrepDirHistories = prop.var.etc.grepDirHistories;
  1580. this.oldReplaceHistories = prop.var.etc.replaceHistories;
  1581. this.oldUndoMaxMainView = prop.var.etc.undoMaxMainView;
  1582. this.oldUndoMaxEvent = prop.var.etc.undoMaxEvent;
  1583. this.oldUndoMaxReplace = prop.var.etc.undoMaxReplace;
  1584. this.oldUndoMaxEtc = prop.var.etc.undoMaxEtc;
  1585. this.oldDialogStatus = prop.var.etc.dialogStatus;
  1586. foreach (id; EnumMembers!MenuID) { mixin(S_TRACE);
  1587. if (isNoKeyBindMenu(id)) continue;
  1588. oldMnemonic[id] = prop.var.menu.mnemonic(id);
  1589. oldHotkey[id] = prop.var.menu.hotkey(id);
  1590. }
  1591. this.floatMessagePreview = prop.var.etc.floatMessagePreview;
  1592. this.bgmVolume = prop.var.etc.bgmVolume;
  1593. this.seVolume = prop.var.etc.seVolume;
  1594. this.soundPlayType = prop.var.etc.soundPlayType;
  1595. this.soundEffectPlayType = prop.var.etc.soundEffectPlayType;
  1596. this.showEventTreeMark = prop.var.etc.showEventTreeMark;
  1597. this.showCardListHeader = prop.var.etc.showCardListHeader;
  1598. this.showCardListTitle = prop.var.etc.showCardListTitle;
  1599. this.showSkillCardLevel = prop.var.etc.showSkillCardLevel;
  1600. this.ignoreEmptyStart = prop.var.etc.ignoreEmptyStart;
  1601. this.classicStyleTree = prop.var.etc.classicStyleTree;
  1602. this.radarStyleParams = prop.var.etc.radarStyleParams;
  1603. this.showSpNature = prop.var.etc.showSpNature;
  1604. this.showVariableValuesInEventText = prop.var.etc.showVariableValuesInEventText;
  1605. this.useNamesAfterStandard = prop.var.etc.useNamesAfterStandard;
  1606. this.selectVariableWithTree = prop.var.etc.selectVariableWithTree;
  1607. this.straightEventTreeView = prop.var.etc.straightEventTreeView;
  1608. this.gentleAngleEventTree = prop.var.etc.gentleAngleEventTree;
  1609. this.forceIndentBranchContent = prop.var.etc.forceIndentBranchContent;
  1610. this.showTerminalMark = prop.var.etc.showTerminalMark;
  1611. this.showSummaryInAreaTable = prop.var.etc.showSummaryInAreaTable;
  1612. this.showAreaDirTree = prop.var.etc.showAreaDirTree;
  1613. this.contentsFloat = prop.var.etc.contentsFloat;
  1614. this.contentsAutoHide = prop.var.etc.contentsAutoHide;
  1615. }
  1616. void raiseEvent(Commons comm) { mixin(S_TRACE);
  1617. bool refSkin = false;
  1618. if (targetVersion != prop.var.etc.targetVersion) { mixin(S_TRACE);
  1619. comm.refTargetVersion.call();
  1620. }
  1621. if (comm.summary && oldEnginePath != prop.var.etc.enginePath) { mixin(S_TRACE);
  1622. refSkin = true;
  1623. }
  1624. if (oldWallpaper != prop.var.etc.wallpaper || oldWallpaperStyle != prop.var.etc.wallpaperStyle) { mixin(S_TRACE);
  1625. if (oldWallpaper != prop.var.etc.wallpaper) { mixin(S_TRACE);
  1626. comm.refreshWallpaper(prop);
  1627. }
  1628. comm.refWallpaper.call();
  1629. }
  1630. if (oldKeyCodes != prop.var.etc.standardKeyCodes) { mixin(S_TRACE);
  1631. comm.refStandardKeyCodes.call();
  1632. }
  1633. if (tools != prop.var.etc.outerTools) { mixin(S_TRACE);
  1634. comm.refOuterTools.call();
  1635. }
  1636. if (cEngines != prop.var.etc.classicEngines) { mixin(S_TRACE);
  1637. refSkin = true;
  1638. }
  1639. if (eventTemplates != prop.var.etc.eventTemplates) { mixin(S_TRACE);
  1640. comm.refEventTemplates.call();
  1641. }
  1642. if (oldIgnorePaths != prop.var.etc.ignorePaths) { mixin(S_TRACE);
  1643. comm.refIgnorePaths.call();
  1644. }
  1645. if (oldSmoothingCard != prop.var.etc.smoothingCard) { mixin(S_TRACE);
  1646. comm.refCardState.call();
  1647. }
  1648. if (oldLogicalSort != prop.var.etc.logicalSort) { mixin(S_TRACE);
  1649. if (comm.summary) { mixin(S_TRACE);
  1650. if (prop.var.etc.logicalSort) { mixin(S_TRACE);
  1651. comm.summary.flagDirRoot.sorter = (string a, string b) { mixin(S_TRACE);
  1652. return ncmp(a, b);
  1653. };
  1654. } else { mixin(S_TRACE);
  1655. comm.summary.flagDirRoot.sorter = (string a, string b) { mixin(S_TRACE);
  1656. return cmp(a, b);
  1657. };
  1658. }
  1659. }
  1660. comm.refSortCondition.call();
  1661. }
  1662. if (refSkin) { mixin(S_TRACE);
  1663. comm.skin = findSkin(comm, prop, comm.summary, null, comm.skin.legacyEngine, false);
  1664. comm.refSkin.call();
  1665. }
  1666. comm.refClassicSkin.call();
  1667. if (oldOpenHistories != prop.var.etc.openHistories) { mixin(S_TRACE);
  1668. comm.refHistories.call();
  1669. }
  1670. if (oldSearchHistories != prop.var.etc.searchHistories || oldReplaceHistories != prop.var.etc.replaceHistories || oldGrepDirHistories != prop.var.etc.grepDirHistories) { mixin(S_TRACE);
  1671. comm.refSearchHistories.call();
  1672. }
  1673. if (oldUndoMaxMainView != prop.var.etc.undoMaxMainView
  1674. || oldUndoMaxEvent != prop.var.etc.undoMaxEvent
  1675. || oldUndoMaxReplace != prop.var.etc.undoMaxReplace
  1676. || oldUndoMaxEtc != prop.var.etc.undoMaxEtc) { mixin(S_TRACE);
  1677. comm.refUndoMax.call();
  1678. }
  1679. if (oldDialogStatus != prop.var.etc.dialogStatus) { mixin(S_TRACE);
  1680. comm.refContentText.call();
  1681. }
  1682. foreach (id; EnumMembers!MenuID) { mixin(S_TRACE);
  1683. if (isNoKeyBindMenu(id)) continue;
  1684. if (oldMnemonic[id] != prop.var.menu.mnemonic(id) || oldHotkey[id] != prop.var.menu.hotkey(id)) { mixin(S_TRACE);
  1685. comm.refMenu.call(id);
  1686. }
  1687. }
  1688. if (this.floatMessagePreview != prop.var.etc.floatMessagePreview) { mixin(S_TRACE);
  1689. int wg;
  1690. if (prop.var.etc.floatMessagePreview) { mixin(S_TRACE);
  1691. wg = -(cast(int) prop.looks.messageBounds.width);
  1692. } else { mixin(S_TRACE);
  1693. wg = prop.looks.messageBounds.width;
  1694. }
  1695. if (prop.var.etc.showMessagePreview) { mixin(S_TRACE);
  1696. prop.var.msgDlg.width = prop.var.msgDlg.width + wg;
  1697. }
  1698. if (prop.var.etc.showDialogPreview) { mixin(S_TRACE);
  1699. prop.var.speakDlg.width = prop.var.speakDlg.width + wg;
  1700. }
  1701. }
  1702. if (this.bgmVolume != prop.var.etc.bgmVolume) { mixin(S_TRACE);
  1703. .bgmVolume = prop.var.etc.bgmVolume;
  1704. }
  1705. if (this.seVolume != prop.var.etc.seVolume) { mixin(S_TRACE);
  1706. .seVolume = prop.var.etc.seVolume;
  1707. }
  1708. if (this.soundPlayType != prop.var.etc.soundPlayType || this.soundEffectPlayType != prop.var.etc.soundEffectPlayType) { mixin(S_TRACE);
  1709. comm.refSoundType.call();
  1710. }
  1711. if (this.showEventTreeMark != prop.var.etc.showEventTreeMark || this.showSkillCardLevel != prop.var.etc.showSkillCardLevel || this.ignoreEmptyStart != prop.var.etc.ignoreEmptyStart) { mixin(S_TRACE);
  1712. comm.refCardImageStatus.call();
  1713. }
  1714. if (this.classicStyleTree != prop.var.etc.classicStyleTree) { mixin(S_TRACE);
  1715. comm.refEventTreeStyle.call();
  1716. }
  1717. if (this.radarStyleParams != prop.var.etc.radarStyleParams) { mixin(S_TRACE);
  1718. comm.refRadarStyle.call();
  1719. }
  1720. if (this.showSpNature != prop.var.etc.showSpNature || this.useNamesAfterStandard != prop.var.etc.useNamesAfterStandard) { mixin(S_TRACE);
  1721. comm.refCoupons.call();
  1722. }
  1723. if (this.useNamesAfterStandard != prop.var.etc.useNamesAfterStandard) { mixin(S_TRACE);
  1724. comm.refKeyCodes.call();
  1725. }
  1726. if (this.showVariableValuesInEventText != prop.var.etc.showVariableValuesInEventText) { mixin(S_TRACE);
  1727. comm.refPreviewValues.call();
  1728. }
  1729. if (this.showCardListHeader != prop.var.etc.showCardListHeader) { mixin(S_TRACE);
  1730. comm.refShowCardListHeader.call();
  1731. }
  1732. if (this.showCardListTitle != prop.var.etc.showCardListTitle) { mixin(S_TRACE);
  1733. comm.refShowCardListTitle.call();
  1734. }
  1735. if (this.selectVariableWithTree != prop.var.etc.selectVariableWithTree) { mixin(S_TRACE);
  1736. comm.refVarSelectStyle.call();
  1737. }
  1738. if (this.straightEventTreeView != prop.var.etc.straightEventTreeView || this.gentleAngleEventTree != prop.var.etc.gentleAngleEventTree || this.forceIndentBranchContent != prop.var.etc.forceIndentBranchContent) { mixin(S_TRACE);
  1739. comm.refEventTreeViewStyle.call();
  1740. }
  1741. if (this.showTerminalMark != prop.var.etc.showTerminalMark) { mixin(S_TRACE);
  1742. comm.refTerminalMark.call();
  1743. }
  1744. if (this.showSummaryInAreaTable != prop.var.etc.showSummaryInAreaTable) { mixin(S_TRACE);
  1745. comm.refAreaTable.call();
  1746. }
  1747. if (this.showAreaDirTree != prop.var.etc.showAreaDirTree) { mixin(S_TRACE);
  1748. comm.refTableViewStyle.call();
  1749. }
  1750. if (this.contentsFloat != prop.var.etc.contentsFloat || this.contentsAutoHide != prop.var.etc.contentsAutoHide) {
  1751. comm.refContentsToolBoxStyle.call();
  1752. }
  1753. }
  1754. }
  1755. class DefBgImgDialog : AbsDialog {
  1756. private:
  1757. Commons _comm;
  1758. Props _prop;
  1759. BgImageContainer _cont;
  1760. BgImagesView _view;
  1761. public:
  1762. this (Commons comm, Props prop, Shell shell, BgImageS[] bgImagesDefault) { mixin(S_TRACE);
  1763. super(prop, shell, false, prop.msgs.dlgTitBgImagesDefault,
  1764. prop.images.menu(MenuID.Settings), true, prop.var.bgImagesDlg, true);
  1765. _comm = comm;
  1766. _prop = prop;
  1767. BgImage[] bgImages;
  1768. auto skin = _comm.skin;
  1769. _cont = new BgImageContainer(createBgImages(skin, bgImagesDefault));
  1770. }
  1771. @property
  1772. BgImageS[] backs() {return createBgImageSs(_cont.backs);}
  1773. protected:
  1774. override void setup(Composite area) { mixin(S_TRACE);
  1775. area.setLayout(new GridLayout(1, false));
  1776. { mixin(S_TRACE);
  1777. _view = createBgImagesViewAndMenu(_comm, _prop, null, _cont, area, null, false);
  1778. mod(_view);
  1779. _view.setLayoutData(new GridData(GridData.FILL_BOTH));
  1780. }
  1781. }
  1782. override bool apply() { mixin(S_TRACE);
  1783. return true;
  1784. }
  1785. }
  1786. class ToolsPane(T) : Composite {
  1787. private:
  1788. class UndoU : Undo {
  1789. private T[] _old;
  1790. private int _selected;
  1791. this () { mixin(S_TRACE);
  1792. save();
  1793. }
  1794. private void save() { mixin(S_TRACE);
  1795. static if (is(typeof(_array[0].dup))) {
  1796. _old = [];
  1797. foreach (a; _array) { mixin(S_TRACE);
  1798. _old ~= a.dup;
  1799. }
  1800. } else { mixin(S_TRACE);
  1801. _old = _array.dup;
  1802. }
  1803. _selected = _list.getSelectionIndex();
  1804. }
  1805. private void impl() { mixin(S_TRACE);
  1806. auto old = _old;
  1807. auto sels = _selected;
  1808. save();
  1809. _list.setRedraw(false);
  1810. scope (exit) _list.setRedraw(true);
  1811. _array = old;
  1812. _list.removeAll();
  1813. foreach (o; old) { mixin(S_TRACE);
  1814. _list.add(createName(o));
  1815. }
  1816. _list.select(sels);
  1817. _list.showSelection();
  1818. selected();
  1819. _applyEnabled();
  1820. }
  1821. override void undo() {impl();}
  1822. override void redo() {impl();}
  1823. override void dispose() { mixin(S_TRACE);
  1824. // Nothing
  1825. }
  1826. }
  1827. void store() { mixin(S_TRACE);
  1828. _undo ~= new UndoU;
  1829. }
  1830. KeyDownFilter _kdFilter;
  1831. Commons _comm;
  1832. Props _prop;
  1833. UndoManager _undo;
  1834. void delegate(bool) _ignoreMod;
  1835. bool delegate() _catchMod;
  1836. void delegate() _applyEnabled;
  1837. List _list;
  1838. T[] _array;
  1839. Text _name;
  1840. bool _canApply = false;
  1841. static if (is(T:BgImageSetting)) {
  1842. Spinner _bgImgX;
  1843. Spinner _bgImgY;
  1844. Spinner _bgImgW;
  1845. Spinner _bgImgH;
  1846. Button _bgImgMask;
  1847. } else static if (is(T:OuterTool)) {
  1848. Text _toolCommand;
  1849. Button _toolCommandRef;
  1850. Button _toolCommandDirOpen;
  1851. Text _toolWorkDir;
  1852. Button _toolWorkDirRef;
  1853. Button _toolWorkDirOpen;
  1854. Text _mnemonic;
  1855. HotKeyField _hotkey;
  1856. } else static if (is(T:ClassicEngine)) {
  1857. Text _cEnginePath;
  1858. Button _cEnginePathRef;
  1859. Button _cEnginePathDirOpen;
  1860. Text _cEngineDataDir;
  1861. Button _cEngineDataDirRef;
  1862. Button _cEngineDataDirOpen;
  1863. Text _cEngineExecute;
  1864. Button _cEngineExecuteRef;
  1865. Button _cEngineExecuteDirOpen;
  1866. Text _mnemonic;
  1867. HotKeyField _hotkey;
  1868. Shell _ceNameWin;
  1869. Button _features;
  1870. Table _featureName;
  1871. UndoManager _featureUndo;
  1872. TableItem _okText;
  1873. TableItem[Sex] _sexName;
  1874. TableItem[Period] _periodName;
  1875. TableItem[Nature] _natureName;
  1876. TableItem[Makings] _makingsName;
  1877. void refAlt() { mixin(S_TRACE);
  1878. if (0 < _list.getItemCount()) { mixin(S_TRACE);
  1879. _alt.setEnabled(true);
  1880. }
  1881. _canApply = true;
  1882. }
  1883. void featuresEnd(TableItem itm, int column, string newText) { mixin(S_TRACE);
  1884. if (itm.getText(column) == newText) return;
  1885. storeFeatures();
  1886. itm.setText(column, newText);
  1887. refAlt();
  1888. }
  1889. class UndoFeature : Undo {
  1890. private string[] _features;
  1891. private int[] _selected;
  1892. this () { mixin(S_TRACE);
  1893. save();
  1894. }
  1895. private void save() { mixin(S_TRACE);
  1896. _features = [];
  1897. foreach (itm; _featureName.getItems()) { mixin(S_TRACE);
  1898. _features ~= itm.getText(2);
  1899. }
  1900. _selected = _featureName.getSelectionIndices();
  1901. }
  1902. private void impl() { mixin(S_TRACE);
  1903. auto features = _features.dup;
  1904. auto selected = _selected.dup;
  1905. save();
  1906. _featureName.setRedraw(false);
  1907. scope (exit) _featureName.setRedraw(true);
  1908. foreach (i, itm; _featureName.getItems()) { mixin(S_TRACE);
  1909. itm.setText(2, features[i]);
  1910. }
  1911. _featureName.deselectAll();
  1912. _featureName.select(selected);
  1913. _featureName.showSelection();
  1914. _comm.refreshToolBar();
  1915. }
  1916. void undo() {impl();}
  1917. void redo() {impl();}
  1918. override void dispose() { mixin(S_TRACE);
  1919. // Nothing
  1920. }
  1921. }
  1922. void storeFeatures() { mixin(S_TRACE);
  1923. _featureUndo ~= new UndoFeature;
  1924. }
  1925. void undoFeatures() { mixin(S_TRACE);
  1926. _featureUndo.undo();
  1927. }
  1928. void redoFeatures() { mixin(S_TRACE);
  1929. _featureUndo.redo();
  1930. }
  1931. class FTCPD : TCPD {
  1932. void cut(SelectionEvent e) { mixin(S_TRACE);
  1933. copy(e);
  1934. del(e);
  1935. }
  1936. private string copyImpl() { mixin(S_TRACE);
  1937. auto indices = _featureName.getSelectionIndices().sort;
  1938. if (!indices.length) return [];
  1939. string text;
  1940. int i = 0;
  1941. foreach (sel; indices[0] .. indices[$ - 1] + 1) { mixin(S_TRACE);
  1942. auto itm = _featureName.getItem(sel);
  1943. text ~= itm.getText(2);
  1944. text ~= newline;
  1945. i++;
  1946. }
  1947. return text;
  1948. }
  1949. void copy(SelectionEvent e) { mixin(S_TRACE);
  1950. auto t = copyImpl();
  1951. if (!t.length) return;
  1952. _comm.clipboard.setContents([new ArrayWrapperString(t)], [TextTransfer.getInstance()]);
  1953. _comm.refreshToolBar();
  1954. }
  1955. void paste(SelectionEvent e) { mixin(S_TRACE);
  1956. auto a = cast(ArrayWrapperString) _comm.clipboard.getContents(TextTransfer.getInstance());
  1957. if (!a) return;
  1958. pasteImpl(a.array);
  1959. }
  1960. void pasteImpl(in char[] array) { mixin(S_TRACE);
  1961. auto indices = _featureName.getSelectionIndices().sort;
  1962. if (!indices.length) return;
  1963. int i = indices[0];
  1964. auto linesu = array.splitLines();
  1965. if (!linesu.length) return;
  1966. storeFeatures();
  1967. auto lines = assumeUnique(linesu);
  1968. int[] sels;
  1969. foreach (line; lines) { mixin(S_TRACE);
  1970. if (_featureName.getItemCount() <= i) break;
  1971. _featureName.getItem(i).setText(2, line);
  1972. sels ~= i;
  1973. i++;
  1974. }
  1975. _featureName.deselectAll();
  1976. _featureName.select(sels);
  1977. _featureName.showSelection();
  1978. refAlt();
  1979. _comm.refreshToolBar();
  1980. }
  1981. void del(SelectionEvent e) { mixin(S_TRACE);
  1982. if(-1 == _featureName.getSelectionIndex()) return;
  1983. storeFeatures();
  1984. foreach (itm; _featureName.getSelection()) { mixin(S_TRACE);
  1985. itm.setText(2, "");
  1986. }
  1987. refAlt();
  1988. _comm.refreshToolBar();
  1989. }
  1990. void clone(SelectionEvent e) { mixin(S_TRACE);
  1991. return;
  1992. }
  1993. @property
  1994. bool canDoTCPD() { mixin(S_TRACE);
  1995. return _featureName.isFocusControl();
  1996. }
  1997. @property
  1998. bool canDoT() { mixin(S_TRACE);
  1999. return -1 != _featureName.getSelectionIndex();
  2000. }
  2001. @property
  2002. bool canDoC() { mixin(S_TRACE);
  2003. return canDoT;
  2004. }
  2005. @property
  2006. bool canDoP() { mixin(S_TRACE);
  2007. return -1 != _featureName.getSelectionIndex() && CBisText(_comm.clipboard);
  2008. }
  2009. @property
  2010. bool canDoD() { mixin(S_TRACE);
  2011. return canDoT;
  2012. }
  2013. @property
  2014. bool canDoClone() { mixin(S_TRACE);
  2015. return false;
  2016. }
  2017. }
  2018. } else static if (is(T:ScTemplate)) {
  2019. Text _templPath;
  2020. Button _templPathRef;
  2021. Button _templPathDirOpen;
  2022. } else static if (is(T:EvTemplate)) {
  2023. Text _templScript;
  2024. Text _mnemonic;
  2025. HotKeyField _hotkey;
  2026. } else static assert (0);
  2027. Button _alt;
  2028. Button _del;
  2029. TextMenuModify[] _tms;
  2030. void upImpl(List list, ref T[] array) { mixin(S_TRACE);
  2031. int i = list.getSelectionIndex();
  2032. if (i <= 0) return;
  2033. string tempS = list.getItem(i - 1);
  2034. list.setItem(i - 1, list.getItem(i));
  2035. list.setItem(i, tempS);
  2036. auto temp = array[i - 1];
  2037. array[i - 1] = array[i];
  2038. array[i] = temp;
  2039. list.select(i - 1);
  2040. _applyEnabled();
  2041. _comm.refreshToolBar();
  2042. }
  2043. void downImpl(T)(List list, ref T[] array) { mixin(S_TRACE);
  2044. int i = list.getSelectionIndex();
  2045. if (i < 0 || array.length <= i + 1) return;
  2046. string tempS = list.getItem(i + 1);
  2047. list.setItem(i + 1, list.getItem(i));
  2048. list.setItem(i, tempS);
  2049. auto temp = array[i + 1];
  2050. array[i + 1] = array[i];
  2051. array[i] = temp;
  2052. list.select(i + 1);
  2053. _applyEnabled();
  2054. _comm.refreshToolBar();
  2055. }
  2056. void up() { mixin(S_TRACE);
  2057. store();
  2058. upImpl(_list, _array);
  2059. }
  2060. void down() { mixin(S_TRACE);
  2061. store();
  2062. downImpl(_list, _array);
  2063. }
  2064. void selected() { mixin(S_TRACE);
  2065. _ignoreMod(true);
  2066. scope (exit) _ignoreMod(false);
  2067. int i = _list.getSelectionIndex();
  2068. _del.setEnabled(i >= 0);
  2069. if (i >= 0) { mixin(S_TRACE);
  2070. _name.setText(_array[i].name);
  2071. static if (is(T:BgImageSetting)) {
  2072. _bgImgX.setSelection(_array[i].x);
  2073. _bgImgY.setSelection(_array[i].y);
  2074. _bgImgW.setSelection(_array[i].width);
  2075. _bgImgH.setSelection(_array[i].height);
  2076. _bgImgMask.setSelection(_array[i].mask);
  2077. } else static if (is(T:OuterTool)) {
  2078. _toolCommand.setText(_array[i].command);
  2079. _toolWorkDir.setText(_array[i].workDir);
  2080. _mnemonic.setText(_array[i].mnemonic);
  2081. _hotkey.accelerator = _array[i].hotkey;
  2082. } else static if (is(T:ClassicEngine)) {
  2083. _cEnginePath.setText(_array[i].enginePath);
  2084. _cEngineDataDir.setText(_array[i].dataDirName);
  2085. _cEngineExecute.setText(_array[i].execute);
  2086. _mnemonic.setText(_array[i].mnemonic);
  2087. _hotkey.accelerator = _array[i].hotkey;
  2088. auto n = _array[i].legacyName;
  2089. _okText.setText(1, _prop.sys.evtChildOK(n));
  2090. _okText.setText(2, _array[i].okText is null ? "" : _array[i].okText);
  2091. foreach (f, itm; _sexName) { mixin(S_TRACE);
  2092. itm.setText(1, _prop.sys.sexName(f, n));
  2093. itm.setText(2, _array[i].sexName.get(_prop.sys.sexName(f, ""), ""));
  2094. }
  2095. foreach (f, itm; _periodName) { mixin(S_TRACE);
  2096. itm.setText(1, _prop.sys.periodName(f, n));
  2097. itm.setText(2, _array[i].periodName.get(_prop.sys.periodName(f, ""), ""));
  2098. }
  2099. foreach (f, itm; _natureName) { mixin(S_TRACE);
  2100. itm.setText(1, _prop.sys.natureName(f, n));
  2101. itm.setText(2, _array[i].natureName.get(_prop.sys.natureName(f, ""), ""));
  2102. }
  2103. foreach (f, itm; _makingsName) { mixin(S_TRACE);
  2104. itm.setText(1, _prop.sys.makingsName(f, n));
  2105. itm.setText(2, _array[i].makingsName.get(_prop.sys.makingsName(f, ""), ""));
  2106. }
  2107. _featureUndo.reset();
  2108. } else static if (is(T:ScTemplate)) {
  2109. _templPath.setText(_array[i].path);
  2110. } else static if (is(T:EvTemplate)) {
  2111. _templScript.setText(_array[i].script);
  2112. _mnemonic.setText(_array[i].mnemonic);
  2113. _hotkey.accelerator = _array[i].hotkey;
  2114. } else static assert (0);
  2115. } else { mixin(S_TRACE);
  2116. _name.setText("");
  2117. static if (is(T:BgImageSetting)) {
  2118. _bgImgX.setSelection(0);
  2119. _bgImgY.setSelection(0);
  2120. _bgImgW.setSelection(0);
  2121. _bgImgH.setSelection(0);
  2122. _bgImgMask.setSelection(false);
  2123. } else static if (is(T:OuterTool)) {
  2124. _toolCommand.setText("");
  2125. _toolWorkDir.setText("");
  2126. _mnemonic.setText("");
  2127. _hotkey.accelerator = "";
  2128. } else static if (is(T:ClassicEngine)) {
  2129. _cEnginePath.setText("");
  2130. _cEngineDataDir.setText("");
  2131. _cEngineExecute.setText("");
  2132. _mnemonic.setText("");
  2133. _hotkey.accelerator = "";
  2134. } else static if (is(T:ScTemplate)) {
  2135. _templPath.setText("");
  2136. } else static if (is(T:EvTemplate)) {
  2137. _templScript.setText("");
  2138. _mnemonic.setText("");
  2139. _hotkey.accelerator = "";
  2140. } else static assert (0);
  2141. }
  2142. _alt.setEnabled(false);
  2143. _canApply = false;
  2144. foreach (tm; _tms) { mixin(S_TRACE);
  2145. tm.reset();
  2146. }
  2147. _comm.refreshToolBar();
  2148. }
  2149. void add(T t) { mixin(S_TRACE);
  2150. store();
  2151. int index = _list.getItemCount();
  2152. _array ~= t;
  2153. _list.add(createName(t));
  2154. _list.select(index);
  2155. selected();
  2156. _applyEnabled();
  2157. _comm.refreshToolBar();
  2158. }
  2159. void create() { mixin(S_TRACE);
  2160. if (!checkData()) return;
  2161. string name = _name.getText();
  2162. static if (is(T:BgImageSetting)) {
  2163. bool mask = _bgImgMask.getSelection();
  2164. int x = _bgImgX.getSelection();
  2165. int y = _bgImgY.getSelection();
  2166. int w = _bgImgW.getSelection();
  2167. int h = _bgImgH.getSelection();
  2168. add(BgImageSetting(name, x, y, w, h, mask));
  2169. } else static if (is(T:OuterTool)) {
  2170. string commnad = _toolCommand.getText();
  2171. string workDir = _toolWorkDir.getText();
  2172. string mnemonic = _mnemonic.getText();
  2173. string hotkey = _hotkey.acceleratorText();
  2174. add(OuterTool(name, commnad, workDir, mnemonic, hotkey));
  2175. } else static if (is(T:ClassicEngine)) {
  2176. string path = _cEnginePath.getText();
  2177. string dataDir = _cEngineDataDir.getText();
  2178. string execute = _cEngineExecute.getText();
  2179. string mnemonic = _mnemonic.getText();
  2180. string hotkey = _hotkey.acceleratorText();
  2181. add(ClassicEngine(name, path, dataDir, execute, mnemonic, hotkey));
  2182. } else static if (is(T:ScTemplate)) {
  2183. string path = _templPath.getText();
  2184. add(ScTemplate(name, path));
  2185. } else static if (is(T:EvTemplate)) {
  2186. string script = _templScript.getText();
  2187. string mnemonic = _mnemonic.getText();
  2188. string hotkey = _hotkey.acceleratorText();
  2189. add(EvTemplate(name, script, mnemonic, hotkey));
  2190. } else static assert (0);
  2191. }
  2192. void alt() { mixin(S_TRACE);
  2193. int i = _list.getSelectionIndex();
  2194. if (-1 == i) return;
  2195. if (!checkData()) return;
  2196. store();
  2197. _array[i].name = _name.getText();
  2198. static if (is(T:BgImageSetting)) {
  2199. _array[i].mask = _bgImgMask.getSelection();
  2200. _array[i].x = _bgImgX.getSelection();
  2201. _array[i].y = _bgImgY.getSelection();
  2202. _array[i].width = _bgImgW.getSelection();
  2203. _array[i].height = _bgImgH.getSelection();
  2204. } else static if (is(T:OuterTool)) {
  2205. _array[i].command = _toolCommand.getText();
  2206. _array[i].workDir = _toolWorkDir.getText();
  2207. _array[i].mnemonic = _mnemonic.getText();
  2208. _array[i].hotkey = _hotkey.acceleratorText();
  2209. } else static if (is(T:ClassicEngine)) {
  2210. _array[i].enginePath = _cEnginePath.getText();
  2211. _array[i].dataDirName = _cEngineDataDir.getText();
  2212. _array[i].execute = _cEngineExecute.getText();
  2213. _array[i].mnemonic = _mnemonic.getText();
  2214. _array[i].hotkey = _hotkey.acceleratorText();
  2215. _array[i].clearFeatures();
  2216. if (_okText.getText(2).length) _array[i].okText = _okText.getText(2);
  2217. foreach (f; SEX_ALL) { mixin(S_TRACE);
  2218. auto t = _sexName[f].getText(2);
  2219. if (t.length) _array[i].sexName[_prop.sys.sexName(f, "")] = t;
  2220. }
  2221. foreach (f; PERIOD_ALL) { mixin(S_TRACE);
  2222. auto t = _periodName[f].getText(2);
  2223. if (t.length) _array[i].periodName[_prop.sys.periodName(f, "")] = t;
  2224. }
  2225. foreach (f; NATURE_DEF ~ NATURE_EXT) { mixin(S_TRACE);
  2226. auto t = _natureName[f].getText(2);
  2227. if (t.length) _array[i].natureName[_prop.sys.natureName(f, "")] = t;
  2228. }
  2229. foreach (Makings f; MAKINGS_LEFT) { mixin(S_TRACE);
  2230. auto t = _makingsName[f].getText(2);
  2231. if (t.length) _array[i].makingsName[_prop.sys.makingsName(f, "")] = t;
  2232. f = reverseMakings(f);
  2233. t = _makingsName[f].getText(2);
  2234. if (t.length) _array[i].makingsName[_prop.sys.makingsName(f, "")] = t;
  2235. }
  2236. } else static if (is(T:ScTemplate)) {
  2237. _array[i].path = _templPath.getText();
  2238. } else static if (is(T:EvTemplate)) {
  2239. _array[i].script = .wrapReturnCode(_templScript.getText());
  2240. _array[i].mnemonic = _mnemonic.getText();
  2241. _array[i].hotkey = _hotkey.acceleratorText();
  2242. } else static assert (0);
  2243. _list.setItem(i, createName(_array[i]));
  2244. _alt.setEnabled(false);
  2245. _canApply = false;
  2246. _applyEnabled();
  2247. _comm.refreshToolBar();
  2248. }
  2249. void del() { mixin(S_TRACE);
  2250. int i = _list.getSelectionIndex();
  2251. if (i < 0) return;
  2252. store();
  2253. _list.remove(i);
  2254. _array = _array[0 .. i] ~ _array[i + 1 .. $];
  2255. if (_array.length > 0) { mixin(S_TRACE);
  2256. _list.select(i < _array.length ? i : _array.length - 1);
  2257. }
  2258. selected();
  2259. _applyEnabled();
  2260. _comm.refreshToolBar();
  2261. }
  2262. class UTCPD : TCPD {
  2263. void cut(SelectionEvent se) { mixin(S_TRACE);
  2264. int i = _list.getSelectionIndex();
  2265. if (i < 0) return;
  2266. copy(se);
  2267. del(se);
  2268. }
  2269. void copy(SelectionEvent se) { mixin(S_TRACE);
  2270. int i = _list.getSelectionIndex();
  2271. if (i < 0) return;
  2272. XMLtoCB(_prop, _comm.clipboard, _array[i].toNode().text);
  2273. _comm.refreshToolBar();
  2274. }
  2275. void paste(SelectionEvent se) { mixin(S_TRACE);
  2276. auto xml = CBtoXML(_comm.clipboard);
  2277. if (xml) { mixin(S_TRACE);
  2278. try { mixin(S_TRACE);
  2279. auto node = XNode.parse(xml);
  2280. if (node.name == T.XML_NAME) { mixin(S_TRACE);
  2281. T t;
  2282. t.fromNode(node);
  2283. add(t);
  2284. }
  2285. } catch (Exception e) {
  2286. debugln(e);
  2287. }
  2288. }
  2289. }
  2290. void del(SelectionEvent se) { mixin(S_TRACE);
  2291. this.outer.del();
  2292. }
  2293. void clone(SelectionEvent se) { mixin(S_TRACE);
  2294. _comm.clipboard.memoryMode = true;
  2295. scope (exit) _comm.clipboard.memoryMode = false;
  2296. copy(se);
  2297. paste(se);
  2298. }
  2299. @property
  2300. bool canDoTCPD() { mixin(S_TRACE);
  2301. return _list.isFocusControl();
  2302. }
  2303. @property
  2304. bool canDoT() { mixin(S_TRACE);
  2305. return _list.getSelectionIndex() >= 0;
  2306. }
  2307. @property
  2308. bool canDoC() { mixin(S_TRACE);
  2309. return canDoT;
  2310. }
  2311. @property
  2312. bool canDoP() { mixin(S_TRACE);
  2313. return CBisXML(_comm.clipboard);
  2314. }
  2315. @property
  2316. bool canDoD() { mixin(S_TRACE);
  2317. return canDoT;
  2318. }
  2319. @property
  2320. bool canDoClone() { mixin(S_TRACE);
  2321. return canDoC;
  2322. }
  2323. }
  2324. /// ???false????????????????????????
  2325. bool checkData() {return true;}
  2326. void refUndoMax() { mixin(S_TRACE);
  2327. _undo.max = _prop.var.etc.undoMaxEtc;
  2328. }
  2329. Spinner createS(Composite parent, string name, int max, int min) { mixin(S_TRACE);
  2330. auto l = new Label(parent, SWT.NONE);
  2331. l.setText(name);
  2332. auto spn = new Spinner(parent, SWT.BORDER);
  2333. initSpinner(spn);
  2334. spn.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  2335. spn.setMaximum(max);
  2336. spn.setMinimum(min);
  2337. spn.setSelection(0);
  2338. return spn;
  2339. }
  2340. void modB(C)(Button button, List list, C ctrl, ref bool flag) { mixin(S_TRACE);
  2341. static if (is(C : Button)) {
  2342. ctrl.addSelectionListener(new class SelectionAdapter {
  2343. override void widgetSelected(SelectionEvent e) { mixin(S_TRACE);
  2344. if (0 < list.getItemCount()) { mixin(S_TRACE);
  2345. button.setEnabled(true);
  2346. }
  2347. flag = true;
  2348. }
  2349. });
  2350. } else { mixin(S_TRACE);
  2351. ctrl.addModifyListener(new class ModifyListener {
  2352. override void modifyText(ModifyEvent e) { mixin(S_TRACE);
  2353. if (0 < list.getItemCount()) { mixin(S_TRACE);
  2354. button.setEnabled(true);
  2355. }
  2356. flag = true;
  2357. }
  2358. });
  2359. }
  2360. }
  2361. class KeyDownFilter : Listener {
  2362. this () { mixin(S_TRACE);
  2363. refMenu(MenuID.Undo);
  2364. refMenu(MenuID.Redo);
  2365. }
  2366. override void handleEvent(Event e) { mixin(S_TRACE);
  2367. auto c = cast(Control) e.widget;
  2368. if (!c || c.getShell() !is getShell()) return;
  2369. if (isDescendant(this.outer, c)) { mixin(S_TRACE);
  2370. if (c.getMenu() && findMenu(c.getMenu(), e.keyCode, e.character, e.stateMask)) return;
  2371. if (eqAcc(_undoAcc, e.keyCode, e.character, e.stateMask)) { mixin(S_TRACE);
  2372. _undo.undo();
  2373. e.doit = false;
  2374. } else if (eqAcc(_redoAcc, e.keyCode, e.character, e.stateMask)) { mixin(S_TRACE);
  2375. _undo.redo();
  2376. e.doit = false;
  2377. }
  2378. }
  2379. }
  2380. }
  2381. private int _undoAcc;
  2382. private int _redoAcc;
  2383. void refMenu(MenuID id) { mixin(S_TRACE);
  2384. if (id == MenuID.Undo) _undoAcc = convertAccelerator(_prop.buildMenu(MenuID.Undo));
  2385. if (id == MenuID.Redo) _redoAcc = convertAccelerator(_prop.buildMenu(MenuID.Redo));
  2386. }
  2387. static if (is(T:OuterTool) || is(T:ClassicEngine) || is(T:EvTemplate)) {
  2388. SplitPane _shortcutSash;
  2389. string createName(ref const T t) { mixin(S_TRACE);
  2390. return MenuProps.buildMenuSample(t.name, t.mnemonic, t.hotkey, false);
  2391. }
  2392. void setupShortcut(Composite parent) { mixin(S_TRACE);
  2393. auto l1 = new Label(parent, SWT.NONE);
  2394. l1.setText(_prop.msgs.mnemonic);
  2395. _shortcutSash = new SplitPane(parent, SWT.HORIZONTAL);
  2396. auto gd = new GridData(GridData.FILL_HORIZONTAL);
  2397. gd.horizontalSpan = 3;
  2398. _shortcutSash.setLayoutData(gd);
  2399. _mnemonic = mnemonicText(_shortcutSash, SWT.BORDER);
  2400. createTextMenu!Text(_comm, _prop, _mnemonic, _catchMod);
  2401. auto hotkeyComp = new Composite(_shortcutSash, SWT.NONE);
  2402. hotkeyComp.setLayout(zeroMarginGridLayout(2, false));
  2403. auto l2 = new Label(hotkeyComp, SWT.NONE);
  2404. l2.setText(_prop.msgs.hotkey);
  2405. _hotkey = new HotKeyField(hotkeyComp, SWT.BORDER);
  2406. createTextMenu!Text(_comm, _prop, _hotkey.widget, _catchMod);
  2407. _hotkey.widget.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  2408. }
  2409. } else {
  2410. string createName(ref const T t) { mixin(S_TRACE);
  2411. return t.name;
  2412. }
  2413. }
  2414. static if (is(T:BgImageSetting)) {
  2415. void setupRight(Composite parent) { mixin(S_TRACE);
  2416. auto comp3 = new Composite(parent, SWT.NONE);
  2417. auto gd = new GridData(GridData.FILL_HORIZONTAL);
  2418. gd.horizontalSpan = 4;
  2419. comp3.setLayoutData(gd);
  2420. comp3.setLayout(zeroMarginGridLayout(2, false));
  2421. _name = new Text(comp3, SWT.BORDER);
  2422. _tms ~= createTextMenu!Text(_comm, _prop, _name, _catchMod);
  2423. _name.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  2424. _bgImgMask = new Button(comp3, SWT.TOGGLE);
  2425. _bgImgMask.setImage(_prop.images.menu(MenuID.Mask));
  2426. _bgImgMask.setToolTipText(_prop.buildTool(MenuID.Mask));
  2427. _bgImgX = createS(parent, _prop.msgs.left, _prop.var.etc.posLeftMax, -(cast(int) _prop.var.etc.posLeftMax));
  2428. _bgImgY = createS(parent, _prop.msgs.top, _prop.var.etc.posTopMax, -(cast(int) _prop.var.etc.posTopMax));
  2429. _bgImgW = createS(parent, _prop.msgs.width, _prop.var.etc.backWidthMax, 0);
  2430. _bgImgH = createS(parent, _prop.msgs.height, _prop.var.etc.backHeightMax, 0);
  2431. }
  2432. } else static if (is(T:OuterTool)) {
  2433. void selectProgram() { mixin(S_TRACE);
  2434. string[] desc;
  2435. string[] ext;
  2436. version (Windows) {
  2437. desc = [_prop.msgs.exeFileDescExe, _prop.msgs.exeFileDescAll];
  2438. ext = ["*.exe", "*.*"];
  2439. } else { mixin(S_TRACE);
  2440. desc = [_prop.msgs.exeFileDescAll];
  2441. ext = ["*.*"];
  2442. }
  2443. selectFile(_toolCommand, desc, ext, "", _prop.msgs.dlgTitOuterTool, _toolCommand.getText());
  2444. }
  2445. void selectWorkDir() { mixin(S_TRACE);
  2446. selectDir(_prop, _toolWorkDir, _prop.msgs.toolWorkDir, _prop.msgs.toolWorkDirDesc, _toolWorkDir.getText());
  2447. }
  2448. void setupRight(Composite parent) { mixin(S_TRACE);
  2449. { mixin(S_TRACE);
  2450. auto l = new Label(parent, SWT.NONE);
  2451. l.setText(_prop.msgs.outerToolName);
  2452. _name = new Text(parent, SWT.BORDER);
  2453. _tms ~= createTextMenu!Text(_comm, _prop, _name, _catchMod);
  2454. auto gd = new GridData(GridData.FILL_HORIZONTAL);
  2455. gd.horizontalSpan = 3;
  2456. _name.setLayoutData(gd);
  2457. }
  2458. setupShortcut(parent);
  2459. { mixin(S_TRACE);
  2460. auto l = new Label(parent, SWT.NONE);
  2461. l.setText(_prop.msgs.outerToolCommand);
  2462. _toolCommand = new Text(parent, SWT.BORDER);
  2463. _tms ~= createTextMenu!Text(_comm, _prop, _toolCommand, _catchMod);
  2464. auto gd = new GridData(GridData.FILL_HORIZONTAL);
  2465. gd.widthHint = 0;
  2466. _toolCommand.setLayoutData(gd);
  2467. _toolCommandRef = new Button(parent, SWT.PUSH);
  2468. _toolCommandRef.setText(_prop.msgs.reference);
  2469. listener(_toolCommandRef, SWT.Selection, &selectProgram);
  2470. _toolCommandDirOpen = createOpenButton(_comm, parent, &_toolCommand.getText, false);
  2471. setupDropFile(_toolCommand, _toolCommand, toDelegate(&dropDefault));
  2472. }
  2473. { mixin(S_TRACE);
  2474. auto l = new Label(parent, SWT.NONE);
  2475. l.setText(_prop.msgs.outerToolWorkDir);
  2476. _toolWorkDir = new Text(parent, SWT.BORDER);
  2477. _tms ~= createTextMenu!Text(_comm, _prop, _toolWorkDir, _catchMod);
  2478. auto gd = new GridData(GridData.FILL_HORIZONTAL);
  2479. gd.widthHint = 0;
  2480. _toolWorkDir.setLayoutData(gd);
  2481. _toolWorkDirRef = new Button(parent, SWT.PUSH);
  2482. _toolWorkDirRef.setText(_prop.msgs.reference);
  2483. listener(_toolWorkDirRef, SWT.Selection, &selectWorkDir);
  2484. _toolWorkDirOpen = createOpenButton(_comm, parent, &_toolWorkDir.getText, true);
  2485. setupDropFile(_toolWorkDir, _toolWorkDir, toDelegate(&dropDir));
  2486. }
  2487. { mixin(S_TRACE);
  2488. auto dummy = new Composite(parent, SWT.NONE);
  2489. auto gd = new GridData;
  2490. gd.verticalSpan = 3;
  2491. gd.widthHint = 0;
  2492. gd.heightHint = 0;
  2493. dummy.setLayoutData(gd);
  2494. auto hint1 = new Label(parent, SWT.NONE);
  2495. hint1.setText(_prop.msgs.toolsHint1);
  2496. auto gd1 = new GridData;
  2497. gd1.horizontalSpan = 3;
  2498. hint1.setLayoutData(gd1);
  2499. auto hint2 = new Label(parent, SWT.NONE);
  2500. hint2.setText(_prop.msgs.toolsHint2);
  2501. auto gd2 = new GridData;
  2502. gd2.horizontalSpan = 3;
  2503. hint2.setLayoutData(gd2);
  2504. auto hint3 = new Label(parent, SWT.NONE);
  2505. hint3.setText(_prop.msgs.toolsHint3);
  2506. auto gd3 = new GridData;
  2507. gd3.horizontalSpan = 3;
  2508. hint3.setLayoutData(gd3);
  2509. }
  2510. }
  2511. } else static if (is(T:ClassicEngine)) {
  2512. string dropCEnginePath(string[] files) { mixin(S_TRACE);
  2513. if (!files.length) return "";
  2514. string file = files[0];
  2515. if (.exists(file) && .isDir(file)) { mixin(S_TRACE);
  2516. string resDir, lEnginePath;
  2517. if (Skin.hasClassicEngine(file, resDir, lEnginePath, _prop.var.etc.classicEngineRegex, _prop.var.etc.classicDataDirRegex, _prop.var.etc.classicMatchKey, _array)) { mixin(S_TRACE);
  2518. return lEnginePath;
  2519. }
  2520. return file;
  2521. }
  2522. return file;
  2523. }
  2524. @property
  2525. string curCEnginePath() { mixin(S_TRACE);
  2526. string path = _cEnginePath.getText();
  2527. if (!path.length) return path;
  2528. if (isAbsolute(path)) return path;
  2529. return std.path.buildPath(nabs(_prop.parent.appPath).dirName(), path);
  2530. }
  2531. string dropCEngineSub(string file) { mixin(S_TRACE);
  2532. string engine = curCEnginePath;
  2533. if (!engine.length) return file;
  2534. return abs2rel(file, engine.dirName());
  2535. }
  2536. string dropCEngineDataDir(string[] files) { mixin(S_TRACE);
  2537. return dropCEngineSub(dropDir(files));
  2538. }
  2539. string dropCEngineExecute(string[] files) { mixin(S_TRACE);
  2540. return dropCEngineSub(dropDefault(files));
  2541. }
  2542. void selectCEnginePath() { mixin(S_TRACE);
  2543. string[] desc;
  2544. string[] ext;
  2545. version (Windows) {
  2546. desc = [_prop.msgs.exeFileDescExe, _prop.msgs.exeFileDescAll];
  2547. ext = ["*.exe", "*.*"];
  2548. } else { mixin(S_TRACE);
  2549. desc = [_prop.msgs.exeFileDescAll];
  2550. ext = ["*.*"];
  2551. }
  2552. string fname = selectFile(_cEnginePath, desc, ext, "", _prop.msgs.dlgTitClassicEnginePath, _cEnginePath.getText());
  2553. if (fname) { mixin(S_TRACE);
  2554. dropCEnginePath(fname);
  2555. }
  2556. }
  2557. void dropCEnginePath(string path) { mixin(S_TRACE);
  2558. string resDir = Skin.findResDir(path.dirName(), _prop.var.etc.classicDataDirRegex, _prop.var.etc.classicMatchKey);
  2559. if (resDir.length) { mixin(S_TRACE);
  2560. _cEngineDataDir.setText(resDir);
  2561. }
  2562. }
  2563. void selectCEngineDataDir() { mixin(S_TRACE);
  2564. string path = _cEngineDataDir.getText();
  2565. if (_cEnginePath.getText().length && !isAbsolute(path)) { mixin(S_TRACE);
  2566. path = std.path.buildPath(_cEnginePath.getText().dirName(), path);
  2567. }
  2568. path = nabs(path);
  2569. string fname = selectDir(_prop, _cEngineDataDir, _prop.msgs.classicEngineDataDirName, _prop.msgs.classicEngineDataDirNameDesc, path, false);
  2570. if (fname) { mixin(S_TRACE);
  2571. fname = dropCEngineSub(fname);
  2572. _cEngineDataDir.setText(fname);
  2573. }
  2574. }
  2575. void selectCEngineExecute() { mixin(S_TRACE);
  2576. string[] desc;
  2577. string[] ext;
  2578. version (Windows) {
  2579. desc = [_prop.msgs.exeFileDescExe, _prop.msgs.exeFileDescAll];
  2580. ext = ["*.exe", "*.*"];
  2581. } else { mixin(S_TRACE);
  2582. desc = [_prop.msgs.exeFileDescAll];
  2583. ext = ["*.*"];
  2584. }
  2585. string path = _cEngineExecute.getText();
  2586. string fileName = "";
  2587. if (path.length) { mixin(S_TRACE);
  2588. fileName = path.baseName();
  2589. if (_cEnginePath.getText().length && !isAbsolute(path)) { mixin(S_TRACE);
  2590. path = std.path.buildPath(_cEnginePath.getText().dirName(), path);
  2591. }
  2592. } else { mixin(S_TRACE);
  2593. path = std.path.buildPath(_cEnginePath.getText().dirName(), "*.exe");
  2594. }
  2595. path = nabs(path);
  2596. string fname = selectFile(_cEngineExecute, desc, ext, fileName, _prop.msgs.dlgTitClassicEngineExecute, path);
  2597. if (fname) { mixin(S_TRACE);
  2598. fname = dropCEngineSub(fname);
  2599. _cEngineExecute.setText(fname);
  2600. }
  2601. }
  2602. private class CEOpenDir : SelectionAdapter {
  2603. private Text _text;
  2604. this (Text text) { mixin(S_TRACE);
  2605. _text = text;
  2606. }
  2607. override void widgetSelected(SelectionEvent e) { mixin(S_TRACE);
  2608. string file = _text.getText();
  2609. if (!isAbsolute(file)) { mixin(S_TRACE);
  2610. auto engine = curCEnginePath;
  2611. if (engine.length) { mixin(S_TRACE);
  2612. file = std.path.buildPath(engine.dirName(), file);
  2613. }
  2614. }
  2615. if (!.exists(file) || !isDir(file)) { mixin(S_TRACE);
  2616. file = file.dirName();
  2617. }
  2618. if (!.exists(file)) return;
  2619. openFolder(file);
  2620. }
  2621. }
  2622. Button createCEngineSubOpenButton(Composite parent, Text path, bool dir) { mixin(S_TRACE);
  2623. auto open = new Button(parent, SWT.PUSH);
  2624. open.setToolTipText(_prop.buildTool(dir ? MenuID.OpenDir : MenuID.OpenPlace));
  2625. open.setImage(_prop.images.menu(MenuID.OpenDir));
  2626. open.addSelectionListener(new CEOpenDir(path));
  2627. return open;
  2628. }
  2629. void setupRight(Composite parent) { mixin(S_TRACE);
  2630. { mixin(S_TRACE);
  2631. auto l = new Label(parent, SWT.NONE);
  2632. l.setText(_prop.msgs.classicEngineName);
  2633. _name = new Text(parent, SWT.BORDER);
  2634. _tms ~= createTextMenu!Text(_comm, _prop, _name, _catchMod);
  2635. auto gd = new GridData(GridData.FILL_HORIZONTAL);
  2636. gd.horizontalSpan = 3;
  2637. _name.setLayoutData(gd);
  2638. }
  2639. setupShortcut(parent);
  2640. { mixin(S_TRACE);
  2641. auto l = new Label(parent, SWT.NONE);
  2642. l.setText(_prop.msgs.classicEnginePath);
  2643. _cEnginePath = new Text(parent, SWT.BORDER);
  2644. _tms ~= createTextMenu!Text(_comm, _prop, _cEnginePath, _catchMod);
  2645. auto gd = new GridData(GridData.FILL_HORIZONTAL);
  2646. gd.widthHint = 0;
  2647. _cEnginePath.setLayoutData(gd);
  2648. _cEnginePathRef = new Button(parent, SWT.PUSH);
  2649. _cEnginePathRef.setText(_prop.msgs.reference);
  2650. listener(_cEnginePathRef, SWT.Selection, &selectCEnginePath);
  2651. _cEnginePathDirOpen = createOpenButton(_comm, parent, &_cEnginePath.getText, false);
  2652. setupDropFile(_cEnginePath, _cEnginePath, &dropCEnginePath, &dropCEnginePath);
  2653. }
  2654. { mixin(S_TRACE);
  2655. auto l = new Label(parent, SWT.NONE);
  2656. l.setText(_prop.msgs.classicEngineDataDirName);
  2657. _cEngineDataDir = new Text(parent, SWT.BORDER);
  2658. _tms ~= createTextMenu!Text(_comm, _prop, _cEngineDataDir, _catchMod);
  2659. _cEngineDataDir.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  2660. _cEngineDataDirRef = new Button(parent, SWT.PUSH);
  2661. _cEngineDataDirRef.setText(_prop.msgs.reference);
  2662. listener(_cEngineDataDirRef, SWT.Selection, &selectCEngineDataDir);
  2663. _cEngineDataDirOpen = createCEngineSubOpenButton(parent, _cEngineDataDir, true);
  2664. setupDropFile(_cEngineDataDir, _cEngineDataDir, &dropCEngineDataDir);
  2665. }
  2666. { mixin(S_TRACE);
  2667. auto l = new Label(parent, SWT.NONE);
  2668. l.setText(_prop.msgs.classicEngineExecute);
  2669. _cEngineExecute = new Text(parent, SWT.BORDER);
  2670. _tms ~= createTextMenu!Text(_comm, _prop, _cEngineExecute, _catchMod);
  2671. _cEngineExecute.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  2672. _cEngineExecuteRef = new Button(parent, SWT.PUSH);
  2673. _cEngineExecuteRef.setText(_prop.msgs.reference);
  2674. listener(_cEngineExecuteRef, SWT.Selection, &selectCEngineExecute);
  2675. _cEngineExecuteDirOpen = createCEngineSubOpenButton(parent, _cEngineExecute, true);
  2676. setupDropFile(_cEngineExecute, _cEngineExecute, &dropCEngineExecute);
  2677. }
  2678. { mixin(S_TRACE);
  2679. auto hint1 = new Label(parent, SWT.NONE);
  2680. hint1.setText(_prop.msgs.classicEngineHint1);
  2681. auto gd1 = new GridData;
  2682. gd1.horizontalSpan = 4;
  2683. hint1.setLayoutData(gd1);
  2684. }
  2685. }
  2686. } else static if (is(T:ScTemplate)) {
  2687. string dropTemplate(string[] files) { mixin(S_TRACE);
  2688. if (!files.length) return "";
  2689. string file = files[0];
  2690. if (.isDir(file)) return file;
  2691. auto bn = file.baseName();
  2692. if (cfnmatch(bn, "Summary.wsm") || cfnmatch(bn, "Summary.xml")) { mixin(S_TRACE);
  2693. return file;
  2694. }
  2695. auto ext = .extension(bn);
  2696. if (cfnmatch(ext, ".zip") || cfnmatch(ext, ".wsn") || (cfnmatch(ext, ".cab") && canUncab)) { mixin(S_TRACE);
  2697. return file;
  2698. }
  2699. return "";
  2700. }
  2701. void selectTemplate() { mixin(S_TRACE);
  2702. string[] desc = scenarioFilterDesc(_prop);
  2703. string[] ext = scenarioFilter;
  2704. selectFile(_templPath, desc, ext, "", _prop.msgs.dlgTitScTemplate, _templPath.getText());
  2705. }
  2706. void setupRight(Composite parent) { mixin(S_TRACE);
  2707. { mixin(S_TRACE);
  2708. auto l = new Label(parent, SWT.NONE);
  2709. l.setText(_prop.msgs.scenarioTemplateName);
  2710. _name = new Text(parent, SWT.BORDER);
  2711. _tms ~= createTextMenu!Text(_comm, _prop, _name, _catchMod);
  2712. auto gd = new GridData(GridData.FILL_HORIZONTAL);
  2713. gd.horizontalSpan = 3;
  2714. _name.setLayoutData(gd);
  2715. }
  2716. { mixin(S_TRACE);
  2717. auto l = new Label(parent, SWT.NONE);
  2718. l.setText(_prop.msgs.scenarioTemplatePath);
  2719. _templPath = new Text(parent, SWT.BORDER);
  2720. _tms ~= createTextMenu!Text(_comm, _prop, _templPath, _catchMod);
  2721. auto gd = new GridData(GridData.FILL_HORIZONTAL);
  2722. gd.widthHint = 0;
  2723. _templPath.setLayoutData(gd);
  2724. _templPathRef = new Button(parent, SWT.PUSH);
  2725. _templPathRef.setText(_prop.msgs.reference);
  2726. listener(_templPathRef, SWT.Selection, &selectTemplate);
  2727. _templPathDirOpen = createOpenButton(_comm, parent, &_templPath.getText, false);
  2728. setupDropFile(_templPath, _templPath, &dropTemplate);
  2729. }
  2730. }
  2731. } else static if (is(T:EvTemplate)) {
  2732. void setupRight(Composite parent) { mixin(S_TRACE);
  2733. parent.setLayoutData(new GridData(GridData.FILL_BOTH));
  2734. { mixin(S_TRACE);
  2735. auto l = new Label(parent, SWT.NONE);
  2736. l.setText(_prop.msgs.eventTemplateName);
  2737. _name = new Text(parent, SWT.BORDER);
  2738. _tms ~= createTextMenu!Text(_comm, _prop, _name, _catchMod);
  2739. auto gd = new GridData(GridData.FILL_HORIZONTAL);
  2740. gd.horizontalSpan = 3;
  2741. _name.setLayoutData(gd);
  2742. }
  2743. setupShortcut(parent);
  2744. { mixin(S_TRACE);
  2745. auto l = new Label(parent, SWT.NONE);
  2746. l.setText(_prop.msgs.eventTemplateScript);
  2747. _templScript = new Text(parent, SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.H_SCROLL | SWT.V_SCROLL);
  2748. _tms ~= createTextMenu!Text(_comm, _prop, _templScript, _catchMod);
  2749. auto gd = new GridData(GridData.FILL_BOTH);
  2750. gd.widthHint = 0;
  2751. gd.horizontalSpan = 3;
  2752. _templScript.setLayoutData(gd);
  2753. auto font = _templScript.getFont();
  2754. auto fSize = font ? cast(uint) font.getFontData()[0].height : 0;
  2755. auto font2 = new Font(Display.getCurrent(), dwtData(CFont(_prop.looks.monospace, fSize, false, false)));
  2756. _templScript.setFont(font2);
  2757. listener(_templScript, SWT.Dispose, { mixin(S_TRACE);
  2758. font2.dispose();
  2759. });
  2760. }
  2761. { mixin(S_TRACE);
  2762. void putDummy() { mixin(S_TRACE);
  2763. auto dummy1 = new Composite(parent, SWT.NONE);
  2764. auto dgd1 = new GridData;
  2765. dgd1.widthHint = 0;
  2766. dgd1.heightHint = 0;
  2767. dummy1.setLayoutData(dgd1);
  2768. }
  2769. putDummy();
  2770. auto hint1 = new Label(parent, SWT.WRAP);
  2771. hint1.setText(_prop.msgs.eventTemplateHint1);
  2772. auto gd1 = new GridData(GridData.FILL_HORIZONTAL);
  2773. gd1.widthHint = 0;
  2774. gd1.horizontalSpan = 3;
  2775. hint1.setLayoutData(gd1);
  2776. putDummy();
  2777. auto hint2 = new Text(parent, SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.READ_ONLY);
  2778. hint2.setText(_prop.msgs.eventTemplateHint2);
  2779. createTextMenu!Text(_comm, _prop, hint2, _catchMod);
  2780. auto gd2 = new GridData(GridData.FILL_HORIZONTAL);
  2781. gd2.widthHint = 0;
  2782. gd2.horizontalSpan = 3;
  2783. hint2.setLayoutData(gd2);
  2784. }
  2785. }
  2786. } else static assert (0);
  2787. public:
  2788. this (Commons comm, void delegate(bool) ignoreMod, bool delegate() catchMod, void delegate() applyEnabled, Composite parent, int style) { mixin(S_TRACE);
  2789. super (parent, style);
  2790. _comm = comm;
  2791. _prop = comm.prop;
  2792. _ignoreMod = ignoreMod;
  2793. _applyEnabled = applyEnabled;
  2794. _catchMod = catchMod;
  2795. _undo = new UndoManager(_prop.var.etc.undoMaxEtc);
  2796. }
  2797. void setup(T[] array, ref int sashL, ref int sashR) { mixin(S_TRACE);
  2798. this.setLayout(zeroMarginGridLayout(1, true));
  2799. auto grp = new Group(this, SWT.NONE);
  2800. grp.setLayoutData(new GridData(GridData.FILL_BOTH));
  2801. grp.setLayout(new GridLayout(1, true));
  2802. grp.setText(boxName);
  2803. auto leftSash = new SplitPane(grp, SWT.HORIZONTAL);
  2804. leftSash.setLayoutData(new GridData(GridData.FILL_BOTH));
  2805. { mixin(S_TRACE);
  2806. auto left = new Composite(leftSash, SWT.NONE);
  2807. left.setLayout(zeroMarginGridLayout(2, true));
  2808. _list = new List(left, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL);
  2809. auto gd = new GridData(GridData.FILL_BOTH);
  2810. gd.widthHint = _prop.var.etc.settingListWidth;
  2811. gd.heightHint = _prop.var.etc.settingListHeight;
  2812. gd.horizontalSpan = 2;
  2813. _list.setLayoutData(gd);
  2814. listener(_list, SWT.Selection, &selected);
  2815. auto menu = new Menu(_list);
  2816. createMenuItem(_comm, menu, MenuID.Undo, {_undo.undo();}, &_undo.canUndo);
  2817. createMenuItem(_comm, menu, MenuID.Redo, {_undo.redo();}, &_undo.canRedo);
  2818. new MenuItem(menu, SWT.SEPARATOR);
  2819. bool canUp() { mixin(S_TRACE);
  2820. return _list.getSelectionIndex() != -1 && 0 < _list.getSelectionIndex();
  2821. }
  2822. bool canDown() { mixin(S_TRACE);
  2823. return _list.getSelectionIndex() != -1 && _list.getSelectionIndex() + 1 < _list.getItemCount();
  2824. }
  2825. createMenuItem(_comm, menu, MenuID.Up, &up, &canUp);
  2826. createMenuItem(_comm, menu, MenuID.Down, &down, &canDown);
  2827. new MenuItem(menu, SWT.SEPARATOR);
  2828. appendMenuTCPD(_comm, menu, new UTCPD, true, true, true, true, true);
  2829. _list.setMenu(menu);
  2830. auto up = new Button(left, SWT.PUSH);
  2831. up.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  2832. up.setText(_prop.buildTool(MenuID.Up));
  2833. up.setImage(_prop.images.menu(MenuID.Up));
  2834. listener(up, SWT.Selection, &this.up);
  2835. _comm.put(up, &canUp);
  2836. auto down = new Button(left, SWT.PUSH);
  2837. down.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  2838. down.setText(_prop.buildTool(MenuID.Down));
  2839. down.setImage(_prop.images.menu(MenuID.Down));
  2840. listener(down, SWT.Selection, &this.down);
  2841. _comm.put(down, &canDown);
  2842. }
  2843. auto right = new Composite(leftSash, SWT.NONE);
  2844. right.setLayout(zeroMarginGridLayout(2, false));
  2845. { mixin(S_TRACE);
  2846. auto comp2 = new Composite(right, SWT.NONE);
  2847. auto gd = new GridData(GridData.FILL_HORIZONTAL);
  2848. gd.horizontalSpan = 2;
  2849. comp2.setLayoutData(gd);
  2850. comp2.setLayout(zeroMarginGridLayout(4, false));
  2851. setupRight(comp2);
  2852. }
  2853. static if (is(T:ClassicEngine)) {
  2854. _features = new Button(right, SWT.TOGGLE);
  2855. _features.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
  2856. _features.setText(_prop.msgs.featureName);
  2857. }
  2858. { mixin(S_TRACE);
  2859. auto buttons = new Composite(right, SWT.NONE);
  2860. auto gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
  2861. static if (!is(T:ClassicEngine)) {
  2862. gd.horizontalSpan = 2;
  2863. }
  2864. buttons.setLayoutData(gd);
  2865. buttons.setLayout(zeroMarginGridLayout(3, true));
  2866. auto create = new Button(buttons, SWT.PUSH);
  2867. create.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  2868. create.setText(_prop.msgs.sNew);
  2869. listener(create, SWT.Selection, &this.create);
  2870. _alt = new Button(buttons, SWT.PUSH);
  2871. _alt.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  2872. _alt.setText(_prop.msgs.sAlt);
  2873. listener(_alt, SWT.Selection, &alt);
  2874. _del = new Button(buttons, SWT.PUSH);
  2875. _del.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  2876. _del.setText(_prop.msgs.sDel);
  2877. listener(_del, SWT.Selection, &del);
  2878. }
  2879. static if (is(T:ClassicEngine)) {
  2880. { mixin(S_TRACE);
  2881. _ceNameWin = new Shell(parent.getShell(), SWT.TITLE | SWT.RESIZE | SWT.TOOL | SWT.CLOSE);
  2882. _ceNameWin.setLayout(new FillLayout);
  2883. _ceNameWin.setText(_prop.msgs.dlgTitFeatureName);
  2884. .listener(_ceNameWin, SWT.Close, (Event e) { mixin(S_TRACE);
  2885. _ceNameWin.setVisible(false);
  2886. _features.setSelection(false);
  2887. e.doit = false;
  2888. });
  2889. _featureName = new Table(_ceNameWin, SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL);
  2890. _featureUndo = new UndoManager(_prop.var.etc.undoMaxEtc);
  2891. auto menu = new Menu(_featureName.getShell(), SWT.POP_UP);
  2892. createMenuItem(_comm, menu, MenuID.Undo, &undoFeatures, &_featureUndo.canUndo);
  2893. createMenuItem(_comm, menu, MenuID.Redo, &redoFeatures, &_featureUndo.canRedo);
  2894. new MenuItem(menu, SWT.SEPARATOR);
  2895. appendMenuTCPD(_comm, menu, new FTCPD, true, true, true, true, false);
  2896. new MenuItem(menu, SWT.SEPARATOR);
  2897. createMenuItem(_comm, menu, MenuID.SelectAll, { mixin(S_TRACE);
  2898. _featureName.select(iota(0, _featureName.getItemCount(), 1).array());
  2899. }, () => _featureName.getSelection().length < _featureName.getItemCount());
  2900. _featureName.setMenu(menu);
  2901. _featureName.setLayoutData(new GridData(GridData.FILL_BOTH));
  2902. _featureName.setHeaderVisible(true);
  2903. _featureName.setLinesVisible(true);
  2904. auto col1 = new TableColumn(_featureName, SWT.NONE);
  2905. col1.setText(_prop.msgs.featureDefaultName);
  2906. saveColumnWidth!("prop.var.etc.featureDefaultNameWidth")(_prop, col1);
  2907. auto col2 = new TableColumn(_featureName, SWT.NONE);
  2908. col2.setText(_prop.msgs.featureVariantName);
  2909. saveColumnWidth!("prop.var.etc.featureVariantNameWidth")(_prop, col2);
  2910. auto col3 = new TableColumn(_featureName, SWT.NONE);
  2911. col3.setText(_prop.msgs.featureManualName);
  2912. saveColumnWidth!("prop.var.etc.featureManualNameWidth")(_prop, col3);
  2913. _okText = new TableItem(_featureName, SWT.NONE);
  2914. _okText.setText(0, _prop.sys.evtChildOK(""));
  2915. foreach (f; SEX_ALL) { mixin(S_TRACE);
  2916. auto itm = new TableItem(_featureName, SWT.NONE);
  2917. itm.setText(0, _prop.sys.sexName(f, ""));
  2918. _sexName[f] = itm;
  2919. }
  2920. foreach (f; PERIOD_ALL) { mixin(S_TRACE);
  2921. auto itm = new TableItem(_featureName, SWT.NONE);
  2922. itm.setText(0, _prop.sys.periodName(f, ""));
  2923. _periodName[f] = itm;
  2924. }
  2925. foreach (f; NATURE_DEF ~ NATURE_EXT) { mixin(S_TRACE);
  2926. auto itm = new TableItem(_featureName, SWT.NONE);
  2927. itm.setText(0, _prop.sys.natureName(f, ""));
  2928. _natureName[f] = itm;
  2929. }
  2930. foreach (Makings f; MAKINGS_LEFT) { mixin(S_TRACE);
  2931. auto itm = new TableItem(_featureName, SWT.NONE);
  2932. itm.setText(0, _prop.sys.makingsName(f, ""));
  2933. _makingsName[f] = itm;
  2934. f = reverseMakings(f);
  2935. auto itmR = new TableItem(_featureName, SWT.NONE);
  2936. itmR.setText(0, _prop.sys.makingsName(f, ""));
  2937. _makingsName[f] = itmR;
  2938. }
  2939. new TableTextEdit(_comm, _prop, _featureName, 2, &featuresEnd, null);
  2940. auto winProps = _prop.var.featuresWin;
  2941. auto shell = _ceNameWin;
  2942. bool first = true;
  2943. .listener(_ceNameWin, SWT.Dispose, { mixin(S_TRACE);
  2944. if (first) return;
  2945. winProps.width = shell.getSize().x;
  2946. winProps.height = shell.getSize().y;
  2947. winProps.x = shell.getBounds().x - shell.getParent().getBounds().x;
  2948. winProps.y = shell.getBounds().y - shell.getParent().getBounds().y;
  2949. });
  2950. int parX, parY;
  2951. .listener(features, SWT.Selection, { mixin(S_TRACE);
  2952. if (first) { mixin(S_TRACE);
  2953. first = false;
  2954. auto pb = _ceNameWin.getParent().getBounds();
  2955. int px = pb.x;
  2956. int py = pb.y;
  2957. int pw = pb.width;
  2958. int ph = pb.height;
  2959. parX = px;
  2960. parY = py;
  2961. scope wp = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT);
  2962. int width = winProps.width == SWT.DEFAULT ? wp.x : winProps.width;
  2963. int height = winProps.height == SWT.DEFAULT ? wp.y : winProps.height;
  2964. int x = winProps.x == SWT.DEFAULT ? SWT.DEFAULT : winProps.x + shell.getParent().getBounds().x;
  2965. int y = winProps.y == SWT.DEFAULT ? SWT.DEFAULT : winProps.y + shell.getParent().getBounds().y;
  2966. if (SWT.DEFAULT == x) { mixin(S_TRACE);
  2967. auto fb = features.getBounds();
  2968. auto p = features.toDisplay(fb.x, fb.y);
  2969. x = p.x + fb.width;
  2970. }
  2971. if (SWT.DEFAULT == y) { mixin(S_TRACE);
  2972. y = py + ph - height;
  2973. }
  2974. intoDisplay(x, y, width, height);
  2975. shell.setBounds(x, y, width, height);
  2976. }
  2977. _ceNameWin.setVisible(features.getSelection());
  2978. });
  2979. .listener(getShell(), SWT.Move, { mixin(S_TRACE);
  2980. if (!getShell().isVisible()) return;
  2981. auto pb = _ceNameWin.getParent().getBounds();
  2982. auto tb = _ceNameWin.getBounds();
  2983. _ceNameWin.setBounds(tb.x + pb.x - parX, tb.y + pb.y - parY, tb.width, tb.height);
  2984. parX = pb.x;
  2985. parY = pb.y;
  2986. });
  2987. }
  2988. }
  2989. _kdFilter = new KeyDownFilter();
  2990. this.getDisplay().addFilter(SWT.KeyDown, _kdFilter);
  2991. _comm.refMenu.add(&refMenu);
  2992. _comm.refUndoMax.add(&refUndoMax);
  2993. listener(this, SWT.Dispose, { mixin(S_TRACE);
  2994. this.getDisplay().removeFilter(SWT.KeyDown, _kdFilter);
  2995. _comm.refMenu.remove(&refMenu);
  2996. _comm.refUndoMax.remove(&refUndoMax);
  2997. });
  2998. modB(_alt, _list, _name, _canApply);
  2999. static if (is(T:BgImageSetting)) {
  3000. modB(_alt, _list, _bgImgMask, _canApply);
  3001. modB(_alt, _list, _bgImgX, _canApply);
  3002. modB(_alt, _list, _bgImgY, _canApply);
  3003. modB(_alt, _list, _bgImgW, _canApply);
  3004. modB(_alt, _list, _bgImgH, _canApply);
  3005. } else static if (is(T:OuterTool)) {
  3006. modB(_alt, _list, _toolCommand, _canApply);
  3007. modB(_alt, _list, _toolWorkDir, _canApply);
  3008. modB(_alt, _list, _mnemonic, _canApply);
  3009. modB(_alt, _list, _hotkey.widget, _canApply);
  3010. } else static if (is(T:ClassicEngine)) {
  3011. modB(_alt, _list, _cEnginePath, _canApply);
  3012. modB(_alt, _list, _cEngineDataDir, _canApply);
  3013. modB(_alt, _list, _cEngineExecute, _canApply);
  3014. modB(_alt, _list, _mnemonic, _canApply);
  3015. modB(_alt, _list, _hotkey.widget, _canApply);
  3016. } else static if (is(T:ScTemplate)) {
  3017. modB(_alt, _list, _templPath, _canApply);
  3018. } else static if (is(T:EvTemplate)) {
  3019. modB(_alt, _list, _templScript, _canApply);
  3020. modB(_alt, _list, _mnemonic, _canApply);
  3021. modB(_alt, _list, _hotkey.widget, _canApply);
  3022. } else static assert (0);
  3023. leftSash.setWeights([sashL, sashR]);
  3024. listener(leftSash, SWT.Dispose, (Event e) { mixin(S_TRACE);
  3025. auto ws = (cast(SplitPane)e.widget).getWeights();
  3026. sashL = ws[0];
  3027. sashR = ws[1];
  3028. });
  3029. _array.length = array.length;
  3030. foreach (i, t; array) { mixin(S_TRACE);
  3031. _list.add(createName(t));
  3032. static if (is(typeof(t.dup))) {
  3033. _array[i] = t.dup;
  3034. } else { mixin(S_TRACE);
  3035. _array[i] = t;
  3036. }
  3037. }
  3038. if (_array.length > 0) _list.select(0);
  3039. selected();
  3040. }
  3041. @property
  3042. const
  3043. T[] array() { mixin(S_TRACE);
  3044. T[] arr;
  3045. arr.length = _array.length;
  3046. foreach (i, t; _array) { mixin(S_TRACE);
  3047. static if (is(typeof(t.dup))) {
  3048. arr[i] = t.dup;
  3049. } else { mixin(S_TRACE);
  3050. arr[i] = t;
  3051. }
  3052. }
  3053. return arr;
  3054. }
  3055. @property
  3056. const
  3057. bool noApply() { return _canApply; }
  3058. @property
  3059. const
  3060. string boxName() {
  3061. static if (is(T:BgImageSetting)) {
  3062. return _prop.msgs.bgImageSettings;
  3063. } else static if (is(T:OuterTool)) {
  3064. return _prop.msgs.outerToolsTitle;
  3065. } else static if (is(T:ClassicEngine)) {
  3066. return _prop.msgs.classicEnginesTitle;
  3067. } else static if (is(T:ScTemplate)) {
  3068. return _prop.msgs.scenarioTemplatesTitle;
  3069. } else static if (is(T:EvTemplate)) {
  3070. return _prop.msgs.eventTemplatesTitle;
  3071. } else static assert (0);
  3072. }
  3073. static if (is(T:ClassicEngine)) {
  3074. @property
  3075. Shell ceNameWin() { return _ceNameWin; }
  3076. @property
  3077. Button features() { return _features; }
  3078. }
  3079. static if (is(typeof(_shortcutSash))) {
  3080. void setShortcutWeights(ref int sashL, ref int sashR) {
  3081. _shortcutSash.setWeights([sashL, sashR]);
  3082. .listener(_shortcutSash, SWT.Dispose, { mixin(S_TRACE);
  3083. auto ws = _shortcutSash.getWeights();
  3084. sashL = ws[0];
  3085. sashR = ws[1];
  3086. });
  3087. }
  3088. }
  3089. }