Exemple #1
0
    private void SetPosAndEffect()
    {
        if (m_index - 1 < 0)
        {
            return;
        }
        RectTransform m_last_rect = blockTextList[m_index - 1].m_rect;

        m_last_rect.localScale = new Vector3(1, 1, 1);
        float posX = m_last_rect.localPosition.x + m_last_rect.rect.width;
        float posY = m_last_rect.localPosition.y;

        if (IsNeedChangeRow(posX) || IsForceChangeRow)
        {
            posY = posY - m_rect.rect.height;
            posX = blockTextList[0].m_rect.localPosition.x;
        }
        float   posZ   = m_last_rect.localPosition.z;
        Vector3 newPos = new Vector3(posX, posY, posZ);
        Vector3 pos    = new Vector3(newPos.x, newPos.y + 20f, newPos.z);

        m_rect.localPosition = pos;

        UICollection.MoveToPos(gameObject, newPos, 0.8f);
        UICollection.AlphaFadeText(gameObject, false);
        //Debug.Log("原始坐标位置:" + newPos);
        //Debug.Log("BlockTextList长度:" + blockTextList.Count);
    }
    public static void ExportUIView()
    {
        var uiObj = Selection.activeGameObject;

        if (null == uiObj)
        {
            return;
        }
        var UIViewName = uiObj.name;

        if (!UIViewName.StartsWith("UI", StringComparison.CurrentCultureIgnoreCase))
        {
            UIViewName = "UI" + UIViewName;
        }
        UIViewName = UIViewName.Substring(0, 2).ToUpper() + UIViewName.Substring(2);  //ToUpperFirst

        uiObj.name = UIViewName;
        uiExportTypeElementDic.Clear();
        uiExportElementDic.Clear();
        uiCollection     = null;
        UIComponentIndex = -1;

        ProcessUIPrefab(uiObj);
        GenUIViewCode(UIViewName);
        var prefabPath = UIExportPrefabPath + UIViewName + ".prefab";

        CreateOrReplacePrefab(uiObj, prefabPath);
        AssetDatabase.Refresh();
    }
Exemple #3
0
 public void FadeInOrOut(bool isIn)
 {
     if (isIn)
     {
         UICollection.AlphaFadeImg(gameObject, isIn, 0.7f);
     }
 }
        internal UIGridTabItem convertFromLuaData()
        {
            UICollection uic = null;

            try
            {
                uic = elements.ConvertFromLua(LuaUICollection.luaStateConversion);
            }
            catch (Exception)
            {
                Console.WriteLine("Something went wrong converting UIGrid from LUA layout!");
            }

            UIGridTabItem tabItem = null;

            if (uic != null)
            {
                tabItem = new UIGridTabItem();
                tabItem.TabItemContents = uic;
            }
            else
            {
                tabItem = null;
            }

            return(tabItem);
        }
 public Grid()
 {
     _columnDefinitions = new UICollection <IColumnDefinition>(this);
     SetValue(ColumnDefinitionsProperty, _columnDefinitions);
     _rowDefinitions = new UICollection <IRowDefinition>(this);
     SetValue(RowDefinitionsProperty, _rowDefinitions);
 }
