예제 #1
0
 /// <summary>
 /// Expands the toolbar
 /// </summary>
 public void Expand()
 {
     visible     = true;
     expanded    = true;
     fullyHidden = false;
     if (Buttons.ContainsKey("Expand"))
     {
         ((PictureButton)Buttons["Expand"]).Picture = ResourceManager.Skins["Control"].SubSkins["Control.Expand"];
     }
 }
예제 #2
0
 public Button GetButton(string name)
 {
     if (Buttons.ContainsKey(name))
     {
         return(Buttons[name]);
     }
     else
     {
         return(null);
     }
 }
예제 #3
0
 /// <summary>
 /// Contracts the toolbar
 /// </summary>
 public void Contract()
 {
     expanded = false;
     visible  = false;
     if (Buttons.ContainsKey("Expand"))
     {
         ((PictureButton)Buttons["Expand"]).Picture = ResourceManager.Skins["Control"].SubSkins["Control.Contract"];
     }
     foreach (ExpanderToolbar child in this.Children.Values)
     {
         child.Contract();
     }
 }
예제 #4
0
        protected void AddButton(GumpButton entry, Action <GumpButton> handler)
        {
            if (entry == null || !CanDisplay(entry))
            {
                return;
            }

            if (!Buttons.ContainsKey(entry))
            {
                Buttons.Add(entry, handler);
            }
            else
            {
                Buttons[entry] = handler;
            }

            Add(entry);
        }
예제 #5
0
 /// <summary>
 /// Adds a child toolbar
 /// </summary>
 /// <param name="name">Name of the child toolbar</param>
 /// <param name="child">The ExpanderToolbar instance to set as child</param>
 public void AddChild(string name, ExpanderToolbar child)
 {
     Children.Add(name, child);
     child.CreateGui(ParentPanel.GUI);
     if (Buttons.ContainsKey(name))
     {
         Buttons[name].Click += (object sender, EventArgs e) =>
         {
             if (child.visible)
             {
                 child.Hide();
             }
             else
             {
                 child.Show();
             }
         };
     }
 }
        private void PublishResponseMethodInvocation(XElement publishElement)
        {
            string childID = string.Empty;

            if (publishElement.Attribute(Common.IDAttrib) != null)
            {
                childID = publishElement.Attribute(Common.IDAttrib).Value;
            }

            if (FixedContext != null)
            {
                if (childID.StartsWith(FixedContext) && childID != FixedContext)
                {
                    childID = childID.Remove(0, FixedContext.Length + 1);
                }
            }

            if (Buttons.ContainsKey(childID))
            {
                IMethodCaller c = Buttons[childID];

                if (publishElement.Attribute(Common.State) != null)
                {
                    string state = publishElement.Attribute(Common.State).Value;

                    if (state == Common.PublishFieldDisabled)
                    {
                        c.SetDisabled(true);
                    }
                    else if (state == Common.PublishFieldHidden)
                    {
                        c.SetVisible(false);
                    }
                    else
                    {
                        c.SetVisible(true);
                        c.SetDisabled(false);
                    }
                }
            }
        }
예제 #7
0
        public async Task SendMouseClick(string button, ClickDirection direction = ClickDirection.PressAndRelease, Duration duration = null)
        {
            if (string.IsNullOrEmpty(button))
            {
                return;
            }

            if (duration == null)
            {
                duration = AverageClickDuration;
            }

            button = button.ToLowerInvariant();

            if (!Buttons.ContainsKey(button))
            {
                return;
            }

            var buttonValue = Buttons[button];

            switch (direction)
            {
            case ClickDirection.Press:
                SendButtonPress(buttonValue);
                break;

            case ClickDirection.Release:
                SendButtonRelease(buttonValue);
                break;

            case ClickDirection.PressAndRelease:
            default:
                SendButtonPress(buttonValue);
                await Util.Hesitate(duration);

                SendButtonRelease(buttonValue);
                break;
            }
        }
예제 #8
0
 public Button this[HexagonNode hexagonNode] => Buttons.ContainsKey(hexagonNode) ? Buttons[hexagonNode] : null;
