public override void Init()
    {
        base.Init();
        this.Create(Config.VIEW_LOGINCARD, false);

        userModel = ModelManager.inst.userModel;
        chatModel = ModelManager.inst.chatModel;
        //
        this.GetChild("n17").asTextField.text = Tools.GetMessageById("25501");
        //
        listData = new List <object[]> ();
        Dictionary <string, object> data = (Dictionary <string, object>)userModel.records ["guild_support_logs"];

        this.GetChild("n7").text = Tools.GetMessageById("25502");
        this.GetChild("n9").text = Tools.GetMessageById("25503");

        card = this.GetChild("n8").asCom as ComCard;
        list = this.GetChild("n12").asList;
//		bar = this.GetChild ("n4").asCom as ComProgressBar;
//		bar.skin = ComProgressBar.BAR7;

        int count = 0;
        Dictionary <string, object> users = (Dictionary <string, object>)data ["data"];

        object[] obj;
        foreach (string n in users.Keys)
        {
            obj = new object[3];
            object[] ob = (object[])users [n];
            obj [0] = n;
            obj [1] = ob [0];
            obj [2] = ob [1];
            listData.Add(obj);
            count += Convert.ToInt32(obj [2]);
        }

        int max = chatModel.GetCardRequestCount(data ["cid"].ToString(), userModel.effort_lv);

//		bar.value = count;
//		bar.max = max;
        this.GetChild("n19").asTextField.text = count + "/" + max;
        CardVo vo = DataManager.inst.GetCardVo(data ["cid"].ToString());

        card.SetData(vo.id, 1, 1);
        card.SetText(Tools.GetMessageById(vo.name));

        this.GetChild("n11").text = vo.exp + "";       // + "/" + vo.maxExp;
        this.GetChild("n18").text = "/" + vo.maxExp;

        list.itemRenderer = Item_Render;
        list.SetVirtual();
        list.numItems = listData.Count;
    }