Exemple #6
0
 private void UIGetIn()
 {
     StartCoroutine(DelayToInvoke.DelayToInvokeDo(() => {
         UICollection.AlphaFade(UIElementsList[0], true);
     }, 0.5f));
     StartCoroutine(DelayToInvoke.DelayToInvokeDo(() => {
         UICollection.AlphaFade(UIElementsList[1], true);
         GameObject role          = element2[1].gameObject;
         RectTransform roleRect   = role.GetComponent <RectTransform>();
         GameObject shadow        = element2[0].gameObject;
         RectTransform shadowRect = role.GetComponent <RectTransform>();
         UICollection.MoveToPos(role, new Vector3(0f, roleRect.localPosition.y, roleRect.localPosition.z), 0.15f);
         UICollection.MoveToPos(shadow, new Vector3(0f, shadowRect.localPosition.y, shadowRect.localPosition.z), 0.15f);
     }, 1.0f));
     StartCoroutine(DelayToInvoke.DelayToInvokeDo(() => {
         UICollection.AlphaFade(UIElementsList[3], true);
         int i = 0;
         foreach (Image item in element4)
         {
             GameObject obj     = element4[i].gameObject;
             RectTransform rect = obj.GetComponent <RectTransform>();
             UICollection.MoveToPos(obj, new Vector3(rect.localPosition.x, -80f * i, rect.localPosition.z), 0.2f);
             i++;
         }
     }, 1.5f));
     StartCoroutine(DelayToInvoke.DelayToInvokeDo(() => {
         UICollection.AlphaFade(element3Img.gameObject, true, 0.7f);
     }, 2.0f));
     StartCoroutine(DelayToInvoke.DelayToInvokeDo(() => {
         UICollection.AlphaFade(element3Text.gameObject, true);
     }, 2.0f));
 }
Exemple #7
0
    public void ChangeItem(ItemData item)
    {
        itemData = item;
        if (itemData.itemName != "")
        {
            string imagePath = "Sprites/DrinkItem/" + itemData.imgName;
            Sprite spr       = Resources.Load <Sprite>(imagePath);
            UICollection.SetImage(spr, GetComponent <Image>());
            UICollection.AlphaFadeImg(gameObject, true);
            colliderObj.isAllowDrag = true;
            try {
                colliderObj.ChangeBindItem(this, spr);
            }
            catch (Exception e) {
                Debug.Log("刚启动时绑定拖拽物品CraftItemCollider,好像会报错");
                Debug.Log("报错为:" + e);
            }
        }
        else
        {
            gameObject.GetComponent <Image>().sprite = null;
            UICollection.AlphaFadeImg(gameObject, false);

            colliderObj.isAllowDrag = false;
        }
    }
        private void VerifyBreadcrumbItemsContain(UICollection <UIObject> breadcrumbItems, string[] expectedItemValues)
        {
            // WARNING: this method clicks on each breadcrumb so once the verification has finished,
            // only the ellipsis item and 'Root' should exist

            // As recycled breadcrumbs are not deleted, then we compare that the breadcrumb count is always bigger
            // than the expected values count
            Verify.IsTrue(breadcrumbItems.Count > expectedItemValues.Length,
                          "The expected values count should at least be one less than the BreadcrumbItems count");

            // To verify the existence of the expected nodes we click on each of them and verify agains the strings
            // in LastClickedItemIndex and LastClickedItem textboxes.
            for (int i = expectedItemValues.Length - 1; i >= 0; --i)
            {
                var currentItem = breadcrumbItems[i + 1];
                Verify.IsNotNull(currentItem, "Current BreadcrumbItem should not be null");

                var currentBreadcrumbItem = ConvertTo <BreadcrumbItem>(currentItem);
                Verify.IsNotNull(currentBreadcrumbItem, "UIElement should be a BreadcrumbItem");

                currentBreadcrumbItem.Click();

                VerifyLastClickedItemIndexIs(i);
                VerifyLastClickedItemIs(expectedItemValues[i]);
            }
        }
Exemple #9
0
    public void ChangeBack(DrinkInst.BackType type)
    {
        Sprite targetSpr;

        switch (type)
        {
        case DrinkInst.BackType.normal:
            targetSpr = normalBackSpr;
            break;

        case DrinkInst.BackType.good:
            targetSpr = goodBackSpr;
            break;

        case DrinkInst.BackType.perfect:
            targetSpr = perfectBackSpr;
            break;

        default:
            targetSpr = normalBackSpr;
            break;
        }
        Vector3 scale = new Vector3(3.0f, 3.0f, 3.0f);
        Color   color = new Color(1.0f, 1.0f, 1.0f, 1.0f);

        UICollection.SetImage(targetSpr, BackImage, scale, color);
    }
        public UICollection ConvertFromLua(NLua.Lua state)
        {
            luaStateConversion = state;

            UICollection UIC = new UICollection();

            UIC.elementsInCollection = new List <BaseUIElement>();
            try
            {
                UIC.startMainElement = mainScreen.convertFromLuaData(null) as UIScreen;
            }
            catch (Exception)
            {
                UIC = null;
                LUAUtilities.errorList.Add("***Error Begin***");
                LUAUtilities.errorList.Add("No (suitable) 'mainScreen' in collection found!");
                LUAUtilities.errorList.Add("***Error End***");
            }

            if (UIC != null)
            {
                foreach (var item in listLuaElements)
                {
                    UIC.AddElement(item.convertFromLuaData(null));
                    //UIC.elementsInCollection.Add(item.convertFromLuaData(null));
                }
            }

            return(UIC);
        }
