public override void Awake()
        {
            base.Awake();

            //setup tabstrip
            this.size                      = DEFAULT_TABSTRIP_SIZE;
            this.tabstrip                  = base.AddUIComponent <UITabstrip>();
            this.tabstrip.size             = DEFAULT_TABSTRIP_SIZE;
            this.tabstrip.relativePosition = new Vector3(0f, 0f);
            this.tabstrip.padding          = DEFAULT_TAB_PADDING;

            //setup first button
            UIButton _buttonItemwise = tabstrip.AddTab();

            _buttonItemwise.autoSize        = false;
            _buttonItemwise.playAudioEvents = true;
            UISimpleElems.ModifyToCustomButton(ref _buttonItemwise, DEFAULT_BUTTON_SIZE, new Vector3(0f, 0f), "PLT_ItemwiseZero", "", SpriteManager.atlasPLT);
            //setup second button
            UIButton _buttonSpacing = tabstrip.AddTab("Spacing", _buttonItemwise, false);

            UISimpleElems.ModifyToCustomButton(ref _buttonSpacing, DEFAULT_BUTTON_SIZE, DEFAULT_BUTTON_SIZE + DEFAULT_TAB_SPACING, "PLT_SpacingwiseZero", "", SpriteManager.atlasPLT);
            //finalize buttons
            _buttonItemwise.focusedBgSprite = "PLT_ItemwiseOneFocused";
            _buttonItemwise.tooltip         = "[PLT]: Itemwise Control\n\nPlace one item at a time along the curve.";
            _buttonSpacing.focusedBgSprite  = "PLT_SpacingwiseOneFocused";
            _buttonSpacing.tooltip          = "[PLT]: Spacingwise Control (Default)\n\nPlace items at discrete intervals.";

            //penultimately
            tabstrip.startSelectedIndex = (int)PropLineTool.controlMode;
            tabstrip.selectedIndex      = (int)PropLineTool.controlMode;

            //finally
            //event subscriptions
            this.tabstrip.eventSelectedIndexChanged += delegate(UIComponent c, int index)
            {
                PropLineTool.controlMode = (PropLineTool.ControlMode)index;
            };
        }
