Example #1
0
    public TemplateIcon ImportIcon()
    {
        string assetp = EditorUtility.OpenFilePanel("模板Icon", "C:/Users/Administrator/Desktop", "png");

        if (string.IsNullOrEmpty(assetp))
        {
            return(null);
        }

        TemplateIcon icon = new TemplateIcon(assetp);

        return(icon);
    }
    private void onObjectAdded(RectTransform item, int index)
    {
        TemplateIcon      component         = item.GetComponent <TemplateIcon>();
        DisplayedTemplate displayedTemplate = displayedTemplates[index];

        component.gameObject.name = displayedTemplate.Definition.AssetName + "_button";
        RectTransform rectTransform = component.transform as RectTransform;

        rectTransform.anchoredPosition = Vector2.zero;
        rectTransform.anchorMin        = Vector2.zero;
        rectTransform.anchorMax        = Vector2.one;
        rectTransform.sizeDelta        = Vector2.zero;
        rectTransform.localScale       = Vector3.one;
        bool flag    = Service.Get <CPDataEntityCollection>().IsLocalPlayerMember();
        bool canDrag = flag;

        if (!flag)
        {
            canDrag = !displayedTemplate.Definition.IsMemberOnlyCreatable;
        }
        string assetName = displayedTemplate.Definition.AssetName;
        Texture2DContentKey equipmentIconPath = EquipmentPathUtil.GetEquipmentIconPath(assetName);

        component.Init(equipmentIconPath, BreadcrumbType, displayedTemplate.Definition.Id, canDrag);
        if (!flag && displayedTemplate.Definition.IsMemberOnlyCreatable)
        {
            component.SetTemplateMemberLocked(displayedTemplate.Definition);
        }
        else if (userLevel < displayedTemplate.Level)
        {
            component.SetTemplateToLevelLocked(displayedTemplate.Definition, displayedTemplate.Level);
        }
        else if (!string.IsNullOrEmpty(displayedTemplate.MascotName))
        {
            component.SetTemplateToProgressionLocked(displayedTemplate.Definition, displayedTemplate.MascotName);
        }
        else
        {
            component.SetTemplateToUnlocked(displayedTemplate.Definition);
        }
        AccessibilitySettings component2 = component.GetComponent <AccessibilitySettings>();

        if (component2 != null)
        {
            component2.CustomToken = displayedTemplate.Definition.Name;
        }
    }
