Option to define multiple compatible content packages in submarine files, added extension methods for parsing string, float and int arrays from XML elements
This commit is contained in:
@@ -137,21 +137,21 @@ namespace Barotrauma
|
||||
TextManager.Get("DimensionsFormat").Replace("[width]", ((int)(realWorldDimensions.X)).ToString()).Replace("[height]", ((int)(realWorldDimensions.Y)).ToString());
|
||||
|
||||
new GUITextBlock(new Rectangle(246, 60, 100, 20),
|
||||
TextManager.Get("ContentPackage") + ": " + (ContentPackage ?? "Unknown"),
|
||||
"", frame, GUI.SmallFont);
|
||||
|
||||
new GUITextBlock(new Rectangle(246, 80, 100, 20),
|
||||
TextManager.Get("Dimensions") + ": " + dimensionsStr,
|
||||
"", frame, GUI.SmallFont);
|
||||
|
||||
new GUITextBlock(new Rectangle(246, 100, 100, 20),
|
||||
new GUITextBlock(new Rectangle(246, 80, 100, 20),
|
||||
TextManager.Get("RecommendedCrewSize") + ": " + (RecommendedCrewSizeMax == 0 ? TextManager.Get("Unknown") : RecommendedCrewSizeMin + " - " + RecommendedCrewSizeMax),
|
||||
"", frame, GUI.SmallFont);
|
||||
|
||||
new GUITextBlock(new Rectangle(246, 120, 100, 20),
|
||||
new GUITextBlock(new Rectangle(246, 100, 100, 20),
|
||||
TextManager.Get("RecommendedCrewExperience") + ": " + (string.IsNullOrEmpty(RecommendedCrewExperience) ? TextManager.Get("unknown") : RecommendedCrewExperience),
|
||||
"", frame, GUI.SmallFont);
|
||||
|
||||
new GUITextBlock(new Rectangle(246, 120, 100, 20),
|
||||
TextManager.Get("CompatibleContentPackages") + ": " + string.Join(", ", CompatibleContentPackages),
|
||||
"", Alignment.TopLeft, Alignment.TopLeft, frame, true, GUI.SmallFont);
|
||||
|
||||
var descr = new GUITextBlock(new Rectangle(0, 200, 0, 100), Description, "", Alignment.TopLeft, Alignment.TopLeft, frame, true, GUI.SmallFont);
|
||||
descr.CanBeFocused = false;
|
||||
}
|
||||
|
||||
@@ -59,13 +59,12 @@ namespace Barotrauma
|
||||
if (selectedSub == null) return false;
|
||||
|
||||
string savePath = SaveUtil.CreateSavePath(isMultiplayer ? SaveUtil.SaveType.Multiplayer : SaveUtil.SaveType.Singleplayer, saveNameBox.Text);
|
||||
if (selectedSub.HasTag(SubmarineTag.Shuttle) || GameMain.SelectedPackage.Name != selectedSub.ContentPackage)
|
||||
if (selectedSub.HasTag(SubmarineTag.Shuttle) || !selectedSub.CompatibleContentPackages.Contains(GameMain.SelectedPackage.Name))
|
||||
{
|
||||
if (GameMain.SelectedPackage.Name != selectedSub.ContentPackage)
|
||||
if (!selectedSub.CompatibleContentPackages.Contains(GameMain.SelectedPackage.Name))
|
||||
{
|
||||
var msgBox = new GUIMessageBox(TextManager.Get("ContentPackageMismatch"),
|
||||
TextManager.Get("ContentPackageMismatchWarning")
|
||||
.Replace("[subcontentpackage]", selectedSub.ContentPackage)
|
||||
.Replace("[selectedcontentpackage]", GameMain.SelectedPackage.Name),
|
||||
new string[] { TextManager.Get("Yes"), TextManager.Get("No") });
|
||||
|
||||
|
||||
@@ -422,7 +422,7 @@ namespace Barotrauma
|
||||
savePath = Path.Combine(Submarine.SavePath, savePath);
|
||||
}
|
||||
|
||||
Submarine.MainSub.ContentPackage = GameMain.Config.SelectedContentPackage.Name;
|
||||
Submarine.MainSub.CompatibleContentPackages.Add(GameMain.Config.SelectedContentPackage.Name);
|
||||
|
||||
MemoryStream imgStream = new MemoryStream();
|
||||
CreateImage(256, 128, imgStream);
|
||||
@@ -481,7 +481,7 @@ namespace Barotrauma
|
||||
y += descriptionBox.Rect.Height;
|
||||
new GUITextBlock(new Rectangle(0, y, 150, 20), TextManager.Get("SaveSubDialogSettings"), "", saveFrame);
|
||||
|
||||
y += 20;
|
||||
y += 30;
|
||||
|
||||
int tagX = 10, tagY = 0;
|
||||
foreach (SubmarineTag tag in Enum.GetValues(typeof(SubmarineTag)))
|
||||
@@ -519,7 +519,36 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
y += tagY;
|
||||
y -= 30;
|
||||
|
||||
new GUITextBlock(new Rectangle(160, y, 100, 20), TextManager.Get("CompatibleContentPackages"), "", saveFrame);
|
||||
var contentPackList = new GUIListBox(new Rectangle(160, y + 30, 0, 50), "", saveFrame);
|
||||
List<string> contentPacks = Submarine.MainSub.CompatibleContentPackages.ToList();
|
||||
foreach (ContentPackage contentPack in ContentPackage.list)
|
||||
{
|
||||
if (!contentPacks.Contains(contentPack.Name)) contentPacks.Add(contentPack.Name);
|
||||
}
|
||||
|
||||
foreach (string contentPackageName in contentPacks)
|
||||
{
|
||||
var cpTickBox = new GUITickBox(new Rectangle(0, 0, 15, 15), contentPackageName, Alignment.TopLeft, GUI.SmallFont, contentPackList);
|
||||
cpTickBox.Selected = Submarine.MainSub.CompatibleContentPackages.Contains(contentPackageName);
|
||||
cpTickBox.UserData = contentPackageName;
|
||||
cpTickBox.OnSelected += (GUITickBox tickBox) =>
|
||||
{
|
||||
if (tickBox.Selected)
|
||||
{
|
||||
Submarine.MainSub.CompatibleContentPackages.Add((string)tickBox.UserData);
|
||||
}
|
||||
else
|
||||
{
|
||||
Submarine.MainSub.CompatibleContentPackages.Remove((string)tickBox.UserData);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
y += 90;
|
||||
|
||||
new GUITextBlock(new Rectangle(0, y, 100, 20), TextManager.Get("RecommendedCrewSize"), "", Alignment.TopLeft, Alignment.CenterLeft, saveFrame);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user