public CreateTopologyControl(IKeyTableFactory tableFactory, IAsynchQueueFactory queueFactory, IPrimFactory primFactory, IModel model, IConfigSource config)
            : base(tableFactory, queueFactory, primFactory, model, config)
        {
            /*
             * //Touch Button
             * IButton floor = Factory.MakeButton("Floor", Permissions, HostPrim.ID);
             * floor.OnTouched += (source, args) =>  AddRouter(args.AvatarName, args.AvatarID, args.TouchPosition);
             */
            IConfig controlConfig = config.Configs["Control"];

            string god             = controlConfig.Get(GOD_KEY, GOD);
            string topologyDefault = controlConfig.Get(TOPOLOGY_KEY, GOD);

            _listener = (name, id, text, channel) => {
                string[] args = text.Split(' ');
                if (id.Equals(HostPrim.Owner) && args[0].ToUpper().Equals("SAVE"))
                {
                    if (args.Length > 1)
                    {
                        HostPrim.Say("Saving topology as " + args[1]);
                        Topology.SaveTopology(name, id, args[1]);
                    }
                    else
                    {
                        HostPrim.Say("Showing Dialog");
                        SaveDialog save = new SaveDialog(HostPrim, primFactory, "Topology", topologyDefault, user => Topology.GetUserFolder(god));
                        save.OnSave += (userName, userID, file) => Topology.SaveTopology(name, id, file);
                        save.Show(name, id);
                    }
                }
            };

            primFactory.OnChat += _listener;
        }
예제 #2
0
        /// <summary>
        /// Play back a previously recorded sequence of events.
        /// </summary>
        /// <param name="events">The events where the sequence of events is stored.</param>
        protected void PlayRecording(string name, UUID id, string file)
        {
            string shortFile = file;

            file = GetFile(Path.Combine(GetPath(name), _sequenceFolder), file);
            if (file == null)
            {
                throw new ArgumentException("Control event playback cannot load null file.");
            }
            if (!File.Exists(file))
            {
                throw new ArgumentException("Control event playback cannot load '" + shortFile + "'. It does not exist in the filesystem.");
            }
            XmlDocument doc = new XmlDocument();

            try {
                doc.Load(file);
            } catch (XmlException e) {
                throw new XmlException("Control event playback cannot load '" + shortFile + "'. " + e.Message);
            }

            XmlAttribute topologyAttr = doc.FirstChild.NextSibling.Attributes != null ? doc.FirstChild.NextSibling.Attributes["Topology"] : null;

            if (topologyAttr != null)
            {
                LoadTopology(topologyAttr.Value, name, id);
            }

            HostPrim.Say("Starting playback of " + shortFile);
            _reader.PlayRecording(doc, true, _timing);
            PlayEvents(name, id);
        }
예제 #3
0
        /// <summary>
        /// Write the sequence of user triggered events to an XML events.
        /// </summary>
        /// <param name="events">The method of the events to write the sequence of events to.</param>
        /// <param name="topology">The method of the topology events to load in as the start point for the sequence.</param>
        protected void SaveRecording(string name, string file, string topology = null)
        {
            if (!_recordingEnabled)
            {
                HostPrim.Say("Recording has beeen disabled in the configuration.");
                return;
            }
            string shortFile = file;

            file = GetFile(Path.Combine(GetPath(name), _sequenceFolder), file);
            if (file == null)
            {
                return;
            }

            if (topology != null)
            {
                XmlAttribute topologyAttr = _modelWriter.Log.CreateAttribute("Topology");
                topologyAttr.Value = topology;
                _modelWriter.Log.FirstChild.NextSibling.Attributes.Append(topologyAttr);
            }

            _modelWriter.Log.Save(file);
            HostPrim.Say("Saved recording as '" + shortFile + "'");
        }
