Пример #1
0
    private void LoadValue(IAssignableIdentity minion, GameObject widget_go)
    {
        if (!((UnityEngine.Object)widget_go == (UnityEngine.Object)null))
        {
            PrioritizationGroupTableColumn prioritizationGroupTableColumn = GetWidgetColumn(widget_go) as PrioritizationGroupTableColumn;
            ChoreGroup choreGroup = prioritizationGroupTableColumn.userData as ChoreGroup;
            TableRow   widgetRow  = GetWidgetRow(widget_go);
            switch (widgetRow.rowType)
            {
            case TableRow.RowType.Header:
                InitializeHeader(choreGroup, widget_go);
                break;

            case TableRow.RowType.Default:
            case TableRow.RowType.Minion:
            case TableRow.RowType.StoredMinon:
            {
                IPersonalPriorityManager priorityManager = GetPriorityManager(widgetRow);
                bool flag = priorityManager.IsChoreGroupDisabled(choreGroup);
                HierarchyReferences component = widget_go.GetComponent <HierarchyReferences>();
                KImage kImage = component.GetReference("FG") as KImage;
                kImage.raycastTarget = flag;
                ToolTip toolTip = component.GetReference("FGToolTip") as ToolTip;
                toolTip.enabled = flag;
                break;
            }
            }
            IPersonalPriorityManager priorityManager2 = GetPriorityManager(widgetRow);
            if (priorityManager2 != null)
            {
                UpdateWidget(widget_go, choreGroup, priorityManager2);
            }
        }
    }
Пример #2
0
 private void AddMask(GameObject go, JsonData data)
 {
     if (HasParam(data, PARAM_CLIP_EFFECT))
     {
         go.AddComponent <ClipMask>();
     }
     if (HasParam(data, PARAM_MASK_STENCIL))
     {
         var    mask  = go.AddComponent <Mask>();
         KImage image = go.AddComponent <KImage>();
         string link  = (string)(data["normal"]["link"]);
         image.sprite = KAssetManager.GetSprite(link);
         //image.material = KAssetManager.GetEtcMaterialByLink(link);
         //image.color = new Color(0, 0, 0, 0);
         Vector4 border = image.sprite.border;
         if (border.x > 0 || border.y > 0 || border.z > 0 || border.w > 0)
         {
             image.type = Image.Type.Sliced;
         }
         mask.showMaskGraphic = false;
     }
     else
     {
         go.AddComponent <KImageNoTex>();  //RectMask2D还需要一张白图接受点击事件,否则scrollview不法拖动
         go.AddComponent <RectMask2D>();
     }
 }
Пример #3
0
        //添加图片_九宫格
        private KImage AddScale9GridImage(GameObject go)
        {
            KImage image = go.AddComponent <KImage>();

            image.type = Image.Type.Sliced;
            return(image);
        }
 private void UpdateColor(bool interactable, bool hover, bool press)
 {
     if ((UnityEngine.Object)bgImage == (UnityEngine.Object)null)
     {
         bgImage = GetComponent <KImage>();
         string    arg       = string.Empty;
         Transform transform = base.transform;
         for (int i = 0; i < 5; i++)
         {
             if (!((UnityEngine.Object)transform.parent != (UnityEngine.Object)null))
             {
                 break;
             }
             transform = transform.parent;
             string name = transform.name;
             arg = $"{name}/{arg}";
         }
         if ((UnityEngine.Object)bgImage == (UnityEngine.Object)null)
         {
             return;
         }
     }
     UpdateKImageColor(bgImage, interactable, hover, press);
     for (int j = 0; j < additionalKImages.Length; j++)
     {
         UpdateKImageColor(additionalKImages[j], interactable, hover, press);
     }
 }
