/// <summary> /// Collects and condenses the list of server settings that belong /// in Game.ini /// </summary> /// /// <returns>The finalized list of server settings ready for writing to file</returns> private List <String> generateGameIni() { List <String> settings = new List <string>(); float[] floatValues = { float.Parse(resourceReplenishPlayer.Text), float.Parse(resourceReplenishStructure.Text), float.Parse(matingInterval.Text), float.Parse(eggHatch.Text), float.Parse(babyMature.Text), float.Parse(babyFood.Text), float.Parse(eggInterval.Text), float.Parse(poopInterval.Text), float.Parse(cropDecay.Text), float.Parse(structureDamageCooldown.Text), float.Parse(dinoHarvestDamage.Text), float.Parse(playerHarvestDamage.Text), float.Parse(dinoTurretDamage.Text), float.Parse(pvpRespawn.Text), float.Parse(pvpRespawnMultiplier.Text), float.Parse(pvpRespawnBase.Text) }; Boolean[] boolValues = { (Boolean)passiveDefenseDamageDinos.IsChecked, (Boolean)pvpRespwanInterval.IsChecked, (Boolean)autoPve.IsChecked, (Boolean)autoPveUsesSystemTime.IsChecked }; GameIni game = new GameIni( int.Parse(levelCap.Text), Reference.xpStep, int.Parse(engramStep.Text), int.Parse(lvlStep.Text), levelGrid, dinoGrid, engramGrid, (Boolean)overrideVanilla.IsChecked ); settings = game.write(boolValues, floatValues); return(settings); }
/// <summary> /// Collects and condenses the list of server settings that belong /// in Game.ini /// </summary> /// /// <returns>The finalized list of server settings ready for writing to file</returns> private List<String> generateGameIni() { List<String> settings = new List<string>(); float[] floatValues = { float.Parse(resourceReplenishPlayer.Text), float.Parse(resourceReplenishStructure.Text), float.Parse(matingInterval.Text), float.Parse(eggHatch.Text), float.Parse(babyMature.Text), float.Parse(babyFood.Text), float.Parse(eggInterval.Text), float.Parse(poopInterval.Text), float.Parse(cropDecay.Text), float.Parse(structureDamageCooldown.Text), float.Parse(dinoHarvestDamage.Text), float.Parse(playerHarvestDamage.Text), float.Parse(dinoTurretDamage.Text), float.Parse(pvpRespawn.Text), float.Parse(pvpRespawnMultiplier.Text), float.Parse(pvpRespawnBase.Text) }; Boolean[] boolValues = { (Boolean)passiveDefenseDamageDinos.IsChecked, (Boolean)pvpRespwanInterval.IsChecked, (Boolean)autoPve.IsChecked, (Boolean)autoPveUsesSystemTime.IsChecked }; GameIni game = new GameIni( int.Parse(levelCap.Text), Reference.xpStep, int.Parse(engramStep.Text), int.Parse(lvlStep.Text), levelGrid, dinoGrid, engramGrid, (Boolean)overrideVanilla.IsChecked ); settings = game.write(boolValues, floatValues); return settings; }
/// <summary> /// Saves the server settings when clicked /// </summary> /// /// <param name="sender">The object that sent the event</param> /// <param name="e">Arguments for the event</param> private void generateClick(object sender, RoutedEventArgs e) { List <String> errors = validate(); if (errors.Count > 0) { String error = ""; foreach (String err in errors) { error += err + "\n"; } MessageBox.Show(error); } else { // Ensure server is installed String serverExe = Reference.serversDirectory + serverName.Text + Reference.serverExePath; if (!File.Exists(serverExe)) { updateServer(); } // Save ini files List <String> game; List <String> gameUser; game = generateGameIni(); gameUser = generateGameUserIni(); GameIni.saveFile(serverName.Text, game); GameUserIni.saveFile(serverName.Text, gameUser); // Save congifuration file String[] configKeys = { "serverName", "mods", "map" }; String[] values = { serverName.Text, modList.Text, serverMap.Text }; ConfigData serverConfig = new ConfigData("serverData", Reference.serversDirectory + serverName.Text); List <String> settings = new List <String>(); for (int i = 0; i < configKeys.Length; i++) { settings.Add(configKeys[i] + "=" + values[i]); } serverConfig.write(settings); } }