(4246de267) Fixed saving a submarine with a new name causing the previous sub file to disappear from sub lists until saved subs are refreshed, fixed new subs appearing at the end of the list (instead of being sorted alphabetically)
This commit is contained in:
@@ -849,8 +849,10 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
string savePath = nameBox.Text + ".sub";
|
||||
string prevSavePath = null;
|
||||
if (Submarine.MainSub != null)
|
||||
{
|
||||
prevSavePath = Submarine.MainSub.FilePath;
|
||||
savePath = Path.Combine(Path.GetDirectoryName(Submarine.MainSub.FilePath), savePath);
|
||||
}
|
||||
else
|
||||
@@ -889,6 +891,10 @@ namespace Barotrauma
|
||||
GUI.AddMessage(TextManager.Get("SubSavedNotification").Replace("[filepath]", Submarine.MainSub.FilePath), Color.Green);
|
||||
|
||||
Submarine.RefreshSavedSub(savePath);
|
||||
if (prevSavePath != null && prevSavePath != savePath)
|
||||
{
|
||||
Submarine.RefreshSavedSub(prevSavePath);
|
||||
}
|
||||
|
||||
linkedSubBox.ClearChildren();
|
||||
foreach (Submarine sub in Submarine.SavedSubmarines)
|
||||
@@ -1280,9 +1286,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (CharacterMode) SetCharacterMode(false);
|
||||
if (WiringMode) SetWiringMode(false);
|
||||
|
||||
Submarine.RefreshSavedSubs();
|
||||
|
||||
|
||||
loadFrame = new GUIButton(new RectTransform(Vector2.One, GUI.Canvas), style: "GUIBackgroundBlocker")
|
||||
{
|
||||
OnClicked = (btn, userdata) => { if (GUI.MouseOn == btn || GUI.MouseOn == btn.TextBlock) loadFrame = null; return true; },
|
||||
@@ -1432,6 +1436,7 @@ namespace Barotrauma
|
||||
{
|
||||
sub.Remove();
|
||||
File.Delete(sub.FilePath);
|
||||
Submarine.RefreshSavedSubs();
|
||||
CreateLoadScreen();
|
||||
}
|
||||
catch (Exception e)
|
||||
|
||||
@@ -1117,6 +1117,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
savedSubmarines.Add(new Submarine(filePath));
|
||||
savedSubmarines = savedSubmarines.OrderBy(s => s.filePath ?? "").ToList();
|
||||
}
|
||||
|
||||
public static void RefreshSavedSubs()
|
||||
|
||||
Reference in New Issue
Block a user