Пример #1
0
        internal SpriteBox(AESprite _aeSprite, int curHeight)
        {
            this.aeSprite  = _aeSprite;
            this.curHeight = curHeight;

            foreach (ActionTemplate actionTemplate in _aeSprite.actions)
            {
                addAction(actionTemplate);
            }
        }
Пример #2
0
        private void treeView_NodeClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            if (treeView1 != sender)
            {
                return;
            }
            Console.WriteLine("treeView_NodeClick");

            Point point = treeView1.PointToClient(Cursor.Position);
            TreeViewHitTestInfo info = treeView1.HitTest(point.X, point.Y);
            TreeNode            node = info.Node;

            if (node == null)
            {
                return;
            }

            if (MouseButtons.Right == e.Button)
            {
                treeView1.SelectedNode = node;

                curTreeNodeBindedObject = curEditAEData.getNodeBindedObject(node);
                if (curTreeNodeBindedObject == null)
                {
                    return;
                }

                this.nodeContextMenu.MenuItems.Clear();

                this.nodeContextMenu.MenuItems.Add(node.Text);
                this.nodeContextMenu.MenuItems.Add("-");
                this.nodeContextMenu.MenuItems[0].Enabled = false;
                if (curTreeNodeBindedObject is AEData)
                { // nothing
                    this.nodeContextMenu.MenuItems.Add("新建精灵");
                }
                else if (curTreeNodeBindedObject is AEConfig)
                {
                    this.nodeContextMenu.MenuItems.Add("修改配置");
                }
                else if (curTreeNodeBindedObject is AESprite)
                {
                    AESprite __aeSprite    = (AESprite)curTreeNodeBindedObject;
                    AESprite __upperSprite = curEditAEData.getUpperSprite(__aeSprite);
                    this.nodeContextMenu.MenuItems.Add("修改精灵");
                    this.nodeContextMenu.MenuItems.Add("覆盖动作 -- 使用复制").Enabled = (curToCopyed is ActionTemplate);
                    if (__aeSprite._canDelete)
                    {
                        this.nodeContextMenu.MenuItems.Add("删除精灵");
                    }
                    if (__aeSprite._canMove)
                    {
                        if (__upperSprite == null || __upperSprite._canMove)
                        {
                            this.nodeContextMenu.MenuItems.Add("上移精灵");
                        }
                        this.nodeContextMenu.MenuItems.Add("下移精灵");
                        this.nodeContextMenu.MenuItems.Add("新建精灵(上方)");
                        this.nodeContextMenu.MenuItems.Add("新建精灵(下方)");
                        this.nodeContextMenu.MenuItems.Add("-");
                    }

                    this.nodeContextMenu.MenuItems.Add("新建动作");
                    if (curToCopyed is ActionTemplate)
                    {
                        this.nodeContextMenu.MenuItems.Add("当前复制: " + ((ActionTemplate)curToCopyed).getTreeNode().Text).Enabled = false;
                        this.nodeContextMenu.MenuItems.Add("粘贴动作");
                    }
                    this.nodeContextMenu.MenuItems.Add("-");
                    if (__aeSprite._canMove)
                    {
                        this.nodeContextMenu.MenuItems.Add("复制精灵");
                    }
                    if (curToCopyed != null && curToCopyed is AESprite)
                    {
                        this.nodeContextMenu.MenuItems.Add("当前复制: " + ((AESprite)curToCopyed).getTreeNode().Text).Enabled = false;
                        this.nodeContextMenu.MenuItems.Add("粘贴精灵(上方)");
                        this.nodeContextMenu.MenuItems.Add("粘贴精灵(下方)");
                    }
                }
                else if (curTreeNodeBindedObject is ActionTemplate)
                {
                    ActionTemplate actionTemplate     = (ActionTemplate)curTreeNodeBindedObject;
                    Object         parentBindedObject = curEditAEData.getNodeBindedObject(actionTemplate.getTreeNode().Parent);
                    this.nodeContextMenu.MenuItems.Add("修改动作").Enabled         = (actionTemplate.actionParams.Count > 0);
                    this.nodeContextMenu.MenuItems.Add("覆盖动作 -- 使用复制").Enabled = (curToCopyed is ActionTemplate);
                    if (actionTemplate.actionList == 1 && actionTemplate.subActionList.Count == 0 ||
                        actionTemplate.actionList > 1)
                    {
                        this.nodeContextMenu.MenuItems.Add("添加子动作");
                    }
                    if (parentBindedObject is ActionTemplate)
                    {
                        if (((ActionTemplate)parentBindedObject).subActionList.Count > 1)
                        {
                            this.nodeContextMenu.MenuItems.Add("删除动作");
                            this.nodeContextMenu.MenuItems.Add("上移动作");
                            this.nodeContextMenu.MenuItems.Add("下移动作");
                        }
                        else if (actionTemplate.subActionList.Count == 1)
                        {
                            this.nodeContextMenu.MenuItems.Add("删除动作");
                        }

                        if (((ActionTemplate)parentBindedObject).actionList > 1)
                        {
                            this.nodeContextMenu.MenuItems.Add("新建动作(上方)");
                            this.nodeContextMenu.MenuItems.Add("新建动作(下方)");
                            if (curToCopyed is ActionTemplate)
                            {
                                this.nodeContextMenu.MenuItems.Add("粘贴动作(上方)");
                                this.nodeContextMenu.MenuItems.Add("粘贴动作(下方)");
                            }
                        }
                    }
                    else
                    {
                        this.nodeContextMenu.MenuItems.Add("删除动作");
                        this.nodeContextMenu.MenuItems.Add("上移动作");
                        this.nodeContextMenu.MenuItems.Add("下移动作");
                    }
                    this.nodeContextMenu.MenuItems.Add("添加父动作");
                    this.nodeContextMenu.MenuItems.Add("-");
                    this.nodeContextMenu.MenuItems.Add("复制动作");
                    if (curToCopyed != null && curToCopyed is ActionTemplate)
                    {
                        this.nodeContextMenu.MenuItems.Add("当前复制: " + ((ActionTemplate)curToCopyed).getTreeNode().Text).Enabled = false;

                        if (actionTemplate.actionList == 1 && actionTemplate.subActionList.Count == 0 || actionTemplate.actionList > 1)
                        {
                            this.nodeContextMenu.MenuItems.Add("粘贴子动作");
                        }
                    }
                }

                // 0 for Name
                for (int i = 1; i < this.nodeContextMenu.MenuItems.Count; i++)
                {
                    this.nodeContextMenu.MenuItems[i].Click += new EventHandler(contextmenu_Click);
                }
            }

            this.treeView1.Refresh();
        }
