(eba811de) Unstable 0.9.703.0

This commit is contained in:
Juan Pablo Arce
2020-02-04 11:54:57 -03:00
parent 15499cb704
commit 08ab6185c4
100 changed files with 2162 additions and 1520 deletions
@@ -78,7 +78,7 @@ namespace Barotrauma
OnClicked = (btn, userdata) => { SelectTab(Tab.Map); return true; }
};
outpostBtn.TextBlock.Font = GUI.LargeFont;
outpostBtn.TextBlock.AutoScale = true;
outpostBtn.TextBlock.AutoScaleHorizontal = true;
var tabButtonContainer = new GUILayoutGroup(new RectTransform(new Vector2(0.4f, 0.4f), topPanelContent.RectTransform, Anchor.BottomLeft), isHorizontal: true);
@@ -161,7 +161,7 @@ namespace Barotrauma
{
UserData = "mycrew",
CanBeFocused = false,
AutoScale = true
AutoScaleHorizontal = true
};
if (campaign is SinglePlayerCampaign)
{
@@ -170,7 +170,7 @@ namespace Barotrauma
{
UserData = "hire",
CanBeFocused = false,
AutoScale = true
AutoScaleHorizontal = true
};
}
@@ -210,6 +210,7 @@ namespace Barotrauma
searchBox = new GUITextBox(new RectTransform(new Vector2(1.0f, 1.0f), filterContainer.RectTransform), createClearButton: true);
searchBox.OnSelected += (sender, userdata) => { searchTitle.Visible = false; };
searchBox.OnDeselected += (sender, userdata) => { searchTitle.Visible = true; };
searchBox.OnTextChanged += (textBox, text) => { FilterStoreItems(null, text); return true; };
var storeItemLists = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.8f), storeContent.RectTransform), isHorizontal: true)
{
@@ -256,7 +257,7 @@ namespace Barotrauma
TextManager.Get("MapEntityCategory." + category), textAlignment: Alignment.Center, textColor: categoryButton.TextColor)
{
Padding = Vector4.Zero,
AutoScale = true,
AutoScaleHorizontal = true,
Color = Color.Transparent,
HoverColor = Color.Transparent,
PressedColor = Color.Transparent,
@@ -454,7 +455,7 @@ namespace Barotrauma
textAlignment: Alignment.Center, font: GUI.LargeFont, style: "GUISlopedHeader")
{
UserData = "missionlabel",
AutoScale = true
AutoScaleHorizontal = true
};
var missionPanelContent = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.95f), missionPanel.RectTransform, Anchor.Center))
{
@@ -468,10 +469,11 @@ namespace Barotrauma
Stretch = true
};
selectedMissionInfo = new GUIListBox(new RectTransform(new Vector2(0.9f, 0.25f), missionPanel.RectTransform, Anchor.BottomRight, Pivot.TopRight)
{ MinSize = new Point(0, (int)(250 * GUI.Scale)) })
{ MinSize = new Point(0, (int)(150 * GUI.Scale)) })
{
Visible = false
};
selectedMissionInfo.RectTransform.MaxSize = new Point(int.MaxValue, selectedMissionInfo.Rect.Height * 2);
new GUIFrame(new RectTransform(new Vector2(1.25f, 1.25f), selectedMissionInfo.RectTransform, Anchor.Center), style: "OuterGlow", color: Color.Black * 0.9f)
{
UserData = "outerglow",
@@ -676,7 +678,7 @@ namespace Barotrauma
var container = selectedLocationInfo;
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), container.RectTransform), location.Name, font: GUI.LargeFont)
{
AutoScale = true
AutoScaleHorizontal = true
};
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), container.RectTransform), location.Type.Name, font: GUI.SubHeadingFont);
@@ -686,7 +688,7 @@ namespace Barotrauma
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), container.RectTransform), TextManager.Get("SelectMission"), font: GUI.SubHeadingFont)
{
AutoScale = true
AutoScaleHorizontal = true
};
var missionFrame = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.3f), container.RectTransform), style: "InnerFrame");
@@ -784,13 +786,13 @@ namespace Barotrauma
selectedMissionInfo.ClearChildren();
var container = selectedMissionInfo.Content;
selectedMissionInfo.Visible = selectedMission != null;
selectedMissionInfo.Spacing = 10;
selectedMissionInfo.Spacing = (int)(10 * GUI.Scale);
if (selectedMission == null) { return; }
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), container.RectTransform),
selectedMission.Name, font: GUI.LargeFont)
{
AutoScale = true,
AutoScaleHorizontal = true,
CanBeFocused = false
};
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), container.RectTransform),
@@ -804,6 +806,12 @@ namespace Barotrauma
CanBeFocused = false
};
//scale down mission info box if it's much taller than the text
float missionInfoHeight = selectedMissionInfo.Content.Children.Sum(c => c.Rect.Height + selectedMissionInfo.Spacing);
selectedMissionInfo.Content.Children.ForEach(c => c.RectTransform.IsFixedSize = true);
selectedMissionInfo.RectTransform.Resize(new Point(selectedMissionInfo.Rect.Width, (int)(missionInfoHeight + 15 * GUI.Scale)));
selectedMissionInfo.UpdateScrollBarSize();
if (StartButton != null)
{
StartButton.Enabled = true;
@@ -1897,7 +1897,7 @@ namespace Barotrauma.CharacterEditor
}
// Create the areas
rightArea = new GUILayoutGroup(new RectTransform(new Vector2(0.15f, 0.95f), parent: Frame.RectTransform, anchor: Anchor.CenterRight), childAnchor: Anchor.BottomRight)
rightArea = new GUILayoutGroup(new RectTransform(new Vector2(0.15f, 1.0f), parent: Frame.RectTransform, anchor: Anchor.CenterRight), childAnchor: Anchor.BottomRight)
{
RelativeSpacing = 0.02f
};
@@ -1917,6 +1917,14 @@ namespace Barotrauma.CharacterEditor
CreateFileEditPanel();
CreateOptionsPanel(toggleSize);
CreateCharacterSelectionPanel();
if (rightArea.RectTransform.Children.Sum(c => c.Rect.Height) > GameMain.GraphicsHeight)
{
fileEditPanel.GetAllChildren().Where(c => c is GUIButton).ForEach(b => b.RectTransform.MinSize = ((GUIButton)b).Frame.RectTransform.MinSize = b.RectTransform.MinSize.Multiply(new Vector2(1.0f, 0.75f)));
fileEditPanel.RectTransform.MinSize = new Point(0, (int)(fileEditPanel.GetChild<GUILayoutGroup>().RectTransform.Children.Sum(c => c.Rect.Height) / innerScale.Y));
optionsPanel.GetAllChildren().Where(c => c is GUITickBox).ForEach(t => t.RectTransform.MinSize = t.RectTransform.MinSize.Multiply(new Vector2(1.0f, 0.75f)));
optionsPanel.RectTransform.MinSize = new Point(0, (int)(optionsPanel.GetChild<GUILayoutGroup>().RectTransform.Children.Sum(c => c.Rect.Height) / innerScale.Y));
rightArea.Recalculate();
}
CreateButtonsPanel();
CreateModesPanel(toggleSize);
@@ -2686,14 +2694,14 @@ namespace Barotrauma.CharacterEditor
}
var charButtons = new GUIFrame(new RectTransform(new Vector2(1, 0.25f), parent: content.RectTransform, anchor: Anchor.BottomLeft), style: null);
var prevCharacterButton = new GUIButton(new RectTransform(new Vector2(0.5f, 1.0f), charButtons.RectTransform, Anchor.TopLeft), GetCharacterEditorTranslation("PreviousCharacter"));
prevCharacterButton.TextBlock.AutoScale = true;
prevCharacterButton.TextBlock.AutoScaleHorizontal = true;
prevCharacterButton.OnClicked += (b, obj) =>
{
SpawnCharacter(GetPreviousConfigFile());
return true;
};
var nextCharacterButton = new GUIButton(new RectTransform(new Vector2(0.5f, 1.0f), charButtons.RectTransform, Anchor.TopRight), GetCharacterEditorTranslation("NextCharacter"));
prevCharacterButton.TextBlock.AutoScale = true;
prevCharacterButton.TextBlock.AutoScaleHorizontal = true;
nextCharacterButton.OnClicked += (b, obj) =>
{
SpawnCharacter(GetNextConfigFile());
@@ -3151,7 +3159,6 @@ namespace Barotrauma.CharacterEditor
public ToggleButton(RectTransform rectT, Direction dir)
{
rectT.MaxSize = new Point(int.MaxValue, (int)(100 * GUI.Scale));
toggleButton = new GUIButton(rectT, style: "UIToggleButton")
{
OnClicked = (button, data) =>
@@ -157,7 +157,7 @@ namespace Barotrauma
//(= the background texture that's revealed when a wall is destroyed) into the background render target
//These will be visible through the LOS effect.
spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.NonPremultiplied, null, DepthStencilState.None, null, null, cam.Transform);
Submarine.DrawBack(spriteBatch, false, e => e is Structure s);
Submarine.DrawBack(spriteBatch, false, e => e is Structure s && (e.SpriteDepth >= 0.9f || s.Prefab.BackgroundSprite != null));
spriteBatch.End();
graphics.SetRenderTarget(null);
@@ -201,7 +201,7 @@ namespace Barotrauma
spriteBatch.End();
//Draw the rest of the structures, characters and front structures
spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.NonPremultiplied, null, DepthStencilState.None, null, null, cam.Transform);
Submarine.DrawBack(spriteBatch, false, s => !(s is Structure));
Submarine.DrawBack(spriteBatch, false, e => !(e is Structure) || e.SpriteDepth < 0.9f);
foreach (Character c in Character.CharacterList)
{
if (c.AnimController.Limbs.Any(l => l.DeformSprite != null) || !c.IsVisible) { continue; }
@@ -784,12 +784,12 @@ namespace Barotrauma
};
shuttleTickBox.TextBlock.RectTransform.SizeChanged += () =>
{
shuttleTickBox.TextBlock.AutoScale = true;
shuttleTickBox.TextBlock.AutoScaleHorizontal = true;
shuttleTickBox.TextBlock.TextScale = 1.0f;
if (shuttleTickBox.TextBlock.TextScale < 0.75f)
{
shuttleTickBox.TextBlock.Wrap = true;
shuttleTickBox.TextBlock.AutoScale = true;
shuttleTickBox.TextBlock.AutoScaleHorizontal = true;
shuttleTickBox.TextBlock.TextScale = 1.0f;
}
};
@@ -831,13 +831,13 @@ namespace Barotrauma
if (child is GUITextBlock textBlock)
{
textBlock.TextScale = 1;
textBlock.AutoScale = true;
textBlock.AutoScaleHorizontal = true;
textBlock.SetTextPos();
}
else if (child is GUITickBox tickBox)
{
tickBox.TextBlock.TextScale = 1;
tickBox.TextBlock.AutoScale = true;
tickBox.TextBlock.AutoScaleHorizontal = true;
tickBox.TextBlock.SetTextPos();
}
}
@@ -1827,7 +1827,7 @@ namespace Barotrauma
{
UserData = selectedClient
};
viewSteamProfileButton.TextBlock.AutoScale = true;
viewSteamProfileButton.TextBlock.AutoScaleHorizontal = true;
viewSteamProfileButton.OnClicked = (bt, userdata) =>
{
Steamworks.SteamFriends.OpenWebOverlay("https://steamcommunity.com/profiles/" + selectedClient.SteamID.ToString());
@@ -2694,7 +2694,7 @@ namespace Barotrauma
SelectedColor = Color.Transparent,
TextColor = jobPrefab.UIColor,
CanBeFocused = false,
AutoScale = true
AutoScaleHorizontal = true
};
textBlock.RectTransform.SizeChanged += () => { textBlock.TextScale = 1.0f; };
@@ -185,7 +185,7 @@ namespace Barotrauma
{
Padding = Vector4.Zero,
ForceUpperCase = true,
AutoScale = true
AutoScaleHorizontal = true
};
var infoHolder = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.33f), topRow.RectTransform), isHorizontal: true, Anchor.BottomLeft) { RelativeSpacing = 0.01f, Stretch = false };
@@ -279,7 +279,7 @@ namespace Barotrauma
var filterTitle = new GUITextBlock(new RectTransform(new Vector2(1.0f, elementHeight), filtersHolder.RectTransform), TextManager.Get("FilterServers"), font: GUI.SubHeadingFont)
{
Padding = Vector4.Zero,
AutoScale = true,
AutoScaleHorizontal = true,
CanBeFocused = false
};
@@ -1608,7 +1608,6 @@ namespace Barotrauma
if (serverInfo.OwnerVerified)
{
DebugConsole.NewMessage(serverInfo.OwnerID + " verified!");
var childrenToRemove = serverList.Content.FindChildren(c => (c.UserData is ServerInfo info) && info != serverInfo &&
(serverInfo.OwnerID != 0 ? info.OwnerID == serverInfo.OwnerID : info.IP == serverInfo.IP)).ToList();
foreach (var child in childrenToRemove)
@@ -1637,7 +1636,7 @@ namespace Barotrauma
var compatibleBox = new GUITickBox(new RectTransform(new Vector2(columnRelativeWidth[0], 0.9f), serverContent.RectTransform, Anchor.Center), label: "")
{
Enabled = false,
CanBeFocused = false,
Selected =
serverInfo.GameVersion == GameMain.Version.ToString() &&
serverInfo.ContentPackagesMatch(GameMain.SelectedPackages),
@@ -1648,7 +1647,7 @@ namespace Barotrauma
{
ToolTip = TextManager.Get((serverInfo.HasPassword) ? "ServerListHasPassword" : "FilterPassword"),
Selected = serverInfo.HasPassword,
Enabled = false,
CanBeFocused = false,
UserData = "password"
};
@@ -1659,12 +1658,17 @@ namespace Barotrauma
((serverInfo.OwnerID != 0 || serverInfo.LobbyID != 0) ? "[STEAMP2P] " : "[LIDGREN] ") + serverInfo.ServerName,
#endif
style: "GUIServerListTextBox");
serverName.UserData = serverName.Text;
serverName.RectTransform.SizeChanged += () =>
{
serverName.Text = ToolBox.LimitString(serverName.Text, serverName.Font, serverName.Rect.Width);
};
new GUITickBox(new RectTransform(new Vector2(columnRelativeWidth[3], 0.9f), serverContent.RectTransform, Anchor.Center), label: "")
{
ToolTip = TextManager.Get((serverInfo.GameStarted) ? "ServerListRoundStarted" : "ServerListRoundNotStarted"),
Selected = serverInfo.GameStarted,
Enabled = false
CanBeFocused = false
};
var serverPlayers = new GUITextBlock(new RectTransform(new Vector2(columnRelativeWidth[4], 1.0f), serverContent.RectTransform),
@@ -162,7 +162,7 @@ namespace Barotrauma
return true;
}
};
resetBtn.TextBlock.AutoScale = true;
resetBtn.TextBlock.AutoScaleHorizontal = true;
new GUITickBox(new RectTransform(new Vector2(0.2f, 0.2f), topPanelContents.RectTransform, Anchor.BottomCenter, Pivot.CenterRight) { RelativeOffset = new Vector2(0, 0.3f) }, TextManager.Get("spriteeditor.showgrid"))
{
@@ -868,7 +868,7 @@ namespace Barotrauma
t.RectTransform.SizeChanged += () =>
{
t.TextScale = 1.0f;
t.AutoScale = true;
t.AutoScaleHorizontal = true;
};
}
@@ -1096,25 +1096,20 @@ namespace Barotrauma
{
var tagBtn = new GUIButton(new RectTransform(new Vector2(0.25f, 1.0f), tagHolder.Content.RectTransform, anchor: Anchor.CenterLeft),
tag.CapitaliseFirstInvariant(), style: "GUIButtonRound");
tagBtn.TextBlock.AutoScale = true;
tagBtn.TextBlock.AutoScaleHorizontal = true;
tagBtn.Selected = itemEditor?.Tags?.Any(t => t.ToLowerInvariant() == tag) ?? false;
Color defaultTextColor = tagBtn.TextColor;
tagBtn.TextColor = tagBtn.Selected ? GUI.Style.Green : defaultTextColor;
tagBtn.OnClicked = (btn, userdata) =>
{
if (!tagBtn.Selected)
{
if (!(itemEditor?.Tags?.Any(t => t.ToLowerInvariant() == tag) ?? false)) { itemEditor = itemEditor?.WithTag(tagBtn.Text); }
tagBtn.Selected = true;
tagBtn.TextColor = GUI.Style.Green;
}
else
{
itemEditor?.Tags?.RemoveAll(t => t.ToLowerInvariant() == tagBtn.Text.ToLowerInvariant());
tagBtn.Selected = false;
tagBtn.TextColor = defaultTextColor;
}
return true;
};
@@ -1387,7 +1382,7 @@ namespace Barotrauma
return true;
}
};
publishBtn.TextBlock.AutoScale = true;
publishBtn.TextBlock.AutoScaleHorizontal = true;
}
private void OnPreviewImageSelected(GUIImage previewImageElement, string filePath)
@@ -38,6 +38,8 @@ namespace Barotrauma
private GUIComponent showEntitiesPanel, entityCountPanel;
private List<GUITickBox> showEntitiesTickBoxes = new List<GUITickBox>();
private GUITextBlock subNameLabel;
private bool entityMenuOpen = true;
private float entityMenuOpenState = 1.0f;
public GUIComponent EntityMenu;
@@ -45,11 +47,16 @@ namespace Barotrauma
private GUIListBox entityList;
private GUIButton toggleEntityMenuButton;
private GUITickBox defaultModeTickBox, wiringModeTickBox, characterModeTickBox;
private GUIComponent loadFrame, saveFrame;
private GUITextBox nameBox, descriptionBox;
private GUIButton selectedCategoryButton;
private GUITextBlock selectedCategoryText;
private readonly List<GUIButton> entityCategoryButtons = new List<GUIButton>();
private MapEntityCategory? selectedCategory;
private GUIFrame hullVolumeFrame;
@@ -61,8 +68,6 @@ namespace Barotrauma
private GUIDropDown linkedSubBox;
private GUIRadioButtonGroup modeButtonGroup;
//a Character used for picking up and manipulating items
private Character dummyCharacter;
@@ -89,15 +94,10 @@ namespace Barotrauma
get { return cam; }
}
public string GetSubName()
{
return (Submarine.MainSub == null) ? "" : Submarine.MainSub.Name;
}
public string GetSubDescription()
{
string localizedDescription = TextManager.Get("submarine.description." + GetSubName(), true);
if (localizedDescription != null) return localizedDescription;
string localizedDescription = TextManager.Get("submarine.description." + (Submarine.MainSub?.Name ?? ""), true);
if (localizedDescription != null) { return localizedDescription; }
return (Submarine.MainSub == null) ? "" : Submarine.MainSub.Description;
}
@@ -214,11 +214,8 @@ namespace Barotrauma
new GUIFrame(new RectTransform(new Vector2(0.01f, 0.9f), paddedTopPanel.RectTransform), style: "VerticalLine");
var nameLabel = new GUITextBlock(new RectTransform(new Vector2(0.1f, 0.9f), paddedTopPanel.RectTransform, Anchor.CenterLeft),
"", font: GUI.LargeFont, textAlignment: Alignment.CenterLeft)
{
TextGetter = GetSubName
};
subNameLabel = new GUITextBlock(new RectTransform(new Vector2(0.3f, 0.9f), paddedTopPanel.RectTransform, Anchor.CenterLeft),
TextManager.Get("unspecifiedsubfilename"), font: GUI.LargeFont, textAlignment: Alignment.CenterLeft);
linkedSubBox = new GUIDropDown(new RectTransform(new Vector2(0.15f, 0.9f), paddedTopPanel.RectTransform),
TextManager.Get("AddSubButton"), elementCount: 20)
@@ -238,52 +235,36 @@ namespace Barotrauma
new GUIFrame(new RectTransform(new Vector2(0.01f, 0.9f), paddedTopPanel.RectTransform), style: "VerticalLine");
modeButtonGroup = new GUIRadioButtonGroup();
var defaultModeTickBox = new GUITickBox(new RectTransform(new Vector2(0.9f, 0.9f), paddedTopPanel.RectTransform, scaleBasis: ScaleBasis.BothHeight), "", style: "EditSubButton")
defaultModeTickBox = new GUITickBox(new RectTransform(new Vector2(0.9f, 0.9f), paddedTopPanel.RectTransform, scaleBasis: ScaleBasis.BothHeight), "", style: "EditSubButton")
{
ToolTip = TextManager.Get("SubEditorEditingMode"),
OnSelected = (GUITickBox tBox) =>
{
if (tBox.Selected)
{
SetMode(Mode.Default);
}
if (tBox.Selected) { SetMode(Mode.Default); }
return true;
}
};
var characterModeTickBox = new GUITickBox(new RectTransform(new Vector2(0.9f, 0.9f), paddedTopPanel.RectTransform, scaleBasis: ScaleBasis.BothHeight), "", style: "CharacterModeButton")
characterModeTickBox = new GUITickBox(new RectTransform(new Vector2(0.9f, 0.9f), paddedTopPanel.RectTransform, scaleBasis: ScaleBasis.BothHeight), "", style: "CharacterModeButton")
{
ToolTip = TextManager.Get("CharacterModeButton") + '\n' + TextManager.Get("CharacterModeToolTip"),
OnSelected = (GUITickBox tBox) =>
{
if (tBox.Selected)
{
SetMode(Mode.Character);
}
SetMode(tBox.Selected ? Mode.Character : Mode.Default);
return true;
}
};
var wiringModeTickBox = new GUITickBox(new RectTransform(new Vector2(0.9f, 0.9f), paddedTopPanel.RectTransform, scaleBasis: ScaleBasis.BothHeight), "", style: "WiringModeButton")
wiringModeTickBox = new GUITickBox(new RectTransform(new Vector2(0.9f, 0.9f), paddedTopPanel.RectTransform, scaleBasis: ScaleBasis.BothHeight), "", style: "WiringModeButton")
{
ToolTip = TextManager.Get("WiringModeButton") + '\n' + TextManager.Get("WiringModeToolTip"),
OnSelected = (GUITickBox tBox) =>
{
if (tBox.Selected)
{
SetMode(Mode.Wiring);
}
SetMode(tBox.Selected ? Mode.Wiring : Mode.Default);
return true;
}
};
modeButtonGroup.AddRadioButton((int)Mode.Default, defaultModeTickBox);
modeButtonGroup.AddRadioButton((int)Mode.Character, characterModeTickBox);
modeButtonGroup.AddRadioButton((int)Mode.Wiring, wiringModeTickBox);
modeButtonGroup.Selected = (int)Mode.Default;
new GUIFrame(new RectTransform(new Vector2(0.01f, 0.9f), paddedTopPanel.RectTransform), style: "VerticalLine");
new GUIButton(new RectTransform(new Vector2(0.9f, 0.9f), paddedTopPanel.RectTransform, scaleBasis: ScaleBasis.BothHeight), "", style: "GenerateWaypointsButton")
@@ -294,7 +275,7 @@ namespace Barotrauma
new GUIFrame(new RectTransform(new Vector2(0.01f, 0.9f), paddedTopPanel.RectTransform), style: "VerticalLine");
var visibilityButton = new GUIButton(new RectTransform(new Vector2(0.15f, 0.9f), paddedTopPanel.RectTransform, scaleBasis: ScaleBasis.BothHeight), "", style: "SetupVisibilityButton")
var visibilityButton = new GUIButton(new RectTransform(new Vector2(0.9f, 0.9f), paddedTopPanel.RectTransform, scaleBasis: ScaleBasis.BothHeight), "", style: "SetupVisibilityButton")
{
ToolTip = TextManager.Get("SubEditorVisibilityButton") + '\n' + TextManager.Get("SubEditorVisibilityToolTip"),
OnClicked = (btn, userData) =>
@@ -306,7 +287,7 @@ namespace Barotrauma
}
};
var previouslyUsedButton = new GUIButton(new RectTransform(new Vector2(0.15f, 0.9f), paddedTopPanel.RectTransform, scaleBasis: ScaleBasis.BothHeight), "", style: "RecentlyUsedButton")
var previouslyUsedButton = new GUIButton(new RectTransform(new Vector2(0.9f, 0.9f), paddedTopPanel.RectTransform, scaleBasis: ScaleBasis.BothHeight), "", style: "RecentlyUsedButton")
{
ToolTip = TextManager.Get("PreviouslyUsedLabel"),
OnClicked = (btn, userData) =>
@@ -536,7 +517,7 @@ namespace Barotrauma
Visible = false
};
var saveAssemblyButton = new GUIButton(new RectTransform(new Vector2(0.9f, 0.8f), saveAssemblyFrame.RectTransform, Anchor.Center), TextManager.Get("SaveItemAssembly"));
saveAssemblyButton.TextBlock.AutoScale = true;
saveAssemblyButton.TextBlock.AutoScaleHorizontal = true;
saveAssemblyButton.OnClicked += (btn, userdata) =>
{
CreateSaveAssemblyScreen();
@@ -567,7 +548,7 @@ namespace Barotrauma
var paddedTab = new GUILayoutGroup(new RectTransform(new Vector2(0.98f, 0.96f), EntityMenu.RectTransform, Anchor.BottomCenter), childAnchor: Anchor.TopCenter)
{
RelativeSpacing = 0.05f,
RelativeSpacing = 0.04f,
Stretch = true
};
@@ -576,22 +557,28 @@ namespace Barotrauma
Stretch = true
};
var selectedCategoryButton = new GUIButton(new RectTransform(new Vector2(1.0f, 1.0f), entityMenuTop.RectTransform, scaleBasis: ScaleBasis.BothHeight), "", style: "CategoryButton.All")
selectedCategoryButton = new GUIButton(new RectTransform(new Vector2(1.0f, 1.0f), entityMenuTop.RectTransform, scaleBasis: ScaleBasis.BothHeight), "", style: "CategoryButton.All")
{
CanBeFocused = false
};
var selectedCategoryText = new GUITextBlock(new RectTransform(new Vector2(0.4f, 1.0f), entityMenuTop.RectTransform), TextManager.Get("MapEntityCategory.All"), font: GUI.LargeFont);
selectedCategoryText = new GUITextBlock(new RectTransform(new Vector2(0.2f, 1.0f), entityMenuTop.RectTransform), TextManager.Get("MapEntityCategory.All"), font: GUI.LargeFont);
var filterText = new GUITextBlock(new RectTransform(new Vector2(0.1f, 1.0f), entityMenuTop.RectTransform), TextManager.Get("serverlog.filter"), font: GUI.SubHeadingFont);
filterText.RectTransform.MaxSize = new Point((int)(filterText.TextSize.X * 1.5f), int.MaxValue);
entityFilterBox = new GUITextBox(new RectTransform(new Vector2(0.17f, 1.0f), entityMenuTop.RectTransform), font: GUI.Font, createClearButton: true);
entityFilterBox.OnTextChanged += (textBox, text) => { FilterEntities(text); return true; };
//spacing
new GUIFrame(new RectTransform(new Vector2(0.075f, 1.0f), entityMenuTop.RectTransform), style: null);
entityCategoryButtons.Clear();
entityCategoryButtons.Add(
new GUIButton(new RectTransform(new Vector2(1.0f, 1.0f), entityMenuTop.RectTransform, scaleBasis: ScaleBasis.BothHeight), "", style: "CategoryButton.All")
{
OnClicked = (btn, userdata) =>
{
entityCategoryButtons.ForEach(b => b.Selected = b == btn);
selectedCategoryText.Text = TextManager.Get("MapEntityCategory.All");
selectedCategoryButton.ApplyStyle(GUI.Style.GetComponentStyle("CategoryButton.All"));
ClearFilter();
OnClicked = (btn, userdata) =>
{
if (!string.IsNullOrEmpty(entityFilterBox.Text)) { ClearFilter(); }
OpenEntityMenu(null);
return true;
}
});
@@ -605,20 +592,14 @@ namespace Barotrauma
ToolTip = TextManager.Get("MapEntityCategory." + category.ToString()),
OnClicked = (btn, userdata) =>
{
entityMenuOpen = true;
if (!string.IsNullOrEmpty(entityFilterBox.Text)) { ClearFilter(); }
MapEntityCategory newCategory = (MapEntityCategory)userdata;
selectedCategoryText.Text = TextManager.Get("MapEntityCategory." + newCategory.ToString());
selectedCategoryButton.ApplyStyle(GUI.Style.GetComponentStyle("CategoryButton." + category.ToString()));
OpenEntityMenu(newCategory);
return true;
}
});
}
var filterText = new GUITextBlock(new RectTransform(new Vector2(0.1f, 1.0f), entityMenuTop.RectTransform), TextManager.Get("serverlog.filter"), font: GUI.SubHeadingFont);
filterText.RectTransform.MaxSize = new Point((int)(filterText.TextSize.X * 1.5f), int.MaxValue);
entityFilterBox = new GUITextBox(new RectTransform(new Vector2(0.2f, 1.0f), entityMenuTop.RectTransform), font: GUI.Font, createClearButton: true);
entityFilterBox.OnTextChanged += (textBox, text) => { FilterEntities(text); return true; };
entityCategoryButtons.ForEach(b => b.RectTransform.MaxSize = new Point(b.Rect.Height));
new GUIFrame(new RectTransform(new Vector2(0.8f, 0.01f), paddedTab.RectTransform), style: "HorizontalLine");
@@ -636,7 +617,7 @@ namespace Barotrauma
{
entityList.Content.ClearChildren();
int entitiesPerRow = (int)Math.Ceiling(entityList.Content.Rect.Width / Math.Max(125 * GUI.Scale, 100));
int entitiesPerRow = (int)Math.Ceiling(entityList.Content.Rect.Width / Math.Max(125 * GUI.Scale, 60));
foreach (MapEntityPrefab ep in MapEntityPrefab.List)
{
@@ -762,6 +743,9 @@ namespace Barotrauma
UpdateEntityList();
string name = (Submarine.MainSub == null) ? TextManager.Get("unspecifiedsubfilename") : Submarine.MainSub.Name;
subNameLabel.Text = ToolBox.LimitString(name, subNameLabel.Font, subNameLabel.Rect.Width);
foreach (MapEntityPrefab prefab in MapEntityPrefab.List)
{
prefab.sprite?.EnsureLazyLoaded();
@@ -1000,7 +984,6 @@ namespace Barotrauma
if (string.IsNullOrWhiteSpace(nameBox.Text))
{
GUI.AddMessage(TextManager.Get("SubNameMissingWarning"), GUI.Style.Red);
nameBox.Flash();
return false;
}
@@ -1069,6 +1052,8 @@ namespace Barotrauma
linkedSubBox.AddItem(sub.Name, sub);
}
subNameLabel.Text = ToolBox.LimitString(Submarine.MainSub.Name, subNameLabel.Font, subNameLabel.Rect.Width);
saveFrame = null;
return false;
@@ -1102,8 +1087,7 @@ namespace Barotrauma
nameBox = new GUITextBox(new RectTransform(new Vector2(.95f, 0.05f), leftColumn.RectTransform))
{
OnEnterPressed = ChangeSubName,
Text = GetSubName()
OnEnterPressed = ChangeSubName
};
nameBox.OnTextChanged += (textBox, text) =>
{
@@ -1627,6 +1611,9 @@ namespace Barotrauma
Submarine.MainSub.SetPrevTransform(Submarine.MainSub.Position);
Submarine.MainSub.UpdateTransform();
string name = Submarine.MainSub.Name;
subNameLabel.Text = ToolBox.LimitString(name, subNameLabel.Font, subNameLabel.Rect.Width);
cam.Position = Submarine.MainSub.Position + Submarine.MainSub.HiddenSubPosition;
loadFrame = null;
@@ -1700,22 +1687,25 @@ namespace Barotrauma
msgBox.Buttons[1].OnClicked += msgBox.Close;
}
private bool OpenEntityMenu(MapEntityCategory selectedCategory)
private bool OpenEntityMenu(MapEntityCategory? selectedCategory)
{
entityFilterBox.Text = "";
foreach (GUIButton categoryButton in entityCategoryButtons)
{
categoryButton.Selected = selectedCategory.HasValue ?
categoryButton.UserData is MapEntityCategory category && selectedCategory.Value == category :
categoryButton.UserData == null;
string categoryName = selectedCategory.HasValue ? selectedCategory.Value.ToString() : "All";
selectedCategoryText.Text = TextManager.Get("MapEntityCategory." + categoryName);
selectedCategoryButton.ApplyStyle(GUI.Style.GetComponentStyle("CategoryButton." + categoryName));
}
this.selectedCategory = selectedCategory;
SetMode(Mode.Default);
saveFrame = null;
loadFrame = null;
ClearFilter();
foreach (GUIButton button in entityCategoryButtons)
{
button.Selected =
button.UserData != null &&
(MapEntityCategory)button.UserData == selectedCategory;
}
foreach (GUIComponent child in toggleEntityMenuButton.Children)
{
child.SpriteEffects = entityMenuOpen ? SpriteEffects.None : SpriteEffects.FlipVertically;
@@ -1723,7 +1713,7 @@ namespace Barotrauma
foreach (GUIComponent child in entityList.Content.Children)
{
child.Visible = ((MapEntityPrefab)child.UserData).Category == selectedCategory;
child.Visible = !selectedCategory.HasValue || ((MapEntityPrefab)child.UserData).Category == selectedCategory;
}
entityList.UpdateScrollBarSize();
entityList.BarScroll = 0.0f;
@@ -1733,14 +1723,9 @@ namespace Barotrauma
private bool FilterEntities(string filter)
{
foreach (GUIButton button in entityCategoryButtons)
{
button.Selected = false;
}
if (string.IsNullOrWhiteSpace(filter))
{
entityList.Content.Children.ForEach(c => c.Visible = true);
entityList.Content.Children.ForEach(c => c.Visible = !selectedCategory.HasValue || selectedCategory == ((MapEntityPrefab)c.UserData).Category);
return true;
}
@@ -1748,7 +1733,9 @@ namespace Barotrauma
foreach (GUIComponent child in entityList.Content.Children)
{
var textBlock = child.GetChild<GUITextBlock>();
child.Visible = ((MapEntityPrefab)child.UserData).Name.ToLower().Contains(filter);
child.Visible =
(!selectedCategory.HasValue || selectedCategory == ((MapEntityPrefab)child.UserData).Category) &&
((MapEntityPrefab)child.UserData).Name.ToLower().Contains(filter);
}
entityList.UpdateScrollBarSize();
entityList.BarScroll = 0.0f;
@@ -1768,9 +1755,13 @@ namespace Barotrauma
public void SetMode(Mode mode)
{
if (mode == this.mode) { return; }
this.mode = mode;
modeButtonGroup.Selected = (int)mode;
defaultModeTickBox.Selected = mode == Mode.Default;
defaultModeTickBox.CanBeFocused = !defaultModeTickBox.Selected;
characterModeTickBox.Selected = mode == Mode.Character;
wiringModeTickBox.Selected = mode == Mode.Wiring;
switch (mode)
{
@@ -1855,10 +1846,11 @@ namespace Barotrauma
{
if (!child.Enabled) { child.TextColor *= 0.5f; }
}
contextMenu.Content.Children.ForEach(c => c.RectTransform.MinSize = new Point(0, c.Rect.Height));
contextMenu.RectTransform.NonScaledSize = new Point(
contextMenu.Rect.Width,
(int)((contextMenu.Content.CountChildren * 18) * GUI.Scale));
(int)((contextMenu.Content.CountChildren * 20) * GUI.Scale));
contextMenu.OnSelected = (GUIComponent component, object obj) =>
{
@@ -2411,6 +2403,11 @@ namespace Barotrauma
hullVolumeFrame.Visible = MapEntity.SelectedList.Any(s => s is Hull);
saveAssemblyFrame.Visible = MapEntity.SelectedList.Count > 0;
if (PlayerInput.KeyHit(Microsoft.Xna.Framework.Input.Keys.Tab))
{
entityFilterBox.Select();
}
cam.MoveCamera((float)deltaTime, true);
if (PlayerInput.MidButtonHeld())
@@ -2615,9 +2612,11 @@ namespace Barotrauma
GUI.DrawLine(spriteBatch, new Vector2(Submarine.MainSub.HiddenSubPosition.X, -cam.WorldView.Y), new Vector2(Submarine.MainSub.HiddenSubPosition.X, -(cam.WorldView.Y - cam.WorldView.Height)), Color.White * 0.5f, 1.0f, (int)(2.0f / cam.Zoom));
GUI.DrawLine(spriteBatch, new Vector2(cam.WorldView.X, -Submarine.MainSub.HiddenSubPosition.Y), new Vector2(cam.WorldView.Right, -Submarine.MainSub.HiddenSubPosition.Y), Color.White * 0.5f, 1.0f, (int)(2.0f / cam.Zoom));
}
Submarine.DrawBack(spriteBatch, editing: true);
Submarine.DrawBack(spriteBatch, true, e => e is Structure s && (e.SpriteDepth >= 0.9f || s.Prefab.BackgroundSprite != null));
spriteBatch.End();
spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.NonPremultiplied, transformMatrix: cam.Transform);
Submarine.DrawBack(spriteBatch, true, e => !(e is Structure) || e.SpriteDepth < 0.9f);
spriteBatch.End();
spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.NonPremultiplied, transformMatrix: cam.Transform);