Inheritance: UIRect
Ejemplo n.º 1
0
	/// <summary>做初始設定,並傳回是否成功初始化</summary>
	private bool checkAndInit(){
		
		if(cacheGameObject == null){
			cacheGameObject = gameObject;
			if(cacheGameObject == null){
				return false;
			}
		}
		
		if(targetPanel == null){
			targetPanel = NGUITools.FindInParents<UIPanel>(transform);
			if(targetPanel == null){
				Debug.LogWarning("找不到 Panel", cacheGameObject);
				return false;
			}
		}

		if(cacheRenderer == null){
			ParticleSystem cacheParticle = cacheGameObject.GetComponent<ParticleSystem>();
			if(cacheParticle != null){
				cacheRenderer = cacheParticle.GetComponent<Renderer>();
			}else{
				cacheRenderer = cacheGameObject.GetComponent<ParticleRenderer>();
			}
			
			if(cacheRenderer == null){
				Debug.LogWarning("沒有 renderer 物件!");
				return false;
			}
		}
		return true;
	}
Ejemplo n.º 2
0
 void Start()
 {
     state = GetComponent<StateMachineState>();
     panel = GetComponent<UIPanel>();
     state.Enter += Enter;
     state.Exit += Exit;
 }
 private void Awake()
 {
     this.mTrans = base.transform;
     this.mPanel = base.GetComponent<UIPanel>();
     if (this.mPanel.clipping == UIDrawCall.Clipping.None)
     {
         this.mPanel.clipping = UIDrawCall.Clipping.Invisible;
     }
     if ((this.movement != Movement.Custom) && (this.scale.sqrMagnitude > 0.001f))
     {
         if ((this.scale.x == 1f) && (this.scale.y == 0f))
         {
             this.movement = Movement.Horizontal;
         }
         else if ((this.scale.x == 0f) && (this.scale.y == 1f))
         {
             this.movement = Movement.Vertical;
         }
         else if ((this.scale.x == 1f) && (this.scale.y == 1f))
         {
             this.movement = Movement.Unrestricted;
         }
         else
         {
             this.movement = Movement.Custom;
             this.customMovement.x = this.scale.x;
             this.customMovement.y = this.scale.y;
         }
         this.scale = Vector3.zero;
     }
     if (Application.isPlaying)
     {
         this.mPanel.onChange = (UIPanel.OnChangeDelegate) Delegate.Combine(this.mPanel.onChange, new UIPanel.OnChangeDelegate(this.OnPanelChange));
     }
 }
Ejemplo n.º 4
0
    // Use this for initialization
    void Start()
    {
        meetingListPage = GameObject.Find("mainPannel").GetComponent<UIPanel>();
        grid = meetingListPage.GetComponentInChildren<UIGrid>();

        this.initFakeData();
    }
 public static void Init(GameAreaInfoPanel g)
 {
     m_AreaIndex = g.GetType().GetField("m_AreaIndex", BindingFlags.NonPublic | BindingFlags.Instance);
        m_FullscreenContainer = UIView.Find("FullScreenContainer");
        m_Title = g.Find<UILabel>("Title");
        m_BuildableArea = g.Find<UILabel>("BuildableArea");
        m_Price = g.Find<UILabel>("Price");
        m_PurchasePanel = g.Find<UIPanel>("PurchasePanel");
        m_OilResources = g.Find<UIProgressBar>("ResourceBarOil");
        m_OreResources = g.Find<UIProgressBar>("ResourceBarOre");
        m_ForestryResources = g.Find<UIProgressBar>("ResourceBarForestry");
        m_FertilityResources = g.Find<UIProgressBar>("ResourceBarFarming");
        m_OilNoResources = g.Find("ResourceOil").Find<UISprite>("NoNoNo");
        m_OreNoResources = g.Find("ResourceOre").Find<UISprite>("NoNoNo");
        m_ForestryNoResources = g.Find("ResourceForestry").Find<UISprite>("NoNoNo");
        m_FertilityNoResources = g.Find("ResourceFarming").Find<UISprite>("NoNoNo");
        m_Water = g.Find<UISprite>("Water");
        m_NoWater =m_Water.Find<UISprite>("NoNoNo");
        m_Highway = g.Find<UISprite>("Highway");
        m_NoHighway =m_Highway.Find<UISprite>("NoNoNo");
        m_InHighway =m_Highway.Find<UISprite>("Incoming");
        m_OutHighway =m_Highway.Find<UISprite>("Outgoing");
        m_Train = g.Find<UISprite>("Train");
        m_NoTrain =m_Train.Find<UISprite>("NoNoNo");
        m_InTrain =m_Train.Find<UISprite>("Incoming");
        m_OutTrain =m_Train.Find<UISprite>("Outgoing");
        m_Ship = g.Find<UISprite>("Ship");
        m_NoShip =m_Ship.Find<UISprite>("NoNoNo");
        m_InShip =m_Ship.Find<UISprite>("Incoming");
        m_OutShip =m_Ship.Find<UISprite>("Outgoing");
        m_Plane = g.Find<UISprite>("Plane");
        m_NoPlane =m_Plane.Find<UISprite>("NoNoNo");
        m_InPlane =m_Plane.Find<UISprite>("Incoming");
        m_OutPlane = m_Plane.Find<UISprite>("Outgoing");
 }
Ejemplo n.º 6
0
	void Start () 
	{
		//create root window
		this.window = NGUITools.CreateUI(false);

		HHGameLayoutPanel.GetGamePanel(5,this.window.gameObject);
	}
Ejemplo n.º 7
0
 private void CreateObjects()
 {
     this.mPanel = base.gameObject.GetComponent<UIPanel>();
     this.mBG = GameUITools.FindGameObject("BG", base.gameObject);
     this.mTitle = GameUITools.FindUILabel("Title", this.mBG);
     this.mTeamCombat = GameUITools.FindUILabel("TeamCombat", this.mBG);
     this.mRecommendCombat = GameUITools.FindUILabel("RecommendCombat", this.mBG);
     GameUITools.FindUILabel("Times/Value", this.mBG).text = (GameConst.GetInt32(125) - Globals.Instance.Player.Data.MGCount).ToString();
     this.mRewards = GameUITools.FindGameObject("Rewards", this.mBG);
     this.mPending = GameUITools.FindGameObject("Pending", this.mBG).AddComponent<GUIGuardReadyPopUp.PendingPetFragment>();
     this.mPending.Init();
     GameObject gameObject = GameUITools.FindGameObject("Levels", this.mBG);
     int num = 0;
     while (num < 3 && num < gameObject.transform.childCount)
     {
         this.mLevelItems[num] = gameObject.transform.GetChild(num).gameObject.AddComponent<GUIGuardReadyPopUp.LevelItem>();
         this.mLevelItems[num].Init(num, new EventDelegate.Callback(this.RefreshInfo));
         num++;
     }
     GameUITools.RegisterClickEvent("FadeBG", new UIEventListener.VoidDelegate(this.OnCloseClick), base.gameObject);
     GameUITools.RegisterClickEvent("CloseBtn", new UIEventListener.VoidDelegate(this.OnCloseClick), this.mBG);
     GameUITools.RegisterClickEvent("TeamBtn", new UIEventListener.VoidDelegate(this.OnTeamClick), this.mBG);
     GameUITools.RegisterClickEvent("StartBtn", new UIEventListener.VoidDelegate(this.OnStartBtnClick), this.mBG);
     this.mFarmBtn = GameUITools.RegisterClickEvent("FarmBtn", new UIEventListener.VoidDelegate(this.OnFarmBtnClick), this.mBG);
 }
Ejemplo n.º 8
0
	void Start()
	{
		_uiPanel = GetComponent<UIPanel>();
		_uiScrollView = GetComponent<UIScrollView>();
		if(_uiScrollView != null)
			_originalUiScrollViewMomentum = _uiScrollView.currentMomentum;
	}
Ejemplo n.º 9
0
    public override void Awake()
    {
        base.Awake();

        _UIPanelReceiver = GetComponent<UIPanel>();
		_sprite = GetComponent<UISprite> ();
    }
Ejemplo n.º 10
0
 private void Start()
 {
     if(command == MenuAction.back)
     {
         panel = gameObject.transform.parent.gameObject.GetComponent<UIPanel>();
     }
 }
Ejemplo n.º 11
0
	void Start() 
	{
		holder = transform.parent.GetComponent<CompanionsHolder>();
		
		selectedObj = transform.Find("Selected").gameObject;
		unselectedObj = transform.Find("Unselected").gameObject;
		selectedObj.SetActive(selected);
		unselectedObj.SetActive(!selected);
		
		if (selected) {
			myPanel = selectedObj.GetComponent<UISprite>().panel;
			Select();
		} 
		else {
			myPanel = unselectedObj.GetComponent<UISprite>().panel;
		}
		
		myPanel.Refresh();
		
//		if (selected) {
//			holder.selectedCompanion = this;
//		}
		
		selectEvent = "Select " + name.Substring(name.Length - 1);
	}
Ejemplo n.º 12
0
	/// <summary>
	/// Show the specified window.
	/// </summary>

	static public void Show (UIPanel window)
	{
		if (mActive == window) return;

		CreateInstance();

		if (mActive != null)
		{
			mFading.Add(mActive);
			mHistory.Add(mActive);
		}

		if (mHistory.Remove(window))
		{
			mFading.Remove(window);
		}
		else if (window != null)
		{
            window.alpha = 0;
			//window. SetAlphaRecursive(0f, false);
		}

		mActive = window;
        if (mActive != null)
        {
            mActive.gameObject.SetActive(true);
        }
	}
Ejemplo n.º 13
0
 public void Init()
 {
     base.transform.localPosition = new Vector3(0f, 0f, -580f);
     this.mWinBG = base.transform.Find("winBG");
     this.mCloseBtn = this.mWinBG.Find("closeBtn").gameObject;
     this.mCloseBtn.SetActive(false);
     UIEventListener expr_67 = UIEventListener.Get(this.mCloseBtn);
     expr_67.onClick = (UIEventListener.VoidDelegate)Delegate.Combine(expr_67.onClick, new UIEventListener.VoidDelegate(this.OnCloseBtnClicked));
     UIEventListener expr_93 = UIEventListener.Get(base.gameObject);
     expr_93.onClick = (UIEventListener.VoidDelegate)Delegate.Combine(expr_93.onClick, new UIEventListener.VoidDelegate(this.OnCloseBtnClicked));
     this.mFinishFarm = this.mWinBG.Find("finish").gameObject;
     this.mFinishFarm.SetActive(false);
     UIEventListener expr_E6 = UIEventListener.Get(this.mFinishFarm);
     expr_E6.onClick = (UIEventListener.VoidDelegate)Delegate.Combine(expr_E6.onClick, new UIEventListener.VoidDelegate(this.OnCloseBtnClicked));
     UIEventListener expr_121 = UIEventListener.Get(base.transform.Find("FadeBG").gameObject);
     expr_121.onClick = (UIEventListener.VoidDelegate)Delegate.Combine(expr_121.onClick, new UIEventListener.VoidDelegate(this.OnCloseBtnClicked));
     this.panel = this.mWinBG.FindChild("bagPanel").GetComponent<UIPanel>();
     this.mFarmTable = this.panel.transform.Find("bagContents").gameObject.AddComponent<PillageFarmUITable>();
     this.mFarmTable.maxPerLine = 1;
     this.mFarmTable.arrangement = UICustomGrid.Arrangement.Vertical;
     this.mFarmTable.cellWidth = 486f;
     this.mFarmTable.cellHeight = 130f;
     this.mFarmTable.gapHeight = 0f;
     this.mFarmTable.gapWidth = 0f;
 }
Ejemplo n.º 14
0
 private void DestroyPage(UIPanel go)
 {
     if (go != null)
     {
         GameObject.Destroy(go.gameObject);
     }
 }
Ejemplo n.º 15
0
        void Awake()
        {
            m_Panel = GetComponent<UIPanel>();

            string[] spritenames = {
                "symbol_001",
                "symbol_002",
                "symbol_003",
                "symbol_004",
                "symbol_005",
                "symbol_006",
                "symbol_007",
                "symbol_008",
                "symbol_009",
                "symbol_010"
            };

            spriteNames = spritenames;

            m_slotLines = new SlotLine[5];
            SlotLines = new SlotLine[5];

            for (int i = 0; i < 5; i++)
            {
                SlotLines[i] = GameObject.Find("SLOTLINE_" + (i + 1)).GetComponent<SlotLine>();
                
                SlotLines[i].onTweenFinishCB = Listener_Tween;

                SlotLines[i].onStopCB = Listener_SlotStop;
                SlotLines[i].Init(spritenames);
            }
            m_slotLines = SlotLines;
        }
Ejemplo n.º 16
0
 private void Awake()
 {
     panelCached = ScrollView.GetComponentInChildren<UIPanel>();
     gridCached = ScrollView.GetComponentInChildren<UIGrid>();
     ScrollView.onDragFinished += OnDragFinished;
     restrictWithinPanelCached = ScrollView.restrictWithinPanel;
 }
	void InitObject()
	{
		if(boxCollider == null)
			boxCollider = transform.GetComponent<BoxCollider>();
		if(panel == null)
			panel = transform.GetComponent<UIPanel>();
	}
Ejemplo n.º 18
0
	void GoToPanel (UIPanel targetPanel) {
		NGUITools.SetActive (startPanel.gameObject, false);
		NGUITools.SetActive (homePanel.gameObject, false);
		NGUITools.SetActive (resultPanel.gameObject, false);
		NGUITools.SetActive (storePanel.gameObject, false);
		NGUITools.SetActive (descriptionPanel.gameObject, false);
		NGUITools.SetActive (targetPanel.gameObject, true);
	}
 private void FindPanel()
 {
     this.mPanel = (this.target == null) ? null : UIPanel.Find(this.target.transform, false);
     if (this.mPanel == null)
     {
         this.restrictWithinPanel = false;
     }
 }
Ejemplo n.º 20
0
 /// <summary>
 /// Adds a copy of the slider panel object to the extended panel.
 /// </summary>
 /// <param name="originalSliderObject">The original slider panel to add.</param>
 public void addSlider(UIPanel originalSliderObject)
 {
     UIPanel sliderObject = duplicateUIPanel(originalSliderObject);
     //sliderObject.transform.parent = this.transform;
     AttachUIComponent(sliderObject.gameObject);
     sliders.Add(sliderObject);
     slimCloseTimer.Add(-1);
 }
Ejemplo n.º 21
0
 private void CreateObjects()
 {
     this.mPanel = base.gameObject.GetComponent<UIPanel>();
     this.mMsgBg = base.transform.Find("bg").GetComponent<UISprite>();
     this.mMsgTxt = base.transform.Find("msg").GetComponent<UILabel>();
     this.mIsInit = true;
     this.mIsDestroy = false;
 }
        private void Start()
        {
            m_Container = (UIScrollablePanel)typeof(DecorationPropertiesPanel).GetField("m_Container", BindingFlags.GetField | BindingFlags.SetField | BindingFlags.NonPublic | BindingFlags.Instance)
                .GetValue(UIView.Find<UIPanel>("DecorationProperties").GetComponent<DecorationPropertiesPanel>());

            m_SizePanel = (UIPanel)typeof(DecorationPropertiesPanel).GetField("m_SizePanel", BindingFlags.GetField | BindingFlags.SetField | BindingFlags.NonPublic | BindingFlags.Instance)
                .GetValue(UIView.Find<UIPanel>("DecorationProperties").GetComponent<DecorationPropertiesPanel>());
        }
 private void Awake()
 {
     this.mPanel = base.GetComponent<UIPanel>();
     if (this.mPanel == null)
     {
         this.mWidget = base.GetComponentInChildren<UIWidget>();
     }
 }
Ejemplo n.º 24
0
    public bool AddPanel( string strName, UIPanel uiPanel )
    {
        if( mapPanel.ContainsKey(strName) )
            return false;

        mapPanel.Add(strName, uiPanel);
        return true;
    }
 private static void SetPanelPosition(Transform panelTrans, Vector3 localOffset, UIPanel targetPsanel)
 {
     panelTrans.localPosition = panelTrans.localPosition - localOffset;
     Vector4 co = targetPsanel.clipOffset;
     co.x += localOffset.x;
     co.y += localOffset.y;
     targetPsanel.clipOffset = co;
 }
Ejemplo n.º 26
0
 private void Init()
 {
     this.mInitDone = true;
     if (this.keepWithinPanel)
     {
         this.mPanel = NGUITools.FindInParents<UIPanel>(base.gameObject);
         this.mDrag = NGUITools.FindInParents<UIScrollView>(base.gameObject);
     }
 }
Ejemplo n.º 27
0
 public static void FlipPanels(UIPanel source, UIPanel target)
 {
     source.transform.localPosition += new Vector3 (1000, 0, 0);
     target.transform.localPosition -= new Vector3 (1000, 0, 0);
     source.enabled = false;
     target.enabled = true;
     source.SendMessage ("PanelFlipOut", target, SendMessageOptions.DontRequireReceiver);
     target.SendMessage ("PanelFlipIn", source, SendMessageOptions.DontRequireReceiver);
 }
 private void InitScrollView()
 {
     if (this.mScrollView != null)
         mPanel = this.mScrollView.GetComponent<UIPanel>();
     this.mTrans = mGrid.transform;
     // reset the scroll view.
     isInitLoopManager = true;
     ResetScrollView();
 }
Ejemplo n.º 29
0
 void Start()
 {
     panel = GetComponent<UIPanel>();
     panel.alpha = 0;
     menu1 = GameObject.Find("Menu1").GetComponent<UILabel>();
     menu2 = GameObject.Find("Menu2").GetComponent<UILabel>();
     menu3 = GameObject.Find("Menu3").GetComponent<UILabel>();
     menu4 = GameObject.Find("Menu4").GetComponent<UILabel>();
 }
Ejemplo n.º 30
0
	/// <summary>
	/// Ensure that the specified window has been added to the list.
	/// </summary>

	static public void Add (UIPanel window)
	{
		if (mActive == window) return;

		CreateInstance();

		if (mActive == null)
			mActive = window;
	}
Ejemplo n.º 31
0
    /// <summary>
    /// Draw widget's depth.
    /// </summary>

    static void DrawDepth(SerializedObject so, UIWidget w, bool isPrefab)
    {
        if (isPrefab)
        {
            return;
        }

        GUILayout.Space(2f);
        GUILayout.BeginHorizontal();
        {
            EditorGUILayout.PrefixLabel("Depth");

            if (GUILayout.Button("Back", GUILayout.MinWidth(46f)))
            {
                {
                    // foreach(var go in Selection.gameObjects)
                    var __enumerator2 = (Selection.gameObjects).GetEnumerator();
                    while (__enumerator2.MoveNext())
                    {
                        var go = (GameObject)__enumerator2.Current;
                        {
                            UIWidget pw = go.GetComponent <UIWidget>();
                            if (pw != null)
                            {
                                pw.depth = w.depth - 1;
                            }
                        }
                    }
                }
            }

            NGUIEditorTools.DrawProperty("", so, "mDepth", GUILayout.MinWidth(20f));

            if (GUILayout.Button("Forward", GUILayout.MinWidth(60f)))
            {
                {
                    // foreach(var go in Selection.gameObjects)
                    var __enumerator3 = (Selection.gameObjects).GetEnumerator();
                    while (__enumerator3.MoveNext())
                    {
                        var go = (GameObject)__enumerator3.Current;
                        {
                            UIWidget pw = go.GetComponent <UIWidget>();
                            if (pw != null)
                            {
                                pw.depth = w.depth + 1;
                            }
                        }
                    }
                }
            }
        }
        GUILayout.EndHorizontal();

        int matchingDepths = 1;

        UIPanel p = w.panel;

        if (p != null)
        {
            for (int i = 0, imax = p.widgets.Count; i < imax; ++i)
            {
                UIWidget pw = p.widgets[i];
                if (pw != w && pw.depth == w.depth)
                {
                    ++matchingDepths;
                }
            }
        }

        if (matchingDepths > 1)
        {
            EditorGUILayout.HelpBox(matchingDepths + " widgets are sharing the depth value of " + w.depth, MessageType.Info);
        }
    }
