Exemplo n.º 1
0
        public static void Export(string filename)
        {
            string file = Path.Combine(MoveItTool.saveFolder, filename + ".xml");

            if (File.Exists(file))
            {
                ConfirmPanel.ShowModal("Overwrite file", "The file '" + filename + "' already exists.\n Do you want to overwrite it?", (comp, ret) =>
                {
                    if (ret == 1)
                    {
                        MoveItTool.instance.Export(filename);
                        instance.RefreshFileList();
                        instance.fileNameInput.Focus();
                        instance.fileNameInput.SelectAll();
                    }
                });
            }
            else
            {
                MoveItTool.instance.Export(filename);
                instance.RefreshFileList();
                instance.fileNameInput.Focus();
                instance.fileNameInput.SelectAll();
            }
        }
Exemplo n.º 2
0
        public static void Export(string filename)
        {
            string file = Path.Combine(MoveItTool.saveFolder, filename + ".xml");

            if (File.Exists(file))
            {
                ConfirmPanel.ShowModal(Str.xml_OverwriteTitle, String.Format(Str.xml_OverwriteMessage, filename), (comp, ret) =>
                {
                    if (ret == 1)
                    {
                        MoveItTool.instance.Export(filename);
                        instance.RefreshFileList();
                        instance.fileNameInput.Focus();
                        instance.fileNameInput.SelectAll();
                    }
                });
            }
            else
            {
                MoveItTool.instance.Export(filename);
                instance.RefreshFileList();
                instance.fileNameInput.Focus();
                instance.fileNameInput.SelectAll();
            }
        }
Exemplo n.º 3
0
        private void DeleteButtonOnEventClicked(UIComponent component, UIMouseEventParameter eventparam)
        {
            ConfirmPanel.ShowModal(
                Locale.Get($"{Configuration.ResourcePrefix}TOOLTIPS", "DeleteButton"),
                string.Format(Locale.Get($"{Configuration.ResourcePrefix}TEXTS", "DeleteConfirmationMessage"),
                              _fileNameLabel.text),
                (comp, ret) =>
            {
                if (ret != 1)
                {
                    return;
                }

                PresetsUtils.Delete(_fileNameLabel.text);

                if (UISaveWindow.Instance != null)
                {
                    UISaveWindow.Instance.RefreshFileList();
                }
                else
                {
                    UILoadWindow.Instance.RefreshFileList();
                }
            });
        }
Exemplo n.º 4
0
        public static void Export(string filename)
        {
            var file = Path.Combine(Configuration.AutoSaveFolderPath, filename + ".xml");

            if (File.Exists(file))
            {
                ConfirmPanel.ShowModal(
                    Locale.Get($"{Configuration.ResourcePrefix}TEXTS", "OverwriteButton"),
                    string.Format(Locale.Get($"{Configuration.ResourcePrefix}TEXTS", "OverwriteConfirmationMessage"),
                                  filename),
                    (comp, ret) =>
                {
                    if (ret != 1)
                    {
                        return;
                    }

                    //DebugUtils.Log("Deleting " + file);
                    File.Delete(file);
                    PresetsUtils.Export(filename);
                    Instance.RefreshFileList();
                });
            }
            else
            {
                PresetsUtils.Export(filename);
                Instance.RefreshFileList();
            }
        }
 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);
         });
     });
 }
Exemplo n.º 6
0
        public override void Awake()
        {
            height = 46;

            fileNameLabel                   = AddUIComponent <UILabel>();
            fileNameLabel.textScale         = 0.9f;
            fileNameLabel.autoSize          = false;
            fileNameLabel.height            = 30;
            fileNameLabel.verticalAlignment = UIVerticalAlignment.Middle;
            fileNameLabel.relativePosition  = new Vector3(8, 8);

            deleteButton                  = UIUtils.CreateButton(this);
            deleteButton.name             = "MoveIt_DeleteFileButton";
            deleteButton.text             = "X";
            deleteButton.size             = new Vector2(40f, 30f);
            deleteButton.relativePosition = new Vector3(430 - deleteButton.width - 8, 8);
            deleteButton.tooltip          = "Delete saved path";

            saveLoadButton                  = UIUtils.CreateButton(this);
            saveLoadButton.name             = "MoveIt_SaveLoadFileButton";
            saveLoadButton.text             = UISaveWindow.instance != null ? "Export" : "Import";
            saveLoadButton.size             = new Vector2(80f, 30f);
            saveLoadButton.relativePosition = new Vector3(deleteButton.relativePosition.x - saveLoadButton.width - 8, 8);

            saveLoadButton.eventClicked += (c, p) =>
            {
                if (UISaveWindow.instance != null)
                {
                    UISaveWindow.Export(fileNameLabel.text);
                }
                else
                {
                    UILoadWindow.Close();
                    MoveItTool.instance.Import(fileNameLabel.text);
                }
            };

            deleteButton.eventClicked += (c, p) =>
            {
                ConfirmPanel.ShowModal("Delete file", "Do you want to delete the file '" + fileNameLabel.text + "' permanently?", (comp, ret) =>
                {
                    if (ret == 1)
                    {
                        MoveItTool.instance.Delete(fileNameLabel.text);

                        if (UISaveWindow.instance != null)
                        {
                            UISaveWindow.instance.RefreshFileList();
                        }
                        else
                        {
                            UILoadWindow.instance.RefreshFileList();
                        }
                    }
                });
            };

            fileNameLabel.width = saveLoadButton.relativePosition.x - 16f;
        }
        private static void OnBindingMouseDown(UIComponent comp, UIMouseEventParameter p)
        {
            if (m_EditingBinding == null)
            {
                p.Use();
                m_EditingBinding = (Shortcut)p.source.objectUserData;
                UIButton uIButton = p.source as UIButton;
                uIButton.buttonsMask = (UIMouseButton.Left | UIMouseButton.Right | UIMouseButton.Middle | UIMouseButton.Special0 | UIMouseButton.Special1 | UIMouseButton.Special2 | UIMouseButton.Special3);
                uIButton.text        = "Press any key";
                p.source.Focus();
                UIView.PushModal(p.source);
            }
            else if (!IsUnbindableMouseButton(p.buttons))
            {
                p.Use();
                UIView.PopModal();
                InputKey        inputKey = SavedInputKey.Encode(ButtonToKeycode(p.buttons), IsControlDown(), IsShiftDown(), IsAltDown());
                List <Shortcut> currentAssigned;
                if (!IsAlreadyBound(m_EditingBinding, inputKey, out currentAssigned))
                {
                    if (m_EditingBinding.inputKey != inputKey)
                    {
                        m_EditingBinding.inputKey = inputKey;
                        Shortcut.SaveShorcuts();
                    }

                    UIButton uIButton = p.source as UIButton;
                    uIButton.text        = SavedInputKey.ToLocalizedString("KEYNAME", m_EditingBinding.inputKey);
                    uIButton.buttonsMask = UIMouseButton.Left;
                    m_EditingBinding     = null;
                }
                else
                {
                    string arg     = (currentAssigned.Count <= 1) ? Locale.Get("KEYMAPPING", currentAssigned[0].name) : Locale.Get("KEYMAPPING_MULTIPLE");
                    string message = string.Format(Locale.Get("CONFIRM_REBINDKEY", "Message"), SavedInputKey.ToLocalizedString("KEYNAME", inputKey), arg);
                    ConfirmPanel.ShowModal(Locale.Get("CONFIRM_REBINDKEY", "Title"), message, delegate(UIComponent c, int ret)
                    {
                        if (ret == 1)
                        {
                            m_EditingBinding.inputKey = inputKey;

                            for (int i = 0; i < currentAssigned.Count; i++)
                            {
                                currentAssigned[i].inputKey = 0;
                            }
                            Shortcut.SaveShorcuts();
                            RefreshKeyMapping();
                        }
                        UIButton uIButton    = p.source as UIButton;
                        uIButton.text        = SavedInputKey.ToLocalizedString("KEYNAME", m_EditingBinding.inputKey);
                        uIButton.buttonsMask = UIMouseButton.Left;
                        m_EditingBinding     = null;
                    });
                }
            }
        }
