Пример #1
0
        /// <summary>
        /// Adds control bouttons the the panel.
        /// </summary>
        /// <param name="panel">UI panel instance</param>
        protected void AddButtons(UIPanel panel)
        {
            // Add extra space.
            currentY += RowHeight;

            // Reset button.
            UIButton resetButton = UIUtils.CreateButton(panel, 150);

            resetButton.text             = Translations.Translate("RPR_OPT_RTD");
            resetButton.relativePosition = new Vector3(Margin, currentY);
            resetButton.eventClicked    += (component, clickEvent) => ResetToDefaults();

            UIButton revertToSaveButton = UIUtils.CreateButton(panel, 150);

            revertToSaveButton.text             = Translations.Translate("RPR_OPT_RTS");
            revertToSaveButton.relativePosition = new Vector3((Margin * 2) + 150, currentY);

            revertToSaveButton.eventClicked += (component, clickEvent) => { XMLUtilsWG.ReadFromXML(); PopulateFields(); };

            UIButton saveButton = UIUtils.CreateButton(panel, 150);

            saveButton.text             = Translations.Translate("RPR_OPT_SAA");
            saveButton.relativePosition = new Vector3((Margin * 3) + 300, currentY);
            saveButton.eventClicked    += (component, clickEvent) => ApplyFields();
        }
Пример #2
0
        /// <summary>
        /// Sets the customised number of households for a given prefab.
        /// If a record doesn't already exist, a new one will be created.
        /// </summary>
        /// <param name="prefab">The prefab (BuildingInfo) to set</param>
        /// <param name="houses">The updated households</param>
        public static void SetResidential(BuildingInfo prefab, int houses)
        {
            // Update or add entry to configuration file cache.
            if (DataStore.householdCache.ContainsKey(prefab.name))
            {
                // Prefab already has a record; update.
                DataStore.householdCache[prefab.name] = houses;
            }
            else
            {
                // Prefab doesn't already have a record; create.
                DataStore.householdCache.Add(prefab.name, houses);
            }

            // Save the updated configuration file.
            XMLUtilsWG.WriteToXML();

            // Get current building hash (for updating prefab dictionary).
            var prefabHash = prefab.gameObject.GetHashCode();

            // Update entry in 'live' settings.
            if (DataStore.prefabHouseHolds.ContainsKey(prefabHash))
            {
                // Prefab already has a record; update.
                DataStore.prefabHouseHolds[prefabHash] = houses;
            }
            else
            {
                // Prefab doesn't already have a record; create.
                DataStore.prefabHouseHolds.Add(prefabHash, houses);
            }
        }
Пример #3
0
        /// <summary>
        /// Removes the custom household record (if any) for a given prefab.
        /// </summary>
        /// <param name="prefab">The prefab (BuildingInfo) to remove the record from</param>
        public static void RemoveResidential(BuildingInfo prefab)
        {
            // Remove the entry from the configuration file cache.
            DataStore.householdCache.Remove(prefab.name);

            // Save the updated configuration file.
            XMLUtilsWG.WriteToXML();

            // Remove current building's record from 'live' dictionary.
            DataStore.prefabHouseHolds.Remove(prefab.gameObject.GetHashCode());
        }
Пример #4
0
        /// <summary>
        /// Removes the custom household record (if any) for a given prefab.
        /// </summary>
        /// <param name="prefab">The prefab (BuildingInfo) to remove the record from</param>
        public static void RemoveWorker(BuildingInfo prefab)
        {
            // Remove the entry from the configuration file cache.
            DataStore.workerCache.Remove(prefab.name);

            // Save the updated configuration file.
            XMLUtilsWG.WriteToXML();

            // Remove current building's record from 'live' dictionary.
            DataStore.prefabWorkerVisit.Remove(prefab.gameObject.GetHashCode());
        }
        /// <summary>
        /// Updates the DataStore with the information from the text fields.
        /// </summary>
        protected override void ApplyFields()
        {
            // Apply each subservice.
            ApplySubService(DataStore.office, Office);
            ApplySubService(DataStore.officeHighTech, HighTech);

            // Clear cached values.
            DataStore.prefabWorkerVisit.Clear();

            // Save new settings.
            XMLUtilsWG.WriteToXML();

            // Refresh settings.
            PopulateFields();
        }
        public override void OnLevelLoaded(LoadMode mode)
        {
            // Check to see if a conflicting mod has been detected - if so, alert the user.
            if (conflictingMod)
            {
                UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel").SetMessage("Realistic Population Revisited", "Original Realistic Population and Consumption Mod mod detected - Realistic Population Revisited is shutting down to protect your game.  Only ONE of these mods can be enabled at the same time; please unsubscribe from the old Realistic Population and Consumption Mod, which is now deprecated!", true);
            }

            // Don't do anything further if mod hasn't activated (conflicting mod detected, or loading into editor instead of game).
            if (!isModEnabled)
            {
                return;
            }

            else if (mode == LoadMode.LoadGame || mode == LoadMode.NewGame)
            {
                if (!isLevelLoaded)
                {
                    isLevelLoaded = true;
                    // Now we can remove people
                    DataStore.allowRemovalOfCitizens = true;
                    Debugging.releaseBuffer();
                    Debugging.Message("successfully applied");
                }
            }

            // Create new XML if one doesn't already exist.
            if (!File.Exists(DataStore.currentFileLocation))
            {
                XMLUtilsWG.WriteToXML();
            }

            // Add button to building info panels.
            BuildingDetailsPanel.AddInfoPanelButton();

            // Check if we need to display update notification.
            if (UpdateNotification.notificationVersion != 2)
            {
                // No update notification "Don't show again" flag found; show the notification.
                UpdateNotification notification = new UpdateNotification();
                notification.Create();
                notification.Show();
            }

            // Set up options panel event handler.
            OptionsPanel.OptionsEventHook();
        }