Ejemplo n.º 32
0
        public override void OnInitialize()
        {
            UIElement uIElement = new UIElement();

            uIElement.Width.Set(0f, 0.8f);
            uIElement.MaxWidth.Set(600f, 0f);
            uIElement.Top.Set(220f, 0f);
            uIElement.Height.Set(-220f, 1f);
            uIElement.HAlign = 0.5f;
            UIPanel uIPanel = new UIPanel();

            uIPanel.Width.Set(0f, 1f);
            uIPanel.Height.Set(-110f, 1f);
            uIPanel.BackgroundColor = new Color(33, 43, 79) * 0.8f;
            uIElement.Append(uIPanel);
            modList = new UIList();
            modList.Width.Set(-25f, 1f);
            modList.Height.Set(0f, 1f);
            modList.ListPadding = 5f;
            uIPanel.Append(modList);
            UIScrollbar uIScrollbar = new UIScrollbar();

            uIScrollbar.SetView(100f, 1000f);
            uIScrollbar.Height.Set(0f, 1f);
            uIScrollbar.HAlign = 1f;
            uIPanel.Append(uIScrollbar);
            modList.SetScrollbar(uIScrollbar);
            UITextPanel <string> uITextPanel = new UITextPanel <string>("Mod Sources", 0.8f, true);

            uITextPanel.HAlign = 0.5f;
            uITextPanel.Top.Set(-35f, 0f);
            uITextPanel.SetPadding(15f);
            uITextPanel.BackgroundColor = new Color(73, 94, 171);
            uIElement.Append(uITextPanel);
            UITextPanel <string> button = new UITextPanel <string>("Build All", 1f, false);

            button.Width.Set(-10f, 0.5f);
            button.Height.Set(25f, 0f);
            button.VAlign = 1f;
            button.Top.Set(-65f, 0f);
            button.OnMouseOver += UICommon.FadedMouseOver;
            button.OnMouseOut  += UICommon.FadedMouseOut;
            button.OnClick     += BuildMods;
            uIElement.Append(button);
            UITextPanel <string> button2 = new UITextPanel <string>("Build + Reload All", 1f, false);

            button2.CopyStyle(button);
            button2.HAlign       = 1f;
            button2.OnMouseOver += UICommon.FadedMouseOver;
            button2.OnMouseOut  += UICommon.FadedMouseOut;
            button2.OnClick     += BuildAndReload;
            uIElement.Append(button2);
            UITextPanel <string> button3 = new UITextPanel <string>("Back", 1f, false);

            button3.CopyStyle(button);
            button3.Width.Set(-10f, 1f / 3f);
            button3.Top.Set(-20f, 0f);
            button3.OnMouseOver += UICommon.FadedMouseOver;
            button3.OnMouseOut  += UICommon.FadedMouseOut;
            button3.OnClick     += BackClick;
            uIElement.Append(button3);
            UITextPanel <string> button4 = new UITextPanel <string>("Open Sources", 1f, false);

            button4.CopyStyle(button3);
            button4.HAlign       = .5f;
            button4.OnMouseOver += UICommon.FadedMouseOver;
            button4.OnMouseOut  += UICommon.FadedMouseOut;
            button4.OnClick     += OpenSources;
            uIElement.Append(button4);
            UITextPanel <string> button5 = new UITextPanel <string>("Manage Published", 1f, false);

            button5.CopyStyle(button3);
            button5.HAlign       = 1f;
            button5.OnMouseOver += UICommon.FadedMouseOver;
            button5.OnMouseOut  += UICommon.FadedMouseOut;
            button5.OnClick     += ManagePublished;
            uIElement.Append(button5);
            base.Append(uIElement);
        }
Ejemplo n.º 33
0
    /// <summary>
    /// Draw the custom wizard.
    /// </summary>

    void OnGUI()
    {
        List <UIPanel> panels = GetListOfPanels();

        if (panels != null && panels.Count > 0)
        {
            UIPanel selectedPanel = NGUITools.FindInParents <UIPanel>(Selection.activeGameObject);

            // First, collect a list of panels with their associated widgets
            List <Entry> entries       = new List <Entry>();
            Entry        selectedEntry = null;
            bool         allEnabled    = true;

            foreach (UIPanel panel in panels)
            {
                Entry ent = new Entry();
                ent.panel          = panel;
                ent.widgets        = GetWidgets(panel);
                ent.isEnabled      = panel.enabled && NGUITools.GetActive(panel.gameObject);
                ent.widgetsEnabled = ent.isEnabled;

                if (ent.widgetsEnabled)
                {
                    foreach (UIWidget w in ent.widgets)
                    {
                        if (!NGUITools.GetActive(w.gameObject))
                        {
                            allEnabled         = false;
                            ent.widgetsEnabled = false;
                            break;
                        }
                    }
                }
                else
                {
                    allEnabled = false;
                }
                entries.Add(ent);
            }

            // Sort the list by depth
            entries.Sort(Compare);

            mScroll = GUILayout.BeginScrollView(mScroll);

            NGUIEditorTools.SetLabelWidth(80f);
            bool showAll = DrawRow(null, null, allEnabled);
            NGUIEditorTools.DrawSeparator();

            foreach (Entry ent in entries)
            {
                if (DrawRow(ent, selectedPanel, ent.widgetsEnabled))
                {
                    selectedEntry = ent;
                }
            }

            GUILayout.EndScrollView();

            if (showAll)
            {
                foreach (Entry ent in entries)
                {
                    NGUITools.SetActive(ent.panel.gameObject, !allEnabled);
                }
            }
            else if (selectedEntry != null)
            {
                NGUITools.SetActive(selectedEntry.panel.gameObject, !selectedEntry.widgetsEnabled);
            }
        }
        else
        {
            GUILayout.Label("No UI Panels found in the scene");
        }
    }
Ejemplo n.º 34
0
		////////////////

		public override void OnInitialize() {
			var mymod = (HonorBoundMod)HonorBoundMod.Instance;
			var myworld = ModContent.GetInstance<HonorBoundWorld>();

			if( HonorBoundUI.BackgroundLogo == null ) {
				HonorBoundUI.BackgroundLogo = mymod.GetTexture( "BackgroundLogo" );
			}

			float top = 0;
			
			this.MainPanel = new UIPanel();
			this.MainPanel.Left.Set( -(HonorBoundUI.PanelWidth / 2f), 0.5f );
			this.MainPanel.Top.Set( 8f - HonorBoundUI.PanelHeight, 0f );
			this.MainPanel.Width.Set( HonorBoundUI.PanelWidth, 0f );
			this.MainPanel.Height.Set( HonorBoundUI.PanelHeight, 0f );
			this.MainPanel.SetPadding( 12f );
			this.MainPanel.BackgroundColor = new Color( 0, 0, 64 );
			
			var bg = new UIImage( HonorBoundUI.BackgroundLogo );
			bg.Top.Set( 0f, 0.05f );
			bg.Left.Set( 0f, 0.4f );
			this.MainPanel.Append( bg );

			this.MainPanel.Append( new UIText( "Choose your honorifics:", 0.9f ) );
			
			foreach( var kv in HonorBoundLogic.Honorifics ) {
				top += 20f;
				
				string honorific = kv.Key;
				var uiOption = new UICheckbox( UITheme.Vanilla, honorific, String.Join("\n", kv.Value.Descriptions) );

				uiOption.Top.Set( top, 0f );
				uiOption.SetText( "    "+honorific, 0.8f, false );
				uiOption.TextColor = Color.Gray;

				uiOption.OnSelectedChanged += delegate () {
					mymod = (HonorBoundMod)ModLoader.GetMod( "HonorBound" );
					myworld = ModContent.GetInstance<HonorBoundWorld>();
					
					if( uiOption.Selected ) {
						myworld.Logic.CurrentActiveHonorifics.Add( honorific );
					} else {
						myworld.Logic.CurrentActiveHonorifics.Remove( honorific );
					}
				};

				this.Options[ honorific ] = uiOption;
				this.MainPanel.Append( uiOption );
			}
			
			top += 20f;
			var honorWarnText = new UIText( "Warning: Settings are permanent for your\nworld when honor bound.\nSelect 'No Honor' to play only vanilla.", 0.7f );
			honorWarnText.Top.Set( top, 0f );
			honorWarnText.Left.Set( 0, 0f );
			honorWarnText.TextColor = Color.Yellow;
			this.MainPanel.Append( honorWarnText );

			top += 56f;
			var forHonorButton = new UITextPanel<string>( "For Honor!" );
			forHonorButton.SetPadding( 4f );
			forHonorButton.Width.Set( HonorBoundUI.PanelWidth - 24f, 0f );
			forHonorButton.Left.Set( 0f, 0 );
			forHonorButton.Top.Set( top, 0f );
			forHonorButton.OnClick += delegate ( UIMouseEvent evt, UIElement listeningElement ) {
				this.ActivateForHonor();
			};
			forHonorButton.OnMouseOver += delegate ( UIMouseEvent evt, UIElement listeningElement ) {
				forHonorButton.BackgroundColor = HonorBoundUI.ButtonBodyLitColor;
			};
			forHonorButton.OnMouseOut += delegate ( UIMouseEvent evt, UIElement listeningElement ) {
				forHonorButton.BackgroundColor = HonorBoundUI.ButtonBodyColor;
			};
			this.MainPanel.Append( forHonorButton );
			
			top += 32f;
			var noHonorButton = new UITextPanel<string>( "No Honor..." );
			noHonorButton.SetPadding( 4f );
			noHonorButton.Width.Set( HonorBoundUI.PanelWidth - 24f, 0f );
			noHonorButton.Left.Set( 0f, 0 );
			noHonorButton.Top.Set( top, 0f );
			noHonorButton.OnClick += delegate( UIMouseEvent evt, UIElement listeningElement ) {
				this.ActivateNoHonor();
			};
			noHonorButton.OnMouseOver += delegate ( UIMouseEvent evt, UIElement listeningElement ) {
				noHonorButton.BackgroundColor = HonorBoundUI.ButtonBodyLitColor;
			};
			noHonorButton.OnMouseOut += delegate ( UIMouseEvent evt, UIElement listeningElement ) {
				noHonorButton.BackgroundColor = HonorBoundUI.ButtonBodyColor;
			};
			this.MainPanel.Append( noHonorButton );
			
			this.Append( this.MainPanel );
		}
Ejemplo n.º 35
0
    /// <summary>
    /// Create a brand-new UI hierarchy.
    /// </summary>

    static public GameObject CreateNewUI()
    {
        NGUIEditorTools.RegisterUndo("Create New UI");

        // Root for the UI
        GameObject root = null;

        if (camType == CameraType.Simple2D)
        {
            root = new GameObject("UI Root (2D)");
            root.AddComponent <UIRoot>().scalingStyle = UIRoot.Scaling.PixelPerfect;
        }
        else
        {
            root = new GameObject((camType == CameraType.Advanced3D) ? "UI Root (3D)" : "UI Root");
            root.transform.localScale = new Vector3(0.0025f, 0.0025f, 0.0025f);
            root.AddComponent <UIRoot>().scalingStyle = UIRoot.Scaling.FixedSize;
        }

        // Assign the layer to be used by everything
        root.layer = NGUISettings.layer;

        // Figure out the depth of the highest camera
        if (camType == CameraType.None)
        {
            // No camera requested -- simply add a panel
            UIPanel panel = NGUITools.AddChild <UIPanel>(root.gameObject);
            panel.sortByDepth          = true;
            Selection.activeGameObject = panel.gameObject;
        }
        else
        {
            int   mask          = 1 << NGUISettings.layer;
            float depth         = -1f;
            bool  clearColor    = true;
            bool  audioListener = true;

            List <Camera> cameras = NGUIEditorTools.FindInScene <Camera>();

            foreach (Camera c in cameras)
            {
                // Choose the maximum depth
                depth = Mathf.Max(depth, c.depth);

                // Automatically exclude the specified layer mask from the camera if it can see more than that layer
                if (NGUISettings.layer != 0 && c.cullingMask != mask)
                {
                    c.cullingMask = (c.cullingMask & (~mask));
                }

                // Only consider this object if it's active
                if (c.enabled && NGUITools.GetActive(c.gameObject))
                {
                    clearColor = false;
                }

                // If this camera has an audio listener, we won't need to add one
                if (c.GetComponent <AudioListener>() != null)
                {
                    audioListener = false;
                }
            }

            // Camera and UICamera for this UI
            Camera cam = NGUITools.AddChild <Camera>(root);
            cam.depth           = depth + 1;
            cam.backgroundColor = Color.grey;
            cam.cullingMask     = mask;

            if (camType == CameraType.Simple2D)
            {
                cam.orthographicSize = 1f;
                cam.orthographic     = true;
                cam.nearClipPlane    = -2f;
                cam.farClipPlane     = 2f;
            }
            else
            {
                cam.nearClipPlane           = 0.1f;
                cam.farClipPlane            = 4f;
                cam.transform.localPosition = new Vector3(0f, 0f, -700f);
            }

            // We don't want to clear color if this is not the first camera
            if (cameras.Count > 0)
            {
                cam.clearFlags = clearColor ? CameraClearFlags.Skybox : CameraClearFlags.Depth;
            }

            // Add an audio listener if we need one
            if (audioListener)
            {
                cam.gameObject.AddComponent <AudioListener>();
            }

            // Add a UI Camera for event handling
            cam.gameObject.AddComponent <UICamera>();

            if (camType == CameraType.Simple2D)
            {
                // Anchor is useful to have
                UIAnchor anchor = NGUITools.AddChild <UIAnchor>(cam.gameObject);
                anchor.uiCamera = cam;

                // And finally -- the first UI panel
                UIPanel panel = NGUITools.AddChild <UIPanel>(anchor.gameObject);
                panel.sortByDepth          = true;
                Selection.activeGameObject = panel.gameObject;
            }
            else
            {
                UIPanel panel = NGUITools.AddChild <UIPanel>(root);
                panel.sortByDepth          = true;
                Selection.activeGameObject = panel.gameObject;
            }
        }
        return(Selection.activeGameObject);
    }
Ejemplo n.º 36
0
        public override void OnInitialize()
        {
            _rootElement = new UIElement {
                Width    = { Percent = 0.8f },
                MaxWidth = UICommon.MaxPanelWidth,
                Top      = { Pixels = 220 },
                Height   = { Pixels = -220, Percent = 1f },
                HAlign   = 0.5f
            };

            _backgroundElement = new UIPanel {
                Width           = { Percent = 1f },
                Height          = { Pixels = -110, Percent = 1f },
                BackgroundColor = UICommon.MainPanelBackground,
                PaddingTop      = 0f
            };
            _rootElement.Append(_backgroundElement);

            _loaderElement = new UILoaderAnimatedImage(0.5f, 0.5f);

            ModList = new UIList {
                Width       = { Pixels = -25, Percent = 1f },
                Height      = { Pixels = -50, Percent = 1f },
                Top         = { Pixels = 50 },
                ListPadding = 5f
            };

            var listScrollbar = new UIScrollbar {
                Height = { Pixels = -50, Percent = 1f },
                Top    = { Pixels = 50 },
                HAlign = 1f
            }.WithView(100f, 1000f);

            _backgroundElement.Append(listScrollbar);

            _backgroundElement.Append(ModList);
            ModList.SetScrollbar(listScrollbar);

            HeaderTextPanel = new UITextPanel <string>(Language.GetTextValue("tModLoader.MenuModBrowser"), 0.8f, true)
            {
                HAlign          = 0.5f,
                Top             = { Pixels = -35 },
                BackgroundColor = UICommon.DefaultUIBlue
            }.WithPadding(15f);
            _backgroundElement.Append(HeaderTextPanel);

            _reloadButton = new UITextPanel <string>(Language.GetTextValue("tModLoader.MBGettingData"))
            {
                Width  = { Pixels = -10, Percent = 0.5f },
                Height = { Pixels = 25 },
                VAlign = 1f,
                Top    = { Pixels = -65 }
            }.WithFadedMouseOver();

            _backButton = new UITextPanel <string>(Language.GetTextValue("UI.Back"))
            {
                Width  = { Pixels = -10, Percent = 0.5f },
                Height = { Pixels = 25 },
                VAlign = 1f,
                Top    = { Pixels = -20 }
            }.WithFadedMouseOver();

            _clearButton = new UITextPanel <string>(Language.GetTextValue("tModLoader.MBClearSpecialFilter", "??"))
            {
                Width           = { Pixels = -10, Percent = 0.5f },
                Height          = { Pixels = 25 },
                HAlign          = 1f,
                VAlign          = 1f,
                Top             = { Pixels = -65 },
                BackgroundColor = Color.Purple * 0.7f
            }.WithFadedMouseOver(Color.Purple, Color.Purple * 0.7f);

            _updateAllButton = new UITextPanel <string>(Language.GetTextValue("tModLoader.MBUpdateAll"))
            {
                Width           = { Pixels = -10, Percent = 0.5f },
                Height          = { Pixels = 25 },
                HAlign          = 1f,
                VAlign          = 1f,
                Top             = { Pixels = -20 },
                BackgroundColor = Color.Orange * 0.7f
            }.WithFadedMouseOver(Color.Orange, Color.Orange * 0.7f);

            _downloadAllButton = new UITextPanel <string>(Language.GetTextValue("tModLoader.MBDownloadAll"))
            {
                Width           = { Pixels = -10, Percent = 0.5f },
                Height          = { Pixels = 25 },
                HAlign          = 1f,
                VAlign          = 1f,
                Top             = { Pixels = -20 },
                BackgroundColor = Color.Azure * 0.7f
            }.WithFadedMouseOver(Color.Azure, Color.Azure * 0.7f);

            NoModsFoundText = new UIText(Language.GetTextValue("tModLoader.MBNoModsFound"))
            {
                HAlign = 0.5f
            }.WithPadding(15f);

            FilterTextBox = new UIInputTextField(Language.GetTextValue("tModLoader.ModsTypeToSearch"))
            {
                Top    = { Pixels = 5 },
                Left   = { Pixels = -160, Percent = 1f },
                Width  = { Pixels = 100 },
                Height = { Pixels = 10 }
            };

            _upperMenuContainer = new UIElement {
                Width  = { Percent = 1f },
                Height = { Pixels = 32 },
                Top    = { Pixels = 10 }
            };

            _filterTextBoxBackground = new UIPanel {
                Top    = { Percent = 0f },
                Left   = { Pixels = -170, Percent = 1f },
                Width  = { Pixels = 135 },
                Height = { Pixels = 40 }
            };

            SortModeFilterToggle = new UIBrowserFilterToggle <ModBrowserSortMode>(0, 0)
            {
                Left = new StyleDimension {
                    Pixels = 0 * 36 + 8
                }
            };
            UpdateFilterToggle = new UIBrowserFilterToggle <UpdateFilter>(34, 0)
            {
                Left = new StyleDimension {
                    Pixels = 1 * 36 + 8
                }
            };
            SearchFilterToggle = new UIBrowserFilterToggle <SearchFilter>(34 * 2, 0)
            {
                Left = new StyleDimension {
                    Pixels = 545f
                }
            };
            ModSideFilterToggle = new UIBrowserFilterToggle <ModSideFilter>(34 * 5, 0)
            {
                Left = new StyleDimension {
                    Pixels = 2 * 36 + 8
                }
            };
            SearchFilterToggle.SetCurrentState(SearchFilter.Name);
            UpdateFilterToggle.SetCurrentState(UpdateFilter.Available);
            ModSideFilterToggle.SetCurrentState(ModSideFilter.All);
            SortModeFilterToggle.SetCurrentState(ModBrowserSortMode.RecentlyUpdated);

            InitializeInteractions();

            _rootElement.Append(_reloadButton);
            _rootElement.Append(_backButton);

            CategoryButtons.Add(SortModeFilterToggle);
            _upperMenuContainer.Append(SortModeFilterToggle);
            CategoryButtons.Add(UpdateFilterToggle);
            _upperMenuContainer.Append(UpdateFilterToggle);
            CategoryButtons.Add(ModSideFilterToggle);
            _upperMenuContainer.Append(ModSideFilterToggle);
            CategoryButtons.Add(SearchFilterToggle);
            _upperMenuContainer.Append(SearchFilterToggle);

            _upperMenuContainer.Append(_filterTextBoxBackground);
            _upperMenuContainer.Append(FilterTextBox);
            _backgroundElement.Append(_upperMenuContainer);

            Append(_rootElement);
        }
    /// <summary>
    /// Anchor the object to the appropriate point.
    /// </summary>

    void Update()
    {
        if (mAnim != null && mAnim.enabled && mAnim.isPlaying)
        {
            return;
        }

        bool useCamera = false;

        UIWidget wc = (container == null) ? null : container.GetComponent <UIWidget>();
        UIPanel  pc = (container == null && wc == null) ? null : container.GetComponent <UIPanel>();

        if (wc != null)
        {
            Bounds b = wc.CalculateBounds(container.transform.parent);

            mRect.x = b.min.x;
            mRect.y = b.min.y;

            mRect.width  = b.size.x;
            mRect.height = b.size.y;
        }
        else if (pc != null)
        {
            if (pc.clipping == UIDrawCall.Clipping.None)
            {
                // Panel has no clipping -- just use the screen's dimensions
                float ratio = (mRoot != null) ? (float)mRoot.activeHeight / Screen.height * 0.5f : 0.5f;
                mRect.xMin = -Screen.width * ratio;
                mRect.yMin = -Screen.height * ratio;
                mRect.xMax = -mRect.xMin;
                mRect.yMax = -mRect.yMin;
            }
            else
            {
                // Panel has clipping -- use it as the mRect
                Vector4 pos = pc.finalClipRegion;
                mRect.x      = pos.x - (pos.z * 0.5f);
                mRect.y      = pos.y - (pos.w * 0.5f);
                mRect.width  = pos.z;
                mRect.height = pos.w;
            }
        }
        else if (container != null)
        {
            Transform root = container.transform.parent;
            Bounds    b    = (root != null) ? NGUIMath.CalculateRelativeWidgetBounds(root, container.transform) :
                             NGUIMath.CalculateRelativeWidgetBounds(container.transform);

            mRect.x = b.min.x;
            mRect.y = b.min.y;

            mRect.width  = b.size.x;
            mRect.height = b.size.y;
        }
        else if (uiCamera != null)
        {
            useCamera = true;
            mRect     = uiCamera.pixelRect;
        }
        else
        {
            return;
        }

        float   cx = (mRect.xMin + mRect.xMax) * 0.5f;
        float   cy = (mRect.yMin + mRect.yMax) * 0.5f;
        Vector3 v  = new Vector3(cx, cy, 0f);

        if (side != Side.Center)
        {
            if (side == Side.Right || side == Side.TopRight || side == Side.BottomRight)
            {
                v.x = mRect.xMax;
            }
            else if (side == Side.Top || side == Side.Center || side == Side.Bottom)
            {
                v.x = cx;
            }
            else
            {
                v.x = mRect.xMin;
            }

            if (side == Side.Top || side == Side.TopRight || side == Side.TopLeft)
            {
                v.y = mRect.yMax;
            }
            else if (side == Side.Left || side == Side.Center || side == Side.Right)
            {
                v.y = cy;
            }
            else
            {
                v.y = mRect.yMin;
            }
        }

        float width  = mRect.width;
        float height = mRect.height;

        v.x += pixelOffset.x + relativeOffset.x * width;
        v.y += pixelOffset.y + relativeOffset.y * height;

        if (useCamera)
        {
            if (uiCamera.orthographic)
            {
                v.x = Mathf.Round(v.x);
                v.y = Mathf.Round(v.y);
            }

            v.z = uiCamera.WorldToScreenPoint(mTrans.position).z;
            v   = uiCamera.ScreenToWorldPoint(v);
        }
        else
        {
            v.x = Mathf.Round(v.x);
            v.y = Mathf.Round(v.y);

            if (pc != null)
            {
                v = pc.cachedTransform.TransformPoint(v);
            }
            else if (container != null)
            {
                Transform t = container.transform.parent;
                if (t != null)
                {
                    v = t.TransformPoint(v);
                }
            }
            v.z = mTrans.position.z;
        }

        // Wrapped in an 'if' so the scene doesn't get marked as 'edited' every frame
        if (mTrans.position != v)
        {
            mTrans.position = v;
        }
        if (runOnlyOnce && Application.isPlaying)
        {
            enabled = false;
        }
    }
