GUI elements now respect render order + some minor distance comparison optimization

This commit is contained in:
juanjp600
2016-11-15 22:26:36 -03:00
parent 3c57b9d945
commit d2c17274fe
39 changed files with 441 additions and 47 deletions

View File

@@ -196,7 +196,7 @@ namespace Launcher2
var messageBox = GUIMessageBox.MessageBoxes.Peek();
if (messageBox != null)
{
GUIComponent.MouseOn = messageBox;
GUIComponent.ForceMouseOn(messageBox);
messageBox.Update(deltaTime);
return;
}

View File

@@ -1019,7 +1019,7 @@ namespace Barotrauma
if (lerp)
{
limb.body.TargetPosition = movePos;
limb.body.MoveToTargetPosition(Vector2.Distance(limb.SimPosition, movePos) < 10.0f);
limb.body.MoveToTargetPosition(Vector2.DistanceSquared(limb.SimPosition, movePos) < 100.0f);
}
else
{
@@ -1041,7 +1041,7 @@ namespace Barotrauma
//if the ragdoll is too far from the collider, disable collisions until it's close enough
//(in case the ragdoll has gotten stuck somewhere)
if (Vector2.Distance(collider.SimPosition, MainLimb.SimPosition) > allowedDist)
if (Vector2.DistanceSquared(collider.SimPosition, MainLimb.SimPosition) > allowedDist*allowedDist)
{
if (!collisionsDisabled)
{

View File

@@ -857,7 +857,7 @@ namespace Barotrauma
if (selectedCharacter!=null)
{
if (Vector2.Distance(selectedCharacter.WorldPosition, WorldPosition) > 300.0f || !selectedCharacter.CanBeSelected)
if (Vector2.DistanceSquared(selectedCharacter.WorldPosition, WorldPosition) > 90000.0f || !selectedCharacter.CanBeSelected)
{
DeselectCharacter(controlled == this);
}
@@ -952,7 +952,7 @@ namespace Barotrauma
maxDist = 150.0f;
}
if (Vector2.Distance(WorldPosition, item.WorldPosition) < maxDist ||
if (Vector2.DistanceSquared(WorldPosition, item.WorldPosition) < maxDist*maxDist ||
item.IsInsideTrigger(WorldPosition))
{
return true;
@@ -994,10 +994,10 @@ namespace Barotrauma
{
if (c == this || !c.enabled) continue;
if (Vector2.Distance(SimPosition, c.SimPosition) > maxDist) continue;
if (Vector2.DistanceSquared(SimPosition, c.SimPosition) > maxDist*maxDist) continue;
float dist = Vector2.Distance(mouseSimPos, c.SimPosition);
if (dist < maxDist && (closestCharacter==null || dist<closestDist))
float dist = Vector2.DistanceSquared(mouseSimPos, c.SimPosition);
if (dist < maxDist*maxDist && (closestCharacter==null || dist<closestDist))
{
closestCharacter = c;
closestDist = dist;
@@ -1074,7 +1074,7 @@ namespace Barotrauma
Vector2 mouseSimPos = ConvertUnits.ToSimUnits(cursorPosition);
if (Lights.LightManager.ViewTarget == this && Vector2.Distance(AnimController.Limbs[0].SimPosition, mouseSimPos) > 1.0f)
if (Lights.LightManager.ViewTarget == this && Vector2.DistanceSquared(AnimController.Limbs[0].SimPosition, mouseSimPos) > 1.0f)
{
Body body = Submarine.PickBody(AnimController.Limbs[0].SimPosition, mouseSimPos);
Structure structure = null;
@@ -1106,7 +1106,7 @@ namespace Barotrauma
if (closestCharacter != null && closestItem != null)
{
if (Vector2.Distance(closestCharacter.SimPosition, mouseSimPos) < ConvertUnits.ToSimUnits(closestItemDist))
if (Vector2.DistanceSquared(closestCharacter.SimPosition, mouseSimPos) < ConvertUnits.ToSimUnits(closestItemDist)*ConvertUnits.ToSimUnits(closestItemDist))
{
if (selectedConstruction != closestItem) closestItem = null;
}
@@ -1172,6 +1172,14 @@ namespace Barotrauma
}
}
public static void AddAllToGUIUpdateList()
{
for (int i = 0; i < CharacterList.Count; i++)
{
CharacterList[i].AddToGUIUpdateList();
}
}
public static void UpdateAll(Camera cam, float deltaTime)
{
//if (NewCharacterQueue.Count>0)
@@ -1185,6 +1193,14 @@ namespace Barotrauma
}
}
public virtual void AddToGUIUpdateList()
{
if (controlled == this)
{
CharacterHUD.AddToGUIUpdateList(this);
}
}
public virtual void Update(Camera cam, float deltaTime)
{
if (!Enabled) return;

View File

@@ -32,6 +32,31 @@ namespace Barotrauma
damageOverlayTimer = MathHelper.Clamp(amount * 0.1f, 0.2f, 5.0f);
}
public static void AddToGUIUpdateList(Character character)
{
if (cprButton != null && cprButton.Visible) cprButton.AddToGUIUpdateList();
if (suicideButton != null && suicideButton.Visible) suicideButton.AddToGUIUpdateList();
if (!character.IsUnconscious && character.Stun <= 0.0f)
{
if (character.Inventory != null)
{
for (int i = 0; i < character.Inventory.Items.Length - 1; i++)
{
var item = character.Inventory.Items[i];
if (item == null || CharacterInventory.limbSlots[i] == InvSlotType.Any) continue;
foreach (ItemComponent ic in item.components)
{
if (ic.DrawHudWhenEquipped) ic.AddToGUIUpdateList();
}
}
}
}
}
public static void Update(float deltaTime, Character character)
{
if (drowningBar != null)
@@ -228,7 +253,7 @@ namespace Barotrauma
suicideButton.OnClicked = (button, userData) =>
{
GUIComponent.MouseOn = null;
GUIComponent.ForceMouseOn(null);
if (Character.Controlled != null)
{
Character.Controlled.Kill(Character.Controlled.CauseOfDeath);

View File

@@ -78,6 +78,14 @@ namespace Barotrauma
}
public static void AddToGUIUpdateList()
{
if (isOpen)
{
frame.AddToGUIUpdateList();
}
}
public static void Update(GameMain game, float deltaTime)
{
if (PlayerInput.KeyHit(Keys.F3))
@@ -89,7 +97,7 @@ namespace Barotrauma
}
else
{
GUIComponent.MouseOn = null;
GUIComponent.ForceMouseOn(null);
textBox.Deselect();
}

View File

@@ -499,6 +499,28 @@ namespace Barotrauma
cursor.Draw(spriteBatch, PlayerInput.MousePosition);
}
public static void AddToGUIUpdateList()
{
if (pauseMenuOpen)
{
pauseMenu.AddToGUIUpdateList();
}
if (settingsMenuOpen)
{
GameMain.Config.SettingsFrame.AddToGUIUpdateList();
}
if (GUIMessageBox.MessageBoxes.Count > 0)
{
var messageBox = GUIMessageBox.MessageBoxes.Peek();
if (messageBox != null)
{
messageBox.AddToGUIUpdateList();
}
}
}
public static void Update(float deltaTime)
{
if (pauseMenuOpen)
@@ -516,7 +538,6 @@ namespace Barotrauma
var messageBox = GUIMessageBox.MessageBoxes.Peek();
if (messageBox != null)
{
GUIComponent.MouseOn = messageBox;
messageBox.Update(deltaTime);
}
}

View File

@@ -10,9 +10,47 @@ namespace Barotrauma
public abstract class GUIComponent
{
const float FlashDuration = 1.5f;
public static GUIComponent MouseOn;
public static GUIComponent MouseOn
{
get;
private set;
}
public static void ForceMouseOn(GUIComponent c)
{
MouseOn = c;
}
protected static List<GUIComponent> ComponentsToUpdate = new List<GUIComponent>();
public virtual void AddToGUIUpdateList()
{
if (!Visible) return;
if (ComponentsToUpdate.Contains(this)) return;
ComponentsToUpdate.Add(this);
children.ForEach(c => c.AddToGUIUpdateList());
}
public static void ClearUpdateList()
{
ComponentsToUpdate.Clear();
}
public static GUIComponent UpdateMouseOn()
{
MouseOn = null;
for (int i=ComponentsToUpdate.Count-1;i>=0;i--)
{
GUIComponent c = ComponentsToUpdate[i];
if (c.MouseRect.Contains(PlayerInput.MousePosition))
{
MouseOn = c;
break;
}
}
return MouseOn;
}
protected static KeyboardDispatcher keyboardDispatcher;
public enum ComponentState { None, Hover, Selected};
@@ -97,6 +135,11 @@ namespace Barotrauma
}
}
}
public virtual Rectangle MouseRect
{
get { return CanBeFocused ? rect : Rectangle.Empty; }
}
public List<UISprite> sprites;
//public Alignment SpriteAlignment { get; set; }
@@ -304,7 +347,7 @@ namespace Barotrauma
if (flashTimer>0.0f) flashTimer -= deltaTime;
if (CanBeFocused)
/*if (CanBeFocused)
{
if (rect.Contains(PlayerInput.MousePosition))
{
@@ -315,7 +358,7 @@ namespace Barotrauma
if (MouseOn == this) MouseOn = null;
}
}
}*/
//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

View File

@@ -166,6 +166,13 @@ namespace Barotrauma
return true;
}
public override void AddToGUIUpdateList()
{
base.AddToGUIUpdateList();
button.AddToGUIUpdateList();
if (Dropped) listBox.AddToGUIUpdateList();
}
public override void Update(float deltaTime)
{
if (!Visible) return;

View File

@@ -36,7 +36,7 @@ namespace Barotrauma
//if (style != null) ApplyStyle(style);
}
public override void Draw(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch)
{
if (!Visible) return;

View File

@@ -264,6 +264,20 @@ namespace Barotrauma
}
}
public override void AddToGUIUpdateList()
{
base.AddToGUIUpdateList();
if (scrollBarEnabled && !scrollBarHidden) scrollBar.AddToGUIUpdateList();
}
public override Rectangle MouseRect
{
get
{
return Rectangle.Empty;
}
}
public override void Update(float deltaTime)
{
if (!Visible) return;

View File

@@ -55,6 +55,11 @@ namespace Barotrauma
}
}
public override Rectangle MouseRect
{
get { return box.Rect; }
}
public GUITickBox(Rectangle rect, string label, Alignment alignment, GUIComponent parent)
: this(rect, label, alignment, GUI.Font, parent)
{
@@ -69,6 +74,7 @@ namespace Barotrauma
box = new GUIFrame(rect, Color.DarkGray, null, this);
box.HoverColor = Color.Gray;
box.SelectedColor = Color.DarkGray;
box.CanBeFocused = false;
text = new GUITextBlock(new Rectangle(rect.Right + 10, rect.Y+2, 20, rect.Height), label, GUI.Style, this, font);
@@ -76,19 +82,19 @@ namespace Barotrauma
Enabled = true;
}
public override void Update(float deltaTime)
{
if (!Visible || !Enabled) return;
if (MouseOn != null && MouseOn != this && !MouseOn.IsParentOf(this)) return;
//if (MouseOn != null && MouseOn != this && !MouseOn.IsParentOf(this)) return;
if (text.Rect.Contains(PlayerInput.MousePosition)) MouseOn = this;
//if (text.Rect.Contains(PlayerInput.MousePosition)) MouseOn = this;
if (box.Rect.Contains(PlayerInput.MousePosition))
if (MouseOn==this)//box.Rect.Contains(PlayerInput.MousePosition))
{
//ToolTip = this.ToolTip;
MouseOn = this;
//MouseOn = this;
box.State = ComponentState.Hover;

View File

@@ -327,10 +327,26 @@ namespace Barotrauma
if (PlayerInput.KeyHit(Keys.Escape)) GUI.TogglePauseMenu();
DebugConsole.Update(this, (float)Timing.Step);
GUIComponent.ClearUpdateList();
DebugConsole.AddToGUIUpdateList();
paused = (DebugConsole.IsOpen || GUI.PauseMenuOpen || GUI.SettingsMenuOpen) &&
(NetworkMember == null || !NetworkMember.GameStarted);
if (!paused)
{
Screen.Selected.AddToGUIUpdateList();
}
if (NetworkMember != null)
{
NetworkMember.AddToGUIUpdateList();
}
GUI.AddToGUIUpdateList();
GUIComponent.UpdateMouseOn();
DebugConsole.Update(this, (float)Timing.Step);
if (!paused)
{
@@ -371,6 +387,14 @@ namespace Barotrauma
{
Screen.Selected.Draw(deltaTime, GraphicsDevice, spriteBatch);
}
if (!DebugDraw) return;
if (GUIComponent.MouseOn!=null)
{
spriteBatch.Begin();
GUI.DrawRectangle(spriteBatch, GUIComponent.MouseOn.MouseRect, Color.Lime);
spriteBatch.End();
}
}
static bool waitForKeyHit = true;

View File

@@ -157,6 +157,13 @@ namespace Barotrauma
//new GUIImage(new Rectangle(-10, -5, 0, 0), character.AnimController.Limbs[0].sprite, Alignment.Left, frame);
}
public void AddToGUIUpdateList()
{
guiFrame.AddToGUIUpdateList();
if (commander.Frame != null) commander.Frame.AddToGUIUpdateList();
if (crewFrameOpen) crewFrame.AddToGUIUpdateList();
}
public void Update(float deltaTime)
{
guiFrame.Update(deltaTime);

View File

@@ -77,6 +77,8 @@ namespace Barotrauma
public virtual void MsgBox() { }
public virtual void AddToGUIUpdateList() { }
public virtual void Update(float deltaTime)
{
//if (!isRunning) return;

View File

@@ -27,6 +27,11 @@ namespace Barotrauma
}
public override void AddToGUIUpdateList()
{
tutorialType.AddToGUIUpdateList();
}
public override void Update(float deltaTime)
{
base.Update(deltaTime);

View File

@@ -75,6 +75,11 @@ namespace Barotrauma.Tutorials
CoroutineManager.StartCoroutine(UpdateState());
}
public virtual void AddToGUIUpdateList()
{
if (infoBox != null) infoBox.AddToGUIUpdateList();
}
public virtual void Update(float deltaTime)
{
if (character!=null)

View File

@@ -360,6 +360,13 @@ namespace Barotrauma
}
public void AddToGUIUpdateList()
{
if (gameMode != null) gameMode.AddToGUIUpdateList();
if (infoFrame != null) infoButton.AddToGUIUpdateList();
}
public void Update(float deltaTime)
{
TaskManager.Update(deltaTime);

View File

@@ -469,6 +469,8 @@ namespace Barotrauma.Items.Components
public virtual void DrawHUD(SpriteBatch spriteBatch, Character character) { }
public virtual void AddToGUIUpdateList() { }
public virtual void UpdateHUD(Character character) { }
/// <returns>true if the operation was completed</returns>

View File

@@ -85,6 +85,11 @@ namespace Barotrauma.Items.Components
GuiFrame.Draw(spriteBatch);
}
public override void AddToGUIUpdateList()
{
GuiFrame.AddToGUIUpdateList();
}
public override void UpdateHUD(Character character)
{
GuiFrame.Update((float)Timing.Step);

View File

@@ -116,7 +116,11 @@ namespace Barotrauma.Items.Components
//GUI.DrawRectangle(spriteBatch, new Rectangle(x, y, width, height), Color.Black, true);
spriteBatch.DrawString(GUI.Font, "Force: " + (int)(targetForce) + " %", new Vector2(GuiFrame.Rect.X + 30, GuiFrame.Rect.Y + 30), Color.White);
}
public override void AddToGUIUpdateList()
{
GuiFrame.AddToGUIUpdateList();
}
public override void UpdateHUD(Character character)

View File

@@ -385,6 +385,11 @@ namespace Barotrauma.Items.Components
GuiFrame.Draw(spriteBatch);
}
public override void AddToGUIUpdateList()
{
GuiFrame.AddToGUIUpdateList();
}
public override void UpdateHUD(Character character)
{
FabricableItem targetItem = itemList.SelectedData as FabricableItem;

View File

@@ -162,6 +162,11 @@ namespace Barotrauma.Items.Components
}
public override void AddToGUIUpdateList()
{
GuiFrame.AddToGUIUpdateList();
}
public override void UpdateHUD(Character character)
{
GuiFrame.Update(1.0f / 60.0f);

View File

@@ -62,6 +62,7 @@ namespace Barotrauma.Items.Components
return true;
};
GuiFrame.CanBeFocused = false;
}
public override void Update(float deltaTime, Camera cam)
@@ -100,6 +101,11 @@ namespace Barotrauma.Items.Components
return pingState > 1.0f;
}
public override void AddToGUIUpdateList()
{
GuiFrame.AddToGUIUpdateList();
}
public override void UpdateHUD(Character character)
{
GuiFrame.Update((float)Timing.Step);

View File

@@ -479,6 +479,11 @@ namespace Barotrauma.Items.Components
//y = y - 260;
}
public override void AddToGUIUpdateList()
{
GuiFrame.AddToGUIUpdateList();
}
public override void UpdateHUD(Character character)
{
GuiFrame.Update(1.0f / 60.0f);

View File

@@ -214,20 +214,28 @@ namespace Barotrauma.Items.Components
if (Vector2.Distance(PlayerInput.MousePosition, new Vector2(velRect.Center.X, velRect.Center.Y)) < 200.0f)
{
GUI.DrawRectangle(spriteBatch, new Rectangle((int)targetVelPos.X -10, (int)targetVelPos.Y - 10, 20, 20), Color.Red);
if (PlayerInput.LeftButtonHeld())
{
TargetVelocity = PlayerInput.MousePosition - new Vector2(velRect.Center.X, velRect.Center.Y);
targetVelocity.Y = -targetVelocity.Y;
valueChanged = true;
}
}
}
public override void AddToGUIUpdateList()
{
GuiFrame.AddToGUIUpdateList();
}
public override void UpdateHUD(Character character)
{
GuiFrame.Update(1.0f / 60.0f);
if (Vector2.Distance(PlayerInput.MousePosition, new Vector2(GuiFrame.Rect.Center.X, GuiFrame.Rect.Center.Y)) < 200.0f)
{
if (PlayerInput.LeftButtonHeld())
{
TargetVelocity = PlayerInput.MousePosition - new Vector2(GuiFrame.Rect.Center.X, GuiFrame.Rect.Center.Y);
targetVelocity.Y = -targetVelocity.Y;
valueChanged = true;
}
}
}
private void UpdateAutoPilot(float deltaTime)

View File

@@ -246,6 +246,11 @@ namespace Barotrauma.Items.Components
spriteBatch.DrawString(GUI.Font, "Recharge rate: " + (int)((rechargeSpeed / maxRechargeSpeed) * 100.0f) + " %", new Vector2(x + 30, y + 95), Color.White);
}
public override void AddToGUIUpdateList()
{
GuiFrame.AddToGUIUpdateList();
}
public override void UpdateHUD(Character character)
{
GuiFrame.Update(1.0f / 60.0f);

View File

@@ -181,6 +181,11 @@ namespace Barotrauma.Items.Components
spriteBatch.DrawString(GUI.Font, "Load: " + (int)powerLoad + " kW", new Vector2(x + 30, y + 100), Color.White);
}
public override void AddToGUIUpdateList()
{
GuiFrame.AddToGUIUpdateList();
}
public override void UpdateHUD(Character character)
{
GuiFrame.Update(1.0f / 60.0f);

View File

@@ -192,6 +192,13 @@ namespace Barotrauma
frame.Draw(spriteBatch);
}
public static void AddToGUIUpdateList()
{
if (frame == null) return;
frame.AddToGUIUpdateList();
}
public static void UpdateHud(Item item, Character character)
{
if (frame == null || frame.UserData != item)

View File

@@ -1139,6 +1139,27 @@ namespace Barotrauma
}
}
public override void AddToGUIUpdateList()
{
if (condition <= 0.0f)
{
FixRequirement.AddToGUIUpdateList();
return;
}
if (HasInGameEditableProperties)
{
if (editingHUD != null) editingHUD.AddToGUIUpdateList();
}
foreach (ItemComponent ic in components)
{
ic.AddToGUIUpdateList();
}
if (Screen.Selected is EditMapScreen && editingHUD != null) editingHUD.AddToGUIUpdateList();
}
public virtual void UpdateHUD(Camera cam, Character character)
{
if (condition <= 0.0f)
@@ -1388,7 +1409,7 @@ namespace Barotrauma
ic.ApplyStatusEffects(ActionType.OnPicked, 1.0f, picker);
ic.PlaySound(ActionType.OnPicked, picker.WorldPosition);
if (picker==Character.Controlled) GUIComponent.MouseOn = null;
if (picker==Character.Controlled) GUIComponent.ForceMouseOn(null);
if (ic.CanBeSelected) selected = true;
}

