public override void OnUpdate(float realTimeDelta, float simulationTimeDelta)
        {
            if (Event.current.alt && Input.GetKeyDown(KeyCode.T))
            {
                var manager = Singleton <InfoManager> .instance;
                UIView.playSoundDelegate(UIView.GetAView().defaultClickSound, 1f);

                if (manager.CurrentMode != InfoManager.InfoMode.TerrainHeight)
                {
                    BuildingTool currentTool = ToolsModifierControl.GetCurrentTool <BuildingTool>();
                    if (currentTool != null && currentTool.m_relocate != 0)
                    {
                        currentTool.CancelRelocate();
                    }
                    Singleton <InfoViewsPanel> .instance.CloseToolbar();

                    WorldInfoPanel.HideAllWorldInfoPanels();
                    if (Singleton <InfoManager> .exists)
                    {
                        m_previousMode        = manager.CurrentMode;
                        m_previousSubInfoMode = manager.CurrentSubMode;
                        Singleton <InfoManager> .instance.SetCurrentMode(InfoManager.InfoMode.TerrainHeight, InfoManager.SubInfoMode.Default);

                        Singleton <GuideManager> .instance.InfoViewUsed();
                    }
                }
                else
                {
                    Singleton <InfoViewsPanel> .instance.CloseToolbar();

                    manager.SetCurrentMode(m_previousMode, m_previousSubInfoMode);
                    Singleton <GuideManager> .instance.InfoViewUsed();
                }
            }
        }
Beispiel #2
0
        public override void Start()
        {
            base.Start();

            isVisible     = true;
            canFocus      = true;
            isInteractive = true;
            width         = 740f;
            height        = 40f;

            m_name = UIUtils.CreateLabel(this, 300f, height);
            m_name.textAlignment    = UIHorizontalAlignment.Left;
            m_name.pivot            = UIPivotPoint.MiddleLeft;
            m_name.relativePosition = new Vector3(10f, 0f);
            statusLabel             = UIUtils.CreateLabelForGrid(this, m_name, 190f, height);
            m_triangles             = UIUtils.CreateLabelForGrid(this, statusLabel, 150f, height);
            m_textureSize           = UIUtils.CreateLabelForGrid(this, m_triangles, 90f, height);

            eventMouseEnter += (component, eventParam) => Background.opacity = Mathf.Lerp(baseBgOpacity, 1, 0.5f);
            eventMouseLeave += (component, eventParam) => Background.opacity = baseBgOpacity;
            eventClick      += (component, p) =>
            {
                Background.opacity = Mathf.Lerp(baseBgOpacity, 1, 0.75f);
                WorldInfoPanel.Show <CityServiceWorldInfoPanel>(m_meshData.position, m_meshData.instanceID);
                ToolsModifierControl.cameraController.SetTarget(m_meshData.instanceID, m_meshData.position, true);
            };
        }
Beispiel #3
0
        /// <summary>
        /// ToolsModifierControl.SetTool
        /// But instead of searching the tool in ToolsModifierControl.m_Tools,
        /// this method uses ToolsModifierControl.toolController.gameObject.GetComponent<T>
        /// </summary>
        public static T SetTool <T>()
            where T : ToolBase
        {
            var toolController = ToolsModifierControl.toolController;

            if (toolController == null)
            {
                return(null);
            }
            var tool = toolController.GetComponent <T>();

            if (tool == null)
            {
                return(null);
            }

            if (!ToolsModifierControl.keepThisWorldInfoPanel)
            {
                WorldInfoPanel.HideAllWorldInfoPanels();
            }
            GameAreaInfoPanel.Hide();
            ToolsModifierControl.keepThisWorldInfoPanel = false;
            if (toolController.CurrentTool != tool)
            {
                toolController.CurrentTool = tool;
            }
            return(tool);
        }
Beispiel #4
0
 private void EnableTool()
 {
     Log("EnableTool: called");
     WorldInfoPanel.HideAllWorldInfoPanels();
     GameAreaInfoPanel.Hide();
     ToolsModifierControl.toolController.CurrentTool = this;
 }
 public static void small_OnCheckChanged(UIComponent UIComp, bool bValue)
 {
     MainDataStore.lastBuilding = WorldInfoPanel.GetCurrentInstanceID().Building;
     if (bValue)
     {
         MainDataStore.resourceCategory[MainDataStore.lastBuilding] = 2;
         small.isChecked = true;
         heavy.isChecked = false;
         both.isChecked  = false;
     }
     else
     {
         if (MainDataStore.resourceCategory[MainDataStore.lastBuilding] == 0)
         {
             both.isChecked  = true;
             small.isChecked = false;
             heavy.isChecked = false;
         }
         else if (MainDataStore.resourceCategory[MainDataStore.lastBuilding] == 1)
         {
             both.isChecked  = false;
             small.isChecked = false;
             heavy.isChecked = true;
         }
         else if (MainDataStore.resourceCategory[MainDataStore.lastBuilding] == 2)
         {
             both.isChecked  = false;
             small.isChecked = true;
             heavy.isChecked = false;
         }
     }
 }
