Exemplo n.º 1
0
        public static UITitle CreateTitle(UIComponent parent, string text, Vector2 size, MouseEventHandler onClose = null)
        {
            UITitle titleContainer = parent.AddUIComponent <UITitle>();

            titleContainer.transform.parent        = parent.transform;
            titleContainer.transform.localPosition = Vector2.zero;
            titleContainer.relativePosition        = Vector2.zero;

            UILabel lbl = CreateLabel(titleContainer, text);

            lbl.relativePosition = new Vector2(size.x / 2 - lbl.width / 2, size.y / 2 - lbl.height / 2);
            titleContainer.label = lbl;

            UIDragHandle dragHandle = CreateDragHandle(parent, size);

            titleContainer.dragHandle = dragHandle;

            if (onClose != null)
            {
                UIButton closeButton = CreateCloseButton(titleContainer, new Vector2(size.y - 6, size.y - 6));
                closeButton.relativePosition = new Vector2(size.x - closeButton.width - 3, 3);
                closeButton.eventClicked    += onClose;
                dragHandle.width             = dragHandle.width - closeButton.width - 6;
            }

            return(titleContainer);
        }
Exemplo n.º 2
0
        private void SetupControls()
        {
            name             = "CustomizeItTitleBar";
            isVisible        = false;
            canFocus         = true;
            isInteractive    = true;
            relativePosition = Vector3.zero;
            width            = parent.width;
            height           = 40f;

            dragHandle                  = AddUIComponent <UIDragHandle>();
            dragHandle.height           = height;
            dragHandle.relativePosition = Vector3.zero;
            dragHandle.target           = parent;

            titleLabel               = AddUIComponent <UILabel>();
            titleLabel.text          = CustomizeIt.instance.CurrentBuilding.GetUncheckedLocalizedTitle();
            titleLabel.textScale     = 0.9f;
            titleLabel.isInteractive = false;

            closeButton                  = AddUIComponent <UIButton>();
            closeButton.size             = new Vector2(20, 20);
            closeButton.relativePosition = new Vector3(width - closeButton.width - 10f, 10f);
            closeButton.normalBgSprite   = "DeleteLineButton";
            closeButton.hoveredBgSprite  = "DeleteLineButtonHovered";
            closeButton.pressedBgSprite  = "DeleteLineButtonPressed";
            closeButton.eventClick      += (component, param) =>
            {
                CustomizeIt.instance.CustomizePanel.isVisible = false;
                UIUtil.DestroyDeeply(CustomizeIt.instance.CustomizePanel);
            };
        }
Exemplo n.º 3
0
        private void CreateUI()
        {
            try
            {
                name             = "WatchItWarningsPanel";
                backgroundSprite = "MenuPanel2";
                isVisible        = false;
                canFocus         = true;
                isInteractive    = true;
                width            = 750f;
                height           = 650f;
                relativePosition = new Vector3(Mathf.Floor((GetUIView().fixedWidth - width) / 2f), Mathf.Floor((GetUIView().fixedHeight - height) / 2f));

                _title      = UIUtils.CreateMenuPanelTitle(this, "Game Warnings - Overview");
                _close      = UIUtils.CreateMenuPanelCloseButton(this);
                _dragHandle = UIUtils.CreateMenuPanelDragHandle(this);

                _lastUpdated                   = UIUtils.CreateLabel(this, "UpdateTime", "Updated: Never");
                _lastUpdated.textScale         = 0.7f;
                _lastUpdated.textAlignment     = UIHorizontalAlignment.Right;
                _lastUpdated.verticalAlignment = UIVerticalAlignment.Middle;
                _lastUpdated.relativePosition  = new Vector3(30f, height - 38f);

                CreateWarningItems();
            }
            catch (Exception e)
            {
                Debug.Log("[Watch It!] WarningsPanel:CreateUI -> Exception: " + e.Message);
            }
        }
Exemplo n.º 4
0
        public override void Start()
        {
            base.Start();

            width  = parent.width;
            height = Constants.UITitleBarHeight;

            icon                  = AddUIComponent <UISprite>();
            icon.atlas            = ResourceLoader.ForestBrushAtlas;
            icon.spriteName       = ResourceLoader.ForestBrushNormal;
            icon.relativePosition = new Vector3(5f, 5f);
            icon.size             = new Vector2(28f, 32f);

            titleLabel                  = AddUIComponent <UILabel>();
            titleLabel.text             = Translation.Instance.GetTranslation("FOREST-BRUSH-MODNAME");
            titleLabel.textScale        = Constants.UITitleTextScale;
            titleLabel.relativePosition = new Vector3((width - titleLabel.width) / 2f, (Constants.UITitleBarHeight - titleLabel.height) / 2f);

            dragHandle                  = AddUIComponent <UIDragHandle>();
            dragHandle.size             = new Vector2(width, Constants.UITitleBarHeight);
            dragHandle.relativePosition = Vector3.zero;
            dragHandle.target           = parent;
            dragHandle.eventMouseUp    += DragHandle_eventMouseUp;

            closeButton                  = AddUIComponent <UIButton>();
            closeButton.atlas            = ResourceLoader.Atlas;
            closeButton.size             = new Vector2(20f, 20f);
            closeButton.relativePosition = new Vector3(width - closeButton.width - Constants.UISpacing, Constants.UISpacing);
            closeButton.normalBgSprite   = ResourceLoader.DeleteLineButton;
            closeButton.hoveredBgSprite  = ResourceLoader.DeleteLineButtonHovered;
            closeButton.pressedBgSprite  = ResourceLoader.DeleteLineButtonPressed;
            closeButton.eventClick      += CloseButton_eventClick;
        }
Exemplo n.º 5
0
        void CreateComponents()
        {
            int          headerHeight = 40;
            UIHelperBase uiHelper     = new UIHelper(this);

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

            label.text             = "Prop Thingy";
            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;

            // Vehicle import button
            m_vehicleButton                  = UIUtils.CreateButton(this);
            m_vehicleButton.text             = "Import Vehicle";
            m_vehicleButton.width            = WIDTH - 20;
            m_vehicleButton.relativePosition = new Vector3(10, headerHeight + 10);
            m_vehicleButton.eventClicked    += (c, b) =>
            {
                ImportVehicle();
            };
        }
        /// <summary>Creates a draggable label with current unit (mph or km/h).</summary>
        /// <param name="builder">The UI builder to use.</param>
        private void SetupControls_TitleBar(UBuilder builder)
        {
            string unitTitle = string.Format(
                format: "{0} - {1}",
                Translation.SpeedLimits.Get("Window.Title:Speed Limits"),
                GlobalConfig.Instance.Main.DisplaySpeedLimitsMph
                    ? Translation.SpeedLimits.Get("Miles per hour")
                    : Translation.SpeedLimits.Get("Kilometers per hour"));

            // The label will be repositioned to the top of the parent
            this.windowTitleLabel_ = builder.Label_(
                parent: this,
                t: unitTitle,
                stack: UStackMode.Below);

            this.dragHandle_ = this.CreateDragHandle();

            // On window drag - clamp to screen and then save in the config
            this.eventPositionChanged += (_, value) => {
                GlobalConfig.Instance.Main.SpeedLimitsWindowX = (int)value.x;
                GlobalConfig.Instance.Main.SpeedLimitsWindowY = (int)value.y;

                if (!queuedClampToScreen)
                {
                    // Prevent multiple invocations by setting a flag
                    queuedClampToScreen = true;
                    Invoke(eventName: "OnPeriodicClampToScreen", 2.0f);
                }
            };
        }
Exemplo n.º 7
0
        private void SetupControls()
        {
            name             = "ServiceRestrictionTitlebar";
            isVisible        = false;
            canFocus         = true;
            isInteractive    = true;
            relativePosition = Vector3.zero;
            width            = parent.width;
            height           = 40f;

            DragHandle                  = AddUIComponent <UIDragHandle>();
            DragHandle.height           = height;
            DragHandle.relativePosition = Vector3.zero;
            DragHandle.target           = parent;

            _titleLabel               = AddUIComponent <UILabel>();
            _titleLabel.text          = "Campus Restrictions";
            _titleLabel.textScale     = 0.9f;
            _titleLabel.isInteractive = false;

            _closeButton                  = AddUIComponent <UIButton>();
            _closeButton.size             = new Vector2(20, 20);
            _closeButton.relativePosition = new Vector3(width - _closeButton.width - 10f, 10f);
            _closeButton.normalBgSprite   = "DeleteLineButton";
            _closeButton.hoveredBgSprite  = "DeleteLineButtonHovered";
            _closeButton.pressedBgSprite  = "DeleteLineButtonPressed";
            _closeButton.eventClick      += (component, param) =>
            {
                RestrictedDistrictsPanel.Instance.CampusPanelWrapper.isVisible = false;
                UIUtils.DeepDestroy(RestrictedDistrictsPanel.Instance.CampusPanelWrapper);
            };
        }
