private IXNAButton CreateStateChangeButton(InGameStates whichState) { if (whichState == InGameStates.News) { throw new ArgumentOutOfRangeException(nameof(whichState), "News state does not have a button associated with it"); } var buttonIndex = (int)whichState; var mainButtonTexture = _nativeGraphicsManager.TextureFromResource(GFXTypes.PostLoginUI, 25); var widthDelta = mainButtonTexture.Width / 2; var heightDelta = mainButtonTexture.Height / 11; var xPosition = buttonIndex < 6 ? 62 : 590; var yPosition = (buttonIndex < 6 ? 330 : 350) + (buttonIndex < 6 ? buttonIndex : buttonIndex - 6) * 20; var retButton = new XNAButton( mainButtonTexture, new Vector2(xPosition, yPosition), new Rectangle(0, heightDelta * buttonIndex, widthDelta, heightDelta), new Rectangle(widthDelta, heightDelta * buttonIndex, widthDelta, heightDelta)) { DrawOrder = HUD_CONTROL_LAYER }; retButton.OnClick += (o, e) => DoHudStateChangeClick(whichState); retButton.OnMouseEnter += (o, e) => _statusLabelSetter.SetStatusLabel( EOResourceID.STATUS_LABEL_TYPE_BUTTON, EOResourceID.STATUS_LABEL_HUD_BUTTON_HOVER_FIRST + buttonIndex); return(retButton); }
public virtual void InitializeResources(INativeGraphicsManager gfxManager, ContentManager xnaContentManager) { if (_resourcesInitialized) { throw new InvalidOperationException("Error initializing resources: resources have already been initialized"); } _mainButtonTexture = gfxManager.TextureFromResource(GFXTypes.PreLoginUI, 13, true); _secondaryButtonTexture = gfxManager.TextureFromResource(GFXTypes.PreLoginUI, 14, true); _smallButtonSheet = gfxManager.TextureFromResource(GFXTypes.PreLoginUI, 15, true); _textBoxBackground = xnaContentManager.Load <Texture2D>("tbBack"); _textBoxLeft = xnaContentManager.Load <Texture2D>("tbLeft"); _textBoxRight = xnaContentManager.Load <Texture2D>("tbRight"); _textBoxCursor = xnaContentManager.Load <Texture2D>("cursor"); _backgroundImages = new Texture2D[7]; for (int i = 0; i < _backgroundImages.Length; ++i) { _backgroundImages[i] = gfxManager.TextureFromResource(GFXTypes.PreLoginUI, 30 + i); } _resourcesInitialized = true; }
protected override void LoadContent() { _mainFrame = _nativeGraphicsManager.TextureFromResource(GFXTypes.PostLoginUI, 1, true); _topLeft = _nativeGraphicsManager.TextureFromResource(GFXTypes.PostLoginUI, 21, true); _sidebar = _nativeGraphicsManager.TextureFromResource(GFXTypes.PostLoginUI, 22, true); _topBar = _nativeGraphicsManager.TextureFromResource(GFXTypes.PostLoginUI, 23, true); _filler = new Texture2D(_graphicsDeviceProvider.GraphicsDevice, 1, 1); _filler.SetData(new[] { Color.FromNonPremultiplied(8, 8, 8, 255) }); base.LoadContent(); }
public Texture2D GetItemGraphic(int id, int amount) { var item = _eifFileProvider.EIFFile[id]; if (item.Type == ItemType.Money) { var gfx = amount >= 100000 ? 4 : ( amount >= 10000 ? 3 : ( amount >= 100 ? 2 : ( amount >= 2 ? 1 : 0))); return(_nativeGraphicsManager.TextureFromResource(GFXTypes.Items, 269 + 2 * gfx, true)); } return(_nativeGraphicsManager.TextureFromResource(GFXTypes.Items, 2 * item.Graphic - 1, true)); }
public ProgressDialog(INativeGraphicsManager nativeGraphicsManager, IGameStateProvider gameStateProvider, IEODialogButtonService eoDialogButtonService, string messageText, string captionText) : base(gameStateProvider) { BackgroundTexture = nativeGraphicsManager.TextureFromResource(GFXTypes.PreLoginUI, 18); _messageLabel = new XNALabel(Constants.FontSize10) { AutoSize = true, ForeColor = ColorConstants.LightYellowText, Text = messageText, TextWidth = 254, DrawPosition = new Vector2(18, 57) }; _messageLabel.SetParentControl(this); _captionLabel = new XNALabel(Constants.FontSize10) { AutoSize = true, ForeColor = ColorConstants.LightYellowText, Text = captionText, DrawPosition = new Vector2(59, 23) }; _captionLabel.SetParentControl(this); _cancelButton = new XNAButton(eoDialogButtonService.SmallButtonSheet, new Vector2(181, 113), eoDialogButtonService.GetSmallDialogButtonOutSource(SmallButton.Cancel), eoDialogButtonService.GetSmallDialogButtonOverSource(SmallButton.Cancel)); _cancelButton.OnClick += DoCancel; _cancelButton.SetParentControl(this); _pbBackgroundTexture = nativeGraphicsManager.TextureFromResource(GFXTypes.PreLoginUI, 19); _pbForegroundTexture = new Texture2D(Game.GraphicsDevice, 1, _pbBackgroundTexture.Height - 2); //foreground texture is just a fill var pbForeFill = new Color[_pbForegroundTexture.Width * _pbForegroundTexture.Height]; for (int i = 0; i < pbForeFill.Length; ++i) { pbForeFill[i] = Color.FromNonPremultiplied(0xb4, 0xdc, 0xe6, 0xff); } _pbForegroundTexture.SetData(pbForeFill); CenterInGameView(); }
public void Render(SpriteBatch spriteBatch, SpriteFont chatFont, INativeGraphicsManager nativeGraphicsManager) { spriteBatch.Begin(); var pos = TOP_LEFT + new Vector2(0, DisplayIndex * 13); spriteBatch.Draw(nativeGraphicsManager.TextureFromResource(GFXTypes.PostLoginUI, 32, true), new Vector2(pos.X + ICON_GRAPHIC_X_OFF, pos.Y + HeaderYOffset), GetChatIconRectangle(_data.Icon), Color.White); string strToDraw; if (string.IsNullOrEmpty(_data.Who)) { strToDraw = _partialMessage; } else { strToDraw = _data.Who + " " + _partialMessage; } spriteBatch.DrawString(chatFont, strToDraw, new Vector2(pos.X + CHAT_MESSAGE_X_OFF, pos.Y + HeaderYOffset), _data.ChatColor.ToColor()); spriteBatch.End(); }
//top left - 334, 36 + ndx*124 protected CharacterInfoPanel(int characterIndex, INativeGraphicsManager gfxManager, IEODialogButtonService dialogButtonService) { _gfxManager = gfxManager; DrawPosition = new Vector2(334, 36 + characterIndex * 124); _loginButton = new XNAButton(dialogButtonService.SmallButtonSheet, new Vector2(161, 57), dialogButtonService.GetSmallDialogButtonOutSource(SmallButton.Login), dialogButtonService.GetSmallDialogButtonOverSource(SmallButton.Login)); _loginButton.OnClick += async(o, e) => await LoginButtonClick(); _loginButton.SetParentControl(this); _deleteButton = new XNAButton(dialogButtonService.SmallButtonSheet, new Vector2(161, 85), dialogButtonService.GetSmallDialogButtonOutSource(SmallButton.Delete), dialogButtonService.GetSmallDialogButtonOverSource(SmallButton.Delete)); _deleteButton.OnClick += async(o, e) => await DeleteButtonClick(); _deleteButton.SetParentControl(this); _backgroundImage = _gfxManager.TextureFromResource(GFXTypes.PreLoginUI, 11); }
public ActiveSpellsPanel(INativeGraphicsManager nativeGraphicsManager) { _nativeGraphicsManager = nativeGraphicsManager; BackgroundImage = _nativeGraphicsManager.TextureFromResource(GFXTypes.PostLoginUI, 62); DrawArea = new Rectangle(102, 330, BackgroundImage.Width, BackgroundImage.Height); }
public NewsPanel(INativeGraphicsManager nativeGraphicsManager, IChatRenderableGenerator chatRenderableGenerator, INewsProvider newsProvider, SpriteFont chatFont) { _nativeGraphicsManager = nativeGraphicsManager; _chatRenderableGenerator = chatRenderableGenerator; _newsProvider = newsProvider; //abs coordiantes: 568 331 _scrollBar = new ScrollBar(new Vector2(467, 20), new Vector2(16, 97), ScrollBarColors.LightOnMed, _nativeGraphicsManager) { LinesToRender = 7, Visible = true }; _scrollBar.SetParentControl(this); _chatRenderables = new List <IChatRenderable>(); _chatFont = chatFont; _cachedNewsStrings = new List <string>(); _cachedScrollOffset = -1; _cachedLinesToRender = -1; BackgroundImage = _nativeGraphicsManager.TextureFromResource(GFXTypes.PostLoginUI, 48); DrawArea = new Rectangle(102, 330, BackgroundImage.Width, BackgroundImage.Height); }
public ScrollingMessageDialog(INativeGraphicsManager nativeGraphicsManager, IGameStateProvider gameStateProvider, IEODialogButtonService eoDialogButtonService) : base(gameStateProvider) { _font = Game.Content.Load <SpriteFont>(Constants.FontSize08); _textSplitter = new TextSplitter("", _font) { LineLength = 275 }; BackgroundTexture = nativeGraphicsManager.TextureFromResource(GFXTypes.PreLoginUI, 40); var smallButtonSheet = eoDialogButtonService.SmallButtonSheet; _ok = new XNAButton(smallButtonSheet, new Vector2(138, 197), eoDialogButtonService.GetSmallDialogButtonOutSource(SmallButton.Ok), eoDialogButtonService.GetSmallDialogButtonOverSource(SmallButton.Ok)); _ok.OnClick += (sender, e) => Close(XNADialogResult.OK); _ok.SetParentControl(this); _scrollBar = new ScrollBar(new Vector2(320, 66), new Vector2(16, 119), ScrollBarColors.LightOnMed, nativeGraphicsManager); _scrollBar.SetParentControl(this); MessageText = ""; CenterInGameView(); }
private void DrawWall(SpriteBatch spriteBatch, int row, int col, int alpha, int gfxNum, MapLayer renderLayer) { if (renderLayer != MapLayer.WallRowsDown && renderLayer != MapLayer.WallRowsRight) { throw new ArgumentOutOfRangeException(nameof(renderLayer), "renderLayer must be WallRowsDown or WallRowsRight"); } if (_currentMapStateProvider.OpenDoors.Any(openDoor => openDoor.X == col && openDoor.Y == row)) { gfxNum++; } var gfx = _nativeGraphicsManager.TextureFromResource(GFXTypes.MapWalls, gfxNum, true); var pos = GetDrawCoordinatesFromGridUnits(col, row); var gfxWidthDelta = gfx.Width / 4; var src = gfx.Width > WALL_FRAME_WIDTH ? new Rectangle?(new Rectangle(gfxWidthDelta * 0, 0, gfxWidthDelta, gfx.Height)) //todo: animated walls using source index offset! : null; var wallXOffset = renderLayer == MapLayer.WallRowsRight ? 47 : 15; var wallAnimationAdjust = (int)Math.Round((gfx.Width > WALL_FRAME_WIDTH ? gfxWidthDelta : gfx.Width) / 2.0); pos = new Vector2(pos.X - wallAnimationAdjust + wallXOffset, pos.Y - (gfx.Height - 29)); spriteBatch.Draw(gfx, pos, src, Color.FromNonPremultiplied(255, 255, 255, alpha)); }
public MouseCursorRenderer(INativeGraphicsManager nativeGraphicsManager, ICharacterProvider characterProvider, IRenderOffsetCalculator renderOffsetCalculator, IMapCellStateProvider mapCellStateProvider, IItemStringService itemStringService, IEIFFileProvider eifFileProvider, ICurrentMapProvider currentMapProvider, IGraphicsDeviceProvider graphicsDeviceProvider, IMapInteractionController mapInteractionController) { _mouseCursorTexture = nativeGraphicsManager.TextureFromResource(GFXTypes.PostLoginUI, 24, true); _characterProvider = characterProvider; _renderOffsetCalculator = renderOffsetCalculator; _mapCellStateProvider = mapCellStateProvider; _itemStringService = itemStringService; _eifFileProvider = eifFileProvider; _currentMapProvider = currentMapProvider; _mapInteractionController = mapInteractionController; SingleCursorFrameArea = new Rectangle(0, 0, _mouseCursorTexture.Width / (int)CursorIndex.NumberOfFramesInSheet, _mouseCursorTexture.Height); _drawArea = SingleCursorFrameArea; _mapItemText = new XNALabel(Constants.FontSize08pt75) { Visible = false, Text = string.Empty, ForeColor = Color.White, AutoSize = false, DrawOrder = 10 //todo: make a better provider for draw orders (see also HudControlsFactory) }; _spriteBatch = new SpriteBatch(graphicsDeviceProvider.GraphicsDevice); }
public ISpriteSheet GetBootsTexture(ICharacterRenderProperties characterRenderProperties) { if (characterRenderProperties.BootsGraphic == 0) { return(new EmptySpriteSheet()); } var type = BootsSpriteType.Standing; switch (characterRenderProperties.CurrentAction) { case CharacterActionState.Walking: switch (characterRenderProperties.WalkFrame) { case 1: type = BootsSpriteType.WalkFrame1; break; case 2: type = BootsSpriteType.WalkFrame2; break; case 3: type = BootsSpriteType.WalkFrame3; break; case 4: type = BootsSpriteType.WalkFrame4; break; } break; case CharacterActionState.Attacking: if (!BowIsEquipped(characterRenderProperties) && characterRenderProperties.AttackFrame == 2 || BowIsEquipped(characterRenderProperties) && characterRenderProperties.AttackFrame == 1) { type = BootsSpriteType.Attack; } break; case CharacterActionState.Sitting: switch (characterRenderProperties.SitState) { case SitState.Chair: type = BootsSpriteType.SitChair; break; case SitState.Floor: type = BootsSpriteType.SitGround; break; } break; } var gfxFile = characterRenderProperties.Gender == 0 ? GFXTypes.FemaleShoes : GFXTypes.MaleShoes; var offset = GetOffsetBasedOnState(type) * GetBaseOffsetFromDirection(characterRenderProperties.Direction); var baseBootGraphic = GetBaseBootGraphic(characterRenderProperties.BootsGraphic); var gfxNumber = baseBootGraphic + (int)type + offset; return(new SpriteSheet(_gfxManager.TextureFromResource(gfxFile, gfxNumber, true))); }
public override void InitializeResources(INativeGraphicsManager gfxManager, ContentManager xnaContentManager) { base.InitializeResources(gfxManager, xnaContentManager); for (int i = 0; i < _personSet2.Length; ++i) { _personSet2[i] = gfxManager.TextureFromResource(GFXTypes.PreLoginUI, 61 + i, true); } }
public override void RenderElementAt(SpriteBatch spriteBatch, int row, int col, int alpha) { int gfxNum = CurrentMap.GFX[MapLayer.OverlayObjects][row, col]; var gfx = _nativeGraphicsManager.TextureFromResource(GFXTypes.MapOverlay, gfxNum, true); var pos = GetDrawCoordinatesFromGridUnits(col, row); pos = new Vector2(pos.X + 16, pos.Y - 11); spriteBatch.Draw(gfx, pos, Color.FromNonPremultiplied(255, 255, 255, alpha)); }
public ChangePasswordDialog(INativeGraphicsManager nativeGraphicsManager, IGameStateProvider gameStateProvider, IContentManagerProvider contentManagerProvider, IEOMessageBoxFactory eoMessageBoxFactory, IKeyboardDispatcherProvider keyboardDispatcherProvider, IPlayerInfoProvider playerInfoProvider, IEODialogButtonService dialogButtonService) : base(gameStateProvider) { _eoMessageBoxFactory = eoMessageBoxFactory; _playerInfoProvider = playerInfoProvider; var dispatcher = keyboardDispatcherProvider.Dispatcher; BackgroundTexture = nativeGraphicsManager.TextureFromResource(GFXTypes.PreLoginUI, 21); var cursorTexture = contentManagerProvider.Content.Load <Texture2D>("Cursor"); _inputBoxes = new IXNATextBox[4]; for (int i = 0; i < _inputBoxes.Length; ++i) { var tb = new XNATextBox(new Rectangle(198, 60 + i * 30, 137, 19), Constants.FontSize08, caretTexture: cursorTexture) { LeftPadding = 5, DefaultText = " ", MaxChars = i == 0 ? 16 : 12, PasswordBox = i > 1, TextColor = ColorConstants.LightBeigeText }; _inputBoxes[i] = tb; } _clickEventHandler = new TextBoxClickEventHandler(dispatcher, _inputBoxes); _tabEventHandler = new TextBoxTabEventHandler(dispatcher, _inputBoxes); dispatcher.Subscriber = _inputBoxes[0]; _ok = new XNAButton( dialogButtonService.SmallButtonSheet, new Vector2(157, 195), dialogButtonService.GetSmallDialogButtonOutSource(SmallButton.Ok), dialogButtonService.GetSmallDialogButtonOverSource(SmallButton.Ok)); _ok.OnClick += OnButtonPressed; _cancel = new XNAButton( dialogButtonService.SmallButtonSheet, new Vector2(250, 195), dialogButtonService.GetSmallDialogButtonOutSource(SmallButton.Cancel), dialogButtonService.GetSmallDialogButtonOverSource(SmallButton.Cancel)); _cancel.OnClick += (s, e) => Close(XNADialogResult.Cancel); CenterInGameView(); }
public override void RenderElementAt(SpriteBatch spriteBatch, int row, int col, int alpha) { var pos = GetDrawCoordinatesFromGridUnits(col, row); int tileGFX; if ((tileGFX = CurrentMap.Properties.FillTile) > 0 && CurrentMap.GFX[MapLayer.GroundTile][row, col] < 0) { //todo: source rectangle for fill tile var fillTile = _nativeGraphicsManager.TextureFromResource(GFXTypes.MapTiles, tileGFX, true); spriteBatch.Draw(fillTile, new Vector2(pos.X - 1, pos.Y - 2), Color.FromNonPremultiplied(255, 255, 255, alpha)); } else if ((tileGFX = CurrentMap.GFX[MapLayer.GroundTile][row, col]) > 0) { var tile = _nativeGraphicsManager.TextureFromResource(GFXTypes.MapTiles, tileGFX, true); //todo: animate ground tiles by adjusting the source rectangle offset var src = tile.Width > 64 ? new Rectangle?(new Rectangle(0, 0, tile.Width / 4, tile.Height)) : null; spriteBatch.Draw(tile, new Vector2(pos.X - 1, pos.Y - 2), src, Color.FromNonPremultiplied(255, 255, 255, alpha)); } }
public override void RenderElementAt(SpriteBatch spriteBatch, int row, int col, int alpha) { //todo: handling for spike traps when players walk over them: see OldMapRenderer._drawMapObjectsAtLoc int gfxNum = MapFile.GFX[MapLayer.Objects][row, col]; var gfx = _nativeGraphicsManager.TextureFromResource(GFXTypes.MapObjects, gfxNum, true); var pos = GetDrawCoordinatesFromGridUnits(col, row); pos = new Vector2(pos.X - (int)Math.Round(gfx.Width / 2.0) + 29, pos.Y - (gfx.Height - 28)); spriteBatch.Draw(gfx, pos, Color.FromNonPremultiplied(255, 255, 255, alpha)); }
public ScrollBar(Vector2 locationRelativeToParent, Vector2 size, ScrollBarColors palette, INativeGraphicsManager nativeGraphicsManager) { scrollArea = new Rectangle(0, 15, 0, (int)size.Y - 15); DrawPosition = locationRelativeToParent; SetSize((int)size.X, (int)size.Y); ScrollOffset = 0; var scrollSpriteSheet = nativeGraphicsManager.TextureFromResource(GFXTypes.PostLoginUI, 29); var upArrows = new Rectangle[2]; var downArrows = new Rectangle[2]; int vertOff; switch (palette) { case ScrollBarColors.LightOnLight: vertOff = 0; break; case ScrollBarColors.LightOnMed: vertOff = 105; break; case ScrollBarColors.LightOnDark: vertOff = 180; break; case ScrollBarColors.DarkOnDark: vertOff = 255; break; default: throw new ArgumentOutOfRangeException(nameof(palette)); } //regions based on verticle offset (which is based on the chosen palette) upArrows[0] = new Rectangle(0, vertOff + 15 * 3, 16, 15); upArrows[1] = new Rectangle(0, vertOff + 15 * 4, 16, 15); downArrows[0] = new Rectangle(0, vertOff + 15, 16, 15); downArrows[1] = new Rectangle(0, vertOff + 15 * 2, 16, 15); var scrollBox = new Rectangle(0, vertOff, 16, 15); _upButton = new XNAButton(scrollSpriteSheet, Vector2.Zero, upArrows[0], upArrows[1]); _upButton.OnClick += arrowClicked; _upButton.SetParentControl(this); _downButton = new XNAButton(scrollSpriteSheet, new Vector2(0, size.Y - 15), downArrows[0], downArrows[1]); _downButton.OnClick += arrowClicked; _downButton.SetParentControl(this); _scrollButton = new XNAButton(scrollSpriteSheet, new Vector2(0, 15), scrollBox, scrollBox); _scrollButton.OnClickDrag += OnScrollButtonDragged; _scrollButton.OnMouseEnter += (o, e) => { SuppressParentClickDragEvent(true); }; _scrollButton.OnMouseLeave += (o, e) => { SuppressParentClickDragEvent(false); }; _scrollButton.SetParentControl(this); _totalHeight = DrawAreaWithParentOffset.Height; }
public Texture2D GetNPCTexture(int baseGraphic, NPCFrame whichFrame, EODirection direction) { int offset; switch (whichFrame) { case NPCFrame.Standing: offset = direction == EODirection.Down || direction == EODirection.Right ? 1 : 3; break; case NPCFrame.StandingFrame1: offset = direction == EODirection.Down || direction == EODirection.Right ? 2 : 4; break; case NPCFrame.WalkFrame1: offset = direction == EODirection.Down || direction == EODirection.Right ? 5 : 9; break; case NPCFrame.WalkFrame2: offset = direction == EODirection.Down || direction == EODirection.Right ? 6 : 10; break; case NPCFrame.WalkFrame3: offset = direction == EODirection.Down || direction == EODirection.Right ? 7 : 11; break; case NPCFrame.WalkFrame4: offset = direction == EODirection.Down || direction == EODirection.Right ? 8 : 12; break; case NPCFrame.Attack1: offset = direction == EODirection.Down || direction == EODirection.Right ? 13 : 15; break; case NPCFrame.Attack2: offset = direction == EODirection.Down || direction == EODirection.Right ? 14 : 16; break; default: return(null); } var baseGfx = (baseGraphic - 1) * 40; return(_gfxManager.TextureFromResource(GFXTypes.NPC, baseGfx + offset, true)); }
protected StatusBarBase(INativeGraphicsManager nativeGraphicsManager, ICharacterProvider characterProvider) { _characterProvider = characterProvider; _texture = nativeGraphicsManager.TextureFromResource(GFXTypes.PostLoginUI, 58, true); _label = new XNALabel(Constants.FontSize08) { AutoSize = false, BackColor = Color.Transparent, DrawPosition = new Vector2(3, 15), ForeColor = ColorConstants.LightGrayText, Visible = false }; _label.SetParentControl(this); _sourceRectangleArea = new Rectangle(0, 0, 110, 14); }
private ISpriteSheet CreateAdminGraphic(AdminLevel adminLevel) { var adminGraphic = _gfxManager.TextureFromResource(GFXTypes.PreLoginUI, 22); switch (adminLevel) { case AdminLevel.Player: return(new EmptySpriteSheet()); case AdminLevel.Guide: return(new SpriteSheet(adminGraphic, new Rectangle(252, 39, 17, 17))); case AdminLevel.Guardian: case AdminLevel.GM: case AdminLevel.HGM: return(new SpriteSheet(adminGraphic, new Rectangle(233, 39, 17, 17))); default: throw new ArgumentOutOfRangeException(nameof(adminLevel), adminLevel, null); } }
public GameLoadingDialog(INativeGraphicsManager nativeGraphicsManager, IGameStateProvider gameStateProvider, IClientWindowSizeProvider clientWindowSizeProvider, ILocalizedStringFinder localizedStringFinder) : base(gameStateProvider) { _localizedStringFinder = localizedStringFinder; _backgroundSprite = nativeGraphicsManager.TextureFromResource(GFXTypes.PostLoginUI, 33); DrawPosition = new Vector2(clientWindowSizeProvider.Width - _backgroundSprite.Width / 4 - 10, clientWindowSizeProvider.Height - _backgroundSprite.Height - 10); SetSize(_backgroundSprite.Width / 4, _backgroundSprite.Height); _bgSrcIndex = 0; _lastBackgroundUpdate = DateTime.Now; _caption = new XNALabel(Constants.FontSize10) { AutoSize = true, Text = _localizedStringFinder.GetString(EOResourceID.LOADING_GAME_PLEASE_WAIT), ForeColor = ColorConstants.LightYellowText, DrawPosition = new Vector2(12, 9) }; _caption.SetParentControl(this); var gen = new Random(); var messageTextID = (EOResourceID)gen.Next((int)EOResourceID.LOADING_GAME_HINT_FIRST, (int)EOResourceID.LOADING_GAME_HINT_LAST); var localizedMessage = _localizedStringFinder.GetString(messageTextID); _message = new XNALabel(Constants.FontSize08) { AutoSize = true, TextWidth = 175, ForeColor = ColorConstants.MediumGrayText, Text = localizedMessage, DrawPosition = new Vector2(18, 61) }; _message.SetParentControl(this); }
protected EODialogBase(INativeGraphicsManager nativeGraphicsManager) { smallButtonSheet = nativeGraphicsManager.TextureFromResource(GFXTypes.PreLoginUI, 15, true); }
public EOMessageBox(INativeGraphicsManager graphicsManager, IGameStateProvider gameStateProvider, IEODialogButtonService eoDialogButtonService, string message, string caption = "", EOMessageBoxStyle style = EOMessageBoxStyle.SmallDialogSmallHeader, EODialogButtons whichButtons = EODialogButtons.Ok) : base(gameStateProvider) { var useSmallHeader = style != EOMessageBoxStyle.SmallDialogLargeHeader; int graphic; switch (style) { case EOMessageBoxStyle.SmallDialogLargeHeader: graphic = 18; break; case EOMessageBoxStyle.SmallDialogSmallHeader: graphic = 23; break; case EOMessageBoxStyle.LargeDialogSmallHeader: graphic = 25; break; default: throw new ArgumentOutOfRangeException(nameof(style), "Unrecognized dialog style!"); } BackgroundTexture = graphicsManager.TextureFromResource(GFXTypes.PreLoginUI, graphic); _messageLabel = new XNALabel(Constants.FontSize10) { AutoSize = true, ForeColor = ColorConstants.LightYellowText, Text = message, TextWidth = 254, DrawPosition = new Vector2(18, useSmallHeader ? 40 : 57) }; _messageLabel.SetParentControl(this); _captionLabel = new XNALabel(Constants.FontSize10) { AutoSize = true, ForeColor = ColorConstants.LightYellowText, Text = caption, TextWidth = 254, DrawPosition = useSmallHeader ? new Vector2(18, 12) : new Vector2(59, 23) }; _captionLabel.SetParentControl(this); var smallButtonSheet = eoDialogButtonService.SmallButtonSheet; var okOut = eoDialogButtonService.GetSmallDialogButtonOutSource(SmallButton.Ok); var okOver = eoDialogButtonService.GetSmallDialogButtonOverSource(SmallButton.Ok); var cancelOut = eoDialogButtonService.GetSmallDialogButtonOutSource(SmallButton.Cancel); var cancelOver = eoDialogButtonService.GetSmallDialogButtonOverSource(SmallButton.Cancel); switch (whichButtons) { case EODialogButtons.Ok: _ok = new XNAButton(smallButtonSheet, new Vector2(181, 113), okOut, okOver); _ok.OnClick += (sender, e) => Close(XNADialogResult.OK); _ok.SetParentControl(this); break; case EODialogButtons.Cancel: _cancel = new XNAButton(smallButtonSheet, new Vector2(181, 113), cancelOut, cancelOver); _cancel.OnClick += (sender, e) => Close(XNADialogResult.Cancel); _cancel.SetParentControl(this); break; case EODialogButtons.OkCancel: //implement this more fully when it is needed //update draw location of ok button to be on left? _ok = new XNAButton(smallButtonSheet, new Vector2(89, 113), okOut, okOver); _ok.OnClick += (sender, e) => Close(XNADialogResult.OK); _ok.SetParentControl(this); _cancel = new XNAButton(smallButtonSheet, new Vector2(181, 113), cancelOut, cancelOver); _cancel.OnClick += (s, e) => Close(XNADialogResult.Cancel); _cancel.SetParentControl(this); break; } if (useSmallHeader) { if (_ok != null) { _ok.DrawPosition = new Vector2(_ok.DrawPosition.X, style == EOMessageBoxStyle.SmallDialogSmallHeader ? 82 : 148); } if (_cancel != null) { _cancel.DrawPosition = new Vector2(_cancel.DrawPosition.X, style == EOMessageBoxStyle.SmallDialogSmallHeader ? 82 : 148); } } CenterInGameView(); }
public Texture2D GetArmor(bool isBow = false) { ArmorShieldSpriteType type = ArmorShieldSpriteType.Standing; switch (_charRef.State) { case CharacterActionState.Walking: switch (_data.walkFrame) { case 1: type = ArmorShieldSpriteType.WalkFrame1; break; case 2: type = ArmorShieldSpriteType.WalkFrame2; break; case 3: type = ArmorShieldSpriteType.WalkFrame3; break; case 4: type = ArmorShieldSpriteType.WalkFrame4; break; } break; case CharacterActionState.Attacking: if (isBow) { switch (_data.attackFrame) { case 1: type = ArmorShieldSpriteType.Bow; break; case 2: type = ArmorShieldSpriteType.Standing; break; } } else { switch (_data.attackFrame) { case 1: type = ArmorShieldSpriteType.PunchFrame1; break; case 2: type = ArmorShieldSpriteType.PunchFrame2; break; } } break; case CharacterActionState.SpellCast: type = ArmorShieldSpriteType.SpellCast; break; case CharacterActionState.Sitting: switch (_data.sitting) { case SitState.Chair: type = ArmorShieldSpriteType.SitChair; break; case SitState.Floor: type = ArmorShieldSpriteType.SitGround; break; } break; } short baseArmorValue = (short)((_data.armor - 1) * 50); GFXTypes gfxFile = (_data.gender == 0) ? GFXTypes.FemaleArmor : GFXTypes.MaleArmor; int factor = (_data.facing == EODirection.Down || _data.facing == EODirection.Right) ? 0 : 1; //multiplier for the direction faced factor *= getFactor(type); int gfxNumber = baseArmorValue + (int)type + factor; return(_gfxManager.TextureFromResource(gfxFile, gfxNumber, true)); }
public StatsPanel(INativeGraphicsManager nativeGraphicsManager, ICharacterProvider characterProvider, ICharacterInventoryProvider characterInventoryProvider, IExperienceTableProvider experienceTableProvider, IEOMessageBoxFactory messageBoxFactory, ITrainingController trainingController) { _characterProvider = characterProvider; _characterInventoryProvider = characterInventoryProvider; _experienceTableProvider = experienceTableProvider; _messageBoxFactory = messageBoxFactory; _trainingController = trainingController; BackgroundImage = nativeGraphicsManager.TextureFromResource(GFXTypes.PostLoginUI, 34); DrawArea = new Rectangle(102, 330, BackgroundImage.Width, BackgroundImage.Height); _basicStats = new IXNALabel[6]; _arrowButtons = new IXNAButton[6]; _characterStats = new IXNALabel[6]; _characterInfo = new IXNALabel[3]; _otherInfo = new IXNALabel[8]; var buttonTexture = nativeGraphicsManager.TextureFromResource(GFXTypes.PostLoginUI, 27, true); var outTextureArea = new Rectangle(215, 386, 19, 15); var overTextureArea = new Rectangle(234, 386, 19, 15); for (int i = 0; i < _basicStats.Length; ++i) { _basicStats[i] = new XNALabel(Constants.FontSize08pt5) { ForeColor = ColorConstants.LightGrayText, AutoSize = false, Text = "", DrawArea = new Rectangle(50, 8 + i * 18, 73, 13) }; _arrowButtons[i] = new XNAButton(buttonTexture, new Vector2(106, 7 + i * 18), outTextureArea, overTextureArea) { Visible = false, FlashSpeed = 500 }; } for (int i = 0; i < _characterStats.Length; ++i) { _characterStats[i] = new XNALabel(Constants.FontSize08pt5) { ForeColor = ColorConstants.LightGrayText, AutoSize = false, Text = "", DrawArea = new Rectangle(158, 8 + i * 18, 73, 13) }; } for (int i = 0; i < _otherInfo.Length; ++i) { var drawArea = i < 4 ? new Rectangle(280, 44 + i % 4 * 18, 60, 13) : new Rectangle(379, 44 + i % 4 * 18, 94, 13); _otherInfo[i] = new XNALabel(Constants.FontSize08pt5) { ForeColor = ColorConstants.LightGrayText, AutoSize = false, Text = "", DrawArea = drawArea }; } _characterInfo[NAME] = new XNALabel(Constants.FontSize08pt5) { ForeColor = ColorConstants.LightGrayText, AutoSize = false, Text = "", DrawArea = new Rectangle(280, 8, 144, 13) }; _characterInfo[GUILD] = new XNALabel(Constants.FontSize08pt5) { ForeColor = ColorConstants.LightGrayText, AutoSize = false, Text = "", DrawArea = new Rectangle(280, 26, 193, 13) }; _characterInfo[LEVEL] = new XNALabel(Constants.FontSize08pt5) { ForeColor = ColorConstants.LightGrayText, AutoSize = false, Text = "", DrawArea = new Rectangle(453, 8, 20, 13) }; }
public override void InitializeResources(INativeGraphicsManager gfxManager, ContentManager xnaContentManager) { base.InitializeResources(gfxManager, xnaContentManager); _labelsTexture = gfxManager.TextureFromResource(GFXTypes.PreLoginUI, 12, true); }
public OldScrollBar(XNAControl parent, Vector2 locationRelaiveToParent, Vector2 size, ScrollBarColors palette, INativeGraphicsManager nativeGraphicsManager) : base(locationRelaiveToParent, new Rectangle((int)locationRelaiveToParent.X, (int)locationRelaiveToParent.Y, (int)size.X, (int)size.Y)) { SetParent(parent); scrollArea = new Rectangle(0, 15, 0, (int)size.Y - 15); DrawLocation = locationRelaiveToParent; ScrollOffset = 0; Texture2D scrollSpriteSheet = nativeGraphicsManager.TextureFromResource(GFXTypes.PostLoginUI, 29); Rectangle[] upArrows = new Rectangle[2]; Rectangle[] downArrows = new Rectangle[2]; int vertOff; switch (palette) { case ScrollBarColors.LightOnLight: vertOff = 0; break; case ScrollBarColors.LightOnMed: vertOff = 105; break; case ScrollBarColors.LightOnDark: vertOff = 180; break; case ScrollBarColors.DarkOnDark: vertOff = 255; break; default: throw new ArgumentOutOfRangeException(nameof(palette)); } //regions based on verticle offset (which is based on the chosen palette) upArrows[0] = new Rectangle(0, vertOff + 15 * 3, 16, 15); upArrows[1] = new Rectangle(0, vertOff + 15 * 4, 16, 15); downArrows[0] = new Rectangle(0, vertOff + 15, 16, 15); downArrows[1] = new Rectangle(0, vertOff + 15 * 2, 16, 15); Rectangle scrollBox = new Rectangle(0, vertOff, 16, 15); Texture2D[] upButton = new Texture2D[2]; Texture2D[] downButton = new Texture2D[2]; Texture2D[] scrollButton = new Texture2D[2]; for (int i = 0; i < 2; ++i) { upButton[i] = new Texture2D(scrollSpriteSheet.GraphicsDevice, upArrows[i].Width, upArrows[i].Height); Color[] upData = new Color[upArrows[i].Width * upArrows[i].Height]; scrollSpriteSheet.GetData(0, upArrows[i], upData, 0, upData.Length); upButton[i].SetData(upData); downButton[i] = new Texture2D(scrollSpriteSheet.GraphicsDevice, downArrows[i].Width, downArrows[i].Height); Color[] downData = new Color[downArrows[i].Width * downArrows[i].Height]; scrollSpriteSheet.GetData(0, downArrows[i], downData, 0, downData.Length); downButton[i].SetData(downData); //same texture for hover, AFAIK scrollButton[i] = new Texture2D(scrollSpriteSheet.GraphicsDevice, scrollBox.Width, scrollBox.Height); Color[] scrollData = new Color[scrollBox.Width * scrollBox.Height]; scrollSpriteSheet.GetData(0, scrollBox, scrollData, 0, scrollData.Length); scrollButton[i].SetData(scrollData); } up = new XNAButton(upButton, new Vector2(0, 0)); up.OnClick += arrowClicked; up.SetParent(this); down = new XNAButton(downButton, new Vector2(0, size.Y - 15)); //update coordinates!!!! down.OnClick += arrowClicked; down.SetParent(this); scroll = new XNAButton(scrollButton, new Vector2(0, 15)); //update coordinates!!!! scroll.OnClickDrag += scrollDragged; scroll.OnMouseEnter += (o, e) => { SuppressParentClickDrag(true); }; scroll.OnMouseLeave += (o, e) => { SuppressParentClickDrag(false); }; scroll.SetParent(this); _totalHeight = DrawAreaWithOffset.Height; }
public CreateCharacterDialog( INativeGraphicsManager nativeGraphicsManager, IGameStateProvider gameStateProvider, ICharacterRendererFactory rendererFactory, ContentManager contentManager, KeyboardDispatcher dispatcher, IEOMessageBoxFactory messageBoxFactory, IEODialogButtonService eoDialogButtonService) : base(gameStateProvider) { _messageBoxFactory = messageBoxFactory; BackgroundTexture = nativeGraphicsManager.TextureFromResource(GFXTypes.PreLoginUI, 20); _charCreateSheet = nativeGraphicsManager.TextureFromResource(GFXTypes.PreLoginUI, 22); var cursorTexture = contentManager.Load <Texture2D>("cursor"); _inputBox = new XNATextBox(new Rectangle(80, 57, 138, 19), Constants.FontSize08, caretTexture: cursorTexture) { LeftPadding = 5, DefaultText = " ", Text = " ", MaxChars = 12, Selected = true, TextColor = ColorConstants.LightBeigeText, Visible = true }; _inputBox.SetParentControl(this); dispatcher.Subscriber = _inputBox; for (int i = 0; i < _arrowButtons.Length; ++i) { var btn = new XNAButton(_charCreateSheet, new Vector2(196, 85 + i * 26), new Rectangle(185, 38, 19, 19), new Rectangle(206, 38, 19, 19)); btn.OnClick += ArrowButtonClick; btn.SetParentControl(this); _arrowButtons[i] = btn; } _characterControl = new CreateCharacterControl(rendererFactory) { DrawPosition = new Vector2(235, 58) }; _characterControl.SetParentControl(this); _srcRectangles[0] = new Rectangle(0, 38, 23, 19); _srcRectangles[1] = new Rectangle(0, 19, 23, 19); _srcRectangles[2] = new Rectangle(0, 0, 23, 19); _srcRectangles[3] = new Rectangle(46, 38, 23, 19); _ok = new XNAButton(eoDialogButtonService.SmallButtonSheet, new Vector2(157, 195), eoDialogButtonService.GetSmallDialogButtonOutSource(SmallButton.Ok), eoDialogButtonService.GetSmallDialogButtonOverSource(SmallButton.Ok)); _ok.OnClick += (s, e) => ClickOk(); _ok.SetParentControl(this); _cancel = new XNAButton(eoDialogButtonService.SmallButtonSheet, new Vector2(250, 195), eoDialogButtonService.GetSmallDialogButtonOutSource(SmallButton.Cancel), eoDialogButtonService.GetSmallDialogButtonOverSource(SmallButton.Cancel)); _cancel.OnClick += (s, e) => Close(XNADialogResult.Cancel); _cancel.SetParentControl(this); CenterInGameView(); }