Ejemplo n.º 1
0
            async void SaveAsButtonReleased(ReleasedEventArgs args)
            {
                if (Level.LevelRep.GamePack.TryGetLevel(name, out LevelRep oldLevel))
                {
                    bool confirm = await MenuUIManager.ConfirmationPopUp.RequestConfirmation("Override level",
                                                                                             "Do you want to override existing level with the same name?",
                                                                                             null,
                                                                                             proxy);

                    if (!confirm)
                    {
                        return;
                    }
                }

                LevelRep newLevelRep = null;

                try {
                    newLevelRep = Level.LevelRep.CreateClone(name, description, ThumbnailPath);
                    newLevelRep.SaveToGamePack(true);
                    MenuUIManager.SwitchBack();
                }
                catch (Exception) {
                    newLevelRep?.Dispose();
                    await MenuUIManager.ErrorPopUp.DisplayError("Package Error",
                                                                "There was an error while saving the level to package, see log for details.",
                                                                proxy);
                }
            }
Ejemplo n.º 2
0
 protected override void Released(ReleasedEventArgs args)
 {
     if (controllingMovement)
     {
         StopMovementControl();
     }
 }
Ejemplo n.º 3
0
 void CloseButtonReleased(ReleasedEventArgs obj)
 {
     underlyingMenuScreen?.ResetInput();
     //Dummy boolean value, publicly the task present as plain Task without return value
     taskSource.SetResult(false);
     proxy.Hide();
 }
Ejemplo n.º 4
0
            void LevelManipulatingButtonPressed(ReleasedEventArgs args)
            {
                var selectedItem = GetSelectedItem();

                if (selectedItem == null)
                {
                    throw new
                          InvalidOperationException("Level manipulation button was enabled and pressed while no level was selected");
                }

                switch (args.Element.Name)
                {
                case DeleteButtonName:
                    DeleteLevel(selectedItem);
                    break;

                case EditButtonName:
                    EditLevel(selectedItem);
                    break;

                case PlayButtonName:
                    PlayLevel(selectedItem);
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(args), args.Element.Name, "Unknown button pressed");
                }
            }
Ejemplo n.º 5
0
            void ButtonReleased(ReleasedEventArgs args)
            {
                switch (args.Element.Name)
                {
                case ResumeButton:
                    Resume();
                    break;

                case SaveButton:
                    SaveGame();
                    break;

                case LoadButton:
                    LoadGame();
                    break;

                case OptionsButton:
                    GoToOptions();
                    break;

                case ExitButton:
                    Exit();
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(args.Element.Name), args.Element.Name, "Unknown button released");
                }
            }
Ejemplo n.º 6
0
            async void AddButtonReleased(ReleasedEventArgs obj)
            {
                IPathResult result = await MenuUIManager
                                     .FileBrowsingPopUp
                                     .Request(Game.Files.PackageDirectoryPath,
                                              SelectOption.File);

                if (result == null)
                {
                    return;
                }

                try {
                    var newPack = Game.PackageManager.AddGamePack(result.RelativePath);
                    AddItem(newPack);
                }
                catch (FatalPackagingException e) {
                    Game.ErrorExit(e.Message);
                }
                catch (ArgumentException e) {
                    await MenuUIManager.ErrorPopUp.DisplayError("Error", e.Message, proxy);
                }
                catch (PackageLoadingException e) {
                    await MenuUIManager.ErrorPopUp.DisplayError("Error", e.Message, proxy);
                }
            }
Ejemplo n.º 7
0
        private void OnHoldedListReleased(object sender, ReleasedEventArgs <ServerEntry> e)
        {
            var index = _removeWhenReleased.IndexOf(e.Value);

            if (index != -1)
            {
                _removeWhenReleased.RemoveAt(index);
                List.Remove(e.Value);
            }
        }
Ejemplo n.º 8
0
            void SelectButtonPressed(ReleasedEventArgs obj)
            {
                if (totalMatch != null)
                {
                    Debug.Assert(SelectEntry(totalMatch), "Select button was enabled with totalMatch an unselectable item");

                    Selected(totalMatch.Name, totalMatch.IsDirectory);
                }
                else
                {
                    Debug.Assert(currentDirMatch, "Nothing was there to select even though select button was enabled");

                    Selected("", true);
                }
            }
