public void Configure(IApplicationBuilder app, Microsoft.AspNetCore.Hosting.IHostingEnvironment env, IPollResultsService pollResults) { app.Use(async(context, next) => { if (context.Request.Query.ContainsKey("favorite")) { string selectedValue = context.Request.Query["favorite"]; SelectedGame selectedGame = (SelectedGame)System.Enum.Parse(typeof(SelectedGame), selectedValue, true); pollResults.AddVote(selectedGame); var gameVotes = pollResults.GetVoteResult(); foreach (var currentVote in gameVotes) { await context.Response.WriteAsync($"<div> Game name: {currentVote.Key}. Votes: {currentVote.Value} </div>"); } } else { await next.Invoke(); } }); app.UseStaticFiles(); app.Run(async(context) => { await context.Response.WriteAsync("This text was generated by the app.Run middleware. wwwroot folder path: " + env.WebRootPath); }); }
public PlayerScoreRecord(PlayerScore playerScore, SelectedGame selectedGame, string playerName, DateTime recordData) { PlayerScore = playerScore; SelectedGame = selectedGame; PlayerName = playerName; RecordDate = recordData; }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IPollResultsService pollResults) { app.Use(async(context, next) => { if (context.Request.Query.ContainsKey("favorite")) { string selectedValue = context.Request.Query["favorite"]; SelectedGame selectedGame = (SelectedGame)Enum.Parse(typeof(SelectedGame), selectedValue, true); pollResults.AddVote(selectedGame); SortedDictionary <SelectedGame, int> gameVotes = pollResults.GetVoteResult(); foreach (KeyValuePair <SelectedGame, int> currentVote in gameVotes) { await context.Response.WriteAsync($"<div> Game name: {currentVote.Key}. Votes: {currentVote.Value} </div>"); } } else { await next.Invoke(); } }); app.UseStaticFiles(); app.UseMvcWithDefaultRoute(); app.Run(async(context) => { await context.Response.WriteAsync("This text was generated by the app.Run middleware."); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, IPollResultsService pollResults) { app.Use(async(context, next) => { if (context.Request.Query.ContainsKey("favorite")) { string selectedValue = context.Request.Query["favorite"]; SelectedGame selectedGame = (SelectedGame)Enum.Parse(typeof(SelectedGame), selectedValue, true); pollResults.AddVote(selectedGame); await context.Response.WriteAsync($"Thank you for submitting the poll."); } else { await next.Invoke(); } }); app.UseStaticFiles(); app.UseMvcWithDefaultRoute(); app.Run(async(context) => { await context.Response.WriteAsync("This text was generated by the app.Run middleware. wwwroot folder path: " + env.WebRootPath); }); }
//public void Configure(IApplicationBuilder app) public void Configure(IApplicationBuilder app, IHostingEnvironment env, IPollResultsService pollResults) { app.Use(async(context, next) => { if (context.Request.Query.ContainsKey("favorite")) { string selectedValue = context.Request.Query["favorite"]; SelectedGame selectedGame = (SelectedGame)Enum.Parse(typeof(SelectedGame), selectedValue, true); pollResults.AddVote(selectedGame); //await context.Response.WriteAsync("Selected value is: " + selectedValue); //SortedDictionary<SelectedGame, int> gameVotes = pollResults.GetVoteResult(); //foreach (KeyValuePair<SelectedGame, int> currentVote in gameVotes) //{ // await context.Response.WriteAsync($"<div> Game name: {currentVote.Key}. Votes: {currentVote.Value} </div>"); //} context.Response.Headers.Add("content-type", "text/html"); await context.Response.WriteAsync("Thank you for submitting the poll. You may look at the poll results <a href='/?submitted=true'>Here</a>."); } else { await next.Invoke(); } }); app.UseStaticFiles(); app.UseMvcWithDefaultRoute(); app.Run(async(context) => { //await context.Response.WriteAsync("This text was generated by the app.Run middleware."); await context.Response.WriteAsync("This text was generated by the app.Run middleware. wwwroot folder path: " + env.WebRootPath); }); }
private void SaveAndClose() { StringBuilder sb = new StringBuilder(); sb.AppendLine(SelectedGame.ToString()); sb.AppendLine(GroupName); sb.AppendLine(Utilities.ConvertNewlineToBr(GroupDescription)); var libraryRoot = Utilities.GetModDirectoryForGame(SelectedGame); foreach (var m in ModsInGroup) { sb.AppendLine(m.ModDescPath.Substring(libraryRoot.Length + 1)); //STORE RELATIVE! } var batchfolder = Utilities.GetBatchInstallGroupsFolder(); if (existingFilename != null) { var existingPath = Path.Combine(batchfolder, existingFilename); if (File.Exists(existingPath)) { File.Delete(existingPath); } } var savePath = getSaveName(GroupName); File.WriteAllText(savePath, sb.ToString()); SavedPath = savePath; Close(); //OnClosing(new DataEventArgs(savePath)); }
public override int GetHashCode() { var hashCode = 2107766179; hashCode = hashCode * -1521134295 + SelectedGame.GetHashCode(); hashCode = hashCode * -1521134295 + Score.GetHashCode(); return(hashCode); }
private void InitialiseAllPlayers() { foreach (var participatingPlayer in ParticipatingPlayers) { participatingPlayer.InitPlayer(SelectedSet, SelectedLeg, SelectedGame.GetStartingScore(participatingPlayer.PlayerDetails), _matchWon); } }
public override int GetHashCode() { var hashCode = 2020233827; hashCode = hashCode * -1521134295 + PlayerScore.GetHashCode(); hashCode = hashCode * -1521134295 + SelectedGame.GetHashCode(); hashCode = hashCode * -1521134295 + PlayerName.GetHashCode(); hashCode = hashCode * -1521134295 + RecordDate.GetHashCode(); return(hashCode); }
public void AddVote(SelectedGame game) { if (SelectionVotes.ContainsKey(game)) { SelectionVotes[game]++; } else { SelectionVotes.Add(game, 1); } }
void IPollResultsService.AddVote(SelectedGame game) { if (_selectionVotes.ContainsKey(game)) { _selectionVotes[game]++; } else { _selectionVotes.Add(game, 1); } }
public string this[string columnName] { get { if (columnName == nameof(InstallDir)) { return(SelectedGame?.ValidateGamePath(InstallDir)); } return(null); } }
private void NewButton_Click(object sender, RoutedEventArgs e) { var newMod = new NewModDialog() { Owner = this }; var result = newMod.ShowDialog(); if (!result.HasValue || !result.Value) { return; } // Get unique directory string modPath = Path.Combine(ModDatabase.ModDirectory, SelectedGame.ToString(), newMod.ModTitle); if (Directory.Exists(modPath)) { var newModPath = modPath; int i = 0; while (Directory.Exists(newModPath)) { newModPath = modPath + "_" + i++; } modPath = newModPath; } // Build mod var mod = new ModBuilder() .SetGame(SelectedGame) .SetTitle(newMod.ModTitle) .SetDescription(newMod.Description) .SetVersion(newMod.Version) .SetDate(DateTime.UtcNow.ToShortDateString()) .SetAuthor(newMod.Author) .SetUrl(newMod.Url) .SetUpdateUrl(newMod.UpdateUrl) .SetBaseDirectoryPath(modPath) .Build(); // Do actual saving var modLoader = new XmlModLoader(); modLoader.Save(mod); // Reload RefreshModDatabase(); }
public bool Equals(PlayerScoreRecord other) { if (other == null) { return(false); } if (other.GetType() != this.GetType()) { return(false); } return(PlayerScore.Equals(other.PlayerScore) && SelectedGame.Equals(other.SelectedGame) && PlayerName == other.PlayerName && RecordDate == other.RecordDate); }
private void saveCurrentSettingsToolStripMenuItem_Click(object sender, EventArgs e) { // save current properties Properties.Settings.Default.GameType = SelectedGame.ToString(); Properties.Settings.Default.UpperClockName = clock1.ClockName; Properties.Settings.Default.UpperClockColor = clock1.ClockColor; Properties.Settings.Default.UpperClockTextColor = clock1.TextColor; Properties.Settings.Default.UpperClockStartKey = clock1.StartKey; Properties.Settings.Default.UpperClockStartKeyChar = clock1.StartKeyChar; Properties.Settings.Default.LowerClockName = clock2.ClockName; Properties.Settings.Default.LowerClockColor = clock2.ClockColor; Properties.Settings.Default.LowerClockTextColor = clock2.TextColor; Properties.Settings.Default.LowerClockStartKey = clock2.StartKey; Properties.Settings.Default.LowerClockStartKeyChar = clock2.StartKeyChar; Properties.Settings.Default.Save(); }
protected void newmodclick(object sender, EventArgs e) { GTKFrontend.NewModDialog newMod = new GTKFrontend.NewModDialog(); if (newMod.Run() != (int)ResponseType.Ok) { newMod.Destroy(); return; } // Get unique directory string modPath = System.IO.Path.Combine(ModDatabase.ModDirectory, SelectedGame.ToString(), newMod.ModTitle); if (Directory.Exists(modPath)) { var newModPath = modPath; int i = 0; while (Directory.Exists(newModPath)) { newModPath = modPath + "_" + i++; } modPath = newModPath; } // Build mod var mod = new ModBuilder() .SetGame(SelectedGame) .SetTitle(newMod.ModTitle) .SetDescription(newMod.Description) .SetVersion(newMod.Version) .SetDate(DateTime.UtcNow.ToShortDateString()) .SetAuthor(newMod.Author) .SetUrl(newMod.Url) .SetUpdateUrl(newMod.UpdateUrl) .SetBaseDirectoryPath(modPath) .Build(); // Do actual saving var modLoader = new XmlModLoader(); modLoader.Save(mod); // Reload RefreshModDatabase(); }
private void UpdateGameSelected() { this.gameInfoGrid.Clear(); if (SelectedGame == null) { return; } var gameInfoRows = SelectedGame.GetGridRows(); foreach (var gameInfoRow in gameInfoRows.OrderBy(r => r.Order)) { this.gameInfoGrid.Add(gameInfoRow); } NotifyOfPropertyChange(() => GameInfoGrid); }
private void LoadGameData() { if (SelectedGame == null) { return; } InstallDir = _config[SelectedGame.Id].InstallDir; if (string.IsNullOrWhiteSpace(InstallDir) && SelectedGame.DefaultPaths != null) { foreach (string defaultPath in SelectedGame.DefaultPaths) { if (SelectedGame.ValidateGamePath(defaultPath) == null) { InstallDir = defaultPath; break; } } } CheckIfGameIsPatched(); }
private void InitialiseParticipatingPlayers() { ParticipatingPlayers.Clear(); for (var i = 1; i <= SelectedPlayers; i++) { var player = new Player(i); // Set up the player details for each participant if (ConfiguredPlayers.Count >= i) { player.CurrentScore = SelectedGame.GetStartingScore(ConfiguredPlayers[i - 1].PlayerDetails); player.PlayerDetails = ConfiguredPlayers[i - 1].PlayerDetails; } else { player.CurrentScore = SelectedGame.GetStartingScore(null); } ParticipatingPlayers.Add(player); } }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, IPollResultsService pollResults) { app.UseStaticFiles(); app.Use(async(context, next) => { await context.Response.WriteAsync( "This text was generated by the app.Run middleware. wwwroot folder path: " + env.WebRootPath); string selectedValue = context.Request.Query["favorite"]; SelectedGame selectedGame = (SelectedGame)Enum .Parse(typeof(SelectedGame), selectedValue, true); pollResults.AddVote(selectedGame); await context.Response.WriteAsync("Selected value is: " + selectedValue); }); app.UseRouting(); app.Run(async(context) => { await context.Response.WriteAsync("This text was generated by the app.Run middleware."); }); }
public AddGameViewModel(IGamesService gamesService, IFlyoutService flyoutService) { _gamesService = gamesService; _flyoutService = flyoutService; WhenStateUpdated(() => SelectedGame, () => { if (SelectedGame == null) { return; } HasExistingGame = false; if (gamesService.Games.Any(g => String.Equals(g.Name, SelectedGame.Name, StringComparison.InvariantCultureIgnoreCase))) { HasExistingGame = true; } else { NewGame = SelectedGame.ToGame(); } HasNewGame = !HasExistingGame && NewGame != null; }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, IPollResultsService pollResults) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseMvcWithDefaultRoute(); app.Use(async(context, next) => { if (context.Request.Query.ContainsKey("Favorite")) { string selectedValue = context.Request.Query["Favorite"]; SelectedGame selectedGame = (SelectedGame)Enum.Parse(typeof(SelectedGame), selectedValue); pollResults.AddVote(selectedGame); SortedDictionary <SelectedGame, int> gameVotes = pollResults.GetVoteResult(); foreach (KeyValuePair <SelectedGame, int> currentVote in gameVotes) { await context.Response.WriteAsync($"<p> Game name: {currentVote.Key}, Votes: {currentVote.Value} </p>"); } } else { await next.Invoke(); } }); app.UseStaticFiles(); app.Run(async(context) => { await context.Response.WriteAsync("Action was not handled by any middleware. App run is executing. wwwroot folder path: " + env.WebRootPath); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. //public void Configure(IApplicationBuilder app, IHostingEnvironment env) public void Configure(IApplicationBuilder app, IHostingEnvironment env, IPollResultsService pollResults) { app.Use(async(context, next) => { if (context.Request.Query.ContainsKey("favorite")) { string selectedValue = context.Request.Query["favorite"]; SelectedGame selectedGame = (SelectedGame)Enum.Parse(typeof(SelectedGame), selectedValue, true); pollResults.AddVote(selectedGame); //await context.Response.WriteAsync("Selected value is: " + selectedValue); SortedDictionary <SelectedGame, int> gameVotes = pollResults.GetVoteResult(); foreach (KeyValuePair <SelectedGame, int> currentVote in gameVotes) { await context.Response.WriteAsync($"<div> Game name: {currentVote.Key}. Votes: {currentVote.Value} </div>"); } await context.Response.WriteAsync("This text was generated by the app.Run middleware. wwwroot folder path: " + env.WebRootPath); } else { await next.Invoke(); } }); app.UseStaticFiles(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.Run(async(context) => { await context.Response.WriteAsync("Hello World!"); }); }
public void Configure(IApplicationBuilder app, Microsoft.AspNetCore.Hosting.IHostingEnvironment env, IPollResultsService pollResults) { app.Use(async(context, next) => { if (context.Request.Query.ContainsKey("favorite")) { string selectedValue = context.Request.Query["favorite"]; SelectedGame game = (SelectedGame)Enum.Parse(typeof(SelectedGame), selectedValue, true); pollResults.AddVote(game); context.Response.Headers.Add("Content-Type", "text/html"); await context.Response.WriteAsync("Thank you for submitting the poll. You may look at the poll results <a href='/?submitted=true'>Here</a>."); } else { await next.Invoke(); } }); app.UseStaticFiles(); app.UseMvcWithDefaultRoute(); app.Run(async(context) => { await context.Response.WriteAsync("This text was generated by the app.Run middleware. wwwroot folder path: " + env.WebRootPath); }); }
public MainViewModel(IWindow mainWindow) { _mainWindow = mainWindow; UserData = _dal.GetUserData(); RunSelectedGame = new DelegateCommand(() => RunGame(), () => SelectedGame != null && SelectedGame.CanRun(UserData)); RunGameSetup = new DelegateCommand(() => RunGame(true), () => SelectedGame != null && SelectedGame.CanRunSetup(UserData)); RunDOSBox = new DelegateCommand(() => GameProcessController.RunOnlyDOSBox(UserData), () => GameProcessController.CanRunMainDOSBoxVariant(UserData)); NewCategory = new DelegateCommand(NewCategoryMethod, () => IsSelectedCategoryNotNull()); UseLargeIcons = new DelegateCommand(() => { ChangeViewMode(View.LargeIcon); }, () => IsSelectedCategoryNotNull()); UseSmallIcons = new DelegateCommand(() => { ChangeViewMode(View.SmallIcon); }, () => IsSelectedCategoryNotNull()); UseTiles = new DelegateCommand(() => { ChangeViewMode(View.Tile); }, () => IsSelectedCategoryNotNull()); UseList = new DelegateCommand(() => { ChangeViewMode(View.List); }, () => IsSelectedCategoryNotNull()); UseDetails = new DelegateCommand(() => { ChangeViewMode(View.Details); }, () => IsSelectedCategoryNotNull()); EditDefaultConfigFile = new DelegateCommand(() => ConfigEditorRunner.EditDefaultConfigFile(_dal, UserData), () => ConfigEditorRunner.CanRunConfigEditor(UserData)); RunConfigEditor = new DelegateCommand(() => ConfigEditorRunner.RunConfigEditor(_dal, UserData), () => ConfigEditorRunner.CanOpenDefaultConfigFile(UserData)); NewGame = new DelegateCommand(() => { }, () => { return(IsSelectedCategoryNotNull()); }); OpenGameFolder = new DelegateCommand(() => { if (SelectedGame != null) { SelectedGame.OpenGameFolder(); } }, () => SelectedGame != null && SelectedGame.HasAGameFolder()); EditSelectedGameConfigFile = new DelegateCommand(() => { if (SelectedGame != null) { _ = SelectedGame.EditConfigFile(_dal); } }, () => SelectedGame != null && SelectedGame.HasACustomConfigFile()); EditSelectedGame = new DelegateCommand(() => { }); MakeConfigFileForSelectedGame = new DelegateCommand(() => { }); EditSelectedCategory = new DelegateCommand(() => { }); DeleteSelectedGame = new DelegateCommand(() => { }); DeleteSelectedCategory = new DelegateCommand(() => { }); ImportAmpShellData = new DelegateCommand(() => { }); OrderByName = new DelegateCommand(() => { }); OrderByNameReversed = new DelegateCommand(() => { }); OrderByReleaseDate = new DelegateCommand(() => { }); }
public HighScore(SelectedGame selectedGame, int score) { SelectedGame = selectedGame; Score = score; }
private void displayOnlineJoin(ref int ypos, int spacing, int width, int height) { if (!NetworkServer.active && !NetworkClient.active) { ypos += 10; if (this.manager.matchMaker == null) { this.manager.StartMatchMaker(); } else { if (this.manager.matchInfo == null) { if (this.showMatches && !this.hasMatches) { GUI.Label(new Rect(Screen.width / 2 - width * 3 / 2, ypos, width * 3, height), "No matches found", this.hudStyle); ypos += spacing; } if (this.manager.matches == null) { ypos += 10; if (GUI.Button(new Rect(Screen.width / 2 - width * 3 / 2, ypos, width * 3, height), "Find Internet Match", this.hudStyle)) { this.showMatches = true; this.manager.matchMaker.ListMatches(0, 20, "", false, 0, 0, this.manager.OnMatchList); } ypos += spacing; } else { this.hasMatches = false; foreach (var match in this.manager.matches) { this.hasMatches = true; if (GUI.Button(new Rect(Screen.width / 2 - width, ypos, width * 2, height), "Join Match:" + match.name, this.hudStyle)) { this.manager.matchName = match.name; this.manager.matchSize = (uint)match.currentSize; this.manager.matchMaker.JoinMatch(match.networkId, "", "", "", 0, 0, this.manager.OnMatchJoined); } ypos += spacing; } } } ypos += spacing; GUI.Label(new Rect(Screen.width / 2 - width * 2, ypos, width * 4, height), "MM Uri: " + this.manager.matchMaker.baseUri, this.hudStyle); ypos += spacing; if (GUI.Button(new Rect(Screen.width / 2 - width / 2, ypos, width, height), "Back", this.hudStyle)) { this.selectedGame = SelectedGame.None; if (this.manager.matchMaker != null) { this.manager.StopMatchMaker(); } this.noGameSelected = true; this.awaitingGame = false; this.hostingGame = false; } ypos += spacing; } } }
private void OnGUI() { if (!this.showGUI) { return; } int ypos = 40 + offsetY; int upperYPos = 40; int height = 100; int width = 400; int spacing = 120; if (this.noGameSelected) { if (GUI.Button(new Rect(Screen.width / 2 - width / 2, ypos, width, height), "Singleplayer", this.hudStyle)) { this.manager.StartHost(); this.noGameSelected = false; this.singleplayer = true; GameSession.Instance.IsSinglePlayer = true; } ypos += spacing; if (GUI.Button(new Rect(Screen.width / 2 - width / 2, ypos, width, height), "Multiplayer", this.hudStyle)) { this.noGameSelected = false; } ypos += spacing; } else { if (!this.awaitingGame && !NetworkClient.active && !NetworkServer.active && this.manager.matchMaker == null) { if (this.selectedGame == SelectedGame.None) { if (GUI.Button(new Rect(Screen.width / 2 - width, ypos, width * 2, height), "LAN Game", this.hudStyle)) { this.selectedGame = SelectedGame.LAN; } ypos += spacing; if (GUI.Button(new Rect(Screen.width / 2 - width, ypos, width * 2, height), "Online Game", this.hudStyle)) { this.selectedGame = SelectedGame.Online; } ypos += spacing; } else if (this.selectedGame == SelectedGame.LAN) { if (GUI.Button(new Rect(Screen.width / 2 - width, ypos, width * 2, height), "Start LAN Game", this.hudStyle)) { this.hostingGame = true; this.awaitingGame = true; this.manager.StartHost(); } ypos += spacing; if (GUI.Button(new Rect(Screen.width / 2 - width, ypos, width * 2, height), "Join LAN Game", this.hudStyle)) { this.hostingGame = false; this.awaitingGame = true; this.manager.StartClient(); } ypos += spacing; } else if (this.selectedGame == SelectedGame.Online) { if (GUI.Button(new Rect(Screen.width / 2 - width, ypos, width * 2, height), "Start Online Game", this.hudStyle)) { this.hostingGame = true; this.awaitingGame = true; } ypos += spacing; if (GUI.Button(new Rect(Screen.width / 2 - width, ypos, width * 2, height), "Join Online Game", this.hudStyle)) { this.hostingGame = false; this.awaitingGame = true; } ypos += spacing; } if (GUI.Button(new Rect(Screen.width / 2 - width / 2, ypos, width, height), "Back", this.hudStyle)) { this.selectedGame = SelectedGame.None; this.noGameSelected = true; this.awaitingGame = false; this.hostingGame = false; this.showMatches = false; this.hasMatches = false; } ypos += spacing; } else { if (this.singleplayer && NetworkClient.active && ClientScene.ready) { this.manager.SetMatchHost("localhost", 1337, false); } if (this.selectedGame == SelectedGame.Online) { if (this.hostingGame) { this.displayOnlineHost(ref ypos, spacing, width, height); } else { this.displayOnlineJoin(ref ypos, spacing, width, height); } } if (NetworkServer.active || NetworkClient.active) { if (GUI.Button(new Rect(0, upperYPos, width, height), "Stop", this.hudStyle)) { this.hostingGame = false; this.selectedGame = SelectedGame.None; this.noGameSelected = true; this.awaitingGame = false; this.showMatches = false; this.hasMatches = false; this.manager.StopHost(); Application.LoadLevel(Application.loadedLevel); } upperYPos += spacing; } } if (NetworkClient.active && !ClientScene.ready && !this.hostingGame) { ClientScene.Ready(this.manager.client.connection); } if (NetworkServer.active) { GUI.Label(new Rect(0, upperYPos, width * 3, height), "Server: port=" + this.manager.networkPort, this.hudStyle); upperYPos += spacing; } if (NetworkClient.active) { if (this.hostingGame) { GUI.Label(new Rect(0, upperYPos, width * 3, height), "Players In Room=" + this.manager.numPlayers, this.hudStyle); upperYPos += spacing; } GUI.Label(new Rect(0, upperYPos, width * 3, height), "Client: address=" + this.manager.networkAddress + " port=" + this.manager.networkPort, this.hudStyle); upperYPos += spacing; } } }
private void NewButton_Click(object sender, RoutedEventArgs e) { var newMod = new NewModDialog() { Owner = this }; var result = newMod.ShowDialog(); if (!result.HasValue || !result.Value) { return; } // Get unique directory string folderPath = Path.Combine(ModDatabase.ModDirectory, SelectedGame.ToString()); string[] gamePath = Directory.GetDirectories(folderPath, "*", SearchOption.AllDirectories); if (FolderComboBox.SelectedItem.ToString() != "All Folders") { foreach (string folder in gamePath) { if (Path.GetFileName(folder) == FolderComboBox.SelectedItem.ToString()) { folderPath = folder; } } } string modPath = Path.Combine(folderPath, newMod.ModTitle); if (Directory.Exists(modPath)) { var newModPath = modPath; int i = 0; while (Directory.Exists(newModPath)) { newModPath = modPath + "_" + i++; } modPath = newModPath; } // Build mod var mod = new ModBuilder() .SetGame(SelectedGame) .SetTitle(newMod.ModTitle) .SetDescription(newMod.Description) .SetVersion(newMod.Version) .SetDate(DateTime.UtcNow.ToShortDateString()) .SetAuthor(newMod.Author) .SetUrl(newMod.Url) .SetUpdateUrl(newMod.UpdateUrl) .SetBaseDirectoryPath(modPath) .Build(); // Do actual saving var modLoader = new XmlModLoader(); modLoader.Save(mod); // Reload RefreshModDatabase(); RefreshMods(); }
public override void OnUserInput(GamesPanel.UserInput inp) { // HACK: for web games launch, make sure that music is turned back on upon next user input after play if (!isGameLaunchOngoing && !GardenGame.Instance.music.IsFadedIn && GardenGame.Instance.music.UserWantsMusic) { GardenGame.Instance.music.FadeIn(); } switch (inp) { case UserInput.DOWN: if (cursor.GridPosition.Y < GridMaxY - 1) { cursor.GridPosition.Y += 1f; SelectGameBelowCursor(); } break; case UserInput.UP: if (cursor.GridPosition.Y > 0) { cursor.GridPosition.Y -= 1f; SelectGameBelowCursor(); } break; case UserInput.LEFT: if (cursor.GridPosition.X > 0) { cursor.GridPosition.X -= 1f; SelectGameBelowCursor(); } break; case UserInput.RIGHT: if (cursor.GridPosition.X < GridMaxX - 1) { cursor.GridPosition.X += 1f; SelectGameBelowCursor(); } break; case UserInput.START_EXIT: isExiting = true; //selectionLevel = 0; Motion.ZoomTarget = PANEL_ZOOM_TARGET_QUITTING; Motion.ZoomSpeed = PANEL_ZOOM_SPEED_REGULAR; infoBox.Motion.TargetPos = INFOBOX_ALL_HIDDEN_POSITION; creditsBitmap.Motion.TargetPos = CREDITS_HIDDEN_POSITION; helpTextBitmap.Motion.TargetPos = HELPTEXT_HIDDEN_POSITION; //Motion.ZoomCenter = cursor.Motion.PositionAbs; //Motion.ZoomCenterTarget = cursor.Motion; break; case UserInput.STOP_EXIT: if (timeExiting < TIME_BEFORE_EXIT_CONTINUES) { isExiting = false; selectionLevel = 0; Motion.ZoomTarget = PANEL_ZOOM_REGULAR; Motion.ZoomSpeed = PANEL_ZOOM_SPEED_ABORTQUITTING; //Motion.ZoomCenter = cursor.Motion.PositionAbs; //Motion.ZoomCenterTarget = cursor.Motion; } break; case UserInput.START_SELECT: if (SelectedGame != null) { GameThumbnail th = null; try { th = thumbnailsCache[SelectedGame.GameID]; } catch (Exception) {; } if (th != null) { switch (selectionLevel) { case 0: // select once - zoom in on selected game Motion.ZoomTarget = PANEL_ZOOM_DETAILED_VIEW; Motion.ZoomSpeed = PANEL_ZOOM_SPEED_REGULAR; // 0.01f; Motion.ZoomCenterTarget = cursor.Motion; SelectedGame.Refresh(); selectionLevel++; break; case 1: // select again - install or launch game if selection key pressed long enough. isGameLaunchOngoing = true; break; } } } break; case UserInput.STOP_SELECT: // if not launched long enough, reset - no action if (timeLaunching < TIME_BEFORE_GAME_LAUNCH) { isGameLaunchConfirmed = false; } else { isGameLaunchConfirmed = true; } isGameLaunchOngoing = false; timeLaunching = 0f; break; case UserInput.LAUNCH_WEBSITE: isLaunchWebsite = true; break; case UserInput.TOGGLE_MUSIC: GardenGame.Instance.music.ToggleMusic(); break; } // switch(inp) if (!isExiting) { if (selectionLevel == 0) { infoBox.Motion.TargetPos = INFOBOX_DESCRIPTION_HIDDEN_POSITION; } if (selectionLevel == 1 && SelectedGame != null) { int lnCount = SelectedGame.DescriptionLineCount; infoBox.Motion.TargetPos = INFOBOX_SHOWN_POSITION - new Vector2(0f, 0.015f + 0.029f * (lnCount - 1)); } if (SelectedGame == null || SelectedGame.Name.Length == 0) { infoBox.Motion.TargetPos = INFOBOX_ALL_HIDDEN_POSITION; } } }