Beispiel #6
0
        private void RefreshDisplayData()
        {
            if (refeshOnce || (CitizenData.lastCitizenID != WorldInfoPanel.GetCurrentInstanceID().Citizen))
            {
                if (isVisible)
                {
                    CitizenData.lastCitizenID = WorldInfoPanel.GetCurrentInstanceID().Citizen;
                    CitizenManager  instance3    = Singleton <CitizenManager> .instance;
                    ushort          homeBuilding = instance3.m_citizens.m_buffer[(int)((UIntPtr)CitizenData.lastCitizenID)].m_homeBuilding;
                    BuildingManager instance2    = Singleton <BuildingManager> .instance;
                    uint            homeId       = instance3.m_citizens.m_buffer[CitizenData.lastCitizenID].GetContainingUnit(CitizenData.lastCitizenID, instance2.m_buildings.m_buffer[homeBuilding].m_citizenUnits, CitizenUnit.Flags.Home);
                    familyMoney.text  = string.Format(Localization.Get("FAMILY_MONEY") + " [{0}]", CitizenUnitData.familyMoney[homeId]) + $"ID = ({homeId})";
                    citizenMoney.text = string.Format(Localization.Get("CITIZEN_MONEY") + " [{0}]", CitizenData.citizenMoney[CitizenData.lastCitizenID]);
                    familySalary.text = string.Format(Localization.Get("FAMILY_SALARY") + " [{0}]", CaculateFamilySalary(homeId).ToString());

                    if ((instance3.m_citizens.m_buffer[CitizenData.lastCitizenID].m_flags & Citizen.Flags.NeedGoods) != 0)
                    {
                        familyGoods.text = string.Format(Localization.Get("FAMILY_GOODS") + " [{0}] " + Localization.Get("FAMILY_NEED_GOODS"), (CitizenUnitData.familyGoods[homeId] / 10f).ToString()) + $"({instance3.m_units.m_buffer[homeId].m_goods})";
                    }
                    else
                    {
                        familyGoods.text = string.Format(Localization.Get("FAMILY_GOODS") + " [{0}]", (CitizenUnitData.familyGoods[homeId] / 10f).ToString()) + $"({instance3.m_units.m_buffer[homeId].m_goods})";
                    }

                    refeshOnce = false;
                }
            }
        }
Beispiel #7
0
        public void Show(Vector3 worldMousePosition, InstanceID instanceID)
        {
            this.m_WorldMousePosition = worldMousePosition;
            this.m_InstanceID         = instanceID;
            if (InstanceManager.IsValid(this.m_InstanceID))
            {
                WorldInfoPanel.HideAllWorldInfoPanels();
                NetManager instance      = Singleton <NetManager> .instance;
                ushort     transportLine = instance.m_nodes.m_buffer[(int)this.m_InstanceID.NetNode].m_transportLine;
                this.m_VehicleType.spriteName = PublicTransportWorldInfoPanel.GetVehicleTypeIcon(Singleton <TransportManager> .instance.m_lines.m_buffer[(int)transportLine].Info.m_transportType);
                this.m_StopIndex     = TransportLineMod.GetStopIndex(transportLine, this.m_InstanceID.NetNode);
                this.m_StopName.text = Singleton <InstanceManager> .instance.GetName(this.m_InstanceID) ?? string.Format(Localization.Get("STOP_LIST_BOX_ROW_STOP"), (object)(this.m_StopIndex + 1));

                this.m_SuggestedNames.ClearItems();
                this.m_SuggestedNames.AddItems(this.FindBuildings(instance.m_nodes.m_buffer[(int)this.m_InstanceID.NetNode].m_position), new Func <ushort, string>(this.IDToName));
                this.m_Line.text = Singleton <TransportManager> .instance.GetLineName(transportLine);

                this.Show();
                this.LateUpdate();
            }
            else
            {
                this.Hide();
            }
        }
Beispiel #8
0
        private void Update()
        {
            if (!WorldInfoPanel.AnyWorldInfoPanelOpen())
            {
                return;
            }

            InstanceID id = WorldInfoPanel.GetCurrentInstanceID();

            if (id.IsEmpty)
            {
                return;
            }

            if (id.Vehicle == 0)
            {
                foreach (UIButton button in _buttons)
                {
                    button.Hide();
                }
            }
            else
            {
                foreach (UIButton button in _buttons)
                {
                    button.Show();
                }
            }
        }
Beispiel #9
0
 static void Postfix(WorldInfoPanel __instance)
 {
     if (__instance is ZonedBuildingWorldInfoPanel)
     {
         Painter.instance.IsPanelVisible = false;
     }
 }
