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); } }
protected override void Released(ReleasedEventArgs args) { if (controllingMovement) { StopMovementControl(); } }
void CloseButtonReleased(ReleasedEventArgs obj) { underlyingMenuScreen?.ResetInput(); //Dummy boolean value, publicly the task present as plain Task without return value taskSource.SetResult(false); proxy.Hide(); }
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"); } }
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"); } }
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); } }
private void OnHoldedListReleased(object sender, ReleasedEventArgs <ServerEntry> e) { var index = _removeWhenReleased.IndexOf(e.Value); if (index != -1) { _removeWhenReleased.RemoveAt(index); List.Remove(e.Value); } }
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); } }
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); } }
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); } }
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); } }
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); }
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 } }
void Button_Released(ReleasedEventArgs args) { timeoutCancel?.Cancel(); Reply(args.Element == confirmButton); }
protected abstract void Released(ReleasedEventArgs args);
void BackButtonReleased(ReleasedEventArgs obj) { Cancel(); }
void SelectButtonReleased(ReleasedEventArgs args) { proxy.ItemSelectionConfirmed(GetSelectedItem()); }
void ButtonPressed(ReleasedEventArgs obj) { //Log.Write(LogLevel.Debug, "Button pressed"); ExecuteButtonPressAction(obj.Element.Name); }
void BackButtonReleased(ReleasedEventArgs args) { MenuUIManager.SwitchBack(); }