Ejemplo n.º 38
0
        private void BuildPage()
        {
            this.RemoveAllChildren();
            UIElement element1 = new UIElement();

            element1.Width.Set(0.0f, 0.8f);
            element1.MaxWidth.Set(500f, 0.0f);
            element1.MinWidth.Set(300f, 0.0f);
            element1.Top.Set(230f, 0.0f);
            element1.Height.Set(-element1.Top.Pixels, 1f);
            element1.HAlign = 0.5f;
            this.Append(element1);
            UIPanel uiPanel = new UIPanel();

            uiPanel.Width.Set(0.0f, 1f);
            uiPanel.Height.Set(-110f, 1f);
            uiPanel.BackgroundColor = new Color(33, 43, 79) * 0.8f;
            element1.Append((UIElement)uiPanel);
            UIElement element2 = new UIElement()
            {
                Width  = StyleDimension.Fill,
                Height = StyleDimension.FromPixelsAndPercent(0.0f, 1f)
            };

            uiPanel.Append(element2);
            UIElement element3 = new UIElement()
            {
                Width  = new StyleDimension(0.0f, 1f),
                Height = new StyleDimension(52f, 0.0f)
            };

            element3.SetPadding(0.0f);
            element2.Append(element3);
            UIText uiText1 = new UIText(this._pack.Name, 0.7f, true)
            {
                TextColor = Color.Gold
            };

            uiText1.HAlign = 0.5f;
            uiText1.VAlign = 0.0f;
            element3.Append((UIElement)uiText1);
            UIText uiText2 = new UIText(Language.GetTextValue("UI.Author", (object)this._pack.Author), 0.9f, false);

            uiText2.HAlign = 0.0f;
            uiText2.VAlign = 1f;
            UIText uiText3 = uiText2;

            uiText3.Top.Set(-6f, 0.0f);
            element3.Append((UIElement)uiText3);
            UIText uiText4 = new UIText(Language.GetTextValue("UI.Version", (object)this._pack.Version.GetFormattedVersion()), 0.9f, false);

            uiText4.HAlign    = 1f;
            uiText4.VAlign    = 1f;
            uiText4.TextColor = Color.Silver;
            UIText uiText5 = uiText4;

            uiText5.Top.Set(-6f, 0.0f);
            element3.Append((UIElement)uiText5);
            Asset <Texture2D> asset    = (Asset <Texture2D>)Main.Assets.Request <Texture2D>("Images/UI/Divider", (AssetRequestMode)1);
            UIImage           uiImage1 = new UIImage(asset);

            uiImage1.Width      = StyleDimension.FromPixelsAndPercent(0.0f, 1f);
            uiImage1.Height     = StyleDimension.FromPixels((float)asset.Height());
            uiImage1.ScaleToFit = true;
            UIImage uiImage2 = uiImage1;

            uiImage2.Top.Set(52f, 0.0f);
            uiImage2.SetPadding(6f);
            element2.Append((UIElement)uiImage2);
            UIElement element4 = new UIElement()
            {
                HAlign = 0.5f,
                VAlign = 1f,
                Width  = StyleDimension.FromPixelsAndPercent(0.0f, 1f),
                Height = StyleDimension.FromPixelsAndPercent(-74f, 1f)
            };

            element2.Append(element4);
            this._container = element4;
            UIText uiText6 = new UIText(this._pack.Description, 1f, false);

            uiText6.HAlign    = 0.5f;
            uiText6.VAlign    = 0.0f;
            uiText6.Width     = StyleDimension.FromPixelsAndPercent(0.0f, 1f);
            uiText6.Height    = StyleDimension.FromPixelsAndPercent(0.0f, 0.0f);
            uiText6.IsWrapped = true;
            uiText6.WrappedTextBottomPadding = 0.0f;
            UIText uiText7 = uiText6;
            UIList uiList1 = new UIList();

            uiList1.HAlign       = 0.5f;
            uiList1.VAlign       = 0.0f;
            uiList1.Width        = StyleDimension.FromPixelsAndPercent(0.0f, 1f);
            uiList1.Height       = StyleDimension.FromPixelsAndPercent(0.0f, 1f);
            uiList1.PaddingRight = 20f;
            UIList uiList2 = uiList1;

            uiList2.ListPadding = 5f;
            uiList2.Add((UIElement)uiText7);
            element4.Append((UIElement)uiList2);
            this._list = uiList2;
            UIScrollbar scrollbar = new UIScrollbar();

            scrollbar.SetView(100f, 1000f);
            scrollbar.Height.Set(0.0f, 1f);
            scrollbar.HAlign = 1f;
            this._scrollbar  = scrollbar;
            uiList2.SetScrollbar(scrollbar);
            UITextPanel <LocalizedText> uiTextPanel = new UITextPanel <LocalizedText>(Language.GetText("UI.Back"), 0.7f, true);

            uiTextPanel.Width.Set(-10f, 0.5f);
            uiTextPanel.Height.Set(50f, 0.0f);
            uiTextPanel.VAlign = 1f;
            uiTextPanel.HAlign = 0.5f;
            uiTextPanel.Top.Set(-45f, 0.0f);
            uiTextPanel.OnMouseOver += new UIElement.MouseEvent(UIResourcePackInfoMenu.FadedMouseOver);
            uiTextPanel.OnMouseOut  += new UIElement.MouseEvent(UIResourcePackInfoMenu.FadedMouseOut);
            uiTextPanel.OnClick     += new UIElement.MouseEvent(this.GoBackClick);
            uiTextPanel.SetSnapPoint("GoBack", 0, new Vector2?(), new Vector2?());
            element1.Append((UIElement)uiTextPanel);
        }
Ejemplo n.º 39
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);
            };
        }
Ejemplo n.º 40
0
        public override void OnInitialize()
        {
            uIElement = new UIElement {
                Width    = { Percent = 0.8f },
                MaxWidth = UICommon.MaxPanelWidth,
                Top      = { Pixels = 220 },
                Height   = { Pixels = -220, Percent = 1f },
                HAlign   = 0.5f
            };

            uIPanel = new UIPanel {
                Width           = { Percent = 1f },
                Height          = { Pixels = -110, Percent = 1f },
                BackgroundColor = UICommon.mainPanelBackground,
                PaddingTop      = 0f
            };
            uIElement.Append(uIPanel);

            uiLoader = new UILoaderAnimatedImage(0.5f, 0.5f, 1f);

            modList = new UIList {
                Width       = { Pixels = -25, Percent = 1f },
                Height      = { Pixels = -50, Percent = 1f },
                Top         = { Pixels = 50 },
                ListPadding = 5f
            };
            uIPanel.Append(modList);

            var uIScrollbar = new UIScrollbar {
                Height = { Pixels = -50, Percent = 1f },
                Top    = { Pixels = 50 },
                HAlign = 1f
            }.WithView(100f, 1000f);

            uIPanel.Append(uIScrollbar);

            modList.SetScrollbar(uIScrollbar);

            var uIHeaderTexTPanel = new UITextPanel <string>(Language.GetTextValue("tModLoader.ModsModsList"), 0.8f, true)
            {
                HAlign          = 0.5f,
                Top             = { Pixels = -35 },
                BackgroundColor = UICommon.defaultUIBlue
            }.WithPadding(15f);

            uIElement.Append(uIHeaderTexTPanel);

            buttonEA = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModsEnableAll"))
            {
                TextColor = Color.Green,
                Width     = new StyleDimension(-10f, 1f / 3f),
                Height    = { Pixels = 40 },
                VAlign    = 1f,
                Top       = { Pixels = -65 }
            }.WithFadedMouseOver();
            buttonEA.OnClick += EnableAll;
            uIElement.Append(buttonEA);

            // TODO CopyStyle doesn't capture all the duplication here, consider an inner method
            buttonDA = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModsDisableAll"));
            buttonDA.CopyStyle(buttonEA);
            buttonDA.TextColor = Color.Red;
            buttonDA.HAlign    = 0.5f;
            buttonDA.WithFadedMouseOver();
            buttonDA.OnClick += DisableAll;
            uIElement.Append(buttonDA);

            buttonRM = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModsReloadMods"));
            buttonRM.CopyStyle(buttonEA);
            buttonRM.HAlign = 1f;
            buttonDA.WithFadedMouseOver();
            buttonRM.OnClick += ReloadMods;
            uIElement.Append(buttonRM);

            buttonB = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("UI.Back"));
            buttonB.CopyStyle(buttonEA);
            buttonB.Top.Pixels = -20;
            buttonB.WithFadedMouseOver();
            buttonB.OnClick += BackClick;

            uIElement.Append(buttonB);
            buttonOMF = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModsOpenModsFolder"));
            buttonOMF.CopyStyle(buttonB);
            buttonOMF.HAlign = 0.5f;
            buttonOMF.WithFadedMouseOver();
            buttonOMF.OnClick += OpenModsFolder;
            uIElement.Append(buttonOMF);

            var texture            = Texture2D.FromStream(Main.instance.GraphicsDevice, Assembly.GetExecutingAssembly().GetManifestResourceStream("Terraria.ModLoader.UI.UIModBrowserIcons.png"));
            var upperMenuContainer = new UIElement {
                Width  = { Percent = 1f },
                Height = { Pixels = 32 },
                Top    = { Pixels = 10 }
            };

            UICycleImage toggleImage;

            for (int j = 0; j < 3; j++)
            {
                if (j == 0)                   //TODO: ouch, at least there's a loop but these click events look quite similar
                {
                    toggleImage = new UICycleImage(texture, 3, 32, 32, 34 * 3, 0);
                    toggleImage.setCurrentState((int)sortMode);
                    toggleImage.OnClick += (a, b) => {
                        sortMode     = sortMode.NextEnum();
                        updateNeeded = true;
                    };
                    toggleImage.OnRightClick += (a, b) => {
                        sortMode     = sortMode.PreviousEnum();
                        updateNeeded = true;
                    };
                }
                else if (j == 1)
                {
                    toggleImage = new UICycleImage(texture, 3, 32, 32, 34 * 4, 0);
                    toggleImage.setCurrentState((int)enabledFilterMode);
                    toggleImage.OnClick += (a, b) => {
                        enabledFilterMode = enabledFilterMode.NextEnum();
                        updateNeeded      = true;
                    };
                    toggleImage.OnRightClick += (a, b) => {
                        enabledFilterMode = enabledFilterMode.PreviousEnum();
                        updateNeeded      = true;
                    };
                }
                else
                {
                    toggleImage = new UICycleImage(texture, 5, 32, 32, 34 * 5, 0);
                    toggleImage.setCurrentState((int)modSideFilterMode);
                    toggleImage.OnClick += (a, b) => {
                        modSideFilterMode = modSideFilterMode.NextEnum();
                        updateNeeded      = true;
                    };
                    toggleImage.OnRightClick += (a, b) => {
                        modSideFilterMode = modSideFilterMode.PreviousEnum();
                        updateNeeded      = true;
                    };
                }
                toggleImage.Left.Pixels = j * 36 + 8;
                _categoryButtons.Add(toggleImage);
                upperMenuContainer.Append(toggleImage);
            }

            var filterTextBoxBackground = new UIPanel {
                Top    = { Percent = 0f },
                Left   = { Pixels = -170, Percent = 1f },
                Width  = { Pixels = 135 },
                Height = { Pixels = 40 }
            };

            filterTextBoxBackground.OnRightClick += (a, b) => filterTextBox.Text = "";
            upperMenuContainer.Append(filterTextBoxBackground);

            filterTextBox = new UIInputTextField(Language.GetTextValue("tModLoader.ModsTypeToSearch"))
            {
                Top    = { Pixels = 5 },
                Left   = { Pixels = -160, Percent = 1f },
                Width  = { Pixels = 160 },
                Height = { Pixels = 20 }
            };
            filterTextBox.OnTextChange += (a, b) => updateNeeded = true;
            upperMenuContainer.Append(filterTextBox);

            SearchFilterToggle = new UICycleImage(texture, 2, 32, 32, 34 * 2, 0)
            {
                Left = { Pixels = 545 }
            };
            SearchFilterToggle.setCurrentState((int)searchFilterMode);
            SearchFilterToggle.OnClick += (a, b) => {
                searchFilterMode = searchFilterMode.NextEnum();
                updateNeeded     = true;
            };
            SearchFilterToggle.OnRightClick += (a, b) => {
                searchFilterMode = searchFilterMode.PreviousEnum();
                updateNeeded     = true;
            };
            _categoryButtons.Add(SearchFilterToggle);
            upperMenuContainer.Append(SearchFilterToggle);

            buttonMP = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModsModPacks"));
            buttonMP.CopyStyle(buttonOMF);
            buttonMP.HAlign = 1f;
            buttonMP.WithFadedMouseOver();
            buttonMP.OnClick += GotoModPacksMenu;
            uIElement.Append(buttonMP);

            uIPanel.Append(upperMenuContainer);
            Append(uIElement);
        }