Exemplo n.º 8
0
 public override void OnClickInternal(UIMouseEventParameter p)
 {
     ConfirmPanel.ShowModal(Translation.GetString("Clear_Traffic"), Translation.GetString("Clear_Traffic") + "?", delegate(UIComponent comp, int ret) {
         if (ret == 1)
         {
             UtilityManager.Instance.RequestClearTraffic();
         }
         UIBase.GetTrafficManagerTool(true).SetToolMode(ToolMode.None);
     });
 }
Exemplo n.º 9
0
 private void DeleteBrushButton_eventClicked(UIComponent component, UIMouseEventParameter mouseEventParameter)
 {
     ConfirmPanel.ShowModal(Translation.Instance.GetTranslation("FOREST-BRUSH-MODAL-WARNING"), Translation.Instance.GetTranslation("FOREST-BRUSH-PROMPT-DELETE"), (d, i) =>
     {
         if (i == 1)
         {
             ForestBrush.Instance.BrushTool.DeleteCurrent();
         }
     });
 }
Exemplo n.º 10
0
 public void Execute()
 {
     ModLogger.Debug("Executing ShowWorkshopAssetInfo command for workshopid '{0}'", _workshopAssetRowData.WorkshopId);
     if (Steam.IsOverlayEnabled() && _workshopAssetRowData.WorkshopId > 0)
     {
         Steam.ActivateGameOverlayToWorkshopItem(new PublishedFileId(_workshopAssetRowData.WorkshopId));
     }
     else
     {
         ConfirmPanel.ShowModal(UITexts.WorkshopAssetInfoOpenInBrowserTitle, UITexts.WorkshopAssetInfoOpenInBrowserMessage, AskInfoModalCallback);
     }
 }
 public static void ShowConfirmDialog(string title, string text, Action onConfirm, Action onCancel)
 {
     ConfirmPanel.ShowModal(title, text, (_, result) => {
         if (result != 1)
         {
             onCancel();
         }
         else
         {
             onConfirm();
         }
     });
 }
Exemplo n.º 12
0
 private static void ShowSubscriptionPrompt()
 {
     if (!GetSubscriptionHelpMessages(out var reason, out var solution))
     {
         ShowError(reason, solution);
         return;
     }
     else
     {
         ConfirmPanel.ShowModal("Missing dependency: Harmony",
                                "The dependency 'Harmony' is required for some mod(s) to work correctly. Do you want to subscribe to it in the Steam Workshop?",
                                OnConfirm);
     }
 }
Exemplo n.º 13
0
        public override void Group9SettingsUI(UIHelperExtension group9)
        {
            TLMConfigOptions.instance.generateNumberFieldConfig(group9, Locale.Get("K45_TLM_MAXIMUM_VEHICLE_COUNT_FOR_SPECIFIC_LINE_CONFIG"), TLMConfigWarehouse.ConfigIndex.MAX_VEHICLES_SPECIFIC_CONFIG).maxLength = 3;

            group9.AddButton(Locale.Get("K45_TLM_DRAW_CITY_MAP"), TLMMapDrawer.drawCityMap);
            group9.AddButton("Open generated map folder", () => ColossalFramework.Utils.OpenInFileBrowser(TLMController.exportedMapsFolder));
            group9.AddSpace(2);
            group9.AddButton(Locale.Get("K45_TLM_RELOAD_DEFAULT_CONFIGURATION"), () =>
            {
                TLMConfigWarehouse.GetConfig(null, null).ReloadFromDisk();
                TLMConfigOptions.instance.ReloadData();
            });
            if (IsCityLoaded)
            {
                group9.AddButton(Locale.Get("K45_TLM_EXPORT_CITY_CONFIG"), () =>
                {
                    string path = TLMConfigOptions.instance.currentLoadedCityConfig.Export();
                    ConfirmPanel.ShowModal(Name, string.Format(Locale.Get("K45_TLM_FILE_EXPORTED_TO_TEMPLATE"), path), (x, y) =>
                    {
                        if (y == 1)
                        {
                            ColossalFramework.Utils.OpenInFileBrowser(path);
                        }
                    });
                });
                group9.AddButton(Locale.Get("K45_TLM_IMPORT_CITY_CONFIG"), () =>
                {
                    ConfirmPanel.ShowModal(Name, string.Format(Locale.Get("K45_TLM_FILE_WILL_BE_IMPORTED_TEMPLATE"), TLMConfigOptions.instance.currentLoadedCityConfig.ThisPath), (x, y) =>
                    {
                        if (y == 1)
                        {
                            TLMConfigOptions.instance.currentLoadedCityConfig.ReloadFromDisk();
                            TLMConfigOptions.instance.ReloadData();
                        }
                    });
                });
                group9.AddButton(Locale.Get("K45_TLM_SAVE_CURRENT_CITY_CONFIG_AS_DEFAULT"), () =>
                {
                    TLMConfigOptions.instance.currentLoadedCityConfig.SaveAsDefault();
                    TLMConfigWarehouse.GetConfig(null, null).ReloadFromDisk();
                    TLMConfigOptions.instance.ReloadData();
                });
                group9.AddButton(Locale.Get("K45_TLM_LOAD_DEFAULT_AS_CURRENT_CITY_CONFIG"), () =>
                {
                    TLMConfigOptions.instance.currentLoadedCityConfig.LoadFromDefault();
                    TLMConfigWarehouse.GetConfig(null, null).ReloadFromDisk();
                    TLMConfigOptions.instance.ReloadData();
                });
            }
        }
        private static void OnBindingKeyDown(UIComponent comp, UIKeyEventParameter p)
        {
            if (m_EditingBinding != null && !IsModifierKey(p.keycode))
            {
                p.Use();
                UIView.PopModal();
                KeyCode  keycode  = p.keycode;
                InputKey inputKey = (p.keycode == KeyCode.Escape) ? (InputKey)m_EditingBinding.inputKey : SavedInputKey.Encode(keycode, p.control, p.shift, p.alt);
                if (p.keycode == KeyCode.Backspace)
                {
                    inputKey = 0;
                }
                List <Shortcut> currentAssigned;
                if (!IsAlreadyBound(m_EditingBinding, inputKey, out currentAssigned))
                {
                    if (m_EditingBinding.inputKey != inputKey)
                    {
                        m_EditingBinding.inputKey = inputKey;
                        Shortcut.SaveShorcuts();
                    }

                    UITextComponent uITextComponent = p.source as UITextComponent;
                    uITextComponent.text = SavedInputKey.ToLocalizedString("KEYNAME", inputKey);
                    m_EditingBinding     = null;
                }
                else
                {
                    string arg     = (currentAssigned.Count <= 1) ? currentAssigned[0].name : Locale.Get("KEYMAPPING_MULTIPLE");
                    string message = string.Format(Locale.Get("CONFIRM_REBINDKEY", "Message"), SavedInputKey.ToLocalizedString("KEYNAME", inputKey), arg);
                    ConfirmPanel.ShowModal(Locale.Get("CONFIRM_REBINDKEY", "Title"), message, delegate(UIComponent c, int ret)
                    {
                        if (ret == 1)
                        {
                            for (int i = 0; i < currentAssigned.Count; i++)
                            {
                                currentAssigned[i].inputKey = 0;
                            }
                        }

                        m_EditingBinding.inputKey = inputKey;
                        Shortcut.SaveShorcuts();
                        RefreshKeyMapping();

                        UITextComponent uITextComponent = p.source as UITextComponent;
                        uITextComponent.text            = SavedInputKey.ToLocalizedString("KEYNAME", m_EditingBinding.inputKey);
                        m_EditingBinding = null;
                    });
                }
            }
        }
        private void AddKeymapping(string label, Shortcut shortcut)
        {
            UIPanel uIPanel = component.AttachUIComponent(UITemplateManager.GetAsGameObject(kKeyBindingTemplate)) as UIPanel;

            uIPanel.name = "ShortcutItem";
            if (count++ % 2 == 1)
            {
                uIPanel.backgroundSprite = null;
            }

            UILabel  uILabel  = uIPanel.Find <UILabel>("Name");
            UIButton uIButton = uIPanel.Find <UIButton>("Binding");

            uIButton.eventClick += (c, p) =>
            {
                GUI.UIShortcutModal.instance.title    = "Edit Shortcut";
                GUI.UIShortcutModal.instance.shortcut = shortcut;

                UIView.PushModal(GUI.UIShortcutModal.instance);
                GUI.UIShortcutModal.instance.Show();
            };

            uILabel.text            = label;
            uIButton.text           = SavedInputKey.ToLocalizedString("KEYNAME", shortcut.inputKey);
            uIButton.objectUserData = shortcut;
            uIButton.stringUserData = "MoreShortcuts";

            UIButton delete = uIPanel.AddUIComponent <UIButton>();

            delete.atlas           = UIUtils.GetAtlas("Ingame");
            delete.normalBgSprite  = "buttonclose";
            delete.hoveredBgSprite = "buttonclosehover";
            delete.pressedBgSprite = "buttonclosepressed";
            delete.tooltip         = "Delete Shortcut";
            delete.eventClick     += (c, p) =>
            {
                ConfirmPanel.ShowModal("Delete Shortcut", "Are you sure you want to delete the [" + shortcut.name + "] shortcut?", (c2, ret) =>
                {
                    if (ret == 1)
                    {
                        Shortcut.RemoveShortcut(shortcut);
                        Shortcut.SaveShorcuts();
                        RefreshShortcutsList();
                    }
                });
            };

            delete.relativePosition = uIButton.relativePosition + new Vector3(uIButton.width + 10, 0);
        }
