Improved node placement in research screen
This commit is contained in:
@@ -28,16 +28,22 @@ public partial class ResearchList : PanelContainer
|
|||||||
|
|
||||||
private GraphNode CreateItemNode(string id, string texturePath)
|
private GraphNode CreateItemNode(string id, string texturePath)
|
||||||
{
|
{
|
||||||
|
Vector2 viewportSize = GetViewport().GetVisibleRect().Size;
|
||||||
TextureRect icon = new TextureRect
|
TextureRect icon = new TextureRect
|
||||||
{
|
{
|
||||||
Texture = GD.Load<Texture2D>(texturePath),
|
Texture = GD.Load<Texture2D>(texturePath),
|
||||||
StretchMode = TextureRect.StretchModeEnum.KeepAspectCentered
|
StretchMode = TextureRect.StretchModeEnum.KeepAspectCentered
|
||||||
};
|
};
|
||||||
|
//Step 1: Place the node in the visible field for the player
|
||||||
|
Vector2 nodePosition = new Vector2(viewportSize.X / 32, viewportSize.Y / 4);
|
||||||
|
//Step 2: Modify position by nodeIndex
|
||||||
|
nodePosition = nodePosition + new Vector2(GameData.availableResearch.Count * -icon.Texture.GetWidth() + researchGraph.GetChildCount() * icon.Texture.GetWidth() * 10, 0);
|
||||||
|
|
||||||
GraphNode node = new GraphNode
|
GraphNode node = new GraphNode
|
||||||
{
|
{
|
||||||
Name = id,
|
Name = id,
|
||||||
Title = id,
|
Title = id,
|
||||||
PositionOffset = new Vector2(GameData.availableResearch.Count * -icon.Texture.GetWidth() + researchGraph.GetChildCount() * icon.Texture.GetWidth() * 10, 0)
|
PositionOffset = nodePosition
|
||||||
};
|
};
|
||||||
|
|
||||||
node.SetSlot(
|
node.SetSlot(
|
||||||
|
|||||||
Reference in New Issue
Block a user