Ejemplo n.º 41
0
        public override void OnInitialize()
        {
            mainPanel = new UIPanel();
            int width  = 310;
            int height = 610;

            mainPanel.Left.Set(-40f - width, 1f);
            mainPanel.Top.Set(-100f - height, 1f);
            mainPanel.Width.Set(width, 0f);
            mainPanel.Height.Set(height, 0f);
            mainPanel.SetPadding(12);
            mainPanel.BackgroundColor = Color.Orange * 0.7f;

            int    top  = 0;
            UIText text = new UIText("Projectiles:", 0.85f);

            text.Top.Set(top, 0f);
            mainPanel.Append(text);

            UITextPanel <string> clearProjectilesButton = new UITextPanel <string>("Clear Projectiles");

            clearProjectilesButton.OnClick += (a, b) =>
            {
                for (int i = 0; i < Main.maxProjectiles; i++)
                {
                    if (Main.projectile[i].active)
                    {
                        Main.projectile[i].Kill();
                        if (Main.netMode == 1)
                        {
                            NetMessage.SendData(27, -1, -1, null, i, 0f, 0f, 0f, 0);
                        }
                    }
                }
            };
            clearProjectilesButton.Top.Set(top, 0f);
            clearProjectilesButton.Width.Set(-10, 0.5f);
            clearProjectilesButton.HAlign = 1;
            clearProjectilesButton.SetPadding(4);
            mainPanel.Append(clearProjectilesButton);

            top += 20;

            UIText text2 = new UIText("Filter:", 0.85f);

            text2.Top.Set(top, 0f);
            mainPanel.Append(text2);

            searchFilter = new NewUITextBox("Search", 0.85f);
            searchFilter.SetPadding(0);
            searchFilter.OnTextChanged += () => { ValidateInput(); updateneeded = true; };
            searchFilter.Top.Set(top, 0f);
            searchFilter.Left.Set(text2.GetInnerDimensions().Width, 0f);
            searchFilter.Width.Set(-text2.GetInnerDimensions().Width, 1f);
            searchFilter.Height.Set(20, 0f);
            //searchFilter.VAlign = 0.5f;
            mainPanel.Append(searchFilter);
            top += 20;

            speedXDataProperty = new UIFloatRangedDataValue("SpeedX:", 0, -10, 10);
            speedYDataProperty = new UIFloatRangedDataValue("SpeedY:", 0, -10, 10);
            var ui2DRange = new UI2DRange <float>(speedXDataProperty, speedYDataProperty);

            ui2DRange.Top.Set(top, 0f);
            mainPanel.Append(ui2DRange);
            top += 30;

            ai0DataProperty = new UIFloatRangedDataValue("ai0:", 0, -10, 10);
            var uiRange = new UIRange <float>(ai0DataProperty);

            uiRange.Top.Set(top, 0f);
            uiRange.Width.Set(0, 1f);
            mainPanel.Append(uiRange);
            top += 30;

            ai1DataProperty = new UIFloatRangedDataValue("ai1:", 0, -10, 10);
            uiRange         = new UIRange <float>(ai1DataProperty);
            uiRange.Top.Set(top, 0f);
            uiRange.Width.Set(0, 1f);
            mainPanel.Append(uiRange);
            top += 30;

            knockbackDataProperty = new UIFloatRangedDataValue("Knockback:", 0, 0, 20);
            uiRange = new UIRange <float>(knockbackDataProperty);
            uiRange.Top.Set(top, 0f);
            uiRange.Width.Set(0, 1f);
            mainPanel.Append(uiRange);
            top += 30;

            damageDataProperty = new UIIntRangedDataValue("Damage:", 20, 0, 200);
            var uiRangeI = new UIRange <int>(damageDataProperty);

            uiRangeI.Top.Set(top, 0f);
            uiRangeI.Width.Set(0, 1f);
            mainPanel.Append(uiRangeI);
            top += 30;

            aiStyleDataProperty = new UIIntRangedDataValue("AIStyle:", -1, -1, 145);
            uiRangeI            = new UIRange <int>(aiStyleDataProperty);
            uiRangeI.Top.Set(top, 0f);
            uiRangeI.Width.Set(0, 1f);
            mainPanel.Append(uiRangeI);
            top += 30;

            drawOffsetXDataProperty = new UIIntRangedDataValue("drawOffsetX:", 0, -30, 30);
            uiRangeI = new UIRange <int>(drawOffsetXDataProperty);
            uiRangeI.Top.Set(top, 0f);
            uiRangeI.Width.Set(0, 1f);
            mainPanel.Append(uiRangeI);
            top += 30;

            drawOriginOffsetXDataProperty = new UIIntRangedDataValue("drawOriginOffsetX:", 0, -30, 30);
            uiRangeI = new UIRange <int>(drawOriginOffsetXDataProperty);
            uiRangeI.Top.Set(top, 0f);
            uiRangeI.Width.Set(0, 1f);
            mainPanel.Append(uiRangeI);
            top += 30;

            drawOriginOffsetYDataProperty = new UIIntRangedDataValue("drawOriginOffsetY:", 0, -30, 30);
            uiRangeI = new UIRange <int>(drawOriginOffsetYDataProperty);
            uiRangeI.Top.Set(top, 0f);
            uiRangeI.Width.Set(0, 1f);
            mainPanel.Append(uiRangeI);
            top += 30;

            hostile = new UIBoolNDataValue("Hostile");
            var hostileCheckbox = new UITriStateCheckbox(hostile);

            hostileCheckbox.Top.Set(top, 0f);
            mainPanel.Append(hostileCheckbox);
            top += 30;

            friendly = new UIBoolNDataValue("Friendly");
            var friendlyCheckbox = new UITriStateCheckbox(friendly);

            friendlyCheckbox.Top.Set(top, 0f);
            mainPanel.Append(friendlyCheckbox);
            top += 25;

            pause = new UICheckbox("Pause", "Pauses All Projectiles (Prevent AI from running)");
            pause.Top.Set(top, 0f);
            mainPanel.Append(pause);

            UIHoverImageButton stepButton = new UIHoverImageButton(ModdersToolkit.instance.GetTexture("UIElements/next"), "Step");

            stepButton.OnClick += (s, e) => step = true;
            stepButton.Top.Set(top - 6, 0f);
            stepButton.Left.Set(80, 0f);
            mainPanel.Append(stepButton);

            top += 25;

            freeze = new UICheckbox("Freeze", "Zero out velocity during PreAI for All Projectiles");
            freeze.Top.Set(top, 0f);
            mainPanel.Append(freeze);
            top += 25;

            projectileGrid            = new UIGrid(7);
            projectileGrid.Top.Pixels = top;
            //autoTrashGrid.Left.Pixels = spacing;
            projectileGrid.Width.Set(-25f, 1f);             // leave space for scroll?
            projectileGrid.Height.Set(-top, 1f);
            projectileGrid.ListPadding = 6f;
            mainPanel.Append(projectileGrid);

            // this will initialize grid
            updateneeded = true;

            var projectileGridScrollbar = new UIElements.FixedUIScrollbar(userInterface);

            projectileGridScrollbar.SetView(100f, 1000f);
            projectileGridScrollbar.Top.Pixels = top;            // + spacing;
            projectileGridScrollbar.Height.Set(-top /*- spacing*/, 1f);
            projectileGridScrollbar.HAlign = 1f;
            mainPanel.Append(projectileGridScrollbar);
            projectileGrid.SetScrollbar(projectileGridScrollbar);

            Append(mainPanel);
        }
Ejemplo n.º 42
0
    void ShowBuffInfo(Transform container, bool bMainRole)
    {
        if (container == null)
        {
            return;
        }
        int       cellHegiht  = 100;
        Transform buffMessage = container.transform.Find("BuffMessage");

        if (buffMessage == null)
        {
            return;
        }

        ArrayList buffList = BuffManager.MainRoleBuffList;

        if (!bMainRole)
        {
            buffList = BuffManager.TargetBuffList;
        }
        if (buffList.Count == 0)
        {
            buffMessage.gameObject.SetActive(false);
        }
        else
        {
            //  buffMessage.gameObject.SetActive(true);
        }
        if (!buffMessage.gameObject.activeSelf)
        {
            return;
        }
        int       count       = buffList.Count < totalBuffIconCount ? buffList.Count : totalBuffIconCount;
        Transform scrollTrans = buffMessage.Find("ScrollView");

        if (scrollTrans == null)
        {
            return;
        }
        Transform bg = buffMessage.Find("Bg");

        if (bg == null)
        {
            return;
        }
        UIScrollView sv = scrollTrans.GetComponent <UIScrollView>();

        if (sv == null)
        {
            return;
        }
        UIPanel panel   = sv.GetComponent <UIPanel>();
        Vector4 baseVec = panel.baseClipRegion;

        panel.baseClipRegion = new Vector4(baseVec.x, -cellHegiht * (count) / 2 + cellHegiht / 2, baseVec.z, cellHegiht * count);
        panel.clipOffset     = new UnityEngine.Vector2(0, 0);
        UISprite spr = bg.GetComponent <UISprite>();

        if (spr != null)
        {
            spr.height = cellHegiht * count;
        }
        spr.transform.localPosition = new Vector3(0, -cellHegiht * (count - 1) / 2, 0);
        // sv.ResetPosition();


        // Transform gridTrans = scrollTrans.Find("BuffGrid");
        Transform gridTrans = scrollTrans;

        if (gridTrans == null)
        {
            return;
        }

        int childCount = gridTrans.childCount;

        for (int j = buffList.Count; j < childCount; j++)
        {
            string    buffItemName = GetBuffItemName(j);
            Transform itemTrans    = gridTrans.Find(buffItemName);
            if (itemTrans != null)
            {
                itemTrans.gameObject.SetActive(false);
            }
        }
        for (int i = 0; i < buffList.Count; i++)
        {
            Client.stAddBuff st = (Client.stAddBuff)buffList[i];

            BuffDataBase db = GameTableManager.Instance.GetTableItem <BuffDataBase>(st.buffid, (int)st.level);
            if (db != null)
            {
                GameObject buffItem     = null;
                string     buffItemName = GetBuffItemName(i);
                Transform  itemTrans    = gridTrans.Find(buffItemName);
                if (itemTrans != null)
                {
                    buffItem = itemTrans.gameObject;
                }
                else
                {
                    buffItem  = GameObject.Instantiate(m_trans_BuffItemInfo.gameObject) as GameObject;
                    itemTrans = buffItem.transform;
                }

                buffItem.transform.parent = sv.transform;//gridTrans;
                itemTrans.localScale      = Vector3.one;
                itemTrans.localRotation   = Quaternion.identity;
                itemTrans.localPosition   = new Vector3(0, -cellHegiht * i, 0);
                //  UIGrid grid = gridTrans.GetComponent<UIGrid>();

                buffItem.gameObject.SetActive(true);
                // grid.repositionNow = true;
                buffItem.name = buffItemName;
                UIDragScrollView dragScroll = buffItem.GetComponent <UIDragScrollView>();
                if (dragScroll == null)
                {
                    dragScroll = buffItem.AddComponent <UIDragScrollView>();
                }
                dragScroll.scrollView = sv;
                BuffItemInfo info = buffItem.GetComponent <BuffItemInfo>();
                if (info == null)
                {
                    info = buffItem.AddComponent <BuffItemInfo>();
                }

                info.InitBuffItemInfo(db, st.lTime);
            }
        }
    }
Ejemplo n.º 43
0
 public EscWatchBase(UIPanel panelName, string assetAddress, PanelType panelType) : base(panelName, assetAddress, panelType)
 {
 }
Ejemplo n.º 44
0
    /// <summary>
    /// This callback is sent inside the editor notifying us that some property has changed.
    /// </summary>

    protected override void OnValidate()
    {
        if (NGUITools.GetActive(this))
        {
            base.OnValidate();

            // Prior to NGUI 2.7.0 width and height was specified as transform's local scale
            if ((mWidth == 100 || mWidth == minWidth) &&
                (mHeight == 100 || mHeight == minHeight) && cachedTransform.localScale.magnitude > 8f)
            {
                UpgradeFrom265();
                cachedTransform.localScale = Vector3.one;
            }

            if (mWidth < minWidth)
            {
                mWidth = minWidth;
            }
            if (mHeight < minHeight)
            {
                mHeight = minHeight;
            }
            if (autoResizeBoxCollider)
            {
                ResizeCollider();
            }

            // If the texture is changing, we need to make sure to rebuild the draw calls
            if (mOldTex != mainTexture || mOldShader != shader)
            {
                mOldTex    = mainTexture;
                mOldShader = shader;
            }

            aspectRatio = (keepAspectRatio == AspectRatioSource.Free) ?
                          (float)mWidth / mHeight : Mathf.Max(0.01f, aspectRatio);

            if (keepAspectRatio == AspectRatioSource.BasedOnHeight)
            {
                mWidth = Mathf.RoundToInt(mHeight * aspectRatio);
            }
            else if (keepAspectRatio == AspectRatioSource.BasedOnWidth)
            {
                mHeight = Mathf.RoundToInt(mWidth / aspectRatio);
            }

            if (!Application.isPlaying)
            {
                if (panel != null)
                {
                    panel.RemoveWidget(this);
                    panel = null;
                }
                CreatePanel();
            }
        }
        else
        {
            if (mWidth < minWidth)
            {
                mWidth = minWidth;
            }
            if (mHeight < minHeight)
            {
                mHeight = minHeight;
            }
        }
    }
Ejemplo n.º 45
0
        public override void OnInitialize()
        {
            uIElement = new UIElement();
            uIElement.Width.Set(0f, 0.8f);
            uIElement.MaxWidth.Set(600f, 0f);
            uIElement.Top.Set(220f, 0f);
            uIElement.Height.Set(-220f, 1f);
            uIElement.HAlign = 0.5f;

            UIPanel uIPanel = new UIPanel();

            uIPanel.Width.Set(0f, 1f);
            uIPanel.Height.Set(-110f, 1f);
            uIPanel.BackgroundColor = new Color(33, 43, 79) * 0.8f;
            uIElement.Append(uIPanel);

            modInfo = new UIMessageBox("This is a test of mod info here.");
            modInfo.Width.Set(-25f, 1f);
            modInfo.Height.Set(0f, 1f);
            uIPanel.Append(modInfo);

            UIScrollbar uIScrollbar = new UIScrollbar();

            uIScrollbar.SetView(100f, 1000f);
            uIScrollbar.Height.Set(-20, 1f);
            uIScrollbar.VAlign = 0.5f;
            uIScrollbar.HAlign = 1f;
            uIPanel.Append(uIScrollbar);

            modInfo.SetScrollbar(uIScrollbar);
            uITextPanel        = new UITextPanel <string>(Language.GetTextValue("tModLoader.ModInfoHeader"), 0.8f, true);
            uITextPanel.HAlign = 0.5f;
            uITextPanel.Top.Set(-35f, 0f);
            uITextPanel.SetPadding(15f);
            uITextPanel.BackgroundColor = new Color(73, 94, 171);
            uIElement.Append(uITextPanel);

            modHomepageButton = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModInfoVisitHomepage"), 1f, false);
            modHomepageButton.Width.Set(0f, 1f);
            modHomepageButton.Height.Set(40f, 0f);
            modHomepageButton.VAlign = 1f;
            modHomepageButton.Top.Set(-65f, 0f);
            modHomepageButton.OnMouseOver += UICommon.FadedMouseOver;
            modHomepageButton.OnMouseOut  += UICommon.FadedMouseOut;
            modHomepageButton.OnClick     += VisitModHomePage;
            uIElement.Append(modHomepageButton);

            UIAutoScaleTextTextPanel <string> backButton = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("UI.Back"), 1f, false);

            backButton.Width.Set(-10f, 0.333f);
            backButton.Height.Set(40f, 0f);
            backButton.VAlign = 1f;
            backButton.Top.Set(-20f, 0f);
            backButton.OnMouseOver += UICommon.FadedMouseOver;
            backButton.OnMouseOut  += UICommon.FadedMouseOut;
            backButton.OnClick     += BackClick;
            uIElement.Append(backButton);

            extractButton = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModInfoExtract"), 1f, false);
            extractButton.Width.Set(-10f, 0.333f);
            extractButton.Height.Set(40f, 0f);
            extractButton.VAlign = 1f;
            extractButton.HAlign = 0.5f;
            extractButton.Top.Set(-20f, 0f);
            extractButton.OnMouseOver += UICommon.FadedMouseOver;
            extractButton.OnMouseOut  += UICommon.FadedMouseOut;
            extractButton.OnClick     += ExtractClick;
            uIElement.Append(extractButton);

            deleteButton = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("UI.Delete"), 1f, false);
            deleteButton.Width.Set(-10f, 0.333f);
            deleteButton.Height.Set(40f, 0f);
            deleteButton.VAlign = 1f;
            deleteButton.HAlign = 1f;
            deleteButton.Top.Set(-20f, 0f);
            deleteButton.OnMouseOver += UICommon.FadedMouseOver;
            deleteButton.OnMouseOut  += UICommon.FadedMouseOut;
            deleteButton.OnClick     += DeleteClick;
            uIElement.Append(deleteButton);

            Append(uIElement);
        }
