diff --git a/Subsurface/Source/GUI/GUIDropDown.cs b/Subsurface/Source/GUI/GUIDropDown.cs index 55b357a97..3e54d0cf1 100644 --- a/Subsurface/Source/GUI/GUIDropDown.cs +++ b/Subsurface/Source/GUI/GUIDropDown.cs @@ -103,14 +103,11 @@ namespace Barotrauma { GUITextBlock textBlock = new GUITextBlock(new Rectangle(0,0,0,20), text, GUI.Style, listBox); textBlock.UserData = userData; + } - //int totalHeight = 0; - //foreach (GUIComponent child in listBox.children) - //{ - // totalHeight += child.Rect.Height; - //} - - //listBox.Rect = new Rectangle(listBox.Rect.X,listBox.Rect.Y,listBox.Rect.Width,totalHeight); + public override void ClearChildren() + { + listBox.ClearChildren(); } public List GetChildren() diff --git a/Subsurface/Source/GameMain.cs b/Subsurface/Source/GameMain.cs index db7cca7db..47ca750eb 100644 --- a/Subsurface/Source/GameMain.cs +++ b/Subsurface/Source/GameMain.cs @@ -247,7 +247,7 @@ namespace Barotrauma GameModePreset.Init(); - Submarine.Preload(); + Submarine.RefreshSavedSubs(); TitleScreen.LoadState = 80.0f; yield return CoroutineStatus.Running; diff --git a/Subsurface/Source/Map/Submarine.cs b/Subsurface/Source/Map/Submarine.cs index 50c55db68..beeb06bd7 100644 --- a/Subsurface/Source/Map/Submarine.cs +++ b/Subsurface/Source/Map/Submarine.cs @@ -896,11 +896,8 @@ namespace Barotrauma } } - public static void Preload() + public static void RefreshSavedSubs() { - - //string[] mapFilePaths; - //Unload(); SavedSubmarines.Clear(); if (!Directory.Exists(SavePath)) diff --git a/Subsurface/Source/Screens/EditMapScreen.cs b/Subsurface/Source/Screens/EditMapScreen.cs index b3097a063..d27dba525 100644 --- a/Subsurface/Source/Screens/EditMapScreen.cs +++ b/Subsurface/Source/Screens/EditMapScreen.cs @@ -31,6 +31,8 @@ namespace Barotrauma const int PreviouslyUsedCount = 10; private GUIListBox previouslyUsedList; + GUIDropDown linkedSubBox; + //a Character used for picking up and manipulating items private Character dummyCharacter; @@ -151,7 +153,7 @@ namespace Barotrauma 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 = 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, "+ @@ -319,6 +321,12 @@ namespace Barotrauma Sounds.SoundManager.Pause(i); } + linkedSubBox.ClearChildren(); + foreach (Submarine sub in Submarine.SavedSubmarines) + { + linkedSubBox.AddItem(sub.Name, sub); + } + cam.UpdateTransform(); } @@ -398,6 +406,13 @@ namespace Barotrauma 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; return false; @@ -489,7 +504,7 @@ namespace Barotrauma private bool CreateLoadScreen(GUIButton button, object obj) { - Submarine.Preload(); + Submarine.RefreshSavedSubs(); 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);