Пример #7
0
        /// <summary>
        /// Updates the DataStore with the information from the text fields.
        /// </summary>
        protected override void ApplyFields()
        {
            // Apply each subservice.
            ApplySubService(DataStore.residentialLow, LowRes);
            ApplySubService(DataStore.residentialHigh, HighRes);
            ApplySubService(DataStore.resEcoLow, LowEcoRes);
            ApplySubService(DataStore.resEcoHigh, HighEcoRes);

            // Clear cached values.
            DataStore.prefabHouseHolds.Clear();

            // Save new settings.
            XMLUtilsWG.WriteToXML();

            // Refresh settings.
            PopulateFields();
        }
Пример #8
0
        /// <summary>
        /// Updates the DataStore with the information from the text fields.
        /// </summary>
        protected override void ApplyFields()
        {
            // Apply each subservice.
            ApplySubService(DataStore.commercialLow, LowCom);
            ApplySubService(DataStore.commercialHigh, HighCom);
            ApplySubService(DataStore.commercialEco, EcoCom);
            ApplySubService(DataStore.commercialLeisure, Leisure);
            ApplySubService(DataStore.commercialTourist, Tourist);

            // Clear cached values.
            DataStore.prefabWorkerVisit.Clear();

            // Save new settings.
            XMLUtilsWG.WriteToXML();

            // Refresh settings.
            PopulateFields();
        }
        /// <summary>
        /// Updates the DataStore with the information from the text fields.
        /// </summary>
        protected override void ApplyFields()
        {
            // Apply each subservice.
            ApplySubService(DataStore.industry, Generic);
            ApplySubService(DataStore.industry_farm, Farming);
            ApplySubService(DataStore.industry_forest, Forestry);
            ApplySubService(DataStore.industry_oil, Oil);
            ApplySubService(DataStore.industry_ore, Ore);

            // Clear cached values.
            DataStore.prefabWorkerVisit.Clear();

            // Save new settings.
            XMLUtilsWG.WriteToXML();

            // Refresh settings.
            PopulateFields();
        }
        /// <summary>
        /// Adds the options panel event handler for the start screen (to enable/disable options panel based on visibility).
        /// </summary>
        public void OnEnabled()
        {
            // Load settings file.
            SettingsUtils.LoadSettings();

            // Populate Datastore from configuration file.
            XMLUtilsWG.ReadFromXML();

            // Check to see if UIView is ready.
            if (UIView.GetAView() != null)
            {
                // It's ready - attach the hook now.
                OptionsPanel.OptionsEventHook();
            }
            else
            {
                // Otherwise, queue the hook for when the intro's finished loading.
                LoadingManager.instance.m_introLoaded += OptionsPanel.OptionsEventHook;
            }
        }
Пример #11
0
        /// <summary>
        /// Sets the customised number of workers for a given prefab.
        /// If a record doesn't already exist, a new one will be created.
        /// </summary>
        /// <param name="prefab">The prefab (BuildingInfo) to set</param>
        /// <param name="workers">The updated worker count</param>
        public static void SetWorker(BuildingInfo prefab, int workers)
        {
            // Update or add entry to configuration file cache.
            if (DataStore.workerCache.ContainsKey(prefab.name))
            {
                // Prefab already has a record; update.
                DataStore.workerCache[prefab.name] = workers;
            }
            else
            {
                // Prefab doesn't already have a record; create.
                DataStore.workerCache.Add(prefab.name, workers);
            }

            // Save the updated configuration file.
            XMLUtilsWG.WriteToXML();

            // Get current building hash (for updating prefab dictionary).
            var prefabHash = prefab.gameObject.GetHashCode();

            // Calculate employment breakdown.
            int[] array = CommercialBuildingAIMod.GetArray(prefab, (int)prefab.GetClassLevel());
            PrefabEmployStruct output = new PrefabEmployStruct();

            AI_Utils.CalculateprefabWorkerVisit(prefab.GetWidth(), prefab.GetLength(), ref prefab, 4, ref array, out output);

            // Update entry in 'live' settings.
            if (DataStore.prefabWorkerVisit.ContainsKey(prefabHash))
            {
                // Prefab already has a record; update.
                DataStore.prefabWorkerVisit[prefabHash] = output;
            }
            else
            {
                // Prefab doesn't already have a record; create.
                DataStore.prefabWorkerVisit.Add(prefabHash, output);
            }
        }