Exemplo n.º 16
0
        public override void OnClickInternal(UIMouseEventParameter p)
        {
            ConfirmPanel.ShowModal(
                Translation.Menu.Get("Tooltip:Clear traffic"),
                Translation.Menu.Get("Dialog.Text:Clear traffic, confirmation"),
                (comp, ret) => {
                if (ret == 1)
                {
                    Constants.ServiceFactory.SimulationService.AddAction(
                        () => { UtilityManager.Instance.ClearTraffic(); });
                }

                ModUI.GetTrafficManagerTool(true).SetToolMode(ToolMode.None);
            });
        }
        protected override void OnClick(UIMouseEventParameter p)
        {
            ConfirmPanel.ShowModal(
                title: Translation.Menu.Get("Tooltip:Clear traffic"),
                message: Translation.Menu.Get("Dialog.Text:Clear traffic, confirmation"),
                callback: (comp, ret) => {
                if (ret == 1)
                {
                    Singleton <SimulationManager> .instance.AddAction(
                        () => UtilityManager.Instance.ClearTraffic());
                }

                ModUI.GetTrafficManagerTool()?.SetToolMode(ToolMode.None);
            });
            base.OnClick(p);
        }
Exemplo n.º 18
0
 private void OnDeleteLinesClick(UIComponent component, UIMouseEventParameter eventParam)
 {
     if (!this._deleteBusLines.isChecked && !this._deleteTramLines.isChecked && (!this._deleteMetroLines.isChecked && !this._deleteTrainLines.isChecked) && (!this._deleteShipLines.isChecked && !this._deleteAirLines.isChecked))
     {
         return;
     }
     WorldInfoPanel.Hide <PublicTransportWorldInfoPanel>();
     ConfirmPanel.ShowModal(Localization.Get("SETTINGS_LINE_DELETION_TOOL_CONFIRM_TITLE"), Localization.Get("SETTINGS_LINE_DELETION_TOOL_CONFIRM_MSG"), (UIView.ModalPoppedReturnCallback)((s, r) =>
     {
         if (r != 1)
         {
             return;
         }
         Singleton <SimulationManager> .instance.AddAction(new System.Action(this.DeleteLines));
     }));
 }
Exemplo n.º 19
0
 private void OnBindingKeyDown(UIComponent comp, UIKeyEventParameter p)
 {
     if (this.m_EditingBinding != null && !this.IsModifierKey(p.keycode))
     {
         p.Use();
         UIView.PopModal();
         KeyCode  keycode  = p.keycode;
         InputKey inputKey = (p.keycode == KeyCode.Escape) ? this.m_EditingBinding.value : SavedInputKey.Encode(keycode, p.control, p.shift, p.alt);
         if (p.keycode == KeyCode.Backspace)
         {
             inputKey = SavedInputKey.Empty;
         }
         List <SavedInputKey> currentAssigned;
         if (!this.IsAlreadyBound(this.m_EditingBinding, inputKey, this.m_EditingBindingCategory, out currentAssigned))
         {
             this.m_EditingBinding.value = inputKey;
             UITextComponent uITextComponent = p.source as UITextComponent;
             uITextComponent.text          = this.m_EditingBinding.ToLocalizedString("KEYNAME");
             this.m_EditingBinding         = null;
             this.m_EditingBindingCategory = string.Empty;
         }
         else
         {
             string arg     = (currentAssigned.Count <= 1) ? Locale.Get("KEYMAPPING", currentAssigned[0].name) : Locale.Get("KEYMAPPING_MULTIPLE");
             string message = string.Format(Locale.Get("CONFIRM_REBINDKEY", "Message"), SavedInputKey.ToLocalizedString("KEYNAME", inputKey), arg);
             ConfirmPanel.ShowModal(Locale.Get("CONFIRM_REBINDKEY", "Title"), message, delegate(UIComponent c, int ret)
             {
                 if (ret == 1)
                 {
                     this.m_EditingBinding.value = inputKey;
                     for (int i = 0; i < currentAssigned.Count; i++)
                     {
                         currentAssigned[i].value = SavedInputKey.Empty;
                     }
                     this.RefreshKeyMapping();
                 }
                 UITextComponent uITextComponent2 = p.source as UITextComponent;
                 uITextComponent2.text            = this.m_EditingBinding.ToLocalizedString("KEYNAME");
                 this.m_EditingBinding            = null;
                 this.m_EditingBindingCategory    = string.Empty;
             });
         }
     }
 }
        private static void OnClickRemoveAllExistingTrafficLights()
        {
            if (!Options.IsGameLoaded())
            {
                return;
            }

            ConfirmPanel.ShowModal(T("Maintenance.Dialog.Title:Remove all traffic lights"),
                                   T("Maintenance.Dialog.Text:Remove all traffic lights, Confirmation"),
                                   (_, result) => {
                if (result != 1)
                {
                    return;
                }

                Log._Debug("Removing all existing Traffic Lights");
                Constants.ServiceFactory.SimulationService.AddAction(() => TrafficLightManager.Instance.RemoveAllExistingTrafficLights());
            });
        }
Exemplo n.º 21
0
        public static void ShowModal(string title, string desc, Action <bool> returnMethod)
        {
            var logic = ProceduralObjectsLogic.instance;

            if (logic == null)
            {
                return;
            }
            logic.generalShowUI = false;
            ConfirmPanel.ShowModal(title, desc, delegate(UIComponent comp, int r)
            {
                returnMethod.Invoke(r == 1);
                logic.generalShowUI = true;
                if (!UIView.HasFocus(logic.mainButton))
                {
                    UIView.SetFocus(logic.mainButton);
                }
            });
        }
Exemplo n.º 22
0
        private static void Show()
        {
            if (PlatformService.platformType != PlatformType.Steam)
            {
                UnityEngine.Debug.LogError("Cannot auto-subscribe CitiesHarmony on platforms other than Steam!");
                ShowError("Harmony could not be installed automatically because you are using a platform other than Steam.",
                          "You can manually download the Harmony mod from github.com/boformer/CitiesHarmony/releases");
                return;
            }

            if (PluginManager.noWorkshop)
            {
                UnityEngine.Debug.LogError("Cannot auto-subscribe CitiesHarmony in --noWorkshop mode!");
                ShowError("Harmony could not be installed automatically because you are playing in --noWorkshop mode!",
                          "Restart without --noWorkshop or manually download the Harmony mod from github.com/boformer/CitiesHarmony/releases");
                return;
            }

            if (!PlatformService.workshop.IsAvailable())
            {
                UnityEngine.Debug.LogError("Cannot auto-subscribe CitiesHarmony while workshop is not available");
                ShowError("Harmony could not be installed automatically because the Steam workshop is not available (no network connection?)",
                          "You can manually download the Harmony mod from github.com/boformer/CitiesHarmony/releases");
                return;
            }


            if (HarmonyHelper.IsCitiesHarmonyWorkshopItemSubscribed)
            {
                UnityEngine.Debug.LogError("CitiesHarmony workshop item is subscribed, but assembly is not loaded!");
                ShowError("It seems that Harmony has already been subscribed, but Steam failed to download the files correctly or they were deleted.",
                          "Close the game, then unsubscribe and resubscribe the Harmony workshop item from steamcommunity.com/sharedfiles/filedetails/?id=2040656402");
                return;
            }

            ConfirmPanel.ShowModal("Missing dependency: Harmony",
                                   "The dependency 'Harmony' is required for some mod(s) to work correctly. Do you want to subscribe to it in the Steam Workshop?",
                                   OnConfirm);

            UnityEngine.Debug.Log("Subscribing to CitiesHarmony workshop item!");
        }
