// Not used currently (button is hidden) but have ideas for this. Reuse for importing body tables. private void btnGenerateBodyTable_Click(object sender, RoutedEventArgs e) { string header = $"INSERT INTO `weenie_properties_body_part` (`object_Id`, `key`, `d_Type`, `d_Val`, `d_Var`, `base_Armor`, `armor_Vs_Slash`, `armor_Vs_Pierce`, `armor_Vs_Bludgeon`, `armor_Vs_Cold`, `armor_Vs_Fire`, `armor_Vs_Acid`, `armor_Vs_Electric`, `armor_Vs_Nether`, `b_h`, `h_l_f`, `m_l_f`, `l_l_f`, `h_r_f`, `m_r_f`, `l_r_f`, `h_l_b`, `m_l_b`, `l_l_b`, `h_r_b`, `m_r_b`, `l_r_b`)"; string bodyparts = TableToSql.ConvertBodyPart(bodypartsDataTable, tbWCID.Text, header); rtbBodyParts.Document.Blocks.Clear(); rtbBodyParts.Document.Blocks.Add(new System.Windows.Documents.Paragraph(new Run(bodyparts))); }
public void WriteSQLFile(string filename) { string dateModified = string.Format("'{0:yyyy-MM-dd hh:mm:ss}'", DateTime.Now); string[] weenieTypeDescription = cbWeenieType.Text.Split(" "); // Header string header = $"DELETE FROM `weenie` WHERE `class_Id` = {tbWCID.Text} \n\n"; string body = $"DELETE FROM `weenie` WHERE `class_Id` = {tbWCID.Text};\n\n"; // WeenieType body += $"INSERT INTO `weenie` (`class_Id`, `class_Name`, `type`, `last_Modified`)\n"; body += $"VALUES ({tbWCID.Text}, '{tbWeenieName.Text}', {cbWeenieType.SelectedIndex}, {dateModified}) /* {weenieTypeDescription[1]} */;\n\n"; // Integer32 header = $"INSERT INTO `weenie_properties_int` (`object_Id`, `type`, `value`)"; body += TableToSql.ConvertTriValueTable(integerDataTable, tbWCID.Text, header); // Integer64 header = $"INSERT INTO `weenie_properties_int64` (`object_Id`, `type`, `value`)"; body += TableToSql.ConvertTriValueTable(integer64DataTable, tbWCID.Text, header); // Boolean header = $"INSERT INTO `weenie_properties_bool` (`object_Id`, `type`, `value`)"; body += TableToSql.ConvertBooleanTable(boolDataTable, tbWCID.Text, header); // Float header = $"INSERT INTO `weenie_properties_float` (`object_Id`, `type`, `value`)"; body += TableToSql.ConvertFloatTable(floatDataTable, tbWCID.Text, header); // String header = $"INSERT INTO `weenie_properties_string` (`object_Id`, `type`, `value`)"; body += TableToSql.ConvertStringTable(stringDataTable, tbWCID.Text, header); // DiD header = $"INSERT INTO `weenie_properties_d_i_d` (`object_Id`, `type`, `value`)"; body += TableToSql.ConvertDidTable(didDataTable, tbWCID.Text, header); // IiD header = $"INSERT INTO `weenie_properties_i_i_d` (`object_Id`, `type`, `value`)"; body += TableToSql.ConvertIidTable(iidDataTable, tbWCID.Text, header); // Positions header = $"INSERT INTO `weenie_properties_position` (`object_Id`, `position_Type`, `obj_Cell_Id`, `origin_X`, `origin_Y`, `origin_Z`, `angles_W`, `angles_X`, `angles_Y`, `angles_Z`)"; body += TableToSql.ConvertPositionTable(positionsDataTable, tbWCID.Text, header); // Body Parts header = $"INSERT INTO `weenie_properties_body_part` (`object_Id`, `key`, `d_Type`, `d_Val`, `d_Var`, `base_Armor`, `armor_Vs_Slash`, `armor_Vs_Pierce`, `armor_Vs_Bludgeon`, `armor_Vs_Cold`, `armor_Vs_Fire`, `armor_Vs_Acid`, `armor_Vs_Electric`, `armor_Vs_Nether`, `b_h`, `h_l_f`, `m_l_f`, `l_l_f`, `h_r_f`, `m_r_f`, `l_r_f`, `h_l_b`, `m_l_b`, `l_l_b`, `h_r_b`, `m_r_b`, `l_r_b`)"; body += TableToSql.ConvertBodyPart(bodypartsDataTable, tbWCID.Text, header); //string bodyparts = new TextRange(rtbBodyParts.Document.ContentStart, rtbBodyParts.Document.ContentEnd).Text; //if (bodyparts != "") // body += TableToSql.ConvertBodyTable(bodyparts, tbWCID.Text, header); // Attributes header = $"INSERT INTO `weenie_properties_attribute` (`object_Id`, `type`, `init_Level`, `level_From_C_P`, `c_P_Spent`)"; body += TableToSql.ConvertAttributeTable(attributeDataTable, tbWCID.Text, header); // Attributes 2 - Health, Stam, Mana header = $"INSERT INTO `weenie_properties_attribute_2nd` (`object_Id`, `type`, `init_Level`, `level_From_C_P`, `c_P_Spent`, `current_Level`)"; body += TableToSql.ConvertAttribute2Table(attribute2DataTable, tbWCID.Text, header); // Skills header = $"INSERT INTO `weenie_properties_skill` (`object_Id`, `type`, `level_From_P_P`, `s_a_c`, `p_p`, `init_Level`, `resistance_At_Last_Check`, `last_Used_Time`)"; body += TableToSql.ConvertSkillsTable(skillsDataTable, tbWCID.Text, header); // Spells header = $"INSERT INTO `weenie_properties_spell_book` (`object_Id`, `spell`, `probability`)"; body += TableToSql.ConvertSpellTable(spellDataTable, tbWCID.Text, header); // Emotes string tempES = new TextRange(rtbEmoteScript.Document.ContentStart, rtbEmoteScript.Document.ContentEnd).Text; // To fix the issue with Rich Text Boxes tempES = tempES.Replace("\n", "\r\n"); tempES = tempES.Replace("\r\r\n", "\r\n"); string[] saES = tempES.Split(new string[] { System.Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); int tWCID = ConvertToInteger(tbWCID.Text); string finalEmotes = ""; // var eslist = EmoteScriptLib.Converter.es2sql(saES, ConvertToInteger(tbWCID.Text)); try { var eslist = EmoteScriptLib.Converter.es2sql(saES, (uint)tWCID); foreach (var emoteline in eslist) { finalEmotes += emoteline + "\r\n"; } } catch (Exception ex) { LogError(ex); MessageBoxButton buttons = MessageBoxButton.OK; MessageBoxImage icon = MessageBoxImage.Error; MessageBoxResult result = MessageBox.Show("FILE NOT SAVED WITH E MOTES! Please Copy Emotes and save outside of WF. Issue with Emote Script. Please send WeenieFabErrorLog.txt to Harli Quinn on Discord", "ERROR!", buttons, icon); //MessageBox.Show($"{ex.Message} \n {ex.StackTrace} \n {ex.Source} \n {ex.TargetSite}"); //throw; } body += finalEmotes; // Create Items header = $"INSERT INTO `weenie_properties_create_list` (`object_Id`, `destination_Type`, `weenie_Class_Id`, `stack_Size`, `palette`, `shade`, `try_To_Bond`)"; body += TableToSql.ConvertCreateItemsTable(createListDataTable, tbWCID.Text, header); // Book Info header = $"INSERT INTO `weenie_properties_book` (`object_Id`, `max_Num_Pages`, `max_Num_Chars_Per_Page`)"; body += TableToSql.ConvertBookInfo(bookInfoDataTable, tbWCID.Text, header); // Book Pages header = $"INSERT INTO `weenie_properties_book_page_data` (`object_Id`, `page_Id`, `author_Id`, `author_Name`, `author_Account`, `ignore_Author`, `page_Text`)"; body += TableToSql.ConvertBookPages(bookPagesDataTable, tbWCID.Text, header); // Generator if (tbGenerator.Text != "") { // header = $"INSERT INTO `weenie_properties_generator` (`object_Id`, `probability`, `weenie_Class_Id`, `delay`, `init_Create`, `max_Create`, `when_Create`, `where_Create`, `stack_Size`, `palette_Id`, `shade`, `obj_Cell_Id`, `origin_X`, `origin_Y`, `origin_Z`, `angles_W`, `angles_X`, `angles_Y`, `angles_Z`)"; // body += header; body += tbGenerator.Text; } File.WriteAllText(filename, body); }