public async Task<IAnimation> LoadAnimationFromSpriteSheetAsync(ISpriteSheet spriteSheet, IAnimationConfiguration animationConfig = null, ILoadImageConfig loadConfig = null) { animationConfig = animationConfig ?? new AGSAnimationConfiguration (); string filePath = spriteSheet.Path; IResource resource = await Task.Run(() =>_resources.LoadResource (filePath)); if (resource == null) { throw new InvalidOperationException ("Failed to load sprite sheet from " + filePath); } IBitmap bitmap = await Task.Run(() => _bitmapLoader.Load (resource.Stream)); int cellsInRow, cellsInCol, cellsTotal, cellX, cellY, cellsToGrab, cellsGrabbed = 0; Point mainStep, secondStep; AGSAnimation animation; getSpriteSheetData (bitmap, spriteSheet, animationConfig, out cellsInRow, out cellsInCol, out cellsTotal, out cellX, out cellY, out cellsToGrab, out mainStep, out secondStep, out animation); for (int currentCell = 0; cellsGrabbed < cellsToGrab; currentCell++) { if (currentCell >= spriteSheet.StartFromCell) { Rectangle rect; IBitmap clone; string path; ITexture tex; getImageInfo (bitmap, cellX, cellY, spriteSheet, loadConfig, filePath, out rect, out clone, out path, out tex); IImage image = _loadImage (tex, clone, path, loadConfig, spriteSheet); _addAnimationFrame (image, animation); cellsGrabbed++; } nextCell (mainStep, secondStep, cellsInRow, cellsInCol, ref cellX, ref cellY); } animation.Setup (); return animation; }
public async Task<IInventoryItem> GetInventoryItemAsync(string hotspot, string graphicsFile, string cursorFile = null, ILoadImageConfig loadConfig = null, bool playerStartsWithItem = false) { var graphicsImage = await _graphics.LoadImageAsync (graphicsFile, loadConfig); var cursorImage = cursorFile == null ? graphicsImage : await _graphics.LoadImageAsync(cursorFile, loadConfig); return getInventoryItem(hotspot, graphicsImage, cursorImage, playerStartsWithItem); }
public IInventoryItem GetInventoryItem(string hotspot, string graphicsFile, string cursorFile = null, ILoadImageConfig loadConfig = null, bool playerStartsWithItem = false) { var graphicsImage = _graphics.LoadImage(graphicsFile, loadConfig); var cursorImage = cursorFile == null ? graphicsImage : _graphics.LoadImage(cursorFile, loadConfig); return getInventoryItem (hotspot, graphicsImage, cursorImage, playerStartsWithItem); }
public GLImage(IBitmap bitmap, string id, ITexture texture, ISpriteSheet spriteSheet, ILoadImageConfig loadConfig) { OriginalBitmap = bitmap; Width = bitmap.Width; Height = bitmap.Height; ID = id; Texture = texture; SpriteSheet = spriteSheet; LoadConfig = loadConfig; }
public async Task<IOutfit> LoadOutfitFromFoldersAsync(string baseFolder, string walkLeftFolder = null, string walkRightFolder = null, string walkDownFolder = null, string walkUpFolder = null, string idleLeftFolder = null, string idleRightFolder = null, string idleDownFolder = null, string idleUpFolder = null, string speakLeftFolder = null, string speakRightFolder = null, string speakDownFolder = null, string speakUpFolder = null, IAnimationConfiguration animationConfig = null, ILoadImageConfig loadConfig = null) { IOutfit outfit = _resolver.Resolve<IOutfit> (); outfit[AGSOutfit.Idle] = await _graphics.LoadDirectionalAnimationFromFoldersAsync(baseFolder, idleLeftFolder, idleRightFolder, idleDownFolder, idleUpFolder, animationConfig, loadConfig); outfit[AGSOutfit.Walk] = await _graphics.LoadDirectionalAnimationFromFoldersAsync (baseFolder, walkLeftFolder, walkRightFolder, walkDownFolder, walkUpFolder, animationConfig, loadConfig); outfit[AGSOutfit.Speak] = await _graphics.LoadDirectionalAnimationFromFoldersAsync (baseFolder, speakLeftFolder, speakRightFolder, speakDownFolder, speakUpFolder, animationConfig, loadConfig); return outfit; }
public async Task<IDirectionalAnimation> LoadDirectionalAnimationFromFoldersAsync(string baseFolder, string leftFolder = null, string rightFolder = null, string downFolder = null, string upFolder = null, IAnimationConfiguration animationConfig = null, ILoadImageConfig loadConfig = null) { if (leftFolder == null && rightFolder == null && downFolder == null && upFolder == null) return null; AGSDirectionalAnimation dirAnimation = new AGSDirectionalAnimation (); if (leftFolder != null) dirAnimation.Left = await LoadAnimationFromFolderAsync(baseFolder + leftFolder, animationConfig, loadConfig); if (rightFolder != null) dirAnimation.Right = await LoadAnimationFromFolderAsync(baseFolder + rightFolder, animationConfig, loadConfig); if (downFolder != null) dirAnimation.Down = await LoadAnimationFromFolderAsync(baseFolder + downFolder, animationConfig, loadConfig); if (upFolder != null) dirAnimation.Up = await LoadAnimationFromFolderAsync(baseFolder + upFolder, animationConfig, loadConfig); if (dirAnimation.Left != null && dirAnimation.Right == null) { dirAnimation.Right = createLeftRightAnimation (dirAnimation.Left); } if (dirAnimation.Right != null && dirAnimation.Left == null) { dirAnimation.Left = createLeftRightAnimation (dirAnimation.Right); } return dirAnimation; }
public async Task <IPanel> GetPanelAsync(string id, string imagePath, float x, float y, IObject parent = null, ILoadImageConfig loadConfig = null, bool addToUi = true) { IImage image = await _graphics.LoadImageAsync(imagePath, loadConfig); return(GetPanel(id, image, x, y, parent, addToUi)); }
private IImage loadImage(ITexture texture, IBitmap bitmap, string id, ILoadImageConfig config, ISpriteSheet spriteSheet) { manipulateImage(bitmap, config); bitmap.LoadTexture(null); GLImage image = new GLImage (bitmap, id, texture, spriteSheet, config); if (_textures != null) _textures.GetOrAdd (image.ID, () => image.Texture); return image; }
private ITexture createTexture(ILoadImageConfig config) { ITextureConfig textureConfig = config == null ? null : config.TextureConfig; TypedParameter textureConfigParam = new TypedParameter(typeof(ITextureConfig), textureConfig); return _resolver.Resolve<ITexture>(textureConfigParam); }
private async Task<IAnimation> loadAnimationFromResourcesAsync (List<IResource> resources, IAnimationConfiguration animationConfig = null, ILoadImageConfig loadConfig = null) { AGSAnimation animation = getAnimation (animationConfig, resources.Count); foreach (IResource resource in resources) { var image = await loadImageAsync (resource, loadConfig); addAnimationFrame (image, animation); } animation.Setup (); return animation; }
private IImage loadImage(IResource resource, ILoadImageConfig config = null) { ITexture tex = createTexture(config); try { IBitmap bitmap = _bitmapLoader.Load(resource.Stream); return loadImage (tex, bitmap, resource.ID, config, null); } catch (ArgumentException e) { Debug.WriteLine("Failed to load image from {0}, is it really an image?\r\n{1}", resource.ID, e.ToString()); return null; } }
public async Task<IAnimation> LoadAnimationFromSpriteSheetAsync (ISpriteSheet spriteSheet, IAnimationConfiguration animationConfig = null, ILoadImageConfig loadConfig = null) { return await _spriteSheetLoader.LoadAnimationFromSpriteSheetAsync (spriteSheet, animationConfig, loadConfig); }
public IImage LoadImage(string path, ILoadImageConfig config = null) { IResource resource = _resources.LoadResource(path); return loadImage(resource, config); }
public IImage LoadImage(IBitmap bitmap, ILoadImageConfig config = null, string id = null) { return(loadImage(bitmap, config, id)); }
public IImage LoadImage(string path, ILoadImageConfig config = null) { IResource resource = _resources.LoadResource(path); return(loadImage(resource, config)); }
public IAnimation LoadAnimationFromSpriteSheet(ISpriteSheet spriteSheet, IAnimationConfiguration animationConfig = null, ILoadImageConfig loadConfig = null) { return(_spriteSheetLoader.LoadAnimationFromSpriteSheet(spriteSheet, animationConfig, loadConfig)); }
public async Task <IAnimation> LoadAnimationFromSpriteSheetAsync(ISpriteSheet spriteSheet, IAnimationConfiguration animationConfig = null, ILoadImageConfig loadConfig = null) { return(await _spriteSheetLoader.LoadAnimationFromSpriteSheetAsync(spriteSheet, animationConfig, loadConfig)); }
public async Task <IAnimation> LoadAnimationFromFolderAsync(string folderPath, IAnimationConfiguration animationConfig = null, ILoadImageConfig loadConfig = null) { return(await loadAnimationFromResourcesAsync(folderPath, await Task.Run(() => _resources.LoadResources(folderPath)), animationConfig, loadConfig)); }
public IAnimation LoadAnimationFromFolder(string folderPath, IAnimationConfiguration animationConfig = null, ILoadImageConfig loadConfig = null) { return(loadAnimationFromResources(folderPath, _resources.LoadResources(folderPath), animationConfig, loadConfig)); }
public IPanel GetPanel(string id, string imagePath, float x, float y, IObject parent = null, ILoadImageConfig loadConfig = null, bool addToUi = true) { IImage image = _graphics.LoadImage(imagePath, loadConfig); return(GetPanel(id, image, x, y, parent, addToUi)); }
public GLImage(IBitmap bitmap, string id, ITexture texture, ISpriteSheet spriteSheet, ILoadImageConfig loadConfig) { OnImageDisposed = new AGSEvent(); OriginalBitmap = bitmap; Width = bitmap.Width; Height = bitmap.Height; ID = id; Texture = texture; SpriteSheet = spriteSheet; LoadConfig = loadConfig; }
public async Task <IImage> LoadImageAsync(string filePath, ILoadImageConfig config = null) { IResource resource = await Task.Run(() => _resources.LoadResource(filePath)); return(await loadImageAsync(resource, config)); }
public IAnimation LoadAnimationFromSpriteSheet (ISpriteSheet spriteSheet, IAnimationConfiguration animationConfig = null, ILoadImageConfig loadConfig = null) { return _spriteSheetLoader.LoadAnimationFromSpriteSheet (spriteSheet, animationConfig, loadConfig); }
private async Task <IAnimation> loadAnimationFromResourcesAsync(string samplePath, List <IResource> resources, IAnimationConfiguration animationConfig = null, ILoadImageConfig loadConfig = null) { AGSAnimation animation = getAnimation(samplePath, animationConfig, resources.Count); foreach (IResource resource in resources) { var image = await loadImageAsync(resource, loadConfig); addAnimationFrame(image, animation); } animation.Setup(); return(animation); }
public IImage LoadImage(IBitmap bitmap, ILoadImageConfig config = null, string id = null) { return loadImage(bitmap, config, id); }
public async Task <IDirectionalAnimation> LoadDirectionalAnimationFromFoldersAsync(string baseFolder, string leftFolder = null, string rightFolder = null, string downFolder = null, string upFolder = null, IAnimationConfiguration animationConfig = null, ILoadImageConfig loadConfig = null) { if (leftFolder == null && rightFolder == null && downFolder == null && upFolder == null) { return(null); } AGSDirectionalAnimation dirAnimation = new AGSDirectionalAnimation(); if (leftFolder != null) { dirAnimation.Left = await LoadAnimationFromFolderAsync(baseFolder + leftFolder, animationConfig, loadConfig); } if (rightFolder != null) { dirAnimation.Right = await LoadAnimationFromFolderAsync(baseFolder + rightFolder, animationConfig, loadConfig); } if (downFolder != null) { dirAnimation.Down = await LoadAnimationFromFolderAsync(baseFolder + downFolder, animationConfig, loadConfig); } if (upFolder != null) { dirAnimation.Up = await LoadAnimationFromFolderAsync(baseFolder + upFolder, animationConfig, loadConfig); } if (dirAnimation.Left != null && dirAnimation.Right == null) { dirAnimation.Right = createLeftRightAnimation(dirAnimation.Left); } if (dirAnimation.Right != null && dirAnimation.Left == null) { dirAnimation.Left = createLeftRightAnimation(dirAnimation.Right); } return(dirAnimation); }
public async Task<IImage> LoadImageAsync (string filePath, ILoadImageConfig config = null) { IResource resource = await Task.Run(() => _resources.LoadResource(filePath)); return await loadImageAsync(resource, config); }
public IAnimation LoadAnimationFromFiles(IAnimationConfiguration animationConfig = null, ILoadImageConfig loadConfig = null, params string[] files) { return loadAnimationFromResources(_resources.LoadResources(files), animationConfig, loadConfig); }
private IImage loadImage(IBitmap bitmap, ILoadImageConfig config = null, string id = null) { id = id ?? Guid.NewGuid().ToString(); ITexture tex = createTexture(config); return loadImage(tex, bitmap, id, config, null); }
public IAnimation LoadAnimationFromFolder (string folderPath, IAnimationConfiguration animationConfig = null, ILoadImageConfig loadConfig = null) { return loadAnimationFromResources(_resources.LoadResources(folderPath), animationConfig, loadConfig); }
private async Task<IImage> loadImageAsync (IResource resource, ILoadImageConfig config = null) { try { if (resource == null) return new EmptyImage(1f, 1f); IBitmap bitmap = await Task.Run(() => _bitmapLoader.Load (resource.Stream)); ITexture tex = createTexture(config); return loadImage(tex, bitmap, resource.ID, config, null); } catch (ArgumentException e) { Debug.WriteLine ("Failed to load image from {0}, is it really an image?\r\n{1}", resource.ID, e.ToString ()); return null; } }
private void getImageInfo(IBitmap bitmap, int cellX, int cellY, ISpriteSheet spriteSheet, ILoadImageConfig loadConfig, string filePath, out Rectangle rect, out IBitmap clone, out string path, out ITexture texture) { texture = new GLTexture(loadConfig.TextureConfig, _graphics); rect = new Rectangle (cellX * spriteSheet.CellWidth, cellY * spriteSheet.CellHeight, spriteSheet.CellWidth, spriteSheet.CellHeight); clone = bitmap.Crop (rect); path = string.Format ("{0}_{1}_{2}", rect.X, rect.Y, filePath); }
private void manipulateImage(IBitmap bitmap, ILoadImageConfig config) { if (config == null) return; if (config.TransparentColorSamplePoint != null) { Color transparentColor = bitmap.GetPixel((int)config.TransparentColorSamplePoint.Value.X, (int)config.TransparentColorSamplePoint.Value.Y); bitmap.MakeTransparent(transparentColor); } }
public IPanel GetPanel(string id, string imagePath, float x, float y, ILoadImageConfig loadConfig = null, bool addToUi = true) { IImage image = _graphics.LoadImage(imagePath, loadConfig); return GetPanel(id, image, x, y, addToUi); }
private IImage getImage(ITexture texture, ISpriteSheet spriteSheet, ILoadImageConfig loadConfig) { return(new GLImage(AGSGame.Device.BitmapLoader.Load((int)Width, (int)Height), ID, texture, spriteSheet, loadConfig)); }
public async Task <ISlider> GetSliderAsync(string id, string imagePath, string handleImagePath, float value, float min, float max, IObject parent = null, ITextConfig config = null, ILoadImageConfig loadConfig = null, bool addToUi = true) { var image = imagePath == null ? null : await _graphics.LoadImageAsync(imagePath, loadConfig); var handleImage = handleImagePath == null ? null : await _graphics.LoadImageAsync(handleImagePath, loadConfig); return(getSlider(id, image, handleImage, value, min, max, parent, config, addToUi)); }
public async Task<IAnimation> LoadAnimationFromFilesAsync(IAnimationConfiguration animationConfig = null, ILoadImageConfig loadConfig = null, params string [] files) { return await loadAnimationFromResourcesAsync(await Task.Run(() => _resources.LoadResources (files)), animationConfig, loadConfig); }
public async Task <IOutfit> LoadOutfitFromFoldersAsync(string baseFolder, string walkLeftFolder = null, string walkRightFolder = null, string walkDownFolder = null, string walkUpFolder = null, string idleLeftFolder = null, string idleRightFolder = null, string idleDownFolder = null, string idleUpFolder = null, string speakLeftFolder = null, string speakRightFolder = null, string speakDownFolder = null, string speakUpFolder = null, IAnimationConfiguration animationConfig = null, ILoadImageConfig loadConfig = null) { IOutfit outfit = _resolver.Container.Resolve <IOutfit> (); outfit[AGSOutfit.Idle] = await _graphics.LoadDirectionalAnimationFromFoldersAsync(baseFolder, idleLeftFolder, idleRightFolder, idleDownFolder, idleUpFolder, animationConfig, loadConfig); outfit[AGSOutfit.Walk] = await _graphics.LoadDirectionalAnimationFromFoldersAsync(baseFolder, walkLeftFolder, walkRightFolder, walkDownFolder, walkUpFolder, animationConfig, loadConfig); outfit[AGSOutfit.Speak] = await _graphics.LoadDirectionalAnimationFromFoldersAsync(baseFolder, speakLeftFolder, speakRightFolder, speakDownFolder, speakUpFolder, animationConfig, loadConfig); return(outfit); }
public async Task<IAnimation> LoadAnimationFromFolderAsync (string folderPath, IAnimationConfiguration animationConfig = null, ILoadImageConfig loadConfig = null) { return await loadAnimationFromResourcesAsync (await Task.Run(() => _resources.LoadResources (folderPath)), animationConfig, loadConfig); }
public async Task <IAnimation> LoadAnimationFromSpriteSheetAsync(ISpriteSheet spriteSheet, IAnimationConfiguration animationConfig = null, ILoadImageConfig loadConfig = null) { animationConfig = animationConfig ?? new AGSAnimationConfiguration(); string filePath = spriteSheet.Path; IResource resource = await Task.Run(() => _resources.LoadResource(filePath)); if (resource == null) { throw new InvalidOperationException("Failed to load sprite sheet from " + filePath); } IBitmap bitmap = await Task.Run(() => _bitmapLoader.Load(resource.Stream)); int cellsInRow, cellsInCol, cellsTotal, cellX, cellY, cellsToGrab, cellsGrabbed = 0; Point mainStep, secondStep; AGSAnimation animation; getSpriteSheetData(bitmap, spriteSheet, animationConfig, out cellsInRow, out cellsInCol, out cellsTotal, out cellX, out cellY, out cellsToGrab, out mainStep, out secondStep, out animation); for (int currentCell = 0; cellsGrabbed < cellsToGrab; currentCell++) { if (currentCell >= spriteSheet.StartFromCell) { Rectangle rect; IBitmap clone; string path; ITexture tex; getImageInfo(bitmap, cellX, cellY, spriteSheet, loadConfig, filePath, out rect, out clone, out path, out tex); IImage image = _loadImage(tex, clone, path, loadConfig, spriteSheet); _addAnimationFrame(image, animation); cellsGrabbed++; } nextCell(mainStep, secondStep, cellsInRow, cellsInCol, ref cellX, ref cellY); } animation.Setup(); return(animation); }
public async Task<ISlider> GetSliderAsync(string id, string imagePath, string handleImagePath, float value, float min, float max, ITextConfig config = null, ILoadImageConfig loadConfig = null, bool addToUi = true) { var image = await _graphics.LoadImageAsync(imagePath, loadConfig); var handleImage = await _graphics.LoadImageAsync(handleImagePath, loadConfig); return getSlider(id, image, handleImage, value, min, max, config, addToUi); }
public IAnimation LoadAnimationFromFiles(IAnimationConfiguration animationConfig = null, ILoadImageConfig loadConfig = null, params string[] files) { if (files.Length == 0) { throw new InvalidOperationException("No files given to LoadAnimationFromFiles"); } return(loadAnimationFromResources(files[0], _resources.LoadResourcesFromPaths(files), animationConfig, loadConfig)); }
public async Task<IPanel> GetPanelAsync(string id, string imagePath, float x, float y, ILoadImageConfig loadConfig = null, bool addToUi = true) { IImage image = await _graphics.LoadImageAsync(imagePath, loadConfig); return GetPanel (id, image, x, y, addToUi); }
public async Task <IAnimation> LoadAnimationFromFilesAsync(IAnimationConfiguration animationConfig = null, ILoadImageConfig loadConfig = null, params string [] files) { if (files.Length == 0) { throw new InvalidOperationException("No files given to LoadAnimationFromFilesAsync"); } return(await loadAnimationFromResourcesAsync(files[0], await Task.Run(() => _resources.LoadResourcesFromPaths(files)), animationConfig, loadConfig)); }