public DbScriptControl(Event_dataset_script Data, Int32 ID, uint id) { InitializeComponent(); this.Name = ID.ToString(); eventid = ID; script_id = id; this.eventCheckbox.Text = "Event: " + ID.ToString(); this.eventCheckbox.Checked = true; for (int n = 0; n < Info.ScriptCommands.GetLength(0); n++) this.comboBoxAction.Items.Add(Info.ScriptCommands[n, 0]); // set width comboBoxAction.DropDownWidth = DropDownWidth(comboBoxAction); comboBoxAction.DropDownStyle = ComboBoxStyle.DropDownList; this.comboBoxAction.SelectedIndex = Data.command; this.textBoxDelay.Text = Data.delay.ToString(); this.textBox_datalong.Text = Data.datalong.ToString(); this.textBox_datalong2.Text = Data.datalong2.ToString(); this.textBox_buddy.Text = Data.buddy.ToString(); this.textBox_radius.Text = Data.radius.ToString(); this.textBox_flags.Text = Data.dataflags.ToString(); this.textBox_dataint1.Text = Data.dataint.ToString(); this.textBox_dataint2.Text = Data.dataint2.ToString(); this.textBox_dataint3.Text = Data.dataint3.ToString(); this.textBox_dataint4.Text = Data.dataint4.ToString(); this.textBox_posX.Text = Data.position_x.ToString(); this.textBox_posY.Text = Data.position_y.ToString(); this.textBox_posZ.Text = Data.position_z.ToString(); this.textBox_orientation.Text = Data.orientation.ToString(); this.commentTextbox.Text = Data.comment; //switch (comboBoxAction.SelectedIndex) //{ // case 0: // talk // textBox_dataint1.ReadOnly = false; // textBox_dataint2.ReadOnly = false; // textBox_dataint3.ReadOnly = false; // textBox_dataint4.ReadOnly = false; // break; // case 3: // move // case 6: // teleport // case 10: // summon // textBox_posX.ReadOnly = false; // textBox_posY.ReadOnly = false; // textBox_posZ.ReadOnly = false; // textBox_orientation.ReadOnly = false; // break; //} locked = false; }
// Load event data to list public Event_dataset_script GetEventData() { Event_dataset_script Data = new Event_dataset_script(); Data.command = comboBoxAction.SelectedIndex; if (textBoxDelay.Text.Length != 0) Data.delay = Convert.ToUInt32(textBoxDelay.Text); if (textBox_datalong.Text.Length != 0) Data.datalong = Convert.ToUInt32(textBox_datalong.Text); if (textBox_datalong2.Text.Length != 0) Data.datalong2 = Convert.ToUInt32(textBox_datalong2.Text); if (textBox_dataint1.Text.Length != 0) Data.dataint = Convert.ToUInt32(textBox_dataint1.Text); if (textBox_dataint2.Text.Length != 0) Data.dataint = Convert.ToUInt32(textBox_dataint2.Text); if (textBox_dataint3.Text.Length != 0) Data.dataint = Convert.ToUInt32(textBox_dataint3.Text); if (textBox_dataint4.Text.Length != 0) Data.dataint = Convert.ToUInt32(textBox_dataint4.Text); if (textBox_posX.Text.Length != 0) Data.position_x = float.Parse(textBox_posX.Text); if (textBox_posY.Text.Length != 0) Data.position_x = float.Parse(textBox_posY.Text); if (textBox_posZ.Text.Length != 0) Data.position_x = float.Parse(textBox_posZ.Text); if (textBox_orientation.Text.Length != 0) Data.position_x = float.Parse(textBox_orientation.Text); if (textBox_buddy.Text.Length != 0) Data.buddy = Convert.ToUInt32(textBox_buddy.Text); if (textBox_radius.Text.Length != 0) Data.radius = Convert.ToUInt32(textBox_radius.Text); if (textBox_flags.Text.Length != 0) Data.dataflags = Convert.ToUInt32(textBox_flags.Text); if (commentTextbox.Text.Length != 0) Data.comment = commentTextbox.Text; db_scripts.scriptList[script_id].line[eventid] = Data; db_scripts.scriptList[script_id].changed = true; return Data; }
public void AddScriptLine() { Event_dataset_script temp = new Event_dataset_script(); line.Add(temp); }
// Load DB scripts public static void LoadDBScripts(string sTable) { if (!Datastores.dbused) return; MySqlDataReader reader = null; // Check for the creatureAI tables try { string sQuery = "SELECT information_schema.TABLES.table_name FROM information_schema.TABLES " + "where information_schema.TABLES.table_name IN ('creature_movement_scripts','event_script','gameobject_scripts','gossip_scripts','quest_end_scripts','quest_start_scripts','spell_scripts') and information_schema.TABLES.Table_schema='" + Properties.Settings.Default.DBMANGOS + "'"; MySqlCommand comm = new MySqlCommand(sQuery, SQLConnection.conn); reader = comm.ExecuteReader(); while (reader.Read()) { if (!reader.HasRows) { MessageBox.Show("Your database doesn't contain the script tables. The application won't use the database anymore"); dbused = false; } } } catch (Exception e) { MessageBox.Show(e.Message); } reader.Close(); if (Datastores.dbused) { // Select all creature scripts and creature names MySqlCommand c = new MySqlCommand("SELECT * FROM " + sTable, SQLConnection.conn); reader = c.ExecuteReader(); // clear existing script first db_scripts.scriptList.Clear(); try { while (reader.Read()) { if (!db_scripts.scriptList.ContainsKey(reader.GetUInt32("id"))) { db_script temp = new db_script(reader.GetUInt32("id")); db_scripts.scriptList.Add(reader.GetUInt32("id"), temp); } Event_dataset_script item = new Event_dataset_script(); item.id = reader.GetUInt32("id"); item.delay = reader.GetUInt32("delay"); item.command = reader.GetInt32("command"); item.datalong = reader.GetUInt32("datalong"); item.datalong2 = reader.GetUInt32("datalong2"); item.buddy = reader.GetUInt32("buddy_entry"); item.radius = reader.GetUInt32("search_radius"); item.dataint = reader.GetUInt32("dataint"); item.dataint2 = reader.GetUInt32("dataint2"); item.dataint3 = reader.GetUInt32("dataint3"); item.dataint4 = reader.GetUInt32("dataint4"); item.position_x = reader.GetFloat("x"); item.position_y = reader.GetFloat("y"); item.position_z = reader.GetFloat("z"); item.orientation = reader.GetFloat("o"); item.comment = reader.GetString("comments"); db_scripts.scriptList[reader.GetUInt32("id")].line.Add(item); } } catch (Exception ex) { MessageBox.Show(ex.Message); } reader.Close(); } }
// Load event data to list public Event_dataset_script GetEventData() { Event_dataset_script Data = new Event_dataset_script(); Data.command = comboBoxAction.SelectedIndex; if (textBoxDelay.Text.Length != 0) { Data.delay = Convert.ToUInt32(textBoxDelay.Text); } if (textBox_datalong.Text.Length != 0) { Data.datalong = Convert.ToUInt32(textBox_datalong.Text); } if (textBox_datalong2.Text.Length != 0) { Data.datalong2 = Convert.ToUInt32(textBox_datalong2.Text); } if (textBox_datalong3.Text.Length != 0) { Data.datalong3 = Convert.ToUInt32(textBox_datalong3.Text); } if (textBox_dataint1.Text.Length != 0) { Data.dataint = Convert.ToInt32(textBox_dataint1.Text); } if (textBox_dataint2.Text.Length != 0) { Data.dataint = Convert.ToInt32(textBox_dataint2.Text); } if (textBox_dataint3.Text.Length != 0) { Data.dataint = Convert.ToInt32(textBox_dataint3.Text); } if (textBox_dataint4.Text.Length != 0) { Data.dataint = Convert.ToInt32(textBox_dataint4.Text); } if (textBox_posX.Text.Length != 0) { Data.position_x = float.Parse(textBox_posX.Text, System.Globalization.CultureInfo.InvariantCulture); } if (textBox_posY.Text.Length != 0) { Data.position_y = float.Parse(textBox_posY.Text, System.Globalization.CultureInfo.InvariantCulture); } if (textBox_posZ.Text.Length != 0) { Data.position_z = float.Parse(textBox_posZ.Text, System.Globalization.CultureInfo.InvariantCulture); } if (textBox_orientation.Text.Length != 0) { Data.orientation = float.Parse(textBox_orientation.Text, System.Globalization.CultureInfo.InvariantCulture); } if (textBox_buddy.Text.Length != 0) { Data.buddy = Convert.ToUInt32(textBox_buddy.Text); } if (textBox_radius.Text.Length != 0) { Data.radius = Convert.ToUInt32(textBox_radius.Text); } if (textBox_flags.Text.Length != 0) { Data.dataflags = Convert.ToUInt32(textBox_flags.Text); } if (commentTextbox.Text.Length != 0) { Data.comment = commentTextbox.Text; } db_scripts.scriptList[script_id].line[eventid] = Data; db_scripts.scriptList[script_id].changed = true; return(Data); }
public DbScriptControl(Event_dataset_script Data, Int32 ID, uint id) { InitializeComponent(); this.Name = ID.ToString(); eventid = ID; script_id = id; this.eventCheckbox.Text = "Event: " + ID.ToString(); this.eventCheckbox.Checked = true; for (int n = 0; n < Info.ScriptCommands.GetLength(0); n++) { this.comboBoxAction.Items.Add(Info.ScriptCommands[n, 0]); } // set width comboBoxAction.DropDownWidth = DropDownWidth(comboBoxAction); comboBoxAction.DropDownStyle = ComboBoxStyle.DropDownList; this.comboBoxAction.SelectedIndex = Data.command; this.textBoxDelay.Text = Data.delay.ToString(); this.textBox_datalong.Text = Data.datalong.ToString(); this.textBox_datalong2.Text = Data.datalong2.ToString(); this.textBox_datalong3.Text = Data.datalong3.ToString(); this.textBox_buddy.Text = Data.buddy.ToString(); this.textBox_radius.Text = Data.radius.ToString(); this.textBox_flags.Text = Data.dataflags.ToString(); this.textBox_dataint1.Text = Data.dataint.ToString(); this.textBox_dataint2.Text = Data.dataint2.ToString(); this.textBox_dataint3.Text = Data.dataint3.ToString(); this.textBox_dataint4.Text = Data.dataint4.ToString(); this.textBox_posX.Text = Data.position_x.ToString(); this.textBox_posY.Text = Data.position_y.ToString(); this.textBox_posZ.Text = Data.position_z.ToString(); this.textBox_orientation.Text = Data.orientation.ToString(); this.commentTextbox.Text = Data.comment; //switch (comboBoxAction.SelectedIndex) //{ // case 0: // talk // textBox_dataint1.ReadOnly = false; // textBox_dataint2.ReadOnly = false; // textBox_dataint3.ReadOnly = false; // textBox_dataint4.ReadOnly = false; // break; // case 3: // move // case 6: // teleport // case 10: // summon // textBox_posX.ReadOnly = false; // textBox_posY.ReadOnly = false; // textBox_posZ.ReadOnly = false; // textBox_orientation.ReadOnly = false; // break; //} locked = false; }
// Load DB scripts public static void LoadDBScripts(string sTable) { // Force using dots on floats, no matter which is the system setting System.Globalization.CultureInfo customCulture = (System.Globalization.CultureInfo)System.Threading.Thread.CurrentThread.CurrentCulture.Clone(); customCulture.NumberFormat.NumberDecimalSeparator = "."; System.Threading.Thread.CurrentThread.CurrentCulture = customCulture; if (!Datastores.dbused) return; MySqlDataReader reader = null; // Check for the creatureAI tables try { string sQuery = "SELECT information_schema.TABLES.table_name FROM information_schema.TABLES " + "where information_schema.TABLES.table_name IN ('dbscripts_on_creature_movement','dbscripts_on_event','dbscripts_on_go_use','dbscripts_on_go_template_use','dbscripts_on_gossip','dbscripts_on_quest_end','dbscripts_on_quest_start','dbscripts_on_spell') and information_schema.TABLES.Table_schema='" + Properties.Settings.Default.DBMANGOS + "'"; MySqlCommand comm = new MySqlCommand(sQuery, SQLConnection.conn); reader = comm.ExecuteReader(); while (reader.Read()) { if (!reader.HasRows) { MessageBox.Show("Your database doesn't contain the script tables. The application won't use the database anymore"); dbused = false; } } } catch (Exception e) { MessageBox.Show(e.Message); } reader.Close(); if (Datastores.dbused) { // Select all creature scripts and creature names MySqlCommand c = new MySqlCommand("SELECT * FROM " + sTable, SQLConnection.conn); reader = c.ExecuteReader(); // clear existing script first db_scripts.scriptList.Clear(); try { while (reader.Read()) { if (!db_scripts.scriptList.ContainsKey(reader.GetUInt32("id"))) { db_script temp = new db_script(reader.GetUInt32("id")); db_scripts.scriptList.Add(reader.GetUInt32("id"), temp); } Event_dataset_script item = new Event_dataset_script(); item.id = reader.GetUInt32("id"); item.delay = reader.GetUInt32("delay"); item.command = reader.GetInt32("command"); item.datalong = reader.GetUInt32("datalong"); item.datalong2 = reader.GetUInt32("datalong2"); item.buddy = reader.GetUInt32("buddy_entry"); item.radius = reader.GetUInt32("search_radius"); item.dataint = reader.GetUInt32("dataint"); item.dataint2 = reader.GetUInt32("dataint2"); item.dataint3 = reader.GetUInt32("dataint3"); item.dataint4 = reader.GetUInt32("dataint4"); item.position_x = reader.GetFloat("x"); item.position_y = reader.GetFloat("y"); item.position_z = reader.GetFloat("z"); item.orientation = reader.GetFloat("o"); item.comment = reader.GetString("comments"); db_scripts.scriptList[reader.GetUInt32("id")].line.Add(item); } } catch (Exception ex) { MessageBox.Show(ex.Message); } reader.Close(); } }