예제 #9
0
파일: CombatMenu.cs 프로젝트: teamstor/aod
        /// <summary>
        /// Draws the menu text on top of the menu background.
        /// </summary>
        /// <param name="batch">The sprite batch to draw with.</param>
        /// <param name="menuRectangle">The rectangle the background was drawn in.</param>
        public void Draw(SpriteBatch batch, Rectangle menuRectangle, CombatState state)
        {
            Font font = state.Assets.Get <Font>("fonts/bitcell.ttf");

            if (Page == CombatMenuPage.Stats)
            {
                batch.Rectangle(new Rectangle(0, 0, 480, 270 - menuRectangle.Height), Color.Black * 0.6f);

                DrawTextMultiline(batch, font, state.Combatant.StatsInfoString, new Vector2(10, 4), Color.White * 0.8f, false);
                DrawTextMultiline(batch, font, state.Enemy.StatsInfoString, new Vector2(480 - 10, 4), Color.White * 0.8f, true);
            }

            if (Buttons.ContainsKey(Page))
            {
                int x = 20;
                int y = 34;

                batch.Text(font, 16, state.Combatant.Name, new Vector2(menuRectangle.X + 20, menuRectangle.Y + 14), Color.White);

                for (int i = 0; i < Buttons[Page].Count; i++)
                {
                    string  s       = Buttons[Page][i];
                    Vector2 measure = font.Measure(16, s);

                    if (menuRectangle.X + x + measure.X >= 480 - 12)
                    {
                        x  = 10;
                        y += 16 + 2;
                    }

                    if (SelectedButton == i)
                    {
                        batch.Texture(new Vector2(menuRectangle.X + x - 8, menuRectangle.Y + y), state.Assets.Get <Texture2D>("ui/arrow.png"), Color.White);
                    }
                    batch.Text(font, 16, s, new Vector2(menuRectangle.X + x, menuRectangle.Y + y - 8), Color.White * (SelectedButton == i ? 0.8f : 0.6f));

                    x += (int)measure.X + 20;
                }

                string action = "";

                if (Page == CombatMenuPage.ActionSelection)
                {
                    if (Buttons[Page][SelectedButton] == "Attack")
                    {
                        action = "Attacks \"" + state.Enemy.Name + "\" with your equipped weapon";
                    }
                    if (Buttons[Page][SelectedButton] == "Magic")
                    {
                        action = "Choose a magic attack to use on \"" + state.Enemy.Name + "\"";
                    }
                    if (Buttons[Page][SelectedButton] == "Inventory")
                    {
                        action = "Choose an item to use on yourself";
                    }
                    if (Buttons[Page][SelectedButton] == "Run")
                    {
                        action = "Attempt to run away from combat";
                    }
                    if (Buttons[Page][SelectedButton] == "Stats")
                    {
                        action = "Shows statistics for you and your enemy";
                    }

                    Rectangle hpRectangle = new Rectangle(480 - 90 - 30, menuRectangle.Y + menuRectangle.Height / 2 - (16 * 2 + 4) / 2 + 2, 90, 16);

                    batch.Rectangle(hpRectangle, Color.White * 0.1f);
                    hpRectangle.Width = (int)(90 * ((float)state.Combatant.Health / state.Combatant.MaxHealth));
                    batch.Rectangle(hpRectangle, Color.White * 0.3f);
                    hpRectangle.Width = 90;

                    batch.Text(font, 16, "HP", new Vector2(hpRectangle.X + 4, hpRectangle.Y - 4), Color.White);

                    Vector2 measure = font.Measure(16, state.Combatant.Health + "/" + state.Combatant.MaxHealth);
                    batch.Text(font, 16, state.Combatant.Health + "/" + state.Combatant.MaxHealth, new Vector2(hpRectangle.X + hpRectangle.Width - 4 - measure.X, hpRectangle.Y - 4), Color.White);

                    hpRectangle.Y += 16 + 4;
                    batch.Rectangle(hpRectangle, Color.White * 0.1f);
                    hpRectangle.Width = (int)(90 * ((float)state.Enemy.Health / state.Enemy.MaxHealth));
                    batch.Rectangle(hpRectangle, Color.White * 0.3f);
                    hpRectangle.Width = 90;

                    batch.Text(font, 16, "Enemy", new Vector2(hpRectangle.X + 4, hpRectangle.Y - 4), Color.White);

                    measure = font.Measure(16, state.Enemy.Health + "/" + state.Enemy.MaxHealth);
                    batch.Text(font, 16, state.Enemy.Health + "/" + state.Enemy.MaxHealth, new Vector2(hpRectangle.X + hpRectangle.Width - 4 - measure.X, hpRectangle.Y - 4), Color.White);
                }

                if (Page == CombatMenuPage.MagicSelection ||
                    Page == CombatMenuPage.Stats)
                {
                    if (Page == CombatMenuPage.MagicSelection)
                    {
                        Rectangle mpRectangle = new Rectangle(480 - 90 - 30, menuRectangle.Y + menuRectangle.Height / 2 - 6, 90, 16);

                        batch.Rectangle(mpRectangle, Color.White * 0.1f);
                        mpRectangle.Width = (int)(90 * ((float)state.Combatant.Magicka / state.Combatant.MaxMagicka));
                        batch.Rectangle(mpRectangle, Color.White * 0.3f);
                        mpRectangle.Width = 90;

                        batch.Text(font, 16, "MP", new Vector2(mpRectangle.X + 4, mpRectangle.Y - 4), Color.White);

                        Vector2 measure = font.Measure(16, state.Combatant.Magicka + "/" + state.Combatant.MaxMagicka);
                        batch.Text(font, 16, state.Combatant.Magicka + "/" + state.Combatant.MaxMagicka, new Vector2(mpRectangle.X + mpRectangle.Width - 4 - measure.X, mpRectangle.Y - 4), Color.White);
                    }

                    if (Buttons[Page][SelectedButton] == "Back")
                    {
                        action = "Go back to main page";
                    }
                }

                batch.Text(font, 16, action, new Vector2(menuRectangle.X + 20, menuRectangle.Y + y + 8), Color.White * (0.4f + (float)Math.Sin(state.Game.Time * 10) * 0.1f));
            }

            batch.Text(font, 16, Message, new Vector2(menuRectangle.X + 20, menuRectangle.Y + 14), Color.White);

            if (AttackSlots != null)
            {
                for (int i = 0; i < AttackSlots.Length; i++)
                {
                    int x = i * 8 - (int)AttackSlotAnimation.Value - 4;
                    batch.Texture(new Vector2(x, menuRectangle.Y + 30), state.Assets.Get <Texture2D>(AttackSlots[i] ? "icons/armors.png" : "icons/weapons.png"), Color.White);
                }

                int offsetY = (int)(Math.Sin(state.Game.Time * 10) * 2);
                batch.Texture(new Vector2(menuRectangle.X + menuRectangle.Width / 2 - 3, menuRectangle.Y + 44 + offsetY), state.Assets.Get <Texture2D>("combat/arrow.png"), Color.White);
            }
        }
