v0.11.0.9
This commit is contained in:
+4
-1
@@ -372,6 +372,9 @@ namespace Barotrauma.CharacterEditor
|
||||
{
|
||||
base.Update(deltaTime);
|
||||
if (Wizard.instance != null) { return; }
|
||||
|
||||
GameMain.LightManager?.Update((float)deltaTime);
|
||||
|
||||
spriteSheetRect = CalculateSpritesheetRectangle();
|
||||
// Handle shortcut keys
|
||||
if (PlayerInput.KeyHit(Keys.F1))
|
||||
@@ -787,7 +790,7 @@ namespace Barotrauma.CharacterEditor
|
||||
if (GameMain.LightManager.LightingEnabled)
|
||||
{
|
||||
GameMain.LightManager.ObstructVision = Character.Controlled.ObstructVision;
|
||||
GameMain.LightManager.UpdateLightMap(graphics, spriteBatch, cam);
|
||||
GameMain.LightManager.RenderLightMap(graphics, spriteBatch, cam);
|
||||
GameMain.LightManager.UpdateObstructVision(graphics, spriteBatch, cam, Character.Controlled.CursorWorldPosition);
|
||||
}
|
||||
base.Draw(deltaTime, graphics, spriteBatch);
|
||||
|
||||
@@ -186,7 +186,7 @@ namespace Barotrauma
|
||||
spriteBatch.End();
|
||||
|
||||
graphics.SetRenderTarget(null);
|
||||
GameMain.LightManager.UpdateLightMap(graphics, spriteBatch, cam, renderTarget);
|
||||
GameMain.LightManager.RenderLightMap(graphics, spriteBatch, cam, renderTarget);
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
graphics.SetRenderTarget(renderTargetBackground);
|
||||
|
||||
@@ -24,24 +24,26 @@ namespace Barotrauma
|
||||
get { return cam; }
|
||||
}
|
||||
|
||||
private GUIFrame leftPanel, rightPanel, bottomPanel, topPanel;
|
||||
private readonly GUIFrame leftPanel, rightPanel, bottomPanel, topPanel;
|
||||
|
||||
private LevelGenerationParams selectedParams;
|
||||
private LevelObjectPrefab selectedLevelObject;
|
||||
|
||||
private GUIListBox paramsList, ruinParamsList, outpostParamsList, levelObjectList;
|
||||
private GUIListBox editorContainer;
|
||||
private readonly GUIListBox paramsList, ruinParamsList, caveParamsList, outpostParamsList, levelObjectList;
|
||||
private readonly GUIListBox editorContainer;
|
||||
|
||||
private GUIButton spriteEditDoneButton;
|
||||
private readonly GUIButton spriteEditDoneButton;
|
||||
|
||||
private GUITextBox seedBox;
|
||||
private readonly GUITextBox seedBox;
|
||||
|
||||
private GUITickBox lightingEnabled, cursorLightEnabled;
|
||||
private readonly GUITickBox lightingEnabled, cursorLightEnabled;
|
||||
|
||||
private Sprite editingSprite;
|
||||
|
||||
private LightSource pointerLightSource;
|
||||
|
||||
private readonly Color[] tunnelDebugColors = new Color[] { Color.White, Color.Cyan, Color.LightGreen, Color.Red, Color.LightYellow, Color.LightSeaGreen };
|
||||
|
||||
public LevelEditorScreen()
|
||||
{
|
||||
cam = new Camera()
|
||||
@@ -78,8 +80,17 @@ 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);
|
||||
|
||||
caveParamsList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.1f), paddedLeftPanel.RectTransform));
|
||||
caveParamsList.OnSelected += (GUIComponent component, object obj) =>
|
||||
{
|
||||
CreateCaveParamsEditor(obj as CaveGenerationParams);
|
||||
return true;
|
||||
};
|
||||
|
||||
var outpostTitle = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), paddedLeftPanel.RectTransform), TextManager.Get("leveleditor.outpostparams"), font: GUI.SubHeadingFont);
|
||||
GUITextBlock.AutoScaleAndNormalize(ruinTitle, outpostTitle);
|
||||
GUITextBlock.AutoScaleAndNormalize(ruinTitle, caveTitle, outpostTitle);
|
||||
|
||||
outpostParamsList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.2f), paddedLeftPanel.RectTransform));
|
||||
outpostParamsList.OnSelected += (GUIComponent component, object obj) =>
|
||||
@@ -237,13 +248,17 @@ namespace Barotrauma
|
||||
{
|
||||
OnClicked = (btn, obj) =>
|
||||
{
|
||||
bool wasLevelLoaded = Level.Loaded != null;
|
||||
Submarine.Unload();
|
||||
GameMain.LightManager.ClearLights();
|
||||
LevelData levelData = LevelData.CreateRandom(seedBox.Text, generationParams: selectedParams);
|
||||
levelData.ForceOutpostGenerationParams = outpostParamsList.SelectedData as OutpostGenerationParams;
|
||||
Level.Generate(levelData, mirror: false);
|
||||
GameMain.LightManager.AddLight(pointerLightSource);
|
||||
cam.Position = new Vector2(Level.Loaded.Size.X / 2, Level.Loaded.Size.Y / 2);
|
||||
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);
|
||||
}
|
||||
foreach (GUITextBlock param in paramsList.Content.Children)
|
||||
{
|
||||
param.TextColor = param.UserData == selectedParams ? GUI.Style.Green : param.Style.TextColor;
|
||||
@@ -344,6 +359,7 @@ namespace Barotrauma
|
||||
editingSprite = null;
|
||||
UpdateParamsList();
|
||||
UpdateRuinParamsList();
|
||||
UpdateCaveParamsList();
|
||||
UpdateOutpostParamsList();
|
||||
UpdateLevelObjectsList();
|
||||
}
|
||||
@@ -371,6 +387,22 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateCaveParamsList()
|
||||
{
|
||||
editorContainer.ClearChildren();
|
||||
caveParamsList.Content.ClearChildren();
|
||||
|
||||
foreach (CaveGenerationParams genParams in CaveGenerationParams.CaveParams)
|
||||
{
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), caveParamsList.Content.RectTransform) { MinSize = new Point(0, 20) },
|
||||
genParams.Name)
|
||||
{
|
||||
Padding = Vector4.Zero,
|
||||
UserData = genParams
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateRuinParamsList()
|
||||
{
|
||||
editorContainer.ClearChildren();
|
||||
@@ -425,6 +457,7 @@ namespace Barotrauma
|
||||
text: ToolBox.LimitString(levelObjPrefab.Name, GUI.SmallFont, paddedFrame.Rect.Width), textAlignment: Alignment.Center, font: GUI.SmallFont)
|
||||
{
|
||||
CanBeFocused = false,
|
||||
ToolTip = levelObjPrefab.Name
|
||||
};
|
||||
|
||||
Sprite sprite = levelObjPrefab.Sprites.FirstOrDefault() ?? levelObjPrefab.DeformableSprite?.Sprite;
|
||||
@@ -437,15 +470,14 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateLevelObjectEditor(LevelObjectPrefab levelObjectPrefab)
|
||||
private void CreateCaveParamsEditor(CaveGenerationParams caveGenerationParams)
|
||||
{
|
||||
editorContainer.ClearChildren();
|
||||
|
||||
var editor = new SerializableEntityEditor(editorContainer.Content.RectTransform, levelObjectPrefab, false, true, elementHeight: 20, titleFont: GUI.LargeFont);
|
||||
var editor = new SerializableEntityEditor(editorContainer.Content.RectTransform, caveGenerationParams, false, true, elementHeight: 20);
|
||||
|
||||
if (selectedParams != null)
|
||||
{
|
||||
var commonnessContainer = new GUILayoutGroup(new RectTransform(new Point(editor.Rect.Width, 70)) { IsFixedSize = true },
|
||||
var commonnessContainer = new GUILayoutGroup(new RectTransform(new Point(editor.Rect.Width, 70)) { IsFixedSize = true },
|
||||
isHorizontal: false, childAnchor: Anchor.TopCenter)
|
||||
{
|
||||
AbsoluteSpacing = 5,
|
||||
@@ -457,15 +489,60 @@ namespace Barotrauma
|
||||
{
|
||||
MinValueFloat = 0,
|
||||
MaxValueFloat = 100,
|
||||
FloatValue = levelObjectPrefab.GetCommonness(selectedParams.Identifier),
|
||||
FloatValue = caveGenerationParams.GetCommonness(selectedParams),
|
||||
OnValueChanged = (numberInput) =>
|
||||
{
|
||||
levelObjectPrefab.OverrideCommonness[selectedParams.Identifier] = numberInput.FloatValue;
|
||||
caveGenerationParams.OverrideCommonness[selectedParams.Identifier] = numberInput.FloatValue;
|
||||
}
|
||||
};
|
||||
new GUIFrame(new RectTransform(new Vector2(1.0f, 0.2f), commonnessContainer.RectTransform), style: null);
|
||||
editor.AddCustomContent(commonnessContainer, 1);
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateLevelObjectEditor(LevelObjectPrefab levelObjectPrefab)
|
||||
{
|
||||
editorContainer.ClearChildren();
|
||||
|
||||
var editor = new SerializableEntityEditor(editorContainer.Content.RectTransform, levelObjectPrefab, false, true, elementHeight: 20, titleFont: GUI.LargeFont);
|
||||
|
||||
if (selectedParams != null)
|
||||
{
|
||||
List<string> availableIdentifiers = new List<string>();
|
||||
{
|
||||
if (selectedParams != null) { availableIdentifiers.Add(selectedParams.Identifier); }
|
||||
}
|
||||
foreach (var caveParam in CaveGenerationParams.CaveParams)
|
||||
{
|
||||
if (selectedParams != null && caveParam.GetCommonness(selectedParams) <= 0.0f) { continue; }
|
||||
availableIdentifiers.Add(caveParam.Identifier);
|
||||
}
|
||||
availableIdentifiers.Reverse();
|
||||
|
||||
foreach (string paramsId in availableIdentifiers)
|
||||
{
|
||||
var commonnessContainer = new GUILayoutGroup(new RectTransform(new Point(editor.Rect.Width, 70)) { IsFixedSize = true },
|
||||
isHorizontal: false, childAnchor: Anchor.TopCenter)
|
||||
{
|
||||
AbsoluteSpacing = 5,
|
||||
Stretch = true
|
||||
};
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.4f), commonnessContainer.RectTransform),
|
||||
TextManager.GetWithVariable("leveleditor.levelobjcommonness", "[leveltype]", paramsId), textAlignment: Alignment.Center);
|
||||
new GUINumberInput(new RectTransform(new Vector2(0.5f, 0.4f), commonnessContainer.RectTransform), GUINumberInput.NumberType.Float)
|
||||
{
|
||||
MinValueFloat = 0,
|
||||
MaxValueFloat = 100,
|
||||
FloatValue = selectedParams.Identifier == paramsId ? levelObjectPrefab.GetCommonness(selectedParams) : levelObjectPrefab.GetCommonness(CaveGenerationParams.CaveParams.Find(p => p.Identifier == paramsId)),
|
||||
OnValueChanged = (numberInput) =>
|
||||
{
|
||||
levelObjectPrefab.OverrideCommonness[paramsId] = numberInput.FloatValue;
|
||||
}
|
||||
};
|
||||
new GUIFrame(new RectTransform(new Vector2(1.0f, 0.2f), commonnessContainer.RectTransform), style: null);
|
||||
editor.AddCustomContent(commonnessContainer, 1);
|
||||
}
|
||||
}
|
||||
|
||||
Sprite sprite = levelObjectPrefab.Sprites.FirstOrDefault() ?? levelObjectPrefab.DeformableSprite?.Sprite;
|
||||
if (sprite != null)
|
||||
@@ -508,7 +585,7 @@ namespace Barotrauma
|
||||
foreach (LevelObjectPrefab objPrefab in LevelObjectPrefab.List)
|
||||
{
|
||||
dropdown.AddItem(objPrefab.Name, objPrefab);
|
||||
if (childObj.AllowedNames.Contains(objPrefab.Name)) dropdown.SelectItem(objPrefab);
|
||||
if (childObj.AllowedNames.Contains(objPrefab.Name)) { dropdown.SelectItem(objPrefab); }
|
||||
}
|
||||
dropdown.OnSelected = (selected, obj) =>
|
||||
{
|
||||
@@ -590,7 +667,7 @@ namespace Barotrauma
|
||||
foreach (GUIComponent levelObjFrame in levelObjectList.Content.Children)
|
||||
{
|
||||
var levelObj = levelObjFrame.UserData as LevelObjectPrefab;
|
||||
float commonness = levelObj.GetCommonness(selectedParams.Identifier);
|
||||
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;
|
||||
@@ -607,7 +684,7 @@ namespace Barotrauma
|
||||
{
|
||||
var levelObj1 = c1.GUIComponent.UserData as LevelObjectPrefab;
|
||||
var levelObj2 = c2.GUIComponent.UserData as LevelObjectPrefab;
|
||||
return Math.Sign(levelObj2.GetCommonness(selectedParams.Identifier) - levelObj1.GetCommonness(selectedParams.Identifier));
|
||||
return Math.Sign(levelObj2.GetCommonness(selectedParams) - levelObj1.GetCommonness(selectedParams));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -630,7 +707,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (lightingEnabled.Selected)
|
||||
{
|
||||
GameMain.LightManager.UpdateLightMap(graphics, spriteBatch, cam);
|
||||
GameMain.LightManager.RenderLightMap(graphics, spriteBatch, cam);
|
||||
}
|
||||
graphics.Clear(Color.Black);
|
||||
|
||||
@@ -643,6 +720,72 @@ namespace Barotrauma
|
||||
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));
|
||||
|
||||
for (int i = 0; i < Level.Loaded.Tunnels.Count; i++)
|
||||
{
|
||||
var tunnel = Level.Loaded.Tunnels[i];
|
||||
Color tunnelColor = tunnelDebugColors[i % tunnelDebugColors.Length] * 0.2f;
|
||||
for (int j = 1; j < tunnel.Nodes.Count; j++)
|
||||
{
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
// TODO: Improve this temporary level editor debug solution (or remove it)
|
||||
foreach (var pathPoint in Level.Loaded.PathPoints)
|
||||
{
|
||||
Vector2 pathPointPos = new Vector2(pathPoint.Position.X, -pathPoint.Position.Y);
|
||||
foreach (var location in pathPoint.ClusterLocations)
|
||||
{
|
||||
if (location.Resources == null) { continue; }
|
||||
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);
|
||||
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));
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
/*for (int i = 0; i < Level.Loaded.distanceField.Count; i++)
|
||||
{
|
||||
GUI.DrawRectangle(spriteBatch,
|
||||
new Vector2(Level.Loaded.distanceField[i].First.X, -Level.Loaded.distanceField[i].First.Y),
|
||||
Vector2.One * 5 / cam.Zoom,
|
||||
ToolBox.GradientLerp((float)(Level.Loaded.distanceField[i].Second / 20000.0), Color.Red, Color.Orange, Color.Yellow, Color.LightGreen),
|
||||
isFilled: true);
|
||||
}*/
|
||||
/*for (int i = 0; i < Level.Loaded.siteCoordsX.Count; i++)
|
||||
{
|
||||
GUI.DrawRectangle(spriteBatch,
|
||||
new Vector2((float)Level.Loaded.siteCoordsX[i], -(float)Level.Loaded.siteCoordsY[i]),
|
||||
Vector2.One * 5 / cam.Zoom,
|
||||
Color.Red,
|
||||
isFilled: true);
|
||||
}*/
|
||||
|
||||
spriteBatch.End();
|
||||
|
||||
if (lightingEnabled.Selected)
|
||||
@@ -659,12 +802,23 @@ 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)
|
||||
{
|
||||
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.Draw(Cam, spriteBatch);
|
||||
spriteBatch.End();
|
||||
}
|
||||
|
||||
public override void Update(double deltaTime)
|
||||
{
|
||||
GameMain.LightManager?.Update((float)deltaTime);
|
||||
|
||||
pointerLightSource.Position = cam.ScreenToWorld(PlayerInput.MousePosition);
|
||||
pointerLightSource.Enabled = cursorLightEnabled.Selected;
|
||||
pointerLightSource.IsBackground = true;
|
||||
@@ -694,7 +848,40 @@ namespace Barotrauma
|
||||
{
|
||||
foreach (XElement element in doc.Root.Elements())
|
||||
{
|
||||
XElement levelParamElement = element;
|
||||
if (element.IsOverride())
|
||||
{
|
||||
foreach (XElement subElement in element.Elements())
|
||||
{
|
||||
string id = element.GetAttributeString("identifier", null) ?? element.Name.ToString();
|
||||
if (!id.Equals(genParams.Name, StringComparison.OrdinalIgnoreCase)) { continue; }
|
||||
SerializableProperty.SerializeProperties(genParams, element, true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string id = element.GetAttributeString("identifier", null) ?? element.Name.ToString();
|
||||
if (!id.Equals(genParams.Name, StringComparison.OrdinalIgnoreCase)) { continue; }
|
||||
SerializableProperty.SerializeProperties(genParams, element, true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
using (var writer = XmlWriter.Create(configFile.Path, settings))
|
||||
{
|
||||
doc.WriteTo(writer);
|
||||
writer.Flush();
|
||||
}
|
||||
}
|
||||
|
||||
foreach (ContentFile configFile in GameMain.Instance.GetFilesOfType(ContentType.CaveGenerationParameters))
|
||||
{
|
||||
XDocument doc = XMLExtensions.TryLoadXml(configFile.Path);
|
||||
if (doc == null) { continue; }
|
||||
|
||||
foreach (CaveGenerationParams genParams in CaveGenerationParams.CaveParams)
|
||||
{
|
||||
foreach (XElement element in doc.Root.Elements())
|
||||
{
|
||||
if (element.IsOverride())
|
||||
{
|
||||
foreach (XElement subElement in element.Elements())
|
||||
@@ -730,7 +917,8 @@ namespace Barotrauma
|
||||
{
|
||||
foreach (XElement element in doc.Root.Elements())
|
||||
{
|
||||
if (!element.Name.ToString().Equals(levelObjPrefab.Name, StringComparison.OrdinalIgnoreCase)) { continue; }
|
||||
string identifier = element.GetAttributeString("identifier", null);
|
||||
if (!identifier.Equals(levelObjPrefab.Identifier, StringComparison.OrdinalIgnoreCase)) { continue; }
|
||||
levelObjPrefab.Save(element);
|
||||
break;
|
||||
}
|
||||
@@ -846,7 +1034,7 @@ namespace Barotrauma
|
||||
return false;
|
||||
}
|
||||
|
||||
if (LevelObjectPrefab.List.Any(obj => obj.Name.ToLower() == nameBox.Text.ToLower()))
|
||||
if (LevelObjectPrefab.List.Any(obj => obj.Identifier.Equals(nameBox.Text, StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
nameBox.Flash(GUI.Style.Red);
|
||||
GUI.AddMessage(TextManager.Get("leveleditor.levelobjnametaken"), GUI.Style.Red);
|
||||
@@ -860,14 +1048,14 @@ namespace Barotrauma
|
||||
return false;
|
||||
}
|
||||
|
||||
newPrefab.Name = nameBox.Text;
|
||||
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.Name);
|
||||
var newElement = new XElement(newPrefab.Identifier);
|
||||
newPrefab.Save(newElement);
|
||||
newElement.Add(new XElement("Sprite",
|
||||
new XAttribute("texture", texturePathBox.Text),
|
||||
|
||||
@@ -38,6 +38,9 @@ namespace Barotrauma
|
||||
private GUIImage playstyleBanner;
|
||||
private GUITextBlock playstyleDescription;
|
||||
|
||||
private GUIComponent remoteContentContainer;
|
||||
private XDocument remoteContentDoc;
|
||||
|
||||
private Tab selectedTab;
|
||||
|
||||
private Sprite backgroundSprite;
|
||||
@@ -62,6 +65,14 @@ namespace Barotrauma
|
||||
}
|
||||
CreateHostServerFields();
|
||||
CreateCampaignSetupUI();
|
||||
if (remoteContentDoc?.Root != null)
|
||||
{
|
||||
remoteContentContainer.ClearChildren();
|
||||
foreach (XElement subElement in remoteContentDoc.Root.Elements())
|
||||
{
|
||||
GUIComponent.FromXML(subElement, remoteContentContainer.RectTransform);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
new GUIImage(new RectTransform(new Vector2(0.4f, 0.25f), Frame.RectTransform, Anchor.BottomRight)
|
||||
@@ -84,6 +95,11 @@ namespace Barotrauma
|
||||
RelativeSpacing = 0.02f
|
||||
};
|
||||
|
||||
remoteContentContainer = new GUIFrame(new RectTransform(Vector2.One, parent: Frame.RectTransform), style: null)
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
|
||||
#if TEST_REMOTE_CONTENT
|
||||
|
||||
var doc = XMLExtensions.TryLoadXml("Content/UI/MenuTextTest.xml");
|
||||
@@ -91,7 +107,7 @@ namespace Barotrauma
|
||||
{
|
||||
foreach (XElement subElement in doc?.Root.Elements())
|
||||
{
|
||||
GUIComponent.FromXML(subElement, Frame.RectTransform);
|
||||
GUIComponent.FromXML(subElement, remoteContentContainer.RectTransform);
|
||||
}
|
||||
}
|
||||
#else
|
||||
@@ -1402,10 +1418,10 @@ namespace Barotrauma
|
||||
if (index > 0) { xml = xml.Substring(index, xml.Length - index); }
|
||||
if (!string.IsNullOrWhiteSpace(xml))
|
||||
{
|
||||
XElement element = XDocument.Parse(xml)?.Root;
|
||||
foreach (XElement subElement in element.Elements())
|
||||
remoteContentDoc = XDocument.Parse(xml);
|
||||
foreach (XElement subElement in remoteContentDoc?.Root.Elements())
|
||||
{
|
||||
GUIComponent.FromXML(subElement, Frame.RectTransform);
|
||||
GUIComponent.FromXML(subElement, remoteContentContainer.RectTransform);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -832,7 +832,7 @@ namespace Barotrauma
|
||||
var modeFrame = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.15f), modeList.Content.RectTransform), style: null)
|
||||
{
|
||||
UserData = mode
|
||||
};
|
||||
};
|
||||
|
||||
var modeContent = new GUILayoutGroup(new RectTransform(new Vector2(0.75f, 0.9f), modeFrame.RectTransform, Anchor.CenterRight) { RelativeOffset = new Vector2(0.02f, 0.0f) })
|
||||
{
|
||||
@@ -910,21 +910,24 @@ namespace Barotrauma
|
||||
}
|
||||
};
|
||||
|
||||
missionTypeTickBoxes = new GUITickBox[Enum.GetValues(typeof(MissionType)).Length - 2];
|
||||
var missionTypes = (MissionType[])Enum.GetValues(typeof(MissionType));
|
||||
missionTypeTickBoxes = new GUITickBox[missionTypes.Length - 2];
|
||||
int index = 0;
|
||||
foreach (MissionType missionType in Enum.GetValues(typeof(MissionType)))
|
||||
for (int i = 0; i < missionTypes.Length; i++)
|
||||
{
|
||||
var missionType = missionTypes[i];
|
||||
if (missionType == MissionType.None || missionType == MissionType.All) { continue; }
|
||||
|
||||
GUIFrame frame = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.05f), missionTypeList.Content.RectTransform) { MinSize = new Point(0, (int)(30 * GUI.Scale)) }, style: "ListBoxElement")
|
||||
{
|
||||
UserData = index,
|
||||
UserData = missionType,
|
||||
};
|
||||
|
||||
missionTypeTickBoxes[index] = new GUITickBox(new RectTransform(Vector2.One, frame.RectTransform),
|
||||
TextManager.Get("MissionType." + missionType.ToString()))
|
||||
{
|
||||
UserData = (int)missionType,
|
||||
ToolTip = TextManager.Get("MissionTypeDescription." + missionType.ToString(), returnNull: true),
|
||||
OnSelected = (tickbox) =>
|
||||
{
|
||||
int missionTypeOr = tickbox.Selected ? (int)tickbox.UserData : (int)MissionType.None;
|
||||
@@ -934,7 +937,6 @@ namespace Barotrauma
|
||||
}
|
||||
};
|
||||
frame.RectTransform.MinSize = missionTypeTickBoxes[index].RectTransform.MinSize;
|
||||
|
||||
index++;
|
||||
}
|
||||
clientDisabledElements.AddRange(missionTypeTickBoxes);
|
||||
@@ -1485,7 +1487,7 @@ namespace Barotrauma
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateChangesPendingText()
|
||||
@@ -2509,7 +2511,7 @@ namespace Barotrauma
|
||||
Selected = info.Gender == Gender.Female
|
||||
};
|
||||
|
||||
int hairCount = info.FilterByTypeAndHeadID(info.FilterElementsByGenderAndRace(info.Wearables), WearableType.Hair).Count();
|
||||
int hairCount = info.FilterByTypeAndHeadID(info.FilterElementsByGenderAndRace(info.Wearables, info.Head.gender, info.Head.race), WearableType.Hair, info.HeadSpriteId).Count();
|
||||
if (hairCount > 0)
|
||||
{
|
||||
var label = new GUITextBlock(new RectTransform(elementSize, content.RectTransform), TextManager.Get("FaceAttachment.Hair"), font: GUI.SubHeadingFont);
|
||||
@@ -2524,7 +2526,7 @@ namespace Barotrauma
|
||||
};
|
||||
}
|
||||
|
||||
int beardCount = info.FilterByTypeAndHeadID(info.FilterElementsByGenderAndRace(info.Wearables), WearableType.Beard).Count();
|
||||
int beardCount = info.FilterByTypeAndHeadID(info.FilterElementsByGenderAndRace(info.Wearables, info.Head.gender, info.Head.race), WearableType.Beard, info.HeadSpriteId).Count();
|
||||
if (beardCount > 0)
|
||||
{
|
||||
var label = new GUITextBlock(new RectTransform(elementSize, content.RectTransform), TextManager.Get("FaceAttachment.Beard"), font: GUI.SubHeadingFont);
|
||||
@@ -2539,7 +2541,7 @@ namespace Barotrauma
|
||||
};
|
||||
}
|
||||
|
||||
int moustacheCount = info.FilterByTypeAndHeadID(info.FilterElementsByGenderAndRace(info.Wearables), WearableType.Moustache).Count();
|
||||
int moustacheCount = info.FilterByTypeAndHeadID(info.FilterElementsByGenderAndRace(info.Wearables, info.Head.gender, info.Head.race), WearableType.Moustache, info.HeadSpriteId).Count();
|
||||
if (moustacheCount > 0)
|
||||
{
|
||||
var label = new GUITextBlock(new RectTransform(elementSize, content.RectTransform), TextManager.Get("FaceAttachment.Moustache"), font: GUI.SubHeadingFont);
|
||||
@@ -2554,7 +2556,7 @@ namespace Barotrauma
|
||||
};
|
||||
}
|
||||
|
||||
int faceAttachmentCount = info.FilterByTypeAndHeadID(info.FilterElementsByGenderAndRace(info.Wearables), WearableType.FaceAttachment).Count();
|
||||
int faceAttachmentCount = info.FilterByTypeAndHeadID(info.FilterElementsByGenderAndRace(info.Wearables, info.Head.gender, info.Head.race), WearableType.FaceAttachment, info.HeadSpriteId).Count();
|
||||
if (faceAttachmentCount > 0)
|
||||
{
|
||||
var label = new GUITextBlock(new RectTransform(elementSize, content.RectTransform), TextManager.Get("FaceAttachment.Accessories"), font: GUI.SubHeadingFont);
|
||||
@@ -2976,7 +2978,7 @@ namespace Barotrauma
|
||||
public void SelectMode(int modeIndex)
|
||||
{
|
||||
if (modeIndex < 0 || modeIndex >= modeList.Content.CountChildren) { return; }
|
||||
|
||||
|
||||
if ((GameModePreset)modeList.Content.GetChild(modeIndex).UserData != GameModePreset.MultiPlayerCampaign)
|
||||
{
|
||||
ToggleCampaignMode(false);
|
||||
@@ -3001,16 +3003,33 @@ namespace Barotrauma
|
||||
RefreshGameModeContent();
|
||||
}
|
||||
|
||||
private void RefreshMissionTypes()
|
||||
{
|
||||
for (int i = 0; i < missionTypeTickBoxes.Length; i++)
|
||||
{
|
||||
MissionType missionType = (MissionType)((int)missionTypeTickBoxes[i].UserData);
|
||||
if (SelectedMode == GameModePreset.Mission)
|
||||
{
|
||||
missionTypeTickBoxes[i].Parent.Visible = MissionPrefab.CoOpMissionClasses.ContainsKey(missionType);
|
||||
}
|
||||
else if (SelectedMode == GameModePreset.PvP)
|
||||
{
|
||||
missionTypeTickBoxes[i].Parent.Visible = MissionPrefab.PvPMissionClasses.ContainsKey(missionType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshGameModeContent()
|
||||
{
|
||||
if (GameMain.Client == null) { return; }
|
||||
|
||||
autoRestartBox.Parent.Visible = true;
|
||||
settingsBlocker.Visible = false;
|
||||
if (SelectedMode == GameModePreset.Mission)
|
||||
if (SelectedMode == GameModePreset.Mission || SelectedMode == GameModePreset.PvP)
|
||||
{
|
||||
MissionTypeFrame.Visible = true;
|
||||
CampaignFrame.Visible = CampaignSetupFrame.Visible = false;
|
||||
RefreshMissionTypes();
|
||||
}
|
||||
else if (SelectedMode == GameModePreset.MultiPlayerCampaign)
|
||||
{
|
||||
@@ -3062,7 +3081,7 @@ namespace Barotrauma
|
||||
RefreshEnabledElements();
|
||||
if (enabled)
|
||||
{
|
||||
modeList.Select(2, true);
|
||||
modeList.Select(GameModePreset.MultiPlayerCampaign, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace Barotrauma
|
||||
{
|
||||
var temp = LoadException;
|
||||
LoadException = null;
|
||||
throw temp;
|
||||
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Capture(temp).Throw();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -696,6 +696,7 @@ namespace Barotrauma
|
||||
private void ReadServerMemFromFile(string file, ref List<ServerInfo> servers)
|
||||
{
|
||||
if (servers == null) { servers = new List<ServerInfo>(); }
|
||||
servers.Clear();
|
||||
|
||||
if (!File.Exists(file)) { return; }
|
||||
|
||||
@@ -716,11 +717,21 @@ namespace Barotrauma
|
||||
return;
|
||||
}
|
||||
|
||||
bool saveCleanup = false;
|
||||
foreach (XElement element in doc.Root.Elements())
|
||||
{
|
||||
if (element.Name != "ServerInfo") { continue; }
|
||||
servers.Add(ServerInfo.FromXElement(element));
|
||||
var info = ServerInfo.FromXElement(element);
|
||||
if (!servers.Any(s => s.Equals(info)))
|
||||
{
|
||||
servers.Add(info);
|
||||
}
|
||||
else
|
||||
{
|
||||
saveCleanup = true;
|
||||
}
|
||||
}
|
||||
if (saveCleanup) { WriteServerMemToFile(file, servers); }
|
||||
}
|
||||
|
||||
private void WriteServerMemToFile(string file, List<ServerInfo> servers)
|
||||
@@ -1061,7 +1072,7 @@ namespace Barotrauma
|
||||
(!filterFull.Selected || serverInfo.PlayerCount < serverInfo.MaxPlayers) &&
|
||||
(!filterEmpty.Selected || serverInfo.PlayerCount > 0) &&
|
||||
(!filterWhitelisted.Selected || serverInfo.UsingWhiteList == true) &&
|
||||
(filterOffensive.Selected || !ForbiddenWordFilter.IsForbidden(serverInfo.ServerName)) &&
|
||||
(!filterOffensive.Selected || !ForbiddenWordFilter.IsForbidden(serverInfo.ServerName)) &&
|
||||
(!filterKarma.Selected || serverInfo.KarmaEnabled == true) &&
|
||||
(!filterFriendlyFire.Selected || serverInfo.FriendlyFireEnabled == false) &&
|
||||
(!filterTraitor.Selected || serverInfo.TraitorsEnabled == YesNoMaybe.Yes || serverInfo.TraitorsEnabled == YesNoMaybe.Maybe) &&
|
||||
|
||||
@@ -353,6 +353,8 @@ namespace Barotrauma
|
||||
{
|
||||
element.Elements("sprite").ForEach(s => CreateSprite(s));
|
||||
element.Elements("Sprite").ForEach(s => CreateSprite(s));
|
||||
element.Elements("deformablesprite").ForEach(s => CreateSprite(s));
|
||||
element.Elements("DeformableSprite").ForEach(s => CreateSprite(s));
|
||||
element.Elements("backgroundsprite").ForEach(s => CreateSprite(s));
|
||||
element.Elements("BackgroundSprite").ForEach(s => CreateSprite(s));
|
||||
element.Elements("brokensprite").ForEach(s => CreateSprite(s));
|
||||
|
||||
@@ -71,6 +71,7 @@ namespace Barotrauma
|
||||
|
||||
private bool entityMenuOpen = true;
|
||||
private float entityMenuOpenState = 1.0f;
|
||||
private string lastFilter;
|
||||
public GUIComponent EntityMenu;
|
||||
private GUITextBox entityFilterBox;
|
||||
private GUIListBox entityList;
|
||||
@@ -105,7 +106,25 @@ namespace Barotrauma
|
||||
private static GUIComponent autoSaveLabel;
|
||||
private static int maxAutoSaves = GameSettings.MaximumAutoSaves;
|
||||
|
||||
public static bool BulkItemBufferInUse;
|
||||
public static readonly object ItemAddMutex = new object(), ItemRemoveMutex = new object();
|
||||
|
||||
public static bool TransparentWiringMode = true;
|
||||
|
||||
private static object bulkItemBufferinUse;
|
||||
|
||||
public static object BulkItemBufferInUse
|
||||
{
|
||||
get => bulkItemBufferinUse;
|
||||
set
|
||||
{
|
||||
if (value != bulkItemBufferinUse && bulkItemBufferinUse != null)
|
||||
{
|
||||
CommitBulkItemBuffer();
|
||||
}
|
||||
|
||||
bulkItemBufferinUse = value;
|
||||
}
|
||||
}
|
||||
public static List<AddOrDeleteCommand> BulkItemBuffer = new List<AddOrDeleteCommand>();
|
||||
|
||||
public static List<WarningType> SuppressedWarnings = new List<WarningType>();
|
||||
@@ -197,7 +216,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (buoyancyVol / selectedVol < 1.0f)
|
||||
{
|
||||
retVal += " (" + TextManager.GetWithVariable("OptimalBallastLevel", "[value]", (buoyancyVol / selectedVol).ToString("0.000")) + ")";
|
||||
retVal += " (" + TextManager.GetWithVariable("OptimalBallastLevel", "[value]", (buoyancyVol / selectedVol).ToString("0.0000")) + ")";
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -630,35 +649,33 @@ namespace Barotrauma
|
||||
return Structure.WallList.Count.ToString();
|
||||
};
|
||||
|
||||
var lightCountText = new GUITextBlock(new RectTransform(new Vector2(0.75f, 0.0f), paddedEntityCountPanel.RectTransform), TextManager.Get("SubEditorLights"),
|
||||
var lightCountLabel = new GUITextBlock(new RectTransform(new Vector2(0.75f, 0.0f), paddedEntityCountPanel.RectTransform), TextManager.Get("SubEditorLights"),
|
||||
textAlignment: Alignment.CenterLeft, font: GUI.SmallFont);
|
||||
var lightCount = new GUITextBlock(new RectTransform(new Vector2(0.33f, 1.0f), lightCountText.RectTransform, Anchor.TopRight, Pivot.TopLeft), "", textAlignment: Alignment.CenterRight);
|
||||
lightCount.TextGetter = () =>
|
||||
var lightCountText = new GUITextBlock(new RectTransform(new Vector2(0.33f, 1.0f), lightCountLabel.RectTransform, Anchor.TopRight, Pivot.TopLeft), "", textAlignment: Alignment.CenterRight);
|
||||
lightCountText.TextGetter = () =>
|
||||
{
|
||||
int disabledItemLightCount = 0;
|
||||
int lightCount = 0;
|
||||
foreach (Item item in Item.ItemList)
|
||||
{
|
||||
if (item.ParentInventory == null) { continue; }
|
||||
disabledItemLightCount += item.GetComponents<LightComponent>().Count();
|
||||
if (item.ParentInventory != null) { continue; }
|
||||
lightCount += item.GetComponents<LightComponent>().Count();
|
||||
}
|
||||
int count = GameMain.LightManager.Lights.Count() - disabledItemLightCount;
|
||||
lightCount.TextColor = ToolBox.GradientLerp(count / 250.0f, GUI.Style.Green, GUI.Style.Orange, GUI.Style.Red);
|
||||
return count.ToString();
|
||||
lightCountText.TextColor = ToolBox.GradientLerp(lightCount / 250.0f, GUI.Style.Green, GUI.Style.Orange, GUI.Style.Red);
|
||||
return lightCount.ToString();
|
||||
};
|
||||
var shadowCastingLightCountText = new GUITextBlock(new RectTransform(new Vector2(0.75f, 0.0f), paddedEntityCountPanel.RectTransform), TextManager.Get("SubEditorShadowCastingLights"),
|
||||
var shadowCastingLightCountLabel = new GUITextBlock(new RectTransform(new Vector2(0.75f, 0.0f), paddedEntityCountPanel.RectTransform), TextManager.Get("SubEditorShadowCastingLights"),
|
||||
textAlignment: Alignment.CenterLeft, font: GUI.SmallFont, wrap: true);
|
||||
var shadowCastingLightCount = new GUITextBlock(new RectTransform(new Vector2(0.33f, 1.0f), shadowCastingLightCountText.RectTransform, Anchor.TopRight, Pivot.TopLeft), "", textAlignment: Alignment.CenterRight);
|
||||
shadowCastingLightCount.TextGetter = () =>
|
||||
var shadowCastingLightCountText = new GUITextBlock(new RectTransform(new Vector2(0.33f, 1.0f), shadowCastingLightCountLabel.RectTransform, Anchor.TopRight, Pivot.TopLeft), "", textAlignment: Alignment.CenterRight);
|
||||
shadowCastingLightCountText.TextGetter = () =>
|
||||
{
|
||||
int disabledItemLightCount = 0;
|
||||
int lightCount = 0;
|
||||
foreach (Item item in Item.ItemList)
|
||||
{
|
||||
if (item.ParentInventory == null) { continue; }
|
||||
disabledItemLightCount += item.GetComponents<LightComponent>().Count();
|
||||
if (item.ParentInventory != null) { continue; }
|
||||
lightCount += item.GetComponents<LightComponent>().Count(l => l.CastShadows);
|
||||
}
|
||||
int count = GameMain.LightManager.Lights.Count(l => l.CastShadows) - disabledItemLightCount;
|
||||
shadowCastingLightCount.TextColor = ToolBox.GradientLerp(count / 60.0f, GUI.Style.Green, GUI.Style.Orange, GUI.Style.Red);
|
||||
return count.ToString();
|
||||
shadowCastingLightCountText.TextColor = ToolBox.GradientLerp(lightCount / 60.0f, GUI.Style.Green, GUI.Style.Orange, GUI.Style.Red);
|
||||
return lightCount.ToString();
|
||||
};
|
||||
entityCountPanel.RectTransform.NonScaledSize =
|
||||
new Point(
|
||||
@@ -737,7 +754,13 @@ namespace Barotrauma
|
||||
var filterText = new GUITextBlock(new RectTransform(new Vector2(0.1f, 1.0f), entityMenuTop.RectTransform), TextManager.Get("serverlog.filter"), font: GUI.SubHeadingFont);
|
||||
filterText.RectTransform.MaxSize = new Point((int)(filterText.TextSize.X * 1.5f), int.MaxValue);
|
||||
entityFilterBox = new GUITextBox(new RectTransform(new Vector2(0.17f, 1.0f), entityMenuTop.RectTransform), font: GUI.Font, createClearButton: true);
|
||||
entityFilterBox.OnTextChanged += (textBox, text) => { FilterEntities(text); return true; };
|
||||
entityFilterBox.OnTextChanged += (textBox, text) =>
|
||||
{
|
||||
if (text == lastFilter) { return true; }
|
||||
lastFilter = text;
|
||||
FilterEntities(text);
|
||||
return true;
|
||||
};
|
||||
|
||||
//spacing
|
||||
new GUIFrame(new RectTransform(new Vector2(0.075f, 1.0f), entityMenuTop.RectTransform), style: null);
|
||||
@@ -994,15 +1017,9 @@ namespace Barotrauma
|
||||
|
||||
GameMain.LightManager.AmbientLight =
|
||||
Level.Loaded?.GenerationParams?.AmbientLightColor ??
|
||||
LevelGenerationParams.LevelParams?.FirstOrDefault()?.AmbientLightColor ??
|
||||
new Color(20, 20, 20, 255);
|
||||
new Color(3, 3, 3, 3);
|
||||
|
||||
UpdateEntityList();
|
||||
if (!wasSelectedBefore)
|
||||
{
|
||||
OpenEntityMenu(MapEntityCategory.Structure);
|
||||
wasSelectedBefore = true;
|
||||
}
|
||||
|
||||
isAutoSaving = false;
|
||||
if (!wasSelectedBefore)
|
||||
@@ -1150,7 +1167,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (dummyCharacter != null) RemoveDummyCharacter();
|
||||
|
||||
dummyCharacter = Character.Create(CharacterPrefab.HumanSpeciesName, Vector2.Zero, "", hasAi: false);
|
||||
dummyCharacter = Character.Create(CharacterPrefab.HumanSpeciesName, Vector2.Zero, "", id: Entity.RespawnManagerID, hasAi: false);
|
||||
dummyCharacter.Info.Name = "Galldren";
|
||||
|
||||
//make space for the entity menu
|
||||
@@ -1195,7 +1212,7 @@ namespace Barotrauma
|
||||
|
||||
CrossThread.RequestExecutionOnMainThread(() =>
|
||||
{
|
||||
if (AutoSaveInfo?.Root == null) { return; }
|
||||
if (AutoSaveInfo?.Root == null || Submarine.MainSub?.Info == null) { return; }
|
||||
|
||||
int saveCount = AutoSaveInfo.Root.Elements().Count();
|
||||
while (AutoSaveInfo.Root.Elements().Count() > maxAutoSaves)
|
||||
@@ -1602,14 +1619,14 @@ namespace Barotrauma
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.4f, 1f), subTypeContainer.RectTransform), TextManager.Get("submarinetype"));
|
||||
var subTypeDropdown = new GUIDropDown(new RectTransform(new Vector2(0.6f, 1f), subTypeContainer.RectTransform));
|
||||
subTypeContainer.RectTransform.MinSize = new Point(0, subTypeContainer.RectTransform.Children.Max(c => c.MinSize.Y));
|
||||
subTypeDropdown.AddItem(TextManager.Get("submarinetype.player"), SubmarineType.Player);
|
||||
subTypeDropdown.AddItem(TextManager.Get("submarinetype.outpostmodule"), SubmarineType.OutpostModule);
|
||||
subTypeDropdown.AddItem(TextManager.Get("submarinetype.outpost"), SubmarineType.Outpost);
|
||||
subTypeDropdown.AddItem(TextManager.Get("submarinetype.wreck"), SubmarineType.Wreck);
|
||||
foreach (SubmarineType subType in Enum.GetValues(typeof(SubmarineType)))
|
||||
{
|
||||
subTypeDropdown.AddItem(TextManager.Get("submarinetype."+subType.ToString().ToLowerInvariant()), subType);
|
||||
}
|
||||
|
||||
//---------------------------------------
|
||||
//---------------------------------------
|
||||
|
||||
var outpostSettingsContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.15f), leftColumn.RectTransform))
|
||||
var outpostSettingsContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.15f), leftColumn.RectTransform))
|
||||
{
|
||||
IgnoreLayoutGroups = true,
|
||||
CanBeFocused = true,
|
||||
@@ -1853,6 +1870,10 @@ namespace Barotrauma
|
||||
Submarine.MainSub.Info.Price = numberInput.IntValue;
|
||||
}
|
||||
};
|
||||
if (Submarine.MainSub?.Info != null)
|
||||
{
|
||||
Submarine.MainSub.Info.Price = Math.Max(Submarine.MainSub.Info.Price, basePrice);
|
||||
}
|
||||
|
||||
if (!Submarine.MainSub.Info.HasTag(SubmarineTag.Shuttle))
|
||||
{
|
||||
@@ -2665,7 +2686,7 @@ namespace Barotrauma
|
||||
|
||||
foreach (GUIComponent child in entityList.Content.Children)
|
||||
{
|
||||
child.Visible = !entityCategory.HasValue || ((MapEntityPrefab) child.UserData).Category == entityCategory;
|
||||
child.Visible = !entityCategory.HasValue || ((MapEntityPrefab) child.UserData).Category.HasFlag(entityCategory);
|
||||
if (child.Visible && dummyCharacter?.SelectedConstruction?.OwnInventory != null)
|
||||
{
|
||||
child.Visible = child.UserData is MapEntityPrefab item && IsItemPrefab(item);
|
||||
@@ -2790,11 +2811,17 @@ namespace Barotrauma
|
||||
if (PlayerInput.IsShiftDown())
|
||||
{
|
||||
new GUITextBlock(new RectTransform(Point.Zero, contextMenu.Content.RectTransform),
|
||||
TextManager.Get("CharacterEditor.EditBackgroundColor"), font: GUI.SmallFont)
|
||||
TextManager.Get("SubEditor.EditBackgroundColor"), font: GUI.SmallFont)
|
||||
{
|
||||
UserData = "bgcolor"
|
||||
};
|
||||
|
||||
new GUITextBlock(new RectTransform(Point.Zero, contextMenu.Content.RectTransform),
|
||||
TextManager.Get("SubEditor.ToggleTransparency"), font: GUI.SmallFont)
|
||||
{
|
||||
UserData = "transparency"
|
||||
};
|
||||
|
||||
new GUITextBlock(new RectTransform(Point.Zero, contextMenu.Content.RectTransform),
|
||||
TextManager.Get("editor.selectsame"), font: GUI.SmallFont)
|
||||
{
|
||||
@@ -2870,6 +2897,9 @@ namespace Barotrauma
|
||||
case "bgcolor":
|
||||
CreateBackgroundColorPicker();
|
||||
break;
|
||||
case "transparency":
|
||||
TransparentWiringMode = !TransparentWiringMode;
|
||||
break;
|
||||
case "selectsame":
|
||||
IEnumerable<MapEntity> matching = MapEntity.mapEntityList.Where(e => e.prefab != null && targets.Any(t => t.prefab.Identifier == e.prefab.Identifier) && !MapEntity.SelectedList.Contains(e));
|
||||
MapEntity.SelectedList.AddRange(matching);
|
||||
@@ -3710,6 +3740,24 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
private static void CommitBulkItemBuffer()
|
||||
{
|
||||
if (BulkItemBuffer.Any())
|
||||
{
|
||||
AddOrDeleteCommand master = BulkItemBuffer[0];
|
||||
for (int i = 1; i < BulkItemBuffer.Count; i++)
|
||||
{
|
||||
AddOrDeleteCommand command = BulkItemBuffer[i];
|
||||
command.MergeInto(master);
|
||||
}
|
||||
|
||||
StoreCommand(master);
|
||||
BulkItemBuffer.Clear();
|
||||
}
|
||||
|
||||
bulkItemBufferinUse = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allows the game to run logic such as updating the world,
|
||||
/// checking for collisions, gathering input, and playing audio.
|
||||
@@ -3939,6 +3987,11 @@ namespace Barotrauma
|
||||
CloseItem();
|
||||
}
|
||||
|
||||
if (lightingEnabled)
|
||||
{
|
||||
GameMain.LightManager?.Update((float)deltaTime);
|
||||
}
|
||||
|
||||
if (contextMenu != null)
|
||||
{
|
||||
Rectangle expandedRect = contextMenu.Rect;
|
||||
@@ -4034,7 +4087,7 @@ namespace Barotrauma
|
||||
|
||||
// Deposit item from our "infinite stack" into inventory slots
|
||||
var inv = dummyCharacter?.SelectedConstruction?.OwnInventory;
|
||||
if (inv?.slots != null)
|
||||
if (inv?.slots != null && !PlayerInput.IsCtrlDown())
|
||||
{
|
||||
var dragginMouse = MouseDragStart != Vector2.Zero && Vector2.Distance(PlayerInput.MousePosition, MouseDragStart) >= GUI.Scale * 20;
|
||||
|
||||
@@ -4090,7 +4143,7 @@ namespace Barotrauma
|
||||
|
||||
if (!newItem.Removed)
|
||||
{
|
||||
BulkItemBufferInUse = true;
|
||||
BulkItemBufferInUse = ItemAddMutex;
|
||||
BulkItemBuffer.Add(new AddOrDeleteCommand(new List<MapEntity> { newItem }, false));
|
||||
}
|
||||
|
||||
@@ -4162,7 +4215,7 @@ namespace Barotrauma
|
||||
List<MapEntity> placedEntities = itemInstance.Where(it => !it.Removed).Cast<MapEntity>().ToList();
|
||||
if (placedEntities.Any())
|
||||
{
|
||||
BulkItemBufferInUse = true;
|
||||
BulkItemBufferInUse = ItemAddMutex;
|
||||
BulkItemBuffer.Add(new AddOrDeleteCommand(placedEntities, false));
|
||||
}
|
||||
}
|
||||
@@ -4174,18 +4227,9 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
if (BulkItemBufferInUse && PlayerInput.PrimaryMouseButtonReleased() && BulkItemBuffer.Any())
|
||||
if (PlayerInput.PrimaryMouseButtonReleased() && BulkItemBufferInUse != null)
|
||||
{
|
||||
AddOrDeleteCommand master = BulkItemBuffer[0];
|
||||
for (int i = 1; i < BulkItemBuffer.Count; i++)
|
||||
{
|
||||
AddOrDeleteCommand command = BulkItemBuffer[i];
|
||||
command.MergeInto(master);
|
||||
}
|
||||
|
||||
StoreCommand(master);
|
||||
BulkItemBuffer.Clear();
|
||||
BulkItemBufferInUse = false;
|
||||
CommitBulkItemBuffer();
|
||||
}
|
||||
|
||||
if (SerializableEntityEditor.PropertyChangesActive && (SerializableEntityEditor.NextCommandPush < DateTime.Now || MapEntity.EditingHUD == null))
|
||||
@@ -4326,7 +4370,7 @@ namespace Barotrauma
|
||||
cam.UpdateTransform();
|
||||
if (lightingEnabled)
|
||||
{
|
||||
GameMain.LightManager.UpdateLightMap(graphics, spriteBatch, cam);
|
||||
GameMain.LightManager.RenderLightMap(graphics, spriteBatch, cam);
|
||||
}
|
||||
|
||||
foreach (Submarine sub in Submarine.Loaded)
|
||||
@@ -4493,6 +4537,7 @@ namespace Barotrauma
|
||||
stream.Dispose();
|
||||
}
|
||||
|
||||
public static bool IsSubEditor() { return Screen.Selected is SubEditorScreen && !Submarine.Unloading; }
|
||||
public static bool IsSubEditor() => Screen.Selected is SubEditorScreen && !Submarine.Unloading;
|
||||
public static bool IsWiringMode() => Screen.Selected == GameMain.SubEditorScreen && GameMain.SubEditorScreen.WiringMode && !Submarine.Unloading;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user