Beispiel #10
0
        private void RefreshDisplayData()
        {
            if (refeshOnce || (MainDataStore.lastBuildingID != WorldInfoPanel.GetCurrentInstanceID().Building))
            {
                if (base.isVisible)
                {
                    MainDataStore.lastBuildingID  = WorldInfoPanel.GetCurrentInstanceID().Building;
                    this.failedBuildingCount.text = Localization.Get("FAILED_BUILDING_COUNT") + ":" + MainDataStore.canNotConnectedBuildingIDCount[MainDataStore.lastBuildingID].ToString();
                    if (generateDetail.isChecked == true)
                    {
                        generateDetail.isChecked = false;
                    }
                    this.BringToFront();
                    localUse.isChecked = (Singleton <BuildingManager> .instance.m_buildings.m_buffer[MainDataStore.lastBuildingID].m_childHealth != 0);
                }
                refeshOnce = false;
                this.Show();
            }

            var  buildingAI          = Singleton <BuildingManager> .instance.m_buildings.m_buffer[MainDataStore.lastBuildingID].Info.m_buildingAI;
            bool isLocalUseAvailable = MoreEffectiveTransfer.localUse && ((buildingAI is LandfillSiteAI) || (buildingAI is PoliceStationAI) || (buildingAI is FireStationAI));

            if (!MoreEffectiveTransfer.debugMode && !isLocalUseAvailable)
            {
                this.Hide();
            }
        }
        public void openInfo(ushort buildingID)
        {
            WorldInfoPanel.HideAllWorldInfoPanels();

            var ssds = ServiceSystemDefinition.from(Singleton <BuildingManager> .instance.m_buildings.m_buffer[buildingID].Info);
            var ext  = ssds.First().GetTransportExtension();

            m_buildingIdSelecionado          = default(InstanceID);
            m_ignoreDistrict.isChecked       = ext.GetIgnoreDistrict(buildingID);
            m_buildingIdSelecionado.Building = buildingID;
            buildingNameField.text           = Singleton <BuildingManager> .instance.GetBuildingName(buildingID, default(InstanceID));


            var configIdx = ssds.First().toConfigIndex();


            String bgIcon = SVMConfigWarehouse.getIconServiceSystem(configIdx);
            String fgIcon = SVMConfigWarehouse.getFgIconServiceSystem(configIdx);

            buildingTypeIcon.normalFgSprite = bgIcon;
            buildingTypeIconFg.spriteName   = fgIcon;

            SVMController.instance.CloseSVMPanel();
            Show();
            EventOnBuildingSelChanged?.Invoke(buildingID);
        }
Beispiel #12
0
            public override void HandleClick(UIMouseEventParameter p)
            {
                InstanceID worldInfoPanelInstanceId = WorldInfoPanel.GetCurrentInstanceID();

                Log._Debug($"Current citizen: {worldInfoPanelInstanceId.Citizen}");

                if (worldInfoPanelInstanceId.Citizen != 0)
                {
                    ushort citizenInstanceId = worldInfoPanelInstanceId.Citizen.ToCitizen().m_instance;

                    Log._Debug(
                        $"Current citizen: {worldInfoPanelInstanceId.Citizen} Instance: {citizenInstanceId}");
                    if (citizenInstanceId != 0)
                    {
                        bool isTourist = citizenInstanceId.ToCitizenInstance().Info.m_citizenAI is TouristAI;
                        Singleton <SimulationManager> .instance.AddAction(
                            () => Singleton <CitizenManager> .instance.ReleaseCitizenInstance(citizenInstanceId));

                        // InfoPanel needs to be closed manually because method responsible for hiding it testing against type Citizen instead of CitizenInstance
                        // We are not removing Citizen but only instance
                        if (isTourist)
                        {
                            WorldInfoPanel.Hide <TouristWorldInfoPanel>();
                        }
                        else
                        {
                            WorldInfoPanel.Hide <CitizenWorldInfoPanel>();
                        }
                    }
                }
            }
        private void UpdateProgress()
        {
            VehicleManager instance     = Singleton <VehicleManager> .instance;
            ushort         vehicle      = WorldInfoPanel.GetCurrentInstanceID().Vehicle;
            ushort         firstVehicle = instance.m_vehicles.m_buffer[(int)vehicle].GetFirstVehicle(vehicle);
            float          current;
            float          max;

            if (GetProgressStatus(firstVehicle, ref instance.m_vehicles.m_buffer[(int)firstVehicle], out current, out max) || (int)firstVehicle != (int)(ushort)this._cachedProgressVehicle.GetValue((object)this._publicTransportVehicleWorldInfoPanel))
            {
                this._cachedCurrentProgress.SetValue((object)this._publicTransportVehicleWorldInfoPanel, (object)current);
                this._cachedTotalProgress.SetValue((object)this._publicTransportVehicleWorldInfoPanel, (object)max);
                this._cachedProgressVehicle.SetValue((object)this._publicTransportVehicleWorldInfoPanel, (object)firstVehicle);
            }
            else
            {
                current = (float)this._cachedCurrentProgress.GetValue((object)this._publicTransportVehicleWorldInfoPanel);
                max     = (float)this._cachedTotalProgress.GetValue((object)this._publicTransportVehicleWorldInfoPanel);
            }
            if ((double)max == 0.0)
            {
                return;
            }
            this._distanceTraveled.parent.Show();
            this._distanceProgress.parent.Show();
            float num = current / max;
            int   p   = Mathf.RoundToInt(num * 100f);

            this._distanceTraveled.value = num;
            this._distanceProgress.text  = LocaleFormatter.FormatPercentage(p);
        }
        private void RefreshDisplayData()
        {
            if (refeshOnce || (MainDataStore.lastBuildingID != WorldInfoPanel.GetCurrentInstanceID().Building))
            {
                if (base.isVisible)
                {
                    MainDataStore.lastBuildingID  = WorldInfoPanel.GetCurrentInstanceID().Building;
                    this.failedBuildingCount.text = Localization.Get("FAILED_BUILDING_COUNT") + ":" + MainDataStore.canNotConnectedBuildingIDCount[MainDataStore.lastBuildingID].ToString();
                    if (generateDetail.isChecked == true)
                    {
                        generateDetail.isChecked = false;
                    }
                    this.BringToFront();
                }
                refeshOnce = false;
                this.Show();
            }
            else
            {
                this.Hide();
            }

            if (!MoreEffectiveTransfer.debugMode)
            {
                this.Hide();
            }
        }
 public static void OnDeleteLinesClick()
 {
     if (!ImprovedPublicTransportMod.inGame)
     {
         return;
     }
     if (!OptionsWrapper <Settings> .Options.DeleteBusLines &&
         !OptionsWrapper <Settings> .Options.DeleteTramLines &&
         !OptionsWrapper <Settings> .Options.DeleteTrainLines &&
         !OptionsWrapper <Settings> .Options.DeleteMetroLines &&
         !OptionsWrapper <Settings> .Options.DeleteMonorailLines &&
         !OptionsWrapper <Settings> .Options.DeleteShipLines &&
         !OptionsWrapper <Settings> .Options.DeletePlaneLines)
     {
         return;
     }
     WorldInfoPanel.Hide <PublicTransportWorldInfoPanel>();
     ConfirmPanel.ShowModal(Localization.Get("SETTINGS_LINE_DELETION_TOOL_CONFIRM_TITLE"),
                            Localization.Get("SETTINGS_LINE_DELETION_TOOL_CONFIRM_MSG"), (s, r) =>
     {
         if (r != 1)
         {
             return;
         }
         Singleton <SimulationManager> .instance.AddAction(() =>
         {
             SimulationManager.instance.AddAction(DeleteLines);
         });
     });
 }
