Fixed bug with GUIComponent children changing order in parent's list
This commit is contained in:
@@ -467,7 +467,6 @@ namespace Barotrauma
|
||||
|
||||
public static void Update(float deltaTime)
|
||||
{
|
||||
|
||||
if (pauseMenuOpen)
|
||||
{
|
||||
pauseMenu.Update(0.016f);
|
||||
|
||||
@@ -311,10 +311,13 @@ namespace Barotrauma
|
||||
|
||||
}
|
||||
|
||||
for (int i = 0; i < children.Count; i++)
|
||||
//use a fixed list since children can change their order in the main children list
|
||||
//TODO: maybe find a more efficient way of handling changes in list order
|
||||
List<GUIComponent> fixedChildren = new List<GUIComponent>(children);
|
||||
foreach (GUIComponent c in fixedChildren)
|
||||
{
|
||||
if (!children[i].Visible) continue;
|
||||
children[i].Update(deltaTime);
|
||||
if (!c.Visible) continue;
|
||||
c.Update(deltaTime);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -153,7 +153,7 @@ namespace Barotrauma
|
||||
private bool OnClicked(GUIComponent component, object obj)
|
||||
{
|
||||
if (wasOpened) return false;
|
||||
|
||||
|
||||
wasOpened = true;
|
||||
Dropped = !Dropped;
|
||||
|
||||
|
||||
@@ -284,8 +284,7 @@ namespace Barotrauma
|
||||
{
|
||||
Sound.Dispose();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Allows the game to run logic such as updating the world,
|
||||
/// checking for collisions, gathering input, and playing audio.
|
||||
@@ -324,7 +323,10 @@ namespace Barotrauma
|
||||
paused = (DebugConsole.IsOpen || GUI.PauseMenuOpen || GUI.SettingsMenuOpen) &&
|
||||
(NetworkMember == null || !NetworkMember.GameStarted);
|
||||
|
||||
if (!paused || Screen.Selected is MainMenuScreen) Screen.Selected.Update(deltaTime);
|
||||
if (!paused)
|
||||
{
|
||||
Screen.Selected.Update(deltaTime);
|
||||
}
|
||||
|
||||
if (NetworkMember != null)
|
||||
{
|
||||
@@ -336,7 +338,6 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
GUI.Update((float)deltaTime);
|
||||
|
||||
}
|
||||
|
||||
CoroutineManager.Update((float)deltaTime, paused ? 0.0f : (float)deltaTime);
|
||||
|
||||
@@ -11,9 +11,7 @@ namespace Barotrauma
|
||||
class MainMenuScreen : Screen
|
||||
{
|
||||
public enum Tab { NewGame = 1, LoadGame = 2, HostServer = 3, Settings = 4 }
|
||||
|
||||
private GUIButton[] menuButtons;
|
||||
|
||||
|
||||
GUIFrame buttonsTab;
|
||||
|
||||
private GUIFrame[] menuTabs;
|
||||
@@ -44,53 +42,43 @@ namespace Barotrauma
|
||||
Rectangle panelRect = new Rectangle(
|
||||
290, y,
|
||||
500, 360);
|
||||
|
||||
menuButtons = new GUIButton[8];
|
||||
|
||||
|
||||
GUIButton button = new GUIButton(new Rectangle(50, y, 200, 30), "Tutorial", null, Alignment.TopLeft, Alignment.Left, GUI.Style, buttonsTab);
|
||||
button.Color = button.Color * 0.8f;
|
||||
button.OnClicked = TutorialButtonClicked;
|
||||
menuButtons[0] = button;
|
||||
|
||||
button = new GUIButton(new Rectangle(50, y + 60, 200, 30), "New Game", null, Alignment.TopLeft, Alignment.Left, GUI.Style, buttonsTab);
|
||||
button.Color = button.Color * 0.8f;
|
||||
button.UserData = Tab.NewGame;
|
||||
button.OnClicked = SelectTab;
|
||||
menuButtons[1] = button;
|
||||
|
||||
button = new GUIButton(new Rectangle(50, y + 100, 200, 30), "Load Game", null, Alignment.TopLeft, Alignment.Left, GUI.Style, buttonsTab);
|
||||
button.Color = button.Color * 0.8f;
|
||||
button.UserData = Tab.LoadGame;
|
||||
button.OnClicked = SelectTab;
|
||||
menuButtons[2] = button;
|
||||
|
||||
button = new GUIButton(new Rectangle(50, y + 160, 200, 30), "Join Server", null, Alignment.TopLeft, Alignment.Left, GUI.Style, buttonsTab);
|
||||
button.Color = button.Color * 0.8f;
|
||||
//button.UserData = (int)Tabs.JoinServer;
|
||||
button.OnClicked = JoinServerClicked;
|
||||
menuButtons[3] = button;
|
||||
|
||||
button = new GUIButton(new Rectangle(50, y + 200, 200, 30), "Host Server", null, Alignment.TopLeft, Alignment.Left, GUI.Style, buttonsTab);
|
||||
button.Color = button.Color * 0.8f;
|
||||
button.UserData = Tab.HostServer;
|
||||
button.OnClicked = SelectTab;
|
||||
menuButtons[4] = button;
|
||||
|
||||
button = new GUIButton(new Rectangle(50, y + 260, 200, 30), "Submarine Editor", null, Alignment.TopLeft, Alignment.Left, GUI.Style, buttonsTab);
|
||||
button.Color = button.Color * 0.8f;
|
||||
button.OnClicked = (GUIButton btn, object userdata) => { GameMain.EditMapScreen.Select(); return true; };
|
||||
menuButtons[5] = button;
|
||||
|
||||
button = new GUIButton(new Rectangle(50, y + 320, 200, 30), "Settings", null, Alignment.TopLeft, Alignment.Left, GUI.Style, buttonsTab);
|
||||
button.Color = button.Color * 0.8f;
|
||||
button.UserData = Tab.Settings;
|
||||
button.OnClicked = SelectTab;
|
||||
menuButtons[6] = button;
|
||||
|
||||
button = new GUIButton(new Rectangle(0, 0, 150, 30), "Quit", Alignment.BottomRight, GUI.Style, buttonsTab);
|
||||
button.Color = button.Color * 0.8f;
|
||||
button.OnClicked = QuitClicked;
|
||||
menuButtons[7] = button;
|
||||
|
||||
panelRect.Y += 10;
|
||||
|
||||
@@ -491,14 +479,11 @@ namespace Barotrauma
|
||||
public override void Update(double deltaTime)
|
||||
{
|
||||
//GameMain.TitleScreen.Update();
|
||||
|
||||
foreach (GUIButton button in menuButtons)
|
||||
{
|
||||
button.Update((float)deltaTime);
|
||||
}
|
||||
|
||||
buttonsTab.Update((float)deltaTime);
|
||||
if (selectedTab>0) menuTabs[selectedTab].Update((float)deltaTime);
|
||||
if (selectedTab > 0)
|
||||
{
|
||||
menuTabs[selectedTab].Update((float)deltaTime);
|
||||
}
|
||||
|
||||
GameMain.TitleScreen.TitlePosition =
|
||||
Vector2.Lerp(GameMain.TitleScreen.TitlePosition, new Vector2(
|
||||
|
||||
@@ -340,7 +340,7 @@ namespace Barotrauma
|
||||
|
||||
menu.Update((float)deltaTime);
|
||||
|
||||
GUI.Update((float)deltaTime);
|
||||
//GUI.Update((float)deltaTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user