Ejemplo n.º 46
0
    static public int FullCompareFunc(UIWidget left, UIWidget right)
    {
        int val = UIPanel.CompareFunc(left.panel, right.panel);

        return((val == 0) ? PanelCompareFunc(left, right) : val);
    }
 private void OnWillRenderObject()
 {
     this.UpdateMaterials();
     if (this.onRender != null)
     {
         this.onRender(this.mDynamicMat ?? this.mMaterial);
     }
     if (this.mDynamicMat == null || this.mClipCount == 0)
     {
         return;
     }
     if (this.mTextureClip)
     {
         Vector4 drawCallClipRange = this.panel.drawCallClipRange;
         Vector2 clipSoftness      = this.panel.clipSoftness;
         Vector2 vector            = new Vector2(1000f, 1000f);
         if (clipSoftness.x > 0f)
         {
             vector.x = drawCallClipRange.z / clipSoftness.x;
         }
         if (clipSoftness.y > 0f)
         {
             vector.y = drawCallClipRange.w / clipSoftness.y;
         }
         this.mDynamicMat.SetVector(UIDrawCall.ClipRange[0], new Vector4(-drawCallClipRange.x / drawCallClipRange.z, -drawCallClipRange.y / drawCallClipRange.w, 1f / drawCallClipRange.z, 1f / drawCallClipRange.w));
         this.mDynamicMat.SetTexture("_ClipTex", this.clipTexture);
     }
     else if (!this.mLegacyShader)
     {
         UIPanel parentPanel = this.panel;
         int     num         = 0;
         while (parentPanel != null)
         {
             if (parentPanel.hasClipping)
             {
                 float   angle = 0f;
                 Vector4 drawCallClipRange2 = parentPanel.drawCallClipRange;
                 if (parentPanel != this.panel)
                 {
                     Vector3 vector2 = parentPanel.cachedTransform.InverseTransformPoint(this.panel.cachedTransform.get_position());
                     drawCallClipRange2.x -= vector2.x;
                     drawCallClipRange2.y -= vector2.y;
                     Vector3 eulerAngles  = this.panel.cachedTransform.get_rotation().get_eulerAngles();
                     Vector3 eulerAngles2 = parentPanel.cachedTransform.get_rotation().get_eulerAngles();
                     Vector3 vector3      = eulerAngles2 - eulerAngles;
                     vector3.x = NGUIMath.WrapAngle(vector3.x);
                     vector3.y = NGUIMath.WrapAngle(vector3.y);
                     vector3.z = NGUIMath.WrapAngle(vector3.z);
                     if (Mathf.Abs(vector3.x) > 0.001f || Mathf.Abs(vector3.y) > 0.001f)
                     {
                         Debug.LogWarning("Panel can only be clipped properly if X and Y rotation is left at 0", this.panel);
                     }
                     angle = vector3.z;
                 }
                 this.SetClipping(num++, drawCallClipRange2, parentPanel.clipSoftness, angle);
             }
             parentPanel = parentPanel.parentPanel;
         }
     }
     else
     {
         Vector2 clipSoftness2      = this.panel.clipSoftness;
         Vector4 drawCallClipRange3 = this.panel.drawCallClipRange;
         Vector2 mainTextureOffset  = new Vector2(-drawCallClipRange3.x / drawCallClipRange3.z, -drawCallClipRange3.y / drawCallClipRange3.w);
         Vector2 mainTextureScale   = new Vector2(1f / drawCallClipRange3.z, 1f / drawCallClipRange3.w);
         Vector2 vector4            = new Vector2(1000f, 1000f);
         if (clipSoftness2.x > 0f)
         {
             vector4.x = drawCallClipRange3.z / clipSoftness2.x;
         }
         if (clipSoftness2.y > 0f)
         {
             vector4.y = drawCallClipRange3.w / clipSoftness2.y;
         }
         this.mDynamicMat.set_mainTextureOffset(mainTextureOffset);
         this.mDynamicMat.set_mainTextureScale(mainTextureScale);
         this.mDynamicMat.SetVector("_ClipSharpness", vector4);
     }
 }
        public static void makeSettings(UIHelperBase helper)
        {
            // tabbing code is borrowed from RushHour mod
            // https://github.com/PropaneDragon/RushHour/blob/release/RushHour/Options/OptionHandler.cs

            UIHelper    actualHelper = helper as UIHelper;
            UIComponent container    = actualHelper.self as UIComponent;

            UITabstrip tabStrip = container.AddUIComponent <UITabstrip>();

            tabStrip.relativePosition = new Vector3(0, 0);
            tabStrip.size             = new Vector2(container.width - 20, 40);

            UITabContainer tabContainer = container.AddUIComponent <UITabContainer>();

            tabContainer.relativePosition = new Vector3(0, 40);
            tabContainer.size             = new Vector2(container.width - 20, container.height - tabStrip.height - 20);
            tabStrip.tabPages             = tabContainer;

            int tabIndex = 0;

            // GENERAL

            AddOptionTab(tabStrip, Translation.GetString("General"));            // tabStrip.AddTab(Translation.GetString("General"), tabTemplate, true);
            tabStrip.selectedIndex = tabIndex;

            UIPanel currentPanel = tabStrip.tabContainer.components[tabIndex] as UIPanel;

            currentPanel.autoLayout              = true;
            currentPanel.autoLayoutDirection     = LayoutDirection.Vertical;
            currentPanel.autoLayoutPadding.top   = 5;
            currentPanel.autoLayoutPadding.left  = 10;
            currentPanel.autoLayoutPadding.right = 10;

            UIHelper panelHelper = new UIHelper(currentPanel);

            simAccuracyDropdown = panelHelper.AddDropdown(Translation.GetString("Simulation_accuracy") + ":", new string[] { Translation.GetString("Very_high"), Translation.GetString("High"), Translation.GetString("Medium"), Translation.GetString("Low"), Translation.GetString("Very_Low") }, simAccuracy, onSimAccuracyChanged) as UIDropDown;

            var featureGroup = panelHelper.AddGroup(Translation.GetString("Activated_features"));

            enablePrioritySignsToggle        = featureGroup.AddCheckbox(Translation.GetString("Priority_signs"), prioritySignsEnabled, onPrioritySignsEnabledChanged) as UICheckBox;
            enableTimedLightsToggle          = featureGroup.AddCheckbox(Translation.GetString("Timed_traffic_lights"), timedLightsEnabled, onTimedLightsEnabledChanged) as UICheckBox;
            enableCustomSpeedLimitsToggle    = featureGroup.AddCheckbox(Translation.GetString("Speed_limits"), customSpeedLimitsEnabled, onCustomSpeedLimitsEnabledChanged) as UICheckBox;
            enableVehicleRestrictionsToggle  = featureGroup.AddCheckbox(Translation.GetString("Vehicle_restrictions"), vehicleRestrictionsEnabled, onVehicleRestrictionsEnabledChanged) as UICheckBox;
            enableJunctionRestrictionsToggle = featureGroup.AddCheckbox(Translation.GetString("Junction_restrictions"), junctionRestrictionsEnabled, onJunctionRestrictionsEnabledChanged) as UICheckBox;
            enableLaneConnectorToggle        = featureGroup.AddCheckbox(Translation.GetString("Lane_connector"), laneConnectorEnabled, onLaneConnectorEnabledChanged) as UICheckBox;

            // GAMEPLAY
            ++tabIndex;

            AddOptionTab(tabStrip, Translation.GetString("Gameplay"));
            tabStrip.selectedIndex = tabIndex;

            currentPanel                         = tabStrip.tabContainer.components[tabIndex] as UIPanel;
            currentPanel.autoLayout              = true;
            currentPanel.autoLayoutDirection     = LayoutDirection.Vertical;
            currentPanel.autoLayoutPadding.top   = 5;
            currentPanel.autoLayoutPadding.left  = 10;
            currentPanel.autoLayoutPadding.right = 10;

            panelHelper = new UIHelper(currentPanel);

            var vehBehaviorGroup = panelHelper.AddGroup(Translation.GetString("Vehicle_behavior"));

            recklessDriversDropdown            = vehBehaviorGroup.AddDropdown(Translation.GetString("Reckless_driving") + ":", new string[] { Translation.GetString("Path_Of_Evil_(10_%)"), Translation.GetString("Rush_Hour_(5_%)"), Translation.GetString("Minor_Complaints_(2_%)"), Translation.GetString("Holy_City_(0_%)") }, recklessDrivers, onRecklessDriversChanged) as UIDropDown;
            realisticSpeedsToggle              = vehBehaviorGroup.AddCheckbox(Translation.GetString("Realistic_speeds"), realisticSpeeds, onRealisticSpeedsChanged) as UICheckBox;
            strongerRoadConditionEffectsToggle = vehBehaviorGroup.AddCheckbox(Translation.GetString("Road_condition_has_a_bigger_impact_on_vehicle_speed"), strongerRoadConditionEffects, onStrongerRoadConditionEffectsChanged) as UICheckBox;
            enableDespawningToggle             = vehBehaviorGroup.AddCheckbox(Translation.GetString("Enable_despawning"), enableDespawning, onEnableDespawningChanged) as UICheckBox;

            var vehAiGroup = panelHelper.AddGroup(Translation.GetString("Advanced_Vehicle_AI"));

            advancedAIToggle = vehAiGroup.AddCheckbox(Translation.GetString("Enable_Advanced_Vehicle_AI"), advancedAI, onAdvancedAIChanged) as UICheckBox;
#if DEBUG
            //if (SystemInfo.processorCount >= DYNAMIC_RECALC_MIN_PROCESSOR_COUNT)
            //dynamicPathRecalculationToggle = vehAiGroup.AddCheckbox(Translation.GetString("Enable_dynamic_path_calculation"), dynamicPathRecalculation, onDynamicPathRecalculationChanged) as UICheckBox;
#endif
            highwayRulesToggle    = vehAiGroup.AddCheckbox(Translation.GetString("Enable_highway_specific_lane_merging/splitting_rules"), highwayRules, onHighwayRulesChanged) as UICheckBox;
            preferOuterLaneToggle = vehAiGroup.AddCheckbox(Translation.GetString("Heavy_trucks_prefer_outer_lanes_on_highways"), preferOuterLane, onPreferOuterLaneChanged) as UICheckBox;

            var parkAiGroup = panelHelper.AddGroup(Translation.GetString("Parking_AI"));
            prohibitPocketCarsToggle = parkAiGroup.AddCheckbox(Translation.GetString("Enable_more_realistic_parking") + " (BETA feature)", prohibitPocketCars, onProhibitPocketCarsChanged) as UICheckBox;

            // VEHICLE RESTRICTIONS
            ++tabIndex;

            AddOptionTab(tabStrip, Translation.GetString("Policies_&_Restrictions"));
            tabStrip.selectedIndex = tabIndex;

            currentPanel                         = tabStrip.tabContainer.components[tabIndex] as UIPanel;
            currentPanel.autoLayout              = true;
            currentPanel.autoLayoutDirection     = LayoutDirection.Vertical;
            currentPanel.autoLayoutPadding.top   = 5;
            currentPanel.autoLayoutPadding.left  = 10;
            currentPanel.autoLayoutPadding.right = 10;

            panelHelper = new UIHelper(currentPanel);

            var atJunctionsGroup = panelHelper.AddGroup(Translation.GetString("At_junctions"));
#if DEBUG
            allRelaxedToggle = atJunctionsGroup.AddCheckbox(Translation.GetString("All_vehicles_may_ignore_lane_arrows"), allRelaxed, onAllRelaxedChanged) as UICheckBox;
#endif
            relaxedBussesToggle = atJunctionsGroup.AddCheckbox(Translation.GetString("Busses_may_ignore_lane_arrows"), relaxedBusses, onRelaxedBussesChanged) as UICheckBox;
            allowEnterBlockedJunctionsToggle = atJunctionsGroup.AddCheckbox(Translation.GetString("Vehicles_may_enter_blocked_junctions"), allowEnterBlockedJunctions, onAllowEnterBlockedJunctionsChanged) as UICheckBox;
            allowUTurnsToggle = atJunctionsGroup.AddCheckbox(Translation.GetString("Vehicles_may_do_u-turns_at_junctions"), allowUTurns, onAllowUTurnsChanged) as UICheckBox;
            allowLaneChangesWhileGoingStraightToggle = atJunctionsGroup.AddCheckbox(Translation.GetString("Vehicles_going_straight_may_change_lanes_at_junctions"), allowLaneChangesWhileGoingStraight, onAllowLaneChangesWhileGoingStraightChanged) as UICheckBox;

            if (SteamHelper.IsDLCOwned(SteamHelper.DLC.NaturalDisastersDLC))
            {
                var inCaseOfEmergencyGroup = panelHelper.AddGroup(Translation.GetString("In_case_of_emergency"));
                evacBussesMayIgnoreRulesToggle = inCaseOfEmergencyGroup.AddCheckbox(Translation.GetString("Evacuation_busses_may_ignore_traffic_rules"), evacBussesMayIgnoreRules, onEvacBussesMayIgnoreRulesChanged) as UICheckBox;
            }

            // OVERLAYS
            ++tabIndex;

            AddOptionTab(tabStrip, Translation.GetString("Overlays"));
            tabStrip.selectedIndex = tabIndex;

            currentPanel                         = tabStrip.tabContainer.components[tabIndex] as UIPanel;
            currentPanel.autoLayout              = true;
            currentPanel.autoLayoutDirection     = LayoutDirection.Vertical;
            currentPanel.autoLayoutPadding.top   = 5;
            currentPanel.autoLayoutPadding.left  = 10;
            currentPanel.autoLayoutPadding.right = 10;

            panelHelper = new UIHelper(currentPanel);

            prioritySignsOverlayToggle        = panelHelper.AddCheckbox(Translation.GetString("Priority_signs"), prioritySignsOverlay, onPrioritySignsOverlayChanged) as UICheckBox;
            timedLightsOverlayToggle          = panelHelper.AddCheckbox(Translation.GetString("Timed_traffic_lights"), timedLightsOverlay, onTimedLightsOverlayChanged) as UICheckBox;
            speedLimitsOverlayToggle          = panelHelper.AddCheckbox(Translation.GetString("Speed_limits"), speedLimitsOverlay, onSpeedLimitsOverlayChanged) as UICheckBox;
            vehicleRestrictionsOverlayToggle  = panelHelper.AddCheckbox(Translation.GetString("Vehicle_restrictions"), vehicleRestrictionsOverlay, onVehicleRestrictionsOverlayChanged) as UICheckBox;
            junctionRestrictionsOverlayToggle = panelHelper.AddCheckbox(Translation.GetString("Junction_restrictions"), junctionRestrictionsOverlay, onJunctionRestrictionsOverlayChanged) as UICheckBox;
            connectedLanesOverlayToggle       = panelHelper.AddCheckbox(Translation.GetString("Connected_lanes"), connectedLanesOverlay, onConnectedLanesOverlayChanged) as UICheckBox;
            nodesOverlayToggle = panelHelper.AddCheckbox(Translation.GetString("Nodes_and_segments"), nodesOverlay, onNodesOverlayChanged) as UICheckBox;
            showLanesToggle    = panelHelper.AddCheckbox(Translation.GetString("Lanes"), showLanes, onShowLanesChanged) as UICheckBox;
#if DEBUG
            vehicleOverlayToggle  = panelHelper.AddCheckbox(Translation.GetString("Vehicles"), vehicleOverlay, onVehicleOverlayChanged) as UICheckBox;
            citizenOverlayToggle  = panelHelper.AddCheckbox(Translation.GetString("Citizens"), citizenOverlay, onCitizenOverlayChanged) as UICheckBox;
            buildingOverlayToggle = panelHelper.AddCheckbox(Translation.GetString("Buildings"), buildingOverlay, onBuildingOverlayChanged) as UICheckBox;
#endif

            // MAINTENANCE
            ++tabIndex;

            AddOptionTab(tabStrip, Translation.GetString("Maintenance"));
            tabStrip.selectedIndex = tabIndex;

            currentPanel                         = tabStrip.tabContainer.components[tabIndex] as UIPanel;
            currentPanel.autoLayout              = true;
            currentPanel.autoLayoutDirection     = LayoutDirection.Vertical;
            currentPanel.autoLayoutPadding.top   = 5;
            currentPanel.autoLayoutPadding.left  = 10;
            currentPanel.autoLayoutPadding.right = 10;

            panelHelper = new UIHelper(currentPanel);

            forgetTrafficLightsBtn = panelHelper.AddButton(Translation.GetString("Forget_toggled_traffic_lights"), onClickForgetToggledLights) as UIButton;
            resetStuckEntitiesBtn  = panelHelper.AddButton(Translation.GetString("Reset_stuck_cims_and_vehicles"), onClickResetStuckEntities) as UIButton;
#if DEBUG
            resetSpeedLimitsBtn = panelHelper.AddButton(Translation.GetString("Reset_custom_speed_limits"), onClickResetSpeedLimits) as UIButton;
#endif
            reloadGlobalConfBtn = panelHelper.AddButton(Translation.GetString("Reload_global_configuration"), onClickReloadGlobalConf) as UIButton;
            resetGlobalConfBtn  = panelHelper.AddButton(Translation.GetString("Reset_global_configuration"), onClickResetGlobalConf) as UIButton;
#if DEBUG
            // DEBUG

            /*++tabIndex;
             *
             * settingsButton = tabStrip.AddTab("Debug", tabTemplate, true);
             * settingsButton.textPadding = new RectOffset(10, 10, 10, 10);
             * settingsButton.autoSize = true;
             * settingsButton.tooltip = "Debug";
             *
             * currentPanel = tabStrip.tabContainer.components[tabIndex] as UIPanel;
             * currentPanel.autoLayout = true;
             * currentPanel.autoLayoutDirection = LayoutDirection.Vertical;
             * currentPanel.autoLayoutPadding.top = 5;
             * currentPanel.autoLayoutPadding.left = 10;
             * currentPanel.autoLayoutPadding.right = 10;
             *
             * panelHelper = new UIHelper(currentPanel);
             *
             * debugSwitchFields.Clear();
             * for (int i = 0; i < debugSwitches.Length; ++i) {
             *      int index = i;
             *      string varName = $"Debug switch #{i}";
             *      debugSwitchFields.Add(panelHelper.AddCheckbox(varName, debugSwitches[i], delegate (bool newVal) { onBoolValueChanged(varName, newVal, ref debugSwitches[index]); }) as UICheckBox);
             * }
             *
             * debugValueFields.Clear();
             * for (int i = 0; i < debugValues.Length; ++i) {
             *      int index = i;
             *      string varName = $"Debug value #{i}";
             *      debugValueFields.Add(panelHelper.AddTextfield(varName, String.Format("{0:0.##}", debugValues[i]), delegate(string newValStr) { onFloatValueChanged(varName, newValStr, ref debugValues[index]); }, null) as UITextField);
             * }*/
#endif

            tabStrip.selectedIndex = 0;
        }
 public static UIDrawCall Create(UIPanel panel, Material mat, Texture tex, Shader shader)
 {
     return(UIDrawCall.Create(null, panel, mat, tex, shader));
 }
Ejemplo n.º 50
0
    /// <summary>
    /// Cache the transform.
    /// </summary>

    void Start()
    {
        mPanel = GetComponent <UIPanel>();
        mDrag  = GetComponent <UIScrollView>();
        mTrans = transform;
    }
Ejemplo n.º 51
0
    /// <summary>
    /// This function is called when it's clear that the object will be rendered.
    /// We want to set the shader used by the material, creating a copy of the material in the process.
    /// We also want to update the material's properties before it's actually used.
    /// </summary>

    void OnWillRenderObject()
    {
        UpdateMaterials();

        if (onRender != null)
        {
            onRender(mDynamicMat ?? mMaterial);
        }
        if (mDynamicMat == null || mClipCount == 0)
        {
            return;
        }

        if (mTextureClip)
        {
            Vector4 cr   = panel.drawCallClipRange;
            Vector2 soft = panel.clipSoftness;

            Vector2 sharpness = new Vector2(1000.0f, 1000.0f);
            if (soft.x > 0f)
            {
                sharpness.x = cr.z / soft.x;
            }
            if (soft.y > 0f)
            {
                sharpness.y = cr.w / soft.y;
            }

            mDynamicMat.SetVector(ClipRange[0], new Vector4(-cr.x / cr.z, -cr.y / cr.w, 1f / cr.z, 1f / cr.w));
            mDynamicMat.SetTexture("_ClipTex", clipTexture);

            UIPanel currentPanel = panel;

            for (int i = 0; currentPanel != null;)
            {
                if (currentPanel.hasClipping)
                {
                    float angle = 0f;
                    cr = currentPanel.drawCallClipRange;

                    // Clipping regions past the first one need additional math
                    if (currentPanel != panel)
                    {
                        Vector3 pos = currentPanel.cachedTransform.InverseTransformPoint(panel.cachedTransform.position);
                        cr.x -= pos.x;
                        cr.y -= pos.y;

                        Vector3 v0   = panel.cachedTransform.rotation.eulerAngles;
                        Vector3 v1   = currentPanel.cachedTransform.rotation.eulerAngles;
                        Vector3 diff = v1 - v0;

                        diff.x = NGUIMath.WrapAngle(diff.x);
                        diff.y = NGUIMath.WrapAngle(diff.y);
                        diff.z = NGUIMath.WrapAngle(diff.z);

                        if (Mathf.Abs(diff.x) > 0.001f || Mathf.Abs(diff.y) > 0.001f)
                        {
                            Debug.LogWarning("Panel can only be clipped properly if X and Y rotation is left at 0", panel);
                        }

                        angle = diff.z;
                    }

                    // Pass the clipping parameters to the shader
                    SetClipping(1, cr, currentPanel.clipSoftness, angle);
                }
                currentPanel = currentPanel.parentPanel;
            }
        }
        else if (!mLegacyShader)
        {
            UIPanel currentPanel = panel;

            for (int i = 0; currentPanel != null;)
            {
                if (currentPanel.hasClipping)
                {
                    float   angle = 0f;
                    Vector4 cr    = currentPanel.drawCallClipRange;

                    // Clipping regions past the first one need additional math
                    if (currentPanel != panel)
                    {
                        Vector3 pos = currentPanel.cachedTransform.InverseTransformPoint(panel.cachedTransform.position);
                        cr.x -= pos.x;
                        cr.y -= pos.y;

                        Vector3 v0   = panel.cachedTransform.rotation.eulerAngles;
                        Vector3 v1   = currentPanel.cachedTransform.rotation.eulerAngles;
                        Vector3 diff = v1 - v0;

                        diff.x = NGUIMath.WrapAngle(diff.x);
                        diff.y = NGUIMath.WrapAngle(diff.y);
                        diff.z = NGUIMath.WrapAngle(diff.z);

                        if (Mathf.Abs(diff.x) > 0.001f || Mathf.Abs(diff.y) > 0.001f)
                        {
                            Debug.LogWarning("Panel can only be clipped properly if X and Y rotation is left at 0", panel);
                        }

                        angle = diff.z;
                    }

                    // Pass the clipping parameters to the shader
                    SetClipping(i++, cr, currentPanel.clipSoftness, angle);
                }
                currentPanel = currentPanel.parentPanel;
            }
        }
        else         // Legacy functionality
        {
            Vector2 soft = panel.clipSoftness;
            Vector4 cr   = panel.drawCallClipRange;
            Vector2 v0   = new Vector2(-cr.x / cr.z, -cr.y / cr.w);
            Vector2 v1   = new Vector2(1f / cr.z, 1f / cr.w);

            Vector2 sharpness = new Vector2(1000.0f, 1000.0f);
            if (soft.x > 0f)
            {
                sharpness.x = cr.z / soft.x;
            }
            if (soft.y > 0f)
            {
                sharpness.y = cr.w / soft.y;
            }

            mDynamicMat.mainTextureOffset = v0;
            mDynamicMat.mainTextureScale  = v1;
            mDynamicMat.SetVector("_ClipSharpness", sharpness);
        }
    }