Пример #5
0
    public TestPop4()
    {
        m_popId    = POP_ID.TEST_POP_4;
        m_layerIdx = POP_LAYER_IDX.LAYER_POP_1;

        ShowGameObject();

        //
        m_btnOk    = GetChildByName <KButton>("Button_Ok", true);
        m_btnClose = GetChildByName <KButton>("Button_Close", true);

        m_panel = GameObjUtil.GetParent(m_btnOk.gameObject);

        //
        m_inputName      = GetChildByName <KInputField>("Input_name", true);
        m_labelTestInput = GetChildByName <KText>("Label_testInput", true);
        //
        m_tgl_1      = GetChildByName <KToggle>("Toggle_position1", true);
        m_labelTgl_1 = GetChildByName <KText>(m_tgl_1.gameObject, "Label_Text", true);
        m_tglGroup_1 = GetChildByName <KToggleGroup>("ToggleGroup_a1", true);
        //
        m_sliderSchedule = GetChildByName <KSlider>("Slider_Schedule1", true);
        m_labelSchedule  = GetChildByName <KText>("Label_testSilder", true);
        //
        m_barLoading = GetChildByName <KProgressBar>("ProgressBar_loading", true);
        //
        m_icon = GetChildByName <KImage>("Image_sharedAnchor", true);
        //
        m_scrollView = GetChildByName <KScrollView>("ScrollView_GuildList", true);
        m_listView   = ComponentUtil.EnsureComponent <KListViewScroll>(m_scrollView.gameObject);
    }
Пример #6
0
    public TestKUIPop3()
    {
        m_popId    = POP_ID.TEST_KUI_3;
        m_layerIdx = POP_LAYER_IDX.LAYER_POP_1;

        ShowGameObject();

        m_toggle1 = GetChildByName <KToggle>("Toggle_position1", true);
        m_toggle1.needReqChange = true;

        m_toggleGroup1 = GetChildByName <KToggleGroup>("ToggleGroup_1", true);
        //m_toggleGroup1.allowMultiple = true;
        //m_toggleGroup1.needReqChange = true;
        //m_toggleGroup1.allowSwitchOff = true;

        m_inputName = GetChildByName <KInputField>("Input_name", true);


        m_buttonAnnounce = GetChildByName <KButton>("Button_SystemAnnounce", true);
        m_buttonClose    = GetChildByName <KButton>("Button_Close", true);


        m_barExp          = GetChildByName <KProgressBar>("ProgressBar_EXP", true);
        m_sliderSchedule1 = GetChildByName <KSlider>("Slider_Schedule1", true);

        m_icon1 = GetChildByName <KImage>("Image_Icon1", true);


        m_scrollViewItemList = GetChildByName <KScrollView>("ScrollView_ItemList", true);
    }
