public static bool DrawForegroundTile(StarboundTile tile, int x, int y, int gridFactor, Graphics gfx, float opacity) { if (tile.Image == null) { return(false); } var colourMatrix = new ColorMatrix(); colourMatrix.Matrix33 = opacity; var attributes = new ImageAttributes(); attributes.SetColorMatrix(colourMatrix); // Fix this, scaling on colour map gfx.DrawImage(tile.Image, new Rectangle( x * gridFactor, y * gridFactor, gridFactor, gridFactor), 0, 0, gridFactor, gridFactor, GraphicsUnit.Pixel, attributes); return(true); }
public virtual void LoadBrushWithBackAsset(EditorBrush brush, Editor parent, string name, string type) { string extension = EditorHelpers.GetExtensionFromBrushType(type); // Objects and NPCs must always be a front asset if (!brush.NeedsBackAsset || extension == null || type == "object" || type == "npc") { return; } StarboundAsset asset = null; // Load the background tile if (parent.AssetMap.ContainsKey(name + extension)) { asset = parent.AssetMap[name + extension]; brush.BackAsset = asset; } else { // If this is an internal asset - liquids, etc // This is a hack to display liquids until liquid parsing has been implemented // (low priority) if (name == "lava") { asset = new StarboundTile(); asset.AssetName = name; asset.Image = EditorHelpers.GetGeneratedRectangle(8, 8, 207, 16, 32, 255); } else if (name == "acid") { asset = new StarboundTile(); asset.AssetName = name; asset.Image = EditorHelpers.GetGeneratedRectangle(8, 8, 107, 141, 63, 255); } else if (name == "water") { asset = new StarboundTile(); asset.AssetName = name; asset.Image = EditorHelpers.GetGeneratedRectangle(8, 8, 0, 78, 111, 255); } else if (name == "liquidtar" || name == "tentaclejuice") { asset = new StarboundTile(); asset.AssetName = name; asset.Image = EditorHelpers.GetGeneratedRectangle(8, 8, 200, 191, 231, 255); } // Else just load the asset else { asset = parent.LoadAsset(name, type); } if (asset != null) { parent.AssetMap[name + extension] = asset; brush.BackAsset = asset; } } }
public static bool DrawBackgroundTile(StarboundTile tile, int x, int y, int gridFactor, Graphics gfx) { if (tile.Image == null) { return(false); } // How much we must scale to fit this correctly float sizeScaleFactor = Editor.DEFAULT_GRID_FACTOR / (float)gridFactor; var sizeX = (int)Math.Ceiling(tile.Image.Width / sizeScaleFactor); var sizeY = (int)Math.Ceiling(tile.Image.Height / sizeScaleFactor); float[][] floatColourMatrx = { new float[] { 1, 0, 0, 0, 0 }, new float[] { 0, 1, 0, 0, 0 }, new float[] { 0, 0, 1, 0, 0 }, new float[] { 0, 0, 0, 1, 0 }, new[] { -0.25f, -0.25f, -0.25f, 1, 1 } }; var colourMatrix = new ColorMatrix(floatColourMatrx); var attributes = new ImageAttributes(); attributes.SetColorMatrix(colourMatrix); gfx.DrawImage(tile.Image, new Rectangle( x * gridFactor, y * gridFactor, sizeX, sizeY), 0, 0, sizeX, sizeY, GraphicsUnit.Pixel, attributes); attributes.Dispose(); return(true); }
public void SetSelectedBrush(EditorBrush brush) { StarboundAsset asset = null; if (brush != null && brush.NeedsFrontAsset && brush.FrontAsset != null) { asset = brush.FrontAsset; } else if (brush != null && brush.NeedsBackAsset && brush.BackAsset != null) { asset = brush.BackAsset; } else { asset = new StarboundTile(); asset.AssetName = "gridAsset.INTERNAL"; asset.Image = EditorHelpers.GetGeneratedRectangle(8, 8, 255, 255, 255, 128); } m_selectedBrush = brush; m_selectedAsset = asset; Invalidate(); }
public static bool DrawForegroundTile(StarboundTile tile, int x, int y, int gridFactor, Graphics gfx) { return(DrawForegroundTile(tile, x, y, gridFactor, gfx, 1.0f)); }
public static bool DrawForegroundTile(StarboundTile tile, int x, int y, Graphics gfx) { return(DrawForegroundTile(tile, x, y, Editor.DEFAULT_GRID_FACTOR, gfx)); }