Merge https://github.com/Regalis11/Barotrauma into develop
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Barotrauma.Extensions;
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using Barotrauma.Extensions;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
@@ -199,8 +199,8 @@ namespace Barotrauma
|
||||
if (GameMain.GraphicsWidth <= maxResolution.X && GameMain.GraphicsHeight <= maxResolution.Y)
|
||||
{
|
||||
size = new Point(
|
||||
subElement.GetAttributeInt("width", 0),
|
||||
subElement.GetAttributeInt("height", 0));
|
||||
ParseSize(subElement, "width"),
|
||||
ParseSize(subElement, "height"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -533,7 +533,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (characterInfo.MinReputationToHire.factionId != Identifier.Empty)
|
||||
{
|
||||
if (campaign.GetReputation(characterInfo.MinReputationToHire.factionId) < characterInfo.MinReputationToHire.reputation)
|
||||
if (MathF.Round(campaign.GetReputation(characterInfo.MinReputationToHire.factionId)) < characterInfo.MinReputationToHire.reputation)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Barotrauma.Extensions;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Xml.Linq;
|
||||
using Barotrauma.Extensions;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
@@ -20,6 +18,26 @@ namespace Barotrauma
|
||||
{
|
||||
return element.NameAsIdentifier();
|
||||
}
|
||||
|
||||
protected int ParseSize(XElement element, string attributeName)
|
||||
{
|
||||
string valueStr = element.GetAttributeString(attributeName, string.Empty);
|
||||
bool relativeToWidth = valueStr.EndsWith("vw");
|
||||
bool relativeToHeight = valueStr.EndsWith("vh");
|
||||
if (relativeToWidth || relativeToHeight)
|
||||
{
|
||||
string floatStr = valueStr.Substring(0, valueStr.Length - 2);
|
||||
if (!float.TryParse(floatStr, NumberStyles.Any, CultureInfo.InvariantCulture, out float relativeHeight))
|
||||
{
|
||||
DebugConsole.ThrowError($"Error while parsing a {nameof(GUIComponentStyle)}: {valueStr} is not a valid size.");
|
||||
}
|
||||
return (int)(relativeHeight / 100.0f * (relativeToWidth ? GameMain.GraphicsWidth : GameMain.GraphicsHeight));
|
||||
}
|
||||
else
|
||||
{
|
||||
return element.GetAttributeInt(attributeName, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class GUISelector<T> where T : GUIPrefab
|
||||
@@ -166,7 +184,8 @@ namespace Barotrauma
|
||||
Point maxResolution = subElement.GetAttributePoint("maxresolution", new Point(int.MaxValue, int.MaxValue));
|
||||
if (GameMain.GraphicsWidth <= maxResolution.X && GameMain.GraphicsHeight <= maxResolution.Y)
|
||||
{
|
||||
return (uint)Math.Round(subElement.GetAttributeInt("size", 14) * GameSettings.CurrentConfig.Graphics.TextScale);
|
||||
int rawSize = ParseSize(subElement, "size");
|
||||
return (uint)Math.Round(rawSize * GameSettings.CurrentConfig.Graphics.TextScale);
|
||||
}
|
||||
}
|
||||
return (uint)Math.Round(defaultSize * GameSettings.CurrentConfig.Graphics.TextScale);
|
||||
|
||||
@@ -542,6 +542,7 @@ namespace Barotrauma
|
||||
void drawRect(Vector2 topLeft, Vector2 bottomRight)
|
||||
{
|
||||
int minWidth = GUI.IntScale(5);
|
||||
if (OverflowClip) { topLeft.X = Math.Max(topLeft.X, 0.0f); }
|
||||
if (bottomRight.X - topLeft.X < minWidth) { bottomRight.X = topLeft.X + minWidth; }
|
||||
GUI.DrawRectangle(spriteBatch,
|
||||
Rect.Location.ToVector2() + topLeft,
|
||||
|
||||
@@ -159,8 +159,9 @@ namespace Barotrauma
|
||||
|
||||
int crewAreaY = ButtonAreaTop.Bottom + Padding;
|
||||
int crewAreaHeight = ObjectiveAnchor.Top - Padding - crewAreaY;
|
||||
CrewArea = new Rectangle(Padding, crewAreaY, (int)Math.Max(400 * GUI.Scale, 220), crewAreaHeight);
|
||||
|
||||
float crewAreaWidthMultiplier = GUI.IsUltrawide ? GUI.HorizontalAspectRatio : 1.0f;
|
||||
CrewArea = new Rectangle(Padding, crewAreaY, (int)(Math.Max(400 * GUI.Scale, 220) * crewAreaWidthMultiplier), crewAreaHeight);
|
||||
InventoryAreaLower = new Rectangle(ChatBoxArea.Right + Padding * 7, inventoryTopY, GameMain.GraphicsWidth - Padding * 9 - ChatBoxArea.Width, GameMain.GraphicsHeight - inventoryTopY);
|
||||
|
||||
int healthWindowWidth = (int)(GameMain.GraphicsWidth * 0.5f);
|
||||
|
||||
@@ -175,6 +175,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (relativeOffset.NearlyEquals(value)) { return; }
|
||||
relativeOffset = value;
|
||||
recalculateRect = true;
|
||||
RecalculateChildren(false, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -870,7 +870,7 @@ namespace Barotrauma
|
||||
{
|
||||
foreach (var minRep in priceInfo.MinReputation)
|
||||
{
|
||||
if (campaign.GetReputation(minRep.Key) < minRep.Value)
|
||||
if (MathF.Round(campaign.GetReputation(minRep.Key)) < minRep.Value)
|
||||
{
|
||||
return minRep;
|
||||
}
|
||||
@@ -1930,7 +1930,7 @@ namespace Barotrauma
|
||||
"campaignstore.reputationrequired",
|
||||
("[amount]", ((int)requiredReputation.Value.Value).ToString()),
|
||||
("[faction]", TextManager.Get("faction." + requiredReputation.Value.Key).Value));
|
||||
Color color = campaign.GetReputation(requiredReputation.Value.Key) < requiredReputation.Value.Value ?
|
||||
Color color = MathF.Round(campaign.GetReputation(requiredReputation.Value.Key)) < requiredReputation.Value.Value ?
|
||||
GUIStyle.Orange : GUIStyle.Green;
|
||||
toolTip += $"\n‖color:{color.ToStringHex()}‖{repStr}‖color:end‖";
|
||||
}
|
||||
|
||||
@@ -807,8 +807,10 @@ namespace Barotrauma
|
||||
{
|
||||
if (GameMain.Client == null)
|
||||
{
|
||||
GameMain.GameSession.PurchaseSubmarine(selectedSubmarine);
|
||||
GameMain.GameSession.SwitchSubmarine(selectedSubmarine, TransferItemsOnSwitch);
|
||||
if (GameMain.GameSession.TryPurchaseSubmarine(selectedSubmarine))
|
||||
{
|
||||
GameMain.GameSession.SwitchSubmarine(selectedSubmarine, TransferItemsOnSwitch);
|
||||
}
|
||||
RefreshSubmarineDisplay(true);
|
||||
}
|
||||
else
|
||||
@@ -829,7 +831,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (GameMain.Client == null)
|
||||
{
|
||||
GameMain.GameSession.PurchaseSubmarine(selectedSubmarine);
|
||||
GameMain.GameSession.TryPurchaseSubmarine(selectedSubmarine);
|
||||
RefreshSubmarineDisplay(true);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -1722,7 +1722,7 @@ namespace Barotrauma
|
||||
static void CreateMaterialCosts(GUIListBox list, UpgradePrefab prefab, int targetLevel)
|
||||
{
|
||||
list.Content.ClearChildren();
|
||||
List<Item> allItems = Character.Controlled?.Inventory?.FindAllItems(recursive: true) ?? new List<Item>();
|
||||
var allItems = CargoManager.FindAllItemsOnPlayerAndSub(Character.Controlled);
|
||||
|
||||
var resources = prefab.GetApplicableResources(targetLevel);
|
||||
|
||||
|
||||
@@ -23,9 +23,12 @@ namespace Barotrauma
|
||||
private float votingTime = 100f;
|
||||
private float timer;
|
||||
private VoteType currentVoteType;
|
||||
private Color SubmarineColor => GUIStyle.Orange;
|
||||
private static Color SubmarineColor => GUIStyle.Orange;
|
||||
private Point createdForResolution;
|
||||
|
||||
//timer ran out but server still hasn't notified of the result of the vote
|
||||
public bool TimedOut => VoteRunning && timer - votingTime > 10.0f;
|
||||
|
||||
public static VotingInterface CreateSubmarineVotingInterface(Client starter, SubmarineInfo info, VoteType type, bool transferItems, float votingTime)
|
||||
{
|
||||
if (starter == null || info == null) { return null; }
|
||||
|
||||
Reference in New Issue
Block a user