Exemple #1
0
            public Screen(LevelSettingsScreen proxy, out string errorMessage)
                : base(proxy)
            {
                this.proxy = proxy;
                Game.UI.LoadLayoutToElement(MenuUIManager.MenuRoot, Game.ResourceCache, "UI/LevelSettingsScreenLayout.xml");

                window = (Window)MenuUIManager.MenuRoot.GetChild("LevelSettingsWindow");

                customSettingsWindow = (Window)window.GetChild("CustomSettings", true);

                UIElement descriptionTextElement = Game.UI.LoadLayout(Game.PackageManager.GetXmlFile("UI/DescriptionTextLayout.xml", true),
                                                                      MenuUIManager.MenuRoot.GetDefaultStyle());

                descriptionText       = (Text)descriptionTextElement.GetChild("DescriptionText");
                descriptionText.Value = Level.Description;
                descriptionScrollView = (ScrollView)window.GetChild("DescriptionScrollView", true);

                descriptionScrollView.ContentElement = descriptionTextElement;

                mapImage           = (BorderImage)window.GetChild("MapImage");
                mapImage.Texture   = Level.Thumbnail;
                mapImage.ImageRect = new Urho.IntRect(0, 0, Level.Thumbnail.Width, Level.Thumbnail.Height);

                playerList = (ListView)window.GetChild("PlayerListView");

                ((Button)window.GetChild("PlayButton", true)).Released += PlayButtonReleased;
                ((Button)window.GetChild("BackButton", true)).Released += BackButtonReleased;

                InsigniaGetter insigniaGetter = new InsigniaGetter();

                PlayerItem.CreateAndAddToList(playerList,
                                              this,
                                              insigniaGetter.MarkUsed(PlayerInsignia.NeutralPlayerInsignia),
                                              0,
                                              PlayerTypeCategory.Neutral);

                PlayerItem.CreateAndAddToList(playerList,
                                              this,
                                              insigniaGetter.GetNextUnusedInsignia(),
                                              1,
                                              PlayerTypeCategory.Human);

                for (int i = 0; i < Level.MaxNumberOfPlayers - 1; i++)
                {
                    PlayerItem.CreateAndAddToList(playerList, this, insigniaGetter.GetNextUnusedInsignia(), i + 2, PlayerTypeCategory.AI);
                }

                try {
                    pluginCustomSettings = Level.LevelLogicType.GetCustomSettings(customSettingsWindow, Game);
                    errorMessage         = null;
                }
                catch (Exception e) {
                    string message =
                        $"Level plugin threw an exception when getting the Custom settings window contents: {e.Message}";
                    Urho.IO.Log.Write(Urho.LogLevel.Error, message);
                    pluginCustomSettings = null;
                    errorMessage         = message;
                }
            }