コード例 #1
0
        private static void updateSelection()
        {
            if (PlaySettings.singleplayerMap == null || PlaySettings.singleplayerMap.Length == 0)
            {
                return;
            }
            LevelInfo level = Level.getLevel(PlaySettings.singleplayerMap);

            if (level == null)
            {
                return;
            }
            Local local = Localization.tryRead(level.path, false);

            if (local != null)
            {
                MenuPlaySingleplayerUI.descriptionBox.text = local.format("Description");
            }
            if (local != null && local.has("Name"))
            {
                MenuPlaySingleplayerUI.selectedBox.text = local.format("Name");
            }
            else
            {
                MenuPlaySingleplayerUI.selectedBox.text = PlaySettings.singleplayerMap;
            }
            if (MenuPlaySingleplayerUI.previewImage.texture != null && MenuPlaySingleplayerUI.previewImage.shouldDestroyTexture)
            {
                Object.Destroy(MenuPlaySingleplayerUI.previewImage.texture);
                MenuPlaySingleplayerUI.previewImage.texture = null;
            }
            string path = level.path + "/Preview.png";

            if (!ReadWrite.fileExists(path, false, false))
            {
                path = level.path + "/Level.png";
            }
            if (ReadWrite.fileExists(path, false, false))
            {
                byte[]    array     = ReadWrite.readBytes(path, false, false);
                Texture2D texture2D = new Texture2D(320, 180, 5, false, true);
                texture2D.name       = "Preview_" + PlaySettings.singleplayerMap + "_Selected_Icon";
                texture2D.filterMode = 2;
                texture2D.hideFlags  = 61;
                texture2D.LoadImage(array);
                MenuPlaySingleplayerUI.previewImage.texture = texture2D;
            }
            if (level.configData.Creators.Length > 0 || level.configData.Collaborators.Length > 0 || level.configData.Thanks.Length > 0)
            {
                int    num  = 0;
                string text = string.Empty;
                if (level.configData.Creators.Length > 0)
                {
                    text += MenuPlaySingleplayerUI.localization.format("Creators");
                    num  += 15;
                    for (int i = 0; i < level.configData.Creators.Length; i++)
                    {
                        text = text + "\n" + level.configData.Creators[i];
                        num += 15;
                    }
                }
                if (level.configData.Collaborators.Length > 0)
                {
                    if (text.Length > 0)
                    {
                        text += "\n\n";
                        num  += 30;
                    }
                    text += MenuPlaySingleplayerUI.localization.format("Collaborators");
                    num  += 15;
                    for (int j = 0; j < level.configData.Collaborators.Length; j++)
                    {
                        text = text + "\n" + level.configData.Collaborators[j];
                        num += 15;
                    }
                }
                if (level.configData.Thanks.Length > 0)
                {
                    if (text.Length > 0)
                    {
                        text += "\n\n";
                        num  += 30;
                    }
                    text += MenuPlaySingleplayerUI.localization.format("Thanks");
                    num  += 15;
                    for (int k = 0; k < level.configData.Thanks.Length; k++)
                    {
                        text = text + "\n" + level.configData.Thanks[k];
                        num += 15;
                    }
                }
                MenuPlaySingleplayerUI.creditsBox.sizeOffset_Y = num;
                MenuPlaySingleplayerUI.creditsBox.text         = text;
                MenuPlaySingleplayerUI.creditsBox.isVisible    = true;
            }
            else
            {
                MenuPlaySingleplayerUI.creditsBox.isVisible = false;
            }
            if (level.configData.Item != 0)
            {
                MenuPlaySingleplayerUI.itemButton.positionOffset_Y = MenuPlaySingleplayerUI.creditsBox.positionOffset_Y;
                if (MenuPlaySingleplayerUI.creditsBox.isVisible)
                {
                    MenuPlaySingleplayerUI.itemButton.positionOffset_Y += MenuPlaySingleplayerUI.creditsBox.sizeOffset_Y + 10;
                }
                MenuPlaySingleplayerUI.itemButton.text = MenuPlaySingleplayerUI.localization.format("Credits_Text", new object[]
                {
                    MenuPlaySingleplayerUI.selectedBox.text,
                    string.Concat(new string[]
                    {
                        "<color=",
                        Palette.hex(Provider.provider.economyService.getInventoryColor(level.configData.Item)),
                        ">",
                        Provider.provider.economyService.getInventoryName(level.configData.Item),
                        "</color>"
                    })
                });
                MenuPlaySingleplayerUI.itemButton.tooltip   = MenuPlaySingleplayerUI.localization.format("Credits_Tooltip");
                MenuPlaySingleplayerUI.itemButton.isVisible = true;
            }
            else
            {
                MenuPlaySingleplayerUI.itemButton.isVisible = false;
            }
            if (!string.IsNullOrEmpty(level.configData.Feedback))
            {
                MenuPlaySingleplayerUI.feedbackButton.positionOffset_Y = MenuPlaySingleplayerUI.creditsBox.positionOffset_Y;
                if (MenuPlaySingleplayerUI.creditsBox.isVisible)
                {
                    MenuPlaySingleplayerUI.feedbackButton.positionOffset_Y += MenuPlaySingleplayerUI.creditsBox.sizeOffset_Y + 10;
                }
                if (MenuPlaySingleplayerUI.itemButton.isVisible)
                {
                    MenuPlaySingleplayerUI.feedbackButton.positionOffset_Y += MenuPlaySingleplayerUI.itemButton.sizeOffset_Y + 10;
                }
                MenuPlaySingleplayerUI.feedbackButton.isVisible = true;
            }
            else
            {
                MenuPlaySingleplayerUI.feedbackButton.isVisible = false;
            }
        }