Ejemplo n.º 52
0
    void Update2()
    {
        if (mAnim != null && mAnim.isPlaying)
        {
            return;
        }

        if (style != Style.None)
        {
            UIWidget wc         = (container == null) ? null : container.GetComponent <UIWidget>();
            UIPanel  pc         = (container == null && wc == null) ? null : container.GetComponent <UIPanel>();
            float    adjustment = 1f;

            if (wc != null)
            {
                Bounds b = wc.CalculateBounds(transform.parent);

                mRect.x = b.min.x;
                mRect.y = b.min.y;

                mRect.width  = b.size.x;
                mRect.height = b.size.y;
            }
            else if (pc != null)
            {
                if (pc.clipping == UIDrawCall.Clipping.None)
                {
                    // Panel has no clipping -- just use the screen's dimensions
                    float ratio = (mRoot != null) ? (float)mRoot.activeHeight / Screen.height * 0.5f : 0.5f;
                    mRect.xMin = -Screen.width * ratio;
                    mRect.yMin = -Screen.height * ratio;
                    mRect.xMax = -mRect.xMin;
                    mRect.yMax = -mRect.yMin;
                }
                else
                {
                    // Panel has clipping -- use it as the mRect
                    Vector4 cr = pc.finalClipRegion;
                    mRect.x      = cr.x - (cr.z * 0.5f);
                    mRect.y      = cr.y - (cr.w * 0.5f);
                    mRect.width  = cr.z;
                    mRect.height = cr.w;
                }
            }
            else if (container != null)
            {
                Transform root = transform.parent;
                Bounds    b    = (root != null) ? NGUIMath.CalculateRelativeWidgetBounds(root, container.transform) :
                                 NGUIMath.CalculateRelativeWidgetBounds(container.transform);

                mRect.x = b.min.x;
                mRect.y = b.min.y;

                mRect.width  = b.size.x;
                mRect.height = b.size.y;
            }
            else if (uiCamera != null)
            {
                mRect = uiCamera.pixelRect;
                if (mRoot != null)
                {
                    adjustment = mRoot.pixelSizeAdjustment;
                }
            }
            else
            {
                return;
            }

            float rectWidth  = mRect.width;
            float rectHeight = mRect.height;

            if (adjustment != 1f && rectHeight > 1f)
            {
                float scale = mRoot.activeHeight / rectHeight;
                rectWidth  *= scale;
                rectHeight *= scale;
            }

            Vector3 size = (mWidget != null) ? new Vector3(mWidget.width, mWidget.height) : mTrans.localScale;

            if (style == Style.BasedOnHeight)
            {
                size.x = relativeSize.x * rectHeight;
                size.y = relativeSize.y * rectHeight;
            }
            else if (style == Style.FillKeepingRatio)
            {
                // Contributed by Dylan Ryan
                float screenRatio = rectWidth / rectHeight;
                float imageRatio  = initialSize.x / initialSize.y;

                if (imageRatio < screenRatio)
                {
                    // Fit horizontally
                    float scale = rectWidth / initialSize.x;
                    size.x = rectWidth;
                    size.y = initialSize.y * scale;
                }
                else
                {
                    // Fit vertically
                    float scale = rectHeight / initialSize.y;
                    size.x = initialSize.x * scale;
                    size.y = rectHeight;
                }
            }
            else if (style == Style.FitInternalKeepingRatio)
            {
                // Contributed by Dylan Ryan
                float screenRatio = rectWidth / rectHeight;
                float imageRatio  = initialSize.x / initialSize.y;

                if (imageRatio > screenRatio)
                {
                    // Fit horizontally
                    float scale = rectWidth / initialSize.x;
                    size.x = rectWidth;
                    size.y = initialSize.y * scale;
                }
                else
                {
                    // Fit vertically
                    float scale = rectHeight / initialSize.y;
                    size.x = initialSize.x * scale;
                    size.y = rectHeight;
                }
            }
            else
            {
                if (style != Style.Vertical)
                {
                    size.x = relativeSize.x * rectWidth;
                }

                if (style != Style.Horizontal)
                {
                    size.y = relativeSize.y * rectHeight;
                }
            }

            if (mSprite != null)
            {
                float multiplier = (mSprite.atlas != null) ? mSprite.atlas.pixelSize : 1f;
                size.x -= borderPadding.x * multiplier;
                size.y -= borderPadding.y * multiplier;

                if (style != Style.Vertical)
                {
                    mSprite.width = Mathf.RoundToInt(size.x);
                }

                if (style != Style.Horizontal)
                {
                    mSprite.height = Mathf.RoundToInt(size.y);
                }

                size = Vector3.one;
            }
            else if (mWidget != null)
            {
                if (style != Style.Vertical)
                {
                    mWidget.width = Mathf.RoundToInt(size.x - borderPadding.x);
                }

                if (style != Style.Horizontal)
                {
                    mWidget.height = Mathf.RoundToInt(size.y - borderPadding.y);
                }

                size = Vector3.one;
            }
            else if (mPanel != null)
            {
                Vector4 cr = mPanel.baseClipRegion;

                if (style != Style.Vertical)
                {
                    cr.z = size.x - borderPadding.x;
                }

                if (style != Style.Horizontal)
                {
                    cr.w = size.y - borderPadding.y;
                }

                mPanel.baseClipRegion = cr;
                size = Vector3.one;
            }
            else
            {
                if (style != Style.Vertical)
                {
                    size.x -= borderPadding.x;
                }

                if (style != Style.Horizontal)
                {
                    size.y -= borderPadding.y;
                }
            }

            if (mTrans.localScale != size)
            {
                mTrans.localScale = size;
            }

            if (runOnlyOnce && Application.isPlaying)
            {
                count++;
                if (count == GameConfig.UpdateNGUIStretch)
                {
                    enabled = false;
                }
            }
        }
    }
Ejemplo n.º 53
0
        private void CreateVehicleOptionsPanel()
        {
            UIPanel uiPanel1 = this.AddUIComponent <UIPanel>();

            uiPanel1.name   = "RightSidePanel";
            uiPanel1.anchor = UIAnchorStyle.Top | UIAnchorStyle.Left | UIAnchorStyle.Right;
            uiPanel1.transform.localPosition = Vector3.zero;
            uiPanel1.width               = 246f;
            uiPanel1.height              = 304f;
            uiPanel1.autoLayout          = true;
            uiPanel1.autoLayoutDirection = LayoutDirection.Vertical;
            uiPanel1.autoLayoutPadding   = new RectOffset(3, 3, 0, 0);
            uiPanel1.autoLayoutStart     = LayoutStart.TopLeft;
            uiPanel1.backgroundSprite    = "InfoviewPanel";
            uiPanel1.relativePosition    = new Vector3(60f, 50f);
            this._rightSidePanel         = uiPanel1;
            UIPanel uiPanel2 = uiPanel1.AddUIComponent <UIPanel>();

            uiPanel2.name             = "CaptionPanel";
            uiPanel2.width            = uiPanel2.parent.width - 6f;
            uiPanel2.height           = 30f;
            uiPanel2.backgroundSprite = "InfoviewPanel";
            UILabel uiLabel1 = uiPanel2.AddUIComponent <UILabel>();

            uiLabel1.name          = "CaptionLabel";
            uiLabel1.font          = UIUtils.Font;
            uiLabel1.textColor     = (Color32)Color.white;
            uiLabel1.textScale     = 0.95f;
            uiLabel1.textAlignment = UIHorizontalAlignment.Center;
            uiLabel1.useOutline    = true;
            uiLabel1.autoSize      = false;
            uiLabel1.height        = 18f;
            uiLabel1.width         = uiPanel2.width;
            uiLabel1.position      = new Vector3((float)((double)uiPanel2.width / 2.0 - (double)uiPanel2.width / 2.0), (float)((double)uiPanel2.height / 2.0 - 20.0));
            UIPanel uiPanel3 = uiPanel1.AddUIComponent <UIPanel>();
            string  str1     = "RowContainer";

            uiPanel3.name = str1;
            double num1 = (double)uiPanel3.parent.width - 6.0;

            uiPanel3.width = (float)num1;
            double num2 = 271.0;

            uiPanel3.height = (float)num2;
            int num3 = 1;

            uiPanel3.autoLayoutDirection = (LayoutDirection)num3;
            int num4 = 0;

            uiPanel3.autoLayoutStart = (LayoutStart)num4;
            RectOffset rectOffset1 = new RectOffset(8, 0, 0, 0);

            uiPanel3.autoLayoutPadding = rectOffset1;
            int num5 = 1;

            uiPanel3.autoLayout = num5 != 0;
            string str2 = "GenericPanelWhite";

            uiPanel3.backgroundSprite = str2;
            Color32 color32 = new Color32((byte)91, (byte)97, (byte)106, byte.MaxValue);

            uiPanel3.color = color32;
            UIPanel uiPanel4 = uiPanel3.AddUIComponent <UIPanel>();
            double  num6     = (double)uiPanel4.parent.width - 8.0;

            uiPanel4.width = (float)num6;
            double num7 = 4.0;

            uiPanel4.height = (float)num7;
            int num8 = 0;

            uiPanel4.autoLayoutDirection = (LayoutDirection)num8;
            int num9 = 0;

            uiPanel4.autoLayoutStart = (LayoutStart)num9;
            RectOffset rectOffset2 = new RectOffset(0, 6, 0, 0);

            uiPanel4.autoLayoutPadding = rectOffset2;
            int num10 = 1;

            uiPanel4.autoLayout = num10 != 0;
            UIPanel uiPanel5 = uiPanel3.AddUIComponent <UIPanel>();
            double  num11    = (double)uiPanel5.parent.width - 8.0;

            uiPanel5.width = (float)num11;
            double num12 = 30.0;

            uiPanel5.height = (float)num12;
            int num13 = 0;

            uiPanel5.autoLayoutDirection = (LayoutDirection)num13;
            int num14 = 0;

            uiPanel5.autoLayoutStart = (LayoutStart)num14;
            RectOffset rectOffset3 = new RectOffset(0, 6, 0, 0);

            uiPanel5.autoLayoutPadding = rectOffset3;
            int num15 = 1;

            uiPanel5.autoLayout = num15 != 0;
            DropDown dropDown = DropDown.Create((UIComponent)uiPanel5);
            string   str3     = "AssetDropDown";

            dropDown.name = str3;
            double num16 = 27.0;

            dropDown.height = (float)num16;
            double num17 = (double)dropDown.parent.width - 6.0;

            dropDown.width = (float)num17;
            dropDown.DropDownPanelAlignParent = (UIComponent)this;
            UIFont font = UIUtils.Font;

            dropDown.Font = font;
            PropertyChangedEventHandler <ushort> changedEventHandler1 = new PropertyChangedEventHandler <ushort>(this.OnSelectedItemChanged);

            dropDown.eventSelectedItemChanged += changedEventHandler1;
            UIPanel uiPanel6 = uiPanel3.AddUIComponent <UIPanel>();
            double  num18    = (double)uiPanel6.parent.width - 8.0;

            uiPanel6.width = (float)num18;
            double num19 = 30.0;

            uiPanel6.height = (float)num19;
            int num20 = 0;

            uiPanel6.autoLayoutDirection = (LayoutDirection)num20;
            int num21 = 0;

            uiPanel6.autoLayoutStart = (LayoutStart)num21;
            RectOffset rectOffset4 = new RectOffset(0, 3, 0, 0);

            uiPanel6.autoLayoutPadding = rectOffset4;
            int num22 = 1;

            uiPanel6.autoLayout = num22 != 0;
            UILabel uiLabel2 = uiPanel6.AddUIComponent <UILabel>();

            uiLabel2.name              = "CapacityLabel";
            uiLabel2.text              = Localization.Get("VEHICLE_EDITOR_CAPACITY");
            uiLabel2.font              = UIUtils.Font;
            uiLabel2.textColor         = (Color32)Color.white;
            uiLabel2.textScale         = 0.8f;
            uiLabel2.autoSize          = false;
            uiLabel2.height            = 30f;
            uiLabel2.width             = 115f;
            uiLabel2.wordWrap          = true;
            uiLabel2.verticalAlignment = UIVerticalAlignment.Middle;
            UITextField uiTextField1 = uiPanel6.AddUIComponent <UITextField>();
            string      str4         = "Capacity";

            uiTextField1.name = str4;
            string str5 = "0";

            uiTextField1.text = str5;
            uiLabel2.tooltip  = "";
            Color32 black1 = (Color32)Color.black;

            uiTextField1.textColor = black1;
            string str6 = "EmptySprite";

            uiTextField1.selectionSprite = str6;
            string str7 = "TextFieldPanelHovered";

            uiTextField1.normalBgSprite = str7;
            string str8 = "TextFieldPanel";

            uiTextField1.focusedBgSprite = str8;
            int num23 = 1;

            uiTextField1.builtinKeyNavigation = num23 != 0;
            int num24 = 1;

            uiTextField1.submitOnFocusLost = num24 != 0;
            PropertyChangedEventHandler <string> changedEventHandler2 = new PropertyChangedEventHandler <string>(this.OnCapacitySubmitted);

            uiTextField1.eventTextSubmitted += changedEventHandler2;
            double num25 = 45.0;

            uiTextField1.width = (float)num25;
            double num26 = 22.0;

            uiTextField1.height = (float)num26;
            int num27 = 4;

            uiTextField1.maxLength = num27;
            int num28 = 1;

            uiTextField1.numericalOnly = num28 != 0;
            int num29 = 1;

            uiTextField1.verticalAlignment = (UIVerticalAlignment)num29;
            RectOffset rectOffset5 = new RectOffset(0, 0, 4, 0);

            uiTextField1.padding = rectOffset5;
            UIPanel uiPanel7 = uiPanel3.AddUIComponent <UIPanel>();
            string  str9     = "MaintenanceRow";

            uiPanel7.name = str9;
            double num30 = (double)uiPanel7.parent.width - 8.0;

            uiPanel7.width = (float)num30;
            double num31 = 30.0;

            uiPanel7.height = (float)num31;
            int num32 = 0;

            uiPanel7.autoLayoutDirection = (LayoutDirection)num32;
            int num33 = 0;

            uiPanel7.autoLayoutStart = (LayoutStart)num33;
            RectOffset rectOffset6 = new RectOffset(0, 3, 0, 0);

            uiPanel7.autoLayoutPadding = rectOffset6;
            int num34 = 1;

            uiPanel7.autoLayout = num34 != 0;
            UILabel uiLabel3 = uiPanel7.AddUIComponent <UILabel>();

            uiLabel3.text              = Localization.Get("VEHICLE_EDITOR_MAINTENANCE");
            uiLabel3.font              = UIUtils.Font;
            uiLabel3.textColor         = (Color32)Color.white;
            uiLabel3.textScale         = 0.8f;
            uiLabel3.autoSize          = false;
            uiLabel3.height            = 30f;
            uiLabel3.width             = 115f;
            uiLabel3.wordWrap          = true;
            uiLabel3.verticalAlignment = UIVerticalAlignment.Middle;
            UITextField uiTextField2 = uiPanel7.AddUIComponent <UITextField>();
            string      str10        = "MaintenanceCost";

            uiTextField2.name = str10;
            string str11 = "0";

            uiTextField2.text = str11;
            Color32 black2 = (Color32)Color.black;

            uiTextField2.textColor = black2;
            string str12 = "EmptySprite";

            uiTextField2.selectionSprite = str12;
            string str13 = "TextFieldPanelHovered";

            uiTextField2.normalBgSprite = str13;
            string str14 = "TextFieldPanel";

            uiTextField2.focusedBgSprite = str14;
            int num35 = 1;

            uiTextField2.builtinKeyNavigation = num35 != 0;
            int num36 = 1;

            uiTextField2.submitOnFocusLost = num36 != 0;
            double num37 = 45.0;

            uiTextField2.width = (float)num37;
            double num38 = 22.0;

            uiTextField2.height = (float)num38;
            int num39 = 6;

            uiTextField2.maxLength = num39;
            int num40 = 1;

            uiTextField2.numericalOnly = num40 != 0;
            int num41 = 1;

            uiTextField2.verticalAlignment = (UIVerticalAlignment)num41;
            RectOffset rectOffset7 = new RectOffset(0, 0, 4, 0);

            uiTextField2.padding = rectOffset7;
            UILabel uiLabel4 = uiPanel7.AddUIComponent <UILabel>();

            uiLabel4.name              = "MaintenanceCostLabel";
            uiLabel4.text              = "0";
            uiLabel4.font              = UIUtils.Font;
            uiLabel4.textColor         = (Color32)Color.white;
            uiLabel4.textScale         = 0.8f;
            uiLabel4.textAlignment     = UIHorizontalAlignment.Right;
            uiLabel4.autoSize          = false;
            uiLabel4.height            = 30f;
            uiLabel4.width             = 60f;
            uiLabel4.verticalAlignment = UIVerticalAlignment.Middle;
            UIPanel uiPanel8 = uiPanel3.AddUIComponent <UIPanel>();
            double  num42    = (double)uiPanel8.parent.width - 8.0;

            uiPanel8.width = (float)num42;
            double num43 = 30.0;

            uiPanel8.height = (float)num43;
            int num44 = 0;

            uiPanel8.autoLayoutDirection = (LayoutDirection)num44;
            int num45 = 0;

            uiPanel8.autoLayoutStart = (LayoutStart)num45;
            RectOffset rectOffset8 = new RectOffset(0, 3, 0, 0);

            uiPanel8.autoLayoutPadding = rectOffset8;
            int num46 = 1;

            uiPanel8.autoLayout = num46 != 0;

            UIPanel uiPanel9 = uiPanel3.AddUIComponent <UIPanel>();
            double  num54    = (double)uiPanel9.parent.width - 8.0;

            uiPanel9.width = (float)num54;
            double num55 = 30.0;

            uiPanel9.height = (float)num55;
            int num56 = 0;

            uiPanel9.autoLayoutDirection = (LayoutDirection)num56;
            int num57 = 0;

            uiPanel9.autoLayoutStart = (LayoutStart)num57;
            RectOffset rectOffset10 = new RectOffset(0, 3, 0, 0);

            uiPanel9.autoLayoutPadding = rectOffset10;
            int num58 = 1;

            uiPanel9.autoLayout = num58 != 0;
            UILabel uiLabel7 = uiPanel9.AddUIComponent <UILabel>();

            uiLabel7.text              = Localization.Get("VEHICLE_EDITOR_MAX_SPEED");
            uiLabel7.font              = UIUtils.Font;
            uiLabel7.textColor         = (Color32)Color.white;
            uiLabel7.textScale         = 0.8f;
            uiLabel7.autoSize          = false;
            uiLabel7.height            = 30f;
            uiLabel7.width             = 115f;
            uiLabel7.wordWrap          = true;
            uiLabel7.verticalAlignment = UIVerticalAlignment.Middle;
            UITextField uiTextField4 = uiPanel9.AddUIComponent <UITextField>();
            string      str20        = "MaxSpeed";

            uiTextField4.name = str20;
            string str21 = "0";

            uiTextField4.text = str21;
            Color32 black4 = (Color32)Color.black;

            uiTextField4.textColor = black4;
            string str22 = "EmptySprite";

            uiTextField4.selectionSprite = str22;
            string str23 = "TextFieldPanelHovered";

            uiTextField4.normalBgSprite = str23;
            string str24 = "TextFieldPanel";

            uiTextField4.focusedBgSprite = str24;
            int num59 = 1;

            uiTextField4.builtinKeyNavigation = num59 != 0;
            int num60 = 1;

            uiTextField4.submitOnFocusLost = num60 != 0;
            double num61 = 45.0;

            uiTextField4.width = (float)num61;
            double num62 = 22.0;

            uiTextField4.height = (float)num62;
            int num63 = 3;

            uiTextField4.maxLength = num63;
            int num64 = 1;

            uiTextField4.numericalOnly = num64 != 0;
            int num65 = 1;

            uiTextField4.verticalAlignment = (UIVerticalAlignment)num65;
            RectOffset rectOffset11 = new RectOffset(0, 0, 4, 0);

            uiTextField4.padding = rectOffset11;
            UILabel uiLabel8 = uiPanel9.AddUIComponent <UILabel>();

            uiLabel8.name              = "MaxSpeedLabel";
            uiLabel8.text              = "0";
            uiLabel8.font              = UIUtils.Font;
            uiLabel8.textColor         = (Color32)Color.white;
            uiLabel8.textScale         = 0.8f;
            uiLabel8.textAlignment     = UIHorizontalAlignment.Right;
            uiLabel8.autoSize          = false;
            uiLabel8.height            = 30f;
            uiLabel8.width             = 60f;
            uiLabel8.verticalAlignment = UIVerticalAlignment.Middle;
            UIPanel uiPanel10 = uiPanel3.AddUIComponent <UIPanel>();
            string  str25     = "EngineRow";

            uiPanel10.name = str25;
            double num66 = (double)uiPanel10.parent.width - 8.0;

            uiPanel10.width = (float)num66;
            double num67 = 30.0;

            uiPanel10.height = (float)num67;
            int num68 = 0;

            uiPanel10.autoLayoutDirection = (LayoutDirection)num68;
            int num69 = 0;

            uiPanel10.autoLayoutStart = (LayoutStart)num69;
            RectOffset rectOffset12 = new RectOffset(0, 3, 0, 0);

            uiPanel10.autoLayoutPadding = rectOffset12;
            int num70 = 1;

            uiPanel10.autoLayout = num70 != 0;
            UICheckBox checkBox = UIUtils.CreateCheckBox((UIComponent)uiPanel10);
            string     str26    = "EngineOnBothEnds";

            checkBox.name = str26;
            string str27 = Localization.Get("VEHICLE_EDITOR_ENGINE_ON_BOTH_ENDS_TOOLTIP");

            checkBox.tooltip    = str27;
            checkBox.label.text = Localization.Get("VEHICLE_EDITOR_ENGINE_ON_BOTH_ENDS");
            UIPanel uiPanel11 = uiPanel3.AddUIComponent <UIPanel>();
            string  str28     = "ButtonRow";

            uiPanel11.name = str28;
            double num71 = (double)uiPanel11.parent.width - 8.0;

            uiPanel11.width = (float)num71;
            double num72 = 30.0;

            uiPanel11.height = (float)num72;
            int num73 = 0;

            uiPanel11.autoLayoutDirection = (LayoutDirection)num73;
            int num74 = 0;

            uiPanel11.autoLayoutStart = (LayoutStart)num74;
            RectOffset rectOffset13 = new RectOffset(0, 6, 4, 0);

            uiPanel11.autoLayoutPadding = rectOffset13;
            int num75 = 1;

            uiPanel11.autoLayout = num75 != 0;
            UIButton button1 = UIUtils.CreateButton((UIComponent)uiPanel11);
            string   str29   = "Apply";

            button1.name = str29;
            string str30 = Localization.Get("VEHICLE_EDITOR_APPLY");

            button1.text = str30;
            double num76 = 0.800000011920929;

            button1.textScale = (float)num76;
            double num77 = 110.0;

            button1.width = (float)num77;
            double num78 = 22.0;

            button1.height = (float)num78;
            MouseEventHandler mouseEventHandler1 = new MouseEventHandler(this.OnApplyButtonClick);

            button1.eventClick += mouseEventHandler1;
            UIButton button2 = UIUtils.CreateButton((UIComponent)uiPanel11);
            string   str31   = "Default";

            button2.name = str31;
            string str32 = Localization.Get("VEHICLE_EDITOR_DEFAULT");

            button2.text = str32;
            double num79 = 0.800000011920929;

            button2.textScale = (float)num79;
            double num80 = 110.0;

            button2.width = (float)num80;
            double num81 = 22.0;

            button2.height = (float)num81;
            MouseEventHandler mouseEventHandler2 = new MouseEventHandler(this.OnDefaultButtonClick);

            button2.eventClick += mouseEventHandler2;
        }
