(f0d812055) v0.9.9.0

This commit is contained in:
Joonas Rikkonen
2020-04-23 19:19:37 +03:00
parent b647059b93
commit ac37a3b0e4
391 changed files with 15054 additions and 5420 deletions
@@ -21,7 +21,7 @@ namespace Barotrauma
private GUIButton loadGameButton, deleteMpSaveButton;
public Action<Submarine, string, string> StartNewGame;
public Action<SubmarineInfo, string, string> StartNewGame;
public Action<string> LoadGame;
public GUIButton StartButton
@@ -32,7 +32,7 @@ namespace Barotrauma
private readonly bool isMultiplayer;
public CampaignSetupUI(bool isMultiplayer, GUIComponent newGameContainer, GUIComponent loadGameContainer, IEnumerable<Submarine> submarines, IEnumerable<string> saveFiles = null)
public CampaignSetupUI(bool isMultiplayer, GUIComponent newGameContainer, GUIComponent loadGameContainer, IEnumerable<SubmarineInfo> submarines, IEnumerable<string> saveFiles = null)
{
this.isMultiplayer = isMultiplayer;
this.newGameContainer = newGameContainer;
@@ -81,6 +81,7 @@ namespace Barotrauma
var searchTitle = new GUITextBlock(new RectTransform(new Vector2(0.001f, 1.0f), filterContainer.RectTransform), TextManager.Get("serverlog.filter"), textAlignment: Alignment.CenterLeft, font: GUI.Font);
var searchBox = new GUITextBox(new RectTransform(new Vector2(1.0f, 1.0f), filterContainer.RectTransform, Anchor.CenterRight), font: GUI.Font, createClearButton: true);
filterContainer.RectTransform.MinSize = searchBox.RectTransform.MinSize;
searchBox.OnSelected += (sender, userdata) => { searchTitle.Visible = false; };
searchBox.OnDeselected += (sender, userdata) => { searchTitle.Visible = true; };
searchBox.OnTextChanged += (textBox, text) => { FilterSubs(subList, text); return true; };
@@ -115,12 +116,12 @@ namespace Barotrauma
return false;
}
Submarine selectedSub = null;
SubmarineInfo selectedSub = null;
if (!isMultiplayer)
{
if (!(subList.SelectedData is Submarine)) { return false; }
selectedSub = subList.SelectedData as Submarine;
if (!(subList.SelectedData is SubmarineInfo)) { return false; }
selectedSub = subList.SelectedData as SubmarineInfo;
}
else
{
@@ -226,7 +227,7 @@ namespace Barotrauma
{
foreach (GUIComponent child in subList.Content.Children)
{
var sub = child.UserData as Submarine;
var sub = child.UserData as SubmarineInfo;
if (sub == null) { return; }
child.Visible = string.IsNullOrEmpty(filter) ? true : sub.DisplayName.ToLower().Contains(filter.ToLower());
}
@@ -238,7 +239,7 @@ namespace Barotrauma
(subPreviewContainer.Parent as GUILayoutGroup)?.Recalculate();
subPreviewContainer.ClearChildren();
Submarine sub = obj as Submarine;
SubmarineInfo sub = obj as SubmarineInfo;
if (sub == null) { return true; }
sub.CreatePreviewWindow(subPreviewContainer);
@@ -278,7 +279,7 @@ namespace Barotrauma
saveNameBox.Text = Path.GetFileNameWithoutExtension(savePath);
}
public void UpdateSubList(IEnumerable<Submarine> submarines)
public void UpdateSubList(IEnumerable<SubmarineInfo> submarines)
{
#if !DEBUG
var subsToShow = submarines.Where(s => !s.HasTag(SubmarineTag.HideInMenus));
@@ -288,7 +289,7 @@ namespace Barotrauma
subList.ClearChildren();
foreach (Submarine sub in subsToShow)
foreach (SubmarineInfo sub in subsToShow)
{
var textBlock = new GUITextBlock(
new RectTransform(new Vector2(1, 0.1f), subList.Content.RectTransform) { MinSize = new Point(0, 30) },
@@ -319,7 +320,7 @@ namespace Barotrauma
};
}
}
if (Submarine.SavedSubmarines.Any())
if (SubmarineInfo.SavedSubmarines.Any())
{
var nonShuttles = subsToShow.Where(s => !s.HasTag(SubmarineTag.Shuttle)).ToList();
if (nonShuttles.Count > 0)
@@ -435,8 +435,8 @@ namespace Barotrauma
{
OnClicked = (btn, userdata) =>
{
if (GameMain.GameSession?.Submarine != null &&
GameMain.GameSession.Submarine.LeftBehindSubDockingPortOccupied)
if (GameMain.GameSession?.SubmarineInfo != null &&
GameMain.GameSession.SubmarineInfo.LeftBehindSubDockingPortOccupied)
{
new GUIMessageBox("", TextManager.Get("ReplaceShuttleDockingPortOccupied"));
return true;
@@ -917,7 +917,7 @@ namespace Barotrauma
GUINumberInput.NumberType.Int)
{
MinValueInt = 0,
MaxValueInt = 100,
MaxValueInt = CargoManager.MaxQuantity,
UserData = pi,
IntValue = pi.Quantity
};
@@ -927,7 +927,11 @@ namespace Barotrauma
{
if (suppressBuySell) { return; }
PurchasedItem purchasedItem = numberInput.UserData as PurchasedItem;
if (GameMain.Client != null && !GameMain.Client.HasPermission(Networking.ClientPermissions.ManageCampaign))
{
numberInput.IntValue = purchasedItem.Quantity;
return;
}
//Attempting to buy
if (numberInput.IntValue > purchasedItem.Quantity)
{
@@ -965,15 +969,18 @@ namespace Barotrauma
private bool BuyItem(GUIComponent component, object obj)
{
if (!(obj is PurchasedItem pi) || pi.ItemPrefab == null) return false;
if (!(obj is PurchasedItem pi) || pi.ItemPrefab == null) { return false; }
if (GameMain.Client != null && !GameMain.Client.HasPermission(Networking.ClientPermissions.ManageCampaign))
{
return false;
}
var purchasedItem = Campaign.CargoManager.PurchasedItems.Find(pi2 => pi2.ItemPrefab == pi.ItemPrefab);
if (purchasedItem != null && purchasedItem.Quantity >= CargoManager.MaxQuantity) { return false; }
PriceInfo priceInfo = pi.ItemPrefab.GetPrice(Campaign.Map.CurrentLocation);
if (priceInfo == null || priceInfo.BuyPrice > Campaign.Money) return false;
if (priceInfo == null || priceInfo.BuyPrice > Campaign.Money) { return false; }
Campaign.CargoManager.PurchaseItem(pi.ItemPrefab, 1);
GameMain.Client?.SendCampaignState();
@@ -983,7 +990,7 @@ namespace Barotrauma
private bool SellItem(GUIComponent component, object obj)
{
if (!(obj is PurchasedItem pi) || pi.ItemPrefab == null) return false;
if (!(obj is PurchasedItem pi) || pi.ItemPrefab == null) { return false; }
if (GameMain.Client != null && !GameMain.Client.HasPermission(Networking.ClientPermissions.ManageCampaign))
{
@@ -1068,7 +1075,7 @@ namespace Barotrauma
(GameMain.Client == null || GameMain.Client.HasPermission(Networking.ClientPermissions.ManageCampaign));
repairItemsButton.GetChild<GUITickBox>().Selected = Campaign.PurchasedItemRepairs;
if (GameMain.GameSession?.Submarine == null || !GameMain.GameSession.Submarine.SubsLeftBehind)
if (GameMain.GameSession?.SubmarineInfo == null || !GameMain.GameSession.SubmarineInfo.SubsLeftBehind)
{
replaceShuttlesButton.Enabled = false;
replaceShuttlesButton.GetChild<GUITickBox>().Selected = false;
@@ -1166,7 +1173,7 @@ namespace Barotrauma
};
var characterPreviewContent = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.8f), characterPreviewFrame.RectTransform, Anchor.TopCenter) { RelativeOffset = new Vector2(0.0f, 0.02f) }, style: null);
characterInfo.CreateInfoFrame(characterPreviewContent);
characterInfo.CreateInfoFrame(characterPreviewContent, true);
}
var currentCrew = GameMain.GameSession.CrewManager.GetCharacterInfos();
@@ -119,9 +119,12 @@ namespace Barotrauma.CharacterEditor
if (Submarine.MainSub == null)
{
ResetVariables();
Submarine.MainSub = new Submarine("Content/AnimEditor.sub");
Submarine.MainSub.Load(unloadPrevious: false, showWarningMessages: false);
Submarine.MainSub.PhysicsBody.Enabled = false;
var subInfo = new SubmarineInfo("Content/AnimEditor.sub");
Submarine.MainSub = new Submarine(subInfo);
if (Submarine.MainSub.PhysicsBody != null)
{
Submarine.MainSub.PhysicsBody.Enabled = false;
}
originalWall = new WallGroup(new List<Structure>(Structure.WallList));
CloneWalls();
CalculateMovementLimits();
@@ -476,9 +479,16 @@ namespace Barotrauma.CharacterEditor
if (character.IsHumanoid)
{
animTestPoseToggle.Enabled = CurrentAnimation.IsGroundedAnimation;
if (animTestPoseToggle.Enabled && PlayerInput.KeyHit(Keys.X))
if (animTestPoseToggle.Enabled)
{
SetToggle(animTestPoseToggle, !animTestPoseToggle.Selected);
if (PlayerInput.KeyHit(Keys.X))
{
SetToggle(animTestPoseToggle, !animTestPoseToggle.Selected);
}
}
else
{
animTestPoseToggle.Selected = false;
}
}
if (PlayerInput.KeyHit(InputType.Run))
@@ -2117,7 +2127,7 @@ namespace Barotrauma.CharacterEditor
CreateTextures();
return true;
};
new GUIButton(new RectTransform(buttonSize, parent.RectTransform, Anchor.BottomCenter), GetCharacterEditorTranslation("RecreateRagdoll"))
var recreateButton = new GUIButton(new RectTransform(buttonSize, parent.RectTransform, Anchor.BottomCenter), GetCharacterEditorTranslation("RecreateRagdoll"))
{
ToolTip = GetCharacterEditorTranslation("RecreateRagdollTooltip"),
OnClicked = (button, data) =>
@@ -2127,6 +2137,7 @@ namespace Barotrauma.CharacterEditor
return true;
}
};
GUITextBlock.AutoScaleAndNormalize(reloadTexturesButton.TextBlock, recreateButton.TextBlock);
buttonsPanelToggle = new ToggleButton(new RectTransform(new Vector2(0.08f, 1), buttonsPanel.RectTransform, Anchor.CenterRight, Pivot.CenterLeft), Direction.Left);
buttonsPanel.RectTransform.MinSize = new Point(0, (int)(parent.RectTransform.Children.Sum(c => c.MinSize.Y) * 1.5f));
}
@@ -3117,6 +3128,8 @@ namespace Barotrauma.CharacterEditor
}
};
GUITextBlock.AutoScaleAndNormalize(layoutGroup.Children.Where(c => c is GUIButton).Select(c => ((GUIButton)c).TextBlock));
fileEditToggle = new ToggleButton(new RectTransform(new Vector2(0.08f, 1), fileEditPanel.RectTransform, Anchor.CenterLeft, Pivot.CenterRight), Direction.Right);
void ResetView()
@@ -394,7 +394,7 @@ namespace Barotrauma.CharacterEditor
return false;
}
var path = Path.GetFileName(TexturePath);
if (!path.EndsWith(".png", StringComparison.InvariantCultureIgnoreCase))
if (!path.EndsWith(".png", StringComparison.OrdinalIgnoreCase))
{
GUI.AddMessage(TextManager.Get("WrongFileType"), GUI.Style.Red);
texturePathElement.Flash(GUI.Style.Red);
@@ -724,8 +724,8 @@ namespace Barotrauma.CharacterEditor
{
ParseLimbsFromGUIElements();
ParseJointsFromGUIElements();
var main = LimbXElements.Values.Select(xe => xe.Attribute("type")).Where(a => a.Value.ToLowerInvariant() == "torso").FirstOrDefault() ??
LimbXElements.Values.Select(xe => xe.Attribute("type")).Where(a => a.Value.ToLowerInvariant() == "head").FirstOrDefault();
var main = LimbXElements.Values.Select(xe => xe.Attribute("type")).Where(a => a.Value.Equals("torso", StringComparison.OrdinalIgnoreCase)).FirstOrDefault() ??
LimbXElements.Values.Select(xe => xe.Attribute("type")).Where(a => a.Value.Equals("head", StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
if (main == null)
{
GUI.AddMessage(GetCharacterEditorTranslation("MissingTorsoOrHead"), GUI.Style.Red);
@@ -17,7 +17,7 @@ namespace Barotrauma
private RenderTarget2D renderTargetFinal;
private Effect damageEffect;
private Texture2D damageStencil;
private Texture2D damageStencil;
private Texture2D distortTexture;
public Effect PostProcessEffect { get; private set; }
@@ -122,10 +122,12 @@ namespace Barotrauma
{
if (Submarine.MainSubs[i] == null) continue;
if (Level.Loaded != null && Submarine.MainSubs[i].WorldPosition.Y < Level.MaxEntityDepth) continue;
Vector2 position = Submarine.MainSubs[i].SubBody != null ? Submarine.MainSubs[i].WorldPosition : Submarine.MainSubs[i].HiddenSubPosition;
Color indicatorColor = i == 0 ? Color.LightBlue * 0.5f : GUI.Style.Red * 0.5f;
GUI.DrawIndicator(
spriteBatch, Submarine.MainSubs[i].WorldPosition, cam,
spriteBatch, position, cam,
Math.Max(Submarine.MainSub.Borders.Width, Submarine.MainSub.Borders.Height),
GUI.SubmarineIcon, indicatorColor);
}
@@ -202,9 +204,12 @@ namespace Barotrauma
//Start drawing to the normal render target (stuff that can't be seen through the LOS effect)
graphics.SetRenderTarget(renderTarget);
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, null, DepthStencilState.None, null, null, null);
spriteBatch.Draw(renderTargetBackground, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.White);
spriteBatch.End();
graphics.BlendState = BlendState.NonPremultiplied;
graphics.SamplerStates[0] = SamplerState.LinearWrap;
Quad.UseBasicEffect(renderTargetBackground);
Quad.Render();
//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, e => !(e is Structure) || e.SpriteDepth < 0.9f);
@@ -230,11 +235,12 @@ namespace Barotrauma
//draw the rendertarget and particles that are only supposed to be drawn in water into renderTargetWater
graphics.SetRenderTarget(renderTargetWater);
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Opaque);
spriteBatch.Draw(renderTarget, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.White);// waterColor);
spriteBatch.End();
graphics.BlendState = BlendState.Opaque;
graphics.SamplerStates[0] = SamplerState.LinearWrap;
Quad.UseBasicEffect(renderTarget);
Quad.Render();
//draw alpha blended particles that are inside a sub
//draw alpha blended particles that are inside a sub
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, null, DepthStencilState.DepthRead, null, null, cam.Transform);
GameMain.ParticleManager.Draw(spriteBatch, true, true, Particles.ParticleBlendState.AlphaBlend);
spriteBatch.End();
@@ -282,10 +288,12 @@ namespace Barotrauma
spriteBatch.End();
if (GameMain.LightManager.LightingEnabled)
{
spriteBatch.Begin(SpriteSortMode.Deferred, Lights.CustomBlendStates.Multiplicative, null, DepthStencilState.None, null, null, null);
spriteBatch.Draw(GameMain.LightManager.LightMap, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.White);
spriteBatch.End();
}
graphics.DepthStencilState = DepthStencilState.None;
graphics.SamplerStates[0] = SamplerState.LinearWrap;
graphics.BlendState = Lights.CustomBlendStates.Multiplicative;
Quad.UseBasicEffect(GameMain.LightManager.LightMap);
Quad.Render();
}
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, SamplerState.LinearWrap, DepthStencilState.None, null, null, cam.Transform);
foreach (Character c in Character.CharacterList)
@@ -331,9 +339,12 @@ namespace Barotrauma
losColor = Color.Black;
}
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, SamplerState.PointClamp, null, null, GameMain.LightManager.LosEffect, null);
spriteBatch.Draw(renderTargetBackground, new Rectangle(0, 0, spriteBatch.GraphicsDevice.Viewport.Width, spriteBatch.GraphicsDevice.Viewport.Height), losColor);
spriteBatch.End();
GameMain.LightManager.LosEffect.Parameters["xColor"].SetValue(losColor.ToVector4());
graphics.BlendState = BlendState.NonPremultiplied;
graphics.SamplerStates[0] = SamplerState.PointClamp;
GameMain.LightManager.LosEffect.CurrentTechnique.Passes[0].Apply();
Quad.Render();
}
graphics.SetRenderTarget(null);
@@ -371,29 +382,23 @@ namespace Barotrauma
postProcessTechnique += "Distort";
PostProcessEffect.Parameters["distortScale"].SetValue(Vector2.One * DistortStrength);
PostProcessEffect.Parameters["distortUvOffset"].SetValue(WaterRenderer.Instance.WavePos * 0.001f);
#if LINUX || OSX
PostProcessEffect.Parameters["xTexture"].SetValue(distortTexture);
#else
PostProcessEffect.Parameters["xTexture"].SetValue(renderTargetFinal);
#endif
}
graphics.BlendState = BlendState.Opaque;
graphics.SamplerStates[0] = SamplerState.LinearClamp;
graphics.DepthStencilState = DepthStencilState.None;
if (string.IsNullOrEmpty(postProcessTechnique))
{
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Opaque, SamplerState.PointClamp, DepthStencilState.None);
Quad.UseBasicEffect(renderTargetFinal);
}
else
{
PostProcessEffect.Parameters["MatrixTransform"].SetValue(Matrix.Identity);
PostProcessEffect.Parameters["xTexture"].SetValue(renderTargetFinal);
PostProcessEffect.CurrentTechnique = PostProcessEffect.Techniques[postProcessTechnique];
PostProcessEffect.CurrentTechnique.Passes[0].Apply();
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Opaque, SamplerState.PointClamp, DepthStencilState.None, effect: PostProcessEffect);
}
#if LINUX || OSX
spriteBatch.Draw(renderTargetFinal, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.White);
#else
spriteBatch.Draw(DistortStrength > 0.0f ? distortTexture : renderTargetFinal, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.White);
#endif
spriteBatch.End();
Quad.Render();
}
}
}
@@ -170,14 +170,6 @@ namespace Barotrauma
{
base.Select();
foreach (LevelObjectPrefab levelObjPrefab in LevelObjectPrefab.List)
{
foreach (Sprite sprite in levelObjPrefab.Sprites)
{
sprite?.EnsureLazyLoaded();
}
}
pointerLightSource = new LightSource(Vector2.Zero, 1000.0f, Color.White, submarine: null);
GameMain.LightManager.AddLight(pointerLightSource);
topPanel.ClearChildren();
@@ -253,9 +245,10 @@ namespace Barotrauma
};
Sprite sprite = levelObjPrefab.Sprites.FirstOrDefault() ?? levelObjPrefab.DeformableSprite?.Sprite;
GUIImage img = new GUIImage(new RectTransform(new Point(paddedFrame.Rect.Height, paddedFrame.Rect.Height - textBlock.Rect.Height),
new GUIImage(new RectTransform(new Point(paddedFrame.Rect.Height, paddedFrame.Rect.Height - textBlock.Rect.Height),
paddedFrame.RectTransform, Anchor.TopCenter), sprite, scaleToFit: true)
{
LoadAsynchronously = true,
CanBeFocused = false
};
}
@@ -466,6 +459,7 @@ namespace Barotrauma
Submarine.Draw(spriteBatch, false);
Submarine.DrawFront(spriteBatch);
Submarine.DrawDamageable(spriteBatch, null);
GUI.DrawRectangle(spriteBatch, new Rectangle(new Point(0, -Level.Loaded.Size.Y), Level.Loaded.Size), Color.White, thickness: (int)(1.0f / cam.Zoom));
spriteBatch.End();
if (lightingEnabled.Selected)
@@ -531,7 +525,7 @@ namespace Barotrauma
else if (element.Name.ToString().Equals(genParams.Name, StringComparison.OrdinalIgnoreCase))
{
SerializableProperty.SerializeProperties(genParams, element, true);
}
}
break;
}
}
@@ -552,7 +546,7 @@ namespace Barotrauma
{
foreach (XElement element in doc.Root.Elements())
{
if (element.Name.ToString().ToLowerInvariant() != levelObjPrefab.Name.ToLowerInvariant()) continue;
if (!element.Name.ToString().Equals(levelObjPrefab.Name, StringComparison.OrdinalIgnoreCase)) { continue; }
levelObjPrefab.Save(element);
break;
}
@@ -577,7 +571,7 @@ namespace Barotrauma
bool elementFound = false;
foreach (XElement element in doc.Root.Elements())
{
if (element.Name.ToString().ToLowerInvariant() != genParams.Name.ToLowerInvariant()) continue;
if (!element.Name.ToString().Equals(genParams.Name, StringComparison.OrdinalIgnoreCase)) { continue; }
SerializableProperty.SerializeProperties(genParams, element, true);
elementFound = true;
}
@@ -78,8 +78,7 @@ namespace Barotrauma
private IEnumerable<object> LoadRound()
{
GameMain.GameSession.StartRound(campaignUI.SelectedLevel,
reloadSub: true,
GameMain.GameSession.StartRound(campaignUI.SelectedLevel,
mirrorLevel: GameMain.GameSession.Map.CurrentLocation != GameMain.GameSession.Map.SelectedConnection.Locations[0]);
GameMain.GameScreen.Select();
@@ -31,6 +31,7 @@ namespace Barotrauma
private GUITextBox serverNameBox, /*portBox, queryPortBox,*/ passwordBox, maxPlayersBox;
private GUITickBox isPublicBox, wrongPasswordBanBox, karmaEnabledBox;
private GUIDropDown karmaPresetDD;
private readonly GUIFrame downloadingModsContainer, enableModsContainer;
private readonly GUIButton joinServerButton, hostServerButton, steamWorkshopButton;
private readonly GameMain game;
@@ -230,13 +231,31 @@ namespace Barotrauma
};
#if USE_STEAM
steamWorkshopButton = new GUIButton(new RectTransform(new Vector2(1.0f, 1.0f), customizeList.RectTransform), TextManager.Get("SteamWorkshopButton"), textAlignment: Alignment.Left, style: "MainMenuGUIButton")
var steamWorkshopButtonContainer = new GUIFrame(new RectTransform(new Vector2(1.0f, 1.0f), customizeList.RectTransform), style: null);
steamWorkshopButton = new GUIButton(new RectTransform(new Vector2(1.0f, 1.0f), steamWorkshopButtonContainer.RectTransform), TextManager.Get("SteamWorkshopButton"), textAlignment: Alignment.Left, style: "MainMenuGUIButton")
{
ForceUpperCase = true,
Enabled = false,
UserData = Tab.SteamWorkshop,
OnClicked = SelectTab
};
downloadingModsContainer = new GUIFrame(new RectTransform(new Vector2(1.4f, 0.9f), steamWorkshopButtonContainer.RectTransform,
Anchor.CenterRight, Pivot.CenterLeft)
{ RelativeOffset = new Vector2(0.3f, 0.0f) },
"MainMenuNotifBackground", Color.Yellow)
{
CanBeFocused = false,
UserData = "workshopnotif",
Visible = false
};
new GUITextBlock(new RectTransform(Vector2.One * 0.9f, downloadingModsContainer.RectTransform, Anchor.CenterLeft, Pivot.CenterLeft) { RelativeOffset = new Vector2(0.05f, 0.0f) },
TextManager.Get("ModsDownloadingNotif"), Color.Black)
{
CanBeFocused = false,
};
#endif
new GUIButton(new RectTransform(new Vector2(1.0f, 1.0f), customizeList.RectTransform), TextManager.Get("SubEditorButton"), textAlignment: Alignment.Left, style: "MainMenuGUIButton")
@@ -280,12 +299,28 @@ namespace Barotrauma
RelativeSpacing = 0.035f
};
new GUIButton(new RectTransform(new Vector2(1.0f, 1.0f), optionList.RectTransform), TextManager.Get("SettingsButton"), textAlignment: Alignment.Left, style: "MainMenuGUIButton")
var settingsButtonContainer = new GUIFrame(new RectTransform(new Vector2(1.0f, 1.0f), optionList.RectTransform), style: null);
new GUIButton(new RectTransform(Vector2.One, settingsButtonContainer.RectTransform), TextManager.Get("SettingsButton"), textAlignment: Alignment.Left, style: "MainMenuGUIButton")
{
ForceUpperCase = true,
UserData = Tab.Settings,
OnClicked = SelectTab
};
enableModsContainer = new GUIFrame(new RectTransform(new Vector2(1.4f, 0.9f), settingsButtonContainer.RectTransform,
Anchor.CenterRight, Pivot.CenterLeft) { RelativeOffset = new Vector2(0.5f, 0.0f) },
"MainMenuNotifBackground", Color.Yellow)
{
CanBeFocused = false,
UserData = "settingsnotif",
Visible = false
};
new GUITextBlock(new RectTransform(Vector2.One * 0.9f, enableModsContainer.RectTransform, Anchor.CenterLeft, Pivot.CenterLeft) { RelativeOffset = new Vector2(0.05f, 0.0f) },
TextManager.Get("ModsInstalledNotif"), Color.Black)
{
CanBeFocused = false
};
new GUIButton(new RectTransform(new Vector2(1.0f, 1.0f), optionList.RectTransform), TextManager.Get("CreditsButton"), textAlignment: Alignment.Left, style: "MainMenuGUIButton")
{
@@ -401,12 +436,18 @@ namespace Barotrauma
GameMain.Client = null;
}
GameMain.SubEditorScreen?.ClearBackedUpSubInfo();
Submarine.Unload();
ResetButtonStates(null);
GameAnalyticsManager.SetCustomDimension01("");
if (GameMain.SteamWorkshopScreen != null)
{
CoroutineManager.StartCoroutine(GameMain.SteamWorkshopScreen.RefreshDownloadState());
}
#if OSX
// Hack for adjusting the viewport properly after splash screens on older Macs
if (firstLoadOnMac)
@@ -495,12 +536,13 @@ namespace Barotrauma
}
campaignSetupUI.CreateDefaultSaveName();
campaignSetupUI.RandomizeSeed();
campaignSetupUI.UpdateSubList(Submarine.SavedSubmarines);
campaignSetupUI.UpdateSubList(SubmarineInfo.SavedSubmarines);
break;
case Tab.LoadGame:
campaignSetupUI.UpdateLoadMenu();
break;
case Tab.Settings:
GameMain.MainMenuScreen?.SetEnableModsNotification(false);
menuTabs[(int)Tab.Settings].RectTransform.ClearChildren();
GameMain.Config.SettingsFrame.RectTransform.Parent = menuTabs[(int)Tab.Settings].RectTransform;
GameMain.Config.SettingsFrame.RectTransform.RelativeSize = Vector2.One;
@@ -631,12 +673,12 @@ namespace Barotrauma
Rand.SetLocalRandom(1);
}
Submarine selectedSub = null;
SubmarineInfo selectedSub = null;
string subName = GameMain.Config.QuickStartSubmarineName;
if (!string.IsNullOrEmpty(subName))
{
DebugConsole.NewMessage($"Loading the predefined quick start sub \"{subName}\"", Color.White);
selectedSub = Submarine.SavedSubmarines.FirstOrDefault(s =>
selectedSub = SubmarineInfo.SavedSubmarines.FirstOrDefault(s =>
s.Name.ToLower() == subName.ToLower());
if (selectedSub == null)
@@ -647,7 +689,7 @@ namespace Barotrauma
if (selectedSub == null)
{
DebugConsole.NewMessage("Loading a random sub.", Color.White);
var subs = Submarine.SavedSubmarines.Where(s => !s.HasTag(SubmarineTag.Shuttle) && !s.HasTag(SubmarineTag.HideInMenus));
var subs = SubmarineInfo.SavedSubmarines.Where(s => !s.HasTag(SubmarineTag.Shuttle) && !s.HasTag(SubmarineTag.HideInMenus));
selectedSub = subs.ElementAt(Rand.Int(subs.Count()));
}
var gamesession = new GameSession(
@@ -684,6 +726,16 @@ namespace Barotrauma
}
}
public void SetEnableModsNotification(bool visible)
{
if (enableModsContainer != null) { enableModsContainer.Visible = visible; }
}
public void SetDownloadingModsNotification(bool visible)
{
if (downloadingModsContainer != null) { downloadingModsContainer.Visible = visible; }
}
private void ShowTutorialSkipWarning(Tab tabToContinueTo)
{
var tutorialSkipWarning = new GUIMessageBox("", TextManager.Get("tutorialskipwarning"), new string[] { TextManager.Get("tutorialwarningskiptutorials"), TextManager.Get("tutorialwarningplaytutorials") });
@@ -990,7 +1042,7 @@ namespace Barotrauma
spriteBatch.End();
}
private void StartGame(Submarine selectedSub, string saveName, string mapSeed)
private void StartGame(SubmarineInfo selectedSub, string saveName, string mapSeed)
{
if (string.IsNullOrEmpty(saveName)) return;
@@ -1027,7 +1079,7 @@ namespace Barotrauma
return;
}
selectedSub = new Submarine(Path.Combine(SaveUtil.TempPath, selectedSub.Name + ".sub"), "");
selectedSub = new SubmarineInfo(Path.Combine(SaveUtil.TempPath, selectedSub.Name + ".sub"));
GameMain.GameSession = new GameSession(selectedSub, saveName,
GameModePreset.List.Find(g => g.Identifier == "singleplayercampaign"));
@@ -1072,7 +1124,7 @@ namespace Barotrauma
var paddedLoadGame = new GUIFrame(new RectTransform(new Vector2(0.9f, 0.9f), menuTabs[(int)Tab.LoadGame].RectTransform, Anchor.Center) { AbsoluteOffset = new Point(0, 10) },
style: null);
campaignSetupUI = new CampaignSetupUI(false, paddedNewGame, paddedLoadGame, Submarine.SavedSubmarines)
campaignSetupUI = new CampaignSetupUI(false, paddedNewGame, paddedLoadGame, SubmarineInfo.SavedSubmarines)
{
LoadGame = LoadGame,
StartNewGame = StartGame
@@ -22,6 +22,7 @@ namespace Barotrauma
private GUIListBox subList, modeList;
private GUIListBox chatBox, playerList;
private GUIButton serverLogReverseButton;
private GUIListBox serverLogBox, serverLogFilterTicks;
private GUIComponent jobVariantTooltip;
@@ -64,12 +65,15 @@ namespace Barotrauma
private readonly GUIButton gameModeViewButton, campaignViewButton, spectateButton;
private readonly GUILayoutGroup roundControlsHolder;
public GUIButton SettingsButton { get; private set; }
public static GUIButton JobInfoFrame;
private readonly GUITickBox spectateBox;
private readonly GUIFrame playerInfoContainer;
private GUIButton jobInfoFrame;
private GUIButton playerFrame;
private GUILayoutGroup infoContainer;
private GUITextBlock changesPendingText;
public GUIButton PlayerFrame;
private readonly GUIComponent subPreviewContainer;
@@ -208,15 +212,15 @@ namespace Barotrauma
private set;
}
public Submarine SelectedSub
public SubmarineInfo SelectedSub
{
get { return subList.SelectedData as Submarine; }
get { return subList.SelectedData as SubmarineInfo; }
set { subList.Select(value); }
}
public Submarine SelectedShuttle
public SubmarineInfo SelectedShuttle
{
get { return shuttleList.SelectedData as Submarine; }
get { return shuttleList.SelectedData as SubmarineInfo; }
}
public bool UsingShuttle
@@ -525,7 +529,7 @@ namespace Barotrauma
if (!(serverLogHolder?.Visible ?? true))
{
serverLogHolder.Visible = true;
GameMain.Client.ServerSettings.ServerLog.AssignLogFrame(serverLogBox, serverLogFilterTicks.Content, serverLogFilter);
GameMain.Client.ServerSettings.ServerLog.AssignLogFrame(serverLogReverseButton, serverLogBox, serverLogFilterTicks.Content, serverLogFilter);
}
showChatButton.Selected = false;
showLogButton.Selected = true;
@@ -609,7 +613,13 @@ namespace Barotrauma
//server log ----------------------------------------------------------------------
serverLogBox = new GUIListBox(new RectTransform(new Vector2(0.5f, 1.0f), serverLogHolderHorizontal.RectTransform));
GUILayoutGroup serverLogListboxLayout = new GUILayoutGroup(new RectTransform(new Vector2(0.5f, 1.0f), serverLogHolderHorizontal.RectTransform))
{
Stretch = true
};
serverLogReverseButton = new GUIButton(new RectTransform(new Vector2(1.0f, 0.05f), serverLogListboxLayout.RectTransform), style: "UIToggleButtonVertical");
serverLogBox = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.95f), serverLogListboxLayout.RectTransform));
//filter tickbox list ------------------------------------------------------------------
@@ -1393,18 +1403,34 @@ namespace Barotrauma
parent.ClearChildren();
GUILayoutGroup infoContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.9f), parent.RectTransform, Anchor.BottomCenter), childAnchor: Anchor.TopCenter)
bool isGameRunning = GameMain.GameSession?.GameMode?.IsRunning ?? false;
infoContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, isGameRunning ? 0.95f : 0.9f), parent.RectTransform, Anchor.BottomCenter), childAnchor: Anchor.TopCenter)
{
RelativeSpacing = 0.015f,
RelativeSpacing = 0.025f,
Stretch = true,
UserData = characterInfo
UserData = characterInfo
};
CharacterNameBox = new GUITextBox(new RectTransform(new Vector2(1.0f, 0.065f), infoContainer.RectTransform), characterInfo.Name, textAlignment: Alignment.Center)
bool nameChangePending = isGameRunning && GameMain.Client.PendingName != string.Empty && GameMain.Client?.Character?.Name != GameMain.Client.PendingName;
changesPendingText = null;
if (isGameRunning)
{
infoContainer.RectTransform.AbsoluteOffset = new Point(0, (int)(parent.Rect.Height * 0.025f));
}
if (TabMenu.PendingChanges)
{
CreateChangesPendingText();
}
CharacterNameBox = new GUITextBox(new RectTransform(new Vector2(1.0f, 0.065f), infoContainer.RectTransform), !nameChangePending ? characterInfo.Name : GameMain.Client.PendingName, textAlignment: Alignment.Center)
{
MaxTextLength = Client.MaxNameLength,
OverflowClip = true
};
CharacterNameBox.OnEnterPressed += (tb, text) => { CharacterNameBox.Deselect(); return true; };
CharacterNameBox.OnDeselected += (tb, key) =>
{
@@ -1417,7 +1443,15 @@ namespace Barotrauma
}
else
{
ReadyToStartBox.Selected = false;
if (isGameRunning)
{
GameMain.Client.PendingName = tb.Text;
}
else
{
ReadyToStartBox.Selected = false;
}
GameMain.Client.SetName(tb.Text);
};
};
@@ -1538,6 +1572,13 @@ namespace Barotrauma
}
}
private void CreateChangesPendingText()
{
if (changesPendingText != null || infoContainer == null) return;
changesPendingText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.065f), infoContainer.Parent.RectTransform, Anchor.BottomCenter, Pivot.TopCenter) { RelativeOffset = new Vector2(0f, -0.065f) },
TextManager.Get("tabmenu.characterchangespending"), textColor: GUI.Style.Orange, textAlignment: Alignment.Center, style: null) { IgnoreLayoutGroups = true };
}
private void CreateJobVariantTooltip(JobPrefab jobPrefab, int variant, GUIComponent parentSlot)
{
jobVariantTooltip = new GUIFrame(new RectTransform(new Point((int)(500 * GUI.Scale), (int)(200 * GUI.Scale)), GUI.Canvas, pivot: Pivot.BottomRight),
@@ -1628,19 +1669,19 @@ namespace Barotrauma
MissionType = missionType;
}
public void UpdateSubList(GUIComponent subList, List<Submarine> submarines)
public void UpdateSubList(GUIComponent subList, List<SubmarineInfo> submarines)
{
if (subList == null) { return; }
subList.ClearChildren();
foreach (Submarine sub in submarines)
foreach (SubmarineInfo sub in submarines)
{
AddSubmarine(subList, sub);
}
}
private void AddSubmarine(GUIComponent subList, Submarine sub)
private void AddSubmarine(GUIComponent subList, SubmarineInfo sub)
{
if (subList is GUIListBox)
{
@@ -1665,8 +1706,8 @@ namespace Barotrauma
CanBeFocused = false
};
var matchingSub = Submarine.SavedSubmarines.FirstOrDefault(s => s.Name == sub.Name && s.MD5Hash?.Hash == sub.MD5Hash?.Hash);
if (matchingSub == null) matchingSub = Submarine.SavedSubmarines.FirstOrDefault(s => s.Name == sub.Name);
var matchingSub = SubmarineInfo.SavedSubmarines.FirstOrDefault(s => s.Name == sub.Name && s.MD5Hash?.Hash == sub.MD5Hash?.Hash);
if (matchingSub == null) matchingSub = SubmarineInfo.SavedSubmarines.FirstOrDefault(s => s.Name == sub.Name);
if (matchingSub == null)
{
@@ -1723,7 +1764,7 @@ namespace Barotrauma
{
if (!GameMain.Client.ServerSettings.Voting.AllowSubVoting)
{
var selectedSub = component.UserData as Submarine;
var selectedSub = component.UserData as SubmarineInfo;
if (!selectedSub.RequiredContentPackagesInstalled)
{
var msgBox = new GUIMessageBox(TextManager.Get("ContentPackageMismatch"),
@@ -1748,7 +1789,7 @@ namespace Barotrauma
}
return false;
}
if (component.UserData is Submarine sub)
if (component.UserData is SubmarineInfo sub)
{
CreateSubPreview(sub);
}
@@ -1780,7 +1821,7 @@ namespace Barotrauma
}
GameMain.Client.RequestSelectMode(component.Parent.GetChildIndex(component));
HighlightMode(SelectedModeIndex);
return (presetName.ToLowerInvariant() != "multiplayercampaign");
return !presetName.Equals("multiplayercampaign", StringComparison.OrdinalIgnoreCase);
}
return false;
}
@@ -1812,6 +1853,7 @@ namespace Barotrauma
SelectedColor = Color.White * 0.85f,
OutlineColor = Color.White * 0.5f,
TextColor = Color.White,
SelectedTextColor = Color.Black,
UserData = client
};
var soundIcon = new GUIImage(new RectTransform(new Point((int)(textBlock.Rect.Height * 0.8f)), textBlock.RectTransform, Anchor.CenterRight) { AbsoluteOffset = new Point(5, 0) },
@@ -1844,28 +1886,28 @@ namespace Barotrauma
public void SetPlayerNameAndJobPreference(Client client)
{
var playerFrame = (GUITextBlock)PlayerList.Content.FindChild(client);
if (playerFrame == null) { return; }
playerFrame.Text = client.Name;
var PlayerFrame = (GUITextBlock)PlayerList.Content.FindChild(client);
if (PlayerFrame == null) { return; }
PlayerFrame.Text = client.Name;
Color color = Color.White;
if (JobPrefab.Prefabs.ContainsKey(client.PreferredJob))
{
color = JobPrefab.Prefabs[client.PreferredJob].UIColor;
}
playerFrame.Color = color * 0.4f;
playerFrame.HoverColor = color * 0.6f;
playerFrame.SelectedColor = color * 0.8f;
playerFrame.OutlineColor = color * 0.5f;
playerFrame.TextColor = color;
PlayerFrame.Color = color * 0.4f;
PlayerFrame.HoverColor = color * 0.6f;
PlayerFrame.SelectedColor = color * 0.8f;
PlayerFrame.OutlineColor = color * 0.5f;
PlayerFrame.TextColor = color;
}
public void SetPlayerVoiceIconState(Client client, bool muted, bool mutedLocally)
{
var playerFrame = PlayerList.Content.FindChild(client);
if (playerFrame == null) { return; }
var soundIcon = playerFrame.FindChild(c => c.UserData is Pair<string, float> pair && pair.First == "soundicon");
var soundIconDisabled = playerFrame.FindChild("soundicondisabled");
var PlayerFrame = PlayerList.Content.FindChild(client);
if (PlayerFrame == null) { return; }
var soundIcon = PlayerFrame.FindChild(c => c.UserData is Pair<string, float> pair && pair.First == "soundicon");
var soundIconDisabled = PlayerFrame.FindChild("soundicondisabled");
Pair<string, float> userdata = soundIcon.UserData as Pair<string, float>;
@@ -1880,9 +1922,9 @@ namespace Barotrauma
public void SetPlayerSpeaking(Client client)
{
var playerFrame = PlayerList.Content.FindChild(client);
if (playerFrame == null) { return; }
var soundIcon = playerFrame.FindChild(c => c.UserData is Pair<string, float> pair && pair.First == "soundicon");
var PlayerFrame = PlayerList.Content.FindChild(client);
if (PlayerFrame == null) { return; }
var soundIcon = PlayerFrame.FindChild(c => c.UserData is Pair<string, float> pair && pair.First == "soundicon");
Pair<string, float> userdata = soundIcon.UserData as Pair<string, float>;
userdata.Second = Math.Max(userdata.Second, 0.18f);
soundIcon.Visible = true;
@@ -1894,18 +1936,18 @@ namespace Barotrauma
if (child != null) { playerList.RemoveChild(child); }
}
private bool SelectPlayer(Client selectedClient)
public bool SelectPlayer(Client selectedClient)
{
bool myClient = selectedClient.ID == GameMain.Client.ID;
playerFrame = new GUIButton(new RectTransform(Vector2.One, GUI.Canvas), style: "GUIBackgroundBlocker")
PlayerFrame = new GUIButton(new RectTransform(Vector2.One, GUI.Canvas), style: "GUIBackgroundBlocker")
{
OnClicked = (btn, userdata) => { if (GUI.MouseOn == btn || GUI.MouseOn == btn.TextBlock) ClosePlayerFrame(btn, userdata); return true; }
};
Vector2 frameSize = GameMain.Client.HasPermission(ClientPermissions.ManagePermissions) ? new Vector2(.24f, .5f) : new Vector2(.24f, .24f);
Vector2 frameSize = GameMain.Client.HasPermission(ClientPermissions.ManagePermissions) ? new Vector2(.28f, .5f) : new Vector2(.28f, .24f);
var playerFrameInner = new GUIFrame(new RectTransform(frameSize, playerFrame.RectTransform, Anchor.Center) { MinSize = new Point(550, 0) });
var playerFrameInner = new GUIFrame(new RectTransform(frameSize, PlayerFrame.RectTransform, Anchor.Center) { MinSize = new Point(550, 0) });
var paddedPlayerFrame = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.88f), playerFrameInner.RectTransform, Anchor.Center))
{
Stretch = true,
@@ -1938,7 +1980,7 @@ namespace Barotrauma
if (GameMain.Client.HasPermission(ClientPermissions.ManagePermissions))
{
playerFrame.UserData = selectedClient;
PlayerFrame.UserData = selectedClient;
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), paddedPlayerFrame.RectTransform),
TextManager.Get("Rank"), font: GUI.SubHeadingFont);
@@ -1964,11 +2006,11 @@ namespace Barotrauma
PermissionPreset selectedPreset = (PermissionPreset)userdata;
if (selectedPreset != null)
{
var client = playerFrame.UserData as Client;
var client = PlayerFrame.UserData as Client;
client.SetPermissions(selectedPreset.Permissions, selectedPreset.PermittedCommands);
GameMain.Client.UpdateClientPermissions(client);
playerFrame = null;
PlayerFrame = null;
SelectPlayer(client);
}
return true;
@@ -2004,7 +2046,7 @@ namespace Barotrauma
//reset rank to custom
rankDropDown.SelectItem(null);
if (!(playerFrame.UserData is Client client)) { return false; }
if (!(PlayerFrame.UserData is Client client)) { return false; }
foreach (GUIComponent child in tickbox.Parent.GetChild<GUIListBox>().Content.Children)
{
@@ -2037,7 +2079,7 @@ namespace Barotrauma
//reset rank to custom
rankDropDown.SelectItem(null);
if (!(playerFrame.UserData is Client client)) { return false; }
if (!(PlayerFrame.UserData is Client client)) { return false; }
var thisPermission = (ClientPermissions)tickBox.UserData;
if (tickBox.Selected)
@@ -2071,7 +2113,7 @@ namespace Barotrauma
//reset rank to custom
rankDropDown.SelectItem(null);
if (!(playerFrame.UserData is Client client)) { return false; }
if (!(PlayerFrame.UserData is Client client)) { return false; }
foreach (GUIComponent child in tickbox.Parent.GetChild<GUIListBox>().Content.Children)
{
@@ -2104,7 +2146,7 @@ namespace Barotrauma
rankDropDown.SelectItem(null);
DebugConsole.Command selectedCommand = tickBox.UserData as DebugConsole.Command;
if (!(playerFrame.UserData is Client client)) { return false; }
if (!(PlayerFrame.UserData is Client client)) { return false; }
if (!tickBox.Selected)
{
@@ -2130,7 +2172,7 @@ namespace Barotrauma
{
if (GameMain.Client.HasPermission(ClientPermissions.Ban))
{
var banButton = new GUIButton(new RectTransform(new Vector2(0.3f, 1.0f), buttonAreaTop.RectTransform),
var banButton = new GUIButton(new RectTransform(new Vector2(0.34f, 1.0f), buttonAreaTop.RectTransform),
TextManager.Get("Ban"))
{
UserData = selectedClient
@@ -2138,7 +2180,7 @@ namespace Barotrauma
banButton.OnClicked = (bt, userdata) => { BanPlayer(selectedClient); return true; };
banButton.OnClicked += ClosePlayerFrame;
var rangebanButton = new GUIButton(new RectTransform(new Vector2(0.3f, 1.0f), buttonAreaTop.RectTransform),
var rangebanButton = new GUIButton(new RectTransform(new Vector2(0.34f, 1.0f), buttonAreaTop.RectTransform),
TextManager.Get("BanRange"))
{
UserData = selectedClient
@@ -2151,7 +2193,7 @@ namespace Barotrauma
if (GameMain.Client != null && GameMain.Client.ServerSettings.Voting.AllowVoteKick &&
selectedClient != null && selectedClient.AllowKicking)
{
var kickVoteButton = new GUIButton(new RectTransform(new Vector2(0.3f, 1.0f), buttonAreaLower.RectTransform),
var kickVoteButton = new GUIButton(new RectTransform(new Vector2(0.34f, 1.0f), buttonAreaLower.RectTransform),
TextManager.Get("VoteToKick"))
{
Enabled = !selectedClient.HasKickVoteFromID(GameMain.Client.ID),
@@ -2163,7 +2205,7 @@ namespace Barotrauma
if (GameMain.Client.HasPermission(ClientPermissions.Kick) &&
selectedClient != null && selectedClient.AllowKicking)
{
var kickButton = new GUIButton(new RectTransform(new Vector2(0.3f, 1.0f), buttonAreaLower.RectTransform),
var kickButton = new GUIButton(new RectTransform(new Vector2(0.34f, 1.0f), buttonAreaLower.RectTransform),
TextManager.Get("Kick"))
{
UserData = selectedClient
@@ -2172,6 +2214,9 @@ namespace Barotrauma
kickButton.OnClicked += ClosePlayerFrame;
}
GUITextBlock.AutoScaleAndNormalize(
buttonAreaTop.Children.Select(c => ((GUIButton)c).TextBlock).Concat(buttonAreaLower.Children.Select(c => ((GUIButton)c).TextBlock)));
new GUITickBox(new RectTransform(new Vector2(0.25f, 1.0f), buttonAreaTop.RectTransform, Anchor.TopRight),
TextManager.Get("Mute"))
{
@@ -2181,7 +2226,7 @@ namespace Barotrauma
};
}
var closeButton = new GUIButton(new RectTransform(new Vector2(0.3f, 1.0f), buttonAreaLower.RectTransform, Anchor.BottomRight),
var closeButton = new GUIButton(new RectTransform(new Vector2(0.3f, 1.0f), buttonAreaLower.RectTransform, Anchor.TopRight),
TextManager.Get("Close"))
{
IgnoreLayoutGroups = true,
@@ -2202,7 +2247,7 @@ namespace Barotrauma
private bool ClosePlayerFrame(GUIButton button, object userData)
{
playerFrame = null;
PlayerFrame = null;
playerList.Deselect();
return true;
}
@@ -2229,9 +2274,8 @@ namespace Barotrauma
{
base.AddToGUIUpdateList();
playerFrame?.AddToGUIUpdateList();
//CampaignSetupUI?.AddToGUIUpdateList();
jobInfoFrame?.AddToGUIUpdateList();
JobInfoFrame?.AddToGUIUpdateList();
HeadSelectionList?.AddToGUIUpdateList();
JobSelectionFrame?.AddToGUIUpdateList();
@@ -2260,7 +2304,7 @@ namespace Barotrauma
targetMicStyle = "GUIMicrophoneDisabled";
}
if (targetMicStyle.ToLowerInvariant() != currMicStyle.ToLowerInvariant())
if (!targetMicStyle.Equals(currMicStyle, StringComparison.OrdinalIgnoreCase))
{
GUI.Style.Apply(micIcon, targetMicStyle);
}
@@ -2528,6 +2572,7 @@ namespace Barotrauma
StepValue = 1,
BarScrollValue = info.HairIndex,
OnMoved = SwitchHair,
OnReleased = SaveHead,
BarSize = 1.0f / (float)(hairCount + 1)
};
}
@@ -2542,6 +2587,7 @@ namespace Barotrauma
StepValue = 1,
BarScrollValue = info.BeardIndex,
OnMoved = SwitchBeard,
OnReleased = SaveHead,
BarSize = 1.0f / (float)(beardCount + 1)
};
}
@@ -2556,6 +2602,7 @@ namespace Barotrauma
StepValue = 1,
BarScrollValue = info.MoustacheIndex,
OnMoved = SwitchMoustache,
OnReleased = SaveHead,
BarSize = 1.0f / (float)(moustacheCount + 1)
};
}
@@ -2570,6 +2617,7 @@ namespace Barotrauma
StepValue = 1,
BarScrollValue = info.FaceAttachmentIndex,
OnMoved = SwitchFaceAttachment,
OnReleased = SaveHead,
BarSize = 1.0f / (float)(faceAttachmentCount + 1)
};
}
@@ -2616,7 +2664,7 @@ namespace Barotrauma
GUILayoutGroup row = null;
int itemsInRow = 0;
XElement headElement = info.Ragdoll.MainElement.Elements().FirstOrDefault(e => e.GetAttributeString("type", "").ToLowerInvariant() == "head");
XElement headElement = info.Ragdoll.MainElement.Elements().FirstOrDefault(e => e.GetAttributeString("type", "").Equals("head", StringComparison.OrdinalIgnoreCase));
XElement headSpriteElement = headElement.Element("sprite");
string spritePathWithTags = headSpriteElement.Attribute("texture").Value;
@@ -2674,8 +2722,11 @@ namespace Barotrauma
private bool SwitchJob(GUIButton button, object obj)
{
if (JobList == null) { return false; }
int childIndex = JobList.SelectedIndex;
var child = JobList.SelectedComponent;
if (child == null) { return false; }
bool moveToNext = obj != null;
@@ -2874,7 +2925,7 @@ namespace Barotrauma
var textBlock = new GUITextBlock(
innerFrame.CountChildren == 0 ?
new RectTransform(Vector2.One, parent.RectTransform, Anchor.Center) :
new RectTransform(new Vector2(selectedByPlayer ? 0.65f : 0.95f, 0.3f), parent.RectTransform, Anchor.BottomCenter),
new RectTransform(new Vector2(selectedByPlayer ? 0.55f : 0.95f, 0.3f), parent.RectTransform, Anchor.BottomCenter),
jobPrefab.Name, wrap: true, textAlignment: Alignment.BottomCenter)
{
Padding = Vector4.Zero,
@@ -2903,7 +2954,7 @@ namespace Barotrauma
info.Head = new CharacterInfo.HeadInfo(id, gender, race);
info.ReloadHeadAttachments();
}
StoreHead();
StoreHead(true);
UpdateJobPreferences(JobList);
@@ -2911,7 +2962,8 @@ namespace Barotrauma
return true;
}
private bool SaveHead(GUIScrollBar scrollBar, float barScroll) => StoreHead(true);
private bool SwitchHair(GUIScrollBar scrollBar, float barScroll) => SwitchAttachment(scrollBar, WearableType.Hair);
private bool SwitchBeard(GUIScrollBar scrollBar, float barScroll) => SwitchAttachment(scrollBar, WearableType.Beard);
private bool SwitchMoustache(GUIScrollBar scrollBar, float barScroll) => SwitchAttachment(scrollBar, WearableType.Moustache);
@@ -2939,14 +2991,15 @@ namespace Barotrauma
return false;
}
info.ReloadHeadAttachments();
StoreHead();
StoreHead(false);
return true;
}
private void StoreHead()
private bool StoreHead(bool save)
{
var info = GameMain.Client.CharacterInfo;
var config = GameMain.Config;
config.CharacterRace = info.Race;
config.CharacterGender = info.Gender;
config.CharacterHeadIndex = info.HeadSpriteId;
@@ -2954,8 +3007,22 @@ namespace Barotrauma
config.CharacterBeardIndex = info.BeardIndex;
config.CharacterMoustacheIndex = info.MoustacheIndex;
config.CharacterFaceAttachmentIndex = info.FaceAttachmentIndex;
if (save)
{
if (GameMain.GameSession?.GameMode?.IsRunning ?? false)
{
TabMenu.PendingChanges = true;
CreateChangesPendingText();
}
GameMain.Config.SaveNewPlayerConfig();
}
return true;
}
public void SelectMode(int modeIndex)
{
if (modeIndex < 0 || modeIndex >= modeList.Content.CountChildren) { return; }
@@ -3044,7 +3111,7 @@ namespace Barotrauma
}*/
}
public void TryDisplayCampaignSubmarine(Submarine submarine)
public void TryDisplayCampaignSubmarine(SubmarineInfo submarine)
{
string name = submarine?.Name;
bool displayed = false;
@@ -3053,13 +3120,13 @@ namespace Barotrauma
subPreviewContainer.ClearChildren();
foreach (GUIComponent child in subList.Content.Children)
{
if (!(child.UserData is Submarine sub)) { continue; }
if (!(child.UserData is SubmarineInfo sub)) { continue; }
//just check the name, even though the campaign sub may not be the exact same version
//we're selecting the sub just for show, the selection is not actually used for anything
if (sub.Name == name)
{
subList.Select(sub);
if (Submarine.SavedSubmarines.Contains(sub))
if (SubmarineInfo.SavedSubmarines.Contains(sub))
{
CreateSubPreview(sub);
displayed = true;
@@ -3078,20 +3145,20 @@ namespace Barotrauma
{
if (!(button.UserData is Pair<JobPrefab, int> jobPrefab)) { return false; }
jobInfoFrame = jobPrefab.First.CreateInfoFrame(jobPrefab.Second);
GUIButton closeButton = new GUIButton(new RectTransform(new Vector2(0.25f, 0.05f), jobInfoFrame.GetChild(2).GetChild(0).RectTransform, Anchor.BottomRight),
JobInfoFrame = jobPrefab.First.CreateInfoFrame(jobPrefab.Second);
GUIButton closeButton = new GUIButton(new RectTransform(new Vector2(0.25f, 0.05f), JobInfoFrame.GetChild(2).GetChild(0).RectTransform, Anchor.BottomRight),
TextManager.Get("Close"))
{
OnClicked = CloseJobInfo
};
jobInfoFrame.OnClicked = (btn, userdata) => { if (GUI.MouseOn == btn || GUI.MouseOn == btn.TextBlock) CloseJobInfo(btn, userdata); return true; };
JobInfoFrame.OnClicked = (btn, userdata) => { if (GUI.MouseOn == btn || GUI.MouseOn == btn.TextBlock) CloseJobInfo(btn, userdata); return true; };
return true;
}
private bool CloseJobInfo(GUIButton button, object obj)
{
jobInfoFrame = null;
JobInfoFrame = null;
return true;
}
@@ -3185,8 +3252,14 @@ namespace Barotrauma
}
GameMain.Client.ForceNameAndJobUpdate();
if (!GameMain.Config.JobPreferences.SequenceEqual(jobNamePreferences))
if (!GameMain.Config.AreJobPreferencesEqual(jobNamePreferences))
{
if (GameMain.GameSession?.GameMode?.IsRunning ?? false)
{
TabMenu.PendingChanges = true;
CreateChangesPendingText();
}
GameMain.Config.JobPreferences = jobNamePreferences;
GameMain.Config.SaveNewPlayerConfig();
}
@@ -3219,10 +3292,10 @@ namespace Barotrauma
{
return false;
}
Submarine sub = subList.Content.Children
.FirstOrDefault(c => c.UserData is Submarine s && s.Name == subName && s.MD5Hash?.Hash == md5Hash)?
.UserData as Submarine;
SubmarineInfo sub = subList.Content.Children
.FirstOrDefault(c => c.UserData is SubmarineInfo s && s.Name == subName && s.MD5Hash?.Hash == md5Hash)?
.UserData as SubmarineInfo;
//matching sub found and already selected, all good
if (sub != null)
@@ -3231,7 +3304,7 @@ namespace Barotrauma
{
CreateSubPreview(sub);
}
if (subList.SelectedData is Submarine selectedSub && selectedSub.MD5Hash?.Hash == md5Hash && System.IO.File.Exists(sub.FilePath))
if (subList.SelectedData is SubmarineInfo selectedSub && selectedSub.MD5Hash?.Hash == md5Hash && System.IO.File.Exists(sub.FilePath))
{
return true;
}
@@ -3241,8 +3314,8 @@ namespace Barotrauma
if (sub == null)
{
sub = subList.Content.Children
.FirstOrDefault(c => c.UserData is Submarine s && s.Name == subName)?
.UserData as Submarine;
.FirstOrDefault(c => c.UserData is SubmarineInfo s && s.Name == subName)?
.UserData as SubmarineInfo;
}
//found a sub that at least has the same name, select it
@@ -3265,7 +3338,7 @@ namespace Barotrauma
FailedSelectedShuttle = null;
//hashes match, all good
if (sub.MD5Hash?.Hash == md5Hash && Submarine.SavedSubmarines.Contains(sub))
if (sub.MD5Hash?.Hash == md5Hash && SubmarineInfo.SavedSubmarines.Contains(sub))
{
return true;
}
@@ -3280,7 +3353,7 @@ namespace Barotrauma
FailedSelectedShuttle = new Pair<string, string>(subName, md5Hash);
string errorMsg = "";
if (sub == null || !Submarine.SavedSubmarines.Contains(sub))
if (sub == null || !SubmarineInfo.SavedSubmarines.Contains(sub))
{
errorMsg = TextManager.GetWithVariable("SubNotFoundError", "[subname]", subName) + " ";
}
@@ -3322,7 +3395,7 @@ namespace Barotrauma
return false;
}
private void CreateSubPreview(Submarine sub)
private void CreateSubPreview(SubmarineInfo sub)
{
subPreviewContainer?.ClearChildren();
sub.CreatePreviewWindow(subPreviewContainer);
@@ -237,7 +237,7 @@ namespace Barotrauma
{
foreach (XElement element in doc.Root.Elements())
{
if (element.Name.ToString().ToLowerInvariant() != prefab.Name.ToLowerInvariant()) continue;
if (!element.Name.ToString().Equals(prefab.Name, StringComparison.OrdinalIgnoreCase)) { continue; }
SerializableProperty.SerializeProperties(prefab, element, true);
}
}
@@ -260,7 +260,7 @@ namespace Barotrauma
private void SerializeToClipboard(ParticlePrefab prefab)
{
#if WINDOWS
if (prefab == null) return;
if (prefab == null) { return; }
XmlWriterSettings settings = new XmlWriterSettings
{
@@ -269,18 +269,40 @@ namespace Barotrauma
NewLineOnAttributes = true
};
XElement element = new XElement(prefab.Name);
SerializableProperty.SerializeProperties(prefab, element, true);
XElement originalElement = null;
foreach (ContentFile configFile in GameMain.Instance.GetFilesOfType(ContentType.Particles))
{
XDocument doc = XMLExtensions.TryLoadXml(configFile.Path);
if (doc == null) { continue; }
var prefabList = GameMain.ParticleManager.GetPrefabList();
foreach (ParticlePrefab otherPrefab in prefabList)
{
foreach (XElement subElement in doc.Root.Elements())
{
if (!subElement.Name.ToString().Equals(prefab.Name, StringComparison.OrdinalIgnoreCase)) { continue; }
SerializableProperty.SerializeProperties(prefab, subElement, true);
originalElement = subElement;
break;
}
}
}
if (originalElement == null)
{
originalElement = new XElement(prefab.Name);
SerializableProperty.SerializeProperties(prefab, originalElement, true);
}
StringBuilder sb = new StringBuilder();
using (var writer = XmlWriter.Create(sb, settings))
{
element.WriteTo(writer);
originalElement.WriteTo(writer);
writer.Flush();
}
Clipboard.SetText(sb.ToString());
#endif
#endif
}
public override void Update(double deltaTime)
@@ -474,7 +474,7 @@ namespace Barotrauma
};
btn.Color *= 0.5f;
labelTexts.Add(btn.TextBlock);
new GUIImage(new RectTransform(new Vector2(0.5f, 0.3f), btn.RectTransform, Anchor.BottomCenter, scaleBasis: ScaleBasis.BothHeight), style: "GUIButtonVerticalArrow", scaleToFit: true)
{
CanBeFocused = false,
@@ -567,7 +567,18 @@ namespace Barotrauma
var directJoinButton = new GUIButton(new RectTransform(new Vector2(0.25f, 0.9f), buttonContainer.RectTransform),
TextManager.Get("serverlistdirectjoin"))
{
OnClicked = (btn, userdata) => { ShowDirectJoinPrompt(); return true; }
OnClicked = (btn, userdata) =>
{
if (string.IsNullOrWhiteSpace(ClientNameBox.Text))
{
ClientNameBox.Flash();
ClientNameBox.Select();
GUI.PlayUISound(GUISoundType.PickItemFail);
return false;
}
ShowDirectJoinPrompt();
return true;
}
};
joinButton = new GUIButton(new RectTransform(new Vector2(0.25f, 0.9f), buttonContainer.RectTransform),
@@ -909,6 +920,12 @@ namespace Barotrauma
Steamworks.SteamMatchmaking.ResetActions();
if (GameMain.Client != null)
{
GameMain.Client.Disconnect();
GameMain.Client = null;
}
RefreshServers();
}
@@ -965,7 +982,7 @@ namespace Barotrauma
child.Visible =
serverInfo.OwnerVerified &&
serverInfo.ServerName.ToLowerInvariant().Contains(searchBox.Text.ToLowerInvariant()) &&
serverInfo.ServerName.Contains(searchBox.Text, StringComparison.OrdinalIgnoreCase) &&
(!filterSameVersion.Selected || (remoteVersion != null && NetworkMember.IsCompatible(remoteVersion, GameMain.Version))) &&
(!filterPassword.Selected || !serverInfo.HasPassword) &&
(!filterIncompatible.Selected || !incompatible) &&
@@ -996,7 +1013,7 @@ namespace Barotrauma
foreach (GUITickBox tickBox in gameModeTickBoxes)
{
var gameMode = (string)tickBox.UserData;
if (!tickBox.Selected && (serverInfo.GameMode == gameMode.ToLowerInvariant() || serverInfo.GameMode == gameMode))
if (!tickBox.Selected && serverInfo.GameMode.Equals(gameMode, StringComparison.OrdinalIgnoreCase))
{
child.Visible = false;
break;
@@ -1304,6 +1321,8 @@ namespace Barotrauma
{
#if DEBUG
DebugConsole.ThrowError($"Failed to parse a Steam friend's connect command ({connectCommand})", e);
#else
DebugConsole.Log($"Failed to parse a Steam friend's connect command ({connectCommand})\n" + e.StackTrace);
#endif
info.ConnectName = null;
info.ConnectEndpoint = null;
@@ -1512,7 +1531,7 @@ namespace Barotrauma
{
serverList.ClearChildren();
if (masterServerData.Substring(0, 5).ToLowerInvariant() == "error")
if (masterServerData.Substring(0, 5).Equals("error", StringComparison.OrdinalIgnoreCase))
{
DebugConsole.ThrowError("Error while connecting to master server (" + masterServerData + ")!");
return;
@@ -1895,6 +1914,8 @@ namespace Barotrauma
if (string.IsNullOrWhiteSpace(ClientNameBox.Text))
{
ClientNameBox.Flash();
ClientNameBox.Select();
GUI.PlayUISound(GUISoundType.PickItemFail);
return false;
}
@@ -196,8 +196,9 @@ namespace Barotrauma
Stretch = true,
UserData = "filterarea"
};
filterTexturesLabel = new GUITextBlock(new RectTransform(Vector2.One, filterArea.RectTransform), TextManager.Get("serverlog.filter"), font: GUI.Font) { IgnoreLayoutGroups = true }; ;
filterTexturesLabel = new GUITextBlock(new RectTransform(Vector2.One, filterArea.RectTransform), TextManager.Get("serverlog.filter"), font: GUI.Font, textAlignment: Alignment.CenterLeft) { IgnoreLayoutGroups = true }; ;
filterTexturesBox = new GUITextBox(new RectTransform(new Vector2(0.8f, 1.0f), filterArea.RectTransform), font: GUI.Font, createClearButton: true);
filterArea.RectTransform.MinSize = filterTexturesBox.RectTransform.MinSize;
filterTexturesBox.OnTextChanged += (textBox, text) => { FilterTextures(text); return true; };
textureList = new GUIListBox(new RectTransform(new Vector2(1.0f, 1.0f), paddedLeftPanel.RectTransform))
@@ -240,8 +241,9 @@ namespace Barotrauma
Stretch = true,
UserData = "filterarea"
};
filterSpritesLabel = new GUITextBlock(new RectTransform(Vector2.One, filterArea.RectTransform), TextManager.Get("serverlog.filter"), font: GUI.Font) { IgnoreLayoutGroups = true };
filterSpritesLabel = new GUITextBlock(new RectTransform(Vector2.One, filterArea.RectTransform), TextManager.Get("serverlog.filter"), font: GUI.Font, textAlignment: Alignment.CenterLeft) { IgnoreLayoutGroups = true };
filterSpritesBox = new GUITextBox(new RectTransform(new Vector2(0.8f, 1.0f), filterArea.RectTransform), font: GUI.Font, createClearButton: true);
filterArea.RectTransform.MinSize = filterSpritesBox.RectTransform.MinSize;
filterSpritesBox.OnTextChanged += (textBox, text) => { FilterSprites(text); return true; };
spriteList = new GUIListBox(new RectTransform(new Vector2(1.0f, 1.0f), paddedRightPanel.RectTransform))
@@ -26,10 +26,24 @@ namespace Barotrauma
//listbox that shows the files included in the item being created
private GUIListBox createItemFileList;
private FileSystemWatcher createItemWatcher;
private readonly List<GUIButton> tabButtons = new List<GUIButton>();
private readonly HashSet<string> pendingPreviewImageDownloads = new HashSet<string>();
private readonly Dictionary<string, Sprite> itemPreviewSprites = new Dictionary<string, Sprite>();
private class PendingPreviewImageDownload
{
/// <summary>
/// Was the image downloaded
/// </summary>
public bool Downloaded = false;
/// <summary>
/// How many tasks are looking to create a preview image based on this download
/// </summary>
public int PendingLoads = 1;
}
private readonly Dictionary<ulong, PendingPreviewImageDownload> pendingPreviewImageDownloads = new Dictionary<ulong, PendingPreviewImageDownload>();
private Dictionary<string, Sprite> itemPreviewSprites = new Dictionary<string, Sprite>();
private enum Tab
{
@@ -54,6 +68,8 @@ namespace Barotrauma
{
GameMain.Instance.OnResolutionChanged += CreateUI;
CreateUI();
Steamworks.SteamUGC.GlobalOnItemInstalled += OnItemInstalled;
}
private void CreateUI()
@@ -199,7 +215,7 @@ namespace Barotrauma
{
if (GUI.MouseOn is GUIButton || GUI.MouseOn?.Parent is GUIButton) { return false; }
publishedItemList.Deselect();
if (userdata is Submarine sub)
if (userdata is SubmarineInfo sub)
{
CreateWorkshopItem(sub);
}
@@ -215,6 +231,8 @@ namespace Barotrauma
createItemFrame = new GUIFrame(new RectTransform(new Vector2(0.58f, 1.0f), tabs[(int)Tab.Publish].RectTransform, Anchor.TopRight), style: null);
SelectTab(Tab.Mods);
subscribedCoroutine = CoroutineManager.StartCoroutine(PollSubscribedItems());
}
public override void Select()
@@ -230,11 +248,37 @@ namespace Barotrauma
SelectTab(Tab.Mods);
}
private void OnItemInstalled(ulong itemId)
{
RefreshSubscribedItems();
}
CoroutineHandle subscribedCoroutine;
private IEnumerable<object> PollSubscribedItems()
{
if (!SteamManager.IsInitialized) { yield return CoroutineStatus.Success; }
uint numSubscribed = 0;
while (true)
{
while (CoroutineManager.IsCoroutineRunning("Load")) { yield return new WaitForSeconds(1.0f); }
uint newNumSubscribed = Steamworks.SteamUGC.NumSubscribedItems;
if (newNumSubscribed != numSubscribed)
{
RefreshSubscribedItems();
numSubscribed = newNumSubscribed;
}
yield return new WaitForSeconds(1.0f);
}
}
private void SelectTab(Tab tab)
{
for (int i = 0; i < tabs.Length; i++)
{
tabButtons[i].Selected = tabs[i].Visible = i == (int)tab;
tabButtons[i].Selected = tabs[i].Visible = i == (int)tab;
}
if (createItemFrame.CountChildren == 0)
@@ -246,6 +290,7 @@ namespace Barotrauma
};
}
createItemWatcher?.Dispose(); createItemWatcher = null;
if (Screen.Selected == this)
{
switch (tab)
@@ -272,6 +317,25 @@ namespace Barotrauma
GameMain.SteamWorkshopScreen.Select();
}
public IEnumerable<object> RefreshDownloadState()
{
bool isDownloading = true;
while (true)
{
SteamManager.GetSubscribedWorkshopItems((items) =>
{
isDownloading = items.Any(it => it.IsDownloading || it.IsDownloadPending);
GameMain.MainMenuScreen.SetDownloadingModsNotification(isDownloading);
});
if (!isDownloading) { break; }
yield return new WaitForSeconds(0.5f);
}
yield return CoroutineStatus.Success;
}
private void RefreshSubscribedItems()
{
SteamManager.GetSubscribedWorkshopItems((items) =>
@@ -279,6 +343,8 @@ namespace Barotrauma
//filter out the items published by the player (they're shown in the publish tab)
var mySteamID = SteamManager.GetSteamID();
OnItemsReceived(GetVisibleItems(items.Where(it => it.Owner.Id != mySteamID)), subscribedItemList);
GameMain.MainMenuScreen.SetDownloadingModsNotification(items.Any(it => it.IsDownloading || it.IsDownloadPending));
});
}
@@ -312,7 +378,7 @@ namespace Barotrauma
{
CanBeFocused = false
};
foreach (Submarine sub in Submarine.SavedSubmarines)
foreach (SubmarineInfo sub in SubmarineInfo.SavedSubmarines)
{
if (sub.HasTag(SubmarineTag.HideInMenus)) { continue; }
string subPath = Path.GetFullPath(sub.FilePath);
@@ -348,6 +414,7 @@ namespace Barotrauma
foreach (ContentPackage contentPackage in ContentPackage.List)
{
if (!string.IsNullOrEmpty(contentPackage.SteamWorkshopUrl) || contentPackage.HideInWorkshopMenu) { continue; }
if (contentPackage == GameMain.VanillaContent) { continue; }
//don't list content packages that only define one sub (they're visible in the "Submarines" section)
if (contentPackage.Files.Count == 1 && contentPackage.Files[0].Type == ContentType.Submarine) { continue; }
CreateMyItemFrame(contentPackage, myItemList);
@@ -414,7 +481,7 @@ namespace Barotrauma
CanBeFocused = false
};
}
else
else if (Screen.Selected == this)
{
new GUIImage(new RectTransform(new Point(iconSize), innerFrame.RectTransform), SteamManager.DefaultPreviewImage, scaleToFit: true)
{
@@ -430,16 +497,20 @@ namespace Barotrauma
bool isNewImage;
lock (pendingPreviewImageDownloads)
{
isNewImage = !pendingPreviewImageDownloads.Contains(item?.PreviewImageUrl);
if (isNewImage) { pendingPreviewImageDownloads.Add(item?.PreviewImageUrl); }
isNewImage = !pendingPreviewImageDownloads.ContainsKey(item.Value.Id);
if (isNewImage)
{
if (File.Exists(imagePreviewPath))
{
File.Delete(imagePreviewPath);
}
pendingPreviewImageDownloads.Add(item.Value.Id, new PendingPreviewImageDownload());
}
}
if (isNewImage)
{
if (File.Exists(imagePreviewPath))
{
File.Delete(imagePreviewPath);
}
Directory.CreateDirectory(SteamManager.WorkshopItemPreviewImageFolder);
Uri baseAddress = new Uri(item?.PreviewImageUrl);
@@ -450,16 +521,23 @@ namespace Barotrauma
var request = new RestRequest(fileName, Method.GET);
client.ExecuteAsync(request, response =>
{
lock (pendingPreviewImageDownloads)
{
pendingPreviewImageDownloads.Remove(item?.PreviewImageUrl);
}
OnPreviewImageDownloaded(response, imagePreviewPath);
CoroutineManager.StartCoroutine(WaitForItemPreviewDownloaded(item, listBox, imagePreviewPath));
OnPreviewImageDownloaded(response, imagePreviewPath,
() =>
{
lock (pendingPreviewImageDownloads)
{
pendingPreviewImageDownloads[item.Value.Id].Downloaded = true;
}
CoroutineManager.StartCoroutine(WaitForItemPreviewDownloaded(item, listBox, imagePreviewPath));
});
});
}
else
{
lock (pendingPreviewImageDownloads)
{
pendingPreviewImageDownloads[item.Value.Id].PendingLoads++;
}
CoroutineManager.StartCoroutine(WaitForItemPreviewDownloaded(item, listBox, imagePreviewPath));
}
}
@@ -468,7 +546,7 @@ namespace Barotrauma
{
lock (pendingPreviewImageDownloads)
{
pendingPreviewImageDownloads.Remove(item?.PreviewImageUrl);
pendingPreviewImageDownloads.Remove(item.Value.Id);
}
DebugConsole.ThrowError("Downloading the preview image of the Workshop item \"" + item?.Title + "\" failed.", e);
}
@@ -488,10 +566,11 @@ namespace Barotrauma
CanBeFocused = false
};
if ((item?.IsSubscribed ?? false) && (item?.IsInstalled ?? false))
if ((item?.IsSubscribed ?? false) && (item?.IsInstalled ?? false) && Directory.Exists(item?.Directory))
{
GUITickBox enabledTickBox = null;
try
bool installed = SteamManager.CheckWorkshopItemEnabled(item);
if (!installed)
{
bool? compatible = SteamManager.CheckWorkshopItemCompatibility(item);
if (compatible.HasValue && !compatible.Value)
@@ -504,63 +583,29 @@ namespace Barotrauma
}
else
{
enabledTickBox = new GUITickBox(new RectTransform(new Point(32, 32), rightColumn.RectTransform), null)
installed = SteamManager.EnableWorkShopItem(item, true, out string errorMsg, Selected == this);
if (!installed)
{
ToolTip = TextManager.Get("WorkshopItemEnabled"),
UserData = item,
};
enabledTickBox.Selected = SteamManager.CheckWorkshopItemEnabled(item);
enabledTickBox.OnSelected = ToggleItemEnabled;
}
}
catch (Exception e)
{
if (enabledTickBox != null) { enabledTickBox.Enabled = false; }
itemFrame.ToolTip = e.Message;
itemFrame.Color = GUI.Style.Red;
itemFrame.HoverColor = GUI.Style.Red;
itemFrame.SelectedColor = GUI.Style.Red;
titleText.TextColor = GUI.Style.Red;
if (item?.IsSubscribed ?? false)
{
new GUIButton(new RectTransform(new Vector2(0.5f, 0.5f), rightColumn.RectTransform), TextManager.Get("WorkshopItemUnsubscribe"))
{
UserData = item,
OnClicked = (btn, userdata) =>
{
item?.Unsubscribe();
subscribedItemList.RemoveChild(subscribedItemList.Content.GetChildByUserData(item));
return true;
}
};
}
}
if (listBox != publishedItemList && SteamManager.CheckWorkshopItemEnabled(item) && !SteamManager.CheckWorkshopItemUpToDate(item))
{
new GUIButton(new RectTransform(new Vector2(0.4f, 0.5f), rightColumn.RectTransform, Anchor.BottomLeft), text: TextManager.Get("WorkshopItemUpdate"))
{
UserData = "updatebutton",
Font = GUI.SmallFont,
OnClicked = (btn, userdata) =>
{
if (SteamManager.UpdateWorkshopItem(item, out string errorMsg))
{
new GUIMessageBox("", TextManager.GetWithVariable("WorkshopItemUpdated", "[itemname]", item?.Title));
}
else
{
DebugConsole.ThrowError(errorMsg);
new GUIMessageBox(
TextManager.Get("Error"),
TextManager.GetWithVariables("WorkshopItemUpdateFailed", new string[2] { "[itemname]", "[errormessage]" }, new string[2] { item?.Title, errorMsg }));
}
btn.Enabled = false;
btn.Visible = false;
return true;
DebugConsole.NewMessage(errorMsg, Color.Red);
titleText.TextColor = Color.Red;
titleText.ToolTip = itemFrame.ToolTip = TextManager.GetWithVariables("WorkshopItemUpdateFailed", new string[2] { "[itemname]", "[errormessage]" }, new string[2] { TextManager.EnsureUTF8(item?.Title), errorMsg });
}
};
}
}
if (installed)
{
bool upToDate = SteamManager.CheckWorkshopItemUpToDate(item);
if (!upToDate)
{
if (!SteamManager.UpdateWorkshopItem(item, out string errorMsg))
{
DebugConsole.NewMessage(errorMsg, Color.Red);
titleText.TextColor = Color.Red;
titleText.ToolTip = itemFrame.ToolTip = TextManager.GetWithVariables("WorkshopItemUpdateFailed", new string[2] { "[itemname]", "[errormessage]" }, new string[2] { TextManager.EnsureUTF8(item?.Title), errorMsg });
}
}
}
}
@@ -568,7 +613,11 @@ namespace Barotrauma
{
new GUITextBlock(new RectTransform(new Vector2(0.5f, 0.5f), rightColumn.RectTransform), TextManager.Get("WorkshopItemDownloading"));
}
else
else if (item?.IsDownloadPending ?? false)
{
new GUITextBlock(new RectTransform(new Vector2(0.5f, 0.5f), rightColumn.RectTransform), TextManager.Get("WorkshopItemDownloadPending"));
}
else if (!(item?.IsSubscribed ?? false))
{
var downloadBtn = new GUIButton(new RectTransform(new Point((int)(32 * GUI.Scale)), rightColumn.RectTransform), "", style: "GUIPlusButton")
{
@@ -579,10 +628,66 @@ namespace Barotrauma
downloadBtn.OnClicked = (btn, userdata) => { DownloadItem(itemFrame, downloadBtn, item); return true; };
}
if ((item?.IsSubscribed ?? false) && listBox == subscribedItemList)
{
var reinstallBtn = new GUIButton(new RectTransform(new Point((int)(32 * GUI.Scale)), rightColumn.RectTransform), "", style: "GUIReloadButton")
{
ToolTip = TextManager.Get("WorkshopItemReinstall"),
ForceUpperCase = true,
UserData = "reinstall"
};
reinstallBtn.OnClicked = (btn, userdata) =>
{
var elem = subscribedItemList.Content.GetChildByUserData(item);
try
{
bool reselect = GameMain.Config.SelectedContentPackages.Any(cp => !string.IsNullOrWhiteSpace(cp.SteamWorkshopUrl) && cp.SteamWorkshopUrl == item?.Url);
if (!SteamManager.DisableWorkShopItem(item, false, out string errorMsg) ||
!SteamManager.EnableWorkShopItem(item, true, out errorMsg, reselect, true))
{
DebugConsole.ThrowError($"Failed to reinstall \"{item?.Title}\": {errorMsg}", null, true);
elem.Flash(GUI.Style.Red);
}
}
catch (Exception e)
{
DebugConsole.ThrowError($"Failed to reinstall \"{item?.Title}\"", e, true);
elem.Flash(GUI.Style.Red);
}
return true;
};
var unsubBtn = new GUIButton(new RectTransform(new Point((int)(32 * GUI.Scale)), rightColumn.RectTransform), "", style: "GUIMinusButton")
{
ToolTip = TextManager.Get("WorkshopItemUnsubscribe"),
ForceUpperCase = true,
UserData = "unsubscribe"
};
unsubBtn.OnClicked = (btn, userdata) =>
{
SteamManager.DisableWorkShopItem(item, true, out _);
item?.Unsubscribe();
subscribedItemList.RemoveChild(subscribedItemList.Content.GetChildByUserData(item));
return true;
};
}
innerFrame.Recalculate();
listBox.RecalculateChildren();
}
public void SetReinstallButtonStatus(Steamworks.Ugc.Item? item, bool enabled, Color? flashColor)
{
var child = subscribedItemList.Content.FindChild((component) => { return (component.UserData is Steamworks.Ugc.Item?) && (component.UserData as Steamworks.Ugc.Item?)?.Id == item?.Id; });
if (child != null)
{
var reinstallBtn = child.FindChild("reinstall", true);
if (reinstallBtn != null) { reinstallBtn.Enabled = enabled; }
var unsubBtn = child.FindChild("unsubscribe", true);
if (unsubBtn != null) { unsubBtn.Enabled = enabled; }
if (flashColor.HasValue) { child.Flash(flashColor); }
}
}
private void RemoveItemFromLists(ulong itemID)
{
RemoveItemFromList(publishedItemList);
@@ -596,7 +701,7 @@ namespace Barotrauma
}
}
private void CreateMyItemFrame(Submarine submarine, GUIListBox listBox)
private void CreateMyItemFrame(SubmarineInfo submarine, GUIListBox listBox)
{
var itemFrame = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.1f), listBox.Content.RectTransform, minSize: new Point(0, 80)),
style: "ListBoxElement")
@@ -629,21 +734,27 @@ namespace Barotrauma
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.4f), innerFrame.RectTransform), contentPackage.Name, textAlignment: Alignment.CenterLeft);
}
private void OnPreviewImageDownloaded(IRestResponse response, string previewImagePath)
private void OnPreviewImageDownloaded(IRestResponse response, string previewImagePath, Action action)
{
if (response.ResponseStatus == ResponseStatus.Completed)
{
try
{
File.WriteAllBytes(previewImagePath, response.RawBytes);
}
catch (Exception e)
{
string errorMsg = "Failed to save workshop item preview image to \"" + previewImagePath + "\".";
GameAnalyticsManager.AddErrorEventOnce("SteamWorkshopScreen.OnItemPreviewDownloaded:WriteAllBytesFailed" + previewImagePath,
GameAnalyticsSDK.Net.EGAErrorSeverity.Error, errorMsg + "\n" + e.Message);
return;
}
TaskPool.Add(WritePreviewImageAsync(response, previewImagePath), (task) => { action?.Invoke(); });
}
}
private async Task WritePreviewImageAsync(IRestResponse response, string previewImagePath)
{
await Task.Yield();
try
{
File.WriteAllBytes(previewImagePath, response.RawBytes);
}
catch (Exception e)
{
string errorMsg = "Failed to save workshop item preview image to \"" + previewImagePath + "\".";
GameAnalyticsManager.AddErrorEventOnce("SteamWorkshopScreen.OnItemPreviewDownloaded:WriteAllBytesFailed" + previewImagePath,
GameAnalyticsSDK.Net.EGAErrorSeverity.Error, errorMsg + "\n" + e.Message);
return;
}
}
@@ -653,47 +764,67 @@ namespace Barotrauma
{
lock (pendingPreviewImageDownloads)
{
if (!pendingPreviewImageDownloads.Contains(item?.PreviewImageUrl)) { break; }
if (pendingPreviewImageDownloads[item.Value.Id].Downloaded){ break; }
}
yield return CoroutineStatus.Running;
yield return new WaitForSeconds(0.2f);
}
if (File.Exists(previewImagePath))
{
Sprite newSprite;
if (itemPreviewSprites.ContainsKey(item?.PreviewImageUrl))
TaskPool.Add(LoadPreviewImageAsync(item?.PreviewImageUrl, previewImagePath),
new Tuple<Steamworks.Ugc.Item?, GUIListBox>(item, listBox),
(task, tuple) =>
{
newSprite = itemPreviewSprites[item?.PreviewImageUrl];
}
else
{
newSprite = new Sprite(previewImagePath, sourceRectangle: null);
itemPreviewSprites.Add(item?.PreviewImageUrl, newSprite);
}
(var it, var lb) = tuple;
var previewImage = lb.Content.FindChild(item)?.GetChildByUserData("previewimage") as GUIImage;
if (previewImage != null)
{
previewImage.Sprite = task.Result;
}
else
{
CreateWorkshopItemFrame(it, lb);
}
if (listBox.Content.FindChild(item)?.GetChildByUserData("previewimage") is GUIImage previewImage)
{
previewImage.Sprite = newSprite;
}
else
{
CreateWorkshopItemFrame(item, listBox);
}
if (modsPreviewFrame.FindChild(it) != null)
{
ShowItemPreview(it, modsPreviewFrame);
}
if (browsePreviewFrame.FindChild(item) != null)
{
ShowItemPreview(it, browsePreviewFrame);
}
if (modsPreviewFrame.FindChild(item) != null)
{
ShowItemPreview(item, modsPreviewFrame);
}
if (browsePreviewFrame.FindChild(item) != null)
{
ShowItemPreview(item, browsePreviewFrame);
}
lock (pendingPreviewImageDownloads)
{
pendingPreviewImageDownloads[it.Value.Id].PendingLoads--;
if (pendingPreviewImageDownloads[it.Value.Id].PendingLoads <= 0) { pendingPreviewImageDownloads.Remove(it.Value.Id); }
}
});
}
yield return CoroutineStatus.Success;
}
private async Task<Sprite> LoadPreviewImageAsync(string previewImageUrl, string previewImagePath)
{
await Task.Yield();
lock (itemPreviewSprites)
{
if (itemPreviewSprites.ContainsKey(previewImageUrl))
{
return itemPreviewSprites[previewImageUrl];
}
else
{
Sprite newSprite = new Sprite(previewImagePath, sourceRectangle: null);
itemPreviewSprites.Add(previewImageUrl, newSprite);
return newSprite;
}
}
}
private bool DownloadItem(GUIComponent frame, GUIButton downloadButton, Steamworks.Ugc.Item? item)
{
if (item == null) { return false; }
@@ -721,49 +852,6 @@ namespace Barotrauma
return true;
}
private bool ToggleItemEnabled(GUITickBox tickBox)
{
if (!(tickBox.UserData is Steamworks.Ugc.Item?)) { return false; }
var item = tickBox.UserData as Steamworks.Ugc.Item?;
if (item == null) { return false; }
//currently editing the item, don't allow enabling/disabling it
if (itemEditor?.FileId == item?.Id) { tickBox.Selected = true; return false; }
var updateButton = tickBox.Parent.FindChild("updatebutton");
string errorMsg;
if (tickBox.Selected)
{
if (!SteamManager.EnableWorkShopItem(item, false, out errorMsg))
{
tickBox.Visible = false;
tickBox.Selected = false;
if (tickBox.Parent.GetChildByUserData("titletext") is GUITextBlock titleText) { titleText.TextColor = GUI.Style.Red; }
}
}
else
{
if (!SteamManager.DisableWorkShopItem(item, false, out errorMsg))
{
tickBox.Enabled = false;
}
GameMain.Config.EnsureCoreContentPackageSelected();
}
if (updateButton != null)
{
//cannot update if enabling/disabling the item failed or if the item is not enabled
updateButton.Enabled = tickBox.Enabled && tickBox.Selected;
}
if (!string.IsNullOrEmpty(errorMsg))
{
new GUIMessageBox(TextManager.Get("Error"), errorMsg);
}
return true;
}
private void ShowItemPreview(Steamworks.Ugc.Item? item, GUIFrame itemPreviewFrame)
{
itemPreviewFrame.ClearChildren();
@@ -920,9 +1008,9 @@ namespace Barotrauma
};
}
private void CreateWorkshopItem(Submarine sub)
private void CreateWorkshopItem(SubmarineInfo sub)
{
string destinationFolder = Path.Combine("Mods", sub.Name);
string destinationFolder = Path.Combine("Mods", sub.Name.Trim());
itemContentPackage = ContentPackage.CreatePackage(sub.Name, Path.Combine(destinationFolder, SteamManager.MetadataFileName), corePackage: false);
SteamManager.CreateWorkshopItemStaging(itemContentPackage, out itemEditor);
@@ -940,8 +1028,8 @@ namespace Barotrauma
itemContentPackage.AddFile(sub.FilePath, ContentType.Submarine);
itemContentPackage.Name = sub.Name;
itemContentPackage.Save(itemContentPackage.Path);
ContentPackage.List.Add(itemContentPackage);
GameMain.Config.SelectContentPackage(itemContentPackage);
//ContentPackage.List.Add(itemContentPackage);
//GameMain.Config.SelectContentPackage(itemContentPackage);
itemEditor = itemEditor?.WithTitle(sub.Name).WithTag("Submarine").WithDescription(sub.Description);
@@ -1097,7 +1185,7 @@ 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.AutoScaleHorizontal = true;
tagBtn.Selected = itemEditor?.Tags?.Any(t => t.ToLowerInvariant() == tag) ?? false;
tagBtn.Selected = itemEditor?.Tags?.Any(t => t.Equals(tag, StringComparison.OrdinalIgnoreCase)) ?? false;
tagBtn.OnClicked = (btn, userdata) =>
{
@@ -1108,7 +1196,7 @@ namespace Barotrauma
}
else
{
itemEditor?.Tags?.RemoveAll(t => t.ToLowerInvariant() == tagBtn.Text.ToLowerInvariant());
itemEditor?.Tags?.RemoveAll(t => t.Equals(tagBtn.Text, StringComparison.OrdinalIgnoreCase));
tagBtn.Selected = false;
}
return true;
@@ -1201,6 +1289,16 @@ namespace Barotrauma
OnClicked = (btn, userdata) => { ToolBox.OpenFileWithShell(Path.GetFullPath(Path.GetDirectoryName(itemContentPackage.Path))); return true; }
};
createItemFileList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.35f), createItemContent.RectTransform));
createItemWatcher?.Dispose();
createItemWatcher = new FileSystemWatcher(Path.GetDirectoryName(itemContentPackage.Path))
{
Filter = "*",
NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName
};
createItemWatcher.Created += OnFileSystemChanges;
createItemWatcher.Deleted += OnFileSystemChanges;
createItemWatcher.Renamed += OnFileSystemChanges;
createItemWatcher.EnableRaisingEvents = true;
RefreshCreateItemFileList();
var buttonContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.05f), createItemContent.RectTransform), isHorizontal: true)
@@ -1447,23 +1545,54 @@ namespace Barotrauma
{
destinationPath = Path.Combine(modFolder, filePathRelativeToModFolder);
}
itemContentPackage.AddFile(destinationPath, ContentType.None);
}
itemContentPackage.Save(itemContentPackage.Path);
RefreshCreateItemFileList();
}
volatile bool refreshFileList = false;
private void OnFileSystemChanges(object sender, FileSystemEventArgs e)
{
refreshFileList = true;
}
private void RefreshCreateItemFileList()
{
createItemFileList.ClearChildren();
if (itemContentPackage == null) return;
var contentTypes = Enum.GetValues(typeof(ContentType));
foreach (ContentFile contentFile in itemContentPackage.Files)
List<ContentFile> files = itemContentPackage.Files.ToList();
foreach (ContentFile contentFile in files)
{
bool fileExists = File.Exists(contentFile.Path);
if (!fileExists) { itemContentPackage.Files.Remove(contentFile); continue; }
}
List<ContentFile> allFiles = Directory.GetFiles(Path.GetDirectoryName(itemContentPackage.Path), "*", SearchOption.AllDirectories)
.Select(f => new ContentFile(f, ContentType.None))
.Where(file => Path.GetFileName(file.Path) != SteamManager.MetadataFileName &&
Path.GetFileName(file.Path) != SteamManager.PreviewImageName)
.ToList();
for (int i=0;i<allFiles.Count;i++)
{
ContentFile file = allFiles[i];
ContentFile otherFile = itemContentPackage.Files.Find(f => string.Equals(Path.GetFullPath(f.Path).CleanUpPath(),
Path.GetFullPath(file.Path).CleanUpPath(),
StringComparison.InvariantCultureIgnoreCase));
if (otherFile != null)
{
//replace the generated ContentFile object with the one that's present in the
//content package to determine which tickboxes should already be checked
allFiles[i] = otherFile;
}
}
foreach (ContentFile contentFile in allFiles)
{
bool illegalPath = !ContentPackage.IsModFilePathAllowed(contentFile);
//string pathInStagingFolder = Path.Combine(SteamManager.WorkshopItemStagingFolder, contentFile.Path);
//bool fileInStagingFolder = File.Exists(pathInStagingFolder);
bool fileExists = File.Exists(contentFile.Path);
var fileFrame = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.12f), createItemFileList.Content.RectTransform) { MinSize = new Point(0, 20) },
@@ -1479,11 +1608,25 @@ namespace Barotrauma
RelativeSpacing = 0.05f
};
var tickBox = new GUITickBox(new RectTransform(new Vector2(0.1f, 0.8f), content.RectTransform), "")
var tickBox = new GUITickBox(new RectTransform(Vector2.One, content.RectTransform, scaleBasis: ScaleBasis.BothHeight), "")
{
Selected = fileExists && !illegalPath,
Enabled = false,
ToolTip = TextManager.Get(illegalPath ? "WorkshopItemFileNotIncluded" : "WorkshopItemFileIncluded")
Selected = itemContentPackage.Files.Contains(contentFile),
UserData = contentFile
};
tickBox.OnSelected = (tb) =>
{
ContentFile f = tb.UserData as ContentFile;
if (tb.Selected)
{
if (!itemContentPackage.Files.Contains(f)) { itemContentPackage.Files.Add(f); }
}
else
{
if (itemContentPackage.Files.Contains(f)) { itemContentPackage.Files.Remove(f); }
}
return true;
};
var nameText = new GUITextBlock(new RectTransform(new Vector2(0.6f, 1.0f), content.RectTransform, Anchor.CenterLeft), contentFile.Path, font: GUI.SmallFont)
@@ -1523,10 +1666,29 @@ namespace Barotrauma
{
OnClicked = (btn, userdata) =>
{
itemContentPackage.RemoveFile(contentFile);
itemContentPackage.Save(itemContentPackage.Path);
RefreshCreateItemFileList();
RefreshMyItemList();
var msgBox = new GUIMessageBox(TextManager.Get("ConfirmFileDeletionHeader"),
TextManager.GetWithVariable("ConfirmFileDeletion", "[file]", contentFile.Path),
new string[] { TextManager.Get("Yes"), TextManager.Get("Cancel") })
{
UserData = "verificationprompt"
};
msgBox.Buttons[0].OnClicked = (applyButton, obj) =>
{
try
{
File.Delete(contentFile.Path);
if (contentFile.Type == ContentType.Submarine) { SubmarineInfo.RefreshSavedSub(contentFile.Path); }
}
catch (Exception e)
{
DebugConsole.ThrowError($"Failed to delete \"${contentFile.Path}\".", e);
}
//RefreshCreateItemFileList();
RefreshMyItemList();
return true;
};
msgBox.Buttons[0].OnClicked += msgBox.Close;
msgBox.Buttons[1].OnClicked = msgBox.Close;
return true;
}
};
@@ -1536,6 +1698,8 @@ namespace Barotrauma
new Point(0, (int)(content.RectTransform.Children.Max(c => c.MinSize.Y) / content.RectTransform.RelativeSize.Y));
nameText.Text = ToolBox.LimitString(nameText.Text, nameText.Font, maxWidth: nameText.Rect.Width);
}
itemContentPackage.Save(itemContentPackage.Path);
}
private void PublishWorkshopItem()
@@ -1640,6 +1804,11 @@ namespace Barotrauma
public override void Update(double deltaTime)
{
if (refreshFileList)
{
RefreshCreateItemFileList();
refreshFileList = false;
}
}
#endregion
File diff suppressed because it is too large Load Diff