Пример #7
0
    private void InitializeHeader(ChoreGroup chore_group, GameObject widget_go)
    {
        HierarchyReferences component           = widget_go.GetComponent <HierarchyReferences>();
        HierarchyReferences hierarchyReferences = component.GetReference("PrioritizationWidget") as HierarchyReferences;
        GameObject          items_root          = hierarchyReferences.GetReference("ItemPanel").gameObject;

        if (items_root.transform.childCount <= 0)
        {
            items_root.SetActive(false);
            LocText locText = component.GetReference("Label") as LocText;
            locText.text = chore_group.Name;
            KButton    kButton    = component.GetReference("PrioritizeButton") as KButton;
            Selectable selectable = items_root.GetComponent <Selectable>();
            kButton.onClick += delegate
            {
                selectable.Select();
                items_root.SetActive(true);
            };
            GameObject gameObject = hierarchyReferences.GetReference("ItemTemplate").gameObject;
            for (int num = 5; num >= 0; num--)
            {
                PriorityInfo priorityInfo = GetPriorityInfo(num);
                if (priorityInfo.name != null)
                {
                    GameObject          gameObject2 = Util.KInstantiateUI(gameObject, items_root, true);
                    KButton             component2  = gameObject2.GetComponent <KButton>();
                    HierarchyReferences component3  = gameObject2.GetComponent <HierarchyReferences>();
                    KImage  kImage       = component3.GetReference("Icon") as KImage;
                    LocText locText2     = component3.GetReference("Label") as LocText;
                    int     new_priority = num;
                    component2.onClick += delegate
                    {
                        ChangeColumnPriority(widget_go, new_priority);
                        UnityEngine.EventSystems.EventSystem.current.SetSelectedGameObject(null);
                    };
                    kImage.sprite = priorityInfo.sprite;
                    locText2.text = priorityInfo.name;
                }
            }
        }
    }
 private void UpdateKImageColor(KImage image, bool interactable, bool hover, bool press)
 {
     if ((UnityEngine.Object)image != (UnityEngine.Object)null)
     {
         if (interactable)
         {
             if (press)
             {
                 image.ColorState = KImage.ColorSelector.Active;
             }
             else
             {
                 image.ColorState = ((!hover) ? KImage.ColorSelector.Inactive : KImage.ColorSelector.Hover);
             }
         }
         else
         {
             image.ColorState = ((!hover) ? KImage.ColorSelector.Disabled : KImage.ColorSelector.Disabled);
         }
     }
 }
    public void ConfigureItem(bool disabled, DisplayOptionInfo display_info)
    {
        KImage kImage = selectedItem;
        HierarchyReferences component = kImage.GetComponent <HierarchyReferences>();
        KImage kImage2 = component.GetReference("BG") as KImage;

        if (display_info.bgOptions == null)
        {
            kImage2.gameObject.SetActive(false);
        }
        else
        {
            kImage2.sprite = display_info.bgOptions[display_info.bgIndex];
        }
        KImage kImage3 = component.GetReference("FG") as KImage;

        if (display_info.fgOptions == null)
        {
            kImage3.gameObject.SetActive(false);
        }
        else
        {
            kImage3.sprite = display_info.fgOptions[display_info.fgIndex];
        }
        KImage kImage4 = component.GetReference("Fill") as KImage;

        if ((UnityEngine.Object)kImage4 != (UnityEngine.Object)null)
        {
            kImage4.enabled = !disabled;
            kImage4.color   = display_info.fillColour;
        }
        KImage kImage5 = component.GetReference("Outline") as KImage;

        if ((UnityEngine.Object)kImage5 != (UnityEngine.Object)null)
        {
            kImage5.enabled = !disabled;
        }
    }
