(a00338777) v0.9.2.1
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using EventInput;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
public class GUIDropDown : GUIComponent
|
||||
public class GUIDropDown : GUIComponent, IKeyboardSubscriber
|
||||
{
|
||||
public delegate bool OnSelectedHandler(GUIComponent selected, object obj = null);
|
||||
public OnSelectedHandler OnSelected;
|
||||
@@ -42,10 +44,22 @@ namespace Barotrauma
|
||||
set { button.Enabled = value; }
|
||||
}
|
||||
|
||||
public GUIComponent Selected
|
||||
public GUIComponent SelectedComponent
|
||||
{
|
||||
get { return listBox.SelectedComponent; }
|
||||
}
|
||||
|
||||
public bool Selected
|
||||
{
|
||||
get
|
||||
{
|
||||
return Dropped;
|
||||
}
|
||||
set
|
||||
{
|
||||
Dropped = value;
|
||||
}
|
||||
}
|
||||
|
||||
public GUIListBox ListBox
|
||||
{
|
||||
@@ -69,6 +83,30 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public void ReceiveTextInput(char inputChar)
|
||||
{
|
||||
GUI.KeyboardDispatcher.Subscriber = null;
|
||||
}
|
||||
public void ReceiveTextInput(string text) { }
|
||||
public void ReceiveCommandInput(char command) { }
|
||||
|
||||
public void ReceiveSpecialInput(Keys key)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case Keys.Up:
|
||||
case Keys.Down:
|
||||
listBox.ReceiveSpecialInput(key);
|
||||
GUI.KeyboardDispatcher.Subscriber = this;
|
||||
break;
|
||||
case Keys.Enter:
|
||||
case Keys.Space:
|
||||
case Keys.Escape:
|
||||
GUI.KeyboardDispatcher.Subscriber = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private List<object> selectedDataMultiple = new List<object>();
|
||||
public IEnumerable<object> SelectedDataMultiple
|
||||
{
|
||||
@@ -287,6 +325,12 @@ namespace Barotrauma
|
||||
{
|
||||
OnDropped?.Invoke(this, userData);
|
||||
listBox.UpdateScrollBarSize();
|
||||
|
||||
GUI.KeyboardDispatcher.Subscriber = this;
|
||||
}
|
||||
else if (GUI.KeyboardDispatcher.Subscriber == this)
|
||||
{
|
||||
GUI.KeyboardDispatcher.Subscriber = null;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -343,6 +387,10 @@ namespace Barotrauma
|
||||
if (!listBoxRect.Contains(PlayerInput.MousePosition) && !button.Rect.Contains(PlayerInput.MousePosition))
|
||||
{
|
||||
Dropped = false;
|
||||
if (GUI.KeyboardDispatcher.Subscriber == this)
|
||||
{
|
||||
GUI.KeyboardDispatcher.Subscriber = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user