Ejemplo n.º 1
0
        public GameAction Create(string resName, Resource res)
        {
            var data  = res.GetLayer <ActionLayer>();
            var image = TextureSlice.FromBitmap(res.GetLayer <ImageLayer>().Data);

            return(new GameAction(
                       data.Name,
                       resName,
                       data.Parent,
                       data.Name,
                       new Picture(image, null),
                       data.Verbs));
        }
Ejemplo n.º 2
0
 private void RequestMinimap(MapGrid grid)
 {
     try
     {
         var bytes = provider.Get(grid.MinimapName);
         // texture needs to be loaded on the main thread
         App.QueueOnMainThread(() =>
         {
             var tex   = TextureSlice.FromBitmap(bytes);
             var image = new Picture(tex, null);
             cache[grid.MinimapName] = image;
         });
     }
     catch (Exception ex)
     {
         Log.Error(ex, "Couldn't get minimap at " + grid.Coord);
     }
 }
Ejemplo n.º 3
0
        static AimWidget()
        {
            var res = App.Resources.Load("ui/aim");

            foreach (var imageData in res.GetLayers <ImageLayer>())
            {
                if (imageData.Id == 0)
                {
                    bg       = new Picture(TextureSlice.FromBitmap(imageData.Data), null);
                    bgOffset = imageData.Offset;
                }
                if (imageData.Id == 1)
                {
                    fg       = new Picture(TextureSlice.FromBitmap(imageData.Data), null);
                    fgOffset = imageData.Offset;
                }
            }
        }
Ejemplo n.º 4
0
        public Drawable Create(string resName, Resource res)
        {
            var imageData = res.GetLayer <ImageLayer>();

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

            using (var ms = new MemoryStream(imageData.Data))
                using (var bitmap = new Bitmap(ms))
                {
                    // load texture
                    var tex = TextureSlice.FromBitmap(bitmap);
                    // check whether image is a ninepatch
                    var ninepatch = res.GetLayer <NinepatchLayer>();
                    if (ninepatch != null)
                    {
                        return(new NinePatch(tex, ninepatch.Left, ninepatch.Right,
                                             ninepatch.Top, ninepatch.Bottom));
                    }
                    return(new Picture(tex, GenerateHitmask(bitmap)));
                }
        }