#region Copyright /* -------------------------------------------------------------------------------- This source file is part of Xenocide by Project Xenocide Team For the latest info on Xenocide, see http://www.projectxenocide.com/ This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/2.5/ or send a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA. -------------------------------------------------------------------------------- */ /* * @file ShowTransfersScreen.cs * @date Created: 2007/09/23 * @author File creator: David Teviotdale * @author Credits: none */ #endregion #region Using Statements using System; using System.Collections.Generic; using System.Text; using CeGui; using ProjectXenocide.Utils; using ProjectXenocide.Model.Geoscape; using ProjectXenocide.Model.Geoscape.Outposts; using ProjectXenocide.Model.StaticData.Items; using Xenocide.Resources; #endregion namespace ProjectXenocide.UI.Screens { /// /// This is the screen that shows the shipments currently on their way to an outpost /// public class ShowTransfersScreen : Screen { /// /// Constructor (obviously) /// /// index specifying the outpost who's shipments will be shown public ShowTransfersScreen(int selectedOutpostIndex) : base("ShowTransfers") { this.selectedOutpostIndex = selectedOutpostIndex; } #region Create the CeGui widgets /// /// add the buttons to the screen /// protected override void CreateCeguiWidgets() { // The grid of items being shiped to this outpost InitializeGrid(); PopulateGrid(); // buttons closeButton = AddButton("BUTTON_CLOSE", 0.7475f, 0.95f, 0.2275f, 0.04125f); closeButton.Clicked += new CeGui.GuiEventHandler(OnCloseButton); } private CeGui.Widgets.MultiColumnList grid; private CeGui.Widgets.PushButton closeButton; /// /// Create MultiColumnListBox which holds items being shiped /// private void InitializeGrid() { grid = AddGrid(0.01f, 0.01f, 0.73f, 0.98f, Strings.SCREEN_SHOW_TRANSFERS_COLUMN_ITEM, 0.69f, Strings.SCREEN_SHOW_TRANSFERS_COLUMN_QUANTITY, 0.15f, Strings.SCREEN_SHOW_TRANSFERS_COLUMN_ETA, 0.15f ); } /// /// Put the list of items being shiped into the grid /// private void PopulateGrid() { foreach (Shipment shipment in SelectedOutpost.Inventory.Shipments) { foreach (Shipment.ManifestLine line in shipment.Manifest) { AddRowToGrid(line, (int)shipment.Eta.TotalHours); } } } /// /// Add a row to the grid /// /// item in shipment /// hours before shipment arrives private void AddRowToGrid(Shipment.ManifestLine line, int hours) { // add item to grid int rowNum = grid.AddRow(Util.CreateListboxItem(line.Label), 0); Util.AddNumericElementToGrid(grid, 1, rowNum, line.Quantity); Util.AddNumericElementToGrid(grid, 2, rowNum, hours); } #endregion Create the CeGui widgets #region event handlers /// React to user pressing the Close button /// Not used /// Not used private void OnCloseButton(object sender, CeGui.GuiEventArgs e) { GoToBaseInfoScreen(); } #endregion event handlers /// /// Close this screen and go back to the BaseInfo Screen for this outpost /// private void GoToBaseInfoScreen() { ScreenManager.ScheduleScreen(new BaseInfoScreen(selectedOutpostIndex)); } #region Fields /// /// The outpost who's shipments will be shown /// private Outpost SelectedOutpost { get { return Xenocide.GameState.GeoData.Outposts[selectedOutpostIndex]; } } // index specifying the outpost who's shipments will be shown private int selectedOutpostIndex; #endregion Fields } }