private void Init() { if (isUsingActualConfig) { // Load configurations GameConfiguration.Load(); settingsData = GameConfiguration.Settings; } else { settingsData = new SettingsData(); var a = settingsData.AddTabData(new SettingsTab("A", "icon-arrow-left")); a.AddEntry(new SettingsEntryBool("a-a", testDataAA = new BindableBool(false))); a.AddEntry(new SettingsEntryBool("a-b", testDataAB = new BindableBool(true))); a.AddEntry(new SettingsEntryEnum <TestType>("a-c", testDataAC = new Bindable <TestType>(TestType.TypeB))); var b = settingsData.AddTabData(new SettingsTab("B", "icon-backward")); b.AddEntry(new SettingsEntryFloat("b-a", testDataBA = new BindableFloat(0f, -10f, 10f))); b.AddEntry(new SettingsEntryFloat("b-b", testDataBB = new BindableFloat(5f, 10f, 20f))); b.AddEntry(new SettingsEntryInt("b-c", testDataBC = new BindableInt(0, -20, 5))); } // Create nav bar. navBar = RootMain.CreateChild <NavBar>("nav-bar"); { navBar.Size = new Vector2(64f, 400f); navBar.SetSettingsData(settingsData); } }
public RadioButton(string label, Action action, Func <Drawable> createIcon = null) { Label = label; CreateIcon = createIcon; this.action = action; Selected = new BindableBool(); }
private SettingsTab CreateTabData(string name, string iconName) { BindableFloat bindableFloat = new BindableFloat(10f, -1, 20f); bindableFloat.OnValueChanged += (val, _) => Debug.Log($"{nameof(bindableFloat)} value: {val}"); Bindable<string> bindableString = new Bindable<string>("My Text"); bindableString.OnValueChanged += (val, _) => Debug.Log($"{nameof(bindableString)} value: {val}"); BindableInt bindableInt = new BindableInt(-10, -20, 0); bindableInt.OnValueChanged += (val, _) => Debug.Log($"{nameof(bindableInt)} value: {val}"); Bindable<TestType> bindableEnum = new Bindable<TestType>(TestType.TypeB); bindableEnum.OnValueChanged += (val, _) => Debug.Log($"{nameof(bindableEnum)} value: {val}"); BindableBool bindableBool = new BindableBool(false); bindableBool.OnValueChanged += (val, _) => Debug.Log($"{nameof(bindableBool)} value: {val}"); BindableBool bindableBool2 = new BindableBool(true); bindableBool2.OnValueChanged += (val, _) => Debug.Log($"{nameof(bindableBool2)} value: {val}"); var tabData = new SettingsTab(name, iconName); tabData.AddEntry(new SettingsEntryFloat(nameof(bindableFloat), bindableFloat)); tabData.AddEntry(new SettingsEntryString(nameof(bindableString), bindableString)); tabData.AddEntry(new SettingsEntryInt(nameof(bindableInt), bindableInt)); tabData.AddEntry(new SettingsEntryAction("Do action!", () => Debug.Log("Performed action"))); tabData.AddEntry(new SettingsEntryEnum<TestType>(nameof(bindableEnum), bindableEnum)); tabData.AddEntry(new SettingsEntryBool(nameof(bindableBool), bindableBool)); tabData.AddEntry(new SettingsEntryBool(nameof(bindableBool2), bindableBool2)); return tabData; }
public RadioButton(object item, Action action, Func <Drawable> createIcon = null) { Item = item; CreateIcon = createIcon; this.action = action; Selected = new BindableBool(); }
public void TestChangeThroughBindable() { BindableBool bindable = null; AddStep("bind bindable", () => switchButton.Current.BindTo(bindable = new BindableBool())); AddStep("toggle bindable", () => bindable.Toggle()); AddStep("toggle bindable", () => bindable.Toggle()); }
public void TestParsingBoolean(bool value) { var bindable = new BindableBool(); bindable.Parse(value); Assert.AreEqual(value, bindable.Value); }
public void TestParsingString(string value, bool expected) { var bindable = new BindableBool(); bindable.Parse(value); Assert.AreEqual(expected, bindable.Value); }
public void TestSet(bool value) { var bindable = new BindableBool { Value = value }; Assert.AreEqual(value, bindable.Value); }
/// <summary> /// Initializes the filter to toggle specified bindable data. /// </summary> public void Setup(BindableBool bindable) { UnbindEvents(); AdjustTouchArea(); this.bindable = bindable; BindEvents(); }
internal OptionCheckbox(string title, string tooltip, BindableBool binding = null, EventHandler onChange = null) : this(title, tooltip, binding != null ? binding.Value : false, onChange) { this.binding = binding; if (binding != null) { binding.ValueChanged += binding_ValueChanged; } }
protected BeatmapCard(APIBeatmapSet beatmapSet, bool allowExpansion = true) : base(HoverSampleSet.Button) { Expanded = new BindableBool { Disabled = !allowExpansion }; BeatmapSet = beatmapSet; FavouriteState = new Bindable <BeatmapSetFavouriteState>(new BeatmapSetFavouriteState(beatmapSet.HasFavourited, beatmapSet.FavouriteCount)); DownloadTracker = new BeatmapDownloadTracker(beatmapSet); }
public BeatmapCard(APIBeatmapSet beatmapSet, bool allowExpansion = true) : base(HoverSampleSet.Submit) { Expanded = new BindableBool { Disabled = !allowExpansion }; this.beatmapSet = beatmapSet; favouriteState = new Bindable <BeatmapSetFavouriteState>(new BeatmapSetFavouriteState(beatmapSet.HasFavourited, beatmapSet.FavouriteCount)); downloadTracker = new BeatmapDownloadTracker(beatmapSet); }
public KeyboardKey(KeyCode keyCode) { this.keyCode = keyCode; this.state = new Bindable <InputState>() { TriggerWhenDifferent = true }; this.isActive = new BindableBool() { TriggerWhenDifferent = true }; }
public void Test() { bool lastUpdated = false; var bindable = new BindableBool(); bindable.OnValueChanged += (v, _) => lastUpdated = v; Assert.IsFalse(bindable.Value); bindable.Value = true; Assert.IsTrue(bindable.Value); Assert.IsTrue(lastUpdated); }
protected Cursor(KeyCode keyCode, Vector2 resolution) { this.keyCode = keyCode; this.resolution = resolution; this.state = new Bindable <InputState>(InputState.Idle) { TriggerWhenDifferent = true }; this.isActive = new BindableBool(false) { TriggerWhenDifferent = true }; processScale = new Vector2(1f / Screen.width, 1f / Screen.height); }
private void Init() { BindableFloat bindableFloat = new BindableFloat(10f, -1, 20f); bindableFloat.OnValueChanged += (val, _) => Debug.Log($"{nameof(bindableFloat)} value: {val}"); Bindable <string> bindableString = new Bindable <string>("My Text"); bindableString.OnValueChanged += (val, _) => Debug.Log($"{nameof(bindableString)} value: {val}"); BindableInt bindableInt = new BindableInt(-10, -20, 0); bindableInt.OnValueChanged += (val, _) => Debug.Log($"{nameof(bindableInt)} value: {val}"); Bindable <TestType> bindableEnum = new Bindable <TestType>(TestType.TypeB); bindableEnum.OnValueChanged += (val, _) => Debug.Log($"{nameof(bindableEnum)} value: {val}"); BindableBool bindableBool = new BindableBool(false); bindableBool.OnValueChanged += (val, _) => Debug.Log($"{nameof(bindableBool)} value: {val}"); BindableBool bindableBool2 = new BindableBool(true); bindableBool2.OnValueChanged += (val, _) => Debug.Log($"{nameof(bindableBool2)} value: {val}"); tabData = new SettingsTab("A", "icon-arrow-left"); tabData.AddEntry(new SettingsEntryFloat(nameof(bindableFloat), bindableFloat)); tabData.AddEntry(new SettingsEntryString(nameof(bindableString), bindableString)); tabData.AddEntry(new SettingsEntryInt(nameof(bindableInt), bindableInt)); tabData.AddEntry(new SettingsEntryEnum <TestType>(nameof(bindableEnum), bindableEnum)); tabData.AddEntry(new SettingsEntryBool(nameof(bindableBool), bindableBool)); tabData.AddEntry(new SettingsEntryBool(nameof(bindableBool2), bindableBool2)); var bg = RootMain.CreateChild <UguiSprite>("bg", -1); { bg.Size = new Vector2(600f, 600f); bg.Alpha = 0.5f; } contentGroup = RootMain.CreateChild <ContentGroup>(); { contentGroup.Width = 400f; contentGroup.SetTabData(tabData); } }
public void TestEntryBool() { BindableBool data = new BindableBool(false); SettingsEntryBool boolEntry = new SettingsEntryBool("test-bool", data); Assert.AreEqual("test-bool", boolEntry.Name); Assert.AreEqual(data.Value, boolEntry.Value); boolEntry.Value = true; Assert.IsTrue(boolEntry.Value); Assert.IsTrue(data.Value); data.Value = false; Assert.IsFalse(boolEntry.Value); Assert.IsFalse(data.Value); }
public void TestParseBindableOfExactSameType() { var bindable1 = new BindableInt(); var bindable2 = new BindableDouble(); var bindable3 = new BindableBool(); var bindable4 = new Bindable <string>(); bindable1.Parse(new BindableInt(3)); bindable2.Parse(new BindableDouble(2.5)); bindable3.Parse(new BindableBool(true)); bindable4.Parse(new Bindable <string>("string value")); Assert.That(bindable1.Value, Is.EqualTo(3)); Assert.That(bindable2.Value, Is.EqualTo(2.5)); Assert.That(bindable3.Value, Is.EqualTo(true)); Assert.That(bindable4.Value, Is.EqualTo("string value")); // parsing bindable of different type should throw exception. Assert.Throws <ArgumentException>(() => bindable1.Parse(new BindableDouble(3.0))); }
public RadioButton(string text, Action action) { Text = text; Action = action; Selected = new BindableBool(); }
internal OptionCheckbox(OsuString title, BindableBool binding, EventHandler onChange = null) : this(LocalisationManager.GetString(title), LocalisationManager.GetString(title + 1), binding, onChange) { addKeyword(title.ToString()); }
public RadioButton(object item, Action action) { Item = item; this.action = action; Selected = new BindableBool(); }