Exemplo n.º 1
0
        public override NotifyResult notified(EditorComponent from, MessageBase msg)
        {
            switch (msg.MsgType)
            {
                case MessageType.Editor:
                    Domain domain = null;
                    switch (msg.getNote<SceneEditorNote>())
                    {
                        case SceneEditorNote.DocInitDone:
                            domain = DomainManager.Instance().getDomain(this);
                            mUI.EntityMng = domain.getCurrentDoc().EntityMng as SceneEntityManager;
                            break;

                    }
                    switch (msg.getNote<CommonEntityNode>())
                    {
                        case CommonEntityNode.SelectedEntityChanged:
                            domain = DomainManager.Instance().getDomain(this);
                            mUI.EntityMng = domain.getCurrentDoc().EntityMng as SceneEntityManager;
                            mUI.refreshPropertyGrid();
                            break;
                    }
                    break;
            }
            return NotifyResult.Pending;
        }
Exemplo n.º 2
0
        static void GenerateVariableRelatedCode(StreamWriter writer, EditorComponent component)
        {
            int code_variable_count = 0;
            int attribute_count     = 0;

            for (int i = 0; i < component.m_variables.Count; ++i)
            {
                EditorVariable variable = component.m_variables[i];
                if (variable.m_code_name == null)
                {
                    continue;
                }
                if (variable.NeedDeclareVariable())
                {
                    ++code_variable_count;
                    writer.Write("\r\n        public const int ");
                    writer.Write(variable.m_code_name);
                    writer.Write(" = ");
                    writer.Write(((int)CRC.Calculate(variable.m_config_name)).ToString());
                    writer.Write(";");
                }
                if (variable.NeedCSAttribute())
                {
                    ++attribute_count;
                }
            }

            bool generate = code_variable_count > 0 || component.Need_InitializeVariable();

            if (m_logic == false && generate)
            {
                writer.Write("\r\n\r\n#if COMBAT_CLIENT");
            }

            if (code_variable_count > 0)
            {
                Generate_StaticConstructor(writer, component);
            }
            if (component.Need_InitializeVariable())
            {
                Generate_InitializeVariable(writer, component);
            }
            if (code_variable_count > 0 && component.Need_GetVariable())
            {
                Generate_GetVariable(writer, component);
            }
            if (code_variable_count > 0 && component.Need_SetVariable())
            {
                Generate_SetVariable(writer, component);
            }
            if (attribute_count > 0 && component.Need_CSharpAttribute())
            {
                Generate_CSharpAttribute(writer, component);
            }

            if (m_logic == false && generate)
            {
                writer.Write("\r\n#endif");
            }
        }
Exemplo n.º 3
0
        public static void RegisterComponent(Type t, EditorComponent component)
        {
            if (knownComponents == null)
            {
                knownComponents = new Dictionary <Type, List <EditorComponent> >();
            }

            if (!knownComponents.ContainsKey(t))
            {
                knownComponents.Add(t, new List <EditorComponent>());
            }

            if (component is BaseWindow)
            {
                (component as BaseWindow).OnRequestRepaint = () => thisWindowReference.Repaint();
            }

            // if there's a component of the same tipe already registered we ignore it
            if (knownComponents[t].Any(c => c.GetType() == component.GetType()))
            {
                return;
            }

            knownComponents[t].Add(component);
            knownComponents[t].Sort((c1, c2) => CompareComponents(c1, c2));
        }
Exemplo n.º 4
0
 public override NotifyResult notified(EditorComponent from, MessageBase msg)
 {
     switch (msg.MsgType)
     {
         case MessageType.Doc:
             switch (msg.getNote<SceneEditorNote>())
             {
                 case SceneEditorNote.DocInitDone:
                     mUI.initialize();
                     break;
             }
             break;
         case MessageType.NewDoc:
             mUI.initialize();
             break;
         case MessageType.Editor:
             switch (msg.getNote<CommonEntityNode>())
             {
                 case CommonEntityNode.EntityCreated:
                     mUI.refreshEntityTree(null);
                     break;
             }
             break; ;
     }
     return NotifyResult.Pending;
 }
Exemplo n.º 5
0
        private static int CompareComponents(EditorComponent c1, EditorComponent c2)
        {
            var c1Attr = c1.GetType().GetCustomAttributes(typeof(EditorComponentAttribute), true)[0] as EditorComponentAttribute;
            var c2Attr = c2.GetType().GetCustomAttributes(typeof(EditorComponentAttribute), true)[0] as EditorComponentAttribute;

            return(c1Attr.Order.CompareTo(c2Attr.Order));
        }
