public InventoryForm(LevelInfo info) : base(true) { ItemQuantityFont = Assets.Level.Fonts.InventoryItem; try { CurrentlySelectedTile = info.Inventory.First(kvp => kvp.Value != 0).Key; } catch (InvalidOperationException) { CurrentlySelectedTile = null; } var invButtonWidth = Assets.Level.Images.InventoryButton.Width + INVENTORY_BUTTON_X_GAP; var invButtonHeight = Assets.Level.Images.InventoryButton.Height + INVENTORY_BUTTON_Y_GAP; var inv_h = invButtonHeight * LevelInfo.InventoryTileOrder[0].Length; var y = (DisplayManager.WindowResolution.Height - inv_h - invButtonHeight) / 2; var inv_w = invButtonWidth * LevelInfo.InventoryTileOrder.Length; var x = (DisplayManager.WindowResolution.Width + Assets.Level.Images.EmptyTile.Width * info.BoardDimensions.X + LevelInfo.BOARD_INVENTORY_GAP) / 2f - invButtonWidth + INVENTORY_BUTTON_X_GAP; int i = 0, j = 0; foreach (var column in LevelInfo.InventoryTileOrder) { foreach (var tileType in column) { if (info.InactiveInventory.Contains(tileType)) { continue; } var position = new Vector2( x + i * invButtonWidth, y + j * invButtonHeight); var button = new InventoryButtonForm(tileType, position, info.Inventory[tileType]); InventoryButtons.Add(tileType, button); j++; } i++; j = 0; } }
public override void Construct(MultiformTransmissionData args) { // Reinitialize variables that may have been carried over from the last // time the multiform was loaded. TimeOfMessagesCopied = -1; ResetTime(); WarningMessages.Clear(); RegisteredTextForms.Clear(); LevelNameInfo = args.GetAttr<LevelNameInfo>("LevelNameInfo"); LevelInfo = new LevelInfo(LevelNameInfo.LevelName); FatalError = LevelInfo.Exception != null; if (FatalError) { ErrorMessage = LevelInfo.Exception.Message; } if (LevelInfo != null && LevelInfo.WarningMessages.Count > 0) { WarningMessages.AddRange(LevelInfo.WarningMessages); } TransmissionData = new MultiformTransmissionData(MultiformName); TransmissionData.SetAttr<LevelNameInfo>("LevelNameInfo", LevelNameInfo); TransmissionData.SetAttr<LevelInfo>("LevelInfo", LevelInfo); ConstructMessageForms(); SetUpdater(Update_Main); SetRenderer(Render_Main); }