Beispiel #16
0
        private void AddDefaultBuildingPropertiesButton(WorldInfoPanel infoPanel, out UIButton button, Vector3 offset)
        {
            button = UiUtils.CreateToggleButton(infoPanel.component, offset, UIAlignAnchor.BottomLeft,
                                                (comp, e) =>
            {
                PanelType = InfoPanelType.Default;

                InstanceID instanceID = InstanceHelper.GetInstanceID(infoPanel);

                var building = BuildingManager.instance.m_buildings.m_buffer[instanceID.Building].Info;
                try
                {
                    if (CustomizeItExtendedPanel == null || building != CurrentSelectedBuilding)
                    {
                        CustomizeItExtendedPanel = building.GenerateCustomizeItExtendedPanel();
                    }
                    else
                    {
                        CustomizeItExtendedPanel.isVisible = false;
                        UiUtils.DeepDestroy(CustomizeItExtendedPanel);
                    }
                }
                catch (Exception ex)
                {
                    Debug.Log($"{ex.Message} - {ex.StackTrace}");
                }

                if (comp.hasFocus)
                {
                    comp.Unfocus();
                }
            });
        }
Beispiel #17
0
        private void AddBuildingInformationButton(WorldInfoPanel infoPanel, out UIButton button, Vector3 offset)
        {
            button = UiUtils.CreateToggleButton(ZoneBuildingPanel.component, offset, UIAlignAnchor.BottomLeft,
                                                (comp, e) =>
            {
                InstanceID instanceID = InstanceHelper.GetInstanceID(infoPanel);

                var building = BuildingManager.instance.m_buildings.m_buffer[instanceID.Building].Info;
                try
                {
                    if (ZonedBuildingPanelWrapper == null || building != CurrentSelectedBuilding)
                    {
                        ZonedBuildingPanelWrapper = building.GenerateBuildingInformation();
                    }
                    else
                    {
                        ZonedBuildingPanelWrapper.isVisible = false;
                        UiUtils.DeepDestroy(ZonedBuildingPanelWrapper);
                    }
                }
                catch (Exception ex)
                {
                    Debug.Log($"{ex.Message} - {ex.StackTrace}");
                }

                if (comp.hasFocus)
                {
                    comp.Unfocus();
                }
            });
        }
Beispiel #18
0
        public void openDepotInfo(ushort buildingID)
        {
            isLoading = true;
            WorldInfoPanel.HideAllWorldInfoPanels();

            m_buildingIdSelecionado          = default(InstanceID);
            m_buildingIdSelecionado.Building = buildingID;

            DepotAI depotAI = Singleton <BuildingManager> .instance.m_buildings.m_buffer[buildingID].Info.GetAI() as DepotAI;

            if (depotAI == null)
            {
                return;
            }
            depotNameField.text = Singleton <BuildingManager> .instance.GetBuildingName(buildingID, default(InstanceID));

            lineTransportIconTypeLabel.relativePosition = new Vector3(10f, 12f);
            lineTransportIconTypeLabel.height           = 20;
            lineTransportIconTypeLabel.backgroundSprite = PublicTransportWorldInfoPanel.GetVehicleTypeIcon(depotAI.m_transportInfo.m_transportType);

            Show();
            m_controller.defaultListingLinesPanel.Hide();

            updateCheckboxes();

            isLoading = false;
        }