示例#2
0
    private void List_Render(int index, GObject item)
    {
//		Debug.LogError("Render Index:" + item.parent.width);
        GComponent go = item.asCom;

        go.name = index + "";
        go.RemoveChildren();
//        go.x = GRoot.inst.width/9;
//		go.x = item.parent.width - go.width;
        Dictionary <string, object> data = (Dictionary <string, object>)ld [index];
        GComponent     it;
        GButton        head;
        GTextField     text;
        GButton        btn1;
        GButton        btn2;
        ComProgressBar bar;

        if (data ["ctype"].ToString() == "chat")
        {
            GImage bg;
            it = Tools.GetComponent(Config.ITEM_CHAT).asCom;
            Controller c1 = it.GetController("c1");
            if (data ["uid"].ToString() == userModel.uid)
            {
                c1.selectedIndex = 1;
                it = it.GetChild("n1").asCom;
            }
            else
            {
                c1.selectedIndex = 0;
                it = it.GetChild("n0").asCom;
            }
            head = it.GetChild("n0").asButton;
            text = it.GetChild("n2").asTextField;
            bg   = it.GetChild("n5").asImage;


            it.GetChild("n1").text = ModelUser.GetUname(data ["uid"], data ["uname"]);
            Dictionary <string, object> use = data ["head"] as Dictionary <string, object>;
            Tools.SetLoaderButtonUrl(head, ModelUser.GetHeadUrl(use ["use"].ToString()));
            text.text = data ["chat"].ToString();
            it.GetChild("n4").text = ((DateTime)data ["time"]).ToString("HH:mm:ss");
            if (text.textHeight > 29)
            {
                float c = text.textHeight - 29;
                bg.height           = bg.height + c;
                go.height           = (115 - 29) + text.textHeight;
                it.GetChild("n4").y = it.GetChild("n4").y + c;
            }
            else
            {
                go.height           = 115;
                it.GetChild("n4").y = 90;
            }
            head.onClick.Add(() =>
            {
                this.DispatchGlobalEvent(new MainEvent(MainEvent.SHOW_USER, new object[] {
                    null,
                    data ["uid"].ToString(),
                    roleModel.tab_CurSelect1,
                    roleModel.tab_CurSelect2,
                    roleModel.tab_CurSelect3
                }));
            });
            go.AddChild(it);
            chatModel.IsEffect(data, go);
        }
        else if (data ["ctype"].ToString() == "guild")
        {
            GTextField rank;
            it   = Tools.GetComponent(Config.ITEM_GUILD).asCom;
            head = it.GetChild("n3").asButton;
            rank = it.GetChild("n6").asTextField;
            btn1 = it.GetChild("n0").asButton;
            btn2 = it.GetChild("n7").asButton;

            it.GetChild("n4").text = ModelUser.GetUname(data ["uid"], data ["uname"]);
            it.GetChild("n2").text = Tools.GetMessageById("22014");
            Dictionary <string, object> use = data ["head"] as Dictionary <string, object>;
            head.GetChild("n2").text = data ["lv"].ToString();
            Tools.SetLoaderButtonUrl(head.GetChild("n0").asButton, ModelUser.GetHeadUrl(use ["use"].ToString()));
            it.GetChild("n9").text = ((DateTime)data ["time"]).ToString("HH:mm:ss");
            rank.text = Tools.GetMessageById("22002", new string[] { data ["rank_score"].ToString() });
            go.height = 280;
            go.AddChild(it);
            chatModel.IsEffect(data, go);
            btn1.onClick.Add(() =>
            {
                Dictionary <string, object> d1 = new Dictionary <string, object> ();
                d1 ["uid"]  = data ["uid"].ToString();
                d1 ["flag"] = 1;
                NetHttp.inst.Send(NetBase.HTTP_GUILD_JOIN, d1, (VoHttp vo) =>
                {
//					Log.debug (vo.data.ToString ());
                    if (!Convert.ToBoolean(vo.data))
                    {
                        chatModel.RemoveChat("guild", data ["uid"].ToString());
                        ViewManager.inst.ShowText(Tools.GetMessageById("22029"));
                        list.RemoveChildAt(index);
                    }
                });
            });
            btn2.onClick.Add(() =>
            {
                Dictionary <string, object> d1 = new Dictionary <string, object> ();
                d1 ["uid"]  = data ["uid"].ToString();
                d1 ["flag"] = 2;
                NetHttp.inst.Send(NetBase.HTTP_GUILD_JOIN, d1, null);
            });
        }
        else if (data ["ctype"].ToString() == "guild_join")
        {
            it   = Tools.GetComponent(Config.ITEM_TEXT).asCom;
            text = it.GetChild("n0").asTextField;
            Dictionary <string, object> user1 = (Dictionary <string, object>)data ["user1"];
            Dictionary <string, object> user2 = (Dictionary <string, object>)data ["user2"];
            string name2 = ModelUser.GetUname(user2 ["uid"], user2 ["uname"]);
            if (user1 == null)
            {
                text.text = Tools.GetMessageById("22028", new string[] { name2 });
            }
            else
            {
                string name1 = ModelUser.GetUname(user1 ["uid"], user1 ["uname"]);
                if (data ["flag"].ToString() == "1")
                {
                    text.text = Tools.GetMessageById("22004", new string[] { name1, name2 });
                }
                else
                {
                    text.text = Tools.GetMessageById("22005", new string[] { name1, name2 });
                }
            }
            go.height = 70f;
//			try{
            go.AddChild(it);
//			}catch(Exception ee){
//			}
            chatModel.IsEffect(data, go);
        }
        else if (data ["ctype"].ToString() == "guild_modify")
        {
            it   = Tools.GetComponent(Config.ITEM_TEXT).asCom;
            text = it.GetChild("n0").asTextField;
            if (data.ContainsKey("user"))
            {
                Dictionary <string, object> user = (Dictionary <string, object>)data ["user"];
                string name0 = ModelUser.GetUname(user ["uid"], user ["uname"]);
                text.text = Tools.GetMessageById("22030", new string[] { name0 });
            }
            else
            {
                Dictionary <string, object> user1 = (Dictionary <string, object>)data ["user1"];
                Dictionary <string, object> user2 = (Dictionary <string, object>)data ["user2"];
                string name1   = ModelUser.GetUname(user1 ["uid"], user1 ["uname"]);
                string name2   = ModelUser.GetUname(user2 ["uid"], user2 ["uname"]);
                int    num     = Convert.ToInt32(data ["num"]);
                int    old_num = Convert.ToInt32(data ["old_num"]);
                if (num == -1)
                {
                    text.text = Tools.GetMessageById("22008", new string[] { name1, name2 });
                }
                else if (num == 0)
                {
                    text.text = Tools.GetMessageById("22009", new string[] { name1, name2 });
                }
                else if (num < old_num)
                {
                    text.text = Tools.GetMessageById("22006", new string[] { name1, name2 });
                }
                else
                {
                    text.text = Tools.GetMessageById("22007", new string[] { name1, name2 });
                }
            }
            go.height = 70;
            go.AddChild(it);
            chatModel.IsEffect(data, go);
        }
        else if (data ["ctype"].ToString() == "send_guild_redbag")
        {
//			go.name = go.name+"_isRed";
            it = Tools.GetComponent(Config.ITEM_RED1).asCom;
            GLoader load = it.GetChild("n6").asLoader;
            load.url = data ["type"].ToString() == "0" ? Tools.GetResourceUrl("Image2:n_icon_bthb2") : Tools.GetResourceUrl("Image2:n_icon_bthb1");
//			it.GetChild ("n1").text = ModelUser.GetUname (data ["uid"], data ["uname"]);
            string ti = Tools.GetMessageById("22017", new string[] { ModelUser.GetUname(data ["uid"], data ["uname"]) });
            ti = Tools.GetMessageColor(ti, new string[] { "dc8100" });
            it.GetChild("n2").text     = ti;
            it.GetChild("n4").text     = ((DateTime)data ["time"]).ToString("HH:mm:ss");
            it.GetChild("n11").text    = Tools.GetMessageById("22011");
            it.GetChild("n12").visible = true;
            if (Convert.ToBoolean(data ["is_my_grab"]))
            {
                it.GetChild("n12").text = Tools.GetMessageById("22034");
            }
            else if (Convert.ToBoolean(data ["is_grab_all"]))
            {
                it.GetChild("n12").text = Tools.GetMessageById("22046");
            }
            else
            {
                it.GetChild("n12").visible = false;
            }
            load.onClick.Add(() =>
            {
                if (!chatModel.isSendRedBagOutTime(data))
                {
                    ViewManager.inst.ShowText(Tools.GetMessageById("22039"));
                    return;
                }
                Dictionary <string, object> d = new Dictionary <string, object> ();
                d ["redbag_id"] = data ["id"].ToString();
                NetHttp.inst.Send(NetBase.HTTP_GRABGUILDREDBAG, d, (VoHttp vo) =>
                {
                    Dictionary <string, object> da   = (Dictionary <string, object>)vo.data;
                    Dictionary <string, object> gift = (Dictionary <string, object>)da ["gift"];
                    chatModel.grab_List = (object[])da ["grab_list"];
                    chatModel.card_List = (object[])da ["card_list"];
                    chatModel.grab_Type = Convert.ToInt32(data ["type"]);
                    if (gift == null)
                    {
                        if (!Convert.ToBoolean(data ["is_my_grab"]))
                        {
                            data ["is_avable"]  = false;
                            data ["is_my_grab"] = true;
                            chatModel.UpdateRedBagData(data);
                            chatModel.Remove_RedCount();
                            this.List_Render(index, item);
                        }
                        ViewManager.inst.ShowView <MediatorRed2> ();
                    }
                    else
                    {
                        data ["is_avable"]  = false;
                        data ["is_my_grab"] = true;
                        chatModel.UpdateRedBagData(data);
                        chatModel.Remove_RedCount();
                        this.List_Render(index, item);
                        chatModel.isRedbagGift = true;
                        //ViewManager.inst.ShowIcon (gift, () =>
                        //{
                        int gold = userModel.gold;
                        userModel.UpdateData(vo.data);
                        int gold2 = gift.ContainsKey("gold") ? Convert.ToInt32(gift["gold"]) : 0;
                        if (gold + gold2 != userModel.gold)
                        {
                            ViewManager.inst.ShowText(Tools.GetMessageById("33212"));
                        }
                        userModel.records ["guild_redbag_log"] = da ["guild_redbag_log"];
                        ViewManager.inst.ShowView <MediatorRed2> ();
//						});
//						ViewManager.inst.ShowReward (gift);
                    }
                });
            });
            go.height = 280;
            go.AddChild(it);
            chatModel.IsEffect(data, go);
        }
        else if (data ["ctype"].ToString() == "require_guild_support")
        {
//			go.name = go.name+"_isRed";
            it   = Tools.GetComponent(Config.ITEM_REQUEST).asCom;
            text = it.GetChild("n2").asTextField;
            bar  = it.GetChild("n9") as ComProgressBar;
            bar.SetTextSize(28);
            bar.offsetY = 8;
            ComCard ci = it.GetChild("n8") as ComCard;
            btn1      = it.GetChild("n5").asButton;
            btn1.text = Tools.GetMessageById("22049");
            bar.skin  = ComProgressBar.BAR7;

            CardVo vo = DataManager.inst.GetCardVo(data ["cid"].ToString());
            text.text = Tools.GetMessageById("22019");
            it.GetChild("n16").text = Tools.GetMessageById("22012");
            it.GetChild("n10").text = Tools.GetMessageById("22033");
            it.GetChild("n18").text = Tools.GetMessageColor("[0]" + vo.exp + "[/0]/" + vo.maxExp, new string[] { "a6fb30" });
            it.GetChild("n1").text  = ModelUser.GetUname(data ["uid"], data ["uname"]);
            it.GetChild("n4").text  = ((DateTime)data ["time"]).ToString("HH:mm:ss");
            Dictionary <string, object> da = (Dictionary <string, object>)data ["data"];
            int count = 0;
            foreach (string n in da.Keys)
            {
                count += Convert.ToInt32(da [n]);
            }
            int max = chatModel.GetCardRequestCount(data ["cid"].ToString(), Convert.ToInt32(data ["effort_lv"]));
            bar.value = count;
            bar.max   = max;
            it.GetChild("n20").asTextField.text = bar.text;
            ci.SetData(vo.id, 1, 1);
            ci.SetText(Tools.GetMessageById(vo.name));
            if (data ["uid"].ToString() == userModel.uid || vo.exp == 0 || !chatModel.IsSendGiveCard() ||
                !chatModel.IsSendCardOver(data) || !chatModel.isSendSupportOutTime(data) || count >= max)
            {
                go.name     = go.name + "_isExc";
                btn1.grayed = true;
            }
            btn1.onClick.Add(() =>
            {
                if (isRequestEffect)
                {
                    return;
                }
                if (count >= max)
                {
                    ViewManager.inst.ShowText(Tools.GetMessageById("22038"));
                    return;
                }
                else if (data ["uid"].ToString() == userModel.uid)
                {
                    ViewManager.inst.ShowText(Tools.GetMessageById("22035"));
                    return;
                }
                else if (vo.exp == 0)
                {
                    ViewManager.inst.ShowText(Tools.GetMessageById("22036"));
                    return;
                }
                else if (!chatModel.IsSendGiveCard())
                {
                    ViewManager.inst.ShowText(Tools.GetMessageById("22022"));
                    return;
                }
                else if (!chatModel.IsSendCardOver(data))
                {
                    ViewManager.inst.ShowText(Tools.GetMessageById("22024"));
                    return;
                }
                else if (!chatModel.isSendSupportOutTime(data))
                {
                    ViewManager.inst.ShowText(Tools.GetMessageById("22037"));
                    return;
                }
                Dictionary <string, object> d = new Dictionary <string, object> ();
                d ["support_id"] = data ["id"].ToString();
                NetHttp.inst.Send(NetBase.HTPP_SENDGUILDSUPPORT, d, (VoHttp v) =>
                {
                    chatModel.Remove_RedCount();
                    isRequestEffect = true;
                    ViewManager.inst.ShowIcon(userModel.GetReward(v.data), () =>
                    {
                        userModel.UpdateData(v.data);
                        chatModel.UpdateGuildSupport(data);
                        DispatchManager.inst.Dispatch(new MainEvent(MainEvent.CHAT_SENDGUILDSUPPORT));
                        isRequestEffect = false;
                    });
                });
            });
            go.height = 300;
            go.AddChild(it);
            chatModel.IsEffect(data, go);
        }
        else if (data ["ctype"].ToString() == "guild_fight_share")
        {
            it = Tools.GetComponent(Config.ITEM_SHARE).asCom;
            object[] fight = (object[])data ["fight_data"];
//			it.GetChild ("n4").text = ModelUser.GetUname (data ["uid"], data ["uname"]);
            string na = "[0]" + ModelUser.GetUname(data ["uid"], data ["uname"]) + "[/0]";
            na = Tools.GetMessageColor(na, new string[] { "dc8100" });
            if (fight [0].ToString() == "1")
            {
                it.GetChild("n2").text = na + Tools.GetMessageById("22042");
            }
            else
            {
                it.GetChild("n2").text = na + Tools.GetMessageById("22043");
            }
            it.GetChild("n6").text = data ["chat"].ToString();
            it.GetChild("n9").text = ((DateTime)data ["time"]).ToString("HH:mm:ss");
            it.GetChild("n0").asButton.onClick.Add(() =>
            {
                this.DispatchGlobalEventWith(MainEvent.SHOW_FIGHTDETAIL, data);
            });
            go.height = 255;
            go.AddChild(it);
            chatModel.IsEffect(data, go);
        }
//		go.Center ();
    }