Exemplo n.º 6
0
 private void OnMessageExpandRightPanel(EditorComponent from, MessageBase msg)
 {
     if (msg.Messages.Count != 0)
     {
         string info0 = msg.Messages[0];
         m_modelview_form.setRightPanelExpand(info0 == "true");
     }
 }
Exemplo n.º 7
0
 private void onAfterModelCreatedMessage(EditorComponent from, MessageBase msg)
 {
     //if (Doc.CurrentDynamicModel != null)
     //{
     //    BoneListUI.updateBoneList(Doc.CurrentDynamicModel.RootBone);
     //}
     //else
     //    BoneListUI.updateBoneList(null);
 }
Exemplo n.º 8
0
 // Update component selection
 // Used to save selection history
 public void NewSelection(EditorComponent c)
 {
     // selection starts at null
     if (selection != null)
     {
         selectionStack.Push(selection);
     }
     selection = c;
 }
Exemplo n.º 9
0
        public override NotifyResult notified(EditorComponent from, MessageBase msg)
        {
            NotifyResult nr = base.notified(from, msg);

            if (msg.MsgType == MessageType.NewDoc)
            {
                m_current_doc.newDoc();
            }

            return nr;
        }
Exemplo n.º 10
0
        public static void RegisterComponent(EditorComponent component)
        {
            var attr = GetAttribute(component.GetType());

            if (attr != null)
            {
                foreach (var t in attr.Types)
                {
                    uAdventureWindowMain.Instance.RegisterComponent(t, component);
                }
            }
        }
Exemplo n.º 11
0
        public static void RegisterComponent(EditorComponent component)
        {
            var attr = GetAttribute(component.GetType());

            if (attr != null)
            {
                foreach (var t in attr.Types)
                {
                    EditorWindowBase.RegisterComponent(t, component);
                }
            }
        }
Exemplo n.º 12
0
        //static void Generate_ActivateAllRegisteredComponents(StreamWriter writer)
        //{
        //    writer.Write("\r\n        static public void ActivateAllRegisteredComponents()\r\n        {");
        //    writer.Write("\r\n            int id = 0;");
        //    for (int i = 0; i < m_logic_componnets.Count; ++i)
        //    {
        //        writer.Write("\r\n            id = ");
        //        writer.Write(m_logic_componnets[i].m_name);
        //        writer.Write(".ID;");
        //    }
        //    writer.Write("\r\n#if COMBAT_CLIENT");
        //    for (int i = 0; i < m_render_componnets.Count; ++i)
        //    {
        //        writer.Write("\r\n            id = ");
        //        writer.Write(m_logic_componnets[i].m_name);
        //        writer.Write(".ID;");
        //    }
        //    writer.Write("\r\n#endif\r\n        }");
        //}

        static void GenerateOneComponent(StreamWriter writer, EditorComponent component)
        {
            writer.Write("    public partial class ");
            writer.Write(component.m_name);
            writer.Write("\r\n    {\r\n        public const int ID = ");
            writer.Write(((int)CRC.Calculate(component.m_name)).ToString());
            writer.Write(";");
            if (component.m_variables.Count > 0)
            {
                GenerateVariableRelatedCode(writer, component);
            }
            writer.Write("\r\n    }");
        }
Exemplo n.º 13
0
 public Domain getDomain(EditorComponent comp)
 {
     List<EditorComponent> parents = EditorGraph.getParents(comp);
     foreach (EditorComponent parent in parents)
     {
         Domain domain = parent as Domain;
         if (domain != null && m_domains.Contains(domain))
         {
             return domain;
         }
     }
     return null;
 }
Exemplo n.º 14
0
        static EditorComponent REGISTER_COMPONENT <T>(int flag = Flag_LogicComponent)
        {
            EditorComponent new_cmp = new EditorComponent();

            new_cmp.m_name = typeof(T).Name;
            new_cmp.m_flag = flag;
            if (m_logic)
            {
                m_logic_componnets.Add(new_cmp);
            }
            else
            {
                m_render_componnets.Add(new_cmp);
            }
            return(new_cmp);
        }
Exemplo n.º 15
0
 static void Generate_StaticConstructor(StreamWriter writer, EditorComponent component)
 {
     writer.Write("\r\n\r\n        static ");
     writer.Write(component.m_name);
     writer.Write("()\r\n        {");
     for (int i = 0; i < component.m_variables.Count; ++i)
     {
         EditorVariable variable = component.m_variables[i];
         if (variable.m_code_name == null || !variable.NeedDeclareVariable())
         {
             continue;
         }
         writer.Write("\r\n            ComponentTypeRegistry.RegisterVariable(");
         writer.Write(variable.m_code_name);
         writer.Write(", ID);");
     }
     writer.Write("\r\n        }");
 }
