예제 #1
0
        public Outro(IRenderView renderView, OutroData outroData, Font outroFont, Font outroFontLarge, Action finishAction)
        {
            this.finishAction    = finishAction;
            this.outroData       = outroData;
            this.outroFont       = outroFont;
            this.outroFontLarge  = outroFontLarge;
            this.renderView      = renderView;
            renderLayer          = renderView.GetLayer(Layer.OutroGraphics);
            picture              = renderView.SpriteFactory.Create(160, 128, true, 1) as ILayerSprite;
            picture.Layer        = renderLayer;
            picture.PaletteIndex = paletteOffset = renderView.GraphicProvider.FirstOutroPaletteIndex;
            picture.Visible      = false;
            renderTextFactory    = renderView.RenderTextFactory;
            textProcessor        = renderView.TextProcessor;

            fadeArea         = renderView.ColoredRectFactory.Create(Global.VirtualScreenWidth, Global.VirtualScreenHeight, Color.Black, 255);
            fadeArea.Layer   = renderView.GetLayer(Layer.Effects);
            fadeArea.X       = 0;
            fadeArea.Y       = 0;
            fadeArea.Visible = false;

            graphicInfos = outroData.GraphicInfos;

            EnsureTextures(renderView, outroData, outroFont, outroFontLarge);
        }
예제 #2
0
 public BattleAnimation(ILayerSprite sprite)
 {
     baseSpriteLocation = new Position(sprite.X + sprite.Width / 2, sprite.Y + sprite.Height / 2);
     baseSpriteSize     = new Size(sprite.Width, sprite.Height);
     this.sprite        = sprite;
     baseTextureCoords  = new Position(sprite.TextureAtlasOffset);
     sprite.TextureSize ??= baseSpriteSize;
     Scale = 1.0f;
     sprite.ClipArea ??= Global.CombatBackgroundArea;
 }
예제 #3
0
        public Minimap(Interface interf, Map map = null)
            : base(interf)
        {
            this.interf         = interf;
            sprite              = interf.RenderView.SpriteFactory.Create(128, 128, 0, 0, false, true) as ILayerSprite;
            sprite.Layer        = interf.RenderView.GetLayer(Freeserf.Layer.Minimap);
            sprite.Visible      = false;
            sprite.DisplayLayer = (byte)(BaseDisplayLayer + 1);

            SetMap(map);
        }
예제 #4
0
        public Button(IRenderView renderView, Position position,
                      TextureAtlasManager textureAtlasManager = null)
        {
            Area = new Rect(position, new Size(Width, Height));
            byte paletteIndex = (byte)(renderView.GraphicProvider.PrimaryUIPaletteIndex - 1);

            frameSprite    = renderView.SpriteFactory.Create(Width, Height, true, 3) as ILayerSprite;
            disableOverlay = renderView.SpriteFactory.Create(Width, Height - 6, true, 5) as ILayerSprite;
            iconSprite     = renderView.SpriteFactory.Create(Width, Height - 4, true, 4) as ILayerSprite;

            var layer = renderView.GetLayer(Layer.UI);

            frameSprite.Layer    = layer;
            disableOverlay.Layer = layer;
            iconSprite.Layer     = layer;

            textureAtlas = (textureAtlasManager ?? TextureAtlasManager.Instance).GetOrCreate(Layer.UI);
            frameSprite.TextureAtlasOffset    = textureAtlas.GetOffset(Graphics.GetUIGraphicIndex(UIGraphic.ButtonFrame));
            disableOverlay.TextureAtlasOffset = textureAtlas.GetOffset(Graphics.GetUIGraphicIndex(UIGraphic.ButtonDisabledOverlay));
            iconSprite.TextureAtlasOffset     = textureAtlas.GetOffset(Graphics.GetButtonGraphicIndex(ButtonType.Empty));

            frameSprite.PaletteIndex    = paletteIndex;
            disableOverlay.PaletteIndex = paletteIndex;
            iconSprite.PaletteIndex     = paletteIndex;

            frameSprite.X    = position.X;
            frameSprite.Y    = position.Y;
            disableOverlay.X = position.X;
            disableOverlay.Y = position.Y + 3;
            iconSprite.X     = position.X;
            iconSprite.Y     = position.Y + 2;

            frameSprite.Visible    = true;
            disableOverlay.Visible = false;
            iconSprite.Visible     = true;
        }
