v0.14.6.0
This commit is contained in:
@@ -6,6 +6,7 @@ using Barotrauma.IO;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using System.Globalization;
|
||||
using Barotrauma.Extensions;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
@@ -42,6 +43,12 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
public GUITickBox EnableRadiationToggle { get; set; }
|
||||
public GUILayoutGroup CampaignSettingsContent { get; set; }
|
||||
|
||||
public GUIButton CampaignCustomizeButton { get; set; }
|
||||
public GUIMessageBox CampaignCustomizeSettings { get; set; }
|
||||
|
||||
public GUITextBlock MaxMissionCountText;
|
||||
|
||||
private readonly bool isMultiplayer;
|
||||
|
||||
@@ -177,10 +184,19 @@ namespace Barotrauma
|
||||
if (isMultiplayer)
|
||||
{
|
||||
settings.RadiationEnabled = GameMain.NetLobbyScreen.IsRadiationEnabled();
|
||||
settings.MaxMissionCount = GameMain.NetLobbyScreen.GetMaxMissionCount();
|
||||
}
|
||||
else
|
||||
{
|
||||
settings.RadiationEnabled = EnableRadiationToggle?.Selected ?? false;
|
||||
if (MaxMissionCountText != null && Int32.TryParse(MaxMissionCountText.Text, out int missionCount))
|
||||
{
|
||||
settings.MaxMissionCount = missionCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
settings.MaxMissionCount = CampaignSettings.DefaultMaxMissionCount;
|
||||
}
|
||||
}
|
||||
|
||||
if (selectedSub.HasTag(SubmarineTag.Shuttle) || !hasRequiredContentPackages)
|
||||
@@ -265,14 +281,14 @@ namespace Barotrauma
|
||||
|
||||
if (!isMultiplayer)
|
||||
{
|
||||
if (MapGenerationParams.Instance.RadiationParams != null)
|
||||
CampaignCustomizeButton = new GUIButton(new RectTransform(new Vector2(0.25f, 1f), buttonContainer.RectTransform, Anchor.CenterLeft), TextManager.Get("SettingsButton"))
|
||||
{
|
||||
EnableRadiationToggle = new GUITickBox(new RectTransform(new Vector2(0.3f, 1f), buttonContainer.RectTransform), TextManager.Get("CampaignOption.EnableRadiation"), font: GUI.Style.Font)
|
||||
OnClicked = (tb, userdata) =>
|
||||
{
|
||||
Selected = true,
|
||||
ToolTip = TextManager.Get("campaignoption.enableradiation.tooltip")
|
||||
};
|
||||
}
|
||||
CreateCustomizeWindow();
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
var disclaimerBtn = new GUIButton(new RectTransform(new Vector2(1.0f, 0.8f), rightColumn.RectTransform, Anchor.TopRight) { AbsoluteOffset = new Point(5) }, style: "GUINotificationButton")
|
||||
{
|
||||
@@ -290,6 +306,52 @@ namespace Barotrauma
|
||||
UpdateLoadMenu(saveFiles);
|
||||
}
|
||||
|
||||
private void CreateCustomizeWindow()
|
||||
{
|
||||
CampaignCustomizeSettings = new GUIMessageBox("", "", new string[] { TextManager.Get("OK") }, new Vector2(0.2f, 0.2f));
|
||||
CampaignCustomizeSettings.Buttons[0].OnClicked += CampaignCustomizeSettings.Close;
|
||||
|
||||
CampaignSettingsContent = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.9f), CampaignCustomizeSettings.Content.RectTransform, Anchor.TopCenter))
|
||||
{
|
||||
RelativeSpacing = 0.1f
|
||||
};
|
||||
|
||||
if (MapGenerationParams.Instance.RadiationParams != null)
|
||||
{
|
||||
EnableRadiationToggle = new GUITickBox(new RectTransform(new Vector2(0.3f, 0.3f), CampaignSettingsContent.RectTransform), TextManager.Get("CampaignOption.EnableRadiation"), font: GUI.Style.Font)
|
||||
{
|
||||
Selected = true,
|
||||
ToolTip = TextManager.Get("campaignoption.enableradiation.tooltip")
|
||||
};
|
||||
}
|
||||
var maxMissionCountSettingHolder = new GUILayoutGroup(new RectTransform(new Vector2(1f, 0.3f), CampaignSettingsContent.RectTransform), isHorizontal: true, childAnchor: Anchor.CenterLeft)
|
||||
{
|
||||
Stretch = true,
|
||||
ToolTip = TextManager.Get("maxmissioncounttooltip")
|
||||
};
|
||||
var maxMissionCountDescription = new GUITextBlock(new RectTransform(new Vector2(0.7f, 0.0f), maxMissionCountSettingHolder.RectTransform), TextManager.Get("maxmissioncount", fallBackTag: "missions"), wrap: true);
|
||||
var maxMissionCountContainer = new GUILayoutGroup(new RectTransform(new Vector2(0.5f, 1.0f), maxMissionCountSettingHolder.RectTransform), isHorizontal: true, childAnchor: Anchor.CenterLeft) { RelativeSpacing = 0.05f, Stretch = true };
|
||||
var maxMissionCountButtons = new GUIButton[2];
|
||||
maxMissionCountButtons[0] = new GUIButton(new RectTransform(new Vector2(0.15f, 0.8f), maxMissionCountContainer.RectTransform), style: "GUIButtonToggleLeft")
|
||||
{
|
||||
OnClicked = (button, obj) =>
|
||||
{
|
||||
MaxMissionCountText.Text = Math.Clamp(Int32.Parse(MaxMissionCountText.Text) - 1, CampaignSettings.MinMissionCountLimit, CampaignSettings.MaxMissionCountLimit).ToString();
|
||||
return true;
|
||||
}
|
||||
};
|
||||
MaxMissionCountText = new GUITextBlock(new RectTransform(new Vector2(0.7f, 1.0f), maxMissionCountContainer.RectTransform), CampaignSettings.DefaultMaxMissionCount.ToString(), textAlignment: Alignment.Center, style: "GUITextBox");
|
||||
maxMissionCountButtons[1] = new GUIButton(new RectTransform(new Vector2(0.15f, 0.8f), maxMissionCountContainer.RectTransform), style: "GUIButtonToggleRight")
|
||||
{
|
||||
OnClicked = (button, obj) =>
|
||||
{
|
||||
MaxMissionCountText.Text = Math.Clamp(Int32.Parse(MaxMissionCountText.Text) + 1, CampaignSettings.MinMissionCountLimit, CampaignSettings.MaxMissionCountLimit).ToString();
|
||||
return true;
|
||||
}
|
||||
};
|
||||
maxMissionCountContainer.Children.ForEach(c => c.ToolTip = maxMissionCountSettingHolder.ToolTip);
|
||||
}
|
||||
|
||||
private void CreateMultiplayerCampaignSubList(RectTransform parent)
|
||||
{
|
||||
GUILayoutGroup subHolder = new GUILayoutGroup(new RectTransform(new Vector2(1f, 0.725f), parent))
|
||||
|
||||
@@ -21,6 +21,9 @@ namespace Barotrauma
|
||||
private GUIComponent locationInfoPanel;
|
||||
|
||||
private GUIListBox missionList;
|
||||
private readonly List<GUITickBox> missionTickBoxes = new List<GUITickBox>();
|
||||
|
||||
private bool hasMaxMissions;
|
||||
|
||||
private GUIButton repairHullsButton, replaceShuttlesButton, repairItemsButton;
|
||||
|
||||
@@ -51,9 +54,18 @@ namespace Barotrauma
|
||||
CreateUI(container);
|
||||
|
||||
campaign.Map.OnLocationSelected += SelectLocation;
|
||||
campaign.Map.OnMissionSelected += (connection, mission) =>
|
||||
campaign.Map.OnMissionsSelected += (connection, missions) =>
|
||||
{
|
||||
missionList?.Select(mission);
|
||||
if (missionList?.Content != null)
|
||||
{
|
||||
foreach (GUIComponent missionElement in missionList.Content.Children)
|
||||
{
|
||||
if (missionElement.FindChild(c => c is GUITickBox, recursive: true) is GUITickBox tickBox)
|
||||
{
|
||||
tickBox.Selected = missions.Contains(tickBox.UserData as Mission);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -311,6 +323,20 @@ namespace Barotrauma
|
||||
map.SelectLocation(-1);
|
||||
}
|
||||
map.Update(deltaTime, mapContainer);
|
||||
foreach (GUITickBox tickBox in missionTickBoxes)
|
||||
{
|
||||
bool disable = hasMaxMissions && !tickBox.Selected;
|
||||
tickBox.Enabled = Campaign.AllowedToManageCampaign() && !disable;
|
||||
tickBox.Box.DisabledColor = disable ? tickBox.Box.Color * 0.5f : tickBox.Box.Color * 0.8f;
|
||||
foreach (GUIComponent child in tickBox.Parent.Parent.Children)
|
||||
{
|
||||
if (child is GUITextBlock textBlock)
|
||||
{
|
||||
textBlock.SelectedTextColor = textBlock.HoverTextColor = textBlock.TextColor =
|
||||
disable ? new Color(textBlock.TextColor, 0.5f) : new Color(textBlock.TextColor, 1.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Update(float deltaTime)
|
||||
@@ -341,6 +367,7 @@ namespace Barotrauma
|
||||
|
||||
public void SelectLocation(Location location, LocationConnection connection)
|
||||
{
|
||||
missionTickBoxes.Clear();
|
||||
locationInfoPanel.ClearChildren();
|
||||
//don't select the map panel if we're looking at some other tab
|
||||
if (selectedTab == CampaignMode.InteractionType.Map)
|
||||
@@ -436,6 +463,19 @@ namespace Barotrauma
|
||||
{
|
||||
Spacing = (int)(5 * GUI.yScale)
|
||||
};
|
||||
missionList.OnSelected = (GUIComponent selected, object userdata) =>
|
||||
{
|
||||
var tickBox = selected.FindChild(c => c is GUITickBox, recursive: true) as GUITickBox;
|
||||
if (GUI.MouseOn == tickBox) { return false; }
|
||||
if (tickBox != null)
|
||||
{
|
||||
if (Campaign.AllowedToManageCampaign() && tickBox.Enabled)
|
||||
{
|
||||
tickBox.Selected = !tickBox.Selected;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
SelectedLevel = connection?.LevelData;
|
||||
Location currentDisplayLocation = Campaign.GetCurrentDisplayLocation();
|
||||
@@ -444,9 +484,6 @@ namespace Barotrauma
|
||||
List<Mission> availableMissions = currentDisplayLocation.GetMissionsInConnection(connection).ToList();
|
||||
if (!availableMissions.Contains(null)) { availableMissions.Insert(0, null); }
|
||||
|
||||
Mission selectedMission = currentDisplayLocation.SelectedMission != null && availableMissions.Contains(currentDisplayLocation.SelectedMission) ?
|
||||
currentDisplayLocation.SelectedMission : null;
|
||||
|
||||
missionList.Content.ClearChildren();
|
||||
|
||||
foreach (Mission mission in availableMissions)
|
||||
@@ -458,67 +495,93 @@ namespace Barotrauma
|
||||
var missionTextContent = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.9f), missionPanel.RectTransform, Anchor.Center))
|
||||
{
|
||||
Stretch = true,
|
||||
CanBeFocused = true
|
||||
CanBeFocused = true,
|
||||
AbsoluteSpacing = GUI.IntScale(5)
|
||||
};
|
||||
|
||||
var missionName = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), missionTextContent.RectTransform), mission?.Name ?? TextManager.Get("NoMission"), font: GUI.SubHeadingFont, wrap: true);
|
||||
// missionName.RectTransform.MinSize = new Point(0, (int)(missionName.Rect.Height * 1.5f));
|
||||
if (mission != null)
|
||||
{
|
||||
if (MapGenerationParams.Instance?.MissionIcon != null)
|
||||
{
|
||||
var tickBox = new GUITickBox(new RectTransform(Vector2.One * 0.9f, missionName.RectTransform, anchor: Anchor.CenterLeft, scaleBasis: ScaleBasis.Smallest) { AbsoluteOffset = new Point((int)missionName.Padding.X, 0) }, label: string.Empty)
|
||||
{
|
||||
var icon = new GUIImage(new RectTransform(Vector2.One * 0.9f, missionName.RectTransform, anchor: Anchor.CenterLeft, scaleBasis: ScaleBasis.Smallest) { AbsoluteOffset = new Point((int)missionName.Padding.X, 0) },
|
||||
MapGenerationParams.Instance.MissionIcon, scaleToFit: true)
|
||||
{
|
||||
Color = MapGenerationParams.Instance.IndicatorColor * 0.5f,
|
||||
SelectedColor = MapGenerationParams.Instance.IndicatorColor,
|
||||
HoverColor = Color.Lerp(MapGenerationParams.Instance.IndicatorColor, Color.White, 0.5f)
|
||||
};
|
||||
icon.RectTransform.IsFixedSize = true;
|
||||
|
||||
GUILayoutGroup difficultyIndicatorGroup = null;
|
||||
if (mission.Difficulty.HasValue)
|
||||
{
|
||||
difficultyIndicatorGroup = new GUILayoutGroup(new RectTransform(Vector2.One * 0.9f, missionName.RectTransform, anchor: Anchor.CenterRight, scaleBasis: ScaleBasis.Smallest) { AbsoluteOffset = new Point((int)missionName.Padding.Z, 0) },
|
||||
isHorizontal: true, childAnchor: Anchor.CenterRight)
|
||||
{
|
||||
AbsoluteSpacing = 1,
|
||||
UserData = "difficulty"
|
||||
};
|
||||
var difficultyColor = mission.GetDifficultyColor();
|
||||
for (int i = 0; i < mission.Difficulty; i++)
|
||||
{
|
||||
new GUIImage(new RectTransform(Vector2.One, difficultyIndicatorGroup.RectTransform, scaleBasis: ScaleBasis.Smallest) { IsFixedSize = true }, "DifficultyIndicator", scaleToFit: true)
|
||||
{
|
||||
Color = difficultyColor * 0.5f,
|
||||
SelectedColor = difficultyColor,
|
||||
HoverColor = Color.Lerp(difficultyColor, Color.White, 0.5f)
|
||||
};
|
||||
}
|
||||
}
|
||||
UserData = mission,
|
||||
Selected = Campaign.Map.CurrentLocation?.SelectedMissions.Contains(mission) ?? false
|
||||
};
|
||||
tickBox.RectTransform.MinSize = new Point(tickBox.Rect.Height, 0);
|
||||
tickBox.RectTransform.IsFixedSize = true;
|
||||
tickBox.Enabled = Campaign.AllowedToManageCampaign();
|
||||
tickBox.OnSelected += (GUITickBox tb) =>
|
||||
{
|
||||
if (!Campaign.AllowedToManageCampaign()) { return false; }
|
||||
|
||||
float extraPadding = 0.5f * icon.Rect.Width;
|
||||
float extraZPadding = difficultyIndicatorGroup != null ? mission.Difficulty.Value * (difficultyIndicatorGroup.Children.First().Rect.Width + difficultyIndicatorGroup.AbsoluteSpacing) : 0;
|
||||
missionName.Padding = new Vector4(missionName.Padding.X + icon.Rect.Width + extraPadding,
|
||||
missionName.Padding.Y,
|
||||
missionName.Padding.Z + extraZPadding + extraPadding,
|
||||
missionName.Padding.W);
|
||||
missionName.CalculateHeightFromText();
|
||||
if (tb.Selected)
|
||||
{
|
||||
Campaign.Map.CurrentLocation.SelectMission(mission);
|
||||
}
|
||||
else
|
||||
{
|
||||
Campaign.Map.CurrentLocation.DeselectMission(mission);
|
||||
}
|
||||
|
||||
UpdateMaxMissions(connection.OtherLocation(currentDisplayLocation));
|
||||
|
||||
if ((Campaign is MultiPlayerCampaign multiPlayerCampaign) && !multiPlayerCampaign.SuppressStateSending &&
|
||||
Campaign.AllowedToManageCampaign())
|
||||
{
|
||||
GameMain.Client?.SendCampaignState();
|
||||
}
|
||||
return true;
|
||||
};
|
||||
missionTickBoxes.Add(tickBox);
|
||||
|
||||
GUILayoutGroup difficultyIndicatorGroup = null;
|
||||
if (mission.Difficulty.HasValue)
|
||||
{
|
||||
difficultyIndicatorGroup = new GUILayoutGroup(new RectTransform(Vector2.One * 0.9f, missionName.RectTransform, anchor: Anchor.CenterRight, scaleBasis: ScaleBasis.Smallest) { AbsoluteOffset = new Point((int)missionName.Padding.Z, 0) },
|
||||
isHorizontal: true, childAnchor: Anchor.CenterRight)
|
||||
{
|
||||
AbsoluteSpacing = 1,
|
||||
UserData = "difficulty"
|
||||
};
|
||||
var difficultyColor = mission.GetDifficultyColor();
|
||||
for (int i = 0; i < mission.Difficulty; i++)
|
||||
{
|
||||
new GUIImage(new RectTransform(Vector2.One, difficultyIndicatorGroup.RectTransform, scaleBasis: ScaleBasis.Smallest) { IsFixedSize = true }, "DifficultyIndicator", scaleToFit: true)
|
||||
{
|
||||
Color = difficultyColor,
|
||||
SelectedColor = difficultyColor,
|
||||
HoverColor = difficultyColor
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), missionTextContent.RectTransform), mission.GetMissionRewardText(), wrap: true, parseRichText: true);
|
||||
float extraPadding = 0;// 0.8f * tickBox.Rect.Width;
|
||||
float extraZPadding = difficultyIndicatorGroup != null ? mission.Difficulty.Value * (difficultyIndicatorGroup.Children.First().Rect.Width + difficultyIndicatorGroup.AbsoluteSpacing) : 0;
|
||||
missionName.Padding = new Vector4(missionName.Padding.X + tickBox.Rect.Width * 1.2f + extraPadding,
|
||||
missionName.Padding.Y,
|
||||
missionName.Padding.Z + extraZPadding + extraPadding,
|
||||
missionName.Padding.W);
|
||||
missionName.CalculateHeightFromText();
|
||||
|
||||
//spacing
|
||||
new GUIFrame(new RectTransform(new Vector2(1.0f, 0.0f), missionTextContent.RectTransform) { MinSize = new Point(0, GUI.IntScale(10)) }, style: null);
|
||||
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), missionTextContent.RectTransform), mission.GetMissionRewardText(Submarine.MainSub), wrap: true, parseRichText: true);
|
||||
|
||||
string reputationText = mission.GetReputationRewardText(mission.Locations[0]);
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), missionTextContent.RectTransform), reputationText, wrap: true, parseRichText: true);
|
||||
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), missionTextContent.RectTransform), mission.Description, wrap: true, parseRichText: true);
|
||||
}
|
||||
missionPanel.RectTransform.MinSize = new Point(0, (int)(missionTextContent.Children.Sum(c => c.Rect.Height) / missionTextContent.RectTransform.RelativeSize.Y) + GUI.IntScale(20));
|
||||
missionPanel.RectTransform.MinSize = new Point(0, (int)(missionTextContent.Children.Sum(c => c.Rect.Height + missionTextContent.AbsoluteSpacing) / missionTextContent.RectTransform.RelativeSize.Y) + GUI.IntScale(0));
|
||||
foreach (GUIComponent child in missionTextContent.Children)
|
||||
{
|
||||
var textBlock = child as GUITextBlock;
|
||||
textBlock.Color = textBlock.SelectedColor = textBlock.HoverColor = Color.Transparent;
|
||||
textBlock.HoverTextColor = textBlock.TextColor;
|
||||
textBlock.TextColor *= 0.5f;
|
||||
if (child is GUITextBlock textBlock)
|
||||
{
|
||||
textBlock.Color = textBlock.SelectedColor = textBlock.HoverColor = Color.Transparent;
|
||||
textBlock.SelectedTextColor = textBlock.HoverTextColor = textBlock.TextColor;
|
||||
}
|
||||
}
|
||||
missionPanel.OnAddedToGUIUpdateList = (c) =>
|
||||
{
|
||||
@@ -537,36 +600,33 @@ namespace Barotrauma
|
||||
};
|
||||
}
|
||||
}
|
||||
missionList.Select(selectedMission);
|
||||
if (prevSelectedLocation == selectedLocation)
|
||||
{
|
||||
missionList.BarScroll = prevMissionListScroll;
|
||||
}
|
||||
|
||||
if (Campaign.AllowedToManageCampaign())
|
||||
{
|
||||
missionList.OnSelected = (component, userdata) =>
|
||||
{
|
||||
Mission mission = userdata as Mission;
|
||||
if (Campaign.Map.CurrentLocation.SelectedMission == mission) { return false; }
|
||||
Campaign.Map.CurrentLocation.SelectedMission = mission;
|
||||
//RefreshMissionInfo(mission);
|
||||
if ((Campaign is MultiPlayerCampaign multiPlayerCampaign) && !multiPlayerCampaign.SuppressStateSending &&
|
||||
Campaign.AllowedToManageCampaign())
|
||||
{
|
||||
GameMain.Client?.SendCampaignState();
|
||||
}
|
||||
return true;
|
||||
};
|
||||
missionList.UpdateDimensions();
|
||||
missionList.UpdateScrollBarSize();
|
||||
}
|
||||
}
|
||||
var destination = connection.OtherLocation(currentDisplayLocation);
|
||||
UpdateMaxMissions(destination);
|
||||
|
||||
StartButton = new GUIButton(new RectTransform(new Vector2(0.5f, 0.1f), content.RectTransform),
|
||||
var buttonArea = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.05f), content.RectTransform), isHorizontal: true);
|
||||
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.6f, 1.0f), buttonArea.RectTransform), "", font: GUI.Style.SubHeadingFont)
|
||||
{
|
||||
TextGetter = () =>
|
||||
{
|
||||
return TextManager.AddPunctuation(':', TextManager.Get("Missions"), $"{Campaign.NumberOfMissionsAtLocation(destination)}/{Campaign.Settings.MaxMissionCount}");
|
||||
}
|
||||
};
|
||||
|
||||
StartButton = new GUIButton(new RectTransform(new Vector2(0.4f, 1.0f), buttonArea.RectTransform),
|
||||
TextManager.Get("StartCampaignButton"), style: "GUIButtonLarge")
|
||||
{
|
||||
OnClicked = (GUIButton btn, object obj) =>
|
||||
{
|
||||
if (missionList.Content.Children.Any(c => c.UserData is Mission) && !(missionList.SelectedData is Mission))
|
||||
if (missionList.Content.FindChild(c => c is GUITickBox tickBox && tickBox.Selected, recursive: true) == null &&
|
||||
missionList.Content.Children.Any(c => c.UserData is Mission))
|
||||
{
|
||||
var noMissionVerification = new GUIMessageBox(string.Empty, TextManager.Get("nomissionprompt"), new string[] { TextManager.Get("yes"), TextManager.Get("no") });
|
||||
noMissionVerification.Buttons[0].OnClicked = (btn, userdata) =>
|
||||
@@ -587,6 +647,8 @@ namespace Barotrauma
|
||||
Visible = Campaign.AllowedToEndRound()
|
||||
};
|
||||
|
||||
buttonArea.RectTransform.MinSize = new Point(0, StartButton.RectTransform.MinSize.Y);
|
||||
|
||||
if (Level.Loaded != null &&
|
||||
connection?.LevelData == Level.Loaded.LevelData &&
|
||||
currentDisplayLocation == Campaign.Map?.CurrentLocation)
|
||||
@@ -594,6 +656,7 @@ namespace Barotrauma
|
||||
StartButton.Visible = false;
|
||||
missionList.Enabled = false;
|
||||
}
|
||||
//locationInfoPanel?.UpdateAuto(1.0f);
|
||||
}
|
||||
|
||||
public void SelectTab(CampaignMode.InteractionType tab)
|
||||
@@ -657,5 +720,10 @@ namespace Barotrauma
|
||||
{
|
||||
return TextManager.GetWithVariable("PlayerCredits", "[credits]", (GameMain.GameSession?.Campaign == null) ? "0" : string.Format(CultureInfo.InvariantCulture, "{0:N0}", GameMain.GameSession.Campaign.Money));
|
||||
}
|
||||
|
||||
private void UpdateMaxMissions(Location location)
|
||||
{
|
||||
hasMaxMissions = Campaign.NumberOfMissionsAtLocation(location) >= Campaign.Settings.MaxMissionCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -4731,7 +4731,7 @@ namespace Barotrauma.CharacterEditor
|
||||
rotation: 0,
|
||||
origin: orig,
|
||||
sourceRectangle: wearable.InheritSourceRect ? limb.ActiveSprite.SourceRect : wearable.Sprite.SourceRect,
|
||||
scale: (wearable.InheritTextureScale ? 1 : 1 / RagdollParams.TextureScale) * spriteSheetZoom,
|
||||
scale: (wearable.InheritTextureScale ? 1 : wearable.Scale / RagdollParams.TextureScale) * spriteSheetZoom,
|
||||
effects: SpriteEffects.None,
|
||||
color: Color.White,
|
||||
layerDepth: 0);
|
||||
|
||||
@@ -305,7 +305,7 @@ namespace Barotrauma.CharacterEditor
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.3f, 1), mainElement.RectTransform, Anchor.CenterLeft), TextManager.Get("ContentPackage"));
|
||||
var rightContainer = new GUIFrame(new RectTransform(new Vector2(0.7f, 1), mainElement.RectTransform, Anchor.CenterRight), style: null);
|
||||
contentPackageDropDown = new GUIDropDown(new RectTransform(new Vector2(1.0f, 0.5f), rightContainer.RectTransform, Anchor.TopRight));
|
||||
foreach (ContentPackage cp in ContentPackage.AllPackages)
|
||||
foreach (ContentPackage cp in GameMain.Config.AllEnabledPackages)
|
||||
{
|
||||
#if !DEBUG
|
||||
if (cp == GameMain.VanillaContent) { continue; }
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
class EditorScreen : Screen
|
||||
{
|
||||
public static Color BackgroundColor = GameSettings.SubEditorBackgroundColor;
|
||||
|
||||
public void CreateBackgroundColorPicker()
|
||||
{
|
||||
var msgBox = new GUIMessageBox(TextManager.Get("CharacterEditor.EditBackgroundColor"), "", new[] { TextManager.Get("Reset"), TextManager.Get("OK")}, new Vector2(0.2f, 0.175f), minSize: new Point(300, 175));
|
||||
|
||||
var rgbLayout = new GUILayoutGroup(new RectTransform(new Vector2(1f, 0.25f), msgBox.Content.RectTransform), isHorizontal: true);
|
||||
|
||||
// Generate R,G,B labels and parent elements
|
||||
var layoutParents = new GUILayoutGroup[3];
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
var colorContainer = new GUILayoutGroup(new RectTransform(new Vector2(0.33f, 1), rgbLayout.RectTransform), isHorizontal: true) { Stretch = true };
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.2f, 1), colorContainer.RectTransform, Anchor.CenterLeft) { MinSize = new Point(15, 0) }, GUI.colorComponentLabels[i], font: GUI.SmallFont, textAlignment: Alignment.Center);
|
||||
layoutParents[i] = colorContainer;
|
||||
}
|
||||
|
||||
// attach number inputs to our generated parent elements
|
||||
var rInput = new GUINumberInput(new RectTransform(new Vector2(0.7f, 1f), layoutParents[0].RectTransform), GUINumberInput.NumberType.Int) { IntValue = BackgroundColor.R };
|
||||
var gInput = new GUINumberInput(new RectTransform(new Vector2(0.7f, 1f), layoutParents[1].RectTransform), GUINumberInput.NumberType.Int) { IntValue = BackgroundColor.G };
|
||||
var bInput = new GUINumberInput(new RectTransform(new Vector2(0.7f, 1f), layoutParents[2].RectTransform), GUINumberInput.NumberType.Int) { IntValue = BackgroundColor.B };
|
||||
|
||||
rInput.MinValueInt = gInput.MinValueInt = bInput.MinValueInt = 0;
|
||||
rInput.MaxValueInt = gInput.MaxValueInt = bInput.MaxValueInt = 255;
|
||||
|
||||
rInput.OnValueChanged = gInput.OnValueChanged = bInput.OnValueChanged = delegate
|
||||
{
|
||||
var color = new Color(rInput.IntValue, gInput.IntValue, bInput.IntValue);
|
||||
BackgroundColor = color;
|
||||
GameSettings.SubEditorBackgroundColor = color;
|
||||
};
|
||||
|
||||
// Reset button
|
||||
msgBox.Buttons[0].OnClicked = (button, o) =>
|
||||
{
|
||||
rInput.IntValue = 13;
|
||||
gInput.IntValue = 37;
|
||||
bInput.IntValue = 69;
|
||||
return true;
|
||||
};
|
||||
|
||||
// Ok button
|
||||
msgBox.Buttons[1].OnClicked = (button, o) =>
|
||||
{
|
||||
msgBox.Close();
|
||||
GameMain.Config.SaveNewPlayerConfig();
|
||||
return true;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -227,7 +227,7 @@ namespace Barotrauma
|
||||
public static GUIMessageBox AskForConfirmation(string header, string body, Func<bool> onConfirm)
|
||||
{
|
||||
string[] buttons = { TextManager.Get("Ok"), TextManager.Get("Cancel") };
|
||||
GUIMessageBox msgBox = new GUIMessageBox(header, body, buttons, new Vector2(0.2f, 0.175f), minSize: new Point(300, 175));
|
||||
GUIMessageBox msgBox = new GUIMessageBox(header, body, buttons);
|
||||
|
||||
// Cancel button
|
||||
msgBox.Buttons[1].OnClicked = delegate
|
||||
|
||||
@@ -364,13 +364,15 @@ namespace Barotrauma
|
||||
Quad.Render();
|
||||
}
|
||||
|
||||
float grainStrength = Character.Controlled?.GrainStrength ?? 0;
|
||||
if (grainStrength > 0)
|
||||
if (Character.Controlled is { } character)
|
||||
{
|
||||
float grainStrength = character.GrainStrength;
|
||||
Rectangle screenRect = new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight);
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, effect: GrainEffect);
|
||||
GUI.DrawRectangle(spriteBatch, screenRect, Color.White * grainStrength, isFilled: true);
|
||||
GUI.DrawRectangle(spriteBatch, screenRect, Color.White, isFilled: true);
|
||||
GrainEffect.Parameters["seed"].SetValue(Rand.Range(0f, 1f, Rand.RandSync.Unsynced));
|
||||
GrainEffect.Parameters["intensity"].SetValue(grainStrength);
|
||||
GrainEffect.Parameters["grainColor"].SetValue(character.GrainColor.ToVector4());
|
||||
spriteBatch.End();
|
||||
}
|
||||
|
||||
|
||||
@@ -469,18 +469,17 @@ namespace Barotrauma
|
||||
|
||||
this.game = game;
|
||||
|
||||
menuTabs[(int)Tab.Credits] = new GUIFrame(new RectTransform(Vector2.One, GUI.Canvas, Anchor.Center), style: null);
|
||||
new GUIFrame(new RectTransform(GUI.Canvas.RelativeSize, menuTabs[(int)Tab.Credits].RectTransform, Anchor.Center), style: "GUIBackgroundBlocker");
|
||||
menuTabs[(int)Tab.Credits] = new GUIFrame(new RectTransform(Vector2.One, GUI.Canvas, Anchor.Center), style: null)
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
new GUIFrame(new RectTransform(GUI.Canvas.RelativeSize, menuTabs[(int)Tab.Credits].RectTransform, Anchor.Center), style: "GUIBackgroundBlocker")
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
|
||||
var creditsContainer = new GUIFrame(new RectTransform(new Vector2(0.75f, 1.5f), menuTabs[(int)Tab.Credits].RectTransform, Anchor.CenterRight), style: "OuterGlow", color: Color.Black * 0.8f);
|
||||
creditsPlayer = new CreditsPlayer(new RectTransform(Vector2.One, creditsContainer.RectTransform), "Content/Texts/Credits.xml");
|
||||
|
||||
new GUIButton(new RectTransform(new Vector2(0.1f, 0.05f), menuTabs[(int)Tab.Credits].RectTransform, Anchor.BottomLeft) { RelativeOffset = new Vector2(0.25f, 0.02f) },
|
||||
TextManager.Get("Back"), style: "GUIButtonLarge")
|
||||
{
|
||||
OnClicked = SelectTab
|
||||
};
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -867,9 +866,7 @@ namespace Barotrauma
|
||||
{
|
||||
int.TryParse(maxPlayersBox.Text, out int currMaxPlayers);
|
||||
currMaxPlayers = (int)MathHelper.Clamp(currMaxPlayers + (int)button.UserData, 1, NetConfig.MaxPlayers);
|
||||
|
||||
maxPlayersBox.Text = currMaxPlayers.ToString();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1167,15 +1164,18 @@ namespace Barotrauma
|
||||
StartNewGame = StartGame
|
||||
};
|
||||
|
||||
var startButtonContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.05f), innerNewGame.RectTransform, Anchor.Center), isHorizontal: true, childAnchor: Anchor.BottomRight);
|
||||
var startButtonContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.05f), innerNewGame.RectTransform, Anchor.Center), isHorizontal: true, childAnchor: Anchor.BottomRight)
|
||||
{
|
||||
RelativeSpacing = 0.05f
|
||||
};
|
||||
campaignSetupUI.StartButton.RectTransform.Parent = startButtonContainer.RectTransform;
|
||||
campaignSetupUI.StartButton.RectTransform.MinSize = new Point(
|
||||
(int)(campaignSetupUI.StartButton.TextBlock.TextSize.X * 1.5f),
|
||||
campaignSetupUI.StartButton.RectTransform.MinSize.Y);
|
||||
startButtonContainer.RectTransform.MinSize = new Point(0, campaignSetupUI.StartButton.RectTransform.MinSize.Y);
|
||||
if (campaignSetupUI.EnableRadiationToggle != null)
|
||||
if (campaignSetupUI.CampaignCustomizeButton != null)
|
||||
{
|
||||
campaignSetupUI.EnableRadiationToggle.RectTransform.Parent = startButtonContainer.RectTransform;
|
||||
campaignSetupUI.CampaignCustomizeButton.RectTransform.Parent = startButtonContainer.RectTransform;
|
||||
}
|
||||
campaignSetupUI.InitialMoneyText.RectTransform.Parent = startButtonContainer.RectTransform;
|
||||
}
|
||||
@@ -1322,8 +1322,18 @@ namespace Barotrauma
|
||||
};
|
||||
maxPlayersBox = new GUITextBox(new RectTransform(new Vector2(0.6f, 1.0f), buttonContainer.RectTransform), textAlignment: Alignment.Center)
|
||||
{
|
||||
Text = maxPlayers.ToString(),
|
||||
CanBeFocused = false
|
||||
Text = maxPlayers.ToString()
|
||||
};
|
||||
maxPlayersBox.OnEnterPressed += (GUITextBox sender, string text) =>
|
||||
{
|
||||
maxPlayersBox.Deselect();
|
||||
return true;
|
||||
};
|
||||
maxPlayersBox.OnDeselected += (GUITextBox sender, Microsoft.Xna.Framework.Input.Keys key) =>
|
||||
{
|
||||
int.TryParse(maxPlayersBox.Text, out int currMaxPlayers);
|
||||
currMaxPlayers = (int)MathHelper.Clamp(currMaxPlayers, 1, NetConfig.MaxPlayers);
|
||||
maxPlayersBox.Text = currMaxPlayers.ToString();
|
||||
};
|
||||
new GUIButton(new RectTransform(new Vector2(0.2f, 1.0f), buttonContainer.RectTransform, scaleBasis: ScaleBasis.BothHeight), style: "GUIPlusButton", textAlignment: Alignment.Center)
|
||||
{
|
||||
|
||||
@@ -45,6 +45,10 @@ namespace Barotrauma
|
||||
|
||||
private readonly GUITickBox radiationEnabledTickBox;
|
||||
|
||||
private readonly GUIButton[] maxMissionCountButtons;
|
||||
private readonly GUITextBlock maxMissionCountText;
|
||||
private readonly GUITextBlock maxMissionCountDescription;
|
||||
|
||||
private readonly GUIButton[] traitorProbabilityButtons;
|
||||
private readonly GUITextBlock traitorProbabilityText;
|
||||
|
||||
@@ -929,7 +933,7 @@ namespace Barotrauma
|
||||
}
|
||||
};
|
||||
QuitCampaignButton = new GUIButton(new RectTransform(new Vector2(1.0f, 0.3f), campaignContent.RectTransform),
|
||||
TextManager.Get("pausemenusavequit"), textAlignment: Alignment.Center)
|
||||
TextManager.Get("quitbutton"), textAlignment: Alignment.Center)
|
||||
{
|
||||
OnClicked = (_, __) =>
|
||||
{
|
||||
@@ -969,6 +973,16 @@ namespace Barotrauma
|
||||
UserData = missionType,
|
||||
};
|
||||
|
||||
if (MissionPrefab.HiddenMissionClasses.Contains(missionType))
|
||||
{
|
||||
missionTypeTickBoxes[index] = new GUITickBox(new RectTransform(Vector2.One, frame.RectTransform), string.Empty)
|
||||
{
|
||||
UserData = (int)missionType,
|
||||
Visible = false,
|
||||
CanBeFocused = false
|
||||
};
|
||||
continue;
|
||||
}
|
||||
missionTypeTickBoxes[index] = new GUITickBox(new RectTransform(Vector2.One, frame.RectTransform),
|
||||
TextManager.Get("MissionType." + missionType.ToString()))
|
||||
{
|
||||
@@ -1148,6 +1162,31 @@ namespace Barotrauma
|
||||
};
|
||||
}
|
||||
|
||||
var maxMissionCountSettingHolder = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.1f), settingsContent.RectTransform), isHorizontal: true, childAnchor: Anchor.CenterLeft) { Stretch = true };
|
||||
maxMissionCountDescription = new GUITextBlock(new RectTransform(new Vector2(0.7f, 0.0f), maxMissionCountSettingHolder.RectTransform), TextManager.Get("maxmissioncount", fallBackTag: "missions"), wrap: true)
|
||||
{
|
||||
ToolTip = TextManager.Get("maxmissioncounttooltip")
|
||||
};
|
||||
var maxMissionCountContainer = new GUILayoutGroup(new RectTransform(new Vector2(0.5f, 1.0f), maxMissionCountSettingHolder.RectTransform), isHorizontal: true, childAnchor: Anchor.CenterLeft) { RelativeSpacing = 0.05f, Stretch = true };
|
||||
maxMissionCountButtons = new GUIButton[2];
|
||||
maxMissionCountButtons[0] = new GUIButton(new RectTransform(new Vector2(0.15f, 1.0f), maxMissionCountContainer.RectTransform), style: "GUIButtonToggleLeft")
|
||||
{
|
||||
OnClicked = (button, obj) =>
|
||||
{
|
||||
GameMain.Client.ServerSettings.ClientAdminWrite(ServerSettings.NetFlags.Misc, maxMissionCount: -1);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
maxMissionCountText = new GUITextBlock(new RectTransform(new Vector2(0.7f, 1.0f), maxMissionCountContainer.RectTransform), "0", textAlignment: Alignment.Center, style: "GUITextBox");
|
||||
maxMissionCountButtons[1] = new GUIButton(new RectTransform(new Vector2(0.15f, 1.0f), maxMissionCountContainer.RectTransform), style: "GUIButtonToggleRight")
|
||||
{
|
||||
OnClicked = (button, obj) =>
|
||||
{
|
||||
GameMain.Client.ServerSettings.ClientAdminWrite(ServerSettings.NetFlags.Misc, maxMissionCount: 1);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
maxMissionCountSettingHolder.Children.ForEach(c => c.ToolTip = maxMissionCountSettingHolder.ToolTip);
|
||||
|
||||
List<GUIComponent> settingsElements = settingsContent.Children.ToList();
|
||||
for (int i = 0; i < settingsElements.Count; i++)
|
||||
@@ -1301,6 +1340,13 @@ namespace Barotrauma
|
||||
{
|
||||
radiationEnabledTickBox.Enabled = CampaignSetupFrame.Visible && GameMain.Client.HasPermission(ClientPermissions.ManageSettings);
|
||||
}
|
||||
maxMissionCountDescription.Enabled = CampaignSetupFrame.Visible && GameMain.Client.HasPermission(ClientPermissions.ManageSettings);
|
||||
maxMissionCountText.Enabled = CampaignSetupFrame.Visible && GameMain.Client.HasPermission(ClientPermissions.ManageSettings);
|
||||
foreach (var button in maxMissionCountButtons)
|
||||
{
|
||||
button.Enabled = CampaignSetupFrame.Visible && GameMain.Client.HasPermission(ClientPermissions.ManageSettings);
|
||||
}
|
||||
|
||||
traitorProbabilityButtons[0].Enabled = traitorProbabilityButtons[1].Enabled = traitorProbabilityText.Enabled =
|
||||
!CampaignFrame.Visible && !CampaignSetupFrame.Visible && GameMain.Client.HasPermission(ClientPermissions.ManageSettings);
|
||||
botCountButtons[0].Enabled = botCountButtons[1].Enabled = GameMain.Client.HasPermission(ClientPermissions.ManageSettings);
|
||||
@@ -1322,7 +1368,7 @@ namespace Barotrauma
|
||||
roundControlsHolder.Children.ForEach(c => c.IgnoreLayoutGroups = !c.Visible);
|
||||
roundControlsHolder.Recalculate();
|
||||
|
||||
ReadyToStartBox.Parent.Visible = !GameMain.Client.GameStarted && SelectedMode != GameModePreset.MultiPlayerCampaign;
|
||||
ReadyToStartBox.Parent.Visible = !GameMain.Client.GameStarted;
|
||||
|
||||
RefreshGameModeContent();
|
||||
}
|
||||
@@ -3214,7 +3260,12 @@ namespace Barotrauma
|
||||
{
|
||||
for (int i = 0; i < missionTypeTickBoxes.Length; i++)
|
||||
{
|
||||
MissionType missionType = (MissionType)((int)missionTypeTickBoxes[i].UserData);
|
||||
MissionType missionType = (MissionType)(int)missionTypeTickBoxes[i].UserData;
|
||||
if (MissionPrefab.HiddenMissionClasses.Contains(missionType))
|
||||
{
|
||||
missionTypeTickBoxes[i].Parent.Visible = false;
|
||||
continue;
|
||||
}
|
||||
if (SelectedMode == GameModePreset.Mission)
|
||||
{
|
||||
missionTypeTickBoxes[i].Parent.Visible = MissionPrefab.CoOpMissionClasses.ContainsKey(missionType);
|
||||
@@ -3269,7 +3320,7 @@ namespace Barotrauma
|
||||
CampaignFrame.Visible = CampaignSetupFrame.Visible = false;
|
||||
}
|
||||
|
||||
ReadyToStartBox.Parent.Visible = !GameMain.Client.GameStarted && SelectedMode != GameModePreset.MultiPlayerCampaign;
|
||||
ReadyToStartBox.Parent.Visible = !GameMain.Client.GameStarted;
|
||||
|
||||
StartButton.Visible =
|
||||
GameMain.Client.HasPermission(ClientPermissions.ManageRound) &&
|
||||
|
||||
@@ -6,6 +6,7 @@ using System.Collections.Generic;
|
||||
using System.Xml.Linq;
|
||||
using System.Text;
|
||||
using Barotrauma.Extensions;
|
||||
using FarseerPhysics;
|
||||
#if DEBUG
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
@@ -15,57 +16,8 @@ using Barotrauma.IO;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
class ParticleEditorScreen : Screen
|
||||
class ParticleEditorScreen : EditorScreen
|
||||
{
|
||||
class Emitter : ISerializableEntity
|
||||
{
|
||||
public float EmitTimer;
|
||||
|
||||
public float BurstTimer;
|
||||
|
||||
[Editable(), Serialize("0.0,360.0", false)]
|
||||
public Vector2 AngleRange { get; private set; }
|
||||
|
||||
[Editable(), Serialize("0.0,0.0", false)]
|
||||
public Vector2 VelocityRange { get; private set; }
|
||||
|
||||
[Editable(), Serialize("1.0,1.0", false)]
|
||||
public Vector2 ScaleRange { get; private set; }
|
||||
|
||||
[Editable(), Serialize(0, false)]
|
||||
public int ParticleBurstAmount { get; private set; }
|
||||
|
||||
[Editable(), Serialize(1.0f, false)]
|
||||
public float ParticleBurstInterval { get; private set; }
|
||||
|
||||
[Editable(), Serialize(1.0f, false)]
|
||||
public float ParticlesPerSecond { get; private set; }
|
||||
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return TextManager.Get("particleeditor.emitter");
|
||||
}
|
||||
}
|
||||
|
||||
public Dictionary<string, SerializableProperty> SerializableProperties
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public Emitter()
|
||||
{
|
||||
ScaleRange = Vector2.One;
|
||||
AngleRange = new Vector2(0.0f, 360.0f);
|
||||
ParticleBurstAmount = 1;
|
||||
ParticleBurstInterval = 1.0f;
|
||||
|
||||
SerializableProperties = SerializableProperty.GetProperties(this);
|
||||
}
|
||||
}
|
||||
|
||||
private GUIComponent rightPanel, leftPanel;
|
||||
private GUIListBox prefabList;
|
||||
private GUITextBox filterBox;
|
||||
@@ -73,23 +25,38 @@ namespace Barotrauma
|
||||
|
||||
private ParticlePrefab selectedPrefab;
|
||||
|
||||
private Emitter emitter;
|
||||
private readonly ParticleEmitterProperties emitterProperties = new ParticleEmitterProperties(null)
|
||||
{
|
||||
ScaleMax = 1f,
|
||||
ScaleMin = 1f,
|
||||
AngleMax = 360f,
|
||||
AngleMin = 0,
|
||||
ParticlesPerSecond = 1f
|
||||
};
|
||||
|
||||
private ParticleEmitterPrefab emitterPrefab;
|
||||
private ParticleEmitter emitter;
|
||||
|
||||
private readonly Camera cam;
|
||||
|
||||
public override Camera Cam
|
||||
{
|
||||
get
|
||||
{
|
||||
return cam;
|
||||
}
|
||||
}
|
||||
public override Camera Cam => cam;
|
||||
|
||||
private const string sizeRefFilePath = "Content/size_reference.png";
|
||||
private readonly Texture2D sizeReference;
|
||||
private Vector2 sizeRefPosition = Vector2.Zero;
|
||||
private readonly Vector2 sizeRefOrigin;
|
||||
private bool sizeRefEnabled;
|
||||
|
||||
public ParticleEditorScreen()
|
||||
{
|
||||
cam = new Camera();
|
||||
GameMain.Instance.ResolutionChanged += CreateUI;
|
||||
CreateUI();
|
||||
if (File.Exists(sizeRefFilePath))
|
||||
{
|
||||
sizeReference = TextureLoader.FromFile(sizeRefFilePath, compress: false);
|
||||
sizeRefOrigin = new Vector2(sizeReference.Width / 2f, sizeReference.Height / 2f);
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateUI()
|
||||
@@ -122,8 +89,8 @@ namespace Barotrauma
|
||||
}
|
||||
};
|
||||
|
||||
var serializeToClipBoardButton = new GUIButton(new RectTransform(new Vector2(1.0f, 0.03f), paddedRightPanel.RectTransform),
|
||||
TextManager.Get("editor.copytoclipboard"))
|
||||
new GUIButton(new RectTransform(new Vector2(1.0f, 0.03f), paddedRightPanel.RectTransform),
|
||||
TextManager.Get("ParticleEditor.CopyPrefabToClipboard"))
|
||||
{
|
||||
OnClicked = (btn, obj) =>
|
||||
{
|
||||
@@ -132,11 +99,18 @@ namespace Barotrauma
|
||||
}
|
||||
};
|
||||
|
||||
emitter = new Emitter();
|
||||
var emitterEditorContainer = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.25f), paddedRightPanel.RectTransform), style: null);
|
||||
var emitterEditor = new SerializableEntityEditor(emitterEditorContainer.RectTransform, emitter, false, true, elementHeight: 20, titleFont: GUI.SubHeadingFont);
|
||||
emitterEditor.RectTransform.RelativeSize = Vector2.One;
|
||||
emitterEditorContainer.RectTransform.Resize(new Point(emitterEditorContainer.RectTransform.NonScaledSize.X, emitterEditor.ContentHeight), false);
|
||||
new GUIButton(new RectTransform(new Vector2(1.0f, 0.03f), paddedRightPanel.RectTransform),
|
||||
TextManager.Get("ParticleEditor.CopyEmitterToClipboard"))
|
||||
{
|
||||
OnClicked = (btn, obj) =>
|
||||
{
|
||||
SerializeEmitterToClipboard();
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
var emitterListBox = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.25f), paddedRightPanel.RectTransform));
|
||||
new SerializableEntityEditor(emitterListBox.Content.RectTransform, emitterProperties, false, true, elementHeight: 20, titleFont: GUI.SubHeadingFont);
|
||||
|
||||
var listBox = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.6f), paddedRightPanel.RectTransform));
|
||||
|
||||
@@ -157,7 +131,10 @@ namespace Barotrauma
|
||||
prefabList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.8f), paddedLeftPanel.RectTransform));
|
||||
prefabList.OnSelected += (GUIComponent component, object obj) =>
|
||||
{
|
||||
cam.Position = Vector2.Zero;
|
||||
selectedPrefab = obj as ParticlePrefab;
|
||||
emitterPrefab = new ParticleEmitterPrefab(selectedPrefab, emitterProperties);
|
||||
emitter = new ParticleEmitter(emitterPrefab);
|
||||
listBox.ClearChildren();
|
||||
new SerializableEntityEditor(listBox.Content.RectTransform, selectedPrefab, false, true, elementHeight: 20, titleFont: GUI.SubHeadingFont);
|
||||
//listBox.Content.RectTransform.NonScaledSize = particlePrefabEditor.RectTransform.NonScaledSize;
|
||||
@@ -198,19 +175,6 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
private void Emit(Vector2 position)
|
||||
{
|
||||
float angle = MathHelper.ToRadians(Rand.Range(emitter.AngleRange.X, emitter.AngleRange.Y));
|
||||
Vector2 velocity = new Vector2((float)Math.Cos(angle), (float)Math.Sin(angle)) * Rand.Range(emitter.VelocityRange.X, emitter.VelocityRange.Y);
|
||||
|
||||
var particle = GameMain.ParticleManager.CreateParticle(selectedPrefab, position, velocity, 0.0f);
|
||||
|
||||
if (particle != null)
|
||||
{
|
||||
particle.Size *= Rand.Range(emitter.ScaleRange.X, emitter.ScaleRange.Y);
|
||||
}
|
||||
}
|
||||
|
||||
private void FilterEmitters(string text)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(text))
|
||||
@@ -263,9 +227,34 @@ namespace Barotrauma
|
||||
Barotrauma.IO.Validation.SkipValidationInDebugBuilds = false;
|
||||
}
|
||||
|
||||
private void SerializeEmitterToClipboard()
|
||||
{
|
||||
XElement element = new XElement(nameof(ParticleEmitter));
|
||||
if (selectedPrefab is { } prefab)
|
||||
{
|
||||
element.Add(new XAttribute("particle", prefab.Identifier));
|
||||
}
|
||||
|
||||
SerializableProperty.SerializeProperties(emitterProperties, element, saveIfDefault: false, ignoreEditable: true);
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
System.Xml.XmlWriterSettings settings = new System.Xml.XmlWriterSettings
|
||||
{
|
||||
OmitXmlDeclaration = true
|
||||
};
|
||||
|
||||
using (var writer = System.Xml.XmlWriter.Create(sb, settings))
|
||||
{
|
||||
element.WriteTo(writer);
|
||||
writer.Flush();
|
||||
}
|
||||
|
||||
Clipboard.SetText(sb.ToString());
|
||||
}
|
||||
|
||||
private void SerializeToClipboard(ParticlePrefab prefab)
|
||||
{
|
||||
#if WINDOWS
|
||||
if (prefab == null) { return; }
|
||||
|
||||
System.Xml.XmlWriterSettings settings = new System.Xml.XmlWriterSettings
|
||||
@@ -308,43 +297,39 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
Clipboard.SetText(sb.ToString());
|
||||
#endif
|
||||
}
|
||||
|
||||
public override void Update(double deltaTime)
|
||||
{
|
||||
cam.MoveCamera((float)deltaTime, allowMove: true, allowZoom: GUI.MouseOn == null);
|
||||
|
||||
if (selectedPrefab != null)
|
||||
|
||||
if (GUI.MouseOn is null && PlayerInput.PrimaryMouseButtonHeld())
|
||||
{
|
||||
emitter.EmitTimer += (float)deltaTime;
|
||||
emitter.BurstTimer += (float)deltaTime;
|
||||
sizeRefPosition = cam.ScreenToWorld(PlayerInput.MousePosition);
|
||||
}
|
||||
|
||||
if (PlayerInput.SecondaryMouseButtonClicked())
|
||||
{
|
||||
CreateContextMenu();
|
||||
}
|
||||
|
||||
if (emitter.ParticlesPerSecond > 0)
|
||||
{
|
||||
float emitInterval = 1.0f / emitter.ParticlesPerSecond;
|
||||
while (emitter.EmitTimer > emitInterval)
|
||||
{
|
||||
Emit(Vector2.Zero);
|
||||
emitter.EmitTimer -= emitInterval;
|
||||
}
|
||||
}
|
||||
|
||||
if (emitter.BurstTimer > emitter.ParticleBurstInterval)
|
||||
{
|
||||
for (int i = 0; i < emitter.ParticleBurstAmount; i++)
|
||||
{
|
||||
Emit(Vector2.Zero);
|
||||
}
|
||||
emitter.BurstTimer = 0.0f;
|
||||
}
|
||||
|
||||
if (selectedPrefab != null && emitter != null)
|
||||
{
|
||||
emitter.Emit((float) deltaTime, Vector2.Zero);
|
||||
}
|
||||
|
||||
GameMain.ParticleManager.Update((float)deltaTime);
|
||||
}
|
||||
|
||||
private void CreateContextMenu()
|
||||
{
|
||||
GUIContextMenu.CreateContextMenu
|
||||
(
|
||||
new ContextMenuOption("subeditor.editbackgroundcolor", true, CreateBackgroundColorPicker),
|
||||
new ContextMenuOption("editor.togglereferencecharacter", true, delegate { sizeRefEnabled = !sizeRefEnabled; })
|
||||
);
|
||||
}
|
||||
|
||||
public override void Draw(double deltaTime, GraphicsDevice graphics, SpriteBatch spriteBatch)
|
||||
{
|
||||
cam.UpdateTransform();
|
||||
@@ -357,7 +342,7 @@ namespace Barotrauma
|
||||
null, null, null, null,
|
||||
cam.Transform);
|
||||
|
||||
graphics.Clear(new Color(0.051f, 0.149f, 0.271f, 1.0f));
|
||||
graphics.Clear(BackgroundColor);
|
||||
|
||||
GameMain.ParticleManager.Draw(spriteBatch, false, false, ParticleBlendState.AlphaBlend);
|
||||
GameMain.ParticleManager.Draw(spriteBatch, true, false, ParticleBlendState.AlphaBlend);
|
||||
@@ -374,6 +359,20 @@ namespace Barotrauma
|
||||
|
||||
spriteBatch.End();
|
||||
|
||||
if (sizeRefEnabled && !(sizeReference is null))
|
||||
{
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred,
|
||||
BlendState.NonPremultiplied,
|
||||
null, null, null, null,
|
||||
cam.Transform);
|
||||
|
||||
Vector2 pos = sizeRefPosition;
|
||||
pos.Y = -pos.Y;
|
||||
spriteBatch.Draw(sizeReference, pos, null, Color.White, 0f, sizeRefOrigin, new Vector2(0.4f), SpriteEffects.None, 0f);
|
||||
|
||||
spriteBatch.End();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------
|
||||
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, null, GUI.SamplerState, null, GameMain.ScissorTestEnable);
|
||||
|
||||
@@ -66,6 +66,8 @@ namespace Barotrauma
|
||||
yield return CoroutineStatus.Success;
|
||||
}
|
||||
|
||||
public virtual void OnFileDropped(string filePath, string extension) { }
|
||||
|
||||
public virtual void Release()
|
||||
{
|
||||
frame.RectTransform.Parent = null;
|
||||
|
||||
@@ -363,7 +363,10 @@ namespace Barotrauma
|
||||
"VineSprite",
|
||||
"LeafSprite",
|
||||
"FlowerSprite",
|
||||
"DecorativeSprite"
|
||||
"DecorativeSprite",
|
||||
"BarrelSprite",
|
||||
"RailSprite",
|
||||
"SchematicSprite"
|
||||
};
|
||||
|
||||
foreach (string spriteElementName in spriteElementNames)
|
||||
|
||||
@@ -26,6 +26,8 @@ namespace Barotrauma
|
||||
//listbox that shows the files included in the item being created
|
||||
private GUIListBox createItemFileList;
|
||||
|
||||
private GUIImage previewIcon;
|
||||
|
||||
private System.IO.FileSystemWatcher createItemWatcher;
|
||||
|
||||
private readonly List<GUIButton> tabButtons = new List<GUIButton>();
|
||||
@@ -277,6 +279,24 @@ namespace Barotrauma
|
||||
SelectTab(Tab.Mods);
|
||||
}
|
||||
|
||||
public override void OnFileDropped(string filePath, string extension)
|
||||
{
|
||||
switch (extension)
|
||||
{
|
||||
case ".png": // workshop preview
|
||||
case ".jpg":
|
||||
case ".jpeg":
|
||||
if (previewIcon == null || itemContentPackage == null) { break; }
|
||||
|
||||
OnPreviewImageSelected(previewIcon, filePath);
|
||||
break;
|
||||
|
||||
default:
|
||||
DebugConsole.ThrowError($"Could not drag and drop the file. \"{extension}\" is not a valid file extension! (expected .png, .jpg or .jpeg)");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnItemInstalled(ulong itemId)
|
||||
{
|
||||
RefreshSubscribedItems();
|
||||
@@ -1263,7 +1283,7 @@ namespace Barotrauma
|
||||
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), topLeftColumn.RectTransform), TextManager.Get("WorkshopItemPreviewImage"), font: GUI.SubHeadingFont);
|
||||
|
||||
var previewIcon = new GUIImage(new RectTransform(new Vector2(1.0f, 0.7f), topLeftColumn.RectTransform), SteamManager.DefaultPreviewImage, scaleToFit: true);
|
||||
previewIcon = new GUIImage(new RectTransform(new Vector2(1.0f, 0.7f), topLeftColumn.RectTransform), SteamManager.DefaultPreviewImage, scaleToFit: true);
|
||||
new GUIButton(new RectTransform(new Vector2(1.0f, 0.2f), topLeftColumn.RectTransform), TextManager.Get("WorkshopItemBrowse"), style: "GUIButtonSmall")
|
||||
{
|
||||
OnClicked = (btn, userdata) =>
|
||||
|
||||
@@ -19,7 +19,7 @@ using Barotrauma.IO;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
class SubEditorScreen : Screen
|
||||
class SubEditorScreen : EditorScreen
|
||||
{
|
||||
private static readonly string[] crewExperienceLevels =
|
||||
{
|
||||
@@ -177,8 +177,6 @@ namespace Barotrauma
|
||||
|
||||
private Mode mode;
|
||||
|
||||
private Color backgroundColor = GameSettings.SubEditorBackgroundColor;
|
||||
|
||||
private Vector2 MeasurePositionStart = Vector2.Zero;
|
||||
|
||||
// Prevent the mode from changing
|
||||
@@ -1007,6 +1005,12 @@ namespace Barotrauma
|
||||
string name = legacy ? TextManager.GetWithVariable("legacyitemformat", "[name]", ep.Name) : ep.Name;
|
||||
frame.ToolTip = string.IsNullOrEmpty(ep.Description) ? name : name + '\n' + ep.Description;
|
||||
|
||||
if (ep.ContentPackage != GameMain.VanillaContent && ep.ContentPackage != null)
|
||||
{
|
||||
frame.Color = Color.Magenta;
|
||||
string colorStr = XMLExtensions.ColorToString(Color.MediumPurple);
|
||||
frame.ToolTip += $"\n‖color:{colorStr}‖{ep.ContentPackage?.Name}‖color:end‖";
|
||||
}
|
||||
if (ep.HideInMenus)
|
||||
{
|
||||
frame.Color = Color.Red;
|
||||
@@ -1225,6 +1229,50 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnFileDropped(string filePath, string extension)
|
||||
{
|
||||
switch (extension)
|
||||
{
|
||||
case ".sub": // Submarine
|
||||
SubmarineInfo info = new SubmarineInfo(filePath);
|
||||
if (info.IsFileCorrupted)
|
||||
{
|
||||
DebugConsole.ThrowError($"Could not drag and drop the file. File \"{filePath}\" is corrupted!");
|
||||
info.Dispose();
|
||||
return;
|
||||
}
|
||||
|
||||
string body = TextManager.GetWithVariable("SubEditor.LoadConfirmBody", "[submarine]", info.Name);
|
||||
GUI.AskForConfirmation(TextManager.Get("Load"), body, onConfirm: () => LoadSub(info), onDeny: () => info.Dispose());
|
||||
break;
|
||||
|
||||
case ".xml": // Item Assembly
|
||||
string text = File.ReadAllText(filePath);
|
||||
// PlayerInput.MousePosition doesn't update while the window is not active so we need to use this method
|
||||
Vector2 mousePos = Mouse.GetState().Position.ToVector2();
|
||||
PasteAssembly(text, cam.ScreenToWorld(mousePos));
|
||||
break;
|
||||
|
||||
case ".png": // submarine preview
|
||||
case ".jpg":
|
||||
case ".jpeg":
|
||||
if (saveFrame == null) { break; }
|
||||
|
||||
Texture2D texture = Sprite.LoadTexture(filePath);
|
||||
previewImage.Sprite = new Sprite(texture, null, null);
|
||||
if (Submarine.MainSub != null)
|
||||
{
|
||||
Submarine.MainSub.Info.PreviewImage = previewImage.Sprite;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
DebugConsole.ThrowError($"Could not drag and drop the file. \"{extension}\" is not a valid file extension! (expected .xml, .sub, .png or .jpg)");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Coroutine that waits 5 minutes and then runs itself recursively again to save the submarine into a temporary file
|
||||
/// </summary>
|
||||
@@ -1466,6 +1514,9 @@ namespace Barotrauma
|
||||
case SubmarineType.Wreck:
|
||||
contentType = ContentType.Wreck;
|
||||
break;
|
||||
case SubmarineType.EnemySubmarine:
|
||||
contentType = ContentType.EnemySubmarine;
|
||||
break;
|
||||
}
|
||||
if (contentType != ContentType.Submarine)
|
||||
{
|
||||
@@ -1504,8 +1555,13 @@ namespace Barotrauma
|
||||
if (!string.IsNullOrEmpty(specialSavePath) &&
|
||||
(string.IsNullOrEmpty(Submarine.MainSub?.Info.FilePath) || Path.GetFileNameWithoutExtension(Submarine.MainSub.Info.Name) != nameBox.Text || Path.GetDirectoryName(Submarine.MainSub?.Info.FilePath) != specialSavePath))
|
||||
{
|
||||
string submarineTypeTag = "SubmarineType." + Submarine.MainSub.Info.Type;
|
||||
if (Submarine.MainSub.Info.Type == SubmarineType.EnemySubmarine && !TextManager.ContainsTag(submarineTypeTag))
|
||||
{
|
||||
submarineTypeTag = "MissionType.Pirate";
|
||||
}
|
||||
var msgBox = new GUIMessageBox("", TextManager.GetWithVariables("savesubtospecialfolderprompt",
|
||||
new string[] { "[type]", "[outpostpath]" }, new string[] { TextManager.Get("submarinetype." + Submarine.MainSub.Info.Type), specialSavePath }),
|
||||
new string[] { "[type]", "[outpostpath]" }, new string[] { TextManager.Get(submarineTypeTag), specialSavePath }),
|
||||
new string[] { TextManager.Get("yes"), TextManager.Get("no") });
|
||||
msgBox.Buttons[0].OnClicked = (bt, userdata) =>
|
||||
{
|
||||
@@ -1781,7 +1837,12 @@ namespace Barotrauma
|
||||
subTypeContainer.RectTransform.MinSize = new Point(0, subTypeContainer.RectTransform.Children.Max(c => c.MinSize.Y));
|
||||
foreach (SubmarineType subType in Enum.GetValues(typeof(SubmarineType)))
|
||||
{
|
||||
subTypeDropdown.AddItem(TextManager.Get("submarinetype."+subType.ToString().ToLowerInvariant()), subType);
|
||||
string textTag = "SubmarineType." + subType;
|
||||
if (subType == SubmarineType.EnemySubmarine && !TextManager.ContainsTag(textTag))
|
||||
{
|
||||
textTag = "MissionType.Pirate";
|
||||
}
|
||||
subTypeDropdown.AddItem(TextManager.Get(textTag), subType);
|
||||
}
|
||||
|
||||
//---------------------------------------
|
||||
@@ -2020,30 +2081,27 @@ namespace Barotrauma
|
||||
Submarine.MainSub.Info.Price = Math.Max(Submarine.MainSub.Info.Price, basePrice);
|
||||
}
|
||||
|
||||
if (!Submarine.MainSub.Info.HasTag(SubmarineTag.Shuttle))
|
||||
var classGroup = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.25f), subSettingsContainer.RectTransform), isHorizontal: true)
|
||||
{
|
||||
var classGroup = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.25f), subSettingsContainer.RectTransform), isHorizontal: true)
|
||||
{
|
||||
Stretch = true
|
||||
};
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.6f, 1.0f), classGroup.RectTransform),
|
||||
TextManager.Get("submarineclass"), textAlignment: Alignment.CenterLeft, wrap: true);
|
||||
GUIDropDown classDropDown = new GUIDropDown(new RectTransform(new Vector2(0.4f, 1.0f), classGroup.RectTransform));
|
||||
classDropDown.RectTransform.MinSize = new Point(0, subTypeContainer.RectTransform.Children.Max(c => c.MinSize.Y));
|
||||
classDropDown.AddItem(TextManager.Get("submarineclass.undefined"), SubmarineClass.Undefined);
|
||||
classDropDown.AddItem(TextManager.Get("submarineclass.scout"), SubmarineClass.Scout);
|
||||
classDropDown.AddItem(TextManager.Get("submarineclass.attack"), SubmarineClass.Attack);
|
||||
classDropDown.AddItem(TextManager.Get("submarineclass.transport"), SubmarineClass.Transport);
|
||||
classDropDown.AddItem(TextManager.Get("submarineclass.deepdiver"), SubmarineClass.DeepDiver);
|
||||
classDropDown.OnSelected += (selected, userdata) =>
|
||||
{
|
||||
SubmarineClass submarineClass = (SubmarineClass)userdata;
|
||||
Submarine.MainSub.Info.SubmarineClass = submarineClass;
|
||||
return true;
|
||||
};
|
||||
|
||||
classDropDown.SelectItem(Submarine.MainSub.Info.SubmarineClass);
|
||||
}
|
||||
Stretch = true
|
||||
};
|
||||
var classText = new GUITextBlock(new RectTransform(new Vector2(0.6f, 1.0f), classGroup.RectTransform),
|
||||
TextManager.Get("submarineclass"), textAlignment: Alignment.CenterLeft, wrap: true);
|
||||
GUIDropDown classDropDown = new GUIDropDown(new RectTransform(new Vector2(0.4f, 1.0f), classGroup.RectTransform));
|
||||
classDropDown.RectTransform.MinSize = new Point(0, subTypeContainer.RectTransform.Children.Max(c => c.MinSize.Y));
|
||||
classDropDown.AddItem(TextManager.Get("submarineclass.undefined"), SubmarineClass.Undefined);
|
||||
classDropDown.AddItem(TextManager.Get("submarineclass.scout"), SubmarineClass.Scout);
|
||||
classDropDown.AddItem(TextManager.Get("submarineclass.attack"), SubmarineClass.Attack);
|
||||
classDropDown.AddItem(TextManager.Get("submarineclass.transport"), SubmarineClass.Transport);
|
||||
classDropDown.AddItem(TextManager.Get("submarineclass.deepdiver"), SubmarineClass.DeepDiver);
|
||||
classDropDown.OnSelected += (selected, userdata) =>
|
||||
{
|
||||
SubmarineClass submarineClass = (SubmarineClass)userdata;
|
||||
Submarine.MainSub.Info.SubmarineClass = submarineClass;
|
||||
return true;
|
||||
};
|
||||
classDropDown.SelectItem(Submarine.MainSub.Info.SubmarineClass);
|
||||
classText.Enabled = classDropDown.ButtonEnabled = !Submarine.MainSub.Info.HasTag(SubmarineTag.Shuttle);
|
||||
|
||||
var crewSizeArea = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.25f), subSettingsContainer.RectTransform), isHorizontal: true)
|
||||
{
|
||||
@@ -2216,17 +2274,29 @@ namespace Barotrauma
|
||||
{
|
||||
Selected = Submarine.MainSub != null && Submarine.MainSub.Info.HasTag(tag),
|
||||
UserData = tag,
|
||||
|
||||
OnSelected = (GUITickBox tickBox) =>
|
||||
{
|
||||
if (Submarine.MainSub == null) return false;
|
||||
SubmarineTag tag = (SubmarineTag)tickBox.UserData;
|
||||
if (tag == SubmarineTag.Shuttle)
|
||||
{
|
||||
if (tickBox.Selected)
|
||||
{
|
||||
classDropDown.SelectItem(SubmarineClass.Undefined);
|
||||
}
|
||||
else
|
||||
{
|
||||
classDropDown.SelectItem(Submarine.MainSub.Info.SubmarineClass);
|
||||
}
|
||||
classText.Enabled = classDropDown.ButtonEnabled = !tickBox.Selected;
|
||||
}
|
||||
if (tickBox.Selected)
|
||||
{
|
||||
Submarine.MainSub.Info.AddTag((SubmarineTag)tickBox.UserData);
|
||||
Submarine.MainSub.Info.AddTag(tag);
|
||||
}
|
||||
else
|
||||
{
|
||||
Submarine.MainSub.Info.RemoveTag((SubmarineTag)tickBox.UserData);
|
||||
Submarine.MainSub.Info.RemoveTag(tag);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -2305,7 +2375,6 @@ namespace Barotrauma
|
||||
if (quickSave) { SaveSub(saveButton, saveButton.UserData); }
|
||||
}
|
||||
|
||||
|
||||
private void CreateSaveAssemblyScreen()
|
||||
{
|
||||
SetMode(Mode.Default);
|
||||
@@ -2317,10 +2386,10 @@ namespace Barotrauma
|
||||
|
||||
new GUIFrame(new RectTransform(GUI.Canvas.RelativeSize, saveFrame.RectTransform, Anchor.Center), style: "GUIBackgroundBlocker");
|
||||
|
||||
var innerFrame = new GUIFrame(new RectTransform(new Vector2(0.25f, 0.3f), saveFrame.RectTransform, Anchor.Center) { MinSize = new Point(400, 300) });
|
||||
var innerFrame = new GUIFrame(new RectTransform(new Vector2(0.25f, 0.35f), saveFrame.RectTransform, Anchor.Center) { MinSize = new Point(400, 350) });
|
||||
GUILayoutGroup paddedSaveFrame = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.9f), innerFrame.RectTransform, Anchor.Center))
|
||||
{
|
||||
AbsoluteSpacing = 5,
|
||||
AbsoluteSpacing = GUI.IntScale(5),
|
||||
Stretch = true
|
||||
};
|
||||
|
||||
@@ -2337,15 +2406,22 @@ namespace Barotrauma
|
||||
};
|
||||
#endif
|
||||
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), paddedSaveFrame.RectTransform),
|
||||
TextManager.Get("SaveItemAssemblyDialogDescription"));
|
||||
descriptionBox = new GUITextBox(new RectTransform(new Vector2(1.0f, 0.3f), paddedSaveFrame.RectTransform))
|
||||
var descriptionContainer = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.5f), paddedSaveFrame.RectTransform));
|
||||
descriptionBox = new GUITextBox(new RectTransform(Vector2.One, descriptionContainer.Content.RectTransform, Anchor.TopLeft),
|
||||
font: GUI.SmallFont, style: "GUITextBoxNoBorder", wrap: true, textAlignment: Alignment.TopLeft)
|
||||
{
|
||||
UserData = "description",
|
||||
Wrap = true,
|
||||
Text = ""
|
||||
Padding = new Vector4(10 * GUI.Scale)
|
||||
};
|
||||
|
||||
|
||||
descriptionBox.OnTextChanged += (textBox, text) =>
|
||||
{
|
||||
Vector2 textSize = textBox.Font.MeasureString(descriptionBox.WrappedText);
|
||||
textBox.RectTransform.NonScaledSize = new Point(textBox.RectTransform.NonScaledSize.X, Math.Max(descriptionContainer.Content.Rect.Height, (int)textSize.Y + 10));
|
||||
descriptionContainer.UpdateScrollBarSize();
|
||||
descriptionContainer.BarScroll = 1.0f;
|
||||
return true;
|
||||
};
|
||||
|
||||
var buttonArea = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.1f), paddedSaveFrame.RectTransform), style: null);
|
||||
new GUIButton(new RectTransform(new Vector2(0.25f, 1.0f), buttonArea.RectTransform, Anchor.BottomLeft),
|
||||
TextManager.Get("Cancel"))
|
||||
@@ -2361,6 +2437,7 @@ namespace Barotrauma
|
||||
{
|
||||
OnClicked = SaveAssembly
|
||||
};
|
||||
buttonArea.RectTransform.MinSize = new Point(0, buttonArea.Children.First().RectTransform.MinSize.Y);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -2404,7 +2481,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
bool hideInMenus = !(nameBox.Parent.GetChildByUserData("hideinmenus") is GUITickBox hideInMenusTickBox) ? false : hideInMenusTickBox.Selected;
|
||||
bool hideInMenus = nameBox.Parent.GetChildByUserData("hideinmenus") is GUITickBox hideInMenusTickBox && hideInMenusTickBox.Selected;
|
||||
#if DEBUG
|
||||
string saveFolder = ItemAssemblyPrefab.VanillaSaveFolder;
|
||||
#else
|
||||
@@ -2423,7 +2500,6 @@ namespace Barotrauma
|
||||
}
|
||||
#endif
|
||||
string filePath = Path.Combine(saveFolder, nameBox.Text + ".xml");
|
||||
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
var msgBox = new GUIMessageBox(TextManager.Get("Warning"), TextManager.Get("ItemAssemblyFileExistsWarning"), new[] { TextManager.Get("Yes"), TextManager.Get("No") });
|
||||
@@ -2438,18 +2514,27 @@ namespace Barotrauma
|
||||
}
|
||||
else
|
||||
{
|
||||
Save();
|
||||
var identifier = nameBox.Text.ToLowerInvariant().Replace(" ", "");
|
||||
var existingPrefab = MapEntityPrefab.Find(null, identifier, showErrorMessages: false);
|
||||
if (existingPrefab != null && System.IO.Path.GetDirectoryName(existingPrefab.FilePath) == ItemAssemblyPrefab.VanillaSaveFolder)
|
||||
{
|
||||
var msgBox = new GUIMessageBox(TextManager.Get("Warning"), TextManager.Get("ItemAssemblyVanillaFileExistsWarning"));
|
||||
}
|
||||
else
|
||||
{
|
||||
Save();
|
||||
}
|
||||
}
|
||||
|
||||
void Save()
|
||||
{
|
||||
XDocument doc = new XDocument(ItemAssemblyPrefab.Save(MapEntity.SelectedList, nameBox.Text, descriptionBox.Text, hideInMenus));
|
||||
XDocument doc = new XDocument(ItemAssemblyPrefab.Save(MapEntity.SelectedList.ToList(), nameBox.Text, descriptionBox.Text, hideInMenus));
|
||||
#if DEBUG
|
||||
doc.Save(filePath);
|
||||
#else
|
||||
doc.SaveSafe(filePath);
|
||||
#endif
|
||||
new ItemAssemblyPrefab(filePath);
|
||||
new ItemAssemblyPrefab(filePath, allowOverwrite: true);
|
||||
UpdateEntityList();
|
||||
}
|
||||
|
||||
@@ -2519,8 +2604,13 @@ namespace Barotrauma
|
||||
{
|
||||
if (prevSub == null || prevSub.Type != sub.Type)
|
||||
{
|
||||
string textTag = "SubmarineType." + sub.Type;
|
||||
if (sub.Type == SubmarineType.EnemySubmarine && !TextManager.ContainsTag(textTag))
|
||||
{
|
||||
textTag = "MissionType.Pirate";
|
||||
}
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), subList.Content.RectTransform) { MinSize = new Point(0, 35) },
|
||||
TextManager.Get("SubmarineType." + sub.Type), font: GUI.LargeFont, textAlignment: Alignment.Center, style: "ListBoxElement")
|
||||
TextManager.Get(textTag), font: GUI.LargeFont, textAlignment: Alignment.Center, style: "ListBoxElement")
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
@@ -2712,8 +2802,15 @@ namespace Barotrauma
|
||||
if (subList.SelectedComponent == null) { return false; }
|
||||
if (!(subList.SelectedComponent.UserData is SubmarineInfo selectedSubInfo)) { return false; }
|
||||
|
||||
LoadSub(selectedSubInfo);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void LoadSub(SubmarineInfo info)
|
||||
{
|
||||
Submarine.Unload();
|
||||
var selectedSub = new Submarine(selectedSubInfo);
|
||||
var selectedSub = new Submarine(info);
|
||||
Submarine.MainSub = selectedSub;
|
||||
Submarine.MainSub.UpdateTransform(interpolate: false);
|
||||
ClearUndoBuffer();
|
||||
@@ -2744,8 +2841,6 @@ namespace Barotrauma
|
||||
};
|
||||
adjustLightsPrompt.Buttons[1].OnClicked += adjustLightsPrompt.Close;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void TryDeleteSub(SubmarineInfo sub)
|
||||
@@ -2822,7 +2917,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(entityFilterBox.Text) || dummyCharacter?.SelectedConstruction?.OwnInventory != null)
|
||||
if (!string.IsNullOrEmpty(entityFilterBox.Text))
|
||||
{
|
||||
FilterEntities(entityFilterBox.Text);
|
||||
}
|
||||
@@ -2835,7 +2930,7 @@ namespace Barotrauma
|
||||
|
||||
private void FilterEntities(string filter)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(filter) && dummyCharacter?.SelectedConstruction?.OwnInventory == null)
|
||||
if (string.IsNullOrWhiteSpace(filter))
|
||||
{
|
||||
allEntityList.Visible = false;
|
||||
categorizedEntityList.Visible = true;
|
||||
@@ -2862,11 +2957,7 @@ namespace Barotrauma
|
||||
{
|
||||
child.Visible =
|
||||
(!selectedCategory.HasValue || ((MapEntityPrefab)child.UserData).Category.HasFlag(selectedCategory)) &&
|
||||
((MapEntityPrefab)child.UserData).Name.ToLower().Contains(filter); ;
|
||||
if (child.Visible && dummyCharacter?.SelectedConstruction?.OwnInventory != null)
|
||||
{
|
||||
child.Visible = child.UserData is MapEntityPrefab item && IsItemPrefab(item);
|
||||
}
|
||||
((MapEntityPrefab)child.UserData).Name.ToLower().Contains(filter);
|
||||
}
|
||||
allEntityList.UpdateScrollBarSize();
|
||||
allEntityList.BarScroll = 0.0f;
|
||||
@@ -2942,11 +3033,14 @@ namespace Barotrauma
|
||||
new ContextMenuOption("SubEditor.EditBackgroundColor", isEnabled: true, onSelected: CreateBackgroundColorPicker),
|
||||
new ContextMenuOption("SubEditor.ToggleTransparency", isEnabled: true, onSelected: () => TransparentWiringMode = !TransparentWiringMode),
|
||||
new ContextMenuOption("SubEditor.ToggleGrid", isEnabled: true, onSelected: () => ShouldDrawGrid = !ShouldDrawGrid),
|
||||
new ContextMenuOption("SubEditor.PasteAssembly", isEnabled: true, PasteAssembly),
|
||||
new ContextMenuOption("SubEditor.PasteAssembly", isEnabled: true, () => PasteAssembly()),
|
||||
new ContextMenuOption("Editor.SelectSame", isEnabled: targets.Count > 0, onSelected: delegate
|
||||
{
|
||||
IEnumerable<MapEntity> matching = MapEntity.mapEntityList.Where(e => e.prefab != null && targets.Any(t => t.prefab?.Identifier == e.prefab.Identifier) && !MapEntity.SelectedList.Contains(e));
|
||||
MapEntity.SelectedList.AddRange(matching);
|
||||
foreach (MapEntity match in MapEntity.mapEntityList.Where(e => e.prefab != null && targets.Any(t => t.prefab?.Identifier == e.prefab.Identifier) && !MapEntity.SelectedList.Contains(e)))
|
||||
{
|
||||
if (MapEntity.SelectedList.Contains(match)) { continue; }
|
||||
MapEntity.SelectedList.Add(match);
|
||||
}
|
||||
}),
|
||||
new ContextMenuOption("SubEditor.AddImage", isEnabled: true, onSelected: ImageManager.CreateImageWizard),
|
||||
new ContextMenuOption("SubEditor.ToggleImageEditing", isEnabled: true, onSelected: delegate
|
||||
@@ -2973,10 +3067,11 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
private void PasteAssembly()
|
||||
private void PasteAssembly(string text = null, Vector2? pos = null)
|
||||
{
|
||||
string clipboard = Clipboard.GetText();
|
||||
if (string.IsNullOrWhiteSpace(clipboard))
|
||||
pos ??= cam.ScreenToWorld(PlayerInput.MousePosition);
|
||||
text ??= Clipboard.GetText();
|
||||
if (string.IsNullOrWhiteSpace(text))
|
||||
{
|
||||
DebugConsole.ThrowError("Unable to paste assembly: Clipboard content is empty.");
|
||||
return;
|
||||
@@ -2986,7 +3081,7 @@ namespace Barotrauma
|
||||
|
||||
try
|
||||
{
|
||||
element = XDocument.Parse(clipboard).Root;
|
||||
element = XDocument.Parse(text).Root;
|
||||
}
|
||||
catch (Exception) { /* ignored */ }
|
||||
|
||||
@@ -2996,12 +3091,11 @@ namespace Barotrauma
|
||||
return;
|
||||
}
|
||||
|
||||
Vector2 pos = cam.ScreenToWorld(PlayerInput.MousePosition);
|
||||
Submarine sub = Submarine.MainSub;
|
||||
List<MapEntity> entities;
|
||||
try
|
||||
{
|
||||
entities = ItemAssemblyPrefab.PasteEntities(pos, sub, element, selectInstance: true);
|
||||
entities = ItemAssemblyPrefab.PasteEntities(pos.Value, sub, element, selectInstance: true);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -3143,6 +3237,8 @@ namespace Barotrauma
|
||||
|
||||
Color newColor = SetColor(null);
|
||||
|
||||
if (!IsSubEditor()) { return true; }
|
||||
|
||||
Dictionary<object, List<ISerializableEntity>> oldProperties = new Dictionary<object, List<ISerializableEntity>>();
|
||||
|
||||
foreach (var (sEntity, color, _) in entities)
|
||||
@@ -3274,57 +3370,6 @@ namespace Barotrauma
|
||||
|
||||
static string ColorToHex(Color color) => $"#{(color.R << 16 | color.G << 8 | color.B):X6}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a color picker that can be used to change the submarine editor's background color
|
||||
/// </summary>
|
||||
private void CreateBackgroundColorPicker()
|
||||
{
|
||||
var msgBox = new GUIMessageBox(TextManager.Get("CharacterEditor.EditBackgroundColor"), "", new[] { TextManager.Get("Reset"), TextManager.Get("OK")}, new Vector2(0.2f, 0.175f), minSize: new Point(300, 175));
|
||||
|
||||
var rgbLayout = new GUILayoutGroup(new RectTransform(new Vector2(1f, 0.25f), msgBox.Content.RectTransform), isHorizontal: true);
|
||||
|
||||
// Generate R,G,B labels and parent elements
|
||||
var layoutParents = new GUILayoutGroup[3];
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
var colorContainer = new GUILayoutGroup(new RectTransform(new Vector2(0.33f, 1), rgbLayout.RectTransform), isHorizontal: true) { Stretch = true };
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.2f, 1), colorContainer.RectTransform, Anchor.CenterLeft) { MinSize = new Point(15, 0) }, GUI.colorComponentLabels[i], font: GUI.SmallFont, textAlignment: Alignment.Center);
|
||||
layoutParents[i] = colorContainer;
|
||||
}
|
||||
|
||||
// attach number inputs to our generated parent elements
|
||||
var rInput = new GUINumberInput(new RectTransform(new Vector2(0.7f, 1f), layoutParents[0].RectTransform), GUINumberInput.NumberType.Int) { IntValue = backgroundColor.R };
|
||||
var gInput = new GUINumberInput(new RectTransform(new Vector2(0.7f, 1f), layoutParents[1].RectTransform), GUINumberInput.NumberType.Int) { IntValue = backgroundColor.G };
|
||||
var bInput = new GUINumberInput(new RectTransform(new Vector2(0.7f, 1f), layoutParents[2].RectTransform), GUINumberInput.NumberType.Int) { IntValue = backgroundColor.B };
|
||||
|
||||
rInput.MinValueInt = gInput.MinValueInt = bInput.MinValueInt = 0;
|
||||
rInput.MaxValueInt = gInput.MaxValueInt = bInput.MaxValueInt = 255;
|
||||
|
||||
rInput.OnValueChanged = gInput.OnValueChanged = bInput.OnValueChanged = delegate
|
||||
{
|
||||
var color = new Color(rInput.IntValue, gInput.IntValue, bInput.IntValue);
|
||||
backgroundColor = color;
|
||||
GameSettings.SubEditorBackgroundColor = color;
|
||||
};
|
||||
|
||||
// Reset button
|
||||
msgBox.Buttons[0].OnClicked = (button, o) =>
|
||||
{
|
||||
rInput.IntValue = 13;
|
||||
gInput.IntValue = 37;
|
||||
bInput.IntValue = 69;
|
||||
return true;
|
||||
};
|
||||
|
||||
// Ok button
|
||||
msgBox.Buttons[1].OnClicked = (button, o) =>
|
||||
{
|
||||
msgBox.Close();
|
||||
GameMain.Config.SaveNewPlayerConfig();
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
private GUIFrame CreateWiringPanel()
|
||||
{
|
||||
@@ -3495,27 +3540,7 @@ namespace Barotrauma
|
||||
|
||||
submarineDescriptionCharacterCount.Text = text.Length + " / " + submarineDescriptionLimit;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the prefab is an item or if it only consists of items
|
||||
/// </summary>
|
||||
/// <param name="mapPrefab">The prefab to check</param>
|
||||
/// <returns>True if the the prefab is an item or it contains only items</returns>
|
||||
private bool IsItemPrefab(MapEntityPrefab mapPrefab)
|
||||
{
|
||||
if (dummyCharacter?.SelectedConstruction == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return mapPrefab switch
|
||||
{
|
||||
ItemPrefab iPrefab => true,
|
||||
ItemAssemblyPrefab aPrefab => aPrefab.DisplayEntities.All(pair => pair.First is ItemPrefab),
|
||||
_ => false
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
private bool SelectPrefab(GUIComponent component, object obj)
|
||||
{
|
||||
allEntityList.Deselect();
|
||||
@@ -3983,9 +4008,9 @@ namespace Barotrauma
|
||||
{
|
||||
loadFrame.AddToGUIUpdateList();
|
||||
}
|
||||
else if (saveFrame != null)
|
||||
else
|
||||
{
|
||||
saveFrame.AddToGUIUpdateList();
|
||||
saveFrame?.AddToGUIUpdateList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4728,9 +4753,9 @@ namespace Barotrauma
|
||||
CloseItem();
|
||||
}
|
||||
}
|
||||
else if (MapEntity.SelectedList.Count == 1 && WiringMode)
|
||||
else if (MapEntity.SelectedList.Count == 1 && WiringMode && MapEntity.SelectedList.FirstOrDefault() is Item item)
|
||||
{
|
||||
(MapEntity.SelectedList[0] as Item)?.UpdateHUD(cam, dummyCharacter, (float)deltaTime);
|
||||
item.UpdateHUD(cam, dummyCharacter, (float)deltaTime);
|
||||
}
|
||||
|
||||
CharacterHUD.Update((float)deltaTime, dummyCharacter, cam);
|
||||
@@ -4753,7 +4778,7 @@ namespace Barotrauma
|
||||
sub.UpdateTransform();
|
||||
}
|
||||
|
||||
graphics.Clear(backgroundColor);
|
||||
graphics.Clear(BackgroundColor);
|
||||
|
||||
ImageManager.Draw(spriteBatch, cam);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user