Esempio n. 1
0
        public void Start()
        {
            try
            {
                // Loading config
                AdvancedVehicleOptions.InitVehicleDataConfig();

                if (AdvancedVehicleOptions.OnLoadValidateServices)
                {
                    AdvancedVehicleOptions.CheckAllServicesValidity();
                }

                m_mainPanel = GameObject.FindObjectOfType <GUI.UIMainPanel>();
                UpdateGUI();

                UIThreading.Operating = true;
            }
            catch (Exception e)
            {
                Logging.Error("UI initialization failed.");
                Logging.LogException(e);

                GameObject.Destroy(gameObject);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Look for keypress to activate tool.
        /// </summary>
        /// <param name="realTimeDelta"></param>
        /// <param name="simulationTimeDelta"></param>
        public override void OnUpdate(float realTimeDelta, float simulationTimeDelta)
        {
            // Don't do anything if not active.
            if (operating)
            {
                // Has hotkey been pressed?
                if (savedKey.Key != KeyCode.None && Input.GetKey(savedKey.Key))
                {
                    // Check modifier keys according to settings.
                    bool altPressed   = Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt) || Input.GetKey(KeyCode.AltGr);
                    bool ctrlPressed  = Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl);
                    bool shiftPressed = Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift);

                    // Modifiers have to *exactly match* settings, e.g. "alt-E" should not trigger on "ctrl-alt-E".
                    bool altOkay   = altPressed == savedKey.Alt;
                    bool ctrlOkay  = ctrlPressed == savedKey.Control;
                    bool shiftOkay = shiftPressed == savedKey.Shift;

                    // Process keystroke.
                    if (altOkay && ctrlOkay && shiftOkay)
                    {
                        // Only process if we're not already doing so.
                        if (!processed)
                        {
                            // Set processed flag.
                            processed = true;

                            // Toggle AVO Mainpanel Visibility

                            if (!AdvancedVehicleOptions.m_mainPanel.isVisible)
                            {
                                AdvancedVehicleOptions.m_mainPanel.isVisible = true;
                                AdvancedVehicleOptions.m_mainPanel.m_fastList.DisplayAt(AdvancedVehicleOptions.m_mainPanel.m_fastList.listPosition);
                                AdvancedVehicleOptions.m_mainPanel.m_optionPanel.Show(AdvancedVehicleOptions.m_mainPanel.m_fastList.rowsData[AdvancedVehicleOptions.m_mainPanel.m_fastList.selectedIndex] as VehicleOptions);
                                AdvancedVehicleOptions.m_mainPanel.m_followVehicle.isVisible = AdvancedVehicleOptions.m_mainPanel.m_preview.parent.isVisible = true;
                                AdvancedVehicleOptions.UpdateOptionPanelInfo();
                            }
                            else
                            {
                                AdvancedVehicleOptions.m_mainPanel.isVisible = false;
                            }
                        }
                    }
                    else
                    {
                        // Relevant keys aren't pressed anymore; this keystroke is over, so reset and continue.
                        processed = false;
                    }
                }
                else
                {
                    // Relevant keys aren't pressed anymore; this keystroke is over, so reset and continue.
                    processed = false;
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Called when the level (game, map editor, asset editor) is loaded
        /// </summary>
        public override void OnLevelLoaded(LoadMode mode)
        {
            try
            {
                // Is it an actual game ?
                if (mode != LoadMode.LoadGame && mode != LoadMode.NewGame && mode != LoadMode.NewGameFromScenario)
                {
                    DefaultOptions.Clear();
                    Logging.Error("AVO Incompatible GameMode " + mode);
                    return;
                }

                AdvancedVehicleOptions.isGameLoaded = true;

                if (instance != null)
                {
                    GameObject.DestroyImmediate(instance.gameObject);
                }

                instance = new GameObject("AdvancedVehicleOptions").AddComponent <AdvancedVehicleOptions>();

                try
                {
                    DefaultOptions.BuildVehicleInfoDictionary();
                    VehicleOptions.Clear();
                    Logging.Message("UIMainPanel created");
                }
                catch
                {
                    Logging.Error("Could not create UIMainPanel");

                    if (instance != null)
                    {
                        GameObject.Destroy(instance.gameObject);
                    }

                    return;
                }

                //new EnumerableActionThread(BrokenAssetsFix);
            }
            catch (Exception e)
            {
                if (instance != null)
                {
                    GameObject.Destroy(instance.gameObject);
                }
                Logging.LogException(e);
            }
        }
Esempio n. 4
0
        public void OnSettingsUI(UIHelperBase helper)
        {
            try
            {
                // Section for General Settings

                UIHelperBase Group_General = helper.AddGroup(Translations.Translate("AVO_OPT_GEN") + " - " + Name);

                // Checkbox for Autosave Config

                UICheckBox AutoSaveVehicleConfig_Box = (UICheckBox)Group_General.AddCheckbox(Translations.Translate("AVO_OPT_GEN_ASAVE"), AdvancedVehicleOptions.AutoSaveVehicleConfig, (b) =>
                {
                    AdvancedVehicleOptions.AutoSaveVehicleConfig = b;
                    ModSettings.Save();
                    AdvancedVehicleOptions.UpdateOptionPanelInfo();
                });

                AutoSaveVehicleConfig_Box.tooltip = Translations.Translate("AVO_OPT_GEN_ASAVE_TT");

                // Checkbox for validating services

                UICheckBox ValidateMissingServices_Box = (UICheckBox)Group_General.AddCheckbox(Translations.Translate("AVO_OPT_GEN_SERVICE"), AdvancedVehicleOptions.OnLoadValidateServices, (b) =>
                {
                    AdvancedVehicleOptions.OnLoadValidateServices = b;
                    ModSettings.Save();
                });

                ValidateMissingServices_Box.tooltip = Translations.Translate("AVO_OPT_GEN_SERVICE_TT");

                // Checkbox for Debug Setting

                UICheckBox DebugMsg_Box = (UICheckBox)Group_General.AddCheckbox(Translations.Translate("AVO_OPT_GEN_DEBUG"), Logging.detailLogging, (b) =>
                {
                    Logging.detailLogging = b;
                    ModSettings.Save();
                });

                DebugMsg_Box.tooltip = Translations.Translate("AVO_OPT_GEN_DEBUG_TT");

                Group_General.AddSpace(1);

                // Checkbox for GUI Button

                UICheckBox HideButton_Box = (UICheckBox)Group_General.AddCheckbox(Translations.Translate("AVO_OPT_GEN_GUI"), AdvancedVehicleOptions.HideGUIbutton, (b) =>
                {
                    AdvancedVehicleOptions.HideGUIbutton = b;
                    AdvancedVehicleOptions.UpdateGUI();
                    ModSettings.Save();
                });

                HideButton_Box.tooltip = Translations.Translate("AVO_OPT_GEN_GUI_TT");

                // Datafield for Hot Key

                HideButton_Box.parent.gameObject.AddComponent <OptionsKeymapping>();

                // Checkbox for Language Option

                UIDropDown Language_DropDown = (UIDropDown)Group_General.AddDropdown(Translations.Translate("TRN_CHOICE"), Translations.LanguageList, Translations.Index, (value) =>
                {
                    Translations.Index = value;
                    ModSettings.Save();
                });

                Language_DropDown.tooltip  = Translations.Translate("TRN_TOOLTIP");
                Language_DropDown.autoSize = false;
                Language_DropDown.width    = 270f;

                // Section for Game Balancing

                UIHelperBase Group_Balance = helper.AddGroup(Translations.Translate("AVO_OPT_BAL"));

                // Checkbox for SpeedUnitOption kmh vs mph

                UICheckBox SpeedUnitOptions_Box = (UICheckBox)Group_Balance.AddCheckbox(Translations.Translate("AVO_OPT_BAL_UNITS"), AdvancedVehicleOptions.SpeedUnitOption, (b) =>
                {
                    AdvancedVehicleOptions.SpeedUnitOption = b;
                    ModSettings.Save();
                    AdvancedVehicleOptions.UpdateOptionPanelInfo();
                });

                SpeedUnitOptions_Box.tooltip = Translations.Translate("AVO_OPT_BAL_UNITS_TT");

                // Checkbox for Game Balancing

                UICheckBox ExtendedValues_Box = (UICheckBox)Group_Balance.AddCheckbox(Translations.Translate("AVO_OPT_BAL_EXT"), AdvancedVehicleOptions.ShowMoreVehicleOptions, (b) =>
                {
                    AdvancedVehicleOptions.ShowMoreVehicleOptions = b;
                    ModSettings.Save();
                });

                ExtendedValues_Box.tooltip = Translations.Translate("AVO_OPT_BAL_EXT_TT");

                // Section for Compatibility

                UIHelperBase Group_Compatibility = helper.AddGroup(Translations.Translate("AVO_OPT_COMP"));

                // Checkbox for Overriding Incompability Warnings

                UICheckBox DisplayCompatibility_Box = (UICheckBox)Group_Compatibility.AddCheckbox(Translations.Translate("AVO_OPT_COMP_MODS"), AdvancedVehicleOptions.OverrideCompatibilityWarnings, (b) =>
                {
                    AdvancedVehicleOptions.OverrideCompatibilityWarnings = b;
                    ModSettings.Save();
                });

                DisplayCompatibility_Box.tooltip = Translations.Translate("AVO_OPT_COMP_MODS_TT");

                // Default = True, as AVO shall color shared mod setting values in red.

                // Checkbox for Vehicle Color Expander

                UICheckBox OverrideVCX_Box = (UICheckBox)Group_Compatibility.AddCheckbox(Translations.Translate("AVO_OPT_COMP_VCX"), AdvancedVehicleOptions.OverrideVCX, (b) =>
                {
                    AdvancedVehicleOptions.OverrideVCX = b;
                    ModSettings.Save();
                });

                OverrideVCX_Box.tooltip = Translations.Translate("AVO_OPT_COMP_VCX_TT");

                //Always True, if AVO shall not override Vehicle Color Expander / Asset Color Expander settings. As there is no Settings for Vehicle Color Expander / Asset Color Expander. AVO will show the option, but user cannot change anything as long readOnly is True.

                OverrideVCX_Box.readOnly        = true;
                OverrideVCX_Box.label.textColor = Color.gray;

                if (!VCXCompatibilityPatch.IsVCXActive() | !VCXCompatibilityPatch.IsACXActive())
                {
                    OverrideVCX_Box.enabled = false;    //Do not show the option Checkbox, if Vehicle Color Expander / Asset Color Expander is not active.
                }

                // Checkbox for No Big Trucks

                UICheckBox NoBigTrucks_Box = (UICheckBox)Group_Compatibility.AddCheckbox(Translations.Translate("AVO_OPT_COMP_NBT"), AdvancedVehicleOptions.ControlTruckDelivery, (b) =>
                {
                    AdvancedVehicleOptions.ControlTruckDelivery = b;
                    ModSettings.Save();
                });

                NoBigTrucks_Box.tooltip = Translations.Translate("AVO_OPT_COMP_NBT_TT");
                //True, if AVO shall be enabled to classify Generic Industry vehicles as Large Vehicles, so No Big Trucks can suppress the dispatch to small buildings.

                if (!NoBigTruckCompatibilityPatch.IsNBTActive() | !NoBigTruckCompatibilityPatch.IsNBTBetaActive())
                {
                    NoBigTrucks_Box.enabled = false;   //Do not show the option Checkbox, if No Big Trucks is not active.
                }

                // Add Trailer Compatibility Reference

                UITextField TrailerCompatibilityList_Textfield = (UITextField)Group_Compatibility.AddTextfield(Translations.Translate("AVO_OPT_COMP_TRL"), TrailerRef.Revision, (value) =>
                {
                    Logging.KeyMessage("Using Trailer Configuration file: " + TrailerRef.Revision, value);
                });

                TrailerCompatibilityList_Textfield.tooltip  = Translations.Translate("AVO_OPT_COMP_TRL_TT");
                TrailerCompatibilityList_Textfield.readOnly = true;

                // Support Section with Wiki and Output-Log

                UIHelperBase Group_Support = helper.AddGroup(Translations.Translate("AVO_OPT_SUP"));

                UIButton Wikipedia_Button = (UIButton)Group_Support.AddButton(Translations.Translate("AVO_OPT_SUP_WIKI"), () =>
                {
                    SimulationManager.instance.SimulationPaused = true;
                    Application.OpenURL("https://github.com/CityGecko/CS-AdvancedVehicleOptions/wiki");
                });
                Wikipedia_Button.textScale = 0.8f;

                UIButton OutputLog_Button = (UIButton)Group_Support.AddButton(Translations.Translate("AVO_OPT_SUP_LOG"), () =>
                {
                    Utils.OpenInFileBrowser(Application.dataPath);
                });
                OutputLog_Button.textScale = 0.8f;

                UIButton AVOLog_Button = (UIButton)Group_Support.AddButton(Translations.Translate("AVO_OPT_SUP_SET"), () =>
                {
                    // Utils.OpenInFileBrowser(Application.streamingAssetsPath);
                    Utils.OpenInFileBrowser(DataLocation.localApplicationData);
                });
                AVOLog_Button.textScale = 0.8f;
                AVOLog_Button.tooltip   = (Translations.Translate("AVO_OPT_SUP_SET_TT"));
            }

            catch (Exception e)
            {
                Logging.Error("OnSettingsUI failed");
                Logging.LogException(e);
            }
        }