// 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]); }
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); } }
// 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); } }