(bad1f3738) Added search bars to sub lists in campaign setup UI and sub editor. Closes #1415
This commit is contained in:
@@ -76,6 +76,20 @@ namespace Barotrauma
|
||||
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.02f), leftColumn.RectTransform) { MinSize = new Point(0, 20) }, TextManager.Get("SelectedSub") + ":");
|
||||
subList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.65f), leftColumn.RectTransform)) { ScrollBarVisible = true };
|
||||
|
||||
var filterContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.07f), leftColumn.RectTransform), isHorizontal: true)
|
||||
{
|
||||
Stretch = true,
|
||||
RelativeSpacing = 0.02f
|
||||
};
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.3f, 1.0f), filterContainer.RectTransform), TextManager.Get("FilterMapEntities"), textAlignment: Alignment.CenterLeft, font: GUI.Font);
|
||||
var searchBox = new GUITextBox(new RectTransform(new Vector2(0.9f, 1.0f), filterContainer.RectTransform), font: GUI.Font);
|
||||
|
||||
searchBox.OnTextChanged += (textBox, text) => { FilterSubs(subList, text); return true; };
|
||||
var clearButton = new GUIButton(new RectTransform(new Vector2(0.15f, 1.0f), filterContainer.RectTransform), "x")
|
||||
{
|
||||
OnClicked = (btn, userdata) => { searchBox.Text = ""; FilterSubs(subList, ""); searchBox.Flash(Color.White); return true; }
|
||||
};
|
||||
|
||||
if (!isMultiplayer) { subList.OnSelected = OnSubSelected; }
|
||||
|
||||
@@ -186,6 +200,16 @@ namespace Barotrauma
|
||||
seedBox.Text = ToolBox.RandomSeed(8);
|
||||
}
|
||||
|
||||
private void FilterSubs(GUIListBox subList, string filter)
|
||||
{
|
||||
foreach (GUIComponent child in subList.Content.Children)
|
||||
{
|
||||
var sub = child.UserData as Submarine;
|
||||
if (sub == null) { return; }
|
||||
child.Visible = string.IsNullOrEmpty(filter) ? true : sub.Name.ToLower().Contains(filter.ToLower());
|
||||
}
|
||||
}
|
||||
|
||||
private bool OnSubSelected(GUIComponent component, object obj)
|
||||
{
|
||||
if (subPreviewContainer == null) { return false; }
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace Barotrauma
|
||||
var outpostBtn = new GUIButton(new RectTransform(new Vector2(0.15f, 0.55f), topPanelContent.RectTransform),
|
||||
TextManager.Get("Outpost"), textAlignment: Alignment.Center, style: "GUISlopedHeader")
|
||||
{
|
||||
OnClicked = (btn, userdata) => { SelectTab(Tab.Map); return true; }
|
||||
OnClicked = (btn, userdata) => { SelectTab(Tab.Map); return true; }
|
||||
};
|
||||
outpostBtn.TextBlock.Font = GUI.LargeFont;
|
||||
outpostBtn.TextBlock.AutoScale = true;
|
||||
|
||||
@@ -1287,6 +1287,7 @@ namespace Barotrauma
|
||||
if (CharacterMode) SetCharacterMode(false);
|
||||
if (WiringMode) SetWiringMode(false);
|
||||
|
||||
|
||||
loadFrame = new GUIButton(new RectTransform(Vector2.One, GUI.Canvas), style: "GUIBackgroundBlocker")
|
||||
{
|
||||
OnClicked = (btn, userdata) => { if (GUI.MouseOn == btn || GUI.MouseOn == btn.TextBlock) loadFrame = null; return true; },
|
||||
@@ -1294,10 +1295,9 @@ namespace Barotrauma
|
||||
|
||||
var innerFrame = new GUIFrame(new RectTransform(new Vector2(0.2f, 0.36f), loadFrame.RectTransform, Anchor.Center) { MinSize = new Point(350, 500) });
|
||||
|
||||
var paddedLoadFrame = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.9f), innerFrame.RectTransform, Anchor.Center)) { Stretch = true, RelativeSpacing = 0.05f };
|
||||
var paddedLoadFrame = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.9f), innerFrame.RectTransform, Anchor.Center)) { Stretch = true, RelativeSpacing = 0.02f };
|
||||
|
||||
var deleteButtonHolder = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.1f), paddedLoadFrame.RectTransform, Anchor.Center));
|
||||
|
||||
var subList = new GUIListBox(new RectTransform(new Vector2(1.0f, 1.0f), paddedLoadFrame.RectTransform))
|
||||
{
|
||||
ScrollBarVisible = true,
|
||||
@@ -1308,6 +1308,19 @@ namespace Barotrauma
|
||||
}
|
||||
};
|
||||
|
||||
var filterContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.1f), paddedLoadFrame.RectTransform), isHorizontal: true)
|
||||
{
|
||||
Stretch = true,
|
||||
RelativeSpacing = 0.02f
|
||||
};
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.3f, 1.0f), filterContainer.RectTransform), TextManager.Get("FilterMapEntities"), textAlignment: Alignment.CenterLeft, font: GUI.Font);
|
||||
var searchBox = new GUITextBox(new RectTransform(new Vector2(0.9f, 1.0f), filterContainer.RectTransform), font: GUI.Font);
|
||||
searchBox.OnTextChanged += (textBox, text) => { FilterSubs(subList, text); return true; };
|
||||
var clearButton = new GUIButton(new RectTransform(new Vector2(0.15f, 1.0f), filterContainer.RectTransform), "x")
|
||||
{
|
||||
OnClicked = (btn, userdata) => { searchBox.Text = ""; FilterSubs(subList, ""); searchBox.Flash(Color.White); return true; }
|
||||
};
|
||||
|
||||
foreach (Submarine sub in Submarine.SavedSubmarines)
|
||||
{
|
||||
GUITextBlock textBlock = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.1f), subList.Content.RectTransform) { MinSize = new Point(0, 30) },
|
||||
@@ -1368,6 +1381,16 @@ namespace Barotrauma
|
||||
return true;
|
||||
}
|
||||
|
||||
private void FilterSubs(GUIListBox subList, string filter)
|
||||
{
|
||||
foreach (GUIComponent child in subList.Content.Children)
|
||||
{
|
||||
var sub = child.UserData as Submarine;
|
||||
if (sub == null) { return; }
|
||||
child.Visible = string.IsNullOrEmpty(filter) ? true : sub.Name.ToLower().Contains(filter.ToLower());
|
||||
}
|
||||
}
|
||||
|
||||
private bool LoadSub(GUIButton button, object obj)
|
||||
{
|
||||
if (loadFrame == null)
|
||||
|
||||
Reference in New Issue
Block a user