Fixed spectators joining messing up the game, textboxes are deselected when switching the screen, nerfed engineer construction level, tickboxes or textboxes cannot be selected through other ui elements

This commit is contained in:
Regalis
2016-02-16 20:52:39 +02:00
parent 9004205c80
commit f3112e29b4
19 changed files with 55 additions and 37 deletions

View File

@@ -16,7 +16,7 @@
<Job name="Engineer" description="Engineers have above-average construction and mechanic skills, but fixing complex mechanical devices is still usually out of their skill set. They are competent at fixing electrical devices however, and are the ones to turn to when the power grid starts failing." minnumber="1">
<Skills>
<Skill name="Weapons" level="10,30"/>
<Skill name="Construction" level="30,40"/>
<Skill name="Construction" level="30,30"/>
<Skill name="Electrical Engineering" level="50,60"/>
</Skills>
<Item name="ID Card"/>
@@ -29,7 +29,7 @@
<Skills>
<Skill name="Weapons" level="10,30"/>
<Skill name="Construction" level="50,60"/>
<Skill name="Electrical Engineering" level="30,40"/>
<Skill name="Electrical Engineering" level="30,35"/>
</Skills>
<Item name="ID Card"/>
<Item name="Wrench"/>

View File

@@ -109,9 +109,9 @@ namespace Barotrauma
if (Character.AnimController is HumanoidAnimController)
{
if (Math.Abs(Character.AnimController.TargetMovement.X) > 0.1f && !Character.AnimController.InWater)
if (Math.Abs(Character.AnimController.movement.X) > 0.1f && !Character.AnimController.InWater)
{
Character.AnimController.TargetDir = Character.AnimController.TargetMovement.X > 0.0f ? Direction.Right : Direction.Left;
Character.AnimController.TargetDir = Character.AnimController.movement.X > 0.0f ? Direction.Right : Direction.Left;
}
}

View File