Exemple #11
0
    private void OnEnable()
    {
        m_audio_slider.value = GlobalManager.instance.audioVolumn;
        m_sound_slider.value = GlobalManager.instance.soundVolumn;
        screenResType        = GlobalManager.instance.screenResType;
        screenResText.text   = screenResStrArr[screenResType];

        UICollection.JumpBorder(gameObject);
    }
 private static void ProcessUIPrefab(GameObject gameObject)
 {
     if (null == gameObject)
     {
         return;
     }
     if (gameObject.CompareTag(UIViewTag))
     {
         uiCollection = gameObject.GetComponent <UICollection>();
         if (null == uiCollection)
         {
             uiCollection = gameObject.AddComponent <UICollection>();
         }
         uiCollection.components.Clear();
     }
     foreach (Transform transform in gameObject.transform)
     {
         if (transform.CompareTag(UIIgnoreTag))
         {
             continue;
         }
         ProcessUIPrefab(transform.gameObject);
         bool isHandled = false;
         foreach (var type in ExportComponentTypes)
         {
             var UIComp = transform.GetComponent(type);
             if (null != UIComp)
             {
                 UIComponentIndex++;
                 uiCollection.components.Add(UIComp);
                 var componentName = "m_" + transform.name;
                 uiExportElementDic[componentName]     = UIComponentIndex;
                 uiExportTypeElementDic[componentName] = type.ToString();
                 isHandled = true;
                 break;
             }
         }
         if (isHandled)
         {
             continue;
         }
         foreach (var type in ExportPropertyTypes)
         {
             var UIComp = transform.GetComponent(type);
             if (null != UIComp && transform.CompareTag(UIPropertyTag))
             {
                 UIComponentIndex++;
                 uiCollection.components.Add(UIComp);
                 var componentName = "m_" + transform.name;
                 uiExportElementDic[componentName]     = UIComponentIndex;
                 uiExportTypeElementDic[componentName] = type.ToString();
                 isHandled = true;
                 break;
             }
         }
     }
 }
Exemple #13
0
 SimpleBox panel; //panel
 public TreeView(int width, int height)
     : base(width, height)
 {
     //panel for listview items
     this.panel = new SimpleBox(width, height);
     panel.ContentLayoutKind = BoxContentLayoutKind.VerticalStack;
     panel.BackColor         = Color.LightGray;
     uiList = new UICollection(this);
     uiList.AddUI(panel);
 }
Exemple #14
0
 internal void ClearData()
 {
     UICollection.SetImage(originCupSpr, cupImage);
     drinkInst       = null;
     isDrinkReady    = false;
     buttonText.text = makeStr;
     if (drinkManager.gameObject.active)
     {
         drinkManager.gameObject.SetActive(false);
     }
 }
 /// <summary>
 /// Updates the list.
 /// </summary>
 /// <param name="removed">if set to <c>true</c> the item will be removed.</param>
 /// <param name="item">The item to update.</param>
 public void UpdateList(bool removed, S22.Xmpp.Im.RosterItem item)
 {
     if (removed)
     {
         UICollection.AddOnUI(AllContacts, item);
     }
     else
     {
         UICollection.RemoveOnUI(AllContacts, item);
     }
 }