Exemplo n.º 23
0
        private void CreateUI()
        {
            try
            {
                height           = 57f;
                width            = 310f;
                absolutePosition = new Vector3(Mathf.Floor((GetUIView().fixedWidth - width) / 2f), Mathf.Floor((GetUIView().fixedHeight - height) / 1.25f));
                isVisible        = false;

                _purchaseAllButton        = UIUtils.CreateButton(this, "PurchaseAllButton", "PURCHASE ALL FOR FREE");
                _purchaseAllButton.height = 57f;
                _purchaseAllButton.width  = 310f;
                _purchaseAllButton.anchor = UIAnchorStyle.CenterHorizontal;

                _purchaseAllButton.textScale        = 1.25f;
                _purchaseAllButton.useDropShadow    = true;
                _purchaseAllButton.dropShadowOffset = new Vector2(0f, -1.33f);
                _purchaseAllButton.eventClick      += (component, eventParam) =>
                {
                    if (!eventParam.used)
                    {
                        eventParam.Use();

                        ConfirmPanel.ShowModal("Confirmation", "Are you sure you wish to purchase all remaining tiles for free now?", delegate(UIComponent comp, int ret)
                        {
                            if (ret == 1)
                            {
                                isVisible = false;

                                PurchaseUtils.PurchaseAll();
                            }
                        });
                    }
                };
            }
            catch (Exception e)
            {
                Debug.Log("[Purchase It!] PurchasePanel:CreateUI -> Exception: " + e.Message);
            }
        }
 /// <summary>
 /// Checks a VehicleInfo for missing effects and prompts the user to remove them.
 /// </summary>
 /// <param name="vehicle">The vehicle to check.</param>
 private void CheckMissingEffects(VehicleInfo vehicle)
 {
     if (vehicle != null && vehicle.m_effects != null)
     {
         for (int i = 0; i < vehicle.m_effects.Length; i++)
         {
             if (vehicle.m_effects[i].m_effect == null)
             {
                 ConfirmPanel.ShowModal(Mod.name, "Detected missing effect on vehicle " + vehicle.name + ", do you want EAE to remove this for you? Click cancel to ignore this warning.", delegate(UIComponent comp, int ret)
                 {
                     if (ret == 1)
                     {
                         List <VehicleInfo.Effect> list = new List <VehicleInfo.Effect>();
                         list.AddRange(vehicle.m_effects);
                         list.RemoveAll(x => x.m_effect == null);
                         vehicle.m_effects = list.ToArray();
                     }
                 });
                 break;
             }
         }
     }
 }
