Пример #1
0
        private void UpdateItemLocation(int newSlot)
        {
            if (Slot != newSlot && ((OldEOInventory)parent).MoveItem(this, newSlot))
            {
                Slot = newSlot;
            }

            //top-left grid slot in the inventory is 115, 339
            //parent top-left is 103, 330
            //grid size is 26*26 (w/o borders 23*23)
            int width, height;

            OldEOInventory._getItemSizeDeltas(m_itemData.Size, out width, out height);
            DrawLocation = new Vector2(13 + 26 * (Slot % OldEOInventory.INVENTORY_ROW_LENGTH), 9 + 26 * (Slot / OldEOInventory.INVENTORY_ROW_LENGTH));
            _setSize(width * 26, height * 26);

            if (m_nameLabel != null) //fix the position of the name label too if we aren't creating the inventoryitem
            {
                m_nameLabel.DrawLocation = new Vector2(DrawArea.Width, 0);
                if (!OldEOInventory.GRID_AREA.Contains(m_nameLabel.DrawAreaWithOffset))
                {
                    m_nameLabel.DrawLocation = new Vector2(-m_nameLabel.DrawArea.Width, 0); //show on the right if it isn't in bounds!
                }
                m_nameLabel.ResizeBasedOnText(16, 9);
            }
        }
Пример #2
0
        private void UpdateDisplayedMapItemName()
        {
            var mi = _parentMapRenderer.GetMapItemAt(_gridX, _gridY);

            if (mi != null)
            {
                _cursorSourceRect.Location = new Point(2 * (_mouseCursor.Width / 5), 0);

                string itemName = OldEOInventoryItem.GetNameString(mi.ItemID, mi.Amount);
                if (_itemHoverName.Text != itemName)
                {
                    _itemHoverName.Visible = true;
                    _itemHoverName.Text    = OldEOInventoryItem.GetNameString(mi.ItemID, mi.Amount);
                    _itemHoverName.ResizeBasedOnText();
                    _itemHoverName.ForeColor = OldEOInventoryItem.GetItemTextColor(mi.ItemID);
                }
                _itemHoverName.DrawLocation = new Vector2(
                    _cursorPos.X + 32 - _itemHoverName.ActualWidth / 2f,
                    _cursorPos.Y - _itemHoverName.ActualHeight - 4);
            }
            else if (_itemHoverName.Visible)
            {
                _itemHoverName.Visible = false;
                _itemHoverName.Text    = " ";
            }

            if (_itemHoverName.Text.Length > 0 && !_game.Components.Contains(_itemHoverName))
            {
                _game.Components.Add(_itemHoverName);
            }
        }
Пример #3
0
        /// <summary>
        /// turns the primary text into a link that performs the specified action. When Style is Small, the entire item becomes clickable.
        /// </summary>
        /// <param name="onClickAction">The action to perform</param>
        public void SetPrimaryTextLink(Action onClickAction)
        {
            if (m_primaryText == null)
            {
                return;
            }
            XNALabel oldText = m_primaryText;

            m_primaryText = new XNAHyperLink(oldText.DrawArea, Constants.FontSize08pt5)
            {
                AutoSize       = false,
                BackColor      = oldText.BackColor,
                ForeColor      = oldText.ForeColor,
                HighlightColor = oldText.ForeColor,
                Text           = oldText.Text,
                Underline      = true
            };
            m_primaryText.ResizeBasedOnText();
            ((XNAHyperLink)m_primaryText).OnClick += (o, e) => onClickAction();
            m_primaryText.SetParent(this);
            oldText.Close();

            if (Style == ListItemStyle.Small)
            {
                OnLeftClick += (o, e) => onClickAction();
            }
        }