Beispiel #19
0
        private void RefreshDisplayData()
        {
            if (refeshOnce || (BuildingData.lastBuildingID != WorldInfoPanel.GetCurrentInstanceID().Building))
            {
                if (isVisible)
                {
                    BuildingData.lastBuildingID = WorldInfoPanel.GetCurrentInstanceID().Building;
                    Building buildingData           = Singleton <BuildingManager> .instance.m_buildings.m_buffer[BuildingData.lastBuildingID];
                    int      aliveWorkCount         = 0;
                    int      totalWorkCount         = 0;
                    Citizen.BehaviourData behaviour = default;
                    RealCityCommonBuildingAI.InitDelegate();
                    RealCityCommonBuildingAI.GetWorkBehaviour((PlayerBuildingAI)buildingData.Info.m_buildingAI, BuildingData.lastBuildingID, ref buildingData, ref behaviour, ref aliveWorkCount, ref totalWorkCount);
                    int allWorkCount = RealCityResidentAI.TotalWorkCount(BuildingData.lastBuildingID, buildingData, true, false);
                    maintainFeeTips.text = Localization.Get("MAINTAIN_FEE_TIPS");
                    workerStatus.text    = Localization.Get("LOCAL_WORKERS_DIV_TOTAL_WORKERS") + totalWorkCount.ToString() + "/" + allWorkCount.ToString();

                    if (buildingData.Info.m_buildingAI is MarketAI)
                    {
                        fishAmount.text = Localization.Get("MATERIAL_BUFFER") + "/" + Localization.Get("PRODUCTION_BUFFER") + ":" + buildingData.m_customBuffer1.ToString() + "/" + buildingData.m_customBuffer2.ToString();
                        int aliveVisitCount = 0;
                        int totalVisitCount = 0;
                        RealCityMarketAI.InitDelegate();
                        RealCityMarketAI.GetVisitBehaviour((MarketAI)(buildingData.Info.m_buildingAI), BuildingData.lastBuildingID, ref buildingData, ref behaviour, ref aliveVisitCount, ref totalVisitCount);
                        var amount = buildingData.m_customBuffer2 / MainDataStore.maxGoodPurchase - totalVisitCount + aliveVisitCount;
                        fishVisitor.text = string.Format("FORDEBUG" + " [{0}/{1}/{2}]", aliveVisitCount, totalVisitCount, amount);
                    }
                    refeshOnce = false;
                }
                else
                {
                    Hide();
                }
            }
        }
            public override void HandleClick(UIMouseEventParameter p)
            {
                InstanceID instance = WorldInfoPanel.GetCurrentInstanceID();

                Log._Debug($"Current citizen: {instance.Citizen}");

                if (instance.Citizen != 0)
                {
                    ushort citizenInstanceId = 0;
                    Constants.ServiceFactory.CitizenService.ProcessCitizen(
                        instance.Citizen,
                        (uint citId, ref Citizen cit) => {
                        citizenInstanceId = cit.m_instance;
                        return(true);
                    });

                    Log._Debug(
                        $"Current citizen: {instance.Citizen} Instance: {citizenInstanceId}");
                    if (citizenInstanceId != 0)
                    {
                        Constants.ServiceFactory.SimulationService.AddAction(
                            () => Constants
                            .ServiceFactory.CitizenService
                            .ReleaseCitizenInstance(citizenInstanceId));
                    }
                }
            }
Beispiel #21
0
        private void Update()
        {
            if ((Singleton <SimulationManager> .instance.m_currentTickIndex & 15) == 15)
            {
                if (!WorldInfoPanel.AnyWorldInfoPanelOpen())
                {
                    return;
                }

                InstanceID id = WorldInfoPanel.GetCurrentInstanceID();

                if (id.IsEmpty)
                {
                    return;
                }

                if (id.Vehicle == 0 && id.ParkedVehicle == 0)
                {
                    foreach (UIButton button in _buttons)
                    {
                        button.Hide();
                    }
                }
                else
                {
                    foreach (UIButton button in _buttons)
                    {
                        button.Show();
                    }
                }
            }
        }
