示例#1
0
    static int SetText(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 2);
        MultiLabel obj  = (MultiLabel)LuaScriptMgr.GetUnityObjectSelf(L, 1, "MultiLabel");
        string     arg0 = LuaScriptMgr.GetLuaString(L, 2);

        obj.SetText(arg0);
        return(0);
    }
示例#2
0
    public void RefreshServerList(GameObject go)
    {
        GameObject childGo = null;

        for (int i = 0; i < leftGrid.transform.childCount; i++)
        {
            childGo = leftGrid.transform.GetChild(i).gameObject;
            if (go == childGo)
            {
                childGo.transform.FindChild("Sele").GetComponent <UISprite>().spriteName = "login_yellow5";
                while (rightGrid.transform.childCount > 0)
                {
                    NGUITools.Destroy(rightGrid.transform.GetChild(0).gameObject);
                }
                for (int j = 0; j < eachGroupList[i].Count; j++)
                {
                    GameObject serverItem = CommonFunction.InstantiateObject("Prefab/GUI/ServerItem", rightGrid.transform);
                    GameObject level      = serverItem.transform.FindChild("Level").gameObject;
                    MultiLabel levelText  = level.transform.FindChild("Text").GetComponent <MultiLabel>();
                    MultiLabel serverID   = serverItem.transform.FindChild("Server").GetComponent <MultiLabel>();
                    MultiLabel serverName = serverItem.transform.FindChild("Name").GetComponent <MultiLabel>();
                    UISprite   serverIcon = serverItem.transform.FindChild("Icon").GetComponent <UISprite>();
                    UISprite   backShade  = serverItem.transform.FindChild("BackShade").GetComponent <UISprite>();
                    serverItem.name = eachGroupList[i][j].server_name;
                    serverID.SetText(string.Format(CommonFunction.GetConstString("LOGIN_SEVER_AREA"), eachGroupList[i][j].display_server_id));
                    serverName.SetText(eachGroupList[i][j].server_name);
                    if (eachGroupList[i][j].name == null || eachGroupList[i][j].name == "")
                    {
                        NGUITools.SetActive(level, false);
                    }
                    else
                    {
                        levelText.SetText(CommonFunction.GetConstString("UI_HALL_LEVEL_1") + eachGroupList[i][j].level.ToString());
                        if (eachGroupList[i][j].server_name == LoginIDManager.GetPlatServerName())
                        {
                            NGUITools.SetActive(backShade.gameObject, true);
                            if (eachGroupList[i][j].level != LoginIDManager.GetLastLevel())
                            {
                                lastLevel.text = CommonFunction.GetConstString("UI_HALL_LEVEL_1") + eachGroupList[i][j].level.ToString();
                            }
                        }
                    }
                    uint state = eachGroupList[i][j].load;
                    if (state == (uint)ServerState.SS_BUSY)
                    {
                        serverIcon.spriteName = "login_login_Orange";
                    }
                    else if (state == (uint)ServerState.SS_CLOSE)
                    {
                        serverIcon.spriteName = "login_login_Gray";
                    }
                    else if (state == (uint)ServerState.SS_FULL)
                    {
                        serverIcon.spriteName = "login_login_Red";
                    }
                    else if (state == (uint)ServerState.SS_IDLE)
                    {
                        serverIcon.spriteName = "login_login_Green";
                    }
                    if (eachGroupList[i][j].server_name == LoginIDManager.GetPlatServerName())
                    {
                        lastLoad.spriteName = serverIcon.spriteName;
                    }

                    UIEventListener.Get(serverItem).onClick = OnChooseServer;
                }
            }
        }
        rightGrid.repositionNow = true;
        rightGrid.Reposition();
    }
示例#3
0
    public void DisplayServerList(List <ServerListInfo> serverList)
    {
        if (loginServerPopup != null || goUI == null)
        {
            //NGUITools.SetActive(loginServerPopup.gameObject, true);
            return;
        }

        loginServerPopup = CommonFunction.InstantiateObject("Prefab/GUI/LoginServerPopup", goUI.transform);
        popupAnimator    = loginServerPopup.GetComponent <Animator>();
        leftGrid         = loginServerPopup.transform.FindChild("Window/Left/Scroll/Grid").GetComponent <UIGrid>();
        rightGrid        = loginServerPopup.transform.FindChild("Window/Right/Scroll/Grid").GetComponent <UIGrid>();
        lastServerArea   = loginServerPopup.transform.FindChild("Window/Right/Up/Server").GetComponent <UILabel>();
        lastServerName   = loginServerPopup.transform.FindChild("Window/Right/Up/Name").GetComponent <UILabel>();
        lastLevel        = loginServerPopup.transform.FindChild("Window/Right/Up/Lever").GetComponent <UILabel>();
        lastLoad         = loginServerPopup.transform.FindChild("Window/Right/Up/Icon").GetComponent <UISprite>();
        closeBtn         = loginServerPopup.transform.FindChild("Window/ButtonClose/ButtonClose").GetComponent <UIButton>();
        UIEventListener.Get(closeBtn.gameObject).onClick = (go)
                                                           =>
        {
            popupAnimator.enabled = true;
            popupAnimator.SetBool("Close", true);
        };
        SetLastLoginInfo(serverList);

        eachGroupList.Clear();
        int  serverCount = serverList.Count;
        int  nameIndex   = (serverCount / 4) * 4 <= serverCount ? serverCount / 4 + 1 : serverCount / 4;
        int  itemIndex   = 0;
        bool isShowIcon  = false;

        do
        {
            List <ServerListInfo> servers = new List <ServerListInfo>();
            int count = serverCount % 4;
            if (count > 0)
            {
                for (int i = serverCount - 1; i >= serverCount - count; i--)
                {
                    servers.Add(serverList[i]);
                    if (serverList[i].name != null && serverList[i].name != "")
                    {
                        isShowIcon = true;
                    }
                }
                servers.Reverse();
                serverCount = serverCount - count;
            }
            else if (count == 0 && serverCount > 0)
            {
                for (int i = serverCount - 1; i >= serverCount - 4; i--)
                {
                    servers.Add(serverList[i]);
                    if (serverList[i].name != null && serverList[i].name != "")
                    {
                        isShowIcon = true;
                    }
                }
                servers.Reverse();
                serverCount = serverCount - 4;
            }

            eachGroupList[itemIndex] = servers;
            GameObject serverBtn = CommonFunction.InstantiateObject("Prefab/GUI/ServerButton", leftGrid.transform);
            MultiLabel title     = serverBtn.transform.FindChild("Title").GetComponent <MultiLabel>();
            GameObject icon      = serverBtn.transform.FindChild("Icon").gameObject;
            serverBtn.transform.name = nameIndex.ToString();
            int max = nameIndex * 4 > serverList.Count ? serverList.Count : nameIndex * 4;
            title.SetText(string.Format(CommonFunction.GetConstString("LOGIN_SEVER_AREA"), string.Format("{0} — {1}", (nameIndex - 1) * 4 + 1, max)));
            icon.SetActive(isShowIcon);

            UIEventListener.Get(serverBtn).onClick = RefreshServerList;
            nameIndex--;
            itemIndex++;
            isShowIcon = false;
        } while (serverCount > 0);

        leftGrid.repositionNow = true;
        leftGrid.Reposition();
        leftGrid.transform.GetChild(0).GetComponent <UIToggle>().startsActive = true;
        RefreshServerList(leftGrid.transform.GetChild(0).gameObject);
    }