private void DropTarget(string str, Point mouse) { SmartEvent el = events.EventAt(mouse.X, mouse.Y); SmartAction action = (SmartAction)el.GetElementFromPos(mouse.X, mouse.Y); SmartTarget target = SmartFactory.GetInstance().TargetFactory(str); target.UpdateParams(action.Target); action.Target = target; }
public void Copy(SmartEvent prev) { base.Copy(prev); this.phasemask = prev.phasemask; this.flags = prev.flags; this.chance = prev.chance; this.conditions = prev.conditions; this.actions = prev.actions; ParameterValueChanged(this, new EventArgs()); }
private DropResult TargetDropResult(int x, int y) { SmartEvent ev = EventAt(x, y); if (ev != null) { DrawableElement dr = ev.GetElementFromPos(x, y); if (dr != null) { return(DropResult.REPLACE); } } return(DropResult.NONE); }
private void scratch1_MouseDown(object sender, MouseEventArgs e) { if (ModifierKeys.HasFlag(Keys.Control)) { SmartEvent selected = Selected(); if (selected != null) { SmartAction action = selected.GetSelectedAction(); if (action != null && action.ID == 80) // TRIGGER TIMED EVENT { RequestNewSAIWindow(this, new EventArgsRequestNewSAIWindow(action.parameters[0].GetValue(), SAIType.TimedActionList)); } } } }
private void DropEvent(string strEvent, Point mouse) { switch (dropResult) { case DropResult.INSERT: events.Insert(SmartFactory.GetInstance().EventFactory(strEvent), events.GetInsertIndexFromPos(mouse.X, mouse.Y)); break; case DropResult.REPLACE: SmartEvent ev = (SmartEvent)events.ElementAt(mouse.X, mouse.Y); SmartEvent new_event = SmartFactory.GetInstance().EventFactory(strEvent); new_event.Copy(ev); events.Replace(ev, new_event); break; } }
private void DropAction(string str, Point mouse) { SmartEvent el = events.EventAt(mouse.X, mouse.Y); switch (dropResult) { case DropResult.INSERT: el.InsertAction(SmartFactory.GetInstance().ActionFactory(str), el.GetInsertActionIndexFromPos(mouse.X, mouse.Y)); break; case DropResult.REPLACE: SmartAction action = (SmartAction)el.GetElementFromPos(mouse.X, mouse.Y); el.ReplaceAction(SmartFactory.GetInstance().ActionFactory(str), action); break; } }
private void DropCondition(string str, Point mouse) { SmartEvent el = events.EventAt(mouse.X, mouse.Y); switch (dropResult) { case DropResult.INSERT: el.InsertCondition(SmartFactory.GetInstance().ConditionFactory(str), el.GetInsertConditionIndexFromPos(mouse.X, mouse.Y)); break; case DropResult.REPLACE: DrawableElement condition = el.GetElementFromPos(mouse.X, mouse.Y); el.ReplaceCondition(SmartFactory.GetInstance().ConditionFactory(str), (SmartCondition)condition); break; } }
private DropResult EventDropResult(int x, int y) { if (y < 5) { return(DropResult.INSERT); } foreach (DrawableElement element in collection) { SmartEvent ev = (SmartEvent)element; if (y > (ev.rect.Top + 5) && y < (ev.rect.Bottom - 5)) { return(DropResult.REPLACE); } } return(DropResult.INSERT); }
private DropResult ActionDropResult(int x, int y) { SmartEvent ev = EventAt(x, y); if (ev != null) { foreach (SmartAction element in ev.actions) { if (y > (element.rect.Top + 5) && y < (element.rect.Bottom - 5)) { return(DropResult.REPLACE); } } return(DropResult.INSERT); } return(DropResult.NONE); }
// @TODO: to rewrite ASAP!! just for test // I know, it it TOTAL MESS public void LoadFromDB(int entryorguid) { this.entryorguid = entryorguid; DBConnect connect = new DBConnect(); bool opened = connect.OpenConnection(); if (!opened) { return; } events.Clear(); MySql.Data.MySqlClient.MySqlCommand cmd = connect.Query("SELECT * FROM conditions WHERE sourceentry = " + entryorguid + " and sourceid=0 and sourcetypeorreferenceid=22"); Dictionary <int, List <SmartCondition> > conditions = new Dictionary <int, List <SmartCondition> >(); using (MySql.Data.MySqlClient.MySqlDataReader reader = cmd.ExecuteReader()) { int prevelsegroup = 0; while (reader.Read()) { int id = Convert.ToInt32(reader["sourcegroup"]) - 1; if (!conditions.ContainsKey(id)) { conditions.Add(id, new List <SmartCondition>()); } if (Convert.ToInt32(reader["ElseGroup"]) != prevelsegroup) { conditions[id].Add(new CONDITION_LOGICAL_OR()); } SmartCondition cond = SmartFactory.GetInstance().ConditionFactory(Convert.ToInt32(reader["ConditionTypeOrReference"])); cond.UpdateParams(0, (Convert.ToInt32(reader["ConditionValue1"]))); cond.UpdateParams(1, (Convert.ToInt32(reader["ConditionValue2"]))); cond.UpdateParams(2, (Convert.ToInt32(reader["ConditionValue3"]))); cond.invert = (Convert.ToInt32(reader["NegativeCondition"]) == 1); conditions[id].Add(cond); prevelsegroup = Convert.ToInt32(reader["ElseGroup"]); } } cmd = connect.Query("SELECT * FROM smart_scripts WHERE source_type = " + (int)Type + " and entryorguid = " + entryorguid + " order by id"); SmartEvent prev = null; bool keep_legacy_comments = false; bool keep_lagacy_comments_asked = false; using (MySql.Data.MySqlClient.MySqlDataReader reader = cmd.ExecuteReader()) { int next_link = -1; while (reader.Read()) { //(`entryorguid`,`source_type`,`id`,`link`,`event_type`,`event_phase_mask`,`event_chance`,`event_flags`,`event_param1`,`event_param2`,`event_param3`,`event_param4`,`action_type`,`action_param1`,`action_param2`,`action_param3`,`action_param4`,`action_param5`,`action_param6`,`target_type`,`target_param1`,`target_param2`,`target_param3`,`target_x`,`target_y`,`target_z`,`target_o`,`comment`) int id = Convert.ToInt32(reader["id"]); int entry = Convert.ToInt32(reader["entryorguid"]); string comment = Convert.ToString(reader["comment"]); SmartAction a = SmartFactory.GetInstance().ActionFactory(Convert.ToInt32(reader["action_type"])); SmartTarget target = SmartFactory.GetInstance().TargetFactory(Convert.ToInt32(reader["target_type"])); for (int i = 0; i < 6; i++) { a.UpdateParams(i, Convert.ToInt32(reader["action_param" + (i + 1)])); } for (int i = 0; i < 3; i++) { target.UpdateParams(i, Convert.ToInt32(reader["target_param" + (i + 1)])); } target.position[0] = (float)Convert.ToDouble(reader["target_x"]); target.position[1] = (float)Convert.ToDouble(reader["target_y"]); target.position[2] = (float)Convert.ToDouble(reader["target_z"]); target.position[3] = (float)Convert.ToDouble(reader["target_o"]); a.Target = target; if (comment.IndexOf(" // ") > -1) { a.Comment = comment.Substring(comment.IndexOf(" // ") + 4); } else if (!Properties.Settings.Default.DiscardLegacyComments) { if (!keep_lagacy_comments_asked) { DialogResult res = PSTaskDialog.cTaskDialog.ShowTaskDialogBox("Legacy comments", "Legacy comments", "Visual SAI Studio has detected script you loaded doesn't have comments created with SAI Studio.\n", "", "", "Never propose keeping legacy comments", "", "Keep legacy comments|Discard legacy comments", PSTaskDialog.eTaskDialogButtons.Cancel, PSTaskDialog.eSysIcons.Question, PSTaskDialog.eSysIcons.Information); if (PSTaskDialog.cTaskDialog.VerificationChecked) { Properties.Settings.Default.DiscardLegacyComments = true; } if (PSTaskDialog.cTaskDialog.CommandButtonResult == 0) { keep_legacy_comments = true; } keep_lagacy_comments_asked = true; } if (keep_legacy_comments) { a.Comment = comment; } } if (id == next_link) { prev.AddAction(a); } else { SmartEvent ev = SmartFactory.GetInstance().EventFactory(Convert.ToInt32(reader["event_type"])); ev.chance = Convert.ToInt32(reader["event_chance"]); ev.flags = (SmartEventFlag)Convert.ToInt32(reader["event_flags"]); ev.phasemask = (SmartPhaseMask)Convert.ToInt32(reader["event_phase_mask"]); ev.UpdateParams(0, Convert.ToInt32(reader["event_param1"])); ev.UpdateParams(1, Convert.ToInt32(reader["event_param2"])); ev.UpdateParams(2, Convert.ToInt32(reader["event_param3"])); ev.UpdateParams(3, Convert.ToInt32(reader["event_param4"])); if (conditions.ContainsKey(id)) { foreach (SmartCondition cond in conditions[id]) { ev.AddCondition(cond); } } ev.AddAction(a); events.Add(ev); prev = ev; } next_link = Convert.ToInt32(reader["link"]); } } connect.CloseConnection(); scratch1.Refresh(); }
public void Copy(SmartEvent prev) { base.Copy(prev); this.conditions = prev.conditions; }