Exemplo n.º 16
0
        public override NotifyResult notified(EditorComponent from, MessageBase msg)
        {
            switch (msg.MsgType)
            {
                case MessageType.Doc:
                    switch (msg.getNote<SceneEditorNote>())
                    {
                        case SceneEditorNote.DocInitDone:
                            Domain domain = DomainManager.Instance().getDomain(this);
                            mEntityMng = domain.getCurrentDoc().EntityMng as SceneEntityManager;
                            mWorld = domain.getCurrentDoc().World as SceneWorld;
                            break;
                    }
                    break; ;
            }

            return base.notified(from, msg);
        }
Exemplo n.º 17
0
 public static void RegisterComponent <T>(EditorComponent component)
 {
     RegisterComponent(typeof(T), component);
 }
Exemplo n.º 18
0
 private void onAfterModelViewUICreatedMessage(EditorComponent from, MessageBase msg)
 {
     refreshActionList();
 }
Exemplo n.º 19
0
 private void onUIUpdateCurrentFrameMessage(EditorComponent from, MessageBase msg)
 {
     if (msg.Messages.Count != 0)
     {
         string s = msg.Messages[0];
         if (int.TryParse(s, out CurrentFrame))
         {
             ActionTimeLineUI.updateUI();
         }
     }
 }
Exemplo n.º 20
0
        public override NotifyResult notified(EditorComponent from, MessageBase msg)
        {
            if (msg.MsgType != MessageType.Log || msg.Messages.Count < 1)
                return NotifyResult.Pending;

            if(msg.Messages.Count == 1)
                m_log_form.addNewLog(msg.Messages[0]);
            else if (msg.Messages.Count > 1)
            {
                string msgex = msg.Messages[0] + ": " +DateTime.Now.ToString() + ": " + msg.Messages[1];
                m_log_form.addNewLog(msgex);
            }

            return NotifyResult.Succeed;
        }
Exemplo n.º 21
0
        static void Generate_CSharpAttribute(StreamWriter writer, EditorComponent component)
        {
            bool need = false;

            for (int i = 0; i < component.m_variables.Count; ++i)
            {
                EditorVariable variable = component.m_variables[i];
                if (variable.m_code_fragment == null || variable.m_code_name == null || (!variable.CanAttributeGet() && !variable.CanAttributeSet()))
                {
                    continue;
                }
                need = true;
                break;
            }
            if (!need)
            {
                return;
            }

            writer.Write("\r\n\r\n#region GETTER/SETTER");
            //        public FixPoint X
            //        {
            //            get { return m_current_position.x; }
            //            set { m_current_position.x = value; }
            //        }
            bool first = true;

            for (int i = 0; i < component.m_variables.Count; ++i)
            {
                EditorVariable variable = component.m_variables[i];
                if (variable.m_code_fragment == null || variable.m_code_name == null || (!variable.CanAttributeGet() && !variable.CanAttributeSet()))
                {
                    continue;
                }
                if (first)
                {
                    writer.Write("\r\n        public ");
                    first = false;
                }
                else
                {
                    writer.Write("\r\n\r\n        public ");
                }
                if (variable.IsFormula())
                {
                    writer.Write("FixPoint ");
                }
                else
                {
                    writer.Write(variable.m_type_name);
                    writer.Write(" ");
                }
                writer.Write(variable.m_code_name.Substring(4));
                writer.Write("\r\n        {");
                if (variable.CanAttributeGet())
                {
                    writer.Write("\r\n            get { return ");
                    if (variable.IsFormula())
                    {
                        writer.Write(variable.m_code_fragment);
                        writer.Write(".Evaluate(this); }");
                    }
                    else
                    {
                        writer.Write(variable.m_code_fragment);
                        writer.Write("; }");
                    }
                }
                if (variable.CanAttributeSet())
                {
                    writer.Write("\r\n            set { ");
                    writer.Write(variable.m_code_fragment);
                    writer.Write(" = value; }");
                }
                writer.Write("\r\n        }");
            }
            writer.Write("\r\n#endregion");
        }