Example #3
0
        public async Task <Stream> GenerateXpImageStream(User user, SocketGuildUser guildUser, Server server = null)
        {
            var          templateStream = new MemoryStream();
            MemoryStream pfpStream;
            MemoryStream badgeStream;

            var xp = new XpTemplate
            {
                ProfilePicture = new TemplateIcon
                {
                    Loc = new TemplateLoc
                    {
                        X = 13,
                        Y = 15
                    },
                    ProfileUrl = guildUser.GetAvatarUrl(),
                    Show       = true
                },
                LevelUpMessageText = new TemplateText
                {
                    Color     = Rgba32.WhiteSmoke,
                    Font      = Font(server is null ? 60 : 48),
                    HasStroke = true,
                    Loc       = server is null
                        ? new TemplateLoc
                    {
                        X = 210,
                        Y = 125
                    }
                        : new TemplateLoc
                    {
                        X = 160,
                        Y = 125
                    },
                    Show        = true,
                    StrokeColor = Rgba32.LightSalmon,
                    StrokeWidth = 1.4f,
                    Text        = $"{(server is null ? "Level Up!" : "Server Level Up!")}"
                },
Example #4
0
    //public List<UmaDnaItem> LoadDna()
    //{
    //    return characterData.dna;
    //}

    public void Save(TemplateIcon icon, List <TemplateClothItem> cloths, List <UmaDnaItem> dna)
    {
        if (characterData != null)
        {
            if (!icon.sourceFlag)
            {
                string source = icon.path;
                FileHelper.copyFile(source, iconPath, true);
            }

            List <ClothModel> cms = new List <ClothModel>();
            for (int i = 0; i < cloths.Count; i++)
            {
                if (cloths[i].cm != null)
                {
                    cms.Add(cloths[i].cm);
                }
            }
            characterData.avatars = cms;
            //characterData.dna = dna;
            string json = characterData.JsonTransferString();
            FileHelper.CreatFile(path, id + ".txt", json);
        }
    }
Example #5
0
        /// <summary>
        /// Generates the profile image for the provided <see cref="User"/>. A <see cref="Server"/>
        /// is passed in to display their Server EXp progress and rank.
        /// </summary>
        /// <param name="user"></param>
        /// <param name="server"></param>
        /// <param name="guildUser"></param>
        /// <returns></returns>
        public async Task <Stream> GenerateProfileImageStream(User user, Server server, SocketGuildUser guildUser)
        {
            var          templateStream = new MemoryStream();
            MemoryStream pfpStream;
            MemoryStream badgeStream;

            bool isDefaultPfp = string.IsNullOrEmpty(guildUser.AvatarId);

            var profile = new ProfileTemplate
            {
                Xp = new ProfileTemplateXp
                {
                    GlobalBar       = GlobalBarData.Bar(user),
                    GuildBar        = GuildBarData.Bar(user, server),
                    IconAndUsername = ProfilePictureData.ProfileIcon(guildUser),
                    PremiumBadge    = new PremiumBadge(user).Data,
                    LeftPanel       = await ProfilePanelData.LeftPanel(user, server),
                    RightPanel      = ProfilePanelData.RightPanel(user)
                }
            };

            TemplateIcon pfpIcon = ProfilePictureData.ProfileIcon(guildUser);

            using (var wc = new WebClient())
            {
                string avatarUrl = guildUser.GetAvatarUrl(ImageFormat.Png);
                avatarUrl = string.IsNullOrEmpty(avatarUrl) ? guildUser.GetDefaultAvatarUrl() : avatarUrl;

                byte[] pfpImg = await wc.DownloadDataTaskAsync(avatarUrl);

                pfpStream = new MemoryStream(pfpImg);

                byte[] badgeImg = await wc.DownloadDataTaskAsync(profile.Xp.PremiumBadge.Emote.Url);

                badgeStream = new MemoryStream(badgeImg);
            }

            using Image image          = Image.Load(ProfileTemplatePath);
            using Image profilePicture = Image.Load(pfpStream);
            using Image suppBadge      = Image.Load(badgeStream);
            using var gBar             = new Image <Rgba32>(image.Width, image.Height);

            PointF[] gFillPoints = GlobalBarData.GlobalXpBarCoordinates(user, profile.Xp);
            PointF[] sFillPoints = GuildBarData.GuildXpBarCoordinates(user, server, profile.Xp);

            /*
             * In order to avoid clipping and artifacts, we render a completely new image
             * that just contains the bars themselves. This serves as our "layer zero" if
             * we were in Photoshop.
             *
             * Now that we have our base layer, we draw the template on top as our
             * middle layer. This is because the template has transparent "cutouts" for
             * our bars to fit into. In order for the bar to look pretty, the template must
             * "trim" the bar for us naturally. This is why we have to draw the template on top
             * separately.
             *
             * We do this for all bars and images that are filling transparent areas on our template.
             */

            // Resize downloaded supporter image, she's a little too chonky <(^-^)>
            const double RESIZE_SCALAR = 0.75;

            suppBadge.Mutate(x => x.Resize((int)(x.GetCurrentSize().Width *RESIZE_SCALAR), (int)(x.GetCurrentSize().Height *RESIZE_SCALAR)));

            // If the user has the default Discord profile picture, fix the width to 132 x 132 px.
            profilePicture.Mutate(x => x.Resize(new ResizeOptions
            {
                Position = AnchorPositionMode.Center,
                Size     = new Size(116, 116)
            }));

            // Draw the profile picture on top of the global bar. Global bar will serve as the base layer
            // that we continually add onto, even if it doesn't directly overlap it, as it's a layer
            // with the same size of our template. Think of it as a canvas.
            gBar.Mutate(x => x.DrawImage(profilePicture, new Point(22, 23), 1));
            gBar.Mutate(x => x.FillPolygon(profile.Xp.GlobalBar.Color, gFillPoints));
            gBar.Mutate(x => x.FillPolygon(profile.Xp.GuildBar.Color, sFillPoints));
            gBar.Mutate(x => x.DrawImage(image, 1));

            // Draw username and discriminator texts.
            gBar.Mutate(x => x.DrawKaguyaText(pfpIcon.UsernameText));
            gBar.Mutate(x => x.DrawKaguyaText(pfpIcon.UserDiscriminatorText));

            //Draw global bar top-left, bottom-right, and center texts
            gBar.Mutate(x => x.DrawKaguyaText(profile.Xp.GlobalBar.TopLeftText));
            gBar.Mutate(x => x.DrawKaguyaText(profile.Xp.GlobalBar.BottomRightText));
            gBar.Mutate(x => x.DrawKaguyaText(profile.Xp.GlobalBar.CenterText));

            //Draw guild bar top-left, bottom-right, and center texts
            gBar.Mutate(x => x.DrawKaguyaText(profile.Xp.GuildBar.TopLeftText));
            gBar.Mutate(x => x.DrawKaguyaText(profile.Xp.GuildBar.BottomRightText));
            gBar.Mutate(x => x.DrawKaguyaText(profile.Xp.GuildBar.CenterText));

            //Draw card panel data/statistics texts
            gBar.Mutate(x => x.DrawKaguyaTemplatePanelText(profile.Xp.LeftPanel));
            gBar.Mutate(x => x.DrawKaguyaTemplatePanelText(profile.Xp.RightPanel));

            // Draw supporter badge.
            if (user.IsPremium)
            {
                gBar.Mutate(x => x.DrawImage(suppBadge,
                                             new Point((int)profile.Xp.PremiumBadge.Loc.X, (int)profile.Xp.PremiumBadge.Loc.Y), 1));
            }

            // Save the completed drawing to a MemoryStream so that we can send it to Discord elsewhere.
            gBar.SaveAsPng(templateStream);
            templateStream.Seek(0, SeekOrigin.Begin);

            return(templateStream);
        }
Example #6
0
    void tempBtn_Click()
    {
        //SOAService_Resource_Character_ICON _icon = new SOAService_Resource_Character_ICON("0204_0001");
        //_icon.AddListener(loadicon);
        //_icon.Run();

        //sample.TakeHighScaledShot(1080, 1920, sample.screenshotScale, sample.screenshotFilter, "/../" + sample.relativeScreenshotPath);
        //return;

        StartCoroutine(change());
        return;

        danPnael.gameObject.SetActive(false);
        string p = Application.dataPath + "/player.png";

        Camera c = Camera.main;
        Rect   r = new Rect();

        r.width  = 1080f;
        r.height = 1920f;

        CameraPng.CaptureCamera(c, r, p);
        //Application.CaptureScreenshot(p);
        danPnael.gameObject.SetActive(true);
        return;

#if UNITY_EDITOR
        //IExpressModel male = new ExpressModel_Male();//实例化男性
        //IExpressModel female = new ExpressModel_Female();//实例化女性

        CompressAssetbundleZip com = new CompressAssetbundleZip();
        com.Compress();
        return;

        ITemplate male2 = new Template_Male2();//女性模板2
        List <TemplateClothItem> cloths = male2.LoadCloths();
        TemplateIcon             icon   = male2.LoadIcon();
        return;

        TemplateCloth            cloth = new TemplateCloth();
        List <TemplateClothItem> list  = cloth.Load(EnumCharacterType.Charater_Female, "04");
        return;

        ImportBase female = new ImportFemale();
        female.Import();

        ImportBase male = new ImportMale();
        male.Import();

        ImportBase import = new ImportIcon();
        import.Import();

        IniEditor.iniData();

        PackagerEditor.Assetbundle_All();

        BuildPlayer build = new BuildPlayer_Android();
        build.Build();

        ExportBase export = new CharacterCustomExport();
        export.ExportAsset();

        ClearLocalData.clear();

        CharacterConst.assetBundle = true;          //使用
        CharacterConst.assetBundle = false;         //不使用

        ITemplate female1 = new Template_Female1(); //女性模板1
        ITemplate female2 = new Template_Female1(); //女性模板2
        ITemplate male1   = new Template_Male1();   //女性模板1


        /*IScence scence = new ScenceExpression();
         * scence.Load();
         * return;
         *
         * BuildPlayer build = new BuildPlayer_Android();
         * build.Build();
         * return;
         *
         * ExportBase export = new CharacterCustomExport();
         * export.ExportAsset();
         * return;
         *
         * ClearLocalData.clear();
         * return;
         *
         * ImportBase import = new ImportIcon();
         * import.Import();
         * return;*/
        //IniEditor.iniData();


        // ImportBase female = new ImportFemale();
        //female.Import();
        //string path3 = EditorUtility.OpenFolderPanel("import female fold", "C:/Users/Administrator/Desktop", "");
        //string url = "http://192.168.1.151:90/Characters/face/0203_0111.png";
        //player.ChangeFace(url);
        //    player.CompressMesh(1);
#endif
    }
Example #7
0
    private CustomizerGestureModel processGesture(ITouch touch, CustomizerGestureModel gestureModel)
    {
        gestureModel.TouchDownStartPos = touch.position;
        gestureModel.TouchStartTime    = Time.time;
        if (isOverUI(touch))
        {
            PointerEventData pointerEventData = new PointerEventData(EventSystem.current);
            pointerEventData.position = touch.position;
            List <RaycastResult> list = new List <RaycastResult>();
            EventSystem.current.RaycastAll(pointerEventData, list);
            GameObject gameObject = null;
            float      num        = 0f;
            if (list != null && list.Count > 0)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    if (num <= list[i].index)
                    {
                        gameObject = list[i].gameObject;
                        num        = list[i].index;
                    }
                }
            }
            if (gameObject != null)
            {
                CustomizationButton component = gameObject.GetComponent <CustomizationButton>();
                if (component != null && component.CanDrag && component.GetTexture != null)
                {
                    switch (component.DraggableButtonType)
                    {
                    case DraggableButtonType.TEMPLATE:
                    {
                        TemplateIcon templateIcon = component as TemplateIcon;
                        gestureModel.TouchDownStartArea = AreaTouchedEnum.TEMPLATE_BUTTON;
                        gestureModel.DragIconTexture    = component.GetTexture;
                        gestureModel.TemplateData       = templateIcon.TemplateData;
                        gestureModel.IsEquippable       = templateIcon.CanSelect;
                        gestureModel.ItemDefinitionId   = templateIcon.DefinitionId;
                        gestureModel.IsEnabled          = templateIcon.IsEnabled;
                        break;
                    }

                    case DraggableButtonType.FABRIC:
                        gestureModel.TouchDownStartArea = AreaTouchedEnum.FABRIC_BUTTON;
                        gestureModel.DragIconTexture    = component.GetTexture;
                        gestureModel.ItemDefinitionId   = component.DefinitionId;
                        break;

                    case DraggableButtonType.DECAL:
                        gestureModel.TouchDownStartArea = AreaTouchedEnum.DECAL_BUTTON;
                        gestureModel.DragIconTexture    = component.GetTexture;
                        gestureModel.ItemDefinitionId   = component.DefinitionId;
                        break;
                    }
                }
            }
        }
        else if (isTouchBlockedByUIControls(touch))
        {
            gestureModel.TouchDownStartArea = AreaTouchedEnum.CLICK_BLOCKING_UI;
        }
        else
        {
            Ray ray = Camera.main.ScreenPointToRay(touch.position);
            if (Physics.Raycast(ray, out RaycastHit hitInfo))
            {
                GameObject gameObject2 = hitInfo.collider.gameObject;
                if (gameObject2.GetComponent <SkinnedMeshRenderer>() != null && gameObject2.GetComponent <SkinnedMeshRenderer>().sharedMaterial.shader.name.Contains("Equipment"))
                {
                    Texture2D texture2D = gameObject2.GetComponent <SkinnedMeshRenderer>().sharedMaterial.GetTexture(EquipmentShaderParams.DECALS_123_OPACITY_TEX) as Texture2D;
                    if (texture2D == null)
                    {
                        Log.LogErrorFormatted(this, "Unable to retrieve decal 123 map on item {0}. Property did not exist {1}.", gameObject2.name, EquipmentShaderParams.DECALS_123_OPACITY_TEX);
                        return(gestureModel);
                    }
                    Vector2 textureCoord = hitInfo.textureCoord;
                    textureCoord.Scale(new Vector2(texture2D.width, texture2D.height));
                    Color pixel = texture2D.GetPixel((int)textureCoord.x, (int)textureCoord.y);
                    if (Mathf.Abs(pixel.r) < Mathf.Epsilon && Mathf.Abs(pixel.g) < Mathf.Epsilon && Mathf.Abs(pixel.b) < Mathf.Epsilon)
                    {
                        gestureModel.TouchDownStartArea = AreaTouchedEnum.NOTHING;
                    }
                    else if (pixel.r > pixel.g && pixel.r > pixel.b)
                    {
                        gestureModel.TouchDownStartArea = AreaTouchedEnum.RED_CHANNEL;
                        gestureModel.StartGameObject    = gameObject2;
                    }
                    else if (pixel.g > pixel.r && pixel.g > pixel.b)
                    {
                        gestureModel.TouchDownStartArea = AreaTouchedEnum.GREEN_CHANNEL;
                        gestureModel.StartGameObject    = gameObject2;
                    }
                    else
                    {
                        gestureModel.TouchDownStartArea = AreaTouchedEnum.BLUE_CHANNEL;
                        gestureModel.StartGameObject    = gameObject2;
                    }
                }
                else
                {
                    gestureModel.TouchDownStartArea = AreaTouchedEnum.PENGUIN_ROTATION_AREA;
                }
            }
            else
            {
                gestureModel.TouchDownStartArea = AreaTouchedEnum.PENGUIN_ROTATION_AREA;
            }
        }
        return(gestureModel);
    }