PageRenderTime 58ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 1ms

/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

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

  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.CH

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