public GActionMenu(GMacroEditorPanel panel, Macro macro, Action action) : base(action.Handler.Name) { this.m_Panel = panel; this.m_Macro = macro; this.m_Action = action; base.Tooltip = new Tooltip("Click here to edit this action", true); }
public GEditAction(GMacroEditorPanel p, Macro macro, Action action) : base(0, 0, 0x67, 0x56) { this.m_Panel = p; this.m_Macro = macro; this.m_Action = action; Gumps.Modal = this; Gumps.Focus = this; base.Text = "Edit"; base.m_NonRestrictivePicking = true; this.AddButton("↑", 6, 7, 0x18, 0x18, new OnClick(this.Up_OnClick)).Tooltip = new Tooltip("Moves the instruction up", true); this.AddButton("↓", 6, 30, 0x18, 0x18, new OnClick(this.Down_OnClick)).Tooltip = new Tooltip("Moves the instruction down", true); this.AddButton("Delete", 0x27, 7, 50, 0x18, new OnClick(this.Delete_OnClick)).Tooltip = new Tooltip("Removes the instruction", true); this.Center(); }
public GNewActionMenu(GMacroEditorPanel panel, Macro macro, ActionHandler action) : base(action.Name) { this.m_Panel = panel; this.m_Macro = macro; this.m_Action = action; if ((this.m_Action.Params != null) && (this.m_Action.Params.Length > 0)) { base.Tooltip = new Tooltip("Choose a parameter from the menu to the right, or just click here to add the instruction with a default parameter.", false, 200); } else { base.Tooltip = new Tooltip("Click here to add this instruction.", false, 200); } base.Tooltip.Delay = 2f; }
public static void Load(string filename) { m_List = new ArrayList(); m_Running = new ArrayList(); string path = Engine.FileManager.BasePath(string.Format("Data/Plugins/Macros/{0}.txt", filename)); if (File.Exists(path)) { int num = 0; using (StreamReader reader = new StreamReader(path)) { while (true) { string str4; string line = ReadLine(reader); if (line == null) { break; } if (line.Length != 5) { Skip(line, reader); break; } string[] strArray = line.Split(new char[] { ' ' }); if (strArray.Length != 3) { Skip(line, reader); break; } bool flag = true; for (int i = 0; flag && (i < strArray.Length); i++) { flag = (strArray[i] == "0") || (strArray[i] == "1"); } if (!flag) { Skip(line, reader); break; } Keys none = Keys.None; if (strArray[0] != "0") { none |= Keys.Control; } if (strArray[1] != "0") { none |= Keys.Alt; } if (strArray[2] != "0") { none |= Keys.Shift; } string str3 = ReadLine(reader); if (str3 == null) { break; } Keys key = ~Keys.None; switch (str3) { case "WheelUp": case "Wheel Up": key = 0x11000; break; case "WheelDown": case "Wheel Down": key = 0x11001; break; case "WheelPress": case "Wheel Press": key = 0x11002; break; default: try { key = (Keys) Enum.Parse(typeof(Keys), str3, true); } catch { } break; } if (key == ~Keys.None) { Skip(str3, reader); break; } ArrayList dataStore = Engine.GetDataStore(); while ((str4 = ReadLine(reader)) != null) { if (str4.StartsWith("#")) { break; } Action action = new Action(str4); if (action.Handler == null) { Debug.Trace("Bad macro action: {0}", str4); } dataStore.Add(action); } Macro macro = new Macro(key, none, (Action[]) dataStore.ToArray(typeof(Action))) { FileIndex = num++ }; m_List.Add(macro); Engine.ReleaseDataStore(dataStore); } m_List.Sort(); } } }
public void RepeatMacro() { Macro.Repeat(); }
private void SetMacro(ArrayList list, GMacroKeyButton btn, Macro mc) { if (list.Contains(btn) || (btn.Macro == null)) { list.Remove(btn); btn.Macro = mc; } else if (btn.Macro is Macro) { btn.Macro = new Macro[] { (Macro) btn.Macro, mc }; } else if (btn.Macro is Macro[]) { Macro[] macro = (Macro[]) btn.Macro; Macro[] macroArray2 = new Macro[macro.Length + 1]; for (int i = 0; i < macro.Length; i++) { macroArray2[i] = macro[i]; } macroArray2[macro.Length] = mc; btn.Macro = macroArray2; } }
public static void Load(string filename) { m_List = new ArrayList(); m_Running = new ArrayList(); string path = Engine.FileManager.BasePath(string.Format("Data/Plugins/Macros/{0}.txt", filename)); if (File.Exists(path)) { int num = 0; using (StreamReader reader = new StreamReader(path)) { while (true) { string str4; string line = ReadLine(reader); if (line == null) { break; } if (line.Length != 5) { Skip(line, reader); break; } string[] strArray = line.Split(new char[] { ' ' }); if (strArray.Length != 3) { Skip(line, reader); break; } bool flag = true; for (int i = 0; flag && (i < strArray.Length); i++) { flag = (strArray[i] == "0") || (strArray[i] == "1"); } if (!flag) { Skip(line, reader); break; } Keys none = Keys.None; if (strArray[0] != "0") { none |= Keys.Control; } if (strArray[1] != "0") { none |= Keys.Alt; } if (strArray[2] != "0") { none |= Keys.Shift; } string str3 = ReadLine(reader); if (str3 == null) { break; } Keys key = ~Keys.None; switch (str3) { case "WheelUp": case "Wheel Up": key = 0x11000; break; case "WheelDown": case "Wheel Down": key = 0x11001; break; case "WheelPress": case "Wheel Press": key = 0x11002; break; default: try { key = (Keys)Enum.Parse(typeof(Keys), str3, true); } catch { } break; } if (key == ~Keys.None) { Skip(str3, reader); break; } ArrayList dataStore = Engine.GetDataStore(); while ((str4 = ReadLine(reader)) != null) { if (str4.StartsWith("#")) { break; } Action action = new Action(str4); if (action.Handler == null) { Debug.Trace("Bad macro action: {0}", str4); } dataStore.Add(action); } Macro macro = new Macro(key, none, (Action[])dataStore.ToArray(typeof(Action))) { FileIndex = num++ }; m_List.Add(macro); Engine.ReleaseDataStore(dataStore); } m_List.Sort(); } } }
public static void Save(Mobile who, string filename) { if (m_List != null) { Engine.WantDirectory("Data/Plugins/Macros"); using (StreamWriter writer = new StreamWriter(Engine.FileManager.BasePath(string.Format("Data/Plugins/Macros/{0}.txt", filename)))) { if (who == null) { writer.WriteLine("; Default macro definitions file"); } else { writer.WriteLine("; Macro definition file for {0} on {1}", who.Name, Engine.m_ServerName); } writer.WriteLine("; Format:"); writer.WriteLine("; Control Alt Shift"); writer.WriteLine("; Key"); writer.WriteLine("; [list]"); writer.WriteLine("; <name> [param]"); writer.WriteLine("; #####"); writer.WriteLine(); Cleanup(); for (int i = 0; i < m_List.Count; i++) { Macro macro = (Macro)m_List[i]; writer.WriteLine("{0} {1} {2}", macro.Control ? "1" : "0", macro.Alt ? "1" : "0", macro.Shift ? "1" : "0"); switch (macro.Key) { case 0x11000: writer.WriteLine("Wheel Up"); break; case 0x11001: writer.WriteLine("Wheel Down"); break; case 0x11002: writer.WriteLine("Wheel Press"); break; default: writer.WriteLine(macro.Key); break; } for (int j = 0; j < macro.Actions.Length; j++) { Action action = macro.Actions[j]; if (action.Handler == null) { writer.WriteLine(action.Line); } else if (action.Param.Length > 0) { writer.WriteLine("{0} {1}", action.Handler.Action, action.Param); } else { writer.WriteLine(action.Handler.Action); } } if (i == (m_List.Count - 1)) { writer.Write("#####"); } else { writer.WriteLine("#####"); } } } } }
public bool Slice() { m_Current = this; if (this.m_Index < this.m_Actions.Length) { Action action = this.m_Actions[this.m_Index]; ActionHandler handler = action.Handler; if ((handler == null) || handler.Plugin.OnMacroAction(action.Param)) { this.m_Index++; } } if (this.m_Index >= this.m_Actions.Length) { this.m_Index = -1; } m_Current = null; return this.Running; }