View File

@@ -18,10 +18,24 @@ namespace Barotrauma
//which entities have been selected for editing
private static List<MapEntity> selectedList = new List<MapEntity>();
public static List<MapEntity> SelectedList
{
get
{
return selectedList;
}
}
private static List<MapEntity> copiedList = new List<MapEntity>();
protected static GUIComponent editingHUD;
public static GUIComponent EditingHUD
{
get
{
return editingHUD;
}
}
protected static Vector2 selectionPos = Vector2.Zero;
protected static Vector2 selectionSize = Vector2.Zero;
@@ -636,6 +650,11 @@ namespace Barotrauma
Move(-relative * 2.0f);
}
public virtual void AddToGUIUpdateList()
{
if (editingHUD != null) editingHUD.AddToGUIUpdateList();
}
public virtual void UpdateEditing(Camera cam) { }

View File

@@ -288,6 +288,14 @@ namespace Barotrauma.Networking
Log("Master server responded", Color.Cyan);
}
public override void AddToGUIUpdateList()
{
if (started) base.AddToGUIUpdateList();
if (settingsFrame != null) settingsFrame.AddToGUIUpdateList();
if (log.LogFrame != null) log.LogFrame.AddToGUIUpdateList();
}
public override void Update(float deltaTime)
{
if (ShowNetStats) netStats.Update(deltaTime);

View File

@@ -338,6 +338,16 @@ namespace Barotrauma.Networking
public virtual void KickPlayer(string kickedName, bool ban, bool range = false) { }
public virtual void AddToGUIUpdateList()
{
if (gameStarted && Screen.Selected == GameMain.GameScreen)
{
inGameHUD.AddToGUIUpdateList();
GameMain.GameSession.CrewManager.AddToGUIUpdateList();
}
}
public virtual void Update(float deltaTime)
{
if (gameStarted && Screen.Selected == GameMain.GameScreen)

View File

@@ -250,8 +250,8 @@ namespace Barotrauma
public override void Select()
{
base.Select();
GUIComponent.MouseOn = null;
GUIComponent.ForceMouseOn(null);
characterMode = false;
if (Submarine.MainSub != null)
@@ -278,7 +278,7 @@ namespace Barotrauma
{
base.Deselect();
GUIComponent.MouseOn = null;
GUIComponent.ForceMouseOn(null);
MapEntityPrefab.Selected = null;
@@ -768,7 +768,7 @@ namespace Barotrauma
MapEntityPrefab.SelectPrefab(obj);
selectedTab = -1;
GUIComponent.MouseOn = null;
GUIComponent.ForceMouseOn(null);
return false;
}
@@ -803,6 +803,43 @@ namespace Barotrauma
previouslyUsedList.children.Insert(0, textBlock);
}
public override void AddToGUIUpdateList()
{
if (tutorial != null) tutorial.AddToGUIUpdateList();
if (MapEntity.SelectedList.Count == 1)
{
MapEntity.SelectedList[0].AddToGUIUpdateList();
}
leftPanel.AddToGUIUpdateList();
topPanel.AddToGUIUpdateList();
if (wiringMode)
{
wiringToolPanel.AddToGUIUpdateList();
}
if (loadFrame != null)
{
loadFrame.AddToGUIUpdateList();
}
else if (saveFrame != null)
{
saveFrame.AddToGUIUpdateList();
}
else if (selectedTab > -1)
{
GUItabs[selectedTab].AddToGUIUpdateList();
}
if ((characterMode || wiringMode) && dummyCharacter != null)
{
CharacterHUD.AddToGUIUpdateList(dummyCharacter);
}
GUI.AddToGUIUpdateList();
}
/// <summary>
/// Allows the game to run logic such as updating the world,
@@ -851,16 +888,15 @@ namespace Barotrauma
}
else
{
MapEntity.UpdateSelecting(cam);
}
GUIComponent.MouseOn = null;
//GUIComponent.ForceMouseOn(null);
if (!characterMode && !wiringMode)
{
if (MapEntityPrefab.Selected != null) MapEntityPrefab.Selected.UpdatePlacing(cam);
MapEntity.UpdateEditor(cam);
}

View File

@@ -88,7 +88,21 @@ namespace Barotrauma
Sounds.SoundManager.LowPassHFGain = 1.0f;
}
public override void AddToGUIUpdateList()
{
if (GameMain.GameSession != null) GameMain.GameSession.AddToGUIUpdateList();
if (Character.Controlled != null && Character.Controlled.SelectedConstruction != null)
{
if (Character.Controlled.SelectedConstruction == Character.Controlled.ClosestItem)
{
Character.Controlled.SelectedConstruction.AddToGUIUpdateList();
}
}
Character.AddAllToGUIUpdateList();
}
/// <summary>
/// Allows the game to run logic such as updating the world,
/// checking for collisions, gathering input, and playing audio.
@@ -132,7 +146,7 @@ namespace Barotrauma
}
}
Character.UpdateAll(cam, (float)deltaTime);
BackgroundCreatureManager.Update(cam, (float)deltaTime);
GameMain.ParticleManager.Update((float)deltaTime);

