BackgroundPattern(Render.ISpriteFactory spriteFactory, int type, uint spriteIndex) { definition = definitions[type]; var offset = GuiObject.GetTextureAtlasOffset(Data.Resource.Icon, spriteIndex); background = spriteFactory.Create(definition.SpriteWidth, definition.SpriteHeight, offset.X, offset.Y, false, true) as Render.ILayerSprite; }
public override void Draw(GuiObject parent) { if (parent == null) { Action <Render.ILayerSprite, int, int> action = (Render.ILayerSprite sprite, int index, int param) => sprite.Visible = false; BackgroundAction(iconBackground, action); BackgroundAction(background, action); BackgroundAction(backgroundPieces, action); visible = false; return; } Action <Render.ILayerSprite, int, int> spriteAction = (Render.ILayerSprite sprite, int index, int param) => { if (param == 2) { sprite.X = parent.TotalX + Offset.X + 8 + (3 + index % 2) * 16; sprite.Y = parent.TotalY + Offset.Y + 8 + 80 + (index / 2) * 16; } else { int yOffset = 8 + param * 64; int columns = 7 + param; if (param == 0) { yOffset += (index / columns) * 16; } else { int row = (index / columns); if (row == 1) { yOffset += 48; } else if (row == 2) { yOffset += 64; } } sprite.X = parent.TotalX + Offset.X + 8 + (index % columns) * 16; sprite.Y = parent.TotalY + Offset.Y + yOffset; } sprite.DisplayLayer = parent.BaseDisplayLayer; sprite.Layer = parent.Layer; sprite.Visible = visible && parent.Displayed && sprite.X < parent.TotalX + parent.Width && sprite.Y < parent.TotalY + parent.Height; }; BackgroundAction(iconBackground, spriteAction, 0); BackgroundAction(background, spriteAction, 1); BackgroundAction(backgroundPieces, spriteAction, 2); }
public virtual void Draw(GuiObject parent) { if (parent == null) { background.Visible = false; return; } Resize(parent.Width, parent.Height); background.X = parent.TotalX + Offset.X + (parent.Width - background.Width) / 2; background.Y = parent.TotalY + Offset.Y + (parent.Height - background.Height) / 2; background.DisplayLayer = parent.BaseDisplayLayer; background.Layer = parent.Layer; background.Visible = parent.Displayed; }
internal ResourceStatisticBackgroundPattern(Render.ISpriteFactory spriteFactory, uint spriteIndex) { Position offset; for (int i = 0; i < 4 * 7; ++i) { offset = GuiObject.GetTextureAtlasOffset(Data.Resource.Icon, spriteIndex); iconBackground[i] = spriteFactory.Create(16, 16, offset.X, offset.Y, false, true) as Render.ILayerSprite; } for (int i = 0; i < 3 * 8; ++i) { offset = GuiObject.GetTextureAtlasOffset(Data.Resource.Icon, 129u); background[i] = spriteFactory.Create(16, 16, offset.X, offset.Y, false, true) as Render.ILayerSprite; } for (int i = 0; i < 4; ++i) { offset = GuiObject.GetTextureAtlasOffset(Data.Resource.Icon, 129u); backgroundPieces[i] = spriteFactory.Create(16, 16, offset.X, offset.Y, false, true) as Render.ILayerSprite; } }