Пример #4
0
        public ListDialogItem(EODialogBase parent, ListItemStyle style, int listIndex = -1)
        {
            DrawLocation = new Vector2(17, DrawLocation.Y); //the base X coordinate is 17 - this can be adjusted with OffsetX property

            Style = style;
            if (listIndex >= 0)
            {
                Index = listIndex;
            }

            _setSize(232, Style == ListItemStyle.Large ? 36 : 13);

            int colorFactor = Style == ListItemStyle.Large ? 0xc8 : 0xb4;

            m_primaryText = new XNALabel(new Rectangle(Style == ListItemStyle.Large ? 56 : 2, Style == ListItemStyle.Large ? 5 : 0, 1, 1), Constants.FontSize08pt5)
            {
                AutoSize  = false,
                BackColor = Color.Transparent,
                ForeColor = Color.FromNonPremultiplied(colorFactor, colorFactor, colorFactor, 0xff),
                TextAlign = LabelAlignment.TopLeft,
                Text      = " "
            };
            m_primaryText.ResizeBasedOnText();

            if (Style == ListItemStyle.Large)
            {
                m_secondaryText = new XNALabel(new Rectangle(56, 20, 1, 1), Constants.FontSize08pt5)
                {
                    AutoSize  = true,
                    BackColor = m_primaryText.BackColor,
                    ForeColor = m_primaryText.ForeColor,
                    Text      = " "
                };
                m_secondaryText.ResizeBasedOnText();

                m_gfxPadThing      = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.MapTiles, 0, true);
                ShowItemBackGround = true;
            }
            m_backgroundColor = new Texture2D(Game.GraphicsDevice, 1, 1);
            m_backgroundColor.SetData(new[] { Color.FromNonPremultiplied(0xff, 0xff, 0xff, 64) });

            SetParent(parent);
            m_primaryText.SetParent(this);
            if (Style == ListItemStyle.Large)
            {
                m_secondaryText.SetParent(this);
            }
            OffsetY = Style == ListItemStyle.Large ? 25 : 45;
        }
        private void UpdateMapItemLabel(Optional <IItem> item)
        {
            if (!item.HasValue)
            {
                _mapItemText.Visible = false;
                _mapItemText.Text    = string.Empty;
            }
            else if (!_mapItemText.Visible)
            {
                _mapItemText.Visible = true;
                _mapItemText.Text    = _itemStringService.GetStringForMapDisplay(
                    _eifFileProvider.EIFFile[item.Value.ItemID], item.Value.Amount);
                _mapItemText.ResizeBasedOnText();
                _mapItemText.ForeColor = GetColorForMapDisplay(_eifFileProvider.EIFFile[item.Value.ItemID]);

                //relative to cursor DrawPosition, since this control is a parent of MapItemText
                _mapItemText.DrawPosition = new Vector2(_drawArea.X + 32 - _mapItemText.ActualWidth / 2f,
                                                        _drawArea.Y + -_mapItemText.ActualHeight - 4);
            }
        }
Пример #6
0
        private void _initItemLabel()
        {
            if (m_nameLabel != null)
            {
                m_nameLabel.Dispose();
            }

            m_nameLabel = new XNALabel(new Rectangle(DrawArea.Width, 0, 150, 23), "Microsoft Sans MS", 8f)
            {
                Visible   = false,
                AutoSize  = false,
                TextAlign = ContentAlignment.MiddleCenter,
                ForeColor = System.Drawing.Color.FromArgb(255, 200, 200, 200),
                BackColor = System.Drawing.Color.FromArgb(160, 30, 30, 30)
            };

            UpdateItemLabel();

            m_nameLabel.ForeColor = GetItemTextColor((short)m_itemData.ID);

            m_nameLabel.SetParent(this);
            m_nameLabel.ResizeBasedOnText(16, 9);
        }
