private void SetScriptable(IScriptable scriptable, string scriptablePath, bool reload = false)
        {
            if (reload || scriptable != this.scriptable)
            {
                edits.Clear();
                savedEditIndex = editIndex = 0;
            }

            this.scriptable = scriptable;
            bool sameFile = scriptablePath == LastFile;

            this.scriptablePath = LastFile = scriptablePath;
            AddRecentFile(scriptablePath);
            UpdateText();
            bool loading = scriptable != objectEditor.DataObject || reload;

            if (reload)
            {
                objectEditor.DataObject = null;
            }
            objectEditor.DataObject = scriptable;
            objectEditor.Visible    = scriptable != null;

            if (loading && sameFile)
            {
                string      indexString = Properties.Settings.Default.LastIndex;
                EditorIndex index       = JsonSerializer.fromJson <EditorIndex>(indexString);
                if (index != null)
                {
                    objectEditor.Index = index;
                }
            }
            Properties.Settings.Default.LastIndex = JsonSerializer.toJson(objectEditor.Index);
            Properties.Settings.Default.Save();
        }
Exemple #2
0
 public InlineEditAction(EditorIndex index, int inlineIndex, DataObject obj1, DataObject obj2)
     : base(new InlineEditState(obj1), new InlineEditState(obj2))
 {
     this.index       = index;
     this.inlineIndex = inlineIndex;
     ((InlineEditState)this.state0).Edit = this;
     ((InlineEditState)this.state1).Edit = this;
 }
Exemple #3
0
 public void AddIndexParent(EditorIndex index)
 {
     Index0.AddParent(index);
     if (Index1 != Index0)
     {
         Index1.AddParent(index);
     }
 }
Exemple #4
0
 public FieldEditAction(FieldEditState state0, FieldEditState state1, EditorIndex index, int fieldIndex, bool canCombime)
     : base(state0, state1)
 {
     state0.Edit     = state1.Edit = this;
     this.index      = index;
     this.fieldIndex = fieldIndex;
     this.canCombime = canCombime;
 }
 private void ApplyEdit(EditorIndex before, EditorIndex after, EditState state)
 {
     //Console.WriteLine(before + " / " + after);
     this.objectEditor.Index = before;
     Application.DoEvents();
     this.objectEditor.ApplyEdit(after, state);
     this.objectEditor.Index = after;
 }
        public void AddParent(EditorIndex index)
        {
            EditorIndex child = new EditorIndex();

            child.listIndex = listIndex;
            child.itemIndex = itemIndex;
            child.nextIndex = nextIndex;

            listIndex = index.listIndex;
            itemIndex = index.itemIndex;
            nextIndex = child;
        }
        public MainForm()
        {
            InitializeComponent();
            EditorIndex.Load();

            SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true);

            objectEditor.Visible = false;
            PopulateRecentFiles();
            TryOpenScriptable(LastFile);

            UpdateUndoRedoEnabled();

            objectEditor.OnObjectEdited += RecordEdit;
            objectEditor.Holder          = panel;
        }
        private void AddRow(Accessor accessor, TableLayoutPanel tableLayout)
        {
            if (accessor.GetTags().Any(x => x.flag == FieldTags.Inline))
            {
                AddInlineRow(accessor, tableLayout);
                return;
            }

            FieldEditor editor = FieldEditor.CreateEditor(accessor, this);

            if (editor == null)
            {
                return;
            }

            tableLayout.RowCount++;
            Label label = new Label();

            label.AutoSize = true;
            label.Text     = GetHumanReadableField(accessor.GetName());
            FieldTag comment = accessor.GetTags().Where(tag => tag.flag == FieldTags.Comment).FirstOrDefault();

            if (comment != null)
            {
                ToolTip tooltip = new ToolTip();
                tooltip.SetToolTip(label, comment.arg);
            }
            tableLayout.Controls.Add(label, 0, tableLayout.RowCount - 1);

            Control content = editor.GetControl();

            content.Enabled = !editor.accessor.GetTags().Any((tag) => tag.flag == FieldTags.Readonly);
            tableLayout.Controls.Add(content, 1, tableLayout.RowCount - 1);
            int fieldIndex = editors.Count;

            editors.Add(editor);
            editor.OnEdited += (sender, args) =>
            {
                if (OnObjectEdited != null)
                {
                    EditorIndex    index  = Index;
                    FieldEditState state0 = new FieldEditState(args.valueBefore, editor.LastSelectedIndex);
                    FieldEditState state1 = new FieldEditState(args.valueAfter, editor.SelectedIndex);
                    OnObjectEdited(sender, new FieldEditAction(state0, state1, index.RemoveNext(), fieldIndex, editor.EditsCanCombine));
                }
            };
        }
        public void ApplyEdit(EditorIndex index, EditState state)
        {
            if (index.nextIndex != null)
            {
                if (nextEditor != null)
                {
                    nextEditor.ApplyEdit(index.nextIndex, state);
                }
                UpdateSelectedItemText();
                return;
            }

            ApplyEdit(state as FieldEditState);
            ApplyEdit(state as CreateEditState);
            ApplyEdit(state as MoveEditState);
            ApplyEdit(state as InlineEditState);
            RefreshEditors(null, null);
        }
 public bool Equals(EditorIndex index)
 {
     if (this.listIndex != index.listIndex ||
         this.itemIndex != index.itemIndex)
     {
         return(false);
     }
     if (index.nextIndex != null)
     {
         if (this.nextIndex == null)
         {
             return(false);
         }
         return(nextIndex.Equals(index.nextIndex));
     }
     if (this.nextIndex != null)
     {
         return(false);
     }
     return(true);
 }
Exemple #11
0
 public TwoIndexEditAction(EditState state0, EditState state1, EditorIndex index0, EditorIndex index1)
     : base(state0, state1)
 {
     this.index0 = index0;
     this.index1 = index1;
 }
Exemple #12
0
 public CreateEditAction(bool create, EditorIndex index0, EditorIndex index1)
     : base(new CreateEditState(!create), new CreateEditState(create), index0, index1)
 {
     ((CreateEditState)this.state0).Edit = this;
     ((CreateEditState)this.state1).Edit = this;
 }
Exemple #13
0
 public MoveEditAction(int startIndex, int endIndex, EditorIndex index0, EditorIndex index1)
     : base(new MoveEditState(endIndex, startIndex), new MoveEditState(startIndex, endIndex), index0, index1)
 {
     ((MoveEditState)this.state0).Edit = this;
     ((MoveEditState)this.state1).Edit = this;
 }
 public void AddFields(FieldData fields)
 {
     listIndex = fields.add(listIndex, "listIndex");
     itemIndex = fields.add(itemIndex, "itemIndex");
     nextIndex = fields.add(nextIndex, "nextIndex");
 }
 public EditorIndex RemoveNext()
 {
     nextIndex = null;
     return(this);
 }