Exemplo n.º 22
0
        static void Generate_SetVariable(StreamWriter writer, EditorComponent component)
        {
            bool need = false;

            for (int i = 0; i < component.m_variables.Count; ++i)
            {
                EditorVariable variable = component.m_variables[i];
                if (variable.m_code_fragment == null || variable.m_code_name == null || !variable.CanVariableSet() || variable.IsFormula())
                {
                    continue;
                }
                need = true;
                break;
            }
            if (!need)
            {
                return;
            }
            //        public override bool SetVariable(int id, FixPoint value)
            //        {
            //            switch (id)
            //            {
            //            case VID_X:
            //                m_current_position.x = value;
            //                return true;
            //            default:
            //                return false;
            //            }
            //        }
            writer.Write(
                @"

        public override bool SetVariable(int id, FixPoint value)
        {
            switch (id)
            {");
            for (int i = 0; i < component.m_variables.Count; ++i)
            {
                EditorVariable variable = component.m_variables[i];
                if (variable.m_code_fragment == null || variable.m_code_name == null || !variable.CanVariableSet() || variable.IsFormula())
                {
                    continue;
                }
                writer.Write("\r\n            case ");
                writer.Write(variable.m_code_name);
                writer.Write(":\r\n                ");
                writer.Write(variable.m_code_fragment);
                if (variable.NeedCast())
                {
                    writer.Write(" = (");
                    writer.Write(variable.m_type_name);
                    writer.Write(")value;");
                }
                else
                {
                    writer.Write(" = value;");
                }
                writer.Write("\r\n                return true;");
            }
            writer.Write(
                @"
            default:
                return false;
            }
        }");
        }
Exemplo n.º 23
0
        static void Generate_InitializeVariable(StreamWriter writer, EditorComponent component)
        {
            bool need = false;

            for (int i = 0; i < component.m_variables.Count; ++i)
            {
                EditorVariable variable = component.m_variables[i];
                if (!variable.CanVariableInit())
                {
                    continue;
                }
                need = true;
                break;
            }
            if (!need)
            {
                return;
            }
            //        public override void InitializeVariable(Dictionary<string, string> variables)
            //        {
            //            string value;
            //            if (variables.TryGetValue("x", out value))
            //                m_current_position.x = int.Parse(value);
            //        }
            writer.Write(
                @"

        public override void InitializeVariable(Dictionary<string, string> variables)
        {
            string value;");
            for (int i = 0; i < component.m_variables.Count; ++i)
            {
                EditorVariable variable = component.m_variables[i];
                if (!variable.CanVariableInit())
                {
                    continue;
                }
                writer.Write("\r\n            if (variables.TryGetValue(\"");
                writer.Write(variable.m_config_name);
                writer.Write("\", out value))\r\n                ");
                writer.Write(variable.m_code_fragment);
                if (variable.IsFormula())
                {
                    writer.Write(".Compile(value);");
                }
                //else if (variable.NeedParse())
                //{
                //    if (variable.Transform2Crc())
                //        writer.Write(" = (int)CRC.Calculate(");
                //    else
                //        writer.Write(" = ");
                //    writer.Write(variable.m_type_name);
                //    if (variable.Transform2Crc())
                //        writer.Write(".Parse(value));");
                //    else
                //        writer.Write(".Parse(value);");
                //}
                //else
                //{
                //    if (variable.Transform2Crc())
                //        writer.Write(" = (int)CRC.Calculate(value);");
                //    else
                //        writer.Write(" = value;");
                //}
                else if (variable.Transform2Crc())
                {
                    writer.Write(" = (int)CRC.Calculate(value);");
                }
                else if (variable.NeedParse())
                {
                    writer.Write(" = ");
                    writer.Write(variable.m_type_name);
                    writer.Write(".Parse(value);");
                }
                else
                {
                    writer.Write(" = value;");
                }
            }
            writer.Write("\r\n        }");
        }
Exemplo n.º 24
0
 private void onMessageEntityCreated(EditorComponent from, MessageBase msg)
 {
 }
Exemplo n.º 25
0
 private void onAfterModelActionChangedMessage(EditorComponent from, MessageBase msg)
 {
     resetUIByCurrentAction();
 }
Exemplo n.º 26
0
 public static EditorDoc GetCurrentDoc(EditorComponent component)
 {
     Domain domain = DomainManager.Instance().getDomain(component);
     return domain == null ? null : domain.getCurrentDoc();
 }
Exemplo n.º 27
0
        private void onOpenFileMessage(EditorComponent from, MessageBase msg)
        {
            string file_name = "";

            if (msg.Messages.Count != 0)
            {
                file_name = msg.Messages[0];
            }
            else
            {
                System.Windows.Forms.OpenFileDialog of = new System.Windows.Forms.OpenFileDialog();
                of.Title = "打开...";
                of.ShowReadOnly = true;
                of.Filter = "Model Files(*.dml;*.chr)|*.dml;*.chr";
                of.FilterIndex = 1;
                of.RestoreDirectory = true;
                of.InitialDirectory = "../assets/";
                file_name = of.FileName;
                if (of.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    file_name = of.FileName;
                }
            }

            open(file_name);
        }
Exemplo n.º 28
0
 public override NotifyResult notified(EditorComponent from, MessageBase msg)
 {
     return NotifyResult.Succeed;
 }
Exemplo n.º 29
0
 public static void newLog(EditorComponent from,string msg)
 {
     EditorGraph.notify("Log", from, new MessageBase(MessageType.Log, from.getName(), msg));
 }