/// <summary>
        /// Unloads the scene
        /// </summary>
        /// <returns></returns>
        public override bool Close()
        {
            if (mGUIScene == null)
                return false;

            mGUIScene = null;
            return true;
        }
Exemple #2
0
        /// <summary>
        /// Constructor
        /// </summary>
        public ActionsEditor(GUIScene scene)
        {
            mScene = scene;

            InitializeComponent();

            mActionTypesComboBox.Items.Clear();
            mActionTypesComboBox.Items.Add("Add Action...");
            mActionTypesComboBox.Items.Add("Send Message");
            mActionTypesComboBox.Items.Add("Play Sound");

            mActionTypesComboBox.SelectedIndex = 0;
        }
Exemple #3
0
        /// <summary>
        /// Saves a GUIScene to disk.
        /// </summary>
        /// <param name="scene"></param>
        /// <param name="fileName"></param>
        /// <returns></returns>
        public static bool Save(GUIScene scene, XmlAttributeOverrides overrides, string filename)
        {
            FileStream fs       = null;
            bool       bSuccess = false;

            try
            {
                // First get the list of used control descriptors
                List <Type> controlDescriptors = new List <Type>();
                foreach (GUIView view in scene.Views)
                {
                    List <Type> list = GetUsedCustomControls(view.Controls);

                    foreach (Type type in list)
                    {
                        if (!controlDescriptors.Contains(type))
                        {
                            controlDescriptors.Add(type);
                        }
                    }
                }

                // Now store their names
                scene.CustomControlsUsed.Clear();
                scene.CustomControlsUsed.AddRange(controlDescriptors.Select((a) => (a.FullName)));

                fs = new FileStream(filename, FileMode.Create);
                XmlSerializer serializer = new XmlSerializer(typeof(GUIScene), overrides);

                // Prior to serialization, ensure the version is correct
                scene.Version = Otter.Properties.Settings.Default.SceneVersion;
                serializer.Serialize(fs, scene);

                bSuccess = true;
            }
            catch (Exception ex)
            {
                System.Console.WriteLine("Exception : " + ex);
            }
            finally
            {
                if (fs != null)
                {
                    fs.Close();
                }
            }

            return(bSuccess);
        }
 /// <summary>
 /// Sets the 
 /// </summary>
 /// <param name="scene"></param>
 /// <param name="ms"></param>
 private void Save(GUIScene scene, ref MemoryStream ms)
 {
     try
     {
         ms = new MemoryStream();
         XmlSerializer serializer = new XmlSerializer(typeof(GUIScene));
         serializer.Serialize(ms, scene);
     }
     catch (Exception ex)
     {
         throw new InvalidOperationException(ex.Message);
     }
     finally
     {
         if (ms != null)
             ms.Close();
     }
 }
 /// <summary>
 /// Saves the scene as an 'after' snapshot.
 /// </summary>
 /// <param name="scene"></param>
 public void SaveAfter(GUIScene scene)
 {
     Save(scene, ref mSnapshotAfter);
 }
 /// <summary>
 /// Saves the scene as a 'before' snapshot.
 /// </summary>
 /// <param name="scene"></param>
 public void SaveBefore(GUIScene scene)
 {
     Save(scene, ref mSnapshotBefore);
 }
 /// <summary>
 /// Executes the command.  Deserializes the 'before' data and creates a new scen
 /// </summary>
 /// <returns></returns>
 public override bool Undo()
 {
     mScene = Load(mSnapshotBefore);
     return mScene != null;
 }
 /// <summary>
 /// Executes the command.  Deserializes the 'after' data and creates a new scene
 /// </summary>
 /// <returns></returns>
 public override bool Execute()
 {
     mScene = Load(mSnapshotAfter);
     return mScene != null;
 }
        /// <summary>
        /// Saves the scene to disk
        /// </summary>
        /// <returns></returns>
        public override bool Save()
        {
            GUIScene scene = mGUIScene;
            if (scene == null)
            {
                if (!Exists())
                {
                    scene = new GUIScene();
                }
                else
                {
                    return false;
                }
            }

            return GUIScene.Save(scene, GUIProject.XmlAttributeOverrides, FullPath);
        }
Exemple #10
0
        /// <summary>
        /// Loads the scene, if not yet loaded.
        /// </summary>
        /// <returns></returns>
        public override bool Open()
        {
            if (mGUIScene != null)
                return true;

            mGUIScene = GUIScene.Load(FullPath, GUIProject.XmlAttributeOverrides);
            return (mGUIScene != null);
        }