Exemplo n.º 25
0
        private void Awake()
        {
            base.component.eventZOrderChanged += delegate(UIComponent c, int r)
            {
                this.SetBackgroundColor();
            };
            this.m_LineIsVisible = base.Find <UICheckBox>("LineVisible");
            this.m_LineIsVisible.eventCheckChanged += (x, y) => ChangeLineVisibility(y);
            this.m_LineColor = base.Find <UIColorField>("LineColor");
            this.m_LineColor.normalBgSprite             = "";
            this.m_LineColor.focusedBgSprite            = "";
            this.m_LineColor.hoveredBgSprite            = "";
            this.m_LineColor.width                      = 40;
            this.m_LineColor.height                     = 40;
            this.m_LineColor.atlas                      = TLMController.taLineNumber;
            this.m_LineNumberFormatted                  = this.m_LineColor.GetComponentInChildren <UIButton>();
            m_LineNumberFormatted.textScale             = 1.5f;
            m_LineNumberFormatted.useOutline            = true;
            this.m_LineColor.eventSelectedColorChanged += new PropertyChangedEventHandler <Color>(this.OnColorChanged);
            this.m_LineName                        = base.Find <UILabel>("LineName");
            this.m_LineNameField                   = this.m_LineName.Find <UITextField>("LineNameField");
            this.m_LineNameField.maxLength         = 256;
            this.m_LineNameField.eventTextChanged += new PropertyChangedEventHandler <string>(this.OnRename);
            this.m_LineName.eventMouseEnter       += delegate(UIComponent c, UIMouseEventParameter r)
            {
                this.m_LineName.backgroundSprite = "TextFieldPanelHovered";
            };
            this.m_LineName.eventMouseLeave += delegate(UIComponent c, UIMouseEventParameter r)
            {
                this.m_LineName.backgroundSprite = string.Empty;
            };
            this.m_LineName.eventClick += delegate(UIComponent c, UIMouseEventParameter r)
            {
                this.m_LineNameField.Show();
                this.m_LineNameField.text = this.m_LineName.text;
                this.m_LineNameField.Focus();
            };
            this.m_LineNameField.eventLeaveFocus += delegate(UIComponent c, UIFocusEventParameter r)
            {
                this.m_LineNameField.Hide();
                this.m_LineName.text = this.m_LineNameField.text;
            };


            this.m_DayLine               = base.Find <UICheckBox>("DayLine");
            this.m_NightLine             = base.Find <UICheckBox>("NightLine");
            this.m_DayNightLine          = base.Find <UICheckBox>("DayNightLine");
            m_DisabledLine               = GameObject.Instantiate(base.Find <UICheckBox>("DayLine"), m_DayLine.transform.parent);
            this.m_DayLine.eventClicked += delegate(UIComponent comp, UIMouseEventParameter c)
            {
                ushort lineID = this.m_LineID;
                if (Singleton <SimulationManager> .exists && lineID != 0)
                {
                    m_LineOperation = Singleton <SimulationManager> .instance.AddAction(delegate
                    {
                        changeLineTime(true, false);
                    });
                }
            };
            this.m_NightLine.eventClicked += delegate(UIComponent comp, UIMouseEventParameter c)
            {
                ushort lineID = this.m_LineID;
                if (Singleton <SimulationManager> .exists && lineID != 0)
                {
                    m_LineOperation = Singleton <SimulationManager> .instance.AddAction(delegate
                    {
                        changeLineTime(false, true);
                    });
                }
            };
            this.m_DayNightLine.eventClicked += delegate(UIComponent comp, UIMouseEventParameter c)
            {
                ushort lineID = this.m_LineID;
                if (Singleton <SimulationManager> .exists && lineID != 0)
                {
                    m_LineOperation = Singleton <SimulationManager> .instance.AddAction(delegate
                    {
                        changeLineTime(true, true);
                    });
                }
            };

            m_DisabledLine.eventClicked += delegate(UIComponent comp, UIMouseEventParameter c)
            {
                ushort lineID = this.m_LineID;
                if (Singleton <SimulationManager> .exists && lineID != 0)
                {
                    m_LineOperation = Singleton <SimulationManager> .instance.AddAction(delegate
                    {
                        changeLineTime(false, false);
                    });
                }
            };


            if (TLMSingleton.isIPTLoaded)
            {
                m_DisabledLine.isEnabled = false;
                m_DisabledLine.isVisible = false;
            }
            else
            {
                m_NightLine.relativePosition    = new Vector3(678, 8);
                m_DayNightLine.relativePosition = new Vector3(704, 8);
            }

            this.m_LineStops      = base.Find <UILabel>("LineStops");
            this.m_LinePassengers = base.Find <UILabel>("LinePassengers");

            var tsd = Singleton <T> .instance.GetTSD();

            this.m_LineVehicles = base.Find <UILabel>("LineVehicles");
            if (tsd.hasVehicles())
            {
                m_LineVehicles.relativePosition = new Vector3(m_LineVehicles.relativePosition.x, 5, 0);
                m_lineBudgetLabel = GameObject.Instantiate(this.m_LineStops, m_LineStops.transform.parent);
            }
            else
            {
                Destroy(m_LineVehicles.gameObject);
            }

            this.m_Background               = base.Find("Background");
            this.m_BackgroundColor          = this.m_Background.color;
            this.m_mouseIsOver              = false;
            base.component.eventMouseEnter += new MouseEventHandler(this.OnMouseEnter);
            base.component.eventMouseLeave += new MouseEventHandler(this.OnMouseLeave);
            base.Find <UIButton>("DeleteLine").eventClick += delegate(UIComponent c, UIMouseEventParameter r)
            {
                if (this.m_LineID != 0)
                {
                    ConfirmPanel.ShowModal("CONFIRM_LINEDELETE", delegate(UIComponent comp, int ret)
                    {
                        if (ret == 1)
                        {
                            Singleton <SimulationManager> .instance.AddAction(delegate
                            {
                                Singleton <TransportManager> .instance.ReleaseLine(this.m_LineID);
                                GameObject.Destroy(gameObject);
                            });
                        }
                    });
                }
            };
            base.Find <UIButton>("ViewLine").eventClick += delegate(UIComponent c, UIMouseEventParameter r)
            {
                if (this.m_LineID != 0)
                {
                    Vector3    position   = Singleton <NetManager> .instance.m_nodes.m_buffer[(int)Singleton <TransportManager> .instance.m_lines.m_buffer[(int)this.m_LineID].m_stops].m_position;
                    InstanceID instanceID = default(InstanceID);
                    instanceID.TransportLine = this.m_LineID;
                    TLMController.instance.lineInfoPanel.openLineInfo(lineID);
                    TLMController.instance.CloseTLMPanel();
                }
            };
            base.component.eventVisibilityChanged += delegate(UIComponent c, bool v)
            {
                if (v)
                {
                    this.RefreshData(true, true);
                }
            };

            //Auto color & Auto Name
            TLMUtils.createUIElement(out UIButton buttonAutoName, transform);
            buttonAutoName.pivot            = UIPivotPoint.TopRight;
            buttonAutoName.relativePosition = new Vector3(164, 2);
            buttonAutoName.text             = "A";
            buttonAutoName.textScale        = 0.6f;
            buttonAutoName.width            = 15;
            buttonAutoName.height           = 15;
            buttonAutoName.tooltip          = Locale.Get("TLM_AUTO_NAME_SIMPLE_BUTTON_TOOLTIP");
            TLMUtils.initButton(buttonAutoName, true, "ButtonMenu");
            buttonAutoName.name        = "AutoName";
            buttonAutoName.isVisible   = true;
            buttonAutoName.eventClick += (component, eventParam) =>
            {
                DoAutoName();
            };

            TLMUtils.createUIElement(out UIButton buttonAutoColor, transform);
            buttonAutoColor.pivot            = UIPivotPoint.TopRight;
            buttonAutoColor.relativePosition = new Vector3(90, 2);
            buttonAutoColor.text             = "A";
            buttonAutoColor.textScale        = 0.6f;
            buttonAutoColor.width            = 15;
            buttonAutoColor.height           = 15;
            buttonAutoColor.tooltip          = Locale.Get("TLM_AUTO_COLOR_SIMPLE_BUTTON_TOOLTIP");
            TLMUtils.initButton(buttonAutoColor, true, "ButtonMenu");
            buttonAutoColor.name        = "AutoColor";
            buttonAutoColor.isVisible   = true;
            buttonAutoColor.eventClick += (component, eventParam) =>
            {
                DoAutoColor();
            };

            m_lineIncompleteWarning = base.Find <UIPanel>("WarningIncomplete");

            if (tsd.hasVehicles())
            {
                TLMUtils.createUIElement(out m_perHourBudgetInfo, transform);
                m_perHourBudgetInfo.name              = "PerHourIndicator";
                m_perHourBudgetInfo.autoSize          = false;
                m_perHourBudgetInfo.autoHeight        = true;
                m_perHourBudgetInfo.anchor            = UIAnchorStyle.CenterHorizontal | UIAnchorStyle.CenterVertical;
                m_perHourBudgetInfo.width             = 180;
                m_perHourBudgetInfo.height            = m_perHourBudgetInfo.parent.height;
                m_perHourBudgetInfo.verticalAlignment = UIVerticalAlignment.Middle;
                m_perHourBudgetInfo.textAlignment     = UIHorizontalAlignment.Center;
                m_perHourBudgetInfo.textScale         = 1f;
                m_perHourBudgetInfo.localeID          = "TLM_PER_HOUR_BUDGET_ACTIVE_LABEL";
                m_perHourBudgetInfo.wordWrap          = true;
                m_perHourBudgetInfo.eventTextChanged += constraintedScale;
                constraintedScale(m_perHourBudgetInfo, "");
            }
        }
