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:
@@ -3,8 +3,10 @@ using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
@@ -19,7 +21,9 @@ namespace Barotrauma
|
||||
|
||||
private GUIFrame loadFrame;
|
||||
|
||||
private GUITextBox nameBox, descriptionBox;
|
||||
private GUIFrame saveFrame;
|
||||
|
||||
private GUITextBox nameBox;
|
||||
|
||||
const int PreviouslyUsedCount = 10;
|
||||
private GUIListBox previouslyUsedList;
|
||||
@@ -88,24 +92,23 @@ namespace Barotrauma
|
||||
var button = new GUIButton(new Rectangle(0, 0, 70, 20), "Open...", GUI.Style, topPanel);
|
||||
button.OnClicked = CreateLoadScreen;
|
||||
|
||||
nameBox = new GUITextBox(new Rectangle(150, 0, 150, 20), GUI.Style, topPanel);
|
||||
nameBox.OnEnterPressed = ChangeSubName;
|
||||
button = new GUIButton(new Rectangle(80,0,70,20), "Save", GUI.Style, topPanel);
|
||||
button.OnClicked = (GUIButton btn, object data) =>
|
||||
{
|
||||
CreateSaveScreen();
|
||||
|
||||
button = new GUIButton(new Rectangle(310,0,70,20), "Save", GUI.Style, topPanel);
|
||||
button.OnClicked = SaveSub;
|
||||
return true;
|
||||
};
|
||||
|
||||
new GUITextBlock(new Rectangle(390, 0, 100, 20), "Description: ", GUI.Style, topPanel);
|
||||
|
||||
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 nameLabel = new GUITextBlock(new Rectangle(170, -4, 150, 20), "", GUI.Style, topPanel, GUI.LargeFont);
|
||||
nameLabel.TextGetter = GetSubName;
|
||||
|
||||
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)
|
||||
{
|
||||
linkedSubBox.AddItem(sub.Name, sub);
|
||||
@@ -121,8 +124,7 @@ namespace Barotrauma
|
||||
GUITextBlock structureCount = new GUITextBlock(new Rectangle(0, 50, 0, 20), "", GUI.Style, leftPanel);
|
||||
structureCount.TextGetter = GetStructureCount;
|
||||
|
||||
GUItabs = new GUIComponent[Enum.GetValues(typeof(MapEntityCategory)).Length];
|
||||
|
||||
GUItabs = new GUIComponent[Enum.GetValues(typeof(MapEntityCategory)).Length];
|
||||
|
||||
int width = 400, height = 400;
|
||||
int y = 90;
|
||||
@@ -255,19 +257,19 @@ namespace Barotrauma
|
||||
if (Submarine.MainSub != null)
|
||||
{
|
||||
cam.Position = Submarine.MainSub.Position + Submarine.MainSub.HiddenSubPosition;
|
||||
nameBox.Text = Submarine.MainSub.Name;
|
||||
descriptionBox.Text = ToolBox.LimitString(Submarine.MainSub.Description, 15);
|
||||
//nameBox.Text = Submarine.MainSub.Name;
|
||||
//descriptionBox.Text = ToolBox.LimitString(Submarine.MainSub.Description, 15);
|
||||
}
|
||||
else
|
||||
{
|
||||
cam.Position = Submarine.HiddenSubStartPosition;
|
||||
nameBox.Text = "";
|
||||
descriptionBox.Text = "";
|
||||
//if (nameBox != null) nameBox.Text = "";
|
||||
//descriptionBox.Text = "";
|
||||
|
||||
Submarine.MainSub = new Submarine(Path.Combine(Submarine.SavePath, "Unnamed.sub"), "", false);
|
||||
}
|
||||
|
||||
nameBox.Deselect();
|
||||
//nameBox.Deselect();
|
||||
|
||||
cam.UpdateTransform();
|
||||
}
|
||||
@@ -345,6 +347,91 @@ namespace Barotrauma
|
||||
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)
|
||||
{
|
||||
Submarine.Preload();
|
||||
@@ -427,8 +514,8 @@ namespace Barotrauma
|
||||
Submarine.MainSub = selectedSub;
|
||||
selectedSub.Load(true);
|
||||
|
||||
nameBox.Text = selectedSub.Name;
|
||||
descriptionBox.Text = ToolBox.LimitString(selectedSub.Description,15);
|
||||
//nameBox.Text = selectedSub.Name;
|
||||
//descriptionBox.Text = ToolBox.LimitString(selectedSub.Description,15);
|
||||
|
||||
loadFrame = null;
|
||||
|
||||
@@ -737,10 +824,10 @@ namespace Barotrauma
|
||||
|
||||
if (GUIComponent.MouseOn == null)
|
||||
{
|
||||
if (nameBox.Selected && PlayerInput.LeftButtonClicked())
|
||||
{
|
||||
ChangeSubName(nameBox, nameBox.Text);
|
||||
}
|
||||
//if (nameBox.Selected && PlayerInput.LeftButtonClicked())
|
||||
//{
|
||||
// ChangeSubName(nameBox, nameBox.Text);
|
||||
//}
|
||||
|
||||
cam.MoveCamera((float)deltaTime);
|
||||
//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);
|
||||
if (PlayerInput.RightButtonClicked()) loadFrame = null;
|
||||
}
|
||||
else if (saveFrame != null)
|
||||
{
|
||||
saveFrame.Update((float)deltaTime);
|
||||
}
|
||||
else if (selectedTab > -1)
|
||||
{
|
||||
GUItabs[selectedTab].Update((float)deltaTime);
|
||||
@@ -879,6 +970,10 @@ namespace Barotrauma
|
||||
{
|
||||
loadFrame.Draw(spriteBatch);
|
||||
}
|
||||
else if (saveFrame != null)
|
||||
{
|
||||
saveFrame.Draw(spriteBatch);
|
||||
}
|
||||
else if (selectedTab > -1)
|
||||
{
|
||||
GUItabs[selectedTab].Draw(spriteBatch);
|
||||
|
||||
@@ -7,6 +7,7 @@ using FarseerPhysics;
|
||||
using FarseerPhysics.Factories;
|
||||
using FarseerPhysics.Dynamics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Barotrauma
|
||||
@@ -37,6 +38,8 @@ namespace Barotrauma
|
||||
|
||||
private GUITickBox autoRestartBox;
|
||||
|
||||
private GUIDropDown shuttleList;
|
||||
|
||||
public bool IsServer;
|
||||
public string ServerName;
|
||||
|
||||
@@ -53,6 +56,11 @@ namespace Barotrauma
|
||||
get { return subList; }
|
||||
}
|
||||
|
||||
public GUIDropDown ShuttleList
|
||||
{
|
||||
get { return shuttleList; }
|
||||
}
|
||||
|
||||
public GUIListBox ModeList
|
||||
{
|
||||
get { return modeList; }
|
||||
@@ -79,6 +87,11 @@ namespace Barotrauma
|
||||
get { return subList.SelectedData as Submarine; }
|
||||
}
|
||||
|
||||
public Submarine SelectedShuttle
|
||||
{
|
||||
get { return shuttleList.SelectedData as Submarine; }
|
||||
}
|
||||
|
||||
public GameModePreset SelectedMode
|
||||
{
|
||||
get { return modeList.SelectedData as GameModePreset; }
|
||||
@@ -206,10 +219,17 @@ namespace Barotrauma
|
||||
|
||||
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 ------------------------------------------------------------------
|
||||
|
||||
new GUITextBlock(new Rectangle(columnX, 120, 0, 30), "Game mode: ", GUI.Style, infoFrame);
|
||||
modeList = new GUIListBox(new Rectangle(columnX, 150, columnWidth, infoFrame.Rect.Height - 150 - 80), GUI.Style, infoFrame);
|
||||
new GUITextBlock(new Rectangle(columnX, 180, 0, 30), "Game mode: ", GUI.Style, infoFrame);
|
||||
modeList = new GUIListBox(new Rectangle(columnX, 200, columnWidth, infoFrame.Rect.Height - 300), GUI.Style, infoFrame);
|
||||
modeList.OnSelected = VotableClicked;
|
||||
|
||||
voteText = new GUITextBlock(new Rectangle(columnX, 120, columnWidth, 30), "Votes: ", GUI.Style, Alignment.TopLeft, Alignment.TopRight, infoFrame);
|
||||
@@ -229,8 +249,7 @@ namespace Barotrauma
|
||||
textBlock.Padding = new Vector4(10.0f, 0.0f, 0.0f, 0.0f);
|
||||
textBlock.UserData = mode;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//mission type ------------------------------------------------------------------
|
||||
|
||||
missionTypeBlock = new GUITextBlock(new Rectangle(columnX, 0, 300, 20), "Mission type:", GUI.Style, Alignment.BottomLeft, Alignment.TopLeft, infoFrame);
|
||||
@@ -318,8 +337,7 @@ namespace Barotrauma
|
||||
GameMain.LightManager.LosEnabled = false;
|
||||
|
||||
textBox.Select();
|
||||
|
||||
|
||||
|
||||
textBox.OnEnterPressed = GameMain.NetworkMember.EnterChatMessage;
|
||||
textBox.OnTextChanged = GameMain.NetworkMember.TypingChatMessage;
|
||||
|
||||
@@ -327,6 +345,7 @@ namespace Barotrauma
|
||||
//GameMain.GameScreen.Cam.TargetPos = Vector2.Zero;
|
||||
|
||||
subList.Enabled = GameMain.Server != null || GameMain.NetworkMember.Voting.AllowSubVoting;
|
||||
shuttleList.Enabled = subList.Enabled;
|
||||
playerList.Enabled = GameMain.Server != null;
|
||||
modeList.Enabled = GameMain.Server != null || GameMain.NetworkMember.Voting.AllowModeVoting;
|
||||
seedBox.Enabled = GameMain.Server != null;
|
||||
@@ -349,8 +368,11 @@ namespace Barotrauma
|
||||
|
||||
if (IsServer && GameMain.Server != null)
|
||||
{
|
||||
int prevSelected = subList.SelectedIndex;
|
||||
UpdateSubList(Submarine.SavedSubmarines);
|
||||
int prevSelectedSub = subList.SelectedIndex;
|
||||
UpdateSubList(subList, Submarine.SavedSubmarines);
|
||||
|
||||
int prevSelectedShuttle = shuttleList.SelectedIndex;
|
||||
UpdateSubList(shuttleList, Submarine.SavedSubmarines);
|
||||
|
||||
modeList.OnSelected = VotableClicked;
|
||||
modeList.OnSelected = SelectMode;
|
||||
@@ -369,12 +391,21 @@ namespace Barotrauma
|
||||
GUIButton settingsButton = new GUIButton(new Rectangle(-100, 0, 80, 30), "Settings", Alignment.BottomRight, GUI.Style, infoFrame);
|
||||
settingsButton.OnClicked = GameMain.Server.ToggleSettingsFrame;
|
||||
settingsButton.UserData = "settingsButton";
|
||||
|
||||
|
||||
if (subList.CountChildren > 0 && subList.Selected == null)
|
||||
|
||||
if (subList.Selected == null) subList.Select(Math.Max(0, prevSelectedSub));
|
||||
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 (myPlayerFrame.children.Find(c => c.UserData as string == "playyourself") == null)
|
||||
@@ -600,7 +631,7 @@ namespace Barotrauma
|
||||
return true;
|
||||
}
|
||||
|
||||
public void UpdateSubList(List<Submarine> submarines)
|
||||
public void UpdateSubList(GUIComponent subList, List<Submarine> submarines)
|
||||
{
|
||||
if (subList == null) return;
|
||||
|
||||
@@ -613,11 +644,11 @@ namespace Barotrauma
|
||||
|
||||
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(
|
||||
new Rectangle(0, 0, 0, 25), sub.Name, GUI.Style,
|
||||
@@ -639,8 +670,16 @@ namespace Barotrauma
|
||||
subTextBlock.TextColor = Color.LightGray;
|
||||
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)
|
||||
{
|
||||
if (GameMain.Client == null) return false;
|
||||
@@ -1011,7 +1050,7 @@ namespace Barotrauma
|
||||
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
|
||||
if (GameMain.Client.ActiveFileTransferName == subName+".sub") return false;
|
||||
@@ -1078,8 +1117,8 @@ namespace Barotrauma
|
||||
|
||||
if (selectedSub==null)
|
||||
{
|
||||
msg.Write(" ");
|
||||
msg.Write(" ");
|
||||
msg.Write("");
|
||||
msg.Write("");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1087,6 +1126,17 @@ namespace Barotrauma
|
||||
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(serverMessage.Text);
|
||||
|
||||
@@ -1110,7 +1160,8 @@ namespace Barotrauma
|
||||
|
||||
public void ReadData(NetIncomingMessage msg)
|
||||
{
|
||||
string subName = "", md5Hash = "";
|
||||
string subName = "", subHash = "";
|
||||
string shuttleName = "", shuttleHash = "";
|
||||
|
||||
int modeIndex = 0;
|
||||
//float durationScroll = 0.0f;
|
||||
@@ -1125,7 +1176,10 @@ namespace Barotrauma
|
||||
try
|
||||
{
|
||||
subName = msg.ReadString();
|
||||
md5Hash = msg.ReadString();
|
||||
subHash = msg.ReadString();
|
||||
|
||||
shuttleName = msg.ReadString();
|
||||
shuttleHash = msg.ReadString();
|
||||
|
||||
ServerName = msg.ReadString();
|
||||
serverMessage.Text = msg.ReadString();
|
||||
@@ -1156,7 +1210,9 @@ namespace Barotrauma
|
||||
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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user