Ejemplo n.º 54
0
        public override void OnInitialize()
        {
            uIElement = new UIElement();
            uIElement.Width.Set(0f, 0.8f);
            uIElement.MaxWidth.Set(600f, 0f);
            uIElement.Top.Set(220f, 0f);
            uIElement.Height.Set(-220f, 1f);
            uIElement.HAlign = 0.5f;

            uIPanel = new UIPanel();
            uIPanel.Width.Set(0f, 1f);
            uIPanel.Height.Set(-110f, 1f);
            uIPanel.BackgroundColor = new Color(33, 43, 79) * 0.8f;
            uIElement.Append(uIPanel);

            uiLoader = new UILoaderAnimatedImage(0.5f, 0.5f, 1f);

            modList = new UIList();
            modList.Width.Set(-25f, 1f);
            modList.Height.Set(0f, 1f);
            modList.ListPadding = 5f;
            uIPanel.Append(modList);
            UIScrollbar uIScrollbar = new UIScrollbar();

            uIScrollbar.SetView(100f, 1000f);
            uIScrollbar.Height.Set(0f, 1f);
            uIScrollbar.HAlign = 1f;
            uIPanel.Append(uIScrollbar);
            modList.SetScrollbar(uIScrollbar);
            UITextPanel <string> uIHeaderTextPanel = new UITextPanel <string>("Mod Sources", 0.8f, true);

            uIHeaderTextPanel.HAlign = 0.5f;
            uIHeaderTextPanel.Top.Set(-35f, 0f);
            uIHeaderTextPanel.SetPadding(15f);
            uIHeaderTextPanel.BackgroundColor = new Color(73, 94, 171);
            uIElement.Append(uIHeaderTextPanel);
            UITextPanel <string> buttonBA = new UITextPanel <string>("Build All", 1f, false);

            buttonBA.Width.Set(-10f, 0.5f);
            buttonBA.Height.Set(25f, 0f);
            buttonBA.VAlign = 1f;
            buttonBA.Top.Set(-65f, 0f);
            buttonBA.OnMouseOver += UICommon.FadedMouseOver;
            buttonBA.OnMouseOut  += UICommon.FadedMouseOut;
            buttonBA.OnClick     += BuildMods;
            uIElement.Append(buttonBA);
            UITextPanel <string> buttonBRA = new UITextPanel <string>("Build + Reload All", 1f, false);

            buttonBRA.CopyStyle(buttonBA);
            buttonBRA.HAlign       = 1f;
            buttonBRA.OnMouseOver += UICommon.FadedMouseOver;
            buttonBRA.OnMouseOut  += UICommon.FadedMouseOut;
            buttonBRA.OnClick     += BuildAndReload;
            uIElement.Append(buttonBRA);
            UITextPanel <string> buttonB = new UITextPanel <string>("Back", 1f, false);

            buttonB.CopyStyle(buttonBA);
            buttonB.Width.Set(-10f, 1f / 3f);
            buttonB.Top.Set(-20f, 0f);
            buttonB.OnMouseOver += UICommon.FadedMouseOver;
            buttonB.OnMouseOut  += UICommon.FadedMouseOut;
            buttonB.OnClick     += BackClick;
            uIElement.Append(buttonB);
            UITextPanel <string> buttonOS = new UITextPanel <string>("Open Sources", 1f, false);

            buttonOS.CopyStyle(buttonB);
            buttonOS.HAlign       = .5f;
            buttonOS.OnMouseOver += UICommon.FadedMouseOver;
            buttonOS.OnMouseOut  += UICommon.FadedMouseOut;
            buttonOS.OnClick     += OpenSources;
            uIElement.Append(buttonOS);
            UITextPanel <string> buttonMP = new UITextPanel <string>("Manage Published", 1f, false);

            buttonMP.CopyStyle(buttonB);
            buttonMP.HAlign       = 1f;
            buttonMP.OnMouseOver += UICommon.FadedMouseOver;
            buttonMP.OnMouseOut  += UICommon.FadedMouseOut;
            buttonMP.OnClick     += ManagePublished;
            uIElement.Append(buttonMP);
            base.Append(uIElement);
        }
Ejemplo n.º 55
0
    /// <summary>
    /// Helper function used to print things in columns.
    /// </summary>

    bool DrawRow(Entry ent, UIPanel selected, bool isChecked)
    {
        bool   retVal = false;
        string panelName, layer, depth, widgetCount, drawCalls, clipping, triangles;

        if (ent != null)
        {
            panelName   = ent.panel.name;
            layer       = LayerMask.LayerToName(ent.panel.gameObject.layer);
            depth       = ent.panel.depth.ToString();
            widgetCount = ent.widgets.Count.ToString();
            drawCalls   = ent.panel.drawCalls.Count.ToString();
            clipping    = (ent.panel.clipping != UIDrawCall.Clipping.None) ? "Yes" : "";

            int triangeCount = 0;
            foreach (var dc in ent.panel.drawCalls)
            {
                triangeCount += dc.triangles;
            }

            triangles = triangeCount.ToString();
        }
        else
        {
            panelName   = "Panel's Name";
            layer       = "Layer";
            depth       = "DP";
            widgetCount = "WG";
            drawCalls   = "DC";
            clipping    = "Clip";
            triangles   = "Tris";
        }

        if (ent != null)
        {
            GUILayout.Space(-1f);
        }

        if (ent != null)
        {
            GUI.backgroundColor = ent.panel == selected ? Color.white : new Color(0.8f, 0.8f, 0.8f);
            //GUILayout.BeginHorizontal("AS TextArea", GUILayout.MinHeight(20f));
            GUILayout.BeginHorizontal("TextArea", GUILayout.MinHeight(20f));
            GUI.backgroundColor = Color.white;
        }
        else
        {
            GUILayout.BeginHorizontal();
        }

        GUI.contentColor = (ent == null || ent.isEnabled) ? Color.white : new Color(0.7f, 0.7f, 0.7f);
        if (isChecked != EditorGUILayout.Toggle(isChecked, GUILayout.Width(20f)))
        {
            retVal = true;
        }

        GUILayout.Label(depth, GUILayout.Width(30f));

        if (GUILayout.Button(panelName, EditorStyles.label, GUILayout.MinWidth(100f)))
        {
            if (ent != null)
            {
                Selection.activeGameObject = ent.panel.gameObject;
                EditorUtility.SetDirty(ent.panel.gameObject);
            }
        }

        GUILayout.Label(layer, GUILayout.Width(ent == null ? 65f : 70f));
        GUILayout.Label(widgetCount, GUILayout.Width(30f));
        GUILayout.Label(drawCalls, GUILayout.Width(30f));
        GUILayout.Label(clipping, GUILayout.Width(30f));
        GUILayout.Label(triangles, GUILayout.Width(30f));

        if (ent == null)
        {
            GUILayout.Label("Stc", GUILayout.Width(24f));
        }
        else
        {
            bool val = ent.panel.widgetsAreStatic;

            if (val != EditorGUILayout.Toggle(val, GUILayout.Width(20f)))
            {
                ent.panel.widgetsAreStatic = !val;
                EditorUtility.SetDirty(ent.panel.gameObject);
#if !UNITY_3_5
                if (NGUITransformInspector.instance != null)
                {
                    NGUITransformInspector.instance.Repaint();
                }
#endif
            }
        }
        GUI.contentColor = Color.white;
        GUILayout.EndHorizontal();
        return(retVal);
    }
Ejemplo n.º 56
0
 public void Show()
 {
     if (base.enabled && NGUITools.GetActive(base.gameObject) && mChild == null && atlas != null && isValid && items.Count > 0)
     {
         mLabelList.Clear();
         if (mPanel == null)
         {
             mPanel = UIPanel.Find(base.transform);
             if (mPanel == null)
             {
                 return;
             }
         }
         handleEvents = true;
         Transform transform = base.transform;
         Bounds    bounds    = NGUIMath.CalculateRelativeWidgetBounds(transform.parent, transform);
         mChild       = new GameObject("Drop-down List");
         mChild.layer = base.gameObject.layer;
         Transform transform2 = mChild.transform;
         transform2.parent        = transform.parent;
         transform2.localPosition = bounds.min;
         transform2.localRotation = Quaternion.identity;
         transform2.localScale    = Vector3.one;
         mBackground       = NGUITools.AddSprite(mChild, atlas, backgroundSprite);
         mBackground.pivot = UIWidget.Pivot.TopLeft;
         mBackground.depth = NGUITools.CalculateNextDepth(mPanel.gameObject);
         mBackground.color = backgroundColor;
         Vector4 border = mBackground.border;
         mBgBorder = border.y;
         mBackground.cachedTransform.localPosition = new Vector3(0f, border.y, 0f);
         mHighlight       = NGUITools.AddSprite(mChild, atlas, highlightSprite);
         mHighlight.pivot = UIWidget.Pivot.TopLeft;
         mHighlight.color = highlightColor;
         UISpriteData atlasSprite = mHighlight.GetAtlasSprite();
         if (atlasSprite != null)
         {
             float          num             = (float)atlasSprite.borderTop;
             float          num2            = (float)activeFontSize;
             float          activeFontScale = this.activeFontScale;
             float          num3            = num2 * activeFontScale;
             float          num4            = 0f;
             float          num5            = 0f - padding.y;
             List <UILabel> list            = new List <UILabel>();
             if (!items.Contains(mSelectedItem))
             {
                 mSelectedItem = null;
             }
             int i = 0;
             for (int count = items.Count; i < count; i++)
             {
                 string  text    = items[i];
                 UILabel uILabel = NGUITools.AddWidget <UILabel>(mChild);
                 uILabel.name         = i.ToString();
                 uILabel.pivot        = UIWidget.Pivot.TopLeft;
                 uILabel.bitmapFont   = bitmapFont;
                 uILabel.trueTypeFont = trueTypeFont;
                 uILabel.fontSize     = fontSize;
                 uILabel.fontStyle    = fontStyle;
                 uILabel.text         = ((!isLocalized) ? text : Localization.Get(text));
                 uILabel.color        = textColor;
                 Transform cachedTransform = uILabel.cachedTransform;
                 float     num6            = border.x + padding.x;
                 Vector2   pivotOffset     = uILabel.pivotOffset;
                 cachedTransform.localPosition = new Vector3(num6 - pivotOffset.x, num5, -1f);
                 uILabel.overflowMethod        = UILabel.Overflow.ResizeFreely;
                 uILabel.alignment             = alignment;
                 list.Add(uILabel);
                 num5 -= num3;
                 num5 -= padding.y;
                 float   a           = num4;
                 Vector2 printedSize = uILabel.printedSize;
                 num4 = Mathf.Max(a, printedSize.x);
                 UIEventListener uIEventListener = UIEventListener.Get(uILabel.gameObject);
                 uIEventListener.onHover   = OnItemHover;
                 uIEventListener.onPress   = OnItemPress;
                 uIEventListener.onClick   = OnItemClick;
                 uIEventListener.parameter = text;
                 if (mSelectedItem == text || (i == 0 && string.IsNullOrEmpty(mSelectedItem)))
                 {
                     Highlight(uILabel, instant: true);
                 }
                 mLabelList.Add(uILabel);
             }
             float   a2   = num4;
             Vector3 size = bounds.size;
             num4 = Mathf.Max(a2, size.x * activeFontScale - (border.x + padding.x) * 2f);
             float   num7    = num4;
             Vector3 vector  = new Vector3(num7 * 0.5f, (0f - num2) * 0.5f, 0f);
             Vector3 vector2 = new Vector3(num7, num3 + padding.y, 1f);
             int     j       = 0;
             for (int count2 = list.Count; j < count2; j++)
             {
                 UILabel uILabel2 = list[j];
                 NGUITools.AddWidgetCollider(uILabel2.gameObject);
                 uILabel2.autoResizeBoxCollider = false;
                 BoxCollider component = uILabel2.GetComponent <BoxCollider>();
                 if (component != null)
                 {
                     Vector3 center = component.center;
                     vector.z         = center.z;
                     component.center = vector;
                     component.size   = vector2;
                 }
                 else
                 {
                     BoxCollider2D component2 = uILabel2.GetComponent <BoxCollider2D>();
                     component2.offset = vector;
                     component2.size   = vector2;
                 }
             }
             int width = Mathf.RoundToInt(num4);
             num4 += (border.x + padding.x) * 2f;
             num5 -= border.y;
             mBackground.width  = Mathf.RoundToInt(num4);
             mBackground.height = Mathf.RoundToInt(0f - num5 + border.y);
             int k = 0;
             for (int count3 = list.Count; k < count3; k++)
             {
                 UILabel uILabel3 = list[k];
                 uILabel3.overflowMethod = UILabel.Overflow.ShrinkContent;
                 uILabel3.width          = width;
             }
             float num8 = 2f * atlas.pixelSize;
             float f    = num4 - (border.x + padding.x) * 2f + (float)atlasSprite.borderLeft * num8;
             float f2   = num3 + num * num8;
             mHighlight.width  = Mathf.RoundToInt(f);
             mHighlight.height = Mathf.RoundToInt(f2);
             bool flag = position == Position.Above;
             if (position == Position.Auto)
             {
                 UICamera uICamera = UICamera.FindCameraForLayer(base.gameObject.layer);
                 if (uICamera != null)
                 {
                     Vector3 vector3 = uICamera.cachedCamera.WorldToViewportPoint(transform.position);
                     flag = (vector3.y < 0.5f);
                 }
             }
             if (isAnimated)
             {
                 float bottom = num5 + num3;
                 Animate(mHighlight, flag, bottom);
                 int l = 0;
                 for (int count4 = list.Count; l < count4; l++)
                 {
                     Animate(list[l], flag, bottom);
                 }
                 AnimateColor(mBackground);
                 AnimateScale(mBackground, flag, bottom);
             }
             if (flag)
             {
                 Transform transform3 = transform2;
                 Vector3   min        = bounds.min;
                 float     x          = min.x;
                 Vector3   max        = bounds.max;
                 float     y          = max.y - num5 - border.y;
                 Vector3   min2       = bounds.min;
                 transform3.localPosition = new Vector3(x, y, min2.z);
             }
         }
     }
     else
     {
         OnSelect(isSelected: false);
     }
 }
Ejemplo n.º 57
0
        public void OnSettingsUI(UIHelperBase helper)
        {
            try
            {
                UIHelper group = helper.AddGroup(Name) as UIHelper;
                UIPanel  panel = group.self as UIPanel;

                // Integrate main button with UUI
                UICheckBox integrateMainButtonUUI = (UICheckBox)group.AddCheckbox(Translations.Translate("YAT_SET_UUI"), Settings.integrateMainButtonUUI, (b) =>
                {
                    Settings.integrateMainButtonUUI = b;
                    XMLUtils.SaveSettings();
                    if (YetAnotherToolbar.instance?.mainButton != null)
                    {
                        if (Settings.integrateMainButtonUUI)
                        {
                            UUIIntegration.AttachMainButton();
                        }
                        else
                        {
                            UUIIntegration.DetachMainButton();
                        }
                    }
                });
                group.AddSpace(10);

                // Hide main button
                UICheckBox hideMainButton = (UICheckBox)group.AddCheckbox(Translations.Translate("YAT_SET_HMB"), Settings.hideMainButton, (b) =>
                {
                    Settings.hideMainButton = b;
                    XMLUtils.SaveSettings();
                    if (YetAnotherToolbar.instance?.mainButton != null)
                    {
                        YetAnotherToolbar.instance.mainButton.isVisible = !Settings.hideMainButton;
                    }
                });
                group.AddSpace(10);

                UIButton mainButtonPositionReset = (UIButton)group.AddButton(Translations.Translate("YAT_SET_HMBRST"), () =>
                {
                    Settings.mainButtonX = 538.0f;
                    Settings.mainButtonY = 947.0f;
                    XMLUtils.SaveSettings();
                    if (YetAnotherToolbar.instance?.mainButton != null)
                    {
                        UIView view = UIView.GetAView();
                        Vector2 screenResolution = view.GetScreenResolution();
                        YetAnotherToolbar.instance.mainButton.absolutePosition = new Vector3(Settings.mainButtonX * screenResolution.x / 1920f, Settings.mainButtonY * screenResolution.y / 1080f);// advisorButton.absolutePosition + new Vector3(advisorButton.width, 0);
                    }
                });
                group.AddSpace(10);

                // Hide Advisor Button
                UICheckBox hideAdvisorButton = (UICheckBox)group.AddCheckbox(Translations.Translate("YAT_SET_HAB"), Settings.hideAdvisorButton, (b) =>
                {
                    Settings.hideAdvisorButton = b;
                    XMLUtils.SaveSettings();
                    if (YetAnotherToolbar.instance != null)
                    {
                        YetAnotherToolbar.instance.SetAdvisorButtonVisibility();
                    }
                });
                group.AddSpace(10);

                /*
                 * // Hide Filter Panels
                 * UICheckBox hideFilterPanels = (UICheckBox)group.AddCheckbox(Translations.Translate("YAT_SET_HFP"), Settings.hideFilterPanels, (b) =>
                 * {
                 *  Settings.hideFilterPanels = b;
                 *  XMLUtils.SaveSettings();
                 *  if (YetAnotherToolbar.instance != null)
                 *  {
                 *      YetAnotherToolbar.instance.hideFilterPanels = Settings.hideFilterPanels;
                 *      YetAnotherToolbar.instance.SetFilterPanelsVisibility();
                 *  }
                 * });
                 * group.AddSpace(10);
                 */

                // Disable update notice
                UICheckBox disableUpdateNotice = (UICheckBox)group.AddCheckbox(Translations.Translate("YAT_SET_DUN"), Settings.disableUpdateNotice, (b) =>
                {
                    Settings.disableUpdateNotice = b;
                    XMLUtils.SaveSettings();
                });
                group.AddSpace(10);

                // languate settings
                UIDropDown languageDropDown = (UIDropDown)group.AddDropdown(Translations.Translate("TRN_CHOICE"), Translations.LanguageList, Translations.Index, (value) =>
                {
                    Translations.Index = value;
                    XMLUtils.SaveSettings();
                });

                languageDropDown.width = 300;
                group.AddSpace(10);

                // show path to YetAnotherToolbarConfig.xml
                string      path           = Path.Combine(DataLocation.executableDirectory, "YetAnotherToolbarConfig.xml");
                UITextField ConfigFilePath = (UITextField)group.AddTextfield($"{Translations.Translate("YAT_SET_CFP")} - YetAnotherToolbarConfig.xml", path, _ => { }, _ => { });
                ConfigFilePath.width = panel.width - 30;

                group.AddButton(Translations.Translate("YAT_SET_OFE"), () => System.Diagnostics.Process.Start(DataLocation.executableDirectory));

                // shortcut keys
                panel.gameObject.AddComponent <ModeToggleKeyMapping>();
                panel.gameObject.AddComponent <QuickMenuKeyMapping>();
                panel.gameObject.AddComponent <HideMenuKeyMapping>();
                group.AddSpace(10);
            }
            catch (Exception e)
            {
                Debugging.Message("OnSettingsUI failed");
                Debugging.LogException(e);
            }
        }