Exemple #11
0
        /// <summary>
        /// Loads the GUI Scene from disk
        /// </summary>
        /// <returns></returns>
        public static GUIScene Load(string filename, XmlAttributeOverrides overrides)
        {
            GUIScene   scene = null;
            FileStream fs    = null;

            try
            {
                fs = new FileStream(filename, FileMode.Open, FileAccess.Read);
                XmlSerializer serializer = new XmlSerializer(typeof(GUIScene), overrides);
                serializer.UnknownNode      += new XmlNodeEventHandler(serializer_UnknownNode);
                serializer.UnknownAttribute += new XmlAttributeEventHandler(serializer_UnknownAttribute);
                serializer.UnknownElement   += new XmlElementEventHandler(serializer_UnknownElement);
                scene = serializer.Deserialize(fs) as GUIScene;

                foreach (GUIView view in scene.Views)
                {
                    view.Scene = scene;
                    view.PostImport();

                    // Once all the references and whatnot have been fixed up, set the
                    // sceneView's current state to be the first frame of the first channel.
                    // (effectively frame 0 of "OnActivate")
                    view.CurrentAnimationIndex = 0;
                    if (view.CurrentAnimation != null)
                    {
                        view.CurrentAnimation.Frame = 0;
                        view.CurrentAnimation.UpdateAnimations();
                    }
                }

                // TODO - perform any specific fixups here.

                // Set the scene's version to current, as it is assumed that after
                // all fixups and stuff it is now "correct"
                scene.Version = Otter.Properties.Settings.Default.SceneVersion;

                GUIProjectScene sceneEntry = GUIProject.CurrentProject.GetSceneEntry(filename);
                if (sceneEntry != null)
                {
                    scene.ID = sceneEntry.ID;
                }

                List <string> availableCustomControls = new List <string>();

                // Now cycle through our list of control descriptors and see if we're missing any plugins
                XmlAttributes attributes = overrides[typeof(Otter.UI.GUIControl), "Controls"];
                foreach (XmlArrayItemAttribute xmlAttr in attributes.XmlArrayItems)
                {
                    Type type = xmlAttr.Type;

                    // Found a custom GUIControl.  Ensure that the "ControlAttribute" is present
                    System.Attribute attribute = System.Attribute.GetCustomAttribute(type, typeof(Plugins.ControlAttribute));
                    if (attribute != null)
                    {
                        Otter.Plugins.ControlAttribute  controlAttribute  = (Otter.Plugins.ControlAttribute)attribute;
                        Otter.Plugins.ControlDescriptor controlDescriptor = controlAttribute.GetDescriptor();

                        if (controlDescriptor != null)
                        {
                            availableCustomControls.Add(type.FullName);
                        }
                    }
                }

                // We have a list of available plugins, now store the plugins we're missing (if any)
                foreach (string customControlName in scene.CustomControlsUsed)
                {
                    if (!availableCustomControls.Contains(customControlName))
                    {
                        scene.MissingCustomControls.Add(customControlName);
                    }
                }
            }
            catch (Exception ex)
            {
                System.Console.Write(ex.Message);
            }
            finally
            {
                if (fs != null)
                {
                    fs.Close();
                }
            }

            return(scene);
        }
Exemple #12
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="renderer"></param>
        public SceneView(GUIScene scene)
        {
            PromptSave = true;

            mScene = scene;
            mScene.OnTextureUpdated += new GUIScene.TextureEventHandler(mScene_OnTextureUpdated);

            mCommandManager = new CommandManager();
            mCommandManager.AddCommand(new NullCommand("- Scene -"), false);

            mCommandManager.OnCommandAdded += new CommandManager.CommandDelegate(mCommandManager_OnCommandAdded);
            mCommandManager.OnExecute += new CommandManager.CommandDelegate(mCommandManager_OnExecute);
            mCommandManager.OnUndo += new CommandManager.CommandDelegate(mCommandManager_OnUndo);

            mSelectedControls.OnItemAdded += new NotifyingList<GUIControl>.ListEventHandler(mSelectedControls_OnItemAdded);
            mSelectedControls.OnItemRemoved += new NotifyingList<GUIControl>.ListEventHandler(mSelectedControls_OnItemRemoved);

            InitializeComponent();
        }
Exemple #13
0
 /// <summary>
 /// Constructor
 /// </summary>
 public MessagesEditor(GUIScene scene)
 {
     mScene = scene;
     InitializeComponent();
 }
Exemple #14
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="scene"></param>
 /// <param name="view"></param>
 public AddViewCommand(GUIScene scene, GUIView view)
 {
     mScene = scene;
     mView = view;
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="scene"></param>
 /// <param name="view"></param>
 public DeleteViewCommand(GUIScene scene, GUIView view)
 {
     mScene = scene;
     mView = view;
     mIndex = mScene.Views.IndexOf(mView);
 }