List of linkable subs in the editor is refreshed after saving a new sub

This commit is contained in:
Regalis
2016-12-14 17:00:09 +02:00
parent a2f19a3b16
commit d7ed27381f
4 changed files with 23 additions and 14 deletions
+4 -7
View File
@@ -103,14 +103,11 @@ namespace Barotrauma
{ {
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);
textBlock.UserData = userData; textBlock.UserData = userData;
}
//int totalHeight = 0; public override void ClearChildren()
//foreach (GUIComponent child in listBox.children) {
//{ listBox.ClearChildren();
// totalHeight += child.Rect.Height;
//}
//listBox.Rect = new Rectangle(listBox.Rect.X,listBox.Rect.Y,listBox.Rect.Width,totalHeight);
} }
public List<GUIComponent> GetChildren() public List<GUIComponent> GetChildren()
+1 -1
View File
@@ -247,7 +247,7 @@ namespace Barotrauma
GameModePreset.Init(); GameModePreset.Init();
Submarine.Preload(); Submarine.RefreshSavedSubs();
TitleScreen.LoadState = 80.0f; TitleScreen.LoadState = 80.0f;
yield return CoroutineStatus.Running; yield return CoroutineStatus.Running;
+1 -4
View File
@@ -896,11 +896,8 @@ namespace Barotrauma
} }
} }
public static void Preload() public static void RefreshSavedSubs()
{ {
//string[] mapFilePaths;
//Unload();
SavedSubmarines.Clear(); SavedSubmarines.Clear();
if (!Directory.Exists(SavePath)) if (!Directory.Exists(SavePath))
+17 -2
View File
@@ -31,6 +31,8 @@ namespace Barotrauma
const int PreviouslyUsedCount = 10; const int PreviouslyUsedCount = 10;
private GUIListBox previouslyUsedList; private GUIListBox previouslyUsedList;
GUIDropDown linkedSubBox;
//a Character used for picking up and manipulating items //a Character used for picking up and manipulating items
private Character dummyCharacter; private Character dummyCharacter;
@@ -151,7 +153,7 @@ namespace Barotrauma
var nameLabel = new GUITextBlock(new Rectangle(170, -4, 150, 20), "", GUI.Style, topPanel, GUI.LargeFont); var nameLabel = new GUITextBlock(new Rectangle(170, -4, 150, 20), "", GUI.Style, topPanel, GUI.LargeFont);
nameLabel.TextGetter = GetSubName; nameLabel.TextGetter = GetSubName;
var linkedSubBox = new GUIDropDown(new Rectangle(750,0,200,20), "Add submarine", GUI.Style, topPanel); linkedSubBox = new GUIDropDown(new Rectangle(750,0,200,20), "Add submarine", GUI.Style, topPanel);
linkedSubBox.ToolTip = linkedSubBox.ToolTip =
"Places another submarine into the current submarine file. "+ "Places another submarine into the current submarine file. "+
"Can be used for adding things such as smaller vessels, "+ "Can be used for adding things such as smaller vessels, "+
@@ -319,6 +321,12 @@ namespace Barotrauma
Sounds.SoundManager.Pause(i); Sounds.SoundManager.Pause(i);
} }
linkedSubBox.ClearChildren();
foreach (Submarine sub in Submarine.SavedSubmarines)
{
linkedSubBox.AddItem(sub.Name, sub);
}
cam.UpdateTransform(); cam.UpdateTransform();
} }
@@ -398,6 +406,13 @@ namespace Barotrauma
GUI.AddMessage("Submarine saved to " + Submarine.MainSub.FilePath, Color.Green, 3.0f); GUI.AddMessage("Submarine saved to " + Submarine.MainSub.FilePath, Color.Green, 3.0f);
Submarine.RefreshSavedSubs();
linkedSubBox.ClearChildren();
foreach (Submarine sub in Submarine.SavedSubmarines)
{
linkedSubBox.AddItem(sub.Name, sub);
}
saveFrame = null; saveFrame = null;
return false; return false;
@@ -489,7 +504,7 @@ namespace Barotrauma
private bool CreateLoadScreen(GUIButton button, object obj) private bool CreateLoadScreen(GUIButton button, object obj)
{ {
Submarine.Preload(); Submarine.RefreshSavedSubs();
int width = 300, height = 400; int width = 300, height = 400;
loadFrame = new GUIFrame(new Rectangle(GameMain.GraphicsWidth / 2 - width / 2, GameMain.GraphicsHeight / 2 - height / 2, width, height), GUI.Style, null); loadFrame = new GUIFrame(new Rectangle(GameMain.GraphicsWidth / 2 - width / 2, GameMain.GraphicsHeight / 2 - height / 2, width, height), GUI.Style, null);