Example #2
0
        public override void Awake()
        {
            base.Awake();

            Debug.Log("[PLT] begin UIOptionPanel.Awake()");

            //old as of 161129
            //Util.LoadSprites();
            //new as of 161129
            SpriteManager.CreateAtlasPLT();

            //setup panel
            //base.width = 256;
            //base.height = 36;
            base.size                    = SIZE_DEFAULT_INGAME;
            this._panel                  = base.AddUIComponent <UIPanel>();
            this._panel.name             = "HolderPanel";
            this._panel.width            = base.width;
            this._panel.height           = base.height;
            this._panel.relativePosition = new Vector3(0f, 0f);

            //setup snapping toggle
            this._snappingToggle                  = UISimpleElems.AddAThreeStateButton(this._panel, "PLT_ToggleSnapping", SpriteManager.atlasPLT, "PLT_MultiStateZero", "PLT_MultiStateOne", "PLT_MultiStateTwo", "PLT_SnappingModeZero", "PLT_SnappingModeOne", "PLT_SnappingModeTwo");
            this._snappingToggle.height           = 36f;
            this._snappingToggle.width            = 36f;
            this._snappingToggle.relativePosition = new Vector3(0f, 0f, 0f);
            this._snappingToggle.playAudioEvents  = true;
            this._snappingToggle.tooltip          = "[PLT]: Toggle Snapping";
            if (this._snappingToggle != null)
            {
                this._snappingToggle.eventActiveStateIndexChanged += delegate(UIComponent sender, int index)
                {
                    PropLineTool.m_snapMode = this.m_snapModes[index];
                };
            }

            //setup fenceMode toggle
            this._fenceModeToggle        = UISimpleElems.AddAToggleButton(this._panel, "PLTToggleFenceMode", SpriteManager.atlasPLT, "PLT_MultiStateZero", "PLT_MultiStateOne", "PLT_FenceModeZero", "PLT_FenceModeOne");
            this._fenceModeToggle.height = 36f;
            this._fenceModeToggle.width  = 36f;
            //this._fenceModeToggle.relativePosition = new Vector3(36f, 0f, 0f);
            //new for circle draw mode
            this._fenceModeToggle.relativePosition = new Vector3(0f, 0f, 0f);
            this._fenceModeToggle.playAudioEvents  = true;
            this._fenceModeToggle.tooltip          = "[PLT]: Toggle Fence Mode";
            if (this._fenceModeToggle != null)
            {
                this._fenceModeToggle.eventActiveStateIndexChanged += delegate(UIComponent sender, int index)
                {
                    bool _fenceModeActive = false;
                    if (index >= 1)
                    {
                        _fenceModeActive = true;
                    }
                    else if (index <= 0)
                    {
                        _fenceModeActive = false;
                    }
                    PropLineTool.fenceMode = _fenceModeActive;
                };
            }

            //setup tabstrip
            this._tabstrip = this._panel.AddUIComponent <UITabstrip>();
            //this._tabstrip.relativePosition = new Vector3(72f, 0f, 0f);
            //this._tabstrip.width = 144f;
            //new for circle draw mode
            this._tabstrip.relativePosition = new Vector3(36f, 0f, 0f);
            this._tabstrip.width            = 180f;
            this._tabstrip.height           = 36f;
            this._tabstrip.padding.right    = 0;
            UIButton       componentInChildren = GameObject.Find("ToolMode").GetComponent <UITabstrip>().GetComponentInChildren <UIButton>();
            UITextureAtlas atlas = UIView.GetAView().defaultAtlas;

            for (int i = 0; i < TOOL_MODE_NAMES.Length; i++)
            {
                UIButton _button = this._tabstrip.AddTab(TOOL_MODE_NAMES[i], componentInChildren, false);
                _button.autoSize = false;

                _button.tooltip = "[PLT]: " + TOOL_MODE_NAMES[i];

                _button.height = 36f;
                _button.width  = 36f;

                if (i == 0 || i == 4)
                {
                    _button.name = i == 4 ? "PLTCircle" : "PLTSingle";

                    _button.normalFgSprite   = "";
                    _button.focusedFgSprite  = "";
                    _button.hoveredFgSprite  = "";
                    _button.pressedFgSprite  = "";
                    _button.disabledFgSprite = "";

                    _button.text              = i == 4 ? "○" : "•";
                    _button.textScale         = i == 4? 3.0f : 1.5f;
                    _button.textPadding.left  = i == 4 ? -2 : 0;
                    _button.textPadding.right = 1;
                    _button.textPadding.top   = i == 4 ? -13 : 4;
                    //_button.textPadding.bottom = i == 4? 2 : 0;
                    _button.textPadding.bottom = 0;
                    _button.textColor          = new Color32(119, 124, 126, 255);
                    _button.hoveredTextColor   = new Color32(110, 113, 114, 255);
                    _button.pressedTextColor   = new Color32(172, 175, 176, 255);
                    _button.focusedTextColor   = new Color32(187, 224, 235, 255);
                    _button.disabledTextColor  = new Color32(66, 69, 70, 255);
                }


                if (i > 0 && i < 4)
                {
                    _button.name = "PLT" + TOOL_MODE_NAMES[i];

                    string str = "RoadOption" + TOOL_MODE_NAMES[i];
                    _button.normalFgSprite   = str;
                    _button.focusedFgSprite  = str + "Focused";
                    _button.hoveredFgSprite  = str + "Hovered";
                    _button.pressedFgSprite  = str + "Pressed";
                    _button.disabledFgSprite = str + "Disabled";
                }

                _button.playAudioEvents = componentInChildren.playAudioEvents;
            }
            //setup selected index in case of re-Load from in-game
            this._tabstrip.selectedIndex = (int)PropLineTool.drawMode;
            if (this._tabstrip != null)
            {
                this._tabstrip.eventSelectedIndexChanged += delegate(UIComponent sender, int index)
                {
                    PropLineTool.drawMode = this.m_drawModes[index];
                };
            }

            //setup controlPanel toggle
            this._controlPanelToggle                  = UISimpleElems.AddAToggleButton(this._panel, "PLTToggleControlPanel", SpriteManager.atlasPLT, "PLT_ToggleCPZero", "PLT_ToggleCPOne", "", "");
            this._controlPanelToggle.height           = 36f;
            this._controlPanelToggle.width            = 36f;
            this._controlPanelToggle.relativePosition = new Vector3(216f, 0f, 0f);
            this._controlPanelToggle.playAudioEvents  = true;
            this._controlPanelToggle.tooltip          = "[PLT]: Toggle Control Panel";
            if (this._controlPanelToggle != null)
            {
                this._controlPanelToggle.eventActiveStateIndexChanged += delegate(UIComponent sender, int index)
                {
                    if (index >= 1)
                    {
                        PropLineToolMod.basicControlPanel.Show();
                    }
                    else if (index <= 0)
                    {
                        PropLineToolMod.basicControlPanel.Hide();
                    }
                };
            }



            base.FitChildren();

            //this is only important to set to zero if we call it after the _tabstrip.eventSelectedIndexChanged event subscription
            //***VERY IMPORTANT THAT THIS EQUALS ZERO***
            //so that TreeTool or PropTool can initialize before PropLineTool
            this._tabstrip.startSelectedIndex = 0;


            //fix sprites if PLTAtlas could not be created
            if (SpriteManager.atlasPLT == null)
            {
                RevertToBackupToggleButtons();
            }

            //event subscriptions
            PropLineTool.eventActiveStateChanged += PropLineTool_ActiveStateChanged;

            Debug.Log("[PLT] end UIOptionPanel.Awake()");
        }