(33abbb810) Fixed: Interfaces that were too small on 4k by removing the use of maxsize & adding scale related multipliers to absolute values

This commit is contained in:
Joonas Rikkonen
2019-05-18 17:24:54 +03:00
parent 73bfd8d4a4
commit 75b88e0c18
18 changed files with 106 additions and 85 deletions
@@ -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;
@@ -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)
@@ -293,7 +293,7 @@ namespace Barotrauma.Tutorials
// Room 3
do { yield return null; } while (!mechanic_weldingObjectiveSensor.MotionDetected);
TriggerTutorialSegment(2, GameMain.Config.KeyBind(InputType.Aim), GameMain.Config.KeyBind(InputType.Shoot)); // Welding objective
TriggerTutorialSegment(2, GameMain.Config.KeyBind(InputType.Shoot), GameMain.Config.KeyBind(InputType.Aim)); // Welding objective
do
{
if (!mechanic.HasEquippedItem("divingmask"))
@@ -334,13 +334,14 @@ namespace Barotrauma.Tutorials
//TriggerTutorialSegment(11, GameMain.Config.KeyBind(InputType.Select), GameMain.Config.KeyBind(InputType.Up), GameMain.Config.KeyBind(InputType.Down), GameMain.Config.KeyBind(InputType.Select)); // Ladder objective
//do { yield return null; } while (!mechanic_ladderSensor.MotionDetected);
//RemoveCompletedObjective(segments[11]);
yield return new WaitForSeconds(2f);
GameMain.GameSession?.CrewManager.AddSinglePlayerChatMessage(radioSpeakerName, TextManager.Get("Mechanic.Radio.News"), ChatMessageType.Radio, null);
yield return new WaitForSeconds(1f);
GameMain.GameSession?.CrewManager.AddSinglePlayerChatMessage(radioSpeakerName, TextManager.Get("Mechanic.Radio.Fire"), ChatMessageType.Radio, null);
yield return new WaitForSeconds(6f);
// Room 4
do { yield return null; } while (!mechanic_thirdDoor.IsOpen);
yield return new WaitForSeconds(1f);
mechanic_fire = new DummyFireSource(new Vector2(20f, 2f), Item.ItemList.Find(i => i.HasTag("mechanic_fire")).WorldPosition);
//do { yield return null; } while (!mechanic_craftingObjectiveSensor.MotionDetected);
TriggerTutorialSegment(4); // Deconstruct
@@ -755,7 +755,7 @@ namespace Barotrauma
OnClicked = (button, data) =>
{
// TODO: add a prompt
LoadDefaultConfig(setLanguage: false);
LoadDefaultConfig();
CheckBindings(true);
RefreshItemMessages();
ApplySettings();
@@ -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
@@ -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,
@@ -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));
}
}
@@ -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<GUIButton>();
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
};
@@ -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"),
@@ -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);
@@ -95,7 +95,7 @@ namespace Barotrauma.Items.Components
else
{
c.Draw(spriteBatch, panel, leftPos,
new Vector2(leftPos.X + 20, leftPos.Y - 12),
new Vector2(leftPos.X + 20 * GUI.xScale, leftPos.Y - 12 * GUI.yScale),
leftWirePos,
mouseInRect, equippedWire,
wireInterval);
@@ -317,7 +317,7 @@ namespace Barotrauma.Items.Components
if (ShowProjectileIndicator)
{
Point slotSize = new Point(60, 30);
Point slotSize = new Point((int)(60 * GUI.Scale), (int)(30 * GUI.Scale));
int spacing = 5;
int slotsPerRow = Math.Min(availableAmmo.Count, 6);
int totalWidth = slotSize.X * slotsPerRow + spacing * (slotsPerRow - 1);
@@ -361,9 +361,6 @@
<Content Include="$(MSBuildThisFileDirectory)Content\Effects\waterbump.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="$(MSBuildThisFileDirectory)Content\Fonts\Exo2-SemiBold.otf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="$(MSBuildThisFileDirectory)Content\Fonts\NotoSans\NotoSansCJKsc-Bold.otf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
@@ -146,7 +146,7 @@ namespace Barotrauma
{
bool isDifferentTarget = Vector2.DistanceSquared(target, currentTarget) > 1;
//find a new path if one hasn't been found yet or the target is different from the current target
if (currentPath == null || isDifferentTarget || findPathTimer < -1.0f)
if (currentPath == null || Vector2.DistanceSquared(target, currentTarget) > 1.0f || findPathTimer < -1.0f)
{
IsPathDirty = true;
@@ -163,11 +163,7 @@ namespace Barotrauma
}
}
var newPath = pathFinder.FindPath(pos, target, "(Character: " + character.Name + ")");
if (currentPath == null || isDifferentTarget || newPath.Cost < currentPath.Cost)
{
currentPath = newPath;
}
currentPath = pathFinder.FindPath(pos, target, "(Character: " + character.Name + ")");
findPathTimer = Rand.Range(1.0f, 1.2f);
@@ -175,7 +175,7 @@ namespace Barotrauma
{
if (character.CanInteractWith(item, out _, checkLinked: false)) { isCompleted = true; }
}
else if (Target is Character targetCharacter && !FollowControlledCharacter)
else if (Target is Character targetCharacter)
{
if (character.CanInteractWith(targetCharacter, CloseEnough)) { isCompleted = true; }
}
@@ -230,6 +230,13 @@ namespace Barotrauma
//if searching for a path inside the sub, make sure the waypoint is visible
if (insideSubmarine)
{
// Doesn't seem to work
//var body = Submarine.CheckVisibility(end, node.Waypoint.SimPosition);
//if (body != null && body.UserData is Structure)
//{
// continue;
//}
var body = Submarine.PickBody(end, node.Waypoint.SimPosition, null,
Physics.CollisionWall | Physics.CollisionLevel | Physics.CollisionStairs );
@@ -415,17 +415,6 @@ namespace Barotrauma
}
}
#region Load DefaultConfig
private void LoadDefaultConfig(bool setLanguage = true)
{
XDocument doc = XMLExtensions.TryLoadXml(savePath);
if (setLanguage || string.IsNullOrEmpty(Language))
{
Language = doc.Root.GetAttributeString("language", "English");
}
}
#region Load DefaultConfig
private void LoadDefaultConfig()
{
@@ -443,26 +432,6 @@ namespace Barotrauma
QuickStartSubmarineName = doc.Root.GetAttributeString("quickstartsub", "");
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", "");
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", "");
if (doc == null)
{
GraphicsWidth = 1024;
@@ -848,6 +817,58 @@ namespace Barotrauma
{
VoiceSetting = voiceSetting;
}
foreach (ContentFile file in contentPackage.Files)
{
ToolBox.IsProperFilenameCase(file.Path);
}
}
if (!SelectedContentPackages.Any())
{
var availablePackage = ContentPackage.List.FirstOrDefault(cp => cp.IsCompatible() && cp.CorePackage);
if (availablePackage != null)
{
SelectedContentPackages.Add(availablePackage);
}
}
//save to get rid of the invalid selected packages in the config file
if (missingPackagePaths.Count > 0 || incompatiblePackages.Count > 0) { SaveNewPlayerConfig(); }
}
#endregion
#region Save DefaultConfig
private void SaveNewDefaultConfig()
{
XDocument doc = new XDocument();
if (doc.Root == null)
{
doc.Add(new XElement("config"));
}
doc.Root.Add(
new XAttribute("language", TextManager.Language),
new XAttribute("masterserverurl", MasterServerUrl),
new XAttribute("autocheckupdates", AutoCheckUpdates),
new XAttribute("musicvolume", musicVolume),
new XAttribute("soundvolume", soundVolume),
new XAttribute("voicechatvolume", voiceChatVolume),
new XAttribute("verboselogging", VerboseLogging),
new XAttribute("savedebugconsolelogs", SaveDebugConsoleLogs),
new XAttribute("enablesplashscreen", EnableSplashScreen),
new XAttribute("usesteammatchmaking", useSteamMatchmaking),
new XAttribute("quickstartsub", QuickStartSubmarineName),
new XAttribute("requiresteamauthentication", requireSteamAuthentication),
new XAttribute("aimassistamount", aimAssistAmount));
if (!ShowUserStatisticsPrompt)
{
doc.Root.Add(new XAttribute("senduserstatistics", sendUserStatistics));
}
if (WasGameUpdated)
{
doc.Root.Add(new XAttribute("wasgameupdated", true));
}
useSteamMatchmaking = doc.Root.GetAttributeBool("usesteammatchmaking", useSteamMatchmaking);
@@ -602,7 +602,7 @@ namespace Barotrauma
if (ladderItem != null) Ladders = ladderItem.GetComponent<Ladder>();
}
Body pickedBody = Submarine.PickBody(SimPosition, SimPosition - Vector2.UnitY * 2.0f, null, Physics.CollisionStairs);
Body pickedBody = Submarine.PickBody(SimPosition, SimPosition - Vector2.UnitY * 2.0f, null, Physics.CollisionWall | Physics.CollisionStairs);
if (pickedBody != null && pickedBody.UserData is Structure)
{
Structure structure = (Structure)pickedBody.UserData;
-15
View File
@@ -1,18 +1,3 @@
---------------------------------------------------------------------------------------------------------
v0.9.0.2
---------------------------------------------------------------------------------------------------------
- Fixed a bug that caused frequent desync kicks when playing a multiplayer monster mission.
- Fixed an index out of range error in DoctorTutorial if proceeding too fast to the submarine.
- Fixes to missing translations and UI layout problems when using languages other than English.
- More readable font and a fix to some texts appearing slightly "clipped".
- Additions to the credits.
- Fixed bots loading only half of the target items in the contain item objective.
- Minor tweaks to subs and shuttles.
- Fixed find safety AI objective not working properly.
- Miscellaneous crew AI fixes and improvements.
- Fixed incorrect reward amount in the "Chemical shipment" description.
---------------------------------------------------------------------------------------------------------
v0.9.0.1
---------------------------------------------------------------------------------------------------------