Exemplo n.º 8
0
        private void SetupControls()
        {
            width = parent.width;
            height = 40;
            isVisible = true;
            canFocus = true;
            isInteractive = true;
            relativePosition = Vector3.zero;

            m_drag = AddUIComponent<UIDragHandle>();
            m_drag.width = width - 50;
            m_drag.height = height;
            m_drag.relativePosition = Vector3.zero;
            m_drag.target = parent;

            m_icon = AddUIComponent<UISprite>();
            m_icon.spriteName = iconSprite;
            m_icon.relativePosition = new Vector3(10, 5);

            m_title = AddUIComponent<UILabel>();
            m_title.relativePosition = new Vector3(50, 13);
            m_title.text = title;

            m_close = AddUIComponent<UIButton>();
            m_close.relativePosition = new Vector3(width - 35, 2);
            m_close.normalBgSprite = "buttonclose";
            m_close.hoveredBgSprite = "buttonclosehover";
            m_close.pressedBgSprite = "buttonclosepressed";
            m_close.eventClick += (component, param) =>
            {
                if (isModal)
                    UIView.PopModal();
                parent.Hide();
            };
        }
        //private UILabel optionsLabel;

        public override void Start()
        {
            GlobalConfig conf = GlobalConfig.Instance;

            DetermineProfile(conf);

            OnUpdate(conf);

            confDisposable = conf.Subscribe(this);

            isVisible = false;

            backgroundSprite = "GenericPanel";
            color            = new Color32(64, 64, 64, 240);

            VersionLabel = AddUIComponent <VersionLabel>();
            StatsLabel   = AddUIComponent <StatsLabel>();

            Buttons = new MenuButton[MENU_BUTTON_TYPES.Length];
            for (int i = 0; i < MENU_BUTTON_TYPES.Length; ++i)
            {
                Buttons[i] = AddUIComponent(MENU_BUTTON_TYPES[i]) as MenuButton;
            }

            var dragHandler = new GameObject("TMPE_Menu_DragHandler");

            dragHandler.transform.parent        = transform;
            dragHandler.transform.localPosition = Vector3.zero;
            Drag         = dragHandler.AddComponent <UIDragHandle>();
            Drag.enabled = !GlobalConfig.Instance.Main.MainMenuPosLocked;

            UpdateAllSizes();
            started = true;
        }
Exemplo n.º 10
0
 public override void Start()
 {
     base.Start();
     size             = new Vector2(WIDTH, HEIGHT);
     backgroundSprite = "MenuPanel";
     canFocus         = true;
     isInteractive    = true;
     BringToFront();
     relativePosition   = new Vector3(50f, 170f);
     opacity            = 1f;
     cachedName         = cacheName;
     dragHandler        = AddUIComponent <UIDragHandle>();
     dragHandler.target = this;
     title                        = AddUIComponent <UILabel>();
     title.text                   = Localization.Get("ECONOMIC_DATA");
     title.relativePosition       = new Vector3(WIDTH / 2f - title.width / 2f - 25f, HEADER / 2f - title.height / 2f);
     title.textAlignment          = UIHorizontalAlignment.Center;
     closeButton                  = AddUIComponent <UIButton>();
     closeButton.normalBgSprite   = "buttonclose";
     closeButton.hoveredBgSprite  = "buttonclosehover";
     closeButton.pressedBgSprite  = "buttonclosepressed";
     closeButton.relativePosition = new Vector3(WIDTH - 35f, 5f, 10f);
     closeButton.eventClick      += delegate(UIComponent component, UIMouseEventParameter eventParam)
     {
         Hide();
     };
     Hide(); //dont show in the beginning
     DoOnStartup();
 }
Exemplo n.º 11
0
        //Properties
        //Methods
        public override void Start()
        {
            UIDragHandle dh = (UIDragHandle)this.AddUIComponent(typeof(UIDragHandle)); //Activates the dragging of the window

            try
            {
                //Configures this window
                this.backgroundSprite = "GenericPanel";
                this.name             = "MPConfigurationPanel";
                this.color            = new Color32(51, 204, 51, 220);
                this.width            = 385;
                this.height           = 523;
                this.relativePosition = new Vector3(700, 270, 0);
                Log.Message(String.Format("panel height:{0} width:{1} position x-y-z:{2}-{3}-{4} relposition x-y-z:{5}-{6}-{7} transposition x-y-z:{8}-{9}-{10}", this.height, this.width, this.position.x, this.position.y, this.position.z, this.relativePosition.x, this.relativePosition.y, this.relativePosition.z, this.transformPosition.x, this.transformPosition.y, this.transformPosition.z));

                //Adds all elements to the panel
                try
                {
                    PopulateConfigurationPanel();
                }
                catch (Exception ex)
                {
                    Log.Error("Populate Error: " + ex.ToString());
                }
            }
            catch (Exception ex)
            {
                Log.Error("Error creating Panel: " + ex.ToString());
            }
        }