예제 #10
0
파일: CombatMenu.cs 프로젝트: teamstor/aod
        /// <summary>
        /// Updates the menu.
        /// </summary>
        /// <param name="state">The combat state using this menu.</param>
        public void Update(CombatState state)
        {
            if (Page == CombatMenuPage.ActionSelection)
            {
                if (InputMap.FindMapping(InputAction.Left).Pressed(state.Input))
                {
                    SelectedButton--;
                }
                if (InputMap.FindMapping(InputAction.Right).Pressed(state.Input))
                {
                    SelectedButton++;
                }
            }

            if (Buttons.ContainsKey(Page))
            {
                if (SelectedButton >= Buttons[Page].Count)
                {
                    SelectedButton = 0;
                }
                if (SelectedButton < 0)
                {
                    SelectedButton = Buttons[Page].Count - 1;
                }

                if (InputMap.FindMapping(InputAction.Action).Pressed(state.Input))
                {
                    switch (Page)
                    {
                    case CombatMenuPage.ActionSelection:
                        if (Buttons[Page][SelectedButton] == "Attack")
                        {
                            PendingAction = CombatPendingPlayerAction.AttackMelee;
                            Page          = CombatMenuPage.None;
                        }
                        else if (Buttons[Page][SelectedButton] == "Magic")
                        {
                            Page = CombatMenuPage.MagicSelection;
                        }
                        else if (Buttons[Page][SelectedButton] == "Inventory")
                        {
                            PendingAction = CombatPendingPlayerAction.OpenInventory;
                            Page          = CombatMenuPage.None;
                        }
                        else if (Buttons[Page][SelectedButton] == "Stats")
                        {
                            Page = CombatMenuPage.Stats;
                        }
                        else if (Buttons[Page][SelectedButton] == "Run")
                        {
                            PendingAction = CombatPendingPlayerAction.AttemptRunAway;
                            Page          = CombatMenuPage.None;
                        }
                        break;

                    case CombatMenuPage.MagicSelection:
                    case CombatMenuPage.Stats:
                        if (Buttons[Page][SelectedButton] == "Back")
                        {
                            Page = CombatMenuPage.ActionSelection;
                        }
                        break;
                    }
                }
            }

            if (_messageResetTime != -1 && state.Game.Time > _messageResetTime)
            {
                Message           = _messageTarget = "";
                _messageResetTime = -1;
            }

            _untilNextChar -= state.Game.DeltaTime;
            while (_untilNextChar <= 0)
            {
                if (Message.Length < _messageTarget.Length)
                {
                    Message += _messageTarget[Message.Length];
                }

                _untilNextChar += 0.03;
            }
        }