Beispiel #22
0
        public override void Update()
        {
            base.Update();

            var instanceId = WorldInfoPanel.GetCurrentInstanceID();

            if (instanceId.Type == InstanceType.Building && instanceId.Building != 0)
            {
                var buildingId = instanceId.Building;
                if (_selectedBuilding != buildingId)
                {
                    _selectedBuilding = buildingId;

                    var buildingAi = Singleton <BuildingManager> .instance.m_buildings.m_buffer[buildingId].Info.m_buildingAI;
                    if (buildingAi.CanBeEmptied() && (buildingAi is LandfillSiteAI || buildingAi is CemeteryAI))
                    {
                        this.isVisible = true;

                        var serviceData = BuildingDataManager.Data[buildingId];
                        _autoEmptyingCheckbox.Checked = serviceData.AutoEmptyingDisabled;
                        //_autoFillingCheckbox.Checked = serviceData.AutoFillingDisabled;
                    }
                    else
                    {
                        this.isVisible = false;
                    }
                }
            }
        }
        public void UpdateBuildingInfoPanel()
        {
            InstanceID instanceID = WorldInfoPanel.GetCurrentInstanceID();

            if (statsLabel != null)
            {
                CargoStats2 stats;
                if (instanceID.Building != 0 && mod.data.TryGetEntry(instanceID.Building, out stats))
                {
                    var sb        = new StringBuilder();
                    var timeScale = mod.Options.UseMonthlyValues? 1.0f: 0.25f;

                    var receivedAmount = Mathf.Ceil(Mathf.Max(stats.CarsReceived, stats.CarsReceivedLastTime) /
                                                    CargoData.TruckCapacity * timeScale);

                    var sentAmount = Mathf.Ceil(Mathf.Max(stats.CarsSent, stats.CarsSentLastTime) /
                                                CargoData.TruckCapacity * timeScale);

                    sb.AppendFormat(
                        "{0}: {1:0}",
                        Localization.Get(mod.Options.UseMonthlyValues ? "TRUCKS_RCVD_LAST_MONTH": "TRUCKS_RCVD_LAST_WEEK"),
                        receivedAmount);
                    sb.AppendLine();
                    sb.AppendFormat(
                        "{0}: {1:0}",
                        Localization.Get(mod.Options.UseMonthlyValues ? "TRUCKS_SENT_LAST_MONTH" : "TRUCKS_SENT_LAST_WEEK"),
                        sentAmount);
                    sb.AppendLine();
                    sb.Append(Localization.Get("CLICK_MORE"));
                    statsLabel.text = sb.ToString();
                }
            }
        }
        /// <summary>
        /// Adds button to access building details from building info panels.
        /// </summary>
        internal static void AddInfoPanelButton()
        {
            // Zoned building panel - get parent panel and add button.
            ZonedBuildingWorldInfoPanel infoPanel = UIView.library.Get <ZonedBuildingWorldInfoPanel>(typeof(ZonedBuildingWorldInfoPanel).Name);

            zonedButton             = UIControls.AddButton(infoPanel.component, infoPanel.component.width - 133f - 10, 120, Translations.Translate("RPR_REALPOP"), 133f, 19.5f, 0.65f);
            zonedButton.textPadding = new RectOffset(2, 2, 4, 0);

            // Just in case other mods are interfering.
            zonedButton.Enable();

            // Event handler.
            zonedButton.eventClick += (control, clickEvent) =>
            {
                // Select current building in the building details panel and show.
                Open(InstanceManager.GetPrefabInfo(WorldInfoPanel.GetCurrentInstanceID()) as BuildingInfo);
            };

            // Service building panel - get parent panel and add button.
            CityServiceWorldInfoPanel servicePanel = UIView.library.Get <CityServiceWorldInfoPanel>(typeof(CityServiceWorldInfoPanel).Name);

            serviceButton             = UIControls.AddButton(servicePanel.component, servicePanel.component.width - 133f - 10, 120, Translations.Translate("RPR_REALPOP"), 133f, 19.5f, 0.65f);
            serviceButton.textPadding = new RectOffset(2, 2, 4, 0);

            // Event handler.
            serviceButton.eventClick += (control, clickEvent) =>
            {
                // Select current building in the building details panel and show.
                Open(InstanceManager.GetPrefabInfo(WorldInfoPanel.GetCurrentInstanceID()) as BuildingInfo);
            };
        }