Пример #10
0
        //添加图片_填充模式
        private KImage AddUvImage(GameObject go, JsonData stateData)
        {
            KImage image = go.AddComponent <KImage>();

            image.type = Image.Type.Filled;
            //填充模式
            string param = GetParam(stateData, PATTERN_UV);

            if (param == PARAM_UV_LEFT2RIGHT)
            {
                image.fillMethod = Image.FillMethod.Horizontal;
                image.fillOrigin = (int)Image.OriginHorizontal.Left;
            }
            else if (param == PARAM_UV_RIGHT2LEFT)
            {
                image.fillMethod = Image.FillMethod.Horizontal;
                image.fillOrigin = (int)Image.OriginHorizontal.Right;
            }
            else if (param == PARAM_UV_UP2DOWN)
            {
                image.fillMethod = Image.FillMethod.Vertical;
                image.fillOrigin = (int)Image.OriginVertical.Top;
            }
            else if (param == PARAM_UV_DOWN2UP)
            {
                image.fillMethod = Image.FillMethod.Vertical;
                image.fillOrigin = (int)Image.OriginVertical.Bottom;
            }
            else if (param == PARAM_UV_RADIAL_360)
            {
                image.fillMethod    = Image.FillMethod.Radial360;
                image.fillOrigin    = (int)Image.Origin360.Top;
                image.fillClockwise = false;
            }
            return(image);
        }
    private void AddNotification(Notification notification)
    {
        notifications.Add(notification);
        notification.Idx = notificationIncrement++;
        Entry entry = null;

        entriesByMessage.TryGetValue(notification.titleText, out entry);
        if (entry == null)
        {
            GameObject label;
            if (notification.Type == NotificationType.Messages)
            {
                label = Util.KInstantiateUI(MessagesPrefab, MessagesFolder, false);
            }
            else
            {
                label = Util.KInstantiateUI(LabelPrefab, LabelsFolder, false);
            }
            label.GetComponentInChildren <NotificationAnimator>().Init();
            label.gameObject.SetActive(true);
            KImage     componentInChildren  = label.GetComponentInChildren <KImage>(true);
            Button[]   componentsInChildren = label.gameObject.GetComponentsInChildren <Button>();
            ColorBlock colors = componentsInChildren[0].colors;
            if (notification.Type == NotificationType.Bad || notification.Type == NotificationType.DuplicantThreatening)
            {
                colors.normalColor = badColorBG;
            }
            else if (notification.Type == NotificationType.Messages)
            {
                colors.normalColor = messageColorBG;
                Debug.Assert(notification.GetType() == typeof(MessageNotification), $"Notification: \"{notification.titleText}\" is not of type MessageNotification");
                componentsInChildren[1].onClick.AddListener(delegate
                {
                    List <Notification> list = notifications.FindAll((Notification n) => n.titleText == notification.titleText);
                    foreach (Notification item in list)
                    {
                        MessageNotification messageNotification = (MessageNotification)item;
                        Messenger.Instance.RemoveMessage(messageNotification.message);
                        messageNotification.Clear();
                    }
                });
            }
            else if (notification.Type == NotificationType.Tutorial)
            {
                colors.normalColor = warningColorBG;
            }
            else
            {
                colors.normalColor = normalColorBG;
            }
            componentsInChildren[0].colors = colors;
            componentsInChildren[0].onClick.AddListener(delegate
            {
                OnClick(entry);
            });
            if (notification.ToolTip != null)
            {
                label.GetComponentInChildren <ToolTip>().OnToolTip = delegate
                {
                    ToolTip componentInChildren2 = label.GetComponentInChildren <ToolTip>();
                    componentInChildren2.ClearMultiStringTooltip();
                    componentInChildren2.AddMultiStringTooltip(notification.ToolTip(entry.notifications, notification.tooltipData), TooltipTextStyle);
                    return(string.Empty);
                };
            }
            entry = new Entry(label);
            entriesByMessage[notification.titleText] = entry;
            entries.Add(entry);
            LocText[] componentsInChildren2 = label.GetComponentsInChildren <LocText>();
            LocText[] array = componentsInChildren2;
            foreach (LocText locText in array)
            {
                switch (notification.Type)
                {
                case NotificationType.Bad:
                    locText.color = badColor;
                    componentInChildren.sprite = icon_bad;
                    break;

                case NotificationType.DuplicantThreatening:
                    locText.color = badColor;
                    componentInChildren.sprite = icon_bad;
                    break;

                case NotificationType.Tutorial:
                    locText.color = warningColor;
                    componentInChildren.sprite = icon_warning;
                    break;

                case NotificationType.Messages:
                    locText.color = messageColor;
                    componentInChildren.sprite = icon_message;
                    break;

                default:
                    locText.color = normalColor;
                    componentInChildren.sprite = icon_normal;
                    break;
                }
                componentInChildren.color = locText.color;
                string str = string.Empty;
                if (KTime.Instance.UnscaledGameTime - initTime > 5f && notification.playSound)
                {
                    PlayDingSound(notification, 0);
                }
                else
                {
                    str = "too early";
                }
                if (AudioDebug.Get().debugNotificationSounds)
                {
                    Debug.Log("Notification(" + notification.titleText + "):" + str);
                }
            }
        }
        entry.Add(notification);
        entry.UpdateMessage(notification, true);
        dirty = true;
        SortNotifications();
    }
Пример #12
0
 /// <summary>
 /// Sets up the background image to have the right sprite and slice type.
 /// </summary>
 /// <param name="bgImage">The image that forms the button background.</param>
 internal static void SetupButtonBackground(KImage bgImage)
 {
     UIDetours.APPLY_COLOR_STYLE.Invoke(bgImage);
     bgImage.sprite = PUITuning.Images.ButtonBorder;
     bgImage.type   = Image.Type.Sliced;
 }
Пример #13
0
 /// <summary>
 /// Sets up the button to have the right sound and background image.
 /// </summary>
 /// <param name="button">The button to set up.</param>
 /// <param name="bgImage">The background image.</param>
 internal static void SetupButton(KButton button, KImage bgImage)
 {
     UIDetours.ADDITIONAL_K_IMAGES.Set(button, new KImage[0]);
     UIDetours.SOUND_PLAYER_BUTTON.Set(button, PUITuning.ButtonSounds);
     UIDetours.BG_IMAGE.Set(button, bgImage);
 }
