Unstable 0.1400.0.0
This commit is contained in:
@@ -505,7 +505,7 @@ namespace Barotrauma
|
||||
missionName.CalculateHeightFromText();
|
||||
}
|
||||
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), missionTextContent.RectTransform), mission.GetMissionRewardText(), wrap: true, parseRichText: true);
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), missionTextContent.RectTransform), mission.GetMissionRewardText(Submarine.MainSub), wrap: true, parseRichText: true);
|
||||
|
||||
string reputationText = mission.GetReputationRewardText(mission.Locations[0]);
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), missionTextContent.RectTransform), reputationText, wrap: true, parseRichText: true);
|
||||
@@ -517,8 +517,9 @@ namespace Barotrauma
|
||||
{
|
||||
var textBlock = child as GUITextBlock;
|
||||
textBlock.Color = textBlock.SelectedColor = textBlock.HoverColor = Color.Transparent;
|
||||
textBlock.HoverTextColor = textBlock.TextColor;
|
||||
textBlock.SelectedTextColor = textBlock.TextColor;
|
||||
textBlock.TextColor *= 0.5f;
|
||||
textBlock.HoverTextColor = textBlock.TextColor;
|
||||
}
|
||||
missionPanel.OnAddedToGUIUpdateList = (c) =>
|
||||
{
|
||||
|
||||
+1
-1
@@ -4731,7 +4731,7 @@ namespace Barotrauma.CharacterEditor
|
||||
rotation: 0,
|
||||
origin: orig,
|
||||
sourceRectangle: wearable.InheritSourceRect ? limb.ActiveSprite.SourceRect : wearable.Sprite.SourceRect,
|
||||
scale: (wearable.InheritTextureScale ? 1 : 1 / RagdollParams.TextureScale) * spriteSheetZoom,
|
||||
scale: (wearable.InheritTextureScale ? 1 : wearable.Scale / RagdollParams.TextureScale) * spriteSheetZoom,
|
||||
effects: SpriteEffects.None,
|
||||
color: Color.White,
|
||||
layerDepth: 0);
|
||||
|
||||
@@ -305,7 +305,7 @@ namespace Barotrauma.CharacterEditor
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.3f, 1), mainElement.RectTransform, Anchor.CenterLeft), TextManager.Get("ContentPackage"));
|
||||
var rightContainer = new GUIFrame(new RectTransform(new Vector2(0.7f, 1), mainElement.RectTransform, Anchor.CenterRight), style: null);
|
||||
contentPackageDropDown = new GUIDropDown(new RectTransform(new Vector2(1.0f, 0.5f), rightContainer.RectTransform, Anchor.TopRight));
|
||||
foreach (ContentPackage cp in ContentPackage.AllPackages)
|
||||
foreach (ContentPackage cp in GameMain.Config.AllEnabledPackages)
|
||||
{
|
||||
#if !DEBUG
|
||||
if (cp == GameMain.VanillaContent) { continue; }
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
class EditorScreen : Screen
|
||||
{
|
||||
public static Color BackgroundColor = GameSettings.SubEditorBackgroundColor;
|
||||
|
||||
public void CreateBackgroundColorPicker()
|
||||
{
|
||||
var msgBox = new GUIMessageBox(TextManager.Get("CharacterEditor.EditBackgroundColor"), "", new[] { TextManager.Get("Reset"), TextManager.Get("OK")}, new Vector2(0.2f, 0.175f), minSize: new Point(300, 175));
|
||||
|
||||
var rgbLayout = new GUILayoutGroup(new RectTransform(new Vector2(1f, 0.25f), msgBox.Content.RectTransform), isHorizontal: true);
|
||||
|
||||
// Generate R,G,B labels and parent elements
|
||||
var layoutParents = new GUILayoutGroup[3];
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
var colorContainer = new GUILayoutGroup(new RectTransform(new Vector2(0.33f, 1), rgbLayout.RectTransform), isHorizontal: true) { Stretch = true };
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.2f, 1), colorContainer.RectTransform, Anchor.CenterLeft) { MinSize = new Point(15, 0) }, GUI.colorComponentLabels[i], font: GUI.SmallFont, textAlignment: Alignment.Center);
|
||||
layoutParents[i] = colorContainer;
|
||||
}
|
||||
|
||||
// attach number inputs to our generated parent elements
|
||||
var rInput = new GUINumberInput(new RectTransform(new Vector2(0.7f, 1f), layoutParents[0].RectTransform), GUINumberInput.NumberType.Int) { IntValue = BackgroundColor.R };
|
||||
var gInput = new GUINumberInput(new RectTransform(new Vector2(0.7f, 1f), layoutParents[1].RectTransform), GUINumberInput.NumberType.Int) { IntValue = BackgroundColor.G };
|
||||
var bInput = new GUINumberInput(new RectTransform(new Vector2(0.7f, 1f), layoutParents[2].RectTransform), GUINumberInput.NumberType.Int) { IntValue = BackgroundColor.B };
|
||||
|
||||
rInput.MinValueInt = gInput.MinValueInt = bInput.MinValueInt = 0;
|
||||
rInput.MaxValueInt = gInput.MaxValueInt = bInput.MaxValueInt = 255;
|
||||
|
||||
rInput.OnValueChanged = gInput.OnValueChanged = bInput.OnValueChanged = delegate
|
||||
{
|
||||
var color = new Color(rInput.IntValue, gInput.IntValue, bInput.IntValue);
|
||||
BackgroundColor = color;
|
||||
GameSettings.SubEditorBackgroundColor = color;
|
||||
};
|
||||
|
||||
// Reset button
|
||||
msgBox.Buttons[0].OnClicked = (button, o) =>
|
||||
{
|
||||
rInput.IntValue = 13;
|
||||
gInput.IntValue = 37;
|
||||
bInput.IntValue = 69;
|
||||
return true;
|
||||
};
|
||||
|
||||
// Ok button
|
||||
msgBox.Buttons[1].OnClicked = (button, o) =>
|
||||
{
|
||||
msgBox.Close();
|
||||
GameMain.Config.SaveNewPlayerConfig();
|
||||
return true;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -227,7 +227,7 @@ namespace Barotrauma
|
||||
public static GUIMessageBox AskForConfirmation(string header, string body, Func<bool> onConfirm)
|
||||
{
|
||||
string[] buttons = { TextManager.Get("Ok"), TextManager.Get("Cancel") };
|
||||
GUIMessageBox msgBox = new GUIMessageBox(header, body, buttons, new Vector2(0.2f, 0.175f), minSize: new Point(300, 175));
|
||||
GUIMessageBox msgBox = new GUIMessageBox(header, body, buttons);
|
||||
|
||||
// Cancel button
|
||||
msgBox.Buttons[1].OnClicked = delegate
|
||||
|
||||
@@ -364,13 +364,15 @@ namespace Barotrauma
|
||||
Quad.Render();
|
||||
}
|
||||
|
||||
float grainStrength = Character.Controlled?.GrainStrength ?? 0;
|
||||
if (grainStrength > 0)
|
||||
if (Character.Controlled is { } character)
|
||||
{
|
||||
float grainStrength = character.GrainStrength;
|
||||
Rectangle screenRect = new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight);
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, effect: GrainEffect);
|
||||
GUI.DrawRectangle(spriteBatch, screenRect, Color.White * grainStrength, isFilled: true);
|
||||
GUI.DrawRectangle(spriteBatch, screenRect, Color.White, isFilled: true);
|
||||
GrainEffect.Parameters["seed"].SetValue(Rand.Range(0f, 1f, Rand.RandSync.Unsynced));
|
||||
GrainEffect.Parameters["intensity"].SetValue(grainStrength);
|
||||
GrainEffect.Parameters["grainColor"].SetValue(character.GrainColor.ToVector4());
|
||||
spriteBatch.End();
|
||||
}
|
||||
|
||||
|
||||
@@ -929,7 +929,7 @@ namespace Barotrauma
|
||||
}
|
||||
};
|
||||
QuitCampaignButton = new GUIButton(new RectTransform(new Vector2(1.0f, 0.3f), campaignContent.RectTransform),
|
||||
TextManager.Get("pausemenusavequit"), textAlignment: Alignment.Center)
|
||||
TextManager.Get("quitbutton"), textAlignment: Alignment.Center)
|
||||
{
|
||||
OnClicked = (_, __) =>
|
||||
{
|
||||
@@ -1322,7 +1322,7 @@ namespace Barotrauma
|
||||
roundControlsHolder.Children.ForEach(c => c.IgnoreLayoutGroups = !c.Visible);
|
||||
roundControlsHolder.Recalculate();
|
||||
|
||||
ReadyToStartBox.Parent.Visible = !GameMain.Client.GameStarted && SelectedMode != GameModePreset.MultiPlayerCampaign;
|
||||
ReadyToStartBox.Parent.Visible = !GameMain.Client.GameStarted;
|
||||
|
||||
RefreshGameModeContent();
|
||||
}
|
||||
@@ -3269,7 +3269,7 @@ namespace Barotrauma
|
||||
CampaignFrame.Visible = CampaignSetupFrame.Visible = false;
|
||||
}
|
||||
|
||||
ReadyToStartBox.Parent.Visible = !GameMain.Client.GameStarted && SelectedMode != GameModePreset.MultiPlayerCampaign;
|
||||
ReadyToStartBox.Parent.Visible = !GameMain.Client.GameStarted;
|
||||
|
||||
StartButton.Visible =
|
||||
GameMain.Client.HasPermission(ClientPermissions.ManageRound) &&
|
||||
|
||||
@@ -6,6 +6,7 @@ using System.Collections.Generic;
|
||||
using System.Xml.Linq;
|
||||
using System.Text;
|
||||
using Barotrauma.Extensions;
|
||||
using FarseerPhysics;
|
||||
#if DEBUG
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
@@ -15,7 +16,7 @@ using Barotrauma.IO;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
class ParticleEditorScreen : Screen
|
||||
class ParticleEditorScreen : EditorScreen
|
||||
{
|
||||
class Emitter : ISerializableEntity
|
||||
{
|
||||
@@ -23,22 +24,22 @@ namespace Barotrauma
|
||||
|
||||
public float BurstTimer;
|
||||
|
||||
[Editable(), Serialize("0.0,360.0", false)]
|
||||
[Editable, Serialize("0.0,360.0", false)]
|
||||
public Vector2 AngleRange { get; private set; }
|
||||
|
||||
[Editable(), Serialize("0.0,0.0", false)]
|
||||
[Editable, Serialize("0.0,0.0", false)]
|
||||
public Vector2 VelocityRange { get; private set; }
|
||||
|
||||
[Editable(), Serialize("1.0,1.0", false)]
|
||||
[Editable, Serialize("1.0,1.0", false)]
|
||||
public Vector2 ScaleRange { get; private set; }
|
||||
|
||||
[Editable(), Serialize(0, false)]
|
||||
[Editable, Serialize(0, false)]
|
||||
public int ParticleBurstAmount { get; private set; }
|
||||
|
||||
[Editable(), Serialize(1.0f, false)]
|
||||
[Editable, Serialize(1.0f, false)]
|
||||
public float ParticleBurstInterval { get; private set; }
|
||||
|
||||
[Editable(), Serialize(1.0f, false)]
|
||||
[Editable, Serialize(1.0f, false)]
|
||||
public float ParticlesPerSecond { get; private set; }
|
||||
|
||||
public string Name
|
||||
@@ -77,19 +78,24 @@ namespace Barotrauma
|
||||
|
||||
private readonly Camera cam;
|
||||
|
||||
public override Camera Cam
|
||||
{
|
||||
get
|
||||
{
|
||||
return cam;
|
||||
}
|
||||
}
|
||||
public override Camera Cam => cam;
|
||||
|
||||
private const string sizeRefFilePath = "Content/size_reference.png";
|
||||
private readonly Texture2D sizeReference;
|
||||
private Vector2 sizeRefPosition = Vector2.Zero;
|
||||
private readonly Vector2 sizeRefOrigin;
|
||||
private bool sizeRefEnabled;
|
||||
|
||||
public ParticleEditorScreen()
|
||||
{
|
||||
cam = new Camera();
|
||||
GameMain.Instance.ResolutionChanged += CreateUI;
|
||||
CreateUI();
|
||||
if (File.Exists(sizeRefFilePath))
|
||||
{
|
||||
sizeReference = TextureLoader.FromFile(sizeRefFilePath, compress: false);
|
||||
sizeRefOrigin = new Vector2(sizeReference.Width / 2f, sizeReference.Height / 2f);
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateUI()
|
||||
@@ -314,7 +320,17 @@ namespace Barotrauma
|
||||
public override void Update(double deltaTime)
|
||||
{
|
||||
cam.MoveCamera((float)deltaTime, allowMove: true, allowZoom: GUI.MouseOn == null);
|
||||
|
||||
|
||||
if (GUI.MouseOn is null && PlayerInput.PrimaryMouseButtonHeld())
|
||||
{
|
||||
sizeRefPosition = cam.ScreenToWorld(PlayerInput.MousePosition);
|
||||
}
|
||||
|
||||
if (PlayerInput.SecondaryMouseButtonClicked())
|
||||
{
|
||||
CreateContextMenu();
|
||||
}
|
||||
|
||||
if (selectedPrefab != null)
|
||||
{
|
||||
emitter.EmitTimer += (float)deltaTime;
|
||||
@@ -345,6 +361,15 @@ namespace Barotrauma
|
||||
GameMain.ParticleManager.Update((float)deltaTime);
|
||||
}
|
||||
|
||||
private void CreateContextMenu()
|
||||
{
|
||||
GUIContextMenu.CreateContextMenu
|
||||
(
|
||||
new ContextMenuOption("subeditor.editbackgroundcolor", true, CreateBackgroundColorPicker),
|
||||
new ContextMenuOption("editor.togglereferencecharacter", true, delegate { sizeRefEnabled = !sizeRefEnabled; })
|
||||
);
|
||||
}
|
||||
|
||||
public override void Draw(double deltaTime, GraphicsDevice graphics, SpriteBatch spriteBatch)
|
||||
{
|
||||
cam.UpdateTransform();
|
||||
@@ -357,7 +382,7 @@ namespace Barotrauma
|
||||
null, null, null, null,
|
||||
cam.Transform);
|
||||
|
||||
graphics.Clear(new Color(0.051f, 0.149f, 0.271f, 1.0f));
|
||||
graphics.Clear(BackgroundColor);
|
||||
|
||||
GameMain.ParticleManager.Draw(spriteBatch, false, false, ParticleBlendState.AlphaBlend);
|
||||
GameMain.ParticleManager.Draw(spriteBatch, true, false, ParticleBlendState.AlphaBlend);
|
||||
@@ -374,6 +399,20 @@ namespace Barotrauma
|
||||
|
||||
spriteBatch.End();
|
||||
|
||||
if (sizeRefEnabled && !(sizeReference is null))
|
||||
{
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred,
|
||||
BlendState.NonPremultiplied,
|
||||
null, null, null, null,
|
||||
cam.Transform);
|
||||
|
||||
Vector2 pos = sizeRefPosition;
|
||||
pos.Y = -pos.Y;
|
||||
spriteBatch.Draw(sizeReference, pos, null, Color.White, 0f, sizeRefOrigin, new Vector2(0.4f), SpriteEffects.None, 0f);
|
||||
|
||||
spriteBatch.End();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------
|
||||
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, null, GUI.SamplerState, null, GameMain.ScissorTestEnable);
|
||||
|
||||
@@ -66,6 +66,8 @@ namespace Barotrauma
|
||||
yield return CoroutineStatus.Success;
|
||||
}
|
||||
|
||||
public virtual void OnFileDropped(string filePath, string extension) { }
|
||||
|
||||
public virtual void Release()
|
||||
{
|
||||
frame.RectTransform.Parent = null;
|
||||
|
||||
@@ -363,7 +363,9 @@ namespace Barotrauma
|
||||
"VineSprite",
|
||||
"LeafSprite",
|
||||
"FlowerSprite",
|
||||
"DecorativeSprite"
|
||||
"DecorativeSprite",
|
||||
"BarrelSprite",
|
||||
"RailSprite"
|
||||
};
|
||||
|
||||
foreach (string spriteElementName in spriteElementNames)
|
||||
|
||||
@@ -26,6 +26,8 @@ namespace Barotrauma
|
||||
//listbox that shows the files included in the item being created
|
||||
private GUIListBox createItemFileList;
|
||||
|
||||
private GUIImage previewIcon;
|
||||
|
||||
private System.IO.FileSystemWatcher createItemWatcher;
|
||||
|
||||
private readonly List<GUIButton> tabButtons = new List<GUIButton>();
|
||||
@@ -277,6 +279,24 @@ namespace Barotrauma
|
||||
SelectTab(Tab.Mods);
|
||||
}
|
||||
|
||||
public override void OnFileDropped(string filePath, string extension)
|
||||
{
|
||||
switch (extension)
|
||||
{
|
||||
case ".png": // workshop preview
|
||||
case ".jpg":
|
||||
case ".jpeg":
|
||||
if (previewIcon == null || itemContentPackage == null) { break; }
|
||||
|
||||
OnPreviewImageSelected(previewIcon, filePath);
|
||||
break;
|
||||
|
||||
default:
|
||||
DebugConsole.ThrowError($"Could not drag and drop the file. \"{extension}\" is not a valid file extension! (expected .png, .jpg or .jpeg)");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnItemInstalled(ulong itemId)
|
||||
{
|
||||
RefreshSubscribedItems();
|
||||
@@ -1263,7 +1283,7 @@ namespace Barotrauma
|
||||
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), topLeftColumn.RectTransform), TextManager.Get("WorkshopItemPreviewImage"), font: GUI.SubHeadingFont);
|
||||
|
||||
var previewIcon = new GUIImage(new RectTransform(new Vector2(1.0f, 0.7f), topLeftColumn.RectTransform), SteamManager.DefaultPreviewImage, scaleToFit: true);
|
||||
previewIcon = new GUIImage(new RectTransform(new Vector2(1.0f, 0.7f), topLeftColumn.RectTransform), SteamManager.DefaultPreviewImage, scaleToFit: true);
|
||||
new GUIButton(new RectTransform(new Vector2(1.0f, 0.2f), topLeftColumn.RectTransform), TextManager.Get("WorkshopItemBrowse"), style: "GUIButtonSmall")
|
||||
{
|
||||
OnClicked = (btn, userdata) =>
|
||||
|
||||
@@ -19,7 +19,7 @@ using Barotrauma.IO;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
class SubEditorScreen : Screen
|
||||
class SubEditorScreen : EditorScreen
|
||||
{
|
||||
private static readonly string[] crewExperienceLevels =
|
||||
{
|
||||
@@ -177,8 +177,6 @@ namespace Barotrauma
|
||||
|
||||
private Mode mode;
|
||||
|
||||
private Color backgroundColor = GameSettings.SubEditorBackgroundColor;
|
||||
|
||||
private Vector2 MeasurePositionStart = Vector2.Zero;
|
||||
|
||||
// Prevent the mode from changing
|
||||
@@ -1007,6 +1005,12 @@ namespace Barotrauma
|
||||
string name = legacy ? TextManager.GetWithVariable("legacyitemformat", "[name]", ep.Name) : ep.Name;
|
||||
frame.ToolTip = string.IsNullOrEmpty(ep.Description) ? name : name + '\n' + ep.Description;
|
||||
|
||||
if (ep.ContentPackage != GameMain.VanillaContent && ep.ContentPackage != null)
|
||||
{
|
||||
frame.Color = Color.Magenta;
|
||||
string colorStr = XMLExtensions.ColorToString(Color.MediumPurple);
|
||||
frame.ToolTip += $"\n‖color:{colorStr}‖{ep.ContentPackage?.Name}‖color:end‖";
|
||||
}
|
||||
if (ep.HideInMenus)
|
||||
{
|
||||
frame.Color = Color.Red;
|
||||
@@ -1225,6 +1229,50 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnFileDropped(string filePath, string extension)
|
||||
{
|
||||
switch (extension)
|
||||
{
|
||||
case ".sub": // Submarine
|
||||
SubmarineInfo info = new SubmarineInfo(filePath);
|
||||
if (info.IsFileCorrupted)
|
||||
{
|
||||
DebugConsole.ThrowError($"Could not drag and drop the file. File \"{filePath}\" is corrupted!");
|
||||
info.Dispose();
|
||||
return;
|
||||
}
|
||||
|
||||
string body = TextManager.GetWithVariable("SubEditor.LoadConfirmBody", "[submarine]", info.Name);
|
||||
GUI.AskForConfirmation(TextManager.Get("Load"), body, onConfirm: () => LoadSub(info), onDeny: () => info.Dispose());
|
||||
break;
|
||||
|
||||
case ".xml": // Item Assembly
|
||||
string text = File.ReadAllText(filePath);
|
||||
// PlayerInput.MousePosition doesn't update while the window is not active so we need to use this method
|
||||
Vector2 mousePos = Mouse.GetState().Position.ToVector2();
|
||||
PasteAssembly(text, cam.ScreenToWorld(mousePos));
|
||||
break;
|
||||
|
||||
case ".png": // submarine preview
|
||||
case ".jpg":
|
||||
case ".jpeg":
|
||||
if (saveFrame == null) { break; }
|
||||
|
||||
Texture2D texture = Sprite.LoadTexture(filePath);
|
||||
previewImage.Sprite = new Sprite(texture, null, null);
|
||||
if (Submarine.MainSub != null)
|
||||
{
|
||||
Submarine.MainSub.Info.PreviewImage = previewImage.Sprite;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
DebugConsole.ThrowError($"Could not drag and drop the file. \"{extension}\" is not a valid file extension! (expected .xml, .sub, .png or .jpg)");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Coroutine that waits 5 minutes and then runs itself recursively again to save the submarine into a temporary file
|
||||
/// </summary>
|
||||
@@ -2020,30 +2068,27 @@ namespace Barotrauma
|
||||
Submarine.MainSub.Info.Price = Math.Max(Submarine.MainSub.Info.Price, basePrice);
|
||||
}
|
||||
|
||||
if (!Submarine.MainSub.Info.HasTag(SubmarineTag.Shuttle))
|
||||
var classGroup = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.25f), subSettingsContainer.RectTransform), isHorizontal: true)
|
||||
{
|
||||
var classGroup = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.25f), subSettingsContainer.RectTransform), isHorizontal: true)
|
||||
{
|
||||
Stretch = true
|
||||
};
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.6f, 1.0f), classGroup.RectTransform),
|
||||
TextManager.Get("submarineclass"), textAlignment: Alignment.CenterLeft, wrap: true);
|
||||
GUIDropDown classDropDown = new GUIDropDown(new RectTransform(new Vector2(0.4f, 1.0f), classGroup.RectTransform));
|
||||
classDropDown.RectTransform.MinSize = new Point(0, subTypeContainer.RectTransform.Children.Max(c => c.MinSize.Y));
|
||||
classDropDown.AddItem(TextManager.Get("submarineclass.undefined"), SubmarineClass.Undefined);
|
||||
classDropDown.AddItem(TextManager.Get("submarineclass.scout"), SubmarineClass.Scout);
|
||||
classDropDown.AddItem(TextManager.Get("submarineclass.attack"), SubmarineClass.Attack);
|
||||
classDropDown.AddItem(TextManager.Get("submarineclass.transport"), SubmarineClass.Transport);
|
||||
classDropDown.AddItem(TextManager.Get("submarineclass.deepdiver"), SubmarineClass.DeepDiver);
|
||||
classDropDown.OnSelected += (selected, userdata) =>
|
||||
{
|
||||
SubmarineClass submarineClass = (SubmarineClass)userdata;
|
||||
Submarine.MainSub.Info.SubmarineClass = submarineClass;
|
||||
return true;
|
||||
};
|
||||
|
||||
classDropDown.SelectItem(Submarine.MainSub.Info.SubmarineClass);
|
||||
}
|
||||
Stretch = true
|
||||
};
|
||||
var classText = new GUITextBlock(new RectTransform(new Vector2(0.6f, 1.0f), classGroup.RectTransform),
|
||||
TextManager.Get("submarineclass"), textAlignment: Alignment.CenterLeft, wrap: true);
|
||||
GUIDropDown classDropDown = new GUIDropDown(new RectTransform(new Vector2(0.4f, 1.0f), classGroup.RectTransform));
|
||||
classDropDown.RectTransform.MinSize = new Point(0, subTypeContainer.RectTransform.Children.Max(c => c.MinSize.Y));
|
||||
classDropDown.AddItem(TextManager.Get("submarineclass.undefined"), SubmarineClass.Undefined);
|
||||
classDropDown.AddItem(TextManager.Get("submarineclass.scout"), SubmarineClass.Scout);
|
||||
classDropDown.AddItem(TextManager.Get("submarineclass.attack"), SubmarineClass.Attack);
|
||||
classDropDown.AddItem(TextManager.Get("submarineclass.transport"), SubmarineClass.Transport);
|
||||
classDropDown.AddItem(TextManager.Get("submarineclass.deepdiver"), SubmarineClass.DeepDiver);
|
||||
classDropDown.OnSelected += (selected, userdata) =>
|
||||
{
|
||||
SubmarineClass submarineClass = (SubmarineClass)userdata;
|
||||
Submarine.MainSub.Info.SubmarineClass = submarineClass;
|
||||
return true;
|
||||
};
|
||||
classDropDown.SelectItem(Submarine.MainSub.Info.SubmarineClass);
|
||||
classText.Enabled = classDropDown.ButtonEnabled = !Submarine.MainSub.Info.HasTag(SubmarineTag.Shuttle);
|
||||
|
||||
var crewSizeArea = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.25f), subSettingsContainer.RectTransform), isHorizontal: true)
|
||||
{
|
||||
@@ -2216,17 +2261,29 @@ namespace Barotrauma
|
||||
{
|
||||
Selected = Submarine.MainSub != null && Submarine.MainSub.Info.HasTag(tag),
|
||||
UserData = tag,
|
||||
|
||||
OnSelected = (GUITickBox tickBox) =>
|
||||
{
|
||||
if (Submarine.MainSub == null) return false;
|
||||
SubmarineTag tag = (SubmarineTag)tickBox.UserData;
|
||||
if (tag == SubmarineTag.Shuttle)
|
||||
{
|
||||
if (tickBox.Selected)
|
||||
{
|
||||
classDropDown.SelectItem(SubmarineClass.Undefined);
|
||||
}
|
||||
else
|
||||
{
|
||||
classDropDown.SelectItem(Submarine.MainSub.Info.SubmarineClass);
|
||||
}
|
||||
classText.Enabled = classDropDown.ButtonEnabled = !tickBox.Selected;
|
||||
}
|
||||
if (tickBox.Selected)
|
||||
{
|
||||
Submarine.MainSub.Info.AddTag((SubmarineTag)tickBox.UserData);
|
||||
Submarine.MainSub.Info.AddTag(tag);
|
||||
}
|
||||
else
|
||||
{
|
||||
Submarine.MainSub.Info.RemoveTag((SubmarineTag)tickBox.UserData);
|
||||
Submarine.MainSub.Info.RemoveTag(tag);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -2305,7 +2362,6 @@ namespace Barotrauma
|
||||
if (quickSave) { SaveSub(saveButton, saveButton.UserData); }
|
||||
}
|
||||
|
||||
|
||||
private void CreateSaveAssemblyScreen()
|
||||
{
|
||||
SetMode(Mode.Default);
|
||||
@@ -2712,8 +2768,15 @@ namespace Barotrauma
|
||||
if (subList.SelectedComponent == null) { return false; }
|
||||
if (!(subList.SelectedComponent.UserData is SubmarineInfo selectedSubInfo)) { return false; }
|
||||
|
||||
LoadSub(selectedSubInfo);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void LoadSub(SubmarineInfo info)
|
||||
{
|
||||
Submarine.Unload();
|
||||
var selectedSub = new Submarine(selectedSubInfo);
|
||||
var selectedSub = new Submarine(info);
|
||||
Submarine.MainSub = selectedSub;
|
||||
Submarine.MainSub.UpdateTransform(interpolate: false);
|
||||
ClearUndoBuffer();
|
||||
@@ -2744,8 +2807,6 @@ namespace Barotrauma
|
||||
};
|
||||
adjustLightsPrompt.Buttons[1].OnClicked += adjustLightsPrompt.Close;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void TryDeleteSub(SubmarineInfo sub)
|
||||
@@ -2822,7 +2883,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(entityFilterBox.Text) || dummyCharacter?.SelectedConstruction?.OwnInventory != null)
|
||||
if (!string.IsNullOrEmpty(entityFilterBox.Text))
|
||||
{
|
||||
FilterEntities(entityFilterBox.Text);
|
||||
}
|
||||
@@ -2835,7 +2896,7 @@ namespace Barotrauma
|
||||
|
||||
private void FilterEntities(string filter)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(filter) && dummyCharacter?.SelectedConstruction?.OwnInventory == null)
|
||||
if (string.IsNullOrWhiteSpace(filter))
|
||||
{
|
||||
allEntityList.Visible = false;
|
||||
categorizedEntityList.Visible = true;
|
||||
@@ -2862,11 +2923,7 @@ namespace Barotrauma
|
||||
{
|
||||
child.Visible =
|
||||
(!selectedCategory.HasValue || ((MapEntityPrefab)child.UserData).Category.HasFlag(selectedCategory)) &&
|
||||
((MapEntityPrefab)child.UserData).Name.ToLower().Contains(filter); ;
|
||||
if (child.Visible && dummyCharacter?.SelectedConstruction?.OwnInventory != null)
|
||||
{
|
||||
child.Visible = child.UserData is MapEntityPrefab item && IsItemPrefab(item);
|
||||
}
|
||||
((MapEntityPrefab)child.UserData).Name.ToLower().Contains(filter);
|
||||
}
|
||||
allEntityList.UpdateScrollBarSize();
|
||||
allEntityList.BarScroll = 0.0f;
|
||||
@@ -2942,7 +2999,7 @@ namespace Barotrauma
|
||||
new ContextMenuOption("SubEditor.EditBackgroundColor", isEnabled: true, onSelected: CreateBackgroundColorPicker),
|
||||
new ContextMenuOption("SubEditor.ToggleTransparency", isEnabled: true, onSelected: () => TransparentWiringMode = !TransparentWiringMode),
|
||||
new ContextMenuOption("SubEditor.ToggleGrid", isEnabled: true, onSelected: () => ShouldDrawGrid = !ShouldDrawGrid),
|
||||
new ContextMenuOption("SubEditor.PasteAssembly", isEnabled: true, PasteAssembly),
|
||||
new ContextMenuOption("SubEditor.PasteAssembly", isEnabled: true, () => PasteAssembly()),
|
||||
new ContextMenuOption("Editor.SelectSame", isEnabled: targets.Count > 0, onSelected: delegate
|
||||
{
|
||||
IEnumerable<MapEntity> matching = MapEntity.mapEntityList.Where(e => e.prefab != null && targets.Any(t => t.prefab?.Identifier == e.prefab.Identifier) && !MapEntity.SelectedList.Contains(e));
|
||||
@@ -2973,10 +3030,11 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
private void PasteAssembly()
|
||||
private void PasteAssembly(string text = null, Vector2? pos = null)
|
||||
{
|
||||
string clipboard = Clipboard.GetText();
|
||||
if (string.IsNullOrWhiteSpace(clipboard))
|
||||
pos ??= cam.ScreenToWorld(PlayerInput.MousePosition);
|
||||
text ??= Clipboard.GetText();
|
||||
if (string.IsNullOrWhiteSpace(text))
|
||||
{
|
||||
DebugConsole.ThrowError("Unable to paste assembly: Clipboard content is empty.");
|
||||
return;
|
||||
@@ -2986,7 +3044,7 @@ namespace Barotrauma
|
||||
|
||||
try
|
||||
{
|
||||
element = XDocument.Parse(clipboard).Root;
|
||||
element = XDocument.Parse(text).Root;
|
||||
}
|
||||
catch (Exception) { /* ignored */ }
|
||||
|
||||
@@ -2996,12 +3054,11 @@ namespace Barotrauma
|
||||
return;
|
||||
}
|
||||
|
||||
Vector2 pos = cam.ScreenToWorld(PlayerInput.MousePosition);
|
||||
Submarine sub = Submarine.MainSub;
|
||||
List<MapEntity> entities;
|
||||
try
|
||||
{
|
||||
entities = ItemAssemblyPrefab.PasteEntities(pos, sub, element, selectInstance: true);
|
||||
entities = ItemAssemblyPrefab.PasteEntities(pos.Value, sub, element, selectInstance: true);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -3274,57 +3331,6 @@ namespace Barotrauma
|
||||
|
||||
static string ColorToHex(Color color) => $"#{(color.R << 16 | color.G << 8 | color.B):X6}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a color picker that can be used to change the submarine editor's background color
|
||||
/// </summary>
|
||||
private void CreateBackgroundColorPicker()
|
||||
{
|
||||
var msgBox = new GUIMessageBox(TextManager.Get("CharacterEditor.EditBackgroundColor"), "", new[] { TextManager.Get("Reset"), TextManager.Get("OK")}, new Vector2(0.2f, 0.175f), minSize: new Point(300, 175));
|
||||
|
||||
var rgbLayout = new GUILayoutGroup(new RectTransform(new Vector2(1f, 0.25f), msgBox.Content.RectTransform), isHorizontal: true);
|
||||
|
||||
// Generate R,G,B labels and parent elements
|
||||
var layoutParents = new GUILayoutGroup[3];
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
var colorContainer = new GUILayoutGroup(new RectTransform(new Vector2(0.33f, 1), rgbLayout.RectTransform), isHorizontal: true) { Stretch = true };
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.2f, 1), colorContainer.RectTransform, Anchor.CenterLeft) { MinSize = new Point(15, 0) }, GUI.colorComponentLabels[i], font: GUI.SmallFont, textAlignment: Alignment.Center);
|
||||
layoutParents[i] = colorContainer;
|
||||
}
|
||||
|
||||
// attach number inputs to our generated parent elements
|
||||
var rInput = new GUINumberInput(new RectTransform(new Vector2(0.7f, 1f), layoutParents[0].RectTransform), GUINumberInput.NumberType.Int) { IntValue = backgroundColor.R };
|
||||
var gInput = new GUINumberInput(new RectTransform(new Vector2(0.7f, 1f), layoutParents[1].RectTransform), GUINumberInput.NumberType.Int) { IntValue = backgroundColor.G };
|
||||
var bInput = new GUINumberInput(new RectTransform(new Vector2(0.7f, 1f), layoutParents[2].RectTransform), GUINumberInput.NumberType.Int) { IntValue = backgroundColor.B };
|
||||
|
||||
rInput.MinValueInt = gInput.MinValueInt = bInput.MinValueInt = 0;
|
||||
rInput.MaxValueInt = gInput.MaxValueInt = bInput.MaxValueInt = 255;
|
||||
|
||||
rInput.OnValueChanged = gInput.OnValueChanged = bInput.OnValueChanged = delegate
|
||||
{
|
||||
var color = new Color(rInput.IntValue, gInput.IntValue, bInput.IntValue);
|
||||
backgroundColor = color;
|
||||
GameSettings.SubEditorBackgroundColor = color;
|
||||
};
|
||||
|
||||
// Reset button
|
||||
msgBox.Buttons[0].OnClicked = (button, o) =>
|
||||
{
|
||||
rInput.IntValue = 13;
|
||||
gInput.IntValue = 37;
|
||||
bInput.IntValue = 69;
|
||||
return true;
|
||||
};
|
||||
|
||||
// Ok button
|
||||
msgBox.Buttons[1].OnClicked = (button, o) =>
|
||||
{
|
||||
msgBox.Close();
|
||||
GameMain.Config.SaveNewPlayerConfig();
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
private GUIFrame CreateWiringPanel()
|
||||
{
|
||||
@@ -3495,27 +3501,7 @@ namespace Barotrauma
|
||||
|
||||
submarineDescriptionCharacterCount.Text = text.Length + " / " + submarineDescriptionLimit;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the prefab is an item or if it only consists of items
|
||||
/// </summary>
|
||||
/// <param name="mapPrefab">The prefab to check</param>
|
||||
/// <returns>True if the the prefab is an item or it contains only items</returns>
|
||||
private bool IsItemPrefab(MapEntityPrefab mapPrefab)
|
||||
{
|
||||
if (dummyCharacter?.SelectedConstruction == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return mapPrefab switch
|
||||
{
|
||||
ItemPrefab iPrefab => true,
|
||||
ItemAssemblyPrefab aPrefab => aPrefab.DisplayEntities.All(pair => pair.First is ItemPrefab),
|
||||
_ => false
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
private bool SelectPrefab(GUIComponent component, object obj)
|
||||
{
|
||||
allEntityList.Deselect();
|
||||
@@ -4753,7 +4739,7 @@ namespace Barotrauma
|
||||
sub.UpdateTransform();
|
||||
}
|
||||
|
||||
graphics.Clear(backgroundColor);
|
||||
graphics.Clear(BackgroundColor);
|
||||
|
||||
ImageManager.Draw(spriteBatch, cam);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user