Exemple #16
0
    internal void ShowNewDrink(DrinkInst drinkInst)
    {
        string  imagePath = "Sprites/Drinks/" + drinkInst.drinkName;
        Vector3 scale     = new Vector3(2.0f, 2.0f, 2.0f);

        UICollection.SetImage(imagePath, drinkImage, scale);
        nameText.text    = drinkInst.tagStr + drinkInst.drinkName;
        qualityText.text = drinkInst.qualityName;
        //新饮料弹出时不允许点击上饮料
        makeDrink.isAllowClick = false;
    }
Exemple #17
0
        Box _panel; //panel

        public TreeView(int width, int height)
            : base(width, height)
        {
            //panel for listview items
            _panel = new Box(width, height);
            _panel.ContentLayoutKind = BoxContentLayoutKind.VerticalStack;
            _panel.BackColor         = Color.LightGray;
            _panel.NeedClipArea      = true;
            _uiList = new UICollection(this);
            _uiList.AddUI(_panel);
        }
        internal void AssignFromLayout(UIGrid p, UIGridTabItem layout, int index)
        {
            parent          = p;
            TabItemContents = layout.TabItemContents.Clone();

            position        = TabItemContents.startMainElement.position;
            initialPosition = TabItemContents.startMainElement.initialPosition;

            size        = TabItemContents.startMainElement.size;
            initialSize = TabItemContents.startMainElement.initialSize;

            gridIndex = index;
        }
 public void ChangeBindItem(CraftItem binditem, Sprite spr)
 {
     bindItem = binditem;
     try {
         //m_image.sprite = spr;
         UICollection.SetImage(bindItem.GetComponent <Image>().sprite, m_image);
         m_image.color = ColorCollection.GetVecClear();
     }
     catch (Exception e) {
         Debug.Log("这里的报错应该是因为Awake事件还未执行造成");
         Debug.Log(e);
     }
 }
 // Start is called before the first frame update
 void Awake()
 {
     //得到自己的必要组件
     m_rect  = GetComponent <RectTransform>();
     m_image = GetComponent <Image>();
     //设置拖动部件初始不可见
     //m_image.sprite = bindItem.GetComponent<Image>().sprite;
     UICollection.SetImage(bindItem.GetComponent <Image>().sprite, m_image);
     m_image.color = ColorCollection.GetVecClear();
     //设置用于拖动逻辑的坐标
     itemOriginPos = m_rect.localPosition;
     dragPos       = itemOriginPos;
 }
Exemple #21
0
    public void PauseButtonOnClick()
    {
        Sprite spr;

        if (pauseImg.sprite == pauseSpr)
        {
            spr = playSpr;
        }
        else
        {
            spr = pauseSpr;
        }
        UICollection.SetImage(spr, pauseImg);
    }
        public override void Reload(UICollection uic, UIElementLayout uiel)
        {
            base.Reload(uic, uiel);
            var temp = uiel as UIGridSaveLayout;

            //foreach (var item in temp.listTabItemLayouts)
            //{
            //    gridItems.Add(new UIGridTabItem());
            //    gridItems.Last().Reload(uic, item, this);
            //}

            if (gridCompleteRender == null || gridCompleteRender.IsDisposed)
            {
                gridCompleteRender = new RenderTarget2D(Game1.graphics.GraphicsDevice, size.X, size.Y);
            }
        }
