public DeathTreasure SaveDeathTreasureForm() { var saveProfileData = new DeathTreasure(); saveProfileData.DTdid = MainWindow.ConvertToInteger(tbDeathTreasureDID.Text); saveProfileData.Tier = MainWindow.ConvertToInteger(tbTier.Text); saveProfileData.LootQualityMod = float.Parse(tbLootQualityMod.Text); saveProfileData.UnknownChances = MainWindow.ConvertToInteger(tbUnknownChances.Text); saveProfileData.ItemChance = MainWindow.ConvertToInteger(tbItemChance.Text); saveProfileData.ItemMinAmount = MainWindow.ConvertToInteger(tbItemMinAmount.Text); saveProfileData.ItemMaxAmount = MainWindow.ConvertToInteger(tbItemMaxAmount.Text); saveProfileData.ItemTreasureTypeSelectionChances = cbItemTreasureType.SelectedIndex + 1; saveProfileData.MagicItemChance = MainWindow.ConvertToInteger(tbMagicItemChance.Text); saveProfileData.MagicItemMinAmount = MainWindow.ConvertToInteger(tbMagicItemMinAmount.Text); saveProfileData.MagicItemMaxAmount = MainWindow.ConvertToInteger(tbMagicItemMaxAmount.Text); saveProfileData.MagicItemTreasureTypeSelectionChances = cbMagicItemTreasureType.SelectedIndex + 1; saveProfileData.MundaneItemChance = MainWindow.ConvertToInteger(tbMundaneItemChance.Text); saveProfileData.MundaneItemMinAmount = MainWindow.ConvertToInteger(tbMundaneItemMinAmount.Text); saveProfileData.MundaneItemMaxAmount = MainWindow.ConvertToInteger(tbMundaneItemMaxAmount.Text); saveProfileData.MundaneItemTreasureTypeSelectionChances = cbMundaneItemTreasureType.SelectedIndex + 1; saveProfileData.LastModified = string.Format("{0:yyyy-MM-dd hh:mm:ss}", DateTime.Now); return(saveProfileData); }
public static void SaveDeathTreasureFile(DeathTreasure filedata, string myfilename) { // Saves sql file string header = $"DELETE FROM `treasure_death` WHERE `treasure_Type` = {filedata.DTdid}; \n\n" + "INSERT INTO `treasure_death` (`treasure_Type`, `tier`, `loot_Quality_Mod`, `unknown_Chances`, `item_Chance`, `item_Min_Amount`, `item_Max_Amount`, `item_Treasure_Type_Selection_Chances`, `magic_Item_Chance`, `magic_Item_Min_Amount`, `magic_Item_Max_Amount`, `magic_Item_Treasure_Type_Selection_Chances`, `mundane_Item_Chance`, `mundane_Item_Min_Amount`, `mundane_Item_Max_Amount`, `mundane_Item_Type_Selection_Chances`, `last_Modified`)\n"; string dateModified = string.Format("'{0:yyyy-MM-dd hh:mm:ss}');", DateTime.Now); string dtData = $"VALUES ({filedata.DTdid}, {filedata.Tier}, {filedata.LootQualityMod}, {filedata.UnknownChances}, " + $"{filedata.ItemChance}, {filedata.ItemMinAmount}, {filedata.ItemMaxAmount}, {filedata.ItemTreasureTypeSelectionChances}, " + $"{filedata.MagicItemChance}, {filedata.MagicItemMinAmount}, {filedata.MagicItemMaxAmount}, {filedata.MagicItemTreasureTypeSelectionChances}, " + $"{filedata.MundaneItemChance}, {filedata.MundaneItemMinAmount}, {filedata.MundaneItemMaxAmount}, {filedata.MundaneItemTreasureTypeSelectionChances}," + dateModified; File.WriteAllText(myfilename, header + dtData); }
private void btnLootProfileOpen_Click(object sender, RoutedEventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Title = "Open DeathTreasure File"; ofd.Filter = "All Weenie Types|*.sql|SQL files|*.sql"; ofd.InitialDirectory = WeenieFabUser.Default.DefaultSqlPath; Nullable <bool> result = ofd.ShowDialog(); if (result == true) { var formData = new DeathTreasure(); formData = OpenLootProfileFile(ofd.FileName); FillForm(formData); } }
public static DeathTreasure OpenLootProfileFile(string filepath) { // Opens sql file var profileData = new DeathTreasure(); foreach (string line in File.ReadLines(filepath)) { if (line.Contains("VALUES")) { string dtRegEx = @"VALUES\s*\((\d+),\s(\d+),\s([0-9]*\.[0-9]+|[0-9]+),\s(\d+),\s(\d+),\s(\d+),\s(\d+),\s(\d+),\s(\d+),\s(\d+),\s(\d+),\s(\d+),\s(\d+),\s(\d+),\s(\d+),\s(\d+),.*'(.*)'.*$"; //string linedata = ""; var match = Regex.Match(line, dtRegEx); //string linedata = ""; //linedata = line.Replace("VALUES", ""); //linedata = linedata.Replace("(", ""); //linedata = linedata.Replace(");", ""); //linedata = linedata.Replace("'", ""); //string[] lootProfileValues = linedata.Split(','); profileData.DTdid = MainWindow.ConvertToInteger(match.Groups[1].ToString()); profileData.Tier = MainWindow.ConvertToInteger(match.Groups[2].ToString()); profileData.LootQualityMod = MainWindow.ConvertToFloat(match.Groups[3].ToString()); profileData.UnknownChances = MainWindow.ConvertToInteger(match.Groups[4].ToString()); profileData.ItemChance = MainWindow.ConvertToInteger(match.Groups[5].ToString()); profileData.ItemMinAmount = MainWindow.ConvertToInteger(match.Groups[6].ToString()); profileData.ItemMaxAmount = MainWindow.ConvertToInteger(match.Groups[7].ToString()); profileData.ItemTreasureTypeSelectionChances = MainWindow.ConvertToInteger(match.Groups[8].ToString()); profileData.MagicItemChance = MainWindow.ConvertToInteger(match.Groups[9].ToString()); profileData.MagicItemMinAmount = MainWindow.ConvertToInteger(match.Groups[10].ToString()); profileData.MagicItemMaxAmount = MainWindow.ConvertToInteger(match.Groups[11].ToString()); profileData.MagicItemTreasureTypeSelectionChances = MainWindow.ConvertToInteger(match.Groups[12].ToString()); profileData.MundaneItemChance = MainWindow.ConvertToInteger(match.Groups[13].ToString()); profileData.MundaneItemMinAmount = MainWindow.ConvertToInteger(match.Groups[14].ToString()); profileData.MundaneItemMaxAmount = MainWindow.ConvertToInteger(match.Groups[15].ToString()); profileData.MundaneItemTreasureTypeSelectionChances = MainWindow.ConvertToInteger(match.Groups[16].ToString()); profileData.LastModified = match.Groups[17].ToString(); } } return(profileData); }
private void FillForm(DeathTreasure lootProfile) { tbDeathTreasureDID.Text = lootProfile.DTdid.ToString(); tbTier.Text = lootProfile.Tier.ToString(); tbLootQualityMod.Text = lootProfile.LootQualityMod.ToString(); tbUnknownChances.Text = lootProfile.UnknownChances.ToString(); tbItemChance.Text = lootProfile.ItemChance.ToString(); tbItemMinAmount.Text = lootProfile.ItemMinAmount.ToString(); tbItemMaxAmount.Text = lootProfile.ItemMaxAmount.ToString(); cbItemTreasureType.SelectedIndex = lootProfile.ItemTreasureTypeSelectionChances - 1; tbMagicItemChance.Text = lootProfile.MagicItemChance.ToString(); tbMagicItemMinAmount.Text = lootProfile.MagicItemMinAmount.ToString(); tbMagicItemMaxAmount.Text = lootProfile.MagicItemMaxAmount.ToString(); cbMagicItemTreasureType.SelectedIndex = lootProfile.MagicItemTreasureTypeSelectionChances - 1; tbMundaneItemChance.Text = lootProfile.MundaneItemChance.ToString(); tbMundaneItemMinAmount.Text = lootProfile.MundaneItemMinAmount.ToString(); tbMundaneItemMaxAmount.Text = lootProfile.MundaneItemMaxAmount.ToString(); cbMundaneItemTreasureType.SelectedIndex = lootProfile.MundaneItemTreasureTypeSelectionChances - 1; tbLastModifed.Text = lootProfile.LastModified; }