Пример #3
0
 //--------------------------------------
 //  PUBLIC METHODS
 //--------------------------------------
 public void AddChild(AESprite sprite)
 {
     sprite.transform.parent = childAnchor.transform;
 }
Пример #4
0
        //// true / false : res
        //private String isFileInResDir(String strFile)
        //{
        //    foreach (String strResDir in resPath) {
        //        //File f;
        //    }
        //}

        //private String selectPngFileInResDir()
        //{
        //    if (DialogResult.OK == openPngFileDialog.ShowDialog(this))
        //    {
        //        String file = openPngFileDialog.FileName;

        //    }
        //}

        private void contextmenu_Click(object sender, EventArgs e)
        {
            if (curTreeNodeBindedObject == null)
            {
                return;
            }
            MenuItem item = sender as MenuItem;

            if (item == null)
            {
                return;
            }

            bool __isOpDirty = true;

            if (curTreeNodeBindedObject is AEData)
            { // AEData
                AEData aeData = (AEData)curTreeNodeBindedObject;
                if (item.Text == "新建精灵")
                {
                    AESprite aeSprite = aeData.createSprite();
                    aeData.addSprite(aeSprite);
                    treeView1.SelectedNode = aeSprite.getTreeNode();
                }
            }
            else if (curTreeNodeBindedObject is AEConfig)
            { // AEConfig
                if (item.Text == "修改配置")
                {
                    curEditAEData.createConfigPropForm(this).ShowDialog(this);
                    __isOpDirty = false; // 内部设置了Dirty
                }
            }
            else if (curTreeNodeBindedObject is AESprite)
            { // AESprite
                AESprite aeSprite = (AESprite)curTreeNodeBindedObject;
                if (item.Text == "新建精灵(上方)")
                {
                    AESprite newAESprite = curEditAEData.createSprite();
                    this.curEditAEData.addSprite(newAESprite, aeSprite, true);
                    treeView1.SelectedNode = newAESprite.getTreeNode();
                }
                else if (item.Text == "新建精灵(下方)")
                {
                    AESprite newAESprite = curEditAEData.createSprite();
                    this.curEditAEData.addSprite(newAESprite, aeSprite, false);
                    treeView1.SelectedNode = newAESprite.getTreeNode();
                }
                else if (item.Text == "上移精灵")
                {
                    this.curEditAEData.moveSprite(aeSprite, true);
                    treeView1.SelectedNode = aeSprite.getTreeNode();
                }
                else if (item.Text == "下移精灵")
                {
                    this.curEditAEData.moveSprite(aeSprite, false);
                    treeView1.SelectedNode = aeSprite.getTreeNode();
                }
                else if (item.Text == "删除精灵")
                {
                    this.curEditAEData.removeSprite(aeSprite);
                }
                else if (item.Text == "修改精灵")
                {
                    this.curEditAEData.createSpritePropForm(aeSprite, this).ShowDialog(this);
                    __isOpDirty = false;  // dirty setted in PropForm setBack
                }
                else if (item.Text == "复制精灵")
                {
                    curToCopyed = aeSprite;
                    __isOpDirty = false;
                }
                else if (item.Text == "粘贴精灵(上方)")
                {
                    AESprite newSprite = curEditAEData.copySprite((AESprite)curToCopyed, table);
                    this.curEditAEData.addSprite(newSprite, aeSprite, true);
                    newSprite.recalcAndUpdate();
                    treeView1.SelectedNode = newSprite.getTreeNode();
                }
                else if (item.Text == "粘贴精灵(下方)")
                {
                    AESprite newSprite = curEditAEData.copySprite((AESprite)curToCopyed, table);
                    this.curEditAEData.addSprite(newSprite, aeSprite, false);
                    newSprite.recalcAndUpdate();
                    treeView1.SelectedNode = newSprite.getTreeNode();
                }
                else if (item.Text == "新建动作")
                {
                    alfForm.setItems(table.getActionsByIgnoreList(curEditAEData.eType, ActionTemplateTable.EActionFilterType.ACTION_LIST_1, ActionTemplateTable.EActionFilterType.ACTION_LIST_2));

                    if (alfForm.ShowDialog(this) == DialogResult.OK)
                    {
                        String selected = alfForm.getSelected();
                        if (selected != null)
                        {
                            ActionTemplate action = table.createActionByNote(selected);
                            aeSprite.addAction(action);
                            treeView1.SelectedNode = action.getTreeNode();
                        }
                    }
                }
                else if (item.Text == "粘贴动作")
                {
                    if (curToCopyed is ActionTemplate)
                    {
                        aeSprite.addAction(((ActionTemplate)curToCopyed).copy(table));
                    }
                }
            }
            else if (curTreeNodeBindedObject is ActionTemplate)
            { // ActionTemplate
                ActionTemplate actionTemplate     = (ActionTemplate)curTreeNodeBindedObject;
                Object         parentBindedObject = curEditAEData.getNodeBindedObject(actionTemplate.getTreeNode().Parent);
                if (item.Text == "修改动作")
                {
                    new ActionPropForm(actionTemplate, this).ShowDialog(this);
                    __isOpDirty = false; // 内部设置了Dirty
                }
                if (item.Text == "复制动作")
                {
                    curToCopyed = actionTemplate.copy(table);
                    __isOpDirty = false;
                }
                else if (item.Text == "添加子动作")
                {
                    if (actionTemplate.actionList == 0)
                    {
                        return;
                    }
                    if (actionTemplate.actionList == 1 && actionTemplate.subActionList.Count >= 1)
                    {
                        return;
                    }

                    if (!actionTemplate.isContainGridSubAction())
                    {
                        alfForm.setItems(table.getActionsByIgnoreList(curEditAEData.eType, ActionTemplateTable.EActionFilterType.ACTION_LIST_1,
                                                                      ActionTemplateTable.EActionFilterType.ACTION_LIST_2));
                    }
                    else
                    {
                        alfForm.setItems(table.getActionsByIgnoreList(curEditAEData.eType, ActionTemplateTable.EActionFilterType.ACTION_LIST_1,
                                                                      ActionTemplateTable.EActionFilterType.ACTION_LIST_2,
                                                                      ActionTemplateTable.EActionFilterType.GRID));
                    }
                    if (alfForm.ShowDialog(this) == DialogResult.OK)
                    {
                        String selected = alfForm.getSelected();
                        if (selected != null)
                        {
                            ActionTemplate newAction = table.createActionByNote(selected);
                            actionTemplate.addSubAction(newAction);
                            treeView1.SelectedNode = newAction.getTreeNode();
                        }
                    }
                }
                else if (item.Text == "粘贴子动作")
                {
                    if (actionTemplate.actionList == 0)
                    {
                        return;
                    }
                    if (actionTemplate.actionList == 1 && actionTemplate.subActionList.Count >= 1)
                    {
                        return;
                    }
                    if (curToCopyed is ActionTemplate)
                    {
                        ActionTemplate newAction = ((ActionTemplate)curToCopyed).copy(table);
                        actionTemplate.addSubAction(newAction);
                        treeView1.SelectedNode = newAction.getTreeNode();
                    }
                }

                if (parentBindedObject is AESprite)
                {
                    AESprite parent = (AESprite)parentBindedObject;
                    if (item.Text == "覆盖动作 -- 使用复制")
                    {
                        if (curToCopyed is ActionTemplate)
                        {
                            ActionTemplate newAction = ((ActionTemplate)curToCopyed).copy(table);
                            parent.addAction(newAction, actionTemplate, true);
                            treeView1.SelectedNode = newAction.getTreeNode();
                            parent.removeAction(actionTemplate);
                        }
                    }
                    else if (item.Text == "删除动作")
                    {
                        if (actionTemplate.subActionList.Count == 1)
                        {
                            ActionTemplate actionToAddBack = actionTemplate.subActionList[0];
                            actionTemplate.removeSubAction(actionToAddBack, false);
                            parent.replaceAction(actionTemplate, actionToAddBack);

                            treeView1.SelectedNode = actionToAddBack.getTreeNode();
                        }
                        else
                        {
                            parent.removeAction(actionTemplate);
                        }
                    }
                    else if (item.Text == "上移动作")
                    {
                        parent.moveAction(actionTemplate, true);
                    }
                    else if (item.Text == "下移动作")
                    {
                        parent.moveAction(actionTemplate, false);
                    }
                    else if (item.Text == "添加父动作")
                    {
                        if (actionTemplate.eActionType == EActionType.CCActionInstant)
                        {
                            alfForm.setItems(table.getActionsByPerferList(curEditAEData.eType, ActionTemplateTable.EActionFilterType.SPAWN_AND_SEQUENCE));
                        }
                        else
                        {
                            alfForm.setItems(table.getActionsByPerferList(curEditAEData.eType, ActionTemplateTable.EActionFilterType.ACTION_LIST_1,
                                                                          ActionTemplateTable.EActionFilterType.ACTION_LIST_2));
                        }

                        if (alfForm.ShowDialog(this) == DialogResult.OK)
                        {
                            String selected = alfForm.getSelected();
                            if (selected != null)
                            {
                                ActionTemplate newAction = table.createActionByNote(selected);
                                parent.replaceAction(actionTemplate, newAction);
                                newAction.addSubAction(actionTemplate);
                                treeView1.SelectedNode = actionTemplate.getTreeNode();
                                newAction.getTreeNode().ExpandAll();
                            }
                        }
                    }
                }
                else if (parentBindedObject is ActionTemplate)
                {
                    ActionTemplate parent = (ActionTemplate)parentBindedObject;
                    if (item.Text == "覆盖动作 -- 使用复制")
                    {
                        if (curToCopyed is ActionTemplate)
                        {
                            ActionTemplate newAction = ((ActionTemplate)curToCopyed).copy(table);
                            parent.addSubAction(newAction, actionTemplate, true);
                            treeView1.SelectedNode = newAction.getTreeNode();
                            parent.removeSubAction(actionTemplate);
                        }
                    }
                    else if (item.Text == "删除动作")
                    {
                        if (actionTemplate.subActionList.Count == 1)
                        {
                            ActionTemplate actionToAddBack = actionTemplate.subActionList[0];
                            actionTemplate.removeSubAction(actionToAddBack, false);
                            parent.replaceAction(actionTemplate, actionToAddBack);

                            treeView1.SelectedNode = actionToAddBack.getTreeNode();
                        }
                        else
                        {
                            parent.removeSubAction(actionTemplate);
                        }
                    }
                    else if (item.Text == "新建动作(上方)")
                    {
                        if (parent.actionList <= 1)
                        {
                            return;
                        }
                        if (!parent.isContainGridSubAction())
                        {
                            alfForm.setItems(table.getActionsByIgnoreList(curEditAEData.eType, ActionTemplateTable.EActionFilterType.ACTION_LIST_1,
                                                                          ActionTemplateTable.EActionFilterType.ACTION_LIST_2));
                        }
                        else
                        {
                            alfForm.setItems(table.getActionsByIgnoreList(curEditAEData.eType, ActionTemplateTable.EActionFilterType.ACTION_LIST_1,
                                                                          ActionTemplateTable.EActionFilterType.ACTION_LIST_2,
                                                                          ActionTemplateTable.EActionFilterType.GRID));
                        }
                        if (alfForm.ShowDialog(this) == DialogResult.OK)
                        {
                            String selected = alfForm.getSelected();
                            if (selected != null)
                            {
                                ActionTemplate newAction = table.createActionByNote(selected);
                                parent.addSubAction(newAction, actionTemplate, true);
                                treeView1.SelectedNode = newAction.getTreeNode();
                            }
                        }
                    }
                    else if (item.Text == "新建动作(下方)")
                    {
                        if (parent.actionList <= 1)
                        {
                            return;
                        }
                        if (!parent.isContainGridSubAction())
                        {
                            alfForm.setItems(table.getActionsByIgnoreList(curEditAEData.eType, ActionTemplateTable.EActionFilterType.ACTION_LIST_1,
                                                                          ActionTemplateTable.EActionFilterType.ACTION_LIST_2));
                        }
                        else
                        {
                            alfForm.setItems(table.getActionsByIgnoreList(curEditAEData.eType, ActionTemplateTable.EActionFilterType.ACTION_LIST_1,
                                                                          ActionTemplateTable.EActionFilterType.ACTION_LIST_2,
                                                                          ActionTemplateTable.EActionFilterType.GRID));
                        }
                        if (alfForm.ShowDialog(this) == DialogResult.OK)
                        {
                            String selected = alfForm.getSelected();
                            if (selected != null)
                            {
                                ActionTemplate newAction = table.createActionByNote(selected);
                                parent.addSubAction(newAction, actionTemplate, false);
                                treeView1.SelectedNode = newAction.getTreeNode();
                            }
                        }
                    }
                    else if (item.Text == "粘贴动作(上方)")
                    {
                        if (parent.actionList <= 1)
                        {
                            return;
                        }
                        if (curToCopyed is ActionTemplate)
                        {
                            ActionTemplate newAction = ((ActionTemplate)curToCopyed).copy(table);
                            parent.addSubAction(newAction, actionTemplate, true);
                            treeView1.SelectedNode = newAction.getTreeNode();
                        }
                    }
                    else if (item.Text == "粘贴动作(下方)")
                    {
                        if (parent.actionList <= 1)
                        {
                            return;
                        }
                        if (curToCopyed is ActionTemplate)
                        {
                            ActionTemplate newAction = ((ActionTemplate)curToCopyed).copy(table);
                            parent.addSubAction(newAction, actionTemplate, false);
                            treeView1.SelectedNode = newAction.getTreeNode();
                        }
                    }
                    else if (item.Text == "上移动作")
                    {
                        parent.moveSubAction(actionTemplate, true);
                    }
                    else if (item.Text == "下移动作")
                    {
                        parent.moveSubAction(actionTemplate, false);
                    }
                    else if (item.Text == "添加父动作")
                    {
                        if (actionTemplate.eActionType == EActionType.CCActionInstant)
                        {
                            alfForm.setItems(table.getActionsByPerferList(curEditAEData.eType, ActionTemplateTable.EActionFilterType.SPAWN_AND_SEQUENCE));
                        }
                        else
                        {
                            alfForm.setItems(table.getActionsByPerferList(curEditAEData.eType, ActionTemplateTable.EActionFilterType.ACTION_LIST_1,
                                                                          ActionTemplateTable.EActionFilterType.ACTION_LIST_2));
                        }

                        if (alfForm.ShowDialog(this) == DialogResult.OK)
                        {
                            String selected = alfForm.getSelected();
                            if (selected != null)
                            {
                                ActionTemplate newAction = table.createActionByNote(selected);
                                parent.replaceAction(actionTemplate, newAction);
                                newAction.addSubAction(actionTemplate);
                                treeView1.SelectedNode = actionTemplate.getTreeNode();
                                newAction.getTreeNode().ExpandAll();
                            }
                        }
                    }
                }
            }

            curEditAEData.recalcAndUpdate();
            if (__isOpDirty)
            {
                setDirty(__isOpDirty);
            }
            curTreeNodeBindedObject = null;
            treeView1.Update();
        }
    public float GetLayerGlobalZ(float index, AESprite sp)
    {
        zIndexHolder.transform.localPosition = new Vector3 (0, 0, index * AEConf.ZPosPadding);
        zIndexHolder.transform.parent = sp.transform.parent;
        float depth = zIndexHolder.transform.localPosition.z;

        zIndexHolder.transform.parent = transform;

        return depth;
    }