void AddCursors(IGraphicProvider graphicProvider) { var cursorGraphics = graphicProvider.GetGraphics(GraphicType.Cursor); for (int i = 0; i < cursorGraphics.Count; ++i) { AddTexture(Layer.Cursor, (uint)i, cursorGraphics[i]); } }
void AddUI(IGraphicProvider graphicProvider, bool withLayout = true) { if (withLayout) { var layoutGraphics = graphicProvider.GetGraphics(GraphicType.Layout); for (int i = 0; i < layoutGraphics.Count; ++i) { AddTexture(Layer.UI, Graphics.LayoutOffset + (uint)i, layoutGraphics[i]); } } var uiElementGraphics = graphicProvider.GetGraphics(GraphicType.UIElements); for (int i = 0; i < uiElementGraphics.Count; ++i) { AddTexture(Layer.UI, Graphics.UICustomGraphicOffset + (uint)i, uiElementGraphics[i]); } }
public void AddAll(IGameData gameData, IGraphicProvider graphicProvider, IFontProvider fontProvider, Dictionary <uint, Graphic> introTextGlyphs, Dictionary <uint, Graphic> introGraphics) { if (gameData == null) { throw new ArgumentNullException(nameof(gameData)); } if (graphicProvider == null) { throw new ArgumentNullException(nameof(graphicProvider)); } #region Map 2D for (int i = (int)GraphicType.Tileset1; i <= (int)GraphicType.Tileset8; ++i) { var tilesetGraphics = graphicProvider.GetGraphics((GraphicType)i); for (uint graphicIndex = 0; graphicIndex < tilesetGraphics.Count; ++graphicIndex) { AddTexture(Layer.MapBackground1 + i, graphicIndex, tilesetGraphics[(int)graphicIndex]); AddTexture(Layer.MapForeground1 + i, graphicIndex, tilesetGraphics[(int)graphicIndex]); } } #endregion #region Player 2D var playerGraphics = graphicProvider.GetGraphics(GraphicType.Player); if (playerGraphics.Count != 3 * 17) { throw new AmbermoonException(ExceptionScope.Data, "Wrong number of player graphics."); } // There are 3 player characters (one for each world, first lyramion, second forest moon, third morag). // Each has 17 frames: 3 back, 3 right, 3 front, 3 left, 1 sit back, 1 sit right, 1 sit front, 1 sit left, 1 bed/sleep. // All have a dimension of 16x32 pixels. for (int i = 0; i < playerGraphics.Count; ++i) { AddTexture(Layer.Characters, (uint)i, playerGraphics[i]); } // On world maps the travel graphics are used. // Only 4 sprites are used (one for each direction). var travelGraphics = graphicProvider.GetGraphics(GraphicType.TravelGfx); if (travelGraphics.Count != 11 * 4) { throw new AmbermoonException(ExceptionScope.Data, "Wrong number of travel graphics."); } for (int i = 0; i < travelGraphics.Count; ++i) { AddTexture(Layer.Characters, Graphics.TravelGraphicOffset + (uint)i, travelGraphics[i]); } var transportGraphics = graphicProvider.GetGraphics(GraphicType.Transports); if (transportGraphics.Count != 5) { throw new AmbermoonException(ExceptionScope.Data, "Wrong number of transport graphics."); } for (int i = 0; i < transportGraphics.Count; ++i) { AddTexture(Layer.Characters, Graphics.TransportGraphicOffset + (uint)i, transportGraphics[i]); } var npcGraphics = graphicProvider.GetGraphics(GraphicType.NPC); if (npcGraphics.Count != 34) { throw new AmbermoonException(ExceptionScope.Data, "Wrong number of NPC graphics."); } for (int i = 0; i < npcGraphics.Count; ++i) { AddTexture(Layer.Characters, Graphics.NPCGraphicOffset + (uint)i, npcGraphics[i]); } #endregion #region UI Layout AddUI(graphicProvider); #endregion #region Portraits var portraits = graphicProvider.GetGraphics(GraphicType.Portrait); for (int i = 0; i < portraits.Count; ++i) { AddTexture(Layer.UI, Graphics.PortraitOffset + (uint)i, portraits[i]); } #endregion #region Pics 80x80 var pics80x80Graphics = graphicProvider.GetGraphics(GraphicType.Pics80x80); for (int i = 0; i < pics80x80Graphics.Count; ++i) { AddTexture(Layer.UI, Graphics.Pics80x80Offset + (uint)i, pics80x80Graphics[i]); } #endregion #region Event pix var eventGraphics = graphicProvider.GetGraphics(GraphicType.EventPictures); for (int i = 0; i < eventGraphics.Count; ++i) { AddTexture(Layer.UI, Graphics.EventPictureOffset + (uint)i, eventGraphics[i]); } #endregion #region Text AddFont(fontProvider); #endregion #region Items var itemGraphics = graphicProvider.GetGraphics(GraphicType.Item); for (int i = 0; i < itemGraphics.Count; ++i) { AddTexture(Layer.Items, (uint)i, itemGraphics[i]); } #endregion #region Cursors AddCursors(graphicProvider); #endregion #region Combat backgrounds var combatBackgrounds = graphicProvider.GetGraphics(GraphicType.CombatBackground); for (int i = 0; i < combatBackgrounds.Count; ++i) { AddTexture(Layer.CombatBackground, Graphics.CombatBackgroundOffset + (uint)i, combatBackgrounds[i]); } #endregion #region Combat graphics (without battle field icons) var combatGraphics = graphicProvider.GetGraphics(GraphicType.CombatGraphics); for (int i = 0; i < combatGraphics.Count; ++i) { // Note: One graphic is an UI element so we put it into the UI layer. The rest goes into the BattleEffects layer. AddTexture(i == (int)CombatGraphicIndex.UISwordAndMace ? Layer.UI : Layer.BattleEffects, Graphics.CombatGraphicOffset + (uint)i, combatGraphics[i]); } #endregion #region Battle field icons var battleFieldIcons = graphicProvider.GetGraphics(GraphicType.BattleFieldIcons); for (int i = 0; i < battleFieldIcons.Count; ++i) { AddTexture(Layer.UI, Graphics.BattleFieldIconOffset + (uint)i, battleFieldIcons[i]); } #endregion #region Automap graphics var automapGraphics = graphicProvider.GetGraphics(GraphicType.AutomapGraphics); for (int i = 0; i < automapGraphics.Count; ++i) { AddTexture(Layer.UI, Graphics.AutomapOffset + (uint)i, automapGraphics[i]); } #endregion #region Riddlemouth graphics var riddlemouthGraphics = graphicProvider.GetGraphics(GraphicType.RiddlemouthGraphics); for (int i = 0; i < riddlemouthGraphics.Count; ++i) { AddTexture(Layer.UI, Graphics.RiddlemouthOffset + (uint)i, riddlemouthGraphics[i]); } #endregion #region Intro Text foreach (var introTextGlyph in introTextGlyphs) { AddTexture(Layer.IntroText, introTextGlyph.Key, introTextGlyph.Value); } #endregion #region Intro Graphics foreach (var introGraphic in introGraphics) { AddTexture(Layer.IntroGraphics, introGraphic.Key, introGraphic.Value); } #endregion }