Exemplo n.º 26
0
        internal void SetupControls()
        {
            float offset = 40f;

            // Title Bar
            m_title            = AddUIComponent <UITitleBar>();
            m_title.iconSprite = "InfoIconTrafficCongestion";
            m_title.title      = AVOMod.ModName + " " + AVOMod.Version;

            // Category DropDown
            UILabel label = AddUIComponent <UILabel>();

            label.textScale        = 0.8f;
            label.padding          = new RectOffset(0, 0, 8, 0);
            label.relativePosition = new Vector3(10f, offset);
            label.text             = Translations.Translate("AVO_MOD_MP56");

            m_category       = UIUtils.CreateDropDown(this);
            m_category.width = 175;

            for (int i = 0; i < categoryList.Length; i++)
            {
                m_category.AddItem(categoryList[i]);
            }

            m_category.selectedIndex    = 0;
            m_category.tooltip          = Translations.Translate("AVO_MOD_MP39");
            m_category.relativePosition = label.relativePosition + new Vector3(75f, 0f);

            m_category.eventSelectedIndexChanged += (c, t) =>
            {
                m_category.enabled = false;
                PopulateList();
                m_category.enabled = true;
            };

            // Search
            m_search                  = UIUtils.CreateTextField(this);
            m_search.width            = 145f;
            m_search.height           = 30f;
            m_search.padding          = new RectOffset(6, 6, 6, 6);
            m_search.tooltip          = Translations.Translate("AVO_MOD_MP40");
            m_search.relativePosition = new Vector3(WIDTHLEFT - m_search.width, offset);

            m_search.eventTextChanged += (c, t) => PopulateList();

            label                  = AddUIComponent <UILabel>();
            label.textScale        = 0.8f;
            label.padding          = new RectOffset(0, 0, 8, 0);
            label.relativePosition = m_search.relativePosition - new Vector3(60f, 0f);
            label.text             = Translations.Translate("AVO_MOD_MP55");

            // FastList
            m_fastList = UIFastList.Create <UIVehicleItem>(this);
            m_fastList.backgroundSprite = "UnlockingPanel";
            m_fastList.width            = WIDTHLEFT - 5;
            m_fastList.height           = height - offset - 110;
            m_fastList.canSelect        = true;
            m_fastList.relativePosition = new Vector3(5, offset + 35);

            // Configuration file buttons
            UILabel configLabel = this.AddUIComponent <UILabel>();

            configLabel.text             = Translations.Translate("AVO_MOD_MP41");
            configLabel.textScale        = 0.8f;
            configLabel.relativePosition = new Vector3(16, height - 65);

            m_import                  = UIUtils.CreateButton(this);
            m_import.text             = Translations.Translate("AVO_MOD_MP42");
            m_import.width            = 80;
            m_import.tooltip          = Translations.Translate("AVO_MOD_MP43");
            m_import.relativePosition = new Vector3(10, height - 45);

            m_export                  = UIUtils.CreateButton(this);
            m_export.text             = Translations.Translate("AVO_MOD_MP44");
            m_export.width            = 80;
            m_export.tooltip          = Translations.Translate("AVO_MOD_MP45");
            m_export.relativePosition = new Vector3(95, height - 45);

            m_resetall                  = UIUtils.CreateButton(this);
            m_resetall.text             = Translations.Translate("AVO_MOD_MP46");
            m_resetall.width            = 80;
            m_resetall.tooltip          = Translations.Translate("AVO_MOD_MP47");
            m_resetall.relativePosition = new Vector3(180, height - 45);

            m_autosave                  = AddUIComponent <UILabel>();
            m_autosave.textScale        = 0.6f;
            m_autosave.text             = Translations.Translate("AVO_MOD_MP48");
            m_autosave.relativePosition = new Vector3(275, height - 40);
            m_autosave.autoSize         = true;
            m_autosave.textAlignment    = UIHorizontalAlignment.Center;
            m_autosave.textColor        = Color.green;
            m_autosave.tooltip          = Translations.Translate("AVO_MOD_MP49");
            m_autosave.isVisible        = AdvancedVehicleOptions.AutoSaveVehicleConfig;

            // Preview
            UIPanel panel = AddUIComponent <UIPanel>();

            panel.backgroundSprite = "GenericPanel";
            panel.width            = WIDTHRIGHT - 10;
            panel.height           = HEIGHT - 420;
            panel.relativePosition = new Vector3(WIDTHLEFT + 5, offset);

            m_preview                  = panel.AddUIComponent <UITextureSprite>();
            m_preview.size             = panel.size;
            m_preview.relativePosition = Vector3.zero;

            m_previewRenderer      = gameObject.AddComponent <PreviewRenderer>();
            m_previewRenderer.size = m_preview.size * 2; // Twice the size for anti-aliasing

            m_preview.texture = m_previewRenderer.texture;

            // Follow a vehicle
            if (m_cameraController != null)
            {
                m_followVehicle                  = AddUIComponent <UISprite>();
                m_followVehicle.spriteName       = "LocationMarkerFocused";
                m_followVehicle.width            = m_followVehicle.spriteInfo.width;
                m_followVehicle.height           = m_followVehicle.spriteInfo.height;
                m_followVehicle.tooltip          = Translations.Translate("AVO_MOD_MP50");
                m_followVehicle.relativePosition = new Vector3(panel.relativePosition.x + panel.width - m_followVehicle.width - 5, panel.relativePosition.y + 5);

                m_followVehicle.eventClick += (c, p) => FollowNextVehicle();
            }

            //Remove the followed vehicle
            {
                m_removeVehicle = AddUIComponent <UISprite>();
                m_removeVehicle.Hide();
                m_removeVehicle.spriteName       = "IconPolicyOldTown";
                m_removeVehicle.width            = m_removeVehicle.spriteInfo.width - 12;
                m_removeVehicle.height           = m_removeVehicle.spriteInfo.height - 12;
                m_removeVehicle.tooltip          = Translations.Translate("AVO_MOD_MP51");
                m_removeVehicle.relativePosition = new Vector3(panel.relativePosition.x + panel.width - m_removeVehicle.width - 33, panel.relativePosition.y + 7);

                m_removeVehicle.eventClick += (c, p) => RemoveThisVehicle();
            }

            // Option panel
            m_optionPanel = AddUIComponent <UIOptionPanel>();
            m_optionPanel.relativePosition = new Vector3(WIDTHLEFT, height - 370);

            // Event handlers
            m_fastList.eventSelectedIndexChanged  += OnSelectedItemChanged;
            m_optionPanel.eventEnableCheckChanged += OnEnableStateChanged;

            m_import.eventClick += (c, t) =>
            {
                DefaultOptions.RestoreAll();
                AdvancedVehicleOptions.ImportVehicleDataConfig();
                optionList = AdvancedVehicleOptions.config.options;
            };

            m_export.eventClick += (c, t) => AdvancedVehicleOptions.ExportVehicleDataConfig(true);

            m_resetall.eventClick += (c, t) =>
            {
                ConfirmPanel.ShowModal(Translations.Translate("AVO_MOD_MP52"), Translations.Translate("AVO_MOD_MP53"), (comp, ret) =>
                {
                    if (ret != 1)
                    {
                        return;
                    }

                    DefaultOptions.RestoreAll();
                    AdvancedVehicleOptions.ResetVehicleDataConfig();
                    optionList = AdvancedVehicleOptions.config.options;

                    ExceptionPanel resetpanel = UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel");
                    resetpanel.SetMessage("Advanced Vehicle Options", Translations.Translate("AVO_MOD_MP54"), false);
                });
            };

            panel.eventMouseDown += (c, p) =>
            {
                eventMouseMove += RotateCamera;
                if (m_optionPanel.m_options != null && m_optionPanel.m_options.useColorVariations)
                {
                    m_previewRenderer.RenderVehicle(m_optionPanel.m_options.prefab, m_previewColor);
                }
                else
                {
                    m_previewRenderer.RenderVehicle(m_optionPanel.m_options.prefab);
                }
            };

            panel.eventMouseUp += (c, p) =>
            {
                eventMouseMove -= RotateCamera;
                if (m_optionPanel.m_options != null && m_optionPanel.m_options.useColorVariations)
                {
                    m_previewRenderer.RenderVehicle(m_optionPanel.m_options.prefab, m_previewColor);
                }
                else
                {
                    m_previewRenderer.RenderVehicle(m_optionPanel.m_options.prefab);
                }
            };

            panel.eventMouseWheel += (c, p) =>
            {
                m_previewRenderer.zoom -= Mathf.Sign(p.wheelDelta) * 0.25f;
                if (m_optionPanel.m_options != null && m_optionPanel.m_options.useColorVariations)
                {
                    m_previewRenderer.RenderVehicle(m_optionPanel.m_options.prefab, m_previewColor);
                }
                else
                {
                    m_previewRenderer.RenderVehicle(m_optionPanel.m_options.prefab);
                }
            };
        }