예제 #5
0
        public CharacterCreator(IRenderView renderView, Game game, Action <string, bool, int> selectHandler)
        {
            this.renderView = renderView;
            textureAtlas    = TextureAtlasManager.Instance.GetOrCreate(Layer.UI);
            var fontTextureAtlas = TextureAtlasManager.Instance.GetOrCreate(Layer.Text);
            var spriteFactory    = renderView.SpriteFactory;
            var layer            = renderView.GetLayer(Layer.UI);

            #region Window
            var windowSize = new Size(16, 6);
            var windowArea = new Rect
                             (
                (Global.VirtualScreenWidth - windowSize.Width * 16) / 2,
                (Global.VirtualScreenHeight - windowSize.Height * 16) / 2 - 8,
                windowSize.Width * 16,
                windowSize.Height * 16
                             );
            void AddBorder(PopupFrame frame, int column, int row)
            {
                var sprite = spriteFactory.Create(16, 16, true) as ILayerSprite;

                sprite.Layer = layer;
                sprite.TextureAtlasOffset = textureAtlas.GetOffset(Graphics.GetPopupFrameGraphicIndex(frame));
                sprite.PaletteIndex       = 0;
                sprite.X       = windowArea.X + column * 16;
                sprite.Y       = windowArea.Y + row * 16;
                sprite.Visible = true;
                borders.Add(sprite);
            }

            // 4 corners
            AddBorder(PopupFrame.FrameUpperLeft, 0, 0);
            AddBorder(PopupFrame.FrameUpperRight, windowSize.Width - 1, 0);
            AddBorder(PopupFrame.FrameLowerLeft, 0, windowSize.Height - 1);
            AddBorder(PopupFrame.FrameLowerRight, windowSize.Width - 1, windowSize.Height - 1);
            // top and bottom border
            for (int i = 0; i < windowSize.Width - 2; ++i)
            {
                AddBorder(PopupFrame.FrameTop, i + 1, 0);
                AddBorder(PopupFrame.FrameBottom, i + 1, windowSize.Height - 1);
            }
            // left and right border
            for (int i = 0; i < windowSize.Height - 2; ++i)
            {
                AddBorder(PopupFrame.FrameLeft, 0, i + 1);
                AddBorder(PopupFrame.FrameRight, windowSize.Width - 1, i + 1);
            }
            backgroundFill = FillArea(new Rect(windowArea.X + 16, windowArea.Y + 16,
                                               windowSize.Width * 16 - 32, windowSize.Height * 16 - 32), game.GetUIColor(28), 0);
            #endregion

            #region Buttons
            var offset = windowArea.Position;
            maleButton                   = CreateButton(game, offset + new Position(16, 26));
            maleButton.ButtonType        = ButtonType.Male;
            maleButton.Visible           = true;
            maleButton.LeftClickAction   = () => ChangeMale(false);
            femaleButton                 = CreateButton(game, offset + new Position(16, 45));
            femaleButton.ButtonType      = ButtonType.Female;
            femaleButton.Visible         = true;
            femaleButton.LeftClickAction = () => ChangeMale(true);
            leftButton                   = CreateButton(game, offset + new Position(64, 35));
            leftButton.ButtonType        = ButtonType.MoveLeft;
            leftButton.Visible           = true;
            leftButton.LeftClickAction   = () => SwapPortrait(-1);
            rightButton                  = CreateButton(game, offset + new Position(160, 35));
            rightButton.ButtonType       = ButtonType.MoveRight;
            rightButton.Visible          = true;
            rightButton.LeftClickAction  = () => SwapPortrait(1);
            okButton                 = CreateButton(game, new Position(windowArea.Right - 16 - 32, windowArea.Bottom - 16 - 17));
            okButton.ButtonType      = ButtonType.Ok;
            okButton.Visible         = true;
            okButton.LeftClickAction = () =>
            {
                nameInput.Submit();
                afterFadeOutAction = () => selectHandler?.Invoke(nameInput.Text, isFemale, portraitIndex);
                DestroyAndFadeOut();
            };
            #endregion

            portraitBackground       = spriteFactory.Create(32, 34, true, 1) as ILayerSprite;
            portraitBackground.Layer = layer;
            portraitBackground.X     = offset.X + 112;
            portraitBackground.Y     = offset.Y + 32;
            portraitBackground.TextureAtlasOffset = textureAtlas.GetOffset(Graphics.UICustomGraphicOffset + (uint)UICustomGraphic.PortraitBackground);
            portraitBackground.PaletteIndex       = 52;
            portraitBackground.Visible            = true;

            portrait       = spriteFactory.Create(32, 34, true, 2) as ILayerSprite;
            portrait.Layer = layer;
            portrait.X     = portraitBackground.X;
            portrait.Y     = portraitBackground.Y;
            portrait.TextureAtlasOffset = textureAtlas.GetOffset(Graphics.PortraitOffset + (uint)portraitIndex - 1);
            portrait.PaletteIndex       = (byte)(renderView.GraphicProvider.PrimaryUIPaletteIndex - 1);
            portrait.Visible            = true;

            // draw border around portrait
            var area = new Rect(portraitBackground.X - 1, portraitBackground.Y - 1, 34, 36);
            // TODO: use named palette colors
            var darkBorderColor   = game.GetUIColor(26);
            var brightBorderColor = game.GetUIColor(31);
            // upper dark border
            portraitBorders.Add(FillArea(new Rect(area.X, area.Y, area.Width - 1, 1), darkBorderColor, 1));
            // left dark border
            portraitBorders.Add(FillArea(new Rect(area.X, area.Y + 1, 1, area.Height - 2), darkBorderColor, 1));
            // right bright border
            portraitBorders.Add(FillArea(new Rect(area.Right - 1, area.Y + 1, 1, area.Height - 2), brightBorderColor, 1));
            // lower bright border
            portraitBorders.Add(FillArea(new Rect(area.X + 1, area.Bottom - 1, area.Width - 1, 1), brightBorderColor, 1));

            const int inputWidth = 16 * Global.GlyphWidth - 2;
            nameInput = new TextInput(null, renderView, new Position(windowArea.Center.X - inputWidth / 2, offset.Y + 32 + 40),
                                      15, 2, TextInput.ClickAction.FocusOrSubmit, TextInput.ClickAction.Abort, TextAlign.Left);
            nameInput.AllowEmpty = true;
            nameInput.AutoSubmit = true;
            nameInput.SetText("Thalion");
            nameInput.InputChanged += text => { okButton.Disabled = string.IsNullOrWhiteSpace(text); };
            AddSunkenBox(game, new Rect(windowArea.Center.X - inputWidth / 2 - 2, offset.Y + 32 + 38, inputWidth + 6, Global.GlyphLineHeight + 3));

            string headerText = game.DataNameProvider.ChooseCharacter.Trim();
            int    textWidth  = headerText.Length * Global.GlyphWidth;
            int    textOffset = (windowArea.Width - textWidth) / 2;
            header = AddText(offset + new Position(textOffset, 16), headerText, TextColor.BrightGray);

            fadeArea         = renderView.ColoredRectFactory.Create(Global.VirtualScreenWidth, Global.VirtualScreenHeight, Render.Color.Black, 255);
            fadeArea.Layer   = renderView.GetLayer(Layer.Effects);
            fadeArea.X       = 0;
            fadeArea.Y       = 0;
            fadeArea.Visible = true;
            fadeInStartTime  = DateTime.Now;
        }