Ejemplo n.º 58
0
        private void SetupControls()
        {
            if (m_panel != null)
            {
                return;
            }

            // Panel
            m_panel                  = AddUIComponent <UIPanel>();
            m_panel.width            = width - 10f;
            m_panel.height           = height;
            m_panel.padding          = new RectOffset(2, 2, 2, 2);
            m_panel.backgroundSprite = "LevelBarBackground";
            m_panel.color            = m_color;
            m_panel.clipChildren     = true;
            m_panel.relativePosition = Vector2.zero;

            // Scrollbar
            m_scrollbar             = AddUIComponent <UIScrollbar>();
            m_scrollbar.width       = 12f;
            m_scrollbar.height      = height;
            m_scrollbar.orientation = UIOrientation.Vertical;
            m_scrollbar.pivot       = UIPivotPoint.BottomLeft;
            m_scrollbar.AlignTo(this, UIAlignAnchor.TopRight);
            m_scrollbar.minValue        = 0;
            m_scrollbar.value           = 0;
            m_scrollbar.incrementAmount = 50;

            UISlicedSprite tracSprite = m_scrollbar.AddUIComponent <UISlicedSprite>();

            tracSprite.relativePosition = new Vector3(2, 0);
            tracSprite.autoSize         = true;
            tracSprite.size             = tracSprite.parent.size;
            tracSprite.fillDirection    = UIFillDirection.Vertical;
            tracSprite.spriteName       = "LevelBarBackground";

            m_scrollbar.trackObject = tracSprite;

            UISlicedSprite thumbSprite = tracSprite.AddUIComponent <UISlicedSprite>();

            thumbSprite.relativePosition = Vector2.zero;
            thumbSprite.fillDirection    = UIFillDirection.Vertical;
            thumbSprite.autoSize         = true;
            thumbSprite.width            = 12f;
            thumbSprite.spriteName       = "LevelBarForeground";

            m_scrollbar.thumbObject = thumbSprite;

            // Rows
            CheckRows();

            m_scrollbar.eventValueChanged += (c, t) =>
            {
                if (m_lock || m_rowHeight <= 0)
                {
                    return;
                }

                m_lock = true;

                listPosition = m_scrollbar.value * (m_rowsData.m_size - height / m_rowHeight) / (height - m_scrollbar.scrollSize - 1f);
                m_lock       = false;
            };
        }
        public void Awake()
        {
            MainContainer                     = GetComponent <UIPanel>();
            MainContainer.autoLayout          = true;
            MainContainer.autoLayoutDirection = LayoutDirection.Vertical;
            MainContainer.padding             = new RectOffset(5, 5, 5, 5);
            MainContainer.autoLayoutPadding   = new RectOffset(0, 0, 3, 3);

            KlyteMonoUtils.CreateTabsComponent(out m_tabstrip, out m_tabContainer, MainContainer.transform, "TextEditor", new Vector4(0, 0, MainContainer.width, 40), new Vector4(0, 0, MainContainer.width, MainContainer.height - 40));
            m_tabSettings   = TabCommons.CreateNonScrollableTabLocalized(m_tabstrip, KlyteResourceLoader.GetDefaultSpriteNameFor(CommonsSpriteNames.K45_Settings), "K45_WTS_GENERAL_SETTINGS", "TxtSettings");
            m_tabSize       = TabCommons.CreateNonScrollableTabLocalized(m_tabstrip, KlyteResourceLoader.GetDefaultSpriteNameFor(CommonsSpriteNames.K45_MoveCross), "K45_WTS_TEXT_SIZE_ATTRIBUTES", "TxtSize");
            m_tabAppearence = TabCommons.CreateScrollableTabLocalized(m_tabstrip, KlyteResourceLoader.GetDefaultSpriteNameFor(CommonsSpriteNames.K45_AutoColorIcon), "K45_WTS_TEXT_APPEARANCE_ATTRIBUTES", "TxtApp");
            m_tabConfig     = TabCommons.CreateScrollableTabLocalized(m_tabstrip, KlyteResourceLoader.GetDefaultSpriteNameFor(CommonsSpriteNames.K45_AutoNameIcon), "K45_WTS_TEXT_CONFIGURATION_ATTRIBUTES", "TxtCnf");

            var helperSettings   = new UIHelperExtension(m_tabSettings, LayoutDirection.Vertical);
            var helperSize       = new UIHelperExtension(m_tabSize, LayoutDirection.Vertical);
            var helperAppearance = new UIHelperExtension(m_tabAppearence, LayoutDirection.Vertical);
            var helperConfig     = new UIHelperExtension(m_tabConfig, LayoutDirection.Vertical);

            AddTextField(Locale.Get("K45_WTS_TEXT_TAB_TITLE"), out m_tabName, helperSettings, OnTabNameChanged);

            AddVector3Field(Locale.Get("K45_WTS_RELATIVE_POS"), out m_arrayCoord, helperSize, OnPositionChange);
            AddVector3Field(Locale.Get("K45_WTS_RELATIVE_ROT"), out m_arrayRotation, helperSize, OnRotationChange);
            AddFloatField(Locale.Get("K45_WTS_TEXT_SCALE"), out m_textScale, helperSize, OnScaleSubmit, false);
            AddFloatField(Locale.Get("K45_WTS_MAX_WIDTH_METERS"), out m_maxWidth, helperSize, OnMaxWidthChange, false);
            AddCheckboxLocale("K45_WTS_RESIZE_Y_TEXT_OVERFLOW", out m_applyScaleOnY, helperSize, OnChangeApplyRescaleOnY);
            AddCheckboxLocale("K45_WTS_CREATE_CLONE_180DEG", out m_create180degSimmetricClone, helperSize, OnChangeCreateSimmetricClone);
            AddCheckboxLocale("K45_WTS_CLONE_180DEG_INVERT_TEXT_HOR_ALIGN", out m_invertTextHorizontalAlignClone, helperSize, OnChangeInvertCloneTextHorizontalAlignment);

            //      AddCheckboxLocale("K45_WTS_MIRRORED", out m_mirrored, helperSize, OnChangeMirrored);

            AddDropdown(Locale.Get("K45_WTS_TEXT_ALIGN_HOR"), out m_dropdownTextAlignHorizontal, helperAppearance, ColossalUIExtensions.GetDropdownOptions <UIHorizontalAlignment>("K45_ALIGNMENT"), OnSetTextAlignmentHorizontal);
            helperAppearance.AddSpace(5);
            AddCheckboxLocale("K45_WTS_USE_CONTRAST_COLOR", out m_useContrastColor, helperAppearance, OnContrastColorChange);
            AddColorField(helperAppearance, Locale.Get("K45_WTS_TEXT_COLOR"), out m_textFixedColor, OnFixedColorChanged);
            AddSlider(Locale.Get("K45_WTS_TEXT_DEPTH"), out m_sliderDepth, helperAppearance, OnChangeDepth, -1, 1, 0.025f, (x) => $"{x.ToString("P1")}");
            AddDropdown(Locale.Get("K45_WTS_TEXT_MATERIALTYPE"), out m_dropdownMaterialType, helperAppearance, ColossalUIExtensions.GetDropdownOptions <MaterialType>("K45_WTS_TEXTMATERIALTYPE"), OnSetMaterialType);
            AddSlider(Locale.Get("K45_WTS_TEXT_ILLUMINATIONSTRENGTH"), out m_sliderIllumination, helperAppearance, OnChangeIlluminationStrength, 0, 10, 0.025f, (x) => $"{x.ToString("P1")}");
            AddDropdown(Locale.Get("K45_WTS_TEXT_BLINKTYPE"), out m_dropdownBlinkType, helperAppearance, ColossalUIExtensions.GetDropdownOptions <BlinkType>("K45_WTS_BLINKTYPE"), OnSetBlinkType);
            AddVector4Field(Locale.Get("K45_WTS_TEXT_CUSTOMBLINKPARAMS"), out m_arrayCustomBlink, helperAppearance, OnCustomBlinkChange);


            AddEmptyDropdown(Locale.Get("K45_WTS_TEXT_CONTENT"), out m_dropdownTextContent, helperConfig, OnSetTextOwnNameContent);
            AddTextField(Locale.Get("K45_WTS_CUSTOM_TEXT"), out m_customText, helperConfig, OnSetTextCustom);

            IEnumerator OnFilter(string x, Wrapper <string[]> result)
            {
                yield return(result.Value = OnFilterParamImages(WTSPropLayoutEditor.Instance.PropPreview.OverrideSprite, x));
            }

            AddFilterableInput(Locale.Get("K45_WTS_SPRITE_NAME"), helperConfig, out m_spriteFilter, out UIListBox lb2, OnFilter, OnSpriteNameChanged);
            lb2.size                      = new Vector2(MainContainer.width - 20, 220);
            lb2.processMarkup             = true;
            m_spriteFilter.eventGotFocus += (x, y) =>
            {
                var text = ((UITextField)x).text;
                if (text.StartsWith(WTSAtlasesLibrary.PROTOCOL_IMAGE_ASSET) || text.StartsWith(WTSAtlasesLibrary.PROTOCOL_IMAGE))
                {
                    WTSPropLayoutEditor.Instance.PropPreview.OverrideSprite.spriteName = ((UITextField)x).text.Split('/').Last().Trim();
                }
            };
            lb2.eventItemMouseHover += (x, y) =>
            {
                if (y >= 0 && y < lb2.items.Length)
                {
                    WTSPropLayoutEditor.Instance.PropPreview.OverrideSprite.spriteName = lb2.items[y].Split('/').Last().Trim();
                }
            };
            lb2.eventVisibilityChanged += (x, y) => WTSPropLayoutEditor.Instance.PropPreview.OverrideSprite.parent.isVisible = y;
            WTSPropLayoutEditor.Instance.PropPreview.OverrideSprite.parent.isVisible = false;

            AddDropdown(Locale.Get("K45_WTS_PROPLAYOUT_DESTINATIONREFERENCE"), out m_destinationRef, helperConfig, ColossalUIExtensions.GetDropdownOptions <DestinationReference>("K45_WTS_ONNETTEXT_DESTINATION_DESC"), OnChangeDestinationRef);
            AddDropdown(Locale.Get("K45_WTS_PROPLAYOUT_TEXTPARAMETERIDX"), out m_parameterIdx, helperConfig, ColossalUIExtensions.GetDropdownOptionsUnlocalized(new string[BoardInstanceOnNetXml.TEXT_PARAMETERS_COUNT].Select((x, i) => $"#{i}").ToArray()), OnChangeTextParameterIdx);
            AddTextField(Locale.Get("K45_WTS_PROPLAYOUT_TEXTPARAMETERNAME"), out m_parameterDisplayName, helperConfig, OnSetParameterDisplayName);
            IEnumerator OnFilter2(string x, Wrapper <string[]> result)
            {
                yield return(result.Value = OnFilterParamImages(WTSPropLayoutEditor.Instance.PropPreview.OverrideSprite, x));
            }

            AddFilterableInput(Locale.Get("K45_WTS_PROPLAYOUT_TEXTPARAMETERDEFAULTVAL"), helperConfig, out m_defaultParameterValue, out UIListBox lb, OnFilter2, OnChangedDefaultTextParam);
            lb.processMarkup = true;
            lb.size          = new Vector2(MainContainer.width - 20, 220);
            m_defaultParameterValue.eventGotFocus += (x, y) =>
            {
                var text = ((UITextField)x).text;
                if (text.StartsWith(WTSAtlasesLibrary.PROTOCOL_IMAGE_ASSET) || text.StartsWith(WTSAtlasesLibrary.PROTOCOL_IMAGE))
                {
                    WTSPropLayoutEditor.Instance.PropPreview.OverrideSprite.spriteName = ((UITextField)x).text.Split('/').Last().Trim();
                }
            };
            lb.eventItemMouseHover += (x, y) =>
            {
                if (y >= 0 && y < lb.items.Length)
                {
                    WTSPropLayoutEditor.Instance.PropPreview.OverrideSprite.spriteName = lb.items[y].Split('/').Last().Trim();
                }
            };
            lb.eventVisibilityChanged += (x, y) => WTSPropLayoutEditor.Instance.PropPreview.OverrideSprite.parent.isVisible = y;
            WTSPropLayoutEditor.Instance.PropPreview.OverrideSprite.parent.isVisible = false;

            AddIntField(Locale.Get("K45_WTS_PROPLAYOUT_ITEMDURATIONFRAMES"), out m_slideDurationFrames, helperConfig, OnSetDurationFrames, false);
            AddIntField(Locale.Get("K45_WTS_PROPLAYOUT_DESYNCFRAMES"), out m_slideDesync, helperConfig, OnSetDesyncOffset, false);
            helperConfig.AddSpace(5);
            AddDropdown(Locale.Get("K45_WTS_CLASS_FONT"), out m_fontClassSelect, helperConfig, ColossalUIExtensions.GetDropdownOptions <FontClass>("K45_WTS_FONTCLASS"), OnSetFontClass);
            AddEmptyDropdown(Locale.Get("K45_WTS_OVERRIDE_FONT"), out m_overrideFontSelect, helperConfig, OnSetOverrideFont);
            AddTextField(Locale.Get("K45_WTS_PREFIX"), out m_textPrefix, helperConfig, OnSetPrefix);
            AddTextField(Locale.Get("K45_WTS_SUFFIX"), out m_textSuffix, helperConfig, OnSetSuffix);
            AddCheckboxLocale("K45_WTS_TEXT_ALL_CAPS", out m_allCaps, helperConfig, OnSetAllCaps);
            AddCheckboxLocale("K45_WTS_TEXT_APPLYABBREVIATIONS", out m_applyAbbreviations, helperConfig, OnSetApplyAbbreviations);
            AddVector2Field(Locale.Get("K45_WTS_TEXT_ROW_COLUMNS"), out m_arrayRowColumnsCount, helperConfig, OnRowColumnCountChanged, true, true);
            m_arrayRowColumnsCount.ForEach(x => x.allowNegative = false);
            AddVector2Field(Locale.Get("K45_WTS_TEXT_ROW_COLUMNS_SPACING"), out m_arrayRowColumnsSpacing, helperConfig, OnRowColumnSpacingChanged);
            AddDropdown(Locale.Get("K45_WTS_VERTICAL_ALIGNMENT"), out m_verticalAlignDD, helperConfig, ColossalUIExtensions.GetDropdownOptions <UIVerticalAlignment>("K45_VERT_ALIGNMENT"), OnSetVerticalAlign);
            AddCheckboxLocale("K45_WTS_TEXT_FILLCOLUMNSFIRST", out m_checkboxVerticalFirst, helperConfig, OnColumnsFirstChanged);

            WTSUtils.ReloadFontsOf(m_overrideFontSelect, null, true, true);

            WTSPropLayoutEditor.Instance.CurrentTabChanged += (newVal) =>
            {
                int targetTab = newVal - 1;
                SafeObtain(OnSetData, targetTab);
                if (WTSPropLayoutEditor.Instance.EditingInstance?.m_configurationSource == ConfigurationSource.CITY)
                {
                    m_tabContainer.Enable();
                }
                else
                {
                    m_tabContainer.Disable();
                }
            };
            m_isEditing = false;


            AddLibBox <WTSLibPropTextItem, BoardTextDescriptorGeneralXml>(helperSettings, out UIButton m_copyButtonText,
                                                                          DoCopyText, out m_pasteButtonText,
                                                                          DoPasteText, out UIButton m_deleteButtonText,
                                                                          DoDeleteText, (loadedItem) => SafeObtain((ref BoardTextDescriptorGeneralXml x) =>
            {
                string name = x.SaveName;
                x           = XmlUtils.DefaultXmlDeserialize <BoardTextDescriptorGeneralXml>(loadedItem);
                x.SaveName  = name;
                OnSetData(ref x);
                x.SaveName = name;
            }),
                                                                          () => XmlUtils.DefaultXmlSerialize(WTSPropLayoutEditor.Instance.EditingInstance.TextDescriptors[Math.Max(0, TabToEdit)]));
        }
Ejemplo n.º 60
0
    /// <summary>
    /// Changes the drag amount of the scroll view to the specified 0-1 range values.
    /// (0, 0) is the top-left corner, (1, 1) is the bottom-right.
    /// </summary>

    public virtual void SetDragAmount(float x, float y, bool updateScrollbars)
    {
        if (mPanel == null)
        {
            mPanel = GetComponent <UIPanel>();
        }

        DisableSpring();

        Bounds b = bounds;

        if (b.min.x == b.max.x || b.min.y == b.max.y)
        {
            return;
        }

        Vector4 clip = mPanel.finalClipRegion;

        float hx     = clip.z * 0.5f;
        float hy     = clip.w * 0.5f;
        float left   = b.min.x + hx;
        float right  = b.max.x - hx;
        float bottom = b.min.y + hy;
        float top    = b.max.y - hy;

        if (mPanel.clipping == UIDrawCall.Clipping.SoftClip)
        {
            left   -= mPanel.clipSoftness.x;
            right  += mPanel.clipSoftness.x;
            bottom -= mPanel.clipSoftness.y;
            top    += mPanel.clipSoftness.y;
        }

        // Calculate the offset based on the scroll value
        float ox = Mathf.Lerp(left, right, x);
        float oy = Mathf.Lerp(top, bottom, y);

        // Update the position
        if (!updateScrollbars)
        {
            Vector3 pos = mTrans.localPosition;
            if (canMoveHorizontally)
            {
                pos.x += clip.x - ox;
            }
            if (canMoveVertically)
            {
                pos.y += clip.y - oy;
            }
            mTrans.localPosition = pos;
        }

        if (canMoveHorizontally)
        {
            clip.x = ox;
        }
        if (canMoveVertically)
        {
            clip.y = oy;
        }

        // Update the clipping offset
        Vector4 cr = mPanel.baseClipRegion;

        mPanel.clipOffset = new Vector2(clip.x - cr.x, clip.y - cr.y);

        // Update the scrollbars, reflecting this change
        if (updateScrollbars)
        {
            UpdateScrollbars(mDragID == -10);
        }
    }