コード例 #1
0
ファイル: GUI_CargoItem.cs プロジェクト: Zeropol/unitystation
        public void ReInit()
        {
            category = null;
            if (order == null)
            {
                Logger.Log("CargoItem: no order found, not doing init", Category.Cargo);
                return;
            }
            foreach (var element in Elements)
            {
                string nameBeforeIndex = element.name.Split('~')[0];
                switch (nameBeforeIndex)
                {
                case "SupplyName":
                    ((NetUIElement <string>)element).SetValueServer(order.OrderName);
                    break;

                case "Price":
                    ((NetUIElement <string>)element).SetValueServer(order.CreditCost + " credits");
                    break;

                case "CartName":
                    ((NetUIElement <string>)element).SetValueServer(order.OrderName + "\n" + order.CreditCost + " credits");
                    break;

                case "Cancel":
                    ((NetUIElement <string>)element).SetValueServer("CANCEL");
                    break;
                }
            }
        }
コード例 #2
0
        private void CargoItemValidation(MSD1 localMSD1, CargoCategory currentCargoCategory, CargoGroup currentCargoGroup)
        {
            ManualModelValidation(localMSD1);

            CargoCategoryHardValidations(localMSD1, currentCargoCategory);
            bool selectedCategory12 = currentCargoCategory.CategoryCode == (int)PortCategory.CrudeOilCode;
            bool selectedCategory13 = currentCargoCategory.CategoryCode == (int)PortCategory.OilProductsCode;

            bool isValidCategory = _cargoPortValidateService.IsValidPortForCategory(currentCargoCategory.CategoryCode, localMSD1.ReportingPort, localMSD1.AssociatedPort, localMSD1.IsInbound);

            if (!isValidCategory)
            {
                if (selectedCategory12)
                {
                    ModelState.AddModelError("CargoItem.Category", $"Crude Oil cannot be carried through " + localMSD1.ReportingPort);
                }
                if (selectedCategory13)
                {
                    var portName = (localMSD1.IsInbound == true ? localMSD1.AssociatedPort : localMSD1.ReportingPort);
                    ModelState.AddModelError("CargoItem.Category", $"Oil Products cannot be carried through " + portName);
                }
            }

            bool isValidCategoryVessel = _cargoPortValidateService.IsValidVesselCargo(currentCargoCategory.CategoryCode, localMSD1.Imo);

            if (!isValidCategoryVessel)
            {
                ModelState.AddModelError("CargoItem.Category", $"Category '" + currentCargoCategory.Description + "' is not valid for the vessel '" + localMSD1.Imo + "-" + localMSD1.ShipName + "'");
            }
        }
コード例 #3
0
        private void CargoCategoryHardValidations(MSD1 localMSD1, CargoCategory currentCargoCategory)
        {
            bool isvalid = _cargoPortValidateService.IsValidCategoryForPort(CargoItem.Category, localMSD1.AssociatedPort);

            if (!isvalid)
            {
                ModelState.AddModelError("CargoItem.Category", $" Cargo Category cannot be carried through " + "'" + localMSD1.AssociatedPort + "'");
            }

            var(allowedTonnage, avgWeightPerUnit, isTonnageExceeded, IsUnitsWithCargoZero) = _cargoPortValidateService.HasTonnagePerUnitExceeded(currentCargoCategory.CategoryCode, CargoItem.TotalUnits, CargoItem.UnitsWithCargo, CargoItem.UnitsWithoutCargo, CargoItem.GrossWeight);
            if (isTonnageExceeded)
            {
                ModelState.AddModelError("CargoItem.GrossWeight", $" Average gross weight entered '" + avgWeightPerUnit + " tonnes' per unit has exceeded maximum permitted '" + allowedTonnage + " tonnes' for Cargo Category: " + "'" + CargoItem.Category + "'");
            }
            if (!IsUnitsWithCargoZero)
            {
                ModelState.AddModelError("CargoItem.", $" The number of units without cargo must be '0' for selected " + CargoItem.Category);
            }

            bool RequiredCargoDescription = _cargoPortValidateService.IsMandatoryCargoDescription(currentCargoCategory.CategoryCode);

            if (RequiredCargoDescription && CargoItem.Description == null)
            {
                ModelState.AddModelError("CargoItem.Description", $"The Cargo description is required");
            }
        }
コード例 #4
0
ファイル: GUI_CargoItem.cs プロジェクト: Zeropol/unitystation
        public void ReInit(CargoCategory _category)
        {
            category = _category;
            foreach (var element in Elements)
            {
                string nameBeforeIndex = element.name.Split('~')[0];
                switch (nameBeforeIndex)
                {
                case "SupplyName":
                    ((NetUIElement <string>)element).SetValueServer(category.CategoryName);
                    break;

                case "Price":
                    ((NetUIElement <string>)element).SetValueServer("ENTER");
                    break;
                }
            }
        }
コード例 #5
0
        private string BuildTextInputDisplayDriver(CargoCategory x, bool Unitised)
        {
            string result = string.Empty;

            if (Unitised)
            {
                if (x.TakesCargo)
                {
                    result = CargoConfigure;
                }
                else
                {
                    result = NoCargoConfigure;
                }
            }

            if (x.HasWeight)
            {
                result += WeightConfigure;
            }

            return(result);
        }
コード例 #6
0
 public void SetValues(CargoCategory newCategory)
 {
     category = newCategory;
     CategoryName.SetValueServer(category.CategoryName);
 }
コード例 #7
0
ファイル: Cargo.cs プロジェクト: killergege/OpenTTDTool
        public static List<CargoCategory> ReadCargoTypes(CargoCategory bitmask)
        {
            var types = new List<CargoCategory>();

            foreach (CargoCategory type in Enum.GetValues(typeof(CargoCategory)))
            {
                if (bitmask.HasFlag(type))
                {
                    types.Add(type);
                }
            }

            return types;
        }