private void btnCreate_Click(object sender, EventArgs e) { SmartAI script = new SmartAI(); script.EntryOrGuid = _tbEntryOrGuid.Text.ToInt32(); script.SourceType = _cbSourceType.GetIntValue(); script.ID = _tbID.Text.ToInt32(); script.Link = _tbLink.Text.ToInt32(); script.EventType = _cbEventType.GetIntValue(); script.EventPhaseMask = _clbPhase.GetFlagsValue(); script.EventChance = _tbChance.Text.ToInt32(); script.EventParam[0] = _cbEventParametr1.GetIntValue(); script.EventParam[1] = _cbEventParametr2.GetIntValue(); script.EventParam[2] = _cbEventParametr3.GetIntValue(); script.EventParam[3] = _cbEventParametr4.GetIntValue(); script.ActionType = _cbActionType.GetIntValue(); script.ActionParam[0] = _cbActionParam1.GetIntValue(); script.ActionParam[1] = _cbActionParam2.GetIntValue(); script.ActionParam[2] = _cbActionParam3.GetIntValue(); script.ActionParam[3] = _cbActionParam4.GetIntValue(); script.ActionParam[4] = _cbActionParam5.GetIntValue(); script.ActionParam[5] = _cbActionParam6.GetIntValue(); script.TargetType = _cbTargetType.GetIntValue(); script.TargetParam[0] = _cbTargetParam1.GetIntValue(); script.TargetParam[1] = _cbTargetParam2.GetIntValue(); script.TargetParam[2] = _cbTargetParam3.GetIntValue(); script.TargetX = _cbTargetParamX.Text.ToFloat(); script.TargetY = _cbTargetParamY.Text.ToFloat(); script.TargetZ = _cbTargetParamZ.Text.ToFloat(); script.TargetO = _cbTargetParamO.Text.ToFloat(); script.Comment = _tbComment.Text; QueryHandler.BuildScriptQuery(script); }
private void SmartAIData(SmartAI script) { _tbEntryOrGuid.Text = script.EntryOrGuid.ToString(); _tbID.Text = script.ID.ToString(); _tbChance.Text = script.EventChance.ToString(); _tbLink.Text = script.Link.ToString(); _cbSourceType.SelectedValue = script.SourceType; _clbEventFlag.SetCheckedItemFromFlag((uint)script.EventFlags); _clbPhase.SetCheckedItemFromFlag((uint)script.EventPhaseMask); _cbEventType.SelectedValue = script.EventType; _cbEventParametr1.SetValue(script.EventParam[0]); _cbEventParametr2.SetValue(script.EventParam[1]); _cbEventParametr3.SetValue(script.EventParam[2]); _cbEventParametr4.SetValue(script.EventParam[3]); _cbActionType.SelectedValue = script.ActionType; _cbActionParam1.SetValue(script.ActionParam[0]); _cbActionParam2.SetValue(script.ActionParam[1]); _cbActionParam3.SetValue(script.ActionParam[2]); _cbActionParam4.SetValue(script.ActionParam[3]); _cbActionParam5.SetValue(script.ActionParam[4]); _cbActionParam6.SetValue(script.ActionParam[5]); _cbTargetType.SelectedValue = script.TargetType; _cbTargetParam1.SetValue(script.TargetParam[0]); _cbTargetParam2.SetValue(script.TargetParam[1]); _cbTargetParam3.SetValue(script.TargetParam[2]); _cbTargetParamX.SetValue(script.TargetX.ToString()); _cbTargetParamY.SetValue(script.TargetY.ToString()); _cbTargetParamZ.SetValue(script.TargetZ.ToString()); _cbTargetParamO.SetValue(script.TargetO.ToString()); _tbComment.Text = script.Comment; }
public static void SelectSmartAIScript(string query) { if (!IsConnected) { if (Settings.Default.UseConnect) System.Windows.Forms.MessageBox.Show("No connection to database, please check settings", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } using (_conn = new MySqlConnection(ConnectionString)) { _command = new MySqlCommand(query, _conn); _conn.Open(); _SmartAIScript.Clear(); using (var reader = _command.ExecuteReader()) { while (reader.Read()) { SmartAI script = new SmartAI(); script.EntryOrGuid = reader[0].ToInt32(); script.SourceType = reader[1].ToInt32(); script.ID = reader[2].ToInt32(); script.Link = reader[3].ToInt32(); script.EventType = reader[4].ToInt32(); script.EventPhaseMask = reader[5].ToInt32(); script.EventChance = reader[6].ToInt32(); script.EventFlags = reader[7].ToInt32(); script.EventParam[0] = reader[8].ToInt32(); script.EventParam[1] = reader[9].ToInt32(); script.EventParam[2] = reader[10].ToInt32(); script.EventParam[3] = reader[11].ToInt32(); script.ActionType = reader[12].ToInt32(); script.ActionParam[0] = reader[13].ToInt32(); script.ActionParam[1] = reader[14].ToInt32(); script.ActionParam[2] = reader[15].ToInt32(); script.ActionParam[3] = reader[16].ToInt32(); script.ActionParam[4] = reader[17].ToInt32(); script.ActionParam[5] = reader[18].ToInt32(); script.TargetType = reader[19].ToInt32(); script.TargetParam[0] = reader[20].ToInt32(); script.TargetParam[1] = reader[21].ToInt32(); script.TargetParam[2] = reader[22].ToInt32(); script.TargetX = reader[23].ToFloat(); script.TargetY = reader[24].ToFloat(); script.TargetZ = reader[25].ToFloat(); script.TargetO = reader[26].ToFloat(); script.Comment = reader[27].ToString(); _SmartAIScript.Add(script); } } _conn.Close(); } }