Beispiel #1
0
        /// <summary>
        /// Look for keypress to open GUI.
        /// </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 (hotKey != KeyCode.None && Input.GetKey(hotKey))
                {
                    // 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 == hotAlt;
                    bool ctrlOkay  = ctrlPressed == hotCtrl;
                    bool shiftOkay = shiftPressed == hotShift;

                    // Process keystroke.
                    if (altOkay && ctrlOkay && shiftOkay)
                    {
                        // Cancel if key input is already queued for processing.
                        if (_processed)
                        {
                            return;
                        }

                        _processed = true;

                        try
                        {
                            // Is options panel open?  If so, we ignore this and don't do anything.
                            if (!OptionsPanel.IsOpen)
                            {
                                BuildingDetailsPanel.Open();
                            }
                        }
                        catch (Exception e)
                        {
                            Logging.LogException(e, "exception opening building details panel");
                        }
                    }
                    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;
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Create the titlebar; we no longer use Start() as that's not sufficiently reliable (race conditions), and is no longer needed, with the new create/destroy process.
        /// </summary>
        public void Setup()
        {
            // Basic setup.
            width            = parent.width;
            height           = UIBuildingDetails.TitleHeight;
            isVisible        = true;
            canFocus         = true;
            isInteractive    = true;
            relativePosition = Vector3.zero;

            // Make it draggable.
            dragHandle                  = AddUIComponent <UIDragHandle>();
            dragHandle.width            = width - 50;
            dragHandle.height           = height;
            dragHandle.relativePosition = Vector3.zero;
            dragHandle.target           = parent;

            // Decorative icon (top-left).
            iconSprite = AddUIComponent <UISprite>();
            iconSprite.relativePosition = new Vector3(10, 5);
            iconSprite.spriteName       = "ToolbarIconZoomOutCity";
            UIUtils.ResizeIcon(iconSprite, new Vector2(30, 30));
            iconSprite.relativePosition = new Vector3(10, 5);

            // Titlebar label.
            titleLabel = AddUIComponent <UILabel>();
            titleLabel.relativePosition = new Vector3(50, 13);
            titleLabel.text             = RealPopMod.ModName;

            // Close button.
            closeButton = AddUIComponent <UIButton>();
            closeButton.relativePosition = new Vector3(width - 35, 2);
            closeButton.normalBgSprite   = "buttonclose";
            closeButton.hoveredBgSprite  = "buttonclosehover";
            closeButton.pressedBgSprite  = "buttonclosepressed";
            closeButton.eventClick      += (component, param) =>
            {
                BuildingDetailsPanel.Close();
            };
        }
        /// <summary>
        /// Called by the game when level loading is complete.
        /// </summary>
        /// <param name="mode">Loading mode (e.g. game, editor, scenario, etc.)</param>
        public override void OnLevelLoaded(LoadMode mode)
        {
            base.OnLevelLoaded(mode);

            // Check to see that Harmony 2 was properly loaded.
            if (!harmonyLoaded)
            {
                // Harmony 2 wasn't loaded; display warning notification and exit.
                ListMessageBox harmonyBox = MessageBoxBase.ShowModal <ListMessageBox>();

                // Key text items.
                harmonyBox.AddParas(Translations.Translate("ERR_HAR0"), Translations.Translate("RPR_ERR_HAR"), Translations.Translate("RPR_ERR_FAT"), Translations.Translate("ERR_HAR1"));

                // List of dot points.
                harmonyBox.AddList(Translations.Translate("ERR_HAR2"), Translations.Translate("ERR_HAR3"));

                // Closing para.
                harmonyBox.AddParas(Translations.Translate("MES_PAGE"));
            }

            // Check to see if a conflicting mod has been detected.
            if (conflictingMod)
            {
                // Mod conflict detected - display warning notification and exit.
                ListMessageBox modConflictBox = MessageBoxBase.ShowModal <ListMessageBox>();

                // Key text items.
                modConflictBox.AddParas(Translations.Translate("ERR_CON0"), Translations.Translate("RPR_ERR_CON0"), Translations.Translate("RPR_ERR_FAT"), Translations.Translate("ERR_CON1"));

                // Add conflicting mod name(s).
                modConflictBox.AddList(ModUtils.conflictingModNames.ToArray());

                // Closing para.
                modConflictBox.AddParas(Translations.Translate("RPR_ERR_CON1"));
            }

            // Don't do anything further if mod hasn't activated for whatever reason (mod conflict, harmony error, something else).
            if (!isModEnabled)
            {
                // Disable keystrokes.
                UIThreading.operating = false;

                return;
            }

            // Show legacy choice message box if this save hasn't been flagged as being from Realistic Population 2.
            if (!ModSettings.isRealPop2Save)
            {
                MessageBoxBase.ShowModal <LegacyChoiceMessageBox>();
            }

            // Record initial (default) school settings and apply ours over the top.
            SchoolData.instance.OnLoad();

            // IF a legacy file exists, flag it for writing.
            if (File.Exists(DataStore.currentFileLocation))
            {
                Logging.KeyMessage("found legacy settings file");
                XMLUtilsWG.writeToLegacy = true;
            }

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

            Logging.KeyMessage("loading complete");

            // Display update notification.
            WhatsNew.ShowWhatsNew();

            // Set up options panel event handler.
            OptionsPanel.OptionsEventHook();

            // Check and record CitizenUnits count.
            Logging.KeyMessage("citizen unit count is currently ", ColossalFramework.Singleton <CitizenManager> .instance.m_unitCount.ToString());
        }
Beispiel #4
0
 /// <summary>
 /// Harmony Postfix patch to toggle Realistic Population building info panel button visibility when building selection changes.
 /// </summary>
 public static void Postfix()
 {
     BuildingDetailsPanel.UpdateServicePanelButton();
 }