Пример #1
0
        // Returning `true` means it ran a custom menu update. `false` means the menu needs to be updated manually.
        public override bool RunCustomMenuUpdate()
        {
            List <byte> rulesToShow = new List <byte>();

            // Add Rules that are present for this menu:
            this.AddRulesToShow(new string[] { "hp", "armor", "suit", "hat", "shoes", "mob", "att" }, ref rulesToShow);

            short attType = WandData.GetParamVal(WandData.actParamSet, "att");

            if (attType == 2)
            {
                this.AddRulesToShow(new string[] { "weapon" }, ref rulesToShow);
            }
            else if (attType == 3)
            {
                this.AddRulesToShow(new string[] { "spell" }, ref rulesToShow);
            }
            else if (attType == 4)
            {
                this.AddRulesToShow(new string[] { "thrown" }, ref rulesToShow);
            }
            else if (attType == 5)
            {
                this.AddRulesToShow(new string[] { "bolt" }, ref rulesToShow);
            }

            byte[] ruleIdsToShow = rulesToShow.ToArray();
            WandData.actParamMenu.UpdateMenuOptions((byte)ruleIdsToShow.Length, ruleIdsToShow);
            return(true);
        }
Пример #2
0
        public override void RunTick(EditorRoomScene scene)
        {
            if (UIComponent.ComponentWithFocus != null)
            {
                return;
            }

            // Left Mouse Button
            if (Cursor.LeftMouseState == Cursor.MouseDownState.Clicked)
            {
                // Initialize the Wand Data for this Tile
                bool validWand = WandData.InitializeWandData(scene, Cursor.TileGridX, Cursor.TileGridY);
                if (validWand == false)
                {
                    return;
                }

                scene.scene.editorUI.moveParamMenu.LoadParamMenu();
                scene.scene.editorUI.actParamMenu.LoadParamMenu();
            }

            // Right Mouse Button (Clone Current Tile)
            else if (Cursor.RightMouseState == Cursor.MouseDownState.Clicked)
            {
                scene.CloneTile(Cursor.TileGridX, Cursor.TileGridY);
            }
        }
Пример #3
0
        // Retrieve Param Value from Param List (the JSON for the specific param key)
        public static short GetParamVal(Params paramSet, string paramKey)
        {
            Dictionary <string, short> paramList = WandData.GetAllParamsOnTile();

            // Get the default value if the tile data does not have one saved:
            if (paramList == null || !paramList.ContainsKey(paramKey))
            {
                ParamGroup rule = paramSet.GetParamRule(paramKey);
                return(rule.defValue);
            }

            return((short)paramList[paramKey]);
        }
Пример #4
0
        // This override will check the "fly" group param, and show the appropriate rule accordingly.
        public override bool RunCustomMenuUpdate()
        {
            short flightVal = WandData.GetParamVal(WandData.moveParamSet, "fly");

            List <byte> rulesToShow = new List <byte>();

            // Add Rules that are present for this menu:
            this.AddRulesToShow(new string[] { "fly" }, ref rulesToShow);

            if (flightVal != 0)
            {
                this.AddRulesToShow(new string[] { "duration" }, ref rulesToShow);
            }

            switch (flightVal)
            {
            // X, Y, Reverse, Cluster Link, Cluster ID
            case (byte)FlightMovement.Axis:
                this.AddRulesToShow(new string[] { "durOffset", "x", "y", "reverse", "toCluster" }, ref rulesToShow);
                break;

            // X, Y, MidX, MidY, Reverse, Cluster Link, Cluster ID
            case (byte)FlightMovement.Quadratic:
                this.AddRulesToShow(new string[] { "durOffset", "x", "y", "midX", "midY", "reverse", "toCluster" }, ref rulesToShow);
                break;

            // Diameter, Reverse, Cluster Link, Cluster ID
            case (byte)FlightMovement.Circle:
                this.AddRulesToShow(new string[] { "durOffset", "diameter", "reverse", "toCluster", "rel" }, ref rulesToShow);
                break;

            // X, Y, Countdown, Cluster ID
            case (byte)FlightMovement.To:
                this.AddRulesToShow(new string[] { "x", "y", "countdown" }, ref rulesToShow);
                break;

            // Track, Cluster ID
            case (byte)FlightMovement.Track:
                this.AddRulesToShow(new string[] { "durOffset", "toTrack" }, ref rulesToShow);
                break;
            }

            byte[] ruleIdsToShow = rulesToShow.ToArray();
            WandData.moveParamMenu.UpdateMenuOptions((byte)ruleIdsToShow.Length, ruleIdsToShow);
            return(true);
        }
