(aa84bc3c8) Fixed: UI Scaling issues in 4k
This commit is contained in:
@@ -273,7 +273,7 @@ namespace Barotrauma
|
||||
{
|
||||
IsHorizontal = false
|
||||
};
|
||||
cprButton = new GUIButton(new RectTransform(new Point(80, 80), GUI.Canvas), text: "", style: "CPRButton")
|
||||
cprButton = new GUIButton(new RectTransform(new Point((int)(80 * GUI.Scale)), GUI.Canvas), text: "", style: "CPRButton")
|
||||
{
|
||||
OnClicked = (button, userData) =>
|
||||
{
|
||||
|
||||
@@ -91,7 +91,7 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
InnerFrame.RectTransform.NonScaledSize =
|
||||
new Point(InnerFrame.Rect.Width, (int)Math.Max(height / Content.RectTransform.RelativeSize.Y, height + 50));
|
||||
new Point(InnerFrame.Rect.Width, (int)Math.Max(height / Content.RectTransform.RelativeSize.Y, height + (int)(50 * GUI.yScale)));
|
||||
Content.RectTransform.NonScaledSize =
|
||||
new Point(Content.Rect.Width, height);
|
||||
}
|
||||
@@ -99,7 +99,7 @@ namespace Barotrauma
|
||||
Buttons = new List<GUIButton>(buttons.Length);
|
||||
for (int i = 0; i < buttons.Length; i++)
|
||||
{
|
||||
var button = new GUIButton(new RectTransform(new Vector2(Math.Min(0.9f / buttons.Length, 0.5f), 1.0f), buttonContainer.RectTransform, maxSize: new Point(300, 35)), buttons[i], style: "GUIButtonLarge");
|
||||
var button = new GUIButton(new RectTransform(new Vector2(Math.Min(0.9f / buttons.Length, 0.5f), 1.0f), buttonContainer.RectTransform), buttons[i], style: "GUIButtonLarge");
|
||||
Buttons.Add(button);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,8 +31,6 @@ namespace Barotrauma
|
||||
private bool masterServerResponded;
|
||||
private IRestResponse masterServerResponse;
|
||||
|
||||
private GUIButton refreshButton;
|
||||
|
||||
private float[] columnRelativeWidth;
|
||||
|
||||
//filters
|
||||
@@ -142,7 +140,7 @@ namespace Barotrauma
|
||||
OnClicked = GameMain.MainMenuScreen.ReturnToMainMenu
|
||||
};
|
||||
|
||||
refreshButton = new GUIButton(new RectTransform(new Vector2(buttonContainer.Rect.Height / (float)buttonContainer.Rect.Width, 0.9f), buttonContainer.RectTransform, Anchor.Center),
|
||||
var refreshButton = new GUIButton(new RectTransform(new Vector2(buttonContainer.Rect.Height / (float)buttonContainer.Rect.Width, 0.9f), buttonContainer.RectTransform, Anchor.Center),
|
||||
"", style: "GUIButtonRefresh") {
|
||||
|
||||
ToolTip = TextManager.Get("ServerListRefresh"),
|
||||
@@ -222,6 +220,22 @@ namespace Barotrauma
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool RefreshJoinButtonState(GUIComponent component, object obj)
|
||||
{
|
||||
if (obj == null || waitingForRefresh) return false;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(clientNameBox.Text) && !string.IsNullOrWhiteSpace(ipBox.Text))
|
||||
{
|
||||
joinButton.Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
joinButton.Enabled = false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool SelectServer(GUIComponent component, object obj)
|
||||
{
|
||||
if (obj == null || waitingForRefresh) { return false; }
|
||||
@@ -236,6 +250,16 @@ namespace Barotrauma
|
||||
joinButton.Enabled = false;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(clientNameBox.Text))
|
||||
{
|
||||
joinButton.Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
clientNameBox.Flash();
|
||||
joinButton.Enabled = false;
|
||||
}
|
||||
|
||||
ServerInfo serverInfo;
|
||||
try
|
||||
{
|
||||
@@ -260,11 +284,8 @@ namespace Barotrauma
|
||||
ipBox.Text = null;
|
||||
joinButton.Enabled = false;
|
||||
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 1.0f), serverList.Content.RectTransform),
|
||||
TextManager.Get("RefreshingServerList"), textAlignment: Alignment.Center)
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), serverList.Content.RectTransform),
|
||||
TextManager.Get("RefreshingServerList"));
|
||||
|
||||
CoroutineManager.StartCoroutine(WaitForRefresh());
|
||||
|
||||
@@ -285,19 +306,17 @@ namespace Barotrauma
|
||||
if (!SteamManager.GetServers(AddToServerList, UpdateServerInfo, ServerQueryFinished))
|
||||
{
|
||||
serverList.ClearChildren();
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 1.0f), serverList.Content.RectTransform),
|
||||
TextManager.Get("ServerListNoSteamConnection"), textAlignment: Alignment.Center)
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), serverList.Content.RectTransform),
|
||||
TextManager.Get("ServerListNoSteamConnection"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CoroutineManager.StartCoroutine(SendMasterServerRequest());
|
||||
waitingForRefresh = false;
|
||||
}
|
||||
|
||||
waitingForRefresh = false;
|
||||
|
||||
refreshDisableTimer = DateTime.Now + AllowedRefreshInterval;
|
||||
|
||||
yield return CoroutineStatus.Success;
|
||||
@@ -362,11 +381,8 @@ namespace Barotrauma
|
||||
serverList.Content.ClearChildren();
|
||||
if (serverInfos.Count() == 0)
|
||||
{
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 1.0f), serverList.Content.RectTransform),
|
||||
TextManager.Get("NoServers"), textAlignment: Alignment.Center)
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), serverList.Content.RectTransform),
|
||||
TextManager.Get("NoServers"));
|
||||
return;
|
||||
}
|
||||
foreach (ServerInfo serverInfo in serverInfos)
|
||||
@@ -506,7 +522,6 @@ namespace Barotrauma
|
||||
UserData = "noresults"
|
||||
};
|
||||
}
|
||||
waitingForRefresh = false;
|
||||
}
|
||||
|
||||
private IEnumerable<object> SendMasterServerRequest()
|
||||
|
||||
@@ -478,7 +478,7 @@ namespace Barotrauma
|
||||
}
|
||||
else
|
||||
{
|
||||
var downloadBtn = new GUIButton(new RectTransform(new Point(32, 32), rightColumn.RectTransform), "+", style: null)
|
||||
var downloadBtn = new GUIButton(new RectTransform(new Point((int)(32 * GUI.Scale)), rightColumn.RectTransform), "+", style: null)
|
||||
{
|
||||
Font = GUI.LargeFont,
|
||||
Color = new Color(38, 65, 86, 255),
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace Barotrauma
|
||||
|
||||
public bool PauseOnFocusLost { get; set; } = true;
|
||||
public bool MuteOnFocusLost { get; set; }
|
||||
public bool UseDirectionalVoiceChat { get; set; } = true;
|
||||
public bool UseDirectionalVoiceChat { get; set; }
|
||||
|
||||
public enum VoiceMode
|
||||
{
|
||||
@@ -424,79 +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(bool setLanguage = true)
|
||||
{
|
||||
XDocument doc = XMLExtensions.TryLoadXml(savePath);
|
||||
|
||||
if (setLanguage || string.IsNullOrEmpty(Language))
|
||||
{
|
||||
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", "");
|
||||
|
||||
@@ -959,6 +886,55 @@ namespace Barotrauma
|
||||
|
||||
selectedContentPackagePaths = new HashSet<string>();
|
||||
|
||||
foreach (XElement subElement in doc.Root.Elements())
|
||||
{
|
||||
switch (subElement.Name.ToString().ToLowerInvariant())
|
||||
{
|
||||
case "keymapping":
|
||||
LoadKeyBinds(subElement);
|
||||
break;
|
||||
case "gameplay":
|
||||
jobPreferences = new List<string>();
|
||||
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<string>();
|
||||
|
||||
foreach (XElement subElement in doc.Root.Elements())
|
||||
{
|
||||
gSettings = new XElement("graphicssettings");
|
||||
|
||||
Reference in New Issue
Block a user