Пример #1
0
        public static MacroSet LoadTextMacroSet(string fileName)
        {
            MacroSet macroSet = new MacroSet();
            string   path     = Engine.FileManager.BasePath(string.Format("data/ultima/macros/{0}.txt", (object)fileName));

            if (File.Exists(path))
            {
                using (StreamReader ip = new StreamReader(path))
                {
                    string line1;
                    string line2;
                    while (true)
                    {
                        line1 = Macros.ReadLine(ip);
                        if (line1 != null)
                        {
                            if (line1.Length == 5)
                            {
                                string[] strArray = line1.Split(' ');
                                if (strArray.Length == 3)
                                {
                                    bool flag = true;
                                    for (int index = 0; flag && index < strArray.Length; ++index)
                                    {
                                        flag = strArray[index] == "0" || strArray[index] == "1";
                                    }
                                    if (flag)
                                    {
                                        Keys keys1 = Keys.None;
                                        if (strArray[0] != "0")
                                        {
                                            keys1 |= Keys.Control;
                                        }
                                        if (strArray[1] != "0")
                                        {
                                            keys1 |= Keys.Alt;
                                        }
                                        if (strArray[2] != "0")
                                        {
                                            keys1 |= Keys.Shift;
                                        }
                                        line2 = Macros.ReadLine(ip);
                                        if (line2 != null)
                                        {
                                            Keys keys2 = Keys.KeyCode | Keys.Modifiers;
                                            switch (line2)
                                            {
                                            case "WheelUp":
                                            case "Wheel Up":
                                                keys2 = (Keys)69632;
                                                break;

                                            case "WheelDown":
                                            case "Wheel Down":
                                                keys2 = (Keys)69633;
                                                break;

                                            case "WheelPress":
                                            case "Wheel Press":
                                                keys2 = (Keys)69634;
                                                break;

                                            default:
                                                try
                                                {
                                                    keys2 = (Keys)Enum.Parse(typeof(Keys), line2, true);
                                                    break;
                                                }
                                                catch
                                                {
                                                    break;
                                                }
                                            }
                                            if (keys2 != (Keys.KeyCode | Keys.Modifiers))
                                            {
                                                MacroData data = new MacroData();
                                                data.Key  = keys2;
                                                data.Mods = keys1;
                                                string command;
                                                while ((command = Macros.ReadLine(ip)) != null && !command.StartsWith("#"))
                                                {
                                                    int    length = command.IndexOf(' ');
                                                    Action action = length < 0 ? new Action(command, "") : new Action(command.Substring(0, length), command.Substring(length + 1));
                                                    if (action.Handler == null)
                                                    {
                                                        Debug.Trace("Bad macro action: {0}", (object)command);
                                                    }
                                                    data.Actions.Add(action);
                                                }
                                                macroSet.Macros.Add(new Macro(data));
                                            }
                                            else
                                            {
                                                goto label_26;
                                            }
                                        }
                                        else
                                        {
                                            goto label_36;
                                        }
                                    }
                                    else
                                    {
                                        goto label_11;
                                    }
                                }
                                else
                                {
                                    goto label_6;
                                }
                            }
                            else
                            {
                                break;
                            }
                        }
                        else
                        {
                            goto label_36;
                        }
                    }
                    Macros.Skip(line1, ip);
                    goto label_36;
label_6:
                    Macros.Skip(line1, ip);
                    goto label_36;
label_11:
                    Macros.Skip(line1, ip);
                    goto label_36;
label_26:
                    Macros.Skip(line2, ip);
                }
            }
label_36:
            return(macroSet);
        }
Пример #2
0
 public static void Reset()
 {
     Macros.StopAll();
     Macros.m_Current = (MacroSet)null;
     Macros.m_Current = Macros.Current;
 }
Пример #3
0
 public static void Save()
 {
     XmlPersistanceWriter.SaveObject((PersistableObject)Macros.Config, Macros.GetConfigurationPath());
 }