PageRenderTime 140ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

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

https://bitbucket.org/k4nagatsuki/cwxeditor
D | 2797 lines | 2594 code | 177 blank | 26 comment | 441 complexity | cce9a03b07879c46e6d5cc7a8d6cacfb MD5 | raw file
Possible License(s): LGPL-2.1
  1. module cwx.editor.gui.dwt.eventdialog;
  2. import cwx.summary;
  3. import cwx.area;
  4. import cwx.background;
  5. import cwx.card;
  6. import cwx.utils;
  7. import cwx.event;
  8. import cwx.types;
  9. import cwx.flag;
  10. import cwx.features;
  11. import cwx.usecounter;
  12. import cwx.skin;
  13. import cwx.path;
  14. import cwx.structs;
  15. import cwx.menu;
  16. import cwx.types;
  17. import cwx.editor.gui.sound;
  18. import cwx.editor.gui.dwt.areaview;
  19. import cwx.editor.gui.dwt.areaviewutils;
  20. import cwx.editor.gui.dwt.dskin;
  21. import cwx.editor.gui.dwt.dutils;
  22. import cwx.editor.gui.dwt.dprops;
  23. import cwx.editor.gui.dwt.commons;
  24. import cwx.editor.gui.dwt.centerlayout;
  25. import cwx.editor.gui.dwt.customtable;
  26. import cwx.editor.gui.dwt.materialselect;
  27. import cwx.editor.gui.dwt.motionview;
  28. import cwx.editor.gui.dwt.undo;
  29. import cwx.editor.gui.dwt.absdialog;
  30. import cwx.editor.gui.dwt.splitpane;
  31. import cwx.editor.gui.dwt.dmenu;
  32. import cwx.editor.gui.dwt.incsearch;
  33. import cwx.editor.gui.dwt.chooser;
  34. import std.algorithm : countUntil;
  35. import std.conv;
  36. import std.math;
  37. import std.path;
  38. import std.traits;
  39. import org.eclipse.swt.all;
  40. immutable transitionSpeedDef = Content.transitionSpeed_min + ((Content.transitionSpeed_max - Content.transitionSpeed_min) / 2);
  41. abstract class EventDialog : AbsDialog {
  42. private Commons _comm;
  43. private Props _prop;
  44. private Summary _summ;
  45. private Content _parent;
  46. private Content _evt;
  47. private CType _type;
  48. private class Dispose : DisposeListener {
  49. override void widgetDisposed(DisposeEvent e) { mixin(S_TRACE);
  50. _comm.delContent.remove(&delContent);
  51. _comm.refSkin.remove(&refSkin);
  52. _comm.refTargetVersion.remove(&refreshWarning);
  53. }
  54. }
  55. private void delContent(Content c) { mixin(S_TRACE);
  56. if ((_evt && _evt.isDescendant(c)) || (_parent && _parent.isDescendant(c))) { mixin(S_TRACE);
  57. forceCancel();
  58. }
  59. }
  60. protected void refreshWarning() { mixin(S_TRACE);
  61. // ????
  62. }
  63. this (Commons comm, Props prop, Shell shell, Summary summ, CType type, Content parent, Content evt, bool resizable, DSize size, bool eClose, bool rightGroup = false) in { mixin(S_TRACE);
  64. assert (!evt || evt.type is type);
  65. assert (summ);
  66. } body { mixin(S_TRACE);
  67. super (prop, shell, false, .tryFormat(prop.msgs.dlgTitContent, prop.msgs.contentName(type)), prop.images.content(type), resizable, size, true, true, [], rightGroup);
  68. enterClose = eClose;
  69. _comm = comm;
  70. _prop = prop;
  71. _summ = summ;
  72. _type = type;
  73. _parent = parent;
  74. _evt = evt;
  75. _comm.delContent.add(&delContent);
  76. _comm.refSkin.add(&refSkin);
  77. _comm.refTargetVersion.add(&refreshWarning);
  78. getShell().addDisposeListener(new Dispose);
  79. }
  80. @property
  81. Content event() { mixin(S_TRACE);
  82. return _evt;
  83. }
  84. @property protected Commons comm() {return _comm;}
  85. @property protected Props prop() {return _prop;}
  86. @property protected Summary summ() {return _summ;}
  87. @property protected Content evt() {return _evt;}
  88. @property protected void evt(Content evt) {_evt = evt;}
  89. @property protected CType type() {return _type;}
  90. protected void refSkin() {}
  91. bool openCWXPath(string path, bool shellActivate) { mixin(S_TRACE);
  92. return cpempty(path);
  93. }
  94. }
  95. class ContentCommentDialog : AbsDialog {
  96. private Commons _comm;
  97. private Props _prop;
  98. private Content _parent;
  99. private Content _evt;
  100. private Text _comment;
  101. private class Dispose : DisposeListener {
  102. override void widgetDisposed(DisposeEvent e) { mixin(S_TRACE);
  103. _comm.delContent.remove(&delContent);
  104. }
  105. }
  106. private void delContent(Content c) { mixin(S_TRACE);
  107. if ((_evt && _evt.isDescendant(c)) || (_parent && _parent.isDescendant(c))) { mixin(S_TRACE);
  108. forceCancel();
  109. }
  110. }
  111. this (Commons comm, Props prop, Shell shell, Content parent, Content evt) in { mixin(S_TRACE);
  112. assert (evt);
  113. } body { mixin(S_TRACE);
  114. super (prop, shell, false, prop.msgs.dlgTitComment, prop.images.menu(MenuID.Comment), true, prop.var.commentDlg, true);
  115. _comm = comm;
  116. _prop = prop;
  117. _parent = parent;
  118. _evt = evt;
  119. _comm.delContent.add(&delContent);
  120. getShell().addDisposeListener(new Dispose);
  121. }
  122. override void setup(Composite area) { mixin(S_TRACE);
  123. auto cl = new CenterLayout;
  124. cl.fillHorizontal = true;
  125. cl.fillVertical = true;
  126. area.setLayout(cl);
  127. _comment = new Text(area, SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
  128. mod(_comment);
  129. _comment.setText(_evt.comment);
  130. createTextMenu!Text(_comm, _prop, _comment, &catchMod);
  131. auto font = _comment.getFont();
  132. auto fSize = font ? cast(uint) font.getFontData()[0].height : 0;
  133. _comment.setFont(new Font(Display.getCurrent(), dwtData(_prop.looks.textDlgFont(fSize))));
  134. _comment.setSelection(to!dstring(_comment.getText()).length);
  135. closeEvent ~= () { mixin(S_TRACE);
  136. _comment.getFont().dispose();
  137. };
  138. }
  139. override bool apply() { mixin(S_TRACE);
  140. _evt.comment = lastRet(wrapReturnCode(_comment.getText()));
  141. return true;
  142. }
  143. }
  144. /// ?????????????????????????????????
  145. class AreaSelectDialog(CType Type, A, string Areas) : EventDialog {
  146. private:
  147. AreaChooser!(A, false) _list;
  148. static if (Type == CType.CHANGE_AREA) {
  149. Combo _ts;
  150. Spinner _tsSpeed;
  151. Transition[int] _tsTbl;
  152. }
  153. void delA(A a) { mixin(S_TRACE);
  154. auto summary = _summ;
  155. auto areas = mixin (Areas);
  156. if (!areas.length) { mixin(S_TRACE);
  157. forceCancel();
  158. }
  159. }
  160. class Dispose : DisposeListener {
  161. override void widgetDisposed(DisposeEvent e) { mixin(S_TRACE);
  162. static if (is(A : Area)) {
  163. _comm.delArea.remove(&delA);
  164. } else static if (is(A : Battle)) {
  165. _comm.delBattle.remove(&delA);
  166. } else static if (is(A : Package)) {
  167. _comm.delPackage.remove(&delA);
  168. } else static if (is(A : CastCard)) {
  169. _comm.delCast.remove(&delA);
  170. } else static if (is(A : InfoCard)) {
  171. _comm.delInfo.remove(&delA);
  172. } else static assert (0);
  173. }
  174. }
  175. protected override void refSkin() { mixin(S_TRACE);
  176. refreshTS();
  177. }
  178. void refreshTS() { mixin(S_TRACE);
  179. static if (Type == CType.CHANGE_AREA) {
  180. _ts.setEnabled(!_summ.legacy);
  181. _tsSpeed.setEnabled(!_summ.legacy);
  182. }
  183. }
  184. public:
  185. this (Commons comm, Props prop, Shell shell, Summary summ, Content parent, Content evt) { mixin(S_TRACE);
  186. super (comm, prop, shell, summ, Type, parent, evt, true, prop.var.selEvtDlg, true);
  187. }
  188. protected:
  189. override void setup(Composite area) { mixin(S_TRACE);
  190. area.setLayout(zeroGridLayout(1, false));
  191. { mixin(S_TRACE);
  192. auto listComp = new Composite(area, SWT.NONE);
  193. listComp.setLayout(new GridLayout(1, true));
  194. listComp.setLayoutData(new GridData(GridData.FILL_BOTH));
  195. _list = new AreaChooser!(A, false)(comm, summ, listComp);
  196. mod(_list);
  197. auto gd = new GridData(GridData.FILL_BOTH);
  198. gd.widthHint = _prop.var.etc.nameTableWidth;
  199. gd.heightHint = _prop.var.etc.nameTableHeight;
  200. _list.setLayoutData(gd);
  201. }
  202. static if (Type == CType.CHANGE_AREA) {
  203. { mixin(S_TRACE);
  204. auto sep = new Label(area, SWT.SEPARATOR | SWT.HORIZONTAL);
  205. sep.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  206. }
  207. { mixin(S_TRACE);
  208. auto comp = new Composite(area, SWT.NONE);
  209. comp.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
  210. comp.setLayout(new GridLayout(3, false));
  211. auto lt = new Label(comp, SWT.NONE);
  212. lt.setText(_prop.msgs.transition);
  213. _ts = new Combo(comp, SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY);
  214. mod(_ts);
  215. auto tgd = new GridData;
  216. tgd.horizontalSpan = 2;
  217. _ts.setLayoutData(tgd);
  218. _ts.setVisibleItemCount(prop.var.etc.comboVisibleItemCount);
  219. foreach (i, t; ALL_TRANSITION) { mixin(S_TRACE);
  220. _ts.add(_prop.msgs.transitionName(t));
  221. _tsTbl[i] = t;
  222. if (_evt && t == _evt.transition) _ts.select(i);
  223. }
  224. auto ls = new Label(comp, SWT.NONE);
  225. ls.setText(_prop.msgs.transitionSpeed);
  226. _tsSpeed = new Spinner(comp, SWT.BORDER);
  227. initSpinner(_tsSpeed);
  228. mod(_tsSpeed);
  229. _tsSpeed.setMaximum(Content.transitionSpeed_max);
  230. _tsSpeed.setMinimum(Content.transitionSpeed_min);
  231. auto hint = new Label(comp, SWT.NONE);
  232. hint.setText(.tryFormat(_prop.msgs.rangeHint, Content.transitionSpeed_min, Content.transitionSpeed_max));
  233. }
  234. if (_evt) { mixin(S_TRACE);
  235. _tsSpeed.setSelection(_evt.transitionSpeed);
  236. } else { mixin(S_TRACE);
  237. _ts.select(0);
  238. _tsSpeed.setSelection(.transitionSpeedDef);
  239. }
  240. refreshTS();
  241. }
  242. static if (is(A : Area)) {
  243. _comm.delArea.add(&delA);
  244. } else static if (is(A : Battle)) {
  245. _comm.delBattle.add(&delA);
  246. } else static if (is(A : Package)) {
  247. _comm.delPackage.add(&delA);
  248. } else static if (is(A : CastCard)) {
  249. _comm.delCast.add(&delA);
  250. } else static if (is(A : InfoCard)) {
  251. _comm.delInfo.add(&delA);
  252. } else static assert (0);
  253. _list.addDisposeListener(new Dispose);
  254. ignoreMod = true;
  255. scope (exit) ignoreMod = false;
  256. if (_evt) { mixin(S_TRACE);
  257. static if (Type == CType.CHANGE_AREA) {
  258. _list.selected = _evt.area;
  259. } else static if (Type == CType.START_BATTLE) {
  260. _list.selected = _evt.battle;
  261. } else static if (Type == CType.CALL_PACKAGE || Type == CType.LINK_PACKAGE) {
  262. _list.selected = _evt.packages;
  263. } else static if (Type == CType.BRANCH_CAST || Type == CType.GET_CAST || Type == CType.LOSE_CAST) {
  264. _list.selected = _evt.casts;
  265. } else static if (Type == CType.BRANCH_INFO || Type == CType.GET_INFO || Type == CType.LOSE_INFO) {
  266. _list.selected = _evt.info;
  267. } else { mixin(S_TRACE);
  268. static assert (0);
  269. }
  270. }
  271. }
  272. override bool apply() { mixin(S_TRACE);
  273. assert (_list.selected != 0UL);
  274. auto id = _list.selected;
  275. if (!_evt) { mixin(S_TRACE);
  276. _evt = new Content(Type, "");
  277. }
  278. static if (Type == CType.CHANGE_AREA) {
  279. auto ts = _tsTbl[_ts.getSelectionIndex()];
  280. uint tsSpeed = _tsSpeed.getSelection();
  281. _evt.area = id;
  282. _evt.transition = ts;
  283. _evt.transitionSpeed = tsSpeed;
  284. } else static if (Type == CType.START_BATTLE) {
  285. _evt.battle = id;
  286. } else static if (Type == CType.CALL_PACKAGE || Type == CType.LINK_PACKAGE) {
  287. _evt.packages = id;
  288. } else static if (Type == CType.BRANCH_CAST || Type == CType.GET_CAST || Type == CType.LOSE_CAST) {
  289. _evt.casts = id;
  290. } else static if (Type == CType.BRANCH_INFO || Type == CType.GET_INFO || Type == CType.LOSE_INFO) {
  291. _evt.info = id;
  292. } else { mixin(S_TRACE);
  293. static assert (0);
  294. }
  295. return true;
  296. }
  297. }
  298. /// ?????????????????????
  299. class StartSelectDialog(CType Type) : EventDialog {
  300. private:
  301. string _selected = "";
  302. EventTree _et;
  303. Table _list;
  304. IncSearch _incSearch;
  305. void incSearch() { mixin(S_TRACE);
  306. .forceFocus(_list, true);
  307. _incSearch.startIncSearch();
  308. }
  309. void selected() { mixin(S_TRACE);
  310. int index = _list.getSelectionIndex();
  311. if (-1 == index) return;
  312. _selected = (cast(Content) _list.getItem(index).getData()).name;
  313. }
  314. class Dispose : DisposeListener {
  315. override void widgetDisposed(DisposeEvent e) { mixin(S_TRACE);
  316. _comm.refContent.remove(&refContent);
  317. _comm.delContent.remove(&delContent);
  318. }
  319. }
  320. void refContent(Content c) { mixin(S_TRACE);
  321. refreshStarts(null);
  322. }
  323. void delContent(Content c) { mixin(S_TRACE);
  324. refreshStarts(c);
  325. }
  326. void refreshStarts() { mixin(S_TRACE);
  327. refreshStarts(null);
  328. }
  329. void refreshStarts(Content del) { mixin(S_TRACE);
  330. string sel = _selected;
  331. _list.removeAll();
  332. int i = 0;
  333. foreach (s; _et.starts) { mixin(S_TRACE);
  334. if (s is del) continue;
  335. if (!_incSearch.match(s.name)) continue;
  336. auto itm = new TableItem(_list, SWT.NONE);
  337. itm.setData(s);
  338. itm.setImage(0, _prop.images.content(CType.START));
  339. itm.setText(0, s.name);
  340. if (sel == s.name) _list.select(i);
  341. i++;
  342. }
  343. if (del && sel == del.name && _list.getItemCount()) { mixin(S_TRACE);
  344. _list.select(0);
  345. _selected = (cast(Content) _list.getItem(0).getData()).name;
  346. }
  347. _list.showSelection();
  348. }
  349. void openView() { mixin(S_TRACE);
  350. auto i = _list.getSelectionIndex();
  351. if (-1 == i) return;
  352. auto a = cast(Content) _list.getItem(i).getData();
  353. try { mixin(S_TRACE);
  354. _comm.openCWXPath(cpaddattr(a.cwxPath(true), "shallow"), false);
  355. } catch (Exception e) {
  356. debugln(e);
  357. }
  358. }
  359. class OpenView : MouseAdapter {
  360. override void mouseDoubleClick(MouseEvent e) { mixin(S_TRACE);
  361. if (1 != e.button) return;
  362. openView();
  363. }
  364. }
  365. public:
  366. this (Commons comm, Props prop, Shell shell, Summary summ, Content parent, Content evt) { mixin(S_TRACE);
  367. _et = parent.tree;
  368. super (comm, prop, shell, summ, Type, parent, evt, true, prop.var.selEvtDlg, true);
  369. }
  370. protected:
  371. override void setup(Composite area) { mixin(S_TRACE);
  372. area.setLayout(new GridLayout(1, false));
  373. _list = new Table(area, SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL);
  374. mod(_list);
  375. auto nameCol = new FullTableColumn(_list, SWT.NONE);
  376. auto gd = new GridData(GridData.FILL_BOTH);
  377. gd.widthHint = _prop.var.etc.nameTableWidth;
  378. gd.heightHint = _prop.var.etc.nameTableHeight;
  379. _list.setLayoutData(gd);
  380. _list.addMouseListener(new OpenView);
  381. auto menu = new Menu(_list.getShell(), SWT.POP_UP);
  382. createMenuItem(comm, menu, MenuID.IncSearch, &incSearch, null);
  383. new MenuItem(menu, SWT.SEPARATOR);
  384. createMenuItem(comm, menu, MenuID.OpenAtEventView, &openView, () => _list.getSelectionIndex() != -1);
  385. _list.setMenu(menu);
  386. .listener(_list, SWT.Selection, &selected);
  387. _incSearch = new IncSearch(comm, _list);
  388. _incSearch.modEvent ~= &refreshStarts;
  389. refreshStarts();
  390. _comm.refContent.add(&refContent);
  391. _comm.delContent.add(&delContent);
  392. _list.addDisposeListener(new Dispose);
  393. ignoreMod = true;
  394. scope (exit) ignoreMod = false;
  395. if (_evt) { mixin(S_TRACE);
  396. _selected = _evt.start;
  397. foreach (i, itm; _list.getItems()) { mixin(S_TRACE);
  398. if (_selected == (cast(Content) itm.getData()).name) { mixin(S_TRACE);
  399. _list.select(i);
  400. break;
  401. }
  402. }
  403. }
  404. if (-1 == _list.getSelectionIndex()) { mixin(S_TRACE);
  405. _list.select(0);
  406. _selected = (cast(Content) _list.getItem(0).getData()).name;
  407. }
  408. _list.showSelection();
  409. }
  410. override bool apply() { mixin(S_TRACE);
  411. if (!_evt) _evt = new Content(Type, "");
  412. _evt.start = _selected;
  413. return true;
  414. }
  415. }
  416. /// ???????????????????
  417. class ClearEventDialog : EventDialog {
  418. private:
  419. Button _mark;
  420. Button _unmark;
  421. public:
  422. this (Commons comm, Props prop, Shell shell, Summary summ, Content parent, Content evt) { mixin(S_TRACE);
  423. super (comm, prop, shell, summ, CType.END, parent, evt, false, null, enterClose);
  424. }
  425. protected:
  426. override void setup(Composite area) { mixin(S_TRACE);
  427. auto cl = new CenterLayout;
  428. cl.fillHorizontal = true;
  429. area.setLayout(cl);
  430. auto grp = new Group(area, SWT.NONE);
  431. grp.setText(_prop.msgs.afterClear);
  432. grp.setLayout(new CenterLayout(SWT.VERTICAL | SWT.HORIZONTAL, 0));
  433. auto comp = new Composite(grp, SWT.NONE);
  434. comp.setLayout(new GridLayout(1, true));
  435. _mark = new Button(comp, SWT.RADIO);
  436. mod(_mark);
  437. _mark.setText(_prop.msgs.afterClearEndMark);
  438. _unmark = new Button(comp, SWT.RADIO);
  439. mod(_unmark);
  440. _unmark.setText(_prop.msgs.afterClearNoEndMark);
  441. if (_evt) { mixin(S_TRACE);
  442. if (_evt.complete) { mixin(S_TRACE);
  443. _mark.setSelection(true);
  444. } else { mixin(S_TRACE);
  445. _unmark.setSelection(true);
  446. }
  447. } else { mixin(S_TRACE);
  448. _mark.setSelection(true);
  449. }
  450. }
  451. override bool apply() { mixin(S_TRACE);
  452. if (!_evt) { mixin(S_TRACE);
  453. _evt = new Content(CType.END, "");
  454. }
  455. _evt.complete = _mark.getSelection();
  456. return true;
  457. }
  458. }
  459. /// ??????????????????????
  460. class CouponEventDialog(CType Type, bool EditValue, bool Field) : EventDialog {
  461. private:
  462. Button[Range] _range;
  463. Button[CouponType] _type;
  464. Combo _name;
  465. static if (EditValue) {
  466. Spinner _value;
  467. }
  468. override
  469. protected void refreshWarning() { mixin(S_TRACE);
  470. string[] ws;
  471. static if (Type is CType.GET_COUPON || Type is CType.LOSE_COUPON) {
  472. if (prop.sys.isCouponType(_name.getText(), CouponType.System)) { mixin(S_TRACE);
  473. ws ~= .tryFormat(prop.msgs.warningSystemCoupon, prop.sys.couponSystem);
  474. }
  475. }
  476. static if (Field) {
  477. if (_prop.targetVersion("1.30")) { mixin(S_TRACE);
  478. if (_range[Range.FIELD].getSelection()) { mixin(S_TRACE);
  479. ws ~= prop.msgs.warningBranchCouponAtField;
  480. }
  481. }
  482. }
  483. warning = ws;
  484. }
  485. class SelType : SelectionAdapter {
  486. private CouponType _coType;
  487. this (CouponType coType) { mixin(S_TRACE);
  488. _coType = coType;
  489. }
  490. override void widgetSelected(SelectionEvent e) { mixin(S_TRACE);
  491. _name.setText(prop.sys.convCoupon(_name.getText(), _coType, true));
  492. }
  493. }
  494. public:
  495. this (Commons comm, Props prop, Shell shell, Summary summ, Content parent, Content evt) { mixin(S_TRACE);
  496. super (comm, prop, shell, summ, Type, parent, evt, true, prop.var.couponEvtDlg, true);
  497. }
  498. protected:
  499. override void setup(Composite area) { mixin(S_TRACE);
  500. area.setLayout(new GridLayout(2, false));
  501. auto skin = _comm.skin;
  502. auto leftComp = new Composite(area, SWT.NONE);
  503. leftComp.setLayout(zeroMarginGridLayout(1, true));
  504. leftComp.setLayoutData(new GridData(GridData.FILL_VERTICAL));
  505. { mixin(S_TRACE);
  506. auto grp = new Group(leftComp, SWT.NONE);
  507. static if (EditValue) {
  508. grp.setLayoutData(new GridData(GridData.FILL_BOTH));
  509. } else { mixin(S_TRACE);
  510. grp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  511. }
  512. grp.setText(_prop.msgs.range);
  513. grp.setLayout(new GridLayout(1, true));
  514. auto ranges = RANGE_MEMBER.dup;
  515. static if (Field) {
  516. ranges ~= Range.FIELD;
  517. }
  518. foreach (r; ranges) { mixin(S_TRACE);
  519. auto radio = new Button(grp, SWT.RADIO);
  520. mod(radio);
  521. radio.setLayoutData(new GridData(GridData.FILL_BOTH));
  522. radio.setText(_prop.msgs.rangeName(r));
  523. .listener(radio, SWT.Selection, &refreshWarning);
  524. _range[r] = radio;
  525. }
  526. }
  527. { mixin(S_TRACE);
  528. auto grp = new Group(area, SWT.NONE);
  529. grp.setLayoutData(new GridData(GridData.FILL_BOTH));
  530. auto cl = new CenterLayout(SWT.VERTICAL, 0);
  531. cl.fillHorizontal = true;
  532. grp.setLayout(cl);
  533. grp.setText(_prop.msgs.couponName);
  534. { mixin(S_TRACE);
  535. auto comp = new Composite(grp, SWT.NONE);
  536. comp.setLayout(new GridLayout(3, false));
  537. { mixin(S_TRACE);
  538. _name = createCouponCombo(comm, summ, comp, &catchMod, CouponComboType.AllCoupons, _evt ? _evt.coupon : "");
  539. mod(_name);
  540. auto gd = new GridData(GridData.FILL_HORIZONTAL);
  541. gd.horizontalSpan = 3;
  542. gd.widthHint = _prop.var.etc.nameWidth;
  543. _name.setLayoutData(gd);
  544. }
  545. foreach (coType; [CouponType.Normal, CouponType.Hide, CouponType.Dur, CouponType.DurBattle]) { mixin(S_TRACE);
  546. auto b = new Button(comp, SWT.RADIO);
  547. b.setText(_prop.msgs.couponTypeDesc(coType));
  548. auto gd = new GridData(GridData.FILL_HORIZONTAL);
  549. gd.horizontalSpan = 3;
  550. b.setLayoutData(gd);
  551. b.addSelectionListener(new SelType(coType));
  552. _type[coType] = b;
  553. }
  554. .listener(_name, SWT.Modify, { mixin(S_TRACE);
  555. auto t = prop.sys.couponType(_name.getText());
  556. bool checked = false;
  557. foreach (coType; _type.keys) { mixin(S_TRACE);
  558. _type[coType].setSelection(coType == t);
  559. checked |= (coType == t);
  560. }
  561. if (!checked) _type[CouponType.Normal].setSelection(true);
  562. refreshWarning();
  563. });
  564. }
  565. }
  566. static if (EditValue) {
  567. { mixin(S_TRACE);
  568. auto grp = new Group(leftComp, SWT.NONE);
  569. grp.setLayoutData(new GridData(GridData.FILL_BOTH));
  570. grp.setText(_prop.msgs.couponValue);
  571. grp.setLayout(new CenterLayout(SWT.HORIZONTAL | SWT.VERTICAL));
  572. auto comp = new Composite(grp, SWT.NONE);
  573. comp.setLayout(zeroMarginGridLayout(2, false));
  574. _value = new Spinner(comp, SWT.BORDER);
  575. initSpinner(_value);
  576. mod(_value);
  577. _value.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  578. _value.setMaximum(_prop.var.etc.couponValueMax);
  579. _value.setMinimum(-(cast(int) _prop.var.etc.couponValueMax));
  580. auto lr = new Label(comp, SWT.LEFT);
  581. lr.setText(.tryFormat(_prop.msgs.couponValueRange, -(cast(int) prop.var.etc.couponValueMax), prop.var.etc.couponValueMax));
  582. }
  583. }
  584. if (_evt) { mixin(S_TRACE);
  585. _range[_evt.range].setSelection(true);
  586. auto cType = prop.sys.couponType(_evt.coupon);
  587. auto cTypeP = cType in _type;
  588. if (cTypeP) { mixin(S_TRACE);
  589. cTypeP.setSelection(true);
  590. } else { mixin(S_TRACE);
  591. _type[CouponType.Normal].setSelection(true);
  592. }
  593. _name.setText(_evt.coupon);
  594. static if (EditValue) {
  595. _value.setSelection(_evt.couponValue);
  596. }
  597. } else { mixin(S_TRACE);
  598. _range[Range.SELECTED].setSelection(true);
  599. _type[CouponType.Normal].setSelection(true);
  600. static if (EditValue) {
  601. _value.setSelection(0);
  602. }
  603. }
  604. refreshWarning();
  605. }
  606. override bool apply() { mixin(S_TRACE);
  607. if (!_evt) _evt = new Content(Type, "");
  608. foreach (range, radio; _range) { mixin(S_TRACE);
  609. if (radio.getSelection()) { mixin(S_TRACE);
  610. _evt.range = range;
  611. _evt.coupon = _name.getText();
  612. static if (EditValue) {
  613. _evt.couponValue = _value.getSelection();
  614. }
  615. break;
  616. }
  617. }
  618. comm.refCoupons.call();
  619. return true;
  620. }
  621. }
  622. alias CouponEventDialog!(CType.BRANCH_COUPON, false, true) BranchCouponDialog;
  623. alias CouponEventDialog!(CType.GET_COUPON, true, false) GetCouponDialog;
  624. alias CouponEventDialog!(CType.LOSE_COUPON, false, false) LoseCouponDialog;
  625. /// ???????????????????
  626. private class OneTextEventDialog(CType Type, string Name, string Get, string Set, string EngineVersion = "") : EventDialog {
  627. private:
  628. Combo _name;
  629. override
  630. protected void refreshWarning() { mixin(S_TRACE);
  631. string[] ws;
  632. static if (EngineVersion != "") {
  633. if (!_prop.targetVersion(EngineVersion)) { mixin(S_TRACE);
  634. ws ~= .tryFormat(_prop.msgs.warningUnknownContent, _prop.msgs.contentName(Type), EngineVersion);
  635. }
  636. }
  637. warning = ws;
  638. }
  639. public:
  640. this (Commons comm, Props prop, Shell shell, Summary summ, Content parent, Content evt) { mixin(S_TRACE);
  641. super (comm, prop, shell, summ, Type, parent, evt, true, prop.var.inputEvtDlg, true);
  642. }
  643. protected:
  644. override void setup(Composite area) { mixin(S_TRACE);
  645. area.setLayout(new GridLayout(1, false));
  646. { mixin(S_TRACE);
  647. auto grp = new Group(area, SWT.NONE);
  648. grp.setLayoutData(new GridData(GridData.FILL_BOTH));
  649. grp.setText(mixin (Name));
  650. auto cl = new CenterLayout(SWT.HORIZONTAL | SWT.VERTICAL, 0);
  651. cl.fillHorizontal = true;
  652. grp.setLayout(cl);
  653. auto comp = new Composite(grp, SWT.NONE);
  654. comp.setLayout(new GridLayout(1, true));
  655. if (CDetail.fromType(Type).use(CArg.GOSSIP)) { mixin(S_TRACE);
  656. _name = createGossipCombo(comm, summ, comp, &catchMod, _evt ? mixin(Get) : "");
  657. } else if (CDetail.fromType(Type).use(CArg.COMPLETE_STAMP)) { mixin(S_TRACE);
  658. _name = createCompleteStampCombo(comm, summ, comp, &catchMod, _evt ? mixin(Get) : "");
  659. } else if (CDetail.fromType(Type).use(CArg.CELL_NAME)) { mixin(S_TRACE);
  660. _name = createCellNameCombo(comm, summ, comp, &catchMod, _evt ? mixin(Get) : "");
  661. } else assert (0);
  662. mod(_name);
  663. auto gd = new GridData(GridData.FILL_HORIZONTAL);
  664. gd.widthHint = _prop.var.etc.nameWidth;
  665. _name.setLayoutData(gd);
  666. }
  667. if (_evt) { mixin(S_TRACE);
  668. _name.setText(mixin (Get));
  669. }
  670. refreshWarning();
  671. }
  672. override bool apply() { mixin(S_TRACE);
  673. if (!_evt) _evt = new Content(Type, "");
  674. string text = _name.getText();
  675. mixin (Set);
  676. if (CDetail.fromType(Type).use(CArg.GOSSIP)) { mixin(S_TRACE);
  677. comm.refGossips.call();
  678. }
  679. if (CDetail.fromType(Type).use(CArg.COMPLETE_STAMP)) { mixin(S_TRACE);
  680. comm.refCompleteStamps.call();
  681. }
  682. if (CDetail.fromType(Type).use(CArg.CELL_NAME)) { mixin(S_TRACE);
  683. comm.refCellNames.call();
  684. }
  685. return true;
  686. }
  687. }
  688. template GossipEventDialog(CType Type) {
  689. alias OneTextEventDialog!(Type, "_prop.msgs.gossipName",
  690. "_evt.gossip", "_evt.gossip = text;") GossipEventDialog;
  691. }
  692. template EndEventDialog(CType Type) {
  693. alias OneTextEventDialog!(Type, "_prop.msgs.endName",
  694. "_evt.completeStamp", "_evt.completeStamp = text;") EndEventDialog;
  695. }
  696. alias OneTextEventDialog!(CType.LOSE_BG_IMAGE, "_prop.msgs.cellName",
  697. "_evt.cellName", "_evt.cellName = text;", "1.60") LoseBgImageDialog;
  698. /// ???????????????????????
  699. class BgImagesDialog : EventDialog {
  700. private:
  701. AbstractArea _refTarget;
  702. Combo _ts;
  703. Spinner _tsSpeed;
  704. Transition[int] _tsTbl;
  705. BgImageContainer _cont;
  706. BgImagesView _view;
  707. Combo _cellName = null;
  708. override
  709. protected void refreshWarning() { mixin(S_TRACE);
  710. string[] ws;
  711. if (type is CType.REPLACE_BG_IMAGE) {
  712. if (!_prop.targetVersion("1.60")) { mixin(S_TRACE);
  713. ws ~= .tryFormat(_prop.msgs.warningUnknownContent, _prop.msgs.contentName(CType.REPLACE_BG_IMAGE), "1.60");
  714. }
  715. }
  716. warning = ws;
  717. }
  718. protected override void refSkin() { mixin(S_TRACE);
  719. refreshTS();
  720. }
  721. void refreshTS() { mixin(S_TRACE);
  722. _ts.setEnabled(!_summ.legacy);
  723. _tsSpeed.setEnabled(!_summ.legacy);
  724. }
  725. public:
  726. this (Commons comm, Props prop, Shell shell, Summary summ, Content parent, Content evt, AbstractArea refTarget, CType type) { mixin(S_TRACE);
  727. _refTarget = refTarget;
  728. super (comm, prop, shell, summ, type, parent, evt, true, prop.var.bgImagesDlg, false);
  729. BgImage[] bgImages;
  730. if (evt) { mixin(S_TRACE);
  731. foreach (b; evt.backs) { mixin(S_TRACE);
  732. bgImages ~= b.dup;
  733. }
  734. }
  735. _cont = new BgImageContainer(bgImages);
  736. }
  737. override
  738. bool openCWXPath(string path, bool shellActivate) { mixin(S_TRACE);
  739. return _view.openCWXPath(path, shellActivate);
  740. }
  741. protected:
  742. override void setup(Composite area) { mixin(S_TRACE);
  743. area.setLayout(new GridLayout(1, false));
  744. auto skin = _comm.skin;
  745. { mixin(S_TRACE);
  746. _view = createBgImagesViewAndMenu(_comm, _prop, _summ, _cont, area, _refTarget, false);
  747. mod(_view);
  748. _view.setLayoutData(new GridData(GridData.FILL_BOTH));
  749. _view.modEvent ~= &refreshWarning;
  750. }
  751. { mixin(S_TRACE);
  752. auto comp = new Composite(area, SWT.NONE);
  753. comp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  754. if (CDetail.fromType(type).use(CArg.CELL_NAME)) {
  755. comp.setLayout(zeroMarginGridLayout(8, false));
  756. auto l = new Label(comp, SWT.NONE);
  757. l.setText(_prop.msgs.cellName);
  758. _cellName = createCellNameCombo(comm, summ, comp, &catchMod, _evt ? _evt.cellName : "");
  759. mod(_cellName);
  760. _cellName.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  761. auto gd = new GridData(GridData.FILL_VERTICAL);
  762. gd.heightHint = 0;
  763. (new Label(comp, SWT.SEPARATOR | SWT.VERTICAL)).setLayoutData(gd);
  764. } else {
  765. comp.setLayout(zeroMarginGridLayout(5, false));
  766. }
  767. auto lt = new Label(comp, SWT.NONE);
  768. lt.setText(_prop.msgs.transition);
  769. _ts = new Combo(comp, SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY);
  770. mod(_ts);
  771. _ts.setVisibleItemCount(prop.var.etc.comboVisibleItemCount);
  772. foreach (i, t; ALL_TRANSITION) { mixin(S_TRACE);
  773. _ts.add(_prop.msgs.transitionName(t));
  774. _tsTbl[i] = t;
  775. if (_evt && t == _evt.transition) _ts.select(i);
  776. }
  777. auto ls = new Label(comp, SWT.NONE);
  778. ls.setText(_prop.msgs.transitionSpeed);
  779. _tsSpeed = new Spinner(comp, SWT.BORDER);
  780. initSpinner(_tsSpeed);
  781. mod(_tsSpeed);
  782. _tsSpeed.setMaximum(Content.transitionSpeed_max);
  783. _tsSpeed.setMinimum(Content.transitionSpeed_min);
  784. auto hint = new Label(comp, SWT.NONE);
  785. hint.setText(.tryFormat(_prop.msgs.rangeHint, Content.transitionSpeed_min, Content.transitionSpeed_max));
  786. }
  787. refreshTS();
  788. ignoreMod = true;
  789. scope (exit) ignoreMod = false;
  790. if (_evt) { mixin(S_TRACE);
  791. if (_cellName) _cellName.setText(_evt.cellName);
  792. _tsSpeed.setSelection(_evt.transitionSpeed);
  793. } else { mixin(S_TRACE);
  794. if (_cellName) _cellName.setText("");
  795. _ts.select(0);
  796. _tsSpeed.setSelection(.transitionSpeedDef);
  797. }
  798. }
  799. override bool apply() { mixin(S_TRACE);
  800. _evt.backs = _cont.backs;
  801. auto ts = _tsTbl[_ts.getSelectionIndex()];
  802. uint tsSpeed = _tsSpeed.getSelection();
  803. _evt.transition = ts;
  804. _evt.transitionSpeed = tsSpeed;
  805. if (CDetail.fromType(type).use(CArg.CELL_NAME)) {
  806. _evt.cellName = _cellName.getText();
  807. }
  808. return true;
  809. }
  810. }
  811. /// BGM????????????????
  812. class BgmDialog : EventDialog {
  813. private:
  814. MaterialSelect!(MtType.BGM, Combo, Table) _msel;
  815. override
  816. protected void refreshWarning() { mixin(S_TRACE);
  817. warning = comm.skin.warningBGM(prop.parent, _msel.filePath, summ.legacy, _prop.var.etc.targetVersion);
  818. }
  819. public:
  820. this (Commons comm, Props prop, Shell shell, Summary summ, Content parent, Content evt) { mixin(S_TRACE);
  821. super (comm, prop, shell, summ, CType.PLAY_BGM, parent, evt, true, prop.var.soundEvtDlg, true);
  822. }
  823. protected:
  824. override void setup(Composite area) { mixin(S_TRACE);
  825. area.setLayout(new GridLayout(1, true));
  826. auto comp = new Composite(area, SWT.NONE);
  827. comp.setLayout(zeroMarginGridLayout(4, false));
  828. comp.setLayoutData(new GridData(GridData.FILL_BOTH));
  829. { mixin(S_TRACE);
  830. auto skin = _comm.skin;
  831. _msel = new MaterialSelect!(MtType.BGM, Combo, Table)
  832. (_comm, _prop, _summ, false, null, [_prop.msgs.bgmStop]);
  833. _msel.createDirsCombo(comp).setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  834. mod(_msel);
  835. _msel.modEvent ~= &refreshWarning;
  836. _msel.createPlayButton(comp).setLayoutData(new GridData);
  837. _msel.createRefreshButton(comp, false).setLayoutData(new GridData);
  838. _msel.createDirectoryButton(comp, false).setLayoutData(new GridData);
  839. auto gd = new GridData(GridData.FILL_BOTH);
  840. gd.horizontalSpan = 4;
  841. gd.widthHint = _prop.var.etc.nameTableWidth;
  842. gd.heightHint = _prop.var.etc.nameTableHeight;
  843. auto list = _msel.createFileList(comp);
  844. list.setLayoutData(gd);
  845. }
  846. ignoreMod = true;
  847. scope (exit) ignoreMod = false;
  848. _msel.path = _evt ? _evt.bgmPath : "";
  849. }
  850. override bool apply() { mixin(S_TRACE);
  851. if (!_evt) _evt = new Content(CType.PLAY_BGM, "");
  852. _evt.bgmPath = _msel.path;
  853. return true;
  854. }
  855. }
  856. /// ???????????????????
  857. class SeDialog : EventDialog {
  858. private:
  859. MaterialSelect!(MtType.SE, Combo, Table) _msel;
  860. override
  861. protected void refreshWarning() { mixin(S_TRACE);
  862. warning = comm.skin.warningSE(prop.parent, _msel.filePath, summ.legacy, _prop.var.etc.targetVersion);
  863. }
  864. public:
  865. this (Commons comm, Props prop, Shell shell, Summary summ, Content parent, Content evt) { mixin(S_TRACE);
  866. super (comm, prop, shell, summ, CType.PLAY_SOUND, parent, evt, true, prop.var.soundEvtDlg, true);
  867. }
  868. protected:
  869. override void setup(Composite area) { mixin(S_TRACE);
  870. area.setLayout(new GridLayout(1, true));
  871. auto comp = new Composite(area, SWT.NONE);
  872. comp.setLayout(zeroMarginGridLayout(5, false));
  873. comp.setLayoutData(new GridData(GridData.FILL_BOTH));
  874. { mixin(S_TRACE);
  875. auto skin = _comm.skin;
  876. _msel = new MaterialSelect!(MtType.SE, Combo, Table)
  877. (_comm, _prop, _summ, false, null, []);
  878. _msel.createDirsCombo(comp).setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  879. mod(_msel);
  880. _msel.modEvent ~= &refreshWarning;
  881. _msel.createStopButton(comp).setLayoutData(new GridData);
  882. _msel.createPlayButton(comp).setLayoutData(new GridData);
  883. _msel.createRefreshButton(comp, false).setLayoutData(new GridData);
  884. _msel.createDirectoryButton(comp, false).setLayoutData(new GridData);
  885. auto gd = new GridData(GridData.FILL_BOTH);
  886. gd.horizontalSpan = 5;
  887. gd.widthHint = _prop.var.etc.nameTableWidth;
  888. gd.heightHint = _prop.var.etc.nameTableHeight;
  889. auto list = _msel.createFileList(comp);
  890. list.setLayoutData(gd);
  891. }
  892. ignoreMod = true;
  893. scope (exit) ignoreMod = false;
  894. _msel.path = _evt ? _evt.soundPath : "";
  895. }
  896. override bool apply() { mixin(S_TRACE);
  897. if (!_evt) _evt = new Content(CType.PLAY_SOUND, "");
  898. _evt.soundPath = _msel.path;
  899. return true;
  900. }
  901. }
  902. /// ??????????????
  903. private class NumericEventDialog(CType Type, string Name, string Max, string Get, string Set, uint Min = 0, uint Def = 0) : EventDialog {
  904. private:
  905. Spinner _value;
  906. public:
  907. this (Commons comm, Props prop, Shell shell, Summary summ, Content parent, Content evt) { mixin(S_TRACE);
  908. super (comm, prop, shell, summ, Type, parent, evt, false, null, true);
  909. }
  910. protected:
  911. private class PM : SelectionAdapter {
  912. private int _v;
  913. this (int v) {_v = v;}
  914. override void widgetSelected(SelectionEvent e) { mixin(S_TRACE);
  915. _value.setSelection(_value.getSelection() + _v);
  916. }
  917. }
  918. override void setup(Composite area) { mixin(S_TRACE);
  919. area.setLayout(new GridLayout(1, false));
  920. { mixin(S_TRACE);
  921. auto grp = new Group(area, SWT.NONE);
  922. grp.setLayoutData(new GridData(GridData.FILL_BOTH));
  923. grp.setText(mixin (Name));
  924. grp.setLayout(new CenterLayout(SWT.VERTICAL | SWT.HORIZONTAL, 0));
  925. auto comp = new Composite(grp, SWT.NONE);
  926. _value = new Spinner(comp, SWT.BORDER);
  927. initSpinner(_value);
  928. mod(_value);
  929. _value.setMinimum(Min);
  930. _value.setMaximum(mixin (Max));
  931. comp.setLayout(new GridLayout(10 <= _value.getMaximum() ? 3 : 2, false));
  932. if (10 <= _value.getMaximum()) { mixin(S_TRACE);
  933. auto tools = new Composite(comp, SWT.NONE);
  934. tools.setLayout(new FillLayout(SWT.HORIZONTAL));
  935. for (int i = 5; i <= _value.getMaximum() && i < 10000; i*= i == 5 ? 2 : 10) { mixin(S_TRACE);
  936. auto ts = new Composite(tools, SWT.NONE);
  937. ts.setLayout(new FillLayout(SWT.VERTICAL));
  938. void createB(int i) { mixin(S_TRACE);
  939. auto r = new Button(ts, SWT.PUSH);
  940. auto fontd = r.getFont().getFontData();
  941. foreach (fd; fontd) { mixin(S_TRACE);
  942. fd.height /= 1.5;
  943. }
  944. r.setFont(new Font(Display.getCurrent(), fontd));
  945. r.addDisposeListener(new class DisposeListener {
  946. override void widgetDisposed(DisposeEvent e) { mixin(S_TRACE);
  947. (cast(Control) e.widget).getFont().dispose();
  948. }
  949. });
  950. r.setText(i < 0 ? to!(string)(i) : "+" ~ to!(string)(i));
  951. r.addSelectionListener(new PM(i));
  952. }
  953. createB(i);
  954. createB(-i);
  955. }
  956. }
  957. auto l = new Label(comp, SWT.NONE);
  958. l.setText(.tryFormat(_prop.msgs.rangeHint, Min, _value.getMaximum()));
  959. }
  960. ignoreMod = true;
  961. scope (exit) ignoreMod = false;
  962. if (_evt) { mixin(S_TRACE);
  963. _value.setSelection(mixin (Get));
  964. } else { mixin(S_TRACE);
  965. _value.setSelection(Def);
  966. }
  967. }
  968. override bool apply() { mixin(S_TRACE);
  969. if (!_evt) _evt = new Content(Type, "");
  970. int value = _value.getSelection();
  971. mixin (Set);
  972. return true;
  973. }
  974. }
  975. alias NumericEventDialog!(CType.WAIT, "_prop.msgs.waitName",
  976. "_prop.var.etc.waitMax", "_evt.wait", "_evt.wait = value;") WaitEventDialog;
  977. alias NumericEventDialog!(CType.BRANCH_RANDOM, "_prop.msgs.randomName",
  978. "100", "_evt.percent", "_evt.percent = value;", 0, 50) BrRandomEventDialog;
  979. alias NumericEventDialog!(CType.BRANCH_PARTY_NUMBER, "_prop.msgs.partyNumName",
  980. "_prop.var.etc.partyMax", "_evt.partyNumber", "_evt.partyNumber = value;", 1, 1) BrNumEventDialog;
  981. template MoneyEventDialog(CType Type) {
  982. alias NumericEventDialog!(Type, "_prop.msgs.moneyName",
  983. "_prop.var.etc.priceMax", "_evt.money", "_evt.money = value;") MoneyEventDialog;
  984. }
  985. /// ??????????????????
  986. class EffectDialog : EventDialog {
  987. private:
  988. MotionView _mview;
  989. Spinner _lev;
  990. MaterialSelect!(MtType.SE, Combo, Combo) _se;
  991. Scale _sucRate;
  992. Button[EffectType] _effTyp;
  993. Button[Resist] _res;
  994. Button[CardVisual] _vis;
  995. Button[Target.M] _targ;
  996. override
  997. protected void refreshWarning() { mixin(S_TRACE);
  998. string[] ws;
  999. if (_se.path != "" && !_se.selectedDefDir) ws ~= prop.msgs.warningNotDefaultSE;
  1000. warning = ws ~ comm.skin.warningSE(prop.parent, _se.filePath, summ.legacy, _prop.var.etc.targetVersion);
  1001. }
  1002. public:
  1003. this (Commons comm, Props prop, Shell shell, Summary summ, Content parent, Content evt) { mixin(S_TRACE);
  1004. super (comm, prop, shell, summ, CType.EFFECT, parent, evt, true, prop.var.effEvtDlg, true);
  1005. }
  1006. override
  1007. bool openCWXPath(string path, bool shellActivate) { mixin(S_TRACE);
  1008. return _mview.openCWXPath(path, shellActivate);
  1009. }
  1010. protected:
  1011. override void setup(Composite area) { mixin(S_TRACE);
  1012. auto cl = new CenterLayout;
  1013. cl.fillHorizontal = true;
  1014. cl.fillVertical = true;
  1015. area.setLayout(cl);
  1016. auto tabf = new CTabFolder(area, SWT.BORDER);
  1017. auto tabM = new CTabItem(tabf, SWT.NONE);
  1018. tabM.setText(_prop.msgs.motion);
  1019. { mixin(S_TRACE);
  1020. _mview = new MotionView(_comm, _prop, _summ, tabf, SWT.NONE);
  1021. mod(_mview);
  1022. tabM.setControl(_mview);
  1023. }
  1024. auto tabS = new CTabItem(tabf, SWT.NONE);
  1025. tabS.setText(_prop.msgs.settings);
  1026. { mixin(S_TRACE);
  1027. auto comp = new Composite(tabf, SWT.NONE);
  1028. tabS.setControl(comp);
  1029. comp.setLayout(new GridLayout(2, false));
  1030. { mixin(S_TRACE);
  1031. auto comp2 = new Composite(comp, SWT.NONE);
  1032. comp2.setLayoutData(new GridData(GridData.FILL_BOTH));
  1033. comp2.setLayout(zeroMarginGridLayout(1, true));
  1034. { mixin(S_TRACE);
  1035. auto grp = new Group(comp2, SWT.NONE);
  1036. grp.setText(_prop.msgs.targetLevel);
  1037. grp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  1038. grp.setLayout(new GridLayout(2, false));
  1039. _lev = new Spinner(grp, SWT.BORDER);
  1040. initSpinner(_lev);
  1041. mod(_lev);
  1042. _lev.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  1043. _lev.setMinimum(-(cast(int) _prop.var.etc.castLevelMax));
  1044. _lev.setMaximum(_prop.var.etc.castLevelMax);
  1045. auto l = new Label(grp, SWT.NONE);
  1046. l.setText(.tryFormat(_prop.msgs.rangeHint, _lev.getMinimum(), _lev.getMaximum()));
  1047. }
  1048. { mixin(S_TRACE);
  1049. auto grp = new Group(comp2, SWT.NONE);
  1050. grp.setText(_prop.msgs.elementProps);
  1051. grp.setLayoutData(new GridData(GridData.FILL_BOTH));
  1052. grp.setLayout(new GridLayout(2, true));
  1053. foreach (i, eff; [EffectType.PHYSIC, EffectType.MAGIC,
  1054. EffectType.MAGICAL_PHYSIC, EffectType.PHYSICAL_MAGIC,
  1055. EffectType.NONE]) { mixin(S_TRACE);
  1056. auto radio = new Button(grp, SWT.RADIO);
  1057. mod(radio);
  1058. auto gd = new GridData(GridData.FILL_BOTH);
  1059. if (2 <= i) { mixin(S_TRACE);
  1060. gd.horizontalSpan = 2;
  1061. }
  1062. radio.setLayoutData(gd);
  1063. radio.setText(.tryFormat(_prop.msgs.effectTypeElement, _prop.msgs.effectTypeName(eff)));
  1064. radio.setToolTipText(_prop.msgs.effectTypeDesc(eff));
  1065. _effTyp[eff] = radio;
  1066. }
  1067. }
  1068. { mixin(S_TRACE);
  1069. auto grp = new Group(comp2, SWT.NONE);
  1070. grp.setText(_prop.msgs.resistProps);
  1071. grp.setLayoutData(new GridData(GridData.FILL_BOTH));
  1072. grp.setLayout(new GridLayout(2, true));
  1073. foreach (res; [Resist.AVOID, Resist.RESIST, Resist.UNFAIL]) { mixin(S_TRACE);
  1074. auto radio = new Button(grp, SWT.RADIO);
  1075. mod(radio);
  1076. radio.setText(_prop.msgs.resistName(res));
  1077. radio.setToolTipText(_prop.msgs.resistDesc(res));
  1078. radio.setLayoutData(new GridData(GridData.FILL_BOTH));
  1079. _res[res] = radio;
  1080. }
  1081. }
  1082. }
  1083. { mixin(S_TRACE);
  1084. auto comp2 = new Composite(comp, SWT.NONE);
  1085. comp2.setLayoutData(new GridData(GridData.FILL_BOTH));
  1086. comp2.setLayout(zeroMarginGridLayout(2, false));
  1087. { mixin(S_TRACE);
  1088. auto grp = new Group(comp2, SWT.NONE);
  1089. grp.setText(_prop.msgs.effectVisual);
  1090. grp.setLayoutData(new GridData(GridData.FILL_BOTH));
  1091. grp.setLayout(new GridLayout(1, false));
  1092. foreach (v; [CardVisual.NONE, CardVisual.REVERSE, CardVisual.HORIZONTAL, CardVisual.VERTICAL]) { mixin(S_TRACE);
  1093. auto radio = new Button(grp, SWT.RADIO);
  1094. mod(radio);
  1095. radio.setLayoutData(new GridData(GridData.FILL_BOTH));
  1096. radio.setText(_prop.msgs.cardVisualName(v));
  1097. _vis[v] = radio;
  1098. }
  1099. }
  1100. { mixin(S_TRACE);
  1101. auto grp = new Group(comp2, SWT.NONE);
  1102. grp.setText(_prop.msgs.judgeTarget);
  1103. grp.setLayoutData(new GridData(GridData.FILL_BOTH));
  1104. grp.setLayout(new GridLayout(1, true));
  1105. foreach (m; [Target.M.SELECTED, Target.M.RANDOM, Target.M.PARTY]) { mixin(S_TRACE);
  1106. auto radio = new Button(grp, SWT.RADIO);
  1107. mod(radio);
  1108. radio.setText(_prop.msgs.targetName(m));
  1109. radio.setLayoutData(new GridData(GridData.FILL_BOTH));
  1110. _targ[m] = radio;
  1111. }
  1112. }
  1113. { mixin(S_TRACE);
  1114. auto grp = new Group(comp2, SWT.NONE);
  1115. grp.setText(_prop.msgs.se);
  1116. auto gd = new GridData(GridData.FILL_HORIZONTAL);
  1117. gd.horizontalSpan = 2;
  1118. grp.setLayoutData(gd);
  1119. grp.setLayout(new GridLayout(3, false));
  1120. _se = new MaterialSelect!(MtType.SE, Combo, Combo)(comm, prop, summ, false, null, [prop.msgs.soundNone]);
  1121. mod(_se);
  1122. _se.modEvent ~= &refreshWarning;
  1123. _se.createDirsCombo(grp).setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  1124. _se.createStopButton(grp);
  1125. _se.createPlayButton(grp);
  1126. auto gdfl = new GridData(GridData.FILL_HORIZONTAL);
  1127. gdfl.horizontalSpan = 4;
  1128. _se.createFileList(grp).setLayoutData(gdfl);
  1129. }
  1130. { mixin(S_TRACE);
  1131. auto gd = new GridData(GridData.FILL_BOTH);
  1132. gd.horizontalSpan = 2;
  1133. createSuccessRateScale(_prop, comp2, _sucRate).setLayoutData(gd);
  1134. mod(_sucRate);
  1135. }
  1136. }
  1137. }
  1138. tabf.setLayoutData(area.computeSize(SWT.DEFAULT, SWT.DEFAULT));
  1139. ignoreMod = true;
  1140. scope (exit) ignoreMod = false;
  1141. if (_evt) { mixin(S_TRACE);
  1142. _mview.motions = _evt.motions;
  1143. _lev.setSelection(_evt.signedLevel);
  1144. _se.path = _evt.soundPath;
  1145. _sucRate.setSelection(_evt.successRate + Content.successRate_max);
  1146. _effTyp[_evt.effectType].setSelection(true);
  1147. _res[_evt.resist].setSelection(true);
  1148. _vis[_evt.cardVisual].setSelection(true);
  1149. _targ[_evt.targetNS.m].setSelection(true);
  1150. } else { mixin(S_TRACE);
  1151. _mview.motions = [];
  1152. _lev.setSelection(0);
  1153. _se.path = "";
  1154. _sucRate.setSelection(Content.successRate_max + Content.successRate_max);
  1155. _effTyp[EffectType.NONE].setSelection(true);
  1156. _res[Resist.UNFAIL].setSelection(true);
  1157. _vis[CardVisual.NONE].setSelection(true);
  1158. _targ[Target.M.SELECTED].setSelection(true);
  1159. }
  1160. }
  1161. override bool apply() { mixin(S_TRACE);
  1162. if (!_evt) _evt = new Content(CType.EFFECT, "");
  1163. _evt.motions = _mview.motions;
  1164. _evt.signedLevel = _lev.getSelection();
  1165. _evt.soundPath = _se.path;
  1166. _evt.successRate = cast(int) _sucRate.getSelection() - Content.successRate_max;
  1167. _evt.effectType = getRadioValue!(EffectType)(_effTyp);
  1168. _evt.resist = getRadioValue!(Resist)(_res);
  1169. _evt.cardVisual = getRadioValue!(CardVisual)(_vis);
  1170. _evt.targetNS = Target(getRadioValue!(Target.M)(_targ), false);
  1171. return true;
  1172. }
  1173. }
  1174. /// ???????????????????????
  1175. private class FlagStepDialog(CType Type, F, bool SelValue) : EventDialog {
  1176. private:
  1177. override
  1178. protected void refreshWarning() { mixin(S_TRACE);
  1179. string[] ws;
  1180. static if (Type is CType.CHECK_STEP) {
  1181. if (!_prop.targetVersion("1.50")) { mixin(S_TRACE);
  1182. ws ~= .tryFormat(_prop.msgs.warningUnknownContent, _prop.msgs.contentName(CType.CHECK_STEP), "1.50");
  1183. }
  1184. }
  1185. warning = ws;
  1186. }
  1187. FlagDir _root;
  1188. SplitPane _sash;
  1189. FlagChooser!(F, false) _flags;
  1190. string _oldSel = "";
  1191. Table _values;
  1192. @property
  1193. uint selectedValue() { mixin(S_TRACE);
  1194. return _values.getSelectionIndex();
  1195. }
  1196. void refreshValues() { mixin(S_TRACE);
  1197. static if (is(F:Flag)) {
  1198. F flag = summ.flagDirRoot.findFlag(_flags.selected);
  1199. } else static if (is(F:Step)) {
  1200. F flag = summ.flagDirRoot.findStep(_flags.selected);
  1201. } else static assert (0);
  1202. static if (SelValue) {
  1203. int sel = _values.getSelectionIndex();
  1204. }
  1205. _values.removeAll();
  1206. if (flag) { mixin(S_TRACE);
  1207. static if (is (F == Flag)) {
  1208. auto itm1 = new TableItem(_values, SWT.NONE);
  1209. itm1.setText(flag.on);
  1210. auto itm2 = new TableItem(_values, SWT.NONE);
  1211. itm2.setText(flag.off);
  1212. } else static if (is (F == Step)) {
  1213. foreach (val; flag.values) { mixin(S_TRACE);
  1214. auto itm = new TableItem(_values, SWT.NONE);
  1215. itm.setText(val);
  1216. }
  1217. } else { mixin(S_TRACE);
  1218. static assert (0);
  1219. }
  1220. static if (SelValue) {
  1221. if (sel < 0) sel = 0;
  1222. static if (is (F == Step)) {
  1223. if (sel >= flag.values.length) sel = flag.values.length - 1;
  1224. }
  1225. _values.select(sel);
  1226. }
  1227. }
  1228. updateLabel();
  1229. }
  1230. void selectedFlag() { mixin(S_TRACE);
  1231. string selPath = _flags.selectedWithDir;
  1232. if (_oldSel == selPath) { mixin(S_TRACE);
  1233. static if (SelValue) {
  1234. _values.select(0);
  1235. updateLabel();
  1236. }
  1237. } else { mixin(S_TRACE);
  1238. _oldSel = _flags.selectedWithDir;
  1239. refreshValues();
  1240. }
  1241. }
  1242. class ValSListener : SelectionAdapter {
  1243. override void widgetSelected(SelectionEvent e) { mixin(S_TRACE);
  1244. updateLabel();
  1245. }
  1246. }
  1247. class Dispose : DisposeListener {
  1248. override void widgetDisposed(DisposeEvent e) { mixin(S_TRACE);
  1249. _comm.refFlagAndStep.remove(&refFS);
  1250. _comm.delFlagAndStep.remove(&delFS);
  1251. }
  1252. }
  1253. void refFS(Flag[] f, Step[] s) { mixin(S_TRACE);
  1254. static if (is(F : Flag)) {
  1255. if (!f.length) return;
  1256. } else { mixin(S_TRACE);
  1257. if (!s.length) return;
  1258. }
  1259. int sel = _values.getSelectionIndex();
  1260. refreshValues();
  1261. _values.select(sel);
  1262. }
  1263. void delFS(Flag[] f, Step[] s) { mixin(S_TRACE);
  1264. static if (is(F : Flag)) {
  1265. if (!f.length) return;
  1266. } else { mixin(S_TRACE);
  1267. if (!s.length) return;
  1268. }
  1269. static if (is(F : Flag)) {
  1270. if (!_root.allFlags.length) { mixin(S_TRACE);
  1271. forceCancel();
  1272. return;
  1273. }
  1274. } else static if (is(F : Step)) {
  1275. if (!_root.allSteps.length) { mixin(S_TRACE);
  1276. forceCancel();
  1277. return;
  1278. }
  1279. } else static assert (0);
  1280. refreshValues();
  1281. }
  1282. static if (Type is CType.CHECK_STEP) {
  1283. Label _cmpLabel = null;
  1284. Combo _cmp = null;
  1285. Comparison4[] _cmps;
  1286. void updateLabel() { mixin(S_TRACE);
  1287. static if (is(F:Flag)) {
  1288. F step = summ.flagDirRoot.findFlag(_flags.selected);
  1289. } else static if (is(F:Step)) {
  1290. F step = summ.flagDirRoot.findStep(_flags.selected);
  1291. } else static assert (0);
  1292. if (!step) return;
  1293. uint value = selectedValue;
  1294. _cmpLabel.setText(.tryFormat(prop.msgs.stepValueIs, step.path, step.getValue(value)));
  1295. }
  1296. } else {
  1297. void updateLabel() { mixin(S_TRACE);
  1298. // ????
  1299. }
  1300. }
  1301. public:
  1302. this (Commons comm, Props prop, Shell shell, Summary summ, Content parent, Content evt, FlagDir root) { mixin(S_TRACE);
  1303. _root = root;
  1304. super (comm, prop, shell, summ, Type, parent, evt, true, prop.var.flagEvtDlg, true);
  1305. closeEvent ~= { mixin(S_TRACE);
  1306. auto ws = _sash.getWeights();
  1307. _prop.var.etc.flagEventSashL = ws[0];
  1308. _prop.var.etc.flagEventSashR = ws[1];
  1309. };
  1310. }
  1311. protected:
  1312. override void setup(Composite area) { mixin(S_TRACE);
  1313. area.setLayout(new GridLayout(1, true));
  1314. _sash = new SplitPane(area, SWT.HORIZONTAL);
  1315. _sash.setLayoutData(new GridData(GridData.FILL_BOTH));
  1316. auto left = new Composite(_sash, SWT.NONE);
  1317. left.setLayout(zeroGridLayout(1));
  1318. auto right = new Composite(_sash, SWT.NONE);
  1319. right.setLayout(zeroGridLayout(1));
  1320. { mixin(S_TRACE);
  1321. auto l1 = new CLabel(left, SWT.NONE);
  1322. auto l2 = new CLabel(right, SWT.NONE);
  1323. static if (is (F == Flag)) {
  1324. l1.setText(_prop.msgs.flag);
  1325. l1.setImage(_prop.images.flag);
  1326. l2.setText(_prop.msgs.flagValue);
  1327. } else static if (is (F == Step)) {
  1328. l1.setText(_prop.msgs.step);
  1329. l1.setImage(_prop.images.step);
  1330. l2.setText(_prop.msgs.stepValue);
  1331. } else { mixin(S_TRACE);
  1332. static assert (0);
  1333. }
  1334. auto gd = new GridData;
  1335. gd.heightHint = l1.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
  1336. l2.setLayoutData(gd);
  1337. }
  1338. { mixin(S_TRACE);
  1339. _flags = new FlagChooser!(F, false, false)(comm, summ, left);
  1340. mod(_flags);
  1341. _flags.modEvent ~= &selectedFlag;
  1342. _flags.setLayoutData(new GridData(GridData.FILL_BOTH));
  1343. }
  1344. { mixin(S_TRACE);
  1345. _values = new Table(right, SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL);
  1346. new FullTableColumn(_values, SWT.NONE);
  1347. mod(_values);
  1348. auto gd = new GridData(GridData.FILL_BOTH);
  1349. gd.heightHint = _prop.var.etc.nameTableHeight;
  1350. _values.setLayoutData(gd);
  1351. _values.setEnabled(SelValue);
  1352. _values.addSelectionListener(new ValSListener);
  1353. }
  1354. static if (Type is CType.CHECK_STEP) {
  1355. auto comp = new Composite(area, SWT.NONE);
  1356. comp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  1357. comp.setLayout(zeroMarginGridLayout(2, false));
  1358. _cmpLabel = new Label(comp, SWT.RIGHT);
  1359. _cmpLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  1360. _cmp = new Combo(comp, SWT.READ_ONLY | SWT.DROP_DOWN | SWT.BORDER);
  1361. mod(_cmp);
  1362. _cmp.setVisibleItemCount(prop.var.etc.comboVisibleItemCount);
  1363. foreach (cmp; EnumMembers!Comparison4) { mixin(S_TRACE);
  1364. _cmp.add(prop.msgs.comparison4Name(cmp));
  1365. _cmps ~= cmp;
  1366. }
  1367. }
  1368. _comm.refFlagAndStep.add(&refFS);
  1369. _comm.delFlagAndStep.add(&delFS);
  1370. _flags.addDisposeListener(new Dispose);
  1371. ignoreMod = true;
  1372. scope (exit) ignoreMod = false;
  1373. if (_evt) { mixin(S_TRACE);
  1374. static if (is (F == Flag)) {
  1375. _flags.selected = _evt.flag;
  1376. } else static if (is (F == Step)) {
  1377. _flags.selected = _evt.step;
  1378. } else { mixin(S_TRACE);
  1379. static assert (0);
  1380. }
  1381. _oldSel = _flags.selectedWithDir;
  1382. refreshValues();
  1383. static if (SelValue) {
  1384. static if (is (F == Flag)) {
  1385. _values.select(_evt.flagValue ? 0 : 1);
  1386. } else static if (is (F == Step)) {
  1387. _values.select(_evt.stepValue);
  1388. } else { mixin(S_TRACE);
  1389. static assert (0);
  1390. }
  1391. }
  1392. static if (Type is CType.CHECK_STEP) {
  1393. _cmp.select(_cmps.countUntil(_evt.comparison4));
  1394. }
  1395. } else { mixin(S_TRACE);
  1396. _flags.selected = "";
  1397. refreshValues();
  1398. static if (Type is CType.CHECK_STEP) {
  1399. _cmp.select(0);
  1400. }
  1401. }
  1402. updateLabel();
  1403. refreshWarning();
  1404. _sash.setWeights([_prop.var.etc.flagEventSashL, _prop.var.etc.flagEventSashR]);
  1405. }
  1406. override bool apply() { mixin(S_TRACE);
  1407. assert (_flags.selected != "");
  1408. if (!_evt) _evt = new Content(Type, "");
  1409. static if (is (F == Flag)) {
  1410. _evt.flag = _flags.selected;
  1411. static if (SelValue) {
  1412. _evt.flagValue = _values.getSelectionIndex() == 0;
  1413. }
  1414. } else static if (is (F == Step)) {
  1415. _evt.step = _flags.selected;
  1416. static if (SelValue) {
  1417. _evt.stepValue = _values.getSelectionIndex();
  1418. }
  1419. } else { mixin(S_TRACE);
  1420. static assert (0);
  1421. }
  1422. static if (Type is CType.CHECK_STEP) {
  1423. _evt.comparison4 = _cmps[_cmp.getSelectionIndex()];
  1424. }
  1425. return true;
  1426. }
  1427. }
  1428. alias FlagStepDialog!(CType.BRANCH_FLAG, Flag, false) BrFlagDialog;
  1429. alias FlagStepDialog!(CType.BRANCH_MULTI_STEP, Step, false) BrStepNDialog;
  1430. alias FlagStepDialog!(CType.BRANCH_STEP, Step, true) BrStepULDialog;
  1431. alias FlagStepDialog!(CType.SET_FLAG, Flag, true) FlagSetDialog;
  1432. alias FlagStepDialog!(CType.SET_STEP, Step, true) StepSetDialog;
  1433. alias FlagStepDialog!(CType.SET_STEP_UP, Step, false) StepPlusDialog;
  1434. alias FlagStepDialog!(CType.SET_STEP_DOWN, Step, false) StepMinusDialog;
  1435. alias FlagStepDialog!(CType.REVERSE_FLAG, Flag, false) FlagRDialog;
  1436. alias FlagStepDialog!(CType.CHECK_FLAG, Flag, false) FlagJudgeDialog;
  1437. alias FlagStepDialog!(CType.CHECK_STEP, Step, true) CheckStepDialog;
  1438. /// ?????????????????????????
  1439. private class FlagStepCombiDialog(CType Type, F, bool Random) : EventDialog {
  1440. private:
  1441. FlagDir _root;
  1442. SplitPane _sash;
  1443. FlagChooser!(F, false, Random) _flags1;
  1444. FlagChooser!(F, false, false) _flags2;
  1445. override
  1446. protected void refreshWarning() { mixin(S_TRACE);
  1447. string[] ws;
  1448. if (!_prop.targetVersion("1.30")) { mixin(S_TRACE);
  1449. ws ~= .tryFormat(_prop.msgs.warningUnknownContent, _prop.msgs.contentName(Type), "1.30");
  1450. }
  1451. warning = ws;
  1452. }
  1453. class Dispose : DisposeListener {
  1454. override void widgetDisposed(DisposeEvent e) { mixin(S_TRACE);
  1455. _comm.delFlagAndStep.remove(&delFS);
  1456. }
  1457. }
  1458. void delFS(Flag[] f, Step[] s) { mixin(S_TRACE);
  1459. static if (is(F : Flag)) {
  1460. if (!_root.allFlags.length) { mixin(S_TRACE);
  1461. forceCancel();
  1462. }
  1463. } else static if (is(F : Step)) {
  1464. if (!_root.allSteps.length) { mixin(S_TRACE);
  1465. forceCancel();
  1466. }
  1467. } else static assert (0);
  1468. }
  1469. public:
  1470. this (Commons comm, Props prop, Shell shell, Summary summ, Content parent, Content evt, FlagDir root) { mixin(S_TRACE);
  1471. _root = root;
  1472. super (comm, prop, shell, summ, Type, parent, evt, true, prop.var.flagCombiDlg, true);
  1473. closeEvent ~= { mixin(S_TRACE);
  1474. auto ws = _sash.getWeights();
  1475. _prop.var.etc.flagCombiSashL = ws[0];
  1476. _prop.var.etc.flagCombiSashR = ws[1];
  1477. };
  1478. }
  1479. protected:
  1480. override void setup(Composite area) { mixin(S_TRACE);
  1481. area.setLayout(new GridLayout(1, true));
  1482. _sash = new SplitPane(area, SWT.HORIZONTAL);
  1483. _sash.setLayoutData(new GridData(GridData.FILL_BOTH));
  1484. auto left = new Composite(_sash, SWT.NONE);
  1485. left.setLayout(zeroGridLayout(1));
  1486. auto right = new Composite(_sash, SWT.NONE);
  1487. right.setLayout(zeroGridLayout(1));
  1488. { mixin(S_TRACE);
  1489. auto l1 = new CLabel(left, SWT.NONE);
  1490. auto l2 = new CLabel(right, SWT.NONE);
  1491. static if (Type == CType.SUBSTITUTE_STEP || Type == CType.SUBSTITUTE_FLAG) {
  1492. l1.setText(_prop.msgs.substituteSource);
  1493. l2.setText(_prop.msgs.substituteTarget);
  1494. } else static if (Type == CType.BRANCH_STEP_CMP || Type == CType.BRANCH_FLAG_CMP) {
  1495. l1.setText(_prop.msgs.cmpSource);
  1496. l2.setText(_prop.msgs.cmpTarget);
  1497. } else static assert (0);
  1498. static if (is (F == Flag)) {
  1499. l1.setImage(_prop.images.flag);
  1500. l2.setImage(_prop.images.flag);
  1501. } else static if (is (F == Step)) {
  1502. l1.setImage(_prop.images.step);
  1503. l2.setImage(_prop.images.step);
  1504. } else { mixin(S_TRACE);
  1505. static assert (0);
  1506. }
  1507. }
  1508. _flags1 = new FlagChooser!(F, false, Random)(comm, summ, left);
  1509. _flags1.setLayoutData(new GridData(GridData.FILL_BOTH));
  1510. _flags2 = new FlagChooser!(F, false, false)(comm, summ, right, false);
  1511. _flags2.setLayoutData(new GridData(GridData.FILL_BOTH));
  1512. _comm.delFlagAndStep.add(&delFS);
  1513. _sash.addDisposeListener(new Dispose);
  1514. ignoreMod = true;
  1515. scope (exit) ignoreMod = false;
  1516. if (_evt) { mixin(S_TRACE);
  1517. static if (is (F == Flag)) {
  1518. _flags1.selected = _evt.flag;
  1519. _flags2.selected = _evt.flag2;
  1520. } else static if (is (F == Step)) {
  1521. _flags1.selected = _evt.step;
  1522. _flags2.selected = _evt.step2;
  1523. } else { mixin(S_TRACE);
  1524. static assert (0);
  1525. }
  1526. } else { mixin(S_TRACE);
  1527. _flags1.selected = "";
  1528. _flags2.selected = "";
  1529. }
  1530. refreshWarning();
  1531. _sash.setWeights([_prop.var.etc.flagCombiSashL, _prop.var.etc.flagCombiSashR]);
  1532. }
  1533. override bool apply() { mixin(S_TRACE);
  1534. if (!_evt) _evt = new Content(Type, "");
  1535. static if (is (F == Flag)) {
  1536. _evt.flag = _flags1.selected;
  1537. _evt.flag2 = _flags2.selected;
  1538. } else static if (is (F == Step)) {
  1539. _evt.step = _flags1.selected;
  1540. _evt.step2 = _flags2.selected;
  1541. } else { mixin(S_TRACE);
  1542. static assert (0);
  1543. }
  1544. return true;
  1545. }
  1546. }
  1547. alias FlagStepCombiDialog!(CType.SUBSTITUTE_STEP, Step, true) SubstituteStepDialog;
  1548. alias FlagStepCombiDialog!(CType.SUBSTITUTE_FLAG, Flag, true) SubstituteFlagDialog;
  1549. alias FlagStepCombiDialog!(CType.BRANCH_STEP_CMP, Step, false) BrStepCmpDialog;
  1550. alias FlagStepCombiDialog!(CType.BRANCH_FLAG_CMP, Flag, false) BrFlagCmpDialog;
  1551. /// ???????????????????
  1552. class BrMemberDialog : EventDialog {
  1553. private:
  1554. // FIXME: KeyType?bool??????
  1555. Button[] _all;
  1556. Button[] _random;
  1557. public:
  1558. this (Commons comm, Props prop, Shell shell, Summary summ, Content parent, Content evt) { mixin(S_TRACE);
  1559. super (comm, prop, shell, summ, CType.BRANCH_SELECT, parent, evt, false, null, true);
  1560. }
  1561. protected:
  1562. override void setup(Composite area) { mixin(S_TRACE);
  1563. area.setLayout(new GridLayout(2, false));
  1564. void createR(string title, string trueText, string falseText, ref Button[] btns) { mixin(S_TRACE);
  1565. auto grp = new Group(area, SWT.NONE);
  1566. grp.setLayoutData(new GridData(GridData.FILL_BOTH));
  1567. grp.setLayout(new CenterLayout);
  1568. grp.setText(title);
  1569. auto comp = new Composite(grp, SWT.NONE);
  1570. comp.setLayout(zeroMarginGridLayout(1, true));
  1571. auto btnT = new Button(comp, SWT.RADIO);
  1572. mod(btnT);
  1573. btnT.setText(trueText);
  1574. auto btnF = new Button(comp, SWT.RADIO);
  1575. mod(btnF);
  1576. btnF.setText(falseText);
  1577. btns.length = 2;
  1578. btns[0] = btnT;
  1579. btns[1] = btnF;
  1580. }
  1581. createR(_prop.msgs.selectMember, _prop.msgs.activeMember, _prop.msgs.allMember, _all);
  1582. createR(_prop.msgs.selectMethod, _prop.msgs.manualMethod, _prop.msgs.randomMethod, _random);
  1583. ignoreMod = true;
  1584. scope (exit) ignoreMod = false;
  1585. if (_evt) { mixin(S_TRACE);
  1586. _all[_evt.targetAll ? 1 : 0].setSelection(true);
  1587. _random[_evt.random ? 1 : 0].setSelection(true);
  1588. } else { mixin(S_TRACE);
  1589. _all[0].setSelection(true);
  1590. _random[0].setSelection(true);
  1591. }
  1592. }
  1593. override bool apply() { mixin(S_TRACE);
  1594. if (!_evt) _evt = new Content(CType.BRANCH_SELECT, "");
  1595. _evt.targetAll = _all[1].getSelection();
  1596. _evt.random = _random[1].getSelection();
  1597. return true;
  1598. }
  1599. }
  1600. /// ??????????????????
  1601. class BrPowerDialog : EventDialog {
  1602. private:
  1603. Spinner _lev;
  1604. Button[Target.M] _targ;
  1605. // FIXME: KeyType?bool??????
  1606. Button[2] _sleep;
  1607. Button[Physical] _phy;
  1608. Button[Mental] _mtl;
  1609. public:
  1610. this (Commons comm, Props prop, Shell shell, Summary summ, Content parent, Content evt) { mixin(S_TRACE);
  1611. super (comm, prop, shell, summ, CType.BRANCH_ABILITY, parent, evt, false, null, true);
  1612. }
  1613. protected:
  1614. override void setup(Composite area) { mixin(S_TRACE);
  1615. area.setLayout(new GridLayout(3, false));
  1616. { mixin(S_TRACE);
  1617. auto comp = new Composite(area, SWT.NONE);
  1618. comp.setLayout(zeroMarginGridLayout(1, true));
  1619. { mixin(S_TRACE);
  1620. auto grp = new Group(comp, SWT.NONE);
  1621. grp.setText(_prop.msgs.targetLevel);
  1622. grp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  1623. grp.setLayout(new GridLayout(2, false));
  1624. _lev = new Spinner(grp, SWT.BORDER);
  1625. initSpinner(_lev);
  1626. mod(_lev);
  1627. _lev.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  1628. _lev.setMinimum(-(cast(int) _prop.var.etc.castLevelMax));
  1629. _lev.setMaximum(_prop.var.etc.castLevelMax);
  1630. auto l = new Label(grp, SWT.NONE);
  1631. l.setText(.tryFormat(_prop.msgs.rangeHint, _lev.getMinimum(), _lev.getMaximum()));
  1632. }
  1633. { mixin(S_TRACE);
  1634. auto grp = new Group(comp, SWT.NONE);
  1635. grp.setText(_prop.msgs.judgeTarget);
  1636. grp.setLayoutData(new GridData(GridData.FILL_BOTH));
  1637. grp.setLayout(new GridLayout(1, true));
  1638. foreach (m; [Target.M.SELECTED, Target.M.RANDOM, Target.M.PARTY]) { mixin(S_TRACE);
  1639. auto radio = new Button(grp, SWT.RADIO);
  1640. mod(radio);
  1641. radio.setText(_prop.msgs.targetName(m));
  1642. radio.setLayoutData(new GridData(GridData.FILL_BOTH));
  1643. _targ[m] = radio;
  1644. }
  1645. }
  1646. { mixin(S_TRACE);
  1647. auto grp = new Group(comp, SWT.NONE);
  1648. grp.setText(_prop.msgs.judgeSleep);
  1649. grp.setLayoutData(new GridData(GridData.FILL_BOTH));
  1650. grp.setLayout(new GridLayout(1, true));
  1651. _sleep[1] = new Button(grp, SWT.RADIO);
  1652. mod(_sleep[1]);
  1653. _sleep[1].setText(_prop.msgs.sleepDisabled);
  1654. _sleep[0] = new Button(grp, SWT.RADIO);
  1655. mod(_sleep[0]);
  1656. _sleep[0].setText(_prop.msgs.sleepEnabled);
  1657. }
  1658. }
  1659. { mixin(S_TRACE);
  1660. auto grp = new Group(area, SWT.NONE);
  1661. grp.setText(_prop.msgs.aptPhysical);
  1662. grp.setLayoutData(new GridData(GridData.FILL_BOTH));
  1663. auto cl = new CenterLayout(SWT.HORIZONTAL, 0);
  1664. cl.fillVertical = true;
  1665. grp.setLayout(cl);
  1666. auto comp2 = new Composite(grp, SWT.NONE);
  1667. comp2.setLayout(new GridLayout(1, true));
  1668. foreach (phy; [Physical.DEX, Physical.AGL, Physical.INT,
  1669. Physical.STR, Physical.VIT, Physical.MIN]) { mixin(S_TRACE);
  1670. auto radio = new Button(comp2, SWT.RADIO);
  1671. mod(radio);
  1672. radio.setLayoutData(new GridData(GridData.FILL_VERTICAL));
  1673. radio.setText(_prop.msgs.physicalName(phy));
  1674. _phy[phy] = radio;
  1675. }
  1676. }
  1677. { mixin(S_TRACE);
  1678. auto grp = new Group(area, SWT.NONE);
  1679. grp.setText(_prop.msgs.aptMental);
  1680. grp.setLayoutData(new GridData(GridData.FILL_BOTH));
  1681. auto cl = new CenterLayout(SWT.HORIZONTAL, 0);
  1682. cl.fillVertical = true;
  1683. grp.setLayout(cl);
  1684. auto comp2 = new Composite(grp, SWT.NONE);
  1685. comp2.setLayout(new GridLayout(2, true));
  1686. static const Ms = [Mental.AGGRESSIVE, Mental.UNAGGRESSIVE,
  1687. Mental.CHEERFUL, Mental.UNCHEERFUL,
  1688. Mental.BRAVE, Mental.UNBRAVE, Mental.CAUTIOUS, Mental.UNCAUTIOUS,
  1689. Mental.TRICKISH, Mental.UNTRICKISH];
  1690. foreach (i, m; Ms) { mixin(S_TRACE);
  1691. auto radio = new Button(comp2, SWT.RADIO);
  1692. mod(radio);
  1693. radio.setLayoutData(new GridData(GridData.FILL_BOTH));
  1694. radio.setText(_prop.msgs.mentalName(m));
  1695. _mtl[m] = radio;
  1696. }
  1697. }
  1698. ignoreMod = true;
  1699. scope (exit) ignoreMod = false;
  1700. if (_evt) { mixin(S_TRACE);
  1701. _lev.setSelection(_evt.signedLevel);
  1702. _targ[_evt.targetS.m].setSelection(true);
  1703. _sleep[_evt.targetS.sleep ? 0 : 1].setSelection(true);
  1704. _phy[_evt.physical].setSelection(true);
  1705. _mtl[_evt.mental].setSelection(true);
  1706. } else { mixin(S_TRACE);
  1707. _lev.setSelection(0);
  1708. _targ[Target.M.SELECTED].setSelection(true);
  1709. _sleep[1].setSelection(true);
  1710. _phy[Physical.DEX].setSelection(true);
  1711. _mtl[Mental.AGGRESSIVE].setSelection(true);
  1712. }
  1713. }
  1714. override bool apply() { mixin(S_TRACE);
  1715. if (!_evt) _evt = new Content(CType.BRANCH_ABILITY, "");
  1716. auto targ = Target(getRadioValue!(Target.M)(_targ), _sleep[0].getSelection());
  1717. _evt.signedLevel = _lev.getSelection();
  1718. _evt.targetS = targ;
  1719. _evt.physical = getRadioValue!(Physical)(_phy);
  1720. _evt.mental = getRadioValue!(Mental)(_mtl);
  1721. return true;
  1722. }
  1723. }
  1724. /// ???????????????????
  1725. class BrLevelDialog : EventDialog {
  1726. private:
  1727. Spinner _lev;
  1728. Button[2] _ave;
  1729. public:
  1730. this (Commons comm, Props prop, Shell shell, Summary summ, Content parent, Content evt) { mixin(S_TRACE);
  1731. super (comm, prop, shell, summ, CType.BRANCH_LEVEL, parent, evt, false, null, true);
  1732. }
  1733. protected:
  1734. override void setup(Composite area) { mixin(S_TRACE);
  1735. area.setLayout(new GridLayout(2, false));
  1736. { mixin(S_TRACE);
  1737. auto grp = new Group(area, SWT.NONE);
  1738. grp.setText(_prop.msgs.judgeTarget);
  1739. grp.setLayoutData(new GridData(GridData.FILL_BOTH));
  1740. grp.setLayout(new CenterLayout);
  1741. auto comp = new Composite(grp, SWT.NONE);
  1742. comp.setLayout(zeroMarginGridLayout(1, true));
  1743. _ave[1] = new Button(comp, SWT.RADIO);
  1744. mod(_ave[1]);
  1745. _ave[1].setText(_prop.msgs.selectedLevel);
  1746. _ave[0] = new Button(comp, SWT.RADIO);
  1747. mod(_ave[0]);
  1748. _ave[0].setText(_prop.msgs.allMemberLevel);
  1749. }
  1750. { mixin(S_TRACE);
  1751. auto grp = new Group(area, SWT.NONE);
  1752. grp.setText(_prop.msgs.judgeLevel);
  1753. grp.setLayoutData(new GridData(GridData.FILL_BOTH));
  1754. grp.setLayout(new CenterLayout);
  1755. auto comp = new Composite(grp, SWT.NONE);
  1756. comp.setLayout(zeroMarginGridLayout(2, false));
  1757. _lev = new Spinner(comp, SWT.BORDER);
  1758. initSpinner(_lev);
  1759. mod(_lev);
  1760. _lev.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  1761. _lev.setMinimum(1);
  1762. _lev.setMaximum(_prop.var.etc.castLevelMax);
  1763. auto l = new Label(comp, SWT.NONE);
  1764. l.setText(.tryFormat(_prop.msgs.rangeHint, _lev.getMinimum(), _lev.getMaximum()));
  1765. }
  1766. ignoreMod = true;
  1767. scope (exit) ignoreMod = false;
  1768. if (_evt) { mixin(S_TRACE);
  1769. _ave[_evt.average ? 0 : 1].setSelection(true);
  1770. _lev.setSelection(_evt.unsignedLevel);
  1771. } else { mixin(S_TRACE);
  1772. _ave[1].setSelection(true);
  1773. _lev.setSelection(1);
  1774. }
  1775. }
  1776. override bool apply() { mixin(S_TRACE);
  1777. if (!_evt) _evt = new Content(CType.BRANCH_LEVEL, "");
  1778. _evt.average = _ave[0].getSelection();
  1779. _evt.unsignedLevel = _lev.getSelection();
  1780. return true;
  1781. }
  1782. }
  1783. private Composite createStatusPane(Props prop, Composite area, ref Button[Status] stat, void delegate(Button) mod) { mixin(S_TRACE);
  1784. auto grp = new Group(area, SWT.NONE);
  1785. grp.setText(prop.msgs.judgeState);
  1786. grp.setLayout(new GridLayout(4, true));
  1787. auto statuses = [Status.ACTIVE, Status.INACTIVE, Status.ALIVE, Status.DEAD,
  1788. Status.FINE, Status.INJURED, Status.HEAVY_INJURED, Status.UNCONSCIOUS,
  1789. Status.POISON, Status.SLEEP, Status.BIND, Status.PARALYZE,
  1790. Status.CONFUSE, Status.OVERHEAT, Status.BRAVE, Status.PANIC,
  1791. Status.SILENCE, Status.FACE_UP, Status.ANTI_MAGIC,
  1792. Status.UP_ACTION, Status.UP_AVOID, Status.UP_RESIST, Status.UP_DEFENSE,
  1793. Status.DOWN_ACTION, Status.DOWN_AVOID, Status.DOWN_RESIST, Status.DOWN_DEFENSE];
  1794. foreach (s; statuses) { mixin(S_TRACE);
  1795. auto radio = new Button(grp, SWT.RADIO);
  1796. mod(radio);
  1797. radio.setText(prop.msgs.statusName(s));
  1798. radio.setLayoutData(new GridData(GridData.FILL_BOTH));
  1799. stat[s] = radio;
  1800. }
  1801. return grp;
  1802. }
  1803. private Composite createStatusHint(Props prop, Composite area) { mixin(S_TRACE);
  1804. auto grp = new Group(area, SWT.NONE);
  1805. grp.setText(prop.msgs.stateHint);
  1806. grp.setLayout(new CenterLayout);
  1807. auto comp = new Composite(grp, SWT.NONE);
  1808. comp.setLayout(zeroMarginGridLayout(1, true));
  1809. auto hint1 = new Label(comp, SWT.NONE);
  1810. hint1.setText(prop.msgs.statusActive);
  1811. auto hint2 = new Label(comp, SWT.NONE);
  1812. hint2.setText(prop.msgs.statusInactive);
  1813. auto hint3 = new Label(comp, SWT.NONE);
  1814. hint3.setText(prop.msgs.statusAlive);
  1815. auto hint4 = new Label(comp, SWT.NONE);
  1816. hint4.setText(prop.msgs.statusDead);
  1817. return grp;
  1818. }
  1819. /// ????????????????
  1820. class BrStateDialog : EventDialog {
  1821. private:
  1822. Button[Target.M] _targ;
  1823. Button[Status] _stat;
  1824. override
  1825. protected void refreshWarning() { mixin(S_TRACE);
  1826. string[] ws;
  1827. if (!_prop.targetVersion("1.30")) { mixin(S_TRACE);
  1828. auto status = getRadioValue!(Status)(_stat);
  1829. if (Status.CONFUSE <= status) { mixin(S_TRACE);
  1830. if (Status.SILENCE <= status) { mixin(S_TRACE);
  1831. ws ~= .tryFormat(_prop.msgs.warningBranchStatusMental, _prop.msgs.statusName(status), "1.50");
  1832. } else { mixin(S_TRACE);
  1833. ws ~= .tryFormat(_prop.msgs.warningBranchStatusMental, _prop.msgs.statusName(status), "1.30");
  1834. }
  1835. }
  1836. } else if (!_prop.targetVersion("1.50")) { mixin(S_TRACE);
  1837. auto status = getRadioValue!(Status)(_stat);
  1838. if (Status.SILENCE <= status) { mixin(S_TRACE);
  1839. ws ~= .tryFormat(_prop.msgs.warningBranchStatusMental, _prop.msgs.statusName(status), "1.50");
  1840. }
  1841. }
  1842. warning = ws;
  1843. }
  1844. public:
  1845. this (Commons comm, Props prop, Shell shell, Summary summ, Content parent, Content evt) { mixin(S_TRACE);
  1846. super (comm, prop, shell, summ, CType.BRANCH_STATUS, parent, evt, false, null, true);
  1847. }
  1848. protected:
  1849. override void setup(Composite area) { mixin(S_TRACE);
  1850. area.setLayout(new GridLayout(1, false));
  1851. { mixin(S_TRACE);
  1852. auto grp = new Group(area, SWT.NONE);
  1853. grp.setText(_prop.msgs.judgeTarget);
  1854. grp.setLayoutData(new GridData(GridData.FILL_BOTH));
  1855. grp.setLayout(new GridLayout(3, true));
  1856. foreach (m; [Target.M.SELECTED, Target.M.RANDOM, Target.M.PARTY]) { mixin(S_TRACE);
  1857. auto radio = new Button(grp, SWT.RADIO);
  1858. mod(radio);
  1859. radio.setText(_prop.msgs.targetName(m));
  1860. radio.setLayoutData(new GridData(GridData.FILL_BOTH));
  1861. _targ[m] = radio;
  1862. }
  1863. }
  1864. auto status = createStatusPane(prop, area, _stat, &mod!Button);
  1865. status.setLayoutData(new GridData(GridData.FILL_BOTH));
  1866. foreach (st, b; _stat) { mixin(S_TRACE);
  1867. .listener(b, SWT.Selection, &refreshWarning);
  1868. }
  1869. auto hint = createStatusHint(prop, area);
  1870. hint.setLayoutData(new GridData(GridData.FILL_BOTH));
  1871. ignoreMod = true;
  1872. scope (exit) ignoreMod = false;
  1873. if (_evt) { mixin(S_TRACE);
  1874. _targ[_evt.targetNS.m].setSelection(true);
  1875. _stat[_evt.status].setSelection(true);
  1876. } else { mixin(S_TRACE);
  1877. _targ[Target.M.SELECTED].setSelection(true);
  1878. _stat[Status.ACTIVE].setSelection(true);
  1879. }
  1880. refreshWarning();
  1881. }
  1882. override bool apply() { mixin(S_TRACE);
  1883. if (!_evt) _evt = new Content(CType.BRANCH_STATUS, "");
  1884. auto targ = Target(getRadioValue!(Target.M)(_targ), false);
  1885. _evt.targetNS = targ;
  1886. _evt.status = getRadioValue!(Status)(_stat);
  1887. return true;
  1888. }
  1889. }
  1890. /// ?????????????????????????
  1891. private class CardEventDialog(CType Type, C : EffectCard, string Cards, bool Delete, Range RangeDef) : EventDialog {
  1892. private:
  1893. Spinner _num;
  1894. static if (Delete) {
  1895. Button _allDel;
  1896. class DelSListener : SelectionAdapter {
  1897. override void widgetSelected(SelectionEvent e) { mixin(S_TRACE);
  1898. _num.setEnabled(!_allDel.getSelection());
  1899. }
  1900. }
  1901. }
  1902. Button[Range] _range;
  1903. Table _list;
  1904. IncSearch _incSearch;
  1905. void incSearch() { mixin(S_TRACE);
  1906. .forceFocus(_list, true);
  1907. _incSearch.startIncSearch();
  1908. }
  1909. ulong _selectedID = 0;
  1910. void selected() { mixin(S_TRACE);
  1911. auto index = _list.getSelectionIndex();
  1912. if (-1 != index) { mixin(S_TRACE);
  1913. _selectedID = (cast(C) _list.getItem(index).getData()).id;
  1914. }
  1915. }
  1916. void refreshList() { mixin(S_TRACE);
  1917. ulong id = _selectedID;
  1918. _list.removeAll();
  1919. size_t i = 0;
  1920. foreach (c; mixin (Cards)) { mixin(S_TRACE);
  1921. if (!_incSearch.match(c.name)) continue;
  1922. auto itm = new TableItem(_list, SWT.NONE);
  1923. itm.setData(c);
  1924. static if (is (C == SkillCard)) {
  1925. itm.setImage(0, _prop.images.skill);
  1926. } else static if (is (C == ItemCard)) {
  1927. itm.setImage(0, _prop.images.item);
  1928. } else static if (is (C == BeastCard)) {
  1929. itm.setImage(0, _prop.images.beast);
  1930. } else { mixin(S_TRACE);
  1931. static assert (0);
  1932. }
  1933. itm.setText(0, to!(string)(c.id));
  1934. itm.setText(1, c.name);
  1935. if (id == c.id) _list.select(i);
  1936. i++;
  1937. }
  1938. _list.showSelection();
  1939. }
  1940. class Dispose : DisposeListener {
  1941. override void widgetDisposed(DisposeEvent e) { mixin(S_TRACE);
  1942. static if (is (C == SkillCard)) {
  1943. _comm.refSkill.remove(&refCard);
  1944. _comm.delSkill.remove(&delCard);
  1945. } else static if (is (C == ItemCard)) {
  1946. _comm.refItem.remove(&refCard);
  1947. _comm.delItem.remove(&delCard);
  1948. } else static if (is (C == BeastCard)) {
  1949. _comm.refBeast.remove(&refCard);
  1950. _comm.delBeast.remove(&delCard);
  1951. } else static assert (0);
  1952. }
  1953. }
  1954. void refCard(C c) { mixin(S_TRACE);
  1955. refreshList();
  1956. }
  1957. void delCard(C c) { mixin(S_TRACE);
  1958. auto cards = mixin (Cards);
  1959. if (cards.length) { mixin(S_TRACE);
  1960. refreshList();
  1961. } else { mixin(S_TRACE);
  1962. forceCancel();
  1963. }
  1964. }
  1965. void openView() { mixin(S_TRACE);
  1966. auto i = _list.getSelectionIndex();
  1967. if (-1 == i) return;
  1968. auto a = cast(C) _list.getItem(i).getData();
  1969. try { mixin(S_TRACE);
  1970. _comm.openCWXPath(cpaddattr(a.cwxPath(true), "shallow"), false);
  1971. } catch (Exception e) {
  1972. debugln(e);
  1973. }
  1974. }
  1975. class OpenView : MouseAdapter {
  1976. override void mouseDoubleClick(MouseEvent e) { mixin(S_TRACE);
  1977. if (1 != e.button) return;
  1978. openView();
  1979. }
  1980. }
  1981. public:
  1982. this (Commons comm, Props prop, Shell shell, Summary summ, Content parent, Content evt) { mixin(S_TRACE);
  1983. super (comm, prop, shell, summ, Type, parent, evt, true, prop.var.cardEvtDlg, true);
  1984. }
  1985. protected:
  1986. override void setup(Composite area) { mixin(S_TRACE);
  1987. area.setLayout(new GridLayout(2, false));
  1988. { mixin(S_TRACE);
  1989. auto comp = new Composite(area, SWT.NONE);
  1990. comp.setLayoutData(new GridData(GridData.FILL_VERTICAL));
  1991. comp.setLayout(zeroMarginGridLayout(1, true));
  1992. { mixin(S_TRACE);
  1993. auto grp = new Group(comp, SWT.NONE);
  1994. grp.setText(_prop.msgs.cardNumber);
  1995. grp.setLayoutData(new GridData(GridData.FILL_BOTH));
  1996. auto cl = new CenterLayout(SWT.HORIZONTAL | SWT.VERTICAL, 0);
  1997. cl.fillHorizontal = true;
  1998. grp.setLayout(cl);
  1999. auto comp2 = new Composite(grp, SWT.NONE);
  2000. comp2.setLayout(new GridLayout(2, false));
  2001. _num = new Spinner(comp2, SWT.BORDER);
  2002. initSpinner(_num);
  2003. mod(_num);
  2004. _num.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  2005. _num.setMinimum(1);
  2006. _num.setMaximum(_prop.var.etc.cardNumberMax);
  2007. auto l = new Label(comp2, SWT.NONE);
  2008. l.setText(.tryFormat(_prop.msgs.rangeHint, _num.getMinimum(), _num.getMaximum()));
  2009. static if (Delete) {
  2010. _allDel = new Button(comp2, SWT.CHECK);
  2011. mod(_allDel);
  2012. _allDel.setText(_prop.msgs.cardAllDelete);
  2013. auto gd = new GridData;
  2014. gd.horizontalSpan = 2;
  2015. _allDel.setLayoutData(gd);
  2016. _allDel.addSelectionListener(new DelSListener);
  2017. }
  2018. }
  2019. { mixin(S_TRACE);
  2020. auto grp = new Group(comp, SWT.NONE);
  2021. grp.setText(_prop.msgs.cardEventRange);
  2022. grp.setLayoutData(new GridData(GridData.FILL_BOTH));
  2023. grp.setLayout(new GridLayout(1, true));
  2024. foreach (r; [Range.SELECTED, Range.RANDOM, Range.PARTY,
  2025. Range.BACKPACK, Range.PARTY_AND_BACKPACK, Range.FIELD]) { mixin(S_TRACE);
  2026. auto radio = new Button(grp, SWT.RADIO);
  2027. mod(radio);
  2028. radio.setText(_prop.msgs.rangeName(r));
  2029. radio.setLayoutData(new GridData(GridData.FILL_BOTH));
  2030. _range[r] = radio;
  2031. }
  2032. }
  2033. }
  2034. { mixin(S_TRACE);
  2035. _list = new Table(area, SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL);
  2036. mod(_list);
  2037. _incSearch = new IncSearch(comm, _list);
  2038. _incSearch.modEvent ~= &refreshList;
  2039. auto idCol = new TableColumn(_list, SWT.NONE);
  2040. saveColumnWidth!("prop.var.etc.idColumn")(_prop, idCol);
  2041. auto nameCol = new FullTableColumn(_list, SWT.NONE);
  2042. auto gd = new GridData(GridData.FILL_BOTH);
  2043. gd.widthHint = _prop.var.etc.nameTableWidth;
  2044. gd.heightHint = _prop.var.etc.nameTableHeight;
  2045. _list.setLayoutData(gd);
  2046. .listener(_list, SWT.Selection, &selected);
  2047. _list.addMouseListener(new OpenView);
  2048. auto menu = new Menu(_list.getShell(), SWT.POP_UP);
  2049. createMenuItem(comm, menu, MenuID.IncSearch, &incSearch, null);
  2050. new MenuItem(menu, SWT.SEPARATOR);
  2051. createMenuItem(comm, menu, MenuID.OpenAtCardView, &openView, () => _list.getSelectionIndex() != -1);
  2052. _list.setMenu(menu);
  2053. refreshList();
  2054. }
  2055. static if (is (C == SkillCard)) {
  2056. _comm.refSkill.add(&refCard);
  2057. _comm.delSkill.add(&delCard);
  2058. } else static if (is (C == ItemCard)) {
  2059. _comm.refItem.add(&refCard);
  2060. _comm.delItem.add(&delCard);
  2061. } else static if (is (C == BeastCard)) {
  2062. _comm.refBeast.add(&refCard);
  2063. _comm.delBeast.add(&delCard);
  2064. } else static assert (0);
  2065. _list.addDisposeListener(new Dispose);
  2066. ignoreMod = true;
  2067. scope (exit) ignoreMod = false;
  2068. if (_evt) { mixin(S_TRACE);
  2069. static if (is (C == SkillCard)) {
  2070. _selectedID = _evt.skill;
  2071. } else static if (is (C == ItemCard)) {
  2072. _selectedID = _evt.item;
  2073. } else static if (is (C == BeastCard)) {
  2074. _selectedID = _evt.beast;
  2075. } else { mixin(S_TRACE);
  2076. static assert (0);
  2077. }
  2078. foreach (i, itm; _list.getItems()) { mixin(S_TRACE);
  2079. if (_selectedID == (cast(C) itm.getData()).id) { mixin(S_TRACE);
  2080. _list.select(i);
  2081. break;
  2082. }
  2083. }
  2084. static if (Delete) {
  2085. if (_evt.cardNumber == 0u) { mixin(S_TRACE);
  2086. _allDel.setSelection(true);
  2087. _num.setSelection(1);
  2088. _num.setEnabled(false);
  2089. } else { mixin(S_TRACE);
  2090. _allDel.setSelection(false);
  2091. _num.setSelection(_evt.cardNumber);
  2092. }
  2093. } else { mixin(S_TRACE);
  2094. _num.setSelection(_evt.cardNumber);
  2095. }
  2096. _range[_evt.range].setSelection(true);
  2097. } else { mixin(S_TRACE);
  2098. static if (Delete) {
  2099. _allDel.setSelection(false);
  2100. }
  2101. _num.setSelection(1);
  2102. _range[RangeDef].setSelection(true);
  2103. }
  2104. assert (_list.getItemCount());
  2105. if (-1 == _list.getSelectionIndex()) { mixin(S_TRACE);
  2106. _list.select(0);
  2107. _selectedID = (cast(C) _list.getItem(0).getData()).id;
  2108. }
  2109. }
  2110. override bool apply() { mixin(S_TRACE);
  2111. assert (_list.getItemCount());
  2112. if (!_evt) _evt = new Content(Type, "");
  2113. static if (is (C == SkillCard)) {
  2114. _evt.skill = _selectedID;
  2115. } else static if (is (C == ItemCard)) {
  2116. _evt.item = _selectedID;
  2117. } else static if (is (C == BeastCard)) {
  2118. _evt.beast = _selectedID;
  2119. } else { mixin(S_TRACE);
  2120. static assert (0);
  2121. }
  2122. _evt.range = getRadioValue!(Range)(_range);
  2123. static if (Delete) {
  2124. if (_allDel.getSelection()) { mixin(S_TRACE);
  2125. _evt.cardNumber = 0u;
  2126. } else { mixin(S_TRACE);
  2127. _evt.cardNumber = _num.getSelection();
  2128. }
  2129. } else { mixin(S_TRACE);
  2130. _evt.cardNumber = _num.getSelection();
  2131. }
  2132. return true;
  2133. }
  2134. }
  2135. alias CardEventDialog!(CType.BRANCH_SKILL, SkillCard, "_summ.skills", false, Range.FIELD) BrSkillDialog;
  2136. alias CardEventDialog!(CType.BRANCH_ITEM, ItemCard, "_summ.items", false, Range.FIELD) BrItemDialog;
  2137. alias CardEventDialog!(CType.BRANCH_BEAST, BeastCard, "_summ.beasts", false, Range.FIELD) BrBeastDialog;
  2138. alias CardEventDialog!(CType.GET_SKILL, SkillCard, "_summ.skills", false, Range.SELECTED) GetSkillDialog;
  2139. alias CardEventDialog!(CType.GET_ITEM, ItemCard, "_summ.items", false, Range.SELECTED) GetItemDialog;
  2140. alias CardEventDialog!(CType.GET_BEAST, BeastCard, "_summ.beasts", false, Range.SELECTED) GetBeastDialog;
  2141. alias CardEventDialog!(CType.LOSE_SKILL, SkillCard, "_summ.skills", true, Range.FIELD) LostSkillDialog;
  2142. alias CardEventDialog!(CType.LOSE_ITEM, ItemCard, "_summ.items", true, Range.FIELD) LostItemDialog;
  2143. alias CardEventDialog!(CType.LOSE_BEAST, BeastCard, "_summ.beasts", true, Range.FIELD) LostBeastDialog;
  2144. /// ?????????????????????
  2145. class RefreshDialog : EventDialog {
  2146. private:
  2147. Combo _ts;
  2148. Spinner _tsSpeed;
  2149. Transition[int] _tsTbl;
  2150. public:
  2151. this (Commons comm, Props prop, Shell shell, Summary summ, Content parent, Content evt) { mixin(S_TRACE);
  2152. super (comm, prop, shell, summ, CType.REDISPLAY, parent, evt, false, null, true);
  2153. }
  2154. protected:
  2155. override void setup(Composite area) { mixin(S_TRACE);
  2156. area.setLayout(new GridLayout(1, false));
  2157. { mixin(S_TRACE);
  2158. auto grp = new Group(area, SWT.NONE);
  2159. grp.setText(_prop.msgs.transitionType);
  2160. grp.setLayoutData(new GridData(GridData.FILL_BOTH));
  2161. grp.setLayout(new CenterLayout);
  2162. auto comp = new Composite(grp, SWT.NONE);
  2163. comp.setLayout(zeroMarginGridLayout(3, false));
  2164. auto lt = new Label(comp, SWT.NONE);
  2165. lt.setText(_prop.msgs.transition);
  2166. _ts = new Combo(comp, SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY);
  2167. mod(_ts);
  2168. auto gd = new GridData;
  2169. gd.horizontalSpan = 2;
  2170. _ts.setLayoutData(gd);
  2171. _ts.setVisibleItemCount(prop.var.etc.comboVisibleItemCount);
  2172. foreach (i, t; ALL_TRANSITION) { mixin(S_TRACE);
  2173. _ts.add(_prop.msgs.transitionName(t));
  2174. _tsTbl[i] = t;
  2175. if (_evt && t == _evt.transition) _ts.select(i);
  2176. }
  2177. auto ls = new Label(comp, SWT.NONE);
  2178. ls.setText(_prop.msgs.transitionSpeed);
  2179. _tsSpeed = new Spinner(comp, SWT.BORDER);
  2180. initSpinner(_tsSpeed);
  2181. mod(_tsSpeed);
  2182. _tsSpeed.setMaximum(Content.transitionSpeed_max);
  2183. _tsSpeed.setMinimum(Content.transitionSpeed_min);
  2184. auto hint = new Label(comp, SWT.NONE);
  2185. hint.setText(.tryFormat(_prop.msgs.rangeHint, Content.transitionSpeed_min, Content.transitionSpeed_max));
  2186. }
  2187. ignoreMod = true;
  2188. scope (exit) ignoreMod = false;
  2189. if (_evt) { mixin(S_TRACE);
  2190. _tsSpeed.setSelection(_evt.transitionSpeed);
  2191. } else { mixin(S_TRACE);
  2192. _ts.select(0);
  2193. _tsSpeed.setSelection(.transitionSpeedDef);
  2194. }
  2195. }
  2196. override bool apply() { mixin(S_TRACE);
  2197. if (!_evt) _evt = new Content(CType.REDISPLAY, "");
  2198. auto ts = _tsTbl[_ts.getSelectionIndex()];
  2199. uint tsSpeed = _tsSpeed.getSelection();
  2200. _evt.transition = ts;
  2201. _evt.transitionSpeed = tsSpeed;
  2202. return true;
  2203. }
  2204. }
  2205. /// ????????????????????
  2206. class BrRandomSelectDialog : EventDialog {
  2207. private:
  2208. Button[CastRange] _castRange;
  2209. Button _hasLevel, _hasStatus;
  2210. Spinner _levMin, _levMax;
  2211. Button[Status] _status;
  2212. override
  2213. protected void refreshWarning() { mixin(S_TRACE);
  2214. string[] ws;
  2215. if (!_prop.targetVersion("1.30")) { mixin(S_TRACE);
  2216. ws ~= .tryFormat(_prop.msgs.warningUnknownContent, _prop.msgs.contentName(CType.BRANCH_RANDOM_SELECT), "1.30");
  2217. } else if (!_prop.targetVersion("1.50")) { mixin(S_TRACE);
  2218. auto status = getRadioValue!(Status)(_status);
  2219. if (Status.SILENCE <= status) { mixin(S_TRACE);
  2220. ws ~= .tryFormat(_prop.msgs.warningBranchStatusMental, _prop.msgs.statusName(status), "1.50");
  2221. }
  2222. }
  2223. warning = ws;
  2224. }
  2225. void levMaxEnter(int enter) { mixin(S_TRACE);
  2226. if (enter > 0 && _levMin.getSelection() != 0 && enter < _levMin.getSelection()) { mixin(S_TRACE);
  2227. _levMin.setSelection(enter);
  2228. }
  2229. }
  2230. void levMinEnter(int enter) { mixin(S_TRACE);
  2231. if (enter > 0 && _levMax.getSelection() != 0 && enter > _levMax.getSelection()) { mixin(S_TRACE);
  2232. _levMax.setSelection(enter);
  2233. }
  2234. }
  2235. void updateEnabled() { mixin(S_TRACE);
  2236. _levMin.setEnabled(_hasLevel.getSelection());
  2237. _levMax.setEnabled(_hasLevel.getSelection());
  2238. foreach (key, b; _status) { mixin(S_TRACE);
  2239. b.setEnabled(_hasStatus.getSelection());
  2240. }
  2241. }
  2242. public:
  2243. this (Commons comm, Props prop, Shell shell, Summary summ, Content parent, Content evt) { mixin(S_TRACE);
  2244. super (comm, prop, shell, summ, CType.BRANCH_RANDOM_SELECT, parent, evt, false, null, true);
  2245. }
  2246. protected:
  2247. override void setup(Composite area) { mixin(S_TRACE);
  2248. area.setLayout(new GridLayout(1, false));
  2249. { mixin(S_TRACE);
  2250. auto grp = new Group(area, SWT.NONE);
  2251. grp.setText(_prop.msgs.selectMember);
  2252. grp.setLayoutData(new GridData(GridData.FILL_BOTH));
  2253. grp.setLayout(new GridLayout(3, true));
  2254. foreach (r; EnumMembers!CastRange) { mixin(S_TRACE);
  2255. auto radio = new Button(grp, SWT.CHECK);
  2256. mod(radio);
  2257. radio.setText(prop.msgs.castRangeName(r));
  2258. radio.setLayoutData(new GridData(GridData.FILL_BOTH));
  2259. _castRange[r] = radio;
  2260. }
  2261. auto sep = new Label(grp, SWT.SEPARATOR | SWT.HORIZONTAL);
  2262. auto sgd = new GridData(GridData.FILL_HORIZONTAL);
  2263. sgd.horizontalSpan = 3;
  2264. sep.setLayoutData(sgd);
  2265. _hasLevel = new Button(grp, SWT.CHECK);
  2266. mod(_hasLevel);
  2267. _hasLevel.setText(prop.msgs.randomSelectHasLevel);
  2268. _hasLevel.setLayoutData(new GridData(GridData.FILL_BOTH));
  2269. .listener(_hasLevel, SWT.Selection, &updateEnabled);
  2270. _hasStatus = new Button(grp, SWT.CHECK);
  2271. mod(_hasStatus);
  2272. _hasStatus.setText(prop.msgs.randomSelectHasStatus);
  2273. _hasStatus.setLayoutData(new GridData(GridData.FILL_BOTH));
  2274. .listener(_hasStatus, SWT.Selection, &updateEnabled);
  2275. }
  2276. { mixin(S_TRACE);
  2277. auto grp = new Group(area, SWT.NONE);
  2278. grp.setText(_prop.msgs.targetLevel);
  2279. grp.setLayoutData(new GridData(GridData.FILL_BOTH));
  2280. grp.setLayout(new CenterLayout);
  2281. auto comp = new Composite(grp, SWT.NONE);
  2282. comp.setLayout(zeroMarginGridLayout(4, false));
  2283. _levMin = new Spinner(comp, SWT.BORDER);
  2284. initSpinner(_levMin);
  2285. mod(_levMin);
  2286. _levMin.setMinimum(1);
  2287. _levMin.setMaximum(_prop.var.etc.castLevelMax);
  2288. new SpinnerEdit(_levMin, &levMinEnter);
  2289. auto lbl = new Label(comp, SWT.NONE);
  2290. lbl.setText(_prop.msgs.levSep);
  2291. _levMax = new Spinner(comp, SWT.BORDER);
  2292. initSpinner(_levMax);
  2293. mod(_levMax);
  2294. _levMax.setMinimum(1);
  2295. _levMax.setMaximum(_prop.var.etc.castLevelMax);
  2296. new SpinnerEdit(_levMax, &levMaxEnter);
  2297. auto lHint = new Label(comp, SWT.NONE);
  2298. lHint.setText(.tryFormat(_prop.msgs.rangeHint, 1, _prop.var.etc.castLevelMax));
  2299. }
  2300. auto status = createStatusPane(prop, area, _status, &mod!Button);
  2301. status.setLayoutData(new GridData(GridData.FILL_BOTH));
  2302. auto hint = createStatusHint(prop, area);
  2303. hint.setLayoutData(new GridData(GridData.FILL_BOTH));
  2304. ignoreMod = true;
  2305. scope (exit) ignoreMod = false;
  2306. if (_evt) { mixin(S_TRACE);
  2307. foreach (e; _evt.castRange) { mixin(S_TRACE);
  2308. _castRange[e].setSelection(true);
  2309. }
  2310. _hasLevel.setSelection(0 < _evt.levelMax);
  2311. _hasStatus.setSelection(Status.NONE !is _evt.status);
  2312. if (_hasLevel.getSelection()) { mixin(S_TRACE);
  2313. _levMin.setSelection(_evt.levelMin);
  2314. _levMax.setSelection(_evt.levelMax);
  2315. } else { mixin(S_TRACE);
  2316. _levMin.setSelection(1);
  2317. _levMax.setSelection(1);
  2318. }
  2319. if (_hasStatus.getSelection()) { mixin(S_TRACE);
  2320. _status[_evt.status].setSelection(true);
  2321. } else { mixin(S_TRACE);
  2322. _status[Status.ACTIVE].setSelection(true);
  2323. }
  2324. } else { mixin(S_TRACE);
  2325. _castRange[CastRange.PARTY].setSelection(true);
  2326. _hasLevel.setSelection(false);
  2327. _hasStatus.setSelection(false);
  2328. _levMin.setSelection(1);
  2329. _levMax.setSelection(1);
  2330. _status[Status.ACTIVE].setSelection(true);
  2331. }
  2332. updateEnabled();
  2333. refreshWarning();
  2334. }
  2335. override bool apply() { mixin(S_TRACE);
  2336. if (!_evt) _evt = new Content(CType.BRANCH_RANDOM_SELECT, "");
  2337. CastRange[] range;
  2338. foreach (e, b; _castRange) { mixin(S_TRACE);
  2339. if (b.getSelection()) range ~= e;
  2340. }
  2341. _evt.castRange = range;
  2342. bool hasLevel = _hasLevel.getSelection();
  2343. bool hasStatus = _hasStatus.getSelection();
  2344. if (hasLevel) { mixin(S_TRACE);
  2345. _evt.levelMin = _levMin.getSelection();
  2346. _evt.levelMax = _levMax.getSelection();
  2347. } else { mixin(S_TRACE);
  2348. _evt.levelMin = 0;
  2349. _evt.levelMax = 0;
  2350. }
  2351. if (hasStatus) { mixin(S_TRACE);
  2352. _evt.status = getRadioValue!(Status)(_status);
  2353. } else { mixin(S_TRACE);
  2354. _evt.status = Status.NONE;
  2355. }
  2356. return true;
  2357. }
  2358. }
  2359. /// ?????????????????????
  2360. class BrKeyCodeDialog : EventDialog {
  2361. private:
  2362. Button[Range] _keyCodeRange;
  2363. Button[EffectCardType] _effectCardType;
  2364. Combo _keyCode;
  2365. override
  2366. protected void refreshWarning() { mixin(S_TRACE);
  2367. string[] ws;
  2368. if (!_prop.targetVersion("1.50")) { mixin(S_TRACE);
  2369. ws ~= .tryFormat(_prop.msgs.warningUnknownContent, _prop.msgs.contentName(CType.BRANCH_KEY_CODE), "1.50");
  2370. }
  2371. warning = ws;
  2372. }
  2373. public:
  2374. this (Commons comm, Props prop, Shell shell, Summary summ, Content parent, Content evt) { mixin(S_TRACE);
  2375. super (comm, prop, shell, summ, CType.BRANCH_KEY_CODE, parent, evt, false, null, true);
  2376. }
  2377. protected:
  2378. override void setup(Composite area) { mixin(S_TRACE);
  2379. area.setLayout(new GridLayout(2, false));
  2380. { mixin(S_TRACE);
  2381. auto grp = new Group(area, SWT.NONE);
  2382. grp.setText(_prop.msgs.range);
  2383. grp.setLayoutData(new GridData(GridData.FILL_BOTH));
  2384. grp.setLayout(new CenterLayout(SWT.HORIZONTAL));
  2385. auto comp = new Composite(grp, SWT.NONE);
  2386. comp.setLayout(zeroMarginGridLayout(1, true));
  2387. foreach (r; [Range.SELECTED, Range.RANDOM, Range.BACKPACK, Range.PARTY_AND_BACKPACK]) { mixin(S_TRACE);
  2388. auto radio = new Button(comp, SWT.RADIO);
  2389. mod(radio);
  2390. radio.setText(_prop.msgs.rangeName(r));
  2391. radio.setLayoutData(new GridData(GridData.FILL_BOTH));
  2392. _keyCodeRange[r] = radio;
  2393. }
  2394. }
  2395. { mixin(S_TRACE);
  2396. auto grp = new Group(area, SWT.NONE);
  2397. grp.setText(_prop.msgs.cardType);
  2398. grp.setLayoutData(new GridData(GridData.FILL_BOTH));
  2399. grp.setLayout(new CenterLayout(SWT.HORIZONTAL));
  2400. auto comp = new Composite(grp, SWT.NONE);
  2401. comp.setLayout(zeroMarginGridLayout(1, true));
  2402. foreach (r; [EffectCardType.ALL, EffectCardType.SKILL, EffectCardType.ITEM, EffectCardType.BEAST]) { mixin(S_TRACE);
  2403. auto radio = new Button(comp, SWT.RADIO);
  2404. mod(radio);
  2405. radio.setText(_prop.msgs.effectCardTypeName(r));
  2406. radio.setLayoutData(new GridData(GridData.FILL_BOTH));
  2407. _effectCardType[r] = radio;
  2408. }
  2409. }
  2410. { mixin(S_TRACE);
  2411. auto grp = new Group(area, SWT.NONE);
  2412. grp.setText(_prop.msgs.keyCode);
  2413. auto gd = new GridData(GridData.FILL_BOTH);
  2414. gd.horizontalSpan = 2;
  2415. grp.setLayoutData(gd);
  2416. grp.setLayout(new GridLayout(1, true));
  2417. _keyCode = createKeyCodeCombo(comm, summ, grp, &catchMod, _evt ? _evt.keyCode : "");
  2418. mod(_keyCode);
  2419. auto kgd = new GridData(GridData.FILL_HORIZONTAL);
  2420. kgd.widthHint = _prop.var.etc.nameWidth;
  2421. _keyCode.setLayoutData(kgd);
  2422. }
  2423. ignoreMod = true;
  2424. scope (exit) ignoreMod = false;
  2425. if (_evt) { mixin(S_TRACE);
  2426. _keyCodeRange[_evt.keyCodeRange].setSelection(true);
  2427. _effectCardType[_evt.effectCardType].setSelection(true);
  2428. _keyCode.setText(_evt.keyCode);
  2429. } else { mixin(S_TRACE);
  2430. _keyCodeRange[Range.SELECTED].setSelection(true);
  2431. _effectCardType[EffectCardType.ALL].setSelection(true);
  2432. _keyCode.setText("");
  2433. }
  2434. refreshWarning();
  2435. }
  2436. override bool apply() { mixin(S_TRACE);
  2437. if (!_evt) _evt = new Content(CType.BRANCH_KEY_CODE, "");
  2438. _evt.keyCode = _keyCode.getText();
  2439. _evt.keyCodeRange = getRadioValue!(Range)(_keyCodeRange);
  2440. _evt.effectCardType = getRadioValue!(EffectCardType)(_effectCardType);
  2441. _comm.refKeyCodes.call();
  2442. return true;
  2443. }
  2444. }
  2445. /// ??????????????????
  2446. class BranchRoundDialog : EventDialog {
  2447. private:
  2448. override
  2449. protected void refreshWarning() { mixin(S_TRACE);
  2450. string[] ws;
  2451. if (!_prop.targetVersion("1.50")) { mixin(S_TRACE);
  2452. ws ~= .tryFormat(_prop.msgs.warningUnknownContent, _prop.msgs.contentName(CType.BRANCH_ROUND), "1.50");
  2453. }
  2454. warning = ws;
  2455. }
  2456. Spinner _value;
  2457. Combo _cmp;
  2458. Comparison3[] _cmps;
  2459. public:
  2460. this (Commons comm, Props prop, Shell shell, Summary summ, Content parent, Content evt) { mixin(S_TRACE);
  2461. super (comm, prop, shell, summ, CType.BRANCH_ROUND, parent, evt, false, null, true);
  2462. }
  2463. protected:
  2464. override void setup(Composite area) { mixin(S_TRACE);
  2465. area.setLayout(new GridLayout(1, false));
  2466. { mixin(S_TRACE);
  2467. auto grp = new Group(area, SWT.NONE);
  2468. grp.setLayoutData(new GridData(GridData.FILL_BOTH));
  2469. grp.setText(prop.msgs.roundCondition);
  2470. grp.setLayout(new CenterLayout(SWT.VERTICAL | SWT.HORIZONTAL, 0));
  2471. auto comp = new Composite(grp, SWT.NONE);
  2472. comp.setLayout(new GridLayout(4, false));
  2473. auto l1 = new Label(comp, SWT.NONE);
  2474. l1.setText(_prop.msgs.roundIs);
  2475. _value = new Spinner(comp, SWT.BORDER);
  2476. initSpinner(_value);
  2477. mod(_value);
  2478. _value.setMinimum(0);
  2479. _value.setMaximum(_prop.var.etc.roundMax);
  2480. auto l2 = new Label(comp, SWT.NONE);
  2481. l2.setText(_prop.msgs.roundCmpIs);
  2482. _cmp = new Combo(comp, SWT.READ_ONLY | SWT.DROP_DOWN | SWT.BORDER);
  2483. mod(_cmp);
  2484. _cmp.setVisibleItemCount(prop.var.etc.comboVisibleItemCount);
  2485. foreach (cmp; EnumMembers!Comparison3) { mixin(S_TRACE);
  2486. _cmp.add(prop.msgs.comparison3Name(cmp));
  2487. _cmps ~= cmp;
  2488. }
  2489. }
  2490. ignoreMod = true;
  2491. scope (exit) ignoreMod = false;
  2492. if (_evt) { mixin(S_TRACE);
  2493. _value.setSelection(_evt.round);
  2494. _cmp.select(_cmps.countUntil(_evt.comparison3));
  2495. } else { mixin(S_TRACE);
  2496. _value.setSelection(0);
  2497. _cmp.select(0);
  2498. }
  2499. refreshWarning();
  2500. }
  2501. override bool apply() { mixin(S_TRACE);
  2502. if (!_evt) _evt = new Content(CType.BRANCH_ROUND, "");
  2503. _evt.round = _value.getSelection();
  2504. _evt.comparison3 = _cmps[_cmp.getSelectionIndex()];
  2505. return true;
  2506. }
  2507. }
  2508. /// ?????????????????
  2509. class MoveBgImageDialog : EventDialog {
  2510. private:
  2511. Combo _cellName;
  2512. Button[CoordinateType] _positionType;
  2513. Spinner _x;
  2514. Spinner _y;
  2515. Button[CoordinateType] _sizeType;
  2516. Spinner _w;
  2517. Spinner _h;
  2518. override
  2519. protected void refreshWarning() { mixin(S_TRACE);
  2520. string[] ws;
  2521. if (!_prop.targetVersion("1.60")) { mixin(S_TRACE);
  2522. ws ~= .tryFormat(_prop.msgs.warningUnknownContent, _prop.msgs.contentName(type), "1.60");
  2523. }
  2524. warning = ws;
  2525. }
  2526. private void updateEnabled() { mixin(S_TRACE);
  2527. auto p = !_positionType[CoordinateType.None].getSelection();
  2528. _x.setEnabled(p);
  2529. _y.setEnabled(p);
  2530. auto s = !_sizeType[CoordinateType.None].getSelection();
  2531. _w.setEnabled(s);
  2532. _h.setEnabled(s);
  2533. }
  2534. public:
  2535. this (Commons comm, Props prop, Shell shell, Summary summ, Content parent, Content evt) { mixin(S_TRACE);
  2536. super (comm, prop, shell, summ, CType.MOVE_BG_IMAGE, parent, evt, false, null, true);
  2537. }
  2538. protected:
  2539. override void setup(Composite area) { mixin(S_TRACE);
  2540. area.setLayout(new GridLayout(2, true));
  2541. { mixin(S_TRACE);
  2542. auto grp = new Group(area, SWT.NONE);
  2543. auto ggd = new GridData(GridData.FILL_HORIZONTAL);
  2544. ggd.horizontalSpan = 2;
  2545. grp.setLayoutData(ggd);
  2546. grp.setLayout(new GridLayout(1, true));
  2547. grp.setText(prop.msgs.cellName);
  2548. _cellName = createCellNameCombo(comm, summ, grp, &catchMod, _evt ? _evt.cellName : "");
  2549. mod(_cellName);
  2550. _cellName.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  2551. }
  2552. void createGrp(string name, ref Button[CoordinateType] type, ref Spinner x, ref Spinner y, int max1, int max2) { mixin(S_TRACE);
  2553. auto grp = new Group(area, SWT.NONE);
  2554. grp.setLayoutData(new GridData(GridData.FILL_BOTH));
  2555. grp.setText(name);
  2556. grp.setLayout(new CenterLayout(SWT.VERTICAL | SWT.HORIZONTAL, 0));
  2557. auto comp = new Composite(grp, SWT.NONE);
  2558. comp.setLayout(new GridLayout(4, false));
  2559. void putRadio(CoordinateType ct) { mixin(S_TRACE);
  2560. auto radio = new Button(comp, SWT.RADIO);
  2561. mod(radio);
  2562. radio.setText(_prop.msgs.coordinateTypeName(ct));
  2563. .listener(radio, SWT.Selection, &updateEnabled);
  2564. auto gd = new GridData;
  2565. gd.horizontalSpan = 4;
  2566. radio.setLayoutData(gd);
  2567. type[ct] = radio;
  2568. }
  2569. foreach (ct; EnumMembers!CoordinateType) { mixin(S_TRACE);
  2570. putRadio(ct);
  2571. }
  2572. Spinner putSpinner(string name, int max) { mixin(S_TRACE);
  2573. auto l1 = new Label(comp, SWT.NONE);
  2574. l1.setText(name);
  2575. auto spn = new Spinner(comp, SWT.BORDER);
  2576. initSpinner(spn);
  2577. mod(spn);
  2578. spn.setMinimum(-max);
  2579. spn.setMaximum(max);
  2580. return spn;
  2581. }
  2582. x = putSpinner(prop.msgs.horizontalValue, max1);
  2583. y = putSpinner(prop.msgs.verticalValue, max2);
  2584. }
  2585. createGrp(prop.msgs.moveCell, _positionType, _x, _y, prop.var.etc.posLeftMax, prop.var.etc.posTopMax);
  2586. createGrp(prop.msgs.resizeCell, _sizeType, _w, _h, prop.var.etc.backWidthMax, prop.var.etc.backHeightMax);
  2587. ignoreMod = true;
  2588. scope (exit) ignoreMod = false;
  2589. if (_evt) { mixin(S_TRACE);
  2590. _cellName.setText(_evt.cellName);
  2591. _positionType[_evt.positionType].setSelection(true);
  2592. _x.setSelection(_evt.x);
  2593. _y.setSelection(_evt.y);
  2594. _sizeType[_evt.sizeType].setSelection(true);
  2595. _w.setSelection(_evt.width);
  2596. _h.setSelection(_evt.height);
  2597. } else { mixin(S_TRACE);
  2598. _cellName.setText("");
  2599. _positionType[CoordinateType.None].setSelection(true);
  2600. _x.setSelection(0);
  2601. _y.setSelection(0);
  2602. _sizeType[CoordinateType.None].setSelection(true);
  2603. _w.setSelection(0);
  2604. _h.setSelection(0);
  2605. }
  2606. updateEnabled();
  2607. refreshWarning();
  2608. }
  2609. override bool apply() { mixin(S_TRACE);
  2610. if (!_evt) _evt = new Content(type, "");
  2611. _evt.cellName = _cellName.getText();
  2612. _evt.positionType = getRadioValue(_positionType);
  2613. _evt.x = _x.getSelection();
  2614. _evt.y = _y.getSelection();
  2615. _evt.sizeType = getRadioValue(_sizeType);
  2616. _evt.width = _w.getSelection();
  2617. _evt.height = _h.getSelection();
  2618. return true;
  2619. }
  2620. }