protected void rCustomOptions_ItemCommand(object source, RepeaterCommandEventArgs e) { LoadCustomOptions(); if (e.CommandName.Equals("AddNewOption")) { CustomOption copt = _customOptions[e.Item.ItemIndex]; var opt = new OptionItem { OptionId = -1, PriceBc = 0 }; if (copt.Options.Count > 0) { opt.SortOrder = copt.Options[copt.Options.Count - 1].SortOrder + 10; } else { opt.SortOrder = 10; } copt.Options.Add(opt); } else if (e.CommandName.Equals("DeleteCustomOptions")) { _customOptions.RemoveAt(e.Item.ItemIndex); } UpdateCustomOptions(); }
public override void Load() { foreach (Role role in Roles) { // RoleAllowSpawns.Add(GetRoleAllowSpawnOption(role)); RoleSpawnChances.Add(CreateRoleSpawnChanceOption(role)); } for (var i = 0; i < RoleSlots.Length; i++) { RoleSlots[i] = CustomOption.AddString("Role Slot " + (i + 1), new[] { "Crew", "Crew Investigative", "Crew Killing", "Crew Protective", "Crew Support", "Mafia", "Mafia Deception", "Mafia Killing", "Mafia Support", "Neutral", "Neutral Benign", "Neutral Chaos", "Neutral Evil", "Neutral Killing" }); } OptionPage.CreateOptionPage(GeneralOptions); OptionPage.CreateOptionPage(RoleSlots); OptionPage.CreateOptionPage(RoleSpawnChances.Values); OptionPage.CreateOptionPage(RoleCooldowns.Values); OptionPage.CreateOptionPage(RoleDurations.Values); OptionPage.CreateOptionPage(RoleOptions.Keys); // Disable the https://github.com/DorCoMaNdO/Reactor-Essentials watermark. // The code said that you were allowed, as long as you provided credit elsewhere. // I added a link in the Credits of the GitHub page, and I'm also mentioning it here. // If the owner of this library has any problems with this, just message me on discord and we'll find a solution // BothLine#9610 CustomOption.ShamelessPlug = false; Harmony.PatchAll(); }
private static KeyValuePair <CustomOption, Type> CreateNumberRoleOption <TRole>(string name, float value, float min, float max, float increment) where TRole : RoleGeneric <TRole>, new() { return(new KeyValuePair <CustomOption, Type>( CustomOption.AddNumber(Role.GetName <TRole>() + ": " + name, value, min, max, increment), typeof(TRole))); }
public static void Postfix(GameOptionsMenu __instance) { var template = UnityEngine.Object.FindObjectsOfType <StringOption>().FirstOrDefault(); if (template == null) { return; } List <OptionBehaviour> allOptions = __instance.IGFJIPMAJHF.ToList(); for (int i = 0; i < CustomOption.options.Count; i++) { CustomOption option = CustomOption.options[i]; if (option.optionBehaviour == null) { StringOption stringOption = UnityEngine.Object.Instantiate(template, template.transform.parent); allOptions.Add(stringOption); stringOption.transform.localPosition = new Vector3(template.transform.localPosition.x, -7.85f - (i + 1) * 0.5F, template.transform.localPosition.z); stringOption.OnValueChanged = new Action <OptionBehaviour>((o) => {}); stringOption.TitleText.Text = option.name; stringOption.Value = stringOption.IOFLMCGMJBA = option.selection; stringOption.ValueText.Text = option.selections[option.selection].ToString(); option.optionBehaviour = stringOption; } option.optionBehaviour.gameObject.SetActive(true); } __instance.IGFJIPMAJHF = allOptions.ToArray(); }
private void GetTextBoxMultiLine(HtmlGenericControl row, CustomOption customOption, IList <EvaluatedCustomOptions> evlist) { var title = new HtmlGenericControl("div"); title.Attributes.Add("class", "param-name"); var l = new Label { Text = customOption.Title + ":" }; title.Controls.Add(l); var value = new HtmlGenericControl("div"); value.Attributes.Add("class", "param-value"); var ctrl = new TextBox { TextMode = TextBoxMode.MultiLine, ID = customOption.Title }; if (evlist != null) { EvaluatedCustomOptions ev = evlist.WithCustomOptionId(customOption.CustomOptionsId); if (ev != null) { ctrl.Text = ev.OptionTitle; } } value.Controls.Add(ctrl); _controls.Add(ctrl); row.Controls.Add(title); row.Controls.Add(value); }
private void ProcessCustomOption(CustomOption customOption) { switch (customOption.option_type.ToLower()) { case "toggle": if (customOption.operation_list == null) { return; } for (int i = 0; i < customOption.operation_list.Length; i++) { ProcessCustomOperation(customOption.operation_list[i], customOption.is_check); } break; case "grid": if (customOption.grid_list == null) { return; } CustomGridOption customGridOption = customOption.grid_list[customOption.select]; for (int i = 0; i < customGridOption.operation_list.Length; i++) { ProcessCustomOperation(customGridOption.operation_list[i], true); } break; } }
/* * Setuper側の処理が終わったあとに実行される * SetuperExpandOptionから呼び出し */ public void AfterSetuperProcess() { //不要なオブジェクトを削除 if (isDeleteUnnecessaryObject) { for (int i = 0; i < expandOption.unnecessary_objects.Length; i++) { Transform unnecessaryObject = PrefabData.GetAvatar().transform.Find(expandOption.unnecessary_objects[i]); if (unnecessaryObject != null) { GameObject.DestroyImmediate(unnecessaryObject.gameObject); } } } if (expandOption.custom_options == null) { return; } for (int i = 0; i < expandOption.custom_options.Length; i++) { CustomOption customOption = expandOption.custom_options[i]; RunCustomOption(customOption); } }
private static KeyValuePair <CustomOption, Type> CreateStringRoleOption <TRole>(string name, params string[] values) where TRole : RoleGeneric <TRole>, new() { return(new KeyValuePair <CustomOption, Type>( CustomOption.AddString(Role.GetName <TRole>() + ": " + name, values), typeof(TRole))); }
private static KeyValuePair <Type, CustomNumberOption> CreateRoleSpawnChanceOption(Role role, float value = 100F, float min = 0F, float max = 100F, float increment = 5F) { CustomNumberOption customNumberOption = CustomOption.AddNumber( $"({role.Faction.Name} {role.Alignment.Name}) {role.Name}", value, min, max, increment); return(new KeyValuePair <Type, CustomNumberOption>(role.GetType(), customNumberOption)); }
//****** Private controls set private void GetTextBoxSingleLine(HtmlGenericControl row, CustomOption customOption, IList <EvaluatedCustomOptions> evlist) { var title = new HtmlGenericControl("div"); title.Attributes.Add("class", "param-name"); var l = new Label { Text = customOption.Title + ":" }; title.Controls.Add(l); var value = new HtmlGenericControl("div"); value.Attributes.Add("class", "param-value"); var subDiv = new HtmlGenericControl("div"); subDiv.Attributes.Add("style", "width:200px;float:left"); var ctrl = new TextBox { ID = (customOption.ID + customOption.Title).GetHashCode().ToString() }; ctrl.Attributes.Add("style", "width:170px;"); if (ShowValidation) { ctrl.Attributes.Add("class", "valid-required group-cOptions"); } if (evlist != null) { EvaluatedCustomOptions ev = evlist.WithCustomOptionId(customOption.CustomOptionsId); if (ev != null) { ctrl.Text = ev.OptionTitle; } } subDiv.Controls.Add(ctrl); value.Controls.Add(subDiv); _controls.Add(ctrl); var lbApply = new LinkButton() { ID = (customOption.ID + customOption.Title + "lb").GetHashCode().ToString(), Text = Resource.Client_Details_Apply }; lbApply.Attributes.Add("style", "float:right"); lbApply.Attributes.Add("class", "group-cOptions"); lbApply.OnClientClick = "if(!$('form').valid('cOptions')){return false;}"; value.Controls.Add(lbApply); _controls.Add(lbApply); row.Controls.Add(title); row.Controls.Add(value); }
private void GetCheckBox(HtmlGenericControl row, CustomOption customOption, IList <EvaluatedCustomOptions> evlist) { var title = new HtmlGenericControl("div"); title.Attributes.Add("class", "param-name"); var l = new Label { Text = customOption.Title + ":" }; title.Controls.Add(l); var value = new HtmlGenericControl("div"); value.Attributes.Add("class", "param-value"); var price = customOption.Options[0].PriceBc; var ctrl = new CheckBox { ID = (customOption.ID + customOption.Title).GetHashCode().ToString(), AutoPostBack = true }; if (price != 0) { var prefix = (price > 0) ? " +" : " "; switch (customOption.Options[0].PriceType) { case OptionPriceType.Fixed: price = GetPrice(price); ctrl.Text = prefix + CatalogService.GetStringPrice(price); break; case OptionPriceType.Percent: ctrl.Text = prefix + price.ToString("#,0.##") + @"%"; break; } } else { ctrl.Text = string.Empty; } if (evlist != null) { EvaluatedCustomOptions ev = evlist.WithCustomOptionId(customOption.CustomOptionsId); if (ev != null) { ctrl.Checked = ev.OptionId > 0; } } value.Controls.Add(ctrl); _controls.Add(ctrl); row.Controls.Add(title); row.Controls.Add(value); }
private static CustomToggleOption MakeRoleToggle(string Id, string Type, Dictionary <string, Func <string> > Arguments, OptionGroup Group) { var Result = CustomOption.AddToggle($"er.{Id}.{Type}", $"er.role.{Type}", false); Result.LocalizationArguments = Arguments; Result.Group = Group; return(Result); }
// public static string GetActionName<T>() // where T : RoleGeneric<T>, new() // { // return ActionNames.TryGetValue(typeof(T), out string actionName) ? actionName : ""; // } private static KeyValuePair <TypePair, CustomNumberOption> CreateRoleDurationOption <TRole, TAbility>( float value = 15F, float min = 5F, float max = 30F, float increment = 2.5F) where TRole : RoleGeneric <TRole>, new() where TAbility : Ability { return(new KeyValuePair <TypePair, CustomNumberOption>( new TypePair(typeof(TRole), typeof(TAbility)), CustomOption.AddNumber($"{Role.GetName<TRole>()} {typeof(TAbility).Name} Duration", value, min, max, increment))); }
public static bool Prefix(StringOption __instance) { CustomOption option = CustomOption.options.FirstOrDefault(option => option.optionBehaviour == __instance); if (option == null) { return(true); } option.updateSelection(option.selection - 1); return(false); }
/* * public static float GetRoleSpawnChance<T>() * where T : RoleGeneric<T>, new() * { * return RoleSpawnChances.TryGetValue(typeof(T), out CustomNumberOption value) ? value.GetValue() : 0F; * } */ private static KeyValuePair <TypePair, CustomNumberOption> CreateRoleCooldownOption <TRole, TAbility>( float value = 30F, float min = 10F, float max = 60F, float increment = 2.5F) where TRole : RoleGeneric <TRole>, new() where TAbility : Ability { // ActionNames.Add(typeof(T), actionName); return(new KeyValuePair <TypePair, CustomNumberOption>( new TypePair(typeof(TRole), typeof(TAbility)), CustomOption.AddNumber($"{Role.GetName<TRole>()} {typeof(TAbility).Name} Cooldown", value, min, max, increment))); }
public static void Init() { CustomOption.AddTitle("").Group = Team.GROUP_TEAMS; CustomOption.AddTitle(LanguageManager.Get("m.teams")).Group = Team.GROUP_TEAMS; Teams.Add(new Team(Color.red, "Red", ExtraResources.CAPTURE_RED)); Teams.Add(new Team(Color.blue, "Blue", ExtraResources.CAPTURE_BLUE)); Teams.Add(new Team(Color.green, "Green", ExtraResources.CAPTURE_GREEN)); Teams.Add(new Team(Color.yellow, "Yellow", ExtraResources.CAPTURE_YELLOW)); CustomOption.AddTitle("").Group = Team.GROUP_TEAMS; CustomOption.AddTitle(LanguageManager.Get("m.roles")).Group = Team.GROUP_TEAMS; }
private static KeyValuePair <Type, CustomNumberOption> CreateRoleSpawnChanceOption <T>(float value = 50F, float min = 0F, float max = 100F, float increment = 5F) where T : RoleGeneric <T>, new() { Type type = typeof(T); string name = Role.GetName <T>(); string faction = Role.GetFaction <T>().ShortHandle; string alignment = Role.GetAlignment <T>().ShortHandle; CustomNumberOption customNumberOption = CustomOption.AddNumber($"({faction}{alignment}) {name}", value, min, max, increment); return(new KeyValuePair <Type, CustomNumberOption>(type, customNumberOption)); }
public static bool Prefix(StringOption __instance) { CustomOption option = CustomOption.options.FirstOrDefault(option => option.optionBehaviour == __instance); if (option == null) { return(true); } __instance.OnValueChanged = new Action <OptionBehaviour>((o) => {}); __instance.TitleText.Text = option.name; __instance.Value = __instance.IOFLMCGMJBA = option.selection; __instance.ValueText.Text = option.selections[option.selection].ToString(); return(false); }
protected void btnAddCustomOption_Click(object sender, EventArgs e) { LoadCustomOptions(); var copt = new CustomOption(true) { CustomOptionsId = -1, ProductId = ProductId }; var opt = new OptionItem { OptionId = -1, PriceBc = 0, SortOrder = 10 }; copt.Options = new List <OptionItem> { opt }; _customOptions.Add(copt); UpdateCustomOptions(); }
protected void btnAddCustomOption_Click(object sender, EventArgs e) { LoadCustomOptions(); var maxSort = _customOptions.Select(x => x.SortOrder).DefaultIfEmpty().Max(); var copt = new CustomOption(true) { CustomOptionsId = -1, ProductId = ProductId, SortOrder = maxSort + 10 }; var opt = new OptionItem { OptionId = -1, PriceBc = 0, SortOrder = 10 }; copt.Options = new List <OptionItem> { opt }; _customOptions.Add(copt); UpdateCustomOptions(); }
protected Role(string Id, Color RoleColor) { this.Id = Id; Color = RoleColor; var RoleHexColor = $"[{RoleColor.ToHexRGBA()}]"; var Arguments = new Dictionary <string, Func <string> > { { "%c", () => RoleHexColor }, { "%w", () => LanguageManager.Get($"er.{Id}.whom") } }; _Enable = MakeRoleToggle(Id, "enable", Arguments, GROUP_ENABLE); var RoleTitle = CustomOption.AddTitle("er.role.title"); RoleTitle.LocalizationArguments = new Dictionary <string, Func <string> > { { "%c", () => RoleHexColor }, { "%n", () => LanguageManager.Get($"er.{Id}") }, { "%r", () => Globals.FORMAT_WHITE }, }; }
public void RunCustomOption(CustomOption customOption) { switch (customOption.option_type.ToLower()) { case "toggle": if (customOption.multi_operation != null) { for (int i = 0; i < customOption.multi_operation.Length; i++) { CustomOperation customOperation = customOption.multi_operation[i]; ProcessCustomOption(customOperation.operation, true, customOperation.argment, customOperation.target_object_list); } } else { ProcessCustomOption(customOption.operation, customOption.is_check, customOption.argment, customOption.target_object_list); } break; case "grid": CustomGridOption customGridOption = customOption.grid_list[customOption.select]; if (customGridOption.multi_operation != null) { for (int multiOperationCount = 0; multiOperationCount < customGridOption.multi_operation.Length; multiOperationCount++) { CustomOperation customOperation = customGridOption.multi_operation[multiOperationCount]; ProcessCustomOption(customOperation.operation, true, customOperation.argment, customOperation.target_object_list); } } else { ProcessCustomOption(customGridOption.operation, true, customGridOption.argment, customGridOption.target_object_list); } break; } }
public void CreateOptions() { CustomOption.AddHeader(Properties.Resources.HunterOptions); HunterSpawnChance = CustomOption.AddNumber("hunter-spawn-chance", Properties.Resources.SpawnChance, saveValue: true, 100, 0, 100, 10); HunterKillCooldown = CustomOption.AddNumber("hunter-kill-cooldown", Properties.Resources.HunterKillCooldown, saveValue: true, 30, 10, 60, 2.5f); CustomOption.AddHeader(Properties.Resources.EngineerOptions); EngineerSpawnChance = CustomOption.AddNumber("engineer-spawn-chance", Properties.Resources.SpawnChance, saveValue: true, 80, 0, 100, 10); CustomOption.AddHeader(Properties.Resources.ShapeShifterOptions); ShapeShifterSpawnChance = CustomOption.AddNumber("shape-shifter-spawn-chance", Properties.Resources.SpawnChance, saveValue: true, 80, 0, 100, 10); ShapeShifterSampleCooldown = CustomOption.AddNumber("shape-shifter-sample-cooldown", Properties.Resources.ShapeShifterSampleCooldown, saveValue: true, 0, 0, 30, 2.5f); ShapeShifterMorphCooldown = CustomOption.AddNumber("shape-shifter-morph-cooldown", Properties.Resources.ShapeShifterMorphCooldown, saveValue: true, 20, 0, 30, 2.5f); ShapeShifterMorphDuration = CustomOption.AddNumber("shape-shifter-morph-duration", Properties.Resources.ShapeShifterMorphDuration, saveValue: true, 10, 0, 30, 2.5f); CustomOption.AddHeader(Properties.Resources.JesterOptions); JesterSpawnChance = CustomOption.AddNumber("jester-spawn-chance", Properties.Resources.SpawnChance, saveValue: true, 80, 0, 100, 10); CustomOption.AddHeader(Properties.Resources.DetectiveOptions); DetectiveSpawnChance = CustomOption.AddNumber("detective-spawn-chance", Properties.Resources.SpawnChance, saveValue: true, 80, 0, 100, 10); DetectiveShieldedPlayerSeesShield = CustomOption.AddToggle("detective-shielded-player-sees-shield", Properties.Resources.ShieldedPlayerSeesShield, saveValue: true, true); //DetectiveDeathReportThreshold = CustomOption.AddNumber("detective-death-report-threshold", Properties.Resources.DetectiveDeathReportThreshold, saveValue: true, 20, 0, 30, 2.5f); }
private void LoadCustomOptions() { var customOptions = new List <CustomOption>(); foreach (RepeaterItem item in rCustomOptions.Items) { var customOption = new CustomOption { CustomOptionsId = ((HiddenField)(item.FindControl("hfId"))).Value.TryParseInt(), ProductId = ((HiddenField)(item.FindControl("hfProductId"))).Value.TryParseInt() }; if (string.IsNullOrEmpty(((TextBox)(item.FindControl("txtTitle"))).Text)) { _valid = false; } int i; if (!int.TryParse(((TextBox)(item.FindControl("txtSortOrder"))).Text, out i)) { _valid = false; } customOption.Title = ((TextBox)(item.FindControl("txtTitle"))).Text; customOption.InputType = (CustomOptionInputType)((((DropDownList)(item.FindControl("ddlInputType"))).SelectedValue.TryParseInt())); customOption.IsRequired = ((CheckBox)(item.FindControl("cbIsRequired"))).Checked; try { customOption.SortOrder = Convert.ToInt32(((TextBox)(item.FindControl("txtSortOrder"))).Text); } catch (Exception) { customOption.SetFieldToNull(CustomOptionField.SortOrder); } customOption.Options = new List <OptionItem>(); if (customOption.InputType == CustomOptionInputType.CheckBox) { var opt = new OptionItem { Title = " " }; try { opt.PriceBc = Convert.ToDecimal(((TextBox)(item.FindControl("txtPrice"))).Text); } catch (Exception) { opt.SetFieldToNull(OptionField.PriceBc); _valid = false; } opt.PriceType = OptionPriceType.Fixed; if (Enum.IsDefined(typeof(OptionPriceType), ((DropDownList)(item.FindControl("ddlPriceType"))).SelectedValue)) { opt.PriceType = (OptionPriceType)Enum.Parse(typeof(OptionPriceType), ((DropDownList)(item.FindControl("ddlPriceType"))).SelectedValue, true); } customOption.Options.Add(opt); } else { foreach (GridViewRow row in ((GridView)(item.FindControl("grid"))).Rows) { var opt = new OptionItem { OptionId = ((Label)(row.Cells[0].FindControl("lId"))).Text.TryParseInt() }; if (string.IsNullOrEmpty(((TextBox)(row.Cells[1].FindControl("txtTitle"))).Text) && !(customOption.InputType == CustomOptionInputType.CheckBox || customOption.InputType == CustomOptionInputType.TextBoxMultiLine || customOption.InputType == CustomOptionInputType.TextBoxSingleLine)) { _valid = false; } opt.Title = ((TextBox)(row.Cells[1].FindControl("txtTitle"))).Text; try { opt.PriceBc = Convert.ToDecimal(((TextBox)(row.Cells[2].FindControl("txtPriceBC"))).Text); } catch (Exception) { opt.SetFieldToNull(OptionField.PriceBc); _valid = false; } opt.PriceType = OptionPriceType.Fixed; if (Enum.IsDefined(typeof(OptionPriceType), ((DropDownList)(row.Cells[3].FindControl("ddlPriceType"))).SelectedValue)) { opt.PriceType = (OptionPriceType)Enum.Parse(typeof(OptionPriceType), ((DropDownList)(row.Cells[3].FindControl("ddlPriceType"))).SelectedValue, true); } try { opt.SortOrder = int.Parse(((TextBox)(row.Cells[4].FindControl("txtSortOrder"))).Text); } catch (Exception) { opt.SetFieldToNull(OptionField.SortOrder); _valid = false; } customOption.Options.Add(opt); } } customOptions.Add(customOption); } _customOptions = customOptions; }
public static void Postfix() { CustomOption.ShareOptionSelections(); }
public static CooldownController FromOption(string Prefix, string OptionName = "cooldown", float Value = 30f, float Min = 5f, float Max = 60f, float Increment = 2.5f) { return(new CooldownController(CustomOption.AddNumber( $"{Prefix}.{OptionName}", Value, Min, Max, Increment))); }
protected CustomNumberOption MakeNumber(string Name, float Value, float Min, float Max, float Increment) { return(CustomOption.AddNumber(MakeOptionId(Name), Value, Min, Max, Increment)); }
protected CustomToggleOption MakeToggle(string Name, bool Value) { return(CustomOption.AddToggle(MakeOptionId(Name), Value)); }
//ExpandOptionのGUI処理 private void OnCustomOptionGUI() { if (expandOption.custom_options == null) { return; } for (int i = 0; i < expandOption.custom_options.Length; i++) { CustomOption customOption = expandOption.custom_options[i]; //オプションが非表示の場合 if (customOption.is_not_visible_option) { return; } GUILayout.Space(4); switch (customOption.option_type.ToLower()) { case "toggle": customOption.is_check = GUILayout.Toggle(customOption.is_check, I18N.Instance().Get(customOption.name)); break; case "grid": GUILayout.Label(I18N.Instance().Get(customOption.name)); //GUI用の文字列リストを作る List <string> selectGridList = new List <string>(); //CustomOptionのgrid_listから名前を取り出し文字列リストに追加 for (int selectGridCount = 0; selectGridCount < customOption.grid_list.Length; selectGridCount++) { selectGridList.Add(I18N.Instance().Get(customOption.grid_list[selectGridCount].name)); } //GUI表示。処理するときにはselect(index)を使ってCustomOptionのgrid_listから取り出す customOption.select = GUILayout.SelectionGrid(customOption.select, selectGridList.ToArray(), 3); break; } //適用ボタン表示のフィルター処理 bool filterPassed = false; if (customOption.apply_filter != null && PrefabData.GetAvatar() != null) { for (int filterCount = 0; filterCount < customOption.apply_filter.Length; filterCount++) { Transform filterObject = PrefabData.GetAvatar().transform.Find(customOption.apply_filter[filterCount]); if (filterObject != null) { filterPassed = true; } } } if (customOption.display_apply_button && filterPassed) { GUILayout.Space(4); EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button(I18N.Instance().Get("option.button.apply") + ": " + I18N.Instance().Get(customOption.name), new GUILayoutOption[] { GUILayout.MinWidth(200) })) { RunCustomOption(customOption); } EditorGUILayout.EndHorizontal(); } } }
private static KeyValuePair <CustomOption, Type> CreateToggleRoleOption <TRole>(string name, bool value) where TRole : RoleGeneric <TRole>, new() { return(new KeyValuePair <CustomOption, Type>( CustomOption.AddToggle(Role.GetName <TRole>() + ": " + name, value), typeof(TRole))); }