示例#1
0
        public void Update(Guid currentItemId, int[] statBoost)
        {
            if (currentItemId != mCurrentItemId || !mTexLoaded)
            {
                mCurrentItemId = currentItemId;
                mStatBoost     = statBoost;
                var item = ItemBase.Get(mCurrentItemId);
                if (item != null)
                {
                    var itemTex = Globals.ContentManager.GetTexture(GameContentManager.TextureType.Item, item.Icon);
                    if (itemTex != null)
                    {
                        ContentPanel.Show();
                        ContentPanel.Texture = itemTex;
                    }
                    else
                    {
                        ContentPanel.Hide();
                    }
                }
                else
                {
                    ContentPanel.Hide();
                }

                mTexLoaded = true;
            }
        }
        //Init
        public EventWindow(Canvas gameCanvas)
        {
            //Event Dialog Window
            mEventDialogWindow = new ImagePanel(gameCanvas, "EventDialogueWindow");
            mEventDialogWindow.Hide();
            Interface.InputBlockingElements.Add(mEventDialogWindow);

            mEventFace = new ImagePanel(mEventDialogWindow, "EventFacePanel");

            mEventDialogArea          = new ScrollControl(mEventDialogWindow, "EventDialogArea");
            mEventDialogLabelTemplate = new Label(mEventDialogArea, "EventDialogLabel");
            mEventDialogLabel         = new RichLabel(mEventDialogArea);

            mEventDialogAreaNoFace          = new ScrollControl(mEventDialogWindow, "EventDialogAreaNoFace");
            mEventDialogLabelNoFaceTemplate = new Label(mEventDialogAreaNoFace, "EventDialogLabel");
            mEventDialogLabelNoFace         = new RichLabel(mEventDialogAreaNoFace);

            mEventResponse1          = new Button(mEventDialogWindow, "EventResponse1");
            mEventResponse1.Clicked += EventResponse1_Clicked;

            mEventResponse2          = new Button(mEventDialogWindow, "EventResponse2");
            mEventResponse2.Clicked += EventResponse2_Clicked;

            mEventResponse3          = new Button(mEventDialogWindow, "EventResponse3");
            mEventResponse3.Clicked += EventResponse3_Clicked;

            mEventResponse4          = new Button(mEventDialogWindow, "EventResponse4");
            mEventResponse4.Clicked += EventResponse4_Clicked;
        }
 public void Close()
 {
     if (Picture != null)
     {
         Globals.Picture = null;
         Picture         = null;
         mPicture.Hide();
     }
 }
 public void Close()
 {
     if (Picture != null)
     {
         PacketSender.SendClosePicture(Globals.Picture?.EventId ?? Guid.Empty);
         Globals.Picture = null;
         Picture         = null;
         mPicture.Hide();
     }
 }
        //Methods
        public void Update()
        {
            // Is this disabled from the server config? If so, skip doing anything.
            if (!Options.Loot.EnableLootWindow)
            {
                mMapItemWindow.Hide();
                return;
            }

            // Are we allowed to scan for items?
            if (mLastItemScan < Timing.Global.Milliseconds)
            {
                // Reset if we've found items
                mFoundItems = false;

                // Find all valid locations near our location and iterate through them to find items we can display.
                var itemSlot = 0;
                foreach (var map in FindSurroundingTiles(Globals.Me.X, Globals.Me.Y, Options.Loot.MaximumLootWindowDistance))
                {
                    var mapItems = map.Key.MapItems;
                    var tiles    = map.Value;

                    // iterate through all locations on this map to see if we've got items there.
                    foreach (var tileIndex in tiles)
                    {
                        // When no items have ever been on this location, just skip straight away.
                        if (!mapItems.ContainsKey(tileIndex))
                        {
                            continue;
                        }

                        // Go through each item up to our display limit and add them to our window.
                        foreach (var mapItem in mapItems[tileIndex])
                        {
                            // Skip rendering this item if we're already past the cap we are allowed to display.
                            if (itemSlot > Options.Loot.MaximumLootWindowItems - 1)
                            {
                                continue;
                            }

                            var finalItem = mapItem.Base;
                            if (finalItem != null)
                            {
                                Items[itemSlot].TileIndex    = tileIndex;
                                Items[itemSlot].MapId        = map.Key.Id;
                                Items[itemSlot].MyItem       = mapItem;
                                Items[itemSlot].Pnl.IsHidden = false;
                                if (finalItem.IsStackable)
                                {
                                    mValues[itemSlot].IsHidden = false;
                                    mValues[itemSlot].Text     = Strings.FormatQuantityAbbreviated(mapItem.Quantity);
                                }
                                else
                                {
                                    mValues[itemSlot].IsHidden = true;
                                }

                                mFoundItems = true;
                                itemSlot++;
                            }
                            else
                            {
                                Items[itemSlot].TileIndex    = -1;
                                Items[itemSlot].MyItem       = null;
                                Items[itemSlot].Pnl.IsHidden = true;
                                mValues[itemSlot].IsHidden   = true;
                            }
                        }
                    }
                }

                // Update our UI and hide our unused icons.
                for (var slot = 0; slot < Options.Loot.MaximumLootWindowItems; slot++)
                {
                    if (slot > itemSlot - 1)
                    {
                        Items[slot].MyItem       = null;
                        Items[slot].Pnl.IsHidden = true;
                        mValues[slot].IsHidden   = true;
                    }

                    Items[slot].Update();
                }

                // Set up our timer
                mLastItemScan = Timing.Global.Milliseconds + mScanTimer;
            }

            // Do we display our window?
            if (!mFoundItems)
            {
                mMapItemWindow.Hide();
            }
            else
            {
                mMapItemWindow.Show();
            }
        }
