Fixed LobbyScreen item grouping & light.hullsInRange updating
This commit is contained in:
@@ -1084,12 +1084,12 @@ namespace Barotrauma
|
|||||||
for (int i = 0; i < 10; i++)
|
for (int i = 0; i < 10; i++)
|
||||||
{
|
{
|
||||||
Particle p = GameMain.ParticleManager.CreateParticle("waterblood",
|
Particle p = GameMain.ParticleManager.CreateParticle("waterblood",
|
||||||
ConvertUnits.ToDisplayUnits(centerOfMass) + Rand.Vector(50.0f),
|
ConvertUnits.ToDisplayUnits(centerOfMass) + Rand.Vector(5.0f),
|
||||||
Vector2.Zero);
|
Rand.Vector(10.0f));
|
||||||
if (p!=null) p.Size *= 2.0f;
|
if (p!=null) p.Size *= 2.0f;
|
||||||
|
|
||||||
GameMain.ParticleManager.CreateParticle("bubbles",
|
GameMain.ParticleManager.CreateParticle("bubbles",
|
||||||
ConvertUnits.ToDisplayUnits(centerOfMass) + Rand.Vector(50.0f),
|
ConvertUnits.ToDisplayUnits(centerOfMass) + Rand.Vector(5.0f),
|
||||||
new Vector2(Rand.Range(-50f, 50f), Rand.Range(-100f,50f)));
|
new Vector2(Rand.Range(-50f, 50f), Rand.Range(-100f,50f)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -166,12 +166,15 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public static void DrawString(SpriteBatch sb, Vector2 pos, string text, Color color, Color? backgroundColor=null, int backgroundPadding=0, SpriteFont font = null)
|
public static void DrawString(SpriteBatch sb, Vector2 pos, string text, Color color, Color? backgroundColor=null, int backgroundPadding=0, SpriteFont font = null)
|
||||||
{
|
{
|
||||||
if (font == null) font = GUI.Font;
|
|
||||||
sb.DrawString(font, text, pos, color);
|
|
||||||
if (backgroundColor == null) return;
|
|
||||||
|
|
||||||
Vector2 textSize = font.MeasureString(text);
|
if (font == null) font = GUI.Font;
|
||||||
DrawRectangle(sb, pos - Vector2.One*backgroundPadding, textSize + Vector2.One * 2.0f * backgroundPadding, (Color)backgroundColor, true);
|
if (backgroundColor != null)
|
||||||
|
{
|
||||||
|
Vector2 textSize = font.MeasureString(text);
|
||||||
|
DrawRectangle(sb, pos - Vector2.One * backgroundPadding, textSize + Vector2.One * 2.0f * backgroundPadding, (Color)backgroundColor, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
sb.DrawString(font, text, pos, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void DrawRectangle(SpriteBatch sb, Vector2 start, Vector2 size, Color clr, bool isFilled = false, float depth = 0.0f)
|
public static void DrawRectangle(SpriteBatch sb, Vector2 start, Vector2 size, Color clr, bool isFilled = false, float depth = 0.0f)
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ namespace Barotrauma.Items.Components
|
|||||||
item.NewComponentEvent(this, true, false);
|
item.NewComponentEvent(this, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
int radius = GuiFrame.Rect.Height / 2 - 10;
|
int radius = GuiFrame.Rect.Height / 2 - 30;
|
||||||
DrawRadar(spriteBatch, new Rectangle((int)GuiFrame.Center.X - radius, (int)GuiFrame.Center.Y - radius, radius * 2, radius * 2));
|
DrawRadar(spriteBatch, new Rectangle((int)GuiFrame.Center.X - radius, (int)GuiFrame.Center.Y - radius, radius * 2, radius * 2));
|
||||||
|
|
||||||
//voltage = 0.0f;
|
//voltage = 0.0f;
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ namespace Barotrauma.Lights
|
|||||||
foreach (LightSource light in lights)
|
foreach (LightSource light in lights)
|
||||||
{
|
{
|
||||||
if (light.hullsInRange.Count > 0 || light.Color.A < 0.01f || light.Range < 1.0f) continue;
|
if (light.hullsInRange.Count > 0 || light.Color.A < 0.01f || light.Range < 1.0f) continue;
|
||||||
if (!MathUtils.CircleIntersectsRectangle(light.Position, light.Range, viewRect)) continue;
|
if (!MathUtils.CircleIntersectsRectangle(light.WorldPosition, light.Range, viewRect)) continue;
|
||||||
|
|
||||||
light.Draw(spriteBatch);
|
light.Draw(spriteBatch);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ namespace Barotrauma.Lights
|
|||||||
{
|
{
|
||||||
|
|
||||||
range = MathHelper.Clamp(value, 0.0f, 2048.0f);
|
range = MathHelper.Clamp(value, 0.0f, 2048.0f);
|
||||||
if (Math.Abs(prevHullUpdateRange - range)>5.0f) return;
|
if (Math.Abs(prevHullUpdateRange - range)<5.0f) return;
|
||||||
|
|
||||||
UpdateHullsInRange();
|
UpdateHullsInRange();
|
||||||
prevHullUpdateRange = range;
|
prevHullUpdateRange = range;
|
||||||
|
|||||||
@@ -95,7 +95,6 @@ namespace Barotrauma
|
|||||||
itemList.OnSelected = SelectPrefab;
|
itemList.OnSelected = SelectPrefab;
|
||||||
itemList.CheckSelected = MapEntityPrefab.GetSelected;
|
itemList.CheckSelected = MapEntityPrefab.GetSelected;
|
||||||
|
|
||||||
|
|
||||||
foreach (MapEntityPrefab ep in MapEntityPrefab.list)
|
foreach (MapEntityPrefab ep in MapEntityPrefab.list)
|
||||||
{
|
{
|
||||||
if (ep.Category != category) continue;
|
if (ep.Category != category) continue;
|
||||||
@@ -130,6 +129,9 @@ namespace Barotrauma
|
|||||||
img.Color = ep.SpriteColor;
|
img.Color = ep.SpriteColor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
itemList.children.Sort((i1, i2) => (i1.UserData as MapEntityPrefab).Name.CompareTo((i2.UserData as MapEntityPrefab).Name));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
|
||||||
@@ -20,7 +21,7 @@ namespace Barotrauma
|
|||||||
private GUIListBox characterList, hireList;
|
private GUIListBox characterList, hireList;
|
||||||
|
|
||||||
private GUIListBox selectedItemList;
|
private GUIListBox selectedItemList;
|
||||||
private GUIListBox[] storeItemLists;
|
private GUIListBox storeItemList;
|
||||||
|
|
||||||
private SinglePlayerMode gameMode;
|
private SinglePlayerMode gameMode;
|
||||||
|
|
||||||
@@ -139,24 +140,24 @@ namespace Barotrauma
|
|||||||
buyButton = new GUIButton(new Rectangle(sellColumnWidth + 20, 0, 100, 25), "Buy", Alignment.Bottom, GUI.Style, bottomPanel[(int)PanelTab.Store]);
|
buyButton = new GUIButton(new Rectangle(sellColumnWidth + 20, 0, 100, 25), "Buy", Alignment.Bottom, GUI.Style, bottomPanel[(int)PanelTab.Store]);
|
||||||
buyButton.OnClicked = BuyItems;
|
buyButton.OnClicked = BuyItems;
|
||||||
|
|
||||||
|
int x = selectedItemList.Rect.Width + 40;
|
||||||
storeItemLists = new GUIListBox[Enum.GetValues(typeof(MapEntityCategory)).Length];
|
|
||||||
|
|
||||||
foreach (MapEntityCategory category in Enum.GetValues(typeof(MapEntityCategory)))
|
foreach (MapEntityCategory category in Enum.GetValues(typeof(MapEntityCategory)))
|
||||||
{
|
{
|
||||||
storeItemLists[(int)category] = new GUIListBox(new Rectangle(0, 0, sellColumnWidth, 400), Color.White * 0.7f, Alignment.TopRight, GUI.Style, bottomPanel[(int)PanelTab.Store]);
|
var items = MapEntityPrefab.list.FindAll(ep => ep.Price>0.0f && ep.Category == category);
|
||||||
storeItemLists[(int)category].OnSelected = SelectItem;
|
if (!items.Any()) continue;
|
||||||
storeItemLists[(int)category].UserData = category;
|
|
||||||
bottomPanel[(int)PanelTab.Store].RemoveChild(storeItemLists[(int)category]);
|
|
||||||
|
|
||||||
foreach (MapEntityPrefab ep in MapEntityPrefab.list)
|
var categoryButton = new GUIButton(new Rectangle(x, 0, 100, 20), category.ToString(), GUI.Style, bottomPanel[(int)PanelTab.Store]);
|
||||||
{
|
categoryButton.UserData = category;
|
||||||
if (ep.Price == 0 || ep.Category != category) continue;
|
categoryButton.OnClicked = SelectItemCategory;
|
||||||
|
x += 110;
|
||||||
|
|
||||||
CreateItemFrame(ep, storeItemLists[(int)category]);
|
storeItemList = new GUIListBox(new Rectangle(0, 30, sellColumnWidth, 400), Color.White * 0.7f, Alignment.TopRight, GUI.Style, bottomPanel[(int)PanelTab.Store]);
|
||||||
}
|
storeItemList.OnSelected = SelectItem;
|
||||||
|
storeItemList.UserData = category;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SelectItemCategory(null, MapEntityCategory.Item);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Select()
|
public override void Select()
|
||||||
@@ -427,10 +428,22 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
|
|
||||||
if (!(selection is MapEntityCategory)) return false;
|
if (!(selection is MapEntityCategory)) return false;
|
||||||
var existingList = bottomPanel[(int)PanelTab.Store].children.Find(c => c.UserData is MapEntityCategory);
|
//var existingList = bottomPanel[(int)PanelTab.Store].children.Find(c => c is GUIListBox && c.UserData is MapEntityCategory);
|
||||||
if (existingList != null) bottomPanel[(int)PanelTab.Store].RemoveChild(existingList);
|
//if (existingList != null) bottomPanel[(int)PanelTab.Store].RemoveChild(existingList);
|
||||||
|
|
||||||
bottomPanel[(int)PanelTab.Store].AddChild(storeItemLists[(int)selection]);
|
//bottomPanel[(int)PanelTab.Store].AddChild(storeItemLists[(int)selection]);
|
||||||
|
|
||||||
|
storeItemList.ClearChildren();
|
||||||
|
|
||||||
|
MapEntityCategory category = (MapEntityCategory)selection;
|
||||||
|
var items = MapEntityPrefab.list.FindAll(ep => ep.Price > 0.0f && ep.Category == category);
|
||||||
|
|
||||||
|
foreach (MapEntityPrefab ep in items)
|
||||||
|
{
|
||||||
|
CreateItemFrame(ep, storeItemList);
|
||||||
|
}
|
||||||
|
|
||||||
|
storeItemList.children.Sort((x, y) => (x.UserData as MapEntityPrefab).Name.CompareTo((y.UserData as MapEntityPrefab).Name));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user