コード例 #1
0
        private static void Replace(PListDict dict, String key, String value)
        {
            if (value == null)
            {
                if (dict.ContainsKey(key))
                {
                    dict.Remove(key);
                }
                return;
            }

            if (!dict.ContainsKey(key))
            {
                dict[key] = new PListString(value);
                return;
            }

            PListString pListString = dict[key] as PListString;

            if (pListString == null)
            {
                dict[key] = new PListString(value);
                return;
            }

            String currentValue = pListString.Value;

            if (currentValue.StartsWith("${") && currentValue.EndsWith("}"))
            {
                dict[key] = new PListString(value);
                return;
            }
        }
コード例 #2
0
        public static string GetMatchImage(string filePath)
        {
            PListDict plistDict = PlistParticleReader.ReadPlist(filePath);

            if (plistDict.ContainsKey("textureImageData"))
            {
                return((string)null);
            }
            return(((PListElement <string>)plistDict["textureFileName"]).Value);
        }
コード例 #3
0
        public static PlistImageFormat CreatePlistFormat(PListDict rootPlistDict)
        {
            if (!rootPlistDict.ContainsKey("metadata"))
            {
                return((PlistImageFormat)null);
            }
            switch ((int)((PListElement <long>)(rootPlistDict["metadata"] as PListDict)["format"]).Value)
            {
            case 0:
                return((PlistImageFormat) new PlistFormatCocos2d_Original());

            case 1:
                return((PlistImageFormat) new PlistFormatCocos2d_0994());

            case 2:
                return((PlistImageFormat) new PlistFormatCocos2d());

            case 3:
                return((PlistImageFormat) new PlistFormatZwoptex());

            default:
                return((PlistImageFormat)null);
            }
        }
コード例 #4
0
        private static void Replace(PListDict dict, String key, String value)
        {
            if (value == null)
            {
                if (dict.ContainsKey(key))
                {
                    dict.Remove(key);
                }
                return;
            }

            if (!dict.ContainsKey(key))
            {
                dict[key] = new PListString(value);
                return;
            }

            PListString pListString = dict[key] as PListString;
            if (pListString == null)
            {
                dict[key] = new PListString(value);
                return;
            }

            String currentValue = pListString.Value;
            if (currentValue.StartsWith("${") && currentValue.EndsWith("}"))
            {
                dict[key] = new PListString(value);
                return;
            }
        }
コード例 #5
0
        /// <summary>
        ///   Compiles the specified XIB file.
        /// </summary>
        /// <param name = "xibFile">The XIB file.</param>
        /// <param name = "directory">The directory.</param>
        /// <returns><code>true</code> if the compilation is successful, <code>false</code> otherwise.</returns>
        public bool Compile(String xibFile, String directory)
        {
            // TODO: I18N
            this.Logger.LogDebug(String.Format(CultureInfo.CurrentCulture, "Compiling {0} into {1}", xibFile, directory));

            PListDocument result = XibTool.Compile(xibFile, directory);

            if (result == null)
            {
                this.Logger.LogInfo(String.Format(CultureInfo.CurrentCulture, Resources.IBFileUpToDate, xibFile));
                return(true);
            }

            PList     root = result.Root;
            PListDict dict = root.Dict;

            if (dict == null)
            {
                this.Logger.LogError(Resources.NoDictionaryFound);
                return(false);
            }

            // Global errors
            if (dict.ContainsKey(XibTool.ERRORS))
            {
                PListArray errors = (PListArray)dict[XibTool.ERRORS];
                foreach (PListItemBase item in errors)
                {
                    PListDict error = item as PListDict;
                    if (error == null)
                    {
                        continue;
                    }
                    PListString description = error[XibTool.KEY_DESCRIPTION] as PListString;
                    if (description != null)
                    {
                        this.Logger.LogError(description.Value);
                    }
                }

                // If there was global errors, return
                if (errors.Count > 0)
                {
                    return(false);
                }
            }

            // Document errors
            PListDict documentErrors = (PListDict)dict[XibTool.DOCUMENT_ERRORS];

            foreach (String key in documentErrors.Keys)
            {
                PListArray elementErrors = documentErrors[key] as PListArray;
                if (elementErrors == null)
                {
                    continue;
                }
                foreach (PListItemBase item in elementErrors)
                {
                    PListDict   error   = item as PListDict;
                    PListString type    = error[XibTool.KEY_TYPE] as PListString;
                    PListString message = error[XibTool.KEY_MESSAGE] as PListString;
                    if (type != null && message != null)
                    {
                        this.Logger.LogError(String.Format(CultureInfo.CurrentCulture, Resources.ValueDescriptionFormat, type.Value, message.Value));
                    }
                }
            }

            // If there was document errors, return
            if (documentErrors.Count > 0)
            {
                return(false);
            }

            // Document warnings
            PListDict documentWarnings = (PListDict)dict[XibTool.DOCUMENT_WARNINGS];

            foreach (String key in documentWarnings.Keys)
            {
                PListArray elementWarnings = documentWarnings[key] as PListArray;
                if (elementWarnings == null)
                {
                    continue;
                }
                foreach (PListItemBase item in elementWarnings)
                {
                    PListDict   error   = item as PListDict;
                    PListString type    = error[XibTool.KEY_TYPE] as PListString;
                    PListString message = error[XibTool.KEY_MESSAGE] as PListString;
                    if (type != null && message != null)
                    {
                        this.Logger.LogWarning(String.Format(CultureInfo.CurrentCulture, Resources.ValueDescriptionFormat, type.Value, message.Value));
                    }
                }
            }

            // Document notices
            PListDict documentNotices = (PListDict)dict[XibTool.DOCUMENT_NOTICES];

            foreach (String key in documentNotices.Keys)
            {
                PListArray elementNotices = documentNotices[key] as PListArray;
                if (elementNotices == null)
                {
                    continue;
                }
                foreach (PListItemBase item in elementNotices)
                {
                    PListDict   error   = item as PListDict;
                    PListString type    = error[XibTool.KEY_TYPE] as PListString;
                    PListString message = error[XibTool.KEY_MESSAGE] as PListString;
                    if (type != null && message != null)
                    {
                        this.Logger.LogInfo(String.Format(CultureInfo.CurrentCulture, Resources.ValueDescriptionFormat, type.Value, message.Value));
                    }
                }
            }

            return(true);
        }