Пример #5
0
        public virtual void Draw()
        {
            if (!this.visible)
            {
                return;
            }

            Dictionary <string, short> paramList = WandData.GetAllParamsOnTile();

            // Draw Line Divisions & Menu Options
            byte count = (byte)this.numberOptsToShow;

            // Draw White Background
            Systems.spriteBatch.Draw(Systems.tex2dWhite, new Rectangle(this.x, this.y, this.width, this.height), Color.White * 0.75f);

            // Loop through vertical set:
            for (byte i = 0; i < count; i++)
            {
                string label = this.menuOptLabels[i];
                string text  = this.menuOptText[i];

                // Draw Line
                Systems.spriteBatch.Draw(Systems.tex2dBlack, new Rectangle(this.x, this.y + ParamMenu.SlotHeight * i, this.width, 2), Color.Black);

                // Set this line as green to indicate that it's not a default value (unless currently being highlighted):
                if (this.optionSelected != i && paramList != null && paramList.ContainsKey(this.paramSet.rules[(byte)this.menuOptRuleIds[i]].key))
                {
                    Systems.spriteBatch.Draw(Systems.tex2dDarkGreen, new Rectangle(this.x, this.y + ParamMenu.SlotHeight * i, this.width, ParamMenu.SlotHeight), Color.White * 0.2f);
                }

                // Draw Label + Text
                Vector2 textSize = ParamMenu.font.font.MeasureString(label);
                ParamMenu.font.Draw(label, this.splitPos - 10 - (byte)Math.Floor(textSize.X), this.y + ParamMenu.SlotHeight * i + 8, Color.Black);
                ParamMenu.font.Draw(text, this.splitPos + 10, this.y + ParamMenu.SlotHeight * i + 8, Color.Black);
            }

            // Draw Bottom Line
            Systems.spriteBatch.Draw(Systems.tex2dBlack, new Rectangle(this.x, this.y + ParamMenu.SlotHeight * count, this.width, 2), Color.Black);

            // Hovering Visual
            if (this.optionSelected > -1)
            {
                Systems.spriteBatch.Draw(Systems.tex2dDarkRed, new Rectangle(this.x, this.y + ParamMenu.SlotHeight * this.optionSelected, this.width, ParamMenu.SlotHeight), Color.White * 0.5f);
            }
        }
Пример #6
0
        // Update Menu Options (run when menu changes)
        public void UpdateMenuOptions(byte numOptsToShow = 0, byte[] optRuleIds = null)
        {
            if (!this.visible)
            {
                return;
            }

            Dictionary <string, short> paramList = WandData.GetAllParamsOnTile();

            // Get Rules
            List <ParamGroup> rules = this.paramSet.rules;

            // Prepare Menu Options
            this.numberOptsToShow = (numOptsToShow == 0 ? (byte)rules.Count : numOptsToShow);

            // Determine the Rule IDs that appear in the Option List. The default is just to list each rule in order.
            // Some wand menus (such as Flight and Chest) will have different sequences that must be sent to this method.
            // The reason for this is because there are certain rules that will affect others. Such as Flight Type of Rotation making the rotating diameter value visible.
            for (byte i = 0; i < this.numberOptsToShow; i++)
            {
                this.menuOptRuleIds[i] = optRuleIds == null ? i : optRuleIds[i];
            }

            // Loop through each rule:
            for (byte i = 0; i < this.numberOptsToShow; i++)
            {
                byte       ruleId = this.menuOptRuleIds[i];
                ParamGroup rule   = rules[ruleId];

                this.menuOptLabels[i] = rule.name;

                // Determine the Text
                if (paramList != null && paramList.ContainsKey(rule.key))
                {
                    // Labeled Params
                    if (rule is LabeledParam)
                    {
                        byte paramVal = byte.Parse(paramList[rule.key].ToString());
                        if (((LabeledParam)rule).labels.Length > paramVal)
                        {
                            this.menuOptText[i] = ((LabeledParam)rule).labels[paramVal];
                        }
                    }

                    // Dictionary Params
                    else if (rule is DictParam)
                    {
                        DictParam dictRule    = (DictParam)(rule);
                        byte[]    contentKeys = dictRule.dict.Keys.ToArray <byte>();
                        byte      paramVal    = byte.Parse(paramList[rule.key].ToString());
                        this.menuOptText[i] = dictRule.dict[contentKeys[paramVal]];
                    }

                    // Frame Params (show them as milliseconds, rather than by frames)
                    else if (rule is FrameParam)
                    {
                        int newVal = short.Parse(paramList[rule.key].ToString()) * 1000 / 60;
                        this.menuOptText[i] = newVal.ToString() + " ms";
                    }

                    // Default Numeric Params
                    else
                    {
                        this.menuOptText[i] = paramList[rule.key].ToString() + rule.unitName;
                    }
                }

                // Display Default String
                else
                {
                    // Default Rule for Frame Params is still altered.
                    if (rule is FrameParam)
                    {
                        this.menuOptText[i] = (rule.defValue * 1000 / 60).ToString() + " ms";
                    }
                    else
                    {
                        this.menuOptText[i] = rule.defStr;
                    }
                }

                // Resize Menu after any update.
                this.ResizeMenu(false);
            }
        }