@@ -52,7 +52,7 @@ namespace Barotrauma
return;
}
if (container.Item.Inventory == character.Inventory)
if (container.Item.ParentInventory == character.Inventory)
{
var containedItems = container.Inventory.Items;
//if there's already something in the mask (empty oxygen tank?), drop it

View File

@@ -106,7 +106,7 @@ namespace Barotrauma
if (!Item.ItemList[currSearchIndex].HasTag(itemName) && Item.ItemList[currSearchIndex].Name != itemName) continue;
if (IgnoreContainedItems && Item.ItemList[currSearchIndex].Container != null) continue;
if (Item.ItemList[currSearchIndex].Inventory is CharacterInventory) continue;
if (Item.ItemList[currSearchIndex].ParentInventory is CharacterInventory) continue;
targetItem = Item.ItemList[currSearchIndex];

View File

@@ -49,7 +49,7 @@ namespace Barotrauma
case 1:
//item.body.LinearVelocity = Vector2.Zero;
if (item.Inventory!=null) item.body.FarseerBody.IsKinematic = false;
if (item.ParentInventory!=null) item.body.FarseerBody.IsKinematic = false;
if (item.CurrentHull == null) return;
state = 2;

View File

@@ -52,7 +52,7 @@ namespace Barotrauma
{
case 0:
//item.body.LinearVelocity = Vector2.Zero;
if (item.Inventory!=null) item.body.FarseerBody.IsKinematic = false;
if (item.ParentInventory!=null) item.body.FarseerBody.IsKinematic = false;
if (item.CurrentHull == null) return;
ShowMessage(state);

View File

@@ -183,18 +183,21 @@ namespace Barotrauma
if (flashTimer > 0.0f) flashTimer -= deltaTime;
if (!Enabled) return;
if (CaretEnabled)
{
caretTimer += deltaTime;
caretVisible = ((caretTimer*1000.0f) % 1000) < 500;
caretVisible = ((caretTimer * 1000.0f) % 1000) < 500;
}
if (rect.Contains(PlayerInput.MousePosition))
{
state = ComponentState.Hover;
if (PlayerInput.LeftButtonClicked())
{
if (MouseOn != null && MouseOn != this && MouseOn!=textBlock && !MouseOn.IsParentOf(this)) return;
Select();
if (OnSelected != null) OnSelected(this, Keys.None);
}

View File

@@ -61,6 +61,8 @@ namespace Barotrauma
{
if (!Visible || !Enabled) return;
if (MouseOn != null && MouseOn != this && !MouseOn.IsParentOf(this)) return;
if (text.Rect.Contains(PlayerInput.MousePosition)) MouseOn = this;
if (box.Rect.Contains(PlayerInput.MousePosition))

View File

@@ -168,8 +168,8 @@ namespace Barotrauma
System.Diagnostics.Debug.Assert(false);
return false;
}
Inventory otherInventory = Items[index].Inventory;
if (otherInventory != null && createNetworkEvent)
Inventory otherInventory = Items[index].ParentInventory;
if (otherInventory != null && otherInventory.Owner!=null && createNetworkEvent)
{
new Networking.NetworkEvent(Networking.NetworkEventType.InventoryUpdate, otherInventory.Owner.ID, true, true);
}
@@ -219,7 +219,7 @@ namespace Barotrauma
string toolTip = "";
Rectangle highlightedSlot = Rectangle.Empty;
if (doubleClickedItem!=null && doubleClickedItem.Inventory!=this)
if (doubleClickedItem!=null && doubleClickedItem.ParentInventory!=this)
{
TryPutItem(doubleClickedItem, doubleClickedItem.AllowedSlots, true);
}

View File

@@ -30,7 +30,7 @@ namespace Barotrauma.Items.Components
[HasDefaultValue(false, true)]
public bool Attached
{
get { return attached && item.Inventory == null; }
get { return attached && item.ParentInventory == null; }
set { attached = value; }
}
@@ -278,7 +278,7 @@ namespace Barotrauma.Items.Components
}
else
{
if (item.Inventory != null)
if (item.ParentInventory != null)
{
if (body != null)
{

View File

@@ -125,11 +125,11 @@ namespace Barotrauma
if (removeItem)
{
item.Drop(null, false);
if (item.Inventory != null) item.Inventory.RemoveItem(item);
if (item.ParentInventory != null) item.ParentInventory.RemoveItem(item);
}
Items[i] = item;
item.Inventory = this;
item.ParentInventory = this;
if (item.body != null)
{
item.body.Enabled = false;
@@ -154,7 +154,7 @@ namespace Barotrauma
{
if (Items[n] != item) continue;
Items[n] = null;
item.Inventory = null;
item.ParentInventory = null;
}
}

View File

@@ -63,20 +63,20 @@ namespace Barotrauma
private bool inWater;
private Inventory inventory;
private Inventory parentInventory;
//the inventory in which the item is contained in
public Inventory Inventory
public Inventory ParentInventory
{
get
{
return inventory;
return parentInventory;
}
set
{
inventory = value;
parentInventory = value;
if (inventory != null) Container = inventory.Owner as Item;
if (parentInventory != null) Container = parentInventory.Owner as Item;
}
}

View File

@@ -250,7 +250,7 @@ namespace Barotrauma
foreach (Item item in Item.ItemList)
{
if (item.CurrentHull != hull || item.FireProof || item.Condition <= 0.0f) continue;
if (item.Inventory != null) return;
if (item.ParentInventory != null) return;
float range = (float)Math.Sqrt(size.X) * 10.0f;
if (item.Position.X < position.X - range || item.Position.X > position.X + size.X + range) continue;

View File

@@ -262,7 +262,7 @@ namespace Barotrauma.Networking
(myCharacter == null || myCharacter.IsDead);
//restart if all characters are dead or submarine is at the end of the level
if ((AutoRestart && isCrewDead)
if ((autoRestart && isCrewDead)
||
(endRoundAtLevelEnd && Submarine.Loaded!=null && Submarine.Loaded.AtEndPosition))
{
@@ -716,7 +716,7 @@ namespace Barotrauma.Networking
yield return new WaitForSeconds(3.0f);
//save all the current events to a list and clear them
var existingEvents = NetworkEvent.Events;
var existingEvents = new List<NetworkEvent>(NetworkEvent.Events);
NetworkEvent.Events.Clear();
foreach (Hull hull in Hull.hullList)
@@ -740,7 +740,7 @@ namespace Barotrauma.Networking
item.NewComponentEvent(item.components[i], false, true);
}
if (item.body == null || item.body.Enabled == false) continue;
if (item.body == null || !item.body.Enabled || item.ParentInventory!=null) continue;
new NetworkEvent(NetworkEventType.DropItem, item.ID, false);
}
@@ -758,7 +758,7 @@ namespace Barotrauma.Networking
yield return new WaitForSeconds(0.1f);
//save "normal" events again
existingEvents = NetworkEvent.Events;
existingEvents = new List<NetworkEvent>(NetworkEvent.Events);
}
yield return CoroutineStatus.Success;

View File

@@ -134,10 +134,10 @@ namespace Barotrauma
//new GUITextBlock(new Rectangle(0, -25, 0, 30), "Host Server", GUI.style, Alignment.CenterX, Alignment.CenterX, menuTabs[(int)Tabs.HostServer], false, GUI.LargeFont);
new GUITextBlock(new Rectangle(0, 0, 0, 30), "Server Name:", GUI.Style, Alignment.TopLeft, Alignment.Left, menuTabs[(int)Tab.HostServer]);
new GUITextBlock(new Rectangle(0, 0, 100, 30), "Server Name:", GUI.Style, Alignment.TopLeft, Alignment.Left, menuTabs[(int)Tab.HostServer]);
serverNameBox = new GUITextBox(new Rectangle(160, 0, 200, 30), null, null, Alignment.TopLeft, Alignment.Left, GUI.Style, menuTabs[(int)Tab.HostServer]);
new GUITextBlock(new Rectangle(0, 50, 0, 30), "Server port:", GUI.Style, Alignment.TopLeft, Alignment.Left, menuTabs[(int)Tab.HostServer]);
new GUITextBlock(new Rectangle(0, 50, 100, 30), "Server port:", GUI.Style, Alignment.TopLeft, Alignment.Left, menuTabs[(int)Tab.HostServer]);
portBox = new GUITextBox(new Rectangle(160, 50, 200, 30), null, null, Alignment.TopLeft, Alignment.Left, GUI.Style, menuTabs[(int)Tab.HostServer]);
portBox.Text = NetConfig.DefaultPort.ToString();
portBox.ToolTip = "Server port";
@@ -155,7 +155,7 @@ namespace Barotrauma
plusPlayersBox.UserData = 1;
plusPlayersBox.OnClicked = ChangeMaxPlayers;
new GUITextBlock(new Rectangle(0, 150, 0, 30), "Password (optional):", GUI.Style, Alignment.TopLeft, Alignment.Left, menuTabs[(int)Tab.HostServer]);
new GUITextBlock(new Rectangle(0, 150, 100, 30), "Password (optional):", GUI.Style, Alignment.TopLeft, Alignment.Left, menuTabs[(int)Tab.HostServer]);
passwordBox = new GUITextBox(new Rectangle(160, 150, 200, 30), null, null, Alignment.TopLeft, Alignment.Left, GUI.Style, menuTabs[(int)Tab.HostServer]);
isPublicBox = new GUITickBox(new Rectangle(10, 200, 20, 20), "Public server", Alignment.TopLeft, menuTabs[(int)Tab.HostServer]);

View File

@@ -668,11 +668,20 @@ namespace Barotrauma
//GameMain.GameScreen.Cam.TargetPos = pos;
//GameMain.GameScreen.Cam.MoveCamera((float)deltaTime);
if (jobInfoFrame != null)
{
jobInfoFrame.Update((float)deltaTime);
}
else if (playerFrame != null)
{
playerFrame.Update((float)deltaTime);
}
else
{
menu.Update((float)deltaTime);
if (jobInfoFrame != null) jobInfoFrame.Update((float)deltaTime);
if (playerFrame != null) playerFrame.Update((float)deltaTime);
}
if (autoRestartTimer != 0.0f && autoRestartBox.Selected)
{

View File

@@ -20,7 +20,11 @@ namespace Barotrauma
public virtual void Select()
{
if (selected != null && selected!=this) selected.Deselect();
if (selected != null && selected != this)
{
selected.Deselect();
GUIComponent.KeyboardDispatcher.Subscriber = null;
}
selected = this;
}

View File

@@ -197,9 +197,9 @@ namespace Barotrauma
public void Draw(SpriteBatch spriteBatch, Vector2 pos, Color color, Vector2 origin, float rotate, Vector2 scale, SpriteEffects spriteEffect = SpriteEffects.None, float? depth = null)
{
//for (int x = -1; x < 3; x += 2)
//for (int x = -1; x <= 1; x += 2)
//{
// for (int y = -1; y < 3; y += 2)
// for (int y = -1; y <= 1; y += 2)
// {
// spriteBatch.Draw(texture, pos + offset + new Vector2(x, y) * 1.0f, sourceRect, Color.Black, rotation + rotate, origin, scale, spriteEffect, (depth == null ? this.depth : (float)depth) + 0.0001f);

Binary file not shown.