示例#1
0
        private void OnRemoteStorageGetPublishedFileDetailsResult(RemoteStorageGetPublishedFileDetailsResult_t pCallback, bool bIOFailure)
        {
            Console.WriteLine("Got file details for " + pCallback.m_pchFileName + " with preview image " + pCallback.m_hPreviewFile);
            if (pCallback.m_eResult == EResult.k_EResultOK)
            {
                if (published.Count > 0)
                {
                    Console.WriteLine("Handling published level and downloading the next");
                    myLevels.Add(pCallback.m_pchFileName.ToLower());
                    published.Pop();
                    DownloadNextPublishedFileDetails();
                }
                else
                {
                    if (!subscribedItemButtonMap.ContainsKey(pCallback.m_hFile))
                    {
                        int x = (LevelButton.lvButtonList.Count) % 3;
                        int y = (int)Math.Floor((LevelButton.lvButtonList.Count) / 3f) % 2;
                        Texture2D thumbnail = Textures.GetCustomThumbnail();
                        Vector2 position = new Vector2((float)((220 * (x % 3)) + 80), (float)((220 * (y % 2)) + 0x69));
                        WorkshopLevelButton button = new WorkshopLevelButton(pCallback.m_pchFileName, position, thumbnail);
                        LevelButton.CalculateGroup();
                        LevelButton.lvButtonList.Add(button);

                        subscribedItemButtonMap.Add(pCallback.m_hFile, button);
                        subscribedThumbnailButtonMap.Add(pCallback.m_hPreviewFile, button);

                        levelDataStack.Push(pCallback.m_hFile);
                        levelThumbnailStack.Push(pCallback.m_hPreviewFile);
                    }
                    subscriptions.Pop();
                    if (subscriptions.Count > 0)
                    {
                        DownloadNextLevel();
                    }
                    else
                    {
                        DownloadNextLevelData();
                        DownloadNextLevelThumbnail();
                    }
                }
            }
            else
            {
                System.Windows.Forms.MessageBox.Show(
                    "An unexpected error occured (Get published file details result)\n" + pCallback.m_eResult, "Error");
            }
        }
示例#2
0
        public static void LevelSelectOn()
        {
            //int i;
            //int j;
            LevelButton.CurrentGroup = 0;
            TextSprite.TextList      = new List <TextSprite>();
            Button.ButtonList        = new List <Button>();
            LevelButton.lvButtonList = new List <LevelButton>();


            TextSprite ts = new TextSprite("Main Menu", "Medium", Color.White);

            Button.ButtonList.Add(new Button(ts, new Vector2(525f, 25f), 1));

            ts = new TextSprite("Next", "Medium", Color.White);
            Button.ButtonList.Add(new Button(ts, new Vector2(565f, 550f), 1));

            ts = new TextSprite("Previous", "Medium", Color.White);
            Button.ButtonList.Add(new Button(ts, new Vector2(40f, 550f), 1));

            if (!ScreenManager.Custom && !ScreenManager.Editing)
            {
                ts = new TextSprite("Erase Save Data", "Medium", Color.White);
                Button.ButtonList.Add(new Button(ts, new Vector2(40f, 25f), 1));
            }

            Button.ButtonList[2].Active = false;
            if (!ScreenManager.Editing && !ScreenManager.Custom)
            {
                SaveFile.LoadSaveFiles();
                for (int j = 0; j < Level.maxLevels / 3; j++)
                {
                    for (int i = 0; i < 3; i++)
                    {
                        int levelIndex = (j * 3) + i;
                        int collected  = 0;
                        for (int h = 0; h < SaveFile.SaveData.MainCoastersCollected[levelIndex].Length; h++)
                        {
                            if (SaveFile.SaveData.MainCoastersCollected[levelIndex][h])
                            {
                                collected++;
                            }
                        }

                        string status = "Locked";
                        if (SaveFile.SaveData.LevelsCompleted > (levelIndex))
                        {
                            if (collected == 3)
                            {
                                status = "Complete";
                            }
                            else
                            {
                                status = "Unlocked";
                            }
                        }
                        if (SaveFile.SaveData.LevelsCompleted == (levelIndex))
                        {
                            status = "Unlocked";
                        }

                        LevelButton.lvButtonList.Add(new LevelButton(levelIndex + 1, new Vector2((float)((220 * (i % 3)) + 80), (float)((220 * (j % 2)) + 0x69)), status, collected));
                    }
                }
            }
            else
            {
                if (!Directory.Exists(LevelSaver.CustomLevelsPath))
                {
                    Directory.CreateDirectory(LevelSaver.CustomLevelsPath);
                    string[] premadeCustoms = Directory.GetDirectories(@"Content\Levels\Custom");
                    foreach (string custom in premadeCustoms)
                    {
                        string[] parts      = custom.Split('\\');
                        string   customName = parts[parts.Length - 1];
                        Directory.CreateDirectory(LevelSaver.CustomLevelsPath + customName);
                        if (File.Exists(custom + "\\LevelData.xml"))
                        {
                            File.Copy(custom + "\\LevelData.xml", LevelSaver.CustomLevelsPath + customName + "\\LevelData.xml", true);
                        }
                        if (File.Exists(custom + "\\Thumbnail.png"))
                        {
                            File.Copy(custom + "\\Thumbnail.png", LevelSaver.CustomLevelsPath + customName + "\\Thumbnail.png", true);
                        }
                    }
                }

                SteamIntegration.LoadWorkshopLevels();

                //Load custom levels here
                String[]  levels     = Directory.GetDirectories(LevelSaver.CustomLevelsPath);
                int       levelIndex = 0;
                Texture2D thumbnail;
                for (int j = 0; j < Math.Ceiling(levels.Length / 3f); j++)
                {
                    for (int i = 0; i < 3; i++)
                    {
                        while (levelIndex < levels.Length && !File.Exists(levels[levelIndex] + "/LevelData.xml"))
                        {
                            // Delete folders that don't contain a level
                            Directory.Delete(levels[levelIndex], true);
                            levelIndex++;
                        }
                        if (levelIndex < levels.Length)
                        {
                            if (File.Exists(levels[levelIndex] + "/Thumbnail.png"))
                            {
                                FileStream filestream = new FileStream(levels[levelIndex] + "/Thumbnail.png", FileMode.Open);
                                thumbnail = Texture2D.FromStream(MainMethod.device, filestream, 160, 120, true);
                                filestream.Close();
                            }
                            else
                            {
                                thumbnail = Textures.GetCustomThumbnail();
                            }
                            LevelButton.lvButtonList.Add(new CustomLevelButton(levels[levelIndex], new Vector2((float)((220 * (i % 3)) + 80), (float)((220 * (j % 2)) + 0x69)), thumbnail));
                            levelIndex++;
                        }
                    }
                }
                int    x           = (LevelButton.lvButtonList.Count) % 3;
                int    y           = (int)Math.Floor((LevelButton.lvButtonList.Count) / 3f) % 2;
                int    levelSuffix = LevelButton.lvButtonList.Count;
                string name        = "";
                do
                {
                    levelSuffix++;
                    name = "Untitled" + levelSuffix;
                } while (LevelButton.lvButtonList.Exists(item => (item as CustomLevelButton).Name == name));

                LevelButton.lvButtonList.Add(new NewLevelButton(name, new Vector2((float)((220 * (x % 3)) + 80), (float)((220 * (y % 2)) + 0x69))));
            }

            if (LevelButton.lvButtonList.Count < 7)
            {
                Button.ButtonList[1].Active = false;
            }
        }