Esempio n. 1
0
 /// <summary>Returns cpp code which create gc::Vec2</summary>
 /// <returns> ::gc::SpriteFrame(FilePath, Duration) </returns>
 internal string GetCppCtor()
 {
     if (FilePath == null)
     {
         throw new Exception("In SpriteFrame.GetCppCtor(): FilePath != null assertion failed");
     }
     return("::gc::SpriteFrame(::gc::Sprite(" + Glance.ToCppString(FilePath) + "), " + Glance.floatToString(Duration) + ")");
 }
Esempio n. 2
0
        internal override string GetComponentsConstructors()
        {
            var result = new List <string>();

            foreach (var i in _components)
            {
                result.AddRange(i.GetCppConstructor());
            }
            return(Glance.GatherStringList(result, ", "));
        }
Esempio n. 3
0
        internal string GetConstructors()
        {
            if (_layerList.Count == 0)
            {
                return("");
            }
            var list = new List <string>();

            foreach (var i in _layerList)
            {
                list.Add(i.ObjectName + "(*this)");
            }
            return(":\n" + Glance.GatherStringList(list, ", "));
        }
Esempio n. 4
0
        internal override string GetComponentsVariables()
        {
            string result = "";
            var    dict   = new Dictionary <Glance.FieldsAccessType, List <string> >();

            foreach (var i in _components)
            {
                dict.gAddOrMerge(i.GetCppVariables());
            }
            result += "public:\n";
            result += Glance.GatherStringList(dict.gGetByKeyOrDefault(Glance.FieldsAccessType.Public), ";\n");
            result += "private:\n";
            result += Glance.GatherStringList(dict.gGetByKeyOrDefault(Glance.FieldsAccessType.Private), ";\n");
            //do not distinct array, if in components two same variables, it must cause compiling error
            return(result);
        }
Esempio n. 5
0
        internal override string GetComponentsMethodsDeclaration()
        {
            string result = "";
            var    dict   = new Dictionary <Glance.FieldsAccessType, List <string> >();

            foreach (var i in _components)
            {
                dict.gAddOrMerge(i.GetCppMethodsDeclaration());
            }
            //distinct array
            result += "public:\n";
            result += Glance.GatherStringList(dict.gGetByKeyOrDefault(Glance.FieldsAccessType.Public).Distinct().ToList(), ";\n");
            result += "private:\n";
            result += Glance.GatherStringList(dict.gGetByKeyOrDefault(Glance.FieldsAccessType.Private).Distinct().ToList(), ";\n");
            //some methods may repeat in different components, it's normal
            return(result);
        }
Esempio n. 6
0
        internal override string GetComponentsMethodsImplementation()
        {
            string result    = "";
            var    functions = new Dictionary <string, string>();

            foreach (var i in _components)
            {
                Glance.MergeDictionary(ref functions, i.GetCppMethodsImplementation());
            }
            foreach (var i in functions)
            {
                if (i.Key != "")
                {
                    result += Glance.GetRetTypeFromSignature(i.Key) + ' ' + ClassName + "::" + Glance.GetSignatureWithoutRetType(i.Key) + '{' + i.Value + '}' + '\n';
                }
            }
            return(result);
        }
Esempio n. 7
0
        internal override string GetComponentsConstructors()
        {
            if (GraphComponent == null)
            {
                throw new InvalidOperationException("GraphComponent for Object " + ClassName + "is empty");
            }
            List <string> result = new List <string>();

            foreach (var i in _components)
            {
                result.AddRange(i.GetCppConstructor());
            }
            result.AddRange(GraphComponent.GetCppConstructor());
            if (result.Count == 0)
            {
                return("");
            }
            return(", " + Glance.GatherStringList(result, ", "));
        }
Esempio n. 8
0
        /// <summary>return all variables of this layer</summary>
        internal string GetVariables()
        {
            string result = "";
            var    dict   = new Dictionary <Glance.FieldsAccessType, List <string> >();

            foreach (var i in _scripts)
            {
                dict.gAddOrMerge(i.GetCppVariables());
            }
            dict = dict.gRemoveWhiteSpace();

            result += "\npublic:\n";
            result += Glance.GatherStringList(dict.gGetByKeyOrDefault(Glance.FieldsAccessType.Public), ";\n") + ';';
            foreach (var i in _objects)
            {
                result += i.ClassName + ' ' + i.ObjectName + ";\n";                //in public area
            }
            result += "\nprivate:\n";
            result += Glance.GatherStringList(dict.gGetByKeyOrDefault(Glance.FieldsAccessType.Private), ";\n") + ';';
            return(result);
        }
Esempio n. 9
0
        internal override string GetComponentsMethodsDeclaration()
        {
            if (GraphComponent == null)
            {
                throw new InvalidOperationException("GraphComponent for Object " + ClassName + "is empty");
            }
            string result = "";
            var    dict   = new Dictionary <Glance.FieldsAccessType, List <string> >();

            foreach (var i in _components)
            {
                dict.gAddOrMerge(i.GetCppMethodsDeclaration());
            }
            dict.gAddOrMerge(GraphComponent.GetCppMethodsDeclaration());
            //distinct array
            result += "public:\n";
            result += Glance.GatherStringList(dict.gGetByKeyOrDefault(Glance.FieldsAccessType.Public).Distinct().ToList(), ";\n") + ';';
            result += "private:\n";
            result += Glance.GatherStringList(dict.gGetByKeyOrDefault(Glance.FieldsAccessType.Private).Distinct().ToList(), ";\n") + ';';
            //some methods may repeat in different components, it's normal
            return(result);
        }
Esempio n. 10
0
        internal override string GetComponentsVariables()
        {
            if (GraphComponent == null)
            {
                throw new InvalidOperationException("GraphComponent for Object " + ClassName + "is empty");
            }
            string result = "";
            var    dict   = new Dictionary <Glance.FieldsAccessType, List <string> >();

            foreach (var i in _components)
            {
                dict.gAddOrMerge(i.GetCppVariables());
            }
            dict.gAddOrMerge(GraphComponent.GetCppVariables());
            dict = dict.gRemoveWhiteSpace();

            result += "\npublic:\n";
            result += Glance.GatherStringList(dict.gGetByKeyOrDefault(Glance.FieldsAccessType.Public), ";\n") + ';';
            result += "\nprivate:\n";
            result += Glance.GatherStringList(dict.gGetByKeyOrDefault(Glance.FieldsAccessType.Private), ";\n") + ';';
            return(result);
        }
Esempio n. 11
0
        internal override string GetComponentsMethodsImplementation()
        {
            if (GraphComponent == null)
            {
                throw new InvalidOperationException("GraphComponent for Object " + ClassName + "is empty");
            }
            string result    = "";
            var    functions = new Dictionary <string, string>();

            foreach (var i in _components)
            {
                Glance.MergeDictionary(ref functions, i.GetCppMethodsImplementation());
            }
            Glance.MergeDictionary(ref functions, GraphComponent.GetCppMethodsImplementation());
            foreach (var i in functions)
            {
                if (i.Key != "")
                {
                    result += Glance.GetRetTypeFromSignature(i.Key) + ' ' + ClassName + "::" + Glance.GetSignatureWithoutRetType(i.Key) + '{' + i.Value + '}' + '\n';
                }
            }
            return(result);
        }