(5a377a8ee) Unstable v0.9.1000.0
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Barotrauma.IO;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
|
||||
@@ -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; };
|
||||
|
||||
@@ -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();
|
||||
|
||||
+52
-34
@@ -2,13 +2,17 @@
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using Barotrauma.Extensions;
|
||||
using FarseerPhysics;
|
||||
using FarseerPhysics.Dynamics;
|
||||
#if DEBUG
|
||||
using System.IO;
|
||||
#else
|
||||
using Barotrauma.IO;
|
||||
#endif
|
||||
|
||||
namespace Barotrauma.CharacterEditor
|
||||
{
|
||||
@@ -121,7 +125,10 @@ namespace Barotrauma.CharacterEditor
|
||||
ResetVariables();
|
||||
var subInfo = new SubmarineInfo("Content/AnimEditor.sub");
|
||||
Submarine.MainSub = new Submarine(subInfo);
|
||||
Submarine.MainSub.PhysicsBody.Enabled = false;
|
||||
if (Submarine.MainSub.PhysicsBody != null)
|
||||
{
|
||||
Submarine.MainSub.PhysicsBody.Enabled = false;
|
||||
}
|
||||
originalWall = new WallGroup(new List<Structure>(Structure.WallList));
|
||||
CloneWalls();
|
||||
CalculateMovementLimits();
|
||||
@@ -275,7 +282,7 @@ namespace Barotrauma.CharacterEditor
|
||||
return TextManager.Get(screenTextTag + tag);
|
||||
}
|
||||
|
||||
#region Main methods
|
||||
#region Main methods
|
||||
public override void AddToGUIUpdateList()
|
||||
{
|
||||
rightArea.AddToGUIUpdateList();
|
||||
@@ -476,9 +483,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))
|
||||
@@ -652,9 +666,6 @@ namespace Barotrauma.CharacterEditor
|
||||
}
|
||||
if (!isFrozen)
|
||||
{
|
||||
Submarine.MainSub.SetPrevTransform(Submarine.MainSub.Position);
|
||||
Submarine.MainSub.Update((float)deltaTime);
|
||||
|
||||
foreach (PhysicsBody body in PhysicsBody.List)
|
||||
{
|
||||
body.SetPrevTransform(body.SimPosition, body.Rotation);
|
||||
@@ -981,9 +992,9 @@ namespace Barotrauma.CharacterEditor
|
||||
}
|
||||
spriteBatch.End();
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Ragdoll Manipulation
|
||||
#region Ragdoll Manipulation
|
||||
private void UpdateJointCreation()
|
||||
{
|
||||
if (jointCreationMode == JointCreationMode.None)
|
||||
@@ -1310,9 +1321,9 @@ namespace Barotrauma.CharacterEditor
|
||||
}
|
||||
RecreateRagdoll();
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Endless runner
|
||||
#region Endless runner
|
||||
private int min;
|
||||
private int max;
|
||||
private void CalculateMovementLimits()
|
||||
@@ -1415,9 +1426,9 @@ namespace Barotrauma.CharacterEditor
|
||||
AllWalls.ForEach(w => w.SetCollisionCategory(collisionCategory));
|
||||
GameMain.World.ProcessChanges();
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Character spawning
|
||||
#region Character spawning
|
||||
private int characterIndex = -1;
|
||||
private string currentCharacterConfig;
|
||||
private string selectedJob = null;
|
||||
@@ -1739,7 +1750,11 @@ namespace Barotrauma.CharacterEditor
|
||||
{
|
||||
Directory.CreateDirectory(mainFolder);
|
||||
}
|
||||
#if DEBUG
|
||||
doc.Save(configFilePath);
|
||||
#else
|
||||
doc.SaveSafe(configFilePath);
|
||||
#endif
|
||||
// Add to the selected content package
|
||||
contentPackage.AddFile(configFilePath, ContentType.Character);
|
||||
contentPackage.Save(contentPackage.Path);
|
||||
@@ -1820,9 +1835,9 @@ namespace Barotrauma.CharacterEditor
|
||||
{
|
||||
character.Inventory?.Items.ForEachMod(i => i?.Unequip(character));
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region GUI
|
||||
#region GUI
|
||||
private static Vector2 innerScale = new Vector2(0.95f, 0.95f);
|
||||
|
||||
private GUILayoutGroup rightArea, leftArea;
|
||||
@@ -2117,7 +2132,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 +2142,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 +3133,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()
|
||||
@@ -3134,9 +3152,9 @@ namespace Barotrauma.CharacterEditor
|
||||
|
||||
fileEditPanel.RectTransform.MinSize = new Point(0, (int)(layoutGroup.RectTransform.Children.Sum(c => c.MinSize.Y + layoutGroup.AbsoluteSpacing) * 1.2f));
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region ToggleButtons
|
||||
#region ToggleButtons
|
||||
private enum Direction
|
||||
{
|
||||
Left,
|
||||
@@ -3198,9 +3216,9 @@ namespace Barotrauma.CharacterEditor
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Params
|
||||
#region Params
|
||||
private CharacterParams CharacterParams => character.Params;
|
||||
private List<AnimationParams> AnimParams => character.AnimController.AllAnimParams;
|
||||
private AnimationParams CurrentAnimation => character.AnimController.CurrentAnimationParams;
|
||||
@@ -3451,9 +3469,9 @@ namespace Barotrauma.CharacterEditor
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Helpers
|
||||
#region Helpers
|
||||
private Vector2 ScreenToSim(float x, float y) => ScreenToSim(new Vector2(x, y));
|
||||
private Vector2 ScreenToSim(Vector2 p) => ConvertUnits.ToSimUnits(Cam.ScreenToWorld(p)) + Submarine.MainSub.SimPosition;
|
||||
private Vector2 SimToScreen(float x, float y) => SimToScreen(new Vector2(x, y));
|
||||
@@ -3694,9 +3712,9 @@ namespace Barotrauma.CharacterEditor
|
||||
SetToggle(spritesheetToggle, true);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Animation Controls
|
||||
#region Animation Controls
|
||||
private void DrawAnimationControls(SpriteBatch spriteBatch, float deltaTime)
|
||||
{
|
||||
var collider = character.AnimController.Collider;
|
||||
@@ -4289,9 +4307,9 @@ namespace Barotrauma.CharacterEditor
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Ragdoll
|
||||
#region Ragdoll
|
||||
private Vector2[] corners = new Vector2[4];
|
||||
private Vector2[] GetLimbPhysicRect(Limb limb)
|
||||
{
|
||||
@@ -4613,9 +4631,9 @@ namespace Barotrauma.CharacterEditor
|
||||
}
|
||||
return otherLimbs;
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Spritesheet
|
||||
#region Spritesheet
|
||||
private List<Texture2D> textures;
|
||||
private List<Texture2D> Textures
|
||||
{
|
||||
@@ -5210,9 +5228,9 @@ namespace Barotrauma.CharacterEditor
|
||||
CalculateSpritesheetZoom();
|
||||
spriteSheetZoomBar.BarScroll = MathHelper.Lerp(0, 1, MathUtils.InverseLerp(spriteSheetMinZoom, spriteSheetMaxZoom, spriteSheetZoom));
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Widgets as methods
|
||||
#region Widgets as methods
|
||||
private void DrawRadialWidget(SpriteBatch spriteBatch, Vector2 drawPos, float value, string toolTip, Color color, Action<float> onClick,
|
||||
float circleRadius = 30, int widgetSize = 10, float rotationOffset = 0, bool clockWise = true, bool displayAngle = true, bool? autoFreeze = null, bool wrapAnglePi = false, bool holdPosition = false, int rounding = 1)
|
||||
{
|
||||
@@ -5321,9 +5339,9 @@ namespace Barotrauma.CharacterEditor
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Widgets as classes
|
||||
#region Widgets as classes
|
||||
private Dictionary<string, Widget> animationWidgets = new Dictionary<string, Widget>();
|
||||
private Dictionary<string, Widget> jointSelectionWidgets = new Dictionary<string, Widget>();
|
||||
private Dictionary<string, Widget> limbEditWidgets = new Dictionary<string, Widget>();
|
||||
@@ -5477,6 +5495,6 @@ namespace Barotrauma.CharacterEditor
|
||||
return w;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.IO;
|
||||
using Barotrauma.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
|
||||
@@ -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; }
|
||||
@@ -151,7 +151,10 @@ namespace Barotrauma
|
||||
|
||||
GameMain.ParticleManager.UpdateTransforms();
|
||||
|
||||
GameMain.LightManager.ObstructVision = Character.Controlled != null && Character.Controlled.ObstructVision;
|
||||
GameMain.LightManager.ObstructVision =
|
||||
Character.Controlled != null &&
|
||||
Character.Controlled.ObstructVision &&
|
||||
(Character.Controlled.ViewTarget == Character.Controlled || Character.Controlled.ViewTarget == null);
|
||||
|
||||
if (Character.Controlled != null)
|
||||
{
|
||||
@@ -204,9 +207,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);
|
||||
@@ -232,11 +238,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();
|
||||
@@ -257,7 +264,7 @@ namespace Barotrauma
|
||||
graphics.SetRenderTarget(renderTargetFinal);
|
||||
|
||||
WaterRenderer.Instance.ResetBuffers();
|
||||
Hull.UpdateVertices(graphics, cam, WaterRenderer.Instance);
|
||||
Hull.UpdateVertices(cam, WaterRenderer.Instance);
|
||||
WaterRenderer.Instance.RenderWater(spriteBatch, renderTargetWater, cam);
|
||||
WaterRenderer.Instance.RenderAir(graphics, cam, renderTarget, Cam.ShaderTransform);
|
||||
graphics.DepthStencilState = DepthStencilState.None;
|
||||
@@ -284,10 +291,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)
|
||||
@@ -333,9 +342,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);
|
||||
|
||||
@@ -373,29 +385,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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,10 +3,14 @@ using Barotrauma.RuinGeneration;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Xml;
|
||||
using System.Xml.Linq;
|
||||
#if DEBUG
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
#else
|
||||
using Barotrauma.IO;
|
||||
#endif
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
@@ -170,14 +174,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 +249,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,7 +463,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));
|
||||
GUI.DrawRectangle(spriteBatch, new Rectangle(new Point(0, -Level.Loaded.Size.Y), Level.Loaded.Size), Color.Gray, thickness: (int)(1.0f / cam.Zoom));
|
||||
spriteBatch.End();
|
||||
|
||||
if (lightingEnabled.Selected)
|
||||
@@ -504,7 +501,7 @@ namespace Barotrauma
|
||||
|
||||
private void SerializeAll()
|
||||
{
|
||||
XmlWriterSettings settings = new XmlWriterSettings
|
||||
System.Xml.XmlWriterSettings settings = new System.Xml.XmlWriterSettings
|
||||
{
|
||||
Indent = true,
|
||||
NewLineOnAttributes = true
|
||||
@@ -585,7 +582,7 @@ namespace Barotrauma
|
||||
|
||||
if (elementFound)
|
||||
{
|
||||
XmlWriterSettings settings = new XmlWriterSettings
|
||||
System.Xml.XmlWriterSettings settings = new System.Xml.XmlWriterSettings
|
||||
{
|
||||
Indent = true,
|
||||
NewLineOnAttributes = true
|
||||
@@ -602,7 +599,7 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
|
||||
#region LevelObject Wizard
|
||||
#region LevelObject Wizard
|
||||
private class Wizard
|
||||
{
|
||||
private LevelObjectPrefab newPrefab;
|
||||
@@ -683,8 +680,8 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
newPrefab.Name = nameBox.Text;
|
||||
|
||||
XmlWriterSettings settings = new XmlWriterSettings { Indent = true };
|
||||
|
||||
System.Xml.XmlWriterSettings settings = new System.Xml.XmlWriterSettings { Indent = true };
|
||||
foreach (ContentFile configFile in GameMain.Instance.GetFilesOfType(ContentType.LevelObjectPrefabs))
|
||||
{
|
||||
XDocument doc = XMLExtensions.TryLoadXml(configFile.Path);
|
||||
@@ -717,6 +714,6 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ using RestSharp;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using Barotrauma.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Threading;
|
||||
@@ -409,10 +409,9 @@ namespace Barotrauma
|
||||
|
||||
this.game = game;
|
||||
|
||||
menuTabs[(int)Tab.Credits] = new GUIFrame(new RectTransform(Vector2.One, GUI.Canvas), style: null, color: Color.Black * 0.5f)
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
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");
|
||||
|
||||
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");
|
||||
|
||||
@@ -1010,11 +1009,12 @@ namespace Barotrauma
|
||||
GUI.Draw(Cam, spriteBatch);
|
||||
|
||||
#if !UNSTABLE
|
||||
GUI.Font.DrawString(spriteBatch, "Barotrauma v" + GameMain.Version + " (" + AssemblyInfo.GetBuildString() + ", branch " + AssemblyInfo.GetGitBranch() + ", revision " + AssemblyInfo.GetGitRevision() + ")", new Vector2(10, GameMain.GraphicsHeight - 20), Color.White * 0.7f);
|
||||
string versionString = "Barotrauma v" + GameMain.Version + " (" + AssemblyInfo.GetBuildString() + ", branch " + AssemblyInfo.GetGitBranch() + ", revision " + AssemblyInfo.GetGitRevision() + ")";
|
||||
GUI.SmallFont.DrawString(spriteBatch, versionString, new Vector2(HUDLayoutSettings.Padding, GameMain.GraphicsHeight - GUI.SmallFont.MeasureString(versionString).Y - HUDLayoutSettings.Padding * 0.75f), Color.White * 0.7f);
|
||||
#endif
|
||||
if (selectedTab != Tab.Credits)
|
||||
{
|
||||
Vector2 textPos = new Vector2(GameMain.GraphicsWidth - 10, GameMain.GraphicsHeight - 10);
|
||||
Vector2 textPos = new Vector2(GameMain.GraphicsWidth - HUDLayoutSettings.Padding, GameMain.GraphicsHeight - HUDLayoutSettings.Padding * 0.75f);
|
||||
for (int i = legalCrap.Length - 1; i >= 0; i--)
|
||||
{
|
||||
Vector2 textSize = GUI.SmallFont.MeasureString(legalCrap[i]);
|
||||
@@ -1069,7 +1069,7 @@ namespace Barotrauma
|
||||
{
|
||||
File.Copy(selectedSub.FilePath, Path.Combine(SaveUtil.TempPath, selectedSub.Name + ".sub"), true);
|
||||
}
|
||||
catch (IOException e)
|
||||
catch (System.IO.IOException e)
|
||||
{
|
||||
DebugConsole.ThrowError("Copying the file \"" + selectedSub.FilePath + "\" failed. The file may have been deleted or in use by another process. Try again or select another submarine.", e);
|
||||
GameAnalyticsManager.AddErrorEventOnce(
|
||||
|
||||
@@ -4,7 +4,7 @@ using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Barotrauma.IO;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 ------------------------------------------------------------------
|
||||
|
||||
@@ -658,7 +668,7 @@ namespace Barotrauma
|
||||
OnClicked = (btn, obj) =>
|
||||
{
|
||||
GameMain.Client.RequestStartRound();
|
||||
CoroutineManager.StartCoroutine(WaitForStartRound(StartButton, allowCancel: false), "WaitForStartRound");
|
||||
CoroutineManager.StartCoroutine(WaitForStartRound(StartButton), "WaitForStartRound");
|
||||
return true;
|
||||
}
|
||||
};
|
||||
@@ -776,6 +786,26 @@ namespace Barotrauma
|
||||
};
|
||||
|
||||
var subLabel = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.055f), subHolder.RectTransform) { MinSize = new Point(0, 25) }, TextManager.Get("Submarine"), font: GUI.SubHeadingFont);
|
||||
|
||||
var filterContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.05f), subHolder.RectTransform), isHorizontal: true)
|
||||
{
|
||||
Stretch = true
|
||||
};
|
||||
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) =>
|
||||
{
|
||||
foreach (GUIComponent child in subList.Content.Children)
|
||||
{
|
||||
if (!(child.UserData is SubmarineInfo sub)) { continue; }
|
||||
child.Visible = string.IsNullOrEmpty(text) ? true : sub.DisplayName.ToLower().Contains(text.ToLower());
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
subList = new GUIListBox(new RectTransform(Vector2.One, subHolder.RectTransform))
|
||||
{
|
||||
OnSelected = VotableClicked
|
||||
@@ -1163,25 +1193,11 @@ namespace Barotrauma
|
||||
GUI.ClearCursorWait();
|
||||
}
|
||||
|
||||
public IEnumerable<object> WaitForStartRound(GUIButton startButton, bool allowCancel)
|
||||
public IEnumerable<object> WaitForStartRound(GUIButton startButton)
|
||||
{
|
||||
GUI.SetCursorWaiting();
|
||||
string headerText = TextManager.Get("RoundStartingPleaseWait");
|
||||
var msgBox = new GUIMessageBox(headerText, TextManager.Get("RoundStarting"),
|
||||
allowCancel ? new string[] { TextManager.Get("Cancel") } : new string[0]);
|
||||
|
||||
if (allowCancel)
|
||||
{
|
||||
msgBox.Buttons[0].OnClicked = (btn, userdata) =>
|
||||
{
|
||||
startButton.Enabled = true;
|
||||
GameMain.Client.RequestRoundEnd();
|
||||
CoroutineManager.StopCoroutines("WaitForStartRound");
|
||||
GUI.ClearCursorWait();
|
||||
return true;
|
||||
};
|
||||
msgBox.Buttons[0].OnClicked += msgBox.Close;
|
||||
}
|
||||
var msgBox = new GUIMessageBox(headerText, TextManager.Get("RoundStarting"), new string[0]);
|
||||
|
||||
if (startButton != null)
|
||||
{
|
||||
@@ -1393,18 +1409,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 +1449,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 +1578,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),
|
||||
@@ -1845,28 +1892,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>;
|
||||
|
||||
@@ -1881,9 +1928,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;
|
||||
@@ -1895,51 +1942,38 @@ 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;
|
||||
bool hasManagePermissions = GameMain.Client.HasPermission(ClientPermissions.ManagePermissions);
|
||||
|
||||
playerFrame = new GUIButton(new RectTransform(Vector2.One, GUI.Canvas), style: "GUIBackgroundBlocker")
|
||||
PlayerFrame = new GUIButton(new RectTransform(Vector2.One, GUI.Canvas, Anchor.Center), style: null)
|
||||
{
|
||||
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(.28f, .5f) : new Vector2(.28f, .24f);
|
||||
new GUIFrame(new RectTransform(GUI.Canvas.RelativeSize, PlayerFrame.RectTransform, Anchor.Center), style: "GUIBackgroundBlocker");
|
||||
Vector2 frameSize = hasManagePermissions ? new Vector2(.28f, .5f) : new Vector2(.28f, .15f);
|
||||
|
||||
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,
|
||||
RelativeSpacing = 0.03f
|
||||
};
|
||||
|
||||
var headerContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.1f), paddedPlayerFrame.RectTransform), isHorizontal: true, childAnchor: Anchor.CenterLeft)
|
||||
var headerContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, hasManagePermissions ? 0.1f : 0.25f), paddedPlayerFrame.RectTransform), isHorizontal: true, childAnchor: Anchor.CenterLeft)
|
||||
{
|
||||
Stretch = true
|
||||
};
|
||||
|
||||
var nameText = new GUITextBlock(new RectTransform(new Vector2(0.6f, 1.0f), headerContainer.RectTransform),
|
||||
var nameText = new GUITextBlock(new RectTransform(new Vector2(0.5f, 1.0f), headerContainer.RectTransform),
|
||||
text: selectedClient.Name, font: GUI.LargeFont);
|
||||
nameText.Text = ToolBox.LimitString(nameText.Text, nameText.Font, nameText.Rect.Width);
|
||||
nameText.Text = ToolBox.LimitString(nameText.Text, nameText.Font, (int)(nameText.Rect.Width * 0.95f));
|
||||
|
||||
if (selectedClient.SteamID != 0 && Steam.SteamManager.IsInitialized)
|
||||
if (hasManagePermissions)
|
||||
{
|
||||
var viewSteamProfileButton = new GUIButton(new RectTransform(new Vector2(0.4f, 1.0f), headerContainer.RectTransform, Anchor.TopCenter) { MaxSize = new Point(int.MaxValue, (int)(40 * GUI.Scale)) },
|
||||
TextManager.Get("ViewSteamProfile"))
|
||||
{
|
||||
UserData = selectedClient
|
||||
};
|
||||
viewSteamProfileButton.TextBlock.AutoScaleHorizontal = true;
|
||||
viewSteamProfileButton.OnClicked = (bt, userdata) =>
|
||||
{
|
||||
Steamworks.SteamFriends.OpenWebOverlay("https://steamcommunity.com/profiles/" + selectedClient.SteamID.ToString());
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
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);
|
||||
@@ -1965,11 +1999,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;
|
||||
@@ -2005,7 +2039,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)
|
||||
{
|
||||
@@ -2038,7 +2072,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)
|
||||
@@ -2072,7 +2106,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)
|
||||
{
|
||||
@@ -2105,7 +2139,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)
|
||||
{
|
||||
@@ -2125,7 +2159,7 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
var buttonAreaTop = myClient ? null : new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.08f), paddedPlayerFrame.RectTransform), isHorizontal: true);
|
||||
var buttonAreaLower = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.08f), paddedPlayerFrame.RectTransform), isHorizontal: true);
|
||||
var buttonAreaLower = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.08f), paddedPlayerFrame.RectTransform), isHorizontal: true, childAnchor: Anchor.CenterLeft);
|
||||
|
||||
if (!myClient)
|
||||
{
|
||||
@@ -2173,32 +2207,66 @@ namespace Barotrauma
|
||||
kickButton.OnClicked += ClosePlayerFrame;
|
||||
}
|
||||
|
||||
GUITextBlock.AutoScaleAndNormalize(
|
||||
buttonAreaTop.Children.Select(c => ((GUIButton)c).TextBlock).Concat(buttonAreaLower.Children.Select(c => ((GUIButton)c).TextBlock)));
|
||||
if (buttonAreaTop.CountChildren > 0)
|
||||
{
|
||||
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),
|
||||
new GUITickBox(new RectTransform(new Vector2(0.175f, 1.0f), headerContainer.RectTransform, Anchor.TopRight),
|
||||
TextManager.Get("Mute"))
|
||||
{
|
||||
IgnoreLayoutGroups = true,
|
||||
Selected = selectedClient.MutedLocally,
|
||||
OnSelected = (tickBox) => { selectedClient.MutedLocally = tickBox.Selected; return true; }
|
||||
};
|
||||
}
|
||||
|
||||
var closeButton = new GUIButton(new RectTransform(new Vector2(0.3f, 1.0f), buttonAreaLower.RectTransform, Anchor.TopRight),
|
||||
if (selectedClient.SteamID != 0 && Steam.SteamManager.IsInitialized)
|
||||
{
|
||||
var viewSteamProfileButton = new GUIButton(new RectTransform(new Vector2(0.3f, 1.0f), headerContainer.RectTransform, Anchor.TopCenter) { MaxSize = new Point(int.MaxValue, (int)(40 * GUI.Scale)) },
|
||||
TextManager.Get("ViewSteamProfile"))
|
||||
{
|
||||
UserData = selectedClient
|
||||
};
|
||||
viewSteamProfileButton.TextBlock.AutoScaleHorizontal = true;
|
||||
viewSteamProfileButton.OnClicked = (bt, userdata) =>
|
||||
{
|
||||
Steamworks.SteamFriends.OpenWebOverlay("https://steamcommunity.com/profiles/" + selectedClient.SteamID.ToString());
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
var closeButton = new GUIButton(new RectTransform(new Vector2(0f, 1.0f), buttonAreaLower.RectTransform, Anchor.CenterRight),
|
||||
TextManager.Get("Close"))
|
||||
{
|
||||
IgnoreLayoutGroups = true,
|
||||
OnClicked = ClosePlayerFrame
|
||||
};
|
||||
|
||||
float xSize = 1f / buttonAreaLower.CountChildren;
|
||||
for (int i = 0; i < buttonAreaLower.CountChildren; i++)
|
||||
{
|
||||
buttonAreaLower.GetChild(i).RectTransform.RelativeSize = new Vector2(xSize, 1f);
|
||||
}
|
||||
|
||||
buttonAreaLower.RectTransform.NonScaledSize = new Point(buttonAreaLower.Rect.Width, buttonAreaLower.RectTransform.Children.Max(c => c.NonScaledSize.Y));
|
||||
|
||||
if (buttonAreaTop != null)
|
||||
{
|
||||
buttonAreaTop.RectTransform.NonScaledSize =
|
||||
buttonAreaLower.RectTransform.NonScaledSize =
|
||||
new Point(buttonAreaLower.Rect.Width, Math.Max(buttonAreaLower.RectTransform.NonScaledSize.Y, buttonAreaTop.RectTransform.Children.Max(c => c.NonScaledSize.Y)));
|
||||
if (buttonAreaTop.CountChildren == 0)
|
||||
{
|
||||
paddedPlayerFrame.RemoveChild(buttonAreaTop);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < buttonAreaTop.CountChildren; i++)
|
||||
{
|
||||
buttonAreaTop.GetChild(i).RectTransform.RelativeSize = new Vector2(1f / 3f, 1f);
|
||||
}
|
||||
|
||||
buttonAreaTop.RectTransform.NonScaledSize =
|
||||
buttonAreaLower.RectTransform.NonScaledSize =
|
||||
new Point(buttonAreaLower.Rect.Width, Math.Max(buttonAreaLower.RectTransform.NonScaledSize.Y, buttonAreaTop.RectTransform.Children.Max(c => c.NonScaledSize.Y)));
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -2206,7 +2274,7 @@ namespace Barotrauma
|
||||
|
||||
private bool ClosePlayerFrame(GUIButton button, object userData)
|
||||
{
|
||||
playerFrame = null;
|
||||
PlayerFrame = null;
|
||||
playerList.Deselect();
|
||||
return true;
|
||||
}
|
||||
@@ -2233,9 +2301,8 @@ namespace Barotrauma
|
||||
{
|
||||
base.AddToGUIUpdateList();
|
||||
|
||||
playerFrame?.AddToGUIUpdateList();
|
||||
//CampaignSetupUI?.AddToGUIUpdateList();
|
||||
jobInfoFrame?.AddToGUIUpdateList();
|
||||
JobInfoFrame?.AddToGUIUpdateList();
|
||||
|
||||
HeadSelectionList?.AddToGUIUpdateList();
|
||||
JobSelectionFrame?.AddToGUIUpdateList();
|
||||
@@ -2532,6 +2599,7 @@ namespace Barotrauma
|
||||
StepValue = 1,
|
||||
BarScrollValue = info.HairIndex,
|
||||
OnMoved = SwitchHair,
|
||||
OnReleased = SaveHead,
|
||||
BarSize = 1.0f / (float)(hairCount + 1)
|
||||
};
|
||||
}
|
||||
@@ -2546,6 +2614,7 @@ namespace Barotrauma
|
||||
StepValue = 1,
|
||||
BarScrollValue = info.BeardIndex,
|
||||
OnMoved = SwitchBeard,
|
||||
OnReleased = SaveHead,
|
||||
BarSize = 1.0f / (float)(beardCount + 1)
|
||||
};
|
||||
}
|
||||
@@ -2560,6 +2629,7 @@ namespace Barotrauma
|
||||
StepValue = 1,
|
||||
BarScrollValue = info.MoustacheIndex,
|
||||
OnMoved = SwitchMoustache,
|
||||
OnReleased = SaveHead,
|
||||
BarSize = 1.0f / (float)(moustacheCount + 1)
|
||||
};
|
||||
}
|
||||
@@ -2574,6 +2644,7 @@ namespace Barotrauma
|
||||
StepValue = 1,
|
||||
BarScrollValue = info.FaceAttachmentIndex,
|
||||
OnMoved = SwitchFaceAttachment,
|
||||
OnReleased = SaveHead,
|
||||
BarSize = 1.0f / (float)(faceAttachmentCount + 1)
|
||||
};
|
||||
}
|
||||
@@ -2881,7 +2952,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,
|
||||
@@ -2910,7 +2981,7 @@ namespace Barotrauma
|
||||
info.Head = new CharacterInfo.HeadInfo(id, gender, race);
|
||||
info.ReloadHeadAttachments();
|
||||
}
|
||||
StoreHead();
|
||||
StoreHead(true);
|
||||
|
||||
UpdateJobPreferences(JobList);
|
||||
|
||||
@@ -2918,7 +2989,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);
|
||||
@@ -2946,14 +3018,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;
|
||||
@@ -2961,8 +3034,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; }
|
||||
@@ -3026,7 +3113,7 @@ namespace Barotrauma
|
||||
StartRound = () =>
|
||||
{
|
||||
GameMain.Client.RequestStartRound();
|
||||
CoroutineManager.StartCoroutine(WaitForStartRound(campaignUI.StartButton, allowCancel: true), "WaitForStartRound");
|
||||
CoroutineManager.StartCoroutine(WaitForStartRound(campaignUI.StartButton), "WaitForStartRound");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -3085,20 +3172,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;
|
||||
}
|
||||
|
||||
@@ -3192,8 +3279,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();
|
||||
}
|
||||
@@ -3238,7 +3331,8 @@ namespace Barotrauma
|
||||
{
|
||||
CreateSubPreview(sub);
|
||||
}
|
||||
if (subList.SelectedData is SubmarineInfo selectedSub && selectedSub.MD5Hash?.Hash == md5Hash && System.IO.File.Exists(sub.FilePath))
|
||||
|
||||
if (subList.SelectedData is SubmarineInfo selectedSub && selectedSub.MD5Hash?.Hash == md5Hash && Barotrauma.IO.File.Exists(sub.FilePath))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -4,9 +4,14 @@ using Barotrauma.Particles;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Xml.Linq;
|
||||
using System.Xml;
|
||||
using System.Text;
|
||||
using Barotrauma.Extensions;
|
||||
#if DEBUG
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
#else
|
||||
using Barotrauma.IO;
|
||||
#endif
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
@@ -242,7 +247,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
XmlWriterSettings settings = new XmlWriterSettings
|
||||
System.Xml.XmlWriterSettings settings = new System.Xml.XmlWriterSettings
|
||||
{
|
||||
Indent = true,
|
||||
OmitXmlDeclaration = true,
|
||||
@@ -260,27 +265,49 @@ namespace Barotrauma
|
||||
private void SerializeToClipboard(ParticlePrefab prefab)
|
||||
{
|
||||
#if WINDOWS
|
||||
if (prefab == null) return;
|
||||
if (prefab == null) { return; }
|
||||
|
||||
XmlWriterSettings settings = new XmlWriterSettings
|
||||
System.Xml.XmlWriterSettings settings = new System.Xml.XmlWriterSettings
|
||||
{
|
||||
Indent = true,
|
||||
OmitXmlDeclaration = true,
|
||||
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))
|
||||
using (var writer = System.Xml.XmlWriter.Create(sb, settings))
|
||||
{
|
||||
element.WriteTo(writer);
|
||||
originalElement.WriteTo(writer);
|
||||
writer.Flush();
|
||||
}
|
||||
|
||||
Clipboard.SetText(sb.ToString());
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
public override void Update(double deltaTime)
|
||||
|
||||
@@ -14,10 +14,11 @@ namespace Barotrauma
|
||||
{
|
||||
if (frame == null)
|
||||
{
|
||||
frame = new GUIFrame(new RectTransform(Vector2.One, GUICanvas.Instance), style: null)
|
||||
frame = new GUIFrame(new RectTransform(GUICanvas.Instance.RelativeSize, GUICanvas.Instance), style: null)
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
|
||||
}
|
||||
return frame;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ using Microsoft.Xna.Framework.Graphics;
|
||||
using RestSharp;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Barotrauma.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.NetworkInformation;
|
||||
@@ -422,7 +422,7 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
// Game mode Selection
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), filters.Content.RectTransform), TextManager.Get("gamemode")) { CanBeFocused = false };
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), filters.Content.RectTransform), TextManager.Get("gamemode"), font: GUI.SubHeadingFont) { CanBeFocused = false };
|
||||
|
||||
gameModeTickBoxes = new List<GUITickBox>();
|
||||
foreach (GameModePreset mode in GameModePreset.List)
|
||||
@@ -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),
|
||||
@@ -672,7 +683,21 @@ namespace Barotrauma
|
||||
if (!File.Exists(file)) { return; }
|
||||
|
||||
XDocument doc = XMLExtensions.TryLoadXml(file);
|
||||
if (doc == null) { return; }
|
||||
if (doc == null)
|
||||
{
|
||||
DebugConsole.NewMessage("Failed to load file \"" + file + "\". Attempting to recreate the file...");
|
||||
try
|
||||
{
|
||||
doc = new XDocument(new XElement("servers"));
|
||||
doc.Save(file);
|
||||
DebugConsole.NewMessage("Recreated \"" + file + "\".");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DebugConsole.ThrowError("Failed to recreate the file \"" + file + "\".", e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (XElement element in doc.Root.Elements())
|
||||
{
|
||||
@@ -694,7 +719,7 @@ namespace Barotrauma
|
||||
rootElement.Add(info.ToXElement());
|
||||
}
|
||||
|
||||
doc.Save(file);
|
||||
doc.SaveSafe(file);
|
||||
}
|
||||
|
||||
public ServerInfo UpdateServerInfoWithServerSettings(object endpoint, ServerSettings serverSettings)
|
||||
@@ -909,6 +934,12 @@ namespace Barotrauma
|
||||
|
||||
Steamworks.SteamMatchmaking.ResetActions();
|
||||
|
||||
if (GameMain.Client != null)
|
||||
{
|
||||
GameMain.Client.Disconnect();
|
||||
GameMain.Client = null;
|
||||
}
|
||||
|
||||
RefreshServers();
|
||||
}
|
||||
|
||||
@@ -996,7 +1027,7 @@ namespace Barotrauma
|
||||
foreach (GUITickBox tickBox in gameModeTickBoxes)
|
||||
{
|
||||
var gameMode = (string)tickBox.UserData;
|
||||
if (!tickBox.Selected && serverInfo.GameMode.Equals(gameMode, StringComparison.OrdinalIgnoreCase))
|
||||
if (!tickBox.Selected && serverInfo.GameMode != null && serverInfo.GameMode.Equals(gameMode, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
child.Visible = false;
|
||||
break;
|
||||
@@ -1653,7 +1684,7 @@ namespace Barotrauma
|
||||
{
|
||||
CanBeFocused = false,
|
||||
Selected =
|
||||
serverInfo.GameVersion == GameMain.Version.ToString() &&
|
||||
(NetworkMember.IsCompatible(GameMain.Version.ToString(), serverInfo.GameVersion) ?? true) &&
|
||||
serverInfo.ContentPackagesMatch(GameMain.SelectedPackages),
|
||||
UserData = "compatible"
|
||||
};
|
||||
@@ -1679,6 +1710,14 @@ namespace Barotrauma
|
||||
serverName.Text = ToolBox.LimitString(serverName.Text, serverName.Font, serverName.Rect.Width);
|
||||
};
|
||||
|
||||
if (serverInfo.ContentPackageNames.Any())
|
||||
{
|
||||
if (serverInfo.ContentPackageNames.Any(cp => !cp.Equals(GameMain.VanillaContent.Name, StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
serverName.TextColor = new Color(219, 125, 217);
|
||||
}
|
||||
}
|
||||
|
||||
new GUITickBox(new RectTransform(new Vector2(columnRelativeWidth[3], 0.9f), serverContent.RectTransform, Anchor.Center), label: "")
|
||||
{
|
||||
ToolTip = TextManager.Get((serverInfo.GameStarted) ? "ServerListRoundStarted" : "ServerListRoundNotStarted"),
|
||||
@@ -1897,6 +1936,8 @@ namespace Barotrauma
|
||||
if (string.IsNullOrWhiteSpace(ClientNameBox.Text))
|
||||
{
|
||||
ClientNameBox.Flash();
|
||||
ClientNameBox.Select();
|
||||
GUI.PlayUISound(GUISoundType.PickItemFail);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,10 +3,14 @@ using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using Barotrauma.Extensions;
|
||||
#if DEBUG
|
||||
using System.IO;
|
||||
#else
|
||||
using Barotrauma.IO;
|
||||
#endif
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
@@ -196,8 +200,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 +245,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))
|
||||
@@ -413,7 +419,11 @@ namespace Barotrauma
|
||||
{
|
||||
string xmlPath = doc.ParseContentPathFromUri();
|
||||
xmlPathText.Text += "\n" + xmlPath;
|
||||
#if DEBUG
|
||||
doc.Save(xmlPath);
|
||||
#else
|
||||
doc.SaveSafe(xmlPath);
|
||||
#endif
|
||||
}
|
||||
xmlPathText.TextColor = GUI.Style.Green;
|
||||
return true;
|
||||
|
||||
@@ -4,7 +4,7 @@ using Microsoft.Xna.Framework.Graphics;
|
||||
using RestSharp;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Barotrauma.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@@ -26,7 +26,7 @@ namespace Barotrauma
|
||||
//listbox that shows the files included in the item being created
|
||||
private GUIListBox createItemFileList;
|
||||
|
||||
private FileSystemWatcher createItemWatcher;
|
||||
private System.IO.FileSystemWatcher createItemWatcher;
|
||||
|
||||
private readonly List<GUIButton> tabButtons = new List<GUIButton>();
|
||||
|
||||
@@ -135,6 +135,8 @@ namespace Barotrauma
|
||||
}
|
||||
};
|
||||
|
||||
CreateFilterBox(modsContainer, subscribedItemList);
|
||||
|
||||
modsPreviewFrame = new GUIFrame(new RectTransform(new Vector2(0.6f, 1.0f), tabs[(int)Tab.Mods].RectTransform, Anchor.TopRight), style: null);
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
@@ -163,6 +165,8 @@ namespace Barotrauma
|
||||
}
|
||||
};
|
||||
|
||||
CreateFilterBox(listContainer, topItemList);
|
||||
|
||||
new GUIButton(new RectTransform(new Vector2(1.0f, 0.02f), listContainer.RectTransform), TextManager.Get("FindModsButton"), style: "GUIButtonSmall")
|
||||
{
|
||||
OnClicked = (btn, userdata) =>
|
||||
@@ -235,6 +239,29 @@ namespace Barotrauma
|
||||
subscribedCoroutine = CoroutineManager.StartCoroutine(PollSubscribedItems());
|
||||
}
|
||||
|
||||
private void CreateFilterBox(GUIComponent parent, GUIListBox listbox)
|
||||
{
|
||||
var filterContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.05f), parent.RectTransform), isHorizontal: true)
|
||||
{
|
||||
Stretch = true
|
||||
};
|
||||
filterContainer.RectTransform.SetAsFirstChild();
|
||||
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) =>
|
||||
{
|
||||
foreach (GUIComponent child in listbox.Content.Children)
|
||||
{
|
||||
if (!(child.UserData is Steamworks.Ugc.Item item)) { continue; }
|
||||
child.Visible = string.IsNullOrEmpty(text) ? true : (item.Title?.ToLower().Contains(text.ToLower()) ?? false);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
public override void Select()
|
||||
{
|
||||
base.Select();
|
||||
@@ -414,6 +441,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);
|
||||
@@ -582,14 +610,12 @@ namespace Barotrauma
|
||||
}
|
||||
else
|
||||
{
|
||||
installed = SteamManager.EnableWorkShopItem(item, true, out string errorMsg, Screen.Selected == this);
|
||||
|
||||
installed = SteamManager.EnableWorkShopItem(item, out string errorMsg, Selected == this);
|
||||
if (!installed)
|
||||
{
|
||||
DebugConsole.ThrowError(errorMsg);
|
||||
new GUIMessageBox(
|
||||
TextManager.Get("Error"),
|
||||
TextManager.GetWithVariables("WorkshopItemUpdateFailed", new string[2] { "[itemname]", "[errormessage]" }, new string[2] { TextManager.EnsureUTF8(item?.Title), 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 });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -602,10 +628,9 @@ namespace Barotrauma
|
||||
{
|
||||
if (!SteamManager.UpdateWorkshopItem(item, out string errorMsg))
|
||||
{
|
||||
DebugConsole.ThrowError(errorMsg);
|
||||
new GUIMessageBox(
|
||||
TextManager.Get("Error"),
|
||||
TextManager.GetWithVariables("WorkshopItemUpdateFailed", new string[2] { "[itemname]", "[errormessage]" }, new string[2] { TextManager.EnsureUTF8(item?.Title), 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 });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -645,7 +670,7 @@ namespace Barotrauma
|
||||
{
|
||||
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))
|
||||
!SteamManager.EnableWorkShopItem(item, out errorMsg, reselect, true))
|
||||
{
|
||||
DebugConsole.ThrowError($"Failed to reinstall \"{item?.Title}\": {errorMsg}", null, true);
|
||||
elem.Flash(GUI.Style.Red);
|
||||
@@ -839,7 +864,7 @@ namespace Barotrauma
|
||||
|
||||
item?.Download(onInstalled: () =>
|
||||
{
|
||||
if (SteamManager.EnableWorkShopItem(item, false, out _))
|
||||
if (SteamManager.EnableWorkShopItem(item, out _))
|
||||
{
|
||||
textBlock.Text = TextManager.Get("workshopiteminstalled");
|
||||
frame.Flash(GUI.Style.Green);
|
||||
@@ -1012,7 +1037,7 @@ namespace Barotrauma
|
||||
|
||||
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);
|
||||
|
||||
@@ -1040,7 +1065,7 @@ namespace Barotrauma
|
||||
string previewImagePath = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(itemContentPackage.Path), SteamManager.PreviewImageName));
|
||||
try
|
||||
{
|
||||
using (Stream s = File.Create(previewImagePath))
|
||||
using (System.IO.Stream s = File.Create(previewImagePath))
|
||||
{
|
||||
sub.PreviewImage.Texture.SaveAsPng(s, (int)sub.PreviewImage.size.X, (int)sub.PreviewImage.size.Y);
|
||||
itemEditor = itemEditor?.WithPreviewFile(previewImagePath);
|
||||
@@ -1292,10 +1317,10 @@ namespace Barotrauma
|
||||
};
|
||||
createItemFileList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.35f), createItemContent.RectTransform));
|
||||
createItemWatcher?.Dispose();
|
||||
createItemWatcher = new FileSystemWatcher(Path.GetDirectoryName(itemContentPackage.Path))
|
||||
createItemWatcher = new System.IO.FileSystemWatcher(Path.GetDirectoryName(itemContentPackage.Path))
|
||||
{
|
||||
Filter = "*",
|
||||
NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName
|
||||
NotifyFilter = System.IO.NotifyFilters.LastWrite | System.IO.NotifyFilters.FileName | System.IO.NotifyFilters.DirectoryName
|
||||
};
|
||||
createItemWatcher.Created += OnFileSystemChanges;
|
||||
createItemWatcher.Deleted += OnFileSystemChanges;
|
||||
@@ -1553,7 +1578,7 @@ namespace Barotrauma
|
||||
|
||||
volatile bool refreshFileList = false;
|
||||
|
||||
private void OnFileSystemChanges(object sender, FileSystemEventArgs e)
|
||||
private void OnFileSystemChanges(object sender, System.IO.FileSystemEventArgs e)
|
||||
{
|
||||
refreshFileList = true;
|
||||
}
|
||||
@@ -1566,14 +1591,26 @@ namespace Barotrauma
|
||||
|
||||
List<ContentFile> files = itemContentPackage.Files.ToList();
|
||||
|
||||
foreach (ContentFile contentFile in files)
|
||||
for (int i = files.Count - 1; i >= 0; i--)
|
||||
{
|
||||
ContentFile contentFile = files[i];
|
||||
|
||||
bool fileExists = File.Exists(contentFile.Path);
|
||||
|
||||
if (!fileExists) { itemContentPackage.Files.Remove(contentFile); continue; }
|
||||
if (contentFile.Type == ContentType.Executable ||
|
||||
contentFile.Type == ContentType.ServerExecutable)
|
||||
{
|
||||
fileExists |= File.Exists(contentFile.Path + ".dll");
|
||||
}
|
||||
|
||||
if (!fileExists)
|
||||
{
|
||||
itemContentPackage.Files.Remove(contentFile);
|
||||
files.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
|
||||
List<ContentFile> allFiles = Directory.GetFiles(Path.GetDirectoryName(itemContentPackage.Path), "*", SearchOption.AllDirectories)
|
||||
List<ContentFile> allFiles = Directory.GetFiles(Path.GetDirectoryName(itemContentPackage.Path), "*", System.IO.SearchOption.AllDirectories)
|
||||
.Select(f => new ContentFile(f, ContentType.None))
|
||||
.Where(file => Path.GetFileName(file.Path) != SteamManager.MetadataFileName &&
|
||||
Path.GetFileName(file.Path) != SteamManager.PreviewImageName)
|
||||
@@ -1581,22 +1618,31 @@ namespace Barotrauma
|
||||
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));
|
||||
ContentFile otherFile = 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;
|
||||
files.Remove(otherFile);
|
||||
}
|
||||
}
|
||||
|
||||
allFiles.AddRange(files);
|
||||
|
||||
foreach (ContentFile contentFile in allFiles)
|
||||
{
|
||||
bool illegalPath = !ContentPackage.IsModFilePathAllowed(contentFile);
|
||||
bool fileExists = File.Exists(contentFile.Path);
|
||||
|
||||
if (contentFile.Type == ContentType.Executable ||
|
||||
contentFile.Type == ContentType.ServerExecutable)
|
||||
{
|
||||
fileExists |= File.Exists(contentFile.Path + ".dll");
|
||||
}
|
||||
|
||||
var fileFrame = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.12f), createItemFileList.Content.RectTransform) { MinSize = new Point(0, 20) },
|
||||
style: "ListBoxElement")
|
||||
{
|
||||
@@ -1664,36 +1710,39 @@ namespace Barotrauma
|
||||
return true;
|
||||
};
|
||||
|
||||
new GUIButton(new RectTransform(new Vector2(0.2f, 1.0f), content.RectTransform), TextManager.Get("Delete"), style: "GUIButtonSmall")
|
||||
if (!files.Contains(contentFile)) //this prevents deletion of files not contained in the mod's path (i.e. vanilla content)
|
||||
{
|
||||
OnClicked = (btn, userdata) =>
|
||||
new GUIButton(new RectTransform(new Vector2(0.2f, 1.0f), content.RectTransform), TextManager.Get("Delete"), style: "GUIButtonSmall")
|
||||
{
|
||||
var msgBox = new GUIMessageBox(TextManager.Get("ConfirmFileDeletionHeader"),
|
||||
TextManager.GetWithVariable("ConfirmFileDeletion", "[file]", contentFile.Path),
|
||||
new string[] { TextManager.Get("Yes"), TextManager.Get("Cancel") })
|
||||
OnClicked = (btn, userdata) =>
|
||||
{
|
||||
UserData = "verificationprompt"
|
||||
};
|
||||
msgBox.Buttons[0].OnClicked = (applyButton, obj) =>
|
||||
{
|
||||
try
|
||||
var msgBox = new GUIMessageBox(TextManager.Get("ConfirmFileDeletionHeader"),
|
||||
TextManager.GetWithVariable("ConfirmFileDeletion", "[file]", contentFile.Path),
|
||||
new string[] { TextManager.Get("Yes"), TextManager.Get("Cancel") })
|
||||
{
|
||||
File.Delete(contentFile.Path);
|
||||
if (contentFile.Type == ContentType.Submarine) { SubmarineInfo.RefreshSavedSub(contentFile.Path); }
|
||||
}
|
||||
catch (Exception e)
|
||||
UserData = "verificationprompt"
|
||||
};
|
||||
msgBox.Buttons[0].OnClicked = (applyButton, obj) =>
|
||||
{
|
||||
DebugConsole.ThrowError($"Failed to delete \"${contentFile.Path}\".", e);
|
||||
}
|
||||
//RefreshCreateItemFileList();
|
||||
RefreshMyItemList();
|
||||
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;
|
||||
};
|
||||
msgBox.Buttons[0].OnClicked += msgBox.Close;
|
||||
msgBox.Buttons[1].OnClicked = msgBox.Close;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
content.Recalculate();
|
||||
fileFrame.RectTransform.MinSize =
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user