Beispiel #25
0
 public static void OnBudgetClicked()
 {
     if (ToolsModifierControl.IsUnlocked(UnlockManager.Feature.Economy))
     {
         ToolsModifierControl.mainToolbar.ShowEconomyPanel(1);
         WorldInfoPanel.Hide <PublicTransportWorldInfoPanel>();
     }
 }
        /// <summary>
        /// Adds a Ploppable RICO button to a building info panel to directly access that building's RICO settings.
        /// The button will be added to the right of the panel with a small margin from the panel edge, at the relative Y position specified.
        /// </summary>
        /// <param name="infoPanel">Infopanel to apply the button to</param>
        private static void AddInfoPanelButton(BuildingWorldInfoPanel infoPanel)
        {
            UIButton panelButton = infoPanel.component.AddUIComponent <UIButton>();

            // Basic button setup.
            panelButton.size             = new Vector2(34, 34);
            panelButton.normalBgSprite   = "ToolbarIconGroup6Normal";
            panelButton.normalFgSprite   = "IconPolicyBigBusiness";
            panelButton.focusedBgSprite  = "ToolbarIconGroup6Focused";
            panelButton.hoveredBgSprite  = "ToolbarIconGroup6Hovered";
            panelButton.pressedBgSprite  = "ToolbarIconGroup6Pressed";
            panelButton.disabledBgSprite = "ToolbarIconGroup6Disabled";
            panelButton.name             = "PloppableButton";
            panelButton.tooltip          = Translations.Translate("PRR_SET_RICO");

            // Find ProblemsPanel relative position to position button.
            // We'll use 40f as a default relative Y in case something doesn't work.
            UIComponent problemsPanel;
            float       relativeY = 40f;

            // Player info panels have wrappers, zoned ones don't.
            UIComponent wrapper = infoPanel.Find("Wrapper");

            if (wrapper == null)
            {
                problemsPanel = infoPanel.Find("ProblemsPanel");
            }
            else
            {
                problemsPanel = wrapper.Find("ProblemsPanel");
            }

            try
            {
                // Position button vertically in the middle of the problems panel.  If wrapper panel exists, we need to add its offset as well.
                relativeY = (wrapper == null ? 0 : wrapper.relativePosition.y) + problemsPanel.relativePosition.y + ((problemsPanel.height - 34) / 2);
            }
            catch
            {
                // Don't really care; just use default relative Y.
                Logging.Message("couldn't find ProblemsPanel relative position");
            }

            // Set position.
            panelButton.AlignTo(infoPanel.component, UIAlignAnchor.TopRight);
            panelButton.relativePosition += new Vector3(-5f, relativeY, 0f);

            // Event handler.
            panelButton.eventClick += (control, clickEvent) =>
            {
                // Select current building in the building details panel and show.
                Open(InstanceManager.GetPrefabInfo(WorldInfoPanel.GetCurrentInstanceID()) as BuildingInfo);

                // Manually unfocus control, otherwise it can stay focused until next UI event (looks untidy).
                control.Unfocus();
            };
        }
        private void UpdateVehicleInfoPanel()
        {
            var vehicleID = WorldInfoPanel.GetCurrentInstanceID().Vehicle;

            if (vehicleID != 0 && vehicleCargoChart != null)
            {
                int guard = 0;

                // Find leading vehicle that actually has all the cargo
                while (VehicleManager.instance.m_vehicles.m_buffer[vehicleID].m_leadingVehicle != 0)
                {
                    guard++;
                    vehicleID = VehicleManager.instance.m_vehicles.m_buffer[vehicleID].m_leadingVehicle;
                    if (guard > ushort.MaxValue)
                    {
                        Debug.LogError("Invalid list detected!");
                        return;
                    }
                }

                var ai = VehicleManager.instance.m_vehicles.m_buffer[vehicleID].Info.m_vehicleAI;
                if (ai is CargoTrainAI || ai is CargoShipAI)
                {
                    var cargo  = VehicleManager.instance.m_vehicles.m_buffer[vehicleID].m_firstCargo;
                    var result = new float[CargoParcel.ResourceTypes.Length];
                    guard = 0;
                    while (cargo != 0)
                    {
                        var parcel = new CargoParcel(0, false,
                                                     VehicleManager.instance.m_vehicles.m_buffer[cargo].m_transferType,
                                                     VehicleManager.instance.m_vehicles.m_buffer[cargo].m_transferSize,
                                                     VehicleManager.instance.m_vehicles.m_buffer[cargo].m_flags);
                        result[parcel.ResourceType] += parcel.transferSize;
                        cargo = VehicleManager.instance.m_vehicles.m_buffer[cargo].m_nextCargo;
                        guard++;
                        if (guard > ushort.MaxValue)
                        {
                            Debug.LogError("Invalid list detected!");
                            return;
                        }
                    }
                    var total = result.Sum();
                    Debug.Log(string.Join(", ", result.Select(v => v / total).Select(f => f.ToString()).ToArray()));
                    vehicleCargoChart.isVisible = true;
                    vehicleCargoChart.tooltip   = string.Format("{0:0}{1}", total / 1000, Localization.Get("KILO_UNITS"));
                    if (Math.Abs(total) < 1f)
                    {
                        total = 1f;
                    }
                    vehicleCargoChart.SetValues(result.Select(v => v / total).ToArray());
                }
                else
                {
                    vehicleCargoChart.isVisible = false;
                }
            }
        }
        private UIButton AddRemoveCitizenInstanceButton(WorldInfoPanel panel, string cimInstanceType)
        {
            UIButton button = new GameObject($"Remove{cimInstanceType}InstanceButton")
                              .AddComponent <RemoveCitizenInstanceButton>();

            button.AlignTo(panel.component, UIAlignAnchor.TopRight);
            button.relativePosition += new Vector3(-button.width - 80f, 50f);
            return(button);
        }
Beispiel #29
0
        protected UIButton AddRemoveVehicleButton(WorldInfoPanel panel)
        {
            UIButton button = UIView.GetAView().AddUIComponent(typeof(RemoveVehicleButton)) as RemoveVehicleButton;

            button.AlignTo(panel.component, UIAlignAnchor.TopRight);
            button.relativePosition += new Vector3(-button.width - 40f, 50f);

            return(button);
        }
