Пример #1
0
        public float update(GameObject obj_item, bool fix = true)
        {
            obj_item.transform.FindChild("icon").GetComponent <UISprite>().spriteName = icon;
            UILabel user_name = obj_item.transform.FindChild("user").GetComponent <UILabel>();

            if (!tar.Equals("null"))
            {
                user_name.text = userName + " [0000ef]回复[-] " + tar;
            }
            else
            {
                user_name.text = userName;
            }
            obj_item.transform.FindChild("time").GetComponent <UILabel>().text = time;
            UILabel content_label = obj_item.transform.FindChild("content").GetComponent <UILabel>();

            content_label.text = context;
            int len = MyUtilTools.computeRow(content_label);

            content_label.height = len * (content_label.fontSize + content_label.spacingY);
            float a = (len * content_label.fontSize + (len - 1) * content_label.spacingY) / 2;

            content_label.transform.localPosition = new Vector3(60, -70 - a, 0);
            if (len % 2 != 0)
            {
                a += content_label.fontSize / 2;
            }
            obj_item.transform.FindChild("event").localPosition = new Vector3(0, -180 - a, 0);
            return(fix ? (290 + a) : 200);
        }
Пример #2
0
    void gotoDetailFrame(MainData.EmailBody email)
    {
        if (email.isNew == 0)
        {//更新是否阅读标志
            ByteBuffer buffer = ByteBuffer.Allocate(1024);
            buffer.skip(4);
            buffer.WriteString("LookEmail");
            buffer.WriteLong(MainData.instance.user.id);//编号
            buffer.WriteLong(email.id);
            NetUtil.getInstance.SendMessage(buffer, false);
        }
        transform.FindChild("list").gameObject.SetActive(false);
        Transform deatail_trans = transform.FindChild("detail");

        deatail_trans.gameObject.SetActive(true);
        needBacks.Add(new EventDelegate(backFromDetail));
        UILabel label_sender = deatail_trans.FindChild("sender").GetComponent <UILabel>();

        label_sender.text = email.senderName;
        UILabel label_title = deatail_trans.FindChild("title").GetComponent <UILabel>();

        label_title.text = email.theme;
        UILabel label_content = deatail_trans.FindChild("content").GetComponent <UILabel>();

        label_content.text = email.content;
        int   row   = MyUtilTools.computeRow(label_content);
        float off_y = row * (label_content.fontSize + label_content.spacingX) / 2;

        label_content.transform.localPosition = new Vector3(0, 290 - off_y, 0);
        UIButton      delete_button = deatail_trans.FindChild("delete").GetComponent <UIButton>();
        EventDelegate deleteEvent   = new EventDelegate(this, "delete");

        deleteEvent.parameters[0]     = new EventDelegate.Parameter();
        deleteEvent.parameters[0].obj = email;
        delete_button.onClick.Clear();
        delete_button.onClick.Add(deleteEvent);
        UIButton      revert_button = deatail_trans.FindChild("revert").GetComponent <UIButton>();
        EventDelegate revertEvent   = new EventDelegate(this, "revertEmail");

        revertEvent.parameters[0]     = new EventDelegate.Parameter();
        revertEvent.parameters[0].obj = email;
        revert_button.onClick.Clear();
        revert_button.onClick.Add(revertEvent);
    }
