Beispiel #1
0
        private void UpdateSelectedResourceURL(string fileName, string tileName, Size s)
        {
            string newURL = ResProtocol.ComposeURL(fileName, tileName);

            m_selectedResourceURL           = newURL;
            m_imgFullQualifiedLocation.Text = string.Format("尺寸: {0},{1} 路径: {2}", s.Width, s.Height, newURL);
        }
Beispiel #2
0
        public override System.Drawing.Size GetExpectedResourceSize()
        {
            if (ResProtocol.IsSingleTexture(Res))
            {
                AssetDesc desc = Scene.Instance.GetAssetDesc(Res);
                if (desc == null)
                {
                    return(Const.ZERO_SIZE);
                }

                return(AssetUtil.GetImageSize(desc.Path));
            }
            else
            {
                return(ResourceManager.Instance.GetResourceSize(Res));
            }
        }
Beispiel #3
0
        public static TextureRenderInfo BuildSingleTexture(Gwen.Renderer.Tao renderer, string url)
        {
            if (!ResProtocol.IsSingleTexture(url))
            {
                return(null);
            }

            AssetDesc desc = Scene.Instance.GetAssetDesc(url);

            if (desc == null)
            {
                return(null);
            }

            string fullpath = Path.Combine(GState.AssetRoot, SysUtil.ToWindowsPath(desc.Path));

            if (!File.Exists(fullpath))
            {
                return(null);
            }

            Gwen.Texture t;
            t = new Gwen.Texture(renderer);
            if (t == null)
            {
                return(null);
            }

            t.Load(fullpath);
            if (t.Failed)
            {
                return(null);
            }

            TextureRenderInfo tri = new TextureRenderInfo();

            tri.u1      = 0;
            tri.v1      = 0;
            tri.u2      = 1;
            tri.v2      = 1;
            tri.texture = t;
            return(tri);
        }
        public TextureRenderInfo GetTextureRenderInfo(Gwen.Renderer.Tao renderer, string url)
        {
            TextureRenderInfo tri;

            if (m_lut.TryGetValue(url, out tri))
            {
                return(tri);
            }

            // 如果是单张贴图,直接处理后返回
            if (ResProtocol.IsSingleTexture(url))
            {
                tri        = GwenTextureUtil.BuildSingleTexture(renderer, url);
                m_lut[url] = tri;
                return(tri);
            }

            string atlasName;
            string tileName;

            if (!ResProtocol.ParseURL(url, out atlasName, out tileName))
            {
                return(null);
            }

            string filePath = ResourceManager.Instance.GetAtlasFilePath(atlasName);
            Atlas  atlas    = AtlasManager.Instance.GetAtlas(renderer, filePath);

            if (atlas == null)
            {
                return(null);
            }

            ImageResource res = ResourceManager.Instance.GetResource(url);

            if (res == null)
            {
                return(null);
            }

            Texture9GridBorderInfo uv9Grid = null;
            Rectangle border9Grid          = atlas.GetTileBorderInfo(tileName);

            if (border9Grid != ucore.Const.ZERO_RECT)
            {
                uv9Grid        = new Texture9GridBorderInfo();
                uv9Grid.border = border9Grid;
                uv9Grid.size   = res.Size;
                if (border9Grid.Left != 0 && border9Grid.Right != 0)
                {
                    uv9Grid.uLeft  = ((float)res.Position.X + (float)border9Grid.Left) / (float)atlas.Texture.Width;
                    uv9Grid.uRight = ((float)res.Position.X + (float)border9Grid.Right) / (float)atlas.Texture.Width;
                }

                if (border9Grid.Top != 0 && border9Grid.Bottom != 0)
                {
                    uv9Grid.vTop    = ((float)res.Position.Y + (float)border9Grid.Top) / (float)atlas.Texture.Height;
                    uv9Grid.vBottom = ((float)res.Position.Y + (float)border9Grid.Bottom) / (float)atlas.Texture.Height;
                }
            }

            tri         = new TextureRenderInfo();
            tri.u1      = (float)res.Position.X / (float)atlas.Texture.Width;
            tri.v1      = (float)res.Position.Y / (float)atlas.Texture.Height;
            tri.u2      = ((float)res.Position.X + (float)res.Size.Width) / (float)atlas.Texture.Width;
            tri.v2      = ((float)res.Position.Y + (float)res.Size.Height) / (float)atlas.Texture.Height;
            tri.texture = atlas.Texture;
            tri.uv9Grid = uv9Grid;
            m_lut[url]  = tri;
            return(tri);
        }
Beispiel #5
0
 private void UpdateSingleTextureURL(string textureName)
 {
     m_selectedResourceURL = ResProtocol.ComposeSingleTextureURL(textureName);
 }