Beispiel #30
0
        private void SetupUIBindings()
        {
#if DEBUG
            Debug.Log("Setting up UI...");
#endif
            cargoPanel = (CargoUIPanel)UIView.GetAView().AddUIComponent(typeof(CargoUIPanel));

            var servicePanel = UIHelper.GetPanel("(Library) CityServiceWorldInfoPanel");
            //var statsPanel = servicePanel?.Find<UIPanel>("DescPanel");
            //statsLabel = statsPanel?.Find<UILabel>("Desc");
            statsLabel = servicePanel?.Find <UILabel>("Desc");
            rightPanel = servicePanel?.Find <UIPanel>("Right");
            if (servicePanel == null)
            {
                Debug.LogError("CityServiceWorldInfoPanel not found");
            }
            //if (statsPanel == null)
            //    Debug.LogError("DescPanel not found");
            //if (statsLabel == null)
            if (rightPanel == null)
            {
                //Debug.LogError("DescPanel.Desc label not found");
                Debug.LogError("ServicePanel.Right panel not found");
            }
            else
            {
                //Debug.Log("Service stats label found!");
#if DEBUG
                Debug.Log("ServicePanel.Right panel found!");
#endif
                showDelegate = (sender, e) =>
                {
                    if (mod.data.TryGetEntry(WorldInfoPanel.GetCurrentInstanceID().Building, out _))
                    {
                        cargoPanel.Show();
                    }
                };

                //statsLabel.eventClicked += showDelegate;
                rightPanel.eventClicked += showDelegate;
            }

            var vehicleMainPanel = UIHelper.GetPanel("(Library) CityServiceVehicleWorldInfoPanel");
            var vehiclePanel     = vehicleMainPanel.Find <UIPanel>("Panel");
            if (vehiclePanel != null)
            {
                vehiclePanel.autoLayout            = false;
                vehicleCargoChart                  = vehiclePanel.AddUIComponent <UICargoChart>();
                vehicleCargoChart.size             = new Vector2(60, 60);
                vehicleCargoChart.relativePosition = new Vector3(330, 0);
                vehicleCargoChart.SetValues(CargoParcel.ResourceTypes.Select(f => 1f / CargoParcel.ResourceTypes.Length).ToArray());
            }
            else
            {
                Debug.LogError("CityServiceVehicleWorldInfoPanel not found!");
            }
        }
        void AddBuildingPanelControls(WorldInfoPanel infoPanel, out UILabel assetNameLabel,
            out UIButton showExplorerButton, Vector3 showExplorerButtonOffset,
            out UIButton dumpMeshTextureButton, Vector3 dumpMeshTextureButtonOffset)
        {
            infoPanel.component.Find<UILabel>("AllGood").isVisible = false;
            infoPanel.component.Find<UIPanel>("ProblemsPanel").isVisible = false;

            assetNameLabel = CreateLabel
            (
                "AssetName: <>", 160, 24,
                infoPanel.component,
                new Vector3(8.0f, 48.0f, 0.0f),
                UIAlignAnchor.TopLeft
            );

            showExplorerButton = CreateButton
            (
                "Find in SceneExplorer", 160, 24,
                infoPanel.component,
                showExplorerButtonOffset,
                UIAlignAnchor.TopRight,
                (component, param) =>
                {
                    InstanceID instance = Util.GetPrivate<InstanceID>(infoPanel, "m_InstanceID");
                    sceneExplorer.ExpandFromRefChain(buildingsBufferRefChain.Add(instance.Building));
                    sceneExplorer.visible = true;
                }
            );

            dumpMeshTextureButton = CreateButton
            (
                "Preview", 160, 24,
                infoPanel.component,
                dumpMeshTextureButtonOffset,
                UIAlignAnchor.TopRight,
                (component, param) =>
                {
                    InstanceID instance = Util.GetPrivate<InstanceID>(infoPanel, "m_InstanceID");
                    var building = BuildingManager.instance.m_buildings.m_buffer[instance.Building];
                    var material = building.Info.m_material;
                    var mesh = building.Info.m_mesh;
                    var assetName = building.Info.name;
                    MeshViewer.CreateMeshViewer(assetName, mesh, material);
                }
            );
        }
        void AddVehiclePanelControls(WorldInfoPanel infoPanel, out UILabel assetNameLabel, out UIButton showExplorerButton, out UIButton dumpMeshTextureButton)
        {
            infoPanel.component.Find<UILabel>("Type").isVisible = false;

            assetNameLabel = CreateLabel
            (
                "AssetName: <>", 160, 24,
                infoPanel.component,
                new Vector3(8.0f, 48.0f, 0.0f),
                UIAlignAnchor.TopLeft
            );

            showExplorerButton = CreateButton
            (
                "Find in SceneExplorer", 160, 24,
                infoPanel.component,
                new Vector3(-8.0f, -57.0f, 0.0f),
                UIAlignAnchor.BottomRight,
                (component, param) =>
                {
                    InstanceID instance = Util.GetPrivate<InstanceID>(infoPanel, "m_InstanceID");

                    if (instance.Vehicle == 0)
                    {
                        sceneExplorer.ExpandFromRefChain(vehiclesParkedBufferRefChain.Add(instance.ParkedVehicle));
                    }
                    else
                    {
                        sceneExplorer.ExpandFromRefChain(vehiclesBufferRefChain.Add(instance.Vehicle));
                    }

                    sceneExplorer.visible = true;
                }
            );

            dumpMeshTextureButton = CreateButton
            (
                "Preview", 160, 24,
                infoPanel.component,
                new Vector3(-8.0f, -25.0f, 0.0f),
                UIAlignAnchor.BottomRight,
                (component, param) =>
                {
                    InstanceID instance = Util.GetPrivate<InstanceID>(infoPanel, "m_InstanceID");
                    VehicleInfo vehicleInfo;
                    if (instance.Vehicle == 0)
                    {
                        vehicleInfo  = VehicleManager.instance.m_parkedVehicles.m_buffer[instance.ParkedVehicle].Info;
                    }
                    else
                    {
                        vehicleInfo = VehicleManager.instance.m_vehicles.m_buffer[instance.Vehicle].Info;
                    }
                    var material = vehicleInfo.m_material;
                    var mesh = vehicleInfo.m_mesh;
                    var assetName = vehicleInfo.name;
                    MeshViewer.CreateMeshViewer(assetName, mesh, material);
                }
            );
        }