예제 #11
0
            internal static void Postfix(KnowledgeSkillTree __instance)
            {
                knowledgeSkillTree = __instance;

                foreach (var(megaKnowledgeKey, megaKnowledge) in Main.MegaKnowledges)
                {
                    var cloneFrom = __instance.GetComponentsInChildren <Component>()
                                    .First(component => component.name == megaKnowledge.cloneFrom).gameObject;

                    var child = cloneFrom.transform.parent.FindChild(megaKnowledge.name);
                    if (child != null)
                    {
                        return;
                    }

                    var newButton = Object.Instantiate(cloneFrom, cloneFrom.transform.parent, true);
                    newButton.transform.Translate(megaKnowledge.offsetX, megaKnowledge.offsetY, 0);

                    var btn = newButton.GetComponentInChildren <KnowledgeSkillBtn>();
                    newButton.name = megaKnowledge.name;
                    var knowledgeModels = Game.instance.model.knowledgeSets.First(model => model.name == megaKnowledge.set).GetKnowledgeModels();
                    btn.ClickedEvent = new Action <KnowledgeSkillBtn>(skillBtn =>
                    {
                        var hasAll     = true;
                        var btd6Player = Game.instance.GetBtd6Player();
                        foreach (var knowledgeModel in knowledgeModels)
                        {
                            if (!btd6Player.HasKnowledge(knowledgeModel.id))
                            {
                                hasAll = false;
                            }
                        }
                        if (!(Input.GetKey(KeyCode.LeftShift) || hasAll))
                        {
                            foreach (var knowledgeSkillBtn in Buttons[megaKnowledge.set].Values)
                            {
                                knowledgeSkillBtn.SetState(KnowlegdeSkillBtnState.Available);
                            }

                            foreach (var mkv in Main.MegaKnowledges.Values.Where(mkv =>
                                                                                 mkv.set == megaKnowledge.set))
                            {
                                mkv.enabled = false;
                            }
                        }

                        if (Input.GetKey(KeyCode.LeftAlt))
                        {
                            megaKnowledge.enabled = false;
                            skillBtn.SetState(KnowlegdeSkillBtnState.Available);
                        }
                        else
                        {
                            megaKnowledge.enabled = true;

                            skillBtn.SetState(KnowlegdeSkillBtnState.Purchased);
                            knowledgeSkillTree.BtnClicked(skillBtn);
                            knowledgeSkillTree.selectedPanelTitleTxt.SetText(megaKnowledge.name);
                            knowledgeSkillTree.selectedPanelDescTxt.SetText(megaKnowledge.description);
                        }
                    });
                    btn.Construct(newButton);
                    if (!Buttons.ContainsKey(megaKnowledge.set))
                    {
                        Buttons[megaKnowledge.set] = new Dictionary <string, KnowledgeSkillBtn>();
                    }

                    Buttons[megaKnowledge.set][megaKnowledgeKey] = btn;
                    btn.SetState(megaKnowledge.enabled
                        ? KnowlegdeSkillBtnState.Purchased
                        : KnowlegdeSkillBtnState.Available);

                    var image = btn.GetComponentsInChildren <Component>().First(component => component.name == "Icon")
                                .GetComponent <Image>();

                    ResourceLoader.LoadSpriteFromSpriteReferenceAsync(new SpriteReference(megaKnowledge.GUID), image,
                                                                      false);
                    image.mainTexture.filterMode = FilterMode.Trilinear;
                }

                foreach (var gameObject in knowledgeSkillTree.scrollers)
                {
                    gameObject.GetComponent <RectTransform>().sizeDelta += new Vector2(0, 500);
                }
            }