/cwxeditor_src/cwx/editor/gui/dwt/eventdialog.d
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
- module cwx.editor.gui.dwt.eventdialog;
- import cwx.summary;
- import cwx.area;
- import cwx.background;
- import cwx.card;
- import cwx.utils;
- import cwx.event;
- import cwx.types;
- import cwx.flag;
- import cwx.features;
- import cwx.usecounter;
- import cwx.skin;
- import cwx.path;
- import cwx.structs;
- import cwx.menu;
- import cwx.types;
- import cwx.editor.gui.sound;
- import cwx.editor.gui.dwt.areaview;
- import cwx.editor.gui.dwt.areaviewutils;
- import cwx.editor.gui.dwt.dskin;
- import cwx.editor.gui.dwt.dutils;
- import cwx.editor.gui.dwt.dprops;
- import cwx.editor.gui.dwt.commons;
- import cwx.editor.gui.dwt.centerlayout;
- import cwx.editor.gui.dwt.customtable;
- import cwx.editor.gui.dwt.materialselect;
- import cwx.editor.gui.dwt.motionview;
- import cwx.editor.gui.dwt.undo;
- import cwx.editor.gui.dwt.absdialog;
- import cwx.editor.gui.dwt.splitpane;
- import cwx.editor.gui.dwt.dmenu;
- import cwx.editor.gui.dwt.incsearch;
- import cwx.editor.gui.dwt.chooser;
- import std.algorithm : countUntil;
- import std.conv;
- import std.math;
- import std.path;
- import std.traits;
- import org.eclipse.swt.all;
- immutable transitionSpeedDef = Content.transitionSpeed_min + ((Content.transitionSpeed_max - Content.transitionSpeed_min) / 2);
- abstract class EventDialog : AbsDialog {
- private Commons _comm;
- private Props _prop;
- private Summary _summ;
- private Content _parent;
- private Content _evt;
- private CType _type;
- private class Dispose : DisposeListener {
- override void widgetDisposed(DisposeEvent e) { mixin(S_TRACE);
- _comm.delContent.remove(&delContent);
- _comm.refSkin.remove(&refSkin);
- _comm.refTargetVersion.remove(&refreshWarning);
- }
- }
- private void delContent(Content c) { mixin(S_TRACE);
- if ((_evt && _evt.isDescendant(c)) || (_parent && _parent.isDescendant(c))) { mixin(S_TRACE);
- forceCancel();
- }
- }
- protected void refreshWarning() { mixin(S_TRACE);
- // ????
- }
- 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);
- assert (!evt || evt.type is type);
- assert (summ);
- } body { mixin(S_TRACE);
- super (prop, shell, false, .tryFormat(prop.msgs.dlgTitContent, prop.msgs.contentName(type)), prop.images.content(type), resizable, size, true, true, [], rightGroup);
- enterClose = eClose;
- _comm = comm;
- _prop = prop;
- _summ = summ;
- _type = type;
- _parent = parent;
- _evt = evt;
- _comm.delContent.add(&delContent);
- _comm.refSkin.add(&refSkin);
- _comm.refTargetVersion.add(&refreshWarning);
- getShell().addDisposeListener(new Dispose);
- }
- @property
- Content event() { mixin(S_TRACE);
- return _evt;
- }
- @property protected Commons comm() {return _comm;}
- @property protected Props prop() {return _prop;}
- @property protected Summary summ() {return _summ;}
- @property protected Content evt() {return _evt;}
- @property protected void evt(Content evt) {_evt = evt;}
- @property protected CType type() {return _type;}
- protected void refSkin() {}
- bool openCWXPath(string path, bool shellActivate) { mixin(S_TRACE);
- return cpempty(path);
- }
- }
- class ContentCommentDialog : AbsDialog {
- private Commons _comm;
- private Props _prop;
- private Content _parent;
- private Content _evt;
- private Text _comment;
- private class Dispose : DisposeListener {
- override void widgetDisposed(DisposeEvent e) { mixin(S_TRACE);
- _comm.delContent.remove(&delContent);
- }
- }
- private void delContent(Content c) { mixin(S_TRACE);
- if ((_evt && _evt.isDescendant(c)) || (_parent && _parent.isDescendant(c))) { mixin(S_TRACE);
- forceCancel();
- }
- }
- this (Commons comm, Props prop, Shell shell, Content parent, Content evt) in { mixin(S_TRACE);
- assert (evt);
- } body { mixin(S_TRACE);
- super (prop, shell, false, prop.msgs.dlgTitComment, prop.images.menu(MenuID.Comment), true, prop.var.commentDlg, true);
- _comm = comm;
- _prop = prop;
- _parent = parent;
- _evt = evt;
- _comm.delContent.add(&delContent);
- getShell().addDisposeListener(new Dispose);
- }
- override void setup(Composite area) { mixin(S_TRACE);
- auto cl = new CenterLayout;
- cl.fillHorizontal = true;
- cl.fillVertical = true;
- area.setLayout(cl);
- _comment = new Text(area, SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
- mod(_comment);
- _comment.setText(_evt.comment);
- createTextMenu!Text(_comm, _prop, _comment, &catchMod);
- auto font = _comment.getFont();
- auto fSize = font ? cast(uint) font.getFontData()[0].height : 0;
- _comment.setFont(new Font(Display.getCurrent(), dwtData(_prop.looks.textDlgFont(fSize))));
- _comment.setSelection(to!dstring(_comment.getText()).length);
- closeEvent ~= () { mixin(S_TRACE);
- _comment.getFont().dispose();
- };
- }
- override bool apply() { mixin(S_TRACE);
- _evt.comment = lastRet(wrapReturnCode(_comment.getText()));
- return true;
- }
- }
- /// ?????????????????????????????????
- class AreaSelectDialog(CType Type, A, string Areas) : EventDialog {
- private:
- AreaChooser!(A, false) _list;
- static if (Type == CType.CHANGE_AREA) {
- Combo _ts;
- Spinner _tsSpeed;
- Transition[int] _tsTbl;
- }
- void delA(A a) { mixin(S_TRACE);
- auto summary = _summ;
- auto areas = mixin (Areas);
- if (!areas.length) { mixin(S_TRACE);
- forceCancel();
- }
- }
- class Dispose : DisposeListener {
- override void widgetDisposed(DisposeEvent e) { mixin(S_TRACE);
- static if (is(A : Area)) {
- _comm.delArea.remove(&delA);
- } else static if (is(A : Battle)) {
- _comm.delBattle.remove(&delA);
- } else static if (is(A : Package)) {
- _comm.delPackage.remove(&delA);
- } else static if (is(A : CastCard)) {
- _comm.delCast.remove(&delA);
- } else static if (is(A : InfoCard)) {
- _comm.delInfo.remove(&delA);
- } else static assert (0);
- }
- }
- protected override void refSkin() { mixin(S_TRACE);
- refreshTS();
- }
- void refreshTS() { mixin(S_TRACE);
- static if (Type == CType.CHANGE_AREA) {
- _ts.setEnabled(!_summ.legacy);
- _tsSpeed.setEnabled(!_summ.legacy);
- }
- }
- public:
- this (Commons comm, Props prop, Shell shell, Summary summ, Content parent, Content evt) { mixin(S_TRACE);
- super (comm, prop, shell, summ, Type, parent, evt, true, prop.var.selEvtDlg, true);
- }
- protected:
- override void setup(Composite area) { mixin(S_TRACE);
- area.setLayout(zeroGridLayout(1, false));
- { mixin(S_TRACE);
- auto listComp = new Composite(area, SWT.NONE);
- listComp.setLayout(new GridLayout(1, true));
- listComp.setLayoutData(new GridData(GridData.FILL_BOTH));
- _list = new AreaChooser!(A, false)(comm, summ, listComp);
- mod(_list);
- auto gd = new GridData(GridData.FILL_BOTH);
- gd.widthHint = _prop.var.etc.nameTableWidth;
- gd.heightHint = _prop.var.etc.nameTableHeight;
- _list.setLayoutData(gd);
- }
- static if (Type == CType.CHANGE_AREA) {
- { mixin(S_TRACE);
- auto sep = new Label(area, SWT.SEPARATOR | SWT.HORIZONTAL);
- sep.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- }
- { mixin(S_TRACE);
- auto comp = new Composite(area, SWT.NONE);
- comp.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
- comp.setLayout(new GridLayout(3, false));
- auto lt = new Label(comp, SWT.NONE);
- lt.setText(_prop.msgs.transition);
- _ts = new Combo(comp, SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY);
- mod(_ts);
- auto tgd = new GridData;
- tgd.horizontalSpan = 2;
- _ts.setLayoutData(tgd);
- _ts.setVisibleItemCount(prop.var.etc.comboVisibleItemCount);
- foreach (i, t; ALL_TRANSITION) { mixin(S_TRACE);
- _ts.add(_prop.msgs.transitionName(t));
- _tsTbl[i] = t;
- if (_evt && t == _evt.transition) _ts.select(i);
- }
- auto ls = new Label(comp, SWT.NONE);
- ls.setText(_prop.msgs.transitionSpeed);
- _tsSpeed = new Spinner(comp, SWT.BORDER);
- initSpinner(_tsSpeed);
- mod(_tsSpeed);
- _tsSpeed.setMaximum(Content.transitionSpeed_max);
- _tsSpeed.setMinimum(Content.transitionSpeed_min);
- auto hint = new Label(comp, SWT.NONE);
- hint.setText(.tryFormat(_prop.msgs.rangeHint, Content.transitionSpeed_min, Content.transitionSpeed_max));
- }
- if (_evt) { mixin(S_TRACE);
- _tsSpeed.setSelection(_evt.transitionSpeed);
- } else { mixin(S_TRACE);
- _ts.select(0);
- _tsSpeed.setSelection(.transitionSpeedDef);
- }
- refreshTS();
- }
- static if (is(A : Area)) {
- _comm.delArea.add(&delA);
- } else static if (is(A : Battle)) {
- _comm.delBattle.add(&delA);
- } else static if (is(A : Package)) {
- _comm.delPackage.add(&delA);
- } else static if (is(A : CastCard)) {
- _comm.delCast.add(&delA);
- } else static if (is(A : InfoCard)) {
- _comm.delInfo.add(&delA);
- } else static assert (0);
- _list.addDisposeListener(new Dispose);
- ignoreMod = true;
- scope (exit) ignoreMod = false;
- if (_evt) { mixin(S_TRACE);
- static if (Type == CType.CHANGE_AREA) {
- _list.selected = _evt.area;
- } else static if (Type == CType.START_BATTLE) {
- _list.selected = _evt.battle;
- } else static if (Type == CType.CALL_PACKAGE || Type == CType.LINK_PACKAGE) {
- _list.selected = _evt.packages;
- } else static if (Type == CType.BRANCH_CAST || Type == CType.GET_CAST || Type == CType.LOSE_CAST) {
- _list.selected = _evt.casts;
- } else static if (Type == CType.BRANCH_INFO || Type == CType.GET_INFO || Type == CType.LOSE_INFO) {
- _list.selected = _evt.info;
- } else { mixin(S_TRACE);
- static assert (0);
- }
- }
- }
- override bool apply() { mixin(S_TRACE);
- assert (_list.selected != 0UL);
- auto id = _list.selected;
- if (!_evt) { mixin(S_TRACE);
- _evt = new Content(Type, "");
- }
- static if (Type == CType.CHANGE_AREA) {
- auto ts = _tsTbl[_ts.getSelectionIndex()];
- uint tsSpeed = _tsSpeed.getSelection();
- _evt.area = id;
- _evt.transition = ts;
- _evt.transitionSpeed = tsSpeed;
- } else static if (Type == CType.START_BATTLE) {
- _evt.battle = id;
- } else static if (Type == CType.CALL_PACKAGE || Type == CType.LINK_PACKAGE) {
- _evt.packages = id;
- } else static if (Type == CType.BRANCH_CAST || Type == CType.GET_CAST || Type == CType.LOSE_CAST) {
- _evt.casts = id;
- } else static if (Type == CType.BRANCH_INFO || Type == CType.GET_INFO || Type == CType.LOSE_INFO) {
- _evt.info = id;
- } else { mixin(S_TRACE);
- static assert (0);
- }
- return true;
- }
- }
- /// ?????????????????????
- class StartSelectDialog(CType Type) : EventDialog {
- private:
- string _selected = "";
- EventTree _et;
- Table _list;
- IncSearch _incSearch;
- void incSearch() { mixin(S_TRACE);
- .forceFocus(_list, true);
- _incSearch.startIncSearch();
- }
- void selected() { mixin(S_TRACE);
- int index = _list.getSelectionIndex();
- if (-1 == index) return;
- _selected = (cast(Content) _list.getItem(index).getData()).name;
- }
- class Dispose : DisposeListener {
- override void widgetDisposed(DisposeEvent e) { mixin(S_TRACE);
- _comm.refContent.remove(&refContent);
- _comm.delContent.remove(&delContent);
- }
- }
- void refContent(Content c) { mixin(S_TRACE);
- refreshStarts(null);
- }
- void delContent(Content c) { mixin(S_TRACE);
- refreshStarts(c);
- }
- void refreshStarts() { mixin(S_TRACE);
- refreshStarts(null);
- }
- void refreshStarts(Content del) { mixin(S_TRACE);
- string sel = _selected;
- _list.removeAll();
- int i = 0;
- foreach (s; _et.starts) { mixin(S_TRACE);
- if (s is del) continue;
- if (!_incSearch.match(s.name)) continue;
- auto itm = new TableItem(_list, SWT.NONE);
- itm.setData(s);
- itm.setImage(0, _prop.images.content(CType.START));
- itm.setText(0, s.name);
- if (sel == s.name) _list.select(i);
- i++;
- }
- if (del && sel == del.name && _list.getItemCount()) { mixin(S_TRACE);
- _list.select(0);
- _selected = (cast(Content) _list.getItem(0).getData()).name;
- }
- _list.showSelection();
- }
- void openView() { mixin(S_TRACE);
- auto i = _list.getSelectionIndex();
- if (-1 == i) return;
- auto a = cast(Content) _list.getItem(i).getData();
- try { mixin(S_TRACE);
- _comm.openCWXPath(cpaddattr(a.cwxPath(true), "shallow"), false);
- } catch (Exception e) {
- debugln(e);
- }
- }
- class OpenView : MouseAdapter {
- override void mouseDoubleClick(MouseEvent e) { mixin(S_TRACE);
- if (1 != e.button) return;
- openView();
- }
- }
- public:
- this (Commons comm, Props prop, Shell shell, Summary summ, Content parent, Content evt) { mixin(S_TRACE);
- _et = parent.tree;
- super (comm, prop, shell, summ, Type, parent, evt, true, prop.var.selEvtDlg, true);
- }
- protected:
- override void setup(Composite area) { mixin(S_TRACE);
- area.setLayout(new GridLayout(1, false));
- _list = new Table(area, SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL);
- mod(_list);
- auto nameCol = new FullTableColumn(_list, SWT.NONE);
- auto gd = new GridData(GridData.FILL_BOTH);
- gd.widthHint = _prop.var.etc.nameTableWidth;
- gd.heightHint = _prop.var.etc.nameTableHeight;
- _list.setLayoutData(gd);
- _list.addMouseListener(new OpenView);
- auto menu = new Menu(_list.getShell(), SWT.POP_UP);
- createMenuItem(comm, menu, MenuID.IncSearch, &incSearch, null);
- new MenuItem(menu, SWT.SEPARATOR);
- createMenuItem(comm, menu, MenuID.OpenAtEventView, &openView, () => _list.getSelectionIndex() != -1);
- _list.setMenu(menu);
- .listener(_list, SWT.Selection, &selected);
- _incSearch = new IncSearch(comm, _list);
- _incSearch.modEvent ~= &refreshStarts;
- refreshStarts();
- _comm.refContent.add(&refContent);
- _comm.delContent.add(&delContent);
- _list.addDisposeListener(new Dispose);
- ignoreMod = true;
- scope (exit) ignoreMod = false;
- if (_evt) { mixin(S_TRACE);
- _selected = _evt.start;
- foreach (i, itm; _list.getItems()) { mixin(S_TRACE);
- if (_selected == (cast(Content) itm.getData()).name) { mixin(S_TRACE);
- _list.select(i);
- break;
- }
- }
- }
- if (-1 == _list.getSelectionIndex()) { mixin(S_TRACE);
- _list.select(0);
- _selected = (cast(Content) _list.getItem(0).getData()).name;
- }
- _list.showSelection();
- }
- override bool apply() { mixin(S_TRACE);
- if (!_evt) _evt = new Content(Type, "");
- _evt.start = _selected;
- return true;
- }
- }
- /// ???????????????????
- class ClearEventDialog : EventDialog {
- private:
- Button _mark;
- Button _unmark;
- public:
- this (Commons comm, Props prop, Shell shell, Summary summ, Content parent, Content evt) { mixin(S_TRACE);
- super (comm, prop, shell, summ, CType.END, parent, evt, false, null, enterClose);
- }
- protected:
- override void setup(Composite area) { mixin(S_TRACE);
- auto cl = new CenterLayout;
- cl.fillHorizontal = true;
- area.setLayout(cl);
- auto grp = new Group(area, SWT.NONE);
- grp.setText(_prop.msgs.afterClear);
- grp.setLayout(new CenterLayout(SWT.VERTICAL | SWT.HORIZONTAL, 0));
- auto comp = new Composite(grp, SWT.NONE);
- comp.setLayout(new GridLayout(1, true));
- _mark = new Button(comp, SWT.RADIO);
- mod(_mark);
- _mark.setText(_prop.msgs.afterClearEndMark);
- _unmark = new Button(comp, SWT.RADIO);
- mod(_unmark);
- _unmark.setText(_prop.msgs.afterClearNoEndMark);
- if (_evt) { mixin(S_TRACE);
- if (_evt.complete) { mixin(S_TRACE);
- _mark.setSelection(true);
- } else { mixin(S_TRACE);
- _unmark.setSelection(true);
- }
- } else { mixin(S_TRACE);
- _mark.setSelection(true);
- }
- }
- override bool apply() { mixin(S_TRACE);
- if (!_evt) { mixin(S_TRACE);
- _evt = new Content(CType.END, "");
- }
- _evt.complete = _mark.getSelection();
- return true;
- }
- }
- /// ??????????????????????
- class CouponEventDialog(CType Type, bool EditValue, bool Field) : EventDialog {
- private:
- Button[Range] _range;
- Button[CouponType] _type;
- Combo _name;
- static if (EditValue) {
- Spinner _value;
- }
- override
- protected void refreshWarning() { mixin(S_TRACE);
- string[] ws;
- static if (Type is CType.GET_COUPON || Type is CType.LOSE_COUPON) {
- if (prop.sys.isCouponType(_name.getText(), CouponType.System)) { mixin(S_TRACE);
- ws ~= .tryFormat(prop.msgs.warningSystemCoupon, prop.sys.couponSystem);
- }
- }
- static if (Field) {
- if (_prop.targetVersion("1.30")) { mixin(S_TRACE);
- if (_range[Range.FIELD].getSelection()) { mixin(S_TRACE);
- ws ~= prop.msgs.warningBranchCouponAtField;
- }
- }
- }
- warning = ws;
- }
- class SelType : SelectionAdapter {
- private CouponType _coType;
- this (CouponType coType) { mixin(S_TRACE);
- _coType = coType;
- }
- override void widgetSelected(SelectionEvent e) { mixin(S_TRACE);
- _name.setText(prop.sys.convCoupon(_name.getText(), _coType, true));
- }
- }
- public:
- this (Commons comm, Props prop, Shell shell, Summary summ, Content parent, Content evt) { mixin(S_TRACE);
- super (comm, prop, shell, summ, Type, parent, evt, true, prop.var.couponEvtDlg, true);
- }
- protected:
- override void setup(Composite area) { mixin(S_TRACE);
- area.setLayout(new GridLayout(2, false));
- auto skin = _comm.skin;
- auto leftComp = new Composite(area, SWT.NONE);
- leftComp.setLayout(zeroMarginGridLayout(1, true));
- leftComp.setLayoutData(new GridData(GridData.FILL_VERTICAL));
- { mixin(S_TRACE);
- auto grp = new Group(leftComp, SWT.NONE);
- static if (EditValue) {
- grp.setLayoutData(new GridData(GridData.FILL_BOTH));
- } else { mixin(S_TRACE);
- grp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- }
- grp.setText(_prop.msgs.range);
- grp.setLayout(new GridLayout(1, true));
- auto ranges = RANGE_MEMBER.dup;
- static if (Field) {
- ranges ~= Range.FIELD;
- }
- foreach (r; ranges) { mixin(S_TRACE);
- auto radio = new Button(grp, SWT.RADIO);
- mod(radio);
- radio.setLayoutData(new GridData(GridData.FILL_BOTH));
- radio.setText(_prop.msgs.rangeName(r));
- .listener(radio, SWT.Selection, &refreshWarning);
- _range[r] = radio;
- }
- }
- { mixin(S_TRACE);
- auto grp = new Group(area, SWT.NONE);
- grp.setLayoutData(new GridData(GridData.FILL_BOTH));
- auto cl = new CenterLayout(SWT.VERTICAL, 0);
- cl.fillHorizontal = true;
- grp.setLayout(cl);
- grp.setText(_prop.msgs.couponName);
- { mixin(S_TRACE);
- auto comp = new Composite(grp, SWT.NONE);
- comp.setLayout(new GridLayout(3, false));
- { mixin(S_TRACE);
- _name = createCouponCombo(comm, summ, comp, &catchMod, CouponComboType.AllCoupons, _evt ? _evt.coupon : "");
- mod(_name);
- auto gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = 3;
- gd.widthHint = _prop.var.etc.nameWidth;
- _name.setLayoutData(gd);
- }
- foreach (coType; [CouponType.Normal, CouponType.Hide, CouponType.Dur, CouponType.DurBattle]) { mixin(S_TRACE);
- auto b = new Button(comp, SWT.RADIO);
- b.setText(_prop.msgs.couponTypeDesc(coType));
- auto gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = 3;
- b.setLayoutData(gd);
- b.addSelectionListener(new SelType(coType));
- _type[coType] = b;
- }
- .listener(_name, SWT.Modify, { mixin(S_TRACE);
- auto t = prop.sys.couponType(_name.getText());
- bool checked = false;
- foreach (coType; _type.keys) { mixin(S_TRACE);
- _type[coType].setSelection(coType == t);
- checked |= (coType == t);
- }
- if (!checked) _type[CouponType.Normal].setSelection(true);
- refreshWarning();
- });
- }
- }
- static if (EditValue) {
- { mixin(S_TRACE);
- auto grp = new Group(leftComp, SWT.NONE);
- grp.setLayoutData(new GridData(GridData.FILL_BOTH));
- grp.setText(_prop.msgs.couponValue);
- grp.setLayout(new CenterLayout(SWT.HORIZONTAL | SWT.VERTICAL));
- auto comp = new Composite(grp, SWT.NONE);
- comp.setLayout(zeroMarginGridLayout(2, false));
- _value = new Spinner(comp, SWT.BORDER);
- initSpinner(_value);
- mod(_value);
- _value.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- _value.setMaximum(_prop.var.etc.couponValueMax);
- _value.setMinimum(-(cast(int) _prop.var.etc.couponValueMax));
- auto lr = new Label(comp, SWT.LEFT);
- lr.setText(.tryFormat(_prop.msgs.couponValueRange, -(cast(int) prop.var.etc.couponValueMax), prop.var.etc.couponValueMax));
- }
- }
- if (_evt) { mixin(S_TRACE);
- _range[_evt.range].setSelection(true);
- auto cType = prop.sys.couponType(_evt.coupon);
- auto cTypeP = cType in _type;
- if (cTypeP) { mixin(S_TRACE);
- cTypeP.setSelection(true);
- } else { mixin(S_TRACE);
- _type[CouponType.Normal].setSelection(true);
- }
- _name.setText(_evt.coupon);
- static if (EditValue) {
- _value.setSelection(_evt.couponValue);
- }
- } else { mixin(S_TRACE);
- _range[Range.SELECTED].setSelection(true);
- _type[CouponType.Normal].setSelection(true);
- static if (EditValue) {
- _value.setSelection(0);
- }
- }
- refreshWarning();
- }
- override bool apply() { mixin(S_TRACE);
- if (!_evt) _evt = new Content(Type, "");
- foreach (range, radio; _range) { mixin(S_TRACE);
- if (radio.getSelection()) { mixin(S_TRACE);
- _evt.range = range;
- _evt.coupon = _name.getText();
- static if (EditValue) {
- _evt.couponValue = _value.getSelection();
- }
- break;
- }
- }
- comm.refCoupons.call();
- return true;
- }
- }
- alias CouponEventDialog!(CType.BRANCH_COUPON, false, true) BranchCouponDialog;
- alias CouponEventDialog!(CType.GET_COUPON, true, false) GetCouponDialog;
- alias CouponEventDialog!(CType.LOSE_COUPON, false, false) LoseCouponDialog;
- /// ???????????????????
- private class OneTextEventDialog(CType Type, string Name, string Get, string Set, string EngineVersion = "") : EventDialog {
- private:
- Combo _name;
- override
- protected void refreshWarning() { mixin(S_TRACE);
- string[] ws;
- static if (EngineVersion != "") {
- if (!_prop.targetVersion(EngineVersion)) { mixin(S_TRACE);
- ws ~= .tryFormat(_prop.msgs.warningUnknownContent, _prop.msgs.contentName(Type), EngineVersion);
- }
- }
- warning = ws;
- }
- public:
- this (Commons comm, Props prop, Shell shell, Summary summ, Content parent, Content evt) { mixin(S_TRACE);
- super (comm, prop, shell, summ, Type, parent, evt, true, prop.var.inputEvtDlg, true);
- }
- protected:
- override void setup(Composite area) { mixin(S_TRACE);
- area.setLayout(new GridLayout(1, false));
- { mixin(S_TRACE);
- auto grp = new Group(area, SWT.NONE);
- grp.setLayoutData(new GridData(GridData.FILL_BOTH));
- grp.setText(mixin (Name));
- auto cl = new CenterLayout(SWT.HORIZONTAL | SWT.VERTICAL, 0);
- cl.fillHorizontal = true;
- grp.setLayout(cl);
- auto comp = new Composite(grp, SWT.NONE);
- comp.setLayout(new GridLayout(1, true));
- if (CDetail.fromType(Type).use(CArg.GOSSIP)) { mixin(S_TRACE);
- _name = createGossipCombo(comm, summ, comp, &catchMod, _evt ? mixin(Get) : "");
- } else if (CDetail.fromType(Type).use(CArg.COMPLETE_STAMP)) { mixin(S_TRACE);
- _name = createCompleteStampCombo(comm, summ, comp, &catchMod, _evt ? mixin(Get) : "");
- } else if (CDetail.fromType(Type).use(CArg.CELL_NAME)) { mixin(S_TRACE);
- _name = createCellNameCombo(comm, summ, comp, &catchMod, _evt ? mixin(Get) : "");
- } else assert (0);
- mod(_name);
- auto gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.widthHint = _prop.var.etc.nameWidth;
- _name.setLayoutData(gd);
- }
- if (_evt) { mixin(S_TRACE);
- _name.setText(mixin (Get));
- }
- refreshWarning();
- }
- override bool apply() { mixin(S_TRACE);
- if (!_evt) _evt = new Content(Type, "");
- string text = _name.getText();
- mixin (Set);
- if (CDetail.fromType(Type).use(CArg.GOSSIP)) { mixin(S_TRACE);
- comm.refGossips.call();
- }
- if (CDetail.fromType(Type).use(CArg.COMPLETE_STAMP)) { mixin(S_TRACE);
- comm.refCompleteStamps.call();
- }
- if (CDetail.fromType(Type).use(CArg.CELL_NAME)) { mixin(S_TRACE);
- comm.refCellNames.call();
- }
- return true;
- }
- }
- template GossipEventDialog(CType Type) {
- alias OneTextEventDialog!(Type, "_prop.msgs.gossipName",
- "_evt.gossip", "_evt.gossip = text;") GossipEventDialog;
- }
- template EndEventDialog(CType Type) {
- alias OneTextEventDialog!(Type, "_prop.msgs.endName",
- "_evt.completeStamp", "_evt.completeStamp = text;") EndEventDialog;
- }
- alias OneTextEventDialog!(CType.LOSE_BG_IMAGE, "_prop.msgs.cellName",
- "_evt.cellName", "_evt.cellName = text;", "1.60") LoseBgImageDialog;
- /// ???????????????????????
- class BgImagesDialog : EventDialog {
- private:
- AbstractArea _refTarget;
- Combo _ts;
- Spinner _tsSpeed;
- Transition[int] _tsTbl;
- BgImageContainer _cont;
- BgImagesView _view;
- Combo _cellName = null;
- override
- protected void refreshWarning() { mixin(S_TRACE);
- string[] ws;
- if (type is CType.REPLACE_BG_IMAGE) {
- if (!_prop.targetVersion("1.60")) { mixin(S_TRACE);
- ws ~= .tryFormat(_prop.msgs.warningUnknownContent, _prop.msgs.contentName(CType.REPLACE_BG_IMAGE), "1.60");
- }
- }
- warning = ws;
- }
- protected override void refSkin() { mixin(S_TRACE);
- refreshTS();
- }
- void refreshTS() { mixin(S_TRACE);
- _ts.setEnabled(!_summ.legacy);
- _tsSpeed.setEnabled(!_summ.legacy);
- }
- public:
- this (Commons comm, Props prop, Shell shell, Summary summ, Content parent, Content evt, AbstractArea refTarget, CType type) { mixin(S_TRACE);
- _refTarget = refTarget;
- super (comm, prop, shell, summ, type, parent, evt, true, prop.var.bgImagesDlg, false);
- BgImage[] bgImages;
- if (evt) { mixin(S_TRACE);
- foreach (b; evt.backs) { mixin(S_TRACE);
- bgImages ~= b.dup;
- }
- }
- _cont = new BgImageContainer(bgImages);
- }
- override
- bool openCWXPath(string path, bool shellActivate) { mixin(S_TRACE);
- return _view.openCWXPath(path, shellActivate);
- }
- protected:
- override void setup(Composite area) { mixin(S_TRACE);
- area.setLayout(new GridLayout(1, false));
- auto skin = _comm.skin;
- { mixin(S_TRACE);
- _view = createBgImagesViewAndMenu(_comm, _prop, _summ, _cont, area, _refTarget, false);
- mod(_view);
- _view.setLayoutData(new GridData(GridData.FILL_BOTH));
- _view.modEvent ~= &refreshWarning;
- }
- { mixin(S_TRACE);
- auto comp = new Composite(area, SWT.NONE);
- comp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- if (CDetail.fromType(type).use(CArg.CELL_NAME)) {
- comp.setLayout(zeroMarginGridLayout(8, false));
- auto l = new Label(comp, SWT.NONE);
- l.setText(_prop.msgs.cellName);
- _cellName = createCellNameCombo(comm, summ, comp, &catchMod, _evt ? _evt.cellName : "");
- mod(_cellName);
- _cellName.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- auto gd = new GridData(GridData.FILL_VERTICAL);
- gd.heightHint = 0;
- (new Label(comp, SWT.SEPARATOR | SWT.VERTICAL)).setLayoutData(gd);
- } else {
- comp.setLayout(zeroMarginGridLayout(5, false));
- }
- auto lt = new Label(comp, SWT.NONE);
- lt.setText(_prop.msgs.transition);
- _ts = new Combo(comp, SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY);
- mod(_ts);
- _ts.setVisibleItemCount(prop.var.etc.comboVisibleItemCount);
- foreach (i, t; ALL_TRANSITION) { mixin(S_TRACE);
- _ts.add(_prop.msgs.transitionName(t));
- _tsTbl[i] = t;
- if (_evt && t == _evt.transition) _ts.select(i);
- }
- auto ls = new Label(comp, SWT.NONE);
- ls.setText(_prop.msgs.transitionSpeed);
- _tsSpeed = new Spinner(comp, SWT.BORDER);
- initSpinner(_tsSpeed);
- mod(_tsSpeed);
- _tsSpeed.setMaximum(Content.transitionSpeed_max);
- _tsSpeed.setMinimum(Content.transitionSpeed_min);
- auto hint = new Label(comp, SWT.NONE);
- hint.setText(.tryFormat(_prop.msgs.rangeHint, Content.transitionSpeed_min, Content.transitionSpeed_max));
- }
- refreshTS();
- ignoreMod = true;
- scope (exit) ignoreMod = false;
- if (_evt) { mixin(S_TRACE);
- if (_cellName) _cellName.setText(_evt.cellName);
- _tsSpeed.setSelection(_evt.transitionSpeed);
- } else { mixin(S_TRACE);
- if (_cellName) _cellName.setText("");
- _ts.select(0);
- _tsSpeed.setSelection(.transitionSpeedDef);
- }
- }
- override bool apply() { mixin(S_TRACE);
- _evt.backs = _cont.backs;
- auto ts = _tsTbl[_ts.getSelectionIndex()];
- uint tsSpeed = _tsSpeed.getSelection();
- _evt.transition = ts;
- _evt.transitionSpeed = tsSpeed;
- if (CDetail.fromType(type).use(CArg.CELL_NAME)) {
- _evt.cellName = _cellName.getText();
- }
- return true;
- }
- }
- /// BGM????????????????
- class BgmDialog : EventDialog {
- private:
- MaterialSelect!(MtType.BGM, Combo, Table) _msel;
- override
- protected void refreshWarning() { mixin(S_TRACE);
- warning = comm.skin.warningBGM(prop.parent, _msel.filePath, summ.legacy, _prop.var.etc.targetVersion);
- }
- public:
- this (Commons comm, Props prop, Shell shell, Summary summ, Content parent, Content evt) { mixin(S_TRACE);
- super (comm, prop, shell, summ, CType.PLAY_BGM, parent, evt, true, prop.var.soundEvtDlg, true);
- }
- protected:
- override void setup(Composite area) { mixin(S_TRACE);
- area.setLayout(new GridLayout(1, true));
- auto comp = new Composite(area, SWT.NONE);
- comp.setLayout(zeroMarginGridLayout(4, false));
- comp.setLayoutData(new GridData(GridData.FILL_BOTH));
- { mixin(S_TRACE);
- auto skin = _comm.skin;
- _msel = new MaterialSelect!(MtType.BGM, Combo, Table)
- (_comm, _prop, _summ, false, null, [_prop.msgs.bgmStop]);
- _msel.createDirsCombo(comp).setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- mod(_msel);
- _msel.modEvent ~= &refreshWarning;
- _msel.createPlayButton(comp).setLayoutData(new GridData);
- _msel.createRefreshButton(comp, false).setLayoutData(new GridData);
- _msel.createDirectoryButton(comp, false).setLayoutData(new GridData);
- auto gd = new GridData(GridData.FILL_BOTH);
- gd.horizontalSpan = 4;
- gd.widthHint = _prop.var.etc.nameTableWidth;
- gd.heightHint = _prop.var.etc.nameTableHeight;
- auto list = _msel.createFileList(comp);
- list.setLayoutData(gd);
- }
- ignoreMod = true;
- scope (exit) ignoreMod = false;
- _msel.path = _evt ? _evt.bgmPath : "";
- }
- override bool apply() { mixin(S_TRACE);
- if (!_evt) _evt = new Content(CType.PLAY_BGM, "");
- _evt.bgmPath = _msel.path;
- return true;
- }
- }
- /// ???????????????????
- class SeDialog : EventDialog {
- private:
- MaterialSelect!(MtType.SE, Combo, Table) _msel;
- override
- protected void refreshWarning() { mixin(S_TRACE);
- warning = comm.skin.warningSE(prop.parent, _msel.filePath, summ.legacy, _prop.var.etc.targetVersion);
- }
- public:
- this (Commons comm, Props prop, Shell shell, Summary summ, Content parent, Content evt) { mixin(S_TRACE);
- super (comm, prop, shell, summ, CType.PLAY_SOUND, parent, evt, true, prop.var.soundEvtDlg, true);
- }
- protected:
- override void setup(Composite area) { mixin(S_TRACE);
- area.setLayout(new GridLayout(1, true));
- auto comp = new Composite(area, SWT.NONE);
- comp.setLayout(zeroMarginGridLayout(5, false));
- comp.setLayoutData(new GridData(GridData.FILL_BOTH));
- { mixin(S_TRACE);
- auto skin = _comm.skin;
- _msel = new MaterialSelect!(MtType.SE, Combo, Table)
- (_comm, _prop, _summ, false, null, []);
- _msel.createDirsCombo(comp).setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- mod(_msel);
- _msel.modEvent ~= &refreshWarning;
- _msel.createStopButton(comp).setLayoutData(new GridData);
- _msel.createPlayButton(comp).setLayoutData(new GridData);
- _msel.createRefreshButton(comp, false).setLayoutData(new GridData);
- _msel.createDirectoryButton(comp, false).setLayoutData(new GridData);
- auto gd = new GridData(GridData.FILL_BOTH);
- gd.horizontalSpan = 5;
- gd.widthHint = _prop.var.etc.nameTableWidth;
- gd.heightHint = _prop.var.etc.nameTableHeight;
- auto list = _msel.createFileList(comp);
- list.setLayoutData(gd);
- }
- ignoreMod = true;
- scope (exit) ignoreMod = false;
- _msel.path = _evt ? _evt.soundPath : "";
- }
- override bool apply() { mixin(S_TRACE);
- if (!_evt) _evt = new Content(CType.PLAY_SOUND, "");
- _evt.soundPath = _msel.path;
- return true;
- }
- }
- /// ??????????????
- private class NumericEventDialog(CType Type, string Name, string Max, string Get, string Set, uint Min = 0, uint Def = 0) : EventDialog {
- private:
- Spinner _value;
- public:
- this (Commons comm, Props prop, Shell shell, Summary summ, Content parent, Content evt) { mixin(S_TRACE);
- super (comm, prop, shell, summ, Type, parent, evt, false, null, true);
- }
- protected:
- private class PM : SelectionAdapter {
- private int _v;
- this (int v) {_v = v;}
- override void widgetSelected(SelectionEvent e) { mixin(S_TRACE);
- _value.setSelection(_value.getSelection() + _v);
- }
- }
- override void setup(Composite area) { mixin(S_TRACE);
- area.setLayout(new GridLayout(1, false));
- { mixin(S_TRACE);
- auto grp = new Group(area, SWT.NONE);
- grp.setLayoutData(new GridData(GridData.FILL_BOTH));
- grp.setText(mixin (Name));
- grp.setLayout(new CenterLayout(SWT.VERTICAL | SWT.HORIZONTAL, 0));
- auto comp = new Composite(grp, SWT.NONE);
- _value = new Spinner(comp, SWT.BORDER);
- initSpinner(_value);
- mod(_value);
- _value.setMinimum(Min);
- _value.setMaximum(mixin (Max));
- comp.setLayout(new GridLayout(10 <= _value.getMaximum() ? 3 : 2, false));
- if (10 <= _value.getMaximum()) { mixin(S_TRACE);
- auto tools = new Composite(comp, SWT.NONE);
- tools.setLayout(new FillLayout(SWT.HORIZONTAL));
- for (int i = 5; i <= _value.getMaximum() && i < 10000; i*= i == 5 ? 2 : 10) { mixin(S_TRACE);
- auto ts = new Composite(tools, SWT.NONE);
- ts.setLayout(new FillLayout(SWT.VERTICAL));
- void createB(int i) { mixin(S_TRACE);
- auto r = new Button(ts, SWT.PUSH);
- auto fontd = r.getFont().getFontData();
- foreach (fd; fontd) { mixin(S_TRACE);
- fd.height /= 1.5;
- }
- r.setFont(new Font(Display.getCurrent(), fontd));
- r.addDisposeListener(new class DisposeListener {
- override void widgetDisposed(DisposeEvent e) { mixin(S_TRACE);
- (cast(Control) e.widget).getFont().dispose();
- }
- });
- r.setText(i < 0 ? to!(string)(i) : "+" ~ to!(string)(i));
- r.addSelectionListener(new PM(i));
- }
- createB(i);
- createB(-i);
- }
- }
- auto l = new Label(comp, SWT.NONE);
- l.setText(.tryFormat(_prop.msgs.rangeHint, Min, _value.getMaximum()));
- }
- ignoreMod = true;
- scope (exit) ignoreMod = false;
- if (_evt) { mixin(S_TRACE);
- _value.setSelection(mixin (Get));
- } else { mixin(S_TRACE);
- _value.setSelection(Def);
- }
- }
- override bool apply() { mixin(S_TRACE);
- if (!_evt) _evt = new Content(Type, "");
- int value = _value.getSelection();
- mixin (Set);
- return true;
- }
- }
- alias NumericEventDialog!(CType.WAIT, "_prop.msgs.waitName",
- "_prop.var.etc.waitMax", "_evt.wait", "_evt.wait = value;") WaitEventDialog;
- alias NumericEventDialog!(CType.BRANCH_RANDOM, "_prop.msgs.randomName",
- "100", "_evt.percent", "_evt.percent = value;", 0, 50) BrRandomEventDialog;
- alias NumericEventDialog!(CType.BRANCH_PARTY_NUMBER, "_prop.msgs.partyNumName",
- "_prop.var.etc.partyMax", "_evt.partyNumber", "_evt.partyNumber = value;", 1, 1) BrNumEventDialog;
- template MoneyEventDialog(CType Type) {
- alias NumericEventDialog!(Type, "_prop.msgs.moneyName",
- "_prop.var.etc.priceMax", "_evt.money", "_evt.money = value;") MoneyEventDialog;
- }
- /// ??????????????????
- class EffectDialog : EventDialog {
- private:
- MotionView _mview;
- Spinner _lev;
- MaterialSelect!(MtType.SE, Combo, Combo) _se;
- Scale _sucRate;
- Button[EffectType] _effTyp;
- Button[Resist] _res;
- Button[CardVisual] _vis;
- Button[Target.M] _targ;
- override
- protected void refreshWarning() { mixin(S_TRACE);
- string[] ws;
- if (_se.path != "" && !_se.selectedDefDir) ws ~= prop.msgs.warningNotDefaultSE;
- warning = ws ~ comm.skin.warningSE(prop.parent, _se.filePath, summ.legacy, _prop.var.etc.targetVersion);
- }
- public:
- this (Commons comm, Props prop, Shell shell, Summary summ, Content parent, Content evt) { mixin(S_TRACE);
- super (comm, prop, shell, summ, CType.EFFECT, parent, evt, true, prop.var.effEvtDlg, true);
- }
- override
- bool openCWXPath(string path, bool shellActivate) { mixin(S_TRACE);
- return _mview.openCWXPath(path, shellActivate);
- }
- protected:
- override void setup(Composite area) { mixin(S_TRACE);
- auto cl = new CenterLayout;
- cl.fillHorizontal = true;
- cl.fillVertical = true;
- area.setLayout(cl);
- auto tabf = new CTabFolder(area, SWT.BORDER);
- auto tabM = new CTabItem(tabf, SWT.NONE);
- tabM.setText(_prop.msgs.motion);
- { mixin(S_TRACE);
- _mview = new MotionView(_comm, _prop, _summ, tabf, SWT.NONE);
- mod(_mview);
- tabM.setControl(_mview);
- }
- auto tabS = new CTabItem(tabf, SWT.NONE);
- tabS.setText(_prop.msgs.settings);
- { mixin(S_TRACE);
- auto comp = new Composite(tabf, SWT.NONE);
- tabS.setControl(comp);
- comp.setLayout(new GridLayout(2, false));
- { mixin(S_TRACE);
- auto comp2 = new Composite(comp, SWT.NONE);
- comp2.setLayoutData(new GridData(GridData.FILL_BOTH));
- comp2.setLayout(zeroMarginGridLayout(1, true));
- { mixin(S_TRACE);
- auto grp = new Group(comp2, SWT.NONE);
- grp.setText(_prop.msgs.targetLevel);
- grp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- grp.setLayout(new GridLayout(2, false));
- _lev = new Spinner(grp, SWT.BORDER);
- initSpinner(_lev);
- mod(_lev);
- _lev.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- _lev.setMinimum(-(cast(int) _prop.var.etc.castLevelMax));
- _lev.setMaximum(_prop.var.etc.castLevelMax);
- auto l = new Label(grp, SWT.NONE);
- l.setText(.tryFormat(_prop.msgs.rangeHint, _lev.getMinimum(), _lev.getMaximum()));
- }
- { mixin(S_TRACE);
- auto grp = new Group(comp2, SWT.NONE);
- grp.setText(_prop.msgs.elementProps);
- grp.setLayoutData(new GridData(GridData.FILL_BOTH));
- grp.setLayout(new GridLayout(2, true));
- foreach (i, eff; [EffectType.PHYSIC, EffectType.MAGIC,
- EffectType.MAGICAL_PHYSIC, EffectType.PHYSICAL_MAGIC,
- EffectType.NONE]) { mixin(S_TRACE);
- auto radio = new Button(grp, SWT.RADIO);
- mod(radio);
- auto gd = new GridData(GridData.FILL_BOTH);
- if (2 <= i) { mixin(S_TRACE);
- gd.horizontalSpan = 2;
- }
- radio.setLayoutData(gd);
- radio.setText(.tryFormat(_prop.msgs.effectTypeElement, _prop.msgs.effectTypeName(eff)));
- radio.setToolTipText(_prop.msgs.effectTypeDesc(eff));
- _effTyp[eff] = radio;
- }
- }
- { mixin(S_TRACE);
- auto grp = new Group(comp2, SWT.NONE);
- grp.setText(_prop.msgs.resistProps);
- grp.setLayoutData(new GridData(GridData.FILL_BOTH));
- grp.setLayout(new GridLayout(2, true));
- foreach (res; [Resist.AVOID, Resist.RESIST, Resist.UNFAIL]) { mixin(S_TRACE);
- auto radio = new Button(grp, SWT.RADIO);
- mod(radio);
- radio.setText(_prop.msgs.resistName(res));
- radio.setToolTipText(_prop.msgs.resistDesc(res));
- radio.setLayoutData(new GridData(GridData.FILL_BOTH));
- _res[res] = radio;
- }
- }
- }
- { mixin(S_TRACE);
- auto comp2 = new Composite(comp, SWT.NONE);
- comp2.setLayoutData(new GridData(GridData.FILL_BOTH));
- comp2.setLayout(zeroMarginGridLayout(2, false));
- { mixin(S_TRACE);
- auto grp = new Group(comp2, SWT.NONE);
- grp.setText(_prop.msgs.effectVisual);
- grp.setLayoutData(new GridData(GridData.FILL_BOTH));
- grp.setLayout(new GridLayout(1, false));
- foreach (v; [CardVisual.NONE, CardVisual.REVERSE, CardVisual.HORIZONTAL, CardVisual.VERTICAL]) { mixin(S_TRACE);
- auto radio = new Button(grp, SWT.RADIO);
- mod(radio);
- radio.setLayoutData(new GridData(GridData.FILL_BOTH));
- radio.setText(_prop.msgs.cardVisualName(v));
- _vis[v] = radio;
- }
- }
- { mixin(S_TRACE);
- auto grp = new Group(comp2, SWT.NONE);
- grp.setText(_prop.msgs.judgeTarget);
- grp.setLayoutData(new GridData(GridData.FILL_BOTH));
- grp.setLayout(new GridLayout(1, true));
- foreach (m; [Target.M.SELECTED, Target.M.RANDOM, Target.M.PARTY]) { mixin(S_TRACE);
- auto radio = new Button(grp, SWT.RADIO);
- mod(radio);
- radio.setText(_prop.msgs.targetName(m));
- radio.setLayoutData(new GridData(GridData.FILL_BOTH));
- _targ[m] = radio;
- }
- }
- { mixin(S_TRACE);
- auto grp = new Group(comp2, SWT.NONE);
- grp.setText(_prop.msgs.se);
- auto gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = 2;
- grp.setLayoutData(gd);
- grp.setLayout(new GridLayout(3, false));
- _se = new MaterialSelect!(MtType.SE, Combo, Combo)(comm, prop, summ, false, null, [prop.msgs.soundNone]);
- mod(_se);
- _se.modEvent ~= &refreshWarning;
- _se.createDirsCombo(grp).setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- _se.createStopButton(grp);
- _se.createPlayButton(grp);
- auto gdfl = new GridData(GridData.FILL_HORIZONTAL);
- gdfl.horizontalSpan = 4;
- _se.createFileList(grp).setLayoutData(gdfl);
- }
- { mixin(S_TRACE);
- auto gd = new GridData(GridData.FILL_BOTH);
- gd.horizontalSpan = 2;
- createSuccessRateScale(_prop, comp2, _sucRate).setLayoutData(gd);
- mod(_sucRate);
- }
- }
- }
- tabf.setLayoutData(area.computeSize(SWT.DEFAULT, SWT.DEFAULT));
- ignoreMod = true;
- scope (exit) ignoreMod = false;
- if (_evt) { mixin(S_TRACE);
- _mview.motions = _evt.motions;
- _lev.setSelection(_evt.signedLevel);
- _se.path = _evt.soundPath;
- _sucRate.setSelection(_evt.successRate + Content.successRate_max);
- _effTyp[_evt.effectType].setSelection(true);
- _res[_evt.resist].setSelection(true);
- _vis[_evt.cardVisual].setSelection(true);
- _targ[_evt.targetNS.m].setSelection(true);
- } else { mixin(S_TRACE);
- _mview.motions = [];
- _lev.setSelection(0);
- _se.path = "";
- _sucRate.setSelection(Content.successRate_max + Content.successRate_max);
- _effTyp[EffectType.NONE].setSelection(true);
- _res[Resist.UNFAIL].setSelection(true);
- _vis[CardVisual.NONE].setSelection(true);
- _targ[Target.M.SELECTED].setSelection(true);
- }
- }
- override bool apply() { mixin(S_TRACE);
- if (!_evt) _evt = new Content(CType.EFFECT, "");
- _evt.motions = _mview.motions;
- _evt.signedLevel = _lev.getSelection();
- _evt.soundPath = _se.path;
- _evt.successRate = cast(int) _sucRate.getSelection() - Content.successRate_max;
- _evt.effectType = getRadioValue!(EffectType)(_effTyp);
- _evt.resist = getRadioValue!(Resist)(_res);
- _evt.cardVisual = getRadioValue!(CardVisual)(_vis);
- _evt.targetNS = Target(getRadioValue!(Target.M)(_targ), false);
- return true;
- }
- }
- /// ???????????????????????
- private class FlagStepDialog(CType Type, F, bool SelValue) : EventDialog {
- private:
- override
- protected void refreshWarning() { mixin(S_TRACE);
- string[] ws;
- static if (Type is CType.CHECK_STEP) {
- if (!_prop.targetVersion("1.50")) { mixin(S_TRACE);
- ws ~= .tryFormat(_prop.msgs.warningUnknownContent, _prop.msgs.contentName(CType.CHECK_STEP), "1.50");
- }
- }
- warning = ws;
- }
- FlagDir _root;
- SplitPane _sash;
- FlagChooser!(F, false) _flags;
- string _oldSel = "";
- Table _values;
- @property
- uint selectedValue() { mixin(S_TRACE);
- return _values.getSelectionIndex();
- }
- void refreshValues() { mixin(S_TRACE);
- static if (is(F:Flag)) {
- F flag = summ.flagDirRoot.findFlag(_flags.selected);
- } else static if (is(F:Step)) {
- F flag = summ.flagDirRoot.findStep(_flags.selected);
- } else static assert (0);
- static if (SelValue) {
- int sel = _values.getSelectionIndex();
- }
- _values.removeAll();
- if (flag) { mixin(S_TRACE);
- static if (is (F == Flag)) {
- auto itm1 = new TableItem(_values, SWT.NONE);
- itm1.setText(flag.on);
- auto itm2 = new TableItem(_values, SWT.NONE);
- itm2.setText(flag.off);
- } else static if (is (F == Step)) {
- foreach (val; flag.values) { mixin(S_TRACE);
- auto itm = new TableItem(_values, SWT.NONE);
- itm.setText(val);
- }
- } else { mixin(S_TRACE);
- static assert (0);
- }
- static if (SelValue) {
- if (sel < 0) sel = 0;
- static if (is (F == Step)) {
- if (sel >= flag.values.length) sel = flag.values.length - 1;
- }
- _values.select(sel);
- }
- }
- updateLabel();
- }
- void selectedFlag() { mixin(S_TRACE);
- string selPath = _flags.selectedWithDir;
- if (_oldSel == selPath) { mixin(S_TRACE);
- static if (SelValue) {
- _values.select(0);
- updateLabel();
- }
- } else { mixin(S_TRACE);
- _oldSel = _flags.selectedWithDir;
- refreshValues();
- }
- }
- class ValSListener : SelectionAdapter {
- override void widgetSelected(SelectionEvent e) { mixin(S_TRACE);
- updateLabel();
- }
- }
- class Dispose : DisposeListener {
- override void widgetDisposed(DisposeEvent e) { mixin(S_TRACE);
- _comm.refFlagAndStep.remove(&refFS);
- _comm.delFlagAndStep.remove(&delFS);
- }
- }
- void refFS(Flag[] f, Step[] s) { mixin(S_TRACE);
- static if (is(F : Flag)) {
- if (!f.length) return;
- } else { mixin(S_TRACE);
- if (!s.length) return;
- }
- int sel = _values.getSelectionIndex();
- refreshValues();
- _values.select(sel);
- }
- void delFS(Flag[] f, Step[] s) { mixin(S_TRACE);
- static if (is(F : Flag)) {
- if (!f.length) return;
- } else { mixin(S_TRACE);
- if (!s.length) return;
- }
- static if (is(F : Flag)) {
- if (!_root.allFlags.length) { mixin(S_TRACE);
- forceCancel();
- return;
- }
- } else static if (is(F : Step)) {
- if (!_root.allSteps.length) { mixin(S_TRACE);
- forceCancel();
- return;
- }
- } else static assert (0);
- refreshValues();
- }
- static if (Type is CType.CHECK_STEP) {
- Label _cmpLabel = null;
- Combo _cmp = null;
- Comparison4[] _cmps;
- void updateLabel() { mixin(S_TRACE);
- static if (is(F:Flag)) {
- F step = summ.flagDirRoot.findFlag(_flags.selected);
- } else static if (is(F:Step)) {
- F step = summ.flagDirRoot.findStep(_flags.selected);
- } else static assert (0);
- if (!step) return;
- uint value = selectedValue;
- _cmpLabel.setText(.tryFormat(prop.msgs.stepValueIs, step.path, step.getValue(value)));
- }
- } else {
- void updateLabel() { mixin(S_TRACE);
- // ????
- }
- }
- public:
- this (Commons comm, Props prop, Shell shell, Summary summ, Content parent, Content evt, FlagDir root) { mixin(S_TRACE);
- _root = root;
- super (comm, prop, shell, summ, Type, parent, evt, true, prop.var.flagEvtDlg, true);
- closeEvent ~= { mixin(S_TRACE);
- auto ws = _sash.getWeights();
- _prop.var.etc.flagEventSashL = ws[0];
- _prop.var.etc.flagEventSashR = ws[1];
- };
- }
- protected:
- override void setup(Composite area) { mixin(S_TRACE);
- area.setLayout(new GridLayout(1, true));
- _sash = new SplitPane(area, SWT.HORIZONTAL);
- _sash.setLayoutData(new GridData(GridData.FILL_BOTH));
- auto left = new Composite(_sash, SWT.NONE);
- left.setLayout(zeroGridLayout(1));
- auto right = new Composite(_sash, SWT.NONE);
- right.setLayout(zeroGridLayout(1));
- { mixin(S_TRACE);
- auto l1 = new CLabel(left, SWT.NONE);
- auto l2 = new CLabel(right, SWT.NONE);
- static if (is (F == Flag)) {
- l1.setText(_prop.msgs.flag);
- l1.setImage(_prop.images.flag);
- l2.setText(_prop.msgs.flagValue);
- } else static if (is (F == Step)) {
- l1.setText(_prop.msgs.step);
- l1.setImage(_prop.images.step);
- l2.setText(_prop.msgs.stepValue);
- } else { mixin(S_TRACE);
- static assert (0);
- }
- auto gd = new GridData;
- gd.heightHint = l1.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
- l2.setLayoutData(gd);
- }
- { mixin(S_TRACE);
- _flags = new FlagChooser!(F, false, false)(comm, summ, left);
- mod(_flags);
- _flags.modEvent ~= &selectedFlag;
- _flags.setLayoutData(new GridData(GridData.FILL_BOTH));
- }
- { mixin(S_TRACE);
- _values = new Table(right, SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL);
- new FullTableColumn(_values, SWT.NONE);
- mod(_values);
- auto gd = new GridData(GridData.FILL_BOTH);
- gd.heightHint = _prop.var.etc.nameTableHeight;
- _values.setLayoutData(gd);
- _values.setEnabled(SelValue);
- _values.addSelectionListener(new ValSListener);
- }
- static if (Type is CType.CHECK_STEP) {
- auto comp = new Composite(area, SWT.NONE);
- comp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- comp.setLayout(zeroMarginGridLayout(2, false));
- _cmpLabel = new Label(comp, SWT.RIGHT);
- _cmpLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- _cmp = new Combo(comp, SWT.READ_ONLY | SWT.DROP_DOWN | SWT.BORDER);
- mod(_cmp);
- _cmp.setVisibleItemCount(prop.var.etc.comboVisibleItemCount);
- foreach (cmp; EnumMembers!Comparison4) { mixin(S_TRACE);
- _cmp.add(prop.msgs.comparison4Name(cmp));
- _cmps ~= cmp;
- }
- }
- _comm.refFlagAndStep.add(&refFS);
- _comm.delFlagAndStep.add(&delFS);
- _flags.addDisposeListener(new Dispose);
- ignoreMod = true;
- scope (exit) ignoreMod = false;
- if (_evt) { mixin(S_TRACE);
- static if (is (F == Flag)) {
- _flags.selected = _evt.flag;
- } else static if (is (F == Step)) {
- _flags.selected = _evt.step;
- } else { mixin(S_TRACE);
- static assert (0);
- }
- _oldSel = _flags.selectedWithDir;
- refreshValues();
- static if (SelValue) {
- static if (is (F == Flag)) {
- _values.select(_evt.flagValue ? 0 : 1);
- } else static if (is (F == Step)) {
- _values.select(_evt.stepValue);
- } else { mixin(S_TRACE);
- static assert (0);
- }
- }
- static if (Type is CType.CHECK_STEP) {
- _cmp.select(_cmps.countUntil(_evt.comparison4));
- }
- } else { mixin(S_TRACE);
- _flags.selected = "";
- refreshValues();
- static if (Type is CType.CHECK_STEP) {
- _cmp.select(0);
- }
- }
- updateLabel();
- refreshWarning();
- _sash.setWeights([_prop.var.etc.flagEventSashL, _prop.var.etc.flagEventSashR]);
- }
- override bool apply() { mixin(S_TRACE);
- assert (_flags.selected != "");
- if (!_evt) _evt = new Content(Type, "");
- static if (is (F == Flag)) {
- _evt.flag = _flags.selected;
- static if (SelValue) {
- _evt.flagValue = _values.getSelectionIndex() == 0;
- }
- } else static if (is (F == Step)) {
- _evt.step = _flags.selected;
- static if (SelValue) {
- _evt.stepValue = _values.getSelectionIndex();
- }
- } else { mixin(S_TRACE);
- static assert (0);
- }
- static if (Type is CType.CHECK_STEP) {
- _evt.comparison4 = _cmps[_cmp.getSelectionIndex()];
- }
- return true;
- }
- }
- alias FlagStepDialog!(CType.BRANCH_FLAG, Flag, false) BrFlagDialog;
- alias FlagStepDialog!(CType.BRANCH_MULTI_STEP, Step, false) BrStepNDialog;
- alias FlagStepDialog!(CType.BRANCH_STEP, Step, true) BrStepULDialog;
- alias FlagStepDialog!(CType.SET_FLAG, Flag, true) FlagSetDialog;
- alias FlagStepDialog!(CType.SET_STEP, Step, true) StepSetDialog;
- alias FlagStepDialog!(CType.SET_STEP_UP, Step, false) StepPlusDialog;
- alias FlagStepDialog!(CType.SET_STEP_DOWN, Step, false) StepMinusDialog;
- alias FlagStepDialog!(CType.REVERSE_FLAG, Flag, false) FlagRDialog;
- alias FlagStepDialog!(CType.CHECK_FLAG, Flag, false) FlagJudgeDialog;
- alias FlagStepDialog!(CType.CH…
Large files files are truncated, but you can click here to view the full file