Exemple #23
0
 private void InitUIComponent()
 {
     element1     = UIElementsList[0].GetComponent <Image>();
     element2     = UIElementsList[1].GetComponentsInChildren <Image>();
     element3Img  = UIElementsList[2].GetComponent <Image>();
     element3Text = UIElementsList[2].GetComponentInChildren <Text>();
     element4     = UIElementsList[3].GetComponentsInChildren <Image>();
     foreach (Image img in element4)
     {
         img.gameObject.GetComponent <RectTransform>().localPosition = new Vector3(0, 0, 0);
     }
     UICollection.SetAlphaClear(element1);
     UICollection.SetAlphaClear(element2);
     UICollection.SetAlphaClear(element3Img);
     UICollection.SetAlphaClear(element3Text);
     UICollection.SetAlphaClear(element4);
 }
 public static void Update(GameTime gt, Point trueMousePos)
 {
     if (uic != null)
     {
         // uic.startMainElement.position = new Point(150,70);
         trueMousePos = (Microsoft.Xna.Framework.Input.Mouse.GetState().Position.ToVector2() / ResolutionUtility.stdScale).ToPoint();
         //  Console.WriteLine(trueMousePos);
         uic.Update(gt, trueMousePos);
     }
     else
     {
         if (Scenes.Editor.MapBuilder.gcDB.gameUICollections.Count >= 1)
         {
             uic = Scenes.Editor.MapBuilder.gcDB.gameUICollections[0].parent;
         }
     }
 }
Exemple #25
0
        public ListView(int width, int height)
            : base(width, height)
        {
            uiList = new UICollection(this);

            var simpleBox = new SimpleBox(width, height);

            simpleBox.ContentLayoutKind   = BoxContentLayoutKind.VerticalStack;
            simpleBox.BackColor           = Color.LightGray;
            simpleBox.MouseDown          += panel_MouseDown;
            simpleBox.MouseDoubleClick   += panel_MouseDoubleClick;
            simpleBox.AcceptKeyboardFocus = true;
            simpleBox.KeyDown            += simpleBox_KeyDown;

            this.panel = simpleBox;
            uiList.AddUI(panel);
        }
        /// <summary>
        /// Gets a user or create it based on its JID.
        /// </summary>
        /// <param name="jid">The jid.</param>
        /// <returns>A user in the Contact List.</returns>
        public Models.UserViewModel GetUser(Jid jid)
        {
            foreach (var contact in AllContacts)
            {
                if (jid.GetBareJid() == contact.Jid.GetBareJid())
                {
                    return(contact);
                }
            }

            // Create a temporary contact if a non-roster user creates a conversation.
            // Allows administrator to talk to anyone.
            // Change ctor in user
            var tempContact = new Models.UserViewModel(jid, "");

            UICollection.AddOnUI(AllContacts, tempContact);

            return(tempContact);
        }
Exemple #27
0
    public void ChangeContent(int marknum)
    {
        switch (marknum)
        {
        case 0:
            m_text.gameObject.SetActive(true);
            m_image.gameObject.SetActive(false);
            m_text.text = strArr[marknum];
            FadeInOrOut(true);
            break;

        case 1:
            m_text.gameObject.SetActive(true);
            m_image.gameObject.SetActive(false);
            m_text.text = strArr[marknum];
            FadeInOrOut(true);
            break;

        case 2:
            m_text.gameObject.SetActive(false);
            m_image.gameObject.SetActive(true);
            UICollection.SetImage(sprPlayBall, m_image, new Vector3(3, 3, 1));
            FadeInOrOut(true);
            break;

        case 3:
            m_text.gameObject.SetActive(true);
            m_image.gameObject.SetActive(false);
            m_text.text = strArr[marknum];
            FadeInOrOut(true);
            break;

        case 4:
            m_text.gameObject.SetActive(true);
            m_image.gameObject.SetActive(false);
            m_text.text = strArr[marknum];
            FadeInOrOut(true);
            break;
        }
    }
