// Returning `true` means it ran a custom menu update. `false` means the menu needs to be updated manually. public override bool CycleParam(string paramKey, bool up = true) { ArrayList tileObj = WandData.wandTileData; // Verify that the parameter can exist. if (tileObj == null) { return(false); } if (tileObj.Count <= 2) { tileObj.Add(new Dictionary <string, short>()); } // Get Tile Data Dictionary <string, short> paramList = (Dictionary <string, short>)tileObj[2]; // A Content Group must be listed: if (!paramList.ContainsKey("content")) { paramList["content"] = 0; } if (!paramList.ContainsKey("id")) { paramList["id"] = 0; } short groupVal = paramList["content"]; // Cycle "content" Param if (paramKey == "content") { short newValue = this.CycleNumber(groupVal, 0, (short)(this.contentGroup.Length - 1), 1, up); this.UpdateParamNum(paramList, paramKey, newValue, 0); this.UpdateParamNum(paramList, "id", 0, 0); } // Cycle "id" Supply Param (dependent on "content" type) else { if (groupVal < 0 || groupVal > 9) { groupVal = 0; } DictParam rule = (DictParam)WandData.actParamSet.rules[(byte)(groupVal + 1)]; Dictionary <byte, string> dict = rule.dict; byte[] contentKeys = dict.Keys.ToArray <byte>(); byte cId = byte.Parse(paramList["id"].ToString()); short newId = this.CycleNumber((short)cId, 0, (short)(contentKeys.Length - 1), 1, up); this.UpdateParamNum(paramList, paramKey, newId, contentKeys[0]); } // Update the Menu Options return(this.RunCustomMenuUpdate()); }
// 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); } }