Exemplo n.º 27
0
        private void CreateComponents()
        {
            int headerHeight = 40;

            // Label
            UILabel label = AddUIComponent <UILabel>();

            label.text             = "Save Asset";
            label.relativePosition = new Vector3(WIDTH / 2 - label.width / 2, 10);

            // Drag handle
            UIDragHandle handle = AddUIComponent <UIDragHandle>();

            handle.target            = this;
            handle.constrainToScreen = true;
            handle.width             = WIDTH;
            handle.height            = headerHeight;
            handle.relativePosition  = Vector3.zero;

            // Fields
            label                           = AddUIComponent <UILabel>();
            label.text                      = "Package name:";
            label.relativePosition          = new Vector3(10, headerHeight + 15);
            m_packageField                  = UIUtils.CreateTextField(this);
            m_packageField.width            = 400;
            m_packageField.relativePosition = new Vector3(20 + label.width, headerHeight + 10);

            // Fields
            label                        = AddUIComponent <UILabel>();
            label.text                   = "Asset name:";
            label.relativePosition       = new Vector3(10, headerHeight + 45);
            m_nameField                  = UIUtils.CreateTextField(this);
            m_nameField.width            = 400;
            m_nameField.relativePosition = new Vector3(m_packageField.relativePosition.x, headerHeight + 40);


            // Naming dropdown menu
            label                  = AddUIComponent <UILabel>();
            label.text             = "Trailer naming:";
            label.relativePosition = new Vector3(m_nameField.relativePosition.x + m_nameField.width + 20, headerHeight + 10);
            m_namingDropdown       = UIUtils.CreateDropDown(this);
            m_namingDropdown.text  = "Trailer naming convention";
            m_namingDropdown.AddItem("Package name (TrailerPackageName0)");     //0
            m_namingDropdown.AddItem("Default (Trailer0)");                     //1
            m_namingDropdown.selectedIndex    = 0;
            m_namingDropdown.width            = 300;
            m_namingDropdown.relativePosition = new Vector3(m_nameField.relativePosition.x + m_nameField.width + 20, headerHeight + 35);


            // Save button
            m_saveButton               = UIUtils.CreateButton(this);
            m_saveButton.text          = "Save";
            m_saveButton.textScale     = 1.3f;
            m_saveButton.width         = 153f;
            m_saveButton.height        = 47f;
            m_saveButton.eventClicked += (c, b) =>
            {
                string assetName   = m_nameField.text.Trim();
                string packageName = m_packageField.text.Trim();
                string file        = GetSavePathName(packageName);
                if (!File.Exists(file))
                {
                    SaveAsset(assetName, packageName);
                }
                else
                {
                    ConfirmPanel.ShowModal("CONFIRM_SAVEOVERRIDE", delegate(UIComponent comp, int ret)
                    {
                        if (ret == 1)
                        {
                            SaveAsset(assetName, packageName);
                        }
                    });
                }
            };
            m_saveButton.relativePosition = new Vector3(WIDTH / 2 - m_saveButton.width - 50, HEIGHT - m_saveButton.height - 10);

            // Cancel button
            m_cancelButton               = UIUtils.CreateButton(this);
            m_cancelButton.text          = "Cancel";
            m_cancelButton.textScale     = 1.3f;
            m_cancelButton.width         = 153f;
            m_cancelButton.height        = 47f;
            m_cancelButton.eventClicked += (c, b) =>
            {
                m_info    = null;
                isVisible = false;
            };
            m_cancelButton.relativePosition = new Vector3(WIDTH / 2 + 50, HEIGHT - m_cancelButton.height - 10);

            // Snapshot container
            GameObject go = GameObject.Find("SnapshotContainer");

            if (go != null)
            {
                m_snapshotContainer = GameObject.Instantiate <UIPanel>(go.GetComponent <UIPanel>());
                m_snapshotContainer.transform.SetParent(transform);
                m_snapshotSprite             = m_snapshotContainer.Find <UITextureSprite>("SnapShot");
                m_snapshotLabel              = m_snapshotContainer.Find <UILabel>("CurrentSnapShot");
                m_snapshotPrev               = m_snapshotContainer.Find <UIButton>("Previous");
                m_snapshotPrev.eventClicked += (c, b) =>
                {
                    OnPreviousSnapshot();
                };
                m_snapshotNext = m_snapshotContainer.Find <UIButton>("Next");
                m_snapshotNext.eventClicked += (c, b) =>
                {
                    OnNextSnapshot();
                };
            }
        }
Exemplo n.º 28
0
        private void OnBindingKeyDown(UIComponent comp, UIKeyEventParameter e)
        {
            var key = e.keycode;

            if (_editingBinding == null || KeyHelper.IsModifierKey(key))
            {
                return;
            }

            e.Use();
            UIView.PopModal();

            InputKey newKey;

            switch (key)
            {
            case KeyCode.Backspace:
                newKey = SavedInputKey.Empty;
                break;

            case KeyCode.Escape:
                newKey = _editingBinding.value;
                break;

            default:
                newKey = SavedInputKey.Encode(key, e.control, e.shift, e.alt);
                break;
            }

            if (IsAlreadyBound(_editingBinding, newKey, out var currentAssigned))
            {
                var text = currentAssigned.Count <= 1
          ? (
                    Locale.Exists("KEYMAPPING", currentAssigned[0].name)
              ? Locale.Get("KEYMAPPING", currentAssigned[0].name)
              : Options.GetShortcutName(currentAssigned[0].name)
                    )
          : Locale.Get("KEYMAPPING_MULTIPLE");
                var message = StringUtils.SafeFormat(Locale.Get("CONFIRM_REBINDKEY", "Message"),
                                                     SavedInputKey.ToLocalizedString("KEYNAME", newKey), text);

                ConfirmPanel.ShowModal(Locale.Get("CONFIRM_REBINDKEY", "Title"), message, (c, ret) =>
                {
                    var btn = (UIButton)comp;
                    if (ret == 1)
                    {
                        _editingBinding.value = newKey;
                        foreach (var asigned in currentAssigned)
                        {
                            asigned.value = SavedInputKey.Empty;
                        }
                        UpdateKeyBinding(newKey, btn, false);
                        RefreshKeyMapping();
                    }
                    _editingBinding = null;
                    btn.text        = ((SavedInputKey)btn.objectUserData).ToLocalizedString("KEYNAME");
                });
            }
            else
            {
                UpdateKeyBinding(newKey, (UIButton)comp, false);
            }
        }
Exemplo n.º 29
0
        public override void Awake()
        {
            height = 46;

            fileNameLabel                   = AddUIComponent <UILabel>();
            fileNameLabel.textScale         = 0.9f;
            fileNameLabel.autoSize          = false;
            fileNameLabel.height            = 30;
            fileNameLabel.verticalAlignment = UIVerticalAlignment.Middle;
            fileNameLabel.relativePosition  = new Vector3(8, 8);

            deleteButton                  = UIUtils.CreateButton(this);
            deleteButton.name             = "MoveIt_DeleteFileButton";
            deleteButton.text             = "X";
            deleteButton.size             = new Vector2(40f, 30f);
            deleteButton.relativePosition = new Vector3((UISaveWindow.instance != null ? 430 : 510) - deleteButton.width - 8, 8);
            deleteButton.tooltip          = Str.xml_DeleteLabel;

            saveLoadButton                  = UIUtils.CreateButton(this);
            saveLoadButton.name             = "MoveIt_SaveLoadFileButton";
            saveLoadButton.text             = UISaveWindow.instance != null ? Str.xml_Export : Str.xml_Import;
            saveLoadButton.size             = new Vector2(80f, 30f);
            saveLoadButton.relativePosition = new Vector3(deleteButton.relativePosition.x - saveLoadButton.width - 8, 8);

            if (UISaveWindow.instance == null) // Importing
            {
                loadToPosition                  = UIUtils.CreateButton(this);
                loadToPosition.name             = "MoveIt_loadToPosition";
                loadToPosition.text             = Str.xml_Restore;
                loadToPosition.tooltip          = Str.xml_Restore_Tooltip;
                loadToPosition.size             = new Vector2(80f, 30f);
                loadToPosition.relativePosition = new Vector3(saveLoadButton.relativePosition.x - loadToPosition.width - 8, 8);

                loadToPosition.eventClicked += (c, p) =>
                {
                    UIView.Find("DefaultTooltip")?.Hide();
                    UILoadWindow.Close();
                    Destroy(loadToPosition);
                    MoveItTool.instance.Restore(fileNameLabel.text);
                };
            }
            else
            {
                loadToPosition = null;
            }

            saveLoadButton.eventClicked += (c, p) =>
            {
                UIView.Find("DefaultTooltip")?.Hide();
                if (UISaveWindow.instance != null)
                {
                    UISaveWindow.Export(fileNameLabel.text);
                }
                else
                {
                    UILoadWindow.Close();
                    MoveItTool.instance.Import(fileNameLabel.text);
                }
            };

            deleteButton.eventClicked += (c, p) =>
            {
                ConfirmPanel.ShowModal(Str.xml_DeleteConfirmTitle, String.Format(Str.xml_DeleteConfirmMessage, fileNameLabel.text), (comp, ret) =>
                {
                    if (ret == 1)
                    {
                        MoveItTool.instance.Delete(fileNameLabel.text);

                        if (UISaveWindow.instance != null)
                        {
                            UISaveWindow.instance.RefreshFileList();
                        }
                        else
                        {
                            UILoadWindow.instance.RefreshFileList();
                        }
                    }
                });
            };

            if (UISaveWindow.instance == null) // Importing
            {
                fileNameLabel.width = loadToPosition.relativePosition.x - 16f;
            }
            else
            {
                fileNameLabel.width = saveLoadButton.relativePosition.x - 16f;
            }
        }