Пример #3
0
    void goToDetail(TimeLine timeLine)
    {
        needshow[0].transform.FindChild("list").gameObject.SetActive(false);
        Transform detail_trans = needshow[0].transform.FindChild("detail");

        detail_trans.gameObject.SetActive(true);
        callback = new EventDelegate(backFromDetail);
        if (detail_container == null)
        {
            detail_container = detail_trans.FindChild("body").FindChild("container");
        }
        MyUtilTools.clearChild(detail_container);
        detail_container.parent.GetComponent <UIPanel>().clipOffset = Vector2.zero;
        detail_container.parent.localPosition = new Vector3(0, 0, 0);
        GameObject newObj    = new GameObject();
        GameObject title_obj = NGUITools.AddChild(detail_container.gameObject, newObj);

        title_obj.transform.localPosition = new Vector3(0, 520, 0);
        title_obj.name = "title";
        UILabel title_label = title_obj.AddComponent <UILabel>();

        title_label.trueTypeFont = labelFont;
        title_label.fontSize     = 50;
        title_label.text         = timeLine.title;
        title_label.width        = 800;
        title_label.height       = 60;
        title_label.spacingX     = 5;
        title_label.spacingY     = 5;
        title_label.maxLineCount = 100;
        title_label.color        = Color.black;
        title_label.depth        = 2;
        float starty = 450;

        for (int i = 0; i < timeLine.contents.Count; i++)
        {
            GameObject  sun     = null;
            TimeContent content = timeLine.contents[i];
            int         height  = 0;
            float       offset  = 0;
            if (content.type == 0)
            {
                sun      = NGUITools.AddChild(detail_container.gameObject, title_obj);
                sun.name = "content" + i;
                UILabel sun_label = sun.GetComponent <UILabel>();
                sun_label.fontSize = 40;
                sun_label.width    = 750;
                sun_label.height   = 10000;
                sun_label.text     = content.str_value;
                int row   = MyUtilTools.computeRow(sun_label);
                int total = row * (sun_label.fontSize + title_label.spacingY);
                sun_label.height = total;
                height           = total;
                offset           = total / 2;
            }
            else
            {
                sun      = NGUITools.AddChild(detail_container.gameObject, newObj);
                sun.name = "content" + i;
                UITexture texture = sun.AddComponent <UITexture>();
                texture.width  = 512;
                texture.height = 512;
                JustRun.Instance.loadPic(content.str_value, texture);
                height = texture.height + 20;
                offset = texture.height / 2;
            }
            starty -= height;
            sun.transform.localPosition = new Vector3(0, starty + offset, 0);
        }
        Destroy(newObj);
    }
Пример #4
0
    public void insterItem(GameObject obj_item, bool fix = true)
    {
        GameObject obj    = obj_item.transform.FindChild("icon").gameObject;
        UISprite   sprite = obj_item.transform.FindChild("icon").GetComponent <UISprite>();

        sprite.spriteName = icon;
        UILabel label = obj_item.transform.FindChild("user").GetComponent <UILabel>();

        label.text = userName + " ";
        label      = obj_item.transform.FindChild("time").GetComponent <UILabel>();
        label.text = time;
        Transform content_trans = obj_item.transform.FindChild("content");

        label      = content_trans.FindChild("id").FindChild("value").GetComponent <UILabel>();
        label.text = id + "";
        label      = content_trans.FindChild("tip").FindChild("value").GetComponent <UILabel>();
        label.text = seller ? "出售" : "求购";
        label      = content_trans.FindChild("type").FindChild("value").GetComponent <UILabel>();
        label.text = typeStr;
        label      = content_trans.FindChild("help").FindChild("value").GetComponent <UILabel>();
        label.text = helpFlag ? "平台中介" : "买方先款";
        if (typeStr.Equals("入库"))
        {
            label          = content_trans.FindChild("bourse").GetComponent <UILabel>();
            label.text     = "文 交 所";
            label.spacingX = 4;
        }
        else
        {
            label          = content_trans.FindChild("bourse").GetComponent <UILabel>();
            label.text     = "交易城市";
            label.spacingX = 1;
        }
        label = content_trans.FindChild("bourse").FindChild("value").GetComponent <UILabel>();
        string[] ss = bourse.Split(","[0]);
        label.text = ss[1];
        label      = content_trans.FindChild("title").FindChild("value").GetComponent <UILabel>();
        label.text = stampName;
        label      = content_trans.FindChild("price").FindChild("value").GetComponent <UILabel>();
        label.text = price + "";
        label      = content_trans.FindChild("monad").FindChild("value").GetComponent <UILabel>();
        label.text = monad;
        label      = content_trans.FindChild("num").FindChild("value").GetComponent <UILabel>();
        label.text = curNum + "";
        label      = content_trans.FindChild("valid").FindChild("value").GetComponent <UILabel>();
        label.text = validTime;
        Transform event_tran = obj_item.transform.FindChild("event");

        if (!context.Equals(""))
        {
            label      = content_trans.FindChild("other").GetComponent <UILabel>();
            label.text = context;
            int len = MyUtilTools.computeRow(label);
            label.transform.localPosition = new Vector3(0, -420 - len * label.fontSize / 2 + 20, 0);
            UITexture bg = content_trans.FindChild("rect-bg").GetComponent <UITexture>();
            bg.height = (int)(640 + len * label.fontSize);
            bg.transform.localPosition = new Vector3(0, -100 - len * label.fontSize / 2, 0);
            event_tran.localPosition   = new Vector3(0, -750 - len * label.fontSize + 20, 0);
        }
        else
        {
            event_tran.localPosition = new Vector3(0, -750, 0);
            content_trans.FindChild("other").gameObject.SetActive(false);
        }
        System.DateTime vTime      = System.DateTime.Parse(validTime);
        bool            flag       = revoke || vTime.CompareTo(System.DateTime.Now) < 0;
        GameObject      revoke_obj = content_trans.FindChild("revoke").gameObject;

        revoke_obj.SetActive(flag);
        Transform reverts = obj_item.transform.FindChild("reverts");

        if (reverts != null)
        {
            reverts.localPosition = new Vector3(0, event_tran.localPosition.y - 120, 0);
        }
    }