Пример #7
0
        private void _initItemLabel()
        {
            if (m_nameLabel != null)
            {
                m_nameLabel.Dispose();
            }

            m_nameLabel = new XNALabel(new Rectangle(DrawArea.Width, 0, 150, 23), Constants.FontSize08)
            {
                Visible   = false,
                AutoSize  = false,
                TextAlign = LabelAlignment.MiddleCenter,
                ForeColor = Color.FromNonPremultiplied(200, 200, 200, 255),
                BackColor = Color.FromNonPremultiplied(30, 30, 30, 160)
            };

            UpdateItemLabel();

            m_nameLabel.ForeColor = GetItemTextColor((short)m_itemData.ID);

            m_nameLabel.SetParent(this);
            m_nameLabel.ResizeBasedOnText(16, 9);
        }
Пример #8
0
        private void _initItemLabel()
        {
            if (m_nameLabel != null) m_nameLabel.Dispose();

            m_nameLabel = new XNALabel(new Rectangle(DrawArea.Width, 0, 150, 23), "Microsoft Sans MS", 8f)
            {
                Visible = false,
                AutoSize = false,
                TextAlign = ContentAlignment.MiddleCenter,
                ForeColor = System.Drawing.Color.FromArgb(255, 200, 200, 200),
                BackColor = System.Drawing.Color.FromArgb(160, 30, 30, 30)
            };

            UpdateItemLabel();

            m_nameLabel.ForeColor = GetItemTextColor((short)m_itemData.ID);

            m_nameLabel.SetParent(this);
            m_nameLabel.ResizeBasedOnText(16, 9);
        }
Пример #9
0
		private void _initItemLabel()
		{
			if (m_nameLabel != null) m_nameLabel.Dispose();

			m_nameLabel = new XNALabel(new Rectangle(DrawArea.Width, 0, 150, 23), Constants.FontSize08)
			{
				Visible = false,
				AutoSize = false,
				TextAlign = LabelAlignment.MiddleCenter,
				ForeColor = Color.FromNonPremultiplied(200, 200, 200, 255),
				BackColor = Color.FromNonPremultiplied(30, 30, 30, 160)
			};

			UpdateItemLabel();

			m_nameLabel.ForeColor = GetItemTextColor((short)m_itemData.ID);

			m_nameLabel.SetParent(this);
			m_nameLabel.ResizeBasedOnText(16, 9);
		}
Пример #10
0
		private void CreateMouseoverName()
		{
			_mouseoverName = new XNALabel(new Rectangle(1, 1, 1, 1), Constants.FontSize08pt75)
			{
				Visible = false,
				Text = NPC.Data.Name,
				ForeColor = Color.White,
				AutoSize = false,
				DrawOrder = (int)ControlDrawLayer.BaseLayer + 3
			};
			_mouseoverName.DrawLocation = new Vector2(
				DrawArea.X + (DrawArea.Width - _mouseoverName.ActualWidth) / 2f,
				DrawArea.Y + TopPixel - _mouseoverName.ActualHeight - 4);
			_mouseoverName.ResizeBasedOnText();
		}
Пример #11
0
		//turns the subtext into a link that performs the specified action
		public void SetSubtextLink(Action onClickAction)
		{
			if (m_secondaryText == null || Style == ListItemStyle.Small)
				return;
			XNALabel oldText = m_secondaryText;
			m_secondaryText = new XNAHyperLink(oldText.DrawArea, Constants.FontSize08pt5)
			{
				AutoSize = false,
				BackColor = oldText.BackColor,
				ForeColor = oldText.ForeColor,
				HighlightColor = oldText.ForeColor,
				Text = oldText.Text,
				Underline = true
			};
			m_secondaryText.ResizeBasedOnText();
			((XNAHyperLink)m_secondaryText).OnClick += (o, e) => onClickAction();
			m_secondaryText.SetParent(this);
			oldText.Close();
		}