Exemplo n.º 30
0
        private void SetupControls()
        {
            // Title Bar
            m_title            = AddUIComponent <UITitleBar>();
            m_title.title      = "Theme Manager";
            m_title.iconSprite = "ToolbarIconZoomOutCity";

            // Filter
            m_filter                  = AddUIComponent <UIBuildingFilter>();
            m_filter.width            = width - SPACING * 2;
            m_filter.height           = 70;
            m_filter.relativePosition = new Vector3(SPACING, TITLE_HEIGHT);

            m_filter.eventFilteringChanged += (c, i) =>
            {
                if (m_themeSelection != null && m_themeSelection.selectedIndex != -1)
                {
                    Configuration.Theme theme = m_themeSelection.selectedItem as Configuration.Theme;
                    m_buildingSelection.selectedIndex = -1;
                    m_buildingSelection.rowsData      = Filter(m_themes[theme]);
                }
            };

            // Panels
            UIPanel left = AddUIComponent <UIPanel>();

            left.width            = LEFT_WIDTH;
            left.height           = HEIGHT - m_filter.height;
            left.relativePosition = new Vector3(SPACING, TITLE_HEIGHT + m_filter.height + SPACING);

            UIPanel middle = AddUIComponent <UIPanel>();

            middle.width            = MIDDLE_WIDTH;
            middle.height           = HEIGHT - m_filter.height;
            middle.relativePosition = new Vector3(LEFT_WIDTH + SPACING * 2, TITLE_HEIGHT + m_filter.height + SPACING);

            UIPanel right = AddUIComponent <UIPanel>();

            right.width            = RIGHT_WIDTH;
            right.height           = HEIGHT - m_filter.height;
            right.relativePosition = new Vector3(LEFT_WIDTH + MIDDLE_WIDTH + SPACING * 3, TITLE_HEIGHT + m_filter.height + SPACING);

            // Theme selection
            m_themeSelection = UIFastList.Create <UIThemeItem>(left);

            m_themeSelection.backgroundSprite  = "UnlockingPanel";
            m_themeSelection.width             = left.width;
            m_themeSelection.height            = left.height - 40;
            m_themeSelection.canSelect         = true;
            m_themeSelection.rowHeight         = 40;
            m_themeSelection.autoHideScrollbar = true;
            m_themeSelection.relativePosition  = Vector3.zero;

            m_themeSelection.rowsData.m_buffer = m_themes.Keys.ToArray();
            m_themeSelection.rowsData.m_size   = m_themeSelection.rowsData.m_buffer.Length;
            m_themeSelection.DisplayAt(0);

            m_themeSelection.eventSelectedIndexChanged += (c, i) =>
            {
                if (i == -1)
                {
                    return;
                }

                int   listCount = m_buildingSelection.rowsData.m_size;
                float pos       = m_buildingSelection.listPosition;

                Configuration.Theme theme = m_themeSelection.selectedItem as Configuration.Theme;
                m_buildingSelection.selectedIndex = -1;
                m_buildingSelection.rowsData      = Filter(m_themes[theme]);

                if (m_filter.buildingStatus == Status.All && m_buildingSelection.rowsData.m_size == listCount)
                {
                    m_buildingSelection.DisplayAt(pos);
                }

                m_themeRemove.isEnabled = !((Configuration.Theme)m_themeSelection.selectedItem).isBuiltIn;
            };

            // Add theme
            m_themeAdd                  = UIUtils.CreateButton(left);
            m_themeAdd.width            = (LEFT_WIDTH - SPACING) / 2;
            m_themeAdd.text             = "New Theme";
            m_themeAdd.relativePosition = new Vector3(0, m_themeSelection.height + SPACING);

            m_themeAdd.eventClick += (c, p) =>
            {
                UIView.PushModal(UINewThemeModal.instance);
                UINewThemeModal.instance.Show(true);
            };

            // Remove theme
            m_themeRemove                  = UIUtils.CreateButton(left);
            m_themeRemove.width            = (LEFT_WIDTH - SPACING) / 2;
            m_themeRemove.text             = "Delete Theme";
            m_themeRemove.isEnabled        = false;
            m_themeRemove.relativePosition = new Vector3(LEFT_WIDTH - m_themeRemove.width, m_themeSelection.height + SPACING);

            m_themeRemove.eventClick += (c, p) =>
            {
                ConfirmPanel.ShowModal("Delete Theme", "Are you sure you want to delete '" + selectedTheme.name + "' theme ?",
                                       (d, i) => { if (i == 1)
                                                   {
                                                       DeleteTheme(selectedTheme);
                                                   }
                                       });
            };

            // Building selection
            m_buildingSelection = UIFastList.Create <UIBuildingItem>(middle);

            m_buildingSelection.backgroundSprite  = "UnlockingPanel";
            m_buildingSelection.width             = middle.width;
            m_buildingSelection.height            = middle.height - 40;
            m_buildingSelection.canSelect         = true;
            m_buildingSelection.rowHeight         = 40;
            m_buildingSelection.autoHideScrollbar = true;
            m_buildingSelection.relativePosition  = Vector3.zero;

            m_buildingSelection.rowsData = new FastList <object>();

            m_buildingSelection.eventSelectedIndexChanged += (c, i) =>
            {
                m_cloneBuilding.isEnabled = selectedBuilding != null && selectedBuilding.prefab != null;

                if (selectedBuilding != null && selectedBuilding.isCloned)
                {
                    BuildingItem item = GetBuildingItem(selectedBuilding.building.baseName);
                    m_cloneBuilding.isEnabled = item != null && item.prefab != null;
                }
            };

            m_buildingSelection.eventMouseLeave += (c, p) =>
            {
                UpdateBuildingInfo(selectedBuilding);
            };

            // Include buttons
            m_includeNone                  = UIUtils.CreateButton(middle);
            m_includeNone.width            = 55;
            m_includeNone.text             = "None";
            m_includeNone.relativePosition = new Vector3(MIDDLE_WIDTH - m_includeNone.width, m_buildingSelection.height + SPACING);

            m_includeAll                  = UIUtils.CreateButton(middle);
            m_includeAll.width            = 55;
            m_includeAll.text             = "All";
            m_includeAll.relativePosition = new Vector3(m_includeNone.relativePosition.x - m_includeAll.width - SPACING, m_buildingSelection.height + SPACING);

            UILabel include = middle.AddUIComponent <UILabel>();

            include.width            = 100;
            include.padding          = new RectOffset(0, 0, 8, 0);
            include.textScale        = 0.8f;
            include.text             = "Include:";
            include.relativePosition = new Vector3(m_includeAll.relativePosition.x - include.width - SPACING, m_buildingSelection.height + SPACING);

            m_includeAll.eventClick += (c, p) =>
            {
                for (int i = 0; i < m_buildingSelection.rowsData.m_size; i++)
                {
                    BuildingItem item = m_buildingSelection.rowsData[i] as BuildingItem;
                    if (item != null)
                    {
                        ChangeBuildingStatus(item, true);
                    }
                }

                m_buildingSelection.Refresh();
            };

            m_includeNone.eventClick += (c, p) =>
            {
                for (int i = 0; i < m_buildingSelection.rowsData.m_size; i++)
                {
                    BuildingItem item = m_buildingSelection.rowsData[i] as BuildingItem;
                    if (item != null)
                    {
                        ChangeBuildingStatus(item, false);
                    }
                }

                m_buildingSelection.Refresh();
            };

            // Preview
            m_buildingPreview                  = right.AddUIComponent <UIBuildingPreview>();
            m_buildingPreview.width            = right.width;
            m_buildingPreview.height           = (right.height - SPACING) / 2;
            m_buildingPreview.relativePosition = Vector3.zero;

            // Building Options
            m_buildingOptions                  = right.AddUIComponent <UIBuildingOptions>();
            m_buildingOptions.width            = RIGHT_WIDTH;
            m_buildingOptions.height           = (right.height - SPACING) / 2 - 40;
            m_buildingOptions.relativePosition = new Vector3(0, m_buildingPreview.height + SPACING);

            // Clone building
            m_cloneBuilding                  = UIUtils.CreateButton(right);
            m_cloneBuilding.width            = RIGHT_WIDTH;
            m_cloneBuilding.height           = 30;
            m_cloneBuilding.text             = "Clone building";
            m_cloneBuilding.isEnabled        = false;
            m_cloneBuilding.relativePosition = new Vector3(0, m_buildingOptions.relativePosition.y + m_buildingOptions.height + SPACING);

            m_cloneBuilding.eventClick += (c, p) =>
            {
                UIView.PushModal(UICloneBuildingModal.instance);
                UICloneBuildingModal.instance.Show(true);
            };
        }