Moved some more UI update logic from draw to update
todo: inventories (oh the horror)
This commit is contained in:
@@ -197,6 +197,36 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
scrollBar.BarScroll -= (PlayerInput.ScrollWheelSpeed / 500.0f) * BarSize;
|
scrollBar.BarScroll -= (PlayerInput.ScrollWheelSpeed / 500.0f) * BarSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < children.Count; i++)
|
||||||
|
{
|
||||||
|
GUIComponent child = children[i];
|
||||||
|
if (child == frame || !child.Visible) continue;
|
||||||
|
|
||||||
|
if (enabled && child.CanBeFocused &&
|
||||||
|
(MouseOn == this || (MouseOn != null && this.IsParentOf(MouseOn))) && child.Rect.Contains(PlayerInput.MousePosition))
|
||||||
|
{
|
||||||
|
child.State = ComponentState.Hover;
|
||||||
|
if (PlayerInput.LeftButtonClicked())
|
||||||
|
{
|
||||||
|
Debug.WriteLine("clicked");
|
||||||
|
Select(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (selected.Contains(child))
|
||||||
|
{
|
||||||
|
child.State = ComponentState.Selected;
|
||||||
|
|
||||||
|
if (CheckSelected != null)
|
||||||
|
{
|
||||||
|
if (CheckSelected() != child.UserData) selected.Remove(child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
child.State = ComponentState.None;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Select(int childIndex, bool force = false)
|
public void Select(int childIndex, bool force = false)
|
||||||
@@ -359,36 +389,6 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enabled && child.CanBeFocused &&
|
|
||||||
(MouseOn == this || (MouseOn != null && this.IsParentOf(MouseOn))) && child.Rect.Contains(PlayerInput.MousePosition))
|
|
||||||
{
|
|
||||||
child.State = ComponentState.Hover;
|
|
||||||
if (PlayerInput.LeftButtonClicked())
|
|
||||||
{
|
|
||||||
Debug.WriteLine("clicked");
|
|
||||||
Select(i);
|
|
||||||
//selected = child;
|
|
||||||
//if (OnSelected != null)
|
|
||||||
//{
|
|
||||||
// if (!OnSelected(selected, child.UserData)) selected = null;
|
|
||||||
//}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (selected.Contains(child))
|
|
||||||
{
|
|
||||||
child.State = ComponentState.Selected;
|
|
||||||
|
|
||||||
if (CheckSelected != null)
|
|
||||||
{
|
|
||||||
if (CheckSelected() != child.UserData) selected.Remove(child);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
child.State = ComponentState.None;
|
|
||||||
}
|
|
||||||
|
|
||||||
child.Draw(spriteBatch);
|
child.Draw(spriteBatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -217,6 +217,24 @@ namespace Barotrauma
|
|||||||
if (flashTimer > 0.0f) flashTimer -= deltaTime;
|
if (flashTimer > 0.0f) flashTimer -= deltaTime;
|
||||||
if (!Enabled) return;
|
if (!Enabled) return;
|
||||||
|
|
||||||
|
if (rect.Contains(PlayerInput.MousePosition) && Enabled &&
|
||||||
|
(MouseOn == null || MouseOn == this || IsParentOf(MouseOn) || MouseOn.IsParentOf(this)))
|
||||||
|
{
|
||||||
|
|
||||||
|
state = ComponentState.Hover;
|
||||||
|
if (PlayerInput.LeftButtonClicked())
|
||||||
|
{
|
||||||
|
Select();
|
||||||
|
if (OnSelected != null) OnSelected(this, Keys.None);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
state = ComponentState.None;
|
||||||
|
}
|
||||||
|
|
||||||
|
textBlock.State = state;
|
||||||
|
|
||||||
if (CaretEnabled)
|
if (CaretEnabled)
|
||||||
{
|
{
|
||||||
caretTimer += deltaTime;
|
caretTimer += deltaTime;
|
||||||
@@ -248,24 +266,6 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
if (!Visible) return;
|
if (!Visible) return;
|
||||||
|
|
||||||
if (rect.Contains(PlayerInput.MousePosition) && Enabled &&
|
|
||||||
(MouseOn == null || MouseOn == this || IsParentOf(MouseOn) || MouseOn.IsParentOf(this)))
|
|
||||||
{
|
|
||||||
|
|
||||||
state = ComponentState.Hover;
|
|
||||||
if (PlayerInput.LeftButtonClicked())
|
|
||||||
{
|
|
||||||
Select();
|
|
||||||
if (OnSelected != null) OnSelected(this, Keys.None);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
state = ComponentState.None;
|
|
||||||
}
|
|
||||||
|
|
||||||
textBlock.State = state;
|
|
||||||
|
|
||||||
DrawChildren(spriteBatch);
|
DrawChildren(spriteBatch);
|
||||||
|
|
||||||
if (!CaretEnabled) return;
|
if (!CaretEnabled) return;
|
||||||
@@ -279,7 +279,6 @@ namespace Barotrauma
|
|||||||
new Vector2((int)caretPos.X + 2, caretPos.Y + Font.MeasureString("I").Y - 3),
|
new Vector2((int)caretPos.X + 2, caretPos.Y + Font.MeasureString("I").Y - 3),
|
||||||
textBlock.TextColor * (textBlock.TextColor.A / 255.0f));
|
textBlock.TextColor * (textBlock.TextColor.A / 255.0f));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ReceiveTextInput(char inputChar)
|
public void ReceiveTextInput(char inputChar)
|
||||||
|
|||||||
@@ -254,20 +254,18 @@ namespace Barotrauma
|
|||||||
currentLocation.Discovered = true;
|
currentLocation.Discovered = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Draw(SpriteBatch spriteBatch, Rectangle rect, float scale = 1.0f)
|
public void Update(float deltaTime, Rectangle rect, float scale = 1.0f)
|
||||||
{
|
{
|
||||||
Vector2 rectCenter = new Vector2(rect.Center.X, rect.Center.Y);
|
Vector2 rectCenter = new Vector2(rect.Center.X, rect.Center.Y);
|
||||||
Vector2 offset = -currentLocation.MapPosition;
|
Vector2 offset = -currentLocation.MapPosition;
|
||||||
|
|
||||||
iceTexture.DrawTiled(spriteBatch, new Vector2(rect.X, rect.Y), new Vector2(rect.Width, rect.Height), Vector2.Zero, Color.White*0.8f);
|
|
||||||
|
|
||||||
float maxDist = 20.0f;
|
float maxDist = 20.0f;
|
||||||
float closestDist = 0.0f;
|
float closestDist = 0.0f;
|
||||||
highlightedLocation = null;
|
highlightedLocation = null;
|
||||||
for (int i = 0; i < locations.Count;i++ )
|
for (int i = 0; i < locations.Count; i++)
|
||||||
{
|
{
|
||||||
Location location = locations[i];
|
Location location = locations[i];
|
||||||
Vector2 pos = rectCenter + (location.MapPosition+offset) * scale;
|
Vector2 pos = rectCenter + (location.MapPosition + offset) * scale;
|
||||||
|
|
||||||
if (!rect.Contains(pos)) continue;
|
if (!rect.Contains(pos)) continue;
|
||||||
|
|
||||||
@@ -281,21 +279,30 @@ namespace Barotrauma
|
|||||||
|
|
||||||
foreach (LocationConnection connection in connections)
|
foreach (LocationConnection connection in connections)
|
||||||
{
|
{
|
||||||
Color crackColor = Color.White * Math.Max(connection.Difficulty/100.0f, 1.5f);
|
|
||||||
|
|
||||||
if (highlightedLocation != currentLocation &&
|
if (highlightedLocation != currentLocation &&
|
||||||
connection.Locations.Contains(highlightedLocation) && connection.Locations.Contains(currentLocation))
|
connection.Locations.Contains(highlightedLocation) && connection.Locations.Contains(currentLocation))
|
||||||
{
|
{
|
||||||
crackColor = Color.Red;
|
if (PlayerInput.LeftButtonClicked() &&
|
||||||
|
|
||||||
if (PlayerInput.LeftButtonClicked()&&
|
|
||||||
selectedLocation != highlightedLocation && highlightedLocation != null)
|
selectedLocation != highlightedLocation && highlightedLocation != null)
|
||||||
{
|
{
|
||||||
selectedConnection = connection;
|
selectedConnection = connection;
|
||||||
selectedLocation = highlightedLocation;
|
selectedLocation = highlightedLocation;
|
||||||
GameMain.LobbyScreen.SelectLocation(highlightedLocation, connection);
|
GameMain.LobbyScreen.SelectLocation(highlightedLocation, connection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Draw(SpriteBatch spriteBatch, Rectangle rect, float scale = 1.0f)
|
||||||
|
{
|
||||||
|
Vector2 rectCenter = new Vector2(rect.Center.X, rect.Center.Y);
|
||||||
|
Vector2 offset = -currentLocation.MapPosition;
|
||||||
|
|
||||||
|
iceTexture.DrawTiled(spriteBatch, new Vector2(rect.X, rect.Y), new Vector2(rect.Width, rect.Height), Vector2.Zero, Color.White*0.8f);
|
||||||
|
|
||||||
|
foreach (LocationConnection connection in connections)
|
||||||
|
{
|
||||||
|
Color crackColor = Color.White * Math.Max(connection.Difficulty/100.0f, 1.5f);
|
||||||
|
|
||||||
if (selectedLocation != currentLocation &&
|
if (selectedLocation != currentLocation &&
|
||||||
(connection.Locations.Contains(selectedLocation) && connection.Locations.Contains(currentLocation)))
|
(connection.Locations.Contains(selectedLocation) && connection.Locations.Contains(currentLocation)))
|
||||||
|
|||||||
@@ -350,7 +350,12 @@ namespace Barotrauma
|
|||||||
|
|
||||||
mapZoom += PlayerInput.ScrollWheelSpeed / 1000.0f;
|
mapZoom += PlayerInput.ScrollWheelSpeed / 1000.0f;
|
||||||
mapZoom = MathHelper.Clamp(mapZoom, 1.0f, 4.0f);
|
mapZoom = MathHelper.Clamp(mapZoom, 1.0f, 4.0f);
|
||||||
//shiftPanel.Update((float)deltaTime);
|
|
||||||
|
GameMain.GameSession.Map.Update((float)deltaTime, new Rectangle(
|
||||||
|
bottomPanel[selectedRightPanel].Rect.X + 20,
|
||||||
|
bottomPanel[selectedRightPanel].Rect.Y + 20,
|
||||||
|
bottomPanel[selectedRightPanel].Rect.Width - 310,
|
||||||
|
bottomPanel[selectedRightPanel].Rect.Height - 40), mapZoom);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Draw(double deltaTime, GraphicsDevice graphics, SpriteBatch spriteBatch)
|
public override void Draw(double deltaTime, GraphicsDevice graphics, SpriteBatch spriteBatch)
|
||||||
|
|||||||
Reference in New Issue
Block a user