示例#1
0
    public byte[] GetPacketData() // 바이트형 패킷(송신용)
    {
        ResourceDataSerializer serializer = new ResourceDataSerializer();

        serializer.Serialize(m_data);
        return(serializer.GetSerializedData());
    }
示例#2
0
    public ResourceDataPacket(byte[] data) // 패킷을 데이터로 변환(수신용)
    {
        m_data = new ResourceData();
        ResourceDataSerializer serializer = new ResourceDataSerializer();

        serializer.SetDeserializedData(data);
        serializer.Deserialize(ref m_data);
    }
示例#3
0
        public bool SaveFont(string resourceFile, string fontName, string imageFileRoot)
        {
            if (Path.IsPathRooted(resourceFile) == false)
            {
                resourceFile = Path.Combine(Directory.GetCurrentDirectory(), resourceFile);
            }

            string localImagePartialPath;
            string dir = Path.GetDirectoryName(resourceFile);

            if (Path.IsPathRooted(imageFileRoot) == false)
            {
                localImagePartialPath = imageFileRoot;
                imageFileRoot         = Path.Combine(Path.GetDirectoryName(resourceFile), imageFileRoot);
            }
            else
            {
                localImagePartialPath = GetRelativePath(dir, imageFileRoot);
            }

            localImagePartialPath = localImagePartialPath.Replace(Path.DirectorySeparatorChar.ToString(), "/");

            FontResource fontResource = new FontResource();

            foreach (var fs in Font.FontSurfaces)
            {
                var res            = new FontSurfaceResource();
                var localImagePath = localImagePartialPath + "-" + fs.Key.ToString() + ".png";
                var impl           = (BitmapFontImpl)fs.Value.Impl;

                res.Name    = fontName;
                res.Image   = localImagePath;
                res.Metrics = impl.FontMetrics.Clone();
                res.Size    = fs.Key.Size;
                res.Style   = fs.Key.Style;

                var imagePath = Path.Combine(dir, localImagePath);
                var surface   = (Surface)impl.Surface;
                surface.SaveTo(imagePath);

                fontResource.Add(res);
            }

            var fonts = new FontResourceCollection {
                { fontName, fontResource }
            };
            var resLoader = new ResourceDataSerializer();
            var result    = resLoader.Serialize(fonts);

            File.WriteAllText(resourceFile, result);

            return(true);
        }