private void BtnSfoglia_MouseUp(object sender, MouseButtonEventArgs e) { switch (SelectorType) { case SelectorType.File: DialogUtils.File(x => { if (!string.IsNullOrEmpty(x)) { txtFilePath.Text = x; OnSelection?.Invoke(x); } }); break; case SelectorType.Folder: DialogUtils.Folder(x => { if (!string.IsNullOrEmpty(x)) { txtFilePath.Text = x; OnSelection?.Invoke(x); } }); break; default: break; } }
public void SetSpell(int spellID) { if (!usedSpells.ContainsKey(spellID)) { GameObject spellPrefab = SpellManager.instance.createSpell(transform, spellID); SpellBehavior spell = spellPrefab.GetComponent <SpellBehavior>(); spellRack.Add(spell); usedSpells[spellID] = spell; spellStatus[spellID] = true; } else { if (!spellStatus[spellID]) { spellRack.Add(usedSpells[spellID]); spellStatus[spellID] = true; } } if (!hasSpell) { hasSpell = true; selected = spellRack[0]; OnSelection?.Invoke(selected); } }
private void FireOnSelection(Campaign campaign, Mod mod) { if (OnSelection != null) { OnSelection.Invoke(this, new CampaignEventArgs(campaign, mod)); } }
/// <summary> /// Create a list menu /// </summary> public ListMenu(string menuDescription, string enumName, OnSelection callback, int X = 500, int Y = 100, int width = 280, int height = 520) : base(X, Y, Image.CreateRectangle(width, height)) { //enum magic Type enumType = Type.GetType(enumName); if (enumType == null) throw new ArgumentException("Specified enum type could not be found", nameof(enumName)); //save callback _callback = callback; //register callback for scene add OnAdded += OnAdd; //set enter to blocked on begin to avoid double-entering menus _blockedKeys[2] = true; //set background Graphic.Color = Color.Gray; //draw a info text _infoText = new Text(menuDescription, 48) { X = X, Color = Color.Black, Y = Y - 50 }; //define this entity as part of the menu pause group Group = (int) PauseGroups.Menu; //how to draw a menu follows float paddingPercentage = 0.1f; //Magic.Cast(how many items are in the enum?) int numberOfEnumItems = Enum.GetNames(enumType).Length; int paddingHeight = (int) ((height / numberOfEnumItems) * paddingPercentage); int paddingWidth = (int) ((width / numberOfEnumItems) * paddingPercentage); //height per item int itemHeight = ((height - ((paddingHeight * (numberOfEnumItems + 1)))) / numberOfEnumItems); int itemWidth = width - paddingWidth * 2; //list of the items in the enum Array enumList = Enum.GetValues(enumType);//A wild magical unicorn appears //add menu item for each enum item for (int i = 0; i < enumList.Length; i++){ MenuChoice newChoice = new MenuChoice(X + paddingWidth, Y + paddingHeight + (i * paddingHeight) + i * itemHeight, itemWidth, itemHeight, enumList.GetValue(i).ToString()); _choiceList.Add(newChoice); } }
/// <summary> /// Invokes selection of specified dropdown data. /// </summary> public void SelectData(DropdownData data) { if (IsSelectionMenu) { Selection = data; } OnSelection?.Invoke(data); }
/// <summary> /// Method called when the device has recognized a tap event /// </summary> /// <param name="args"></param> private void OnTap(TappedEventArgs args) { if (!gameObject.activeInHierarchy) { return; } OnSelection?.Invoke(this); }
public void Select() { if (IsSelected) { throw new Selectable.AlreadySelectedException(); } IsSelected = true; OnSelection?.Invoke(); }
private async void btnSelectWithoutFirst_Click(object sender, EventArgs e) { ToggleButtons(); lblStatus.Text = "Fetching..."; var selectionResult = await IsolationManager.FetchMembersWithoutFirst(); OnSelection?.Invoke(selectionResult); lblStatus.Text = "Fetching Done"; ToggleButtons(); }
private void Select(int selected) { int i = 0; foreach (var btn in Btns) { btn.Outlined = (i++) == selected; } OnSelection?.Invoke(selected); }
public void StartSelection(OnSelection onSelection, EntitySelectionType selectionType, int startIndex, params BattleEntity[] targets) { StartSelection(onSelection, selectionType, targets); //Works with the failsafe in the other overload if (Targets != null) { ChangeSelection(startIndex); } }
public void SelectSpell(int index) { if (spellRack.Count > 0) { Debug.Log("scrolled"); int realIndex = (index + spellRack.Count) % spellRack.Count; selected = spellRack[realIndex]; OnSelection?.Invoke(selected); } }
private void OnTap(TappedEventArgs args) { if (!gameObject.activeInHierarchy) { return; } if (!m_isHandDetected) { args.sourcePose.TryGetPosition(out m_handPosition); } OnSelection?.Invoke(this); }
public void StartSelection(OnSelection onSelection, EntitySelectionType selectionType, params BattleEntity[] targets) { Targets = targets; Selection = onSelection; SelectionType = selectionType; //Failsafe - end selection immediately if inputs are invalid if (Targets == null || Targets.Length == 0) { Debug.LogError($"Null or empty target array in {nameof(TargetSelectionMenu)}.{nameof(StartSelection)}, ending selection..."); EndSelection(); } }
public ListMenu(string menuDescription, List <string> choiceNames, OnSelection callback, int X = 500, int Y = 100, int width = 280, int height = 520) : base(X, Y, Image.CreateRectangle(width, height)) { //save callback _callback = callback; //register callback for scene add OnAdded += OnAdd; //set enter to blocked on begin to avoid double-entering menus _blockedKeys[2] = true; //set background Graphic.Color = Color.Gray; //draw a info text _infoText = new Text(menuDescription, 48) { X = X, Color = Color.Black, Y = Y - 50 }; //define this entity as part of the menu pause group Group = (int)PauseGroups.Menu; //how to draw a menu follows float paddingPercentage = 0.1f; //Magic.Cast(how many items are in the enum?) int numberOfEnumItems = choiceNames.Count; int paddingHeight = (int)((height / numberOfEnumItems) * paddingPercentage); int paddingWidth = (int)((width / numberOfEnumItems) * paddingPercentage); //height per item int itemHeight = ((height - ((paddingHeight * (numberOfEnumItems + 1)))) / numberOfEnumItems); int itemWidth = width - paddingWidth * 2; //add menu item for each enum item for (int i = 0; i < choiceNames.Count; i++) { MenuChoice newChoice = new MenuChoice(X + paddingWidth, Y + paddingHeight + (i * paddingHeight) + i * itemHeight, itemWidth, itemHeight, choiceNames[i]); _choiceList.Add(newChoice); } }
private void Selections_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { if (Selections == null) { ResultPanel.Children.Clear(); } var hasChanged = CheckItemsHasChanged(e); if (hasChanged) { OnSelection?.Invoke(Selections); } }
public void EndSelection() { CurSelection = 0; Targets = null; Selection = null; SelectionType = EntitySelectionType.Single; if (BattleUIManager.Instance.TopMenu != null) { BattleUIManager.Instance.PopMenu(); } Cursor.Reset(); }
private void AutoList_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (autoList.SelectedIndex <= -1) { CloseAutoSuggestionBox(); } else { CloseAutoSuggestionBox(); //Those are used for searching only so clear the text OnSelection.Invoke(this, autoList.SelectedItem.ToString()); autoTextBox.Text = null; //autoList.SelectedItem.ToString(); autoList.SelectedIndex = -1; } }
private void Initialize() { if (spellPrefabs.Length > 0) { foreach (GameObject go in spellPrefabs) { GameObject prefab = Instantiate(go, transform); SpellBehavior spell = prefab.GetComponent <SpellBehavior>(); spellRack.Add(spell); usedSpells[spell.spellStats.spellID] = spell; spellStatus[spell.spellStats.spellID] = true; } hasSpell = true; selected = spellRack[0]; OnSelection?.Invoke(selected); } }
public ItemSelection(IGameEngine engine, IItem item, OnSelection selectionDelegate) { InitializeComponent(); m_item = item; m_selection = selectionDelegate; m_options = engine.GameState.GetOptionsForInventoryItem(item); ActionList.ItemsSource = m_options; if (m_options.Count > 0) ActionList.SelectedIndex = 0; Description.Text = item.ItemDescription + "\n\n" + item.FlavorDescription; ParentWindow = null; }
//**************************************************************************************************** // //**************************************************************************************************** public UIItemList(GameObject paramRoot, string paramScrollView, string paramViewport, string paramContent, string paramScrollbar, string paramItemTemplate, OnSelection paramOnSelection) : base(paramRoot, paramScrollView, paramViewport, paramContent, paramScrollbar, paramItemTemplate, paramOnSelection) { }
public void Setup(Transform[] selectables) { this.selectables = selectables; Vector2 startPosition = transform.position; for (int i = 0; i < selectables.Length; i++) { Vector2 position = startPosition + Vector2.right * spacing * i; selectables[i].position = position; selectables[i].SetParent(transform); } transform.position = Vector2.right * (selectables.Length - 1) / 2; OnSelection?.Invoke(); isSelection = true; }
public UICutawayPanel(int cut) { BgAnim = 0; var ui = Content.Get().CustomUI; Background = ui.Get("cut_bg.png").Get(GameFacade.GraphicsDevice); DownButton = new UIStencilButton(ui.Get("cut_stencil_down.png").Get(GameFacade.GraphicsDevice)); DownButton.Position = new Vector2(12, 64); DownButton.Selected = (cut == 0); DownButton.OnButtonClick += (b) => { OnSelection?.Invoke(0); }; Add(DownButton); CutButton = new UIStencilButton(ui.Get("cut_stencil_away.png").Get(GameFacade.GraphicsDevice)); CutButton.Position = new Vector2(8, 128); CutButton.Selected = (cut == 1); CutButton.OnButtonClick += (b) => { OnSelection?.Invoke(1); }; Add(CutButton); UpButton = new UIStencilButton(ui.Get("cut_stencil_up.png").Get(GameFacade.GraphicsDevice)); UpButton.OnButtonClick += (b) => { OnSelection?.Invoke(2); }; UpButton.Selected = (cut == 2); UpButton.Position = new Vector2(24, 196); Add(UpButton); RoofButton = new UIStencilButton(ui.Get("cut_stencil_roof.png").Get(GameFacade.GraphicsDevice)); RoofButton.OnButtonClick += (b) => { OnSelection?.Invoke(3); }; RoofButton.Selected = (cut == 3); RoofButton.Position = new Vector2(54, 254); Add(RoofButton); Opacity = 0f; GameFacade.Screens.Tween.To(this, 0.3f, new Dictionary <string, float>() { { "Opacity", 1f }, { "BgAnim", 1f } }, TweenQuad.EaseOut); foreach (var child in Children) { ((UIStencilButton)child).Alpha = 0f; ((UIStencilButton)child).InflateHitbox(25, 5); GameFacade.Screens.Tween.To(child, 0.3f, new Dictionary <string, float>() { { "Alpha", 1f } }, TweenQuad.EaseOut); } }
public void RemoveSpell(int id) { if (hasSpell) { if (spellStatus.ContainsKey(id) && spellStatus[id]) { spellRack.Remove(usedSpells[id]); spellStatus[id] = false; if (selected.spellStats.spellID == id) { selected = null; } } if (spellRack.Count < 1) { hasSpell = false; selected = null; } OnSelection?.Invoke(selected); } }
//**************************************************************************************************** // //**************************************************************************************************** public UIItemListBase(GameObject paramRoot, string paramScrollView, string paramViewport, string paramContent, string paramScrollbar, string paramItemTemplate, OnSelection paramOnSelection) { GameObject scrl = CORE.HIERARCHY.Find(paramRoot, paramScrollView); viewport = CORE.HIERARCHY.FindXForm <RectTransform>(scrl, paramViewport); content = CORE.HIERARCHY.FindXForm <RectTransform>(scrl, paramContent); scrollbar = CORE.HIERARCHY.FindComp <UnityEngine.UI.Scrollbar>(scrl, paramScrollbar); itemTemplate = Resources.Load <GameObject>(paramItemTemplate); onSelection = paramOnSelection; datas = new List <UIListItemData>(); items = new List <UIListItem>(); dic = new Dictionary <int, UIListItem>(); pool = new ObjectPool <UIListItem>(256); selection = null; dirty = true; ConfigureViewport(); if (scrollbar != null) { scrollbar.onValueChanged.RemoveAllListeners(); scrollbar.onValueChanged.AddListener(delegate { dirty = true; }); } }
public override void Select(IEnumerable <Tag> tags) => OnSelection?.Invoke(this, tags);
/// <summary> /// Create a list menu /// </summary> public ListMenu(string menuDescription, string enumName, OnSelection callback, int X = 500, int Y = 100, int width = 280, int height = 520) : base(X, Y, Image.CreateRectangle(width, height)) { //enum magic Type enumType = Type.GetType(enumName); if (enumType == null) { throw new ArgumentException("Specified enum type could not be found", nameof(enumName)); } //save callback _callback = callback; //register callback for scene add OnAdded += OnAdd; //set enter to blocked on begin to avoid double-entering menus _blockedKeys[2] = true; //set background Graphic.Color = Color.Gray; //draw a info text _infoText = new Text(menuDescription, 48) { X = X, Color = Color.Black, Y = Y - 50 }; //define this entity as part of the menu pause group Group = (int)PauseGroups.Menu; //how to draw a menu follows float paddingPercentage = 0.1f; //Magic.Cast(how many items are in the enum?) int numberOfEnumItems = Enum.GetNames(enumType).Length; int paddingHeight = (int)((height / numberOfEnumItems) * paddingPercentage); int paddingWidth = (int)((width / numberOfEnumItems) * paddingPercentage); //height per item int itemHeight = ((height - ((paddingHeight * (numberOfEnumItems + 1)))) / numberOfEnumItems); int itemWidth = width - paddingWidth * 2; //list of the items in the enum Array enumList = Enum.GetValues(enumType);//A wild magical unicorn appears //add menu item for each enum item for (int i = 0; i < enumList.Length; i++) { MenuChoice newChoice = new MenuChoice(X + paddingWidth, Y + paddingHeight + (i * paddingHeight) + i * itemHeight, itemWidth, itemHeight, enumList.GetValue(i).ToString()); _choiceList.Add(newChoice); } }
public ListMenu(string menuDescription, List<string> choiceNames, OnSelection callback, int X = 500, int Y = 100, int width = 280, int height = 520) : base(X, Y, Image.CreateRectangle(width, height)) { //save callback _callback = callback; //register callback for scene add OnAdded += OnAdd; //set enter to blocked on begin to avoid double-entering menus _blockedKeys[2] = true; //set background Graphic.Color = Color.Gray; //draw a info text _infoText = new Text(menuDescription, 48) { X = X, Color = Color.Black, Y = Y - 50 }; //define this entity as part of the menu pause group Group = (int)PauseGroups.Menu; //how to draw a menu follows float paddingPercentage = 0.1f; //Magic.Cast(how many items are in the enum?) int numberOfEnumItems = choiceNames.Count; int paddingHeight = (int)((height / numberOfEnumItems) * paddingPercentage); int paddingWidth = (int)((width / numberOfEnumItems) * paddingPercentage); //height per item int itemHeight = ((height - ((paddingHeight * (numberOfEnumItems + 1)))) / numberOfEnumItems); int itemWidth = width - paddingWidth * 2; //add menu item for each enum item for (int i = 0; i < choiceNames.Count; i++) { MenuChoice newChoice = new MenuChoice(X + paddingWidth, Y + paddingHeight + (i * paddingHeight) + i * itemHeight, itemWidth, itemHeight, choiceNames[i]); _choiceList.Add(newChoice); } }
public void OnMouseLeftDownAction() { OnSelection?.Invoke(this); }