Exemple #28
0
    public void ChangeDisc(CdBoxControl control)
    {
        //切换歌曲列表
        track = control.track;
        musicList.Clear();
        foreach (CdData.OneMusic music in track.musicList)
        {
            AudioClip clip = Resources.Load <AudioClip>("Musics/" + music.musicName);
            musicList.Add(clip);
        }

        Image cdSmallImage = control.cdSmallImage;

        StartCoroutine(DelayToInvoke.DelayToInvokeDo(() => {
            UICollection.MoveToPos(cdSmallImage.gameObject, control.MoveTargetPos, 0.2f);
        }, 0.0f));
        StartCoroutine(DelayToInvoke.DelayToInvokeDo(() => {
            UICollection.AlphaFadeImg(cdSmallImage.gameObject, false);
        }, 0.2f));
        StartCoroutine(DelayToInvoke.DelayToInvokeDo(() => {
            NeedleOut();
            UICollection.AlphaFadeImg(discImage.gameObject, false);
            DiscStopRotating();
        }, 1f));
        StartCoroutine(DelayToInvoke.DelayToInvokeDo(() => {
            NeedleIn(5.0f);
            UICollection.SetImage(control.cdSmallImage.sprite, discImage);
            UICollection.AlphaFadeImg(discImage.gameObject, true);
            control.isChanging = false;
            control.isSelected = true;
        }, 2f));
        StartCoroutine(DelayToInvoke.DelayToInvokeDo(() => {
            DiscStartRotating();
            audioSource.Play();
            musicNameText.text = audioSource.clip.name;
            ChangeToPauseSpr();
            UICollection.SetImage(pauseBtn.upSpr, pauseBtn.gameObject.GetComponent <Image>());
        }, 2.5f));
    }
Exemple #29
0
        private void VerifyBreadcrumbBarItemsContain(UICollection <UIObject> breadcrumbItems, string[] expectedItemValues, bool firstItemIsCurrentItem = false, bool isEllipsisVisible = false)
        {
            // WARNING: this method clicks on each breadcrumb so once the verification has finished,
            // only the ellipsis item and 'Root' should exist

            // As recycled breadcrumbs are not deleted, then we compare that the breadcrumb count is always bigger
            // than the expected values count
            var ellipsisPresentCount = isEllipsisVisible ? 1 : 0;

            Verify.IsTrue(breadcrumbItems.Count - ellipsisPresentCount >= expectedItemValues.Length,
                          "The expected values count should at least be one less than the BreadcrumbBarItems count");

            bool mustVerifyItemAsLastItem = firstItemIsCurrentItem;

            // To verify the existence of the expected nodes we click on each of them and verify agains the strings
            // in LastClickedItemIndex and LastClickedItem textboxes.
            for (int i = expectedItemValues.Length - 1; i >= 0; --i)
            {
                var currentItem = breadcrumbItems[i + ellipsisPresentCount];
                Verify.IsNotNull(currentItem, "Current BreadcrumbBarItem should not be null");

                var currentBreadcrumbBarItem = ConvertTo <BreadcrumbBarItem>(currentItem);
                Verify.IsNotNull(currentBreadcrumbBarItem, "UIElement should be a BreadcrumbBarItem");

                currentBreadcrumbBarItem.Click();

                if (mustVerifyItemAsLastItem)
                {
                    Verify.AreEqual(expectedItemValues[i], GetCurrentItemText(currentBreadcrumbBarItem));
                    mustVerifyItemAsLastItem = false;
                }
                else
                {
                    VerifyLastClickedItemIndexIs(i);
                    VerifyLastClickedItemIs(expectedItemValues[i]);
                }
            }
        }
Exemple #30
0
        public void AddChild(UIElement ui)
        {
            if (this.uiList == null)
            {
                this.uiList = new UICollection(this);
            }

            needContentLayout = true;
            this.uiList.AddUI(ui);
            if (this.HasReadyRenderElement)
            {
                primElement.AddChild(ui);
                if (this.panelLayoutKind != BoxContentLayoutKind.Absolute)
                {
                    this.InvalidateLayout();
                }
            }

            if (ui.NeedContentLayout)
            {
                ui.InvalidateLayout();
            }
        }
Exemple #31
0
        public void AddChild(UIElement ui)
        {
            if (this.uiList == null)
            {
                this.uiList = new UICollection(this);
            }

            needContentLayout = true;
            this.uiList.AddUI(ui);
            if (this.HasReadyRenderElement)
            {
                primElement.AddChild(ui);
                if (this.panelLayoutKind != BoxContentLayoutKind.Absolute)
                {
                    this.InvalidateLayout();
                }
            }

            if (ui.NeedContentLayout)
            {
                ui.InvalidateLayout();
            }
        }