Пример #12
0
		public ListDialogItem(EODialogBase parent, ListItemStyle style, int listIndex = -1)
		{
			DrawLocation = new Vector2(17, DrawLocation.Y); //the base X coordinate is 17 - this can be adjusted with OffsetX property

			Style = style;
			if (listIndex >= 0)
				Index = listIndex;

			_setSize(232, Style == ListItemStyle.Large ? 36 : 13);

			int colorFactor = Style == ListItemStyle.Large ? 0xc8 : 0xb4;

			m_primaryText = new XNALabel(new Rectangle(Style == ListItemStyle.Large ? 56 : 2, Style == ListItemStyle.Large ? 5 : 0, 1, 1), Constants.FontSize08pt5)
			{
				AutoSize = false,
				BackColor = Color.Transparent,
				ForeColor = Color.FromNonPremultiplied(colorFactor, colorFactor, colorFactor, 0xff),
				TextAlign = LabelAlignment.TopLeft,
				Text = " "
			};
			m_primaryText.ResizeBasedOnText();

			if (Style == ListItemStyle.Large)
			{
				m_secondaryText = new XNALabel(new Rectangle(56, 20, 1, 1), Constants.FontSize08pt5)
				{
					AutoSize = true,
					BackColor = m_primaryText.BackColor,
					ForeColor = m_primaryText.ForeColor,
					Text = " "
				};
				m_secondaryText.ResizeBasedOnText();

				m_gfxPadThing = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.MapTiles, 0, true);
				ShowItemBackGround = true;
			}
			m_backgroundColor = new Texture2D(Game.GraphicsDevice, 1, 1);
			m_backgroundColor.SetData(new[] { Color.FromNonPremultiplied(0xff, 0xff, 0xff, 64) });

			SetParent(parent);
			m_primaryText.SetParent(this);
			if (Style == ListItemStyle.Large)
			{
				m_secondaryText.SetParent(this);
			}
			OffsetY = Style == ListItemStyle.Large ? 25 : 45;
		}
Пример #13
0
		public NPC(NPCData data)
			: base(EOGame.Instance)
		{
			ApplyData(data);
			bool success = true;
			npcSheet = new EONPCSpriteSheet(((EOGame)Game).GFXManager, this);
			int tries = 0;
			do
			{
				try
				{
					//attempt to get standing frame 1. It will have non-black pixels if it exists.
					Frame = NPCFrame.StandingFrame1;
					Texture2D tmp = npcSheet.GetNPCTexture();
					Color[] tmpData = new Color[tmp.Width*tmp.Height];
					tmp.GetData(tmpData);
					hasStandFrame1 = tmpData.Any(_c => _c.R != 0 || _c.G != 0 || _c.B != 0);

					//get the first non-transparent pixel to determine offsets for name labels and damage counters
					Frame = NPCFrame.Standing;
					tmp = npcSheet.GetNPCTexture();
					tmpData = new Color[tmp.Width*tmp.Height];
					tmp.GetData(tmpData);
					int i = 0;
					while (i < tmpData.Length && tmpData[i].A == 0) i++;
					TopPixel = i == tmpData.Length - 1 ? 0 : i/tmp.Height;

				} //this block throws errors sometimes..no idea why. Keep looping until it works.
				catch (InvalidOperationException)
				{
					success = false;
					tries++;
				}
			} while (!success && tries < 3);

			if(tries >= 3)
				throw new InvalidOperationException("Something weird happened initializing this NPC.");

			m_chatBubble = new EOChatBubble(this);
			m_damageCounter = new DamageCounter(this);
			_mouseoverName = new XNALabel(new Rectangle(1, 1, 1, 1), Constants.FontSize08pt75)
			{
				Visible = false,
				Text = Data.Name,
				ForeColor = Color.White,
				AutoSize = false,
				DrawOrder = (int) ControlDrawLayer.BaseLayer + 3
			};
			_mouseoverName.DrawLocation = new Vector2(
				DrawArea.X + (DrawArea.Width - _mouseoverName.ActualWidth)/2f,
				DrawArea.Y + TopPixel - _mouseoverName.ActualHeight - 4);
			_mouseoverName.ResizeBasedOnText();
		}