Option to choose which submarine to use as the respawn shuttle, submarines can be given "tags" (atm just shuttle and HideInMenu), separate saving window in sub editor
This commit is contained in:
@@ -103,6 +103,19 @@ namespace Barotrauma
|
|||||||
set { textBlock.Text = value; }
|
set { textBlock.Text = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override string ToolTip
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return base.ToolTip;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
textBlock.ToolTip = value;
|
||||||
|
base.ToolTip = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public bool Selected { get; set; }
|
public bool Selected { get; set; }
|
||||||
|
|
||||||
public GUIButton(Rectangle rect, string text, GUIStyle style, GUIComponent parent = null)
|
public GUIButton(Rectangle rect, string text, GUIStyle style, GUIComponent parent = null)
|
||||||
|
|||||||
@@ -27,6 +27,53 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool Enabled
|
||||||
|
{
|
||||||
|
get { return listBox.Enabled; }
|
||||||
|
set { listBox.Enabled = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public GUIComponent Selected
|
||||||
|
{
|
||||||
|
get { return listBox.Selected; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public GUIListBox ListBox
|
||||||
|
{
|
||||||
|
get { return listBox; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public object SelectedData
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return (listBox.Selected == null) ? null : listBox.Selected.UserData;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int SelectedIndex
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (listBox.Selected == null) return -1;
|
||||||
|
return listBox.children.FindIndex(x => x == listBox.Selected);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToolTip
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return base.ToolTip;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
base.ToolTip = value;
|
||||||
|
button.ToolTip = value;
|
||||||
|
listBox.ToolTip = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public GUIDropDown(Rectangle rect, string text, GUIStyle style, GUIComponent parent = null)
|
public GUIDropDown(Rectangle rect, string text, GUIStyle style, GUIComponent parent = null)
|
||||||
: base(style)
|
: base(style)
|
||||||
{
|
{
|
||||||
@@ -34,7 +81,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (parent != null) parent.AddChild(this);
|
if (parent != null) parent.AddChild(this);
|
||||||
|
|
||||||
button = new GUIButton(Rectangle.Empty, text, Color.White, Alignment.TopLeft, Alignment.TopLeft, null, this);
|
button = new GUIButton(this.rect, text, Color.White, Alignment.TopLeft, Alignment.TopLeft, null, null);
|
||||||
|
|
||||||
button.TextColor = Color.White;
|
button.TextColor = Color.White;
|
||||||
button.Color = Color.Black * 0.8f;
|
button.Color = Color.Black * 0.8f;
|
||||||
@@ -47,6 +94,11 @@ namespace Barotrauma
|
|||||||
//listBox.ScrollBarEnabled = false;
|
//listBox.ScrollBarEnabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void AddChild(GUIComponent child)
|
||||||
|
{
|
||||||
|
listBox.AddChild(child);
|
||||||
|
}
|
||||||
|
|
||||||
public void AddItem(string text, object userData = null)
|
public void AddItem(string text, object userData = null)
|
||||||
{
|
{
|
||||||
GUITextBlock textBlock = new GUITextBlock(new Rectangle(0,0,0,20), text, GUI.Style, listBox);
|
GUITextBlock textBlock = new GUITextBlock(new Rectangle(0,0,0,20), text, GUI.Style, listBox);
|
||||||
@@ -61,6 +113,11 @@ namespace Barotrauma
|
|||||||
//listBox.Rect = new Rectangle(listBox.Rect.X,listBox.Rect.Y,listBox.Rect.Width,totalHeight);
|
//listBox.Rect = new Rectangle(listBox.Rect.X,listBox.Rect.Y,listBox.Rect.Width,totalHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<GUIComponent> GetChildren()
|
||||||
|
{
|
||||||
|
return listBox.children;
|
||||||
|
}
|
||||||
|
|
||||||
private bool SelectItem(GUIComponent component, object obj)
|
private bool SelectItem(GUIComponent component, object obj)
|
||||||
{
|
{
|
||||||
GUITextBlock textBlock = component as GUITextBlock;
|
GUITextBlock textBlock = component as GUITextBlock;
|
||||||
@@ -85,6 +142,11 @@ namespace Barotrauma
|
|||||||
//SelectItem(child, userData);
|
//SelectItem(child, userData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Select(int index)
|
||||||
|
{
|
||||||
|
listBox.Select(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private bool wasOpened;
|
private bool wasOpened;
|
||||||
|
|
||||||
@@ -116,13 +178,12 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
Rectangle listBoxRect = listBox.Rect;
|
Rectangle listBoxRect = listBox.Rect;
|
||||||
listBoxRect.Width += 20;
|
listBoxRect.Width += 20;
|
||||||
if (!listBoxRect.Contains(PlayerInput.MousePosition))
|
if (!listBoxRect.Contains(PlayerInput.MousePosition) && !button.Rect.Contains(PlayerInput.MousePosition))
|
||||||
{
|
{
|
||||||
Dropped = false;
|
Dropped = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
button.Update(deltaTime);
|
button.Update(deltaTime);
|
||||||
|
|
||||||
if (Dropped) listBox.Update(deltaTime);
|
if (Dropped) listBox.Update(deltaTime);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using Microsoft.Xna.Framework;
|
|||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
@@ -18,8 +19,18 @@ namespace Barotrauma
|
|||||||
None = 0, Left = 1, Right = 2
|
None = 0, Left = 1, Right = 2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Flags]
|
||||||
|
public enum SubmarineTag
|
||||||
|
{
|
||||||
|
[Description("Shuttle")]
|
||||||
|
Shuttle = 1,
|
||||||
|
[Description("Hide in menus")]
|
||||||
|
HideInMenus = 2
|
||||||
|
}
|
||||||
|
|
||||||
class Submarine : Entity
|
class Submarine : Entity
|
||||||
{
|
{
|
||||||
|
|
||||||
public static string SavePath = "Submarines";
|
public static string SavePath = "Submarines";
|
||||||
|
|
||||||
public static readonly Vector2 HiddenSubStartPosition = new Vector2(-50000.0f, 80000.0f);
|
public static readonly Vector2 HiddenSubStartPosition = new Vector2(-50000.0f, 80000.0f);
|
||||||
@@ -56,6 +67,8 @@ namespace Barotrauma
|
|||||||
private string filePath;
|
private string filePath;
|
||||||
private string name;
|
private string name;
|
||||||
|
|
||||||
|
private SubmarineTag tags;
|
||||||
|
|
||||||
private Vector2 prevPosition;
|
private Vector2 prevPosition;
|
||||||
|
|
||||||
private float lastNetworkUpdate, networkUpdateTimer;
|
private float lastNetworkUpdate, networkUpdateTimer;
|
||||||
@@ -230,6 +243,7 @@ namespace Barotrauma
|
|||||||
if (doc != null && doc.Root != null)
|
if (doc != null && doc.Root != null)
|
||||||
{
|
{
|
||||||
Description = ToolBox.GetAttributeString(doc.Root, "description", "");
|
Description = ToolBox.GetAttributeString(doc.Root, "description", "");
|
||||||
|
Enum.TryParse(ToolBox.GetAttributeString(doc.Root, "tags", ""), out tags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,6 +254,24 @@ namespace Barotrauma
|
|||||||
base.Remove();
|
base.Remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool HasTag(SubmarineTag tag)
|
||||||
|
{
|
||||||
|
return tags.HasFlag(tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddTag(SubmarineTag tag)
|
||||||
|
{
|
||||||
|
if (tags.HasFlag(tag)) return;
|
||||||
|
|
||||||
|
tags |= tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveTag(SubmarineTag tag)
|
||||||
|
{
|
||||||
|
if (!tags.HasFlag(tag)) return;
|
||||||
|
|
||||||
|
tags &= ~tag;
|
||||||
|
}
|
||||||
|
|
||||||
//drawing ----------------------------------------------------
|
//drawing ----------------------------------------------------
|
||||||
|
|
||||||
@@ -579,6 +611,8 @@ namespace Barotrauma
|
|||||||
element.Add(new XAttribute("name", name));
|
element.Add(new XAttribute("name", name));
|
||||||
element.Add(new XAttribute("description", Description == null ? "" : Description));
|
element.Add(new XAttribute("description", Description == null ? "" : Description));
|
||||||
|
|
||||||
|
element.Add(new XAttribute("tags", tags.ToString()));
|
||||||
|
|
||||||
foreach (MapEntity e in MapEntity.mapEntityList)
|
foreach (MapEntity e in MapEntity.mapEntityList)
|
||||||
{
|
{
|
||||||
if (e.MoveWithLevel || e.Submarine != this) continue;
|
if (e.MoveWithLevel || e.Submarine != this) continue;
|
||||||
@@ -768,7 +802,7 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
|
|
||||||
Description = ToolBox.GetAttributeString(submarineElement, "description", "");
|
Description = ToolBox.GetAttributeString(submarineElement, "description", "");
|
||||||
|
Enum.TryParse(ToolBox.GetAttributeString(submarineElement, "tags", ""), out tags);
|
||||||
|
|
||||||
HiddenSubPosition = HiddenSubStartPosition;
|
HiddenSubPosition = HiddenSubStartPosition;
|
||||||
foreach (Submarine sub in Submarine.loaded)
|
foreach (Submarine sub in Submarine.loaded)
|
||||||
|
|||||||
@@ -286,7 +286,8 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
submarines.Add(new Submarine(mySubPath, subHash, false));
|
submarines.Add(new Submarine(mySubPath, subHash, false));
|
||||||
}
|
}
|
||||||
GameMain.NetLobbyScreen.UpdateSubList(submarines);
|
GameMain.NetLobbyScreen.UpdateSubList(GameMain.NetLobbyScreen.SubList, Submarine.SavedSubmarines);
|
||||||
|
GameMain.NetLobbyScreen.UpdateSubList(GameMain.NetLobbyScreen.ShuttleList.ListBox, Submarine.SavedSubmarines);
|
||||||
|
|
||||||
//add the name of own client to the lobby screen
|
//add the name of own client to the lobby screen
|
||||||
GameMain.NetLobbyScreen.AddPlayer(name);
|
GameMain.NetLobbyScreen.AddPlayer(name);
|
||||||
@@ -367,7 +368,9 @@ namespace Barotrauma.Networking
|
|||||||
List<Submarine> subList = GameMain.NetLobbyScreen.GetSubList();
|
List<Submarine> subList = GameMain.NetLobbyScreen.GetSubList();
|
||||||
|
|
||||||
GameMain.NetLobbyScreen = new NetLobbyScreen();
|
GameMain.NetLobbyScreen = new NetLobbyScreen();
|
||||||
GameMain.NetLobbyScreen.UpdateSubList(subList);
|
GameMain.NetLobbyScreen.UpdateSubList(GameMain.NetLobbyScreen.SubList, subList);
|
||||||
|
GameMain.NetLobbyScreen.UpdateSubList(GameMain.NetLobbyScreen.ShuttleList.ListBox, subList);
|
||||||
|
|
||||||
GameMain.NetLobbyScreen.Select();
|
GameMain.NetLobbyScreen.Select();
|
||||||
}
|
}
|
||||||
connected = true;
|
connected = true;
|
||||||
@@ -486,7 +489,11 @@ namespace Barotrauma.Networking
|
|||||||
string subName = inc.ReadString();
|
string subName = inc.ReadString();
|
||||||
string subHash = inc.ReadString();
|
string subHash = inc.ReadString();
|
||||||
|
|
||||||
if (GameMain.NetLobbyScreen.TrySelectSub(subName,subHash))
|
string shuttleName = inc.ReadString();
|
||||||
|
string shuttleHash = inc.ReadString();
|
||||||
|
|
||||||
|
if (GameMain.NetLobbyScreen.TrySelectSub(subName,subHash,GameMain.NetLobbyScreen.SubList) &&
|
||||||
|
GameMain.NetLobbyScreen.TrySelectSub(shuttleName, shuttleHash, GameMain.NetLobbyScreen.ShuttleList.ListBox))
|
||||||
{
|
{
|
||||||
NetOutgoingMessage readyToStartMsg = client.CreateMessage();
|
NetOutgoingMessage readyToStartMsg = client.CreateMessage();
|
||||||
readyToStartMsg.Write((byte)PacketTypes.StartGame);
|
readyToStartMsg.Write((byte)PacketTypes.StartGame);
|
||||||
@@ -636,8 +643,11 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
int missionTypeIndex = inc.ReadByte();
|
int missionTypeIndex = inc.ReadByte();
|
||||||
|
|
||||||
string mapName = inc.ReadString();
|
string subName = inc.ReadString();
|
||||||
string mapHash = inc.ReadString();
|
string subHash = inc.ReadString();
|
||||||
|
|
||||||
|
string shuttleName = inc.ReadString();
|
||||||
|
string shuttleHash = inc.ReadString();
|
||||||
|
|
||||||
string modeName = inc.ReadString();
|
string modeName = inc.ReadString();
|
||||||
|
|
||||||
@@ -651,11 +661,15 @@ namespace Barotrauma.Networking
|
|||||||
yield return CoroutineStatus.Success;
|
yield return CoroutineStatus.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!GameMain.NetLobbyScreen.TrySelectSub(mapName, mapHash))
|
if (!GameMain.NetLobbyScreen.TrySelectSub(subName, subHash, GameMain.NetLobbyScreen.SubList))
|
||||||
{
|
{
|
||||||
yield return CoroutineStatus.Success;
|
yield return CoroutineStatus.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!GameMain.NetLobbyScreen.TrySelectSub(shuttleName, shuttleHash, GameMain.NetLobbyScreen.ShuttleList.ListBox))
|
||||||
|
{
|
||||||
|
yield return CoroutineStatus.Success;
|
||||||
|
}
|
||||||
|
|
||||||
Rand.SetSyncedSeed(seed);
|
Rand.SetSyncedSeed(seed);
|
||||||
//int gameModeIndex = inc.ReadInt32();
|
//int gameModeIndex = inc.ReadInt32();
|
||||||
@@ -663,7 +677,7 @@ namespace Barotrauma.Networking
|
|||||||
GameMain.GameSession = new GameSession(GameMain.NetLobbyScreen.SelectedSub, "", gameMode, Mission.MissionTypes[missionTypeIndex]);
|
GameMain.GameSession = new GameSession(GameMain.NetLobbyScreen.SelectedSub, "", gameMode, Mission.MissionTypes[missionTypeIndex]);
|
||||||
GameMain.GameSession.StartShift(levelSeed);
|
GameMain.GameSession.StartShift(levelSeed);
|
||||||
|
|
||||||
if (respawnAllowed) respawnManager = new RespawnManager(this);
|
if (respawnAllowed) respawnManager = new RespawnManager(this, GameMain.NetLobbyScreen.SelectedShuttle);
|
||||||
|
|
||||||
|
|
||||||
//myCharacter = ReadCharacterData(inc);
|
//myCharacter = ReadCharacterData(inc);
|
||||||
|
|||||||
@@ -905,6 +905,7 @@ namespace Barotrauma.Networking
|
|||||||
public bool StartGameClicked(GUIButton button, object obj)
|
public bool StartGameClicked(GUIButton button, object obj)
|
||||||
{
|
{
|
||||||
Submarine selectedSub = null;
|
Submarine selectedSub = null;
|
||||||
|
Submarine selectedShuttle = GameMain.NetLobbyScreen.SelectedShuttle;
|
||||||
|
|
||||||
if (Voting.AllowSubVoting)
|
if (Voting.AllowSubVoting)
|
||||||
{
|
{
|
||||||
@@ -922,6 +923,12 @@ namespace Barotrauma.Networking
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (selectedShuttle == null)
|
||||||
|
{
|
||||||
|
GameMain.NetLobbyScreen.ShuttleList.Flash();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
GameModePreset selectedMode = Voting.HighestVoted<GameModePreset>(VoteType.Mode, connectedClients);
|
GameModePreset selectedMode = Voting.HighestVoted<GameModePreset>(VoteType.Mode, connectedClients);
|
||||||
if (selectedMode == null) selectedMode = GameMain.NetLobbyScreen.SelectedMode;
|
if (selectedMode == null) selectedMode = GameMain.NetLobbyScreen.SelectedMode;
|
||||||
|
|
||||||
@@ -931,12 +938,12 @@ namespace Barotrauma.Networking
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CoroutineManager.StartCoroutine(WaitForPlayersReady(selectedSub, selectedMode), "WaitForPlayersReady");
|
CoroutineManager.StartCoroutine(WaitForPlayersReady(selectedSub, selectedShuttle, selectedMode), "WaitForPlayersReady");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<object> WaitForPlayersReady(Submarine selectedSub, GameModePreset selectedMode)
|
private IEnumerable<object> WaitForPlayersReady(Submarine selectedSub, Submarine selectedShuttle, GameModePreset selectedMode)
|
||||||
{
|
{
|
||||||
GameMain.NetLobbyScreen.StartButton.Enabled = false;
|
GameMain.NetLobbyScreen.StartButton.Enabled = false;
|
||||||
|
|
||||||
@@ -945,6 +952,9 @@ namespace Barotrauma.Networking
|
|||||||
msg.Write(selectedSub.Name);
|
msg.Write(selectedSub.Name);
|
||||||
msg.Write(selectedSub.MD5Hash.Hash);
|
msg.Write(selectedSub.MD5Hash.Hash);
|
||||||
|
|
||||||
|
msg.Write(selectedShuttle.Name);
|
||||||
|
msg.Write(selectedShuttle.MD5Hash.Hash);
|
||||||
|
|
||||||
SendMessage(msg, NetDeliveryMethod.ReliableUnordered);
|
SendMessage(msg, NetDeliveryMethod.ReliableUnordered);
|
||||||
|
|
||||||
connectedClients.ForEach(c => c.ReadyToStart = false);
|
connectedClients.ForEach(c => c.ReadyToStart = false);
|
||||||
@@ -974,12 +984,12 @@ namespace Barotrauma.Networking
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GameMain.ShowLoading(StartGame(selectedSub, selectedMode), false);
|
GameMain.ShowLoading(StartGame(selectedSub, selectedShuttle, selectedMode), false);
|
||||||
|
|
||||||
yield return CoroutineStatus.Success;
|
yield return CoroutineStatus.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<object> StartGame(Submarine selectedSub, GameModePreset selectedMode)
|
private IEnumerable<object> StartGame(Submarine selectedSub, Submarine selectedShuttle, GameModePreset selectedMode)
|
||||||
{
|
{
|
||||||
Item.Spawner.Clear();
|
Item.Spawner.Clear();
|
||||||
Item.Remover.Clear();
|
Item.Remover.Clear();
|
||||||
@@ -1001,7 +1011,7 @@ namespace Barotrauma.Networking
|
|||||||
GameServer.Log("Game mode: " + selectedMode.Name, Color.Cyan);
|
GameServer.Log("Game mode: " + selectedMode.Name, Color.Cyan);
|
||||||
GameServer.Log("Level seed: " + GameMain.NetLobbyScreen.LevelSeed, Color.Cyan);
|
GameServer.Log("Level seed: " + GameMain.NetLobbyScreen.LevelSeed, Color.Cyan);
|
||||||
|
|
||||||
if (AllowRespawn) respawnManager = new RespawnManager(this);
|
if (AllowRespawn) respawnManager = new RespawnManager(this, selectedShuttle);
|
||||||
|
|
||||||
yield return CoroutineStatus.Running;
|
yield return CoroutineStatus.Running;
|
||||||
|
|
||||||
@@ -1105,6 +1115,9 @@ namespace Barotrauma.Networking
|
|||||||
msg.Write(selectedSub.Name);
|
msg.Write(selectedSub.Name);
|
||||||
msg.Write(selectedSub.MD5Hash.Hash);
|
msg.Write(selectedSub.MD5Hash.Hash);
|
||||||
|
|
||||||
|
msg.Write(GameMain.NetLobbyScreen.SelectedShuttle.Name);
|
||||||
|
msg.Write(GameMain.NetLobbyScreen.SelectedShuttle.MD5Hash.Hash);
|
||||||
|
|
||||||
msg.Write(selectedMode.Name);
|
msg.Write(selectedMode.Name);
|
||||||
|
|
||||||
msg.Write(AllowRespawn);
|
msg.Write(AllowRespawn);
|
||||||
|
|||||||
@@ -61,11 +61,11 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
private float updateReturnTimer;
|
private float updateReturnTimer;
|
||||||
|
|
||||||
public RespawnManager(NetworkMember networkMember)
|
public RespawnManager(NetworkMember networkMember, Submarine shuttle)
|
||||||
{
|
{
|
||||||
this.networkMember = networkMember;
|
this.networkMember = networkMember;
|
||||||
|
|
||||||
respawnShuttle = new Submarine("Submarines/Shuttle Mark I.sub");
|
respawnShuttle = shuttle;
|
||||||
respawnShuttle.Load(false);
|
respawnShuttle.Load(false);
|
||||||
|
|
||||||
ResetShuttle();
|
ResetShuttle();
|
||||||
@@ -398,7 +398,9 @@ namespace Barotrauma.Networking
|
|||||||
msg.Write((byte)characterInfos.Count);
|
msg.Write((byte)characterInfos.Count);
|
||||||
for (int i = 0; i < characterInfos.Count; i++)
|
for (int i = 0; i < characterInfos.Count; i++)
|
||||||
{
|
{
|
||||||
var character = Character.Create(characterInfos[i], waypoints[i].WorldPosition, true, false);
|
bool myCharacter = i >= clients.Count;
|
||||||
|
|
||||||
|
var character = Character.Create(characterInfos[i], waypoints[i].WorldPosition, !myCharacter, false);
|
||||||
|
|
||||||
if (divingSuitPrefab != null && oxyPrefab != null)
|
if (divingSuitPrefab != null && oxyPrefab != null)
|
||||||
{
|
{
|
||||||
@@ -416,17 +418,17 @@ namespace Barotrauma.Networking
|
|||||||
Item.Spawner.AddToSpawnedList(oxyTank);
|
Item.Spawner.AddToSpawnedList(oxyTank);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i < clients.Count)
|
if (myCharacter)
|
||||||
{
|
|
||||||
msg.Write((byte)clients[i].ID);
|
|
||||||
clients[i].Character = character;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
msg.Write((byte)0);
|
msg.Write((byte)0);
|
||||||
server.Character = character;
|
server.Character = character;
|
||||||
Character.Controlled = character;
|
Character.Controlled = character;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
msg.Write((byte)clients[i].ID);
|
||||||
|
clients[i].Character = character;
|
||||||
|
}
|
||||||
|
|
||||||
character.GiveJobItems(waypoints[i]);
|
character.GiveJobItems(waypoints[i]);
|
||||||
|
|
||||||
|
|||||||
@@ -3,8 +3,10 @@ using Microsoft.Xna.Framework.Graphics;
|
|||||||
using Microsoft.Xna.Framework.Input;
|
using Microsoft.Xna.Framework.Input;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
namespace Barotrauma
|
namespace Barotrauma
|
||||||
{
|
{
|
||||||
@@ -19,7 +21,9 @@ namespace Barotrauma
|
|||||||
|
|
||||||
private GUIFrame loadFrame;
|
private GUIFrame loadFrame;
|
||||||
|
|
||||||
private GUITextBox nameBox, descriptionBox;
|
private GUIFrame saveFrame;
|
||||||
|
|
||||||
|
private GUITextBox nameBox;
|
||||||
|
|
||||||
const int PreviouslyUsedCount = 10;
|
const int PreviouslyUsedCount = 10;
|
||||||
private GUIListBox previouslyUsedList;
|
private GUIListBox previouslyUsedList;
|
||||||
@@ -88,24 +92,23 @@ namespace Barotrauma
|
|||||||
var button = new GUIButton(new Rectangle(0, 0, 70, 20), "Open...", GUI.Style, topPanel);
|
var button = new GUIButton(new Rectangle(0, 0, 70, 20), "Open...", GUI.Style, topPanel);
|
||||||
button.OnClicked = CreateLoadScreen;
|
button.OnClicked = CreateLoadScreen;
|
||||||
|
|
||||||
nameBox = new GUITextBox(new Rectangle(150, 0, 150, 20), GUI.Style, topPanel);
|
button = new GUIButton(new Rectangle(80,0,70,20), "Save", GUI.Style, topPanel);
|
||||||
nameBox.OnEnterPressed = ChangeSubName;
|
button.OnClicked = (GUIButton btn, object data) =>
|
||||||
|
{
|
||||||
|
CreateSaveScreen();
|
||||||
|
|
||||||
button = new GUIButton(new Rectangle(310,0,70,20), "Save", GUI.Style, topPanel);
|
return true;
|
||||||
button.OnClicked = SaveSub;
|
};
|
||||||
|
|
||||||
new GUITextBlock(new Rectangle(390, 0, 100, 20), "Description: ", GUI.Style, topPanel);
|
var nameLabel = new GUITextBlock(new Rectangle(170, -4, 150, 20), "", GUI.Style, topPanel, GUI.LargeFont);
|
||||||
|
nameLabel.TextGetter = GetSubName;
|
||||||
descriptionBox = new GUITextBox(new Rectangle(490, 0, 200, 20), null, null, Alignment.TopLeft,
|
|
||||||
Alignment.TopLeft, GUI.Style, topPanel);
|
|
||||||
descriptionBox.Wrap = true;
|
|
||||||
descriptionBox.OnSelected += ExpandDescriptionBox;
|
|
||||||
descriptionBox.OnTextChanged = ChangeSubDescription;
|
|
||||||
|
|
||||||
|
|
||||||
//new GUITextBlock(new Rectangle(390, 0, 100, 20), "Link ", GUI.Style, topPanel);
|
|
||||||
|
|
||||||
var linkedSubBox = new GUIDropDown(new Rectangle(750,0,200,20), "Add submarine", GUI.Style, topPanel);
|
var linkedSubBox = new GUIDropDown(new Rectangle(750,0,200,20), "Add submarine", GUI.Style, topPanel);
|
||||||
|
linkedSubBox.ToolTip =
|
||||||
|
"Places another submarine into the current submarine file. "+
|
||||||
|
"Can be used for adding things such as smaller vessels, "+
|
||||||
|
"escape pods or detachable sections into the main submarine.";
|
||||||
|
|
||||||
foreach (Submarine sub in Submarine.SavedSubmarines)
|
foreach (Submarine sub in Submarine.SavedSubmarines)
|
||||||
{
|
{
|
||||||
linkedSubBox.AddItem(sub.Name, sub);
|
linkedSubBox.AddItem(sub.Name, sub);
|
||||||
@@ -123,7 +126,6 @@ namespace Barotrauma
|
|||||||
|
|
||||||
GUItabs = new GUIComponent[Enum.GetValues(typeof(MapEntityCategory)).Length];
|
GUItabs = new GUIComponent[Enum.GetValues(typeof(MapEntityCategory)).Length];
|
||||||
|
|
||||||
|
|
||||||
int width = 400, height = 400;
|
int width = 400, height = 400;
|
||||||
int y = 90;
|
int y = 90;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
@@ -255,19 +257,19 @@ namespace Barotrauma
|
|||||||
if (Submarine.MainSub != null)
|
if (Submarine.MainSub != null)
|
||||||
{
|
{
|
||||||
cam.Position = Submarine.MainSub.Position + Submarine.MainSub.HiddenSubPosition;
|
cam.Position = Submarine.MainSub.Position + Submarine.MainSub.HiddenSubPosition;
|
||||||
nameBox.Text = Submarine.MainSub.Name;
|
//nameBox.Text = Submarine.MainSub.Name;
|
||||||
descriptionBox.Text = ToolBox.LimitString(Submarine.MainSub.Description, 15);
|
//descriptionBox.Text = ToolBox.LimitString(Submarine.MainSub.Description, 15);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cam.Position = Submarine.HiddenSubStartPosition;
|
cam.Position = Submarine.HiddenSubStartPosition;
|
||||||
nameBox.Text = "";
|
//if (nameBox != null) nameBox.Text = "";
|
||||||
descriptionBox.Text = "";
|
//descriptionBox.Text = "";
|
||||||
|
|
||||||
Submarine.MainSub = new Submarine(Path.Combine(Submarine.SavePath, "Unnamed.sub"), "", false);
|
Submarine.MainSub = new Submarine(Path.Combine(Submarine.SavePath, "Unnamed.sub"), "", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
nameBox.Deselect();
|
//nameBox.Deselect();
|
||||||
|
|
||||||
cam.UpdateTransform();
|
cam.UpdateTransform();
|
||||||
}
|
}
|
||||||
@@ -345,6 +347,91 @@ namespace Barotrauma
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void CreateSaveScreen()
|
||||||
|
{
|
||||||
|
int width = 400, height = 400;
|
||||||
|
|
||||||
|
int y = 0;
|
||||||
|
|
||||||
|
saveFrame = new GUIFrame(new Rectangle(GameMain.GraphicsWidth / 2 - width / 2, GameMain.GraphicsHeight / 2 - height / 2, width, height), GUI.Style, null);
|
||||||
|
saveFrame.Padding = new Vector4(10.0f, 10.0f, 10.0f, 10.0f);
|
||||||
|
|
||||||
|
new GUITextBlock(new Rectangle(0,0,200,30), "Save submarine", GUI.Style, saveFrame, GUI.LargeFont);
|
||||||
|
|
||||||
|
y += 30;
|
||||||
|
|
||||||
|
new GUITextBlock(new Rectangle(0,y,150,20), "Name:", GUI.Style, saveFrame);
|
||||||
|
y += 20;
|
||||||
|
|
||||||
|
nameBox = new GUITextBox(new Rectangle(5, y, 150, 20), GUI.Style, saveFrame);
|
||||||
|
nameBox.OnEnterPressed = ChangeSubName;
|
||||||
|
nameBox.Text = GetSubName();
|
||||||
|
|
||||||
|
y += 30;
|
||||||
|
|
||||||
|
new GUITextBlock(new Rectangle(0, y, 150, 20), "Description:", GUI.Style, saveFrame);
|
||||||
|
y += 20;
|
||||||
|
|
||||||
|
var descriptionBox = new GUITextBox(new Rectangle(5, y, 0, 100), null, null, Alignment.TopLeft,
|
||||||
|
Alignment.TopLeft, GUI.Style, saveFrame);
|
||||||
|
descriptionBox.Wrap = true;
|
||||||
|
descriptionBox.Text = Submarine.MainSub == null ? "" : Submarine.MainSub.Description;
|
||||||
|
descriptionBox.OnSelected += ExpandDescriptionBox;
|
||||||
|
descriptionBox.OnTextChanged = ChangeSubDescription;
|
||||||
|
|
||||||
|
y += descriptionBox.Rect.Height + 15;
|
||||||
|
new GUITextBlock(new Rectangle(0, y, 150, 20), "Settings:", GUI.Style, saveFrame);
|
||||||
|
|
||||||
|
y += 20;
|
||||||
|
|
||||||
|
int tagX = 10, tagY = 0;
|
||||||
|
foreach (SubmarineTag tag in Enum.GetValues(typeof(SubmarineTag)))
|
||||||
|
{
|
||||||
|
FieldInfo fi = typeof(SubmarineTag).GetField(tag.ToString());
|
||||||
|
DescriptionAttribute[] attributes = (DescriptionAttribute[])fi.GetCustomAttributes(typeof(DescriptionAttribute), false);
|
||||||
|
|
||||||
|
string tagStr = attributes.Length > 0 ? attributes[0].Description : "";
|
||||||
|
|
||||||
|
var tagTickBox = new GUITickBox(new Rectangle(tagX, y+ tagY, 20, 20), tagStr, Alignment.TopLeft, saveFrame);
|
||||||
|
tagTickBox.Selected = Submarine.MainSub == null ? false : Submarine.MainSub.HasTag(tag);
|
||||||
|
tagTickBox.UserData = tag;
|
||||||
|
|
||||||
|
tagTickBox.OnSelected = (GUITickBox tickBox) =>
|
||||||
|
{
|
||||||
|
if (Submarine.MainSub == null) return false;
|
||||||
|
|
||||||
|
if (tickBox.Selected)
|
||||||
|
{
|
||||||
|
Submarine.MainSub.AddTag((SubmarineTag)tickBox.UserData);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Submarine.MainSub.RemoveTag((SubmarineTag)tickBox.UserData);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
tagY += 25;
|
||||||
|
if (tagY > 100)
|
||||||
|
{
|
||||||
|
tagY = 0;
|
||||||
|
tagX += 200;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var saveButton = new GUIButton(new Rectangle(-90, 0, 80, 20), "Save", Alignment.Right | Alignment.Bottom, GUI.Style, saveFrame);
|
||||||
|
saveButton.OnClicked = SaveSub;
|
||||||
|
|
||||||
|
var cancelButton = new GUIButton(new Rectangle(0, 0, 80, 20), "Cancel", Alignment.Right | Alignment.Bottom, GUI.Style, saveFrame);
|
||||||
|
cancelButton.OnClicked = (GUIButton btn, object userdata) =>
|
||||||
|
{
|
||||||
|
saveFrame = null;
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private bool CreateLoadScreen(GUIButton button, object obj)
|
private bool CreateLoadScreen(GUIButton button, object obj)
|
||||||
{
|
{
|
||||||
Submarine.Preload();
|
Submarine.Preload();
|
||||||
@@ -427,8 +514,8 @@ namespace Barotrauma
|
|||||||
Submarine.MainSub = selectedSub;
|
Submarine.MainSub = selectedSub;
|
||||||
selectedSub.Load(true);
|
selectedSub.Load(true);
|
||||||
|
|
||||||
nameBox.Text = selectedSub.Name;
|
//nameBox.Text = selectedSub.Name;
|
||||||
descriptionBox.Text = ToolBox.LimitString(selectedSub.Description,15);
|
//descriptionBox.Text = ToolBox.LimitString(selectedSub.Description,15);
|
||||||
|
|
||||||
loadFrame = null;
|
loadFrame = null;
|
||||||
|
|
||||||
@@ -737,10 +824,10 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (GUIComponent.MouseOn == null)
|
if (GUIComponent.MouseOn == null)
|
||||||
{
|
{
|
||||||
if (nameBox.Selected && PlayerInput.LeftButtonClicked())
|
//if (nameBox.Selected && PlayerInput.LeftButtonClicked())
|
||||||
{
|
//{
|
||||||
ChangeSubName(nameBox, nameBox.Text);
|
// ChangeSubName(nameBox, nameBox.Text);
|
||||||
}
|
//}
|
||||||
|
|
||||||
cam.MoveCamera((float)deltaTime);
|
cam.MoveCamera((float)deltaTime);
|
||||||
//cam.Zoom = MathHelper.Clamp(cam.Zoom + (PlayerInput.ScrollWheelSpeed / 1000.0f)*cam.Zoom, 0.1f, 2.0f);
|
//cam.Zoom = MathHelper.Clamp(cam.Zoom + (PlayerInput.ScrollWheelSpeed / 1000.0f)*cam.Zoom, 0.1f, 2.0f);
|
||||||
@@ -797,6 +884,10 @@ namespace Barotrauma
|
|||||||
loadFrame.Update((float)deltaTime);
|
loadFrame.Update((float)deltaTime);
|
||||||
if (PlayerInput.RightButtonClicked()) loadFrame = null;
|
if (PlayerInput.RightButtonClicked()) loadFrame = null;
|
||||||
}
|
}
|
||||||
|
else if (saveFrame != null)
|
||||||
|
{
|
||||||
|
saveFrame.Update((float)deltaTime);
|
||||||
|
}
|
||||||
else if (selectedTab > -1)
|
else if (selectedTab > -1)
|
||||||
{
|
{
|
||||||
GUItabs[selectedTab].Update((float)deltaTime);
|
GUItabs[selectedTab].Update((float)deltaTime);
|
||||||
@@ -879,6 +970,10 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
loadFrame.Draw(spriteBatch);
|
loadFrame.Draw(spriteBatch);
|
||||||
}
|
}
|
||||||
|
else if (saveFrame != null)
|
||||||
|
{
|
||||||
|
saveFrame.Draw(spriteBatch);
|
||||||
|
}
|
||||||
else if (selectedTab > -1)
|
else if (selectedTab > -1)
|
||||||
{
|
{
|
||||||
GUItabs[selectedTab].Draw(spriteBatch);
|
GUItabs[selectedTab].Draw(spriteBatch);
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ using FarseerPhysics;
|
|||||||
using FarseerPhysics.Factories;
|
using FarseerPhysics.Factories;
|
||||||
using FarseerPhysics.Dynamics;
|
using FarseerPhysics.Dynamics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Barotrauma
|
namespace Barotrauma
|
||||||
@@ -37,6 +38,8 @@ namespace Barotrauma
|
|||||||
|
|
||||||
private GUITickBox autoRestartBox;
|
private GUITickBox autoRestartBox;
|
||||||
|
|
||||||
|
private GUIDropDown shuttleList;
|
||||||
|
|
||||||
public bool IsServer;
|
public bool IsServer;
|
||||||
public string ServerName;
|
public string ServerName;
|
||||||
|
|
||||||
@@ -53,6 +56,11 @@ namespace Barotrauma
|
|||||||
get { return subList; }
|
get { return subList; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public GUIDropDown ShuttleList
|
||||||
|
{
|
||||||
|
get { return shuttleList; }
|
||||||
|
}
|
||||||
|
|
||||||
public GUIListBox ModeList
|
public GUIListBox ModeList
|
||||||
{
|
{
|
||||||
get { return modeList; }
|
get { return modeList; }
|
||||||
@@ -79,6 +87,11 @@ namespace Barotrauma
|
|||||||
get { return subList.SelectedData as Submarine; }
|
get { return subList.SelectedData as Submarine; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Submarine SelectedShuttle
|
||||||
|
{
|
||||||
|
get { return shuttleList.SelectedData as Submarine; }
|
||||||
|
}
|
||||||
|
|
||||||
public GameModePreset SelectedMode
|
public GameModePreset SelectedMode
|
||||||
{
|
{
|
||||||
get { return modeList.SelectedData as GameModePreset; }
|
get { return modeList.SelectedData as GameModePreset; }
|
||||||
@@ -206,10 +219,17 @@ namespace Barotrauma
|
|||||||
|
|
||||||
columnX += columnWidth + 20;
|
columnX += columnWidth + 20;
|
||||||
|
|
||||||
|
|
||||||
|
//respawn shuttle ------------------------------------------------------------------
|
||||||
|
|
||||||
|
new GUITextBlock(new Rectangle(columnX, 120, 20, 20), "Respawn shuttle:", GUI.Style, infoFrame);
|
||||||
|
shuttleList = new GUIDropDown(new Rectangle(columnX, 150, 200, 20), "", GUI.Style, infoFrame);
|
||||||
|
|
||||||
|
|
||||||
//gamemode ------------------------------------------------------------------
|
//gamemode ------------------------------------------------------------------
|
||||||
|
|
||||||
new GUITextBlock(new Rectangle(columnX, 120, 0, 30), "Game mode: ", GUI.Style, infoFrame);
|
new GUITextBlock(new Rectangle(columnX, 180, 0, 30), "Game mode: ", GUI.Style, infoFrame);
|
||||||
modeList = new GUIListBox(new Rectangle(columnX, 150, columnWidth, infoFrame.Rect.Height - 150 - 80), GUI.Style, infoFrame);
|
modeList = new GUIListBox(new Rectangle(columnX, 200, columnWidth, infoFrame.Rect.Height - 300), GUI.Style, infoFrame);
|
||||||
modeList.OnSelected = VotableClicked;
|
modeList.OnSelected = VotableClicked;
|
||||||
|
|
||||||
voteText = new GUITextBlock(new Rectangle(columnX, 120, columnWidth, 30), "Votes: ", GUI.Style, Alignment.TopLeft, Alignment.TopRight, infoFrame);
|
voteText = new GUITextBlock(new Rectangle(columnX, 120, columnWidth, 30), "Votes: ", GUI.Style, Alignment.TopLeft, Alignment.TopRight, infoFrame);
|
||||||
@@ -230,7 +250,6 @@ namespace Barotrauma
|
|||||||
textBlock.UserData = mode;
|
textBlock.UserData = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//mission type ------------------------------------------------------------------
|
//mission type ------------------------------------------------------------------
|
||||||
|
|
||||||
missionTypeBlock = new GUITextBlock(new Rectangle(columnX, 0, 300, 20), "Mission type:", GUI.Style, Alignment.BottomLeft, Alignment.TopLeft, infoFrame);
|
missionTypeBlock = new GUITextBlock(new Rectangle(columnX, 0, 300, 20), "Mission type:", GUI.Style, Alignment.BottomLeft, Alignment.TopLeft, infoFrame);
|
||||||
@@ -319,7 +338,6 @@ namespace Barotrauma
|
|||||||
|
|
||||||
textBox.Select();
|
textBox.Select();
|
||||||
|
|
||||||
|
|
||||||
textBox.OnEnterPressed = GameMain.NetworkMember.EnterChatMessage;
|
textBox.OnEnterPressed = GameMain.NetworkMember.EnterChatMessage;
|
||||||
textBox.OnTextChanged = GameMain.NetworkMember.TypingChatMessage;
|
textBox.OnTextChanged = GameMain.NetworkMember.TypingChatMessage;
|
||||||
|
|
||||||
@@ -327,6 +345,7 @@ namespace Barotrauma
|
|||||||
//GameMain.GameScreen.Cam.TargetPos = Vector2.Zero;
|
//GameMain.GameScreen.Cam.TargetPos = Vector2.Zero;
|
||||||
|
|
||||||
subList.Enabled = GameMain.Server != null || GameMain.NetworkMember.Voting.AllowSubVoting;
|
subList.Enabled = GameMain.Server != null || GameMain.NetworkMember.Voting.AllowSubVoting;
|
||||||
|
shuttleList.Enabled = subList.Enabled;
|
||||||
playerList.Enabled = GameMain.Server != null;
|
playerList.Enabled = GameMain.Server != null;
|
||||||
modeList.Enabled = GameMain.Server != null || GameMain.NetworkMember.Voting.AllowModeVoting;
|
modeList.Enabled = GameMain.Server != null || GameMain.NetworkMember.Voting.AllowModeVoting;
|
||||||
seedBox.Enabled = GameMain.Server != null;
|
seedBox.Enabled = GameMain.Server != null;
|
||||||
@@ -349,8 +368,11 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (IsServer && GameMain.Server != null)
|
if (IsServer && GameMain.Server != null)
|
||||||
{
|
{
|
||||||
int prevSelected = subList.SelectedIndex;
|
int prevSelectedSub = subList.SelectedIndex;
|
||||||
UpdateSubList(Submarine.SavedSubmarines);
|
UpdateSubList(subList, Submarine.SavedSubmarines);
|
||||||
|
|
||||||
|
int prevSelectedShuttle = shuttleList.SelectedIndex;
|
||||||
|
UpdateSubList(shuttleList, Submarine.SavedSubmarines);
|
||||||
|
|
||||||
modeList.OnSelected = VotableClicked;
|
modeList.OnSelected = VotableClicked;
|
||||||
modeList.OnSelected = SelectMode;
|
modeList.OnSelected = SelectMode;
|
||||||
@@ -370,11 +392,20 @@ namespace Barotrauma
|
|||||||
settingsButton.OnClicked = GameMain.Server.ToggleSettingsFrame;
|
settingsButton.OnClicked = GameMain.Server.ToggleSettingsFrame;
|
||||||
settingsButton.UserData = "settingsButton";
|
settingsButton.UserData = "settingsButton";
|
||||||
|
|
||||||
|
if (subList.Selected == null) subList.Select(Math.Max(0, prevSelectedSub));
|
||||||
if (subList.CountChildren > 0 && subList.Selected == null)
|
if (shuttleList.Selected == null)
|
||||||
{
|
{
|
||||||
subList.Select(Math.Max(0, prevSelected));
|
var shuttles = shuttleList.GetChildren().FindAll(c => c.UserData is Submarine && ((Submarine)c.UserData).HasTag(SubmarineTag.Shuttle));
|
||||||
|
if (prevSelectedShuttle==-1 && shuttles.Any())
|
||||||
|
{
|
||||||
|
shuttleList.SelectItem(shuttles[0].UserData);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
shuttleList.Select(Math.Max(0, prevSelectedShuttle));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GameModePreset.list.Count > 0 && modeList.Selected == null) modeList.Select(0);
|
if (GameModePreset.list.Count > 0 && modeList.Selected == null) modeList.Select(0);
|
||||||
|
|
||||||
if (myPlayerFrame.children.Find(c => c.UserData as string == "playyourself") == null)
|
if (myPlayerFrame.children.Find(c => c.UserData as string == "playyourself") == null)
|
||||||
@@ -600,7 +631,7 @@ namespace Barotrauma
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateSubList(List<Submarine> submarines)
|
public void UpdateSubList(GUIComponent subList, List<Submarine> submarines)
|
||||||
{
|
{
|
||||||
if (subList == null) return;
|
if (subList == null) return;
|
||||||
|
|
||||||
@@ -613,11 +644,11 @@ namespace Barotrauma
|
|||||||
|
|
||||||
foreach (Submarine sub in submarines)
|
foreach (Submarine sub in submarines)
|
||||||
{
|
{
|
||||||
AddSubmarine(sub);
|
AddSubmarine(subList, sub);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddSubmarine(Submarine sub)
|
public void AddSubmarine(GUIComponent subList, Submarine sub)
|
||||||
{
|
{
|
||||||
var subTextBlock = new GUITextBlock(
|
var subTextBlock = new GUITextBlock(
|
||||||
new Rectangle(0, 0, 0, 25), sub.Name, GUI.Style,
|
new Rectangle(0, 0, 0, 25), sub.Name, GUI.Style,
|
||||||
@@ -639,8 +670,16 @@ namespace Barotrauma
|
|||||||
subTextBlock.TextColor = Color.LightGray;
|
subTextBlock.TextColor = Color.LightGray;
|
||||||
subTextBlock.ToolTip = "Your version of the submarine doesn't match the servers version";
|
subTextBlock.ToolTip = "Your version of the submarine doesn't match the servers version";
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (subList == shuttleList || subList == shuttleList.ListBox)
|
||||||
|
{
|
||||||
|
subTextBlock.TextColor = sub.HasTag(SubmarineTag.Shuttle) ? Color.White : Color.DarkGray;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public bool VotableClicked(GUIComponent component, object userData)
|
public bool VotableClicked(GUIComponent component, object userData)
|
||||||
{
|
{
|
||||||
if (GameMain.Client == null) return false;
|
if (GameMain.Client == null) return false;
|
||||||
@@ -1011,7 +1050,7 @@ namespace Barotrauma
|
|||||||
if (GameMain.Client!=null) GameMain.Client.SendCharacterData();
|
if (GameMain.Client!=null) GameMain.Client.SendCharacterData();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool TrySelectSub(string subName, string md5Hash)
|
public bool TrySelectSub(string subName, string md5Hash, GUIListBox subList)
|
||||||
{
|
{
|
||||||
//already downloading the selected sub file
|
//already downloading the selected sub file
|
||||||
if (GameMain.Client.ActiveFileTransferName == subName+".sub") return false;
|
if (GameMain.Client.ActiveFileTransferName == subName+".sub") return false;
|
||||||
@@ -1078,8 +1117,8 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (selectedSub==null)
|
if (selectedSub==null)
|
||||||
{
|
{
|
||||||
msg.Write(" ");
|
msg.Write("");
|
||||||
msg.Write(" ");
|
msg.Write("");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1087,6 +1126,17 @@ namespace Barotrauma
|
|||||||
msg.Write(selectedSub.MD5Hash.Hash);
|
msg.Write(selectedSub.MD5Hash.Hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (SelectedShuttle == null)
|
||||||
|
{
|
||||||
|
msg.Write("");
|
||||||
|
msg.Write("");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
msg.Write(Path.GetFileName(SelectedShuttle.Name));
|
||||||
|
msg.Write(selectedShuttle.MD5Hash.Hash);
|
||||||
|
}
|
||||||
|
|
||||||
msg.Write(ServerName);
|
msg.Write(ServerName);
|
||||||
msg.Write(serverMessage.Text);
|
msg.Write(serverMessage.Text);
|
||||||
|
|
||||||
@@ -1110,7 +1160,8 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public void ReadData(NetIncomingMessage msg)
|
public void ReadData(NetIncomingMessage msg)
|
||||||
{
|
{
|
||||||
string subName = "", md5Hash = "";
|
string subName = "", subHash = "";
|
||||||
|
string shuttleName = "", shuttleHash = "";
|
||||||
|
|
||||||
int modeIndex = 0;
|
int modeIndex = 0;
|
||||||
//float durationScroll = 0.0f;
|
//float durationScroll = 0.0f;
|
||||||
@@ -1125,7 +1176,10 @@ namespace Barotrauma
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
subName = msg.ReadString();
|
subName = msg.ReadString();
|
||||||
md5Hash = msg.ReadString();
|
subHash = msg.ReadString();
|
||||||
|
|
||||||
|
shuttleName = msg.ReadString();
|
||||||
|
shuttleHash = msg.ReadString();
|
||||||
|
|
||||||
ServerName = msg.ReadString();
|
ServerName = msg.ReadString();
|
||||||
serverMessage.Text = msg.ReadString();
|
serverMessage.Text = msg.ReadString();
|
||||||
@@ -1156,7 +1210,9 @@ namespace Barotrauma
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(subName) && !GameMain.NetworkMember.Voting.AllowSubVoting) TrySelectSub(subName, md5Hash);
|
if (!string.IsNullOrWhiteSpace(subName) && !GameMain.NetworkMember.Voting.AllowSubVoting) TrySelectSub(subName, subHash, subList);
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(shuttleName)) TrySelectSub(shuttleName, shuttleHash, shuttleList.ListBox);
|
||||||
|
|
||||||
if (!GameMain.NetworkMember.Voting.AllowModeVoting)
|
if (!GameMain.NetworkMember.Voting.AllowModeVoting)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user