예제 #1
0
        /// <summary>Updates the origin building display using the specified building ID. If 0 value is specified,
        /// hides the origin building panel.</summary>
        /// <param name="buildingId">The ID of the building to show as origin.</param>
        /// <param name="instanceIndex">The game instance object's index value.</param>
        protected void UpdateOriginFromBuilding(ushort buildingId, uint instanceIndex)
        {
            if (buildingId == 0)
            {
                SetCustomPanelVisibility(OriginPanel, false);
                return;
            }

            SetCustomPanelVisibility(OriginPanel, true);
            OriginButton.text           = GetBuildingName(buildingId, instanceIndex, out bool isObservable);
            OriginButton.isEnabled      = isObservable;
            OriginButton.objectUserData = buildingId;
            UIComponentTools.ShortenTextToFitParent(OriginButton);
        }
예제 #2
0
        /// <summary>
        /// Builds up the custom UI objects for the info panel.
        /// </summary>
        /// <returns><c>true</c> on success; otherwise, <c>false</c>.</returns>
        protected override bool InitializeCore()
        {
            bool result = base.InitializeCore();

            if (!result)
            {
                return(result);
            }

            wealthPanel = UIComponentTools.CreateCopy(OriginPanel, ItemsPanel);
            wealthLabel = UIComponentTools.CreateCopy(OriginLabel, wealthPanel, WealthComponentId);

            wealthLabel.text      = string.Empty;
            wealthPanel.isVisible = false;

            return(true);
        }
예제 #3
0
        /// <summary>
        /// Builds up the custom UI objects for the info panel.
        /// </summary>
        /// <returns><c>true</c> on success; otherwise, <c>false</c>.</returns>
        protected override bool InitializeCore()
        {
            if (!GetUIObjects(InfoPanelName, ItemsPanel, out var targetPanel, out var targetLabel, out var targetButton))
            {
                return(false);
            }

            OriginPanel  = UIComponentTools.CreateCopy(targetPanel, ItemsPanel);
            OriginLabel  = UIComponentTools.CreateCopy(targetLabel, OriginPanel, OriginComponentId + targetLabel.name);
            OriginButton = UIComponentTools.CreateCopy(targetButton, OriginPanel, OriginComponentId + targetButton.name);

            OriginButton.eventClick += OriginButtonClick;
            OriginLabel.text         = "▣";
            OriginPanel.isVisible    = false;

            return(true);
        }
예제 #4
0
        /// <summary>
        /// Builds up the custom UI objects for the info panel.
        /// </summary>
        /// <returns><c>true</c> on success; otherwise, <c>false</c>.</returns>
        protected override bool InitializeCore()
        {
            bool result = base.InitializeCore();

            if (!result)
            {
                return(result);
            }

            carPanel  = UIComponentTools.CreateCopy(OriginPanel, ItemsPanel);
            carLabel  = UIComponentTools.CreateCopy(OriginLabel, carPanel, CarComponentId + "Label");
            carButton = UIComponentTools.CreateCopy(OriginButton, carPanel, CarComponentId + "Button");

            carButton.eventClick += CarButtonClick;
            carLabel.text         = "| P| ";
            carPanel.isVisible    = false;

            return(true);
        }
예제 #5
0
        /// <summary>Updates the parked car display using the specified citizen instance ID. If 0 value is specified,
        /// hides the parked car panel.</summary>
        /// <param name="citizenId">The citizen ID to search the parked car for.</param>
        protected void UpdateCar(uint citizenId)
        {
            if (citizenId == 0)
            {
                SetCustomPanelVisibility(carPanel, false);
                return;
            }

            ushort parkedCarId = GetParkedVehicle(citizenId);

            if (parkedCarId == 0)
            {
                SetCustomPanelVisibility(carPanel, false);
            }
            else
            {
                SetCustomPanelVisibility(carPanel, true);
                carButton.text           = GetVehicleName(parkedCarId);
                carButton.objectUserData = parkedCarId;
                UIComponentTools.ShortenTextToFitParent(carButton);
            }
        }
예제 #6
0
        /// <summary>Updates the origin building display using the specified citizen instance ID. If 0 value is specified,
        /// hides the origin building panel.</summary>
        /// <param name="instanceId">The citizen instance ID to search the origin building for.</param>
        protected void UpdateOrigin(ushort instanceId)
        {
            if (instanceId == 0)
            {
                UpdateVisibility(false);
                return;
            }

            ushort originBuildingId = GetSourceBuilding(instanceId);

            if (originBuildingId == 0)
            {
                UpdateVisibility(false);
            }
            else
            {
                UpdateVisibility(true);
                originButton.text           = GetBuildingName(originBuildingId);
                originButton.objectUserData = originBuildingId;
                UIComponentTools.ShortenTextToFitParent(originButton);
            }
        }
예제 #7
0
        private void Initialize(string panelName)
        {
            GetUIObjects(panelName, out UIComponent itemsPanel, out UIPanel targetPanel, out UILabel targetLabel, out UIButton targetButton);

            if (itemsPanel == null || targetPanel == null || targetLabel == null || targetButton == null)
            {
                return;
            }

            defaultHeight = itemsPanel.parent?.height ?? 0;

            string buttonId = ButtonId + GetType().Name;

            originPanel  = UIComponentTools.CreateCopy(targetPanel, itemsPanel);
            originLabel  = UIComponentTools.CreateCopy(targetLabel, originPanel, buttonId);
            originButton = UIComponentTools.CreateCopy(targetButton, originPanel, buttonId);

            newHeight = defaultHeight + originPanel.height + originPanel.padding.bottom + originPanel.padding.top;

            originButton.eventClick += OriginButtonClick;
            originLabel.text         = "▣";
            originPanel.isVisible    = false;
        }