Fixed timestep for some GUI & input code

Fixed timestep only applied to the physics simulation, but input and GUI updates were not being handled properly, so here's some progress into fixing them.
This commit is contained in:
juanjp600
2016-09-18 11:03:52 -03:00
parent 179c0424d7
commit 33641ead3e
14 changed files with 153 additions and 50 deletions

View File

@@ -161,6 +161,27 @@ namespace Barotrauma
public override void Draw(SpriteBatch spriteBatch)
{
if (!Visible) return;
//Color currColor = color;
//if (state == ComponentState.Hover) currColor = hoverColor;
//if (state == ComponentState.Selected) currColor = selectedColor;
//GUI.DrawRectangle(spriteBatch, rect, currColor * alpha, true);
////spriteBatch.DrawString(HUD.font, text, new Vector2(rect.X+rect.Width/2, rect.Y+rect.Height/2), Color.Black, 0.0f, new Vector2(0.5f,0.5f), 1.0f, SpriteEffects.None, 0.0f);
//GUI.DrawRectangle(spriteBatch, rect, Color.Black * alpha, false);
DrawChildren(spriteBatch);
//if (!Enabled) GUI.DrawRectangle(spriteBatch, rect, Color.Gray*0.5f, true);
}
public override void Update(float deltaTime)
{
if (!Visible) return;
base.Update(deltaTime);
if (rect.Contains(PlayerInput.MousePosition) && CanBeSelected && Enabled && (MouseOn == null || MouseOn == this || IsParentOf(MouseOn)))
{
@@ -183,7 +204,7 @@ namespace Barotrauma
else
{
Selected = !Selected;
// state = state == ComponentState.Selected ? ComponentState.None : ComponentState.Selected;
// state = state == ComponentState.Selected ? ComponentState.None : ComponentState.Selected;
}
}
}
@@ -193,20 +214,6 @@ namespace Barotrauma
}
frame.State = state;
//Color currColor = color;
//if (state == ComponentState.Hover) currColor = hoverColor;
//if (state == ComponentState.Selected) currColor = selectedColor;
//GUI.DrawRectangle(spriteBatch, rect, currColor * alpha, true);
////spriteBatch.DrawString(HUD.font, text, new Vector2(rect.X+rect.Width/2, rect.Y+rect.Height/2), Color.Black, 0.0f, new Vector2(0.5f,0.5f), 1.0f, SpriteEffects.None, 0.0f);
//GUI.DrawRectangle(spriteBatch, rect, Color.Black * alpha, false);
DrawChildren(spriteBatch);
//if (!Enabled) GUI.DrawRectangle(spriteBatch, rect, Color.Gray*0.5f, true);
}
}
}