diff --git a/Barotrauma/BarotraumaClient/Source/GUI/GUI.cs b/Barotrauma/BarotraumaClient/Source/GUI/GUI.cs index a7b05fc0f..34de3d244 100644 --- a/Barotrauma/BarotraumaClient/Source/GUI/GUI.cs +++ b/Barotrauma/BarotraumaClient/Source/GUI/GUI.cs @@ -36,6 +36,16 @@ namespace Barotrauma get { return (GameMain.GraphicsWidth / 1920.0f + GameMain.GraphicsHeight / 1080.0f) / 2.0f * GameSettings.HUDScale; } } + public static float xScale + { + get { return GameMain.GraphicsWidth / 1920.0f * GameSettings.HUDScale; } + } + + public static float yScale + { + get { return GameMain.GraphicsHeight / 1080.0f * GameSettings.HUDScale; } + } + public static GUIStyle Style; private static Texture2D t; diff --git a/Barotrauma/BarotraumaClient/Source/GUI/RectTransform.cs b/Barotrauma/BarotraumaClient/Source/GUI/RectTransform.cs index b453de6ed..365a9a2a9 100644 --- a/Barotrauma/BarotraumaClient/Source/GUI/RectTransform.cs +++ b/Barotrauma/BarotraumaClient/Source/GUI/RectTransform.cs @@ -356,7 +356,7 @@ namespace Barotrauma Point? minSize = null, maxSize = null; if (element.Attribute("minsize") != null) minSize = element.GetAttributePoint("minsize", Point.Zero); - if (element.Attribute("maxsize") != null) maxSize = element.GetAttributePoint("maxsize", new Point(1000, 1000)); + //if (element.Attribute("maxsize") != null) maxSize = element.GetAttributePoint("maxsize", new Point(1000, 1000)); RectTransform rectTransform; if (element.Attribute("relativesize") != null) diff --git a/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/Engine.cs b/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/Engine.cs index e7431cb8b..6c7404f03 100644 --- a/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/Engine.cs +++ b/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/Engine.cs @@ -36,7 +36,9 @@ namespace Barotrauma.Items.Components RelativeSpacing = 0.05f }; - powerIndicator = new GUITickBox(new RectTransform(new Point(30, 30), content.RectTransform), + int indicatorSize = (int)(30 * GUI.Scale); + + powerIndicator = new GUITickBox(new RectTransform(new Point(indicatorSize, indicatorSize), content.RectTransform), TextManager.Get("EnginePowered"), style: "IndicatorLightGreen") { CanBeFocused = false diff --git a/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/Fabricator.cs b/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/Fabricator.cs index 9ad58876d..9b6cf355e 100644 --- a/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/Fabricator.cs +++ b/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/Fabricator.cs @@ -108,7 +108,7 @@ namespace Barotrauma.Items.Components foreach (FabricationRecipe fi in fabricationRecipes) { - GUIFrame frame = new GUIFrame(new RectTransform(new Point(itemList.Rect.Width, 30), itemList.Content.RectTransform), style: null) + GUIFrame frame = new GUIFrame(new RectTransform(new Point(itemList.Rect.Width, (int)(30 * GUI.yScale)), itemList.Content.RectTransform), style: null) { UserData = fi, HoverColor = Color.Gold * 0.2f, @@ -116,7 +116,7 @@ namespace Barotrauma.Items.Components ToolTip = fi.TargetItem.Description }; - GUITextBlock textBlock = new GUITextBlock(new RectTransform(Vector2.Zero, frame.RectTransform, Anchor.CenterLeft) { AbsoluteOffset = new Point(50, 0) }, + GUITextBlock textBlock = new GUITextBlock(new RectTransform(Vector2.Zero, frame.RectTransform, Anchor.CenterLeft) { AbsoluteOffset = new Point((int)(50 * GUI.xScale), 0) }, fi.DisplayName) { ToolTip = fi.TargetItem.Description @@ -125,7 +125,7 @@ namespace Barotrauma.Items.Components var itemIcon = fi.TargetItem.InventoryIcon ?? fi.TargetItem.sprite; if (itemIcon != null) { - GUIImage img = new GUIImage(new RectTransform(new Point(30, 30), frame.RectTransform, Anchor.CenterLeft) { AbsoluteOffset = new Point(3, 0) }, + GUIImage img = new GUIImage(new RectTransform(new Point((int)(30 * GUI.Scale)), frame.RectTransform, Anchor.CenterLeft) { AbsoluteOffset = new Point((int)(3 * GUI.xScale), 0) }, itemIcon, scaleToFit: true) { Color = fi.TargetItem.InventoryIconColor, diff --git a/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/MiniMap.cs b/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/MiniMap.cs index 81caad11f..467bbbb77 100644 --- a/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/MiniMap.cs +++ b/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/MiniMap.cs @@ -114,9 +114,9 @@ namespace Barotrauma.Items.Components Vector2 textSize = GUI.Font.MeasureString(text); Vector2 textPos = child.Center; if (textPos.X + textSize.X / 2 > submarineContainer.Rect.Right) - textPos.X -= ((textPos.X + textSize.X / 2) - submarineContainer.Rect.Right) + 10; + textPos.X -= ((textPos.X + textSize.X / 2) - submarineContainer.Rect.Right) + 10 * GUI.xScale; if (textPos.X - textSize.X / 2 < submarineContainer.Rect.X) - textPos.X += (submarineContainer.Rect.X - (textPos.X - textSize.X / 2)) + 10; + textPos.X += (submarineContainer.Rect.X - (textPos.X - textSize.X / 2)) + 10 * GUI.xScale; GUI.DrawString(spriteBatch, textPos - textSize / 2, text, Color.Orange * (float)Math.Abs(Math.Sin(Timing.TotalTime)), Color.Black * 0.8f); break; @@ -269,7 +269,7 @@ namespace Barotrauma.Items.Components start.Y = -start.Y; Vector2 end = (sub.HullVertices[(i + 1) % sub.HullVertices.Count] + offset) * displayScale; end.Y = -end.Y; - GUI.DrawLine(spriteBatch, center + start, center + end, Color.DarkCyan * Rand.Range(0.3f, 0.35f), width: 10); + GUI.DrawLine(spriteBatch, center + start, center + end, Color.DarkCyan * Rand.Range(0.3f, 0.35f), width: (int)(10 * GUI.Scale)); } } diff --git a/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/Pump.cs b/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/Pump.cs index ab54744a6..55caa8d4b 100644 --- a/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/Pump.cs +++ b/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/Pump.cs @@ -44,7 +44,7 @@ namespace Barotrauma.Items.Components GUIFrame paddedFrame = new GUIFrame(new RectTransform(new Vector2(0.9f, 0.8f), GuiFrame.RectTransform, Anchor.Center), style: null); - isActiveSlider = new GUIScrollBar(new RectTransform(new Point(50, 100), paddedFrame.RectTransform, Anchor.CenterLeft), + isActiveSlider = new GUIScrollBar(new RectTransform(new Point((int)(50 * GUI.Scale), (int)(100 * GUI.Scale)), paddedFrame.RectTransform, Anchor.CenterLeft), barSize: 0.2f, style: "OnOffLever") { IsBooleanSwitch = true, @@ -52,7 +52,7 @@ namespace Barotrauma.Items.Components MaxValue = 0.75f }; var sliderHandle = isActiveSlider.GetChild(); - sliderHandle.RectTransform.NonScaledSize = new Point(84, sliderHandle.Rect.Height); + sliderHandle.RectTransform.NonScaledSize = new Point((int)(84 * GUI.Scale), sliderHandle.Rect.Height); isActiveSlider.OnMoved = (GUIScrollBar scrollBar, float barScroll) => { bool active = scrollBar.BarScroll < 0.5f; @@ -73,7 +73,7 @@ namespace Barotrauma.Items.Components var rightArea = new GUILayoutGroup(new RectTransform(new Vector2(0.75f, 1.0f), paddedFrame.RectTransform, Anchor.CenterRight)) { RelativeSpacing = 0.1f }; - powerIndicator = new GUITickBox(new RectTransform(new Point(30, 30), rightArea.RectTransform), TextManager.Get("PumpPowered"), style: "IndicatorLightGreen") + powerIndicator = new GUITickBox(new RectTransform(new Point((int)(30 * GUI.Scale)), rightArea.RectTransform), TextManager.Get("PumpPowered"), style: "IndicatorLightGreen") { CanBeFocused = false }; diff --git a/Barotrauma/BarotraumaClient/Source/Items/Components/Power/PowerTransfer.cs b/Barotrauma/BarotraumaClient/Source/Items/Components/Power/PowerTransfer.cs index 8519fd792..272dfe94f 100644 --- a/Barotrauma/BarotraumaClient/Source/Items/Components/Power/PowerTransfer.cs +++ b/Barotrauma/BarotraumaClient/Source/Items/Components/Power/PowerTransfer.cs @@ -14,19 +14,21 @@ namespace Barotrauma.Items.Components { if (GuiFrame == null) return; + Point indicatorSize = new Point((int)(30 * GUI.Scale)); + var paddedFrame = new GUIFrame(new RectTransform(new Vector2(0.9f, 0.7f), GuiFrame.RectTransform, Anchor.Center), style: null); - powerIndicator = new GUITickBox(new RectTransform(new Point(30, 30), paddedFrame.RectTransform), + powerIndicator = new GUITickBox(new RectTransform(indicatorSize, paddedFrame.RectTransform), TextManager.Get("PowerTransferPowered"), style: "IndicatorLightGreen") { Enabled = false }; - highVoltageIndicator = new GUITickBox(new RectTransform(new Point(30, 30), paddedFrame.RectTransform) { AbsoluteOffset = new Point(0, 40) }, + highVoltageIndicator = new GUITickBox(new RectTransform(indicatorSize, paddedFrame.RectTransform) { AbsoluteOffset = new Point(0, (int)(40 * GUI.yScale)) }, TextManager.Get("PowerTransferHighVoltage"), style: "IndicatorLightRed") { ToolTip = TextManager.Get("PowerTransferTipOvervoltage"), Enabled = false }; - lowVoltageIndicator = new GUITickBox(new RectTransform(new Point(30, 30), paddedFrame.RectTransform) { AbsoluteOffset = new Point(0, 80) }, + lowVoltageIndicator = new GUITickBox(new RectTransform(indicatorSize, paddedFrame.RectTransform) { AbsoluteOffset = new Point(0, (int)(80 * GUI.yScale)) }, TextManager.Get("PowerTransferLowVoltage"), style: "IndicatorLightRed") { ToolTip = TextManager.Get("PowerTransferTipLowvoltage"), diff --git a/Barotrauma/BarotraumaClient/Source/Items/Components/Signal/Connection.cs b/Barotrauma/BarotraumaClient/Source/Items/Components/Signal/Connection.cs index 8469e0bbe..bcce5950b 100644 --- a/Barotrauma/BarotraumaClient/Source/Items/Components/Signal/Connection.cs +++ b/Barotrauma/BarotraumaClient/Source/Items/Components/Signal/Connection.cs @@ -57,15 +57,15 @@ namespace Barotrauma.Items.Components } } - Vector2 rightPos = new Vector2(x + width - 130, y + 80); - Vector2 leftPos = new Vector2(x + 130, y + 80); + Vector2 rightPos = new Vector2(x + width - 130 * GUI.xScale, y + 80 * GUI.yScale); + Vector2 leftPos = new Vector2(x + 130 * GUI.xScale, y + 80 * GUI.yScale); - Vector2 rightWirePos = new Vector2(x + width - 5, y + 30); - Vector2 leftWirePos = new Vector2(x + 5, y + 30); + Vector2 rightWirePos = new Vector2(x + width - 5 * GUI.xScale, y + 30 * GUI.yScale); + Vector2 leftWirePos = new Vector2(x + 5 * GUI.xScale, y + 30 * GUI.yScale); - int wireInterval = (height - 20) / Math.Max(totalWireCount, 1); - int connectorIntervalLeft = (height - 100) / Math.Max(panel.Connections.Count(c => c.IsOutput), 1); - int connectorIntervalRight = (height - 100) / Math.Max(panel.Connections.Count(c => !c.IsOutput), 1); + int wireInterval = (height - (int)(20 * GUI.yScale)) / Math.Max(totalWireCount, 1); + int connectorIntervalLeft = (height - (int)(100 * GUI.yScale)) / Math.Max(panel.Connections.Count(c => c.IsOutput), 1); + int connectorIntervalRight = (height - (int)(100 * GUI.yScale)) / Math.Max(panel.Connections.Count(c => !c.IsOutput), 1); foreach (Connection c in panel.Connections) { @@ -84,7 +84,7 @@ namespace Barotrauma.Items.Components if (c.IsOutput) { c.Draw(spriteBatch, panel, rightPos, - new Vector2(rightPos.X - GUI.SmallFont.MeasureString(c.DisplayName).X - 20, rightPos.Y + 3), + new Vector2(rightPos.X - GUI.SmallFont.MeasureString(c.DisplayName).X - 20 * GUI.xScale, rightPos.Y + 3 * GUI.yScale), rightWirePos, mouseInRect, equippedWire, wireInterval); diff --git a/Barotrauma/BarotraumaShared/Source/GameSettings.cs b/Barotrauma/BarotraumaShared/Source/GameSettings.cs index 2d2f09fc2..d6722b111 100644 --- a/Barotrauma/BarotraumaShared/Source/GameSettings.cs +++ b/Barotrauma/BarotraumaShared/Source/GameSettings.cs @@ -424,76 +424,6 @@ namespace Barotrauma { Language = doc.Root.GetAttributeString("language", "English"); } - } - - public void CheckBindings(bool useDefaults) - { - foreach (InputType inputType in Enum.GetValues(typeof(InputType))) - { - var binding = keyMapping[(int)inputType]; - if (binding == null) - { - switch (inputType) - { - case InputType.Deselect: - if (useDefaults) - { - binding = new KeyOrMouse(1); - } - else - { - // Legacy support - var selectKey = keyMapping[(int)InputType.Select]; - if (selectKey != null && selectKey.Key != Keys.None) - { - binding = new KeyOrMouse(selectKey.Key); - } - } - break; - case InputType.Shoot: - if (useDefaults) - { - binding = new KeyOrMouse(0); - } - else - { - // Legacy support - var useKey = keyMapping[(int)InputType.Use]; - if (useKey != null && useKey.MouseButton.HasValue) - { - binding = new KeyOrMouse(useKey.MouseButton.Value); - } - } - break; - default: - break; - } - if (binding == null) - { - DebugConsole.ThrowError("Key binding for the input type \"" + inputType + " not set!"); - binding = new KeyOrMouse(Keys.D1); - } - keyMapping[(int)inputType] = binding; - } - } - } - - #region Load DefaultConfig - private void LoadDefaultConfig() - { - XDocument doc = XMLExtensions.TryLoadXml(savePath); - - Language = doc.Root.GetAttributeString("language", "English"); - - MasterServerUrl = doc.Root.GetAttributeString("masterserverurl", ""); - - AutoCheckUpdates = doc.Root.GetAttributeBool("autocheckupdates", true); - WasGameUpdated = doc.Root.GetAttributeBool("wasgameupdated", false); - - VerboseLogging = doc.Root.GetAttributeBool("verboselogging", false); - SaveDebugConsoleLogs = doc.Root.GetAttributeBool("savedebugconsolelogs", false); - - QuickStartSubmarineName = doc.Root.GetAttributeString("quickstartsub", ""); MasterServerUrl = doc.Root.GetAttributeString("masterserverurl", ""); @@ -956,6 +886,55 @@ namespace Barotrauma selectedContentPackagePaths = new HashSet(); + foreach (XElement subElement in doc.Root.Elements()) + { + switch (subElement.Name.ToString().ToLowerInvariant()) + { + case "keymapping": + LoadKeyBinds(subElement); + break; + case "gameplay": + jobPreferences = new List(); + foreach (XElement ele in subElement.Element("jobpreferences").Elements("job")) + { + string jobIdentifier = ele.GetAttributeString("identifier", ""); + if (string.IsNullOrEmpty(jobIdentifier)) continue; + jobPreferences.Add(jobIdentifier); + } + break; + case "player": + defaultPlayerName = subElement.GetAttributeString("name", defaultPlayerName); + CharacterHeadIndex = subElement.GetAttributeInt("headindex", CharacterHeadIndex); + if (Enum.TryParse(subElement.GetAttributeString("gender", "none"), true, out Gender g)) + { + CharacterGender = g; + } + if (Enum.TryParse(subElement.GetAttributeString("race", "white"), true, out Race r)) + { + CharacterRace = r; + } + else + { + CharacterRace = Race.White; + } + CharacterHairIndex = subElement.GetAttributeInt("hairindex", CharacterHairIndex); + CharacterBeardIndex = subElement.GetAttributeInt("beardindex", CharacterBeardIndex); + CharacterMoustacheIndex = subElement.GetAttributeInt("moustacheindex", CharacterMoustacheIndex); + CharacterFaceAttachmentIndex = subElement.GetAttributeInt("faceattachmentindex", CharacterFaceAttachmentIndex); + break; + case "tutorials": + foreach (XElement tutorialElement in subElement.Elements()) + { + CompletedTutorialNames.Add(tutorialElement.GetAttributeString("name", "")); + } + break; + } + } + + UnsavedSettings = false; + + selectedContentPackagePaths = new HashSet(); + foreach (XElement subElement in doc.Root.Elements()) { gSettings = new XElement("graphicssettings");