v1.6.17.0 (Unto the Breach update)
This commit is contained in:
@@ -7,6 +7,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
#if DEBUG
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
@@ -20,23 +21,26 @@ namespace Barotrauma
|
||||
{
|
||||
public override Camera Cam { get; }
|
||||
|
||||
private readonly GUIFrame leftPanel, rightPanel, bottomPanel, topPanel;
|
||||
private GUIFrame leftPanel, rightPanel, bottomPanel, topPanel;
|
||||
|
||||
private LevelGenerationParams selectedParams;
|
||||
private RuinGenerationParams selectedRuinGenerationParams;
|
||||
private OutpostGenerationParams selectedOutpostGenerationParams;
|
||||
private LevelObjectPrefab selectedLevelObject;
|
||||
|
||||
private readonly GUIListBox paramsList, ruinParamsList, caveParamsList, outpostParamsList, levelObjectList;
|
||||
private readonly GUIListBox editorContainer;
|
||||
private GUIListBox paramsList, ruinParamsList, caveParamsList, outpostParamsList, levelObjectList;
|
||||
private GUIListBox editorContainer;
|
||||
|
||||
private readonly GUIButton spriteEditDoneButton;
|
||||
private GUIButton spriteEditDoneButton;
|
||||
|
||||
private readonly GUITextBox seedBox;
|
||||
private GUITextBox seedBox;
|
||||
|
||||
private readonly GUITickBox lightingEnabled, cursorLightEnabled, allowInvalidOutpost, mirrorLevel;
|
||||
private GUITickBox lightingEnabled, cursorLightEnabled, allowInvalidOutpost, mirrorLevel;
|
||||
|
||||
private readonly GUIDropDown selectedSubDropDown;
|
||||
private readonly GUIDropDown selectedBeaconStationDropdown;
|
||||
private readonly GUIDropDown selectedWreckDropdown;
|
||||
private GUIDropDown selectedSubDropDown;
|
||||
private GUIDropDown selectedBeaconStationDropdown;
|
||||
private GUIDropDown selectedWreckDropdown;
|
||||
private GUINumberInput forceDifficultyInput;
|
||||
|
||||
private Sprite editingSprite;
|
||||
|
||||
@@ -45,15 +49,32 @@ namespace Barotrauma
|
||||
private readonly Color[] tunnelDebugColors = new Color[] { Color.White, Color.Cyan, Color.LightGreen, Color.Red, Color.LightYellow, Color.LightSeaGreen };
|
||||
|
||||
private LevelData currentLevelData;
|
||||
|
||||
public LevelEditorScreen()
|
||||
|
||||
private void RefreshUI(bool forceCreate = false)
|
||||
{
|
||||
Cam = new Camera()
|
||||
if (forceCreate)
|
||||
{
|
||||
MinZoom = 0.01f,
|
||||
MaxZoom = 1.0f
|
||||
};
|
||||
|
||||
CreateUI();
|
||||
}
|
||||
|
||||
GUI.PreventPauseMenuToggle = false;
|
||||
pointerLightSource = new LightSource(Vector2.Zero, 1000.0f, Color.White, submarine: null);
|
||||
GameMain.LightManager.AddLight(pointerLightSource);
|
||||
topPanel.ClearChildren();
|
||||
new SerializableEntityEditor(topPanel.RectTransform, pointerLightSource.LightSourceParams, false, true);
|
||||
|
||||
editingSprite = null;
|
||||
UpdateParamsList();
|
||||
UpdateRuinParamsList();
|
||||
UpdateCaveParamsList();
|
||||
UpdateOutpostParamsList();
|
||||
UpdateLevelObjectsList();
|
||||
}
|
||||
|
||||
private void CreateUI()
|
||||
{
|
||||
leftPanel?.ClearChildren();
|
||||
rightPanel?.ClearChildren();
|
||||
leftPanel = new GUIFrame(new RectTransform(new Vector2(0.125f, 0.8f), Frame.RectTransform) { MinSize = new Point(150, 0) });
|
||||
var paddedLeftPanel = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.95f), leftPanel.RectTransform, Anchor.CenterLeft) { RelativeOffset = new Vector2(0.02f, 0.0f) })
|
||||
{
|
||||
@@ -72,6 +93,7 @@ namespace Barotrauma
|
||||
editorContainer.ClearChildren();
|
||||
SortLevelObjectsList(currentLevelData);
|
||||
new SerializableEntityEditor(editorContainer.Content.RectTransform, selectedParams, inGame: false, showName: true, elementHeight: 20, titleFont: GUIStyle.LargeFont);
|
||||
forceDifficultyInput.FloatValue = (selectedParams.MinLevelDifficulty + selectedParams.MaxLevelDifficulty) / 2f;
|
||||
return true;
|
||||
};
|
||||
|
||||
@@ -83,7 +105,30 @@ namespace Barotrauma
|
||||
};
|
||||
ruinParamsList.OnSelected += (GUIComponent component, object obj) =>
|
||||
{
|
||||
CreateOutpostGenerationParamsEditor(obj as OutpostGenerationParams);
|
||||
if (selectedRuinGenerationParams == obj)
|
||||
{
|
||||
// need to wait a frame before deselecting or the highlight on the list item gets left on
|
||||
CoroutineManager.StartCoroutine(DeselectRuinParams());
|
||||
|
||||
IEnumerable<CoroutineStatus> DeselectRuinParams()
|
||||
{
|
||||
if (Screen.Selected != this)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
yield return null;
|
||||
selectedRuinGenerationParams = null;
|
||||
CreateOutpostGenerationParamsEditor(null);
|
||||
ruinParamsList.Deselect();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
selectedRuinGenerationParams = obj as RuinGenerationParams;
|
||||
CreateOutpostGenerationParamsEditor(selectedRuinGenerationParams);
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
@@ -108,7 +153,8 @@ namespace Barotrauma
|
||||
};
|
||||
outpostParamsList.OnSelected += (GUIComponent component, object obj) =>
|
||||
{
|
||||
CreateOutpostGenerationParamsEditor(obj as OutpostGenerationParams);
|
||||
selectedOutpostGenerationParams = obj as OutpostGenerationParams;
|
||||
CreateOutpostGenerationParamsEditor(selectedOutpostGenerationParams);
|
||||
return true;
|
||||
};
|
||||
|
||||
@@ -218,15 +264,31 @@ namespace Barotrauma
|
||||
selectedWreckDropdown.AddItem(wreck.DisplayName, userData: wreck);
|
||||
}
|
||||
wreckDropDownContainer.RectTransform.MinSize = new Point(0, selectedWreckDropdown.RectTransform.MinSize.Y);
|
||||
|
||||
var forceDifficultyContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.02f), paddedRightPanel.RectTransform), isHorizontal: true);
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.5f, 1.0f), forceDifficultyContainer.RectTransform), TextManager.Get("leveldifficulty"));
|
||||
forceDifficultyInput = new GUINumberInput(new RectTransform(new Vector2(0.5f, 1.0f), forceDifficultyContainer.RectTransform), NumberType.Float)
|
||||
{
|
||||
MinValueFloat = 0,
|
||||
MaxValueFloat = 100,
|
||||
FloatValue = Level.ForcedDifficulty ?? selectedParams?.MinLevelDifficulty ?? 0f,
|
||||
OnValueChanged = (numberInput) =>
|
||||
{
|
||||
if (Level.ForcedDifficulty == null) { return; }
|
||||
Level.ForcedDifficulty = numberInput.FloatValue;
|
||||
}
|
||||
};
|
||||
forceDifficultyContainer.RectTransform.MinSize = new Point(0, forceDifficultyInput.RectTransform.MinSize.Y);
|
||||
|
||||
var tickBoxContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.04f), paddedRightPanel.RectTransform), isHorizontal: true);
|
||||
mirrorLevel = new GUITickBox(new RectTransform(new Vector2(0.5f, 0.02f), tickBoxContainer.RectTransform), TextManager.Get("mirrorentityx"));
|
||||
|
||||
mirrorLevel = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.02f), paddedRightPanel.RectTransform), TextManager.Get("mirrorentityx"));
|
||||
|
||||
allowInvalidOutpost = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.025f), paddedRightPanel.RectTransform),
|
||||
allowInvalidOutpost = new GUITickBox(new RectTransform(new Vector2(0.5f, 0.025f), tickBoxContainer.RectTransform),
|
||||
TextManager.Get("leveleditor.allowinvalidoutpost"))
|
||||
{
|
||||
ToolTip = TextManager.Get("leveleditor.allowinvalidoutpost.tooltip")
|
||||
};
|
||||
|
||||
|
||||
new GUIButton(new RectTransform(new Vector2(1.0f, 0.05f), paddedRightPanel.RectTransform),
|
||||
TextManager.Get("leveleditor.generate"))
|
||||
{
|
||||
@@ -240,10 +302,11 @@ namespace Barotrauma
|
||||
Submarine.MainSub = new Submarine(subInfo);
|
||||
}
|
||||
GameMain.LightManager.ClearLights();
|
||||
currentLevelData = LevelData.CreateRandom(seedBox.Text, generationParams: selectedParams);
|
||||
currentLevelData = LevelData.CreateRandom(seedBox.Text, difficulty: forceDifficultyInput.FloatValue, generationParams: selectedParams);
|
||||
currentLevelData.ForceOutpostGenerationParams = outpostParamsList.SelectedData as OutpostGenerationParams;
|
||||
currentLevelData.ForceBeaconStation = selectedBeaconStationDropdown.SelectedData as SubmarineInfo;
|
||||
currentLevelData.ForceWreck = selectedWreckDropdown.SelectedData as SubmarineInfo;
|
||||
currentLevelData.ForceRuinGenerationParams = selectedRuinGenerationParams;
|
||||
currentLevelData.AllowInvalidOutpost = allowInvalidOutpost.Selected;
|
||||
var dummyLocations = GameSession.CreateDummyLocations(currentLevelData);
|
||||
Level.Generate(currentLevelData, mirror: mirrorLevel.Selected, startLocation: dummyLocations[0], endLocation: dummyLocations[1]);
|
||||
@@ -272,7 +335,6 @@ namespace Barotrauma
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
new GUIButton(new RectTransform(new Vector2(1.0f, 0.05f), paddedRightPanel.RectTransform),
|
||||
TextManager.Get("leveleditor.test"))
|
||||
{
|
||||
@@ -300,7 +362,7 @@ namespace Barotrauma
|
||||
subInfo ??= SubmarineInfo.SavedSubmarines.GetRandomUnsynced(s =>
|
||||
s.IsPlayer && !s.HasTag(SubmarineTag.Shuttle) &&
|
||||
!nonPlayerFiles.Any(f => f.Path == s.FilePath));
|
||||
GameSession gameSession = new GameSession(subInfo, "", GameModePreset.TestMode, CampaignSettings.Empty, null);
|
||||
GameSession gameSession = new GameSession(subInfo, Option.None, CampaignDataPath.Empty, GameModePreset.TestMode, CampaignSettings.Empty, null);
|
||||
gameSession.StartRound(Level.Loaded.LevelData);
|
||||
(gameSession.GameMode as TestGameMode).OnRoundEnd = () =>
|
||||
{
|
||||
@@ -350,6 +412,17 @@ namespace Barotrauma
|
||||
topPanel = new GUIFrame(new RectTransform(new Point(400, 100), GUI.Canvas)
|
||||
{ RelativeOffset = new Vector2(leftPanel.RectTransform.RelativeSize.X * 2, 0.0f) }, style: "GUIFrameTop");
|
||||
}
|
||||
|
||||
public LevelEditorScreen()
|
||||
{
|
||||
Cam = new Camera()
|
||||
{
|
||||
MinZoom = 0.01f,
|
||||
MaxZoom = 1.0f
|
||||
};
|
||||
|
||||
RefreshUI(forceCreate: true);
|
||||
}
|
||||
|
||||
public void TestLevelGenerationForErrors(int amountOfLevelsToGenerate)
|
||||
{
|
||||
@@ -394,28 +467,13 @@ namespace Barotrauma
|
||||
yield return CoroutineStatus.Running;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public override void Select()
|
||||
{
|
||||
base.Select();
|
||||
|
||||
GUI.PreventPauseMenuToggle = false;
|
||||
pointerLightSource = new LightSource(Vector2.Zero, 1000.0f, Color.White, submarine: null);
|
||||
GameMain.LightManager.AddLight(pointerLightSource);
|
||||
topPanel.ClearChildren();
|
||||
new SerializableEntityEditor(topPanel.RectTransform, pointerLightSource.LightSourceParams, false, true);
|
||||
|
||||
editingSprite = null;
|
||||
UpdateParamsList();
|
||||
UpdateRuinParamsList();
|
||||
UpdateCaveParamsList();
|
||||
UpdateOutpostParamsList();
|
||||
UpdateLevelObjectsList();
|
||||
|
||||
RefreshUI(forceCreate: false);
|
||||
}
|
||||
|
||||
protected override void DeselectEditorSpecific()
|
||||
@@ -464,7 +522,7 @@ namespace Barotrauma
|
||||
foreach (RuinGenerationParams genParams in RuinGenerationParams.RuinParams.OrderBy(p => p.Identifier))
|
||||
{
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), ruinParamsList.Content.RectTransform) { MinSize = new Point(0, 20) },
|
||||
genParams.Name)
|
||||
genParams.Identifier.Value)
|
||||
{
|
||||
Padding = Vector4.Zero,
|
||||
UserData = genParams
|
||||
@@ -556,6 +614,7 @@ namespace Barotrauma
|
||||
private void CreateOutpostGenerationParamsEditor(OutpostGenerationParams outpostGenerationParams)
|
||||
{
|
||||
editorContainer.ClearChildren();
|
||||
if (outpostGenerationParams == null) { return; }
|
||||
var outpostParamsEditor = new SerializableEntityEditor(editorContainer.Content.RectTransform, outpostGenerationParams, false, true, elementHeight: 20);
|
||||
|
||||
// location type -------------------------
|
||||
@@ -584,7 +643,7 @@ namespace Barotrauma
|
||||
locationTypeDropDown.SelectItem("any");
|
||||
}
|
||||
|
||||
locationTypeDropDown.OnSelected += (_, __) =>
|
||||
locationTypeDropDown.AfterSelected += (_, __) =>
|
||||
{
|
||||
outpostGenerationParams.SetAllowedLocationTypes(locationTypeDropDown.SelectedDataMultiple.Cast<Identifier>());
|
||||
locationTypeDropDown.Text = ToolBox.LimitString(locationTypeDropDown.Text, locationTypeDropDown.Font, locationTypeDropDown.Rect.Width);
|
||||
@@ -596,29 +655,29 @@ namespace Barotrauma
|
||||
|
||||
// module count -------------------------
|
||||
|
||||
var moduleLabel = new GUITextBlock(new RectTransform(new Point(editorContainer.Content.Rect.Width, (int)(70 * GUI.Scale))), TextManager.Get("submarinetype.outpostmodules"), font: GUIStyle.SubHeadingFont);
|
||||
outpostParamsEditor.AddCustomContent(moduleLabel, 100);
|
||||
|
||||
foreach (var moduleCount in outpostGenerationParams.ModuleCounts)
|
||||
{
|
||||
var moduleCountGroup = new GUILayoutGroup(new RectTransform(new Point(editorContainer.Content.Rect.Width, (int)(25 * GUI.Scale))), isHorizontal: true, childAnchor: Anchor.CenterLeft);
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.5f, 1f), moduleCountGroup.RectTransform), TextManager.Capitalize(moduleCount.Identifier.Value), textAlignment: Alignment.CenterLeft);
|
||||
new GUINumberInput(new RectTransform(new Vector2(0.5f, 1f), moduleCountGroup.RectTransform), NumberType.Int)
|
||||
var editor = new SerializableEntityEditor(editorContainer.Content.RectTransform, moduleCount, inGame: false, showName: true, elementHeight: 20, titleFont: GUIStyle.Font);
|
||||
foreach (var componentList in editor.Fields.Values)
|
||||
{
|
||||
MinValueInt = 0,
|
||||
MaxValueInt = 100,
|
||||
IntValue = moduleCount.Count,
|
||||
OnValueChanged = (numInput) =>
|
||||
foreach (var component in componentList)
|
||||
{
|
||||
outpostGenerationParams.SetModuleCount(moduleCount.Identifier, numInput.IntValue);
|
||||
if (numInput.IntValue == 0)
|
||||
if (component is GUINumberInput numberInput)
|
||||
{
|
||||
outpostParamsList.Select(outpostParamsList.SelectedData);
|
||||
numberInput.OnValueChanged += (numInput) =>
|
||||
{
|
||||
if (moduleCount.Count == 0)
|
||||
{
|
||||
//refresh to remove this module count from the editor
|
||||
outpostParamsList.Select(outpostParamsList.SelectedData);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
moduleCountGroup.RectTransform.MinSize = new Point(moduleCountGroup.Rect.Width, moduleCountGroup.RectTransform.Children.Max(c => c.MinSize.Y));
|
||||
outpostParamsEditor.AddCustomContent(moduleCountGroup, 100);
|
||||
}
|
||||
editor.RectTransform.MaxSize = new Point(int.MaxValue, editor.Rect.Height);
|
||||
outpostParamsEditor.AddCustomContent(editor, 100);
|
||||
editor.Recalculate();
|
||||
}
|
||||
|
||||
// add module count -------------------------
|
||||
@@ -648,7 +707,7 @@ namespace Barotrauma
|
||||
};
|
||||
addModuleCountGroup.RectTransform.MinSize = new Point(addModuleCountGroup.Rect.Width, addModuleCountGroup.RectTransform.Children.Max(c => c.MinSize.Y));
|
||||
outpostParamsEditor.AddCustomContent(addModuleCountGroup, 100);
|
||||
|
||||
outpostParamsEditor.Recalculate();
|
||||
}
|
||||
|
||||
private void CreateLevelObjectEditor(LevelObjectPrefab levelObjectPrefab)
|
||||
@@ -736,7 +795,7 @@ namespace Barotrauma
|
||||
dropdown.AddItem(objPrefab.Name, objPrefab);
|
||||
if (childObj.AllowedNames.Contains(objPrefab.Name)) { dropdown.SelectItem(objPrefab); }
|
||||
}
|
||||
dropdown.OnSelected = (selected, obj) =>
|
||||
dropdown.AfterSelected = (selected, obj) =>
|
||||
{
|
||||
childObj.AllowedNames = dropdown.SelectedDataMultiple.Select(d => ((LevelObjectPrefab)d).Name).ToList();
|
||||
return true;
|
||||
@@ -965,11 +1024,17 @@ namespace Barotrauma
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, samplerState: GUI.SamplerState, rasterizerState: GameMain.ScissorTestEnable);
|
||||
if (Level.Loaded != null)
|
||||
{
|
||||
float crushDepthScreen = Cam.WorldToScreen(new Vector2(0.0f, -Level.Loaded.CrushDepth)).Y;
|
||||
if (crushDepthScreen > 0.0f && crushDepthScreen < GameMain.GraphicsHeight)
|
||||
float hullUpgradePrcIncrease = UpgradePrefab.CrushDepthUpgradePrc / 100f;
|
||||
for (int upgradeLevel = 0; upgradeLevel <= UpgradePrefab.IncreaseWallHealthMaxLevel; upgradeLevel++)
|
||||
{
|
||||
GUI.DrawLine(spriteBatch, new Vector2(0, crushDepthScreen), new Vector2(GameMain.GraphicsWidth, crushDepthScreen), GUIStyle.Red * 0.25f, width: 5);
|
||||
GUI.DrawString(spriteBatch, new Vector2(GameMain.GraphicsWidth / 2, crushDepthScreen), "Crush depth", GUIStyle.Red, backgroundColor: Color.Black);
|
||||
float upgradeLevelCrushDepth = Level.DefaultRealWorldCrushDepth + (Level.DefaultRealWorldCrushDepth * upgradeLevel * hullUpgradePrcIncrease);
|
||||
float subCrushDepth = (upgradeLevelCrushDepth / Physics.DisplayToRealWorldRatio) - Level.Loaded.LevelData.InitialDepth;
|
||||
string labelText = $"Crush depth (upgrade level {upgradeLevel})";
|
||||
if (upgradeLevel == 0)
|
||||
{
|
||||
labelText = $"Crush depth (no upgrade)";
|
||||
}
|
||||
DrawCrushDepth(subCrushDepth, labelText, Color.Red);
|
||||
}
|
||||
|
||||
float abyssStartScreen = Cam.WorldToScreen(new Vector2(0.0f, Level.Loaded.AbyssArea.Bottom)).Y;
|
||||
@@ -987,9 +1052,18 @@ namespace Barotrauma
|
||||
}
|
||||
GUI.Draw(Cam, spriteBatch);
|
||||
spriteBatch.End();
|
||||
|
||||
void DrawCrushDepth(float crushDepth, string labelText, Color color)
|
||||
{
|
||||
float crushDepthScreen = Cam.WorldToScreen(new Vector2(0.0f, -crushDepth)).Y;
|
||||
if (crushDepthScreen > 0.0f && crushDepthScreen < GameMain.GraphicsHeight)
|
||||
{
|
||||
GUI.DrawLine(spriteBatch, new Vector2(0, crushDepthScreen), new Vector2(GameMain.GraphicsWidth, crushDepthScreen), color * 0.25f, width: 5);
|
||||
GUI.DrawString(spriteBatch, new Vector2(GameMain.GraphicsWidth / 2, crushDepthScreen), labelText, GUIStyle.Red, backgroundColor: Color.Black);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public override void Update(double deltaTime)
|
||||
{
|
||||
if (lightingEnabled.Selected)
|
||||
@@ -1016,6 +1090,19 @@ namespace Barotrauma
|
||||
{
|
||||
GameMain.SpriteEditorScreen.Update(deltaTime);
|
||||
}
|
||||
|
||||
// in case forced difficulty was changed by console command or such
|
||||
if (Level.ForcedDifficulty != null && MathHelper.Distance((float)Level.ForcedDifficulty, forceDifficultyInput.FloatValue) > 0.001f)
|
||||
{
|
||||
forceDifficultyInput.FloatValue = (float)Level.ForcedDifficulty;
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
if (PlayerInput.KeyDown(Keys.LeftControl) && PlayerInput.KeyHit(Keys.R))
|
||||
{
|
||||
RefreshUI(forceCreate: true);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
private void SerializeAll()
|
||||
|
||||
Reference in New Issue
Block a user