From d8da3700260aabb5c85f8b1027c2c6e85b443a4d Mon Sep 17 00:00:00 2001 From: Damien Ostler Date: Fri, 12 Jan 2024 00:01:16 -0500 Subject: [PATCH] chore: changed the inventory controller so it populated all of the inventory model fields --- Code/Grid/InventoryModel.cs | 14 ++++++++------ Code/InventoryController.cs | 7 ++++++- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/Code/Grid/InventoryModel.cs b/Code/Grid/InventoryModel.cs index ed8a410..1cc8d3b 100644 --- a/Code/Grid/InventoryModel.cs +++ b/Code/Grid/InventoryModel.cs @@ -1,18 +1,20 @@ using System.Collections.Generic; using System.Linq; using Godot; +using GodotGridInventory.Code.UI; namespace GodotGridInventory.Code.Grid; + +#nullable enable public class InventoryModel { - public int Id { get; set; } - public string Name { get; set; } + public int Id { get; init; } + public string Name { get; init; } = string.Empty; public int GridWidth { get; set; } public int GridHeight { get; set; } - - public List Items { get; set; } - + public List Items { get; set; } = new List(); public List Cells { get; set; } = new List(); - public InventoryGrid? Grid { get; set; } + public InventoryGrid? Grid { get; set; } = null; + public InventoryGridInterface? GridInterface { get; set; } = null; public bool Open { get; set; } = false; } \ No newline at end of file diff --git a/Code/InventoryController.cs b/Code/InventoryController.cs index fb7e179..eeb881d 100644 --- a/Code/InventoryController.cs +++ b/Code/InventoryController.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Linq; using Godot; @@ -58,7 +59,11 @@ public partial class InventoryController : Node Name = name, Items = items.Select( item=> _itemDatabase.GetItemConfiguration(item)).ToList(), Cells = inventoryGrid.GridCells, - Open = false + Open = false, + Grid = inventoryGrid, + GridInterface = null, + GridWidth = (int)Math.Round(size.X), + GridHeight = (int)Math.Round(size.Y) }); _inventoryIdCounter++;