PageRenderTime 66ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 1ms

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

https://bitbucket.org/k4nagatsuki/cwxeditor
D | 4172 lines | 3962 code | 140 blank | 70 comment | 734 complexity | db2c64d38f688f2071e9751bd1eb210b MD5 | raw file
Possible License(s): LGPL-2.1

Large files files are truncated, but you can click here to view the full file

  1. module cwx.editor.gui.dwt.replacedialog;
  2. import cwx.area;
  3. import cwx.summary;
  4. import cwx.event;
  5. import cwx.coupon;
  6. import cwx.utils;
  7. import cwx.card;
  8. import cwx.motion;
  9. import cwx.flag;
  10. import cwx.usecounter;
  11. import cwx.types;
  12. import cwx.path;
  13. import cwx.background;
  14. import cwx.skin;
  15. import cwx.msgutils;
  16. import cwx.menu;
  17. import cwx.jpy;
  18. import cwx.cab;
  19. import cwx.features;
  20. import cwx.textholder;
  21. import cwx.system;
  22. import cwx.warning;
  23. import cwx.editor.gui.dwt.dprops;
  24. import cwx.editor.gui.dwt.dutils;
  25. import cwx.editor.gui.dwt.centerlayout;
  26. import cwx.editor.gui.dwt.customtable;
  27. import cwx.editor.gui.dwt.commons;
  28. import cwx.editor.gui.dwt.dskin;
  29. import cwx.editor.gui.dwt.splitpane;
  30. import cwx.editor.gui.dwt.undo;
  31. import cwx.editor.gui.dwt.dmenu;
  32. import cwx.editor.gui.dwt.chooser;
  33. import cwx.editor.gui.dwt.incsearch;
  34. import std.ascii;
  35. import std.conv;
  36. import std.array;
  37. import std.string;
  38. import std.file;
  39. import std.path;
  40. import std.regex : Regex, regex, RegexMatch, match;
  41. import std.utf;
  42. import std.algorithm : uniq, swap;
  43. import std.traits;
  44. import std.typecons : Tuple;
  45. import org.eclipse.swt.all;
  46. import java.lang.all;
  47. private class CWXPathString {
  48. string scPath;
  49. CWXPath path;
  50. string array;
  51. this (string scPath, CWXPath path, string array) { mixin(S_TRACE);
  52. this.scPath = scPath;
  53. this.path = path;
  54. this.array = array;
  55. }
  56. }
  57. private class FilePathString {
  58. string scPath;
  59. string array;
  60. this (string scPath, string array) { mixin(S_TRACE);
  61. this.scPath = scPath;
  62. this.array = array;
  63. }
  64. }
  65. private class FKeyCodesUndo : TUndo!(FKeyCode[]) {
  66. this (FKeyCode[] old, FKeyCode[] n, void delegate(FKeyCode[]) set) { mixin(S_TRACE);
  67. super (old.dup, n.dup, set, (FKeyCode[] v) {return v.dup;});
  68. }
  69. }
  70. /// ??????????????
  71. class ReplaceDialog {
  72. private:
  73. class UndoRepl : UndoArr {
  74. this (Undo[] array, bool rev = true) { mixin(S_TRACE);
  75. super (array, rev);
  76. }
  77. override void undo() { mixin(S_TRACE);
  78. reset(false);
  79. super.undo();
  80. refContentText();
  81. _status.setText(.tryFormat(_prop.msgs.replaceUndo, .formatNum(_result.getItemCount())));
  82. _comm.replText.call();
  83. }
  84. override void redo() { mixin(S_TRACE);
  85. reset(false);
  86. super.redo();
  87. refContentText();
  88. _status.setText(.tryFormat(_prop.msgs.replaceRedo, .formatNum(_result.getItemCount())));
  89. _comm.replText.call();
  90. }
  91. }
  92. class RUndo : Undo {
  93. private CWXPath _path = null;
  94. private string _filePath = null;
  95. private Undo[] _uArr;
  96. this (CWXPath path, Undo[] uArr) { mixin(S_TRACE);
  97. _path = path;
  98. _uArr = uArr;
  99. }
  100. this (string filePath, Undo[] uArr) { mixin(S_TRACE);
  101. _filePath = filePath;
  102. _uArr = uArr;
  103. }
  104. void undo() { mixin(S_TRACE);
  105. size_t dmy = 0;
  106. foreach_reverse (u; _uArr) u.undo();
  107. if (_path) addResult(_path, dmy);
  108. if (_filePath) addResult(_filePath, dmy);
  109. }
  110. void redo() { mixin(S_TRACE);
  111. size_t dmy = 0;
  112. foreach_reverse (u; _uArr) u.redo();
  113. if (_path) addResult(_path, dmy);
  114. if (_filePath) addResult(_filePath, dmy);
  115. }
  116. void dispose() { mixin(S_TRACE);
  117. foreach (u; _uArr) u.dispose();
  118. }
  119. }
  120. void store(string filePath, Undo[] uArr) { mixin(S_TRACE);
  121. _rUndo ~= new RUndo(filePath, uArr);
  122. }
  123. void store(CWXPath path, Undo[] uArr) { mixin(S_TRACE);
  124. _rUndo ~= new RUndo(path, uArr);
  125. }
  126. void store(CWXPath path, string o, string n, void delegate(string) set) { mixin(S_TRACE);
  127. _rUndo ~= new RUndo(path, [new StrUndo(o, n, set)]);
  128. }
  129. void store(CWXPath path, string[] o, string[] n, void delegate(string[]) set) { mixin(S_TRACE);
  130. _rUndo ~= new RUndo(path, [new StrArrUndo(o, n, set)]);
  131. }
  132. void store(CWXPath path, FKeyCode[] o, FKeyCode[] n, void delegate(FKeyCode[]) set) { mixin(S_TRACE);
  133. _rUndo ~= new RUndo(path, [new FKeyCodesUndo(o, n, set)]);
  134. }
  135. void storeID(User, Id)(CWXPath path, User u, Id from, Id to, void delegate(Id) set) { mixin(S_TRACE);
  136. _rUndo ~= new RUndo(path, [new TUndo!Id(from, to, set)]);
  137. }
  138. bool _inProc = false;
  139. bool _inUndo = false;
  140. Undo[] _rUndo;
  141. void delegate()[] _after;
  142. core.thread.Thread _uiThread;
  143. Commons _comm;
  144. Props _prop;
  145. Summary _summ;
  146. UndoManager _undo;
  147. Summary _grepSumm = null;
  148. int _grepCount = -1;
  149. Skin _grepSkin = null;
  150. string _grepFile = "";
  151. bool _inGrep = false;
  152. bool _cancel = false;
  153. Shell _win;
  154. Composite _parent;
  155. CTabFolder _tabf;
  156. CTabItem _tabText;
  157. CTabItem _tabID;
  158. CTabItem _tabPath;
  159. CTabItem _tabContents;
  160. CTabItem _tabCoupon;
  161. CTabItem _tabUnuse;
  162. CTabItem _tabError;
  163. CTabItem _tabGrep;
  164. CTabItem _lastFind = null;
  165. Button _find;
  166. Button _replace;
  167. Button _close;
  168. Button _rangeAllCheck;
  169. bool ignoreMod = false;
  170. Composite _textGrp1, _textGrp2, _textFromComp, _grepFromComp;
  171. Combo _from;
  172. Combo _to;
  173. IncSearch _fromIncSearch = null;
  174. IncSearch _toIncSearch = null;
  175. Combo _idKind;
  176. Combo _fromID;
  177. Composite _fromIDComp;
  178. Spinner _fromIDVal;
  179. ulong[int] _fromIDTbl;
  180. Combo _toID;
  181. Composite _toIDComp;
  182. Spinner _toIDVal;
  183. ulong[int] _toIDTbl;
  184. IncSearch _fromIDIncSearch = null;
  185. IncSearch _toIDIncSearch = null;
  186. Combo _fromPath;
  187. Combo _toPath;
  188. IncSearch _fromPathIncSearch = null;
  189. IncSearch _toPathIncSearch = null;
  190. Combo _grepDir;
  191. Button _grepSubDir;
  192. Button _notIgnoreCase;
  193. Button _useRegex;
  194. Button _useWildcard;
  195. Button _exact;
  196. Button _ignoreReturnCode;
  197. class SelRegex : SelectionAdapter {
  198. override void widgetSelected(SelectionEvent e) { mixin(S_TRACE);
  199. if (_useRegex.getSelection()) { mixin(S_TRACE);
  200. _useWildcard.setSelection(false);
  201. }
  202. }
  203. }
  204. class SelWildcard : SelectionAdapter {
  205. override void widgetSelected(SelectionEvent e) { mixin(S_TRACE);
  206. if (_useWildcard.getSelection()) { mixin(S_TRACE);
  207. _useRegex.setSelection(false);
  208. }
  209. }
  210. }
  211. class SelIgnoreReturnCode : SelectionAdapter {
  212. override void widgetSelected(SelectionEvent e) { mixin(S_TRACE);
  213. _comm.refreshToolBar();
  214. }
  215. }
  216. @property
  217. const
  218. bool catchMod() {return !ignoreMod;}
  219. /// ???
  220. Button _summary;
  221. /// ????????
  222. Button _rCoupon;
  223. /// ?????
  224. Button _msg;
  225. /// ????
  226. Button _cardName;
  227. /// ?????
  228. Button _cardDesc;
  229. /// ????????
  230. Button _event;
  231. /// ?????
  232. Button _start;
  233. /// ???/????
  234. Button _flag;
  235. /// ????
  236. Button _coupon;
  237. /// ????
  238. Button _gossip;
  239. /// ???
  240. Button _end;
  241. /// ???/???/??????
  242. Button _area;
  243. /// ?????
  244. Button _keyCode;
  245. /// ????
  246. Button _file;
  247. /// ????
  248. Button _comment;
  249. /// JPTX????
  250. Button _jptx;
  251. Button[] _noSummText;
  252. Button _unuseFlag;
  253. Button _unuseStep;
  254. Button _unuseArea;
  255. Button _unuseBattle;
  256. Button _unusePackage;
  257. Button _unuseCast;
  258. Button _unuseSkill;
  259. Button _unuseItem;
  260. Button _unuseBeast;
  261. Button _unuseInfo;
  262. Button _unuseStart;
  263. Button _unusePath;
  264. Button _cCoupon;
  265. Button _cGossip;
  266. Button _cEnd;
  267. Button _cKeyCode;
  268. // FIXME: CardWirth 1.60 ????
  269. /+ Button _cCellName;
  270. +/
  271. Table _result;
  272. TableTextEdit _edit;
  273. Tree _range;
  274. Composite[CTabItem] _comps;
  275. ToolItem[CType] _contents;
  276. Label _status;
  277. bool _notIgnoreCaseSel;
  278. bool _exactSel;
  279. bool _ignoreReturnCodeSel;
  280. bool _summarySel;
  281. bool _msgSel;
  282. bool _cardNameSel;
  283. bool _cardDescSel;
  284. bool _eventSel;
  285. bool _startSel;
  286. bool _flagSel;
  287. bool _couponSel;
  288. bool _gossipSel;
  289. bool _endSel;
  290. bool _areaSel;
  291. bool _keyCodeSel;
  292. bool _fileSel;
  293. bool _commentSel;
  294. bool _jptxSel;
  295. string _fromText;
  296. string _toText;
  297. bool _flagDirOnRange = false;
  298. bool _resultRedraw = true;
  299. void resultRedraw(bool val) { mixin(S_TRACE);
  300. if (!_win || _win.isDisposed()) return;
  301. if (_resultRedraw !is val) { mixin(S_TRACE);
  302. _resultRedraw = val;
  303. _result.setRedraw(val);
  304. }
  305. }
  306. class AddResultPath : Runnable {
  307. size_t count = 0;
  308. string path;
  309. string desc;
  310. void run() { mixin(S_TRACE);
  311. if (cancel) return;
  312. if (!_win || _win.isDisposed()) return;
  313. if (_inProc && !_prop.var.etc.searchResultRealtime) resultRedraw(false);
  314. auto itm = new TableItem(_result, SWT.NONE);
  315. auto summ = _grepSumm ? _grepSumm : _summ;
  316. auto fullPath = std.path.buildPath(summ.scenarioPath, path);
  317. if (_grepSumm) { mixin(S_TRACE);
  318. if (!_grepSkin) _grepSkin = findSkin(_comm, _prop, summ);
  319. itm.setImage(fimage(fullPath, _grepSkin));
  320. } else { mixin(S_TRACE);
  321. itm.setImage(fimage(fullPath, _comm.skin));
  322. }
  323. string scPath = null;
  324. string text = encodePath(path);
  325. itm.setText(0, text);
  326. if (desc.length) { mixin(S_TRACE);
  327. itm.setText(2, desc);
  328. itm.setImage(2, _prop.images.warning);
  329. }
  330. if (_grepSumm) { mixin(S_TRACE);
  331. scPath = _grepSumm.useTemp ? _grepSumm.zipName : _grepSumm.scenarioPath;
  332. text = .tryFormat(_prop.msgs.grepScenario, _grepSumm.scenarioName, scPath);
  333. itm.setText(2, text);
  334. itm.setImage(2, _prop.images.summary);
  335. }
  336. itm.setData(new FilePathString(scPath, path));
  337. refResultStatus(count, false);
  338. }
  339. }
  340. class AddResultCWXPath : Runnable {
  341. CWXPath path;
  342. int index;
  343. string desc;
  344. size_t count = 0;
  345. void run() { mixin(S_TRACE);
  346. if (cancel) return;
  347. if (!_win || _win.isDisposed()) return;
  348. if (_inProc && !_prop.var.etc.searchResultRealtime) resultRedraw(false);
  349. auto itm = new TableItem(_result, SWT.NONE, -1 == index ? _result.getItemCount() : index);
  350. string text1, text2;
  351. Image img1, img2;
  352. getPathParams(path, text1, text2, img1, img2);
  353. itm.setImage(0, img1);
  354. itm.setText(0, text1);
  355. itm.setImage(1, img2);
  356. itm.setText(1, text2);
  357. if (desc.length) { mixin(S_TRACE);
  358. itm.setText(2, desc);
  359. itm.setImage(2, _prop.images.warning);
  360. }
  361. string scPath = null;
  362. if (_grepSumm) { mixin(S_TRACE);
  363. scPath = _grepSumm.useTemp ? _grepSumm.zipName : _grepSumm.scenarioPath;
  364. itm.setText(2, .tryFormat(_prop.msgs.grepScenario, _grepSumm.scenarioName, scPath));
  365. itm.setImage(2, _prop.images.summary);
  366. }
  367. itm.setData(new CWXPathString(scPath, _grepSumm ? null : path, path.cwxPath(true)));
  368. refResultStatus(count, false);
  369. }
  370. }
  371. class AddResultMsg : Runnable {
  372. string name;
  373. Image delegate() image;
  374. int index;
  375. size_t count = 0;
  376. void run() { mixin(S_TRACE);
  377. if (cancel) return;
  378. if (!_win || _win.isDisposed()) return;
  379. if (_inProc && !_prop.var.etc.searchResultRealtime) resultRedraw(false);
  380. auto itm = new TableItem(_result, SWT.NONE, -1 == index ? _result.getItemCount() : index);
  381. itm.setText(name);
  382. itm.setImage(image());
  383. refResultStatus(count, false);
  384. }
  385. }
  386. class AddResultUse : Runnable {
  387. string name;
  388. uint use;
  389. Image delegate() image;
  390. int index;
  391. size_t count = 0;
  392. void run() { mixin(S_TRACE);
  393. if (cancel) return;
  394. if (!_win || _win.isDisposed()) return;
  395. if (_inProc && !_prop.var.etc.searchResultRealtime) resultRedraw(false);
  396. auto itm = new TableItem(_result, SWT.NONE, -1 == index ? _result.getItemCount() : index);
  397. itm.setText(0, name);
  398. itm.setImage(0, image());
  399. itm.setText(1, .text(use));
  400. refResultStatus(count, false);
  401. }
  402. }
  403. Display _display;
  404. class ML : MouseAdapter {
  405. public override void mouseDoubleClick(MouseEvent e) { mixin(S_TRACE);
  406. if (_result.isFocusControl() && e.button == 1) { mixin(S_TRACE);
  407. openPath();
  408. }
  409. }
  410. }
  411. class KL : KeyAdapter {
  412. public override void keyPressed(KeyEvent e) { mixin(S_TRACE);
  413. if (_result.isFocusControl() && e.character == SWT.CR) { mixin(S_TRACE);
  414. openPath();
  415. }
  416. }
  417. }
  418. static const ID_AREA = 0;
  419. static const ID_BATTLE = 1;
  420. static const ID_PACKAGE = 2;
  421. static const ID_CAST = 3;
  422. static const ID_SKILL = 4;
  423. static const ID_ITEM = 5;
  424. static const ID_BEAST = 6;
  425. static const ID_INFO = 7;
  426. static const ID_FLAG = 8;
  427. static const ID_STEP = 9;
  428. static const ID_COUPON = 10;
  429. static const ID_GOSSIP = 11;
  430. static const ID_COMPLETE_STAMP = 12;
  431. static const ID_KEY_CODE = 13;
  432. // FIXME: CardWirth 1.60 ????
  433. /+ static const ID_CELL_NAME = 14;
  434. +/ private void setupIDsImpl2(T)(T[] arr, Combo combo, Spinner spn, ref ulong[int] tbl, bool clear, IncSearch incSearch) { mixin(S_TRACE);
  435. ulong[int] tbl2;
  436. string oldSel = clear ? "" : combo.getText();
  437. combo.removeAll();
  438. static if (is(T:Flag) || is(T:Step)) {
  439. auto set = new HashSet!string;
  440. if (_summ) { mixin(S_TRACE);
  441. static if (is(T:Flag)) {
  442. foreach (key; _summ.useCounter.flag.keys) { mixin(S_TRACE);
  443. if (_prop.sys.randomValue == cast(string)key) continue;
  444. if (!incSearch.match(cast(string)key)) continue;
  445. set.add(cast(string)key);
  446. }
  447. } else static if (is(T:Step)) {
  448. foreach (key; _summ.useCounter.step.keys) { mixin(S_TRACE);
  449. if (_prop.sys.randomValue == cast(string)key) continue;
  450. if (!incSearch.match(cast(string)key)) continue;
  451. set.add(cast(string)key);
  452. }
  453. } else static assert (0);
  454. }
  455. foreach (i, a; arr) { mixin(S_TRACE);
  456. auto p = a.path;
  457. if (p == "") continue;
  458. if (!incSearch.match(p)) continue;
  459. combo.add(p);
  460. set.remove(p);
  461. }
  462. bool delegate(string a, string b) cmps;
  463. if (_prop.var.etc.logicalSort) { mixin(S_TRACE);
  464. cmps = (a, b) => incmp(a, b) < 0;
  465. } else { mixin(S_TRACE);
  466. cmps = (a, b) => icmp(a, b) < 0;
  467. }
  468. foreach (p; .sortDlg(set.array(), cmps)) { mixin(S_TRACE);
  469. if (p == "") continue;
  470. if (!incSearch.match(p)) continue;
  471. combo.add(p);
  472. }
  473. combo.setText(oldSel);
  474. if (combo.getText() == "" && combo.getItemCount()) { mixin(S_TRACE);
  475. combo.select(0);
  476. }
  477. spn.setEnabled(false);
  478. } else static if (is(T:CouponId) || is(T:GossipId) || is(T:CompleteStampId) || is(T:KeyCodeId) || is(T:CellNameId)) {
  479. string[] arr2;
  480. static if (is(T:CouponId)) {
  481. arr2 = .allCoupons(_comm, _summ, CouponComboType.AllCoupons);
  482. } else static if (is(T:GossipId)) {
  483. arr2 = .allGossips(_comm, _summ);
  484. } else static if (is(T:CompleteStampId)) {
  485. arr2 = .allCompleteStamps(_comm, _summ);
  486. } else static if (is(T:KeyCodeId)) {
  487. arr2 = .allKeyCodes(_comm, _summ);
  488. } else static if (is(T:CellNameId)) {
  489. arr2 = .allCellNames(_comm, _summ);
  490. } else static assert (0);
  491. foreach (a; arr2) {
  492. if (!incSearch.match(a)) continue;
  493. combo.add(a);
  494. }
  495. combo.setText(oldSel);
  496. if (combo.getText() == "" && combo.getItemCount()) { mixin(S_TRACE);
  497. combo.select(0);
  498. }
  499. spn.setEnabled(false);
  500. } else {
  501. combo.add(_prop.msgs.replSetID);
  502. foreach (i, a; arr) { mixin(S_TRACE);
  503. if (!incSearch.match(a.name)) continue;
  504. combo.add(to!(string)(a.id) ~ "." ~ a.name);
  505. tbl2[i + 1] = a.id;
  506. }
  507. combo.select(1 < combo.getItemCount() ? 1 : 0);
  508. if (oldSel) { mixin(S_TRACE);
  509. auto i = combo.indexOf(oldSel);
  510. if (i >= 0) combo.select(i);
  511. }
  512. spn.setEnabled(combo.getSelectionIndex() == 0);
  513. }
  514. tbl = tbl2;
  515. }
  516. private void setupIDsImpl1(T)(T[] arr, bool clear, bool from, bool to) { mixin(S_TRACE);
  517. if (from) setupIDsImpl2(arr, _fromID, _fromIDVal, _fromIDTbl, clear, _fromIDIncSearch);
  518. if (to) setupIDsImpl2(arr, _toID, _toIDVal, _toIDTbl, clear, _toIDIncSearch);
  519. }
  520. private void setupIDs(bool clear, bool from, bool to) { mixin(S_TRACE);
  521. if (!_summ) { mixin(S_TRACE);
  522. _fromID.removeAll();
  523. _fromID.setEnabled(false);
  524. _fromIDVal.setEnabled(false);
  525. _toID.removeAll();
  526. _toID.setEnabled(false);
  527. _toIDVal.setEnabled(false);
  528. return;
  529. }
  530. if (from) _fromID.setEnabled(true);
  531. if (to) _toID.setEnabled(true);
  532. switch (_idKind.getSelectionIndex()) {
  533. case ID_AREA: setupIDsImpl1(_summ.areas, clear, from, to); break;
  534. case ID_BATTLE: setupIDsImpl1(_summ.battles, clear, from, to); break;
  535. case ID_PACKAGE: setupIDsImpl1(_summ.packages, clear, from, to); break;
  536. case ID_CAST: setupIDsImpl1(_summ.casts, clear, from, to); break;
  537. case ID_SKILL: setupIDsImpl1(_summ.skills, clear, from, to); break;
  538. case ID_ITEM: setupIDsImpl1(_summ.items, clear, from, to); break;
  539. case ID_BEAST: setupIDsImpl1(_summ.beasts, clear, from, to); break;
  540. case ID_INFO: setupIDsImpl1(_summ.infos, clear, from, to); break;
  541. case ID_FLAG: setupIDsImpl1(_summ.flagDirRoot.allFlags, clear, from, to); break;
  542. case ID_STEP: setupIDsImpl1(_summ.flagDirRoot.allSteps, clear, from, to); break;
  543. case ID_COUPON: setupIDsImpl1(_summ.useCounter.coupon.keys, clear, from, to); break;
  544. case ID_GOSSIP: setupIDsImpl1(_summ.useCounter.gossip.keys, clear, from, to); break;
  545. case ID_COMPLETE_STAMP: setupIDsImpl1(_summ.useCounter.completeStamp.keys, clear, from, to); break;
  546. case ID_KEY_CODE: setupIDsImpl1(_summ.useCounter.keyCode.keys, clear, from, to); break;
  547. // FIXME: CardWirth 1.60 ????
  548. /+ case ID_CELL_NAME: setupIDsImpl1(_summ.useCounter.cellName.keys, clear, from, to); break;
  549. +/ default: assert (0);
  550. }
  551. }
  552. private void fromIDIncSearch() { mixin(S_TRACE);
  553. .forceFocus(_fromID, true);
  554. _fromIDIncSearch.startIncSearch();
  555. }
  556. private void toIDIncSearch() { mixin(S_TRACE);
  557. .forceFocus(_toID, true);
  558. _toIDIncSearch.startIncSearch();
  559. }
  560. private string[] _lastMaterialPaths;
  561. private string[] allMaterials(bool scenarioOnly) { mixin(S_TRACE);
  562. if (!_summ) return [];
  563. return _summ.allMaterials(_comm.skin, _prop.var.etc.ignorePaths, _prop.var.etc.logicalSort, scenarioOnly);
  564. }
  565. private void setupPaths() { mixin(S_TRACE);
  566. bool oldIgnoreMod = ignoreMod;
  567. ignoreMod = true;
  568. scope (exit) ignoreMod = oldIgnoreMod;
  569. _lastMaterialPaths = [""] ~ allMaterials(false);
  570. setupPathsImpl(true, true);
  571. }
  572. private void setupPathsImpl(bool from, bool to) {
  573. void setPaths(Combo combo, IncSearch incSearch) { mixin(S_TRACE);
  574. auto old = combo.getText();
  575. combo.removeAll();
  576. foreach (path; _lastMaterialPaths) {
  577. if (!incSearch.match(path)) continue;
  578. combo.add(path);
  579. }
  580. combo.setText(old);
  581. }
  582. if (from) setPaths(_fromPath, _fromPathIncSearch);
  583. if (to) setPaths(_toPath, _toPathIncSearch);
  584. }
  585. class SListener : ShellAdapter {
  586. override void shellActivated(ShellEvent e) { mixin(S_TRACE);
  587. setupIDs(false, true, true);
  588. setupPaths();
  589. _comm.refreshToolBar();
  590. }
  591. }
  592. class SelID : SelectionAdapter {
  593. private Spinner _spn;
  594. this (Spinner spn) {_spn = spn;}
  595. override void widgetSelected(SelectionEvent e) { mixin(S_TRACE);
  596. auto combo = cast(Combo) e.widget;
  597. _spn.setEnabled(combo.getSelectionIndex() == 0);
  598. _comm.refreshToolBar();
  599. }
  600. }
  601. class SelIDKind : SelectionAdapter {
  602. override void widgetSelected(SelectionEvent e) { mixin(S_TRACE);
  603. selIDKind();
  604. }
  605. }
  606. void selIDKind() {
  607. updateIDCombo();
  608. setupIDs(true, true, true);
  609. _prop.var.etc.searchIDKind = _idKind.getSelectionIndex();
  610. _comm.refreshToolBar();
  611. }
  612. @property
  613. private bool idKindIsString() {
  614. auto index = _idKind.getSelectionIndex();
  615. // FIXME: CardWirth 1.60 ???? ????
  616. /+ return index == ID_FLAG || index == ID_STEP || index == ID_COUPON || index == ID_GOSSIP || index == ID_COMPLETE_STAMP || index == ID_KEY_CODE || index == ID_CELL_NAME;
  617. +/ return index == ID_FLAG || index == ID_STEP || index == ID_COUPON || index == ID_GOSSIP || index == ID_COMPLETE_STAMP || index == ID_KEY_CODE;
  618. // FIXME: CardWirth 1.60 ???? ????
  619. }
  620. private void updateIDCombo() { mixin(S_TRACE);
  621. if (idKindIsString) { mixin(S_TRACE);
  622. if (_fromID && !(_fromID.getStyle() & SWT.READ_ONLY)) return;
  623. if (_fromID) { mixin(S_TRACE);
  624. _fromID.dispose();
  625. _toID.dispose();
  626. }
  627. _fromID = new Combo(_fromIDComp, SWT.BORDER | SWT.DROP_DOWN);
  628. _fromID.setVisibleItemCount(_prop.var.etc.comboVisibleItemCount);
  629. _toID = new Combo(_toIDComp, SWT.BORDER | SWT.DROP_DOWN);
  630. _toID.setVisibleItemCount(_prop.var.etc.comboVisibleItemCount);
  631. } else { mixin(S_TRACE);
  632. if (_fromID && (_fromID.getStyle() & SWT.READ_ONLY)) return;
  633. if (_fromID) { mixin(S_TRACE);
  634. _fromID.dispose();
  635. _toID.dispose();
  636. }
  637. _fromID = new Combo(_fromIDComp, SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY);
  638. _fromID.setVisibleItemCount(_prop.var.etc.comboVisibleItemCount);
  639. _fromID.addSelectionListener(new SelID(_fromIDVal));
  640. _toID = new Combo(_toIDComp, SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY);
  641. _toID.setVisibleItemCount(_prop.var.etc.comboVisibleItemCount);
  642. _toID.addSelectionListener(new SelID(_toIDVal));
  643. }
  644. auto fMenu = new Menu(_win, SWT.POP_UP);
  645. _fromID.setMenu(fMenu);
  646. createMenuItem(_comm, fMenu, MenuID.IncSearch, &fromIDIncSearch, null);
  647. new MenuItem(fMenu, SWT.SEPARATOR);
  648. createTextMenu!Combo(_comm, _prop, _fromID, &catchMod);
  649. auto tMenu = new Menu(_win, SWT.POP_UP);
  650. _toID.setMenu(tMenu);
  651. createMenuItem(_comm, tMenu, MenuID.IncSearch, &toIDIncSearch, null);
  652. new MenuItem(tMenu, SWT.SEPARATOR);
  653. createTextMenu!Combo(_comm, _prop, _toID, &catchMod);
  654. _fromIDIncSearch = new IncSearch(_comm, _fromID);
  655. _fromIDIncSearch.modEvent ~= () => setupIDs(false, true, false);
  656. _toIDIncSearch = new IncSearch(_comm, _toID);
  657. _toIDIncSearch.modEvent ~= () => setupIDs(false, false, true);
  658. _fromIDComp.layout();
  659. _toIDComp.layout();
  660. }
  661. private void tabChanged() { mixin(S_TRACE);
  662. auto sel = _tabf.getSelection();
  663. if (!sel) return;
  664. _parent.setRedraw(false);
  665. scope (exit) _parent.setRedraw(true);
  666. _prop.var.etc.searchPlan = _tabf.getSelectionIndex();
  667. if (sel is _tabText || sel is _tabGrep) { mixin(S_TRACE);
  668. auto comp = _comps[sel is _tabGrep ? _tabGrep : _tabText];
  669. if (_textGrp1.getParent() !is comp) _textGrp1.setParent(comp);
  670. if (_textGrp2.getParent() !is comp) _textGrp2.setParent(comp);
  671. auto fromComp = sel is _tabGrep ? _grepFromComp : _textFromComp;
  672. if (_from.getParent() !is fromComp) { mixin(S_TRACE);
  673. _from.setParent(fromComp);
  674. }
  675. }
  676. foreach (tab, comp; _comps) { mixin(S_TRACE);
  677. auto gd = cast(GridData) comp.getLayoutData();
  678. if (tab is sel) { mixin(S_TRACE);
  679. gd.heightHint= SWT.DEFAULT;
  680. } else { mixin(S_TRACE);
  681. gd.heightHint= 0;
  682. }
  683. }
  684. _parent.layout(true);
  685. _replace.setEnabled(!(sel is _tabText && _ignoreReturnCode.getSelection()) && sel !is _tabContents && sel !is _tabCoupon && sel !is _tabUnuse && sel !is _tabError);
  686. _range.setEnabled(sel !is _tabUnuse && sel !is _tabGrep);
  687. _rangeAllCheck.setEnabled(_range.getEnabled());
  688. _comm.refreshToolBar();
  689. }
  690. class TSListener : SelectionAdapter {
  691. override void widgetSelected(SelectionEvent e) { mixin(S_TRACE);
  692. tabChanged();
  693. }
  694. }
  695. LCheck[] _checked;
  696. class LCheck : SelectionAdapter {
  697. Widget[] buttons;
  698. private Button _all = null;
  699. private void setSelection(Widget b, bool s) { mixin(S_TRACE);
  700. auto button = cast(Button) b;
  701. if (button) button.setSelection(s);
  702. auto ti = cast(ToolItem) b;
  703. if (ti) ti.setSelection(s);
  704. }
  705. private bool getSelection(Widget b) { mixin(S_TRACE);
  706. auto button = cast(Button) b;
  707. if (button) return button.getSelection();
  708. auto ti = cast(ToolItem) b;
  709. if (ti) return ti.getSelection();
  710. assert (0);
  711. }
  712. class AllCheck : SelectionAdapter {
  713. override void widgetSelected(SelectionEvent e) { mixin(S_TRACE);
  714. foreach (b; buttons) { mixin(S_TRACE);
  715. setSelection(b, _all.getSelection());
  716. }
  717. }
  718. }
  719. void check() { mixin(S_TRACE);
  720. bool checked = true;
  721. foreach (b; buttons) { mixin(S_TRACE);
  722. checked &= getSelection(b);
  723. }
  724. _all.setSelection(checked);
  725. }
  726. override void widgetSelected(SelectionEvent e) { mixin(S_TRACE);
  727. assert (_all);
  728. check();
  729. }
  730. void createAlls(Composite parent, string text) { mixin(S_TRACE);
  731. _all = new Button(parent, SWT.CHECK);
  732. _all.setText(text);
  733. _all.addSelectionListener(new AllCheck);
  734. check();
  735. }
  736. }
  737. Composite addButtonLine(Composite grp) { mixin(S_TRACE);
  738. auto comp = new Composite(grp, SWT.NONE);
  739. comp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  740. auto rl = new RowLayout(SWT.HORIZONTAL);
  741. rl.wrap = true;
  742. rl.pack = false;
  743. comp.setLayout(rl);
  744. return comp;
  745. }
  746. void constructText(CTabFolder tabf) { mixin(S_TRACE);
  747. auto comp = new Composite(tabf, SWT.NONE);
  748. comp.setLayout(new GridLayout(1, true));
  749. auto comp2 = new Composite(comp, SWT.NONE);
  750. auto comp2gl = windowGridLayout(1, true);
  751. comp2gl.marginWidth = 0;
  752. comp2gl.marginHeight = 0;
  753. comp2.setLayout(comp2gl);
  754. { mixin(S_TRACE);
  755. auto grp = new Group(comp2, SWT.NONE);
  756. grp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  757. grp.setText(_prop.msgs.replText);
  758. grp.setLayout(new GridLayout(2, false));
  759. auto fl = new Label(grp, SWT.NONE);
  760. fl.setText(_prop.msgs.replFrom);
  761. _textFromComp = new Composite(grp, SWT.NONE);
  762. _textFromComp.setLayout(new FillLayout);
  763. _from = new Combo(grp, SWT.BORDER | SWT.DROP_DOWN);
  764. _from.setVisibleItemCount(_prop.var.etc.comboVisibleItemCount);
  765. auto gd = new GridData(GridData.FILL_HORIZONTAL);
  766. gd.widthHint = _prop.var.etc.nameWidth;
  767. _textFromComp.setLayoutData(gd);
  768. auto lt = new Label(grp, SWT.NONE);
  769. lt.setText(_prop.msgs.replTo);
  770. _to = new Combo(grp, SWT.BORDER | SWT.DROP_DOWN);
  771. _to.setVisibleItemCount(_prop.var.etc.comboVisibleItemCount);
  772. _to.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  773. auto fMenu = new Menu(_win, SWT.POP_UP);
  774. _from.setMenu(fMenu);
  775. createMenuItem(_comm, fMenu, MenuID.IncSearch, {
  776. .forceFocus(_from, true);
  777. _fromIncSearch.startIncSearch();
  778. }, null);
  779. new MenuItem(fMenu, SWT.SEPARATOR);
  780. createTextMenu!Combo(_comm, _prop, _from, &catchMod);
  781. auto tMenu = new Menu(_win, SWT.POP_UP);
  782. _to.setMenu(tMenu);
  783. createMenuItem(_comm, tMenu, MenuID.IncSearch, {
  784. .forceFocus(_to, true);
  785. _toIncSearch.startIncSearch();
  786. }, null);
  787. new MenuItem(tMenu, SWT.SEPARATOR);
  788. createTextMenu!Combo(_comm, _prop, _to, &catchMod);
  789. _fromIncSearch = new IncSearch(_comm, _from);
  790. _fromIncSearch.modEvent ~= &updateFromHistory;
  791. _toIncSearch = new IncSearch(_comm, _to);
  792. _toIncSearch.modEvent ~= &updateToHistory;
  793. }
  794. { mixin(S_TRACE);
  795. auto grp = new Group(comp2, SWT.NONE);
  796. _textGrp1 = grp;
  797. auto gd = new GridData(GridData.FILL_HORIZONTAL);
  798. gd.widthHint = _prop.var.etc.searchResultTableWidth;
  799. grp.setLayoutData(gd);
  800. grp.setText(_prop.msgs.replCond);
  801. grp.setLayout(new GridLayout(3, false));
  802. _notIgnoreCase = new Button(grp, SWT.CHECK);
  803. _notIgnoreCase.setText(_prop.msgs.replNotIgnoreCase);
  804. _exact = new Button(grp, SWT.CHECK);
  805. _exact.setText(_prop.msgs.replExactMatch);
  806. _ignoreReturnCode = new Button(grp, SWT.CHECK);
  807. _ignoreReturnCode.setText(_prop.msgs.replIgnoreReturnCode);
  808. _ignoreReturnCode.addSelectionListener(new SelIgnoreReturnCode);
  809. _useWildcard = new Button(grp, SWT.CHECK);
  810. _useWildcard.setText(_prop.msgs.replWildcard);
  811. _useWildcard.addSelectionListener(new SelWildcard);
  812. auto gdw = new GridData;
  813. gdw.horizontalSpan = 3;
  814. _useWildcard.setLayoutData(gdw);
  815. _useRegex = new Button(grp, SWT.CHECK);
  816. _useRegex.setText(_prop.msgs.replRegExp);
  817. _useRegex.addSelectionListener(new SelRegex);
  818. auto gdr = new GridData;
  819. gdr.horizontalSpan = 3;
  820. _useRegex.setLayoutData(gdr);
  821. }
  822. { mixin(S_TRACE);
  823. auto grp = new Group(comp2, SWT.NONE);
  824. _textGrp2 = grp;
  825. auto gd = new GridData(GridData.FILL_HORIZONTAL);
  826. gd.widthHint = _prop.var.etc.searchResultTableWidth;
  827. grp.setLayoutData(gd);
  828. grp.setText(_prop.msgs.replTextTarget);
  829. grp.setLayout(zeroGridLayout(1, true));
  830. auto checked = new LCheck;
  831. _checked ~= checked;
  832. { mixin(S_TRACE);
  833. auto btns = addButtonLine(grp);
  834. Button createB(string text, char accr, bool summ = false) { mixin(S_TRACE);
  835. auto b = new Button(btns, SWT.CHECK);
  836. b.setText(text ~ "(&" ~ accr ~ ")");
  837. checked.buttons ~= b;
  838. b.addSelectionListener(checked);
  839. if (!summ) _noSummText ~= b;
  840. return b;
  841. }
  842. _summary = createB(_prop.msgs.replTextSummary, '1', true);
  843. _msg = createB(_prop.msgs.replTextMessage, '2');
  844. _cardName = createB(_prop.msgs.replTextCardName, '3');
  845. _cardDesc = createB(_prop.msgs.replTextCardDesc, '4');
  846. _event = createB(_prop.msgs.replTextEventText, '5');
  847. _start = createB(_prop.msgs.replTextStart, '6');
  848. _flag = createB(_prop.msgs.replTextFlagAndStep, '7');
  849. _coupon = createB(_prop.msgs.replTextCoupon, '8');
  850. _gossip = createB(_prop.msgs.replTextGossip, '9');
  851. _end = createB(_prop.msgs.replTextEndScenario, 'A');
  852. _area = createB(_prop.msgs.replTextAreaName, 'B');
  853. _keyCode = createB(_prop.msgs.replTextKeyCode, 'D');
  854. _file = createB(_prop.msgs.replTextFile, 'E');
  855. _comment = createB(_prop.msgs.replTextComment, 'G');
  856. _jptx = createB(_prop.msgs.replTextJptx, 'H');
  857. }
  858. auto sep = new Label(grp, SWT.SEPARATOR | SWT.HORIZONTAL);
  859. sep.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  860. { mixin(S_TRACE);
  861. auto btns = addButtonLine(grp);
  862. checked.createAlls(btns, _prop.msgs.allCheck);
  863. }
  864. }
  865. auto tab = new CTabItem(tabf, SWT.NONE);
  866. tab.setText(_prop.msgs.replForText);
  867. tab.setControl(comp);
  868. _tabText = tab;
  869. auto gd = new GridData(GridData.FILL_BOTH);
  870. comp2.setLayoutData(gd);
  871. _comps[tab] = comp2;
  872. }
  873. void constructID(CTabFolder tabf) { mixin(S_TRACE);
  874. auto comp = new Composite(tabf, SWT.NONE);
  875. comp.setLayout(new GridLayout(1, true));
  876. auto comp2 = new Composite(comp, SWT.NONE);
  877. comp2.setLayout(zeroGridLayout(1, true));
  878. { mixin(S_TRACE);
  879. auto grp = new Group(comp2, SWT.NONE);
  880. grp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  881. grp.setText(_prop.msgs.replID);
  882. grp.setLayout(new GridLayout(3, false));
  883. { mixin(S_TRACE);
  884. auto l = new Label(grp, SWT.NONE);
  885. l.setText(_prop.msgs.replIDKind);
  886. _idKind = new Combo(grp, SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY);
  887. _idKind.setVisibleItemCount(_prop.var.etc.comboVisibleItemCount);
  888. _idKind.add(_prop.msgs.replIDArea);
  889. _idKind.add(_prop.msgs.replIDBattle);
  890. _idKind.add(_prop.msgs.replIDPackage);
  891. _idKind.add(_prop.msgs.replIDCast);
  892. _idKind.add(_prop.msgs.replIDSkill);
  893. _idKind.add(_prop.msgs.replIDItem);
  894. _idKind.add(_prop.msgs.replIDBeast);
  895. _idKind.add(_prop.msgs.replIDInfo);
  896. _idKind.add(_prop.msgs.replIDFlag);
  897. _idKind.add(_prop.msgs.replIDStep);
  898. _idKind.add(_prop.msgs.replIDCoupon);
  899. _idKind.add(_prop.msgs.replIDGossip);
  900. _idKind.add(_prop.msgs.replIDCompleteStamp);
  901. _idKind.add(_prop.msgs.replIDKeyCode);
  902. // FIXME: CardWirth 1.60 ????
  903. /+ _idKind.add(_prop.msgs.replIDCellName);
  904. +/ _idKind.select(0);
  905. if (0 <= _prop.var.etc.searchIDKind && _prop.var.etc.searchIDKind < _idKind.getItemCount()) { mixin(S_TRACE);
  906. _idKind.select(_prop.var.etc.searchIDKind);
  907. }
  908. auto gd = new GridData;
  909. gd.horizontalSpan = 2;
  910. _idKind.setLayoutData(gd);
  911. _idKind.addSelectionListener(new SelIDKind);
  912. }
  913. { mixin(S_TRACE);
  914. auto sep = new Label(grp, SWT.SEPARATOR | SWT.HORIZONTAL);
  915. auto gd = new GridData(GridData.FILL_HORIZONTAL);
  916. gd.horizontalSpan = 3;
  917. sep.setLayoutData(gd);
  918. }
  919. void setupID(string text, ref Composite comboComp, ref Spinner spn) { mixin(S_TRACE);
  920. auto l = new Label(grp, SWT.NONE);
  921. l.setText(text);
  922. comboComp = new Composite(grp, SWT.NONE);
  923. auto cl = new CenterLayout(SWT.HORIZONTAL | SWT.VERTICAL, 0);
  924. cl.fillHorizontal = true;
  925. cl.fillVertical = true;
  926. comboComp.setLayout(cl);
  927. auto gd = new GridData(GridData.FILL_HORIZONTAL);
  928. gd.widthHint = _prop.var.etc.nameWidth;
  929. comboComp.setLayoutData(gd);
  930. spn = new Spinner(grp, SWT.BORDER);
  931. initSpinner(spn);
  932. spn.setMinimum(1);
  933. spn.setMaximum(_prop.looks.idMax);
  934. }
  935. setupID(_prop.msgs.replFrom, _fromIDComp, _fromIDVal);
  936. setupID(_prop.msgs.replTo, _toIDComp, _toIDVal);
  937. updateIDCombo();
  938. }
  939. auto tab = new CTabItem(tabf, SWT.NONE);
  940. tab.setText(_prop.msgs.replForID);
  941. tab.setControl(comp);
  942. _tabID = tab;
  943. auto gd = new GridData(GridData.FILL_BOTH);
  944. gd.heightHint = 0;
  945. comp2.setLayoutData(gd);
  946. _comps[tab] = comp2;
  947. }
  948. void constructPath(CTabFolder tabf) { mixin(S_TRACE);
  949. auto comp = new Composite(tabf, SWT.NONE);
  950. comp.setLayout(new GridLayout(1, true));
  951. auto comp2 = new Composite(comp, SWT.NONE);
  952. comp2.setLayout(zeroGridLayout(1, true));
  953. { mixin(S_TRACE);
  954. auto grp = new Group(comp2, SWT.NONE);
  955. grp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  956. grp.setText(_prop.msgs.replPath);
  957. grp.setLayout(new GridLayout(2, false));
  958. Combo setupPath(string text, ref IncSearch incSearch) { mixin(S_TRACE);
  959. auto l = new Label(grp, SWT.NONE);
  960. l.setText(text);
  961. auto combo = new Combo(grp, SWT.BORDER | SWT.DROP_DOWN);
  962. combo.setVisibleItemCount(_prop.var.etc.comboVisibleItemCount);
  963. auto gd = new GridData(GridData.FILL_HORIZONTAL);
  964. gd.widthHint = _prop.var.etc.nameWidth;
  965. combo.setLayoutData(gd);
  966. auto menu = new Menu(_win, SWT.POP_UP);
  967. combo.setMenu(menu);
  968. createMenuItem(_comm, menu, MenuID.IncSearch, {
  969. .forceFocus(combo, true);
  970. incSearch.startIncSearch();
  971. }, null);
  972. new MenuItem(menu, SWT.SEPARATOR);
  973. createTextMenu!Combo(_comm, _prop, combo, &catchMod);
  974. incSearch = new IncSearch(_comm, combo);
  975. return combo;
  976. }
  977. _fromPath = setupPath(_prop.msgs.replFrom, _fromPathIncSearch);
  978. _fromPathIncSearch.modEvent ~= () => setupPathsImpl(true, false);
  979. _toPath = setupPath(_prop.msgs.replTo, _toPathIncSearch);
  980. _fromPathIncSearch.modEvent ~= () => setupPathsImpl(false, true);
  981. }
  982. auto tab = new CTabItem(tabf, SWT.NONE);
  983. tab.setText(_prop.msgs.replForPath);
  984. tab.setControl(comp);
  985. _tabPath = tab;
  986. auto gd = new GridData(GridData.FILL_BOTH);
  987. gd.heightHint = 0;
  988. comp2.setLayoutData(gd);
  989. _comps[tab] = comp2;
  990. }
  991. void constructContents(CTabFolder tabf) { mixin(S_TRACE);
  992. auto comp = new Composite(tabf, SWT.NONE);
  993. comp.setLayout(new GridLayout(1, true));
  994. auto comp2 = new Composite(comp, SWT.NONE);
  995. comp2.setLayout(zeroGridLayout(1, true));
  996. { mixin(S_TRACE);
  997. auto grp = new Group(comp2, SWT.NONE);
  998. auto gd = new GridData(GridData.FILL_HORIZONTAL);
  999. gd.widthHint = _prop.var.etc.searchResultTableWidth;
  1000. grp.setLayoutData(gd);
  1001. grp.setText(_prop.msgs.searchRange);
  1002. grp.setLayout(zeroGridLayout(1, true));
  1003. auto checked = new LCheck;
  1004. _checked ~= checked;
  1005. auto comp3 = new Composite(grp, SWT.NONE);
  1006. comp3.setLayoutData(new GridData(GridData.FILL_BOTH));
  1007. comp3.setLayout(windowGridLayout(1, true));
  1008. auto bar = new ToolBar(comp3, SWT.HORIZONTAL | SWT.FLAT | SWT.WRAP);
  1009. _comm.put(bar);
  1010. bar.setLayoutData(new GridData(GridData.FILL_BOTH));
  1011. foreach (cGrp, cs; CTYPE_GROUP) { mixin(S_TRACE);
  1012. foreach (cType; cs) { mixin(S_TRACE);
  1013. auto text = _prop.msgs.contentName(cType);
  1014. auto img = _prop.images.content(cType);
  1015. void delegate() func = null;
  1016. auto ti = createToolItem2(_comm, bar, text, img, func, null, SWT.CHECK);
  1017. _contents[cType] = ti;
  1018. checked.buttons ~= ti;
  1019. ti.addSelectionListener(checked);
  1020. }
  1021. if (cGrp < CTypeGroup.max) { mixin(S_TRACE);
  1022. new ToolItem(bar, SWT.SEPARATOR);
  1023. }
  1024. }
  1025. auto sep = new Label(grp, SWT.SEPARATOR | SWT.HORIZONTAL);
  1026. sep.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  1027. auto btns = addButtonLine(grp);
  1028. checked.createAlls(btns, _prop.msgs.allSelect);
  1029. }
  1030. auto tab = new CTabItem(tabf, SWT.NONE);
  1031. tab.setText(_prop.msgs.replContents);
  1032. tab.setControl(comp);
  1033. _tabContents = tab;
  1034. auto gd = new GridData(GridData.FILL_BOTH);
  1035. gd.heightHint = 0;
  1036. comp2.setLayoutData(gd);
  1037. _comps[tab] = comp2;
  1038. }
  1039. void constructCoupon(CTabFolder tabf) { mixin(S_TRACE);
  1040. auto comp = new Composite(tabf, SWT.NONE);
  1041. comp.setLayout(new GridLayout(1, true));
  1042. auto comp2 = new Composite(comp, SWT.NONE);
  1043. auto comp2gl = windowGridLayout(1, true);
  1044. comp2gl.marginWidth = 0;
  1045. comp2gl.marginHeight = 0;
  1046. comp2.setLayout(comp2gl);
  1047. { mixin(S_TRACE);
  1048. auto grp = new Group(comp2, SWT.NONE);
  1049. auto gd = new GridData(GridData.FILL_HORIZONTAL);
  1050. gd.widthHint = _prop.var.etc.searchResultTableWidth;
  1051. grp.setLayoutData(gd);
  1052. grp.setText(_prop.msgs.searchRange);
  1053. grp.setLayout(zeroGridLayout(1, true));
  1054. auto checked = new LCheck;
  1055. _checked ~= checked;
  1056. { mixin(S_TRACE);
  1057. auto btns = addButtonLine(grp);
  1058. Button createB(string text, char accr) { mixin(S_TRACE);
  1059. auto b = new Button(btns, SWT.CHECK);
  1060. b.setText(text ~ "(&" ~ accr ~ ")");
  1061. checked.buttons ~= b;
  1062. b.addSelectionListener(checked);
  1063. return b;
  1064. }
  1065. _cCoupon = createB(_prop.msgs.replTextCoupon, '1');
  1066. _cGossip = createB(_prop.msgs.replTextGossip, '2');
  1067. _cEnd = createB(_prop.msgs.replTextEndScenario, '3');
  1068. _cKeyCode = createB(_prop.msgs.replTextKeyCode, '4');
  1069. // FIXME: CardWirth 1.60 ????
  1070. /+ _cCellName = createB(_prop.msgs.replTextCellName, '5');
  1071. +/ }
  1072. auto sep = new Label(grp, SWT.SEPARATOR | SWT.HORIZONTAL);
  1073. sep.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  1074. { mixin(S_TRACE);
  1075. auto btns = addButtonLine(grp);
  1076. checked.createAlls(btns, _prop.msgs.allCheck);
  1077. }
  1078. }
  1079. auto tab = new CTabItem(tabf, SWT.NONE);
  1080. tab.setText(_prop.msgs.replForCoupon);
  1081. tab.setControl(comp);
  1082. _tabCoupon = tab;
  1083. auto gd = new GridData(GridData.FILL_BOTH);
  1084. comp2.setLayoutData(gd);
  1085. _comps[tab] = comp2;
  1086. }
  1087. void constructUnuse(CTabFolder tabf) { mixin(S_TRACE);
  1088. auto comp = new Composite(tabf, SWT.NONE);
  1089. comp.setLayout(new GridLayout(1, true));
  1090. auto comp2 = new Composite(comp, SWT.NONE);
  1091. comp2.setLayout(zeroGridLayout(1, true));
  1092. { mixin(S_TRACE);
  1093. auto grp = new Group(comp2, SWT.NONE);
  1094. grp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  1095. grp.setText(_prop.msgs.replUnuseTarget);
  1096. grp.setLayout(zeroGridLayout(1, true));
  1097. auto checked = new LCheck;
  1098. _checked ~= checked;
  1099. { mixin(S_TRACE);
  1100. auto btns = addButtonLine(grp);
  1101. Button createB(string text, char accr) { mixin(S_TRACE);
  1102. auto b = new Button(btns, SWT.CHECK);
  1103. b.setText(text ~ "(&" ~ accr ~ ")");
  1104. checked.buttons ~= b;
  1105. b.addSelectionListener(checked);
  1106. return b;
  1107. }
  1108. _unuseFlag = createB(_prop.msgs.replUnuseFlag, '1');
  1109. _unuseStep = createB(_prop.msgs.replUnuseStep, '2');
  1110. _unuseArea = createB(_prop.msgs.replUnuseArea, '3');
  1111. _unuseBattle = createB(_prop.msgs.replUnuseBattle, '4');
  1112. _unusePackage = createB(_prop.msgs.replUnusePackage, '5');
  1113. _unuseCast = createB(_prop.msgs.replUnuseCast, '6');
  1114. _unuseSkill = createB(_prop.msgs.replUnuseSkill, '7');
  1115. _unuseItem = createB(_prop.msgs.replUnuseItem, '8');
  1116. _unuseBeast = createB(_prop.msgs.replUnuseBeast, '9');
  1117. _unuseInfo = createB(_prop.msgs.replUnuseInfo, 'A');
  1118. _unuseStart = createB(_prop.msgs.replUnuseStart, 'B');
  1119. _unusePath = createB(_prop.msgs.replUnusePath, 'C');
  1120. }
  1121. auto sep = new Label(grp, SWT.SEPARATOR | SWT.HORIZONTAL);
  1122. sep.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  1123. { mixin(S_TRACE);
  1124. auto btns = addButtonLine(grp);
  1125. checked.createAlls(btns, _prop.msgs.allCheck);
  1126. }
  1127. }
  1128. auto tab = new CTabItem(tabf, SWT.NONE);
  1129. tab.setText(_prop.msgs.replForUnuse);
  1130. tab.setControl(comp);
  1131. _tabUnuse = tab;
  1132. auto gd = new GridData(GridData.FILL_BOTH);
  1133. gd.heightHint = 0;
  1134. comp2.setLayoutData(gd);
  1135. _comps[tab] = comp2;
  1136. }
  1137. void constructError(CTabFolder tabf) { mixin(S_TRACE);
  1138. auto comp = new Composite(tabf, SWT.NONE);
  1139. comp.setLayout(new GridLayout(1, true));
  1140. auto comp2 = new Composite(comp, SWT.NONE);
  1141. comp2.setLayout(zeroGridLayout(1, true));
  1142. { mixin(S_TRACE);
  1143. auto l = new Label(comp2, SWT.WRAP);
  1144. l.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  1145. l.setText(_prop.msgs.replError);
  1146. }
  1147. auto tab = new CTabItem(tabf, SWT.NONE);
  1148. tab.setText(_prop.msgs.replForError);
  1149. tab.setControl(comp);
  1150. _tabError = tab;
  1151. auto gd = new GridData(GridData.FILL_BOTH);
  1152. gd.heightHint = 0;
  1153. comp2.setLayoutData(gd);
  1154. _comps[tab] = comp2;
  1155. }
  1156. void constructGrep(CTabFolder tabf) { mixin(S_TRACE);
  1157. auto comp = new Composite(tabf, SWT.NONE);
  1158. comp.setLayout(new GridLayout(1, true));
  1159. auto comp2 = new Composite(comp, SWT.NONE);
  1160. auto comp2gl = windowGridLayout(1, true);
  1161. comp2gl.marginWidth = 0;
  1162. comp2gl.marginHeight = 0;
  1163. comp2.setLayout(comp2gl);
  1164. { mixin(S_TRACE);
  1165. auto grp = new Group(comp2, SWT.NONE);
  1166. grp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  1167. grp.setText(_prop.msgs.grepText);
  1168. grp.setLayout(new GridLayout(2, false));
  1169. auto fl = new Label(grp, SWT.NONE);
  1170. fl.setText(_prop.msgs.grepFrom);
  1171. _grepFromComp = new Composite(grp, SWT.NONE);
  1172. _grepFromComp.setLayout(new FillLayout);
  1173. auto gd = new GridData(GridData.FILL_HORIZONTAL);
  1174. gd.widthHint = _prop.var.etc.nameWidth;
  1175. _grepFromComp.setLayoutData(gd);
  1176. }
  1177. { mixin(S_TRACE);
  1178. auto grp = new Group(comp2, SWT.NONE);
  1179. grp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  1180. grp.setText(_prop.msgs.grepTarget);
  1181. grp.setLayout(new GridLayout(4, false));
  1182. _grepDir = new Combo(grp, SWT.BORDER | SWT.DROP_DOWN);
  1183. _grepDir.setVisibleItemCount(_prop.var.etc.comboVisibleItemCount);
  1184. createTextMenu!Combo(_comm, _prop, _grepDir, &catchMod);
  1185. _grepDir.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  1186. auto grepDirRef = new Button(grp, SWT.PUSH);
  1187. grepDirRef.setText(_prop.msgs.reference);
  1188. .listener(grepDirRef, SWT.Selection, { mixin(S_TRACE);
  1189. selectDir(_prop, _grepDir, _prop.msgs.grepDir, _prop.msgs.grepDirDesc, _grepDir.getText());
  1190. });
  1191. createOpenButton(_comm, grp, {return _prop.toAppAbs(_grepDir.getText());}, true);
  1192. auto grepCurrent = new Button(grp, SWT.PUSH);
  1193. grepCurrent.setText(_prop.msgs.grepCurrent);
  1194. .listener(grepCurrent, SWT.Selection, &setGrepCurrentDir);
  1195. _grepSubDir = new Button(grp, SWT.CHECK);
  1196. auto gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
  1197. gd.horizontalSpan = 4;
  1198. _grepSubDir.setLayoutData(gd);
  1199. _grepSubDir.setText(_prop.msgs.grepSubDir);
  1200. .listener(_grepDir, SWT.Modify, { mixin(S_TRACE);
  1201. if (ignoreMod) return;
  1202. _prop.var.etc.grepDir = _grepDir.getText();
  1203. });
  1204. .listener(_grepSubDir, SWT.Selection, { mixin(S_TRACE);
  1205. if (ignoreMod) return;
  1206. _prop.var.etc.grepSubDir = _grepSubDir.getSelection();
  1207. });
  1208. }
  1209. auto tab = new CTabItem(tabf, SWT.NONE);
  1210. tab.setText(_prop.msgs.replGrep);
  1211. tab.setControl(comp);
  1212. _tabGrep = tab;
  1213. auto gd = new GridData(GridData.FILL_BOTH);
  1214. comp2.setLayoutData(gd);
  1215. _comps[tab] = comp2;
  1216. }
  1217. void setGrepCurrentDir() { mixin(S_TRACE);
  1218. if (_summ) { mixin(S_TRACE);
  1219. auto sc = _summ.scenarioPath.dirName();
  1220. if (_summ.useTemp) sc = _summ.zipName.dirName();
  1221. _grepDir.setText(sc);
  1222. }
  1223. }
  1224. void refFunc(bool Del, A : CWXPath)(A a) { mixin(S_TRACE);
  1225. bool recurse(TreeItem itm) { mixin(S_TRACE);
  1226. if (a is itm.getData()) { mixin(S_TRACE);
  1227. static if (Del) {
  1228. itm.dispose();
  1229. } else { mixin(S_TRACE);
  1230. itm.setText(a.name);
  1231. }
  1232. return true;
  1233. } else { mixin(S_TRACE);
  1234. foreach (child; itm.getItems()) { mixin(S_TRACE);
  1235. if (recurse(child)) { mixin(S_TRACE);
  1236. return true;
  1237. }
  1238. }
  1239. return false;
  1240. }
  1241. }
  1242. foreach (child; _range.getItems()) { mixin(S_TRACE);
  1243. if (recurse(child)) { mixin(S_TRACE);
  1244. return;
  1245. }
  1246. }
  1247. static if (!Del) {
  1248. // ??
  1249. refreshRangeTree();
  1250. }
  1251. }
  1252. void delArea(Area a) { mixin(S_TRACE);
  1253. refFunc!true(a);
  1254. }
  1255. void delBattle(Battle a) { mixin(S_TRACE);
  1256. refFunc!true(a);
  1257. }
  1258. void delPackage(Package a) { mixin(S_TRACE);
  1259. refFunc!true(a);
  1260. }
  1261. void delCast(CastCard a) { mixin(S_TRACE);
  1262. refFunc!true(a);
  1263. }
  1264. void delSkill(SkillCard a) { mixin(S_TRACE);
  1265. refFunc!true(a);
  1266. }
  1267. void delItem(ItemCard a) { mixin(S_TRACE);
  1268. refFunc!true(a);
  1269. }
  1270. void delBeast(BeastCard a) { mixin(S_TRACE);
  1271. refFunc!true(a);
  1272. }
  1273. void delInfo(InfoCard a) { mixin(S_TRACE);
  1274. refFunc!true(a);
  1275. }
  1276. void refArea(Area a) { mixin(S_TRACE);
  1277. if (_prop.var.etc.showAreaDirTree) {
  1278. refreshRangeTree();
  1279. } else {
  1280. refFunc!false(a);
  1281. }
  1282. }
  1283. void refBattle(Battle a) { mixin(S_TRACE);
  1284. if (_prop.var.etc.showAreaDirTree) {
  1285. refreshRangeTree();
  1286. } else {
  1287. refFunc!false(a);
  1288. }
  1289. }
  1290. void refPackage(Package a) { mixin(S_TRACE);
  1291. if (_prop.var.etc.showAreaDirTree) {
  1292. refreshRangeTree();
  1293. } else {
  1294. refFunc!false(a);
  1295. }
  1296. }
  1297. void refCast(CastCard a) { mixin(S_TRACE);
  1298. refFunc!false(a);
  1299. }
  1300. void refSkill(SkillCard a) { mixin(S_TRACE);
  1301. refFunc!false(a);
  1302. }
  1303. void refItem(ItemCard a) { mixin(S_TRACE);
  1304. refFunc!false(a);
  1305. }
  1306. void refBeast(BeastCard a) { mixin(S_TRACE);
  1307. refFunc!false(a);
  1308. }
  1309. void refInfo(InfoCard a) { mixin(S_TRACE);
  1310. refFunc!false(a);
  1311. }
  1312. static CWXPath[] rangeTree(Summary summ) { mixin(S_TRACE);
  1313. CWXPath[] r;
  1314. r ~= summ;
  1315. r ~= summ.flagDirRoot;
  1316. foreach (a; summ.areas) r ~= a;
  1317. foreach (a; summ.battles) r ~= a;
  1318. foreach (a; summ.packages) r ~= a;
  1319. foreach (a; summ.casts) { mixin(S_TRACE);
  1320. r ~= a;
  1321. foreach (c; a.skills) { mixin(S_TRACE);
  1322. if (0 != c.linkId) continue;
  1323. r ~= c;
  1324. }
  1325. foreach (c; a.items) { mixin(S_TRACE);
  1326. if (0 != c.linkId) continue;
  1327. r ~= c;
  1328. }
  1329. foreach (c; a.beasts) { mixin(S_TRACE);
  1330. if (0 != c.linkId) continue;
  1331. r ~= c;
  1332. }
  1333. }
  1334. foreach (a; summ.skills) r ~= a;
  1335. foreach (a; summ.items) r ~= a;
  1336. foreach (a; summ.beasts) r ~= a;
  1337. foreach (a; summ.infos) r ~= a;
  1338. return r;
  1339. }
  1340. void refreshRangeTree() { mixin(S_TRACE);
  1341. _range.setRedraw(false);
  1342. scope (exit) _range.setRedraw(true);
  1343. if (!_summ) { mixin(S_TRACE);
  1344. _range.removeAll();
  1345. return;
  1346. }
  1347. CWXPath sel = null;
  1348. auto selItm = _range.getSelection();
  1349. if (selItm.length) { mixin(S_TRACE);
  1350. sel = cast(CWXPath)selItm[0].getData();
  1351. }
  1352. _range.removeAll();
  1353. TreeItem add(TreeItem par, string name, CWXPath path) { mixin(S_TRACE);
  1354. TreeItem itm;
  1355. if (par) { mixin(S_TRACE);
  1356. itm = new TreeItem(par, SWT.NONE);
  1357. } else { mixin(S_TRACE);
  1358. itm = new TreeItem(_range, SWT.NONE);
  1359. }
  1360. string text1, text2;
  1361. Image img1, img2;
  1362. getPathParams(path, text1, text2, img1, img2, false);
  1363. itm.setText(name);
  1364. itm.setImage(img1);
  1365. itm.setData(cast(Object) path);
  1366. itm.setChecked(true);
  1367. if (sel is path) { mixin(S_TRACE);
  1368. _range.setSelection([itm]);
  1369. }
  1370. return itm;
  1371. }
  1372. add(null, _prop.msgs.summary, _summ);
  1373. add(null, _prop.msgs.flagsAndSteps, _summ.flagDirRoot);
  1374. if (_prop.var.etc.showAreaDirTree) { mixin(S_TRACE);
  1375. TreeItem[string] itmTable;
  1376. auto dirSet = new HashSet!string;
  1377. auto dirSet2 = new HashSet!string;
  1378. void put1(string dirName) { mixin(S_TRACE);
  1379. auto l = dirName.toLower();
  1380. if (dirSet2.contains(l)) return;
  1381. dirSet.add(dirName);
  1382. dirSet2.add(l);
  1383. }
  1384. foreach (a; _summ.areas) put1(a.dirName);
  1385. foreach (a; _summ.battles) put1(a.dirName);
  1386. foreach (a; _summ.packages) put1(a.dirName);
  1387. bool delegate(string, string) cmps;
  1388. if (_prop.var.etc.logicalSort) {
  1389. cmps = (a, b) => incmp(a, b) < 0;
  1390. } else {
  1391. cmps = (a, b) => icmp(a, b) < 0;
  1392. }
  1393. foreach (dirName; .sortDlg(dirSet.toArray(), cmps)) { mixin (S_TRACE);
  1394. auto dirs = .split(dirName, "\\");
  1395. TreeItem itm = null;
  1396. foreach (i, dir; dirs) { mixin (S_TRACE);
  1397. auto fPath = dirs[0 .. i + 1].join("\\");
  1398. auto path = fPath.toLower();
  1399. auto p = path in itmTable;
  1400. if (p) { mixin (S_TRACE);
  1401. itm = *p;
  1402. } else { mixin (S_TRACE);
  1403. TreeItem sub;
  1404. if (itm) { mixin (S_TRACE);
  1405. sub = new TreeItem(itm, SWT.NONE);
  1406. } else { mixin (S_TRACE);
  1407. sub = new TreeItem(_range, SWT.NONE);
  1408. }
  1409. sub.setText(dir);
  1410. sub.setImage(_prop.images.areaDir);
  1411. sub.setChecked(true);
  1412. itm = sub;
  1413. itmTable[path] = sub;
  1414. }
  1415. }
  1416. itmTable[dirName.toLower()] = itm;
  1417. }
  1418. void put(A)(A[] arr) { mixin (S_TRACE);
  1419. foreach (a; arr) { mixin (S_TRACE);
  1420. add(itmTable[a.dirName.toLower()], .tryFormat("%s.%s", a.id, a.baseName), a);
  1421. }
  1422. }
  1423. put(_summ.areas);
  1424. put(_summ.battles);
  1425. put(_summ.packages);
  1426. } else { mixin(S_TRACE);
  1427. foreach (a; _summ.areas) add(null, a.name, a);
  1428. foreach (a; _summ.battles) add(null, a.name, a);
  1429. foreach (a; _summ.packages) add(null, a.name, a);
  1430. }
  1431. foreach (a; _summ.casts) { mixin(S_TRACE);
  1432. auto par = add(null, .tryFormat("%s.%s", a.id, a.name), a);
  1433. foreach (c; a.skills) { mixin(S_TRACE);
  1434. if (0 != c.linkId) continue;
  1435. add(par, .tryFormat("%s.%s", c.id, c.name), c);
  1436. }
  1437. foreach (c; a.items) { mixin(S_TRACE);
  1438. if (0 != c.linkId) continue;
  1439. add(par, .tryFormat("%s.%s", c.id, c.name), c);
  1440. }
  1441. foreach (c; a.beasts) { mixin(S_TRACE);
  1442. if (0 != c.linkId) continue;
  1443. add(par, .tryFormat("%s.%s", c.id, c.name), c);
  1444. }
  1445. }
  1446. foreach (a; _summ.skills) { mixin(S_TRACE);
  1447. add(null, .tryFormat("%s.%s", a.id, a.name), a);
  1448. }
  1449. foreach (a; _summ.items) { mixin(S_TRACE);
  1450. add(null, .tryFormat("%s.%s", a.id, a.name), a);
  1451. }
  1452. foreach (a; _summ.beasts) { mixin(S_TRACE);
  1453. add(null, .tryFormat("%s.%s", a.id, a.name), a);
  1454. }
  1455. foreach (a; _summ.infos) { mixin(S_TRACE);
  1456. add(null, .tryFormat("%s.%s", a.id, a.name), a);
  1457. }
  1458. _range.treeExpandedAll();
  1459. _range.showSelection();
  1460. _comm.refreshToolBar();
  1461. }
  1462. void refreshRangeAllCheck() { mixin(S_TRACE);
  1463. bool recurse(TreeItem itm) { mixin(S_TRACE);
  1464. if (!itm.getChecked()) { mixin(S_TRACE);
  1465. return true;
  1466. } else { mixin(S_TRACE);
  1467. foreach (child; itm.getItems()) { mixin(S_TRACE);
  1468. if (recurse(child)) { mixin(S_TRACE);
  1469. return true;
  1470. }
  1471. }
  1472. return false;
  1473. }
  1474. }
  1475. foreach (child; _range.getItems()) { mixin(S_TRACE);
  1476. if (recurse(child)) { mixin(S_TRACE);
  1477. _rangeAllCheck.setSelection(false);
  1478. return;
  1479. }
  1480. }
  1481. _rangeAllCheck.setSelection(true);
  1482. }
  1483. class RefRangeAllCheck : SelectionAdapter {
  1484. override void widgetSelected(SelectionEvent e) { mixin(S_TRACE);
  1485. if (SWT.CHECK != e.detail) return;
  1486. auto par = (cast(TreeItem)e.item);
  1487. // ????????????????
  1488. // ??????????????????
  1489. if (par && !par.getData()) { mixin(S_TRACE);
  1490. void recurse(TreeItem itm) { mixin(S_TRACE);
  1491. itm.setChecked(par.getChecked());
  1492. foreach (child; itm.getItems()) recurse(child);
  1493. }
  1494. foreach (itm; par.getItems()) { mixin(S_TRACE);
  1495. recurse(itm);
  1496. }
  1497. }
  1498. // ??????????????????
  1499. // ?????????????????????????
  1500. while (par && par.getParentItem() && !par.getParentItem().getData()) { mixin(S_TRACE);
  1501. bool same = true;
  1502. void recurse2(TreeItem itm) { mixin(S_TRACE);
  1503. if (itm.getChecked() != par.getChecked()) { mixin(S_TRACE);
  1504. same = false;
  1505. return;
  1506. }
  1507. foreach (child; itm.getItems()) recurse2(child);
  1508. }
  1509. foreach (itm; par.getParentItem().getItems()) { mixin(S_TRACE);
  1510. recurse2(itm);
  1511. }
  1512. if (!same) break;
  1513. par.getParentItem().setChecked(par.getChecked());
  1514. pa

Large files files are truncated, but you can click here to view the full file