コード例 #2
0
        // Token: 0x060032EC RID: 13036 RVA: 0x00149C74 File Offset: 0x00148074
        public SleekLevel(LevelInfo level, bool isEditor)
        {
            base.init();
            base.sizeOffset_X        = 400;
            base.sizeOffset_Y        = 100;
            this.button              = new SleekButton();
            this.button.sizeOffset_X = 0;
            this.button.sizeOffset_Y = 0;
            this.button.sizeScale_X  = 1f;
            this.button.sizeScale_Y  = 1f;
            if (level.isEditable || !isEditor)
            {
                this.button.onClickedButton = new ClickedButton(this.onClickedButton);
            }
            base.add(this.button);
            if (ReadWrite.fileExists(level.path + "/Icon.png", false, false))
            {
                byte[]    data      = ReadWrite.readBytes(level.path + "/Icon.png", false, false);
                Texture2D texture2D = new Texture2D(380, 80, TextureFormat.ARGB32, false, true);
                texture2D.name      = "Icon_" + level.name + "_List_Icon";
                texture2D.hideFlags = HideFlags.HideAndDontSave;
                texture2D.LoadImage(data);
                this.icon = new SleekImageTexture();
                this.icon.positionOffset_X     = 10;
                this.icon.positionOffset_Y     = 10;
                this.icon.sizeOffset_X         = -20;
                this.icon.sizeOffset_Y         = -20;
                this.icon.sizeScale_X          = 1f;
                this.icon.sizeScale_Y          = 1f;
                this.icon.texture              = texture2D;
                this.icon.shouldDestroyTexture = true;
                this.button.add(this.icon);
            }
            this.nameLabel = new SleekLabel();
            this.nameLabel.positionOffset_Y = 10;
            this.nameLabel.sizeScale_X      = 1f;
            this.nameLabel.sizeOffset_Y     = 50;
            this.nameLabel.fontAlignment    = TextAnchor.MiddleCenter;
            this.nameLabel.fontSize         = 14;
            this.button.add(this.nameLabel);
            Local local = Localization.tryRead(level.path, false);

            if (local != null && local.has("Name"))
            {
                this.nameLabel.text = local.format("Name");
            }
            else
            {
                this.nameLabel.text = level.name;
            }
            this.infoLabel = new SleekLabel();
            this.infoLabel.positionOffset_Y = 60;
            this.infoLabel.sizeScale_X      = 1f;
            this.infoLabel.sizeOffset_Y     = 30;
            this.infoLabel.fontAlignment    = TextAnchor.MiddleCenter;
            string text = "#SIZE";

            if (level.size == ELevelSize.TINY)
            {
                text = MenuPlaySingleplayerUI.localization.format("Tiny");
            }
            else if (level.size == ELevelSize.SMALL)
            {
                text = MenuPlaySingleplayerUI.localization.format("Small");
            }
            else if (level.size == ELevelSize.MEDIUM)
            {
                text = MenuPlaySingleplayerUI.localization.format("Medium");
            }
            else if (level.size == ELevelSize.LARGE)
            {
                text = MenuPlaySingleplayerUI.localization.format("Large");
            }
            else if (level.size == ELevelSize.INSANE)
            {
                text = MenuPlaySingleplayerUI.localization.format("Insane");
            }
            string text2 = "#TYPE";

            if (level.type == ELevelType.SURVIVAL)
            {
                text2 = MenuPlaySingleplayerUI.localization.format("Survival");
            }
            else if (level.type == ELevelType.HORDE)
            {
                text2 = MenuPlaySingleplayerUI.localization.format("Horde");
            }
            else if (level.type == ELevelType.ARENA)
            {
                text2 = MenuPlaySingleplayerUI.localization.format("Arena");
            }
            this.infoLabel.text = MenuPlaySingleplayerUI.localization.format("Info", new object[]
            {
                text,
                text2
            });
            this.button.add(this.infoLabel);
            if (!level.isEditable && isEditor)
            {
                Bundle            bundle            = Bundles.getBundle("/Bundles/Textures/Menu/Icons/Workshop/MenuWorkshopEditor/MenuWorkshopEditor.unity3d");
                SleekImageTexture sleekImageTexture = new SleekImageTexture();
                sleekImageTexture.positionOffset_X = 20;
                sleekImageTexture.positionOffset_Y = -20;
                sleekImageTexture.positionScale_Y  = 0.5f;
                sleekImageTexture.sizeOffset_X     = 40;
                sleekImageTexture.sizeOffset_Y     = 40;
                sleekImageTexture.texture          = (Texture2D)bundle.load("Lock");
                sleekImageTexture.backgroundTint   = ESleekTint.FOREGROUND;
                this.button.add(sleekImageTexture);
                bundle.unload();
            }
            if (level.configData != null && level.configData.Status != EMapStatus.NONE)
            {
                SleekNew sleek = new SleekNew(level.configData.Status == EMapStatus.UPDATED);
                if (this.icon != null)
                {
                    this.icon.add(sleek);
                }
                else
                {
                    base.add(sleek);
                }
            }
            if (level.configData != null && level.configData.Category == ESingleplayerMapCategory.CURATED && level.configData.CuratedMapMode == ECuratedMapMode.TIMED)
            {
                SleekLabel sleekLabel = new SleekLabel();
                sleekLabel.positionOffset_X = -105;
                sleekLabel.positionScale_X  = 1f;
                sleekLabel.sizeOffset_X     = 100;
                sleekLabel.sizeOffset_Y     = 30;
                sleekLabel.fontAlignment    = TextAnchor.MiddleRight;
                sleekLabel.text             = MenuPlaySingleplayerUI.localization.format("Curated_Map_Timed");
                sleekLabel.foregroundTint   = ESleekTint.NONE;
                sleekLabel.foregroundColor  = Color.green;
                if (level.configData.Status != EMapStatus.NONE)
                {
                    sleekLabel.positionOffset_Y += 30;
                }
                SleekLabel sleekLabel2 = new SleekLabel();
                sleekLabel2.positionOffset_X = -205;
                sleekLabel2.positionOffset_Y = -30;
                sleekLabel2.positionScale_X  = 1f;
                sleekLabel2.positionScale_Y  = 1f;
                sleekLabel2.sizeOffset_X     = 200;
                sleekLabel2.sizeOffset_Y     = 30;
                sleekLabel2.fontAlignment    = TextAnchor.MiddleRight;
                sleekLabel2.text             = MenuPlaySingleplayerUI.localization.format("Curated_Map_Timestamp", new object[]
                {
                    level.configData.getCuratedMapTimestamp().ToString(MenuPlaySingleplayerUI.localization.format("Curated_Map_Timestamp_Format"))
                });
                sleekLabel2.foregroundTint  = ESleekTint.NONE;
                sleekLabel2.foregroundColor = Color.green;
                if (this.icon != null)
                {
                    this.icon.add(sleekLabel);
                    this.icon.add(sleekLabel2);
                }
                else
                {
                    base.add(sleekLabel);
                    base.add(sleekLabel2);
                }
            }
        }