Unstable 0.17.0.0
This commit is contained in:
@@ -16,13 +16,9 @@ using Barotrauma.IO;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
class LevelEditorScreen : Screen
|
||||
class LevelEditorScreen : EditorScreen
|
||||
{
|
||||
private readonly Camera cam;
|
||||
public override Camera Cam
|
||||
{
|
||||
get { return cam; }
|
||||
}
|
||||
public override Camera Cam { get; }
|
||||
|
||||
private readonly GUIFrame leftPanel, rightPanel, bottomPanel, topPanel;
|
||||
|
||||
@@ -46,7 +42,7 @@ namespace Barotrauma
|
||||
|
||||
public LevelEditorScreen()
|
||||
{
|
||||
cam = new Camera()
|
||||
Cam = new Camera()
|
||||
{
|
||||
MinZoom = 0.01f,
|
||||
MaxZoom = 1.0f
|
||||
@@ -69,7 +65,7 @@ namespace Barotrauma
|
||||
return true;
|
||||
};
|
||||
|
||||
var ruinTitle = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), paddedLeftPanel.RectTransform), TextManager.Get("leveleditor.ruinparams"), font: GUI.SubHeadingFont);
|
||||
var ruinTitle = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), paddedLeftPanel.RectTransform), TextManager.Get("leveleditor.ruinparams"), font: GUIStyle.SubHeadingFont);
|
||||
|
||||
ruinParamsList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.1f), paddedLeftPanel.RectTransform));
|
||||
ruinParamsList.OnSelected += (GUIComponent component, object obj) =>
|
||||
@@ -78,7 +74,7 @@ namespace Barotrauma
|
||||
return true;
|
||||
};
|
||||
|
||||
var caveTitle = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), paddedLeftPanel.RectTransform), TextManager.Get("leveleditor.caveparams"), font: GUI.SubHeadingFont);
|
||||
var caveTitle = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), paddedLeftPanel.RectTransform), TextManager.Get("leveleditor.caveparams"), font: GUIStyle.SubHeadingFont);
|
||||
|
||||
caveParamsList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.1f), paddedLeftPanel.RectTransform));
|
||||
caveParamsList.OnSelected += (GUIComponent component, object obj) =>
|
||||
@@ -87,7 +83,7 @@ namespace Barotrauma
|
||||
return true;
|
||||
};
|
||||
|
||||
var outpostTitle = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), paddedLeftPanel.RectTransform), TextManager.Get("leveleditor.outpostparams"), font: GUI.SubHeadingFont);
|
||||
var outpostTitle = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), paddedLeftPanel.RectTransform), TextManager.Get("leveleditor.outpostparams"), font: GUIStyle.SubHeadingFont);
|
||||
GUITextBlock.AutoScaleAndNormalize(ruinTitle, caveTitle, outpostTitle);
|
||||
|
||||
outpostParamsList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.2f), paddedLeftPanel.RectTransform));
|
||||
@@ -185,13 +181,13 @@ namespace Barotrauma
|
||||
levelData.ForceOutpostGenerationParams = outpostParamsList.SelectedData as OutpostGenerationParams;
|
||||
Level.Generate(levelData, mirror: mirrorLevel.Selected);
|
||||
GameMain.LightManager.AddLight(pointerLightSource);
|
||||
if (!wasLevelLoaded || cam.Position.X < 0 || cam.Position.Y < 0 || cam.Position.Y > Level.Loaded.Size.X || cam.Position.Y > Level.Loaded.Size.Y)
|
||||
if (!wasLevelLoaded || Cam.Position.X < 0 || Cam.Position.Y < 0 || Cam.Position.Y > Level.Loaded.Size.X || Cam.Position.Y > Level.Loaded.Size.Y)
|
||||
{
|
||||
cam.Position = new Vector2(Level.Loaded.Size.X / 2, Level.Loaded.Size.Y / 2);
|
||||
Cam.Position = new Vector2(Level.Loaded.Size.X / 2, Level.Loaded.Size.Y / 2);
|
||||
}
|
||||
foreach (GUITextBlock param in paramsList.Content.Children)
|
||||
{
|
||||
param.TextColor = param.UserData == selectedParams ? GUI.Style.Green : param.Style.TextColor;
|
||||
param.TextColor = param.UserData == selectedParams ? GUIStyle.Green : param.Style.TextColor;
|
||||
}
|
||||
seedBox.Deselect();
|
||||
return true;
|
||||
@@ -218,14 +214,13 @@ namespace Barotrauma
|
||||
Submarine.MainSub.Remove();
|
||||
}
|
||||
|
||||
//TODO: hacky workaround to check for wrecks and outposts, refactor SubmarineInfo and ContentType at some point
|
||||
var nonPlayerFiles = ContentPackage.GetFilesOfType(GameMain.Config.AllEnabledPackages, ContentType.Wreck).ToList();
|
||||
nonPlayerFiles.AddRange(ContentPackage.GetFilesOfType(GameMain.Config.AllEnabledPackages, ContentType.Outpost));
|
||||
nonPlayerFiles.AddRange(ContentPackage.GetFilesOfType(GameMain.Config.AllEnabledPackages, ContentType.OutpostModule));
|
||||
SubmarineInfo subInfo = SubmarineInfo.SavedSubmarines.FirstOrDefault(s => s.Name.Equals(GameMain.Config.QuickStartSubmarineName, StringComparison.InvariantCultureIgnoreCase));
|
||||
subInfo ??= SubmarineInfo.SavedSubmarines.GetRandom(s =>
|
||||
var nonPlayerFiles = ContentPackageManager.EnabledPackages.All.SelectMany(p => p
|
||||
.GetFiles<BaseSubFile>()
|
||||
.Where(f => !(f is SubmarineFile))).ToArray();
|
||||
SubmarineInfo subInfo = SubmarineInfo.SavedSubmarines.FirstOrDefault(s => s.Name == GameSettings.CurrentConfig.QuickStartSub);
|
||||
subInfo ??= SubmarineInfo.SavedSubmarines.GetRandomUnsynced(s =>
|
||||
s.IsPlayer && !s.HasTag(SubmarineTag.Shuttle) &&
|
||||
!nonPlayerFiles.Any(f => f.Path.CleanUpPath().Equals(s.FilePath.CleanUpPath(), StringComparison.InvariantCultureIgnoreCase)));
|
||||
!nonPlayerFiles.Any(f => f.Path == s.FilePath));
|
||||
GameSession gameSession = new GameSession(subInfo, "", GameModePreset.TestMode, CampaignSettings.Empty, null);
|
||||
gameSession.StartRound(Level.Loaded.LevelData);
|
||||
(gameSession.GameMode as TestGameMode).OnRoundEnd = () =>
|
||||
@@ -309,7 +304,7 @@ namespace Barotrauma
|
||||
foreach (LevelGenerationParams genParams in LevelGenerationParams.LevelParams)
|
||||
{
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), paramsList.Content.RectTransform) { MinSize = new Point(0, 20) },
|
||||
genParams.Identifier)
|
||||
genParams.Identifier.Value)
|
||||
{
|
||||
Padding = Vector4.Zero,
|
||||
UserData = genParams
|
||||
@@ -354,7 +349,7 @@ namespace Barotrauma
|
||||
editorContainer.ClearChildren();
|
||||
outpostParamsList.Content.ClearChildren();
|
||||
|
||||
foreach (OutpostGenerationParams genParams in OutpostGenerationParams.Params)
|
||||
foreach (OutpostGenerationParams genParams in OutpostGenerationParams.OutpostParams)
|
||||
{
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), outpostParamsList.Content.RectTransform) { MinSize = new Point(0, 20) },
|
||||
genParams.Name)
|
||||
@@ -373,7 +368,7 @@ namespace Barotrauma
|
||||
int objectsPerRow = (int)Math.Ceiling(levelObjectList.Content.Rect.Width / Math.Max(100 * GUI.Scale, 100));
|
||||
float relWidth = 1.0f / objectsPerRow;
|
||||
|
||||
foreach (LevelObjectPrefab levelObjPrefab in LevelObjectPrefab.List)
|
||||
foreach (LevelObjectPrefab levelObjPrefab in LevelObjectPrefab.Prefabs)
|
||||
{
|
||||
var frame = new GUIFrame(new RectTransform(
|
||||
new Vector2(relWidth, relWidth * ((float)levelObjectList.Content.Rect.Width / levelObjectList.Content.Rect.Height)),
|
||||
@@ -384,7 +379,7 @@ namespace Barotrauma
|
||||
var paddedFrame = new GUIFrame(new RectTransform(new Vector2(0.9f, 0.9f), frame.RectTransform, Anchor.Center), style: null);
|
||||
|
||||
GUITextBlock textBlock = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), paddedFrame.RectTransform, Anchor.BottomCenter),
|
||||
text: ToolBox.LimitString(levelObjPrefab.Name, GUI.SmallFont, paddedFrame.Rect.Width), textAlignment: Alignment.Center, font: GUI.SmallFont)
|
||||
text: ToolBox.LimitString(levelObjPrefab.Name, GUIStyle.SmallFont, paddedFrame.Rect.Width), textAlignment: Alignment.Center, font: GUIStyle.SmallFont)
|
||||
{
|
||||
CanBeFocused = false,
|
||||
ToolTip = levelObjPrefab.Name
|
||||
@@ -414,7 +409,7 @@ namespace Barotrauma
|
||||
Stretch = true
|
||||
};
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.4f), commonnessContainer.RectTransform),
|
||||
TextManager.GetWithVariable("leveleditor.levelobjcommonness", "[leveltype]", selectedParams.Identifier), textAlignment: Alignment.Center);
|
||||
TextManager.GetWithVariable("leveleditor.levelobjcommonness", "[leveltype]", selectedParams.Identifier.Value), textAlignment: Alignment.Center);
|
||||
new GUINumberInput(new RectTransform(new Vector2(0.5f, 0.4f), commonnessContainer.RectTransform), GUINumberInput.NumberType.Float)
|
||||
{
|
||||
MinValueFloat = 0,
|
||||
@@ -443,14 +438,14 @@ namespace Barotrauma
|
||||
};
|
||||
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.5f, 1f), locationTypeGroup.RectTransform), TextManager.Get("outpostmoduleallowedlocationtypes"), textAlignment: Alignment.CenterLeft);
|
||||
HashSet<string> availableLocationTypes = new HashSet<string> { "any" };
|
||||
foreach (LocationType locationType in LocationType.List) { availableLocationTypes.Add(locationType.Identifier); }
|
||||
HashSet<Identifier> availableLocationTypes = new HashSet<Identifier> { "any".ToIdentifier() };
|
||||
foreach (LocationType locationType in LocationType.Prefabs) { availableLocationTypes.Add(locationType.Identifier); }
|
||||
|
||||
var locationTypeDropDown = new GUIDropDown(new RectTransform(new Vector2(0.5f, 1f), locationTypeGroup.RectTransform),
|
||||
text: string.Join(", ", outpostGenerationParams.AllowedLocationTypes.Select(lt => TextManager.Capitalize(lt)) ?? "any".ToEnumerable()), selectMultiple: true);
|
||||
foreach (string locationType in availableLocationTypes)
|
||||
text: LocalizedString.Join(", ", outpostGenerationParams.AllowedLocationTypes.Select(lt => TextManager.Capitalize(lt.Value)) ?? ((LocalizedString)"any").ToEnumerable()), selectMultiple: true);
|
||||
foreach (Identifier locationType in availableLocationTypes)
|
||||
{
|
||||
locationTypeDropDown.AddItem(TextManager.Capitalize(locationType), locationType);
|
||||
locationTypeDropDown.AddItem(TextManager.Capitalize(locationType.Value), locationType);
|
||||
if (outpostGenerationParams.AllowedLocationTypes.Contains(locationType))
|
||||
{
|
||||
locationTypeDropDown.SelectItem(locationType);
|
||||
@@ -463,7 +458,7 @@ namespace Barotrauma
|
||||
|
||||
locationTypeDropDown.OnSelected += (_, __) =>
|
||||
{
|
||||
outpostGenerationParams.SetAllowedLocationTypes(locationTypeDropDown.SelectedDataMultiple.Cast<string>());
|
||||
outpostGenerationParams.SetAllowedLocationTypes(locationTypeDropDown.SelectedDataMultiple.Cast<Identifier>());
|
||||
locationTypeDropDown.Text = ToolBox.LimitString(locationTypeDropDown.Text, locationTypeDropDown.Font, locationTypeDropDown.Rect.Width);
|
||||
return true;
|
||||
};
|
||||
@@ -473,13 +468,13 @@ 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: GUI.SubHeadingFont);
|
||||
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 (KeyValuePair<string, int> moduleCount in outpostGenerationParams.ModuleCounts)
|
||||
foreach (KeyValuePair<Identifier, int> 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.Key), textAlignment: Alignment.CenterLeft);
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.5f, 1f), moduleCountGroup.RectTransform), TextManager.Capitalize(moduleCount.Key.Value), textAlignment: Alignment.CenterLeft);
|
||||
new GUINumberInput(new RectTransform(new Vector2(0.5f, 1f), moduleCountGroup.RectTransform), GUINumberInput.NumberType.Int)
|
||||
{
|
||||
MinValueInt = 0,
|
||||
@@ -502,24 +497,24 @@ namespace Barotrauma
|
||||
|
||||
var addModuleCountGroup = new GUILayoutGroup(new RectTransform(new Point(editorContainer.Content.Rect.Width, (int)(40 * GUI.Scale))), isHorizontal: true, childAnchor: Anchor.Center);
|
||||
|
||||
HashSet<string> availableFlags = new HashSet<string>();
|
||||
foreach (string flag in OutpostGenerationParams.Params.SelectMany(p => p.ModuleCounts.Select(m => m.Key))) { availableFlags.Add(flag); }
|
||||
HashSet<Identifier> availableFlags = new HashSet<Identifier>();
|
||||
foreach (Identifier flag in OutpostGenerationParams.OutpostParams.SelectMany(p => p.ModuleCounts.Select(m => m.Key))) { availableFlags.Add(flag); }
|
||||
foreach (var sub in SubmarineInfo.SavedSubmarines)
|
||||
{
|
||||
if (sub.OutpostModuleInfo == null) { continue; }
|
||||
foreach (string flag in sub.OutpostModuleInfo.ModuleFlags) { availableFlags.Add(flag); }
|
||||
foreach (Identifier flag in sub.OutpostModuleInfo.ModuleFlags) { availableFlags.Add(flag); }
|
||||
}
|
||||
|
||||
var moduleTypeDropDown = new GUIDropDown(new RectTransform(new Vector2(0.8f, 0.8f), addModuleCountGroup.RectTransform),
|
||||
text: TextManager.Get("leveleditor.addmoduletype"));
|
||||
foreach (string flag in availableFlags)
|
||||
foreach (Identifier flag in availableFlags)
|
||||
{
|
||||
if (outpostGenerationParams.ModuleCounts.Any(mc => mc.Key.Equals(flag, StringComparison.OrdinalIgnoreCase))) { continue; }
|
||||
moduleTypeDropDown.AddItem(TextManager.Capitalize(flag), flag);
|
||||
if (outpostGenerationParams.ModuleCounts.Any(mc => mc.Key == flag)) { continue; }
|
||||
moduleTypeDropDown.AddItem(TextManager.Capitalize(flag.Value), flag);
|
||||
}
|
||||
moduleTypeDropDown.OnSelected += (_, userdata) =>
|
||||
{
|
||||
outpostGenerationParams.SetModuleCount(userdata as string, 1);
|
||||
outpostGenerationParams.SetModuleCount((Identifier)userdata, 1);
|
||||
outpostParamsList.Select(outpostParamsList.SelectedData);
|
||||
return true;
|
||||
};
|
||||
@@ -532,14 +527,12 @@ namespace Barotrauma
|
||||
{
|
||||
editorContainer.ClearChildren();
|
||||
|
||||
var editor = new SerializableEntityEditor(editorContainer.Content.RectTransform, levelObjectPrefab, false, true, elementHeight: 20, titleFont: GUI.LargeFont);
|
||||
var editor = new SerializableEntityEditor(editorContainer.Content.RectTransform, levelObjectPrefab, false, true, elementHeight: 20, titleFont: GUIStyle.LargeFont);
|
||||
|
||||
if (selectedParams != null)
|
||||
{
|
||||
List<string> availableIdentifiers = new List<string>();
|
||||
{
|
||||
if (selectedParams != null) { availableIdentifiers.Add(selectedParams.Identifier); }
|
||||
}
|
||||
List<Identifier> availableIdentifiers = new List<Identifier>();
|
||||
if (selectedParams != null) { availableIdentifiers.Add(selectedParams.Identifier); }
|
||||
foreach (var caveParam in CaveGenerationParams.CaveParams)
|
||||
{
|
||||
if (selectedParams != null && caveParam.GetCommonness(selectedParams, abyss: false) <= 0.0f) { continue; }
|
||||
@@ -547,7 +540,7 @@ namespace Barotrauma
|
||||
}
|
||||
availableIdentifiers.Reverse();
|
||||
|
||||
foreach (string paramsId in availableIdentifiers)
|
||||
foreach (Identifier paramsId in availableIdentifiers)
|
||||
{
|
||||
var commonnessContainer = new GUILayoutGroup(new RectTransform(new Point(editor.Rect.Width, 70)) { IsFixedSize = true },
|
||||
isHorizontal: false, childAnchor: Anchor.TopCenter)
|
||||
@@ -556,7 +549,7 @@ namespace Barotrauma
|
||||
Stretch = true
|
||||
};
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.4f), commonnessContainer.RectTransform),
|
||||
TextManager.GetWithVariable("leveleditor.levelobjcommonness", "[leveltype]", paramsId), textAlignment: Alignment.Center);
|
||||
TextManager.GetWithVariable("leveleditor.levelobjcommonness", "[leveltype]", paramsId.Value), textAlignment: Alignment.Center);
|
||||
new GUINumberInput(new RectTransform(new Vector2(0.5f, 0.4f), commonnessContainer.RectTransform), GUINumberInput.NumberType.Float)
|
||||
{
|
||||
MinValueFloat = 0,
|
||||
@@ -599,7 +592,7 @@ namespace Barotrauma
|
||||
}
|
||||
//child object editing
|
||||
new GUITextBlock(new RectTransform(new Point(editor.Rect.Width, 40), editorContainer.Content.RectTransform),
|
||||
TextManager.Get("leveleditor.childobjects"), font: GUI.SubHeadingFont, textAlignment: Alignment.BottomCenter);
|
||||
TextManager.Get("leveleditor.childobjects"), font: GUIStyle.SubHeadingFont, textAlignment: Alignment.BottomCenter);
|
||||
foreach (LevelObjectPrefab.ChildObject childObj in levelObjectPrefab.ChildObjects)
|
||||
{
|
||||
var childObjFrame = new GUIFrame(new RectTransform(new Point(editor.Rect.Width, 30)));
|
||||
@@ -610,7 +603,7 @@ namespace Barotrauma
|
||||
};
|
||||
var selectedChildObj = childObj;
|
||||
var dropdown = new GUIDropDown(new RectTransform(new Vector2(0.5f, 1.0f), paddedFrame.RectTransform), elementCount: 10, selectMultiple: true);
|
||||
foreach (LevelObjectPrefab objPrefab in LevelObjectPrefab.List)
|
||||
foreach (LevelObjectPrefab objPrefab in LevelObjectPrefab.Prefabs)
|
||||
{
|
||||
dropdown.AddItem(objPrefab.Name, objPrefab);
|
||||
if (childObj.AllowedNames.Contains(objPrefab.Name)) { dropdown.SelectItem(objPrefab); }
|
||||
@@ -669,7 +662,7 @@ namespace Barotrauma
|
||||
|
||||
//light editing
|
||||
new GUITextBlock(new RectTransform(new Point(editor.Rect.Width, 40), editorContainer.Content.RectTransform),
|
||||
TextManager.Get("leveleditor.lightsources"), textAlignment: Alignment.BottomCenter, font: GUI.SubHeadingFont);
|
||||
TextManager.Get("leveleditor.lightsources"), textAlignment: Alignment.BottomCenter, font: GUIStyle.SubHeadingFont);
|
||||
foreach (LightSourceParams lightSourceParams in selectedLevelObject.LightSourceParams)
|
||||
{
|
||||
new SerializableEntityEditor(editorContainer.Content.RectTransform, lightSourceParams, inGame: false, showName: true);
|
||||
@@ -696,9 +689,9 @@ namespace Barotrauma
|
||||
{
|
||||
var levelObj = levelObjFrame.UserData as LevelObjectPrefab;
|
||||
float commonness = levelObj.GetCommonness(selectedParams);
|
||||
levelObjFrame.Color = commonness > 0.0f ? GUI.Style.Green * 0.4f : Color.Transparent;
|
||||
levelObjFrame.SelectedColor = commonness > 0.0f ? GUI.Style.Green * 0.6f : Color.White * 0.5f;
|
||||
levelObjFrame.HoverColor = commonness > 0.0f ? GUI.Style.Green * 0.7f : Color.White * 0.6f;
|
||||
levelObjFrame.Color = commonness > 0.0f ? GUIStyle.Green * 0.4f : Color.Transparent;
|
||||
levelObjFrame.SelectedColor = commonness > 0.0f ? GUIStyle.Green * 0.6f : Color.White * 0.5f;
|
||||
levelObjFrame.HoverColor = commonness > 0.0f ? GUIStyle.Green * 0.7f : Color.White * 0.6f;
|
||||
|
||||
levelObjFrame.GetAnyChild<GUIImage>().Color = commonness > 0.0f ? Color.White : Color.DarkGray;
|
||||
if (commonness <= 0.0f)
|
||||
@@ -735,20 +728,20 @@ namespace Barotrauma
|
||||
{
|
||||
if (lightingEnabled.Selected)
|
||||
{
|
||||
GameMain.LightManager.RenderLightMap(graphics, spriteBatch, cam);
|
||||
GameMain.LightManager.RenderLightMap(graphics, spriteBatch, Cam);
|
||||
}
|
||||
graphics.Clear(Color.Black);
|
||||
|
||||
if (Level.Loaded != null)
|
||||
{
|
||||
Level.Loaded.DrawBack(graphics, spriteBatch, cam);
|
||||
Level.Loaded.DrawFront(spriteBatch, cam);
|
||||
spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.NonPremultiplied, SamplerState.LinearWrap, DepthStencilState.DepthRead, transformMatrix: cam.Transform);
|
||||
Level.Loaded.DrawDebugOverlay(spriteBatch, cam);
|
||||
Level.Loaded.DrawBack(graphics, spriteBatch, Cam);
|
||||
Level.Loaded.DrawFront(spriteBatch, Cam);
|
||||
spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.NonPremultiplied, SamplerState.LinearWrap, DepthStencilState.DepthRead, transformMatrix: Cam.Transform);
|
||||
Level.Loaded.DrawDebugOverlay(spriteBatch, Cam);
|
||||
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.Gray, 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));
|
||||
|
||||
for (int i = 0; i < Level.Loaded.Tunnels.Count; i++)
|
||||
{
|
||||
@@ -758,21 +751,21 @@ namespace Barotrauma
|
||||
{
|
||||
Vector2 start = new Vector2(tunnel.Nodes[j - 1].X, -tunnel.Nodes[j - 1].Y);
|
||||
Vector2 end = new Vector2(tunnel.Nodes[j].X, -tunnel.Nodes[j].Y);
|
||||
GUI.DrawLine(spriteBatch, start, end, tunnelColor, width: (int)(2.0f / cam.Zoom));
|
||||
GUI.DrawLine(spriteBatch, start, end, tunnelColor, width: (int)(2.0f / Cam.Zoom));
|
||||
}
|
||||
}
|
||||
|
||||
foreach (Level.InterestingPosition interestingPos in Level.Loaded.PositionsOfInterest)
|
||||
{
|
||||
if (interestingPos.Position.X < cam.WorldView.X || interestingPos.Position.X > cam.WorldView.Right ||
|
||||
interestingPos.Position.Y > cam.WorldView.Y || interestingPos.Position.Y < cam.WorldView.Y - cam.WorldView.Height)
|
||||
if (interestingPos.Position.X < Cam.WorldView.X || interestingPos.Position.X > Cam.WorldView.Right ||
|
||||
interestingPos.Position.Y > Cam.WorldView.Y || interestingPos.Position.Y < Cam.WorldView.Y - Cam.WorldView.Height)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Vector2 pos = new Vector2(interestingPos.Position.X, -interestingPos.Position.Y);
|
||||
spriteBatch.DrawCircle(pos, 500, 6, Color.White * 0.5f, thickness: (int)(2 / cam.Zoom));
|
||||
GUI.DrawString(spriteBatch, pos, interestingPos.PositionType.ToString(), Color.White, font: GUI.LargeFont);
|
||||
spriteBatch.DrawCircle(pos, 500, 6, Color.White * 0.5f, thickness: (int)(2 / Cam.Zoom));
|
||||
GUI.DrawString(spriteBatch, pos, interestingPos.PositionType.ToString(), Color.White, font: GUIStyle.LargeFont);
|
||||
}
|
||||
|
||||
// TODO: Improve this temporary level editor debug solution (or remove it)
|
||||
@@ -785,17 +778,17 @@ namespace Barotrauma
|
||||
foreach (var resource in location.Resources)
|
||||
{
|
||||
Vector2 resourcePos = new Vector2(resource.Position.X, -resource.Position.Y);
|
||||
spriteBatch.DrawCircle(resourcePos, 100, 6, Color.DarkGreen * 0.5f, thickness: (int)(2 / cam.Zoom));
|
||||
GUI.DrawString(spriteBatch, resourcePos, resource.Name, Color.DarkGreen, font: GUI.LargeFont);
|
||||
spriteBatch.DrawCircle(resourcePos, 100, 6, Color.DarkGreen * 0.5f, thickness: (int)(2 / Cam.Zoom));
|
||||
GUI.DrawString(spriteBatch, resourcePos, resource.Name, Color.DarkGreen, font: GUIStyle.LargeFont);
|
||||
var dist = Vector2.Distance(resourcePos, pathPointPos);
|
||||
var lineStartPos = Vector2.Lerp(resourcePos, pathPointPos, 110 / dist);
|
||||
var lineEndPos = Vector2.Lerp(pathPointPos, resourcePos, 310 / dist);
|
||||
GUI.DrawLine(spriteBatch, lineStartPos, lineEndPos, Color.DarkGreen * 0.5f, width: (int)(2 / cam.Zoom));
|
||||
GUI.DrawLine(spriteBatch, lineStartPos, lineEndPos, Color.DarkGreen * 0.5f, width: (int)(2 / Cam.Zoom));
|
||||
}
|
||||
}
|
||||
var color = pathPoint.ShouldContainResources ? Color.DarkGreen : Color.DarkRed;
|
||||
spriteBatch.DrawCircle(pathPointPos, 300, 6, color * 0.5f, thickness: (int)(2 / cam.Zoom));
|
||||
GUI.DrawString(spriteBatch, pathPointPos, "Path Point\n" + pathPoint.Id, color, font: GUI.LargeFont);
|
||||
spriteBatch.DrawCircle(pathPointPos, 300, 6, color * 0.5f, thickness: (int)(2 / Cam.Zoom));
|
||||
GUI.DrawString(spriteBatch, pathPointPos, "Path Point\n" + pathPoint.Id, color, font: GUIStyle.LargeFont);
|
||||
}
|
||||
|
||||
/*for (int i = 0; i < Level.Loaded.distanceField.Count; i++)
|
||||
@@ -833,24 +826,24 @@ 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;
|
||||
float crushDepthScreen = Cam.WorldToScreen(new Vector2(0.0f, -Level.Loaded.CrushDepth)).Y;
|
||||
if (crushDepthScreen > 0.0f && crushDepthScreen < GameMain.GraphicsHeight)
|
||||
{
|
||||
GUI.DrawLine(spriteBatch, new Vector2(0, crushDepthScreen), new Vector2(GameMain.GraphicsWidth, crushDepthScreen), GUI.Style.Red * 0.25f, width: 5);
|
||||
GUI.DrawString(spriteBatch, new Vector2(GameMain.GraphicsWidth / 2, crushDepthScreen), "Crush depth", GUI.Style.Red, backgroundColor: Color.Black);
|
||||
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 abyssStartScreen = cam.WorldToScreen(new Vector2(0.0f, Level.Loaded.AbyssArea.Bottom)).Y;
|
||||
float abyssStartScreen = Cam.WorldToScreen(new Vector2(0.0f, Level.Loaded.AbyssArea.Bottom)).Y;
|
||||
if (abyssStartScreen > 0.0f && abyssStartScreen < GameMain.GraphicsHeight)
|
||||
{
|
||||
GUI.DrawLine(spriteBatch, new Vector2(0, abyssStartScreen), new Vector2(GameMain.GraphicsWidth, abyssStartScreen), GUI.Style.Blue * 0.25f, width: 5);
|
||||
GUI.DrawString(spriteBatch, new Vector2(GameMain.GraphicsWidth / 2, abyssStartScreen), "Abyss start", GUI.Style.Blue, backgroundColor: Color.Black);
|
||||
GUI.DrawLine(spriteBatch, new Vector2(0, abyssStartScreen), new Vector2(GameMain.GraphicsWidth, abyssStartScreen), GUIStyle.Blue * 0.25f, width: 5);
|
||||
GUI.DrawString(spriteBatch, new Vector2(GameMain.GraphicsWidth / 2, abyssStartScreen), "Abyss start", GUIStyle.Blue, backgroundColor: Color.Black);
|
||||
}
|
||||
float abyssEndScreen = cam.WorldToScreen(new Vector2(0.0f, Level.Loaded.AbyssArea.Y)).Y;
|
||||
float abyssEndScreen = Cam.WorldToScreen(new Vector2(0.0f, Level.Loaded.AbyssArea.Y)).Y;
|
||||
if (abyssEndScreen > 0.0f && abyssEndScreen < GameMain.GraphicsHeight)
|
||||
{
|
||||
GUI.DrawLine(spriteBatch, new Vector2(0, abyssEndScreen), new Vector2(GameMain.GraphicsWidth, abyssEndScreen), GUI.Style.Blue * 0.25f, width: 5);
|
||||
GUI.DrawString(spriteBatch, new Vector2(GameMain.GraphicsWidth / 2, abyssEndScreen), "Abyss end", GUI.Style.Blue, backgroundColor: Color.Black);
|
||||
GUI.DrawLine(spriteBatch, new Vector2(0, abyssEndScreen), new Vector2(GameMain.GraphicsWidth, abyssEndScreen), GUIStyle.Blue * 0.25f, width: 5);
|
||||
GUI.DrawString(spriteBatch, new Vector2(GameMain.GraphicsWidth / 2, abyssEndScreen), "Abyss end", GUIStyle.Blue, backgroundColor: Color.Black);
|
||||
}
|
||||
}
|
||||
GUI.Draw(Cam, spriteBatch);
|
||||
@@ -863,17 +856,17 @@ namespace Barotrauma
|
||||
{
|
||||
foreach (Item item in Item.ItemList)
|
||||
{
|
||||
item?.GetComponent<Items.Components.LightComponent>()?.Update((float)deltaTime, cam);
|
||||
item?.GetComponent<Items.Components.LightComponent>()?.Update((float)deltaTime, Cam);
|
||||
}
|
||||
}
|
||||
GameMain.LightManager?.Update((float)deltaTime);
|
||||
|
||||
pointerLightSource.Position = cam.ScreenToWorld(PlayerInput.MousePosition);
|
||||
pointerLightSource.Position = Cam.ScreenToWorld(PlayerInput.MousePosition);
|
||||
pointerLightSource.Enabled = cursorLightEnabled.Selected;
|
||||
pointerLightSource.IsBackground = true;
|
||||
cam.MoveCamera((float)deltaTime, allowZoom: GUI.MouseOn == null);
|
||||
cam.UpdateTransform();
|
||||
Level.Loaded?.Update((float)deltaTime, cam);
|
||||
Cam.MoveCamera((float)deltaTime, allowZoom: GUI.MouseOn == null);
|
||||
Cam.UpdateTransform();
|
||||
Level.Loaded?.Update((float)deltaTime, Cam);
|
||||
|
||||
if (editingSprite != null)
|
||||
{
|
||||
@@ -888,7 +881,7 @@ namespace Barotrauma
|
||||
Indent = true,
|
||||
NewLineOnAttributes = true
|
||||
};
|
||||
foreach (ContentFile configFile in GameMain.Instance.GetFilesOfType(ContentType.LevelGenerationParameters))
|
||||
foreach (var configFile in ContentPackageManager.AllPackages.SelectMany(p => p.GetFiles<LevelGenerationParametersFile>()))
|
||||
{
|
||||
XDocument doc = XMLExtensions.TryLoadXml(configFile.Path);
|
||||
if (doc == null) { continue; }
|
||||
@@ -899,7 +892,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (element.IsOverride())
|
||||
{
|
||||
foreach (XElement subElement in element.Elements())
|
||||
foreach (var subElement in element.Elements())
|
||||
{
|
||||
string id = element.GetAttributeString("identifier", null) ?? element.Name.ToString();
|
||||
if (!id.Equals(genParams.Name, StringComparison.OrdinalIgnoreCase)) { continue; }
|
||||
@@ -915,14 +908,14 @@ namespace Barotrauma
|
||||
break;
|
||||
}
|
||||
}
|
||||
using (var writer = XmlWriter.Create(configFile.Path, settings))
|
||||
using (var writer = XmlWriter.Create(configFile.Path.Value, settings))
|
||||
{
|
||||
doc.WriteTo(writer);
|
||||
writer.Flush();
|
||||
}
|
||||
}
|
||||
|
||||
foreach (ContentFile configFile in GameMain.Instance.GetFilesOfType(ContentType.CaveGenerationParameters))
|
||||
foreach (var configFile in ContentPackageManager.AllPackages.SelectMany(p => p.GetFiles<CaveGenerationParametersFile>()))
|
||||
{
|
||||
XDocument doc = XMLExtensions.TryLoadXml(configFile.Path);
|
||||
if (doc == null) { continue; }
|
||||
@@ -933,7 +926,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (element.IsOverride())
|
||||
{
|
||||
foreach (XElement subElement in element.Elements())
|
||||
foreach (var subElement in element.Elements())
|
||||
{
|
||||
string id = subElement.GetAttributeString("identifier", null) ?? subElement.Name.ToString();
|
||||
if (!id.Equals(genParams.Name, StringComparison.OrdinalIgnoreCase)) { continue; }
|
||||
@@ -949,7 +942,7 @@ namespace Barotrauma
|
||||
break;
|
||||
}
|
||||
}
|
||||
using (var writer = XmlWriter.Create(configFile.Path, settings))
|
||||
using (var writer = XmlWriter.Create(configFile.Path.Value, settings))
|
||||
{
|
||||
doc.WriteTo(writer);
|
||||
writer.Flush();
|
||||
@@ -957,22 +950,22 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
settings.NewLineOnAttributes = false;
|
||||
foreach (ContentFile configFile in GameMain.Instance.GetFilesOfType(ContentType.LevelObjectPrefabs))
|
||||
foreach (var configFile in ContentPackageManager.AllPackages.SelectMany(p => p.GetFiles<LevelObjectPrefabsFile>()))
|
||||
{
|
||||
XDocument doc = XMLExtensions.TryLoadXml(configFile.Path);
|
||||
if (doc == null) { continue; }
|
||||
|
||||
foreach (LevelObjectPrefab levelObjPrefab in LevelObjectPrefab.List)
|
||||
foreach (LevelObjectPrefab levelObjPrefab in LevelObjectPrefab.Prefabs)
|
||||
{
|
||||
foreach (XElement element in doc.Root.Elements())
|
||||
{
|
||||
string identifier = element.GetAttributeString("identifier", null);
|
||||
if (!identifier.Equals(levelObjPrefab.Identifier, StringComparison.OrdinalIgnoreCase)) { continue; }
|
||||
Identifier identifier = element.GetAttributeIdentifier("identifier", "");
|
||||
if (identifier != levelObjPrefab.Identifier) { continue; }
|
||||
levelObjPrefab.Save(element);
|
||||
break;
|
||||
}
|
||||
}
|
||||
using (var writer = XmlWriter.Create(configFile.Path, settings))
|
||||
using (var writer = XmlWriter.Create(configFile.Path.Value, settings))
|
||||
{
|
||||
doc.WriteTo(writer);
|
||||
writer.Flush();
|
||||
@@ -984,7 +977,7 @@ namespace Barotrauma
|
||||
|
||||
private void Serialize(LevelGenerationParams genParams)
|
||||
{
|
||||
foreach (ContentFile configFile in GameMain.Instance.GetFilesOfType(ContentType.LevelGenerationParameters))
|
||||
foreach (var configFile in ContentPackageManager.AllPackages.SelectMany(p => p.GetFiles<LevelGenerationParametersFile>()))
|
||||
{
|
||||
XDocument doc = XMLExtensions.TryLoadXml(configFile.Path);
|
||||
if (doc == null) { continue; }
|
||||
@@ -1006,7 +999,7 @@ namespace Barotrauma
|
||||
NewLineOnAttributes = true
|
||||
};
|
||||
|
||||
using (var writer = XmlWriter.Create(configFile.Path, settings))
|
||||
using (var writer = XmlWriter.Create(configFile.Path.Value, settings))
|
||||
{
|
||||
doc.WriteTo(writer);
|
||||
writer.Flush();
|
||||
@@ -1043,7 +1036,7 @@ namespace Barotrauma
|
||||
public GUIMessageBox Create()
|
||||
{
|
||||
var box = new GUIMessageBox(TextManager.Get("leveleditor.createlevelobj"), string.Empty,
|
||||
new string[] { TextManager.Get("cancel"), TextManager.Get("done") }, new Vector2(0.5f, 0.8f));
|
||||
new LocalizedString[] { TextManager.Get("cancel"), TextManager.Get("done") }, new Vector2(0.5f, 0.8f));
|
||||
|
||||
box.Content.ChildAnchor = Anchor.TopCenter;
|
||||
box.Content.AbsoluteSpacing = 20;
|
||||
@@ -1057,14 +1050,15 @@ namespace Barotrauma
|
||||
new GUITextBlock(new RectTransform(new Point(listBox.Content.Rect.Width, elementSize), listBox.Content.RectTransform),
|
||||
TextManager.Get("leveleditor.levelobjtexturepath")) { CanBeFocused = false };
|
||||
var texturePathBox = new GUITextBox(new RectTransform(new Point(listBox.Content.Rect.Width, elementSize), listBox.Content.RectTransform));
|
||||
foreach (LevelObjectPrefab prefab in LevelObjectPrefab.List)
|
||||
foreach (LevelObjectPrefab prefab in LevelObjectPrefab.Prefabs)
|
||||
{
|
||||
if (prefab.Sprites.FirstOrDefault() == null) continue;
|
||||
texturePathBox.Text = Path.GetDirectoryName(prefab.Sprites.FirstOrDefault().FilePath);
|
||||
texturePathBox.Text = Path.GetDirectoryName(prefab.Sprites.FirstOrDefault().FilePath.Value);
|
||||
break;
|
||||
}
|
||||
|
||||
newPrefab = new LevelObjectPrefab(null);
|
||||
//this is nasty :(
|
||||
newPrefab = new LevelObjectPrefab(null, null, Identifier.Empty);
|
||||
|
||||
new SerializableEntityEditor(listBox.Content.RectTransform, newPrefab, false, false);
|
||||
|
||||
@@ -1078,51 +1072,62 @@ namespace Barotrauma
|
||||
{
|
||||
if (string.IsNullOrEmpty(nameBox.Text))
|
||||
{
|
||||
nameBox.Flash(GUI.Style.Red);
|
||||
GUI.AddMessage(TextManager.Get("leveleditor.levelobjnameempty"), GUI.Style.Red);
|
||||
nameBox.Flash(GUIStyle.Red);
|
||||
GUI.AddMessage(TextManager.Get("leveleditor.levelobjnameempty"), GUIStyle.Red);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (LevelObjectPrefab.List.Any(obj => obj.Identifier.Equals(nameBox.Text, StringComparison.OrdinalIgnoreCase)))
|
||||
if (LevelObjectPrefab.Prefabs.Any(obj => obj.Identifier == nameBox.Text))
|
||||
{
|
||||
nameBox.Flash(GUI.Style.Red);
|
||||
GUI.AddMessage(TextManager.Get("leveleditor.levelobjnametaken"), GUI.Style.Red);
|
||||
nameBox.Flash(GUIStyle.Red);
|
||||
GUI.AddMessage(TextManager.Get("leveleditor.levelobjnametaken"), GUIStyle.Red);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!File.Exists(texturePathBox.Text))
|
||||
{
|
||||
texturePathBox.Flash(GUI.Style.Red);
|
||||
GUI.AddMessage(TextManager.Get("leveleditor.levelobjtexturenotfound"), GUI.Style.Red);
|
||||
texturePathBox.Flash(GUIStyle.Red);
|
||||
GUI.AddMessage(TextManager.Get("leveleditor.levelobjtexturenotfound"), GUIStyle.Red);
|
||||
return false;
|
||||
}
|
||||
|
||||
newPrefab.Identifier = nameBox.Text;
|
||||
|
||||
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);
|
||||
if (doc == null) { continue; }
|
||||
var newElement = new XElement(newPrefab.Identifier);
|
||||
newPrefab.Save(newElement);
|
||||
newElement.Add(new XElement("Sprite",
|
||||
new XAttribute("texture", texturePathBox.Text),
|
||||
new XAttribute("sourcerect", "0,0,100,100"),
|
||||
new XAttribute("origin", "0.5,0.5")));
|
||||
|
||||
doc.Root.Add(newElement);
|
||||
using (var writer = XmlWriter.Create(configFile.Path, settings))
|
||||
{
|
||||
doc.WriteTo(writer);
|
||||
writer.Flush();
|
||||
}
|
||||
// Recreate the prefab so that the sprite loads correctly: TODO: consider a better way to do this
|
||||
newPrefab = new LevelObjectPrefab(newElement);
|
||||
break;
|
||||
}
|
||||
var newElement = new XElement(nameBox.Text);
|
||||
newPrefab.Save(newElement);
|
||||
newElement.Add(new XElement("Sprite",
|
||||
new XAttribute("texture", texturePathBox.Text),
|
||||
new XAttribute("sourcerect", "0,0,100,100"),
|
||||
new XAttribute("origin", "0.5,0.5")));
|
||||
|
||||
LevelObjectPrefab.List.Add(newPrefab);
|
||||
// Create a new mod for the purpose of providing this new prefab
|
||||
#warning TODO: add a clear way to tack it into an existing content package?
|
||||
string modDir = Path.Combine(ContentPackage.LocalModsDir, nameBox.Text);
|
||||
Directory.CreateDirectory(modDir);
|
||||
|
||||
string fileListPath = Path.Combine(modDir, ContentPackage.FileListFileName);
|
||||
string prefabFilePath = Path.Combine(modDir, $"{nameBox.Text}.xml");
|
||||
|
||||
var newMod = new ModProject { Name = nameBox.Text };
|
||||
var newFile = ModProject.File.FromPath<LevelObjectPrefabsFile>(prefabFilePath);
|
||||
newMod.AddFile(newFile);
|
||||
|
||||
XDocument fileListDoc = newMod.ToXDocument();
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(fileListPath));
|
||||
using (XmlWriter writer = XmlWriter.Create(fileListPath, settings)) { fileListDoc.Save(writer); }
|
||||
|
||||
XDocument prefabDoc = new XDocument();
|
||||
var prefabFileRoot = new XElement("LevelObjects");
|
||||
prefabFileRoot.Add(newElement);
|
||||
prefabDoc.Add(prefabFileRoot);
|
||||
using (XmlWriter writer = XmlWriter.Create(prefabFilePath, settings)) { prefabDoc.Save(writer); }
|
||||
|
||||
ContentPackageManager.UpdateContentPackageList();
|
||||
|
||||
var newRegularList = ContentPackageManager.EnabledPackages.Regular.ToList();
|
||||
newRegularList.Add(ContentPackageManager.RegularPackages.First(p => p.Name == nameBox.Text));
|
||||
ContentPackageManager.EnabledPackages.SetRegular(newRegularList);
|
||||
|
||||
GameMain.LevelEditorScreen.UpdateLevelObjectsList();
|
||||
|
||||
box.Close();
|
||||
|
||||
Reference in New Issue
Block a user