View File

@@ -341,6 +341,14 @@ namespace Barotrauma
return false;
}
public override void AddToGUIUpdateList()
{
base.AddToGUIUpdateList();
topPanel.AddToGUIUpdateList();
bottomPanel[selectedRightPanel].AddToGUIUpdateList();
}
public override void Update(double deltaTime)
{
base.Update(deltaTime);

View File

@@ -467,6 +467,12 @@ namespace Barotrauma
menuTabs[(int)Tab.LoadGame].RemoveChild(prevFrame);
}
public override void AddToGUIUpdateList()
{
buttonsTab.AddToGUIUpdateList();
if (selectedTab > 0) menuTabs[selectedTab].AddToGUIUpdateList();
}
public override void Update(double deltaTime)
{
buttonsTab.Update((float)deltaTime);

View File

@@ -916,6 +916,24 @@ namespace Barotrauma
playerList.ClearChildren();
}
public override void AddToGUIUpdateList()
{
base.AddToGUIUpdateList();
if (jobInfoFrame != null)
{
jobInfoFrame.AddToGUIUpdateList();
}
else if (playerFrame != null)
{
playerFrame.AddToGUIUpdateList();
}
else
{
menu.AddToGUIUpdateList();
}
}
public override void Update(double deltaTime)
{
base.Update(deltaTime);
@@ -944,9 +962,7 @@ namespace Barotrauma
}
else
{
menu.Update((float)deltaTime);
menu.Update((float)deltaTime);
}
if (autoRestartTimer != 0.0f && autoRestartBox.Selected)

View File

@@ -33,6 +33,10 @@ namespace Barotrauma
get { return null; }
}
public virtual void AddToGUIUpdateList()
{
}
public virtual void Update(double deltaTime)
{
}

View File

@@ -366,6 +366,11 @@ namespace Barotrauma
spriteBatch.End();
}
public override void AddToGUIUpdateList()
{
menu.AddToGUIUpdateList();
}
public override void Update(double deltaTime)
{
menu.Update((float)deltaTime);