Пример #14
0
 /// <summary>
 /// Sets up the background image to have the right sprite and slice type.
 /// </summary>
 /// <param name="bgImage">The image that forms the button background.</param>
 internal static void SetupButtonBackground(KImage bgImage)
 {
     bgImage.ApplyColorStyleSetting();
     bgImage.sprite = PUITuning.Images.ButtonBorder;
     bgImage.type   = Image.Type.Sliced;
 }
Пример #15
0
 /// <summary>
 /// Sets up the button to have the right sound and background image.
 /// </summary>
 /// <param name="button">The button to set up.</param>
 /// <param name="bgImage">The background image.</param>
 internal static void SetupButton(KButton button, KImage bgImage)
 {
     button.additionalKImages = new KImage[0];
     button.soundPlayer       = PUITuning.ButtonSounds;
     button.bgImage           = bgImage;
 }
Пример #16
0
        protected virtual void AddImageComponent(GameObject go, JsonData stateData)
        {
            KImage image = null;

            if (HasParam(stateData, NO_TEX) == true)     //纯色
            {
                image      = go.AddComponent <KImageNoTex>();
                image.type = Image.Type.Simple;
            }
            else if (HasParam(stateData, PATTERN_SCALE_9_GRID) == true) //九宫格
            {
                image = AddScale9GridImage(go);
            }
            else if (HasParam(stateData, PATTERN_UV) == true)    //渐变
            {
                image = AddUvImage(go, stateData);
            }
            else
            {
                image      = go.AddComponent <KImage>();
                image.type = Image.Type.Simple;
            }

            string link = (string)stateData["link"];    //资源路径

            if (HasParam(stateData, NO_TEX) == false)
            {
                image.sprite = KAssetManager.GetSprite(link);
                //if (LinkTextureData.GetAtlasName(link) != image.sprite.texture.name)      //引用其他part的图片,暂时不需要
                //{
                //    link = image.sprite.texture.name + "." + LinkTextureData.GetTextureName(link);
                //    link = link.Replace("UI_", "");
                //}

                image.spritePadding = AtlasSpritePaddingHelper.GetAtlasSpritePadding(link);
            }

            if (go.name.Contains(SHARED_ANCHOR) || link.Contains(SHARED_ANCHOR))
            {
                //icon用
                image.color = new Color(1.0f, 1.0f, 1.0f, 1.0f);
                var sc        = GetSolidFillColor(stateData);
                var blendMode = GetSolidFillMode(stateData);
                if (blendMode == "normal")
                {
                    image.overlayColor = sc;
                }
                else if (blendMode == "multiply")
                {
                    image.color        = sc;
                    image.overlayColor = new Color(1.0f, 1.0f, 1.0f, 0.0f);
                }
            }
            else if (HasParam(stateData, NO_TEX))
            {
                //纯色
                image.sprite = null;
                //image.material = KAssetManager.GetNoTexMaterial();
                image.color = GetSolidFillColor(stateData); //配置颜色
                if (GetAlpha(stateData) > 0.03)
                {
                    var comNoTex = (KImageNoTex)image;
                    comNoTex.NeedColor = true;
                }
            }
            else
            {
                //image.material = KAssetManager.GetEtcMaterialByLink(link);  //设置为ui对应的材质球
                var sc        = GetSolidFillColor(stateData);
                var blendMode = GetSolidFillMode(stateData);
                if (blendMode == "normal")
                {
                    image.overlayColor = sc;
                }
                else if (blendMode == "multiply")
                {
                    image.color        = sc;
                    image.overlayColor = new Color(1.0f, 1.0f, 1.0f, 0.0f);
                }
                //image.color = new Color(1.0f, 1.0f, 1.0f, 0.0f);
            }

            image.alpha    = GetAlpha(stateData);    //透明度
            image.rotation = GetRotation(stateData); //ImageType为Simple时
            image.Initialize();
        }