示例#6
0
        public void Update()
        {
            if (Globals.Me == null)
            {
                return;
            }

            //See if Label Should be changed
            if (mHotKey != Controls.ActiveControls.ControlMapping[Control.Hotkey1 + mYindex].Key1)
            {
                KeyLabel.SetText(
                    Strings.Keys.keydict[
                        Enum.GetName(
                            typeof(Keys), Controls.ActiveControls.ControlMapping[Control.Hotkey1 + mYindex].Key1
                            )
                        .ToLower()]
                    );

                mHotKey = Controls.ActiveControls.ControlMapping[Control.Hotkey1 + mYindex].Key1;
            }

            var slot          = Globals.Me.Hotbar[mYindex];
            var updateDisplay =
                mCurrentId != slot.ItemOrSpellId ||
                mTexLoaded ==
                false; //Update display if the hotbar item changes or we dont have a texture for the current item

            if (mCurrentId != slot.ItemOrSpellId)
            {
                mCurrentItem  = null;
                mCurrentSpell = null;
                var itm = ItemBase.Get(slot.ItemOrSpellId);
                var spl = SpellBase.Get(slot.ItemOrSpellId);
                if (itm != null)
                {
                    mCurrentItem = itm;
                }

                if (spl != null)
                {
                    mCurrentSpell = spl;
                }

                mCurrentId = slot.ItemOrSpellId;
            }

            mSpellBookItem      = null;
            mInventoryItem      = null;
            mInventoryItemIndex = -1;

            if (mCurrentItem != null)
            {
                var itmIndex = Globals.Me.FindHotbarItem(slot);
                if (itmIndex > -1)
                {
                    mInventoryItemIndex = itmIndex;
                    mInventoryItem      = Globals.Me.Inventory[itmIndex];
                }
            }
            else if (mCurrentSpell != null)
            {
                var splIndex = Globals.Me.FindHotbarSpell(slot);
                if (splIndex > -1)
                {
                    mSpellBookItem = Globals.Me.Spells[splIndex];
                }
            }

            if (mCurrentItem != null) //When it's an item
            {
                //We don't have it, and the icon isn't faded
                if (mInventoryItem == null && !mIsFaded)
                {
                    updateDisplay = true;
                }

                //We have it, and the equip icon doesn't match equipped status
                if (mInventoryItem != null && Globals.Me.IsEquipped(mInventoryItemIndex) != mIsEquipped)
                {
                    updateDisplay = true;
                }

                //We have it, and it's on cd
                if (mInventoryItem != null && Globals.Me.ItemOnCd(mInventoryItemIndex))
                {
                    updateDisplay = true;
                }

                //We have it, and it's on cd, and the fade is incorrect
                if (mInventoryItem != null && Globals.Me.ItemOnCd(mInventoryItemIndex) != mIsFaded)
                {
                    updateDisplay = true;
                }
            }

            if (mCurrentSpell != null) //When it's a spell
            {
                //We don't know it, and the icon isn't faded!
                if (mSpellBookItem == null && !mIsFaded)
                {
                    updateDisplay = true;
                }

                //Spell on cd
                if (mSpellBookItem != null &&
                    Globals.Me.GetSpellCooldown(mSpellBookItem.SpellId) > Globals.System.GetTimeMs())
                {
                    updateDisplay = true;
                }

                //Spell on cd and the fade is incorrect
                if (mSpellBookItem != null &&
                    Globals.Me.GetSpellCooldown(mSpellBookItem.SpellId) > Globals.System.GetTimeMs() != mIsFaded)
                {
                    updateDisplay = true;
                }
            }

            if (updateDisplay) //Item on cd and fade is incorrect
            {
                if (mCurrentItem != null)
                {
                    mCooldownLabel.IsHidden = true;
                    mContentPanel.Show();
                    mContentPanel.Texture = Globals.ContentManager.GetTexture(
                        GameContentManager.TextureType.Item, mCurrentItem.Icon
                        );

                    if (mInventoryItemIndex > -1)
                    {
                        EquipPanel.IsHidden = !Globals.Me.IsEquipped(mInventoryItemIndex);
                        EquipLabel.IsHidden = !Globals.Me.IsEquipped(mInventoryItemIndex);
                        mIsFaded            = Globals.Me.ItemOnCd(mInventoryItemIndex);
                        if (mIsFaded)
                        {
                            mCooldownLabel.IsHidden = false;
                            var secondsRemaining = (float)Globals.Me.ItemCdRemainder(mInventoryItemIndex) / 1000f;
                            if (secondsRemaining > 10f)
                            {
                                mCooldownLabel.Text =
                                    Strings.Inventory.cooldown.ToString(secondsRemaining.ToString("N0"));
                            }
                            else
                            {
                                mCooldownLabel.Text = Strings.Inventory.cooldown.ToString(
                                    secondsRemaining.ToString("N1").Replace(".", Strings.Numbers.dec)
                                    );
                            }
                        }

                        mIsEquipped = Globals.Me.IsEquipped(mInventoryItemIndex);
                    }
                    else
                    {
                        EquipPanel.IsHidden = true;
                        EquipLabel.IsHidden = true;
                        mIsEquipped         = false;
                        mIsFaded            = true;
                    }

                    mTexLoaded = true;
                }
                else if (mCurrentSpell != null)
                {
                    mContentPanel.Show();
                    mContentPanel.Texture = Globals.ContentManager.GetTexture(
                        GameContentManager.TextureType.Spell, mCurrentSpell.Icon
                        );

                    EquipPanel.IsHidden     = true;
                    EquipLabel.IsHidden     = true;
                    mCooldownLabel.IsHidden = true;
                    if (mSpellBookItem != null)
                    {
                        mIsFaded = Globals.Me.GetSpellCooldown(mSpellBookItem.SpellId) > Globals.System.GetTimeMs();
                        if (mIsFaded)
                        {
                            mCooldownLabel.IsHidden = false;
                            var secondsRemaining =
                                (float)(Globals.Me.GetSpellCooldown(mSpellBookItem.SpellId) -
                                        Globals.System.GetTimeMs()) /
                                1000f;

                            if (secondsRemaining > 10f)
                            {
                                mCooldownLabel.Text = Strings.Spells.cooldown.ToString(secondsRemaining.ToString("N0"));
                            }
                            else
                            {
                                mCooldownLabel.Text = Strings.Spells.cooldown.ToString(
                                    secondsRemaining.ToString("N1").Replace(".", Strings.Numbers.dec)
                                    );
                            }
                        }
                    }
                    else
                    {
                        mIsFaded = true;
                    }

                    mTexLoaded  = true;
                    mIsEquipped = false;
                }
                else
                {
                    mContentPanel.Hide();
                    mTexLoaded              = true;
                    mIsEquipped             = false;
                    EquipPanel.IsHidden     = true;
                    EquipLabel.IsHidden     = true;
                    mCooldownLabel.IsHidden = true;
                }

                if (mIsFaded)
                {
                    if (mCurrentSpell != null)
                    {
                        mContentPanel.RenderColor = new Color(100, 255, 255, 255);
                    }

                    if (mCurrentItem != null)
                    {
                        mContentPanel.RenderColor = new Color(100, mCurrentItem.Color.R, mCurrentItem.Color.G, mCurrentItem.Color.B);
                    }
                }
                else
                {
                    if (mCurrentSpell != null)
                    {
                        mContentPanel.RenderColor = Color.White;
                    }

                    if (mCurrentItem != null)
                    {
                        mContentPanel.RenderColor = mCurrentItem.Color;
                    }
                }
            }

            if (mCurrentItem != null || mCurrentSpell != null)
            {
                if (!IsDragging)
                {
                    if (mMouseOver)
                    {
                        if (!Globals.InputManager.MouseButtonDown(GameInput.MouseButtons.Left))
                        {
                            mCanDrag = true;
                            mMouseX  = -1;
                            mMouseY  = -1;
                            if (Globals.System.GetTimeMs() < mClickTime)
                            {
                                Activate();
                                mClickTime = 0;
                            }
                        }
                        else
                        {
                            if (mCanDrag && Draggable.Active == null)
                            {
                                if (mMouseX == -1 || mMouseY == -1)
                                {
                                    mMouseX = InputHandler.MousePosition.X - Pnl.LocalPosToCanvas(new Point(0, 0)).X;
                                    mMouseY = InputHandler.MousePosition.Y - Pnl.LocalPosToCanvas(new Point(0, 0)).Y;
                                }
                                else
                                {
                                    var xdiff = mMouseX -
                                                (InputHandler.MousePosition.X -
                                                 Pnl.LocalPosToCanvas(new Point(0, 0)).X);

                                    var ydiff = mMouseY -
                                                (InputHandler.MousePosition.Y -
                                                 Pnl.LocalPosToCanvas(new Point(0, 0)).Y);

                                    if (Math.Sqrt(Math.Pow(xdiff, 2) + Math.Pow(ydiff, 2)) > 5)
                                    {
                                        IsDragging = true;
                                        mDragIcon  = new Draggable(
                                            Pnl.LocalPosToCanvas(new Point(0, 0)).X + mMouseX,
                                            Pnl.LocalPosToCanvas(new Point(0, 0)).X + mMouseY, mContentPanel.Texture
                                            );

                                        //SOMETHING SHOULD BE RENDERED HERE, RIGHT?
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    if (mDragIcon.Update())
                    {
                        mContentPanel.IsHidden = false;

                        //Drug the item and now we stopped
                        IsDragging = false;
                        var dragRect = new FloatRect(
                            mDragIcon.X - sItemXPadding / 2, mDragIcon.Y - sItemYPadding / 2, sItemXPadding / 2 + 32,
                            sItemYPadding / 2 + 32
                            );

                        float bestIntersect      = 0;
                        var   bestIntersectIndex = -1;

                        if (Interface.GameUi.Hotbar.RenderBounds().IntersectsWith(dragRect))
                        {
                            for (var i = 0; i < Options.MaxHotbar; i++)
                            {
                                if (Interface.GameUi.Hotbar.Items[i].RenderBounds().IntersectsWith(dragRect))
                                {
                                    if (FloatRect.Intersect(Interface.GameUi.Hotbar.Items[i].RenderBounds(), dragRect)
                                        .Width *
                                        FloatRect.Intersect(Interface.GameUi.Hotbar.Items[i].RenderBounds(), dragRect)
                                        .Height >
                                        bestIntersect)
                                    {
                                        bestIntersect =
                                            FloatRect.Intersect(
                                                Interface.GameUi.Hotbar.Items[i].RenderBounds(), dragRect
                                                )
                                            .Width *
                                            FloatRect.Intersect(
                                                Interface.GameUi.Hotbar.Items[i].RenderBounds(), dragRect
                                                )
                                            .Height;

                                        bestIntersectIndex = i;
                                    }
                                }
                            }

                            if (bestIntersectIndex > -1 && bestIntersectIndex != mYindex)
                            {
                                Globals.Me.HotbarSwap(mYindex, (byte)bestIntersectIndex);
                            }
                        }

                        mDragIcon.Dispose();
                    }
                    else
                    {
                        mContentPanel.IsHidden = true;
                    }
                }
            }
        }
        //Update
        public void Update()
        {
            if (mEventDialogWindow.IsHidden)
            {
                Interface.InputBlockingElements.Remove(this);
            }
            else
            {
                if (!Interface.InputBlockingElements.Contains(this))
                {
                    Interface.InputBlockingElements.Add(this);
                }
            }

            if (Globals.EventDialogs.Count > 0)
            {
                if (mEventDialogWindow.IsHidden)
                {
                    base.Show();
                    mEventDialogWindow.Show();
                    mEventDialogWindow.MakeModal();
                    mEventDialogArea.ScrollToTop();
                    mEventDialogWindow.BringToFront();
                    var faceTex = Globals.ContentManager.GetTexture(
                        GameContentManager.TextureType.Face, Globals.EventDialogs[0].Face
                        );

                    var responseCount = 0;
                    var maxResponse   = 1;
                    if (Globals.EventDialogs[0].Opt1.Length > 0)
                    {
                        responseCount++;
                    }

                    if (Globals.EventDialogs[0].Opt2.Length > 0)
                    {
                        responseCount++;
                        maxResponse = 2;
                    }

                    if (Globals.EventDialogs[0].Opt3.Length > 0)
                    {
                        responseCount++;
                        maxResponse = 3;
                    }

                    if (Globals.EventDialogs[0].Opt4.Length > 0)
                    {
                        responseCount++;
                        maxResponse = 4;
                    }

                    mEventResponse1.Name = "";
                    mEventResponse2.Name = "";
                    mEventResponse3.Name = "";
                    mEventResponse4.Name = "";
                    switch (maxResponse)
                    {
                    case 1:
                        mEventDialogWindow.Name = "EventDialogWindow_1Response";
                        mEventResponse1.Name    = "Response1Button";

                        break;

                    case 2:
                        mEventDialogWindow.Name = "EventDialogWindow_2Responses";
                        mEventResponse1.Name    = "Response1Button";
                        mEventResponse2.Name    = "Response2Button";

                        break;

                    case 3:
                        mEventDialogWindow.Name = "EventDialogWindow_3Responses";
                        mEventResponse1.Name    = "Response1Button";
                        mEventResponse2.Name    = "Response2Button";
                        mEventResponse3.Name    = "Response3Button";

                        break;

                    case 4:
                        mEventDialogWindow.Name = "EventDialogWindow_4Responses";
                        mEventResponse1.Name    = "Response1Button";
                        mEventResponse2.Name    = "Response2Button";
                        mEventResponse3.Name    = "Response3Button";
                        mEventResponse4.Name    = "Response4Button";

                        break;
                    }

                    mEventDialogWindow.LoadJsonUi(
                        GameContentManager.UI.InGame, Graphics.Renderer.GetResolutionString()
                        );

                    if (faceTex != null)
                    {
                        mEventFace.Show();
                        mEventFace.Texture = faceTex;
                        mEventDialogArea.Show();
                        mEventDialogAreaNoFace.Hide();
                    }
                    else
                    {
                        mEventFace.Hide();
                        mEventDialogArea.Hide();
                        mEventDialogAreaNoFace.Show();
                    }

                    if (responseCount == 0)
                    {
                        mEventResponse1.Show();
                        mEventResponse1.SetText(Strings.EventWindow.Continue);
                        mEventResponse2.Hide();
                        mEventResponse3.Hide();
                        mEventResponse4.Hide();
                    }
                    else
                    {
                        if (Globals.EventDialogs[0].Opt1 != "")
                        {
                            mEventResponse1.Show();
                            mEventResponse1.SetText(Globals.EventDialogs[0].Opt1);
                        }
                        else
                        {
                            mEventResponse1.Hide();
                        }

                        if (Globals.EventDialogs[0].Opt2 != "")
                        {
                            mEventResponse2.Show();
                            mEventResponse2.SetText(Globals.EventDialogs[0].Opt2);
                        }
                        else
                        {
                            mEventResponse2.Hide();
                        }

                        if (Globals.EventDialogs[0].Opt3 != "")
                        {
                            mEventResponse3.Show();
                            mEventResponse3.SetText(Globals.EventDialogs[0].Opt3);
                        }
                        else
                        {
                            mEventResponse3.Hide();
                        }

                        if (Globals.EventDialogs[0].Opt4 != "")
                        {
                            mEventResponse4.Show();
                            mEventResponse4.SetText(Globals.EventDialogs[0].Opt4);
                        }
                        else
                        {
                            mEventResponse4.Hide();
                        }
                    }

                    mEventDialogWindow.SetSize(
                        mEventDialogWindow.Texture.GetWidth(), mEventDialogWindow.Texture.GetHeight()
                        );

                    if (faceTex != null)
                    {
                        mEventDialogLabel.ClearText();
                        mEventDialogLabel.Width = mEventDialogArea.Width -
                                                  mEventDialogArea.GetVerticalScrollBar().Width;

                        mEventDialogLabel.AddText(
                            Globals.EventDialogs[0].Prompt, mEventDialogLabelTemplate.TextColor,
                            mEventDialogLabelTemplate.CurAlignments.Count > 0
                                ? mEventDialogLabelTemplate.CurAlignments[0]
                                : Alignments.Left, mEventDialogLabelTemplate.Font
                            );

                        mEventDialogLabel.SizeToChildren(false, true);
                        mEventDialogArea.ScrollToTop();
                    }
                    else
                    {
                        mEventDialogLabelNoFace.ClearText();
                        mEventDialogLabelNoFace.Width = mEventDialogAreaNoFace.Width -
                                                        mEventDialogAreaNoFace.GetVerticalScrollBar().Width;

                        mEventDialogLabelNoFace.AddText(
                            Globals.EventDialogs[0].Prompt, mEventDialogLabelNoFaceTemplate.TextColor,
                            mEventDialogLabelNoFaceTemplate.CurAlignments.Count > 0
                                ? mEventDialogLabelNoFaceTemplate.CurAlignments[0]
                                : Alignments.Left, mEventDialogLabelNoFaceTemplate.Font
                            );

                        mEventDialogLabelNoFace.SizeToChildren(false, true);
                        mEventDialogAreaNoFace.ScrollToTop();
                    }
                }
            }
        }
示例#8
0
        public void SetupEntityElements()
        {
            ShowAllElements();

            //Update Bars
            CurHpWidth     = -1;
            CurShieldWidth = -1;
            CurMpWidth     = -1;
            CurExpWidth    = -1;
            ShieldBar.Hide();
            UpdateHpBar(0, true);
            UpdateMpBar(0, true);
            if (MyEntity is Player)
            {
                UpdateXpBar(0, true);
            }

            switch (EntityType)
            {
            case EntityTypes.Player:
                if (Globals.Me != null && Globals.Me == MyEntity)
                {
                    TradeLabel.Hide();
                    PartyLabel.Hide();
                    FriendLabel.Hide();
                    GuildLabel.Hide();

                    if (!PlayerBox)
                    {
                        ExpBackground.Hide();
                        ExpBar.Hide();
                        ExpLbl.Hide();
                        ExpTitle.Hide();
                        EntityMap.Hide();
                    }
                }
                else
                {
                    ExpBackground.Hide();
                    ExpBar.Hide();
                    ExpLbl.Hide();
                    ExpTitle.Hide();
                    EntityMap.Hide();
                }

                EventDesc.Hide();

                break;

            case EntityTypes.GlobalEntity:
                EventDesc.Hide();
                ExpBackground.Hide();
                ExpBar.Hide();
                ExpLbl.Hide();
                ExpTitle.Hide();
                TradeLabel.Hide();
                PartyLabel.Hide();
                GuildLabel.Hide();
                FriendLabel.Hide();
                EntityMap.Hide();

                break;

            case EntityTypes.Event:
                EventDesc.Show();
                ExpBackground.Hide();
                ExpBar.Hide();
                ExpLbl.Hide();
                ExpTitle.Hide();
                MpBackground.Hide();
                MpBar.Hide();
                MpTitle.Hide();
                MpLbl.Hide();
                HpBackground.Hide();
                HpBar.Hide();
                HpLbl.Hide();
                HpTitle.Hide();
                TradeLabel.Hide();
                PartyLabel.Hide();
                FriendLabel.Hide();
                GuildLabel.Hide();
                EntityMap.Hide();

                break;
            }

            EntityName.SetText(MyEntity.Name);
            ShieldBar.Hide();
        }
示例#9
0
        //Methods
        public void Update()
        {
            if (mPartyWindow.IsHidden)
            {
                return;
            }

            mLeader.Hide();
            mLeaderText.Hide();
            mLeaveButton.Hide();
            for (var i = 0; i < 4; i++)
            {
                mHpBarContainer[i].Hide();
                mHpLabel[i].Hide();
                mHpValue[i].Hide();
                mLblnames[i].Text = "";
                mMpBarContainer[i].Hide();
                mMpLabel[i].Hide();
                mMpValue[i].Hide();
                if (i > 0)
                {
                    mKickButtons[i].Hide();
                }
            }

            if (Globals.Me.IsInParty())
            {
                mLeader.Show();
                mLeaderText.Show();
                mLeaveButton.Show();

                for (var i = 0; i < 4; i++)
                {
                    if (i < Globals.Me.Party.Count)
                    {
                        mHpLabel[i].Show();
                        mHpValue[i].Show();
                        mHpBarContainer[i].Show();

                        mMpLabel[i].Show();
                        mMpValue[i].Show();
                        mMpBarContainer[i].Show();

                        mLblnames[i].Text = Strings.Parties.name.ToString(
                            Globals.Me.Party[i].Name, Globals.Me.Party[i].Level
                            );

                        if (mHpBar[i].Texture != null)
                        {
                            var vitalHp    = Globals.Me.Party[i].Vital[(int)Vitals.Health];
                            var vitalMaxHp = Globals.Me.Party[i].MaxVital[(int)Vitals.Health];
                            var ratioHp    = (float)vitalHp / (float)vitalMaxHp;
                            ratioHp = Math.Min(1, Math.Max(0, ratioHp));
                            mHpBar[i]
                            .SetTextureRect(
                                0, 0, Convert.ToInt32(mHpBar[i].Texture.GetWidth() * ratioHp),
                                mHpBar[i].Texture.GetHeight()
                                );

                            mHpBar[i]
                            .SetSize(
                                Convert.ToInt32(ratioHp * mHpBarContainer[i].Width), mHpBarContainer[i].Height
                                );
                        }

                        mHpValue[i].Text = Strings.Parties.vital0val.ToString(
                            Globals.Me.Party[i].Vital[(int)Vitals.Health],
                            Globals.Me.Party[i].MaxVital[(int)Vitals.Health]
                            );

                        if (mMpBar[i].Texture != null)
                        {
                            var vitalMp    = Globals.Me.Party[i].Vital[(int)Vitals.Mana];
                            var vitalMaxMp = Globals.Me.Party[i].MaxVital[(int)Vitals.Mana];
                            var ratioMp    = (float)vitalMp / (float)vitalMaxMp;
                            ratioMp = Math.Min(1, Math.Max(0, ratioMp));
                            mMpBar[i]
                            .SetTextureRect(
                                0, 0, Convert.ToInt32(mMpBar[i].Texture.GetWidth() * ratioMp),
                                mMpBar[i].Texture.GetHeight()
                                );

                            mMpBar[i]
                            .SetSize(
                                Convert.ToInt32(ratioMp * mMpBarContainer[i].Width), mMpBarContainer[i].Height
                                );
                        }

                        mMpValue[i].Text = Strings.Parties.vital1val.ToString(
                            Globals.Me.Party[i].Vital[(int)Vitals.Mana],
                            Globals.Me.Party[i].MaxVital[(int)Vitals.Mana]
                            );

                        if (i > 0)
                        {
                            mKickButtons[i].Hide();
                        }

                        //Only show the kick buttons if its you or you are the party leader
                        if (Globals.Me.Party[0].Id == Globals.Me.Id && i > 0)
                        {
                            mKickButtons[i].Show();
                            mKickButtons[i].SetToolTipText(Strings.Parties.kick.ToString(Globals.Me.Party[i].Name));
                        }
                    }
                    else
                    {
                        if (i > 0)
                        {
                            mKickButtons[i].SetToolTipText("");
                        }

                        mLblnames[i].Text = "";
                        mHpBar[i].SetSize(0, mHpBarContainer[i].Height);
                        mHpBarContainer[i].Hide();
                    }
                }
            }
        }
示例#10
0
        //Init
        public EntityBox(Canvas gameCanvas, EntityTypes entityType, Entity myEntity, bool playerBox = false)
        {
            MyEntity     = myEntity;
            EntityType   = entityType;
            PlayerBox    = playerBox;
            EntityWindow =
                playerBox ? new ImagePanel(gameCanvas, "PlayerBox") : new ImagePanel(gameCanvas, "TargetBox");

            EntityWindow.ShouldCacheToTexture = true;

            EntityInfoPanel = new ImagePanel(EntityWindow, "EntityInfoPanel");

            EntityName = new Framework.Gwen.Control.Label(EntityInfoPanel, "EntityNameLabel")
            {
                Text = myEntity?.Name
            };
            EntityLevel        = new Framework.Gwen.Control.Label(EntityInfoPanel, "EntityLevelLabel");
            EntityNameAndLevel = new Framework.Gwen.Control.Label(EntityInfoPanel, "NameAndLevelLabel")
            {
                IsHidden = true
            };

            EntityMap = new Framework.Gwen.Control.Label(EntityInfoPanel, "EntityMapLabel");

            PaperdollPanels   = new ImagePanel[Options.EquipmentSlots.Count];
            PaperdollTextures = new string[Options.EquipmentSlots.Count];
            var i = 0;

            for (var z = 0; z < Options.PaperdollOrder[1].Count; z++)
            {
                if (Options.PaperdollOrder[1][z] == "Player")
                {
                    EntityFaceContainer = new ImagePanel(EntityInfoPanel, "EntityGraphicContainer");

                    EntityFace = new ImagePanel(EntityFaceContainer);
                    EntityFace.SetSize(64, 64);
                    EntityFace.AddAlignment(Alignments.Center);
                }
                else
                {
                    PaperdollPanels[i]   = new ImagePanel(EntityFaceContainer);
                    PaperdollTextures[i] = "";
                    PaperdollPanels[i].Hide();
                    i++;
                }
            }

            EventDesc = new RichLabel(EntityInfoPanel, "EventDescLabel");

            HpBackground = new ImagePanel(EntityInfoPanel, "HPBarBackground");
            HpBar        = new ImagePanel(EntityInfoPanel, "HPBar");
            ShieldBar    = new ImagePanel(EntityInfoPanel, "ShieldBar");
            HpTitle      = new Framework.Gwen.Control.Label(EntityInfoPanel, "HPTitle");
            HpTitle.SetText(Strings.EntityBox.vital0);
            HpLbl = new Framework.Gwen.Control.Label(EntityInfoPanel, "HPLabel");

            MpBackground = new ImagePanel(EntityInfoPanel, "MPBackground");
            MpBar        = new ImagePanel(EntityInfoPanel, "MPBar");
            MpTitle      = new Framework.Gwen.Control.Label(EntityInfoPanel, "MPTitle");
            MpTitle.SetText(Strings.EntityBox.vital1);
            MpLbl = new Framework.Gwen.Control.Label(EntityInfoPanel, "MPLabel");

            ExpBackground = new ImagePanel(EntityInfoPanel, "EXPBackground");
            ExpBar        = new ImagePanel(EntityInfoPanel, "EXPBar");
            ExpTitle      = new Framework.Gwen.Control.Label(EntityInfoPanel, "EXPTitle");
            ExpTitle.SetText(Strings.EntityBox.exp);
            ExpLbl = new Framework.Gwen.Control.Label(EntityInfoPanel, "EXPLabel");

            TradeLabel = new Button(EntityInfoPanel, "TradeButton");
            TradeLabel.SetText(Strings.EntityBox.trade);
            TradeLabel.SetToolTipText(Strings.EntityBox.tradetip.ToString(MyEntity.Name));
            TradeLabel.Clicked += tradeRequest_Clicked;

            PartyLabel = new Button(EntityInfoPanel, "PartyButton");
            PartyLabel.SetText(Strings.EntityBox.party);
            PartyLabel.SetToolTipText(Strings.EntityBox.partytip.ToString(MyEntity.Name));
            PartyLabel.Clicked += invite_Clicked;

            FriendLabel = new Button(EntityInfoPanel, "FriendButton");
            FriendLabel.SetText(Strings.EntityBox.friend);
            FriendLabel.SetToolTipText(Strings.EntityBox.friendtip.ToString(MyEntity.Name));
            FriendLabel.Clicked += friendRequest_Clicked;
            FriendLabel.IsHidden = true;

            EntityStatusPanel = new ImagePanel(EntityWindow, "StatusArea");

            SetEntity(myEntity);

            EntityWindow.LoadJsonUi(GameContentManager.UI.InGame, Graphics.Renderer.GetResolutionString());

            UpdateSpellStatus();

            i = 0;
            for (var z = 0; z < Options.PaperdollOrder[1].Count; z++)
            {
                if (Options.PaperdollOrder[1][z] == "Player")
                {
                    EntityFace.RenderColor = EntityFaceContainer.RenderColor;
                }
                else
                {
                    PaperdollPanels[i].RenderColor = EntityFaceContainer.RenderColor;
                    i++;
                }
            }

            EntityWindow.Hide();

            mLastUpdateTime = Globals.System.GetTimeMs();
        }
 public void Hide()
 {
     mCharacterSelectionPanel.Hide();
 }
示例#12
0
        private void _myWindow_BeforeDraw(Base sender, EventArgs arguments)
        {
            if (!mInitialized)
            {
                mMyWindow.LoadJsonUi(_uiStage, Graphics.Renderer.GetResolutionString(), true);
                var text = Interface.WrapText(mPrompt, mPromptLabel.Width, mPromptLabel.Font);
                var y    = mPromptLabel.Y;
                foreach (var s in text)
                {
                    var label = new Label(mMyWindow)
                    {
                        Text = s,
                        TextColorOverride = mPromptLabel.TextColor,
                        Font = mPromptLabel.Font
                    };

                    label.SetPosition(mPromptLabel.X, y);
                    y += label.Height;
                    Align.CenterHorizontally(label);
                }

                switch (mInputType)
                {
                case InputType.YesNo:
                    mYesButton.Text = Strings.InputBox.yes;
                    mNoButton.Text  = Strings.InputBox.no;
                    mOkayButton.Hide();
                    mYesButton.Show();
                    mNoButton.Show();
                    mNumericTextboxBg.Hide();
                    mTextboxBg.Hide();

                    break;

                case InputType.OkayOnly:
                    mOkayButton.Show();
                    mYesButton.Hide();
                    mNoButton.Hide();
                    mNumericTextboxBg.Hide();
                    mTextboxBg.Hide();

                    break;

                case InputType.NumericInput:
                    mOkayButton.Hide();
                    mYesButton.Show();
                    mNoButton.Show();
                    mNumericTextboxBg.Show();
                    mTextboxBg.Hide();

                    break;

                case InputType.TextInput:
                    mOkayButton.Hide();
                    mYesButton.Show();
                    mNoButton.Show();
                    mNumericTextboxBg.Hide();
                    mTextboxBg.Show();

                    break;
                }

                mMyWindow.Show();
                mMyWindow.Focus();
                mInitialized = true;
            }
        }
        public void Update()
        {
            if (mStatus != null)
            {
                var remaining        = mStatus.RemainingMs();
                var spell            = SpellBase.Get(mStatus.SpellId);
                var secondsRemaining = (float)remaining / 1000f;
                if (secondsRemaining > 10f)
                {
                    mDurationLabel.Text =
                        Strings.EntityBox.cooldown.ToString(((float)remaining / 1000f).ToString("N0"));
                }
                else
                {
                    mDurationLabel.Text = Strings.EntityBox.cooldown.ToString(
                        ((float)remaining / 1000f).ToString("N1").Replace(".", Strings.Numbers.dec)
                        );
                }

                if ((mTexLoaded != "" && spell == null ||
                     spell != null && mTexLoaded != spell.Icon ||
                     mCurrentSpellId != mStatus.SpellId) &&
                    remaining > 0)
                {
                    Container.Show();
                    if (spell != null)
                    {
                        var spellTex = Globals.ContentManager.GetTexture(
                            GameContentManager.TextureType.Spell, spell.Icon
                            );

                        if (spellTex != null)
                        {
                            Pnl.Texture  = spellTex;
                            Pnl.IsHidden = false;
                        }
                        else
                        {
                            if (Pnl.Texture != null)
                            {
                                Pnl.Texture = null;
                            }
                        }

                        mTexLoaded      = spell.Icon;
                        mCurrentSpellId = mStatus.SpellId;
                    }
                    else
                    {
                        if (Pnl.Texture != null)
                        {
                            Pnl.Texture = null;
                        }

                        mTexLoaded = "";
                    }
                }
                else if (remaining <= 0)
                {
                    if (Pnl.Texture != null)
                    {
                        Pnl.Texture = null;
                    }

                    Container.Hide();
                    mTexLoaded = "";
                }
            }
        }
 public void Hide()
 {
     mRegistrationPanel.Hide();
 }
示例#15
0
        //Update
        public void Update()
        {
            if (MyEntity == null || MyEntity.IsDisposed())
            {
                if (!EntityWindow.IsHidden)
                {
                    EntityWindow.Hide();
                }

                return;
            }
            else
            {
                if (EntityWindow.IsHidden)
                {
                    EntityWindow.Show();
                }
            }

            if (PlayerBox)
            {
                if (EntityWindow.IsHidden)
                {
                    EntityWindow.Show();
                }

                if (MyEntity.IsDisposed())
                {
                    Dispose();
                }
            }

            UpdateSpellStatus();

            //Time since this window was last updated (for bar animations)
            var elapsedTime = (Globals.System.GetTimeMs() - mLastUpdateTime) / 1000.0f;

            //Update the event/entity face.
            UpdateImage();

            IsHidden = true;
            if (EntityType != EntityTypes.Event)
            {
                EntityName.SetText(MyEntity.Name);
                UpdateLevel();
                UpdateMap();
                UpdateHpBar(elapsedTime);
                UpdateMpBar(elapsedTime);
                IsHidden = false;
            }
            else
            {
                if (!EntityNameAndLevel.IsHidden)
                {
                    EntityNameAndLevel.Text = MyEntity.Name;
                }
            }

            //If player draw exp bar
            if (PlayerBox && MyEntity == Globals.Me)
            {
                UpdateXpBar(elapsedTime);
            }

            if (MyEntity.GetEntityType() == EntityTypes.Player && MyEntity != Globals.Me)
            {
                if (MyEntity.Vital[(int)Vitals.Health] <= 0)
                {
                    TradeLabel.Hide();
                    PartyLabel.Hide();
                    FriendLabel.Hide();
                    GuildLabel.Hide();
                }
                else if (TradeLabel.IsHidden || PartyLabel.IsHidden || FriendLabel.IsHidden)
                {
                    TradeLabel.Show();
                    PartyLabel.Show();
                    FriendLabel.Show();
                    TryShowGuildButton();
                }
            }

            if (UpdateStatuses)
            {
                UpdateSpellStatus();
                UpdateStatuses = false;
            }

            foreach (var itm in mActiveStatuses)
            {
                itm.Value.Update();
            }

            mLastUpdateTime = Globals.System.GetTimeMs();
        }
 public void Hide()
 {
     mCharCreationPanel.Hide();
 }
 /// <summary>
 /// Hides the control.
 /// </summary>
 public void Hide()
 {
     mPicture.Hide();
 }
示例#18
0
        public void SetupEntityElements()
        {
            switch (EntityType)
            {
            case EntityTypes.Player:
                if (Globals.Me != null && Globals.Me == MyEntity)
                {
                    TradeLabel.Hide();
                    PartyLabel.Hide();
                    FriendLabel.Hide();
                }
                else
                {
                    ExpBackground.Hide();
                    ExpBar.Hide();
                    ExpLbl.Hide();
                    ExpTitle.Hide();
                    EntityMap.Hide();
                }

                EventDesc.Hide();

                break;

            case EntityTypes.GlobalEntity:
                EventDesc.Hide();
                ExpBackground.Hide();
                ExpBar.Hide();
                ExpLbl.Hide();
                ExpTitle.Hide();
                TradeLabel.Hide();
                PartyLabel.Hide();
                FriendLabel.Hide();
                EntityMap.Hide();

                break;

            case EntityTypes.Event:
                ExpBackground.Hide();
                ExpBar.Hide();
                ExpLbl.Hide();
                ExpTitle.Hide();
                MpBackground.Hide();
                MpBar.Hide();
                MpTitle.Hide();
                MpLbl.Hide();
                HpBackground.Hide();
                HpBar.Hide();
                HpLbl.Hide();
                HpTitle.Hide();
                TradeLabel.Hide();
                PartyLabel.Hide();
                FriendLabel.Hide();
                EntityMap.Hide();

                break;
            }

            EntityName.SetText(MyEntity.Name);
            ShieldBar.Hide();
        }
示例#19
0
        //Init
        public PartyWindow(Canvas gameCanvas)
        {
            mPartyWindow = new WindowControl(gameCanvas, Strings.Parties.title, false, "PartyWindow");
            mPartyWindow.DisableResizing();

            //Add the icon representing party leader (ALWAYS member 1 in the party list)
            mLeader = new ImagePanel(mPartyWindow, "LeaderIcon");
            mLeader.SetToolTipText(Strings.Parties.leadertip);
            mLeader.Hide();

            mLeaderText = new Label(mPartyWindow, "LeaderText");
            mLeaderText.SetTextColor(new Color(0, 0, 0, 0), Label.ControlState.Normal);
            mLeaderText.Text = Strings.Parties.leader;
            mLeaderText.Hide();

            if (Globals.Me.Party.Count > 0)
            {
                mLeader.Show();
                mLeaderText.Show();
            }

            mLblnames.Clear();
            mKickButtons.Clear();
            mHpBarContainer.Clear();
            mHpBar.Clear();

            for (var i = 0; i < 4; i++)
            {
                //Labels
                mLblnames.Add(new Label(mPartyWindow, "MemberName" + i));
                if (i < Globals.Me.Party.Count)
                {
                    mLblnames[i].Text = Strings.Parties.name.ToString(
                        Globals.Me.Party[i].Name, Globals.Me.Party[i].Level
                        );
                }
                else
                {
                    mLblnames[i].Text = "";
                }

                //Health bars
                mHpBarContainer.Add(new ImagePanel(mPartyWindow, "HealthBarContainer" + i));
                mHpBarContainer[i].Hide();
                mHpLabel.Add(new Label(mPartyWindow, "HealthLabel" + i));
                mHpLabel[i].Hide();
                mHpLabel[i].SetTextColor(new Color(0, 0, 0, 0), Label.ControlState.Normal);
                mHpLabel[i].Text = Strings.Parties.vital0;
                mHpValue.Add(new Label(mPartyWindow, "HealthValue" + i));
                mHpValue[i].Hide();
                mHpValue[i].SetTextColor(new Color(0, 0, 0, 0), Label.ControlState.Normal);
                if (i < Globals.Me.Party.Count)
                {
                    mHpBarContainer[i].Show();
                }

                mHpBar.Add(new ImagePanel(mHpBarContainer[i], "HealthBar" + i));

                //Mana bars
                mMpBarContainer.Add(new ImagePanel(mPartyWindow, "ManaBarContainer" + i));
                mMpBarContainer[i].Hide();
                mMpBarContainer[i].RenderColor = new Color(0, 0, 0, 0);
                mMpLabel.Add(new Label(mPartyWindow, "ManaLabel" + i));
                mMpLabel[i].Hide();
                mMpLabel[i].SetTextColor(new Color(0, 0, 0, 0), Label.ControlState.Normal);
                mMpLabel[i].Text = Strings.Parties.vital1;
                mMpValue.Add(new Label(mPartyWindow, "ManaValue" + i));
                mMpValue[i].Hide();
                mMpValue[i].SetTextColor(new Color(0, 0, 0, 0), Label.ControlState.Normal);
                mMpBar.Add(new ImagePanel(mMpBarContainer[i], "ManaBar" + i));
                mMpBar[i].RenderColor = new Color(0, 0, 0, 0);

                if (i == 0)
                {
                    mKickButtons.Add(null);
                }
                else
                {
                    mKickButtons.Add(new Button(mPartyWindow, "KickButton" + i));
                    mKickButtons[i].Clicked += kick_Clicked;
                    mKickButtons[i].Text     = Strings.Parties.kicklbl;
                    if (i < Globals.Me.Party.Count)
                    {
                        mKickButtons[i]
                        .SetToolTipText(
                            Strings.Parties.kick.ToString(Globals.Entities[Globals.Me.Party[i].Id].Name)
                            );
                    }
                    else
                    {
                        mKickButtons[i].SetToolTipText("");
                    }

                    mKickButtons[i].Hide();

                    //Only show the kick buttons if its you or you are the party leader
                    if (i < Globals.Me.Party.Count)
                    {
                        if (Globals.Me.Party[0].Id == Globals.Me.Id)
                        {
                            mKickButtons[i].Show();
                        }
                    }
                }
            }

            mLeaveButton      = new Button(mPartyWindow, "LeavePartyButton");
            mLeaveButton.Text = Strings.Parties.leave;
            mLeaveButton.SetToolTipText(Strings.Parties.leavetip);
            mLeaveButton.Clicked += leave_Clicked;

            mPartyWindow.LoadJsonUi(GameContentManager.UI.InGame, Graphics.Renderer.GetResolutionString());
        }
示例#20
0
        //Update
        public void Update()
        {
            if (MyEntity == null)
            {
                if (!EntityWindow.IsHidden)
                {
                    EntityWindow.Hide();
                }

                return;
            }

            if (EntityWindow.IsHidden)
            {
                EntityWindow.Show();
            }

            if (MyEntity.IsDisposed())
            {
                Dispose();
            }

            if (!mInitialized)
            {
                SetupEntityElements();
                UpdateSpellStatus();
                if (EntityType == EntityTypes.Event)
                {
                    EventDesc.AddText(((Event)MyEntity).Desc, Color.White);
                    EventDesc.SizeToChildren(false, true);
                }

                mInitialized = true;
            }

            //Time since this window was last updated (for bar animations)
            var elapsedTime = (Globals.System.GetTimeMs() - mLastUpdateTime) / 1000.0f;

            //Update the event/entity face.
            UpdateImage();

            IsHidden = true;
            if (EntityType != EntityTypes.Event)
            {
                UpdateLevel();
                UpdateMap();
                UpdateHpBar(elapsedTime);
                UpdateMpBar(elapsedTime);
                IsHidden = false;
            }
            else
            {
                if (!EntityNameAndLevel.IsHidden)
                {
                    EntityNameAndLevel.Text = MyEntity.Name;
                }
            }

            //If player draw exp bar
            if (MyEntity == Globals.Me)
            {
                UpdateXpBar(elapsedTime);
            }

            if (UpdateStatuses)
            {
                UpdateSpellStatus();
                UpdateStatuses = false;
            }

            foreach (var itm in mActiveStatuses)
            {
                itm.Value.Update();
            }

            mLastUpdateTime = Globals.System.GetTimeMs();
        }