Пример #5
0
    void initMessage(MainData.MessageBody message)
    {
        GameObject pref_obj    = message.type == 1 ? (message.sendId == MainData.instance.user.id ? pref_message_pic_detail_right : pref_message_pic_detail_left) : (message.sendId == MainData.instance.user.id ? pref_message_word_detail_right : pref_message_word_detail_left);
        GameObject message_obj = NGUITools.AddChild(messageDetailContainer.gameObject, pref_obj);

        message_obj.name = "message-" + message.id;
        Transform icon_tran = message_obj.transform.FindChild("icon");

        icon_tran.GetComponent <UISprite>().spriteName = message.sendFace;
        Transform time_tran = message_obj.transform.FindChild("time");

        time_tran.gameObject.SetActive(message.showTime == 1);
        if (message.showTime == 1)
        {
            UILabel         time_label = time_tran.GetComponent <UILabel>();
            System.DateTime dateTime   = System.DateTime.Parse(message.time);
            string          showStr    = null;
            //int days = System.DateTime.DaysInMonth(dateTime.Year, dateTime.Month);
            if (System.DateTime.Now.Year == dateTime.Year && System.DateTime.Now.Month == dateTime.Month && System.DateTime.Now.Day == dateTime.Day)
            {//同一天
                showStr = "今天" + MyUtilTools.numToString(dateTime.Hour) + ":" + MyUtilTools.numToString(dateTime.Minute);
            }
            else
            {
                showStr = dateTime.Year + "/" + MyUtilTools.numToString(dateTime.Month) + "/" + MyUtilTools.numToString(dateTime.Day) + " " + MyUtilTools.numToString(dateTime.Hour) + ":" + MyUtilTools.numToString(dateTime.Minute);
            }
            time_label.text = showStr;
            messageStarty  -= 70;
        }
        if (message.type == 0)
        {//文字类型
            Transform content_trans = message_obj.transform.FindChild("content");
            float     cx            = content_trans.localPosition.x;
            Transform rect_tran     = content_trans.FindChild("rect");
            UISprite  rect_sprite   = rect_tran.GetComponent <UISprite>();
            UILabel   content       = rect_tran.FindChild("value").GetComponent <UILabel>();
            content.width = 570;
            content.text  = message.content;
            int row    = MyUtilTools.computeRow(content);
            int height = row * 64;
            if (row == 1)
            {
                int width = (int)MyUtilTools.computeLen(content) + content.fontSize;
                rect_sprite.width = Mathf.Min(600, width);
                content.width     = rect_sprite.width - content.fontSize;
            }
            rect_sprite.height = height;
            content.height     = row * (content.fontSize + content.spacingX);
            float offx     = rect_sprite.width / 2 + 14;
            int   opration = cx > 0 ? -1 : 1;
            rect_tran.localPosition             = new Vector3(opration * offx, content.fontSize - height / 2 - 5, 0);
            message_obj.transform.localPosition = new Vector3(0, messageStarty, 0);
            messageStarty -= height + 10;
        }
        else //图片
        {
            UITexture pic_texture = message_obj.transform.FindChild("content").FindChild("rect").FindChild("value").GetComponent <UITexture>();
            JustRun.Instance.loadPic(message.content, pic_texture);
            message_obj.transform.localPosition = new Vector3(0, messageStarty, 0);
            messageStarty -= 590;
        }
    }