Ejemplo n.º 9
0
            async void BackButton_Released(ReleasedEventArgs args)
            {
                if (changed)
                {
                    bool confirmed = await MenuUIManager.ConfirmationPopUp
                                     .RequestConfirmation("Exit config",
                                                          "Do you wish to revert these settings to their previous state?",
                                                          null,
                                                          proxy);

                    ExitConfirmation(confirmed);
                }
                else
                {
                    ExitConfirmation(true);
                }
            }
Ejemplo n.º 10
0
            void RemoveButtonReleased(ReleasedEventArgs obj)
            {
                PackageListItem selectedItem = GetSelectedItem();

                try {
                    Game.PackageManager.RemoveGamePack(selectedItem.Pack);
                    RemoveItem(selectedItem);
                }
                catch (FatalPackagingException e) {
                    Game.ErrorExit(e.Message);
                }
                catch (ArgumentException e) {
                    MenuUIManager.ErrorPopUp.DisplayError("Error", e.Message, proxy);
                }
                catch (PackageLoadingException e) {
                    MenuUIManager.ErrorPopUp.DisplayError("Error", e.Message, proxy);
                }
            }
Ejemplo n.º 11
0
            async void SaveButton_Released(ReleasedEventArgs args)
            {
                if (changed)
                {
                    Game.Config.SetGraphicsMode(Game.Graphics);

                    bool confirmed = await MenuUIManager.ConfirmationPopUp
                                     .RequestConfirmation("Save config",
                                                          "Do you wish to save these settings ?",
                                                          TimeSpan.FromSeconds(10),
                                                          proxy);

                    SaveConfirmation(confirmed);
                }
                else
                {
                    SaveConfirmation(true);
                }
            }
Ejemplo n.º 12
0
            void PlayButtonReleased(ReleasedEventArgs args)
            {
                PlayerItem neutralPlayerItem = ((PlayerItem)playerList.GetItem(0));


                PlayerItem humanPlayerItem = ((PlayerItem)playerList.GetItem(1));
                List <Tuple <PlayerType, int, PlayerInsignia> > aiPlayers = new List <Tuple <PlayerType, int, PlayerInsignia> >();

                for (uint i = 2; i < playerList.NumItems; i++)
                {
                    PlayerItem item = (PlayerItem)playerList.GetItem(i);
                    aiPlayers.Add(Tuple.Create(item.ChosenType, item.ChosenTeam, item.Insignia));
                }

                //Has to be last statement in the method, this instance will be released during execution.
                proxy.Play(neutralPlayerItem.ChosenType,
                           Tuple.Create(humanPlayerItem.ChosenType, humanPlayerItem.ChosenTeam, humanPlayerItem.Insignia),
                           aiPlayers,
                           pluginCustomSettings);
            }
Ejemplo n.º 13
0
            async void ThumbnailPathButtonReleased(ReleasedEventArgs args)
            {
                try
                {
                    string oldPath = thumbnailPathText.Value;

                    var result = await MenuUIManager.
                                 FileBrowsingPopUp.
                                 Request(Game.PackageManager.ActivePackage.RootedDirectoryPath,
                                         SelectOption.File,
                                         thumbnailPathText.HasDefaultValue?null : thumbnailPathText.Value);


                    string newPath = result == null ? oldPath : result.RelativePath;
                    await MHUrhoApp.InvokeOnMainSafeAsync(() => thumbnailPathText.Value = newPath);
                }
                catch (OperationCanceledException)
                {
                    //Text should not have changed
                }
            }
Ejemplo n.º 14
0
 void Button_Released(ReleasedEventArgs args)
 {
     timeoutCancel?.Cancel();
     Reply(args.Element == confirmButton);
 }
Ejemplo n.º 15
0
 protected abstract void Released(ReleasedEventArgs args);
Ejemplo n.º 16
0
 void BackButtonReleased(ReleasedEventArgs obj)
 {
     Cancel();
 }
Ejemplo n.º 17
0
 void SelectButtonReleased(ReleasedEventArgs args)
 {
     proxy.ItemSelectionConfirmed(GetSelectedItem());
 }
Ejemplo n.º 18
0
 void ButtonPressed(ReleasedEventArgs obj)
 {
     //Log.Write(LogLevel.Debug, "Button pressed");
     ExecuteButtonPressAction(obj.Element.Name);
 }
Ejemplo n.º 19
0
 void BackButtonReleased(ReleasedEventArgs args)
 {
     MenuUIManager.SwitchBack();
 }