Exemplo n.º 12
0
        public override void Start()
        {
            name             = "FRA_MainWindow";
            atlas            = ResourceLoader.GetAtlas("Ingame");
            backgroundSprite = "SubcategoriesPanel";
            isVisible        = false;

            UIDragHandle dragHandle = AddUIComponent <UIDragHandle>();

            dragHandle.target           = parent;
            dragHandle.relativePosition = Vector3.zero;
            dragHandle.size             = size;
            dragHandle.SendToBack();

            // Control panel
            UILabel label = AddUIComponent <UILabel>();

            label.textScale        = 0.9f;
            label.text             = "Fine Road Anarchy";
            label.relativePosition = new Vector2(8, 8);
            label.SendToBack();

            absolutePosition = new Vector3(savedWindowX.value, savedWindowY.value);

            DebugUtils.Log("UIMainWindow created");
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="OnScreenDisplayPanel"/> class.
        /// Constructs the empty OSD panel and hides it.
        /// </summary>
        /// <param name="parent">The parent panel to attach to</param>
        public OnScreenDisplayPanel(UxLibrary uxmod)
        {
            uxmod_ = uxmod;

            UIView uiView = UIView.GetAView();

            items_ = new List <OsdItem>();

            thisPanel_                  = (OsdUnityUiPanel)uiView.AddUIComponent(typeof(OsdUnityUiPanel));
            thisPanel_.name             = UxLibrary.UXMOD_PANEL_NAME;
            thisPanel_.width            = 10f;
            thisPanel_.height           = PANEL_HEIGHT;
            thisPanel_.backgroundSprite = "GenericPanel";
            thisPanel_.color            = new Color32(64, 64, 64, 240);
            thisPanel_.objectUserData   = uxmod;

            // Hide!
            osdVisible_                 = uxmod_.OsdPanelVisible.value;
            thisPanel_.isVisible        = false;
            thisPanel_.absolutePosition = new Vector3(uxmod.OsdPanelX, uxmod.OsdPanelY);

            // Setup drag
            var dragHandler = new GameObject("UXMod_OSD_DragHandler");

            dragHandler.transform.parent        = thisPanel_.transform;
            dragHandler.transform.localPosition = Vector3.zero;
            Drag         = dragHandler.AddComponent <UIDragHandle>();
            Drag.enabled = true;

            // Update();
        }
Exemplo n.º 14
0
        private void CreateComponents()
        {
            UILabel label = AddUIComponent <UILabel>();

            label.text             = "Select an effect to add";
            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            = 40;
            handle.relativePosition  = Vector3.zero;

            // Name field
            label      = AddUIComponent <UILabel>();
            label.text = "Name:";

            m_searchField       = UIUtils.CreateTextField(this);
            m_searchField.width = 250;

            label.relativePosition         = new Vector3((WIDTH - (label.width + m_searchField.width + 10)) / 2, 55);
            m_searchField.relativePosition = new Vector3((WIDTH - m_searchField.width + label.width + 10) / 2, 50);
            m_searchField.text             = "";

            m_searchField.eventTextChanged += (c, s) => {
                PopulateList();
            };
            m_searchField.tooltip = "Search for an effect by name";

            // Buttons
            UIButton confirmButton = UIUtils.CreateButton(this);

            confirmButton.text             = "Add";
            confirmButton.relativePosition = new Vector3(WIDTH / 2 - confirmButton.width - 10, HEIGHT - confirmButton.height - 10);
            confirmButton.eventClicked    += (c, p) =>
            {
                AddEffect();
            };

            UIButton cancelButton = UIUtils.CreateButton(this);

            cancelButton.text             = "Cancel";
            cancelButton.relativePosition = new Vector3(WIDTH / 2 + 10, HEIGHT - cancelButton.height - 10);
            cancelButton.eventClicked    += (c, p) =>
            {
                isVisible = false;
            };

            // Effect list
            m_effectList = UIFastList.Create <UIEffectRow>(this);
            m_effectList.backgroundSprite = "UnlockingPanel";
            m_effectList.relativePosition = new Vector3(10, 90);
            m_effectList.height           = HEIGHT - 90 - 10 - cancelButton.height;
            m_effectList.width            = WIDTH - 20;
            m_effectList.canSelect        = true;
        }
Exemplo n.º 15
0
        public override void Start()
        {
            name             = "APF_panel";
            atlas            = ResourceLoader.GetAtlas("Ingame");
            backgroundSprite = "SubcategoriesPanel";
            size             = new Vector2(300, 180);

            cumulativeHeight = 8;

            absolutePosition = new Vector3(ModInfo.savedWindowX.value, ModInfo.savedWindowY.value);

            eventPositionChanged += (c, p) =>
            {
                if (absolutePosition.x < 0)
                {
                    absolutePosition = ModInfo.defWindowPosition;
                }

                Vector2 resolution = GetUIView().GetScreenResolution();

                absolutePosition = new Vector2(
                    Mathf.Clamp(absolutePosition.x, 0, resolution.x - width),
                    Mathf.Clamp(absolutePosition.y, 0, resolution.y - height));

                ModInfo.savedWindowX.value = (int)absolutePosition.x;
                ModInfo.savedWindowY.value = (int)absolutePosition.y;
            };

            UIPanel header = AddUIComponent <UIPanel>();

            header.relativePosition = Vector2.zero;
            header.width            = width;

            UILabel label = header.AddUIComponent <UILabel>();

            label.textScale        = 0.9f;
            label.text             = "Adjust Pathfinding";
            label.relativePosition = new Vector2(spacing, spacing);

            UIDragHandle dragHandle = header.AddUIComponent <UIDragHandle>();

            dragHandle.width            = width;
            dragHandle.relativePosition = Vector3.zero;
            dragHandle.target           = this;

            dragHandle.height = spacing + label.height;
            header.height     = dragHandle.height;
            cumulativeHeight += header.height;

            dropDown = AddUIComponent <CustomDropDown>();
            dropDown.relativePosition = new Vector2(8, cumulativeHeight);
            dropDown.width            = width - 16;
            cumulativeHeight         += /*dropDown.height*/ +8 + 30;

            setupPanel = AddUIComponent <SetupPanel>();
            setupPanel.relativePosition = new Vector2(0, cumulativeHeight);

            //height = cumulativeHeight + setupPanel.height + 8;
        }
Exemplo n.º 16
0
 public override void Start()
 {
     base.Start();
     //init data
     fromSelected = 0;
     toSelected   = 0;
     symmetry     = 255;
     uturnLane    = false;
     hasSidewalk  = true;
     hasBike      = true;
     //UI
     size             = new Vector2(WIDTH, HEIGHT);
     backgroundSprite = "MenuPanel";
     canFocus         = true;
     isInteractive    = true;
     BringToFront();
     relativePosition = new Vector3((Loader.parentGuiView.fixedWidth / 2 + 20f), 170f);
     opacity          = 1f;
     cachedName       = cacheName;
     //UITOP
     m_DragHandler        = AddUIComponent <UIDragHandle>();
     m_DragHandler.target = this;
     m_DragHandler.zOrder = 11;
     m_UITOP                  = m_DragHandler.AddUIComponent <UISprite>();
     m_UITOP.atlas            = SpriteUtilities.GetAtlas(Loader.m_atlasNameHeader);
     m_UITOP.spriteName       = "UITOP";
     m_UITOP.relativePosition = new Vector3(0f, 0f);
     m_UITOP.width            = WIDTH;
     m_UITOP.height           = 35f;
     m_UITOP.zOrder           = 12;
     //UIBG
     m_UIBG                  = AddUIComponent <UISprite>();
     m_UIBG.atlas            = SpriteUtilities.GetAtlas(Loader.m_atlasNameBg);
     m_UIBG.spriteName       = "UIBG";
     m_UIBG.relativePosition = new Vector3(0f, 35f);
     m_UIBG.width            = WIDTH;
     m_UIBG.height           = HEIGHT - 30f;
     m_UIBG.zOrder           = 12;
     //result
     m_result                  = AddUIComponent <UISprite>();
     m_result.atlas            = SpriteUtilities.GetAtlas(Loader.m_atlasNameNoAsset);
     m_result.spriteName       = "NOASSET";
     m_result.relativePosition = new Vector3(20f, 45f);
     m_result.width            = 150f;
     m_result.height           = 150f;
     m_result.zOrder           = 11;
     //close
     m_closeButton = AddUIComponent <UIButton>();
     m_closeButton.normalBgSprite   = "buttonclose";
     m_closeButton.hoveredBgSprite  = "buttonclosehover";
     m_closeButton.pressedBgSprite  = "buttonclosepressed";
     m_closeButton.relativePosition = new Vector3(WIDTH - 35f, 0f, 10f);
     m_closeButton.eventClick      += delegate(UIComponent component, UIMouseEventParameter eventParam)
     {
         Hide();
     };
     Hide(); //dont show in the beginning
     DoOnStartup();
 }
Exemplo n.º 17
0
        public static UIDragHandle CreateDragHandle(UIComponent parent, UIComponent target)
        {
            UIDragHandle dragHandle = parent.AddUIComponent <UIDragHandle>();

            dragHandle.name   = "DragHandle";
            dragHandle.target = target;

            return(dragHandle);
        }
Exemplo n.º 18
0
        public static UIDragHandle CreateDragHandle(UIComponent parent, string name)
        {
            UIDragHandle dragHandle = parent.AddUIComponent <UIDragHandle>();

            dragHandle.name   = name;
            dragHandle.target = parent;

            return(dragHandle);
        }
Exemplo n.º 19
0
        private void SetupControls()
        {
            name             = "ServiceRestrictionTitlebar";
            isVisible        = false;
            canFocus         = true;
            isInteractive    = true;
            relativePosition = Vector3.zero;
            width            = parent.width;
            height           = 40f;

            DragHandle                  = AddUIComponent <UIDragHandle>();
            DragHandle.height           = height;
            DragHandle.relativePosition = Vector3.zero;
            DragHandle.target           = parent;
            DragHandle.eventMouseUp    += (c, e) =>
            {
                ServiceRestrictionsMod.Settings.PanelX = parent.relativePosition.x;
                ServiceRestrictionsMod.Settings.PanelY = parent.relativePosition.y;
                ServiceRestrictionsMod.Settings.Save();
            };

            _titleLabel      = AddUIComponent <UILabel>();
            _titleLabel.text =
                $"{CustomizeItExtendedCompatibility.RetrieveBuildingName()} Restrictions";
            _titleLabel.textScale     = 0.9f;
            _titleLabel.isInteractive = false;

            _closeButton                  = AddUIComponent <UIButton>();
            _closeButton.size             = new Vector2(20, 20);
            _closeButton.relativePosition = new Vector3(width - _closeButton.width - 10f, 10f);
            _closeButton.normalBgSprite   = "DeleteLineButton";
            _closeButton.hoveredBgSprite  = "DeleteLineButtonHovered";
            _closeButton.pressedBgSprite  = "DeleteLineButtonPressed";
            _closeButton.eventClick      += (component, param) =>
            {
                if (RestrictedDistrictsPanel.Instance.CampusPanelWrapper != null)
                {
                    RestrictedDistrictsPanel.Instance.CampusPanelWrapper.isVisible = false;
                    UIUtils.DeepDestroy(RestrictedDistrictsPanel.Instance.CampusPanelWrapper);
                }

                if (RestrictedDistrictsPanel.Instance.IndustriesPanelWrapper != null)
                {
                    RestrictedDistrictsPanel.Instance.IndustriesPanelWrapper.isVisible = false;
                    UIUtils.DeepDestroy(RestrictedDistrictsPanel.Instance.IndustriesPanelWrapper);
                }

                if (RestrictedDistrictsPanel.Instance.ParkPanelWrapper != null)
                {
                    RestrictedDistrictsPanel.Instance.ParkPanelWrapper.isVisible = false;
                    UIUtils.DeepDestroy(RestrictedDistrictsPanel.Instance.ParkPanelWrapper);
                }

                ServiceRestrictTool.instance.RestrictedDistrictsPanelWrapper.isVisible = false;
                UIUtils.DeepDestroy(ServiceRestrictTool.instance.RestrictedDistrictsPanelWrapper);
            };
        }
        public override void Start()
        {
            chirpPane = GameObject.Find("ChirperPanel").GetComponent <ChirpPanel>();

            if (chirpPane == null)
            {
                return;
            }

            // Set visuals for panel
            this.backgroundSprite  = "ChirperBubble";
            this.color             = new Color32(122, 132, 138, 255);
            this.width             = 300;
            this.height            = 200;
            this.transformPosition = new Vector3(-1.0f, 0.9f);

            // Allow automated layout
            this.autoLayoutDirection = LayoutDirection.Vertical;
            this.autoLayoutStart     = LayoutStart.TopLeft;
            this.autoLayoutPadding   = new RectOffset(10, 10, 0, 10);
            this.autoLayout          = true;

            // Add drag handle for panel
            UIDragHandle dragHandle = this.AddUIComponent <UIDragHandle>();
            // Add title to drag handle
            UILabel titleLabel = dragHandle.AddUIComponent <UILabel>();

            titleLabel.text          = "Options";
            titleLabel.textScale     = 1.5f;
            titleLabel.textColor     = new Color32(36, 202, 255, 255);
            titleLabel.textAlignment = UIHorizontalAlignment.Center;

            UIButton muteButton     = AddNewButton("Mute");
            UIButton filterButton   = AddNewButton("Filters: OFF");
            UIButton hashTagsButton = AddNewButton("HashTags: ON");

            // Defaults to ON if ChirpFilter is active.

            /*
             * if (SuperChirper.HasFilters)
             *  filterButton.text = "Filters: ON";
             */

            muteButton.eventClick     += MuteButtonClick;
            filterButton.eventClick   += FilterButtonClick;
            hashTagsButton.eventClick += HashTagsButtonClick;

            SuperChirperMod.MuteButtonInstance     = muteButton;
            SuperChirperMod.FilterButtonInstance   = filterButton;
            SuperChirperMod.HashTagsButtonInstance = hashTagsButton;

            // Default to hidden
            this.Hide();

            DebugOutputPanel.AddMessage(PluginManager.MessageType.Message, "[SuperChirper] ConfigPanel built.");
        }
Exemplo n.º 21
0
        public override void Awake()
        {
            base.Awake();

            _TitileText = AddUIComponent <UILabel>();
            _drag       = AddUIComponent <UIDragHandle>();

            height = 50;
            width  = 550;
        }
Exemplo n.º 22
0
        // runs only once, do internal init here
        public override void Awake()
        {
            base.Awake();

            // Note - parent may not be set yet

            Title       = AddUIComponent <UILabel>();
            CloseButton = AddUIComponent <UIButton>();
            DragHandle  = AddUIComponent <UIDragHandle>();
        }
Exemplo n.º 23
0
 public override void Awake()
 {
     title        = AddUIComponent <UILabel>();
     dragHandle   = AddUIComponent <UIDragHandle>();
     closeButton  = AddUIComponent <UIButton>();
     buildButton  = AddUIComponent <UIButton>();
     latTextField = AddUIComponent <UITextField>();
     lonTextField = AddUIComponent <UITextField>();
     status       = AddUIComponent <UILabel>();
 }
Exemplo n.º 24
0
        private void CreateUI()
        {
#if DEBUG
            Next.Debug.Log("MOM ABOVE GROUND STATION TRACK GUI Created");
#endif

            backgroundSprite = "GenericPanel";
            color            = new Color32(68, 84, 68, 170);
            width            = 200;
            height           = 100;
            opacity          = 60;
            position         = Vector2.zero;
            isVisible        = false;
            isInteractive    = true;
            padding          = new RectOffset()
            {
                bottom = 8, left = 8, right = 8, top = 8
            };

            UIPanel dragHandlePanel = AddUIComponent <UIPanel>();
            dragHandlePanel.atlas            = atlas;
            dragHandlePanel.backgroundSprite = "GenericPanel";
            dragHandlePanel.width            = width;
            dragHandlePanel.height           = 20;
            dragHandlePanel.opacity          = 100;
            dragHandlePanel.color            = new Color32(21, 140, 34, 255);
            dragHandlePanel.relativePosition = Vector3.zero;

            UIDragHandle dragHandle = dragHandlePanel.AddUIComponent <UIDragHandle>();
            dragHandle.width            = width;
            dragHandle.height           = dragHandle.parent.height;
            dragHandle.relativePosition = Vector3.zero;
            dragHandle.target           = this;

            UILabel titleLabel = dragHandlePanel.AddUIComponent <UILabel>();
            titleLabel.relativePosition = new Vector3()
            {
                x = 5, y = 5, z = 0
            };
            titleLabel.textAlignment = UIHorizontalAlignment.Center;
            titleLabel.text          = "Surface Station Options";
            titleLabel.isInteractive = false;

            btnModernStyle = CreateButton("Modern", new Vector3(8, 50), (c, v) =>
            {
                trackStyle = 0;
                SetNetToolPrefab();
            });

            btnClassicStyle = CreateButton("Classic", new Vector3(8 + (0.5f * width) - 16, 50), (c, v) =>
            {
                trackStyle = 1;
                SetNetToolPrefab();
            });
        }
Exemplo n.º 25
0
        public static UIDragHandle CreateMenuPanelDragHandle(UIComponent parent)
        {
            UIDragHandle dragHandle = parent.AddUIComponent <UIDragHandle>();

            dragHandle.name   = "DragHandle";
            dragHandle.zOrder = 2;

            dragHandle.target = parent;

            return(dragHandle);
        }
Exemplo n.º 26
0
        private UIDragHandle CreateDragHandle(UIPanel parent)
        {
            UIDragHandle dragHandle = parent.AddUIComponent <UIDragHandle>();

            dragHandle.name             = "DragHandle";
            dragHandle.width            = parent.width - 40f; // Make room for close button?
            dragHandle.height           = 40f;
            dragHandle.relativePosition = Vector3.zero;
            dragHandle.target           = parent;
            return(dragHandle);
        }
        /// <summary>
        /// Creates the drag handle.
        /// </summary>
        protected virtual void CreateDragHandle()
        {
            this.DragHandleObject = new GameObject("DragHandler");
            this.DragHandleObject.transform.parent        = this.transform;
            this.DragHandleObject.transform.localPosition = Vector3.zero;

            UIDragHandle dragHandle = this.DragHandleObject.AddComponent <UIDragHandle>();

            dragHandle.anchor = UIAnchorStyle.Top | UIAnchorStyle.Left | UIAnchorStyle.Right;
            dragHandle.size   = new Vector2(this.width, TitleBarHeight);
        }
Exemplo n.º 28
0
        public override void Start()
        {
            U.UIUtil.MakeUniqueAndSetName(this.gameObject, "TMPE_MainMenuButton");

            // Place the button.
            OnUpdate(GlobalConfig.Instance);

            confDisposable_ = GlobalConfig.Instance.Subscribe(this);

            // Let the mainmenu atlas know we need this texture and assign it to self.atlas.
            this.Skin = new ButtonSkin {
                BackgroundPrefix  = "MainMenuButton",
                Prefix            = "MainMenuButton",
                BackgroundHovered = true,
                BackgroundActive  = true,
                ForegroundHovered = true,
                ForegroundActive  = true,
            };
            var atlasBuilder = new U.AtlasBuilder();

            this.Skin.UpdateAtlasBuilder(
                atlasBuilder: atlasBuilder,
                spriteSize: new IntVector2(50));
            this.atlas = atlasBuilder.CreateAtlas(
                atlasName: "MainTMPEButton_Atlas",
                loadingPath: "MainMenu",
                atlasSizeHint: new IntVector2(256));
            UpdateButtonImageAndTooltip();

            // Set the button dimensions to smallest of 2.6% of screen width or 4.6% of screen height
            // Which approximately equals to 50 pixels in 1080p.
            width = height = GetButtonDimensions();

            // Enable button sounds.
            playAudioEvents = true;

            var dragHandler = new GameObject("TMPE_MainButton_DragHandler");

            dragHandler.transform.parent        = transform;
            dragHandler.transform.localPosition = Vector3.zero;
            Drag = dragHandler.AddComponent <UIDragHandle>();

            Drag.width   = width;
            Drag.height  = height;
            Drag.enabled = !GlobalConfig.Instance.Main.MainMenuButtonPosLocked;

            // Set up the tooltip
            var uiView = GetUIView();

            if (uiView != null)
            {
                m_TooltipBox = uiView.defaultTooltipBox;
            }
        }
Exemplo n.º 29
0
        public static UIDragHandle CreateMenuPanelDragHandle(UIComponent parent)
        {
            UIDragHandle dragHandle = parent.AddUIComponent <UIDragHandle>();

            dragHandle.name             = "DragHandle";
            dragHandle.width            = parent.width - 40f;
            dragHandle.height           = 40f;
            dragHandle.relativePosition = Vector3.zero;
            dragHandle.target           = parent;

            return(dragHandle);
        }
Exemplo n.º 30
0
        /// <summary>
        /// Constructor.
        /// </summary>
        internal BOBPanelBase()
        {
            // Basic behaviour.
            autoLayout    = false;
            canFocus      = true;
            isInteractive = true;

            // Appearance.
            backgroundSprite = "MenuPanel2";
            opacity          = PanelOpacity;

            // Size.
            size = new Vector2(PanelWidth, PanelHeight);

            // Drag bar.
            UIDragHandle dragHandle = AddUIComponent <UIDragHandle>();

            dragHandle.width            = this.width - 50f;
            dragHandle.height           = this.height;
            dragHandle.relativePosition = Vector3.zero;
            dragHandle.target           = this;

            // Close button.
            UIButton closeButton = AddUIComponent <UIButton>();

            closeButton.relativePosition = new Vector2(width - 35, 2);
            closeButton.normalBgSprite   = "buttonclose";
            closeButton.hoveredBgSprite  = "buttonclosehover";
            closeButton.pressedBgSprite  = "buttonclosepressed";
            closeButton.eventClick      += (component, clickEvent) => CloseEvent();

            // Name filter.
            nameFilter = UIControls.SmallLabelledTextField(this, width - 200f - Margin, TitleHeight + Margin, Translations.Translate("BOB_FIL_NAME"));
            // Event handlers for name filter textbox.
            nameFilter.eventTextChanged   += (control, text) => LoadedList();
            nameFilter.eventTextSubmitted += (control, text) => LoadedList();

            // Vanilla filter.
            hideVanilla                    = UIControls.LabelledCheckBox((UIComponent)(object)this, nameFilter.relativePosition.x, nameFilter.relativePosition.y + nameFilter.height + (Margin / 2f), Translations.Translate("BOB_PNL_HDV"), 12f, 0.7f);
            hideVanilla.isChecked          = ModSettings.hideVanilla;
            hideVanilla.eventCheckChanged += VanillaCheckChanged;

            // Mode label.
            modeLabel = UIControls.AddLabel(this, Margin, ToggleHeaderY, Translations.Translate("BOB_PNL_MOD"), textScale: 0.8f);

            // Tree/Prop checkboxes.
            propCheck                    = IconToggleCheck(this, Margin, ToggleY, "BOB-PropsSmall", "BOB_PNL_PRP");
            treeCheck                    = IconToggleCheck(this, Margin + ToggleSize, ToggleY, "BOB-TreesSmall", "BOB_PNL_TRE");
            propCheck.isChecked          = !InitialTreeCheckedState;
            treeCheck.isChecked          = InitialTreeCheckedState;
            propCheck.eventCheckChanged += PropCheckChanged;
            treeCheck.eventCheckChanged += TreeCheckChanged;
        }
Exemplo n.º 31
0
        public static UIDragHandle CreateDragHandle(UIComponent parent, Vector2?size)
        {
            UIDragHandle dragHandle = parent.AddUIComponent <UIDragHandle>();

            dragHandle.transform.parent        = parent.transform;
            dragHandle.transform.localPosition = Vector2.zero;
            dragHandle.relativePosition        = Vector2.zero;
            dragHandle.target = parent;
            dragHandle.size   = size ?? parent.size;

            return(dragHandle);
        }
        public override void Awake()
        {
            base.Awake();

            iconSprite = AddUIComponent<UISprite>();
            titleLabel = AddUIComponent<UILabel>();
            closeButton = AddUIComponent<UIButton>();
            dragHandle = AddUIComponent<UIDragHandle>();

            height = 40;
            TitleText = "(None)";
            IconSprite = "";
        }
Exemplo n.º 33
0
        public override void Awake()
        {
            base.Awake();

            _icon = AddUIComponent<UISprite>();
            _title = AddUIComponent<UILabel>();
            _close = AddUIComponent<UIButton>();
            _drag = AddUIComponent<UIDragHandle>();

            height = UIConstants.TitlePanelHeight;
            width = UIConstants.TitlePanelWidth;
            TitleText = UITexts.WindowTitle ;
            IconSprite = "";
        }
        public override void Awake()
        {
            base.Awake();

            _icon = AddUIComponent<UISprite>();
            _title = AddUIComponent<UILabel>();
            _close = AddUIComponent<UIButton>();
            _drag = AddUIComponent<UIDragHandle>();

            height = 40;
            width = 450;
            TitleText = EPTUILang.text("NONE");
            IconSprite = "";
        }
Exemplo n.º 35
0
        public override void Awake()
        {
            base.Awake();

            m_icon = AddUIComponent<UISprite>();
            m_title = AddUIComponent<UILabel>();
            m_close = AddUIComponent<UIButton>();
            m_drag = AddUIComponent<UIDragHandle>();

            height = 40;
            width = 450;
            title = "(None)";
            iconSprite = "";
        }
Exemplo n.º 36
0
        public override void Start()
        {
            base.Start ();
            Debug.PrintMessage ("Creating ChallengePanel");
            this.width = WIDTH;
            this.height = HEAD;
            if (m_challenge != null && m_challenge.Goals != null) { //covers case when the panel reassignes hieght to be head even with a challenge being loaded
                this.height = HEAD + GoalProgressPanel.SPACING + m_challenge.Goals.Length * (GoalProgressPanel.HEIGHT+GoalProgressPanel.SPACING);
            }
            this.backgroundSprite = "MenuPanel";
            this.Hide ();
            this.relativePosition = new Vector3 (10,GetUIView().fixedHeight - height - 135);

            m_titleLabel = this.AddUIComponent<UILabel> ();
            m_titleLabel.text = "Challenges";
            m_titleLabel.textScale = 1.25f;
            m_titleLabel.size = new Vector2 (WIDTH,HEAD);
            m_titleLabel.relativePosition = new Vector3(SPACING,SPACING);

            m_drag = this.AddUIComponent<UIDragHandle> ();
            m_drag.width = this.width;
            m_drag.height = HEAD;
            m_drag.relativePosition = new Vector3(0,0,10);
            m_drag.target = this;

            m_closeButton = this.AddUIComponent<UIButton> ();
            m_closeButton.size = new Vector2 (CLOSE_BUTTON_SIZE, CLOSE_BUTTON_SIZE);
            m_closeButton.normalBgSprite = "buttonclose";
            m_closeButton.hoveredBgSprite = "buttonclosehover";
            m_closeButton.pressedBgSprite = "buttonclosepressed";
            m_closeButton.relativePosition = new Vector3 (WIDTH - 3f - m_closeButton.width, 5);
            Debug.PrintMessage(m_closeButton.size);
            m_closeButton.eventClick += (component, eventParam) => {
                this.Hide ();
            };

            m_startButton = this.AddUIComponent<UIButton> ();
            m_startButton.size = new Vector2 (BUTTON_WIDTH,BUTTON_HEIGHT);
            m_startButton.text = "Start";
            m_startButton.textScale = 0.875f;
            m_startButton.normalBgSprite = "ButtonMenu";
            m_startButton.hoveredBgSprite = "ButtonMenuHovered";
            m_startButton.pressedBgSprite = "ButtonMenuPressed";
            m_startButton.disabledBgSprite = "ButtonMenuDisabled";
            m_startButton.color = Color.green;
            m_startButton.focusedColor = m_startButton.color;
            m_startButton.hoveredColor = m_startButton.color;
            m_startButton.pressedColor = m_startButton.color;
            m_startButton.relativePosition = m_closeButton.relativePosition + new Vector3 (-BUTTON_WIDTH -SPACING,6f);

            //m_startButton.eventClick += StartChallenge;
            m_startButton.Disable ();
            m_startButton.Hide ();

            m_endButton = this.AddUIComponent<UIButton> ();
            m_endButton.size = m_startButton.size;
            m_endButton.text = "Forfeit";
            m_endButton.textScale = 0.875f;
            m_endButton.normalBgSprite = "ButtonMenu";
            m_endButton.hoveredBgSprite = "ButtonMenuHovered";
            m_endButton.pressedBgSprite = "ButtonMenuPressed";
            m_endButton.disabledBgSprite = "ButtonMenuDisabled";
            m_endButton.color = new Color32(255,0,0,255);
            m_endButton.focusedColor = m_endButton.color;
            m_endButton.hoveredColor = m_endButton.color;
            m_endButton.pressedColor = m_endButton.color;
            m_endButton.relativePosition = m_startButton.relativePosition;
            m_endButton.eventClick += AskForfeit;
            //m_startButton.disabledColor = Color.gray;
            //m_endButton.Disable ();
            //m_endButton.Hide ();
        }
Exemplo n.º 37
0
        /// <summary>
        /// Gets called upon the base UI component's creation. Basically it's the constructor...but not really.
        /// </summary>
        public override void Start()
        {
            base.Start();
            if (SomeModName.DEBUG_LOG_ON & SomeModName.DEBUG_LOG_LEVEL > 0) Logger.dbgLog(string.Concat("Attempting to create our display panel.  ",DateTime.Now.ToString(DTMilli).ToString()));
            this.size = new Vector2(WIDTH, HEIGHT);
            this.backgroundSprite = "MenuPanel";
            this.canFocus = true;
            this.isInteractive = true;
            this.BringToFront();
            this.relativePosition = new Vector3((Loader.parentGuiView.fixedWidth / 2) - 200, (Loader.parentGuiView.fixedHeight / 2) - 350);
            this.opacity = SomeModName.config.GuiOpacity;
            this.cachedName = cacheName;
            SomeModNameGUI.instance = this;
            CurrentMode = Singleton<ToolManager>.instance.m_properties.m_mode;

            //DragHandler
            m_DragHandler = this.AddUIComponent<UIDragHandle>();
            m_DragHandler.target = this;  //set the drag hangler target to this panel. it will do the rest magically.

            //Our Titlebar UILabel
            m_title = this.AddUIComponent<UILabel>();
            m_title.text = "Vehicle Cargo Data"; //spaces on purpose
            m_title.relativePosition = new Vector3(WIDTH / 2 - (m_title.width / 2) - 25f, (HEADER / 2) - (m_title.height / 2));
            m_title.textAlignment = UIHorizontalAlignment.Center;

            //Our Close Button UIButton
            m_closeButton = this.AddUIComponent<UIButton>();
            m_closeButton.normalBgSprite = "buttonclose";
            m_closeButton.hoveredBgSprite = "buttonclosehover";
            m_closeButton.pressedBgSprite = "buttonclosepressed";
            m_closeButton.relativePosition = new Vector3(WIDTH - 35, 5, 10);
            m_closeButton.eventClick += (component, eventParam) =>
            {
                this.Hide();
            };
            //^^above that's just an inline delegate to trigger hidding the panel when someone clicks the ' X ' (close) Button

            //What's our config say about Showing on map load?
            if (!SomeModName.config.AutoShowOnMapLoad)
            {
                this.Hide();
            }

            DoOnStartup(); //let go do some other stuff too during "start"
            if (SomeModName.DEBUG_LOG_ON) Logger.dbgLog(string.Concat("Display panel created. ",DateTime.Now.ToString(DTMilli).ToString()));
        }
        /// <summary>
        /// Gets called upon the base UI component's creation. Basically it's the constructor...but not really.
        /// </summary>
        public override void Start()
        {
            base.Start();
            CSLShowMoreLimitsGUI.instance = this;
            if (Mod.DEBUG_LOG_ON & Mod.DEBUG_LOG_LEVEL > 0) Helper.dbgLog(string.Concat("Attempting to create our display panel.  ",DateTime.Now.ToString(DTMilli).ToString()));
            this.size = new Vector2(WIDTH, HEIGHT);
            this.backgroundSprite = "MenuPanel";
            this.canFocus = true;
            this.isInteractive = true;
            this.BringToFront();
            this.relativePosition = new Vector3((Loader.parentGuiView.fixedWidth / 2) - 200, (Loader.parentGuiView.fixedHeight / 2) - 350);
            this.opacity = Mod.config.GuiOpacity;
            this.cachedName = cacheName;
            CurrentMode = Singleton<ToolManager>.instance.m_properties.m_mode;
            /*            if (CurrentMode == ItemClass.Availability.MapEditor)
            {
                Helper.dbgLog("sdfsfasdfasdfasdfasdfasdfasdf");
                UITextureAtlas[] tAtlas;
                tAtlas = FindObjectsOfType<UITextureAtlas>();
                if (tAtlas != null)
                {
                    for (int i = 0; i < tAtlas.Length; i++)
                    {
                        if (tAtlas[i].name == "Ingame")
                        {
                            this.atlas = tAtlas[i];
                            Helper.dbgLog("sdfsfa22222222222222222222asdf");
                            break;
                        }
                    }
                }
            }
            */
            //DragHandler
            m_DragHandler = this.AddUIComponent<UIDragHandle>();
            m_DragHandler.target = this;
            //Title UILabel
            m_title = this.AddUIComponent<UILabel>();
            m_title.text = "Counter and Object Limit Data"; //spaces on purpose
            m_title.relativePosition = new Vector3(WIDTH / 2 - (m_title.width / 2) - 25f, (HEADER / 2) - (m_title.height / 2));
            m_title.textAlignment = UIHorizontalAlignment.Center;
            //Close Button UIButton
            m_closeButton = this.AddUIComponent<UIButton>();
            m_closeButton.normalBgSprite = "buttonclose";
            m_closeButton.hoveredBgSprite = "buttonclosehover";
            m_closeButton.pressedBgSprite = "buttonclosepressed";
            m_closeButton.relativePosition = new Vector3(WIDTH - 35, 5, 10);
            m_closeButton.eventClick += (component, eventParam) =>
            {
                this.Hide();
            };

            if (!Mod.config.AutoShowOnMapLoad)
            {
                this.Hide();
            }
            DoOnStartup();
            if (Mod.DEBUG_LOG_ON) Helper.dbgLog(string.Concat("Display panel created. ",DateTime.Now.ToString(DTMilli).ToString()));
        }
Exemplo n.º 39
0
        public override void OnLevelLoaded(LoadMode mode)
        {
            if (mode != LoadMode.LoadGame && mode != LoadMode.NewGame)
            {
                base.OnLevelLoaded(mode);
                return;
            }

            // Get a reference to the game's UI.
            var uiView = UnityEngine.Object.FindObjectOfType<UIView>();

            var button = uiView.AddUIComponent(typeof(UIButton));
            _browserButton = button as UIButton;

            // The object should *never* be null.
            // We call this a "sanity check".
            if (_browserButton == null) { return; }

            // Create a drag handler and attach it to our button.
            _browserButtonDragHandle = button.AddUIComponent<UIDragHandle>();
            _browserButtonDragHandle.target = _browserButton;

            _browserButton.width = 36;
            _browserButton.height = 36;
            _browserButton.pressedBgSprite = "OptionBasePressed";
            _browserButton.normalBgSprite = "OptionBase";
            _browserButton.hoveredBgSprite = "OptionBaseHovered";
            _browserButton.disabledBgSprite = "OptionBaseDisabled";
            _browserButton.normalFgSprite = "ToolbarIconZoomOutGlobe";
            _browserButton.foregroundSpriteMode = UIForegroundSpriteMode.Scale;
            _browserButton.scaleFactor = 1.0f;
            _browserButton.tooltip = "Open Browser (Hold Shift to drag)";
            _browserButton.tooltipBox = uiView.defaultTooltipBox;

            // If the user has moved the button, load their saved position data.
            if (Configuration.HasSetting(keyButtonPositionX) && Configuration.HasSetting(keyButtonPositionY))
            {
                var buttonPositionX = Configuration.GetFloat(keyButtonPositionX);
                var buttonPositionY = Configuration.GetFloat(keyButtonPositionY);
                _buttonPosition = new Vector2(buttonPositionX, buttonPositionY);
                _useSavedPosition = true;
            }
            else
            {
                _useSavedPosition = false;
            }

            // Since we're on another thread, we can pretty safely spin until our object has been created.
            //while (_browserButton == null) { System.Threading.Thread.Sleep(100); }

            if (!_useSavedPosition)
            {
                // Get a reference to the game's UI.
                //var uiView = UnityEngine.Object.FindObjectOfType<UIView>();

                // The default position of the button is the middle of the screen.
                var buttonPositionX = (uiView.fixedWidth / 2f) + (_browserButton.width / 2f);
                var buttonPositionY = (uiView.fixedHeight / 2f) + (_browserButton.height / 2f);
                _buttonPosition = new Vector2(buttonPositionX, buttonPositionY);
            }
            _browserButton.absolutePosition = _buttonPosition;

            var labelObject = new GameObject();
            labelObject.transform.parent = uiView.transform;

            _browserButtonLabel = labelObject.AddComponent<UILabel>();
            _browserButtonLabel.textColor = new Color32(255, 255, 255, 255);
            _browserButtonLabel.transformPosition = new Vector3(1.15f, 0.90f);
            _browserButtonLabel.Hide();

            RegisterEvents();

            base.OnLevelLoaded(mode);
        }
        /// <summary>
        /// Creates all objects. Call first.
        /// </summary>
        public void start()
        {
            // RoadOptionStraightPressed possible icon
            name = "TitleBar";
            setMode(Parent.mode); // isVisible
            canFocus = true;
            isInteractive = true;
            width = 385;
            height = 42;

            // Title
            bool customPanel = false;
            _title = AddUIComponent<UILabel>();
            _title.name = "Title Label";
            switch (Parent.name)
            {
                case "ExtendedPanelElectricity":
                    _title.localeID = "INFO_ELECTRICITY_TITLE"; break;
                case "ExtendedPanelWater":
                    _title.localeID = "INFO_WATER_WATERANDSEWAGE"; break;
                case "ExtendedPanelGarbage":
                    _title.localeID = "INFO_GARBAGE_TITLE"; break;
                case "ExtendedPanelHealth":
                    _title.localeID = "INFO_HEALTH_TITLE"; break;
                case "ExtendedPanelFireSafety":
                    _title.localeID = "INFO_FIRE_TITLE"; break;
                case "ExtendedPanelCrime":
                    _title.localeID = "INFO_CRIMERATE_TITLE"; break;
                case "ExtendedPanelEducation":
                    _title.localeID = "INFO_EDUCATION_TITLE"; break;
                case "ExtendedPanelParks":
                    _title.localeID = "INFO_ENTERTAINMENT_PARKS"; break;
                case "ExtendedPanelMonuments":
                    _title.localeID = "INFO_ENTERTAINMENT_BUILDINGS"; break;
                case "ExtendedPanelTransportBus":
                    _title.localeID = "INFO_PUBLICTRANSPORT_BUS"; break;
                case "ExtendedPanelTransportMetro":
                    _title.localeID = "INFO_PUBLICTRANSPORT_METRO"; break;
                case "ExtendedPanelTransportTrain":
                    _title.localeID = "INFO_PUBLICTRANSPORT_TRAIN"; break;
                case "ExtendedPanelTransportShip":
                    _title.localeID = "INFO_PUBLICTRANSPORT_SHIP"; break;
                case "ExtendedPanelTransportPlane":
                    _title.localeID = "INFO_PUBLICTRANSPORT_PLANE"; break;
                case "ExtendedPanelFreetime":
                    _title.localeID = "INFO_ENTERTAINMENT_TITLE"; break;
                case "ExtendedPanelTransport":
                    _title.localeID = "INFO_PUBLICTRANSPORT_TITLE"; break;
                default:
                    _title.text = Parent.name;
                    customPanel = true;
                    break;
            }

            String titletext = _title.text;
            if (!customPanel)
            {
                _title.localeID = "ECONOMY_BUDGET";
                titletext = titletext + " " + _title.text;
                _title.text = titletext;
            }
            _title.relativePosition = new Vector3(185-(_title.text.Length*4), 11);
            _title.textScale = 1.1f;

            // Drag Handler
            _draghandler = AddUIComponent<UIDragHandle>();
            _draghandler.name = "Draghandler";
            _draghandler.target = Parent;
            _draghandler.width = width;
            _draghandler.height = height;
            _draghandler.relativePosition = Vector3.zero;
            _draghandler.BringToFront();

            // Sticky Checkbox
            _stickybutton = AddUIComponent<UIButton>();
            _stickybutton.name = "Sticky Button";
            if (customPanel)
            {
                _stickybutton.normalBgSprite = "buttonclose";
                _stickybutton.pressedBgSprite = "buttonclosehover";
                _stickybutton.hoveredBgSprite = "buttonclosepressed";
                _stickybutton.focusedBgSprite = "buttonclosehover";
            }
            else
            {
                _stickybutton.normalBgSprite = "LocationMarkerActiveHovered";
                _stickybutton.pressedBgSprite = "LocationMarkerActivePressed";
                _stickybutton.hoveredBgSprite = "LocationMarkerActiveFocused";
                _stickybutton.focusedBgSprite = "LocationMarkerActivePressed";
            }
            _stickybutton.eventClick += toogleSticky;
            _stickybutton.size = new Vector2(36,36);
            _stickybutton.relativePosition = new Vector3(width-43,2);

            // Money Icon
            _icon = AddUIComponent<UISprite>();
            _icon.name = "Icon";
            _icon.relativePosition = new Vector3(4, 2);
            _icon.spriteName = "MoneyThumb";
            _icon.size = new Vector2(40, 40);
            _icon.eventClick += changeOpacity;
        }
Exemplo n.º 41
0
        public override void Awake()
        {
            base.Awake();

            Debug.Log("Begin UINetworkSkinsPanel.Awake");

            LoadSprites();

            this.backgroundSprite = "MenuPanel2";
            this.width = Width + 2 * Padding;
            //this.padding = new RectOffset(PADDING, 0, PADDING, 0);

            _titleBar = this.AddUIComponent<UIDragHandle>();
            _titleBar.name = "TitlePanel";
            _titleBar.width = this.width;
            _titleBar.height = TabHeight + PaddingTop;
            _titleBar.target = this;
            _titleBar.relativePosition = new Vector3(0, 0);

            // display a drag cursor sprite in the top right corner of the panel
            var dragSprite = _titleBar.AddUIComponent<UISprite>();
            dragSprite.atlas = SpriteUtilities.GetAtlas(Atlas);
            dragSprite.spriteName = "DragCursor";
            dragSprite.relativePosition = new Vector3(Width - 20, PaddingTop + 1);
            dragSprite.MakePixelPerfect();

            _tabstrip = _titleBar.AddUIComponent<UITabstrip>();
            _tabstrip.relativePosition = new Vector3(Padding, PaddingTop, 0);
            _tabstrip.width = Width;
            _tabstrip.height = TabHeight;
            _tabstrip.tabPages = this.AddUIComponent<UITabContainer>();
            _tabstrip.tabPages.width = this.width;
            _tabstrip.tabPages.height = PageHeight;
            _tabstrip.tabPages.relativePosition = new Vector3(0, _titleBar.height);
            _tabstrip.tabPages.padding = new RectOffset(PagesPadding, PagesPadding, PagesPadding, PagesPadding);
            _tabstrip.padding.right = 0;

            // Add 4 tabs and 4 pages
            var keyMappingTabstrip = GameObject.Find("KeyMappingTabStrip").GetComponent<UITabstrip>();
            var buttonTemplate = keyMappingTabstrip.GetComponentInChildren<UIButton>();

            _netTypePages = new UIPanel[NetUtil.NET_TYPE_NAMES.Length];

            for (var i = 0; i < NetUtil.NET_TYPE_NAMES.Length; i++)
            {
                var tab = _tabstrip.AddTab(NetUtil.NET_TYPE_NAMES[i], buttonTemplate, true);
                tab.textPadding.top = 8;
                tab.textPadding.bottom = 8;
                tab.textPadding.left = 10;
                tab.textPadding.right = 10;
                tab.autoSize = true;
                tab.textScale = .9f;
                tab.playAudioEvents = buttonTemplate.playAudioEvents;

                tab.pressedTextColor = new Color32(255, 255, 255, 255);
                tab.focusedTextColor = new Color32(255, 255, 255, 255);
                tab.focusedColor = new Color32(205, 205, 205, 255);
                tab.disabledTextColor = buttonTemplate.disabledTextColor;

                var page = _tabstrip.tabPages.components.Last() as UIPanel;
                page.autoLayoutDirection = LayoutDirection.Vertical;
                page.autoLayoutPadding = new RectOffset(0, 0, 0, Padding);
                page.autoLayout = true;
                page.isVisible = false;

                // TODO add scrolling + autofitting

                _netTypePages[i] = page;
            }

            this.FitChildren();

            _netToolWrapper = NetUtil.GenerateNetToolWrapper();
            if (_netToolWrapper == null) throw new Exception("NetworkSkins Error: NetToolWrapper is null!");

            // Add some example options
            GetPage(NetType.Ground).AddUIComponent<UILightOption>();
            //GetPage(NetType.Ground).AddUIComponent<UILightDistanceOption>();
            GetPage(NetType.Ground).AddUIComponent<UITreeOption>().LanePosition = LanePosition.Left;
            //GetPage(NetType.Ground).AddUIComponent<UITreeDistanceOption>().LanePosition = LanePosition.Left;
            GetPage(NetType.Ground).AddUIComponent<UITreeOption>().LanePosition = LanePosition.Middle;
            //GetPage(NetType.Ground).AddUIComponent<UITreeDistanceOption>().LanePosition = LanePosition.Middle;
            GetPage(NetType.Ground).AddUIComponent<UITreeOption>().LanePosition = LanePosition.Right;
            //GetPage(NetType.Ground).AddUIComponent<UITreeDistanceOption>().LanePosition = LanePosition.Right;

            GetPage(NetType.Elevated).AddUIComponent<UILightOption>();
            //GetPage(NetType.Elevated).AddUIComponent<UILightDistanceOption>();
            GetPage(NetType.Elevated).AddUIComponent<UIPillarOption>().PillarType = PillarType.BridgePillar;
            //GetPage(NetType.ELEVATED).AddUIComponent<UIPillarOption>().PillarType = PillarType.MIDDLE_PILLAR;

            GetPage(NetType.Bridge).AddUIComponent<UILightOption>();
            //GetPage(NetType.Bridge).AddUIComponent<UILightDistanceOption>();
            GetPage(NetType.Bridge).AddUIComponent<UIPillarOption>().PillarType = PillarType.BridgePillar;
            //GetPage(NetType.BRIDGE).AddUIComponent<UIPillarOption>().PillarType = PillarType.MIDDLE_PILLAR;
            //GetPage(NetType.BRIDGE).AddUIComponent<UIBridgeTypeOption>();

            _tabstrip.startSelectedIndex = (int)NetType.Ground;

            Debug.Log("End UINetworkSkinsPanel.Awake");
        }
Exemplo n.º 42
0
        public override void Start()
        {
            base.Start ();
            Debug.PrintMessage ("Start");
            this.size = new Vector2 (WIDTH, HEIGHT);
            this.backgroundSprite = "MenuPanel";
            this.canFocus = true;
            this.isInteractive = true;
            this.BringToFront ();
            this.relativePosition = new Vector3 (50, 50);
            this.Show ();
            this.cachedName = cacheName;

            m_challengePanel = (ChallengePanel) this.GetUIView ().AddUIComponent (typeof(ChallengePanel));
            Debug.PrintMessage("Start() - Does ChallengePanel Exists? " + (m_challengePanel != null).ToString());
            m_challengePanel.manager = this;
            m_challengePanel.OnChallengeStarted += () => {m_selectButton.Disable ();};
            m_challengePanel.OnChallengeEnded += () => {m_selectButton.Enable ();};

            m_challengePanel.Hide ();

            m_title = this.AddUIComponent<UILabel> ();
            m_title.text = "CHALLENGES OPTIONS";
            m_title.relativePosition = new Vector3 (WIDTH / 2 - m_title.width / 2, HEAD / 2 - m_title.height / 2);
            m_title.textAlignment = UIHorizontalAlignment.Center;

            m_dragHandle = this.AddUIComponent<UIDragHandle> ();
            m_dragHandle.size = new Vector2(WIDTH,HEIGHT);
            m_dragHandle.relativePosition = Vector3.zero;
            m_dragHandle.target = this;

            m_closeButton = this.AddUIComponent<UIButton> ();
            m_closeButton.normalBgSprite = "buttonclose";
            m_closeButton.hoveredBgSprite = "buttonclosehover";
            m_closeButton.pressedBgSprite = "buttonclosepressed";
            m_closeButton.relativePosition = new Vector3 (WIDTH - 35, 5,10);
            m_closeButton.eventClick += (component, eventParam) => {
                this.Hide();
            };

            m_challengeListPanel = this.AddUIComponent<UIPanel> ();
            m_challengeListPanel.size = new Vector2 (LIST_PANEL_WIDTH, LIST_PANEL_HEIGHT);
            m_challengeListPanel.relativePosition = new Vector3 (0, HEAD);

            m_challengeBrowser = m_challengeListPanel.AddUIComponent<UIListBox> ();
            m_challengeBrowser.size = new Vector2 (LIST_PANEL_WIDTH - SPACING * 2, LIST_PANEL_HEIGHT - SELECT_BUTTON_HEIGHT - SPACING * 2);
            m_challengeBrowser.relativePosition = new Vector3 (SPACING, SPACING);

            m_challengeBrowser.normalBgSprite = "GenericPanelDark";
            //m_challengeBrowser.bottomColor = Color.green;

            m_challengeBrowser.itemHighlight = "ListItemHighlight";
            m_challengeBrowser.itemHover = "ListItemHover";
            m_challengeBrowser.itemPadding.left = 10;
            m_challengeBrowser.itemPadding.top = 4;
            m_challengeBrowser.listPadding.top = 10;
            m_challengeBrowser.listPadding.bottom = 10;
            m_challengeBrowser.colorizeSprites = true;

            LoadChallenges ();

            m_selectButton = m_challengeListPanel.AddUIComponent<UIButton> ();
            m_selectButton.text = "START";
            m_selectButton.size = new Vector2 (LIST_PANEL_WIDTH - SPACING * 2, SELECT_BUTTON_HEIGHT - SPACING);
            m_selectButton.textScale = 1.25f;
            m_selectButton.textVerticalAlignment = UIVerticalAlignment.Middle;
            m_selectButton.textHorizontalAlignment = UIHorizontalAlignment.Center;
            m_selectButton.normalBgSprite = "ButtonMenu";
            m_selectButton.hoveredBgSprite = "ButtonMenuHovered";
            m_selectButton.pressedBgSprite = "ButtonMenuPressed";
            m_selectButton.disabledBgSprite = "ButtonMenuDisabled";
            m_selectButton.color = Color.green;
            m_selectButton.focusedColor = m_selectButton.color;
            m_selectButton.hoveredColor = m_selectButton.color;
            m_selectButton.pressedColor = m_selectButton.color;
            m_selectButton.relativePosition = new Vector3 (SPACING, LIST_PANEL_HEIGHT - SELECT_BUTTON_HEIGHT);
            m_selectButton.Disable ();
            m_selectButton.eventClick += ChallengeSelected;

            m_refresh = this.AddUIComponent<UIButton> ();
            m_refresh.size = new Vector2 (60,24);
            m_refresh.text = "Refresh";
            m_refresh.textScale = 0.875f;
            m_refresh.normalBgSprite = "ButtonMenu";
            m_refresh.hoveredBgSprite = "ButtonMenuHovered";
            m_refresh.pressedBgSprite = "ButtonMenuPressed";
            m_refresh.disabledBgSprite = "ButtonMenuDisabled";
            //m_refresh.color = new Color32(255,0,0,255);
            //m_refresh.focusedColor = m_refresh.color;
            //m_refresh.hoveredColor = m_refresh.color;
            //m_refresh.pressedColor = m_refresh.color;
            m_refresh.relativePosition = m_closeButton.relativePosition + new Vector3 (-60 -SPACING,6f);
            m_refresh.eventClick += (component, eventParam) => {LoadChallenges();};

            m_challengeDetailsPanel = this.AddUIComponent<UIPanel> ();
            m_challengeDetailsPanel.size = new Vector2 (WIDTH - LIST_PANEL_WIDTH, HEIGHT - HEAD);
            //m_challengeDetailsPanel.backgroundSprite = "GenericPanel";
            m_challengeDetailsPanel.relativePosition = new Vector3 (LIST_PANEL_WIDTH, HEAD);

            m_challengeName = m_challengeDetailsPanel.AddUIComponent<UILabel> ();
            m_challengeName.text = "Name\n";
            m_challengeName.disabledTextColor = Color.gray;
            m_challengeName.Disable ();

            m_challengeDesc = m_challengeDetailsPanel.AddUIComponent<UILabel> ();
            m_challengeDesc.text = "Description\n";
            //m_challengeDesc.backgroundSprite = "GenericPanel";
            m_challengeDesc.width = m_challengeDetailsPanel.width;
            m_challengeDesc.minimumSize = new Vector2 (m_challengeDetailsPanel.width - SPACING * 2, 20);
            m_challengeDesc.wordWrap = true;
            m_challengeDesc.disabledTextColor = Color.gray;
            m_challengeDesc.Disable ();

            m_challengeBreakdown = m_challengeDetailsPanel.AddUIComponent<UILabel> ();
            m_challengeBreakdown.text = "Breakdown\n";
            //m_challengeBreakdown.backgroundSprite = "GenericPanel";
            m_challengeBreakdown.minimumSize = new Vector2 (m_challengeDetailsPanel.width - SPACING * 2, 20);
            m_challengeBreakdown.wordWrap = true;
            m_challengeBreakdown.disabledTextColor = Color.gray;
            m_challengeBreakdown.Disable ();

            m_challengeReward = m_challengeDetailsPanel.AddUIComponent<UILabel> ();
            m_challengeReward.text = "Reward\n";
            //m_challengeBreakdown.backgroundSprite = "GenericPanel";
            m_challengeReward.minimumSize = new Vector2 (m_challengeDetailsPanel.width - SPACING * 2, 20);
            m_challengeReward.wordWrap = true;
            m_challengeReward.autoSize = true;
            m_challengeReward.disabledTextColor = Color.gray;
            m_challengeReward.Disable ();

            m_challengePenalty = m_challengeDetailsPanel.AddUIComponent<UILabel> ();
            m_challengePenalty.text = "Penalty\n";
            //m_challengeBreakdown.backgroundSprite = "GenericPanel";
            m_challengePenalty.minimumSize = new Vector2 (m_challengeDetailsPanel.width - SPACING * 2, 20);
            m_challengePenalty.wordWrap = true;
            m_challengePenalty.autoSize = true;
            m_challengePenalty.disabledTextColor = Color.gray;
            m_challengePenalty.Disable ();

            m_challengeDeadline = m_challengeDetailsPanel.AddUIComponent<UILabel> ();
            m_challengeDeadline.text = "Duration\n";
            m_challengeDeadline.disabledTextColor = Color.gray;
            m_challengeDeadline.Disable ();

            FormatDetails ();

            if (m_temp_challenge != null) {
                m_challengePanel.SetCurrentChallenge (m_temp_challenge,true);
                //m_temp_challenge = null;
            }
        }