예제 #4
0
        public CreateSequenceControl(IKeyTableFactory tableFactory, IAsynchQueueFactory queueFactory, IPrimFactory primFactory, IModel model, IConfigSource config)
            : base(tableFactory, queueFactory, primFactory, model, config)
        {
            IConfig controlConfig = config.Configs["Control"];

            string god             = controlConfig.Get(GOD_KEY, GOD);
            string topology        = controlConfig.Get(TOPOLOGY_KEY, null);
            string sequenceDefault = controlConfig.Get(SEQUENCE_KEY, SEQUENCE);

            if (topology != null)
            {
                Topology.LoadTopology(god, Factory.Host.Owner, topology);
            }

            _listener = (name, id, text, channel) => {
                string[] args = text.Split(' ');
                if (id.Equals(HostPrim.Owner) && args[0].ToUpper().Equals("SAVE"))
                {
                    if (args.Length > 1)
                    {
                        HostPrim.Say("Saving sequence as " + args[1]);
                        if (topology != null)
                        {
                            Record.SaveRecording(god, args[1], topology);
                        }
                        else
                        {
                            Record.SaveRecording(god, args[1]);
                        }
                    }
                    else
                    {
                        HostPrim.Say("Showing Dialog");
                        SaveDialog save = new SaveDialog(HostPrim, primFactory, "Sequence", sequenceDefault, user => Record.GetUserFolder(god));
                        save.OnSave += (user, userID, file) => {
                            if (topology == null)
                            {
                                Record.SaveRecording(god, file);
                            }
                            else
                            {
                                Record.SaveRecording(god, file, topology);
                            }
                        };
                        save.Show(name, id);
                    }
                }
            };

            primFactory.OnChat += _listener;

            Record.StartRecording();
        }
예제 #5
0
        public TopologyControl(IKeyTableFactory tableFactory, IAsynchQueueFactory queueFactory, IPrimFactory primFactory, IModel model, IConfigSource config)
            : base(tableFactory, queueFactory, primFactory, model, config)
        {
            IConfig control = config.Configs[CONTROL_CONFIG];

            if (control == null)
            {
                control = config.Configs[0];
            }

            _reposition = !control.GetBoolean("RotateWithHost", true) && control.GetBoolean("Reposition", true);
            _hostPos    = HostPrim.Pos;
            _hostRot    = HostPrim.Rotation;

            string topology = control.GetString(TOPOLOGY_KEY);
            string godName  = control.GetString(GOD_KEY, GOD);

            if (topology == null)
            {
                HostPrim.Say("Unable to start topology control. No topology file specified.");
                throw new Exception("Unable to start topology control. No topology file specified.");
            }
            Topology.LoadTopology(godName, HostPrim.Owner, topology);
            HostPrim.Say("Started Topology Control.");

            Factory.AddLinkSetRoot(Factory.Host.ID);
            IButton PauseButton = MakeButton("Pause");
            IButton StepButton  = MakeButton("Step");
            IToggle PauseToggle = new Toggle(PauseButton, 1, ToggleGlow);

            foreach (var pause in PauseToggle.Prims)
            {
                pause.Colour = Color.White;
            }

            PauseToggle.OnToggled += (source, args) => {
                Record.Paused = PauseToggle.IsOn;
                foreach (var prim in PauseToggle.Prims)
                {
                    prim.Glow   = PauseToggle.IsOn ? .1d : 0d;
                    prim.Colour = Color.White;
                }
            };
            StepButton.OnTouched += (source, args) => Model.Step();
        }
예제 #6
0
        /// <summary>
        /// Start recording all user triggered events.
        /// </summary>
        protected void StartRecording()
        {
            if (!_recordingEnabled)
            {
                HostPrim.Say("Recording has beeen disabled in the configuration.");
                return;
            }

            _currentlyRecording = true;
            if (_recordingEnabled)
            {
                _modelWriter.StartRecording();
                foreach (IXmlLogWriter writer in _writers)
                {
                    writer.StartRecording(_modelWriter.Log);
                }
            }
        }
예제 #7
0
 protected string GetFile(string folder, string file)
 {
     if (Path.IsPathRooted(file))
     {
         HostPrim.Say("Unable to get topology at '" + file + "'. Filename must be a relative path.");
         return(null);
     }
     if (!File.Exists(folder))
     {
         Directory.CreateDirectory(folder);
     }
     file = Path.Combine(folder, Path.GetFileName(file));
     if (!Path.GetExtension(file).ToUpper().Equals(".XML"))
     {
         file += ".xml";
     }
     return(file);
 }
예제 #8
0
 public void Say(string msg)
 {
     Logger.Info(msg);
     HostPrim.Say(msg);
 }