(98ad00fa2) v0.9.1.0
This commit is contained in:
@@ -19,6 +19,8 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
private GUIComponent inSufficientPowerWarning;
|
||||
|
||||
private bool pendingState;
|
||||
|
||||
partial void InitProjSpecific(XElement element)
|
||||
{
|
||||
var paddedFrame = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.9f), GuiFrame.RectTransform, Anchor.Center), childAnchor: Anchor.TopCenter)
|
||||
@@ -73,32 +75,34 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public override void UpdateHUD(Character character, float deltaTime, Camera cam)
|
||||
{
|
||||
inSufficientPowerWarning.Visible = powerConsumption > 0 && voltage < minVoltage;
|
||||
//activateButton.Enabled = !inSufficientPowerWarning.Visible;
|
||||
inSufficientPowerWarning.Visible = CurrPowerConsumption > 0 && !hasPower;
|
||||
}
|
||||
|
||||
private bool ToggleActive(GUIButton button, object obj)
|
||||
{
|
||||
SetActive(!IsActive, Character.Controlled);
|
||||
|
||||
currPowerConsumption = IsActive ? powerConsumption : 0.0f;
|
||||
|
||||
if (GameMain.Client != null)
|
||||
{
|
||||
pendingState = !IsActive;
|
||||
item.CreateClientEvent(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetActive(!IsActive, Character.Controlled);
|
||||
currPowerConsumption = IsActive ? powerConsumption : 0.0f;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void ClientWrite(NetBuffer msg, object[] extraData = null)
|
||||
{
|
||||
msg.Write(IsActive);
|
||||
msg.Write(pendingState);
|
||||
}
|
||||
|
||||
public void ClientRead(ServerNetObject type, NetBuffer msg, float sendingTime)
|
||||
{
|
||||
SetActive(msg.ReadBoolean());
|
||||
progressTimer = msg.ReadSingle();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,8 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
private GUIComponent inSufficientPowerWarning;
|
||||
|
||||
private FabricationRecipe pendingFabricatedItem;
|
||||
|
||||
private Pair<Rectangle, string> tooltip;
|
||||
|
||||
partial void InitProjSpecific()
|
||||
@@ -403,7 +405,7 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private bool StartButtonClicked(GUIButton button, object obj)
|
||||
{
|
||||
if (selectedItem == null) { return false; }
|
||||
@@ -412,19 +414,22 @@ namespace Barotrauma.Items.Components
|
||||
outputInventoryHolder.Flash(Color.Red);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (fabricatedItem == null)
|
||||
|
||||
if (GameMain.Client != null)
|
||||
{
|
||||
StartFabricating(selectedItem, Character.Controlled);
|
||||
pendingFabricatedItem = fabricatedItem != null ? null : selectedItem;
|
||||
item.CreateClientEvent(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
CancelFabricating(Character.Controlled);
|
||||
}
|
||||
|
||||
if (GameMain.Client != null)
|
||||
{
|
||||
item.CreateClientEvent(this);
|
||||
if (fabricatedItem == null)
|
||||
{
|
||||
StartFabricating(selectedItem, Character.Controlled);
|
||||
}
|
||||
else
|
||||
{
|
||||
CancelFabricating(Character.Controlled);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -433,7 +438,7 @@ namespace Barotrauma.Items.Components
|
||||
public override void UpdateHUD(Character character, float deltaTime, Camera cam)
|
||||
{
|
||||
activateButton.Enabled = false;
|
||||
inSufficientPowerWarning.Visible = powerConsumption > 0 && voltage < minVoltage;
|
||||
inSufficientPowerWarning.Visible = currPowerConsumption > 0 && !hasPower;
|
||||
|
||||
var availableIngredients = GetAvailableIngredients();
|
||||
if (character != null)
|
||||
@@ -457,7 +462,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public void ClientWrite(NetBuffer msg, object[] extraData = null)
|
||||
{
|
||||
int itemIndex = fabricatedItem == null ? -1 : fabricationRecipes.IndexOf(fabricatedItem);
|
||||
int itemIndex = pendingFabricatedItem == null ? -1 : fabricationRecipes.IndexOf(pendingFabricatedItem);
|
||||
msg.WriteRangedInteger(-1, fabricationRecipes.Count - 1, itemIndex);
|
||||
}
|
||||
|
||||
@@ -474,8 +479,8 @@ namespace Barotrauma.Items.Components
|
||||
else
|
||||
{
|
||||
//if already fabricating the selected item, return
|
||||
if (fabricatedItem != null && fabricationRecipes.IndexOf(fabricatedItem) == itemIndex) return;
|
||||
if (itemIndex < 0 || itemIndex >= fabricationRecipes.Count) return;
|
||||
if (fabricatedItem != null && fabricationRecipes.IndexOf(fabricatedItem) == itemIndex) { return; }
|
||||
if (itemIndex < 0 || itemIndex >= fabricationRecipes.Count) { return; }
|
||||
|
||||
SelectItem(user, fabricationRecipes[itemIndex]);
|
||||
StartFabricating(fabricationRecipes[itemIndex], user);
|
||||
|
||||
@@ -17,10 +17,14 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
private GUITextBlock hullNameText, hullBreachText, hullAirQualityText, hullWaterText;
|
||||
|
||||
private string noPowerTip = "";
|
||||
|
||||
private List<Submarine> displayedSubs = new List<Submarine>();
|
||||
|
||||
partial void InitProjSpecific(XElement element)
|
||||
{
|
||||
noPowerTip = TextManager.Get("SteeringNoPowerTip");
|
||||
|
||||
GuiFrame.RectTransform.RelativeOffset = new Vector2(0.4f, 0.0f);
|
||||
new GUICustomComponent(new RectTransform(new Vector2(0.9f, 0.85f), GuiFrame.RectTransform, Anchor.Center),
|
||||
DrawHUDBack, null);
|
||||
@@ -105,6 +109,16 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
private void DrawHUDFront(SpriteBatch spriteBatch, GUICustomComponent container)
|
||||
{
|
||||
if (voltage < minVoltage)
|
||||
{
|
||||
Vector2 textSize = GUI.Font.MeasureString(noPowerTip);
|
||||
Vector2 textPos = GuiFrame.Rect.Center.ToVector2();
|
||||
|
||||
GUI.DrawString(spriteBatch, textPos - textSize / 2, noPowerTip,
|
||||
Color.Orange * (float)Math.Abs(Math.Sin(Timing.TotalTime)), Color.Black * 0.8f);
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (GUIComponent child in submarineContainer.Children.First().Children)
|
||||
{
|
||||
if (child.UserData is Hull hull)
|
||||
@@ -145,6 +159,11 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
}
|
||||
|
||||
if (voltage < minVoltage)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
float scale = 1.0f;
|
||||
HashSet<Submarine> subs = new HashSet<Submarine>();
|
||||
foreach (Hull hull in Hull.hullList)
|
||||
|
||||
@@ -34,7 +34,8 @@ namespace Barotrauma.Items.Components
|
||||
private GUITickBox directionalTickBox;
|
||||
private GUIScrollBar directionalSlider;
|
||||
|
||||
private GUIComponent activeControlsContainer;
|
||||
private GUILayoutGroup activeControlsContainer;
|
||||
private GUIFrame controlContainer;
|
||||
|
||||
private GUICustomComponent sonarView;
|
||||
|
||||
@@ -76,12 +77,11 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
sonarBlips = new List<SonarBlip>();
|
||||
|
||||
int viewSize = (int)Math.Min(GuiFrame.Rect.Width - 150, GuiFrame.Rect.Height * 0.9f);
|
||||
sonarView = new GUICustomComponent(new RectTransform(new Point(viewSize), GuiFrame.RectTransform, Anchor.CenterLeft),
|
||||
sonarView = new GUICustomComponent(new RectTransform(Point.Zero, GuiFrame.RectTransform, Anchor.CenterLeft),
|
||||
(spriteBatch, guiCustomComponent) => { DrawSonar(spriteBatch, guiCustomComponent.Rect); }, null);
|
||||
|
||||
var controlContainer = new GUIFrame(new RectTransform(new Vector2(0.3f, 0.35f), GuiFrame.RectTransform, Anchor.TopLeft)
|
||||
{ MinSize = new Point(150, 0), AbsoluteOffset = new Point((int)(viewSize * 0.9f), 0) }, "SonarFrame");
|
||||
controlContainer = new GUIFrame(new RectTransform(new Vector2(0.3f, 0.35f), GuiFrame.RectTransform, Anchor.TopLeft)
|
||||
{ MinSize = new Point(150, 0) }, "SonarFrame");
|
||||
|
||||
controlContainer.RectTransform.SetAsFirstChild();
|
||||
|
||||
@@ -200,6 +200,18 @@ namespace Barotrauma.Items.Components
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
SetUILayout();
|
||||
|
||||
GameMain.Instance.OnResolutionChanged += SetUILayout;
|
||||
GameMain.Config.OnHUDScaleChanged += SetUILayout;
|
||||
}
|
||||
|
||||
private void SetUILayout()
|
||||
{
|
||||
int viewSize = (int)Math.Min(GuiFrame.Rect.Width - 150, GuiFrame.Rect.Height * 0.9f);
|
||||
sonarView.RectTransform.NonScaledSize = new Point(viewSize);
|
||||
controlContainer.RectTransform.AbsoluteOffset = new Point((int)(viewSize * 0.9f), 0);
|
||||
}
|
||||
|
||||
public override void OnItemLoaded()
|
||||
@@ -612,6 +624,16 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
if (Level.Loaded != null && dockingPort.Item.Submarine.WorldPosition.Y > Level.Loaded.Size.Y) { continue; }
|
||||
|
||||
//don't show the docking ports of the opposing team on the sonar
|
||||
if (item.Submarine != null && dockingPort.Item.Submarine != null)
|
||||
{
|
||||
if ((dockingPort.Item.Submarine.TeamID == Character.TeamType.Team1 && item.Submarine.TeamID == Character.TeamType.Team2) ||
|
||||
(dockingPort.Item.Submarine.TeamID == Character.TeamType.Team2 && item.Submarine.TeamID == Character.TeamType.Team1))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
Vector2 offset = (dockingPort.Item.WorldPosition - transducerCenter) * scale;
|
||||
offset.Y = -offset.Y;
|
||||
if (offset.LengthSquared() > DisplayRadius * DisplayRadius) { continue; }
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace Barotrauma.Items.Components
|
||||
};
|
||||
private GUITickBox maintainPosTickBox, levelEndTickBox, levelStartTickBox;
|
||||
|
||||
private GUIComponent statusContainer, dockingContainer;
|
||||
private GUIComponent statusContainer, dockingContainer, controlContainer;
|
||||
|
||||
private bool dockingNetworkMessagePending;
|
||||
|
||||
@@ -86,9 +86,8 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
partial void InitProjSpecific(XElement element)
|
||||
{
|
||||
int viewSize = (int)Math.Min(GuiFrame.Rect.Width - 150, GuiFrame.Rect.Height * 0.9f);
|
||||
var controlContainer = new GUIFrame(new RectTransform(new Vector2(0.3f, 0.35f), GuiFrame.RectTransform, Anchor.CenterLeft)
|
||||
{ MinSize = new Point(150, 0), AbsoluteOffset = new Point((int)(viewSize * 0.99f), (int)(viewSize * 0.05f)) }, "SonarFrame");
|
||||
controlContainer = new GUIFrame(new RectTransform(new Vector2(0.3f, 0.35f), GuiFrame.RectTransform, Anchor.CenterLeft)
|
||||
{ MinSize = new Point(150, 0) }, "SonarFrame");
|
||||
var paddedControlContainer = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.8f), controlContainer.RectTransform, Anchor.Center))
|
||||
{
|
||||
RelativeSpacing = 0.03f,
|
||||
@@ -96,7 +95,7 @@ namespace Barotrauma.Items.Components
|
||||
};
|
||||
|
||||
statusContainer = new GUIFrame(new RectTransform(new Vector2(0.3f, 0.25f), GuiFrame.RectTransform, Anchor.BottomLeft)
|
||||
{ MinSize = new Point(150, 0), AbsoluteOffset = new Point((int)(viewSize * 0.9f), 0) }, "SonarFrame");
|
||||
{ MinSize = new Point(150, 0) }, "SonarFrame");
|
||||
var paddedStatusContainer = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.9f), statusContainer.RectTransform, Anchor.Center))
|
||||
{
|
||||
RelativeSpacing = 0.03f,
|
||||
@@ -295,12 +294,12 @@ namespace Barotrauma.Items.Components
|
||||
autoPilotLevelEndTip = TextManager.GetWithVariable("SteeringAutoPilotLocationTip", "[locationname]",
|
||||
GameMain.GameSession?.EndLocation == null ? "End" : GameMain.GameSession.EndLocation.Name);
|
||||
|
||||
steerArea = new GUICustomComponent(new RectTransform(new Point(viewSize), GuiFrame.RectTransform, Anchor.CenterLeft),
|
||||
steerArea = new GUICustomComponent(new RectTransform(Point.Zero, GuiFrame.RectTransform, Anchor.CenterLeft),
|
||||
(spriteBatch, guiCustomComponent) => { DrawHUD(spriteBatch, guiCustomComponent.Rect); }, null);
|
||||
|
||||
//docking interface ----------------------------------------------------
|
||||
dockingContainer = new GUIFrame(new RectTransform(new Vector2(0.3f, 0.25f), GuiFrame.RectTransform, Anchor.BottomLeft)
|
||||
{ MinSize = new Point(150, 0), AbsoluteOffset = new Point((int)(viewSize * 0.9f), 0) }, style: null);
|
||||
{ MinSize = new Point(150, 0) }, style: null);
|
||||
var paddedDockingContainer = new GUIFrame(new RectTransform(new Vector2(0.9f, 0.9f), dockingContainer.RectTransform, Anchor.Center), style: null);
|
||||
|
||||
//TODO: add new texts for these ("Dock" & "Undock")
|
||||
@@ -364,6 +363,21 @@ namespace Barotrauma.Items.Components
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
SetUILayout();
|
||||
|
||||
GameMain.Instance.OnResolutionChanged += SetUILayout;
|
||||
GameMain.Config.OnHUDScaleChanged += SetUILayout;
|
||||
}
|
||||
|
||||
private void SetUILayout()
|
||||
{
|
||||
int viewSize = (int)Math.Min(GuiFrame.Rect.Width - 150, GuiFrame.Rect.Height * 0.9f);
|
||||
|
||||
controlContainer.RectTransform.AbsoluteOffset = new Point((int)(viewSize * 0.99f), (int)(viewSize * 0.05f));
|
||||
statusContainer.RectTransform.AbsoluteOffset = new Point((int)(viewSize * 0.9f), 0);
|
||||
steerArea.RectTransform.NonScaledSize = new Point(viewSize);
|
||||
dockingContainer.RectTransform.AbsoluteOffset = new Point((int)(viewSize * 0.9f), 0);
|
||||
}
|
||||
|
||||
private void FindConnectedDockingPort()
|
||||
|
||||
@@ -41,8 +41,9 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
|
||||
Wire equippedWire = null;
|
||||
|
||||
if (!panel.Locked || Screen.Selected == GameMain.SubEditorScreen)
|
||||
|
||||
bool allowRewiring = GameMain.NetworkMember?.ServerSettings == null || GameMain.NetworkMember.ServerSettings.AllowRewiring;
|
||||
if (allowRewiring && (!panel.Locked || Screen.Selected == GameMain.SubEditorScreen))
|
||||
{
|
||||
//if the Character using the panel has a wire item equipped
|
||||
//and the wire hasn't been connected yet, draw it on the panel
|
||||
@@ -278,7 +279,8 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
ConnectionPanel.HighlightedWire = wire;
|
||||
|
||||
if (!wire.Locked && (!panel.Locked || Screen.Selected == GameMain.SubEditorScreen))
|
||||
bool allowRewiring = GameMain.NetworkMember?.ServerSettings == null || GameMain.NetworkMember.ServerSettings.AllowRewiring;
|
||||
if (allowRewiring && !wire.Locked && (!panel.Locked || Screen.Selected == GameMain.SubEditorScreen))
|
||||
{
|
||||
//start dragging the wire
|
||||
if (PlayerInput.LeftButtonHeld()) draggingConnected = wire;
|
||||
|
||||
Reference in New Issue
Block a user